1. gzip
Only single files can be compressed, but not directories.
Quick compression of individual files, especially for text files
- Compress a single file
gzip -> The original changed to directly, the source file is not retained
- Decompress a single file
gunzip -> The file before compression is not retained, it becomes
2. bizp2
Only single files can be compressed, but not directories.
Provides higher compression ratios, especially for files with higher data redundancy.
This means that despite the slower compression process, the file size can be compressed smaller, suitable for occasions where extreme space optimization is required.
- Compress a single file
bzip2 -> .bz2 file The file before compression is not retained, it becomes
- Decompress a single file
bunzip2.bz2 -> File The file before decompression is not retained, it becomes
3. tar
Package the directory. No compression is provided, and the size after packaging has not changed.
Usually, the directory is packaged first and then compressed with gzip and bzip2.
Usually we need to compress the entire folder. The first two commands can only compress a single file. If you want to compress a folder, you need to package the folder into a file type before you can compress the file.
- Package folders
Package the hello folder in the current directory into a file and store it in the current directory, and the source folder will be retained.
tar -cf hello -> File
- Unpack the file
Unpack the file into a hello folder and store it in the current directory.
tar -xf -> hello folder
- General integration
The most commonly used combination of packaging and compression commands.
If you want to use bzip2, just replace it with: -jzcf | -jzxf
- Directly pack and compress folders
Package and compress the hello folder in the current directory into
tar -zcf hello -> File
- Directly unpack and unzip the folder
Unpack and unzip the files in the current directory into hello folder
tar -zxf -> hello folder
4. Zip
Cross-platform compatibility.
Ideal for fast packaging of multiple files or entire directory structures.
- Directly compress the entire folder
zip -r hello -> Compress the hello folder in the current directory into
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.