Recent Articles / Archives

Ubuntu 安裝 terminus 及 Fixedsys 字型

平日使用電腦習慣在終端機及寫程式時使用 terminus 字型,而以 plain 閱讀電郵則喜歡 Fixedsys 字型。但 Ubuntu 安裝也這兩種字型也沒有,以下是安裝以上兩種字型的方法:

安裝 terminus
在終端機打入以下指令即可:

sudo apt-get install xfonts-terminus

安裝 Fixedsys
fixedsys 下載 fixedsys 的 ttf 檔,解壓後將 Fixedsys500c.ttf 複製到 /usr/share/fonts/truetype/,指令如下:

sudo cp /path/Fixedsys500c.ttf /usr/share/fonts/truetype/
sudo fc-cache -f -v

這樣就可以使用 terminus 及 Fixedsys 字型 了。

February 11, 2009 · Linux / BSD 筆記 · Comments (1)

Linux Memory Management

好文推介,介紹 Linux 的記憶體管理:

Memory management is the heart of operating systems; it is crucial for both programming and system administration. In the next few posts I’ll cover memory with an eye towards practical aspects, but without shying away from internals. While the concepts are generic, examples are mostly from Linux and Windows on 32-bit x86. This first post describes how programs are laid out in memory. Each process in a multi-tasking OS runs in its own memory sandbox. This sandbox is the virtual address space, which in 32-bit mode is always a 4GB block of memory addresses.

Anatomy of a Program in Memory

January 28, 2009 · Linux / BSD 筆記 · No Comments Yet

重新設定 MySQL root 密碼

如果忘記了 MySQL 的 root 密碼,可以透過以下方法重新設定:

1. 停止 MySQL server。

# /etc/init.d/mysql stop

2. 啟動 MySQL server,並加上 –skip-grant-tables 參數,便可以略過輸入密碼的過程:

# mysqld_safe –skip-grant-tables &

3. 用 root 連接到 MySQL server,輸入:

mysql -u root

4. 進入 MySQL server 後,輸入以下幾行 SQL 語句:
mysql> use mysql;
mysql> update user set password=PASSWORD("newpass") where User=’root’;
mysql> flush privileges;
mysql> quit

5. 重新啟動 MySQL 即可。

January 26, 2009 · Linux / BSD 筆記 · No Comments Yet

透過 Linux 恢復 Windows 系統管理員密碼

如果忘記了 Windows 的 administrator 密碼,可以透過 Linux 的 Live CD 進行恢復,而這裡會使用 Ubuntu 作為例子:

1. 使用 Ubuntu Live CD 開機

2. 安裝一個名為 “chntpw” 的程式

$ sudo apt-get install chntpw

3. 安裝 “chntpw” 後,便要將 Windows 的 NTFS 分割區掛載。

4. 進入 Windows 分割區下的 system32/config 目錄,然後輸入:

$ sudo chntpw SAM

5. 出現了一堆訊息後,系統會提示 reset 密碼,如果想設成空密碼,可以輸入星號 *,重新開機後便可以進入 Windows。

January 22, 2009 · Linux / BSD 筆記 · Comments (1)

Ubuntu 8.10 安裝 Java

安裝 Ubuntu 後系統預設沒有安裝 Java,以下是安裝方法:

$ sudo apt-get install sun-java6-jre sun-java6-plugin

安裝後再設定 Firefox 成支援 java

$ sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.10/jre/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/firefox/plugins/
January 21, 2009 · Linux / BSD 筆記 · No Comments Yet


只針對檔案或目錄 chmod

在 Unix Like 環境可以用 chmod 改變檔案或目錄的權限,以下方法可以只針對檔案或目錄 chmod:

1. 在當前目錄下遁迴 chmod 檔案:
find . -type f -exec chmod 0600 {} \;

2. 在當前目錄下遁迴 chmod 目錄:
find . -type d -exec chmod 0755 {} \;

January 21, 2009 · Linux / BSD 筆記 · Comments (1)

改變需要勇氣,投進 Linux 桌面懷抱

由剛開始用電腦開始已經使用 Windows,那時好像是 Windows 3.x 的版本,至今已經十幾年。雖然這段時間也有使用 Ubuntu 及 EeePC,但主要的作業系統還是 Windows,原因可能是因為沒有改變的勇氣。

一般上我的工作也是寫程式及管理主機,全都可以在 Linux 下完成,上個月買了一個新硬碟來灌 Ubuntu,將在 Windows 下面的資料複製到新硬碟後,直接將裝有 Windows 的硬碟拆除,免得自己想開 Windows。 但裝有 Windows 的硬碟也要留著,只怕在什麼時候真的要開個 Windows,手邊又沒有的話就麻煩了。

到目前的情況是進展良好,證實我的工作是全部在 Linux 下完成,只是自己不願作出改變。

January 20, 2009 · Linux / BSD 筆記 · No Comments Yet

Ubuntu 9.04 將會支援 Ext4 filesystem

新一代的 Ext 檔案系統 Ext4,而 Ubuntu 的下一個版本 9.04 也會支援。而 Ext4 在上個月發佈的 Linux kernel 2.6.28 正式被納入。Ext4 的設計提供更佳的效能及可靠度,而檔案系統可支援的容量相應增加到 1 exabyte,及縮短 fsck 所須的時間。

