有用/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
文件中。