Operating System - HP-UX
1832089 Members
2708 Online
110037 Solutions
New Discussion

sudo command to nfs mount a file system

 
SOLVED
Go to solution
ConnieK
Regular Advisor

sudo command to nfs mount a file system

I have created a Cmnd_Alias statement to nfs mount a file system (for the DBAs to run as needed), but visudo will not allow me to save the sudoers file. This is the Cmnd_Alias statement:
Cmnd_Alias NFS_MOUNT /usr/sbin/mount -F nfs -o rw hpservername:/backups /backups

This command works for me as root as a regular command. Is there something that sudo soes not like in this statement? Maybe the colon? Is the Cmnd_Alias location the correct place for this?

Thanks in advance!

Connie

Independent by nature
3 REPLIES 3
Patrick Wallek
Honored Contributor
Solution

Re: sudo command to nfs mount a file system

Your syntax is just a bit off. I think your statement should be:

Cmnd_Alias NFS_MOUNT=/usr/sbin/mount -F nfs -o rw hpservername:/backups /backups

The other thing I can think of that would make this slightly easier to create a small script containing the mount command:

# cat /usr/local/bin/dba-nfs-mount
/usr/sbin/mount -F nfs -o rw hpservername:/backups /backups

Set the permissions on the script to 500 (r-w------) and make root the owner.

Then you can just add:

CMND_ALIAS NFS_MOUNT=/usr/local/bin/dba-nfs-mount

to sudo.

Now your dba's just have to run:

$ sudo /usr/local/bin/dba-nfs-mount

rather than typing out the long mount string.
ConnieK
Regular Advisor

Re: sudo command to nfs mount a file system

Patrick - That sounds good. I'll try it! Thanks so much!
Independent by nature
ConnieK
Regular Advisor

Re: sudo command to nfs mount a file system

It works.
Independent by nature