LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 06-18-2010, 09:18 AM   #1
rahilmaknojia
Member
 
Registered: Dec 2007
Distribution: RHEL6, CentOS6.3
Posts: 188

Rep: Reputation: 32
Question (Sudo) command can't run by sudo


I am having trouble running commands by using sudo

I configured visudo file with localuser ALL=(ALL) ALL but I can't run any command, it tells me command not found.

Last edited by rahilmaknojia; 06-18-2010 at 09:23 AM.
 
Old 06-18-2010, 09:42 AM   #2
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by rahilmaknojia View Post
I am having trouble running commands by using sudo

I configured visudo file with localuser ALL=(ALL) ALL but I can't run any command, it tells me command not found.
can you show the commands you are running and the error please?

you would normally need to run like this

Code:
sudo /path/to/command
 
Old 06-19-2010, 02:20 AM   #3
casion98
LQ Newbie
 
Registered: May 2010
Posts: 4

Rep: Reputation: 2
[root@FC5 bin]# ll /usr/bin/sudo
---s--x--x 2 root root 106832 Feb 12 2006 /usr/bin/sudo
 
Old 06-20-2010, 02:02 AM   #4
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by casion98 View Post
[root@FC5 bin]# ll /usr/bin/sudo
---s--x--x 2 root root 106832 Feb 12 2006 /usr/bin/sudo
I meant path to command being run
 
Old 06-21-2010, 07:35 AM   #5
rahilmaknojia
Member
 
Registered: Dec 2007
Distribution: RHEL6, CentOS6.3
Posts: 188

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by centosboy View Post
I meant path to command being run
Okay, this is what happen bellow when I type sudo command.

[rahil@rmaknojia ~]$ sudo service sshd restart
[sudo] password for rahil:
sudo: service: command not found
[rahil@rmaknojia ~]$
 
Old 06-21-2010, 07:54 AM   #6
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 5.4, Mac OS 10.4 (tiger)
Posts: 1,005

Rep: Reputation: 79
Hi,

Please note that when running sudo you are still using your own paths and not those of root. /sbin/service as is generally used with red hat based distributions will be found as root because /sbin/ is a default path for root but /sbin/ is not a default path for other users, you might want to try sudo /sbin/service sshd restart or sudo /etc/init.d/sshd restart

If you wish to be able to do this as root, you will have to add the paths that root has and your user does not, generally this wouldn't be advised however.
 
Old 06-21-2010, 10:42 AM   #7
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by rahilmaknojia View Post
Okay, this is what happen bellow when I type sudo command.

[rahil@rmaknojia ~]$ sudo service sshd restart
[sudo] password for rahil:
sudo: service: command not found
[rahil@rmaknojia ~]$
Code:
sudo /sbin/service sshd restart
 
Old 06-24-2010, 03:07 PM   #8
rahilmaknojia
Member
 
Registered: Dec 2007
Distribution: RHEL6, CentOS6.3
Posts: 188

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by centosboy View Post
Code:
sudo /sbin/service sshd restart
Okay, I will try that when I get home.
 
Old 06-25-2010, 09:30 AM   #9
rahilmaknojia
Member
 
Registered: Dec 2007
Distribution: RHEL6, CentOS6.3
Posts: 188

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by rahilmaknojia View Post
Okay, I will try that when I get home.
Guys it worked! Thanks to all!
 
  


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
LXer: The Ultimate Sudo FAQ To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 01:36 AM
sudo mkinitrd -o /boot/initrd.img-2.6.32.9 2.6.32.9 sudo: mkinitrd: command not foun vishwas181 Linux - Newbie 1 02-27-2010 01:16 AM
gnome launcher won't run a sudo command directly or via a script gnreeke Linux - Desktop 1 06-23-2009 10:44 AM
Problem with SUDO : sudo: pam_authenticate: Module is unknown cristoph_ Linux - Software 2 03-02-2009 07:12 PM
can't run app w/ sudo command fatblueduck Linux - Software 2 09-30-2005 07:39 PM


All times are GMT -5. The time now is 05:36 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration