原文链接:https://rumenz.com/rumenbiji/linux-tar-skills.html
另:有些服务器没有安装zip包执行不了zip命令,但基本上都可以用tar命令的,实例如下:
ヘ^ヽ、 /⌒、 , |  ̄7 (⌒r⌒7/ レ \/ ̄\」 _/ { _フ ● ゝ _人 ο ● ナ `ト、_ メ /  ̄ ーィ゙ 〈゚・。。。・゚ 丶
最常用的打包 是 tar,使用 tar 程序打出来的包我们常称为 tar 包,tar 包文件的命令通常都是以 .tar 结尾的。生成 tar 包后,就可以用其它的程序来进行压缩了,所以首先就来讲讲 tar 命令的基本用法。
原文链接:https://rumenz.com/rumenbiji/linux-tar.html
tar zxvf ut6410-android2.1.tgz tar zcvf ut6410-android2.1.tgz ut6410-android2.1/ tar --exclude ut6410-android2.1/out -zcvf ut6410-android2.1.tgz ut6410-android2.1/ tar命令 [root@linux ~]# tar [-cxtzjvfpPN] 文件与目录 .... 参数: -c :建立一个压缩文件的参数指令(create 的意思); -x :
本文介绍了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种压缩文件进行操作
tar -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个。下面的参数是根据需要在压缩或解压档案时可选的。 -z:有gzip属性的 -j:有bz2属性的 -Z:有compress属性的 -v:显示所有过程 -O:将文件解开到标准输出 下面的参数-f是必须的 -f: 使用档案名字,切记,这个参数是最后一个参数,后面只能接档案名。 # tar -cf al
其原因是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的原因是因为可以压缩绝对路径。
这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个。
tar命令可以为linux的文件和目录创建档案。利用tar,可以为某一特定文件创建档案(备份文件),也可以在档案中改变文件,或者向档案中加入新的文件。tar最初被用来在磁带上创建档案,现在,用户可以在任何设备上创建档案。利用tar命令,可以把一大堆的文件和目录全部打包成一个文件,这对于备份文件或将几个文件组合成为一个文件以便于网络传输是非常有用的。
大致总结了一下linux下各种格式的压缩包的压缩、解压方法。但是部分方法我没有用到,也就不全,希望大家帮我补充,我将随时修改完善,谢谢!
文章目录 example.tar 类型文件 example.tar.gz / example.tgz 类型文件 example.tar.bz2 类型文件 example.tar.Z 类型文件 example.gz 类型文件 example.bz2 类型文件 example.zip 类型文件 example.tar 类型文件 打包 -c 表示创建包 ,-f指定包的文件名 tar -cf all.tar *.jpg 增加到包 -r 表示增加文件 tar -rf all.tar *.gif 替换包中文
-c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件
tar命令详解 -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个。 下面的参数是根据需要在压缩或解压档案时可选的。 -z:有gzip属性的 -j:有bz2属性的 -Z:有compress属性的 -v:显示所有过程 -O:将文件解开到标准输出 参数-f是必须的 -f: 使用档案名字,切记,这个参数是最后一个参数,后面只能接档案名。 # tar -cf all.tar
在Linux平台,tar是主要的打包工具。tar命令通常用来把文件和目录压缩为一个文件( tarball 或 tar, gzip 和 bzip)。
文章目录 打包压缩 打包 / 解包 打包解包演练 压缩/解压缩 1) `gzip` 2) `bzip2(two)` 打包压缩 打包压缩 是日常工作中备份文件的一种方式 在不同操作系统中,常用的打包压缩方式是不同的 Windows 常用 rar Mac 常用 zip Linux 常用 tar.gz 打包 / 解包 tar 是 Linux 中最常用的 备份工具,此命令可以 把一系列文件 打包到 一个大文件中,也可以把一个 打包的大文件恢复成一系列文件 tar 的命令格式如下: # 打包文件 ta
tar命令允许你创建和解压缩 tar 包。它支持很多压缩算法,例如 gzip, bzip2, lzip, lzop, xz 和 compress。
把常用的tar解压命令总结下,当作备忘: tar -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个。下面的参数是根据需要在压缩或解压档案时可选的。 -z:有gzip属性的 -j:有bz2属性的 -Z:有compress属性的 -v:显示所有过程 -O:将文件解开到标准输出 下面的参数-f是必须的 -f: 使用档案名字,切记,这个参数是最后一个参数,后
tar 命令常常用于打包、压缩某些文件或目录,也可以添加新文件到归档文件中。Tar 代表的是磁带存档,是一种归档的文件格式,早期用于将文件归档到磁带备份存储。现可以用于收集、分发、归档文件,还可以保留文件原有的属性,如:用户和组权限,访问和修改日期以及目录结构。
下面我们就分别讲一下在 Linux 下如何用不同的方式对文件进行打包、压缩和解压缩
通过SSH访问服务器,难免会要用到压缩,解压缩,打包,解包等,这时候tar命令就是是必不可少的一个功能强大的工具 tar命令可以为linux的文件和目录创建档案。利用tar,可以为某一特定文件创建档案(备份文件),也可以在档案中改变文件,或者向档案中加入新的文件。tar最初被用来在磁带上创建档案,现在,用户可以在任何设备上创建档案。利用tar命令,可以把一大堆的文件和目录全部打包成一个文件,这对于备份文件或将几个文件组合成为一个文件以便于网络传输是非常有用的。 打包和压缩 打包是指将一大堆文件或目录变成一个
本文包括:语法介绍、使用示例、通过file命令确定文件的压缩格式、通过MD5检验比较两个tar包是否一致、批量压缩和解压缩。
因为不可能同时压缩与解压缩。 -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 打包!
Linux 系统中,最常用的归档(打包)命令就是 tar,该命令可以将许多文件一起保存到一个单独的磁带或磁盘中进行归档。不仅如此,该命令还可以从归档文件中还原所需文件,也就是打包的反过程,称为解打包。
Linux下用户经常需要备份计算机系统中的数据,为了节省存储空间,常常将备份文件进行压缩,本文是对压缩和解压命令的大致总结
搬运[置顶]:https://www.cnblogs.com/sui776265233/p/10185402.html
注意:使用tar命令,打包仅仅是打包xxx.tar,打包并压缩就是xxxx.tar.gz,打包压缩的文件一定要指定文件格式,这样解包解压才好用对应的参数来解包解压缩,注意压缩包文件名和源文件位置不要颠倒了。
在处理文件和数据传输时,文件的压缩和打包技术是必不可少的一部分。Go语言提供了archive/tar包,允许开发者在程序中创建和管理TAR文件,这种文件格式支持将多个文件合并为一个单独的文件(TAR档案),常见于Unix和Linux系统中。本文将深入探讨如何使用Go语言的archive/tar包来创建和提取TAR文件,同时结合实例和UML图解,让读者对archive/tar包有更全面的了解。
bzip2和gzip的使用方法差不多,而且压缩后源文件消失,解压后压缩文件消失。bzip2多一个特色功能bzcat,可以查看压缩文件的内容
为了实现对多个文件或目录的压缩操作,可以使用tar命令将多个文件或目录归档为一个文件,然后再使用压缩命令对该归档文件进行压缩。
tar命令用于将多个文件合成1个文件,wiki中把这个命令和cpio、shar等一起叫做archive文件,个人理解是归档,合成一个文件,后就可以用gzip、bz2、xz等工具进行压缩,同时也能方便在各个计算机间传输,有点类似windows下共享的zip文件。
tar 是 GNU 项目中的一个归档工具,其创建可以追溯到磁带机的年代,可谓历史悠久。虽然 tar 工具最初是用于磁带机的数据归档,但其现在也支持磁盘的数据归档,而且仍然保留着对磁带机的兼容。tar 工具一路发展过来,经过很多大佬的打磨,功能强大,现在已经是 Linux 系统上默认的数据归档工具。
使用该命令时,主选项是必须要有的,它告诉tar要做什么事情,辅选项是辅助使用的,可以选用。 主选项: c 创建新的档案文件。如果用户想备份一个目录或是一些文件,就要选择这个选项。相当于打包。
Linux tar.gz zip 解压缩 压缩命令 这条命令是将所有.jpg的文件打成一个名为all.tar的包。-c是表示产生新的包,-f指定包的文件名。 tar -cf all.tar *.jpg 这条命令是将所有.gif的文件增加到all.tar的包里面去。-r是表示增加文件的意思。 tar -rf all.tar *.gif 这条命令是更新原来tar包all.tar中logo.gif文件,-u是表示更新文件的意思。 tar -uf all.tar logo.gif 这条命令是列出all.t
6.5 zip压缩工具 zip目录概要 zip支持压缩目录 zip 1.txt.zip 1.txt 压缩文件 zip -r 123.zip 123/ 压缩文件到指定目录下 unzip 1.txt.zip 解压文件 unzip 123.zip -d /root/456/ 解压文件到制定目录 unzip -l 123.zip 查看压缩文件列表 zip压缩文件或目录 在linux和windows中都有一个zip压缩工具,但是linux下不支持解压windos下的rar文件(默认不支持,需要安装工具才可以) 安装z
由于这是每一个 Linux用户都会经常用到的基本功能,因此我们将介绍最常见到的打 包、压缩和解压缩程序。 打包文件的tar命令 tar命令位于/bin目录中,它能将用户所指定的文件或目录打包成一个文件,不过它并 不做压缩。一般Unix上常用的压缩方式是先用tar命令将许多文件打包成一个文件,再以gzip等压缩命令压缩文件。 tar命令参数繁多,以下举例常用参数作说明:
1.压缩命令: 命令格式:tar -zcvf 压缩文件名.tar.gz 被压缩文件名 可先切换到当前目录下。压缩文件名和被压缩文件名都可加入路径。 2.解压缩命令: 命令格式:tar -zxvf 压缩文件名.tar.gz 解压缩后的文件只能放在当前的目录。 3.Linux下如何解压tar.bz2文件 在linux用下面命令解压 tar jxvf 文件名.tar.bz2 压缩 tar –cvf jpg.tar *.jpg 将目录里所有jpg文件打包成tar.jpg tar –czf
Linux 系统中,最常用的归档(打包)命令就是 tar,该命令可以将许多文件一起保存到一个单独的磁带或磁盘中进行归档。不仅如此,该命令还可以从归档文件中还原所需文件,也就是打包的反过程,称为解打包。
linux下使用tar命令 解压 语法:tar [主选项+辅选项] 文件或者目录 使用该命令时,主选项是必须要有的,它告诉tar要做什么事情,辅选项是辅助使用的,可以选用。 主选项: c 创建新的档案文件。如果用户想备份一个目录或是一些文件,就要选择这个选项。相当于打包。 x 从档案文件中释放文件。相当于拆包。 t 列出档案文件的内容,查看已经备份了哪些文件。 特别注意,在参数的下达中, c/x/t 仅能存在一个!不可同时存在!因为不可能同时压缩与解压缩。 辅助选项: -z :是否同时具有 gzip
上面说的是打包.是指文件可以合并到一起.但不能压缩. 压缩有两种方式,一种是 gzip 一种是bzip2 (2念做two)
通过SSH访问服务器,难免会要用到压缩,解压缩,打包,解包等,这时候tar命令就是是必不可少的一个功能强大的工具。linux中最流行的tar是麻雀虽小,五脏俱全,功能强大。
1. 在 Linux 中创建 tar 存档文件 下面的示例命令将创建一个tar存档文件rumenz-14-09-12.tar对于目录/home/rumenz在当前工作目录中。请参阅示例命令的操作。 # tar -cvf rumenz-14-09-12.tar /home/rumenz/ /home/rumenz/ /home/rumenz/cleanfiles.sh /home/rumenz/openvpn-2.1.4.tar.gz /home/rumenz/rumenz-14-09-12.tar /ho
领取专属 10元无门槛券
手把手带您无忧上云