歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> CentOS安裝rar及用法

CentOS安裝rar及用法

日期:2017/3/1 11:47:33   编辑:關於Linux

安裝步驟如下:
1、下載rar安裝包
下載地址:http://www.rarsoft.com/download.htm,根據操作系統選擇對應的二進制安裝包,我的CentOS操作系統為64bit,因此下載的rar為rarlinux-x64-5.4.b2.tar.gz。

2、安裝rar

[root@localhost Downloads]# tar -zxvf rarlinux-x64-5.4.b2.tar.gz 
rar/
rar/order.htm
rar/acknow.txt
rar/readme.txt
rar/rar_static
rar/default.sfx
rar/license.txt
rar/rarfiles.lst
rar/whatsnew.txt
rar/makefile
rar/rar
rar/unrar
rar/rar.txt
[root@localhost Downloads]# cd rar
[root@localhost rar]# ls
acknow.txt   license.txt  order.htm  rarfiles.lst  rar.txt     unrar
default.sfx  makefile     rar        rar_static    readme.txt  whatsnew.txt
[root@localhost rar]# make
mkdir -p /usr/local/bin
mkdir -p /usr/local/lib
cp rar unrar /usr/local/bin
cp rarfiles.lst /etc
cp default.sfx /usr/local/lib
[root@localhost rar]# rar

RAR 5.40 beta 2   Copyright (c) 1993-2016 Alexander Roshal   30 May 2016
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 (registered versions only)
  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>[N]  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

3、rar命令用法
例1:添加文件或目錄到壓縮檔案中,使用a命令。
例如把文件files1添加到abc.rar中,使用a或m命令,a命令把file1文件添加到abc.rar檔案中保持原有的file1文件不變,m命令移動file1文件到file1.rar檔案中(壓縮完成後會刪除原有的file1文件,注意:m命令只針對文件進行操作)

[root@localhost ~]# 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的文件,
[root@localhost ~]# rar e abc.rar  #不推薦
說明:使用e命令,會將abc.rar中的file1文件連同 test目錄下的file2文件解壓到當前目錄。如果想保持abc.rar目錄中的目錄結構請使用x命令。
[root@localhost ~]# rar x abc.rar #推薦
說明:此時會將file1文件和test目錄解壓到當前文件夾。

例3:為整個壓縮文件添加注釋
[root@localhost ~]# rar c abc.rar
說明:輸入該命令後,屏幕最下方會顯示
Processing archive test.
rarReading comment from stdin
並有一個光標在閃爍,從光標閃爍的位置輸入注釋信息,輸入完了按下Ctrl+D結束輸入

例4:把整個檔案的注釋寫入到一個文件中,使用cw命令。加入要將abc.rar的注釋寫入到test.txt文件中
[root@localhost ~]# rar cw abc.rar test.txt
說 明:如果當前目錄下不存在名為test.txt的文件,則會自行創建一個名為 test.txt的文件,並將abc.rar的注釋寫入到text.txt文 件中,如果當前目錄中已經存在一個名為text.txt的文件,則會提示你是否覆蓋已經存在的文件,如果選擇Yes或者All,則會清空test.txt 中原有的內容,然後將abc.rar的注釋內容寫入到text.txt文件中。

例5:刪除壓縮檔案中的文件或目錄,使用d命令。例如要刪除abc.rar檔案中的file1文件。
[root@localhost ~]# rar d abc.rar file1
說明:該命令刪除abc.rar檔案中的file1文件,對於目錄同樣有效。

解壓縮命令unrar的使用:
[root@localhost ~]# unrar --help
用法:

unrar 


- - <@listfiles...> <命令>
e             解壓文件到當前目錄
l[t,b]        列出壓縮文檔信息[technical, bare]
p             打印文件到標准輸出
t             測試壓縮我俄當
v[t,b]        列出壓縮文檔的詳細信息[technical,bare]
x             解壓文件到完整路徑
unrar的命令和rar具有同樣的效果,可以看出unrar只包含了rar的一部分命令而已,因此使用rar就可以完成所有操作。

參數如下:
<命令>

  a             添加文件到壓縮檔案
  c             添加壓縮檔案注釋(注釋的大小最大不能超過62000字節)
  cf            添加文件備注( 當使用'v'參數時顯示文件備注,最大不能超過32767字節)
  ch            改變壓縮檔案參數
  cw            向指定文件寫入檔案備注
  d             從檔案中刪除文件
  e             解壓縮文件到當前目錄(不創建任何子目錄)
  f             刷新檔案中的文件(更新這些文件自它們被打包之後產生的變化,不在壓縮檔案中增加新的)
  i[par]=  在檔案中查找特定字符
  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      在檔案內部設置路徑
  as            同步檔案內目錄
  av            設置認證檢測(只有注冊版提供此功能)
  av-           關閉認證檢測
  c-            關閉備注顯示
  cfg-          關閉讀取設置
  cl            轉換名稱為小寫字母
  cu            轉換名稱為大寫字母
  df            壓縮後刪除原文件
  dh            打開共享文件
  ds            關閉針對於穩固檔案的名稱排序
  dw            壓縮後擦除文件
  e[+]    設置文件排除與包含屬性
  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       設置高級壓縮參數
  md      Dictionary size in KB (64,128,256,512,1024,2048,4096 or A-G)
  ms[ext;ext]   存儲指定的文件類型
  n       僅包含指定的文件
  n@            從標准輸入讀取文件名到包含內容中
  n@      在指定列表文件中包含文件
  o[+|-]        設置重寫模式
  ol            替文件保存符號連接作為連接
  or            自動重命名文件
  ow            保存活存儲文件的擁有者與群組
  p[password]   設置密碼
  p-            不詢問密碼
  r             對子目錄進行遞歸操作
  r0            僅用通配符名稱對子目錄進行遞歸操作
  rr[N]         添加數據恢復記錄
  rv[N]         創建恢復
  s[,v[-],e] 創建穩固檔案壓縮
  s-            關閉穩固檔案壓縮
  sc[obj]  設置指定的字符串
  sfx[name]     創建SFX檔案
  si[name]      從標准輸入讀取數據
  sl      處理文件的大小小於指定的值
  sm      處理文件的大小大於指定的值
  t             壓縮後測試文件
  ta      處理修改日期為指定日期之後的文件,格式: YYYYMMDDHHMMSS
  tb      處理修改日期為指定日期之前的文件,格式: YYYYMMDDHHMMSS
  tk            保持檔案最初的時間
  tl            設置檔案時間為據現在最近的文件時間
  tn
Copyright © Linux教程網 All Rights Reserved