TAR command example

zhaozj2021-02-16  68

Example 1: Do all the subdirectory in the / home directory all the backup files, the backup file name is usr.tar.

$ TAR CVF USR.TAR / HOME

Example 2: Do all the subdirectories in the / home directory all the backup files, and compress, the backup file is named usr.tar.gz.

$ TAR CZVF USR.TAR.GZ / HOME

Example 3: Restore the USR.TAR.GZ backup file and decompressed.

$ tar xzvf usr.tar.gz

Example 4: View the contents of the usr.tar backup file and display it on the display in a split screen.

$ tar tvf usr.tar | more

To back up files to a specific device, just use the device name as the backup file name.

Example 5: Create a backup file in the / dev / fd0 device's floppy disk and copy all the files in the / home directory to the backup file.

$ TAR CF / DEV / FD0 / HOME

To recover files in the device disk, you can use the XF options:

$ TAR XF / DEV / FD0

If the user backed up file size exceeds the storage space available, such as a floppy disk, you can create a multi-volume TAR backup file. M Options indicate that TAR command prompts you to use a new storage device, when archiving a floppy drive with M option, the TAR command will remind you to add a new floppy disk when a floppy is full. This way you can save the TAR file into several disks.

$ TAR CMF / DEV / FD0 / HOME

To restore the files in a few discs, just put the first place in the floppy drive, then enter the tar command with the X and M options. When necessary, you will be reminded to put another floppy disk.

$ TAR XMF / DEV / FD0

转载请注明原文地址:https://www.9cbs.com/read-14479.html

New Post(0)