![]() |
![]() |
Newbie's Linux Manual |
Tar and Feathers - Without the Feathers |
by Laurence Hunter |
[ Home ] [ Contents ] [ Download*] [ Previous ] [ Next ] |
* 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 |
[ Home ] [ Contents ] [ Download*] [ Previous ] [ Next ] |
* In Linux enter: unzip nlm.zip |
The Newbie's Linux Manual is reproduced on LinuxMall.com by permission. The Newbie's Linux Manual is written and maintained by Laurence Hunter. You can find much more of Laurence's work at his site: www.Linuxdot.org |
© 1999 Linuxdot.org | Manual's Copyright Terms