Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

/etc/profile and ${HOME}/.profile not read for non root

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
User avatar
MickPF
Posts: 2
Joined: 2018-04-18 06:28
Location: Planet Earth
Contact:

/etc/profile and ${HOME}/.profile not read for non root

#1 Post by MickPF »

Hello,

yesterday I've installed Debian 9.4 (with MATE desktop) from DVD's and created during the GUI mode installation process an user with bash as the login shell.
When I login as this user, neither '/etc/profile' (with files from '/etc/profile.d') nor '${HOME}/.profile' are read/executed! But it reads '/etc/bash.bashrc' and '${HOME}/.bashrc'.

When I login as root, all these files are read.

I have not made any changes to these system files so far.

Thanks in advance,
Michael
Nobody is perfect.
My name is NOT Nobody.

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5346
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 13 times
Been thanked: 66 times

Re: /etc/profile and ${HOME}/.profile not read for non root

#2 Post by dilberts_left_nut »

https://wiki.debian.org/EnvironmentVariables wrote:The login shell starts and reads its shell-specific configuration files.

bash first reads /etc/profile to get values that are defined for all users. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first of these files that exists and is readable. See DotFiles for full details.
AdrianTM wrote:There's no hacker in my grandma...

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: /etc/profile and ${HOME}/.profile not read for non root

#3 Post by debiman »

MickPF wrote:created (...) user with bash as the login shell.
how exactly did you do that?
it sounds like you didn't just go with defaults, but made some conscious choices, but then bash is the default login shell anyhow, no?
MickPF wrote:When I login as this user, neither '/etc/profile' (with files from '/etc/profile.d') nor '${HOME}/.profile' are read/executed!
highly unlikely.
how did you form that opinion?

User avatar
MickPF
Posts: 2
Joined: 2018-04-18 06:28
Location: Planet Earth
Contact:

Re: /etc/profile and ${HOME}/.profile not read for non root

#4 Post by MickPF »

Hello debiman,

during the installation process I was asked for user data to be created. This process creates this user with "bash" as the login shell.

It's very unlikely to find intelligent life on Earth also, you will find it definitely not everywhere but here and there.

I set and exported some different environment variables in '/etc/profile', in '/etc/profile.d/my_env.sh', in '${HOME}/.profile', in '/etc/bash.bashrc' and in '${HOME}/.bashrc'.
Asking for their values in a terminal window (SHELL=/bin/bash) displays only vars set in '/etc/bash.bashrc' and in '${HOME}/.bashrc'.
Values of vars set in '/etc/profile', in '/etc/profile.d/my_env.sh' and in '${HOME}/.profile' are empty.
Nobody is perfect.
My name is NOT Nobody.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: /etc/profile and ${HOME}/.profile not read for non root

#5 Post by debiman »

quoted from https://wiki.debian.org/DotFiles :
Now, since bash is being invoked as a login shell (with name "-bash", a special ancient hack), it reads /etc/profile first. Then it looks in your home directory for .bash_profile, and if it finds it, it reads that. If it doesn't find .bash_profile, it looks for .bash_login, and if it doesn't find that, it looks for .profile (the standard Bourne/Korn shell configuration file). Otherwise, it stops looking for dot files, and gives you a prompt.
of course you should read the whole article.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: /etc/profile and ${HOME}/.profile not read for non root

#6 Post by Head_on_a_Stick »

tl;dr: for a display manager login, add your lines to ~/.xsessionrc instead of ~/.profile.
deadbang

Post Reply