Compress / Decompress files

0. Requirement packages

1
apt install tar zip unzip gzip
Copied!

1. Compress

    Compress single file into .tar.gz
1
tar -zcvf telegraf-legacy.log.tar.gz telegraf.log --totals --verbose
Copied!
    Compress a directory into .tar.gz
1
tar -zczf monit-5.26.0.tar.gz monit-5.26.0/ --totals --verbose
Copied!
After that if you want remove original file then use with option --remove-files
    Compress single file into .gz
1
# From tocdo.log --> tocdo.gz (dropped original file)
2
3
gzip tocdo.log
Copied!
    Compress single file into .zip
1
# From tocdo.log --> tocdo.zip (dropped original file)
2
3
zip x tocdo.log
Copied!

2. Decompress

1
tar -xzf foo.tar.gz --totals --verbose
Copied!
1
unzip -a x.zip
Copied!
Last modified 1yr ago