Does $SHELL store the path to the default shell in Linux?
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
My administrator says that my default shell is set to bash
, but
$ echo $SHELL
/bin/csh
$
Is the default shell related to the SHELL
variable at all? Is not, what is the variable used for?
bash shell rhel csh
add a comment |
up vote
3
down vote
favorite
My administrator says that my default shell is set to bash
, but
$ echo $SHELL
/bin/csh
$
Is the default shell related to the SHELL
variable at all? Is not, what is the variable used for?
bash shell rhel csh
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
My administrator says that my default shell is set to bash
, but
$ echo $SHELL
/bin/csh
$
Is the default shell related to the SHELL
variable at all? Is not, what is the variable used for?
bash shell rhel csh
My administrator says that my default shell is set to bash
, but
$ echo $SHELL
/bin/csh
$
Is the default shell related to the SHELL
variable at all? Is not, what is the variable used for?
bash shell rhel csh
bash shell rhel csh
asked Nov 17 '10 at 15:11
Lazer
12.2k196173
12.2k196173
add a comment |
add a comment |
5 Answers
5
active
oldest
votes
up vote
5
down vote
accepted
That's not 100% true. For example:
$> echo $SHELL
/bin/bash
$> /bin/ksh
$] echo $SHELL
/bin/bash
$SHELL contains the parent shell for your session, which is commonly your login shell as dictated by your user entry in /etc/passwd. More clearly, $SHELL is the parent shell from which your current session spawned. In my example the current shell, Korn, is technically running within BASH, which is why $SHELL was unmodified.
Obviously this is an almost exclusively semantic distinction, however, do not fall into the trap of believing that what you see is always what you get.
add a comment |
up vote
2
down vote
No, it is not related to default shell.
The system default shell is defined in /etc/default/useradd
file.
Your default shell is defined in /etc/passwd
file. You can change it by chsh
command.
The $SHELL
variables usually stores the current shell executable path. Each shell behaves differently on this point. E.g. bash sets the SHELL variable if it is unset when it starts, otherwise it leaves it unchanged. tcsh does not support this variable at all.
I did theecho $SHELL
from bash. Then, the current shell executable path should have referred to bash, right?
– Lazer
Nov 17 '10 at 16:56
mumble ... I checked more carefully and edited the response.
– andcoz
Nov 17 '10 at 18:01
add a comment |
up vote
2
down vote
The variable is for your information ("Hey, what shell am I running under?") rather than the way you set the shell. Since Unix environment variables can only propagate down to child processes and not back up to parents, generally environment variables like this are descriptive rather than configuration options.
To see your default shell, look at your entry in /etc/passwd
, and to change that, run chsh
. (This is assuming you're not using NIS or LDAP for this information; in that case use getent passwd $USERNAME
.) And as andcoz notes, the initial defaults for new users added with the standard useradd
program are in /etc/default/useradd
.
add a comment |
up vote
1
down vote
The “default shell“ for a unix system administrator is what is stored in the “shell” column of the user database. This is the program that is invoked when you log in in text mode (on a text mode console, or over the network via e.g. ssh).
The ”default shell” for a unix application is either sh
or $SHELL
. There is some variation as to whether $SHELL
is intended to be an interactive shell or a shell to run scripts. The POSIX specification is ambiguous in that regard, reflecting diverging practice:
This variable shall represent a pathname of the user's preferred command language interpreter. If this interpreter does not conform to the Shell Command Language in the Shell and Utilities volume of IEEE Std 1003.1-2001, Chapter 2, Shell Command Language, utilities may behave differently from those described in IEEE Std 1003.1-2001.
That bit about the preferred command language means that some applications may try to run commands in $SHELL
, using POSIX shell command syntax. However, the normal way to run a shell command in a unix application is through functions such as system
, which is supposed to find a suitable shell regardless of the value of the $SHELL
environment variable. Bash and ksh are examples of POSIX-compliant shells. Zsh comes close. Csh is different, and you may occasionally run into trouble due to SHELL
being set to csh (it's not very common as most applications do call sh
and csh is compatible enough for basic use).
In practice, for a unix user, $SHELL
is your preferred interactive shell, i.e., what you want to see when you start a terminal emulator. It doesn't have to be the same as your login shell¹: you can set it in your .profile
or .login
.
¹
For example, I typically leave whatever login shell is the default, maintain a Bourne-compatible .profile
, but set SHELL
to zsh if it's available.
add a comment |
up vote
0
down vote
I always understood environmental variables to be advisory to programs you are running. $SHELL would be the shell you want a program to start when it needs to run a shell. Compare with $EDITOR, you email program might use it to decide which editor to offer you. B/c these environmental variables are so easy to change you can't really rely on them as the final word on what the world is really like.
Related to your question on default shell: chsh is a command that allows you to change your login shell. Before changing it shows you what your current choice is.
add a comment |
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
That's not 100% true. For example:
$> echo $SHELL
/bin/bash
$> /bin/ksh
$] echo $SHELL
/bin/bash
$SHELL contains the parent shell for your session, which is commonly your login shell as dictated by your user entry in /etc/passwd. More clearly, $SHELL is the parent shell from which your current session spawned. In my example the current shell, Korn, is technically running within BASH, which is why $SHELL was unmodified.
Obviously this is an almost exclusively semantic distinction, however, do not fall into the trap of believing that what you see is always what you get.
add a comment |
up vote
5
down vote
accepted
That's not 100% true. For example:
$> echo $SHELL
/bin/bash
$> /bin/ksh
$] echo $SHELL
/bin/bash
$SHELL contains the parent shell for your session, which is commonly your login shell as dictated by your user entry in /etc/passwd. More clearly, $SHELL is the parent shell from which your current session spawned. In my example the current shell, Korn, is technically running within BASH, which is why $SHELL was unmodified.
Obviously this is an almost exclusively semantic distinction, however, do not fall into the trap of believing that what you see is always what you get.
add a comment |
up vote
5
down vote
accepted
up vote
5
down vote
accepted
That's not 100% true. For example:
$> echo $SHELL
/bin/bash
$> /bin/ksh
$] echo $SHELL
/bin/bash
$SHELL contains the parent shell for your session, which is commonly your login shell as dictated by your user entry in /etc/passwd. More clearly, $SHELL is the parent shell from which your current session spawned. In my example the current shell, Korn, is technically running within BASH, which is why $SHELL was unmodified.
Obviously this is an almost exclusively semantic distinction, however, do not fall into the trap of believing that what you see is always what you get.
That's not 100% true. For example:
$> echo $SHELL
/bin/bash
$> /bin/ksh
$] echo $SHELL
/bin/bash
$SHELL contains the parent shell for your session, which is commonly your login shell as dictated by your user entry in /etc/passwd. More clearly, $SHELL is the parent shell from which your current session spawned. In my example the current shell, Korn, is technically running within BASH, which is why $SHELL was unmodified.
Obviously this is an almost exclusively semantic distinction, however, do not fall into the trap of believing that what you see is always what you get.
answered Nov 17 '10 at 17:10
Tok
6,87421810
6,87421810
add a comment |
add a comment |
up vote
2
down vote
No, it is not related to default shell.
The system default shell is defined in /etc/default/useradd
file.
Your default shell is defined in /etc/passwd
file. You can change it by chsh
command.
The $SHELL
variables usually stores the current shell executable path. Each shell behaves differently on this point. E.g. bash sets the SHELL variable if it is unset when it starts, otherwise it leaves it unchanged. tcsh does not support this variable at all.
I did theecho $SHELL
from bash. Then, the current shell executable path should have referred to bash, right?
– Lazer
Nov 17 '10 at 16:56
mumble ... I checked more carefully and edited the response.
– andcoz
Nov 17 '10 at 18:01
add a comment |
up vote
2
down vote
No, it is not related to default shell.
The system default shell is defined in /etc/default/useradd
file.
Your default shell is defined in /etc/passwd
file. You can change it by chsh
command.
The $SHELL
variables usually stores the current shell executable path. Each shell behaves differently on this point. E.g. bash sets the SHELL variable if it is unset when it starts, otherwise it leaves it unchanged. tcsh does not support this variable at all.
I did theecho $SHELL
from bash. Then, the current shell executable path should have referred to bash, right?
– Lazer
Nov 17 '10 at 16:56
mumble ... I checked more carefully and edited the response.
– andcoz
Nov 17 '10 at 18:01
add a comment |
up vote
2
down vote
up vote
2
down vote
No, it is not related to default shell.
The system default shell is defined in /etc/default/useradd
file.
Your default shell is defined in /etc/passwd
file. You can change it by chsh
command.
The $SHELL
variables usually stores the current shell executable path. Each shell behaves differently on this point. E.g. bash sets the SHELL variable if it is unset when it starts, otherwise it leaves it unchanged. tcsh does not support this variable at all.
No, it is not related to default shell.
The system default shell is defined in /etc/default/useradd
file.
Your default shell is defined in /etc/passwd
file. You can change it by chsh
command.
The $SHELL
variables usually stores the current shell executable path. Each shell behaves differently on this point. E.g. bash sets the SHELL variable if it is unset when it starts, otherwise it leaves it unchanged. tcsh does not support this variable at all.
edited Nov 17 '10 at 18:06
answered Nov 17 '10 at 16:52
andcoz
12.3k33039
12.3k33039
I did theecho $SHELL
from bash. Then, the current shell executable path should have referred to bash, right?
– Lazer
Nov 17 '10 at 16:56
mumble ... I checked more carefully and edited the response.
– andcoz
Nov 17 '10 at 18:01
add a comment |
I did theecho $SHELL
from bash. Then, the current shell executable path should have referred to bash, right?
– Lazer
Nov 17 '10 at 16:56
mumble ... I checked more carefully and edited the response.
– andcoz
Nov 17 '10 at 18:01
I did the
echo $SHELL
from bash. Then, the current shell executable path should have referred to bash, right?– Lazer
Nov 17 '10 at 16:56
I did the
echo $SHELL
from bash. Then, the current shell executable path should have referred to bash, right?– Lazer
Nov 17 '10 at 16:56
mumble ... I checked more carefully and edited the response.
– andcoz
Nov 17 '10 at 18:01
mumble ... I checked more carefully and edited the response.
– andcoz
Nov 17 '10 at 18:01
add a comment |
up vote
2
down vote
The variable is for your information ("Hey, what shell am I running under?") rather than the way you set the shell. Since Unix environment variables can only propagate down to child processes and not back up to parents, generally environment variables like this are descriptive rather than configuration options.
To see your default shell, look at your entry in /etc/passwd
, and to change that, run chsh
. (This is assuming you're not using NIS or LDAP for this information; in that case use getent passwd $USERNAME
.) And as andcoz notes, the initial defaults for new users added with the standard useradd
program are in /etc/default/useradd
.
add a comment |
up vote
2
down vote
The variable is for your information ("Hey, what shell am I running under?") rather than the way you set the shell. Since Unix environment variables can only propagate down to child processes and not back up to parents, generally environment variables like this are descriptive rather than configuration options.
To see your default shell, look at your entry in /etc/passwd
, and to change that, run chsh
. (This is assuming you're not using NIS or LDAP for this information; in that case use getent passwd $USERNAME
.) And as andcoz notes, the initial defaults for new users added with the standard useradd
program are in /etc/default/useradd
.
add a comment |
up vote
2
down vote
up vote
2
down vote
The variable is for your information ("Hey, what shell am I running under?") rather than the way you set the shell. Since Unix environment variables can only propagate down to child processes and not back up to parents, generally environment variables like this are descriptive rather than configuration options.
To see your default shell, look at your entry in /etc/passwd
, and to change that, run chsh
. (This is assuming you're not using NIS or LDAP for this information; in that case use getent passwd $USERNAME
.) And as andcoz notes, the initial defaults for new users added with the standard useradd
program are in /etc/default/useradd
.
The variable is for your information ("Hey, what shell am I running under?") rather than the way you set the shell. Since Unix environment variables can only propagate down to child processes and not back up to parents, generally environment variables like this are descriptive rather than configuration options.
To see your default shell, look at your entry in /etc/passwd
, and to change that, run chsh
. (This is assuming you're not using NIS or LDAP for this information; in that case use getent passwd $USERNAME
.) And as andcoz notes, the initial defaults for new users added with the standard useradd
program are in /etc/default/useradd
.
edited Nov 21 at 15:26
answered Nov 17 '10 at 17:03
mattdm
27.7k1172110
27.7k1172110
add a comment |
add a comment |
up vote
1
down vote
The “default shell“ for a unix system administrator is what is stored in the “shell” column of the user database. This is the program that is invoked when you log in in text mode (on a text mode console, or over the network via e.g. ssh).
The ”default shell” for a unix application is either sh
or $SHELL
. There is some variation as to whether $SHELL
is intended to be an interactive shell or a shell to run scripts. The POSIX specification is ambiguous in that regard, reflecting diverging practice:
This variable shall represent a pathname of the user's preferred command language interpreter. If this interpreter does not conform to the Shell Command Language in the Shell and Utilities volume of IEEE Std 1003.1-2001, Chapter 2, Shell Command Language, utilities may behave differently from those described in IEEE Std 1003.1-2001.
That bit about the preferred command language means that some applications may try to run commands in $SHELL
, using POSIX shell command syntax. However, the normal way to run a shell command in a unix application is through functions such as system
, which is supposed to find a suitable shell regardless of the value of the $SHELL
environment variable. Bash and ksh are examples of POSIX-compliant shells. Zsh comes close. Csh is different, and you may occasionally run into trouble due to SHELL
being set to csh (it's not very common as most applications do call sh
and csh is compatible enough for basic use).
In practice, for a unix user, $SHELL
is your preferred interactive shell, i.e., what you want to see when you start a terminal emulator. It doesn't have to be the same as your login shell¹: you can set it in your .profile
or .login
.
¹
For example, I typically leave whatever login shell is the default, maintain a Bourne-compatible .profile
, but set SHELL
to zsh if it's available.
add a comment |
up vote
1
down vote
The “default shell“ for a unix system administrator is what is stored in the “shell” column of the user database. This is the program that is invoked when you log in in text mode (on a text mode console, or over the network via e.g. ssh).
The ”default shell” for a unix application is either sh
or $SHELL
. There is some variation as to whether $SHELL
is intended to be an interactive shell or a shell to run scripts. The POSIX specification is ambiguous in that regard, reflecting diverging practice:
This variable shall represent a pathname of the user's preferred command language interpreter. If this interpreter does not conform to the Shell Command Language in the Shell and Utilities volume of IEEE Std 1003.1-2001, Chapter 2, Shell Command Language, utilities may behave differently from those described in IEEE Std 1003.1-2001.
That bit about the preferred command language means that some applications may try to run commands in $SHELL
, using POSIX shell command syntax. However, the normal way to run a shell command in a unix application is through functions such as system
, which is supposed to find a suitable shell regardless of the value of the $SHELL
environment variable. Bash and ksh are examples of POSIX-compliant shells. Zsh comes close. Csh is different, and you may occasionally run into trouble due to SHELL
being set to csh (it's not very common as most applications do call sh
and csh is compatible enough for basic use).
In practice, for a unix user, $SHELL
is your preferred interactive shell, i.e., what you want to see when you start a terminal emulator. It doesn't have to be the same as your login shell¹: you can set it in your .profile
or .login
.
¹
For example, I typically leave whatever login shell is the default, maintain a Bourne-compatible .profile
, but set SHELL
to zsh if it's available.
add a comment |
up vote
1
down vote
up vote
1
down vote
The “default shell“ for a unix system administrator is what is stored in the “shell” column of the user database. This is the program that is invoked when you log in in text mode (on a text mode console, or over the network via e.g. ssh).
The ”default shell” for a unix application is either sh
or $SHELL
. There is some variation as to whether $SHELL
is intended to be an interactive shell or a shell to run scripts. The POSIX specification is ambiguous in that regard, reflecting diverging practice:
This variable shall represent a pathname of the user's preferred command language interpreter. If this interpreter does not conform to the Shell Command Language in the Shell and Utilities volume of IEEE Std 1003.1-2001, Chapter 2, Shell Command Language, utilities may behave differently from those described in IEEE Std 1003.1-2001.
That bit about the preferred command language means that some applications may try to run commands in $SHELL
, using POSIX shell command syntax. However, the normal way to run a shell command in a unix application is through functions such as system
, which is supposed to find a suitable shell regardless of the value of the $SHELL
environment variable. Bash and ksh are examples of POSIX-compliant shells. Zsh comes close. Csh is different, and you may occasionally run into trouble due to SHELL
being set to csh (it's not very common as most applications do call sh
and csh is compatible enough for basic use).
In practice, for a unix user, $SHELL
is your preferred interactive shell, i.e., what you want to see when you start a terminal emulator. It doesn't have to be the same as your login shell¹: you can set it in your .profile
or .login
.
¹
For example, I typically leave whatever login shell is the default, maintain a Bourne-compatible .profile
, but set SHELL
to zsh if it's available.
The “default shell“ for a unix system administrator is what is stored in the “shell” column of the user database. This is the program that is invoked when you log in in text mode (on a text mode console, or over the network via e.g. ssh).
The ”default shell” for a unix application is either sh
or $SHELL
. There is some variation as to whether $SHELL
is intended to be an interactive shell or a shell to run scripts. The POSIX specification is ambiguous in that regard, reflecting diverging practice:
This variable shall represent a pathname of the user's preferred command language interpreter. If this interpreter does not conform to the Shell Command Language in the Shell and Utilities volume of IEEE Std 1003.1-2001, Chapter 2, Shell Command Language, utilities may behave differently from those described in IEEE Std 1003.1-2001.
That bit about the preferred command language means that some applications may try to run commands in $SHELL
, using POSIX shell command syntax. However, the normal way to run a shell command in a unix application is through functions such as system
, which is supposed to find a suitable shell regardless of the value of the $SHELL
environment variable. Bash and ksh are examples of POSIX-compliant shells. Zsh comes close. Csh is different, and you may occasionally run into trouble due to SHELL
being set to csh (it's not very common as most applications do call sh
and csh is compatible enough for basic use).
In practice, for a unix user, $SHELL
is your preferred interactive shell, i.e., what you want to see when you start a terminal emulator. It doesn't have to be the same as your login shell¹: you can set it in your .profile
or .login
.
¹
For example, I typically leave whatever login shell is the default, maintain a Bourne-compatible .profile
, but set SHELL
to zsh if it's available.
answered Nov 17 '10 at 21:50
Gilles
522k12610401575
522k12610401575
add a comment |
add a comment |
up vote
0
down vote
I always understood environmental variables to be advisory to programs you are running. $SHELL would be the shell you want a program to start when it needs to run a shell. Compare with $EDITOR, you email program might use it to decide which editor to offer you. B/c these environmental variables are so easy to change you can't really rely on them as the final word on what the world is really like.
Related to your question on default shell: chsh is a command that allows you to change your login shell. Before changing it shows you what your current choice is.
add a comment |
up vote
0
down vote
I always understood environmental variables to be advisory to programs you are running. $SHELL would be the shell you want a program to start when it needs to run a shell. Compare with $EDITOR, you email program might use it to decide which editor to offer you. B/c these environmental variables are so easy to change you can't really rely on them as the final word on what the world is really like.
Related to your question on default shell: chsh is a command that allows you to change your login shell. Before changing it shows you what your current choice is.
add a comment |
up vote
0
down vote
up vote
0
down vote
I always understood environmental variables to be advisory to programs you are running. $SHELL would be the shell you want a program to start when it needs to run a shell. Compare with $EDITOR, you email program might use it to decide which editor to offer you. B/c these environmental variables are so easy to change you can't really rely on them as the final word on what the world is really like.
Related to your question on default shell: chsh is a command that allows you to change your login shell. Before changing it shows you what your current choice is.
I always understood environmental variables to be advisory to programs you are running. $SHELL would be the shell you want a program to start when it needs to run a shell. Compare with $EDITOR, you email program might use it to decide which editor to offer you. B/c these environmental variables are so easy to change you can't really rely on them as the final word on what the world is really like.
Related to your question on default shell: chsh is a command that allows you to change your login shell. Before changing it shows you what your current choice is.
answered Nov 17 '10 at 21:19
kasterma
4291413
4291413
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f4150%2fdoes-shell-store-the-path-to-the-default-shell-in-linux%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown