星期三, 8月 19, 2009
Squid 執行狀態
/etc/squid/squid.conf
cachemgr_passwd yourpassword all #設定密碼
acl our_networks src 192.xxx.xxx.0/24 192.xxx.xxx.0/24
http_access allow manager our_networks #讓內網 PC 使用 cache manager
http_access deny manager #不許其它 PC 使用
/etc/squid/cachemgr.conf
加入一行 192.xxx.xxx.xxx #Squid 主機 IP
要察看Cache Manager提供的資訊時,可在瀏覽器位址列鍵入
http://伺服器的名稱或IP位址/cgi-bin/cachemgr.cgi
星期二, 8月 18, 2009
Squid Efficiency Analyzer 1.1.0
網站指是用在 Squid 2.5,但我用在2.6也沒有問題。
其他分析軟件可以在這裡找
http://www.squid-cache.org/Misc/related-software.dyn
Squid Transparent Proxy 設定
因為不再在用戶 PC 指定 proxy 的 IP,所以要在 squid.conf 內設定每個服務網域的 proxy 阜;
http_port 192.xxx.xxx.xxx/nn:3128 transparent
http_port 192.xxx.xxx.xxx/nn:3128 transparent
因主機連接外出網路,指定可服務網域會比較安全。
同時也要加入 NAT Routing 把所有到80阜的轉向3128阜;
iptables -t nat -A PREROUTING -i eth0 -p tcp -s 192.xxx.xxx.0/nn \
--dport 80 -j REDIRECT --to-ports 3128
iptables -t nat -A PREROUTING -i ath0 -p tcp -s 192.xxx.xxx.0/nn \
--dport 80 -j REDIRECT --to-ports 3128
eth0 及 ath0 是『NAT 對內的網路卡裝置代號』
星期六, 7月 04, 2009
CD/DVD Cannot Mount Volume
Cannot Mount Volume
"Mount failed for /org/freedesktop/Hal/devices/volume_label_NEW org.freedesktop.DBus.Error.AccessDenied : A security policy ..."
解決方法是要把 user 如以下的加入 /etc/dbus-1/system.d/hal.conf 內;
<policy user="xxxxxx">
<allow send_interface="org.freedesktop.Hal.Device.SystemPowerManagement"/>
<allow send_interface="org.freedesktop.Hal.Device.VideoAdapterPM"/>
<allow send_interface="org.freedesktop.Hal.Device.LaptopPanel"/>
<allow send_interface="org.freedesktop.Hal.Device.Volume"/>
<allow send_interface="org.freedesktop.Hal.Device.Volume.Crypto"/>
</policy>
星期五, 3月 13, 2009
星期六, 3月 07, 2009
用 RamDisk(tmpfs) 加速 Linux
1. 用/dev/shm, 可執行以下指令
mkdir /dev/shm/tmp
chmod 1777 /dev/shm/tmp
mount --bind /dev/shm/tmp /tmp
註:
/dev/shm 不完全是 ramdisk,若它使用超過電腦一半以上的 RAM,就會開始吃 SWAP。另外它沒用到的部份,會自動釋放出來給系統使用。
寫入 rc.local 可能會出現問題,因為在那之前就啟動 x-window 了,而啟動 X 時會寫入一些東東到 /tmp,此時就會出錯,導致啟動失敗。
2. 在 fstab 內加下面這一行
none /tmp tmpfs defaults,size=64M 0 0
詳細的說明
Linux Tmpfs 系統加速實作
拿 RAM 當硬碟來用(RAM Disk)
星期五, 3月 06, 2009
Clone Linux 到新硬碟
1. 先下載並燒製 gparted 的開機光碟
2. 安裝新硬碟到電腦
3. 用 fdisk 在新硬碟建立一個 partition
4. 執行 ddrescue -v /dev/hda(舊) /dev/hdc(新)
5. 關機、移除舊硬並用新硬碟代替舊硬碟,若不用變更 partition 可直接用新硬碟開機
6. 以 gparted 光碟開機,變更 partition 的大小后便可直接用新硬碟開機
gparted的網站
http://gparted.sourceforge.net/
星期四, 3月 05, 2009
為 Scientific Linux 安裝對 ntfs 的支援
1. 先 enable rpmforge repo
2. 執行 yum install fuse fuse-ntfs-3g dkms dkms-fuse
3. 在 /etc/fstab 寫入;
/dev/hdx1 /mnt/backup ntfs-3g rw,umask=0000,defaults 0 0
4. 執行 mount /mnt/backup
參考:
http://wiki.centos.org/TipsAndTricks/NTFS
星期三, 3月 04, 2009
lm_sensors 溫度、電壓偵測程式
yum install lm_sensors
2. 執行 sensors-detect 指令
sensors-detect
3. 根據 sensors-detect 結果編輯 /etc/modprobe.conf 及 /etc/rc.d/rc.local
4. 重新開機後執行 sensors 指令就可看到電腦 CPU 溫度及電壓。
sensors
星期二, 3月 03, 2009
用 NTP 跟網絡時間伺服器同步
Linux
先用 ntpdate 同步Linux OS 上的時間,再用 hardclock -w 同步 Bios 上的時間,並在/etc/crontab
加入這一行。
0 0,8,16 * * * root /usr/sbin/ntpdate stdtime.hk && /sbin/hwclock -w
(每8小時同步一次)
Windows XP

