当前位置:   article > 正文

Linux文件压缩与打包

/etc/dbus-1/system.d/org.freedesktop.policykit1.conf

准备工作

  1. [root@centos-01 ~]# cd /tmp/
  2. [root@centos-01 tmp]# ls
  3. 1.txt
  4. systemd-private-40c0e692674844949b91361dc6ab4a40-chronyd.service-6km7K9
  5. systemd-private-40c0e692674844949b91361dc6ab4a40-vgauthd.service-3W1kyg
  6. systemd-private-40c0e692674844949b91361dc6ab4a40-vmtoolsd.service-wJZPyD
  7. [root@centos-01 tmp]# mkdir mytest
  8. [root@centos-01 tmp]# cd mytest/
  9. [root@centos-01 mytest]# ls
  10. [root@centos-01 mytest]# find /etc/ -type f -name "*conf"
  11. /etc/lvm/lvm.conf
  12. /etc/lvm/lvmlocal.conf
  13. /etc/resolv.conf
  14. /etc/pki/ca-trust/ca-legacy.conf
  15. /etc/yum/pluginconf.d/fastestmirror.conf
  16. /etc/yum/pluginconf.d/langpacks.conf
  17. /etc/yum/protected.d/systemd.conf
  18. /etc/yum/version-groups.conf
  19. /etc/asound.conf
  20. /etc/sasl2/smtpd.conf
  21. /etc/logrotate.conf
  22. /etc/openldap/ldap.conf
  23. /etc/libuser.conf
  24. /etc/sestatus.conf
  25. /etc/yum.conf
  26. /etc/host.conf
  27. /etc/dracut.conf
  28. /etc/dbus-1/system.d/teamd.conf
  29. /etc/dbus-1/system.d/org.freedesktop.hostname1.conf
  30. /etc/dbus-1/system.d/org.freedesktop.import1.conf
  31. /etc/dbus-1/system.d/org.freedesktop.locale1.conf
  32. /etc/dbus-1/system.d/org.freedesktop.login1.conf
  33. /etc/dbus-1/system.d/org.freedesktop.machine1.conf
  34. /etc/dbus-1/system.d/org.freedesktop.systemd1.conf
  35. /etc/dbus-1/system.d/org.freedesktop.timedate1.conf
  36. /etc/dbus-1/system.d/org.freedesktop.PolicyKit1.conf
  37. /etc/dbus-1/system.d/wpa_supplicant.conf
  38. /etc/dbus-1/system.d/nm-dispatcher.conf
  39. /etc/dbus-1/system.d/nm-ifcfg-rh.conf
  40. /etc/dbus-1/system.d/org.freedesktop.NetworkManager.conf
  41. /etc/dbus-1/system.d/com.redhat.tuned.conf
  42. /etc/dbus-1/system.d/FirewallD.conf
  43. /etc/dbus-1/system.d/dnsmasq.conf
  44. /etc/dbus-1/session.conf
  45. /etc/dbus-1/system.conf
  46. /etc/depmod.d/dist.conf
  47. /etc/modprobe.d/tuned.conf
  48. /etc/systemd/bootchart.conf
  49. /etc/systemd/coredump.conf
  50. /etc/systemd/journald.conf
  51. /etc/systemd/logind.conf
  52. /etc/systemd/system.conf
  53. /etc/systemd/user.conf
  54. /etc/rsyslog.d/listen.conf
  55. /etc/X11/xorg.conf.d/00-keyboard.conf
  56. /etc/prelink.conf.d/nss-softokn-prelink.conf
  57. /etc/prelink.conf.d/fipscheck.conf
  58. /etc/prelink.conf.d/grub2.conf
  59. /etc/ld.so.conf
  60. /etc/ld.so.conf.d/mariadb-x86_64.conf
  61. /etc/ld.so.conf.d/kernel-3.10.0-693.el7.x86_64.conf
  62. /etc/nsswitch.conf
  63. /etc/udev/udev.conf
  64. /etc/NetworkManager/NetworkManager.conf
  65. /etc/libaudit.conf
  66. /etc/fuse.conf
  67. /etc/GeoIP.conf
  68. /etc/selinux/semanage.conf
  69. /etc/selinux/targeted/setrans.conf
  70. /etc/sysctl.conf
  71. /etc/krb5.conf
  72. /etc/security/pwquality.conf
  73. /etc/security/access.conf
  74. /etc/security/chroot.conf
  75. /etc/security/group.conf
  76. /etc/security/limits.conf
  77. /etc/security/limits.d/20-nproc.conf
  78. /etc/security/namespace.conf
  79. /etc/security/pam_env.conf
  80. /etc/security/sepermit.conf
  81. /etc/security/time.conf
  82. /etc/wpa_supplicant/wpa_supplicant.conf
  83. /etc/plymouth/plymouthd.conf
  84. /etc/tuned/tuned-main.conf
  85. /etc/vmware-tools/guestproxy-ssl.conf
  86. /etc/vmware-tools/vgauth.conf
  87. /etc/firewalld/firewalld.conf
  88. /etc/kdump.conf
  89. /etc/audisp/audispd.conf
  90. /etc/audisp/plugins.d/af_unix.conf
  91. /etc/audisp/plugins.d/syslog.conf
  92. /etc/audit/auditd.conf
  93. /etc/chrony.conf
  94. /etc/rsyslog.conf
  95. /etc/man_db.conf
  96. /etc/sudo-ldap.conf
  97. /etc/sudo.conf
  98. /etc/e2fsck.conf
  99. /etc/mke2fs.conf
  100. /etc/vconsole.conf
  101. /etc/locale.conf
  102. /etc/updatedb.conf
  103. /etc/dnsmasq.conf
  104. [root@centos-01 mytest]# find /etc/ -type f -name "*conf" -exec cat {} >> 2.txt \;
  105. [root@centos-01 mytest]# ls
  106. 2.txt
  107. [root@centos-01 mytest]# du -sh 2.txt
  108. 240K 2.txt
  109. [root@centos-01 mytest]# find /etc/ -type f -name "*conf" -exec cat {} >> 2.txt \;
  110. [root@centos-01 mytest]# du -sh 2.txt
  111. 476K 2.txt
  112. [root@centos-01 mytest]# find /etc/ -type f -name "*conf" -exec cat {} >> 2.txt \;
  113. [root@centos-01 mytest]# du -sh 2.txt
  114. 1.2M 2.txt
  115. [root@centos-01 mytest]# find /etc/ -type f -name "*conf" -exec cat {} >> 2.txt \;
  116. [root@centos-01 mytest]# du -sh 2.txt
  117. 1.2M 2.txt
  118. [root@centos-01 mytest]# find /etc/ -type f -name "*conf" -exec cat {} >> 2.txt \;
  119. [root@centos-01 mytest]# du -sh 2.txt
  120. 1.2M 2.txt
  121. [root@centos-01 mytest]# find /etc/ -type f -name "*conf" -exec cat {} >> 2.txt \;
  122. [root@centos-01 mytest]# du -sh 2.txt
  123. 2.2M 2.txt
  124. [root@centos-01 mytest]# wc -l 2.txt
  125. 36486 2.txt
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126

