소유권이 다른 자료를 복사를 했는데 다른 소유권으로 변경하기 정보
JavaScript 소유권이 다른 자료를 복사를 했는데 다른 소유권으로 변경하기본문
웹호스팅이나 서버 호스팅을 하다 보면 자료를 디렉토리 통채로 복사를 해 달라고 하는 경우가 있습니다.
aaa.aaa /home/aaa/public_html 자료를 bbb.bbb /home/bbb/public_html 로 복사를 한다고 할 경우
어떻게 작업을 하시나요?
find ./ -user aaa > out.txt 이런씩으로 해서 파일 리스트를 얻을 수 있습니다.
예전에는 조금 무식한 방법으로 이렇게 파일 리스트를 저장해서 vi 편집기를 열어서
:%s/^/chown bbb.bbb /g 이렇게 변경을 하고 저장을 한다음 sh out.txt 로 실행해서 변경했었습니다.
혹은 for file in $(find ./ -user aaa); do chown bbb.bbb $file; done 이렇게 변경하곤 했습니다.
그런데 이런 방법 보다 더 간단한 방법이 있었습니다.
chown --from=aaa:aaa bbb.bbb -R *
이 한줄이면 끝납니다.
man page 에는 이렇게 설명되어 있네요.
--from=CURRENT_OWNER:CURRENT_GROUP
change the owner and/or group of each file only if its current owner and/or group match those specified here. Either may be omitted, in which case a match is not required for the omitted attribute.<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:32:05 Linux에서 이동 됨]</div>
aaa.aaa /home/aaa/public_html 자료를 bbb.bbb /home/bbb/public_html 로 복사를 한다고 할 경우
어떻게 작업을 하시나요?
find ./ -user aaa > out.txt 이런씩으로 해서 파일 리스트를 얻을 수 있습니다.
예전에는 조금 무식한 방법으로 이렇게 파일 리스트를 저장해서 vi 편집기를 열어서
:%s/^/chown bbb.bbb /g 이렇게 변경을 하고 저장을 한다음 sh out.txt 로 실행해서 변경했었습니다.
혹은 for file in $(find ./ -user aaa); do chown bbb.bbb $file; done 이렇게 변경하곤 했습니다.
그런데 이런 방법 보다 더 간단한 방법이 있었습니다.
chown --from=aaa:aaa bbb.bbb -R *
이 한줄이면 끝납니다.
man page 에는 이렇게 설명되어 있네요.
--from=CURRENT_OWNER:CURRENT_GROUP
change the owner and/or group of each file only if its current owner and/or group match those specified here. Either may be omitted, in which case a match is not required for the omitted attribute.<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:32:05 Linux에서 이동 됨]</div>
추천
0
0
댓글 1개
감사합니다.