加入收藏 | 设为首页 | 会员中心 | 我要投稿 财气旺网 - 财气网 (https://www.caiqiwang.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

4.1 打包和压缩的概念和区别

发布时间:2022-10-30 17:31:59 所属栏目:Linux 来源:互联网
导读: 在解释具体的存档和压缩命令之前,让我们先来看看存档和压缩的含义。
[En]
Before we explain the specific archiving and compression commands, let’s take a look at what archiving a

在解释具体的存档和压缩命令之前,让我们先来看看存档和压缩的含义。

[En]

Before we explain the specific archiving and compression commands, let’s take a look at what archiving and compression represent.

存档,也称为打包,指的是存储在文件中的文件或目录的集合。存档文件未压缩,因此它占据了其中所有文件和目录的总和的空间。

[En]

Archiving, also known as packaging, refers to a collection of files or directories that are stored in a file. The archive file is not compressed, so it takes up the space of all the files and directories in it combined.

通常,归档总是会和系统(数据)备份联系在一起,不过,有关数据备份的内容,留到后续章节讲,本章仅学习归档命令的基本使用。

像归档文件一样,压缩文件是文件和目录的集合,该集合也存储在文件中,但它们的不同之处在于压缩文件的存储方式不同。它占用的磁盘空间少于集合中所有文件大小的总和。

[En]

Like an archive file, a compressed file is a collection of files and directories, and this collection is also stored in a file, but they are different in that compressed files are stored in different ways. it takes up less disk space than the sum of all the file sizes in the collection.

压缩是指利用算法将文件进行处理,已达到保留最大文件信息linux压缩,而让文件体积变小的目的。其基本原理为,通过查找文件内的重复字节,建立一个相同字节的词典文件,并用一个代码表示。比如说,在压缩文件中,有不止一处出现了 “C语言中文网”,那么,在压缩文件时,这个词就会用一个代码表示并写入词典文件,这样就可以实现缩小文件体积的目的。

由于计算机处理的信息是以二进制形式表示的,压缩软件在二进制信息中用特殊字符标记相同的字符串,只要通过合理的数学计算,文件的体积就可以得到很大的压缩。使用压缩软件对一个或多个文件进行压缩,形成一个文件压缩包,可以节省存储空间,方便网络传输。

[En]

Because the information processed by the computer is expressed in binary form, the compression software marks the same string in the binary information with special characters, as long as through reasonable mathematical calculation, the volume of the file can be greatly compressed. Compress one or more files with compression software to form a file compression package, which can save storage space and facilitate transmission on the network.

如果你能够理解文件压缩的基本原理,那么很容易就能想到,对文件进行压缩,很可能损坏文件中的内容,因此,压缩又可以分为有损压缩和无损压缩。无损压缩很好理解,指的是压缩数据必须准确无误;有损压缩指的是即便丢失个别的数据,对文件也不会造成太大的影响。有损压缩广泛应用于动画、声音和图像文件中,典型代表就是影碟文件格式 mpeg、音乐文件格式 mp3 以及图像文件格式 jpg。

压缩工具用于压缩文件,生成的文件称为压缩包,其大小通常是原始文件的一半或更小。需要注意的是,压缩包中的数据不能直接使用。在使用之前,您需要使用压缩工具来恢复文件数据。这一过程也称为解压缩。

[En]

The compression tool is used to compress the file, and the resulting file is called a compression package, which is usually half the size of the original file or even smaller. It should be noted that the data in the compression package can not be used directly. Before use, you need to use the compression tool to restore the file data. This process is also called decompression.

Linux 下,常用归档命令有 2 个,分别是 tar 和 dd(相对而言,tar 的使用更为广泛);常用的压缩命令有很多,比如 gzip、zip、bzip2 等。这些命令的详细用法,后续文件会做一一介绍。

注意,tar 命令也可以作为压缩命令,也很常用。

Original:

Author: 开源Linux

Title: 4.1 打包和压缩的概念和区别

(编辑:财气旺网 - 财气网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!