Linux Programming Tutoring Introduction to Linux environment and

  • Slides: 26
Download presentation
Linux Programming Tutoring - Introduction to Linux environment and frequently used commands - TA

Linux Programming Tutoring - Introduction to Linux environment and frequently used commands - TA : 陳欣毅

Outline • Introduce Linux environment • What is shell • Frequently used commands

Outline • Introduce Linux environment • What is shell • Frequently used commands

Linux environment (1/2) • Linux is an operating system (OS) Application System call Kernel

Linux environment (1/2) • Linux is an operating system (OS) Application System call Kernel Hardware OS

Linux environment (2/2) • Unix (1973) – 高階C語言 – 容易移植到不同的機器上 • BSD (1977) –

Linux environment (2/2) • Unix (1973) – 高階C語言 – 容易移植到不同的機器上 • BSD (1977) – 是Unix 的重要分支 – Workstation in CSIE (bsd 1 ~ bsd 6) • Linux (1991) – Workstation in CSIE (linux 1 ~ linux 15)

Outline • Introduce Linux environment • What is shell • Frequent used commands

Outline • Introduce Linux environment • What is shell • Frequent used commands

What is shell (1/3) • Shell – An user interface of operating system –

What is shell (1/3) • Shell – An user interface of operating system – For example : 用電腦聽音樂 • 硬體: 喇叭. 音效卡晶片 • Kernel management: driver • App: users • bash, tcsh…

What is shell (2/3) User Interface ( Shell , application ) Kernel Hardware

What is shell (2/3) User Interface ( Shell , application ) Kernel Hardware

Outline • Introduce Linux environment • What is shell • Frequently used commands

Outline • Introduce Linux environment • What is shell • Frequently used commands

Frequent used commands • man – 使用手冊(manual) – 詳細介紹指令的參數 – man ls • exit

Frequent used commands • man – 使用手冊(manual) – 詳細介紹指令的參數 – man ls • exit – 離開

File and Directory (1/2) Command ls cd Synopsis ls [Option] [File] cd [Path] Option

File and Directory (1/2) Command ls cd Synopsis ls [Option] [File] cd [Path] Option Function -a 列出全部檔案包括隱藏檔 -l 列出詳細的檔案資訊 / 回到root底下 ~ 回到家目錄 . . 回上一層 mkdir [Oprion] Dir. 建立目錄 rmdir [Option] Dir. 刪除空目錄 mv mv [Option] Source Dest 移動檔案或重新命名

Process (3/3) Command Synopsis Option Function fg fg [job] 前景執行 bg bg [job] 背景執行

Process (3/3) Command Synopsis Option Function fg fg [job] 前景執行 bg bg [job] 背景執行 jobs [Option] 列出暫停或執行中 作 -l 列出PID Ctrl+C 終止程式 Ctrl+Z 暫停程式 Ctrl+D 送出EOF . /執行檔 啟動程式 指令& 在背景啟動程式

Management • read/write /execute (r/w/x) – r: 4 ; w: 2 ; x: 1

Management • read/write /execute (r/w/x) – r: 4 ; w: 2 ; x: 1 owner group others • owner/group/others rwxrwx – [-rwxrwxrwx] • For example – [-rwxr-x---] – Owner = rwx = 4+2+1 = 7 – Group = r-x = 4+0+1 = 5 – Others = --- = 0+0+0 = 0

Management Command chmod chown Synopsis Option chmod [Option] Mode File 變更檔案屬性 -R 改變目錄內所有File mode

Management Command chmod chown Synopsis Option chmod [Option] Mode File 變更檔案屬性 -R 改變目錄內所有File mode 數字型式的權限屬性 chown [Option] [Owner] File 改變檔案擁有者 -R chgrp Function chgrp [Option] File Recursive 改變目錄下所有File 改變檔案的擁有群組 -R Recursive 改變目錄下所有File

Management • 符號類型改變檔案權限 chmod u g o a + (加入) - (除去) = (設定)

Management • 符號類型改變檔案權限 chmod u g o a + (加入) - (除去) = (設定) r w x File or Dir. • For example : – 假如我們要設定ABC的權限成為-rwxr-xr-x – chmod u=rwx, go+rx ABC

Others (2/3) Command tar Synopsis Option tar [Option] [File] Source Function 建立壓縮檔 -cvf 將資料夾包成

Others (2/3) Command tar Synopsis Option tar [Option] [File] Source Function 建立壓縮檔 -cvf 將資料夾包成 File. tar -czvf 將資料夾壓縮成 File. tar. gz -cjvf 將資料夾壓縮成 File. tar. bz 2 tar [Option] [File] 解開壓縮檔 -xvf 展開File. tar -xzvf 解開File. tar. gz -xjvf 解開File. tar. bz 2

Others (3/3) Command su Synopsis Option su [Option] 轉換身份成為系統管理員 -c diff Function diff [Option]

Others (3/3) Command su Synopsis Option su [Option] 轉換身份成為系統管理員 -c diff Function diff [Option] File 1 File 2 Pass Command 比較兩個檔案的文字內容有 何不同處 -b 忽略一行當中多個空白的差 異 Ex. About you / About -B 忽略空白行 -i 忽略大小寫不同 you

I/O Redirection Command Function Command > file 把command的STDOUT存到file (若檔案存在則覆蓋) Command 1> file command 2>

I/O Redirection Command Function Command > file 把command的STDOUT存到file (若檔案存在則覆蓋) Command 1> file command 2> file 把command的STDERR存到file (若檔案存在則覆蓋) command >> file 把command的STDOUT存到file (若檔案存在則附加在後面) command 1>> file command 2>> file 把command的STDOUT存到file (若檔案存在則附加在後面) command < file 讀入file當作command的STDIN command 0< file

Reference • Linux man page – http: //linux. die. net/man/ • 鳥哥的Linux私房菜 – http:

Reference • Linux man page – http: //linux. die. net/man/ • 鳥哥的Linux私房菜 – http: //linux. vbird. org/ • Linux指令集 – http: //www. pcnet. idv. tw/pcnet/linux/l inux_command. htm