Linux Scroll

Just another site

Linux zip and unzip – Tar

Compress (tar) a folder using tar command
To tar a folder without compress:

$ tar -cvf folder.tar > folder

* c – create a new archive
* v – verbosely list files which are processed.
* f – following is the archive file name

To tar a folder with compress:

$ tar -czvf folder.tar.gz folder/

tar -czvf /tmp/file.25Aug2011.tar.gz file

* z – gzip
* j – bzip2

Extracting (untar) an archive using tar command
To untar an archive folder.tar:

$ tar -xvf folder.tar

* x – extract files from archive

To untar an archive folder.tar.gz:

$ tar -xvfz folder.tar.gz

To untar an archive folder.tar.bz2:

$ tar -xvfj folder.tar.bz2

View the tar archive file content without extracting:

$ tar -tvf folder.tar

* t – list the content

Adding a file or directory to an existing archive:

$ tar -rvf folder.tar file

* r – append

Direct extract to destination:

$ tar -xvfz folder.tar.gz -C /path/destination/

Extract zip file:

$ unzip -aq

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: