Suppose I wanted to add a group of users who are allowed to run mount
and umount
without passwords.
So I first want to add a group called "anyname"
sudo groupadd anyname
Next we need to edit the /etc/group
and add the users
anyname:x:407:
will be present ,hence append users you want to add the users seperated by commas.
anyname:x:407:user1,user2,...
Now we need to configure sudo to allow members of the "anyname" group to actually invoke the mount
and umount
commands.
You just need to add the following lines to /etc/sudoers
%anyname ALL=NOPASSWD: /sbin/mount, /sbin/umount
Now sudo mount
wont ask password but since it is a pain in the butt typing sudo all the time, we can avoid it by dong the following:
I can create the following script called "/usr/bin/mount" (and similar script for umount)
#! /bin/sh
sudo /sbin/mount $*
To make this slightly more secure, We might want to change the ownership of these scripts to the "anyname" group.
chgrp anyname /usr/bin/mount /usr/bin/umount
and then make them executable only for the group "anyname"
chmod g+x /usr/bin/mount /usr/bin/umount
EDIT:Depending on the OS you are using please check where mount and umount commands are located. It might be in /bin/ instead of /sbin.So you might have to make necessary changes
IMPORTANT: BTW don't run the script on Arch based systems where all of the bin folders are symlinked with each other.
What is your OS? Are you trying to mount a NTFS partition, EXT partition, or optical drive? – nate – 2013-08-26T13:35:02.470