Shell is a command line interpreter. There are various shells in Linux. The bash shell is integrated in many Linux distributions. There also are ksh, zsh, tcsh. This tutorial provides 3 methods to check which shell currently using in Linux.
Method 1 - $0 special parameter
$0 is a special parameter that contains the name of the currently used shell. Use
echo command to print value:
Method 2 - ps command
ps command allows to get a snapshot of the current processes. The
-p option allows to select the process by ID (PID). The
$$ is a special parameter that contains the process ID of the currently used shell.
ps -p $$
PID TTY TIME CMD 1422 pts/0 00:00:00 bash
Method 3 - /etc/passwd file
/etc/passwd is a text file which contains details about users such as username, user ID, group ID, shell, etc. Each line in a file contains 7 fields. The last field is shell.
grep "^$USER" /etc/passwd | cut -d: -f7