Selecting a Shell to Use

The login shell is the command interpreter that runs when you log in. The Solaris 9 operating environment offers three commonly used shells:

  • The Bourne shell (/sbin/sh) This is the default shell. It is a command interpreter that executes commands read from a terminal or a file.

  • The C shell (/bin/csh) This is a command interpreter with a C-like syntax. The C shell provides a number of convenient features for interactive use that are not available with the Bourne shell, including filename completion, command aliasing, and history substitution.

  • The Korn shell (/bin/ksh) This is a command interpreter that executes commands read from a terminal or a file.

When writing scripts, you can use any of these three shells. The basic features of each shell are described in Table 3.1.

Table 3.1. Basic Features of the Bourne, C, and Korn Shells
Feature Bourne C Korn
Syntax compatible with sh Yes No Yes
Job control Yes Yes Yes
History list No Yes Yes
Command-line editing No Yes Yes
Aliases No Yes Yes
Single-character abbreviation for login directory No Yes Yes
Protect files from overwriting No Yes Yes (noclobber)
Ignore Ctrl+d (ignoreeof) No Yes Yes
Enhanced cd No Yes Yes
Initialization file separate No Yes Yes
From profile   
Logout file No Yes No

In addition to the commonly used shells described, Solaris 9 also provides six additional shells:

  • The J shell (/sbin/jsh) This provides all of the functionality of the Bourne shell but enables job control. When the J shell is invoked, job control is enabled in addition to all of the other Bourne shell functionality.

  • The restricted version of the Bourne shell This limited version of the Bourne shell (sh) is used to restrict logins and user environments for those users who need to be more controlled than those of the standard shell.

  • The restricted Korn shell A restricted version of the Korn shell is used to set up login names and execution environments whose capabilities need to be more controlled than those of the standard shell.

  • The T shell (/usr/bin/tcsh) This is an enhanced, but compatible, version of the C shell with filename completion and command-line editing. Type man tcsh to see a complete online listing of the enhancements.

  • The GNU Bourne-Again shell (/usr/bin/bash) Bash incorporates useful features from the Korn and C shells.

  • The Z shell (/usr/bin/zsh) This command interpreter (shell) is usable as an interactive login shell and as a shell script command processor.

  • The Secure shell (/usr/bin/ssh) This is used for logging in to remote systems and executing commands on that remote system. It is intended to replace rlogin and rsh by providing a more secure network connection between the two systems. The Secure shell is described in Chapter 21, “The Solaris Network Environment.”

NOTE

In addition to the three standard shells, the Common Desktop Environment (CDE), described in Chapter 25, “Administration and Configuration of CDE,” provides the Desktop Korn shell ( dtksh). This shell gives Korn shell scripts a way to easily access most of the existing Xt and Motif functions used in the CDE graphical interface. To successfully use dtksh, you should have experience with Xlib, the Xt Intrinsics, the Motif widgets, and Korn shell programming. It also is helpful to know the C programming language.

In addition, Solaris 9 includes Perl, the practical extraction report language, for creating programs.


Selecting a particular shell to use is a personal preference. I find that most BSD UNIX users use the C shell because of its roots at Berkeley. Many of us old SunOS users still prefer to use the C shell because we’ve used it for so many years. On the other hand, I find that SystemV users prefer the Korn shell. These preferences stem from the early development days of UNIX. For system administration, the Bourne shell is best for writing scripts. It is the default shell in Solaris and is the only shell found on all UNIX systems. All scripts that come with Solaris (that is, those that run control scripts located in /etc/init.d) and most third-party software also is written in the Bourne shell. In addition, because the Bourne shell is located in /sbin, it’s the only shell available when /usr is not mounted (that is, in single-user mode). The Bourne shell was designed from the beginning for use as a programming language, which explains its breadth of programming features. An additional reason for using the Bourne shell is that its conditionals and controls are compatible with all other shells, including the dtksh shell used in the CDE environment. dtksh is discussed in Chapter 25.

The Korn shell is an excellent choice to use when you are in multiuser mode, but the Bourne shell should be the default shell selected for the root user. All of your regular user accounts would appreciate the functionality provided by the Korn shell; therefore, use the Korn shell as the default shell for everyone except root.

Although I’ll describe features of both the Bourne and Korn shell, I’m going to focus mainly on the Bourne shell because that is the default shell for the system administrator.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset