Skip to main content

Unit 3 · Linux^2 · Lesson 30 of 34

Tarball

tar, zip, and friends

Sometimes you'll get a bunch of files squished together into one file, called an archive. On Linux the most common one is the .tar file, and people call them tarballs (which is honestly an incredible name).

A lot of the time they're also compressed, so you'll see endings like .tar.gz.

tar

The tar command has a ton of flags and nobody remembers all of them. Just remember these two:

CommandWhat it does
tar -xvf [archive.tar.gz]Extracts (unpacks) an archive
tar -cvf [archive.tar] [files]Creates an archive out of your files

Here's what the letters actually mean, so it's not just magic:

LetterMeaning
xExtract
cCreate
vVerbose (shows you what it's doing)
fFile (tells tar that the next thing is the archive's name)

When extracting, tar figures out the compression on its own. When creating a compressed one, add a z:

[user@linux]$ tar -czvf archive.tar.gz [files]

zip

You'll also run into .zip files, which are way simpler:

CommandWhat it does
unzip [file.zip]Unpacks it
zip [name.zip] [files]Zips files up

Your turn

You've got mail! There's a package waiting for you at ~/mail/package.tar.gz. Open it up and see what's inside.

Capture-the-flag challenge

Put the lesson to work on a challenge and submit the flag you find. Create a free account to do this part.

Do this lesson for real

With a free account you get the terminal, the challenges and the checks that go with every lesson in Intro to Linux, and your progress is saved as you go. CyberAcad is a 501(c)(3) nonprofit, so there is nothing to pay.