Compression and decompression scheme of rar package under linux

Category: LINUX

 

method one:

yum install unrar

Method Two:

Download address: http://www.rarsoft.com/download.htm

The latest one shall prevail.
For common compressed files .zip and .rar under Windows, Linux also has corresponding methods to decompress them:

1: For .zip

Linux provides zip and unzip programs, zip is a compression program, and unzip is a decompression program. They have a lot of parameter options, here is just a brief introduction, and an example to illustrate their usage:

# zip all.zip *.jpg (this command is to compress all .jpg files into a zip package)

# unzip all.zip (this The command is to extract all files in all.zip)

2: For .rar

to process .rar files under linux, you need to install RAR for Linux, which can be downloaded from the Internet, but remember that RAR for
Linux is not free ; You can
download RAR 3.60 for Linux from http://www.rarsoft.com/download.htm , and then install it as follows: # tar -xzpvf rarlinux-3.2.0.tar.gz # cd rar # make This is installed. After installation, there are two programs, rar and unrar. Rar is a compression program, and unrar is a decompression program. They have a lot of parameter options, give an example of their usage # rar a all *.jpg This command is to compress all .jpg files into a rar package named all.rar, the program will automatically append the .rar extension to the package name. # unrar e all.rar















This command is to extract all files in all.rar.

In fact, rar under linux is not open source, I personally recommend using this unrar.
Unrar can only decompress rar files, but cannot compress them. You can use bzip2 for compression under linux, but sometimes you still need to decompress rar files.

Unzip the file:
unrar e file.rar or
unrar x file.rar The
explanation is as follows:
#x Extract files with full path
#e Extract files to current directory

View the compressed file:
unrar l file.rar


Installation steps:
tar jxf unrar.tar.bz2
cd unrar
make
cp unrar /usr/bin/

Then you can use unrar to decompress it!

=====================================================

Detailed explanation of Linux rar command

rar x arm.rar Full path decompression


of rar command under Linux

Usage : rar <command> -<option1> ….-<optionN> <operation document> <file…> <@file list…> <decompression path>

usually The rar command consists of a main command plus several options (optional), the operation document is the .rar file object applied by the operation, and the
file or file list is the specific file or directory (optional) that modifies the operation document.
-------------------------------------------------- ----------------------
The common commands of rar mainly include
a Add files to the operation document
Example : rar a test.rar file1.txt If the test.rar file does not exist , then package the file1.txt file into test.rar
    Example: rar a test.rar file2.txt If the test.rar file already exists, add the file2.txt file to test.rar
    (there are two in test.rar file)
    Note, if there is a copy of a file in the operation document, the a command can update the file, and the directory can also be operated
   . Example: rar a test.rar dir1

c Add a note to the operation document
   rar c test. rar
    (Reading comment from stdin will appear, then enter one or more lines of comments, ending with ctrl+d)
    cf Add a file comment, similar to c above, but this is to comment on each file in the archive

    cw Write the document comment to the file
    Example: rar cw test.rar comment.txt

d Delete the file from the document
    Example: rar d test .rar file1.txt

e Unzip the file to the current directory
   Example: rar e test.rar
    Note: If you unzip with e, not only the original file1.txt and file2.txt will be extracted to the current directory,
    but also all the files in dir1 It is decompressed to the current directory, and the directory structure before compression cannot be maintained. If you want to maintain the directory structure before compression, use x to decompress

k to lock the document
   . Example: rar k test.rar After the document is locked, the document cannot be updated.

r Repair the document
   example: rar r test.rar
     When there is a problem with the rar file, you can try to use this command to repair (the ghost knows how much use)

s Convert the document into a self-extracting document
   Example: rar s test.rar
    will generate a test. The executable document of sfx, the effect of running it is equivalent to rar x test.rar,
    suitable for transferring files to users without rar

t test document
   example: rar t test.rar
    Check the integrity of test.rar. Generally, it is best to use this command to ensure the correctness of the file before compressing large files and preparing for transmission.

