previous
section   next section   upper level

Section 12: Customizing the UNIX Shell

The UNIX shell is a actually a user program that the kernel runs for you when you log in. There is usually more than one shell available on most UNIX systems. The most common shells available on UNIX systems are the Bourne Shell (sh), the C Shell (csh) and the Korn shell (ksh). Here at BYU another commonly used shell is the TC Shell (tcsh) , which is an enhanced but completely compatible version of the C shell with additional modifications. Here is a summary of features available on the three main shells used here at BYU, adapted from the Hewlett Packard "Beginner's Guide to HPUX."

Feature Function sh csh tcsh
Job control Allows processes to be
run in the background
No Yes Yes
History substitution Allows previous commands to be
saved, edited, and reused
No Yes Yes
File name completion Allows automatic completion of
partially typed file name
No Yes Yes
Command line editing Allows the use of an editor to
modify the command line text
No No Yes
Command aliasing Allows the user to rename
commands
No Yes Yes

Choosing your shell

It is possible to invoke any available shell from within another shell. To start a new shell, you can simply type the name of the shell you want to run, tcsh, csh, or sh.

It is also possible to set the default startup shell for all your future sessions. The default shell for your account is stored in the system database /etc/passwd, along with the other information about your account. To change your default shell, use the chsh command The chsh command requires one argument, the name of the shell you want as your default. To change your default shell to the C shell, you could enter the command

chsh /usr/bin/csh

NOTE:The chsh command is currently not functioning properly.

Default file access permissions

Whenever you create a file or directory in a UNIX filesystem, the newly created file or directory is stamped with a default set of permissions. That default set of permissions is stored in a variable called the umask. You can change the value of umask to suit your preferences. To see the current value of the umask variable, enter the shell command:
umask

The umask is stored as an octal (base 8) number, that defines which permissions to deny. As you recall, three kinds of file permissions (read, write, and execute) are given for each of three classes of users (owner, group, and others). Each of the nine permissions is specified as a zero (allow access), or a one (deny access).

To set your umask to deny write permission to group and others, use the command

umask 022
To deny all access to group and others, use the command
umask 077

Customizing with user login scripts

Since tcsh is the most commonly used shell here in the Electrical and Computer Engineering department at BYU, the remainder of this section describes some ways you can initialize tcsh by presenting the default .cshrc script. Your .cshrc file is found in your home directory. Alterations made to it are reflected in each tcsh shell you introduce thereafter. As noted above, the following is the default .cshrc script used in our department:

#---------------------------------------------------------------------
#set path tells the shell where to look for programs/commands that are
#entered at the command line
#---------------------------------------------------------------------
set path = ( /usr/bin /usr/sbin /usr/bin/X11 /usr/local/bin /usr/local/games . )

#---------------------------------------------------------------------
#Set up the shell variables
#history buffer set at 100
#various aliases are instigated
#command line prompt configured to display host and current directory
#-------------------------------------------------------------------- 
if ($?prompt) then
	set autologout = 0
	set history = 100
	set old = $cwd
	set host = `hostname`
	set logname = $LOGNAME
	alias back 'set back = $old; set old = $cwd; cd $back; unset back'
	alias popd 'popd; sp'
	alias pushd 'pushd \!*; sp'
	alias sp 'set temp = `whoami`; set prompt = $host\:$temp\:\!\:$cwd\>\ '
	sp
	alias cd 'set old = $cwd; chdir \!*; sp'
	alias h history
	alias ll 'ls -alF'
	alias ls 'ls -F'
	alias mail 'mailx'
endif

#-------------------------------------------------------------------
#stty used to assign keypresses to command line operations
#-------------------------------------------------------------------
stty kill ^U intr ^C eof ^D susp ^Z dsusp ^F echoe erase ^H

#-------------------------------------------------------------------
# Set default permissions so that you can read and write all files, 
#and that others can't. Changing this can potentially mess up the 
#security of your account, so make sure you know what you're doing 
#before changing this.
#-------------------------------------------------------------------
umask 022
resize > /dev/null

###
### Local customizations go below this line
###

#-------------------------------------------------------------------
#environmental variables are set for editor, pager, and news server
#-------------------------------------------------------------------
setenv EMACS emacs
setenv PAGER less
setenv NNTPSERVER news.ee.byu.edu


previous
section   next section   upper level