I am running Ubuntu 10.04 and I use upstart
for daemon management. My enterprise application is run as a daemon and must be run as root because of various privileges. E.g.:
sudo start my-application-long-ID
sudo stop my-application-long-ID
etc
I would like to introduce an alias
to abbreviate these commands as something like:
alias startapp='sudo start my-application-long-ID'
and run it as startapp
and that works but I would prefer to not have sudo in the alias.
alias startapp='start my-application-long-ID'
does not when run using sudo startapp
, returning sudo: startapp: command not found
.
However, when I added the alias:
alias sudo='sudo '
sudo startapp
now works but I am still curious why sudo ignores aliases.
Best Answer
I see the below information from here.
When using sudo, use alias expansion (otherwise sudo ignores your aliases)
The reason why it doesn't work is explained here.