/etc/profile.d 脚本显然不会在登录时执行

/etc/profile.d 脚本显然不会在登录时执行

有用/etc/profile.d吗?

rexster-console.sh我在以下位置创建一个文件/etc/profile.d

alias rexster="/var/rexster-console-2.4.0/bin/rexster-console.sh"

-rwxr-xr-x   1 root root    66 Feb 15 13:05 rexster-console.sh

我甚至跑步sh rexster-console.sh

我打开另一个终端:

root@ubuntu:/etc/profile.d# rexster
rexster: command not found

那么,我遗漏了什么?

答案1

你缺少什么?

目录中的文件/etc/profile.d是在启动时获取的,而不是在应用程序启动时获取的(就你的情况而言另一个终端) 启动。因此,系统重启后您的别名可能就会起作用。

但是,创建别名的正确方法是:

  • 如果你想创建系统范围的别名,这些应该放在/etc/bashrc文件中
  • 如果您想创建个人别名,这些别名应该放入您的~/.bashrc文件中,或者最好放入~/bash_aliases文件中。

相关内容