Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm running unbuntu 12.04. I want a script to be able to run "ip link blah blah...".

sudo ./myscript.sh

works as intended, but

./myscript.sh

gets me : RTNETLINK answers: Operation not permitted

I have these lines in my sodoers file:

myusername ALL = (ALL:ALL) NOPASSWD: ALL
%mygroup ALL = (ALL:ALL) NOPASSWD:/sbin/ip, /bin/ip

There are no lines following this except a timeout for the timestamp, and the default reference to /etc/sudoers.d

/etc/sudoers.d is empty except for the default README file.

NOPASSWD does not seem to be working either. I have tried moving the lines around so that the timeout and sudoers.d lines are before the ones I mostly care about, with no effect.

What have I missed?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

The /etc/sudoers file only applies to sudo. That means that if you do not run programs with sudo, it will not get a chance to get elevated privileges. You must use sudo ./myscript.sh or edit the script and change something like:

ip link ...

to:

sudo ip link ...
share|improve this answer
    
Duh, of course. I knew it would be something simple... Thanks! –  mickeyf Jan 21 '13 at 16:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.