LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 09-07-2002, 05:35 PM   #1
radnix
Member
 
Registered: Aug 2002
Location: Huntsville AL
Distribution: redhat 7.3
Posts: 48

Rep: Reputation: 15
tar a directory


If I use the following command : tar czvf somedirectory.tar directory ......... will this tar up my entire directory path to include hidden files?

Would I then use the : tar xzvf somedirectory.tar to untar a mirror image of the entire directory tree plus hidden files to the location of my choice?

I've read the man pages, tried it and seams to work....just want some input to make sure I'm doing this right.

Thanks ahead. ......doesn't hurt to ask .
 
Old 09-07-2002, 05:53 PM   #2
mace
Member
 
Registered: Apr 2002
Distribution: redhat7, 7.1, 7.2, 8.0, mandrake, debian2.2, 3, suse
Posts: 176

Rep: Reputation: 30
tar -czvf backup.tgz /home/wambo


to undo

tar -xzvf backup.tgz
 
Old 09-07-2002, 07:59 PM   #3
radnix
Member
 
Registered: Aug 2002
Location: Huntsville AL
Distribution: redhat 7.3
Posts: 48

Original Poster
Rep: Reputation: 15
tar,tar.gz,tgz hummmm...

Thanks for the responce. I think I understand that a tar is as in "gathered" and that *.tar.gz is added compresion if I've got it right

I hadn't seen the *.tgz...is that similiar to *.tar.gz ?
 
Old 09-07-2002, 09:45 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
Yes, you got it right. Tar puts all files from a directory, including its sub-directories, ownership and access-rights, in a single . tar file. The 'z'-option compresses the .tar file using gzip, thus creating a .tar.gz.

So:
tar czvf some_name.tar.gz some_dir

is the same as:

tar cvf some_file.tar some_dir

...and then compressig it with:

gzip some_file.tar

The same goes for un-tarring (and decompressing), in the opposite order, like:

gunzip some_file.tar.gz
tar xvf some_file.tar

or:

tar xzvf some_file.tar.gz

The 'v' options tells 'tar' to be verbose, i.e. leaving the 'v' option out will do exacly the same thing, but silently.

And, yes, "aFile.tgz" is the same as "aFile.tar.gz".

Today often tar-files are compressed with "bzip2". The files are named like "aFile.tar.bz2". You can decompress them with "bunzip2", or in one go (with recent tar versions) with the 'j' or 'I' (capital 'i') option (depends on your tar-version) instead of 'z'. Like

tar cjvf some_name.tar.bz2 some_dir

or

tar cIvf some_name.tar.bz2 some_dir

Last edited by Hko; 09-07-2002 at 09:49 PM.
 
Old 09-07-2002, 09:54 PM   #5
neo77777
LQ Addict
 
Registered: Dec 2001
Location: Brooklyn, NY
Distribution: *NIX
Posts: 3,704

Rep: Reputation: 55
To preserve permissions and ownership of the files use p flag as well
tar cvfpz archive.tar.gz [archive.tgz] /home/username
tar xvfzp archive.tar.gz [archive.tgz]
 
Old 09-08-2002, 08:43 AM   #6
radnix
Member
 
Registered: Aug 2002
Location: Huntsville AL
Distribution: redhat 7.3
Posts: 48

Original Poster
Rep: Reputation: 15
Got it!

Now I got it !

Yeah, that works great plus the ownership and permissions.

Thanks guys !
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How Can I tar This Directory? Xian Linux - General 4 06-17-2005 06:32 PM
tar help - how to tar to a different directory thick_guy_9 Linux - Software 2 03-10-2005 04:35 PM
tar with directory path scatterbrain Linux - General 2 03-15-2004 11:05 PM
tar a directory kbeaver Linux - General 4 09-12-2003 11:00 AM
Can I tar a directory structure.... shelby Linux - General 9 02-20-2003 09:17 AM


All times are GMT -5. The time now is 04:01 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration