1 .gz

1)压缩

root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# gzip 2.txt 3.txt
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# ls -al
总用量 20
drwxr-xr-x 3 root root 4096 8月  30 19:11 .
drwxr-xr-x 3 root root 4096 8月  30 19:05 ..
-rw-r--r-- 1 root root   26 8月  30 19:05 2.txt.gz
-rw-r--r-- 1 root root   26 8月  30 19:06 3.txt.gz
drwxr-xr-x 2 root root 4096 8月  30 19:07 word
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow#

  

2)解压缩:

root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# gzip -d 2.txt.gz 3.txt.gz
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# ls -al
总用量 12
drwxr-xr-x 3 root root 4096 8月  30 19:12 .
drwxr-xr-x 3 root root 4096 8月  30 19:05 ..
-rw-r--r-- 1 root root    0 8月  30 19:05 2.txt
-rw-r--r-- 1 root root    0 8月  30 19:06 3.txt
drwxr-xr-x 2 root root 4096 8月  30 19:07 word
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow#

  

注意:不能压缩目录!支持批量压缩,源文件被替换成.gz结尾的文件。


2 .bz2

1)压缩

root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# bzip2 2.txt 3.txt
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# ls -al
总用量 20
drwxr-xr-x 3 root root 4096 8月  30 19:17 .
drwxr-xr-x 3 root root 4096 8月  30 19:05 ..
-rw-r--r-- 1 root root   14 8月  30 19:05 2.txt.bz2
-rw-r--r-- 1 root root   14 8月  30 19:06 3.txt.bz2
drwxr-xr-x 2 root root 4096 8月  30 19:07 word
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow#

  

2)解压缩:

root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# bzip2 -d 2.txt.bz2 3.txt.bz2
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# ls -al
总用量 12
drwxr-xr-x 3 root root 4096 8月  30 19:17 .
drwxr-xr-x 3 root root 4096 8月  30 19:05 ..
-rw-r--r-- 1 root root    0 8月  30 19:05 2.txt
-rw-r--r-- 1 root root    0 8月  30 19:06 3.txt
drwxr-xr-x 2 root root 4096 8月  30 19:07 word
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow#

  

3)强制压缩:

root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# bzip2 -z 2.txt 3.txt
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# ls -alh
总用量 20K
drwxr-xr-x 3 root root 4.0K 8月  30 19:23 .
drwxr-xr-x 3 root root 4.0K 8月  30 19:05 ..
-rw-r--r-- 1 root root   14 8月  30 19:05 2.txt.bz2
-rw-r--r-- 1 root root   14 8月  30 19:06 3.txt.bz2
drwxr-xr-x 2 root root 4.0K 8月  30 19:07 word
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow#

  

注意:不能压缩目录!支持批量压缩,源文件被替换成.bz2结尾的文件。


3 .zip

1)压缩

root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# zip hellow 1.txt
  adding: 1.txt (stored 0%)
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls -al
总用量 16
drwxr-xr-x 3 root      root      4096 8月  30 19:27 .
drwxr-xr-x 5 xiaohuang xiaohuang 4096 8月  30 19:03 ..
-rw-r--r-- 1 root      root         0 8月  30 19:04 1.txt
drwxr-xr-x 3 root      root      4096 8月  30 19:23 hellow
-rw-r--r-- 1 root      root         0 8月  30 19:04 hellow.py
-rw-r--r-- 1 root      root       160 8月  30 19:27 hellow.zip
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#

  

2)解压缩

root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# unzip hellow.zip
Archive:  hellow.zip
 extracting: 1.txt
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls -al
总用量 12
drwxr-xr-x 2 root      root      4096 8月  30 19:33 .
drwxr-xr-x 5 xiaohuang xiaohuang 4096 8月  30 19:03 ..
-rw-r--r-- 1 root      root         0 8月  30 19:04 1.txt
-rw-r--r-- 1 root      root         0 8月  30 19:04 hellow.py
-rw-r--r-- 1 root      root       160 8月  30 19:27 hellow.zip
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#

  

注意:可以压缩目录!支持批量压缩,源文件被替换成.zip结尾的文件。


4 tar

tar

  • -c 打包

  • -x 解包

  • -v 显示过程

  • -f 指定文件名

  • -t 查看包中的内容

1)打包

