まめぞうの技術メモ

IT関連で勉強したことをメモします

Linuxのzip・unzipコマンドでの解凍・圧縮方法

いつも忘れてしまうLinuxのzipコマンドでの圧縮・解凍方法。

Linuxのzipコマンドでの圧縮・解凍方法
Linuxのzipコマンドでの圧縮・解凍方法

自分の備忘録も兼ねて記事にします。

zipコマンドでの圧縮方法

zip -r 作成するzipファイルの名前(.zip)圧縮対象ディレクトリ

具体例 

aaaフォルダを、aaa.zipに変更するときの例です。

[root@150-95-149-109 zip_test]# ls -la
合計 4
drwxr-xr-x  3 root root   16  6月 16 23:50 .
dr-xr-x---. 8 root root 4096  6月 16 23:47 ..
drwxr-xr-x  2 root root   30  6月 16 23:48 aaa
[root@150-95-149-109 zip_test]# zip -r aaa.zip aaa
  adding: aaa/ (stored 0%)
  adding: aaa/1.txt (stored 0%)
  adding: aaa/2.txt (stored 0%)
[root@150-95-149-109 zip_test]# ls -la
合計 8
drwxr-xr-x  3 root root   30  6月 16 23:50 .
dr-xr-x---. 8 root root 4096  6月 16 23:47 ..
drwxr-xr-x  2 root root   30  6月 16 23:48 aaa
-rw-r--r--  1 root root  460  6月 16 23:50 aaa.zip

unzipコマンドでの解凍方法

unzipの場合はオプションは特に必要ありません。

unzip 解凍対象のzpファイル

具体例

[root@150-95-149-109 zip_test]# ls -la
合計 8
drwxr-xr-x  2 root root   20  6月 16 23:55 .
dr-xr-x---. 8 root root 4096  6月 16 23:47 ..
-rw-r--r--  1 root root  460  6月 16 23:50 aaa.zip
[root@150-95-149-109 zip_test]# unzip aaa.zip
Archive:  aaa.zip
   creating: aaa/
 extracting: aaa/1.txt
 extracting: aaa/2.txt
[root@150-95-149-109 zip_test]# ls -la
合計 8
drwxr-xr-x  3 root root   30  6月 16 23:57 .
dr-xr-x---. 8 root root 4096  6月 16 23:47 ..
drwxr-xr-x  2 root root   30  6月 16 23:48 aaa
-rw-r--r--  1 root root  460  6月 16 23:50 aaa.zip