一. source:

命令是使该文件立刻执行,这样刚才做的修改就可以立即生效了,否则要重新启动系统修改才能生效。(执行其后命令使之立即生效,不用重启)

二.bashrc:

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

/etc/bashrc:为每个运行bash shell的用户执行此文件。当bash shell被打开时,该文件被读取。

2. 用户:~/.bashrc_profile:每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件.

~/.bashrc:该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该文件被读取.(每个用户都有一个.bashrc文件,在用户目录下)

~/bash_logout:当每次退出系统(退出bash shell)时,执行该文件.

3. 在登录Linux时要执行文件的过程如下:

在刚登录Linux时,首先启动 /etc/profile 文件,然后再启动用户目录下的 ~/.bash_profile、 ~/.bash_login或 ~/.profile文件中的其中一个,
执行的顺序为:~/.bash_profile、 ~/.bash_login、 ~/.profile。
如果 ~/.bash_profile文件存在的话,一般还会执行 ~/.bashrc文件。
因为在 ~/.bash_profile文件中一般会有下面的代码:
if [ -f ~/.bashrc ] ; then

. ./bashrc

fi

~/.bashrc中,一般还会有以下代码:
if [ -f /etc/bashrc ] ; then

. /bashrc

fi

所以,~/.bashrc会调用 /etc/bashrc文件。最后,在退出shell时,还会执行 ~/.bash_logout文件。

执行顺序为:/etc/profile -> (~/.bash_profile | ~/.bash_login | ~/.profile) -> ~/.bashrc -> /etc/bashrc -> ~/.bash_logout

4. 以ROS安装后环境配置为例,说明bashrc和source

为方便起见,我们可以在每次打开终端时让系统自动配置好ROS环境变量,方法如下:

echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc  //添加ros indigo启动文件setup.bash到.bashrc文件中,用source启动,每次登陆自动运行.bashrc启动ros
source ~/.bashrc //用source命令运行.bashrc文件,启动ros,或者source /opt/ros/indigo/setup.bash 备注:~/.bashrc 文件末尾
source /opt/ros/indigo/setup.bash
source /home/wang/bzrobot_ws/devel/setup.bash
source /usr/share/gazebo/setup.sh

profile, bashrc, source, setup.*sh的更多相关文章

  1. ros bashrc 无法source setup.sh

    不知道什么时候开始的,莫名其妙首先是QT闪退,无法找到头文件,然后命令行进去catkin无法提示catkin_make 手动source之后就好了 问题出现在bashrc中source失败了 所以检查 ...

  2. ti processor sdk linux am335x evm setup.sh hacking

    #!/bin/sh # # ti processor sdk linux am335x evm setup.sh hacking # 说明: # 本文主要对TI的sdk中的setup.sh脚本进行解读 ...

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

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

  4. profile,bashrc,.bash_profile,.bash_login,.profile,.bashrc,.bash_logout浅析 Part 2

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

  5. [Shell Script]关于source和sh对于脚本执行不同

    当我修改了/etc/profile文件,我想让它立刻生效,而不用重新登录:这时就想到用source命令,如:source /etc/profile对source进行了学习,并且用它与sh 执行脚本进行 ...

  6. linux里source、sh、bash、./有什么区别

    在linux里,source.sh.bash../都可以执行shell script文件,那它们有什么不同吗? ----------- 1.source source a.sh 在当前shell内去读 ...

  7. shell中source与sh区别

    shell中使用source conf.sh,是直接运行conf.sh的命令,不创建子shell,类似与html中include,而sh是则创建子shell, 子shell里面 的变量父shell无法 ...

  8. source 和sh 区别

    sh新建一个子shell进程,变量在主shell中无法获取 source在当前shell中执行脚本,变量在主shell即当前shell中可以获取 例子: 1.新建一个test.sh脚本,内容为:A=1 ...

  9. source、sh、bash

    source.sh.bash../ 执行脚本的区别 1.source命令用法: source FileName 作用:在当前bash环境下读取并执行FileName中的命令.该filename文件可以 ...

随机推荐

  1. 14.list列表

    1).列表的切片 li = ['德玛西亚',[1,2,3],'luokesasi','eson','女神','jingdongi'] l1 = li[0] print(l1) #>>> ...

  2. WebStorm换主题(护眼)

    一.下载喜欢颜色的主题 http://www.phpstorm-themes.com/ 我用的豆沙绿护眼 <scheme name="Solarized Light My" ...

  3. (2)JSTL的fmt国际化标签库

    format标签库:做国际化格式化,分两类 : 国际化核心标签:<fmt:setLocale>.<fmt:bundle>.<fmt:setBundle>.<f ...

  4. word转HTML在layuiadmin中锚点调转问题

    前言: 在以前我们讲过把word转成HTML移植入自己的web项目使用:Word转html并移植到web项目 正文: 发现如果在layuiadmin框架中,页面里锚点跳转时会不正常(会跳转到新页面): ...

  5. shell脚本,awk常见初始化变量的题目。

    文件 内容如下 clone=line1gb=line1gi=line1lib=line1gb=line2gi=line2lib=line2clone=line3gb=line3gi=line3lib= ...

  6. WinPcap过滤串表达式的语法

    注意:这篇文档取自tcpdump的指南.原始的版本 www.tcpdump.org 找到.   wpcap的过滤器是以已声明的谓词语法为基础的.过滤器是一个ASCII字符串,它包含了一个过滤表达式.p ...

  7. html节点类型

    <li> nodeType:节点类型: <br> 1--->Element节点: <br> 3--->Text节点: <br> 8---&g ...

  8. python爬虫(爬取图片)

    python爬虫爬图片 爬虫爬校花网校花的图片 第一步 载入爬虫模块 #载入爬虫模块 import re #载入爬虫模块 import requests #载入爬虫模块 第二步 获得校花网的地址,获得 ...

  9. Python GUI界面开发环境配置:Pycharm+PyQt5

    通过DoS命令行执行如下命令,可能需要管理员权限. 检查Python版本:python 更新pip版本:python -m pip install --upgrade pip 安装PyQt5: pip ...

  10. vuex相关知识点

    vuex简单理解转载博客 vuex从入门到入门------state:从 store 实例中读取状态最简单的方法就是在计算属性中返回某个状态------Getters:可以很容易地在任何组件中使用它- ...