Creation format: Tar czvf ← file name .tar.gz] [file name]
For example, tar czvf test.tar.gz test (the current command occurs in the directory where the file to be packaged is located)
Decompression format: Tar zxvf ghost file name .tar.gz]
For example, tar zxvf test.tar.gz (you need to upload the compressed package to the current release directory in advance)
Detailed usage of FreeBSD tar
Tar command
Tar files are collections of several files and/or directories in one file. This is an excellent path for creating backups and archives.
Tar uses the following options:
-C-create a new archive.
-F-when used with the-C option, the created tar file uses the file name specified by this option; when used with the-x Option
When used together, the archive specified by this option is removed.
-T-displays the list of files included in the TAR file.
-V-displays the file archiving progress.
-X-Extract files from the archive.
-Z-use gzip to compress the tar file.
-J-use Bzip2 to compress the tar file.
To create a tar file, type:
Tar-CVF filename.tar directory/File
You can use the tar command to process multiple files and directories at the same time by listing them one by one and using spaces:
Tar-CVF filename.tar/home/mine/work/home/mine/School
The above command puts all the files in the work and school subdirectories under the/home/mine Directory into the current
A new file named filename.tar in the directory.
To list the contents of the TAR file, type:
Tar-tvf filename.tar
To extract the content of the TAR file, Type
Tar-xvf filename.tar
This command will not delete the tar file, but it will unarchive the content
Copy to the current working directory and keep any
Directory structure. For example, if the tar file contains a file named
Bar.txt file, which is included in the foo/directory,
Extracting archive files will cause you to create
Foo/directory, which contains the bar.txt File
By default, tar does not compress files.
To create a file that uses tar and bzip for archiving and compression, use the-J option:
Tar-cjvf filename. TBZ File
The preceding command creates an archive file and compresses it into a filename. TBZ file. If you use the bunzip2 command to decompress the filename. TBZ file, the filename. TBZ file will be deleted, followed by the filename.tar file.
You can also use a command to expand and release the archive bzip tar file:
Tar-xjvf filename. TBZ
To create a file archived and compressed with tar and gzip, use the-Z option:
Tar-czvf filename. tgz File
This command creates an archive file filename.tar and compresses it into a filename. tgz file (the file filename.tar is not retained ).
If you use the gunzip command to decompress the filename. tgz file, the filename. tgz file will be deleted and
Replace with filename.tar.
You can use a single command to expand the gzip tar file:
Tar-xzvf filename. tgz
1. Tar
1.zip a group of files with the suffix tar.gz.
# Tar CVF backup.tar/etc
# Gzip-Q backup.tar
Or
# Tar cvfz backup.tar.gz/etc/
Tar zxvf xxxx.tar.gz
Tar jxvf XXXX tar.bz2
2.release a file suffixed with tar.gz.
# Gunzip backup.tar.gz
# Tar xvf backup.tar
Or
# Tar xvfz backup.tar.gz
3. Compress With one command
# Tar CVF-/etc/| gzip-QC> backup.tar.gz
4. Run a command to release the instance.
# Gunzip-C backup.tar.gz | tar xvf-
5. How to unbind the tar. Z file?
# Tar xvfz backup.tar. Z
Or
# Uncompress backup.tar. Z
# Tar xvf backup.tar
6. How to unbind the. tgz file?
# Gunzip backup. tgz
7.where are the packages compressed and uncompressed?
# Bzip2/etc/smb. conf
This will convert the compressed file smb.confinto smb.conf.bz2
# bunzip2/etc/smb.conf.bz2
in the current directory, smb.conf.bz2 will be restored to SMB. conf
Note :. bz2 compression format is not very common, you can use man Bzip2