Such as:
Unzip the file in the current directory:
The code is as follows |
Copy Code |
Tar zxvf my_name.tgz or tar zxvf MY_NAME.tar.gz |
Example: View the contents of the Usr.tar backup file and display it as a split screen on the monitor.
The code is as follows |
Copy Code |
$ tar TVF Usr.tar | More |
Example: The/home directory includes its subdirectories to do all the backup files, the backup file name is Usr.tar.
The code is as follows |
Copy Code |
$ tar cvf usr.tar/home |
Example: The/home directory includes its subdirectories to do all backup files, and compression, backup file name usr.tar.gz.
The code is as follows |
Copy Code |
$ tar czvf usr.tar.gz/home |
Some of the other uses of tar
There are many options for the tar command (which can be viewed with man tar), but there are a few options that are commonly used, below
To illustrate:
The code is as follows |
Copy Code |
# TAR-CF All.tar *.jpg |
This command is to make all. jpg files into a package named All.tar. -C is to indicate the creation of a new package
,-f Specifies the file name of the package.
The code is as follows |
Copy Code |
# TAR-RF All.tar *.gif
|
This command adds all the. gif files to the All.tar package. -R is the file that adds the
Mean.
The code is as follows |
Copy Code |
# Tar-uf All.tar logo.gif |
This command updates the logo.gif file in the original tar package All.tar, and-U is the meaning of the update file.
The code is as follows |
Copy Code |
# TAR-TF All.tar |
This command lists all the files in the All.tar package----------T is the list of files
The code is as follows |
Copy Code |
# TAR-XF All.tar |
This command is to solve all the files in the All.tar package------X is the meaning of the undo
# Note that the file name after the parameter F is taken by itself, and we are accustomed to using. Tar as a recognition.
# If you add the z parameter, you can use. tar.gz or. tgz to represent the gzip-compressed tar file ~
# If you add the J parameter, then the. tar.bz2 as the file name. ~