zoukankan      html  css  js  c++  java
  • profile, bashrc, source, setup.*sh

    一. 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
  • 相关阅读:
    JSON:JSON对象和JSON数组混排的复杂字符串
    爬虫4:pdf页面+pdfminer模块+demo
    爬虫3:html页面+webdriver模块+demo
    爬虫2:html页面+beautifulsoap模块+post方式+demo
    爬虫1:html页面+beautifulsoap模块+get方式+demo
    IKanalyzer、ansj_seg、jcseg三种中文分词器的实战较量
    【转】linux下如何查看某个软件 是否安装?安装路径在哪
    Linux下通过源码编译安装程序
    【转】rpm包和源码包安装的区别
    linux centos7 安装nginx并启动
  • 原文地址:https://www.cnblogs.com/cj2014/p/3955404.html
Copyright © 2011-2022 走看看