原文:为什么不能在shell脚本中执行source /etc/profile或者source ~/.bashrc问题?

执行脚本时,其中的命令是在一个子shell中执行的。子shell继承了父shell的环境变量,但无法修改他们,或者说所做的修改仅对子shell有效。 ...

2019-04-25 20:04 0 2519 推荐指数:

查看详情

Linux执行source /etc/profile报错“:command not found”

修改完 /etc/profile的内容后,执行“立即生效”命令 “source /etc/profile”报错: :command not found :command not found :command not found 解决方法: 执行如下命令(两种方式): 1. ...

Thu Oct 25 03:42:00 CST 2018 0 3840
shell脚本source无效

发现在shell里面执行source,提示找不到命令。所以,我取搜了一些资料,总结一下。 一. 脚本source找不到命令--------------是因为用了sh执行脚本,而debian系统的sh指向dash。需要更改系统sh指向: (1)cd /bin (2)mv sh ...

Wed Jan 16 19:22:00 CST 2019 0 3205
source命令在shell脚本执行不生效的原因

最近发现,把我原来编译安装MySQL的命令写到脚本里,然后执行source命令执行总是不生效。 查了下资料,算是知道了原因,在此记录一下。 使用 bash 脚本名 方式来执行脚本,这种方式会启动一个子shell,在子shell执行脚本里面的语句,该子shell继承父shell的环境变量 ...

Sat Aug 22 02:55:00 CST 2020 0 2145
shell脚本执行source命令不生效的解决办法

一个shell脚本文件中有一个source命令,使用bash a.sh命令执行source命令进行验证没有生效。 这是因为在shell脚本执行source会看到效果,但是shell脚本执行完后再次验证就没看到效果。 此时可以换这种方式执行shell脚本命令:source a.sh ...

Tue Apr 13 21:23:00 CST 2021 0 1105
详解shellsource、sh、bash、./执行脚本的区别

1、source命令用法:   source FileName   作用:在当前bash环境下读取并执行FileName的命令。该filename文件可以无"执行权限" 注:该命令通常用命令“.”来替代。 如:source .bash_profile ...

Fri Jul 13 22:54:00 CST 2018 0 2896
解决linux下source /etc/profile关闭终端失效问题

  本来想配置环境变量的,看网上和博客上很多说改/etc/profile,然后source /etc/profile之后就可以永久保存使环境变量生效,但是终端一关闭,就环境变量就失效了,其他终端也用不了。网上有说在当前用户目录下创建.bash_profile文件,编写环境变量,然后执行 ...

Tue Aug 07 02:23:00 CST 2018 0 3319
(Linux)解决每次进入命令要重新 source /etc/profile问题

目录 一、问题出现 二、解决办法 一、问题出现 今天在Linux安装jdk后(下载安装教程)发现每次使用jdk都要重新执行 source /etc/profile 命令,使该文件生效才可以使用jdk(非常麻烦),所以上网查找解决办法,具体解决办法请继续向下看。 二、解决办法 ...

Thu Sep 17 17:30:00 CST 2020 0 2248
source ~/.bashrc

编辑命令: gedit ~/.bashrc source ~/.bashrc 每次修改.bashrc后,使用source ~/.bashrc(或者 . ~/.bashrc)就可以立刻加载修改后的设置,使之生效。 ...

Tue Nov 05 22:47:00 CST 2019 0 644
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM