剛準備在FreeBSD下學習Shell,結果發現怎麼好多命令都沒有,好比declare。後來發現連bash都沒有,好像bash用的多一些吧,因而就準備將csh換成bash。shell
因爲沒有bash,因此先得安裝一個bash:bash
pkg install bash -- 下載速度超慢,不過好在bash不大學習
root@www:/usr/ports/ports-mgmt/pkg # pkg install bash
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):ui
New packages to be INSTALLED:
bash: 4.4.12_1this
Number of packages to be installed: 1spa
The process will require 8 MiB more space.
1 MiB to be downloaded.orm
Proceed with this action? [y/N]: y
[1/1] bash-4.4.12_1.txz : 100% 1 MiB 36.5kB/s 00:40
Checking integrity... done (0 conflicting)
[1/1] Installing bash-4.4.12_1...
Extracting bash-4.4.12_1: 100%
Message from bash-4.4.12_1:
======================================================================it
bash requires fdescfs(5) mounted on /dev/fdio
If you have not done it yet, please do the following:form
mount -t fdescfs fdescfs /dev/fd
To make it permanent, you need the following lines in /etc/fstab:
fdescfs /dev/fd fdescfs rw,late 0 0
======================================================================
安裝好了bash以後,用以下命令更換shell:
chsh -s /usr/local/bin/bash
root@www:/usr/ports/ports-mgmt/pkg # chsh -s /usr/local/bin/bash
chsh: user information updated
而後查看當前SHELL:
[root@www ~]# echo $SHELL
/usr/local/bin/bash
更換非root用戶默認的shell,#chsh -s /usr/local/bin/bash username -- 用實際的用戶名替換
p.s.
freebsd安裝了bash以後並不默認去讀取.bashrc文件,若是想作設置相似
alias ls='ls - G',那麼應該直接添加到.profile裏面而後:
source .profile就能夠了
p.s.
爲了支持中文顯示,能夠在.profile中添加以下內容:
export LANG=zh_CN.UTF-8 export LC_CTYPE=zh_CN.UTF-8 export LC_ALL=zh_CN.UTF-8