Working with directories
Changing directory
The cd
(change directory) command is used to, well, change directory. This allows you to change where you are 'standing' at the command line.
Examples
- Change to your home directory:
cd ~
- Change to your documents directory:
cd ~/Documents
- Change to an absolute path:
cd /Users/bob/Music
Making
mkdir
will make a directory
Examples
- Make a directory 'test' in the current directory
mkdir test
- Make a directory 'test' at a specific location
mkdir /Users/alice/documents/test
Deleting directories
rm -rf
(rm: remove) will delete a directory.
Examples
- Delete a directory 'test' in the current directory
rm -rf test
- Delete a specific 'test' directory
rm -rf /Users/alice/documents/test
Note: 'rm -rf' is dangerous - it will delete all files and subdirectories without any prompt or ability to undo. Be very sure of the path you have told rm to remove before pressing ENTER