查看shell默认类型
ls -l /bin/sh
//ubuntu默认如下
lrwxrwxrwx 1 root root 4 Dec 9 2021 /bin/sh -> dash
什么是dash?
dash (Debian Almquist Shell)
Debian和Ubuntu中,/bin/sh默认指向dash,这是一个不同于bash的shell,它主要是为了执行脚本而出现,而不是交互,它速度更快,但功能相比bash要少很多,语法严格遵守POSIX标准。
什么是bash?
bash(GNU Bourne-Again Shell)是许多Linux平台的内定Shell
GNU/Linux 操作系统中的 /bin/sh 原本是 bash ,但鉴于 bash 过于复杂,有人把 bash 从 NetBSD 移植到 Linux 并更名为 dash,并建议将 /bin/sh 指向它,以获得更快的脚本执行速度。
事实上,还有许多传统UNIX上用的Shell,像tcsh、csh、ash、bsh、ksh等等。
dash和bash比较
Dash Shell 比 Bash Shell 小的多,符合POSIX标准。
遇到问题如下
这个dash使得我按照bash语法写的shell 脚本不能运行。
切换bash和dash
输入 dpkg-reconfigure dash,弹出如下窗口
选择no,完成切换