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

Linux uses iftop to monitor network card traffic in real time

Linux uses iftop to monitor the traffic of the ne...

Analysis of MySQL cumulative aggregation principle and usage examples

This article uses examples to illustrate the prin...

MySQL foreign key (FOREIGN KEY) usage case detailed explanation

Introduction: The disadvantages of storing all da...

JavaScript static scope and dynamic scope explained with examples

Table of contents Preface Static scope vs. dynami...

Vue makes div height draggable

This article shares the specific code of Vue to r...

win10 docker-toolsbox tutorial on building a php development environment

Download image docker pull mysql:5.7 docker pull ...

Analysis of a MySQL deadlock scenario example

Preface Recently I encountered a deadlock problem...

Examples of using && and || operators in javascript

Table of contents Preface && Operator || ...

Analysis of the implementation principle of Vue instructions

Table of contents 1. Basic Use 2. Working Princip...

The front-end must know how to lazy load images (three methods)

Table of contents 1. What is lazy loading? 2. Imp...

How to display web pages properly in various resolutions and browsers

The key codes are as follows: Copy code The code i...

Several solutions for forgetting the MySQL password

Solution 1 Completely uninstall and delete all da...

Implementation of navigation bar and drop-down menu in CSS

1. CSS Navigation Bar (1) Function of the navigat...