admin 管理员组文章数量: 1087582
tar打包与压缩
Linux压缩,解压缩常用命令
不能对目录进行压缩
压缩
- gzip 文件
- bzip2 文件
- xz 文件
解压缩
- gzip -d 压缩文件
- bzip2 -d 压缩文件
- xz -d 压缩文件
查看压缩文件内容(不解压情况下)
- zcat 压缩文件
- bzcat 压缩文件
- xzcat 压缩文件
tar打包命令
命令格式:
- tar 选项 打包后名字 被打包名字
选项:
- c 创建打包文件
- -f 指定打包后的文件名称(这个放在选项后面)
- -z 调用gzip压缩工具,-J 调用xz压缩工具, -j 调用bzip2压缩工具
- t 不解压缩,同时列出打包内容
- x 解压缩
- C 指定的解压路径
- v 显示详细信息
[root@student opt]# tar -czf services.tar.gz services
[root@student opt]# ll
total 796
-rw-r--r--. 2 root root 68 Oct 10 20:00 a.txt
-rw-r--r--. 1 root root 670293 Oct 14 00:31 services
-rw-r--r--. 1 root root 136200 Oct 15 02:30 services.tar.gz
drwxr-xr-x. 2 root root 6 Oct 14 01:00 test
[root@student opt]# rm -rf /opt/services.tar.gz
[root@student opt]# ls
a.txt services test
[root@student opt]# tar -cJtf services.tar.xz services
tar: You may not specify more than one `-Acdtrux' or `--test-label' option
Try `tar --help' or `tar --usage' for more information.
[root@student opt]# tar -ctf services.tar.xz services
tar: You may not specify more than one `-Acdtrux' or `--test-label' option
Try `tar --help' or `tar --usage' for more information.
[root@student opt]# tar -cJf services.tar.xz services
[root@student opt]# ls
a.txt services services.tar.xz test
[root@student opt]# tar -tf services.tar.xz
services
[root@student opt]# ll
total 760
-rw-r--r--. 2 root root 68 Oct 10 20:00 a.txt
-rw-r--r--. 1 root root 670293 Oct 14 00:31 services
-rw-r--r--. 1 root root 100752 Oct 15 02:32 services.tar.xz
drwxr-xr-x. 2 root root 6 Oct 14 01:00 test
[root@student opt]# tar -xf services.tar.xz -C /root/
本文标签: tar打包与压缩
版权声明:本文标题:tar打包与压缩 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1686635482a20019.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论