如何检查 Linux 中压缩工具是否可用

LinuxLinuxBeginner
立即练习

💡 本教程由 AI 辅助翻译自英文原版。如需查看原文,您可以 切换至英文原版

简介

在这个实验中,你将学习如何检查 Linux 中常见压缩工具的可用性。我们将探讨如何使用 gzipbzip2--version 选项来验证它们是否已安装,并查看它们的版本。

你还将学习如何检查 /usr/bin 目录,以了解包括这些压缩工具在内的许多可执行二进制文件在你的系统上的位置。


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("Linux")) -.-> linux/CompressionandArchivingGroup(["Compression and Archiving"]) linux(("Linux")) -.-> linux/PackagesandSoftwaresGroup(["Packages and Softwares"]) linux(("Linux")) -.-> linux/BasicSystemCommandsGroup(["Basic System Commands"]) linux(("Linux")) -.-> linux/BasicFileOperationsGroup(["Basic File Operations"]) linux/BasicSystemCommandsGroup -.-> linux/help("Command Assistance") linux/BasicFileOperationsGroup -.-> linux/ls("Content Listing") linux/CompressionandArchivingGroup -.-> linux/gzip("Gzip") linux/PackagesandSoftwaresGroup -.-> linux/software("Linux Software") subgraph Lab Skills linux/help -.-> lab-558702{{"如何检查 Linux 中压缩工具是否可用"}} linux/ls -.-> lab-558702{{"如何检查 Linux 中压缩工具是否可用"}} linux/gzip -.-> lab-558702{{"如何检查 Linux 中压缩工具是否可用"}} linux/software -.-> lab-558702{{"如何检查 Linux 中压缩工具是否可用"}} end

使用 gzip --version 检查 gzip

在这一步中,我们将开始探索一些常见的 Linux 实用工具。许多 Linux 系统都自带用于压缩和解压缩文件的工具。其中两个流行的工具是 gzipbzip2

让我们检查 gzip 是否已安装,并查看其版本。我们可以使用 --version 选项来完成此操作。

如果终端尚未打开,请打开它。记住,你可以在桌面左侧找到 Xfce 终端 图标。

输入以下命令并按回车键:

gzip --version

你应该会看到类似以下的输出,这表明 gzip 已安装并显示其版本信息:

gzip (GNU gzip) 1.10
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

确切的版本号可能会有所不同,但此输出的出现证实了 gzip 命令在你的系统上可用。

--version 选项是检查 Linux 中许多命令行工具版本的常用方法。这是一种快速查看程序是否已安装以及你正在使用哪个版本的方法。

点击 继续 以进入下一步。

使用 bzip2 --version 验证 bzip2

在上一步中,我们检查了 gzip 的版本。现在,让我们对另一个常见的压缩实用工具 bzip2 进行同样的操作。

gzip 一样,bzip2 也支持使用 --version 选项来显示其版本信息。

在你的终端中,输入以下命令并按下回车键:

bzip2 --version

你应该会看到类似以下的输出:

bzip2, a block-sorting file compressor.  Version 1.0.8, 13-July-2019.

   Copyright (C) 1996-2019 Julian Seward <[email protected]>.  All rights reserved.

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions
   are met:

   1. Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.

   2. The origin of this software must not be misrepresented; you must
      not claim that you wrote the original software.  If you use this
      software in a product, an acknowledgment in the product
      documentation would be appreciated but is not required.

   This software is provided `as is'', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   arising from the use of this software.

   Julian Seward, Cambridge, UK.
   [email protected]

同样,具体的版本号可能会有所不同,但这个输出确认了 bzip2 已安装并且可以使用。

检查命令的版本是 Linux 中的一项基本技能。它能帮助你确认程序是否已安装,并了解你正在使用的版本,这对于兼容性或故障排除可能很重要。

点击 继续 以继续。

使用 ls /usr/bin 查看二进制文件

在 Linux 中,可执行程序(命令)通常存储在特定的目录中。系统命令的主要存储位置之一是 /usr/bin

让我们使用 ls 命令来列出 /usr/bin 目录的内容。ls 命令用于列出文件和目录。

在你的终端中,输入以下命令并按下回车键:

ls /usr/bin

你会看到一长串的文件列表。这些是系统上可用的许多命令和程序。

[... many lines of output ...]
a2ps
a2query
aa-enabled
aa-exec
aa-status
ab
abcde
abrt-action-analyze-ccpp
abrt-action-analyze-core
abrt-action-analyze-oops
[... many more lines ...]

这个目录包含大量的可执行文件,从像 ls 本身这样的基本实用工具到更复杂的应用程序都有。如果你滚动列表,甚至可能会在其中找到 gzipbzip2

列出像 /usr/bin 这样的目录内容有助于你了解命令的存储位置,并让你对 Linux 文件系统的结构有一个初步的认识。

不必担心理解列表中的每一个文件。这里的目标只是了解许多命令的存放位置。

点击 继续 以完成本实验的这一部分。

总结

在本实验中,我们学习了如何检查常见 Linux 压缩工具的可用性和版本。我们对 gzipbzip2 都使用了 --version 选项,以确认它们已安装并查看其版本信息。这展示了在 Linux 中验证命令行实用工具是否存在以及其版本的标准方法。