Compress file Command’s

This is a Linux command line guide/cheat sheet that will help you archive or compress file. More options are also available by reading the man pages!

Most compression or archiving methods that you may want are already built into popular distributions (Ubuntu, Fedora, Suse, etc…), but some of them aren’t.

I would recommend installing this group of packages using apt-get, yum, or an equivalent before using this guide (unless of course you already know what you need):

compress file
su -c 'yum install unzip zip p7zip rar unrar bzip2 gzip lzma'



tar cvf filename.tar /dir


tar czvf filename.tar.gz /dir


tar cvzf filename.tgz /dir


You probably mean .tar.bz2

tar cjvf /dir


tar cjvf filename.tbz /dir


tar cjvf filename.tar.bz2 /dir


.Z is an old naming convention which has moved to .gz. See .tar.gz above.


tar cvf -  filenames | lzma > filename.tar.xz 


gzip filename


bzip filenameCreate Compress Archive


bzip2 filename


lzma filename


zip -r /dir


7z a -t7z filename.7z /dir


rar a filename.rar /dir

Create these image files using:

dd if=inputfile.dd of=outputfile.dd

Have more to share? I would love to hear about it in the comments section below. Also, If you’re having any trouble, let me know about it in the comments. We’ll get you straightened out.

Tags: , , , , , , , , , , , ,

Spin up a cloud server in no time flat

Simple setup. Full root access. Straightforward pricing.


Leave a Reply