Introduction to Linux File Compression and Packaging

Introduction to Linux File Compression and Packaging

1. Introduction to compression and packaging

Common compressed files

windows .rar .zip .7z

Linux .zip, .gz, .bz2, .xz, .tar.gz, .tar.bz2, .tar.xz

2. gzip compression tool

Eg. gzip and gzip-d examples

In the following example, it can be seen that after compression, the actual size of the file changes from 1.6M to 1.3M after decompression, and the number of rows remains unchanged.

Gzip -# indicates compression level 1.txt (range 1-9, default 6, increasing from 1 to 9)

zacat 1.txt.gz is the command to view the compressed file. The operation process is to decompress it first and then view it.

gzip -c 1.txt > /root/1.txt.gz means to decompress 1.txt to root and keep the original file 1.txt

bzip2 compression tool

Compared with gzip, the compression strength is stronger and the algorithm is different. The stronger the compression strength, the more CPU resources are consumed. The default level specified by bizp is 9.

Note the following example, which proves that compressed files can be renamed. If you see a binary file when viewing a txt file, you should use file to view the file first.

xz compression tool

Not commonly used, but you may see .tar.xz in tarballs. It has stronger compression than bzip.

zip compression tool

The characteristic of zip is that the original file is not deleted after compression

There is no way to view the contents of a zip archive. You can only view the file list instead of the contents through unzip -l

tar packaging tool

The tar tool is more commonly used on Linux. Tar was originally just a packaging tool, but it also supports 7z, gzip, xz, bzip2 and other tools. These compression tools can only compress files or directories (compress files in a directory separately), but do not realize the packaging and compression of files. Therefore, we do not need to learn several other tools separately. The decompression and compression of tar are the same command, only the parameters are different, which is more convenient to use.

Packaging does not significantly change the file size. The purpose is to integrate all types of files into one large file for easy transmission.

tar -tf fred.tar View the file list, equivalent to unzip -l

Pack and compress, unpack and decompress

You may also be interested in:
  • Detailed explanation of the use of Linux packaging and compression tools
  • A brief analysis of the Linux packaging, compression and decompression commands (collection)
  • Detailed discussion on Linux packaging and compression and tar command
  • How to decompress or compress files in Linux
  • How to use Linux tar compression and packaging command

<<:  MySQL uses inet_aton and inet_ntoa to process IP address data

>>:  Three.js sample code for implementing dewdrop animation effect

Recommend

Detailed explanation of TypeScript's basic types

Table of contents Boolean Type Number Types Strin...

Detailed explanation of data types in JavaScript basics

Table of contents 1. Data Type 1.1 Why do we need...

Tutorial on installing MySQL 5.7.28 on CentOS 6.2 (mysql notes)

1. Environmental Preparation 1.MySQL installation...

How to locate MySQL slow queries

Preface I believe that everyone has had experienc...

Configure Mysql master-slave service implementation example

Configure Mysql master-slave service implementati...

Detailed tutorial on MySql installation and uninstallation

This article shares the tutorial of MySql install...

Ubuntu installs multiple versions of CUDA and switches at any time

I will not introduce what CUDA is, but will direc...

CSS uses the autoflow attribute to achieve seat selection effect

1. Autoflow attribute, if the length and width of...

MySQL index pushdown details

Table of contents 1. Leftmost prefix principle 2....

Two query methods when the MySQL query field type is json

The table structure is as follows: id varchar(32)...

Docker image creation Dockerfile and commit operations

Build the image There are two main ways to build ...

Axios cancel request and avoid duplicate requests

Table of contents origin status quo Cancel reques...

DOCTYPE element detailed explanation complete version

1. Overview This article systematically explains ...