Packing with tar gzip, bzip2 and zip

Looking on my block at the end of the year i see than nearly two years ago i wrote about extracting archives under Linux but not about putting files in to archives. Now a have some time to continue.

Tar.gz

Here are some common way to create your archives.

#Creates simple targetfile.tar without compression.
tar cvf targetfile.tar sourcedir/*

#Zip everything beneath sourcedir to targetfile.tar.gz
tar cvzf targetfile.tar.gz sourcedir/*

#Bzip2 everything beneath sourcedir to targetfile.tar.bz2
tar cvjf targetfile.tar.bz2 sourcedir/*

Parameters explanation:

Alternative with pipe usage:

tar -cf - sourcedir | gzip -c > filename.tar.gz

Zip

Some examples

#Zip every file in current directroy to file.zip.
#But hidden files like (.htaccess) are not included.
zip file.zip sourcedir/*

#also includes hidden files.
zip file.zip sourcedir/* .*

The above examples include directories but still not their content recursively, -r option is required.

#Adds all files and directories recursivly.
zip file.zip -r /sourcedir/*

#Same as abowe with addtional enryption and password lock.
#Password is prompted on the terminal.
zip file.zip -re /sourcedir/*

#Splitts creted archive to parts not bigger than 2 Gigabytes.
zip -s 2g -r test.zip ./*

Hope that helps someone.

Happy new year!!!

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

No comments yet.

Leave a comment

(required)

(required)