Skip to main content
In this lesson we’ll cover how to create, inspect, compress, and extract tar archives on Linux. Think of TAR (Tape ARchive) as placing multiple files and folders into a single box; compression is like vacuum-sealing that box to make it smaller. For RHEL administrators and RHCSA candidates, tar is indispensable for bundling logs, backing up directories, and transferring multiple files between systems.
A dark-themed infographic titled "Archive, Compress, Pack, and Unpack Files Using tar" explaining tar use. It shows a central "RHEL Administrator" gear icon and three icons labeled "Bundle Logs", "Back up directories", and "Transfer multiple files between systems."
What is an archive?
  • An archive is a single file that contains a collection of files and directories (useful for transfer or backup).
  • The tar format is a container that preserves file metadata and directory structure; tar archives typically end in .tar.
  • Tar archives are not compressed by default; you can compress them using tar options (-z, -j, -J) or separate compression utilities (gzip, bzip2, xz).
A dark-themed slide titled "Archiving" with several rounded black text boxes describing the tar archive format (e.g., .tar extension, not compressed by default, can be written to backup tape). The layout shows three boxes across the top and two below on a navy background.
Basic tar operations and options
Tip: -f requires the archive filename as the very next argument (e.g., tar -cvf archive.tar files/). Use -C <directory> to extract into a different location.
Compression flags Examples of creating and extracting archives Create an uncompressed archive:
List contents:
Extract into the current directory:
Extract into a specific directory:
Create and extract compressed archives:
Demo: create, compress, and extract archives Step through a practical example to see how tar behaves with real files. Create a working directory and sample files:
Create an uncompressed tar archive:
List archive contents with details:
Extract into a different directory using -C:
Create gzip and bzip2 compressed archives:
Extract a bzip2 archive into a chosen directory:
Using standalone compression utilities If you forget tar’s compression flags, you can compress/decompress an existing .tar file with dedicated tools:
Warning: When extracting archives, be cautious—archives may contain absolute paths or files that overwrite existing data. Audit contents with tar -tvf archive.tar before extraction, and use -C to extract into a safe directory when unsure.
Quick reference: common patterns Further reading and references This concludes the lesson. With tar you can efficiently archive, compress, and extract file collections—either using tar’s built-in compression flags or separate compression utilities—making backups and transfers straightforward for system administrators and RHCSA candidates.

Watch Video