• 沒有找到結果。

Linux 系統班

N/A
N/A
Protected

Academic year: 2022

Share "Linux 系統班"

Copied!
103
0
0

加載中.... (立即查看全文)

全文

(1)

Linux 系統班

台大資訊系統訓練班 CSIE:98c76b65a32

http://goo.gl/WPi8p

Hung-Chi Su

12年2月1日星期三

(2)

課程注意事項

·• 確認學員資料&點名

·• 發學員證與筆記本

·• 系館大門門禁卡

·• 需簽收,期末繳回

·• 遺失需補60元

12年2月1日星期三

(3)

課程注意事項

·• 一樓垃圾分類處!

·• 門禁警鈴!

12年2月1日星期三

(4)

課程資訊

·•

課程時間

·•

2012/02/01 - 2012/02/14

·•

講師

·•

蘇宏麒 atdog (atdog.cs96@gmail.com)

·•

李孟翰 dm4 (sunrisedm4@gmail.com)

·•

時段

·•

週一~五 PM 14:00-17:00 (3hrs)

·•

Course website: http://dm4.tw/linux

12年2月1日星期三

(5)

課程介紹

·•

Linux 基礎系統/網路管理實務

·•

課程目標

·•

本課程之目標在於

·•

(1) 培養學員認識與熟悉Linux系統架構

·•

(2) 學習如何管理與配置系統資源

·•

(3) 熟悉多人多工作業系統的管理

·•

(4) 架設網路伺服器

·•

成為一個Linux玩家

12年2月1日星期三

(6)

課程規劃

·•

02/01

·•

Linux distribution

·•

使用者管理,遠端管理

·•

ssh

·•

權限管理

·•

02/02

·•

使用文字介面與 Linux 溝通

·•

[實作] Shell操作

·•

[實作] 系統套件管理

12年2月1日星期三

(7)

課程規劃

·•

02/03

·•

檔案系統

·•

正規表示式

·•

文字編輯器介紹與使用

·•

vim, gvim, ee, nano and joe, etc...

·•

02/06

·•

網路環境設置

·•

網路工具

·•

Dynamic and Static IP Configuration

·•

Network File System(NFS)

12年2月1日星期三

(8)

課程規劃

·•

02/07

·•

系統記錄

·•

排程管理

·•

[實作] 使用者建立Cron job

·•

作業(一) announce

·•

02/08

·•

網頁伺服器(Apache)架設與使用

·•

[實作] 架設網站

12年2月1日星期三

(9)

課程規劃

·•

02/09

·•

程式化腳本應用(Shell Scripts)

·•

作業(一) deadline.

·•

作業(二) announce.

·•

02/10

·•

程序資源分享

·•

檔案伺服器

·•

FTP 架設與使用

12年2月1日星期三

(10)

課程規劃

·•

02/13

·•

防火牆建置

·•

iptable

·•

雲端平台 Amazon

·•

作業(二) deadline

·•

02/14

·•

System/Network security

·•

No exam.

12年2月1日星期三

(11)

課程評分

·•

二次作業

·•

each 30 %

·•

出席

·•

40 %

·•

成績於70分以上之學員,將由訓練班發給正

式之中文及英文結業証書。

12年2月1日星期三

(12)

課程參考

·•

鳥哥的Linux 私房菜

·•

http://linux.vbird.org

·•

Google!

·•

Ubuntu 11.10 link

·•

http://www.ubuntu.com/download/ubuntu/

download

12年2月1日星期三

(13)

12年2月1日星期三

(14)

Outline

·•

Linux history

·•

Linux distribution(Linux OS)

·•

Ubuntu installation

·•

VirtualBox - ubuntu 11.10 32 bit

·•

Remote management - ssh

·•

User management

·•

Permission bit

12年2月1日星期三

(15)

認識 Linux

12年2月1日星期三

(16)

認識 Linux

·•

1973 – Unix 系統

·•

Dennis Ritchie等人於AT&T的貝爾實驗室以C語言寫出第

一個Unix核心

·•

1983年Ritchie與Thompson獲得了 Turing Award (Nobel Prize of Computing),理由是「發展出通用的作業系統理論,

並實作出UNIX作業系統」。

·•

後來:商業價值 -> 版權問題

·•

Unix變種:1977年 BSD誕生,其中以柏克萊加州分校 的版本最著名。

·•

