1、前言
笔者出来工作多年,对属于unix分支的bsd系列freebsd的大名早有耳闻。今天终于下定决心去玩一下,发现与linux的细致还是有差异的,将常见的配置记录于此,供往后参阅。
2、系统的安装
系统下载:
https://www.freebsd.org/zh_CN/where.html
系统的安装:
https://www.freebsd.org/doc/zh_CN.UTF-8/books/handbook/bsdinstall.html
注:请安装FreeBSD 10.2-RELEASE
3、服务的管理
3.1、查看当前安装的服务
3.2、服务的选项
显式如下:
1
|
Usage: /etc/rc .d /moused [fast|force|one|quiet](start|stop|restart|rcvar|enabled|status|poll)
|
3.3、服务操作
1
2
3
4
|
/etc/rc .d /moused start
/etc/rc .d /moused restart
/etc/rc .d /moused status
/etc/rc .d /moused stop
|
3.4、服务自启动
配置如下:
1
2
|
moused_enable= "YES"
moused_enable= "NO"
|
3.5、常见的服务清单
1
2
|
/etc/rc .d /netif
/etc/rc .d /routing
|
注:使用方式请参考3.3服务的操作
4、网络的配置
4.1、有线网络
4.1.1、dhcp自动获取IP
配置如下:
re0为指定的网卡名称
4.1.2、静态IP配置
vi /etc/rc.conf
详细配置如下
1
2
3
|
ifconfig_re0= "inet 10.168.0.8 netmask 255.255.255.0"
ifconfig_re0_alias0= "inet 10.168.0.9 netmask 255.255.255.0"
defaultrouter= "10.168.0.1"
|
重启服务
1
2
|
/etc/rc .d /netif restart
/etc/rc .d /routing restart
|
4.2、dns配置
vi /etc/resolv.conf
详细配置如下:
1
2
3
4
|
nameserver 202.96.128.86
nameserver 202.96.128.166
nameserver 8.8.8.8
nameserver 8.8.4.4
|
4.3、无线网络
4.3.1、提取windows驱动
1)去一键工作室下载个U盘pe制作工具,网址:http://www.upanok.com/
2)从U盘的PE系统启动
3)启动PE网络的模式
4)使用PE自带的驱动提取工具提取无线网卡的驱动文件(*.inf,*.sys)
注:以上适用于32位操作系统
4.3.2、制作内核驱动
1)提取的驱动文件U盘复制到系统
1
|
mount -t msdos /dev/da1s1 /mnt/
|
注:卸载方法
2)生成内核驱动
1
2
|
cd /mnt
ndisgen x.inf x.sys
|
注:以上一路回车即可看到生成的x_sys.ko文件
4.3.3、加载内核驱动
1)手动加载
1
2
|
kldload . /x_sys .ko
ifconfig
|
可发现无线网卡:
1
2
3
4
5
|
ndis0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 2290
ether 00:25:56:77:85:b6
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: IEEE 802.11 Wireless Ethernet autoselect mode 11g
status: associated
|
2)自动加载内核
1
2
|
cp . /x_sys .ko /boot/modules/
echo "kldload /boot/modules/x_sys.ko" >> /etc/rc . local
|
4.3.4、加载无线所需的其他内核
1)内核加载
1
2
3
4
5
6
|
if_ath_load= "YES"
wlan_scan_ap_load= "YES"
wlan_scan_sta_load= "YES"
wlan_wep_load= "YES"
wlan_ccmp_load= "YES"
wlan_tkip_load= "YES"
|
2)重启系统
4.3.5、创建无线
1)手动创建无线
1
|
ifconfig wlan0 create wlandev ndis0
|
2)自动创建无线
1
|
echo "ifconfig wlan0 create wlandev ndis0" >> /etc/rc . local
|
4.3.6、创建无线认证
1)配置认证
1
|
vi /etc/wpa_supplicant .conf
|
加入如下配置:
1
2
3
4
|
network={
ssid= "ssid-name"
psk= "password"
}
|
2)重启网络服务
4.3.7、检查
显示如下:
1
2
3
4
5
6
7
8
9
10
|
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:25:56:77:85:b6
inet 10.168.0.77 netmask 0xffffff00 broadcast 10.168.0.255
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: IEEE 802.11 Wireless Ethernet autoselect mode 11g
status: associated
ssid will-work channel 6 (2437 MHz 11g) bssid 12:18:d6:8f:b7:f8
country US authmode WPA2 /802 .11i privacy OFF powersavemode CAM
powersavesleep 100 txpower 0 bmiss 7 mcastrate 6 mgmtrate 6
scanvalid 60 protmode CTS roaming MANUAL bintval 0
|
4.3.8、图形wifi管理
5、软件包安装
5.1、常用指令
1
2
3
|
pkg search vim
pkg install vim
pkg remove vim
|
5.2、配置文件
5.2.1 官方的pkg源
1
|
cat /etc/pkg/FreeBSD .conf
|
显示如下:
1
2
3
4
5
6
7
|
FreeBSD: {
url: "pkg+http://pkg.FreeBSD.org/${ABI}/quarterly" ,
mirror_type: "srv" ,
signature_type: "fingerprints" ,
fingerprints: "/usr/share/keys/pkg" ,
enabled: yes
}
|
5.2.2 本地自定义pkg源
1
2
|
mkdir -p /usr/local/etc/pkg/repos
vi /usr/local/etc/pkg/repos/FreeBSD_install_http .conf
|
定义如下:
1
2
3
4
5
6
7
8
9
|
FreeBSD_install_http: {
url: "http://192.168.0.200/FreeBSD-11.0-RELEASE-amd64/packages/${ABI}" ,
mirror_type: "none" ,
enabled: yes
}
FreeBSD: {
enabled: no
}
|
6、ssh服务配置
6.1、增加用户
执行完根据向导完成用户的信息填写。
6.2、用户加入组
vim /etc/group
因为root默认禁止ssh登录,故而将普通用户user1加入wheel组(可以使用su指令)
6.3、切换至root用户
6.4、启动服务并
6.5、设置服务自启动
配置如下
7、命令行使用
由于无法使用[end]等键,提供如下快捷方式供用户使用:
1
2
3
4
5
|
[ctrl]+a
[ctrl]+e
[ctrl]+u
[ctrl]+k
[ctrl]+w
|
8、桌面环境安装
8.1、二进制包的安装
8.2、配置
8.2.1、配置/proc挂载(GNOME运行需要)
配置如下:
保存并退出后
8.2.2、配置启动文件
1
|
echo "/usr/local/bin/gnome-session" > ~/.xinitrc
|
8.2.3、开机启动桌面环境
1)配置服务
配置如下:
或者这样写
1
2
|
gdm_enable= "YES"
dbus_enable= "YES"
|
2)重启并测试
8.2.4、手动启动桌面环境
1)配置服务
vim /etc/rc.conf
配置如下:
2)重启并测试
8.2.5、中文输入法
1
|
pkg install ibus zh-ibus-pinyin
|
安装完毕选择以下菜单添加输入法:
Activities -> Setting -> Region & Language -> Input Sources -> 单击【+】 -> Chinese(China) -> Chinese(Pinyin) -> Add
8.2.6、办公软件
1
|
pkg install libreoffice xpdf xpdfopen zh-xpdf-zhfont gimp
|
8.2.7 浏览器的安装
1)安装firefox-esr浏览器
1
|
pkg install -y firefox-esr
|
flash安装
1
2
3
4
5
6
7
8
9
10
11
|
pkg install nspluginwrapper
cd /usr/ports/www/linux-f10-flashplugin11
make install
make clean
nspluginwrapper - v -a -i
nspluginwrapper - v -a -u
|
2)安装chrome浏览器
1
2
3
|
pkg install -y chromium
sysctl kern.ipc.shm_allow_removed=1
echo "kern.ipc.shm_allow_removed=1" >> /etc/sysctl .conf
|
flash安装
1
2
3
4
5
6
7
8
9
10
11
|
cd ~
wget https: //fpdownload .adobe.com /pub/flashplayer/pdc/25 .0.0.127 /flash_player_ppapi_linux .x86_64. tar .gz
tar -xf flash_player_ppapi_linux.x86_64. tar .gz
mkdir -p /usr/local/share/chromium/RepperFlash
cp libpepflashplayer.so manifest.json /usr/local/share/chromium/RepperFlash
chmod -R 755 /usr/local/share/chromium/RepperFlash
vim /usr/local/share/applications/chromium-browser .desktop
Exec=chome %U --ppapi-flash-path= /usr/local/share/chromium/RepperFlash/libpepflashplayer .so
|
8.2.8、远程控制
9、拯救模式
9.1、什么是拯救模式
拯救模式是用于系统拯救,如当修改内核参数发生错误,导致系统无法正常引导,我们需要借助光盘引导到正常的操作系统,并切换到可以修复原来系统环境的工作模式。
9.2、操作步骤
1)准备一张光盘并从光驱启动
2)选择“boot single user”模式启动
3)看到如下提示按回车
1
|
Enter full pathname of shell or RETURN for /bin/sh :
|
4)挂载文件系统
1
2
|
mount /dev/ad0p2 /mnt
ls /mnt
|
5)切换根到文件系统
6)做反向操作修复错误配置文件
7)重新引导进入系统
10、错误处理
10.1、错误提示1
pkg: cached package xxx: size mismatch, cannot continue
处理命令:
11、设置时区和校正时间
1
2
|
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ntpdate 0.pool.ntp.org
|
--------------------------------------------------------------------
本文转自 tanzhenchao 51CTO博客,原文链接:http://blog.51cto.com/cmdschool/1728933,如需转载请自行联系原作者