I have to write a script that would allow non root user to display LVM info. I have allowed that user in sudoer file but still not able to run that command returning with following error.

  WARNING: Running as a non-root user. Functionality may be unavailable. /run/lock/lvm/P_global:aux: open failed: Permission denied   Unable to obtain global lock.

If I run this command from using sudo

Sorry, user farooq is not allowed to execute '/sbin/pvdisplay' as root on localhost.

Can anyone help me.

  • 2
    Edit /etc/sudoers file. – Ipor Sircer Sep 20 '16 at 16:50
  • Please share you /etc/sudoers file – linuxdev2013 Oct 4 '16 at 17:44

In order to allow a user run a certain script as root you have to edit /etc/sudoers or /etc/sudoers.d/<alt_sudoers_file>.

You are encouraged to do it using the command visudo. If editing alternative sudoers file user visudo -f <alt_sudoers_file>.

An example that can work for you would be:

%sudo   ALL=(ALL:ALL) ALL

This actually says the following: Any user of group sudo, on ANY host can run ANY command as root if the command is prefixed with sudo.

For full documentation run man sudoers

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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