本文最新網址位於 XFCE 設鍵盤快速鍵
XFCE 要設鍵盤快速鍵
於 設定 -> 視窗管理程式 -> 鍵盤 -> 新增 -> 再來就看自己要如何設定了.
再來就會發現自己 ~/.theme 下會有 自己剛剛新增的那個名字.
之後要換機器或環境. 把這個帶著走就可以囉 :)
本文最新網址位於Xwindow ICON 預設路徑
Xwindow 每次要找 ICON 時. 總是會不知道在哪裡 ... :(
還是記一下好了.. 預設: /usr/share/pixmaps/
而平常自己的 MAC 的 ICON 通常都會放在 ~/.icon 裡面.
今天幹了件很蠢的事情~.. 想要將 a電影.srt 改成跟 電影.avi 同名字.
於是就下了 mv a電影.srt 電影.avi ... 當按下 enter 時清醒了過來...
發現到那 avi 已經被我清掉了.. 變 srt 了... :~
於是就有這篇文章的由來.... 嗚... :~
雖然是寫說檔案刪除的回復救援, 但事實上我沒有成功救回來.. XD
主要是因為還要 mount -ro 而且我砍的檔案是在 "/". 很麻煩~ :(
而且也並不是那麼重要的檔案~ 大不了就那影片別看罷了... :p
但是看了這麼多~ 來做點小筆記比較好.. 希望未來不會需要用到這篇...
先簡單看一下幾種常用的 filesystem - Linux日誌式文件系统面面觀
(這篇下面有許多相關文件蠻不錯的)
說明系統rm, mv 等等動作是做何種事情, 流程, 該如何救回來 - UNIX系统被删文件的恢复策略
簡易說明實作步驟: Linux檔系統的反刪除方法
實作搶救的心得:[chat] 搶救過去!!!! (ext2 undelete)
救援主要就是靠 debugfs 這個程式.
debugfs 的程式就兩個 file, 大約共 500 行. 有興趣的就於下處去看看吧~(kernel 2.6.11)
/usr/src/linux/fs/debugfs/
以下都是轉載自原網站, 怕原網站資料遺失就頭痛了~ :(
發信人: thhsieh (居士), 信區: SM
標 題: [Sys] 搶救過去!!!! (ext2 undelete)
發信站: 冷月流蘇BBS驛站 (Mon Feb 1 17:21:11 1999) , 轉信
本系的 BBS 系統真是多災多難 (嗯 .... 其實是因為我的疏忽,才會這麼多災
多難 ....) ,繼這幾日系統時間不正確,造成許多人的 ID 被誤砍後,又一次
因系統設定上的問題,將 BBS 的重要備份檔給殺了。這件事是學弟發現後告訴
我的,當我上站來一見到他的 mail, 當真是欲哭無淚,差點沒去撞牆。那個備
分檔有多重要呢? 這麼說吧! 所有等待我們恢復舊信件的使用者資料全在裏頭。
那時已是週六晚 11:00 左右,我一邊想著要編一套說辭向大家解釋無法替大家
恢復舊信件與設定了,一邊還在想是否能夠挽回局面。大家知道, UNIX like
的系統是很難像 M$ 的系統一樣,做到 undelete 的,所有網管前輩都曾再三
警告我們,要小心! 小心! 砍檔之前三思而後行,砍了之後再後悔也沒用。雖
然我已漸漸做到砍檔三思而後行,但之次誤砍事件是系統在背景中定時執行的,
等到我找出原因時已是檔案被砍後一個多小時。
我憑著一點點的印象,想起在網路上,有人討論過在 Linux ext2 filesystem
中 undelete 的可能性,但我所見到的多半是負面的答案,但好像真的有人做過
這件事,於是我第一個所做的,就是馬上將該檔案原來所在的 partition mount
成 read-only, 禁止任何的寫入動作,不是怕再有檔案被誤砍 (因為已沒什麼可
砍的了) ,而是怕有新檔案寫進來,新資料可能會覆蓋到舊資料原本存在的磁區
(block) 。我們現在唯一個指望,就是企圖將檔案原來存在的磁區一個個找回來,
並且「希望」這些磁區上的舊資料都還在,然後將這些磁區串成一個檔案。
終於被我找到了!! 原來這方面的技術文件就存在我自己的系統中 :-))
/usr/doc/HOWTO/mini/Ext2fs-Undeletion.gz
於是我就按照這份文件的指示一步步來,總算將一個長達 8MB 的壓縮檔救回了
99%, 還有一個長達 1.1 MB 的壓縮檔完整無缺地救了回來。感謝上帝、 Linux
的設計者、寫那篇文件的作者、曾經討論過此技術的人、以及 Linux 如此優秀
的 ext2 filesystem, 讓我有機會搶救過去。現在,我將我的搶救步驟做一個整
理讓大家參考,希望有派得上用場的時候 (喔! 不,最好是希望大家永遠不要有
機會用到以下的步數 :-)))
************************************************************************
在此嚴正聲明!! 寫這篇文章的目的,是給那些處於萬不得已情況下的人們,有
一個挽回的機會,並不意味著從此我們就可以大意,砍檔不需要三思。前面提
到,我有一個檔案無法 100% 救回,事實上,長達 8MB 的檔案能救回 99% 已是
幸運中的幸運,一般的情況下若能救回 70% - 80% 已經要愉笑了。所以,不要
指望 undelete 能救回一切。預防勝於治療! 請大家平時就養成好習慣,砍檔前
請三思!!!
************************************************************************
我們能救回的機會有多大? 在 kernel-2.0.X 系列中 (本站所用的 kernel 是
2.0.33) ,取決以下兩點:
1. 檔案原來所在的磁區是否沒有被覆寫?
2. 檔案是否完全連續?
第一點我們可以與時間競賽,就是當一發現檔案誤砍時,要以最快的速度 umount
該 filesystem, 或將該 filesystem remount 成唯讀。就這次的情況而言,檔案
誤砍是在事發一個小時後才發現的,但由於該 filesystem 寫入的機會很少 (我
幾乎可確定一天才只有一次,做 backup),所以第一點算是過關了。
第二點真的是要聽天由命了,就本站所使用的 kernel, 必須要在假設「長檔案」所
佔的 block 完全連續的情況下,才有可能完全救回來! 一個 block 是 1024 bytes,
長達 8 MB 的檔案就有超過 8000 個 block。在經常讀寫的 filesystem 中,可以
想見長檔案很難完全連續,但在我們的系統中,這一點似乎又多了幾分指望。同時,
Linux ext2 如此精良的 filesystem, 能做到前 7950 多個 block 都連續,這一點
也功不可沒。
好了,以下我就講一下我的步驟。
1. mount filesystem readonly:
該檔案的位置原來是在 /var/hda/backup/home/bbs 下,我們系統的 filesystem
組態是:
root@bbs:/home/ftp/rescue# df
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/sda1 396500 312769 63250 83% /
/dev/sda3 777410 537633 199615 73% /home
/dev/hda1 199047 36927 151840 20% /var/hda
/dev/hda2 1029023 490998 485710 50% /home/ftp
因此 /var/hda 這個 filesystem 要馬上 mount 成 readonly (以下請用 root 身
份):
mount -o remount,ro /var/hda
當然也可以直接 umount 它,但有時候可能有某些 process 正在此 filesystem
下運作,您可能無法直接 umount 它。因此我選擇 mount readonly。但您也可以
用:
fuser -v -m /usr
看一下目前是那些 process 在用這個 filesystem, 然後一一砍掉,再 umount。
2. 執行
echo lsdel | debugfs /dev/hda1 | less
看一下該 filesystem 最近被砍的 inode (檔案) 有那些 (為什麼是 /dev/hda1?
請見上頭的 df 列表)? 在這裏要說一下,在 UNIX like 的系統中,所有的檔案都
有一個 inode 指向它, inode 中記錄了檔案的重要資訊,如大小、時間、屬性等
等。就我們的系統而言,其列示如下:
debugfs: 92 deleted inodes found.
Inode Owner Mode Size Blocks Time deleted
.................................................................
29771 0 100644 1255337 14/ 14 Sat Jan 30 22:37:10 1999
29772 0 100644 5161017 14/ 14 Sat Jan 30 22:37:10 1999
29773 0 100644 8220922 14/ 14 Sat Jan 30 22:37:10 1999
29774 0 100644 5431 6/ 6 Sat Jan 30 22:37:10 1999
請注意! inode 裏頭不會記錄檔案的檔名,檔名是記錄在該檔案所在的目錄的
data block 中,故在此我們見不到。因此,我們必須要在檔案大小、被砍時間
等資訊中判斷出要救回的檔案是那一個。在此,我們要救回 29773 這個 inode。
3. 執行
echo "stat <29773>" | debugfs /dev/hda1
列出該 inode 的所有資訊,如下:
debugfs: stat <29773>
Inode: 29773 Type: regular Mode: 0644 Flags: 0x0 Version: 1
User: 0 Group: 0 Size: 8220922
File ACL: 0 Directory ACL: 0
Links: 0 Blockcount: 16124
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x36b31916 -- Sat Jan 30 22:37:10 1999
atime: 0x36aebee4 -- Wed Jan 27 15:23:16 1999
mtime: 0x36adec25 -- Wed Jan 27 00:24:05 1999
dtime: 0x36b31916 -- Sat Jan 30 22:37:10 1999
BLOCKS:
123134 123136 123137 123138 123140 131404 131405 131406 131407 131408 131409 131
410 131411 131668
TOTAL: 14
現在的重點是,必須將該 inode 所指的檔案,所指的 block 全部找回來。在這裏,
列出的資訊顯示只有 14 個 block? 不對啊! 應該要有 8000 多個 block 才對啊!
在這裏要談一下 UNIX like filesystem 的「奧密」了。上頭所列的前 12 個 block
是真正指到檔案資料的 block, 稱之為 direct block 。第 13 個稱為第一階
indirect block, 第 14 個稱為第二階 indirect block 。什麼意思? 該檔的資料
所在的 block 位置如下:
123134
123136
123137
123138
......
131409
131410
131411 =========> 131412
131413
131414 (第一階,共 256 個)
......
131667
131668 =========> 131669 ==========> 131670
131671
131672 (共 256 個)
......
131925
131926 ==========> 131927
131928
131929 (共 256 個)
......
132182
132183 ==========> 132184
132185 (共 256 個)
......
各位明白嗎? 第 13 個 (131411) 與第 14 個 block 其實不是 data, 而是 index,
它指出接下來的 block 的位置。由於一個 block 的大小是 1024 bytes, 一個 int
在 32 位元系統中是 4 bytes, 故一個 block 可以記錄 256 筆資料。以 131411
block 為例,它所記錄的資料即為 (在檔案未砍前):
131412 131413 131414 .... 131667 (共 256 筆)
而這 256 個 block 就真正記錄了檔案資料,所以我們稱為第一階。同理,第二階
就有兩個層 index, 以 131668 來說,它可能記錄了:
131669 131926 132182 .... (最多有 256 筆)
而 131669 的 block 記錄為:
131670 131671 131672 .... 131925 (共 256 筆)
而這 256 個 block 才是真正儲存檔案資料的。而我們要的,就是這些真正儲存檔
案資料的 block 。
理論上,我們只要將這些 index block 的內容全部讀出來,然後照這些 index 把
所有的 block 全部讀到手,就能 100% 救回檔案 (假設這些 block 全部沒有被新
檔案覆寫的話)。工程很大,但是可行。不幸的是,在 kernel-2.0.33, 其設計是,
如果該檔案被砍了,則這些 index block 全部會規零,因此我所讀到的是
0 0 0 0 0 ..... (共 256 筆)
哇! 沒辦法知道這些 data block 真正所在的位置。所以,在此我們做了一個很大
的假設: 整個檔案所在的 block 是連續的! 也就是我上頭的例子。這也就是為什
麼說,只有連續 block (是指後頭的 indirect block) 的檔案才能完整救回,而
這一點就要聽天由命了。
4. 好了,現在我們只好假設所有的檔案處於連續的 block 上,現在請用
http://archie.ncu.edu.tw
去找這個工具: fsgrab-1.2.tar.gz, 並將它安裝起來。因為步驟很簡單,故在此
我就不多談。我們要用它將所需的 block 全部抓出來。它的用法如下:
fsgrab -c count -s skip device
其中 count 是只要 (連續) 讀幾個, skip 是指要從第幾個開始讀,例如我要從
131670 開始連續讀 256 個,就這樣下指令:
fsgrab -c 256 -s 131670 /dev/hda1 > recover
現在我們就開始救檔案吧! 以上頭的資料,我們必須用以下的指令來救:
(注意到頭開的 12 個 block 並沒有完全連續!!!)
fsgrab -c 1 -s 123134 /dev/hda1 > recover
fsgrab -c 3 -s 123136 /dev/hda1 >> recover
fsgrab -c 1 -s 123140 /dev/hda1 >> recover
fsgrab -c 7 -s 131404 /dev/hda1 >> recover
這是開頭的 12 個 block, 對於第一階 indirect, 就資料來看好像是連續的 :-))
fsgrab -c 256 -s 131412 /dev/hda1 >> recover
注意要跳過 131411, 因為它是 index block。對於第二階 indirect, 我們 *假設*
它們都是連續的:
fsgrab -c 256 -s 131670 /dev/hda1 >> recover
fsgrab -c 256 -s 131927 /dev/hda1 >> recover
fsgrab -c 256 -s 132184 /dev/hda1 >> recover
............................................
要一直做,直到 recover 的大小超過我們所要救回的檔案大小 (8220922) 為止。
要注意在這裏我們已很小心地跳過那些 index block (如 131668, 131669, 131926,
132183, ....) 了。
5. 最後一步,就是把檔案「剪」出來,並看看我們救回多少了。在這裏我們可以用
split 這個工具,假設我們重覆上述步驟,弄出來的 recover 檔大小為 8294400,
而我們要的大小是 8220922, 那就這樣下指令:
split -b 8220922 recover rec
則會做出兩個檔,一個是 recaa, 大小是 8220922, 另一個是 recab 則是剩下的大
小,後者是垃圾,扔了即可。現在我們可以檢查這個檔案是不是「完整」的那個被
誤砍的檔案了。由於我們的那個檔案是 .tar.gz 的格式,於是我們這個方法來檢查:
mv recaa recaa.tar.gz
zcat recaa.tar.gz > recaa.tar
如果沒有錯誤訊息,那表示成功了! 完全救回來了。但不幸的是,我們沒有成功,
將弄出的 recaa.tar 改名再 gzip 之後,與原來的 recaa.tar.gz 比一下大小,發
現少了 1%, 表示說該檔原來所在的 block 中最後有 1% 是不連續的 (或者被新寫
入的檔案覆寫了),但這已是不幸中的大幸了。
=============================================================================
對於在 undelete 時 *必需* 假設所有 block 連續的問題,那份 HOWTO 文件說 Linus
與其他 kernel 設計者正著手研究,看能否克服這個困難,也就是在檔案砍掉時,不要
將 index block 規零。我剛剛試一下 kenrel-2.2.0 的環境,發現已做到了!! 以下是
一個已砍的檔案的 inode data (由 debugfs 所讀出):
debugfs: Inode: 36154 Type: regular Mode: 0600 Flags: 0x0 Version: 1
User: 0 Group: 0 Size: 2165945
File ACL: 0 Directory ACL: 0
Links: 0 Blockcount: 4252
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x36b54c3b -- Mon Feb 1 14:39:55 1999
atime: 0x36b54c30 -- Mon Feb 1 14:39:44 1999
mtime: 0x36b54c30 -- Mon Feb 1 14:39:44 1999
dtime: 0x36b54c3b -- Mon Feb 1 14:39:55 1999
BLOCKS:
147740 147741 147742 147743 147744 147745 147746 147747 147748 147769 147770 157
642 157643 157644 157645 157646 157647 157648 157649 157650 157651 157652 157653
157654 157655 157656 157657 157658 157659 157660 157661 157662 157663 157664 15
7665 157666 157667 157668 157669 157670 157671 157672 157673 157674 157675 15767
6 157677 157678 157679 157680 157681 157682 157683 157684 157685 157686 157687 1
............................................................................
9745 159746 159747 159748 159749 159750 159751 159752 159753 159754 159755 15975
6
TOTAL: 2126
真是太完美了!! 這意味著在 kernel-2.2.X 的環境下,我們不必假設所有的 block 都
連續,而且可以百分之百找回所有砍掉的 block! 因此上述的第二個風險就不存在了。
以上資料,謹供參考。
參考文件: Ext2fs-Undeletion Mini HOWTO
1. 引导块
位于文件卷最开始的第一扇区,这512字节是文件系统的引导代码,为根文件系统所特有,其他文件系统这512字节为空。
2. 超级块
位于文件系统第二扇区,紧跟引导块之后,用于描述本文件系统的结构。如i节点长度、文件系统大小等,其结构存放于/usr/include/sys/filsys.h中,其结构如下:
struct filsys
{
ushort s_isize; /*磁盘索引节点区所占用的数据块数*/
daddr_t s_fsize; /*整个文件系统的数据块数*/
short s_nfree; /*在空闲块登录表中当前登记的空闲块数目*/
daddr_t s_free[NICFREE]; /*空闲块登记表*/
short s_ninode; /*空闲索引节点数*/
ino_t s_inode[NICINOD]; /*空闲节点登记表*/
char s_flock; /*加锁标志位*/
char s_ilock; /*节点加锁标志位*/
char s_fmod; /*超级块修改标志*/
char s_ronly; /*文件系统只读标志*/
time_t s_time; /*超级块上次修改的时间*/
short s_dinfo[4]; /*设备信息*/
daddr_t s_tfree; /*空闲块总数*/
ino_t s_tinode; /*空闲节点总数*/
char s_fname[6]; /*文件系统名称*/
char s_fpack[6];
long s_fill[13]; /*填空位*/
long s_magic; /*指示文件系统的幻数*/
long s_type; /*新文件系统类型*/
};
3. i节点表
i节点表存放在超级块之后,其长度是由超级块中的s_isize字段决定的,其作用是用来描述文件的属性、长度、属主、属组、数据块表等,其数据结构在/usr/include/sys/ino.h中,如下:
struct dinode
{
ushort di_mode;
short di_nlink;
ushort di_uid;
ushort di_gid;
off_t di_size;
char di_addr[40];
time_t di_atime;
time_t di_mtime;
time_t di_ctime;
};
4. 目录结构
UNIX所有文件均存放于目录中,目录本身也是一个文件。目录存放文件的机制如下:首先,目录文件本身也象普通文件一样,占用一个索引节点,其次,由这个索引节点得到目录内容的存放位置,再次,从其内容中取出一个个的文件名和它对应的节点号,从而访问一个文件。目录结构如下:
索引节点号(2字节) .(本目录)(14字节)
索引节点号(2字节) ..(父目录)(14字节)
索引节点号(2字节) 文件名(14字节)
索引节点号(2字节) 文件名(14字节)
索引节点号(2字节) 文件名(14字节)
由上可知文件名是依靠目录来描述的,文件的内容和其他信息则由索引节点来描述。
二、文件的删除过程
UNIX下删除一个文件的过程很简单,那就是释放索引节点表和文件占用的数据块,清空文件占用的索引节点,但不清除文件内容。但删除文件与删除目录的处理不尽相同,不同命令删除文件的过程也不相同。
1. 删除一个文件
UNIX 删除一个文件的具体步骤是:根据文件i节点的地址表逐一释放文件占用的磁盘数据块,然后清空相应的节点,最后释放i节点。
2. 删除一个目录
删除一个目录的过程:首先逐一删除目录里的所有文件,然后删除目录。目录本身也是一个文件,故删除方法与删除文件一致。
3. 几种不同的删除命令
.rm 命令
一般删除命令,删除过程上述已说明。
.mv命令
格式:mv 文件1 文件2
处理过程是将文件2的数据块释放,然后将文件1的名称改为文件2,再释放文件2所占的i节点。
. > 命令
格式:>文件名
若产生一个新文件,>命令仅仅申请一个i节点,而不写入任何文件内容;若清空一个已经存在的文件,则释放文件所占的数据块,并将文件长度清零。
三、被删文件的恢复策略
要恢复被删除的文件,只能根据删除后留下的东西去做文章。文件被删除后留下了什么呢?由上述分析可知:其一、留下了文件的内容;其二、留下了“现场”。文件的恢复策略只能从这两个方面来分析。以下谈几种恢复策略。
1.根据磁盘现场进行恢复
如果文件被删除,现场未被破坏(即文件被删除后硬盘未发生过写操作),而且假定只删除了一个文件,那么可根据系统的分配算法进行恢复。因为系统建立一个文件时,必定根据某一特定的分配算法决定文件占用的数据块位置。而当该文件被删除后,它所占用的数据块被释放,又回到系统的分配表中,这时如果重新建立一个文件,系统根据原来的分配算法分配出的数据块必定跟该文件原来占用的数据块一致,而且我们知道,UNIX文件最后一数据块尾部多出的字节是全部置0的,据此只要调用系统的数据分配算法,在系统中一块块的申请数据块,因为UNIX文件最后一个数据块尾部多出的字节全部为0,所以,只要发现一个分配出的数据块中尾部全为0,即可认为文件结束,由此可确定文件长度和内容,进而实现恢复。方法如下:
⑴申请一个索引节点,即向系统申请创建一个新文件名而不写入任何内容。如:#>/tmp/xx
⑵调用系统分配数据块算法getnextfreeblock()得到一个数据块号,记入某一地址表变量中。
⑶读出这个数据块,判断其尾部是否全部连续为0,若不是,则回到(2),若是,则进行(4)。
⑷首先用系统函数fstat得到/tmp/xx的i节点号,然后将(2)步所得的地址表写入索引节点的地址表中(注意间址问题),并根据数据块个数和最后一块中有效数据长度计算出文件大小,写入i节点的di_size字段。
⑸回写系统的索引节点表即可。
需要说明的是,第一,系统分配数据块的算法因不同的UNIX版本而不同;第二,有的UNIX如SCO UNIX 5.0版,其空闲数据块的分配和回收是使用一种动态链表的数据结构来实现的,它们的文件恢复更加容易,只要在空闲链表中的表尾去寻找即可,笔者另行描述。
2. 根据内容恢复。
若现场已被破坏,即硬盘发生过写操作,那么只好根据内容来恢复。而且,由于UNIX是一个多进程、多用户系统,它每一次开关机或硬件、通讯故障等都会记录系统日志、.sh_history等,硬盘现场被破坏可能性极大。因此讨论按内容恢复的方法具有更大的实用价值。笔者经过实际探索得出下列四种恢复策略供参考。
⑴关键字搜索法
如果知道被删除的文件内容中若干字节的内容,而且该文件长度又不超过一个磁盘块,那么可以在整个文件系统中搜索这一字节串,得出一个文件所在的数据块,将它们的块号填入一个i节点,即可恢复一个文件,搜索文件系统的算法很简单,说明如下:
a. #df -k 确定文件系统的设备文件名(如/dev/root)
b.用下述函数搜索,若成功,返回数据块号,反之返回-1。其中fsname是文件系统的设备名,如/dev/root,comp()参数是实现搜索条件的函数。
long searchfs(char *fsname , int comp())
{
FILE *fp;
char buf[1024];
long i=0;
fp=fopen(fsname,"r");
while (!feof(fp))
{
fread(buf,1024,1,fp);
if (comp()) /* 检查是否符合搜索条件 */
return i; /* 若成功返回块号 */
i++;
}
fclose(fp);
return -1; /* 未找到符合条件的块,返回-1*/
}
⑵精确长度搜索法
如果知道被删除文件的精确长度(字节数),那么可根据一个数据块的大小,计算出文件的最后一个数据块中数据的精确长度,该数据块中其他字节必然是全0。根据这一条件,通过搜索整个文件系统,找出其中符合条件的数据块,若出现多个块符合要求,则还需要根据其他条件区分。但不管怎样,根据精确长度分析也是恢复数据的一个策略。
⑶内容关联法
如果知道文件内容中存在某种可实现的关联,例如文件的校验和,或者文件内容的某种上下文关系,那么也可通过搜索整个文件系统,通过反复尝试寻找符合关联条件的磁盘数据块,进而恢复一个文件。
⑷环境比较法
如果知道删除文件所在的文件系统的安装过程,那么,另行找一台完全相的机器,按原来完全相同的步骤安装相同版本的UNIX和相应的其他软件,可以想象,新的机器环境会与原来的环境基本相同,比较两个机器上相同文件系统的内容,可以推断出被删除文件的大致位置,至少可以大大减少查找的范围,一旦查找的范围足够小时,可以用逐个观察和尝试的方法结合其他条件恢复数据,降低恢复的难度,增加恢复的可靠性。
UNIX系统下文件系统恢复的具体实现依赖于不同操作系统和不同版本的具体文件系统结构和磁盘块分配算法。本文试图总结出一种一般性的思路和策略,限于篇幅,不能详细讨论它们的具体实现过程。
摘自:http://linux.softhouse.com.cn
Linux檔系統的反刪除方法
作為一個多用戶、多工的作業系統,Linux下的檔一旦被刪除,是難以恢復的。儘管刪除命令只是在檔節點中作刪除標記,並不真正清除檔內容,但是其他用戶和一些有寫盤動作的進程會很快覆蓋這些資料。不過,對於家庭單機使用的Linux,或者誤刪檔後及時補救,還是可以恢復的。
1.Ext2檔系統結構的簡單介紹
在Linux所用的Ext2檔系統中,檔是以塊為單位存儲的,默認情況下每個塊的大小是1K,不同的塊以塊號區分。每個檔還有一個節點,節點中包含有檔所有者,讀寫許可權,檔類型等資訊。對於一個小於12個塊的檔,在節點中直接存儲檔資料塊的塊號。如果檔大於12個塊,那麼節點在12個塊號之後存儲一個間接塊的塊號,在這個間接塊號所對應的塊中,存儲有256個檔資料塊的塊號(Ext2fs中每個塊號佔用4位元組,這樣一個塊中所能存儲的塊號就是 1024/4=256)。如果有更大的檔,那麼還會在節點中出現二級間接塊和三級間接塊。
2。恢復被誤刪檔的方法
大多數Linux發行版都提供一個debugfs工具,可以用來對Ext2檔系統進行編輯操作。不過在使用這個工具之前,還有一些工作要做。
首先以唯讀方式重新掛載被誤刪的檔所在分區。使用如下命令:(假設文件在/usr分區)
mount –r –n –o remount /usr
-r表示唯讀方式掛載;-n表示不寫入/etc/mtab,如果是恢復/etc上的檔,就加上這個參數。如果系統說xxx partion busy,可以用fuser命令查看一下是哪些進程使用這個分區上的檔:
fuser –v –m /usr
如果沒有什麼重要的進程,用以下命令停掉它們:
fuser -k –v –m /usr
然後就可以重新掛載這些檔系統了。
如果是把所有的檔統一安裝在一個大的/分區當中,可以在boot提示符下用linux single進入單用戶模式,儘量減少系統進程向硬碟寫入資料的機會,要不乾脆把硬碟掛在別的機器上。另外,恢復出來的資料不要寫到/上面,避免破壞那些有用的資料。如果機器上有dos/windows,可以寫到這些分區上面:
mount –r –n /dev/hda1 /mnt/had
然後就可以執行debugfs:(假設Linux在 /dev/hda5)
#debugfs /dev/hda5
就會出現debugfs提示符debugfs:
使用lsdel命令可以列出很多被刪除的檔的資訊:
debugfs:lsdel
debugfs: 2692 deleted inodes found.
Inode Owner Mode Size Blocks Time deleted
164821 0 100600 8192 1/ 1 Sun May 13 19:22:46 2001
…………………………………………………………………………………
36137 0 100644 4 1/ 1 Tue Apr 24 10:11:15 2001
196829 0 100644 149500 38/ 38 Mon May 27 13:52:04 2001
debugfs:
列出的檔有很多(這裏找到2692個),第一欄位是檔節點號,第二欄位是檔所有者,第三欄位是讀寫許可權,接下來是檔大小,佔用塊數,刪除時間。然後就可以根據檔大小和刪除日期判斷那些是我們需要的。比如我們要恢復節點是
196829的文件:
可以先看看檔資料狀態:
debugfs:stat <196829>
Inode: 196829 Type: regular Mode: 0644 Flags: 0x0 Version: 1
User: 0 Group: 0 Size: 149500
File ACL: 0 Directory ACL: 0
Links: 0 Blockcount: 38
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x31a9a574 -- Mon May 27 13:52:04 2001
atime: 0x31a21dd1 -- Tue May 21 20:47:29 2001
mtime: 0x313bf4d7 -- Tue Mar 5 08:01:27 2001
dtime: 0x31a9a574 -- Mon May 27 13:52:04 2001
BLOCKS:
594810 594811 594814 594815 594816 594817
………………………………….
TOTAL: 38
然後就可以用dump指令恢復檔:
debugfs:dump <196829> /mnt/hda/01.sav
這樣就把檔恢復出來了。退出debugfs:
debugfs:quit
另一種方法是手工編輯inode:
debugfs:mi <196829>
Mode [0100644]
User ID [0]
Group ID [0]
Size [149500]
Creation time [0x31a9a574]
Modification time [0x31a9a574]
Access time [0x31a21dd1]
Deletion time [0x31a9a574] 0
Link count [0] 1
Block count [38]
File flags [0x0]
Reserved1 [0]
File acl [0]
Directory acl [0]
Fragment address [0]
Fragment number [0]
Fragment size [0]
Direct Block #0 [594810]
…………………………….
Triple Indirect Block [0]
使用mi指令後每次顯示一行資訊以供編輯,其他行可以直接按回車表示確認,把deletion time改成0(未刪除),Link count改成1。改好後退出debugfs:
debugfs:quit
然後用fsck檢查/dev/hda5
fsck /dev/hda5
程式會說找到丟失的資料塊,放在lost+found裏面。這個目錄裏的檔就是我們要的東東。
Now all O.K. Good Luck.
EXT3 Recovery - Score one for the fleshlings
/var was unmountable.
I removed /var from fstab and booted the machine on a /var dir off the root so I could work on it remotely.
Here's what happened next. I fsck a variety of ways, fsck.ext3 etc.. each reported the same:
fsck /dev/ida/c0d0p7
fsck 1.27 (8-Mar-2002)
e2fsck 1.27 (8-Mar-2002)
Group descriptors look bad... trying backup blocks...
fsck.ext2: Invalid argument while checking ext3 journal for /var
Tried downgrading to ext2 to bypass the hosed journal issues:
tune2fs -O ^has_journal /dev/ida/c0d0p7
tune2fs 1.27 (8-Mar-2002)
tune2fs: Invalid argument while reading journal inode
No good. Tried mounting as ext2 read only:
mount -t ext2 /dev/ida/c0d0p7 /mnt -o ro
mount: wrong fs type, bad option, bad superblock on /dev/ida/c0d0p7,
or too many mounted file systems
Nada. Tried some more stuff... tune2fs, and debugfs to try to fix / disable the journal, then decided I'd better back up the partition... should have done that first! ;P
e2fsck -c /dev/ida/c0d0p7
e2fsck 1.27 (8-Mar-2002)
Group descriptors look bad... trying backup blocks...
e2fsck: Invalid argument while checking ext3 journal for /var
[root@adrock init.d]# tune2fs -j /dev/ida/c0d0p7
tune2fs 1.27 (8-Mar-2002)
The filesystem already has a journal.
[root@adrock init.d]# debugfs -w /dev/ida/c0d0p7
debugfs 1.27 (8-Mar-2002)
/dev/ida/c0d0p7: Can't read an inode bitmap while reading inode bitmap
debugfs: quit
[root@adrock init.d]# dd if=/dev/ida/c0d0p7 of=/big/var.bak.dd
530368+0 records in
Still hosed, but now I have a backup of the burnination. And now for the FIX!!!
mke2fs -S /dev/ida/c0d0p7
mke2fs 1.27 (8-Mar-2002)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
66528 inodes, 265184 blocks
13259 blocks (5.00%) reserved for the super user
First data block=1
33 block groups
8192 blocks per group, 8192 fragments per group
2016 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185
Writing superblocks and filesystem accounting information: done
That did it! mke2fs re-wrote all of the superblocks and group descriptors and I was able to mount in RO mode and copy off the data. After that I was able to fsck and remount the original parition with no problems!
I found some great info on the RedHat ext3 mailing list archive which led me to this fix. Big thanks to the guys on that list!
以下兩頁的說明, 一頁說有支援 ext3, 一頁說沒有 :(
DEBUGFS、debugfs(8) - Linux man page
本文最新網址位於套件管理工具比較
比較一下現在市面上幾種套件管理工具
(debian - apt , gentoo - emerge , freebsd - prots)
深入內容中有 emerge, apt, ports 的語法比較(也可以說是語法教學吧)
以下轉載自: Gentoo/Debian/FreeBSD套件管理memo
以關鍵字搜尋軟體
Gentoo: emerge -s
輸出會有這個 pkg 的簡介 , 關鍵字都可以用正規表示式
Debian: apt-cache search
FreeBSD: make search name=
ports_glob
安裝軟體
Gentoo: emerge
Debian: apt-get install
FreeBSD: portinstall
移除軟體
Gentoo: emerge unmerge
Debian: apt-get remove
FreeBSD: pkg_deinstall
升級單一軟體
Gentoo: emerge -u
Debian: ?
FreeBSD: portupgrade
察看升級全系統會動到哪些套件:
Gentoo: emerge -puDv world
Debian: apt-get -u dist-upgrade
FreeBSD: portupgrade -arnv
升級全系統
Gentoo: emerge -u --deep world
Debian: apt-get dist-upgrade
FreeBSD: make world ; portupgrade -ar
查詢系統裝了哪些軟體
Gentoo: emerge -pe world 或 qpkg -I -v
Debian: dpkg --get-selections
FreeBSD: pkg_info
查詢某檔案屬於哪個軟體
Gentoo: qpkg -f
(need gentoolkit)
Debian: dpkg -S
FreeBSD: pkg_info -W
查詢某個套件安裝了什麼檔案
Gentoo: qpkg -l
Debian: ?
FreeBSD: pkg_info -L
查詢有沒有裝這個關鍵字的套件
Gentoo: qpkg -I | grep
Debian: dpkg -qa | grep
FreeBSD: pkg_info | grep
找哪些 pkg "簡介" 裡含有你要找的關鍵字:
Gentoo: emerge -S <關鍵字>
輸出方式和前者一樣, 關鍵字都可以用正規表示式
Debian: apt-cache search
FreeBSD: make search key=
不管相依性強制移除某套件
Gentoo: emerge -C
Debian:
FreeBSD: pkg_delete -f
全系統重新編譯
Gentoo: emerge -e world
Debian: ?
FreeBSD: make world ; portupgrade -arf
========
補充:
qpkg -f
ps: emerge gentoolkit first.
--
gentoo 裡:
查詢某個套件安裝了什麼檔案:
qpkg -l
查詢有沒有裝這個關鍵字的套件:
qpkg -I
不管相依性強制移除某套件:
emerge -C
--
仔細看一下 man emerge
要找一個 pkg 的 "名稱":
emerge -s <關鍵字>
輸出會有這個 pkg 的簡介
找哪些 pkg "簡介" 裡含有你要找的關鍵字:
emerge -S <關鍵字>
輸出方式和前者一樣
更厲害的是上面的關鍵字都可以用正規表示式!!
--
emerge -f
好處在於當你emerge 兩個package以上的時候,可以先把source給抓回來,不過需要再emerge
emerge -p
看要裝些什麼東西,
小弟認為這兩個指令對撥接使用者很重要,尤其 -f .一來可以大略知道下載時間,二來可以隨時中斷,然後在續傳(感謝偉大的wget)
--
升級單一軟體
Gentoo: emerge -u
Debian: apt-get install
FreeBSD: portupgrade
查詢某個套件安裝了什麼檔案
Gentoo: qpkg -l
credit to paar@gentoo.org.tw
Debian: dpkg -L
FreeBSD: pkg_info -L
全系統重新編譯
Gentoo: emerge -e world
Debian: apt-get update;apt-get upgrade
FreeBSD: make world ; portupgrade -arf
HOW TO OPTIMIZE AND ACCELERATE YOUR SYSTEM
讓你的 Gentoo 加速~ 要如何最佳化自己的系統呢?..
從以下幾點來做. 深入的就看看 這篇文章 吧~
0. How to make tests without being in danger
1. Optimization of the init scripts
2. Using rc-update
3. Cflags and ldflags
4. Using hdparm
5. Should you.. prelink?
6. Managing the Swap
7. Ccache
8. Distcc
9. USE's
10. Modifying ebuilds and injecting packages
11. Halt vs Suspend
12. Xdelta - Deltup
13. NPTL
14. GCC
15. Filesystems [data safety vs speed]
16. i/o and tasks schedulers
17. Useful Scripts
以下轉載自: HOW TO OPTIMIZE AND ACCELERATE YOUR SYSTEM
also known as how to fly with gentoo
This is guide is a sum of a lot of posts here in the forum and some investigations i have done in my boxes by trying out several programs and options. Some of them are completely safe, but some other could damage your system. Please make backups of your important data, try this guide in testing boxes, and then move the optimizations to the production boxes.
This improvements will obviously have a greater effect on a old computer, if you have a very good computer this will have a minor impact, as your system should already be pretty fast Wink
INDEX
0. How to make tests without being in danger
1. Optimization of the init scripts
2. Using rc-update
3. Cflags and ldflags
4. Using hdparm
5. Should you.. prelink?
6. Managing the Swap
7. Ccache
8. Distcc
9. USE's
10. Modifying ebuilds and injecting packages
11. Halt vs Suspend
12. Xdelta - Deltup
13. NPTL
14. GCC
15. Filesystems [data safety vs speed]
16. i/o and tasks schedulers
17. Useful Scripts
0. How to make tests without being in danger
To test new ebuilds and try new configurations I did an instalation inside a chroot to be completely safe. There's is a guide HERE to make a similar thing, and be able to test this howto without damaging your system. You could also use vmware or uml, but this seems a fastest way.
Once I did the chroot install, I made a compressed image, so that everytime I broke the sub-system with my tests i can extract it and go on testing with a new installed system (and my system keeps clean).
1. Optimization of the init scripts
Some of the operations performed when you boot the system are not always needed. Let's modify the scripts so that we only do them if they are really needed.
/etc/init.d/modules
change:
Code:
ebegin "Calculating module dependencies"
/sbin/modules-update &>/dev/null
eend $? "Failed to calculate dependencies"
for:
Code:
if [ /etc/modules.d -nt /etc/modules.conf ]
then
ebegin "Calculating module dependencies"
/sbin/modules-update &>/dev/null
eend $? "Failed to calculate dependencies"
else
einfo "Module dependencies are up-to-date"
fi
Doing this, modules-update will only run if it愀 really needed because you made changes in the system.
/etc/init.d/localmount
change:
Code:
mount -at nocoda,nonfs,noproc,noncpfs,nosmbfs,noshm >/dev/null
for:
Code:
mount -aFt nocoda,nonfs,noproc,noncpfs,nosmbfs,noshm >/dev/null
The will start all the local mounts at the same moment, not one after the other.
/etc/init.d/bootmisc
change:
Code:
if [ -x /sbin/env-update.sh ]
then
ebegin "Updating environment"
/sbin/env-update.sh >/dev/null
eend 0
fi
for:
Code:
if [ -x /sbin/env-update.sh ]
then
if [ /etc/env.d -nt /etc/profile.env ]
then
ebegin "Updating environment"
/sbin/env-update.sh >/dev/null
eend 0
else
einfo "Environment up-to-date"
fi
fi
Doing this, env-update will only run if it愀 really needed because you made changes in the system.
/etc/conf.d/rc
change:
Code:
RC_PARALLEL_STARTUP="no"
for:
Code:
RC_PARALLEL_STARTUP="yes"
This will start all the services at the same moment, not one after the other.
note: could some devel explain if this tweaks are dangeorus, and if not why they are not in portage by default?
2. Using rc-update
Managing the runlevels is very easy thanks to rc-update, that makes easy this job:
to see how we have currently configured the boot runlevels:
Code:
# rc-update show
to remove a service from the system start:
Code:
# rc-update del aplicacion runlevel
note: change runlevel for boot or default (you could also create more), if you omit the runlevel it will search in all of them and remove the service.
to add an application:
Code:
# rc-update add application runlevel
I have some service in the boot runlevel and some in the default runlevel, please note that some services need to be started after some other (this means that some services depends on some other.
You can check the depends editing the /etc/init.d/service file and checking the first lines, where the depends are declared. For example, if you want to start sshd, you will need the net services started before.
I have recently created a new runlevel (battery) where i added all i want to have running when i don愒 have AC. Then, with acpid's help I configured the runlevel so that when i unplug the AC, it changes to battery runlevel, and the when i plug it again it gets back to default runlevel. This way, when I switch to the battery level i use speedfreq, hdparm and iwconfig to reduce the power consumption of the hardisk, the wireless card and the processor.
You can check the actual runlevel using rc-status:
Code:
# rc-status
Runlevel: battery
acpid started
alsasound started
domainname started
gpm started
hdparm.battery started
local started
metalog started
speedfreq.battery started
vixie-cron started
wireless.baterry started
more information about the RC- HERE.
For those who boot directly into X (xdm, gdm, kdm,..) i have read that you can put xdm and it's dependencies in boot runlevel, so that it will load X while loading the rest of services in the background. If someone have this running please comment so that the rest can use it.
3. cflags and ldflags
CFLAGS (you can set them at /etc/make.conf) are parameters we pass to gcc when we compile a package when emerging it. You can be more or less risky here, in THIS webpage and THIS one there is a lot of info on recommended configurations for CFLAGS. My CFLAGS for my pentium4 box are the following:
Code:
CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium4 -mcpu=pentium4 -O3 -pipe -fforce-addr -falign-functions=4 -fprefetch-loop-arrays -fomit-frame-pointer"
note: cflags changed a little bit in gcc 3.4.X and -mcpu is deprecated, you should use -mtune instead. Moreover, pentium-m is accepted for centrino laptops. The CFLAGS of my centrino laptop are the following:
Code:
CFLAGS="-O3 -march=pentium-m -mtune=pentium-m -pipe -ftracer -fomit-frame-pointer -ffast-math -momit-leaf-frame-pointers"
As for the CXXFLAGS, -fvisibility-inlines-hidden has been reported as a good flag to improve the C++ compiles (thx teutzz).
Frepo has also been reported as a good cxxflag, but it does not perform very well on my system.
The ldflags are also interesting, they are discussed HERE and HERE. Ldflags are optimizations for the dinamyc loader (ld), so it's more or less the same way prelink would go. I am using them already and didn't have any problem when emerging new packages:
Code:
LDFLAGS="-Wl,-O1 -Wl,--enable-new-dtags -Wl,--sort-common -s"
Something more "stable" would be
Code:
LDFLAGS="-Wl,-O1"
note: those in the ldflags are "L", not "1" (in the -W)
note: some users reported errors using ldflags, if you have problems compiling a package try to remove them (and post ldflags/package in this thread).
NOTE: Cflags and Ldflags are and will be always a subject in which everybody has his opinion. The best way is to test them yourself, do somebenchmarks, and keep the flags you find optimal for your system. Also check the differents posts in the forums talking about this so that you can get an idea. A useful program to determine what cflags you should use, is ACOVEA (already in portage), which is a benchmarking tool that will do several tests on your machine (the standard test will run for more than 15 hours) to help you pick the best cflags for your machine. See THIS thread for acovea scripts and results.
4. Using hdparm
Another important application is hdparm. It allows us to configure our hard disk parameters, so get the maximum performance:
Code:
# emerge hdparm
# rc-update add hdparm default
See /etc/conf.d/hdparm
see actual configuration:
Code:
# hdparm -i /dev/hda
testing the speed:
Code:
# hdparm -Tt /dev/hda
In my computer I modifified /etc/conf.d/hdparm to get the maximum of my hard disk:
Code:
hda_args="-d1 -X69 -c1"
cdrom0_args="-d1"
If you need more information the man page is pretty good
Code:
# man hdparm
Also check THIS for a little tutorial.
5. Should you.. prelink?
Prelink is a powerful application, it allows us to pre-link the libraries needed for a binary before using it. So instead of looking for which libraries the binary will need when we launch it, prelink will modify the binary addind a little descriptions of the libs it nees to run. This get rid of the search for shared libraries everytime we launch the binary, so it makes it faster.
Important: Everytime that you upgrade the libraries that are needed for the binaries, (for example glibc) you have to re-run prelink on the system.
This is a little optimization that we will thank when launching big applications like KDE (moreover, if you prelink your system KDE will not need to launch kdeinit, so it will also run faster). The little binaries are already pretty fast, so will not appreciate the difference.
Requirements: it is a must to have compiled the binaries with binutils-2.13.90.0.xx and gcc-3.2 or higher, and also have installed glibc-2.3.1-r2 or higher. The size of the binaries will be bigger with prelink, and to run the process you need enough free space on the hard disk.
Way to go:
Code:
# emerge prelink
Find config file at /etc/prelink.conf
Code:
# prelink -afmR
This is the common use of prelink, that will prelink ALL the binaries, and also will look if the binaries were already prelinked, and prelink them again if needed.
It is possible that you get some errors when running prelink, because some binaries can not be prelinked (the ones compressed with upx, for example).
More information HERE, and/or man prelink.
6. Managing the swap
In this section I just wanted to mention some things that can help us.
First of all, if you have two harddisks it is better to put the swap partition on the second disk (having the root partition in the first one) as this will improve the read/write times.
Also you should NOT use a file as swap. I tried it once in an old computer, deleted the swap partition and set a file as ./swap of 256 MB.� and modified fstab. This method is slower, as it has to find the file, open the file, find were it was writting to it, writte to it, save, and close the
file. With a partition in the disc this process is pretty much faster.
Another concept to know about is swappiness (kernel 2.6+). When an application needs memory and the RAM is full, there are two options: or the RAM gets empties a little bit cleaning out old used memory, or swap memory gets used (slower than ram). In the new kernels, you can set a variable to define if the kernel should empty some ram or use the swap partition.
/etc/sysctl.conf
Code:
vm.swappiness = 40
This value can be between 0 and 100. Close to 0 will mean that the kernel should empty some ram, and a higher value close to 100 will tell the kernel to use the swap memory more often.
The default value is 60. I set this to 25 in my laptop, so that i can reduce the disk access. You can use 惠ree -m� to see the stats of your memory useage.
7. Ccache
ccache is an application (included en portage and on by default when emerging (if you emerge ccache)) that acts as a cache for the compiler.
With this little prog we will be able to compile in a faster way when compiling packages, specially with the big make's (you could think that using a cache when compiling has no use, but it speeds up some instructions like the make clean)
Just emerge it and set the default cache size (read the einfo after the emerge), and it will be on by default. You can check it with:
Code:
# emerge info | grep ccache
ccache version 2.3 [enabled]
You can check the ccache stats by doing:
Code:
# ccache -s
8. Distcc
distcc is an application that will make our life easier when installing gentoo in several computers, or if our computer is very slow but have another fast computer. It can be combined with ccache, optimizing the compiling time. I won't explaint this
feature a lot, because it's not used by everyone. Just that you know about it, because you can use cross-compiling with different computers with different processors, they will just share the compiling tasks.
More information HERE.
9. USE's
The USE flags are a useful tool that gentoo provides us with to configure our packages as we want them.
For example, imagine that you want to compile apache:
Code:
# emerge -pv apache
[ebuild N ] net-www/apache-2.0.50 -debug -doc -ipv6 +ssl 6,197 kB
The (+/-) options that appear after the name of the program we are going to install (-v flag) are the USE vars we can use to configure the package we are installing. If, for example, we don't want our apache to use ssl, we can do this:
Code:
# USE="-ssl" emerge -pv apache
[ebuild N ] net-www/apache-2.0.50 -debug -doc -ipv6 -ssl 6,197 kB
We can see that ssl is now off, and apache won't be compiled with ssl support.
In this example we set the USE var directly on the propmt, but this is not the correct way to do it if you want the system to remember the USE flags everytime you compile that package. You can set your USE flags in the /etc/make.conf file, or also use /etc/portage/package.use to set them for
individual packages.
It is the same for the "x86" flag (to tell portage to use the latest version available of every package), it's not recommended to just set the flag on the prompt, you should set it on /etc/make.conf to use it for all the packages, or set it individually:
Code:
# echo "app-editors/nano ~x86" >> /etc/portage/package.keywords
It is important to take a look at the USE flags of the packages before installing them, so that we can turn off features we won't be needing saving space and sometimes dependencies.
For example, if we want to emerge the console irc client BitchX, portage want to install xmms, X, and some other dependencies that could be useless for some of us. Setting -xxms and -X for xmms in the /etc/portage/package.use will allow us to install BitchX without the xmms and X support, and we won't need to install all those packages.
You can see that this is a powerful tool to use when emerging, it gives us a lot of control of how the packages will be installed in our system.
You have a little description of the USE flags in /usr/portage/profiles/use.desc
10. Modifying ebuilds and injecting packages
Always keep a backup of your files before modifying them (also note that emerge sync will fix if you mess an ebuild).
獨hat's injecting a package and what's the use of it?
Remember that time when you wanted to install package X, and as a dependency portage asked to install package Y? For example, a lot of users manage the kernel manually instead of using portage to do it (gentoo-sources, gentoo-dev-sources, vanilla-sources, and so on). Then, when you emerge some package that needs the kernel-sources (like alsa, or ipw2X00) installed portage will try to install some kernel-sources. Why would you do that if you already have your kernel at /usr/src?
note: injecting has been deprecated, now you should use package.provided and virtuals as explained
- using package.provided:
package.provided tells portage that a package is installed (even if it's not)
You can use this file to put all the packages you want to tell portage you installed by hand.
Code:
echo "sys-kernel/ck-sources" >> /etc/portage/profile/package.provided
package.provided doesn't affect virtuals, virtuals are used to tell portage what packages should install for a given category:
For example, you could tell portage that you want to satisfy x11 with xorg, and not xfree anymore (which is not a valid example anymore, but it is useful to understand the use of it)
Code:
echo "virtual/x11 x11-base/xorg-x11" >> /etc/portage/profile/virtuals
more information on this and /etc/portage management -> man portage
11. Halt vs Suspend
Have you never asked yourself why you shutdown you computer, when you can suspend it to ram or disk?
If you suspend to ram, it has the handicap that it will still need AC input in order to keep the system alive. But suspending to disk is very useful (specially for laptops), because the laptop will "shutdown", but we will keep our sesion.
Doing it this way we avoid to boot all the system services everytime (it not an instant recuperation from the "sleep", but seems faster).
I have used swsusp2 in my laptop and works fine, but you have to patch the kernel sources. You can find info in THIS post on how to do this. Try it and you won't regret.
12. Xdelta - Deltup
In THIS post Deltup is discussed, because a new version is available. The point is that everytime portage needs to download a file, deltup will look for an older version of the file (/usr/portage/distfiles) and try to download only the
difference between the two files, and create the new file on-the-fly.
This can be a big improvement for all those 56k users who keep their /usr/portage/distfiles in order to only download patches when new "revisions" are released, because this can lower the mb to download everytime they want to emerge new versions of the installed packages.
13. Native POSIX Thread Library
This library, know as NPTL, can improve our system, because it's up to 4 times faster than the standard LinuxThreads when creating new threads. You *should* use 2.6 linux headers, and a new version of glibc and gcc (~x86). To use ntpl you just have to recompile glibc with the USE flag
"nptl" turned on.
note: in order to use nptl you need gcc 3.x or higher installed.
HERE you can get more information and benchmarkings.
14. GCC
GCC is very important, specially in a distro like gentoo in which the users look to optimize their system by compiling theirselves the packages they install. Using an actual version of gcc has some advantages, because all the code we create when compiling will be more optimized (from version 3.4.x you can already use the -march=pentium-m for the centrino
processors).
To install the latest gcc, just emerge gcc with ~x86 turned on (rmember to change your profile also):
Code:
# echo "sys-devel/gcc ~x86" >> /etc/portage/package.keywords
# emerge -u gcc
15. Filesystems [data safety vs speed]
After trying out some filesystems, i use reiser4 because it's the fastest filesystem available. I think that it is very useful to use a fast filesystem, but you have to keep backups of your data just in case you have corruption issues.
Also point that, after using ext2, ext3, reiserfs, xfs, reiserfs and som other encripted filesystems i have never had corruption issues with my data. Just keep backups of your data and you will be all set.
Note that you need a version of the kernel with the reiser4 patches, so it will have to be a development patched release.
To convert your / partition to reiser4 you will need a livecd with reiser4 support like THIS one, and install a kernel with that support also.
NOTA: Some people have problems because they can't find the Reiser4 submenu in the Filesystems tree of the kernel, make sure that you have deactivated the option "use 4kb for kernel stacks instead of 8kb) under the kernel hacking submenu, and then you will find the Reiser4 option.
16. i/o and tasks schedulers
coming soon
17. Useful Scripts and tips
There are some useful scripts in the forums and the portage tree to manage our system:
1- esearch
This one is included in the portage tree (you can just emerge esearch), and it's an utility to search trought the portage package database. The good thing is that it's very fast (faster than emerge -sS).
Note that after every emerge sync we have to update de esearch database by running eupdatedb, or you can just use esync to update the portage tree (esync will emerge sync, and then show a list with the changes (new packages) from the last sync).
2- eix
The same concept as esearch, but it's faster (and it is also faster to update the package database).
It's a young project, but works pretty fine.
More info HERE.
3- Cruft
This script from will generate a list with all the files in our system that could be deleted because they don't belong to any installed package. You have to be careful when using it, because it can generase false positives.
Usage:
Code:
# ./cruft > cruft.log
Then you can check the list, and remove from it the files you want to keep.
Then you can run this command to get rid of the files:
Code:
# cat cruft.log | xargs rm -rf
You could also just take a look at the list and delete them yourself.
More info HERE.
4- Stale
Interesting script that will help us to keep /usr/portage/distfiles with an optimal size. The script will search in that dir, and delete (when invoked with the --nopretend option) the old files, not the actual ones.
For example, if we have libtool-1.3.5.tar.gz and libtool-1.5.2.tar.gz, it would delete libtool-1.3.5.tar.gz
It gets messed with files like font-arial-iso-8859-1 and font-arial-iso-8859-2, in which the numeration doesn't not correspond to the versioning of the package (the same with gtk and glib in their versions 1.x and 2.x)
More info HERE.
5- Porthole
Portage frontend made in python (+gtk), that offers us a visual way to configure portage, and it makes easier to configure the packages and emerges. It's already in portage, so you just have to "emerge porthole".
6- kuroo
Another portage frontend, this one is made with Qt (for the kde-lovers). It's a young project, but works fine.
More info HERE.
You can also find more useful scripts and programs related to Portage in THIS thread.
7- portage cdb
This is not a script itself, but it's a nice tip to improve the portage speed. Try it, you wont be disappointed!
8- mounting / in ram
very nice article, worth a read Smile http://forums.gentoo.org/viewtopic-t-296892.html
-under construction-
_________________
gentoo sex is updatedb; locate; talk; date; cd; strip; look; touch; finger; unzip; uptime; gawk; head; emerge --oneshot condom; mount; fsck; gasp; more; yes; yes; yes; more; umount; emerge -C condom; make clean; sleep
以下轉載自: 弱點掃瞄強大工具 Nessus
Nessus 是一款免費,經常更新且全功能的遠端弱點掃瞄強大工具, 支援各種平台如 Linux, BSD, Solaris 等. 它具備多執行緒, 採 plugin 基礎元件模式, 以良好的 GTK 介面來設計, 目前有超過1000個以上的弱點偵察能力. 另外, Nessus 有強大的報表功能, 能以多種格式輸出 (HTML, LaTeX, ASCII), 不僅可以指出問題所在, 更提示修補之道. 也有 Windows 版本喔.
國內也有廠商做類似的弱點掃瞄工具, 要價數10~60萬, 但功能未必及於 Nessus.
下載位址:
http://www.nessus.org/download/
TNC mirror:
ftp://ftp.tnc.edu.tw/pub/security-tools/nessus/nessus-installer-2.2.4.sh
htop - interactive processes viewer
一個類似 top 的工具. 不過顏色標示清楚, 且有圖形化(文字介面的圖形化).
看起來簡單、清楚又方便. 看系統 loading 的好工具.
可以去 http://htop.sourceforge.net/ 看看 Screenshots.
小小的工具. 但是很實用 ~ :)
Policyd is an anti-spam plugin for Postfix (written in C) that does greylisting, sender (envelope or SASL) based throttling (on messages and/or volume per defined time unit) and Spamtrap monitoring / blacklisting.
另一種防 Spam 的東東 - DomainKeys
網域認證鑰匙 DomainKeys
DomainKey Implementor's Tools and Library for email servers & clients (SourceForge)
一般預設的 shell command.(PS1='\u@\h:\w\$ ')
如果你打的字打到下一行去. 系統會自動的換到下一行去顯示文字.
但是如果自己要再加一些怪怪的東西, 一些控制碼(加顏色等等)..
就會遇到文字太長他不會自動換到下一行去的問題..
這時後 只要去修改 .bashrc 或 .bash_profile
在 PS1 = 前面加 \[ 於最後面加 \] 括起來.
ex: export PS1='\[\u@\h:\e[32m\w\e[0m$ \]'
這樣子就可以了.
(不用擔心 [ ] 這個會出現在自己的 command line)
[] 只是把那整個括起來的意思罷了. [] 不會顯示出來的 :)
Apache2 httpd.conf 設定檔的翻譯.
以下轉載自: Apache2的httpd.conf翻译
提交人: neosnake 时间: 四, 01/20/2005 - 15:04
Apache2的httpd.conf翻译
摘自http://www.linuxaid.com.cn/forum/
#
# 基于 NCSA 服务的配置文件。
#
#这是Apache服务器主要配置文件。
#它包含服务器的影响服务器运行的配置指令。
#参见以取得关于这些指令的详细信息
#
#不要只是简单的阅读这些指令信息而不去理解它。
#这里只是做了简单的说明,如果你没有参考在线文件,你就会被警告。
#
#这些配置指令被分为下面三个部分:
#1. 控制整个Apache服务器行为的部分(即全局环境变量)
#2. 定义主要或者默认服务参数的指令,也为所有虚拟主机提供默认的设置参数
#3. 虚拟主机的设置参数
#
#配置和日志文件名:如果你指定的文件名以“/”开始(win32下以“dirver:/”),
#服务器将使用绝对路径,如果文件名不是以“/”开始的,那么它将把ServerRoot
#的值附加在文件名的前面,例如,对“logs/foo.log",如果ServerRoot的值
#为“/usr/local/apache2”,则该文件应为“/usr/local/apache2/logs/foo.log”
#
##第一区:全局环境参数
#
#这里设置的参数将影响整个Apache服务器的行为;
#例如Apache能够处理的并发请求的数量等。
#
#ServerRoot:指出服务器保存其配置、出错和日志文件等的根目录。
#
#注意!如果你想要将它指定为NFS或其它网络上的位置,
#请一定要去阅读与LockFile有关的文档(可能在
#)。
#这将会使你自己也能解决很多问题。
#
#路径的结尾不要添加斜线。
#
ServerRoot "/usr/loacl/apache2"
#
#串行访问的锁文件必须保存在本地磁盘上
#
#LockFile logs/accept.lock
#ScoreBoardFile:用来保存内部服务进程信息的文件。
#如果未指明(默认),记分板(scoreboard)将被保存在一个匿名的共享内存段中,
#并且它不能被第三方软件所使用。
#如果指定了,要确保不能使用两个Apache使用同一个记分板文件,
#这个记分板文件必须保存在本地磁盘上。
#
#ScoreBoardFile logs/apache_runtime_status
#
#PidFile:记录服务器启动进程号的文件。
#
PidFile logs/httpd.pid
#
#Timeout:接收和发送前超时秒数
#
Timeout 300
#
#KeepAlive:是否允许稳固的连接(每个连接有多个请求),
#设为"Off"则停用。
#
KeepAlive On
#
#MaxKeepAliveRequests:在稳固连接期间允许的最大请求数,
#设为0表示无限制接入。
#我们推荐你将其设为一个较大的值,以便提高性能
MaxKeepAliveRequests 100
#
#KeepAliveTimeout:在同一个连接上从同一台客户上接收请求的秒数
#
KeepAliveTimeout 15
##
##Server-Pool大小设定(针对MPM的)
##
# prefork MPM
# StartServers:启动时服务器启动的进程数
# MinSpareServers:保有的备用进程的最小数目
# MaxSpareServers:保有的备用进程的最大数目
# MaxClients:服务器允许启动的最大进程数
# MaxRequestsPerChild:一个服务进程允许的最大请求数
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestPerChild 0
# worker MPM
# StartServers:服务器启动时的服务进程数目
# MaxClients:允许同时连接的最大用户数目
# MinSpareThreads:保有的最小工作线程数目
# MaxSpareThreads:允许保有的最大工作线程数目
# ThreadsPerChild:每个服务进程中的工作线程常数
# MaxRequestsPerChild:服务进程中允许的最大请求数目
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
# perchild MPM
# NumServers:服务进程数量
# StartThreads:每个服务进程中的起始线程数量
# MinSpareThreads:保有的最小线程数量
# MaxSpareThreads:保有的最大线程数量
# MaxThreadsPerChild:每个服务进程允许的最大线程数
# MaxRequestsPerChild:每个服务进程允许连接的最大数量
NumServers 5
StartThreads 5
MinSpareThreads 5
MaxSpareThreads 10
MaxThreadsPerChild 20
MaxRequestsPerChild 0
# WinNT MPM
# ThreadsPerChild:服务进程中工作线程常数
# MaxRequestsPerChild:服务进程允许的最大请求数
ThreadsPerChild 250
MaxRequestsPerChild 0
# BeOS MPM
# StartThreads:服务器启动时启动的线程数
# MaxClients:可以启动的最大线程数(一个线程等于一个用户)
# MaxRequestsPerThread:每个线程允许的最大请求数
StartThreads 10
MaxClients 50
MaxRequestsPerThread 10000
# NetWare MPM
# ThreadStachSize:为每个工作线程分配的堆栈尺寸
# StartThreads:服务器启动时启动的线程数
# MinSpareThreads:用于处理实发请求的空闲线程数
# MaxSpareThreads:空闲线程的最大数量
# MaxThreads:在同一时间活动的最大线程数
# MaxRequestPerChild:一个线程服务请求的最大数量,
# 推荐将其设置为0,以实现无限制的接入
ThreadStackSize 65536
StartThreads 250
MinSpareThreads 25
MaxSpareThreads 250
MaxThreads 1000
MaxRequestPerChild 0
# OS/2 MPM
# StartServers:启动的服务进程数量
# MinSpareThreads:每个进程允许的最小空闲线程
# MaxSpareThreads:每个进程允许的最大空闲线程
# MaxRequestsPerChild:每个服务进程允许的最大连接数
StartServers 2
MinSpareThreads 5
MaxSpareThreads 10
MaxRequestsPerChild 0
#
# Listen:允许你绑定Apache服务到指定的IP地址和端口上,以取代默认值
# 参见指令
# 使用如下命令使Apache只在指定的IP地址上监听,
# 以防止它在IP地址0.0.0.0上监听
#
# Listen 12.34.56.78:80
Listen 80
#
# 动态共享支持(DSO)
#
# 为了能够使用那些以DSO模式编译的模块中的函数,你必须有相应的“LoadModule”行,
# 因此,在这里包含了这些指令,以便能在使用它之前激活。
# 那些静态编译的模块不需要在这里列出 (即以“httpd -l”列出的模块)
#
# 示例:
# LoadModule foo_module modules/mod_foo.so
#
#
# ExtendedStatus:当调用“server-status”时,控制Apache是产生“全”状态
# 信息(ExtendedStatus On),还是产生基本信息(ExtendedStatus Off)。
# 默认为off
#
# ExtendedStatus On
### 第二区:“主”服务配置
#
# 这一区建立被 “主” 服务器用的指令值,以回应那些不被
# 定义处理的任何请求。
# 这些数值也提供默认值给后面定义的容器。
# 如果中有定义,那么这里定义的指令值将被
# 中的定义所覆盖。
#
#
# 如果你想使httpd以另外的用户或组来运行,你必须在开始时以root方式启动
# 然后再将它切换为你想要使用的用户或组。
#
# User/Group:运行httpd的用户和组
# 在SCO (ODT3)上使用“User nouser”和“Group nogroup”
# 在HPUX上,你可能不能以nobody身份使用共享内存,建议创建一个www用户。
# 注意一些核心(kernel)在组ID大于60000时拒绝setgid(Group)或semctl(IPC_SET),
#节在这些系统上不要使用“Group #-1”。
#
User nobody
Group #-1
#
# ServerAdmin:你的邮件地址,当发生问题时Apache将向你发出邮件。
# 作为一个出错文档,这个地址显示在server-generated页上,
# 例如:admin@your-domain.com
#
ServerAdmin kreny@sina.com
#
# ServerName指定Apache用于识别自身的名字和端口号。
# 通常这个值是自动指定的,但是我们推荐你显式的指定它以防止启动时出错
#
# 如果你为你的主机指定了一个无效的DNS名,server-generated重定向将不能工作。
# 参见UseCanonicalName指令
#
# 如果你的主机没有注册DNS名,在这里键入它的IP地址
# 无论如何,你必须使用它的IP地址来提供服务,
# 这里使用一种容易理解的方式重定向服务
ServerName www.dalouis.com:80
#
# UseCanonicalName:决定Apache如何构造URLS和 SERVER_NAME 和 SERVER_PORT 的指令。
# 当设置为 “Off”时,Apache会使用用户端提供的主机名和端口号。
# 当设置为“On”,Apache会使用ServerName指令的值。
#
UseCanonicalName Off
#
# DocumentRoot:你的文档的根目录。默认情况下,所有的请求从这个目录进行应答。
# 但是可以使用符号链接和别名来指向到其他的位置。
#
DocumentRoot "/home/redhat/public_html"
#
# Apache可以存取的每个目录都可以配置存取权限(包括它的子目录)。
#
# 首先,我们配置一个高限制的特征。
# 这将禁止访问文件系统所在的目录,并添加你希望允许访问的目录块。
# 如下所示
Order Deny,Allow
Deny from all
#
# 注意从这里开始你一定要明确地允许哪些特别的特征能够被使用。
# - 所以,如果Apache没有象你所期待的那样工作的话,
# 请检查你是否在下面明确的指定它可用。
#
#
# 这将改变到你设置的DocumentRoot
#
#
# Options:这个指令的值可以是“None”,“All”,或者下列选项的任意组合:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# 注意,“MultiViews”必须被显式的指定,“Options All”不能为你提供这个特性。
#
# 这个指令既复杂又重要,请参见
#“http://httpd.apache.org/docs-2.0/mod/core.html#optioins”以取得更多的信息。
#
Options FollowSymLinks
#
# AllowOverride控制那些被放置在.htaccess文件中的指令。
# 它可以是“All”,“None”,或者下列指令的组合:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# 控制谁可以获得服务。
#
Order allow,deny
Allow from all
#
# UserDir:指定在得到一个~user请求时将会添加到用户home目录后的目录名。
#
UserDir public_html
# 为防止在UserDir指令上的漏洞,对root用户设置
# 象“./”这样的UserDir是非常有用的。
# 如果你使用Apache 1.3或以上版本,我们强烈建议你
# 在你的服务器配置文件中包含下面的行
UserDir disabled root
#
# 下面是一个使用UserDir指令使一个站点的目录具有只读属性的示例:
#
#
# AllowOverride FileInfo AuthConfig Limit Indexes
# Options MultiViews Indexes SymLinksIfOwnerMatch IncludeNoExec
#
# Order allow,deny
# Allow from all
#
#
# Order deny,allow
# Deny from all
#
#
#
# DirectoryIndex:定义请求是一个目录时,Apache向用户提供服务的文件名
#
# index.html.var文件(一个类型映象文件)用于提供一个文档处理列表,
# 出于同样的目的,也可以使用MultiViews选项,但是它会非常慢。
#
DirectoryIndex index.php index.html index.html.var
#
# AccessFileName:在每个目录中查询为目录提供附加配置指令的文件的文件名。
# 参见AllowOverride指令。
#
AccessFileName .htaccess
#
# 下面的行防止.htaccess和.htpasswd文件被Web客户查看。
#
Order allow,deny
Deny from all
#
# Typeconfig:定义在哪里查询mime.types文件。
#
TypeConfig conf/mime.types
#
# DefaultType:定义当不能确定MIME类型时服务器提供的默认MIME类型。
# 如果你的服务主要包含text或HTML文档,“text/plain”是一个好的选择;
# 如果大多是二进制文档,诸如软件或图像,你应使用
# “application/octer-stream”来防止浏览器象显示文本那样显示二进制文件。
#
DefaultType text/plain
#
# mod_mime_magic允许服务器从自己定义自己类型的文件中使用不同的线索(hints),
# 这个MIMEMagicFile指令定义hints定义所在的文件。
#
MIMEMagicFile conf/magic
#
# HostnameLookups:指定记录用户端的名字还是IP地址,例如,本指令为on时
# 记录主机名,如www.apache.org;为off时记录IP地址,204.62.129.132。
# 默认值为off,这要比设为on好得多,因为如果设为on则每个用户端请求都将会
# 至少造成对 nameserver 进行一次查询。
#
HostnameLookups Off
#
# EnableMMAP:控制是否进行内存转储(如果操作系统支持的话)。
# 默认为on,如果你的服务器安装在网络文件系统上(NFS),请关闭它。
# 在一些系统上,关闭它会提升系统性能(与文件系统类型无关);
# 具体情况请参阅http://httpd.apache.org/docs-2.0/mod/core.html#enablemmap
#
# EnableMMAP off
#
# EnableSendfile:控制是否使用sendfile kernel支持发送文件
# (如果操作系统支持的话)。默认为on,如果你的服务器安装在网络文件系统
# (NFS)上,请你关闭它。
# 参见http://httpd.apache.org/docs-2.0/mod/core.html#enablesendfile
#
# EnableSendfile off
#
# ErrorLog:错误日志文件定位。
# 如果你没有在内定义ErrorLog指令,这个虚拟主机的错误信息
# 将记录在这里。如果你在那儿定义了ErrorLog,这些错误信息将记录在你所
# 定义的文件里,而不是这儿定义的文件。
#
ErrorLog logs/error_log
#
# LogLevel:控制记录在错误日志文件中的日志信息数量。
# 可能的值包括:debug,info,notice,warn,error,crit,alert,emerg。
#
LogLevel warn
#
# 下面的指令为CustomLog指令定义格式别名。
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
# 你需要安装了mod_logio.c模块才能使用%I和%O。
# LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
#
# 指定接入日志文件的定位和格式(一般日志格式)。
# 如果你没有在内定义这个指令,传输信息将记录在这里,
# 如果你定义了这个指令,则记录在你指定的位置,而不是这儿定义的位置。
#
CustomLog logs/access_log common
#
# 如果你想要记录agent和referer信息,可以使用下面的指令
#
# CustomLog logs/referer_log referer
# CustomLog logs/agent_log agent
#
# 如果你想要使用一个文件记录access,agent和referer信息,
# 你可以如下定义这个指令:
#
# CustomLog logs/access_log combined
#
# ServerTokens
# 这个指令定义包含在HTTP回应头中的信息类型。默认为“Full”,
# 这表示在回应头中将包含模块中的操作系统类型和编译信息。
# 可以设为列各值中的一个:
# Full | OS | Minor | Minimal | Major | Prod
# Full传达的信息最多,而Prod最少。
#
ServerTokens Full
#
# 随意的添加包含服务器版本和虚拟主机名字一行信息到server-generated输出页中
# (内部错误文档,FTP目录列表,mod_status和mod_info输出等等,除了CGI错误
# 或自定义的错误文档以外)。
# 设为“EMail”将包含一个指向ServerAdmin的mailto:连接。
# 可以为如下值:On | Off | EMail
#
ServerSignature On
#
# Aliases:在这时添加你需要的别名,格式如下:
# Alias 别名 真实名
#
# 注意,如果你在别名的未尾包含了“/”,那么在URL中也需要包含“/”。
# 因此,“/icons”不是这个示例中的别名。
# 如果别名中以“/”结尾,那么真实名也必须以“/”结尾,
# 如果别名中省略了结尾的“/”,那么真实名也必须省略。
#
# 我们使用别名“/icons/”来表示FancyIndexed目录列表,如果你不使用、
# FancyIndexing,你可以注释掉它。
#
# Alias /icons/ "/usr/local/apache2/icons/"
#
# Options Indexes MultiViews
# AllowOverride None
# Order allow,deny
## Allow from all
#
#
# 这将改变ServerRoot/manual。这个别名提供了手册页所在的位置,
# 即使你改变了你的DocumentRoot。如果你对有无手册页并不在意的话,
# 你可以注释掉它。
#
Alias /manual "/usr/loacl/apache2/manual"
Options Indexes FollowSymLinks MultiViews IncludesNoExec
AddOutputFilter Includes html
Order allow,deny
Allow from all
#
# ScriptAlias:指定包含服务脚本的目录。
# ScriptAliases 本质上与Aliases一样,除了这里的文档在请求时做为程序处理处理以外。
# 尾部的“/”规则与Alias一样
#
ScriptAlias /cgi-bin/ "/usr/loacl/apache2/cgi-bin/"
# 这里是添加php 4支持的指令
AddType application/x-httpd-php .php
LoadModule php4_module modules/libphp4.so
#
# 添加mod_cgid.c设置,mod_cgid提供使用cgid进行通讯的UNIX套接字的
# 脚本接口路径。
#
# Scriptsock logs/cgisock
#
# 将"/usr/local/apache2/cgi-bin"改为你的ScriptAliased指定的CGI目录,
# 如果你配置了的话。
#
AllowOverride None
Options None
Order allow,deny
Allow from all
#
# Redirect允许你告诉客户端使用存在于服务器名字空间中的文档,
# 而不是现在的,这帮助客户定位那些改变了位置的文档。
# 例如:
# Redirect permanent /foo http://www.example.com/bar
#
# 控制server-generated目录列表显示的指令
#
#
# IndexOptions:控制server-generated目录列表显示特征。
#
IndexOptions FancyIndexing VersionSort
#
# AddIcon* 指令告诉服务器不同扩展名的图象文件如何显示,
# 只适用于FancyIndexed指令
#
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*
AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core
AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
#
# DefaultIcon 为那些没有显式定义图标的文件提供处理
#
DefaultIcon /icons/unknown.gif
#
# AddDescription允许你在server-generated索引后放置一个简短的说明。
# 只对FancyIndexed指令有效。
# 格式:AddDescription "说明" 文件名
#
# AddDescription "GZIP compressed document" .gz
# AddDescription "tar archive" .tar
# AddDescription "GZIP compressed tar archive" .tgz
#
# ReadmeName指定服务器默认查找的README文件的名字,并添加到目录列表中
#
# HeaderName指定目录列表前缀文件的文件名
ReadmeName README.html
HeaderName HEADER.html
#
# IndexIgnore指定目录索引忽略并且不包含在列表中的文件名集合,
# 支持shell类型的通配符。
#
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
#
# AddEncoding允许你在信息传送中使用(Mosaic/X 2.1+)解压缩信息,
# 注意:不是所有的浏览器都支持这个选项。
# 尽管名字相似,但是下列的指令与上面的FancyIndexing定制指令不同。
#
AddEncoding x-compress Z
AddEncoding x-gzip gz tgz
#
# DefaultLanguage和AddLanguage允许你指定文档的语言。
# 这使你可以让用户用容易理解的语言浏览文档。
#
# 指定默认的语言,这意味着所有没有指定语言的包都将使用该语言。
# 多数情况下,你也许并不想设置它,除非你确信这样做是正确的。
# 通常,不使用确定的语言比使用错误的语言要好。
#
# DefaultLanguage nl
#
# 注意1:作为语言关键字的词缀毫无疑问是不能一样的--采用波兰
# 文的文档(网络标准语言代码是pl)将希望使用“AddLanguage pl .po”
# 来避免与perl脚本的一般词缀产生二义性。
#
# 注意2: 下面的例子举例说明在一些范例中语言的二字符缩写与它的国家
# 的二字符缩写不相同,例如 “Danmark/dk” 和 “Danmark/da” 的比较.
#
# 注意3: 在 “ltz” 的情况下我们使用三字符词缀,违犯了 RFC的规定,
# 运行中将修复它并使用RFC1766标准取得参考数据。
#
# Danish (da) - Dutch (nl) - English (en) - Estonian (et)
# French (fr) - German (de) - Greek-Modern (el)
# Italian (it) - Norwegian (no) - Norwegian Nynorsk (nn) - Korean (ko)
# Portugese (pt) - Luxembourgeois* (ltz)
# Spanish (es) - Swedish (sv) - Catalan (ca) - Czech(cz)
# Polish (pl) - Brazilian Portuguese (pt-br) - Japanese (ja)
# Russian (ru) - Croatian (hr)
#
AddLanguage da .dk
AddLanguage nl .nl
AddLanguage en .en
AddLanguage et .et
AddLanguage fr .fr
AddLanguage de .de
AddLanguage he .he
AddLanguage el .el
AddLanguage it .it
AddLanguage ja .ja
AddLanguage pl .po
AddLanguage ko .ko
AddLanguage pt .pt
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pt-br .pt-br
AddLanguage ltz .ltz
AddLanguage ca .ca
AddLanguage es .es
AddLanguage sv .sv
AddLanguage cz .cz
AddLanguage ru .ru
AddLanguage tw .tw
AddLanguage zh-tw .tw
AddLanguage hr .hr
# LanguagePriority允许你在会话过程中优先使用一些语言。
#
# 以优先次序递减的方式列出它们。我们或多或少地采用按字母排列顺序的方式
# 排列它们。也许你想要改变这个顺序。
LanguagePriority en da nl et fr de el it ja ko no pl pt pt-br ltz ca es sv tw
#
# ForceLanguagePriority 允许你为MULTIPLE CHOICES(Prefer)[在通讯的情况下]
# 或NOT ACCEPTABLE(Fallback)[没有可接受的语言匹配的情况]提供一个结果页。
#
ForceLanguagePriority Prefer Fallback
#
# 为发送出的所有页指定默认的字符集,这总是一个好主意,并且为你的
# web站点的国际化打开了大门,这不正是你曾经想要的吗。同样地,指定
# 默认字符集有一些小的损害,如一个使用iso-8859-1(latin1)标准命令
# 的页面,除非以别的方式指定例如你仅仅以显式方式声明它。
# 也有一些与那些总是鼓励你使用默认字符集的javascropt和URL语法有关
# 的浏览器安全原因。
#
#AddDefaultCharset ISO-8859-1
AddDefaultCharse GB2312
#
# 一般以文件扩展名的方式使用字符集。也许你想要避免与语言扩展发生
# 碰撞,除非你在每次改变后都做了很好的测试。
# 参见http://www.iana.org/assignments/character-sets以取得字符集
# 的名字列表和它们各自的RFCs。
#
AddCharset ISO-8859-1 .iso8859-1 .latin1
AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen
AddCharset ISO-8859-3 .iso8859-3 .latin3
AddCharset ISO-8859-4 .iso8859-4 .latin4
AddCharset ISO-8859-5 .iso8859-5 .latin5 .cyr .iso-ru
AddCharset ISO-8859-6 .iso8859-6 .latin6 .arb
AddCharset ISO-8859-7 .iso8859-7 .latin7 .grk
AddCharset ISO-8859-8 .iso8859-8 .latin8 .heb
AddCharset ISO-8859-9 .iso8859-9 .latin9 .trk
AddCharset ISO-2022-JP .iso2022-jp .jis
AddCharset ISO-2022-KR .iso2022-kr .kis
AddCharset ISO-2022-CN .iso2022-cn .cis
AddCharset Big5 .Big5 .big5
# 对于俄语,使用了多个字符集(如何使用主要依靠客户端):
AddCharset WINDOWS-1251 .cp-1251 .win-1251
AddCharset CP866 .cp866
AddCharset KOI8-r .koi8-r .koi8-ru
AddCharset KOI8-ru .koi8-uk .ua
AddCharset ISO-10646-UCS-2 .ucs2
AddCharset ISO-10646-UCS-4 .ucs4
AddCharset UTF-8 .utf8
# 下面的字符集没有映射到一个特定的标准(iso)上,但是它们在浏览器
# 中被广泛的支持。注意那些大写字母。
# (它不应该,但是它是为兼容一些浏览器而做)
#
# 参见http://www.iana.org/assianments/character-sets以取得
# 它们的列表。但是浏览器支持较少。
#
AddCharset GB2312 .gb2312 .gb
AddCharset utf-7 .utf7
AddCharset utf-8 .utf8
AddCharset big5 .big5 .b5
AddCharset EUC-TW .euc-tw
AddCharset EUC-JP .euc-jp
AddCharset EUC-KR .euc-kr
AddCharset shift_jis .sjis
#
# AddType允许你为指定的文件类型添加或覆盖mime.types文件中配置的MIME
#
AddType application/x-tar .tgz
AddType image/x-icon .ico
#
# AddHandler允许你映射确定的文件扩展名到“handlers”:
# 与文件类型无关的行为。这既能编译到服务器中也可以添加到Action指令
# 中(看下面)。
# 为了在ScriptAliased指令指定的以外使用CGI脚本:
#(要使它可用,你还需要在Options中添加“ExecCGI”。
#
# AddHandler cgi-script .cgi
#
# 对于那些包含他们自己的HTTP头的文件
#
# AddHandler send-as-is asis
#
# 对于server-parsed imagemap文件:
#
# AddHandler imap-file map
#
# agemap 文件:
#
#AddHandler imap- 文件映像
#
# 对于类型映像:(转移资源)
#(这是默认的设定以允许Apache的“It Worked”页能多种语言分发)。
#
AddHandler type-map var
#
# 过滤器允许你在将它发送到客户端前进行处理。
#
# 为了在服务器端分析包含(SSI)的.shtml文档:
# (要执行这个指令,你还需要在Options指令中添加“Includes”。)
#
# AddType text/html .shtml
# AddOutputFilter INCLUDES .shtml
#
# Action让你定义当调用匹配的媒体文件时将要执行的脚本。这将减少
# 那些经常使用的CGI脚本的URL路径名的重复输入。
# 格式:Action media/type /cgi-script/location
# 格式:Action handler-name /cgi-script/location
#
#
# 可配置的错误应答有三种风格:
# 1)plain text 2)local redirects 3) external redirects
#
# 一些示例:
# ErrorDocument 500 "The server made a boo boo."
# ErrorDocument 404 /missing.html
# ErrorDocument 404 "/cgi-bin/missing_handler.pl"
# ErrorDocument 402 http://www.example.com/subscription_info.html
#
#
# 综合应用这些指令,我们可以创建一个国际化的出错应答。
#
# 我们使用Alias来重定向任意/error/HTTP_.html.var应答到
# 我们的多语言错误消息集合。使用正确的文本替代它。
#
# 通过加入下面的行,你就能够改变这些消息的显示,而不必改变
# HTTP_.html.var文件。
#
# Alias /error/include/ "/your/include/path/"
#
# 以将/usr/local/apache2/error/include/下的文件拷贝到/your/inclue/path/下
# 开始,你可以创建你自己的文件集合,甚至是其于每个虚拟主机的。
# 不管你的ServerSignature如何设置,默认的包含文件将显示你的
# Aapche版本号和你的ServerAdmin邮件地址
#
# 国际化的错误文档需要mod_alias,mod_include和mod_negotiation三个
# 模块。要激活它们,取消下面30行的注释符号
# Alias /error/ "/usr/local/apache2/error/"
#
#
# AllowOverride None
# Options IncludesNoExec
# AddOutputFilter Includes html
# AddHandler type-map var
# Order allow,deny
# Allow from all
# LanguagePriority en de es fr it nl sv
# ForceLanguagePriority Prefer Fallback
#
#
# ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var
# ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var
ErrorDocument 403 /error.php
# ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var
# ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var
# ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var
# ErrorDocument 410 /error/HTTP_GONE.html.var
# ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var
# ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var
# ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var
# ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var
# ErrorDocument 415 /error/HTTP_SERVICE_UNAVAILABLE.html.var
# ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var
# ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var
# ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var
# ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var
# ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var
#
# 下面的命令更改标准的HTTP应答行为以处理己知的浏览器问题。
#
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0
#
# 下面命令关闭对那些没有尾部“/”的目录的非GET请求的重定向,
# 这些命令修复了微软的采用DAV方法不能正确处理重定向的WEB文件夹的问题。
# Apple下的DAV文件系统和Gnome下的VFS对DAV的支持也是采用这样的方法
# 进行处理的。
#
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1.[012]" redirect-carefully
BrowserMatch "^gnome-vfs" redirect-carefully
#
# 允许你使用URL:http://servername/server-status来通过mod_status生
# 成并报告服务器状态信息。改变.example.com为你自己的域名。
#
#
# SetHandler server-status
# Order deny,allow
# Deny from all
# Allow from .example.com
#
#
# 允许使用URL:http://servername/server-info来远程报告服务器配置信息
# (需要mod_info.c支持)。改变“.example.com”为你自己的域名。
#
#
# SetHandler server-info
# Order deny,allow
# Deny from all
# Allow from .example.com
#
#
# 代理服务器命令,去掉下面的行使代理服务可用。
#
#
# ProxyRequests On
#
# Order deny,allow
# Deny from all
# Allow from .example.com
#
#
# 安装或关闭HTTP/1.1“通道”头处理。
# (“Full”添加服务器版本信息,“Block”移掉所有输出“通道”头信息。
# 可以设为下面各选项之一:Off | On | Full | Block
#
# ProxyVia On
# 最好为代理服务安装高速缓冲,去掉下面几行的注释符号:
# (没有CacheRoot则不缓冲)
#
# CacheRoot "/usr/local/apache2/proxy"
# CacheSize 5
# CacheGcInterval 4
# CacheMaxExpire 24
# CacheLastModifiedFactor 01
# CacheDefaultExpire 1
# NoCache a-domain.com another-domain.edu joes.garage-sale.com
#
# 代理命令结束。
#
# 附加的特定模块配置。
#
Include conf/ssl.conf
## 第三区:虚拟主机
#
# VirtualHost:你可以通过设置虚拟主机容器以实现在你的主机上保有多个
# 域名/主机名。大多数配置信息只使用基于名字的虚拟主机,因此服务器
# 不必担心IP地址的问题,下面的命令以*号代替虚拟主机名。
#
# 在你试着配置你的虚拟主机以前,请参见
# URL:http://httpd.apache.org/docs-2.0/vhosts/>以取得更多的信息。
#
# 你可以使用命令行选项“-S”来检验你的虚拟主机配置。
#
# 使用基于名字的虚拟主机。
#
# NameVirtualHost *
#
# 虚拟主机示例:
# 几乎所有的Apache命令都可以在虚拟主机容器中使用。
# 第一个虚拟主机区是用于向服务名未知的请求进行应答的配置。
#
#
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log commom
#
本文最新 url Apache 1.x版 部份參數說明(I) 38, 39 就是其它兩部份.
非常棒的一份文件. Part I ~ III
一定要轉載過來好好學習.
以下轉載自: apache 部份參數說明
AllowOverride 的屬性功能
AllowOverride Limit 允許蓋掉原聯結屬性得範圍
AllowOverride Authconfig 可做密碼設定:如:藏密
AllowOverride Options 可將該目錄之Options 功能覆蓋
AllowOverride FileInfo 可將該目錄之任何文件型態覆蓋,如:DefaultType,ErrorType
AllowOverride Indexs 可將該目錄之顯式列印功能覆蓋,如:AddIcon,HeaderName.ReadName
Options的屬性功能
Indexs 當無index.html可用列印目錄方式顯式,如:center3 homepage 若用 -Indexs 則看不見 listing
FollowSymLinks 加一屬性如+FollowSymLinks可允許使用symbol link 時,依舊可瀏覽
ExecCGI 當為 +ExecCGI可執行 CGI SCRIPT
Includes 可執行Server site include,若為 +Includes
IncludesNOEXEC 可執行Server site include,若為 +Includes,但不可執行CGI
None 沒有任何功能可用
All 均可
總之,以 +, - 符號可加或刪減其功能,若未給符號,則只有初步功能
Limit的屬性功能
GET 限定取得文件法,如:<Limit GET>
POST 限定cgi post方法,如:<Limit POST>
order 限定拒絕或允許的次序
deny 限定拒絕範圍,如:deny from all 或 deny from .mycompany.com
allow 限定允許範圍,如:allow from all 或 allow from 192.153.22
AuthConfig 之方法 & .htaccess 範例
<Files index.html>
#與Directory同,但在 .htaccess 只能用他 AuthName Members-only 設定僅 Member 才可入,僅為名稱 AuthType Basic 解碼方法 AuthUserFile /home1/users/center/center21/public_html/wwwclass/bau
#密碼表位置(絕對位置) AuthGroupFile /home1/users/center/center21/public_html/wwwclass/group
#同群表位置
<Limit GET>
#限制取件
require user center21
#bau的密碼表有很多user,但....
order allow,deny
#先允許在拒絕
allow from all
#允許全部
</Limit>
<Files>
密碼表之產生方法
找到及取得htpasswd程式
執行htpasswd -c filename username (第一次,以後僅htpasswd filename username)
修改需要的 user (在 require 後)
require用法
require user center21 center3
require group cc cv ee
都會啟動httpd以隨畤提供服務。
# inted:需要時才臨時啟動,監聽所有進入本機請求的port,然後核對port所對應的服務
以決定要用哪一個服務,再執行httpd,當請求完結就將httpd結束。
# 語法:Port [編號]
# 說明:指定 httpd 服務的閘道,一般是 80,
# 2000 以後的 URL 就必須寫成 http://xx.xx.xx.xx:2000/
# 語法:HostNameLookups [on/off]
# 說明:設定要不要把自動搜尋 HostName 的功能打開
# 設定為on時,則會記錄進入此網站使用者的主機名稱(例如fo23.flag.com.tw)
# 設為off,則僅記錄使用者主機的IP(例如203.74.205.23)
# 語法:User [username/#uid]
# 說明:設定 httpd 這程式的執行者是誰.
# 一般是 nobody,也可以是已註冊的 user,若用 user id 要加上 # 號
# 語法:Group [groupname/#gid]
# 說明:設定 httpd 這程式的執行者所屬的群組
# 一般是 nogroup,此 group 必須要存在於 /etc/group 中
# 語法:Server Admin [E-mail 位址]
# 說明:設定此 web 站管理者的 E-mail位址,在系統發生錯誤時,方便與管理者聯絡
# 語法:ServerRoot [目錄的絕對路徑]
# 說明:設定 apache 所安裝的絕對路徑,所有網站相關的襠案都存放在此目錄中
# 舉例:ServerRoot /usr/local/apache
# 語法:BindAddress [*/IP/FQDN]
# 說明:強迫 apache 只對某個特定位址反應, * 則是對所有位址都反應
# 如果要採用 Virtual Host 虛擬主機功能,務必要設為 BindAddress *
# 說明:設定要以哪一個 address 來服務,可使用 IP 或完整的主機名稱(FQDN),
# * 是全部接受
# 當使用虛擬主機功能畤,一台電腦上可能有幾張網路卡分別設定不同的IP。BindAddress
設為*,表示系統會監聽每一個IP的連線;設為IP值,則僅監聽該IP的連線;亦可設定為
domain name,僅監聽來自該處的連線
# 語法:ErrorLog [檔案名稱]
# 說明:記錄執行 apache 時所產生的錯誤訊息,如果檔名不是以 / 開頭,那就不會連
# 接到 ServerRoot 的路徑下
# 舉例:ErrorLog logs/error_log
# 將錯誤訊息放在 /usr/local/apache/logs/error_log 中
# apache 的 root directory 在 /usr/local/apache
# 語法:LogLevel [debug/info/notice/warm/error/crit/alert/emerg]
# 說明:設定 error_log 中記錄的錯誤訊息種類,建議值是 warm,越右邊越簡略
# 語法:CustomLog [檔案名稱][combined/common/referer/agent]
# 說明:同 ErrorLog 部份 ,是屬於傳輸記錄,並起設定該記錄所記錄的資訊
# 舉例:CustomLog logs/access_log common (common 是建議值)
# 越右邊的參數越簡略
# 若 user 多時,此檔會變很大,要小心管理
# LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
# LogFormat "%h %l %u %t \"%r\" %>s %b" common
# LogFormat"%{Referer}@->%U"referel
# LogFormat”%{User-agent}i"agent
# 設定每筆記錄的楁式,有 combined、common、referer與 agent四種
# The location of the access logfile (Common Logfile Format)
# If this does not start with /, ServerRoot is prepended to it.
# CustomLog/usr/local/apacHe/Var/log/access_log common
# 存取記錄的位置,使用Comon格式
# If you would like to have an agent and referer logfile uncomment the
# following directives.
# CustomLog/usr/local/apache/var/log/referer_logreferel
# 記錄瀏覽者經由本網站所連結出丟的網址,使用refere「自訂格式
# CustomLog/usr/local/apache/var/log/agent_logagent
# 記錄瀏覽者連到本網站所使用的瀏覽器版本與種類,使用agent自訂格式
# If you prefer a single logfile with access, agent and referer information
# (Combined Logfile Format) you can use the following directive.
# CustomLog /usr/local/apache/var/log/access_log combined
# 語法:PidFile [pid-filename]
# 說明:記錄 httpd 啟動時的 PID,以方便管理員的管理;方便重新啟動時做參考,
# 這樣就不必用 ps 來尋找
# 舉例:PidFile logs/httpd.pid
# PidFile /usr/local/apache/var/run/httpd.pid ←紀錄httpd的 PID
# 語法:ScoreBoardFile [檔案名稱]
# 說明:紀錄被使用過的檔案
# 舉例:ScoreBoardFile logs/apache_runtime_status
# 語法:ServerName [主機名稱]
# 說明:設定該伺服器的 Domain Name ,此名稱必須是已經向貴網域的 DNS 註冊。
# 舉例:ServerName http://www.hmes.kh.edu.tw ← 若沒有一個登記的DNS name,則請改為IP
# 語法:CacheNegotiatedDocs
# 說明:當使用者藉 Proxy 來讀取 Web Server 時,Apache Httpd 會送出 Pragma:
# no-cache 的檔頭使得 Proxy Server 不會把他留在 cache 中。
# 語法:Timeout [秒數]
# 說明:設定 httpd 等待使用者下一個指令的時間,如果在此時間內使用者沒有回應
# ,則終止服務,如果網路速度慢,時間設長一些。
# 舉例:Timeout 300
# 語法:KeepAlive [on/off]
# 說明:設定是否接受使用者之連續請求。
# 語法:MaxKeepAliveRequests [數目]
# 說明:設定能接受之最大連續請求量,如果連續請求超過此數量, server 會自動踢掉。
# 舉例:MaxKeepAliveRequests 100 ←每次連線可提出要求數量,設為0表示不限次數,頇設為100
# 語法:KeepAliveTimeout [秒數]
# 說明:設定使用者連續請求等待的時間上限,如果 user 連續請求的時間超過此數,則
# 不再執行此請求
# 舉例:KeepAliveTimeou 15 ←下個要求如果超過多少秒還未到達,則視為連線結束
# 語法:MaxSpareServers [數量]
# MinSpareServers [數量]
# 說明:設定閒置來等待服務的伺服器數量,當系統的閒置個數小於此設定時,系統會開
# 啟更多的 server 來服務;當系統的閒置個數大於此設定時,多餘的個數會被刪
# 掉;如果 web 使用率高,應加大 MinSpareServers
# 舉例:MaxSpareServers 10 MinSpareServers 5
# 語法:StartServers [數量]
# 說明:一開始驅動 apache httpd 時,閒置等待服務的伺服器數量
# 舉例:StartServers 5 ←(執行ps-aux指令就可以看到這5個serverprocesses)
# 語法:MaxClients [數量]
# 說明:設定最多能提供給幾個 user 同時連線
# 舉例:MaxClients 150 ←因為同時連進來的數目大多時,會降低系統存取的效能,可設
定此數值限制同時連線進來的數目,若您的系統CPU很快、記憶體很多且效能很
好時,可以考慮將此值調高.否則就降低一點
# 語法:MaxRequestsPerChild [數量]
# 說明:設定每個子程序所能接受的最大服務次數,當達到此數目時,子程序會自動關閉
# 舉例:MaxRequestsPerChild 30
# 語法:ProxyRequests [On/Off]
# 說明:開啟或關閉 Proxy 的功能,內定值是關閉,大部份情況也是關閉。用標準安裝時,
Apache並沒有將 proxy 模組加入,若需要此功能,請參考INSTALLS檔的誽明。
# 語法:<VirtualHost [hostname]>..</VirtualHost>
# 說明:虛擬主機的設定;在做此設定之前,必須有支援 multipule address 或有一片
# 以上的網路卡
# 舉例:
# NameVirtualHost 203.72.230.212 ## 一定要設,apache 1.3以上才有的改變
#
# <VirtualHost wwwa.hmes.kh.edu.tw> ## 第一部份
# ServerAdmin webadmin@hmes.kh.edu.tw
# 設定虛擬主機的管理者信箱,不一定要和本機的網站管理者相同
# DocumentRoot /www/docs/
# 指定虛擬主機的網站主目錄
# ServerName wwwa.hmes.kh.edu.tw ##設為 VirtualHost 的名稱
# 指定虛擬主機的URL
# ErrorLog logs/?? ??
# 虛擬主機發生錯誤時要記錄在哪個目錄
# TransferLog logs/??
# 虛擬主機存取記錢要存放的目錄
# </VirtualHost>
# <VirtualHost wwwb.hmes.kh.edu.tw> ##第二個 DNS ## 第二部份
# ServerAdmin webadmin2@hmes.kh.edu.tw
# DocumentRoot /www/docs2/
# ServerName wwwb.hmes.kh.edu.tw
# ErrorLog logs/??
# TransferLog logs/??
# </VirtualHost>
# 語法:UseDir [目錄名稱]
# 說明:若有提供給 user 放置個人首頁時,必須將自己的首頁放置在自己的目錄中,
# 當其他人瀏覽時,只要以 http://xxx.xxx.xxx.xxx/~username 就可以瀏覽
# 個人網頁
# 舉例:UserDir Public_html
# 語法:DirectoryIndex [檔名1][檔名2]
# 說明:設定使用者連入網站時,在不指定瀏覽檔案的情況下,第一個瀏覽的檔案名稱。
# 通常是使用者所看到的第一頁資料
# 舉例:DirectoryIndex index.htm index.html
# 語法:FancyIndexing [on/off]
# 說明:如果找不到 DirectoryIbdex 所指定的檔案時,要不要把該目錄資料轉換成
# html 格式呈現出來。呈現方式要參考 access.conf 中 <Directory ..> ..
# </Directory>,可以用 IndexOptions 來設定。
# 舉例:Fancyindexing on ←從瀏覽器中顯示網站目錄的檔案列表時(例如找不到index.htm檔時
就會出現檔案列表),此值設為on,則會包括檔案類型的小圖示,
看起來比較漂亮;若設為off,則僅單純地列出檔名,小圖示都放
在 /usr/local/apache/icons目錄中
# 語法:AddIconByEncoding [圖形檔位置][MIME-encoding 方式]
# 說明:當 FancyIndexing 為 on ,且必須列出目錄資訊時,會根據所列出檔案的
# MIME-encoding 格式在檔名前面加上特定的圖形檔作為標籤以供辨識。
# 舉例:AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
# 語法:AddIconByType [圖形檔位置] [MIME-Type 種類]
# 說明:當 FancyIndexing 為 on ,且必須列出目錄資訊時,會根據所列出檔案的
# MIME-Type 在檔名前面加上特定的圖形檔作為標籤以供辨識。
# 舉例:AddIconByType (TXT,/icons/text.gif) text/
# 語法:AddIcon [圖形檔位置] [MIME-Type 種類]
# 說明:當 FancyIndexing 為 on ,且必須列出目錄資訊時,會根據所列出檔案的
# 副檔名,在檔名前面加上特定的圖形檔作為標籤以供辨識。
# 舉例:AddIcon /icons/binary.gif .bin .exe
# 語法:DefaultIcon [圖形檔位置]
# 說明:當 FancyIndexing 為 on ,且必須列出目錄資訊時,如果檔案無法分辨其
# 格式或是類型,在檔名前面所要加上的圖形。
# 舉例:DefaultIcon /icons/unknown.gif
# 語法:AddDescription "說明" [檔名]
# 說明:可為檔案加上註解:
# 舉例:AddDescription "Apache original page" apache.htm1
AddDescription "Hello my friend" web01.tif
# 語法:ReadmeName [檔案名稱]
# 說明:當 FancyIndexing 為 on ,且必須列出目錄資訊時,所一起列出的說明內容
# ,一般附在目錄清單的下方。
# 舉例:ReadmeName README ←此檔會秀在檔案列表的結尾.需有README.html
# 語法:HeaderName [檔案名稱]
# 說明:當 FancyIndexing 為 on ,且必須列出目錄資訊時,所一起列出的說明內容
# ,一般附在目錄清單的上方。
# 舉例:HeaderName HEADER ←此檔會秀在檔案列表的開頭.需有HEADER.html
# 語法:IndexIgnore [檔案名稱]
# 說明:當 FancyIndexing 為 on,且必須列出目錄資訊時,目錄中哪些檔案不要列出。
# 舉例:IndexIgnore.??*~*#HEADER*README*RCS ← 遇到這些檔名時不要列出
例如前面的README.html與HEADER.html
# 語法:AccessFileName [檔案名稱]
# 說明:設定當使用者以 http 讀取該目錄及以下目錄時,必須要經過使用者帳號與密
# 碼的認證過程,而這些密碼所存放的檔案名稱
# 舉例:AccessFileName .htaccess !!! .htaccess 已放有帳號和密碼,所以當
# FancyIndexing 設為on 時要小心,務必將 .htaccess 設入 IndexIgnore 中
# 語法:TypesConfig [/path/mime.types]
# 說明:設定各種檔案類型關聯的位置,可將網頁中所包含的各種檔案類型通知瀏覽器,
讓瀏覽器知道使用何種軟體來處理檔案
# 語法:DefaultType [MIME 種類]
# 說明:當伺服器無法辨別的 MIME 檔案類型時,一般宣告為何種 MIME 格式
# 舉例:DefaultType text/plain ←當不認得文件的類型時,則當成一般文字
# 語法:AddEncoding [MIME-encoding 形式] [壓縮的種類]
# 說明:設定檔案壓縮格式,讓瀏覽器抓下來之後,可以自動解壓縮並直接提供給使用
# 者瀏覽
# 舉例:AddEncoding x-gzip gz ←當瀏覽器遇到.gzip、.gz副檔名的檔案時,會自動予以解壓縮
# 語法:Redirect [檔案名稱]
# 說明:可重新導向連結的位�....edu.tw/myfile/ ,但現在已無
該目錄存在了,則可加入下面這一行,將該連結自動導向到另一個連結:"Redirect/myfi1e
http://www.xxx.com/yyy"
# 語法:Alias [虛擬目錄][實際目錄]
# 說明:設定實際目錄至虛擬目錄,可將原本很長的路徑簡化
# 舉例:Alias /luck ”/usr/local/apache/htdocs/manual/luck/”
原本需要用http://www.xxx.com/manual/1uck 才能連到的網頁,現在僅需使用
http://www.xxx.com/luck 即可。但有一點要特別注意,在前面的那一項 /luck/,
如果有加上後面的那一個斜線畤,則URL的最後一定也要加上斜線,否則會找不到
# 語法:ScriptAlias [虛擬目錄][實際目錄]
# 說明:設定哪一個目錄包括server端的script檔案,通常為CGI script。Apache的/cgi-bin/目錄裡面
預設是空的,您若有需要可自行放入CGI script
# 語法:AddType [MIME-type 種類]
# 說明:增加一個沒有設定於 mime.types 中的其他 MIME-type
# 舉例:AddType application/x-httpd-php3 .phtml
可在不修改 mime.types 情況下,在此增加 mime types
# 語法:AddHandler [MIME-type 種類]
# 說明:類似AddType的語法,不過這裡設定的是可執行檔,一般是 CGI
# 舉例:AddHandler cgi-script .cgi ←使用副檔名為.cgi的檔案為CGI script
AddType text/html .shtml
AddHandler server-parsed .shtml ←允許使用副檔名為.shtml 的檔名(應用於SSI),
server將一些特殊標籤轉換為真正的內容
AddHandler imap-file map ←允許網頁中使用需要利用CGI處理的影像地圖
# 語法:ErrorDocument [錯誤編號][檔案/文字說明]
# 說明:自訂系統傳給使用者的錯誤訊息
# 舉例:ErrorDocument 404 /missing.html
# 或 ErrorDocument 404 "找不到您要的檔案...
# 當以文字說明時,務必加上 " 號
一直聽說 Samba UTF-8 有問題.
但是因為資料實在太多. 要從 Big5 轉換到 UTF-8 看來是遙遙無期.
不過看到有人解決掉這個麻煩的事.. 趕快記錄下來 :p
以下轉載自: Samba也要utf8
smb.conf
[global]
dos charset = UTF8
unix charset = UTF8
display charset = UTF8
再來用smbmount也都ok了, 但中文就是一直會缺字, 我smbmount用的參數為iocharacter=utf8,codepage=cp950, 後來才發現原來codepage設錯了, cp950是big5的codepage number, 如果是utf8環境的話, 要用codepage=65001
一些系統維護時要注意的東西.
想到再陸續的加進來..
系統 需 注意的事項:
1. Inode用光
df -i
若 Inode 用光. 可能會讓機器當掉.
2. 容量不夠
df -h
看看到底還剩多少容量
當 loading 太重的時後, 要看到底是哪些命令造成的.
看現在有在跑那些 process
mysqladmin -u root processlist
進入 mysql 中
show processlist
kill Id 就可以清掉那個 Thread id
ex: kill 8888737
轉載自: Linux下Top命令中load averages的涵義
top displays a variety of information about the processor state. The
display is updated every 5 seconds by default, but you can change that
with the d command-line option or the s interactive command.
uptime
This line displays the time the system has been up, and the three
load averages for the system. The load averages are the average
number of process ready to run during the last 1, 5 and 15 min-
utes. This line is just like the output of uptime(1). The uptime
display may be toggled by the interactive l command.
top 動態抓 loading 的方法
top -t -n 25 < file
[使用說明]
uptime秀出目前時間 系統距上次重開機幾天,又幾小時幾分,目前站上有幾位使用者,
還有最近一分鐘,五分鐘,十五分鐘的CPU平均負載(數字越大代表CPU越吃力)
[使用範例]
uptime
9:27PM up 1 day, 18:18, 1 user, load averages: 0.66, 0.29, 0.21
[使用說明]
無參數時,time會秀出目前這個shell與他的子程序的
CPU使用者時間(秒) CPU系統時間(秒) 實耗時間([時]:分:秒) CPU時間佔實耗時間百分比。
有參數時,time會嘗試執行以這個參數為名的指令,並秀出
CPU使用者時間 CPU系統時間 實耗時間 CPU時間佔實耗時間百分比。
P.S.
CPU花在該程式上的時間稱為CPU時間
CPU時間又可細分為CPU花在程式本身的使用者時間與
作業系統處理該程式所花費的系統時間
[使用範例]
無參數
time
10.800u 6.365s 1:07:07.14 0.4%
有參數
time uptime
10:14PM up 1 day, 19:05, 1 user, load averages: 0.04, 0.21, 0.23
0.006u 0.018s 0:00.90 1.1%
[使用說明]
su可以讓目前使用者的shell暫停,轉換成另一個user與group,並重新執行起一個新shell
感覺上就好像暫時變成了另外一個帳號,再執行exit時,就可變回本尊。
對於一般使用者而言
執行su login時,他會要求你輸入參數login的密碼,login必須是這個系統下的一個帳號
如果沒有參數login,login就等於是root,也就是su root
在FreeBSD下,你想要su成root是沒有這麼簡單的,你的gid必須是0
如果系統下都沒人gid=0,那任何人都可以su root
對於root而言,su成任何帳號都不會要求密碼的,懂這意思,root最大。
現在讓我們來看看su成功以後,系統會作什麼事
除了HOME,SHELL,USER這三個環境變數外,所有的環境變數都會保留原狀
HOME和SHELL會變成login目標的預設值
USER一般來說是變成login,不過如果你變成uid=0的帳號(通常是root)那USER就維持不變
當你su別的login時,你的資源限制仍然跟原來一樣,除非你變成uid=0的帳號,懂吧
看不懂沒關係 這跟你的login class有關,但我不會告訴你 你可以自己去查(login.conf(5))
還有一些參數
-K
我也不知道是幹麼的
-f
如果新shell是csh系列的話,這個參數讓新shell起來時不會讀取csh的設定檔(如.cshrc)
-l
模擬一個全新的login,所有的環境變數全部重新設定,除了HOME, SHELL, PATH, TERM, and USER
HOME,SHEEL就像上面解釋過的一樣去變化
USER不管目標login是不是uid=0,都一定會變成目標login
PATH會預設成這樣 "/bin:/usr/bin"
TERM則從你舊帳號的TERM copy過去
資源限制則是使用新帳號class的資源限制喔(請看login.conf(5))
-m
除了變成另一個帳號外,所有的環境都不變,目錄不變,環境變數也不變
單南啦 為了安全的因素 如果目標login的shell不是標準shell(getusershell(3))
而且 目標login的uid!=0 那你就su不過去啦
-c class
使用指定的login class的設定,限superuser喔
從以上的說明可以知道 -l與 -m 是水火不容的,後面指定的參數會蓋掉前面的
你還可以在su login後面接一些args,那是傳給新shell的參數
[使用範例]
su man -c catman
以man的身份執行catman指令(這裡的-c不是-c class而是傳給shell的參數喔)
su man -c 'catman /usr/share/man /usr/local/man /usr/X11R6/man'
以man的身份執行 '....'指令
su -c staff man -c 'catman /usr/share/man /usr/local/man /usr/X11R6/man'
跟上面指令一樣,只是資源限制是staff這個login class
su -l man
模擬man login
initrd.img 的作用, 就是給核心提供啟動所需要的驅動.
為了方便, 把自己硬體的驅動都載入核心中.
參考自:
Creating an initrd image on Debian GNU/Linux
mkinitrd -k -o /boot/initrd.img-[version] -r /dev/hda5 [version]
/dev/hda5 是 / 的位置.
參考自: 編譯核心
編譯核心(kernel)
make bzImage
make modules
make modules_install
make install
initrd.img 的作用, 就是給核心提供啟動所需要的驅動.
為了方便, 把自己硬體的驅動都載入核心中.
誤解了手冊上的意思, 自己手工改了 mkinitrd.conf 的內容,
導致 mkinitrd 不能產生 initrd.img,
其實要產生 initrd.img 只要 mkinitrd -o /boot/initrd.img.[version] [version]
就可以了,[version]代表了/lib/modules/[version] 存在的你安裝的核心的版本號碼.
根本不用手動修改 mkinitrd.conf,除非你想使用ramfs :)
簡單做法:
ln -s /usr/src/linux-2.6.10 /lib/modules/2.6.10
mkinitrd -o /boot/initrd.img-2.6.10 2.6.10
這樣子就可子產生出 initrd.img 了 :)
Mount initrd.img
mount -t cramfs -o loop /boot/initrd.img-2.6.10-1-k7 /mnt/tmp
cat /mnt/tmp/modules
看看有沒有哪些 moudles 沒有載入. 趕快加到 /etc/mkinitrd/modules
再重新 gen 一次 initrd.img :)
最主要是 巧用TMPFS加速Linux伺服器 這篇讓我最感興趣 :)
典型的 tmpfs 文件系統會完全駐留在 RAM 中.
sudo mkdir /dev/shm/tmp
sudo chmod 1777 /dev/shm/tmp
sudo mkdir /ram
sudo mount --bind /dev/shm/tmp /ram
以後開機記得執行最後那 mount --bind /dev/shm/tmp /ram 就可以了.
以下轉載自 幫Linux掛Turbo加速
I. 使用hdparm開啟DMA
加安裝完hdparm後輸入以下設定開啟DMA
hdparm -d1 -X69 -c3 -m16 /dev/hda
在這-X69是開啟UltraDMA mode5,64~69依序是mode0~mode5
II. 進入X前將XF86Config-4中的font關掉一些
我只留下以下內容
FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/CID"
FontPath "/usr/lib/X11/fonts/misc"
FontPath "/usr/lib/X11/fonts/75dpi/:unscaled"
FontPath "/usr/lib/X11/fonts/Type1"
III. 使用tmpfs加速
詳細懶的再打,請參考 巧用TMPFS加速Linux伺服器
以下轉載自: 巧用TMPFS加速Linux伺服器
作者:張微波 發文時間:2004.05.18
今天學了一招,就是使用tmpfs,我把他消化後用來實現虛擬磁片來存放Squid的緩存文件和PHP的Seesion。速度快不少哦!
默認系統就會載入/dev/shm ,它就是所謂的tmpfs,有人說跟Ramdisk(虛擬磁片),但不一樣。象虛擬磁片一樣,tmpfs可以使用您的 RAM,但它也可以使用您的交換分區來存儲。而且傳統的虛擬磁片是個塊設備,並需要一個 mkfs 之類的命令才能真正地使用它,tmpfs 是一個文件系統,而不是塊設備;您只是安裝它,它就可以使用了。
tmpfs有以下優勢:
1. 動態文件系統的大小
2. tmpfs 的另一個主要的好處是它閃電般的速度。因為典型的 tmpfs 文件系統會完全駐留在 RAM 中,讀寫幾乎可以是瞬間的。
3. tmpfs 數據在重新啟動之後不會保留,因為虛擬記憶體本質上就是易失的。所以有必要做一些腳本做諸如載入,綁定的操作。
好了講了一些大道理,大家看的煩了吧,還是講講我的應用吧:)
首先在/dev/stm建個tmp文件夾,然後與實際/tmp綁定
mkdir /dev/shm/tmp
chmod 1777 /dev/shm/tmp
mount --bind /dev/shm/tmp /tmp
squid的緩存目錄設置
vi /etc/squid/squid.conf
修改成
cache_dir ufs /tmp 256 16 256
這裡的第一個256表示使用256M記憶體,我覺得高性能LINUX雙效防火牆HOWTO使用Ramdisk的方法還不如直接使用tmpfs,至少每次啟動不用mkfs,還可以動態改變大小。
然後重啟一下服務,ok,現在所有的Squid緩存文件都保存倒tmpfs文件系統裏了,很快哦。
對php性能的優化
對於一個訪問量大的以apache+php的網站,可能tmp下的臨時文件都會很多,比如Seesion或者一些緩存文件,那麼你可以把它保存到tmpfs文件。
保存Seesion的方法很簡單了只要修改php.ini就行了,由於我已經把/dev/stm/tmp與/tmp綁定,所以不改寫也行,至於PHP程式產生的緩存文件那只能改自己的PHP程式了:)
以下轉載自 RamDisk for BSD
昨天發現在Linux上可使用tmpfs來掛turbo,那BSD呢?我的Server是使用FreeBSD,照理來說RamDisk對於improve server performance比較有效果,因此今早search相關Ramdisk for BSD,找到BSD也support這樣的東東可幫BSD掛turbo^^。
首先要先將kernel中的memory disk功能打開
device md # Memory "disks"
再來將修改/etc/fstab加入下面這行來產生128M的/tmp
md /tmp mfs rw,-s128m 0 0
重開機後就完成了,記得如果有run server的要將tmp的link指到/tmp喔(default是都指到/tmp,但慎重起見還是自行檢查吧!),以下是我用df -h出現的md device
/dev/md0 126M 5.9M 110M 5% /tmp
*由於我的FreeBSD是5.x版本,似乎只能使用以上方式加入mfs,如有興趣可參考以下的link
I. ONLamp.com: BSD Tricks: MFS
II. BSDForum.org: Ramdisk?
III. unable to mount swap backed device
參考文件: 在Linux下使用RamDisk
XMMS 都是用 GTK 1.x 寫的, beep-media-player 用 GTK 2.x 來寫.
主要是還支援 UTF-8 的編碼.
Skins: /usr/share/bmp/Skins
可以用跟 XMMS 一樣的 Skins :)
本文最新 url: Apache 壓力測試
在 apache 本身的套件中, 有個叫 ab(ApacheBench) 的程式.
ApacheBench 主要是用來測試 apache 執行效率.
ab 參數:
Usage: /usr/sbin/ab [options] [http[s]://]hostname[:port]/path
Options are:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make
-t timelimit Seconds to max. wait for responses
-p postfile File containg data to POST
-T content-type Content-type header for POSTing
-v verbosity How much troubleshooting info to print
-w Print out results in HTML tables
-i Use HEAD instead of GET
-x attributes String to insert as table attributes
-y attributes String to insert as tr attributes
-z attributes String to insert as td or th attributes
-C attribute Add cookie, eg. 'Apache=1234' (repeatable)
-H attribute Add Arbitrary header line, eg. 'Accept-Encoding: zop'
Inserted after all normal header lines. (repeatable)
-A attribute Add Basic WWW Authentication, the attributes
are a colon separated username and password.
-P attribute Add Basic Proxy Authentication, the attributes
are a colon separated username and password.
-X proxy:port Proxyserver and port number to use
-V Print version number and exit
-k Use HTTP KeepAlive feature
-d Do not show percentiles served table.
-S Do not show confidence estimators and warnings.
-g filename Output collected data to gnuplot format file.
-e filename Output CSV file with percentages served
-s Use httpS instead of HTTP (SSL)
-h Display usage information (this message)
ex: 要執行 1000 次的 connection, 20 次的 concurrent (並行, 同時).
語法: ab -n 1000 -c 20 http://localhost/abc.php
產生出來的結果. 主要要注意的是以下幾個.
Time taken for tests: 總共執行花了多久的時間.(以上 1000 次共多久)
Requests per second: 每秒平均可以處理多少個 connection.
Debian Kernel Compile HowTo
Debian-Kernel-Compile-Howto (Kernel 2.6)
Debian and the kernel
LINUX KERNEL 2.6 HOWTO
2.6.8核心編譯全過程
make kernel 小記.
cd /usr/src
tar xvfj kernel-source-2.6.10.tar.bz2
ln -s /usr/src/kernel-source-2.6.10 /usr/src/linux
patch -p1 < /path/to/kernel/patch
sudo make menuconfig
# 看最下面要一定要選的東西(must choose)
cd /usr/src
make-kpkg buildpackage -rev Custom.1 kernel_image
# 製作 inirtd.img
sudo ln -s /usr/src/linux-[version] /lib/module/[version]
mkinitrd -k -o /boot/initrd.img-2.6.10 -r /dev/hda5 2.6.10
dpkg -i kernel-image-[version]_Custom.1_i386.deb
must choose:
Compressed ROM File System Support (cramfs)
Ram Disk Support
Initial RAM Disk (initrd)
VGA 16 Color Graphics Suport
Vesa VGA Graphics support
Framebuffer Console Support
Bootsplash Screen
make-kpkg buildpackage -rev Custom.1 kernel_image
於 /etc/apt/source.list
加入 deb http://debian.linux.org.tw/pub/apt unstable main
apt-get install scim-chewing scim-tables-zh(為了有一般注音可以用)
只要安裝 scim-chewing 就可以有新酷音可以用了..
新酷音詞庫的準確度.. 完全是 M$ 的 新注音所不能比的.
不過.. 還是卡在一般注音.. 不知道如何取消掉聰明的自動把常用字排到前面去的功能..
字的順序如果亂跳.. 就會發生常打錯字的情況~ 嘆... :(
安裝參考:
scim - DebianWiki
http://www.linux.org.tw/~andrew/scim-chewing/
Realplayer 10 for Linux
然後下載 .bin 之後, chmod +x Realplayer.bin
./Realplayer.bin 就可以安裝了..
通常應該路徑都設到 /usr/share/RealPlayer/ :)
Magic C++ - The Visual Remote Linux-Unix C-C++ IDE under Windows
根本就是 Virsual C++ 嘛!..
當然也是相對 Virsual C++.. 這個要花錢買才行~
Debian -- Debian-Installer
Debian ISO 檔 Download 位置
http://cdimage.debian.org/pub/cdimage-testing/daily/
Current: http://cdimage.debian.org/pub/cdimage-testing/daily/i386/current/
突然發現到每次想要灌 Debian 時. 都要抓 ISO 檔時都還要去找..
特別是現在都想要直接灌 sarge 的版本.(安裝介面做的比較漂亮).
每次都要努力的找~~ 還是直接記下來會比較快一點~ :p
Gnome 2.8 裝好後預設瀏覽器是 epiphany.
但是我還是喜歡用 Firefox., 所以就要想辦法改囉~
運氣好馬上找到這一篇 預設使用 Tabbed Browsing.
Gnome 官方軟件的預設瀏覽器 可以在"桌面偏好設定 -> 進階 -> 首選應用程式" 設定,
只要在 網頁瀏覽器" 的分頁中選取 "自選網頁瀏覽器"
,並在指令欄填上 "/usr/local/bin/x-tabbed-www-browser %s" ,再按關閉即可。
這篇文章還有要如何讓新開的視窗開在分頁等等. 有空再研究吧 :)
使用mysqlhotcopy熱備份MySQL資料庫
為了找這個東西.. 不小心找到剛剛貼的兩個好站 ~~
不過總算找到我要的東西了~~ XD
以下內容轉載自: 使用mysqlhotcopy熱備份MySQL資料庫
一提起mysql的備份,大家最多想到的就是mysqldump,不過導成文字檔案雖然便於存放,但是速度很慢的。最快的備份方法自然是直接把資料 目錄copy一份了。但是一般來說,都要關閉MySQL的服務才能做,不然在你copy的時候剛好還有人讀寫表那麻煩就大了。下面簡單介紹一下我試用 mysql自帶的熱備份工具mysqlhotcopy的一些心得。~
我是用root用戶完成備份操作的。(是不是應該使用mysql用戶來做操作更安全一些?待嘗試)
首先要在root的home目錄下建立一個.my.cnf檔,以便讓mysqlhotcopy從中讀取用戶名/密碼。
[mysqlhotcopy]
user=root
password=YourPasswordGoesHere
然後安全起見,chmod一下。
chmod 600 ~/.my.cnf
mysqlhotcopy可以把執行的操作記錄入資料庫中,所以我建立了下面這個DB/Table:
CREATE DATABASE `dbinfo`;
USE dbinfo;
CREATE TABLE `checkpoint` (
`time_stamp` timestamp(14) NOT NULL,
`src` varchar(32) NOT NULL default '',
`dest` varchar(60) NOT NULL default '',
`msg` varchar(255) NOT NULL default '',
PRIMARY KEY (`time_stamp`)
) TYPE=MyISAM;
然後建立一個備份目錄。如果不指定備份目錄,mysqlhotcopy會在原來的位置備份(Redhat下面是/var/lib/mysql/),只不過目錄名後面加上了 _old 這個尾碼。
好了一切準備妥當,測試一下:
mysqlhotcopy --checkpoint dbinfo.checkpoint --addtodest db_douzi_org /var/db_backup
簡單說明一下:
--checkpoint dbinfo.checkpoint 這個是指定存放操作記錄的資料庫/表
--addtodest 增量備份,新的備份自動覆蓋掉原來的
db_douzi_org 我要備份的資料庫名,如果有多個,依次寫就行
/var/db_backup 備份目錄
下面是我一次執行的輸出:
Locked 34 tables in 0 seconds.
Flushed tables (`db_douzi_org`.`mt_author`, ...) in 0 seconds.
Copying 102 files...
Copying indices for 0 files...
Unlocked tables.
mysqlhotcopy copied 34 tables (102 files) in 0 seconds (0 seconds overall).
我這個資料庫很小,才1MB多,我另外測試了一個186MB的資料庫,完成也只用了8秒的時間,效率很高。
恢復資料庫也很容易,直接把目錄cp到MySQL的資料庫目錄就可以了,Redhat下面是/var/lib/mysql/。
但是請注意,mysqlhotcopy剛剛被發現有一個嚴重的漏洞,我原來所使用的4.0.20版本也不幸中彈,趕快升級到4.0.21版本吧。
mysqlhotcopy的功能遠比我上面簡單介紹的強大,比如支持正則運算式的表名等等,詳細的請看mysqlhotcopy的兩個文檔,後者要詳細一些。在Linux下可以直接運行"perldoc mysqlhotcopy"查看。
From mysql.com
From perldoc.com
TO-DO: 下一步通過crontab做一個定期備份,還要學習一下:P
經過 Roy Chan 大大的提醒.
http://debian.linux.org.tw/pub/apt/pool/main/s/scim-chewing/
下班後再來試試這個套件.
大大的這篇文章 SCIM 的「速成」輸入法 點到了我現在遇到最大的問題.
"關了『動態調整』,選字的次序保持和 Windows 一樣。 "
看起來... 有機會捨棄掉 xcin 了.. 晚點測試完再來寫寫心得好了 :)
ChineseInformationProcessing
這篇文章有各種輸入法在哪維護.(含語音輸入法)
還有非常多關於輸入法. 中文拼字. 等等的介紹.
How to make Debian support chinese
正好看到這一篇... 看來中文化真是越來越棒了~~
這一篇好好看一看.. 就會知道 Linux 中文化時流程和一些基本流程為何要這樣做~
有問題時比較知道是哪邊沒設定好...
而且內容
3.1 安裝 SCIM 智能通用输入法平台
3.2 為 SCIM 安裝速成輸入法 (可略過)
3.3 為 SCIM 安裝倉頡第三代 (可略過)
3.4 為 SCIM 安裝酷音輸入法 (可略過)
這個應該會符合不少人的需求~ (可惜我不習慣讓他幫我選字)
不過這篇要看清楚
"本文只適用於 Debian GNU/Linux 3.1 (Sarge) 或以上版本 (不適用於 Woody) 。 "
不過.. 現在拿 Xwindow 來當 Desktop 的 應該不會有人用 stable 的吧.. XD
Debian GNU/Linux 完美中文桌面設定指南
ChineseInformationProcessing(Debian Wiki)
ChineseInformationProcessing(所有中文字碼、輸入法)
gcin gcin - Debian Wiki
用了 SCIM 後發現 xcin 的介面輸太多了(SCIM 好漂亮).
只不過 SCIM 有很多東西還是用不習慣. 包括自動選字得要手動.
Ctrl + Space 注音碼都還留在上面等問題. 還是先繼續用 xcin 好了...
找了一些東西.. 看起來 gcin 也蠻不錯的 :)
Adobe推出支援Linux的Acrobat 7
看這篇新聞.. Acrobat 跟 Yahoo 合作還蠻密切的樣子~ :)
參考: Adobe Finally Releases Adobe Reader 7.0 for Linux
tarball 檔下載
rpm 檔下載
以下轉載自: Adobe推出支援Linux的Acrobat 7
Adobe Systems已經推出第7版的Acrobat軟體,當中包括所有升級的功能,和專為Linux設計的免費Adobe Reader 7測試版。
5日上市的Acrobat Version 7有兩種版本,299美元的標準版可供大多數使用者製作PDF檔(可攜式文件檔),499美元的專業版增加若干高階功能。此外,Adobe也決定將Acrobat Reader改名為Adobe Reader。
使用第7版,免費的Acrobat Reader可用來加入註腳和修改PDF檔 – 只要原始的PDF作者允許並使用專業版。這項作法的目標是,讓Adobe軟體在類似表格或採購訂單等電子文件的交換上,發揮更大用處。
Acrobat 7專業版還包括出版技術文件,如結構和工程文件的升級。Adobe在這個領域面臨製圖軟體商Autodesk的挑戰。
Adobe也在同日推出其LiveCycle Policy Server軟體,機關組織可藉此管理使用者閱讀、修改、列印、儲存或寄出的PDF文件。該軟體售價5萬美元。
Adobe Reader 7推出Linux測試版並不意外,該公司在Linux桌面系統的動作日漸積極,並且曾為Acrobat Reader 5推出Linux版,但跳過第6版。
Adobe表示,使用者對Adobe Reader最主要的抱怨 – 在網頁瀏覽器下載PDF檔的龜速 – 已經獲得解決。公司發言人John Cristofano說:「(新版)下載的速度的確比Adobe Reader 6快很多。」大多數的情況下只需1秒至2秒。
去年10月雅虎(Yahoo)與Adobe宣布結盟,新的Adobe Reader 7因而附有阻擋彈出式視窗和搜尋功能的雅虎工具列,但僅支援IE。
完整版的Acrobat Reader 7有19.8MB,雅虎工具列另加0.5MB。若選擇下載Adobe的Photoshop Album 2.0入門版用來管理數位相片,還要增加6.5MB的空間。(陳智文)
最近開發的輸入法實在太多了.. 從最早期的 XCIN 到 IIIMF. SCIM..
又一堆有的沒的~~ 選字等等越來越聰明.. 介面也越來越漂亮..
看了下面這篇文章.再談 SCIM.
讓我有點小心動.. 來換換 SCIM 看看 ~ :)
(這篇文章下面的 link 都非常有用)
先收集一些 SCIM 的資訊吧~~~
這種大型的轉換.. 通常都會蠻痛的... 多些準備比較好 :)
Debian SCIM 套件、安裝步驟解說.
Blog of Roy Chan
有關scim的問題
scim怎麼自動啟動
順便看到之後轉換 UTF-8 時可以參考的資料 - Unicode
================================
完整安裝步驟:
以在本機使用中文輸入為例:
root@debian# apt-get install scim scim-tables-zh
然後 XMODIFIERS 這個環境變數要更改(可能在 ~/.xinitrc 或是其它類似的檔案中, 或是手動執行)
export XMODIFIERS="@im=SCIM"
再來在 xwindows 中執行 scim 就可以囉! (也可以放在 ~/.xinitrc 一類的檔案中, 或是像 gnome 可以用 "作業階段" 指定執行)
user@debian$ scim -d
PHP Opcode Cache
eAccelerator:Home
Gea-Suan Lin's BLOG - PHP Accelerator
Gea-Suan Lin's BLOG - mmcache
PHP 加速器.. Turck MMcache 已經停止不動了. :(
Linux Client Migration Cookbook A Practical Planning and Implementation Guide for Migrating to Desktop Linux
Download pdf
不錯的電子書~
Abstract
The goal of this IBM Redbook is to provide a technical planning reference for IT organizations large or small that are now considering a migration to Linux-based personal computers. For Linux, there is a tremendous amount of “how to” information available online that addresses specific and very technical operating system configuration issues, platform-specific installation methods, user interface customizations, etc. This book includes some technical “how to” as well, but the overall focus of the content in this book is to walk the reader through some of the important considerations and planning issues you could encounter during a migration project. Within the context of a pre-existing Microsoft Windows-based environment, we attempt to present a more holistic, end-to-end view of the technical challenges and methods necessary to complete a successful migration to Linux-based clients.
Table of Contents
Part 1 Choosing Linux
Chapter 1. Introduction
Chapter 2. The case for migration
Part 2 Planning the pilot migration
Chapter 3. Organizational and human factors planning
Chapter 4. Technical planning
Part 3 Performing the pilot migration
Chapter 5. Migration best practices
Chapter 6. Client migration scenario
Chapter 7. Integration how-tos
Part 4 Appendixes
Appendix A. Using enterprise management tools
Appendix B. Application porting
Appendix C. Desktop automation and scripting
Appendix D. Client personalization
Shorewall: iptables Made Easy
Shorewall Firewall
Three-Interface Firewall
iptables 這樣子設起來應該會輕鬆很多~
tcsh 改~/.cshrc
* 遠端登入時能打出中文
setenv LC_CTYPE is_IS.ISO_8859-1
* console下能打出中文
setenv LANG zh_TW.Big5
bash 改~/.bashrc
export LC_CTYPE=it_CH.ISO_8859-1
Chewing / 新酷音: 智慧型注音輸入法發展總部
記得用過一次酷音.. 很聰明.. 蠻好用的 ..
不過多少還是會有些錯字(但是比微軟新注音實在是好上百倍了)..
可惜的就是.. 我還是習慣自己選字.. 自己選字打起來才快呀... :)
以下轉載自: Chewing / 新酷音: 智慧型注音輸入法發展總部
最早的酷音輸入法是台大資工系的龔律全與陳康本兩人的資訊專題,其成果選擇以 GPL 授權釋出,可說是 XIM 中最接近新注音或是自然輸入法的實作,詳情可參閱龔律全所撰寫的技術報告。
但是酷音輸入法的兩位原創者已不再維護,後續的發展由許多熱心的朋友移植到不同的平台上,諸如 TimHsu 維護的 JMCCE 內建酷音輸入法、clkao 移植酷音到 MacOS X 與 IIIMF 架構,以及 gugod 接手 clkao 的 ChewingOSX 後,大幅改善實作的 SpaceChewing 計畫等。而新酷音就是扮演整合這些分支的角色,並且更廣泛移植與改良酷音輸入法的適用性,並且於 2004 年 12 月有獨立的專案資源,期待更多的朋友參與。 而新酷音是由 jserv 所維護。
Chewing 系列的輸入法已經慢慢取代普通注音了。
各大在台灣的社群也有負責提供相關套件,如 deb, ebuild, rpm 等。
關於更多,請參考: http://chewing.csie.net
dpkg的用法:
-S 顯示特定檔案所屬的套件名稱 dpkg -S /etc/samba/smb.conf
-i 安裝套件 dpkg -i
-P 完全移除某一個套件 dpkg -p samba
-l 顯示已經安裝的套件 dpkg -l
-L 顯示某一個已安裝的套件的檔案名稱及安裝路徑 dpkg -L samba
-p 顯示已安裝套件的詳細訊息 dpkg -p samba
-s 查詢系統是否安裝了某一個套件 dpkg -s samba
How to copy & convert linux root file system
FreeBSD 系統備份
Linux & FreeBSD 系統備份~~ :)
除了以上之外.. 還有其他的方法..
以下轉載自 g4u 幫您做硬碟映像檔還原
g4u 代表 ghost for unix 之意.
g4u 是一個使用軟碟或光碟開機的還原軟體, 可以透過 FTP 幫您複製大量 PC 硬碟. g4u 的開機碟可以用來上傳硬碟的映像壓縮檔至 FTP Server, 然後由其它欲複製的 PC 下載還原. 網路的設定透過 DHCP 完成. 由於 g4u 是以映像檔為處理單元, 因此, 幾乎任何檔案系統, 任何作業系統, g4u 都可以適用. 使用者可以複製整顆硬碟, 也可以只複製分割區.
g4u 網址: http://www.feyrer.de/g4u/
目前最新版是 12/04 推出的 2.0 穩定版.
另外的作法是.. 全部都 tar 起來就對了... XD
Sun Solaris 10 終於 Release 了,有興趣的人可以下載來玩玩看!
下載網址:http://www.sun.com/promotions/solaris10download/
非商業使用應該是免費的!
感謝作者提供的資訊.. 不過短時間我應該還是好好把 Linux 玩好就好了 :)
突然發現 資訊隨筆 BLOG 這個 Blog 蠻棒的~~ :)
squid 一些比較難搞懂的參數..
來做做筆記~~ 才不會忘記~~ :)
refresh_pattern 參數
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
refresh_pattern . 4320 100% 5040 ignore-reload
$1: ^ftp (ftp 開頭的) , . (全部)
$2: min time (最小到期時間 單位: 分)
$3: (max time - min time) * $3 (超過這段時間的資料一次更新多少)
$4: max time (最大到期時間 單位: 分)
$5: ignore-reload 略過 reload 的需求
若 $3 設 100% 就代表是要在 時間到的時後. 將這些資料全部更新.
若 $3 設 20% 就代表是要在 時間到的時後. 將這些資料的前 20% 更新.
Jail in FreeBSD 5.3
Jail 是一套類同 chroot 一樣.. 等於是在自己的電腦裡面再弄台電腦~~
現在的電腦一台確實可以當三台來用沒什麼問題 ~ :)
還是盡量要跟之前的模式長一樣比較好看~
於是於 .bashrc 設定
PS1='\u@\h:\e[32m\w\e[0m$ '
\e <-- 控制碼的意思.
\e[32m 綠色 \e[0m 回復正常顏色.
參考以下網址:
照這個做就對了~ BashPrompt
Linux 終端機下的彩色顯示: 有那些顏色可以選擇呢?
彩色的命令行 —— 使用 ANSI 色彩代碼
突然覺得好久沒有用過 pine .. 有種懷念感...
想說裝來懷念一下..沒想到 pine 居然是 non-free... XD
安裝方法如下網址:
Debian PINE PICO HOWTO
pine 安裝方法簡述:
apt-get install pine-tracker
# apt-get --only-source build-dep pine
# apt-get --only-source -b source pine
# dpkg -i pine
這樣子就安裝完成了 :)
為何要這樣子做呢?.. 以下參考一下
Debian 教學手
Debian 參考手冊-把套件引入 stable 系統
照以上的安裝方式.. 就可以輕易的裝好 螢火飛的字型唷~~~ :)
以下轉載自 : 螢火飛相關套件安裝
wget http://firefly.idv.tw/apt/firefly-font/fireflysung.ttf.gz
#下載內嵌點陣字的文鼎新宋字型
gunzip fireflysung.ttf.gz
#解壓縮
cp fireflysung.ttf /usr/share/fonts/truetype
#複製到「/usr/share/fonts/truetype」資料夾
fc-cache -f -v
#建立字型訊息 cache 檔案
wget ftp://ftp3.tnc.edu.tw/b2d/firefly/firefly.sh
#下載 firefly.sh
chmod +x firefly.sh
#增加執行權限
./firefly.sh
#執行
再重新啟動 Xwindow
字型設定都選 AR PL New Sung 10點字就可以了 :)
在 debian 架設 awstats
apt-get install awstats
ln -s /usr/share/awstats/icon/ awstats-icon
設定一下 /etc/awstats/awstats.conf
主要是設 SiteDomain="" 這行要設定自己的 domain name
再加 cron.
0 0 * * * /usr/lib/cgi-bin/awstats.pl -update -config=ip位址 > /dev/null
就可以在這邊看到了 http://yourhostname/cgi-bin/awstats.pl
# W - For a web log file
# S - For a streaming log file
# M - For a mail log file
# F - For a ftp log file
LogType=W 可以設定想要分析哪種 Log.
# 1 - Apache or Lotus Notes/Domino native combined log format (NCSA combined/XLF/ELF log format)
# 2 - Old IIS log format (IIS W3C log format). See FAQ for IIS 6.x.
# 3 - Webstar native log format.
# 4 - Apache or Squid native common log format (NCSA common/CLF log format)
# With LogFormat=4, some features (browsers, os, keywords...) can't work.
LogFormat=1 (apache log 設定 combined 就是最完整的 Log)
也可以自行定義自己想要的分析檔內容.
看要不要分析有人來亂的~~ 不過耗的系統效能蠻高的 ~
# 0 disables Worms detection.
# 2 reduces AWStats speed by 15%
LevelForWormsDetection=2
Mysql Table 大小的限制是 4Gb.
如果超過了這個限制的時後該怎麼辦??..
參考以下兩個地方的說明吧~~ :)
Overcoming MySQL's 4GB Limit
The table is full
GNOME-Look.org MacOS-X Aqua Theme
Gnome MacOS-X Aqua 的 Template. 太漂亮了~~
一定要抓下來用用~~ :)
Gnome-Look
這個站提供 Gnome 桌布、ICON 還有一堆有的沒的~~ 可以美化你的桌面~~ :p
還是喜歡用 Xwindow ~~~ :p
從 Eason's Blog 看到好東西~~ :p
轉錄自 GDB (GNU Debugger)
網路上一些有關GDB的文章
I. Debugger with GDB (入門篇)
II. Linux Software Debugger with GDB
III. Mastering Linux Debugging Techniques
IV. KGDB (Kernel Source Level Debugger)
V. 用GDB調試程序
轉載自: 清除linux上firewall的規則, 還原成原始狀態
要清除先前的設定, 必須執行下面幾個指令:
$>iptables -F # => 清除所有規則
$>iptables -X # => 清除使用者自訂的項目
$>iptables -Z # => 記數器歸零
本文最新網址位於 Debian 設定 開機啟動
Debian 跟 Redhat 有點小小的不同..
主要的是開機的時後, Redhat 有 rc.local 可以設定..
Debian 沒有 rc.local. 所以設定的時後.. 有兩種方法.
1. 設定 /etc/init.d/rcS
2. update-rc.d -n nat start 93 2 3 4 .
建議是用第二種方法.. 還能夠用 rcconf 來管理.
詳細參考可見 如何新增一個自己的/etc/rc.d script ?
簡單的介紹一下 mrtg 架設 ~~
在下面用最簡略的方法來介紹~~~ :)
(以 Debian 為主)
如果自己有架設 snmpd..
將 /etc/snmpd/snmpd.conf
裡面直留一行 rocommunity public
其它全部不留 ~~~ :)
沒架設 snmpd 也一樣能跑 mrtg..
只要你的機器上游有 snmp 的功能~ :)
Debian 下 apt-get install mrtg 即可完成~
現在主要以 ADSL 為例~~
ADSL 的那台小烏龜的 IP.. 內部在連都是 192.168.1.1
所以我們在設定也很簡單~~ :)
這個動作會產生 /etc/mrtg.cfg 的設定檔
cfgmaker --output=/etc/mrtg.cfg public@192.168.1.1
vi /etc/mrtg.cfg
於 ### Global Defaults 下面加入
Options[_]: growright, bits
Language:big5
然後執行 mrtg /etc/mrtg.cfg 三次 (前兩次會有一堆 Message 不要管他)
再來 (建立 index.html)
indexmaker --output=/var/www/mrtg/index.html \
--title=主機流量統計表 \
/etc/mrtg.cfg
crontab 再設一下
*/5 * * * * /usr/bin/mrtg /etc/mrtg.cfg
每 5 分鐘跑一次.. 這樣子就完成囉~~ :)
http://domain/mrtg/ 就可以看到結果了~~
來分享一下系統備份用的 Script.
把下面的 Script 存成一個 file 後..
寫寫 Crontab...
# 看系統大概何時最閒.. 就給他做這個吧~ :)
crontab -e
0 3 * * * /path/backnow
簡略就如下..
#!/bin/sh
today=`date "+%Y-%m-%d"`
#olddate=`date -v-10d "+%Y-%m-%d"`
olddate=`date -d "-10 day" "+%Y-%m-%d"`
cd /path/
/bin/tar -zcvf etc-$today.tar.gz /etc/
/usr/bin/mysqldump --all-databases --user=root --password="passwd" > mysql-$today.sql
rm -rf etc-$olddate.tar.gz
rm -rf mysql-$olddate.sql
Hiweed-Debian GNU/Linux
最近有一堆的 Live CD 出現...
好像都是 knoppix 改版出來的...
這一套的 Xwindow 是以 Xfce 為主... :)
PUD GNU/Linux
是一個朋友所自己創造的 Linux 新的版本...
基本上跟 knoppix 一樣.. 或該說是直接改 knoppix 而創造出來的~ 詳閱
而這 Live CD 裡面包的 程式清單 也是非常簡潔.. 希望別再多下去了..
裡面 DosBox - DOS 模擬器,離不開仙劍或 Liero 嗎? 這個東西倒是蠻吸引我的.. XD
看起來作者似乎蠻喜歡 Ion 這種簡單的環境.. :)
PUD Linux 的特色(轉載自 PUD Linux)
PUD 專案的主要開發者非常特立獨行而且憤世嫉俗,在興趣未失之前仍會激烈的改版開發,誰也沒把握它會變成什麼樣子。但有幾個主要特色絕不會偏離:
1. 完備 - 塞滿功能齊全的自由軟體,讓各種強力工具輕易滿足日常使用需求。
2. 輕巧 - 致力提供乾淨的操作介面,並盡可能選用小巧靈活的程式。
3. 簡約 - 每一版的 ISO 檔大小都不超過 180MB,可以燒進一張 8cm 的空白光碟裡。
PUD 還有一個特殊功能,只要你的 RAM 夠大 (至少60MB) 並且連上網路,執行 rapti,就可以在 LiveCD 上用 apt-get 安裝軟體。
這倒是蠻有趣的~~ :)
以下這些也是同樣轉載自 PUD Linux
下面這些是 Ion 的簡單教學~ (Xwindow)
Ion 的官方網站
視窗操作
Ion 是一套「以鍵盤為基礎」的視窗管理員。幾乎完全不必動到滑鼠,一般的工作就可以輕易完成。加上它善用螢幕空間、視窗不重疊的特性;輕巧的體積;超炫的介面,自然成為 PUD Linux 的首選。 GNOME、KDE 等整合環境與 Ion 相比,就像加了牛奶和果糖的大杯拿鐵對上濃縮咖啡。
以下是 Ion 的基本操作:
Alt + k, s => 左右分割新的視窗
Alt + s => 上下分割新的視窗
Alt + c => 關閉視窗
Alt + 滑鼠移動 => 調整視窗大小
要顯示「開始功能表」請按 F12;更多資訊請見「入門指南」或「重製說明」。
以下是 Ion 的一些常用熱鍵,如果你覺得不夠用,個人強烈建議讀過一遍 Ion 的使用說明;
F1 => 開啟 Ion 的使用說明 (manpage)
F2 => 開啟終端機 (x-terminal-emulator)
F3 => 執行 (Run) 你輸入的程式
F9 => 新增工作區 (workspace), type 可以試試 WFloatWS
滑鼠拖曳標頭 => 將程式移動至目標窗框
http://stud.sjsmit.edu.tw/procmailrc
寫的不少~~~ 看起來蠻好的~~ :)
不過要拿來用.. 信箱要丟地位置都要修改... 有點小累 :(
何謂IPMI
先來瞭解一下IPMI到底是什麼東西,IPMI = Intelligent Platform Management Interface,顧名思義,就是可以智慧型的來管理系統的一種標準,IPMI規格是在1998年由Intel、DELL、HP及NEC所共同提出的,它提供了一個可以跨平台的標準界面來監控系統內的一些狀況,如溫度、電壓、風扇等,並且可以藉由事件發送的形式來讓系統管理人員得知目前系統的狀況。
知道重要性了?.. 好好詳細看看吧~ :)
以下完整轉載自 跨平台系統管理的救星---IPMI之演變
跨平台系統管理的救星---IPMI之演變
專欄作者:朱宜振
發表日期:2004-10-15
版權聲明:本文授權自資策會推廣服務處,全文請見網路通訊雜誌第158期
跨平台系統管理的救星
IPMI之演變
前言:
機房裡跨平台系統的管理始終是一個可怕的惡夢,直到IPMI規格的誕生,才開始露出一線曙光。
內文:
對MIS人員來說,大型機房的有效管理一直是個管理上的夢魘,面對為數眾多、各式各樣的伺服器,要如何判斷哪些機器是否正常或者異常,在過去可能是到現場一台一台檢視;網路出現後,可透過各家廠商提供的遠端管理介面來檢視,但是卻一直沒有一個有效的方式可以管理這些數量眾多、甚至是跨平台的系統,尤其對於MIS人員來說,面對跨平台系統的管理更是一個可怕的惡夢。這些現象,直到IPMI(Intelligent Platform Management Interface)規格的誕生開始露出曙光。
何謂IPMI
先來瞭解一下IPMI到底是什麼東西,IPMI = Intelligent Platform Management Interface,顧名思義,就是可以智慧型的來管理系統的一種標準,IPMI規格是在1998年由Intel、DELL、HP及NEC所共同提出的,它提供了一個可以跨平台的標準界面來監控系統內的一些狀況,如溫度、電壓、風扇等,並且可以藉由事件發送的形式來讓系統管理人員得知目前系統的狀況。
2001年IPMI從1.0版改版至1.5版,主要增加了LAN、Serial/Modem、PCI Management Bus等系統管理的溝通介面,以及提供了Alerting的功能。到了2004年在Intel的開發者論壇(IDF)上正式發表了IPMI 2.0的規格,為IT使用者提供了更高的安全性,遠端伺服器主機畫面的監控(Console Redirection),並支援模組化刀鋒型伺服器(Blade Server)以及能夠向下相容IPMI 1.0及1.5的規格。
IPMI讓系統管理者能夠透過網路或者Serial的傳輸形式來監控系統上各種元件的健康狀況,如CPU的運作、風扇轉速、系統溫度及電壓等。管理者可以將要監控的部分,設定其感應的臨界值,在IPMI控制器感應不到正常狀況時,可以透過發email、送SNMP trap等來通知MIS人員處理問題。另外,藉由硬體及軟體的配合,IPMI增加了遠端管理及系統回復的功能,讓系統管理者可以在遠端得知系統目前是處於何種狀態,如關機、開機中、OS當機等,並且下達開機、關機和重新開機等命令。
輔助系統管理的好幫手
IPMI主要定義一般的規格部分,但在整個系統管理及實際的規劃上沒有去著墨。若單就IPMI這個點來看的話,其實可能會落於狹隘的觀點,於是在系統設計時,到最後出來的成品會發現,若我們只有管理一兩台系統時,內建的標準IPMI功能的確是系統管理者的好幫手,但是若到了大機房及跨平台的眾多系統呢?目前市場上眾多在提到IPMI的資料上均著重在解釋IPMI的規格及特色上,卻沒有去真正想到實際面上的應用。…(請見網路通訊雜誌第158期)
Flexbeta
所有功能都還有附縮圖.. 是個非常不錯抓 extensions 的站..
全都是Google 的 Google firefox extenstions http://googlebar.mozdev.org/
抓現在天氣、溫度的 extenstions Weatherfox
以下是 FREEDOM - Rongjun Mu's Blog 喜愛的 extenstions.
Firefox extensions I love
蠻不錯的.. 我應該也要找時間把自己喜愛的 extenstions 寫成這個樣子的東西.
firefox + sage => 可以來看 RSS news、BLOG... 等等..
下面這篇有簡單的教學.. :)
GMail's Atom feed, in Firefox and Liferea
剛剛貼了一篇 IBM小紅點滾輪使用(Windows) 的後..
理所當然 .. 有 windows 版.. 也一定要有 Linux 版囉.. :)
事實上這是我從自己的 讓小紅點的中鍵支援捲軸功能 這篇文章貼過來的..
因為這個困擾我太久了.. 一定要好好備份起來.. :p
要特別注意的是..
到 BIOS 中把 TouchPad 的功能 disable.
(不過這會造成 windows 無法使用小紅點唷!)
我的設定如下.
IBM notebook 通常都是開機按(F1 進入 BIOS)
1. 先到 BIOS 中把 TouchPad 的功能 disable.
(不過這會造成 windows 無法使用小紅點唷!)
之後如果要切換 Windows 都要進 BIOS 轉換 TouchPad 唷...
雖然有點麻煩.. 不過為了使用方便.. 比外接一隻滑鼠簡單多了說 :)
2. 之後設定 XF86Config-4 如下.
Section "InputDevice"
Identifier "Configured Mouse"
Option "CorePointer"
Driver "mouse"
Option "Protocol" "PS/2"
Option "Device" "/dev/psaux"
Option "Emulate3Buttons" "true"
Option "EmulateWheel" "yes"
Option "EmulateWheelButton" "2"
Option "ZAxisMapping" "4 5"
EndSection
Section "InputDevice"
Identifier "Mouse1"
Driver "mouse"
Option "SendCoreEvents" "true"
Option "Device" "/dev/input/mice"
Option "Protocol" "ImPS/2"
Option "Emulate3Buttons" "true"
Option "ZAxisMapping" "4 5"
EndSection
Section "ServerLayout"
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"
InputDevice "Mouse1" "SendCoreEvents"
EndSection
目前最新版的 Openwebmail 如果 enable_viruscheck 為 yes 的話..
收外部信的功能會有問題...
到 openwebmail.conf 把這個功能先關掉吧.. (改為 no)..
或者要收外部信時再關掉... XD
這功能主要是關掉 Amavis 的掃毒功能..
這個計畫最炫的應該就是他所提到這四點~~~
* 不需要知道如何才能完成一件工作
* 不需要知道電腦如何運行.
* 不需要知道要用那一隻程式.
* 不需要知道檔案名稱.
Pawn Download 這個連結也有 Screenshot 先看一下~~
看起來應該是輸入英文的需求.. 他自己會幫你找程式來用的意思~~
轉載自 : 大太陽底下絕對還有新鮮事! Open Pawn 計劃來了!
發表者 ols3 於 2004-10-19 11:16:19 (1369 人氣)
新聞短打
中譯: by OLS3 ( ols3 at lxer dot idv dot tw)
譯註:常言道: 大太陽底下沒有新鮮事! 但 Open Pawn 計劃可以!
過去以來,幾乎有四分之三的使用者使用 KDE 做為其桌面,雖然 GNOME 桌面在過去幾年大有長進,不過,KDE 很清楚的是商業客層使用者較穩定及成熟的桌面選擇。
這二個桌面並不是互斥的。所有的 GNOME 應用程式可以在 KDE 桌面中執行,反之亦然。大部份的發行套件都會預載二種桌面環境。所以啦只要您高興,您可以每天豪華地選用其中一種,每天把玩它。當然,在把玩的過程您不會自動完成任何工作的!
不過,這二種桌面所提供的功能,了無新意。圖型介面的桌面模式在當初全錄 XEROX 發明時就是這個樣子了,這些年來幾乎沒有長進多少。許多 Linux 社群中的人士說他們不想要另一個和 Windows 長得很像的桌面; 但有些人則並不反對這樣的作法。
在 2003 年,一個新的小型計劃誕生了。這個計劃的目標卻很大,它打算把桌面永遠的做一番變革。其中一個主要的目標是讓電腦能接受人類的自然語言喲! 當然這種事原以為只會發生在美式的電影情節,但誰知道將來呢?另一個目標,就是要把檔案系統的觀念丟掉! 使用者不必去煩惱之前的檔案在那裡?它又是屬於那一個目錄?
今天,這個計劃已改名為 Open Pawn 計劃,並且已推出 0.3 版喔! 這個計劃在它成為一個成熟可用的桌面環境前,還有一段好長的路要走。它的每一個項目幾乎都是創新原有桌面的觀念。
試想以下情節:
如果您在 Pawn 中,您 :
* 不需要知道如何才能完成一件工作
* 不需要知道電腦如何運行.
* 不需要知道要用那一隻程式.
* 不需要知道檔案名稱.
這表示任何人都可以在零知識的基礎下完成工作。Microsoft/KDE/GNOME 這些桌面環境從來也就沒有貼近過這種設計想法。下一版的 Microsoft 作業系統長角 Longhorn 甚至移除了其中最想要的一個功能: "可搜尋的檔案系統",而這個功能卻在 Pawn 0.2 版時就已經完成具備了。
一些小公司及非營利團體已經承諾將要支持 Pawn 桌面系統的發展,因為它獨樹一格、特異風格、而且全然刷新所有桌面舊思維。
未來 Pawn 如何發展,沒人可以預料,不過,可以確定的是,如果沒有開放原始碼社群的支持,Pawn 永遠也無法成功!
Open Pawn 計劃網址:
非常實用的問答~~
Ex: 查看系统信息
cat /proc/cpuinfo - CPU (i.e. vendor, Mhz, flags like mmx)
cat /proc/interrupts - 中斷
cat /proc/ioports - IO Port
cat /proc/meminfo - 内存信息(i.e. mem used, free, swap size)
cat /proc/partitions - 所有設備的分割區
cat /proc/pci - PCI 設備的訊息
cat /proc/swaps - 所有Swap 的訊息
cat /proc/version - Linux的版本號碼 同等於 uname -r
uname -a - 看系统核心的訊息
Gaim-Encryption: 即時通訊的簡易加密器
轉載自 : Gaim-Encryption: 即時通訊的簡易加密器
現在即時通訊(IM) 到處都是,不過如果您知道有心人士只要利用一些工具如 tcpdump、aimsniff 等就可以輕易截錄您的通訊內容的話,你可能會大吃一驚。目前市面上的即時通訊大多以明文傳訊,沒有做任何加密的動作,這種不安全的連訊方式,對個人隱私而言是一大缺點。
現在 Gaim-Encryption 可以幫您把關喔!
Gaim 是一款十分受到歡迎的即時通訊軟體,開放原始碼授權且支援眾多平台,能和各種 IM Server 連接,包括 AIM、Yahoo、MSN 以及 Jabber。
Gaim-Encryption 則是 Gaim 的一個 plug-in,它主要用來在即時通訊的過程中提供加密的機制,使您的溝通內容不易被人截取。安裝方法非常簡單。
詳情請參考:
Gaim-Encryption 網址:
http://gaim-encryption.sourceforge.net/
Linux Driver 是一個結合Wiki的站台,用來建構 Linux 硬體知識庫,
讓每個 Linux 使用者可能會遇到的惱人的硬體支援問題能夠在此獲得解決。
該計劃主持人對 Linux-Driver.org 這個站台有著高度的期許。
轉載自 : Linux Driver
本文最新版本 網路芳鄰samba, 查詢目前使用情況
轉載自: 我的linux有裝網路芳鄰samba, 想要知道目前的使用情況, 該怎麼做?
可以使用 smbstatus 這個指令
ex.
$>smbstatus -d
using configfile = /etc/samba/smb.conf
Opened /var/cache/samba/connections.tdb
Samba version 2.2.7a
Service uid gid pid machine
----------------------------------------------
opt jack jack 21841 angle (192.168.1.1) Wed Sep 15 11:43:17 2004
opt mary mary 7403 magic (192.168.1.2) Tue Sep 14 16:18:20 2004
No locked files
就會列出現在正在使用的使用者. 和連線主機名稱.
看來最近 Linux 又有不少有趣的東西了 :)
小畫家 tuxpaint 企鵝小畫家 附圖
整個桌面的企鵝 企鵝爬桌面! 好玩的小工具! 原網址
打字練習 gtypist 2.7 打字訓練軟體
這真是太棒了... 之前就覺得這套不錯用...
可惜就是遇到中文字會亂碼(中不中文化倒是沒什麼差別.. 秀出來的中文沒問題就好)
不過既然中文化了.. 中文字亂碼的問題應該會解決吧?.. XD
回去再裝裝看.. :)
gentoo 是一個輕快短小但功能強大的檔案總管,檔案總管已經有很多了,為何還要有 gentoo?作者認為多數檔案總管並不合他用,況他自己想要學習 gtk 的設計應用,所以就自已寫了一個。
gentoo 的長處是: 彈性極大,檔案卻很小,加上執行速度很快,是一款小而美的檔案總管。gentoo 可以讓您自訂這個檔案總管要有那些功能!!!
B2D 推出 gentoo 中文版,並把它包成 deb 檔。
下載:
ftp://ftp3.tnc.edu.tw/b2d/gentoo-big5/
安裝方法很簡單:
dpkg -i gentoo_0.11.46-1big5_i386.deb
執行法, 由 B2D 桌面的 "個人目錄" 進入即可。
又一套新的 Linux distribution 出來了...
看一看說明似乎還不錯的樣子....
雖然喜歡 Debian.. 不過每次升級倒是都蠻刺激的體驗(unstable)... :p
Ubuntu Linux
ps:
不過看到 Gnome 變 2.8 總是會想馬上使用說..
看起來好像還是 Debian 適合我... XD
轉載自: Ubuntu, a promising new Linux distribution
為什麼會有另一個Linux散佈版呢?"不是已經有足夠多的Linux版本了嗎"這應該是大家共同的想法吧。Ubuntu Linux是一個Linux的重要解答--一個自由而且是由論譠所驅動專注在初學者的版本,如果使用一個比較容易了解的講法,就是你可以把Ubuntu Linux想成Debian和Fedora的混合體。
新的Ubuntu Linux是根基於Debian unstable的版本,他們決定他們發佈的時間會和Gnome的發佈時間相同-6個月更新一次。這所代表的意思是說你可以得到一個相當穩定的系統而且裡面的軟體都不會多於6個月,而且還會有13000個軟體包(package)可以選擇,由此可見你可以想像這是一個多麼美的事物了吧。Ubuntu第一個發布的版本編號為4.10是由Warty Warthog所命名的,主要是根據發布那一天的日期2004年10月。
可以在不知道背景程式的Process ID下, 直接把程式砍掉嗎?
學學 killall 吧~~ :)
轉載自 LinuxCenter 電子報
以下 轉載自 LinuxCenter 電子報
可以在不知道背景程式的Process ID下, 直接把程式砍掉嗎?
可以使用 killall 這個! 指令
ex.
$>killall --help
usage: killall [ OPTIONS ] [ -- ] name ...
killall -l, --list
killall -V --version
-e,--exact require exact match for very long names
要求程序名稱完全吻合
-g,--process-group kill process group instead of process
刪除全組程序
-i,--interactive ask for confirmation before killing
在刪除前要求確認
-l,--list list all known signal names
列出所以已知的系統訊號
-q,--quiet don't print complaints
不列印訊息
-s,--signal send signal instead of SIGTERM
改用其他系統訊號代替 SIGTERM (終止程式) !
-v,--verbose report if the signal was successfully sent
列印執行結果
-V,--version display version information
版本
-w,--wait wait for processes to die
等待程序終止
假設我想要直接砍掉radiusd這支程式, 只要在killall後面加上程式名稱就可以了.
$>killall -v radiusd
Killed radiusd(21910) with signal 15
轉載自 GNOME 2.8 Desktop & Developer Platform
The GNOME 2.8 Desktop and Platform release is the latest version of the popular, multi-platform free desktop environment.
GNOME runs on a variety of platforms, including GNU/Linux (commonly called Linux), Solaris, HP-UX, BSD and Apple's Darwin. GNOME includes powerful features such as high-quality smooth text rendering and first class internationalization and accessibility support, including support for bi-directional text.
新功能導覽 What's New In GNOME 2.8
看看 Screenshots 吧~~ :)
Mmm... 又要準備升級了... XD
Tuning RedHat Enterprise Linux on IBM @server xSeries Servers
裡面的關念是所有 Linux Distribution 都共通的...
另外~~ 還有~ IBM Redbooks 也參考著看吧 :)
在執行中的程式.. 平常可以使用 Ctrl + z 暫停.. fg 回復...
但是已經下了 nohup 於背景執行該如何 暫停 和 回復 呢?
程序暫停 kill -STOP <processid>
恢復時用 kill -CONT <processid>
refer 功用 : 如果是從(Referrers)外部網站連結過來的時後, 會記錄是從哪邊來的...
ex: http://www.longwin.com.tw/~jon/blog/refer/
例如: 從 Tsung's BLOG 英文翻譯 過來
(這個網址可以幫 BLOG 的網站翻譯.. (雖然是照字翻譯. 不過很驚人了)
from 會記錄 de.staging.search.yahoo.com/language/translatedpag
從 google 過來會記錄 google.com.tw/search?hl=zh-tw&ie=utf-8&q=....
如果是直接連接就不會記錄唷 (ex: 把你的網站設為首頁 或 直接打網址進入網站的)
如果想要記錄就自己去 hack 一下 refer.php (記錄 "直接" 連接到網站的)
把 if ($ref!='' and $uri!='') {
改成 if ($uri!='') { 就可以了..
架設方法於深入再寫...
到 Textism 抓 refer 的 source code.
設定 /etc/apache/http.conf
<Directory $PATH>
AllowOverride ALL (可以設嚴緊一點. 像 AutoConfig 都行, 不會設的就設 ALL)
</Directory>
$PATH -> /var/www/html..... 等等.
再在 要記錄的目錄下
設 .htaccess
DirectoryIndex index.html index.htm index.php
AddType application/x-httpd-php .html .htm
php_value auto_prepend_file /home/jon/public_html/blog/refer/refer.php
php_value default_charset utf-8
再來設定 refer/refer.php (要記得去建資料庫)
$rcfg['sitename'] = 'Tsung\'s\ BLOG';
$rcfg['dexclude'][] = '~jon/blog/';
$rcfg['mydomain'] = 'longwin.com.tw';
$rcfg['tzoffset'] = 0; ( 原本為 6 .. 因為我們是用系統時間. 所以不用 +6 )
( 害我之前還自己去 hack 一下.. date("Y-m-d H:i:s"); (才發現有這個設定) )
時間格式自己挑 $rcfg['tformat'] = "M j - G:i a";
其它設定再自己去找囉 ~~~ :)
再多設 $rcfg['exclude'][] = 'refer'; (不然會 recervice)
有些黑名單的就不要記錄了. Refer 2.1 加上黑名單
然後執行 http://網址/refer/setupdb.php
執行完後記得 rm setupdb.php
就可以開始使用囉 :)
轉載自 Nvu 網頁設計工具
Nvu 可以算是 Linux 版的 Dreamwave 吧 :)
(雖然他還是有 Windows 的版本)..
Nvu 在 08/11 推出 0.41,這一版以 Mozilla 1.7 為基石。
下載位址:
http://www.nvu.com/download.html
關於 Nvu 請參考以前的報導:
http://free.tnc.edu.tw/modules/news/article.php?storyid=747
安裝時可能出現的問題. 於深入再探討..
在執行的時後都會出現以下的錯誤訊息..
./nvu-bin: error while loading shared libraries: libstdc++-libc6.2-2.so.3: cannot open shared object file: No such file or directory
於是 apt-cache search libstdc++
apt-get install libg++2.8.1.3-dbg
就可以啟動了.. :)
irssi 的 Perl Script
http://irssi.org/scripts/
(覺得 irssi 比 xchat 簡單.. 而且也好用多了~~)
irssi 中文設定
1. 進入 irssi 後輸入 /set term_type big5
2. 或在 /etc/irssi.conf 或 ~/.irssi/config 加
settings={"fe-text"={term_type="big5";}}
3. 還是有問題就 Ctrl + l (L) 營幕重繪看看..
用 irssi 進入irc 後..
下 /help set
[misc]
help_path = /usr/share/irssi/help
SET [-clear | -default] [
You can view or change the settings with /SET command.
/SET without any arguments displays all the settings. /SET
/SET
Boolean settings accept only values ON, OFF and TOGGLE. You can also use /TOGGLE command to change them, so /TOGGLE
Remember that changes are not saved until you use /SAVE!
Examples:
/SET autolog OFF - Sets value for setting 'autolog'
/SET close - Shows all settings whose variable name
contains 'close'. Very practical.
發現好東西~~~
/SET autolog OFF => 在各 chat 設 /SET autolog ON
這樣子就會在自己的目錄下 /irclogs/org/ 看到 log 了 :)
感覺跟 Openwebmail 很像.. 不過實際還沒用過...
改天有機會再裝來玩玩看.. :)
轉載自 Open-Xchange Server 將以GPL釋出
Open-Xchange Server 是和微軟 Exchange Server 同類等的軟體,將以 GPL 釋出,它是 Novell/SUSE Openexchange Server 的骨架引擎。
Open-Xchange Server 具模組化設計,具備標準的通訊工具,提供商業界高度彈性的群組軟體功能,包括電子郵件、行事曆、通訊錄、工作表以及文件儲存。
Open-Xchange Server 網址:
如果你寫了一份文件,需要用多種簡易的文件格式來呈現,如比 HTML、XHTML、SGML、LaTex 甚至 Unix 的 man pages,你要怎麼做才不會為了產生不同的格式,而使同樣一份文件要寫很多次?
txt2tags 是一支 python 程式,可以用一份來源文件,產生多樣的目標文件。
什麼是 txt2tags ?
說起來這應該是許多人的需求之一。
如果你寫了一份文件,需要用多種簡易的文件格式來呈現,如比 HTML、XHTML、SGML、LaTex 甚至 Unix 的 man pages,你要怎麼做才不會為了產生不同的格式,而使同樣一份文件要寫很多次?
txt2tags 是一支 python 程式,可以用一份來源文件,產生多樣的目標文件。
txt2tags 可以將 text 轉成
# HTML
# XHTML
# SGML
# LaTeX
# UNIX
# MoinMoin
# Magic Point
# PageMaker 6.0
txt2tags 網址:
http://txt2tags.sourceforge.net/
有關於 FreeBSD 的升級、架設 的好站(而且是中文的)
The FreeBSD NetWork Laboratory Studio.
CVSup系統升級(這篇是我最喜歡的,寫的真清楚)
以下的是從中抓取一些會用到的重點部份。
重點擷取:
1. FreeBSD 5.1 升級 5.2 步驟
2. CVSup系統升級 (這個最有用了,特別對於 初學FreeBSD 來說)
於此網頁中,這個批次檔也是非常實用。
CVSup升級程序批次檔(太棒了,為了怕遺失,於下面把這內容記下來)
#!/bin/sh
# -------------------------------------------------
# FreeBSD CVSup 的程序,完成之後,做 mergemaster 。
# -------------------------------------------------
clear
cd /usr/src
fetch ftp://freebsd.csie.nctu.edu.tw/pub/CVSup/cvsupfile-stable
/usr/local/bin/cvsup /usr/src/cvsupfile-stable
sync;sync;sync
initialize()
{
case "`echo 'x\c'`" in
'x\c') echo="echo -n" nnl= ;; #BSD
x) echo="echo" nnl="\c" ;; # Sys V
*) echo "$0 quitting: Can't set up echo." ; exit 1 ;;
esac
myprompt 'yYnN' " 是否繼續做CVSup.. (y/n)" "N"
if [ $answer = n ] || [ $answer = N ]
then
echo " 下回再來吧!.."
exit 0
fi
echo
}
myprompt()
{
answer="|"
until echo $1 | grep $answer >/dev/null
do
$echo "${2} [${3}]? ${nnl}"
read answer
if [ "$3" != "" ] && [ "$answer" = "" ]
then
answer=$3
fi
done
}
initialize
make buildworld
make buildkernel KERNCONF=GENERIC
make installkernel KERNCONF=GENERIC
make installworld
chmod u+s /usr/bin/sperl5
mergemaster -cpv
Linux Grub 設定 FreeBSD 開機
有三種方法.
先列測試過後確定可用的方法, 其它的於深入探討再看
Grub 的 menu.lst 中設定
title FreeBSD
rootnoverify (hdx,y)
chainloader +1
即可, FreeBSD 不用安裝開機管理程式.
1.
title OpenBSD
root (hd0,0)
makeactive
chainloader +1
2.
title FreeBSD
rootnoverify (hdx,y)
chainloader +1
3.
titile FreeBSD
root(hd0,x,y)
kernel /boot/loader
與 WinXP, Linux, FreeBSD 共存
XP (hd0,0)
Linux (hd0,1) /boot 即可
FreeBSD (hd0,2) 一定要在 primary 的磁區
完成:
title FreeBSD 5.2.1
rootnoverify (hd0,2)
chainloader +1
本文最新版本 hdparm參數
UDMA3(ATA33)
# hdparm -X66 -c1 -d1 -m16 /dev/hda
UDMA4(ATA66)
# hdparm -X68 -c1 -d1 -m16 /dev/hda
UDMA5(ATA100)
# hdparm -X69 -c1 -d1 -m16 /dev/hda
hdparm -tT /dev/hda 測硬碟速度
實際經驗:
shell# hdparm -tT /dev/hda
/dev/hda:
Timing cached reads: 264 MB in 2.01 seconds = 131.30 MB/sec
Timing buffered disk reads: 52 MB in 3.06 seconds = 16.98 MB/sec
shell# hdparm -d 1 /dev/hda
/dev/hda:
setting using_dma to 1 (on)
using_dma = 1 (on)
shell# hdparm -tT /dev/hda
/dev/hda:
Timing cached reads: 412 MB in 2.02 seconds = 204.40 MB/sec
Timing buffered disk reads: 52 MB in 3.01 seconds = 17.29 MB/sec
s31:/mnt/gentoo# hdparm -d 1 -A 1 -m 16 -u 1 -a 64 /dev/hda
/dev/hda:
setting fs readahead to 64
setting multcount to 16
setting unmaskirq to 1 (on)
setting using_dma to 1 (on)
setting drive read-lookahead to 1 (on)
multcount = 16 (on)
unmaskirq = 1 (on)
using_dma = 1 (on)
readahead = 64 (on)
shell# hdparm -tT /dev/hda
/dev/hda:
Timing cached reads: 468 MB in 2.01 seconds = 233.22 MB/sec
Timing buffered disk reads: 52 MB in 3.09 seconds = 16.82 MB/sec
OpenWebmail 被發現安全漏洞,攻擊者可利用該漏洞執行任何指令。
有問題的程式是 /cgi-bin/openwebmail/userstat.pl
快速解決:
52行左右.
請在 if ($user ne "") 之前一列加上:
$user =~ s/[\/\"\'\`\|\<\>\\\(\)\[\]\{\}\$\s;&]//g;
把攻擊者可能輸入的shell字元濾除即可。
本文取自
http://free.tnc.edu.tw/modules/news/article.php?storyid=1059
OpenWebmail 被發現安全漏洞,攻擊者可利用該漏洞執行任何指令。
有問題的程式是 /cgi-bin/openwebmail/userstat.pl
約在第 52 列位置,如下所示:
my $user = cookie('openwebmail-loginname') || param('loginname') || '';
my $playsound = param('playsound')||'';
my $html=qq|< a href="_URL_" target="_blank" style="text-decoration: none" >|.
qq|_TEXT_< /font >< /a >|;
if ($user ne "") {
my $status=`$ow_cgidir/openwebmail-tool.pl -m -e $user`;
# <-- $user is used in the system call
if ($status =~ /has no mail/) {
修補法:
請在 if ($user ne "") 之前一列加上:
$user =~ s/[\/\"\'\`\|\<\>\\\(\)\[\]\{\}\$\s;&]//g;
把攻擊者可能輸入的shell字元濾除即可。
OpenWebmail 版本 2.20、2.21、2.30 均受到影響,請儘速修補。最新的 current 版仍有條件地受到影響。
由於 userstat.pl 並非 OpenWebmail 執行期所必需,
您也可直接把它刪除,暫避漏洞。
消息來源:
http://sourceforge.net/forum/forum.php?thread_id=1072246&forum_id=108435
fluxbox 的桌布預設都是原始大小..
如果要讓他能自動變大或縮小到全營幕,就得要自己修改.
剛剛玩了一下,很輕易的就能修改出來。
預設 $HOME/.fluxbox/bsetbg
FULL="display -geometry 800x600 -window root"
TILE="display -window root"
CENTER="display -backdrop -window root"
DEFAULT="display -backdrop -window root"
修改成如下即可
FULL="display -geometry 800x600 -window root"
TILE="display -window root"
CENTER="display -backdrop -window root"
DEFAULT="display -geometry 1024x768 -window root"
EGroupWare 是一套非常強大的專案管理軟體,有行事曆、通訊錄、事件紀錄簿、fudforum(討論區)、專案管理、messenger(訊息傳遞)、sitemgr(介面排版)、polls(投票)、headlines(好站連結)。
專案管理(Project),微軟有出一套 Project,可以控制一堆程序,算是蠻不錯的程式,不過,這一套有了 Project 的所有特色,並發展出更多相關的功能,我覺得非常經典又好用的軟體,而且也都中文化了(連說明文件都有,且中文化了),萬分推薦。
原始站: http://www.egroupware.org/
Demo: Demo
說明文件: 說明文件下載
下載: Download
'bandwidthd' 可以用來追蹤並以圖型化、網頁化的方式,顯示你的 TCP/IP 網段中的使用狀況。
bandwidthd 圖型化是以網段中各自獨立的 IP 為對象,它可以不同的色彩來顯示 HTTP, TCP, UDP, ICMP, VPN 以及 P2P 協定的交通流量。
對於要看某一整個區域的流量狀況、各種協定跑有各種不同統計,是套非常不錯的軟體。
看看 Demo 吧~~
Linux 的備份非常的重要.. 下面連結的文章中.. 就介紹了一些方法..
不過最特別的是這篇的文章下方 benny 的討論發言.. 自己寫的 Php Script..
雖然我是沒用以下的這個 Php Script 來備份..(小弟是用 Bash Script 來備份)
不過.. 這個程式寫的很漂亮~~ 要好好保存下來~ :)
(Mmm... 不過還沒有測試過就是了.. :) )
此篇文章(程式)取自
http://free.tnc.edu.tw/modules/news/article.php?storyid=20&com_id=495&com_rootid=495&com_mode=threadcomment495 的討論發言區(benny 發表)
這是 benny 用 php 寫的備份 script
只需要依個人所需更改 $SOURCE_DIR 和 $EXCLUDE_D 最後再 chmod +x 就可以了。
如果要放 crontab,將 $ask = strtolower(read());
拿掉就可以了
#!/usr/bin/php -q
<?php
//Change The following two variables
$SOURCE_DIR = "/bin /boot /etc /home /lib /mnt /opt /root /sbin /tmp /usr /var";
$EXCLUDE_D = "/home/benny/mnt /usr/portage/distfiles";
//Stop here unless you know what you're doing
$EXCLUDE_DIR = explode(" ",$EXCLUDE_D);
$DEST_DIR = "/misc/backup";
$DATE = date("Y-m-d");
$FILE = "BACKUP-".$DATE.".tgz";
for ( $i = 0; $i < count($EXCLUDE_DIR); $i++ ) {
if ( !$EXCLUDE ) { $EXCLUDE = " --exclude=".$EXCLUDE_DIR[$i]; }
else { $EXCLUDE = $EXCLUDE." --exclude=".$EXCLUDE_DIR[$i]; }
}
$BACKUP = "tar -zcvf ".$DEST_DIR."/".$FILE." ".$SOURCE_DIR.$EXCLUDE;
function read() {
$fp = fopen("<a href="php://stdin%22" target="_blank">php://stdin"</a>,"r");
$input = fgets($fp,255);
fclose($fp);
return eregi_replace("\n","",$input);
}
echo "=-= System Backup =-=\nDESTINATION PATH: "
.$DEST_DIR."\nFILE: ".$FILE.
"\nExcluding: $EXCLUDE_D\n".
"\nProceed? [Y/n]: ";
$ask = strtolower(read());
if ( !$ask ) { $ask = "y"; }
if ( $ask == "y" ) {
echo "System Backup will start within 5 Secs\n";
for ( $i=0; $i<5; $i++ ) {
echo 5-$i."\n";
sleep(1);
}
echo "Initializing System Backup...\n";
shell_exec("echo Starting @ `date` >> backup.log");
shell_exec("echo Filename: $FILE >> backup.log");
shell_exec("$BACKUP");
shell_exec("echo Completed @ `date` >> backup.log");
}
else { echo "Aborted!\n"; }
?>
$HOME/.fluxbox/init
fluxbox 第一個讀的檔案就是這個 init 檔
修改他讀取的設定檔路徑. 讀自己目錄下的比較好.. :)
下面的 toolbar.widthPercent: 因為時間設定後. 中間會顯得太短.. 所以加長點..
修改以下
session.screen0.toolbar.widthPercent: 80
session.screen0.antialias: true
session.screen0.strftimeFormat: %m月%d日 星期%a %p %I:%M
session.styleFile: /usr/share/fluxbox/styles/Jon
session.keyFile: /home/jon/.fluxbox/keys
session.menuFile: /home/jon/.fluxbox/fluxbox-menu
$HOME/.fluxbox/keys
設定熱鍵.. 有以下的設定.. fluxbox 將會更好用許多...
參照自 man fluxbox (裡面有更詳細的參數)
#Key X11 Name
#Control, Strg Control
#Alt Mod1
#Super, Meta, Win* Keys Mod4
#Shift Shift
Mod1 Tab :NextWindow
Control Tab :PrevWindow
#Mod1 Shift Tab :PrevWindow
Control Mod1 F1 :Workspace1
Control Mod1 F2 :Workspace2
Mod1 F3 :Workspace3
Mod1 F4 :Close
Mod1 F5 :Workspace5
Mod1 F6 :Workspace6
Mod1 F7 :Workspace7
Mod1 F8 :Workspace8
Mod1 F9 :Workspace9
Mod1 F10 :Workspace10
Mod1 F11 :Workspace11
NONE F12 :MaximizeWindow
Mod1 F12 :ExecCommand import -w root ~/`date '+%Y-%m-%d-%H:%M'`.png
Mod1 F2 :ExecCommand crxvt -bg black -fg white
Mod1 c :Minimize
Mod1 m :RootMenu
英文叫 GNOME Onscreen Keyboards suite
簡單說.. 就是營幕小鍵盤.. (或者應該說是大鍵盤)
看起來很好玩.. 不過... 總覺得還有點醜...
等他漂亮點後再來玩.. :)
Tripwire 應該剛裝好機器就該裝這套了。
tripwire 就像是一個記憶資料庫(或說指紋資料庫),只要做過任何修改,都逃不出他的法眼。並且定期檢查。
以下是安裝步驟:
1. apt-get install tripwire
2. 會要輸入要加密的密碼(Global 和 Local 的),包含確認(密碼)共要輸入 4次. 密碼要自己記好呀~
3. tripwire --init (初始化. 並編碼), 執行後要輸入密碼
4. 再來修改 twpol.txt 加入要另外做指紋驗證的目錄(加入 www 和 www設定檔目錄),因為 www 完成後就不太會做更動了,所以一起列入偵測
5. 執行編碼動作, 將 twpol.txt 和 twcfg.txt 做編碼,編成 tw.pol 和 tw.cfg
twadmin -m P /etc/tripwire/twpol.txt (編碼)
5. 執行 tripwire -m i 建立指紋資料庫
6. tripwire -m c --interactive 檢查 並更新指紋資料庫 (預設會進入vi編輯模式)
(簡化 tripwire -m c -I), :q 結束後 會請您再輸入一次密碼。
7. 記得定期執行 第 5 點,(但應該不用列入 crontab 中, 他自己每天會執行並回報),我們要做的是要幫他更新資料庫而已。
8. 建議刪除 /etc/tripwire/*.txt
Ps:
若之後還要修改到 twpol.txt, 則修改完成必須 重新建立資料庫 如下
/usr/sbin/twadmin -m P /etc/tripwire/twpol.txt
/usr/sbin/tripwire -m i
參考網站:
http://main.rtfiber.com.tw/~changyj/linuxtips/html/tripwire-easy.html
http://liy.slat.org/study/tips/tripwire.htm
突然想到來做做擋信.
信箱使用 clamav 來掃毒. 再用 procmail 來擋信.
有點怕從此收不到信.. XD
procmail 擋信 的建制部驟如下:
0. 事前準備
# 自動升級用
wget ftp://ftp.tnc.edu.tw/Sysop/MAIL/procmail/up-procmailrc.sh
# 擋信規則下載
wget ftp://ftp.tnc.edu.tw/pub/Sysop/MAIL/procmailrc
# mv dot.procmailrc /home/$user/.procmailrc
wget ftp://ftp.tnc.edu.tw/pub/MAIL/spam-filter/dot.procmailrc
1. vi /etc/postfix/main.cf
mailbox_command = /usr/bin/procmail
2. 自動抓取過濾信的機智
/usr/bin/wget -O /etc/procmailrc ftp://ftp.tnc.edu.tw/Sysop/MAIL/procmailrc
若要包含自己的擋信規則.
則再設 /etc/my.procmailrc
並於 /etc/up-procmailrc.sh 中加入(粗體部份)
if [ -f /usr/bin/wget ]; then
/usr/bin/wget -O /etc/procmailrc ftp://ftp.tnc.edu.tw/Sysop/MAIL/procmailrc
cd /etc
cat procmailrc my.procmailrc > procmailrc.tmp
mv -f procmailrc.tmp procmailrc
else
echo "Hey man,I can not find any wget stuff in your box."
fi
3. crontab -e
# 每週一的 Am 6:30 會執行自動抓取的動作(crontab -e)
30 6 * * 1 /root/up-procmailrc.sh
4. 看 Log 檔. 看有那些信件已經被擋掉了..
vi /var/log/procmail.log
5. 可再於自己的目錄下弄 .procmailrc
設定 黑白名單 (那些名單的一定不會過濾)
且可將擋掉的信件直接丟到 mail/mail-trash (使用 OpenWebmail 的話)
被擋掉的信可於 OpenWebmail 的垃圾桶中找到. 再看要不要砍掉.
6. 怕 log 擋太大
cd /etc/logrotate.d/
vi procmail
內容如下
/var/log/procmail.log {
monthly
size=10M
rotate 5
nocompress
}
參考以下網站:
http://linux.tnc.edu.tw/techdoc/use-procmail.html
http://linux.tnc.edu.tw/techdoc/postfix-howto.htm
http://free.tnc.edu.tw/modules/news/article.php?storyid=832
http://free.tnc.edu.tw/modules/news/article.php?storyid=823
http://www.securityfocus.com/infocus/1593
http://www.antony.idv.tw/tech/linux1/42syslog.html