tar
Pack a folder into one compressed file, look inside it and unpack it somewhere else.
>_ Try it: a simulated Linux, right herenothing runs on your computer
Loading the terminal…
Examples
-
tar -czf logs.tar.gz logs -
tar -tzf logs.tar.gz -
mkdir restore && tar -xzf logs.tar.gz -C restore -
ls restore/logs -
tar -cvf logs.tar logs
How it works
tar packs many files into one archive. Pick what to do (-c create, -t list, -x extract), add -z to compress with gzip (the .gz), and -f with the archive's name.
Backups, downloads and releases are often .tar.gz files: tar -xzf is the command to open them.
Syntax
tar -c|-t|-x [-z] [-v] -f ARCHIVE [FILE...]
Options
| Option | What it does |
|---|---|
-c | create an archive |
-x | extract an archive |
-t | list what is inside |
-z | compress / decompress with gzip (.gz) |
-f | the archive file (the name comes right after) |
-v | show each file as it goes |
-C | extract into another folder |
Good to know
- Read the letters as a sentence:
-czf= create, gzip, file. - Look inside with
-tbefore extracting: an archive can spill files into the current folder.