Linuxlab

Chapter 9

Archives and backups

Updated July 3, 2026

Archiving and compression are two different operations that one command often does together. An archive glues many files into one; compression shrinks the size. tar handles the gluing and hands compression to an external compressor: gzip, bzip2, or zstd.

Start with tar. Three letters cover almost all the work: c to create, x to extract, t to list the contents. The letter z adds gzip compression, f names the archive file.

$ tar czf logs.tar.gz /var/log/myapp   # create a compressed archive; tar strips the leading / and stores paths from myapp (see the box below)
$ tar tzf logs.tar.gz                   # list what is inside with
Locked

The rest of this chapter is part of a paid course

You are reading the open part. Buy the course to read the whole chapter.

See the course