What is a shell?

A shell is a program that provides the traditional, text-only user interface for Unix-like operating systems. Its primary function is to read commands that are typed into a console (i.e., an all-text display mode) or terminal window (an all-text window) in a GUI (graphical user interface) and then execute (i.e., run) them.

Although bash, the default shell on many Debian based Linux distros like Ubuntu and Linux Mint, is highly versatile and can be used for almost anything, each shell has its own characteristics and there might be situations in which it is preferable to use some other shell, such as ash, csh, ksh, sh or zsh. For example, the csh shell has a syntax that resembles that of the highly popular C programming language, and thus it is sometimes preferred by programmers.

Short Description of the main shells

Bourne: the standard default shell for non root users in FreeBSD. You can read about the shell by looking at the "man sh" pages. Uses abbreviation sh.

Korn: a shell developed by AT &T. You can read more about it by looking at the "man ksh93" pages. Uses abbreviation ksh or ksh93.

Bash: The Bourne Again SHell. You can read about it in the "man bash" pages. Uses abbreviation bash.

Z-Shell: The Z shell. You can read about it by looking at the "man zsh" pages. Uses the abbreviation zsh.

C-Shell: The C shell. You can read about it by looking at the "man csh" pages. Uses the abbreviation csh.

TC-Shell: Basically the same thing as above. They are a little bit different, but not very much so they now fall into the same category. You can read about it by looking at the "man tcsh" pages. Uses the abbreviation tcsh.

How to find out what shell you are running:

type at prompt:

  $ echo $SHELL

Here is what you may see:

/bin/sh : This is the Bourne shell.

/bin/ksh93 : This is the Korn shell.

/bin/bash : This is the Bash shell.

/bin/zsh : This is the Z shell.

/bin/csh : This is the C Shell.

/bin/tcsh : This is the TC Shell.

Next Check on your Valid login Shells

  $ vi /etc/shells

Important Note: You May not have all of these installed on your system right now. The way I checked If a shell was installed my system was by looking to see if I had man pages for a particular shell. I will use csh as an example. Type this into your terminal.

  $ man csh

If you don't have any man pages then there is a high probability you don't have this shell on your system. There is one other way to test this. Type this into your terminal.

  $ csh

  $ ps

If you have csh installed on your system you will see something similar to this.

13964 pts/0    00:00:00 bash
22450 pts/0    00:00:00 csh
22451 pts/0    00:00:00 ps

If you don't have csh installed on your system then install it will this command.

  $ sudo apt-get install csh

Why change your shell

The UNIX shell is most people's main access to the UNIX operating system and as such any improvement to it can result in considerably more effective use of the system, and may even allow you to do things you couldn't do before. The primary improvement most of the new generation shells give you is increased speed. They require fewer key strokes to get the same results due to their completion features, they give you more information (e.g. showing your directory in your prompt, showing which files it would complete) and they cover some of the more annoying features of UNIX, such as not going back up symbolic links to directories.

Deciding on a shell

Which of the many shells you choose depends on many different things, here is what I consider to be the most important, you may think differently.

How much time do I have to learn a new shell?

  • There is no point in using a shell with a different syntax, or a completly different alias system if you havn't the time to learn it. If you have the time and are presently using csh or tcsh it is worth considering a switch to a Bourne shell variant.

What do I wish to be able to do with my new shell?

  • The main reason for switching shells is to gain extra functionality; its vital you know what you are gaining from the switch.

Do I have to be able to switch back to a different shell?

  • If you may have to switch back to a standard shell, it is fairly important you don't become too dependent on extra features and so can't use an older shell.

How much extra load can the system cope with?

  • The more advanced shells tend to take up extra CPU, since they work in cbreak mode; if you are on an overloaded machine they should probably be avoided; this can also cause problems with an overloaded network. This only really applies to very old systems nowadays.

What support is given for my new shell?

  • If your new shell is not supported make sure you have someone you can ask if you encounter problems or that you have the time to sort them out yourself.

What shell am I using already?

  • Switching between certain shells of the same syntax is alot easier than switching between shells of a different syntax. So if you havn't much time a simple upgrade (eg csh to tcsh) may be a good idea.

Can I afford any minor bugs?

  • Like most software all shells have some bugs in them (especially csh), can you afford the problems that may occur because of them.

How to Change Shells

There are two different methods of changing shells.

  1. Temporarily changing your shell for the session you are in.
  2. Changing your login shell which is permanent.

Temporarily changing your shell for the session you are in

I will use csh as again an example. I will assume you already have csh installed on your system. All you need to do is type the command below into your terminal.

  $ csh

There are a few ways to verify this. This first comes from above.

  $ ps

If you have csh installed on your system you will see something similar to this.

13964 pts/0    00:00:00 bash
22450 pts/0    00:00:00 csh
22451 pts/0    00:00:00 ps

The second: Upon changing shells, a different command prompt (i.e., the short text message at the left of each command line) may be shown, depending on the previous and new shells. For example, if the original shell were bash and the new shell is sh, the command prompt would change for a user george from something like [george@localhost george]$ to something like sh-2.05b$.

To return to the original shell, or any other one for that matter, all that is necessary is to just type its name and then press the ENTER key. Thus, for example, to return to the bash shell from the sh shell (or from any other shell), all that is required is to type the word bash or exit.

Changing your login shell which is permanent

You will use a program called chsh. There is a interactive method and non-interactive method. Type this into your terminal.

interactive method

  $ chsh

This results in a brief dialog in which the user is prompted first for its password and then for the full path of the desired new shell.

Caution should be exercised when changing one's default shell because it is possible to make an error that only the root user (i.e., system administrator) can repair (although it should be easy for a skilled user to repair it on a home system). In particular, it is important to first test the shell temporarily in the current session and then to make certain that a valid shell name is being entered when making the permanent change.

non-interactive method

I will use csh as again an example.

  $ chsh -s /bin/csh

The -s sets it for you without having to go into the editor to do it.

Okay you did the command and it went ok.but the echo says it is the same. Log out and back it for the change to take effect.Then do echo $SHELL. You should see it show the new shell.

More information

If you would like more information I recommend reading these websites.

ChangingShells (last edited 2010-12-02 10:49:22 by 63-144-199-3)