LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 01-21-2011, 06:46 PM   #1
McFex
LQ Newbie
 
Registered: Jan 2011
Posts: 8

Rep: Reputation: 0
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
User1 is supposed to gain complete root rights with the su or sudo command now.
But this is what happens:
Code:
[user1@rs ~]$ sudo service sshd restart
sudo: service: command not found
[user1@rs ~]$
Also typing
Code:
[user1@rs ~]$ su
and entering the root password to have root rights
Code:
[root@rs user1]#
leads to the same result:
Code:
[root@rs user1]# service sshd restart
bash: service: command not found
[root@rs user1]#
I found out that by typing
Code:
sudo su -
user1 can become root and then executing the desired commands is no problem, but frankly that is not what I want.
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

Last edited by McFex; 01-21-2011 at 07:52 PM.
 
Old 01-21-2011, 07:00 PM   #2
snowpine
Senior Member
 
Registered: Feb 2009
Posts: 4,037

Rep: Reputation: 1099Reputation: 1099Reputation: 1099Reputation: 1099Reputation: 1099Reputation: 1099Reputation: 1099Reputation: 1099
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.
 
Old 01-21-2011, 07:21 PM   #3
McFex
LQ Newbie
 
Registered: Jan 2011
Posts: 8

Original Poster
Rep: Reputation: 0
You're my hero snowpine !
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!
 
Old 01-21-2011, 07:42 PM   #4
McFex
LQ Newbie
 
Registered: Jan 2011
Posts: 8

Original Poster
Rep: Reputation: 0
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

export PATH
*edit
I figured it out !
This is the solution to my problem:
Code:
PATH=$PATH:$HOME/bin
PATH=$PATH:/sbin

export PATH
Thank you snowpine for pushing me in the right direction

cheers

Last edited by McFex; 01-22-2011 at 12:35 PM.
 
Old 01-21-2011, 07:52 PM   #5
snowpine
Senior Member
 
Registered: Feb 2009
Posts: 4,037

Rep: Reputation: 1099Reputation: 1099Reputation: 1099Reputation: 1099Reputation: 1099Reputation: 1099Reputation: 1099Reputation: 1099
Yay! Glad it worked.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] "sudo: Can't mkdir /var/run/sudo/%user%: File exists" CNBarnes Linux - Server 7 01-10-2011 05:11 PM
When I type "sudo grub" it says "command not found" in Ubuntu 10.10 poumtatalia Linux - Newbie 5 09-14-2010 06:21 PM
[SOLVED] When I type "sudo grub" it says "command not found" in Ubuntu 9.10 Live CD. msbstar Linux - Newbie 7 01-30-2010 12:05 PM
"sudo su - someuser -c xterm" doesn't work kenneho Linux - Newbie 1 10-02-2009 09:08 AM
cannot "sudo apt-get uptate" or "sudo" anything! plz help mdguy21061 Linux - Newbie 7 04-14-2008 12:59 AM


All times are GMT -5. The time now is 04:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration