last day (14 days later) » 

1:47 AM
2
A: How can I run reboot as a normal user without needing to enter a password?

terdonFirst of all, do not, I repeat NOT, attempt to make your user have root privileges at all times, that is the mother of all security risks and is not only unnecessary but asking for trouble. Anyway, if you want your user to be able to run a specific command, you need to add this line to sudoers (...

 
appreciate your answer but I added the terdon ALL=NOPASSWD:/sbin/reboot line to /etc/sudoers and rebooted the system. But if I sudo reboot, it still asks for password.
 
@Level1Coder you did you use actual username and not mine right?
 
correct, I replaced terdon with my own username
 
@Level1Coder yes, it doesn't seem to work for reboot, sorry. I edited and changed to shutdown -r instead (which does the same thing). It works fine like that on my Debian.
@Level1Coder scratch that, it works fine with reboot, I just checked. I'm guessing that you had saved the file but not exited visudo when you ran the command. Anyway, using shutdown -r is better since it is likelier to work on older machines.
 
I'm about to give up, I wanted this downvoted question to have a real answer. I added this to sudoers: terdon ALL = NOPASSWD: /sbin/reboot, /sbin/shutdown but sudo shutdown -r now still asks for password.
 
1:47 AM
@Level1Coder I assume you're using sudoers right?
 
using visudo
 
yes, sorry, that's what I meant
and did you exit it before trying the command?
by the way, try this one instead:
shutdown -r 10
That tells it to reboot in 10 minutes so if it works you can cancel it without actually rebooting :)
 
no, still asks for password
 
Anyway, when I tried it with reboot, it didn't work until I saved the file opened by visudo, and closed the editor window that appeared. While visudo is running you are editing a temporary file, not the actual /etc/sudoers so the changes don't take effect until you exit visudo
@Level1Coder really? Strange, what distro are you running?
 
Crunchbang (Debian 7)
when I run visudo, the file it edits is /etc/sudoers.tmp
 
1:52 AM
@Level1Coder Then we should have the exact same behavior, I'm on LMDE which is Debian testing
@Level1Coder exactly, and when you exit it, the file is copied to /etc/sudoers
Can you try with another command?
 
yep, it asks to save if there is a change
when I ^X from visudo
 
But do you exit visudo?
you are returned to your terminal prompt?
 
yes
 
maybe there's a syntax issue
 
but you said yours works, are you 100% sure?
so I'm baffled why it doesn't work on my system
 
1:55 AM
Yes, I wasn't quick enough to cancel it on one of my tests and it restarted my machine
Try another command:
terdon ALL=NOPASSWD:/bin/ls
 
ok, pls wait
 
put that on a separate line, exactly as is
well, changing your username obviously
 
hmm.. when I ^X from visudo it asks:
Filen Name to Write: /etc/sudoers.tmp
File
do I write to this file?
or remove .tmp?
pls see if your visudo has same behavior
when you make change and ^X and asks to save
 
Hang on cause I don't use vi, I've set it to use emacs
Tell you what, do whatever it tells you and then check /etc/sudoers and see if the changes are there
 
right
 
2:00 AM
that way you'll know whether you should have saved to it directly or not
 
yes
made change in visudo, ^X, save to sudoers.tmp file
rechecked by sudo nano /etc/sudoers
changes are confirmed
 
OK, and your nano session is finished right? You only have one terminal open, the one that started the visudo and you will now run sudo ls in it correct?
Just trying to minimize confounding factors here
 
yes
I usually do one thing at a time
to avoid confusion
right now I rebooted the system
 
That shouldn't be needed
 
with the line: terdon ALL=NOPASSWD:/bin/ls
 
2:04 AM
Please show me the actual line, just for my peace of mind
Just post the output of
sudo grep -w ls /etc/sudoers
 
myusername ALL=NOPASSWD:/bin/ls
it asks for password again when running that sudo grep command
 
OK, no offense but you'd be surprised at how many times I've run into people who refused to understand that they should use their username not mine.
Running the grep command it should, does it ask for one if you run
sudo ls
?
 
sudo ls = still asks for password
 
OK, that is very strange.
I'm doing the same things you are here and they work as expected. I've even tried this with a different user and it works.
Is this your own system or does someone else manage it?
 
my own
 
2:09 AM
Running out of ideas.
 
are you using a base debian and installed your own desktop yourself?
maybe this problem is specific to crunchbang/openbox/slim
 
WHy don't you edit your question, post the contents of your /etc/sudoers (don't worry, there's nothing sensitive there apart from usernames if you want to be paranoid), explain that it doesn't work and we'll get it reopened
@Level1Coder crunchbang maybe I guess it might have some extra SELinux stuff going on. Nothing to do with the desktop environments though
 
ok, I'll post it
 
Don't post a new one, edit your old one.
As soon as you edit, it will go into the reopen queue and it should be opened promptly
 
thanks for taking the time helping me out
yes, I'll edit the old one
 
2:16 AM
@Level1Coder you're very welcome
Sorry I couldn't actually solve it. @strugee I see you watching, any ideas?
 
I highly doubt this will help but try adding Defaults insults to your /etc/sudoers.
then execute a command with sudo and intentionally get your password wrong
see if it insults you
if it doesn't /etc/sudoers isn't being respected
and I would investigate whether sudo is using a different configuration backend
(yes, it can have multiple. /etc/sudoers is just the default.)
 
@strugee but /etc/sudoers is being modified by visudo which would indicate that the sudo system is pointing to the default
Good point about insults though, at least that will rule out the more extreme scenarios.
 
@terdon one would think but I wouldn't be surprised if visudo was hardcoded for /etc/sudoers
 
@strugee nah:
     -f sudoers, --file=sudoers
                 Specify an alternate sudoers file location.  With this
                 option, visudo will edit (or check) the sudoers file of your
                 choice, instead of the default, /etc/sudoers.  The lock file
                 used is the specified sudoers file with “.tmp” appended to
                 it.  In check-only mode only, the argument to -f may be ‘-’,
                 indicating that sudoers will be read from the standard input.
how do you get sudo to use a different configuration backend? You mean that it is independent of sudoers?
 
@terdon yes. I believe one common one is LDAP but I don't know a lot about it
they don't have to be the same format as /etc/sudoers so that manpage section doesn't really mean anything
 
2:28 AM
@strugee OK, so in those cases, visudo is useless and sudo is controlled in a completely different way?
 
@terdon yes
I believe so. I recall reading documentation on it but I've never had a reason to actually try it out.
 
@Level1Coder what's your sudo version?
sudo -V
scratch that @Level1Coder, I was relaying Gille's suggestions and he meant to ask for sudo -l, that makes much more sense:
     -l, --list  If no command is specified, list the allowed (and forbidden) commands for the invoking
                 user (or the user specified by the -U option) on the current host.  A longer list for‐
                 mat is used if this option is specified multiple times and the security policy sup‐
                 ports a verbose output format.
So, runing this should list the commands you are allowed to run
 
 
1 hour later…
3:41 AM
sudo -l shows:
Matching Defaults entries for myusername on this host:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User myusername may run the following commands on this host:
(root) NOPASSWD: /bin/ls
(ALL : ALL) ALL
 

last day (14 days later) »