본문 바로가기

CentOS/Study

[실습]혼자해보기 - 하드 링크와 심볼릭 링크

반응형

1. /etc/hosts 파일을 복사하여 work 파일 생성

[root@linux1 ch2]# cp /etc/hosts work
[root@linux1 ch2]# ll
합계 4
-rw-r--r--. 1 root root   0  9월 13 12:19 data1.cp
-rw-r--r--. 1 root root   0  9월 12 21:02 data1.ln
lrwxrwxrwx. 1 root root   5  9월 13 12:28 data1.sl -> data1
drwxr-xr-x. 2 root root  74  9월 12 21:08 temp
-rw-r--r--. 1 root root 186  9월 13 13:03 work
[root@linux1 ch2]# 

 

2. work 파일의 하드 링크로 work.ln 생성

[root@linux1 ch2]# ln work work.ln
[root@linux1 ch2]# ll
합계 8
-rw-r--r--. 1 root root   0  9월 13 12:19 data1.cp
-rw-r--r--. 1 root root   0  9월 12 21:02 data1.ln
lrwxrwxrwx. 1 root root   5  9월 13 12:28 data1.sl -> data1
drwxr-xr-x. 2 root root  74  9월 12 21:08 temp
-rw-r--r--. 2 root root 186  9월 13 13:03 work
-rw-r--r--. 2 root root 186  9월 13 13:03 work.ln
[root@linux1 ch2]# 

 

3. work 파일의 심볼릭 링크로 work.sl 생성

[root@linux1 ch2]# ln -s work.ln work.sl
[root@linux1 ch2]# ls -l work.sl
lrwxrwxrwx. 1 root root 7  9월 13 13:10 work.sl -> work.ln
[root@linux1 ch2]# 

 

4. work 파일을 복사하여 work.cp 생성

[root@linux1 ch2]# cp work work.cp
[root@linux1 ch2]# ll
합계 12
-rw-r--r--. 1 root root   0  9월 13 12:19 data1.cp
-rw-r--r--. 1 root root   0  9월 12 21:02 data1.ln
lrwxrwxrwx. 1 root root   5  9월 13 12:28 data1.sl -> data1
drwxr-xr-x. 2 root root  74  9월 12 21:08 temp
-rw-r--r--. 2 root root 186  9월 13 13:03 work
-rw-r--r--. 1 root root 186  9월 13 13:11 work.cp
-rw-r--r--. 2 root root 186  9월 13 13:03 work.ln
lrwxrwxrwx. 1 root root   7  9월 13 13:10 work.sl -> work.ln
[root@linux1 ch2]# 

 

5. work.sl 파일에 마지막 행 삭제

[root@linux1 ch2]# cat work.sl
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.25.3.11	www.example.com
[root@linux1 ch2]# cat work.sl | sed '$d'
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@linux1 ch2]#

 

6. work, work.ln, work.sl, work.cp 파일 내용 확인

[root@linux1 ch2]# cat work
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.25.3.11	www.example.com
[root@linux1 ch2]# cat work.ln
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.25.3.11	www.example.com
[root@linux1 ch2]# cat work.sl
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.25.3.11	www.example.com
[root@linux1 ch2]# cat work.cp
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.25.3.11	www.example.com
[root@linux1 ch2]# 

 

7. work, work.ln, work.sl, work.cp 파일을 삭제

[root@linux1 ch2]# rm -rvf work work.ln work.sl work.cp
removed 'work'
removed 'work.ln'
removed 'work.sl'
removed 'work.cp'
[root@linux1 ch2]# ls -i
18111956 data1.cp  18124025 data1.ln  18111957 data1.sl  18111947 temp
[root@linux1 ch2]# 

 

페도라 리눅스
국내도서
저자 : 이종원
출판 : 한빛아카데미 2017.11.10
상세보기
반응형