How to pack and extract file in terminal

Sometimes you need to pack/unpack files in the terminal, so you have to remember commands for different types of archives. Make it easier for you – just bookmark this page and you will always know what to type into terminal ๐Ÿ™‚

Packing file examples for different types

Pack file with zip:

zip -r targetfile sourcedirectory

Pack file with tar:

tar cvzf targetfile.tar.gz sourcedirectory

Pack file with bz2:

bzip2 sourcefile

Pack file with rar:

rar a targetfile.rar sourcedirectory

Extracting file examples for different types

Unpack file with zip:


Unpack file with tar:

tar xvzf archive.tar.gz

Unpack file with bz2:

bunzip2 archive.bz2

Unpack file with rar:

unrar x archive.rar

Leave a Reply

Your email address will not be published. Required fields are marked *