Skip to content

Tar command

July 24, 2010

tar command is used to create archive and extract the archive files.

The Syntax is
tar [options] [archive-file] [File or directory to be archived]


-c Creates Archive
-x Extract the archive
-f creates archive with give filename
-t displays or lists files in archived file
-u archives and adds to an existing archive file
-v Displays Verbose Information
-A Concatenates the archive files


  1. To archive a directory or file :
    tar -cvf backup.tar /etc

    This command creates a tarfile called backup.tar which is the archive of /etc directory.

    backup.tar – Is a tar file created
    /etc – Is a directory archived
  2. To archive a directory or file and store it in a storage device:
    tar -cvf /dev/fd0 /home/user1/HGB

    This command will archive /etc directory and store it in floppy-disk.

    /dev/fd0 – Is a floppy-disk name where the archive is stored
    /home/user1/HGB – Is a directory archived
  3. To Extract the archive:
    tar -xvf backup.tar

    This command will extract the backup.tar file

  4. To List The File In An Archive:
    tar -tvf backup.tar

    The above command will display the files and directories that archived in backup.tar.


From → Unix

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: