LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 03-20-2010, 04:22 AM   #1
salimshahzad
Member
 
Registered: Dec 2009
Posts: 200

Rep: Reputation: 15
tar error


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

regards
 
Old 03-20-2010, 04:29 AM   #2
Maligree
Member
 
Registered: Mar 2008
Distribution: Gentoo, CentOS, Fedora, Arch
Posts: 231
Blog Entries: 1

Rep: Reputation: 42
You didn't tell tar what to archive:
Code:
tar cvzf /test/backup_app/test_app.tar.gz /directory/to/tar
if you're in there already, just do
Code:
tar cvzf /test/backup_app/test_app.tar.gz .
 
Old 03-20-2010, 05:32 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

@salimshahzad: The command given is not correct. You need to tell tar the name of the archive (which you did) and what to tar (which you did not).

tar cvf name.of.archive.tar /target/to/tar
or
tar cvf name.of.archive.tar file1 file2

Take a look here: tar manual: 2.6 How to Create Archives

Hope this helps.
 
Old 03-20-2010, 05:43 AM   #4
salimshahzad
Member
 
Registered: Dec 2009
Posts: 200

Original Poster
Rep: Reputation: 15
dear gurus thanks for support i miss next line

suggest how to do full compress or max compress in linux

rgds
 
Old 03-20-2010, 05:49 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

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.

Take a look here as well: 8.1 Using Less Space through Compression

Hope this helps.

Last edited by druuna; 03-20-2010 at 05:52 AM. Reason: Added external link
 
Old 03-20-2010, 05:54 AM   #6
salimshahzad
Member
 
Registered: Dec 2009
Posts: 200

Original Poster
Rep: Reputation: 15
dear gurus thanks so nice quick repsonse

some people do .tar.gz file does it means it is compress by default, as i heard there r 7-9 level of compression to use in tar/gz combination

your option tar cvZ name.tar file <- uses compress to compress.
does it compress fully max.

1 more query 2 clarify, how to do full or max compression level use in linux for any directory or files.

kind regards again
salim
 
Old 03-20-2010, 06:19 AM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

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.
 
Old 03-20-2010, 10:32 AM   #8
nonamenobody
Member
 
Registered: Oct 2002
Posts: 138

Rep: Reputation: 22
Quote:
Originally Posted by druuna View Post
Hi,

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.
 
Old 03-20-2010, 11:41 AM   #9
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Quote:
Originally Posted by nonamenobody View Post
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.
 
Old 03-20-2010, 12:09 PM   #10
nonamenobody
Member
 
Registered: Oct 2002
Posts: 138

Rep: Reputation: 22
Quote:
Originally Posted by druuna View Post
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.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in TAR - tar: GNU features wanted on incompatible archive format. kuldeep.k Linux - General 3 08-14-2009 11:09 AM
tar this does not look like a tar archive exit depalyed from previous error tasay Linux - Software 1 07-01-2009 03:34 PM
tar & un tar Data integrity error ShadowHywind Linux - General 1 08-13-2008 08:29 PM
Tar gives error when creating a tar file archive davidas Linux - Newbie 10 04-13-2004 12:35 AM
problem unzipping a tar.bz2 file tar: Error is not recov jyome Linux - Software 4 09-04-2003 01:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration