Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
What I'm trying to do is to grant my regular user to locally mount partitions and shutdown the machine without a password. Here is what I've done to /etc/sudoers:
Code:
Host_Alias LOCAL = localhost
Cmnd_Alias SHUTDOWN = /sbin/shutdown
Cmnd_Alias MOUNT = /bin/mount, /bin/umount
<my_username> LOCAL=(root) NOPASSWD: SHUTDOWN, MOUNT
%wheel ALL=(ALL) ALL
My user is a member of wheel group and I want to type the password for each sudo command except for shutdown and mount.
However I am asked for a password whenever I execute "sudo mount [...]" or "sudo shutdown [...]".
Am I missing something?
Does gentoo use PolicyKit. You can add a policy allowing GUI users to have removable media mounted.
Look at "polkit-auth". If it lists policies, is "org.freedesktop.hal.storage.mount-removable" listed?
Well, there are some entries under /etc/polkit-1/ and /var/lib/polkit-1/ so I suppose it does. However this should only resolve the mount issue, not the shutdown.
And I'm not actually a GUI user. The default login is in terminal from which I invoke blackbox WM (through startx). I don't have either KDE or Gnome or any other WM/DE installed. That's why I'm trying to make these two commands work without password (just to avoid typing it so frequently). And of course to understand further how sudo works.
Is it possible that wheel group rule "overwrites" somehow the NOPASSWD rule for the user?
Last edited by segmentation_fault; 05-28-2011 at 09:09 PM.
Looks like it is solved. First of all, instead of "localhost", I put the hostname of the machine.
Secondly, I put the user rule after the group rule
Code:
%wheel ALL=(ALL) ALL
<my_username> <hostname> = (root) NOPASSWD: MOUNT, SHUTDOWN
and it seems that did the trick. Now I can mount/unmount and shutdown without a password and for any other sudo operation I am asked for a password.
Thanks for the replies.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.