0

On CentOS 8, the $PATH is not being updated with the value set in my script '/etc/profile.d/app-server-profile.sh' (SSH login).

I am logging into the box via SSH. I expect for '/etc/profile' to execute my '/etc/profile.d/app-server-profile.sh' script on login. (Is there a log which will confirm this file is executed?)

This is the contents of '/etc/profile.d/' (permissions OK?):

[builder@F1-TEST-V245 ~]$ ls -hal /etc/profile.d
total 108K
drwxr-xr-x.   2 root root 4.0K May 18 15:38 .
drwxr-xr-x. 113 root root 8.0K May 18 15:38 ..
-rw-r--r--.   1 root root  253 May 18 15:37 app-server-profile.sh
-rw-r--r--.   1 root root  664 May 11  2019 bash_completion.sh
-rw-r--r--.   1 root root  196 May 10  2019 colorgrep.csh
-rw-r--r--.   1 root root  201 May 10  2019 colorgrep.sh
-rw-r--r--.   1 root root 1.8K May 11  2019 colorls.csh
-rw-r--r--.   1 root root 1.6K May 11  2019 colorls.sh
-rw-r--r--.   1 root root  162 May 10  2019 colorxzgrep.csh
-rw-r--r--.   1 root root  183 May 10  2019 colorxzgrep.sh
-rw-r--r--.   1 root root  216 May 10  2019 colorzgrep.csh
-rw-r--r--.   1 root root  220 May 10  2019 colorzgrep.sh
-rw-r--r--.   1 root root   80 May 11  2019 csh.local
-rw-r--r--.   1 root root 1.1K Dec 14  2017 gawk.csh
-rw-r--r--.   1 root root  757 Dec 14  2017 gawk.sh
-rw-r--r--.   1 root root 2.3K Sep 10  2018 lang.csh
-rw-r--r--.   1 root root 2.3K Sep 10  2018 lang.sh
-rw-r--r--.   1 root root  500 May 11  2019 less.csh
-rw-r--r--.   1 root root  253 May 11  2019 less.sh
-rw-r--r--.   1 root root   57 May 18 15:38 maven.sh
-rw-r--r--.   1 root root   81 May 11  2019 sh.local
-rw-r--r--.   1 root root  106 May 11  2019 vim.csh
-rw-r--r--.   1 root root  248 May 11  2019 vim.sh
-rw-r--r--.   1 root root  120 May 10  2019 which2.csh
-rw-r--r--.   1 root root  310 May 10  2019 which2.sh

This is a snippet from '/etc/profile' (should run my script):

for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
    if [ -r "$i" ]; then
        if [ "${-#*i}" != "$-" ]; then
            . "$i"
        else
            . "$i" >/dev/null
        fi
    fi
done

This is the contents of '/etc/profile.d/app-server-profile.sh':

# All custom environment settings go in this file

# Add AWS CLI from /usr/local/bin
PATH="/usr/local/bin:$PATH"
PATH="/server-setup/scripts:$PATH"
export PATH

sudo chown --recursive :wheel /server-setup/scripts
sudo chmod -R 755 /server-setup/scripts

This is my $PATH after SSH login (no /server-setup/scripts on path):

[builder@F1-TEST-V245 ~]$ echo $PATH
/home/builder/.local/bin:/home/builder/bin:/bin:/usr/bin:/bin

It appears to me that the 'app-server-profile.sh' script should execute and my $PATH should be updated after SSH into the machine. It was executing previously and recently stopped working. I'm unsure how to trace the boot process to find where this is failing.

KevinB
  • 101

1 Answers1

0

Centos 8

/etc/profile.d/

  • File extension: .sh e.g '/etc/profile.d/my-script.sh'
  • File permissions: 0644 (-rw-r--r--)
  • Updates after: Logout & login (scope: global)

Alternatives

  1. /etc/environment
  • Put lines like: export ENV_VAR=env_value
  • Updates instantly (scope: global)
  1. ~/.bashrc, ~/.bash_profile
  • Put lines like: export ENV_VAR=env_value
  • Updates instantly (scope: current user)

More explained

how-to-permanently-set-environmental-variables

Felix Aballi
  • 101
  • 1