Unix版權:AT&T -> Novell -> SCO(部份版權)

·•

1979 年

12年2月1日星期三

(17)

認識 Linux

·•

1984 - Minix 作業系統(Andrew Tanenbaum)

·•

1984– GNU計畫與自由軟體基金會(FSF, Free Software Foundation)成立

·•

Richard Mathew Stallman:提倡自由、免費、開放的軟體

·•

GNU:建立自由、開放的Unix-like作業系統

·•

透過開發gcc, glibc, bash提倡GNU

·•

1991 – Linux 0.01版誕生

·•

開發者:Linus Torvalds(芬蘭赫爾辛基大學),嚴格地說,

Linux僅代表核心(kernel)

·•

1994年,透過Internet眾多軟體發展人員的共同努力 + GNU軟體 + kernel -> Linux 1.0版

12年2月1日星期三

(18)

Unix 發展史

12年2月1日星期三

(19)

Linux簡介

·•

是免費、自由、開放的軟體

·•

多人/多工處理環境

·•

允許多使用者同時登入使用,良好的資源分配

·•

安全性與穩定度高

·•

嚴格的權限管理,穩定的套件更新

·•

高度的可攜性(portability)與可擴充性(Scalability)

·•

大型工作站

·•

個人電腦

·•

嵌入式系統

12年2月1日星期三

(20)

Linux distribution

·•

即為我們一般所稱的「Linux作業系統」

·•

系統架構

·•

核心(kernel) + 殼程式(shell)

·•

GNU函式庫/工具

·•

vim文字編輯器, 工程計算機

·•

gcc/g++等編譯器

·•

open office, mozilla firefox, 影音播放, 遊戲…等

·•

圖形介面(Gnome, KDE)

·•

著名的發行版本

·•

CentOS, Debian, Fedora , Gentoo, Ubuntu等

12年2月1日星期三

(21)

Linux 系統架構

·•

kernel

·•

控制管理硬體資源

·•

shell

·•

文字介面 -> 適合遠端管理

·•

接受指令與核心溝通

·•

適用所有的linux版本

·•

程式設計 – shell script

·•

Application

·•

GNU函式庫/軟體

·•

使用者圖形介面(GUI)

·•

其他

12年2月1日星期三

(22)

Linux distribution

·•

CentOS

·•

Debian

·•

Fedora

·•

Gentoo

·•

Ubuntu

·•

http://www.ubuntu.com/download/ubuntu/

download

12年2月1日星期三

(23)

Ubuntu installation

如何安裝

12年2月1日星期三

(24)

Installation

·•

打開Virtual box

12年2月1日星期三

(25)

Installation(cont.)

12年2月1日星期三

(26)

Installation(cont.)

12年2月1日星期三

(27)

Installation(cont.)

12年2月1日星期三

(28)

Installation(cont.)

12年2月1日星期三

(29)

Installation(cont.)

12年2月1日星期三

(30)

Installation(cont.)

12年2月1日星期三

(31)

Installation(cont.)

12年2月1日星期三

(32)

Installation(cont.)

12年2月1日星期三

(33)

Installation(cont.)

12年2月1日星期三

(34)

Installation(cont.)

12年2月1日星期三

(35)

Installation(cont.)

12年2月1日星期三

(36)

Installation(cont.)

12年2月1日星期三

(37)

Installation(cont.)

12年2月1日星期三

(38)

Installation(cont.)

12年2月1日星期三

(39)

Installation(cont.)

12年2月1日星期三

(40)

Installation(cont.)

12年2月1日星期三

(41)

Installation(cont.)

12年2月1日星期三

(42)

等吧...

12年2月1日星期三

(43)

Installation(cont.)

12年2月1日星期三

(44)

Installation(cont.)

12年2月1日星期三

(45)

Installation(cont.)

12年2月1日星期三

(46)

趁下課重開成Linux 吧!

12年2月1日星期三

(47)

開始之前...

12年2月1日星期三

(48)

I am root.

Bring me gifts, and I wont read your email.

12年2月1日星期三

(49)

Super user - root

12年2月1日星期三

(50)

就像是...

windows administrator

12年2月1日星期三

(51)

What is root?

·•

萬能的天神!

·•

All rights or permissions!

·•

# -> root / $ -> user

·•

# id

·•

uid=0(root) gid=0(root)

12年2月1日星期三

(52)

No root password in Ubuntu

