Simple trick for remembering tar parameters

You have probably looked up the parameters for tar more than you’ve changed socks. And what if the scenario from xkcd ever became real? Could you really run a valid tar command without googling first?

XKCD: “I don’t know what’s worse–the fact that after 15 years of using tar I still can’t keep the flags straight, or that after 15 years of technological advancement I’m still mucking with tar flags that were 15 years old when I started.”

Here’s a few tricks to help you remember how to use tar if you want to extract files from an archive, either .tar , .gz or tar.bz2

-xextract
-ffile

That’s it! All you need is tar -xf <filename>

Many guides will use -xvfz (or -xfzv or -xfvz or whatever), but -v and -z are not actually necessary.

-z is only used to tell tar it’s a .gz file, but for the last 15 years or so tar have been able to automatically detect this itself.

The other parameter, -v, is not necessary either, but it can be quite useful as it simply means verbose (extended/detailed) output in the terminal window.

So you if you want to see the progress of the file operation, include -v as well, so the final command becomes:

tar -xvf <filename>

Remember it by saying out loud: tar eXtract Verbose File <filename>

Or, as mentioned, simply use: tar -xf <filename> (tar eXtract File <filename>)

Was this post helpful?
Yes
No
Powered by Devhats

Leave a Reply

Your email address will not be published. Required fields are marked *