Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use the Tar tool to archive files under Linux

Shulou Source: shulou.com Published: 2022-06-01 08:08:33 09月22日 Update

This article mainly explains "how to use Tar tools to archive files under Linux", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use Tar tools to archive files under Linux" bar!

Tar is derived from Tape archiver (tape archiver) and was originally used to archive and store files on magnetic tape. Tar is a GNU software that can compress a set of files (archives) or extract them and perform related operations on existing archives. It is useful for storing, backing up, and transferring files. When creating an archive file, Tar can keep the original file and directory structure unchanged. Files archived through Tar have the suffix '.tar'.

The basic usage is as follows:

A) create an archive (c /-- create)

The code is as follows:

Tar-create-verbose-file=archive.tar file1 file2 file3

Or

The code is as follows:

Tar cvf archive.tar file1 file2 file3

Create an archive

B) list the contents of the archived file (t /-- list)

The code is as follows:

Tar-list archive.tar

List the files contained in the archive

C) extraction and archiving (x /-- extract)

The code is as follows:

Tar xvf archive.tar

Tar xvf archive.tar-- wildcards'* .c'

-extract a file with the suffix * .c from the archive.

Extract Fil

Extract only the files you need

D) Update the archived file (u /-- update)

The code is as follows:

Tar uvf archive.tar newfile.c

If the archived newfile.c is newer than the previously archived newfile.c, add the updated newfile.c to the archive.

Update an archive

E) remove files from the archive (--delete)

The code is as follows:

Tar-- delete-f archive.tar file1.c

-remove files from the archive 'archive.tar'' file1.c'

Delete a file

For more specific usage, please refer to the tar home page.

Thank you for your reading, the above is the content of "how to use Tar tools to archive files under Linux". After the study of this article, I believe you have a deeper understanding of how to use Tar tools to archive documents under Linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Files code tools content learning updates suffixes storage home page usage backup that is ideas situations articles methods aspects more useful directories Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Microsoft Huawei MySQL Xiaomi