/ factorpad.com / tech / linux-essentials / tar-command.html
An ad-free and cookie-free website.
Beginner
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
Files.
tar
allows you to archive files and
directories.
-options | description |
---|---|
-? ,
--help ,
--usage |
Print help screen and syntax |
-f |
Use file archive |
-v |
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)
.
The 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
on an f
for files and
v
for verbose messages. And again,
there are many more options here too.
So why is tar
an important command?
Well, since 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,
video73a.txt
then
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.
Then an 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 -t
, listing
mode, for files with f
, like this.
And see what's inside the tar
file.
Okay now you know how to use tar
.
And you know the syntax for commands, options and arguments.
One last tip about the tar
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
gzip
and
bzip2
. Something to consider.
Okay, thanks for visiting today. I hope this was a helpful
introduction to the tar
command.
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.
zip
command,
hit Back.rsync
command, click Next./ factorpad.com / tech / linux-essentials / tar-command.html
A newly-updated free resource. Connect and refer a friend today.