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 Answers2

-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