LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 11-05-2007, 09:50 AM   #1
Denadai
LQ Newbie
 
Registered: Jul 2004
Posts: 14

Rep: Reputation: 0
$PATH driving me NUTS


I'm running XFCE on etch, but having problem with $PATH. I actually get it to work on some terminals but not others. I get the correct (updated by me) path settings (using echo $PATH) when I do Apps>Shells>Bash or Apps>Shells>Sh (apparently I updated the appropriate files for both of them). However, when clicking the "Terminal" button in the docking station, or by selecting "Terminal" from the base menu, it does not give me my updated $PATH! I've tried to change the default terminal through XFCE>Settings>Preferred Applications, but the new terminals that I try (running bash from /bin/bash, or xterm) do not show the correct updated path.

So, how do I know what program runs when I do Apps>Shells>Bash? Adding /bin/bash to preferred applications does not work I think phpMyAdmin is not working because it does not run mysql because the path is not correct - how do I set what all background programs use for terminal commands also?

In update-alternatives, my x-terminal-emulator is: /usr/bin/gnome-terminal.wrapper
- Changing this to xterm makes no difference for my $PATH
 
Old 11-05-2007, 10:19 AM   #2
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
To summarize:
When you login (through the console or kdm/gdm/xdm), a LOGIN SHELL is started. This shell will read /etc/profile (and maybe ~/.profile or ~/.bash_profile) and execute the lines contained in. It will not read ~/.bashrc, unless one of the previous mentionned files calls this file.

After that, all programs that you start will inherit the environment (which includes system variables like PATH which are **exported**) from this LOGIN SHELL. They will read and execute ~/.bashrc.
When you start (for example by clicking on shell icon) two shells, they will both be "child" of this LOGIN SHELL but they will have no link to eachother.

=>
Variables set in shell1 will not propagate to shell2.
Variables set in LOGIN shell will propagate to any child, which means everything. These variables have to be "exported"

Only "exported" variables goes from father to child:
toto=1
xterm& -> in the new xterm, echo $toto will not display anything.
export toto=1
xterm& -> echo $toto will print 1


1)So you need to put your PATH stuffs in /etc/profile or ~/.profile or ~/bash_profile so that all your programs inherit from this exported variable.

2)Or manually, start a shell and decide that all child shells (called subshells) will inherit from PATH:
export PATH="/bla/bla:${PATH}"
xterm& <-- this subshell will have PATH modified
But clicking on the shell icon will start an other independent subshell (of LOGIN shell) and thus won't have PATH set.

Yeah that's a summary

man bash will help you a lot

Last edited by nx5000; 11-05-2007 at 10:21 AM.
 
Old 11-05-2007, 11:04 AM   #3
Denadai
LQ Newbie
 
Registered: Jul 2004
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks for the note. I'm logging in through GDM - I've edited both /etc/profile and ~./bash_profile. I entered the same $PATH settings in both - when I run bash, I actually get the same set of path settings repeated twice, so probably it's reading off from both /etc/profile and ~./bash_profile.

I'm just wondering why the default shell does not inherit these settings, but Apps>Shells>Bash does. I'm not sure if this is how commands are run by default also (i.e., phpMyAdmin trying to run MySQL processes by running with the wrong path), thus preventing phpAdmin from working properly. I've also edited /etc/login.defs.

Quote:
Originally Posted by nx5000 View Post
To summarize:
When you login (through the console or kdm/gdm/xdm), a LOGIN SHELL is started. This shell will read /etc/profile (and maybe ~/.profile or ~/.bash_profile) and execute the lines contained in. It will not read ~/.bashrc, unless one of the previous mentionned files calls this file.

After that, all programs that you start will inherit the environment (which includes system variables like PATH which are **exported**) from this LOGIN SHELL. They will read and execute ~/.bashrc.
When you start (for example by clicking on shell icon) two shells, they will both be "child" of this LOGIN SHELL but they will have no link to eachother.

=>
Variables set in shell1 will not propagate to shell2.
Variables set in LOGIN shell will propagate to any child, which means everything. These variables have to be "exported"

Only "exported" variables goes from father to child:
toto=1
xterm& -> in the new xterm, echo $toto will not display anything.
export toto=1
xterm& -> echo $toto will print 1


1)So you need to put your PATH stuffs in /etc/profile or ~/.profile or ~/bash_profile so that all your programs inherit from this exported variable.

2)Or manually, start a shell and decide that all child shells (called subshells) will inherit from PATH:
export PATH="/bla/bla:${PATH}"
xterm& <-- this subshell will have PATH modified
But clicking on the shell icon will start an other independent subshell (of LOGIN shell) and thus won't have PATH set.

Yeah that's a summary

man bash will help you a lot

Last edited by Denadai; 11-05-2007 at 11:05 AM.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help - it's driving me nuts! n4ogl Linux - Newbie 4 11-13-2005 09:28 PM
Driving me nuts!! jappstam12345 Linux - Newbie 7 03-11-2005 05:51 PM
This is driving me nuts! dareino Fedora 4 06-30-2004 02:17 AM
Gimp is driving me NUTS!!! Lagg Slackware 22 12-26-2003 11:59 AM
driving me nuts!!! ihatebillgates Linux - Newbie 6 12-12-2003 07:03 AM

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

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