LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 09-25-2009, 11:13 AM   #1
scucci
Member
 
Registered: Sep 2009
Posts: 31

Rep: Reputation: 15
Can't run certain commands as SU


I'm logging in remotely via SSH with a local account and when I SU to get to root I get the following error: bash: service: command not found.

After logging into the server via the console as root I'm able to restart the service. Any ideas?
 
Old 09-25-2009, 11:36 AM   #2
ordinary
Member
 
Registered: Apr 2007
Location: the Rocket City
Distribution: Debian, Ubuntu, CentOS; in days past Fedora, Solaris, SunOS, 4.2BSD, 4.3BSD, SVR4, AIX, HP-UX
Posts: 101

Rep: Reputation: Disabled
Here's just a guess:

su changes user ID but not environment. The "-" option gives you the environment of the new user. "su earl" gives you the user ID "earl" but not earl's environment. "su - earl" gives you the user ID "earl" along with earl's environment.

When you run su without the "-" you do, indeed, get root privelege but not the root environment - not root's PATH, for example. So, try "su -". That'll give you root privelege and root's environemnt. Service is in /sbin or /usr/sbin or some place like that that isn't on a typical user's PATH, but is on root's PATH.

Last edited by ordinary; 09-25-2009 at 11:41 AM.
 
Old 09-26-2009, 10:07 AM   #3
scucci
Member
 
Registered: Sep 2009
Posts: 31

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by ordinary View Post
So, try "su -". That'll give you root privelege and root's environemnt.
That was it, thank you!! Is the path the only thing that would have changed from not having roots environment? What else would have been different.

Thanks again!!
 
Old 09-26-2009, 10:19 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
A user's environment includes a variety of things--I can't get to a terminal at the moment, but I think the "env" command shows the whole picture.
 
Old 09-27-2009, 01:39 PM   #5
scucci
Member
 
Registered: Sep 2009
Posts: 31

Original Poster
Rep: Reputation: 15
Understood. Thank you all for your quick replies!!
 
Old 09-27-2009, 04:37 PM   #6
alar
Member
 
Registered: Sep 2003
Location: Canada
Distribution: Fedora 30
Posts: 341

Rep: Reputation: 37
The biggest difference I ever notice between su and su - is access to the commands in /sbin.
If I can't access it, then I think oops did I su -?
 
Old 09-27-2009, 09:33 PM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by alar View Post
The biggest difference I ever notice between su and su - is access to the commands in /sbin.
If I can't access it, then I think oops did I su -?
this of course depends on how your PATH variable is setup---right?
 
  


Reply



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
cron won't run commands? mma8x Linux - Software 4 04-05-2006 12:25 PM
no commands run astroboiii Linux - General 2 01-08-2005 07:40 PM
My Mandrake can not run the following commands. futurist Linux - General 2 03-23-2003 09:12 AM
Cannot run commands after su bugsbunny Linux - Newbie 5 02-07-2003 11:25 AM
Scripts won't run commands Xyphoid Linux - General 4 08-08-2002 08:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:01 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
Open Source Consulting | Domain Registration