圖書館服務隊

Name:
Location: Taiwan

Monday, May 22, 2006

課程講義

http://140.136.81.145:9999/services/

setup runlevel services

sysv-rc - Standard boot mechanism using symlinks in /etc/rc?.d
bum - tool to manage bootup scripts
file-rc - Alternative boot mechanism using a single configuration file
newbiedoc - Documentation by and for newbies
rcconf - Debian Runlevel configuration tool
sysv-rc-conf - SysV init runlevel configuration tool for the terminal

Saturday, May 20, 2006

各圖書館現況

1.弓鞋國小
http://www.wretch.cc/album/album.php?id=linsservice&book=1
barcode
書標-ok
財產標籤
借書證

2.鳳凰國小
http://www.wretch.cc/album/album.php?id=linsservice&book=2
barcode-ok
書標-ok
財產標籤
借書證

3.南港國小
http://www.wretch.cc/album/album.php?id=linsservice&book=3
barcode
書標-ok
財產標籤
借書證

4.梨山國小
http://www.wretch.cc/album/album.php?id=linsservice&book=4
barcode
書標-ok
財產標籤
借書證

目前

1. barcode
2. 書標
3. 財產編號
4. 借書證

Friday, May 19, 2006

設定主機名稱

http://www.in-life.idv.tw/index.php?/archives/2005/11/09/C4.html

先要注意 hostname 及 domainname 和 FQDN 之間的差異,簡單的說 FQDN 就是 hostname+domainname

以下假設使用的 ip 是168.95.1.1, hostname 是 test, domainname 是 foo.com.tw,那麼 FQDN 就是 test.foo.com.tw

1. 設定 hostname

修改 /etc/hostname,將內容改為 test

2. 設定 /etc/hosts,一般尚要注意 127.0.0.1,如下是其內容

127.0.0.1 localhost
168.95.1.1 test.foo.com.tw test

3. 使 hostname 生效

# hostname --file /etc/hostname

4. 檢查是否正確

# hostname --fqdn
test.foo.com.tw

這樣就 ok 了,另外要注意的就是 /etc/mailname 這個檔案,通常只有短短的一行,說明著你的 mail 主機名稱,有些 mail 程式會用到,man 的相關資料

The file /etc/mailname is a plain ASCII configuration file, which on a
Debian system contains the visible mail name of the system. It is used
by many different programs, usually programs that wish to send or relay
mail, and need to know the name of the system.

The file contains only one line describing the fully qualified domain
name that the program wishing to get the mail name should use (that is,
everything after the @).

Debian 參考手冊 第 8 章 - Debian技巧

http://www.debian.org/doc/manuals/reference/ch-tips.zh-tw.html

Debian 參考手冊

http://www.debian.org/doc/manuals/reference/ch-gateway.zh-tw.html

Thursday, May 18, 2006

reference

第1堂(2006/03/28):
0. Live CD下載網址:
http://b2d.tnc.edu.tw/
上課所發的是
B2DpureKDE
ftp://ftp3.tnc.edu.tw/KNOPPIX/health/B2DpureKDE20060119.iso

第2堂(2006/04/18)
0. 強迫結束X-window
ctrl-alt-backspace 三個鍵一起按

1. 切換virtual console與x-windows
ctrl-alt F1
ctrl-alt F2
ctrl-alt F3
ctrl-alt F4
ctrl-alt F5
ctrl-alt F6
ctrl-alt F7

2. screen的使用
ctrl-a-c create
ctrl-a-n next
ctrl-a-p previous
ctrl-a-d detach
screen -ls
screen -r xxxx

第3堂
0. su - knoppix
1. ls -alF /etc/passwd
2. whoami
3. rm /etc/passwd
4. pwd
5. cat /etc/passwd
6. ls -alF /etc/group
7. cat /etc/group
8. /bin/false
9. df
10. umount /dev/sda1
11. umount /dev/media/sda
12. mkdir /media/xxx
13. mount /dev/sda1 /media/xxxx
14. umount /media/xxx
15. mkdir /xxx
16. mount /dev/sda1 /xxx

1. gnome-terminal &
rxvt &
善用tab鍵來做命令補齊

2. ls
ls -F
unalias ls
ls -F
@, *, / etc...

