2009年3月9日 星期一

[freeBSD] 常用網路功能指令

ifconfig #查看網路卡工作狀態
ifconfig eth0 down #停用網卡eth0
ifconfig eth0 up #啟用網卡eth0
ifconfig eth0 140.119.x.x masknet 255.255.0.0 #設定網卡IP

netstat #顯示網路狀況。可以用來看網路的組態及各項服務的情形

-a #顯示所有狀態
-n #以 number 方式顯示 IP 位址
-i #顯示網路介面

# netstat -agrep LISTEN

nslookup 140.119.x.x
#查看主機位置,140.119.x.x的domain name或反查該domain name的IP

tcpdump #列出所有到達本機的 tcp 封包

2009年3月8日 星期日

[freeBSD] 自動備份http log檔

作為網頁伺服器,每天會有來自不同地方的數以百計的人來訪
httpd.acess-log或httpd.error-log分別紀錄下存取和錯誤的log歷史
如此日漸增大的檔案,必須要進行分割備份以避免同一個檔案無限量增大

在此使用/etc/newsyslog.conf 來設定自動備份

使用編輯器把newsyslog.conf打開

加入下面兩行指令
/var/log/httpd-access.log 644 7 * $W0D1 J /var/run/httpd.pid
/var/log/httpd-error.log 644 7 * $W0D2 J /var/run/httpd.pid


※將 /var/log/httpd-access.log 這個檔案做備份,
備份後的檔案名稱像這樣 httpd-access.log.0.bz2 。
備份後該檔案的權限是 644,
最大的數字到 7,也就是最多8個檔案,
*星號代表不限制檔案多大時要備份,
選在每週日半夜 1 點時備份,
並將該檔以 bzip2 壓縮。
在備份完後,要將 /var/run/httpd.pid 所記錄的 Process ID 重新啟動。


以上參考自twbsd.org網頁伺服器篇

2009年3月4日 星期三

[freeBSD] vim功能修正

熟悉了linux的vim操作後
使用freeBSD的vim就覺得差很多
一整個不習慣
不過可以籍由vimrc這個設定檔來修改以配合自己的習慣

1. 在/usr/local/share/vim/ 底下建立一個vimrc的檔案
vi /usr/local/share/vim/vimrc


2. 把下列的屬性貼上去
set fileencoding=taiwan
set guifontset=8x16,kc15f,-*-16-*-big5-0
set cindent
set enc=taiwan
set hls
set nocompatible #解決上下左右會出現英文的情況
set sw=2
set backspace=2 #可使用backspace鍵來往回刪除字元
syntax on #語法顏色
highlight Comment ctermfg=darkcyan
highlight Search term=reverse ctermbg=4 ctermfg=7


3. cp vimrc /home/usr #將vimrc 設定檔拷貝給現有使用者

4. cp vimrc /usr/share/skel/dot.vimrc #日後新增帳號自動複製給該帳號

[FreeBSD] 一般用戶使用tab補齊鍵功能

因為一般用者使用的shell為sh
而不是root使用的csh
所以無法像root那樣使用tab鍵來補齊指令

修改方法:
chsh #更改shell

進入shell資料後
把Shell的/bin/sh 更改為 /bin/chsh
儲存離開

重新登入後會發現指令開端會變為'%'

2009年3月3日 星期二

[freeBSD] 程式安裝

1. 使用package 安裝
sysinstall
進入安裝選單後, 選取適當的連線方法
如FTP, 再選取站台後, 選取要安裝的軟體

2. 使用port安裝
cd /usr/ports #進入/usr/ports/ 資料夾中
再進入要安裝的資料夾中
網頁架站用軟體
apache => www
mysql => databases
php => lang

3. 移除軟體
pkg_delete apache22 #移除apache22
-f 強制移除

[freeBSD] 使用者管理

新增使用者zen
adduser zen


刪除使用者zen
rmuser zen
※刪除使用者會把crontab, at, master.passwd, 正在執行的程式等都刪除掉
Powered By Blogger

Label Cloud

2009 (1) 不能連localhost (1) 內嵌音訊 (1) 求職 (1) 面試 (1) 音樂 (1) 動畫師 (1) 帳號管理 (1) 排程 (1) 畢展 (1) 創意市集 (1) 惡意程式 (1) 電腦動畫 (1) 權限管理 (1) adobe (1) android (4) animation (1) animator (1) apache (3) art (5) art taipei 2008 (1) audio (2) bbs (1) birthday (1) black and white (1) browser (2) career (2) certification (1) cgw (1) cinematography (1) code (3) Collie (1) color (2) command (16) competition (1) computer science (3) connection (1) cover (1) crafyJS (1) creative (1) CSS (1) DBN (2) design (7) developer (1) display (1) drawing (1) eclipse (3) embed (1) engine (1) EntityJS (1) exception (1) exhibition (1) flower (1) frame (1) freebsd (11) french (1) friends (3) function (1) game (1) google (2) graphic (3) html (2) HTML5 (1) https (1) illustrator (1) image processing (1) interactive storytelling (1) internet (3) interview (1) introduce (1) ip (1) japan (1) java (4) javascript (3) JIT (1) jmonkey (1) job (1) jquery (1) LAMP (1) LimeJS (1) linux (8) liquid galaxy (1) ListView (1) localhost (1) log (1) mail (1) marquee (1) midi (1) mime-type (1) mis (1) MIT (2) mo-cap (1) mobile (1) Modernizr (1) motion capture (1) movie (1) music (3) narrative (2) NCCU (3) news (1) note (10) originality (1) otaku (1) painting (4) performance (1) photography (2) photoshop (7) php (1) player modelling (1) poster (1) postfix (1) programming (5) QuarkJS (1) resource (1) schema (1) scroll (1) self aware (1) semantic (1) server (1) share (1) sketch (2) software (4) solve (2) Sonivox (1) speaking (1) ssl (1) SSLPeerUnverifiedException (1) streaming (1) Subversion (1) sunspider (1) SVN (3) svn server (1) system (1) taipei (1) test (1) tfam (1) tool (1) TortoiseSVN (1) tutor (1) ubuntu (3) update (1) uri (1) video (1) vim (1) w3c (1) wap wcss css css2.0 (1) web (8) WebGL (1) webkit (2) well-form (1) wiimote (1) wiiusej (1) workshop (1) xhtml (1) xml (2)