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

The concrete use method of tar Command under Linux

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains the "specific use of tar commands under Linux", the content of the explanation 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 "the specific use of tar commands under Linux" bar!

Tar command

[root@linux ~] # tar [- cxtzjvfpPN] files and directories.

Parameters:

-c: create a parameter instruction for a compressed file (meaning create)

-x: unlock a parameter instruction for a compressed file!

-t: check the files in tarfile!

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.

-z: does it also have the properties of gzip? That is, is it necessary to use gzip compression?

-j: does it also have the properties of bzip2? That is, is it necessary to use bzip2 compression?

-v: display files in the process of compression! This is commonly used, but is not recommended in the background execution process!

-f: use the file name, please note that you should receive the file name immediately after f! No more parameters!

For example, using "tar-zcvfP tfile sfile" is the wrong way to write it.

"tar-zcvPf tfile sfile" is right!

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

-P: absolute path can be used to compress!

-N: it is newer than the following date (yyyy/mm/dd) before it is packaged into the new file!

-- 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

[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