

When compared, the various compression commands shown above yielded the following results. Compression rates will depend to some extent on the content of the files. This file is a large and fairly random text file. The stats shown below all relate to compressing the single file – bigfile – used in the example commands shown above. So, let's compare file size as well as some other issues to be considered when you make plans for how you want to compress your files. Most people have heard it said that "size isn't everything".

rw-rw-r- 1 shs shs 13427236 Apr 15 17:30 bigfile.xzįor large files, you are likely to notice that xz takes longer to run than other compression commands, but the compression results are very impressive. Again, the original file is compressed in place.

Like the two previous commands, you only need to supply the file name to the command. rw-rw-r- 1 shs shs 18115234 Apr 15 17:57 bigfile.bz2Ī relative newcomer to the compression command team, xz is a front runner in terms of how well it compresses files. rw-rw-r- 1 shs shs 21606751 Apr 15 17:57 bigfile.gzĪs with the gzip command, bzip2 will compress the file that you select "in place", leaving only the original file. In other words, the original file will be replaced by the encrypted file. Unlike the commands described above, gzip will encrypt the files "in place". You just type "gzip" followed by the name of the file you want to compress. The syntax is straightforward except that, as with tar, you have to remember that your original file should be the last argument on the command line.
Xz compression linux zip#
The zip command creates a compressed file while leaving the original file intact. Here’s an example: $ tar cfz bin.tgz bin/* ^ ^ | +- files to include + new file zip

To collect a number of files together and compress the resultant “tar ball” in one command, use the same basic syntax, but specify the files to be included as a group in place of the single file. You will be left with both the original file and the compressed file once the compression is complete. If you prefer, you can use the tar.gz extension which might make the character of the file a bit more obvious, but most Linux users will probably recognize tgz as meaning the same thing – the combination of tar and gz to indicate that the file is a compressed tar file. Note the significant reduction in the file size. To use tar for this, just identify the file as you would a group of files with a “tar cfz newtarfile filename” command like this: $ tar cfz bigfile.tgz bigfile You can use tar to compress a single file as easily as a group though this offers no particular advantage over using gzip directly.
