linux file compression and decompression command

We need to send a lot of use on linux or kits are compressed, we need to compress or decompress the file, but do not want to linux as windows with the mouse like a little point, we have to use the linux command to accomplish this jobs.

1. packed files

tar -cvf after the package file name is packaged file
to see chestnuts:

[root@localhost code]# ls
shell
[root@localhost code]# tar -cvf shell.tar shell
shell/
[root@localhost code]# ls
shell  shell.tar

2. packaged file compression

After the tar -czvf compressed file is compressed file name

shell  shell.tar
[root@localhost code]# tar -czvf shell.tar.gz shell.tar
shell.tar
[root@localhost code]# ls
shell  shell.tar  shell.tar.gz

This compression is completed
now we can remove the package and source files go extracting archive

[root@localhost code]# ls
fq  shell  shell.tar.gz  sher  zlb
[root@localhost code]# rm -rf shell
[root@localhost code]# ls
fq  shell.tar.gz  sher  zlb
[root@localhost code]# tar -xzvf shell.tar.gz 
shell/
shell/sher
[root@localhost code]# ls
fq  shell  shell.tar.gz  sher  zlb

Packaging - compression - decompression - the whole process of unpacking

[root@localhost code]# ls
shell
[root@localhost code]# tar -cvf shell.tar shell
shell/
shell/sher
[root@localhost code]# ls
shell  shell.tar
[root@localhost code]# rm shell -rf
[root@localhost code]# ls
shell.tar
[root@localhost code]# tar -czvf shell.tar.gz shell.tar 
shell.tar
[root@localhost code]# ls
shell.tar  shell.tar.gz
[root@localhost code]# rm -rf shell.tar
[root@localhost code]# ls
shell.tar.gz
[root@localhost code]# tar -xzvf shell.tar.gz 
shell.tar
[root@localhost code]# ls
shell.tar  shell.tar.gz
[root@localhost code]# rm -rf shell.tar.gz 
[root@localhost code]# ls
shell.tar
[root@localhost code]# tar -xvf shell.tar 
shell/
shell/sher
[root@localhost code]# ls
shell  shell.tar
[root@localhost code]# rm shell.tar 
rm: remove regular file `shell.tar'? y
[root@localhost code]# ls
shell
[root@localhost code]# 

Compression - decompression simplify the process

[root@localhost code]# ls
shell
[root@localhost code]# tar -czvf shell.tar.gz shell
shell/
shell/sher
[root@localhost code]# ls
shell  shell.tar.gz
[root@localhost code]# rm -rf shell
[root@localhost code]# ls
shell.tar.gz
[root@localhost code]# tar -xzvf shell.tar.gz 
shell/
shell/sher
[root@localhost code]# ls
shell  shell.tar.gz
[root@localhost code]# rm -rf shell.tar.gz 
[root@localhost code]# ls
shell
[root@localhost code]# cd shell/
[root@localhost shell]# ls
sher

Compression and decompression are common commands, you must master

Published 94 original articles · won praise 237 · views 70000 +

Guess you like

Origin blog.csdn.net/qq_38646470/article/details/79558204