1. 压缩格式的介绍 Linux默认支持的压缩格式: .gz .bz2 .zip 说明: .gz和.bz2的压缩包需要使用tar命令来压缩和解压缩 .zip的压缩包需要使用zip命令来压缩,使用unzip命令来解压缩 压缩目的: 节省磁盘空间 2. tar命令及选项的使用 命令 说明 tar 压缩和解压缩命令 tar命令选项: 选项 说明 -c 创建打包文件 -v 显示打包或者解包的详细信息 -f 指定文件名称, 必须放到所有选项后面 -z 压缩或解压缩(.gz) -j 压缩或解压缩(.bz2) -x
这将分别生成file1.txt.bz2、file2.txt.bz2、file3.txt.bz2等压缩文件。
常用压缩格式:.zip, .gz ,.bz2,tar.gz, .tar.bz2 Linux中常用的软件包都是用红色展示的 压缩文件不一定比原文件小,因为压缩文件还包括压缩格式,当原文件比较小时,压缩文件可能会比原文件大
tar命令可以为linux的文件和目录创建档案。利用tar,可以为某一特定文件创建档案(备份文件),也可以在档案中改变文件,或者向档案中加入新的文件。tar最初被用来在磁带上创建档案,现在,用户可以在任何设备上创建档案。利用tar命令,可以把一大堆的文件和目录全部打包成一个文件,这对于备份文件或将几个文件组合成为一个文件以便于网络传输是非常有用的。
在linux下最常见的压缩文件通常都是以.tar.gz 为结尾的,除此之外还有.tar .gz .bz2 .zip等等
在Linux中,查找文件的也需要这两个条件,不同于Windows使用搜索框查找,Linux中使用 find 命令查找文件。
本专栏由小雨ttt创建,致力于分享学习Linux基础知识的过程。本专栏不是机械地介绍Linux指令集,而是包含了作者亲自实践的操作过程,站在一个初学者的角度理解Linux基础知识。
当 tar 命令用于打包操作时,该命令的基本格式为:tar [选项] 源文件或目录 tar 打包命令常用选项及含义
tar -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个。下面的参数是根据需要在压缩或解压档案时可选的。 -z:有gzip属性的 -j:有bz2属性的 -Z:有compress属性的 -v:显示所有过程 -O:将文件解开到标准输出 下面的参数-f是必须的 -f: 使用档案名字,切记,这个参数是最后一个参数,后面只能接档案名。 # tar -cf al
这样,所有/root/test下面的文件都变成了*.gz,目录依然存在只是目录里面的文件相应变成了*.gz.这就是压缩,和打包不同。因为是对目录操作,所以需要加上-r选项,这样也可以对子目录进行递归了。
本文介绍了linux下的压缩程式tar、gzip、gunzip、bzip2、bunzip2、compress 、uncompress、 zip、 unzip、rar、unrar等程式,以及如何使用它们对.tar、.gz 、.tar.gz、.tgz、.bz2、.tar.bz2、.Z、. tar.Z、.zip、.rar这10种压缩文件进行操作
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
ヘ^ヽ、 /⌒、 , |  ̄7 (⌒r⌒7/ レ \/ ̄\」 _/ { _フ ● ゝ _人 ο ● ナ `ト、_ メ /  ̄ ーィ゙ 〈゚・。。。・゚ 丶
由于换行符(为不可见字符),在 Windows 为 CR+LF(Carriage-Return+Line-Feed:回车加换行),而在 Linux/Unix 上为 LF(换行)。因此在linux 编辑的文本,在windows 显示会是没有换行的。
.zip,.gz,.bz2,.xz, .tar.gz,.tar.bz2,.tar.xz
5G 来了,5G 是未来的一个驱动力。比 5G 更重要的一个是 AI,我们赢了 5G,并不代表我们赢了未来。
打包是指将多个文件或者目录放在一起,形成一个总的包,这样便于保存和传输,但是大小是没有变化的,压缩是指将一个或者多个大文件或者目录通过压缩算法使文件的体积变小以达到压缩的目的,可以节省存储空间,在压缩的时候通常是先打包再压缩;
打包:指将多个文件(或目录)合并成一个文件,方便在不同节点之间传递或在服务器集群上部署。
其原因是tar默认为相对路径,使用绝对路径的话就回报这个错,可以使用-P参数(注意大写)解决这个问题 [root@localhost test]# tar zcvf services_(date +%F-%H).tar.gz /etc/services tar: Removing leading `/’ from member names /etc/services //上边之所以会报这个错误是因为tar 默认压缩的文件为当前目录下的文件也就是相对路径,而不能用绝对路径 正确的方法: [root@localhost test]# tar zcvfP services_(date +%F-%H).tar.gz /etc/services tar: Removing leading `/’ from member names /etc/services //上边之所以会报这个错误是因为tar 默认压缩的文件为当前目录下的文件也就是相对路径,而不能用绝对路径 正确的方法: [root@localhost test]# tar zcvfP services_(date +%F-%H).tar.gz /etc/services tar: Removing leading `/’ from member names /etc/services //上边之所以会报这个错误是因为tar 默认压缩的文件为当前目录下的文件也就是相对路径,而不能用绝对路径 正确的方法: [root@localhost test]# tar zcvfP services_(date +%F-%H).tar.gz /etc/services 解释:加上P的原因是因为可以压缩绝对路径。
大致总结了一下linux下各种格式的压缩包的压缩、解压方法。但是部分方法我没有用到,也就不全,希望大家帮我补充,我将随时修改完善,谢谢!
15、.tar .tgz .tar.gz .tar.Z .tar.bz .tar.bz2 .zip .cpio .rpm .deb .slp .arj .rar .ace .lha .lzh .lzx .lzs .arc .sda .sfx .lnx .zoo .cab .kar .cpt .pit .sit .sea
简介 Linux 上常用的压缩/解压工具,介绍了zip、rar、tar的使用。 文件打包和压缩 Linux 上的压缩包文件格式,除了 Windows 最常见的*.zip、*.rar、.7z 后缀的压缩文件,还有 .gz、.xz、.bz2、.tar、.tar.gz、.tar.xz、tar.bz2
ls -a 查询所有子目录和文件,包括隐藏文件【隐藏文件以“.”开头的文件】
r:recursive,递归地,即复制所有文件 f:force,强制覆盖 d:如果源文件为链接文件,也只是把它作为链接文件复制过去,而不是复制实际文件
find 命令用于在指定目录下查找文件和目录。它提供了强大的搜索功能,可以根据不同的条件进行文件搜索和匹配。它可以在指定的起点目录及其子目录中递归搜索,根据文件名、大小、修改时间、权限等多种属性进行筛选。
.tar 解包:tar xvf FileName.tar 打包:tar cvf FileName.tar DirName (注:tar是打包,不是压缩!) ——————————————— .gz 解压1:gunzip FileName.gz 解压2:gzip -d FileName.gz 压缩:gzip FileName .tar.gz 和 .tgz 解压:tar zxvf FileName.tar.gz 压缩:tar zcvf FileName.tar.gz DirName —————————————
.tar 解包:tar xvf FileName.tar 打包:tar cvf FileName.tar DirName (注:tar是打包,不是压缩!) ——————————————— .gz 解压1:gunzip FileName.gz 解压2:gzip -d FileName.gz 压缩:gzip FileName
原文链接:https://rumenz.com/rumenbiji/linux-tar-skills.html
http://linuxtools-rst.readthedocs.org/zh_CN/latest/base/index.html 命令帮助 如果只记得某个命令的一部分,可以使用 man -k 来搜索符合要求的命令及简要说明. 例如, 123456789101112ubuntu@ubuntu:~$ man -k iptaip6tables-apply (8) - a safer way to update iptables remotelyip6tables-save (8) - dump ipt
Linux中最常见的压缩格式有:.zip .gz .bz2 .tar.gz .tar.bz2 .xz .rar .tgz
.tar 解包:tar xvf FileName.tar 打包:tar cvf FileName.tar DirName (注:tar是打包,不是压缩!) ——————————————— .gz 解压1:gunzip FileName.gz 解压2:gzip -d FileName.gz 压缩:gzip FileName .tar.gz 和 .tgz 解压:tar zxvf FileName.tar.gz 压缩:tar zcvf FileName.
前一个命令的输出,作为后一个命令的输入。最后一个命令会在当前shell进程的子shell进程中执行
软链接:类似于Windows下的快捷方式,当一个源文件的目录层级比较深,我们想要方便给源文件创建一个软链接。可以指向目录。
在Linux中可以识别的常见压缩格式有几十种,比如.zip、.gz、.bz2、.tar、.tar.gz、.tar.bz2等,Linux不支持.rar和.tz格式的压缩文件。 1、.zip格式:zip是Windows中最常见的压缩格式,Linux也可以正确识别,zip命令所在目录为/usr/bin/zip,所有用户可以执行,用来压缩文件或目录 命令格式:
因为不可能同时压缩与解压缩。 -z :是否同时具有 gzip 的属性?亦即是否需要用 gzip 压缩? -j :是否同时具有 bzip2 的属性?亦即是否需要用 bzip2 压缩? -v :压缩的过程中显示文件!这个常用,但不建议用在背景执行过程! -f :使用档名,请留意,在 f 之后要立即接档名喔!不要再加参数! 例如使用『 tar -zcvfP tfile sfile』就是错误的写法,要写成 『 tar -zcvPf tfile sfile』才对喔! -p :使用原文件的原来属性(属性不会依据使用者而变) -P :可以使用绝对路径来压缩! -N :比后面接的日期(yyyy/mm/dd)还要新的才会被打包进新建的文件中! –exclude FILE:在压缩的过程中,不要将 FILE 打包!
bzip2命令用于创建和管理(包括解压缩)“.bz2”格式的压缩包。我们遇见Linux压缩打包方法有很多种,以下讲解了Linux压缩打包方法中的Linux bzip2命令的多种范例供大家查看,相信大家看完后会有很多收获。
Linux下用户经常需要备份计算机系统中的数据,为了节省存储空间,常常将备份文件进行压缩,本文是对压缩和解压命令的大致总结
在Linux平台,tar是主要的打包工具。tar命令通常用来把文件和目录压缩为一个文件( tarball 或 tar, gzip 和 bzip)。
注意:v参数是可选参数,表示是否显示压缩/解压过程。 注意:用什么参数必须用配套的命名,否则难以识别用什么方式解压;
本篇博客介绍了如何在Linux系统中使用压缩和解压缩命令,将文件或目录压缩为gzip、tar、zip和bzip2格式,并介绍了如何使用这些命令进行文件或目录的压缩和解压操作。
zipfile.ZipFile(file, mode='r', compression=0, allowZip64=True, compresslevel=None)
压缩解压命令 .gz gzip 英文 GNU zip 功能描述 压缩文件 压缩后的格式 .gz 语法 gzip [文件] 举例: gzip helloWorld.go # 将 helloWorld.go 文件进行压缩,得到 helloWorld.go.gz ps: gzip 只能压缩文件,不能压缩目录 gzip 压缩文件后,源文件消失 ---- gunzip 英文 GNU unzip 功能描述 解压 .gz 文件 语法 gunzip [压缩文件] 举例: gunzip hell
6.1 压缩打包介绍 家用带宽和机房带宽的区别: 家用的IP是动态的、不固定的,而机房的IP却是固定不变的 家用的上传和下载带宽也是不同的;而在机房中的带宽,下载和上传带宽都是相同的 举例:家用—>联通的百兆宽带,指的是下载的速度是一百兆,而上传一般只有10M到20M 常见压缩文件 windows系统中,常见的压缩文件有 .rar, .zip, .7z linux系统中,常见的压缩文件有 .zip, .gz, .bz2, .xz, .tar.gz, .tar.bz2, .tar.xz 压缩后优
本篇文章,我将结合自己的实践以及简介,来对linux系统做一个直观清晰的介绍,使得哪些刚接触Linux的小伙伴可以快速入门,也方便自己以后进行复习查阅。
显示指定目录下的内容,缺省为当前目录,-a参数显示所有文件(包括隐藏文件),-l参数显示文件的详细信息
locate:定位文件和目录【locate命令使用数据库来定位带有test这个词的文件或目录】
详见:[Linux 打印文本部分行内容(前几行,指定行,中间几行,跨行,奇偶行,后几行,最后一行,匹配行)]()
领取专属 10元无门槛券
手把手带您无忧上云