2011年11月11日 星期五

使用中文

reference:
http://razorcap.com/site/devblog/?p=719

2011年10月14日 星期五

Cacti - step by step


1. sudo apt-get install apache2
2. sudo apt-get install php5 libapache2-mod-php5 php5-mysql php5-gd php5-cli
3. sudo /etc/init.d/apache2 restart
4. sudo apt-get install mysql-server mysql-client phpmyadmin
5. sudo apt-get install cacti
6.

mysql -u root -p cacti < pa.sql

modify config.php

2011年10月12日 星期三

Install Cacti

The best way to install Cacti 0.8.7g to Ubuntu

1. apt-get install cacti
2. Download cacti 0.8.7g-1 in i386 (Release) and install it

Install net-snmp

1. get the source code from net-snmp web site
2. untar
3. sudo apt-get install libperl-dev
4. ./configure
5. make
6. sudo make install
7. move to home directory
8. echo export LD_LIBRARY_PATH=/usr/local/lib >> .bashrc

test:
1. close the window
2. open a terminal window
3. snmpget --version
 

Install RRDTool

apt-get install rrdtool

2011年8月12日 星期五

Add user into sudo list

1. #sudo -s
2. #chmod u+w /etc/sudoers
3. #visudo 在root ALL=(ALL) ALLZ下 添加xxx ALL=(ALL) ALL
4. save
5. #chmod u-w /etc/sudoers

2011年4月26日 星期二

/etc/inittab 設定

轉貼
/etc/inittab 設定
init process
init 是在核心 mount 進 root 後,第一個執行的程式 (第一個 process),init 所負責的工作包括:
  • 執行 /etc/rc.d/rc?.d/ 裡的 scripts
  • 將系統由開機狀態 (boot-up state) 切換至多使用者狀態 (multiuser state)
  • 負責載入 tty (本地端) 的 login shell
  • 負責開機與關機的程序 (procedure)。
開 機完成後,init 仍會保持在背景執行,並同時監視與修改系統執行狀態。init 監視許多系統的動作,適時改變系統的狀態,這些動作定義在 /etc/inittab 檔案裡。系統狀態劃分成七個等級,稱之為 run level,/etc/inittab 即告訴 init,在不同的 run level 下所要執行的程式與命令,Linux 下的 run level 有共七個,分別為:
  • run level 0 關機
  • run level 1 單一使用者模式
  • run level 2 多使用者模式(沒有NFS)
  • run level 3 多使用者模式
  • run level 4 保留
  • run level 5 X11
  • run level 6 重開機
以 Red Hat Linux 的 /etc/inittab 為例
不正確的 /etc/inittab 設會使得系統不正常,而且無法登入,所以修改 /etc/inittab 前請先做好備分,/etc/inittab 的設定如下:
#
# inittab This file describes how the INIT process should set up
# the system in a certain run-level.

#
# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
# Modified for RHS Linux by Marc Ewing and Donnie Barnes

#
# Default runlevel. The runlevels used by RHS are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)

# 

id:3:initdefault:

# System initialization.

si::sysinit:/etc/rc.d/rc.sysinit


l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6



# Things to run in every runlevel.

ud::once:/sbin/update



# 處理 [ctrl]-[alt]-[del] 的按鍵
ca::ctrlaltdel:/sbin/shutdown -t3 -r now



# 如果我們有 UPS,這一行的設定會在斷電時通知我們,並在 2 分鐘後自動關機。 
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"



# 如果在關機前恢復電力,則放棄關機。
pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"





# 用來登入系統 (本地端)。
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6



