|Previous||Table of Contents||Next|
THE SOLARIS 2.X ENVIRONMENT PROVIDES THREE SHELLS FOR USE AS COMMAND interpreters the Bourne shell (the default), the C shell, and the Korn shell. One shell is defined as the default shell for each user, but users can start a new shell from any command line. This chapter describes elements that are common to all three shells and then provides a section for each shell that describes some of the prevalent shell features.
Table 8-1 lists the basic shell features and shows which shells provide each feature.
|Ignore CTRL-D (ignoreeof)||No||Yes||Yes|
|Initialization file separate from .profile||No||Yes||Yes|
|Protect files from overwriting (noclobber)||No||Yes||Yes|
|Syntax compatible with Bourne shell||Yes||No||Yes|
The following sections describe commands that can be used with any shell.
The user's login shell is set in the last field of the user's entry in the Passwd database or /etc/passwd file. Use Solstice AdminSuite's User Manager to edit the Passwd database. Use Admintool: Users to edit the local /etc/passwd file. To run Admintool on a local system, you must be a member of the sysadmin group (GID 14):
If you want to use another shell without modifying the Passwd database, you can change shells at a command line prompt by simply typing the name of the shell you want to use.
To change to the C shell, type csh and press Return. The default C shell prompt is the system name followed by a percent sign (%):
$ csh oak%
To change to the Korn shell, type ksh and press Return. The default Korn shell prompt is a dollar sign ($):
oak% ksh $
To change to the Bourne shell, type sh and press Return. The Bourne shell prompt also is a dollar sign ($):
$ sh $
If you start a new shell from the command line, you can quit it and return to the old shell. To quit from a shell, type exit and press Return. If you have started (layered) another shell, you are returned to the original shell prompt:
$ exit oak%
You can clear the contents of a shell window and redisplay the prompt to the top of the window. To clear the contents of a shell window, type clear and press Return:
oak% which openwin no openwin in . /home/ignatz /usr/deskset/bin /usr/bin /home/ignatz/bin /bin /home/bin /etc /usr/etc /usr/ucb oak% clear
The window is cleared and the prompt is redisplayed at the top.
The default shell for the Solaris 2.x environment is the Bourne shell, developed by Steve Bourne when he was at AT&T Bell Laboratories. The Bourne shell is a small shell for general-purpose use. It also provides a full-scale programming language that is used to develop shell scripts to capture frequently performed commands and procedures. Describing how to write shell scripts is beyond the scope of this book.
The Bourne shell uses one initialization file, .profile, in the user's home directory to set the user's environment. When the user logs in or starts a Bourne shell from the command line, the .profile file is read. Use this file to set the user's path and any environment variables.
The syntax for defining an environment variable is the same for both the Bourne and Korn shells; type VARIABLE=value;export VARIABLE and press Return.
$ PS1=oak$;export PS1 $
The C shell, written by Bill Joy when he was at UC-Berkeley, is popular with many users of Berkeley UNIX. The C shell is completely different from the Bourne and Korn shells and has its own syntax. The most important advantages of the C shell are command history, command editing, and aliases. Command history stores a record of the most recent commands that you have used. You can display these commands and reuse them as originally issued. You can also change a command by editing it. Aliases let you type short names for frequently used commands. You can also combine sequences of frequently used commands and provide an alias for the sequence.
The C shell uses two initialization files in the user's home directory to set the user's environment: .login and .cshrc (C shell run control).
When the user logs in, the .login file is read, and then the .cshrc file. When you start the C shell from a command line, only the .cshrc file is read. Because the .login file is not always read, you should set environment variables and the user's path in the .cshrc file.
To define an environment variable for the C shell, type setenv VARIABLE value and press Return:
oak% setenv DISPLAY rogue:Ø oak%
|Previous||Table of Contents||Next|