>_ IzzyLab

Hands-on task

This task is step 24 of the course “Linux: everyday tasks”

Extract a single file from an archive

medium~5 min

/root/backup.tar.gz contains several files. Extract from the archive only config/app.conf into /root, so that /root/config/app.conf appears (without unpacking the rest).

What you'll practise:
  • tar
  • gzip archives
  • selective extraction
  • archive listing
  • -C

Topic breakdown

A tar archive isn't a monolith: inside, each file has its own path, and you can unpack either everything at once or specific entries by name, giving their paths as the last arguments. Before a targeted extraction it's useful to look at exactly how those paths are recorded inside the archive — for that tar has a listing mode (-t), and the -z flag signals that the archive is gzip-compressed. Separately, keep in mind the difference between the view and extract (-x) modes and the -C flag, which sets the destination directory.

What's checked

  1. config/app.conf extracted
  2. the other files were not extracted

What it looks like