Solved

Default PATH environment

Posted on 2004-08-28
9
507 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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…
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.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now