Generalities:
- Warning: The information below is more often than not
incomplete. To see all the details, check the man
pages.
- The syntax and arguments described below are specific for Linux.
There might be small differences for Unix.
- To run a command in the background, put an & at its end
(e.g.: emacs &).
This will return the "shell-prompt", so that you can use the shell
while the command you just issued is running (otherwise, you have to
wait until the last command terminates before you can issue another
command in the same shell).
- To STOP the job running in the foreground use CONTROL-Z; it
can be resumed with fg. To KILL it, use
CONTROL-C.
- Notational conventions:
- an item enclosed between < and > has to be substituted
by the appropriate value;
- an item enclosed between [ and ] is optional.
- the vertical bar | means "or".
- Commands:
Some commands are discussed below in more detail, for the other
check the man/info-page.
- help
- man, info (better organized
man-pages; see more in the Emacs
section, under the Info node)
- navigation and file handling
- ls, cd, mkdir, mv, rm, cp, tar,
pwd, dirs, pushd,
popd
- file viewing (without editing)
- more, less (the latter is
more powerful)
- file editing
- emacs (my preference), vi
- printing
- lpq, lprm, lpr, kprinter
- e-mail
- thunderbird (by mozilla), alpine,
mail
- (La)TeX related
- xdvi, dvips, dvipdf, pdflatex, vlatex
- images
-
- to view: ghostview, gv,
acroread, display, okular (supports many formats); xpdf, xv
are no longer supported
- to create: xfig
- image processing:
-
convert file.jpg file.pdf (many more formats are handled)
- collect PDF files into a single one:
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=new.pdf
-dBATCH OLDFILES
- remote access
- ssh, scp,
ftp, xon
- file permissions and ownership
- chmod, chown, chgrp
- job management
- jobs, bg,
fg, ps (check processes), kill (kill a
process or job)
- other shells
- csh, tcsh
- execute commands from a file
- source
- shell scripts
- other commands (see their man page)
-
- rename: rename more files with one command
- dos2unix, unix2dos: convert text files
between unix/linux and windows (the newline character is
different)
- image conversions: e.g. convert file.jpg
file.pdf
- combine more PDF files into single one:
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=all.pdf
-dBATCH FILES
Linux (or UNIX) Commands:
- man
-
- purpose: on-line manual for Unix (or Linux)
- usage: man <program_name> or man -k <keyword>
- examples:
- man man describes the use of the manual
- man -k print lists commands that refer to printing
- pwd
-
- purpose: print position in the file system (Print
Working Directory); see also dirs
- usage: pwd
- cd
-
- purpose: Change Directory
- usage: cd <directory_to_go>
- remarks:
- If no target directory is specified, cd will change
to the home directory, ~
- A directory can be specified relative to the current location,
or by a full pathname.
A full pathname begings with a forward-slash, /, or a
tilde, ~.
A ~ by itself denotes the user's home directory.
See the examples below.
- examples:
- cd papers
changes to the subdirectory papers of the
current directory
- cd ~/images
changes to the directory ~/images, which is the
directory images in the user's home directory; note that
the full path is given!
- cd /home/HOMER
changes to the directory /home/HOMER, given by a
full path
- cd ~euclid
changes to the home directory of the user whose login-name
is euclid
- dirs
-
- purpose: print position in the file system, use
~ if we are inside the home directory; see also pwd
- Note: actually, dirs prints the whole directory stack;
the current directory is the first in the list. To learn more about this
stack, look at
pushd
and popd
.
- usage: dirs
- ls
-
- purpose: list content of a directory, or information about files
(LiSt)
- usage: ls [-ladR] [<file_names>
<directory_names>]
- if no file or directory is specified, it lists the content
of the current directory
- -a shows all files (including those that start
with a dot)
- -l shows the long form, describing permissions,
size etc.
- -d lists directory entries instead of their
content
- -R descends recursively through the directories
- examples:
- ls -al ~ gives long information for the
whole content of your home directory
- ls -ld ~ gives long information only
about your home directory, not its content
- mkdir
-
- purpose: create a new directory (MaKe DIRectory)
- usage: mkdir <directory_name>
- chmod
-
- purpose: change read/write/execute permissions (CHange MODe)
- usage: chmod [-R] <whoHOWwhat> <target>
- who is any combination of
- u for user
- g for group
- o for other
- a for all (i.e., user, group and others)
- HOW can be one of
- = for set
- + for add
- - for remove
- what is any combination of
- r for read
- w for write
- x for execute
- target is a list of files and directories
- -R causes chmod to descend recursively
through the directories
- examples:
- chmod -R go-rw my_papers protects the directory
my_papers, and any file or directory beneath
it, from being read/written by group and others
- chmod a+r index.html adds for everyone the permission
to read the file
index.html
- fg
-
- purpose: brings jobs that are suspended or in the background to
the foreground (ForeGround)
- Note: an alternative to fg is to issue the command
%job_number, or %first_few_letters. E.g.:
%2 will bring to the foreground the job having number 2,
%em will do the same for emacs (assuming there
is a unique match)
- usage: fg [job_specification]
- job_specification can be %job_number
or %first_few_letters (as above)
- if job_specification is missing,
fg will resume the current
job
- otherwise, it will resume the specified job
- to find the job numbers, use the command jobs.
- examples: fg %1, fg %em
- bg
-
- purpose: takes jobs that are suspended to the background
(BackGround)
- usage: similar to fg
- jobs
-
- purpose: lists the jobs currently executing (running, suspended
etc.) in the shell where the command is issued
- usage: jobs
- the current job is always flagged
with a +, and the previous job with a -
- ssh
-
- purpose: connect securely to another machine (Secure SHell)
- usage: ssh [-l login_name] [hostname | user@hostname]
[command]
- examples:
- ssh math.uh.edu attempts to connect to
math.uh.edu, using as login_name that of the user
issuing the command
- ssh -l john math or ssh john@math
attemps to connect to math as user john
- NOTE: if, e.g., math is not recognized as
hostname, you might have to give its full name,
math.uh.edu. This is expanded by, roughly speaking,
the DNS (Domain Name Server) to the "real" address,
which is a number, something like 132.8.182.9.
- scp
-
- purpose: copy securely from another machine (Secure CoPy)
- WARNING: scp will overwrite files without asking
for confirmation!
- usage: scp [[user@]host1:]file1 [...]
[[user@]host2:]file2
- example: scp john@math.berkeley.edu:papers/text
text_berkeley
copies the file ~/papers/text from
the john@math.berkeley.edu account to the file
text_berkeley on the machine (and account) from where
scp was issued
- alpine (based on pine)
-
- purpose: lets you read, send and handle emails (pine stands
for Program for Internet News and Email)
- usage:
- alpine, and follow the instructions/choices on the
screen
- you may have to set in ~/.pinerc the variable
"rsh-open-timeout" to zero.
- xon
-
- purpose: start an X program on a remote machine
- usage: xon remote-host [-user user-name] [command]
- remarks: when no command is specified, xon runs xterm.
- example: xon math netscape starts netscape on
math
- tar
-
- purpose: gather more files/directories into a single file; the
same command (with different parameters) will reconstruct the
files/directories.
This is useful, say, to make a copy of a directory (e.g., over the
Internet), or to compress it (first tar the directory, then compress
the resulting file - using gzip & gunzip or
bzip2 & bunzip2, etc.)
- usage:
- to create a tar file: tar cvpf <TARGET_FILE.tar>
<INPUT>
- to extract the files: tar xvpf <TARED_STUFF>
The INPUT can be a list of files and/or directories.
- example:
- tar cvpf school.tar ~/2001/school will tar the
directory (or file) ~/2001/school into the file
school.tar
- tar xvpf school.tar will reconstruct the directory (or
file) school in the current directory;
NOTE: the file school.tar is not removed
- remarks: see the explanation of the parameters in the man-page;
there are many more possibilities!
- lpq
-
- purpose: check the laser printer queue (Laser Printer Queue)
- usage:
- lpq
The status of the default printer is checked (if such a
printer is defined).
- lpr -P <printer_name>
The status of the specified printer is checked.
- examples: lpq -P rm645
check the status of the printer rm645
(which is the default printer)
- kprinter
-
- purpose: open a dialog box in which you can select various
parameters, including:
- the printer
- the file to print (see the "folder" icon near the right edge)
- the number of pages per sheet (see "properties" near the
printer name)
- and much more; see for example the section More KDEPrint
"Goodies" in Chapter 3 of kprinter's Help
- usage:
- lpr
-
- purpose: print a PostScript or text (ASCII) file to
the printer (Laser PRinter)
- WARNING: DO NOT SEND OTHER FILES
TO THE PRINTER. The result will be a lot of garbage
pages.
- If this however happened, you can try to stop the printing
with the command lprm - (this might
not help always).
- You can check the status of a printer (e.g., jobs in the
queue) with the command lpq.
- usage:
- lpr <file>
The file will be sent to the default printer.
If there is no default printer defined, an error message will
be issued, and nothing printed.
- lpr -P <printer_name> <file>
The file is sent to the printer specified.
- examples:
lpr -P rm645 exam.ps
(rm645 is the default printer)
- lprm
-
- purpose: remove jobs from the printer (Laser Printer ReMove)
Normally, one can remove only his/her own jobs.
- usage:
- You might have to issue the command from the same machine from
where the job was sent to the printer.
- If the action is directed to the default printer, the
-P parameter can be omitted.
- If the flag - is specified, all queues will be
searched (in some versions the corresponding flag is
-a, check the man-page).
- lprm -P <printer_name>
remove the last job that you submitted to the specified
printer
- lprm -
remove the last job that you submitted from all printer queues
- lprm -P <printer_name> <number>
remove job number <number> from the queue
(the job numbers can be seen with lpq)
- lprm -P <printer_name> all
remove all your jobs from the queue
- examples:
- lprm - all
remove all your jobs in all queues
- lprm -P rm645 1 4
remove jobs 1 and 4 from the printer rm645