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,您已将.profileie打开并编辑"$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.
~/.bashrcUbuntu的默认设置有:
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
Run Code Online (Sandbox Code Playgroud)
所以你也可以把alias定义放进去~/.bash_aliases,只是为了让它们分开并且易于维护。
| 归档时间: |
|
| 查看次数: |
113 次 |
| 最近记录: |