-
리눅스(Linux) - 파일 압축, tar 와 gzip기술 공부 2015. 6. 20. 12:26반응형
리눅스에서 파일을 압축할 때 가장 많이 사용되는 명령어가 tar 와 gzip 이다.
일반적으로 여러 파일들을 하나의 파일로 압축할 때는 tar 가 사용되고,
tar 로 압축한 파일을 또 한 번 더 압축할 때 gzip 을 사용하게 된다.
tar 로 파일 압축 및 압축 해제
압축 : tar cvzf {압축파일명} {압축하고자 하는 파일들 또는 디렉토리}
압축해제 : tar xvfz {압축파일명}
tar 로 test_server 디렉토리를 test_server.tar 로 압축하는 예제
joyfintech@localhost:/home/joyfintech/test>$ ls -al
합계 12
drwxr-x--- 3 joyfintech joyfintech 4096 2015-04-02 10:08 .
drwxr-xr-x 5 joyfintech joyfintech 4096 2015-04-02 09:52 ..
drwxr-x--- 3 joyfintech joyfintech 4096 2015-04-02 09:50 test_server
joyfintech@localhost:/home/joyfintech/test>$ tar cvfz test_server.tar test_server/
test_server/
test_server/test-batch/
test_server/test-batch/test_server.jar
test_server/test-batch/key/
test_server/test-batch/key/tcseed.key
test_server/test-batch/log/
test_server/test-batch/log/ArsFwdServer.log
test_server/TestWebClient.class
test_server/TestWebClient.java
joyfintech@localhost:/home/joyfintech/test>$ ls -al
합계 416
drwxr-x--- 3 joyfintech joyfintech 4096 2015-04-02 10:09 .
drwxr-xr-x 5 joyfintech joyfintech 4096 2015-04-02 09:52 ..
drwxr-x--- 3 joyfintech joyfintech 4096 2015-04-02 09:50 test_server
-rw-r----- 1 joyfintech joyfintech 412265 2015-04-02 10:09 test_server.tar
joyfintech@localhost:/home/joyfintech/test>$gzip 으로 파일 압축 및 압축해제
압축 : gzip {압축하고자 하는 파일명}
압축해제 : gzip -d {압축파일명}
gzip 으로 test_server.tar 를 test_server.tar.gz 으로 압축하고, 해제하는 예제
joyfintech@localhost:/home/joyfintech/test>$ ls -al
합계 416
drwxr-x--- 3 joyfintech joyfintech 4096 2015-04-02 10:09 .
drwxr-xr-x 5 joyfintech joyfintech 4096 2015-04-02 09:52 ..
drwxr-x--- 3 joyfintech joyfintech 4096 2015-04-02 09:50 test_server
-rw-r----- 1 joyfintech joyfintech 412265 2015-04-02 10:09 test_server.tar
joyfintech@localhost:/home/joyfintech/test>$ gzip test_server.tar
joyfintech@localhost:/home/joyfintech/test>$ ls -al
합계 400
drwxr-x--- 3 joyfintech joyfintech 4096 2015-04-02 10:30 .
drwxr-xr-x 5 joyfintech joyfintech 4096 2015-04-02 09:52 ..
drwxr-x--- 3 joyfintech joyfintech 4096 2015-04-02 09:50 test_server
-rw-r----- 1 joyfintech joyfintech 396451 2015-04-02 10:09 test_server.tar.gz
joyfintech@localhost:/home/joyfintech/test>$ gzip -d test_server.tar.gz
joyfintech@localhost:/home/joyfintech/test>$ ls -al
합계 416
drwxr-x--- 3 joyfintech joyfintech 4096 2015-04-02 10:32 .
drwxr-xr-x 5 joyfintech joyfintech 4096 2015-04-02 09:52 ..
drwxr-x--- 3 joyfintech joyfintech 4096 2015-04-02 09:50 test_server
-rw-r----- 1 joyfintech joyfintech 412265 2015-04-02 10:09 test_server.tar
joyfintech@localhost:/home/joyfintech/test>$반응형'기술 공부' 카테고리의 다른 글
쉘스크립트(shell script) - 리스트 정의 및 for loop 예제 (0) 2015.06.20 Shell script 기초 - 코멘트, 출력, 변수선언 (0) 2015.06.20 리눅스(Linux) - alias 로 별칭 붙이기 (0) 2015.06.20 아파치,톰캣 환경에서 https 접속을 위한 아파치 설정 방법 (0) 2015.06.20 리눅스(Linux) - traceroute 로 네트워크 경로 찾기 (0) 2015.06.20