ubuntu中rar与unrar用法详解

本文转载:http://helloklzs.iteye.com/blog/1139993

安装:

sudo apt-get install rar

这样就可以安装了

删除是以下语句

sudo apt-get install unrar



用法:     rar <命令> -<选项 1> -<选项 N> <压缩档案> <文件...>
               <@文件列表...> <解压缩路径\>

<命令>
  a             添加文件到压缩档案
  c             添加压缩档案注释(注释的大小最大不能超过62000字节)
  cf            添加文件备注( 当使用'v'参数时显示文件备注,最大不能超过32767字节)
  ch            改变压缩档案参数
  cw            向指定文件写入档案备注
  d             从档案中删除文件
  e             解压缩文件到当前目录(不创建任何子目录)
  f             刷新档案中的文件(更新这些文件自它们被打包之后产生的变化,不在压缩档案中增加新的)
  i[par]=<str>  在档案中查找特定字符
  k             锁定档案(任何试图改变压缩档案中内容的命令都会被忽略)
  l[t,b]        列出档案[technical, bare]
  m[f]          移动到压缩档案中[只针对文件]
  p             打印文件到标准输出
  r             修补压缩档案
  rc            重建丢失的分卷
  rn            重命名压缩档案中的文件
  rr[N]         添加数据恢复记录
  rv[N]         创建恢复卷
  s[name|-]     压缩档案与SFX(自解压文档)之间的转换
  t             测试压缩档案文件
  u             更新压缩档案中的文件
  v[t,b]        列出压缩档案的详细信息[technical,bare]
  x             解压缩到完整路径

<选项>
  -             停止对选项的扫描
  ad            追加档案名称到目标路径
  ag[format]    使用当前数据生成压缩档案名
  ap<path>      在档案内部设置路径
  as            同步档案内目录
  av            设置认证检测(只有注册版提供此功能)
  av-           关闭认证检测
  c-            关闭备注显示
  cfg-          关闭读取设置
  cl            转换名称为小写字母
  cu            转换名称为大写字母
  df            压缩后删除原文件
  dh            打开共享文件
  ds            关闭针对于稳固档案的名称排序
  dw            压缩后擦除文件
  e[+]<attr>    设置文件排除与包含属性
  ed            不添加空目录
  en            不设置档案结束块
  ep            名称中不包含路径
  ep1           名称中不包含基本文件目录
  ep3           展开路径到完整包含的驱动器名
  f             刷新文件
  hp[password]  加密文件数据和文件头部
  id[c,d,p,q]   关闭消息
  ierr          发送所有消息到标准错误输出
  ilog[name]    记录错误日志到文件中(只有注册版提供此功能)
  inul          关闭所有消息
  isnd          打开声音
  k             锁定压缩档案
  kb            保持被解压过的已损坏的文件
  m<0..5>       设置压缩等级(0-存储...3-默认...5-最大)
  mc<par>       设置高级压缩参数
  md<size>      Dictionary size in KB (64,128,256,512,1024,2048,4096 or A-G)
  ms[ext;ext]   存储指定的文件类型
  n<file>       仅包含指定的文件
  n@            从标准输入读取文件名到包含内容中
  n@<list>      在指定列表文件中包含文件
  o[+|-]        设置重写模式
  ol            替文件保存符号连接作为连接
  or            自动重命名文件
  ow            保存活存储文件的拥有者与群组
  p[password]   设置密码
  p-            不询问密码
  r             对子目录进行递归操作
  r0            仅用通配符名称对子目录进行递归操作
  rr[N]         添加数据恢复记录
  rv[N]         创建恢复
  s[<N>,v[-],e] 创建稳固档案压缩
  s-            关闭稳固档案压缩
  sc<chr>[obj]  设置指定的字符串
  sfx[name]     创建SFX档案
  si[name]      从标准输入读取数据
  sl<size>      处理文件的大小小于指定的值
  sm<size>      处理文件的大小大于指定的值
  t             压缩后测试文件
  ta<date>      处理修改日期为指定日期之后的文件,<date>格式: YYYYMMDDHHMMSS
  tb<date>      处理修改日期为指定日期之前的文件,<date>格式: YYYYMMDDHHMMSS
  tk            保持档案最初的时间
  tl            设置档案时间为据现在最近的文件时间
  tn<time>      处理比指定时间新的文件
  to<time>      处理比指定时间旧的文件
  ts<m,c,a>[N]  保存或存储文件时间(修改,创建,访问)
  u             更新文件
  v             创建自动大小的卷或列出所有卷
  v<size>[k,b]  创建指定大小的卷size=<size>*1000 [*1024, *1]
  ver[n]        文件版本控制
  vn            使用旧的卷命名体系
  vp            在每个卷之前暂停
  w<path>       指定工作目录
  x<file>       排除指定文件
  x@            排除从标准输入中读取的文件名称
  x@<list>      从指定列表文件中指定要排除的文件
  y             设定所有回答为yes
  z[file]       从文件中读取压缩档案的备注


