!["cp --preserve=links"가 작동하지 않는 이유는 무엇입니까? [복사]](https://linux55.com/image/122955/%22cp%20--preserve%3Dlinks%22%EA%B0%80%20%EC%9E%91%EB%8F%99%ED%95%98%EC%A7%80%20%EC%95%8A%EB%8A%94%20%EC%9D%B4%EC%9C%A0%EB%8A%94%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F%20%5B%EB%B3%B5%EC%82%AC%5D.png)
왜 cp --preserve=links
작동하지 않나요? 일부 심볼릭 링크를 복사하고 싶습니다. 매뉴얼 페이지에서:
--preserve[=ATTR_LIST]
지정된 속성(기본값: 모드, 소유권, 타임스탬프)을 유지하고 가능한 경우 추가 속성: context, link, xattr, all*
내 CentOS 3.10.0-693.el7.x86_64에서는 작동하지 않습니다.
내 단계는 다음과 같습니다.
[root@ beau]# ls -l
total 4
lrwxrwxrwx. 1 root root 11 Dec 2 21:49 bar.txt -> foo/bar.txt
drwxr-xr-x. 2 root root 4096 Dec 2 21:41 foo
[root@ beau]# cp --preserve=links bar.txt bar1
[root@ beau]# ls -l
total 4
-rw-r--r--. 1 root root 0 Dec 2 23:08 bar1
lrwxrwxrwx. 1 root root 11 Dec 2 21:49 bar.txt -> foo/bar.txt
drwxr-xr-x. 2 root root 4096 Dec 2 21:41 foo
내 질문은: "--preserve=links" 옵션이 작동하지 않는 이유는 무엇입니까?
답변1
간단히 말해서: --preserve=links
저장을 의미합니다.하드 링크, 심볼릭 링크가 아닌. -P
또는 --no-dereference
대상 대신 링크 자체를 복사하여 기호 링크를 유지합니다. -P
표준이며 GNU cp -d
에는 -a
.