Quick Info - tar & gzip

Creating Archives
File
tar -cvf flints.tar barney.txt fred.txt betty.txt

Creating Compressed Archives
File
tar -czvf flints.tgz barney.txt fred.txt betty.txt
Folder
tar -czvf flints.tgz PATH/folder_name/

Extracting from Archives
To extract files from an archive use:
tar -xvf [filename.tar...]

For example to extract all the files of the archive `flints.tar' (created in the previous section)
tar -xvf flints.tar
This will extract the files `fred.txt barney.txt betty.txt'

To extract only `fred.txt'
`tar -xvf flints.tar fred.txt'
This will extract the files `fred.txt'

Extracting Compressed Archives (Tarball)

You can use the 'z' option to extract compressed archives - these are the most common and have .tgz or .tar.gz filename extensions. For example:
tar -zxvf flints.tgz

Viewing Archive Contents

What if you only want to view the contents of the archive witout extracting them.
tar -tf
lets you do that.

For example to view the members of the archive `flints.tar'
tar -tf flints.tar
This will show you the following
fred.txt
barney.txt
betty.txt

Comments

Popular Posts