Archiving

From Cosmin's Wiki

Jump to: navigation, search

Home > Linux how to's > Archiving



Contents


Using tar

In order group several files in the same package, you would create a .tar archive. Packing/Unpacking from a .tar archive is done like this:

 
> tar -cf archive.tar foo bar  # Create archive.tar from files foo and bar.
> tar -tvf archive.tar         # List all files in archive.tar verbosely.
> tar -xf archive.tar          # Extract all files from archive.tar.
 

However, tar has quite a lot of functionalities, one of which I find really useful, namely creating a .tar.gz archive automatically (packing&archiving). To pack/unpack such an archive you would go like this:

 
> tar -czpf archive.tar.gz foo bar  # Create archive.tar.gz (gzipped) from files foo and bar.
> tar -xzpf archive.tar             # Extract all files from archive.tar.