Skip to content

리눅스 - tar 압축 사용법

조회 수 25522 추천 수 0 2010.02.20 02:12:48
리눅스에서 tar 압축 명령어를 사용하는 방법입니다.

tar 압축하기
[root@ruo91 ~]# tar [옵션] [압축 될 파일명] [압축할 디렉토리 또는 파일]
[root@ruo91 ~]# tar cvf ruo91.tar /home/ruo91/public_html
cvf 옵션 추가

tar.gz 압축 하기
[root@ruo91 ~]# tar cvzf ruo91.tar.gz /home/ruo91/public_html
z 옵션 추가

tar.bz2 압축 하기
[root@ruo91 ~]# tar cvjf ruo91.tar.bz2 /home/ruo91/public_html
j 옵션 추가



tar 압축 풀기

[root@ruo91 ~]# tar xvf ruo91.tar /home/ruo91/public_html
xvf 옵션 추가

tar.gz 압축 풀기
[root@ruo91 ~]# tar xzvf ruo91.tar.gz /home/ruo91/public_html
z 옵션 추가

tar.bz2 압축 풀기
[root@ruo91 ~]# tar xvjf ruo91.tar.bz2 /home/ruo91/public_html
j 옵션 추가



선택적으로 여러개 파일이나 디렉토리 압축하기
/home/ruo91/public_html 디렉토리의 1, 2, 3, 4, 5 파일 중 1, 2, 5 선택 압축 
[root@ruo91 ~]# tar cvf ruo91.tar /home/ruo91/public_html/{1,2,5}
[root@ruo91 ~]# tar cvzf ruo91.tar.gz /home/ruo91/public_html/{1,2,5}
[root@ruo91 ~]# tar cvjf ruo91.tar.bz2 /home/ruo91/public_html/{1,2,5}



해당 파일을 퍼미션 유지 하면서 압축 하기
퍼미션을 유지하기 위해서는 -p 옵션을 사용하면 됩니다.

현재 퍼미션을 모두 제거
[root@ruo91 ~]# chmod 0 /home/ruo91/public_html/4
[root@ruo91 ~]# ls -l /home/ruo91/public_html/4
---------- 1 root root 1 11월  9 14:04 /home/ruo91/public_html/4

현재 퍼미션을 읽기(r), 쓰기(w), 실행(x) 위임
[root@ruo91 ~]# chmod +rwx /home/ruo91/public_html/4
[root@ruo91 ~]# ls -l /home/ruo91/public_html/4
-rwxr-xr-x 1 root root 1 11월  9 14:04 /home/ruo91/public_html/4

설정 된 퍼미션 그대로 보존하고 압축 시도
[root@ruo91 ~]# tar cvf ruo91.tar /home/ruo91/public_html/4

현재 디렉토리에 ruo91.tar 압축 해제
[root@ruo91 ~]# tar xvf ruo91.tar

압축푼 파일 퍼미션 확인
[root@ruo91 ~]# ls -l ~/home/ruo91/public_html/4
-rwxr-xr-x 1 root root 1 11월  9 14:04 /root/home/ruo91/public_html/4
profile

일요일은 짜빠게뤼~ 먹는날~^^

엮인글 :
http://adminplay.com/5667/e02/trackback
List of Articles
번호 제목 글쓴이 날짜 조회 수sort

linux daemon (리눅스 데몬 설명)

대용량 HDD 파티셔닝(Mass storage Partitioning) (GPT 파...

FFMPEG를 가장쉽게 설치하는 방법(ffmpeg-php 등)

rrdtool 컴파일시 에러 configure: error: Please fix the...

커널 2.6으로 업그레이드!「A to Z」

e2fsck - 파일 시스템 복구 및 검사. - fsck file

Maskrading

  • ADMIN
  • 2008-11-11
  • 조회 수 60826

시스템 백업과 응급 복구

리눅스 전원부터 부팅이 되기까지의 과정이해

  • ADMIN
  • 2008-11-11
  • 조회 수 59661

배치파일을 이용한 백업방법

  • l2zeo
  • 2010-03-31
  • 조회 수 59635

리눅스 디렉토리 구조와 파티션 관리의 기본

hdparm 세부옵션

CentOS 설치 - VMware 상에서 CentOS 설치하기 file

  • l2zeo
  • 2010-02-24
  • 조회 수 52165

Dell OMSA 설치 및 이용방법

Red Hat Linux 9

2TB이상의 Disk를 사용한 Raid6 구성

sulinux 1.0. 서버 패키지 리스트

ORA-01031: insufficient privileges 오류

[APM] 리눅스에서 Apache, PHP, MySQL 등 제거 방법

AIX 필수 명령어

Copyright ADMINPLAY corp. All rights reserved.

abcXYZ, 세종대왕,1234

abcXYZ, 세종대왕,1234