Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Next: , Up: operations

4.1 Basic GNU tar Operations

The basic tar operations, --create (-c), --list (-t) and --extract (--get, -x), are currently presented and described in the tutorial chapter of this manual. This section provides some complementary notes for these operations.

Creating an empty archive would have some kind of elegance. One can initialize an empty archive and later use --append (-r) for adding all members. Some applications would not welcome making an exception in the way of adding the first archive member. On the other hand, many people reported that it is dangerously too easy for tar to destroy a magnetic tape with an empty archive1. The two most common errors are:
  1. Mistakingly using create instead of extract, when the intent was to extract the full contents of an archive. This error is likely: keys c and x are right next to each other on the QWERTY keyboard. Instead of being unpacked, the archive then gets wholly destroyed. When users speak about exploding an archive, they usually mean something else :-).
  2. Forgetting the argument to file, when the intent was to create an archive with a single file in it. This error is likely because a tired user can easily add the f key to the cluster of option letters, by the mere force of habit, without realizing the full consequence of doing so. The usual consequence is that the single file, which was meant to be saved, is rather destroyed.

So, recognizing the likelihood and the catastrophical nature of these errors, GNU tar now takes some distance from elegance, and cowardly refuses to create an archive when --create option is given, there are no arguments besides options, and --files-from (-T) option is not used. To get around the cautiousness of GNU tar and nevertheless create an archive with nothing in it, one may still use, as the value for the --files-from option, a file with no names in it, as shown in the following commands:

          tar --create --file=empty-archive.tar --files-from=/dev/null
          tar cfT empty-archive.tar /dev/null

A socket is stored, within a GNU tar archive, as a pipe.
--list (-t)
GNU tar now shows dates as ‘1996-08-30’, while it used to show them as ‘Aug 30 1996’. Preferably, people should get used to ISO 8601 dates. Local American dates should be made available again with full date localization support, once ready. In the meantime, programs not being localizable for dates should prefer international dates, that's really the way to go.

Look up if you are curious, it contains a detailed explanation of the ISO 8601 standard.


[1] This is well described in Unix-haters Handbook, by Simson Garfinkel, Daniel Weise & Steven Strassmann, IDG Books, ISBN 1-56884-203-1.

  Published under the terms of the GNU General Public License Design by Interspire