"리눅스 심볼릭링크 생성 실습"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(사용자 2명의 중간 판 17개는 보이지 않습니다)
2번째 줄: 2번째 줄:
;Creates a symbolic link
;Creates a symbolic link
;리눅스 심볼릭 링크 설정
;리눅스 심볼릭 링크 설정
;리눅스 심볼릭 링크 생성
;리눅스 심볼릭 링크 생성 실습


==명령어==
==명령어==
<source lang='bash'>
<syntaxhighlight lang='bash'>
ln -s 원본파일 링크파일
ln -s 원본 링크파일
</source>
</syntaxhighlight>
:→ 원본은 파일, 디렉토리 모두 가능


==실습==
==실습==
/test.txt 파일을 만들고 그에 대한 심볼릭 링크 파일 /tmp/s_link.txt를 만들어보자.
/test.txt 파일을 만들고 그에 대한 심볼릭 링크 파일 /tmp/s_link.txt를 만들어보자.
*원본 파일 확인
*원본 파일 확인
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@CentOS ~]# echo hello > /test.txt
[root@CentOS ~]# echo hello > /test.txt
[root@CentOS ~]# cat /test.txt
[root@CentOS ~]# cat /test.txt
18번째 줄: 19번째 줄:
[root@CentOS ~]# ll /test.txt
[root@CentOS ~]# ll /test.txt
-rw-r--r-- 1 root root 6 Jun 19 21:44 /test.txt
-rw-r--r-- 1 root root 6 Jun 19 21:44 /test.txt
</source>
</syntaxhighlight>


*심볼릭 링크 설정 및 확인
*심볼릭 링크 설정 및 확인
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@CentOS ~]# ln -s /test.txt /tmp/s_link.txt
[root@CentOS ~]# ln -s /test.txt /tmp/s_link.txt
[root@CentOS ~]# ll /tmp/s_link.txt  
[root@CentOS ~]# ll /tmp/s_link.txt  
27번째 줄: 28번째 줄:
[root@CentOS ~]# cat /tmp/s_link.txt  
[root@CentOS ~]# cat /tmp/s_link.txt  
hello
hello
</source>
</syntaxhighlight>


==하드 링크와 차이==
==하드 링크와 차이==
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@CentOS ~]# ln /test.txt /tmp/h_link.txt
[root@CentOS ~]# ln /test.txt /tmp/h_link.txt
[root@CentOS ~]# ls -i /test.txt
[root@CentOS ~]# ls -i /test.txt
38번째 줄: 39번째 줄:
[root@CentOS ~]# ls -i /tmp/s_link.txt  
[root@CentOS ~]# ls -i /tmp/s_link.txt  
1962252 /tmp/s_link.txt
1962252 /tmp/s_link.txt
</source>
</syntaxhighlight>
:→ 하드 링크 파일의 inode number는 원본과 같다.
:→ 하드 링크 파일의 inode number는 원본과 같다.
:→ 디스크 상에서 근본적으로 같은 파일이라 할 수 있다.<ref>하드 링크가 된 시점에서는 원본과 사본(?)의 구분도 애매하다. 애초에 원본이라는 것도 그 디스크 상의 실제 파일을 가리키는 하드 링크이기 때문이다. 기존의 하드링크 1개(원본)이 있었고 추가로 1개를 더 생성하여 2개가 되었다는 뜻이다.</ref>
:→ 디스크 상에서 근본적으로 같은 파일이라 할 수 있다.<ref>하드 링크가 된 시점에서는 원본과 사본(?)의 구분도 애매하다. 애초에 원본이라는 것도 그 디스크 상의 실제 파일을 가리키는 하드 링크이기 때문이다. 기존의 하드링크 1개(원본)이 있었고 추가로 1개(사본)를 더 생성하여 2개가 되었다는 뜻이다.</ref>
:→ 반면 심볼릭 링크는 디스크 상에서 다른 파일이며 그야말로 바로가기 파일일뿐이다.
:→ 반면 심볼릭 링크는 디스크 상에서 다른 파일이며 그야말로 바로가기 파일일뿐이다.


