This post will help you to know on archiving files in linux and compressing files in linux using various commands available in linux like compress, gzip, bzip2 and tar.
If you are interested in learning, Request you to go through the below recommended tutorial.
DevOps Full Course Tutorial for Beginners - DevOps Free Training Online
Docker Full Course Tutorial for Beginners - Docker Free Training Online
Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online
Ansible Full Course Tutorial for Beginners - Ansible Free Training Online
Openstack Full Course Tutorial for Beginners - Openstack Free Training Online
Learn Linux, DevOps and Cloud
Compression is a technique to reduce the size of bunch of files stacked together. Archiving is a method to make single file of multiple files and folders.
It has 2 steps, Archiving & compression:
1. Archiving files in Linux:
This is a process of collecting the files which have to be compressed and make a single file out of them, that is called archiving.
An Archive is made using "tar"(Tape Archive Command).
[root@selva ~]# tar -cvf example.tar *
Above command makes as an archive "example.tar" & puts all the files in current directory in it.
To list out the archived and compressed content without extracting as below,
[root@selva ~]# tar -tvf example.tar
2. Compressing files in Linux:
There are various tools to compress the file. They are follows:
Compress & Uncompress Tool:
To compress the file use the following command:
[root@selva ~]# compress example.tar
Above command makes a compressed file example.tar.Z in the current directory.
To uncompress the file use the following,
[root@selva ~]# uncompress example.tar.Z
Shortcut command to do compressing is,(Archiving + Compression)
[root@selva ~]# tar -Zcvf example.tar.Z
Shortcut Command to do the uncompressing is (Archiving + Uncompressing)
[root@selva ~]# tar -Zxvf example.tar.Z
GZIP & GUNZIP commands in Linux
To compress the file Gzip tool is used..
[root@selva ~]# gzip example.tar
Above Command makes a compressed file example.tar.z in the current directory.
To Uncompress the file Gunzip tool is used..
[root@selva ~]# gunzip example.tar.z
Shortcut command to do the compressing is (Archiving + Compression )
[root@selva ~]# tar -zcvf example.tar.z
Shortcut command to do Uncomressing ( Archiving + Uncompression )
[root@selva ~]# tar -zxvf example.tar.z
BZIP2 & BUNZIP2 commands in Linux
To compress the file using bzip tool,
[root@selva ~]# bzip2 example.tar
Above command makes a compressed file example.tar.bz2 in the current directory.
To Uncompress the file bunzip2 tool is used,
[root@selva ~]# bunzip2 example.tar.bz2
Shortcut command to do the compressing ( Archiving + Compression )
[root@selva ~]# tar -jcvf example.tar.bz2
Shortcut command to do the uncompressing ( Archiving + Uncomression )
[root@selva ~]# tar -jcvf example.tar.bz2
That's it for this post.
Related Content on Linux might be useful to you to improve your Linux Skills.
How to Configure IP Address on Ubuntu using Netplan
How to Access Linux Server from Windows Remotely
Configure SSH Passwordless Login Authentication (SSH-keygen)
How to Create LVM Partition in Linux – LVM Tutorial
Install & Configure Samba Server on Linux (RHEL7 / CentOS7)
How to Access Linux Server from Windows Remotely
Configure SSH Passwordless Login Authentication (SSH-keygen)
How to Create LVM Partition in Linux – LVM Tutorial
Install & Configure Samba Server on Linux (RHEL7 / CentOS7)
Keep practicing and have fun. Leave your comments if any.
Support Us: Share with your friends and groups.
Stay connected with us on social networking sites, Thank you.
0 Comments