x Unzip the contents of the document with a path to the current directory
   Example: rar x test.rar If
    this is decompressed, dir1 will be The original directory structure will be maintained. The

above are the common commands of rar. There can only be one command for a rar operation, but there can be multiple options.
-------------------------------------------------- ----------------------
There are a lot of rar options, I can't explain them all here, just demonstrate a few frequently used

cl Convert the file name to lowercase
cu will Convert the file name to uppercase
   Example: rar a -cl test.rar
     FILe.txt FILe.txt becomes file.txt after adding to test.rar

df Delete the source file after document operation
    Example: rar a -df test.rar file1 .txt file2.txt dir1
     After compressing file1.txt, file2.txt, dir1 into test.rar, delete the source file

ed without adding an empty directory
    Example: rar a -ed test.rar dir1
     When adding dir1 to test.rar , do not operate on empty directories
     rar e -ed test.rar
     When decompressing test.rar, no empty directories are generated

k lock file
   example: rar a -k test.rar file1.txt is
    equivalent to rar a test.rar file1.txt
          rar k

test.rar m<0..5> Set the compression ratio level (0-storage, 3- Default, 5-maximum)
   Example: rar a -m0 test.rar dir1
    dir2 pack dir1, dir2 into test.rar, without substantial compression (extremely fast, suitable for operating on files that are not very compressible
    Such as avi, jpg, etc.)
    rar a -m5 test.rar *.txt *.bmp
    Pack and compress the txt file and bmp file in the current directory into test.rar, using the maximum compression ratio (the slowest)

ms[ext;ext ] Uncompressed method for specific files
   Example: rar a -m5 -ms avi;jpg;jpeg test.rar /home
    Archives all directories and files in the home directory to test.rar, using maximum compression, but avi, jpg, jpeg files Do not compress
    (just package it into test.rar, because these files cannot be compressed much even with the maximum compression, it is better to package them directly to save time)

o+ Overwrite existing files
o- Do not overwrite existing files
   Example: rar x -o- test. rar
    decompresses the test.rar file, but does not overwrite if it encounters an existing file

ol Save symbolic links as link files instead of ordinary files
ow Save or restore file owner information (username, group)
These two commands are unique to *nix systems, it is easy to understand
--------- -------------------------------------------------- --------------
p[password] Set the password
   Example: rar a test.rar *.txt -p prettygirl
    compressed file set the password to prettygirl, you cannot operate without a password when
    decompressing If you feel that the plaintext password is too exposed, you can use
    rar a test.rar *.txt -p
    and the rar program will ask you what password you want to use, without echoing

s- Do not use solid compression
    Note, solid compression is the content of the compressed document Immutable compression, which is not the same as lock. Because the use of ordinary compression
        to take care of the needs of subsequent insertion and deletion of individual files, it is necessary to leave a lot of room for manipulation. The solid compression can not make any updates
        to its content, so the compression ratio is the largest.

sfx[name] creates a self-extracting file, which is the same as compressing with a and converting with s.

t Perform integrity check after compression.
   Example: rar a test.rar /home -t
    Check after compression, and report an error if there is a problem.

ta only operates on files after the data date
tb only operates on files before the data date.
    Note that the format of date is YYYYMMDDHHMMSS.

v[k,b] is compressed by volume, and the size of each volume is specified by the following size
   Example: rar a -v15000k -m0 test xvid-fn.avi
    Pack and store xvid-fn.avi, and the size of each volume is 15000k (this format It is very popular when publishing dvdrip on the Internet)
    The generated files are named test.part1.rar, test.part2.rar….(rar version 3.20)

x Exclude specific files
   Example: rar x test.rar -x *.txt
    Unzip test Documents other than *.txt in .rar
x@ Same as above, but this time all excluded files are placed in the list file list y Answer yes    for

all operations.
), add -y to select Yes by default and no longer ask

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326914093&siteId=291194637