Compressed Files

Compressed Files

In Windows we are familiar with using zip files. Linux can use zip files, but it is not as common. In Linux it is most common to see xz, bz2, gz as file extensions for compressed files. These files are use different compression types and will provide different results (file size). The xz compression has become more popular these days as it provides the best compression. If you were to download the Linux Kernel source code it would be a xz file! You might also notice that the Linux Kernel file is name is: linux-5.17.11.tar.xz (this is the latest stable version when this page was created). The file name is linux-5.17.11 and it has two file extensions: tar and xz. This is extremely common to see in Linux. When you see a tar file think of this as a file that contains files without any compression. This would create the linux-5.17.11.tar file. That file is then taken and compressed giving us the final output of linux-5.17.11.tar.xz. This sounds complex to do, but it is actually very easy to do. You can do all this with just the tar command!

tar

The tar command has many uses. The most important is create archives. Watch each of these videos to gain expert understanding of you to use the tar command to create compressed files. Once you've watched the videos make sure you look over each man page to learn about the options provided in the videos for each command.

https://linux.die.net/man/1/tar

https://linux.die.net/man/1/gzip

https://linux.die.net/man/1/gunzip

https://linux.die.net/man/1/bzip2

https://linux.die.net/man/1/xz

Videos are great, but sometimes you just need to be able to see command examples for this information to really get absorbed.

https://www.thegeekstuff.com/2010/04/unix-tar-command-examples/

https://linuxconfig.org/beginner-s-guide-to-compression-with-xz-on-linux

Archiving a Drive

At times you might not want to just archive a directory on your drive, but the entire drive. This is really easy to do in Linux using the dd command. You could then take the output of the dd command and compress it using xz if you wished.

dd

The dd command is another way to create an archive of files. The dd command is very powerful as it can be used to clone an entire drive! The main purpose of the dd command is to clone and convert files.

https://linux.die.net/man/1/dd

https://linuxconfig.org/how-dd-command-works-in-linux-with-examples