108
©Brooks/Cole, 2001 Chapter 3 File Systems ( 파파 파파파 파파 파파파 ) )

©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

Embed Size (px)

Citation preview

Page 1: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Chapter 3

File Systems ( 파일 시스템파일 시스템 ))

Page 2: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

파일 시스템파일 시스템

UNIX uses a broader interpretation of files than in most operating systems. In UNIX, a file is any source from which data can be read or any destination to which data can be written. Therefore, the keyboard, a source of input, is a file; the monitor, a destination for output, is a file; a printer, another destination for output, is a file; and a document stored on a disk, a source or destination of data, is also a file.

Page 3: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

• 길이제약 : 14 ~ 255 문자• Any sequence of ASCII characters

• 추천규칙1. Start name with an alphabetic character.

2. Use dividers to separate parts of name. (underscore, period, hyphen)

3. Use an extension at the end of filename. .txt, .dat .c .c++

4. Never start a filename with a period. (hidden files in UNIX are created and used by the system)

.profile, .kshrc, .cshrc

3.1 Filenames( 파일명 )

Page 4: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-1

Wild Cards

A token that specifies that one or more different characters can be used to satisfy a specific request.

와일드카드 문자는 하나 이상의 다른 문자들을 대표적으로 상징하는 특수 문자를 의미한다 .

Page 5: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

• Matching any single character (?) Table 3.1 c? c1 c2 c3 ca ac cat c?t cat cet cit c1t cad dac c??t caat cabt cact c12t cat daat ?a? bat car far mar bed cur• Matching a single character from a set ([…]) Table 3.2 f[aoei]dfad fed fod fid fud fab f[a-d]t fat fbt fct fdt fab fet f[A-z][0-9] fA3 fa3 fr2 f^2 FA3 fa33

Wild Cards

일치불일치

Page 6: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Wild Cards

• Matching zero or more characters (*) include nothing Table 3.3 * 모든 파일 f* f 로 시작하는 모든 파일 f5c2 *f f 로 끝나는 모든 파일 staff *.* 파일 이름에 . 을 가지는 모든 파일 file.dat• Echo command and file wildcards : check existence of files using wildcards $ echo f?t // 현 디렉토리에 f 로 시작하고 f-t f1t fat fbt fgt fwt // t 로 끝나는 중간에 하나의

// 문자만 가지는 파일의 존재 검사

asterisk

Page 7: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-2

3.2 Files in Unix: 파일 유형 P. 68 참조

3.3 Regular (Ordinary) Files

- Text Files ASCII code 로 구성

- Binary Files data files and program files

단말기 디스크 파이프 네트워크

Page 8: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-3

3.4 A Directory Hierarchy( 디렉토리 계층 )

Directory files: A directory is a file that contains the names and locations of all files stored on a physical device.

Page 9: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

• 루트 디렉토리 (Root Directory) (/) - the highest level in the hierarchy - not have a parent directory - belongs to system administrator• 홈 디렉토리 (Home Directory) ~ or ~kykim• 작업 디렉토리 (Working Directory) ., $ pwd• 부모 디렉토리 (Parent Directory) ..

디렉토리 : 특수 디렉토리

Page 10: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Pathnames( 경로명 )

• 경로명 (pathname) 은 디렉토리 계층구조 내의 위치를 규정함으로써 특정 파일이나 디렉토리를 구분한다 .

• 경로명 내의 slashes (/) 는 객체명 ( 파일 or 디렉토리 ) 들 간의 구분자 역할을 한다 .

• 처음 위치의 slash 는 / (root) directory 를 나타낸다

/usr/lib/netsvc/yp/ypstart

root Directory

Delimiters

Object(file or directory)

Page 11: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

• Absolute pathname (Full pathname: 절대 경로명 )– Specifies a file or directory in relation to the entire Solaris relation to the entire Solaris

