官方简体中文安装手册:http://www.freebsd.org/doc/zh_CN/books/handbook/官方en_US安装手册:http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/index.html官方简体中文安装手册 下载: ftp://ftp.freebsd.org/pub/FreeBSD/doc/zh_CN/books/handbook/1: 使用 USB 安装 FreeBSD(设备编号自行修改)# dd if=9.1-RELEASE-amd64-memstick.img of=/dev/da1 bs=10240 conv=syncTips: Windows环境下如何将 *.img 写入USB ? Image Writer for Windows:  https://launchpad.net/win32-image-writer/+download安装source 和 ports等待重启完成 ...# vi /boot/loader.confloader_logo="beastie"(boot menu logo)autoboot_delay="3"(boot delay):wq# vi /etc/rc.confblanktime="600"saver="daemon"hald_enable="YES"dbus_enable="YES"powerd_enable="YES"powerd_flags="-a adaptive -b adaptive -n adaptive"  # 保持温度不会过高就是了:wq# kldload coretemp# sysctl -a |grep temperhw.acpi.thermal.tz0.temperature: 60.0Cdev.cpu.0.temperature: 59.0Cdev.cpu.1.temperature: 59.0Cdev.cpu.2.temperature: 59.0Cdev.cpu.3.temperature: 59.0Cdev.cpu.4.temperature: 61.0Cdev.cpu.5.temperature: 62.0Cdev.cpu.6.temperature: 59.0Cdev.cpu.7.temperature: 59.0C检查一下硬件信息# dmesg | grep attached(列出没有被驱动的硬件) # pciconf -lv(更加详细)  /var/run/dmesg.boot(see also)(找到声卡 和 显卡加载相应驱动)声卡 驱动# kldload snd_driver(加载所有声卡驱动自动匹配)# cat /dev/sndstat(查看声卡驱动信息)# dmesg | grep hdac# cat filename > /dev/dsp(测试声卡,filename为任意文件产生噪音说明正常工作)# vi /boot/device.hintshint.pcm.0.vol="50"(pcm Module加载时,音量默认为50):wq# Microphone     (话筒)# mixer# sysctl dev.pcm.0.play.vchans=4# sysctl dev.pcm.0.rec.vchans=4( 虚拟声道(Virtual Sound Channels)4个音源能够同时播放)# sysctl hw.snd.maxautovchans=4 # less /boot/defaults/loader.conf /snd(找到所有声卡驱动支持项) # pciconf -lv | egrep -i -A3 -B5 'audio|multimedia'(查看device 类型) # vi /boot/loader.conf snd_hda_load="YES"(启动时加载 声卡驱动/添加自己的声卡驱动):wq2: 时间校准 (很重要)# tzsetup(时区设置 CST)# ntpdate cn.pool.ntp.org(校准)# vi /etc/rc.confntpd_enable="YES"(配置开机启动 ntpd)ntpd_sync_on_start="YES":wq# /etc/rc.d/ntpd start# vi /etc/ntp.confserver 1.cn.pool.ntp.orgserver 1.asia.pool.ntp.orgserver 2.asia.pool.ntp.org(配置time server):wq# /etc/rc.d/ntpd restart3:更新 source 和 doc# cp /usr/share/examples/cvsup/standard-supfile /etc# cd /etc/; vi standard-supfile*default host=cvsup.tw.freebsd.org (修改此项)*default base=/var/db*default prefix=/usr*default release=cvs tag=RELENG_9_0*default delete use-rel-suffix*default compresssrc-alldoc-all tag=.   (添加此项):wq # csup /etc/standard-supfile4:ports 和 package 文件下载地址设置# vi /etc/make.conf(详情:man make.conf)MASTER_SITE_BACKUP?=\ftp://ftp.hk.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\ftp://ftp.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/(注意这里没换行了)MASTER_SITE_OVERRIDE?= ${MASTER_SITE_BACKUP}CPUTYPE?=core2(根据情况调整,起到优化作用:me -> i7)# sysctl hw.model(more /usr/share/example/etc/make.conf)# dmidecode(DMI table decoder)INSTALL=install -C(比对已安装文件与最新文件 版本号,低于新版本才安装):wqtcsh/csh:# vi ~/.cshrcsetenv        PACKAGEROOT        ftp://ftp.tw.freebsd.orgsetenv        PKG_TMPDIR        /var/garbage        (package安装后来这里看看:/var/db/pkg):wq# exit            (注销生效)sh/bash:$ vi ~/.profileexport PACKAGEROOT=ftp://ftp.tw.freebsd.orgexport PKG_TMPDIR=/var/garbage:wq# exit            (注销生效) # # pkg_add -r vim(使用远程服务器安装) # pkg_version -v  (list outdated ports that have a newer version available in the Ports) # pkg_version -v |grep vim(首先查出版本号) # pkg_delete vim-7.3.81 或者: # pkg_delete /var/db/pkg/vim-7.3.81 # pkg_delete xchat\*(使用通配符) # pkg_info |grep -i vim(首先查出版本号) # pkg_info -L vim-7.3.81 |less(显示这个软件包安装的所有文件) # pkg_info vim-7.3.81 查看CPU支持指令集合:# grep -i features /var/run/dmesg.bootFeatures=0xbfebfbff  Features2=0x98e3fd  AMD Features=0x28100800  AMD Features2=0x1查看当前操作系统开启的指令集合:# cd /usr/share/mk# make -V CPUTYPEcore2# make -V MACHINE_CPUssse3 sse3 amd64 sse2 sse mmx5: 更新 ports ( portmaster)# portsnap fetch extract  (首次更新port使用此命令)# portsnap fetch update(日后更新port使用此命令)vi /etc/crontab0 5 * * * root /usr/sbin/portsnap cron update  (自动更新port):wq安装 portmaster 用于更新 软件包:# cd /usr/ports/ports-mgmt/portmaster && make install clean---------------------------------------------------------------------# ls /usr/local/etc/portmaster.rc.sample# vim /usr/local/etc/portmaster.rc# Do not create temporary backup packages before pkg_delete (-B)NO_BACKUP=Bopt# Always delete stale distfiles without prompting (-d)ALWAYS_SCRUB_DISTFILES=dopt# Do not run 'make config' for ports that need updating (-G)PM_NO_MAKE_CONFIG=Gopt# Be verbose (-v)PM_VERBOSE=vopt# Save copies of old shared libraries (recommended) (-w)SAVE_SHARED=wopt:wq----------------------------------------------------------------------# /usr/local/sbin/portmaster -L > portmaster.out(列出可更新的软件)===>>> linux_base-fc-4_8===>>> New version available: linux_base-fc-4_9# /usr/local/sbin/portmaster linux_base-fc-4_8(更新 某软件)# /usr/local/sbin/portmaster -e openoffice.org-2.2.0(卸载某软件与其依赖)## portmaster -a(升级所有已安装的 ports)# portmaster -af(always rebuild ports overrides -i)# portmaster -aG -x ? --no-confirm# portmaster -r[-R] -r name/glob of port directory in /var/db/pkg         rebuild the specified port, and all ports that depend on it.  The         list of dependent ports is built according to origin (i.e.,         category/portname) not by the version number of the installed port.         So if you do portmaster -r fooport-1.23 and it is necessary to         restart using -R but the newly installed port is now fooport-1.24 you         can do portmaster -R -r fooport-1.24 and it should pick up where you         left off.  The -r option can be specified more than once.# cd /usr/ports/sysutils/bsdadminscripts/ && make install clean> pkg_libchk                   (检查缺失的动态库,找出有问题的 ports)Thunar-1.3.0: /usr/local/lib/thunarx-2/thunar-sbr.so misses libpng.so.6Thunar-1.3.0: /usr/local/lib/thunarx-2/thunar-sbr.so misses libpng.so.6Thunar-1.3.0: /usr/local/lib/thunarx-2/thunar-uca.so misses libpng.so.6Thunar-1.3.0: /usr/local/lib/thunarx-2/thunar-uca.so misses libpng.so.6Thunar-1.3.0: /usr/local/lib/thunarx-2/thunar-uca.so misses libpng.so.6Thunar-1.3.0: /usr/local/lib/thunarx-2/thunar-uca.so misses libpng.so.6Thunar-1.3.0: /usr/local/lib/thunarx-2/thunar-wallpaper-plugin.so misses libpng.so.6Thunar-1.3.0: /usr/local/lib/thunarx-2/thunar-wallpaper-plugin.so misses libpng.so.6Thunar-1.3.0: /usr/local/lib/thunarx-2/thunar-wallpaper-plugin.so misses libpng.so.6Thunar-1.3.0: /usr/local/lib/xfce4/panel/plugins/libthunar-tpa.so misses libpng.so.6Thunar-1.3.0: /usr/local/lib/xfce4/panel/plugins/libthunar-tpa.so misses libpng.so.6Thunar-1.3.0: /usr/local/lib/xfce4/panel/plugins/libthunar-tpa.so misses libpng.so.6......ports替换升级法(以perl为例):> more /usr/ports/UPDATINGAFFECTS: users of lang/perl* AUTHOR: skv@FreeBSD.org lang/perl5.16 is out. If you want to switch to it from, for example lang/perl5.12, that is: Portupgrade users: 0) Fix pkgdb.db (for safety): pkgdb -Ff 1) Reinstall new version of Perl (5.16): env DISABLE_CONFLICTS=1 portupgrade -o lang/perl5.16 -f perl-5.12.\* 2) Reinstall everything that depends on Perl: portupgrade -fr perl Portmaster users: portmaster -o lang/perl5.16 lang/perl5.12 Conservative: portmaster p5- Comprehensive (but perhaps overkill): portmaster -r perl- Note: If the "perl-" glob matches more than one port you will need to specify the name of the Perl directory in /var/db/pkg explicitly. The default version for Perl has also been changed from 5.12 to 5.14.另一种更新 软件包 的方法:# make deinstall && make install clean(前提是你的ports 已经更新!)下面方法多用于 测试不同版本软件:# make install(注意没有:clean ,保留下载的源码!)# make deinstall && make reinstall(前提是下载的源码没有被清理!)# make PREFIX=/usr/pkg install clean(Changing the Install Path)Cleaning Up Ports:# make install clean(clean a port immediately upon install)You might also want to remove the original distfiles, stored in /usr/ports/distfiles.# make distclean (removes the distfiles for the current port and all dependencies)OR:# portmaster --clean-distfilesTo clean the entire ports tree# make clean -DNOCLEANDEPENDS (  run directly under /usr/ports)Building Packages# make packageThis installs the program on the local machine and creates a package in the port’s directory.Simply copy this package to other systems and run pkg_add(1) to install it.If you create the directory /usr/ports/packages, the Ports Collection willcreate a packages tree in that location. Instead of placing the new packagein the port’s directory, the port will place the package in the appropriatecategory under /usr/ports/packages.--------------------------------------------------------------------------------LOCAL PACKAGE REPOSITORIESRemember the PACKAGESITE environment variable? Set that to a path on your localanonymous FTP server (Chapter 17) or an NFS share (Chapter 8) and put your custompackages there. You can then use pkg_add -r on your other machines, and they willautomatically grab packages from your local repository.6:Binary Updates ( only provides patches to the GENERIC kernel)# freebsd-update fetch(download the latest updates to your errata branch)( files stored in /var/db/freebsd-update)# freebsd-update install(install the downloaded files)## vi /etc/crontab0 5 * * * root /usr/sbin/freebsd-update cron (自动更新至 errata-branch):wqReboot your system ..7:安装 Vim# cd /usr/ports/editors/vim/# make WITHOUT_X11=yes install clean# exit(注销)# vim ~/.vimrcset nomodeline(这个一定要写,目前有这个安装漏洞)set nocpset hls isset icset autoindentset backspace=2syntax on"set bg=dark(更改背景色调/默认为light, " 为注释!):wq(详情:vimtutor)# vim ~/.cshrcsetenvEDITORvim:wq8:使用本地化语言方法一:Class Definitions# vim /etc/login.confchinese:Chinese Users Account:\:charset=UTF-8:\:lang=zh_CN.UTF-8:\:tc=default::wq# cap_mkdb /etc/login.conf(rebuilds the database file /etc/login.conf.db)# pw usermod jacky -L chinese(修改 jacky 的 语言环境)# pw useradd jacky -L chinese(添加 jacky 并使用中文)# pw usershow jackyjacky:*:1001:1001:chinese:0:0:jacky:/home/jacky:/bin/tcsh# su - jacky> localeLANG=zh_CN.UTF-8LC_CTYPE="zh_CN.UTF-8"LC_COLLATE="zh_CN.UTF-8"LC_TIME="zh_CN.UTF-8"LC_NUMERIC="zh_CN.UTF-8"LC_MONETARY="zh_CN.UTF-8"LC_MESSAGES="zh_CN.UTF-8"LC_ALL= 方法二:User Definitions# vim ~/.login_confme:\:lang=zh_CN.UTF-8:\:setenv=LC_CTYPE=zh_CN.UTF-8:\(字符类型):setenv=LC_COLLATE=zh_CN.UTF-8:\(字符对比规则):setenv=LC_TIME=zh_CN.UTF-8:\(时间类型):setenv=LC_NUMERIC=zh_CN.UTF-8:\(数字类型):setenv=LC_MONETARY=zh_CN.UTF-8:\(货币类型):setenv=LC_MESSAGES=zh_CN.UTF-8:\(消息/提示类型):setenv=LC_ALL=zh_CN.UTF-8:\:charset=UTF-8::wq PS: 自定义 prompt 和 alias 方法一:全局设置vim /etc/csh.cshrc set prompt = "%B%n@%m [%/] $ "(详情:man csh /%m) set autolist(TAB命令补全功能) 方法二:自定义设置 vim ~/.cshrc set prompt = "%B%n@%m [%/] # "(注意空格) set autolist(TAB 命令补全功能) alias clclear alias vivim alias dfdf -h  History:(默认记录文件:~/.history) # history -c(清理当前历史记录) # history -S(保存当前历史记录) 9: Axel / Aria2下载大文件利器 (MP3、影片、软件等)   wget# cd /usr/ports/ftp/axel && make install clean# axel -a -n 3 ftp://ftp.kernel.org/pub/linux/kernel/v2.4/linux-2.4.17.tar.bz2(详情:man axel)# axel -S4 ftp://ftp.kernel.org/pub/linux/kernel/v2.4/linux-2.4.17.tar.bz2(自动寻找 4 个最快mirror进行下载)通常我用 wget 下网站(找到资料就下吧!说不准那天站点没了,还是弄下来方便!)# wget -r -np -p -k --level=2 http://tldp.org/HOWTO/Linux+IPv6-HOWTO/(wget默认安装)Aria2 :多链接下载,轻量,平均4-9MB内存使用量,BitTorrent下载速度2.8MiB/s时CPU占用约6%# cd /usr/ports/www/aria2 && make install clean(详情:man aria2c)# aria2c "http://example.org/mylinux.iso"(直接下载)# aria2c "http://host/file.zip" "ftp://host2/file.zip"(同时从 2 个不同源下载 某文件)# aria2c -x2 -k1M "http://host/file.zip"(-x2:一个server只建立 2 个连接 -k1M:man很详细)# aria2c -s4 http://host/file.zip(-s:总共启用多少个连接)# aria2c http://example.org/mylinux.torrent(BT 下载)# aria2c 'magnet:?xt=urn:btih:248D0A1CD08284299DE78D5C1ED359BB46717D8C' (BT Magent URI)# aria2c http://example.org/mylinux.metalink(Metalink)# aria2c -i files.txt -j2(Download URIs found in text file -j:同时进行任务数)Resuming Download:Usually, you can resume transfer by just issuing same command(aria2c URI) if the previous transfer is made by aria2. If the previous transfer is made by a browser or wget like sequential download manager, then use -c option to continue the transfer(aria2c -c URI)BitTorrent Download:# aria2c --follow-torrent=mem "http://host/file.torrent"(download files from remote BT file)# aria2c --max-upload-limit=40k file.torrent (download using a local torrent file)Using Proxy:For HTTParia2c --http-proxy="http://proxy:8080" "http://host/file"aria2c --http-proxy="http://proxy:8080" \--no-proxy="localhost,127.0.0.1,192.168.0.0/16" "http://host/file"For FTParia2c --ftp-proxy="http://proxy:8080" "ftp://host/file"Proxy with Authorizationaria2c --http-proxy="http://username:password@proxy:8080" "http://host/file"aria2c --http-proxy="http://proxy:8080" \--http-proxy-user="username" --http-proxy-passwd="password" "http://host/file"-------------------------------------------------------------------------------------------------------也可以应用到ports下载中!(非必需,一般来说FreeBSD的 fetch够用了)# vim /etc/make.confFETCH_CMD=/usr/local/bin/axel -a -S4(-a:显示每个线程状态信息  -n:连接数)DISABLE_SIZE=yes(开启 此功能!):wq穿越模式:FETCH_ENV=http_proxy=ur addressFETCH_ENV=ftp_proxy=ur address或者 使用其他工具:(proxychains / runsocks)FETCH_CMD=proxychains axelFETCH_CMD=runsocks axelPS:wget  axel aria2 配置均一样!FETCH_CMD=/usr/local/bin/wget -c -t 3(-c:继续以前的下载  -t:默认tries =20)DISABLE_SIZE=yes(开启 此功能!)FETCH_CMD=/usr/local/bin/aria2c -s 4(-s:开启4 个连接)DISABLE_SIZE=yes(开启 此功能!)(在Aria2速度不行的时候,我发现Axel速度确实可以!正常情况匹敌!) 10:Scim-pinyin (fcitx-sunpinyin) (ibus-pinyin)输入法# cd /usr/ports/chinese/scim-pinyin && make install clean> vim ~/.cshrc# set scim as the XIM  input serversetenvXMODIFIERS@im=SCIM:wq# xfce环境下,支持中文默认用英文情况下(Terminal内右键 Input Methods -SCIM)# cd /usr/ports/chinese/fcitx-sunpinyin && make install clean# cd /usr/ports/chinese/fcitx-configtool && make install clean> vim ~/.cshrcsetenvXMODIFIERS@im=fcitxsetenvGTK_IM_MODULEximsetenvQT_IM_MODULExim:wq> vim ~/.xinitrc #!/bin/sh/usr/local/bin/fcitx &    # 确保比xfce提前运行!/usr/local/bin/startxfce4:wq# cd /usr/ports/chinese/ibus-pinyin && make install clean# more /usr/ports/textproc/ibus/pkg-message-------------------------------------------------------------------ibus installation finished. To use ibus, please do the following:If you are using bash, please add following lines to your $HOME/.bashrc:export XIM=ibusexport GTK_IM_MODULE=ibusexport QT_IM_MODULE=ximexport XMODIFIERS=@im=ibusexport XIM_PROGRAM="ibus-daemon"export XIM_ARGS="--daemonize --xim"If you are using tcsh, please add following lines to your $HOME/.cshrc:setenv XIM ibussetenv GTK_IM_MODULE ibussetenv QT_IM_MODULE ximsetenv XMODIFIERS @im=ibussetenv XIM_PROGRAM ibus-daemonsetenv XIM_ARGS "--daemonize --xim"If you are using KDE4, you may create a shell script in $HOME/.kde4/env, and add following lines:#!/bin/shexport XIM=ibusexport GTK_IM_MODULE=ibusexport QT_IM_MODULE=ximexport XMODIFIERS=@im=ibusexport XIM_PROGRAM="ibus-daemon"export XIM_ARGS="--daemonize --xim"Following input methods/engines are available in ports:chinese/ibus-chewing            Chewing engine for IBuschinese/ibus-pinyin             The PinYin input methodjapanese/ibus-anthy             Anthy engine for IBusjapanese/ibus-mozc              Mozc engine for IBusjapanese/ibus-skk               SKK engine for IBuskorean/ibus-hangul              Hangul engine for IBustextproc/ibus-kmfl              KMFL IMEngine for IBus frameworktextproc/ibus-m17n              The m17n IMEngine for IBus frameworktextproc/ibus-table             Table based IM framework for IBusand QT4 input method module, textproc/ibus-qt.If ibus cannot start or the panel does not appear, please ensurethat you are using up-to-date python.There's a bug in python 2.5, which may prevent the panel from appearing.-------------------------------------------------------------------# vim ~/.xinitrc#!/bin/sh/usr/local/bin/ibus-daemon --xim -d    # 确保比xfce提前运行!/usr/local/bin/startxfce4:wq# vim ~/.cshrcsetenv XIM ibussetenv GTK_IM_MODULE ibussetenv QT_IM_MODULE ximsetenv XMODIFIERS @im=ibussetenv XIM_PROGRAM ibus-daemonsetenv XIM_ARGS "--daemonize --xim":wq11:Xorg 和 WQY 字库# cd /usr/ports/x11/xorg && make BATCH=YES install clean(BATCH=YES: 启用默认配置选项, 不会出现对话框来烦你!)# Xorg -configure# mv xorg.conf.new /etc/X11/xorg.conf(生成 xorg 配置文件)# vim /etc/rc.conf(使用 HAL 自动检测键盘和鼠标)hald_enable="YES"dbus_enable="YES":wq# cd /usr/ports/x11-fonts/wqy && make install clean# vim /etc/X11/xorg.conf Section "Files"  FontPath"/usr/local/lib/X11/fonts/wqy"(添加 wqy 路径支持) EndSection Section "Monitor"Identifier"Monitor0"VendorName"Monitor Vendor"ModelName"Monitor Modle"HorizSync30-107(水平刷新频率)VertRefresh48-120(垂直刷新频率)Option"DPMS"(能源之星/EnergyStar) EndSection Section "Screen"Identifier"Screen0"Device"Card0"Monitor"Monitor0"DefaultDepth24SubSection"Display"Viewport0 0Depth24              Modes"1024x768"              Virtual   1366 768EndSubsection EndSection:wqPS: 使用 GTF 命令输出刷新频率 如下! 一定要安装 nvidia-settings 否则分辨率永远是 50Hz!# gtf 1366 768 60# 1366x768 @ 60.00 Hz (GTF) hsync: 47.70 kHz; pclk: 85.86 MHzModeline "1366x768_60.00"  85.86  1366 1440 1584 1800  768 769 772 795  -HSync +Vsyncection "Monitor"Identifier"Monitor0"VendorName"Monitor Vendor"ModelName"Monitor Modle"#HorizSync30-107(水平刷新频率)# VertRefresh48-120(垂直刷新频率)     #  1368x768 @ 60.00 Hz (GTF) hsync: 47.70 kHz; pclk: 85.86 MHz       Modeline "1368x768_60.00"  85.86  1368 1440 1584 1800  768 769 772 795  -HSync +VsyncOption"DPMS"(能源之星/EnergyStar) EndSection Section "Screen"Identifier"Screen0"Device"Card0"Monitor"Monitor0"DefaultDepth24SubSection"Display"Viewport0 0Depth24              Modes"1366x768"              Virtual   1366 768EndSubsection EndSection:wqPS:启用 ctrl+alt+backspace 退出 Xorg(默认已关闭该功能)方法一:# setxkbmap -option terminate:ctrl_alt_bksp方法二:# vim /usr/local/etc/hal/fdi/policy/x11-input.fdi(hald 会读取该文件)#  vim /etc/X11/xorg.confSection"ServerLayout"Option"DontZap""off"EndSection:wq方法三:使用 Xfce4-session-logout# vim ~/.cshrcaliaslogoutxfce4-session-logout --logoutalias   lock    xflock4:wq# source ~/.cshrc12:Nvidia 驱动# cd /usr/ports/x11/nvidia-driver && make BATCH=YES install clean# vim /boot/loader.confnvidia_load="YES"(启动时加载 driver)linux_enable="YES":wq# cd /usr/ports/x11/nvidia-xconfig/ && make install clean# rehash方法一:不开启 compiz-fusion # nvidia-xconfig(自动替换/etc/X11/xorg.conf 并备份原文件为:org.conf.backup)方法二:开启 compiz-fusion# nvidia-xconfig --add-argb-glx-visuals(Enable OpenGL)# nvidia-xconfig --composite(Enable Composite X extension)# nvidia-xconfig --depth=24显卡信息查看 和 分辨率 刷新频率 查看与修改!(Xorg 内 配置无法起作用,只能通过nvidia-settings来调整!)# cd /usr/ports/x11/nvidia-settings && make install clean# rehash# nvidia-settings13:xfce4# cd /usr/ports/x11-wm/xfce4 && make BATCH=YES install clean# vim /usr/local/etc/PolicyKit/PolicyLit.conf(允许用户在 xfce4模式下 reboot 和 shutdown) 还需要进行如下操作:# vim /usr/local/etc/polkit-1/localauthority/50-local.d/.pkla[Restart]Identity=unix-group:wheelAction=org.freedesktop.consolekit.system.restartResultAny=yesResultInactive=yesResultActive=yes[Shutdown]Identity=unix-group:wheelAction=org.freedesktop.consolekit.system.stopResultAny=yesResultInactive=yesResultActive=yes% vim ~/.xinitrc(告诉X 下次启动时执行 Xfce4)#!/bin/sh/usr/local/bin/startxfce4#exec startxfce4(也可这样写):wq PS: 如果使用了 XDM% vim ~/.xsession#!/bin/sh/usr/local/bin/startxfce4:wq% chmod +x ~/.xsession---------------------------------------------------Xfce4 回收站地址: ~/.local/share/Trash/filesXfce4 注销命令:# vim ~/.cshrcaliaslogoutxfce4-session-logout --logoutalias   lock    xflock4:wq# source ~/.cshrc---------------------------------------------------Xfce 4 Setting ManagerThemes/Shortcuts/:  Window ManagerBackground/Icons/display: Desktop DisplayFile Manager:Display-dateStyle: Appearance -xfce dustDesktop Panel SetupTerminal PreferencesAppearance - Font - Background(Transparent)滚动 滑轮 - 收起(打开)终端窗口----------------------------------------------------------------How to install new themes:  http://wiki.xfce.org/howto/install_new_themes----------------------------------------------------------------Xfce4 Plugins:http://goodies.xfce.org/projects/panel-plugins/start#安装 Ristretto(微型图片查看工具)# cd /usr/ports/graphics/ristretto && make install clean安装 Task(图形任务管理器)# cd /usr/ports/x11/xfce4-taskmanager && make install clean安装 Power(电源管理)# cd /usr/ports/sysutils/xfce4-power-manager && make install clean# cd /usr/ports/sysutils/xfce4-battery-plugin && make install clean安装 Notes(便签)# cd /usr/ports/deskutils/xfce4-notes-plugin && make install clean安装 Netload (网络负载)# cd /usr/ports/sysutils/xfce4-netload-plugin && make install clean安装 Weather(天气预报)# cd /usr/ports/misc/xfce4-weather-plugin && make install clean安装 Wavelan(无线上网)# cd /usr/ports/sysutils/xfce4-wavelan-plugin && make install cleanPS: 将以上项目在 panel上右键 添加 new item 才可以显示出来!!我的桌面这样漂亮, 我想做个截屏!在Xfce里怎么做呢?# cd /usr/ports/ # make quicksearch name=xfce4-screenshooter-plugin# cd /usr/ports/x11/xfce4-screenshooter-plugin && make install clean# touch ~/.config/xfce4/xfce4-screenshooter(没有他工作不了!)# 进入 keyboard 设置 shotcut(PrtScr) 或 从菜单栏点击程序安装 Xfburn(CD/DVD 刻录工具)# cd /usr/ports/sysutils/xfburn && make install clean强大的 命令行刻录工具:(建议使用)# cd /usr/ports/sysutils/dvd+rw-tools && make install clean# growisofs -dvd-compat -Z /dev/cd0 -J -R /path/to/data(刻录 数据DVD)# growisofs -dvd-compat -Z /dev/cd0=imagefile.iso(刻录 映像文件)详情:18.7 创建和使用光学介质(DVD)14:Mplayer/Office/Reader/Gimp/Ristretto/Galculator/Thunderbird/Pidgin/VirtualBox/unix2dos# cd /usr/ports/editors/libreoffice(安装libreoffice)# make LOCALIZED_LANG=zh-CN install clean(添加中文支持)# cd /usr/ports && make search key=adobe|less(安装AdobeReader)# cd /usr/ports/chinese/acroread8-zh_CN && make install clean# cd /usr/ports/graphics/mupdf && make install clean    (安装mupdf)# cd /usr/ports/graphics/epdfview && make install clean    (安装epdfview)# cd /usr/ports/graphics/gimp-help && make config(保留:EN 和 ZH_CN)# cd /usr/ports/graphics/gimp && make BATCH=YES install clean (安装图像处理)# cd /usr/ports/graphics/gimp-manual-pdf && make install clean# cd /usr/ports/graphics/ristretto && make install clean(安装微型图片查看工具)# cd /usr/ports/math/galculator && make install clean(安装图形计算器)# cd /usr/ports/mail/thunderbird && make BATCH=YES install clean (安装雷鸟)# cd /usr/ports/mail/thunderbird-i18n && make install clean# cd /usr/ports/net-im/pidgin/ && make install clean(IM Client 注意端口用8001)# 成功登陆IRC(irc.freenode.net)之后:/cs register #ChannelName Password  ChannelDescription  (注册自己的Channel) # cd /usr/ports/converters/unix2dos && make install clean   (unix2dos and dos2unix)unix2dos and dos2unix are utilities that convertASCII files from the DOS cr/lf format to the UNIXlf format..VirtualBox:# cd /usr/ports/emulators/virtualbox-ose && make install clean# kldload vboxdrvor# echo 'vboxdrv_load="YES"'>>/boot/loader.conf# pw groupmod vboxusers -m yourusername% VirtualBox &=====================================VirtualBox was installed.You need to load the vboxdrv kernel module via /boot/loader.conf:vboxdrv_load="YES"You also have to add all users to your vboxusers group in order to use vbox.% pw groupmod vboxusers -m jerryReboot the machine to load the needed kernel modules.Bridging Support:=================For bridged networking please add the following line to your /etc/rc.conf:vboxnet_enable="YES"USB Support:============For USB support your user needs to be in the operator group and needs readand write permissions to the USB device.% pw groupmod operator -m jerryAdd the following to /etc/devfs.rules (create if it doesn't exist):[system=10]add path 'usb/*' mode 0660 group operatorTo load these new rule add the following to /etc/rc.conf:devfs_system_ruleset="system"Then restart devfs to load the new rules:% /etc/rc.d/devfs restart========================================Qemu:# cd /usr/ports/emulators/qemu && make install clean (add kqemu option)# kldload {kqemu,if_bridge,if_tap,aio}  (必备module)# kldstatCreate a 10GB qcow2 image to install Windows XP# qemu-img create -f qcow2 winxp.img 20GInstalling Windows XP ...# qemu -m 1024 -hda winxp.img -cdrom xp_sp3_vol_x86.iso -boot d -localtimeBoot Windows XP ...# qemu-system-x86_64  -m 1500 -hda winxp.img -cdrom xp_sp3_vol_x86.iso \-localtime -M pc -smp 2 -soundhw es1370 -usb -enable-kqemu -kernel-kqemu  -name winxpPS: Windows XP 占用CPU 100% 很无奈,所以还是模拟 Windows2000吧(这个速度是最快的!)或者 用 VirtualBox 安装 Windows XP ...Qemu 模拟 Win2000# qemu-img create -f qcow2 win2000.img 10G# qemu -m 1024 -hda win2000.img -cdrom win2000.iso -boot d -win2k-hack# qemu-system-x86_64  -m 1500 -hda win2000.img -cdrom win2000.iso \-localtime -M pc -smp 2 -soundhw es1370 -usb -enable-kqemu -kernel-kqemu  -name win2000http://forums.freebsd.org/showthread.php?t=175Mplayer 具体使用:1. xdpyinfo(获得使用您的显卡的X服务器所支持的扩展列表) 常见图像接口列表:X11: 一般性的使用共享内存的X11输出。XVideo: 一种X11接口扩展,支持任何X11图像的可拖拉。SDL: 简单直接媒体层。DGA: 直接图片存取。SVGAlib: 低层次掌控图片层。XVideo(X11扩展接口,用于提高 画面质量)# xvinfoX-Video Extension version 2.2screen #0no adapters presnet(表示显卡不支持 XVideo)2. 安装# cd /usr/ports/multimedia/mplayer(安装mplayer)# make WITH_LANG=zh_CN install clean(选中vdpau显卡加速等需要的选项!)3. 第一次启动前% cd /usr/ports/multimedia/mplayer% make install-user(自动建立: ~/.mplayer)要播放一个文件,如 testfile.avi, 可以通过各种视频接口当中的某一个去设置 -vo 选项:% mplayer -vo xv testfile.avi% mplayer -vo sdl testfile.avi% mplayer -vo x11 testfile.avi# mplayer -vo dga testfile.avi# mplayer -vo 'sdl:dga' testfile.avi(详情:man mplayer /-vo)# mplayer -gui -vo x11 testfile.avi(图形界面, 我保证你不会用)常用命令:# mplayer -fs -zoom -vo xv,x11 testfile.avi(全屏模式,不支持xv 则使用x11,你会不支持xv?)# mplayer -ontop -vo xv testfile.avi(置顶播放)# mplayer -vf screenshot -vo xv testfile.avi(屏幕截图,截图保存到当前目录,按键:s)# mplayer -ss 01:33:00 -vo xv testfile.avi(选择播放起始位置)# mplayer -osdlevel 3testfile.avi(音量 + 搜索 + 计时器 + 百分比 + 总时间)# mplayer -cache 4096 testfile.avi(设定缓冲区:KBytes)# cd ~/audio/;ls |cut -d' ' -f1 > music.lst(制作文件列表,文件名不要留空格)# mplayer -loop 0 -playlist ~/audio/music.lst(无限循环播放列表)# mplayer \http://file2.top100.cn/201110042113/A3C42BFC4C75FAC143DC3DDBEF3D821D/\Special_40202/M0040202001.mp3(Stream From HTTP)# mplayer 不支持 SWF,建议拖到 浏览器里播放!KeyBoard Control:up and down(Seek forward/backward 1 minute)pgup and pgdown(Seek forward/backward 10 minutes)[ and ](Decrease/Increase current playback speed by 10%){ and }(Halve/Double current playback speed)BACKSPACE(Reset playback speed to normal)Playlist:(Go backward/forward in the playlist)ENTER(Go forward in the playlist, even over the end)p / SPACE(Pause, pressing agin unpauses)q / ESC(Stop playing and quit)Sound:9 and 0(Decrease/Increase volume)( and ) (Adjust audio balance in favor of left/right channel)m(Mute sound)OSD States:o(Toggle OSD states: none/ seek/ seek+ timer/seek+ timer+ total time)# mplayer -osdlevel 3testfile.avi设定开始的OSD模式.0只有字幕1音量 + 搜索(默认)2音量 + 搜索 + 计时器 + 百分比3音量 + 搜索 + 计时器 + 百分比 + 总时间Subtitle:v(Toggle subtitle visibility)j(Cycle through the available subtitles)y and g(Step forward/backward in the subtile list)F(Toggle displaying "forced subtitles")a(Toggle subtitle alignment: top/ middle/ bottom)r and t(Move subtitles up/ down)ScreenShot:s(-vf screenshot only)S(-vf screentshot only, Start/ Stop taking screenshots)I(Show filename on the OSD)P(show progression bar, elapsed time and total duration on the OSD)FullScreen & Stay-On-Top :f(Toggle fullscreen, also see -fs -zoom)T(Toggle stay-on-top, also see -ontop)-------------------------------------------------------------为了让 mplayer 的命令行不是太长,使用者可以通过建立一个文件  来设定如下默认选项:# vim ~/.mplayer/configvo=vdpau# 使用 vdpau 输出设备播放fs=yes# 全屏ontop=yes# 置顶zoom=yes# 允许改变窗口大小noaspect=yes# 缩放时保持高宽比osdlevel=3# 显示 当前播放时间 和 总时间:wq-------------------------------------------------------------要播放 DVD, 需要把 testfile.avi 改为 dvd://N -dvd-device DEVICE。 这里 N 是要播放的节目编号, 而 DEVICE 则是 DVD-ROM 的设备节点。例如,要播放 /dev/dvd 的第三个节目# mplayer -vo xv dvd://3 -dvd-device /dev/dvd注意: 可以在编译 MPlayer 时, 通过 WITH_DVD_DEVICE 来指定默认的 DVD 设备。 系统内定的默认设备是 /dev/acd0。 更多细节, 请参考 port 的 Makefile。最后,mplayer 可以把DVD题目(title)抓取成为 .vob 文件。为了从DVD中导出第二个题目,请输入:# mplayer -dumpstream -dumpfile out.vob dvd://2 -dvd-device /dev/dvd  输出文件 out.vob 将是 MPEG 并且可以被这部份描述的其它 “包” 利用。--------------------------------------------------------------------文件:/etc/mplayer/mplayer.conf系统范围的设置~/.mplayer/config用户设置~/.mplayer/input.conf输入绑定(完整按键列表参见’mplayer −input keylist’的输出)~/.mplayer/gui.confGUI配置文件~/.mplayer/gui.plGUI播放列表~/.mplayer/font/字体目录(里面必须有一个font.desc文件和.RAW后缀的文件)~/.mplayer/DVDkeys/破解的CSS密钥字幕文件按以下顺序搜索(比如播放/mnt/movie/movie.avi文件):/mnt/cdrom/movie.sub~/.mplayer/sub/movie.sub~/.mplayer/default.sub15:Using Linux Mode(MacromediaFlash插件没有FBSD版,用Linux wrapper运行其flash版本)# kldload linux(加载进来一会用)# cd /usr/ports/emulators/linux_base-f10 && make BATCH=YES install distclean# vim /etc/rc.conflinux_enable="YES":wq16:Firefox 和 MacromediaFlash 和 Add-ons  and Chromium# cd /usr/ports/www/firefox/ && make BATCH=YES install cleanvim /boot/loader.confsem_load="YES"(加载module):wq# cd /usr/ports/www/firefox-i18n/ && make install clean(中文支持)# cd /usr/ports/www/nspluginwrapper && make install clean(提供flash支持)# cd /usr/ports/www/linux-f10-flashplugin10 && make install clean(安装flash插件)# 安装版本11的话不需要 挂载 linproc , 我安装的11 ..# cd /usr/ports/www/linux-f10-flashplugin11 && make install clean(安装flash插件) #  ln -s /usr/local/lib/npapi/linux-f10-flashplugin/libflashplayer.so \/usr/local/lib/browser_plugins/(做个symbolic Link,官方文档:browser_plugins是个目录,没有的话要创建)(目录不行:请直接连接,我就是 直接链接的!)# rehash(Updates FreeBSD's path environment variables)For instance when you have installed software you may not be able to run the executables without specifying the path.rehash solves your problem most of the times>% nspluginwrapper -v -a -i(插件必须由每个用户运行 nspluginwrapper 安装)# 安装版本11(linux-f10-flashplugin11)的话不需要 进行下面的操作 挂载 linproc , 我安装的11 ..实现播放flash 动画效果:# mount -t linprocfs linproc /usr/compat/linux/proc(挂载 linproc ,事实上 procfs存在安全问题FBSD早就废弃了)# vim /etc/fstablinproc/usr/compat/linux/proclinprocfsrw00(开机自动挂载):wqAdd-ons:firefox - Edit - Preferences - Manage Add-ons - SearchEase Link:(转换迅雷、QQ旋风、快车专用链接)Adblock Plus:(屏蔽广告)Adblock Plus Preferences - Filters -Add filter subscription - Update all subscriptionsNetVideoHunter Video Downloader:(视频地址检测)NetVideoHunter Options - Show in statusbar - Enable the capturing of SWF filesPS: npviewer.bin 该进程为flash进程,当关闭flash后不会自动结束,sockstat |grep npviewer.bin 会看到N多 占用内存超多我的办法是:# echo 'alias killflash killall npviewer.bin'>>~/.cshrcChromium# cd /usr/ports/www/chromium/ && make install cleanecho 'aliaschromechrome --incognito'>>~/.cshrc17:compiz-fusion (3D效果)# cd /usr/ports/x11-wm/compiz-fusion && make BATCH=YES install clean% vim start-compiz#!/bin/shcompiz --replace --sm-disable --ignore-desktop-hints ccp &emerald --replace &:wq% chmod +x start-compiz% echo "start-compiz" >> ~/.xinitrcPS: 如果使用了 XDM% echo "start-compiz" >> ~/.xsession% startx 简单设置: 在CompizConfig设置管理器>首选项>在后端选择GConf Configuration Backed (开启即时生效)  接着> 启用 最小化效果、窗口装饰、震颤窗口、移动窗口、调整窗口大小、应用程序切换条,基本的3D桌面竣工!18:Security监视ports所有软件包安全:# cd /usr/ports/ports-mgmt/portaudit && make all install clean(portaudit)# portaudit -Fda(更新数据库, periodic每天自动更新!)# portaudit -a(开始检查)输出如下:Affected package: cups-base-1.1.22.0_1Type of problem: cups-base -- HPGL buffer overflow vulnerability.Reference: 1 problem(s) in your installed packages found.You are advised to update or deinstall the affected package(s) immediately.----------------------------------------------------------------------------------------------------------# cd /usr/ports/ports-mgmt/pkg_cleanup && make install clean       (关于删除冗余ports )FROM: http://wiki.freebsdchina.org/software/p/pkg_cutleavesRootKit:# cd /usr/ports/security/rkhunter && make install clean(rkhunter )Sudo:# cd /usr/ports/security/sudo && make install clean# visudoko ALL=(root) !/usr/bin/passwd, /usr/bin/passwd [A-Za-z]*, !/usr/bin/passwd root, /usr/bin/su -Integrity:# cd /usr/ports/security/aide && make install clean(aide )# cd /usr/ports/security/tripwire && make install clean(tripwire )可用 mtree检查完整性:# mtree -x -ic -K cksum -K md5digest -K sha256digest -p / \-X /home/mwlucas/mtree-exclude > /tmp/mtree.savedspec(Use -X  to specify a file containing a list of paths not to match)# mtree -f savedspec -f newspec > mtree.differencesAntiVirus:# cd /usr/ports/security/clamav && make install clean(clamav )# cd /usr/ports/security/squidclamav && make install clean(squidclamav )Monitor:# cd /usr/ports/net-mgmt/cacti && make install clean(cacti)# cd /usr/ports/net-mgmt/nagios && make install clean(nagios)# cd /usr/ports/security/nessus && make install clean(nessus)# cd /usr/ports/sysutils/lsof && make install clean(lsof)# cd /usr/ports/sysutils/pidof && make install clean(pidof)# cd /usr/ports/security/nmap && make install clean(nmap)# cd /usr/ports/net/wireshark && make install clean(wireshark)# cd /usr/ports/net/tcpdump && make install clean(tcpdump: 系统自带)Unix Password Cracker:# cd /usr/ports/security/crack && make install clean(/usr/local/crack/Crack)Rar Zip 7Z Password Cracker:# cd /usr/ports/security/rarcrack && make install clean(rarcrack )Ciphertext Cracker:# cd /usr/ports/security/rainbowcrack && make install clean(rainbowcrack )----------------------------------------------------------------------------------------------------------Tweaking User Security# vim /etc/login.access(Rules are checked on a first-fit basis)-:ALL EXCEPT wheel:console-:ALL EXCEPT wheel dns webmasters:ALL# vim /etc/login.conf(Restricting System Usage):maxproc-cur: 30:\(Current Resource Limits):maxproc-max: 60:\(Maximum Resource Limits):passwd_format=md5:\(md5 or  blf):minpasswordlen=28:\(Password length Limits):mixpasswordcase=true:\(Password case Limits):wqIf present, FreeBSD complains if the user changes his password to an all lowercase word.# cap_mkdb /etc/login.conf(rebuilds the database file /etc/login.conf.db)PS:in fact, /etc/hosts.equiv and its related services have bitten eventop-notch security experts who thought they could use it safely. I suggestleaving this file empty and perhaps even making it immutable !19:SSHClient: ssh user@host(需要密码 ,远程主机信息保存在:~/.ssh/known_hosts)scp filename user@host:~/sftp user@host# ssh-keygen -lf /etc/ssh/ssh_host_dsa_key.pub(检查SSH 主机 PubKey 的 fingerprint,Client端会自动下载并比对)用户密码被强制到28位怎么记得住啊?(用PubKey实现无密码登录 !)Client:ssh-keygen -t rsa -b 2048(为本机 生成 一对密匙)scp .ssh/id_rsa.pub user@host:~/(把PubKey 发到Server 用户家目录)Server:cd ~user; mkdir .sshcat id_rsa.pub >> .ssh/authorized_keys(Server 把Client端 PubKey添加到 授权文件内)Client:ssh user@host(现在可以无密码登录喽!)20:Insecure Console (Single-user mode)When you boot FreeBSD in single-user mode, you get a root commandprompt. This is fine for your laptop and works nicely for servers in yourcorporate datacenter, but what about machines in untrusted facilities?# vim /etc/ttysconsole none unknown off secureTo make the console require a root login when booted into single-usermode, change the secure to insecure.# vim /etc/ttysconsole none unknown off insecure:wq第一人称射击游戏 Nexuiz  开源赛车Vdrift 开源红警游戏 OpenRedAlertLinux下魔兽争霸 Heroes of NewerthHeroes of Newerth 是一款类似于“魔兽争霸3”中 DotA 场景的游戏,支持 Windows,Linux,Mac 操作系统。HON 提供了比 Warcraft III DotA 场景更好的图形效果,并且支持 VoIP。Heroes of Newerth 游戏特点:自动选择水平相近的队友和对手个人战绩统计包括来自 DotA 和 Savage 2 世界的各种英雄内嵌地图编辑器掉线的玩家可以再度加入游戏可以创建不允许早退玩家的房间服务器-客户端联网模式,不再“一人卡众人杯具”快捷键自定义内嵌语音聊天# 平衡球 Neverball (http://neverball.org/download.php) 支持Windows/Linux/BSD/Mac# cd /usr/ports/games/neverball && make install clean#配置文件一览:# ~/.cshrc# added by ko BEGINsetenv PACKAGEROOT ftp://ftp.freebsd.orgsetenv PKG_TMPDIR /var/garbageset autolistalias cl clearalias df df -halias lock xflock4alias chrome chrome --incognitoalias adobe acroread8alias killflash killall npviewer.bin# ps axo pid,comm,pcpu,pmem# history -c (clear history)# wget -r -np -p -k --level=2 http://freebsd.org/handbook/# added by ko END有意思的命令,或许阁下用得上哦! ^_^N:MLDonkey(电驴、BT )# cd /usr/ports/net-p2p/mldonkey# make WITHOUT_GUI=yes WITHOUT_X11="YES" WITHOUT_TK="YES" install clean%ln -s ~/.mldonkey/incoming ~在/etc/rc.conf加入mlnet_enable=“YES” 和 mlnet_user=“用户名非root“%/usr/local/etc/rc.d/mlnet start (注意是%)1.%telnet 127.0.0.1 40002.>auth admin ""3.>passwd 键入你想设置的密码4.>set allowed_ips "127.0.0.1 192.168.0.0/24" (根据你自己的情况设置)5.>save6.>exit(mldonkey需要一个非root用户来运行。我习惯在装系统的时候就建立一个wheel组的用户,所以这里我就不用在建立用户了。)现在就可以在浏览器里输入:localhost:4080来设置和下载文件了。默认mldonkey的文件夹是隐藏的,在用户目录下。找下载好的电影有点不方便,把incoming连接到你的用户目录下就好了。当然你也可以自己修改默认下载路径。mldonkey简单设置:enable_kademlia的选项为true――打开kad减少对服务器的依赖。max_hard_upload_rate默认是10 (全局最大上传,根据自己情况设置)max_hard_download_rate默认是50 (全局最大下载,根据自己情况设置)mldonkey有两组两组带宽控制模式,通过点击Bandwidth toggle来更改带宽控制模式。=添加服务器列表:=先删除原先的服务器列表下载地址。点击Options>Web infos找到server.met行然后点击前面的Remove然后点击Add Url输入“server.met http://ed2k.im/server.met”(不包括引号,放心都是安全服务器列表。)再点击前面的DL也就是DownLoad。=添加kad节点信息=点击Options>Web infos>Add Url输入nodes.gzip http://ed2k.im/nodes.dat=添加firefox for mldonkey插件=下载地址:http://www.informatik.uni-oldenburg.de/~dyna/mldonkey/
11-02 11:32