Archiving tools
Linux has many compression and archiving tools. Since we are very much used to Windows, these tools might seem difficult to learn as they are new. But once you know, you can easily use them. So let’s check the various archiving tools in Linux.
1. GZIP
Gzip command can be used to create a compressed file the .gz extension.
To compress and create a new file using gzip:
gzip -v xyz
NOTE: Works only on existing file!
Now that you have created a gz file how would you unzip it?
There are two ways to uncompress a gz file.
- Using gunzip
Just write the file name with gunzip.
gunzip -v xyz.gz
It will unzip the file in its current directory only, and a file with abc name file will be there. - Using gzip
We can also use gzip with a ‘-d’ switch to decompress a file.
gzip -dv abc.gz
Switches :
-d decompress
-t checks the integrity of the file.
-v verbose (Shows us the processing, and gives us details of the compression or decompression).
2. BZIP
Bzip is another compressing tool that you can use.
To create a file with bzip compression just enter the file-name after bzip :
bzip -v xyz
This will create a file named xyz.bz2
To decompress it you can either use bzip or bunzip2
bzip2 -dv abc.bz2
or
bunzip2 -dv abc.bz2
Switches
‘-d’ = decompress.
‘-v’ = verbose (Shows us the processing, and gives us details of the compression or decompression).
3. TAR
TAR commonly known as tarballs are one of the most used compressing tools. To create a new file we use
tar -cvf abc
‘-c’ is for create
‘-v’ is for verbose
‘-f’ is for forcefully performing the operation.
If you want, you can also create a tar file using
tar -cf abc
‘-c’ and ‘-f’ are the needed to create tar ball.
To untar the tar file we use
tar -xvf abc.tar
‘-x’ indicates extraction
‘-vf’ has the same meaning as above.
4. TAR+GZ
You can also use two compression techniques together, tar and gz. This will further compress the tar ball, and its extension will be tar.gz.
To create a tar.gz file run
tar -czvf abc.tar.gz smb.conf
tar -czvf ‘desired file-name.tar.gz’ ‘destination file-name’
‘-c’ indicates create and ‘-z’ is used to tell the OS to create a tar.gz file.
To untar tar.gz file, use
tar -xzvf abc.tar.gz
-x stands for extract and -z indicates a tar.gz file
Remember use ‘-c’ file for compression purpose, and ‘-x’ for extraction purpose.
5. TAR+BZ
Similarly, if you need to create a tar.bz file use ‘-j’ instead of ‘-z’
tar -cjvf abc.tar.bz2 smb.conf
tar -cjvf ‘desired file-name.tar.bz2’ ‘destination file-name’
Untar it by simply replacing ‘-c’ with ‘-x’
tar -xjvf abc.tar.bz2