$PATH

beesond001 at hawaii.rr.com beesond001 at hawaii.rr.com
Mon Aug 27 14:08:19 PDT 2001


Ronnie,

	The $PATH variable is a cool one... You can set the path variable in the 
user's .bash_profile file (or the equivalent file for csh .profile, or 
other shells as appropriate).  For the discussion here, I'll use bash as 
the example, but the other shells work almost the same.  Put something 
like this in the user's .bash_profile  file:

PATH=$PATH:$HOME/bin  

This will give you access to the /home/username/bin directory.  

	To set the $PATH variable automatically when you add a new user, place 
the desired path in the /etc/skel/.bash_profile file.  Any file in the 
/etc/skel directory gets copied into a new users directory when you 
create the account, so if you have a system wide configuration you want, 
this is a good place to put it. That way, you don't have to remember all 
the changes to make when you create a new account.  

	The .login file is used for login shells only, so if you set the $PATH 
variable there, it works for login shells, but may behave unexpectedly 
for non-login shells.  Also, it is prudent to add your paths after the 
system default path so that search commands search the system files first 
then your own files.  This way, just in case you write your own program 
and give it the same name as a system command, you will have to type the 
whole path to get your version to run. As an example, some versions of 
Solaris had both system 5 and BSD commands with the same names.  To get 
the Berkely versions of commands to run, you had to type something like 
/usr/ucb/ps -ef.  The System 5 command would run as ps -ef since the 
default path would search the system 5 directory (/bin)  before the 
/usr/ucb directory tree.  

	The /etc/profile file has the system defaults for environment and 
startup programs. (There are other system shell defaults in the /etc/ 
directory such as csh.cshrc and zshrc among others.) If a user does not 
have a .bash_profile etc, the values for the system environment including 
the PATH are found here. This is to say that the system starts here and 
then adds your stuff from .bash_profile to it.  Most folks don't change 
this file without good reason because an upgrade to the operating system 
may undo your change... Changes made in the user's .bash_profile files 
will be preserved across upgrades.  

	You mentioned that you read that the root user should not have 
/usr/local/bin in the path.  I don't know if this is really an issue 
beyond one of convenience because the root user can do anything on a *nix 
box anyway.  This includes running rm * from the / directory..... It is 
more important as a root user to do things carefully and with an 
awareness of consequences.  Many administrators will test dangerous 
commands and evaluate their regular expression expansions using the 
"test" command or the "echo" command prior to running them for real just 
to make sure they know what they are in for.  If you need to know what 
version of a command your system will run, type 'which commandname' at 
the shell prompt and see what comes back.  The which command returns the 
**first version of a command*** the system finds in the ***current 
searchable path***.  

	Also, most people will not add the current directory to their $PATH as a 
security measure. This would keep trojan horses from easily running if a 
local account is cracked.  (Granted a sophisticated cracker would be 
undeterred by this, but nonetheless, the little things do help.)  

	I hope this helps.  You can also find good info on PATH, PROMPTS and 
other tricks in the books Unix Power Tools, and Learning the bash shell.  
Both of these are published by O'reilly.     


Good luck,

Ben 
 
>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 8/27/01, 10:11:58 AM, "Ronnie" <rlivings at hawaii.edu> wrote regarding 
[luau] $PATH:


> hello, i was wondering if someone could clarify $PATH to me.   I am a
> little unclear as to how i set the path permanently,  ive seen it mention
> that you can modify .login and .profile.  Please correct me if im wrong,
> .login is to set the path for users and .profile is to set the path for
> su??  I checked out my path and i noticed that they are both the same for
> su and users,  i also noticed that /usr/local/bin was in the path but i
> just read in the tucows tutorial that su shouldnt have /usr/local/bin in
> the path.

> please help, id like to figure out how to configure the path properly

> thanks,
> Ronnie

> ---
> You are currently subscribed to luau as: beesond001 at hawaii.rr.com
> To unsubscribe send a blank email to $subst('Email.Unsub')



More information about the LUAU mailing list