Create/Compress/Archive Almost Any File in Linux (tar, tar.gz, tar.bz2, gz, bz, zip, 7z, rar, etc…)
This is a no-frills Linux command line guide/cheat sheet that will help you archive or compress just about any file that you’re bound to come across. If you’d like to have more options, read the man pages! Also, the opposite to this guide about extracting/uncompressing/unarchiving files in Linux can be found here.
Preliminary:
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):
su -c 'yum install unzip zip p7zip rar unrar bzip2 gzip lzma'
.tar
tar cvf filename.tar /dir
.tar.gz
tar czvf filename.tar.gz /dir
.tgz
tar cvzf filename.tgz /dir
.tar.gz2
You probably mean .tar.bz2
.tar.bz
tar cjvf filename.tar.bz /dir
.tbz
tar cjvf filename.tbz /dir
.tar.bz2
tar cjvf filename.tar.bz2 /dir
.tar.Z
.Z is an old naming convention which has moved to .gz. See .tar.gz above.
.tar.xz
tar cvf - filenames | lzma > filename.tar.xz
.gz
gzip filename
.gz2
You probably mean .bz2
.bz
bzip filename
.bz2
bzip2 filename
.Z
.Z is an old naming convention which has moved to .gz. See .gz above.
.xz
lzma filename
.zip
zip -r filename.zip /dir
.7z
7z a -t7z filename.7z /dir
.rar
rar a filename.rar /dir
.dmg
This is a bit more complicated than what I have time for. Looks like somebody has already figured something out.
.dd
Create these image files using:
dd if=inputfile.dd of=outputfile.dd
.more?
Have more to share? I wouldn’t mind hearing about it in the comments if you do!
.trouble?
Let me know about it in the comments. We’ll get it straightened out.
Feel free to donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in:
Here are some similar posts that you may be interested in:
There's 2 Comments So Far
December 8th, 2012 at 2:00 am
How can i create an Archive WinRar compatible with Tar?
I know i have to install a tar “extention” by command line… which command?
ap-get install tar-winrar??
Who Linked To This Post?
Share your thoughts, leave a comment!