How to add files/folders to an existing TAR archive?

Is it possible? Yes we can add additional files/folders to an already existing TAR archive. The ‘TAR’ saves many files together into a single tape or disk archive, and can restore individual files from the archive. It is very useful in such conditions like when we want to send a lot of files via email, transfer files from one machine to another etc. We already discussed the the basic switches of TAR command in one previous session. Click here for more details TAR command usages. Here I’m explaining one of the useful TAR switch. It will help you to add more files/folders into an existing TAR archive.

The “-r or –append” option with TAR command will do this.


tar -rf archive.tar file3.txt

This TAR archive contains two files file1.txt and file2.txt

See the example:

## Creating three files;

[[email protected] ~]# touch file1.txt
[[email protected] ~]# touch file2.txt
[[email protected] ~]# touch file3.txt

## Creating a TAR archive;

[[email protected] ~]# tar -cvf archive.tar file1.txt file2.txt

## Listing files in archive using -t

[[email protected] ~]# tar -tf archive.tar

## Adding a file to TAR archive

[[email protected] ~]# tar -rf archive.tar file3.txt

## Check now!

[[email protected] ~]# tar -tf archive.tar

That’s it dude!!

Read also

1, 20+ Rsync command switches
2, Tar command with example
3, LSOF command details

Arunlal Ashok

Linux Server Administrator. I'm dealing with Linux servers since 2012. I started this blog to share and discuss my ideas with the world. Check My Profile!! in uPwork (oDesk) and let me know if you need any assistance. Thanks!!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *