Changing Your UNIX Login Shell
This document describes how to change your login shell on the faculty of Mathematical and Computing Sciences' Unix machines.
In essence, a Unix shell is a program that takes commands you type and executes them. When you telnet to a Unix box, once you've logged in it is your shell that is interpreting what you type and running commands for you. When you login to a graphical workstation (a Linux or Solaris workstation or an NCD X terminal) the shell is run inside an xterm or other terminal program.
Changing your Unix login shell
To change your Unix shell, you will need to be at a Unix shell prompt. You can get to the shell prompt either by telneting to charlie, sally or patty, or by logging in to one of the Sun machines on Level 4. (If you are in the Linux lab on level 16 you will have to telnet to charlie, sally or patty.) The shell prompt should look something like the following: bash$
At the Unix shell prompt, type the command passwd -r nis -e. You will see a prompt that says: Enter login(NIS) password:
Type your Unix password and press return. Your password will not be displayed on the screen. You will then see screen output similar to the following:
Old shell: /usr/local/bin/bash New shell:
Choose the shell you want to have as your new login shell. Brief descriptions of the available shells are given below.
At the New shell: prompt, enter the full name of your new shell. The full names of the available shells are:
/bin/sh /bin/csh /bin/ksh /usr/local/bin/tcsh /usr/local/bin/zsh /usr/local/bin/bash /usr/local/bin/rc
You should then see a message saying:
NIS passwd/attributes changed on lucy
Congratulations, you have now installed your new login shell! The shell you selected will be run automatically the next time you login.
Obtaining default shell configuration files
This section describes how to restore your shell configuration files to their defaults. If you are editing your shell configuration files and somehow manage to make a mess of them help is at hand...
At the Unix prompt type shell-reinit. This will copy the needed shell configuration files for you. (If they exist, your old configuration files will be saved with the .old suffix. shell-reinit will tell you what these files are.)
If you want, you can edit the files .profile and .cshrc in your home directory to customise your shell environment. The instructions for editing these files are contained in the files themselves.
Brief descriptions of the available shells
This section provides extremely superficial descriptions of the available shells. More information can be obtained by typing man shell-name at your shell prompt.
- sh was the first Unix shell and as such its features are quite basic. sh was written by Steve Bourne and hence is often known as the Bourne shell. sh is available on all Unix systems, and for compatibility reasons many shell scripts are written using it.You can customise sh's environment by editing the file .profile in your home directory. This file is only read at login.
- csh was written with the intent of having similar syntax to the C programming language. csh features job control, command aliasing, history substitution and filename/command completion.csh's environment can be customised by editing the files .cshrc and .login in your home directory. The .cshrc file is read every time the shell starts. At login, the .login file is read after reading the .cshrc file.
- The Korn shell, or ksh, is a superset of the Bourne shell, meaning all commands and scripts written for the Bourne shell will work under the Korn shell. ksh extends the Bourne shell by adding filename/command completion, command line editing and job control.ksh reads the file .profile in your home directory to configure its initial environment.
- tcsh is a superset of csh meaning that everything that works under csh will also work under tcsh. It adds many features to csh including spelling correction, programmable word completion and command line editing.tcsh's environment is determined by the files .tcshrc and .login in your home directory. .tcshrc is read every time the shell starts. .login is read only when the shell is a login shell.
- Of all the shells, zsh bears most resemblance to the Korn shell. zsh features command line editing, spelling correction, word completion and a history mechanism.zsh's environment is configured by the files .zshenv, .zprofile, .zshrc and .zlogin in your home directory. .zshenv is always read when the shell starts. .zprofile is also read if the shell is invoked as a login shell. If the shell is interactive (this will be the case unless you're writing a shell script) the file .zshrc is read. Finally, if the shell was invoked as a login shell the file .zlogin is read.
- bash ("Bourne Again SHell") is a superset of the Bourne shell and is the default shell for the Faculty's Unix machines. bash incorporates features from both ksh and csh.The most immediately useful of these features is word completion. If you unambiguously identify a file or command by typing the first few characters of its name, you can press the tab key to have the shell complete what you were typing. If you do not unambiguously identify a file, pressing tab again will show a list of the files/commands whose names start with the characters you typed.bash's interactive environment is determined by the files .bash_profile and .bashrc in your home directory. .bash_profile is read only on login. .bashrc is read only for non-login shells.
- rc is similar in features to sh - meaning it is quite basic. rc syntax is very reminiscent of the C programming language. In fact rc syntax contains more similarities to the C language than csh.If rc is invoked as a login shell it will read the file .rcrc in your home directory to determine its initial environment.