gzip压缩工具

语法:gzip [-dn] filename(n为1-9的数字)

  • “-d”:解压缩时使用
  • “-n” (n为1-9的数字):压缩等级,第1级为最快压缩,但压缩量最小;第9级的压缩速度最慢,但压缩量最大。默认级别为6,“--fast”和“--best”分别等价于“-1”和“-9”。
  1. [root@centos-01 mytest]# gzip 2.txt
  2. [root@centos-01 mytest]# ls
  3. 2.txt.gz
  4. [root@centos-01 mytest]# du -sh 2.txt.gz
  5. 376K 2.txt.gz
  6. [root@centos-01 mytest]# gzip -d 2.txt.gz
  7. [root@centos-01 mytest]# ls
  8. 2.txt
  9. [root@centos-01 mytest]# du -sh 2.txt
  10. 1.4M 2.txt
  11. [root@centos-01 mytest]# wc -l 2.txt
  12. 36486 2.txt
  13. [root@centos-01 mytest]# gzip -1 2.txt
  14. [root@centos-01 mytest]# du -sh 2.txt.gz
  15. 444K 2.txt.gz
  16. [root@centos-01 mytest]# gunzip 2.txt.gz
  17. [root@centos-01 mytest]# ls
  18. 2.txt
  19. [root@centos-01 mytest]# gzip -9 2.txt
  20. [root@centos-01 mytest]# du -sh 2.txt.gz
  21. 372K 2.txt.gz
  22. [root@centos-01 mytest]# ls
  23. 2.txt.gz
  24. [root@centos-01 mytest]# file 2.txt.gz
  25. 2.txt.gz: gzip compressed data, was "2.txt", from Unix, last modified: Fri May 4 10:49:46 2018, max compression
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • zcat命令查看压缩文件内容
[root@centos-01 mytest]# zcat 2.txt.gz
  • 1

  1. [root@centos-01 mytest]# ls
  2. 2.txt.gz
  3. [root@centos-01 mytest]# gzip -d 2.txt.gz
  4. [root@centos-01 mytest]# gzip -c 2.txt > /tmp/2.txt.gz
  5. [root@centos-01 mytest]# ls
  6. 2.txt
  7. [root@centos-01 mytest]# ls /tmp/
  8. 1.txt systemd-private-ad61a62cb5b4492ca6ac55582093dd32-chronyd.service-yzD92d
  9. 2.txt.gz systemd-private-ad61a62cb5b4492ca6ac55582093dd32-vgauthd.service-inJewP
  10. mytest systemd-private-ad61a62cb5b4492ca6ac55582093dd32-vmtoolsd.service-Exaldt
  11. [root@centos-01 mytest]# file /tmp/2.txt.gz
  12. /tmp/2.txt.gz: gzip compressed data, was "2.txt", from Unix, last modified: Fri May 4 10:49:46 2018
  13. [root@centos-01 mytest]# gzip -d -c /tmp/2.txt.gz > /tmp/mytest/3.txt
  14. [root@centos-01 mytest]# ls
  15. 2.txt 3.txt
  16. [root@centos-01 mytest]# wc -l 2.txt 3.txt
  17. 36486 2.txt
  18. 36486 3.txt
  19. 72972 总用量
  20. [root@centos-01 mytest]# du -sh *.txt
  21. 1.4M 2.txt
  22. 1.4M 3.txt
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • gzip是不支持压缩目录的。