參考: 鳥哥的Linux私房菜
星期五, 2月 27, 2009
小、快、美的 Linux pdf reader

下載連結
http://www.foxitsoftware.com/pdf/desklinux/
星期四, 2月 26, 2009
Madwifi 與 ath5k 衝突
雖然 ath5k 較新,而且 build in 在新 kernel 之內,可是 ath5k 還未支援 ap mode,所以還是要用 madwifi。
解決衝突的方法是禁止 ath5k 的 driver module;
1. 執行 rmmod ath5k
2. 將以下一行加進 /etc/modprobe.d/blacklist 檔。
blacklist ath5k
星期二, 2月 24, 2009
NX Server Linux伺服器遠端連線解決方案
NoMachine 的方案好處是安裝設定簡單,而且用户評價也不錯。
NX Server 有免費版,雖然只支援兩個clients,對我來說也以經足够了。
1. 下載 NX Server 套件
http://www.nomachine.com/download.php

2. 在Linux伺服器安裝 NX Server 套件

執行 rpm -ivh nxclient-3.x.rpm rpm nxnode-3.x.rpm nxserver-3.x.rpm
(註:不知為甚麼我要reboot才可以使用 NX Server)
執行 nxserver --version 確定 nxserver 安裝無誤
執行 netstat -nlp 確定 nxagent、sshd 正在運行
3. 在 Windows PC 安裝 NX Client 用戶端軟件
4. 執行 NX Client 連線到主機來操作主機
星期一, 2月 23, 2009
Linux 上的網絡設定
/etc/sysconfig/network
主機名稱設定定義在這個檔案的 HOSTNAME 變數中。
/etc/hosts
建立主機名稱與 IP 的對應
在我的機器上﹐/etc/hosts看上去是這樣的
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost linuxserver
::1 localhost6.localdomain6 localhost6
每一行句子的欄位分別是﹕IP 位址﹑主機名稱﹑主機別名(可以多個﹐用空白鍵分隔)。
/etc/resolv.conf
主要用來設定 dns client 端上所使用的 DNS server,最多可以設定三個 namesever
search localhost
nameserver 210.0.128.241
nameserver 210.0.255.144
/etc/host.conf
告訴系統在進行名稱解釋的時候所使用的方法﹐以及使用順序。order後的 hosts 就是告訴系統首先查詢 /etc/hosts 檔﹐如果沒有結果﹐則轉向 bind﹐也就是 DNS 服務的意思。
order hosts,bind
/etc/samba/smb.conf
設定 samba 在 windows 檔案管理員的顯示字串及主機名
server string = 顯示字串
netbios name = 主機名
星期一, 4月 14, 2008
Activate PHP 的 GD 模組
yum install php-gd
安裝完便可即時用到GD的功能。
星期六, 2月 02, 2008
madwifi 行 WPA
Hostapd 沒有 rpm 安娤,需要從網上下載 source 來 自己 configure 及 compile。
因只要用 WPA-PSK,所以可在 .config 中 刪去大部份不用的 drivers,這樣可同時減少 compile 時出問題的機會,我的 .config 檔只剩下 statements:
# Driver interface for madwifi driver
CONFIG_DRIVER_MADWIFI=y
CFLAGS += -I/usr/src/madwifi-ng # change to reflect local setup; directory for madwifi src
# IEEE 802.11F/IAPP
CONFIG_IAPP=y
# WPA2/IEEE 802.11i RSN pre-authentication
CONFIG_RSN_PREAUTH=y
建立 .config 檔後隨即執行以下指令 compile:
make clean
make
make install
然後再修改 hostapd package 內的 madwifi.conf 來建立 /etc/hostapd.conf,要修改的 statement 有以下幾條:
ssid=wpa-test (設定 ssid)
#bridge=br0 (remark 因沒有行 bridge)
#eap_server=0 (remark 因沒有 compile EAP server)
wpa=1 (設定行 WPA2)
wpa_passphrase=secret passphrase (設定密碼)
wpa_key_mgmt=WPA-PSK (設定行 WPA-PSK)
wpa_pairwise=TKIP CCMP (設定可用 TKIP 及 CCMP)
Madwifi driver 不用再設定,直接執行以下指今啟動 hostapd 就可以提供 WPA 加密:
/usr/local/bin/hostapd -B /etc/hostapd.conf
我在 rc.local 檔加上以上指今,以後開機就會自動啟動 hostapd。
注意:
1. 在 Windows 建立的 config 檔可能會在 compile 或啟動 hostapd 時產生 errors.
2. 不要用 madiwifi.org 提供的 hostapd.conf scripts,因 hostapd 新 version 有些參數已改了。
3. 新的 Scientific Linux 已不預設提供 madiwifi,所以更新 kernel 後 hostapd 可能執行會有問題,要反安娤 madwifi 後再重娤才可正常運作。
參考
WPA on madwifi: AP & Station
hostapd
安娤 CentOS Kernel Source
yum install kernel-devel
yum install kernel-xen-devel
yum install kernel-PAE-devel (only for i386)
參考:
I Need to Build a Custom Kernel
星期五, 2月 01, 2008
Auto-reboot Linux after a kernel panic
TechRepublic 的原文;
"Linux is a robust and stable operating system kernel, but there are instances where it can panic, be it due to bad hardware or bad software. It does not happen often, but it can happen.
If you’re running a server or some other always-on system that you may not have easy access to, a kernel panic typically means an inconvenient trip to reboot a system or a phone call to inconvenience someone else. You can, however, configure Linux to automatically reboot on a kernel panic by making a small modification to /etc/sysctl.conf, a configuration file that tweaks many kernel operating parameters.
Add the following to /etc/sysctl.conf:
kernel.panic = 20
This tells the kernel that if it encounters a panic, it is to reboot the system after a 20 second delay. By default, the kernel will never reboot when it encounters a panic, but with the above setting you can force it to."
星期一, 5月 21, 2007
Patch Linux kernel with madwifi
星期五, 5月 18, 2007
Linux laptop_mode
要確定硬碟 status,可用 hdparm -C /dev/hda 查看。
下載 laptop_mode tool
http://www.xs4all.nl/~bsamwel/laptop_mode/tools/
hdparm Wiki
http://wiki.gentoo.tw/mediawiki/index.php/Hdparm