如何在Ubuntu 18.04上安装7Zip

如何使用终端在Ubuntu上安装p7zip?
在Ubuntu存储库中,7Zip作为名为p7zip的软件包提供。它也可以在其他基于Linux的系统上通过apt或其他软件包管理器进行安装。首先,让我们更新我们的Ubuntu系统。
sudo apt update

sudo apt install p7zip-full p7zip-rar

在您的终端中执行此操作后,p7zip将作为命令行实用程序7z被安装。以下是7z的语法。
7Zip语法和用法
7z <command> [<switch>...] <base_archive_name> [<arguments>...] [<@listfiles...>]
以下是您可以在7zip中使用的命令和开关,以及它们的含义。
7Zip指令
- a: Add files to archive
- b: Benchmark
- d: Delete files from archive
- e: Extract files from archive (without using directory names)
- l: List contents of the archive
- t: Test integrity of the archive
- u: Update files to archive
- x: Extract files with full paths
7Zip开关
- -ai[r[-|0]]{@listfile|!wildcard}: Include archives
- -ax[r[-|0]]{@listfile|!wildcard}: Exclude archives
- -bd: Disable percentage indicator
- -i[r[-|0]]{@listfile|!wildcard}: Include filenames
- -m{Parameters}: set compression Method
- -o{Directory}: set Output directory
- -p{Password}: set Password
- -r[-|0]: Recurse subdirectories
- -scs{UTF-8 | WIN | DOS}: set charset for list files
- -sfx[{name}]: Create SFX archive
- -si[{name}]: read data from stdin
- -slt: show technical information for l (List) command
- -so: write data to stdout
- -ssc[-]: set sensitive case mode
- -t{Type}: Set type of archive
- -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options
- -v{Size}[b|k|m|g]: Create volumes
- -w[{path}]: assign Work directory. Empty path means a temporary directory
- -x[r[-|0]]]{@listfile|!wildcard}: Exclude filenames
- -y: assume: Yes on all queries
- -an: Disable parsing of archive_name
现在让我们来看一下如何在Ubuntu上使用7Zip。
如何在Ubuntu上使用7Zip?
现在你知道了在Ubuntu上使用7Zip的语法,你可以继续压缩和解压文件了。
1. 使用终端压缩文件
使用7-zip在Ubuntu机器上压缩文件的步骤如下:首先,您需要选择文件或文件夹以创建压缩文件。要这样做,只需使用ls -la命令显示当前目录中所有文件和文件夹的列表。例如,我们将压缩当前大小为50 kb的data.txt文件。
$ ls -la

$ 7z a data.7z data.txt

在这里,选项‘a’是用于存档或压缩的。 data.7z是被压缩文件的文件名。 data.txt是待压缩的文件。压缩之后,压缩文件的大小约为3 kb。这在系统空间上节省了超过90%。太棒了!不是吗?您还可以使用‘l’选项获取有关压缩的详细信息。
$ 7z l data.7z

使用文件资源管理器压缩文件

使用终端解压7Z文件。
以下是您在Ubuntu机器上使用7-zip提取7z文件的步骤:首先,您需要选择要提取文件内容的文件或文件夹。为此,只需使用ls -la命令显示当前目录下所有文件和文件夹的列表。例如,我们将提取data.7z文件的内容。
$ ls -la
现在,要提取任何压缩文件。比如,此案例中的data.7z,您需要输入以下命令:
$ 7z e data.7z

只需将上述命令中的data.7z替换为您的文件名,即可开始运行。
使用文件浏览器解压7Z文件
首先,您需要进入Linux系统上的文件资源管理器。现在,选择您要提取或解压缩的压缩文件,然后右键单击该文件。在这里,从上下文菜单中选择“解压缩”选项。选择文件提取的位置,然后点击“解压缩”按钮即可。就这样!您已成功在Ubuntu系统上提取了压缩文件的内容。
结论 (Jié
7Zip是一款非常流行的软件,用于压缩文件并节省系统空间。我们学会了如何在Ubuntu系统上使用命令行安装7Zip。我们还学会了如何在命令行和文件资源管理器中压缩和提取文件。