site infoHacknerd | Tech Blog
blog cover

🚃 [Mac] 环境变量

Mac

语法

shellCopy

#中间用冒号隔开
export PATH=$PATH:<PATH 1>:<PATH 2>:<PATH 3>:------:<PATH N>

加载顺序

etc/profile > /etc/paths > ~/.bash_profile > ~/.bash_login > ~/.profile > ~/.bashrc

1. etc/profile (全局)

2. /etc/paths (全局(公有)配置,不管是哪个用户,登录时都会读取该文件。)

3. ~/.bash_profile

4. ~/.bash_login

5. ~/.profile

6. ~/.bashrc

添加环境变量

shellCopy
> vim ~/.bash_profile

## .bash_profile
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
##:wq

> source ~/.bash_profile 加载环境

Contents

  • 语法
  • 加载顺序
  • 添加环境变量

2024/05/10 03:23