Add 2 new commands and some word edits (#23942)
Add 2 new commands and some word edits
This commit is contained in:
committed by
Huyen Nguyen
parent
b7564a5886
commit
97616fe6fa
@@ -8,15 +8,29 @@ title: Mac OS Terminal
|
||||
Most of the time users interact through a Graphical User Interface to interact with the computer. You use the mouse to point and click to open, move, or create new files or open applications. But, you can also use the Terminal Application to interact with your machine through written commands. When you use the terminal, it allows you to dig deeper and customize in a way not possible through the GUI.
|
||||
|
||||
### Opening the Terminal and Navigating Directories
|
||||
Your terminal exists in the Applications directory. Open your Terminal app. You should see a prompt in the terminal window. it shoudl have the computer's name (ABC's Macbook), followed by the User name (ABC), and then a '$.' If you are in the root directory, the last character will be a '#.'
|
||||
Your terminal exists in the Applications directory. Open your Terminal app. You should see a prompt in the terminal window. It should have the computer's name (ABC's Macbook), followed by the User name (ABC), and then a '$'. If you are in the root directory, the last character will be a '#'.
|
||||
|
||||
To see what directory you are working in, use ```pwd``` which stands for "print working directory"
|
||||
Directory is another word for folder.
|
||||
To see what directory you are working in, just type the command:
|
||||
|
||||
If you want to list the directory's contents, use ```ls```
|
||||
```
|
||||
pwd
|
||||
```
|
||||
|
||||
To change directories, use ```cd <directory_path>``` which stands for change directory and replace the angle brackets with the appropriate path name.
|
||||
If you are currently in `Documents` and want to move into the directory/folder `hello_world` which is inside `Documents` use `cd hello_world`
|
||||
`pwd` stands for "Print Working Directory". Directory is another word for folder.
|
||||
|
||||
If you want to list the contents of your directory, use the command:
|
||||
|
||||
```
|
||||
ls
|
||||
```
|
||||
|
||||
To switch to a new directory you, use the command:
|
||||
|
||||
```
|
||||
cd <directory_name>
|
||||
```
|
||||
|
||||
`cd` stands for "Change Directory". ```cd``` is then followed by the directory's name you wish to switch into.
|
||||
|
||||
Here is a list of common commands:
|
||||
|
||||
@@ -24,11 +38,13 @@ Command | Usage
|
||||
------------ | -------------
|
||||
`pwd` | Print Working Directory (Where Am I? )
|
||||
`ls` | List contents of current directory
|
||||
`mkdir <directoryname>` | Create a new directory
|
||||
`touch <filename>` | Create a new file
|
||||
`cp <filetobecopied> <nameforcopiedfile>` | Copy a file
|
||||
`mkdir <directory_name>` | Create a new directory
|
||||
`rmdir` | Remove directory
|
||||
`touch <file_name>` | Create a new file
|
||||
`cp <file_to_be_copied> <name_for_copied_file>` | Copy a file
|
||||
`mv` | Rename a file/directory
|
||||
`rm <filename>` | Remove a file
|
||||
`rm -rf <directoryname>` | Forcibly remove a directory
|
||||
`rm -rf <directory_name>` | Forcibly remove a directory
|
||||
|
||||
### Usage Examples
|
||||
|
||||
@@ -36,13 +52,17 @@ Some of the aforementioned commands aren't clear without examples. Below are a f
|
||||
|
||||
#### Making a Directory
|
||||
|
||||
```mkdir #YOUR-NEW-FOLDER-NAME-HERE```
|
||||
```
|
||||
mkdir folder_name
|
||||
```
|
||||
|
||||
#### Making a File
|
||||
|
||||
``` touch YOUR-FILE-NAME.JS```
|
||||
```
|
||||
touch file_name.js
|
||||
```
|
||||
|
||||
You can make a file with any extension you choose. As long as it is in an a format accepted by the folder or machine.
|
||||
You can make a file with any extension you choose. As long as it is in a format accepted by the folder or machine.
|
||||
|
||||
#### Copying a File
|
||||
|
||||
@@ -52,19 +72,27 @@ Use the following syntax to copy a file from the terminal:
|
||||
|
||||
For example, if we have a file, _'test.txt'_ that is stored in our _/Desktop_ directory and we want to copy it to the _/Documents_ folder, our command would look like this:
|
||||
|
||||
```
|
||||
cp ~/Desktop/test.txt ~/Documents
|
||||
```
|
||||
|
||||
#### Deleting a File
|
||||
|
||||
Use the following syntax to delete a file
|
||||
Use the following syntax to delete a file.
|
||||
|
||||
**rm _#PATH_TO_FILE_**
|
||||
```
|
||||
rm <path_to_file>
|
||||
```
|
||||
|
||||
#### Detect which process is using the port you want to use
|
||||
``` lsof -i :<PORT> ```
|
||||
```
|
||||
lsof -i :<port>
|
||||
```
|
||||
|
||||
#### Terminate the process which uses the port you want to use
|
||||
``` kill <PID> ```
|
||||
```
|
||||
kill <pid>
|
||||
```
|
||||
|
||||
|
||||
#### Previewing file
|
||||
|
Reference in New Issue
Block a user