LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   tar a directory (https://www.linuxquestions.org/questions/linux-general-1/tar-a-directory-29839/)

radnix 09-07-2002 05:35 PM

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 . :study:

mace 09-07-2002 05:53 PM

tar -czvf backup.tgz /home/wambo


to undo

tar -xzvf backup.tgz

radnix 09-07-2002 07:59 PM

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 ?:study:

Hko 09-07-2002 09:45 PM

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

neo77777 09-07-2002 09:54 PM

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]

radnix 09-08-2002 08:43 AM

Got it!
 
Now I got it !

Yeah, that works great plus the ownership and permissions.

Thanks guys !:cool:


All times are GMT -5. The time now is 08:14 PM.