Questions about startup script order

Issues related to applications and software problems and general support
Post Reply
Posts: 42
Joined: 2015/06/06 23:55:29

Questions about startup script order

Post by bodisha » 2019/11/26 20:44:33

I'm trying to understand the order startup scripts run for interactive vs non-interactive modes. I've put simple echo commands in everything but the /etc/environment & BASH_ENV aren't working how I expected they would (I understand they aren't technically startup scripts)

The way I understand the /etc/environment file is it sets global variables and is read by PAM... Because of this I'm expecting the variables set here to appear for all users... But it only seems to be running for root in a non-interactive terminal

And I can't figure out how to get the $BASH_ENV to work at all... My understanding of it is you point it to a file with variables and it reads them in

Code: Select all

and it's suppose to import everything it finds. I've set this in my /etc/profile... But when I echo it's contents I just get the file location and name instead of it's contents.

Could someone set me straight about them? I would greatly appreciate it!

Posts: 2859
Joined: 2014/09/20 11:22:14

Re: Questions about startup script order

Post by aks » 2019/12/01 17:39:58

/etc/environment is usually read by and AFAIK pam_env doesn't support expanding variables (so $VAR is $VAR literal not the conents of $VAR). Also that's only read, if the pam_env is in your PAM stack and is used by whatever is doing your login.

Because of this I'm expecting the variables set here to appear for all users

Not necessarily so, the shell *may* overwrite those things (it used to ages ago). You're better off putting things in /etc/profile.d (IMO).

For more about BASH_ENV, have a look at ... Files.html (specifically non-interactive login).

User avatar
Forum Moderator
Posts: 27138
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Questions about startup script order

Post by TrevorH » 2019/12/01 18:52:20

And don't forget that systemd has its own set of rules and (at least some of the time) doesn't use PAM at all.
CentOS 6 will die in November 2020 - migrate sooner rather than later!
CentOS 5 has been EOL for nearly 3 years and should no longer be used for anything!
Full time Geek, part time moderator. Use the FAQ Luke

Post Reply

Return to “CentOS 8 - General Support”