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

  1. Change to your home directory: cd ~
  2. Change to your documents directory: cd ~/Documents
  3. Change to an absolute path: cd /Users/bob/Music

Making

mkdir will make a directory

Examples

  1. Make a directory 'test' in the current directory mkdir test
  2. Make a directory 'test' at a specific location mkdir /Users/alice/documents/test

Deleting directories

rm -rf (rm: remove) will delete a directory.

Examples

  1. Delete a directory 'test' in the current directory rm -rf test
  2. 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