Commands are what you type at the prompt. Com-
mands have arguments on which they operate. For
example, in rm temp, the command is rm and the ar-
gument is temp; this command removes the le called
temp. Here I put arguments in UPPER CASE. Thus,
words such as FILE are taken to stand for some other
word, such as temp. In the following list, I use [ ] for
optional arguments that are not typicaly used.
Commands have options that are controlled with
switches, which are usually letters following a single
dash. Usually you can write several letters after one
dash. For example ls -l lists les in a long format,
with more information. ls -a lists all the les, in-
cluding those that begin with ., which are usually
les used by various programs. ls -al lists all the
les in the long format. The following list omits most
options. Many programs will give you a list of their
options if you type the name of the program followed
by -h or -?.
Other options are controlled in special les usu-
ally beginning with ., such as .emacs, .mailrc, and
.newsrc. You can edit these. The le .cshrc con-
tains general options, plus aliases that you make up
for commands you use often.
|, the pipe symbol, takes the output of one command
and gives it to the second command as input, for
example, ls -l | more allows you to view a long
le list through \more".
> directs the output to a le, e.g., ls -l >
listing.tmp puts the listing into a le named list-
ing.tmp. > overwrites an old le of the same name.
>> appends to a le.
* stands for any string of letters. For example, ls t*
lists all the les beginning with t.
" recalls previous commands, and you can edit these
commands using emacs editing.
The tab key completes commands if you type the rst
ctrl-z suspends most programs. fg resumes. ctrl-c
stops most programs.
alias abbreviates a series of commands, separated
by semicolons. Useful in .cshrc.
apropos KEYWORD: Looks for commands related to
man COMMAND: Shows manual pages on COMMAND.
This is the authoritative source on the items de-
scribed here. The commands can do much more
than is listed here.
whatis COMMAND: Tells what COMMAND does.
FILES AND DIRECTORIES
All information is stored in les. File names and
commands are case sensitive. Case matters. Files
are contained in directories. You start out in your
own home directory, and your prompt usually tells
its name. At any given time, one of these directories
is your working directory, the one you are in.
You can refer to les in your working directory by
just their names. You can refer to a le that is in a
subdirectory by giving a subdirectory name, a slash,
and the le name, e.g., Mail/baron. You can refer to
any le on the computer by giving its full name, start-
ing with a slash, such as /home7/b/baron/mbox.
If the le is a program, typing its name will run it.
(That is what commands do.) If the program is some-
thing you have just written and is in the director you
are in, put ./ before the name. If the le is not a
program, typing its name will give you an error mes-
sage. If you want to see its contents, for example, you
must use a command such as \more" before the le
ls [DIRECTORY]: Lists les. (Also try: ls -f, ls -s, ls
rm FILE: Removes FILE.
more FILE or less FILE: View FILE. (? or h for
cd DIRECTORY: Change the directory you are in to
cd: Change to your home directory.
cd ..: Change to the next directory up in the hier-
mkdir DIRECTORY: Make DIRECTORY.
rmdir DIRECTORY: Remove DIRECTORY.
rm -rf: Recursively remove a directory and anything
mv FILE1 FILE2: Moves or renames FILE1 to
cp FILE1 FILE2: Makes a copy of FILE1, called
cat FILE1 FILE2 > FILE3: Concatenate FILE1
and FILE2, calling the result FILE3.
chmod 644 FILE: Unprotect FILE for others to read
chmod 755 FILE: Unprotect program or \script."
chmod 755 DIRECTORY: Unprotect DIRECTORY,
needed for web page directories.
head and tail: Print the top and bottom of a text
TEXT FILE MANIPULATION
These commands operate on les. The output goes
to the \standard output," which is your terminal dis-
play. If you want to \redirect" the output to a le,
use > FILENAME at the end of the command (with
FILENAME being the name of the le). Use >> instead
of > if you want to append to the le rather than
write it from scratch.
diff: Find the dierences between two text les.
grep LETTER-STRING FILE1 [> FILE2]: Prints (or
puts in FILE2) all lines of FILE1 that contain
LETTER-STRING. Use the -v switch to get lines
not containing the string.
sed s/STRING1/STRING2/g: replace STRING1 with
STRING2 throughout a le. See also the y switch
for replacing characters.
cut -d" " -f2 FILE: Extract the second column
from a le, where the columns are delimited by
spaces. Use paste to put such cuttings back to-
sort FILE: Sort the lines alphabetically.
uniq FILE: Remove adjacent duplicate lines. Typi-
cally used with the output of sort, e.g., sort FILE
| uniq. Use the -c to count the number of ad-
jacent examples of each line.
wc FILE: Count characters, words, and lines.
WHAT'S GOING ON?
w [USER]: Who is using the computer. This is useful
to see whether you are logged on twice. (See ps and
kill, below, in case this happens.) Also try who and
finger USER: Gives information about the user, in-
cluding the les .project and .plan, if you have
these les. You can sometimes use this for people
on other computers. You can keep useful infor-
mation in your .plan, such as your schedule, your
phone number, etc.
quota -v: Tells you how much of your quota for les
is used up.
ps -fu USERNAME: Lists the processes that you are
running, if you put in your username. You can use
this to nd the number of processes that you want
to kill, such as those left over when you did not
log out properly. It is the rst number listed.
kill PROCESS-NUMBER: Kills the process you don't
want. If this doesn't work, try kill -9
last -22: Shows you the last 22 users who logged
mutt and elm: Read and write electronic mail. Each
has its own \help". See the discussion of these in
the psychology web page computer section.
slrn and tin: Read news (and respond to postings).
Pnews: Post to newsgroups. (You can
also say mutt psych-general@psych or
elm psych-general@psych to post to
lynx [URL]: Reads web pages as text les.
ssh HOST: Connects to a remote computer.
talk USERNAME: Allows you to talk with someone
logged on. The full username must be specied
for remote computers, and you must use ntalk
instead of talk. It is not a good idea to use this
casually unless you know that the other person will
not be annoyed.
Many computers on the internet have ftp or ssh, but
all of the programs for transferring les depend on
having the relevant software on both computers.
ftp and scp: Fast way of uploading and down-
loading, or moving any le from one com-
puter to another. For example, scp myfile
firstname.lastname@example.org: - you need the colon
at the end.
rsync: synchronize les or directories on two dier-
ent computers. Good for backing up.
pico FILE or emacs FILE xemacs FILE or vi FILE:
Edit FILE. One of these editors may be specied
as the default for mailing and news programs. Pico
is easiest because it has all the commands listed at
the bottom of the screen, but it is the least useful
because it has few commands.
COMPRESSING, ENCRYPTING, and SE-
tar cvf FILE.tar and tar xvf FILE.tar: Create
and extract an archive le. Useful for backing up
directories. On Linux xvfz will extract and unzip
in one step.
gzip FILE: Reduce the size of les for storage. use
gunzip FILE to unzip them. Files \zipped" with
gzip have the sux .gz.
crypt <> FILE2: Encrypts or decodes
le1 so that you need a password to read it. But if
you want to be absolutely sure beyond any doubt
that nobody will read your les, do not leave them
antiword FILE1 > FILE2: Decodes a Word le
into text. (That is all most of them are.) Save
storage space. You can use this with Mutt or Elm
to read doc les sent in email messages.
passwd: Change your password.
Jon Baron, September, 2003
Thursday, July 17, 2008