Compress and uncompress file archives

OS X Yosemite and OS X Server use the GNU tar tool to compress and uncompress files and folders.

When sending folders and multiple files between computers, it’s helpful to compress them into a single archive. This saves space, lets you transfer just one item instead of many, and makes it easier to resume in case the task is suspended for some reason.

The tar tool has many options, but for a basic compression of a folder named, for example, “LotsOfFiles,” you could simply enter:

tar -czf LotsOfFiles.tgz LotsOfFiles

If it’s a large folder, you may want to monitor the process by adding the v flag:

tar -czvf LotsOfFiles.tgz LotsOfFiles

To open an archive, use the x flag. To see progress messages, use the v flag, as shown in this example:

tar -xzvf LotsOfFiles.tgz

The z flag indicates that the archive is being compressed, as well as being combined into one file. Usually you’ll use this option, but you aren’t required to. The traditional file extension for a compressed archive is .tgz, although you might also see files ending in .tar.gz. If the archive isn’t compressed, it usually just ends in .tar.

You open files created with tar in the Finder by double-clicking them. For more information about the tar tool, see its man page.