Linux 压缩与解压缩命令 tar gzip zip rar 详解

目录

tar

gzip

zip

RAR


tar

复制代码
# 压缩文件有时候我们也叫做归档文件
#但是归档和压缩有一些区别,归档只是将多个文件捆绑成一个文件,
并没有压缩,而压缩才是将大小压缩的更小。
#Linux最常用的压缩和解压指令是:
tar:能够解压的文件格式是xx.tar.gz
压缩:tar -zcf 压缩包路径 目标1 目标2 目标3 ...
解压:tar -zxf 解压路径
------------------------------------------------------------
压缩和解压文件
[root@localhost ~]# ls
123.txt 4.txt a.txt c.txt jaden.txt
[root@localhost ~]# tar -zcf jaden.tar.gz services #压缩文件
[root@localhost ~]# tar -zxf jaden.tar.gz # 解压文件
#归档,但是不压缩
tar -cf
[root@localhost ~]# cp /etc/services ./shike # 再拷贝一个services文件过来
#查看压缩包内容
[root@localhost ~]# tar -tf 3.tar.gz

gzip

复制代码
打包和压缩
gzip
#压缩文件,会自动删除原文件,和tar不同,tar会留着原文件
[root@localhost ~]# gzip services
[root@localhost ~]# ls -lh
# 解压,会自动删除原压缩包
[root@localhost ~]# gzip -d services.gz
[root@localhost ~]# ls -lh
#压缩多个文件,每一个文件产生一个单独的压缩包
[root@localhost ~]# gzip services shike
#解压缩
[root@localhost ~]# gzip -d services.gz shike.gz

zip

复制代码
#压缩
zip
[root@localhost ~]# zip -r 1.zip services shike #会保留原文件
------------------------------------------------------------------
#解压
unzip
例子1: # 解压之前先把原文件删掉,以免冲突
[root@localhost ~]# unzip 1.zip

RAR

复制代码
#解压rar包#需要安装软件
yum install epel-release -y
yum install unar -y

#再进行解压
unar -o 解压路径 被解压文件路径

例如:
unar -o /opt 456.rar  
相关推荐
阿里云大数据AI技术19 小时前
阿里云 EMR AI 助手正式发布:从问答工具到全栈智能运维助手
运维·人工智能
你好潘先生1 天前
别再记命令了,用 yeero do 说句人话就能跑脚本,而且不烧 token
服务器·python·命令行
orion572 天前
Missing Semester Class1:course overview and introduction of shell
linux
SkyWalking中文站2 天前
认识 Horizon UI · 6/17:Trace 探索器
运维·监控·自动化运维
用户120487221612 天前
Linux驱动编译与加载
linux·嵌入式
程序员老赵2 天前
服务器文件不想 SFTP 上传?Docker 跑个 File Browser,浏览器就能管理
服务器·docker·开源
火车叼位2 天前
写给初级开发者:SSL、SSH、HTTPS 与证书体系全解析
运维
vivo互联网技术2 天前
从 10 分钟到 1 秒:ES 深度分页任意跳页的三轮优化实战
服务器·数据库·redis·elasticsearch·深度分页
用户805533698032 天前
Input 子系统架构:Core、Handler、Driver 三层是怎么协作的
linux·嵌入式