>_ IzzyLab

Hands-on task

This task is step 1 of the course “Archives and backups”

tar: create an archive of a directory

easy~2 min

Archive the directory /root/src into the compressed archive /root/src.tar.gz (gzip). Paths inside the archive must start with src/, without /root.

What you'll practise:
  • tar
  • gzip
  • creating archives
  • -C flag

Topic breakdown

tar gathers a file tree into a single archive; the c flag sets create mode, f the output file name, and z transparent gzip compression. An important detail is which paths end up inside the archive: to make them relative rather than dragging along the full path from the root, tar is pointed at the parent directory with the -C flag and passed only the name of the folder being packed. You can view the contents of a finished archive with the listing mode.

What's checked

  1. the archive has all files of the directory, paths starting with src/

What it looks like