I want to know how the standard environment variables given by the linux OS like PATH, HOME are set automatically. In which file are these read from. There should be some file from which these variables are set when a particular user login.
|
migrated from serverfault.com Sep 22 '11 at 11:41
|
The answer to your question can be found in
There's even more in the man page, I recommend you read it. |
|||||||
|
|
check |
|||
|
|
Things are a little more complex than just what your shell provides. There are three main ways to login:
They all are able to set up the environment before executing your shell, and they all do (HOME, LOGNAME, TERM are probably not set by your shell, and even if you have no start up files, your shell get probably also a PATH). When login from a true terminal, the process handling the connection will probably set up the TERM environment variable and delegate the rest of the work to the When login from a pseudo-terminal, the same things happen with a little twist. Often the environment get more initialization form the process handling the connection that just the TERM environment variable (network protocols often have a way to transfer the environment from the other side) and thus Graphic environments usually don't delegate to A last thing, when you launch a terminal emulator, you may get either a login shell (in which case the login script from the shell is executed and thus you get to see the effect of your latest changes in it, but won't see the same environment as the other programs) or not (in which case the login script from the shell isn't executed, you don't see your latest changes, but you get the same environment as the other programs — modified by the interactive initialization script of your shell). |
|||
|
|
|
You should take a look at the However, if you mean where do all environmental variables get set - I'd assume that they get inherited from some parent process. Perhaps a look at something like this might help. |
|||
|
|
|
Check the man page for bash as it should give you all the files that are checked (and in which order) depending on your distribution. The |
|||
|
|