In Unix- Linux , the name of the tar
command is short for tape archiving, the storing of entire file systems onto magnetic tape, which is one use for the command. However, a more common use for tar
is to simply combine a few files into a single file, for easy storage and distribution.
The tar command used to rip a collection of files and directories into highly compressed archive file commonly called tarball or tar, gzip and bzip in Unix – Linux. The tar is most widely used command to create compressed archive files and that can be moved easily from one disk to another disk or machine to machine.
2. Create tar.gz Archive File
To create a compressed gzip archive file we use the option as z. For example the below command will create a compressed emrepic.tar.gz file for the directory /emre. (Note : tar.gz and tgz both are similar).
[root@cent ~]# tar cvzf emrepic.tar.gz emre emre/ emre/emrepics1.jpg emre/emrepics2.jpg emre/emrepics3.jpg emre/emrepics4.jpg emre/emrepics5.jpg [root@cent ~]# ls -ltr total 4 drwxr-xr-x. 2 root root 195 Mar 21 11:57 emre -rw-r--r--. 1 root root 213 Mar 21 12:13 emrepic.tar.gz