参考: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. HR数据分析常用的50个公式

    HR数据分析常用的50个公式 HR经常需要和数据打交道,如入职率.离职率.加班费计算等.虽然日常工作中,单个数据的计算并不麻烦,但几十上百个累计在一起,确实很容易混淆,甚至计算失误.今天小编急HR之所 ...

  2. 【KMP】POJ 2185 Milking Grid -- Next函数的应用

    题目链接:http://poj.org/problem?id=2185 题目大意:求一个二维的字符串矩阵的最小覆盖子矩阵,即这个最小覆盖子矩阵在二维空间上不断翻倍后能覆盖原始矩阵. 题目分析:next ...

  3. 静态站点生成器-html-markdown-hugo

    推荐指数:

  4. 【WAP触屏】YouKu视频弹窗播放组件

    (function(window){ /* youku api : http://open.youku.com/tools 调用方法 : LM_youkuPop.open('XODI5Mzk3MDAw ...

  5. git的使用学习(四)git的远程仓库

    1.远程仓库介绍 到目前为止,我们已经掌握了如何在Git仓库里对一个文件进行时光穿梭,你再也不用担心文件备份或者丢失的问题了. 可是有用过集中式版本控制系统SVN的童鞋会站出来说,这些功能在SVN里早 ...

  6. RabbitMQ官方教程五 Topic(GOLANG语言实现)

    在上一教程中,我们改进了日志记录系统. 我们没有使用只能进行虚拟广播的fanout交换器,而是使用直接交换器,并有可能选择性地接收日志. 尽管使用直接交换改进了我们的系统,但它仍然存在局限性-它不能基 ...

  7. 035 Android Volley框架进行网络请求

    1.volley入门介绍 开发Android应用的时候不可避免地都需要用到网络技术,而多数情况下应用程序都会使用HTTP协议来发送和接收网络数据.Android系统中主要提供了两种方式来进行HTTP通 ...

  8. python 之 subprocesss 模块、configparser 模块

    6.18 subprocesss 模块 常用dos命令: cd : changedirectory 切换目录 ​ tasklist:查看任务列表 ​ tasklist | findstr python ...

  9. C++打印乘法表

    #include <iostream> #include <Windows.h> #include <iomanip> using namespace std; i ...

  10. PAT(B) 1051 复数乘法(Java)

    题目链接:1051 复数乘法 (15 point(s)) 参考博客:1051 复数乘法(PAT 乙级 C++实现)-guangjinzheng 题目描述 复数可以写成 (A+Bi) 的常规形式,其中 ...