How to Extract or Open a Tar file in Linux. Untar a File in Linux. Many of the most popular downloadable Linux or Unix files found on the internet are compressed using a tar or tar.gz compression format. So, knowing how to open these compressed files becomes very important. The following examples cover how to untar both popular formats and extract the contents of the compressed archive to a different directory.
How to Extract, Open or Untar a “tar” file in Linux or Unix
- From the terminal, change to the directory where your .tar file has been downloaded.
- To extract or untar the file to the current directory, type the following,
(Making sure to replacefile_name.tar
with the actual filename)tar -xvf file_name.tar
Or to extract to another directory, type
tar -C /myfolder -xvf file_name.tar
How to Open or Untar a “tar.gz” file in Linux or Unix
- Open a terminal window ctrl+alt+t
- From the terminal, change directory to where your .tar.gz file is located,
cd ~/directory_path
- To extract the contents of the tar.gz file to the current directory, type the following
(replacingfile_name.tar.gz
with the actual name of your file)tar -zxvf file_name.tar.gz
NOTE: You can specify a different directory to extract to using the -C parameter and path to the directory as follows:
tar -C /myfolder -zxvf file_name.tar.gz
That is really all there is to it. Hopefully this section has helped you unpack, open, or extract those compressed tar files you downloaded from the internet.
If you are looking for additional helpful solutions, you might want to check out this How to Open Files as Root article.