computer:os:freebsd
目錄表
FreeBSD
常用指令
- 依檔案大小排序
ls -S
- 查看硬碟用量
df -h
- 查看資料夾用量
du -h
- pure-ftpd查看即時狀況
pureftp-who
- FTP傳輸紀錄
tail /var/log/xferlog
- CVSUP
cvsup -g -L 2
接上檔案
Ports管理
- 強迫重裝
make -DFORCE_PKG_REGISTER reinstall
- 修正關聯
pkgdb -F
- 更新
portsdb -Fu pkgdb -F portupgrade -aWy portupgrade -arR
- Patch libiconv
先到 /usr/ports/converters/libiconv/ 執行 make clean make extract 之後把patch過的big5.h和ces_big5.h放到 /usr/ports/converters/libiconv/work/libiconv-1.9.2/lib 取代掉原有的檔案,之後回到/usr/ports/converters/libiconv/執行 make deinstall make install 這樣就完成了
需要裝的
- portupgrade
升級套件用 - portaudit
FSCK設定
- 在/etc/rc.conf加入
fsck_y_enable="YES" background_fsck="NO"
Apache設定
- 設定檔
/usr/local/etc/apache22/httpd.conf
- 重新啟動
/usr/local/etc/rc.d/apache22 restart
Logs Rotate
- apache 的 log 需要定期 rotate ,要不然會爆炸。可以直接透過 newsyslog 來做,直接把下面這兩行加入你的 /etc/newsyslog.conf
/var/log/httpd-access.log 644 3 1 @T00 Z /var/log/httpd-error.log 644 3 1 @T00 Z /var/run/httpd.pid
Virtual Host
<VirtualHost *:80> ServerAdmin wm@gmail.com DocumentRoot /usr/local/www/apache22/data/ ServerName kidwm.net ErrorLog /var/log/httpd-error.log CustomLog /var/log/httpd-access.log combined </VirtualHost>
傳輸壓縮
- mod_deflate
http://yblog.org/archive/index.php/5318
<ifmodule mod_deflate.c> DeflateCompressionLevel 9 AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php AddOutputFilter DEFLATE js css </ifmodule>
Alias轉換
# phpMyAdmin Alias /phpma/ "/backend/phpma/" <Directory "/backend/phpma"> AllowOverride FileInfo AuthConfig Limit Options Indexes FollowSymlinks MultiViews </Directory>
擋機器人
-- <LIMIT GET POST> Order allow,deny Allow from all # baidu Deny from 61.135.0.0/16 # yahoo Deny from 66.196.90.0/24 # yahoo china Deny from 202.160.0.0/16 # openfind Deny from 140.123.101.0/24 # baidu Deny from 202.108.0.0/16 # sogou Deny from 220.181.0.0/16 # openfind Deny from 210.201.54.0/24 </LIMIT> --
DNS與named設定
rndc-confgen -s 163.19.163.93 -a
- 注意!named.conf要把listen-on那行comment掉,這樣外部IP的才會處理
- 設定檔位置:/etc/namedb/master/kidwm.fwd
- 啟動: /etc/rc.d/named start
Mail程式設定
mutt
- 設定檔在
~/.muttrc
- 設定檔內容:
my_hdr From: "OO, XX" <xxx@CCCA.NCTU.edu.tw> set send_charset="big5" charset-hook us-ascii big5 charset-hook iso-8859-1 big5 set charset=big5 set locale="zh_TW.big5"
crontab 排程
- 使用者設定指令:
crontab -e
- 預設執行的Shell不同,需手動設定
SHELL=/bin/tcsh
- 執行結果不通知使用者
MAILTO=""
cvsup 更新
cd /usr/ports/net/cvsup-without-gui ; make install clean distclean
SUPHOST= cvsup7.tw.FreeBSD.org
SUPFILE= /usr/share/examples/cvsup/standard-supfile
PORTSSUPFILE= /usr/share/examples/cvsup/ports-supfile
PPPoE設定
Firewall設定
舉例來說, freebsd.nctu 的 /etc/rc.conf
firewall_enable="YES" firewall_script="/usr/local/sbin/firewall.sh"
然後寫一個 /usr/local/sbin/firewall.sh 放 rule 就好了
/etc/rc.firewall 是給不會詳細設定的人, 可以簡單用一個選項來選擇目前機器是什麼情況下來啟動 firewall rule
--
#!/bin/sh
fwcmd="/sbin/ipfw -q"
# flush
${fwcmd} -f flush
# accept all packet from myself
${fwcmd} add allow ip from any to any via lo0
# mysql
${fwcmd} add deny tcp from any to me 3306
# 52834
${fwcmd} add allow tcp from any to me 52834 limit src-addr 16
-- end
要加規則就是在 lo0 後面加就好了
PF設定
- 在/etc/rc.conf裡面加入
pf_enable="YES" pf_rules="/etc/pf.conf" pf_flags="" pflog_enable="YES" pflog_logfile="/var/log/pflog" pflog_flags=""
- 複製/usr/share/examples/pf/pf.conf這個範例檔到/etc下面
- 開始修改/etc/pf.conf
- 把
#ext_if="ext0"
這行取消註解,改成現用的對外網路卡裝置名稱。(忘了裝置名稱可以進rc.conf看一下)
- 在#table <spamd-white> persist這行底下加入
table <taiwan> persist file "/etc/allow_taiwan"
- 最後面加上
pass in all pass out all block in on $ext_if proto tcp from any to $ext_if port 22 pass in on $ext_if proto tcp from <taiwan> to $ext_if port 22 keep state
- 參考這篇文章,將台灣的網段加入/etc/allow_taiwan檔案裡面。
安裝更新
參考資源
FreeBSD與Postfix http://www.osal.org/index.php?option=com_content&task=view&id=16
in2長輩的裝機筆記 http://in2.wiki.ptt.cc/-installFreeBSD
Rafa長輩的UTF8筆記 http://wiki.rafan.org/doc/utf8note
computer/os/freebsd.txt · 上一次變更: 2010/12/07 11:12 由 wm
