900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > 问题记录:Ubuntu中source运行.sh shell脚本报错:command not found 未找到命令

问题记录:Ubuntu中source运行.sh shell脚本报错:command not found 未找到命令

时间:2022-11-14 05:39:21

相关推荐

问题记录:Ubuntu中source运行.sh shell脚本报错:command not found 未找到命令

问题截图:

一开始,我以为是权限的问题,root之后仍然报错

解决方法:

我解决这个问题分了两步

1.修改了/bin/bash执行方式:

ls -l `which sh`

会发现脚本默认是以dash模式执行的,此时运行:

dpkg-reconfigure dash

就会出现:

2.做完上述步骤,仍然报错,此时便要考虑是脚本本身格式问题。我是从Win10主机复制到虚拟机里面的,于是进行如下操作

安装dos2unix组件

apt install dos2unix

对.sh脚本进行格式转换

chmod 755 your_script.shdos2unix your_script.sh

做完这些后,就可以正常source我们的.sh脚本了

参考链接:

/p/44d659fcbf09

/Together_CZ/article/details/88395718?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。