이것은 내 토폴로지입니다.
My laptop ==> Ubuntu Desktop
| | |
User: root & saeed
My server ==> Ubuntu 20.04
| | |
Users: root & ubuntu (I deleted it as I explain below)
단계:
tar zvcf back.tar.gz .
사용자와 함께 랩탑에서 실행하면saeed
파일이 생성됩니다.- 사용자의 홈 디렉토리가 아닌
root
경로 예제에서 사용자를 사용하여 SFTP를 통해 이 파일을 내 서버에 업로드합니다 ./home/test
- 압축을 풀었
back.tar.gz
지만/home/test
모든 파일과 디렉토리의 소유자가 입니다ubuntu:ubuntu
. - 사용자를 삭제
ubuntu
하고 세 번째 단계를 시도했지만 동일한 결과를 얻었습니다. back.tar.gz
노트북에서 다른 경로로 압축을 풀었는데 모든 파일의 소유자는saeed:saeed
.
왜 이런 일이 발생합니까?
답변1
루트로 추출하면 tar
기본적으로 원래 소유자 ID가 유지됩니다. 사용자는 우연히 다른 컴퓨터 saeed
와 동일한 ID를 가지고 있습니다 (아마도 그럴 것입니다 ). 를 실행하여 ID를 확인 하거나, 현재 사용자를 확인하기만 하면 됩니다.ubuntu
1000
id saeed
id
사용자 ID를 유지하지 않으려면 루트로 추출하지 않거나 --no-same-owner
옵션을 사용하십시오. 관련 조각수동:
--no-same-owner
Extract files as yourself (default for ordinary users).
를 사용하는 일반 사용자의 경우 반대 결과를 얻을 수 있습니다 --same-owner
.
관련 옵션 --owner
이며 --owner-map
아카이브를 생성할 때 사용할 수 있습니다.
--owner=NAME[:UID]
Force NAME as owner for added files. If UID is not
supplied, NAME can be either a user name or numeric UID.
In this case the missing part (UID or name) will be
inferred from the current host's user database.
When used with --owner-map=FILE, affects only those files
whose owner is not listed in FILE.
--owner-map=FILE
Read owner translation map from FILE. Empty lines are
ignored. Comments are introduced with # sign and extend
to the end of line. Each non-empty line in FILE defines
translation for a single UID. It must consist of two
fields, delimited by any amount of whitespace:
OLDUSR NEWUSR[:NEWUID]
OLDUSR is either a valid user name or a UID prefixed with
+. Unless NEWUID is supplied, NEWUSR must also be either
a valid user name or a +UID. Otherwise, both NEWUSR and
NEWUID need not be listed in the system user database.
As a result, each input file owned by OLDUSR will be
stored in archive with owner name NEWUSR and UID NEWUID.