首页 > 科技 > Environment variables

Environment variables

2006年5月10日 10点17分 发表评论 阅读评论

All the processes share the environment variables, as the local variables.when log out, these configuration wil be invalid. So, it is usually to define the environment setting in “.profile” files.The system administrator have the privilege to pre-define some global variables in the “/etc/profile”, which means for every time the users log in, the system will be initialized by this variables exiting in the “/etc/profile”.

The global variables is always using upcase letters for distinction of other local variables.

Pay attention, issue the “export” command before the variables are used, otherwise, the variables do not take any effect in the processes.

1.Set the environment variables:
# VARIABLE_NAME=value;export VARIABLE_NAME
or # VARIABLE_NAME=value
# export VARIABLE_NAME

2.Show the value:
# echo $VARIABLE_NAME
List all the environment variables:
# env

3.Clear/unset the variables:
# unset $VARIABLE_NAME

HOME: declared in the last 2 items of “/etc/passwd”

IFS: default separation character of Shell, for example:
# export IFS=: (change the default setting “space” to “:”)
# echo $PATH
/sbin /bin /usr/bin /usr/sbin

LOGNAME: log name

MAIL: path of mail box directory

PATH: the sequence of directory which would have the command executing. The system read from the first item of PATH to the last, and issue the command when found in the directory listed.
Colon (“:”) acts as the separator of PATH line, for example:
# PATH=$HOME/bin:.:/bin:/usr ; export PATH
“.” means current directory.
PATH could be modified as this syntax:
# PATH=$PATH:/$HOME/bin; export PATH

SHELL: default Shell, this information could also be found in “/etc/passwd”

EDITOR: editor, for example,”vi”

PWD: current directory path

MANPATH: Manual directory path, use colon as separator.

How to export all the environment variables togethe?
# set -a

$#: the count of parameter passing to the script
$$: the script’s current PID.
$?: the status to check if the script has error or not. “0” presents ok,other number means troubles have been happened. This variables is very important for debug and testing.

分类: 科技 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.
您必须在 登录 后才能发布评论.