Nov 29, 2009

screen

這二天在想,因該好好的學習一下 screen 要怎麼使用,從最一開始使用 screen 只是很單純的把他當成一個不會因為斷線就無法執行之後工作的 terminal 來使用,從官方對於 screen 的簡介:
Screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells.
我想,我一直漏掉 multiplexes 的重要特色。

Reference:
  1. screen 中文教學 on debian wiki
  2. screenrc 分享
  3. Screen User's Manual

Nov 25, 2009

利用 rsa 登入 SSH Server

1. ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa): [按 Enter 使用預設值(建議)]
Enter passphrase: 輸入你的 Passphrase
Enter same passphrase again: 再一次輸入你的 Passphrase
Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/id_rsa.pub.
The key fingerprint is: cc:e8:a9:da:a3:41:c6:a9:97:52:59:ef:0c:cf:45:b6 username@abc.com
2. scp ~/.ssh/*.pub 你欲登入的主機:~/.ssh/.
3. ssh 你欲登入的主機
4. cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
5. chmod 711 ~/.ssh
6. chmod 644 ~/.ssh/authorized_keys

發現,用 ubuntu 9.10 完成以上這些動作,就可以直接登入主機,不需在使用 ssh-agent


Reference:
  1. ssh keygen 免輸入密碼
  2. SSH 免密碼登入
  3. PuTTY 免密碼登入
  4. OpenSSH Public Key Authentication

Nov 23, 2009

Diff & Merge tool

原本都是在 windows 下使用 WinMerge ,在Linux 下一直找不到好用的工具,上星期參加 H4 ,有人提到 vimdiff ,這二天 survey 了一下,有那些 diff merge tools 可以使用:

sdiff <- 單純印出,每一行的內容

vimdiff <- 好像沒辨法對目錄下所有的檔案做比較,希望可以像 meld 那樣

meld <- 目前試了一下,還不錯

kdiff3 <- 我大多是用 Gnome,不太想多裝 KDE lib

DiffMerge <- non-opensource


Reference:
Visual Diff Tools in Linux

超棒的 Debian 小技巧

今早看到 Rex 於 H4 mail-list ,分享給大家的 fortunes-debian-hints's zh_TW.po 裡面寫了蠻多好用的小技巧。

Debian 小技巧 #1: 您可以使用 reportbug 套件中的 'reportbug' 指令來回報問題,或者也可使用圖形化介面 'reportbug-ng'。

Debian 小技巧 #2: 您可以使用 'dpkg-reconfigure ' 變更在您第一次安裝一個套件時曾回答的問題。另外 'configure-debian' 套件為此提供了一個統一的介面。

Debian 小技巧 #3: 您可以使用 'apt-cache search <關鍵字>' 搜尋所有套件的描述的關鍵字。

Debian 小技巧 #4: 您可以使用 'apt-cache policy ' 查看可用的以及已安裝的所有候選套件的版本資訊。

Debian 小技巧 #5: 如果您需要編譯一個自定的核心,請使用 kernel-package 套件中的 'make-kpkg' 指令稿。

Debian 小技巧 #6: 第 #6 個提示不存在。今天就來生一個!

Debian 小技巧 #7: 您可以使用 cron-apt 套件每晚自動下載您更新套件。

Debian 小技巧 #8: 如果您在 Debian 中遇到的問題,無法透過閱讀手冊和文件解決,那麼請到 Debian 用戶郵遞論壇詢問 (簡: debian-chinese-gb@lists.debian.org,繁: debian-chinese-big5@lists.debian.org)。

Debian 小技巧 #9: 如果您需要知道目前正在使用的 Debian 是什麼版本,請查看 /etc/debian_version;如果您想知道那個版本的開發代號 (例如: 3.0 的開發代號是'Woody'),請參考此連結: http://www.debian.org/doc/FAQ/ch-ftparchives.html#s-codenames

Debian 小技巧 #10: Debian 郵遞論壇討論使用者問題或者 Debian 政策文件。瀏覽 http://www.debian.org/MailingLists/ 並訂閱您所感興趣的內容吧。

Debian 小技巧 #11: 關心新聞 - 閱讀 Debian Times。請於線上瀏覽 http://times.debian.net/

Debian 小技巧 #12: 有一個 grep-dctrl 套件提供了若干指令,它們可用來快速搜索各種套件的 control 檔 (像是套件中的檔案)。

Debian 小技巧 #13: 如果您不喜歡使用某個 Debian 套件的預設選項,您可以把它的源碼下載下來,按照您的偏好重新編譯一個版本。請參考 http://www.debian.org/doc/FAQ/ch-pkg_basics.html (第 6.13 和 6.14 節) 瞭解更多資訊。不過請記住,大部分軟體的多數選項都能夠在執行時進行設定,通常不必重新編譯套件。

Debian 小技巧 #14: 如果您想追蹤某個套件的發展 (比如說,如果您希望瞭解缺陷回報,發行通知以及其它類似資訊),請考慮在套件追蹤系統 (Package Tracking System)中訂閱。您可以於此找到有關套件跟蹤系統 (PTS) 的更多資訊:http://www.debian.org/doc/manuals/developers-reference/resources.html (第 4.10 節)

Debian 小技巧 #15: 一般而言套件的文件可以在 /usr/share/doc/ 下找到。特別注意 README.Debian 文件專門提供 Debian 專屬資訊。

Debian 小技巧 #16: 如果您正在搜索一個不知道屬於那個套件的檔案,請試試 'apt-file',它為這類資訊提供了一個小型的資料庫。或者您也可以從 Debian 套件資料庫中搜索這些內容,也可以進行檔案搜尋:"http://www.debian.org/distrib/packages#search_contents

Debian 小技巧 #17: 想找一些人聊聊 Debian 嗎? 如果您習慣於 IRC (Intenret Relay Chat) 聊天,只要安裝您慣用的 IRC 軟體,然後加入 irc.debian.org 的 #debian 或 #dot 或 #debian-zh 頻道就可以了。

Debian 小技巧 #18: 在 http://packages.qa.debian.org/ 可以找到套件的品管資訊。這個頁面提供了維護人員的品質保證網頁、BTS、套件新聞、以及檔案庫中的可用版本。

Debian 小技巧 #19: 如果您對從封裝軟體套件感興趣,您應該考慮安裝 apt-src 這個套件。

Debian 小技巧 #20: 想要持續追蹤某個您已安裝的套件版本紀錄 (對那些混用 stable / testing / unstable 系統的人尤其有用)?請試試 apt-show-versions。

Debian 小技巧 #21: 如果您的 Debian 機器所使用的連線速度很慢,但是您可以使用另一個比較快的網路,那麼請試試 apt-zip 套件。

Debian 小技巧 #22: 正在猶豫使用哪個 Debian 鏡像站?請試試 apt-spy 和 netselect-apt 套件,它們可以為您測試不同網站的速度。

Debian 小技巧 #23: 若您的系統佔用了太多的硬碟空間,請試試 deborphan 套件。它能建議您哪些套件是無用的且可刪除的。當然,別忘了清除掉 APT 暫存 (使用 'apt-get clean'、'aptitude clean'、或者 aptitude 工具選單中的 '動作'->'清除套件暫存' 選項)。

Debian 小技巧 #24: 如果您想感謝某個維護者對於所處理的問題的辛勞,請試試reportbug --kudos。

Debian 小技巧 #25: 'debian-reference' 套件為 Debian 使用者和開發人員提供了非常廣泛的參考文件。其中大多數資訊都在這個連結:http://www.debian.org/doc/manuals/reference。

Debian 小技巧 #26: 如果一個套件沒有足夠的參考文件,那麼請查找名為 -doc 的套件,並確認已經安裝。通常含有大量文件的套件會被拆開,這是考慮到某些使用者並不想安裝文件。

Debian 小技巧 #27: 請定期檢查您的備份。您*確定*備份無誤了,對吧? 對吧?(此技巧帶給您的當頭棒喝是 '徹' '底' '崩' '潰',以及「空」。)

Debian 小技巧 #28: 如果您的機器並非持續處於開機狀態 (例如一台筆記型電腦),請試試 'anacron' 套件。即使在機器並未開機,它能夠確保讓該定期執行的軟體依然被啟動。

Debian 小技巧 #29: 保持您系統時鐘的精確性 - 請安裝 'ntpdate' 套件並且設定為每次開機自動啟動。另外,經常開機的機器應該通過安裝 'ntp' 套件在每次開機時進校時。

Debian 小技巧 #30: 若安裝了 'doc-base' 和 'doc-central' 套件以及相依的套件後,就可以從 http://localhost/ 來瀏覽文件囉。

Debian 小技巧 #31: 停用一個特定 runlevel 的開機服務,應該是將 /etc/rc.d 中以 S 開頭的鏈接變更為 K 開頭的鏈接,而不是刪除那個鏈接。如果所有的鏈接都被刪除了,那麼系統在下次安裝升級套件時都將假定它們需要被替換。

Debian 小技巧 #34: 有一個 'doc-debian' 套件提供了一些有關 Debian 項目的通用文件。它還有西班牙語版本 (doc-debian-es)、法語版本 (doc-debian-fr) 和烏克蘭語版本 (doc-debian-uk)。

Debian 小技巧 #35: 'devscripts' 套件為那些希望改進 Debian 的使用者提供了一些有用的指令,如 wnpp-alert, rc-alert 以及 bts。

Debian 小技巧 #36: 如果您希望追蹤 Debian 開發版 (sid),但只有少量的下載權限或者一個頻寬很小的網路,請試試 debdelta 套件。

Debian 小技巧 #37: 搜尋遊戲嗎 ? 試試 'goplay' 吧,它提供了一個很棒的使用介面可瀏覽各種類型的遊戲。

Debian 小技巧 #38: 需要一些比 Debian 穩定版更新的套件,但又不願升級到 'testing' 或者 'unstable' 嗎? 有些更新套件擺在 volatile.debian.org,另一些套件可在 www.backports.org 找到。

Debian 小技巧 #39: 希望下載一個套件但卻不想安裝它?請用 'aptitude download '。

Debian 小技巧 #40: 想學會使用軟體的新技巧嗎? \"man\" 是你最佳好友! 在 shell 下打 \"man <程式名稱>\" 或者打 \"man -H <程式名稱>\" 在瀏覽器下閱讀操作手冊。

Debian 小技巧 #41: 安裝 bash-completion 軟體套件可增強 bash's 的 tab 補齊功能。

Debian 小技巧 #42: 如果你安裝了 command-not-found,當你鍵入系統未安裝之軟體時候,系統將會自動提醒你應該安裝那個套件。

Debian 小技巧 #3: 您可以使用 'apt-cache show <套件名稱>' 或 'aptitude show <套件名稱> 來取得套件的詳細描述。

Debian 小技巧 #44: 您可以使用 'apt-file list <套件名稱> 來查詢套件中所包含得檔案。這個指令很接近 dpkg -L,只是不需要安裝或先下載該套件。

Nov 22, 2009

dns timing issus when install ttf-mscorefonts

安裝 ttf-mscorefonts 會出現某些檔案無法下載,主要是因為下載時,wget 的參數 timeout 設的太短了,可參考 ubuntu Bug #431217

以下做簡單的筆記:
1. sudo vi /var/lib/dpkg/info/ttf-mscorefonts-installer.postinst #改成下面的內容

#!/bin/bash

#Version: 1.0
#Info: Bash script to install mscorefonts without using
#currently broken ttf-mscorefonts-installer (3.0) for
#Ubuntu 9.10 Karmic Koala (date: 03/11/09)

#Author: Jonathan K.
#Website: http://www.friendlytechninja.vndv.com
#Email:

#License: This is free to use and distribute (for free only) as long as
#credit is given to original author.

#Create temp and mscorefonts dir
sudo mkdir /usr/share/fonts/truetype/mscorefonts
mkdir /tmp/mscorefonts
cd /tmp/mscorefonts

#Download links
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/andale32.exe/download?use_mirror=cdnetworks-kr-1
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/arial32.exe/download?use_mirror=cdnetworks-kr-1
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/arialb32.exe/download?use_mirror=cdnetworks-kr-1
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/comic32.exe/download?use_mirror=cdnetworks-kr-1
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/courie32.exe/download?use_mirror=cdnetworks-kr-1
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/georgi32.exe/download?use_mirror=cdnetworks-kr-1
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/impact32.exe/download?use_mirror=cdnetworks-kr-1
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/times32.exe/download?use_mirror=cdnetworks-kr-1
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/trebuc32.exe/download?use_mirror=cdnetworks-kr-1
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/verdan32.exe/download?use_mirror=cdnetworks-kr-1
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/webdin32.exe/download?use_mirror=cdnetworks-kr-1

#Extract all .tff files
cabextract *.exe -F*.ttf -L

#Rename files and move files
sudo cp andalemo.ttf /usr/share/fonts/truetype/mscorefonts/Andale_Mono.ttf
sudo cp ariali.ttf /usr/share/fonts/truetype/mscorefonts/Arial_Italic.ttf
sudo cp arialbd.ttf /usr/share/fonts/truetype/mscorefonts/Arial_Bold.ttf
sudo cp arialbi.ttf /usr/share/fonts/truetype/mscorefonts/Arial_Bold_Italic.ttf
sudo cp arial.ttf /usr/share/fonts/truetype/mscorefonts/Arial.ttf
sudo cp ariblk.ttf /usr/share/fonts/truetype/mscorefonts/Arial_Black.ttf
sudo cp comicbd.ttf /usr/share/fonts/truetype/mscorefonts/Comic_Sans_MS_Bold.ttf
sudo cp comic.ttf /usr/share/fonts/truetype/mscorefonts/Comic_Sans_MS.ttf
sudo cp cour.ttf /usr/share/fonts/truetype/mscorefonts/Courier_New.ttf
sudo cp courbd.ttf /usr/share/fonts/truetype/mscorefonts/Courier_New_Bold.ttf
sudo cp courbi.ttf /usr/share/fonts/truetype/mscorefonts/Courier_New_Bold_Italic.ttf
sudo cp couri.ttf /usr/share/fonts/truetype/mscorefonts/Courier_New_Italic.ttf
sudo cp georgiaz.ttf /usr/share/fonts/truetype/mscorefonts/Georgia_Bold_Italic.ttf
sudo cp georgiab.ttf /usr/share/fonts/truetype/mscorefonts/Georgia_Bold.ttf
sudo cp georgiai.ttf /usr/share/fonts/truetype/mscorefonts/Georgia_Italic.ttf
sudo cp georgia.ttf /usr/share/fonts/truetype/mscorefonts/Georgia.ttf
sudo cp impact.ttf /usr/share/fonts/truetype/mscorefonts/Impact.ttf
sudo cp times.ttf /usr/share/fonts/truetype/mscorefonts/Times_New_Roman.ttf
sudo cp timesbd.ttf /usr/share/fonts/truetype/mscorefonts/Times_New_Roman_Bold.ttf
sudo cp timesbi.ttf /usr/share/fonts/truetype/mscorefonts/Times_New_Roman_Bold_Italic.ttf
sudo cp timesi.ttf /usr/share/fonts/truetype/mscorefonts/Times_New_Roman_Italic.ttf
sudo cp trebuc.ttf /usr/share/fonts/truetype/mscorefonts/Trebuchet_MS.ttf
sudo cp trebucbd.ttf /usr/share/fonts/truetype/mscorefonts/Trebuchet_MS_Bold.ttf
sudo cp trebucbi.ttf /usr/share/fonts/truetype/mscorefonts/Trebuchet_MS_Bold_Italic.ttf
sudo cp trebucit.ttf /usr/share/fonts/truetype/mscorefonts/Trebuchet_MS_Italic.ttf
sudo cp verdanab.ttf /usr/share/fonts/truetype/mscorefonts/Verdana_Bold.ttf
sudo cp verdanai.ttf /usr/share/fonts/truetype/mscorefonts/Verdana_Italic.ttf
sudo cp verdanaz.ttf /usr/share/fonts/truetype/mscorefonts/Verdana_Bold_Italic.ttf
sudo cp verdana.ttf /usr/share/fonts/truetype/mscorefonts/Verdana.ttf
sudo cp webdings.ttf /usr/share/fonts/truetype/mscorefonts/Webdings.ttf

#Clean up
cd ~
rm -r /tmp/mscorefonts

2. sudo dpkg --configure -a

Free E-Book Download

應該選那一個 File System 呢?

Linux 2.6.28 之後,開始支援 EXT4,最近重灌 ubuntu 9.10 發現多了 EXT4 可以選擇,一開始還不確定是不是要直接升級到 EXT4 ,剛剛 Survey 了一下,我想,下直別想那麼多了,直接使用 EXT4 就好了

Reference:

Generate PDF by JS

Reference: 用 JavaScript 產生 PDF 檔

jspdf - jsPDF generates PDF documents using pure JavaScript

我的舊筆電 M2N 裝 Ubuntu 9.10

Reference: Ubuntu karmic freeze on Asus M2n

之前M2N上一直是使用 ubuntu 8.04 一直沒有升級,這次等 9.10 一出,一口氣從新安裝新版的 ubuntu,中間出現蠻多相容性的問題。

1. ubuntu 9.10 安裝時,多增加
acpi=off and nolapic
2. 安裝完之後,更改 grub 開機參數
/etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT 中加入 nolapic nomodeset
3. xorg.conf 改使用 vesa
Section "Device"
Identifier "Configured Video Device"
Driver "vesa"
EndSection

Section "Monitor"
Identifier "Configured Monitor"
EndSection

Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
EndSection

Nov 16, 2009

dvtm || dynamic virtual terminal manager

上星期參加H4,看到這個有好玩的東西,下面是 Hot Key 筆記

Keyboard commands
Mod : 預設為 ^g, 更改於 config.h 或 -m 的方式
Mod-c : 新增一個 window.
Mod-x : 關閉目前 window.
Mod-l : 增加 5% 主視窗的寬度.
Mod-h : 減加 5% 主視窗的寬度.
Mod-j : 移到下一個視窗.
Mod-k : 移到上一個視窗.
Mod-[1..n] : 移到第 n 個視窗
Mod-. : Toggle minimization of current window.
Mod-u : Focus next non minimized window.
Mod-i : Focus prev non minimized window.
Mod-m : Maximize current window (change to fullscreen layout).
Mod-PageUp : Scroll up.
Mod-PageDown : Scroll down.
Mod-Space : Toggle between defined layouts (affects all windows).
Mod-Enter : Zooms/cycles current window to/from master area.
Mod-t : Change to vertical stack tiling layout.
Mod-b : Change to bottom stack tiling layout.
Mod-g : Change to grid layout.
Mod-s : Shows/hides the status bar.
Mod-r : Redraw whole screen.
Mod-G : Escape the next typed key.
Mod-X : Lock screen.
Mod-M : Toggle dvtm mouse grabbing. Mod-q Quit dvtm.

Mouse commands
Copy and Paste : 按 SHIFT 加左鍵反白要 Copy 的文字,SHIFT 加中鍵為貼上
Button1 click : Select window.
Button1 double click : Select window and toggle maximization.
Button2 click : Zooms/cycles current window to/from master area.
Button3 click : Toggle minimization of current window.

延申閱讀: