Temporary set and held only in the current terminal (shell).
# 환경변수 설정
Export variable name = value
# Turn Off Environment Variables
Unset $Variable Name
# Check Environment Variables
echo $ variable name
# Check all environment variables
export
Set Linux/Mac Permanent Configuration Variables (Permanent Settings)
.You can set a variable name in the bashrc
file or the.zshrc
file and apply it permanently.
# For the shell (Bash) used by Linux
echo "export variable name=value" >> ~/.bashrc // or corresponding ~/.You can write it down directly on the bashrc file
source ~/.bashrc// apply configuration settings
# For the shell (Zsh) used by the Mac
echo "export variable name=value" >> ~/.zshrc
source ~/.zshrc
Check the shell currently in use
To check the shell currently in use, use the
echo $SHELL
command.
echo $SHELL
프로그램에서 등록된 환경변수 사용 예제
Python:
import os # 환경변수 읽기
my_variable = os.environ.get('환경변수명')
JavaScript (Node.js):
const myVariable = process.env.환경변수명;
Dec 16, 2023
Views 733