Linux Certification

Tar and untar

by lpilinuxblog on Dec.22, 2009, under About LPI

“To get the files out of a tarball, you can use the following commands:

tar xvf something.tar

If the tarball has also been gzipped (compressed), you can use the following command:

tar xvfz something.tar.gz

If you only want certain directories from the tarball, do this:

tar xvzf something.tar.gz */dir.you.want/*

If you have a .tar.bz2 file, then you need bzip2 installed (/usr/ports/archivers/bzip2), and you issue this command:

tar yxf something.tar.bz2

tar
To tar up *.db in the current directory into a tarball called blah.tar.gz, issue this command:

tar cfz blah.tar.gz *.db

The z option compresses.
listing the contents
To see a list of the files within a tarball, issue the following command:

tar -tzf blah.tar.gz

The -t provides a list. the -z indicates that the tarball is compressed. The -f identifies the tarball.

Here’s an example:

# tar -tzf files.dwhs.tgz
etc/
etc/protocols
etc/aliases
etc/services
etc/hosts”ezlinuxadmin.com

  • Share/Bookmark

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...