9951 explained code solutions for 126 technologies


cli-tarHow do I unpack a tar file using the terminal?


To unpack a tar file using the terminal, you can use the command tar -xvf <tarfile>. This command has the following parts:

  • tar: the command to invoke the tar program
  • -x: the flag to extract files from an archive
  • -v: the flag to display progress and file names while extracting
  • -f: the flag to specify the tar file
  • <tarfile>: the path to the tar file

For example:

tar -xvf my_archive.tar
x file1.txt, 0 bytes, 0 tape blocks
x file2.txt, 0 bytes, 0 tape blocks
x directory1/file3.txt, 0 bytes, 0 tape blocks

The output above shows that three files have been extracted from the tar file.

Helpful links

Edit this code on GitHub