LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-15-2004, 07:57 PM   #1
dave bean
Member
 
Registered: Jun 2003
Location: UK
Distribution: Slackware 9.1
Posts: 136

Rep: Reputation: 15
$PATH problem (probably)


Hi,

I have 2 users, root and cecile. When i log in with either user i can access java or gedit from the command line. But if i log in as cecile and swap user to root and then back to cecile i am unable to access gedit or java.

Code:
cecile@rix:~$ which gedit
/usr/bin/gedit
cecile@rix:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:/usr/lib/java/bin:/usr/lib/java/jre/bin:/opt/kde/bin:/usr/lib/qt-3.2.1/bin:/usr/share/texmf/bin:.:/usr/lib/java/bin/java:/usr/bin
cecile@rix:~$ su -
Password:

Penguin Trivia #46:
        Animals who are not penguins can only wish they were.

root@rix:~# su cecile
cecile@rix:/root$ echo $PATH
/usr/local/bin:/bin:/usr/bin
In the above example cecile cant access java because it is not on her new path. But why can't she access gedit if its in /usr/bin ??? and where does she get this new path from ?

i get this error from gedit:
Code:
(gedit:1943): Gtk-WARNING **: cannot open display:
i have set the path for non root users in /etc/profile like this:
Code:
 PATH="$PATH:.:/usr/lib/java/bin/java:/usr/bin"
thanks in anticipation . .
 
Old 02-15-2004, 08:07 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913
That's because you used
su cecile rather than su - cecile

That way cecile inherits root's display
variable which probably isn't set.

But why don't you 'exit', rather than
running up a sequence of su's?


Cheers,
Tink
 
Old 02-15-2004, 08:19 PM   #3
bnice
Member
 
Registered: Feb 2004
Location: Sacramento, CA
Distribution: Slack 9.1, slackware-current
Posts: 284

Rep: Reputation: 30
I know this is a non-answer but...

Code:
man bash
there's a section on which configuration file gets read when.

/etcprofile
~/.bash_profile
~/.bashrc

if a `source /etc/profile` fixes your path, then copy the relevant path statement to a file in the user's home directory named .bashrc, and it should be read when you plop back into your user.
 
Old 02-15-2004, 08:35 PM   #4
dave bean
Member
 
Registered: Jun 2003
Location: UK
Distribution: Slackware 9.1
Posts: 136

Original Poster
Rep: Reputation: 15
thanks for the quick answers, ill check those out when i reboot out of windows. I know there are ways to fix the problem, most simply i could just open another bash shell.

Also if i was to login with cecile and then 'su - ' i can access java but not gedit.

In the above situation and with cecile 'gedit' is on their path, so why cant they access it ?
 
Old 02-15-2004, 10:34 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913
Quote:
Originally posted by dave bean
In the above situation and with cecile 'gedit' is on their path, so why cant they access it ?
Quote:
Originally posted by dave bean
Code:
(gedit:1943): Gtk-WARNING **: cannot open display:
Quote:
Originally posted by Tinkster
That way cecile inherits root's display
variable which probably isn't set.

Cheers,
Tink
 
Old 02-17-2004, 09:04 AM   #6
CartersAdvocate
Member
 
Registered: Sep 2003
Location: Columbus, OH
Distribution: Slackware 12.2
Posts: 166

Rep: Reputation: 30
Re: $PATH problem (probably)

Quote:
Originally posted by dave bean
Code:
cecile@rix:~$ which gedit
/usr/bin/gedit
cecile@rix:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:/usr/lib/java/bin:/usr/lib/java/jre/bin:/opt/kde/bin:/usr/lib/qt-3.2.1/bin:/usr/share/texmf/bin:.:/usr/lib/java/bin/java:/usr/bin
cecile@rix:~$ su -
Password:

Penguin Trivia #46:
        Animals who are not penguins can only wish they were.

root@rix:~# su cecile
cecile@rix:/root$ echo $PATH
/usr/local/bin:/bin:/usr/bin
Is there a reason you use su to go back to cecile instead of just typing "exit"?
 
Old 02-17-2004, 10:17 AM   #7
dave bean
Member
 
Registered: Jun 2003
Location: UK
Distribution: Slackware 9.1
Posts: 136

Original Poster
Rep: Reputation: 15
sorry, my mistake Tinkster, well ive done a few searches but i cant find how i go about changing the display variable for root ?

and for the exit question the answer is no. im still a newbie and im teaching myself so thanks for pointing out that this isn't a good habit, i've since read 'man su'.
 
Old 02-17-2004, 11:22 AM   #8
nebeSaynebe
LQ Newbie
 
Registered: Feb 2004
Posts: 8

Rep: Reputation: 0
The path for su is restricted for security reason I bet. To make u have the root path as u have when login as root on console, u can append a line into your ~/.bashrc:

source /etcprofile

Append that also into ur ~cecile/.bashrc.

Note, init is the first process startet by the kernel, after awhile, init source the file /etc/profile, the first system wide PATH definition is defined in /etc/profile. This environment will be inherited to all login shell, that is why when u have not ~/.bashrc, ~/.bash_profile, u still have the correct path like it is in /etc/profile, well those scripts in /etc/profile.d/*.sh extends also the path during the PATH definition.

So my conclusion is, it is a good habit to source /etc/profile in ~/.bashrc and ~/.bash_profile b4 extra path are appended. This prevents also redudances of paths in $PATH also, because the PATH value will be set to null b4 it is redefined.

Hope that answer the path confusion, as for root display I have the problem also. That is possibly also made so for security reason.
 
Old 02-17-2004, 06:34 PM   #9
dave bean
Member
 
Registered: Jun 2003
Location: UK
Distribution: Slackware 9.1
Posts: 136

Original Poster
Rep: Reputation: 15
hi, thanks for the advice but either i don't understand or i don't have the dir
~/.bashrc
(im viewing hidden files or ls- a)
 
Old 02-17-2004, 07:43 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913
Quote:
Originally posted by dave bean
sorry, my mistake Tinkster, well ive done a few searches but i cant find how i go about changing the display variable for root ?
The easiest way would be
export DISPLAY=loclahost:0.0

Quote:
and for the exit question the answer is no. im still a newbie and im teaching myself so thanks for pointing out that this isn't a good habit, i've since read 'man su'.
Good ;)


Cheers,
Tink
 
  


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
Problem with $PATH halfpower Linux - Newbie 4 08-30-2005 01:49 PM
qt path problem wmeler Linux - Software 0 05-13-2004 11:20 PM
How to Chnage Python's module search path (sys.path)? lramos85 Linux - Software 1 05-02-2004 07:10 PM
PATH problem jhansman Linux - Newbie 18 08-24-2003 02:15 AM
$PATH problem charlie123 Linux - Newbie 3 01-15-2003 05:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

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