Basic UNIX Commands
alias Display the current aliases (definitions).
cal Calendar. Specify: cal 6 1956 (month and year)
cal 6 56 gives June, 56 A.D.
cancel # Cancel line printer job whose number is #. Check the printer
status to see what number # is with lpq or lpstat -o.
cat Type (actually concatenate)
cat f1 Display f1
cat > f1 Put data typed from terminal up to CNTRL-D into f1
cat f1 > f2 Copy f1 to f2 (like the cp command)
cat f1 >> f2 Append f1 to the end of f2
cat f1 f2 > f3 Concatenate f1 and f1, place result in f3
cat FILE | mail USER Send a pre-edited FILE to a particular USER
(could alternatively use mail USER < FILE)
cat -n Precede each line with its line number. If used to create a column
for join, change the single digits to two digits (i.e., 01).
cd Change directory. With no specifications it returns home.
chmod +x Change mode of file to executable (use for command files)
chmod 666 Change protection to read and write for the user, group, world
(4=read, 2=write, 1=execute; 3=we; 5=re; 6=rw; 7=rwe)
clear Clear the screen
cp Copy file. Example: cp file1 file2 copies file1 into file2.
cut -c Cut specified characters from specified file. Can be used in pipe.
cut -c1-5 FILE Display only columns 1 through 5 from FILE
cut -c1-5 FILE > FILE2 puts the output into FILE2.
date Gives current date and time. Also use to modify date and time.
dd Convert and copy files with various data formats. Use in a pipe
to write data to a tar tape on another host (ips1):
tar cvfb - 20 FILENAMES | rsh ips1 dd of=/dev/nrst0 obs=20b
or to extract that data:
rsh -n ips1 dd if=/dev/nrst0 bs=20b | tar xvBfb - 20 FILENAMES
diff Compares two files. sdiff will do a side by side comparison
showing every line. sdiff -s will show only different lines.
df Show the amount of disk space available in 512K blocks.
du Recursively show disk usage for everything under this directory.
du -s * Show total usage for sub-directories in this directory.
file FILENAME Displays what type of file FILENAME is.
find FILENAME -atime +DAYS -print Find FILENAME accessed since DAYS
find DIRECTORY -name FILENAME -print Find FILENAME in DIRECTORY structure
Examples: find ~ -name core -print
find . -name '*.ps' -print
fpversion Gives information about the system CPU and FPU.
from Displays sender and date of mail which has not been read yet.
ftp HOSTNAME Use to get files from another machine.
grep Search for 'pattern' through files (may be * combination)
Example: grep TEST * searches through all files for the word TEST
grep TEST file1 searches through file1 for the word TEST
ps aux | grep rubin displays all jobs rubin is running
head FILE Display the first ten lines of the file called FILE.
join F1 F2 > F3 Append horizontally each line in F2 to its corresponding
line of F1 and put the output in F3. F1 and F2 must have
identical first columns. In addition, there should be
no extra spaces in the items of that first column (for
example, if the column is 2 digits wide, use 01).
Also check the paste command!
kill -9 # Use ps -aux to determine the number of the process to be killed.
limit View resource limits for this shell.
ln -s Define a symbol. Use rm -f to remove it.
Example: ln -s /home_ips1/file.ips1 file.keiser
will link file.keiser to file.ips1 on /home_ips1.
lpq Shows status of default printer.
lpq -Pqms1 Shows status of qms1 printer.
lpstat -o Shows status of all printers.
lq Shows status of all printers in a brief form (/home/allsuns/scripts)
ls -l List files in current directory
-1 Type in just one column
-a Include files which begin with a .
-F Identify directories with / and executables with *
-t List by time, most recent files first.
-R List all sub-directory contents as well.
-r Reverse (either alphabetically or by time as appropriate)
-t Time sort
Example: ls -alF shows all information about files in current directory.
ls is probably already aliased as ls -aF.
make A powerful utility based on instructions listed in a makefile.
Example: make all >&! log & (for /bin/csh and /bin/tcsh)
make all > log 2>&1 & (for /bin/sh)
man Manual (help file). Use SPACE to move through pages.
Example: man ls gives more information on the command ls.
mkdir Make a directory
more Type a file a page at a time showing the percentage typed. A
carriage return advances one line; a space advances one page.
Use q or CNTRL-C to quit, ? to show available commands.
mv Rename a file or a directory.
Example: mv FILE1 FILE2 renames FILE1 to FILE2.
netstat -i Show network status. Displays the number of collisions occurring.
nroff -man Format and display a manual file.
od -a Octal dump (-a means display the ASCII characters). If you need
to look at the characters in a binary file (or a FITS file),
od -a FILENAME may give you a clue, although it's hard to read.
sp means space, nl means null.
passwd Change password
yppasswd Change password on all SUN machines. (yp is for yellow pages)
paste Paste two files together horizontally.
Example: paste f1 f2 > f3
paste paste -s -d"\0\n" double.dat > single.dat
(Second example removes extra lines from double.dat)
printenv Shows current environment. For example, the PATH variable is
shown here and tells you all of the places that the computer
looks for commands which you tell it.
ps -aux Lists current processes
pstat -s Show the amount of swap space available.
pwd Print working directory (shows current directory)
renice Set a "nice" value for a process already running.
Example: renice +19 PID (where PID is the process ID shown
by the ps command)
rm Remove file. Separate filenames with a blank.
-i asks for confirmation before removing
-r removes all files from a directory as well as the directory
rmdir Remove an empty directory (no confirmation available since
it is already empty). Must be empty to remove.
rsh ips1 Remote login. Does not require a password.
Example: rsh sak ps aux shows the processes running on sak.
rcp Remote copy. Must have the .rhosts file to allow permission.
Example: rcp ips2:/tmp/FILE . to put FILE in current directory.
set Shows shell variables (@ does also)
set VAR1=VAR2 Sets variable VAR1 to be VAR2. Use echo $VAR1 to display.
Use unset VAR1 to remove definition of a shell variable.
sort fil Alphabetical sort on filename 'fil'. Does not change 'fil'
-r for reverse sort -o to redirect output (may be same as input)
sort < f1 > f2 Sorts from f1 and puts into f2
sort -k 2,2 < f1 > f2 Sorts on the second column from f1 into f2
source .cshrc Perform the commands in the .cshrc file immediately.
spell FIL List spelling "errors" from file FIL.
sum Calculate and display a 16-bit checksum for the named
file. Also displays the size of the file in kilobytes.
tail Display the last part of a file (default is 10 lines).
tail -r Display the file in reverse order.
Example: tail -r FORWARD > BACKWARD copies the file FORWARD
into the file BACKWARD in reverse order.
tar Tape archive. c creates, x extracts, f names the file, t types
eg: tar cf TARTEST F1 F2 To create tartest containing F1 and F2
tar xf TARTEST Extracts all files from TARTEST
tee Replicate the standard output, e.g. to send to screen and a file:
/autodump | & tee /autodump.lis
telnet HOST Log into another machine. Probably will ask for a password.
time Times the command (listed on the same line)
touch Reset this file (or files) to the current date and time.
If the file does not exist, it will be created.
umask Set file creation permissions. Default is 22 which gives rw to
user, and r to group and others. umask 002 gives rw (read/write)
to user and group, but just read to others.
unix2dos Convert text file from ISO format to DOS format so that they
will print properly with lpr.
wc fil Word count. Returns number of lines, words, and characters
for filename 'fil'. Characters includes carriage returns.
-l for just lines, -w for words, -c for characters
which FILE Displays which FILE would be executed, include the path name.
who Lists current users
who am i Lists host!user tty date
whoami Lists this user
zcat Types a compressed file and leaves the disk file compressed.
Example (to extract programs): zcat programs.tar.Z | tar xf -
For a gz file use: gzip -dc filename.tar.gz | tar xvf -
To redirect errors and output to a file in csh use:
command_name >& err.file
CNTRL-d Logs off any shell or closes file created with cat >
CNTRL-e Jumps to the end of the line. Useful if you've used the arrow
key to go back and make changes in a command line and need to
go to the end of the line before hitting the carriage return
CNTRL-h Erases a character
CNTRL-u Erases all characters before the cursor
CNTRL-w Erases last word before the cursor
CNTRL-, Jump back to the beginning of the current word
CNTRL-. Jump forward to the end of the current word
~ Type echo ~ to find the definition of home directory.
` Execute command within backward quotes and insert its standard
output at that point as in echo `date`
" Removes special meaning of ' < > # * ? & | ; ( ) [ ] ^ blank nl tab
' Same as " but removes special meaning of $ ` " \
& Type at end of command to execute it in the background.
; Separates several commands typed on the same line.
\ Type at end of line to continue on next line.
Also means ignore followowing special character. Inside double quotes
removes special meaning of $ " \ but otherwise is not interpreted.
/ Indicates comment in list-directed input file.
| Pipe. Output from first command goes into second command.
eg: who | wc -l counts the number of lines from who (# users)
ls | wc -w counts the number of words in listing (# files)
< Redirects input
> Redirects output
>! Redirects output and overwrites file if it already exists.
>> Redirects output to append
A.OUT > OUTFILE Runs A.OUT and sends output to append
A.OUT < INPUT > OUTPUT
b Goes back one page while in more or man. Use space to
go forward again.
? Wild card indicating one place holder.
* Wild card.
./ Refers to the current directory.
../ Refers to the parent of this directory.
Copy & Paste: Use the left mouse button to select multiple lines to
be cut and pasted, or use the left mouse button to indicate
the beginning of the selected portion and the middle mouse
button to indicate the end of the selected portion.
CNTRL-Z Stops a job which is running (hold down CONTROL and Z keys)
% Restart the most recently stopped job.
fg Same as fg (restarts the job which CNTRL-Z just stopped)
jobs Lists stopped and background processes.
fg%# Runs job # in foreground. Example: fg%2 runs job number 2.
%#& Runs stopped job in the background. Example: %1021&
jname& Runs new job 'jname' in background
!! Repeats the last command (you may add characters at the end of the command)
!v Repeats last command that began with the letter v. (Helpful if you are
using vi to edit a file several times.) Works with any letter or group
of letters. Example: !cat will retype the last file you typed.
^OLD^NEW Changes the characters OLD in the last command to NEW and executes
!:gs/OLD/NEW Changes all occurrances of OLD to NEW in the last command
The black and white printers available to the SUNS are escher, optra2, and sp1.
By just typing the name of the printer, you can see the options which
are available. For example, to see options for escher (the duplex printer
in the Astronomy Image Processing Room), type escher:
escherprints ASCII (plain text), DVI, Postscript, SUN Raster, and Tektronix.
Choose the appropriate options based on the type of file. (Do not type
the brackets; they indicate options.)
ASCII: escher -a [-r] [-B] [-2] [-fFont#] filename
Use -r with -a to print in landscape mode.
Use -B with -a to inhibit a header at top of each page (-b also works).
Use -2 with -a to print text in two columns per page.
Use -f with -a to indicate a font other than the default (#=size).
For example: -fCourier8 prints very small characters.
DVI: escher -d [-pn1] [-ln2] [-t orientation] filename
Use -pn1 -ln2 with -d to print only pages n1 through n2.
Use -t orientation with -d (orientation=landscape or portrait).
Other: escher [-p] [-r] [-t] filename
Use -p if file is a POSTSCRIPT file.
Use -r if file is a SUN raster image file.
Use -t if file is a Tektronix file.
Use -s to create a symbolic link (useful with large PostScript files).
Optra Duplex and Resolution Options (use with any of the above options):
Use -ss for single sided pages
Use -dp for double sided portrait pages (default)
Use -dl for double sided landscape pages
Use -X for X dots per inch (dpi) where X is a valid number.
Valid resolutions are -300 -600 -1200
Print darkness options: -light -medium -dark (default)