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  
相关推荐
浪裡遊1 小时前
跨域问题(Cross-Origin Problem)
linux·前端·vue.js·后端·https·sprint
Johny_Zhao2 小时前
OpenStack 全套搭建部署指南(基于 Kolla-Ansible)
linux·python·信息安全·云计算·openstack·shell·yum源·系统运维
2401_867021902 小时前
文件缓冲区(IO与文件 ·III)(linux/C)
linux·运维·服务器·c语言
刘某的Cloud2 小时前
rabbitmq常用命令
linux·运维·分布式·rabbitmq·系统
悄悄敲敲敲2 小时前
Linux:进程间通信->命名管道
linux·运维·服务器
望获linux3 小时前
智能清洁机器人中的实时操作系统应用研究
大数据·linux·服务器·人工智能·机器人·操作系统
io无心3 小时前
Docker绑定端口报错
运维·docker·容器
悄悄敲敲敲5 小时前
Linux:进程间通信->共享内存
linux·运维·服务器
绵绵细雨中的乡音5 小时前
Linux进程学习【环境变量】&&进程优先级
linux·运维·学习
天下·第二5 小时前
【Nginx】负载均衡配置详解
运维·nginx·负载均衡