参考: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. 【error】OutOfRangeError (see above for traceback): RandomShuffleQueue

    前言 在使用tensorflow TFRecord的过程中,读取*.tfrecord文件时出现错误,本文解决这个错误. 错误描述: OutOfRangeError (see above , curre ...

  2. 【Chrome插件】右键搜--多站点搜索

    写在前面:看文章前请先看文章写作时间,避免浪费时间.2019-09-10 使用场景 一次输入,同时在多个网站进行内容搜索,比如一键在不同网站搜索电影.一键获取多个搜索引擎的搜索结果. 操作演示 评分 ...

  3. Python机器学习基础教程-第1章-鸢尾花的例子KNN

    前言 本系列教程基本就是摘抄<Python机器学习基础教程>中的例子内容. 为了便于跟踪和学习,本系列教程在Github上提供了jupyter notebook 版本: Github仓库: ...

  4. ubuntu18.04 安装 wps2019

    安装包可以从官网下载 linuxidc@linuxidc:~/linuxidc.com$ sudo dpkg -i *.deb [sudo] linuxidc 的密码: 正在选中未选择的软件包 wps ...

  5. python实践项目二:列表转字符串

    将列表各元素转换为字符串并以规定形式返回. 假定有下面这样的列表:spam = ['apples', 'bananas', 'tofu', 'cats'],将其转换成字符串:'apples, bana ...

  6. ubuntu16.04 下Mongo数据库搭建

    一 数据库安装 1.下载自己需要的数据库版本和系统,下载地址:https://www.mongodb.com/download-center/community . 本文下载的为ubuntu 16.0 ...

  7. NGINX---一次阿里云宝塔开发flask经历

    1.放行端口问题 不但需要在阿里云官网服务器控制台放行端口,还需要在宝塔里面放行端口 2.nginx 宝塔默认的用户是www 句法: user user [group]; 默认: 用户无人; 语境: ...

  8. django使用pyecharts(3)----django加入echarts_定时全量更新

    三.Django 前后端分离_定时全量更新图表 1.安装 djangorestframework linux pip3 install djangorestframework windows pip ...

  9. Django基础之django分页

    一.Django的内置分页器(paginator) view from django.shortcuts import render,HttpResponse # Create your views ...

  10. Jmeter-后置处理器--json提取器

    Token提取: 将token放入全局变量: 将token值设为全局变量,${__setProperty(newtoken,${token},)}  添加请求头部管理器作为全局使用,将变量token使 ...