Linux 配置环境变量及/etc/profile和/root/.bash_profile区别

/etc/profile 是全局变量用于所有用户
~/.bash_profile 是当前用户变量

编辑vim ~/.bash_profile
生效 source ~/.bash_profile

例如配置python 环境变量

下载安装完python后,可以建立软链接,将Python路径链接到 /usr/bin中,
在 vim ~/.bash_profile 文件中path后边加上 /usr/bin就可以读到python了,在执行命令时就不需要进入Python 路径再用pip 和python

软链接,相当于快捷键,就像windows上的桌面图标,可以直接在桌面图标执行命令

ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
图省事儿,把红线部分全加到配置里了
在这里插入图片描述
/etc/profile和/root/.bash_profile区别
/etc/profile,优先级最高,是全局的,是私有的,用于整个系统所有用户
~/.bashrc和 ~/.bash_profile, ~/.profile 用于各个用户,这里的"~"符号就是各当前用户的$HOME
~/.bash_profile 和 ~/.profile 只在登陆时读取一次
~/.bashrc 每次都读取
~/.bash_profile 和 ~/.profile 的区别在于
bash 只读取~/.bash_profile;而对于 ~/.profile 来说,不光bash, 其他shell 也读 ~/.profile

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值