IT 공부내용 정리/Linux

터미널 명령어 - ln 바로가기를 만들고 싶을 때

따뜻한 차가움 2025. 2. 28. 15:08

사용 버전 : Linux 우분투(레드햇 계열) 24.04.01 LTS 버전
사용한 시스템 지역/언어 : 대한민국/한글

man ln 원문

더보기

LN(1)                            User Commands                           LN(1)

NAME
       ln - make links between files

SYNOPSIS
       ln [OPTION]... [-T] TARGET LINK_NAME
       ln [OPTION]... TARGET
       ln [OPTION]... TARGET... DIRECTORY
       ln [OPTION]... -t DIRECTORY TARGET...

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.  By default,
       each destination (name of new link) should  not  already  exist.   When
       creating  hard  links, each TARGET must exist.  Symbolic links can hold
       arbitrary text; if later resolved, a relative link  is  interpreted  in
       relation to its parent directory.

       Mandatory  arguments  to  long  options are mandatory for short options
       too.

       --backup[=CONTROL]
              make a backup of each existing destination file

       -b     like --backup but does not accept an argument

       -d, -F, --directory
              allow the superuser to attempt to hard link  directories  (note:
              will  probably fail due to system restrictions, even for the su‐
              peruser)

       -f, --force
              remove existing destination files

       -i, --interactive
              prompt whether to remove destinations

       -L, --logical
              dereference TARGETs that are symbolic links

       -n, --no-dereference
              treat LINK_NAME as a normal file if it is a symbolic link  to  a
              directory

       -P, --physical
              make hard links directly to symbolic links

       -r, --relative
              with -s, create links relative to link location

       -s, --symbolic
              make symbolic links instead of hard links

       -S, --suffix=SUFFIX
              override the usual backup suffix

       -t, --target-directory=DIRECTORY
              specify the DIRECTORY in which to create the links

       -T, --no-target-directory
              treat LINK_NAME as a normal file always

       -v, --verbose
              print name of each linked file

       --help display this help and exit

       --version
              output version information and exit

       The   backup   suffix   is  '~',  unless  set  with  --suffix  or  SIM‐
       PLE_BACKUP_SUFFIX.  The version control method may be selected via  the
       --backup  option  or  through the VERSION_CONTROL environment variable.
       Here are the values:

       none, off
              never make backups (even if --backup is given)

       numbered, t
              make numbered backups

       existing, nil
              numbered if numbered backups exist, simple otherwise

       simple, never
              always make simple backups

       Using -s ignores -L and -P.  Otherwise, the last option specified  con‐
       trols behavior when a TARGET is a symbolic link, defaulting to -P.

AUTHOR
       Written by Mike Parker and David MacKenzie.

REPORTING BUGS
       GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
       Report any translation bugs to <https://translationproject.org/team/>

COPYRIGHT
       Copyright  ©  2023  Free Software Foundation, Inc.  License GPLv3+: GNU
       GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
       This is free software: you are free  to  change  and  redistribute  it.
       There is NO WARRANTY, to the extent permitted by law.

SEE ALSO
       link(2), symlink(2)

       Full documentation <https://www.gnu.org/software/coreutils/ln>
       or available locally via: info '(coreutils) ln invocation'

GNU coreutils 9.4                 April 2024                             LN(1)

 

man ln 번역기 번역본

더보기

LN(1)      사용자 명령          LN(1)

이름
ln - 파일 간 링크 만들기

요약
ln [옵션]... [-T] TARGET LINK_NAME
ln [옵션]... TARGET
ln [옵션]... TARGET... DIRECTORY
ln [옵션]... -t DIRECTORY TARGET...

설명
첫 번째 형식에서 LINK_NAME이라는 이름으로 TARGET에 대한 링크를 만듭니다.
두 번째 형식에서 현재 디렉토리에 TARGET에 대한 링크를 만듭니다.
세 번째 및 네 번째 형식에서 DIRECTORY에 있는 각 TARGET에 대한 링크를 만듭니다. 기본적으로
하드 링크를 만들고 --symbolic을 사용하여 심볼릭 링크를 만듭니다. 기본적으로
각 대상(새 링크의 이름)은 이미 존재해서는 안 됩니다.
하드 링크를 만들 때 각 TARGET이 있어야 합니다. 심볼릭 링크는
임의의 텍스트를 포함할 수 있습니다. 나중에 해결되면 상대 링크는
부모 디렉토리와 관련하여 해석됩니다.