注意:rar的<命令>部分不带"-"号,只有<选项>部分带"-"号,这一点注意一下。

例1:添加文件或目录到压缩档案中,使用a命令。例如把文件files1添加到abc.rar中,使用a或m命令,a命令把file1文件添加到 abc.rar档案中保持原有的file1文件不变,m命令移动file1文件到file1.rar档案中(压缩完成后会删除原有的file1文件,注 意:m命令只针对文件进行操作)
$rar a abc.rar file1

说明:如果此时abc.rar档案不存在,会自行创建abc.rar文档案,如果abc.rar档案已经存在,则将file1文件压缩进abc.rar档 案中,若abc.rar档案中已存在一个file1文件,则会更新file1文件。并且原有的file1文件依然存在于当前目录下,若要将file1文件 移动到file1.rar中请使用m命令,对于目录同样可以进行此操作。
注意:如果只输入"rar a file1.rar"命令,而没有接文件名或目录名的话,会将当前目录下所有的文件和文件夹压缩进file1.rar文档中。这点要注意一下。

例2:解压缩abc.rar档案中的内容,可以使用e或x命令,假设abc.rar目录中有一个名为file1的文件和一个名为test的目录,test目录中有一个名为file2的文件,
$rar e abc.rar

说明:使用e命令,会将abc.rar中的file1文件连同test目录下的file2文件解压到当前目录。如果想保持abc.rar目录中的目录结构请使用x命令。
$rar x abc.rar

说明:此时会将file1文件和test目录解压到当前文件夹。

例3:为整个压缩文件添加注释
$rar c abc.rar

说明:输入该命令后,屏幕最下方会显示
Processing archive test.
rarReading comment from stdin

并有一个光标在闪烁,从光标闪烁的位置输入注释信息,输入完了按下Ctrl+D结束输入

例4:为压缩文件中的单个文件添加注释,使用cf命令。假如现在要为abc.rar档案中的file1文件添加注释
$rar ch abc.rar file1

此时屏幕最下方会显示
Reading comment for abc.rar : file1 from stdin

从光标闪烁出输入想要为file1添加的注释,Ctrl+D结束输入

例4:把整个档案的注释写入到一个文件中,使用cw命令。加入要将abc.rar的注释写入到test.txt文件中
$rar cw abc.rar test.txt

说明:如果当前目录下不存在名为test.txt的文件,则会自行创建一个名为test.txt的文件,并将abc.rar的注释写入到text.txt 文件中,如果当前目录中已经存在一个名为text.txt的文件,则会提示你是否覆盖已经存在的文件,如果选择Yes或者All,则会清空 test.txt中原有的内容,然后将abc.rar的注释内容写入到text.txt文件中。

例4:删除压缩档案中的文件或目录,使用d命令。例如要删除abc.rar档案中的file1文件。
$rar d abc.rar file1

说明:该命令删除abc.rar档案中的file1文件,对于目录同样有效。

以上为常用的压缩与解压缩命令,<选项>部分的使用不再进行介绍了,请大家自己尝试一下吧。

解压缩命令unrar的使用:

$unrar --help

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

<命令>
  e             解压文件到当前目录
  l[t,b]        列出压缩文档信息[technical, bare]
  p             打印文件到标准输出
  t             测试压缩我俄当
  v[t,b]        列出压缩文档的详细信息[technical,bare]
  x             解压文件到完整路径
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
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
Ubuntu安装unrar,你可以按照以下步骤进行操作。首先,你需要打开终端并输入以下命令来安装rar压缩工具: sudo apt-get install rar 接下来,你需要安装unrar解压缩工具,输入以下命令: sudo apt-get install unrar 这样,你就成功安装了unrar工具。现在你可以使用unrar命令来解压缩.rar格式的压缩文件了。如果你想要压缩文件为.rar格式,你可以使用rar命令。 请注意,如果你在终端输入unrar命令或rar命令时遇到了问题,你可以尝试将其添加到系统路径,或者直接在rar文件所在的目录执行"./rar"或"./unrar"命令。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [Ubunturar格式压缩文件的处理及rarunrar命令详解](https://blog.csdn.net/qq_33475105/article/details/105680952)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [Linux ubuntu 20.04安装unrar](https://blog.csdn.net/vc_solo/article/details/122189279)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值