Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu.Wang 2019-04-21 09:10:44 +08:00
commit fb34bf478f
33 changed files with 312 additions and 305 deletions

View File

@ -1,28 +1,28 @@
[#]: collector: (lujun9972)
[#]: translator: (Modrisco)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-10752-1.html)
[#]: subject: (Getting started with Vim: The basics)
[#]: via: (https://opensource.com/article/19/3/getting-started-vim)
[#]: author: (Bryant Son (Red Hat, Community Moderator) https://opensource.com/users/brson)
[#]: author: (Bryant Son https://opensource.com/users/brson)
Vim 入门:基础
======
为工作或者新项目学习足够的 Vim 知识。
> 为工作或者新项目学习足够的 Vim 知识。
![Person standing in front of a giant computer screen with numbers, data][1]
我还清晰地记得我第一次接触 Vim 的时候。那时我还是一名大学生,计算机学院的机房里都装着 Ubuntu 系统。尽管我在上大学前也曾接触过不同的 Linux 发行版(比如 RHELRed Hat 在百思买出售它的 CD但这却是我第一次要在日常中频繁使用 Linux 系统,因为我的课程要求我这样做。当我开始使用 Linux 时,正如我的前辈和将来的后继者们一样,我感觉自己像是一名“真正的程序员”了。
我还清晰地记得我第一次接触 Vim 的时候。那时我还是一名大学生,计算机学院的机房里都装着 Ubuntu 系统。尽管我在上大学前也曾接触过不同的 Linux 发行版(比如 RHEL —— Red Hat 在百思买出售它的 CD但这却是我第一次要在日常中频繁使用 Linux 系统,因为我的课程要求我这样做。当我开始使用 Linux 时,正如我的前辈和将来的后继者们一样,我感觉自己像是一名“真正的程序员”了。
![Real Programmers comic][2]
真正的程序员,来自 [xkcd][3]
*真正的程序员,来自 [xkcd][3]*
学生们可以使用像 [Kate][4] 一样的图形文本编辑器,这也安装在学校的电脑上了。对于那些可以使用 shell 但不习惯使用控制台编辑器的学生,最流行的选择是 [Nano][5],它提供了很好的交互式菜单和类似于 Windows 图形文本编辑器的体验。
我有时会用 Nano但当我听说 [Vi/Vim][6] 和 [Emacs][7] 能做一些很棒的事情时我决定试一试它们(主要是因为它们看起来很酷,而且我也很好奇它们有什么特别之处)。第一次使用 Vim 时吓到我了 —— 我不想搞砸任何事情!但是,一旦我掌握了它的诀窍,事情就变得容易得多,我可以欣赏编辑器的强大功能。至于 Emacs我有点放弃了但我很高兴我坚持和 Vim 在一起。
我有时会用 Nano但当我听说 [Vi/Vim][6] 和 [Emacs][7] 能做一些很棒的事情时我决定试一试它们(主要是因为它们看起来很酷,而且我也很好奇它们有什么特别之处)。第一次使用 Vim 时吓到我了 —— 我不想搞砸任何事情!但是,一旦我掌握了它的诀窍,事情就变得容易得多,我可以欣赏这个编辑器的强大功能。至于 Emacs我有点放弃了但我很高兴我坚持和 Vim 在一起。
在本文中,我将介绍一下 Vim基于我的个人经验这样你就可以在 Linux 系统上用它来作为编辑器使用了。这篇文章不会让你变成 Vim 的专家,甚至不会触及 Vim 许多强大功能的皮毛。但是起点总是很重要的,我想让开始的经历尽可能简单,剩下的则由你自己去探索。
@ -40,23 +40,23 @@ Vim 入门:基础
还记得我一开始说过我不敢使用 Vim 吗我当时在害怕“如果我改变了一个现有的文件把事情搞砸了怎么办”毕竟一些计算机科学作业要求我修改现有的文件。我想知道_如何在不保存更改的情况下打开和关闭文件_
好消息是你可以使用相同的命令在 Vim 中创建或打开文件:`vim <FILE_NAME>`,其中 **<FILE_NAME>** 表示要创建或修改的目标文件名。让我们通过输入 `vim HelloWorld.java` 来创建一个名为 `HelloWorld.java` 的文件。
好消息是你可以使用相同的命令在 Vim 中创建或打开文件:`vim <FILE_NAME>`,其中 `<FILE_NAME>` 表示要创建或修改的目标文件名。让我们通过输入 `vim HelloWorld.java` 来创建一个名为 `HelloWorld.java` 的文件。
你好Vim现在讲一下 Vim 中一个非常重要的概念可能也是最需要记住的Vim 有多种模式,下面是 Vim 基础中需要知道的的三种:
模式 | 描述
---|---
正常模式 | 默认模式,用于导航和简单编辑
插入模式 | 用于插入和修改文本
命令模式 | 用于执行如保存,退出等命令
插入模式 | 用于直接插入和修改文本
命令模式 | 用于执行如保存,退出等命令
Vim 也有其他模式,例如可视模式、选择模式和命令模式。不过上面的三种模式对我们来说已经足够了。
Vim 也有其他模式,例如可视模式、选择模式和命令模式。不过上面的三种模式对我们来说已经足够了。
你现在正处于正常模式,如果有文本,你可以用箭头键移动或使用其他导航键(将在稍后看到)。要确定你正处于正常模式,只需按下 `esc` (Escape键即可。
> **提示:** **Esc** 切换到正常模式。即使你已经在正常模式下,点击 **Esc** 只是为了练习。
> **提示** `Esc` 切换到正常模式。即使你已经在正常模式下,点击 `Esc` 只是为了练习。
现在,有趣的事情发生了。输入 `:` (冒号键)并接着 `q!` (完整命令:`:q!`)。你的屏幕将显示如下:
现在,有趣的事情发生了。输入 `:` (冒号键)并接着 `q!` (完整命令:`:q!`。你的屏幕将显示如下:
![Editing Vim][9]
@ -68,7 +68,7 @@ Vim 也有其他模式,例如可视模式、选择模式和命令模式。不
通过输入 `vim HelloWorld.java` 和回车键来再次打开这个文件。你可以在插入模式中修改文件。首先,通过 `Esc` 键来确定你正处于正常模式。接着输入 `i` 来进入插入模式(没错,就是字母 **i**)。
在左下角,你将看到 `\-- INSERT --`,这标志着你这处于插入模式。
在左下角,你将看到 `-- INSERT --`,这标志着你这处于插入模式。
![Vim insert mode][10]
@ -80,9 +80,10 @@ public class HelloWorld {
}
}
```
非常漂亮!注意文本是如何在 Java 语法中高亮显示的。因为这是个 Java 文件,所以 Vim 将自动检测语法并高亮颜色。
保存文件:按下 `Esc` 来退出插入模式并进入命令模式。输入 `:` 并接着 `x!` (完整命令:`:x!`),按回车键来保存文件。你也可以输入 `wq` 来执行相同的操作。
保存文件:按下 `Esc` 来退出插入模式并进入命令模式。输入 `:` 并接着 `x!` (完整命令:`:x!`,按回车键来保存文件。你也可以输入 `wq` 来执行相同的操作。
现在,你知道了如何使用插入模式输入文本并使用以下命令保存文件:`:x!` 或者 `:wq`
@ -96,7 +97,7 @@ public class HelloWorld {
![Showing Line Numbers][12]
好,你也许会说,“这确实很酷,不过我该怎么跳到某一行呢?”再一次的,确认你正处于正常模式。接着输入 `: <LINE_NUMBER>`,在这里 **< LINE_NUMBER>** 是你想去的那一行的行数。按下回车键来试着移动到第二行。
好,你也许会说,“这确实很酷,不过我该怎么跳到某一行呢?”再一次的,确认你正处于正常模式。接着输入 `:<LINE_NUMBER>`,在这里 `<LINE_NUMBER>` 是你想去的那一行的行数。按下回车键来试着移动到第二行。
```
:2
@ -116,17 +117,17 @@ public class HelloWorld {
你现在来到这行的最后一个字节了。在此示例中,高亮左大括号以显示光标移动到的位置,右大括号被高亮是因为它是高亮的左大括号的匹配字符。
这就是 Vim 中的基本导航功能。等等,别急着退出文件。让我们转到 Vim 中的基本编辑。不过,你可以暂时便喝杯咖啡或茶休息一下。
这就是 Vim 中的基本导航功能。等等,别急着退出文件。让我们转到 Vim 中的基本编辑。不过,你可以暂时便喝杯咖啡或茶休息一下。
### 第 4 步Vim 中的基本编辑
现在,你已经知道如何通过跳到想要的一行来在文件中导航,你可以使用这个技能在 Vim 中进行一些基本编辑。切换到插入模式。(还记得怎么做吗?是不是输入 `i` ?)当然,你可以使用键盘逐一删除或插入字符来进行编辑,但是 Vim 提供了更快捷的方法来编辑文件。
来到第三行,这里的代码是 **public static void main(String[] args) {**。双击 `d` 键,没错,就是 `dd`。如果你成功做到了,你将会看到,第三行消失了,剩下的所有行都向上移动了一行。(例如,第四行变成了第三行)。
来到第三行,这里的代码是 `public static void main(String[] args) {`。双击 `d` 键,没错,就是 `dd`。如果你成功做到了,你将会看到,第三行消失了,剩下的所有行都向上移动了一行。(例如,第四行变成了第三行)。
![Deleting A Line][15]
这就是 _删除_delete 命令。不要担心,键入 `u`,你会发现这一行又回来了。喔,这就是 _撤销_undo 命令。
这就是<ruby>删除<rt>delete</rt></ruby>命令。不要担心,键入 `u`,你会发现这一行又回来了。喔,这就是<ruby>撤销<rt>undo</rt></ruby>命令。
![Undoing a change in Vim][16]
@ -134,7 +135,7 @@ public class HelloWorld {
![Highlighting text in Vim][17]
来到第四行,这里的代码是 **System.out.println("Hello, Opensource");**。高亮这一行的所有内容。好了吗?当第四行的内容处于高亮时,按下 `y`。这就叫做 _复制_yank模式,文本将会被复制到剪贴板上。接下来,输入 `o` 来创建新的一行。注意,这将让你进入插入模式。通过按 `Esc` 退出插入模式,然后按下 `p`,代表 _粘贴_。这将把复制的文本从第三行粘贴到第四行。
来到第四行,这里的代码是 `System.out.println("Hello, Opensource");`。高亮这一行的所有内容。好了吗?当第四行的内容处于高亮时,按下 `y`。这就叫做<ruby>复制<rt>yank</rt></ruby>模式,文本将会被复制到剪贴板上。接下来,输入 `o` 来创建新的一行。注意,这将让你进入插入模式。通过按 `Esc` 退出插入模式,然后按下 `p`,代表<ruby>粘贴<rt>paste</rt></ruby>。这将把复制的文本从第三行粘贴到第四行。
![Pasting in Vim][18]
@ -148,50 +149,50 @@ public class HelloWorld {
假设你的团队领导希望你更改项目中的文本字符串。你该如何快速完成任务?你可能希望使用某个关键字来搜索该行。
Vim 的搜索功能非常有用。通过 `Esc` 键来进入命令模式,然后输入冒号 `:`,我们可以通过输入 `/ <SEARCH_KEYWORD>` 来搜索关键词, **< SEARCH_KEYWORD>** 指你希望搜索的字符串。在这里,我们搜索关键字符串 “Hello”。在面的图示中缺少冒号但这是必需的。
Vim 的搜索功能非常有用。通过 `Esc` 键来进入命令模式,然后输入冒号 `:`,我们可以通过输入 `/<SEARCH_KEYWORD>` 来搜索关键词, `<SEARCH_KEYWORD>` 指你希望搜索的字符串。在这里,我们搜索关键字符串 `Hello`。在下面的图示中没有显示冒号,但这是必须输入的。
![Searching in Vim][19]
但是,一个关键字可以出现不止一次,而这可能不是你想要的那一个。那么,如何找到下一个匹配项呢?只需按 `n` 键即可,这代表 _下一个_next。执行此操作时,请确保你没有处于插入模式!
但是,一个关键字可以出现不止一次,而这可能不是你想要的那一个。那么,如何找到下一个匹配项呢?只需按 `n` 键即可,这代表<ruby>下一个<rt>next</rt></ruby>。执行此操作时,请确保你没有处于插入模式!
### 附加步骤Vim中的分割模式
### 附加步骤Vim 中的分割模式
以上几乎涵盖了所有的 Vim 基础知识。但是,作为一个额外奖励,我想给你展示 Vim 一个很酷的特性,叫做 _分割_split模式。
以上几乎涵盖了所有的 Vim 基础知识。但是,作为一个额外奖励,我想给你展示 Vim 一个很酷的特性,叫做<ruby>分割<rt>split</rt></ruby>模式。
退出 _HelloWorld.java_ 并创建一个新文件。在控制台窗口中,输入 `vim GoodBye.java` 并按回车键来创建一个名为 _GoodBye.java_ 的新文件。
退出 `HelloWorld.java` 并创建一个新文件。在控制台窗口中,输入 `vim GoodBye.java` 并按回车键来创建一个名为 `GoodBye.java` 的新文件。
输入任何你想输入的让内容,我选择输入“Goodbye”。保存文件(记住你可以在命令模式中使用 `:x!` 或者 `:wq`)。
输入任何你想输入的让内容,我选择输入 `Goodbye`。保存文件(记住你可以在命令模式中使用 `:x!` 或者 `:wq`)。
在命令模式中,输入 `:split HelloWorld.java`,来看看发生了什么。
![Split mode in Vim][20]
Wow快看**split** 命令将控制台窗口水平分割成了两个部分,上面是 _HelloWorld.java_,下面是 _GoodBye.java_。该怎么能在窗口之间切换呢?按住 `Control` 键 (在 Mac 上)或 `Ctrl`在PC上),然后按下 `ww` (即双击 `w` 键)。
Wow快看 `split` 命令将控制台窗口水平分割成了两个部分,上面是 `HelloWorld.java`,下面是 `GoodBye.java`。该怎么能在窗口之间切换呢? 按住 `Control` 键(在 Mac 上)或 `Ctrl` 键(在 PC 上),然后按下 `ww` (即双击 `w` 键)。
作为最后一个练习,尝试通过复制和粘贴 _HelloWorld.java_ 来编辑 _GoodBye.java_ 以匹配下面屏幕上的内容。
作为最后一个练习,尝试通过复制和粘贴 `HelloWorld.java` 来编辑 `GoodBye.java` 以匹配下面屏幕上的内容。
![Modify GoodBye.java file in Split Mode][21]
保存两份文件,成功!
> **提示 1:** 如果你想将两个文件窗口垂直分割,使用 `:vsplit <FILE_NAME>` 命令。(代替 `:split <FILE_NAME>` 命令,**< FILE_NAME>** 指你想要使用分割模式打开的文件名)。
> **提示 1** 如果你想将两个文件窗口垂直分割,使用 `:vsplit <FILE_NAME>` 命令。(代替 `:split <FILE_NAME>` 命令,`<FILE_NAME>` 指你想要使用分割模式打开的文件名)。
>
> **提示 2:** 你可以通过调用任意数量的 **split** 或者 **vsplit** 命令来打开两个以上的文件。试一试,看看它效果如何。
> **提示 2** 你可以通过调用任意数量的 `split` 或者 `vsplit` 命令来打开两个以上的文件。试一试,看看它效果如何。
### Vim 速查表
在本文中,您学会了如何使用 Vim 来完成工作或项目。但这只是你开启 Vim 强大功能之旅的开始。请务必在 Opensource.com 上查看其他很棒的教程和技巧。
在本文中,您学会了如何使用 Vim 来完成工作或项目,但这只是你开启 Vim 强大功能之旅的开始,可以查看其他很棒的教程和技巧。
为了让一切变得简单些,我已经将你学到的一切总结到了 [a handy cheat sheet][22] 中。
为了让一切变得简单些,我已经将你学到的一切总结到了 [一份方便的速查表][22] 中。
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/3/getting-started-vim
作者:[Bryant Son (Red Hat, Community Moderator)][a]
作者:[Bryant Son][a]
选题:[lujun9972][b]
译者:[Modrisco](https://github.com/Modrisco)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (5 projects for Raspberry Pi at home)
[#]: via: (https://opensource.com/article/17/4/5-projects-raspberry-pi-home)
[#]: author: (Ben Nuttall (Community Moderator) )
[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall)
5 projects for Raspberry Pi at home
======
@ -100,14 +100,14 @@ Let us know in the comments.
via: https://opensource.com/article/17/4/5-projects-raspberry-pi-home
作者:[Ben Nuttall (Community Moderator)][a]
作者:[Ben Nuttall][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:
[a]: https://opensource.com/users/bennuttall
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberry_pi_home_automation.png?itok=2TnmJpD8 (5 projects for Raspberry Pi at home)
[2]: https://www.raspberrypi.org/

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (jdh8383)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (How to create portable documents with CBZ and DjVu)
[#]: via: (https://opensource.com/article/19/3/comic-book-archive-djvu)
[#]: author: (Seth Kenlon (Red Hat, Community Moderator) https://opensource.com/users/seth)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
How to create portable documents with CBZ and DjVu
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (How to set up a homelab from hardware to firewall)
[#]: via: (https://opensource.com/article/19/3/home-lab)
[#]: author: (Michael Zamot (Red Hat) https://opensource.com/users/mzamot)
[#]: author: (Michael Zamot https://opensource.com/users/mzamot)
How to set up a homelab from hardware to firewall
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (Choosing an open messenger client: Alternatives to WhatsApp)
[#]: via: (https://opensource.com/article/19/3/open-messenger-client)
[#]: author: (Chris Hermansen (Community Moderator) https://opensource.com/users/clhermansen)
[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen)
Choosing an open messenger client: Alternatives to WhatsApp
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (Getting started with Jaeger to build an Istio service mesh)
[#]: via: (https://opensource.com/article/19/3/getting-started-jaeger)
[#]: author: (Daniel Oh (Red Hat) https://opensource.com/users/daniel-oh)
[#]: author: (Daniel Oh https://opensource.com/users/daniel-oh)
Getting started with Jaeger to build an Istio service mesh
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (How to use Spark SQL: A hands-on tutorial)
[#]: via: (https://opensource.com/article/19/3/apache-spark-and-dataframes-tutorial)
[#]: author: (Dipanjan (DJ) Sarkar (Red Hat) https://opensource.com/users/djsarkar)
[#]: author: (Dipanjan Sarkar https://opensource.com/users/djsarkar)
How to use Spark SQL: A hands-on tutorial
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (12 open source tools for natural language processing)
[#]: via: (https://opensource.com/article/19/3/natural-language-processing-tools)
[#]: author: (Dan Barker (Community Moderator) https://opensource.com/users/barkerd427)
[#]: author: (Dan Barker https://opensource.com/users/barkerd427)
12 open source tools for natural language processing
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (How to use NetBSD on a Raspberry Pi)
[#]: via: (https://opensource.com/article/19/3/netbsd-raspberry-pi)
[#]: author: (Seth Kenlon (Red Hat, Community Moderator) https://opensource.com/users/seth)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
How to use NetBSD on a Raspberry Pi
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (How to submit a bug report with Bugzilla)
[#]: via: (https://opensource.com/article/19/3/bug-reporting)
[#]: author: (David Both (Community Moderator) https://opensource.com/users/dboth)
[#]: author: (David Both https://opensource.com/users/dboth)
How to submit a bug report with Bugzilla
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (Build and host a website with Git)
[#]: via: (https://opensource.com/article/19/4/building-hosting-website-git)
[#]: author: (Seth Kenlon (Red Hat, Community Moderator) https://opensource.com/users/seth)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Build and host a website with Git
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (Manage your daily schedule with Git)
[#]: via: (https://opensource.com/article/19/4/calendar-git)
[#]: author: (Seth Kenlon (Red Hat, Community Moderator) https://opensource.com/users/seth)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Manage your daily schedule with Git
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (Use Git as the backend for chat)
[#]: via: (https://opensource.com/article/19/4/git-based-chat)
[#]: author: (Seth Kenlon (Red Hat, Community Moderator) https://opensource.com/users/seth)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Use Git as the backend for chat
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (File sharing with Git)
[#]: via: (https://opensource.com/article/19/4/file-sharing-git)
[#]: author: (Seth Kenlon (Red Hat, Community Moderator) https://opensource.com/users/seth)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
File sharing with Git
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (Run a server with Git)
[#]: via: (https://opensource.com/article/19/4/server-administration-git)
[#]: author: (Seth Kenlon (Red Hat, Community Moderator) https://opensource.com/users/seth/users/seth)
[#]: author: (Seth Kenlon https://opensource.com/users/seth/users/seth)
Run a server with Git
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (Manage multimedia files with Git)
[#]: via: (https://opensource.com/article/19/4/manage-multimedia-files-git)
[#]: author: (Seth Kenlon (Red Hat, Community Moderator) https://opensource.com/users/seth)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Manage multimedia files with Git
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (A beginner's guide to building DevOps pipelines with open source tools)
[#]: via: (https://opensource.com/article/19/4/devops-pipeline)
[#]: author: (Bryant Son (Red Hat, Community Moderator) https://opensource.com/users/brson/users/milindsingh/users/milindsingh/users/dscripter)
[#]: author: (Bryant Son https://opensource.com/users/brson/users/milindsingh/users/milindsingh/users/dscripter)
A beginner's guide to building DevOps pipelines with open source tools
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (Getting started with Python's cryptography library)
[#]: via: (https://opensource.com/article/19/4/cryptography-python)
[#]: author: (Moshe Zadka (Community Moderator) https://opensource.com/users/moshez)
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
Getting started with Python's cryptography library
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (5 Linux rookie mistakes)
[#]: via: (https://opensource.com/article/19/4/linux-rookie-mistakes)
[#]: author: (Jen Wike Huger (Red Hat) https://opensource.com/users/jen-wike/users/bcotton/users/petercheer/users/greg-p/users/greg-p)
[#]: author: (Jen Wike Huger https://opensource.com/users/jen-wike/users/bcotton/users/petercheer/users/greg-p/users/greg-p)
5 Linux rookie mistakes
======

View File

@ -1,11 +1,11 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (fuzheng1998 )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (5 open source mobile apps)
[#]: via: (https://opensource.com/article/19/4/mobile-apps)
[#]: author: (Chris Hermansen (Community Moderator) https://opensource.com/users/clhermansen/users/bcotton/users/clhermansen/users/bcotton/users/clhermansen)
[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen/users/bcotton/users/clhermansen/users/bcotton/users/clhermansen)
5 open source mobile apps
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (How to enable serverless computing in Kubernetes)
[#]: via: (https://opensource.com/article/19/4/enabling-serverless-kubernetes)
[#]: author: (Daniel Oh (Red Hat, Community Moderator) https://opensource.com/users/daniel-oh/users/daniel-oh)
[#]: author: (Daniel Oh https://opensource.com/users/daniel-oh/users/daniel-oh)
How to enable serverless computing in Kubernetes
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (Be your own certificate authority)
[#]: via: (https://opensource.com/article/19/4/certificate-authority)
[#]: author: (Moshe Zadka (Community Moderator) https://opensource.com/users/moshez/users/elenajon123)
[#]: author: (Moshe Zadka https://opensource.com/users/moshez/users/elenajon123)
Be your own certificate authority
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (How do you contribute to open source without code?)
[#]: via: (https://opensource.com/article/19/4/contribute-without-code)
[#]: author: (Chris Hermansen (Community Moderator) https://opensource.com/users/clhermansen/users/don-watkins/users/greg-p/users/petercheer)
[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen/users/don-watkins/users/greg-p/users/petercheer)
How do you contribute to open source without code?
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (Managed, enabled, empowered: 3 dimensions of leadership in an open organization)
[#]: via: (https://opensource.com/open-organization/19/4/managed-enabled-empowered)
[#]: author: (Heidi Hess von Ludewig (Red Hat) https://opensource.com/users/heidi-hess-von-ludewig/users/amatlack)
[#]: author: (Heidi Hess von Ludewig https://opensource.com/users/heidi-hess-von-ludewig/users/amatlack)
Managed, enabled, empowered: 3 dimensions of leadership in an open organization
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (Testing Small Scale Scrum in the real world)
[#]: via: (https://opensource.com/article/19/4/next-steps-small-scale-scrum)
[#]: author: (Agnieszka Gancarczyk (Red Hat)Leigh Griffin (Red Hat) https://opensource.com/users/agagancarczyk/users/lgriffin/users/agagancarczyk/users/lgriffin)
[#]: author: (Agnieszka Gancarczyk Leigh Griffin https://opensource.com/users/agagancarczyk/users/lgriffin/users/agagancarczyk/users/lgriffin)
Testing Small Scale Scrum in the real world
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (How libraries are adopting open source)
[#]: via: (https://opensource.com/article/19/4/software-libraries)
[#]: author: (Don Watkins (Community Moderator) https://opensource.com/users/don-watkins)
[#]: author: (Don Watkins https://opensource.com/users/don-watkins)
How libraries are adopting open source
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (Blender short film, new license for Chef, ethics in open source, and more news)
[#]: via: (https://opensource.com/article/15/4/news-april-15)
[#]: author: (Joshua Allen Holm (Community Moderator) https://opensource.com/users/holmja)
[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja)
Blender short film, new license for Chef, ethics in open source, and more news
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (Getting started with Mercurial for version control)
[#]: via: (https://opensource.com/article/19/4/getting-started-mercurial)
[#]: author: (Moshe Zadka (Community Moderator) https://opensource.com/users/moshez)
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
Getting started with Mercurial for version control
======

View File

@ -5,7 +5,7 @@
[#]: url: ( )
[#]: subject: (Detecting malaria with deep learning)
[#]: via: (https://opensource.com/article/19/4/detecting-malaria-deep-learning)
[#]: author: (Dipanjan (DJ) Sarkar (Red Hat) https://opensource.com/users/djsarkar)
[#]: author: (Dipanjan Sarkar https://opensource.com/users/djsarkar)
Detecting malaria with deep learning
======

View File

@ -1,238 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (arrowfeng)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Install MySQL in Ubuntu Linux)
[#]: via: (https://itsfoss.com/install-mysql-ubuntu/)
[#]: author: (Sergiu https://itsfoss.com/author/sergiu/)
How to Install MySQL in Ubuntu Linux
======
_**Brief: This tutorial teaches you to install MySQL in Ubuntu based Linux distributions. Youll also learn how to verify your install and how to connect to MySQL for the first time.**_
**[MySQL][1]** is the quintessential database management system. It is used in many tech stacks, including the popular **[LAMP][2]** (Linux, Apache, MySQL, PHP) stack. It has proven its stability. Another thing that makes **MySQL** so great is that it is **open-source**.
**MySQL** uses **relational databases** (basically **tabular data** ). It is really easy to store, organize and access data this way. For managing data, **SQL** ( **Structured Query Language** ) is used.
In this article Ill show you how to **install** and **use** MySQL 8.0 in Ubuntu 18.04. Lets get to it!
### Installing MySQL in Ubuntu
![][3]
Ill be covering two ways you can install **MySQL** in Ubuntu 18.04:
1. Install MySQL from the Ubuntu repositories. Very basic, not the latest version (5.7)
2. Install MySQL using the official repository. There is a bigger step that youll have to add to the process, but nothing to worry about. Also, youll have the latest version (8.0)
When needed, Ill provide screenshots to guide you. For most of this guide, Ill be entering commands in the **terminal** ( **default hotkey** : CTRL+ALT+T). Dont be scared of it!
#### Method 1. Installing MySQL from the Ubuntu repositories
First of all, make sure your repositories are updated by entering:
```
sudo apt update
```
Now, to install **MySQL 5.7** , simply type:
```
sudo apt install mysql-server -y
```
Thats it! Simple and efficient.
#### Method 2. Installing MySQL using the official repository
Although this method has a few more steps, Ill go through them one by one and Ill try writing down clear notes.
The first step is browsing to the [download page][4] of the official MySQL website.
![][5]
Here, go down to the **download link** for the **DEB Package**.
![][6]
Scroll down past the info about Oracle Web and right-click on **No thanks, just start my download.** Select **Copy link location**.
Now go back to the terminal. Well [use][7] **[Curl][7]** [command][7] to the download the package:
```
curl -OL https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb
```
**<https://dev.mysql.com/get/mysql-apt-config\_0.8.12-1\_all.deb>** is the link I copied from the website. It might be different based on the current version of MySQL. Lets use **dpkg** to start installing MySQL:
```
sudo dpkg -i mysql-apt-config*
```
Update your repositories:
```
sudo apt update
```
To actually install MySQL, well use the same command as in the first method:
```
sudo apt install mysql-server -y
```
Doing so will open a prompt in your terminal for **package configuration**. Use the **down arrow** to select the **Ok** option.
![][8]
Press **Enter**. This should prompt you to enter a **password** :. Your are basically setting the root password for MySQL. Dont confuse it with [root password of Ubuntu][9] system.
![][10]
Type in a password and press **Tab** to select **< Ok>**. Press **Enter.** Youll now have to **re-enter** the **password**. After doing so, press **Tab** again to select **< Ok>**. Press **Enter**.
![][11]
Some **information** on configuring MySQL Server will be presented. Press **Tab** to select **< Ok>** and **Enter** again:
![][12]
Here you need to choose a **default authentication plugin**. Make sure **Use Strong Password Encryption** is selected. Press **Tab** and then **Enter**.
Thats it! You have successfully installed MySQL.
#### Verify your MySQL installation
To **verify** that MySQL installed correctly, use:
```
sudo systemctl status mysql.service
```
This will show some information about the service:
![][13]
You should see **Active: active (running)** in there somewhere. If you dont, use the following command to start the **service** :
```
sudo systemctl start mysql.service
```
#### Configuring/Securing MySQL
For a new install, you should run the provided command for security-related updates. Thats:
```
sudo mysql_secure_installation
```
Doing so will first of all ask you if you want to use the **VALIDATE PASSWORD COMPONENT**. If you want to use it, youll have to select a minimum password strength ( **0 Low, 1 Medium, 2 High** ). You wont be able to input any password doesnt respect the selected rules. If you dont have the habit of using strong passwords (you should!), this could come in handy. If you think it might help, type in **y** or **Y** and press **Enter** , then choose a **strength level** for your password and input the one you want to use. If successful, youll continue the **securing** process; otherwise youll have to re-enter a password.
If, however, you do not want this feature (I wont), just press **Enter** or **any other key** to skip using it.
For the other options, I suggest **enabling** them (typing in **y** or **Y** and pressing **Enter** for each of them). They are (in this order): **remove anonymous user, disallow root login remotely, remove test database and access to it, reload privilege tables now**.
#### Connecting to & Disconnecting from the MySQL Server
To be able to run SQL queries, youll first have to connect to the server using MySQL and use the MySQL prompt. The command for doing this is:
```
mysql -h host_name -u user -p
```
* **-h** is used to specify a **host name** (if the server is located on another machine; if it isnt, just omit it)
* **-u** mentions the **user**
* **-p** specifies that you want to input a **password**.
Although not recommended (for safety reasons), you can enter the password directly in the command by typing it in right after **-p**. For example, if the password for **test_user** is **1234** and you are trying to connect on the machine you are using, you could use:
```
mysql -u test_user -p1234
```
If you successfully inputted the required parameters, youll be greeted by the **MySQL shell prompt** ( **mysql >**):
![][14]
To **disconnect** from the server and **leave** the mysql prompt, type:
```
QUIT
```
Typing **quit** (MySQL is case insensitive) or **\q** will also work. Press **Enter** to exit.
You can also output info about the **version** with a simple command:
```
sudo mysqladmin -u root version -p
```
If you want to see a **list of options** , use:
```
mysql --help
```
#### Uninstalling MySQL
If you decide that you want to use a newer release or just want to stop using MySQL.
First, disable the service:
```
sudo systemctl stop mysql.service && sudo systemctl disable mysql.service
```
Make sure you backed up your databases, in case you want to use them later on. You can uninstall MySQL by running:
```
sudo apt purge mysql*
```
To clean up dependecies:
```
sudo apt autoremove
```
**Wrapping Up**
In this article, Ive covered **installing MySQL** in Ubuntu Linux. Id be glad if this guide helps struggling users and beginners.
Tell us in the comments if you found this post to be a useful resource. What do you use MySQL for? Were eager to receive any feedback, impressions or suggestions. Thanks for reading and have dont hesitate to experiment with this incredible tool!
--------------------------------------------------------------------------------
via: https://itsfoss.com/install-mysql-ubuntu/
作者:[Sergiu][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/sergiu/
[b]: https://github.com/lujun9972
[1]: https://www.mysql.com/
[2]: https://en.wikipedia.org/wiki/LAMP_(software_bundle)
[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/04/install-mysql-ubuntu.png?resize=800%2C450&ssl=1
[4]: https://dev.mysql.com/downloads/repo/apt/
[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/04/mysql_apt_download_page.jpg?fit=800%2C280&ssl=1
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/04/mysql_deb_download_link.jpg?fit=800%2C507&ssl=1
[7]: https://linuxhandbook.com/curl-command-examples/
[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/04/mysql_package_configuration_ok.jpg?fit=800%2C587&ssl=1
[9]: https://itsfoss.com/change-password-ubuntu/
[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/04/mysql_enter_password.jpg?fit=800%2C583&ssl=1
[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/04/mysql_information_on_configuring.jpg?fit=800%2C581&ssl=1
[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/04/mysql_default_authentication_plugin.jpg?fit=800%2C586&ssl=1
[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/04/mysql_service_information.jpg?fit=800%2C402&ssl=1
[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/04/mysql_shell_prompt-2.jpg?fit=800%2C423&ssl=1

View File

@ -0,0 +1,244 @@
[#]: collector: (lujun9972)
[#]: translator: (arrowfeng)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Install MySQL in Ubuntu Linux)
[#]: via: (https://itsfoss.com/install-mysql-ubuntu/)
[#]: author: (Sergiu https://itsfoss.com/author/sergiu/)
怎样在Ubuntu Linux上安装MySQL
======
_**简要: 本教程教你如何在基于Ubuntu的Linux发行版上安装MySQL。对于首次使用的用户你将会学习到如何验证你的安装和第一次怎样去连接MySQL。**_
**[MySQL][1]** 是一个典型的数据库管理系统。它被用于许多技术栈中,包括流行的 **[LAMP][2]** (Linux, Apache, MySQL, PHP) 技术栈. 它已经被证实了其稳定性。 另一个让**MySQL**受欢迎的原因是它是开源的。
**MySQL** 是 **关系型数据库** (基本上是 **表格 数据** ). 以这种方式它很容易去存储,组织和访问数据。它使用**SQL**( **结构化查询语言** )来管理数据。
这这篇文章中我将向你展示如何在Ubuntu 18.04安装和使用MySQL 8.0。让我们一起来看看吧!
### 在Ubuntu上安装MySQL
![][3]
我将会介绍两种在Ubuntu18.04上安装**MySQL**的方法:
1. 从Ubuntu仓库上安装MySQL。非常简单但不是最新版5.7
2. 从官方仓库安装MySQL。你将额外增加一些步处理过程但不用担心。你将会拥有最新版的MySQL8.0
有必要的时候,我将会提供屏幕截图去引导你。但这边文章中的大部分步骤,我将直接在**终端****默认热键**: CTRL+ALT+T输入命令。别害怕它
#### 方法 1. 从Ubuntu仓库安装MySQL
首先,输入下列命令确保你的仓库已经被更新:
```
sudo apt update
```
现在, 安装 **MySQL 5.7** , 简单输入下列命令:
```
sudo apt install mysql-server -y
```
就是这样!简单且高效。
#### 方法 2. 使用官方仓库安装MySQL
虽然这个方法多了一些步骤,但我将逐一介绍,并尝试写下清晰的笔记。
首先浏览官方的MySQL网站[download page][4]。
![][5]
在这,选择**DEB Package**点击**download link**。
![][6]
滑到有关于Oracle网站信息的底部右键 **No thanks, just start my download.** ,然后选择 **Copy link location**
现在回到终端,我们将使用 **[Curl][7]** 命令去下载这个软件包:
Now go back to the terminal. Well [use][7] **[Curl][7]** [command][7] to the download the package:
```
curl -OL https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb
```
**<https://dev.mysql.com/get/mysql-apt-config\_0.8.12-1\_all.deb>** 是我刚刚从网页上复制的链接。根据当前的MySQL版本它有可能不同。让我们使用**dpkg**去开始安装MySQL
```
sudo dpkg -i mysql-apt-config*
```
更新你的仓库:
```
sudo apt update
```
要实际安装MySQL,我们将使用像第一个方法中同样的命令来安装:
```
sudo apt install mysql-server -y
```
这样做会在你的终端中打开**包配置**的提示。使用**向下箭头**选择 **Ok**选项。
![][8]
点击 **Enter**.这应该会提示你输入**password**你的基本上是在为MySQL设置root密码。不要与[Ubuntu的root密码混淆][9]。
![][10]
输入密码然后点击**Tab**键去选择 **< Ok>**.点击**Enter**键,你将**重新输入** **password**。操作完之后,再次键入**Tab**去选择 **< Ok>**。按下**Enter**键。
![][11]
一些关于MySQL Server的配置信息将会展示。再次按下**Tab**去选择 **< Ok>** 和按下 **Enter**键:
![][12]
这里你需要去选择**default authentication plugin**。确保**Use Strong Password Encryption**被选择。按下**Tab**键和**Enter**键。
就是这样你已经成功地安装了MySQL。
#### 验证你的MySQL安装
要验证MySQL已经正确安装使用下列命令
```
sudo systemctl status mysql.service
```
这将展示一些关于MySQL服务的信息
![][13]
你应该在那里看到 **Active: active (running)** 。如果你没有看到,使用下列命令去开始这个 **service**
```
sudo systemctl start mysql.service
```
#### 配置/保护 MySQL
对于刚安装的MySQL你应该运行它提供的安全相关的更新命令。就是
```
sudo mysql_secure_installation
```
这样做首先会询问你是否想使用**VALIDATE PASSWORD COMPONENT**.如果你想使用它,你将不得不去选择一个最小密码强度( **0 Low, 1 Medium, 2 High** )。你将无法输入任何不遵守所选规则的密码。如果你没有使用强密码的习惯(本应该使用),这可能会配上用场。如果你认为它可能有帮助,那你就键入**y** 或者 **Y**,按下**Enter**键,然后为你的密码选择一个**强度等级**和输入一个你想使用的。如果成功,你将继续**securing**过程;否则你将重新输入一个密码。
但是,如果你不想要此功能(我不会),只需按**Enter**或**任何其他键**即可跳过使用它。
对于其他选项,我建议**开启**他们(对于每一步输入**y** 或者 **Y** 和按下**Enter**)。他们是(以这样的顺序):**remove anonymous user, disallow root login remotely, remove test database and access to it, reload privilege tables now**.
MySQL Server上
#### 链接与断开MySQL Server
为了去运行SQL查询你首先不得不使用MySQL链接到MySQL服务并使用MySQL提示符。
To be able to run SQL queries, youll first have to connect to the server using MySQL and use the MySQL prompt. 执行此操作的命令是:
```
mysql -h host_name -u user -p
```
* **-h** 被用来指定一个 **主机名** (如果这个服务被安装到其他机器上,那么会有用;如果没有,忽略它)
* **-u** 指定登录的 **用户**
* **-p** 指定你想输入的 **密码**.
你能通过在最右边输入 **-p**后直接输入密码在命令行,但这样做是不建议的(为了安全原因),如果用户**test_user** 的密码是**1234**那么你可以尝试去连接你正在使用的机器上的mysql你应该这样使用
```
mysql -u test_user -p1234
```
如果你成功输入了必要的参数,你将会收到由**MySQL shell 提示符**提供的欢迎( **mysql >**
![][14]
要从服务端断开连接和离开mysql提示符输入
```
QUIT
```
输入**quit** MySQL不区分大小写或者 **\q**也能工作。按下**Enter**退出。
你使用简单的命令也能输出关于版本的信息:
```
sudo mysqladmin -u root version -p
```
如果你想看 **选项列表**,使用:
```
mysql --help
```
#### 卸载 MySQL
如果您决定要使用较新版本或只是想停止使用MySQL。
首先,关闭服务:
```
sudo systemctl stop mysql.service && sudo systemctl disable mysql.service
```
确保你备份了你的数据库以防你之后想使用它们。你可以通过运行下列命令卸载MySQL
```
sudo apt purge mysql*
```
清理依赖:
```
sudo apt autoremove
```
**小结**
在这边文章中我已经介绍如何在Ubuntu Linux上**安装 Mysql**。我很高兴如果这篇文章能帮助到那些正为此挣扎的用户或者刚刚开始的用户。
In this article, Ive covered **installing MySQL** in Ubuntu Linux. Id be glad if this guide helps struggling users and beginners.
如果你发现这篇文章是一个很有用的资源在评论里告诉我们。你为了什么使用MySQL? 我们渴望收到你的任何反馈,印象和建议。感谢阅读,并毫不犹豫地尝试这个令人难以置信的工具!
--------------------------------------------------------------------------------
via: https://itsfoss.com/install-mysql-ubuntu/
作者:[Sergiu][a]
选题:[lujun9972][b]
译者:[arrowfeng](https://github.com/arrowfeng)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/sergiu/
[b]: https://github.com/lujun9972
[1]: https://www.mysql.com/
[2]: https://en.wikipedia.org/wiki/LAMP_(software_bundle)
[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/04/install-mysql-ubuntu.png?resize=800%2C450&ssl=1
[4]: https://dev.mysql.com/downloads/repo/apt/
[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/04/mysql_apt_download_page.jpg?fit=800%2C280&ssl=1
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/04/mysql_deb_download_link.jpg?fit=800%2C507&ssl=1
[7]: https://linuxhandbook.com/curl-command-examples/
[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/04/mysql_package_configuration_ok.jpg?fit=800%2C587&ssl=1
[9]: https://itsfoss.com/change-password-ubuntu/
[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/04/mysql_enter_password.jpg?fit=800%2C583&ssl=1
[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/04/mysql_information_on_configuring.jpg?fit=800%2C581&ssl=1
[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/04/mysql_default_authentication_plugin.jpg?fit=800%2C586&ssl=1
[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/04/mysql_service_information.jpg?fit=800%2C402&ssl=1
[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/04/mysql_shell_prompt-2.jpg?fit=800%2C423&ssl=1