We can face the situation with restricted rights on a server. This is a use case for sudo. You can get restricted access to specific commands as root, but not to the whole system, which is very good!

I need access to virt-top to monitor kvm based virtual machines on a big host system. Add the following line to sudoers file:

myusername ALL= NOPASSWD: /usr/bin/virt-top

This line allows myusername to run virt-top without password from any terminal.

A couple of useful links:

  • http://www.komar.org/pres/sudo/toc.html
  • http://www.sudo.ws/sudo/sample.sudoers
  • http://www.garron.me/en/linux/visudo-command-sudoers-file-sudo-default-editor.html