To compress folders and multiple files for transferring between computers in one step, we use the
tar command. The .tar format is used for collecting multiple files into one archive file for distribution or backup.
"tar" is short for tape archiving utility. The name is a reminescence of when file were backed up on and occasionally retrieved from magenetic tape, which was then used as a storage device.
Furthermore, the term tarball is a jargon term describing "a bunch of files stuck together in a ball of tar."
Options for tar don't need a hyphen (
-) preceding it. Here are a list of common action options.
With an action option you may include a qualifier.
Some common commands you will use are:
Here are some examples with
tar that you'll most likely come across.
$ tar -cvf myArchive.tar README.md todo.txt index.html a README.md a index.html a todo.txt # Created myArchive.tar file
$ tar xvf archive.tar
Before you go and extract a .tar file, you may want to have a peek inside. The
tar file allows for this with the table-of-contents mode. Simply pass in the
If you extract the files, the original permission settings may be overwritten with your
umask settings. To preserve the original permissions, use the
Oftentimes you'll come across files with a .tar.gz extension. To unpack this, simply use the
gunzip command first, the
$ gunzip myArchive.tar.gz $ tar xf myArchive.tar # Or, even faster... $ zcat myArchive.tar.gz | tar xvf
zcat is the same as using
gunzip with the
-c option, which outputs to standard out.
If you're working with a Windows user, you may come across with the .zip compression file extension. The command line can also handle zip files in a mannner similar to
Zipping is as easy to use as the
gzip command. There are two types of command modes that options work in - external and internal. Internal modes (delete and copy) operate exclusively on entries in an existing archive, while external modes (add, update and freshen) read from both files from the file system, and existing archives.
$ zip myArchive README.md todo.txt index.html adding: README.md (deflated 90%) adding: index.html (deflated 60%) adding: todo.txt (deflated 61%)
To unzip, use the
$ unzip myArchive.zip
Command Line Kung Fu is packed with dozens of tips and practical real-world examples. You won't find theoretical examples in this book. The examples demonstrate how to solve actual problems. The tactics are easy to find, too. Each chapter covers a specific topic and groups related tips and examples together.$ Check price
Stretch out your back and relieve your back muscles with inversion therapy. This device counteracts the forces of gravity on the body by decompressing and elongating the spine. By using this product just ten minutes a day, you can be well on your way to improved circulation and posture while relieving muscle aches, back pain and stress.$$ Check price