LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   Why is the value of $PATH in console mode different from the $PATH in xterm emulator? (https://www.linuxquestions.org/questions/debian-26/why-is-the-value-of-%24path-in-console-mode-different-from-the-%24path-in-xterm-emulator-423000/)

Akhran 03-08-2006 09:35 PM

Why is the value of $PATH in console mode different from the $PATH in xterm emulator?
 
When in console mode (x-window-system is not loaded),

root@myserver:~#echo $PATH

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

However, when I'm in the window manager (fluxbox) and I open a xterm window, my $PATH has a different value.

root@myserver:~#echo $PATH

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

The difference is the additional space between the slash (/) and sbin. That causes /sbin to be missing from my PATH.

So any attempt to install package will give the error

dpkg: ldconfig not found on PATH
dpkg: start-stop-daemon not found on PATH

What is causing the additional space between the slash (/) and sbin in the PATH only when in xterm emulator?

Any advice would be greatly appreciated.

Thanks.
PS. Happens on both machines I installed x-window-system, fluxbox, xterm.

dracae 03-08-2006 11:56 PM

When you login the console /etc/profile is read. Opening an xterm only reads /etc/bash.bashrc, ~/.bashrc.

Akhran 03-09-2006 03:13 AM

For testing purpose, I installed rxvt and eterm. rxvt has the same error but eterm displays the correct $PATH value ( no extra space ).

In short, $PATH shows the correct value in eterm, but incorrect in rxvt and xterm on both machines.

Thanks !

kushalkoolwal 03-09-2006 03:26 AM

Quote:

Originally Posted by Akhran
When in console mode (x-window-system is not loaded),

root@myserver:~#echo $PATH

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

However, when I'm in the window manager (fluxbox) and I open a xterm window, my $PATH has a different value.

root@myserver:~#echo $PATH

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

The difference is the additional space between the slash (/) and sbin. That causes /sbin to be missing from my PATH.

So any attempt to install package will give the error

dpkg: ldconfig not found on PATH
dpkg: start-stop-daemon not found on PATH

What is causing the additional space between the slash (/) and sbin in the PATH only when in xterm emulator?

Any advice would be greatly appreciated.

Thanks.
PS. Happens on both machines I installed x-window-sy
stem, fluxbox, xterm.

I had the exact same problem couple of days ago. I added the line
source /etc/profile in my ~/.bashrc file.

Also, how do the following files work in the sense when and how are they called and by whom?
Code:

.bash_profile,.bashrc, .profile, /etc/profile, /etc/bash.bashrc, .xsesson and .xinitrc
If someone can clarify those it would be really great.

nx5000 03-09-2006 03:31 AM

Yes that's pretty annoying all this differences. Standards would help.. (maybe dash follows)
I add this type of line in scripts when I don't know when they're called.
Code:

echo "In bashrc" | logger
:twocents:

gilead 03-09-2006 04:20 AM

The first few describe bash's use of the files, because that's what I'm used to. My apologies to users of other shells...
Code:

.bash_profile read by the bash shell every time you login to the system (ie only in login shells);
.bashrc      is read by the bash shell every time you open a subshell with the bash command;
.profile      is used by the bash shell as a synonym for .bash_profile (derived from bourne and korn shells);
/etc/profile  is a system-wide 'parent' of .bash_profile/.profile;
/etc/bashrc  is a system-wide 'parent' of .bashrc <= I've never used this one...
.xinitrc      is a script that gets run every time startx is executed;
.xsession    is executed when users log in using xdm (.xinitrc is ignored)


Akhran 03-09-2006 08:42 AM

What's the difference between xterm, eterm and rxvt in terms of implementation that might have caused this difference? As far as I can notice, /etc/profile is the only place where my $PATH is defined.

Quote:

Originally Posted by Akhran
For testing purpose, I installed rxvt and eterm. rxvt has the same error but eterm displays the correct $PATH value ( no extra space ).

In short, $PATH shows the correct value in eterm, but incorrect in rxvt and xterm on both machines.

Thanks !


dracae 03-09-2006 08:53 AM

Use these to track down the problem
grep -r 'PATH=' /root
grep -r 'PATH=' /etc

Akhran 03-09-2006 04:42 PM

No file under /root but lots under /etc with 'PATH='. Eyeball check seems to indicate none of the lines in /etc contain '/ sbin'. What is the correct syntax to use to grep PATH="some_path_here:/ sbin:more_path_here" (with a space between / and sbin).

Also, another point to consider is why only eterm is not affected.

Thanks for all the replies :)



Quote:

Originally Posted by dracae
Use these to track down the problem
grep -r 'PATH=' /root
grep -r 'PATH=' /etc


dracae 03-09-2006 06:10 PM

grep -r '/ sbin' /


All times are GMT -5. The time now is 05:08 AM.