Before you can work with the compressed data, you need to install the necessary tools. The following table lists the commands and their installation instructions. This table work with debian and ubuntu based systems.
Command | Installation | Common Extensions |
---|---|---|
7z | sudo apt-get install -y p7zip-full | .7z |
bzip2 | sudo apt-get install -y bzip2 | .bz2 |
gzip | sudo apt-get install -y gzip | .gz |
rar | sudo apt-get install -y rar | .rar |
tar | sudo apt-get install -y tar | .tar |
un7z | sudo apt-get install -y p7zip-full | .7z |
unrar | sudo apt-get install -y unrar | .rar |
unzip | sudo apt-get install -y unzip | .zip |
xz | sudo apt-get install -y xz-utils | .xz |
zip | sudo apt-get install -y zip | .zip |
lz4 | sudo apt-get install -y lz4 | .lz4 |
And after you have installed the tools, you can use them as following:
Command | Compress | De-Compress |
---|---|---|
7z | 7z a archive.7z file1 file2 | 7z x archive.7z |
bzip2 | bzip2 file | bunzip2 file.bz2 |
gzip | gzip file | gunzip file.gz |
rar | rar a archive.rar file1 file2 | unrar x archive.rar |
tar | tar -cvf archive.tar file1 file2 | tar -xvf archive.tar |
xz | xz file | unxz file.xz |
zip | zip archive.zip file1 file2 | unzip archive.zip |
lz4 | lz4 file | unlz4 file.lz4 |
Sometimes, files are compressed using multiple algorithms. In such cases, you need to unpack the data several times before getting the actual data that you want.