12年2月1日星期三

(53)

How to login as root?

12年2月1日星期三

(54)

sudo

Execute a command as another user .

12年2月1日星期三

(55)

What is sudo?

·•

sudo是Linux/Unix中非常有用的工具

·•

分配合理權限給普通用戶

·•

/etc/sudoers

·•

Ubuntu 中預設帳號的sudo權限

·•

ALL

12年2月1日星期三

(56)

When to use sudo?

·•

In ubuntu

·•

when you need root privilege.

·•

More privilege!

12年2月1日星期三

(57)

How to use sudo?

·•

$ id

·•

uid=1000(linux) gid=1000(linux)

·•

$ sudo id

·•

ask for your password

·•

uid=0(root) gid=0(root) groups=0(root)

·•

# id

12年2月1日星期三

(58)

$ man sudo

12年2月1日星期三

(59)

Set password to root

12年2月1日星期三

(60)

How to set password?

·•

$ passwd

·•

set your password

·•

$ sudo passwd

·•

set root password

12年2月1日星期三

(61)

Management without GUI

12年2月1日星期三

(62)

Local Management

本地端管理

12年2月1日星期三

(63)

Use Terminal in Ubuntu

12年2月1日星期三

(64)

本地端管理

·•

Terminal - application

·•

Ctrl + Alt + F1 - F6

·•

switch to other console

·•

Ctrl + Alt + F7 : switch to GUI

12年2月1日星期三

(65)

Remote Management

遠端管理

12年2月1日星期三

(66)

遠端管理

·•

Server - client

·•

Server: Ubuntu (sshd)

·•

Client: windows(putty) or any other OS(ssh)

12年2月1日星期三

(67)

server - sshd

·•

OpenSSH SSH daemon

·•

通常開機會自動啟動

·•

接收ssh connection,並建立secure連線

·•

client - server (port 22)

·•

Daemon

·•

常駐在記憶體中的程式

·•

提供系統或網路功能

12年2月1日星期三

(68)

How to establish the connection?

12年2月1日星期三

(69)

In the client side

12年2月1日星期三

(70)

In Windows

·•

Use putty

12年2月1日星期三

(71)

In Linux

·•

OpenSSH SSH client (remote login program)

·•

ssh username@hostname

12年2月1日星期三

(72)

In the server side

12年2月1日星期三

(73)

Install sshd first

·•

# apt-get update

·•

# apt-cache search openssh-server

·•

# apt-get install openssh-server

·•

# service ssh status

·•

ssh start/running, process 510

·•

# command = $ sudo command

12年2月1日星期三

(74)

Use ssh to login the server

·•

$ ssh username@localhost

12年2月1日星期三

(75)

User management

使用者管理

12年2月1日星期三

(76)

使用者管理

·•

新增使用者

·•

修改密碼

·•

刪除使用者

·•

管理group

·•

相關檔案

12年2月1日星期三

(77)

使用者管理

·•

以ID做權限控管

·•

UID - User ID, GID - Group ID

·•

real UID and GID

·•

effective UID and GID

12年2月1日星期三

(78)

id

print real and effective user and group IDs

12年2月1日星期三

(79)

使用者管理

·•

$ id

·•

uid=1002(hcsu) gid=1002(hcsu) groups=1002(hcsu)

12年2月1日星期三

(80)

新增使用者

·•

# adduser testuser

·•

key in new unix password

·•

and something else.

·•

$ id testuser

12年2月1日星期三

(81)

修改密碼

·•

$ passwd

·•

輸入現有、欲修改成的密碼

·•

# passwd testuser

·•

以root權限修改testuser密碼

·•

$ sudo passwd testuser

12年2月1日星期三

(82)

管理group

·•

新增群組

·•

增加群組使用者

·•

刪除群組

12年2月1日星期三

(83)

新增群組

·•

# addgroup testgroup

·•

add new group

·•

$ cat /etc/group

12年2月1日星期三

(84)

增加群組使用者

·•

# addgroup testuser testgroup

·•

# addgroup username group

·•

# usermod -G testgroup testuser

·•

小心使用

·•

$ id testuser

·•

$ cat /etc/group

12年2月1日星期三

(85)

刪除群組

·•

# delgroup testgroup

·•

cat /etc/group

12年2月1日星期三

(86)

相關檔案

·•

$ cat /etc/passwd

·•

