在CentOS 8上,我的脚本'/etc/profile.d/app-server-profile.sh‘(SSH登录)中设置的值没有更新$PATH。
我正在通过SSH登录这个盒子。我希望'/etc/profile‘在登录时执行我的'/etc/profile.d/app-server-profile.sh’脚本。(是否有一个日志可以确认是否执行了该文件?)
这是'/etc/profile.d/‘的内容(权限可以吗?):
[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这是“/etc/profile”中的一个片段(应该运行我的脚本):
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这是‘/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这是我在SSH登录后的$PATH (没有/服务器-安装/脚本在路径上):
[builder@F1-TEST-V245 ~]$ echo $PATH
/home/builder/.local/bin:/home/builder/bin:/bin:/usr/bin:/bin在我看来,'app-server-profile.sh‘脚本应该执行,我的$PATH应该在SSH进入机器后更新。它以前是执行的,最近停止工作。我不知道如何跟踪引导过程,以找出失败的地方。
发布于 2020-10-23 21:37:31
/etc/profile.d/
.sh例如'/etc/profile.d/my-script.sh‘0644 (-rw-r--r-)替代物
/etc/environmentexport ENV_VAR=env_value~/.bashrc,~/.bash_profileexport ENV_VAR=env_valuehttps://serverfault.com/questions/1017770
复制相似问题