Methods of compression and decompression in Linux

Gongora

Newbie


In order to package files, we use the following command:​
Tar -cvf file.tar / dir / a / compress /


[align=justify]In order to untar the .tar files, we use the following command:​
Tar -xvf file.tar


[align=justify]If you want to see the contents of a .tar file, the following command is used:​
Tar -tf file.tar


[align=justify]​

To compress files in .gz format, the following command is used:​
Gzip -9 file


[align=justify]To decompress .gz files, the following command will be used:​
Gzip -d file.gz


[align=justify]​

To compress files in bz2 format, the following command is used:​
Bzip file

To decompress .bz2 files, use the following command:​
Bzip2 -d file.bz2

-d: indicates decompression.​

Note:​

To compress files in tar.gz format, the following command is used:​
Tar -czfv file.tar.gz files


[align=justify]To decompress files with tar.gz extension, use the following command:​
Tar -xzvf file.tar.gz


[align=justify]In order to see the contents of a compressed file in tar.gz, the following command is used:​
Tar -tzf file.tar.gz

[align=justify]

To decompress tar.bz2 files, the following command is used:​

And to see the contents of a tar.bz2 file, use the following command:​


In order to compress in zip format, the following command will be used:​
Zip file.zip files to compress

In order to unzip the zip files, the following command is used:​
Unzip archive.zip

To see the contents of a zip file, put the following command:​
Unzip -v zip.zip

Rar files

To compress in rar format, the following command will be used:​
Rar -a file.rar files

To decompress files in rar format, the following command is used:​
Unrar -x file.rar

To view the contents of a rar file, use the following command:​
Unrar -v file.rar
Unrar -l file.rar
 
Top