Back to course

76. Archiving Files: The `tar` Command (Basics)

Linux Basics: From Zero to CLI Hero

Combining Files for Backup

tar (Tape ARchiver) is the standard Linux utility for creating archives (collections of files stored in a single file) for backup or distribution. Note: tar archives are collections, not compressed files yet.

Essential tar Options (Mandatory)

  • c: Create a new archive.
  • x: Extract files from an archive.
  • f: Specify the filename of the archive (must be the last option).
  • v: Verbose output (shows files being processed).

Creating a Tar Archive (-cvf)

Create an archive named project_archive.tar containing the entire project_A directory:

bash $ tar -cvf project_archive.tar project_A/

Extracting a Tar Archive (-xvf)

Extract the contents of the archive to the current directory:

bash $ tar -xvf project_archive.tar