In Linux there various commands which help us to compress and decompress a data. By doing a compression we can able to reduce the size of the data and data will not be missing while transferring from one server to other.
Zip
zip is a compression and file packaging utility for Unix/Linux. Each file is stored in single .zip {.zip-filename} file with the extension .zip.
Compress for zip
Zip a folder for zip
Decompress
Gzip
Gzip compress the size of the given files using Lempel-Ziv coding (LZ77). Whenever possible, each file is replaced by one with the extension .gz.
gzip is a commonly used compression format in GNU/Linux platforms
Compress for gzip
Decompress for gzip
Bzip2
bzip2 compresses files using the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding. Compression is generally considerably better than that achieved by bzip command (LZ77/LZ78-based compressors). Whenever possible, each file is replaced by one with the extension .bz2
Compress for bzip2
Decompress for bzip2
Gzip and Bzip2 with tarball
The GNU tar is archiving utility but it can be use to compressing large file(s). GNU tar supports both archive compressing through gzip and bzip2. If you have more than 2 files then it is recommended to use tar instead of gzip or bzip2
-z: use gzip compress
-j: use bzip2 compress
Compress for gzip
Compress for bzip2
Decompress for bzip2
Zip
zip is a compression and file packaging utility for Unix/Linux. Each file is stored in single .zip {.zip-filename} file with the extension .zip.
Compress for zip
root@linuxstorage:~#zip data.zip data
root@linuxstorage:~#ls
data.zip
Zip a folder for zip
root@linuxstorage:~#zip -r folder.zip data
root@linuxstorage:~#ls
folder.zip
Decompress
root@linuxstorage:~#unzip data.zip
root@linuxstorage:~#ls
data
Gzip
Gzip compress the size of the given files using Lempel-Ziv coding (LZ77). Whenever possible, each file is replaced by one with the extension .gz.
gzip is a commonly used compression format in GNU/Linux platforms
Compress for gzip
root@linuxstorage:~#gzip data
root@linuxstorage:~#ls
data.gz
Decompress for gzip
root@linuxstorage:~#gunzip data.gz
root@linuxstorage:~#ls
data
OR
root@linuxstorage:~#gzip -d data.gz
root@linuxstorage:~#ls
data
Bzip2
bzip2 compresses files using the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding. Compression is generally considerably better than that achieved by bzip command (LZ77/LZ78-based compressors). Whenever possible, each file is replaced by one with the extension .bz2
Compress for bzip2
root@linuxstorage:~#bzip2 data
root@linuxstorage:~#ls
data.bz2
Decompress for bzip2
root@linuxstorage:~# bzip2 -ddata.bz2
or
root@linuxstorage:~#gunzip data.bz2
root@linuxstorage:~#ls
data
Gzip and Bzip2 with tarball
The GNU tar is archiving utility but it can be use to compressing large file(s). GNU tar supports both archive compressing through gzip and bzip2. If you have more than 2 files then it is recommended to use tar instead of gzip or bzip2
-z: use gzip compress
-j: use bzip2 compress
Compress for gzip
root@linuxstorage:~#tar -zcvf data.tar.gz [/path/files]root@linuxstorage:~#ls
data.tar.gz
- -z: Compress archive using gzip program
- -c: Create archive
- -v: Verbose i.e display progress while creating archive
- -f: Archive File name
root@linuxstorage:~#tar -zxvf data.tar.gz
root@linuxstorage:~#ls
data
- -x: Extract files
Compress for bzip2
root@linuxstorage:~#tar -jcvf data.tar.bz2 [/path/files]root@linuxstorage:~#ls
data.tar.bz2
Decompress for bzip2
root@linuxstorage:~#tar -jxvf data.tar.bz2
root@linuxstorage:~#ls
data
0 comments :
Post a Comment