这是一个快速的。 我在debian,以root身份运行一个bash脚本。 如果我已经创build了没有主目录的用户,是否可以为特定的用户设置一个envar?
看着这些答案,他们都指的是看到在主目录中找不到的文件,我不能这样做: https : //unix.stackexchange.com/questions/21598/how-do-i-set-a-user-environment-variable-永久不会话
取决于你分配的实际的shell,但是例如bash将在尝试从用户主目录中尝试各个~/.bash_profile , ~/.bash_login和~/.profile文件之前尝试读取/etc/profile 。
我目前没有Debian主机,但是RHEL使用一个简单的drop-in目录/etc/profile.d来获得更好的结果。 EGtesting用户的特定UID号码(599)的东西应该工作:
# /etc/profile.d/for-user-599.sh [[ $(id -u) = 599 ]] && export VAR=VALUE