Compression and decompression under linux

First, the zip format
zip may be the most used document compression format. Its biggest advantage is that it can be used on different operating system platforms, such as Linux, Windows and Mac OS. The downside is that the supported compression ratios are not very high, while tar.gz and tar.gz2 do very well in terms of compression ratios.
We can compress a directory with the following command:

zip -r archive_name.zip directory_to_compress

Here's how to unzip a zip archive:

unzip archive_name.zip

#unzip archive_name.zip –d new_dir

2. rar format
RAR is a private format for file compression and archiving. It is used for data compression and archiving packaging. Simply put, it is the file format suffix name that is saved after the original file data is compressed. Usually Windows users are more common. The compression software WinRAR, by using WinRAR to compress the file data, the default saved file format is RAR format.
rar command using methods
a add files to archive
c add archive comments (the maximum size of comments cannot exceed 62000 bytes)
cf add file comments (when the 'v' parameter is used to display file comments, the maximum cannot exceed 32767 bytes)
ch change archive parameters
cw write archive remarks to specified file
d delete files from archive
e unpack files to current directory (without creating any subdirectories)
f refresh files in archive (update these files with changes since they were packed , do
not add new ones to the archive)
i[par]= find a specific character in the archive
k lock the archive (any commands that try to change the contents of the archive are ignored)
l[t,b] list the archives [technical, bare]
m[f] move to archive [file only]
p print file to stdout
r patch archive
rc rebuild lost volume
rn rename file in archive
rr[N] add data recovery record
rv[ N] Create recovery volume
s[name|-] Convert between archive and SFX (self-extracting archive)
t Test archive file
u update files in archive
v[t,b] list archive details [technical,bare]
x extract to full path

Compression command use rar
rar a anaconda-ks.cfg.rar anaconda-ks.cfg
decompression command unrar use:
$unrar --help

Usage: unrar - -
<@listfiles...>
<command>
e unzip files to current directory
l[t,b] list archive information [technical, bare]
p print files to standard output
t test zip I rust
v [t,b] List the details of the archive [technical,bare]
x Extract the archive to the full path
[root@localhost ~]# unrar e anaconda-ks.cfg.rar /home/

Third, the tar format
Tar is a very widely used document packaging format in Linux. Its advantage is that it only consumes very little CPU and time to package files. It is just a packaging tool and is not responsible for compression. Here's how to package a directory:

tar -cvf archive_name.tar directory_to_compress

How to unpack:

tar -xvf archive_name.tar.gz

The above unpack command will unpack the document in the current directory. Of course, you can also pinch the unpacked path with this command:

tar -xvf archive_name.tar -C /tmp/extract_here/

Fourth, tar.gz format
This format is the most used compression format. It does not take up too much CPU when compressing, and can get a very ideal compression ratio.
compression:

tar -zcvf archive_name.tar.gz directory_to_compress

unzip:

tar -zxvf archive_name.tar.gz

The above unpack command will unpack the document in the current directory. Of course, you can also create an unpacked path with this command:

tar -zxvf archive_name.tar.gz -C /tmp/extract_here/

Five, tar.bz2 format
This compression format is the best compression rate among all the methods we mentioned. Of course, this also means that it takes up more CPU and time than the previous method.
compression:

tar -jcvf archive_name.tar.bz2 directory_to_compress

The above unpack command will unpack the document in the current directory. Of course, you can also create an unpacked path with this command:

tar -jxvf archive_name.tar.bz2 -C /tmp/extract_here/

    tar是操作.tar的命令 
    gzip是压缩.gz压缩包的命令 

    compress:压缩.Z文件 

    uncompress:解压缩.Z文件

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325198130&siteId=291194637