file hierarchyfile hierarchy– Starts the Starts the rootroot ( (//) directory) directory and lists each directory along

the path to the final destination– Uses a slash (/) separates multiple directory or file names 참고 : Table 3.4(Fig. 3.3)

• Relative pathname( 상대 경로명 )– Describes the location of a file or directory in relation to relation to

the current directorythe current directory– Useful because they are shorter than absolute pathnames– Do not begin with a slashnot begin with a slash– Uses slashes (/) within the pathname as delimiters between

object names

Pathnames( 경로명 ) : 절대경로 / 상대경로

Page 12: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

① ../../../../etc/mail② /usr/ccs/bin③ /usr/openwin/lib/X11/fonts④ bin⑤ Openwin/lib/X11/fonts⑥ /lib⑦ /export/home⑧ ../usr/ccs/bin

Pathnames( 경로명 ) : 절대경로 / 상대경로 예

Page 13: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

상대경로의 축약

• 홈 디렉토리 ( ~ ) tilde ~/project.list ~kykim/file1• 작업 디렉토리 ( . ) file6 ./file6 ~/file6 ~tran/file6• 부모 디렉토리 ( .. ) .., ../..

Page 14: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-4Relative Pathnames for file3

~joan/file3

Page 15: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-5A Disk File Format

In UNIX, a file system has four structural sections known as blocks:

Page 16: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

• 부트 블럭 (Boot Block) boot program : used to load kernel into memory.

• 슈퍼 블럭 (Super Block) contains information about file system.

total size of disk, free blocks, location of bad blocks

• 아이노드 블럭 (Inode Block) Information node block : information about each file in the

data block. (file owner, file type, permission, address)

• 데이터 블럭 (Data Block)

File system

( 파일 시스템 )

Page 17: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-6Inodes

Page 18: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-7A Directory of Three Files

File name Inode number

Link

A link is a logical relationship between an inode and a file that relates the name of a file to its physical location.

Page 19: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-8

링크 : A Hard Link

디렉토리 내의 inode 는 파일 이름을 물리적인 장치에 직접 연결한다 . 다중 파일 링크 허용

Page 20: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-09

링크 : A Symbolic(Soft) Link

1. 디렉토리에 대한 링크

2. 다른 파일 시스템 상의 링크

Page 21: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-10

Symbolic Links to Different File Systems

Page 22: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-11 하나의 파일에 대한 다중 링크

* 하드링크는 파일에 대해서만 사용될 수 있으나 , 소프트링크는 파일 외에 디렉토리에도 사용될 수 있다 .

UNIX 에서 물리적인 파일은 단지 하나의 inode 만 가질 수 있지만 여러 개의 이름을 가질 수 있다 .

Page 23: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.2 inode List

$ ls -ai79944 . 79887 DirE 79937 file1

80925 .. 79942 backUpDir 79872 lnDir

79965 DirA 79906 backUpDir.mt 79871 mvDir

---------------------------------------------------------

현 디렉토리의 inode 가 79944 이고 부모 디렉토리가 80925 이다

Page 24: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

• 복사 , 하드링크 , 심볼릭링크

Inode 블럭

Data 블럭

Inode1

Inode2

원본파일데이타

원본파일포인터

원본 파일

하드링크 파일

심볼릭 링크 파일

디렉토리

원본 복사파일 Inode3 복사파일데이타

$ cp$ ln

$ ln -s

Page 25: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-12

3.6 디렉토리 명령어

Page 26: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-13

The pwd Command: Print Working Directory

No options!

No arguments!

Page 27: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.3. Print Working Directory

$ pwd

/export/home/pro/kykim // /export/home1/std11/s00…

------------------------------------------------------------

자신의 단말기 창에서 $ pwd

명령을 실행하고 결과를 분석

Page 28: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-14

The ls Command: List Directory

Page 29: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.4. Basic List Directory

$ ls

BST.c aFile file1 memo509 saturn zFile

BST.h binSrch.c gnuFile note311 statusRpt

------------------------------------------------------------

Page 30: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-15

Long List Option (-l)

o 파일타입

–( 정규 ), d( 디렉토리 ), c( 문자 ), b( 블록 ), l( 소프트링크 ), p(FIFO), s(소켓 )

o 접근권한 (4 장 )

o 링크 : 디렉토리나 파일에 연결된 (linked) 파일 수

o 소유자 , 그룹 , 파일크기 (byte), 최종수정날짜 , 파일이름

Page 31: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-16Directory Structure Recursive List

$ ls –Rp // ~ 에서 session 3.11 참고 P. 85

Page 32: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.5. List All Option$ ls -a ~. .mailrc file2.. .profile mail.forward .sh_history mail.instr.dp-cis-b12 C-Programs mail.staff.ids.history f-files manVi.login file.c status.lsignature file.bin

------------------------------------------------------------Session 3.6 List Directory Option$ ls -lddrwxr-xr-x 14 gilberg staff 3584 May 17 15:17 .

-d 옵션은 작업디렉토리 만 출력한다

Page 33: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

------------------------------------------------------------

Session 3.7 List User and Group IDs

$ ls -nd

drwxr-xr-x 2 3988 24 512 May 17 08:53 .

------------------------------------------------------------

Session 3.8 List Directory in Reverse Order

$ ls -r

zFile saturn memo509 file1 aFile BST.c

statusRpt note311 gnuFile binSrch.c BST.h

------------------------------------------------------------

Page 34: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.9 List Directory in Basic Time Sequence$ ls –lt // latest file firsttotal 12-rw-r--r-- 1 gilberg staff 14 May 19 13:33 file1drwxr-xr-x 2 gilberg staff 512 May 19 13:29 memos-rw-r--r-- 1 gilberg staff 15 May 18 18:17 zFile-rw-r--r-- 1 gilberg staff 15 May 18 18:16 aFile.tmp------------------------------------------------------------Session 3.10 List Directory-Identify Directories (/)$ ls -pBST.c binSrch.c memo509 saturn zFileBST.h file1 memos/ statusRptaFile.tmp gnuFile note311 unix7.1/

Page 35: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

------------------------------------------------------------Session 3.11 Recursive List$ ls -Rpfile1 file2 techNotes/ unix7.1/./techNotes:personal/ sort.doc vi.doc./techNotes/personal:profile.doc./unix7.1/:BST.c file7.1 memos/ srch.cBST.h gnuFile saturn zFile./unix7.1/memos:dick318 statusRpt tran407------------------------------------------------------------

Page 36: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.12 Print One Column$ ls -1 // 1 one, not (el) BST.cBST.haFile.tmp…zFile------------------------------------------------------------Session 3.13 Print inode Number$ ls -li file1 zFile37585 -rw-r--r-- 1 gilberg staff 14 May 17 16:32 file133809 -rw-r--r-- 1 gilberg staff 15 May 18 18:17 zFile------------------------------------------------------------

$ man ls

Page 37: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-17The mkdir Command: Make Directory

Page 38: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.14 Make Directory$ mkdir saturnGp$ ls -ld saturnGpdrwxr-xr-x 2 gilberg staff 512 May 19 14:03 saturnGp------------------------------------------------------------

Session 3.15 Make Directory in Path$ mkdir -p saturnGp/memos/schedule$ ls -lR saturnGptotal 1drwxrwxr-x 3 gilberg staff 512 May 19 14:17 memos

saturnGp/memos:total 1drwxrwxr-x 2 gilberg staff 512 May 19 14:17 schedule

saturnGp/memos/schedule:total 0

$ mkdir –m 755

Page 39: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-18The cd Command : Change Directory현 작업 디렉토리의 변경

$

Page 40: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.16 Change Directory$ pwd/usr/~gilberg$ cd saturnGp$ pwd/usr/~gilberg/saturnGp------------------------------------------------------------Session 3.17 Change Directory with Home Reference$ cd ~/saturnGp/memos/schedule$ pwd/usr/~gilberg/saturnGp/memos/schedule

Page 41: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-19The rmdir Command: Remove Directory

When a directory is no longer needed, it should be removed. The remove(rmdir) command deletes directories.

Page 42: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.18 Remove Directory( 디렉토리 삭제 )$ rmdir memosmemos: Directory not empty

$ rmdir memo // p. 108 $ rm –r$ _

The rmdir command cannot delete a directory unless it is empty. If it contains any files, UNIX will return an error message. Note that when the command is executed successfully, the only response is the shell prompt.

Page 43: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-20

3.7 파일 관련 명령어

• Create 파일 만들기

cat, vi, etc

• Edit 파일 편집하기

vi, sed, etc

• Display 파일 보기

more

• Print 파일 출력하기

lpr

Page 44: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

$ cat > heart --> store keyboard input into a file called “heart”.

I hear her breathing,

I’m surrounded by the sound.

Floating in this secret place,

I never shall be found.

^D --> tell cat that the end of input has been reached.

$ _

명령어 ‘ cat’ 을 이용한 파일 만들기

Page 45: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-21The more Command

Page 46: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

• After each page is displayed, more displays the message “--more--” to indicate that it’s waiting for a command.

• To list the next page, press the space bar. • To list the next line, press the Enter key. • To quit from more, press the “q” key.• ^B will display the previous page• H will display help page

• Try:$ ls –la /usr/bin > myLongFile$ more myLongFile$ more /usr/dict/words$ more +10 /usr/dict/words

Page 47: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-22

3.8 디렉토리 , 파일 공통 명령어

Page 48: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-23

The cp Command: Copy 복사하기

Page 49: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

• 성공적인 파일 복사를 위한 규칙 (p.94) 1. The source must exist. 2. destination path(omit) default: 현 디렉토리 3. destination(not exist) created 새로 생성 (exist) replaced 대치 4. source 가 multiple or dir destination : 디렉토리 ex) $ cp file1 file2 Test 5. destination 이 source 와 같은 디렉토리이면 destination

파일이름은 달라야 한다 . ( $ cp a a // error) 6. –i option // interactive 7. –p option // preserve permission & access time

source destination

Page 50: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-24Simple File Copy

Page 51: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.21. SESSION 3.1 Copy File to Same Directory$ ls -l f*-rw-r--r-- 1 gilberg staff 120 May 25 15:10 file1

$ cp file1 file2$ ls -l f*-rw-r--r-- 1 gilberg staff 120 May 25 15:10 file1-rw-r--r-- 1 gilberg staff 120 May 25 17:02 file2------------------------------------------------------------Session 3.22 Copy and Replace File$ ls -l f*-rw-r--r-- 1 gilberg staff 120 May 25 15:10 file1-rw-r--r-- 1 gilberg staff 120 May 25 17:02 file2

$ cp file1 file2$ ls -l f*-rw-r--r-- 1 gilberg staff 120 May 25 15:10 file1-rw-r--r-- 1 gilberg staff 120 May 25 17:08 file2------------------------------------------------------------

Page 52: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-25Copy File to A Directory From Home

Page 53: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.23. Copy File to a Directory from Home

$ ls -l DirB

total 0

$ cp DirA/file1 DirB

$ ls -l DirB

total 1

-rw-r--r-- 1 gilberg staff 120 May 27 10:38 file1

------------------------------------------------------------

Page 54: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-26Copy and Rename File

Page 55: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.24 Copy File to Different Directory

$ ls -l ~/DirB

total 0

$ cp file1 ~/DirB/file2

$ ls -l ~/DirB

total 1

-rw-r--r-- 1 gilberg staff 120 May 27 10:46 file2

Page 56: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.25 Preserve Attributes Option$ ls -ltotal 2-rw-r--r-- 1 gilberg staff 120 May 25 15:46 file1-rw------- 1 gilberg staff 120 May 27 11:03 file2

$ cp -p file1 file2

$ ls -ltotal 2-rw-r--r-- 1 gilberg staff 120 May 25 15:46 file1-rw-r--r-- 1 gilberg staff 120 May 25 15:46 file2------------------------------------------------------------Session 3.26 Interactive Option$ cp -i file1 file2UX:cp: overwrite file2? (yes/no)[no] : yepUX:cp: overwrite file2? (yes/no)[no] : y

Page 57: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-27Recursive CopyDirB 가 없는 경우

Page 58: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.27 Example of Recursive Copy$ lsDirA$ ls DirBCannot access DirB: No such file or directory$ cp -r DirA DirB

$ lsDirA DirB

$ ls DirBfile1 file2

Page 59: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-28Recursive Copy with SubdirectoriesDirD 가 이미 존재하는 경우

Page 60: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.28 Recursive Copy with Subdirectories$ ls -R DirCDirC1 DirC2DirC/DirC1:file3DirC/DirC2:file4$ ls -R DirD$$ cp -r DirC DirD$ ls -R DirDDirDDirD/DirC:DirC1 DirC2DirD/DirC/DirC1:file3DirD/DirC/DirC2:file4

Page 61: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-29

Wildcard Copies

Page 62: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.29 Wildcard Copy

$ ls DirB

$

$ cp DirA/f* DirB

$ ls DirB

file1 file2

--------------------------------------------------------

Page 63: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-30

The mv Command : Move파일 이동 & 이름 변경

Page 64: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-31

파일 이동 : Move File

Page 65: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.30 Move File$ ls -i DirA/file179915 DirA/file1$ ls -i DirB$$ mv DirA/file1 DirB$ ls -i DirA$$ ls -i DirB79915 file1------------------------------------------------------------Session 3.31 Using the Interactive Flag to Prevent Move Errors$ ls mvDirfile1 gilbergfile3

$ mv -i file1 mvDiroverwrite mvDir/file1? (yes/no)[no] : n

Page 66: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.32 Force Replacement with Move Command$ ls -l mvDirtotal 2-rw-r--r-- 1 gilberg staff 120 Sep 19 11:40 file1-rw-r--r-- 1 gilberg staff 120 Sep 19 11:40 file3$ mv -f file1 mvDir$ ls -l mvDirtotal 2-rw-r--r-- 1 gilberg staff 120 Oct 28 16:06 file1-rw-r--r-- 1 gilberg staff 120 Sep 19 11:40 file3------------------------------------------------------------Session 3.33 A Simple Move (Rename: 이름 변경 )$ ls -i file*79914 file1 79937 file2

$ mv file1 file0

$ ls -i file*79914 file0 79937 file2

Page 67: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-32The ln Command: Link

Page 68: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

• 링크 (link): 심볼릭 링크와 하드 링크– 파일에 대한 포인터 . 포인터는 파일명을 디스크상의 위치와 연관시킴– 링크를 생성하는 것은 원하는 정보가 위치한 디스크 상의 장소를

가리키는 포인터를 생성하는 것– 심볼릭 링크

• 파일 ( 혹은 디렉토리 ) 의 내용이 아니라 해당 파일 ( 혹은 디렉토리 )의 포인터를 포함하고 있는 파일 ( 혹은 디렉토리 ) 을 의미

• 한 프로그램에 대해 여러 개의 다른 이름을 가지거나 , 여러 사람이 하나의 복사본을 공유하는데 유용

• 링크된 파일의 경로에 대한 정보만을 가짐 . 따라서 링크를 제거한다 해도 원본 파일에는 영향이 없음

– 하드 링크• 파일의 실제 내용 (inode) 에 대한 정보를 공유하기 때문에 링크를

생성하면 링크의 개수가 증가 ( 심볼릭 링크는 링크의 수가 증가하지 않는다 ).

• 따라서 링크를 삭제하면 링크 수가 1 이 될 때까지는 원본 파일이 삭제되지 않지만 링크 수가 0 이 되면 실제 원본 파일도 삭제

• 특히 하드 링크는 디렉토리를 링크할 수 없음

링크 만들기 (1/5)

Page 69: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

• 여러 사람이 하나의 과제를 수행하면서 정보를 공유하고자 할 때 파일 혹은 디렉토리를 공유하는 것은 매우 유용

• 파일에 대한 링크를 생성함으로써 다른 사용자의 접근 용이명령 구조 : ln -s [ 원본파일 ][ 링크명 ] : 심볼릭 링크 생성 ln [ 원본파일 ][ 링크명 ] : 하드 링크 생성

• ln 을 통하여 어떤 파일을 공유하고자 한다면 먼저 그 파일에 대한 접근권한 ( 읽기 , 쓰기 , 실행 ) 을 변경–chmod 명령을 사용–일단 접근권한이 적절하게 설정되면 이제 링크 생성 가능

링크 만들기 (2/5)

Page 70: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

[ce]home1 4 > ln /usr/include/stdio.h stdio.hln: stdio.h´Â ´Ù¸¥ ÆÄÀϽýºÅÛ¿¡ ÀÖÀ½[ce]home1 5 >

하드 링크를 생성하려고 하였으나home1 usr 과 이 다른 파일 시스템에

!있기 때문에 링크 생성 실패

!수퍼 유저로 로그인

!심볼릭 링크 사용

gildong !으로 로그인

[ce:/home1/gildong]% ln -s /usr/include/stdio.h stdio.h[ce:/home1/gildong]% ls -al stdio.hlrwxrwxrwx 1 gildong student 20 11¿ù 27ÀÏ 20:14 stdio.h -> /usr/include/stdio.h[ce:/home1/gildong]% ls -Flogfile2 public_html/ result1 result2 result3 stdio.h@unix2/[ce:/home1/gildong]% ls -lL stdio.h-rw-r--r-- 1 2 bin 11868 1996³â 5¿ù 3ÀÏ stdio.h[ce:/home1/gildong]%

@ 가 심볼릭 링크를.의미한다

!링크 자체 보기

링크 만들기 (3/5)

Page 71: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

• 심볼릭 링크를 유용하게 사용할 수 있는 다른 경우– 심볼릭 링크를 다른 파일 혹은 디렉토리에 새로운 패스를

생성하는데 사용 가능– 예를 들어 , 한 사용자 그룹이 그 동안 chkmag 이라는 명령에

익숙해져 있는데 그 명령을 다시 작성하여 chkit 이라는 이름으로 변경하였다면 이제 chkit 이라는 이름으로 사용해야 함 . 따라서 사용자들이 여전히 chkmag 이라는 이름을 사용할 수 있도록 다음처럼 심볼릭 링크를 연결해 놓으면 유용

– chkmag 에 대한 접근권한이 모두에게 오픈되어 있음• 그러나 이것은 chkmag 을 수행할 때 연결된 chkit 의

접근권한 특성이 적용되기 때문에 전혀 걱정하지 않아도 된다 .

[ce:/home1/gildong]% ln -s chkit chkmag[ce:/home1/gildong]% ls -al . . . 112 -rwxr-x--- 1 gildong student 56401 10¿ù 23ÀÏ 18:40 chkit 2 lrwxrwxrwx 1 gildong student 5 10¿ù 23ÀÏ 18:40 chkmag -> chkit

. . .

[ce:/home1/gildong]%

링크 만들기 (4/5)

Page 72: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

• 하드 링크– 오로지 같은 파일 시스템 상에서 파일에 대해서만 수행 가능– 디렉토리에 대해서는 수행 불가 ( 슈퍼유저는 가능 )– 기존 파일과 같은 inode 를 가리키는 새로운 항목을 생성– 링크된 파일은 하드 링크가 생성되기 전에 존재해야 함 . 또한

링크된 파일은 모든 하드 링크가 제거되기 전까지는 삭제되지 않음

– 두 파일이 같은 inode 번호 (203335) 를 가짐

[ce:/home1/gildong]% ln chkit chkmag[ce:/home1/gildong]% ls -il chkit chkmag203335 -rwxr-x--- 2 gildong student 56401 10¿ù 23ÀÏ 18:40 chkit203335 -rwxr-x--- 2 gildong student 56401 10¿ù 23ÀÏ 18:40 chkmag[ce:/home1/gildong]%

링크 만들기 (5/5)

Page 73: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.39 Symbolic Link to Directory$ ls -il DirC # From parent, List DirCtotal 279917 drwxr-xr-x 2 gilberg staff 512 Aug 29 12:03 DirC179961 drwxr-xr-x 2 gilberg staff 512 May 27 11:40 DirC2

$ ln DirC1 hardDir # Try to create a hard link to directoryCannot link directory DirC1 # Fails--Cannot create hard link$ ls symDir # Verify that there's no symDirCannot access symDir: No such file or directory$ ln -s DirC symDir # Create symbolic link for symDir$ # We have now created a symbolic directory as verified by inodes$ ls -il symDir # Show symDir is symbolic link to DirC79914 lrwxr-xr-x 1 gilberg staff 4 Sep 18 21:53 symDir -> DirC$ cd symDir # Move to newly created symDir$ ls -il # Verify its contents same as DirCtotal 279917 drwxr-xr-x 2 gilberg staff 512 Aug 29 12:03 DirC179961 drwxr-xr-x 2 gilberg staff 512 May 27 11:40 DirC2

Page 74: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Inode 블럭

Data 블럭

Inode1

Inode2

원본파일데이타

원본파일포인터

원본 파일

하드링크 파일

심볼릭 링크 파일

디렉토리

원본 복사파일 Inode3 복사파일데이타

Page 75: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-33The rm Command:Remove

Page 76: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.41 Recursive Removal$ ls -Rl delRecDirtotal 4drwxr-xr-x 2 gilberg staff 512 May 29 11:44 DirAdrwxr-xr-x 2 gilberg staff 512 May 29 11:44 DirBdrwxr-xr-x 2 gilberg staff 512 May 29 11:44 emptyDir-r--r--r-- 1 gilberg staff 120 May 29 11:44 file1

delRecDir/DirA:total 2-rw-r--r-- 1 gilberg staff 120 May 29 11:44 file2-rw-r--r-- 1 gilberg staff 120 May 29 11:44 file3

delRecDir/DirB:total 2-rw-r--r-- 1 gilberg staff 120 May 29 11:44 file4-rw-r--r-- 1 gilberg staff 120 May 29 11:44 file5delRecDir/emptyDir:

delRecDir/emptyDir:total 0

$ rm -r delRecDirdelRecDir/file1: 444 mode. Remove ? (yes/no)[no] : y

$ ls delRecDirCannot access delRecDir: No such file or directory

Page 77: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.42 Using echo to Preview Effects of Remove

$ echo rm -r f* // 사용전 삭제 목록 확인rm -r file1 file2 file2.bak file2.sym

$ rm -r file2.bak file2.sym

Page 78: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Figure 3-34

The find Command파일 찾기

Page 79: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Finding Files: find

Page 80: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Finding Files: find

Page 81: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

파일 찾기 : find

Here are some examples of find in action:

$ find . -name ‘*.c’ -print --> print C source files --> in the current directory or --> any of its subdirectories.

./proj/fall.89/play.c

./proj/fall.89/rerefee.c

./proj/fall.89/player.c

./rock/guess.c

./rock/play.c

./rock/player.c

./rock/referee.c $ find . -mtime -14 –ls --> list modified files during the last 14 days…$ find . -name ‘*.txt’ -print --> find all text files in the current directory…

$ find startingDir searchOptions commandToPerform

Page 82: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

find 명령어를 사용하여 파일 찾기

•To locate a file in the directory treelocate a file in the directory tree, use the find command based on specific criteria, such as file name, size, owner, modification time, or type

•The find command recursively descendsrecursively descends the directory tree in the path name list

•As find locates the files that match those values, the path to each file is displayed on the screen

Page 83: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

• 명령어 형식$ find path(s) expression(s) action(s)

• path(s)- 탐색을 시작하는 경로명- 와일드 카드 포함가능 *, ?, [ ].• expression(s)- 파일을 찾을 때 사용하는 탐색 기준 .-The first argument that starts with a -, or is a ! or a (, and all subsequent arguments.

• action(s)-찾은 파일에 대해 취할 동작 .

Page 84: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

•Where expressions-name filename •Find files with the given filename . •The most commonly used operator.•filename may include wildcards, but if it does, it must be must be quotedquoted to prevent the shell from interpreting the wildcards.

-name abc-name ’a*’-name ”[ab]*”

$ find path(s) expression(s) action(s)

파일이름으로 찾기

Page 85: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

•Where expressions-size [±]n[c]•n[c] says “find files that are exactlyexactly n blocks (characters) long.”•+n[c] says “find files that are overover n  blocks (characters) long.“•-n[c] says “find files that are less thanless than n  blocks (characters) long.“•A block equals 512 bytes512 bytes.-size 20-size 20c

$ find path(s) expression(s) action(s)

파일크기로 찾기

Page 86: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

•Where expressions-mtime [±]n•n means “find files that the file’s contents were modified exactlyexactly n days ago.”•+n means “find files that the file’s contents were modified overover n days ago.” •-n means “find files that the file’s contents were modified less thanless than n days ago.“

-mtime 5-mtime +5-mtime -5

$ find path(s) expression(s) action(s)

파일 찾기 :수정시간

Page 87: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

•Where expressions-atime [±]n•n means “find files that the file’s contents were accessed exactlyexactly n days ago.”•+n means “find files that the file’s contents were accessed overover n days ago.” •-n means “find files that the file’s contents were accessed less thanless than n days ago.“

-atime 5 // $ ls -lu-atime +5-atime -5

$ find path(s) expression(s) action(s)

파일찾기 : 접근시간

Page 88: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

•Where expressions-newer file•Find files that have been modified more recentlyrecently than the given file.

-newer /etc/mail/aliases-inum n•Find files with the inodeinode number n.-inum 13872 // $ ls -li

$ find path(s) expression(s) action(s)

파일찾기 : 수정시간

파일찾기 : inode

Page 89: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

•Where expressions-user name•Find files belonging to useruser name.•name may also be a user ID number.-user root-user 0

-group name•Find files belonging to groupgroup name.•name may also be a group ID number.-group sysadmin-group 14

$ find path(s) expression(s) action(s)

파일찾기 : 소유자 ,

그룹

Page 90: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

•Where expressionsexpressions1 -a expressions2•Find files that match bothboth expressions1 and expressions2.•The -a isn’t necessary (default)$ find / -atime -3 –a –type f –a –size +4$ find / -atime -3 –type f –size +4

expressions1 -o expressions2•Find files that match eithereither expressions1 or expressions2.

$ find / -atime -3 –o type f –o –size +4

$ find path(s) expression(s) action(s)

Page 91: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

•Where expressions! Expressions // not•Finds all files that do notnot match the given expressions.•The ! performs a logical NOT operation.$ find / -atime -3 –o ! –type d –o –size +4

\( expressions \)•Logical precedenceprecedence.•In a complex expression, evaluates this part of the expressions before the rest.

$ find / -type f –a \( -size 10 –o –atime +19 \)

$ find path(s) expression(s) action(s)

Page 92: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

•Where actions– To include the pathname of the file that’s just been

found in command, use the special symbol { }.– command must end with a ;.-exec command•Executes command.

-ok command•The interactive version of –exec.

$ find / -size 0 –exec rm –i {} \;$ find / -name ’*.swp’ –ok mv {} /tmp ’;’

$ find path(s) expression(s) action(s)

-exec Command {} \;

Page 93: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.43 find Address of File (p. 108)

$ find DirC –name file3 –print

DirC/DirC1/file3

Session 3.44 find command // monthly backup

$ find DirC –type f –mtime -30 No ActionFind & Print

Page 94: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session 3.45 Find and Backup (p. 109)$ ls backUpDir$$ find DirC -type f -mtime -30DirC/file1DirC/DirC1/file2DirC/DirC2/file3$ find DirC -type f -mtime -30 -exec cp {} backUpDir \;$ ls backUpDirfile1 file2 file3

------------------------------------------------------------Session 3.46 Find and Backup with Okay$ ls mvDir$$ find DirC -type f -mtime -30 -ok cp {} mvDir \;< cp ... DirC/file1 >? y< cp ... DirC/DirC1/file2 >? n< cp ... DirC/DirC2/file3 >? y$ ls mvDirfile1 file3

Page 95: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

•Where actions-print•Prints the file’s name on standard output.

-ls•Prints the current path name, together with its associated statistics, such as inode number, size in kilobytes, protection mode, number of hard links, and user

$ find / -ctime 5 –inum 1947 -ls

Page 96: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Practice Set (P. 115)

• Exercise

47. Which of the following would be a good file (or directory) name in UNIX?

48. Which of the following would be a good file (or directory) name in UNIX?

49. Write a pattern for each line that refers to all files in the line.

a) file1, file2, file3, …, file9 file[1-9]

Page 97: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

50. You have the following files in your home directory:

file1 file2 file33 file4 f5 f6 f7 NFile1 Nfile2 Nfile441 file1a file2a file2b

Which of them would be selected by each of the following patterns?

a) file? file1 file2 file4 b) file?? c) file* d) Nfile? e) … i)

