Command 'su -' works but 'sudo' gives error
Hi,
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:
Quote:
What should I do? |
perhaps try
Code:
sudo shutdown -h now |
Have you configured or enabled sudo on Slackware?
http://linuxg.net/how-to-install-and...-slackware-14/ Have you tried using the full path? http://www.linuxquestions.org/questi...-found-792446/ |
/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 ;) ) |
If I recall correctly, Slackware does not automatically configure the sudoers file. It does not share Ubuntu's sudo fetish.
To implement sudo, you will need to edit the sudoers file using the visudo command. |
I didn't know that sudo needs to be installed. But I followed the link and did what was asked. Finally got this message.
Quote:
Quote:
Quote:
Quote:
|
Have you edited the sudoers file (usually /etc/sudoers). You need to add a line like this:
Before: Code:
# User privilege specification Code:
# User privilege specification jdk |
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. |
Quote:
ciao, jdk |
Do you have sudo installed?
If not, you can probably do that by logging into root and installing sudo with your preferred package manager. P.S. You can also try removing and purging and then reinstalling sudo to check if it works this time. |
Sudo is installed
Code:
myuser@localhost:~$ sudo Code:
myuser@localhost:~$ sudo /sbin/poweroff |
Did you edit the sudoers file as I suggested in post #8?
jdk |
Quote:
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.:D But I have added the below line already in /etc/sudoers Code:
myuser localhost=/sbin/halt;/sbin/poweroff;/sbin/shutdown Code:
'myuser' is not allowed to execute the execute '/sbin/poweroff' as root on local host |
I made changes in sudoers and this is what I did
Code:
myuser ALL=(ALL) /sbin/halt,/sbin/poweroff,/sbin/shutdown 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? |
Finally figured it out.
Here are the steps in a bottleneck to help a fellow in need. 1) Edit /etc/sudoers with visudo and add this line. Code:
<your-user> ALL=(ALL) <commands-you-want(with path) or ALL(for all commands)> 3) Once installed, open /etc/profile, look for PATH and add ':/sbin' at the end before double quotes or other path if the command is in another folder and save. 4) Logout 5) Login back with the user and try 'sudo <your-command>. It should work now. :D |
Quote:
You can export the path as Code:
export PATH=/sbin:$PATH $PATH has the existing paths you need to retain in the new path. Hope this is Helpful. CheeerrZZZZ |
I tried export but the path it had added was removed when I restarted the system. However, editing directly in the file worked.
This problem has been solved. Thanks for the input though. Much Appreciated. :D |
Quote:
sudo su - and give myuser password again! |
Quote:
|
Quote:
Quote:
|
All times are GMT -5. The time now is 07:15 AM. |