>_ IzzyLab

Hands-on task

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

Extract a single file from an archive

medium~5 min

The archive /root/backup.tar has many files, but you need only one — etc/app.conf. Extract just that one from the archive (without unpacking everything else) into the current directory /root, so that /root/etc/app.conf appears.

What you'll practise:
  • tar
  • selective extraction
  • archives
  • paths inside an archive

Topic breakdown

tar isn't obligated to unpack the whole archive — during extraction you can list specific entries, and only those are pulled out, along with their nested directories. The path is specified exactly as it's recorded inside the archive, so before extracting it's convenient to view the contents in listing mode (-t). The extraction mode and the archive file are set with the usual flags, and after them you list the desired paths.

What's checked

  1. the desired file was extracted
  2. nothing extra was unpacked

What it looks like