3. alias ls
alias ls='ls -F -h -l'

4. cp /etc/hosts hosts
cp /etc/hosts .
ls -l hosts

5. pwd
mkdir test
cd test
cd /etc/dhcp3
cd ~/test

6. whoami

7. cat /etc/passwd
more /etc/passwd
less /etc/passwd

space
g
G
b
/
"q" to quit

8. ls -alF | less

9. less /proc/cpuinfo
less /proc/meminfo
dir /dev/cdrom
less /proc/uptime

10. which ls
which pwd

11. su -
mount /dev/cdrom /mnt
ls -alF /mnt
less /mnt/README.txt
umount /mnt
eject

umount /tmp/hda1
mount /dev/hda1 /tmp/hda1
mount

第4堂
1. umount /tmp/hda1
mount /dev/hda1 /mnt
umount /mnt
mount -t ntfs /dev/hda1 /mnt
umount /mnt
mount -t vfat /dev/hda1 /mnt
dmesg
dmesg | less

mount -t vfat /dev/hda1 /mnt
dmesg | tail
dmesg | tail -n 5
dmesg | less

2. history

3. print only line 3:
dmesg | head -n 3 | tail -n 1

print line 3, 2nd word
dmesg | head -n 3 | tail -n 1 | cut -d" " -f 2

cat /etc/passwd | head -n 3 | tail -n 1 | cut -d":" -f 3

4. mkdir test2
cd test2
cp /etc/hosts .
cd ..
rmdir test2
rm -r test2
rm -ri test2
rm -rf test2

5. unalias
ls -alF
ls -alFh
ls -alFs

6.
cd /tmp
touch test3
chown steven test3
chgrp steven test3
chown steven.steven test3
chown root.root test3
chown steven.steven test3
chown -R steven.steven test4

7. chmod u r file
g + w
o - x
a
chmod u+rwx,g-rxw,o-rxw test3
chmod 700 test3

8. touch .test
ls -alF
ls -l

9. ..
.
.test
cp /etc/hosts .
cd ..
cd /home/steven/tmp/../


第5堂
1. history
!!
!496
ctrl-r + keyword

2. echo "$USER"
echo '$USER'
echo `$USER`

3. bill=ls
echo "$bill"
echo '$bill'
echo `$bill`

4. `which ls`
killbill=`which ls`

5. rxvt
rxvt &

rxvt
ctrl-Z
bg
fg

6. rxvt &
rxvt &

rxvt
ctrl-Z

jobs
bg 3
fg 2

7. ps
kill 7865
kill -9 7865
killall rxvt
pkill rxvt

8. ps -ef
ps -efw
pstree

9. runlevel
init 1
cat /etc/inittab

10. gedit ~/.bash_profile
append:
---
export PATH=$PATH:/sbin
---
source ~/.bash_profile

11. less /etc/fstab
#

12. /etc/init.d/gdm stop

