options parameter
Basic operation options
-c: Create a new archive file. -x: Unzip the archive file. -t: Lists the contents of the archive. -r: Appends files to existing archives. -u: Appends only files that are newer than those already in the archive. -d: Find differences in archive files that are out of sync with the file system. -A: Append one .tar file to another .tar file.
File selection and exclusion
-f<file>: Specifies the name of the archive file (must be placed at the end of the list of options). -C<directory>: Switch to the specified directory for operation. --exclude=<pattern>: Exclude files that match the specified pattern. --exclude-from=<file>: Read the pattern to be excluded from the specified file. --exclude-caches: Exclude cache files from the directory. --exclude-backups: Exclude backup files ending in ~. --exclude-vcs: Exclude files generated by the version control system (e.g., .git, . svn, etc.).
Compression and decompression options
-z: Compress the archive file with gzip. -j: Compress the archive file with bzip2. -J: Compress the archive file with xz. --lzip: Compress archive files with lzip. --lzma: Compress archive files with lzma. --lzop: Compress archive files with lzop. --zstd: Compress archive files with zstd. -a: Automatically select the compression method (based on the extension of the archive file, such as .tar.gz, . tar.bz2, etc.). -I <command>: Compressing or decompressing using a specified compression program.
Output and interaction options
-v: Displays detailed operation procedures (verbose). --progress: Shows a progress bar (when used with -v). -w or --interactive: Ask the user for confirmation before each action. --checkpoint: Displays a checkpoint after processing each file. --checkpoint-action=<action>: Executes the specified action at the checkpoint, such as echo, dot, etc. --totals: Displays the total number of bytes processed after the operation ends. --verbose: Displays the processed information in detail. --quiet: Output as little information as possible.
File and permission-related options
-p: Preserve the original permissions of the file (when unzipped). --same-owner: Try to set the extracted file as the original owner (requires superuser privileges). --no-same-owner: No file owner is set. --same-permissions: Keep the original permissions of the file (same as -p). --no-same-permissions: Doesn't keep the original permissions, use the current user's umask to set permissions. -m: The modification time of the file is not restored when unzipping, but the current time is used.
Archiving management options
-k or --keep-old-files: Keep existing files when unzipping, not overwrite. --overwrite: Force an existing file to be overwritten when unzipping. --remove-files: Deletes the original file after successful archiving. --delete: Deletes the specified file from the archive (gnu tar only). --keep-newer-files: Keep newer files than in the archive when unzipped. --listed-incremental=<file>: Create or restore from an incremental backup.
File system and device options
-L <N>: Split archive files larger than N bytes (for tape drives). --tape-length=<number>: Specifies the tape length (for tape drives). --multi-volume: Create or restore multi-volume archive files. -M: Used with --multi-volume to handle multi-volume archive files. --use-compress-program=<prog>: Use the specified compressor.
Other practical options
--transform=<expression>: Renames files in the archive. --strip-components=<number>: strips a specified number of path components when unzipping. --ignore-failed-read: ignore the read error and proceed. --occurrence=<number>: Select the number of occurrence files in the archive. -S: Handles sparse files (only archives blocks that are actually used). --no-recursion: does not recursively enter the directory. -h or --dereference: Archive the file that the symbolic link points to, not the link itself.
Help and version information
--help: Displays help information. --version: Displays the version information of the tar.
|