search
Homephp教程PHP开发Detailed explanation of tar compression and decompression commands under Linux

tar

-c: Create a compressed archive
-x: Decompress
-t: View the content
-r: Append files to the end of the compressed archive
-u: Update the files in the original compressed package

These five are independent One of the commands is used for compression and decompression. It can be used in conjunction with other commands but only one of them can be used. The following parameters are optional when compressing or decompressing archives as needed.

-z: With gzip attribute
-j: With bz2 attribute
-Z: With compress attribute
-v: Display all processes
-O: Unpack the file to standard output

The following parameter -f It is necessary

-f: Use the file name. Remember, this parameter is the last parameter, and can only be followed by the file name.

# tar -cf all.tar *.jpg
This command is to package all .jpg files into a package named all.tar. -c means generating a new package, and -f specifies the file name of the package.

# tar -rf all.tar *.gif
This command is to add all .gif files to the all.tar package. -r means adding files.

# tar -uf all.tar logo.gif
This command is to update the logo.gif file in the original tar package all.tar. -u means to update the file.

# tar -tf all.tar
This command is to list all files in the all.tar package, -t means to list files

# tar -xf all.tar
This command is to extract all. For all files in the tar package, -t means unpacking

compression

tar -cvf jpg.tar *.jpg //Package all jpg files in the directory into tar.jpg

tar -czf jpg.tar.gz *.jpg //Package all jpg files in the directory into jpg.tar, and compress them with gzip to generate a gzip-compressed package, named jpg.tar.gz

tar -cjf jpg.tar.bz2 *.jpg //Package all jpg files in the directory into jpg.tar, and compress them with bzip2 to generate a bzip2-compressed package named jpg.tar.bz2

tar -cZf jpg.tar.Z *.jpg //Package all jpg files in the directory into jpg.tar, and compress them with compress to generate a umcompress compressed package, named jpg.tar.Z

rar a jpg.rar *.jpg //For compression in rar format, you need to download rar for linux first

zip jpg.zip *.jpg //For compression in zip format, you need to download zip for linux first

Unzip

tar -xvf file.tar //Unzip tar Package

tar -xzvf file.tar.gz //Extract tar.gz

tar -xjvf file.tar.bz2 //Extract tar.bz2

tar -xZvf file.tar.Z //Extract tar.Z

unrar e file.rar //Extract rar

unzip file.zip //Extract zip

Summary

1. Use tar -xvf to decompress *.tar

2. Decompress *.gz with gzip -d or gunzip

3. *.tar.gz and *.tgz use tar -xzf to decompress

4. *.bz2 use bzip2 -d or bunzip2 to decompress

5. *.tar.bz2 use tar -xjf to decompress

6. *.Z Use uncompress to decompress

7, *.tar.Z Use tar -xZf to decompress

8, *.rar Use unrar e to decompress

9, *.zip Use unzip to decompress



More Please pay attention to the PHP Chinese website for related articles about tar compression and decompression commands under Linux!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software