......

Similar documents
chap2

제2장 유닉스 사용

6주차.key

<C0CCBCBCBFB52DC1A4B4EBBFF82DBCAEBBE7B3EDB9AE2D D382E687770>

Microsoft PowerPoint - comp_prac_081223_2.pptx

휠세미나3 ver0.4

Sena Technologies, Inc. HelloDevice Super 1.1.0

본문서는 초급자들을 대상으로 최대한 쉽게 작성하였습니다. 본문서에서는 설치방법만 기술했으며 자세한 설정방법은 검색을 통하시기 바랍니다. 1. 설치개요 워드프레스는 블로그 형태의 홈페이지를 빠르게 만들수 있게 해 주는 프로그램입니다. 다양한 기능을 하는 플러그인과 디자인

PowerPoint 프레젠테이션

MySQL-Ch10

제2장 리눅스 사용

PowerPoint 프레젠테이션

28 THE ASIAN JOURNAL OF TEX [2] ko.tex [5]

chapter4

10X56_NWG_KOR.indd

Copyright 2004 Sun Microsystems, Inc Network Circle, Santa Clara, CA U.S.A..,,. Sun. Sun. Berkeley BSD. UNIX X/Open Company, Ltd.. Sun, Su

강의10

Assign an IP Address and Access the Video Stream - Installation Guide

Remote UI Guide

LXR 설치 및 사용법.doc

PCServerMgmt7

PowerPoint 프레젠테이션

초보자를 위한 C++

Copyright 2012, Oracle and/or its affiliates. All rights reserved.,.,,,,,,,,,,,,.,...,. U.S. GOVERNMENT END USERS. Oracle programs, including any oper

Network seminar.key

Solaris Express Developer Edition

<4D F736F F F696E74202D E20C0CEC5CDB3DD20C0C0BFEB20B9D720BCADBAF1BDBA20B1E2BCFA E >

01Àå

Backup Exec

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

USB USB DV25 DV25 REC SRN-475S REC SRN-475S LAN POWER LAN POWER Quick Network Setup Guide xdsl/cable Modem PC DVR 1~3 1.. DVR DVR IP xdsl Cable xdsl C

소개 TeraStation 을 구입해 주셔서 감사합니다! 이 사용 설명서는 TeraStation 구성 정보를 제공합니다. 제품은 계속 업데이트되므로, 이 설명서의 이미지 및 텍스트는 사용자가 보유 중인 TeraStation 에 표시 된 이미지 및 텍스트와 약간 다를 수

Copyright 2012, Oracle and/or its affiliates. All rights reserved.,,,,,,,,,,,,,.,..., U.S. GOVERNMENT END USERS. Oracle programs, including any operat

APOGEE Insight_KR_Base_3P11

Microsoft PowerPoint - ch02_인터넷 이해와 활용.ppt

슬라이드 1

1217 WebTrafMon II

