CLI - General - Macintosh

Useful command line tools for Macintosh OS X.

  1. ls -alh; Lists a directory with a: all and that includes invisibles, l: long listing, h: human readable.
  2. pwd; Print working directory, the directory you are in.
  3. cd; Change directory, cd / takes you to the root, cd .. takes you up one directory, can also use a full path or drag a directory/file onto the Terminal window.
  4. . (one dot); executes the command in the current location.
  5. .. (two dots); goes up one level or results in a cp or mv occurring in the above directory.
  6. * (asterisk); executes the command on everything in the directory it's pointing to.
  7. tab; auto completes command and files or folders in a directory.
  8. cat; opens a text file for reading, can be used to append a text file to the end of another using the >> redirect.
  9. mkdir; maked a directory at the current location, -p switch will also create the intermediate folders if they don't already exist.
  10. cp; will copy items from one location to another resulting in the items being in both places.
  11. mv; will move items from one location to another resulting in the items being only in the place to which they are moved.
  12. rm; removes the items listed. They are deleted immediately without confirmation.
  13. rmdir; deletes a folder but it must be empty.
  14. rm and rmdir with -R; this will delete items recursively in a folder.
  15. which; followed by a list of commands will tell you which directory they are in, usually bin or sbin.
  16. sudo; super user temporarily.
  17. su; substitute user to some other user;