我在 /opt/my-program/bin 中安装了一些程序,我想将 /opt/my-program/bin 添加到所有用户的非登录 shell 和登录 shell 的系统 $PATH 中。我应该怎么办?
更改 /etc/environment 对于非登录 shell 是可以的,但对于登录 shell 不起作用,因为 Debian 的 /etc/profile (将由登录 shell 获取)将覆盖 /etc/environment 中指定的 $PATH。
答案1
该/etc/login.defs
文件包含默认路径,如下所示:
ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
一些变量正在移动到pam
模块,但/bin/login
仍然具有独立于用户 shell 的配置文件。
答案2
通过添加到的末尾来制作/etc/profile
源代码,然后将路径更改添加到with/etc/bash.bashrc
[ -f /etc/bash.bashrc ] && . /etc/bash.bashrc
/etc/profile
/etc/bash.bashrc
PATH=$PATH:/some/other/path