🐧 Linux / Shell Scripting
Beginner
How does tar work for archiving?
Answer
tar creates and extracts archives (originally "tape archive"). The most common operations: tar -czf archive.tar.gz directory/ creates a gzip-compressed archive (c=create, z=gzip, f=file). tar -xzf archive.tar.gz extracts a gzip archive (x=extract). tar -cjf archive.tar.bz2 dir/ uses bzip2 (better compression, slower). tar -xf archive.tar.gz -C /target/ extracts to a specific directory. tar -tzf archive.tar.gz lists contents without extracting. A common mnemonic for flags: create, extract, verbose (show files), z (gzip), f (filename follows). tar is the standard archiving tool on Linux for backups and software distribution.
Previous
How do sort and uniq work together?
Next
What are environment variables and how do you use $PATH and $HOME?