LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 01-17-2012, 07:01 AM   #1
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Compressing a file to a very smaller size.


Hi,

How to compress a single file of 2GB size so that I can reduce it in a most possible smaller size. I used some of the commands like:

#tar -cvf filename.tar.bz2 filename

and it reduces that 2GB file in 859MB filesize.
 
Old 01-17-2012, 07:41 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
With gzip you can try using -9 or --best options for "best compression."

With bzip2 you can try those same options and/or --repetitive-best.

Compression tends to depend upon content and these command line options may or may not be of benefit -- it's a try it and see sort of thing.

Hope this helps some.
 
1 members found this post helpful.
Old 01-17-2012, 07:54 AM   #3
Hikanthus
LQ Newbie
 
Registered: Dec 2011
Posts: 3

Rep: Reputation: Disabled
That is the correct command to use, to compress a file.

However, sometimes, depending on the contents of the file, it won't compress very efficiently. Some types of data are very repetitive, and therefore will compress very well, to a much smaller size. Data that is not very repetitive, such as images (jpgs are already inherently compressed), recorded sound, or just plain random data, don't compress very well.

Data that is highly repetitive, such as a simple text document, or log file, or even structured data files, such as database files, will compress very well. simple text files can often compress down to 10-15% of the original size.

Without knowing what data you are trying to compress, i would say that 2G compressing down to 850ish MB is pretty decent for mixed data.

-Matt
 
Old 01-17-2012, 08:25 AM   #4
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420

Original Poster
Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Quote:
Without knowing what data you are trying to compress, i would say that 2G compressing down to 850ish MB is pretty decent for mixed data.
It is a single database file of 2GB and yeah I know 850MB is good but I was wondering if there is any other method to bring it's size more less..
 
Old 01-17-2012, 08:29 AM   #5
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Use xz compression:

Code:
tar -cJf test.tar.xz test
Or for absolutely max compression:

Code:
tar -cf - test | xz - -9 -e > test.tar.gz

Last edited by H_TeXMeX_H; 01-17-2012 at 08:35 AM.
 
Old 01-17-2012, 08:34 AM   #6
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
you can try also 7zip to see if size will be smaller

good luck
 
1 members found this post helpful.
Old 01-17-2012, 08:54 AM   #7
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420

Original Poster
Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
When I tried this format :
Quote:
tar -cf - test | xz - -9 -e > test.tar.gz
on my server:

Quote:
[root@testmachine tmp]# tar -cf - 2gbfile | xz - -9 -e > 2gbfile.tar.gz
-bash: xz: command not found
[root@testmachine tmp]#
it gave above output.
Was there something wrong I did?
 
Old 01-17-2012, 09:13 AM   #8
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Quote:
Was there something wrong ...
May be a missing package xz : # apt-get install xz / # yum install xz
 
Old 01-17-2012, 09:20 AM   #9
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
It's a single file (not a directory)? If so, try one of the options I gave you; e.g.,
Code:
bzip2 --repetitive-bist 2gigfile
See what that does for you; also try the other options and see what they do. You'll wind up with 2gifile.bz2.

If it's a single file, there really isn't much use in making a tar archive; I mean, you know where it was so you know where to bunzip2 it if you need it back, eh?

If you don't have the XZ utilities, you can find them at http://tukaani.org/xz or, perhaps, your distribution software site.

Hope this helps some.
 
Old 01-17-2012, 10:29 AM   #10
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
What you have already achieved is pretty darned good. Call it "good enuf," and move along.
 
Old 01-17-2012, 03:56 PM   #11
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,980

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
See this.
PAQ8px -7

http://www.maximumcompression.com/data/summary_mf.php
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I make PDF documents smaller (In file size)? vdemuth Linux - Software 7 11-05-2011 09:39 AM
[SOLVED] smaller video file size with guvcview? SChipS Linux - Software 6 03-01-2010 12:57 PM
make mpg file size smaller secretlydead Linux - Software 2 02-14-2005 08:42 AM
when creating a *.iso file, how to make the file size smaller? minm Linux - Newbie 8 12-26-2004 09:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:08 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