How to Compress and Archive Files with tar
The tar command creates and extracts archive files on Linux and macOS. Combined with gzip or bzip2, it produces compressed archives widely used for backups and distribution.
Create a Compressed Archive
tar -czvf archive.tar.gz /path/to/folder
Extract an Archive
tar -xzvf archive.tar.gz
Extract to a Specific Directory
tar -xzvf archive.tar.gz -C /destination/
List Archive Contents
tar -tzvf archive.tar.gz
Create a bzip2 Archive
tar -cjvf archive.tar.bz2 /path/to/folder