Ubuntu uses gzip and bzip2 and rar and tar to compress and decompress

Table of contents

1. gzip compression and decompression

2. bzip2 compression and decompression

3. rar compression and decompression

tar archive compression and decompression package


1. gzip compression and decompression

Because they are all included in the system, we don't need to install them;

ls Look at the current files in the directory and create a touch 123.txt file;

gzip for compression, ("gzip 123.txt"), so the compression is complete;

The original file has disappeared, and the generated file is 123.txt.gz;

gzip to decompress, ("gzip -d 123.txt.gz"), so that the decompression is complete;

2. bzip2 compression and decompression

Because they are all included in the system, we don't need to install them;

bzip2 for compression, (" bzip2 -k 123.txt "), so that the compression is complete;

The original file is kept, and the generated file is 123.txt.bz2;

bzip2 to decompress, ("bzip2 -k -d 123.txt.bz2"), so the decompression is complete;

3. rar compression and decompression

First you need to install it, ("sudo apt install rar"), verify the password to install;

You also need to install the decompression tool, ("sudo apt intsall unrar");

rar for compression, ("rar a 123.rar"), so the compression is complete;

Unrar to decompress, ("unrar e 123.rar"), so that the decompression is complete;

tar archive compression and decompression package

The tar command can pack one or more files and folders into one file;

The file can be in tar format with a .tar extension: ("tar -cvf test.tar test1 test2 test3");

To extract a tar file, you can use the following command: ("tar -xvf test.tar");

tar compression format, with .tar.gz or .tgz extension: ("tar -cvf test.tar.gz test1 test2 test3");

To uncompress a tar.gz file, you can use the following command: ("tar -xvf test.tar.gz");

Guess you like

Origin blog.csdn.net/m0_67906358/article/details/130464914