HostOnNet Blog

Linux shell – bash, zsh, chsh

Most linux systems use bash shell. When you take terminal, what you do is run bash. To see version of bash, run

bash --version

There are other shells, like dash, zsh, omyzsh available as replacement to bash.

View Shell You Are using

To view shell you are using, run

echo $0


echo $SHELL


root@hon-vpn:~# echo $0
root@hon-vpn:~# echo $SHELL

Another method is to run

echo "$$"

That shows PID of shell you are using. To find the program with the PID, run

ps -p "$$"


root@hon-vpn:~# ps -p "$$"
  PID TTY          TIME CMD
 4939 pts/1    00:00:00 bash

Changing Shell Of A User

Shell of a user is set in /etc/passwd file. To see shell of user root, lets run

root@hon-vpn:~# cat /etc/passwd | grep root

We found user root have shell set to /bin/bash

To change a users shell, run

chsh USERNAME --shell /path/to/shell

Let say i want to set shell for user apache to /bin/bash, run

[root@server1 ~]# chsh apache --shell /bin/bash
Changing shell for apache.
Shell changed.
[root@server1 ~]# 

Posted in Linux