Mac查看與修改系統默認shell
- 查看所有shell
cat /etc/shells
輸出:
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
這表示目前系統下有7種版本的shell可用
- 查看當前窗口使用的shell版本(不要被一個叫 $SHELL 的單獨的環境變量所迷惑,它被設置為你的默認 shell 的完整路徑。因此,這個變量並不一定指向你當前使用的 shell。例如,即使你在終端中調用不同的 shell,$SHELL 也保持不變)
echo $SHELL
輸出:
/bin/bash
- 查看系統用戶默認shell
cat /etc/passwd | grep sh
輸出:
root:*:0:0:System Administrator:/var/root:/bin/sh
_sshd:*:75:75:sshd Privilege separation:/var/empty:/usr/bin/false
_update_sharing:*:95:-2:Update Sharing:/var/empty:/usr/bin/false
_mbsetupuser:*:248:248:Setup User:/var/setup:/bin/bash
表示root賬戶用的是sh,其他用的是bash
- 輸出當前使用的shell
echo $0
- 修改系統默認shell為bash
chsh -s /bin/bash
修改完之后重啟terminal即可生效哦!