LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-29-2006, 03:42 PM   #1
DIGITAL39
Member
 
Registered: Sep 2003
Location: Virginia
Distribution: Slackware, CentOS, Red Hat
Posts: 48

Rep: Reputation: 15
SU and Path


If I login to the box directly or login remotely I can type 'which mysql' and get the correct location, but when I su to root and type it in it says it can't find that. Is there a way to change that or is there a particular reason for it?

Thanks
 
Old 10-29-2006, 11:07 PM   #2
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Blog Entries: 5

Rep: Reputation: 191Reputation: 191
Yes when you su to root make sure you inclued a ' -' that's a <space> and a hyphen after su.. to ensure you get the environment of hte user you are switching to..

su -

Quote:
It is advisable that administrative users, as well as any other users that are authorized to use su (of which there should be very few, if any), acquire the habit of always following the su command with a space and then a hyphen. The hyphen has two effects: (1) it switches the current directory to the home directory of the new user (e.g., to /root in the case of the root user) and (2) it changes the environmental variables to those of the new user. That is, if the first argument to su is a hyphen, the current directory and environment will be changed to what would be expected if the new user had actually logged on to a new session (rather than just taking over an existing session).
http://www.linfo.org/su.html


To verify the difference for yourself first su to root as you normally do. then issue the command echo $PATH

Exit back to your normal user then su - to root, and again issue the command echo $PATH I think you will notice the Environment PATH is a little different.

Last edited by farslayer; 10-29-2006 at 11:09 PM.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Path reference in Linux (Absolute path) javabuddy Linux - General 7 06-05-2006 07:45 AM
script to change unix path to windows path in all files csross Programming 8 04-29-2006 01:05 PM
Why is the value of $PATH in console mode different from the $PATH in xterm emulator? Akhran Debian 9 03-09-2006 06:10 PM
Apache path and kde path questions darkraider Debian 1 11-12-2005 05:07 AM
How to Chnage Python's module search path (sys.path)? lramos85 Linux - Software 1 05-02-2004 06:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:18 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