小编Dav*_*vid的帖子

全局 /etc/profile setenv 或导出覆盖 .profile 中的用户设置

我需要在 CentOS 5.3 集群中调用程序的修改版本/home/user_name/bin而不是(旧)版本/opt/program_name/current。该程序使用 python 创建一个 tcsh 脚本,然后执行该脚本。

我可以覆盖 PATH 以在 中调用程序的修改版本~/bin,以便which program_name标识到~/bin的路径。我已经在这样做了.bashrc.profile.tcshrc,和.cshrc。但是,每次执行 tcsh 时,都会/etc/profile加载来自的环境变量,并且路径将恢复为/opt/program_name/current.

这些程序特定的变量在/etc/profile.d/program_name.sh被调用时设置/etc/profile

# /etc/profile 
for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        . $i
    fi
done
unset i
Run Code Online (Sandbox Code Playgroud)

因此,当program_name.sh被调用时,对应的脚本是:

# /etc/profile.d/program_name.sh
setenv PATH ${PATH}:/opt/program_name/current
Run Code Online (Sandbox Code Playgroud)

如何防止/etc/profile被我的用户帐户访问?

我没有 su 访问权限,其他用户仍在使用旧版本的软件,/opt/program_name/current因此我无法更新软件或修改其中的设置/etc/profile.d/program_name.sh

tcsh centos path shell-script

6
推荐指数
1
解决办法
4762
查看次数

标签 统计

centos ×1

path ×1

shell-script ×1

tcsh ×1