Tar command
1. The tar command is a reliable way to back up files in a unix/linux system and works in almost any environment, with permissions for all users.
2. Format tar [main option + Secondary options] File or directory Eg:tar zxvf libiconv-1.13.tar.gz./libiconv tar cxvf libiconv-1.13.tar.gz./*.php
3. Main parameters
When using this command, the main option is required, and it tells Tar what to do, auxiliary options are auxiliary and can be used.
3.1 Main options:
-C Create a new profile. Select this option if the user wants to back up a directory or some files.
-R appends the file to be archived to the end of the archive file. For example, the user is ready to backup files, and found that there is a directory or some files forgot to back up, you can use this option to append the forgotten directories or files to the backup file.
-T lists the contents of the archive to see which files have been backed up.
-U update file. That is, replace the original backup file with the new file, if the file you want to update is not found in the backup file, append it to the end of the backup file.
-X releases the file from the archive file.
3.2 Auxiliary Options:
-B This option is set for the tape drive, followed by a number to indicate the size of the chunk, with a system preset value of 20x512 bytes.
-f Specifies the file file name or device name, which is usually required.
-K saves the file that already exists. For example, restoring a file, encountering the same file during the restore process, does not overwrite it.
-M when restoring files, set the modification time of all files to now.
-M creates multiple volumes of files for storage on several disks.
-V Details the file information processed by tar. Without this option, TAR does not report file information.
-W each step requires confirmation.
-Z Compress/unzip the file with gzip, plus this option to compress the archive file, but you must also use this option to decompress when restoring.
For example:
1. Package and compress all. txt files in the current directory to file this.tar.gz, we can use
Tar czvf this.tar.gz./*.txt
2. Extract the files from the this.tar.gz in the current directory to the current directory we can use
Tar xzvf this.tar.gz./
Linux Tar Command parameters