Windows 系统压缩的 rar 和 zip 文件,在 Linux 系统下是无法通过 tar 命令解压缩的,需要使用 rar 和 zip 命令来解压缩。下面记录一下 rar 和 zip 安装和简单的使用。
一、rar 安装使用
Linux 系统下使用 rarlinux 解压缩 rar 压缩文件,下载页面:http://www.rarsoft.com/download.htm。
1.1 下载系统对应的版本
| 1
 | $ wget http://www.rarsoft.com/rar/rarlinux-x64-5.4.0.tar.gz
 | 
1.2 解压、安装
| 12
 3
 
 | $ tar -zxvf rarlinux-x64-5.4.0.tar.gz$ cd rar
 $ make
 
 | 
看见下面这些信息就是安装成功了:
| 12
 3
 4
 5
 
 | mkdir -p /usr/local/binmkdir -p /usr/local/lib
 cp rar unrar /usr/local/bin
 cp rarfiles.lst /etc
 cp default.sfx /usr/local/lib
 
 | 
1.3 常用 rar 命令
| 12
 
 | $ rar x centos.rar $ rar centos.rar ./piaoyi.org/
 
 | 
1.4 常见错误原因分析
1.4.1 如果在运行命令 rar 时,出现下面这个问题
| 1
 | rar: /lib/i686/nosegneg/libc.so.6: version 'GLIBC_2.7' not found (required by rar)
 | 
解决办法:
| 1
 | $ cp rar_static /usr/local/bin/rar
 | 
1.4.2 使用 rar 的时候出现错误
| 1
 | bash: /usr/local/bin/rar: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
 | 
因为 64 位系统中安装了 32 位程序,解决方法:
| 1
 | $ yum install glibc.i686
 | 
1.4.3 重新安装 glibc.i686 以后还有如下类似错误
| 1
 | error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
 | 
再继续安装包:
| 1
 | $ yum install libstdc++.so.6
 | 
二、zip/unzip 安装使用
2.1 检查是否有包含 zip(unzip) 的软件包
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 
 | $ yum provides zipLoaded plugins: fastestmirror
 Loading mirror speeds from cached hostfile
 * base: mirrors.cqu.edu.cn
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
 zip-3.0-11.el7.x86_64 : A file compression and packaging utility compatible with PKZIP
 Repo        : base
 
 
 
 zip-3.0-11.el7.x86_64 : A file compression and packaging utility compatible with PKZIP
 Repo        : @base
 
 | 
2.2 安装 zip、unzip
| 12
 
 | $ yum install zip$ yum install unzip
 
 | 
2.3 常用命令
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 
 | $ zip -r myfile.zip ./*
 
 $ unzip -o -d /home/sunny myfile.zip
 
 
 
 
 $ zip -d myfile.zip smart.txt
 
 
 $ zip -m myfile.zip ./rpm_info.txt
 
 
 |