bzip2压缩工具

  1. [root@centos-01 mytest]# bzip2 2.txt
  2. -bash: bzip2: 未找到命令
  3. [root@centos-01 mytest]# yum install -y bzip2
  • 1
  • 2
  • 3

语法:bzip2 [-dz] filename

  • “-d”:解压缩
  • “-z”:压缩
  1. [root@centos-01 mytest]# bzip2 2.txt
  2. [root@centos-01 mytest]# ls
  3. 2.txt.bz2 3.txt
  4. [root@centos-01 mytest]# du -sh 2.txt.bz2
  5. 160K 2.txt.bz2
  6. [root@centos-01 mytest]# bzip2 -d 2.txt.bz2
  7. [root@centos-01 mytest]# ls
  8. 2.txt 3.txt
  9. [root@centos-01 mytest]# bzip2 2.txt
  10. [root@centos-01 mytest]# bunzip2 2.txt.bz2
  11. [root@centos-01 mytest]# ls
  12. 2.txt 3.txt
  13. [root@centos-01 mytest]# ls /tmp/
  14. 1.txt systemd-private-604486059e93474a8b695802ff294d42-chronyd.service-nvD2qs
  15. 2.txt.gz systemd-private-604486059e93474a8b695802ff294d42-vgauthd.service-xKKbjw
  16. mytest systemd-private-604486059e93474a8b695802ff294d42-vmtoolsd.service-yaJKgA
  17. [root@centos-01 mytest]# bzip2 -c 2.txt > /tmp/3.txt.bz2
  18. [root@centos-01 mytest]# du -sh /tmp/3.txt.bz2
  19. 160K /tmp/3.txt.bz2
  20. [root@centos-01 mytest]# bzip2 -d -c /tmp/3.txt.bz2 > 4.txt
  21. [root@centos-01 mytest]# ls
  22. 2.txt 3.txt 4.txt
  23. [root@centos-01 mytest]# du -sh 4.txt
  24. 1.4M 4.txt
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • bzcat命令查看压缩文件内容
[root@centos-01 mytest]# bzcat /tmp/3.txt.bz2
  • 1
  • bzip2不可以压缩目录

