-->
Previous Table of Contents Next


PART IV
Working with Linux

18  Understanding Linux Shells
19  Managing Multiple Processes
20  Printing
21  Installing the X Windows System
22  Using X Windows

Chapter 18
Understanding Linux Shells

by Steve Burnett

In this chapter
Logging In
Understanding Shells
Understanding Shell Command Parsing
Doing Background Processing
Understanding Command Feedback
Editing and Aliasing Shell Commands
Working with Shell Scripts
Customizing Linux Shells

Although graphical interfaces have been added to the UNIX system in recent years, most of the utilities for using and administering Linux (and other UNIX-like systems) are run by typing commands. In Linux, the command-line interpreter is called the shell. This chapter describes how to use the features of the various shells to work with Linux utilities and file systems.

Logging In

As a new user and novice system administrator on your Linux system, you’ve chosen a login ID and password. Because Linux is a multiuser operating system, it must be able to distinguish between users and classes of users. Linux uses your login ID to establish a session in your name and determine the privileges you have. Linux uses your password to verify who you are.

Because any user can log in to any terminal in theory (there is an exception), the UNIX operating system begins by displaying a login prompt on every terminal. Because it’s unlikely you’ll have multiple terminals connected to your initial Linux system (although connecting multiple terminals is certainly possible), you’ll have the alternate, or virtual, terminals available to you.

To switch to the various virtual terminals, press the <Alt> key and any of the first six function keys to switch between the various virtual terminals. For example, to log in to virtual terminal one as root, press <Alt-F1>, which displays the following prompt:


Red Hat Linux release 5.1 (Manhattan)

Kernel 2.0.34 on an i686



login:


NOTE:  The prompt line in the code line declares this example session to be running under the 2.0.34 version of the Linux kernel. As newer kernels are released, this number is incremented, so you may see a different version on the accompanying CD-ROMs. The stable released kernels are given even numbers for the middle number and the odd numbers indicate the latest (and beta) releases.

Enter your user ID (root) and password.

When you log in to any terminal, you own the session on that terminal until you log out. When you log out, Linux displays the login prompt for the next user. Between logging in and logging out, Linux makes sure that all the programs you run and any files you might create are owned by you. Conversely, Linux doesn’t allow you to read or alter a file owned by another user unless that user or the system administrator has given you permission to do so. Your login ID and password allow Linux to maintain the security of your files and those of others.

As the system administrator for your Linux system, you assign every user a user ID, temporary password, group ID, home directory, and shell. This information is kept in a file named /etc/passwd, which is owned and controlled by the system administrator, also known as root or the superuser. After you successfully log in, you can change your password, which is then encrypted in a form that no one else can read. If you forget your password, you (the system administrator) have to log in as the root user to create a new password. You can change your own password with the passwd command (although you have to type in the old password).


NOTE:  For more information on basic system administration duties, such as adding users and fixing forgotten passwords, see the chapters in Part II, “System Administration,” particularly Chapter 10, “Managing User Accounts.”

Understanding Shells

After you log in, Linux places you in your home directory and runs a program called a shell. A shell is really nothing more than a program designed to accept commands from you and execute them. Many kinds of programs can be used as shells, but several standard shells are available with almost all versions of Linux.


NOTE:  Linux shells are equivalent to COMMAND.COM used by MS-DOS. Both accept and execute commands, run batch files, and execute programs.


Previous Table of Contents Next