linux解压rar格式文件

本文介绍如何在Linux CentOS 6.4环境下安装并使用UNRAR程序来解压缩RAR文件。包括检查Linux版本、下载对应版本的UNRAR安装包、安装程序及详细命令用法等步骤。

1.查看linux版本

$  cat /etc/redhat-release

CentOS release 6.4 (Final)

$uname -r

2.6.32-358.el6.i686

2.下载对应的unrar安装包

下载地址:http://www.rpmfind.net/linux/rpm2html/search.php?query=unrar

使用el6.i686在页面查找对应的版本.

3.安装unrar程序

$ sudo rpm -ivh unrar-5.0.3-1.el6.rf.i686.rpm

warning: unrar-5.0.3-1.el6.rf.i686.rpm: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY
Preparing...                ########################################### [100%]
   1:unrar                  ########################################### [100%]

4.使用unrar命令

$ unrar --help

UNRAR 5.00 beta 3 freeware      Copyright (c) 1993-2013 Alexander Roshal

Usage:     unrar <command> -<switch 1> -<switch N> <archive> <files...>
               <@listfiles...> <path_to_extract\>

<Commands>
  e             Extract files without archived paths
  l[t[a],b]     List archive contents [technical[all], bare]
  p             Print file to stdout
  t             Test archive files
  v[t[a],b]     Verbosely list archive contents [technical[all],bare]
  x             Extract files with full path

<Switches>
  -             Stop switches scanning
  @[+]          Disable [enable] file lists
  ad            Append archive name to destination path
  ag[format]    Generate archive name using the current date
  ai            Ignore file attributes
  ap<path>      Set path inside archive
  c-            Disable comments show
  cfg-          Disable read configuration
  cl            Convert names to lower case
  cu            Convert names to upper case
  dh            Open shared files
  ep            Exclude paths from names
  ep3           Expand paths to full including the drive letter
  f             Freshen files
  id[c,d,p,q]   Disable messages
  ierr          Send all messages to stderr
  inul          Disable all messages
  kb            Keep broken extracted files
  n<file>       Additionally filter included files
  n@            Read additional filter masks from stdin
  n@<list>      Read additional filter masks from list file
  o[+|-]        Set the overwrite mode
  or            Rename files automatically
  ow            Save or restore file owner and group
  p[password]   Set password
  p-            Do not query password
  r             Recurse subdirectories
  sl<size>      Process files with size less than specified
  sm<size>      Process files with size more than specified
  ta<date>      Process files modified after <date> in YYYYMMDDHHMMSS format
  tb<date>      Process files modified before <date> in YYYYMMDDHHMMSS format
  tn<time>      Process files newer than <time>
  to<time>      Process files older than <time>
  ts<m,c,a>[N]  Save or restore file time (modification, creation, access)
  u             Update files
  v             List all volumes
  ver[n]        File version control
  vp            Pause before each volume
  x<file>       Exclude specified file
  x@            Read file names to exclude from stdin
  x@<list>      Exclude files listed in specified list file
  y             Assume Yes on all queries


5.解压文件

$unrar x *.rar

### 安装解压工具 在 Linux 系统中解压 RAR 文件,需要使用第三方工具,例如 `unrar`、`rar` 或 `p7zip`。以 `unrar` 为例,可以通过包管理器安装该工具。对于基于 Debian 的系统,可以使用以下命令安装 `unrar`: ```bash sudo apt install unrar ``` 如果希望使用 `rar` 工具,可以选择手动安装。首先下载 RAR 工具包,例如: ```bash wget https://www.rarlab.com/rar/rarlinux-x64-6.0.2.tar.gz ``` 下载完成后,解压并进入解压后的目录,执行编译命令: ```bash tar -zxvf rarlinux-x64-6.0.2.tar.gz cd rar make ``` 完成编译后,需要将 `rar` 和 `unrar` 添加到系统环境变量中,以便全局调用。可以通过修改 `/etc/profile` 文件实现: ```bash vi /etc/profile ``` 添加以下内容以设置环境变量: ```bash export RAR_HOME=/data/apps/rar export PATH=.:$JAVA_HOME/bin:$JRE_HOME/bin:$RAR_HOME:$PATH ``` 保存并退出后,执行以下命令使环境变量生效: ```bash source /etc/profile ``` 验证 `rar` 和 `unrar` 是否已正确安装: ```bash which rar which unrar ``` ### 解压 RAR 文件 使用 `unrar` 命令解压 RAR 文件时,可以选择是否保留原文件目录结构。保留目录结构的命令如下: ```bash unrar x test.rar ``` 如果希望解压时将所有文件压平(即不保留目录结构),可以使用以下命令: ```bash unrar e test.rar ``` ### 压缩文件 除了支持解压 RAR 文件,`rar` 工具还支持压缩文件。例如,压缩所有 `.jpg` 文件并保留原目录结构,可以使用以下命令: ```bash rar a -r all.rar *.jpg ``` 其中,`a` 表示添加文件到压缩包,`-r` 表示递归处理子文件夹,`all.rar` 是生成的压缩文件名,`*.jpg` 表示所有 `.jpg` 文件[^3]。 ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值