$SHELL variable

From Linux Bash Shell Scripting Tutorial Wiki
Jump to navigation Jump to search

The $SHELL is environment variable. The full pathname to the shell is in this environment variable. If it is not set when the shell starts, bash assigns the full pathname of the current user's login shell.

Viewing the $SHELL variable

Use the echo command or printf command as follows to view the current settings:

echo "$SHELL"
printf "The current shell is %s\n" $SHELL

Changing the $SHELL variable

Yes, they can change the $SHELL variable using the following syntax:

SHELL=/bin/sh
SHELL=/bin/ksh

Finding your real shell

The echo $SHELL command is not reliable for finding out your current shell. Instead, we use the following ps command:

ps -p $$
What is the $SHELL environment variable in Linux or Unix?
What is the $SHELL environment variable in Linux or Unix?

See also