源于 WinRAR 的 Linux RAR 解压缩工具

源于 WinRAR 的 Linux RAR 解压缩工具

WinRAR 是 Windows 下用户得最多的压缩工具之一,网络上不少资料也是 .rar 压缩包。但是大部分 Linux 发行版中默认并没有包含管理 RAR 压缩文件的工具。因此,如果要在 Linux 下管理和制作 RAR 压缩文件,需要在 Linux 系统中安装相应的软件包。

  WinRAR 是 Windows 下用户得最多的压缩工具之一,网络上不少资料也是 .rar 压缩包。但是大部分 Linux 发行版中默认并没有包含管理 RAR 压缩文件的工具。因此,如果要在 Linux 下管理和制作 RAR 压缩文件,需要在 Linux 系统中安装相应的软件包。

RAR for Linux

  RAR for Linux 是由 rarlab (即开发 WinRAR 的公司) 推出的 RAR 管理工具,用户可通过以下地址查找并下载最新版本的 rarlinux 软件包

  WinRAR 及 RAR 下载页面: http://www.rarlab.com/download.htm

安装 rarlinux

  通过以上链接下载到最新版的 RAR for Linux,接下来就要将其安装 (解压) 到系统中即可使用。(以下的安装以目前的最新版 RAR 3.93 for Linux 为例)

  假设 rarlinux-3.9.3.tar.gz 文件的绝对路径为 /home/lugir/Download/Software/rarlinux-3.9.3.tar.gz,按照以下的命令,就可以将 rarlinux 安装到系统中,并且用户只需在命令行下输入 rar 或者 unrar 就可以使用了。


cd /opt/
tar xvf /home/lugir/Download/Software/rarlinux-3.9.3.tar.gz
...
ln -s /opt/rar/rar /usr/bin/rar
ln -s /opt/rar/unrar /usr/bin/unrar

注意:在 /opt 目录下创建内容,以及在 /usr/bin 目录下创建链接都需要 root 权限

 

使用 rarlinux

  rar 和 unrar 的命令及参数用法多种多样,以下只介绍一些常用的命令组合,更多更详细用法及说明请参考命令 rar --helpunrar --help

 

解压缩文件

  unrar t <rar_file> 命令测试要解压缩的文件 —— 只测试压缩文件是否正常,不进行实际的解压缩操作


unrar t test.rar

  unrar e <rar_file> 命令将压缩文件解压到当前目录 —— 以下命令将 test.rar 压缩包的内容解压到当前目录


unrar e test.rar

  unrar x <rar_file> <directory> 命令将压缩文件解压到指定的目录 —— 以下命令将 test.rar 压缩文件解压到 /tmp/test/ 目录下


unrar x test.rar /tmp/test/

 

将文件打包成压缩文件

  在 Linux 下很少需要将数据打包为 RAR 压缩文件,因为 Linux 和 Unix 间的数据打包和交换形式实在是太多了。不过为了方便与 Windows 用户传递数据,学会使用 rarlinux 制作 .rar 压缩文件还是有需要的。

  使用 rarlinux 将制作 .rar 文件的命令格式为:rar a <压缩文件名> <file1> <file2> ... <fileN>

  以下示例将 image 和 css 目录,以及 index.php 文件压缩成 backup.rar 文件


rar a backup.rar image/ css/ index.php

  以下命令将所有以 .php 和 .html 文件压缩成 web.rar 文件


rar a web.rar *.php *.html


转载地址:http://lugir.com/software/rar4linux.html


Linux下的rar解压缩工具RAR 5.60 beta 1 Copyright (c) 1993-2018 Alexander Roshal 21 Mar 2018 Trial version Type 'rar -?' for help Usage: rar <command> -<switch 1> -<switch N> <archive> <files...> <@listfiles...> <path_to_extract\> <Commands> a Add files to archive c Add archive comment ch Change archive parameters cw Write archive comment to file d Delete files from archive e Extract files without archived paths f Freshen files in archive i[par]=<str> Find string in archives k Lock archive l[t[a],b] List archive contents [technical[all], bare] m[f] Move to archive [files only] p Print file to stdout r Repair archive rc Reconstruct missing volumes rn Rename archived files rr[N] Add data recovery record rv[N] Create recovery volumes s[name|-] Convert archive to or from SFX t Test archive files u Update files in archive 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 as Synchronize archive contents c- Disable comments show cfg- Disable read configuration cl Convert names to lower case cu Convert names to upper case df Delete files after archiving dh Open shared files ds Disable name sort for solid archive dw Wipe files after archiving e[+]<attr> Set file exclude and include attributes ed Do not add empty directories en Do not put 'end of archive' block ep Exclude paths from names ep1 Exclude base directory from names ep3 Expand paths to full including the drive letter f Freshen files hp[password] Encrypt both file data and headers ht[b|c] Select hash type [BLAKE2,CRC32] for file checksum id[c,d,p,q] Disable messages ierr Send all messages to stderr ilog[name] Log errors to file inul Disable all messages isnd Enable sound iver Display the version number k Lock archive kb Keep broken extracted files log[f][=name] Write names to log file m<0..5> Set compression level (0-store...3-default...5-maximal) ma[4|5] Specify a version of archiving format mc<par> Set advanced compression parameters md<n>[k,m,g] Dictionary size in KB, MB or GB ms[ext;ext] Specify file types to store mt<threads> Set the number of threads 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 oh Save hard links as the link instead of the file oi[0-4][:min] Save identical files as references ol[a] Process symbolic links as the link [absolute paths] or Rename files automatically ow Save or restore file owner and group p[password] Set password p- Do not query password qo[-|+] Add quick open information [none|force] r Recurse subdirectories r- Disable recursion r0 Recurse subdirectories for wildcard names only rr[N] Add data recovery record rv[N] Create recovery volumes s[<N>,v[-],e] Create solid archive s- Disable solid archiving sc<chr>[obj] Specify the character set sfx[name] Create SFX archive si[name] Read data from standard input (stdin) sl<size> Process files with size less than specified sm<size> Process files with size more than specified t Test files after archiving ta<date> Process files modified after <date> in YYYYMMDDHHMMSS format tb<date> Process files modified before <date> in YYYYMMDDHHMMSS format tk Keep original archive time tl Set archive time to latest file tn<time> Process files newer than <time> to<time> Process files older than <time> ts[m|c|a] Save or restore file time (modification, creation, access) u Update files v<size>[k,b] Create volumes with size=<size>*1000 [*1024, *1] ver[n] File version control vn Use the old style volume naming scheme vp Pause before each volume w<path> Assign work directory 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 z[file] Read archive comment from file
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值