Thursday, July 24, 2008

讓FreeRadius Server整合Linux上的帳號做認證

很久以前有介紹透過FreeRadius Server裡的users來做使用者認證,在此update一下透過Linux本機帳號來做認證。

Step1. 將啟動radius server的使用者改為root
# vi /etc/raddb/radiusd.conf


如果不這麼做的話,當啟動radius server時,由於radiusd user對於/etc/shadow沒有讀取的權限,故會發生permission denied。網路上有找到PAM Support for FreeRadius (http://www.sfr-fresh.com/unix/misc/freeradius-1.0.5.tar.gz:a/freeradius-1.0.5/doc/rlm_pam)的文章,可是照著做還是不能work,所以先以此方法來實現。

Step2. Enable Unix account authentication
# vi /etc/raddb/radiusd.conf
unix {
cache=yes
passwd= /etc/passwd
group=/etc/group
shadow=/etc/shadow
radwtmp=${logdir}/radwtmp
}




Step3. 以debug mode啟動
先以debug mode啟動radius server看看是否能啟動成功:

………………. Message

如果看到Ready to process requests的話就代表成功了。
Note: 目前只允許localhost (127.0.0.1)可以連線,如果要允許別的網段或IP連線到本機認證的話請修改 /etc/raddb/clients.conf

Step4. 以本機使用者認證:
Usage: radtest

如果看到回應Access-Accept ……… 那麼就是代表認證成功。

Step6.以daemon方式啟動radius server,並測試:


成功的以daemon的方法啟動radius server,並且能正常工作。

Wednesday, July 23, 2008

Tcl + expect 簡單實作

這陣子在幫公司做些自動化測試的環境,故常利用到tcl搭配expect故在此做個雜記:
舉個簡單的例子,透過tcl與expect ssh login到遠端機器並將它reboot:

整個tcl的內容如下:
#!/usr/bin/tclsh
package require Expect
set ip [lindex $argv 0]
spawn ssh -o StrictHostKeyChecking=no Administrator@$ip
expect "Password: "
send "aaaa\r"
expect ">"
send "reboot\r"
expect "(y/n)"
send "y\r"
expect "# "

以expect期待得到怎樣的輸出後,便使用send輸入命令,而每台機器所吐出來的prompt都不相同,請自行更改。

執行: ./reboot.tcl 192.168.0.1

Saturday, July 19, 2008

赤壁

今天跟老婆請了特休幫小女開戶,之後到中和的環球國賓影城去看赤壁,說起來不難看但是也沒說多好看到那邊去,也許是因為我看過大陸電視版的三國演義,每個段落總是會比較一下,電影場面雖大,但是人物的刻化似乎就沒有那麼傳神了,特別是諸葛亮說服東吳參戰的過程實在不夠精彩,電視版的諸葛亮(唐國強先生飾演)舌戰群臣的一慕實在是令人非常之佩服,相比之下,電影就有點遜色了,想起電視版星落五丈原的那幕:亮不能臨陣討賊,憂憂蒼天,何薄於我。總是會忍不住內心的激動而落下眼淚,唐國強先生的確是把諸葛亮演得非常之成功!

話題扯遠了,回歸正題,我覺得赤壁還算是這幾年來華語片中挺好看的片子,雖然有幾段劇情與史實不太符合但也不至於被改得太誇張,精彩的戰鬥場面替整部片加分了不少,我不是影評人,但是如果要我給分數的話那麼我會給它79分,主要是因為我覺得很多橋段是多餘的,如果能多加強以下幾點那麼整部片將更加完美了:
- 長板坡上的英雄,趙子龍的冷靜與霸氣,浴血救少主,七進七出呀!
- 張飛喝退曹軍百萬雄兵,大喝一聲使曹將摔馬
- 諸葛亮舌戰群臣,製造與論,說服東吳參戰,讓劉軍從中得利

BTW, 老婆不懂三國歷史,一直問我接下來會如何,所以剛剛在網路上買了電視版三國演義全集幫她惡補一下。

Wednesday, July 16, 2008

Kernel Vulnerability in Ubuntu 8.04, 7.10, 7.04 and 6.06 LTS. Upgrade Now!

得到消息Ubuntu Linux Kernel有安全性的漏洞,將導致DOS攻擊。詳情請參考以下連結:

Kernel Vulnerability in Ubuntu 8.04, 7.10, 7.04 and 6.06 LTS. Upgrade Now!



看來我又要recompile一些套件了。

Friday, July 04, 2008

To disable the remote host key checking

最近用Tcl配合Expect SSH至遠端DUT自動測試並產生結果,比較麻煩的是因為測試的緣故,會有很多相同IP但不同DUT的狀況發生,這時我的script裡就要在for loop的開始去砍掉~/.ssh/known_hosts所對應的IP,有點麻煩,經高人指定原來是可以讓SSH不檢查key,實作的方法是:

ssh -o StrictHostKeyChecking=no

不過要小心中間人攻擊唷~ 帽客是在Lab裡面這樣做,倒是不用擔心到這一點 :p

Wednesday, July 02, 2008

Tcl語法雜記

將一些我常用的Tcl語法記錄與此,以後好備查:

1.宣告變數:
set A 100

2.列印變數的值:
puts $A

3.Append變數:
set a {QA Engineer: }
set b {Lawrence Chiu}
puts $a
puts $b
append a $b
puts $a

4.Array:
#Set value to array
for {set i 5} {$i >= 0} {incr i -1} {
set myarray($i) $i
}
#Print array value
for {set i 0} {$i <= 5} {incr i +1} { puts "myarray($i)=$myarray($i)" }

5.將指令結果存於變數內:

set var [exec ifconfig]
puts $var
set var2 [exec ifconfig | grep "inet\ addr" | grep -v 127.0.0.1]
puts $var2

6.eval & subst:
set age 28
set str {I'm $age years old}
set cmd {puts "$str"}
eval $cmd
eval [subst $cmd]

7.foreach:
set SUM 0
foreach test {1 2 3 4 5} {
puts "$test"
set SUM [expr $SUM + $test]
}
puts "SUM=$SUM"

8.if:
set A 100
if {$A==101} {
puts "A=101"
} else { puts "A=100" }

9.開關檔:
set ls [exec ls]
set file [open file w]
puts $file $ls
close $file

10.positional應用:
set count [llength $argv]
puts $count
for { set i 0 } { $i <= [expr $count-1] } { incr i +1} { puts [lindex $argv $i] } 11.positional應用, foreach:
foreach a $argv {
puts $a
}

11.proc:
#functin f1
proc f1 {a b} {
return [expr $a + $b]
}

#Main program
set A 100
set B 150

set sum [f1 $A $B]
puts "A=$A"
puts "B=$B"
puts "A+B=$sum"

12. RE:
set var1 {abcde}
set var2 {b1234}
set var3 {aabcd}

puts "var1=$var1"
puts "var2=$var2"
puts "var3=$var3"
puts "\r"

puts "Which variable have a character?"
if {[regexp {a} $var1]} {
puts "var1 have a character"
} else { puts "var1 haven't a character" }

if {[regexp {a} $var2]} {
puts "var2 have a character"
} else { puts "var2 haven't a character" }

if {[regexp {a} $var3]} {
puts "var3 have a character"
} else { puts "var3 haven't a character" }
puts "\r"
puts "Which variable include number?"

if {[regexp {[0-9]} $var1]} {
puts "var1 have number"
} else { puts "var1 haven't a number" }

if {[regexp {[0-9]} $var2]} {
puts "var2 have number"
} else { puts "var2 haven't number" }

if {[regexp {[0-9]} $var3]} {
puts "var3 have number"
} else { puts "var3 haven't number" }

13.string:
set A "hello world!"
puts $A
puts [string length $A]
puts [string index $A 4]
puts [string range $A 6 9]
puts [string range $A 6 end]
puts [string toupper $A]
puts [string tolower $A]

14.switch:
set A yes
switch $A {
yes { puts "yes"}
no { puts "no" }
YES { puts "YES" }
default { puts "Not match!" }
}

15.while
set SUM 0
set i 1
while { $i <= 100} {
set SUM [expr $SUM + $i]
incr i 1
}
puts "SUM=$SUM"

Tcl online man page: http://www.tcl.tk/man/

Wednesday, June 25, 2008

Install OpenSUSE 11.0 on VirtualBox

把前幾天所抓下來的OpenSUSE11.0安裝到VirtualBox中,目前還在安裝中,大致上應該沒有什麼問題,值得一提的是安裝畫面還真是漂亮。




裝起來後就玩看看吧~

Friday, June 20, 2008

Study TCL

最近被上頭老大要求去玩一下TCL,所以這幾天就去玩玩,目前的心得它的語法真是有點簡單過了頭 :p 不過基本上我覺得還不錯用,結合expect遠端登入到別台機器自動處理些原本要手動且重覆性高的工作,就覺得愉快。

目前覺得最不方便的是要將執行結果存入檔案了,還要開檔關檔@@,不像BASH直接給它 ">"就好。

接下來學結合curl自動登入網頁做些事情,初步已經成功login網頁且取得我需要的資料了,不過此項技能還沒很熟練,還需練練。

Monday, June 16, 2008

sudo 免輸入密碼

這其實不是一個非常好的習慣,但是帽客在Ubuntu下常常sudo來sudo去的,有時跑些script或是執行命令時被要求輸入password,久了就有點煩,所以剛剛決定讓我自己的帳號免輸入password就可以執行所有的指令,方法非常簡單只要將下列敘述新增於/etc/sudoers就可以了,不需重新開機:

lawrence ALL=(ALL) NOPASSWD: ALL

Thursday, June 12, 2008

新增X字型

簡單記錄一下如何在Linux下新增X字型:

1.建立字型檔案:
-將要新增的字型檔案copy到/opt/myfonts下 (隨便哪個目錄都可以)
-執行mkfontscale;mkfontdir產生字型Summary (產生fonts.scale與fonts.dir)

2.將字型加入到X字型路徑 (不透過XFS)
- vi /etc/X11/xorg.conf
-在Section "Files"與EndSection中間 加入 FontPath "/opt/myfonts"
(先後順序是有差的,當兩目錄中存放相同名稱的字型時,會優先使用第一個。)

3.重新執行X,或透過xset fp rehash重新檢查所有字型目錄。

Note: 快速檢查是否有新增成功,可透過xfontsel來測試看看。

Thursday, May 29, 2008

忘記SUSE Linux root密碼時的解決方法

使用SUSE Linux的朋友們,如果您不小心忘了root密碼時,可以採取以下的補救方法:

1. 在boot options輸入 init=/bin/sh:

2. 此時如果直接以passwd嘗試修改的話,系統會報錯:

3. 原因是/此時為read-only,請將它remount成read-write,再次執行passwd,即可成功修改root password:

Tuesday, May 27, 2008

Bind view

透過bind view的功能,我們可以讓DNS Server見人說人話,見鬼說鬼話囉~怎麼說呢?比如說公司中Internet/Intranet的DNS名稱解析都是用同一台,但我不想讓Internet上的machine可以查詢到我內部的hostname時,此時透過bind view的功能,看是誰來查詢,並回應相關的結果。

整個named.conf的架構舉例如下:

22 view "intranet" {
23 match-clients {"192.168.1.0/24";};
24 zone "." IN {
25 type hint;
26 file "named.root";
27 };
28
29 zone "localdomain." IN {
30 type master;
31 file "localdomain.zone";
32 allow-update { none; };
33 };
34
35 zone "localhost." IN {
36 type master;
37 file "localhost.zone";
38 allow-update { none; };
39 };
40
41 zone "0.0.127.in-addr.arpa." IN {
42 type master;
43 file "named.local";
44 allow-update { none; };
45 };
46
47 zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa." IN {
48 type master;
49 file "named.ip6.local";
50 allow-update { none; };
51 };
52
53 zone "255.in-addr.arpa." IN {
54 type master;
55 file "named.broadcast";
56 allow-update { none; };
57 };
58
59 zone "0.in-addr.arpa." IN {
60 type master;
61 file "named.zero";
62 allow-update { none; };
63 };
64
65 zone "example.com" {
66 type master;
67 file "example.com.zone";
68 };
69 };
70
71
72 view "internet" {
73 match-clients {"!192.168.1.0/24";};
74 zone "." IN {
75 type hint;
76 file "named.root";
77 };
78
79 zone "localdomain." IN {
80 type master;
81 file "localdomain.zone";
82 allow-update { none; };
83 };
84
85 zone "localhost." IN {
86 type master;
87 file "localhost.zone";
88 allow-update { none; };
89 };
90
91 zone "0.0.127.in-addr.arpa." IN {
92 type master;
93 file "named.local";
94 allow-update { none; };
95 };
96
97 zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa." IN {
98 type master;
99 file "named.ip6.local";
100 allow-update { none; };
101 };
102
103 zone "255.in-addr.arpa." IN {
104 type master;
105 file "named.broadcast";
106 allow-update { none; };
107 };
108
109 zone "0.in-addr.arpa." IN {
110 type master;
111 file "named.zero";
112 allow-update { none; };
113 };
114 };
115
116 include "/etc/rndc.key";

