CentOS 5 "sudo" does not work as I want it to
Hi everyone!
I am new to Linux/CentOS and kind of learning by doing. I searched the man pages and the How Tos and only found a partial solution to my problem: I'm running a minimalized CentOS 5 on a VPS. My problem: I created a user. Let's call him user1. User1 is member of the group wheel. I changed the sudoers file, so that members of the group wheel can execute all the root commands without password. Code:
%wheel ALL=(ALL) NOPASSWD: ALL But this is what happens: Code:
[user1@rs ~]$ sudo service sshd restart Code:
[user1@rs ~]$ su Code:
[root@rs user1]# Code:
[root@rs user1]# service sshd restart Code:
sudo su - I'd like to understand what I'm doing wrong and learn how to give user1 the right to execute root commands through sudo or su. I used the search option with the term "sudo" and then "problems with sudo" and still had 1.000.000 results. I am also looking for the answer for hours now, so please forgive me if this question already exists and maybe link me to the right thread. Thank you in advance, cheers |
I'm not on my CentOS box right now, so I can't give you an exact answer (sorry) but I suspect the problem is the $PATH variable. If you type $PATH as user1 and compare it to the result of $PATH after becoming root suing su - you will probably see that /sbin is not part of user1's path.
You can verify whether this is the problem by typing sudo /sbin/service... instead of sudo service... If my guess is correct then all you need to figure out is how to set $PATH for user1 to include /sbin. Sorry I don't have the answer at my fingertips but I am on a different computer at the moment. :) |
You're my hero snowpine :D !
Thanks for the quick answer, that confirms what I just read going through another sudo guide. I'll try to find out how to set $PATH for user1 to include /sbin, but will still be very greatful if you happen to get on your CentOS box, if you could post the solution here. Thank you so much! |
O.k.:
To add a directory to a single user's PATH, I need to change the .bash_profile in this user's home/user/ directory: the lines that need to be in the .bash_profile to set an environment variable look like this: Code:
PATH=$PATH:$HOME/bin I figured it out :cool: ! This is the solution to my problem: Code:
PATH=$PATH:$HOME/bin cheers |
Yay! Glad it worked. :)
|
All times are GMT -5. The time now is 09:05 AM. |