[Solved] bash SHELL environment variable not set

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
gwi
Level 2
Level 2
Posts: 97
Joined: Mon Jun 04, 2012 4:20 pm

[Solved] bash SHELL environment variable not set

Post by gwi »

Hello,

I am running Linux Mint 17.3 Cinnamon 64-bit. There are three accounts defined. One of these has an environment variable SHELL defined as /bin/bash. The other two don't have this variable set.

This causes a dircolors warning message when starting a terminal, which is not a big problem.
A big problem is that the Android emulator can not be run from Android Studio, because without the SHELL variable the emulator thinks it is running on a 32-bit system.

I checked the accounts. The don't have a .bashrc file. They have identical .pam_environment and .profile files.
What is setting the SHELL variable in one account (or what is unsetting it in the other two accounts)?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 3 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Regards,

George

Linux Mint 21.2 Victoria Cinnamon 64-bit, Asus Vanguard B85, Intel Core i7 4770S
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: bash SHELL environment variable not set

Post by xenopeek »

From the bash manpage:

Code: Select all

       SHELL  The full pathname to the shell is kept in this environment vari‐
              able.  If it is not set when the shell starts, bash  assigns  to
              it the full pathname of the current user's login shell.
I don't know how it would be empty.
Image
LinuxJim

Re: bash SHELL environment variable not set

Post by LinuxJim »

Two questions:

1. How did you create the additional user accounts?

2. How are you determining that the $SHELL environment variable is not set?
gwi
Level 2
Level 2
Posts: 97
Joined: Mon Jun 04, 2012 4:20 pm

Re: bash SHELL environment variable not set

Post by gwi »

@LinuxJim
  1. As far as I remember I used the adduser command.
  2. The command

    Code: Select all

    env | grep -i shell
    gives SHELL= for the account which has the problem, and SHELL=/bin/bash for the other account.
The account that has the environment variable set is the account made during install. The two accounts I created later do not have the variable set.

@xenopeek
As I can not find a file that sets the environment variable, I assume bash has set it. But why this doesn't happen (or is undone by something else) in the accounts I made later?
Regards,

George

Linux Mint 21.2 Victoria Cinnamon 64-bit, Asus Vanguard B85, Intel Core i7 4770S
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: bash SHELL environment variable not set

Post by xenopeek »

Check your /etc/passwd file. It has a line for each user (also system users) and notes their default shell. The first field has the username, the last field the location of the default shell. You can do grep username /etc/passwd to quickly find the line for a username (replace "username" with the username you want to look up).
Image
gwi
Level 2
Level 2
Posts: 97
Joined: Mon Jun 04, 2012 4:20 pm

Re: bash SHELL environment variable not set

Post by gwi »

That's it. The two accounts that had the problem did have no default shell specified (although they were using bash according to the output of ps $$). Adding /bin/bash solved the problem.

Thank you very much!
Regards,

George

Linux Mint 21.2 Victoria Cinnamon 64-bit, Asus Vanguard B85, Intel Core i7 4770S
LinuxJim

Re: bash SHELL environment variable not set

Post by LinuxJim »

gwi wrote:@LinuxJim
  1. As far as I remember I used the adduser command.
  2. The command

    Code: Select all

    env | grep -i shell
    gives SHELL= for the account which has the problem, and SHELL=/bin/bash for the other account.
The account that has the environment variable set is the account made during install. The two accounts I created later do not have the variable set.
Sorry I didn't get back to you sooner, but it looks like xenopeek pointed you in the right direction.

'adduser' has a command line option to set up the defaults for a new account. If you don't use that option, or you don't explicitly set the shell for that account with another option (see 'man adduser'), it doesn't get set in the passwd file.
Locked

Return to “Scripts & Bash”