390 likes | 511 Views
UNIX 終極指南. 第一章 開始上路. 認識您的鍵盤. System Administrator. 維護系正常運作 管理使用者帳號 維護檔案系統 定期備份系統 管理硬碟空間 執行重要程式 系統管理者帳 root 擁有絶對權力. How to Login. Digital UNIX (mis4k.mis.yuntech.edu.tw) (ttyp2) login: gmi901 Password:Last login: Wed Aug 30 00:14:19 from localhost
E N D
UNIX 終極指南 第一章 開始上路
System Administrator • 維護系正常運作 • 管理使用者帳號 • 維護檔案系統 • 定期備份系統 • 管理硬碟空間 • 執行重要程式 • 系統管理者帳root • 擁有絶對權力
How to Login Digital UNIX (mis4k.mis.yuntech.edu.tw) (ttyp2) login: gmi901 Password:Last login: Wed Aug 30 00:14:19 from localhost Digital UNIX V4.0D (Rev. 878); Tue Mar 2 11:35:26 CST 1999 ====================================== 國立雲林科技大學資訊管理技術系 MIS4K DEC工作站 ====================================== mis4k:/mis/GMI/90/gmi901>
Logging out • [ctrl-d] • logout • exit
mis4k:/mis/GMI/gmi801> passwd Changing password for gmi801. Old password: New password: Retype new password: mis4k:/mis/GMI/gmi801> 應該有6~8個字元長 不應是 單字 電話 生日 名字 最好混合大小寫字母和標點符號及數字 Change Your Password
Who- 列出正在使用系統的所有使用者 • sun4330% who umi3432 ttyp0 Nov 7 19:30 (140.125.250.60) umi4202 ttyp1 Nov 7 17:35 (140.125.200.208) umi4256 ttyp2 Nov 7 17:26 (140.125.202.8) umi3437 ttyp3 Nov 7 18:32 (140.125.201.131) umi4211 ttyp4 Nov 7 16:15 (140.125.201.242) umi4244 ttyp5 Nov 7 19:07 (140.125.201.186) gmi413 ttyp6 Nov 7 17:30 (140.125.202.69) umi4226 ttyp7 Nov 7 19:19 (140.125.201.188) tungsh ttyp8 Nov 7 18:12 (huan.mis.yuntech)
w - who is logged inand what are they doing sun4330% w 7:34pm up 1 day, 2:47, 18 users, load average: 1.71, 1.59, 1.50 User tty login@ idle JCPU PCPU what umi3432 ttyp0 7:30pm rlogin sungx3 umi4202 ttyp1 5:35pm 1:57 1 1 cpine umi4256 ttyp2 5:26pm 16 30 1 -csh umi3437 ttyp3 6:32pm 44 rlogin sungx3 umi4211 ttyp4 4:15pm 2:45 3 scheme umi4244 ttyp5 7:07pm 7 - csh
whoami sun4330% whoami melanie
who am i sun4330% who am i sun4330!melanie ttypf Nov 7 19:30 (140.125.83.140)
who are you sun4330% who are you sun4330!melanie ttypf Nov 7 19:30 (140.125.83.140)
stty and tty • tty • to display full pathname of terminal device • To test whether or not the standard input is a terminal device • UNIX系統視所有的設備為檔案 • sun4330% tty /dev/ttyp5
stty設定終端機選項 • 設定目前裝置的終端輸出入選項 • 設定消去(erase)清除(kill)字元 stty erase \^h kill \^u • 恢復畫面正常 stty sane
Shell • echo $SHELL • 預設使用shell環境為tcsh • MIS4K 所提供之shell程式為 • /bin/sh • /bin/csh • /bin/ksh • /bin/tcsh • chsh指令可更改所使用之shell
瞭解您用的環境 • 瞭解您用的shell • echo $SHELL • 瞭解您用的終端機型態 • echo $TERM • 瞭解您用環境 • set
注意事項 • unix指令是小寫 • 每個令結束按[enter]鍵
建立目錄 mkdir 列出檔案和目錄 ls 在目錄結構中行進 pwd cd
列出檔案 • ls -a列出所有檔案,包含隱藏檔(以.開頭) • ls -l 列出長檔格式檔案資訊 • ls -F • 在檔名上打上記號, 目錄 / 執行檔 * 符號連結@ • ls -ld 只列出目錄名稱
cat • 顯示檔案內容 • cat filename • 連接數個檔案 • cat chat1 chat2 > book • cat chat[12345] > book • cat chat 3 chapt1 > newchapters • cat chat[31] > newchapters
cat • 創造空檔案 cat /dev/null > empty • 編輯檔案 • 以(ctrl -d )結束 • cat > msforbob Victor from IBM called. New machine will arrive on Tuesday. ^d
echo • 重覆參數 • 察看shell的參數設定echo $PATH • 檔案名稱 * ?[ • 忽略參數間多餘的空白
echo • sun4330% echo A B C A B C • sun4330% echo 'A B C' A B C • sun4330% /usr/5bin/echo 'A\nB\n\tC' A B C (DEC: /usr/bin/echo ‘A\nB\n\tC’)
wc-word count • 計算行數 • wc -l hammy • 計算字數 • wc -w hammy • 計算字元數 • wc -c hammy
UNIX的版本 • UNIX有許多不同的版本目前劃分為兩個主要的分支 • SYSTEM V • AT&T開始逐漸演變的各種系統 • System V Release 4, SVR4 • Berkeley Software Distribution (BSD) • 柏克萊大學開始逐漸演變的各種系統 • UNIX4.4BSD
Versions of UNIX • 免費取得的版本 • Linux • FreeBSD
UNIX的內部架構 • 兩大主軸 • 核心Kernel • 與機器硬體做溝通 • Shell • 與使用者做溝通
Kernel • 核心程式 • The kernel is the master control program of the computer • 整個作業系統的核心 • 一開機時就load到記憶體 • 程序管理:啟動程序,排程序程管,分配資源 • 裝置管理:監督主要記憶體及周邊裝之間的資 料傳輸作業 • 檔案管理 • Handles multitasking • 檔名通常為unix或 vmlinuz
SHELL • 命令與KERNEL之間橋樑 • 接受使用者輸入的命令解譯成特殊字元 • 命令翻譯器(COMMANDS INTERPRETER) • 分為Bourne-Shell(sh)、C-Shell(csh)、korn-Shell(ksh)
COMMANDS SHELL KERNEL
Shell Interaction with the user and the OS Shell User types command The OS executes
UNIX的內部架構 • UNIX支援多人使用 • 多人操作系統 • 單人可執行多重工作 • 在multitasking下,只有一個工作在前景,其餘均在背景執行 • Do one thing well • 程序間相互溝通,shell可將一個程式傳送資訊給另一個程式 • 平凡的檔案系統 • 所有的目錄、設備等都含括在檔案定義中
UNIX的內部架構 • Pattern Matching • 樣式比對可節省打字負擔-萬用字元* • 正規表示式可做十分複雜的樣式比對樣式 • 程式設計的機制 • shell也是一種程式語言,具有控制結構、迴圈以及變數的程式語言元素 • 用來設計shell scripts • 可攜性與系統呼叫 • 內建於kernel • 所有的Unix支版本都用同樣的系統呼叫 • 文件系統 • man
finger • sun4330% finger Login Name TTY Idle When Where umi3432 8323032 p0 Thu 19:30 140.125.250.60 umi4202 8423302 p1 1:58 Thu 17:35 140.125.200.208 umi4256 ??? p2 17 Thu 17:26 140.125.202.8 umi3437 8323037 p3 45 Thu 18:32 140.125.201.131 umi4211 8423311 p4 2:46 Thu 16:15 140.125.201.242 umi4244 8423344 p5 Thu 19:07 140.125.201.186
finger • finger username • % finger melanie • % finger –b melanie Login name: melanie In real life: Chi-Meei Yang Directory: /sun4330/melanie Shell: /bin/csh On since Nov 7 19:30:47 on ttypf from 140.125.83.140 Project: NYIT MIS department Plan:Study sendmail 8.8
finger sun4330% finger -h melanie ( 不輸出.project檔案) Login name: melanie In real life: Chi-Meei Yang Directory: /sun4330/melanie Shell: /bin/csh On since Nov 7 19:30:47 on ttypf from 140.125.83.140 16 seconds Idle Time No unread mail Plan: Study sendmail 8.8
finger指令參考下檔案 • /etc/utmp who is logged in • /etc/passwd for users' names • /var/adm/lastlog last login times • /etc/ttytab terminal locations 在個人home directory下建立 .plan 可容納多行資料 .project 只可以一行資料