跳到主要內容

發表文章

目前顯示的是 2009的文章

Keep command running even you logout

Telnet到某台Linux主機上執行指令, 但此時Windows需要重開機, 可以用兩個簡單的方式繼續執行原本指令 1. Ctrl-D 如果指令已經在執行而且不想重run 先用Ctrl-z暫停, 然後執行bg使原本暫停的指令到backgroud 最後再下Ctrl-D 2. nohup 一開始執行指令時就加上nohup在前面 i.e. nohup your-command & 此時關閉視窗或中斷連線都不會影響正在執行的指令了

將patch完後的code還原回來

patch -p0 -R < path/ your . patch

Windows 系統工具大集合: Sysinternals

Sysinternals 公用程式索引 做這些工具的公司後來被微軟買走了, 應該是做的不錯 目前有在用的有Process Explorer 打包下載 十大熱門下載 Process Explorer Autoruns Process Monitor PsTools PageDefrag RootkitRevealer TcpView BgInfo BlueScreen NewSID

Get file's size in Hex

更新firmware前, 如果遇到比較陽春的bootloader, 有的還要自己手動輸入檔案大小 這時可以先將做出來的大小先算出, 再以script代入就可以了 ls -l FileName | awk '{print $5} ' |  echo " ibase = 10; obase = 16;$$" | bc

在Linux下用native2ascii轉成簡中unicode的方式

在JDK安裝目錄中BIN底下有一個轉碼工具native2ascii.exe 資源文件需要進行Unicode編碼,方法是使用這個jdk提供的工具來轉換native2ascii ascii到unicode方式: native2ascii 原檔名 轉換檔名 因為我用的是繁體中文的環境, 首先, 必需將自己的locale換成zh_CN export LC_ALL=zh_CN.utf8 然後再執行gnome-editor將翻譯成簡中的文字貼上 最後再執行native2ascii即可 範例 aaa.txt文件內容包括:中國 native2ascii aaa.txt bbb.txt 執行後變為: \u4e2d\u56fd aaa.txt文件內容包括: \u4e2d\u56fd native2ascii -reverse aaa.txt bbb.txt 執行後變為:中國

檢查snmp mib 的文法格式工具 -- smilint

SNMP mib 的格式訂義在RFC 1155和2578, 目前有SMIv1和SMIv2. 如果想檢查自己寫的mib格式是否正確, 可以用smilint來檢查. Install: yum install libsmi (libsm-devel) Reference: http://en.wikipedia.org/wiki/Management_information_base  

根據MAC Address找網卡廠牌

網卡前六個值稱為OUI, IEEE有提供網頁供大家察詢 http://standards.ieee.org/regauth/oui/index.shtml 比方說 000E2E開頭的為Edimax這家公司的 00-0E-2E (hex) Edimax Technology Co., Ltd. 000E2E (base 16) Edimax Technology Co., Ltd.    3, Wu-Chuan 3rd Road, Wu-Ku Industrial Park, Taipei Hsien, 248 TAIWAN, REPUBLIC OF CHINA

自訂vim指令縮寫

