Essential Unix Linda B. Merims MIT Project Athena Revision A September 10, 1984 Table of Contents Introduction First You Need... Login Logout You Have to Know... Control Keys: Fixing Typos, Bailing Out Case Sensitivity Common Terminal Session Problems Entering Commands The Shell Command Format Change Your Password: passwd Getting Help Documentation: man and apropos Consultants Hardware Trouble Files File Names Name Conventions Wildcards: * and ? To Get a List of Your Files: ls To See the Contents of a File: cat and more To Create a File To Delete a File: rm To Copy a File: cp To Rename (Move) a File: mv Printed Output To Send a File to the Printer: lpr What Files Are Waiting to Print? lpq To Cancel Print Jobs: lprm Interlude Directories The Working Directory The HOME Directory To Make a Directory: mkdir To Change the Working Directory: cd To Find Out What Directory You're In: pwd To Delete a Directory: rmdir The -r Recursive Option Sample Directory Specifications System File Organization: An Aside File Protection: Who Can Read Your Files? The Default Protection Changing Protections To Make a File Readable by Everyone in a Group To Make a Directory Where All Members of a Group Can Read and Write To Make a Public Directory To Open Your Files to All: An Interesting Issue Caveat Emptor: A Final Warning Exploring Your Environment The Files that Come with Your Username Your Neighbors: Who's On? What's the System Doing? To Kill a Session Essential Unix Project Athena Revision A September 10, 1984 Linda B. Merims Introduction Essential Unix explains the dozen things that you have to know to get through a typical Unix session: those commands that, although they make up only 5% of the total commands available to you, are the commands that you use 80% of the time. When you have finished reading Essential Unix, you will know: how to login and logout what control keys to press to delete a character or bail out of a facility how to get help the Unix command format how to manage Unix files, including how to create them, get lists of them, type them out on the terminal, print them on a line printer, delete them, and control who uses them. what directories are and how to move around them a bit about how to explore and control your Unix environment and how to recognize some of the typical traps that everybody always falls into when they start to use Unix Like its companion documents Essential Athena, Essential Emacs, and Essential Mail, Essential Unix's purpose is to get you on the system and started as quickly as possible. As such, many important Unix concepts such as "pipes" and "redirection" will be ignored or mentioned only in passing because they are not survival material. Lastly, although you may be able to squeak by without it, Essential Unix does assume that you have had some prior exposure to computers so that when we say "file," or "system" you understand in a general way what we mean. First You Need... To use the Project Athena system, you need to know all of the things on the list below. Your project or course Account Administrator should supply you will all of this information. If you have questions about any of this, for example, "What's an Account Administrator?" see the companion document Essential Athena. your Unix username and password You login to the system with your username and password. (Usernames are also referred to as "login ids," "accounts," "userids" and "numbers".) The username is up to eight characters long. Unless you asked for something different, it will be your first and middle initials followed by as much of your last name as will fit in the eight character limit. Usernames are always in all-lowercase letters. your assigned host machine and terminal cluster room number Your username will only work on the host machine assigned to you. All terminals in a terminal cluster can reach your host machine. the combination to the terminal cluster door the cluster telephone number (why?) The cluster terminal rooms are normally open, but you may find one locked. A combination entered into an electronic lock at the side of the door opens the door. Login Go to your assigned terminal cluster. All of the terminals in the clusters have little signs on them that say what host machine they are connected to, their tty (port) address, and what kind of terminal they are. In spite of which host a terminal is labelled with, you can reach your host through any terminal. There are currently five kinds of Athena terminals: DEC VT100's Most of the terminals are VT100's. Go by the Athena sign, @i(not) by the manufacturer's tag on the face of the terminal. DEC PRO 350's These are actually microcomputers acting as terminals. Instructions on the main box explain how to establish contact with the host. They can do graphics. DEC VT125 These look just like the VT100's except that they can graphics. Again, go by the Athena sign, not by the manufacturer's tag. DO NOT use the VT125 terminals unless you are doing graphics output work. They do not work right in other situations. DEC VT240 These terminals can do graphics. DEC VS100 The VS100 bit-mapped graphics units do not work as terminals yet. They can only be used as graphics output devices. Find a terminal and turn it on. In the case of the PRO 350's, follow the connection instructions on the box. Once on, hit the terminal's RETURN key several times until you see the login server banner: Project Athena Login Server (mit-zeus on tty01) 8:35 p.m. on Monday, 2 Jul 1984 Machine name: You want to start out with this banner. If the terminal is already asking for a login return it to the above state by entering CTRL-D or CTRL-C several times. @foot(to enter a "control character" described in documentation as CTRL-c, or control-c, or just ^c, find the key labelled CTRL on the keyboard, hold it down, and while still holding it down, enter the second character. CTRL behaves like a different kind of SHIFT key.) Type in the name of your assigned host (home) machine in all lowercase letters and press RETURN. Next the system will prompt you for your username. Type in your username in all lowercase and press RETURN. Then enter your password, followed by RETURN. Notice that your password is not echoed when you type it. If all goes well, there should be a pause, and then you will see something like: Project Athena Login Server (mit-zeus on tty01) 8:35 p.m. on Monday, 2 Jul 1984 Machine name: hera mit-hera Login: yourlogin Password: Last login: Fri Aug 30 14:07:04 on tty05 4.2 BSD Unix #44: Thur Aug 29 17:28:18 EST 1984 Welcome to Project Athena There will be another long pause, the screen will blank, and then you will see something like: Predestination was doomed from the start. host% The first "welcome" screen shows miscellaneous system information such as the last time you logged in, what version of the system is running, and any broadcast messages that Athena wants everybody to see. If there is personal mail waiting for you, you will see the an additional "You have mail" message at the bottom of the screen. The second screen starts off with a "fortune" that changes each time you login. If there is system news that Athena wants you to look at, then you will see an additional line, "There are system messages." The last line is the Unix system prompt. When you reach this point, you are successfully logged in. The first part of the prompt is the host system you are on, the second part is just a % sign. Whenever you see this prompt it means that the system is waiting for you to type commands. If you try to type anything at login before the system prompt appears it is ignored. Problem: After I typed in my username and hit RETURN it just sat there for a long time. Either your host machine or the connection to it is down. Talk to a consultant. Problem: It says something about there being too many users on or the machine being too busy and won't let me on. To prevent one course from monopolizing all the terminals in a cluster, Athena limits how many people can be logged into a host at one time. Try again later. Problem: Unix just prints "login incorrect." This could be several things. First, are you sure you are talking to the right host? Did you enter a machine name first, or just respond to a login prompt? Enter CTRL-D or CTRL-C and start over. Next, did you specify your username and passwork exactly right (no embedded blanks) as the Account Administrator gave it to you? To try again, just hit RETURN until the login: prompt reappears. If you still can't get on, ask a consultant for help. Logout You must always explicitly logout of your Unix session. You cannot just turn off the terminal and walk away; you will still be logged in. To logout of Unix, enter the command logout in response to the host% prompt. (Athena has disabled the CTRL-D logout that works on some Unix systems.) If your terminal has been idle for about an hour, Unix will log you out automatically. Problems: The system says "There are stopped jobs" or "Not login shell" and doesn't log me out. Or, I am completely stuck and just want to logout. These all have reasonable causes, but it isn't worthwhile explaining what they are right here. The best "emergency bail out" logout to use is: Press the RETURN key type in a ~. (a tilde character followed by a period) and press the RETURN key again This should log you out. If it fails, see a consultant or read below about Killing Sessions. You Have to Know... Once you see the host% prompt, you are logged in and ready to enter commands. However, before we start describing Unix commands, there are a few general facts about the system that you have to know. Control Keys: Fixing Typos, Bailing Out Unix, like other computer systems, has a set of keystrokes that you use to signal conditions that commonly occur as you enter commands and converse with the system. The main ones are: To backup and correct a typing mistake in a command line: the DELETE key. The BACKSPACE (CTRL-H, or ^H key) does not fix typos. Use the DELETE key. On PRO350, VS100, and VT240 terminals, the DELETE key isn't labelled DELETE. It is in the upper right corner of the keyboard just above the RETURN key In Unix parlance, this is called the "erase" character. To cancel a whole line and start over: CTRL-U In Unix, this is called the "kill" character. To bail out of any facility, cancel a command in progress, "get me out of here," "forget it," "stop!": CTRL-C CTRL-C usually works. If one doesn't work, try entering several CTRL-C's. Some facilities do not follow system conventions and CTRL-C doesn't work. A good first alternative to try is q (short for quit). After that, try exit, RETURN CTRL-D, or CTRL-Y, or CTRL-Z. If you are really stuck, see a consultant. Turning off the terminal does not log you out. The CTRL-S, CTRL-Q pause/restart characters that some of you may be familiar with do not work on Project Athena terminals. The NOSCROLL key will appear to work, but it is really isn't. For a substitute, see the discussion of more in the Files section. Case Sensitivity Unix is unusual among operating systems because it is case sensitive: whether a letter is typed in upper- or lowercase makes a difference. The command to list files is ls, not LS. The file readme is different from the file Readme, which is different again from the file README. The command option -p is different from the command option -P. You must train your eye to pay attention to the case of letters and always mimic exactly what you see. Most things in Unix are entered in all-lowercase, like e.e. cummings. Uppercase tends to be used selectively to make something really stand out, or when the lowercase alternative is already being used for something else. Unix's case sensitivity causes a lot of confusion and it is a matter of debate as to whether it is really a "good" feature. Nonetheless, it is the way the system works. Common Terminal Session Problems Here are a few problems that you are likely to run into as you use the system: Problem: \EVERYTHING IS IN UPPERCASE WITH \BACKSLASHES IN IT, EVEN THOUGH \I'M NOT TYPING IN UPPERCASE. When you first logged in, you typed your username in all uppercase. (Maybe the CAPS LOCK key was down by mistake.) Unix has decided that your terminal can only understand all-uppercase letters, so that is all it is sending you. The only fix is to logout, and log back in making sure you give your username in all lowercase. Problem: Everything is dead. Nothing I type shows up on the screen, not even RETURN or CTRL-C. This is usually one of four things, in order of frequency: 1. You accidentally hit the NO SCROLL key on a VT100 terminal keyboard in the lower left corner near the SHIFT and CTRL keys. This tells the terminal to stop showing you data. To start things up again, enter CTRL-Q. 2. Your keyboard has become locked. This often happens if you try to list out a binary file on the terminal, or any other un-printable file by mistake. Hit a few keys and then see if the KBD LOCKED light above the "5" key is lit. If it is, press the SET-UP key slowly twice. This usually clears the condition. 3. Your terminal settings have somehow become confused. Turn the terminal off, then on again. 4. The system on your host machine really is down. To verify this, ask your neighbors how they're doing. Try to login from a different terminal. Tell the consultant on duty. If no consultant is present, call the Athena Hardware Hotline (25)3-1410. Entering Commands The Shell You are now logged in talking to Unix. Well...not exactly. What you are actually talking to is one particular Unix program (among hundreds) called the shell. The shell is a command interpreter. This means that the shell is the Unix program that sits on the other end of the line listening to what you type, figures out what program (command) you want to run, and starts it up for you. When the program finishes, the shell comes back and asks for the next command with another % prompt. There is actually more than one shell that you can use. Normally, you use the C shell written at UC Berkeley. The actual name of the C shell program is csh. The C shell prompt always ends with the percent sign (%). There is an older shell, called the Bourne shell, that was originally written at Bell Labs. The Bourne shell's program name is sh. @foot(Athena is actually using yet a third shell, called newshell. This newshell is identical to the Berkeley C shell except that it has some additional very convenient features like those found in the Tops-20 operating system such as automatic file name completion. If you care about this, read the newshell page in the Athena Unix Commands manual, or enter man newshell. For most people, the difference is unimportant and can be ignored.) The C shell is a very powerful program, most of whose abilities are beyond the scope of this document. You can use it, for example, to run more than one program at a time. The C shell is explained fully in "An Introduction to the C Shell." This is for sale at the IPS publications office for a few dollars in 11-209. It is also included in the Athena Unix User's Guide. Online information (16 pages' worth) about the C shell is found by typing man csh. For now, the important thing to know is that the shell is your intermediary to the Unix system and its programs. Command Format The general form of a Unix command is: command options files command Unix commands are entered in all lowercase. You cannot abbreviate command names. There are currently about 250 Unix commands. A Unix "command" is really nothing more than the name of a program. options Options are the adjectives and adverbs; they modify the way that the command works, for example, "Show me all of them instead of just some," or "send it to that printer instead of the usual one." You will also see Options called "arguments," "flags," "qualifiers," and "switches" depending upon the operating system background of the person talking. Unfortunately, Unix commands are very inconsistant about they way they let you specify options. Usually: you start them with a - (hyphen or minus) sign options are: single letters (-a) single letters followed by a value (-P printer) in some newer programs, options are complete words (-draft) you can run all the single letter options together first: lpr -hf followed by all the options with values separated by blanks: lpr -hf -P laser The only way to be sure about how a command will interpret the borderline cases of its options is to look at the documentation for that command and experiment. Essential Unix shows you one form that works. files the files that you want the command to work on Separate these three pieces of a command with blanks. End commands by pressing RETURN. If you mistype the command name, the shell responds: command not found. If you make a mistake in the options, the program will show you the correct general command syntax. If there is something wrong with the file specification, Unix usually replies: filename not found, or filename: cannot open, or filename: no such file or directory. Change Your Password: passwd To protect your work and privacy, you should change your password often. To change your password, type the Unix command @i(passwd). Passwd will prompt for your old password, then ask you twice for your new password. Neither your old nor your new passwords will show on the screen as you type them. The procedure looks like so: mit-host% passwd Changing passwd for yourlogin Old password: <--- you enter it invisibly New password: <--- you enter it invisibly Retype new password: <--- enter it again mit-host% If you try to pick a password that is less than five characters long, Unix will complain. If you really want the short password, insist three times and Unix will give up and let you have your way. Getting Help Documentation: man and apropos Unix keeps a massive amount of information about itself available "online." Indeed, the entire Unix Programmer's Manual--what Project Athena sells as its Commands, Functions, User's and Programmer's guides--is available online. There are two commands that let you access this information, man and apropos. You use man when you know the command you want to use and just want to refresh your memory about its options. You use apropos when you know what you want to do, but you don't know what commands, if any, do it. The format of the man command is: man command Man will search through its database looking for an exact match for command. If it finds it, it displays it on your terminal screen. The NAME section gives a one-line summary of what the command is. The SYNOPSIS section shows you how to enter the command. You don't type the [] characters. These only mean that the option can be ommitted. The DESCRIPTION section explains the command and its options in greater detail. To get man to go on to the next page, hit the SPACEBAR. When you've seen enough, enter q or CTRL-C. Man takes some getting used to. First, you may have trouble understanding the information. Most of it was written by programmers for programmers. It tends to define rather than explain. Next, man contains many entries that are not commands. Man has 8 sections; only sections (1) and (6) are commands. The rest are system calls (2), subroutine libraries (3), I/O devices (4), files (5), games (6), odds 'n ends (7), and system manager tools (8). Sometimes you may think you've found a command and try to execute it when what you've really found is the name of a Fortran subroutine. The top line of the man page tells you what section you're looking at. The format of apropos is: apropos keyword where keyword is any word you can think of that might describe what you're looking for. apropos searches the one-line descriptions of the manual pages looking for the keyword. It them prints all the matches it has found. You then use man to look at the actual entries. apropos also takes some getting used to. You don't usually find what you want on the first try. You often fail to find it altogether. Pick your keywords broadly. "file" is a good desperation choice. You can get apropos to list all the entries in a given section of the manual. To list all the games, for example, say: host% apropos '(6)' Practise using man and apropos. They are a mainstay of a Unix user's life. We assume that you will "look at the man page" for every command introduced in Essential Unix to learn more about its functions. More online Unix documentation is kept in the network of files and directories beneath /usr/doc. (Directores are explained in a later section.) The free Athena document Start Here catalogs all the documentation available. Consultants If you have a question about Unix, the best first strategy is to ask the person next to you. Unix has a very strong oral folklore. Most Athena clusters are staffed by student consultants during the day. They will be wearing some article of clothing that identifies them, likely decorated with an underground version of the Athena owl. Student consultants can answer general questions about the system, but cannot be expected to know the nooks and crannies of every compiler and package on the system. ???Phone? old?? Hardware Trouble If you think there is a hardware malfunction, first seek out a consultant to analyze the situation. It usually isn't hardware. If no consultant is available, call the Athena Hardware Hotline (25)3-1410. Files In the small, closed Unix universe, the most popular topic of conversation is files. A "file" is just a thing with a name and data in it. Most things that you do, you do to files or their contents. There are two main types of files, simple files and directories. We will begin by discussing simple files and leave directories to the next section. File Names File names can be from one to 256 characters long. You can use any character on the keyboard in a file name, but it is wisest to stick to a-z, A-Z, 0-9 and the . (period or "dot"), and _ (underscore) characters. If you use any of the other characters, you may be letting yourself in for serious trouble. As noted earlier, case matters in file names. myfile is a different file from Myfile. Name Conventions You often see Unix files named with "extensions," for example: program.h, paper.mss. The ".characters" is the extension. People do this for two reasons. First, to remind themselves what type of file it is. A .h file is a C language "include" file. A .mss file is a Scribe text formatter file. Second, because some Unix programs, notably the compilers, require that language source files have proper extensions; .c for C, .f for Fortran, and .p for Pascal. Some file names start with a . (dot), e.g., .cshrc or .login. The only significance to this is tht these files do not normally show up when you ask for a list of your files. Background, utility, "start up" files are named beginning with .. Some examples are discussed below in the section "Exploring Your Environment." Wildcards: * and ? Unix provides a shorthand notation for referring to many files at once called "wildcard characters." There are many wilcards. Here are the two most useful: * Matches all files except those whose names begin with . (dot). It can also match characters within a filename. For example, *.f means "all the files with a .f extension. h.f and verylongfilename.f would both match. a* means "all the files that begin with a" File names a and anothernameforyou would both match. ? Matches single characters. ?.f means all one character file names with extensions of .f. a.f would match. ab.f would not. The section on Directories has examples of wildcard characters in use. To Get a List of Your Files: ls The command to get a list of the files in a directory is ls. If you are a new Athena user and you type ls, this is roughly what you will see: host% ls Mail welcome ls by itself lists just the files names, alphabetically (A-Z before a-z) in as many columns as will fit across the screen. The ls command has many options. To see all the options, enter man ls while logged in at a terminal. Here are the most important options. To get a list of all of the files in a directory, including those whose names begin with a . (dot) character, use the -a option (for "all"). A new user doing this would see something like: host% ls -a . .emacs_keys .logout .tiprc .. .emacs_vars .mailrc Mail .cshrc .login .mh_profile welcome The difference, then, is that ls doesn't show the files whose names begin with ., and ls -a does. Just what all these files are is explained below under "The Files that Come with Your Username" in the "Exploring Your Environment" section. To get a "long" listing of your files that shows much more information about them, use ls -l. host% ls -l drwx--x--x 1 you 2 Nov 3 1983 Mail -rw------- 1 you 0 Nov 3 1983 mbox -rw-r--r-- 1 you 404 Nov 27 1983 welcome The first set of information on the line is the file's "mode." A "d" in the first column means that the file is a directory. The r's and x's that follow show who has permission to read, write, delete, and execute the file. This is explained in more detail in the section on "File Protection" below. The second column shows the number of "links" the file has. We won't explain links here. For directories, it shows how many subdirectories exist beneath the file. The third column shows the username that owns the file. In most cases this should be your username. The fourth column column shows the size of the file in "bytes." In a text file, this is the number of characters in the file. The fifth column shows the date when the file was last modified. If a file has never been modified, it shows when it was created. The final column shows the name of the file. You can use other options on the ls command to get it to show you other information about your files. To get a long listing of all the files in a directory, you would enter ls -la. There are different types of files: text files, files that are directories to more files, and executable binary files. Often, you need to know the type of the files being listed. The -F (note, uppercase F) will show this: host% ls -F Mail/ a.out* myfortpgm.f welcome Notice the suffix characters / and * that are now displayed. These characters are NOT part of the filename. The / character means that the file is a directory. The * character means that the file is an executable binary. Nothing means either a plain text file, or that Unix cannot recognize the type of the file. To See the Contents of a File: cat and more There are two commands that willshow you what's in a file. The simplest is the cat command (short for "catenate"). The format of the commands is: cat filename. For example: host% cat .login stty dec setenv PATH /usr/athena:/usr/new:/usr/new/mh: /usr/ucb:/bin:/usr/bin:/usr/local:~/Bin:/usr/games:/usr/hosts setenv VISUAL /usr/athena/xemacs setenv EDITOR /usr/athena/xemacs setenv MORE -cs set ignoreeof host% The contents of the file are shownon the screen. If the file is very long, it will zip by you on the screen faster than you can read it. (CTRL-S and CTRL-Q don't work.) In this case you should probably use the more command instead of cat. You can cancel a cat command and stop its output at any time; enter CTRL-C. Problem: I "catted" a file, but I got a lot of gobble-dee-gook and the terminal acted stranged, beeping a lot. Some kinds of files are "unprintable." They contain data in a format that cannot be displayed on a terminal screen. Binary files (the ones ls -F shows with a * suffix) are not printable. Directory files (ls -F shows with / suffix) are not very printable. It is very common when you start out to say ls when you meant cat and cat when you meant ls. The more command displays a file's contents one screen at a time, pausing after every screenful so that you can read it. The format is: more filename. Most people use more in preference to cat. Once more has filled up a screen, it will not go on until you make it. The typical commands are: SPACEBAR give me the next screenful RETURN give me one more line q or CTRL-C quit, I've seen enough Alas, more cannot back up. More is a very interesting program. If one were making an "all-time Top-10" list of Unix commands, more would be near the top. It is clever enough not to display binary and directory file. There are commands that let you browse through a file for specific words, or invoke a text editor to edit the file. Most interesting is that more is what is called a Unix "filter." Many other Unix commands "pipe" their output through more. This means that instead of giving you their output directly--where it may zip past faster than you can read it the way cat does-- they send it through more first so that it will be easy to read under your control. The man command does this. You, too, can "pipe things through more." Whenever you enter a command and its output is too copious and rapid to manage, cancel the command with CTRL-C and reenter it like this: command | more The | is the "pipe" character. For example, if you have collected hundreds of files, you could pipe the output of ls through more: host% ls -l | more Look at man more to learn more about its powers. To Create a File There are many ways to create a file. The normal way to create a file is with the Emacs text editor. The free Athena document Essential Emacs, explains how to do this. A "quick and dirty" way to create a file is with the cat command (short for "catenate"). It works as follows. host% cat >easyfile Unix just moves the cursor down to the next line. You begin to type. End each line with a RETURN. You can fix typing mistakes with the DELETE key in the line you are currently typing. There is no way to fix previous lines. When you are done, finish the last line with a RETURN and then at the beginning of the next line enter just CTRL-D. It echoes as ^D. ^D host% ls Mail easyfile welcome There is no way to fix mistakes in this file short of deleting it and re-entering the whole thing. Don't forget the >filename part. If you do, cat will just echo your input to the terminal and create no new files. The >filename is what tells cat to save it as a file instead. You can take the output of any Unix command and make it into a file. For example, the command that shows you what electronic mail messages you have is scan: host% scan 102 2/10 cec (Cecilia d'O Re: IPS educational and consulting 104 2/10 jg (Jim Gettys) UUCP outgoing mail. <mymail host% ls Mail easyfile mymail welcome The ">filename" at the end of the command line is the redirection mechanism. Be sure your arrow is pointing the right way. It is all right to have a blank between the > and the filename you have selected. The "quick and dirty" mechanism shown above is really just redirecting the output of the cat command to a file. To Delete a File It is a good idea to delete files as soon as you know you won't be needing them anymore. Otherwise, your directory can become very cluttered and you will eventually run out of your alotted file storage quota and begin to have problems. The command to delete a file is rm (short for "remove"): host% rm easyfile host% Unix doesn't verify the deletion, it just prompts for the next command. You can put more than one name on the line. You can use wildcards (with caution!) to delete whole classes of files. To Copy a File The cp command copies files: host% cp file1 file2 host% Unix copies from the existing file1 to the new file2. If file2 already exists, it will be overwritten. Again, Unix does not verify the copy. Copies from one machine to another work slightly differently. See the section below on "Dealing with Other Machines." To Rename (Move) a File To rename or move a file, use the mv command: host% mv file1 file2 host% Unix renames file1 to file2, in effect "moving" it from one file to another. If file2 already exists, it is overwritten. As ever, Unix does not confirm that it has done the operation. Printed Output Printed output is a copy of a file on paper. Each Athena cluster has at least two printers, a laser printer and a line printer. A large sign posted in the cluster terminal room tells you where the printers for that cluster are, and any combination you may need to get into the printer room. In some clusters, the printers are in the same room as the terminals. The laser printer is the default. Laser printer output is on 8 1/2 x 11 cut sheet paper with 66 lines to the page and approximately 80 columns across. The font is a 10-character to the inch, fixed-width typewriter-like style called "Courier." This is currently the only font available, there are no italics, and no boldface. The laser printer produces about 6 pages per minute and has a limited paper capacity. Problem: very long input lines (>140 characters) such as might be produced by repeated backspaces and underlines during a Scribe run can confuse the laser printer. The line printer prints on 11 x 15 continuous form computer paper with 66 lines to the page, and 132 columns across. The font is a 10 character to the inch, fixed width, sans-serif style. The printer can do overstriking for boldface type. Print quality is poorer than the laser printer. To Send a File to the Printer: lpr The lpr command (short for "line printer") sends a copy of a file to the printer. The general form of the command is: lpr [-P printer] filename The [] are NOT part of the command. Rather, they mean that the -P printer option is optional and can be ommited if you like. The -P option states which printer you want the file(s) sent to. The choices are: -P laser this is the default printer. It sends the file to the laser printer for your cluster (as posted). -P line the line printer for your cluster, as posted. -P alternate each cluster has a laser printer for a different cluster designated as an alternate printer in case your cluster's printer is down, or out of paper, or excessively busy. The alternate printer location should be posted in the cluster. lpr does not verify that it has sent your file(s) to the printer. The lpr command has many options (not all of which work). Type man lpr to see the choices. The lpr command also does not always tell you when you have made a mistake in its options, it just ignores the options it could not handle. You may notice two other possible candidates for commands to send output to the line printer, print and pr. print is an old command that has been superceded by lpr. In spite of what the documentation seems to say, the pr command doesn't print anything. Rather, it is useful for doing minor formatting of output files, such as producing a 2-column format, or adding page numbers and headers, before you actually print the file with the lpr command. The lpr command does have an option (-p) that allows you to run your files through pr on the way to the line printer, but not all of pr's optins work when called this way. pr can be quite handy, but understand what it is not. What Files Are Waiting to Print: lpq When you send a file to the printer with lpr, the file actually is assigned a job number and goes into a waiting line (queue) before it prints. If there are files ahead of it in line, sent by other users, then it waits its turn to print. If there are none before it in line, it will print immediately (unless the printer is broken). Very often, you will want to look at this printer queue to see what's happening with your print job, or to find out your print job's number so that you can cancel it. The command to do this is: lpq [-P printer] lpq is short for "line printer queue" -P printer has the same meaning it had for lpr. It specifies which printer queue you want to see. -P laser is the default. -P line specifies the line printer. -P alternate shows the queue for the alternate printer. lpq has a few other options; see man lpq. Problem: I say lpq, but I don't see my print job. There are two main possibilities. The most likely is that your job has already printed. Alternatively, you sent your output to a different printer queue with the -P option, but forgot to give the same -P option to the lpq command and you are looking at the wrong printer queue. Problem: I say lpq, and get no response at all, things are just dead. Either the print server machine is down, or the network connection to it. To Cancel Print Jobs: lprm Often you change your mind about printing a file. Perhaps you accidentally sent it to the line printer when you meant to send it to the laser printer, or you gave the wrong filename. You can cancel a print job. Use: lprm [-P printer] [-] [jobnumber] lprm stands for "line printer remove" -P printer Remove the job from which printer queue? -P laser -P line -P alternate jobnumber By default, jobnumber will the the number of whichever job is actually printing. If this is your job, it will be removed. If it isn't, then you will get a "Permission denied" message. If your job is not actually printing, you must either use the - option below, or you must give an explicit job number. Use the lpq command to find out what the job's number is. - means remove all my jobs in the specified printer queue You may get some slightly surprising messages from lprm. You should understand that only one host in a cluster actually has printers attached to it. This is the "print server." Print files from all machines in the cluster are first forwarded to the print server, then printed. This is why youmay get a printer message from, say, mit-zeus when you are logged in to mit-hera. For more information on lprm, see man lprm. Problem: The printer's out of paper. Reload the printer yourself from the stock at hand, following the instructions on the printer. Problem: There is no paper stock around. ????I still don't know what to tell them.???? Problem: The laser printer just sits there with an L1 error code. The laser printer shuts itself off when there is no activity for a length of time. It now has to warm up again for about five minutes. Interlude This is the end of the truly "survival" material in Essential Unix. You can do a lot of useful work with just the information presented so far. Probably the best thing to do now is to find the free Athena document Essential Emacs and learn the basics of the text editor. The sections that follow contain information that you can put off learning about for a few days, anyway, but which you will probably need to know about before too long. Directories All files in the Unix system are stored in one large hierarchical tree structure. Everybody's files are somewhere in this tree, occyping some sub-branch: the system's files, your files, other users' files, the mail files, the documentation files. See the picture. Learning your way around this tree structure, gaining a rough idea of what's kept where, and knowing how to get to it, are fundamental to your understanding of Unix. Without it you can function, but you will always feel a little confused, a little out of it, like a stranger in a group of old friends who just doesn't quite ever get it. The tree structure is made possible by a special kind of file, a directory file. A directory file is nothing but a list of pointers to other files. These other files can be text or binary files, but they can also be more directory files (often called subdirectories). These subdirectories can, in turn, point to still more directory files down to many levels of depth. Up to know we've seen only simple filenames like myfile or fortprogram.f. A file's full name is its "given" name precded by the path of directories that the system must follow to reach that file in the Unix tree structure, separated by the / (slash) character. Look again at the picture. At the top of the tree is a file called "the root directory" because it roots the whole tree. Its name is / (just a simple slash). Below that are a set of major directories like bin, dev, etc, mit, projects, sys, and usr. Now look at the mit directory (proper name: /mit). This is the major subtree where user's files are kept. Below it are more subdirectories, one for each letter of the alphabet (/mit/a). Below each of these the same alphabetic pattern is repeated (/mit/a/a). Strung out underneath these doubly-alphabetized directores are directores named after the usernames of everyone on a particular machine. User dkfritz has a directory /mit/d/k/dkfritz. The Working Directory We said that a file's full name is its given name preceded by the path of directories one must follow to find it. Why don't you have to give the file's full name every time you specify it? You don't because the system keeps a value for you called the working directory. (Also known as a "default directory," or "the current directory.") Whenever you specify a simple filename, the system assumes that you are talking about a file in your working directory. A working directory is, simply, the directory you are currently "in". You can change your working directory at any time. The system provides a few short-hand synonyms for the working directory. A simple . (dot) used in a directory specification means "the current working directory." As a shorthand for "the directory above my current working directory," the system recognizes .. (two dots together. Examples using these shorthand synonyms are given below. The HOME Directory Unix also employs the concept of a HOME directory. This is the beginning of your subtree on the main tree, where all the files that belong to you are stored. For user dkfritz above, it was /mit/d/k/dkfritz. Your own HOME directory is named according to the same pattern. You can verify your HOME directory by typing: printenv HOME When you login, your working directory is set to be your HOME directory. Thus, unless you explicitly say otherwise, the system assumes that you are always talking about your own files stored under your HOME directory whenever you give a filename in a command. Synonyms for HOME Directory: ~/ Typing out /mit/d/k/dkfritz everytime you want to discuss the HOME directory of a user is tedious. Unix provides shorthand synonyms for HOME directories. To say, "my HOME directory" type: ~/ To say, "user dkfritz's HOME directory" type: ~dkfritz To Make a Directory: mkdir You can make subdirectories under your HOME directory to better organize your files. Saying: host% mkdir forclass will make a directory called forclass under the current directory. Unix, as usual, will not verify that it has created the directory. To Change the Working Directory You will often want to temporarily change your working directory from your HOME directory to somewhere else on the tree. Use the cd (for "change directory") command. For example, if you had just created a subdirectory forclass and now wish to make and modify files in that directory (or "work in" that directory, as the saying goes) you could tediously specify those files as forclass/assignment1 and forclass/lectnotes. Or, you could change your working directory to forclass and speak of them as just assignment1 and lectnotes: host% cd forclass Sometimes, you may be working somebody else' directory, somewhere else on the tree. Rather than always typing out /mit/o/t/otheruser, you can just change the working directory to their HOME directory: host% cd /mit/o/t/otheruser or host% cd ~otheruser Perhaps you've gotten curious about how Scribe works and wish to rummage around in the Scribe database files. Switch to that portion of the tree with: host% cd /usr/athena/lib/scribe_data To Find Out What Directory You're In As you start hopping around the tree with cd commands, it is easy to forget where you are. You can always find out your current working directory with pwd (print working directory). For example: host% cd /usr/prototype_user host% pwd /usr/prototype_user To Return to Your HOME Directory The quickest way to change your working directory back to your HOME directory, no matter where you have wandered in the tree is: host% cd cd defaults to your HOME directory. This is equivalent to saying cd ~/. To Delete a Directory: rmdir You cannot delete a directory unless all of the files underneath it are gone. This prevents you from accidentally wiping out important subtrees with one careless command. A quick way to delete all the files in a directory you want to get rid of is to change to that directory with cd, then: host% rm * Be careful before you do this! There's no going back. If the directory also has .files in it, you must say: host% rm *. You can then delete the directory itself. Move out of the directory back to the one above it, then type: host% rmdir dirname The -r Recursive Option Many commands will have a -r or -R "recursive" option. When talking about directories, recursive means "do it to this directory and all the files and subdirectories underneath it." R options are thus very powerful and should be used with caution. For example, one could perform the two steps required to delete a directory in one step as follows: host% rm -r dirname For some reason, -r only works with rm, not with rmdir. A sleepy programmer logged in as the user "root", that special all-powerful username that system managers use to control the system, could take out the whole file system with just: host% rm -r / The recursive option on the cp (copy) command makes it easy to copy entire subtrees from one place to another. There are examples of this in the next section. Sample Directory Specifications It takes a little practise to get the knack of correctly typing filenames and directories so that you get the files you want. Here are some common specifications. All of these have synonyms that would work just a well. a directory called foo below my current one: foo (as in cd foo) a file stuff in directory foo below my current one: foo/stuff all the files in directory foo below my current one: foo/* my HOME directory: ~/ a file stuff in my HOME directory when I'm in my HOME directory: stuff a file stuff in my HOME directory when I'm someplace else: ~/stuff a file stuff in user sam's HOME directory: ~sam/stuff a file stuff in user sam's subdirectory foo: ~sam/foo/stuff up one directory: .. (as in, pop me up one level: cd ..) a file stuff in the directory above me: ../stuff a file stuff in the directory foo in the directory above the one I'm in: ../foo/stuff copy my file george into my subdirectory archive: cp foo archive copy sam's file foo into my current directory, and keep the same name: cp ~sam/foo . copy sam's file foo into my current directory, but with a different name: cp ~sam/foo fromsam copy all of the files in sam's subdirectory foo, including all subtrees into my current directory, and keep all the names the same: cp -r ~sam/foo . Problem: ls /Mail: Permission denied. This is one manifestation of a common mistake people make when learning about directory specifications. This person was trying to list out the files under the Mail directory. Your first reaction is to feel indignant about not being allowed to look at your own mail files. The problem is the / A slash at the beginning of a directory specification means the whole system's root directory. Thus, you aren't naming your Mail directory, you're naming a Mail directory immediatly under the root directory. This happens to belong to the system manager, who doesn't want you looking at his/her mail. Never start a directory specification with / unless you explicitly mean one of the directories immediately below the whole system's root directory. (I.e., like /etc, /mit, and /usr.) System File Organization: An Aside This section on directories has emphasized talking about your own, and possibly a neighbor's files. but as anyone new to Boston must, over time, construct a mental map of the city, its suburbs, squares, T stops, restaurants, movie theatres, and points of personal interest beyond their immediate neighborhood, so should you get an inkling of what is kept in other parts of the Unix file system. Here's a nickle tour. Start at the root directory and enter: host% ls -F / (The -F is there to show you which files are directories, text files, and binaries.) You will see something like: Mail/ etc/ mnt/ src/ u2/ bin/ lib/ projects/ src.log usr/ boot* lost+found/ restoresymble staff@ vmunix* dev/ mbox site/ sys/ vmunix.0.11 mit/ source/ tmp/ vmunix.0.3 Each of these root level directories contains different sorts of files that the system needs to function. There are strong historical conventions for what goes in each of these root directories (as well as many arbitrary exceptions). You can look at most of these files. Except for the /mit subtree and a few other exceptions, Unix is open for inspection by anyone curious enough to look. The /bin directory contains the binary (unreadable, excecutable machine language) versions of the programs you absolutely can't bring up a Unix system without, such as the cat and rm commands. When you type the cat command, you are actually executing the file /bin/cat in this directory. The /etc directory contains all the administrative information files necessary to run the system. This includes the /etc/passwd file that defines who has a username on the system. It makes for interesting browsing. The /mit directory, as you already know, contains all user files. The /projects directory contains all the files for Athena projects. You may not have a /source or /src directory. It normally contains all the source code for the entire system. Perhaps the most interesting directory is /usr. /usr has traditionally been where all users' files were kept. (Athena uses /mit for this.) Later, it also came to be the place where documentation, games, and programs added at the local site were kept. For example, /usr/ucb has all the programs that the University of California at Berkeley added to the original Unix to make Berkeley 4.2. /usr/athena has all the programs, like Scribe and Emacs, that Athena is adding to the Unix it got from Berkeley. /usr/doc contains documentation of general interest to users. /usr is worth quite a bit of browsing. To get a detailed outline (somewhat out of date) of this entire system tree, enter: host% man hier File Protection: Who Can Read Your Files? You are the only person who can create, read, modify, delete, and list the files under your own HOME directory. This whole issue of who can see and do what to whose files is called file protection or mode. Unix organizes file protection as follows: The world of users is divided into three main categores: other All users, even users from other machines. This is often referred to as "the world," or "public". group A group is a subset of users as defined in the file /usr/group. You can be a member of any number of different groups at the same time. To see what groups you are in, enter the command: groups Everyone in a particular course may be in one group, say 2.10. All users are in a primary group called mit. Since everyone is in group mit, it is for all practical purposes the same as world ("other"). There is currently no way for users to create new groups themselves. user This is you. This may sometimes be referred to as "owner." A File is "owned" by: The user who created it. The user who created a file is the only person who can change the protection on a file. Only the superuser can change the owner of a file using the chown command. It is why you never have someone give you a file; you always copy it from them yourself. Otherwise, you may find files under your directories that you cannot delete because you don't own them. One group. By default, a file copies its group ownersip from the directory under which it was created. Your HOME directory is owned by your primary group, mit. It is NOT owned by any other group you may belong to. Therefore, unless you tpae active steps, all of your files will be owned by group mit. To see who the group owner of a file is, add the -g option to the ls command: host% ls -lg filename To see the group owner of a directory, say: host% ls -ldg dirname You can change the group owner of a file with the chgrp command. Only the user who owns the file can change its group owner. Each file, plain or directory ha three kinds of access that can be granted to it: read, write, and execute. The interpretations of these three access modes are slightly different for plain files and directories. They are as follows: (taken almost verbatim from McGilton) Read A user who has read permission for a file can look at the contents of that file. A user who has read permission for a directory can find out what files are in that directory. If detailed information about the files in the directory is required, the directory must also have execute permission for that user. Whether the user can see the contents of the files in the directory depends on the read permissions for the files themselves. Write A user who was write permission for a file can change the contents of that file. A user who was write permission for a directory can change the contents of the directory: he/she can create new files under that directory, and delete files stored in it. Whether he/she can change the contents of the files depends upon the write permission for the files themselves. Write is the most powerful access permission. Execute A user who has execute permission for a file can use that filename as a Unix system command, provided the directories above it also have read permission turned on. A user who has execute permission for a directory can change directory to that directory and can copy files from that directory, providing the user also has read permission for the directory. The execute permission is often called a "search" permission. Thus, each file can grant three types of permission to three different categories of users. This vector of permission is called the file's mode. The mode is expressed in two ways. The first format is what shows up when you do an ls -l command. A file with all permissions turned on looks like: rwx rwx rwx --- --- --- | | |____ other (world) permission | |________ group permission |____________ user permission A missing permission is indicated by a "-". Thus, a file with user-only read, write, and execute permission would look like: rwx------. There is a second, numeric format in which to describe protection. Here is a table of equivalences: (from McGilton) user group other r w x r w x r w x | | | | | | | | | 400 ---------------------- | | | | | | | | | | | | | | | | 200 ------------------------ | | | | | | | | | | | | | | 100 -------------------------- | | | | | | | | | | | | 40 ----------------------------------- | | | | | | | | | | 20 ------------------------------------- | | | | | | | | 10 --------------------------------------- | | | | | | 4 ----------------------------------------------- | | | | 2 ------------------------------------------------- | | 1 --------------------------------------------------- To translate the mode you require to a number, add up the numbers corresponding to the individual permissions you want. If you want the files to be user read and write, group read, and world read, you would perform the addition: 400 200 40 4 ---- 644 Seriously. A file with all permissions turned on (rwxrwxrwx) is referred to as a mode 777. rwx--x--x is 711. Notice that there is no way in this scheme to grant access to a file to a particular user. The Default Protection At Project Athena, the default protection for private files (under /mit) is rwx--x--x (711). That is, only the user who created the files can do anything with them. The group and world x (execute) permission does not give users in those categories any access to your files because they do not have permission to read the directories they must pass through to get to the files. It just makes it a little easier for you to share one of your files should you decide to later. Project files (under /projects) are meant to be shared among members of a group so their default is different: rwxr-x--x (751). Changing Protections You change the protection on a file with the chmod (for "change mode") command. The general form of the command is: chmod mode file Chmod does not accept protections expressed in the the simple rwxrwxrwx form, although it does allow a variant on that form. Usually, people use the numeric (711, 644, etc.) form for expressing modes. We will now show you how to do some common protection changes. You should be able to figure out your own minor variations from these examples. To Make a File Readable by Everyone in a Group If you have a particular file that you want everyone in a group to be able to read and execute: 1. Change the file's group owner from the default mit to the name of the group. (Again, the group must be predefined in /etc/group.) chgrp groupname filename 2. Now change the group protection on the file to allow group read and execute. chmod 751 filename To Make a Directory Where All Members of a Group Can Read and Write Groups often want a directory that everybody can write on to place the files they all want to share. Athena projects would likely do this under their /projects/projectname administrative directory. Here is how: 1. Make the directory. mkdir dirname 2. Change its group ownership to the correct group (must be predefined in /etc/group). chgrp groupname dirname 3. Change its protection to allow group read, write, and execute. chmod 771 dirname Any files that you create under this directory will still have the default protection of user /read/write/execute (rwx--x--x) only. You and the other members of your group will have to individually reset the protections to 711 for each file that you place here. Otherwise, people in your group will be in the strange position of being able to delete files they cannot even read! Athena courses may well wish to make directories that allow group read and execute only (751). To Make a Public Directory Many people will want to create a public directory where they will place things that they wish to offer for the public benefit of the community. 1. Make the directory. Calling it public would be intuitive. mkdir public 2. Change its protection to world read and execute. (World write is inviting trouble.) chmod 755 public Again, you will have to manually reset the protection of each file you place under your public directory to 755 because it will be created with the more restrictive 711 default. To Open Your Files to All: An Interesting Issue The traditional default file protection on Unix systems is rwxr-xr-x. In addition to the file's owner having full control of his/her own files, all other users are permitted to read a user's directories and files unless that user takes explicit action to close off access. Anyone can look at and copy anybody else's files. Project Athena started creating user accounts with this traditional rwxr-xr-x (755) protection. The MIT Committee on Privacy that is charged with safeguarding the privacy of MIT students, faculty, and staff reviewed this default protection and decided that it should be changed to rwx--x--x (711, owner access only). The default protection was changed on ????? (We havn't done it yet.) The reasoning is a combination of the belief that the "mom and pop shop" protection scheme of the traditional Unix would not scale up to the eventual Athena community size of 10,000+, that most people do not expect their files to be public, do not investigate the question, and are quite surprised and upset when they find out that this is the default, and that the Unix file protection mechanism is too complicated to grasp quickly when one is new to a system and not interested anyway and therefore the burden upon the novice to figure out how to make files private is unreasonably great. The feeling is very strong among Unix programmers that the traditional relaxed, sharing, open attitude toward file protection is a major factor contributing to Unix's success as an operating system. If you want to profess the Unix "live free or die" philosophy and make your files publically readable, here's how: 1. Edit your .login file. Change the line reading "umask 66" to "umask 22" (Umask uses yet a different numbering scheme, the octal ones complement of the other numbering scheme.) This is rwxr-xr-x (755). 2. You must change the protection on your HOME directory: chmod 755 ~/ 3. If you wish you can then change the protection on your existing files to 755 with the chmod command. Chmod does not have a -r recursive option. 4. If you do wish to have private files, the convention is to create a subdirectory and keep the files there: mkdir private chmod 711 private You do not have to individually change the protection to private on the files within the directory as you have to individually "liberalize" the protection of files in a public directory. This is because the private mode on the directory effectively locks the door to anything below it. Caveat Emptor: A Final Warning A conversation overheard: Systems programmer: "I came in on Saturday because I had to change some things and I discovered that G---- had changed the root password. Changed the root password without telling anyone what the new one is! Well, I had to get my stuff done, so I dinked around a bit and you know how long it took me to break in? Eleven minutes." Manager: "You're slipping." The expertise that let the programmer above figure out how to log in as the root user--who can do anything on a Unix system--in under fifteen minutes without knowing the password is fairly common around MIT. Unix is not a secure operating system. Although file protection is set up so that only you can manipulate your files, this is really not anymore effective against the determined intruder than the lock on your house door is against a burglar. The best that Athena can offer to keep data private is the crypt command. This allows you to encrypt a file using a key you specify so that even if someone does read the file, they will see only gibberish. This, however, doesn't protect against malicious deletion or overwritting. The final word must be that if you have data that MUST be private and that you cannot stand to lose, don't keep it on Athena. Exploring Your Environment The purpose of this section is to introduce you to some of the features of your new Unix environment. Rather than explaining in detail what they are and how to manipulate them, the point is more to let you know that they exist and can be manipulated at a later time if you want to invest the effort to learn how to do it. The Files that Come with Your Username You may have noticed that your new username already has a number of files in its HOME directory. To get the complete list, since most of them are "dot" background files that don't normally show up, add the -a option to the ls command. You will see something like: host% ls -a . .emacs_keys .logout .tiprc .. .emacs_vars .mailrc Mail .cshrc .login .mh_profile welcome What are these files? . and .. These are the files that implement the synonyms . and .. for "working directory" and "the directory above me." You can ignore them. Mail This is the directory where your Mail is kept once you've inc'd (incorporated) it. See the free Athena document, Essential Mail for an explanation. .cshrc This is an important file. It is a file full of commands to the C shell (csh). This file is executed every time you start up a csh. The most obvious time you start a csh is when you log in. Here are a few highlights: set history=40 savhist=50 Set commands are csh "built-in" commands. They give csh variables values. The C shell has a so-called "history" mechanism. This means it keeps all of the commands you enter during a session. You can use the history mechanism to re-execute commands you've already entered or to edit long commands you made mistakes in. This line tells the history mechanism to keep the last 40 commands you entered, and to keep the last 50 commands you've entered during your previous login sessions in a file called .history. alias mail Mail alias back 'set back=$old, set old=$cwd; cd $ back; unset back; dirs' The csh alias mechanism lets you invent and name new commands out of old ones. The first alias is a simple one, it changes the definition of the all-lowercase mail command to point to a newer, better program. (Neither of which Athena supports.) The second alias is defining a new command, back, that remembers the last directory you were in and changes you back there. As another example of a useful alias, if you like the -F option to the ls command that shows you what type of file each file is, you could redefine the ls command in your .cshrc file like this: alias ls ls -F Now ls will always show you the file types. alias logout bye would make "bye" a synonym for logout. .emacs_keys .emacs_vars Emacs is the Athena-supported editor. Emacs works by "binding" keystrokes to editing commands, like binding CTRL-N to "go down one line." You can customize these bindings to suit yourself by defining new bindings in this .emacs_keys file. Emacs also has variables that control things such as "should I automatically wrap long lines or not?" You can define different default values for these variables in this .emacs_vars file. Notice that both files are empty. .login This is the most important file here. It is a file full of csh and Unix commands that is executed everytime you login. It does the most to establish the Athena character of your environment. Here's what the lines are doing: # comment character stty dec This line defines DELETE as the erase character, CTRL-C as the kill character, and several other less important key strokes. If you preferred different keystrokes for these functions, you can change this stty line to somethig else. See man stty. set path=(. $HOME/Bin /usr/athena /usr/new /usr/new/mh /usr/ucb /bin /usr/bin /usr/local /usr/games /usr/hosts) This sets the csh path variable. What's that? Remember that we said in section ? that a Unix command was nothing more than the name of file with a program in it? What happens when you type a "command", say ls, is that Unix takes this path variable--which is nothing more than a list of directories--and looks in each one until it finds a file called ls and then tries to execute it. (It must have x "on".) For ls, it would look first in your current directory (.), then in a Bin directory in your HOME directory, then in the directory where Athena is keeping its additions to Unix (like Scribe and Emacs), then in the next directory, and so on until it found a file called ls. (It would have found ls in /usr/ucb.) If there's more than one ls (there is), it executes the first it finds. This is the way all "commands" work. The path variable is an extremely important, extremely flexible tool. It literally defines what commands you "know about." If you were working on a project or taking a class where important programs you were asked to execute repeatedly were being kept in a central directory, you could add that directory to your path variable search list and treat all the program names just like commands. setenv ... setenv commands are similar to set commands. They establish values for csh environment variables. setenv VISUAL and setenv EDITOR are part of what causes the Emacs editor to be called when you're composing mail instead of any other editor on the system. setenv PRINTER is what makes the laser printer your default instead of the line printer. To see what environment variables there are and what they are set to, enter: printenv set ignoreeof On Unix systems, CTRL-D traditionally works just like the logout command. This can really surprise people and so Athena disabled it as a logout equivalent with set ignoreeof. set noglob ... This sets your terminal type correctly or causes you to be asked for a terminal type if you are dialing in. Don't change it unless you understand exactly what you are doing. /usr/games/fortune This is what causes the "fortune cookie" to appear at login. If you are getting tired of the quips, you can delete this line and they'll go away. msgs -q This checks to see if there are new system messages that you havn't read before. Without it, you would never see that "There are system messages" line you sometimes get at login. umask 66 This is what establishes the default protection on all of your files as rwx--x--x. If you want to change the default, you would change this line. See the previous section on File Protection. returning to the rest of the files... .logout like .login, but executed at logout. Athena's default contains only a command to clear the screen. .mh_profile sets certain standard values used by the mh mail system, including what editor to use and what protection to give your mail files. The rest of the files are not very important. Various system utilities like msgs and notes may create files like this in your HOME directory. Most will have the suffix "rc" (short for "run command file"). The utilities use these files to save state and variable information. If your Unix username is a project username like 6.032 or 2.10, then you will have some additional directories. See the README file that comes in your HOME directory for more information. Your Neighbors: Who's On? Unix is an intensely social system. Unix users spend a great deal of their logged-in time exchanging mail with each other, participating in the public discussion forums, and talking with each other. Here are some of the programs that assist this socialization: mh The Athena electronic mail system. mh is not a command, but an assemblage of system-level commands that together make up a mail utility. To learn about mh, get the free Athena document Essential Mail. /etc/passwd This is the raw accounting file that says who has accounts on your machine. List it out with the more command. See man 5 passwd for an explanation of what you're looking at. users who w These commands tell you, with progressively greater detail, who is logged on to the system at the moment. See their respective man pages. finger The finger command has two forms. As just finger, it tells you who is logged in. When specified as: finger string where string is a username or a part of a person's name, finger searches through /etc/passwd to find who it has on the system that matches string, then prints out what information it has about them. See man finger. .plan If you create a file called .plan under your HOME directory that contains whatever personal data you care to tell the world about yourself, then when someone fingers you, this .plan file will be displayed. See man finger. chfn This program lets you add fundamental information (office, phone number) about yourself to the /etc/passwd file. This information will be printed when somebody fingers you. See man chfn for details. talk This is a fun program. If another user is logged in, you can converse with them without the delays of electronic mail. The spontaneity of the exchange is more like a phone call than a letter. See man talk. notes msgs Both of these are public discussion forum systems. They can be a great source of information and recreation, and also an infinite time sink. Notes is much more advanced than msgs, but as of this writing it was not clear that it would be available for the Fall '84 semester. See man msgs and man notes (if available). What's the System Doing? ps The ps ("process status") command prints information about processing running on the system. A "process" is almost anything; any command entered, anybody logged in, any jobs the system (root) is running. The ps command has many options. Here are two common versions: print out all the information about my processes: ps -ux print out all information about all processes on the system: ps -aux To Kill a Session The one thing you don't want to do is leave yourself logged into Athena. You may have accidentally dropped a dial-in line, or gotten hopelessly stuck inside some program that simply won't let you out and turned off the terminal and walked off hoping it would somehow go away; but you are really still logged in and vulnerable. The next person who dials in or turns on that terminal will be logged in as you. The final recourse is to start a new terminal session and kill off your old one. You will rarely lose anything. The Emacs editor, if it is interrupted, will save the state of the file it is editing in a file called #emacs1. To kill an old session, login on another terminal. (If you are dialing in, just dial-in again.) @begin(enumerate) @multiple[ Once logged in, give this command: @example{ host% users dssaxon nbsina you you pegray dkfritz glwilson } This verifies that you are, indeed, logged in twice. ] @multiple[ If you are logged in twice, then give this command: @verbatim{ host% ps -ux USER PID %CPU %MEM SZ RSS TT STAT TIME COMMAND you 29001 81.3 3.0 157 94 ? R 0:00 ps -ux you 28961 6.0 1.7 121 52 co I 0:00 -csh (csh) you 28949 0.5 1.7 121 52 co S 0:00 -csh (csh) } These are all the processes that belong to your login id. Find the one with the lowest PID ("process id"). It is @i(probably) the oldest, and hence the one you want to do away with. It should also have "-csh (csh)" under the "COMMAND" column, indicating it is a login shell. There should be two such "-csh" processes, otherwise your old process is probably already gone. ] @multiple[ Issue this command: @example{ kill -9 process-id } Replace "process-id" with the PID of the oldest process you found above. (By the example it would be 28949.) ] @multiple[ Verify with more @i(users) and @i(ps) commands. You have now most probably killed off your orphan session. If, instead, you suddenly found yourself logged off, then you have killed your current login process, not your old one. Sometimes the lowest PID is @i(not) the oldest process. This is rare, but it happens. You will have to repeat the entire procedure, only now kill the other -csh process. ] @end(enumerate)