!DOCTYPE html> Tar-Zip-Rar

Update on November 12, 2023

File Compression/Decompression

Linux tar

"tar" stands for tape archive.

The tar command can compress or decompress files and folders. The compressed file is referred to as a tarball.

gzip compression

To compress a file or folder with gz compression:

To extract the tarball:

xz compression

To compress a file or folder with xz compression:

To extract this tarball:

When decompressing a tarball, tar is intelligent enough to determine how the files were compressed. So, the following will decompress either type of tarball:

gzip vs xz compression

xz compression will produce smaller files than gzip, but it takes more time to compress and decompress the files.

zip

Linux also has the commands zip and unzip:

zip does not preserve the ownership and permissions of files!

rar

Rar is often used to split a large file (video) into smaller files.

unrar is usually not installed by default. To install it on Debian:

sudo apt install unrar

To unrar and merge the files:

References:

  1. How to Compress and Extract Files Using the tar Command on Linux - How-to-Greek
  2. https://en.wikipedia.org/wiki/RAR_(file_format)
  3. https://en.wikipedia.org/wiki/WinRAR