UNRAR 在 Windows 用户中广为人知并使用,RAR 文件是更小的档案,并且通过压缩文件对大多数文件的压缩比 ZIP 更好 “一起,” 节省更多空间,UNRAR 没有预先安装在 AlmaLinux 上,也没有在其存储库中提供。

下面的教程会告诉你如何使用 RPM FUSION 在 Almalinux 8 工作站或服务器上安装 UNRAR, 以及最常用的命令。

更新 AlmaLinux 系统

更新你的 AlmaLinux 操作系统以确保所有现有软件包都是最新的:

sudo dnf upgrade --refresh -y

安装 RPM Fusion 存储库

默认情况下,UNRAR 在 AlmaLinux 8 的默认存储库中不可用,因此您需要安装著名的 RPM Fusion 存储库,其中包含该软件包以及许多其他免费和专有的流行软件包。

要在终端中安装 RPM Fusion 存储库,您将执行以下命令。

安装/启用 RPM Fusion 免费存储库:
sudo dnf install --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm -y
安装/启用 RPM Fusion 非免费存储库:
sudo dnf install --nogpgcheck https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-8.noarch.rpm -y

接下来,验证安装。

dnf repolist | grep rpmfusion

输出示例:

如何在 AlmaLinux 8 上安装 UNRAR?_linux

安装 UNRAR

导入 RPM Fusion 后,您现在可以开始安装了。 在您的终端中,使用以下命令。

sudo dnf install unrar

输出示例:

如何在 AlmaLinux 8 上安装 UNRAR?_AlmaLinux 8_02

Y,然后按 回车键 继续。

最后,验证安装的版本以确保安装成功。

unrar -version | grep UNRAR

输出示例:

UNRAR 6.01 freeware      Copyright (c) 1993-2021 Alexander Roshal

如何使用 UNRAR

以下是使用 UNRAR 的一些基本命令和示例。 虽然它们没有展示所有可能的情况,但它们涵盖了大多数用户定期使用 UNRAR 的 75%。

在本教程继续深入之前,最有用的第一个命令是 help 命令。

unrar

输出示例:

Usage:     unrar <command> -<switch 1> -<switch N> <archive> <files...>
<@listfiles...> <path_to_extract\>
<Commands>
e Extract files without archived paths
l[t[a],b] List archive contents [technical[all], bare]
p Print file to stdout
t Test archive files
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[1,2] Alternate destination path
ag[format] Generate archive name using the current date
ai Ignore file attributes
ap<path> Set path inside archive
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
ep4<path> Exclude the path prefix from names
f Freshen files
id[c,d,n,p,q] Display or disable messages
ierr Send all messages to stderr
inul Disable all messages
kb Keep broken extracted files
me[par] Set encryption parameters
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
ol[a] Process symbolic links as the link [absolute paths]
op<path> Set the output path for extracted files
or Rename files automatically
ow Save or restore file owner and group
p[password] Set password
r Recurse subdirectories
sc<chr>[obj] Specify the character set
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
ta[mcao]<d> Process files modified after <d> YYYYMMDDHHMMSS date
tb[mcao]<d> Process files modified before <d> YYYYMMDDHHMMSS date
tn[mcao]<t> Process files newer than <t> time
to[mcao]<t> Process files older than <t> time
ts[m,c,a,p] Save or restore time (modification, creation, access, preserve)
u Update files
v List all volumes
ver[n] File version control
vp Pause before each volume
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

提取 RAR 存档当前目录

要在当前目录中提取或打开 RAR 文件,请使用 解开命令.

unrar e {file-name}.rar

将 RAR 存档解压缩到文件夹

要提取或打开需要特定路径或目标目录的 RAR 文件,请使用以下命令 ​​unrar​​ 再次,然后是最终目的地的完整路径。

unrar e {file-name}.rar /target/path

例如:

unrar {filename}.rar /opt/

提取具有目录结构的 RAR 存档

要提取具有目录结构的 RAR 存档,请使用 解压 x 命令.

unrar x {filename}.rar

列出 RAR 文件

要列出 RAR 文件中的文件,请使用以下命令 ​​unrar l​​.

unrar l[technical[all], bare] {filename}.rar

例如:

unrar l[t[a],b] {filename}.rar

测试 RAR 文件

要测试 RAR 文件中的文件,请使用以下命令 解压命令.

unrar t {filename}.rar

结论

在本教程中,您学习了如何在 AlmaLinux 8 上安装 UNRAR 并使用最常用的命令。

总体而言,UNRAR 是持续使用需要压缩的大量档案的绝佳选择,尤其是在 Windows 或 macOS 等多个操作系统之间工作时。