Environment variable.
A variable that stores settings related to system operation.
환경 변수
시스템 동작과 관련된 설정 값을 저장하는 변수.
Local environment variable.
The variable available in the current shell only.
지역(local) 환경 변수
현재 쉘에서만 사용 가능한 변수
$ TEST1=value1
$ set | grep TEST1
Global environment variable.
The variable available in the current shell and sub shell.
전역(global) 환경 변수
현재 쉘과 서브 쉘에서 사용 가능한 변수
$ export TEST2=value2
$ set | grep TEST2
Remove Environment variable.
환경 변수 제거.
$ unset TEST1
Characteristic
특징
1. The local/global environment variable that you set is only available in the current session. If you want to use it at the next login, you can register it in the configuration file.
1. 설정한 지역/전역 환경 변수는 현재 세션에서만 사용 가능하다. 만약 다음 로그인 시에도 사용하고 싶다면 설정 파일에 등록하면 된다.
e.g. To reflect all accounts in the system, register in /etc/profile.
e.g. 해당 시스템 내 모든 계정에 반영 하려면 /etc/profile에 등록한다.
2. The environment variables set in the child process can not affect the parent process. When using global variables, the parent can affect the child.
2. 자식 프로세스에서 설정한 환경 변수는 부모 프로세스에 영향을 줄 수 없다. 전역 변수 사용 시 부모가 자식에게 영향을 줄 수 있다.
$ bash
$ BBB=1
$ export CCC=1
$ exit
$ set | grep BBB; set | grep CCC;
$ env | grep BBB; env | grep CCC;
$
3. When setting the global environment variable, it is also reflected in the local environment variable(overwrite).
3. 전역 환경 변수 설정 시, 지역 환경 변수에도 반영된다(덮어쓰기).
$ BB=1
$ set | grep BB; env | grep BB;
BB=1
$ export BB=2
$ set | grep BB; env | grep BB;
BB=2
BB=2
4. When setting the local environment variable, all global environment variables with the same name are reflected (overwrite).
4. 지역 환경 변수 설정 시, 전역 환경 변수에 동일한 이름이 있다면 모두 반영된다(덮어쓰기).
$ export BB=2
$ set | grep BB; env | grep BB;
BB=2
BB=2
$ BB=3
$ set | grep BB; env | grep BB;
BB=3
BB=3
5. When removing environment variables, global/local environment variables are removed together.
5. 환경 변수 제거 시 전역/지역 환경 변수가 함께 제거된다.
$ set | grep BB; env | grep BB;
BB=3
BB=3
$ unset BB
$ set | grep BB; env | grep BB;
$