I want to allow sudo this way:
myuser ALL=NOPASSWD:/usr/bin/pkill -fx "/usr/sbin/nethogs -v 3 -s" || /usr/sbin/nethogs -v 3 -s
so I get only a single running instance of nethogs.
visudo accepts it, but I am unable to run these commands without a password...
Failed attempts:
sudo '/usr/bin/pkill -fx "/usr/sbin/nethogs -v 3 -s" || /usr/sbin/nethogs -v 3 -s'
sudo /usr/bin/pkill -fx "/usr/sbin/nethogs -v 3 -s" || sudo /usr/sbin/nethogs -v 3 -s
PS.: this version of nethogs is compiled from its cvs on sf.net
NOPASSWD:
entry has to come after any entry that would match but require a password. See How to run a specific program as root without a password prompt? – Gilles 'SO- stop being evil' Jun 16 '14 at 23:31