Linux: Extract tar zip gzip lzip bzip2 xz rar

By Xah Lee. Date: . Last updated: .

here's how to unarchive or decompress files.

Extract Tar File (.tar)

# extract .tar file
tar xvf filename
# extract .tar.gz .tgz file
tar xvfz filename
# extract tar.bz2 .bz2 .tbz2 file
tar xvfj filename
# extract .tar.xz file
tar xvfJ filename
# List content of .tar
tar -tvf filename

unzip (.zip)

unzip filename

Decompress gzip (.gz)

gzip -d filename


gunzip filename

Extract lzip (.lz)

You have to install lzip. At

lzip -d filename

Decompress bzip2 (.bz2)

bzip2 -d filename

Decompress xz (.xz)

xz -d filename

Extract rar file (.rar)

unrar e fileName


7z x fileName

Linux Compress, Archive, Download