Handbook:Parts/Working/EnvVar/ko

도입부
환경 변수는 하나 이상의 프로그램에서 사용하는 정보가 들어있는 이름을 붙인 객체입니다. 수많은 사람은(그리고 리눅스를 처음 접하는) 약간 이상하거나 관리하기가 힘들다는 점을 발견할 것입니다. 그러나, 이렇게 생각하는 것 자체가 실수입니다. 하나 이상의 프로그램의 환경 설정을 바꿀 때 환경 변수를 사용하면 쉽게 처리할 수 있습니다.

중요 예제
다음 표에서는 리눅스 시스템에서 사용하는 많은 변수들을 나열하였고 용도를 설명합니다. 예제 값은 표 다음에 보여드립니다.

아래에서는 이들 변수에 대한 정의의 예를 보실 수 있습니다:

env.d 디렉터리
To centralize the definitions of these variables, Gentoo introduced the directory. Inside this directory a number of files are available, such as, , etc. which contain the variables needed by the application mentioned in their name.

For instance, when is installed, a file called  was created by the ebuild which contains the definitions of the following variables:

Other distributions might tell their users to change or add such environment variable definitions in or other locations. Gentoo on the other hand makes it easy for the user (and for Portage) to maintain and manage the environment variables without having to pay attention to the numerous files that can contain environment variables.

For instance, when is updated, the  file is updated too without requesting any user-interaction.

This not only benefits Portage, but also the user. Occasionally users might be asked to set a certain environment variable system-wide. As an example we take the http_proxy variable. Instead of messing about with, users can now just create a file (say ) and enter the definition(s) in it:

자체 관리 변수에 동일한 파일을 사용하면, 사용자가 스스로 정의한 변수를 빨리 찾아볼 수 있습니다.

env-update
Several files in define the PATH variable. This is not a mistake: when is executed, it will append the several definitions before it updates the environment variables, thereby making it easy for packages (or users) to add their own environment variable settings without interfering with the already existing values.

The script will append the values in the alphabetical order of the  files. The file names must begin with two decimal digits.

The concatenation of variables does not always happen, only with the following variables: ADA_INCLUDE_PATH, ADA_OBJECTS_PATH , CLASSPATH , KDEDIRS , PATH , LDPATH , MANPATH , INFODIR , INFOPATH , ROOTPATH , CONFIG_PROTECT , CONFIG_PROTECT_MASK , PRELINK_PATH , PRELINK_PATH_MASK , PKG_CONFIG_PATH , and PYTHONPATH. For all other variables the latest defined value (in alphabetical order of the files in ) is used.

It is possible to add more variables into this list of concatenate-variables by adding the variable name to either COLON_SEPARATED or SPACE_SEPARATED variables (also inside an file).

When executing, the script will create all environment variables and place them in (which is used by ). It will also extract the information from the LDPATH variable and use that to create. After this, it will run to recreate the  file used by the dynamical linker.

To notice the effect of immediately after running it, execute the following command to update the environment. Users who have installed Gentoo themselves will probably remember this from the installation instructions:

사용자별 변수
It might not be necessary to define an environment variable globally. For instance, one might want to add and the current working directory (the directory the user is in) to the PATH variable but do not want all other users on the system to have that in their PATH too. To define an environment variable locally, use or :

After logout/login, the PATH variable will be updated.

세션별 변수
때로는 더 엄격한 정의가 필요합니다. 바이너리 자신의 경로를 사용하지 않고 임시로 만든 디렉터리에서 바이너리를 사용할 수 있게 하거나 필요에 따라 잠깐 를 편집할 수도 있습니다.

In this case, just define the PATH variable in the current session by using the command. As long as the user does not log out, the PATH variable will be using the temporary settings.