In the following examples, "noob" will be used as the username. You will not ever type this in, it will just serve as reference for what you will actually see within terminal. For example, if your username is bob, your prompt will look like bob$
instead of noob$
.
Anywhere that you see something within carets, this is an argument placeholder and should be replaced when writing the actual command, for example mkdir <directory location or name>
would be written as something like mkdir example
.
ls
- List contents of current directory
cd
- Change directory
pwd
- Print current "working" directory path
List the contents of the current working directory
noob$ ls
Desktop Downloads Movies Pictures
Documents Library Music Public
Print the current working directory path
noob$ pwd
/Users/noob
Change directory into Downloads
noob$ cd Downloads/
List the contents of the Downloads directory
noob$ ls
About Downloads.lpdf
Check to make sure we are in the Downloads directory
noob$ pwd
/Users/noob/Downloads
Change directory to the parent directory
noob$ cd ..
A shortcut to get you to the home directory
noob$ cd ~
Check to make sure we are back at our user home directory
noob$ pwd
/Users/noob
touch <file location>
- Create a new file
mkdir <directory location or name>
- Make a new directory
cp <file to copy> <location to copy to>
- Copy a file or directory
mv <file to move> <location to move to>
- Move a file or directory
rm <file to remove>
- Remove/delete a file or directory
List the contents of the Desktop directory
noob$ ls
hello_world
Make a new directory called "examples"
noob$ mkdir examples
List out the contents of Desktop to see the new examples directory
noob$ ls
examples hello_world
Change directory into the examples directory
noob$ cd examples/
Create and index.html file within examples
noob$ touch index.html
noob$ ls
index.html
Copy the index.html file and name the new file home.html
noob$ cp index.html home.html
noob$ ls
home.html index.html
Rename home.html by using the move command and giving it a new name, about.html
noob$ mv home.html about.html
noob$ ls
about.html index.html
Remove/delete the about.html file
noob$ rm about.html
noob$ ls
index.html