Zip and Unzip Files Using Tar on Linux (Tutorial)
Sometimes it's hard to remember commands. Bookmark this page or just save this meme for reference.
1. How to ZIP (Compress) Files and Folders
tar czf archive-name.tar.gz folder-name
Breakdown
c— create a new archivez— compress using gzipf— specify the filename (must come last before the archive name)
2. How to UNZIP (Extract) Files
tar xzf archive-name.tar.gz
Breakdown
x— extract filesz— decompress gzipf— specify the filename
3. Extract to a Specific Folder
You can choose where to unpack:
tar xzf backup.tar.gz -C /path/to/destination/
4. View Contents Without Extracting
See what’s inside:
tar tzf backup.tar.gz