use*_*ser 2 bash alias .profile
我正在尝试在我的个人资料中添加启动词,但是我收到了 "hstart: command not found"
sudo vi ~/.profile
alias hstart="$HOME/.linuxbrew/Cellar/hadoop/2.7.3/libexec/sbin/start-dfs.sh;$HOME/.linuxbrew/Cellar/hadoop/2.7.3/libexec/sbin/start-yarn.sh"
alias hstop="$HOME/.linuxbrew/Cellar/hadoop/2.7.3/libexec/sbin/stop-yarn.sh;$HOME/.linuxbrew/Cellar/hadoop/2.7.3/libexec/sbin/stop-dfs.sh"
Run Code Online (Sandbox Code Playgroud)
.sh
文件位置:
./.linuxbrew/Cellar/hadoop/2.7.3/libexec/sbin
find -iname "start-dfs.sh"
./.linuxbrew/Cellar/hadoop/2.7.3/libexec/sbin/start-dfs.sh
./.linuxbrew/Cellar/hadoop/2.7.3/sbin/start-dfs.sh
Run Code Online (Sandbox Code Playgroud)
积分:
通过这样做sudo vi ~/.profile
,您已将.profile
ie打开并编辑"$HOME"/.profile
为root
,这是因为 shell~
首先进行波浪号 ( ) 扩展,因此sudo vi
获取文件的完整路径。内部$HOME
扩展将取决于调用用户。
~/.profile
是只读的登录shell(给定~/.bash_profile
和~/.bash_login
不存在),不为任何交互的shell,~/.bashrc
是阅读任何交互shell会话
因此,您需要将alias
定义放在您的~/.profile
(只是 do vi ~/.profile
, drop sudo
)中,并在当前会话source
中~/.profile
通过source ~/.profile
. IMO,您最好将定义放在~/.bashrc
.
~/.bashrc
Ubuntu的默认设置有:
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
Run Code Online (Sandbox Code Playgroud)
所以你也可以把alias
定义放进去~/.bash_aliases
,只是为了让它们分开并且易于维护。