Extract a file compressed with gunzip (.gz)
gunzip -dk file_name.gz
Extract a file compressed with tar + gunzip (tar.gz)
tar -xvfz filename.tar.gz
Extract a file compressed with bzip2 (.bz2)
bzip2 -d file_name.bz2
tar xvf filename_tar
Zip files (.zip)
This puts the files named file1, file2, and file3 into a new zip archive called myzip.zip
zip myzip file1 file2 file3
Unzip files
unzip myzip.zip -d /path_to_extract
.tar
Extract a file compressed with tar (e.g., filename.tar)
tar xvf filename.tar
Compress a directory using tar
tar -zcvf archive.tar.gz directory/
7z (.7z)
Extract file
7z e filename.7z
Compress file with password
7z a filename.7z -pMYPASSWORD document.pdf
Compress many files
7z a test.7z test1.pdf test2.pdf
.xz
Uncompress .xz files
unxz <filename>.xz
.rar
sudo apt install unrar
Uncompress .rar files
unrar e file_name.rar
unrar e file_name.rar /path_for_extraction/