ubuntu下环境变量详解 bashrc, profile, environment
2017-07-27 20:44
459 查看
在Ubuntu中有如下几个文件可以设置环境变量
/etc/profile:在登录时,操作系统定制用户环境时使用的第一个文件,此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.
/etc/environment:在登录时操作系统使用的第二个文件,系统在读取你自己的profile前,设置环境文件的环境变量
~/.profile:在登录时用到的第三个文件是.profile文件,每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件.
/etc/bashrc:为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取.
~/.bashrc:该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该该文件被读取.
通常设置环境变量有三种方法:
一、临时设置
export PATH=/home/yan/share/usr/local/arm/3.4.1/bin:$PATH
二、当前用户的全局设置
打开~/.bashrc,添加行:
export PATH=/home/yan/share/usr/local/arm/3.4.1/bin:$PATH
使生效
source .bashrc
三、所有用户的全局设置
$ vim /etc/profile
在里面加入:
export PATH=/home/yan/share/usr/local/arm/3.4.1/bin:$PATH
使生效
source profile
测试 echo $PATH
详细原文出自 http://blog.sina.com.cn/s/blog_4b2169480100sklr.html
/etc/profile:在登录时,操作系统定制用户环境时使用的第一个文件,此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.
/etc/environment:在登录时操作系统使用的第二个文件,系统在读取你自己的profile前,设置环境文件的环境变量
~/.profile:在登录时用到的第三个文件是.profile文件,每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件.
/etc/bashrc:为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取.
~/.bashrc:该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该该文件被读取.
通常设置环境变量有三种方法:
一、临时设置
export PATH=/home/yan/share/usr/local/arm/3.4.1/bin:$PATH
二、当前用户的全局设置
打开~/.bashrc,添加行:
export PATH=/home/yan/share/usr/local/arm/3.4.1/bin:$PATH
使生效
source .bashrc
三、所有用户的全局设置
$ vim /etc/profile
在里面加入:
export PATH=/home/yan/share/usr/local/arm/3.4.1/bin:$PATH
使生效
source profile
测试 echo $PATH
详细原文出自 http://blog.sina.com.cn/s/blog_4b2169480100sklr.html
相关文章推荐
- ubuntu下环境变量详解 bashrc, profile, environment
- ubuntu下环境变量详解 bashrc, profile, environment
- ubuntu下环境变量详解 bashrc, profile, environment
- ubuntu profile-environment-bashrc 添加环境变量
- /etc/profile,/etc/environment,.bash_profile及.bashrc等与环境变量有关的文件的比较
- bash配置文件/etc/profile,/etc/bashrc,~/.bash_profile,~/.bashrc详解及修改PATH环境变量
- Linux环境变量文件environment, profile, bashrc含义
- 解决ubuntu下修改环境变量profile后报错,很多常用命令都用不了
- linux中export、ofile、bashrc、bash_profile各种环境变量文件
- Linux下环境变量配置方法梳理(.bash_profile和.bashrc的区别)
- Linux中环境变量文件profile、bashrc、bash_profile之间的区别和联系
- linux的环境变量文件enviroment 、profile、bashrc和.bashrc以及.bash_profile
- linux的export命令和profile,.bashrc,bash.profile各种环境变量文件
- Linux中环境变量文件profile、bashrc、bash_profile之间的区别和联系
- Ubuntu 用/ect/profile文件配置JAVA环境变量
- Ubuntu系统环境变量详解PATH
- Linux环境变量设置中配置文件分析(/etc/profile,~/.bashrc等)(转)
- 转:关于环境变量,profile ,bash_profile ,bashrc
- linux的环境变量文件enviroment 、profile、bashrc和bash_profile的区别
- Ubuntu中设置环境变量详解