# cat /etc/shadow

·•

$ cat /etc/group

·•

$ ls /home

12年2月1日星期三

(87)

/etc/passwd

·•

多數程式需讀取/etc/passwd這個檔案來了解各

使用者的權限

·•

root:x:0:0:root:/root:/bin/bash

·•

username : x : UID : GID : real_name : home_dir : shell

12年2月1日星期三

(88)

/etc/shadow

·•

實際加密過後的密碼儲存於/etc/shadow中

·•

root:!:15296:0:99999:7:::

·•

username:加密密碼:上次變更的時間:最短生命週

期:最長生命週期:提前幾天警告使用者週期要到:

到其後寬限天數:帳號失效日期:保留欄位

12年2月1日星期三

(89)

/etc/group

·•

root:x:0,testuser

·•

群組名稱:群組密碼:群組GID,屬於此群組的使用

12年2月1日星期三

(90)

passwd, shadow, group

12年2月1日星期三

(91)

/home

·•

家目錄(使用者工作環境)

·•

$ cd ~

·•

change directory to home

·•

$ pwd

·•

print name of working directory

12年2月1日星期三

(92)

相關指令

·•

adduser -> useradd

·•

deluser -> userdel

12年2月1日星期三

(93)

權限(permission)設定

12年2月1日星期三

(94)

Permission bit

·•

$ ls -la

·•

-rw-r--r-- 1 linux linux 94 ... .profile

·•

-rw-r--r-- link_num user group size date name

·•

12年2月1日星期三

(95)

Permission bit

·•

權限 r w x

·•

r : readable

·•

w : writable

·•

x : executable

·•

- : no permission

12年2月1日星期三

(96)

Permission

·•

檔案類型

·•

[ d ] 是目錄

·•

[ - ] 是檔案

·•

[ l ] 是link file

·•

[ b ] 可供儲存的周邊設備

·•

[ c ] 序列埠設備

12年2月1日星期三

(97)

how to change?

·•

chmod

·•

change file mode bits

·•

chown

·•

change file owner and group

·•

chgrp

·•

change group ownership

12年2月1日星期三

(98)

how to change it? chmod.

·•

$ touch testfile

·•

$ ls -l testfile

·•

$ chmod u+x testfile

·•

$ chmod 764 testfile

12年2月1日星期三

(99)

how to change it? chown.

·•

$ ls -l testfile

·•

# chown root testfile

·•

# chown user:root testfile

12年2月1日星期三

(100)

how to change it? chgrp.

·•

$ ls -l testfile

·•

# chgrp root testfile

12年2月1日星期三

(101)

Practice

小練習

12年2月1日星期三

(102)

Practice!

·•

新增testuser1, testuser2 使用者(密碼自定)

·•

新增testgroup,並將testuser1, testuser2加入testgroup

·•

建立檔案 testfile 於/tmp下

·•

並設定testfile

·•

testuser1對testfile權限為 可讀可執行不可寫

·•

testuser2對testfile權限為 僅可執行

·•

others 對 testfile無權限

·•

(hint. use `chgrp` to change group of testfile to `testgroup`)

12年2月1日星期三

(103)

Q&A

12年2月1日星期三

參考文獻

相關文件

e-Learning Series: Effective Use of e-Resources to Develop Students’ English Language Skills at the Secondary Level.. Dr Timothy Taylor, Senior Lecturer Department of English

(a) In your group, discuss what impact the social issues in Learning Activity 1 (and any other socials issues you can think of) have on the world, Hong Kong and you.. Choose the

An additional senior teacher post, to be offset by a post in the rank of Certificated Master/Mistress or Assistant Primary School Master/ Mistress as appropriate, is provided

An additional senior teacher post, to be offset by a post in the rank of CM or Assistant Primary School Master/Mistress (APSM) as appropriate, is provided to each primary

An additional senior teacher post, to be offset by a post in the rank of CM or Assistant Primary School Master/Mistress (APSM) as appropriate, is provided to each primary

An additional senior teacher post, to be offset by a post in the rank of Certificated Master/Mistress or Assistant Primary School Master/Mistress as appropriate, is provided to

An additional senior teacher post, to be offset by a post in the rank of APSM, is provided to each primary special school/special school with primary section that operates six or

An additional senior teacher post, to be offset by a post in the rank of APSM, is provided to each primary special school/special school with primary section that operates six or