Linux 硬件網站 Phoronix 公佈了基於 Ext4 的效能測試報告,最突出的是 IOzone 測試對大型檔案的寫入效能,結果顯示效能比 XFS, JFS, ReiserFs 及 Ext3 都大幅領先。

January 14, 2009 · Linux / BSD 筆記 · Comments (1)

Linux 系統管理員輕鬆工作技巧

列出 10 個系統管理員的小技巧:

There are thousands of tricks you can learn from someone’s who’s an expert at the command line. The best systems administrators are set apart by their efficiency. And if an efficient systems administrator can do a task in 10 minutes that would take another mortal two hours to complete, then the efficient systems administrator should be rewarded (paid more) because the company is saving time, and time is money, right?

The trick is to prove your efficiency to management. While I won’t attempt to cover that trick in this article, I will give you 10 essential gems from the lazy admin’s bag of tricks. These tips will save you time — and even if you don’t get paid more money to be more efficient, you’ll at least have more time to play Halo.

Lazy Linux: 10 essential tricks for admins

January 13, 2009 · Linux / BSD 筆記 · No Comments Yet

“service httpd does not support chkconfig” 問題

在 Redhat 上面使用編譯的方式安裝 Apache 後,將 bin/apachectl 複製到 /etc/rc.d/init.d/ 目錄,並想用 chkconfig 將 Apache 設定成自動啟動,但出現了 "service httpd does not support chkconfig"。

解決方法是開解 /etc/rc.d/init.d/httpd (或 /etc/init.d/httpd),在第二行加入以下兩句:

# chkconfig: 2345 10 90
# description: Activates/Deactivates Apache Web Server

這樣就會將 httpd 強制支援 chkconfig。

December 11, 2008 · Linux / BSD 筆記 · No Comments Yet


FreeBSD 編譯核心問題

今日將數台 FreeBSD 主機重新編譯核心,修改完 config 後,make buildkernel 成功沒有問題,但當執行 make installkernel 時便出現以下錯誤:

ERROR: Required audit group is missing, see /usr/src/UPDATING

看一看 /usr/src/UPDATING 沒有什麼作用,還是要靠 Google。解決方法是加入一個 audit 的 group,指令為:

pw group add audit
November 18, 2008 · Linux / BSD 筆記 · Comments (1)

檢查 IP 連線數量及封鎖 IP

以下是幾條有用的指令,檢查 IP 連線數量及封鎖 IP

iptables -A INPUT -p all -s IPHERE/32 -j DROP

封鎖 IP

iptables -D INPUT -p all -s IPHERE/32 -j DROP

解除封鎖 IP

netstat -atnp -A inet | grep ":80" | awk -F " " '{print $5} ' | awk -F ":" '{print $1}' | sort | uniq -c | sort -nr | head -5

列出最多連接數的 5 個 IP 及其連接數,其中 ":80" 是連接埠號,可改成想要檢查的埠號。

netstat -nap | grep ESTABLISHED | wc -l
netstat -nap | grep SYN | wc -l
netstat -nap | grep TIME_WAIT | wc -l

以上 3 個指令可以列出總連線數目。

October 2, 2008 · Linux / BSD 筆記 · Comments (4)

wget 下載密碼保護檔案

wget 是很好用的 command line 下載工具,如果遇到需要密碼才可以下載的檔案,wget 的選項 –user=username 及 –password=password 便可解決,這兩個選項支援 HTTP 及 FTP 連線,用法也很簡單:

$ wget –user=username –password=’password’ http://address/download/foo.pdf
May 6, 2008 · Linux / BSD 筆記 · Comments (1)

FreeBSD 安裝 MRTG 流量分析

MRTG 是一套網路流量分析工具,可以經由網頁介面監看主機的網路流量。MRTG 是透過 SNMP (Simple Network Management Protocol) 收集資料,所以要使用 MRTG 記錄流量數據的主機要先安裝 SNMP,以下是在 FreeBSD 安裝 SNMP 及 MRTG 的方法:

安裝 SNMP
首先安裝 SNMP,在 FreeBSD 透過 ports 安裝很方便,在指令模式輸入以下指令:
Read more…

May 4, 2008 · Linux / BSD 筆記 · Comments (2)

Apache 限制上傳檔案體積

在 Apache 裡面有一個選項是 LimitRequestBody,這個選項可以限制用戶送出的 HTTP 請求內容。這個選項可以在 .htaccess 或 httpd.conf 裡使用,而如果在 httpd.conf 內使用,分別可以用在 virtualhost 或目錄屬性設定。而 LimitRequestBody 的設定值是介乎 0 (無限制) 至 2147483647 (2GB)。

例如要在目錄 /home/httpd/html/www.mydomain.com/uploads 設定上傳限制為 100K,可以在 .htaccess 或 httpd.conf 加入以下語句:

<Directory "/home/httpd/html/www.mydomain.com/uploads">
   LimitRequestBody 102400
</Directory>

如果透過 .htaccess 設定,儲存檔案後會立即生效;如透過 httpd.conf 設定,須要重新啟動 Apache。

April 26, 2008 · Linux / BSD 筆記 · No Comments Yet


« Previous Page  Next Page »