9951 explained code solutions for 126 technologies


cli-tarHow do I extract a tar.gz file using the command line?


To extract a tar.gz file using the command line, use the following syntax:

tar -xzvf <filename>.tar.gz

The parts of the code are as follows:

  • tar: the command to extract files
  • -xzvf: the options for the command, which stands for "extract, gzip, verbose, file"
  • <filename>.tar.gz: the name of the file to be extracted

The output of the command should look something like this:

x file_1.txt
x file_2.txt
x file_3.txt

This shows the command successfully extracting the files in the tar.gz archive.

Helpful links

Edit this code on GitHub