긴 옵션에 대한 필수 인수는 짧은 옵션에도 필수입니다.

--backup[=CONTROL]
기존 대상 파일의 백업을 만듭니다.

-b는 --backup과 유사하지만 인수를 허용하지 않습니다.

-d, -F, --directory
슈퍼유저가 디렉토리를 하드 링크하도록 허용합니다(참고:
슈퍼유저의 경우에도 시스템 제한으로 인해 실패할 가능성이 높음)

-f, --force
기존 대상 파일 제거

-i, --interactive
대상을 제거할지 묻습니다.

-L, --logical
심볼릭 링크인 TARGET을 역참조합니다.

-n, --no-dereference
디렉토리에 대한 심볼릭 링크인 경우 LINK_NAME을 일반 파일로 처리합니다.

-P, --physical
심볼릭 링크에 직접 하드 링크를 만듭니다.

-r, --relative
-s와 함께 사용하면 링크 위치에 상대적인 링크를 만듭니다.

-s, --symbolic
하드 링크 대신 심볼릭 링크를 만듭니다.

-S, --suffix=SUFFIX
일반적인 백업 접미사를 재정의합니다.

-t, --target-directory=DIRECTORY
링크를 생성할 DIRECTORY 지정

-T, --no-target-directory
LINK_NAME을 항상 일반 파일로 취급

-v, --verbose
각 링크된 파일의 이름 출력

--help 이 도움말을 표시하고 종료

--version
버전 정보를 출력하고 종료

--suffix 또는 SIM‐
PLE_BACKUP_SUFFIX로 설정하지 않는 한 백업 접미사는 '~'입니다. 버전 제어 방법은 --backup 옵션 또는 VERSION_CONTROL 환경 변수를 통해 선택할 수 있습니다.
값은 다음과 같습니다.

none, off
백업을 만들지 않음(--backup이 지정된 경우에도)

numbered, t
번호가 매겨진 백업 만들기

existing, nil
번호가 매겨진 백업이 있으면 numbered, 그렇지 않으면 simple

simple, never
항상 간단한 백업 만들기

-s를 사용하면 -L 및 -P가 무시됩니다. 그렇지 않으면 마지막으로 지정된 옵션은 TARGET이 심볼릭 링크일 때 동작을 제어하며 기본값은 -P입니다.

작성자
Mike Parker와 David MacKenzie가 작성했습니다.

버그 보고
GNU coreutils 온라인 도움말: <https://www.gnu.org/software/coreutils/>
번역 버그는 <https://translationproject.org/team/>에 보고하세요.

저작권
저작권 © 2023 Free Software Foundation, Inc. 라이선스 GPLv3+: GNU
GPL 버전 3 이상 <https://gnu.org/licenses/gpl.html>.
이것은 무료 소프트웨어입니다. 자유롭게 변경하고 재배포할 수 있습니다.
법으로 허용되는 범위 내에서 어떠한 보증도 없습니다.

또한 참조
link(2), symlink(2)

전체 문서 <https://www.gnu.org/software/coreutils/ln>
또는 다음을 통해 로컬에서 사용 가능: info '(coreutils) ln invocation'

GNU coreutils 9.4 2024년 4월 LN(1)

 

형태 : ln [옵션] [원본 dir] [생성 dir]

기능 : 원본 dir에 대한 하드링크를 생성한다.

 

-s : 심볼릭 링크 파일을 생성한다.

 

링크에 대해서는 윈도우와 개념이 다른 부분이 있어 내용을 보완하고자 한다.

1. 리눅스는 파일을 inode 개념으로 관리하고 있으며 각각의 파일, 디렉터리가 고유한 inode를 부여받는다.

2. inode는 각 저장소에 실제 저장된 위치를 표기하므로 동일한 inode 값을 가진다면 동일한 파일로 생각할 수 있다.

3. 하드 링크는 동일한 inode를 가져서 해당 데이터에 접근할 수 있는 접근 포인트가 새로 생기며

    동일한 inode이기에 한쪽에서 데이터를 수정하면 다른 곳들도 모두 영향을 받는다.

4. 심볼릭 링크는 새로운 inode 값을 가지는 데이터를 만들고 원본 데이터의 위치를 넣어

    링크된 원본 주소로 찾아갈 수 있게 해주는 방식의 링크이다. 윈도우의 바로가기와 동일한 역할이다.