如何在 debian 上为所有用户的非登录 shell 和登录 shell 添加系统 $PATH 的路径

Yan*_* Bo 6 debian path environment-variables

我在/opt/my-program/bin 中安装了一些程序,我想为所有用户的非登录shell 和登录shell 添加/opt/my-program/bin 到系统$PATH。我该怎么办?

更改 /etc/environment 对于非登录 shell 是可以的,但它不适用于登录 shell,因为 Debian 的 /etc/profile(将由登录 shell 提供)将覆盖 /etc/environment 中指定的 $PATH。

小智 6

/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
Run Code Online (Sandbox Code Playgroud)

一些变量正在移动到pam模块中,但/bin/login仍然具有独立于用户外壳的配置文件。


did*_*ter 5

通过添加到 的末尾来制作/etc/profile源代码,然后将路径更改添加到with/etc/bash.bashrc[ -f /etc/bash.bashrc ] && . /etc/bash.bashrc/etc/profile/etc/bash.bashrcPATH=$PATH:/some/other/path

  • /etc/profile 不被非登录 shell 执行 (6认同)
  • 我知道 - 但 `bash.bashrc` 就是为什么应该在此处添加路径更改,然后将 `/etc/profile` 源化为 `/etc/bash.bashrc` 来对登录 shell 进行更改。 (4认同)