root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# tar -cvf kangbazi.tar 1.txt hellow.py hellow.zip
1.txt
hellow.py
hellow.zip
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls -al
总用量 24
drwxr-xr-x 2 root      root       4096 8月  30 19:37 .
drwxr-xr-x 5 xiaohuang xiaohuang  4096 8月  30 19:03 ..
-rw-r--r-- 1 root      root          0 8月  30 19:04 1.txt
-rw-r--r-- 1 root      root          0 8月  30 19:04 hellow.py
-rw-r--r-- 1 root      root        160 8月  30 19:27 hellow.zip
-rw-r--r-- 1 root      root      10240 8月  30 19:37 kangbazi.tar
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#

  

2)解包

root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# tar xvf kangbazi.tar
1.txt
hellow.py
hellow.zip
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls -al
总用量 24
drwxr-xr-x 2 root      root       4096 8月  30 19:40 .
drwxr-xr-x 5 xiaohuang xiaohuang  4096 8月  30 19:03 ..
-rw-r--r-- 1 root      root          0 8月  30 19:04 1.txt
-rw-r--r-- 1 root      root          0 8月  30 19:04 hellow.py
-rw-r--r-- 1 root      root        160 8月  30 19:27 hellow.zip
-rw-r--r-- 1 root      root      10240 8月  30 19:37 kangbazi.tar
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#

  

3)查看包里的内容

root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# tar -tf kangbazi.tar
1.txt
hellow.py
hellow.zip
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#

  


5.tar打包、压缩、解压缩

1) gz打包压缩

root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls
1.txt  hellow.py  hellow.zip
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# tar -zcvf kangbazi.tar.gz 1.txt hellow.py hellow.zip
1.txt
hellow.py
hellow.zip
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls
1.txt  hellow.py  hellow.zip  kangbazi.tar.gz
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#

  

2) .gz解包解压缩

root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# tar zxvf kangbazi.tar.gz
1.txt
hellow.py
hellow.zip
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls
1.txt  hellow.py  hellow.zip  kangbazi.tar.gz
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#

  

3) .bz2打包压缩

root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# tar -jzcf kangbazi.tar.bz2 1.txt hellow.py hellow.zip kangbazi.tar.gz
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls
1.txt  hellow.py  hellow.zip  kangbazi.tar.bz2  kangbazi1.tar.gz
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#

  

4) .bz2解包解压缩

root@xiaohuang-virtual-machine:/home/xiaohuang/桌面# tar -jxvf kangbazi.tar.bz2
hellow/
hellow/kangbazi2.tar.bz2
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面# ls
hellow  kangbazi.tar.bz2  linux  pycharm-2018.2.2  pycharm-professional-2018.2.2.tar.gz
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面#

  

5) .xz打包压缩

root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# tar -Jcvf kangbazi.tar.xz 1 kangbazi2.tar.bz2
1/
1/1.txt
kangbazi2.tar.bz2
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls
1  kangbazi2.tar.bz2  kangbazi.tar.xz
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#

  

6) .xz解包解压缩

root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# tar -Jxvf kangbazi.tar.xz
1/
1/1.txt
kangbazi2.tar.bz2
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls
1  kangbazi2.tar.bz2  kangbazi.tar.xz
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#

  

最新文章

  1. javax.el.PropertyNotFoundException 出错
  2. F - To the Max
  3. 关于$.getJson
  4. UML用例图(转载)
  5. Keil : Contents missmatch at:08000E84H Verify Failed!
  6. DRP过后,感受知识间的通性
  7. (Android) Download Images by AsyncTask API
  8. Netbeans源代码编辑技巧——使用代码补全和代码生成
  9. HttpServletRequest获取URL、URI
  10. css3特效样式库
  11. 学习安卓开发[3] - 使用RecyclerView显示列表
  12. webpack 配置文件相关解说
  13. Matlab illustrate stiffness
  14. [LeetCode] 35. Search Insert Position_Easy tag: Binary Search
  15. eclispe设置workspace text file encoding
  16. 题目1452:搬寝室(dp题目)
  17. Oracle学习笔记(一)——并发与锁
  18. Spring整合struts的配置文件存放问题
  19. Linux screen命令
  20. Laravel4.2取得配置文件值

热门文章

  1. QT笔记 -- (5) 实现QWidget的paintEvent函数,在widget上画背景图形
  2. PHP mysql_fetch_array得不到数据
  3. (二)React简介
  4. HDU 1043 Eight (A*算法)
  5. 红黑树(RBTREE)之上-------构造红黑树
  6. 紫书 习题 8-20 UVa 1620 (找规律+求逆序对)
  7. 洛谷P5160 WD与循环
  8. URAL 2027 2028 两个有趣的题
  9. 【BZOJ 1260】[CQOI2007]涂色paint
  10. [terry笔记]11gR2_DataGuard搭建_primary零停机