[SOLVED] Command 'su -' works but 'sudo' gives error
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.
I have set root password and I login to root with 'su -' and that password and it is successful. This i am doing from a user account that I am using for myself.
Now I am trying to simply type 'sudo' followed by the command and it asks for password. Entering root password shows
Quote:
'Sorry, try again'
. Instead of entering root password, if I enter the user account password, it says
Quote:
sudo: poweroff: command not found
I am trying to give a user, permission to execute poweroff command which is here: /sbin/poweroff
/sbin is typically not in the normal users' PATH. You can use the full path to it if you want, or you can add /sbin to the PATH, or you can use shutdown -h.
Show the sudoers file, but, as above, its always a good idea to specify the complete cmd path for privileged cmds.
BTW, with sudo cmd, its always the user's passwd, not root's (& vice versa for su obviously )
No point in putting root in sudoers file; he/she already has total power
sudo entry should be comma-with-space separated see http://www.sudo.ws/sudo/sudoers.man.html.
Never use the keyword ALL if you can avoid it; always be specific.
No point in putting root in sudoers file; he/she already has total power
sudo entry should be comma-with-space separated see http://www.sudo.ws/sudo/sudoers.man.html.
Never use the keyword ALL if you can avoid it; always be specific.
I didn't; Debian did. I haven't ever touched the sudoers file except to add my own userid. I don't do anything with root. Just use it as it comes out of the box.
ciao,
jdk
Did you edit the sudoers file as I suggested in post #8?
jdk
Nope, I did not. I don't want to give complete permission to the user. Then there is no point in giving permission at all. I can just 'su -' and get my work done.
I am hoping for something more accurate like 'poweroff' and 'shutdown'. Ofcourse I can 'su -' and do the same but I am trying to do it differently.
But I have added the below line already in /etc/sudoers
I then executed 'sudo poweroff' and got 'Command not found'. I then executed 'sudo /sbin/poweroff' and it worked.
Now the only thing that is left is to remove /sbin, as in to use 'sudo poweroff'. I think adding path /sbin to $PATH should work. Right? If so, how and where do I add path?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.