Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Default PATH environment

Posted on 2004-08-28
9
Medium Priority
?
517 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 750 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
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.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.:
Suggested Courses

722 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