Linux Tar Files
Jump to navigation
Jump to search
Tar is one form of file compression commonly used on Linux machines.
Compress a File
To compress a file, use the command:
tar -czvf <name_of_archive> <path_to_file_or_directory>
Where:
<name_of_archive>
is the name of the compressed file you'll create.<path_to_file_or_directory>
is the path to the file or directory you wish to compress.czvf
stands for:- c - Creates an archive (compressed file).
- z - Compresses using gzip format.
- v - Displays progress in terminal while compressing.
- f - Allows specification of archive name.
Extract a File
To extract a compressed file, use the command:
tar -xzvf <name_of_archive> -C <location_to_decompress_to>
Where:
<name_of_archive>
is the name of the compressed file you'll create.<location_to_decompress_to>
is the path you wish to extract contents to.xzvf
stands for:- c - Extracts an archive (compressed file).
- z - Compression is in gzip format.
- v - Displays progress in terminal while compressing.
- f - Allows specification of archive name.