其實就是多了
view "internet" {
match-clients {"!192.168.1.0/24";};
};

view "intranet" {
match-clients {"192.168.1.0/24";};
};

在這兩個區域內設定相關的zone/zone file就可以了。

Monday, May 26, 2008

Check user mailbox

以往測end user有沒有收到信時,總是習慣切到此使用者執行mail看看有沒有收到信件,今天發現了兩個方法可以不用這麼地麻煩的切換到此使用者,方法如下:

[root@vir1 ~]# mail -u lawrence
Mail version 8.1 6/6/93. Type ? for help.
"/var/mail/lawrence": 2 messages 1 new
1 MAILER-DAEMON@vir1.e Mon May 26 13:42 13/552 "DON'T DELETE THIS MES"
>N 2 root@vir1.example.co Mon May 26 17:35 20/714 "test1"
&
Message 2:
From root@vir1.example.com Mon May 26 17:35:49 2008
X-Original-To: qa@vir1.example.com
Delivered-To: qa@vir1.example.com
Date: Mon, 26 May 2008 17:35:48 +0800
From: root
To: qa@vir1.example.com
Subject: test1

CentOS release 5 (Final)
Kernel \r on an \m

or

[root@vir1 ~]# mail -f /var/spool/mail/lawrence
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/lawrence": 2 messages 1 new
1 MAILER-DAEMON@vir1.e Mon May 26 13:42 13/552 "DON'T DELETE THIS MES"
>N 2 root@vir1.example.co Mon May 26 17:35 20/714 "test1"
&
Message 2:
From root@vir1.example.com Mon May 26 17:35:49 2008
X-Original-To: qa@vir1.example.com
Delivered-To: qa@vir1.example.com
Date: Mon, 26 May 2008 17:35:48 +0800
From: root
To: qa@vir1.example.com
Subject: test1

CentOS release 5 (Final)
Kernel \r on an \m

Wednesday, May 21, 2008

SSH Server allow authorized_keys only

帽客家裡目前總共有2台Linux machines與一台iBook,一台安裝CentOS5.1當作file server使用,而iBook與HP NB分別安裝Mac OSX10.4與Ubuntu7.10,透過rsync的方法將資料update至file server,由於都有使用key作為ssh認證的方法,於是乎想把透過password認證方式取消掉,透過以下的方法完成了需求:

#vi /etc/ssh/sshd_config
-> UsePAM no
-> PasswordAuthentication no
#service sshd restart

Thursday, May 15, 2008

Fedora 9 available to download

前些日子出國,所以晚了些日子post到Blog上,有點想從Ubuntu轉回用Fedora,主要是因為我透過網路upgrade system時,Ubuntu 8.04在我的HP NB上運轉的很不順,3D桌面總是卡卡的,當然還有一些其它的問題,比如撥放rmvb時,超卡的根本無法看,只好用partimage recovery回7.10(好險升級前有backup),既然有備份了,那麼就安裝Fedora 9看看吧,事實上我還是使用Fedora/SUSE順手一點 :)

當然Ubuntu還是很棒的!是我目前感覺最親切的Linux distribution.

Thursday, April 24, 2008

Tcpreplay

Tcpreplay可說是從事網通研發人員的一個好工具,它可以將libpcap format的封包記錄檔,重新reply出來,以利除錯或是regression test,不論是In-line mode或是Routing mode的device,它都有辦法可以將封包pass through device,除了replay,它還可透過tcprewrite修改封包的內容,這麼強大的工具您怎麼可以錯過呢?

Tcpreplay website: http://tcpreplay.synfin.net/trac/


Thursday, April 17, 2008

虛擬機器軟體大集合

今天發現到有個forum針對各家虛擬機器的軟體加以整理與介紹,非常棒!值得收藏起來。

Welcome : Links to get started with Virtualization

Tuesday, April 15, 2008

Linux下的partition magic: GParted

經過測試對ext3的partition做放大與縮小都沒有問題,至於FAT與NTFS就抱歉了,因為很少用Windows所以就不驗證了。

Gparted 官網:
http://gparted.sourceforge.net/

Ubuntu Wiki對於Gparted的教學文件:
http://wiki.ubuntu.org.tw/index.php/GParted

Gparted Live-CD:
http://gparted-livecd.tuxfamily.org/

Saturday, April 12, 2008

固定指定的DNS Server

帽客自己在使用Linux作業系統時,當把NIC設定成透過DHCP Server取得IP時,往往會把我自己所指定好的DNS Server覆蓋掉成DHCP Server所配置的DNS Server address,近日拜讀Cd Chen大大的書時,發現到了一個參數PEERDNS,當在NIC設定檔中把它設定成PEERDNS=no時,那麼/etc/resolv.confnameserver就不會被覆蓋掉了。

Friday, April 11, 2008

Apache stress test tool

今天發現到一個針對Apache Web Server的壓力/效能測試工具,在此做個簡單的筆記:
Tools: ApacheBench
Function: 針對某一Web Server提出連線請求,並且在同一時間內可設定幾個連線請求
Usage: # ab -n N -c N http://server1.example.com/index.html
-c concurrency
Number of multiple requests to perform at a time. Default is one request at a time.
-n requests
Number of requests to perform for the benchmarking session. The default is to just perform
single request which usually leads to non-representative benchmarking results.

Executed Result:
[root@server2 ~]# ab -n 100 -c 100 https://10.5.40.195/script/login.php
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.5.40.195 (be patient).....done


Server Software: Apache
Server Hostname: 10.5.40.195
Server Port: 443
SSL/TLS Protocol: TLSv1/SSLv3,DHE-RSA-AES256-SHA,1024,256

Document Path: /script/login.php
Document Length: 5953 bytes

