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

Share

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

Today Xiaobian to share with you how to use the tar command Linux related knowledge points, detailed content, clear logic, I believe most people are still too familiar with this knowledge, so share this article for your reference, I hope you read this article after some gains, let's take a look at it.

The most commonly used packaging program under linux is tar. The package printed by tar program is often called tar package. The commands of tar package file usually end with.tar. Once the tarball is generated, it can be compressed using other programs.

syntax tar (option) (parameter)

Option-A or catenate: Add files to existing backup files;

-B: Set block size;

-c or create: Create a new backup file;

-C: This option is used for decompression. To decompress in a specific directory, use this option.

-d: differences in documentation;

-x or extract or get: Restore files from backup files;

-t or list: lists the contents of the backup file;

-z or gzip or ungzip: Process backup files via the gzip command;

-Z or compress or uncompress: Process backup files with the compress command;

-f or file=: Specifies the backup file;

-v or verbose: Display instruction execution process;

-r: Add files to already compressed files;

-u: Add changed and existing files to existing zip files;

-j: Support bzip2 decompression files;

-v: Display operation process;

-l: file system boundary setting;

-k: Keep the original file not overwritten;

-m: Keep files not overwritten;

-w: Confirm the correctness of the compressed file;

-p or same-permissions: restore files with original file permissions;

-P or absolute-names: use absolute names for file names without removing the "/" sign before the file name;

-N or newer=: Save only files newer than the specified date to the backup file;

exclude=: Excludes files that conform to the template style.

examples

Packaging files into tarballs:

tar -cvf log.tar log2012.log

Package only, no compression!

tar -zcvf log.tar.gz log2012.log

After packaging, compress it with gzip

tar -jcvf log.tar.bz2 log2012.log

After packaging, compress it with bzip2

Within folders, files newer than a certain date are backed up:

tar -N "2018/3/1" -zcvf log.tar.gz test

The simplest way to use tar is to remember the following three ways:

tar -jcv -f filename.tar.bz2

File or directory name query to compress:

tar -jtv -f filename.tar.bz2

Decompression:

tar -jxv -f filename.tar.bz2 -C

Contents to be decompressed

That's all for "How to use tar in Linux". Thanks for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to the industry information channel.

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

Development

Wechat

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

12
Report