3

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
  • 2
    Edit /etc/sudoers file. Sep 20, 2016 at 16:50
  • 1
    Please share you /etc/sudoers file Oct 4, 2016 at 17:44

2 Answers 2

-1

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

-1
$ lsblk
NAME                    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0                       2:0    1    4K  0 disk
1
  • 1
    At first glance, this looks like gibberish.  Upon closer look, I see that it appears to be a Unix command, but with no indication of what it means or how it relates to the question.  Please explain it, or it is likely to be deleted. … … … … … … … … … … … … … … … … … … … … … Please do not respond in comments; edit your answer to make it clearer and more complete. Jun 28, 2020 at 19:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .