In Linux, we commonly use the following compression formats: .tar
, .tar.bz2
, .tar.gz
.
Installing 7ZIP Software on Windows#
Since many files in Linux are compressed files with .bz2
and .gz
extensions, it is necessary to install 7ZIP software on Windows.
gzip Compression Tool#
gzip is a tool used to compress and decompress .gz
format files.
- Compress file:
gzip xxx
- Decompress file:
gzip -d xxx.gz
- Compress folder:
gzip -r xxx
- Decompress folder:
gzip -rd xxx.gz
It is important to note that although gzip can compress folders, it does not provide packaging functionality. Instead, it compresses each file in the folder individually.
bzip2 Compression Tool#
Similar to gzip, bzip2 is used to compress and decompress .bz2
format files.
- Compress file:
bzip2 -z xxx
- Decompress file:
bzip2 -d xxx.gz
tar Packaging Tool#
tar is a packaging tool that can bundle multiple files into one file.
tar provides the following parameters:
-f
: Use archive file or ARCHIVE device-c
: Create a new archive, i.e., create a compressed file-x
: Extract files from the archive, i.e., decompress-j
: Use bzip2 compression format-z
: Use gzip compression format-v
: Display the execution process of the command
Examples of using tar for packaging and unpackaging operations:
- Package file:
tar -vcf test.tar test
- Unpackage file:
tar -vxf test.tar
It is important to note that in addition to providing packaging and unpackaging functionality, tar can also be combined with gzip or bzip2 for compression, achieving similar functionality to the winRAR software in Windows.
Compression and Decompression of Other Formats#
-
.rar format: In Linux, you need to install rar first:
sudo apt-get install rar
- Decompress:
rar x xxx.rar
- Compress:
rar a xxx.rar xxx
- Decompress:
-
.zip format: Use the zip command for compression and decompression
- Compress:
zip -rv xxx.zip xxx
- Decompress:
unzip -v xxx.zip
- Compress:
This article is synchronized and updated to xLog by Mix Space.
The original link is https://api.lolimiao.run/posts/Linux-Study/LS5