I am trying to add launch words to my profile, however I am receiving "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"

Location of the .sh files:


find -iname "start-dfs.sh"
  • 1
    Why are you editing ~/.profil? Shouldn't it be ~/.profile? Did you make a typo? You also don't need sudo to edit ~/.profile. – edwinksl Sep 25 '16 at 4:08
  • yes it was a typo. – user Sep 25 '16 at 4:11


  • By doing sudo vi ~/.profile, you have opened and edited your .profile i.e. "$HOME"/.profile as root, this is because shell does tilde (~) expansion first, so sudo vi gets the full path to the file. The inside $HOME expansion would depend on the calling user.

  • ~/.profile is only read for login shell (given ~/.bash_profile and ~/.bash_login does not exist), not for any interactive shell, ~/.bashrc is read for any interactive shell session

So, you need to put the alias definitions in your ~/.profile (just do vi ~/.profile, drop sudo), and to get the definitions in the current session source the ~/.profile file by source ~/.profile. IMO, you would be better off putting the definitions in ~/.bashrc.

The default ~/.bashrc of Ubuntu has:

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases

so you can put the alias definitions in ~/.bash_aliases too, just to keep them separate and easily maintainable.

| improve this answer | |
  • 1
    Or maybe put them in ~/.bash_aliases? – edwinksl Sep 25 '16 at 4:16
  • @edwinksl Good point, added. – heemayl Sep 25 '16 at 4:20
  • 1
    When using sudo, the ~ still expands to the invoking user's home directory. I think this is because the shell expands that before invoking sudo. Try sudo ls -d ~ to test. – Byte Commander Sep 25 '16 at 12:44
  • @ByteCommander I stand corrected, forgot about the tilde expansion. Edited, thanks. – heemayl Sep 25 '16 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.