LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   $PATH problem (probably) (https://www.linuxquestions.org/questions/slackware-14/%24path-problem-probably-146510/)

dave bean 02-15-2004 07:57 PM

$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 . .

Tinkster 02-15-2004 08:07 PM

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

bnice 02-15-2004 08:19 PM

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.

dave bean 02-15-2004 08:35 PM

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 ?

Tinkster 02-15-2004 10:34 PM

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

CartersAdvocate 02-17-2004 09:04 AM

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"?

dave bean 02-17-2004 10:17 AM

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'.

nebeSaynebe 02-17-2004 11:22 AM

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.

dave bean 02-17-2004 06:34 PM

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)

Tinkster 02-17-2004 07:43 PM

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


All times are GMT -5. The time now is 07:49 PM.