How to set environment variable globally on Linux - 在Linux 上如何設定環境變數

Set up Environment Variable for all user on Linux

解法方法:

sudo nano /etc/environment

e.g.

ENV_1=abcxyz
ENV_SECRET="This is the secret"

之後reboot 個 System

sudo reboot now

用以下指令去試下有沒有成功加這個新的 environment variable

echo $ENV_1

Hope you find it useful

Chi Yau
Chi Yau
Software Engineer

Interested on Learning new stuff and experience sharing