参考:What does 'source' do?

前言

当我们修改了/etc/profile文件,并想让它立刻生效,而不用重新登录,就可以使用source命令,如source /etc/profile。

source命令

source是一个内建命令。下面命令执行环境是Ubuntu 16.04.3 LTS下的bash。事实上source命令并不是bash(Bourne shell)内置的,他是GNU项目后来扩展引入的。其他shell不确定是否有source命令。

Linux命令——type、which、whatis、apropos、whereis、find

root@ubuntu:~# type source
source is a shell builtin

除了type可以查看source,help命令也可以

root@ubuntu:~# help source
source: source filename [arguments]
Execute commands from a file in the current shell. Read and execute commands from FILENAME in the current shell. The
entries in $PATH are used to find the directory containing FILENAME.
If any ARGUMENTS are supplied, they become the positional parameters
when FILENAME is executed. Exit Status:
Returns the status of the last command executed in FILENAME; fails if
FILENAME cannot be read.

但是man,whatis命令就不可以查看source命令了

root@ubuntu:~# man source
No manual entry for source
root@ubuntu:~# whatis source
source: nothing appropriate.

考虑到和其他shell的兼容性,最好使用点号 . 。点号.是source的同义词,为啥使用source而不是.,可能的原因是:写.有时候看起来像是写错了的命令,用source更直观。

但是从简洁的角度看,实在没必要打那么多字来实现一个和.一样的功能

./ 和 source 不完全一样

  • ./script runs the script as an executable file, launching a new shell to run it
  • source script reads and executes commands from filename in the current shell environment

Note: ./script is not  . script, but . script == source script

Linux命令——source的更多相关文章

  1. Linux命令:source

    语法 source filename 说明 . 的同义词

  2. Linux命令随笔

    Linux命令总结 man ==命令帮助; help ==命令的帮助(bash的内置命令); ls ==list,查看目录列表; -ld:查看目录权限; -l:(long)长格式显示属性; -F:给不 ...

  3. 我常用的那些linux命令

    我常用的那些linux命令 用linux也有些年头了,说来也忏愧,说是有些年头了,其实也还是个不长进的主.记得第一次接触linux是boss跟我说的怎么操作,什么编辑模式,按i,a,o进入编辑模式.在 ...

  4. Java开发必会的Linux命令

    Java开发必会的Linux命令 作为一个Java开发人员,有些常用的Linux命令必须掌握.即时平时开发过程中不使用Linux(Unix)或者mac系统,也需要熟练掌握Linux命令.因为很多服务器 ...

  5. [z]Java开发必会的Linux命令

    1.查找文件 find / -name filename.txt 根据名称查找/目录下的filename.txt文件. find . -name "*.xml" 递归查找所有的xm ...

  6. Linux命令整理中...

    Linux命令整理中... 最常用命令(我最近最常用的一般放在前面tipsbychsry) clear 清屏 date 显示日期 cal 显示日历 cal 2014 显示2014年的日历 shutdo ...

  7. Linux 命令小记

    1. pidof 进程名 :获取进程的pid,例如 pidof memcached 得到5333 2. unset Shell变量 :取消设置一个shell变量,从内存和shell的导出环境中删除它, ...

  8. LINUX命令总结 -------来自 水滴娃娃 的CSDN

    LINUX命令总结 标签: LINUX命令总结 2014-01-27 15:54 41039人阅读 评论(1) 收藏 举报  分类: linux(1)  版权声明:本文为博主原创文章,未经博主允许不得 ...

  9. [Android ] linux命令英文缩写的含义(方便记忆)

    du -sh */ reference to : http://blog.chinaunix.net/uid-27164517-id-3299073.html linux常用命令的英文单词缩写 命令缩 ...

随机推荐

  1. Flink 滑动窗口使用触发器会触发多个窗口的计算

    之前有小伙伴在群里说:滑动窗口使用触发器让每条数据都触发一次计算 但是他并没有得到预期的结果:每条数据都触发一次计算,输出一条结果,而是每天数据都输出了很多条结果 为什么会这样呢? 写了个小案例,来解 ...

  2. 【源码解析】Flink 是如何基于事件时间生成Timestamp和Watermark

    生成Timestamp和Watermark 的三个重载方法介绍可参见上一篇博客: Flink assignAscendingTimestamps 生成水印的三个重载方法 之前想研究下Flink是怎么处 ...

  3. WebService学习总结(三)——使用JDK开发WebService(转)

    一.WebService的开发手段 使用Java开发WebService时可以使用以下两种开发手段 1. 使用JDK开发(1.6及以上版本) 2.使用CXF框架开发(工作中) 二.使用JDK开发Web ...

  4. Python - Django - ORM 常用字段

    AutoField: int 自增列,必须填入参数 primary_key=True 如果没有写 AutoField,则会自动创建一个列名为 id 的列 from django.db import m ...

  5. this page isn't working (ERR_EMPTY_RESPONSE)

    特定情况触发了PHP的Call to undefined function(函数不存在)的Fatal error(致命错误),PHP异常终止执行,Apache收到PHP的异常信号时,认为PHP处理请求 ...

  6. (十三)class文件结构:常量池(转)

    Class类文件的结构 全局规范 1.任何一个Class文件都对应着唯一一个类或接口的定义信息,但反过来说,类或接口并不一定都得定义在文件里(譬如类或接口也可以通过类加载器直接生成).本章中,只是通俗 ...

  7. 【Leetcode_easy】908. Smallest Range I

    problem 908. Smallest Range I solution: class Solution { public: int smallestRangeI(vector<int> ...

  8. mysql函数IFNULL的使用替换递归方法

    在电商行业经常遇到的问题就是类目与类目以及类目与商品的关系. 如果要查询一级类目下的所有商品 常规做法是先查询该一级类目下所有的二级类目,再由二级类目查询所有的三级类目,直到最后一级,再查询出对应的商 ...

  9. LeetCode 896. 单调数列(Monotonic Array)

    896. 单调数列 896. Monotonic Array 题目描述 如果数组是单调递增或单调递减的,那么它是单调的. 如果对于所有 i<=j,A[i]<=A[j],那么数组 A 是单调 ...

  10. 有助提升编程的几个Python 技巧

    一行代码定义List 定义某种列表时,写For 循环过于麻烦,幸运的是,Python有一种内置的方法可以在一行代码中解决这个问题. 下面是使用For循环创建列表和用一行代码创建列表的对比. x = [ ...