1. 程式人生 > >Ubuntu切換預設sh為bash或者dash

Ubuntu切換預設sh為bash或者dash

                     

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

修改預設sh為bash

然後選擇

修改預設sh為bash

成功後再執行

 

ll /bin/sh

結果是: /bin/sh -> bash

預設是修改為bash

修改成功!

2.3   切換sh為dash

當然我們也可以使用

 

sudo dpkg-reconfigure dash

把sh修改回去

3  連結