If you’re a Linux admin, there’s a good chance you make use of tar to create backups of data or simply make files from directories so you can easily store 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 then do?
SEE: 40+ open source and Linux terms you need to know (TechRepublic Premium)
You re-created the tar file in the same way you originally did. That’s kind of a hassle, especially if you happen to be working within a desktop environment. Why bother re-running the same old process for creating a new tar file, when there’s a much easier way of doing things?
Before I show you this method, know that you can also achieve it by way of the command line. Let’s say you have TEST.tar and you want to add the file mytest.txt to the tar. To do that, you would issue the command:
tar -rf TEST.tar mytest.txt
If you then issue the command:
tar -tf TEST.tar
you’ll see that mytest.txt is found within the archive.
Now, how can we do this with a GUI? It’s very simple. You should know this method doesn’t work with just .tar files.
Instead, those files need to be compressed and end with either .gz, .xz, .zip, or .7z. So, if you’ve created your archive with a command like:
tar -cf TEST.tar.xz TEST
you should be OK.
Or, if you’ve created the archive by right-clicking a directory in the file manager and selecting Compress, this will work.
To add the file to the archive, all you have to do is click 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 append files to either compressed or uncompressed tar archives, whereas the command line option only allows you to append to a non-compressed archive. This simple task will save you time and, for once, give you options the command line doesn’t.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.