13. dmesg | grep '^hda:'
dmesg | grep -o '^hda:'
grep "hda" /etc/*
grep -r "hda" /
dmesg | grep -o '^hda:' | wc -l

第6堂
1. sync
sync;sync;sync
shutdown -h -t 5 now "shutdown now..."

2. man ls
man crontab
man 5 crontab
man passwd
man 5 passwd

3. info ls
info info
"p" previous page
"n" next page
l
^L

4. vim
vi test.txt
insert i
:wq
:q!
hjkl
^
$
到某一行
1G
22G
G

:set nu
:set nonu
J
u
:syntax on
:syntax off

:help
:set ic
:set noic

刪除相關
dw
dd
d$
d^
5dd

尋找
/FOO
n
N
set nohlsearch
set hlsearch

複製相關
5Y
p
P
ctrl-v
ctrl-v Y
ctrl-v : y

:set vb
:set novb

視窗相關
ctrl-w s
ctrl-w v
ctrl-w [h,j,k,l]
:e /tmp/abc.txt
:wq
:q

vim ~/.vimrc
-------------
set hlsearch
set ic
set ruler
syntax on
-------------

取代
%s/abc/xyz/
%s/abc/xyz/g
%s/abc/xyz/gc
1,$s/abc/xyz/gc
10,20s/abc/xyz/gc
^$
:g/^$/d

%s/ab\/c/xyz/
ctrl-v [enter]

gvim

其他:
O
o

VIM參考書:
http://opensource.nchc.org.tw/intro_to_linux/part1/vim/vimbook-OPL.pdf
vimbook錯誤更正(非官方)
http://www.moolenaar.net/vim_errata.html

大家來學Vim by 李果正 Edward G.J. Lee
http://edt1023.sayya.org/

# vim in M$ Windows
http://www.vim.org/download.php#pc

# CYGWIN
http://www.cygwin.com


第7堂
1. vim list.txt
------------
abc
acd
kgt 123
kkk 345
abc
kkk
------------
sort list.txt (cat list | sort)
sort -r list.txt (cat list | sort -r)
uniq list.txt (cat list | uniq)
uniq -d list.txt (cat list | uniq)
sort list.txt | uniq -d
wc list.txt
wc -w list.txt

2. grep root /etc/passwd
grep "^root" /etc/passwd
grep -q "^root" /etc/passwd
echo $?

grep "^root" /etc/passwd
RC=$?
ls /tmp/kkk
echo $RC

3. awk -F':' '{print $1, $7}' /etc/passwd
ps aux | awk '$4 > 1 {print $2}'

4. find /etc -type d -print
find /etc -name "*usb*" -print
find /etc -name "*usb*" -type f -print
find $HOME/ -mtime +3 -exec rm {} \;

5. head -n 3 list.txt
tail -n 3 list.txt
tail -n +2 list.txt

6. sed -e "s/abc/xyz/g" list.txt
sed -e "s/abc/xyz/g" -e "s/kkk/ooo/g" list.txt

7. xargs:
ps aux | awk '$4 > 9 {print $2}' | xargs kill

8. gzip list.txt
gunzip list.txt.gz

zip txt.zip list.txt
unzip txt.zip

tar -cvf txt.tar *.txt
gzip txt.tar

tar -cvzf txt.tgz *.txt

tar -tvzf txt.tgz
tar -xvzf txt.tgz

unzip -l txt.zip
-------------
bzip2 list.txt
bunzip2 list.txt.bz2

tar cvjf list.txt.bz2 *.txt
tar tvjf list.txt.bz2
tar xvjf list.txt.bz2

第8堂
1. Shell Script:
export LC_ALL=C
date +%m
date +%d
man date
date +%D
export TODAY=`/bin/date +%D`
echo $TODAY
echo "Today is $TODAY"
export TODAY=`/bin/date +%D`; echo "Today is $TODAY"
vim showtoday.sh
---------------------
#!/bin/sh
# Show today
TODAY=`/bin/date '+%D %b'`
echo "Today is $TODAY"
---------------------
./showtoday.sh
chmod a+x showtoday.sh

---------------------
#!/bin/sh
# Show today
TODAY=`/bin/date '+%D %b'`
echo "Today is $TODAY"
tar cvzf ${TODAY}_steven_home.tgz ~/*
---------------------
./showtoday.sh

./showtoday.sh
sh showtoday.sh
source showtoday.sh
. showtoday.sh

vim subsh.sh
----------------------
#!/bin/sh
TOM="hello"
----------------------
chmod 755 subsh.sh
echo $TOM
./subsh.sh
echo $TOM
source subsh.sh
echo $TOM


2. I/O重導向
File Descriptor(n) Name 一般縮寫 典型預設
0 standard input stdin keyboard
1 standard output stdout screen
2 standard error stderr screen

> file
< file
>> file
n> file
n< file
>&n duplicate the standard output to file descriptor n
<&n duplicate the standard intput to file descriptor n
&> file direct standard output and standart error to file

Ex:
1. ls /tmp/init.d/*
ls /tmp/init.d/* > etc_list.txt
ls /tmp/init.d/* > etc_list.txt 2> etc_list.err

2. ls /tmp/nosuchfile
ls /tmp/nosuchfile > results.txt
ls /tmp/nosuchfile 2> results.txt

3. modprobe 8139too >/dev/null 2>&1
modprobe 8139too &>/dev/null

4. redirect standard output to stnadard error:
echo "Usage error: see adminstrator" 1>&2

5. ls -alF *.sh | tee 2005.txt

6. crontab
crontab -l
crontab -e
-------------
0-59/15 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
-------------


3. Regular Expression 正規表示式
為何要用RE ?
Ex: 在編輯檔案的時候,要將所有text1, text2, text3... text9取代成fig
a. 在不支援RE的編輯器,需要作9次,慢慢改
b. 在支援RE的編輯器,只需一行就可以搞定。以vi為例:
:%s/text[1-9]/fig/g

常見的RE字元:
.
*
?
+
?
^
$
[ ]
[^ ]
|
( )

Ex:
bag
^bag
bag$
^bag$
[Bb]ag "Bag", "bag"
b[aeiou]g
b[^aeiou]g
[0-9]
[a-z]
[A-Z]
[a-zA-Z0-9]
b.g
^...$
^\.
^\.[a-z][a-z]
^[^.]
bugs* "bug", "bugs", "bugss"...
[A-Z][A-Z]*
[A-Z]+
[A-Z].*
[A-Z]*
[a-zA-Z]
[0-9A-Za-z]+
[567]
five|six|seven
80[23]?86 8086, 80286, or 80386
compan(y|ies) company or companies


注意:regular expression的字元和shell expression的字元不盡相同
Ref: http://www.grymoire.com/Unix/Sh.html#uh-4
+-------------------------------------------------------------------------------+
| Table 1|
| Examples of filename expansion|
+-------------------------------------------------------------------------------+
|PatternMatches|
|*Every file in the current directory|
|?Files consisting of one character|
|??Files consisting of two characters|
|??*Files consisting of two or more characters|
|[abcdefg]Files consisting of a single letter from a to g.|
|[gfedcba]Same as above|
|[a-g]Same as above|
|[a-cd-g]Same as above|
|[a-zA-Z0-9]Files that consist of a single letter or number|
|[!a-zA-Z0-9]Files that consist of a single character not a letter or number |
|[a-zA-Z]*Files that start with a letter|
|?[a-zA-Z]*Files whose second character matches a letter.|
|*[0-9]Files that end with a number|
|?[0-9]Two character filename that end with a number|
|*.[0-9]Files that end with a dot and a number|
+-------------------------------------------------------------------------------+

Ex:
Regular expression:
1. vim re.txt
----------------------
text1, text2, text3, text4, text5,... text9
ttxy
xyttk
okokok
bag
bug
bugs
bag
bagxxx
beg beg
big bog
.big
...big
---------------------
:%s/text[1-9]/fig/g

:%s/./5/g

:%s/^/ /g

grep -E t? re.txt
egrep t? re.txt
grep -E t+ re.txt
egrep t+ re.txt
grep ^bag re.txt
grep ' bag' re.txt
grep '^bag$' re.txt
grep [Bb]ag re.txt

第9堂
1. cygwin 介紹 (http://www.cygwin.com)
2. DRBL (企鵝龍) 介紹 (http://drbl.nchc.org.tw, http://drbl.sf.net)
3. Linux上網路相關指令介紹
ref:
Debian 參考手冊 第 10 章 - 網路設定
http://www.debian.org/doc/manuals/reference/ch-gateway.zh-tw.html

3.0
ipcalc 192.168.1.0/255.255.255.248
ipcalc 140.110.1.1/255.255.255.0

3.1 ifconfig
ifconfig eth0

找出網路卡eth0的MAC address:
ifconfig eth0 | awk '/HWaddr/ {print $5}'

找出eth0的IP address:
ifconfig eth0 | awk -F":" '/inet addr/ {print $2}' | awk '{print $1}'
ifconfig eth0 | grep -o 'inet addr:[0-9.]*' | cut -d":" -f2

如果找不到ifconfig:
which ifconfig
whereis ifconfig
printenv PATH
/sbin/ifconfig

3.2 看routing table
route
route -n

3.3 ping
ifconfig eth0
ping 140.110.25.1
ping 140.110.1.1
ping -c 10 140.110.25.1
ping os.nchc.org.tw

3.4 traceeroute
traceroute 140.110.25.1
traceroute 140.110.1.1
traceroute os.nchc.org.tw
traceroute -n os.nchc.org.tw

3.5 ifconfig eth0 down
ifconfig eth0 up
pump

第10堂
Debian Sarge安裝
1. Sarge光碟位於
http://cdimage.debian.org/debian-cd/3.1_r0a/
or
ftp://free.nchc.org.tw/debian-cd/3.1_r0a/i386/

2. apt -> deb
apt/yum/urpmi -> rpm

3. ctrl-alt-F1 切換到console 1
vi /etc/apt/sources.list
加上
deb http://linux.nchc.org.tw/debian sarge main contrib

4. apt-get update
apt-cache search big5
apt-get install ttf-arphic-bkai00mp ttf-arphic-bsmi00lp

5. ctrl-alt-F7 切換到X-window
ctrl-alt-backspace 重新啟動X-window

6. apt-get install vlc
vlc http://free.nchc.org.tw/audio_video/2005-05-27-RMS_NCHC_TW.mpeg4

7. 安裝經典遊戲
apt-get install supertux frozen-bubble tuxracer
執行遊戲
a. supertux
b. frozen-bubble
c. ppracer

第11堂
1. dpkg-reconfigure xserver-xfree86
2. dpkg -l
3. dpkg --purge
4. man 5 contrab
crontab -e
-------------
MAILTO=steven
5 0 * * * apt-get update >/dev/null; apt-get -y upgrade >/dev/null
-------------

another sol :
vim /etc/cron.daily/updatedebian
----------
apt-get update
apt-get -y upgrade
----------
chmod 755 /etc/cron.daily/updatedebian

5. ps -ef |grep cron
runlevel
ls -alF /etc/rc2.d/*cron

6. cd /etc/rc2.d
ln -fs ../cron S89cron
or
update-rc.d cron defaults

To remove
update-rc.d cron remove

第12堂
1. install Linux, coexist with M$ windows XP
2. grub
http://www.gnu.org/software/grub/grub.html
3. How to change root password if I forget that ?

4. /etc/sources.list
-------------
deb http://free.nchc.org.tw/debian stable main contrib
-------------
apt-get update
5. aptitude,然後選tasks中的選項
--\ Tasks
--- End-user
以及
--- Localization
--- Traditional Chinese environment

6. http://free.nchc.org.tw/kernel/linux/kernel/v2.6/linux-2.6.14.5.tar.bz2
or
ftp://free.nchc.org.tw/os/linux/kernel.org/linux/kernel/v2.6/linux-2.6.14.5.tar.bz2

7. a. tar xjf linux-2.6.14.5.tar.bz2
b. cd linux-2.6.14
c. apt-get install libncurses5-dev
d. make menuconfig
e. make
f. make install; make modules_install
(files are in /boot/ and /lib/modules/)

第13堂
A. 上課使用Clonezill複製之後的作業系統環境只有文字介面,並且網路不通。
練習把網路設定好,kde/gnome裝起來
如何作:
1. login
2. vi /etc/network/interfaces
%s/eth0/eth1/g
3. /etc/init.d/networking restart
4. vi /etc/apt/sources.list
編輯檔案/etc/apt/sources.list,只有這一行
------------------------------------
deb http://free.nchc.org.tw/debian stable main contrib
------------------------------------
5. apt-get update
6. aptitude,然後選tasks中的選項
--\ Tasks
--- End-user
以及
--- Localization
--- Traditional Chinese environment

或是
apt-get install x-window-system kde gnome gdm ttf-arphic-bkai00mp ttf-arphic-bsmi00lp kde-i18n-zhtw mozilla
7. /etc/init.d/gdm restart
8. adduser john
userdel -r john

PS.
Debian Sarge安裝後手動設定此次網路
##
ifconfig eth1 140.110.25.x netmask 255.255.255.128
route add default gw 140.110.25.126 eth1
vi /etc/resolv.conf
=================================
nameserver 140.110.60.1
nameserver 140.110.16.1
search nchc.org.tw
=================================

2.
Debian中將資料寫在硬碟以便每次開機自動載入
Debian的設定檔在/etc/network/interfaces :
vi /etc/network/interfaces
=================================
auto eth1
iface eth1 inet static
address 140.110.25.x
netmask 255.255.255.128
broadcast 140.110.25.127
gateway 140.110.25.126
=================================

vi /etc/resolv.conf
=================================
nameserver 140.110.60.1
nameserver 140.110.16.1
search nchc.org.tw
=================================

vi /etc/hosts
=================================
140.110.25.x cpc0xx.nchc.org.tw cpc0xx
=================================

重新啟動網路服務(會讀取/etc/network/interfaces來設定網路)
/etc/init.d/networking restart


3.
RedHat/Fedora/Mandrake的設定檔在/etc/sysconfig/network-scripts/ifcfg-eth0
vi /etc/sysconfig/network-scripts/ifcfg-eth0
=================================
DEVICE=eth0
BOOTPROTO=static
BROADCAST=140.110.25.255
IPADDR=140.110.25.x
NETMASK=255.255.255.0
NETWORK=140.110.25.x
ONBOOT=yes
=================================

vi /etc/sysconfig/network
=================================
NETWORKING=yes
HOSTNAME=XXXX
DOMAINNAME=nchc.org.tw
GATEWAY=140.110.25.x
=================================

重新啟動網路服務(會讀取/etc/sysconfig/network-scripts/ifcfg-eth0與/etc/sysconfig/network來設定網路)
/etc/init.d/network restart
-----

B. 中文輸入法gcin的安裝
For Debian sarge沒有im-switch,可以借用etch中的
1.. /etc/apt/sources.list
deb http://free.nchc.org.tw/debian etch main
deb http://www.calno.com unstable main
2. apt-get update
3. apt-get install im-switch gcin
4. im-switch -z zh_TW -s gcin

For Ubuntu breezy
1. apt-get install im-switch
2. /etc/apt/sources.list
deb http://www.calno.com unstable main
然後
apt-get update
apt-get install gcin
3. im-switch -z zh_TW -s gcin

C.
1. 核心與開機管理程式grub
a. uname -r
b. apt-get install kernel-image | less
c. apt-get install kernel-image-2.6.8-2-686-smp
d. dpkg -L kernel-image-2.6.8-2-686-smp |less
e. /boot, /usr/share/doc/kernel-image-2.6.8-2-686-smp, /lib/modules/2.6.8-2-686-smp
f. zless /usr/share/doc/kernel-image-2.6.8-2-686-smp/Changes.gz
g. vim /boot/grub/menu.lst
h. export LC_ALL=C
i. man bootparam
註:etch (目前的testing)中,kernel-image已經改名成linux-image.

D. grub
a. 改錯/boot/grub/menu.lst的話,可以在開機的時候,進入grub選單,用"e"去修正
b. 如果要進入single user mode,可以在grub的選單中的kernel後面添加參數"single"或是"1"
c. 進入single user mode如果要問密碼的話,要在/etc/inittab中有這一行(Debian預設有,但是RedHat/Fedora等沒有):
-------------
~~:S:wait:/sbin/sulogin
-------------

第14堂
A. Apache
1. Apache2, 參考
http://rapidshare.de/files/1568846/ApacheConfArticle_r22.pdf.html
apt-get install apache
/etc/init.d/apache restart
用Mozilla composer寫一個test.html檔,存在/var/www下
開啟mozilla, 輸入http://localhost/test.html

2. 安裝php & mysql
apt-get install php4 mysql-server
touch /var/www/a.php
/etc/init.d/apache restart
開啟mozilla, 輸入http://localhost/a.php

3. 提到wiki, blog等.
wikipedia ->
http://www.wikipedia.org


第15堂
1. samba
a. apt-get install samba smbclient smbfs
b. less /etc/samba/smb.conf

Samba
a. 啟動samba
/etc/init.d/samba start
b. 列出 Samba Server (IP: 192.168.166.1) 已分享了那些資源:
smbclient -L //192.168.166.1
c. 假設主機名稱為 chanel,它所開放出來的資源服務名叫 share,則可以由以下指令來連到它所分享出來得資源:
smbclient "//chanel/share"
d. 建立 Samba 使用者的帳號
將末加密的 /etc/passwd 檔轉換為有加密碼的 smbpasswd 檔:
cat /etc/passwd | mksmbpasswd > /etc/samba/smbpasswd
更改使用者的 Samba 密碼:
smbpasswd <使用者名稱>
e. 增加samba user
若欲新增 Samba 新使用者,必須先於 Linux 系統中新增使用者,才能於 Samba 中新增使用者
adduser --disabled-login --no-create-home --shell /bin/false test
新增 Samba 使用者:
smbpasswd -a test
測試:
smbclient -U test -L //192.168.166.1
f. 開放某個目錄 (/home/samba)
mkdir /home/samba
chown -R test /home/samba
/etc/samba/smb.conf中加一段
-----------------------------------------
[sambashare]
comment = Samba Share
path = /home/samba
username = test
read only = No
create mask = 0700
hosts allow = 192.168.166., 168.95.1.
-----------------------------------------
測試
testparm
重新啟動samba以便讓設定生效
/etc/init.d/samba restart
連線 smbclient -U test //192.168.166.1/sambashare
Password:
Domain=[SARGE] OS=[Unix] Server=[Samba 3.0.10-Debian]
smb: \> dir
. D 0 Wed Jan 5 15:47:47 2005
.. D 0 Wed Jan 5 15:47:42 2005
test.txt 0 Wed Jan 5 15:47:47 2005
45246 blocks of size 32768. 44220 blocks available

g. 掛載成某個目錄
mount -t smbfs //192.168.166.1/sambashare -o iocharset=950,username=test /mnt/smb
iocharset=950支援中文Big5編碼

如果密碼要寫上去(不建議)
mount -t smbfs //192.168.166.1/sambashare -o iocharset=950,username=test%passwd /mnt/smb

h. 如果是Linux當client, 掛載windows的server (192.168.166.88),使用者winuser屬於某個group (mis)
mount -t smbfs //192.168.166.88/winshare -o iocharset=950,username=winuser/mis%passwd /mnt/smb


2. 增加/移除某個service
增加:update-rc.d exim4 defaults
update-rc.d samba start 20 2 3 4 5 . stop 19 0 1 6 .
移除:update-rc.d -f exim4 remove

man update-rc.d for more details.
In RedHat-like distribution, use "chkconfig"

3. ftp server
可以安裝的ftp server: wu-ftpd or proftpd
a. 安裝
apt-get install wu-ftpd
最好選擇standalone模式

client program: apt-get install gftp
b.
設定檔在/etc/wu-ftpd
ACL: /etc/wu-ftpd/ftpaccess

class all real,guest,anonymous *.nchc.gov.tw
-> 定義一個名為 all 的組,而該組的成員有 real、guest 與 anonymous,而且只允許來自於 nchc.gov.tw 網域的使用者以上述身份登入使用。

語法:limit <群組名稱> <人數> <時間> <訊息檔案名稱>
預設:limit all 10 Any /etc/msgs/msg.dead

設定某一時間內允許連線的最大上限人數。

c. 要開啟anonymous
要先加一個特別的使用者"ftp"
adduser --home /home/ftp ftp
然後改/etc/wu-ftpd/ftpaccess中的
passwd-check
語法:passwd-check <(none/trivial/rfc822)> <(enforce/warn)>
預設:無
設定當使用者用 anonymous 登入時所要輸入的 password 的格式, 選項的說明如下:
* none:表示不做密碼驗證。
* trival:表示只要輸入密碼中含有 @ 便可登入。
* rfc822:表示密碼中一定要照 rfc822 所規定的 E-mail 位址的格式。
* enforce:表示當所輸入的密碼不符合格式即無法登入。
* warn:表示密碼不正確時只會出現警告的字樣,但仍可登入。

再重新啟動wu-ftpd以便設定生效
/etc/init.d/wu-ftpd restart

d. ftpcount 可要用來統計目前連線數目,也就是目前各個群組的上線人數,以及各個群組的連線上限人數
e. ftpwho 可用來察看目前的使用者與連線的情形

4. mail server
postfix, sendmail, qmail, exim...
以postfix為例
a. apt-get install postfix
b. 設定檔
/etc/postfix/main.cf...
c. 看或是修改postfix設定
postconf
例如修改每封信的可容許size
-----------------------------------------------------
postconf | grep size
bounce_size_limit = 50000
header_size_limit = 102400
message_size_limit = 10240000 <----- this is the one you want

可以修改main.cf或是直接執行

postconf -e "message_size_limit="
-----------------------------------------------------
d. 修改main.cf之後,可以重新啟動或是reload postfix
/etc/init.d/postfix reload

PS.
1. 若需要安裝額外的顯示卡驅動程式
a. Nvidia 顯示卡
a.1 "uname -r" 找到目前使用的kernel版本(例如2.6.8-2)
a.2 "apt-get install kernel-headers"列出可安裝的kernel headers
a.3 比較a.1與a.2,找出符合的(例如kernel-headers-2.6.8-2),然後例如:
apt-get install kernel-headers-2.6.8-2
(如果要一個指令做完a.1-a.3,可以這樣執行:apt-get install kernel-headers-`uname -r`)
a.4 到http://www.nvidia.com/linux網頁下載driver,以32位元PC而言,可以下載
標示為"Linux IA32"的驅動程式,例如Linux IA32下的1.0-7667
http://www.nvidia.com/object/linux_display_ia32_1.0-7667.html
然後依照那個網址所列的三個步驟執行即可。也就是
a.4.1 讀license宣告
a.4.2.執行"wget http://download.nvidia.com/XFree86/Linux-x86/1.0-7667/NVIDIA-Linux-x86-1.0-7667-pkg1.run"來下載檔案
a.4.3 執行"sh NVIDIA-Linux-x86-1.0-7667-pkg1.run"來編譯顯示卡驅動程式

b. ATI顯示卡
b.1 同a.1
b.2 同a.2
b.3 同a.3
b.4 以RADEON卡為例,到網頁 http://www.ati.com/ 的"DRIVERS & SOFTWARE"下載驅動程式,選擇"Linux Drivers and Software":
https://support.ati.com/ics/support/KBAnswer.asp?questionID=3380
以32位元PC而言,可以下載標示為"Linux x86"的驅動程式,以本例而言,選擇
"RADEON 8500 Series and higher"
https://support.ati.com/ics/support/KBList.asp?folderID=356
b.4.1 執行"wget http://www2.ati.com/drivers/linux/ati-driver-installer-8.14.13.run"
b.4.2 執行"sh ati-driver-installer-8.14.13.run"來編譯顯示卡驅動程式


其他:
提問的智慧: http://phorum.vbird.org/viewtopic.php?t=96

rcconf

apt-get rcconf
about govern services

考核表

1.安裝 ubuntu 5.10 server

2.設定 root passwd

3.single user mode

4.基本 vim 操作。
大家來學 Vim 一個歷久彌新的編輯器 http://info.sayya.org/~edt1023/vim/node1.html

5.text mode 設定網路。
網路設定 http://people.debian.org.tw/~moto/debian/DebianLessPain/Debian-Install-Guide-11.html#ss11.1

6.設定 apt 以及使用方法
如何手動更新 Ubuntu? http://wiki.ubuntu.org.tw/index.php/Ubuntu510_tw#.E5.A6.82.E4.BD.95.E6.89.8B.E5.8B.95.E6.9B.B4.E6.96.B0_Ubuntu.3F

其他常用指令介紹
http://people.debian.org.tw/~moto/debian/DebianLessPain/Debian-Install-Guide-10.html

7.安裝 ssh 以及使用。
SSH 伺服器 http://wiki.ubuntu.org.tw/index.php/Ubuntu510_tw#SSH_.E4.BC.BA.E6.9C.8D.E5.99.A8

pputty
PieTTY/pputty/PuTTY 是什麼? http://ntu.csie.org/~piaip/pietty/

8.安裝 apcache 以及設定。
阿帕契 HTTP 伺服器
http://wiki.ubuntu.org.tw/index.php/Ubuntu510_tw#.E9.98.BF.E5.B8.95.E5.A5.91_HTTP_.E4.BC.BA.E6.9C.8D.E5.99.A8

9.安裝 mysql
msyql
http://wiki.ubuntu.org.tw/index.php/Ubuntu510_tw#.E8.B3.87.E6.96.99.E5.BA.AB

10.安裝 proftpd 以及設定。
http://wiki.ubuntu.org.tw/index.php/Ubuntu510_tw#FTP_Server