introduction. system administrator? 系統管理員 不只是 it 管理別人 /...
TRANSCRIPT
![Page 1: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/1.jpg)
Introduction
![Page 2: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/2.jpg)
![Page 3: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/3.jpg)
![Page 4: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/4.jpg)
![Page 5: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/5.jpg)
System Administrator?
• 系統管理員• 不只是 IT
• 管理別人 / 大家使用的系統• http://www.theage.com.au/articles/2002/12/27/1040511172494.h
tml
![Page 6: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/6.jpg)
工作內容
• 裝機設定 / 更新• 讓機器 / 系統不要掛• 找問題• 引進並整合新科技• 寫文件• 未雨綢繆 - 防災演練• 資訊安全
![Page 7: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/7.jpg)
工作需求
• 能力傾向 (aptitude)
• 快速上手複雜的東西• 掌握東西如何運作• 小心行事• 把東西搞爆了可以很快救回來• 溝通技巧• 品德操守
![Page 8: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/8.jpg)
參考資料• Unix and Linux System Administration Handbook
• Essential System Administration (O'Reilly)
• http://people.cs.nctu.edu.tw/~huanghs/course/sysadm2011/
• http://www.washington.edu/R870/ ( 有點舊 )
• 我們絕對講不完 !!
![Page 9: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/9.jpg)
UNIX Basics
![Page 10: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/10.jpg)
![Page 11: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/11.jpg)
Linux vs *BSD
• 教派問題• 沒有誰比較好• 發展模式不同
o 中央集權o 各自為政
![Page 12: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/12.jpg)
BSD
• FreeBSD, OpenBSD, NetBSD, ....
• Developed by Berkeley(B -> Berkeley)
• Kernel + base + boot loader + ....
• Ports/Packages
![Page 13: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/13.jpg)
Linux
• Kernel
• Distributionso Debian/Ubuntuo Redhat/CentOS/Fedorao SUSEo Slackwareo Gentoo
• Mostly packages
![Page 14: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/14.jpg)
Root is God
• Root can do anythingo Almighty
• Root can do anythingo Protect it wello Be careful what you doo Always logouto Never login as root
![Page 15: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/15.jpg)
Everything is a file
• Typeso Regularo Directorieso Linkso Specials (devices)o Socketso Pipes
• Similar interface for everything
![Page 16: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/16.jpg)
Trees Everywhere
• Paths starts from / (root)
• Processes start from init (PID 1)
![Page 17: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/17.jpg)
File System Structure
• / Root
• /home User homes
• /dev Device files
• /bin Basic programs
• /lib* Basic libraries
• /sbin Basic system programs
• /usr Programs/libraries
• /var System data storage
• /proc Process states
• /sys System states
• http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
![Page 18: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/18.jpg)
File Permissions
• rwx Octal (八進位 )
• r - 4 - read
• w - 2 - write
• x - 1 - execute / search
rwx = 4+2+1 = 7r-x = 4+1 = 5
![Page 19: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/19.jpg)
File Permissions
rwxrwxrwx 1 wens wens 182 Jun 28 16:13 test.c
Others Group
User
![Page 20: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/20.jpg)
File Permissions
• Owner
• Group
• Others
Check the first matching type onlyCheck complete path
![Page 21: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/21.jpg)
Path vs Inode
• Pathpoint in FS to access file
• Inode actual file
• Multiple paths can point to same fileo Hard linko Share metadata
![Page 22: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/22.jpg)
Inode
• Metadata about a fileo Permissionso Dateso Sizeo ...
• Points to disk blocks with content
![Page 23: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/23.jpg)
Basic CommandsKnow them well
![Page 24: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/24.jpg)
Command Prompt
Normal user$ _
Fancywens@linux1:/home$ _
Root# _
Comment (in this document)##
![Page 25: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/25.jpg)
File/Directory ops
• cd• mkdir• rm• mv• ln• cp• chown• chgrp• chmod
![Page 26: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/26.jpg)
man
• Manual
• Manpages notated as cp(1)
• 1 is section
## Lookup “cp”$ man cp
## to be precise$ man 1 cp
## to search for “XXX”$ man -k XXX
![Page 27: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/27.jpg)
su
• Switch user
$ su root## Enter root password
$ su ta217## Enter ta217 password
![Page 28: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/28.jpg)
sudo
• Switch user and do something
• More controlled
• Enter your password
$ sudo lsEnter your passwordrun "ls" as root
![Page 29: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/29.jpg)
ps
• List processes
• man ps for all options
$ ps
$ ps aux
![Page 30: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/30.jpg)
find
• find something
$ find /home -name wens## search for file "wens" under /home
$ find /home -exec ls -l {} \;## search for files in /home and run ls -l {file} for each one
![Page 31: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/31.jpg)
xargs
• Run a command with a list as arguments
$ find | xargs ls –l# Similar to last find example
![Page 32: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/32.jpg)
grep
• Look for lines in files containing a pattern
• Regular expressions!
$ grep printf *.c## look for lines in all .c files with printf
![Page 33: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/33.jpg)
df
• Disk Free
• How much space is free?
$ df
$ df /home
![Page 34: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/34.jpg)
du
• Disk Usage
• How much space is something using?
$ du hello.c## How large is hello.c
$ du ~## How large are the files in my home?
$ du -s ~## How large (total) is my home?
![Page 35: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/35.jpg)
vi
• Vi/Vim
• Text editor
$ vim
$ vim hello.c
$ vimtutor## Tutorial!!
![Page 36: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/36.jpg)
Vim modes
• Command modecommands (duh)
• Insert modetype and see
• Visual modeselection
![Page 37: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/37.jpg)
![Page 38: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/38.jpg)
Vim key commands
• d - delete from here to...
• c - change from here to...
• x - delete 1 (delete key)
• X - delete 1 (backspace)
• y - copy from here to...
• p - paste here
• P - paste before here
• r - replace
• dd - delete line
• yy - copy line
• /XXX - search for XXX
![Page 39: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/39.jpg)
Vim commands
• :e xxx - open xxx
• :e! xxx - open xxx without saving
• :w - save
• :w xxx - save as xxx
• :q - quit
• :q! - quit without saving
Combine!
• :wq - save and quit
![Page 40: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/40.jpg)
回家練習Vimtutor工作站上熟悉指令
(chown, chgrp, su, sudo 除外 )
![Page 41: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/41.jpg)
作業
最後一堂課是經驗分享 /Q&A你想聽什麼 ?
![Page 42: Introduction. System Administrator? 系統管理員 不只是 IT 管理別人 / 大家使用的系統](https://reader037.vdocuments.pub/reader037/viewer/2022110320/56649cab5503460f9496ce3b/html5/thumbnails/42.jpg)
大家 12月見