# gdm 程式。
x:5:respawn:/etc/X11/prefdm -nodaemon
每個欄位所代表的義意如下:
  • 第一個欄位,是 init 內部使用的名稱,用來辨認每一個項目,執行命令 "ps ax" 所看到的名稱。
  • 第二個欄位,表示這個項目的 run level。
  • 第 三個欄位,關鍵字欄位,其中 respawn 是一個重要的關鍵字。以 "5:2345:respawn:/sbin/mingetty tty5" 為例說明,init 會依據設定,在本地端開啟一個終端機,當這個終端機超過時間沒有人 login 或太久沒有按鍵時,這個終端機就會結束執行,respawn 即在告訴 init 再重新執行這個終端機,否則,在一段時間後,我們會發現這個終端機消失了,無法利用 [alt]-[f5] 切換終端機。
  • 第四個欄位:要執行的命令與參數
第一行的 "id:3:initdefault:" 是很重要的一行,用來告訴 init,預設的 run level,在這裡我們設定開機後的預設 run level 為 3,那麼下面設定的命令都會被執行:
l3:3:wait:/etc/rc.d/rc 3

ud::once:/sbin/update
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
第二個如果是空白,則表示在所有的 run level 都會執行,例如:
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
表示在按下 [ctrl]-[alt]-[del] 的事件發生時,在所有 run level 狀態下,都會去執行/sbin/shutdown -t3 -r now 的命令。這一欄也可以指定多個 run level,例如:
6:2345:respawn:/sbin/mingetty tty6
表示在進入 run level 2/3/4/5 時,都會執行 "/sbin/mingetty tty6"。
改變 run level
如果我們將預設 run level 改為 5:
id:3:initdefault:
那麼:
x:5:respawn:/etc/X11/prefdm -nodaemon
這一行便會生效,"/etc/X11/prefdm -nodaemon" 的命令就會被執行,也就是我們熟悉的gdm。
我們可藉由 telinit 指令來改變目前的 run level,例如在 run level 3 狀態下執行:
linux# telinit 5
就會馬上進入 run level 5,執行 gdm。在 gdm 下如果想回到 console 模式,可以按下[ctrl]-[alt]-[f1],後然再執行:
linux# telinit 3
即可。

/etc/fstab 的用途

轉貼
/etc/fstab 的用途
/etc/fstab 是設定分割區與 mount 目錄關係的檔案,開機時會依這個檔案的內容 mount 檔案系統,mount 檔案系統的命令為:
linux# mount -av
會依 /etc/fstab 的內容 mount 進除了 root 以外的所有檔案系統。
root 是在開機時由核心所 mount 進來的。root 先由核心 mount 成 read-only,然後由使用者手動 remount 成 read-write。
/etc/fstab 設定格式
一個簡單的 /etc/fstab 設定範例如下:
#Device mount point filesystem type option
LABEL=/ / ext2 defaults 1 1
/dev/sda5 /home ext2 defaults 1 2
/dev/cdrom /mnt/cdrom iso9660 noauto,owner,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner 0 0
LABEL=/usr /usr ext2 defaults 1 2
none /proc proc defaults 0 0
none /dev/pts devpts gid=5,mode=620 0 0
/dev/sda7 swap swap defaults 0 0 
每個欄位所代表的義意為:
  • device 指定分割區
  • mount point 指定要 mount 目錄
  • filesystem type 指定檔案系統,比較常用的檔案系統有:
‧ msdos
‧ vfat
‧ nfs
‧ swap
‧ ext2
使用這些檔案系統前,請先確認核心是否支援,要知道目前核心的狀態支援那些檔案系統,可以查看 /proc/filesystems:
ext2
nodev proc

iso9660
nodev devpts
nodev usbdevfs 
表示目前核心支援 ext2/proc/iso9660/devpts/usbdevfs 的檔案格式,其中proc、devpts 與 usbdevfs 前面有一個 nodev 關鍵字,表示這二個檔案系統其實是存在記憶體中的,並非真正存在於儲存裝置中。
  • option 設定參數,如果我們要 mount 的是硬碟的分割區,不管是什麼檔案系統,只要設定為 defaults 即可。
  • 第一個數字,0 或者空白表示不要 dump,1 表示要 dump,dump 是用來將系統備份到磁帶機的指令,備份時,如果想要略過這個分割區,在一欄填 0 即可,如困2這一欄是 1 的話, dump 時就會備份這個分割區。
  • 第 二個數字,是設定當系統有不正常關機情形時,要如何檢查這些檔案系統。首先 fsck 會依序檢查這一欄為 1 的檔案系統,然後同時檢查這一欄為 2 的檔案系統,0 或者空白的話表示不做檢查。一般而言,只會將 root 設定為 1,其它都設定為 0 或 2。一些特定的檔案系統,像是 swap、iso9660、nfs、proc 都設定為0。
