Help Desk

Information Technology

A Guide to UNIX

Unix Commands

Items enclosed in <> are variables, meaning you should type in the name you want but not the <>. Items in courier are commands. The ^ means press the control key and the command letter at the same time. All commands are typed at the Unix prompt; press Return after them, unless otherwise noted.

 

The Basics

  • man is the most important UNIX command. It displays a complete help page on a given command.
    • Usage: man <command> (e.g., man passwd, man pico, man man)
    • Press Return to scroll down one line.
    • Press B to scroll up one screen.
    • Press up and down to scroll normally.
    • Press Q to quit and return to the prompt.
  • passwd will let you change your password. Good passwords are at least 7 characters in length, and are made up of numbers, letters, and symbols.
  • more and less are text viewers. They show you the contents of a file one screen at a time in plain text. Pressing space displays the next page. Usage: more <filename>
  • jobs will list the number and type of jobs you currently have running. For each job listed that you would like to quit running, type kill <jobnumber>, where <jobnumber> is the large, unbracketed number next to the job name.
  • ^C (control-C) kills whatever process you've recently started if you don't know how to quit it.
  • ^Z (control-Z) suspends whatever program you're currently running and puts you at the Unix prompt so you can do something else. Type fg to get back into your program.

 

Using the File System

  • ls lists the files in the directory you're currently in.
    • ls -a lists all the files in that directory, including the ones which start with a "." (like .profile).
    • ls -l lists detailed information of each file.
  • du -k displays the amount of disk space your directories are using in KB. Remember to keep your directory within the disk quota (100000 KB is standard). du -ks gives the summed total of your home directory files and du -ks /usr/spool/mail/<login> gives the total for your mail inbox.
  • cp copies a file. Usage: cp <source file> <target file>.
  • mv moves a file. Can also be used to rename a file. Usage: mv <source file> <targetfile>
  • rm -i removes a file. Usage: rm -i <filename>
  • cd moves you between directories. cd by itself takes you "home." Usage: cd <pathname>
  • pwd (print working directory) tells you what directory you're currently in.
  • lpr -P<printername> <filename> prints a postscript file. Note the lack of a space between —P and the printername.
  • enscript -P<printername> <filename> prints a text file (this includes email files).

 

Compression Commands

  • gzip compresses the file you specify. After compression, your file will have a .gz suffix. Usage: gzip <filename>. You can use gzip -9 to compress your file almost 90%. Default compression is 50%. Be patient; the bigger the file, the longer it will take.
  • gunzip uncompresses a file with a .gz suffix. Usage: gunzip <filename.gz>
  • uncompress uncompresses a .Z file. Usage: uncompress <filename.Z>
  • tar -xvf uncompresses a .tar file. Usage: tar -xvf <filename.tar>

 

Mail and News

  • ipine lets you read and send email. Your command options are at the bottom of the screen. For more information, see E-Mail in UNIX.
  • trn lets you read and post to USENET newsgroups. The command l <topic> will show you a list of those groups that have that word in their name. g <newsgroupname> subscribes you to a newsgroup. u unsubscribes you from the newsgroup you're in. h gives you help by listing the available commands. Read about netiquette before you post news.
  • Press q to quit either of these programs.

 

Editors

To edit a file, type an editor name (pico, jove, emacs, or vi) and the file name at the prompt. We recommend pico. For more information on editors, see Word Processing in Unix.
  • pico: This is the editor pine uses to compose messages. The commands for Pico are at the bottom of the screen. Using pico -w keeps pico from adding line breaks as you type.
  • emacs: A relatively simple text editor in Unix.
  • vi: The text editor used by more Unix veterans than any other. Its interface can be difficult at first.

 

Internet

