Helpful Unix Terminal Commands
Boldface is what you type at the command line.
command is the name of the command.
(If you know a command and doesn’t know how to use it, type man name_of_command. The man
page will tell you all you need to know about using the command)
• Make directory (mkdir directory_name)
• Change Directory/Folder (cd directory_name)
• List contains of directory (ls)
• Remove directory (rmdir directory_name)
• Rename directory (mv directory_name_old directory_name_new)
Make a directory called mydoc mkdir mydoc
Enter directory mydoc cd mydoc
To list contents of directory ls
(if you are in mydoc)
To list contents of directory ls mydoc
To return to home cd ..
To remove mydoc rmdir mydoc
To rename a directory mv mydoc mydoc-new
Print Working Directory
• Display current working directory ( pwd )
Show current working directory pwd
• Create a file (emacs filename) — more on this in another document!
(many ways of doing this, pick your favorite editor!, we will use emacs here)
• Copy a file (cp filename_source filename_destination)
• List a file (ls filename)
• Rename a file (mv filename_old filename_new)
• Remove a file (rm filename)
Create a file emacs test.cpp (save: ctrl-x-s, exit: ctrl-x-c)
Copy a file cp test.cpp new.cpp
List a file ls test.cpp
Rename a file mv new.cpp new2.cpp
Remove/Delete a file rm test.cpp
• Compile a file (CC -o filename filename.cpp)
• Execute (filename)
Compile a file CC -o hello_world hello_world.cpp
Execute hello_world (observe the output)
Well, the followings are not shortcuts to get your programming assignments completed. However,
some of these can help to make ‘life’ much easier!
• List the commands that you have used (history)
• Re-execute the last command (!!)
List the command history history
Pick a command to re-execute !# (# obtain from history list)
Re-execute the last command !!
Repeat Compilation !CC