Page 98: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

51. Which of the following is an absolute pathname? 다음 중 절대 경로는 ?

a. / e. ..

b. /binf. ~

c. jack g. /bin/c

d. ./bin?

52. Which of the following is a relative pathname? 다음 중 상대 경로는 ?

a. ../bin c. jack/letter

b. /bind. /dev/jack/lett

Page 99: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

53. Show how to use the relative pathname to refer to your home directory.

54. Show how to use the relative pathname to refer to the home directory of john(user name is john).

Page 100: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Lab SessionsSession I1. Log into the system2. Create 3 directories named letters, reports, and assignments under your

home directory.3. Move to directory letters.4. Create 2 directories named friendly and formal under the letters directory.5. Move to directory reports using only one command (directly from letters).6. Create 3 directories named personal, business, and school under the

directory reports using only one command.7. Create a directory called UNIX under the assignments directory without

moving from the reports directory.8. Create 2 directories called HWs and Projects under the directory UNIX.

The directories in this step should be created without moving from the reports directory.

9. Move to your home directory.10. Recursively list all of the directories you created under your home

directory using “ls” command.

Page 101: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Home directory ~kykim

letters reports assignments

friendly formal personal business school UNIX

HWs Projects

Page 102: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session II

1. Log into the system2. Recursively list all of the directories you created under your

