Tarbomb Definition

A tarbomb, also sometimes written as tar bomb, is a tarball whose contents appear to explode into the current directory or some other existing directory containing a large number of items when untarred rather than into a new directory created by the tarball specifically for such contents.

A tarball is an archive that has been created with tar, which is perhaps the most frequently used program for creating and opening archive files on Linux and other Unix-like operating systems. An archive is a single file that contains any number of individual files plus information to allow them to be restored to their original form by one or more extraction programs. The current directory is the directory in which the user is currently working. Untarring is the extraction of all of the contents of a tarball so as to recreate the original, separate files, and often directories as well.

Fortunately, most tarballs are designed to create a new, dedicated directory for their contents when they are untarred. However, this is not always the case, and a tarball exploding into an existing directory can be a major annoyance, or even dangerous. That is, it can result in the overwriting of any files and directories that have the same names and which reside in the same directory. This could lead to the loss of important data or of files critical for the operation of programs.

An exploding tarball can create a particular mess if the directory is one, such as the user's home directory, which already contain a large number of files. For example, it can make it more difficult for the user to locate individual items in the directory. It can also be tedious to find and delete the files from the tarball that are scattered around the directory should the user decide that the contents of the tarball are not wanted.

It is common to want to delete the files created by tarballs. For example, many tarballs are programs, and often users find that they do not like a new program, discover that it does not operate as expected or decide that they want to install a newer version of the same program.

The easiest way to prevent unwanted tarball explosions is to get into the habit of first creating a new, protective directory and then moving the tarball into it before untarring. This can be easily accomplished in a GUI by using the right mouse button and then dragging the tarball icon. It can be accomplished at the command line (i.e., in text-only mode) by using the mkdir and mv commands. This protective directory can then be easily eliminated if the tarball has created its own directory during untarring by first moving the new directory (inclusive of its contents) out of it and then dragging it to the trash can or by using the mv and rmdir commands.

Although it is sometimes advised that the best way to avoid problems from exploding tarballs is to first use the -t option to list the contents before unpacking them, experience shows that this can be less reliable and more prone to user error than habitually creating a new directory.

Considerate developers of programs and other items that are supplied as tarballs create their tarballs so that they do not explode into users' current directories when users untar them without taking any precautions. This can be easily accomplished by first using the cd command to move outside of the directory containing the items to be tarred and then using the tar command to tar that directory inclusive of its contents rather than just tarring all of the contents.

Another convenience for users when creating a tarball that contains a program is to give the directory into which the program will be untarred the same name as the program but followed by a hyphen and then the version of the program. This makes it easy for users to locate the directory again in the future and it prevents overwriting of directories containing other versions of the same program. In addition, it facilitates using the cd command and command completion (i.e., the command followed by just the first few letters of the program name and then the TAB key) to easily navigate into the new directory for reading instructions, compiling the program, etc.

Created April 6, 2007.
Copyright © 2007 The Linux Information Project. All Rights Reserved.