您的位置:首页 > 运维架构 > Shell

Ubuntu切换默认sh为bash或者dash

2016-11-14 16:14 393 查看
1、bash与dash
从Ubuntu 6.10开始,默认使用dash(theDebian Almquist Shell)而不是bash(the GNUBourne-Again Shell).
但Login Shell还是bash. 原因是dash更快、更高效,而且它符合POSIX规范。Ubuntu在启动的时候会运行很多shell脚本,使用dash可以加快启动速度。
 
1.1、什么是bash?
Bash(GNU Bourne-Again Shell)是许多Linux平台的内定Shell,事实上,还有许多传统UNIX上用的Shell,像tcsh、csh、ash、bsh、ksh等等,Shell Script大致都类同,当您学会一种Shell以后,其它的Shell会很快就上手,大多数的时候,一个Shell Script通常可以在很多种Shell上使用
 
1.2、什么是dash?
dash is the standard command interpreter for the system. The current version of dash is in the process of being changed to conform with the POSIX 1003.2 and 1003.2a specifications for the shell.
 
2、切换bash和dash
2.1、查看与使用
先用命令ls -l /bin/sh看看
/bin/sh -> dash
默认sh为dash



我们会发现Ubuntu默认采用的是 dash
 
2.2、切换sh为bash
如果要修改默认的sh,可以采用命令
sudo dpkg-reconfigure dash



然后选择否



成功后再执行
ll /bin/sh
结果是:/bin/sh -> bash



修改成功!
 
2.3、切换sh为dash
当然我们也可以使用
sudo dpkg-reconfigure dash
把sh修改回去。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: