search
HomeSystem TutorialLINUXCentos 7 compression and decompression command overview

1.zip file compression

Syntax: zip plus the compressed file name plus the file name to be compressed.

[root@localhost ~]# zip test.zip test.txt
  adding: test.txt (deflated 100%)
[root@localhost ~]# 
The percentage number of the progress bar appearing after

indicates that the compression has been completed. Then you can verify in ll to see if there is a file package you named.

[root@localhost ~]# ll
总用量 820004
-rw-------. 1 root root      1587 3月  22 16:58 anaconda-ks.cfg
-rw-r--r--. 1 root root      1635 3月  22 17:00 initial-setup-ks.cfg
-rw-r--r--. 1 root root 838860800 3月  26 14:56 test.txt
-rw-r--r--. 1 root root    814270 3月  26 14:57 test.zip
[root@localhost ~]# 

2. Unzip the zip file

To decompress

zip, add un in front of zip. If you want to specify the path, add -d

The syntax is unzip The file name to be decompressed -d Specify the decompression path

[root@localhost ~]# unzip test.zip -d /tmp/
Archive:  test.zip
  inflating: /tmp/test.txt           
[root@localhost ~]# 

Isn’t it very simple? Then use ls and add the path you specified to verify whether there are files you decompressed. If there are, it means you are successful. Congratulations on successfully learning zip compression and zip decompression! ! ! Then we continue....

[root@localhost ~]# ls /tmp
test.txt
[root@localhost ~]# 

3.tar compression and decompression

tar parameters are

-c Create a compressed file

-x Unzip a compressed file

-t View the files in the tar compressed file

-z Use gzip compression

-j Use bzip2 compression

-v displays files* during compression (commonly used) but is not recommended for background execution

-f uses the file name, note: f must be followed immediately by the file name, and no parameters can be added

Notice:

tar creates a file command

Syntax: tar [parameter] files and directories... ...

[root@localhost ~]# tar -czvf user /etc
tar: 从成员名中删除开头的“/”
/etc/
/etc/fstab
/etc/crypttab
/etc/mtab
/etc/resolv.conf
/etc/fonts/
/etc/fonts/conf.d/
/etc/fonts/conf.d/57-dejavu-serif.conf
/etc/fonts/conf.d/65-1-vlgothic-gothic.conf
/etc/fonts/conf.d/31-cantarell.conf
/etc/fonts/conf.d/65-0-lohit-nepali.conf
/etc/fonts/conf.d/59-liberation-mono.conf

There are a lot of things at the back that I can’t understand, so I went to the back and checked with ls to see if they exist.

[root@localhost ~]# ls
anaconda-ks.cfg  initial-setup-ks.cfg  test.txt  test.zip  user
[root@localhost ~]# 

Then let’s talk about decompression...

4. tar decompression

tar Add parameters and file name

[root@localhost ~]# tar -xvf user
etc/
etc/fstab
etc/crypttab
etc/mtab
etc/resolv.conf
etc/fonts/
etc/fonts/conf.d/
etc/fonts/conf.d/57-dejavu-serif.conf

There are a lot of decompression processes later, so I will omit them. Anyway, the decompression is successful

The following are the additions from other netizens

1. Linux version

Centos 7 压缩与解压缩命令小结

2. Unzip the .tar.gz package to the current directory

tar -xzvf apache-tomcat-7.0.90.tar.gz

Centos 7 压缩与解压缩命令小结
Centos 7 压缩与解压缩命令小结

3. Compress the specified file into a .tar.gz package

tar -czf apache-tomcat-7.0.90.tar.gz ./bin/ ./conf/ ./BUILDING.txt ./README.md

Centos 7 压缩与解压缩命令小结

4. Unzip the .war package to the current directory

jar -xvf file.war

Centos 7 压缩与解压缩命令小结
Centos 7 压缩与解压缩命令小结

5. Compress all files in the current directory into a .war package

jar -cvfM0 file2.war ./

Centos 7 压缩与解压缩命令小结
Centos 7 压缩与解压缩命令小结

6. Unzip the .tar package to the current directory

tar -xvf desk.tar

7. Compress the specified file into a .tar package

tar -czf desk2.tar ./file.pdf ./abc/

The above is the detailed content of Centos 7 compression and decompression command overview. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:脚本之家. If there is any infringement, please contact admin@php.cn delete
5 Best Free PDF to Word Doc Converters for Linux5 Best Free PDF to Word Doc Converters for LinuxMay 16, 2025 am 10:00 AM

Portable Document Format (PDF) remains a widely used file format due to its consistent standards across different platforms and devices, compatibility, and compact size.Numerous powerful tools are available for viewing PDF files, catering to various

How to Install Linux Mint 22 Mate on Your ComputerHow to Install Linux Mint 22 Mate on Your ComputerMay 16, 2025 am 09:44 AM

Linux Mint 22, codenamed “Wilma”, was officially launched as a significant update to Linux Mint on July 25, 2024. Linux Mint 22 is an LTS (Long Term Service) release, built upon Ubuntu 24.04, and will receive support until April 2029.As anticipated,

How to Hack Your Own Linux System to Strengthen SecurityHow to Hack Your Own Linux System to Strengthen SecurityMay 16, 2025 am 09:39 AM

Passwords serve as the primary security measure across various systems, including Linux, where the root password grants full control over the system. They are essential for securing BIOS, login, disks, applications, and more.Linux is widely regarded

6 Best Linux Software and Apps with Data Encryption6 Best Linux Software and Apps with Data EncryptionMay 16, 2025 am 09:33 AM

Data encryption is an essential component of modern cybersecurity, enabling the encoding of data to render it unreadable to unauthorized users. To enhance your online security, consider choosing software that incorporates this vital feature as a stan

How to Install Linux Mint 22 XFCE on Your ComputerHow to Install Linux Mint 22 XFCE on Your ComputerMay 16, 2025 am 09:28 AM

Linux Mint 22, with the codename “Wilma”, has been officially launched and is ready for download. Built on Ubuntu 24.04, it offers support until 2029 and comes in three flavors: Cinnamon, MATE, and XFCE.This guide will take you through the steps to i

16 Best Open Source Cloud Storage Software for Linux in 202416 Best Open Source Cloud Storage Software for Linux in 2024May 16, 2025 am 09:15 AM

The term "cloud" evokes a sense of vastness and expansiveness. In the technology sector, "the cloud" denotes a virtual platform that delivers services to end-users, encompassing data storage, application hosting, and the virtualiz

How to Install Linux Mint 22 Cinnamon on Your ComputerHow to Install Linux Mint 22 Cinnamon on Your ComputerMay 16, 2025 am 09:10 AM

Linux Mint is a contemporary, user-friendly, and community-driven GNU/Linux desktop distribution, built on the well-known Ubuntu Linux distribution. It's an excellent choice for users transitioning from Windows or macOS to the Linux environment.Linux

4 Best Tools to Create PDF Forms on Linux4 Best Tools to Create PDF Forms on LinuxMay 16, 2025 am 09:08 AM

Introduction: In this article, you will find the best applications for creating PDF files (also known as interactive tables) on Linux. If you need powerful tools to create and edit PDF files on Linux, you have many applications to choose from. These applications are able to perform basic editing operations such as merging pages, cropping pages, adding comments, and sometimes even providing advanced features. However, not all PDF editors can create PDF forms—that is, editable PDF files with interactive fields that can be filled in by other users. Such documents are useful in situations like you need to create a questionnaire, an admission form, or a sales contract, etc. The following list includes solutions that can run on various Linux distributions,

See all articles

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

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.