Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ITAC | Linux Basics
Search
racterub
July 20, 2020
Programming
0
86
ITAC | Linux Basics
ITAC | Linux Basics
racterub
July 20, 2020
Tweet
Share
More Decks by racterub
See All by racterub
IM620 Web Security
racterub
0
110
ITAC | Websec 3
racterub
0
220
ITAC | Websec 2
racterub
0
190
ITAC | Websec 1
racterub
0
230
Introducing Reverse Engineering @ YZU CS250
racterub
0
200
ITAC | Jinja & Bootstrap
racterub
1
84
ITAC | Flask - Basic Flask
racterub
1
91
ITAC-Flask | Environment setup
racterub
1
64
Other Decks in Programming
See All in Programming
読まないコードリーディング術
hisaju
0
100
苦しいTiDBへの移行を乗り越えて快適な運用を目指す
leveragestech
0
1.1k
Learning Kotlin with detekt
inouehi
1
140
Rubyで始める関数型ドメインモデリング
shogo_tksk
0
140
Swift Testingのモチベを上げたい
stoticdev
2
120
Honoをフロントエンドで使う 3つのやり方
yusukebe
7
3.6k
お前もAI鬼にならないか?👹Bolt & Cursor & Supabase & Vercelで人間をやめるぞ、ジョジョー!👺
taishiyade
7
4.2k
Ça bouge du côté des animations CSS !
goetter
2
150
.NET Frameworkでも汎用ホストが使いたい!
tomokusaba
0
200
Kotlinの開発でも AIをいい感じに使いたい / Making the Most of AI in Kotlin Development
kohii00
5
1.4k
LINE messaging APIを使ってGoogleカレンダーと連携した予約ツールを作ってみた
takumakoike
0
120
Djangoアプリケーション 運用のリアル 〜問題発生から可視化、最適化への道〜 #pyconshizu
kashewnuts
1
270
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
Why Our Code Smells
bkeepers
PRO
336
57k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
133
33k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.5k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
Bash Introduction
62gerente
611
210k
A Modern Web Designer's Workflow
chriscoyier
693
190k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Transcript
Linux Racterub @ ITAC 1
我是誰 • 元智電通英專⼤⼀ • ID: Racterub • 2017-19 AIS3 學員
• 2019 台灣好厲駭 學員 • 最近在補技術債QQ • 我就爛 2
Linux • Linux 是什麼? 3
Linux • Linux 是什麼? • ⼀個作業系統 (廢話) 4
Linux • Linux 是什麼? • ⼀個作業系統 (廢話) • 今天會讓你們實際操作,希望你們已經先載好了 5
Linux • Linux 是什麼? • ⼀個作業系統 (廢話) • 今天會讓你們實際操作,希望你們已經先載好了 •
沒載好的找我領 USB 6
Linux • Linux 是什麼? • ⼀個作業系統 (廢話) • 今天會讓你們實際操作,希望你們已經先載好了 •
沒載好的找我領 USB • Linux 有什麼⽤? 7
Linux • Linux 是什麼? • ⼀個作業系統 (廢話) • 今天會讓你們實際操作,希望你們已經先載好了 •
沒載好的找我領 USB • Linux 有什麼⽤? • 炫砲 8
我原本在想要不要講他的一些背景 但是大概你們會先睡死 9
Ubuntu • Linux 底下的⼀個分⽀ • 新⼿好入⾨ • ⽬前⼤約有⼀億⼈在使⽤ ubuntu 10
• / 根⽬錄 • /bin 系統內建會⽤到的執⾏檔 • /boot 系統啟動會⽤到的檔案 •
/dev Linux 核⼼有認識的設備和裝置的資訊 • /etc 系統設定檔 • /home 所有(非 root)使⽤者的家⽬錄 Filesystem 11
Filesystem • /lib & /lib64 系統程式庫和核⼼模組 • /media & /mnt
裝置的掛載點 • /opt 無法透過套件安裝的軟體的安裝點 • /proc 每個 process 相關檔案 • /root root 使⽤者的家⽬錄 • /usr/bin Ubuntu 預載或是透過套件安裝的安裝點 12
Filesystem • /usr/local ⾃⼰⼿動編譯安裝的安裝點 • /var 常態性變動的檔案 • /tmp 暫存檔
(每次重開機都會清除) Ref: http://linux.vbird.org/linux_basic/0210filepermission.php#dir_fhs 13
好ㄌ 該來實際用用看 了 14
VM • Ubuntu 18.04.3 bionic • 匯入 • ⼯具 ->
匯入 • 密碼: itac 15
VM • How to use? • 打開 Terminal • 輸入
cd ~/Desktop/ • (如果要重置的話輸入 removepg ) • (輸入完再輸入 cd ../playground ) 16
VM • 檢查⼀些設定 • 設定 -> 網路 -> 連接埠轉送 •
應該會長這樣
常見指令 我們這裡只討論 Bash :D 18
? • 如果想知道指令該怎麼⽤,有什麼 option 可以⽤ • man && -- help
• man <command> • <command> -- help 19
Commands • ls [options] <dir> :列出當前⽬錄 • options • -a
all • -l long-list • -h human-readable • cd <dir> :切換當前⽬錄 20
Commands • cp [options] <src> <dst> :複製檔案/資料夾 • -r recursive
• rm [options] <file> :刪除檔案/資料夾 • -r recursive 21
Command • mkdir <dir> :建立資料夾 • rmdir <dir> :刪除資料夾 •
rmdir v.s rm? • rmdir 只能刪除空資料夾,rm 則沒限制 22
Command • find <basedir> [options] :搜尋檔案/資料夾 • -type <options> •
d 資料夾 • f 檔案 • l 連結檔 (Only symbolic link) • s socket 23
Command • find <basedir> [options] :搜尋檔案/資料夾 • -name <filename> •
這個指令建議配 sudo 使⽤,要不然會噴⼀堆垃圾給你 24
Command • cat <filename> :讀取並輸出檔案內容 • head / tail [options]
<filename> :讀取前⾯部分檔案內容並 輸出 • -c <bytes> 讀取前N-bytes • -n <lines> 讀取前N⾏ 25
Command • ssh <user>@<ip/domain> [options] • options • -p <port>
指定 port • -i <identity file> 指定 key file • -R -L 可做 port-forwarding • https://dev.to/samuyi/the-how-to-of-ssh-port- forwarding-1f4e
Command • vim / emacs • 痾那個 • 我不會⽤ emacs
• 不要砲我 • 會的可以上來教 • https://emacs.was.best 27
Vim • Vim 共有三個 mode (常⽤到的 • Normal mode •
Insert mode • Visual mode 28
Vim • Normal mode • 輸入 “:” 就可以輸入指令 • :w
寫入檔案 • :q 離開 vim • 也可 :wq 就是寫入後離開 • 按下 i 就可以進入 insert mode 29
Vim • Insert mode • 就簡單的輸入模式 • 要切換成 normal mode
就按 esc 30
阿系統空空的是能幹嘛? 用 apt 安裝 ! 31
apt • sudo apt <command> [arg1, arg2 …] • command
• install • update • upgrade • show • list • info • remove 32
Webservers 33
Webserver • 主流 • IIS (Microsoft) • Apache (Apache Software
foundation) • Nginx (Nginx, Inc. or F5 Networks) 34
Webservers • IIS • 是由微軟公司提供的基於運⾏Microsoft Windows的網際 網路基本服務。 35
36
Webservers • Apache • Based on httpd • 有多個模組可以使⽤, 包含
php, python .. ,亦有認證 模組 37
38
Webservers • Nginx • 這跟剛剛兩款⼜有⼀點不⼀樣了,除了網⾴伺服器,他 還可以反向代理,負載平衡和 HTTP 快取 • 效能相對
apache 會好⼀點 (不⼀定) • 這次會教你們⽤ nginx 接上 php 39
40
該來手動架 server 了 41
Nginx • 系統內建並沒有 nginx ,所以必須透過 apt 安裝 • sudo apt
install nginx 42 ▲安裝完成⽤瀏覽器會看到這⼀⾴
Nginx • 好的,這樣就算架好 server 了 • 我們可以寫⾃⼰的 html 來玩 •
預設的網⾴根⽬錄是在 /var/www/html 43
Nginx • 可以顯⽰⾃⼰要的東⻄了,但是我們要接 php 才可以在網 ⾴上顯⽰ php 執⾏出來的內容 • 我們依舊需要
apt 來安裝 :D • sudo apt install php-fpm (ubuntu 18.04 預設是 7.2 版的 ㄛ) 44
Nginx + php • Nginx 跟 php-fpm 是載好了,但是兩個完全沒搭上線,需 要⾃⼰進 nginx
的設定檔才⾏ 45
Nginx + php ▲注意,這邊 php7.0-fpm.sock 要改成 php7.2-fpm.sock 46 安裝完了之後就要在 Nginx
接上 php,所以需要在兩個地⽅改設定 ▲在 index.html 後⾯加上 index.php
Nginx + php • 最後還要修改⼀個 php 的設定,他會造成你的 php server 出現漏洞
• 檔案在 /etc/php/7.2/fpm/php.ini • ;cgi.fix_pathinfo = 1 ➤ cgi.fix_pathinfo = 0 47
Nginx + php • 最後重啟 nginx 跟 php-fpm 就可以了 •
sudo systemctl restart nginx • sudo systemctl restart php7.2-fpm 48
Nginx + php • 在 /var/www/html 撰寫⾃⼰的 php 檔應該就可以正常顯⽰ 了喔
! 49
Domains? 50
Domains • 簡單來說,domain ⼤概會像這樣運作 w w w.yzu.edu.tw ? DNS Server
Client 51
Domains • 簡單來說,domain ⼤概會像這樣運作 w w w.yzu.edu.tw ? 139.162.77.188 DNS
Server Client 52
Domains
Domains • 簡單來說,domain ⼤概會像這樣運作 racterub.m e? 139.162.77.188 DNS Server Client
www.yzu.edu.tw (140.138.8.10) HTTP GET 54
Domains (racterub.me)
Domains 56
Domains 57
資源 • ⿃哥 http://linux.vbird.org/ • DigitalOcean https://www.digitalocean.com/community/ tutorials/how-to-install-linux-nginx-mysql-php-lemp- stack-ubuntu-18-04
QA? 59
@racterub @racterub 60