2009年12月12日 星期六

在linux中使用rar

在linux中,其壓縮格式有許多
*.tar, *.tar.gz, *.tgz, *.gz, *.Z, *.bz2
*.Z         compress 程式壓縮的檔案;
*.gz        gzip 程式壓縮的檔案;
*.bz2       bzip2 程式壓縮的檔案;
*.tar       tar 程式打包的資料,並沒有壓縮過;
*.tar.gz    tar 程式打包的檔案,其中並且經過 gzip 的壓縮
*.tar.bz2   tar 程式打包的檔案,其中並且經過 bzip2 的壓縮
 
但,在windows上,常看的*.rar卻沒支援
這點,大致於其winrar,是商業型的軟体
故在大多的linux,並沒有放進去,故當
你要從別人,或寄送給別人時,別人不一定
要上述的格式,此時我們是需要有一個可解‘壓
檔案成為*.rar的

setup1:
http://www.rarlab.com/download.htm 
到些下載 winRARLinux.tar.gz
setup2:
將它解壓縮
(tar 對於*.tar 是下 tar -xvf *.tar;
而對於  *.tar.gz時,可分別對gz,對tar;或是一次tar -zxvf) 
[root@localhost src]# tar -zxvf rarlinux-3.9.1b1.tar.gz
rar/
rar/readme.txt
rar/default.sfx
rar/whatsnew.txt
rar/license.txt
rar/order.htm
rar/rar
rar/unrar
rar/rar_static
rar/technote.txt
rar/rarfiles.lst
rar/makefile
rar/rar.txt

setup3:
進入該資料夾中,對安裝其tartools
make clean
make 
make install

-------------------
接下來,是如何來用它所提供的 rar,unrar
來壓縮,解壓縮
----------
壓縮
Usage:     rar  - -  
rar <命令> - <其輸出的檔案名稱> <要壓縮的檔案>
[root@localhost 下載]# rar a rpm_file rpm.txt

RAR 3.91 beta 1   Copyright (c) 1993-2009 Alexander Roshal   24 Nov 2009
Shareware version         Type RAR -? for help

Evaluation copy. Please register.

Creating archive rpm_file.rar

Adding    rpm.txt                                                     OK 
Done
---------
解壓縮
Usage:     unrar  - -  
同上之
[root@localhost 下載]# unrar e rpm_file.rar

UNRAR 3.91 beta 1 freeware      Copyright (c) 1993-2009 Alexander Roshal


Extracting from rpm_file.rar


rpm.txt already exists. Overwrite it ?
[Y]es, [N]o, [A]ll, n[E]ver, [R]ename, [Q]uit y

Extracting  rpm.txt                                                   OK 
All OK
 
指定解壓路徑
[root@localhost 下載]# unrar x rpm_file.rar /home/steven/

UNRAR 3.91 beta 1 freeware      Copyright (c) 1993-2009 Alexander Roshal


Extracting from rpm_file.rar

Extracting  /home/steven/rpm.txt                                      OK 
All OK




------------
 RAR 3.91 beta 1   Copyright (c) 1993-2009 Alexander Roshal   24 Nov 2009
Shareware version         Type RAR -? for help

Usage:     rar - -
               <@listfiles...>


  a             Add files to archive
  c             Add archive comment
  cf            Add files comment
  ch            Change archive parameters
  cw            Write archive comment to file
  d             Delete files from archive
  e             Extract files to current directory
  f             Freshen files in archive
  i[par]=  Find string in archives
  k             Lock archive
  l[t,b]        List archive [technical, 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,b]        Verbosely list archive [technical,bare]
  x             Extract files with full path


  -             Stop switches scanning
  ad            Append archive name to destination path
  ag[format]    Generate archive name using the current date
  ai            Ignore file attributes
  ap      Set path inside archive
  as            Synchronize archive contents
  av            Put authenticity verification (registered versions only)
  av-           Disable authenticity verification check
  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[+]    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
  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
  k             Lock archive
  kb            Keep broken extracted files
  m<0..5>       Set compression level (0-store...3-default...5-maximal)
  mc       Set advanced compression parameters
  md      Dictionary size in KB (64,128,256,512,1024,2048,4096 or A-G)
  ms[ext;ext]   Specify file types to store
  n       Include only specified file
  n@            Read file names to include from stdin
  n@      Include files listed in specified list file
  o[+|-]        Set the overwrite mode
  ol            Save symbolic links as the link instead of the file
  or            Rename files automatically
  ow            Save or restore file owner and group
  p[password]   Set password
  p-            Do not query password
  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[,v[-],e] Create solid archive
  s-            Disable solid archiving
  sc[obj]  Specify the character set
  sfx[name]     Create SFX archive
  si[name]      Read data from standard input (stdin)
  sl      Process files with size less than specified
  sm      Process files with size more than specified
  t             Test files after archiving
  ta      Process files modified after in YYYYMMDDHHMMSS format
  tb      Process files modified before in YYYYMMDDHHMMSS format
  tk            Keep original archive time
  tl            Set archive time to latest file
  tn

-----------
UNRAR 3.91 beta 1 freeware      Copyright (c) 1993-2009 Alexander Roshal

Usage:     unrar - -
               <@listfiles...>


  e             Extract files to current directory
  l[t,b]        List archive [technical, bare]
  p             Print file to stdout
  t             Test archive files
  v[t,b]        Verbosely list archive [technical,bare]
  x             Extract files with full path


  -             Stop switches scanning
  ad            Append archive name to destination path
  ai            Ignore file attributes
  ap      Set path inside archive
  av-           Disable authenticity verification check
  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       Include only specified file
  n@            Read file names to include from stdin
  n@      Include files listed in specified 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      Process files with size less than specified
  sm      Process files with size more than specified
  ta      Process files modified after in YYYYMMDDHHMMSS format
  tb      Process files modified before in YYYYMMDDHHMMSS format
  tn



沒有留言:

張貼留言