1 / 20

Chapter 3 An Introduction to the Utilities

This chapter provides an introduction to various Unix utility programs such as finger, who, w, talk, write, mesg, mail, cp, mv, lpr, grep, head, tail, diff, sort, uniq, man, echo, date, whereis, which, tar, compress, uncompress, gzip, gunzip.

gomezb
Télécharger la présentation

Chapter 3 An Introduction to the Utilities

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 3An Introduction to the Utilities

  2. Introduction • Unix utilities : PART2. The Unix Utility Programs 참조 • 사용자 확인 및 상호 메시지 관련 • finger, who, w, talk, write, mesg • e-mail 관련 • mail, elm • 화일 관련 • cp, mv, lpr, grep, head, tail, diff, sort, uniq • 기타 • man, echo, date, whereis, which • 압축 관련 • tar, compress, uncompress, gzip, gunzip

  3. finger • finger : 사용자에 대한 정보를 출력 • example: [comp76]:/home/hotbody 4 >finger Login Name TTY Idle When Where hotbody (94419-4003) pts/11 Mon 12:23 horn.snu.ac.kr coolhero (96419-6087) pts/0 1:22 Mon 10:58 147.46.82.159 [comp76]:/home/hotbody 6 >finger hotbody Login name: hotbody In real life: (94419-4003) Directory: /home/hotbody Shell: /bin/csh On since Aug 17 12:23:33 on pts/11 from horn.snu.ac.kr No unread mail No Plan.

  4. who, w • who, w : 로그인 한 사용자의 리스트를 출력 • example: [comp76]:/home/hotbody 13 >who hotbody pts/11 Aug 17 12:23 (horn.snu.ac.kr) coolhero pts/0 Aug 17 10:58 (147.46.82.159) limcom pts/5 Aug 12 16:12 (beast) [comp76]:/home/hotbody 14 >w 12:42pm up 57 day(s), 1:41, 2 users, load average: 0.05, 0.02, 0.02 User tty login@ idle JCPU PCPU what hotbody pts/11 12:23pm 1 w coolhero pts/0 10:58am 1:41 1 -tcsh limcom pts/5 Wed 4pm 5days ftp 194.23.196.144 [comp76]:/home/hotbody 15 >who am i hotbody pts/11 Aug 17 12:23 (horn.snu.ac.kr)

  5. talk • talk : 로그인 한 다른 사용자와 온라인 대화 • example: dbms:~> talk user1@db [Waiting for your party to respond] [Connection established] Message from Talk_Daemon@dbmain.snu.ac.kr at 14:52 ... talk: connection requested by subby@dbms.snu.ac.kr. talk: respond with: talk subby@dbms.snu.ac.kr talk subby@dbms [Connection established]

  6. write, mesg • write : 로그인한 다른 사용자에게 메시지 전달 • example: • mesg : 다른 사용자로부터의 메시지(talk, write) 수신 가능여부를 지정 • 사용법 • 수신 허가 : mesg y • 수신 불허 : mesg n [comp76]:/home/user1 7 >write hotbody hello? <CTRL+D> [comp76]:/home/user1 8 > Message from hotbody on comp76 (pts/25) [ Wed Aug 19 15:04:15 ] ... hello? <EOT>

  7. mail (1) • mail : 전자 메일을 보내거나 받음 • example : [comp76]:/home/hotbody 13 >mail No mail for hotbody [comp76]:/home/hotbody 14 >mail subby@db.snu.ac.kr Subject: test mail hello? EOT dbmain:~> mail Mail version 8.1 6/6/93. Type ? for help. "/var/spool/mail/subby": 2 messages 1 new 2 unread >N 1 hotbody@comp76.snu.a Wed Aug 19 15:19 15/552 "test" &

  8. mail (2) • mail command ? help e <message list> (v) edit messages d <message list> delete messages s <message list> file append messages to file u <message list> undelete messages R <message list> reply to message senders r <message list> reply to message senders and all recipients m <user list> mail to specific users q quit, saving unresolved messages in mbox x quit, do not remove system mailbox h print out active message headers list ! shell escape cd [directory] chdir to directory or home if none given

  9. man • man : unix 시스템의 온라인 매뉴얼 • section : man -s <section> name ... • 1 : 사용자 명령어 • 2 : 시스템 콜 • 3 : C 라이브러리 함수 • 4 : 디바이스 파일, 네트워크 인터페이스 • 5 : 파일 포멧 • 6 : 게임과 데모 • 7 : misc (환경, 테이블, troff 메크로 등) • 8 : 시스템 유지 보수

  10. man (2) • 키워드 검색 : -k • example : [comp76]:/home/hotbody 44 >man -k sort aclsort aclsort (3) - sort an ACL alphasort scandir (3b) - scan a directory bsearch bsearch (3c) - binary search a sorted table disksort disksort (9f) - single direction elevator seek sort for buffers look look (1) - find words in the system dictionary or lines in a sorted list qsort qsort (3c) - quick sort sort sort (1) - sort, merge, or sequence check text files sortbib sortbib (1) - sort a bibliographic database tsort tsort (1) - topological sort [comp76]:/home/hotbody 45 >

  11. echo, date • echo :터미날에 문자열 출력 • example: • date :화면에 시간과 날짜를 출력 • example : [comp76]:/home/hotbody 45 >echo hello world hello world [comp76]:/home/hotbody 46 >date Wed Aug 19 16:44:39 KST 1998

  12. cp : 화일 복사(copy) mv : 화일 이동(move) or 화일 이름 변경 example : cp, mv [comp76]:/home/hotbody 56 >cp a.txt b.txt [comp76]:/home/hotbody 57 >mv a.txt util/ [comp76]:/home/hotbody 58 >mv b.txt c.txt

  13. lpr • lpr : 화일을 프린터로 출력 • 프린터에 따라 ps화일을 출력하여야 할 수 있음 • spooling pool에 들어가 프린트를 위해 큐에서 대기한다. • lpq : 스풀러에 있는 프린트 job 출력 • lprm : 스풀러에서 프린트 job 제거 • example : [comp76]:/home/hotbody 67 >a2ps test.txt > test.ps [test.txt: 1 page on 1 sheet] [Total: 1 page on 1 sheet] [comp76]:/home/hotbody 68 >lpr test.ps

  14. grep, head, tail • grep : 파일에서 특정 문자열 검색 • 정규식에 의한 검색(정규식은 PartII, 부록 A 참조) • example : [comp76]:/home/hotbody 69 >grep ello test.txt Hello? world.… • head : 화일의 처음 10줄을 출력 • tail : 화일의 마지막 10줄을 출력 • example: [comp76]:/home/hotbody 87 >head .cshrc stty erase …. set filec setenv CPU SUN4

  15. sort, uniq • sort : 화일을 순서에 따라 정렬 • uniq : 중복된 행 제거 • example : [comp76]:/home/hotbody 89 > cat test.txt ami 100 ami 100 cat 159 bat 300 [comp76]:/home/hotbody 90 >sort test.txt ami 100 ami 100 bat 300 cat 159 [comp76]:/home/hotbody 91 >uniq test.txt ami 100 cat 159 bat 300

  16. whereis, which • whereis : 유틸리티의 경로를 출력 • which : 실행할 수 있는 명령(유틸리티)의 경로 출력 • example: [comp76]:/home/hotbody 92 >whereis ls ls: /usr/bin/ls /usr/ucb/ls /usr/man/man1/ls.1 /usr/man/man1b/ls.1b [comp76]:/home/hotbody 93 >which ls /bin/ls

  17. diff • diff : 두 화일의 차이를 출력 a.txt: abcdefg abcdef123 abcde b.txt: abcdefg abcdef321 abcdef 111 [comp76]:/home/hotbody 98 >diff a.txt a.txt [comp76]:/home/hotbody 99 >diff a.txt b.txt 2,3c2,4 < abcdef123 < abcde --- > abcdef321 > abcdef > 111

  18. tar • tar : 여러 개의 파일을 하나의 화일로 합침 • example: [comp76]:/home/hotbody 113 >tar -cvf txttar *.txt a a.txt 1K a hw02.txt 1K a mail1.txt 3K a mail2.txt 2K a mail3.txt 5K a test.txt 1K [comp76]:/home/hotbody 121 >tar -xvf txttar x a.txt, 24 bytes, 1 tape blocks x hw02.txt, 903 bytes, 2 tape blocks x mail1.txt, 2946 bytes, 6 tape blocks x mail2.txt, 1579 bytes, 4 tape blocks x mail3.txt, 4267 bytes, 9 tape blocks x test.txt, 36 bytes, 1 tape blocks

  19. compress, uncompress • compress : 화일 압축 • uncompress : 압축된 화일 복구 • 참고 : gzip / gunzip [comp76]:/home/hotbody 115 >ls -alF txttar -rw-r--r-- 1 hotbody 94 17408 Aug 19 19:51 txttar [comp76]:/home/hotbody 117 >compress txttar [comp76]:/home/hotbody 119 >ls -alF txttar.Z -rw-r--r-- 1 hotbody 94 7212 Aug 19 19:51 txttar.Z [comp76]:/home/hotbody 120 >uncompress txttar.Z [comp76]:/home/hotbody 123 >gzip txttar [comp76]:/home/hotbody 127 >ls -alF txttar* -rw-r--r-- 1 hotbody 94 4919 Aug 19 19:51 txttar.gz [comp76]:/home/hotbody 125 >gunzip txttar

  20. Homework • 앞에서 설명한 유틸리티를 직접 수행해 보고 그 결과를 갈무리하여 제출하라. • 꼭 사용해야 할 유틸리티 : finger, who, cp, mv, grep, head, tail, diff, sort, uniq, echo, date, whereis, which, tar, compress 등... • 갈무리방법 : 자세한 사용법은 직접 조사 • 시작할 때 : script <filename> • 끝낼때 : exit • 결과는 Hardcopy로 제출하고, 프린트는 반드시 실습실의 프린터를 이용하여라. (lpr) • 제출기한 : 다음 수업시간까지

More Related