1 / 23

雜七雜八的工具

雜七雜八的工具. GNU screen. 文字模式的視窗管理員( Window Manager ) 兩大功能 Session 可在關閉 terminal 或離線後,讓 screen 中開的程式繼續運行。之後可再連接回來繼續工作。 Window 可在單個 terminal 開多個 window ,執行多個 shell (或其他程式). 不用再害怕不小心關閉視窗. 一個視窗以一抵百. screen session 的 detach 及 attach. 啟動新 screen session $ screen

charo
Download Presentation

雜七雜八的工具

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 雜七雜八的工具

  2. GNU screen • 文字模式的視窗管理員(Window Manager) • 兩大功能 • Session可在關閉 terminal 或離線後,讓 screen 中開的程式繼續運行。之後可再連接回來繼續工作。 • Window可在單個 terminal 開多個 window ,執行多個 shell(或其他程式) 不用再害怕不小心關閉視窗 一個視窗以一抵百

  3. screen session 的 detach 及 attach • 啟動新 screen session • $ screen • 在 screen 中 detach screen session(放到背景) • 輸入 C-a d • 察看現存的 screen session • $ screen -ls • attach screen session(接回來) • $ screen -r [pid] • attach 沒有 detach 的 session • screen -d -r [pid]

  4. screen 中的 window 管理和常用快捷鍵操作

  5. DEMO

  6. info 文件 • manpage 的問題 • 雖多數 unix 文件系統以 manpage 為主。 • 但 manpage 僅單頁,瀏覽搜尋都相當不方便。 • GNU Info 是類似網頁的樹狀超連結文件系統。 • 在多數 unix 中通常需要額外安裝套件 dir gdb.info.gz make.info.gz Top Top Summary Invocation Commands Overview Introduction Invoking GDB Quitting GDB Rule Introduction Simple Makefile

  7. info 中的基本操作

  8. DEMO

  9. time • 察看程式的執行時間 $time ./hello real 0m0.003s user 0m0.000s sys 0m0.000s

  10. gprof • 用於分析程式的效率分布 • 哪個 function 被呼叫最多次,花最多時間執行 $ gcc -pg hello.c -o hello $ ./hello $ gprof hello …

  11. DEMO

  12. Tags • 依 function 或 variable 的名稱,找宣告的地方。 • vim • 產生 tags 檔案 $ ctags main.cpp Complex.hpp Complex.cpp $ find . \( -name '*.[ch]' -o -name '*.cpp' -o -name '*.hpp' \) -exec ctags -u {} \; • 操作 • C-] 跳到定義的地方 • C-t 跳回來 • emacs • 產生 TAGS 檔案 $ find . \( -name '*.[ch]' -o -name '*.cpp' -o -name '*.hpp' \) | etags - • 操作 • M-. 套到定義的地方 • M-* 跳回來 • ESC Tab 用 tags 補全 symbol name 另有較新,功能更強的 GNU global

  13. DEMO

  14. diff • 用於比較兩個檔案的差異。 • 編輯器中的加強版 • 不僅可察看差異,還可用於合併或更新檔案 • vimdiff • emacs ediff • patch 程式可用 diff 的輸出修改檔案。 • patch -p1 < file.diff $ diff file1 file2 $ diff -u file1 file2 # 較常用此格式,輸出資訊較多 $ diff -c file1 file2

  15. diff 的輸出 $ diff -u calc.c calc.c~ --- calc.c 2009-06-09 22:35:36.045426360 +0800 +++ calc.c~ 2009-06-10 02:51:32.486507332 +0800 @@ -180,7 +180,10 @@ if ( pv == NULL ) parse_error (exp, p_ch ); - dstack_push ( &s_operand, pv->value ); + if ( pv->type == itype ) + dstack_push ( &s_operand, (double )pv->value.i ); + else if ( pv->type == dtype ) + dstack_push ( &s_operand, (double )pv->value.d ); sign = 1; p_ch--; @@ -242,9 +245,9 @@ pv = vars_find ( &vars, s ); if ( pv->type == itype ) - pv->value = floor ( calc_expression ( exp, &vars ) ); + pv->value.i = (int) calc_expression ( exp, &vars ); --- 的檔案 +++ 的檔案 行數範圍

  16. 若要快樂的在 Unix 開發程式先熟悉你的 Editor 吧 • 更多更好用的工具大多需要與 vim, emacs 整合。先玩熟他們才能再學。 • vim • 一份有點古老但基本東西蠻完整的文件http://edt1023.sayya.org/vim/ • emacs • 中文文件都有點舊,看英文的吧 • Tutorial • C-u C-h t • Manual • info emacs • http://www.gnu.org/software/emacs/manual/emacs.html

  17. emacs 基本操作 • 包山包海的編輯器,一堆現成模組用不完 • 看圖、看 pdf 、看網頁、寫程式、debug、收發 email、玩遊戲、管理檔案、煮咖啡、超強工程計算機、畫圖。 • bash 預設操作皆來自 emacs

  18. Unix 的源頭 • 1965 年時的作業系統都是以批次方式運行程式。 • 1965-1968 年AT&T, G.E, MIT 開始分時作業系統 ---Multics 計畫。 • 1969 年因進度緩慢 AT&T 的 bell 實驗室退出計畫 • Bell 實驗室中的 Ken Tompson 和 Dennis 開始開發了另一套分時作業系統 Unics。

  19. Unix 的初期發展 • 1971 年V1 使用組合語言開發 • 為了使開發更方便,以及在各種硬體間移植程式,開始尋找使用高階語言開發的方案。 • FORTRAN -> B -> C(C 為了 Unix 而發明) • 1973 年V3 使用 C 開發 • 1975 年V6 開始在研發單位、大學中廣為流傳。並由此版本衍生出 Unix 相當重要的一脈 --- BSD • 1979 年V7 誕生

  20. Unix 龐大的血脈

  21. 現今殺傷力最大的 GNU/Linux • 1983 年Richard Stallman 發起 GNU,目標是創造完全自由的 Unix 作業系統。 • 1990 年GNU 已開發出 Emacs、 gcc 、gdb 及大部分 Unix 程式庫和工具,獨缺 kernel 跟不上進度(HURD)。 • 1991 年Linus Torvalds 編寫出 linux kernel 並在網路上廣泛流傳。 • 1992 年GNU 的應用程式、軟體與 linux kernel 結合,成為完整的作業系統。(產生眾多的 linux distros) • GNU 的應用程式比以往 Unix 的應用程式來得更完整強大,現已廣泛移植到各個 Unix 平台,甚至 Windows。

  22. 眾多 Linux Distros

  23. Linux Distros下的套件管理 • 傳統的編譯安裝(逼不得已時) • 上網找程式原始碼 tarball( xxxx.tar.gz),並下載解開 • ./configure # 產生makefile • make • windows 剛跳槽過來的不正確管理方法 • 上網找 .deb 或 .rpm • dpkg -i xxx.deb OR rpm -ivh xxx.rpm • 善用 Distros 官方提供的大量套件 • $ aptitutde install gcc • $ yum install vim • Debian 提供超過 23200 個套件(正常人要用的東西都有) • 官方來源找不到的,也盡量找非官方的 apt 站台(不應找 單獨的 deb)

More Related