How to create and extract archives
Overview
tar stores many files in one archive and can combine with gzip or xz compression. File extensions such as .tar.gz indicate the compression method.
Examples
tar -czf project.tar.gz project/
tar -tzf project.tar.gz
tar -xzf project.tar.gz
tar -xzf project.tar.gz -C ~/restore
tar -cJf project.tar.xz project/
Options
-ccreates;-xextracts;-tlists-fis followed by the archive filename-zuses gzip;-Juses xz-vlists names while working-C directorychanges extraction destination
Safety
List an unfamiliar archive before extraction and unpack it into a new empty directory. Archives can contain paths that overwrite existing files.
Keep the option order understandable and ensure the archive filename immediately follows -f.