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  
相关推荐
LH_R21 小时前
OneTerm开源堡垒机实战(四):访问授权与安全管控
运维·后端·安全
用户31187945592181 天前
Kylin Linux 10 安装 glib2-devel-2.62.5-7.ky10.x86_64.rpm 方法(附安装包)
linux
Raymond运维1 天前
MariaDB源码编译安装(二)
运维·数据库·mariadb
涛啊涛1 天前
Centos7非LVM根分区容量不足后扩容,对调硬盘挂载/
linux·磁盘管理
JuiceFS2 天前
从 MLPerf Storage v2.0 看 AI 训练中的存储性能与扩展能力
运维·后端
CYRUS_STUDIO2 天前
用 Frida 控制 Android 线程:kill 命令、挂起与恢复全解析
android·linux·逆向
熊猫李2 天前
rootfs-根文件系统详解
linux
chen9452 天前
mysql 3节点mgr集群部署
运维·后端
LH_R2 天前
OneTerm开源堡垒机实战(三):功能扩展与效率提升
运维·后端·安全
dessler2 天前
Hadoop HDFS-高可用集群部署
linux·运维·hdfs