Chinaunix首页 | 论坛 | 博客
  • 博客访问: 854802
  • 博文数量: 63
  • 博客积分: 1317
  • 博客等级: 中尉
  • 技术积分: 686
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-30 22:07
文章分类

全部博文(63)

文章存档

2015年(4)

2014年(1)

2013年(1)

2012年(2)

2011年(54)

2010年(1)

我的朋友

分类: 系统运维

2011-08-19 11:06:40

摘自IBM官方网站,原文地址:

The /etc/environment, /etc/profile, and .profile files are run once at login time. The .env file, on the other hand, is run every time you open a new shell or a window.

    * /etc/environment file
      The first file that the operating system uses at login time is the /etc/environment file. The /etc/environment file contains variables specifying the basic environment for all processes.
    * /etc/profile file
      The second file that the operating system uses at login time is the /etc/profile file.
    * .profile file
      The .profile file is present in your home ($HOME) directory and lets you customize your individual working environment.
    * .env file
      A fourth file that the operating system uses at login time is the .env file, if your .profile contains the following line: export ENV=$HOME/.env



/etc/environment file

The first file that the operating system uses at login time is the /etc/environment file. The /etc/environment file contains variables specifying the basic environment for all processes.

When a new process begins, the exec subroutine makes an array of strings available that have the form Name=Value. This array of strings is called the environment. Each name defined by one of the strings is called an environment variable or shell variable. The exec subroutine allows the entire environment to be set at one time.

When you log in, the system sets environment variables from the /etc/environment file before reading your login profile, named .profile. The following variables make up the basic environment:

HOME         The full path name of the user's login or HOME directory. The login program sets this to the name specified in the /etc/passwd file.
LANG         The locale name currently in effect. The LANG variable is initially set in the /etc/profile file at installation time.
NLSPATH         The full path name for message catalogs.
LOCPATH         The full path name of the location of National Language Support tables.
PATH         The sequence of directories that commands, such as sh, time, nice and nohup, search when looking for a command whose path name is incomplete.
TZ         The time zone information. The TZ environment variable is initially set by the /etc/profile file, the system login profile.



/etc/profile file

The second file that the operating system uses at login time is the /etc/profile file.

The /etc/profile file controls system-wide default variables, such as:

    * Export variables
    * File creation mask (umask)
    * Terminal types
    * Mail messages to indicate when new mail has arrived

The system administrator configures the /etc/profile file for all users on the system. Only the system administrator can change this file.

The following example is a typical /etc/profile file:

#Set file creation mask
unmask 022
#Tell me when new mail arrives
MAIL=/usr/mail/$LOGNAME
#Add my /bin directory to the shell search sequence
PATH=/usr/bin:/usr/sbin:/etc::
#Set terminal type
TERM=lft
#Make some environment variables global
export MAIL PATH TERM

For detailed information about the /etc/profile file, see the AIX 5L™ Version 5.3 Files Reference .




.profile file

The .profile file is present in your home ($HOME) directory and lets you customize your individual working environment.

Because the .profile file is hidden, use the ls -a command to list it.

After the login program adds the LOGNAME (login name) and HOME (login directory) variables to the environment, the commands in the $HOME/.profile file are executed if the file is present. The .profile file contains your individual profile that overrides the variables set in the /etc/profile file. The .profile file is often used to set exported environment variables and terminal modes. You can customize your environment by modifying the .profile file. Use the .profile file to control the following defaults:

    * Shells to open
    * Prompt appearance
    * Keyboard sound

The following example is a typical .profile file:

PATH=/usr/bin:/etc:/home/bin1:/usr/lpp/tps4.0/user::
epath=/home/gsc/e3:
export PATH epath
csh

This example has defined two path variables (PATH and epath), exported them, and opened a C shell (csh).




.env file

A fourth file that the operating system uses at login time is the .env file, if your .profile contains the following line: export ENV=$HOME/.env

The .env file lets you customize your individual working environment variables. Because the .env file is hidden, use the ls -a command to list it. For more information about the ls command, see ls. The .env file contains the individual user environment variables that override the variables set in the /etc/environment file. You can customize your environment variables as desired by modifying your .env file.

The following example is a typical .env file:

export  myid=`id | sed -n -e 's/).*$//' -e 's/^.*(//p'`
#set prompt: login & system name & path
if [ $myid = root ]
        then    typeset -x PSCH='#:\${PWD}> '
                PS1="#:\${PWD}> "
        else    typeset -x PSCH='>'
                PS1="$LOGNAME@$UNAME:\${PWD}> "
                PS2=">"
                PS3="#?"
fi
export PS1 PS2 PS3
#setup my command aliases
alias   ls="/bin/ls -CF" \
        d="/bin/ls -Fal | pg" \
        rm="/bin/rm -i" \
        up="cd .."

Note: When modifying the .env file, ensure that newly created environment variables do not conflict with standard variables such as MAIL, PS1, PS2, and IFS.
阅读(4118) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~