How to open a tar file in Unix or Linux
A lot of the downloadable Linux or Unix files found on the internet are compressed using a tar or tar.gz compression format. So, knowing how to open or untar these compressed files becomes very important. In the following examples, we will explain how to untar both popular formats and how to extract the contents to a different directory.
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,
(replacingfile_name.tar.gz
with the actual name of your file)cd /directory_path/file_name.tar.gz
- To extract the contents of the tar.gz file to the current directory, type
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
How to 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 a tar file in Unix or Linux published under Using and Configuring Linux
