Skip to content

Command line references

James Dabbs edited this page Jun 15, 2015 · 3 revisions

More extensive reference here.

Commands

Replace <file> with the path to / name of the file you want to act on

  • ls - list the contents of a directory
  • ls -al - show hidden files, long-form view
  • pwd - show path to current directory
  • cd <directory> - change directory
  • cp <from> <to> - copy
  • mv <from> <to> - move (also used to rename)
  • rm <file> - remove (delete) a file
  • rm -rf <directory> - really really delete (:warning:)
  • cat <file> - print contents of file to the terminal
  • less <file> - open up a paged reader for a file
  • subl <file> - open up a file in Sublime (assuming you've set up command line extensions)

Notes

  • ~ is a shorthand for your home folder. It is typically the same as /Users/YourUserAccountName
  • . means the current directory; .. means the parent directory (one level up)
  • Directory paths can be given relative to your current location (e.g. cd code) or absolute (e.g. cd ~/code)
  • Press tab to autocomplete as much of the path as the shell can determine
  • Most commands take a --help or -h option to display a help page. Alternatively, man shows the manual page for a given command.
  • You should probably configure your prompt to at least show the current working directory at all times so that you know where you are (reference link needed).