Portal Home > Knowledgebase > Articles Database > How to compress a file to its MAX?


How to compress a file to its MAX?




Posted by awaisuk, 09-11-2009, 08:05 PM
How to compress a file to its MAX? Like i have a 700mb file, i want to compress it to its MAX so the size comes down ALOT. What can i do on my dedicated server to achieve that? Please tell me the commands if possible as i am a newbie at server management.

Posted by Mashii, 09-11-2009, 08:18 PM
One thing that might help is mentioning what OS you are running on the server

Posted by MattS, 09-11-2009, 08:19 PM
What you can do is something like this: That will compress it where mydir is the directory you're trying to compress. Then run this when you want to "decompress it": Note: You need to login to shell and do the cd command first to locate what you want to compress and then use the above commands. That's if you have tarball and gunzip installed on your server

Posted by awaisuk, 09-11-2009, 08:25 PM
I have CENTOS and i own the dedicated server so i have root access. So just an estimate, 700mb file will compress to what size? Also if i download that file to my PC, can i "extract" it using winrar or something?

Posted by MattS, 09-11-2009, 08:50 PM
Yeah you can extract it using 7-zip even I do it all the time with cPanel backups. You'd have to try it and see what size it comes out to as I don't know the compression rate / ratio. I just compress it and go lol.

Posted by net, 09-11-2009, 08:54 PM
Moved > Technical & Security Issues.

Posted by Krishopper, 09-11-2009, 09:51 PM
Try using bzip2 at its highest compression level: bzip2 -9 That is some of the best compression I have seen. Keep in mind that the amount the file will compress by cannot be predetermined; it depends what type of data is in the file. If the file is an encrypted file, it will not get compressed very well at all. If it's a text file, it will compress VERY well. It all depends on how much repeatable data patterns can be found inside of the file.

Posted by StevenG, 09-11-2009, 09:53 PM
gzip -9 filename # man gzip

Posted by adwaitk007, 09-11-2009, 11:12 PM
you can also use magic iso

Posted by nomankhn, 09-11-2009, 11:18 PM
Please tell us the file format which you have, if it is *.iso file format it will not compress and if it is already compress it will not compress. if it is text file or sql dump of mysql it will compress. You can use use bzip or seven as earlier suggested.

Posted by sysgallery, 09-12-2009, 06:58 AM
I can only say you can go ahead using this: tar -cjvf compressedfilename.tar.bz2 It can compress in most cases to 7MB, if all are normal files.

Posted by awaisuk, 09-12-2009, 08:12 PM
Ok, its a VIDEO (AVI) file that i am trying to compress. Which compression should i use to make it the smallest size possible?

Posted by Krishopper, 09-12-2009, 08:14 PM
Video is already pretty compressed with the codec's that are used to create them. You probably won't get much out of it by compressing it.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
SFTP /FTPS by Default (Views: 442)