xz压缩工具

  1. [root@centos-01 mytest]# xz 2.txt
  2. [root@centos-01 mytest]# ls
  3. 2.txt.xz 3.txt 4.txt
  4. [root@centos-01 mytest]# du -sh 2.txt.xz
  5. 56K 2.txt.xz
  6. [root@centos-01 mytest]# xz -d 2.txt.xz
  7. [root@centos-01 mytest]# ls
  8. 2.txt 3.txt 4.txt
  9. [root@centos-01 mytest]# xz 2.txt
  10. [root@centos-01 mytest]# unxz 2.txt.xz
  11. [root@centos-01 mytest]# ls
  12. 2.txt 3.txt 4.txt
  13. [root@centos-01 mytest]# ls /tmp/
  14. 1.txt systemd-private-604486059e93474a8b695802ff294d42-chronyd.service-nvD2qs
  15. 2.txt.gz systemd-private-604486059e93474a8b695802ff294d42-vgauthd.service-xKKbjw
  16. 3.txt.bz2 systemd-private-604486059e93474a8b695802ff294d42-vmtoolsd.service-yaJKgA
  17. mytest
  18. [root@centos-01 mytest]# xz -c 2.txt > /tmp/4.txt.xz
  19. [root@centos-01 mytest]# xz -d -c /tmp/4.txt.xz > ./1.txt
  20. [root@centos-01 mytest]# ll
  21. 总用量 5712
  22. -rw-r--r--. 1 root root 1460358 54 20:42 1.txt
  23. -rw-r--r--. 1 root root 1460358 54 10:49 2.txt
  24. -rw-r--r--. 1 root root 1460358 54 20:28 3.txt
  25. -rw-r--r--. 1 root root 1460358 54 20:30 4.txt
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • xzcat命令查看压缩文件内容
[root@centos-01 mytest]# xzcat /tmp/4.txt.xz
  • 1

