linux初学者命令行_如何从Linux终端获得命令帮助:面向初学者和专业人士的8个技巧...

linux初学者命令行_如何从Linux终端获得命令帮助:面向初学者和专业人士的8个技巧...

linux初学者命令行

linux初学者命令行_如何从Linux终端获得命令帮助:面向初学者和专业人士的8个技巧...

Whether you’re an inexperienced terminal user or a grizzled veteran, you won’t always know the right thing to type into the Linux terminal. There are quite a few tools built into the terminal to help you along.

无论您是经验不足的终端用户还是经验丰富的老手,您都不会总是知道在Linux终端中键入正确的内容。 终端中内置了许多工具来帮助您。

These tricks will help you find the command to use, figure out how to install it, learn how to use it, and view detailed information about it. None of these tricks require an Internet connection.

这些技巧将帮助您找到要使用的命令,弄清楚如何安装,了解如何使用它以及查看有关该命令的详细信息。 这些技巧都不需要Internet连接。

-h或–help (-h or –help)

If you’re not sure how to use a specific command, run the command with the -h or –help switches. You’ll see usage information and a list of options you can use with the command. For example, if you want to know how to use the wget command, type wget –help or wget -h.

如果不确定如何使用特定命令,请使用-h–help开关运行该命令。 您将看到用法信息以及可与该命令一起使用的选项列表。 例如,如果您想知道如何使用wget命令,请键入wget –helpwget -h

linux初学者命令行_如何从Linux终端获得命令帮助:面向初学者和专业人士的8个技巧...

This will often print a lot of information to the terminal, which can be inconvenient to scroll through. To read the output more easily, you can pipe it through the less command, which allows you to scroll through it with the arrow keys on your keyboard. For example, use the following command to pipe wget’s help output through less:

这通常会向终端打印很多信息,这可能不方便滚动浏览。 要更轻松地读取输出,可以通过less命令传递它,该命令允许您使用键盘上的箭头键在输出中滚动。 例如,使用以下命令通过更少的管道传递wget的帮助输出:

wget –help | less

wget –帮助| 减

linux初学者命令行_如何从Linux终端获得命令帮助:面向初学者和专业人士的8个技巧...

Press q to close the less utility when you’re done.

完成后,按q关闭less实用程序。

To find a specific option, you can pipe the output through the grep command. For example, use the following command to search for options that contain the word “proxy”:

要查找特定选项,可以通过grep命令通过管道传递输出。 例如,使用以下命令搜索包含单词“ proxy”的选项:

wget –help | grep proxy

wget –帮助| grep代理

linux初学者命令行_如何从Linux终端获得命令帮助:面向初学者和专业人士的8个技巧...

制表符完成 (Tab Completion)

If you’re not sure about a specific command’s name, an option, or a file name, you can use tab completion to help. Let’s say we want to run a command that we know starts with gnome-session, but we don’t know its exact name. We can type gnome-session into the terminal and press Tab twice to view commands that match the name.

如果不确定特定命令的名称,选项或文件名,则可以使用制表符补全来提供帮助。 假设我们要运行一个以gnome-session开头的命令,但我们不知道它的确切名称。 我们可以在终端中输入gnome-session ,然后按两次Tab来查看与名称匹配的命令。

linux初学者命令行_如何从Linux终端获得命令帮助:面向初学者和专业人士的8个技巧...

Once we see the command, option, or file name we want, we can type a few more letters and press the Tab key again. If only one match is available, the Bash shell will fill it in for you. Tab completion is also a great way to save on keystrokes, even if you know what you want to type.

看到所需的命令,选项或文件名后,我们可以再输入几个字母,然后再次按Tab键。 如果只有一个匹配项可用,则Bash shell将为您填充它。 即使您知道要输入的内容,制表符补全也是节省击键的一种好方法。

没有找到指令 (Command Not Found)

If you know the command you want to use, but don’t know the package that contains it, you can type the command into the terminal anyway. Ubuntu will tell you the package that contains the command and show you the command you can use to install it.

如果您知道要使用的命令,但不知道包含该命令的软件包,则仍然可以在终端中键入该命令。 Ubuntu将告诉您包含该命令的软件包,并向您显示可用于安装该命令的命令。

Let’s say we wanted to use the rotate command to rotate an image. We could just type rotate into the terminal and Ubuntu would tell us that we have to install the jigl package to get this command.

假设我们要使用rotate命令旋转图像。 我们可以在终端中输入rotate ,然后Ubuntu告诉我们必须安装jigl软件包才能获得此命令。

linux初学者命令行_如何从Linux终端获得命令帮助:面向初学者和专业人士的8个技巧...

This feature was introduced by Ubuntu, and may have made its way into other Linux distributions. Traditionally, the shell displayed an unhelpful “command not found” message without any additional information.

此功能是Ubuntu引入的,可能已被其他Linux发行版使用。 传统上,shell在没有任何其他信息的情况下显示无用的“找不到命令”消息。

救命 (help)

The help command shows a short list of the commands built into the Bash shell itself.

help命令显示了Bash shell本身内置的命令的简短列表。

linux初学者命令行_如何从Linux终端获得命令帮助:面向初学者和专业人士的8个技巧...

男子 (man)

The man command shows detailed manuals for each command. These are referred to as “man pages.” For example, if you wanted to view the man page for the wget command, you’d type man wget. Man pages generally contain much more detailed information than you’ll get with the -h or –help options

man命令显示每个命令的详细手册。 这些被称为“手册页”。 例如,如果要查看wget命令的手册页,则输入man wget 。 手册页通常包含比-h–help选项更详细的信息。

linux初学者命令行_如何从Linux终端获得命令帮助:面向初学者和专业人士的8个技巧...

Type man intro to see a detailed introduction to using the shell on Linux.

输入man intro以查看在Linux上使用Shell的详细介绍。

linux初学者命令行_如何从Linux终端获得命令帮助:面向初学者和专业人士的8个技巧...

To search a man page, type a /, followed by your query, and press Enter. For example, to search a man page for the word shell, type /shell while reading the man page and press Enter.

要搜索手册页,请键入/ ,后跟您的查询,然后按Enter。 例如,要在手册页中搜索单词shell,请在阅读手册页的同时键入/ shell并按Enter。

linux初学者命令行_如何从Linux终端获得命令帮助:面向初学者和专业人士的8个技巧...

信息 (info)

Some programs don’t have man pages – or have very incomplete man pages – and store their documentation as info documents.

有些程序没有手册页,或者手册页非常不完整,并将其文档存储为信息文档。

linux初学者命令行_如何从Linux终端获得命令帮助:面向初学者和专业人士的8个技巧...

To view these, you’ll have to use the info command instead of the man command. That’s info tar instead of man tar.

要查看这些内容,您必须使用info命令而不是man命令。 那是信息tar而不是man tar

linux初学者命令行_如何从Linux终端获得命令帮助:面向初学者和专业人士的8个技巧...

适当的 (apropos)

The apropos command searches for man pages that contain a phrase, so it’s a quick way of finding a command that can do something. It’s the same thing as running the man -k command.

apropos命令搜索包含短语的手册页,因此这是查找可以执行某项命令的快速方法。 这与运行man -k命令相同。

linux初学者命令行_如何从Linux终端获得命令帮助:面向初学者和专业人士的8个技巧...

什么是 (whatis)

The whatis command shows a one-line summary of a command, taken from its man page. It’s a quick way of seeing what a command actually does.

whatis命令显示命令的单行摘要,取自其手册页。 这是查看命令实际作用的快速方法。

linux初学者命令行_如何从Linux终端获得命令帮助:面向初学者和专业人士的8个技巧...


With these tricks under your belt, it’s possible to start using a Linux shell and learn new commands without Googling anything at all. Of course, if you’re at a terminal with an Internet connection, you can use w3m or another text-mode browser to search Google from the terminal.

掌握了这些技巧之后,就可以开始使用Linux Shell并学习新命令,而无需完全使用Googling。 当然,如果您在具有Internet连接的终端上,则可以使用w3m或其他文本模式浏览器从终端上搜索Google。

翻译自: https://www.howtogeek.com/108890/how-to-get-help-with-a-command-from-the-linux-terminal-8-tricks-for-beginners-pros-alike/

linux初学者命令行