Thursday, September 27, 2012

How to find the default shell in UNIX or Linux or Solaris

Question: Default shell of the logged in User

Answer: There are many ways to find the default shell.

a)      By checking the last column in the /etc/passwd file  ( grep –i username /etc/passwd )

Eg:  [vjsujay@cheetah:/home/vjsujay]#grep -i vjsujay /etc/passwd

b)      By displaying the value of global environment variable SHELL  ( echo $SHELL )

Eg: [vjsujay@cheetah:/home/vjsujay]#echo $SHELL

NOTE: This will give correct default shell name as output as long as your current shell is your default shell

c)      By using the command echo $0

Eg: [vjsujay@cheetah:/home/st39422]#echo $0