An ad-free and cookie-free website.
Learn to compress and decompress files and directories at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux tar Command Summary with Examples (3:45)
Our seventy-third word, or command to memorize is
tar from our category
tar allows you to archive files and
||Print help screen and syntax|
||Use file archive|
||Pirnt verbose detailed messages|
Recall from the last several videos, we've been seeing ways to compress files and now we'll focus on the main tool Linux uses to create archives of files and directories, with or without compression.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s).
tar command has
over 50 options and the arguments include the output
file, in .tar format, then input files or directories.
Before the options we input a mode, like
c to create,
t to list and
x to extract, and there are many
others. Some modes do require an additional argument.
Like most commands, help is available with double-dash
--help. Then after the mode, you tack
f for files and
v for verbose messages. And again,
there are many more options here too.
So why is
tar an important command?
tar is the default file
packaging mechanism for Linux, you need to get comfortable with it.
And now you know how to do that.
Okay, the best way to embed this in your memory is by typing in your own terminal window.
Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.
Here we go. First, let's grab that great
man page for
tar and make a file,
ls -og video73* to confirm.
Next, let's get in create
tar mode, for files, using
-cf, but you could use it without the
dash as well,
video73.tar, which is
the target, and put in there
video73a.txt. And we're only using
one here to keep it super simple.
ls -og video73* again.
And there it is. Notice how, unlike with our compression commands, it doesn't remove the file, the original? That's different here.
And last, let's use the
mode, for files with
f, like this.
And see what's inside the
Okay now you know how to use
And you know the syntax for commands, options and arguments.
One last tip about the
command. So I'm reluctant to go much deeper with
tar in this short time frame, but
make note, you can also use compression algorithms we covered, like
bzip2. Something to consider.
Okay, thanks for visiting today. I hope this was a helpful
introduction to the
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
To be notified of new video content, subscribe, follow and connnect.
zipcommand, hit Back.
rsynccommand, click Next.
A newly-updated free resource. Connect and refer a friend today.