A Linux Command Quick Reference
RRN runs Linux operating system with a default Bash shell. (A shell is an environment to interact with the Linux system and run other programs.) If you are not familiar with Linux command, the two tutorials below can get you started.
- The Unix Shell by Software Carpentry.
- Learning the Shell by William Shotts.
Below we also provide a quick reference to some commonly used Linux commands.
- Basics
- man <commmand>: display help manual for- <command>, e.g.,- man man. Hit the key- qto quit the manual display.
- whoami: display your user name.
- \(\uparrow\) key: get the previous command you used.
- TABkey: auto-complete a command when there is no ambiguity. For example, type- whoaand then hit the- TABkey.
 
- Files and directories: basic navigation
- .: single dot is not a command. It stands for current directory.
- ..: double dots stands for parent directory.
- ~: tilde stands for home directory.
- pwd: print work directory, i.e. find out your current directory.
- ls: list files and directories in the current directory.
- ls -alh:- lswith options- a(list all files including the hidden ones)- l(display in long list format) and- h(show file size in human-readable unit).
- cd dirname: change directory to- dirname. For example,- cd ..takes you to the parent directory.
- cdor- cd ~: go to your home directory.
 
- Files and directories: create, copy, rename and delete
- mkdir dirname: create a new directory (in the current directory).
- rmdir dirname: delete a directory (only works when the directory is empty).
- rm -r dirname: delete a directory including files and sub-directories inside it. Use with caution!
- cat filename: display the content of a (text) file.
- more filename: display (text) file content one screen at a time. Hit- spacefor next screen, and- qto quit.
- nano filename: create or edit a file.- nanois a text editor pre-installed on RRN. It’s easy to use and great for simple text editing. Other editors available on RRN are- gedit,- vimand- emacs.
- rm filename: delete a file.
- mv oldname newname: rename a file or directory from oldname to newname.
- mv file_dir dir: move a file or directory to another directory. For example,- mv *.txt ..moves all files with- txtextension to the parent directory. Asterisk- *is a wildcard representing any sequence of characters.
- cp file dir: copy a file to another directory.
- cp -r dir1 dir2: copy a directory (- dir1) including files and sub-directories to another directory- dir2.