tar
What is tar?
tar: Tape Archive — Create or extract .tar (and .tar.gz) archives. tar bundles files and folders into a single archive file, and unpacks them again. tar -czf backup.tar.gz storage/ creates a compressed archive, and tar -xzf backup.tar.gz extracts it. -t lists the contents without extracting. The letters mean: c create, x extract, z gzip compression, f the file name follows. -C extracts into another folder, which avoids unpacking into the wrong place.
Frequently asked questions about tar
What should you keep in mind with tar?
Tar keeps file permissions and ownership, which makes it suitable for backups and moving folders between servers. Check what an archive contains with tar -tf before extracting one you did not make, because archives can contain absolute paths or overwrite existing files. For very large backups, zstd compression with --zstd is much faster than gzip at a similar size.
At a glance
| Category | CLI commands |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |