How give a user permission to run a specfic command as root Ubuntu

Sometimes it can be really useful to give a user privileges to run a specific command as root. For example – if you wanted to allow a user to restart a specific service or run a specific program as root without given them access to the whole server. You can configure this using visudo command as root. Note: you really must be root when you do this and not a sudo.

 sudo su -

Then..

visudo

You can then modify the configuration file. There are specific sections in the config file which are show below. For example – I want to give a user called debug permission to run supervisorctl as root.

....

# User alias specification
debug ALL=(ALL) NOPASSWD:/usr/bin/supervisorctl

Hope this is helpful.

Leave a Reply