Go to the first, previous, next, last section, table of contents.


Options Controlling the Overwriting of Existing Files

When extracting files, if tar discovers that the extracted file already exists, it normally replaces the file by removing it before extracting it, to prevent confusion in the presence of hard or symbolic links. However, if a directory cannot be removed because it is nonempty, tar neither removes it nor modifies its ownership, permissions, or time stamps.

To be more cautious and prevent existing files from being replaced, use the --keep-old-files (-k) option. It causes tar to refuse to replace or update a file that already exists, i.e., a file with the same name as an archive member prevents extraction of that archive member.

To overwrite existing files, use the --overwrite option. This causes tar to write extracted files into the file system without regard to the files already on the system; i.e., files with the same names as archive members are overwritten when the archive is extracted. It also causes tar to extract the ownership, permissions, and time stamps onto any preexisting files or directories. If the name of a corresponding file name is a symbolic link, the file pointed to by the symbolic link will be overwritten instead of the symbolic link itself (if this is possible). Moreover, special devices, empty directories and even symbolic links are automatically removed if they are in the way of extraction.

Be careful when using the --overwrite option, particularly when combined with the --absolute-names (-P) option, as this combination can change the contents, ownership or permissions of any file on your system. Also, many systems do not take kindly to overwriting files that are currently being executed.

@FIXME{these two P's have problems. i don't understand what they're trying to talk about well enough to fix them; i may have just made them worse (in particular the first of the two). waiting to talk with hag.}

The --unlink-first (-U) option causes tar to always attempt to remove a file unconditionally before attempting to extract it. This can make tar run a bit faster if you know in advance that the extracted files all need to be removed. Normally this option slows tar tar down slightly, so it is disabled by default.

If you specify the --recursive-unlink option, tar removes anything that keeps you from extracting a file as far as current permissions will allow it. This could include removal of the contents of a full directory hierarchy. For example, someone using this feature may be very surprised at the results when extracting a directory entry from the archive. This option can be dangerous; be very aware of what you are doing if you choose to use it.


Go to the first, previous, next, last section, table of contents.