如何在Ubuntu,Debian,Kali,Mint中列出和解压缩Rar文件?

Rar is a very popular compression format used for different purposes. A lot of files like documents, image files, source code, etc. are compressed using rar compression format. In this tutorial, we will look at how to install rar tool for Ubuntu, Debian, Kali, and Mint and then list and extract files and directories.

Rar是一种非常流行的压缩格式,用于不同目的。 许多文件(如文档,图像文件,源代码等)都使用rar压缩格式进行压缩。 在本教程中,我们将研究如何为Ubuntu,Debian,Kali和Mint安装rar工具,然后列出并提取文件和目录。

安装Unrar (Install Unrar)

We will use apt package manager in order to install unrar package.

我们将使用apt软件包管理器来安装unrar软件包。

$ apt install unrar
Install Unrar
Install Unrar
安装Unrar

列出Rar文件内容 (List Rar File Contents)

We can list contents of a rar files with l option and the rar file name. In this example we will list contents of rar file named ans.rar .

我们可以使用l选项和rar文件名列出rar文件的内容。 在此示例中,我们将列出名为ans.rar的rar文件的内容。

$ unrar l ans.rar
List Rar File Contents
List Rar File Contents
列出Rar文件内容

The list operation will print attributes, size, date time and names.

列表操作将打印属性,大小,日期时间和名称。

卸载所有文件和目录 (Unrar All Files and Directories)

We can use e option in order to extract all files and directories inside a rar file. In this example, we will extract contents of ans.rar . -r is used to extract recursively which means all sub files and directories will be extracted too.

我们可以使用e选项来提取rar文件中的所有文件和目录。 在此示例中,我们将提取ans.rar内容。 -r用于递归提取,这意味着所有子文件和目录也将被提取。

$ unrar e -r ans.rar
Unrar All Files and Directories
Unrar All Files and Directories
卸载所有文件和目录

Unrar单个文件或目录(Unrar Single File or Directory)

Some times we may need to extract only a single file or directory from a rar file. This may be a backup rar file where we only need a single file or directory. We need to specify the file and directory path and name in a relative manner. In this example, we will extract a file named data.txt

有时我们可能只需要从rar文件中提取单个文件或目录。 这可能是一个备份rar文件,我们只需要一个文件或目录。 我们需要以相对方式指定文件和目录的路径和名称。 在此示例中,我们将提取一个名为data.txt的文件

$ unrar e ans.rar data.txt

Or if the file is locate in the back/files directory we can use following command.

或者,如果文件位于back/files目录中,则可以使用以下命令。

$ unrar e ans.rar back/files/data.txt

保留目录结构 (Preserve Directory Structure)

While taking backups with rar command the absolute directory path can be stored into the rar file. This is useful for the recovery process where we do not need to specify the extract path explicitly. We can use x option in order to preserve the directory structure while extracting. We will use -r as a recursive extract.

使用rar命令进行备份时,绝对目录路径可以存储到rar文件中。 这对于无需显式指定提取路径的恢复过程很有用。 我们可以使用x选项以便在提取时保留目录结构。 我们将使用-r作为递归提取。

$ unrar x -r ans.rar
LEARN MORE  How To Zip, Unzip Files In Linux?
了解更多如何在Linux中压缩,解压缩文件?

翻译自: https://www.poftut.com/list-unrar-rar-files-ubuntu-debian-kali-mint/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值