zip压缩工具

  1. [root@centos-01 mytest]# tree /tmp/
  2. /tmp/
  3. ├── 1.txt
  4. ├── 2.txt.gz
  5. ├── 3.txt.bz2
  6. ├── 4.txt.xz
  7. ├── mytest
  8. │ ├── 1.txt
  9. │ ├── 2.txt
  10. │ ├── 3.txt
  11. │ ├── 4.txt
  12. │ └── yourtest
  13. │ ├── 1.txt
  14. │ ├── 2.txt
  15. │ ├── 3.txt
  16. │ └── 4.txt
  17. ├── systemd-private-604486059e93474a8b695802ff294d42-chronyd.service-nvD2qs
  18. │ └── tmp
  19. ├── systemd-private-604486059e93474a8b695802ff294d42-vgauthd.service-xKKbjw
  20. │ └── tmp
  21. └── systemd-private-604486059e93474a8b695802ff294d42-vmtoolsd.service-yaJKgA
  22. └── tmp
  23. └── vmware-root
  24. 9 directories, 12 files
  25. [root@centos-01 mytest]# du -sh yourtest/
  26. 5.6M yourtest/
  27. [root@centos-01 mytest]# zip 2.txt.zip 2.txt
  28. -bash: zip: 未找到命令
  29. [root@centos-01 mytest]# yum install -y zip
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  1. [root@centos-01 mytest]# zip 2.txt.zip 2.txt
  2. adding: 2.txt (deflated 74%)
  3. [root@centos-01 mytest]# du -sh 2.txt.zip
  4. 376K 2.txt.zip
  5. [root@centos-01 mytest]# ls
  6. 1.txt 2.txt 2.txt.zip 3.txt 4.txt yourtest
  7. [root@centos-01 mytest]# zip -r yourtest.zip yourtest 3.txt
  8. adding: yourtest/ (stored 0%)
  9. adding: yourtest/3.txt (deflated 74%)
  10. adding: yourtest/4.txt (deflated 74%)
  11. adding: yourtest/2.txt (deflated 74%)
  12. adding: yourtest/1.txt (deflated 74%)
  13. adding: 3.txt (deflated 74%)
  14. [root@centos-01 mytest]# ls
  15. 1.txt 2.txt 2.txt.zip 3.txt 4.txt yourtest yourtest.zip
  16. [root@centos-01 mytest]# du -sh yourtest.zip
  17. 1.9M yourtest.zip
  18. [root@centos-01 mytest]# unzip
  19. -bash: unzip: 未找到命令
  20. [root@centos-01 mytest]# yum install -y unzip
  21. [root@centos-01 mytest]# unzip yourtest.zip
  22. Archive: yourtest.zip
  23. replace yourtest/3.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: n
  24. replace yourtest/4.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
  25. inflating: yourtest/4.txt
  26. replace yourtest/2.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
  27. inflating: yourtest/2.txt
  28. inflating: yourtest/1.txt
  29. inflating: 3.txt
  30. [root@centos-01 mytest]# mkdir test
  31. [root@centos-01 mytest]# unzip 2.txt.zip -d test/
  32. Archive: 2.txt.zip
  33. inflating: test/2.txt
  34. [root@centos-01 mytest]# ls
  35. 1.txt 2.txt 2.txt.zip 3.txt 4.txt test yourtest yourtest.zip
  36. [root@centos-01 mytest]# unzip -l yourtest.zip
  37. Archive: yourtest.zip
  38. Length Date Time Name
  39. --------- ---------- ----- ----
  40. 0 05-04-2018 21:27 yourtest/
  41. 1460358 05-04-2018 21:27 yourtest/3.txt
  42. 1460358 05-04-2018 21:27 yourtest/4.txt
  43. 1460358 05-04-2018 21:27 yourtest/2.txt
  44. 1460358 05-04-2018 21:27 yourtest/1.txt
  45. 1460358 05-04-2018 20:28 3.txt
  46. --------- -------
  47. 7301790 6 files
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48

tar打包工具

tar本身为一个打包工具,可以把目录打包成一个文件,它的好处是它把所有文件整合成一个大文件整体,方便拷贝或者移动。

