9951 explained code solutions for 126 technologies


cli-tarHow do I unzip a tar file using the command line?


Using the command line to unzip a tar file is a fairly straightforward process. The following example code block shows how to unzip a file named example.tar:

tar -xvf example.tar

Code explanation

  • tar: the command to run the tar program
  • -x: the flag to extract the contents of the tar file
  • -v: the flag to show the progress of the extraction
  • -f: the flag to specify the name of the tar file

It is also possible to extract the contents of the tar file into a specific directory. To do this, add the -C flag followed by the path of the directory. For example:

tar -xvf example.tar -C /path/to/directory

For more information, please refer to the following links:

Edit this code on GitHub