Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

An example of using tar command under linux

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "examples of the use of tar commands under linux". In daily operation, I believe many people have doubts about the examples of the use of tar commands under linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "examples of the use of tar commands under linux". Next, please follow the editor to study!

Tar syntax:

Syntax: tar [primary option + secondary option] file or directory

When using this command, the primary option is required, which tells tar what to do, and the secondary option is secondary and optional.

Main options:

C create a new archive file. Select this option if the user wants to back up a directory or some files. It's the equivalent of packing.

X release the file from the archive file. It's the equivalent of unpacking.

T list the contents of the archive file to see which files have been backed up.

Pay special attention to that only one c/x/t can exist in the issue of parameters! Cannot exist at the same time! Because it is impossible to compress and decompress at the same time.

Secondary options:

-z: does it also have the properties of gzip? That is, does it need to be compressed or decompressed with gzip? The general format is xx.tar.gz or xx. Tgz

-j: does it also have the properties of bzip2? That is, does it need to be compressed or decompressed with bzip2? The general format is xx.tar.bz2

-v: display files in the process of compression! This is commonly used.

-f: use the file name, please note that you should receive the file name immediately after f! Don't add any other parameters!

-p: use the original properties of the original file (the attributes will not change based on the user)

-- exclude FILE: do not package FILE in the process of compression!

Example:

Example 1: package all the files in the entire / etc directory into / tmp/etc.tar

The code is as follows:

[root@linux ~] # tar-cvf / tmp/etc.tar / etc

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report