Tar: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 24: Line 24:


Note that the name of the archive file to be created must ''immediately'' follow -f, without any interceding parameters.
Note that the name of the archive file to be created must ''immediately'' follow -f, without any interceding parameters.
To also gzip:
tar cfv - ./mydir | gzip > mydir.tgz


=Restoration=
=Restoration=

Revision as of 21:23, 3 September 2019

Internal

Options

Archival

When tar is executed as root, the file permissions and owner are preserved.

-p

Preserve permissions, default when the root executes the command.

-s

Preserve order (same order). Sort names to extract to match archive.

Archive

Archive maintaining the user IDs and file permissions:

tar -cvspf .../archive.tar *

Note that the name of the archive file to be created must immediately follow -f, without any interceding parameters.

To also gzip:

tar cfv - ./mydir | gzip > mydir.tgz

Restoration

Restore preserving the user ID and file permissions (if done as root, the behavior is implicit):

tar -xvspf .../archive.tar