.login 未在 CentOS 登录上调用

.login not called on CentOS Login

正如我所读,bash shell 应该在每次 myUser 登录时调用 /home/myUser/.login。 那就是我要设置和导出一些变量的地方:

在 /home/myUser/.login:

.  /etc/login
... and some user specific variables later.
echo .login done.

在 /etc/login 中,一些常见的变量设置如:

export JBOSS_HOME=/home/ec2-user/sw/wildfly-8.2.0.Final
echo /etc/login done.

None 显示两个回声。 但是

.  /home/myUser/.login  

有效。

drwx--x--x 6 myUser myUser 4096 1 月 15 18:42 myUser

因为在 useradd -m ... 中 -m 被忽略了, 和 useradd -p hallo ... 不散列密码(但 passwd --stdin 散列), 我在想是不是我犯了错误...

欢迎来到 SO!

bash shell 在交互式登录会话期间从多个文件中读取。 .login 不是其中之一。

来自 bash 手册页的 INVOCATION 部分

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The
--noprofile option may be used when the shell is started to inhibit this behavior.

希望这能回答您的问题。

来自 man bash(RHEL 6 和 RHEL 7):

  ~/.bash_profile
          The personal initialization file, executed for login shells
   ~/.bashrc
          The individual per-interactive-shell startup file