Ad space (banner)
🖥️Linux Lessons
Lesson 29 / 61

Bundling Files with tar

tar is for when "I want to bundle several files together and compress them." tar stands for tape archive, and it bundles multiple files into a single archive file, optionally compressing them at the same time.

Use it in the form tar -czf output-name.tar.gz target-files.... -c means create, -z means gzip-compress, and -f specifies the output filename.

Running tar -czf archive.tar.gz notes.txt fruits.txt bundles and compresses both files into a single file, archive.tar.gz.

A common early mistake is confusing the compress flags (tar -czf) with the extract flags (tar -xzf), and doing the opposite of what you meant. Remember: c is create, x is extract.

In real work, this is used constantly — packaging a set of files for server deployment, and as a standard format for saving backup data.

Linux
Try it (type this into the pseudo terminal)
tar -czf archive.tar.gz notes.txt fruits.txt

🧑‍💻 You can type this command into the Linux pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)