home directory using “ls” command.3. Move to HWs directory.4. Check your current directory.5. Using vi command, create a file named hw4 that contains

answer to exercise 49(P.117).6. Save the file (it should be saved under the HWs directory)7. Move to your home directory.8. Show the content of hw4 file from your home directory.9. Make a copy of hw4 and call it hw4.bk. Store it under the

same directory where hw4 is stored.10. From you home directory check to see if both files (hw4 and

hw4.bk) exist.

Page 103: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Home directory ~kykim

letters reports assignments

friendly formal personal business school UNIX

HWs Projects

hw4 hw4.bk hw4HL hw4SL

Page 104: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

11. Move to HWs directory.12. Check your current working directory.13. Make a hard link to the hw4 file. The link should be under the

HWs directory and be called hw4HL.14. Make a soft link to the hw4 called hw4SL and store it under

the HWs directory. 15. Check the inode of hw4, hw4.bk, hw4HL, and hw4SL. Are

all the same? Are all different? Explain how you determined the answer.

16. Use the “ls” command to find the file types of hw4, hw4.bk, hw4HL, and hw4SL. Explain your observation.

17. Log out the system.

Page 105: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Session III

1. Log into the system2. Create a backup directory in your home directory called

backups.3. Use the find command to find the pathnames of all of the

