Solved

Default PATH environment

Posted on 2004-08-28
9
514 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
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

821 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