SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Downloaden Sie, um offline zu lesen
Mac OS 
Terminal 常⽤用指令與⼩小技巧
終端機 
• Linux 的介⾯面就是終端機,看到畫⾯面的地⽅方。 
• Linux 系統同時會有很多終端機,⼀一般⼀一次只會 
看到⼀一個。 
• Mac OS 因爲有圖像化介⾯面,視窗的概念,因 
此可以同時操作多個終端機。
Option + ⽅方向鍵 
可快速在⻑⾧長指令內,做遊標的移動
pwd 
• 顯⽰示當前⺫⽬目錄
! 
• 重複上⼀一個執⾏行過,開頭相同的指令 
• ex. !redis > redis-server
ls -alh 
• 可列出當前⺫⽬目錄的檔案系統 
• al: 全部檔案(含隱藏檔)與屬性 
• h: ⼤大⼩小顯⽰示爲可讀的⼤大⼩小(B,K,M)
ls -alh
檔案權限 
權限擁有者羣組
chown 
• 可同時變更擁有者與羣組 
• ex. chown user:group file
檔案權限 
格式爲 drwxrwxrwx 
• 綠:是否爲⺫⽬目錄 
• 紅:擁有者(Owner)權限 
• ⿈黃:羣組(Group)權限 
• 紫:擁有者(Other)權限
檔案權限 
rwx 
• 讀取:是否可讀取 
• 寫⼊入:是否可寫⼊入 
• 執⾏行:是否可執⾏行
檔案權限 
22 
rwx 
• 每⼀一個區塊的權限都是數字的總和 
• 如果只可執⾏行權限就是 1 
• 可讀執⾏行不可寫是 5 
• 不具有權限是 0 
20 
21
chmod 
• 可變更檔案或是資料夾的權限 
• ex. chmod 777 mylog < 最壞⽰示範 
• ex. chmod -R 755 htdoc < Web 常⽤用權限
Recursive與檔案系統 
• 資料夾與檔案都是物件,有各⾃自的權限 
• chmod 與 chown 都只能變更⼀一個標的 
• 遞迴可以讓指令對⺫⽬目標下的檔案與根⺫⽬目錄重複 
執⾏行
rm 
• 只能移除檔案 
• 移除資料夾使⽤用 rmdir ,且只能移除空資料夾 
• 透過遞迴可以移除所有檔案與資料夾 
• ex. rm -Rf test/ < ⾮非常危險
touch 
• 修改檔案時間戳記 (存取時間與更改時間) 
• 有時候也被當做快速建⽴立檔案的⽅方式 
• 建⽴立的檔案權限就是建⽴立者的權限
tail 
• 可在終端機顯⽰示特定檔案最後⼗十⾏行內容 
• 適合⽤用來觀看 log 檔案
tail 
• 加上參數 -n 20 可顯⽰示 20 ⾏行,或是可以偷懶直 
接帶⼊入數字
tail 
• 加上參數 -f 可以讓終端機持續顯⽰示 log 的更新, 
直到按下 Ctrl + C 中斷操作
& 
• 執⾏行檔案的指令後⾯面加上 & 符號,可不鎖定終 
端機 
• 但是這個程式如果有 print 訊息,還是會在終端 
機上⾯面被看到 
• ex. redis-server&
> 
• 執⾏行檔案的指令後⾯面加上 > 符號,可將程式 
print 的訊息導向 
• ex. redis-server > /dev/null
ps 
• Process Status,顯⽰示當前使⽤用者執⾏行的程序 
• 加上 aux 參數,可顯⽰示所有系統的程序 
• ex. ps aux
grep 
• Globally Search a Regular Expression and 
Print,搜尋⼯工具 
• 給 grep 關鍵字或正規表⽰示式,會列出結果 
• ex. grep apple fruitlist.txt
| 
• pipe ,會把左邊的執⾏行結果丟給右邊 
• ex. ps aux | grep redis
kill 
• 關閉系統程序,後⾯面通常加上 PID 
• 正常關閉 : 15 
• 強制關閉 : 9 
• ex. kill -9 5568
Finder
不能被關閉 
• 可以關閉 Finder 所有視窗 
• 但是 Finder 不能被關閉
回到上⼀一層 
• 在 Windows 內是倒退鍵 
• 在 Mac 使⽤用 Cmd+ 上
新增視窗與分⾴頁 
• Cmd+N,開新視窗 
• Cmd+T,開新分⾴頁
精度 
var numA = 0.1; 
var numB = 0.2; 
alert( (numA + numB) === 0.3 ); 
會顯⽰示?
精度 
false
精度 
0.1+0.2 = ???? 
JavaScript 說 
0.01 = 0.0001 1001 1001 1001 … 無限循環 
0.02 = 0.0011 0011 0011 0011 … 無限循環 
不過雙精度浮點數最⾼高是 52 位
精度 
所以相加後是 
0.0100110011001100110011001100110011001 
100110011001100 
轉爲⼗十進位就是 0.30000000000000004
精度 
只要先將數字乘上10的 n 次⽅方,n 是你要的⼩小數 
點精度,運算完在除以10的 n 次⽅方就可以解決這 
個問題。 
ex. 想要算出 0.1+0.2,可寫成 
var accuracy = 1 * 10; 
alert((0.1*accuracy+0.2*accuracy)/accuracy);
閉包 
• myText 執⾏行完 closure_test 之後就應該要消失了 
• 但是因爲 closure_test return 了⼀一個 function,且這 
個 function 內部使⽤用到了 text 變數,形成了⼀一個閉 
包。 
• 這個閉包的特性,就像保護罩⼀一樣保護了 myText 。

