echo $SHELL
shows the value of the SHELL
environment variable. This is a user configuration, which you can set to the path to your favorite interactive shell. Many programs invoke $SHELL
when asked to invoke a shell.
I think all shells leave this variable alone unless it is unset when they start. Bash sets SHELL
to its own path if the variable is unset when it starts. ATT ksh93 sets SHELL
to /bin/sh
if unset (even if /bin/sh
is some unrelated shell). Ksh (all versions) checks whether SHELL
is rsh
when it starts; if it is, it starts as a restricted shell.
which bash
shows the path to the bash executable (except when it doesn't — you should use type bash
instead). More precisely, it searches the directories in $PATH
for an executable called bash
.
echo $0
, in an interactive shell, shows the command name that was used to invoke the shell.
ps $$
(typed from a shell) displays information about the shell process ($$
is expanded to the process ID of the shell).
ls -l /proc/$$/exe
shows the full path to the executable for the shell
For example, my favorite shell is zsh, but here I've just started a home-compiled version of bash that isn't in the $PATH
.
% ./bash
$ echo $SHELL
/bin/zsh4
$ type bash
bash is /usr/bin/bash
$ echo $0
./bash
$ readlink /proc/$$/exe
/home/gilles/src/bash-git/bash
$ pwd
/home/gilles/src/bash-git
$ rm bash
$ echo $0
./bash
$ readlink /proc/$$/exe
/home/gilles/src/bash-git/bash (deleted)
which
is not really a useful command. – jw013 Jul 19 '12 at 15:18$SHELL
. It does not necessarily reflect the currently running shell. Instead,$SHELL
is the user's preferred shell, which is typically the one set in/etc/passwd
. If you start a different shell after logging in, you can not necessarily expect$SHELL
to match the current shell anymore. – jw013 Jul 19 '12 at 15:21wtfis
function from my dotfiles: https://github.com/janmoesen/tilde/blob/01a9f86/.bash/commands#L719 — it combinestype
,file
andls
to show as much information as possible. – janmoesen Jul 19 '12 at 20:43