18 Tar Command Examples – Unix/Linux


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.


1. Create tar Archive File

The below example command will create a tar archive file tecmint-14-09-12.tar for a directory /home/tecmint in current working directory. See the example command in action.

[root@cent emre]# ls -ltr
total 0
-rw-r--r--. 1 root root 0 Mar 21 11:57 emrepics3.jpg
-rw-r--r--. 1 root root 0 Mar 21 11:57 emrepics2.jpg
-rw-r--r--. 1 root root 0 Mar 21 11:57 emrepics1.jpg
-rw-r--r--. 1 root root 0 Mar 21 11:57 emrepics9.jpg
-rw-r--r--. 1 root root 0 Mar 21 11:57 emrepics8.jpg

[root@cent emre]# cd ..
[root@cent ~]# ls -ltr
total 0
drwxr-xr-x. 2 root root 195 Mar 21 11:57 emre
[root@cent ~]# tar -cvf emrepics.tar emre

Let’s discuss each option that we have used in the above command for creating a tar archive file.

  1. c – Creates a new .tar archive file.
  2. v – Verbosely show the .tar file progress.
  3. f – File name type of the archive file.


Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.