How to change the shell in Linux or Unix.

Linux and Unix have a vairety of shells. A shell is a program that provides the text interface, it reads the interactive or non interactive commands, interprets and executes the instructions. Depending on your version of Linux or Unix, a number of shells may be available. The default shell for Linux is bash.

Here is the command to find out what shell you are currently in.
echo $0 – this will list the current shell.
echo $SHELL – this will provide the path of the current shell.

You can swith to a different shell temporarily, for example you may have a program that is more compatible with the csh shell. Below is an example.
chs – this will change the shell to csh.
echo $0 – To check and see what your current shell is.

If you wanted to find out what shells are installed, then check the contents of the file /etc/shells.

cat /etc/shells

Below is the output from the above cat command. These are the shells available on Redhat Enterprise 5 Linux.
/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
/bin/ksh

To change the shell permanently for a user in RedHat linux using the GUI, simply goto Systems – Administration – Users and Groups. Edit the users profile and click on the drop down next to Login shell, then select the new default shell.

About Andrew Lin

Hi,
I have always wanted to creat a blog site but never had the time. I have been working in Information Technology for over 15 years. I specialize mainly in networks and server technologies and dabble a little with the programming aspects.

Andrew Lin

View all posts by Andrew Lin →

Leave a Reply

Your email address will not be published. Required fields are marked *