Concurrency Level: 100
Time taken for tests: 14.492808 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 635400 bytes
HTML transferred: 595300 bytes
Requests per second: 6.90 [#/sec] (mean)
Time per request: 14492.808 [ms] (mean)
Time per request: 144.928 [ms] (mean, across all concurrent requests)
Transfer rate: 42.78 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 680 5075 3167.2 4795 14099
Processing: 114 959 1238.7 540 6085
Waiting: 112 913 1240.5 506 6082
Total: 896 6035 3844.3 5503 14470

Percentage of the requests served within a certain time (ms)
50% 5503
66% 6735
75% 7557
80% 8250
90% 14178
95% 14334
98% 14444
99% 14470
100% 14470 (longest request)

Thursday, April 10, 2008

IP alias

在Linux實現IP alias,一般來說大家第一個想到的方法是使用ifconfig,但其實用ifconfig來做IP alias,當要查看IP address時,會dump出一大堆IP alias的介面(ethN:N),不太容易閱讀(最近的測試在網卡上bind 16384個IP),所幸可以使用ip指令來做IP alias,簡單又方便閱讀。
怎麼做呢?非常簡單,只要下達以下指令就好了:
# ip addr add 192.168.1.102/24 dev ethN (N代表0,1,2,.... i.e.網卡編號)

查看:
# ip addr show


192.168.1.102與192.168.1.103是IP alias,如果使用ifconfig來做的話,那麼將會多出兩個ethN:N。提醒一下如果是以ip指令來做IP alias時,使用ifconfig是查看不到IP alias的IP address.

Thursday, March 27, 2008

Check Linux distribution

以往帽客都是去cat /etc/issue這個檔案來查看是那個Linux的版本,但事實上這個檔案是可被修改的。今天找到了一個能100%確認是那一套Linux distribution的指令了,lsb_release,以下列出了cat /etc/issue與lsb_release去確認Linux distribution的結果:

1. cat /etc/issue
[root@server2 tmp]# cat /etc/issue
CentOS release 5 (Final)
Kernel \r on an \m

2. lsb_release
[root@server2 tmp]# lsb_release -a
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: CentOS
Description: CentOS release 5 (Final)
Release: 5
Codename: Final

Tuesday, March 18, 2008

selinux on RHEL5.1

今天在RHEL5.1中,將selinux enable起來,在此分享一下心得:

1. Enable selinux:
[root@dns html]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted
-> 將SELINUX=disabled改成SELINUX=enforcing,並重新開機。

2.查看目前selinux的狀態:
[root@dns html]# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 21
Policy from config file: targeted
如果要查詢到更多的資訊,可加上 -v參數:
[root@dns html]# sestatus -v
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 21
Policy from config file: targeted

Process contexts:
Current context: root:system_r:unconfined_t:SystemLow-SystemHigh
Init context: system_u:system_r:init_t
/sbin/mingetty system_u:system_r:getty_t
/usr/sbin/sshd system_u:system_r:unconfined_t:SystemLow-SystemHigh

File contexts:
Controlling term: root:object_r:devpts_t
/etc/passwd system_u:object_r:etc_t
/etc/shadow system_u:object_r:shadow_t
/bin/bash system_u:object_r:shell_exec_t
/bin/login system_u:object_r:login_exec_t
/bin/sh system_u:object_r:bin_t -> system_u:object_r:shell_exec_t
/sbin/agetty system_u:object_r:getty_exec_t
/sbin/init system_u:object_r:init_exec_t
/sbin/mingetty system_u:object_r:getty_exec_t
/usr/sbin/sshd system_u:object_r:sshd_exec_t
/lib/libc.so.6 system_u:object_r:lib_t -> system_u:object_r:lib_t
/lib/ld-linux.so.2 system_u:object_r:lib_t -> system_u:object_r:ld_so_t

3.查看selinux對daemon的booleans,以查尋httpd為例:
[root@dns html]# getsebool -a | grep httpd
allow_httpd_anon_write --> off
allow_httpd_mod_auth_pam --> off
allow_httpd_sys_script_anon_write --> off
httpd_builtin_scripting --> on
httpd_can_network_connect --> off
httpd_can_network_connect_db --> off
httpd_can_network_relay --> off
httpd_disable_trans --> off
httpd_enable_cgi --> on
httpd_enable_ftp_server --> off
httpd_enable_homedirs --> on
httpd_rotatelogs_disable_trans --> off
httpd_ssi_exec --> off
httpd_suexec_disable_trans --> off
httpd_tty_comm --> off
httpd_unified --> on

如果要設定booleans,可利用setsebool,比如說當我不想要selinux控管httpd時,可以這樣做:
[root@dns html]# setsebool -P httpd_disable_trans 1
[root@dns html]# getsebool -a | grep httpd_disable_trans
httpd_disable_trans --> on
其中0代表off,1代表on,而-P的參數是代表下次開機時套用新的boolean值。

現在來個狀況練習一下,在selinux enable的狀況下,允許匿名的ftp account可以get與put file,並且可以overwrite。

1. 設定vsftpd(請參考以下的configure):
[root@dns html]# cat /etc/vsftpd/vsftpd.conf | grep -v "^$" | grep -v "^#"
anonymous_enable=YES
anon_other_write_enable=YES
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

在以往沒有開啟selinux時,已經達成了題目需求,但當selinux開啟時,是會踢到鐵板的,看一下以下的示範吧:
chiu-lawrencede-ibook-g4:~ Lawrence$ ftp 10.5.30.147
Connected to 10.5.30.147.
220 (vsFTPd 2.0.5)
Name (10.5.30.147:Lawrence): ftp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd pub
250 Directory successfully changed.
ftp> put backup.sh
local: backup.sh remote: backup.sh
229 Entering Extended Passive Mode (|||50891|)
553 Could not create file.
ftp>

查看一下ftp的booleans:
[root@dns pub]# getsebool -a | grep ftp
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftp_home_dir --> off
ftpd_disable_trans --> off
ftpd_is_daemon --> on
httpd_enable_ftp_server --> off
tftpd_disable_trans --> off
看到了嗎?allow_ftpd_anon_write --> off與allow_ftpd_full_access --> off,來enable它們吧!
[root@dns pub]# setsebool -P allow_ftpd_anon_write 1
[root@dns pub]# setsebool -P allow_ftpd_full_access 1

再試一次put檔案:
chiu-lawrencede-ibook-g4:~ Lawrence$ ftp 10.5.30.147
Connected to 10.5.30.147.
220 (vsFTPd 2.0.5)
Name (10.5.30.147:Lawrence): ftp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd pub
250 Directory successfully changed.
ftp> put backup.sh
local: backup.sh remote: backup.sh
229 Entering Extended Passive Mode (|||50580|)
150 Ok to send data.
100% |***********************************************************************************| 666 1.92 MB/s 00:00
226 File receive OK.
666 bytes sent in 00:00 (1.62 KB/s)
ftp> put backup.sh
local: backup.sh remote: backup.sh
229 Entering Extended Passive Mode (|||37711|)
150 Ok to send data.
100% |***********************************************************************************| 666 2.76 MB/s 00:00
226 File receive OK.
666 bytes sent in 00:00 (2.92 KB/s)
ftp>

完成。

Thursday, March 13, 2008

RHEL5 群組管理員

這是以前沒有的觀念,故在此做個筆記:

Objective: 讓一般user可以控管(新增/刪除)群組的成員

Environment:
law -> g1 group的群組管理員
g1 -> 測試用的group
alex -> 將被law assign到g1 group
/home/g1 -> g1 group的共用目錄,權限為770

Setup1. 將law設定為g1群組管理員:
[root@server3 home]# gpasswd -A law g1
[root@server3 home]# grep law /etc/gshadow
law:!::
g1:!:law:
(可在/etc/gshadow中,每個群組的第三個欄位查詢群組管理員

Setup2. 將alex加讓到g1 group:
[law@server3 ~]$ id alex
uid=502(alex) gid=503(alex) groups=503(alex)
[law@server3 ~]$ gpasswd -a alex g1
Adding user alex to group g1
[law@server3 ~]$ id alex
uid=502(alex) gid=503(alex) groups=503(alex),502(g1)

Setup3. 驗證一下alex可至/home/g1 建立檔案:
[alex@server3 home]$ ls -dl /home/g1/
drwxrwx--- 2 root g1 4096 Oct 21 05:06 /home/g1/
[alex@server3 home]$ cd g1
[alex@server3 g1]$ touch alex
[alex@server3 g1]$ ls -l alex
-rw-rw-r-- 1 alex alex 0 Oct 21 05:13 alex

Friday, March 07, 2008

RHEL5 系統管理寶典 基礎篇

最近獲贈永昇兄(Cd Chen)的近期新作"RHEL5 系統管理寶典 基礎篇",在此非常感謝永昇兄,這本新書算是永昇兄對於Redhat Linux系統管理介紹的第二版,因為撰寫第一版時有些原因,故以Fedora來介紹,難免有些遺憾,如今這本新作完全是以RHEL5來介紹,內容與前版相比也更新了許多,是非常值得有心學習Linux系統管理的讀者可參考的一本書物,如果有上過RHCE培訓課程的學生,這本書就等於是RH133的中文參考書,帽客當然不是在打廣告,而是好東西一定要推薦給大家知道,帽客這幾天也開始拜讀這本書了,雖然大部份的知識都知道,但真正的了解應該是: 懂->很懂->精通->分享&教導,所以帽客每次看不同的Linux書物時,都會有不同的收穫。

Friday, February 15, 2008

Linux存取Windows網芳

今天使用Linux machine去mount Windows網芳所分享出來的目錄時,發生了以下的錯誤:
# smbclient //X.X.X.X/temp -U lawrence
Password:
session setup failed: NT_STATUS_LOGON_FAILURE

怪了,帳號跟密碼都正確呀!看看能不能瀏覽,於是乎執行以下的command:
[root@server2 ~]# smbclient -L //X.X.X.X -N
Anonymous login successful
Domain=[XXXXX] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

Sharename Type Comment
--------- ---- -------
cli_rpc_pipe_open: cli_nt_create failed on pipe \srvsvc to machine X.X.X.X. Error was NT_STATUS_ACCESS_DENIED
Error returning browse list: NT_STATUS_ACCESS_DENIED
session request to X.X.X.X failed (Called name not present)
session request to 10 failed (Called name not present)
Anonymous login successful
Domain=[XXXXX] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

想了一下,會不會是Windows domain的問題,所以查了一下smbclient的man page,找到了以下的提示:
-W|--workgroup=domain
Set the SMB domain of the username. This overrides the default domain which is the domain defined in smb.conf. If the domain specified is the same as the servers NetBIOS name, it causes the client to log on using the servers local SAM (as opposed to the Domain SAM).

恩,在執行一次看看,這次加入了--workgroup的參數:
[root@server2 ~]# smbclient //X.X.X.X/temp -U lawrence --workgroup=XXXXX
Password:
Domain=[XXXXX] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
smb: \>

成功了!

Monday, January 28, 2008

X window重點條列

最近加強了關於X window的觀念,整理出重點如下:

- 目前的X window是由X11R6延伸發展而來
- 兩大分支: Xfree86, xorg
- X window = X Server + X Client + window manager (twm, KDE, GNOME and etcs)
- X Server: 負責將X Client的運算結果顯示於screen
- X Client: 負責處理X Server傳回的資訊,並回傳給X Server,不care X Server是用那張顯卡,那個作業系統
- Check X version: 以root身份執行 X -version

- X Server 主要設定檔, 適用於xfree86 & xorg:
/etc/X11/xorg.conf, /etc/X11/XF86Config
主要參數說明:
InputDevice -> 設定輸出入裝置: 如鍵盤 or 滑鼠
Device -> 設定顯卡為那張?驅動程式為?
Screen ->設定色度與解析度
Files -> 設定X font, 設定的方法有直接指定路徑 or 透過xfs (X font Server)
Monitor -> 設定screen的水平與垂直度頻率
Module -> 載入相關的模組
ServerLayout -> 以上所有參數都可有許多筆,至於用到那一筆則是在這邊決定

- 在runlevel 3啟動X的流程:
startx->xinit-> ~/.xinitrc -> /etc/X11/xinit/xinitrc -> ~/.xserverrc -> /etc/X11/xinit/xserverrc
- 如果是runlevel5的話,可以在/etc/inittab看到啟動display manager:
# Run xdm in runlevel 5
x:5:respawn:/etc/X11/prefdm -nodaemon

- 設定window manager的設定檔:
/etc/sysconfig/desktop
KDE -> startkde
GNOME -> gnome-session

-X v7.x的字型目錄:
/usr/share/fonts/
/usr/share/X11/fonts

-X v6.x的字型目錄:
/usr/X11R6/lib/X11/fonts/

-X預設在tty7,也就是ALT+CTRL+F7,執行的程式方法是 X :0,預設port是TCP 6000,如果是X :1,那麼就是tty8,i.e. ALT+CTRL+F8,TCP port 6001

-如果是用xfs管理字型的話,請確認執行X時,要先啟動xfs,否則將無法啟動X


Thursday, January 17, 2008

MacBook Air

Apple終於announce輕機種的NB了,重量僅1.36kg,這才是我想要的!
且觸碰板還支援多點觸碰!真是創意無限!
更詳細的spec: MacBook Air Specs
Demo影片: MackBook Air Guided

Tuesday, December 25, 2007

DNS: forward Zone

這算是一個蠻特別的需求,只有針對特定的domain時,才會將DNS query轉送到特定的DNS Server,不過似乎挺多單位常有這樣的需求,所以還是趕緊給它記下來吧:
zone "test.com"
{
type forward;
forwarders { 192.168.0.254; 192.168.0.253; };
};

就是這麼簡單囉,凡是看到test.com的DNS查詢時便forward到192.168.0.254與192.168.0.253這兩台DNS Server。

Fix NFS ports

NFS Server有一個特性,那就是除了portmapper與nfs分別是使用固定的port number外(portmapper:111,nfs:2049),其它的port都是隨機產生的,如下所示:
[root@server3 ~]# rpcinfo -p
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100011 1 udp 745 rquotad
100011 2 udp 745 rquotad
100011 1 tcp 748 rquotad
100011 2 tcp 748 rquotad
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100021 1 udp 1028 nlockmgr
100021 3 udp 1028 nlockmgr
100021 4 udp 1028 nlockmgr
100021 1 tcp 3767 nlockmgr
100021 3 tcp 3767 nlockmgr
100021 4 tcp 3767 nlockmgr
100005 1 udp 760 mountd
100005 1 tcp 763 mountd
100005 2 udp 760 mountd
100005 2 tcp 763 mountd
100005 3 udp 760 mountd
100005 3 tcp 763 mountd
100024 1 udp 832 status
100024 1 tcp 835 status
[root@server3 ~]# service nfs restart; service nfslock restart
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
Stopping NFS locking: [ OK ]
Stopping NFS statd: [ OK ]
Starting NFS statd: [ OK ]
[root@server3 ~]# rpcinfo -p
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100011 1 udp 904 rquotad
100011 2 udp 904 rquotad
100011 1 tcp 907 rquotad
100011 2 tcp 907 rquotad
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100021 1 udp 1028 nlockmgr
100021 3 udp 1028 nlockmgr
100021 4 udp 1028 nlockmgr
100021 1 tcp 2229 nlockmgr
100021 3 tcp 2229 nlockmgr
100021 4 tcp 2229 nlockmgr
100005 1 udp 919 mountd
100005 1 tcp 922 mountd
100005 2 udp 919 mountd
100005 2 tcp 922 mountd
100005 3 udp 919 mountd
100005 3 tcp 922 mountd
100024 1 udp 971 status
100024 1 tcp 974 status

如果要利用iptables加以控管實在是有些困難之處,所以我們可以做的是將這些daemon指定使用固定的port number,以下的步驟將告訴你怎麼做到這一點:

Linux distro: CentOS 5.0

1. 修改/etc/sysconfig/nfs檔案中的參數如下:
RQUOTAD_PORT=9000
LOCKD_TCPPORT=9001
LOCKD_UDPPORT=9001
MOUNTD_PORT=9002
STATD_PORT=9003

2. 重啟nfs與nfslock daemon,並驗證:
[root@server3 ~]# service nfs restart; service nfslock restart
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
Stopping NFS locking: [ OK ]
Stopping NFS statd: [ OK ]
Starting NFS statd: [ OK ]
[root@server3 ~]# rpcinfo -p
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100011 1 udp 9000 rquotad
100011 2 udp 9000 rquotad
100011 1 tcp 9000 rquotad
100011 2 tcp 9000 rquotad
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100021 1 udp 9001 nlockmgr
100021 3 udp 9001 nlockmgr
100021 4 udp 9001 nlockmgr
100021 1 tcp 9001 nlockmgr
100021 3 tcp 9001 nlockmgr
100021 4 tcp 9001 nlockmgr
100005 1 udp 9002 mountd
100005 1 tcp 9002 mountd
100005 2 udp 9002 mountd
100005 2 tcp 9002 mountd
100005 3 udp 9002 mountd
100005 3 tcp 9002 mountd
100024 1 udp 9003 status
100024 1 tcp 9003 status

如此便完成了固定NFS Server的port number。

Thursday, December 13, 2007

Linux command: screen 應用小技巧

上一篇介紹了screen的基本用法,這一篇呢,就來分享一下screen更進階的一種實用方法。
假使您所要維護的Linux機器有好幾台,每一天都要logon進去關心一下,或是操作一番,每次都要ssh過去的確是有點麻煩,搞不好一天中還要ssh進去好幾次,不太smart。

所以用screen來偷懶吧!用screen所產生的console就算你退出了screen,還是可以保留當時的使用狀況,所以我只需要把screen叫出來用就好了。好處就是快速且又保留當時操作的情境。

假想今天的Server有2台,您每天都要進去關心一下,那麼您可以寫一個script如下:

#!/bin/bash
screen -d -m -S SRV1 -t root@srv1 ssh root@192.168.0.254
screen -d -m -S SRV2 -t root@srv2 ssh root@192.168.0.253

講解一下參數:
-d -m -> 不要去attach這個screen
-S -> 設定screen name,用screen -ls時可以查看,到時可以用screen -r叫回來,有點像這個樣子:
#screen -ls
There are screens on:
555.svr1 (Detached)
560.svr2 (Detached)
# screen -r 555
-> 這樣就會回到Server1
-t -> 設定screen的title,在screen中按下CTRL+a,w時,好方便查詢。

這樣一來呢,當我想到Server1時就執行screen -ls查一下並用screen -r 555切到Server1,夠方便吧!當然你可以讓這隻script在開機時便執行,並搭配SSH免密碼登入。

Thursday, December 06, 2007

Linux command: screen

screen是可遠端登入Linux建立多重終端機的一個非常好用的指令,比如你習慣用putty透過SSH登入到遠端的Linux機器,同時想開啟多個終端機時,怎麼辦呢?這時screen就派上用場了,另一個好處是在screen下所執行的命令,即使你登出了還是會繼續執行,不需另外透過nohup,以下整理一下screen常用到的一些功能。

1. 執行screen: #screen

2. screen熱鍵:
2.1 新增screen: CTRL+a,c
2.2 切換至下個screen: CTRL+a,n
2.3 切換至前一個screen: CTRL+a,a
2.4 查看目前有幾個screen: CTRL+a,w
2.5 離開screen: CTRL+a,d
2.6 刪除screen: #exit or CTRL+a,k

3. 查看目前screen status: #screen -ls
4. 回到screen: #screen -r

Wednesday, November 21, 2007

FUSE+SSHFS

在Linux中要去mount遠端的Server某個分享資料夾,大部份是透過NFS或是Samba的方法來實做,在此帽客提供另一種方法來做,那便是利用SSH來mount。

OS: CentOS5 kernel version: 2.6.18-8.1.14.el5

透過sshfs便可以達到這樣的需求,但由於使用sshfs之前,必需安裝FUSE module,所以請先至rpm.pbone.net抓取以下的RPM並安裝:
fuse-2.7.0-1.el5.rf.i386.rpm
fuse-devel-2.7.0-3_7.el5.i386.rpm
fuse-kmdl-2.6.18-8.1.14.el5-2.7.0-3_7.el5.i686.rpm
fuse-libs-2.7.0-3_7.el5.i386.rpm

在抓取fuse-sshfs-1.8-1.el5.rf.i386.rpm安裝完後將機器重新開機或是執行modprove fuse

由於sshfs在mount遠端時都會要求輸入密碼,如同使用ssh一樣,所以我利用了免密碼就可登入到對方主機來做。(在此server2代表client要mount server1的root家目錄)

server2: 產生金鑰並scp到server1
[root@server2 ~]# ssh-keygen -t dsa
Generating public/private dsa key pair.

Enter file in which to save the key (/root/.ssh/id_dsa): Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
97:49:77:78:b0:82:13:59:fa:0b:70:ad:cd:7d:31:f1 root@server2.example.com
[root@server2 ~]# scp .ssh/id_dsa.pub root@10.4.1.33:~/server2.key.pub
Password:
id_dsa.pub
100% 614 0.6KB/s 00:00
server1: 將server2的金鑰copy到~/.ssh/authorized_keys
server1:~/.ssh # touch authorized_keys
server1:~/.ssh # cat ../server2.key.pub > authorized_keys

server2: 使用sshfs mount server1的root家目錄至/mnt/server1
[root@server2 ~]# sshfs root@10.4.1.33:/root /mnt/server1/
[root@server2 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda5 13G 3.6G 8.8G 29% /
/dev/hda1 99M 14M 80M 15% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/hda2 4.8G 138M 4.4G 4% /home
sshfs#root@10.4.1.33:/root
1000G 0 1000G 0% /mnt/server1

完成。

Monday, November 19, 2007

[Vsftp] Allow anonymous rewrite files

今天發現到在RHEL/SLES的vsftp中,即使我開放讓anonymous有上傳與建立目錄的權限,但當要上傳並覆蓋原本的檔案時會發生權限不足的問題,原來還要多加一個設定anon_other_write_enable=YES
在此總結允許anonymous所有權限的參數:

anonymous_enable=YES
anon_other_write_enable=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
write_enable=YES

Friday, November 16, 2007

[Shell Script] 執行結果變指令!

#!/bin/bash
## A=100
## ls -l
## free -m
eval "`grep "^## " $0 | sed 's/^## //'`"
echo "A=$A"

短短的幾行,卻內含許多觀念!

Friday, November 02, 2007

Top 10 Reasons Not to Use Ubuntu

http://blog.linuxtoday.com/blog/archives/071031-103438.html

這應該是反諷MS吧,雖然我不太prefer MS ,但青菜蘿菠各有所好囉~
當我把compiz特效展現給同事看時,沒有一個不心動的,已經有人安裝Ubuntu了,不過帽客也當起了免費的技術支援。

Thursday, November 01, 2007

DNS cache issue

一般來說,DNS cache的值是以TTL來決定,而TTL也只對於DNS Server與Server之間才有用!如果對DNS Client來說它是不會去做DNS cache的,每查詢一次就update一次RR,但帽客今天發現到了一個非常有趣的現象,當你在DNS Client透過 host / nslookup /dig 來做名稱解析時,每問一次就update一次,這不難理解,合乎常規,但當你用ping時,此時就很怪異了,你會發現!被cache住了!比如我設定 server.example.com 對映到192.168.0.254 / 253, 當你用host查尋時,會每問一次就改變一次對映的IP,但ping確沒有唷!主要的原因是被nscd這隻daemon cache住囉!

nscd daemon就是用來設定DNS Client要cache住Name Server cache查尋的結果多久,這個跟TTL值一點關係也沒有,它也可以應用在LDAP,ypserver等等,以下是它的example config file:

enable-cache passwd yes
positive-time-to-live passwd 600
negative-time-to-live passwd 20
suggested-size passwd 211
check-files passwd yes
persistent passwd yes
shared passwd yes

enable-cache group yes
positive-time-to-live group 3600
negative-time-to-live group 60
suggested-size group 211
check-files group yes
persistent group yes
shared group yes

enable-cache hosts yes
positive-time-to-live hosts 5
negative-time-to-live hosts 0
suggested-size hosts 211
check-files hosts yes
persistent hosts no
shared hosts yes

hosts -> 就是針對DNS cache用的。 :)

Saturday, October 27, 2007

list all PCI devices

在Linux的作業系統下,如果想要check HW info的方法其實有很多種,比如我想看CPU時,我可以打cat /proc/cpuinfo,想看記憶體時可打free -m,想看HDD space時,可透過fdisk -l等等。

在以前我如果想要看電腦的網卡或是顯示是那家的chip時,我會透過dmesg然後配合grep去找出我想要知道的資訊,不過現在發現到一個更好用的指令lspci,可以透過它很簡單的撈出所有PCI devices的資訊,以下是我HP nc6230的info,真是方便呀。

00:00.0 Host bridge: Intel Corporation Mobile 915GM/PM/GMS/910GML Express Processor to DRAM Controller (rev 03)
00:01.0 PCI bridge: Intel Corporation Mobile 915GM/PM Express PCI Express Root Port (rev 03)
00:1c.0 PCI bridge: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 1 (rev 03)
00:1c.1 PCI bridge: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 2 (rev 03)
00:1d.0 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #1 (rev 03)
00:1d.1 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #2 (rev 03)
00:1d.2 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #3 (rev 03)
00:1d.7 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB2 EHCI Controller (rev 03)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev d3)
00:1e.2 Multimedia audio controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) AC'97 Audio Controller (rev 03)
00:1e.3 Modem: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) AC'97 Modem Controller (rev 03)
00:1f.0 ISA bridge: Intel Corporation 82801FBM (ICH6M) LPC Interface Bridge (rev 03)
00:1f.1 IDE interface: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) IDE Controller (rev 03)
01:00.0 VGA compatible controller: ATI Technologies Inc M22 [Mobility Radeon X300]
02:04.0 Network controller: Intel Corporation PRO/Wireless 2200BG Network Connection (rev 05)
02:06.0 CardBus bridge: Texas Instruments PCIxx21/x515 Cardbus Controller
02:06.3 Mass storage controller: Texas Instruments PCIxx21 Integrated FlashMedia Controller
02:06.4 Generic system peripheral [0805]: Texas Instruments PCI6411/6421/6611/6621/7411/7421/7611/7621 Secure Digital Controller
02:06.5 Communication controller: Texas Instruments PCI6411/6421/6611/6621/7411/7421/7611/7621 Smart Card Controller
10:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5751M Gigabit Ethernet PCI Express (rev 11)

