[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Re: I'm really confused by bash, .bashrc, .bash_profile, .profile, etc, etc, etc



hi ya

> forgot-who started it

> > Is there a good system for setting variables, aliases, etc that need to be
> > set for user X, whether I log in at a login prompt or using su?  I'm
> > confused by all the different .profile options (there are at least 3 for
> > bash, why is that?)

why ?? because ... long history ...

general rule ...

	- if you're confused .. do NOT change files in anything other
	than your own home directory  "/home/you"

once you get brave ... decide if you want to enforce others to
use bash or csh or tsch or zsh or hudred-other-sh

	- each will have a different priority of files it will
	read or skip reading because some other files existed
	and it will over-ride the defaults, while in other cases,
	the defaults is still read, and user-defined changes
	overrides the system defaults

the search order is dfferent for user login vs scripts run by 
root or anybody/anything else ( like cron vs your scripts calling
other scripts )

which shell you use is defined in /etc/passed for that user

to add more whackyness, different distro put their defaults
in different directories and different filenames which will
add confusion

for simplicity... let's say you use /bin/bash on debian,
which implies your the search order is:

anything defined in one file can be redefined in the 
subsquent files

	- user defined changes override system defined variables

   system files
	/etc/profile		= read first for user login

	/etc/bash.bashrc	= interactive shell only


   user can do what you want in these files ..

	# after /etc/profile, search in order for the first executable:
	~/.bash_profile	
	~/.bash_login
	~/.profile		- not read if the files exists before it

	~/.bashrc		interactive shell read it if it exists
	
	~/.morebashfiles ??

   more user stuff
	~/.alias		always put aliases outside of bash files
				for portability 

	~/.login
	~/.logout

http://developer.novell.com/wiki/index.php/Bash_-_What_happens_when_you_invoke_bash

- the above ignores other "different" distros and other shells

c ya
alvin



Reply to: