How to easily update a tar file from Linux file manager

Instead of recreating your tarball when you need to add files, why not just add those files? Jack Wallen shows you how from the command line and a graphical file manager in Linux.

If you’re a Linux admin, chances are you use tar to create backups of data or just create files from directories so you can easily store them or share them with others. But how many times have you created a tar file, only to turn around and add a new file to the source directory? What do you do then?

SEE: 40+ open source and Linux terms you need to know (TechRepublic Premium)

You recreated the tar file the same way you did originally. It’s a bit complicated, especially if you work in an office environment. Why bother rerunning the same old process to create a new tar file, when there’s a much easier way to do things?

Before I show you this method, know that you can also achieve this through the command line. Suppose you have TEST.tar and you want to add mytest.txt file to the tar. To do this, you would issue the command:

tar -rf TEST.tar mytest.txt

If you then issue the command:

tar -tf TEST.tar

you will see that mytest.txt is in the archive.

Now, how can we do this with a GUI? It’s very simple. You should know that this method does not only work with .tar files.

Instead, these files should be compressed and end in .gz, .xz, .zip, or .7z. So, if you created your archive with a command like:

tar -cf TEST.tar.xz TEST

it should be fine.

Or, if you created the archive by right-clicking a directory in the file manager and selecting Compress, that will work.

To add the file to the archive, simply click on the mytest.txt file and drag it into the TEST.tar.xz archive. Once you’ve done that, click to open the archive and you should see the mytext.txt file is there.

SEE: Linux Turns 30: Celebrating the Open Source Operating System (Free PDF) (TechRepublic)

Using this method allows you to add files to compressed or uncompressed tar archives, while the command line option only allows you to add to an uncompressed archive. This simple task will save you time and, for once, give you options the command line doesn’t.

Subscribe to TechRepublic How to make technology work on YouTube for all the latest tech tips for professionals from Jack Wallen.

Image: Dilok Klaisataporn/Shutterstock

Comments are closed.