Thursday, October 18, 2007

Ubuntu 7.10 new features since 7.04

Ubuntu 7.10即將問世,以下是它主要的新功能:
New features

Wednesday, October 17, 2007

Mac OSX 10.5 Leopard 即將於2007.10.26 PM6:00開賣

根據官方消息,Apple將於今年的10月26號下午6:00開始於Apple Retail Store開賣MAC OSX 10.5 Leopard,帽客真是感到高興呀!不過在高興之餘忽然驚覺我的iBook,能裝嗎?

於是乎馬上去Apple網站瞧瞧,喔!一進首頁就看到在倒數計時呀!ㄟ~Apple真是個大壞蛋呀!來這招搞得我心癢癢,差點忘了要做什麼,二話不說馬上點選Leopard的Tech Specs的頁面,好險上面有說支援PowerPC G4&G5的CPU,這下子放心的許多,等著升級吧我的小白。

Apple MAC OSX 10.5 Leopard Specs

Friday, October 12, 2007

熱鬧的10月

Novell於10月4日發表了OpenSUSE 10.3, 而Ubuntu也準備於10月18日發表Ubuntu 7.10 (Gutsy Gibbon), Apple就更讓人興奮了,將於10月底發表MAC OS 10.5 Leopard!

真是個熱鬧的10月呀!目前帽客所用的OS大概有:
1. CentOS5.0 on IBM desktop
2. MAC OS 10.4 on iBook
3. Ubuntu 7.04 on HP nc6230
4. Windows XP PRO SP2 on IBM desktop
5. 以模擬的方式跑RHEL5, SLES10與OpenSUSE 10.3

這麼多的OS,我覺得MAC還是桌面應用的王者,好用直覺夠簡單,Linux則是我吃飯的工具,應用廣泛,沒有它還真的不知道怎麼辦.... 那Windows...... 嗯...... 讓我想一想

Tuesday, October 09, 2007

最近狀況

女兒:
快滿8個月了, 嗯 把戲越來越多了,很可愛但也很抓弄人,但我發現到她不太有耐心同時脾氣也很大,老婆說這點像我 @@ 我承認我EQ是低了點, 但我應該還算有耐心吧 呵
人家都說女兒外表也像我, 嗯!感覺好像是耶~ 拿出小時候的照片一比,果然活生生是我的分身~
看來小孩子真是不能偷生,還需要DNA鑑定嗎?
她的外號是企鵝妹,至於為何呢?這點有空我以後在說明,不過不是因為我喜歡玩Linux的關係就是了.

工作:
對於有在瀏覽本Blog的網友,真是感到抱歉,最近公司有一些改變且案子也都排的很趕,所以就沒有太多的心力update一些心得到Blog上,我想應該會一直忙到年底吧.... 沒辦法 @@ 又因為我是Sr. 級的, 所以總是對自己要求高一點,不然怎麼有資格掛Sr.哩~

Linux:
前幾天OpenSUSE 10.3 release了,於是乎當然是馬上download來玩看看囉~ 誰知道在VirtualBox下NIC有些問題get不到IP? 這真是奇怪 我等會在來試看看,如果不行,就問問Google大神看看吧

學習:
1.公司變美商了,所以上面說要加強英文,我的破英文.....的確要加強!以後每個星期 1 3 5 就強迫自己讀英文吧!
2.至於每個星期2 4,預計review一下以前所學的Linux skill吧 我一直很想去考LPIC,但我記憶體小,這種筆試對我來說是比上機考還痛苦...

娛樂:
1. 預計會買Wii送老婆,一來是可以讓她減肥,二來是結婚記念日快到了,應該要表示一下.
2. 假日會玩玩NDSL,雷頓教授與不可思議的小鎮實在很有趣唷! 有NDSL的朋友可千萬不要錯過呀!

Friday, September 21, 2007

Setup bridging network interface on Virtualbox

在Virtualbox中,如果要用bridging到某一張NIC上,是需要一些設定的,不像VMware跑跑它的script就設定好了 @@ 不過這樣還是可以克服的,手動自己搞定就好了,在實作前先講講要怎麼做好了:
1. 新增一bridge到NIC上的interface (bri0 <-> eth0)
2.替Guest OS新增一個Virtual host interface (vbox0 <-> bri0)
3.在Virtualbox中指定要使用的虛擬NIC (vbox0)

Ubuntu 設定步驟:
Setup1. 安裝bridge的套件:
# sudo apt-get install bridge-utils

Setup2. 設定bri0:
# sudo vi /etc/network/interfaces
->
auto br0
iface br0 inet dhcp
bridge_ports eth0

Setup3. 重啟NIC interface:
# sudo /etc/init.d/networking restart

Setup4. 替Guest OS新增一個Virtual host interface
#sudo VBoxAddIF vbox0 br0

Setup5. 在Virtualbox中指定要使用的虛擬NIC (vbox0)
開啟Virtualbox,並設定Guest OS的其中一張NIC bind到vbox0上

搞定收工! 下面是在Ubuntu下的Guest OS: FC7正在更新套件的畫面:

Install VirtualBox in Ubuntu 7.04

聽說VirtualBox非常好用,所以帽客也來嘗試裝看看,以下是帽客的安裝步驟.

Setup1. 至官網抓for Ubuntu 7.04的套件 virtualbox download
Setup2. # sudo dkpg -i virtualbox_1.5.0-24069-1_Ubuntu_feisty_i386.deb
Setup3. 發生了套件相依性的問題用apt來一解決: # sudo apt-get -f install
Setup4. 將User加入到virtualbox的group: # sudo usermod -G vboxusers -a lawrence

啟動Virtualbox: # VirtualBox


裝好了,今天先裝個FC7玩看看 :)

Friday, September 14, 2007

Linux AntiSpoofing method

寫個簡單的script來做吧! 這樣會套用到所有的interface上.

#!/bin/bash
for i in /proc/sys/net/ipv4/conf/*/rp_filter
do
echo 1 > "$i"
echo "$i"
cat `echo "$i"`
done

參考: OReilly.LPI.Linux.Certification.in.a.Nutshell.2nd.Edition

Tuesday, September 11, 2007

Setup IPSec Host to Host Tunnel Connection

1. Test Environment:
Left PC ----- Right PC
Letf PC:
IP address: 192.168.0.2/24
OS: opensuse 10
Install openswan-2.4.4-1.1
Right PC:
IP address: 192.168.0.100/24
OS: CentOS 5.0
Install openswan-2.4.9-31.el5

2.Setup procedure:
2.1 Left PC:
2.1.1 Setup PSK:
# vi /etc/ipsec.secrets
192.168.0.2 192.168.0.100 : PSK "1234567890"
192.168.0.100 192.168.0.2 : PSK "1234567890"

2.1.2 Setup IPSec:
# vi /etc/ipsec.conf
conn hosttohost
# Left security gateway, subnet behind it, nexthop toward right.
left=192.168.0.2
#leftsubnet=192.168.0.0/24
#leftnexthop=10.4.0.1
# Right security gateway, subnet behind it, nexthop toward left.
right=192.168.0.100
#rightsubnet=192.168.1.0/24
#rightnexthop=10.5.30.254
# To authorize this connection, but not actually start it,
# at startup, uncomment this.
type=tunnel
auto=add
authby=secret

2.1.3 Start IPSec
# rcipsec start
# ipsec auto --up hosttohost

2.2 Right PC:
2.2.1 Setup PSK:
# vi /etc/ipsec.secrets
192.168.0.100 192.168.0.2 : PSK "1234567890"
192.168.0.2 192.168.0.100 : PSK "1234567890"

2.2.2 Setup IPSec:
# cp /etc/ipsec.d/examples/linux-linux.conf ..
# vi /etc/ipsec.d/linux-linux.conf
conn linux-to-linux
#
# Simple use raw RSA keys
# After starting openswan, run: ipsec showhostkey --left (or --right)
# and fill in the connection similarly to the example below.
#
left=192.168.0.100
# optional
# leftsubnet=10.0.1.0/24
#leftid=@bofh.xelerance.com
#leftrsasigkey=0sAQPWTXt8DDlEhTZJ91ngNMxTSyuos6JZxXQmtRcwUl6ppUCcuuWvjXrF/qiz6eiL1LMlpGJyG1oVhtFhTaFJl7ZkF/4J1B9LCFzYxvYI97AnLuC0op5pVAZ1SZx29+aRjeMcKC4zbZ6dMMjUdn9H1gqG9rpE0MBEFNSVLEu9U8rtlz14RfxQAQ9ePj64HnGLfgJlDB0VYhKEIcRihy72bvjZ4eoX16S1EY1FgnHyrveZPxRi8sgn6Q19RytEzSmUAlGjvMDhNfenq6WCSYMeqgj0jFSArTNBQmR2QBkUG6NSOXfb+18c6jDPicGmbmWfoRx/PUJo46WiRF4RRmsxnFpbHpklILFzEJ+/k6qHVAekpVfp
# The remote user.
#
right=192.168.0.2
#rightid=@tla.xelerance.com
# optional
# rightsubnet=10.0.2.0/24
#rightrsasigkey=0sAQNxf6caKULJklYZycuo66Ko0U+iHaJUDr0QZHnG4MJ9IRNYi5H6kPxcwKIXkg+OGo+NeUyyWDEc+ox27BFYViAHQNEyBRLZu0kyE681h+cHm7lfCSy0AOEBSCyZF3aGcL8GWxVhtimpJQ4tNxXZg7tLX5sfYw8mZnUBjkHvyccIred/q3cNWbDlq2WU4TL+NBb5FnxXi9Hk/SRV7sMe56fvZuXkcJu4e2C7uocltzzF1b0BZx7yeXwHjzqAWnW/UA54fbSTvzgnrpSC+FMuhWTI1EdxcqGaOFIjGWWGV2nxg/QaPU9i8vpwFwrEEdCJTiqlbYYNudblg4vYthnVNez0/RkfZHfhAaHdbJRSaQzOu88h
authby=secret
auto=add
type=tunnel

2.2.3 Start IPSec:
# service ipsec start
# ipsec auto --up linux-to-linux
3.Verify:
Ping Right PC from Left PC and to check that traffic actually got encrypted!

Thursday, August 30, 2007

Setup a L2TP over IPSec VPN Server on Linux

Test Environment:

L2TP Client ---------- L2TP Server

L2TP Client: Windows XP SP2
L2TP Server: CentOS 5.0

IP address of L2TP Client: 10.5.30.200
IP address of L2TP Server: 10.5.30.3

必要套件:
xl2tpd-1.1.09-1.fc5.src.rpm
openswan-2.4.9-31.el5.i386.rpm
ipsec-tools* (預設已安裝)
ppp* (預設已安裝)

Setup Procedure:

1.Install RPM:
# rpm –ivh openswan*
# rpm –ivh xl2tpd* (That’s source rpm you must rebuild it)

2.Configure L2TP Server:
2.1 設定帳號與密碼:
# vi /etc/ppp/chap-secrets
lawrence * “redhat” *

2.2 設定xl2tpd設定檔:
[global]
; listen-addr = 192.168.1.98
;
;requires openswan-3.1
;ipsec saref = yes
;
;debug tunnel = yes
auth file = /etc/ppp/chap-secrets
[lns default]
ip range = 192.168.1.128-192.168.1.254
local ip = 192.168.1.99
require chap = yes
refuse pap = yes
require authentication = yes
name = LinuxVPNserver
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes

2.3 設定/etc/ppp/options.xl2tpd
ipcp-accept-local
ipcp-accept-remote
ms-dns 192.168.1.1
ms-dns 192.168.1.3
ms-wins 192.168.1.2
ms-wins 192.168.1.4
noccp
auth
crtscts
idle 1800
#mtu 1410
#mru 1410
nodefaultroute
debug
lock
proxyarp
connect-delay 5000
logfile /var/log/xl2tpd.log

2.4 啟動L2TP Server
# service xl2tpd start; chkconfig xl2tpd on

3. 設定IPSec
3.1 PSK setting:
# vi /etc/ipsec.secrets
include /etc/ipsec.d/*.secrets
10.5.30.3 %any : PSK "1234567890"

10.5.30.3 -> Server IP address
%any -> allow all machines
格式要一模一樣,不然會出錯

3.2 設定l2tp-psk.conf
套用範例即可:
# cp /etc/ipsec.d/examples/l2tp-psk.conf /etc/ipsec.d/
# chmod 755 l2tp-psk.conf

3.3 啟動IPSec
# service ipsec start; chkconfig ipsec on

3.4 Check IPSec status
# ipsec verify
Checking your system to see if IPsec got installed and started correctly:
Version check and ipsec on-path [OK]
Linux Openswan Uopenswan-2.4.9-31.el5/K2.6.18-8.1.8.el5 (netkey)
Checking for IPsec support in kernel [OK]
NETKEY detected, testing for disabled ICMP send_redirects [OK]
NETKEY detected, testing for disabled ICMP accept_redirects [OK]
Checking for RSA private key (/etc/ipsec.d/hostkey.secrets) [OK]
Checking that pluto is running [OK]
Two or more interfaces found, checking IP forwarding [OK]
Checking NAT and MASQUERADEing [N/A]
Checking for 'ip' command [OK]
Checking for 'iptables' command [OK]
Opportunistic Encryption Support [DISABLED]

這麼一來L2TP over IPSec就成功架設起來了,如果有問題的話可查看以下的log file
/var/log/message
/var/log/secure
/var/log/xl2tpd.log

4. L2TP Client setting:
4.1新增連線
1. 開始->設定->網路連線->新增連線精靈
2. 選擇連線到公司網路(使用指定撥號或是vpn)
3. 選擇虛擬私人網路連線
4. 輸入名稱(可以隨意選)
5. 輸入VPN server IP (10.5.30.3)

4.2 修改設定

1.在安全性的分頁中->選擇進階->只勾選CHAP->可省加密

2. 點選"ipsec 設定"選項,輸入PSK(pre-shared key)

Thursday, August 23, 2007

Shell Script: 計算CPU的使用率

#!/bin/bash
SUM=0
for i in `vmstat -n 1 10 | grep -v ^p | awk '{ print $15 }' | grep -v "id"`
do
SUM=`expr $SUM + $i`
done
SUM=`expr $SUM / 10`
BUSY=`expr 100 - $SUM`
echo "$BUSY%"

Monday, August 20, 2007

Setup a POP3 Server that enables SSL/TLS function

OS: CentOS4.5
POP3 Server: dovecot

Setup procedure:
1. Edit /etc/dovecot.conf
->
protocols = pop3 pop3s
imap_listen = [::]
pop3_listen = [::]
ssl_disable = no
ssl_cert_file = /usr/share/ssl/certs/dovecot.pem
ssl_key_file = /usr/share/ssl/private/dovecot.pem
disable_plaintext_auth = no
login_dir = /var/run/dovecot-login
login = imap
login = pop3
mbox_locks = fcntl
auth = default
auth_mechanisms = plain
auth_userdb = passwd
auth_passdb = pam
auth_user = root

2. Start dovecot
# service dovecot start; chkconfig dovecot on

Friday, August 17, 2007

讓Linux可以讀寫NTFS磁區

帽客家裡的大黑(IBM桌機)有兩顆HDD,一顆是安裝CentOS5另一顆是Windows XP PRO SP2,所以有時開到CentOS的工作環境而想讀寫NTFS磁區時,我記得我之前只解決了讀的問題,昨天上Google發現到現在連寫的問題也解決了,我真是後知後覺呀!

只要安裝好ntfs-3g與fuse後,並以下面的方法mount NTFS的磁區就可以work囉~

# mount /dev/hda7 /mnt/ntfs -t ntfs-3g
# vi /etc/fstab
->
/dev/hda7 /mnt/ntfs ntfs-3g defaults 0 0
官網:
ntfs-3g

Wednesday, August 15, 2007

Shell Script: 每日檢查硬碟的使用量,當到達90%時寄出Alert mail給root

1. 至/root/bin目錄下,新增一shell script的檔案,名為diskspace.sh,內容如下:
#!/bin/bash
df -h | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge 90 ]; then
echo "Running out of space "$partition $usep%" on $(hostname) as on $(date)" | mail -s "Alert: Almost out of disk space $usep%" root
fi
done

2. # chmod 755 diskspace.sh

3. # crontab -e
-> 10 5 * * * /root/bin/diskspace.sh

這個範例用了grep,awk與cut指令來實作,可以見得它們有多好用了 :)

參考來源: http://www.cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html

Thursday, August 09, 2007

Canon IXUS 850試拍

趁著這次應用展買了Canon IXUS 850,原本也很想買Sony的T100但想到了記憶卡相容性的問題,我還是選擇了Canon :p
附上一張大白(ibook)與小白(NDSL)的合照。

Friday, August 03, 2007

Setup a mail server that enables smtp auth function

Mail Server IP address: 192.168.1.254
OS: OpenSUSE 10

Setup procedure:

1. Setup Hostname (server1.example.com)

# vi /etc/HOSTNAME
server1.example.com
# vi /etc/hosts
192.168.1.254 server1.example.com server1

2. Setup DNS Server:

# vi /etc/named.conf
Configure:

options {
# The directory statement defines the name server's working directory
directory "/var/lib/named";
# Write dump and statistics file to the log subdirectory. The
# pathenames are relative to the chroot jail.
dump-file "/var/log/named_dump.db";
statistics-file "/var/log/named.stats";
# The forwarders record contains a list of servers to which queries
# should be forwarded. Enable this line and modify the IP address to
# your provider's name server. Up to three servers may be listed.
#forwarders { 192.0.2.1; 192.0.2.2; };
# Enable the next entry to prefer usage of the name server declared in
# the forwarders section.
#forward first;
# The listen-on record contains a list of local network interfaces to
# listen on. Optionally the port can be specified. Default is to
# listen on all interfaces found on your system. The default port is
# 53.
#listen-on port 53 { 127.0.0.1; };
# The listen-on-v6 record enables or disables listening on IPv6
# interfaces. Allowed values are 'any' and 'none' or a list of
# addresses.
listen-on-v6 { any; };
# The next three statements may be needed if a firewall stands between
# the local server and the internet.
#query-source address * port 53;
#transfer-source * port 53;
#notify-source * port 53;
# The allow-query record contains a list of networks or IP addresses
# to accept and deny queries from. The default is to allow queries
# from all hosts.
#allow-query { 127.0.0.1; };
# If notify is set to yes (default), notify messages are sent to other
# name servers when the the zone data is changed. Instead of setting
# a global 'notify' statement in the 'options' section, a separate
# 'notify' can be added to each zone definition.
notify no;
};
zone "." in {
type hint;
file "root.hint";
};
zone "localhost" in {
type master;
file "localhost.zone";
};
zone "0.0.127.in-addr.arpa" in {
type master;
file "127.0.0.zone";
};
zone "example.com"
{
type master;
file "master/example.com.zone";
};


# cd /var/lib/named/master
# vi example.com.zone
Configure:

$TTL 1W

@ IN SOA server1.example.com. root.server1.example.com. (

42 ; serial (d. adams)

2D ; refresh

4H ; retry

6W ; expiry

1W ) ; minimum



IN NS server1

server1 IN A 192.168.1.254



# chown root.named example.com.zone
# rcnamed start
# chkconfig named on
# vi /etc/resolv.conf
Configure:

nameserver 192.168.1.254


3. Setup Postfix mail server and enables smtp auth function:

# vi /etc/postfix/main.cf
Configure:

queue_directory = /var/spool/postfix

command_directory = /usr/sbin

daemon_directory = /usr/lib/postfix

mail_owner = postfix

unknown_local_recipient_reject_code = 550

mynetworks = 127.0.0.0/8





debug_peer_level = 2

debugger_command =

PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin

xxgdb $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail

newaliases_path = /usr/bin/newaliases

mailq_path = /usr/bin/mailq

setgid_group = maildrop

html_directory = /usr/share/doc/packages/postfix/html

manpage_directory = /usr/share/man

sample_directory = /usr/share/doc/packages/postfix/samples

readme_directory = /usr/share/doc/packages/postfix/README_FILES

inet_protocols = all

biff = no

mail_spool_directory = /var/mail

canonical_maps = hash:/etc/postfix/canonical

virtual_alias_maps = hash:/etc/postfix/virtual

virtual_alias_domains = hash:/etc/postfix/virtual

relocated_maps = hash:/etc/postfix/relocated

transport_maps = hash:/etc/postfix/transport

sender_canonical_maps = hash:/etc/postfix/sender_canonical

masquerade_exceptions = root

masquerade_classes = envelope_sender, header_sender, header_recipient

myhostname = server1.example.com

program_directory = /usr/lib/postfix

inet_interfaces = all

masquerade_domains =

mydestination = $myhostname, localhost.$mydomain

defer_transports =

disable_dns_lookups = no

relayhost =

mailbox_command =

mailbox_transport =

strict_8bitmime = no

disable_mime_output_conversion = no

smtpd_sender_restrictions = hash:/etc/postfix/access

smtpd_client_restrictions =

smtpd_helo_required = no

smtpd_helo_restrictions =

strict_rfc821_envelopes = no

smtpd_recipient_restrictions = permit_mynetworks,reject_unauth_destination

smtp_sasl_auth_enable = no

smtpd_sasl_auth_enable = no

smtpd_use_tls = no

smtp_use_tls = no

alias_maps = hash:/etc/aliases

mailbox_size_limit = 0

message_size_limit = 10240000

smtpd_sasl_auth_enable = yes

smtpd_sasl_security_options = noanonymous

broken_sasl_auth_clients = yes

smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination

# rcsaslauthd start
# chkconfig saslauthd on

# rcpostfix start
# chkconfig postfix on

4. Enable pop3 server:

# chkconfig qpopper on
# rcxinetd restart

5. Add user account:

# useradd -m lawrence
# passwd lawrence

-> Finished

Sunday, July 29, 2007

Linux Distribution Chooser

Linux Distribution百百種,你適合那一種版本呢?嘿~現在有個網站可以幫您做個分析,帽客做完後,它推薦我用Fedora與OpenSUSE,哇!!真準呀!剛好是我最熟悉的!真好玩 :)

Linux Distribution Chooser

網路效能測試工具: iperf

最近測試的案子中,利用了一套軟體來測試網路的效能,它叫做iperf,iperf支援大多數的作業系統,如: Windows,Linux,FreeBSD,MACOSX,Solaris等等,使用上非常簡單,在你的網路環境中準備兩台電腦,各架設於兩端點間,如core switch到RD switch之間,一邊設定為iperf server,另一邊設定成iperf client,這麼一來你就可以知道core switch與RD switch之間的throughput能達到多少,它可針對TCP or UDP來做測試唷!由於命令參數挺多,所以在這邊我就不多提了,您可以至以下連結取得iperf來安裝,並參考設定範例,經過測試,iperf可以很成功的在Windows XP SP2,RHEL4/5與Ubuntu上執行。

iperf

Saturday, July 28, 2007

找RPM的好地方

以下列出帽客常去找RPM的網址:

http://rpmfind.net
http://rpm.pbone.net/
http://www.rpmseek.com/index.html
http://benjiweber.co.uk:8080/webpin/

Thursday, July 12, 2007

Crossover for Linux

今天帽客要跟大家介紹一個還不錯用的軟體,它叫做Crossover,它是一個能讓你在Linux or MAC OSX下安裝MS applcations的一套軟體。

老實說啦,很多時候迫於無耐,還是要跑跑MS的東西,比如MS office,沒辦法....大部份的公司還是用MS office,為了這樣,我只好在我的Linux下裝個MS office來用吧。

安裝Crossover,一點也不難,先至官網抓下試用版後(它是一個script file),你只要給它有x的權限後就可以安裝了,這時它會引導你一步一步完成安裝。

安裝完畢後,登出並登入X window後,你應該會在Applications選單中看見Crossover,選擇Install Windows Software,並依照它的引導,很簡單的就能安裝好一些MS下的apps,帽客在RHEL,CentOS與Ubuntu測試過都能安裝成功並執行,最後附上幾張圖給大家參考。

圖1:

圖2 Word:

圖3 Excel:

圖4 IE6.0:

Tuesday, July 10, 2007

Ubuntu 架設nfs server

1. Install
$ sudo apt-get install nfs-common
$ sudo apt-get install nfs-kernel-server

2. 設定 /etc/exports (For example: 將/mnt/iso share給all net使用)
$ sudo vi /etc/exports
/mnt/iso *(ro,sync)

3. 啟動 nfs server
$ sudo /etc/init.d/nfs-kernel-server start

4. 檢查
$ showmount -e localhost
成功的話應該可以看到這樣的訊息:
Export list for localhost:
/mnt/iso *

Sunday, July 08, 2007

Ubuntu之旅2-Install AdobeReader 7.x

Procedure:
1. 新增apt server:
1.1 加入金鑰:
$ wget -q http://medibuntu.sos-sts.com/repo/medibuntu-key.gpg -O- sudo apt-key add -
1.2 新增套件來源庫:
$ sudo vi /etc/apt/sources.list
## Medibuntu - Ubuntu 7.04 "feisty fawn" ## Please report any bug on https://launchpad.net/products/medibuntu/+bugs deb http://medibuntu.sos-sts.com/repo/ feisty free non-free deb-src http://medibuntu.sos-sts.com/repo/ feisty free non-free

2. 更新與安裝AdobeReader
$ sudo apt-get update;
$ sudo apt-get install
acroread

3. 新增中文套件:
3.1 download tarball file from here
3.2 解開:
$ sudo tar zxvf FontPack708_cht_i386-linux.tar.gz
3.3 安裝:
$ sudo ./install

圖:

Wednesday, June 27, 2007

Ubuntu 安裝VMware Server

帽客常常透過VMware將一台電腦當兩台用,所以當然也要試著在Ubuntu上安裝看看囉,跟RHEL與SLES不一樣的是,Ubuntu不可透過rpm來安裝唷!要用tarball file與上個path之後才能順利安裝成功,至於怎麼裝,請參考這個連結: 在Ubuntu7.04上安裝vmware server

附上一張圖,有圖有真相嘛 :p

Friday, June 22, 2007

Ubuntu之旅

人家都說用Ubuntu來當Linux Desktop是很方便的選擇,於是乎帽客我也想來體驗看看,去官網抓下Desktop版的iso後,利用我那小白把它燒成CD(只要一片就好ㄟ!),放到測試的機器安裝,嗯~果然非常之簡單,一會便裝完了。

待開機完成後,用剛剛所建立的User登入,第一件事便是來裝個Beryl玩看看,呵呵~真是方便呀!利用apt來安裝真是好用呀~~ 搞定了3D桌面後,便開始安裝各種Applications。
Amule,d4x,gFTP,k3b....都很好裝,跟以往我把RHEL3當桌面,被rpm相依性問題搞爆的痛苦來比真是太美妙了,只是在安裝gcin與stardict時有點小不順,所以先po上來記一下:

-Install stardict
# sudo apt-get install stardict
預設是沒有辭典可以用的唷,這時請到stardict官網抓下辭典,解開後將檔案搬到/usr/share/stardict/dic就可以了。

-Install gcin
# sudo apt-get install gcin
# sudo apt-get install im-switch
# im-switch -s gcin
重新登入,便可使用gcin。

Friday, June 15, 2007

G4Fancontrol

話說,帽客的小白開機久了就會發高燒到60度上下,非常之燙手,同時對小白的壽命也會有影響,所以我都有用散熱墊來幫忙讓它的工作溫度保持在40度上下,但是當我人在外面使用時,就不想帶著散熱墊呀!所以只好讓它發高燒。
之前Intel base的Mac有出控制風扇的軟體,心想~為何PPC沒有呀!哭~~~難道PPC的使用者就沒有明天了嗎? 哭~~~~ 不過,今天讓我找到了For PPC的風扇控制軟體,哈哈!我的小白出運囉~~ 先測試看看會不會work先。

Website: G4Fancontrol

Thursday, June 07, 2007

Final Fantasy XII:歸來之翼


最近趁有空閒的時候,將NDS上的一款遊戲Final Fantasy XII:歸來之翼破關了,整個遊戲必需使用觸碰筆操作,一開始很不習慣,但玩久了還覺得蠻有趣的!

遊戲的難度不高,幾乎給它來個大軍壓境都能輕鬆獲勝,除了後面幾關之外 :p
雖然我沒玩過PS2的FF12,但這款外傳也帶給我不少樂趣!

官方網站: http://www.square-enix.co.jp/ff12rw/

Wednesday, June 06, 2007

在RHEL5架設DNS Server

RHEL5跟以往RHEL4與RHEL3在架設DNS Server時,有些不一樣,不一樣的地方在於,ㄟ~~configure file怎麼都沒看到哩,還有預設的zone files哩,怎麼都沒有呀?!要我自己產生嗎? OH MY GOD! 那有可能呀!所幸今天在高人的指點下,找到了這些檔案身在何處呀!果然是高手高手高高手呀!

01- 安裝system-config-bind這隻套件
02- 到/usr/share/system-config-bind/profiles/下就可以找到named.conf與zone files.
03- 接下來把named.conf copy到 /var/named/chroot/etc/
04- 再把zone files copy到 /var/named/chroot/var/named/
05- 最後把將 /usr/share/doc/bind-*/sample/var/named/named.root copy到/var/named/chroot/var/named/

這樣就大功告成啦!剩下的就是自己改named.conf與新增網域正反解的zone files囉!

Friday, June 01, 2007

Fedora 7 出了!

今天Fedora Project release Fedora 7囉!這次的版本支援i386,x86_64 and ppc,預計今晚回家download後,安裝在IBM X24上測試看看。

如果您需要更多的資訊,請參考Fedora Project的官方網站。
Fedora Project

Thursday, May 31, 2007

Linux發行者大收集

Linux發行的套件到底有幾個呀?呵~這我也不知道,以下這個網站整理了目前發行者的logo與連結(看得我眼睛都花了!)。目前看起來是352個,不過應該不止吧 :p

http://www.gridter.com/linx/linux.html

Tuesday, May 29, 2007

Partimage & SystemRescueCd

最近找到一個很好用的工具: Partimage,它是個類似Ghost這樣的軟體,可對分割區做備份與還原的功能(Support ReiserFS, ext2fs/ext3fs, FAT16/32: DOS and Windows, and NTFS),經過我的測試過後,它真是不錯用!快速又簡單,然後又找到了SystemRescueCd,它算是個Linux Live cd,而且它內建了許多系統救援的工具,當然Partimage也是內建於其中的囉!

Note: 當您在備份分割區時,記得要先把它umount掉唷!


Partimage: http://www.partimage.org/Main_Page
SystemRescueCd: http://www.sysresccd.org/Main_Page

Monday, May 28, 2007

Chkrootkit

擔心你的Linux system被植入後門嗎?試看看這套軟體吧!
您可以從 http://www.chkrootkit.org/download下載,目前的版本是0.47,如果您是用RHEL,Fedora or SUSE的使用者,到rpmfind.net可以下載到rpm來安裝。

Wednesday, May 23, 2007

在多台Linux Server上同時執行相同的commands

multixterm這隻程式可以同時在不同的Server上,執行指令,分享出來給大家參考看看:

-安裝:
請安裝expectexpect-develexpectk這三個套件,帽客是RHEL的愛好者,剛好在光碟片中有這三個套件。

-執行:
# multixterm -xc "ssh %n" host1 host2

-這時會跳出三個視窗,其中兩個為host1與host2的console,另一個為multixterm的主視窗,如果你要將命令同時在host1與host2執行的話,請將滑鼠移到stdin window再敲入指令就可以了。

Monday, May 21, 2007

讓使用者暫時無法登入到Linux系統

Linux是個多人多工的系統,有時萬一碰到要系統升級或除錯時,最好是不要讓使用者登入到系統中,有一個很簡單的方法,可以達成這個要求:
# touch /etc/nologin
這樣一來只有root可以登入到系統中,待系統維護好了之後,再把這個檔案刪除即可。

Thursday, May 17, 2007

Windows2000下解決抓不到大硬碟容量的方法

遇到了就記一下囉:
在開始->執行中輸入regedit,在HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services \Atapi\Parameters下,建立一個DWORD值,名為EnableBigLba,数值填1。 修改後重啟機器即可。

Tuesday, May 15, 2007

我的Linux桌面環境

目前桌機的桌面環境,該有的都有了,套用MAC OSX的佈景主題,看起來還不錯!

利用shell script大量建立帳號

-先建立一個純文字檔(userlist),裡面存放著欲建立的user帳號,格式為 username:password,
user1:123456
user2:123456
user3:123456

-撰寫shell script如下:
#!/bin/bash
FILE=$1
for i in `awk -F: '{ print $1 }' $FILE`
do
useradd $i
grep $i $FILE | cut -d":" -f2 | passwd --stdin $i
done


-執行:
# ./mkuser.sh userlist

這樣便可大量建立帳號。