Solved

Default PATH environment

Posted on 2004-08-28
9
515 Views
Last Modified: 2010-04-21
Hi!

I have often noticed within login's .profile the PATH variable may be pre-pended by $PATH

PATH=$PATH:.....................

My question is where is the very original PATH set before one logs in. I though it picked up from /etc/profile before it sees  .profile. When I opened /etc/profile all I saw was "export PATH". I did not see an actual line where the PATH was set prior to export.

Again, where is the very original PATH variable set. I do realize the final PATH environment set by "login" as per profile settings. I think, the default PATH ise set long before that or read from somewhere other than /etc/profile. I am wondering if it is created within the one of the startup rc scripts. If so, which one would it be.

westclox
0
Comment
Question by:westclox
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 11

Accepted Solution

by:
avizit earned 250 total points
ID: 11924479
excerpts from http://www.linuxenvy.com/gened/notes/note_path.html

During system boot a basic PATH is set by init in rc.init. /etc/rc.d/rc.sysinit is run once during the boot process and sets the PATH to something like /bin:/sbin:/usr/bin:/usr/sbin to provide access to all command directories required to complete the boot process.

Site wide PATH information is set by the /etc/profile script. This script is executed once during each user logon. Site wide PATH extensions should be added to this file.
(i.e. PATH:/usr/X11R6/bin:/opt/wp:/usr/local/bin)
0
 
LVL 48

Expert Comment

by:Tintin
ID: 11927306
Depends on what flavour of Unix you have.  Some Unix flavours set the PATH in /etc/profile (and other places).
0
 
LVL 38

Expert Comment

by:yuzh
ID: 11928249
Here's a list of possible files to set the ENV vars including PATH:

     /etc/profile
      /etc/cshrc
      /etc/default/su
      $HOME/.profile
      $HOME/.login
      $HOME/.cshrc
      $HOME/.kshrc
      $HOME/.dtprofile
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:Gns
ID: 11929251
... And some init might even set it from a default hardcoded, same goes for login, or set it in /etc/enviroment (aix) or....:-)
See, as all the above more or less explicitly say: It depends on whether you're interested in the PATh during system startup or user login, and further depends on what particular brew of programs you use (what init, getty, login, shell ....). So if you really need to know, read the manpages carefully (pay attention to the FILES section:-).

-- Glenn
0
 

Expert Comment

by:Justsolutions
ID: 11942225
Here's some more tips regarding your PATH.  You can put the $PATH at the beginning or end
of your directories your adding.   PATH=$PATH:/your/paths  or PATH=/your/paths:$PATH
Unix shells will traverse the directories in the order found in the PATH variable.  This can help
or hurt performance based on your positioning of the directories.  It is common to add "." at
the end of the PATH to search your current directory.  A common feature of DOS but not UNIX.
This can be a "security hole" if put at the beginning of your PATH.  A trojan horse program could
be in your current directory and be run instead of the "real" program you want.  Hope this helps!
0
 
LVL 11

Expert Comment

by:avizit
ID: 11942259
a "." in the path can be dangerous ANYWHERE in the path , not just in the front

imagine going to someone elses directory and he has a malicious program names "sl" or some other misspelt version of comon unix programs
and you type a 'sl' instead of 'ls' there.. ..
0
 
LVL 20

Expert Comment

by:Gns
ID: 11942756
This has been explained to death now. Can we have some feedback westclox?

-- Glenn
0
 

Author Comment

by:westclox
ID: 11980225
Hi!

I appreciate you all taking a moment to respond to my question.

I felt that [ avizit ] was the closest to answer my question, although without the link he would have only earned 1/2 the points. Yet he was able to understand my original question.

Most of the responses I read were based on after-the-fact.  I was alreday knowledgeable about the pos-login events and profiles and shells that gets executed. What I wanted to know is during boot-up somebody is setting the original PATH variables, which is really before login is even entered. I am fully aware  of deafults that kick in followed by personal login profiles. One can customize them in any way they wish.

[ avizit ] mentions that is a combination of both the variant of Unix OS and the how init scripts are written. I will try and locate PATH setings on my UxWare 7 system, within any one of the init scripts; otherwise I have to assume the "init" program is setting it by itself without and reference to shell scripts.

westclox
0
 
LVL 20

Expert Comment

by:Gns
ID: 11988596
Exactly. Thanks for the feedback.

-- Glenn
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question