Is there anyway to grant the mount
command permission to a user? I seems impossible and the user must be a sudoer. However I want to know is it possible to create a group which has admin permission (only for mount
) and then add the user to this group?
2 Answers
I guess this first link is not strange for you :
http://www.cyberciti.biz/faq/ubuntu-add-user-to-group/
There is then this link for users added to groups with help of acl :
With acl you can adjust partitions too.
Install acl first - if not done already:
sudo apt-get install acl
Assumed your linux-partition for root(sudo) is at sda2 - so then you need to edit /etc/fstab for device resp. partition sda2 and this looks there like before editing :
/dev/sda2 / auto defaults,nobootwait 0 2
after editing :
/dev/sda2 / auto defaults,nobootwait,acl 0 2
Now re-mount this partition with :
sudo mount -o remount /
When you changed /etc/fstab - you normally need to reboot :
sudo reboot
Now you can add a group, and within this group you add some users - e.g. group for developers with :
sudo addgroup developer
sudo adduser lewinsky developer
(lewinsky as example for member of group for developers - you have to repeat latter command for each user of group for developers)
Now you need to set acl for the folder ( you as user resp. boss for the group and the developers ) :
Set ACL for the folder:
sudo setfacl -d -m "u:nobody:rwx,g:developer:rwx,o::r-x" -R /home/you/
(this means.. you don't have any preference for the "user" a new file will be owned by -- defaults to the actual user creating the file, but the user's permissions given - rwx will be applied; group will be forced to "developer" with all permissions for the group; other users will just have read & execute permissions).
In case you already have contents in the folder, you could use this to change existing file's permissions to make it sharable within the group:
sudo chgrp developer -R /home/you
sudo chmod g+rwsx -R /home/you
Now here comes this missing answer for a certain user allowed to use commands like mount:
sudo adduser lewinsky admin
This would mean too, that lewinsky is the boss within the group developer and may use else commands except mount.
If you want lewinsky only to be allowed to use the single command mount - it would look like this :
sudo -u username command
also
sudo -u lewinsky mount
You can edit sudo config. Just type sudo visudo
in Terminal, and you are in it. read man visudo
and edit config.
If, however, you only want to give access to particular disk, edit the /etc/fstab
. Add users
option to mount options listed there. After that use chmod 755 /mnt/disk1
on its mount point.
-
I tried visudo but see no change. I wrote
mahmood ALL=(mahmood) NOPASSWD:/bin/mount,/bin/umount
. Is that correct?– mahmoodJun 26, 2013 at 18:43
udisks
which doesn't require root privileges to mount/unmount volumes.