Home > System Tutorial > LINUX > Centos 7 compression and decompression command overview

Centos 7 compression and decompression command overview

WBOY
Release: 2023-12-31 21:02:03
forward
1107 people have browsed it

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 ~]# 
Copy after login
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 ~]# 
Copy after login

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 ~]# 
Copy after login

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 ~]# 
Copy after login

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
Copy after login

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 ~]# 
Copy after login

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
Copy after login

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!

Related labels:
source:jb51.net
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template