오늘은 리눅스 상에서 tar, gz, unzip 등 압축해야 할 일도 압축 풀어야 할 일도 많이 있다.
그런데 압축형태도 참 다양해서 이거 저거 다 알아 두어야 한다.
(test) root@ckkim:~/IPMICFG_1.29.0_build.181029# ls
IPMICFG_1.29.0_build.181029 test.zip
(test) root@ckkim:~/IPMICFG_1.29.0_build.181029# tar cvf test.tar IPMICFG_1.29.0_build.181029/
IPMICFG_1.29.0_build.181029/
..
..
(test) root@ckkim:~/IPMICFG_1.29.0_build.181029# ls
IPMICFG_1.29.0_build.181029 test.tar test.zip
위에 IPMICFG폴더를 CVF 옵션을 사용하여 test.tar파일로 압축하였다.
c : 대상을 tar로 묶음
v : 처리되는 과정을 상세히 보여줌
f : 대상 파일 이름을 지정
z : gzip 압축 전용 옵션
j : bzip2 압축 전용 옵션
(test) root@ckkim:~/IPMICFG_1.29.0_build.181029# ls
test.tar test.zip
(test) root@ckkim:~/IPMICFG_1.29.0_build.181029# tar xvf test.tar
IPMICFG_1.29.0_build.181029/
..
..
(test) root@ckkim:~/IPMICFG_1.29.0_build.181029# ls
IPMICFG_1.29.0_build.181029 test.tar test.zip
gz는 tar와 다를 바 없으니 z 옵션을 사용하면 된다.
(test) root@ckkim:~/ckkim# ls
IPMICFG_1.29.0_build.181029.zip lsigetlinux_latest.tgz nccl_2.3.7-1cuda10.0_x86_64.txz test
(test) root@ckkim:~/ckkim# ls test
(test) root@ckkim:~/ckkim# unzip -d test/ IPMICFG_1.29.0_build.181029.zip
Archive: IPMICFG_1.29.0_build.181029.zip
..
..
(test) root@ckkim:~/ckkim# ls test
IPMICFG_1.29.0_build.181029
위에 zip 파일은 unzip명령어로 묶고 풀 수 있다.
unzip명령어가 없다면
# yum install unzip 혹은 apt-get install unzip으로 받아서 사용하도록 하자.
-d 옵션은 특정 폴더에 압축을 풀겠다는 의미이다.
(test) root@ckkim:~/ckkim# unzip IPMICFG_1.29.0_build.181029.zip
Archive: IPMICFG_1.29.0_build.181029.zip
..
..
(test) root@ckkim:~/ckkim# ls
IPMICFG_1.29.0_build.181029 IPMICFG_1.29.0_build.181029.zip lsigetlinux_latest.tgz nccl_2.3.7-1cuda10.0_x86_64.txz test
-d 옵션을 사용하지 않게 되면 해당 폴더에 압축을 풀게 된다.
(test) root@ckkim:~/IPMICFG_1.29.0_build.181029# zip -r test.zip IPMICFG_1.29.0_build.181029/
adding: IPMICFG_1.29.0_build.181029/ (stored 0%)
..
..
(test) root@ckkim:~/IPMICFG_1.29.0_build.181029# ls
IPMICFG_1.29.0_build.181029 test.zip
반대로 압축하기는 간편하다.
-r : 하위 디렉터리까지 압축
-1 : 빠른 압축 (압축률 저하)
-9 : 높은 압축 (속도 저하)
-e : zip 파일에 암호 설정
-x : 압축 시 파일 제외
LSI Raid - MSM (Megaraid-storage-management) 설치 및 사용 (7) | 2020.08.27 |
---|---|
linux 현재 접속해 있는 user 사용자 확인 및 kill 하기 (6) | 2020.08.25 |
linux - centos 본딩(bonding)종류 및 설정하기 (1) | 2020.07.30 |
linux - ssh 접속하기 및 포트 변경 (2) | 2020.07.29 |
리눅스(linux) - 기본 명령어 사용법 (2) | 2020.07.27 |