files(hw4, hw4.bk, hw4HL, and hw4SL)that you created in Session II. All of them should be found using only one find command. The command must also copy all of them to the backups directory.

4. Check the number of links and inode number of hw4, hw4.bk, hw4HL, and hw4SL. Make note of the results.

5. Delete the original hw4 file without moving from your home directory.

6. Check the existence of hw4, hw4.bk, hw4HL, and hw4SL. 7. Check the contents of hw4, hw4.bk, hw4HL, and hw4SL.

Page 106: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

8. Restore the file hw4 by making a copy of hw4.bk9. You may have noticed that your soft link (hw4SL) contains

garbage. Delete this file.10. Make a new soft link to hw4 and store it as hw4SL under the

same directory as it was.11. List recursively all of your files and directories to confirm all

operations using “ls” command.

Page 107: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

Home directory ~kykim

letters reports assignments

friendly formal personal business school UNIX

HWs Projects

backups

hw4 hw4.bk hw4HL hw4SL

… … … …

Page 108: ©Brooks/Cole, 2001 Chapter 3 File Systems 파일 시스템 ) ( 파일 시스템 )

©Brooks/Cole, 2001

수고 하셨습니다 !!!!!!!!!!!!Mail to kky!!!!!!!!!!!!!!!!!!!!!!!!