每次要打printf( ... 很累, 可以利用vim 簡寫輸入的功能 :ab 縮寫 全部的字串 For example: :ab pr printf("%s %n\n", __func__, __LINE__); 然後在insert mode輸入pr 就會自動換成後面的字串了

避免Outlook將自己設為預設郵件用戶端

有時候Thunderbird無法開啓的郵件, 還是會用Outlook收下來看. 但預設的電子郵件就用被改掉. 一直以為只要將Outlook2003中的"設為預設電子郵件"關閉, Thunderbird就會成為我預設的用戶端. 但每次只要打開Outlook, 或是有Windows Update有更新Outlook, 就會被改回去 原來控制台->網際網路設定也要修改

自動重開機並記錄重開次數的Script

為了要測試重開機幾次會失敗, 寫了一個script來記算. 因為busybox的shell只提供了有限的功能, 不能像bash一樣宣告整數變數, 所以count的處理算比較麻煩. #!/bin/sh FILE = /etc/count timeout = 2 if [ ! -f $FILE ] ; then echo 0 > $FILE fi count = `cat $FILE ` #echo $count echo $ ( ( $count+ 1 ) ) > $FILE echo "================================================" echo "Success reboot times :" `cat $FILE ` echo "Ctrl+C to break" echo "================================================" # setup timeout old_tty_settings = `stty -g ` stty -icanon min 0 time ${timeout} 0 eval read $input stty " $old_tty_settings " echo "reboot" reboot

blog上的sidebar位置不正確

在寫了幾篇文章之後, 竟然發現右側的sidebar(也就是放置google 小工具的地方) 竟然移動到最右側去了, 在ie內更奇怪, 跑到最下方去.  後來找到原因, 竟然是blog中其中一篇文章在html簡視中, 一直都沒有換行, 造成單行過長. (在撰寫模式中並看不出來) 參考網址: http://blogger-tricks.blogspot.com/2006/04/what-to-do-sidebar-slide-to-bottom-of.html

移動andLinux在windows下的磁碟檔

andLinux在windows下的磁碟檔為base.drv 和 swap.drv 預設被存放在C:\Program Files\andLinux\Drives 下 想到搬到其它的硬碟下, 比方說:g:\andLinuxDisk\ 先將andLinux 的service停止 再將base.drv和swap.drv移動到想要的目錄下 修改設定檔C:\Program Files\andLinux\setting.txt, 如下所示 再將service重新起動即可(但TAP-colinux的網路介面卡無法起動, 需要重新開機才有辨法, 目前還不知道為什麼) mem=256 root=/dev/cobd0 initrd=initrd.gz kernel=vmlinux cobd0=g:\andLinuxDisk\base.drv cobd1=g:\andLinuxDisk\swap.drv eth0=slirp eth1=tuntap,"TAP-Colinux",00:11:22:33:44:55 如果要加大磁碟檔的大小, 可以參考下面這個網頁 http://colinux.wikia.com/wiki/ExpandingRoot#The_most_reliable_way_to_enlarge_the_root_partition

andLinux Menu上新增程式

由於我安裝的是andLinux的最小安裝版, 所以我最常用的gnome-terminal也沒有被安裝到. 先把它裝好: apt-get install gnome-terminal 在andLinux的安裝目錄下的Lanucher目錄找到menu.txt (我的在 C:\Program Files\andLinux\Launcher) 將要加入的程式名稱加到裡面, 一個程式一行 格式: 顯示名稱;圖示;指令 Gnome-terminal;xfce4_terminal.ico;gnome-terminal Terminal;xfce4_terminal.ico;xfce4-terminal Thunar;thunar.ico;thunar Mousepad;mousepad.ico;mousepad - Synaptic;synaptic.ico;synaptic PulseAudio Mixer;volume.ico;pavucontrol

Initrd

現在的Fedora都有用到initrd來開機, 如果想研究看看裡面的機制, 可以將之解開來看看. cpio format mkdir temp ; cd temp cp /boot/initrd-2.6.14.2.img initrd-2.6.14.2.img.gz gunzip initrd-2.6.14.2.img.gz cpio -i --make-directories < initrd-2.6.14.2.img non-cpio format mkdir temp ; cd temp cp /boot/initrd.img.gz . gunzip initrd.img.gz mount -t ext -o loop initrd.img /mnt/initrd ls -la /mnt/initrd Tools mkinitrd; packagename -- mkinitrd References: http://www-128.ibm.com/developerworks/linux/library/l-initrd.html

Linux 下看硬體規格的工具

lshw is a small tool to extract detailed information on the hardware configuration of the machine. yum install -y lshw 有GUI版 yum install -y lshw-gui 其它相關工具: lspci, lsusb, and lshal

andLinux上使用sshfs

在andLinux上裝sshfs package apt-get install sshfs andLinux上default並沒有將/dev/fuse這個device node建立起來, 手動建立它 mknod /dev/fuse c 10 229 確認fuse 的module已經load modprobe fuse 因為在我的windows-host 上有跑CygWin 的sshd, 所以我可以直接將它mount到指定目錄下: mkdir -p /mnt/sshfs sshfs jim@windows-host:/cygdrive/d /mnt/sshfs/ umount 的方式 fusermount -u /mnt/sshfs

在andLinux下新增interface alias

修改/etc/network/interfaces 例如: 幫eth1多bind 一個新的ip叫做192.168.0.53 iface eth1:1 inet static address 192.168.0.53 netmask 255.255.255.0 下次起動時就會有了, 或是直接執行 /etc/init.d/networking restart

andLinux use Windows 網芳

andLinux開機時若沒有幫你把windows網芳的目錄mount起來, 你可以手動用下列指令mount: smbmount //windows-host/LINUX /mnt/win -o username=jim 或是在/etc/fstab上新增設定即可 mount 起來後可以利用/root/windows 這個link 來存取

andLinux

之前在Windows上裝Cygwin來模擬Linux的環境, 現在又有新的選擇 -- andLinux --  http://www.andlinux.org/ andLinux is a complete  Ubuntu  Linux system running seamlessly in Windows 2000 based systems (2000, XP, 2003, Vista; 32-bit versions only).