Unix Command Cheat Sheet
Basic linux commands you need to know like breathing air
ls
- list the contents of the current directorypwd
- print the present working directory - tells you where you are currently. The format is something like/home/myID
- just like on most computer systems, this represents leaves on the tree of the file system structure, also called a "path".cd <whereto>
- change the present working directory to<whereto>
You will need to provide a path like /work/myID to change to that directory.- Some special
<wheretos>
:..
(period, period) means "up one level". . means current directory. ~ (tilde) means "my home directory".~myfriend
(tilde "myfriend) means "myfriend's home directory".
- Some special
nano - The text editor we'll be using
df
shows you the top level of the directory structure of the system you're working on, along with how much disk space is availablehead <file>
andtail <file>
shows you the top or bottom 10 lines of a file<file>
more <file>
andless <file>
both display the contents of<file>
in nice ways. Read the bit above aboutman
to figure out how to navigate and search when usingless
file <file>
tells you what kind of file<file>
is.cat <file>
outputs all the contents of<file>
- CAUTION - only use on small files.rm <file>
deletes a file. This is permanent - not a "trash can" deletion.cp <source> <destination>
copies the filesource
to the location and/or file namedestination
}. Using.
(period) means "here, with the same name". *cp -r <dirname> <destination>
will recursively copy the directorydirname
and all its contents to the directorydestination
.scp <user>@<host>:<source> <destination>
works just like cp but copiessource
from the useruser
's directory on remote machinehost
to the local filedestination
mkdir <dirname>
andrmdir <dirname>
make and remove the directory "dirname". This only removes empty directories - "rm -r <dirname>" will remove everything.wget <url>
fetches a file with a valid URL. It's not that common but we'll usewget
to pull data from one of TACC's web-based storage devices.- man <unixcommand> displays the manual page for a unix command.
- > is used to redirect STDOUT and STDERR to files.
Wildcards and special file names
The shell has shorthand to refer to groups of files by allowing wildcards in file names. *
(asterisk) is the most common; it is a wildcard meaning "any length of any characters". Other useful ones are []
to allow for any character in the set <characters>>
...