翻译完毕 20171117 how to easily remember linux commands.md (#6366)

* translated

* 翻译完毕
This commit is contained in:
DarkSun 2017-11-29 11:15:42 +08:00 committed by Ezio
parent e0615fa11c
commit 738adc3cc8
2 changed files with 74 additions and 126 deletions

View File

@ -1,126 +0,0 @@
translating by darksun
# How to Easily Remember Linux Commands
![](https://www.maketecheasier.com/assets/uploads/2017/10/rc-feat.jpg)
The command line can be daunting for new Linux users. Part of that is
remembering the multitude of commands available. After all, in order to use
the command line effectively, you need to know the commands.
Unfortunately, there's no getting around the fact that you need to learn the
commands, but there are some tools that can help you out when you're getting
started.
## History
![Linux Bash History Commands](https://www.maketecheasier.com/assets/uploads/2017/10/rc-bash-history.jpg)
The first thing you can use to remember commands that you've already used is
your own command line history. Most [Linux shells](https://www.maketecheasier.com/remember-linux-commands/<https:/www.maketecheasier.com/alternative-linux-shells/>), including
the most common default, Bash, create a history file that lists your past
commands. For Bash, you can find it at "/home/<username>/.bash_history."
It's a plain text file, so you can open it in any text editor and loop back
through or even search.
## Apropos
There's actually a command that helps you find _other_ commands. It 's called
"apropos," and it helps you find the appropriate command to complete the
action you search or. For example, if you need to know the command to list the
contents of a directory, you can run the following command:
[code]
apropos "list directory"
[/code]
![Linux Apropos](https://www.maketecheasier.com/assets/uploads/2017/10/rc-apropos.jpg)
There's a catch, though. It's very literal. Add an "s" to "directory," and try
again.
[code]
apropos "list directories"
[/code]
It doesn't work. What `apropos` does is search through a list of commands and
the accompanying descriptions. If your search doesn't match the description,
it won't pick up the command as a result.
There is something else you can do. By using the `-a` flag, you can add
together search terms in a more flexible way. Try this command:
[code]
apropos "match pattern"
[/code]
![Linux Apropos -a Flag](https://www.maketecheasier.com/assets/uploads/2017/10/rc-apropos-a.jpg)
You'd think it'd turn up something, like
[grep](https://www.maketecheasier.com/remember-linux-commands/<https:/www.maketecheasier.com/what-is-grep-and-uses/>)? Instead, you
get nothing. Again, apropos is being too literal. Now, try separating the
words and using the `-a` flag.
[code]
apropos "match" -a "pattern"
[/code]
Suddenly, you have many of the results that you'd expect.
apropos is a great tool, but you always need to be aware of its quirks.
## ZSH
![Linux ZSH
Autocomplete](https://www.maketecheasier.com/assets/uploads/2017/10/rc-
zsh.jpg)![Linux ZSH
Autocomplete](https://www.maketecheasier.com/assets/uploads/2017/10/rc-
zsh.jpg)
ZSH isn't really a tool for remembering commands. It's actually an alternative
shell. You can substitute [ZSH](https://www.maketecheasier.com/remember-linux-
commands/<https:/www.maketecheasier.com/understanding-the-different-shell-in-
linux-zsh-shell/>) for Bash and use it as your command line shell. ZSH
includes an autocorrect feature that catches you if you enter in a command
wrong or misspell something. If you enable it, it'll ask you if you meant
something close. You can continue to use the command line as you normally
would with ZSH, but you get an extra safety net and some other really nice
features, too. The easiest way to get the most of ZSH is with [Oh-My-
ZSH](https://www.maketecheasier.com/remember-linux-commands/<https:/github.com/robbyrussell/oh-my-zsh>).
## Cheat Sheet
The last, and probably simplest, option is to use a [cheat sheet](https://www.maketecheasier.com/remember-linux-commands/<https:/www.maketecheasier.com/premium/cheatsheet/linux-command-line/>). There are plenty available online like [this
one](https://www.maketecheasier.com/remember-linux-commands/<https:/www.cheatography.com/davechild/cheat-sheets/linux-command-line/>) that you can use to look up commands quickly.
![linux-commandline-cheatsheet](https://www.maketecheasier.com/assets/uploads/2013/10/linux-commandline-cheatsheet.gif)
You can actually even find them in image form and set one as your desktop
wallpaper for quick reference.
This isn't the best solution for actually remembering the commands, but when
you're starting out, it can save you from doing a search online every time you
don't remember a command.
Rely on these methods when you're learning, and eventually you'll find
yourself referring to them less and less. No one remembers everything, so
don't feel bad if you occasionally forget or run into something you haven't
seen before. That's what these resources and, of course, the Internet are
there for.
--------------------------------------------------------------------------------
via: https://www.maketecheasier.com/remember-linux-commands/
作者:[Nick Congleton][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,74 @@
# How to Easily Remember Linux Commands
![](https://www.maketecheasier.com/assets/uploads/2017/10/rc-feat.jpg)
Linux 新手往往对命令行心存畏惧。部分原因是因为需要记忆大量的命令。毕竟掌握命令是高效使用命令行的前提。
不幸的是,学习这些命令并无捷径,然而在你开始学习命令之初,有些工具还是可以帮到你的。
## History
![Linux Bash History 命令](https://www.maketecheasier.com/assets/uploads/2017/10/rc-bash-history.jpg)
首先要介绍的是命令行工具 history。它能帮你记住那些你曾经用过的命令。大多数 [Linux shells](https://www.maketecheasier.com/remember-linux-commands/<https:/www.maketecheasier.com/alternative-linux-shells/>),包括应用最广泛的 Bash都会创建一个历史文件来包含那些你输入过的命令。如果你用的是 Bash这个历史文件就是 "/home/<username>/.bash_history"。
这个历史文件是纯文本格式的,你可以用任意的文本编辑器打开来浏览和搜索。
## Apropos
确实存在有一个命令可以帮你找到其他命令。这个命令就是 "apropos",它能帮你找出合适的命令来完成你搜索的操作。比如,假设你需要知道哪个命令可以列出目录的内容,你可以运行下面命令:
```shell
apropos "list directory"
```
![Linux Apropos](https://www.maketecheasier.com/assets/uploads/2017/10/rc-apropos.jpg)
这就搜索出结果了。非常直接。给 "directory" 加上 "s" 后再试一下。
```shell
apropos "list directories"
```
这次没用了。`apropos` 所作的其实就是搜索一系列命令的描述。描述不匹配的命令不会纳入结果中。
还有其他的用法。通过 `-a` 标志,你可以以更灵活的方式来增加搜索关键字。试试这条命令:
```shell
apropos "match pattern"
```
![Linux Apropos -a Flag](https://www.maketecheasier.com/assets/uploads/2017/10/rc-apropos-a.jpg)
你会觉得应该会有一些匹配的内容出现,比如 [grep](https://www.maketecheasier.com/remember-linux-commands/<https:/www.maketecheasier.com/what-is-grep-and-uses/>) 对吗?
然而实际上并没有匹配出任何结果。再说一次apropos 只会根据字面内容进行搜索。
现在让我们试着用 `-a` 标志来把单词分割开来。
```shell
apropos "match" -a "pattern"
```
这一下,你可以看到很多期望的结果了。
apropos 是一个很棒的工具,不过你需要留意它的缺陷。
## ZSH
![Linux ZSH Autocomplete](https://www.maketecheasier.com/assets/uploads/2017/10/rc-zsh.jpg)
ZSH 其实并不是用于记忆命令的工具。它其实是一种 shell。你可以用 [ZSH](https://www.maketecheasier.com/remember-linux-commands/<https:/www.maketecheasier.com/understanding-the-different-shell-in-linux-zsh-shell/>) 来替代 Bash 作为你的命令行 shell。ZSH 包含了自动纠错机制,能在你输入命令的时候给你予提示。
开启该功能后,它会提示你相近的选择想面。在 ZSH 中你可以像往常一样使用命令行,同时你还能享受到极度安全的网络以及其他一些非常好用的特性。充分利用 ZSH 的最简单方法就是使用 [Oh-My-ZSH](https://www.maketecheasier.com/remember-linux-commands/<https:/github.com/robbyrussell/oh-my-zsh>)。
## Cheat Sheet
最后,也可能是最间的方法就是使用 [cheat sheet](https://www.maketecheasier.com/remember-linux-commands/<https:/www.maketecheasier.com/premium/cheatsheet/linux-command-line/>)。
有很多在线的 cheat sheet比如[这个](https://www.maketecheasier.com/remember-linux-commands/<https:/www.cheatography.com/davechild/cheat-sheets/linux-command-line/>) 可以帮助你快速查询命令。
![linux-commandline-cheatsheet](https://www.maketecheasier.com/assets/uploads/2013/10/linux-commandline-cheatsheet.gif)
为了快速查询,你可以寻找图片格式的 cheat sheet 然后将它设置为你的桌面墙纸。
这并不是记忆命令的最好方法,但是这么做可以帮你节省在线搜索遗忘命令的时间。
在学习时依赖这些方法,最终你会发现你会越来越少地使用这些工具。
没有人能够记住所有的事情,因此偶尔遗忘掉某些东西或者遇到某些没有见过的东西也很正常。这也是这些工具以及因特网存在的意义。
--------------------------------------------------------------------------------
via: https://www.maketecheasier.com/remember-linux-commands/
作者:[Nick Congleton][a]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出