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 tar command in linux system

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

Share

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

How can the tar command be used in a linux system? I believe that many inexperienced people are at a loss about this, so this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

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

Copy the code

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