Weitere ähnliche Inhalte

Was ist angesagt?

《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具Will Huang
 
Linux Binary Exploitation - Stack buffer overflow
Linux Binary Exploitation - Stack buffer overflowLinux Binary Exploitation - Stack buffer overflow
Linux Binary Exploitation - Stack buffer overflowAngel Boy
 
如何学习Bash Shell
如何学习Bash Shell如何学习Bash Shell
如何学习Bash ShellLI Daobing
 
[Crypto Course] Block Cipher Mode
[Crypto Course] Block Cipher Mode[Crypto Course] Block Cipher Mode
[Crypto Course] Block Cipher ModeWEI CHIEH CHAO
 
shell script introduction
shell script introductionshell script introduction
shell script introductionJie Jin
 
Effective linux.1.(commandline)
Effective linux.1.(commandline)Effective linux.1.(commandline)
Effective linux.1.(commandline)wang hongjiang
 
Linux 教育訓練
Linux 教育訓練Linux 教育訓練
Linux 教育訓練Bo-Yi Wu
 
Binary exploitation - AIS3
Binary exploitation - AIS3Binary exploitation - AIS3
Binary exploitation - AIS3Angel Boy
 
Linux Binary Exploitation - Heap Exploitation
Linux Binary Exploitation - Heap Exploitation Linux Binary Exploitation - Heap Exploitation
Linux Binary Exploitation - Heap Exploitation Angel Boy
 
Linux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeLinux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeAngel Boy
 
新北市教師工作坊 -- Bash script programming 介紹
新北市教師工作坊 -- Bash script programming 介紹新北市教師工作坊 -- Bash script programming 介紹
新北市教師工作坊 -- Bash script programming 介紹fweng322
 
OpenResty/Lua Practical Experience
OpenResty/Lua Practical ExperienceOpenResty/Lua Practical Experience
OpenResty/Lua Practical ExperienceHo Kim
 
Shell奇技淫巧
Shell奇技淫巧Shell奇技淫巧
Shell奇技淫巧David Xie
 
Openstack swift, how does it work?
Openstack swift, how does it work?Openstack swift, how does it work?
Openstack swift, how does it work?kao kuo-tung
 
1, shell intro
1, shell intro1, shell intro
1, shell introted-xu
 
Return to dlresolve
Return to dlresolveReturn to dlresolve
Return to dlresolveAngel Boy
 
Monitor is all for ops
Monitor is all for opsMonitor is all for ops
Monitor is all for ops琛琳 饶
 
深入Docker的资源管理
深入Docker的资源管理深入Docker的资源管理
深入Docker的资源管理SpeedyCloud
 

Was ist angesagt? (20)

《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
 
Windbg入门
Windbg入门Windbg入门
Windbg入门
 
Linux Binary Exploitation - Stack buffer overflow
Linux Binary Exploitation - Stack buffer overflowLinux Binary Exploitation - Stack buffer overflow
Linux Binary Exploitation - Stack buffer overflow
 
如何学习Bash Shell
如何学习Bash Shell如何学习Bash Shell
如何学习Bash Shell
 
[Crypto Course] Block Cipher Mode
[Crypto Course] Block Cipher Mode[Crypto Course] Block Cipher Mode
[Crypto Course] Block Cipher Mode
 
shell script introduction
shell script introductionshell script introduction
shell script introduction
 
Effective linux.1.(commandline)
Effective linux.1.(commandline)Effective linux.1.(commandline)
Effective linux.1.(commandline)
 
Linux 教育訓練
Linux 教育訓練Linux 教育訓練
Linux 教育訓練
 
Binary exploitation - AIS3
Binary exploitation - AIS3Binary exploitation - AIS3
Binary exploitation - AIS3
 
Linux Binary Exploitation - Heap Exploitation
Linux Binary Exploitation - Heap Exploitation Linux Binary Exploitation - Heap Exploitation
Linux Binary Exploitation - Heap Exploitation
 
Linux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeLinux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledge
 
新北市教師工作坊 -- Bash script programming 介紹
新北市教師工作坊 -- Bash script programming 介紹新北市教師工作坊 -- Bash script programming 介紹
新北市教師工作坊 -- Bash script programming 介紹
 
OpenResty/Lua Practical Experience
OpenResty/Lua Practical ExperienceOpenResty/Lua Practical Experience
OpenResty/Lua Practical Experience
 
Shell奇技淫巧
Shell奇技淫巧Shell奇技淫巧
Shell奇技淫巧
 
Openstack swift, how does it work?
Openstack swift, how does it work?Openstack swift, how does it work?
Openstack swift, how does it work?
 
Execution
ExecutionExecution
Execution
 
1, shell intro
1, shell intro1, shell intro
1, shell intro
 
Return to dlresolve
Return to dlresolveReturn to dlresolve
Return to dlresolve
 
Monitor is all for ops
Monitor is all for opsMonitor is all for ops
Monitor is all for ops
 
深入Docker的资源管理
深入Docker的资源管理深入Docker的资源管理
深入Docker的资源管理
 

Ähnlich wie Mac os Terminal 常用指令與小技巧

網路組-Ubuntu介紹
網路組-Ubuntu介紹網路組-Ubuntu介紹
網路組-Ubuntu介紹maryqute520
 
20121111 linux intro
20121111 linux intro20121111 linux intro
20121111 linux introChang Mt
 
Linux必备知识与Unix基础文化
Linux必备知识与Unix基础文化Linux必备知识与Unix基础文化
Linux必备知识与Unix基础文化Dahui Feng
 
Open Street Map安裝指引 (Ubuntu 12.04)
Open Street Map安裝指引 (Ubuntu 12.04)Open Street Map安裝指引 (Ubuntu 12.04)
Open Street Map安裝指引 (Ubuntu 12.04)Marc Huang
 
20030623 linuxbasic and-security
20030623 linuxbasic and-security20030623 linuxbasic and-security
20030623 linuxbasic and-security建融 黃
 
Linux必学的60个命令
Linux必学的60个命令Linux必学的60个命令
Linux必学的60个命令yiditushe
 
4, files & folders
4, files & folders4, files & folders
4, files & foldersted-xu
 
Linux commands ppt
Linux commands pptLinux commands ppt
Linux commands pptxiaotingting
 
推薦系統實作
推薦系統實作推薦系統實作
推薦系統實作FEG
 
開發流程與工具介紹
開發流程與工具介紹開發流程與工具介紹
開發流程與工具介紹Shengyou Fan
 
DRBL-live-hadoop at TSLC
DRBL-live-hadoop at TSLCDRBL-live-hadoop at TSLC
DRBL-live-hadoop at TSLCYu-Chin Tsai
 
5, system admin
5, system admin5, system admin
5, system adminted-xu
 
讓軟體開發與應用更自由 - 使用 Docker 技術
讓軟體開發與應用更自由 - 使用 Docker 技術讓軟體開發與應用更自由 - 使用 Docker 技術
讓軟體開發與應用更自由 - 使用 Docker 技術Yu Lung Shao
 
Docker tutorial
Docker tutorialDocker tutorial
Docker tutorialazole Lai
 
Aix操作系统培训文档
Aix操作系统培训文档Aix操作系统培训文档
Aix操作系统培训文档lwj2012
 
Hadoop-分布式数据平台
Hadoop-分布式数据平台Hadoop-分布式数据平台
Hadoop-分布式数据平台Jacky Chi
 

Ähnlich wie Mac os Terminal 常用指令與小技巧 (20)

網路組-Ubuntu介紹
網路組-Ubuntu介紹網路組-Ubuntu介紹
網路組-Ubuntu介紹
 
20121111 linux intro
20121111 linux intro20121111 linux intro
20121111 linux intro
 
