[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.
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)>
2) Type sudo to check if it is installed. If not, then install it.(http://linuxg.net/how-to-install-and...-slackware-14/)
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.
Last edited by info.latawaz; 06-22-2013 at 02:20 AM.
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?
Hi,
You can export the path as
Code:
export PATH=/sbin:$PATH
/sbin is the new path you would like to add while
$PATH has the existing paths you need to retain in the new path.
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.
Environment variable settings are unique to that terminal and its child processes. If you want a change to the environment variable to be applied to all future terminals then you need to add it to your .bashrc or .bash_profile file.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.