소유권이 다른 자료를 복사를 했는데 다른 소유권으로 변경하기
웹호스팅이나 서버 호스팅을 하다 보면 자료를 디렉토리 통채로 복사를 해 달라고 하는 경우가 있습니다.
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>
|
댓글을 작성하시려면 로그인이 필요합니다.
프로그램
태그 필터 (최대 3개)
전체
개발자
소스
기타
mysql
팁자료실
javascript
php
linux
flash
정규표현식
jquery
node.js
mobile
웹서버
os
프로그램
강좌
썸네일
이미지관련
도로명주소
그누보드5
기획자
견적서
계약서
기획서
마케팅
제안서
seo
통계
서식
통계자료
퍼블리셔
html
css
반응형
웹접근성
퍼블리싱
표준화
반응형웹
홈페이지기초
부트스트랩
angularjs
포럼
스크린리더
센스리더
개발자톡
개발자팁
퍼블리셔톡
퍼블리셔팁
기획자톡
기획자팁
프로그램강좌
퍼블리싱강좌
댓글 1개