|
UNIX: The BasicsThis document is intended to be an introduction to the use of Harvey Mudd College Computer Science Department's computers running UNIX. This document focuses primarily on knuth, the department's IBM running Debian GNU/Linux, although most information pertains to all Computer Science machines. The document presents a new user with enough information to begin using knuth and illustrates practical uses of some basic UNIX tools. A table of useful commands is also included. The information in this document is subject to change without notice. The Computer Science Department assumes no responsibility for any errors in this document but will attempt to correct errors brought to its attention. Corrections and comments are welcome and should be sent to staff.
Contents:
Chapter 1 Starting OutThis manual provides a basic introduction (plus some more advanced material later on) to the use of knuth and the other Computer Science Department computers. Currently the Computer Science Department runs the following systems: an UltraSPARC Enterprise 3000 running Solaris 9 (turing), a Sun ULTRA 30 running Solaris 7 (muddcs), and knuth running on Linux. Please see the resources page for more information on the CS department's systems. Before you can log in, you must have your own account. CS60 students should receive a new account slip with their orientation packages. This account slip will contain your username (usually first initial + last name) and your account password. If you do not have an account you should contact the CS System Administrator in Beckman 101 or at extension x73485. If you are in Beckman B102 or Beckman B100 then you may be logging in on a Machintosh machine. See Chapter 4 for help on Macs. 1.2.1. Logging In Most users connect from the dorms through an ethernet connection. If you have a working ethernet connection, you can choose to ssh to knuth and you will get a username prompt. Once you have established a connection, the computer will prompt you for your username. Then, after you have entered your username, the computer will prompt you for your password. Here's what a typical login looks like:login: juser password: Your password will not be displayed as you type it. (Note that you must hit Enter at the end of each command line, although we won't remind you from now on.) If you are successful, you will see system notices and then your prompt will appear. The default prompt you get depends upon which shell you are running, but will most likely be either a percent sign ("%"), a dollar sign ("$"), a greater-than sign (">"), or a pound sign ("#"). This indicates that the system is waiting for you to enter a command. On the other hand, if you are unsuccessful, the computer will respond with login incorrectand you will have to try again. Remember that your username is in all lowercase letters. 1.2.2. Change Your Password The first thing you do the first time you log in is change your password. To change your password type % passwd The system will ask you for you current (old) password and then ask you for your new one. It will then ask you to confirm your password. It will also advise you if your password is too short or too simple. It is very important to pick a password that is not construted using your name, other personal information, or a list of dictionary words, since these methods are commonly used to break into accounts. Your password should be 8 characters long, and should include at least one capital letter, one lower case letter, and one character that is not part of the alphabet. Certain symbols like the pound ("#") symbol and the at ("@") symbol are not recommended since they sometimes are used by the computer to hold special information. 1.2.3. Basic Command Information There are functions that require you to type a character by hitting more than one key at once. These are known as control characters, and are typed by holding down the Ctrl key while you hit another key. We'll indicate control characters in this document with the caret (^). For instance, you can usually terminate the process currently running press ^C. Don't type the caret; just hold down the control key and hit the letter key. To execute a program, whether a UNIX utility or a program you wrote, enter that program's name at the prompt. There is no "run" command. For example, to execute the date program (which gives the date and time) just enter: % date Thu Oct 27 19:17:57 PDT 2005 If you are stuck in something you can't get out of, try ^C. If your screen seems frozen you may have typed ^S by accident. Try ^Q to get out of this. If you are familiar with job control (see section 2.4) you can try to suspend and then kill a process. If none of these work, ask someone for help. Also note that UNIX is case-sensitive, so that RM, rm, Rm, and rM are all interpreted differently. This applies to filenames as well as commands, so be careful when you type. 1.2.4 Logging Out To log out, you must be at your prompt, %, and then you can type any of the following: % logout % exit % ^D If you are on a Mac, Section 4.3.5 describes how to log off a Mac.If you need to leave your terminal and you want to continue working when you return, you can lock your screen (for help on locking screens on the mac see sec. 4.3.6). All of your processes will still be running, and you won't be logged out, but it will prevent others from using the terminal. Just type your password to get back to your working screen. Please be considerate when using this function, though, especially when you will be gone for long periods of time or when there are lots of people trying to use terminals in the terminal room. If your locked screen becomes a problem, a CS staff person can break the lock on your screen and log you out. What is a file? Well, in UNIX a file is just a collection of bytes, or in other words just data. A file can be a love letter, a CS assignment, data from your last chemistry lab, or even a "directory" full of more files. The file's meaning depends solely on the program using it. UNIX doesn't require text files to have one format and the object code of a program to have another. To UNIX, files are files. 1.3.1 Common File Commands Most files are stored in directories. A directory is just a file containing a list of other files (similar to a folder). Whenever you log in, the computer automatically places you in your "home" directory. To get a list of the files and directories in your current directory, you can use the ls command, which is short for "list" files. Try this: % ls Well, most likely you just got the % prompt back. This is because you don't have any files yet except that you may have "dot files." These files are hidden so the default ls command does not list them. To see these dot files type: % ls -a The "-" is a standard UNIX way of sending options to a program. In this case the option -a tells the program ls that you wish to see all of the files, including the dot files. If your account has been set up correctly, you should see a list of a bunch of files on your screen. Just having files isn't very useful if you can't read them. The most common way to view a file in UNIX is the more command. For example, to view the .zshrc file (which contains configuration options for the "zsh"shell) type: % more .zshrc When you get the "--More--" prompt, hit Return to see the next line of the file. Hit the space bar to see the next screenful (or windowful). If you wish to quit before you reach the end of the file, hit "q" at the "--More--" prompt to return to your % prompt. A similar command that has more features (like allowing backwards viewing in a document) is the less command. Just type "less file" to view the file. Then use "f" and "b" to go forward and backwards in the document page by page, and use the up and down arrow keys to move up and down in the document line by line. Press "q" to get out of the less viewer. Printing a file is just as easy as displaying the file on your screen. The lpr command will take the file whose name you give it and print it out on the laser printer in the Computer Science terminal room. Just type: % lpr filename where filename is the file you want to print. Other options modify the lpr command, like the -P option, which prints to another printer besides Gute in the terminal room. Check the man pages by typing "man lpr" to see the other options (see section 1.4.1 for more information on man pages.) 1.3.2. Other File Commands Other useful things you can do with files is to copy, move, and remove them. The commands to do this are cp, mv, and rm respectively. Note that since the name of a file also shows the file's location, the mv command is also used to rename a file. 1.3.3. File Security What about security? If you keep private letters on the system, how safe are they? Well, it is quite easy for people to look through your files if you let them, but if you want you can put up the "keep out" sign. You can set various permissions or modes on files. Every file has permissions. Permissions just tell the system who can do what with a file. To see the permissions set on your files, use the ls command with the -l option. The -l option, which stands for "long" format, tells you permissions information plus a few other items. For example: % ls -l total 1 -rw------- 1 juser students 415 Mar 06 04:21 copy_of_newfile Notice the first set of characters, the bar of hyphens with letters. That bar tells you what permissions your file has. The first hyphen tells you the type of the file. Plain files are denoted by - and directories are shown by d. The next nine permission characters are split into three groups of three. The first group sets permissions for the "user" (that's the file owner -- you), the next three refer to the "group" (e.g., students or faculty) and the last three refer to "others" (everyone else). Each sub-group of three contains spaces for the letters rwx. The r tells you that you can read from the file, the w tells you that you can write to it, and the x tells you that you can execute or run it. For the above file, you can read or write to it but "students" and everybody else cannot read, write, or execute the file. To change permissions on a file you use the chmod command, which is short for "change mode." The chmod command has the format: % chmod mode filename where mode can be of the form who operation permission who is one of the letters: u for user (you), g for your group, o for others, and a for all users (user, group, and others). The operation is either a + or a - symbol, which stands for "give" or "take away" the following permission. And the permission is a combination of the letters: rwx. For example: % chmod u-w copy_of_newfile would prevent you (the user) from being able to write (modify or overwrite) to the file. It would also prevent you from deleting the file without first being asked to confirm such a request. 1.3.4. Directories In addition to files, directories can hold other directories, known as subdirectories. Look at the results of pwd (Print Working Directory), a command that shows in which directory you are currently located. % pwd /home/juser Your home directory juser is a subdirectory of the directory home which is a subdirectory under the directory / (slash), which is called root. root is the main directory in a UNIX system. Under root are all the other directories and subdirectories on the system. (Picture the file system as an upside-down tree with a single root and many branches.) The path includes all directories you have to go through, starting from root (/), to get to a particular directory. The names of all the directories along the path are given in order (starting from root) and are separated by slashes (/). You can partition your directory into as many subdirectories as you want using the command called mkdir, which is short for "make directory." To use the command you just type mkdir newdir, where newdir is the name of the directory you want to make. Subdirectories are nice because you can have one for each major category of work you do on the computer, like reports, CS homework, letters, and so forth. This keeps the clutter out of your home directory. It is suggested that you use subdirectories. To get into a subdirectory use the cd command, which is short for "change directory." The format is % cd directory where directory is the name of the directory you want to move to. In UNIX, files lie along what is called a path. The path is formed by the names of subdirectories. Every directory has the hidden directory "..". This hidden directory points back up to the directory that holds the subdirectory, called the "parent". For example, when you're in your home directory juser and you type % cd ..(that is two dots) UNIX brings you back up one directory along the path to /home. Before you go frolicking up and down the path of directories you must know a few things. First, if you ever want to get back to your home directory, just give the command (cd) without a directory name. It's like saying "There's no place like home" and clicking your heels together three times. Second, remember you can always find out where you are by using the pwd command. Also, remember that directories have permissions, just like any other files. Thus, other people can keep you out of their directories and you can keep other people out of your directories. If you have a question or problem there are several things you can do:
The Computer Science Staff would prefer that you don't opt for the first choice! Many users are afraid to ask how to do something. Don't be. UNIX is hard to learn at first, so don't give up or be frightened by some of its cryptic forms. 1.4.1. Online Help The second option is a good place to start. If you have a question about a particular command then try the man command, which is short for "manual." The man command is the usual way to get help on UNIX. All you have to do is tell the man command the name of the command you want, like so: % man command where command is the name of the command you want help on. However, if you don't know the name of the command you want help on, you can try using the -k (keyword) option. For example, if you wanted to know about the command for copying files, you might type: % man copy but this results in the message No manual entry for copy. This means that there is no command called copy, or the command has no manual page. The next thing you should try to find a command which copies files is: % man -k copy This will list every command with the word "copy" in its description. If you can't find something on the first try with the -k option, try using synonyms. Another form of online help is the Frequently Asked Questions and the Quick-Reference pages. These can be accessed by typing "faq" or "qref" from the command line. The Info pages are also very helpful for GNU applications like emacs and gcc. Simply type "info" at the command line to get to the info contents. 1.4.2. Consultants The third option is to ask someone. On weekdays and Sundays there is usually a consultant on duty in the Computer Science Terminal Room (Beckman 102, x73442) to help answer your questions. The consulting hours are posted here. So that the consultant can be found easily, the terminal closest to the door is reserved for the consultant. The consultant is paid to help you, so don't be afraid to ask a consultant for help. If a consultant is not on duty, then someone else in the terminal room can often help answer your questions. If the consultant is not on duty when he should be, feel free to call them and harass them. The Computer Science system staff may also be in the terminal room and may be willing to answer questions. However the staff members have classes too, and may not have time to answer your question. Consultants can also answer questions via email. Send mail to consult@cs.hmc.edu if you have questions and there isn't a consultant nearby. Often the consultant will respond very shortly thereafter. 1.5. Creating and Editing Files There are many different methods of creating and editing files in a UNIX environment. emacs is the primary editor on the Computer Science machines. See Chapter 3, "Editing with emacs," for more editing material. Alternative editors include vim and pico. To find out more about these editors, refer to the Editors FAQ or read the appropriate man pages. The mail utility is provided as a means of communication between users. Normally, mail is used when a user wants to leave a message for a particular user who is not currently logged in, or when a user wants to send mail to a user on a different computer system. For communication between currently logged in users, either write or talk can be used. The most commonly used mail program is pine. This chapter covers the very basics of email for users who have not yet been exposed to it. 1.6.1. Reading Your Mail Sometimes when you log in, the system will print out the message: You have new mail. At this, many people get all excited and scream "Wow, I got mail!" This message means that the system is holding some mail for you. To read your mail, just type: % pine from the command line. It will then display a menu at the top of the screen and a smaller menu at the bottom. Use the up and down arrows to move among the menu options and press Return to choose what you want to do in pine. You can also use the corresponding keys shown as shortcuts. Select "Folder Index" to read mail in your default mailbox and use the keys at the bottom of the page to move between menus and select different options. 1.6.2. Sending a Mail Message To send a mail message in pine, select "Compose Message" from the main menu. Then fill in the "To:" line with the address of the person you will mail the message to. The proper format for an address is username[@machine-name[.domain-name]] where username is the name of the account to which you are sending mail, machine-name is the name of the machine on which that account exists, and domain-name is the name of the network or organization to which that machine belongs. You need not specify the machine and domain names if you are sending mail to another account on the machine (e.g., knuth) where you are currently logged in. (The square brackets just indicate that part of the address is optional; do not actually type them.) The computers in the Claremont Colleges, like any educational institution, belong to the edu domain (case is irrelevant in domain names). Here are some sample addresses: To: jschmoe (jschmoe must be a user on the same machine you are on) To: jschmoe@knuth To: jschmoe@pomona.edu To: srm3735@tybalt.Caltech.edu After you fill in the To: address, you can then fill in the Subject: line, which will appear as a summary line to the recipient of your message. Next you will see a Cc: section, list here any people to whom you want "carbon copies" of your message sent. The attachment field allows you to tag other mail messages or files onto your message. Then begin editing and writing your message in the "Message Text" field. When you are finished, type "^T" to spell check you mail, and then type "^X" to send the message. You must confirm "yes" to send the message. Pine will then return you to the main menu to choose another option. 1.6.3. Getting mail to knuth from outside of Harvey Mudd When your friends at distant sites are trying send you mail the following is your electronic address: username@knuth.cs.hmc.edu They should also be able to reach you at: Firstname_Lastname@hmc.edu This address will send mail to your account on odin, which is the computer system run by Academic Computing, not by the Computer Science Department. This can be changed using a forwarding file. More information on mail and mail forwarding can be found on the mail FAQ page. 1.6.4. Automatic Email Forwarding Once you get a CS account, users can send email to you on knuth. If you like to centralize your email, you can tell knuth to forward all your incoming email to another machine. To forward your email to another machine: Create a file called .forward in your home directory (ie. ~/.forward). This file should contain the email address your mail is to be forwarded to. For example: If your .forward file contains user@odin.ac.hmc.edu, all of your knuth incoming email will be sent to user@odin.ac.hmc.edu. There are many languages available on Computer Science machines: C, C++/g++, Java, Prolog, REX, ISCAL, Python, awk, sed, PHP, SQL, SML, Expect, and perl are just some of them. Not all languages are available on all machines, so ask the system staff if you have trouble finding a particular language. See the quick reference sheet (included in the orientation packet) for an explanation of how to compile programs for your CS class. For information on using these languages, please read their respective manual or info pages. Chapter 2: The Z ShellThe Z shell, zsh, is the command interpreter which is usually used on the Computer Science machines to read commands from the user's keyboard and run the appropriate programs. The shell has features that provide convenient services to the user. The main benefits of the Z shell include filename abbreviation and grouping, input/output redirection, job control, history substitutions, personalizing the environment by defining aliases, and allowing command line editing. There are two reasons for filename substitution. First, this feature is useful when one wants to deal with a collection of files, such as deleting all files that end with .junk. Second, it can provide an abbreviation for a long filename. For example, if you wanted to delete all the files you own that end with .junk, you could type % rm *.junk The asterisk stands for any group of characters, including a null string. The pattern j*k may stand for junk, jk, jhellok, or any other combination of characters between j and k. Other special pattern matching characters are the question mark, which stands for any single character (but never a null string) and brackets, which match any one of the set of characters inside of the brackets. Within brackets one may also include a range of ASCII characters. So, % more chapter.[1-46-9] displays chapters one through nine excluding five. Often it is desirable to redirect input or output from its normal path. There are four primary redirection commands, <, >, >>, and | (called "pipe"). The < takes input from a file, > writes output to a file, >> appends output to a file, and | pipes output from one program to another. For example, the cat command, without parameters, is pretty boring; it simply takes input from the keyboard and outputs it to the terminal screen - not useful unless one wants to practice typing. However, using a single greater-than symbol, one can turn the cat command into a "create file" command. % cat > newfile I am typing information for storage in the file called newfile. ^D This example takes input from the keyboard and sends its output to a file called newfile. Input may be similarly redirected using a less-than symbol. Follow the command with a less-than symbol (<), followed by the name of the file to be used as standard input (instead of the keyboard) for the command. For example: % cat < newfile > copy_of_newfile This simple example copies newfile into copy_of_newfile by reading its input from newfile then redirecting its output to copy_of_newfile. Of course the cp command does it more easily, but you get an idea of what redirection can do. Finally, an example of the use of the pipe is: % ls -s | sort -nr 11 junk 3 old.stuff 1 cats 1 meow The ls -s command lists the filenames with their sizes in the first column. This output is sent as the input of sort, which sorts and outputs these records numerically (-n) and in reverse order (-r). Aliasing is simply a way of substituting one word for a list of words to save key strokes. For instance, if ll is aliased as ls -als, the command ll is first translated to ls -als and then the command is executed. One can set up this alias by typing % alias ll='ls -als' To remove this alias, type unalias ll. To see a list of all of your aliases, type alias. Aliases are usually done from the .zshrc file. This makes the aliases available automatically. You can create a file of aliases and use them by executing the source command. Suppose you edit your .zshrc to add some new aliases. To put these aliases into effect, execute the command % source .zshrc You can control jobs with a series of control character sequences. These sequences are listed with a short explanation. ^Z suspends the current process. ^C terminates the current process. ^D sends an "end-of-file" signal to the current process. (From a login shell, it logs you out of the system.) When a command is typed, the program is run; when it completes, the prompt returns ready for the next command. What happens is that the Z shell creates a subprocess to execute the command and then waits for that subprocess to complete. If you end the command line with an ampersand (&) the Z shell will start the subprocess without waiting for completion, thus freeing up your terminal. This is called running a job "in the background." While jobs are running in the background, you can work on other things. The Z shell will notify you when your background jobs are finished. For example: % gcc homework.c & [1] 2314 % and when the job was done you would get the message [1] Done gcc homework.c The "1" in the brackets indicates that this background job may be referenced with %1. If, while the job is running, you decide to terminate the job, you may type kill %1. You may also kill a process by first finding out its PID number using the ps -U username command, and then using kill PID number to terminate that process. Often you may enter a command and later decide you want to do something else in the shell while the current command is running. This can be accomplished by typing ^Z while the job is running. This stops the job and gives the user a prompt. The stopped job may be continued in the background (the shell lets you continue entering commands while the job is running in the background) with bg, in the foreground with fg, or killed with the aforementioned kill command. To see a list of all your existing jobs, just use the command jobs. If you try to log out with stopped jobs, the system will respond with: There are stopped jobs. Remember, these jobs should be either killed or completed prior to logging out. If you plan to leave any large jobs running in the background, ask a consultant about proper etiquette or see the FAQ, policy in the section on long jobs. The Z shell provides capabilities to facilitate programming in the shell, such as control flow commands and variables. Shell commands can be put into a shell script and executed. A shell script is a file which contains a collection of shell commands to be executed together. These commands are executed just as though the user were typing the commands from the keyboard. In this way one may write programs using the Z shell commands. There are many books in the labs about shell programming that are helpful for beginning shell programmers. 2.5.1. The .zshrc Script The script that customizes your zsh operations is called .zshrc. The Z shell looks at this file, and executes the commands in the file, every time you log in and use the Z shell. The commands in the .zshrc file reconfigure the Z shell to your own liking. The .zshrc file, together with the .login file allow you to personalize your working environment. You can use a text editor (such as emacs) to modify your .zshrc file. The Z shell allows previously entered commands to be recalled, edited if need be, and re-executed. This feature of the Z shell is commonly referred to as history substitution, and should be enabled by default. If you need to enable this feature, the shell variable HISTSIZE must be set. This can be accomplished by entering HISTSIZE=20 either in the Z shell or in a .zshrc file. In the example above, setting the HISTSIZE variable to 20 will cause the shell to remember up to the last 20 commands entered at the current shell level. Setting history can cause only subsequent commands to be remembered; the history feature will not work retroactively. A list of commands remembered by the history mechanism can be obtained by simply typing history while in the Z shell. Now consider the following example of such a list: % history
47 11:44 ls /hmc1/hmc_2000/hmudd/cs164
48 11:54 ls /usr/games
49 11:57 cat file1 file2 file3
50 11:57 cat file4 file5 file6
51 11:58 cat krank1 krank2 krank3 krank4 krank5
A history substitution may occur anywhere in the input stream of a command. The simplest form of a substitution consists of an exclamation mark and the number of the desired event or an exclamation point and the first letter of the command you want to execute. For instance, if we wished to re-execute command 48, we could type one of the following % !48 to execute command 48 % !-4 to execute the fourth previous command % !ls to execute the most recent command beginning with the letters "ls" The last command says to execute the most recent command that starts with the letters "ls". All these history commands are equivalent to ls /usr/games (using the example above). Finally, within the zsh shell, the up and down arrow keys can be used to scroll through the commands in the history file. 2.7. Sources of Additional Information You can use man zsh and man zshall to learn more about the Z shell and zsh.Chapter 3 Editing with emacsemacs is the most commonly used editor in the HMC UNIX environment. . To use emacs to edit a file, simply type % emacs filename Before using emacs, you need a .emacs file in your home directory. If there isn't one, or if it has been messed up beyond all recognition, you can copy the default file from /usr/local/skel/generic/.emacs. The rest of these instructions will assume that you are using the keymapping provided by this file. This file gives you some key definitions, including arrow keys and terminal-emulation workarounds. There are two ways of entering commands into emacs. The most commonly used commands are bound to keyboard sequences using the Esc or Ctrl key. For example, ^V (typed by holding control and pressing V) moves forward one page and Esc-v (typed by pressing and releasing escape, and then pressing V) moves back one page. emacs has several ways of designating combinations of keys. The combination of holding Control and typing "v" can be written Ctrl-v, ^V, or C-v, and the combination of typing the Meta key (either pressing and releasing Escape or holding the Alt key) can be written M-x, Esc-x, or Alt-x. The second method of command entry is called the command line. Typing M-x will cause a M-x prompt to appear at the bottom of the screen. You then type in a command and emacs will execute it. The commands here include all of the commands bound to keys as well as many others. For example, with the default set up M-x scroll-up is the same function as ^V but M-x apropos can only be invoked at the command line. emacs can be customized. If you don't like the command that is attached to a key you can "bind" a different command. You can have emacs expand abbreviations automatically. Also there are many features you can turn on and off. Customizing is best done with your .emacs file (emacs run command file). Put any changes you make after the lines that are already in there, or alter the defaults as suggested by the comments. emacs by default does an auto-save every so often. The amount of time is user-configurable. The auto-save filename will be the filename sandwiched between two # symbols. If the system crashes or you accidently exit without saving your changes, you can get some of them back by using the recover-file command. Edit the file again, and type M-x recover-file. If you wish more information about how to use emacs try typing M-x and then as much of a command as you want followed by a ? and emacs will list all the commands that start that way. You can even simply type M-x ? to get a list of all commands. emacs has command completion so that at any time you may type a space to have emacs try to determine the rest of the command. It will type as much as it can and if the command is not yet complete continue the input process for the remainder. You can also find out what command any keystroke or sequence of keystrokes will execute by using M-x describe-key and then hitting the key or key sequence you are curious about. The command M-x apropos will list all the commands in which the word or character string "keyword" appears. You can then use M-x describe-command to get a brief description of what the commands do.
Chapter 4: Using the MacsThere are 24 Mac Minis available for student use in the terminal room (Beckman 102). There are also more mac minis, graphics workstations, 2 Solaris Workstations, and 2 PowerMac G5 in the graphics lab (Beckman 100) which are available for general use. To log on to a Mac, first find a machine that is not in use. You should see a window with text fields labeled "Name:" and "Password:". If instead you see a window with a list of logged-in users, click on "Other" to get to the username and password window. Type your CS account username and password and click "Log In". The window will disappear and you will be presented with the OS X desktop.After logging on as described in section 4.2, you will notice several prominent features of the OS X desktop environment. Learning how to use these features will make your time in the terminal room much more productive and efficient.
4.3.1. The Menu Bar The menu bar spans the top of the screen. This bar contains different commands that you can issue to the program that is currently active. When you log in, the active program will be Finder, which you can use to locate and organize files. The right side of the menu bar contains useful utilities such as a volume control, a clock, and Apple's Spotlight utility, which is used for quickly finding files on the computer. The contents of the menu bar will change, depending on which window has the focus (see section 4.3.4 for information on the focus). 4.3.2 The Dock The Dock is located at the bottom of the screen. It contains shortcuts to a number of commonly-used application, such as Finder, Terminal Window, Safari (a web browser), an address book, a calendar, and others. To launch one of these applications, left-click its icon. Additionally, when you minimize windows (see section 4.4.2), they will appear in the right side of the Dock. Simply left-click them to restore them. You are free to move the dock and customize it to your liking. 4.3.3 The Desktop The desktop lies between the menu bar and the Dock. This is where your program windows will be placed. Also, you can drag and drop files from the Finder program onto the desktop for easy access. In the upper-right corner you will see an icon that looks like a hard drive, labeled with the name of the computer that you are using. Double-clicking this icon will bring up a Finder window showing the contents of the computer. 4.3.4. The Mouse The Macs all use mice with two buttons and a scroll wheel. The left button is usually used to interact with objects you see on the screen (e.g. clicking buttons, dragging icons), while the right button usually brings up a list of extended commands that vary depending on what you clicked on. The scroll wheel is used for navigating in programs that have more content than can be shown in the window. By default, OS X uses a "click to focus" policy, meaning that in order for a window to have the focus (so you can interact with it), you must click on it when the left mouse button. If it seems like your keystrokes are being ignored, make sure that the appropriate window has the focus. 4.3.5. Logging Out To log out, simply click on the Apple logo on the leftmost part of the menu bar, and click on "Log Out < your name >". You will be asked to confirm that you want to log out. If you do not respond for two minutes, you will be logged out automatically. 4.3.6. Locking a Mac If you need to leave your terminal you can lock your screen so that no one else can use it. All of your processes will still be running but it will prevent others from using the terminal. Just type your password to get back to your working screen. Please be considerate when using this function, though, especially when you will be gone for long periods of time or when there are many people trying to use the terminals in the terminal room. If your locked screen becomes a problem, a CS staff person can break the lock on your screen and log you out. You are not able to lock a mac by default, this has to be enabled. To enable locking First open up the Finder. On the left bar of the finder click on Applications and then click on the utilities folder that appears in the main screen of the finder. Find the program Keychain Access.app and double-click it, Keychain Access should open up. Now that it is open you will see the words "Keychain Access" on the top left of the menu bar next to the blue apple logo (make sure Keychain Access is your focus, click on the window to make it your focus) and click on it to make a drop down window appear. Now a window will appear with the options "About Keychain Access", "Preferences", "Window Settings", etc. Click on Preferences to make the preferences window appear. Make sure you are in the "General" tab and check off "Show Status in Menu Bar". This should create a shaded in lock icon to appear in the top right of your menu bar. This will enable this icon to appear by default at login, making it easier to lock your screen next time. Click on the lock icon to make another drop down window appear with the options "Lock Screen", "Lock Keychain Access", etc. Click on "Lock Screen" and you are done!!! To unlock your computer simply enter your password at the prompt screen. 4.3.7. World Wide Web (WWW) on the Macs There are many ways to get on the WWW on the macs. By default an application called Safari should be available on your dock. Safari's icon looks like a blue compass. Left-click Safari to start it and get access to the WWW. If Safari is not enabled in your dock you can enable it by first opening up your finder and clicking on "applications" on the side bar. In this window you should find the Safari application, double-click it to open it and get access to the WWW. Once you have opened it, the Safari icon should appear in your dock. If you want the icon to appear on the Dock at start up for easier access, drag the application onto the dock. If you want the application to open when you login, right-click the Safari icon in the dock and chose the "Open at Login" option. 4.3.8. Opening a Terminal Window on the Macs You will be doing most of your CS work in a Terminal Window. To open a Terminal Window in the macs look on your dock, by default there should be a Terminal icon (this looks like a black monitor screen with the command line ">_" on it). Double-click this icon to open a terminal. If you do not see a terminal window icon and you want to enable it, open up your finder and click on "applications" on the side bar. Next look for a folder called "Utilities" and double-click it to open it. In this window you should find the terminal application, double-click it to open a terminal window. If you want it to appear on the Dock at start up for easier access, drag the application onto the dock. If you want the application to open when you login, right-click the Terminal icon in the dock and chose the "Open at Login" option. One important feature of windows is that they are flexible. You can move your windows around the screen; you can make them bigger or smaller; you can put other windows in front of them, or you can turn them into icons until you want them back. Also, you can change the look of your windows by adding color or a background design on your desktop. The best way to learn about the visual changes you can make to your windows is to look at other people's windows in the terminal room and ask them how they created their effect. While many people are usually working in the terminal room, most people will be happy to answer your questions and help you. Also, the consultant is a good person to ask about changing your desktop. This section explains how to manipulate your windows. 4.4.1. Resizing Windows To resize a window, move the cursor to the bottom-right corner of the window. There should be some lines arranged in a triangular pattern. Click and hold the left mouse button and drag the window to resize it. 4.4.2 Closing Windows If you have finished working in a window and would like to close it, left-click on the red button in the upper-left corner of the window. The window may close immediately, or OS X may give you a chance to change your mind, or prompt you to save any unsaved changes in the window. Note that, unlike on the Windows platform, closing a window does not close the application entirely. One way to close an application is to right-click the application's icon on the dock and chose the option "quit". 4.4.3. Minimizing Windows What if you want to get a window out of your way, but don't want to eliminate it completely? Simply click on the yellow button (the one marked with a "-" symbol) in the upper-left corner of the window. It will become minimized -- it now appears as a tiny window in the right side of the dock. If you want to bring it back up again, simply click on it in the dock, and it will reappear. 4.4.4. Moving Windows Suppose you don't like the position of a window. To move a Window, move the cursor to the bar on top of the window. If you click and hold the left mouse button click the left mouse you can move the window by moving the mouse. When the window is in the right place, release the mouse button. 4.4.5. Cut and Paste OS X allows you to copy and paste text between windows. To do so, place the cursor at the beginning of the text you wish to copy. Click and hold the left button, move the cursor to the end of the text you want to copy, and release the button. Click on "Edit" in the menu bar, and then click on "Copy". To paste the text, make sure the cursor is at the place that you want to paste the text, click "Edit" again, and then click "Paste". There are shortcuts to cutting and pasting. Usually the macs let you copy and paste with the menu that appears when you right click on highlited text. Like on Windows, there are also keyboard shortcuts. Use the commands Command-C to copy and Command-V to paste, where Command is the Windows key if you are using a Windows based keyboard (like a DELL keyboard) or the Apple key if you are using a Mac keyboard. 4.4.5. Hidden Windows If you want to "hide" a window from view but woul still like to open it later you can press Command-H, where Command is the Windows key if you are using a Windows based keyboard (like a DELL keyboard) or the Apple key if you are using a Mac keyboard. Hidden Windows do not appear on the screen or on the dock. They are completely hidden from view. To "unhide" a hidden window you can press and hold Command-Tab and then pick the window you have hidden from the list of active Windows that appear.This chapter is merely a first introduction to OS X. For more information, you can access "Mac Help" in the Help menu of the Finder program. You can also ask someone!
Appendix A: Useful Things To Know
Reference Materials There are several reference sources available for learning more about the UNIX operating system and related subjects. First there are the actual Solaris reference manuals kept on metal bookshelves which can be found scattered about the CS Terminal Room. These contain a hard copy version of the man pages as well as several supplementary documents. Also in the terminal room are several manuals describing the use of various programs. In addition there is a very small library of computer science books available in Beckman 105. These books cover topics from UNIX to C to networks and are available for check out by request (talk to a CS consultant). Note that there is only a single copy of most of these books, so please plan on returning these quickly so that others may use them. Finally, possibly the finest introductory document ever written for UNIX and knuth is Unix: The Basics produced by the collective wisdom of the Computer Science Department student staff.
This document has been previously published by the Harvey Mudd College Computer Science Department in both hard copy and electronic form. Previous editions published 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1995, 1997.
UNIX is a registered trademark. X Window System is a trademark of the Massachusetts Institute of Technology. PostScript is a trademark of Adobe Systems, Incorporated. Macintosh is a trademark of Apple Computers, Inc. SunOS, SPARC, and Solaris are trademarks of Sun Microsystems, Inc. Symmetry and DYNIX are trademarks of Sequent Computer Systems, Inc. Copyright (c) HMC Computer Science Department.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
or any later version published by the Free Software Foundation;
with the no Invariant Sections, with no
Front-Cover Texts, and with no Back-Cover Texts.
A copy of the license is included in the section entitled ``GNU Free Documentation License.''
HMC Computer Science Department Contact Information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||