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

도메인 Status 상태별 설명 안내

HDD Guardian (a graphical user interface for smartctl)

dpkg 사용법

top 화면 내용중 load average와 PRI : priority(우선순위...

ubuntu 10.04 에서 Nginx, Mysql, PHP5

HP 서버 disk 증설 (hpacucli 사용)

리눅스 메모리 관리, 왜 메모리 여유공간이 없을까? (top ...

windows smartctl

ZFS 파일에 ACL 설정

make 정리

SSL 패스워드 삭제 하기

EXT4 파일 시스템을 Btrfs 파일 시스템으로 변환하기

tar 압축을 실수로 디렉토리 생성 안하고 풀었을때 대처법

ll 명령시 날짜 전체가 보이도록 하기

hddtemp와 mrtg를 이용한 하드디스크 온도 체크 file

python과 mysql 연동시 libmysqlclient_r.so.* 에러가 날 ...

linux 커널 파라메터 수정

우분투(Ubuntu) ssh 설정하기

error: Hm, kex protocol error: type 30 seq 1 [preauth]... file

운영중인 Linux 서버에서 NTFS 파일 시스템 삭제하기

Copyright ADMINPLAY corp. All rights reserved.

abcXYZ, 세종대왕,1234

abcXYZ, 세종대왕,1234