Compress backup.tar using gzip to create backup.tar.gz. (Check the size before and after compression)

1 min read
Step 1: Check the Size of backup.tar
Before Compression
bashCopyEditls -lh backup.tar
l
→ Long listing formath
→ Human-readable sizes (KB, MB, GB)
Step 2: Compress backup.tar
Using gzip
bashCopyEditgzip backup.tar
- This will compress
backup.tar
intobackup.tar.gz
and remove the originalbackup.tar
.
Step 3: Verify the Compressed File
bashCopyEditls -lh backup.tar.gz
- Now you should see
backup.tar.gz
in the directory.
Step 4: Compare the File Sizes
To check size before and after compression:
bashCopyEditls -lh backup.tar.gz
- Compare this size with the original
backup.tar
size.
Step 5: (Optional) Decompress the File
To extract the .tar.gz
file back:
bashCopyEditgunzip backup.tar.gz
- This restores
backup.tar
and removesbackup.tar.gz
.
Now, you've successfully compressed and verified the archive!
0
Subscribe to my newsletter
Read articles from Ravi Vishwakarma directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
