You are not logged in.

#1 2013-05-23 18:17:51

ball
Member
From: Germany
Registered: 2011-12-23
Posts: 164

[SOLVED] [sudo] allow user to run commands as root

Hello,

I want to run programs like netctl and vpnc as normal user without typing in my password. This is what I've come up with for /etc/sudoers:

myusername ALL = (root) NOPASSWD: /usr/bin/netctl, /usr/bin/vpnc, /usr/bin/vpnc-disconnect

But running e.g. "netctl start someprofile" fails because access to the file `someprofile' is denied -- the file is owned by root and only root may read it.

Doesn't running programs as root also mean that these programs can read files owned by root? Or is this a misconception and I should change permissions to the corresponding files?

Thanks & Regards

Edit:
I just realized, that, with the setup above, "sudo netctl start someprofile" does work without demanding a password. This is nice. But can it be tuned further so that I don't have to prepend "sudo"?

Last edited by ball (2013-05-23 19:22:17)

Offline

#2 2013-05-23 18:43:32

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,498

Re: [SOLVED] [sudo] allow user to run commands as root

What about;

myusername ALL=(ALL) ALL
myusername ALL=NOPASSWD: /usr/bin/netctl, /usr/bin/vpnc, /usr/bin/vpnc-disconnect

Offline

#3 2013-05-23 18:49:44

ball
Member
From: Germany
Registered: 2011-12-23
Posts: 164

Re: [SOLVED] [sudo] allow user to run commands as root

@qinohe:
I am in group wheel and I already have

%wheel ALL=(ALL) ALL
myusername ALL=NOPASSWD: /usr/bin/netctl, /usr/bin/vpnc, /usr/bin/vpnc-disconnect

So this would be same, wouldn't it?

I just realized, that "sudo netctl start someprofile" does work without demanding a password. This is nice. But can it be tuned further so that I don't have to prepend "sudo"?

Last edited by ball (2013-05-23 18:50:46)

Offline

#4 2013-05-23 18:59:32

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,498

Re: [SOLVED] [sudo] allow user to run commands as root

Yes , you could create an alias, like this;

alias someprofile='sudo netctl start someprofile'

put that, or something like that in your .zshrc or .bashrc.
Now start it the way you want, terminal, button etc.
Of course the alias is for the terminal!

Last edited by qinohe (2013-05-23 19:02:41)

Offline

#5 2013-05-23 19:21:55

ball
Member
From: Germany
Registered: 2011-12-23
Posts: 164

Re: [SOLVED] [sudo] allow user to run commands as root

Ok, I already presumed that. I just wanted to know if the alias is the canonical way to go from here or if it can also be configured in /etc/sudoers. But after all, making use of /etc/sudoers will implicitly mean using "sudo"...

Thanks for clearing this up. Solved.

Offline

Board footer

Powered by FluxBB