Archiving & Compression

Do I need to archive file or compress file i.e to make a file size smaller.

Archiving & Compression:

Q1. What is Archiving?

Archiving means that you take 10 files and combine them into one file, with no difference in size. If you start with 10 100KB files and archive them, the resulting single file is 1000KB. On the other hand, if you compress those 10 files, you might find that the resulting files range from only a few kilobytes to close to the original size of 100KB, depending upon the original file type.

Q2. What are the different types of archive and compression formats?

The popular archive and compression formats are zip, gzip, bzip2, and tar


zip is probably the world’s most widely used format. That’s because of its almost universal use on Windows, but zip and unzip are well supported among all major (and most minor) operating systems


gzip was designed as an open-source replacement for an older Unix program, compress. It’s found on virtually every Unix-based system in the world, including Linux and Mac OS X, but it is much less common on Windows. If you’re sending files back and forth to users of Unix-based machines, gzip is a safe choice.


The bzip2 command is the new kid on the block. Designed to supersede gzip, bzip2 creates smaller files, but at the cost of speed. That said, computers are so fast nowadays that most users won’t notice much of a difference between the times it takes gzip or bzip2 to compress a group of files.


zip both archives and compresses files, thus making it great for sending multiple files as email attachments, backing up items, or for saving disk space.


$mkdir -p /opt/test/zip_dir;cd /opt/test/zip_dir

Append man pages to a file

$man ls > file-ls;cat /etc/fstab > file-fstab;cat /root/anaconda.cfg >


$ls -lh

$ls -al

Zip the files to

$zip *

$ls -lF

$ man ls > file-ls.txt;cat /etc/fstab > file.txt;cat /root/anaconda.cfg >

file-anaconda.txt;man fdisk > file1.cfg;man fstab > fstab.cfg;man man >


Try compressing the files created using zip and verify the size of



$zip -0 moby.zip1 *.txt

$ls -l

$zip -1 moby.zip2 *.cfg

$ls -l

$zip -9 moby.zip3 *.cfg

$ls -l

You can also try

$alias zip=’zip -9′

Create backup dir under mnt $mkdir/mnt/backup

Copy /opt/test contents with rsync

$rsync -parv/opt/test/* /mnt/backup/

Exclude under /mnt/backup and create under /usr/local/

$zip -r /usrlocal/ /mnt/backup -x “/mnt/backup/zip_dir/moby.zip1”

Change dir to /usr/local by pushd cmd (man pushd)

$pushd /usr/local/

Q3. Give an example of password protected zip?

Try Password protected zip

$ zip -P 12345678 *.txt

$ zip -e *.txt



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s