Reed's Unix machines are multi-user and networked. The following commands will help you to use these facilities.

  • who tells you who is currently logged on at Reed and what time they logged in. There are several commands that can give you similar information: u, w, and finger.
  • finger lets you see someone's finger information such as their real name. Not all sites allow finger access. Usage: finger <login@address>
  • lynx is a text client for the World Wide Web. It reads all the text portions of an HTML document, but doesn't show pictures nor does it handle frames well.  Usage: lynx <web page address>.
  • ftp is a file transfer protocol program that lets you access archives of all sorts of information. Note: ftp is not necessarily secure. For a more secure version of ftp, see sftp below.
  • Telnet allows you to login to a remote computer via a text interface. It is most popular for logging into Unix or Linux workstations, but macOS also has telnet receiving capabilities. Telnet is very insecure, and if at all possible you should use ssh over telnet. Usage: telnet <machine name>. Note: Telnet is not supported on the Reed machines. Use SSH instead.
  • ssh lets you access remote sites. ssh should be used to move between the Unix machines on campus. To use, type ssh and the name/address of your intended destination. For more information, see SSH in Unix. Usage: ssh -l <login name> <machine name> or ssh <login name>@<machine name>.

 

Getting Help

  • man gives you a "manual page." This is the on line help for using Unix. These pages are not, however, the easiest thing to read and understand. Their most useful purpose is to list out all the options you can add to a command. For example, try man ls. Usage: man <commandname>.
  • apropos <subject> will give you a list of possible commands on your listed subject.

 

Panicking in UNIX

  1. UNIX can be a scary place, since it is almost impossible to undo changes. If you get to a point where you are afraid you might do damage, hit ^C ( Control-C). A lot. It is the universal panic command — it will escape any program that is running and return you to the prompt.

 

Logging out of UNIX

  1. It's very important that you always log out completely and correctly. If you don't it's possible for people to get into your account and wreak all sorts of havoc in your name.
  2. At the prompt, enter the command logout or hit ^D (Control-D).
  3. If you are running Terminal from macOS, type logout again to close the window.

 

E-Mail in UNIX

You can send electronic mail (e-mail) to other users on campus or users at other locations around the world. To send e-mail to someone on or off campus, you must know their email address. Your UNIX e-mail address is <yourlogin>@reed.edu. To get started, type ipine at the % prompt. Notice that Pine always lists your command options along the bottom of the window.

 

Sending E-Mail

  • To compose a letter to someone while in Pine, press c (for compose).
  • After "To:" type in the email address.
  • After "cc:" type in the login or address of someone who is to receive a carbon copy of your message. If you don't want a carbon copy sent just press Return.
  • Type a short description of the subject of your letter after "Subject:"
  • Now type your letter.
  • When you have finished your letter press ^X to send it.

Note: Using a person's name rather than their UNIX login is the best way to address on-campus e-mail. For more information about addressing e-mail at Reed, see the Communication Handbook. When the message is sent to someone at Reed, the mail program checks the Domain Name Directory for the best place to put your message. Using names or part of names works for mailing lists, students, faculty and staff -- but alumni only have a UNIX login and thus cannot send or receive email through Reed pine except to their Reed alumni forwarding account.

 

Reading E-Mail

To check your UNIX mail once you have opened Pine:

  • Press i to see an index of the e-mail messages in your Inbox.
  • You can move up and down the list of messages with the arrow keys pressing Return to tell pine that you'd like to read the message you've selected.
  • After you've read the message you can tell pine what you'd like to do with the message you've just read: d to delete it, s to save it into a folder in your home directory, r to send a reply, or n to view the next message.

 

Creating a directory

  1. Suppose you want to create a directory named mydir.
  2. At the prompt, enter the command mkdir ~/mydir, or mkdir <directory> in general.

 

Removing a directory and its contents

  1. Suppose you want to delete the directory ~/mydir.
  2. At the prompt, enter the command rmdir ~/mydir.
  3. If you are sure you want to delete the directory, type y and hit Return. Otherwise, type n and hit Return. Beware: there is no "Recycling Bin" in UNIX; when directories are deleted, there is a good chance they and their contents are gone for good.