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

How to use the tar command of Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article will explain in detail how to use the tar command about Linux. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

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. It should be written as "tar-zcvPf tfile sfile".

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