# Regular user access to stop/start net.eth0? [SOLVED]

## audiodef

How do I give my regular user access to control my nic? I want to write a script to stop net.eth0, run a program, and start net.eth0 when the program is finished, without having to sudo.

----------

## boerKrelis

Why not set sudo up to let the user do just that, without a password?

----------

## audiodef

How do I do that?

----------

## boerKrelis

Have a look at the sudo documentation. I think you could do something like this (in /etc/sudoers. you edit it by running 'visudo':

someuser        ALL=(someotheruser)    NOPASSWD: /path/to/somecommand -arg1 -arg2

resulting in 'someuser' being able to run:

'sudo -u someotheruser /path/to/somecommand -arg1 -arg2 --maybe-some-other-arg'

without being prompted for a password.

So in your case this would be like

you      ALL=(root)      NOPASSWD:/etc/init.d/net.ethX

Sudo is way more powerful than most people think.

----------

## audiodef

Last night, I realised - duh! Visudo!   :Razz:  Thanks for confirming that.

----------

## audiodef

Not sure what I'm missing. I've used visudo to make it possible to reboot and shutdown from the Fluxbox menu (not related to the topic, but just to say I've done this before). I added this line:

audiodef ALL = (root) NOPASSWD:/etc/init.d/net.eth0

and as my regular user I still get a warning about needing to be root.

----------

## boerKrelis

When do you get this warning? How are you invoking /etc/init.d/net.eth0 (what do you type on the commandline) ?

----------

## audiodef

The usual. I tried, as my regular user, /etc/init.d/net.eth0 stop.

----------

## phajdan.jr

 *audiodef wrote:*   

> The usual. I tried, as my regular user, /etc/init.d/net.eth0 stop.

 

Did you mean "sudo /etc/init.d/net.eth0 stop"?

----------

## audiodef

 *phajdan.jr wrote:*   

>  *audiodef wrote:*   The usual. I tried, as my regular user, /etc/init.d/net.eth0 stop. 
> 
> Did you mean "sudo /etc/init.d/net.eth0 stop"?

 

Whoops.   :Embarassed:  Now it works fine. Please brain my excuse damage!

Thanks, boerKrelis and phajdan.jr.

----------

