Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 524
  • Last Modified:

Default PATH environment

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
westclox
Asked:
westclox
1 Solution
 
avizitCommented:
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
 
TintinCommented:
Depends on what flavour of Unix you have.  Some Unix flavours set the PATH in /etc/profile (and other places).
0
 
yuzhCommented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
GnsCommented:
... 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
 
JustsolutionsCommented:
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
 
avizitCommented:
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
 
GnsCommented:
This has been explained to death now. Can we have some feedback westclox?

-- Glenn
0
 
westcloxAuthor Commented:
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
 
GnsCommented:
Exactly. Thanks for the feedback.

-- Glenn
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now