SlideShare a Scribd company logo
1 of 31
Download to read offline
Command Line 初級寶典 
Tom Chen @ IF+ TechArt
http://zh.wikipedia.org/wiki/OS_X
• cd (change directory) 
• cd ~/Desktop 
• passwd (change password) 
• ls (list) 
• ls -alh | more 
• pwd (print working directory) 
• w 
• which [command] (find where the command is) 
• man [command] (Manual) 
• man ls
• Ctrl-E 到最後⼀一個字 
• Ctrl-A 到最前⼀一個字 
• Ctrl-U 從游標所在位置消滅到最前⾯面 
• Ctrl-D 中斷連線、終⽌止程式... 等 
• (箭頭上) 上⼀一個指令 
• (建投下) 下⼀一個指令 
• ![command partial] 上⼀一個指令 
• 例: $ telnet google.com.tw 80 
• $ !telnet 
• 通常 Ctrl 會簡寫為 ^。例如 Ctrl-E —> ^E
檔案系統 
• mv file1 file2 
• cp file1 file2 
• cp -r dir1 dir2 (cp -a dir1 dir2) 
• rm file1 
• rm -r dir1 ⾮非常⾮非常⾮非常的危險!!! 
• rm -rf dir1 ⾮非常⾮非常⾮非常的危險!!! 
• ln -s file1 file2 (製作連結檔)
檔案系統 
• chmod 777 test.py 
• chmod u+x test.py 
• http://zh.wikipedia.org/wiki/Chmod
• top 列出⺫⽬目前最⾼高的幾個 process 
• uptime 開機多久 (也會列出 CPU loading) 
• ps aux 列出⺫⽬目前所有 process 
• ps ax | grep vi 
• kill [pid] 把這個 process 殺死 
• kill -9 [pid] 最暴⼒力
• 找檔案內的字串 
• grep midi * 
• grep -r midi * 
• 找檔名 
• find . | grep meetup
• more [filename] 顯⽰示檔案 
• less [filename] 顯⽰示檔案 
• cat [filename] 顯⽰示檔案 (⼀一股腦兒地) 
• head [filename] 顯⽰示檔案的前幾⾏行 
• tail [filename] 顯⽰示檔案的最後幾⾏行 
• tail -F [filename] 會⾃自動更新 (看 log 檔很有⽤用) 
• touch [filename] 產⽣生⼀一個空的檔案
pipe / redirect 
• command1 | command2 
• command1 的 output 導進 command2 的 input 
• cat abc.txt | more 
• cat file.txt > file2.txt 貼到 file2.txt 
• echo ‘1234’ > file.txt 
• cat file.txt >> file2.txt 貼在 file2.txt 後⾯面
• diff file1.txt file2.txt 
• diff -r dir1 dir2
• df -h 看⺫⽬目前磁碟狀況 (空間) 
• du 列出⺫⽬目前檔案結構的空間 
• du -h -d 0 列出⺫⽬目前這個⺫⽬目錄底下佔了多少空間 
• du -h -d 1 ⼀一樣意思但是... 你打打看就知了 
• 參數 -h 有 human readable 的意思, 例如 16384B 
—> 16KB
• env 列出環境變數 
• env | grep python 
• sudo [command] 以 root 執⾏行 command 
• sudo su - 變⾝身為 root 
• sudo 與 su 的不同 
• sudo 打的是⾃自⼰己的密碼, 使⽤用者要列在 /etc/sudoers 才⾏行 
• su 打的是 root 的密碼 
• 共⽤用密碼其實很危險, 不推薦直接使⽤用 su
網路相關 
• ifconfig 網卡的相關資訊 (interface config) 
• nslookup 查 DNS 
• nslookup google.com.tw 
• nslookup 60.199.175.31 
• dig google.com.tw ⼀一樣是查 DNS
網路相關 
• telnet ptt.cc 
• telnet google.com 80 
• GET / HTTP/1.1 
• ssh xxx.com 
• 暗⿊黑⼤大法 
ssh xxx.com -D8080
網路相關 
• wget URL 
• wget http://www.google.com.tw/ 
• curl URL 
• https://gist.github.com/caspyin/2288960 
(some tutorial)
網路相關 
• scp yychen@test.com:~/test.py ./ 
• scp ./test.py yychen@test.com:~/
• gzip test.txt 
• gunzip test.txt.gz 
• tar zcvf xxx.tgz asdf asdf asdf 
• tar zxvf xxx.tgz 
• xxx.tar.gz, xxx.tgz
screen ⼤大法 
• 先到 https://github.com/yychen/settings/blob/master/screenrc 把內容貼到 ~/.screenrc 
• $ screen 
• Ctrl-A c 製造新的視窗 
• Ctrl-A [spcae] 跳到下⼀一個視窗 
• Ctrl-A [backspace] 跳到前⼀一個視窗 
• Ctrl-A ## 跳到那⼀一個號碼的視窗 
• Ctrl-A d 跳離 (但是東⻄西都還在) 
• Ctrl-A k 把視窗殺死 
• $ screen -r -d 列出有哪些 session 
• $ screen -r -d [PID]
screen ⼤大法 
• Ctrl-A ESC (或 Ctrl-A [) 凍結畫⾯面可以上下卷 
• q 跳回 
• h, j, k, l —> 左, 下, 上, 右 
• Ctrl-B 上⼀一⾴頁 
• Ctrl-F 下⼀一⾴頁 
• $ 游標到這⾏行的最後⼀一個字元 
• | 游標到這⾏行的第⼀一個字元
神編輯器 vi (vim) 
• $ vi 
• .vimrc 
• https://gist.github.com/yychen/5848216 
• 威猛神指南 
• http://blog.vgod.tw/2009/12/08/vim-cheat-sheet-for-programmers/ 
• http://c9s.blogspot.tw/2009/08/vim-hacks-coscup.html
神編輯器 vi (vim) 
• 指令模式 (移動) 
• h, j, k, l —> 左, 下, 上, 右 
• ^ 這⼀一⾏行⾮非空⽩白的⾏行頭 
• | 這⼀一⾏行的第⼀一個字元 
• $ ⾏行尾 
• :1 第⼀一⾏行 (:## 第幾⾏行) 
• G 最後⼀一⾏行 
• Ctrl-F 下⼀一⾴頁 
• Ctrl-B 上⼀一⾴頁 
• w 下⼀一個詞 
• b 上⼀一個詞 
是否看起來很眼熟? 
j, k 為下、上普遍使⽤用 
ptt (BBS), Facebook 都是使⽤用這些熱鍵 
! 
^ 以及 $ 也會在正規表⽰示式 (regular 
expression) 看到
神編輯器 vi (vim) 
• 指令模式 (搜尋) 
• / 搜尋 
• n 下⼀一個 
• N 上⼀一個 
• ? 反向搜尋 
很多程式搜尋的快捷建都是 / 
例如: ptt, Firefox
神編輯器 vi (vim) 
• 指令模式 (插⼊入 INSERT MODE) 
• i 插⼊入 
• a 從下⼀一個字元插⼊入 
• I 從⾏行頭插⼊入 
• o 從下⼀一⾏行插⼊入 
• O 從上⼀一⾏行插⼊入 
• 插⼊入模式進⼊入後按 ESC 退出
神編輯器 vi (vim) 
• 指令模式 (刪除) 
• dw 刪除這個字 
• dd 刪除這⼀一⾏行 
• 10dd 刪除⼗十⾏行 
• dG 刪除到整個檔案的最後 
• d:1 刪除到整個檔案的第⼀一⾏行 
• d$ 從游標刪除到⾏行尾 
• x 刪除這個字元 
• 10x 刪除⼗十個字元
神編輯器 vi (vim) 
• 指令模式 (剪貼) 
• u 回復 
• p 貼上 
• yy 把這⼀一⾏行貼到 vi 的剪貼簿
神編輯器 vi (vim) 
• 指令模式 (圈選模式 VISUAL MODE) 
• V 進⼊入圈選模式 (整⾏行) 
• Ctrl-V 進⼊入圈選模式 (區塊) 
• 圈選後 
• y 把圈選的區域 copy 到剪貼簿 
• x 刪除 
• d 刪除
神編輯器 vi (vim) 
• 指令模式 
• :x (:wq) 存檔並結束 
• :w 存檔 
• :w [filename] 存成另外⼀一個檔案 
• :q 跳出 
• :q! 不存檔跳出 
• :edit 重新載⼊入 
• :![shell command] 執⾏行 shell 指令
看起來超強的⽅方式 
1. ⽤用 screen (或 tmux), 下⾯面⼀一定要有⼀一條 
2. irssi 
3. 會⽤用 vim 
4. 會⽤用 python or ruby
irssi 
• IRC client 
• $ irssi -c irc.freenode.net 
• /join python.tw
不⼩小⼼心按到的鍵 
• 不⼩小⼼心按到 Ctrl-S (只有 Linux 才會這樣) 
• 你的電腦會完全的 hang 住 
• 按下 Ctrl-Q 解開 
• 不⼩小⼼心按到 Ctrl-Z 
• 你的程式跑到背景了 
• $ fg 或 
• $ %

More Related Content

What's hot

Effective linux.2.(tools)
Effective linux.2.(tools)Effective linux.2.(tools)
Effective linux.2.(tools)wang hongjiang
 
Binary exploitation - AIS3
Binary exploitation - AIS3Binary exploitation - AIS3
Binary exploitation - AIS3Angel Boy
 
揭秘家用路由器Ch10 sharing
揭秘家用路由器Ch10 sharing揭秘家用路由器Ch10 sharing
揭秘家用路由器Ch10 sharingYi-Jun Zheng
 
Heap exploitation
Heap exploitationHeap exploitation
Heap exploitationAngel Boy
 
Linux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeLinux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeAngel Boy
 
Return to dlresolve
Return to dlresolveReturn to dlresolve
Return to dlresolveAngel Boy
 
Effective linux.1.(commandline)
Effective linux.1.(commandline)Effective linux.1.(commandline)
Effective linux.1.(commandline)wang hongjiang
 
Clojure
ClojureClojure
ClojureDi Xu
 
Advanced heap exploitaion
Advanced heap exploitaionAdvanced heap exploitaion
Advanced heap exploitaionAngel Boy
 
Sigreturn Oriented Programming
Sigreturn Oriented ProgrammingSigreturn Oriented Programming
Sigreturn Oriented ProgrammingAngel Boy
 
02.python基础
02.python基础02.python基础
02.python基础modou li
 
compiler fuzzer : prog fuzz介紹
compiler fuzzer : prog fuzz介紹compiler fuzzer : prog fuzz介紹
compiler fuzzer : prog fuzz介紹fdgkhdkgh tommy
 
Linux Binary Exploitation - Stack buffer overflow
Linux Binary Exploitation - Stack buffer overflowLinux Binary Exploitation - Stack buffer overflow
Linux Binary Exploitation - Stack buffer overflowAngel Boy
 
shell script introduction
shell script introductionshell script introduction
shell script introductionJie Jin
 
4, grep
4, grep4, grep
4, grepted-xu
 
Linux Binary Exploitation - Heap Exploitation
Linux Binary Exploitation - Heap Exploitation Linux Binary Exploitation - Heap Exploitation
Linux Binary Exploitation - Heap Exploitation Angel Boy
 

What's hot (20)

Effective linux.2.(tools)
Effective linux.2.(tools)Effective linux.2.(tools)
Effective linux.2.(tools)
 
Some tips
Some tipsSome tips
Some tips
 
Binary exploitation - AIS3
Binary exploitation - AIS3Binary exploitation - AIS3
Binary exploitation - AIS3
 
揭秘家用路由器Ch10 sharing
揭秘家用路由器Ch10 sharing揭秘家用路由器Ch10 sharing
揭秘家用路由器Ch10 sharing
 
Execution
ExecutionExecution
Execution
 
Heap exploitation
Heap exploitationHeap exploitation
Heap exploitation
 
Linux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeLinux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledge
 
Return to dlresolve
Return to dlresolveReturn to dlresolve
Return to dlresolve
 
Effective linux.1.(commandline)
Effective linux.1.(commandline)Effective linux.1.(commandline)
Effective linux.1.(commandline)
 
Zsh
ZshZsh
Zsh
 
Windbg入门
Windbg入门Windbg入门
Windbg入门
 
Clojure
ClojureClojure
Clojure
 
Advanced heap exploitaion
Advanced heap exploitaionAdvanced heap exploitaion
Advanced heap exploitaion
 
Sigreturn Oriented Programming
Sigreturn Oriented ProgrammingSigreturn Oriented Programming
Sigreturn Oriented Programming
 
02.python基础
02.python基础02.python基础
02.python基础
 
compiler fuzzer : prog fuzz介紹
compiler fuzzer : prog fuzz介紹compiler fuzzer : prog fuzz介紹
compiler fuzzer : prog fuzz介紹
 
Linux Binary Exploitation - Stack buffer overflow
Linux Binary Exploitation - Stack buffer overflowLinux Binary Exploitation - Stack buffer overflow
Linux Binary Exploitation - Stack buffer overflow
 
shell script introduction
shell script introductionshell script introduction
shell script introduction
 
4, grep
4, grep4, grep
4, grep
 
Linux Binary Exploitation - Heap Exploitation
Linux Binary Exploitation - Heap Exploitation Linux Binary Exploitation - Heap Exploitation
Linux Binary Exploitation - Heap Exploitation
 

Viewers also liked

真蝦意外接到的Case
真蝦意外接到的Case真蝦意外接到的Case
真蝦意外接到的CaseTom Chen
 
Live Performance Effects
Live Performance EffectsLive Performance Effects
Live Performance EffectsTom Chen
 
Pytables
PytablesPytables
Pytablesgowell
 
Two scoops of Django - Deployment
Two scoops of Django - DeploymentTwo scoops of Django - Deployment
Two scoops of Django - Deploymentflywindy
 
Two scoops of django Introduction
Two scoops of django IntroductionTwo scoops of django Introduction
Two scoops of django Introductionflywindy
 
Elasticsearch intro output
Elasticsearch intro outputElasticsearch intro output
Elasticsearch intro outputTom Chen
 
AngularJS Sharing
AngularJS SharingAngularJS Sharing
AngularJS SharingTom Chen
 
Working with the django admin
Working with the django admin Working with the django admin
Working with the django admin flywindy
 
愛樂工程師
愛樂工程師愛樂工程師
愛樂工程師Tom Chen
 
Django 實戰 - 自己的購物網站自己做
Django 實戰 - 自己的購物網站自己做Django 實戰 - 自己的購物網站自己做
Django 實戰 - 自己的購物網站自己做flywindy
 
Integrating tornado and webpack
Integrating tornado and webpackIntegrating tornado and webpack
Integrating tornado and webpackTom Chen
 
那些年,我用 Django Admin 接的案子
那些年,我用 Django Admin 接的案子那些年,我用 Django Admin 接的案子
那些年,我用 Django Admin 接的案子flywindy
 
Learning django step 1
Learning django step 1Learning django step 1
Learning django step 1永昇 陳
 
Django workshop homework 3
Django workshop homework 3Django workshop homework 3
Django workshop homework 3flywindy
 
解密解密
解密解密解密解密
解密解密Tom Chen
 
Django sharing
Django sharingDjango sharing
Django sharingTom Chen
 
Django best practices for logging and signals
Django best practices for logging and signals Django best practices for logging and signals
Django best practices for logging and signals flywindy
 

Viewers also liked (20)

真蝦意外接到的Case
真蝦意外接到的Case真蝦意外接到的Case
真蝦意外接到的Case
 
Live Performance Effects
Live Performance EffectsLive Performance Effects
Live Performance Effects
 
Xmas
XmasXmas
Xmas
 
Pytables
PytablesPytables
Pytables
 
Two scoops of Django - Deployment
Two scoops of Django - DeploymentTwo scoops of Django - Deployment
Two scoops of Django - Deployment
 
Two scoops of django Introduction
Two scoops of django IntroductionTwo scoops of django Introduction
Two scoops of django Introduction
 
Elasticsearch intro output
Elasticsearch intro outputElasticsearch intro output
Elasticsearch intro output
 
AngularJS Sharing
AngularJS SharingAngularJS Sharing
AngularJS Sharing
 
Django step0
Django step0Django step0
Django step0
 
Gitlab
GitlabGitlab
Gitlab
 
Working with the django admin
Working with the django admin Working with the django admin
Working with the django admin
 
愛樂工程師
愛樂工程師愛樂工程師
愛樂工程師
 
Django 實戰 - 自己的購物網站自己做
Django 實戰 - 自己的購物網站自己做Django 實戰 - 自己的購物網站自己做
Django 實戰 - 自己的購物網站自己做
 
Integrating tornado and webpack
Integrating tornado and webpackIntegrating tornado and webpack
Integrating tornado and webpack
 
那些年,我用 Django Admin 接的案子
那些年,我用 Django Admin 接的案子那些年,我用 Django Admin 接的案子
那些年,我用 Django Admin 接的案子
 
Learning django step 1
Learning django step 1Learning django step 1
Learning django step 1
 
Django workshop homework 3
Django workshop homework 3Django workshop homework 3
Django workshop homework 3
 
解密解密
解密解密解密解密
解密解密
 
Django sharing
Django sharingDjango sharing
Django sharing
 
Django best practices for logging and signals
Django best practices for logging and signals Django best practices for logging and signals
Django best practices for logging and signals
 

Similar to Command line 初級寶典

Linux基础
Linux基础Linux基础
Linux基础zhuqling
 
Linux必备知识与Unix基础文化
Linux必备知识与Unix基础文化Linux必备知识与Unix基础文化
Linux必备知识与Unix基础文化Dahui Feng
 
網路組-Ubuntu介紹
網路組-Ubuntu介紹網路組-Ubuntu介紹
網路組-Ubuntu介紹maryqute520
 
Vim+神技 (1)
Vim+神技 (1)Vim+神技 (1)
Vim+神技 (1)Ailsa126
 
Vim hacks
Vim hacksVim hacks
Vim hacksXuYj
 
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具Will Huang
 
開發流程與工具介紹
開發流程與工具介紹開發流程與工具介紹
開發流程與工具介紹Shengyou Fan
 
Vim 神技
Vim 神技Vim 神技
Vim 神技hotoo
 
我的 Windows 平台自動化經驗:基礎批次檔撰寫實務
我的 Windows 平台自動化經驗:基礎批次檔撰寫實務我的 Windows 平台自動化經驗:基礎批次檔撰寫實務
我的 Windows 平台自動化經驗:基礎批次檔撰寫實務Will Huang
 
Shell,信号量以及java进程的退出
Shell,信号量以及java进程的退出Shell,信号量以及java进程的退出
Shell,信号量以及java进程的退出wang hongjiang
 
Effective_Vim
Effective_VimEffective_Vim
Effective_VimKing Hom
 
Emacs入门
Emacs入门Emacs入门
Emacs入门yinhm .
 
COSCUP 2016 - LLVM 由淺入淺
COSCUP 2016 - LLVM 由淺入淺COSCUP 2016 - LLVM 由淺入淺
COSCUP 2016 - LLVM 由淺入淺宗凡 楊
 

Similar to Command line 初級寶典 (20)

Linux基础
Linux基础Linux基础
Linux基础
 
Vim 101
Vim 101Vim 101
Vim 101
 
Python 温故
Python 温故Python 温故
Python 温故
 
Work with Vim
Work with VimWork with Vim
Work with Vim
 
Linux必备知识与Unix基础文化
Linux必备知识与Unix基础文化Linux必备知识与Unix基础文化
Linux必备知识与Unix基础文化
 
網路組-Ubuntu介紹
網路組-Ubuntu介紹網路組-Ubuntu介紹
網路組-Ubuntu介紹
 
Vim+神技 (1)
Vim+神技 (1)Vim+神技 (1)
Vim+神技 (1)
 
Vim hacks
Vim hacksVim hacks
Vim hacks
 
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
 
Rootkit 101
Rootkit 101Rootkit 101
Rootkit 101
 
開發流程與工具介紹
開發流程與工具介紹開發流程與工具介紹
開發流程與工具介紹
 
Win dbg入门
Win dbg入门Win dbg入门
Win dbg入门
 
Vim 神技
Vim 神技Vim 神技
Vim 神技
 
Linux学习
Linux学习Linux学习
Linux学习
 
我的 Windows 平台自動化經驗:基礎批次檔撰寫實務
我的 Windows 平台自動化經驗:基礎批次檔撰寫實務我的 Windows 平台自動化經驗:基礎批次檔撰寫實務
我的 Windows 平台自動化經驗:基礎批次檔撰寫實務
 
Ubuntu
UbuntuUbuntu
Ubuntu
 
Shell,信号量以及java进程的退出
Shell,信号量以及java进程的退出Shell,信号量以及java进程的退出
Shell,信号量以及java进程的退出
 
Effective_Vim
Effective_VimEffective_Vim
Effective_Vim
 
Emacs入门
Emacs入门Emacs入门
Emacs入门
 
COSCUP 2016 - LLVM 由淺入淺
COSCUP 2016 - LLVM 由淺入淺COSCUP 2016 - LLVM 由淺入淺
COSCUP 2016 - LLVM 由淺入淺
 

Command line 初級寶典

  • 1. Command Line 初級寶典 Tom Chen @ IF+ TechArt
  • 3. • cd (change directory) • cd ~/Desktop • passwd (change password) • ls (list) • ls -alh | more • pwd (print working directory) • w • which [command] (find where the command is) • man [command] (Manual) • man ls
  • 4. • Ctrl-E 到最後⼀一個字 • Ctrl-A 到最前⼀一個字 • Ctrl-U 從游標所在位置消滅到最前⾯面 • Ctrl-D 中斷連線、終⽌止程式... 等 • (箭頭上) 上⼀一個指令 • (建投下) 下⼀一個指令 • ![command partial] 上⼀一個指令 • 例: $ telnet google.com.tw 80 • $ !telnet • 通常 Ctrl 會簡寫為 ^。例如 Ctrl-E —> ^E
  • 5. 檔案系統 • mv file1 file2 • cp file1 file2 • cp -r dir1 dir2 (cp -a dir1 dir2) • rm file1 • rm -r dir1 ⾮非常⾮非常⾮非常的危險!!! • rm -rf dir1 ⾮非常⾮非常⾮非常的危險!!! • ln -s file1 file2 (製作連結檔)
  • 6. 檔案系統 • chmod 777 test.py • chmod u+x test.py • http://zh.wikipedia.org/wiki/Chmod
  • 7. • top 列出⺫⽬目前最⾼高的幾個 process • uptime 開機多久 (也會列出 CPU loading) • ps aux 列出⺫⽬目前所有 process • ps ax | grep vi • kill [pid] 把這個 process 殺死 • kill -9 [pid] 最暴⼒力
  • 8. • 找檔案內的字串 • grep midi * • grep -r midi * • 找檔名 • find . | grep meetup
  • 9. • more [filename] 顯⽰示檔案 • less [filename] 顯⽰示檔案 • cat [filename] 顯⽰示檔案 (⼀一股腦兒地) • head [filename] 顯⽰示檔案的前幾⾏行 • tail [filename] 顯⽰示檔案的最後幾⾏行 • tail -F [filename] 會⾃自動更新 (看 log 檔很有⽤用) • touch [filename] 產⽣生⼀一個空的檔案
  • 10. pipe / redirect • command1 | command2 • command1 的 output 導進 command2 的 input • cat abc.txt | more • cat file.txt > file2.txt 貼到 file2.txt • echo ‘1234’ > file.txt • cat file.txt >> file2.txt 貼在 file2.txt 後⾯面
  • 11. • diff file1.txt file2.txt • diff -r dir1 dir2
  • 12. • df -h 看⺫⽬目前磁碟狀況 (空間) • du 列出⺫⽬目前檔案結構的空間 • du -h -d 0 列出⺫⽬目前這個⺫⽬目錄底下佔了多少空間 • du -h -d 1 ⼀一樣意思但是... 你打打看就知了 • 參數 -h 有 human readable 的意思, 例如 16384B —> 16KB
  • 13. • env 列出環境變數 • env | grep python • sudo [command] 以 root 執⾏行 command • sudo su - 變⾝身為 root • sudo 與 su 的不同 • sudo 打的是⾃自⼰己的密碼, 使⽤用者要列在 /etc/sudoers 才⾏行 • su 打的是 root 的密碼 • 共⽤用密碼其實很危險, 不推薦直接使⽤用 su
  • 14. 網路相關 • ifconfig 網卡的相關資訊 (interface config) • nslookup 查 DNS • nslookup google.com.tw • nslookup 60.199.175.31 • dig google.com.tw ⼀一樣是查 DNS
  • 15. 網路相關 • telnet ptt.cc • telnet google.com 80 • GET / HTTP/1.1 • ssh xxx.com • 暗⿊黑⼤大法 ssh xxx.com -D8080
  • 16. 網路相關 • wget URL • wget http://www.google.com.tw/ • curl URL • https://gist.github.com/caspyin/2288960 (some tutorial)
  • 17. 網路相關 • scp yychen@test.com:~/test.py ./ • scp ./test.py yychen@test.com:~/
  • 18. • gzip test.txt • gunzip test.txt.gz • tar zcvf xxx.tgz asdf asdf asdf • tar zxvf xxx.tgz • xxx.tar.gz, xxx.tgz
  • 19. screen ⼤大法 • 先到 https://github.com/yychen/settings/blob/master/screenrc 把內容貼到 ~/.screenrc • $ screen • Ctrl-A c 製造新的視窗 • Ctrl-A [spcae] 跳到下⼀一個視窗 • Ctrl-A [backspace] 跳到前⼀一個視窗 • Ctrl-A ## 跳到那⼀一個號碼的視窗 • Ctrl-A d 跳離 (但是東⻄西都還在) • Ctrl-A k 把視窗殺死 • $ screen -r -d 列出有哪些 session • $ screen -r -d [PID]
  • 20. screen ⼤大法 • Ctrl-A ESC (或 Ctrl-A [) 凍結畫⾯面可以上下卷 • q 跳回 • h, j, k, l —> 左, 下, 上, 右 • Ctrl-B 上⼀一⾴頁 • Ctrl-F 下⼀一⾴頁 • $ 游標到這⾏行的最後⼀一個字元 • | 游標到這⾏行的第⼀一個字元
  • 21. 神編輯器 vi (vim) • $ vi • .vimrc • https://gist.github.com/yychen/5848216 • 威猛神指南 • http://blog.vgod.tw/2009/12/08/vim-cheat-sheet-for-programmers/ • http://c9s.blogspot.tw/2009/08/vim-hacks-coscup.html
  • 22. 神編輯器 vi (vim) • 指令模式 (移動) • h, j, k, l —> 左, 下, 上, 右 • ^ 這⼀一⾏行⾮非空⽩白的⾏行頭 • | 這⼀一⾏行的第⼀一個字元 • $ ⾏行尾 • :1 第⼀一⾏行 (:## 第幾⾏行) • G 最後⼀一⾏行 • Ctrl-F 下⼀一⾴頁 • Ctrl-B 上⼀一⾴頁 • w 下⼀一個詞 • b 上⼀一個詞 是否看起來很眼熟? j, k 為下、上普遍使⽤用 ptt (BBS), Facebook 都是使⽤用這些熱鍵 ! ^ 以及 $ 也會在正規表⽰示式 (regular expression) 看到
  • 23. 神編輯器 vi (vim) • 指令模式 (搜尋) • / 搜尋 • n 下⼀一個 • N 上⼀一個 • ? 反向搜尋 很多程式搜尋的快捷建都是 / 例如: ptt, Firefox
  • 24. 神編輯器 vi (vim) • 指令模式 (插⼊入 INSERT MODE) • i 插⼊入 • a 從下⼀一個字元插⼊入 • I 從⾏行頭插⼊入 • o 從下⼀一⾏行插⼊入 • O 從上⼀一⾏行插⼊入 • 插⼊入模式進⼊入後按 ESC 退出
  • 25. 神編輯器 vi (vim) • 指令模式 (刪除) • dw 刪除這個字 • dd 刪除這⼀一⾏行 • 10dd 刪除⼗十⾏行 • dG 刪除到整個檔案的最後 • d:1 刪除到整個檔案的第⼀一⾏行 • d$ 從游標刪除到⾏行尾 • x 刪除這個字元 • 10x 刪除⼗十個字元
  • 26. 神編輯器 vi (vim) • 指令模式 (剪貼) • u 回復 • p 貼上 • yy 把這⼀一⾏行貼到 vi 的剪貼簿
  • 27. 神編輯器 vi (vim) • 指令模式 (圈選模式 VISUAL MODE) • V 進⼊入圈選模式 (整⾏行) • Ctrl-V 進⼊入圈選模式 (區塊) • 圈選後 • y 把圈選的區域 copy 到剪貼簿 • x 刪除 • d 刪除
  • 28. 神編輯器 vi (vim) • 指令模式 • :x (:wq) 存檔並結束 • :w 存檔 • :w [filename] 存成另外⼀一個檔案 • :q 跳出 • :q! 不存檔跳出 • :edit 重新載⼊入 • :![shell command] 執⾏行 shell 指令
  • 29. 看起來超強的⽅方式 1. ⽤用 screen (或 tmux), 下⾯面⼀一定要有⼀一條 2. irssi 3. 會⽤用 vim 4. 會⽤用 python or ruby
  • 30. irssi • IRC client • $ irssi -c irc.freenode.net • /join python.tw
  • 31. 不⼩小⼼心按到的鍵 • 不⼩小⼼心按到 Ctrl-S (只有 Linux 才會這樣) • 你的電腦會完全的 hang 住 • 按下 Ctrl-Q 解開 • 不⼩小⼼心按到 Ctrl-Z • 你的程式跑到背景了 • $ fg 或 • $ %