Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
dear gurus i am facing tar error i try many ways but always fail i copy some file/folder from windows pc to linux and wish to make .tar.gz file
however other location folders it is working fine
[root@test7 ]# tar -cvf /test/backup_app/test_app.tar.gz
tar: Cowardly refusing to create an empty archive
Try `tar --help' or `tar --usage' for more information
[root@test7 ]# tar cvzf /test/backup_app/test_app.tar.gz
tar: Cowardly refusing to create an empty archive
Try `tar --help' or `tar --usage' for more information
[root@test7 ]# tar -cvzf /test/backup_app/test_app.tar.gz
tar: Cowardly refusing to create an empty archive
Try `tar --help' or `tar --usage' for more information
Tar (the basics) just creates an archive, it does not compress anything.
Depending on your version of tar you can go 2 ways to compress your data:
1) first use a compressing tool (like bzip2, zip, etc), then tar all the comressed files.
2) use tar's build in compression options (this needs to be present in your tar version. it probably is).
An example of the second option:
tar cvz name.tar file <- uses gzip to compress. tar cvj name.tar file <- uses bzip2 to compress. tar cvZ name.tar file <- uses compress to compress.
The name a tarfile gets is all up to the user and doesn't necessarily say anything about the way the archive was created/compressed.
Logic says (but keep my previous comment in mind) that a file ending with:
.tar -> archived with tar (no compression) .tar.gz or .tgz -> compressed by gzip and archived by tar (the compression part can be done by tar's -z option or gzip itslef). .tar.bz -> compressed with bzip2, archived by tar.
I don't think tar can handle the extra compression that some of the tools (gzip. bzip2 etc) have. I haven't seen options for it.
If extra compression is needed take a look at, for example, gzip's options to do so (gzip -# <1-9> <file> or gzip -best <file>). This also means that you need to gzip the file(s) first and then use tar to archive the lot.
bzip2 also has an option for extra compression: bzip2 -1 <file> -> bzip2 -9 <file> 1 being fast and less compression, 9 being slow and best compression.
Hope this helps.
Last edited by druuna; 03-20-2010 at 11:42 AM.
Reason: Fixed a typo, thanks nonamenobody for the heads up.
The name a tarfile gets is all up to the user and doesn't necessarily say anything about the way the archive was created/compressed.
Logic says (but keep my previous comment in mind) that a file ending with:
.tar -> archived with tar (no compression) .tar.gz or .tgz -> compressed by gzip and archived by tar (the compression part can be done by tar's -z option or gzip itslef). .tar.bz -> compressed with bzip2, archived by tar.
I don't think tar can handle the extra compression that some of the tools (gzip. bzip2 etc) have. I haven't seen options for it.
If extra compression is needed take a look at, for example, gzip's options to do so (gzip -# <1-9> <file> or gzip -best <file>). This also means that you need to gzip the file(s) first and then use tar to archive the lot.
bzip2 also has an option for extra compression: bzip2 -1 <file> -> bzip -9 <file> 1 being fast and less compression, 9 being slow and best compression.
Hope this helps.
I would mostly agree with that except that:
If you wanted to use the 'bzip2' or 'gzip' commands to compress manually, you would archive them first using tar and then compress that one file - rather than compress each file and then archiving.
AFAIK The bzip2 command is 'bzip2' not 'bzip' (probably a typo).
I would presume that tar uses the default compression that bzip2 and gzip, but if it doesn't I doubt there are would be a lot of difference between level 1 and level 9 (certainly for bzip2, the man page indicates that there isn't much difference. I suppose you could experiment quite easily and see which level created a file the same size.
Typically bzip2 typically offers the best compression rates and is the slowest. Compress is (I believe) fast but doesn't offer good very ratios except for very repeatative files which it can compress better than bzip2. gzip is a good all rounder.
Tar can also compress using lzip, XV, LZMA and LSOP (though I have never used these, or seen them being used).
RAR probably offers the best compression ratios, however it included by distributors (though unrar is), so you'll have to download it from rarsoft.com
Files which are already compressed (e.g. JPEGs), generally can't be compressed any further. You would probably find that if you were to tar them and then gzip them, the tar.gz would be slightly larger than the original tar file.
I would mostly agree with that except that:[list][*]If you wanted to use the 'bzip2' or 'gzip' commands to compress manually, you would archive them first using tar and then compress that one file - rather than compress each file and then archiving.
That would depend on what is best for the situation. You are correct if the smallest possible archive is what you want/need. If disk space is a possible issue (especially during restoring), it is better to compress each individual file first and archive that. Due to the extra compress headers the archive will be a bit bigger.
Quote:
[*]AFAIK The bzip2 command is 'bzip2' not 'bzip' (probably a typo).
A typo indeed. Corrected it in my original reply. Thanks for pointing that out.
Hi,
That would depend on what is best for the situation. You are correct if the smallest possible archive is what you want/need. If disk space is a possible issue (especially during restoring), it is better to compress each individual file first and archive that. Due to the extra compress headers the archive will be a bit bigger.
I have never even thought about doing it that way around. I'll have to remember that as there are times when it could be handy.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.