tar, gzip, bzip2

categories:

Overview of the most common commands when it comes to compression…

Tar

Create a tar file : tar -cpf target.tar source_folder/

Create a tar.gz file : tar -cpzf target.tar.gz source_folder/

Create a tar.bz file : tar -cpjf target.tar.bz2 source_folder/

-c : create -p : preserve permissions -z : gzip -j : bzip -f : file -x : extract -v : verbose -t : test

Extract foo.tar : tar -xvf foo.tar

Extract gzipped foo.tar.gz : tar -xvzf foo.tar.gz

Extract bzipped foo.tar.bz2 after changing directory (must exist) to bar : tar -xvjf foo.tar.bz2 -C bar/

Extract the file blah.txt from foo.tar.bz2 : tar -xvzf foo.tar.gz blah.txt

Test extraction : tar -tvzf foo.tar.gz

gzip

Extract file : gzip -d file.gz

Compress file : gzip file

Getting info from the zip file : gzip -l foo.tar.gz compressed uncompressed ratio uncompressed_name 176 10240 98.5% foo.tar

bzip

Same as gzip

Best compression : bzip2 -9 file




Thanks for reading this post!


Did you find an issue in this article?

- click on the following Github link
- log into Github with your account
- click on the line number containing the error
- click on the "..." button
- choose "Reference in new issue"
- add a title and your comment
- click "Submit new issue"

Your feedback is much appreciated! πŸ€œπŸΌπŸ€›πŸΌ

You can also drop me a line below!