[SOLVED] Sudo command occasionally asks for root password
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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Sorry about the confusion crosstalk. Here is the full contents of sudoers.
# This file MUST be edited with the 'visudo' command as root.
# See the man page for details on how to write a sudoers file.
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL) ALL
user ALL=(ALL) NOPASSWD:ALL
# Allow members of group sudo to execute any command after they have
# provided their password
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
The canonical (no ubuntu pun intended) and reasonably safe
way to go about this would be to a) put your user into the
admin group (if he isn't already) and b) make an entry in
sudoers (via visudo) to allow the use of certain (HARMLESS!!)
commands w/o a password ... e.g.:
%admin ALL=(ALL) ALL NOPASSWD: /sbin/ifconfig
HARMLESS above is, of course, relative. With ifconfig you
can disconnect the machine from the net, with cat you can
clobber the machine ...
If you'd like to leave a more 'lasting' reminder then on the posts you wish to think people either click the "Yes" to say you found the post helpful, or click the scales by the username and you can also a leave a comment
Hmm the only problem with that is any administrative command can be executed without a password. You should have the following in your sudoers for specifically the command you're using. For instance I run scripts which execute poweroff, reboot, and setpci so I added this line at the end of my sudoers file.
There can be more than one line with %admin ALL (or any group or user) in the sudoers file. Also my user has to run the commands with the exact path specified in the sudoers file such as "sudo /sbin/poweroff".
If you don't like editing the sudoers file and just want to emulate the root password entry then run the following with your script...
sudo -S echo Getting root privilages... << EOF
#now you can run consecutive sudo commands without password challenge
sudo -S COMMAND << EOF
View the sudo man page for more information on the -S switch.