Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use tar Compression and decompression Command in Linux system

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Tar, is a command of Linux system, very easy to use! If you don't know much about the tar command, you can take a look at the detailed explanation of the tar compression and decompression command compiled by Xiaobian.

01root@ubuntu:~# tar-help

02 usage: tar [option.] [FILE]...

03GNU 'tar' saves many files together into a single tape or disk archive, and can

04restore individual files from the archive.

05Examples:

06tar-cf archive.tar foo bar # Create archive.tar from files foo and bar.

07tar-tvf archive.tar # List all files in archive.tar verbosely.

08tar-xf archive.tar # Extract all files from archive.tar.

09 main mode of operation:

10Mura,-- catenate,-- concatenate append tar files to the archive

11murc,-- create creates a new archive

12Murd,-- diff,-- compare find out the difference between archiving and file system

13--delete from archive (non-tape!) Delete in

14Murr,-- append appends the file to the end of the archive

15murt,-- list lists the contents of the archive

16--test-label Test Archive Volume label and exit

17muru,-- update appends only files that are newer than the copy in the archive

18Murx,-- extract,-- get unscrambles files from the archive

19 Action modifier:

20--check-device checks device number when creating incremental archive (default)

21Mug,-- listed-incremental=FILE handles incremental backups in the new GNU format

22m G,-- incremental handles incremental backups in the old GNU format

23--ignore-failed-read

24 do not exit with a non-zero value when you encounter an unreadable file

The output level of the incremental list archive created by 25--level=NUMBER

26murn,-- seek archives can be retrieved

27--no-check-device do not check the device number when creating an incremental archive

28--no-seek archive is not retrievable

29--occurrence [= NUMBER] processes only the NUMBER of each file in the archive

30 events; only if with the following subcommand-- delete

31--diff,-extract or-list

This option is valid only when one of 32 is used in combination. And no matter whether the list of files is given on the command line or through

Specified by 33murt option; the NUMBER value defaults to 1

34--sparse-version=MAJOR [.MINOR]

35 the discrete format version used for the setting (implied

36--sparse)

37mi S,-- sparse efficient processing of discrete files

38 rewrite control:

39MYK,-- keep-old-files don't replace existing files when extracting

40treat them as errors

41--keep-directory-symlink preserve existing symlinks to directories when

42extracting

43--keep-newer-files

44 do not replace existing files that are newer than the copy in the archive

45--no-overwrite-dir retains metadata from existing directories

46--one-top-level [= DIR] create a subdirectory to avoid having loose files

47extracted

Rewrite existing files when 48--overwrite is decompressed

Overwrite metadata for existing directories when 49--overwrite-dir is unzipped (default)

Clear the directory hierarchy before 50--recursive-unlink decompresses the directory

51--remove-files deletes files after adding them to the archive

52--skip-old-files don't replace existing files when extracting

53silently skip over them

54Muth U,-- unlink-first deletes the files to be rewritten before decompressing them

55m W,-- verify attempts to verify the archive after writing

56 Select the output stream:

57--ignore-command-error ignores the exit code of the child process

58--no-ignore-command-error

59 consider the non-zero exit code of the child process to have an error

60muro,-- to-stdout decompresses the file to standard output

61--to-command=COMMAND

62 transfer the extracted files to another program through a pipeline

63 manipulate file attributes:

64--atime-preserve [= METHOD]

65 keep the access time on the output file, or by reading the default

Restore the time after you METHOD='system' the time, or don't set the time for the first time.

67--clamp-mtime only set time when the file is more recent than

68what was given with-mtime

69--delay-directory-restore

70 do not set the modification time and permissions of the extracted directory until the decompression is finished.

71Mutual group = name compels NAME

72 as the group owner of the added file

73--mode=CHANGES forces the added file (symbol) to be changed to permission

74CHANGES

75--mtime=DATE-OR-FILE sets the settings for added files from DATE-OR-FILE

76mtime

77murm,-- touch do not extract the modification time of the file

78--no-delay-directory-restore

79 cancel-the effect of the delay-directory-restore option

80--no-same-owner

81 unzip the file for you (this is the default for ordinary users)

82--no-same-permissions

83 use the user's mask bits when decompressing permissions from the archive (default is normal user service)

84--numeric-owner always represents the name of a user / group with a number

85Muthowner = name forces NAME

86 as the owner of the added file

87cp,-- preserve-permissions,-- same-permissions

88 decompress the file permission information (the default is for superusers only)

89--preserve is the same as-p and-s

90--same-owner

91 keep the owner relationship consistent when trying to decompress (superuser defaults to this item)

92 preserve-order,-- same-order

93member arguments are listed in the same order as

94the files in the archive

95--sort=ORDER directory sorting order: none (default), name or

96inode

97Handling of extended file attributes:

98--acls Enable the POSIX ACLs support

99--no-acls Disable the POSIX ACLs support

100--no-selinux Disable the SELinux context support

101--no-xattrs Disable extended attributes support

102--selinux Enable the SELinux context support

103--xattrs Enable extended attributes support

104--xattrs-exclude=MASK specify the exclude pattern for xattr keys

105--xattrs-include=MASK specify the include pattern for xattr keys

106 device selection and switching:

107murf,-- file=ARCHIVE uses archived files or ARCHIVE devices

108--force-local

109 even if there is a copy of the archive file, it is still considered a local archive.

110murf,-- info-script= name,-- new-volume-script= name

111 run the script at the end of each tape (implied-M)

112Mel,-- tape-length=NUMBER changes tapes after writing NUMBER × 1024 bytes

113m,-- multi-volume creates / lists / decompresses multi-volume archive files

114--rmt-command=COMMAND uses the specified rmt COMMAND instead of rmt

115--rsh-command=COMMAND uses remote COMMAND instead of rsh

116--volno-file=FILE uses / updates the number of volumes in FILE

117 device partitioning:

118Murb,-- blocking-factor=BLOCKS each record BLOCKS x 512 bytes

119 read-full-records B,-- re-chunking when reading (valid for 4.2BSD pipes only)

120muri,-- ignore-zeros ignores zero byte blocks in the archive (that is, the end of the file)

121--record-size=NUMBER the number of bytes per record NUMBER, multiplied by 512

122 Select the archive format:

123Murh,-- format=FORMAT creates an archive in the specified format

124FORMAT is one of the following formats:

125gnu GNU tar 1.13.x format

126oldgnu GNU format as per tar

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report