linux中source

命令用法:
source FileName
作用:在当前bash环境下读取并执行FileName中的命令。
注:该命令通常用命令“.”来替代。
如:source /etc/profile 与 . /etc/profile是等效的。
注意:source命令与shell scripts的区别是,
source在当前bash环境下执行命令,而scripts是启动一个子shell来执行命令。这样如果把设置环境变量(或alias等等)的命令写进scripts中,就只会影响子shell,无法改变当前的BASH,所以通过文件(命令列)设置环境变量时,要用source 命令。

此文章来之:http://zhidao.baidu.com/question/378390415.html

---------------------------------------------------------------
source 命令是 bash shell 的内置命令,从 C Shell 而来。
source 命令的另一种写法是点符号,用法和 source 相同,从Bourne Shell而来。
source 命令可以强行让一个脚本去立即影响当前的环境。
source 命令会强制执行脚本中的全部命令,而忽略文件的权限。
source 命令通常用于重新执行刚修改的初始化文件,如 .bash_profile 和 .profile 等等。
source 命令可以影响执行脚本的父shell的环境,而 export 则只能影响其子shell的环境。

方法1:
让/etc/profile文件修改后立即生效 ,可以使用如下命令:
# .  /etc/profile
注意: . 和 /etc/profile 有空格
方法2:
让/etc/profile文件修改后立即生效 ,可以使用如下命令:
# source /etc/profile

此文章来之: http://blog.chinaunix.net/uid-27200305-id-3319139.html
------------------------------------------------
posted @ 2013-01-22 10:46  shzy2012  阅读(1955)  评论(0编辑  收藏  举报