Skip to content

리눅스 - tar 압축 사용법

조회 수 25482 추천 수 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/fd7/trackback
List of Articles
번호 제목 글쓴이 날짜 조회 수sort

<video>의 속성과 메소드

SCM - 캐시 서버 구축 (Squid in Linux)

Zabbix 웹서비스 모니터링

HTML5 멀티미디어 태그 - <video>,<audio>,<embed>

allowScriptAccess 설정

  • l2zeo
  • 2012-05-05
  • 조회 수 8425

CentOS 자동로그인 설정

클라이언트가 ssh접속시 서버의 RSA키값 변경으로 인한 접...

Bigbluebutton Installation Ubuntu

Adaptec 컨트롤러 StorMan 에러 및 각종 확인 방법

[CentOS] sshfs - 리눅스 윈도우간 데이터 전송을 편리하게 file

How to Enable EPEL Repository for RHEL/CentOS 6/5

파일비교 명령어 diff 사용법

Sample rate(샘플레이트)와 Bit rate (비트레이트)

스트리밍 서비스 위한 각 회사 와우자,어도비,마이크로 ...

FreeBSD 참고 명령문 ( H/W 정보 확인 방법)

TaskSet 으로 Process의 사용 CPU를 지정해 보자!

rsync 를 이용하여 동기화 할때 특정 폴더 2개 이상 제외하기

GSLB(Global Service Load Balancing)

OS X 10.9 매버릭스의 기본 파일공유 프로토콜은 AFP가 아...

Linux 마우스 휠 방향 바꾸기 (mac 처럼 마우스 휠 바꾸기)

Copyright ADMINPLAY corp. All rights reserved.

abcXYZ, 세종대왕,1234

abcXYZ, 세종대왕,1234