Process Understanding

Les hlhowell at pacbell.net
Mon Feb 5 11:49:06 UTC 2007


On Mon, 2007-02-05 at 10:28 +0000, Dan Track wrote:
> Hi
> 
> I'm trying to get my head round how processes start and how they get
> their environment, especially env variables.
> 
> Let's say you have two scenarios, one where a user e.g www has the
> following entry in /etc/passwd
> 
> www:x:500:500::/home/www:/bin/bash
> 
> and the other where the user has the following entry:
> 
> apache:x:48:48:Apache:/var/www:/sbin/nologin
> 
> The main difference between the two that I would like to focus on is
> the that one user has a bash shell (www) while the other has no shell
> (apache).
> 
> If both users are used to start an httpd process, then where and how
> do the processess get their environment variables, i.e what files are
> read in both cases e.g /etc/profile, /etc/bashrc etc.?
> 
> Thank in advance
> Dan
> 
Processes that are started explicitly receive the starting users
profile.  The environment variables are read by software commands.  The
processes started by cron will utilize a default profile, or a shell
script can be executed that will set the environment appropriately.
Other processes can use both the inherited profile, and then add their
own required variables by software.  In short, like everything else
UNIX, Linux offers multiple ways and means to accomplish a given goal.
Environment variables are "shortcuts" or "global" items accessible by
the programs, scripts and shells to simplify the programming task and
make code custom on a per user or per invocation basis.

	As an example:
	Just create a text file "showpath" that contains only the following:
	echo $PATH

	Now depending on your security settings you may have to make this
executable, so do the following:
	%  chmod +x showpath
	This adds the executable capability to the file.

	Then from a command shell window (terminal):
	% source ./showpath
	
	And you will see the path that will be searched for any commands you
issue.  Typically it will contain /bin and /usr/bin among others.

	This can also be used to add a path to search.  For instance if you
write a lot of script files, you might have a ~/scripts directory, and
you could add that path as the first place to look (so it could replace
system commands if you desire) doing the following in your bash shell in
the terminal (the default FC6 terminal shell).
	PATH=~/scripts:$PATH

	Now when you execute the source command again, the path will reflect
the new condition. Don't worry, this will disappear when you log out and
back in again.

Regards,
Les H

Regards,
Les H




More information about the users mailing list