==원본 삭제 실습==
==원본 삭제 실습==
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@CentOS ~]# rm -f /test.txt
[root@CentOS ~]# rm -f /test.txt
[root@CentOS ~]# ll /tmp/s_link.txt
[root@CentOS ~]# ll /tmp/s_link.txt
50번째 줄: 51번째 줄:
[root@CentOS ~]# cat /tmp/s_link.txt
[root@CentOS ~]# cat /tmp/s_link.txt
cat: /tmp/s_link.txt: No such file or director
cat: /tmp/s_link.txt: No such file or director
</source>
</syntaxhighlight>
:→ /tmp/s_link.txt 은 존재하지만 원본인 /test.txt 파일이 없어서 내용은 볼 수 없다.
:→ /tmp/s_link.txt 은 존재하지만 원본인 /test.txt 파일이 없어서 내용은 볼 수 없다.


==같이 보기==
==같이 보기==
*[[리눅스 심볼릭링크 폴더 생성 실습]]
*[[리눅스 하드링크 생성 실습]]
*[[리눅스 심볼릭 링크 확인]]
*[[리눅스 심볼릭 링크 확인]]
*[[리눅스 심볼릭 링크]]
*[[리눅스 심볼릭 링크]]
*[[윈도우 심볼릭 링크 사용]]
*[[윈도우 심볼릭 링크 생성]]
*[[리눅스 하드 링크 설정]]
*[[리눅스 ln]]


==참고 자료==
==주석==
<references/>
 
==참고==
*http://en.wikipedia.org/wiki/Symbolic_link
*http://en.wikipedia.org/wiki/Symbolic_link


[[분류: 리눅스]]
[[분류: 리눅스]]
[[분류:심볼릭 링크]]

2020년 11월 2일 (월) 00:56 기준 최신판

Creates a symbolic link
리눅스 심볼릭 링크 설정
리눅스 심볼릭 링크 생성 실습

1 명령어[ | ]

ln -s 원본 링크파일
→ 원본은 파일, 디렉토리 모두 가능

2 실습[ | ]

/test.txt 파일을 만들고 그에 대한 심볼릭 링크 파일 /tmp/s_link.txt를 만들어보자.

  • 원본 파일 확인
[root@CentOS ~]# echo hello > /test.txt
[root@CentOS ~]# cat /test.txt
hello
[root@CentOS ~]# ll /test.txt
-rw-r--r-- 1 root root 6 Jun 19 21:44 /test.txt
  • 심볼릭 링크 설정 및 확인
[root@CentOS ~]# ln -s /test.txt /tmp/s_link.txt
[root@CentOS ~]# ll /tmp/s_link.txt 
lrwxrwxrwx 1 root root 9 Jun 19 21:45 /tmp/s_link.txt -> /test.txt
[root@CentOS ~]# cat /tmp/s_link.txt 
hello

3 하드 링크와 차이[ | ]

[root@CentOS ~]# ln /test.txt /tmp/h_link.txt
[root@CentOS ~]# ls -i /test.txt
98116 /test.txt
[root@CentOS ~]# ls -i /tmp/h_link.txt
98116 /tmp/h_link.txt
[root@CentOS ~]# ls -i /tmp/s_link.txt 
1962252 /tmp/s_link.txt
→ 하드 링크 파일의 inode number는 원본과 같다.
→ 디스크 상에서 근본적으로 같은 파일이라 할 수 있다.[1]
→ 반면 심볼릭 링크는 디스크 상에서 다른 파일이며 그야말로 바로가기 파일일뿐이다.

4 원본 삭제 실습[ | ]

[root@CentOS ~]# rm -f /test.txt
[root@CentOS ~]# ll /tmp/s_link.txt
lrwxrwxrwx 1 root root 9 Jun 19 22:11 /tmp/s_link.txt -> /test.txt
[root@CentOS ~]# cat /tmp/s_link.txt
cat: /tmp/s_link.txt: No such file or director
→ /tmp/s_link.txt 은 존재하지만 원본인 /test.txt 파일이 없어서 내용은 볼 수 없다.

5 같이 보기[ | ]

6 주석[ | ]

  1. 하드 링크가 된 시점에서는 원본과 사본(?)의 구분도 애매하다. 애초에 원본이라는 것도 그 디스크 상의 실제 파일을 가리키는 하드 링크이기 때문이다. 기존의 하드링크 1개(원본)이 있었고 추가로 1개(사본)를 더 생성하여 2개가 되었다는 뜻이다.

7 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}