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

Re: Structure of /etc/profile



In article <[🔎] Pine.LNX.3.91.960117005039.15115H-100000@myrddin.chu.cam.ac.uk> you write:
>With the discussion going on in another thread about what to put in 
>/etc/profile by default, whether to allow packages to add to it, and so 
>on, I thought it was time to bring this idea up.
>
>/etc/profile is normally used to do two things - set a default 
>process environment for users while logging in (environment variables, 
>umask, ulimit, and so on) and do other things the administrator wants it 
>to do, like running fortune, displaying messages, etc.
>
>I think that these two functions are logically separate, and I suggest 
>that they be separated. I propose that a file /etc/environment is used to 
>set the process environment. This would be sourced by /etc/profile. It 
>would also be sourced by the system Xsession script.

I would prefer /etc/environment to be named /etc/ENV-bash.
Not everyone uses bash as their login shell, and it seems to me that
/etc/csh.login can then source /etc/ENV-csh in a similar manner.

While we're dissussing this, can I show people my current setup:

This is /etc/profile:
------------------------------------------------------------
# Sets up the environment globally

SYSPATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"
PATH=$SYSPATH
PS1='\h\$ '

export SYSPATH PATH PS1

export MANOPT=-Pless

ulimit -c unlimited
umask 022
------------------------------------------------------------

Particularly, notice I define SYSPATH without '.', so that
paranoid user's do not have to have dot on their path if they
don't want to.


Each individual user's .bash_profile then looks like:
------------------------------------------------------------
# ~/.bash_profile: executed by bash(1) for login shells.

# set up your environment
[ -r ~/.bashrc ] && . .bashrc

# now run any interresting commands you might like

# eg allow messages by default
mesg y
------------------------------------------------------------


With all the interesting stuff being in .bashrc:
------------------------------------------------------------
# ~/.bashrc: executed by bash(1) for non-login shells.

# Include system-wide defaults
. /etc/ENV-bash

#######
# Path set up.
#   Edit to suit your taste
#######

# $SYSPATH is what is normally on your path
PATH=$SYSPATH

# If you want to use the pbmplus toolkit, you need to have /usr/bin/pbmplus
# on your path.  Uncomment the line below.
#PATH="$PATH:/usr/bin/pbmplus"

# Some people like having . on their path, others consider it a security
# hazard. Comment out the following line if you don't like .
PATH="$PATH:."

export PATH


# Uncomment these two lines if you want a more verbose prompt
#PS1='\h:\w\$ '
#export PS1


# aliases and functions (because speeling mishtaks happen)
alias sl='ls'
alias mroe='more'


# default file permissions
umask 022
------------------------------------------------------------



Then, the user's .xsession just sources .bashrc, and everything works.


Notice that this whole scheme is idempotent.


Austin


Reply to: