Unix Command Summary |
update Sept. 4, 2016 |
This page is only intended as a quick reference summary, rather
than an exhaustive description of Unix.
All Unix commands take the following form: command options filenames Options begin with a dash. Usually, several options can be combined. Examples: ls -l *.txt |
Return to Using Unix
Logging in and logging out |
|
login: userid |
ends session |
To change password |
|
|
|
Hints: 1. The passsword should be a mixture of letters
(upper and lowercase), numbers and symbols. It should
not be a word that would occur in a dictionary. |
Environment variables hold values such as the paths to files or directories, or parameters required by a program. The names of environment variables begin with a dollar sign ($). Environment variable names may be either upper or lowercase. |
|
$HOME |
User's home directory |
Hints: |
To list files in a directory |
|
ls |
list files in current directory |
Hints: It is best to make a habit of using 'ls -l', which gives more complete information. |
To change to a new working directory |
|
cd directoryname |
move to a new directory |
Hints: The chacter '~' refers to the $HOME directory. '.' refers to the current directory. '..' refers to the parent directory. |
To send output to the screen or to a file
|
|
echo "Just some words" |
prints message to the terminal |
Hints: The chacter '>' redirects output of a command to a file. |
To show the contents of a file
|
|
cat file1.txt |
prints contents of file1.txt to the terminal |
File permissions |
permissions |
Hints: Fields are produced by the ls -l command are described below: Directory: d if it is a directory, - if it is a file Permissions, read (r) write (w) and execute (x). The set of three permissions refers to the owner. The second refer to the group. The third refer to the world (ie. all users on the system). In the example above, all files are readable and writeable by the owner, but group and world have no permissions. Note that directory 'sv40' is executable. To search (eg. list files in) a directory, you must have execute permissions for that directory. Owner: owner of the file or directory Size: size of file or directory in bytes Date/time: data and time file or directory was created Name: name of file or directory |
To change permissions for a file |
|
chmod a-w filename |
write protect, world |
Hints: Permissions can also be set using three-bit code to specify read, write and execute permissions for all users. Type 'man chmod' for a complete description. |
To copy a file |
|
cp originalfilename newfilename |
copy a single file |
Hints: |
To remove a file |
|
rm filename |
remove a file |
Hints: Remove can not be undone |
To rename or move a file |
|
mv oldfile newfile |
rename a file |
Hints: |
To print a file at the lineprinter |
|
lpr filename |
prints at your default printer |
Hints: Only ASCII text files and PostScript files (.ps) can be printed directly to a printer using lpr. Other files, such as spreadsheets and wordprocessor documents must be printed from within the application. |
To edit an ASCII text file |
|
gedit filename |
GNOME graphic text editor |
Hints: A text editor is essentially a word processor specialized for viewing and modifying ASCII text. ASCII text files contain nothing but charcters. There is no special formatting, such as underlining, bold type, pagination, embedded figures and tables etc. |
To view a file on the screen |
|
less filename |
view a screenful at a time. <spacebar> moves down one page; |
Hints: head and tail are the fastest way to find out what is in a very large file, such as a file containing hundreds of thousands or millions of sequencing reads. Many text editors with will not be able to load such large files, or will take a long time doing so. |
To run any programIf the program is found in one of the directories specified in $PATH, simply type the name of the program. If the executable is not in the $PATH, you must specify the path to the program. |
|
numseq |
run a program called 'numseq'. |
Hints: |
Redirection of input and outputMany programs take input from the standard input, and send output to the standard output. Input and output can be redirected to and from files, and piped from one program to the next > redirect output to a file < take input from a file >> apend output to the end of an existing file << take input until ctrl-D is encountered | pipe output from one program to another program |
|
echo "Are we having fun yet?" |
writes message to the standard output (ie. screen) |
Listing and terminating jobs running on the host to which you are logged in |
|
ps |
list all jobs running in the current shell |
Hints: These commands only work for a single login host. For example, if you have jobs running on two hosts eg. antares and deneb, and you are logged into deneb, ps or top will only show jobs running on deneb. To see jobs running on antares, you must log into antares. |
Online manual pages |
|
man command |
view the manual pages for a command, |
Hints: All Unix commands have man pages. Many, but not all other applications have man pages. |
To transfer files across the network |
|
ftp hostname |
opens an interactive session to another host. This protocol |
Hints: Type ? to see a list of commands in ftp and sftp. |
Login to a remote host |
|
ssh hostname |
logs into host under your current userid |