The tar command in Linux explained
The tar command packs and unpacks archive files. It is one of the most useful commands for anyone using a live USB drive or a fresh Linux install.
Syntax
tar [options] archive
Examples
tar -czf backup.tar.gz Documents: create a compressed archivetar -xzf backup.tar.gz: extract it
Tip
Remember the letters: c create, x extract, z gzip and f file name.
Keep learning
New to the terminal? Start with Linux terminal basics. You can try every command safely from a live session: see how to try Linux without installing it. Run man tar in a terminal for the full manual.
Frequently asked questions
How do I see every option for tar?
Run man tar for the full manual, or try tar --help for a short summary.
Do I need sudo to run tar?
Not for your own files. You only need sudo when the command changes something owned by the system or another user.
Is it safe to practise tar on a live USB drive?
Mostly yes, because a live session starts fresh each time. Be careful with commands that write to your internal disk, such as rm on a mounted drive or dd.