Unix Technical Forum

Where does PATH get set for root user?

This is a discussion on Where does PATH get set for root user? within the Linux Operating System forums, part of the Unix Operating Systems category; --> Hello, On my system, echo $PATH reveals this for a normal user: /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:/opt/kde/bin:/usr/lib/qt-3.1.2/bin:. But for root, it's this: /usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin ...


Go Back   Unix Technical Forum > Unix Operating Systems > Linux Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-17-2008, 08:30 AM
Anthony
 
Posts: n/a
Default Where does PATH get set for root user?

Hello,

On my system, echo $PATH reveals this for a normal user:

/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:/opt/kde/bin:/usr/lib/qt-3.1.2/bin:.

But for root, it's this:

/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin

And since root's path lacks the X11R6 path, I can't execute xterm and
some other stuff as root. How can I adjust root's path permanently?

/etc/profile sets this, right near the top:

PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games"

....so root's path must be getting changed somewhere, or else is not
based on /etc/profile.

Thanks,
Anthony
http://nodivisions.com/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-17-2008, 08:30 AM
Michael Heiming
 
Posts: n/a
Default Re: Where does PATH get set for root user?

Anthony <orders@nodivisions.com> wrote:

> And since root's path lacks the X11R6 path, I can't execute xterm and
> some other stuff as root. How can I adjust root's path permanently?


You should never ever run X as root, there is not a single reason,
login in as user, open some xterm and type 'su -' or use 'sudo'.

Good luck

--
Michael Heiming

Remove +SIGNS and www. if you expect an answer, sorry for
inconvenience, but I get tons of SPAM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-17-2008, 08:30 AM
armin walland
 
Posts: n/a
Default Re: Where does PATH get set for root user?

Anthony <orders@nodivisions.com> wrote:
> On my system, echo $PATH reveals this for a normal user:
> /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:/opt/kde/bin:/usr/lib/qt-3.1.2/bin:.
>
> But for root, it's this:
> /usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin
>
> And since root's path lacks the X11R6 path, I can't execute xterm and


this is correct and the way it should be.

> some other stuff as root. How can I adjust root's path permanently?


don't use X as root. period.
use su, sudo, kdesu, gnomesu or whatever if you really need to run
something that requires X as root.


rgds, armin

--

my life, my universe, my everything
http://www.dtch.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-17-2008, 08:30 AM
Alan Connor
 
Posts: n/a
Default Re: Where does PATH get set for root user?

On 18 Oct 2003 23:41:16 -0700, Anthony <orders@nodivisions.com> wrote:
>
>
> Hello,
>
> On my system, echo $PATH reveals this for a normal user:
>
> /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:/opt/kde/bin:/usr/lib/qt-3.1.2/bin:.
>
> But for root, it's this:
>
> /usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin
>
> And since root's path lacks the X11R6 path, I can't execute xterm and
> some other stuff as root. How can I adjust root's path permanently?
>


X is a networking application, and you shouldn't run it as root!


> /etc/profile sets this, right near the top:
>
> PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games"
>
> ...so root's path must be getting changed somewhere, or else is not
> based on /etc/profile.
>
> Thanks,
> Anthony
> http://nodivisions.com/


Try ls -al /root

--
Alan C
Posts with sigs of > 4 lines, or not in plain text, are dumped by my filters.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-17-2008, 08:30 AM
ftoomch
 
Posts: n/a
Default Re: Where does PATH get set for root user?



Alan Connor wrote:
> On 18 Oct 2003 23:41:16 -0700, Anthony <orders@nodivisions.com> wrote:
>
>>
>>Hello,
>>
>>On my system, echo $PATH reveals this for a normal user:
>>
>>/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:/opt/kde/bin:/usr/lib/qt-3.1.2/bin:.
>>
>>But for root, it's this:
>>
>>/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin
>>
>>And since root's path lacks the X11R6 path, I can't execute xterm and
>>some other stuff as root. How can I adjust root's path permanently?
>>

>
>
> X is a networking application, and you shouldn't run it as root!


Does this mean that when RedHat lets you log in as root from gdm, that
this is supremely dangerous and should be turned off?

>
>
>
>>/etc/profile sets this, right near the top:
>>
>>PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games"
>>
>>...so root's path must be getting changed somewhere, or else is not
>>based on /etc/profile.
>>
>>Thanks,
>>Anthony
>>http://nodivisions.com/

>
>
> Try ls -al /root
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-17-2008, 08:30 AM
Michael Heiming
 
Posts: n/a
Default Re: Where does PATH get set for root user?

ftoomch <ftoomch@hotmail.com> wrote:


> Alan Connor wrote:

[..]
> > X is a networking application, and you shouldn't run it as root!


> Does this mean that when RedHat lets you log in as root from gdm, that
> this is supremely dangerous and should be turned off?


Yep, however it's a common newbie mistake and we get polluted with
questions like this.

Once again:

There is not a single reason for running X as root, beside silliness.

One can use, su, sudo, kdesu/etc.

--
Michael Heiming

Remove +SIGNS and www. if you expect an answer, sorry for
inconvenience, but I get tons of SPAM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-17-2008, 08:31 AM
Anthony
 
Posts: n/a
Default Re: Where does PATH get set for root user?

There are times when I want to invoke an instance of xterm as root,
and without its location in my path, that's a big pain. I'm not
"running X as root."

Does anyone here actually know the answer to my question?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 01-17-2008, 08:31 AM
Jan Ceuleers
 
Posts: n/a
Default Re: Where does PATH get set for root user?

>Does anyone here actually know the answer to my question?

~root/.bash_profile

more text to avoid quote-to-new-text-ratio issue
more text to avoid quote-to-new-text-ratio issue
more text to avoid quote-to-new-text-ratio issue
more text to avoid quote-to-new-text-ratio issue
more text to avoid quote-to-new-text-ratio issue
more text to avoid quote-to-new-text-ratio issue

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 01-17-2008, 08:31 AM
Chiefy
 
Posts: n/a
Default Re: Where does PATH get set for root user?

19 Oct 2003 06:41 UTC, Anthony typed:
[snip]
> /etc/profile sets this, right near the top:
>
> PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games"
>
> ...so root's path must be getting changed somewhere, or else is not
> based on /etc/profile.


It's common for the root path to differ. There may be some sort of
modification in /etc/profile, or ~/.profile. And in spite of comments
already made, both Debian and Slackware, although modifying roots path
do have X11 included.

Something along the following lines, placed after existing PATH
definition, in /etc/profile would allow you to add to the root path.

if [ "`id -u`" = "0" ]; then
PATH=/new/path/1:/new/path/2:$PATH
fi

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 01-17-2008, 08:31 AM
ftoomch
 
Posts: n/a
Default Re: Where does PATH get set for root user?



Michael Heiming wrote:
> ftoomch <ftoomch@hotmail.com> wrote:
>
>
>
>>Alan Connor wrote:

>
> [..]
>
>>>X is a networking application, and you shouldn't run it as root!

>
>
>>Does this mean that when RedHat lets you log in as root from gdm, that
>>this is supremely dangerous and should be turned off?

>
>
> Yep, however it's a common newbie mistake and we get polluted with
> questions like this.


Feel free not to answer then.

>
> Once again:
>
> There is not a single reason for running X as root, beside silliness.
>
> One can use, su, sudo, kdesu/etc.
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:06 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com