语法:tar [-zjxcvfpP] filename

  • “-z”:同时用gzip压缩
  • “-j”:同时用bzip2压缩
  • “-x”:解包或者解压缩
  • “-t”:查看tar包里面的文件
  • “-c”:建立一个tar包或者压缩文件包
  • “-v”:可视化
  • “-f”:后面跟文件名,压缩时跟“-f filename”,意思是压缩后的文件名为filename,解压时跟“-f 文件名”,意思是解压filename。需要注意,如果是多个参数组合的情况下带有“-f”,请把“-f”写到最后面。
  • “-p”:使用原文件的属性,压缩前什么属性压缩后还什么属性。
  • “-P”:可以使用绝对路径。
  • --exclude filename:在打包或者压缩时,不要将filename文件包括在内。
  1. [root@centos-01 mytest]# ls
  2. 1.txt 2.txt 2.txt.zip 3.txt 4.txt test yourtest yourtest.zip
  3. [root@centos-01 mytest]# tar -cvf yourtest.tar yourtest
  4. yourtest/
  5. yourtest/3.txt
  6. yourtest/4.txt
  7. yourtest/2.txt
  8. yourtest/1.txt
  9. [root@centos-01 mytest]# ls
  10. 1.txt 2.txt 2.txt.zip 3.txt 4.txt test yourtest yourtest.tar yourtest.zip
  11. [root@centos-01 mytest]# tar -xvf yourtest.tar
  12. yourtest/
  13. yourtest/3.txt
  14. yourtest/4.txt
  15. yourtest/2.txt
  16. yourtest/1.txt
  17. [root@centos-01 mytest]# tar -tf yourtest.tar
  18. yourtest/
  19. yourtest/3.txt
  20. yourtest/4.txt
  21. yourtest/2.txt
  22. yourtest/1.txt
  23. [root@centos-01 mytest]# ls
  24. 1.txt 2.txt 2.txt.zip 3.txt 4.txt test yourtest yourtest.tar yourtest.zip
  25. [root@centos-01 mytest]# tar -cvf yourtest.tar --exclude 1.txt yourtest
  26. yourtest/
  27. yourtest/3.txt
  28. yourtest/4.txt
  29. yourtest/2.txt
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

tar打包并压缩

  1. [root@centos-01 mytest]# tar -zcvf yourtest.tar.gz yourtest
  2. yourtest/
  3. yourtest/3.txt
  4. yourtest/4.txt
  5. yourtest/2.txt
  6. yourtest/1.txt
  7. [root@centos-01 mytest]# du -sh yourtest.tar.gz
  8. 1.5M yourtest.tar.gz
  9. [root@centos-01 mytest]# du -sh yourtest
  10. 5.6M yourtest
  11. [root@centos-01 mytest]# tar -jcvf yourtest.tar.bz2 yourtest
  12. yourtest/
  13. yourtest/3.txt
  14. yourtest/4.txt
  15. yourtest/2.txt
  16. yourtest/1.txt
  17. [root@centos-01 mytest]# du -sh yourtest.tar.bz2
  18. 544K yourtest.tar.bz2
  19. [root@centos-01 mytest]# tar -Jcvf yourtest.tar.xz yourtest
  20. yourtest/
  21. yourtest/3.txt
  22. yourtest/4.txt
  23. yourtest/2.txt
  24. yourtest/1.txt
  25. [root@centos-01 mytest]# du -sh yourtest.tar.xz
  26. 60K yourtest.tar.xz
  27. [root@centos-01 mytest]# ls
  28. 1.txt 2.txt.zip 4.txt yourtest yourtest.tar.bz2 yourtest.tar.xz
  29. 2.txt 3.txt test yourtest.tar yourtest.tar.gz yourtest.zip
  30. [root@centos-01 mytest]# tar -tf yourtest.tar.gz
  31. yourtest/
  32. yourtest/3.txt
  33. yourtest/4.txt
  34. yourtest/2.txt
  35. yourtest/1.txt
  36. [root@centos-01 mytest]# tar -tf yourtest.tar.bz2
  37. yourtest/
  38. yourtest/3.txt
  39. yourtest/4.txt
  40. yourtest/2.txt
  41. yourtest/1.txt
  42. [root@centos-01 mytest]# tar -tf yourtest.tar.xz
  43. yourtest/
  44. yourtest/3.txt
  45. yourtest/4.txt
  46. yourtest/2.txt
  47. yourtest/1.txt
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48

转载于:https://www.cnblogs.com/Genesis2018/p/8998088.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/197493
推荐阅读
相关标签
  

闽ICP备14008679号