proc 是比較特殊的檔案系統,/proc 其實是存在於記憶體中的,/proc 裡的檔案紀錄了目前系統的狀態,藉由觀察這裡面的檔案我們可以得知許多系統的資訊。
例如,要檢查目前 swap partition 的狀態可以查看 /proc/swaps:
Filename Type Size Used Priority
/dev/sda7 partition 136512 4648 -1 
最後舉個例子,例如為電腦新增了一顆硬碟,然後切出了一個 /dev/sdb8 的 partition,並且想將這個 partition 做來做 ftp 的 home,這時就要在 /etc/fstab 裡加上一行:
/dev/sdb8 /home/ftp ext2 defaults 1 2

Install rsyslog

Step 1 - Download Software

Step 2 - Run ./configure

Step 3 - Compile

Step 4 - Install

Step 5 - Configure rsyslogd

 Rsyslogd understands stock syslogd syntax, so you can simply copy over /etc/syslog.conf to /etc/rsyslog.conf.

Note since version 3 rsyslog requires to load plug-in modules to perform useful work (more about compatibilty notes v3). To load the most common plug-ins, add the following to the top of rsyslog.conf:

......

 

Step 6 - Disable stock syslogd

In almost all cases, there already is stock syslogd installed. Because both it and rsyslogd listen to the same sockets, they can NOT be run concurrently. So you need to disable the stock syslogd. To do this, you typically must change your rc.d startup scripts.

Step 7 - Enable rsyslogd Autostart

This step is very close to step 3. Now, we want to enable rsyslogd to start automatically. The rsyslog package contains a (currently small) number of startup scripts. They are inside the distro-specific directory (e.g. debian). If there is nothing for your operating system, you can simply copy the stock syslogd startup script and make the minor modifications to run rsyslogd (the samples should be of help if you intend to do this).
In our Debian example, the actual scripts are stored in /etc/init.d. Copy the standard script to that location. Then, you need to add a symlink to it in the respective rc.d directory. In our sample, we modify rc2.d, and can do this via the command "ln -s ../init.d/rsyslogd S10rsyslogd". Please note that the S10 prefix tells the system to start rsyslogd at the same time stock sysklogd was started.

 

Step 8 - Check daily cron scripts

Most distributions come pre-configured with some daily scripts for log rotation. As long as you use the same log file names, the log rotation scripts will probably work quite well. There is one caveat, though. The scripts need to tell syslogd that the files have been rotated. To do this, they typically have a part using syslogd's init script to do that. Obviously, the default scripts do not know about rsyslogd, so they manipulate syslogd. If that happens, in most cases an additional instance of stock syslogd is started (in almost all cases, this was not functional, but it is at least distracting). It also means that rsyslogd is not properly told about the log rotation, which will lead it to continue to write to the now-rotated files.
So you need to fix these scripts. See your distro-specific documentation how they are located. Under most Linuxes, the primary script to modify is /etc/cron.daily/sysklogd. Watch for a comment "Restart syslogd" (usually at the very end of the file). The restart command must be changed to use rsyslogd's rc script.
Also, if you use klogd together with rsyslogd (under most Linuxes you will do that), you need to make sure that klogd is restarted after rsyslogd is restarted. So it might be a good idea to put a klogd reload-or-restart command right after the rsyslogd command in your daily script. This can save you lots of troubles.

 

2011年2月18日 星期五

setup the source of update manager

系統 / 管理 / synaptic 套件管理程式 / 設定 / 套件庫
(System / Administration / Synaptic package manager --> Settings / Repositories)

