You can just set up an alias in .bashrc or whatever file is used for aliases.  
That's what I do for folks here.  I have a group set up for people needing to 
use a command.  I edit the sudoers file once to set things up.  It looks like
          %hradmin  ALL=/usr/local/bin/hradmin.sh

I make the hradmin group a secondary group for the user.  For example, for the 
user account greg
        usermod -a -G hradmin  greg

Then Gregg has in his .bashrc
        alias hradmin='sudo /usr/local/bin/hradmin.sh'

Names have been changed to protect the innocent.


Cathy
-- 
Cathy L. Smith
IT Engineer

Pacific Northwest National Laboratory
Operated by Battelle for the 
U.S. Department of Energy

Phone: 509.375.2687
Fax:       509.375.4399
Email: [email protected]

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Rich 
Shepard
Sent: Wednesday, February 27, 2019 2:51 PM
To: Portland Linux/Unix Group <[email protected]>
Subject: Re: [PLUG] Allow user to shutdown host

On Wed, 27 Feb 2019, Paul Heinlein wrote:

> My experience is that sudo expects the command line invocation to look 
> like the sudo configuration. So what I'd do is add a function, not an 
> alias, to .bashrc:
>
> function halt {
>  /sbin/shutdown -h now
> }
>
> But since "halt" is the name of an actual executable, maybe train her 
> to use something like "haltnow" and tweak the name of the function:
>
> function haltnow {
>  /sbin/shutdown -h now
> }

Paul,

Your experiences easily top my web search. :-) I read that if the sudo alias 
has a space before the closing quote bash will pass the following command to 
sudo.

The issue today seems to be that she typed sudo /bin/halt rather than sudo 
/sbin/halt

I'll try both your haltnow function and the doit alias and report the results 
... probably over the weekend.

Many thanks,

Rich
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to