Before you can start using UNIX, your system administrator has to set up a UNIX account for you. Think of this account as your office - it's your place in the UNIX environment. Other users may also be at work on the same system. At many sites, there will be a whole network of UNIX computers. So in addition to knowing your account name, you may also need to know the hostname (name) of the computer that has your account.
Each user communicates with the computer from a terminal or a window. To get into the UNIX environment, you first connect to the UNIX computer. (You may have a terminal that's already connected to the computer.) Next, you start a session by logging in to your UNIX account. Logging in does two things: it identifies which user is in a session, and it tells the computer that you're ready to start working. When you've finished working, you log out - and, if necessary, disconnect from the UNIX computer.
you can probably skip ahead to the section "Logging In" later in this chapter. Otherwise, browse through the next few sections and find the one that applies to you. (We can't cover every user's situation exactly. If none of these suggestions helps you enough, ask another UNIX user or your system administrator.)
If you're using a personal computer to connect to the UNIX system, you'll probably need to start a terminal emulation program. Some common programs are procomm , qmodem , kermit , minicom , and telnet . (There are lots of others.)
If you start the program and get a UNIX "login:" prompt, you're ready to log in. But if your screen stays blank or you get another message that you don't understand, check with another user or your system administrator for help.
Your office may have a data switch, a port contender, or another system that allows you to select which computer you will connect to. Like a telephone switchboard, this connects your terminal to one of a number of computers. Enter your computer's hostname or code number at the prompt - or choose from the menu of hosts.
The process of making yourself known to the UNIX computer system and getting to your UNIX account is called logging in . Before you can start work, you must connect your terminal or window to the UNIX computer (see the previous sections). Then log in to UNIX and identify yourself. To log in, enter your username (usually your name or initials) and a private password. The password does not appear on the screen as you enter it.
When you log in successfully, you will get some system messages and finally the UNIX shell prompt (where you can enter UNIX commands). A successful login to the system named nutshell would look something like this:
O'Reilly & Associates, Inc. nutshell.oreilly.com: Solaris UNIX version 2.5 login:
In this example, the system messages include a "fortune" and the date. Although this example doesn't show it, you may be asked for your terminal type , accounting or chargeback information, and so on. The last line to appear is the UNIX shell prompt. When you reach this point, you're logged in to your account and can start using UNIX commands.
Instead of a shell prompt, you may get a menu of choices ("email," "news," and so on). If one of the choices is something like "shell prompt" or "command prompt," select it. Then you'll be able to follow the descriptions and examples in this book.
The messages that appear when you log in differ from system to system
and day to day.
The shell prompt also differs.
The examples in this book use the percentage sign as a prompt (
Let's summarize logging in, step by step:
The system verifies your account name and password, and, if they're correct, logs you in to your account.
The computer you log in to may not be the computer you need to use. For instance, you might have a workstation on your desk but need to do some work on the main computer in another building. Or you might be a professor doing research with a computer at another university.
Your UNIX system can probably connect to another computer to let you work as if you were sitting at the other computer. To do this, you first log in to your local computer. Then you start a program on your local computer that connects to the remote computer. Some typical programs are telnet and rlogin (for connecting over a computer network) as well as cu and tip (for connecting through telephone lines using a modem). You use the remote system until you're done; when you log off the remote computer, the remote-login program quits, and then returns you to your local computer.
The syntax for most remote-login programs is:
For example, if Dr. Nelson wanted to connect to the remote computer named biolab.medu.edu , she'd log in to her local computer (named fuzzy ) first. Next, she'd use the telnet program to reach the remote computer. Her session might look something like this:
Her accounts have shell prompts that include the hostname. This reminds her when she's logged in remotely. If you use more than one system but don't have the hostname in your prompt, references in Appendix A, Reading List ( UNIX Power Tools , for example), will show you how to add it.
Once you've logged in, you're working with a program called a shell . The shell interprets the commands you enter, runs the program you've asked for, and generally coordinates what happens between you and the UNIX operating system. Common shells include Bourne ( sh ), Korn ( ksh ), and C ( csh ) shells, as well as bash and tcsh .
For a beginner, the differences between most shells are slight. If you plan to do a lot of work with UNIX, though, ask your system administrator which shell your account uses; you should learn more about your shell and its set of special commands.
Shell prompts usually contain
Entering a command line at the shell prompt tells the computer what to do. Each command line includes the name of a UNIX program. When you press [RETURN] , the shell interprets your command line and executes the program.
The first word that you type at a shell prompt is always a UNIX command (program name). Like most things in UNIX, command names are case-sensitive; if the command name is lowercase (and most are), you must type it in lowercase. Some simple command lines have just one word: the command name.
As you type a command line, the system simply collects your input from the keyboard. Pressing the [RETURN] key tells the shell that you have finished entering text and that it can start executing the command.
The who command can also tell you who is logged in at the terminal you're using. The command line is who am i . This command line consists of the command ( who ) and arguments ( am i ). (The section "Syntax of UNIX Command Lines," later in this chapter, explains arguments.)
The response shown in this example says that:
Not all versions of who am i give the same information.
Don't be too concerned about getting error messages. Sometimes you'll get an error even if it appears that you typed the command correctly. This can be caused by typing control characters that are invisible on the screen. Once the prompt returns, reenter your command.
Most modern shells let you recall previous commands and edit command lines. If you'll be doing a lot of work at the shell prompt, it's worth learning these handy techniques. They take more time to learn than we can spend here, though. Ask other users for help or read a reference book for your shell (see Appendix A ). We'll concentrate on simple methods that work with all shells.
is called a
To type a control character (for example,
hold down the
key while pressing the letter "h".
(This is like the way you make an uppercase letter:
key while pressing a letter key.) In the text, we will write control
but in the examples, we will use the standard notation:
The key labeled [DEL] may be used as the interrupt character instead of the erase character. (It's labeled [DELETE] or [RUBOUT] on some terminals.) This key is used to interrupt or cancel a command, and can be used in many (but not all) cases when you want to quit what you're doing. Another character often programmed to do the same thing is [CTRL-C] .
Some other common control characters are:
Find the erase and interrupt characters for your account and write them down:
In Chapter 3 , we'll tell you how to change these characters if you like.
To end a UNIX session, you must log out. You should not end a session by just turning off your terminal! To log out, enter the command exit . (In many cases, the command logout will also work.) Depending on your shell, you may also be able to log out by typing [CTRL-D] .
What happens next depends on the place from which you've logged in:
After you've logged out, you can turn off your terminal or leave it on for the next user.