| An Introduction to Unix |
- UNIX
- Logging In
- Using UNIX Commands
- General Commands
- Files and Directories
- Information Services
- Editors, Spelling, Etc.
- File Transfer Aids
- Mathematical Programs & Tools
- Text-based Utilities
- TeX Stuff
UNIX
UNIX is an operating system that was designed at AT&T's Bell Laboratories in 1969. While that makes UNIX very old by computer standards, it is still popular today because of its power, flexibility, and portability. UNIX can run on platforms ranging from PCs and Macs to Cray supercomputers.
Kernel. Today you'll find several flavors of the UNIX operating system, also known as the kernel. AT&T's original version evolved into System V. The version that AT&T licensed to the University of California at Berkeley is called BSD (Berkeley Software Distribution). It is now the de facto standard in the academic community, i.e. it's free. Other versions are also available from commercial vendors: Sun's Solaris, SCO and Microsoft's XENIX, IBM's AIX, DEC's ULTRIX, Apple's A/UX, and the free Intel-based Linux.
Shells. Users rarely use UNIX directly, however. The utility software that interprets a user's commands for the kernel is called the shell. Here too, there are several flavors. While graphical shells exist for UNIX that imitate the Apple Macintosh or MIcrosoft Windows, most users stick with the traditional command line interface. You type commands one by one on your terminal or into a terminal window, press RETURN, and they are executed. The original and most common shell is the Bourne shell (its prompt is $). The C-shell (% or >) is newer and provides an extensive command language similar to the C programming language. The Korn shell (also $) attempts to combine the best of both earlier shells. More than one shell is often available to users on a UNIX system. Here at the UW-Madison Math Department we use a shell called tcsh that has several improvements over the original C shell.
Back to the top.
Logging In
You may use UNIX locally from a hard-wired terminal or remotely from a microcomputer running terminal emulation software, (such as telnet). Once you are connected, UNIX will prompt you for your login name. Type your unique userid assigned to you. At the password prompt, type your password. (Your password will not be printed on the screen.) If you are using a terminal or terminal emulator, you will see a % prompt. If you logged into a workstation you will see the CDE desktop. Open a terminal window to see the % prompt (Right click the mouse and select Terminal or Xterm from the Programs menu).
Changing Your Password. If you are using a temporary password, you should change it immediately. It is also a good idea to change your password periodically. Unlike your login name which may be known by many people, only you should know your password. Make your password 6 to 8 characters long. Make it hard to break by combining capital letters, lowercase letters, and punctuation. Avoid using family names, pet names, words found in dictionaries, birth dates, anniversary dates, and obvious numbers (drivers license, license plate, phone). Do not use common words, even if you add a number to the password (e.g., Gandalf, red3, scottX, etc.). Instead, make up a word by using the first letters from a favorite line of poetry or verse. For example, This is the way the world ends would yield the password Titwtwe. DO NOT WRITE YOUR PASSWORD DOWN, but do make it memorable. If you forget your password, contact the departmental system administrator. To change your password, either type: passwd at the UNIX prompt. UNIX will prompt you for your old password, then your new password. UNIX will then ask you to retype the new password to confirm it. Once you've confirmed it, your new password will be in effect. Use it the next time you log in.
Back to the top.
Using UNIX Commands
UNIX commands follow the format: command -flags arguments. The commands are one-word, lowercase. Optional flags are one-letter switches that modify the way the command works. They follow the dash, are case-sensitive, and can be combined. The optional argument usually specifies the file or directory that is the target of the command's action. Hit RETURN after entering a command.
Below are a bunch of useful commands, but if you want to know even more, check out the friendly and extensive UNIXhelp for Users. In the examples commands below, the following notation is used.
Back to the top.
- Double quotes ... enclose special characters and some examples. Don't type these quotes in a command! When you need to type quotes we'll tell you.
- The symbol ^ indicates the control key. For example, ^C means press CONTROL and C at the same time.
- Italicized words denote generic arguments, such as filenames. Don't type the italicized words. Instead, type in an appropriate filename, directory, etc.
General Commands
These commands are good to keep in mind when doing any sort of work on a UNIX computer.
Back to the top.
- ^C
- Usually kills whatever you are doing and signals the shell to accept the next command. Use ^C only if you are stuck, since work you did during the killed command may be lost.
- ^Z
- Usually typed by accident, this control code temporarily suspends a command, whereupon the shell can accept the next command. Use fg (foreground) to get the suspended process running again; type jobs to see if you have any suspended or background processes. Do not use ^Z unless you really intend to, particularly when editing files or reading mail, since you can easily get inconsistent versions or lose mail if you execute the command a second time without finishing the first one.
- crypt input output
- Encrypt or decrypt a file (it knows which way to go). It will ask you for a key. The algorithm is not sufficiently strong for national security issues.
- date
- Displays the current date and time.
- finger name
- Looks up the loginID of name.
e.g. finger Gilfong will give you the loginID (and full name) of everyone named Gilfong. Be prepared for a lot of output with common names. You can also specify the loginID to find the person's full name.- gunzip file
- The inverse of gzip: restores the original file.
- gzip file
- Compresses file. The full-size file is removed and the compressed file has the same name with an extension of ".gz" added. You can get 4 to 1 compression on low-entropy data.
- hostname
- Gives the name of the computer on which you are currently working.
- kill pid
- Cancel the process with identification pid
- pkill process
- Cancel the named process - e.g. pkill firefox-bin will kill your firefox session. This is useful as firefox often refuses to die and you will not be able to start up a new session without killing the old one.
- logout
- Ends your session. NOTE: you must logout every time you are finished at the terminal or other userss will be able to change your files. On office machines please do not leave idle sessions active overnight, both because of the security hazard and because the unused programs use up system resources. An alternative command is exit.
- lpr filename
- Prints filename to the default printer. You can change your default printer by typing setenv PRINTER N, where N is the number of the desired floor. To print filename to floor N, type lpr -PN filename. Save trees by viewing documents onscreen, and mind your paper quota.
- lprm pid
- Cancels the print job pid.
Also, lprm -PN pid cancels job pid on floor N.- lpq
- Checks on status of print jobs on your default printer. lpq -PNchecks print jobs on printer N. lprm -PN jobid will remove jobid from printer N.
- locate file
- gives the location of file.
- Starts an email program that doesn't work well. Use the email program pine instead.
- man command
- Gives information from the UNIX manual about command.
Also, man -k word will list manual pages whose titles contain the keyword word.- nice -prior job
- Gives job job processing priority value prior (1 being the highest priority level and 19 the lowest) which tells the computer how to process tasks.
e.g. nice -19 ./a.out & runs the program a.out in the background at the lowest priority.- passwd
- Changes your password. You will be asked to type the old password first, and then the new password twice. None of this is visible on the screen. For advice on choosig a good password see the Password FAQ.
- command1 | command2
- Called the pipe command. Takes the output of command command1 and uses it as the input for command2.
e.g. ls | lpr prints the names of the files listed in the cuurent directory.- uptime
- Shows the load on the computer you are currently using.
- who
- Lists all users on the computer in which you are currently working.
- who am i
- Tells who is currently logged on a specific terminal
Files and Directories
In UNIX data is stored in a file. Each file has a name, which you create. Filenames should be composed of letters (upper and lower case), numbers and simple punctuation (hyphens and underbars included). Actually any character can be used except / (slash), but you have to do extra work to specify non-alphanumeric filenames, and you'll regret using one. Many filenames end with an extension, i.e. a dot and one to three letters. It is conventional to use an extension that signifies what is in the file, e.g. .c for C-language source code or .gif for an image in the GIF format. Some programs, such as web browsers, depend on the extension to tell how to process the file.
Files are indexed in directories. Every user has a home directory, and you can (and should) create sub-directories within it, one for each project or purpose. Every process executes in a particular directory called the current directory. Use the cd command to change to another directory. Files in the current directory are accessed just by their names. To specify a file in another directory give the name of that directory, slash, the filename. The directory that contains a directory can be referred to as .. (dot-dot), and the home directory is abbreviated (tilde) or $HOME. Here's a complicated filename: /tasks/lapack/Notes2.txt. This means: In my home directory, subdirectory tasks, its subdirectory lapack, the file Notes2.txt (which judging from the extension probably contains text).
To create a file you need to use an editor or use output redirection.
Back to the top.
- cd directory
- Changes to the directory directory, which becomes the current directory.
Also, cd .. changes to the containing directory.
Also, cd (without arguments) changes to your home directory.- chmod perm file
- Sets the permission of one or more files or directories. Useful permissions are:
- 600
- Only you can use the file.
- 700
- Same, for directories and executable files.
- 644
- Anyone can look at the file; only you may write. This permission is required if a file is to be visible on the World Wide Web.
- 755
- Anyone may look at files in the directory (if the file permission allows); only you may put files in it.
- 711
- For directories, anyone may use a file if the name is known (or guessed) and the file permission allows, but others may not do ls in the directory to snoop for other filenames. Often used on home directories.
- cp file1 file2
- Makes a copy of file1, calling it file2. If file2 does not exist it is created. If it does exist, it is overwritten.
- du subdir
- Shows how much disk space the files in subdir occupy.
Also, du -s subdir shows the disk space occupied by subdir itself.- ls
- List of files. You may specify specific files or directories to be listed. e.g. ls -l gives a "long" list showing the file's date, size and permission.
e.g. ls -s gives a "simple" list with sizes in kilobytes Files whose names begin with "." (dot) normally are not shown.
e.g. ls -a shows them.- mkdir directory
- Makes a directory called directory.
- more file
- Displays file one page at a time, starting at the top of the file.
- mv old new
- Moves or renames file old to new.
It could be moved to a different directory and the simple name could be changed. If new is a directory that already exists, file old will be placed in it. This form still works if several old files are specified.- quota
- Checks your quota of file space. If it displays nothing, you're OK.
Also, quota -v displays a report even if you're not over quota. Please remove files that you're not going to use any more, particularly large ones.- rm file
- Removes a file. Be careful! You can't un-remove it later. Please remove files you aren't going to use anymore.
Also, rm -r directory will remove every file in directory.- rmdir directory
- Removes directory
Information Services
Back to the top.
- AMSlookup
- Queries the AMS database of Mathematicians. This is the computer equivalent of looking up names and addresses in the CML (Combined Membership List of the AMS, MAA and SIAM). You will be asked for a Name. Type in:
smith:john if you know the exact name or
sm*:j* if you are unsure of the name.- lynx
- Starts the text-only web browser Lynx.
- info
- Starts the GNU software guide. Use it to find out information about Gnu-emacs, GCC, GDB, and other gnu programs.
- lookup
- Starts a program that allows you to lookup email addresses and telephone numbers of UW staff and faculty members.
- network news
- Starts an Internet news progam. See entries for the news readers rn and nn.
- nslookup
- Starts a program to lookup numerical IP addresses of host computers.
Editors, Spelling, Etc.
For more detailed information, see the Editors section.
Back to the top.
- emacs
- Starts the Emacs text editor.
- ispell
- Starts an interactive spell-checker, that can be used from unix or from within an editor. This program is better than spell.
e.g. ispell -h summarizes options.
e.g. ispell -t file.tex checks the spelling of TeX or LaTeX files.- pico
- Starts the Pico text editor.
- spell
- Starts the standard unix spell-checker.
- vi or vedit or view
- Starts the vi text editor.
File Transfer Aids
Back to the top.
- mcvert
- Converts Macintosh files from BinHex to MacBinary format.
- rlogin
- Logs you in to another unix host outside the Math Department.
e.g. rlogin hostname -l username logs you as username.- rb or rx or rz
- Starts a file transfer protocol for RX232 transfers. This is for files being sent from an X-modem or Z-modem computer to a Solaris computer.
- sb or sx or sz
- Starts a file transfer protocol for RX232 transfers. This is for files being sent from a Solaris computer to a X-modem or Z-modem computer.
- scp Secure Copy allows you to copy files to remote machines.
Syntax: scp file user@host:. or scp user@host:file .- sftp
- Starts the File Transfer Protocol program which allows users to to send and receive files over the Internet. The computers involved must be connected to the Internet via Ethernet. sftp is secure unlike ftp. You can also use scp to transfer files.
- ssh
- Logs you in to another unix computer within the Math Department.
e.g. ssh hostname -l username logs you in as username.- telnet
- telnet sessions are not allowed to Math Dept computer. Use ssh instead
- tn3270
- Logs you in to an IBM machine such as blue.adp.wisc.edu and IMP, the Yale preprint database. Similar to telnet.
Mathematical Programs & Tools
Back to the top.
- cc or cpp
- Starts a Sun C compiler (not ANSI compliant), Sun C preprocessor
- dvips
- Converts .dvi to .ps.
- f77
- Starts a FORTRAN compiler. Type g77 on Linux machines.
- gcc or gdb or gpp
- Start GCC, a Gnu C compiler, or GDB, a Gnu debugger, or GPP, a Gnu C preprocessor, respectively.
- g++
- Starts a Gnu C++ compiler.
- Macaulay
- Starts Macaulay, a computer algebra system for algebraic geometry and commutative algebra. Note 'M' is capitalized.
- magma
- Starts Magma, a computer clgebra system for finite groups. Available only on computers wasow, schaefer, and erdos.
- maple
- Starts Maple, an interactive or programmable computer algebra system similar to Macsyma or Mathematica. There are two additional packages called coxeter and weyl which may be used to study root systems and finite Coxeter groups.
- matlab
- Starts Matlab, a matrix manipulation program.
- otter
- Starts Otter, a logic program
Text-Based Utilities
Back to the top.
- bc
- Starts a simple command-line desktop calculator.
- calendar
- Starts a simple scheduling program.
- tin
- Starts a text-based news reader.
- pcal
- Displays a large calendar.
- rolo
- Starts a desktop addressbook program.
- sc
- Starts a spreadsheet calculator program. Output can be saved as a table or in TeX or LaTeX format.
- talk
- Used to communicate interactively with another user on the same network or computer.
TeX Stuff
Back to the top.
- bibtex
- Processes .bib files for use with LaTeX.
- clean
- Cleans up the .dvi, .aux, .log and other files created by TeX and its relatives in the current directory. See also rmjunk and listjunk.
- latex
- Processes LaTeX documents.
- latex2html
- Converts LaTeX documents to HTML.
- listjunk
- Lists the .dvi, .aux, .log and other files created by TeX and its relatives. rmjunk will then remove these files. These two commands will descend your directory tree, and remove these files in subdirectories. rmjunk is more powerful than the clean command.
- dvips
- Converts .dvi files to .ps.
- ps2pdf
- Converts .ps files to .pdf.
- tex
- Processes TeX documents.
- tth
- Converts LaTeX or TeX documents to HTML (works very well on documents which are mostly text. See the tth Manual.
- xdvi
- Views .dvi files.