In brief, you cannot interact with the core functionality of Linux—called its kernel—without a shell. As I mentioned earlier in this chapter, a shell is to the Linux kernel as Command.com is to DOS—except that with Linux, you have the choice of more than one shell.
A Linux shell is a program that provides a command-line interface between a user and the kernel. The kernel contains all the routines needed for input and output, file management, and other core functionality. A shell enables the user to access these routines from the command-line prompt that it provides.
In addition, a shell includes a language used for programming, which—in the context of shells—is called shell scripting. (For more information on shell scripting, see Chapter 12.)
Generally, shells are used in three ways:
Interactively, when the user types commands
For customizing a Linux session
For shell programming (for more information on shell programming, see Chapter 12)
To determine what shell you areusing:
5. | At a command prompt, type echo $SHELL
|
6. | Press Enter. Most likely, the response /bin/bash will come back, which means that you are using the bash shell, Linux's default. |
Tip
The content of the SHELL environment variable is the path and name of the shell. If you strip the path away, you will get the name of the shell. In the example above, if you strip away the path, /bin/, you get the name of the shell, bash.
Tip
You can also find out what shell you or anybody is using with the finger command. For example, finger hdavis displays my shell, plus a good bit of other information, including hdavis's home directory and when hdavis last logged on.
Tip
Remember that, unlike with DOS, commands and file names in any Linux shell are case sensitive.
To find out what shells are available:
1. | At a command prompt, type cat /etc/shells
|
2. |
Table 10.1 lists the more commonly used shells that are available in Red Hat Linux 6.
I suppose that even turtles and tortoises would like to change their shells from time to time! You can easily change shells.
To use a temporary shell:
Tip
Think of the temporary shell as a shell within a shell, or a subshell.
Common Shells | ||
---|---|---|
Program Name | Shell | Comments |
/bin/sh | Bourne Shell | This is the granddaddy of Unix shells, but it lacks a great deal of functionality |
/bin/bash | Bourne | This is the default shell in Linux |
Again Shell | ||
/bin/csh | C Shell | The syntax and constructs of this shell resemble those of the C programming language |
/bin/tcsh | Enhanced C Shell | This is an enhanced version of the C shell |
/bin/ksh | Korn Shell | This is one of the most popular Unix shells, but it generally is not the default in Linux |
To return to the original shell:
To change the shell "permanently":
1. | At the command prompt, type chsh. |
2. | Enter your password when you are prompted. |
3. | At the new shell prompt, enter the path to the new shell you want to use: for example, /bin/tcsh. |
4. | To activate the new shell, log off and then log on again. |
Alternatively, if you have root access, you can change each user's default shell by editing each user's entry in the /etc/passwd file. Information in /etc/asswd is contained in a line for each user.
To edit the /etc/passwd file:
1. | Log on as root. |
2. | Open the /etc/passwd file in a text editor (Figure 10.8). Figure 10.8. Administrators can change a user's shell by editing the /ect/passwdfiel
|
3. | The last entry on each user line is the user's shell. Edit the users as you want to reflect the new shell choices. |
4. | Save the file. The next time the user logs on, the new shell that you set will be activated. |