Modified by Jen Wike Huger. Join the 85, open source advocates who receive our giveaway alerts and article roundups.
If you use open source software, chances are you'll encounter a. The open source tar archive utility has been around since , so it is truly ubiquitous in the POSIX world.
Coolest Guides On The Planet
Its purpose is simple: People new to the tar format usually equate it to a. Common compressions applied to a. That's why you rarely see just a. On Windows, the easiest way to handle. A tar archive is often referred to as a tarball , presumably because we hackers love to shorten words to as few syllables as possible, and "tarball" is shorter and easier than "tar archive. In a GUI, creating a tarball is, at the most, a three-step process.
To gather a group of files into one archive, place your files in a directory and then invoke tar, providing a name for the archive that you want to create and the directory you want to archive:. The tar utility is unique among commands, because it doesn't require dashes in front of its short options, allowing power users to abbreviate complex commands like this:.
You don't have to put files into a directory before archiving them, but it's considered poor etiquette not to, because nobody wants 50 files scattered out onto their desktop when they unarchive a directory. These kinds of archives are sometimes called a tarbomb , although not always with a negative connotation. Tarbombs are useful for patches and software installers; it's just a matter of knowing when to use them and when to avoid them.
How to unzip a tar.gz file
Creating a tar archive does not compress your files, it just makes them easier to move around as one blob. For compression, you can have tar call Gzip or bzip:. Common extensions are tar. 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.
I use this option so that when I extract files from a tarbomb, they remain tidy and contained.
macos - How do I create a .tgz from Finder using Archive Utility? - Ask Different
The tar utilities are very robust and flexible. Once you're comfortable with the basics, it's useful to explore other features. If you have an existing tarball and want to add a new file into it, you don't have to unarchive everything just to add a new file. Most Linux and BSD desktops come with a graphical archive utility.
Using it, you can open a tar archive as if it were any other directory, have a look inside, extract individual files, add files to it, and even preview the text files and images it contains. 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. Sometimes you don't need all the files in an archive, you just want to extract one or two. After listing the contents of a tar archive, use the usual tar extract command along with the path of the file you want to extract:.
Now the file "four" is extracted to a new directory called "bar. Previously, I mentioned that some tarballs were tarbombs that left files scattered around your computer. If you list a tar archive and see that its files are not contained in a directory, you can create a destination directory for them:. If you're working on a website and want to send the admin some new files, you can do it a few different ways.
The obvious way is to email the files to the site admin along with some text explaining where each file is to be placed: Given this structure, the site admin could extract your incoming archive directly to the server's root directory. It's bulk copying and pasting, done quickly and easily. The tar format is just a format, and it's an open format, so it can be created by more than just one tool. Unpacking the gz and tar files can be done with applications like Pacifist or Unarchiver free , or by going back to the command line with:.
Generally you should untar things into a directory, or the present working directory will be the destination which can get messy quick. Enjoy this tip?
Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:. A normal cp operation is slow because it never gets a chance to increase the network bandwidth as it resets for each individual file. Watching a performance graph would show it peaking and falling for every individual file.
So the solution would be to tar gzip the files into one huge file and then copy that file.
Trouble was, there was not enough free disk space to handle the huge file. Netcat to the rescue! Netcat is a very powerful tool it can open a raw network port and pass data through that port and it can listen for a raw data stream on the other end. So the trick is to tar gzip the files and pipe the output no filename into nc directing nc to a network port number of choice.
Search form
To give you an idea of how effective something like that is; the attempted copy operation over an SMB share ran for 5 hours and the Finder was still just calculating the number of files which at that point was well over , files! I tried using the cp command from terminal and it was only about a third of the way through the copy process having run overnight. The performance graph rapidly peaked and stayed completely peaked the entire time the copy process ran. So essentially, the sending system executed tar and gzip operations storing the data in RAM while it pushed that data over netcat to a waiting netcat listening on a pre-determined network port where the files were pushed to a tar gzip command that decompressed the files.
Since there was a large continuous amount of data pumping through the network port, the amount of bandwidth increased exponentially until it maxed out the Ethernet card. This allowed it to go as fast as it possibly could have run. The mind blowing part? These tools are built in to OS X and every Unix system but they have been around for more than 20 years. The whole Unix concept is small tools that do one thing very well and you connect the tools to one another via the pipe command. The funny part? The command parameters vary a bit between the two netcat programs and I was unable to get the built-in OS X version of netcat to play nice with the Linux GNU version.
Homebrew will not mess up your Mac, but it might confuse someone else trying to work on your Mac. I have no trouble creating the. Or it would be done already.. Thanks for the read guyz. TBH, i cant remember the command, so this article is my goto when i need to tar and gzip something. Thanks for writing it all out.
Top notch. The benefits of using Linux as an alternative is that it forces you to gain useful technical knowledge that also applies to the Mac. Umm, windows has its uses, such as gaming, but yes, linux is like using stick-shift mac. Some versions of tar even support creating bz2 archives natively with the -j flag, but […]. I tried to converd a file by commandline to tar.