ubuntu 軟體來源 / 下載自:這一行最右方 有一個小小的倒三角形 按一下
(Ubuntu Software / Download from)

選其它 / 選擇最佳的伺服器
(Other... / Select best server)


開始從全球 3百多個 伺服器中選擇跟你的網路回應速度最快的伺服器
選好以後 按選擇伺服器 你可以看到 最好的伺服器 已列名在 下載自:這一行的右方
按關閉
按 重新載入 / 標記所有升級 / 套用
就開始 更新

ftp client

filezilla

  1. 把 filezilla3/bin/ 目錄下的檔案放在 /usr/local/bin 下(sudo mv filezilla3/bin/* /usr/local/bin/)。
  2. 把 filezilla3/share/ 目錄下的檔案放在 /usr/local/share/filezilla 目錄下(sudo mv filezilla3/share/filezilla /usr/local/share/)。
  3. 然後在 /usr/share/applications 下新增一個 filezilla.desktop 的檔案,內容如下:
    [Desktop Entry]
    Encoding=UTF-8
    Name=Filezilla 3
    Comment=Filezilla FTP Client
    Exec=filezilla
    Icon=/usr/local/share/filezilla/resources/filezilla.png
    Terminal=false
    Type=Application
    Categories=Application;Network;

Unix下常用壓縮格式的壓縮與解壓縮方法

  • .tar.bz2
解壓:tar jxvf FileName.tar.bz2
壓縮:tar jcvf FileName.tar.bz2 DirName
  • .tgz
解壓:tar zxvf FileName.tgz
壓縮:未知

2011年1月26日 星期三

羊角村交通

交通
羊角村距離阿姆斯特丹約 120 公里,坐火車到 Amersfoort 換車, 到Steenwijk下車。出Steenwijk車站後左前方即可看到公車站牌。轉公車 No.70 在 Ds T O Hylkemaweg (Giethoorn)下車,一小時一班車,站排上時間表表示週六週日沒有公車,所以盡量不要在週六週日安排至羊角村

公車下車後,往前走約30公尺左轉約30公尺,在右手邊就可以看到 VVV (Informaiton center),(在附近有一個超市),看到VVV 左轉約50公尺就可以看到河道,右轉沿著河道就可以看到租船,一直走到底約1.5公里,就是羊角村的步行觀光區域,與走來得路線成一個 T 字型。

2011年1月4日 星期二

ubuntu ncurses

According to http://packages.ubuntu.com/dapper/libdevel/

We can find
lib32ncurses5-dev (5.5-1ubuntu3) [universe]
Developer's libraries for ncurses (32-bit)
==> sudo apt-get install libncurses5-dev

VNC 自動登陸於 ubuntu

I have found a workaround for this issue on 10.04.
Open up Applications->Accessories->Passwords and Encryption Keys
Right click Passwords:login and unlock it.
You should be able to expand the tree and find a listing for vino. Right click and delete it.
Close Passwords and Encryption Keys.
Open gconf-editor as and navigate to /desktop/gnome/remote_access
Enter in your BASE64 encoded password into the vnc_password key.
Save the config and close the editor.
Reboot and you can now use your VNC client to connect to your machine without being first prompted with the keyring.

http://edmullen.net/mozilla/moz_base64.php

2011年1月3日 星期一

Fedora VNC

1. System - Preferences - Remote Desktop
2. Sharing
    --> Enable "Allow other users to view your desktop"
3. Security
    --> Disable "You must confirm each access to this machine"
    --> Enable "Require the user to enter this password:" and input a password
4. vi /etc/sysconfig/iptables
    --> Add "-A INPUT -m state --state NEW -m tcp -p tcp -- dport 5900 -j ACCEPT"
5. issue "service iptables restart"

Network proxy

1. System - Preferences - Network Proxy

2. For apt-get
     export http_proxy=http://172.19.67.126:3128
     export ftp_proxy=http://172.19.67.126:3128