티스토리 뷰
ln 명령어
📌 특정 파일의 하드/소프트(심볼릭) 링크를 생성하는 명령어
- TargetFile 매개변수에 지정된 파일이나 TargetDirectory 매개변수에 지정된 다른 디렉토리의 동일한 파일 이름과 링크한다.
- 기본적으로 하드 링크를 한다.
- '-s' 옵션을 통해 소프트 링크를 생성한다.
옵션
$ ln [옵션][디렉토리/파일]
명령어 | 설명 | 명령어 | 설명 |
-s (—Symbolic) |
심볼릭 링크를 생성 | -S (—suffix) |
백업 파일 생성시 원하는 접미사(확장자) 지정 |
-v (—verbose) |
링크 생성 정보 자세히 출력 | -b (—backup) |
대상 파일이 존재할 경우 백업 파일을 만들고 링크 파일 생성 |
-f (—force) |
링크 파일 존재 시, 삭제 후 생성 | -i (—interactive) |
대상 파일 존재 시, 대상 파일을 지울지 확인 |
소프트 링크 목표 경로 변경
# 특정 소프트링크의 목표 경로 변경
$ ln -nfs [목표 파일/디렉토리] [변경할 링크]
[root@localhost Test]# ls -lia
51412335 drwxr-xr-x. 3 root root 146 Oct 17 17:27 .
33574977 dr-xr-x---. 7 root root 4096 Oct 17 14:35 ..
51412353 lrwxrwxrwx. 1 root root 8 Oct 17 16:25 NewSofLink2 -> Tuesday2
51412348 lrwxrwxrwx. 1 root root 7 Oct 17 16:23 NewText2Link -> Tuesday
51412358 -rw-r--r--. 1 root root 202 Oct 17 17:27 Tuesday
51412350 -rw-r--r--. 1 root root 35 Oct 17 16:23 Tuesday2
[root@localhost Test]# ln -nfs Tuesday2 NewText2Link
[root@localhost Test]# ls -lia
51412335 drwxr-xr-x. 3 root root 146 Oct 17 17:53 .
33574977 dr-xr-x---. 7 root root 4096 Oct 17 14:35 ..
51412353 lrwxrwxrwx. 1 root root 8 Oct 17 16:25 NewSofLink2 -> Tuesday2
51412348 lrwxrwxrwx. 1 root root 8 Oct 17 17:53 NewText2Link -> Tuesday2
51412358 -rw-r--r--. 1 root root 202 Oct 17 17:27 Tuesday
51412350 -rw-r--r--. 1 root root 35 Oct 17 16:23 Tuesday2
'Computer > Linux' 카테고리의 다른 글
[Linux] 사용자 및 그룹 관리 (1) | 2023.10.31 |
---|---|
[Linux] cat 명령어 (0) | 2023.10.17 |
[Linux] touch 명령어 (1) | 2023.10.17 |
[Linux] 쉘 (Shell) 01 (0) | 2023.09.22 |
[Linux] 입출력 재지정 (IO Redirection) - 입력 재지정 (0) | 2023.09.20 |