Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

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](http://en.wikipedia.org/wiki/Restricted_shell).

which bash shows the path to the bash executable (except when it doesn'tdoesn'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) 

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](http://en.wikipedia.org/wiki/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) 

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](http://en.wikipedia.org/wiki/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) 
Source Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k

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](http://en.wikipedia.org/wiki/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)