PWR PWR HDD HDD USB USB Quick Network Setup Guide xdsl/cable Modem PC DVR 1~3 1.. DVR DVR IP xdsl Cable xdsl Cable PC PC DDNS (

PowerPoint 프레젠테이션

What is Unix? A multi-task and multi-user Operating System Developed in 1969 at AT&T s Bell Labs by Ken Thompson (Unix) Dennis Ritchie (C) Douglas Mcl

untitled

/chroot/lib/ /chroot/etc/

6강.hwp

목 차 Ⅰ. 일반사항 1 Ⅱ. 특기사항 3 Ⅲ. 물품내역 및 세부규격 8 Ⅳ. 주의사항

Mango220 Android How to compile and Transfer image to Target

PowerPoint 프레젠테이션

SRC PLUS 제어기 MANUAL

ORANGE FOR ORACLE V4.0 INSTALLATION GUIDE (Online Upgrade) ORANGE CONFIGURATION ADMIN O

Sun Java System Messaging Server 63 64

SMB_ICMP_UDP(huichang).PDF

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

歯J PDF

VZ94-한글매뉴얼

manual pdfÃÖÁ¾

untitled


1. exit logout 하는 command 는아주간단하다. exit 을커맨드에서입력하고 return 키를누르면 logout 된다. 2. ls & command option 현재 directory 에서 file 의 list 를보는명령어, 즉 DOS 에서의 dir 에해

<32B1B3BDC32E687770>

User Guide

품질검증분야 Stack 통합 Test 결과보고서 [ The Bug Genie ]

chap7.key

GNU/Linux 1, GNU/Linux MS-DOS LOADLIN DOS-MBR LILO DOS-MBR LILO... 6

본교재는수업용으로제작된게시물입니다. 영리목적으로사용할경우저작권법제 30 조항에의거법적처벌을받을수있습니다. [ 실습 ] 스위치장비초기화 1. NVRAM 에저장되어있는 'startup-config' 파일이있다면, 삭제를실시한다. SWx>enable SWx#erase sta

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

Microsoft PowerPoint 통신 및 압축 명령어.ppt

Microsoft PowerPoint - chap9 [호환 모드]

cam_IG.book

vm-웨어-01장

hd1300_k_v1r2_Final_.PDF

DocsPin_Korean.pages

Microsoft PowerPoint - u5.pptx

2-11Àå

침입방지솔루션도입검토보고서

K7VT2_QIG_v3

<4D F736F F F696E74202D20BFEEBFB5C3BCC1A6BDC7BDC D31C7D0B1E229202D20BDA92E BC8A3C8AF20B8F0B5E55D>

PRO1_02E [읽기 전용]

10.

untitled

Sena Device Server Serial/IP TM Version

슬라이드 제목 없음

PowerPoint 프레젠테이션

HTML5가 웹 환경에 미치는 영향 고 있어 웹 플랫폼 환경과는 차이가 있다. HTML5는 기존 HTML 기반 웹 브라우저와의 호환성을 유지하면서도, 구조적인 마크업(mark-up) 및 편리한 웹 폼(web form) 기능을 제공하고, 리치웹 애플리케이 션(RIA)을

Microsoft PowerPoint - 02-Shell-Programming

제1장 Unix란 무엇인가?

PRO1_09E [읽기 전용]

목차 BUG offline replicator 에서유효하지않은로그를읽을경우비정상종료할수있다... 3 BUG 각 partition 이서로다른 tablespace 를가지고, column type 이 CLOB 이며, 해당 table 을 truncate

제20회_해킹방지워크샵_(이재석)

°í¼®ÁÖ Ãâ·Â

다. 최신 버전의 rpm 패키지 버전을 다운로드해 다음과 같이 설 치한다. 단 debuginfo의 rpm 패키지는 설치할 필요가 없다. 하기 위한 옵션이고, init는 저장소를 초기화하기 위한 cvs 명령 어이다. - 새로 설치한 경우 : rpm -ivh cvs* -

Voice Portal using Oracle 9i AS Wireless

Windows 네트워크 사용 설명서

untitled

PowerPoint 프레젠테이션

untitled

인켈(국문)pdf.pdf

ARMBOOT 1

1. efolder 시스템구성 A. DB B. apache - mod-perl - PHP C. SphinxSearch ( 검색서비스 ) D. File Storage 2. efolder 설치순서 A. DB (MySQL) B. efolder Service - efolder

Transcription:

01 02

03 04 05

06 07

08 09

10 11 12

13 14

Unix / Linux 01

Unix / Linux 01 (Unix) 1970 AT&T (Ken Thompson) (Dennis Ritchie) PC 1990 (Linus Torbalds)PC (Linux) (Apple) (Mac) OS X PC OS X ios (Android) PC MIT (Multics) (simplicity) (portability) C

01 C C 1.1

1. (Android) OS 2. ios 3. (Mac) OS X 4. (Linux) 5. BSD (Unix) 6. V 7. Sun (Solaris) 8. IBM AIX 9. HP HP-UX 10. Cray (Unicos) 1.2 (super-user)

01 ftptelnetwww

CPU (Memory) (Disk) (Peripherals) 1.3 (kernel) 1.4

01 (Process management) CPU (File management) (Memory management) (Communication management) (Device management) (system call) (shell)

GNU GNU 1970 AT&T 1969 (Ken Thompson) 1972 (Dennis Ritchie) C C C V(System V) BSD 1.5 AT&T (System V) V V IBM AIXSun SolarisHP UP-UX

01 AT&T (Univ. of California, Berkeley) (Berkeley Software Distribution) BSD TCP/IP (Socket) BSD BSD 4.3 BSD OS(Sun OS) OS(Mac OS)

(Solaris) (Sun) (Sparc) CPU 1.6 (Linux) PC 1991 (Linus Torvalds) PC GNU (RedHat) (Ubuntu) (Debian) (Fedora)CentOS 1.4

01 (Mac OS) 1984 GUI 2002 NeXTSTEP BSD OS X 1.7OS X (Android) PC 1.8

ios OS X API iphoneipadipod 1.9 ios CentOS CentOS (Ubuntu)

01 PC CD/DVD USB MS http://www.ubuntu.com (Unity) 1.10

(Debian) (Debian Project) apt (Debian) (Ian Murdock) (Debra) USB CD/DVD http://www.debian.org/index.ko.html (Fedora) RPM USB CD/DVD http://fedoraproject.org/ko/

01 (Community ENTerprise Operating System) CentOS CentOS CD/DVD CentOS http://www.centos.org http://ftp.daum.net/centos/6/isos/i386/ CD/DVD CentOS-6.x-i386-bin-DVD.iso CentOS-6.x-i386-minimal.iso CentOS-6.x-i386-netinstall.iso gcc (S/W Development Workstation) http://linuxmoz.com/how-to-install-centos-6-linux-for-servers-desktops/ CentOS GNOME 1.11

1.6 X-(X window) X- 1.11 X- CentOS X-

01 1.12 CentOS 1.10 X- 1.13 MS PC

telnet cs 1.14 C:\> telnet cs.sookmyung.ac.kr PuTTY PuTTY http://www.chiark.greenend.org.uk/ ~sgtatham/putty ssh 1.15 ssh (cs2.sookmyung.ac.kr) 1.16

01 X GNOME PuTTY exit logout $ exit $ logout

2 (superuser) root root root root root su root root $ su useradd root 1.1 # useradd

01 -c -d /home/ -e -s -u uid ID -g ID agape # useradd agape cs12 agape # useradd -g cs12 agape passwd agape # passwd agape agape : : passwd:

/etc/passwd agape:x:501:502::/home/agape:/bin/bash /etc/shadow agape:$6$2m53.be.$pgob0x.g8bfhxfn2b5h58.kmcudxvimblh8euqvcb9qap.v0thbx J8WJsocYIesxLV9Sb3sWQIBnlWoZWS.Yw1:15432:0:99999:7::: /home/ # ls -asl /home/agape 32 4 drwx------. 4 agape cs12 4096 2012-04-02 13:19. 4 drwxr-xr-x. 5 root root 4096 2012-04-02 13:19.. 4 -rw-r--r--. 1 agape cs12 18 2011-05-31 01:58.bash_logout 4 -rw-r--r--. 1 agape cs12 176 2011-05-31 01:58.bash_profile 4 -rw-r--r--. 1 agape cs12 124 2011-05-31 01:58.bashrc 4 -rw-r--r--. 1 agape cs12 500 2007-01-24 06:40.emacs 4 drwxr-xr-x. 2 agape cs12 4096 2010-11-12 09:54.gnome2 4 drwxr-xr-x. 4 agape cs12 4096 2011-10-28 22:18.mozilla userdel -r # userdel [-r] GNOME 1.17 1.18

01 groupadd -g ID # groupadd [-g gid] cs12 # groupadd cs12 /etc/group groupdel # groupdel

PC PuTTy PC

Unix / Linux 02

Unix / Linux 02 date $ date 2012 12 24 01 52 02 hostname uname $ hostname cs $ uname SunOS who $ who brain pts/5 12 24 13:46 (203.252.201.55)

02 chang pts/6 12 24 12:40 (203.153.155.35)... ls $ ls Desktop invite.csh README clear $ clear passwd $ passwd passwd: chang : : : passwd: (chang ). man date man $ man date User Commands NAME date - write the date and time... date(1)

DESCRIPTION The date utility writes the date and time to standard output... (ordinary file) (directory) (folder) (device) (special file) ( stdin)( stdout) (root) 2.1

02 /bin /sbin /etc /kernel /dev /home /export /lib /var /tmp /usr NFS /usr/bin /usr/include /usr/lib /usr/local "include"

/usr/man 2.2 (home directory) $HOME (current working directory)

02 pwd pwd $ pwd /home/chang mkdir $ mkdir test $ mkdir test cd [ ] $ cd test $ cd test $ pwd /home/chang/test ls cs1.txt

$ ls cs1.txt ls -s(size) $ ls -s 6 6 cs1.txt ls. -a(all)... $ ls -a... cs1.txt -l(long) rw-r--r-- 2088 4 16 13:37 $ ls -l 6 -rw-r--r-- 1 chang faculty 2088 4 16 13:37 cs1.txt

02 $ ls -asl 10 2 drwxr-xr-x 2 chang faculty 512 4 16 13:37. 2 drwxr-xr-x 3 chang faculty 512 4 16 13:37.. 6 -rw-r--r-- 1 chang faculty 2088 4 16 13:37 cs1.txt ls * 0 $ ls ls /tmp $ ls /tmp cs1.txt $ ls cs1.txt (pathname) (absolute pathname) 2.3 test cs1.txt /home/chang/test/cs1.txt

(relative path name) test cs1.txt ~ :. :.. : cd.. cd ~ 2.1

02 ls ls -a ls -asl mkdir cd cd cd ~ cd.. pwd (cat, more, head, tail, wc ) $ (more ) 0 * $ more + $ more +

(vi, gedit ) cat (2.5 ) cs1.txt cs1.txt ^D(Ctrl-D) $ cat > cs1.txt... ^D cs1.txt cat cs1.txt (1 ) $ cat cs1.txt cat $ cat... ^D more

02 $ more + [space-bar] q $ more cs1.txt Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna. The Unix operating system was first developed in assembly language, but by 1973 had been almost entirely recoded in C, greatly facilitating its further development and porting to other hardware. Today's Unix system evolution is split into various branches, developed over time by AT&T as well as various commercial vendors, universities (such as University of California, Berkeley's BSD), and non-profit organizations. The Open Group, an industry standards consortium, owns the UNIX trademark. Only systems fully compliant with and certified according to the Single UNIX Specification are qualified to use the trademark; others might be called Unix system-like or Unix-like, although the Open Group disapproves[1] of this term. However, the term Unix is often used informally to denote any operating system that closely resembles the trademarked system. During the late 1970s and early 1980s, the influence of Unix in academic circles led to large-scale adoption of Unix(particularly of the BSD variant, ----(59%) head (10 ) $ head cs1.txt

Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna. The Unix operating system was first developed in assembly language, but by 1973 had been almost entirely recoded in C, greatly facilitating its further development and porting to other hardware. Today's Unix system evolution is split into various branches, developed over time by AT&T as well as various commercial vendors, (5) $ head -5 cs1.txt Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna. tail (10 ) $ tail cs1.txt Linux, which is used to power data centers, desktops, mobile phones, and embedded devices such as routers, set-top boxes or e-book readers. Today, in addition to certified Unix systems such as those already mentioned, Unix-like operating systems such as MINIX, Linux, Android, and BSD descendants (FreeBSD, NetBSD, OpenBSD, and DragonFly BSD) are commonly encountered. The term traditional Unix may be used to describe a Unix or an operating system that has the characteristics of either Version 7 Unix or UNIX System V. (5)

02 $ tail -5 cs1.txt wc cs1.txt 38 3182088 $ wc cs1.txt 38 318 2088 cs1.txt (-l) (-w) (-c) $ wc -l cs1.txt 38 cs1.txt cp $ cp 1 2 cs1.txt cs2.txt cs1.txt cs2.txt $ cp cs1.txt cs2.txt ls -l cs1.txt cs2.txt

$ ls -l cs1.txt cs2.txt -rw-r--r-- 1 chang faculty 2088 4 16 13:37 cs1.txt -rw-r--r-- 1 chang faculty 2088 4 16 13:45 cs2.txt $ cp cs1.txt /tmp $ cp cs1.txt /tmp ls -l cs1.txt /tmp/cs1.txt $ ls -l /tmp/cs1.txt -rw-r--r-- 1 chang faculty 2088 4 16 14:31 /tmp/cs1.txt mv $ mv 1 2 cs2.txt cs3.txt cs2.txt $ mv cs2.txt cs3.txt ls cs2.txt cs3.txt

02 $ ls -l -rw-r--r-- 1 chang faculty 2088 4 16 13:37 cs1.txt -rw-r--r-- 1 chang faculty 2088 4 16 13:56 cs3.txt $ mv cs3.txt /tmp $ mv cs3.txt /tmp ls -l cs3.txt /tmp/cs3.txt $ ls -l /tmp/cs3.txt -rw-r--r-- 1 chang faculty 2088 4 16 13:56 /tmp/cs3.txt rm $ rm + cs1.txt $ rm cs1.txt rmdir $ rmdir +

test $ rmdir test rm -r $ rm -r 2.2 cat * more + head * tail * wc * cp 1 2 mv 1 2 rm + rmdir + grep 1 2 1 2

02 (file attribute) cs1.txt $ ls -sl cs1.txt 6 -rw-r--r-- 1 chang faculty 2088 4 16 13:37 cs1.txt - d rw-r--r-- 2088 2 20 13:37 2.3 (-) (d) (l) (p) (s) (b c)

ID( ) root (permission mode) (r) (w) (x) 2.4 r w w (owner) (group) (others) rw-r--r-- rw- r-- r--

02 X GNOME 2.4 2.5 chmod -R $ chmod $ chmod [-R] 8 8 1 1 0 8 8 644

rw- r-- r-- 2 110 100 100 8 6 4 4 cs1.txt 664 rw- rw- r-- 2 110 110 100 8 6 6 4 cs1.txt $ chmod 664 cs1.txt $ ls -l cs1.txt -rw-rw-r-- 1 chang faculty 2088 2 20 13:37 cs1.txt [u g o a] + [+ - =][r w x] + u(user), g(group), o(other), a(all) : +(), -(), =() : r(), w(), x() cs1.txt 644 664 cs1.txt w $ chmod g+w cs1.txt

02 chown chown -R $ chown $ chown [-R] chgrp -R $ chgrp $ chgrp [-R] (output redirection) 2.6 > $ >

who names.txt $ who > names.txt cat cat list1.txt list2.txt $ cat > list1.txt Hi! This is the first list. ^D $ cat > list2.txt Hello! This is the second list. ^D

02 $ cat list1.txt list2.txt > list3.txt list3.txt $ cat list3.txt Hi! This is the first list. Hello! This is the second list. (append) >> $ >> list1.txt $ cat >> list1.txt Bye! This is the end of the first list. ^D list1.txt $ cat list1.txt Hi! This is the first list. Bye! This is the end of the first list.

(input redirection) 2.7 < $ < wc list1.txt $ wc < list1.txt 4 17 71 list1.txt wc list1.txt $ wc... ^D

02 (here document) << << $ <<... end wc $ wc << end hello! word count end 2 4 20 $ who > names.txt $ sort < names.txt (pipe) 2.8

$ 1 2 $ who sort brain pts/5 2 20 13:23 (203.252.201.55) chang pts/3 2 20 13:28 (221.139.179.42) kimch pts/4 2 20 13:35 (203.252.201.51) wc $ who wc -l 3 2.5

02 > >> < 1 2 cat 1 2 > 3 1 2 1 2 3 Ctrl-C $ ^C Ctrl-Z $ ^Z () fg

$ fg 2.9 & $ & 100 done test.c $ (sleep 100; echo done) & [1] 8320 $ find. -name test.c -print & [2] 8325

02 jobs $ jobs [1] + Running ( sleep 100; echo done ) [2] - Running find. -name test.c -print fg $ fg % 1 $ fg %1 ( sleep 100; echo done ) $ find. -name test.c -print > find.txt & $ find. -name test.c -print mail chang & $ wc < inputfile & (process)

PID ps $ ps PID TTY TIME CMD 8695 pts/3 00:00:00 csh 8720 pts/3 00:00:00 ps ps u $ ps u USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND chang 8695 0.0 0.0 5252 1728 pts/3 Ss 11:12 0:00 -csh chang 8793 0.0 0.0 4252 940 pts/3 R+ 11:15 0:00 ps u ps aux $ ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 2064 652? Ss 2011 0:27 init [5] root 2 0.0 0.0 0 0? S< 2011 0:01 [migration/0] root 3 0.0 0.0 0 0? SN 2011 0:00 [ksoftirqd/0] root 4 0.0 0.0 0 0? S< 2011 0:00 [watchdog/0]... root 8692 0.0 0.1 9980 2772? Ss 11:12 0:00 sshd: chang [pr chang 8694 0.0 0.0 9980 1564? R 11:12 0:00 sshd: chang@pts chang 8695 0.0 0.0 5252 1728 pts/3 Ss 11:12 0:00 -csh chang 8976 0.0 0.0 4252 940 pts/3 R+ 11:24 0:00 ps aux

02 kill $ kill $ kill % 1 ( 8320) $ kill 8320 $ kill %1 [1] Terminated ( sleep 100; echo done ) 2.6 & ^C ^Z bg jobs fg %1 kill %1 ps kill 8320 1 1 8320

vi vi 5.5 X GUI gedit kwrite gedit X GNOME gedit GNOME [gedit ] $ gedit [ ] & gedit MS 2.10

02 kwrite KDE gedit 2.11

02 (1) (2) Lab02 (3) Lab02 (4) Lab02 (5) Lab02 (6) $ ls $ ls -a $ ls -l $ ls -al $ ls -d $ ls -F $ ls -u $ ls /tmp $ ls /etc

$ ls /etc/passwd $ ls -asl /etc/passwd $ mkdir unix $ cd unix $ cp /etc/motd test.txt $ ls $ cp /etc/motd. $ mkdir Temp $ cp test.txt Temp $ cp Temp Tmp // $ ls $ cp -r Temp Tmp $ ls Temp $ ls Tmp $ cd unix $ ls -l $ chmod 644 test.txt $ ls -l $ chmod 666 test.txt $ ls -l $ chmod 400 test.txt $ ls -l $ cd Tmp $ ls $ rm -i test.txt $ cd.. $ ls Tmp

02 $ rmdir Tmp $ rm -r Temp $ ls gedit kwrite (intro) $ cat intro $ cat -n intro $ more intro $ tail intro $ tail -5 intro $ tail +5 intro $ tail -f intro cp 8 (1) rwxr-xr-x (2) rw-r--r-- (3) rw-rw---- (4) r-xr--r--

Unix / Linux 03

Unix / Linux 03 X X (GUI) 1984 MIT 1987 X11 1988 X X X11 1996 X11R6 X 2004 X.org (http://www.x.org) 2006 X11R7 3 X 1. 2.

03 3. 4. 5. X X X X xdmgdmkdm X (X display manager) X 3.1 (CentOS) X 3.2

X $ % X $ startx $ xinit X X (window manager) MS OS X X 3

03 X X X TWMMWMFVWM (Window Maker) (After Step) (Enlightenment) TWM(Timeless Window Manager) X X FVWM(F Virtual Window Manager) TWM (Window Maker) GUI

(After Step) FVWM GUI (Enlightenment) GNOMEKDE (Desktop Environment) MS GNOME KDE(K Desktop Environment) CDE(Common Desktop Environment)Xfce CDE GNOME KDE GNOME KDE X X GNOME KDE

03 GNOME(GNU Network Object Model Environment) X GNOME BSD GNOME GNOME GNOME http://www.gnome.org GNOME 2 3.3 GNOME

3.4 3.5

03 3.6 GNOME DVD-ROM 3.8 DVD-ROM DVD-ROM 1. 2. 3. (arag and drop) 3.7 [Open in Terminal]

(file manager) 3.8 (Nautilus)

03 GNOME (Firfox) 3.9 3.9 1. 2. 3. 1. 2. 3.

KDE(K Desktop Environment) X KDE KDE http://www.kde.org KDE HP-UXBSD KDE 3.10 KDE 4

03 3.11 3.11 3.12 3.13 3.14

KDE 1. 2. 3. 3.15 URL Dophin Dolphin

03 3.16 KDE (file manager) (Dolphin) MS 3.17

KDE NTA(Network Transparent Access) Network URL ftp URL 1. 2. 3.

03 1. 2. 3. 3.18 KDE 3.19

X GUI X GUI X (X protocol) X X X X X X X X 3.20 X X X X X X X xterm xclock firefox X X X X X

03 X X X 3.20 X X X X X X GNOME KDE X X xterm xterm GNOME Terminal konsole xclock X xclock $ xclock & [1] 12345 X X X X X X DB

3.21 xclock X X X X X $ x -display :0 & cs2.sookmyung.ac.kr konsole 3.22 linux.sookmyung. ac.kr $ konsole -display linux.sookmyung.ac.kr:0 & # cs2

03 X X X SSH X X X X xhost $ xhost +[] linux.sookmyung.ac.kr cs2 $ xhost +cs2.sookmyung.ac.kr

+ - $ xhost - MS X MS X X X X X X X X X X MS PC PCX MS X XmanagerXming MS Xmanager Xming http://www.netsarang.co.kr http://sourceforge.net/projects/xming Xmanager XDMCP(X Display Manager Control Protocol) http://www.netsarang.co.kr/faq/xmanager/list/21 X Xmanager 3.23 Xbrowser Xbrowser 3.24

03 Xbrowser (Address Bar) IP Xbrowser IP 3.25 (CentOS) 3.26

03 X (1) X X 5 (2) X (3) xhost GNOME KDE KDE GNOME X X (window manager) (file manager) MS X

Unix / Linux 04

Unix / Linux 04 (Local Area Network) LAN 4.1 (Ethernet) PARC LAN 48 MAC LAN LAN

04 (router) 4.2 (Gateway) 4.3 LAN (protocol)

(wireless access point, WAP) (Internet) TCP/IP (protocol) TCP/IP IP(Internet Protocol) IP IP IP IP TCP(Transport Control Protocol) IP HTTPFTPSMTP IP TCP TCP/IP

04 (hostname) IP (domain name) IP 4.1 cs.sookmyung.ac.kr 203.252.201.11 www.sookmyung.ac.kr 203.252.201.8 www.kbs.co.kr 211.233.32.11 cs.kaist.ac.kr 143.248.136.2 www.mit.edu 18.9.22.169 cs.berkeley.edu 128.32.244.172 www.google.com 74.125.127.99 IP IP IP IP DNS(Domain Name System) DNS nslookup(name server lookup) (domain name server)

$ nslookup IP $ nslookup cs.sookmyung.ac.kr Server: 203.252.192.1 Address: 203.252.192.1#53 Name: cs.sookmyung.ac.kr Address: 203.252.201.11 finger $ finger Login Name TTY Idle When Where chang Byeong-Mo Chang pts/5 Tue 12:02 221.139.179.42... $ finger chang $ finger chang Login name: chang In real life: Byeong-Mo Chang Directory: /user/faculty/chang Shell: /bin/csh On since Feb 12 21:07:26 on pts/5 from 221.139.179.42 No unread mail No Plan.

04 wrtie $ write Ctrl-D brain $ write brain who write $ who brain pts/5 4 5 15:36 (203.252.201.55) brain pts/7 4 5 15:46 (203.252.201.55)... $ write brain pts7 wall(write all) (shutdown) $ wall

$ wall System will be shut down in 5 minutes. Please logout quickly. ^D wall tty $ cat /etc/group... tty::7:root,tty,adm... mesg (y) (n) $ mesg [y n] mesg is y is n $ mesg is y write $ mesg n $ mesg y

04 $ talk @ ftp ftp (File Transfer Protocol, FTP) FTP FTP FTP ftp FTP FTP ftp sftp(secure ftp) sftp ftp

$ ftp -n $ sftp -n cs2.sookmyung.ac.kr ftp sftp $ ftp cs2.sookmyung.ac.kr Connected to cs2.sookmyung.ac.kr. 220 (vsftpd 2.0.5) Name (cs2.sookmyung.ac.kr:chang): 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> $ sftp cs2.sookmyung.ac.kr Connecting to cs2.sookmyung.ac.kr... chang@cs2.sookmyung.ac.kr's password: sftp > ftp get put ftp> get ftp> put // // cs2.sookmyung.ac.kr README ls get ftp> ls 200 PORT command successful. Consider using PASV.

04 150 Here comes the directory listing. Desktop README... 226 Directory send OK. 29 bytes received in 0.0087 seconds (3.25 Kbytes/s) ftp> get README 200 PORT command successful. Consider using PASV. 150 Opening BINARY mode data connection for README (1673 bytes). 226 File send OK. local: README remote: README 1673 bytes received in 0.042 seconds (38.71 Kbytes/s) ftp> quit README $ ls -sl README 4 -rw-r--r-- 1 chang faculty 1673 2 21 12:48 README mgetmput ftp 4.2!command lcd path cd path get mget * put mput * help

ls [path] pwd quit ascii bin (ascii mode) (binary mode) telnet ssh telnet (local host) (remote host) telnet $ telnet IP cs telnet $ telnet cs.sookmyung.ac.kr Trying 203.252.201.11... Connected to cs. Escape character is '^]'.

04 SunOS 5.9 login: 2 telnet 4.4 cs C:\> telnet cs.sookmyung.ac.kr telnet (secure shel) ssh rshrlogintelnet ssh

$ ssh @ $ ssh -l cs2.sookmyung.ac.kr chang $ ssh chang@cs2.sookmyung.ac.kr chang@cs2.sookmyung.ac.kr's password: $ ssh ssh who cs2.sookmyung.ac.kr $ ssh cs2.sookmyung.ac.kr who chang@cs2.sookmyung.ac.kr's password: root :0 2012-02-09 07:48 chang pts/1 2012-02-10 09:53 2 MS ssh PuTTY PuTTY http://www.chiark.greenend.org.uk/~sgtatham/putty PuTTY http://kldp.net/projects/iputty

04 4.5 telnet ssh ssh ssh 4.6 ssh cs2 ping IP

$ ping eecs.mit.edu $ ping eecs.mit.edu PING EECS.mit.edu (18.62.1.6) 56(84) bytes of data. 64 bytes from EECS.MIT.EDU (18.62.1.6): icmp_seq=0 ttl=239 time=229 ms 64 bytes from EECS.MIT.EDU (18.62.1.6): icmp_seq=1 ttl=239 time=228 ms... (CERN) (Tim Berners Lee) (World Wide Web, WWW, W3 (Web) HTTP HTML 1993 (hypertext) HTML(Hyper Text Markup Language) (Hyper Text Transfer Protocol)

04 HTTP (Uniform Resource Locator) '//' URL (Firefox) http://www.mozilla.or.kr (web browser) WWW URL Gmail 1993 (Mosaic) 1994 (Netscape) 1995 (Internet Explorer) (Mozilla) (Firefox) (Safari) (Chrome)

http://www.mozilla.or.kr http://www.google.com/chrome 4.7

04 4.8 http://www.apple.com/safari

4.9 http://www.mozilla.or.kr

04

telnet ssh (1) IP (2) (3) ftp sftp ftp C IP http://www.mozilla.or.kr http://www.google.com/chrome

Unix / Linux 05

Unix / Linux 05 AWKvi grep $ grep * grep you.txt grep you.txt When I am down and, oh my soul, so weary When troubles come and my heart burdened be Then, I am still and wait here in the silence Until you come and sit awhile with me

05 You raise me up, so I can stand on mountains You raise me up, to walk on stormy seas I am strong, when I am on your shoulders You raise me up, to more than I can be There is no life - no life without its hunger; Each restless heart beats so imperfectly; But when you come and I am filled with wonder, Sometimes, I think I glimpse eternity $ grep with you.txt Until you come and sit awhile with me There is no life - no life without its hunger; But when you come and I am filled with wonder, grep you.txt with without grep -w (word) without with $ grep -w with you.txt Until you come and sit awhile with me But when you come and I am filled with wonder, -n $ grep -n with you.txt 4:Until you come and sit awhile with me 15:There is no life - no life without its hunger; 17:But when you come and I am filled with wonder, -i (ignore)

$ grep -i when you.txt When I am down and, oh my soul, so weary When troubles come and my heart burdened be I am strong, when I am on your shoulders But when you come and I am filled with wonder, -v (reverse) $ grep -v raise you.txt When I am down and, oh my soul, so weary When troubles come and my heart burdened be Then, I am still and wait here in the silence Until you come and sit awhile with me I am strong, when I am on your shoulders There is no life - no life without its hunger; Each restless heart beats so imperfectly; But when you come and I am filled with wonder, Sometimes, I think I glimpse eternity (regular expression). : * : 0 a*b babaabaaab... a.* a [ ] : [ ] - [abc]d adbdcd [a-z] a z [1-9] 1 9 [^...] : [^ ] [^abc]d adbdcd edfd [^a-z]

05 ^, $ : 'st.*' stillstandstormystrong st 'w.*t' wait without w t $ grep -w 'st.*' you.txt Then, I am still and wait here in the silence You raise me up, so I can stand on mountains You raise me up, to walk on stormy seas I am strong, when I am on your shoulders $ grep -w 'w.*t' you.txt Then, I am still and wait here in the silence There is no life - no life without its hunger; grep egrep fgrep egrep grep -E-F grep sort $ sort [-] *

-r 0 -o -tc c you.txt sort $ sort you.txt But when you come and I am filled with wonder, Each restless heart beats so imperfectly; I am strong, when I am on your shoulders Sometimes, I think I glimpse eternity Then, I am still and wait here in the silence There is no life - no life without its hunger; Until you come and sit awhile with me When I am down and, oh my soul, so weary When troubles come and my heart burdened be You raise me up, so I can stand on mountains You raise me up, to more than I can be You raise me up, to walk on stormy seas 0 $ sort +2-3 you.txt Then, I am still and wait here in the silence When I am down and, oh my soul, so weary Until you come and sit awhile with me

05 When troubles come and my heart burdened be Each restless heart beats so imperfectly; You raise me up, so I can stand on mountains You raise me up, to more than I can be You raise me up, to walk on stormy seas There is no life - no life without its hunger; I am strong, when I am on your shoulders Sometimes, I think I glimpse eternity But when you come and I am filled with wonder, split $ split [-] [ ] -l n 1000 aa zz xaaxab... split you.txt 10 ls xaa xab $ split -l 10 you.txt $ ls -l -rw-r--r-- 1 chang faculty 341 2 16 14:36 xaa -rw-r--r-- 1 chang faculty 177 2 16 14:36 xab -rw-r--r-- 1 chang faculty 518 2 15 19:33 you.txt

cmp $ cmp 1 2 you.txt me.txt 10 340 me.txt When I am down and, oh my soul, so weary When troubles come and my heart burdened be Then, I am still and wait here in the silence Until you come and sit awhile with me You raise me up, so I can stand on mountains You raise me up, to walk on stormy seas I am strong, when I am on your shoulders You raise me up, to more than I can be You raise me up, so I can stand on mountains You raise me up, to walk on stormy seas I am strong, when I am on your shoulders There is no life - no life without its hunger; Each restless heart beats so imperfectly; But when you come and I am filled with wonder, Sometimes, I think I glimpse eternity $ cmp you.txt me.txt you.txt me.txt : 340, 10 diff -i

05 $ diff 1 2 diff 9 10 ~ 13 $ diff you.txt me.txt 9a10,13 > > You raise me up, so I can stand on mountains > You raise me up, to walk on stormy seas > I am strong, when I am on your shoulders n1n2 n3n4 (a) n1 n3 n4 n1 a n3,n4 > (d) n1 n2 n3 n1,n2 d n3 <

(c) n1 n2 n3 n4 n1,n2 c n3,n4 < -- > (link) (-s ) ln $ ln [-s] 1 [2] $ ln [-s] + (hard link) hi.txt hello.txt $ ln hello.txt hi.txt ls -l hello.txt hi.txt $ ls -l -rw------- 2 chang faculty 15 11 7 15:31 hello.txt -rw------- 2 chang faculty 15 11 7 15:31 hi.txt (symbolic link) C

05 $ ln -s hello.txt hi.txt hi.txt hello.txt ls -l $ ls -l -rw------- 1 chang faculty 15 11 7 15:31 hello.txt lrwxrwxrwx 1 chang faculty 9 1 24 12:56 hi.txt -> hello.txt find $ find [-]

-name -atime +n -atime -n -mtime +n -mtime -n -perm nnn -type x -size n -links n -user -group -print -exec cmd {}; n n n n nnn x n n cmd find $ find /usr -name *.c -print /usr.c. $ find. -name ping -ls ping ls. $ find. -type d -print (d). $ find. -perm 700 -ls 700 ls. $ find. -size +1024 -print

05 1024. $ find. -name core -size +2048 -ls core 2048 ls. $ find. -user chang -print chang. $ find. -atime +30 -print 30. $ find. -mtime -7 -print 7. $ find. -name core -exec rm -i {} ; core rm. $ find. -name *.c -atime +30 -exec ls -l {} ; 30 *.c ls -l. cron crontab cron crontab cron crontab crontab $ crontab crontab cron. crontab

$ crontab -l [] crontab. $ crontab -e [] crontab. $ crontab -r [] crontab. crontab 7 6 (*) - (,) 0=1=2=3=4= 5=6= crontab cron 6:30 /home/chang/tmp chang.cron 30 18 * * * rm /home/chang/tmp/* $ crontab chang.cron crontab 20 1 * * * root find /tmp -atime +3 -exec rm -f () ';' 1 20 3 /tmp. 30 1 * 2,4,6,8,10,12 3-5 /usr/bin/wall /var/tmp/message

05 2 1 30 wall. at at cron at at $ at [-] 1 31 11 45 sort Ctrl-D <EOT> $ at 1145 jan 31 at> sort infile > outfile at> <EOT> -f atq at at atq $ atq Rank Execution Date Owner Job Queue Job Name 1st Jan 31, 2012 11:45 chang 1327977900.a a stdin -r $ at -r $ at -r 1327977900.a

df $ df * $ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 49594228 7352576 39681696 16% / /dev/sda5 86495548 66226168 15875608 81% /home /dev/sdb1 141122196 103870536 30083060 78% /home1 /dev/sda1 101086 11455 84412 12% /boot tmpfs 1037652 0 1037652 0% /dev/shm du $ du [-s] * $ du 12./htdocs/graphics 258./htdocs/images 42./htdocs/lecture/math 2582./htdocs/lecture/sp/lab 33196./htdocs/lecture/sp...

05 -s $ du -s 22164. tar(tape archive) tar tar tar c(create)v(verbose)x(extract)t(table of contents) f(file) tar -cvf.tar $ tar -cvf + -xvf $ tar -xvf -tvf $ tar -tvf src.tar

$ tar -cvf src.tar * $ tar -tvf src.tar $ tar -xvf src.tar compress Z uncompress $ compress * $ uncompress.z* gzip ZIP.gz -d $ gzip * $ gzip -d.gz* compress gzip

05 gzip src.tar.gz $ tar -cvf src.tar * $ gzip src.tar gzip -d src.tar tar -xvf $ gzip -d src.tar.gz $ tar -xvf src.tar AWK AWK Alfred Aho, Peter Weinberger, Brian Kernighan AWK awk awk -f awk -F c $ awk [-Fc] * $ awk [-Fc] [-f ] * awk [ ] [ { } ]

awk NF(Number of Fields) $0 you.txt $ awk { print NF, $0 } you.txt 10 When I am down and, oh my soul, so weary 8 When troubles come and my heart burdened be 10 Then, I am still and wait here in the silence 8 Until you come and sit awhile with me 0 10 You raise me up, so I can stand on mountains 9 You raise me up, to walk on stormy seas 9 I am strong, when I am on your shoulders 10 You raise me up, to more than I can be 0 10 There is no life - no life without its hunger; 6 Each restless heart beats so imperfectly; 10 But when you come and I am filled with wonder, 6 Sometimes, I think I glimpse eternity NF $NF $ awk { print $1, $3, $NF } you.txt When am weary When come be Then, am silence Until come me You me mountains

05 You me seas I strong, shoulders You me be There no hunger; Each heart imperfectly; But you wonder, Sometimes, think eternity NR 1 4 $ awk NR > 1 && NR < 4 { print NR, $1, $3, $NF } you.txt 2 When come be 3 Then, am silence grep BEGIN // END // // // 1, 2 // 1 2 (action) C if () [else ] while () for ( ; ; ) break continue =

print [ ] printf [, ] next // exit // { } awk ex1.awk BEGIN { print " :", FILENAME } { print $1, $NF } END { print " " } ex1.awk you.txt -f $ awk -f ex1.awk you.txt : you.txt When weary When be Then, silence Until me You mountains You seas I shoulders You be There hunger; Each imperfectly; But wonder,

05 Sometimes, eternity ex2.awk BEGIN { print " " } { printf "line %d: %d \n", NR, NF; line++; word + = NF } END { printf " = %d, = %d\n", line, word } $ awk -f ex2.awk you.txt line 1: 10 line 2: 8 line 3: 10 line 4: 8 line 5: 0 line 6: 10 line 7: 9 line 8: 9 line 9: 10 line 10: 0 line 11: 10 line 12: 6 line 13: 10 line 14: 6 = 14, = 106

ex3.awk { for (I = 1; I <= NF; I += 2) printf "%s ", $I printf " \n" } $ awk -f ex3.awk you.txt When am and, my so When come my burdened Then, am and here the Until come sit with You me so can on You me to on seas I strong, I on shoulders You me to than can There no - life its Each heart so But you and am with Sometimes, think glimpse st e ex4.awk /st.*e/ {print $0 } $ awk -f ex4.awk you.txt Then, I am still and wait here in the silence You raise me up, to walk on stormy seas

05 I am strong, when I am on your shoulders Each restless heart beats so imperfectly; strong heart ex4.awk /strong/, /heart/ { print $0 } $ awk -f ex5.awk you.txt I am strong, when I am on your shoulders You raise me up, to more than I can be There is no life - no life without its hunger; Each restless heart beats so imperfectly; vi vi $ vi * vi 5.1

you.txt5.2 vi (command mode)(input mode) vi vi GUI vi vi

05 iiooaa ESC 5.3 5.3 ZZ :wq (ZZ ) :q :q!

vi 5 (1) (2) (3) (4) (5) h, j, k, l, BACKSPACE SPACE -

05 + RETURN 0 $ ^ w b ^F ^B ^D ^U ng n 1G G :n n /? /? /?

i a I A o O ESC r ESC r R s C cc cw s s :s// :n,m s// (n m)

05 :n s// (n) (.) 3,100 100 1,$.,.+10 10.,$ think THINK 1,$ s/think/think/g u (Undo) U. (Redo) x X D dd :n,m d n m

ny :n,m y n n m p P (write) :w. :w. :wq. ZZ. :e. :e!. :e#. :set number :se nu :set nonumber

05 :se non vi :! Enter vi :!ls :!cat test.c ls. cat test.c.

(1) tar (2) tar (3) ftp (4) tar (5) tar vi 001 80 M 002 100 M 003 54 M 004 60 F 005 75 M 006 49 F 007 59 F 2

05 2 awk.txt linux.txt. /etc/passwd C.txt *.h 1 10 200000 2 5 350000 3 8 730000 4 6 25000 5 7 220000 (1) (*) awk (2) awk

(3) awk C 8

Unix / Linux 06

Unix / Linux 06 (shell) (Shell) (command processor)

06 6.1 5 C Bash tcsh /bin/sh /bin/ksh /bin/csh /bin/bash /bin/tcsh 2 (Bourne shell) AT&T (Stephen Bourne) 1977 1980 (Korn shell) 6.2 (Bourne again shell) GNU OS X Bash Bash (Bill Joy) C (C shell) BSD

(login shell) /etc/passwd /etc/passwd /etc/passwd... root:x:0:1:super-user:/:/bin/csh... chang:x:109:101:byeong-mo Chang:/user/faculty/chang:/bin/csh C C C $ C % $ csh %... % exit $

06 chsh $ chsh Changing login shell for chang Old shell : /bin/sh New shell : /bin/csh $ logout login : chang passwd: % 3

3 6.3

06 (start-up file) /etc/profile ~/.profile /etc/profile /etc/bashrc ~/.bash_profile ~/.bashrc /etc/.login ~/.login ~/.cshrc

7 8 Bash C $ = TERM $ TERM=xterm $TERM TERM $ $ echo $TERM xterm export $ export TERM env set $ env HOSTNAME=CS2

06 HOST=CS2 TERM=xterm SHELL=/bin/sh GROUP=faculty USER=chang... /etc/profile.profile ~/.profile.profile PATH=$PATH:/usr/local/bin:/etc TERM=vt100 export PATH TERM stty erase ^.profile (.).profile $..profile

(built-in command) echocd $ echo -n * $ cd (utility program) PATH PATH PATH =.:/bin:/usr/bin:/usr/local/bin:/etc ls /bin/ls $ ls 2

06 $ > (append) $ >> $ < (here document) $ <<... 1 2 $ 1 2

(command sequence) $ 1; ; n $ date; who; pwd (command group) $ (1; ; n) pwd out1.txt out2.txt $ date; who; pwd > out1.txt $ (date; who; pwd) > out2.txt (conditional command sequence) && 1 0 2 2 $ 1 && 2

06 a.out $ gcc myprog.c && a.out 1 0 2 1 2 $ 2 $ gcc myprog.c echo (wildcard character) *? [..] *.c C.c C $ gcc *.c.c (a.c, b.c, c.c)

$ gcc a.c b.c c.c.txt $ ls *.txt a c $ ls [ac]* (command substitution) (`) `date` date $ echo `date` 2012 12 8 03 35 45 `ls wc -w` echo $ echo : `ls wc -w` : 32 3

06 3 * 4 = 12 3 4 * $ echo 3 * 4 = 12 3 cat.csh count.csh grade.csh invite.csh menu.csh test.sh = 12 $ echo "3 * 4 = 12" 3 * 4 = 12 $ echo '3 * 4 = 12' 3 * 4 = 12 echo echo $name `date` $ name= $ echo ' $name `date`' $name `date` $ echo " $name `date`" 2011 12 8 03 43 12 1. (') 2. (") 3.

(Shell script) 1. #! #!/bin/csh #!/bin/ksh #!/bin/bash #!/bin/sh 2. # C 3. (1)

06 test.sh echo datewhouptime test.sh #!/bin/sh echo : date echo : who echo : uptime (2) chmod $ chmod +x test.sh (3) $ test.sh : 2012 2 23 01 59 05 : brain pts/2 2 23 13:25 chang pts/5 2 23 11:40... : 1 59 1179, 18:55, 5 users, : 0.00, 0.00, 0.01 7 8 Bash C

(process) (job) ps ps CPU $ ps PID TTY TIME CMD 25435 pts/3 00:00:00 csh 25461 pts/3 00:00:00 ps $ ps [-] BSD V (man) BSD psps -aps -aux -a: -u: -x: V psps -ef -e:

06 -f: sleep $ sleep sleep 5 $ (echo ; sleep 5; echo ) kill $ kill [-] SIGTERM kill kill -9 SIGKILL 1230 $ (echo ; sleep 5; echo ) & 1230 $ kill 1230 wait

$ wait [] $ (sleep 10; echo 1 ) & 1231 $ echo 2 ; wait 1231; echo 3 2 1 3 $ (sleep 10; echo 1 ) & $ (sleep 10; echo 2 ) & $ echo 3 ; wait; echo 4 3 1 2 4 exit (exit code) $exit [] nohup nohup

06 $ nohup [ & nohup.out nice id batch ID ID 6.2 cdecho evalexec shiht eval `echo x=5 ` x=5 x 5 $ eval `echo x=5` $ echo $x 5 exec

date exec 12 $ exec date shift shift $2... $n $1... $n-1 shift shift.sh #!/bin/sh echo $1, $* shift echo $1, $* $ shift.sh a b c d a, a b c d b, b c d

06.profile echo Hello Shell! PATH=$PATH:/usr/local/bin:. TERM=vt100 export PATH TERM stty erase ^H $..profile $ echo $PATH C ps C $ echo $SHELL /bin/sh $ ps $ csh % ps... % exit $ ps

($1) $ date; who; pwd > out1.txt $ (date; who; pwd) > out2.txt $ ps -aux $ ps -ef $ id $ echo $SHELL #!/bin/sh echo $1, $* shift echo $1, $* shift echo $1, $* chsh

06 C C /tmp.txt $ ls -l * > list

Unix / Linux 07

Unix / Linux 07 (Borune-again shell) GNU (Brian Fox) 1989 OS X Bash Bash Bash Bash.bash_history Bash Bash (ksh) C (csh) Bash Bash (stdout) (stderr) Bash Bash (start-up file) /etc/profile

07 /etc/bashrc ~/.bash_profile ~/.bashrc 7.1 /etc/profile.bash_profile.bashrc.bash_profile /etc/profile #.bash_profile if [ -f ~/.bashrc ] then. ~/.bashrc

fi # PATH=$PATH:$HOME/bin BASH_ENV=$HOME/.bashrc USERNAME="root" export USERNAME BASH_ENV PATH 7.1 if bashrc.bash_profile.bashrc PATH BASH_ENV USERNAME export PATH ':' $PATH $HOME/bin.bashrc.bash_profile (alias) 7.2 7.2 4 /etc/bashrc ~/.bash_profile ~/.bashrc /etc/bashrc #.bashrc # alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' alias ll='ls -al --color=yes'

07 # if [ -f /etc/bashrc ] then. /etc/bashrc fi Bash alias $ alias = ls -af dir $ alias dir=ls -af $ dir $ alias h=history $ alias list=ls -l

$ alias # dir ls -af h history list ls -l unalias $ unalias Bash $ history [-rh] [] history $ history 1 ls 2 who 3 env 4 vi test.sh 5 chmod +x test.sh 6 test.sh 7 ls 8 gcc test.c 9 history... HISTSIZE 100 50 $ HISTSIZE=100

07 HISTFIESIZE.bash_history $ HISTFIESIZE=100 Bash 7.1!!!n n!!? $!! # $!20 # 20 $!gcc # gcc $!?test.c # test.c

= (simple variable) $ = city seoul $ city=seoul $ city $ echo $city seoul city city pusan city seoul pusan $ city=pusan country korea city seoul $ country=korea city=seoul

07 $ country= city= $ echo $country $city $ address=" " (list variable) $ =( ) cities $ cities=( ) $ 7.2

${name[i]} ${name[*]} ${name[@]} ${#name[*]} ${#name[@]} name i name name $ echo ${cities[*]} $ echo ${cities[1]} $ echo ${#cities[*]} # 3 $ echo ${cities[4]} cities cities $ cities=(${cities[*] )

07 $ echo ${cities[4]} read $ read 1,..., n $ read x y Merry Christmas! $ echo $x Merry $ echo $y Christmas! $ read x Merry Christmas! $ echo $x Merry Christmas!

(environment variable) (local variable) 7.2 export country

07 city $ country= city= $ export country $ echo $country $city $ sh $ echo $country $city $ ^D $ echo $country $city (predefined environment variable) $USER $TERM $PATH $HOME $SHELL $MAIL $HOSTNAME 7.3

$ echo = $HOME = $USER = $SHELL = /user/faculty/chang = chang = /bin/csh $ echo = $TERM = $PATH = vt100 = /bin:/usr/bin:/usr/local/bin 7.4 (predefined local variable) $$ $0 $1 ~ $9 $* $# #!/bin/bash # builtin.bash echo : $0 echo : $1 echo : $* echo : $$ $ builtin.bash hello shell : builtin.sh : hello

07 : hello shell : 12596 Bash (1) Bash 7.4 state.bash echodatewhouptime #!/bin/bash # state.bash echo -n : date echo : who echo : uptime (2) chmod $ chmod +x state.bash $ state.bash : 2012 2 23 07 16 17 : chang pts/5 2 23 11:40 (221.139.179.42) brain pts/2 2 23 19:12 (203.252.201.55)

... : 7 16 1180, 12, 4 users, : 0.01, 0.01, 0.01 Bash Bash ifcaseforwhile if-then if then fi Bash test [ ] if `test $# -eq 1` if [ $# -ne 1 ]

07 [ ] 7.5 wc if-then 1 wc #!/bin/bash # : wc1.bash # wc. if [ $# -ne 1 ] then echo : $0 exit 1 fi file=$1 wc $file $ wc1.bash : wc1.bash $ wc1.bash cs1.txt 38 318 2088 cs1.txt if-then-else if then else fi

7.6 if-then-else #!/bin/bash # : count1.bash [ ] #. if [ $# -eq 0 ] then dir="." else dir=$1 fi echo -n $dir : ls $dir wc -l $ count1.bash. : 17 Bash 7.5 7.57.6 ($#)

07 1 -eq 2 1 -ne 2 1 -gt 2 1 -ge 2 1 -lt 2 1 -le 2 1 2 1 2 1 2 1 2 7.6 1 == 2 1!= 2 -n null -z null 7.7 #!/bin/bash # : reply.bash #. echo -n "?" read reply if [ $reply == " " ]

then echo elif [ $reply == "" ] then echo fi $ reply.bash? Bash (file-oriented operator) 7.7 -a -e -r -w -x -O -z 0 -f -d

07 7.5 wc $file wc if [ -e $file ] then wc $file else echo "! " fi # $file # $file 7.2 $dir if [ -d $dir ] then echo -n $dir : ls $dir wc -l else echo $dir\: fi (Boolean operators)! (negation) && (logical and) (logical or) uptime if [ -f $file ] && [ -w $file ]

then fi uptime > $file # $file if [! -e $file ] then # $file echo $file : fi if [! -d $file ] then # $dir echo $file : fi Bash $ a=2+3 "2+3" expr expr a $ a=`expr 2 + 3`

07 Bash let let $ let = $ let a=2*3 $ echo $a 6 $ let a=$a+2 $ echo $a 8 C $ let a*=10 $ let a++ Bash C 7.8 -! * / % + - << >> <= >= < > ==!= && & ^ and xor or

Bash (()) 7.5 7.8 #!/bin/bash # : wc2.bash # wc. if (( $#!= 1 )) then echo : $0 exit 1 fi file=$1 wc $1 Bash declare typeset declare bash 2 declare 7.9

07 declare -r declare -i declare -a declare -f declare -f declare -x export let $ declare -i a # a $ a=12 $ a=a+1 # let $ echo $a $ a=12.3 # bash: 12.3: syntax error in expression (error token is ".3") $ declare -r b=23.4 # b $ b=23.5 # bash: b: readonly variable Bash ifswitchforwhile

if if then fi if then else fi if then elif then else fi if 7.9 #!/bin/bash # : score1.bash #.

07 echo -n ' : ' read score if (( $score >= 90 )) then echo A elif (( $score >= 80 )) then echo B elif (( $score >= 70 )) then echo C else echo fi $score1.bash : 85 B if case case in 1) ;; 2) ;;... *) ;; esac 7.9 case 7.10 score 10 grade case "10" "9" grade 10 9 echo A

#!/bin/bash # : score2.bash #. echo -n ' : ' read score let grade=$score/10 case $grade in "10" "9") echo A;; "8") echo B;; "7") echo C;; *) echo ;; esac for for in do done 7.11 person list echo echo \ #!/bin/bash # : invite.bash #.

07 invitee=(lee kim choi) for person in $invitee do echo " :." \ mail "${person}@gmail.com" done for $* for file in $* do... done 7.12 ls -l cut #!/bin/bash # : perm1.bash * #. if [ $# -eq 0 ] then echo : $0 * exit 1 fi echo " for file in $* do "

if [ -f $file ] then fileinfo=`ls -l $file` perm=`echo "$fileinfo" cut -d' ' -f1` echo "$perm $file" fi done $ perm1.bash cs1.txt cs2.txt -rw-rw-r-- cs1.txt -rw-rw-r-- cs2.txt while while do done 2 n 7.13 $j 10 while 2 ^ 1 = 2 i 2 j 1 2 ^ 1 = 2 2 ^ 10 = 1024 #!/bin/bash # : power.bash # 2 1 10. let i=2 let j=1 while (( $j <= 10 )) do

07 echo '2 ^' $j = $i let i*=2 let j++ done $ power.bash 2 ^ 1 = 2 2 ^ 2 = 4 2 ^ 3 = 8 2 ^ 4 = 16 2 ^ 5 = 32 2 ^ 6 = 64 2 ^ 7 = 128 2 ^ 8 = 256 2 ^ 9 = 512 2 ^ 10 = 1024 casewhile 7.14 case while q #!/bin/bash # : menu.bash #. echo stop=0 while (($stop == 0)) do cat << MENU d : l : w :

q : MENU echo -n '? ' read reply case $reply in "d") date;; "l") ls;; "w") who;; "q") stop=1;; *) echo ;; esac done $ menu.bash d : l : w : q :? d 2012 2 23 07 33 27 d : l : w : q :? q Bash () { }

07 $1,..., $n 7.15 lshead() /tmp 3 #!/bin/bash # : lshead.bash lshead() { echo ", $1" date echo " $1 3 " ls -l $1 head -4 } echo "" lshead /tmp exit 0 $lshead.bash, /tmp 2012 2 23 08 31 31 /tmp 3 1184 -rw------- 1 chang faculty 11264 2009 3 28 Ex01378 -rw------- 1 chang faculty 12288 2011 5 8 Ex02004 -rw------- 1 root other 8192 2011 5 4 Ex02504

Bash $ bash -vx [ ] -v -x menu.bash -v $ bash -v menu.bash #!/bin/bash echo stop=0 while (($stop == 0)) do cat << MENU echo -n '? ' read reply case $reply in "d") date;; "l") ls;; "w") who;; "q") stop=1;; *) echo ;; esac done d : l : w :

07 q :? d 2012 2 23 07 35 05 d : l : w : q :? q shift shift [] for while 7.12 7.16 while shift $1 #!/bin/bash # : perm2.bash * #. if [ $# -eq 0 ] then echo : $0 exit 1 fi echo " while [ $# -gt 0 ] "

do file=$1 if [ -f $file ] then fileinfo=`ls -l $file` perm=`echo "$fileinfo" cut -d' ' -f1` echo "$perm $file" fi shift done for * * cd $dir for file in * do... done 7.17 ($#) ($1) for file in * 1 #!/bin/bash

07 # : count2.bash [ ] #,,. if [ $# -eq 0 ] then dir="." else dir=$1 fi if [! -d $dir ] then echo $0\: $dir exit 1 fi let fcount=0 let dcount=0 let others=0 echo $dir\: cd $dir for file in * do if [ -f $file ] then let fcount++ elif [ -d $file ] then let dcount++ else let others++ fi done echo : $fcount : $dcount : $others $ count2.bash /user/faculty/chang: : 4 : 45 : 0

C (recursion) Bash Bash (head) 7.18 head rhead.bash /home/ faculty/chang/bash/rhead.bash #!/bin/bash # rhead.bash [ ] #. cd $1 for file in * do if [ -f $file ] then echo "========== $file ===========" head $file fi if [ -d $file ]

07 then /home/faculty/chang/bash/rhead.bash $file fi done while for $ for f in * > do > echo $f > done $ let i=2 $ let j=1 $ while (( $j <= 10 )) > do > echo '2 ^' $j = $i > let i*=2 > let j++ > done 2 ^ 1 = 2 2 ^ 2 = 4 2 ^ 3 = 8 2 ^ 4 = 16 2 ^ 5 = 32 2 ^ 6 = 64 2 ^ 7 = 128 2 ^ 8 = 256 2 ^ 9 = 512 2 ^ 10 = 1024

Bash (1) -------------------------------------------------------------------- -------------------------------------------------------------------- 1. 2. 3. 4. 5. -------------------------------------------------------------------- : (2) 1 -------------------------------------------------------------------- [... ] -------------------------------------------------------------------- -------------------------------------------------------------------- (3) 2 (4) 3

07 (5) 4 (6) 5 Bash : listexe [ ] del del Bash -p -l : trash [-pl] * while Bash Bash #!/bin/bash let i=2 let j=1 while (( $j <= 10 )) do echo '2 *' $j = $i let i+=2 let j++ done

Bash : listdir [ ] yes Bash : delete [ ] 7.18 #!/bin/bash date > $1.$$ ls $1.$$ #!/bin/bash mail $1 << ENDOFTEXT - $USER ENDOFTEXT echo $1

Unix / Linux 08

Unix / Linux 08 1 C (Bill Joy) C C C C C 6 C C C OS X C tcsh 8.1 C

08 C C ~/.cshrc /etc/.login, ~/.login 1 ~/.cshrc 2 /etc/.login 3 ~/.login.login TERMPATH.login echo Hello, $USER! echo Welcome to UNIX

echo -n "Today is "; date set term = vt100 set path=(. /bin /usr/bin /usr/local/bin) set history = 40 set prompt = '\! % ' stty erase ^H.cshrc.cshrc alias h history alias dir ls -af alias ll ls -l alias m more alias x chmod +x alias % alias # ls -af dir

08 % alias dir ls -af % dir % alias h history % alias list ls -l % alias # dir ls -af h history list ls -l unalias % unalias C $ history [-rh] [] history % history 1 ls 2 who 3 set 4 vi test.sh 5 chmod +x test.sh 6 test.sh

7 ls 8 gcc test.c 9 history... history % set history = 40 savehist % set savehist = 32 \! % set prompt = '\! % ' C 8.2!!!n no!!?

08 %!! # %!20 # 20 %!gcc # gcc %!?test.c # test.c % > % gcc a.c > errors >& % >& errors % gcc a.c >& errors 1 2

% ( > 1) >& 2 out errors % (gcc a.c > out) >& errors 1 2 % 1 2 % gcc a.c wc & % 1 & 2 wc % gcc a.c & wc 1 2

08 % (1 > ) & 2 out wc % (gcc a.c > out) & wc C C set (simple variable) % set = city seoul % set city = seoul $ city % echo $city seoul city city pusan city seoul pusan

% set city = pusan % set color % set color country korea color city seoul % set country = korea color city = seoul % set country = city = % echo $country $city % set address = " "

08 (list variable) set % set cities % set cities = ( ) $ 8.3 $name[i] ${name[i]} $#name ${#name} name i name % echo $cities % echo $cities[1]

% echo $cities[2-3] # % echo $#cities # 3 % echo $cities[4] cities cities % set cities = ($cities ) % echo $cities[4]

08 (environment variable) (local variable) C set setenv setenv

= % setenv LANG ko % setenv LANG ko C (predefined local variables) 8.4 $< $argv $argv[1] = $1 $cwd $history $home $$, $n, $* $prompt $shell $path $term $< % set input = $< hello C shell! % echo $input

08 hello C shell! C #!/bin/csh # local.csh echo : $argv[0] echo : $argv[1] echo : $#argv echo : $home echo : $cwd echo : $shell $ local.csh hello csh : : hello : 2 : /user/faculty/chang : /user/faculty/chang/unix/csh : /bin/csh C (predefined environment variable) $HOME$USER$TERM$PATH$PWD 8.5 $HOME $USER $TERM $PATH $PWD $home $user $term $path $cwd

$TERMCAP $LD_LIBRARY_PATH $LOGNAME ld(linkage editor) C C (1) C 8.2 state.csh echodatewhouptime #!/bin/csh # state.csh echo -n : date echo : who echo : uptime (2) chmod % chmod +x test1.csh (3) C % state.csh

08 : 2012 2 23 07 16 17 : chang pts/5 2 23 11:40 (221.139.179.42) brain pts/2 2 23 19:12 (203.252.201.55)... : 7 16 1180, 12, 4 users, : 0.01, 0.01, 0.01 C C ifswitchforeachwhile if if () "yes" echo set input = $< if ( $input == "yes") echo hello world! if-then if () then endif 8.3

wc if-then 1 #!/bin/csh # : wc.csh # wc. if ($#argv!= 1) then echo : $argv[0] exit 1 endif set file = $argv[1] wc $file $ wc.csh : wc.csh $ wc.csh cs1.txt 38 318 2088 cs1.txt if-then-else if () then else endif 8.4 if-then-else

08 #!/bin/csh # : count1.csh [ ] #. if ($#argv == 0) then set dir = "." else set dir = $argv[1] endif echo -n $dir : ls $dir wc -l $ count1.csh. : 17 C 8.6 =~!~ *? ==!= =~ ==!~!=

8.5 #!/bin/csh # : reply.csh #. echo -n "?" set reply = $< if ($reply == " ") then echo else if ($reply =~ *) then echo endif $ reply.csh? C 8.7 (file-oriented operator)

08 -e -r -w -x -o -z 0 -f -d 8.3 wc $file wc if (-e $file) then # $file wc $file else # $file echo "! " endif 8.4 $dir if (-d $dir) then echo -n $dir : ls $dir wc -l else echo $dir\: endif

(Boolean operator)! (negation) && (logical and) (logical or) uptime if (-f $file && -w $file) then uptime > $file endif # $file if (! -e $file) then endif echo $file : # $file if (! -d $file) then endif echo $file : # $dir C % set a = 2 * 3 set

08 C @ @ @ = % @ a = 2 * 3 % echo $a 6 % @ a = $a + 2 % echo $a 8 C % @ a *= 10 % @ b++ @ (associativity)c C C 5 * 2 10 20 4 + 2 6 9 % @ i = 20 / 5 * 2 % echo $i 2

% @ i = 9-4 + 2 % echo $i 3 C C 8.8 -! * / % + - << >> <= >= < > ==!= && & ^ and xor or C ifswitchforeachwhile

08 if if () if () then endif if () then else endif if () then else if () then else endif if 8.6 if

#!/bin/csh # : score1.csh #. echo -n ' : ' set score = $< if ($score >= 90) then echo A else if ($score >= 80) then echo B else if ($score >= 70) then echo C else echo endif $score1.csh : 85 B if switch switch () case 1: breaksw case 2: breaksw... default: breaksw endsw

08 8.6 switch 8.7 score 10 grade switch case "10" case "9" breaksw grade 10 9 echo A #!/bin/csh # : score2.csh #. echo -n ' : ' set score = $< @ grade = $score / 10 switch ($grade) case "10" : case "9": echo A breaksw case "8": echo B breaksw case "7": echo C breaksw default: echo endsw foreach foreach ()

end 8.8 person list echo echo \ #!/bin/csh # : invite.csh #. set list = (lee kim choi) foreach $person ($list) echo :. \ mail "${person}@gmail.com" end foreach $argv foreach file ($argv)... end 8.9 ls -l 6 #!/bin/csh # : filesize1.csh * #.

08 if ($#argv == 0) then echo : $0 * exit 1 endif echo " ()" foreach file ($argv) if (-f $file) then set fileinfo = `ls -l $file` set size = $fileinfo[5] echo "$file $size" endif end $ filesize1.csh cs1.txt cs2.txt () cs1.txt 2088 cs2.txt 1247 while while () end 2 n 8.10 $j 10 while 2 ^ 1 = 2 i 2 j 1 2 ^ 1 = 2 2 ^ 10 = 1024 #!/bin/csh # : power.csh # 2 1 10.

set i = 2 set j = 1 while ( $j <= 10 ) echo '2 ^' $j = $i @ i *= 2 @ j++ end $ power.csh 2 ^ 1 = 2 2 ^ 2 = 4 2 ^ 3 = 8 2 ^ 4 = 16 2 ^ 5 = 32 2 ^ 6 = 64 2 ^ 7 = 128 2 ^ 8 = 256 2 ^ 9 = 512 2 ^ 10 = 1024 switchwhile 8.11 switch while q #!/bin/csh # : menu.csh #. echo set stop = 0 while ($stop == 0) cat << MENU d :

08 l : w : q : MENU echo -n '? ' set reply = $< switch ($reply) case "d" : date breaksw case "l": ls breaksw case "w": who breaksw case "q": set stop = 1 breaksw default: echo endsw end $ menu.csh d : l : w : q :? d 2012 2 23 07 33 27 d : l : w : q :? q

C C C C % csh -vx [] -v -x -vx menu.csh -v % csh -v menu.csh echo set stop = 0 while ( $stop == 0 ) cat << MENU d : l : w : q : echo -n '? '? set reply = $< d switch ( $reply )

08 date 2011 12 9 04 14 18 breaksw end echo -n '? '? set reply = $< q switch ( $reply ) set stop = 1 breaksw end while ( $stop == 0 ) -x % csh -x menu.csh echo set stop = 0 while ( 0 == 0 ) cat d : l : w : q : echo -n?? d set reply = d switch ( d ) date 2012 2 25 06 03 37 breaksw end while ( 0 == 0 ) cat

d : l : w : q : echo -n?? q set reply = q switch ( q ) set stop = 1 breaksw end while ( 1 == 0 ) shift shift [] shift argv[2]... argv[n] argv[1]... argv[n-1] foreach while 8.9 8.12 while shift argv[1]

08 #!/bin/csh # : filesize2.csh * #. if ($#argv == 0) then echo : $0 * exit 1 endif echo " ()" while ($#argv) set file = $argv[1] if (-f $file) then set fileinfo = `ls -l $file` set size = $fileinfo[5] echo "$file $size" endif shift end foreach * * cd $dir foreach file (*)... end ($#argv)

($argv[1]) foreach file (*) 1 #!/bin/csh #,,. #: count2.csh [ ] if ($#argv == 0) then set dir = "." else set dir = $argv[1] endif if (! -d $dir) then echo $0\: $dir exit 1 endif @ fcount = 0 @ dcount = 0 @ others = 0 echo $dir\: cd $dir foreach file (*) if (-f $file) then @ fcount++ else if (-d $file) then @ dcount++ else @ others++ endif end

08 echo : $fcount : $dcount : $others $ count2.csh ~ /user/faculty/chang: : 4 : 46 : 0 C C (recursion) C (head) 8.14 foreach file (*) head rhead.csh /home/faculty/chang/csh/rhead.csh #!/bin/csh # rhead.csh [ ] #. cd $argv[1]

foreach file (*) if (-f $file) then echo "========== $file ===========" head $file endif if (-d $file) then /home/faculty/chang/csh/rhead.csh $file endif end while foreach % foreach f (*)? if (-d $f) echo $f? end % set i = 2 % set j = 1 % while ($j <= 10)? echo '2 ^' $j = $i? @ i *= 2? @ j++? end 2 ^ 1 = 2 2 ^ 2 = 4 2 ^ 3 = 8 2 ^ 4 = 16 2 ^ 5 = 32 2 ^ 6 = 64

08 2 ^ 7 = 128 2 ^ 8 = 256 2 ^ 9 = 512 2 ^ 10 = 1024

C (1) -------------------------------------------------------------------- -------------------------------------------------------------------- 1. 2. 3. 4. 5. -------------------------------------------------------------------- : (2) 1 -------------------------------------------------------------------- [... ] -------------------------------------------------------------------- -------------------------------------------------------------------- (3) 2 (4) 3

08 (5) 4 (6) 5 C listexe [ ] del del C -p -l trash [-pl] * while C C #!/bin/csh set i = 2 set j = 1 while ( $j <= 10 ) echo '2 *' $j = $i @ i += 2 @ j++ end

listdir [ ] yes C delete [ ] 8.14 #!/bin/csh date > $argv[1].$$ ls $argv[1].$$ #!/bin/csh mail $argv[1] << ENDOFTEXT. - $USER ENDOFTEXT echo $argv[1].

Unix / Linux 09

Unix / Linux 09 C C C C C C (cc) C gcc(gnu cc) gcc http://gcc.gnu.org C 9.1 longest[] longest.c #include <stdio.h> #define MAXLINE 100