A short introduction to the most commonly used Unix (Linux) commands. For more info, read a book1or read the info pages.
Welcome to McGill.
Before we start, let's talk about a few basic rules you must respect.
[email protected]
(Paul and
Juan).
Changing Password
yppasswd
: Changes your password.
info
: To find out about a command.
(ex) info lpr
To search info pages for a keyword
info --apropos=keyword
man
: To read a manual page about a command.
(ex) man lpr
ls
: Lists files and subdirectories in the present directory.
mkdir
: To make a directory.
(ex) mkdir sub_dir
rmdir
: To remove an empty directory.
(ex) rmdir sub_dir
cd
: ``change directory"
(ex) cd sub_dir
pwd
: ``print working directory''
cp
: To copy a file or a directory.
(ex) cp original copy
(ex) cp -r original_dir copy_dir
(Be careful with this!)
mv
: To move a file or a directory.
(ex) mv old_name new_name
rm
: To remove a file.
(ex) rm file
more
or less
: To read a file.
(ex) less unix.txt
nedit
, kdedit
, vi
, emacs
:
To edit a file.
(ex) nedit unix.txt
tar
: To collect a number of files and directories in one big
file.
To make : tar cvf all_files.tar file1 file2 files*
To un-tar : tar xvf all_files.tar
gzip
or bzip2
: To compress a big file.
(ex) gzip all.tar
gunzip
or bunzip2
: To decompress a zipped file.
(ex) gunzip all.tar.gz
gcc
or cc
: C Compiler.
(ex) gcc -o prog_name file.c files.*.c -lm
g77
or f77
: Fortran 77 Compiler.
(ex) g77 -o prog_name file.f files.*.f
qsub
: To submit to the batch que.
<ctrl>c
: To interrupt a running program.
<ctrl>z
: To suspend a running program.
bg
: To run the suspended job in the background.
fg
: To run the suspended job in the foreground or to bring
a job in the background to the foreground.
jobs
: To list your jobs running in the background.
ps -u
: To list all of your processes
kill
: To kill a job or a process
LATEX, PostScript, PDF, Printing
latex
: To latex a LATEXfile.
(ex) latex unix.tex
xdvi
: To preview a .dvi
file on an X-terminal.
(ex) xdvi unix.dvi
dvips
: To make a PostScript (ps) file from a dvi file
to preview or to print.
(ex) dvips unix.dvi -o unix.ps
gv
: To preview a ps file or a pdf file.
(ex) gv unix.ps
dvips -Ppdf
: To make a pdf-ready ps file
(ex) dvips -Ppdf unix.dvi -o unix.ps
ps2pdf
: To make a pdf file from a ps file.
(ex) ps2pdf unix.ps
acroread, xpdf, gv
: To preview and print a pdf file.
(ex) acroread unix.pdf
(ex) xpdf unix.pdf
lpr
: To print a PostScript file or a text file.
(ex) lpr unix.ps
lpstat
or lpq
: To ask a printer how it is doing.
pine
: To read and send e-mails.
enter
.
c
.
r
.
d
.
s
.
<, >
pine
, press q
.
mail [email protected] < file
: To send an ascii
file without going
through an e-mail program.
mozilla &
: To run the web-browser Mozilla in the background
~/WWW
: Your McGill homepage location if you are with
HEP/TNP/ASTRO.
/WWW/user_name
: Your McGill homepage location
if you are with CMP/GANG.
ssh [email protected]
:
To securely login to other computers. Also use this to connect from home.
scp
: To securely copy a file from one machine to another.
(ex) scp file_1 [email protected]:file_2
(ex) scp [email protected]:file_1 file_2
sftp
: To securely transfer files from one account another
ssh
and do
pine
.
Or, configure your browser/outlook
with IMAP with SSL and set the Incoming server to
hepmailhost.physics.mcgill.ca
(for HEP/TNP/ASTRO)
or imap.physics.mcgill.ca
(for CMP/GANG).
SMTP is mx1.hep.physics.mcgill.ca
port number 587.
ypchsh
: To switch your shell globally. Default is tcsh
.
chmod
: To change the attribute of a file or a directory.
Usage: chmod [ugoa][+-][rwx] file
df
: To check filesystem disk space usage
du
: To check your own disk space usage
convert
: To convert one graphics format to another.
(ex) convert picture.eps picture.jpg
display
: To view a graphics file
(ex) display picture.jpg
nice
: To be nice to other people using the same machine
(ex) nice convert huge_picture.eps huge_picture.jpg
<
: Treat the lines in a file as keyboard inputs
(STDIN: standard input).
(ex) prog < input_dat
>
: To
redirect the standard output (STDOUT) of a program to a file.
(ex) prog < input_data > output_data
>>
: To append the output of a program to a file.
(ex) prog < input_data >> output_data
|
: Pipe. To pass STDOUT as a file.
(ex) grep verb unix.tex | less
grep
: To globally search for a regular expression and print the
lines containing it.
(ex) grep verb unix.tex