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
Linux Introduction (for Raspberry Pi Course)
Search
Tzu-ping Chung
August 19, 2015
Programming
0
200
Linux Introduction (for Raspberry Pi Course)
Tzu-ping Chung
August 19, 2015
Tweet
Share
More Decks by Tzu-ping Chung
See All by Tzu-ping Chung
Datasets: What it is, and how it was made
uranusjr
0
120
Let’s fix extras in Core Metadata 3.0
uranusjr
0
470
Python Packaging: Why Don’t You Just…?
uranusjr
1
200
這樣的開發環境沒問題嗎?
uranusjr
9
2.5k
Django After Web 2.0
uranusjr
3
2k
We Store Cheese in A Warehouse
uranusjr
1
440
The Python You Don’t Know
uranusjr
17
3k
Python and Asynchrony
uranusjr
0
350
Graphics on Raspberry Pi with Qt 5
uranusjr
0
96k
Other Decks in Programming
See All in Programming
CSC509 Lecture 12
javiergs
PRO
0
160
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
940
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
130
subpath importsで始めるモック生活
10tera
0
320
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
240
cmp.Or に感動した
otakakot
3
210
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
150
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
300
Featured
See All Featured
Embracing the Ebb and Flow
colly
84
4.5k
Happy Clients
brianwarren
98
6.7k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Site-Speed That Sticks
csswizardry
0
29
GraphQLとの向き合い方2022年版
quramy
43
13k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Fireside Chat
paigeccino
34
3k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Transcript
speakerdeck.com/ uranusjr
Agenda • Introduction • The shell • Git • Linux
topics • Writing code • Python basics • Python in shell • Extensions
Introduction to Linux
None
Me • Call me TP • https://uranusjr.com • Python, C++,
OS X, iOS, Web • Tutorials and courses • Speaker • Django Girls Taipei
Quick Polls • Something “not Windows” • Command line interface
• Plain text editors • Programming
None
None
Prompt
pi@raspberrypi:~$
pi@raspberrypi:~$ ⢪欽罏
pi@raspberrypi:~$ ⚺堣せ珕
pi@raspberrypi:~$ 騟䖜
Shell • Core — Shell — User • Command line
interface • Bash (Bourne-Again Shell)
$ pwd /home/pi
$ mkdir bedroom
$ ls bedroom Desktop
$ touch table
$ ls bedroom Desktop table
$ cd bedroom $ pwd 剙곎爙➊랁
$ mkdir closet
銲䙥랁鹌Ⰵ closet
$ cd closet
$ cd ../.. 植㖈➂㖈ㆬ酬♶銲⡲䒦
穩㼨騟䖜 /home/pi/bedroom/closet 湱㼨騟䖜 bedroom/closet
.. = 㢩
現在位置(.) /home/pi/bedroom/closet 外面兩層(../..) /home/pi
$ cd ~ $ cp -‐r bedroom guest-‐room
$ ls 剙⳿植➊랁
$ cd guest-‐room 酬僽やㄤ bedroom ♧垺剣♧ ⦐ closet銲䙥랁墝叆
拷貝一樣東西 cp something 拷貝一樣東西,以及裡面的所有東西 cp -r something
拷貝一樣東西 cp something 拷貝一樣東西,以及裡面的所有東西 cp -r something
չ侶պ䧴չ䒷侶պ
$ man cp ... -‐R, -‐r, -‐-‐recursive
copy directories recursively
$ cd .. 鸍垺剙ⵋㆬ酬
$ mv guest-‐room living-‐room $ ls 剙⳿植➊랁
$ mv living-‐room/closet bedroom/closet2 鸍⦐䭷⟀⨞✪➊랁✲䞔
$ rm ~/table $ rm -‐r ~/bedroom $
rm -‐r ~/living-‐room 敮嫅։
The File System • The root directory • Other partitions
are “mounted” • Things have their places • Names are case-sensitive
/ ├── bin ├── dev ├── etc ├── home │
└── pi ├── lib ├── media ├── opt ├── root ├── tmp ├── usr └── var
Permissions • Essential for Un*x systems • Owner, group, others
• Read, write, execute
$ groups pi adm dialout cdrom sudo audio
video plugdev games users netdev gpio i2c spi input
$ groups pi pi : pi adm dialout cdrom
sudo audio video plugdev games users netdev input spi i2c gpio
$ cd /var $ ls -‐l total 102436
drwxr-‐xr-‐x 8 root root Aug 16 05:17 log drwxrwsr-‐x 2 root mail May 6 22:12 mail -‐rw-‐-‐-‐-‐-‐-‐-‐ 1 root root May 6 23:29 swap drwxrwxrwt 2 root root Jan 11 2015 tmp
奚ꣳ垦硹 䠑纏 r 隡《 w 㻨Ⰵ x 㛂遤鹎Ⰵ湡ꏗ s ⟃暶㹁魨⟨㛂遤
t ⫦乩剤罏〳ⵅꤑ荈䊹涸墂呪
奚ꣳ垦硹 䠑纏 r 隡《 w 㻨Ⰵ x 㛂遤鹎Ⰵ湡ꏗ s ⟃暶㹁魨⟨㛂遤
t ⫦乩剤罏〳ⵅꤑ荈䊹涸墂呪
$ cd /var $ ls -‐l total 102436
drwxr-‐xr-‐x 8 root root Aug 16 05:17 log drwxrwsr-‐x 2 root mail May 6 22:12 mail -‐rw-‐-‐-‐-‐-‐-‐-‐ 1 root root May 6 23:29 swap drwxrwxrwt 2 root root Jan 11 2015 tmp
The Superuser • “root” • Can do anything • Log-in
disabled by default
/ ├── bin ├── dev ├── etc ├── home │
└── pi ├── lib ├── media ├── opt ├── root ├── tmp ├── usr └── var Superuser’s home directory!
sudo • “superuser do” • Run a command as superuser
• Requires the sudo group
$ groups pi pi : pi adm dialout cdrom
sudo audio video plugdev games users netdev input spi i2c gpio
$ whoami pi $ sudo whoami root
Package Manager • APT = Advance package Tool • apt-get
• apt-cache
$ sudo apt-‐get update $ sudo apt-‐get install git
Git Basics
None
None
$ cd ~ $ git clone https://github.com/raspberrypi-‐ tw/workshop.git
$ cd workshop/gpio-‐tutorial-‐03/02_2-‐ led_blink/led_blink.py $ ls led.py
$ python led.py
HJUDMPOF 䭡頺♧⦐(JU墂呪䏨 HJUBEE墂呪 䪾墂呪⸈Ⰵ墂呪䏨 HJUBEE〳⟃♧妄⸈Ⰵ鿈墂呪 HJUDPNNJUN鏽鎹 ⸈Ⰵ♧⦐晝劥 HJUTUBUVT 叆溏湡涸墂呪䏨朜䢀 HJUEJ
叆溏湡墂呪䏨ㄤ♳⦐晝劥⛓涸䊴殯 HJUMPH 叆溏晝劥鎹ꏗ HJUQVTI 㼟劥㖒墂呪䏨♳⫄荛黇畮 HJUQVMM 刿倞劥㖒Ⰹ㺂
How a Linux OS Boots
Boot Sequence • Load the kernel (details omitted) • Prepare
the system • Start services • Run custom startup hooks • User log in
Boot Sequence • Load the kernel (details omitted) • Prepare
the system • Start services • Run custom startup hooks • User log in
Run Levels ꡠ堥 ㋲➃笞隌垸䒭 搂/'4㢵➃垸䒭 㸤侮㢵➃垸䒭
⥃殆 㕮䕎➝ ꅾ堥
$ ls -‐d /etc/rc* /etc/rc0.d /etc/rc1.d /etc/rc2.d
/etc/rc3.d /etc/rc4.d /etc/rc5.d /etc/rc6.d /etc/rc.local /etc/rcS.d
$ ls -‐d /etc/rc* /etc/rc0.d /etc/rc1.d /etc/rc2.d
/etc/rc3.d /etc/rc4.d /etc/rc5.d /etc/rc6.d /etc/rc.local /etc/rcS.d
raspberrypi login:
$ ls -‐A ~ .bashrc .bash_logout
.bash_profile .profile $ ls -‐d /etc/profile* /etc/profile /etc/profile.d
Summary • Startup • Run levels • Single-user and multi-user
mode • Login shells and non-login shells
$ nano
None
^R ➿邌 Control
倰ぢ꒳ 獵⹛康垦 1H6Q 1H%O )PNF &OE 獵⹛康垦 ^O 㶸墂 ^R
㉬墂呪 ^X 鷎ⴀ剚鑉㉏僽や⮭㶸墂呪 ^W 䵃㼦 ^K 䭡頺♧遤俒㶶 ^U 顦♳⛓䭡頺涸俒㶶
Demo
Error writing /etc/hosts: Permission denied
Demo
Try it!
$ cd ~ $ git clone https://github.com/serialhex/ nano-‐highlight.git .nano
$ nano .nanorc
include "~/.nano/python.nanorc" set tabsize 4 set tabstospaces