Operating System Shell disk network cpu printer O























![其它 • date: 顯示日期 • cal: 月曆, cal [[month] year], ex: 1997 • 列印: 其它 • date: 顯示日期 • cal: 月曆, cal [[month] year], ex: 1997 • 列印:](https://slidetodoc.com/presentation_image_h2/d62d349fd8a997f7d57dd81159744c57/image-24.jpg)

- Slides: 25


Operating System Shell disk network cpu printer. . O S system resources system call smtp init inetd . . process

encoded /etc/passwd user: passwd: uid: gcos: home: shell telnet or login username password login 檢查passowrd 執行 shell 更換 作目錄


線上求助 • man: 手冊 (manual) , ex: man wc • man -k keyword, 尋找與keyword相關的指 令 (系統需建索引檔: windex or whatis, 以 catman 建立) • 分冊: Vol 1: command, Vol 2: system call. . . cat(1): 表示 cat 在手冊的第一冊 • 新手可試 man • 環境變數: MANPATH, 內定 /usr/man

file system • 階層式的檔案架構, 樹狀結構 • 所有device 都是一個file (special file) / root usr var pathname: /etc/password home etc mount point bin ls ncnu mail passwd . .


目錄相關指令 $ ls Mail bin fonts image mail misc slides tmp News doc gwm kernel mbox nsmail src util $ pwd /home/staff/cc/klim $ cd News $ ls comp. lang. forth. 001 comp. lang. forth. 003 comp. lang. forth. 005 comp. lang. forth. 002 comp. lang. forth. 004 comp. lang. forth. 006 $ pwd /home/staff/cc/klim/News $ cd. . $ mkdir newdir $ ls newdir Mail News. . . . $ rmdir newdir $. . . .


檔案相關指令 $ cat mbox From teresa@tcmds. com. tw Mon Mar 16 09: 01 CST 1998 Received: from dns. tcmds. com. tw ([210. 66. 177. 61]) by^C $ more mbox From teresa@tcmds. com. tw Mon Mar 16 09: 01 CST 1998. /home/staff/cc/klim. --More--(15%) $ joe mbox $ cp mbox sun tmp. . . . mbox tmp $ rm sun tmp/sun $ mv mbox sun $ mv sun tmp sun. . . .

檔案屬性 d rwx rwx owner group other r: read w: write x: execute type d: directory -: file $ ls -al total 201 drwxr-xr-x -rw-r--r--rw------- 24 12 2 2 1 1 owner group size klim root klim sys other sys sys 1536 512 512 49259 4820 date Mar Mar Mar 17 10 6 5 14 16 16: 09 19: 49 08: 49 09: 14 20: 28 17: 35 . . . Mail News kernel mbox

檔案屬性 • chmod: 更改屬性, chmod mode file 1 file 2. . 421 421 chmod 444 mbox chmod a+r, u+wx, g+x, o-wx mbox – mode: octal number, augo[+-]rwx • chown: 更改owner, chown user file. . superuser 方能執行 • chgrp: 更改group, chgrp group file. .


檔案相關指令 $ head -3 posted From klim Fri Mar 6 08: 59: 26 1998 Subject: test , ignore it Newsgroups: tw. test $ tail -3 posted this is a test. just ignore it. $ grep From posted From klim Fri Mar 6 08: 59: 26 1998 $

檔案相關指令 從目前目錄開始尋找檔名為 duplex. ps , 並且列印出來 $ find. -name duplex. ps -print. /misc/duplex. ps $ du misc NFS 6 misc $ df Filesystem 1024 -blocks Used Available Capacity Mounted on /dev/dsk/c 0 t 0 d 0 s 0 96031 16540 69891 19% / /dev/dsk/c 0 t 0 d 0 s 6 674471 402207 204824 66% /usr /dev/dsk/c 0 t 0 d 0 s 3 240055 160943 55112 74% /var /dev/dsk/c 0 t 0 d 0 s 5 288855 145740 114235 56% /opt staff: /export/staff 2064704 810248 1244136 39% /home/staff $


輸出入轉向與pipe • • stdout cat f 1 f 2 > f 3 mail user@address < letter stdin ls | wc -w pipe /bin/time ls > /dev/null stderr – sh: /bin/time ls > /dev/null 2> time. out /bin/time ls > out 2>&1 – csh: /bin/time ls > ls. out /bin/time ls >& out

$ cat duplex. ps %%Begin. Feature << /Duplex true >> setpagedevice << /Tumble false >> setpagedevice %%End. Feature $ wc duplex. ps 4 12 99 duplex. ps $ ls course duplex. ps refcard. format $ ls | wc -w 5 $ $ /bin/time ls course real user sys $ /bin/time duplex. ps refcard. format 0. 0 stderr 0. 0 ls > /dev/null 2> out ls > out 2>&1 rivest warn stdout sh syntax



程序和子程序 Shell O S fork Shell execl (. . . program. . ) system call program


離線作業 • at: 定某個時間執行程式 • atq, atrm: 查詢及移除排定時間的程式 • crontab: 定時執行, /usr/spool/crontabs – crontab [filename], crontab [-elr] usrname 0, 30 * * /usr/news/bin/nntpsend 分 時 日 月 星期 命令 $ at midnight at> mail klim@ncnu. edu. tw < announce at> <EOT> job 890236800. a at Thu Mar 19 00: 00 1998 $ atq Rank Execution Date Owner Job 1 st Mar 19, 1998 00: 00 klim 890236800. a $ atrm 890236800. a: removed $ Queue a Job Name stdin
![其它 date 顯示日期 cal 月曆 cal month year ex 1997 列印 其它 • date: 顯示日期 • cal: 月曆, cal [[month] year], ex: 1997 • 列印:](https://slidetodoc.com/presentation_image_h2/d62d349fd8a997f7d57dd81159744c57/image-24.jpg)
其它 • date: 顯示日期 • cal: 月曆, cal [[month] year], ex: 1997 • 列印: – lpr [-Pprinter] f 1 f 2. . . , 列印檔案[至printer] – lpq [-Pprinter], 顯示[printer]的佇列 – lprm [-Pprinter] queue#, 刪除[printer]佇列中的 jobs • gcc, g++: C C++ compiler • telnet, finger. . • FAQ, 各大BBS中UNIX版的精華區
