Tuesday, July 5, 2016

What Shell am I using?

Very simple, use any of the following methods:

Method# 1

$ echo $SHELL


[demo@localhost ~]$ echo $SHELL

Note: SHELL is an environment or system variable, echoing its output will reveal what it contains.

Method# 2

$ echo $0


[demo@localhost ~]$ echo $0

Note: The digit zero - "0" contains the name of the currently running program or script. So, at Shell Prompt, it will tell you the name of the Shell running. In a Shell Script, it will tell you the name of the Shell Script you are running.

Method# 3

$ grep ^user_name /etc/passwd


[demo@localhost ~]$ grep ^demo /etc/passwd
demo:x:500:500:demo user:/home/demo:/bin/bash

Note: The file "/etc/passwd" contains user accounts information, so the last field will contain the Shell Name with its path.

Method# 4

$ getent passwd user_name


[demo@localhost ~]$ getent passwd demo
demo:x:500:500:demo user:/home/demo:/bin/bash

Note: The command "getent" gets entries from administrative database. Here, we have specified "passwd" as the database to be used. This will list a non-local user account as well.