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

Ubuntu切換默認sh為bash或者dash

clas 語法 proc 什麽是 pic 其它 -i man targe

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

技術分享圖片

我們會發現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修改回去

3 鏈接


Dash與Bash的語法區別

Ubuntu切換默認sh為bash或者dash