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

Detailed explanation of the use of Linux Packaging and Compression tools

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

Share

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

Compression tools: gzip,bzip2 compression capabilities are gradually enhanced

Packaging or Compression tool: tar

Packaging and compression tools: zip is more capable of compression than gzip and bzip2

The difference between gzip and bzip2 compression tools:

Gzip and bzip2 can only compress files, while zip can compress files and directories

Bzip2 and gzip are used in a similar way, and the source file disappears after compression, and the compressed file disappears after decompression. Bzip2 has one more feature, bzcat, to view the contents of the compressed file.

Bzip2 [filename] compress a file

Bzip2-d [compressed file name] decompress a compressed file

Gzip [filename] compress a file

Gzip-d [compressed file name] decompress a compressed file

Bzcat [compressed File name] to view the contents of a compressed file

Bzip2 usage:

$bzip2 file

By default, the bzip2 command attempts to compress the original file and replace it with the compressed file (the same file name plus the .bz2 extension).

Decompress:

$bunzip2 file.bz2

If file is a text file, you can view it with bzcat:

$bzcat file.bz2

Gzip is used in the same way as bzip2.

Packaging or Compression tool tar:

Packaging function of tar

Tar-cvf [package to be generated] [directory name] [file name] package directories and files

Tar-xvf [package name] unpack

Compression function of tar

Tar-zcvf [name of the package to be generated .tar.gz] [file name] [directory name]

-package files and directories and compress them (compressed as gzip)

Tar-jcvf [name of the package to be generated .tar.bz2] [file name] [directory name]

-package files and directories and compress them (compressed as bzip2)

Tar-zcvf [compressed package name .tar.gz]-- exclude [exclude packaged file or directory name] [file name] [directory name]

-exclude packaging a file or directory and compress it in gzip

Tar-tf [package name] View all files in the package

Package and compress tool zip:

Zip is used to package and compress files or directories

Zip-r [name of package to be generated] [file] [directory] package files and directories and compress

Unzip is used to extract the compressed package.

Unzip [compressed package name] decompress the compressed package

Tar and zip: the source file is retained after compression, and the compressed file is also retained after decompression.

There are many options for the tar command (you can see them with man tar), but there are only a few commonly used options. Here's an example:

# tar-cf all.tar * .jpg

This command is to type all .jpg files into a package called all.tar. -c means to generate a new package, and-f specifies the file name of the package.

# tar-rf all.tar * .gif

This command adds all .gif files to the all.tar package. -r means to add files.

# tar-uf all.tar logo.gif

This command updates the logo.gif file in the original tar package all.tar, and-u means to update the file.

# tar-tf all.tar

This command lists all the files in the all.tar package.-t means to list files.

# tar-xf all.tar

This command unlocks all the files in the all.tar package, and-x means unpacking

These are the most basic uses of tar.

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