在添加环境变量的时候,我们会去修改配置文件

如果留意过,网上博文,有些在/etc/profile文件中配置的,有些是在~./bash_profile文件中配置的,等等

那么,/etc/profile、~/.profile、~/.bashrc、~./bash_profile这几个配置文件有什么区别呢?

~/.profile ~/.bashrc和~./bash_profile

.bashrc

The individual per-interactive-shell startup file.

这个文件主要保存个人的一些个性化设置,如命令别名、路径等。定义了路径,语言,命令别名(使用rm删除命令时总是加上-i参数需要用户确认,使用ls命令列出文件列表时加上颜色显示)。每次修改.bashrc后,使用source ~/.bashrc就可以立刻加载修改后的设置,使之生效。一般会在.bash_profile文件中显式调用.bashrc。

登陆linux启动bash时首先会去读取/.bash_profile文件,里面会调用/.bashrc,这样/.bashrc也就得到执行了,你的个性化设置也就生效了

全局profile和用户下的~/.profile

用户可以在Profile文件中加入环境变量,比如JAVA_HOME...这样重新登录之后,这些环境变量都会得以设置,不用每次都手工设置。

Unix/Linux有两个profile文件

1./etc/profile:是全局profile文件,设置后会影响到所有用户

2./home/username/.profile或.bash_profile是针对特定用户的,可以针对用户,来配置自己的环境变量。

注意:profile是unix上才有的;bash_profile是Linux下有的(Linux下,用户目录没有.profile文件)

/home/username/.profile或.bash_profile,都是隐藏文件,需要使用ls -a才能看到。

Bash登陆(login)的时候,Profile执行的顺序

1)先执行全局Profile, /etc/profile

接着bash会检查使用者的HOME目录中,是否有 .bash_profile 或者 .bash_login或者 .profile,若有,则会执行其中一个,执行顺序为:

.bash_profile 最优先 > .bash_login其次 > .profile 最后

总之,就是全局或者局部,他们之间有调用关系及调用优先级

参考:https://www.jianshu.com/p/b39fd35e2360

linux的/etc/profile、~/.profile、~/.bashrc、~./bash_profile这几个配置文件的更多相关文章

  1. /etc/rc.local ; /etc/init.d ;/etc/profile;/etc/bashrc;~/.bash_profile;~/.bashrc;~/.bash_logout

    1. /etc/rc.local 这是使用者自订开机启动程序,把需要开机自动运行的程序写在这个脚本里. 把脚本程序写在/etc/rc.d/init.d/目录下也可以  在完成 run level 3 ...

  2. /etc/profile /etc/bashrc ~/.bash_profile ~/.bashrc ~/.bash_logout 说明及区别

    /etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行. 并从/etc/profile.d目录的配置文件中搜集shell的设置. /etc/bashrc:为每一 ...

  3. etc/profile /etc/bashrc ~/.bash_profile ~/.bashrc等配置文件区别

    什么是交互式shell和非交互式shell,什么是login shell 和non-login shell. 交互式模式:就是shell等待你的输入,并且执行你提交的命令.这种模式被称作交互式是因为s ...

  4. Linux profile1,bashrc,.bash_profile,.bash_login,.profile,.bashrc,.bash_logout浅析 Part1

    profile,bashrc,.bash_profile,.bash_login,.profile,.bashrc,.bash_logout浅析 Part 1   by:授客 QQ:103355312 ...

  5. linux关于profile 、bashrc 、.bash_profile、.bashrc的区别

    linux关于profile .bashrc ..bash_profile..bashrc的区别 - /etc/profile /etc/bashrc ~/.bash_profile ~/.bashr ...

  6. Linux 启动时profile、bashrc、~/.bash_profile、~/.bashrc、~/.bash_profile执行顺序以及文件说明

    Linux 启动时profile.bashrc.~/.bash_profile.~/.bashrc.~/.bash_profile执行顺序以及文件说明 一.执行顺序 登录linux时,/etc/pro ...

  7. linux下/etc/profile /etc/bashrc /root/.bashrc /root/.bash_profile这四个配置文件的加载顺序

    目录 一.关于linux配置文件 二.验证四个配置文件的加载顺序 三.结论 一.关于linux配置文件 1.linux下主要有四个配置文件:/etc/profile ./etc/bashrc ./ro ...

  8. Linux中profile与bashrc的作用

    文章同步发表在博主网站朗度云,传输门:http://www.wolfbe.com/detail/201608/278.html 在Linux系统上,我们会看到类似于profile和bashrc的文件, ...

  9. profile bashrc bash_profile之间的区别和联系

    profile bashrc bash_profile之间的区别和联系 博客分类: Linux   执行顺序为:/etc/profile -> (~/.bash_profile | ~/.bas ...

随机推荐

  1. Spring Cloud 微服务开发系列整理

    Spring Boot 系列精选 Spring Boot 自定义 starter Spring Boot 整合 mybatis-plus Spring Boot 整合 spring cache Spr ...

  2. Java的多线程实现生产/消费模式

    Java的多线程实现生产/消费模式 在Java的多线程中,我们经常使用某个Java对象的wait(),notify()以及notifyAll() 方法实现多线程的通讯,今天就使用Java的多线程实现生 ...

  3. Mac10.12下Python3.4调用oracle

    最近,由于项目的短信平台对其它浏览器兼容,只支持IE,但是我们移动端自动化需要测试iphone手机,必须要连接MAC系统下,众所周知,MAC对IE的不友好性,故没办法通过短信平台在UI层自动化获取短信 ...

  4. 安装composer时,提示 /usr/bin/env: php: 没有那个文件或目录

    今晚在Ubuntu环境上安装composer后,想查看下是否安装成功,使用composer -v,结果提示:/usr/bin/env: php: 没有那个文件或目录 现说说我的解决办法: 它提示的原因 ...

  5. SSM —— 注解解析

    @Component是所有受Spring 管理组件的通用形式,@Component注解可以放在类的头上,@Component不推荐使用. @Controller通过@Controller注解说明该类非 ...

  6. cmd黑客入侵命令大全

    nbtstat -A ip 对方136到139其中一个端口开了的话,就可查看对方最近登陆的用户名(03前的为用户名)-注意:参数-A要大写 tracert -参数 ip(或计算机名) 跟踪路由(数据包 ...

  7. 最新webstorm

    https://blog.csdn.net/hdp134793/article/details/81530472 最新webstorm,立即装,还有小盒子要弄个备份的,还有公交卡 2019-3-17( ...

  8. jupyter notebook修改默认路径和浏览器

    1.jupyter notebook --generate-config 2.修改jupyter_notebook_config.py配置文件 3.修改默认路径: c.NotebookApp.note ...

  9. 在Linux系统安装Nodejs 最简单步骤

    1.去官网下载和自己系统匹配的文件: 英文网址:https://nodejs.org/en/download/ 中文网址:http://nodejs.cn/download/ 通过  uname -a ...

  10. matlab函数int2str, num2str, str2num

    函数名:int2str 功能:将整数值转换为字符串 输入格式:str = int2str(N) 备注:就将该值四舍五入后转换为字符串,接受向量和矩阵输入. 如果是向量和矩阵输入,列数字之间会补加两个空 ...