[sudo-users] sudo with shell aliases ?
bob at proulx.com
Fri May 26 12:40:22 EDT 2006
DiZEM PGC wrote:
> I'm new to linux and try to use sudo with a shell-alias instead of
> command as parameter. Might it be unsecure ?
Normally shell aliases are only defined for the user's command line
shell. They are not available elsewhere. So this is not really a
question of security but a question of availability. Normally they
would not be available.
> But first the way i intend to do this:
> -define an shell alias with:
> alias shut 'shutdown'
> -make it 'global':
> export shut
> -then in sudoers file:
> Cmnd_Alias SD = shut
> user host=SD
Unfortunately what you are trying to do will not work. The export is
not doing what you think it is doing.
In the shell aliases and variables live in different namespaces. You
can define an alias "shut" and you can have a variable "shut" and they
are different things. You have defined an alias "shut" in your
example. But you have exported the variable "shut". This is not
causing the alias to be global.
There is no practical way to make a global alias as a shell alias.
Instead make a shell script of that name and install the shell script
into your system. In this case if you were to install a shell script
in /usr/local/bin/shut with these contents then it would do what you
Don't forget to make it executable.
chmod a+x /usr/local/bin/shut
> P.S.: Sorry for my english, I'd prefer to write in german language, but
> the email-archive seems to be completely english-written.
Yes this is an english language mailing list. There may also be other
mailing lists for sudo in german but I do not know about them.
No need for apologies. Your english is much better than my german!
More information about the sudo-users