Packages and backups
The tar command
Packs files and folders into a single file, with or without compression.
Syntax
tar [-czf|-tzf|-xzf] <archivo.tar.gz> [carpeta]Most useful options
-cCreates the package-xExtracts the package-tLists the content-zCompresses with gzip-CChooses the destination folder when extractingCopy-ready examples
$ tar -czf copia.tar.gz DocumentosPack a folder$ tar -czf copia.tar.gz Documentos && tar -tzf copia.tar.gzSee what is inside without extracting$ tar -czf copia.tar.gz Documentos && mkdir restaurado && tar -xzf copia.tar.gz -C restauradoExtract into a folderYou can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- The destination folder for -C must exist before extracting.
FAQ
What does the z in -tzf mean?
That it compresses or decompresses with gzip, the .tar.gz format.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course