Cheat sheet for the Unix and Linux terminal

Terminal Shortcuts

To
“play back” old commands, press the up-arrow key on your keyboard.

To make the Terminal “guess” what you will type next, press the tab key.

To
kill a program that you are running, press control-C

To freeze the output of a program, press control-S

To “unfreeze” the program, press control-Q

Unix or Linux Organization
unix_linux_organization

Terminal Commands


Command name - meaning:

pwd - pwd means “
print working directory”
What it does:
pwd tells you “where” you are right now.

Command name - meaning:

cd - cd means “
change working directory” or “change the folder we’re in right now”
What it does:
cd takes you from one directory to another. Like clicking on a folder to open it up.
Example:
$ pwd # pwd tells us what directory we’re in right now.
/Users/halver
$ cd mystuff # Takes us from where we are now, to the directory “mystuff”
$ pwd # What directory we are in right now?
/Users/halver/mystuff
$ # It worked!
$ cd .. # New we go back “down” to where we were before
$ pwd # What directory we are in right now?
/Users/halver
$ # It worked again!

Command name - meaning:
mkdir - mkdir means “
make a new directory”
What it does:
mkdir creates a new directory. (A directory is the same
thing as a folder.)
Example:
$ mkdir junk # This will create a new directory (folder)
called junk

Command name - meaning:
cp - cp means “
copy”
What it does:
cp duplicates a file (in other words, it makes a copy
of a document)
Example:
$ cp hello.py hello2.py # This will copy the file hello.py
to a new file called hello2.py

Command name - meaning:
rm - rm means “
remove”
What it does:
rm delete a file or document. This is permanent - there is
no “undelete”
Example:
$ rm junk.py h # This will delete the file called junk.py

Command name - meaning:
mv - mv means “
move”
What it does:
mv can move a file (a document) to another place on the
disk. It can also rename a file.
Example:
$ mv hello.py ugly.py #This will rename the file
“hello.py” to “ugly.py”
Example:
$ mv ~/Desktop/report.doc ~/Documents/report.doc #This will
move “report.doc” from the Desktop directory to the
Documents directory.
Example:
$ mv ~/Desktop/report.doc ~/Documents/. #This will
do the same thing as the previous line. The “.” is another
shortcut and it means “here” so you are moving report.doc
to the Documents directory without changing the name.



There are many on-line references for the Terminal commands. Here is one: http://linuxcommand.org/lc3_learning_the_shell.php