/etc/shells is a file that contains shells which are generally found in /bin as shown here:
Command: 1
Code:
-bash-2.05b# ls -l /etc/shells
-rw-r--r-- 1 root root 80 Jul 22 2004 /etc/shells
Command: 2
Code:
-bash-2.05b# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/bash2
/bin/ash
/bin/bsh
/bin/tcsh
/bin/csh
-bash-2.05b#
This will also do the same thing as above:
Code:
-bash-2.05b# chsh --list-shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/bash2
/bin/ash
/bin/bsh
/bin/tcsh
/bin/csh
-bash-2.05b#
Command: 4
Code:
-bash-2.05b# for Shell in `cat /etc/shells`; do ls -l $Shell; done
lrwxrwxrwx 1 root root 4 Jul 27 2004 /bin/sh -> bash
-rwxr-xr-x 1 root root 593304 Mar 11 2004 /bin/bash
-rwxr-xr-x 1 root root 4636 May 4 2004 /sbin/nologin
lrwxrwxrwx 1 root root 4 Jul 27 2004 /bin/bash2 -> bash
-rwxr-xr-x 1 root root 98388 Feb 16 2004 /bin/ash
lrwxrwxrwx 1 root root 3 Jul 27 2004 /bin/bsh -> ash
-rwxr-xr-x 1 root root 319520 Feb 17 2004 /bin/tcsh
lrwxrwxrwx 1 root root 4 Jul 27 2004 /bin/csh -> tcsh
-bash-2.05b#
We need to specify the complete path for the named shell even if the /bin directory is included in the $PATH variable:
Code:
-bash-2.05b# chsh -s sh
Changing shell for root.
chsh: shell must be a full path name.
-bash-2.05b#
But to change your Shell temporarily, you can simply type its name and hit the enter key:
Code:
-bash-2.05b# sh
sh-2.05b#
Without changing your login shell permanently either by executing the chsh -s command or by asking your system admin to make change sin the /etc/passwd file, you can simply put this line of code in your csh (if that is the default shell) or bash (if this is the default shell) profile file. For example, my default login shell is bash. But to get sh every time I login to the server, I can do the following:
Code:
sh-2.05b# cat .bash_profile
PATH=$PATH:$HOME/bin:.
export PATH
echo "Welcome, Dev! Have happy working hours!"
/bin/sh
sh-2.05b#
Even if my default login shell is
/bin/bash:
Code:
sh-2.05b# grep ^$USER /etc/passwd
root:x:0:0:root:/root:/bin/bash
sh-2.05b#
I still get the
sh shell.
So, you should see which profile file is being called upon when you login. Just add that line (at the bottom, if you would like to) and you can make your life easy!