13

Where is the environment variable $SHELL first set on a UNIX system?

How can I find and print all of this type of default settings of my terminal?

Anko
  • 4,526
eloone
  • 395

2 Answers2

12

Traditionally, by login(1):

ENVIRONMENT
     login sets the following environment variables:

     HOME        The user's home directory, as specified by the password
                 database.

     SHELL       The user's shell, as specified by the password database.

Though these days it might be a window manager or terminal program making those settings, depending on the flavor of unix and how far they've departed from tradition. env will show what's currently set in the environment, which a shell or something else may have altered from the default. However, "terminal settings" are not typically environment variables, and shells like bash or zsh have a set command, and other places they hide settings...

thrig
  • 34,938
  • 2
    Any idea what sets SHELL when logging in via SSH? Is login(1) involved (maybe via PAM)? – dpat Nov 13 '22 at 11:25
  • @dpat, I reckon it's worth asking the OP whether they want to clarify whether their question is merely for local systems, and if so, ask your own about SSH. Otherwise, respondents here might neglect to consider SSH. – RokeJulianLockhart Jan 16 '24 at 01:14
2

You can check the default values of your system in /etc/default/useradd or with sudo useradd -D, this will output the default value for $SHELL and other variables.

eloone
  • 395