Linux Mall - The Linux SuperStore!
Linux books, Linux CDs, Linux toys, you name it, they have it!

W W W . L I N U X D O T . O R G

Newbie's Linux Manual
Tar and Feathers - Without the Feathers
] [ Download*] [ Previous] [ Next] Home] [ Contents] [ Download*] [ Previous] [ Next] Homepage| The Last 5 Days| The Daily Linux News| The Linux Bits| Newbie's Linux Manual
The Best Linux Sites| Linux Book Reviews| A Windows Vendetta?
Diary of a Linux Newbie| Diary of an Open Source Newbie
The Linux Forum| Just For Fun Amazon - The World's Biggest Bookstore!
4.7 million books, CDs, videos, and DVDs available to buy! Webmaster| Manual's Copyright Terms
[
* In Linux enter: unzip nlm.zip
tar Made Easy

There's a lot to the tar command, but I'm not going to confuse you with information you'll hardly ever use (if ever).

Just remember, to create an archive you use c and to extract an archive you use x. After the c or the x add vf - followed by z if you need to compress/uncompress the archive.

Here I'm extracting a file called thebits.tar.gz:

tar xvfz thebits.tar.gz

...and here I'm archiving a subdirectory of the current directory called thebits:

tar cvfz thebits.tar.gz thebits
An Exercise in tar

To help everything sink in, follow this quick exercise:

- 1 -

Enter the following to create a temporary directory for this exercise:

mkdir work

- 2 -

Create the files 1, 2, and 3 in the work directory with the following command:

touch work/1 work/2 work/3

- 3 -

Now let's archive the work directory and compress it at the same time using gzip (indicated by the z flag). If the z flag had not been used then it would've been proper to call the archive work.tar, but because of the z flag it's proper to call the file work.tar.gz. Enough explaining, enter the following:

tar cvfz work.tar.gz work

- 4 -

Now that the directory has been archived, the work directory can be removed:

rm -r work

- 5 -

Now let's extract the archive. Once again you will be required to uncompress the archive at the same time, (this time using gzip's partner in crime: gunzip) again indicated by the z flag. (If this had been a .tar file then you wouldn't use the z flag.) Anyway here's the command:

tar xvfz work.tar.gz

- 6 -

Now that you have no more need of work.tar.gz, you can remove it:

rm work.tar.gz

- 7 -

To prove that everything's worked out fine, enter:

tree work

...to display the following:

work
|-- 1
|-- 2
`-- 3

- 8 -

And now that the exercise is finished, enter:

rm -r work
[
* In Linux enter: unzip nlm.zip
© MM Linuxdot.org |