Ubuntu
UbuntuUbuntu
Ubuntu
 
Linux必备知识与Unix基础文化
Linux必备知识与Unix基础文化Linux必备知识与Unix基础文化
Linux必备知识与Unix基础文化
 
Open Street Map安裝指引 (Ubuntu 12.04)
Open Street Map安裝指引 (Ubuntu 12.04)Open Street Map安裝指引 (Ubuntu 12.04)
Open Street Map安裝指引 (Ubuntu 12.04)
 
20030623 linuxbasic and-security
20030623 linuxbasic and-security20030623 linuxbasic and-security
20030623 linuxbasic and-security
 
Linux必学的60个命令
Linux必学的60个命令Linux必学的60个命令
Linux必学的60个命令
 
4, files & folders
4, files & folders4, files & folders
4, files & folders
 
Linux commands ppt
Linux commands pptLinux commands ppt
Linux commands ppt
 
推薦系統實作
推薦系統實作推薦系統實作
推薦系統實作
 
開發流程與工具介紹
開發流程與工具介紹開發流程與工具介紹
開發流程與工具介紹
 
Rootkit 101
Rootkit 101Rootkit 101
Rootkit 101
 
Linux学习
Linux学习Linux学习
Linux学习
 
Win dbg入门
Win dbg入门Win dbg入门
Win dbg入门
 
DRBL-live-hadoop at TSLC
DRBL-live-hadoop at TSLCDRBL-live-hadoop at TSLC
DRBL-live-hadoop at TSLC
 
5, system admin
5, system admin5, system admin
5, system admin
 
讓軟體開發與應用更自由 - 使用 Docker 技術
讓軟體開發與應用更自由 - 使用 Docker 技術讓軟體開發與應用更自由 - 使用 Docker 技術
讓軟體開發與應用更自由 - 使用 Docker 技術
 
Docker tutorial
Docker tutorialDocker tutorial
Docker tutorial
 
Aix操作系统培训文档
Aix操作系统培训文档Aix操作系统培训文档
Aix操作系统培训文档
 
Hadoop-分布式数据平台
Hadoop-分布式数据平台Hadoop-分布式数据平台
Hadoop-分布式数据平台
 

Mehr von Chen Liwei

20160329 facebook access tokens
20160329 facebook access tokens20160329 facebook access tokens
20160329 facebook access tokensChen Liwei
 
Facebook Pixel
Facebook PixelFacebook Pixel
Facebook PixelChen Liwei
 
Facebook Audience
Facebook AudienceFacebook Audience
Facebook AudienceChen Liwei
 
Facebook 競價
Facebook 競價Facebook 競價
Facebook 競價Chen Liwei
 
Facebook Creative 與 Marketing API 使用
Facebook Creative 與 Marketing API 使用Facebook Creative 與 Marketing API 使用
Facebook Creative 與 Marketing API 使用Chen Liwei
 
Facebook Lead Ads 簡介
Facebook Lead Ads 簡介Facebook Lead Ads 簡介
Facebook Lead Ads 簡介Chen Liwei
 
Facebook Dynamic Product Adverts
Facebook Dynamic Product AdvertsFacebook Dynamic Product Adverts
Facebook Dynamic Product AdvertsChen Liwei
 
Why do we need backend testing
Why do we need backend testingWhy do we need backend testing
Why do we need backend testingChen Liwei
 

Mehr von Chen Liwei (8)

20160329 facebook access tokens
20160329 facebook access tokens20160329 facebook access tokens
20160329 facebook access tokens
 
Facebook Pixel
Facebook PixelFacebook Pixel
Facebook Pixel
 
Facebook Audience
Facebook AudienceFacebook Audience
Facebook Audience
 
Facebook 競價
Facebook 競價Facebook 競價
Facebook 競價
 
Facebook Creative 與 Marketing API 使用
Facebook Creative 與 Marketing API 使用Facebook Creative 與 Marketing API 使用
Facebook Creative 與 Marketing API 使用
 
Facebook Lead Ads 簡介
Facebook Lead Ads 簡介Facebook Lead Ads 簡介
Facebook Lead Ads 簡介
 
Facebook Dynamic Product Adverts
Facebook Dynamic Product AdvertsFacebook Dynamic Product Adverts
Facebook Dynamic Product Adverts
 
Why do we need backend testing
Why do we need backend testingWhy do we need backend testing
Why do we need backend testing
 

Mac os Terminal 常用指令與小技巧