發表文章

目前顯示的是有「Linux」標籤的文章

Decompressing vmlinux from vmlinuz

Find the gzip signature: # od -A d -t x1 vmlinuz | grep '1f 8b 08' 0018016 48 8d 83 e0 c7 2e 00 ff e0 1f 8b 08 00 00 00 00 Decompress data after that: # dd if=vmlinuz bs=1 skip=18025 | zcat > vmlinux Note that 18025 = 18016 + 9 Reference: http://www.codeguru.com/forum/showthread.php?t=415186

Turning off discrete graphics for Acer Aspire 4750G

OPTIMUS on Linux has always been a pain in the ass for Linux users. It drains your battery power but you can't use it! Here is a way to turn it off on Linux, enjoy. Install acpi_call From github git clone https://github.com/mkottman/acpi_call.git cd acpi_call make sudo cp acpi_call.ko /lib/modules/`uname -r`/kernel/drivers/acpi From AUR If you are using Arch Linux, it's available at here

嵌入系統實驗PXA300 Lab3

圖片
Ubuntu on ARM Machine? No way. 其實是嵌入實驗做的數位相框XD

Open Source, Open Mind.

Revolution OS ( http://v.youku.com/v_show/id_XMTEwMDA4MjA=.html ) 這是一部有關開放源始碼社群的記錄片 很久以前看過一次,前幾天在噗上又看到很多人在轉噗 所以我就一邊coding一邊要看了一次XD 想要瞭解什麼是Open Source, Linux的人可以看看這部。 不過聽Bill Gates的news letter內容那段還滿火大的XD 現在越想越覺得Stallman真是偉大啊! 如果沒有FSF,大概連Linux都不一定會出現,更別說這麼多開源、免費的軟體了! 雖然他的想法是有些極端,不過也要有這種人,才能創造出這種理念 我也相信商業軟體絕對有他的必要性 像是現在Open Source界就還沒出現能夠媲美商業界的遊戲XD

cool RegExpr

原文在 這裡 判另方程式是否有解 ax + by = c => /^(.*)\1{a-1}(.*)\2{b-1}$/ 而被match的文字是用任意字元重覆c次 實測:13x + 19y = 70 Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> if re.search(r'^(.*)\1{12}(.*)\2{18}$', '1'*70): ... print 'Has solution.' ... else: ... print 'No solution.' ... Has solution. 想一下其實原理不難。

Fixing Live CD boot error: Ext3fs unsupported optional features: (240)

Scenario: Live CD boot without problem in qemu, but boot failed in a real machine with ext4 filesystem in local hard drive. The boot failed because of the following error: Ext3fs: sdaX: unsupported optional features: (240) root filesystem is not mounted and the boot sequence either fell into an infinite loop displaying the error or into busybox. Explaination I first encountered this error years ago in clonezilla Live CD, as I choose a new version of the Live CD image, the problem was gone. This time, I encountered this error again with BackTrack 4 Live CD Image. However, BackTrack Linux doesn't have a release roadmap and even if it does, the problem is not likely to be fixed since there is a workaround for it. As I insists in keeping my live usb layout neat, I decided to fix it myself.

Enable iso-scan in BackTrace 4 Live CD Image

* Update * There is a more elegent way to fix this problem: Since the command mkiniramfs-script copies required file from the system, we just need to find the package that contains '20iso_scan', 'lupin-helpers'. Using the command 'dpkg -S', we can find that these to files belongs to the package: lupin-casper. After chroot into the livecd environment: aptitude install lupin-casper update-initramfs -u exit and copy the initrd.gz to the usb, the iso-scan is enabled!

Merge PDFs with Ghostscript & PDF to JPG

1.Merge PDFs gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=[OUT_NAME] -dBATCH [FILES] 2.PDF to JPG convert -verbose -colorspace RGB -antialias -density 300 -quality 100 [PDF_NAME] [IMAGE_NAME].jpg

OVFF嘸蝦米翻譯機

圖片
本來只有文字介面版的,這幾天用Qt寫了個圖形化介面。 這是我在GNOME上編譯的結果:D 下載:Windows Installer: [ gOVFF-2.1.0-Installer.exe ] Github 頁面: govff @ github

Kill space in filename recursively

I recently wrote a little script to backup my files, but if a filename contains a space, bash couldn't access it correctly. I worte another script to solve this. save the following text to killspace, then run chmod +x killspace

Firefox menu font color tweak

Because I'm using a dark theme in Gnome, so the default menu font color is white. Firefox inherited the font color from gnome, so when I'm using a light theme in firefox, I can't see anything in the menu... Here is the tweak to fix it: Add this to you ~/.mozilla/firefox/*/chrome/userChrome.css if the file doesn't exist, create one. menubar, menubutton, menulist, menu, menuitem, menupopup, popup > * { color: black !important; } P.S. I'm using the theme - Chromifox Carbon

Ubuntu Pary @Taipei

這是我第一次參加說 真的是很有收獲啊! 然後終於看到Carl的真面目了 跟我想像的完全不一樣XD 認識了好多高手也看到了好多高手的真面目啊 Jserv, BlueT, c9s, 佑子, mosky, Carl ... 還有好多強大的大家! 印像比較深刻的是一位寫Muilti Touch TouchPad driver的工程師 整個就是強大! 跟他談完整個就是熱血沸騰啊! 我一定要好好加油 向他們看齊!

GIT版本控制系統

Git Wiki 寫ToyVM時開始使用Git,不得不佩服他的強大 下列是一些常用的指令 (其實看一下gittutorial和man page就會啦) * HEAD在git代表的是最後一個commit。HEAD^代表查看HEAD的parent,也就是上上個commit,HEAD^^代表HEAD的parent的parent。HEAD~4代表HEAD的parent的parent的parent的parent。假如你有branch過的話,HEAD可能不只有一個parent,HEAD^2可以代表另一個parent。 1. git init 這個指令會在當前目錄下創建一個新的Git Repository,也就是產生.git目錄 2. git add 將某的檔案加入索引(index)中,有就是準備建立快照(snapshot)的檔案。注意:這只是加入索引,還沒有真正建立快照。 3. git commit 為已加入索引的檔案建立快照。此時會出現VI(或者其他文字編輯器),讓你編輯commit註解(message). 以後每次都要git add,再git commit有點麻煩,所以可以利用:`-a'這個flag,也就是git commit -a。這樣git會自懂找出本來就加過索引的檔案,然後自動git add再git commit。注意是之前已經加入索引的檔案,新增的檔案要自己用git add加入索引。 -m "MSG" :可以將commit訊息附加在後面,這樣就不用進到文字編輯器。 --amend :是用來修改前一個commit的訊息,假如你在commit的時候把訊息打錯了,可以利用git commit --amend來修改message. 4. git log 查看log檔 5. git branch 顯示目前的分支。 如果branch後面有加參數,比如說git branch experimental,這樣就會產生一個新的branch。 可以在不同branch之間,對檔案進行不同的修改。 6. git checkout 切換目前所在的branch,git checkout experimental就會跳到experimental分支 checkout,也可以用來還原檔案,或是從某個comm...

ToyVM - 紀念一下

圖片
ToyVM是計算機組織與組合語言這門課裡教的TOY Machine的模擬器 本來只是自己寫爽的 寫的很簡陋 沒想到竟然被放到課程網上 結果只好改的完整一點囉 這次也順便學了git來管理版本 git真是好用阿! 恩 只是要紀念一下 畢竟ToyVM的生命週期好短... 大概只有一個多星期吧 以後應該也不會用到 所以也不會再改了 不過應該還是可以給學弟妹用~ 現在覺得這個其實大家都會寫,PO到資訊系版好像有點班門弄斧了Orz 原始碼和執行檔這 [toyvm-0.2.6.1.tar.gz] ,目前是0.2.6.1,應該是最後版本,課程網上的0.2.4.2 不過沒差都差不多,只是加了一些比較花俏的功能罷了 Show一下圖XD

推薦: Moblin 2.0

Moblin是Intel為以Atom為CPU的NetBook所製作的作業系統(以Linux為基礎) Moblin官方介紹 Wiki 英特爾在2007年7月推出了Moblin.org的網站,Moblin 2作業系統是專為運行於英特爾處理器的MID與netbook。 在2009年4月,英特爾將Moblin移交給Linux基金會,以擴大開源社群的參與。 很久以前就在癮科技上看過了,那時候還是很醜的GNOME介面,沒想到現在變這麼漂亮了! 試著在筆電上灌,可是好像只支援Atom阿,我的CPU是AMD的,所以不能灌...哭哭 以後買小筆電來灌好了:p

cbase - 快速進制轉換

以下是自己寫的小程式cbase介紹,主要是用來進行數字的基底轉換,比如說10進位轉16進位。但是比較特別的是,cbase可以支援到256進位,當然有特殊的方法來分辨大於36進位的數字,前36進位是利用,0-9 a-z來表示的。至於寫這個程式的動機呢?因為假如在Linux上用iwconfig設定無線網路的話,WEP密碼必須使用16進位,這時候如果自己轉就很麻煩了。可是用cbase: cbase -i a -o 16 WEP_KEY 輸出: WEP_KEY (a) = 5745505f4b4559 (16) 然後就可以很方便的得到16進位字串了! 查某個字母的ASCII code也很方便,decode unicode也可以 cbase -i a -o 10 A #get ascii cbase -i 16 -o a -do '%' -so [unicode_string] #decode unicode 輸出: A (a) = 65 (10) 還有另一個動機是,看到有人可以把網址加上@然後後面接十進位IP,就可以忽略前面的網址,導向後面那個十進位IP所在的位址。於是我想如果可以把十進位的IP先轉回正常IP,那我就可以先知道會被連到哪裡啦?(當然逆向也可以) 舉例: cbase -i 10 -o 256 2356152436 這樣會輸出: 2356152436 (10) = 140.112.008.116 (256) 於是IP就被還原了,這是因為其實IP可以看成一個256進位的數字所以可以這樣操作,至於詳細的用法自己看下面吧~ 有人會想要用這個程式嗎?如果要的話回應一下吧,我再釋出原始碼。 是說這是我第一次寫比較完整的命令列程式,程式其實很簡單的,如果其他大大覺的我寫很爛的話,請你給我些意見吧XD 然後下面的help list可能有很多文法錯誤XDD 我完全靠殘餘的語感。 Usage : cbase [ - i inbase ] [ - o outbase ] [ options ] string1 string2 . . . Argumets & options : - i [ inbase ] ...

HowTo: Compile BFS Kernel

BFS 是什麼? 請參考 LinuxToy 如何為核心打patchPatch 1.從 The Linux Kernel Archives 下載最新的核心(2.6.31) 2.從 這裡 下載最新的BFS Patch 3.解壓縮 tar -jxf linux-2.6.31.tar.bz 4.打入Patch(假設我下載的kernel和patch放在同一層資料夾) cd linux-2.6.31 patch -p1 < ../2.6.31-sched-bfs-300.patch 5.將原始碼移到/usr/src(這個步驟也可以不要,只是如果利用make-kpkg指令建立deb的話,他會建立一個符號連結到原始碼的資料夾,所以假如你編好後刪掉原始碼資料夾,就找不到原始碼囉~) sudo mv linux-2.6.31 /usr/src 設定編譯參數 1.建議使用原本distro的設定就好 sudo cp /boot/config-$version /usr/src/linux-2.6.31/.config 2.安裝相依套件 sudo apt-get install build-essential kernel-package libncurses5-dev fakeroot wget bzip2 3.menuconfig make menuconfig 這時會出現一個設定畫面,如果要套用distro的設定:將游標移到最下面Load an Alternate Configuration File,接著他會要求你輸入檔名,直接使用剛剛複製的.config就可以了 接下來設定是選擇性的,以下操作可以使桌面延遲減到最低,但會降低穩定性。要不要就看你自己囉,是說我到現在沒出過問題~ * 到Processor type and features -> Tickless System (Dynamic Ticks) 對他按空白鍵直到變成空白 * 到Processor type and features -> Preemption Model (Preemptible Kernel(Low-Latency Desktop)) -> 選擇 Preemptible Kernel (Low-Latenc...

PCManX SSH Login

之前有試過但用wireshark抓封包發現還是telnet封包 以為沒辦法使用ssh登入 結果今天google一下才發現是方法錯誤 方法: 編輯.pcmanx/favorites 將我的最愛的UseExternalSSH設為1 UseExternalSSH=1 然後將bbs位址改成 bbs@ptt.cc:22 (以ptt為例) 同時自動登入功能還是可以使用的~ 重開以後就可以用ssh登入啦 用wireshark檢視的結果確認沒有telnet封包^^

Linux 死機救援

如果遇到ctrl alt backspace/f1也沒反應的話 那是Xorg掛了 之前有一陣子常遇到 只好強制關機... LinuxToy上出現了一篇新方法 引用如下: OK,这是今天才学到的方法,叫做 reisub,这个方法可以在各种情况下安全地重启计算机。大家在键盘上找,可以找到一个叫做“Sys Rq”的键,在台机的键盘上通常与 Prt Sc 共键,在笔记本可能在其他位置,如 Delete。以台机为例,要使用这种方法需要按住 Alt-Print(Sys Rq),然后依次按下 reisub 这几个键,按完 b 系统就会重启。 下面解释一下这个方法:其实 Sys Rq 是一种叫做系统请求的东西,按住 Alt-Print 的时候就相当于按住了 Sys Rq 键,这个时候输入的一切都会直接由 Linux 内核来处理,它可以进行许多低级操作。这个时候 reisub 中的每一个字母都是一个独立操作,他们分别表示: unRaw 将键盘控制从 X Server 那里抢回来 tErminate 给所有进程发送 SIGTERM 信号,让他们自己解决善后 kIll 给所有进程发送 SIGKILL 信号,强制他们马上关闭 Sync 将所有数据同步至磁盘 Unmount 将所有分区挂载为只读模式 reBoot 重启 这6个字母的顺序是不可以记错的。那怎么记呢?这里提供一个个人认为比较好的方法:单词 busier(busy 的比较级,更忙)倒过来就是了。 基本上就这样了,Linux 的死机本来就不多见,现在见了也可以安全解决,多好~ http://linuxtoy.org/archives/what-to-do-if-linux-crash.html

Building deb with dpkg-deb

之前在ubuntu-TW上看到hepha大把剛釋出的pps for linux打包成了deb 很好奇這是如何達成的,之前只聽說過可以用checkinstall從source建立deb 後來終於 查到了 主要是利用dpkg-deb這個指令 你必去建立一個資料夾然後將需要的檔案按照檔案系統架構把檔案加入 假設我建立一個資料夾叫做debain 我想將一個程式test封裝進去,而test應該放在/usr/bin/test 所以我就必須建立debian/usr/bin然後把test複製到debian/usr/bin 然後還需要一個control檔 [control] Package: Version: Section: Priority: Architecture: Depends: Suggests: Conflicts: Replaces: Installed-Size: Maintainer: Description: 不需要全部都填 然後放在 debain/DEBIAN裡頭 註:DEBIAN下可包含檔案 control, prerm, postinst 接著 fakeroot dpkg-deb --build debian 然後就產生了一個deb封裝啦! P.S.可以用ar x *.deb來解開一個封裝 流程from http://tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO/ Prerequisite files: 1. one or more binary executable or shell script files 2.a man page for each executable file 3.a 'control' file 4.a 'copyright' file 5. a 'changelog' and 'changelog.Debian' file Setup temporary 'debian' directories: 1. create 'd...