Now that you know how to log in to your system, here’s a quick look at the logout process and why it is important. You already know that your computer can have multiple people using it simultaneously, and that it can have files owned by many different people. The login process identifies you to the system and enables you to control the computer using your own username. How do you reverse this? That’s where the logout process fits. It closes any files that you might have open and shuts down any programs that you might have left running. If you remain logged in constantly, you might be exposing the system to security risks—not to mention that the processes you leave running might slow down the computer for other users. It’s always best to log out of your computer when you’re finished using it. UNIX users might encounter serious troubles when they don’t properly log out.
Logging out from a Text-based Session
If you are not running a graphical session (you don’t see any windows on your screen), the only command you need to use to log out is logout, surprisingly enough.
In order to log out from a command prompt, type:
>logout
The system immediately returns to the login prompt. That’s it. You’ve successfully logged out of the computer.
Tip:
Logout Alternative Some UNIX shells have the reputation of being picky. In certain cases, when you type logout the UNIX shell might reply with the message “Not login shell” and proceed to leave you logged in. Not to worry—even if a shell refuses to accept the logout command, you can still log out with the exit command. It works the same way as logout and will convince even picky versions of UNIX to allow you to sign off of the system.
Logging out from a KDE Session
If you logged in to the UNIX system through the KDE graphical interface, you can point and click your way out of the system. To log out:
You’re probably wondering what use UNIX is going to be to you if all you can do is log in and log out. Patience! UNIX can be a bit overwhelming if approached too quickly. The power of UNIX comes from its wealth of built-in utilities and the way that processes can be combined to perform tasks that might require customized programming on another operating system. For example, suppose you’re running a Web server on your UNIX computer and you want to count the number of accesses from a machine named kiwi. If you’re a programmer, it isn’t too difficult to write a program to do this—but with UNIX you don’t need to! Instead, you can just enter a command such as this:
>grep "kiwi" /var/log/httpd/access.log | wc -l
This example uses grep, a program that finds patterns, to find all the lines in the Web server log which contain kiwi; it then hands the results to wc, a program which counts things. Obviously, you aren’t expected to know how to construct this command yet—but you will be capable of doing so by the end of the book.
When you are typing commands into UNIX, you are typing them into what is known as a shell. For all the old DOS users out there, a shell is sort of like a version of Command.Com—on steroids. If you remember the days of DOS, you probably also remember different DOS shells that added capabilities to your computer. UNIX has a wide variety of shells that you can use, each offering a different set of capabilities. In addition to giving the user a place to run commands, shells also provide a scripting language that is much like a DOS batch file, but far more capable. Programs written using a shell are called shell scripts.
Lots and Lots of Shells
Because there are numerous shells available for UNIX, most users try different shells until they find the one that they like best. You’ll probably never need to change your shell unless you plan on programming one. Lesson 15, “User Utilities,” discusses the techniques you can use to switch to a different shell. Here is a quick overview of just a few of the different shells that are available, and the benefits they offer:
There are far more shells available, but these four will probably make up the bulk of any that you encounter. Don’t worry if you sit down in front of a computer that is running a different shell. You can still operate the computer using the knowledge gained from this book. You might experience some differences in the scripting architecture, but you’re not going to be lost.