• tar命令参数笔记


        This option will notify 'tar' thar it should use numeric user and group IDs when creating a 'tar' file, rather than names.
        This option allows (ANSI) archives to be written without user/group name information or such information to be ignored when extracting. It effectively disables the generation and/or use of user/group name information. This option forces extraction using the numeric ids from the archive, ignoring the names.
        This if useful in certain circumstances, when restoring a backup from an emergency floppy with different passwd/group files for example. It is otherwise impossible to extract files with the right ownerships if the password file in use during the extraction does not match the one belonging to the file system(s) being extracted. This occurs, for example, if you are restoring your files after a major crash and had booted from an emergency floppy with no password file or put your disk into another machine to do the restore.
        When 'tar' is extracting an archive, it normally subtracts the users' umask from the permissions specified in the archive and uses that number as the permissions to create the destination file. Specifying this option instructs 'tar' that it should use the permission directly from the archive.
        When extracting an archive, 'tar' will attempt to preserve the owner specified in the 'tar' archive with this option present. This is the default behavior for the superuser; this option has an effect only for ordinary users.
        Do not attempt to restore ownership when extracting. This is the default behavior or ordinary users, so this option has an effect only for the superuser.
        Displays the default options used by 'tar' and exits successfully. This option is intended for use in shell scripts. Notice, that this option outputs only one line.
        Sets the data modification time of extracted files to the extraction time rather than the data modification time stored in the archive.
        Specifies that 'tar' should be more verbose about the operations it is performing. This option can be specified multiple times for some operations to increase the amount of information displayed.
        Use 'xz' for compressing or decompressing the archives.
        When adding files to an archive, 'tar' will use PERMISSIONS for the archive members, rather than the permissions from the files. PERMISSIONS can be specified either as an octal number or as symbolic permissions, like with 'chmod' File permissions. Using latter syntax allows for more flexibility. For example, the value 'a+rw' adds read and write permissions for everybody, while retaining executable bits on directories or on any other file already marked as executable.
        Specifies that 'tar' should use USER as the owner of members when creating archives, instead of the user associated with the source file.
        If USER contains a colon, it is taken to be of the form NAME:ID where a nonempty NAME specifies the user name and a nonempty ID specifies the decimal numeric user ID. If USER does not contain a colon, it is taken to be a user number if it is one or more decimal digits; otherwise it is taken to be a user name. If a name is given but no number, the number if interred from the current host's user database if possible, and the file's user number is used otherwise.
        If a number is given but no name, the name is inferred from the number if possible, and an empty name if used otherwise. If both name and nuber are given, the user database is not consulted, and the name and number need not be valid on the corrent host.
        There is no value indicating a missing number, and '0' usually means 'root'. Some people like to force '0' as the value to offer in their distributions for the owner of files, because the 'root' user is anonymous anyway, so that might as well be the owner of anonymous archives.
        Files added to the 'tar' archive will have a group ID of GROUP, rather than the group from the source file. As with '--owner', the argument GROUP can be an existing group symbolic name, or a decimal numeric group ID,or NAME:ID.
        Do not exit with nonzero on unreadable files or directories.
        Do not replace existing files from archive. When such a file is encountered, 'tar' issues an error message. Upon end of extraction, 'tar' exits with code 2.
        Do not replace existing file from archive, but do not treat that as error. Such files are silently skipped and do not affect 'tar' exit status.
        Delays restoring of the modification times and permissions of extracted directories until the end of extraction. This way, correct meta-information is restored even if the archive has unusual member ordering.
        Cancel the effect of the previous 'delay-directory-restore'. Use this option if you have used '--delay-directory-restore' in 'TAR_OPTIONS' varvable and wish to temporarily disable it.
        Writes files to the standard output. Use only in conjunction with '--extract' ('--get', '-x'). When this option is used, instead of creating the files specified, 'tar' writes the contents of the files extracted to its standard output. This may be useful if you are only extracting the files in order to send them through a pipe. This option is meaningless with '--list' ('-t').
        Remove files after adding them to the archive.
        Before archiving a directory, see if it contain any of the following files: '.cvsignore', '.gitignore', '.bzignore', or '.hgignore'. If so, read ignore patterns from these files.
        Exclude files and directories used by following version control systems: 'CVS', 'RCS', 'SCCS', 'SVN', 'Arch', 'Bazaar', 'Mercurial', and 'Darcs'.
        Preserves full file names (including superior directory names) when archiving and extracting files.
        Do not strip leading slashes from file names, and permit file names containing a '..' file name component.
        When 'tar' extracts archive members from an archive, it strips any leading slashes ('/') from the member name. This causes absolute member names in the archive to be treated as relative file names. This allows you to have such members extracted wherever you want, instead of being restricted to extracting the member in the exact directory named in the archive.
    Creating a compressed archive is simple: you just specify a "compression option" along with the usual archive creation commands.
    The compression option is '-z' ('--gzip') to create a 'gzip' compressed archive, '-j' ('--bzip2') to create a 'bzip2' compressed archive, '--lzip' to create an lzip compressed archive, '-J' (--xz) to create an XZ archive, '--lzma' to create an LZMA compressed archive, '--lzop' to create an LSOP archive, and '-Z' ('--compress') to use 'compress' program.
    Compressed archives are easily corrupted, because compressed files have little redundancy. The adaptive nature of the compression scheme means that the compression tables are implicitly spread all over the archive. If you lose a few blocks, the dynamic construction of the compression table becomes unsynchronized, and there is little chance that you could recover later in the archive.
        Select a compression program to use by the archive file name suffix.
        Use external compression program COMMAND. Use this option if you are not happy with the compression program associated with the suffix at compile time or if you have a compression program that GNU 'tar' does not support. The COMMAND argument is a valid command invocation, as you would type it at the command line prompt, with any additional options as needed. Enclose it in quotes if it contains white space.
        The COMMAND should follow two conventions:
        First, when invoked without additional options, it should read data from standard input, compress it and output it on standard output.
        Secondly, if invoked with the additional '-d' option, if should do exactly the opposite.
        The latter requirement means that you must not use the '-d' option as a part of the COMMAND itself.
    When '--dereference' ('-h') is used with '--create' ('-c'), 'tar' archives the files synbolic links point to, instead of the links themselves.
        Check the number of links dumped for each processed file. If this number does not match the total number of hard links for the file, print a warning message.
        Dereference hard links and store the files they refer to.
  • 相关阅读:
    vim 操作
  • 原文地址:https://www.cnblogs.com/vanwoos/p/5451305.html
走看看 - 开发者的网上家园