How to create a .tar, .tar.gz and .tar.bz2 file?
# tar -cf example.tar example
# tar -zcf example.tar.gz example
# tar -jcf example.tar.bz2 example
root@server [~]# ll
drwxr-xr-x 2 root root 4096 Dec 6 07:02 example/
-rw-r–r– 1 root root 30720 Dec 6 08:11 example.tar
-rw-r–r– 1 root root 912 Dec 6 08:11 example.tar.bz2
-rw-r–r– 1 root root 659 Dec 6 08:11 example.tar.gz
How to extract a .tar, .tar.gz and .tar.bz2 file?
# tar -xf example.tar
# tar -zxf example.tar.gz
# tar -jxf example.tar.bz2
If you use ‘v’ switch in the above examples, it will display detail message during the command execution.
How to compress a file using zip, gzip and bzip2?
# zip file.zip file
# gzip file
# bzip2 file
root@server [~]# ll
-rw-r–r– 1 root root 14 Dec 6 08:16 file.bz2
-rw-r–r– 1 root root 25 Dec 6 08:15 file.gz
-rw-r–r– 1 root root 140 Dec 6 08:15 file.zip
How to extract zip, gzip and bzip2 compressed files?
# unzip file.zip
# gunzip file.gz
# bzip2 -d file.bz2
With gunzip and bzip2, the files will be extracted but you will no longer have the compressed file.
Comments are closed.