본문 바로가기
보안과정/참고

ln 명령어

by Luuii 2017. 11. 29.

NAME

       ln - make links between files


 SYNOPSIS

       ln [OPTION]... [-T] TARGET LINK_NAME   (1st form)

       ln [OPTION]... TARGET                  (2nd form)

       ln [OPTION]... TARGET... DIRECTORY     (3rd form)

       ln [OPTION]... -t DIRECTORY TARGET...  (4th form)


 DESCRIPTION

       In the 1st form, create a link to TARGET with the name LINK_NAME.  In the 2nd form,

       create a link to TARGET in the current directory.  In the 3rd and 4th forms, create

       links  to  each  TARGET in DIRECTORY.  Create hard links by default, symbolic links

       with --symbolic.  When creating hard links, each TARGET must exist.


○ 파일의 종류

1. 일반파일

2. 디렉토리 파일

3. 링크파일

>> 하드링크 파일

>> 심볼릭 링크 파일

4. 디바이스 파일

>> 블럭 디바이스 파일

>> 캐릭터 디바이스 파일

5. 파이프 파일

6. 소켓 파일

7. 도어 파일


○ 하드링크에 대한 기본 체계

# ls -l file1

-rw-r-r- 1(하드링크수) root root 6  11월 28일 18:26 file1


○ 하드링크

> 파일에 대한 하드링크 수는 '1'이 기본 값이다.

> 디렉토리에 대한 하드링크 수는 '2'가 기본값이다.

>> 디렉토리 안에 들어 있는 디렉토리 개수

> 디렉토리에 링크를 걸 수 있다.


# echo "hello" > file1

# ls -l file1

-rw-r--r-- 1 root root 6 Nov 30 02:55 file1


ln 명령어 사용법


ln CMD

(하드 링크) # ln file1 file2

(심볼릭 링크) # ln -s file1 file2


(하드링크)

# echo 1111 > file1

# ls-l file1


# ln file1 file2

# ls -l file*

# echo 2222 >> file1

# cat file2


# rm file1

# cat file2


# ls -l file2


(심볼릭링크)

# ln -s file2 file3

# ls -l file*


# ls -li file*

# echo 3333 >> file3

# cat file2


# rm file2

# cat file3


○ 심볼릭 링크의 예제

심볼릭 링크 -> 바탕화면 바로가기 아이콘(ex: 한글.lnk)


○ 하드링크 & 심볼릭 링크의 비교

파일 시스템을 넘어서 링크를 걸 때

디렉토리에 링크 걸때 


○ 기본의 존제파일에 대해 링크를 거는 경우의 에러 메시지

# echo 1111 > file1

# echo 2222> file2

# ls file *

# ln -s file1 file2

>> file2 가 미리 있으면 링크가 걸리지 않는다.

>> 레이스 컨디션 어택을 진행하다보면 이런 에러가 많이 나온다.













































































반응형

'보안과정 > 참고' 카테고리의 다른 글

아스키 코드표  (0) 2017.11.29
SIGNAL에 대하여  (0) 2017.11.29
nc(netcat)명령어 사용법  (0) 2017.11.28
xinetd 방식에 대하여  (0) 2017.11.28
dig/host/nslookup  (0) 2017.11.28