Gzip compression reduces the overall file size, which makes it more efficient for distribution, backup, and storage purposes. Then we’ll jump into the step-by-step process of unzipping on both Linux and Windows platforms. To extract a single file, provide the path and the name of the file. And of course this is possible with the Linux tar command, but firstly you need to check what is there inside the tarball without unpacking it. Most Linux distributions ship with a preinstalled archive manager.
Now the file “four” is extracted to a new directory called “bar.” If “bar” already exists, then “four” is placed inside the existing directory. If you’ve received a tarball from a friend or a software project, you can extract it in either your GUI desktop or in a shell. In a GUI, right-click the archive you want to extract and select “Extract.” This will automatically create a directory based on the filename of the original.
Tar stands for “tape archive” and is GNU software originally developed for backing up data to tape drives. It is still used today for consolidating and compressing data. Archives created with tar are typically saved with a .tar extension and can also be compressed to save space, resulting in files like .tar.gz or .tar.bz2.
Common compressions applied to a .tar file are Gzip, bzip2, and xz. That’s why you rarely see just a .tar file and more commonly encounter .tar.gz or .tgz files. The .gz or .bz2 extension suffix indicates that the archive has been compressed, using either the gzip or bzip2 compression algorithm.
Extract a Single Directory from a Tarball
Creating archives is an important step when you’re backing up your Linux file system. This ensures that your backup remains unaffected and the files don’t corrupt if anything breaks on your system. Ubuntu Core is a minimalistic and immutable version explicitly designed for the Internet of Things (IoT) and embedded systems.
How to Unzip .tar.gz in Linux using tar
Note that if you are working with TAR files, you can remove the -z flag from the commands. In the shell, you can add a file or directory to a tar archive as long as it is not compressed. If your archive has been compressed, you must uncompress it, but you do not need to unarchive it.
If you want to unzip the files to a different folder, click on the Extract To option. Choose the appropriate location and click Select to extract the file to that location. Click on the Extract Here option to unzip the content of the file. The system will extract all the files to your current directory by default.
How to Extract Files From a .tar.bz2 or .tar.gz File on Linux
You can use the official GNU gzip utility to extract the content of the compressed archive file. If the file you’re looking at is a TAR.GZ, using either tar or 7-Zip to extract the file will be a much simpler choice. Most of the time, you will get your hands on a compressed package that needs extracting. On Linux, there are multiple ways to unzip compressed archives.
Likewise, we don’t need the -j option to list the files in a tar.bz2 file. The following article will help you to extract (unpack) and uncompress (untar) – tar, tar.gz and tar.bz2 files from the Linux command line. The -so and -si flags denote Standard Output and Standard Input. The first part of the command writes the archive.tar file to the standard output. The second command reads the archive.tar file from the standard does overhead include payroll input and compresses it accordingly. DEB is the native and most common package format Ubuntu and other Debian-based Linux distributions use.
Deepin Linux 23 Released, Here’s What’s New
You’ll encounter them frequently while using a Linux distribution like Ubuntu or even while using the terminal on macOS. Here’s how to extract — or untar — the contents of a tar file, also known as a tarball. WinRAR is a popular file compression & archive utility software.
Forty years later we are still using the tar command to extract tar files on to our hard drives. Someone somewhere is probably still using tar with tape. A few simple commands are all it takes to untar, unzip or extract tar gz files from within running Linux or Unix operating environments. Hopefully this has helped you decompress, unpack and extract those compressed tar and tar gz files you downloaded from the internet. If you are looking for additional helpful solutions, you might want to check out this right mouse click open files as root article.
It contains compiled binaries, libraries, configuration files, and metadata required to install and manage software on a Ubuntu system. On the other hand, Windows users can rely on third-party file archiver tools like 7-zip or WinRAR to effortlessly extract files. This compression is lossless – that means no data is lost during the compression process, and the original files can be fully restored upon extraction. The -p (parents) option causes mkdir to create any parent directories that are required, ensuring the target directory is created.
Many of the downloadable Linux/Unix files found on the internet are compressed using a tar.gz format. Therefore, knowing how to open or untar tar.gz files is very useful. The command extracts files to a new directory called example1, which is located in the current directory.
- Likewise, we don’t need the -j option to list the files in a tar.bz2 file.
- For example, it goes without saying, that it is inadvisable to untar the whole large archive if you need for example to extract only a dingle file or a directory from it.
- But it does not compress the data, which results in a larger file size compared to compressed formats.
In Linux, the term “untar command” isn’t a standalone command. Instead, it commonly refers to the process of extracting, unzipping, or uncompressing tar and tar.gz files from a tar archive. The actual command used for this purpose is the tar command, combined with specific extraction options or arguments, enabling you to untar files, as we will cover next. The .tar portion of the file extension stands for tape archive, and is the reason that both of these file types are called tar files. Tar files date all the way back to 1979 when the tar command was created to allow system administrators to archive files onto tape.
The tar command will work happily with both types of file, so it doesn’t matter which compression method was used — and it should be available everywhere you have a Bash shell. You just need to use the appropriate tar command line options. When you want to share multiple files with someone else, compressing those files into a single TAR archive is the most efficient solution. Apart from occupying less space on your system storage, compressed archives utilize less server bandwidth when downloaded by multiple users. The following tar examples cover how to untar both popular formats and extract the contents of the compressed archive to a different directory. To do this we’ll use almost exactly the same command as before but with one important difference.