How to Zip and Unzip or Extract TAR and TAR.GZ Files?
If you are working with Linux or UNIX-based operating systems, you might often come across files with the extensions TAR and TAR.GZ. These are archive files that contain multiple files or directories within them.
To work with these archive files, you need to understand how to extract or unzip them. Here is a step-by-step guide on how to zip and unzip or extract TAR and TAR.GZ files.
1. How to Zip Files to TAR and TAR.GZ format
To create a TAR archive, use the following command:
“`
tar -cvf archive.tar file1 folder1 file2
“`
Replace archive.tar with the name you want to give the archive file, and file1, folder1, and file2 with the names of the files or directories you want to include in the archive. To create a GZipped TAR archive, use the following command:
“`
tar -czvf archive.tar.gz file1 folder1 file2
“`
This will create a compressed archive file with the extension .tar.gz
2. How to Unzip or Extract TAR and TAR.GZ Files
To extract files from a TAR archive, use the following command:
“`
tar -xvf archive.tar
“`
Replace archive.tar with the name of the archive file. This will extract all the files and directories from the archive to the current working directory.
To extract files from a GZipped TAR archive, use the following command:
“`
tar -xzvf archive.tar.gz
“`
Replace archive.tar.gz with the name of the compressed archive file. This will extract all the files and directories from the archive to the current working directory.