5

I know I can give permission to use "mount/unmount" through sudo some users without password.

But how can I give permission to use "mount/unmount" only for /dev/sda2 and not for /dev/sda10?

For example, some user can execute: sudo mount -t ntfs /dev/sda2 ~/mnt/ntfs
But the same user must not have permission to execute: sudo mount /dev/sda10 ~/mnt/s10

Braiam
  • 69,112
Dimetry
  • 247

2 Answers2

10

you could create a simple file:

 sudo visudo -f /etc/sudoers.d/myOverrides 

with this directive:

 User ALL = NOPASSWD:/sbin/mount -t ntfs /dev/sda2 /home/User/mnt/ntfs

This allow User to runs mount command with those parameter without entering a password.

Here is sudo manual for more details.

Lety
  • 6,089
  • 2
  • 32
  • 38
0

You can specify arguments in the sudoers file, something like this should work:

user ALL=(ALL) /sbin/mount -t ntfs /dev/sda2 /home/user/mnt/ntfs, /sbin/umount /dev/sda2
fkraiem
  • 12,813