LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 04-20-2007, 04:47 PM   #1
mjguillo
LQ Newbie
 
Registered: Apr 2007
Posts: 2

Rep: Reputation: 0
Where is PATH originally set


I have a question as to where the PATH variable is originally set. All of the posts I have seen about editing the PATH variable include something like

PATH=$PATH:\newstuff
export PATH
But this just appends \newstuff to to the already existing path variable. It has to be set somewhere originally, but I can't seem to find where.

I am using the bash shell.

Can anybody help me out?
Thanks
mjguillo
 
Old 04-20-2007, 05:14 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

This depends a bit on how your distro is set up.

If you don't use pam it's set in this file: /etc/login.defs. The options are ENV_SUPATH and ENV_PATH
If you do use pam it probably in this file: /etc/security/pam_env.conf. The option is PATH

Hope this helps.
 
Old 05-09-2007, 09:45 AM   #3
Oupa
LQ Newbie
 
Registered: Apr 2007
Location: Welkom, South Africa
Distribution: RHL + Mandriva
Posts: 15

Rep: Reputation: 0
PATH variable

One of the sytem wide startup files that sets the PATH is /etc/profile.
/etc/bashrc sets aliases.
Oupa.
 
Old 05-09-2007, 09:58 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

@Oupa: /etc/profile and/or /etc/bashrc are used to change and or add to the PATH variable. The questions was were it was originally set. This is not done in either of the files you mention. If you remove all PATH settings in all login files (including those that are in your homedir files), you are still presented with a basic PATH setting.

Hope this clears things up.
 
Old 05-10-2007, 12:50 AM   #5
Oupa
LQ Newbie
 
Registered: Apr 2007
Location: Welkom, South Africa
Distribution: RHL + Mandriva
Posts: 15

Rep: Reputation: 0
PATH Variable

Hi, it appears that we have still not solved the origin of the PATH. I have checked the /etc/login.defs file and find no reference to PATH. Quoting from the Red Hat Linux Bible:
----------------------------------------
/etc/profile - This file sets up the user environment information for every user. It is executed when you first log in. This file provides values for your path, as well as setting environment variables for such things as the location of your mailbox and size of history file. Finally, /etc/profile gathers shell settings from configuration files in the /etc/profile.d directory.
----------------------------------------
I find no reference to PATH in the files in /etc/profile.d directory. I therefore assume that the RHL Book is correct and that it is set in /etc/profile, at least until someone proves conclusively that it originates elswhere. Oupa.

Last edited by Oupa; 05-10-2007 at 12:58 AM.
 
Old 05-10-2007, 01:34 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

I did mention 2 places, depending on your setup. You seem to have overlooked pam....
 
Old 05-10-2007, 01:45 AM   #7
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
You could grep for 'PATH=' in /etc/. Look in /etc/rc.sysinit if you have it.
There may be something in /etc/profile.d/ as well.
 
Old 05-10-2007, 02:13 AM   #8
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

Some extra, login.defs related, info:

From login.defs:
Quote:
#
# *REQUIRED* The default PATH settings, for superuser and normal users.
#
# (they are minimal, add the rest in the shell startup files)
ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
From the shadow suite:
Quote:
ENV_SUPATH is no longer supported. You must create a valid /root/.bashrc file to provide a modified path for the super-user.
BTW: A Red Hat bible isn't leading, it tells you how Red Hat does things.......
 
Old 05-11-2007, 02:38 AM   #9
Oupa
LQ Newbie
 
Registered: Apr 2007
Location: Welkom, South Africa
Distribution: RHL + Mandriva
Posts: 15

Rep: Reputation: 0
PATH origin

Hi mjguillo and guys, my apoligies for complicating what should have been a simplistic answer. Perhaps I should merely have stated the /etc/profile is the ideal place to modify the PATH globally for the bash shell. As the guys have pointed out other application software can also modify the value of PATH.
Below is a more technical explanation of how the PATH originates:
------------------------------------------------

Init:
Init is a parent process for all the other processes of the system. Other processes inherit environment of the init process and the path is the init path in the rare case that no other path is set.
The 'init path' is fixed in the source of the init program and it is:
/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin

Login:
In text console there is a getty program waiting for user login. It writes 'login:' and other messages. It is working in init environment. When getty gets user to log in to the system, it invokes the 'login' program. This program sets the user environment and invokes the shell.
Login program sets path as defined in /usr/include/paths.h. This 'login path' is different for root users and other users.
for common users (_PATH_DEFPATH):
/usr/local/bin:/usr/bin:/bin:.
for root (_PATH_DEFPATH_ROOT):
/sbin:/bin:/usr/sbin:/usr/bin

Strategies to get the same path for all the users:
The most important settings is possible to set in the global shell initialization files for login shells: /etc/csh.login for tcsh and /etc/profile for bash.
Exceptions that do not get the right path from these files are rsh commands, ssh commands, menu items from X window manager that do not explicitly start login shell, commands invoked from inittab, cron jobs, daemons jobs like magic filters started from lprd, WWW CGI scripts, and so on.
----------------------------------------------------
Oupa.
 
Old 05-11-2007, 03:12 AM   #10
taxtropel
Member
 
Registered: Mar 2005
Location: Cascade Mountains WA USA
Distribution: Linux From Scratch (LFS)
Posts: 149

Rep: Reputation: 16
Why?

The origin of PATH variable it totaly distribution dependant.

The real question is: "Why does it matter?"

You should not modify the Original PATH, but rather you should add on to the end of the path (or beginning).

As stated by many others this can be changed in a multiple of locations.

remember ogres...err...linux is like an onion, it's all about the layers.

If you don't like the way your distribution is setup, then try another or better yet make your own... LFS
mmm...LFS: it's like eating doughnuts...only more stressful and labor intensive.

OH and for a good book about linux, forget the "Red Hat Bible"
and get "Running Linux"

Last edited by taxtropel; 05-11-2007 at 03:15 AM.
 
  


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
Set the path systemwide/Set the path for a user with Slackware jayhel Slackware 1 06-12-2005 12:24 AM
How to set PATH How do I set PATH environment variable? Tranquil Linux - Newbie 3 11-02-2003 02:52 AM
$PATH!? how to set these PATH(s)!? sirpelidor Red Hat 5 10-25-2003 04:00 PM
Set Path reaky Linux - Newbie 2 10-09-2003 07:54 PM
Updating Software when it was originally installed by an RPM jmnovak Linux - General 1 08-22-2003 01:47 PM


All times are GMT -5. The time now is 01:36 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration