FreeBSD 安装后默认可选的 Shell 只有 sh 和 tcsh,如果需要 bash 和 zsh 是需要自己安装配置的。
安装 bash:
sudo pkg install bash
以上命令使用到了 sudo,在 FreeBSD 里 sudo 也是需要自己安装。
配置 bash:
在 FreeBSD 中,用户安装的程序都是放在 /usr/local 下,配置文件在 /usr/local/etc 目录下。
不同于 Linux 各发行版有自己的安装程序路径规则,BSD 系统都使用统一的规范来管理,这样不会显得杂乱无章。
bash 的配置文件路径是 /usr/local/etc/profile,需要自己创建这个文件,内容如下:
# source *.sh files from /usr/local/etc/profile.d if they are readable
if [ -d /usr/local/etc/profile.d ]; then
for i in /usr/local/etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
内容比较简单,就是遍历目录 /usr/local/etc/profile.d 中的所有可读的 *.sh 文件然后执行其内容。
这样配置的好处是用户可以随意添加和修改 bash shell 环境配置。
例如要添加默认的全局代理配置,只需要在 /usr/local/etc/profile.d 目录里创建一个 proxy.sh 文件,内容如下:
http_proxy=http://10.211.55.2:7890
https_proxy=http://10.211.55.2:7890
在用户再次登录的时候,就会自己配置 http_proxy 和 https_proxy 这两环境变量。
