一. 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. html中常见符号的代码表示

    HTML中空格的集中代码表示: HTML中空格   不断行的空白(1个字符宽度)     半个空白(1个字符宽度)     一个空白(2个字符宽度)     窄空白(小于1个字符宽度)   其他常见的 ...

  2. 关于Java IO流学习总结

    一.IO流的三种分类方式 1.按流的方向分为:输入流和输出流 2.按流的数据单位不同分为:字节流和字符流 3.按流的功能不同分为:节点流和处理流     二.IO流的四大抽象类: 字符流:Reader ...

  3. vsftp配置日志及其启用本地时间

    vsftp配置日志及其启用本地时间 1. 启用vsftp日志 xferlog_enable=YES xferlog_std_format=YES xferlog_file=/var/log/xferl ...

  4. Spring框架中的aop操作之二 通过配置文件实现增强

    aop表达式写法 配置文件代码: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns=&q ...

  5. 【DB_MySQL】查询语句中各子句的执行顺序

    1. FROM 指明查询来源 2. WHERE筛选元组 3. GROUP BY进行分组 4. HAVING 筛选分组 5. SELECT 投影出指定的字段列 6. ORDER BY 对结果集排序 7. ...

  6. 文件操作-touch

    本文来给大家介绍另外一个比较常用的命令--touch命令,Linux touch命令 主要用来修改文件或者目录的时间属性,或者建立新文件. 转载自https://www.linuxdaxue.com/ ...

  7. module_param

    该宏定义在include/linux/moduleparam.h中 #define ___module_cat(a,b) __mod_ ## a ## b #define __module_cat(a ...

  8. python基础学习笔记——collections模块

    在内置数据类型(dict.list.set.tuple)的基础上,collections模块还提供了几个额外的数据类型:Counter.deque.defaultdict.namedtuple和Ord ...

  9. mysql 处理数据库中的重复行

    1.对于主键和唯一索引,可以用IGNORE关键字,遇到重复记录会直接忽略插入记录,返回0.insert ignore into table_name ('id','name') values (1,' ...

  10. conda管理包

    清理 conda clean --lock --tarball --package (安装包) 安装或更新包 conda install numpy=1.9.3 conda update numpy= ...