Merge pull request #14 from LCTT/master

update
This commit is contained in:
zxp 2020-12-17 10:34:33 +08:00 committed by GitHub
commit eff67ee111
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 2911 additions and 565 deletions

View File

@ -1,39 +1,41 @@
[#]: collector: (lujun9972)
[#]: translator: (Mjseven)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-12920-1.html)
[#]: subject: (How to Save the Output of a Command to a File in Linux Terminal [Beginners Tip])
[#]: via: (https://itsfoss.com/save-command-output-to-file-linux/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
如何将 Linux 终端中命令的输出保存到文件中[新手技巧]
如何将 Linux 终端中命令的输出保存到文件中
======
![](https://img.linux.net.cn/data/attachment/album/202012/14/223956pidmznldldnnk87f.jpg)
当你在 Linux 终端中运行命令或脚本时,它会在终端中打印输出方便你立即查看。
有时你需要将输出保存到文件中以备将来参考。现在,[当然可以在 Linux 终端中复制和粘贴][1],但是有更好的方法可以在 Linux 命令行中保存 shell 脚本或命令的输出,让我演示给你看。
有时你需要将输出保存到文件中以备将来参考。[当然可以在 Linux 终端中复制和粘贴][1],但是有更好的方法可以在 Linux 命令行中保存 shell 脚本或命令的输出,让我演示给你看。
### 方法 1使用重定向将命令输出保存到文件中
你可以[在 Linux 中使用重定向来达成目的][2]。使用重定向操作符,它会将输出保存到文件中而不是在屏幕上显示。
* > 会将命令输出重定向到文件,它会替换文件中的所有内容。
* >> 会将命令输出添加到文件现有内容的末尾。
* `>` 会将命令输出重定向到文件,它会替换文件中的所有内容。
* `>>` 会将命令输出添加到文件现有内容的末尾。
使用 STDOUT 重定向运算符 > 将输出重定向到文件:
使用标准输出重定向运算符 `>` 将输出重定向到文件:
```
command > file.txt
```
如果 file.txt 不存在,它会自动创建。如果你使用 > 再次重定向到相同的文件,文件内容将被替换为新的输出。
如果 `file.txt` 不存在,它会自动创建。如果你使用 `>` 再次重定向到相同的文件,文件内容将被替换为新的输出。
下面的示例将更好地演示它。它首先会保存 _ls -l_ 命令的输出,然后,它将用 _ls *.c_ 命令的输出替换文件的内容。
下面的示例将更好地演示它。它首先会保存 `ls -l` 命令的输出,然后,它将用 `ls *.c` 命令的输出替换文件的内容。
![将命令输出重定向到文件][3]
如果你不想在保存脚本或命令的输出时丢失现有文件的内容,可以使用 >>
如果你不想在保存脚本或命令的输出时丢失现有文件的内容,可以使用 `>>`
```
command >> file.txt
@ -47,17 +49,19 @@ command >> file.txt
温馨提示:将 Linux 命令输出和错误保存到一个文件中。
如果Linux 命令返回错误,那么错误不会保存在文件中。你可以使用 2>&1 将命令的输出和错误保存到同一个文件中,如下所示:
如果 Linux 命令返回错误,那么错误不会保存在文件中。你可以使用 `2>&1` 将命令的输出和错误保存到同一个文件中,如下所示:
**command > file.txt 2>&1**
```
command > file.txt 2>&1
```
通常0 代表标准输入1 代表标准输出2 代表标准错误。在这里,你要将标准错误(2) 重定向(&)到与标准输出(1) 相同的地址。
通常,`0` 代表标准输入,`1` 代表标准输出,`2` 代表标准错误。在这里,你要将标准错误`2` 重定向(`&`)到与标准输出(`1`相同的地址。
### 方法 2使用 tee 命令显示输出并将其保存到文件中
顺便说一句,你是否注意到,当你将命令输出发送到一个文件时,你再也无法在终端上看到它了?[Linux 的 tee 命令][5]解决了这个问题。
类似于将水流发送到两个方向的三通管tee 命令将输出发送到终端以及文件(或作为另一个命令的输入)。你可以像这样使用它:
类似于将水流发送到两个方向的三通管,`tee` 命令将输出发送到终端以及文件(或作为另一个命令的输入)。你可以像这样使用它:
```
command | tee file.txt
@ -65,7 +69,7 @@ command | tee file.txt
同样,如果该文件不存在,它将自动创建。
你还可以使用 tee 命令在附加模式下使用选项 -a
你还可以使用 `tee` 命令 `-a` 选项进入附加模式
```
command | tee -a file.txt
@ -79,7 +83,7 @@ command | tee -a file.txt
### 注意:将命令输出保存到文件时,避免管道陷阱
你可能对管道重定向很熟悉,可以使用它来组合 Linux 命令,但不能将输出通过管道传输到文件,它显示找不到 output.txt 命令:
你可能对管道重定向很熟悉,可以使用它来组合 Linux 命令,但不能将输出通过管道传输到文件,它显示找不到 `output.txt` 命令:
![][7]
@ -96,7 +100,7 @@ via: https://itsfoss.com/save-command-output-to-file-linux/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[MjSeven](https://github.com/MjSeven)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,92 @@
[#]: collector: (lujun9972)
[#]: translator: (wxy)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-12923-1.html)
[#]: subject: (Why I love Emacs)
[#]: via: (https://opensource.com/article/20/12/emacs)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
为什么我喜欢 Emacs
======
> Emacs 并不是一个单纯的文本编辑器,它将掌控置于你手中,让你几乎可以解决你遇到的任何问题。
!["表情符号键盘"][1]
我是一个典型的 [Emacs][2] 用户。不是我选择的 Emacs而是它选择了我。早在我刚开始学习 Unix 的时候,我偶然发现了一个奇怪的名为 Emacs 的应用程序,它隐藏在我的电脑上,其中有一个鲜为人知的功能。传说中(而且被证明是真的),如果你在终端上输入 `emacs`,按 `Alt+X`,然后输入 `tetris`,你就可以玩一个掉方块的游戏。
![Tetris in Emacs][3]
那就是我对 GNU Emacs 的印象。虽然这很肤浅,但它也准确地表明了 Emacs 的意义:用户可以重新编程他们的(虚拟)世界,并且可以用一个应用程序做*任何*他们想做的事情。在你的文本编辑器中玩俄罗斯方块可能不是你日常的主要目标,但这说明 Emacs 是一个值得骄傲的编程平台。事实上,你可以把它看作是 [Jupyter][4] 的一种先驱,它把一种强大的编程语言(准确的说叫 elisp和自己的实时环境结合起来。因此Emacs 作为一个文本编辑器是灵活的、可定制的、强大的。
如果你习惯于 Bash、Python 或类似的语言elisp以及扩展的 Common Lisp不一定是最容易入门的语言。但是这种 LISP 方言是很强大的,而且因为 Emacs 是一个 LISP 解释器,所以你可以用它构建应用程序,不管它们是 Emacs 插件还是你想开发成一个独立项目的原型。极其流行的 [org 模式项目][5]就是一个例子:它是一个 Emacs 插件,同时也是一个标记语法,有移动应用可以解释和扩展其功能。类似的有用的 Emacs 内应用的例子还有很多包括电子邮件客户端、PDF 浏览器、Web 浏览器、shell 和文件管理器。
### 两个界面
GNU Emacs 至少有两个用户界面图形用户界面GUI和终端用户界面TUI。这有时会让人感到惊讶因为 Emacs 经常与运行在终端中的 Vi 相提并论(尽管 gVim 为现代 Vi 的实现提供了一个 GUI。如果你想把 GNU Emacs 以终端程序来运行,你可以用 `-nw` 选项来启动它。
```
$ emacs -nw
```
有了 GUI 程序,你可以直接从应用程序菜单或终端启动 Emacs。
你可能会认为 GUI 会降低 Emacs 的效率,好像“真正的文本编辑器是在终端中运行的”,但 GUI 可以使 Emacs 更容易学习,因为它的 GUI 遵循了一些典型的惯例(菜单栏、可调节的组件、鼠标交互等)。
事实上,如果你把 Emacs 作为一个 GUI 应用程序来运行,你可能在一天的时间里会完全没有意识到你在 Emacs 中。只要你使用过 GUI大多数常用的惯例都适用。例如你可以用鼠标选择文本导航到**编辑**菜单,选择**复制**,然后将光标放在其他地方,选择**粘贴**。要保存文档,你可以进入**文件**,然后选择**保存**或**另存为**。你可以按 `Ctrl` 键并向上滚动,使屏幕字体变大,你可以使用滚动条来浏览你的文档,等等。
了解 Emacs 的 GUI 形式是拉平学习曲线的好方法。
### Emacs 键盘快捷键
GNU Emacs 以复杂的键盘组合而恶名远扬。它们不仅陌生(`Alt+W` 来复制?`Ctrl+Y` 来粘贴?),而且还用晦涩难懂的术语来标注(`Alt` 被称为 `Meta`),有时它们成双成对(`Ctrl+X` 后是 `Ctrl+S` 来保存),有时则单独出现(`Ctrl+S` 来搜索)。为什么有人会故意选择使用这些呢?
嗯,有些人不会。但那些喜欢这些的人是因为这些组合很容易融入到日常打字的节奏中(而且经常让 `Caps Lock` 键充当 `Ctrl` 键)。然而,那些喜欢不同的东西的人有几个选择:
* “邪恶”模式让你在 Emacs 中使用 Vim 键绑定。就是这么简单。你可以保留你的肌肉记忆中的按键组合,并继承最强大的文本编辑器。
* 通用用户访问CUA键保留了所有 Emacs 常用的组合键,但最令人头疼的键(复制、剪切、粘贴和撤消)都被映射到现代的键盘绑定中(分别为 `Ctrl+C`、`Ctrl+X`、`Ctrl+V` 和 `Ctrl+Z`)。
* `global-set-key` 函数,是 Emacs 编程的一部分,允许你定义自己的键盘快捷键。传统上,用户定义的快捷键以 `Ctrl+C` 开头但没有什么能阻止你发明自己的方案。Emacs 并不敝帚自珍,欢迎你按照自己的意愿来扭转它。
### 学习 Emacs
要想很好地使用 Emacs 是需要时间的。对我来说,这意味着打印出一张[速记表][6],每天都把它放在键盘旁边。当我忘了一个键组合时,我就在我的速记表上查找它。如果它不在我的速记表上,我就学习这个键盘组合,要么通过执行该函数,并注意 Emacs 告诉我如何更快地访问它,要么通过使用 `describe-function`
```
M-x describe-function: save-buffer
save-buffer is an interactive compiled Lisp function in files.el.
It is bound to C-x C-s, <menu-bar> <file> <save-buffer>.
[...]
```
当你使用它的时候,你就会学习它。你对它了解得越多,你就越有能力去改进它,使它变成你自己的。
### 尝试 Emacs
人们常开玩笑说 Emacs 是一个包含文本编辑器的操作系统。也许这是在暗示 Emacs 臃肿和过于复杂,当然也有一种说法是文本编辑器根据其默认配置不应该需要 `libpoppler`(你可以不需要它来编译 Emacs
但这个笑话背后潜藏着一个更大的真相,它揭示了 Emacs 如此有趣的原因。将 Emacs 与其他文本编辑器,如 Vim、Nano甚至 [VSCodium][7] 进行比较是没有意义的,因为 Emacs 真正重要的部分并不是你可以在窗口中输入东西并保存的这种思路。那是连 Bash 都能提供的基本功能。Emacs 的真正意义在于它如何将控制置身于你的手中,以及如何通过 Emacs Lisp[Elisp][8])解决几乎任何问题。
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/emacs
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[wxy](https://github.com/wxy)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/emoji-keyboard.jpg?itok=JplrSZ9c (Emoji keyboard)
[2]: https://en.wikipedia.org/wiki/Emacs
[3]: https://opensource.com/sites/default/files/tetris.png (Tetris in Emacs)
[4]: https://opensource.com/article/20/11/surprising-jupyter
[5]: https://opensource.com/article/19/1/productivity-tool-org-mode
[6]: https://opensource.com/downloads/emacs-cheat-sheet
[7]: https://opensource.com/article/20/6/open-source-alternatives-vs-code
[8]: https://www.gnu.org/software/emacs/manual/html_node/elisp/

View File

@ -0,0 +1,168 @@
[#]: collector: (lujun9972)
[#]: translator: (wxy)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-12921-1.html)
[#]: subject: (Here are the Worthy Replacements of CentOS 8 for Your Production Linux Servers)
[#]: via: (https://itsfoss.com/rhel-based-server-distributions/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
什么 Linux 系统可以替换生产环境的 Linux 服务器上的 CentOS 8
======
CentOS 是世界上最流行的服务器发行版之一。它是<ruby>红帽企业 Linux<rt>Red Hat Enterprise Linux</rt></ruby>RHEL的一个开源分支提供了 RHEL 的优点,却没有 RHEL 的相关成本。
然而,最近情况发生了变化,[红帽正在将稳定的 CentOS 转换为滚动发布模式,即 CentOS Stream的形式][1]。CentOS 8 本来应该支持到 2029 年,但现在到 2021 年底就被迫停止了。
如果你的服务器使用的是 CentOS这可能会让你不知道该何去何从。
你看,取代 CentOS 8 的首要选择就是 CentOS Stream。将 CentOS 8 升级到 CentOS Stream 的[过程很简单][2],你不用担心需要重新安装任何东西。
不过,由于 CentOS Stream 是滚动发布性质的,你可能要考虑一些对生产服务器来说更稳定的东西。我将在本文中会推荐一些 Linux 系统来帮助你做出这个决定。
### 基于 RHEL 的服务器 Linux 发行版,你可以考虑用来取代 CentOS
![][3]
我将从一些正在开发的 RHEL 分支版本开始列举,其唯一目的是取代 CentOS 8。之后我会列出你可以马上使用的服务器发行版。
#### Rocky Linux正在开发中
![][4]
就在红帽宣布计划用滚动发布的 CentOS Stream 取代稳定的 CentOS 8 的同一天CentOS 的原开发者宣布了一个新项目,为 CentOS 用户提供 RHEL 分支。
这个新项目名为 [Rocky Linux][5]。它的名字是为了纪念原 CentOS 项目的共同创始人之一。它是从 RHEL 8 分支出来的目标是“100% 与 RHEL 兼容”。
该项目正在快速开发中,目前可能无法使用。但这是在 2021 年底 CentOS 8 支持结束时取代它的首选之一。
#### Lenix 项目(开发中)
![][6]
这是在宣布 CentOS Stream 成为默认版本一天后创建的又一个 RHEL 分支。
[Lenix 项目][7]是由 CloudLinux 创建的CloudLinux 是一家面向企业的服务机构,多年来一直在提供定制化的 CentOS 服务器,鉴于他们在 CentOS 和企业服务器方面的多年经验Lenix 项目应该是一个很有前途的 RHEL 分支,可以取代 CentOS Stream。
#### Oracle Linux
![][8]
这可能是该列表中唯一能以最佳方式使用的 RHEL 分支。不仅可以随时使用,你甚至可以[从现有的 CentOS 安装迁移到 Oracle Linux][9],而无需重新安装。
Oracle Linux 自 2006 年起推出。它的应用二进制 100% 兼容 RHEL并且它提供了与每个 RHEL 版本相对应的版本。而且,你不需要与 Oracle 签署任何协议来使用 Oracle Linux。
Oracle Linux 有两种 Linux 内核可供选择Oracle Linux 的<ruby>[坚不可摧企业级内核][10]<rt>Unbreakable Enterprise Kernel</rt></ruby>UEK<ruby>红帽兼容内核<rt> Red Hat Compatible Kernel</rt></ruby>RHCK
只是,甲骨文在开源项目上有些黑历史,可能这也是为什么选择 CentOS 这种真正的社区分支形式而不是甲骨文 Linux 的原因。随着 CentOS 被 CentOS Stream 所取代,也许现在正是给 Oracle 一个机会的时候?
#### ClearOS来自惠普
![][11]
[ClearOS][12] 是惠普在其 HPE ProLiant 服务器上提供的。虽然他们的网站上没有明确提到,但 ClearOS 是基于 RHEL 和 CentOS 的。
[Clear Center][13] 和 HPE 在这个项目上进行了合作。开源的 ClearOS 免费提供给社区。他们有自己的应用市场,混杂了免费和付费应用。你不需要为操作系统付费,但如果你选择了付费应用,你可能需要为该应用付费。
它可能没有那么流行,但随着 CentOS Stream 成为默认如果惠普能抓住这个时机ClearOS 应该能获得一些用户。他们会这么做吗?我不太确定。甲骨文正在努力吸引 CentOS 用户,但我没有看到惠普的这种努力。
#### Springdale Linux普林斯顿大学的学术项目
![][14]
一个由院士维护的红帽分支?这就是 Scientific Linux 吧?但 Scientific Linux 已经死了一年多了。
[Springdale Linux][15]SDL是普林斯顿大学的另一个这样的项目。它之前被称为 PUIAS Linux<ruby>普林斯顿大学高级研究所<rt>Princeton University Institute for Advanced Study</rt></ruby>)。
目前还没有 RHEL 8 对应的 Springdale Linux我觉得他们的开发速度可以加快一些。
### 不基于红帽的服务器发行版
好吧,到目前为止,列表中已经提到了基于红帽的发行版。现在是时候看看一些与 RHEL 无关,但仍然是生产服务器的上好选择的服务器发行版了。
#### YunoHost专门为 Web 服务器定制的)
![][16]
[YunoHost][17] 是基于 Debian 定制的,目的是为你提供一个托管 Web 服务器的系统。
你可以在[树莓派等 ARM 板][18]、旧台式机和计算机上使用它当然也可以在虚拟专用服务器VPS上使用。
YunoHost 还提供了一个基于 Web 的管理界面(灵感来自于 [Webmin][19]?),这样你就可以用图形化的方式来管理系统。这对于一个想托管 Web 服务器但又不太会命令行的人来说,是一个很大的安慰。
#### Debian Linux
![][20]
这个通用操作系统提供了一个坚如磐石的服务器发行版。对于那些想要一个稳定系统的人来说,是一个理想的选择。
如果你在 CentOS 上投入了太多的时间和技术,你可能会发现 [Debian][21] 略有不同,尤其是软件包管理系统。不过,我相信,对于一个经验丰富的 Linux 系统管理员来说,这应该不是什么大问题。
#### openSUSE
![][22]
SUSE 是红帽的直接竞争对手之一。他们以 [SUSE Linux Enterprise][23] 的形式提供企业级产品。他们的开源产品 openSUSE 也相当受欢迎,无论是在桌面还是服务器领域。
[openSUSE][24] 是一个服务器 Linux 发行版的好选择。现在的人不会明白 [SUSE 的 YAST 工具][25]在上世纪 90 年代和 2000 年初给用户带来了怎样的解脱。它仍然是管理 SUSE 系统的一个方便的工具。
openSUSE 有两种形式:滚动发布的 Tumbleweed 和稳定的点发布版的 Leap。我猜测你追求的是稳定性所以 Leap 是你应该追求的目标。
#### Ubuntu
![][26]
[Ubuntu][27] 是世界上最流行的发行版,[在服务器上][28]和台式机上都是如此。这就是为什么没有 Ubuntu 这份清单就不完整的原因。
因为我已经使用 Ubuntu 很长时间了,所以我觉得在 Ubuntu 上托管我的 Web 服务器很舒服。但这只是我个人的想法。如果你是从 RHEL 领域过来的,这里的包管理系统和一些网络和管理组件是不同的。
[Ubuntu LTS 版][29]带有五年的支持,这是 CentOS 版本提供的一半长短。如果你不想升级版本,你可以选择为过时的 LTS 版本购买付费的扩展支持。
#### 你的选择是什么?
我已经列出了一些基于 RHEL 的发行版以及通用服务器发行版的顶级推荐。
现在轮到你了,在上面列出的发行版中,你最喜欢哪个?你有什么其他的建议可以添加到这个列表中吗?请在评论区留言。
--------------------------------------------------------------------------------
via: https://itsfoss.com/rhel-based-server-distributions/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[wxy](https://github.com/wxy)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lujun9972
[1]: https://linux.cn/article-12902-1.html
[2]: https://linuxhandbook.com/update-to-centos-stream/
[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/12/Replace-centos.png?resize=800%2C450&ssl=1
[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/12/rocky-linux.png?resize=800%2C350&ssl=1
[5]: https://rockylinux.org
[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/12/cloudlinux.png?resize=800%2C350&ssl=1
[7]: https://www.reddit.com/r/ProjectLenix/
[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/12/oracle-linux.png?resize=800%2C350&ssl=1
[9]: https://github.com/oracle/centos2ol
[10]: https://docs.oracle.com/en/operating-systems/uek/
[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/12/clear-os.jpg?resize=795%2C349&ssl=1
[12]: https://www.clearos.com
[13]: https://www.clearcenter.com
[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/12/springdale-linux.png?resize=800%2C350&ssl=1
[15]: https://puias.math.ias.edu
[16]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/12/yunohost.png?resize=720%2C400&ssl=1
[17]: https://yunohost.org#/
[18]: https://itsfoss.com/raspberry-pi-alternatives/
[19]: https://linuxhandbook.com/use-webmin/
[20]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/12/debian-linux.png?resize=800%2C350&ssl=1
[21]: https://www.debian.org
[22]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/12/opensuse.jpg?resize=800%2C350&ssl=1
[23]: https://www.suse.com/download/sles/
[24]: https://www.opensuse.org
[25]: https://yast.opensuse.org
[26]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/12/ubuntu.jpg?resize=800%2C350&ssl=1
[27]: https://ubuntu.com/download/server
[28]: https://www.datanyze.com/market-share/operating-systems--443/ubuntu-market-share
[29]: https://itsfoss.com/long-term-support-lts/

View File

@ -0,0 +1,103 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Ben Cotton: How Do You Fedora?)
[#]: via: (https://fedoramagazine.org/ben-cotton-how-do-you-fedora/)
[#]: author: (gchang https://fedoramagazine.org/author/gchang/)
Ben Cotton: How Do You Fedora?
======
![][1]
We recently interviewed Ben Cotton on how he uses Fedora. This is part of a [series][2] on the Fedora Magazine. The series profiles Fedora users and how they use Fedora to get things done. Contact us on the [feedback form][3] to express your interest in becoming an interviewee.
### **Who is Ben Cotton?**
If you follow the Fedora Community Blog, theres a good chance you already know who Ben is. 
Bens Linux journey started around late 2002. Frustrated with some issues on using Windows XP, and starting a new application administrator role at his university where some services were being run on FreeBSD. A friend introduced him to Red Hat Linux, when Ben decided it made sense to get more practice with Unix-like operating systems. He switched to Fedora full-time in 2006, after he landed a job as a Linux system administrator.
Since then, his career has included system administration, people management, support engineering, development, and marketing. Several years ago, he even earned a Masters degree in IT Project Management. The variety of experience has helped Ben learn how to work with different groups of people. “A lot of what Ive learned has come from making mistakes. When you mess up communication, you hopefully do a better job the next time.”
Besides tech, Ben also has a range of well-rounded interests. “I used to do a lot of short fiction writing, but these days I mostly write my opinions about whatever is on my mind.” As for favorite foods, he claims “All of it. Feed me.”
Additionally, Ben has taste that spans genres. His childhood hero was a character from the science fiction series “Star Trek: The Next Generation”. “As a young lad, I wanted very much to be Wesley Crusher.” His favorite movies are a parody film and a spy thriller: “Airplane! and The Hunt for Red October” respectively. 
When asked for the five greatest qualities he thinks someone can possess, Ben responded cleverly: “Kindness. Empathy. Curiosity. Resilience. Red hair.”
![][4]
Ben wearing the official “#action bcotton” shirt
### **His Fedora Story**
As a talented writer who described himself as “not much of a programmer”, he selected the [Fedora Docs][5] team in 2009 as an entry point into the community. What he found was that “the Friends foundation was evident.” At the time, he wasnt familiar with tools such as Git, DocBook XML, or Publican (docs toolchain at the time). The community of experienced doc writers helped him get on his feet and freely gave their time. To this day, Ben considers many of them to be his friends and feels really lucky to work with them. Notably “jjmcd, stickster, sparks, and jsmith were a big part of the warm welcome I received.”
Today, as a senior program manager, he describes his job as “Chief Cat Herding Officer”- as his job is largely composed of seeing what different parts of the project are doing and making sure theyre all heading in the same general direction. 
Despite having a huge responsibility, Ben also helps a lot in his free time with tasks outside of his job duties, like website work, CommBlog and Magazine editing, packaging, etc… none of which are his core job responsibilities. He tries to find ways to contribute that match his skills and interests. Building credibility, paying attention, developing relationships with other contributors, and showing folks that hes able to help, is much more important to him than what his “official” title is. 
When thinking towards the future, Ben feels hopeful watching the Change proposals come in. “Sometimes they get rejected, but thats to be expected when youre trying to advance the state of the art. Fedora contributors are working hard to push the project forward.“
### **The Fedora Community **
As a longtime member of the community, Ben has various notions about the Fedora Project that have been developed over the years. For starters, he wants to make it easier to bring new contributors on board. He believes the Join SIG has “done tremendous work in this area”, but new contributors will keep the community vibrant. 
If Ben had to pick a best moment, hed choose Flock 2018 in Dresden. “That was my first Fedora event and it was great to meet so many of the people who Ive only known online for a decade.” 
As for bad moments, Ben hasnt had many. Once he accidentally messed up a Bugzilla query resulting in accidental closure of hundreds of bugs and has dealt with some frustrating mailing list threads, but remains positive, affirming that “frustration is okay.”
To those interested in becoming involved in the Fedora Project, Ben says “Come join us!” Theres something to appeal to almost anyone. “Take the time to develop relationships with the people you meet as you join, because without the Friends foundation, the rest falls apart.”
![][6]
![][7]
### **Pet Peeves**
One issue he finds challenging is a lack of documentation. “Ive learned enough over the years that I can sort of bumble through making code changes to things, but a lot of times its not clear how the code ties together.” Ben sees how sparse or nonexistent documentation can be frustrating to newcomers who might not have the knowledge that is assumed.
Another concern Ben has is that the “interesting” parts of technology are changing. “Operating systems arent as important to end users as they used to be thanks to the rise of mobile computing and Software-as-a-Service. Will this cause our pool of potential new contributors to decrease?”
Likewise, Ben believes that its not always easy to get people to understand why they should care about open source software. “The reasons are often abstract and people dont see that theyre directly impacted, especially when the alternatives provide more immediate convenience.”
### **What Hardware?**
For work, Ben has a ThinkPad X1 Carbon running Fedora 33 KDE. His personal server/desktop is a machine he put together from parts that runs Fedora 33 KDE. He uses it as a file server, print server, Plex media server, and general-purpose desktop. If he has some spare time to get it started, Ben also has an extra laptop that he wants to start using to test Beta releases and “maybe end up running rawhide on it”.
### **What Software?**
Ben has been a KDE user for a decade. A lot of his work is done in a web browser (Firefox for work stuff, Chrome for personal). He does most of his scripting in Python these days, with some inherited scripts in Perl.
Notable applications that Ben uses include:
* Cherrytree for note-taking
* Element for IRC
* Inkscape and Kdenlive when he needs to edit videos.
* Vim on the command line and Kate when he wants a GUI
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/ben-cotton-how-do-you-fedora/
作者:[gchang][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://fedoramagazine.org/author/gchang/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2020/11/LISA2015-printsize-7810-816x545.jpg
[2]: https://fedoramagazine.org/tag/how-do-you-fedora/
[3]: https://fedoramagazine.org/submit-an-idea-or-tip/
[4]: https://fedoramagazine.org/wp-content/uploads/2020/11/image1-2-edited.jpg
[5]: https://docs.fedoraproject.org/
[6]: https://i1.wp.com/fedoramagazine.org/wp-content/uploads/2020/11/image2-2.jpg?ssl=1&resize=1500%2C1500
[7]: https://i1.wp.com/fedoramagazine.org/wp-content/uploads/2020/11/image6-1.jpg?ssl=1&resize=1500%2C1500

View File

@ -1,95 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Why I love Emacs)
[#]: via: (https://opensource.com/article/20/12/emacs)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Why I love Emacs
======
Emacs isn't a mere text editor; it places you in control and allows you
to solve nearly any problem you encounter.
![Emoji keyboard][1]
I'm a habitual [Emacs][2] user. I didn't choose Emacs as much as it chose me. Back when I was first learning about Unix, I stumbled upon a little-known feature in a strange application called Emacs, which was apparently hidden away on my computer. Legend had it (and was proven true) that if you typed `emacs` into a terminal, pressed **Alt**+**X**, and typed `tetris`, you could play a falling-blocks game.
![Tetris in Emacs][3]
That was my introduction to GNU Emacs. While it was frivolous, it was also an accurate indication of what Emacs is all about—the idea that users can reprogram their (virtual) worlds and do _whatever_ they want with an application. Playing Tetris in your text editor is probably not your primary goal on an everyday basis, but it goes to show that Emacs is, proudly, a programming platform. In fact, you might think of it as a kind of precursor to [Jupyter][4], combining a powerful programming language (called `elisp`, to be exact) with its own live environment. As a consequence, Emacs is flexible as a text editor, customizable, and powerful.
Elisp (and Common Lisp, by extension) aren't necessarily the easiest languages to start out on, if you're used to Bash or Python or similar languages. But LISP dialects are powerful, and because Emacs is a LISP interpreter, you can build applications, whether they're Emacs plugins or prototypes of something you want to develop into a stand-alone project. The wildly popular [org-mode project][5] is just one example: it's an Emacs plugin as well as a markdown syntax with mobile apps to interpret and extend its capabilities. There are many examples of similarly useful applications-within-Emacs, including an email client, a PDF viewer, web browser, a shell, and a file manager.
### Two interfaces
GNU Emacs has at least two user interfaces: a graphical user interface (GUI) and a terminal user interface (TUI). This sometimes surprises people because Emacs is often pitted against Vi, which runs in a terminal (although gVim provides a GUI for a modern Vi implementation). If you want to run GNU Emacs as a terminal application, you can launch it with the `-nw` option:
```
`$ emacs -nw`
```
With a GUI, you can just launch Emacs from your application menu or a terminal.
You might think that a GUI renders Emacs less effective, as if "real text editors run in a terminal," but a GUI can make Emacs easier to learn because its GUI follows some typical conventions (a menu bar, adjustable widgets, mouse interaction, and so on).
In fact, if you run Emacs as a GUI application, you can probably get through the day without noticing you're in Emacs at all. Most of the usual conventions apply, as long as you use the GUI. For instance, you can select text with your mouse, navigate to the **Edit** menu, select **Copy**, and then place your cursor elsewhere and select **Paste**. To save a document, you can go to **File** and **Save** or **Save As**. You can press **Ctrl** and scroll up to make your screen font larger, you can use the scroll bar to navigate through your document, and so on.
Getting to know Emacs in its GUI form is a great way to flatten the learning curve.
### Emacs keyboard shortcuts
GNU Emacs is infamous for complex keyboard combinations. They're not only unfamiliar (**Alt**+**W** to copy? **Ctrl**+**Y** to paste?), they're also notated with arcane terminology ("Alt" is called "Meta"), and sometimes they come in pairs (**Ctrl**+**X** followed by **Ctrl**+**S** to save) and other times alone (**Ctrl**+**S** to search). Why would anyone willfully choose to use this?
Well, some don't. But those who do are fans of how these combinations easily flow into the rhythm of everyday typing (and often have the **Caps Lock** key serve as a **Ctrl** key). Those who prefer something different, however, have several options.
* The `evil` mode lets you use Vim keybindings in Emacs. It's that simple: You get to keep the key combinations you've committed to muscle memory, and you inherit the most powerful text editor available.
* Common User Access (CUA) keys keep all of the usual Emacs key combinations but the most jarring ones—copy, cut, paste, and undo—are all mapped to their modern bindings (**Ctrl**+**C**, **Ctrl**+**X**, **Ctrl**+**V**, and **Ctrl**+**Z**, respectively).
* The `global-set-key` function, part of the programming side of Emacs, allows you to define your own keyboard shortcuts. Traditionally, user-defined shortcuts start with **Ctrl**+**C**, but nothing is stopping you from inventing your own scheme. Emacs isn't precious of its own identity. You're welcome to bend it to your will.
### Learn Emacs
It takes time to get very good with Emacs. For me, that meant printing out a [cheat sheet][6] and keeping it next to my keyboard all day, every day. When I forgot a key combo, I looked it up on my cheat sheet. If it wasn't on my cheat sheet, I learned the keyboard combo, either by executing the function and noting how Emacs told me I could access it quicker or by using `describe-function`:
```
M-x describe-function: save-buffer
save-buffer is an interactive compiled Lisp function in files.el.
It is bound to C-x C-s, &lt;menu-bar&gt; &lt;file&gt; &lt;save-buffer&gt;.
[...]
```
As you use it, you learn it. And the more you learn about it, the more empowered you become to improve it and make it your own.
### Try Emacs
It's a common joke to say that Emacs is an operating system with a text editor included. Maybe that's meant to insinuate Emacs is bloated and overly complex, and there's certainly an argument that a text editor shouldn't require `libpoppler` according to its default configuration (you can compile Emacs without it).
But there's a greater truth lurking behind this joke, and it reveals a lot about what makes Emacs so fun. It doesn't make sense to compare Emacs to other text editors, like Vim, Nano, or even [VSCodium][7], because the really important part of Emacs isn't the idea that you can type stuff into a window and save it. That's basic functionality that even Bash provides. The true significance of Emacs is how it places you in control and how, through Emacs Lisp ([Elisp][8]), nearly any problem can be solved.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/emacs
作者:[Seth Kenlon][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://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/emoji-keyboard.jpg?itok=JplrSZ9c (Emoji keyboard)
[2]: https://en.wikipedia.org/wiki/Emacs
[3]: https://opensource.com/sites/default/files/tetris.png (Tetris in Emacs)
[4]: https://opensource.com/article/20/11/surprising-jupyter
[5]: https://opensource.com/article/19/1/productivity-tool-org-mode
[6]: https://opensource.com/downloads/emacs-cheat-sheet
[7]: https://opensource.com/article/20/6/open-source-alternatives-vs-code
[8]: https://www.gnu.org/software/emacs/manual/html_node/elisp/

View File

@ -1,272 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Add storage to your Fedora system with LVM)
[#]: via: (https://fedoramagazine.org/add-storage-to-your-fedora-system-with-lvm/)
[#]: author: (Tim Bosse https://fedoramagazine.org/author/maztaim/)
Add storage to your Fedora system with LVM
======
![][1]
Sometimes there is a need to add another disk to your system. This is where Logical Volume Management (LVM) comes in handy. The cool thing about LVM is that its fairly flexible. There are several ways to add a disk. This article describes one way to do it.
### Heads up!
This article does not cover the process of physically installing a new disk drive into your system. Consult your system and disk documentation on how to do that properly.
**Important:** Always make sure you have backups of important data. The steps described in this article will destroy data if it already exists on the new disk.
### Good to know
This article doesnt cover every LVM feature deeply; the focus is on adding a disk. But basically, LVM has _volume groups_, made up of one or more partitions and/or disks. You add the partitions or disks as _physical volumes_. A volume group can be broken down into many _logical volumes_. Logical volumes can be used as any other storage for filesystems, ramdisks, etc. More information can be found [here][2].
Think of the _physical volumes_ as forming a pool of storage (a _volume group_) from which you then carve out _logical volumes_ for your system to use directly.
### Preparation
Make sure you can see the disk you want to add. Use _lsblk_ prior to adding the disk to see what storage is already available or in use.
```
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
zram0 251:0 0 989M 0 disk [SWAP]
vda 252:0 0 20G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 19G 0 part
└─fedora_fedora-root 253:0 0 19G 0 lvm /
```
This article uses a virtual machine with virtual storage. Therefore the device names start with _vda_ for the first disk, _vdb_ for the second, and so on. The name of your device may be different. Many systems will see physical disks as _sda_ for the first disk, _sdb_ for the second, and so on.
Once the new disk has been connected and your system is back up and running, use _lsblk_ again to see the new block device.
```
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
zram0 251:0 0 989M 0 disk [SWAP]
vda 252:0 0 20G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 19G 0 part
└─fedora_fedora-root 253:0 0 19G 0 lvm /
vdb 252:16 0 10G 0 disk
```
There is now a new device named _vdb_. The location for the device is _/dev/vdb_.
```
$ ls -l /dev/vdb
brw-rw----. 1 root disk 252, 16 Nov 24 12:56 /dev/vdb
```
We can see the disk, but we cannot use it with LVM yet. If you run _blkid_ you should not see it listed. For this and following commands, youll need to ensure your system is [configured so you can use _sudo_][3]:
```
$ sudo blkid
/dev/vda1: UUID="4847cb4d-6666-47e3-9e3b-12d83b2d2448" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="830679b8-01"
/dev/vda2: UUID="k5eWpP-6MXw-foh5-Vbgg-JMZ1-VEf9-ARaGNd" TYPE="LVM2_member" PARTUUID="830679b8-02"
/dev/mapper/fedora_fedora-root: UUID="f8ab802f-8c5f-4766-af33-90e78573f3cc" BLOCK_SIZE="4096" TYPE="ext4"
/dev/zram0: UUID="fc6d7a48-2bd5-4066-9bcf-f062b61f6a60" TYPE="swap"
```
### Add the disk to LVM
Initialize the disk using _pvcreate_. You need to pass the full path to the device. In this example it is _/dev/vdb_; on your system it may be _/dev/sdb_ or another device name.
```
$ sudo pvcreate /dev/vdb
Physical volume "/dev/vdb" successfully created.
```
You should see the disk has been initialized as an LVM2_member when you run _blkid_:
```
$ sudo blkid
/dev/vda1: UUID="4847cb4d-6666-47e3-9e3b-12d83b2d2448" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="830679b8-01"
/dev/vda2: UUID="k5eWpP-6MXw-foh5-Vbgg-JMZ1-VEf9-ARaGNd" TYPE="LVM2_member" PARTUUID="830679b8-02"
/dev/mapper/fedora_fedora-root: UUID="f8ab802f-8c5f-4766-af33-90e78573f3cc" BLOCK_SIZE="4096" TYPE="ext4"
/dev/zram0: UUID="fc6d7a48-2bd5-4066-9bcf-f062b61f6a60" TYPE="swap"
/dev/vdb: UUID="4uUUuI-lMQY-WyS5-lo0W-lqjW-Qvqw-RqeroE" TYPE="LVM2_member"
```
You can list all physical volumes currently available using _pvs_:
```
$ sudo pvs
PV VG Fmt Attr PSize PFree
/dev/vda2 fedora_fedora lvm2 a-- <19.00g 0
/dev/vdb lvm2 --- 10.00g 10.00g
```
_/dev/vdb_ is listed as a PV (phsyical volume), but it isnt assigned to a VG (Volume Group) yet.
### Add the pysical volume to a volume group
You can find a list of available volume groups using _vgs_:
```
$ sudo vgs
VG #PV #LV #SN Attr VSize VFree
fedora_fedora 1 1 0 wz--n- 19.00g 0
```
In this example, there is only one volume group available. Next, add the physical volume to _fedora_fedora_:
```
$ sudo vgextend fedora_fedora /dev/vdb
Volume group "fedora_fedora" successfully extended
```
You should now see the physical volume is added to the volume group:
```
$ sudo pvs
PV VG Fmt Attr PSize PFree
/dev/vda2 fedora_fedora lvm2 a <19.00g 0
/dev/vdb fedora_fedora lvm2 a <10.00g <10.00g
```
Look at the volume groups:
```
$ sudo vgs
VG #PV #LV #SN Attr VSize VFree
fedora_fedora 2 1 0 wzn- 28.99g <10.00g
```
You can get a detailed list of the specific volume group and physical volumes as well:
```
$ sudo vgdisplay fedora_fedora
--- Volume group ---
VG Name fedora_fedora
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 28.99 GiB
PE Size 4.00 MiB
Total PE 7422
Alloc PE / Size 4863 / 19.00 GiB
Free PE / Size 2559 / 10.00 GiB
VG UUID C5dL2s-dirA-SQ15-TfQU-T3yt-l83E-oI6pkp
```
Look at the PV:
```
$ sudo pvdisplay /dev/vdb
--- Physical volume ---
PV Name /dev/vdb
VG Name fedora_fedora
PV Size 10.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 2559
Free PE 2559
Allocated PE 0
PV UUID 4uUUuI-lMQY-WyS5-lo0W-lqjW-Qvqw-RqeroE
```
Now that we have added the disk, we can allocate space to logical volumes (LVs):
```
$ sudo lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root fedora_fedora -wi-ao---- 19.00g
```
Look at the logical volumes. Heres a detailed look at the root LV:
```
$ sudo lvdisplay fedora_fedora/root
--- Logical volume ---
LV Path /dev/fedora_fedora/root
LV Name root
VG Name fedora_fedora
LV UUID yqc9cw-AvOw-G1Ni-bCT3-3HAa-qnw3-qUSHGM
LV Write Access read/write
LV Creation host, time fedora, 2020-11-24 11:44:36 -0500
LV Status available
LV Size 19.00 GiB
Current LE 4863
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
```
Look at the size of the root filesystem and compare it to the logical volume size.
```
$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/fedora_fedora-root 19G 1.4G 17G 8% /
```
The logical volume and the filesystem both agree the size is 19G. Lets add 5G to the root logical volume:
```
$ sudo lvresize -L +5G fedora_fedora/root
Size of logical volume fedora_fedora/root changed from 19.00 GiB (4863 extents) to 24.00 GiB (6143 extents).
Logical volume fedora_fedora/root successfully resized.
```
We now have 24G available to the logical volume. Look at the _/_ filesystem.
```
$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/fedora_fedora-root 19G 1.4G 17G 8% /
```
We are still showing only 19G free. This is because the logical volume is not the same as the filesytem. To use the new space added to the logical volume, resize the filesystem.
```
$ sudo resize2fs /dev/fedora_fedora/root
resize2fs 1.45.6 (20-Mar-2020)
Filesystem at /dev/fedora_fedora/root is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 3
The filesystem on /dev/fedora_fedora/root is now 6290432 (4k) blocks long.
```
Look at the size of the filesystem.
```
$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/fedora_fedora-root 24G 1.4G 21G 7% /
```
As you can see, the root file system _(/)_ has taken all of the space available on the logical volume and no reboot was needed.
You have now initialized a disk as a physical volume, and extended the volume group with the new physical volume. After that you increased the size of the logical volume, and resized the filesystem to use the new space from the logical volume.
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/add-storage-to-your-fedora-system-with-lvm/
作者:[Tim Bosse][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://fedoramagazine.org/author/maztaim/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2020/11/lvm-add-disk-816x345.jpg
[2]: https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)
[3]: https://fedoramagazine.org/howto-use-sudo/

View File

@ -1,70 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Make medit your next Linux terminal text editor)
[#]: via: (https://opensource.com/article/20/12/medit)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Make medit your next Linux terminal text editor
======
This classic text editor offers all the basics and some exciting extra
features that let you customize your experience.
![Person drinking a hot drink at the computer][1]
Theres [XEDIT][2], jEdit, NEdit, [gedit][3], and, as it turns out, [medit][4]. 
I had not heard about medit until I started searching for editors I hadnt yet tried, but Im glad to have discovered it. If youre looking for a classic gedit experience (circa Gnome 2), then medit is, probably unintentionally, an excellent and modern approximation. Its also got many additional features, such as the ability to write plugins in Python, Lua, or C, and a means to integrate even shell scripts into its menu system. All the other usual features are here, too—a tabbed interface, an on-demand shell, indentation management, syntax highlighting, and so on.
### Installing medit
You can download medit from [mooedit.sourceforge.net][5]. Its confirmed to work on Linux and Windows. If youre using Linux, you may also find it in your repository. I installed my copy from [slackbuilds.org][6] on Slackware.
![Medit terminal showing examples of Bash script in editor][7]
### Using medit
Medit advertises itself as an editor "for programming and around programming," and in fact, started its life out as part of a larger project called [GAP (Groups, Algorithms, Programming)][8]. Most of its features are aimed at typical developer expectations. For instance, in the **Edit** menu, there are options to increase and decrease indentation, a common task for any programmer trying to indicate scope visually (and a literal requirement for Python programmers), and options to comment or uncomment blocks of text.
Some features can be useful for general users, too. Medit has an easy-to-use tabbed interface (both at the top of the window and as a pop-up list along the side), a side panel for quick filesystem browsing, the ability to bookmark places in a file, and so on. It also has syntax highlighting for both programming languages, as well as markup and markdown languages, so its a useful editor for code and prose alike.
### Color schemes
When editing plain text with no syntax associated with it or a format like Asciidoc, for which medit has no preset highlighting scheme, the editor assumes your system default. I use a dark theme, so medit displays white text on a dark gray background.
For syntax highlighting, though, the text becomes colorful depending on the part each word plays in its structured language. At first, I was a little frustrated at some of the choices medit made; many of the colors were too dark against my dark background to be legible, and I didnt feel that all the important elements were unique enough. The answer to this problem, should you disagree with medits choices, is in **Preferences**, where you can change the color theme. I changed mine to the Tango colors, which rendered a solarized color array that stood out nicely against my dark editor background and even added color to elements that were kept white under the medit theme.
![Medit terminal showing examples of Bash script in editor using Tango color scheme against dark background][9]
### Pop-up Python
At the bottom of the medit window, theres a pop-up terminal for quick access to a shell. This is a nice feature, but frankly, after youve experienced Emacs and [Kate][10], it feels pretty common. What surprised me about medit was its pop-up Python console, which launches from the **Tools** menu with **moo** and **gtk** modules pre-imported. In other words, when you launch medits Python shell, you can look through the Python and GTK modules that medit itself is partly built upon. Its a great feature and one that might inspire you to write a plugin (the Terminal pop-up is a plugin written in Python, so you can also look through its code to get a feel for how a plugin is written).
### Classic editing
Medit is a great GTK-based editor with all the important basic features and several tantalizing extras to help inspire you to extend the application and make it your own. As it accepts C, Python, Lua, and Bash, there are several entry points for doing just that. If youre looking for a no-nonsense editor for your writing, whether its code or markdown or something in between, give medit a chance.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/medit
作者:[Seth Kenlon][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://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_tea_laptop_computer_work_desk.png?itok=D5yMx_Dr (Person drinking a hot drink at the computer)
[2]: https://opensource.com/article/20/12/xedit
[3]: https://opensource.com/article/20/12/gedit
[4]: http://mooedit.sourceforge.net/
[5]: https://sourceforge.net/projects/mooedit/files/medit/
[6]: https://slackbuilds.org/repository/14.2/development/medit
[7]: https://opensource.com/sites/default/files/uploads/medit-31_days_medit-opensource.png (Medit terminal showing examples of Bash script in editor)
[8]: https://www.gap-system.org/
[9]: https://opensource.com/sites/default/files/uploads/medit-tango-colour-31_days_medit-opensource.png (Medit terminal showing examples of Bash script in editor using Tango color scheme against dark background)
[10]: https://opensource.com/article/20/12/kate-text-editor

View File

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

View File

@ -1,73 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (What web developers love about the Brackets text editor)
[#]: via: (https://opensource.com/article/20/12/brackets)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
What web developers love about the Brackets text editor
======
This basic editor is geared toward web developers, supporting multiple
programming languages and offering plenty of extensions to make it your
own.
![Text editor on a browser, in blue][1]
The Brackets text editor is an editor geared primarily at web developers. Appropriately, its Edit menu is full of functions especially useful to users of web programming languages, with a focus on the classic combination of HTML, CSS, and Javascript.
However, it supports many languages and formats relevant to the internet, including XML, Markdown, YAML and JSON, PHP, Lua, Java, and Python, as well as some common general languages like C, C++, and even the output of `diff` commands.
### Installing Brackets
Brackets can be installed on Linux, Windows, and macOS from the [Brackets website][2].
Alternatively, on Linux, you can install it as a Flatpak from [flathub.org][3].
![Brackets editor][4]
### Using Brackets
For the most part, Brackets is a "normal" text editor, with features similar to jEdit or Medit. Theres syntax highlighting, configurable tab spacing, character encoding settings, and so on. These are available in the status bar at the bottom of the window.
From the View menu, there are theme settings, line numbering, word wrapping, and even options to split the window so you can see two files in one window.
In the Edit menu, however, there are some special functions for programming. Here are some of my favorites:
* Indent and unindent blocks of text using the **Ctrl+[** or **Ctrl+]** keyboard shortcuts, which are useful not only for keeping HTML, CSS, and Javascript tidy but essential for Python code.
* Make a line into a comment with **Ctrl+/**. The way Brackets marks a comment depends on the language youre using, so this function works whether your document uses slashes, dashes, arrows, hashes, or anything else for commenting.
* Move a line up or down in your document with **Shift+Ctrl+Up** or **Shift+Ctrl+Down**.
* Delete an entire line with **Shift+Ctrl+D**.
* Duplicate a line with **Ctrl+D**.
These are all seemingly niche functions you might not think youll use often, but once you have them, you come to rely on them.
### Extensions
Brackets can also accept extensions so you and other coders can add to its features. To see what extensions are available, click the File menu and select Extension Manager. Theres a wide variety of extensions available, including Beautify to adjust code formatting, multiple support kits for additional languages, a function to go to the beginning or end of a tag, and much more.
Extensions can make all the difference to an editor and whether its right for you, so if you try Brackets and enjoy everything about it, but youre missing some vital feature, have a browse through the available extensions before you give up on it.
### Try Brackets
Brackets is a somewhat subdued editor. While it advertises itself as a "code editor for the web," its actually a nice general-purpose editor with some extra features thrown in for common web toolchains. If you like the look of Brackets and what it has to offer, give it a try!
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/brackets
作者:[Seth Kenlon][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://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_blue_text_editor_web.png?itok=lcf-m6N7 (Text editor on a browser, in blue)
[2]: http://brackets.io/
[3]: https://flathub.org/apps/details/io.brackets.Brackets
[4]: https://opensource.com/sites/default/files/screenshot_2020-12-02_at_16.26.58.png (Brackets editor)

View File

@ -0,0 +1,246 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Practice coding in Java by writing a game)
[#]: via: (https://opensource.com/article/20/12/learn-java)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Practice coding in Java by writing a game
======
Writing simple games is a fun way to learn a new programming language.
Put that principle to work to get started with Java.
![Learning and studying technology is the key to success][1]
My article about [learning different programming languages][2] lists five things you need to understand when starting a new language. An important part of learning a language, of course, is knowing what you intend to do with it.
I've found that simple games are both fun to write and useful in exploring a language's abilities. In this article, I demonstrate how to create a simple guessing game in Java.
### Install Java
To do this exercise, you must have Java installed. If you don't have it, check out these links to install Java on [Linux][3], [macOS, or Windows][4].
After installing it, run this Java command in a terminal to confirm the version you installed:
```
`$ java -version`
```
### Guess the number
This "guess the number" program exercises several concepts in programming languages: how to assign values to variables, how to write statements, and how to perform conditional evaluation and loops. It's a great practical experiment for learning a new programming language.
Here's my Java implementation:
```
package com.example.guess;
import java.util.Random;
import java.util.Scanner;
   
class Main {
    private static final [Random][5] r = new [Random][5]();
    private static final int NUMBER = r.nextInt(100) + 1;
    private static int guess = 0;
    public static void main([String][6][] args) {  
        Scanner player = new Scanner([System][7].in);
            [System][7].out.println("number is " + [String][6].valueOf(NUMBER)); //DEBUG
            while ( guess != NUMBER ) {
            // prompt player for guess
            [System][7].out.println("Guess a number between 1 and 100");
            guess = player.nextInt();
            if ( guess &gt; NUMBER ) {
                [System][7].out.println("Too high");
            } else if ( guess &lt; NUMBER ) {
                [System][7].out.println("Too low");
            } else {
                [System][7].out.println("That's right!");
                [System][7].exit(0);
            }
        }
  }
}
```
That's about 20 lines of code, excluding whitespace and trailing braces. Structurally, however, there's a lot going on, which I'll break down here.
#### Package declaration
The first line, `package com.example.guess`, is not strictly necessary in a simple one-file application like this, but it's a good habit to get into. Java is a big language, and new Java is written every day, so every Java project needs to have a unique identifier to help programmers tell one library from another.
When writing Java code, you should declare a `package` it belongs to. The format for this is usually a reverse domain name, such as `com.opensource.guess` or `org.slf4j.Logger`. As usual for Java, this line is terminated by a semicolon.
#### Import statements
The next lines of the code are import statements, which tell the Java compiler what libraries to load when building the executable application. The libraries I use here are distributed along with OpenJDK, so you don't need to download them yourself. Because they're not strictly a part of the core language, you do need to list them for the compiler.
The Random library provides access to pseudo-random number generation, and the Scanner library lets you read user input in a terminal.
#### Java class
The next part creates a Java class. Java is an object-oriented programming language, so its quintessential construct is a _class_. There are some very specific code ideas suggested by a class, and if you're new to programming, you'll pick up on them with practice. For now, think of a class as a box into which you place variables and code instructions, almost as if you were building a machine. The parts you place into the class are unique to that class, and because they're contained in a box, they can't be seen by other classes. More importantly, since there is only one class in this sample game, a class is self-sufficient: It contains everything it needs to perform its particular task. In this case, its task is the whole game, but in larger applications, classes often work together in a sort of daisy-chain to produce complex jobs.
In Java, each file generally contains one class. The class in this file is called `Main` to signify that it's the entry-point for this application. In a single-file application such as this, the significance of a main class is difficult to appreciate, but in a larger Java project with dozens of classes and source files, marking one `Main` is helpful. And anyway, it's easy to package up an application for distribution with a main class defined.
#### Java fields
In Java, as in C and C++, you must declare variables before using them. You can define "fields" at the top of a Java class. The word "field" is just a fancy term for a variable, but it specifically refers to a variable assigned to a class rather than one embedded somewhere in a function.
This game creates three fields: Two to generate a pseudo-random number, and one to establish an initial (and always incorrect) guess. The long string of keywords (`private static final`) leading up to each field may look confusing (especially when starting out with Java), but using a good IDE like Netbeans or Eclipse can help you navigate the best choice.
It's important to understand them, too. A _private_ field is one that's available only to its own class. If another class tries to access a private field, the field may as well not exist. In a one-class application such as this one, it makes sense to use private fields.
A _static_ field belongs to the class itself and not to a class instance. This doesn't make much difference in a small demo app like this because only one instance of the class exists. In a larger application, you may have a reason to define or redefine a variable each time a class instance is spawned.
A _final_ field cannot have its value changed. This application demonstrates this perfectly: The random number never changes during the game (a moving target wouldn't be very fair), while the player's guess _must_ change or the game wouldn't be winnable. For that reason, the random number established at the beginning of the game is final, but the guess is not.
#### Pseudo-random numbers
Two fields create the random number that serves as the player's target. The first creates an instance of the `Random` class. This is essentially a random seed from which you can draw a pretty unpredictable number. To do this, list the class you're invoking followed by a variable name of your choice, which you set to a new instance of the class: `Random r = new Random();`. Like other Java statements, this terminates with a semicolon.
To draw a number, you must create another variable using the `nextInt()` method of Java. The syntax looks a little different, but it's similar: You list the kind of variable you're creating, you provide a name of your choice, and then you set it to the results of some action: `int NUMBER = r.nextInt(100) + 1;`. You can (and should) look at the documentation for specific methods, like `nextInt()`, to learn how they work, but in this case, the integer drawn from the `r` random seed is limited _up to_ 100 (that is, a maximum of 99). Adding 1 to the result ensures that a number is never 0 and the functional maximum is 100.
Obviously, the decision to disqualify any number outside of the 1 to 100 range is a purely arbitrary design decision, but it's important to know these constraints before sitting down to program. Without them, it's difficult to know what you're coding toward. If possible, work with a person whose job it is to define the application you're coding. If you have no one to work with, make sure to list your targets first—and only then put on your "coder hat."
### Main method
By default, Java looks for a `main` method (or "function," as they're called in many other languages) to run in a class. Not all classes need a main method, but this demo app only has one method, so it may as well be the main one. Methods, like fields, can be made public or private and static or non-static, but the main method must be public and static for the Java compiler to recognize and utilize it.
### Application logic
For this application to work as a game, it must continue to run _while_ the player takes guesses at a secret pseudo-random number. Were the application to stop after each guess, the player would only have one guess and would very rarely win. It's also part of the game's design that the computer provides hints to guide the player's next guess.
A `while` loop with embedded `if` statements achieves this design target. A `while` loop inherently continues to run until a specific condition is met. (In this case, the `guess` variable must equal the `NUMBER` variable.) Each guess can be compared to the target `NUMBER` to prompt helpful hints.
### Syntax
The main method starts by creating a new `Scanner` instance. This is the same principle as the `Random` instance used as a pseudo-random seed: You cite the class you want to use as a template, provide a variable name (I use `player` to represent the person entering guesses), and then set that variable to the results of running the class' main method. Again, if you were coding this on your own, you'd look at the class' documentation to get the syntax when using it.
This sample code includes a debugging statement that reveals the target `NUMBER`. That makes the game moot, but it's useful to prove to yourself that it's working correctly. Even this small debugging statement reveals some important Java tips: `System.out.println` is a print statement, and the `valueOf()` method converts the integer `NUMBER` to a string to print it as part of a sentence rather than an element of math.
The `while` statement begins next, with the sole condition that the player's `guess` is not equal to the target `NUMBER`. This is an infinite loop that can end only when it's _false_ that `guess` does _not_ equal `NUMBER`.
In this loop, the player is prompted for a number. The Scanner object, called `player`, takes any valid integer entered by the player and puts its value into the `guess` field.
The `if` statement compares `guess` to `NUMBER` and responds with `System.out.println` print statements to provide feedback to the human player.
If `guess` is neither greater than nor less than `NUMBER`, then it must be equal to it. At this point, the game prints a congratulatory message and exits. As usual with [POSIX][8] application design, this game exits with a 0 status to indicate success.
### Run the game
To test your game, save the sample code as `Guess.java` and use the Java command to run it:
```
$ java ./Guess.java
number is 38
Guess a number between 1 and 100
1
Too low
Guess a number between 1 and 100
39
Too high
Guess a number between 1 and 100
38
That's right!
$
```
Just as expected!
### Package the game
While it isn't as impressive on a single-file application like this as it is on a complex project, Java makes packaging very easy. For the best results, structure your project directory to include a place for your source code, a place for your compiled class, and a manifest file. In practice, this is somewhat flexible, and using an IDE does most of the work for you. It's useful to do it by hand once in a while, though.
Create a project folder if you haven't already. Then create one directory called `src` to hold your source files. Save the sample code in this article as `src/Guess.java`:
```
$ mkdir src
$ mv sample.java src/Guess.java
```
Now, create a directory tree that mirrors the name of your Java package, which appears at the very top of your code:
```
$ head -n1 src/Guess.java
package com.example.guess;
$ mkdir -p com/example/guess
```
Create a new file called `Manifest.txt` with just one line of text in it:
```
`$ echo "Manifest-Version: 1.0" > Manifest.txt`
```
Next, compile your game into a Java class. This produces a file called `Main.class` in `com/example/guess`:
```
$ javac src/Guess.java -d com/example/guess
$ ls com/example/guess/
Main.class
```
You're all set to package your application into a JAR (Java archive). The `jar` command is a lot like the [tar][9] command, so many of the options may look familiar:
```
$ jar cfme Guess.jar \
Manifest.txt \
com.example.guess.Main \
com/example/guess/Main.class
```
From the syntax of the command, you may surmise that it creates a new JAR file called `Guess.jar` with its required manifest data located in `Manifest.txt`. Its main class is defined as an extension of the package name, and the class is `com/example/guess/Main.class`.
You can view the contents of the JAR file:
```
$ jar tvf Guess.jar
     0 Wed Nov 25 10:33:10 NZDT 2020 META-INF/
    96 Wed Nov 25 10:33:10 NZDT 2020 META-INF/MANIFEST.MF
  1572 Wed Nov 25 09:42:08 NZDT 2020 com/example/guess/Main.class
```
And you can even extract it with the `xvf` options.
Run your JAR file with the `java` command:
```
`$ java -jar Guess.jar`
```
Copy your JAR file from Linux to a macOS or Windows computer and try running it. Without recompiling, it runs as expected. This may seem normal if your basis of comparison is, say, a simple Python script that happens to run anywhere, but imagine a complex project with several multimedia libraries and other dependencies. With Java, those dependencies are packaged along with your application, and it _all_ runs on _any_ platform. Welcome to the wonderful world of Java!
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/learn-java
作者:[Seth Kenlon][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://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/studying-books-java-couch-education.png?itok=C9gasCXr (Learning and studying technology is the key to success)
[2]: https://opensource.com/article/20/10/learn-any-programming-language
[3]: https://opensource.com/article/19/11/install-java-linux
[4]: http://adoptopenjdk.org
[5]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+random
[6]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string
[7]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system
[8]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains
[9]: https://opensource.com/article/17/7/how-unzip-targz-file

View File

@ -0,0 +1,318 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Set up an Ansible lab in 20 minutes)
[#]: via: (https://opensource.com/article/20/12/ansible-lab)
[#]: author: (Mike Calizo https://opensource.com/users/mcalizo)
Set up an Ansible lab in 20 minutes
======
Build an environment to support learning and experimenting with new
software.
![Science lab with beakers][1]
Being able to build and tear down a public cloud environment is very useful, but most of us dont have easy access to a public cloud. The next best thing would be to have a lab on your local machine, but even running on a local machine brings performance, flexibility, and other challenges. Most of the time, the additional workloads on our local machines interfere with doing our daily job, and they certainly prevent having a readily available environment to play and experiment with new software.
My team and I encountered this challenge a few years ago when we were starting to learn [Ansible][2]. We couldnt find an environment that we could use individually, and our frustration with the situation caused some of us to stop experimenting. We knew we needed to find a solution.
We spent a lot of time researching the options and came up with a set of tools that enable our curiosity to learn in an environment we fully control. We can spin up and tear down the lab environment on our local machines without needing access to on-premises labs or public clouds.
This article will explain how to deploy your own lab environment on your local machine in as little as 20 minutes in a fully automated way.
You can find all the code for this exercise in my [GitHub repository][3].
### Tools and software
This solution uses the following tools and software:
* [Ansible][4] is our automation tool of choice because its easy to use and flexible enough to handle the lab requirements.
* [Vagrant][5] is easy to use for building and maintaining virtual machines.
* [VirtualBox][6] is a hosted hypervisor that works in Windows and Linux environments.
* [Fedora v30+][7] is the operating system on my local machine.
You must have the following set up to build the environment:
* An internet connection
* Virtualization Technology support enabled in your BIOS (here is the [procedure][8] for my Lenovo laptop)
* Vagrant v2.2.9
* The latest version of Ansible
* The latest version of VirtualBox
* Fedora v30+ host operating system
### Whats in the lab environment?
This project aims to deploy an Ansible host with an Ansible engine and multiple Linux nodes along with some pre-loaded and pre-configured applications (httpd and MySQL). It also enables [Cockpit][9] so that you can monitor the status of the virtual machines (VMs) during testing. The reason to use a pre-deployed application is for efficiency (so you dont have to spend time installing those components). This allows you to focus on creating roles and playbooks and testing against the environments deployed by the tools listed above.
We determined that the best scenario for our use case was a multi-machine Vagrant environment. The Vagrantfile creates three CentOS VMs to simulate two target hosts and an Ansible control machine:
* Host1: No graphical user interface (GUI), with httpd and MySQL installed
* Host2: No GUI, with httpd and MySQL installed
* Ansible-host: No GUI, with Ansible engine installed
### Enable multiple hypervisors
Some hypervisors may not allow you to bring up VMs if more than one hypervisor is in use. To fix this problem, follow these steps (based on Vagrants [installation][10] instructions).
First, find out the name of the hypervisor:
```
$ lsmod | grep kvm
kvm_intel             204800  6
kvm                   593920  1 kvm_intel
irqbypass              16384  1 kvm
```
The one Im interested in is `kvm_intel`, but you might want another (such as `kvm_amd`).
Run the following as root to blacklist the hypervisor:
```
`$ echo 'blacklist kvm-intel' >> /etc/modprobe.d/blacklist.conf`
```
Restart your machine and try running Vagrant again.
### The Vagrant file
```
cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# Define VMs with static private IP addresses, vcpu, memory and vagrant-box.
  boxes = [
    {
      :name =&gt; "web1.demo.com", ⇒ Host1 this is one of the target nodes
      :box =&gt; "centos/8",             ⇒ OS version
      :ram =&gt; 1024,                   ⇒ Allocated memory
      :vcpu =&gt; 1,               Allocated CPU
      :ip =&gt; "192.168.29.2"     ⇒ Allocated IP address of the node
    },
    {
      :name =&gt; "web2.demo.com", ⇒ Host2 this is one of the target nodes
      :box =&gt; "centos/8",
      :ram =&gt; 1024,
      :vcpu =&gt; 1,
      :ip =&gt; "192.168.29.3"
    },
    {
      :name =&gt; "ansible-host", ⇒ Ansible Host with Ansible Engine
      :box =&gt; "centos/8",
      :ram =&gt; 8048,
      :vcpu =&gt; 1,
      :ip =&gt; "192.168.29.4"
    }
  ]
  # Provision each of the VMs.
  boxes.each do |opts|
    config.vm.define opts[:name] do |config|
#   Only Enable this if you are connecting to Proxy server
#      config.proxy.http    = "<http://usernam:password@x.y:80"> Needed if you have a proxy
#      config.proxy.https   = "<http://usernam:password@x.y:80>"
#      config.proxy.no_proxy = "localhost,127.0.0.1"
      config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
      config.ssh.insert_key = false
      config.vm.box = opts[:box]
      config.vm.hostname = opts[:name]
      config.vm.provider :virtualbox do |v| ⇒  Defines the vagrant provider
        v.memory = opts[:ram]
        v.cpus = opts[:vcpu]
      end
      config.vm.network :private_network, ip: opts[:ip]
      config.vm.provision :file do |file|
         file.source     = './keys/vagrant' ⇒ vagrant keys to allow access to the nodes
         file.destination    = '/tmp/vagrant' ⇒ the location to copy the vagrant key
      end
      config.vm.provision :shell, path: "bootstrap-node.sh" ⇒ script that copy hosts entry
      config.vm.provision :ansible do |ansible| ⇒ declaration to run ansible playbook
        ansible.verbose = "v"
        ansible.playbook = "playbook.yml" ⇒ the playbook used to configure the hosts
      end
        end
  end
end
```
These are the important files that you need to pay attention to:
* `inventory-test.yaml`: The inventory file to connect to the nodes
* `playbook.yaml`: The playbook file that Vagrant provisioner calls to configure the nodes
* `Vagrantfile`: The file that Vagrant uses to deploy the environment
* `vagrant keys`: The Vagrant keys for connecting to the nodes in your lab environment
You can adjust these files based on your needs. Ansibles flexibility gives you the power to declaratively change your environment as you require.
### Deploy your lab environment
First, clone the code from the [GitHub repo][11]:
```
$ git clone <https://github.com/mikecali/ansible-labs-101.git>
Cloning into 'ansible-labs-101'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 15 (delta 2), reused 10 (delta 0), pack-reused 0
Unpacking objects: 100% (15/15), 6.82 KiB | 634.00 KiB/s, done.
```
Next, change your directory to `vagrant-session-2`, and view its contents:
```
$ ls
Bootstrap-node.sh   inventory   keys   playbook.yml   README.md Vagrantfile
```
You now have all the artifacts and configuration files you need for your lab environment. To deploy your environment, run:
```
`$ vagrant up`
```
With a decent internet connection, it takes only about 20 minutes to get a running environment:
```
$ vagrant up
Bringing machine 'web1.demo.com' up with 'virtualbox' provider...
Bringing machine 'web2.demo.com' up with 'virtualbox' provider...
Bringing machine 'ansible-host' up with 'virtualbox' provider...
==&gt; web1.demo.com: Importing base box 'centos/8'...
==&gt; web1.demo.com: Matching MAC address for NAT networking...
==&gt; web1.demo.com: Checking if box 'centos/8' version '1905.1' is up to date...
==&gt; web1.demo.com: Setting the name of the VM: ansible-labs_web1democom_1606434176593_70913
==&gt; web1.demo.com: Clearing any previously set network interfaces...
==&gt; web1.demo.com: Preparing network interfaces based on configuration...
    web1.demo.com: Adapter 1: nat
    web1.demo.com: Adapter 2: hostonly
==&gt; web1.demo.com: Forwarding ports...
    web1.demo.com: 22 (guest) =&gt; 2222 (host) (adapter 1)
==&gt; web1.demo.com: Running 'pre-boot' VM customizations...
==&gt; web1.demo.com: Booting VM...
==&gt; web1.demo.com: Waiting for machine to boot. This may take a few minutes...
    web1.demo.com: SSH address: 127.0.0.1:2222
    web1.demo.com: SSH username: vagrant
    web1.demo.com: SSH auth method: private key
[...]
```
Once the playbook execution completes, you will see output like this:
```
PLAY RECAP *********************************
Ansible-host     : ok=20 changed=11 unreachable=0 failed=0 skipped=0 rescued=0 ignored=3
Real 18m14.288s
User 2m26.978s
Sys 0m26.849s
```
Verify that all VMs are running:
```
$ vagrant status
Current machine states:
Web1.demo.com    running (virtualbox)
Web2.demo.com    running (virtualbox)
ansible-host     running (virtualbox)
[...]
```
You can investigate further by logging into one of the VMs. Access the ansible-host:
```
&gt; vagrant ssh ansible-host
Activate the web console with: systemctl enable --now cockpit.socket
Last login: Thu Nov 26 12:21:23 2020 from 10.0.2.2
[vagrant@ansible-host ~] uptime
16:46:42 up 1:24, 1 user, load average: 0.00, 0.01, 0.04
```
Finally, you can use the Ansible module to ping the other nodes you created:
```
[vagrant@ansible-host]$ ansible -i inventory-test.yaml \
webservers -m ping -u vagrant
192.168.29.2 | SUCCESS =&gt; {
  "Ansible-facts": {
      "Discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "Changed": false;
    "Ping": "pong"
}
[...]
```
### Clean up
Clean up your environment by running:
```
`$ vagrant destroy [vagrant machine name]`
```
Your output will look like this:
![Output from cleaning up environment][12]
(Michael Calizo, [CC BY-SA 4.0][13])
### Get creative to learn
Learning software like Ansible on your own time in your own lab is a good habit, but it can be difficult because of constraints that are out of your control.
Sometimes, you need to get creative and find another way. There are many options in the open source community you can choose from; one of the main reasons we picked these tools is because they are commonly used and familiar to many people.
Also, please note that these playbooks are not as optimized as I want. Please feel free to improve them and share your work in the comments.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/ansible-lab
作者:[Mike Calizo][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://opensource.com/users/mcalizo
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/science_experiment_beaker_lab.png?itok=plKWRhlU (Science lab with beakers)
[2]: https://opensource.com/resources/what-ansible
[3]: https://github.com/mikecali/ansible-labs-101
[4]: https://www.ansible.com/
[5]: https://www.vagrantup.com/
[6]: https://www.virtualbox.org/
[7]: https://getfedora.org/
[8]: https://support.lenovo.com/pt/en/solutions/ht500006
[9]: https://opensource.com/article/20/11/cockpit-server-management
[10]: https://www.vagrantup.com/docs/installation
[11]: https://github.com/mikecali/ansible-labs-101.git
[12]: https://opensource.com/sites/default/files/uploads/cleanup.png (Output from cleaning up environment)
[13]: https://creativecommons.org/licenses/by-sa/4.0/

View File

@ -0,0 +1,81 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Write in XML with the NetBeans text editor)
[#]: via: (https://opensource.com/article/20/12/netbeans)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Write in XML with the NetBeans text editor
======
NetBeans is a popular Java IDE, making it a handy text editor for
developers already using it.
![Coffee beans and a cup of coffee][1]
Ive spent a considerable amount of time in NetBeans, a Java IDE (integrated development environment) maintained by the Apache Foundation. I find its got a good mix of automated abstraction and manual configuration that helps me keep my Java projects organized and optimized. Not all IDEs give much thought to text files, but XML is frequently used in Java projects, so XML support in NetBeans is an important feature. It occurred to me that NetBeans, in addition to being an excellent Java IDE, could make for a nice XML editor, with the added benefit of being contained in a familiar application I already use.
### Install
Prior to installing NetBeans, you must ensure you have Java itself installed. The easiest way to install Java is to download a package from [adoptOpenJDK.net][2]. This site provides installer packages for all platforms. I prefer to use the LTS (long-term support) release, but if youre already a Java programmer, then you may have your own preference.
If youre using Linux and BSD, you can probably install NetBeans from your distributions software repository or ports tree. Alternatively, you can install it as a Flatpak from [Flathub][3].
On Windows and Mac (and Linux, if the other methods arent to your liking), you can install NetBeans directly from [netbeans.org][4].
![Black NetBeans terminal with white and yellow XML code ][5]
### XML in NetBeans 
NetBeans supports XML natively, so there are no plugins to install or hidden options to enable. However, NetBeans is project-centric. It assumes, by design, that every file you create belongs to a Java project. This doesnt have to be true, but every file you create does need to belong to a NetBeans project directory unless you open an existing one from an arbitrary place on your hard drive. You probably wont be opening NetBeans just to make a quick note to yourself, but if your use case (like mine) is for projects big enough to have an IDE open all day anyway, then NetBeans makes sense.
When you create a new XML Document, youre prompted to save it into a project directory. After naming your file, it opens as a tab in your NetBeans workspace. NetBeans is schema-aware, so you can set your schema from within an XML document. For example, [I love to write in Docbook][6], so I start my XML files with this declaration:
```
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;article xmlns="<http://docbook.org/ns/docbook>"
     xmlns:xlink="<http://www.w3.org/1999/xlink>"
     dtd="/usr/share/xml/docbook5/schema/dtd/5.0/docbook.dtd"
     version="5.0"
     xml:lang="en"&gt;
```
NetBeans recognizes this as a schema and namespace declaration and downloads the appropriate files.
```
Retrieving Location: <http://docbook.org/ns/docbook>
    Retrieved :    <https://docbook.org/ns/docbook>
    Saved at: /home/tux/.cache/netbeans/12.1/mavencachedirs/1391771919/retriever/docbook.org/ns/docbook.xml
```
Writing XML in NetBeans is a pleasure. It understands tags and how and when to close them. Tags are exempted from the spell checker. NetBeans also has a good syntax highlighting theme to make it easy for you to differentiate tag elements, attributes, and content. It provides code folding, so I can easily collapse blocks of text I dont need to see at any given time. You can hide and reveal folded text by clicking on the **-** or **+** icons on the left of each block. Alternatively, you can use the keyboard shortcut **[ +Ctrl+ + ±+ ]{.keycombo}** or **[ +Ctrl+ ++++ ]{.keycombo}**.
When you right-click on your editing window, you get an XML-specific menu with options to check your XML syntax and to validate your XML against a schema, and even to apply an XSL transform on your work.
There are many more features in NetBeans that arent specific to editing XML but are still useful. For instance, you can split your editing window in NetBeans, so you have multiple files open side by side. Line numbers down the left side of the window make it easy for you to navigate, and you can also create bookmarks in your file and then use them to quickly jump between points. Theres auto-indentation, code completion, an outline view, and a great interface, especially to those already familiar with it as a code editor.
### Try NetBeans 
NetBeans isnt the best choice for a general text editor. Its big, it has lots of options for very specific languages, and not much for anything else. However, if you write in XML on a regular basis, or if you just use NetBeans anyway, then it works great as a handy text editor. Why open a separate application when you have everything you need in your IDE already? Give NetBeans as a text editor a try!
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/netbeans
作者:[Seth Kenlon][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://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/java-coffee-mug.jpg?itok=Bj6rQo8r (Coffee beans and a cup of coffee)
[2]: https://adoptopenjdk.net/
[3]: https://flathub.org/apps/details/org.apache.netbeans
[4]: https://netbeans.apache.org/download/index.html
[5]: https://opensource.com/sites/default/files/uploads/netbeans-xml-31days-netbeans-opensource.png (Black NetBeans terminal with white and yellow XML code )
[6]: https://opensource.com/article/17/9/docbook

View File

@ -0,0 +1,107 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (6 container concepts you need to understand)
[#]: via: (https://opensource.com/article/20/12/containers-101)
[#]: author: (Mike Calizo https://opensource.com/users/mcalizo)
6 container concepts you need to understand
======
Containers are everywhere, and they've radically changed the IT
landscape. What do you need to know about them?
![Ships at sea on the web][1]
Containerization has radically changed the IT landscape because of the significant value and wide array of benefits it brings to business. Nearly any recent business innovation has containerization as a contributing factor, if not the central element.
In modern application architectures, the ability to deliver changes quickly to the production environment gives you an edge over your competitors. Containers deliver speed by using a microservices architecture that helps development teams create functionality, fail small, and recover faster. Containerization also enables applications to start faster and automatically scale cloud resources on demand. Furthermore, [DevOps][2] maximizes containerization's benefits by enabling the flexibility, portability, and efficiency required to go to market early.
While speed, agility, and flexibility are the main promises of containerization using DevOps, security is a critical factor. This led to the rise of DevSecOps, which incorporates security into application development from the start and throughout the lifecycle of a containerized application. By default, containerization massively improves security because it isolates the application from the host and other containerized applications.
### What are containers?
Containers are the solution to problems inherited from monolithic architectures. Although monoliths have strengths, they prevent organizations from moving fast the agile way. Containers allow you to break monoliths into [microservices][3].
Essentially, a container is an application bundle of lightweight components, such as application dependencies, libraries, and configuration files, that run in an isolated environment on top of traditional operating systems or in virtualized environments for easy portability and flexibility.
![Container architecture][4]
(Michael Calizo, [CC BY-SA 4.0][5])
To summarize, containers provide isolation by taking advantage of kernel technologies like cgroups, [kernel namespaces][6], and [SELinux][7]. Containers share a kernel with the host, which allows them to use fewer resources than a virtual machine (VM) would require.
### Container advantages
This architecture provides agility that is not feasible with VMs. Furthermore, containers support a more flexible model when it comes to compute and memory resources, and they allow resource-burst modes so that applications can consume more resources, when required, within the defined boundaries. In other words, containers provide scalability and flexibility that you cannot get from running an application on top of a VM.
Containers make it easy to share and deploy applications on public or private clouds. More importantly, they provide consistency that helps operations and development teams reduce the complexity that comes with multi-platform deployment.
Containers also enable a common set of building blocks that can be reused in any stage of development to recreate identical environments for development, testing, staging, and production, extending the concept of "write-once, deploy anywhere."
Compared to virtualization, containers make it simpler to achieve flexibility, consistency, and the ability to deploy applications faster—the main principles of DevOps.
### The Docker factor
[Docker][8] has become synonymous with containers. Docker revolutionized and popularized containers, even though the technology existed before Docker. Examples include AIX Workload partitions, Solaris Containers, and Linux containers ([LXC][9]), which was created to [run multiple Linux environments in a single Linux host][10].
### The Kubernetes effect
Kubernetes is widely recognized as the leading [orchestration engine][11]. In the last few years, [Kubernetes' popularity][12] coupled with maturing container adoption created the ideal scenario for ops, devs, and security teams to embrace the changing landscape.
Kubernetes provides a holistic approach to managing containers. It can run containers across a cluster to enable features like autoscaling cloud resources, including event-driven application requirements, in an automated and distributed way. This ensures high availability "for free" (i.e., neither developers nor admins expend extra effort to make it happen).
In addition, OpenShift and similar Kubernetes enterprise offerings make container adoption much easier.
![Kubernetes cluster][13]
(Michael Calizo, [CC BY-SA 4.0][5])
### Will containers replace VMs?
[KubeVirt][14] and similar [open source][15] projects show a lot of promise that containers will replace VMs. KubeVirt brings VMs into containerized workflows by converting the VMs into containers, where they run with the benefits of containerized applications.
Right now, containers and VMs work as complementary solutions rather than competing technologies. Containers run atop VMs to increase availability, especially for applications that require persistency, and take advantage of virtualization technology that makes it easier to manage the hardware infrastructure (like storage and networking) required to support containers.
### What about Windows containers?
There is a big push from Microsoft and the open source community to make Windows containers successful. Kubernetes Operators have fast-tracked Windows container adoption, and products like OpenShift now enable [Windows worker nodes][16] to run Windows containers.
Windows containerization creates a lot of enticing possibilities, especially for enterprises with mixed environments. Being able to run your most critical applications on top of a Kubernetes cluster is a big advantage towards achieving a hybrid- or multi-cloud environment.
### The future of containers
Containers play a big role in the shifting IT landscape because enterprises are moving towards fast, agile delivery of software and solutions to [get ahead of competitors][17].
Containers are here to stay. In the very near future, other use cases, like serverless on the edge, will emerge and further change how we think about the speed of getting information to and from digital devices. The only way to survive these changes is to adapt to them.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/containers-101
作者:[Mike Calizo][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://opensource.com/users/mcalizo
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/kubernetes_containers_ship_lead.png?itok=9EUnSwci (Ships at sea on the web)
[2]: https://opensource.com/resources/devops
[3]: https://opensource.com/resources/what-are-microservices
[4]: https://opensource.com/sites/default/files/uploads/container_architecture.png (Container architecture)
[5]: https://creativecommons.org/licenses/by-sa/4.0/
[6]: https://opensource.com/article/19/10/namespaces-and-containers-linux
[7]: https://opensource.com/article/20/11/selinux-containers
[8]: https://opensource.com/resources/what-docker
[9]: https://linuxcontainers.org/
[10]: https://opensource.com/article/18/11/behind-scenes-linux-containers
[11]: https://opensource.com/article/20/11/orchestration-vs-automation
[12]: https://enterprisersproject.com/article/2020/6/kubernetes-statistics-2020
[13]: https://opensource.com/sites/default/files/uploads/kubernetes_cluster.png (Kubernetes cluster)
[14]: https://kubevirt.io/
[15]: https://opensource.com/resources/what-open-source
[16]: https://www.openshift.com/blog/announcing-the-community-windows-machine-config-operator-on-openshift-4.6
[17]: https://www.imd.org/research-knowledge/articles/the-battle-for-digital-disruption-startups-vs-incumbents/

View File

@ -0,0 +1,175 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (9 things to do in your first 10 minutes on a Linux server)
[#]: via: (https://opensource.com/article/20/12/linux-server)
[#]: author: (Gaurav Kamathe https://opensource.com/users/gkamathe)
9 things to do in your first 10 minutes on a Linux server
======
Before putting a newly provisioned server to work, make sure you know
what you're working with.
![Parts, modules, containers for software][1]
When I test software on Linux (a regular part of my job), I need to use multiple servers with various architectures running Linux. I provision the machines, install the required software packages, run my tests, gather the results, and return the machine to the pool so that others can use it for their tests.
Since I do this so often (even multiple times a day), my first 10 minutes on a Linux server have become a daily ritual. When I first log into a Linux server, I look for certain things using commands to gather the information I need. I'll go through my process in this article, but please note that, in most cases, I'll just give the command name, so you will need to identify the specific flags for those commands to get the information that you need. Reading man pages for the commands is a good starting point.
### 1\. First contact
As soon as I log into a server, the first thing I do is check whether it has the operating system, kernel, and hardware architecture needed for the tests I will be running. I often check how long a server has been up and running. While this does not matter very much for a test system because it will be rebooted multiple times, I still find this information helpful.
Use the following commands to get this information. I mostly use Red Hat Linux for testing, so if you are using another Linux distro, use `*-release` in the filename instead of `redhat-release`:
```
cat /etc/redhat-release
uname -a
hostnamectl
uptime
```
### 2\. Is anyone else on board?
Once I know that the machine meets my test needs, I need to ensure no one else is logged into the system at the same time running their own tests. Although it is highly unlikely, given that the provisioning system takes care of this for me, it's still good to check once in a while—especially if it's my first time logging into a server. I also check whether there are other users (other than root) who can access the system.
Use the following commands to find this information. The last command looks for users in the `/etc/passwd` file who have shell access; it skips other services in the file that do not have shell access or have a shell set to `nologin`:
```
who
who -Hu
grep sh$ /etc/passwd
```
### 3\. Physical or virtual machine
Now that I know I have the machine to myself, I need to identify whether it's a physical machine or a virtual machine (VM). If I provisioned the machine myself, I could be sure that I have what I asked for. However, if you are using a machine that you did not provision, you should check whether the machine is physical or virtual.
Use the following commands to identify this information. If it's a physical system, you will see the vendor's name (e.g., HP, IBM, etc.) and the make and model of the server; whereas, in a virtual machine, you should see KVM, VirtualBox, etc., depending on what virtualization software was used to create the VM:
```
dmidecode -s system-manufacturer
dmidecode -s system-product-name
lshw -c system | grep product | head -1
cat /sys/class/dmi/id/product_name
cat /sys/class/dmi/id/sys_vendor
```
### 4\. Hardware
Because I often test hardware connected to the Linux machine, I usually work with physical servers, not VMs. On a physical machine, my next step is to identify the server's hardware capabilities—for example, what kind of CPU is running, how many cores does it have, which flags are enabled, and how much memory is available for running tests. If I am running network tests, I check the type and capacity of the Ethernet or other network devices connected to the server.
Use the following commands to display the hardware connected to a Linux server. Some of the commands might be deprecated in newer operating system versions, but you can still install them from yum repos or switch to their equivalent new commands:
```
lscpu or cat /proc/cpuinfo
lsmem or cat /proc/meminfo
ifconfig -a
ethtool &lt;devname&gt;
lshw
lspci
dmidecode
```
### 5\. Installed software
Testing software always requires installing additional dependent packages, libraries, etc. However, before I install anything, I check what is already installed (including what version it is), as well as which repos are configured, so I know where the software comes from, and I can debug any package installation issues.
Use the following commands to identify what software is installed:
```
rpm -qa
rpm -qa | grep &lt;pkgname&gt;
rpm -qi &lt;pkgname&gt;
yum repolist
yum repoinfo
yum install &lt;pkgname&gt;
ls -l /etc/yum.repos.d/
```
### 6\. Running processes and services
Once I check the installed software, it's natural to check what processes are running on the system. This is crucial when running a performance test on a system—if a running process, daemon, test software, etc. is eating up most of the CPU/RAM, it makes sense to stop that process before running the tests. This also checks that the processes or daemons the test requires are up and running. For example, if the tests require httpd to be running, the service to start the daemon might not have run even if the package is installed.
Use the following commands to identify running processes and enabled services on your system:
```
pstree -pa 1
ps -ef
ps auxf
systemctl
```
### 7\. Network connections
Today's machines are heavily networked, and they need to communicate with other machines or services on the network. I identify which ports are open on the server, if there are any connections from the network to the test machine, if a firewall is enabled, and if so, is it blocking any ports, and which DNS servers the machine talks to.
Use the following commands to identify network services-related information. If a deprecated command is not available, install it from a yum repo or use the equivalent newer command:
```
netstat -tulpn
netstat -anp
lsof -i
ss
iptables -L -n
cat /etc/resolv.conf
```
### 8\. Kernel
When doing systems testing, I find it helpful to know kernel-related information, such as the kernel version and which kernel modules are loaded. I also list any [tunable kernel parameters][2] and what they are set to and check the options used when booting the running kernel.
Use the following commands to identify this information:
```
uname -r
cat /proc/cmdline
lsmod
modinfo &lt;module&gt;
sysctl -a
cat /boot/grub2/grub.cfg
```
### 9\. Logs
By now, I have a good idea about the server, including what software is installed and what processes are running. One other thing I cannot escape is log files—I need to know where to check the information that is continuously being updated.
Use the following commands to see your system's logs:
```
dmesg
tail -f /var/log/messages
journalctl
```
### Next steps
While commands and utilities will change, the underlying information they show remains more or less the same. You need a high-level view of the information you are looking for and what category it falls into before you can focus on which commands to master.
Since Linux saves most information in files, these commands basically read information from the files and present them in an easy-to-understand way. A good next step is to identify the files each command uses to get the information to display. A hint for finding that information is the `strace` command.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/linux-server
作者:[Gaurav Kamathe][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://opensource.com/users/gkamathe
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/containers_modules_networking_hardware_parts.png?itok=rPpVj92- (Parts, modules, containers for software)
[2]: https://www.oreilly.com/library/view/red-hat-enterprise/9781785283550/ch10s05.html

View File

@ -0,0 +1,65 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Cut your Cloud Computing Costs by Half with Unikraft)
[#]: via: (https://www.linux.com/news/cut-your-cloud-computing-costs-by-half-with-unikraft/)
[#]: author: (Linux.com Editorial Staff https://www.linux.com/author/linuxdotcom/)
Cut your Cloud Computing Costs by Half with Unikraft
======
***A novel modular unikernel allows for extreme tailoring of your operating system to your applications needs. A proof of concept, built on Unikraft, a Xen Project subproject, shows up to 50% efficiency improvements than standard Linux on AWS EC2. ***
Cloud computing has revolutionized the way we think about IT infrastructure: Another web server? More database capacity? Resources for your artificial intelligence use case? Just spin-up another instance, and you are good to go. Virtualization and containers have allowed us to deploy services without worrying about physical hardware constraints. As a result, most companies heavily rely on micro-services, which are individual servers highly specialized to perform a specific task.
The problem is that general-purpose operating systems such as Linux struggle to keep pace with this growing trend towards specialization. The status quo is that most microservices are built on top of a complete Linux kernel and distribution. It is as if you wanted to enable individual air travel with only one passenger seat per aircraft but kept the powerful engines of a jumbo jet. The result of having a proliferation of general-purpose OSes in the cloud are bloated instances, that feast on memory and processing power while uselessly burning electrical energy as well as your infrastructure budget.
![Figure 1. Linux kernel components have strong inter-dependencies making it difficult to remove or replace them.][1]
Despite this, putting Linux and other monolithic OSes on a diet is far from trivial. Removing unneeded components from the Linux kernel is a tedious endeavor due to the interdependencies among subsystems of the kernel: Figure 1 above illustrates a large number of such inter-dependencies a line denotes a dependency and a blue number the amount of such dependencies between two components. 
An alternative is to build so-called _unikernels_, images tailored to specific applications and often built on much smaller kernels. Unikernels have shown great promise and performance numbers (e.g., boot times of a few milliseconds, memory consumption when running off-the-shelf applications such as nginx of only a few MBs, and high throughput). However, their Achilles heel has been that they often require substantial expert work to create them and that at least part of the work has to be redone for each additional application. These issues, coupled with the fact that most unikernel projects dont have a rich set of tools and ecosystem (e.g., Kubernetes integration, debugging and monitoring tools, etc.), resulting in 1GB Linux instances for jobs that might be as easy as delivering static web pages. 
## **Unikraft: A Revolutionary Way Forward**
[Unikraft][2] is on a mission to change that. In stark contrast to other unikernel projects, Unikraft, a  Xen Project subproject, has developed a truly modular unikernel common code base from which building tailored made (uni)kernels is orders of magnitude faster than in the past.
 “Without Unikraft, you have to choose between unikernel projects that only work for a specific language or application, or projects that aim to support POSIX but do so while sacrificing performance and thus defeating the purpose of using unikernels in the first place”, says Felipe Huici, one of the Unikraft teams core contributors. “
Unikraft aims to run a large set of off-the-shelf application and languages (C/C++, Python, Go, Ruby, Lua, and WASM are supported, with Rust and Java on the way), but still allows for easy customization and even removal of unneeded kernel parts; also, it provides a set of rich, performance-oriented APIs that allows further customization by plugging the application at different levels of the stack for even higher performance.” 
A sample of such APIs are shown in Figure 2 below.
![Figure 2. Rhea architecture \(APIs in black boxes\) enables specialization by allowing apps to plug into APIs at different levels and to choose from multiple API implementations.][3]
Unikraft already supports more than 130 syscalls in terms of POSIX compatibility, and the number is continuously increasing. While this is certainly short of the 300+ that Linux supports, it turns out that only a subset of these are needed for running most of the major server applications. This, and ongoing efforts to support standard frameworks such as Kubernetes and Prometheus make Unikraft an enticing proposition and mark the coming of age of unikernels into the mainstream.
## **Unikraft Goes to the Cloud**
But whats really in it for end-users? To demonstrate the power and efficiency of Unikraft, the team created an experimental Unikraft AWS EC2 image running nginx, currently the worlds most popular web server. “Weve built a Unikraft nginx image and compared it to a ngnix running on an off-the-shelf Debian image to compare the performance of the two when serving static web pages. Weve been more than pleased with the results” says Huici. “On Unikraft, nginx could handle twice the number of requests per second compared to the Debian instance. Or you could take a less performant AWS EC2 instance at half the price and get the same job done. Further, Unikraft needed about a sixth the amount of memory to run”.  The throughput results can be seen in Figure 3 below.
![][4]
So far, this is only a proof of concept, but Huici and the Unikraft team are moving quickly. “We are currently working on a system to make the process of creating a Unikraft image as easy as online-shopping” this includes analyzing the applications which are meant to run on top of it and providing a ready-to-use operating system that has everything the specific use case needs, and nothing more. “Why should we waste money, resources, and pollute the environment running software in the background that is not needed for a specific service?”
_**About the author: Simon Kuenzer is the Project Lead and Maintainer of Unikraft, which is part of the Xen Project at the Linux Foundation.**_
--------------------------------------------------------------------------------
via: https://www.linux.com/news/cut-your-cloud-computing-costs-by-half-with-unikraft/
作者:[Linux.com Editorial Staff][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://www.linux.com/author/linuxdotcom/
[b]: https://github.com/lujun9972
[1]: https://www.linux.com/wp-content/uploads/2020/12/unikraft1.png
[2]: https://xenproject.org/developers/teams/unikraft/
[3]: https://www.linux.com/wp-content/uploads/2020/12/unikraft2.png
[4]: https://www.linux.com/wp-content/uploads/2020/12/unikraft3.png

View File

@ -0,0 +1,149 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Resize Images with Right Click on Linux)
[#]: via: (https://www.2daygeek.com/how-to-resize-images-with-right-click-on-linux/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
How to Resize Images with Right Click on Linux
======
Do you often manipulate images as part of your daily job?
I personally need to do the graphics work for this website before uploading it to my blog.
One of the most common image editing tasks is resizing, which tremendously reduces the image size from MB to KB.
This allows images to load quickly on the web even if someone uses a slow internet.
I usually use the ImageMagick tool to perform this operation from the command line.
But I recommend using the “Nautilus Image Converter” which gets integrated in the right-click context menu in the image file.
It is very handy and works well in a second. But if you want to perform this action in bulk. I would recommend using the **[ImageMagick tool][1]** because it comes with a batch operation.
### Whats Nautilus?
Nautilus is a file manager used by GNOME and several other desktop environments. It provides a simple and integrated way to manage your files and applications.
The file manager lets you organize your files into folders. This is similar to “File Explorer” in Windows.
### How to Install Nautilus Image Converter Plugin?
There are many Nautilus plugins that enhance its capabilities. They are not installed by default, but you can choose to install them according to your needs.
We are going to install a plugin called Image Manipulator,, which allows you to rotate or resize images by right-clicking on an image.
Run the command below to see if your Linux system uses Nautilus File Manager.
```
$ nautilus --version
GNOME nautilus 3.36.3
```
If you have Nautilus file manager on your system, you will get the same results as above, but the version may vary.
Make sure you already have ImageMagick installed on your system, as this plugin uses ImageMagick for image manipulation. If not, you need to install it.
**Make a note:** Make sure you already have “**[Development Tools][2]**” installed on your Linux system as a prerequisite for this.
For **RHEL/CentOS 6/7** systems, use the **[yum command][3]** to install ImageMagick.
```
$ sudo yum install -y ImageMagick ImageMagick-devel
```
For **RHEL/CentOS 8** and **Fedora** systems, use the **[dnf command][4]** to install ImageMagick.
```
$ sudo dnf install -y ImageMagick ImageMagick-devel
```
For **Debian/Ubuntu** systems, use the **[apt command][5]** or **[apt-get command][6]** to install ImageMagick.
```
$ sudo apt-get update
$ sudo apt-get install imagemagick
```
For **openSUSE** systems, use the **[zypper command][7]** to install ImageMagick.
```
$ sudo zypper install -y ImageMagick
```
Finally install the Nautilus plugin using the commands below.
For **Ubuntu/Debian** system:
```
$ sudo apt install nautilus-image-converter
```
For **Fedora** system:
```
$ sudo dnf install nautilus-image-converter
```
For **Manjaro/ArchLinux** system:
```
$ sudo pacman -S nautilus-image-converter
```
For **openSUSE** system:
```
$ sudo zypper install nautilus-image-converter
```
Once installed, restart Nautilus using the command below.
```
$ nautilus -q
```
### How to Use Nautilus Image Converter Plugin?
You have finished the installation. Now if you right click on an image, you will see two new options in the context menu, **“Resize”** and **“Rotate”**.
![][8]
When you select the resize option in the context menu, you will get a pop-up window below with some options for resizing the image.
* **Select a size:** Select the image size you want to resize. In the drop-down, you will get the following pixels 96×96, 128×128, 640×480, 800×600, 1024×768 or 1280×960.
* **Scale:** This is the compression level. By default, it comes with 50% and you can change this based on your needs. I recommend using the default value.
* **Custom size:** This allows you to set any custom size you want to resize the image to.
* **Append:** By default, it adds “.resized” to the converted image file name, which helps to retain the original image file.
* **Resize in place:** You can change the behavior above by selecting this option. This option replaces the original image with a modified image.
![][8]
Click the **“Resize”** button to complete the image conversion.
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/how-to-resize-images-with-right-click-on-linux/
作者:[Magesh Maruthamuthu][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://www.2daygeek.com/author/magesh/
[b]: https://github.com/lujun9972
[1]: https://www.2daygeek.com/resize-convert-images-from-linux-command-line/
[2]: https://www.2daygeek.com/install-development-tools-on-ubuntu-debian-arch-linux-mint-fedora-centos-rhel-opensuse/
[3]: https://www.2daygeek.com/linux-yum-command-examples-manage-packages-rhel-centos-systems/
[4]: https://www.2daygeek.com/linux-dnf-command-examples-manage-packages-fedora-centos-rhel-systems/
[5]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/
[6]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/
[7]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/
[8]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7

View File

@ -0,0 +1,193 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to View Images from the Linux Terminal)
[#]: via: (https://www.2daygeek.com/how-to-view-display-images-from-linux-terminal/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
How to View Images from the Linux Terminal
======
Linux has many GUI applications for viewing images.
But I have never tried any CLI applications to see it.
Fortunately while working with the **[ImageMagick tool][1]** I got a command to view an image from the terminal.
The command name is **“display”**, which is part of the ImageMagick tool.
This is a great tool that allows NIX users to view images from the terminal.
Also, I got another great tool called FIM for this purpose.
We will show you how to install and use it to view images from the Linux terminal.
These commands use the systems framebuffer to display images directly from the command line.
### How to View Images from Terminal Using display Command
[ImageMagick][2] is a free and open source, feature-rich, command-line based image manipulation tool.
It used to create, edit, compose, or convert bitmap images.
It can read and write images in a variety of formats (over 200) including PNG, JPEG, GIF, PDF, SVG and etc,.
It can resize, mirror, rotate, transform images, adjust image colors, apply various special effects, etc,.
It supports batch process, which allow you to processes all images at once.
### How to Install ImageMagick?
The ImageMagick package is included in the official repository of most Linux distributions. Use the distribution package manager to install it.
**Make a note:** Make sure you already have “**[Development Tools][3]**” installed on your Linux system as a prerequisite for this.
For **RHEL/CentOS 6/7** systems, use the **[yum command][4]** to install ImageMagick.
```
$ sudo yum install -y ImageMagick ImageMagick-devel
```
For **RHEL/CentOS 8** and **Fedora** systems, use the **[dnf command][5]** to install ImageMagick.
```
$ sudo dnf install -y ImageMagick ImageMagick-devel
```
For **Debian/Ubuntu** systems, use the **[apt command][6]** or **[apt-get command][7]** to install ImageMagick.
```
$ sudo apt-get update
$ sudo apt-get install imagemagick
```
For **openSUSE** systems, use the **[zypper command][8]** to install ImageMagick
```
$ sudo zypper install -y ImageMagick
```
To view any image file, run display command as follows. You can close the image by pressing the **“Esc/q”** button.
```
$ display bird.jpg
```
![][9]
If you want to open the image with the specified size of the window, use the **“-geometry”** flag.
```
$ display -geometry 1000x600 ~/Downloads/bird.jpg
```
You can also input position information of the image with display command. The below command open your image 800 pixels from the top and 800 pixels from the top left corner of your desktop.
```
$ display -geometry 1000x600+800+800 ~/Downloads/bird.jpg
```
If you want to resize the image with the display command, use the following format.
```
$ display -resize 600x400 ~/Downloads/bird.jp
```
Alternatively, you can use percentage to resize the image.
```
$ display -resize 50% ~/Downloads/bird.jpg
```
### How to View Images from the Terminal Using fim Command
[FIM][10] is a lightweight global image viewer designed specifically for Linux.
But it is not limited to Linux and can be configured to run on other OS such as MS-Windows.
Its highly customizable and scriptable image viewer for users who are familiar with software like the VIM text editor.
It displays the image in full screen and can be easily controlled using the keyboard shortcuts.
It is very lightweight tool because it only depends on certain libraries.
It can open many file formats and it can display images in the following video modes.
* Graphically, with the Linux framebuffer device
* Graphically, under X/Xorg, using the SDL library
* Graphically, under X/Xorg, using the Imlib2 library
* Rendered as ASCII Art in any textual console, using the AAlib library
The right video mode gets auto-detected or selected at runtime, and may be opted in/out before build at configure time, if desired.
FIM stands for Fbi IMproved, which is the fork of the Fbi Image viewer.
FIM can be easily installed on Debian/Ubuntu based systems as the package is available in the distribution official repository. For other distributions, you may need to compile it from the source.
```
$ sudo apt install fim
```
Once installed, you can display an image using the following command.
```
$ fim bird.jpg
```
You can automatically zoom an image using the **“-a”** option.
```
$ fim -a bird.jpg
```
![][9]
If you want to open multiple image files in the current directory, use the wildcard to open them all. Use the **“Pageup/Down”** keyboard shortcuts to move to the next or previous image.
```
$ fim -a *.jpg
```
To view the image in ASCII format, you can use the **“-t”** flag.
```
$ fim -t bird.jpg
```
The below keyboard shortcuts allow you to control the images.
* PageUp/Down : Prev/Next image
* +/- : Zoom in/out
* a : Autoscale
* w : Fit to width
* ESC/q : Quit
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/how-to-view-display-images-from-linux-terminal/
作者:[Magesh Maruthamuthu][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://www.2daygeek.com/author/magesh/
[b]: https://github.com/lujun9972
[1]: https://www.2daygeek.com/resize-convert-images-from-linux-command-line/
[2]: https://imagemagick.org/
[3]: https://www.2daygeek.com/install-development-tools-on-ubuntu-debian-arch-linux-mint-fedora-centos-rhel-opensuse/
[4]: https://www.2daygeek.com/linux-yum-command-examples-manage-packages-rhel-centos-systems/
[5]: https://www.2daygeek.com/linux-dnf-command-examples-manage-packages-fedora-centos-rhel-systems/
[6]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/
[7]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/
[8]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/
[9]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[10]: https://www.nongnu.org/fbi-improved/#docs

View File

@ -0,0 +1,273 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to use Kubernetes resource quotas)
[#]: via: (https://opensource.com/article/20/12/kubernetes-resource-quotas)
[#]: author: (Mike Calizo https://opensource.com/users/mcalizo)
How to use Kubernetes resource quotas
======
Resource quotas prevent resource contention and "land grabs" by
controlling how much CPU or memory an application can consume.
![Jars with food inside on a shelf][1]
"Control" is the word that comes to mind when someone mentions they need to manage Kubernetes compute resources, especially CPU and memory. These conversations generally happen after the [Kubernetes][2] platform has been deployed for a while and developers are using the cluster extensively. And most of the time, the topic comes up after a problem happens.
Resource issues are common when the Kubernetes implementation is deployed without consideration for the cluster's future growth. Issues may also be related to the team's experience level that deploys and manages the Kubernetes cluster.
Without controls, one rogue application or developer can disrupt business. This inadvertently happens when several developers share a cluster with a fixed number of nodes. These resource constraints can start disagreements, finger-pointing, and "land-grabbing" of available resources among developers. It's a very bad situation for cluster administrators and developers alike.
There are several ways to manage how applications utilize computing resources in the Kubernetes environment. Most of the time, resource quotas and limit ranges are enough. Note that in Kubernetes, storage management takes an unusual approach by using a Persistent Volume plugin where properties to address and control different storage requirements are defined.
Kubernetes resource quotas are a way to control how computing resources are used. This article will show you how to use this feature to manage developers' behavior and control application resource consumption.
### What are resource quotas?
In short, [resource quotas][3] provide constraints that limit resource consumption per namespace. They can be applied only at the namespace level, which means they can be applied to computing resources and limit the number of objects inside the namespace.
A Kubernetes resource quota is defined by a `ResourceQuota` object. When applied to a namespace, it can limit computing resources such as CPU and memory as well as the creation of the following objects:
* Pods
* Services
* Secrets
* Persistent Volume Claims (PVCs)
* ConfigMaps
Kubernetes supports two types of CPU and memory quotas to manage compute resources. These are controlled via limits and requests, as the [LimitRange][4] documentation explains.
In short, a _request_ defines the guaranteed CPU or memory resources for containers, while a _limit_ is the memory or CPU threshold that a container can use, depending on what is available based on other containers' usage.
This image illustrates the difference between requests and limits in Kubernetes resource quotas.
![Requests and limits in Kubernetes resource quotas][5]
(Michael Calizo, [CC BY-SA 4.0][6])
The following exercise demonstrates how to use resource quotas to create constraints that limit an application to certain resources based on a defined threshold. It also shows the usefulness of implementing resource quotas to gain control over your Kubernetes implementation.
### Prerequisites
Before starting, make sure you have Kubernetes deployed in your local machine. Here is my configuration:
* [Minikube][7] v1.14.2
* Fedora 33 operating system
* Internet access
If you need help deploying Minikube on your Linux laptop, you can follow the steps in Bryant Son's [_Getting started with Minikube_][7]. Or, if you're on Windows or macOS, you can follow [these steps][8].
### Set up a resource quota
This example creates a CPU quota, but the process is similar for a memory quota or a combination of the two.
In a real production scenario, CPU resources are usually at the top of the computing resources you need to manage to avoid resource contention. This is true whenever you have multiple applications running on top of your server (compute).
Start by creating a new namespace where you will apply your CPU quota:
```
$ kubectl create namespace quota-test
namespace/quota-test created
```
Create a file named `cpu-quota.yaml` and put the following quota (created for this demo) into it:
```
apiVersion: v1
kind: ResourceQuota
metadata:
  name: test-cpu-quota
spec:
  hard:
    requests.cpu: "100m"  
    limits.cpu: "200m"
```
Apply the quota to your Kubernetes cluster with:
```
$ kubectl apply -f cpu-qouta.yaml
resourcequota/test-cpu-quota created
```
Verify that the quota was applied with the `kubectl describe` command:
```
$ kubectl describe resourcequota/test-cpu-quota --namespace quota-test
Name:         test-cpu-quota
Namespace:    quota-test
Resource      Used  Hard
\--------      ----  ----
limits.cpu    0     200m
requests.cpu  0     100m
```
Notice the `Used resources` column; this value will change as you deploy pods.
Now that you've defined your quota, test it. For this example, deploy three different pods in the same namespace to see if you can control the resources' usage based on the limits you defined. The three pods are:
* **PodA:** This pod, the first to be instantiated, will use 50% of the available CPU.
* **PodB:** This pod will use the other 50% of the available CPU; it will be the second pod instantiated.
* **PodC:** The defined quota should prevent this third pod from being deployed.
Now that you know the scenario, deploy the pods.
#### Deploy the pods
**PodA:**
```
$ kubectl create -n quota-test -f- &lt;&lt;EOF
apiVersion: v1
kind: Pod
metadata:
  name: poda
spec:
  containers:
  - name: quota-test
    image: busybox
    imagePullPolicy: IfNotPresent
    command: ['sh', '-c', 'echo Pod is Running ; sleep 5000']
    resources:
      requests:
        cpu: "50m"
      limits:
        cpu: "100m"
  restartPolicy: Never
EOF
```
Verify the CPU use by describing the quota again and noting the `Used CPU` value limits and requests:
```
$ kubectl describe resourcequota/test-cpu-quota --namespace quota-test
Name:         test-cpu-quota
Namespace:    quota-test
Resource      Used  Hard
\--------      ----  ----
limits.cpu    100m  200m
requests.cpu  50m   100m
```
**PodB:**
```
$ kubectl create -n quota-test -f- &lt;&lt;EOF
apiVersion: v1
kind: Pod
metadata:
  name: podb
spec:
  containers:
  - name: quota-test
    image: busybox
    imagePullPolicy: IfNotPresent
    command: ['sh', '-c', 'echo Pod is Running ; sleep 5000']
    resources:
      requests:
        cpu: "50m"
      limits:
        cpu: "100m"
  restartPolicy: Never
EOF
```
Check the CPU resource usage again. As expected, PodB can be scheduled because the quota allows it:
```
$ kubectl describe resourcequota/test-cpu-quota --namespace quota-test
Name:         test-cpu-quota
Namespace:    quota-test
Resource      Used  Hard
\--------      ----  ----
limits.cpu    200m  200m
requests.cpu  100m  100m
```
**PodC:**
Now, try to instantiate the third pod, even though you know PodA and Pod B maximized the CPU quota threshold you defined:
```
$ kubectl create -n quota-test -f- &lt;&lt;EOF
apiVersion: v1
kind: Pod
metadata:
  name: podc
spec:
  containers:
  - name: quota-test
    image: busybox
    imagePullPolicy: IfNotPresent
    command: ['sh', '-c', 'echo Pod is Running ; sleep 5000']
    resources:
      requests:
        cpu: "5m"
      limits:
        cpu: "10m"
  restartPolicy: Never
EOF
```
As expected, the third pod will not instantiate because the defined quota prevents creating the pods:
```
`Error from server (Forbidden): error when creating "STDIN": pods "podc" is forbidden: exceeded quota: test-cpu-quota, requested: limits.cpu=10m,requests.cpu=5m, used: limits.cpu=200m,requests.cpu=100m, limited: limits.cpu=200m,requests.cpu=100m`
```
As this example shows, properly defined resource quotas are a powerful tool that a Kubernetes admin can utilize to manage developer behavior.
### Clean up
Delete the namespace you created (in this case, `quota-test`):
```
`$ kubectl delete -n quota-test`
```
### Planning your quotas
There are many ways to control how users can deploy applications to avoid "land grabbing" in a Kubernetes cluster. Having a sound implementation of quotas, limit ranges, and other native features contributes to a cluster's stability.
Implementing resource quotas on computing resources is an important design decision that you need to think carefully about—especially when deploying Kubernetes for running business-critical enterprise applications.
When defining quotas, it's important to include developers in your planning. Because of their application knowledge, they are your best resources for estimating what's required.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/kubernetes-resource-quotas
作者:[Mike Calizo][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://opensource.com/users/mcalizo
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_secret_ingredient_520x292.png?itok=QbKzJq-N (Jars with food inside on a shelf)
[2]: https://kubernetes.io/
[3]: https://kubernetes.io/docs/concepts/policy/resource-quotas
[4]: https://kubernetes.io/docs/concepts/policy/limit-range/
[5]: https://opensource.com/sites/default/files/uploads/resourcequota_requests-limits.png (Requests and limits in Kubernetes resource quotas)
[6]: https://creativecommons.org/licenses/by-sa/4.0/
[7]: https://opensource.com/article/18/10/getting-started-minikube
[8]: https://www.liquidweb.com/kb/how-to-install-minikube/

View File

@ -0,0 +1,109 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Radicle: An Open-Source Decentralized App for Code Collaboration [P2P GitHub Alternative])
[#]: via: (https://itsfoss.com/radicle-p2p/)
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
Radicle: An Open-Source Decentralized App for Code Collaboration [P2P GitHub Alternative]
======
_**Brief: Radicle is an open-source project that aims to facilitate peer-to-peer code collaboration without depending on a centralized server. In other words, its a P2P alternative to GitHub.**_
Most of the open-source projects that we talk about are usually hosted at [GitHub][1] or other [GitHub alternatives like GitLab][2]. Even though you get many benefits and features from such platforms (not to mention the potential exposure), there are also downsides of using it.
For instance, [youtube-dl project was taken down by Microsoft][3] to comply with a DMCA request.
With a centralized approach, you do not have a lot of control and privacy. Of course, this may not be a big deal for many folks but if you are someone who does not want centralized servers, want to have peer-to-peer code collaboration feature, and something that works offline, [Radicle][4] will be a good tool for them.
### Radicle: A Peer-to-Peer Code Collaboration Platform
![][5]
[Radicle][4] is an open-source project that aims to provide a decentralized app for code collaboration. You can connect peer-to-peer if you need to share the project and work along with someone else.
It is still something in beta but it is definitely worth looking at. I did some quick tests without our team to see if the basic features to share the project works or not.
But, before you try it out, let me highlight the important features that you get with Radicle and what you can expect from it in the near future.
### Features of Radicle
![][6]
* Ability to add multiple remote peers
* Manage multiple peers
* Feature to follow a project from a specific peer
* Share your project using a unique ID
* Does not depend on central servers
* No censorship
* One network interconnected with peers
* Ability to work offline
* Local issues &amp; patches
* Built on Git to make it easy and comfortable for most developers
* Your infrastructure
* Ability to receive funding from your supporters (Ethereum)
* Manage codebases together
Expect more features for bug reporting and code review in the near future considering that it is still in early development.
**Recommended Read:**
![][7]
#### [Meet LBRY, A Blockchain-based Decentralized Alternative to YouTube][8]
LBRY is a new Blockchain-based, open source platform for sharing digital content. It is gaining popularity as a decentralized alternative to YouTube but LBRY is more than just a video sharing service.
### Installing Radicle on Linux
It provides an AppImage for Linux distributions. So, no matter whether you have an Ubuntu-based system or an Arch system, you can easily use it on your Linux system. In case you do not know, please refer to our guide on [using AppImage in Linux][9] to get started quickly.
[Download Radicle][10]
### Thoughts on Using Radicle
![][11]
If you are familiar with [Git version control system][12], using this should be a breeze. I just did some basic testing where I created a test repository and shared it with my teammate.
It works quite well. But, you need to configure Git with your name and email address before you get started.
Of course, you will need the terminal to configure and use the git version control, but the GUI is easy to use and understand. It is easy to manage remotes, copy the unique ID to share the project, and you can explore more when you try to use it for your projects.
Id advise you to experiment with it and go through the [documentation][13], [official site][4], along with their [GitHub page][14] before trying it out for an important project.
What do you think about Radicle? Even though it is in BETA phase, do you think it will gain traction and be something popular among the open-source developers?
Let me know your thoughts in the comments below!
--------------------------------------------------------------------------------
via: https://itsfoss.com/radicle-p2p/
作者:[Ankush Das][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/ankush/
[b]: https://github.com/lujun9972
[1]: https://github.com/
[2]: https://itsfoss.com/github-alternatives/
[3]: https://itsfoss.com/youtube-dl-github-takedown/
[4]: https://radicle.xyz/
[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/12/radicle-featured.png?resize=800%2C462&ssl=1
[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/12/radicle-upstream.jpg?resize=799%2C600&ssl=1
[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/lbry-featured.jpg?fit=800%2C450&ssl=1
[8]: https://itsfoss.com/lbry/
[9]: https://itsfoss.com/use-appimage-linux/
[10]: https://radicle.xyz/downloads.html
[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/12/radicle-settings.jpg?resize=800%2C598&ssl=1
[12]: https://git-scm.com/
[13]: https://docs.radicle.xyz/docs/what-is-radicle.html
[14]: https://github.com/radicle-dev

View File

@ -0,0 +1,251 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Understanding 52-bit virtual address support in the Arm64 kernel)
[#]: via: (https://opensource.com/article/20/12/52-bit-arm64-kernel)
[#]: author: (Bhupesh Sharma https://opensource.com/users/bhsharma)
Understanding 52-bit virtual address support in the Arm64 kernel
======
The introduction of 64-bit hardware increased the need to handle larger
address spaces.
![Puzzle pieces coming together to form a computer screen][1]
After 64-bit hardware became available, the need to handle larger address spaces (greater than 232 bytes) became obvious. With some vendors now offering servers with 64TiB (or more) of memory, x86_64 and arm64 now allow addressing adress spaces greater than 248 bytes (available with the default 48-bit address support).
x86_64 addressed these use cases by enabling support for five-level page tables in both hardware and software. This enables addressing address spaces equal to 257 bytes (see [x86: 5-level paging enabling for v4.12][2] for details). It bumps the limits to 128PiB of virtual address space and 4PiB of physical address space.
arm64 achieved the same thing by introducing two new architecture extensions—ARMv8.2 LVA (Large Virtual Addressing) and ARMv8.2 LPA (Large Physical Addressing). These allow 4PiB of virtual address space and 4 PiB of physical address space (i.e., 252 bits each, respectively).
With ARMv8.2 architecture extensions available in new arm64 CPUs, the two new hardware extensions are now supported in open source software.
Starting with Linux kernel version 5.4, the 52-bit (Large) Virtual Address (VA) and Physical Address (PA) support was introduced for arm64 architecture. Although the [kernel documentation][3] describes these features and how they impact the new kernels running on older CPUs (which don't support 52-bit VA extension in hardware) and newer CPUs (which support 52-bit VA extensions in hardware), it can be complex for average users to understand them and how they can "opt-in" to receiving VAs from a 52-bit space.
Therefore, I will introduce these relatively new concepts in this article:
1. How the kernel memory layout got "flipped" for Arm64 after the support for these features was added
2. The impact on userspace applications, especially the ones that provide debugging support (e.g., kexec-tools, makedumpfile, and crash-utility)
3. How userspace applications can "opt-in" to receiving VAs from a 52-bit space by specifying an mmap hint parameter that is larger than 48 bits
### ARMv8.2 architecture LVA and LPA extensions
The ARMv8.2 architecture provides two important extensions: Large Virtual Addressing (LVA) and Large Physical Addressing (LPA).
ARMv8.2-LVA supports a larger VA space for each translation table base register of up to 52 bits when using the 64KB translation granule.
ARMv8.2-LPA allows:
* A larger intermediate physical address (IPA) and PA space of up to 52 bits when using the 64KB translation granule
* A level 1 block size where the block covers a 4TB address range for the 64KB translation granule if the implementation supports 52 bits of PA
_Note that these features are supported only in the AArch64 state._
Currently, the following Arm64 Cortex-A processors support ARMv8.2 extensions:
* Cortex-A55
* Cortex-A75
* Cortex-A76
For more details, see the [Armv8 Architecture Reference Manual][4].
### Kernel memory layout on Arm64
With the ARMv8.2 extension adding support for LVA space (which is only available when running with a 64KB page size), the number of descriptors gets expanded in the first level of translation.
User addresses have bits 63:48 set to 0, while the kernel addresses have the same bits set to 1. TTBRx selection is given by bit 63 of the virtual address. The `swapper_pg_dir` contains only kernel (global) mappings, while the user `pgd` contains only user (non-global) mappings. The `swapper_pg_dir` address is written to TTBR1 and never written to TTBR0.
**AArch64 Linux memory layout with 64KB pages plus three levels (52-bit with hardware support):**
```
  Start                 End                     Size            Use
  -----------------------------------------------------------------------
  0000000000000000      000fffffffffffff           4PB          user
  fff0000000000000      fff7ffffffffffff           2PB          kernel logical memory map
  fff8000000000000      fffd9fffffffffff        1440TB          [gap]
  fffda00000000000      ffff9fffffffffff         512TB          kasan shadow region
  ffffa00000000000      ffffa00007ffffff         128MB          bpf jit region
  ffffa00008000000      ffffa0000fffffff         128MB          modules
  ffffa00010000000      fffff81ffffeffff         ~88TB          vmalloc
  fffff81fffff0000      fffffc1ffe58ffff          ~3TB          [guard region]
  fffffc1ffe590000      fffffc1ffe9fffff        4544KB          fixed mappings
  fffffc1ffea00000      fffffc1ffebfffff           2MB          [guard region]
  fffffc1ffec00000      fffffc1fffbfffff          16MB          PCI I/O space
  fffffc1fffc00000      fffffc1fffdfffff           2MB          [guard region]
  fffffc1fffe00000      ffffffffffdfffff        3968GB          vmemmap
  ffffffffffe00000      ffffffffffffffff           2MB          [guard region]
```
**Translation table lookup with 4KB pages:**
```
  +--------+--------+--------+--------+--------+--------+--------+--------+
  |63    56|55    48|47    40|39    32|31    24|23    16|15     8|7      0|
  +--------+--------+--------+--------+--------+--------+--------+--------+
   |                 |         |         |         |         |
   |                 |         |         |         |         v
   |                 |         |         |         |   [11:0]  in-page offset
   |                 |         |         |         +-&gt; [20:12] L3 index
   |                 |         |         +-----------&gt; [29:21] L2 index
   |                 |         +---------------------&gt; [38:30] L1 index
   |                 +-------------------------------&gt; [47:39] L0 index
   +-------------------------------------------------&gt; [63] TTBR0/1
```
**Translation table lookup with 64KB pages:**
```
  +--------+--------+--------+--------+--------+--------+--------+--------+
  |63    56|55    48|47    40|39    32|31    24|23    16|15     8|7      0|
  +--------+--------+--------+--------+--------+--------+--------+--------+
   |                 |    |               |              |
   |                 |    |               |              v
   |                 |    |               |            [15:0]  in-page offset
   |                 |    |               +----------&gt; [28:16] L3 index
   |                 |    +--------------------------&gt; [41:29] L2 index
   |                 +-------------------------------&gt; [47:42] L1 index (48-bit)
   |                                                   [51:42] L1 index (52-bit)
   +-------------------------------------------------&gt; [63] TTBR0/1
```
 
![][5]
opensource.com
### 52-bit VA support in the kernel
Since the newer kernels with the LVA support should run well on older CPUs (which don't support LVA extension in hardware) and the newer CPUs (which support LVA extension in hardware), the chosen design approach is to have a single binary that supports 52 bit (and must be able to fall back to 48 bit at early boot time if the hardware feature is not present). That is, the VMEMMAP must be sized large enough for 52-bit VAs and also must be sized large enough to accommodate a fixed `PAGE_OFFSET`.
This design approach requires the kernel to support the following variables for the new virtual address space:
```
VA_BITS         constant        the *maximum* VA space size
vabits_actual   variable        the *actual* VA space size
```
So, while `VA_BITS` denotes the maximum VA space size, the actual VA space supported (depending on the switch made at boot time) is indicated by `vabits_actual`.
#### Flipping the kernel memory layout
The design approach of keeping a single kernel binary requires the kernel .text to be in the higher addresses, such that they are invariant to 48/52-bit VAs. Due to the Kernel Address Sanitizer (KASAN) shadow being a fraction of the entire kernel VA space, the end of the KASAN shadow must also be in the higher half of the kernel VA space for both 48 and 52 bit. (Switching from 48 bit to 52 bit, the end of the KASAN shadow is invariant and dependent on `~0UL`, while the start address will "grow" towards the lower addresses).
To optimize `phys_to_virt()` and `virt_to_phys()`, the `PAGE_OFFSET` is kept constant at `0xFFF0000000000000` (corresponding to 52 bit), this obviates the need for an extra variable read. The `physvirt` and `vmemmap` offsets are computed at early boot to enable this logic.
Consider the following physical vs. virtual RAM address space conversion:
```
/*
 * The linear kernel range starts at the bottom of the virtual address
 * space. Testing the top bit for the start of the region is a
 * sufficient check and avoids having to worry about the tag.
 */
#define virt_to_phys(addr) ({                                   \
        if (!(((u64)addr) &amp; BIT(vabits_actual - 1)))            \
                (((addr) &amp; ~PAGE_OFFSET) + PHYS_OFFSET)
})
#define phys_to_virt(addr) ((unsigned long)((addr) - PHYS_OFFSET) | PAGE_OFFSET)
where:
 PAGE_OFFSET - the virtual address of the start of the linear map, at the
                start of the TTBR1 address space,
 PHYS_OFFSET - the physical address of the start of memory, and
 vabits_actual - the *actual* VA space size
```
### Impact on userspace applications used to debug kernel
Several userspace applications are used to debug running/live kernels or analyze the vmcore dump from a crashing system (e.g., to determine the root cause of the kernel crash): kexec-tools, makedumpfile, and crash-utility.
When these are used for debugging the Arm64 kernel, there is also an impact on them because of the Arm64 kernel memory map getting "flipped." These applications also need to perform a translation table walk for determining a physical address corresponding to a virtual address (similar to how it is done in the kernel).
Accordingly, userspace applications must be modified as they are broken upstream after the "flip" was introduced in the kernel memory map.
I have proposed fixes in the three affected userspace applications; while some have been accepted upstream, others are still pending:
* [Proposed makedumpfile upstream fix][6]
* [Proposed kexec-tools upstream fix][7]
* [Fix accepted in crash-utility][8]
Unless these changes are made in userspace applications, they will remain broken for debugging running/live kernels or analyzing the vmcore dump from a crashing system.
### 52-bit userspace VAs
To maintain compatibility with userspace applications that rely on the ARMv8.0 VA space maximum size of 48 bits, the kernel will, by default, return virtual addresses to userspace from a 48-bit range.
Userspace applications can "opt-in" to receiving VAs from a 52-bit space by specifying an mmap hint parameter larger than 48 bits.
For example:
```
.mmap_high_addr.c
\----
   maybe_high_address = mmap(~0UL, size, prot, flags,...);
```
It is also possible to build a debug kernel that returns addresses from a 52-bit space by enabling the following kernel config options:
```
`   CONFIG_EXPERT=y && CONFIG_ARM64_FORCE_52BIT=y`
```
_Note that this option is only intended for debugging applications and should **not** be used in production._
### Conclusions
To summarize:
1. Starting with Linux kernel version 5.14, the new Armv8.2 hardware extensions LVA and LPA are now well-supported in the Linux kernel.
2. Userspace applications like kexec-tools and makedumpfile used for debugging the kernel are broken _right now_ and awaiting acceptance of upstream fixes.
3. Legacy userspace applications that rely on Arm64 kernel providing it a 48-bit VA will continue working as-is, whereas newer userspace applications can "opt-in" to receiving VAs from a 52-bit space by specifying an mmap hint parameter that is larger than 48 bits.
* * *
_This article draws on [Memory Layout on AArch64 Linux][9] and [Linux kernel documentation v5.9.12][10]. Both are licensed under GPLv2.0._
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/52-bit-arm64-kernel
作者:[Bhupesh Sharma][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://opensource.com/users/bhsharma
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/puzzle_computer_solve_fix_tool.png?itok=U0pH1uwj (Puzzle pieces coming together to form a computer screen)
[2]: https://lwn.net/Articles/716916/
[3]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/arm64/memory.rst
[4]: https://developer.arm.com/documentation/ddi0487/latest/
[5]: https://opensource.com/sites/default/files/arm64-multi-level-translation_0.png (arm64 Multi-level Translation)
[6]: http://lists.infradead.org/pipermail/kexec/2020-September/021372.html
[7]: http://lists.infradead.org/pipermail/kexec/2020-September/021333.html
[8]: https://github.com/crash-utility/crash/commit/1c45cea02df7f947b4296c1dcaefa1024235ef10
[9]: https://www.kernel.org/doc/html/latest/arm64/memory.html
[10]: https://elixir.bootlin.com/linux/latest/source/arch/arm64/include/asm/memory.h

View File

@ -0,0 +1,115 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Why Vim users will love the Kakoune text editor)
[#]: via: (https://opensource.com/article/20/12/kakoune)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Why Vim users will love the Kakoune text editor
======
This editor may be reminiscent of Vim, but it offers plenty of its own
unique functions and features.
![Typewriter keys in multicolor][1]
The [Kakoune][2] text editor takes inspiration from Vi. With a minimalistic interface, short keyboard shortcuts, and separate editing and insert modes, it does [look and feel a lot like Vi][3] at first. However, the Kakoune editor has its own unique style both in design and function and is better considered its own editor rather than yet another Vim.
### Install
On Linux and BSD, you can install Kakoune from your distributions software repository or ports tree. For example, on Fedora, CentOS, or RHEL:
```
`$ sudo dnf install kakoune`
```
On Debian, Ubuntu, or similar:
```
`$ sudo apt install kakoune`
```
On macOS, you can use Homebrew:
```
`$ brew install kakoune`
```
Alternatively, you can [build it from source code][4].
The command to start Kakoune is `kak`. You can start Kakoune empty, or you can include a file name for it to open upon launch:
```
`$ kak example.txt`
```
### Using Kakoune
When you launch Kakoune (without a file name), it opens a mostly empty buffer in your terminal, except for a small status bar at the bottom of the windows. Like Vim, Kakoune starts in "normal" mode, which accepts key presses as commands and does not enter text into the buffer. To enter _insert_ mode, you must press either **i** (for **insert**) or **a** (for **append**).
While in insert mode, Kakoune acts mostly like any other editor. You type on your keyboard, and the characters you type show up in the buffer. While in insert mode, you can use the arrow keys to navigate through the buffer.
### Normal mode
In normal mode, you can issue navigation and text editing commands. This is the most obvious borrowed feature from the Vi tradition. Editing commands include functions to copy, cut (or "yank," in traditional Unix editing vernacular), and paste words and lines, undo, transform characters to upper or lower case, and so on. Here are some of the basics:
* **d**: yank and delete current selection ("cut" in modern terminology)
* **c**: yank and delete current selection and enter insert mode
* **Esc+Alt+d**: delete current selection
* **y**: yank selection
* **p**: paste
* **&lt;**: unindent selected lines
* **u**: undo
* **U**: redo
* **`**: transform to lower case
* **~**: transform to upper case
### Selection
In Kakoune, your cursor is a single-character mobile selection. Unless you extend your selection, any commands affecting a selection apply to just your cursor. For instance, if your cursor is hovering over the letter **n**, then the yank command (**c** in normal mode) copies the letter **n** to your clipboard, and the paste command (**p** in normal mode) pastes the letter **n** into the buffer.
The easiest way to extend a selection from a single character is to enter normal mode and press the **Shift** key while moving your cursor with the arrow keys. There are, however, several methods of extending a selection based on certain criteria. For instance, **Alt+l** extends a selection region from your cursor to the end of the current line.
Full documentation is available at <https://github.com/mawww/kakoune/blob/master/README.asciidoc>.
### Functions
In addition to these basic interactions, you can also issue commands to invoke the built-in functions of Kakoune. To access the Kakounes command line, type `:` in normal mode. From the command line, you can issue commands, including the essential **edit** command to open a file, the **write** command to save your buffer to a file, and of course, **quit** to exit the application.
There are many more functions, including special options for specific programming languages and file formats, an option to use the [Ranger file navigator][5] to browse your file system, change your color theme, search and replace text, and much more.
![Kakoune][6]
### Try Kakoune
If youre an experienced Vim user or even someone with just a passing competency, you might find Kakoune disorienting at first. Its just similar enough to Vim to lull you into a false sense of familiarity—everything works exactly like Vim until its drastically different. However, if youre new to Vim-like editors, or youre a Vim user looking for a new challenge, then Kakoune could be an ideal editor for you.
Try it for yourself!
When I started using the vi text editor, I hated it. Now I've been using vi for more than 17 years...
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/kakoune
作者:[Seth Kenlon][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://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-docdish-typewriterkeys-3.png?itok=NyBwMdK_ (Typewriter keys in multicolor)
[2]: https://kakoune.org/
[3]: https://opensource.com/article/20/12/vi-text-editor
[4]: https://github.com/mawww/kakoune
[5]: https://opensource.com/article/20/3/ranger-file-navigator
[6]: https://opensource.com/sites/default/files/kakoune-screenshot.png (Kakoune)

View File

@ -7,28 +7,26 @@
[#]: via: (https://www.linuxtechi.com/vlan-tagged-nic-ethernet-card-centos-rhel-servers/)
[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/)
How to Use VLAN tagged NIC (Ethernet Card) on CentOS and RHEL Servers
如何在CentOS和RHEL系统的服务器中使用带VLAN标记的以太网卡
======
There are some scenarios where we want to assign multiple IPs from different **VLAN** on the same Ethernet card (nic) on Linux servers ( **CentOS** / **RHEL** ). This can be done by enabling VLAN tagged interface. But for this to happen first we must make sure multiple VLANs are attached to port on switch or in other words we can say we should configure trunk port by adding multiple VLANs on switch.
在某些方案中我们希望在Linux服务器( **CentOS** / **RHEL** )上的同一以太网卡NIC分配来自不同VLAN的多个IP。这个可以通过使用VLAN标记的接口实现。但是要实现这个问题我们必须确保多个VLAN连接到交换机的端口上也就是说我们应该在交换机上添加多个VLAN来配置聚合端口译者注一般有聚合端口Trunk port接入端口Access port混合端口Hybird port三种
<https://www.linuxtechi.com/wp-content/uploads/2019/06/VLAN-Tagged-NIC-Linux-Server.jpg>
![tagged-interface-status-ip-command-linux-server][7]
Lets assume we have a Linux Server, there we have two Ethernet cards (enp0s3 & enp0s8), first NIC ( **enp0s3** ) will be used for data traffic and second NIC ( **enp0s8** ) will be used for control / management traffic. For Data traffic I will using multiple VLANs (or will assign multiple IPs from different VLANs on data traffic ethernet card).
假设我们有一个Linux服务器我们在这里有两张以太网卡 (enp0s3 和 enp0s8),第一张网卡( **enp0s3** )将被用于数据传输,而第二张网卡( **enp0s8** )将被用于控制/流量管理。我将使用多个VLAN用于数据传输或在数据流量网卡上从不同的VLAN中分配多个IP
I am assuming the port from switch which is connected to my server data NIC is configured as trunk port by mapping the multiple VLANs to it.
我假设连接到我服务器的数据网卡的端口是通过映射多个VLAN去配置为聚合端口。
Following are the VLANs which is mapped to data traffic Ethernet Card (NIC):
下面是映射到数据传输网卡(NIC)的VLAN
* VLAN ID (200), VLAN N/W = 172.168.10.0/24
* VLAN ID (300), VLAN N/W = 172.168.20.0/24
要在CentOS 7 / RHEL 7 / CentOS 8 / RHEL 8系统中使用VLAN标记的接口必须加载[内核模块][1] **8021q**
To use VLAN tagged interface on CentOS 7 / RHEL 7 / CentOS 8 /RHEL 8 systems, [kernel module][1] **8021q** must be loaded.
Use the following command to load the kernel module “8021q”
加载内核模块“8021q”可以使用下面的命令
```
[root@linuxtechi ~]# lsmod | grep -i 8021q
[root@linuxtechi ~]# modprobe --first-time 8021q
@ -39,8 +37,7 @@ mrp 18542 1 8021q
[root@linuxtechi ~]#
```
Use below modinfo command to display information about kernel module “8021q”
可以使用modinfo命令显示内核模块“8021q”的详细信息
```
[root@linuxtechi ~]# modinfo 8021q
filename: /lib/modules/3.10.0-327.el7.x86_64/kernel/net/8021q/8021q.ko
@ -58,48 +55,44 @@ sig_hashalgo: sha256
[root@linuxtechi ~]#
```
Now tagged (or mapped) the VLANs 200 and 300 to NIC enp0s3 using the [ip command][2]
现在使用[ip 命令][2]给enp0s3网卡加上200和300的VLAN标签或映射
译者注先给enp0s3网卡映射上200的VLAN标签。
```
[root@linuxtechi ~]# ip link add link enp0s3 name enp0s3.200 type vlan id 200
```
Bring up the interface using below ip command:
使用下面的ip命令打开接口
```
[root@linuxtechi ~]# ip link set dev enp0s3.200 up
```
Similarly mapped the VLAN 300 to NIC enp0s3
同理给enp0s3网卡映射上300的VLAN标签
```
[root@linuxtechi ~]# ip link add link enp0s3 name enp0s3.300 type vlan id 300
[root@linuxtechi ~]# ip link set dev enp0s3.300 up
[root@linuxtechi ~]#
```
Now view the tagged interface status using ip command:
现在使用ip命令查看标记后的接口状态
[![tagged-interface-ip-command][3]][4]
Now we can assign the IP address to tagged interface from their respective VLANs using beneath ip command,
现在我们可以使用下面的ip命令从它们各自的VLAN为已经标记的接口分配IP地址
```
[root@linuxtechi ~]# ip addr add 172.168.10.51/24 dev enp0s3.200
[root@linuxtechi ~]# ip addr add 172.168.20.51/24 dev enp0s3.300
```
Use below ip command to see whether IP is assigned to tagged interface or not.
使用下面的ip命令查看是否为已标记的接口分配到IP:
![ip-address-tagged-nic][5]
All the above changes via ip commands will not be persistent across the reboot. These tagged interfaces will not be available after reboot and after network service restart
重启之后上面所有通过ip命令的更改都不会持续译者注修改后可保存至配置文件或数据库中如果未进行保存处理则只有当前环境生效重启后配置失效。系统重启和网络服务重启译者注service network restart或down和up命令之后这些标记的接口将不可用。
So, to make tagged interfaces persistent across the reboot then use interface **ifcfg files**
因此,要使标记的接口在重启后保持不变,需要使用接口的**ifcfg files** 。
Edit interface (enp0s3) file “ **/etc/sysconfig/network-scripts/ifcfg-enp0s3** ” and add the following content,
编辑接口(enp0s3)文件“ **/etc/sysconfig/network-scripts/ifcfg-enp0s3** ”,并且增加下面的内容,
Note: Replace the interface name that suits to your env,
**作者提醒**:替换为您环境中的接口名称。
```
[root@linuxtechi ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
@ -109,9 +102,10 @@ BOOTPROTO=none
ONBOOT=yes
```
Save & exit the file
保存和退出文件。
Create tagged interface file for VLAN id 200 as “ **/etc/sysconfig/network-scripts/ifcfg-enp0s3.200** ” and add the following contents to it.
为id是200的VLAN创建接口文件“ **/etc/sysconfig/network-scripts/ifcfg-enp0s3.200** ”,且增加下面的内容。
```
[root@linuxtechi ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3.200
@ -124,9 +118,9 @@ NETWORK=172.168.10.0
VLAN=yes
```
Save & exit the file
保存并退出此文件。
Similarly create interface file for VLAN id 300 as “/etc/sysconfig/network-scripts/ifcfg-enp0s3.300” and add the following contents to it
同理为id是300的VLAN创建接口文件“ **/etc/sysconfig/network-scripts/ifcfg-enp0s3.300** ”,且增加下面的内容。
```
[root@linuxtechi ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3.300
@ -139,26 +133,26 @@ NETWORK=172.168.20.0
VLAN=yes
```
Save and exit file and then restart network services using the beneath command,
保存并退出文件,这时候使用下面的命令重启网络服务,
```
[root@linuxtechi ~]# systemctl restart network
[root@linuxtechi ~]#
```
Now verify whether tagged interface are configured and up & running using the ip command,
现在使用下面的ip命令检验标记的接口是否已配置和启动并且正在运行中
![tagged-interface-status-ip-command-linux-server][6]
Thats all from this article, I hope you got an idea how to configure and enable VLAN tagged interface on CentOS 7 / 8 and RHEL 7 /8 Severs. Please do share your feedback and comments.
以上就是本文的全部内容我希望您已经得到了在CentOS 7 / 8 and RHEL 7 /8 服务器上如何去配置和使能带VLAN标签的接口方法。请分享您的反馈和意见。
--------------------------------------------------------------------------------
via: https://www.linuxtechi.com/vlan-tagged-nic-ethernet-card-centos-rhel-servers/
参考: https://www.linuxtechi.com/vlan-tagged-nic-ethernet-card-centos-rhel-servers/
作者:[Pradeep Kumar][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
译者:[quinbyjoe](https://github.com/quinbyjoe)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
@ -171,3 +165,4 @@ via: https://www.linuxtechi.com/vlan-tagged-nic-ethernet-card-centos-rhel-server
[4]: https://www.linuxtechi.com/wp-content/uploads/2019/06/tagged-interface-ip-command.jpg
[5]: https://www.linuxtechi.com/wp-content/uploads/2019/06/ip-address-tagged-nic-1024x343.jpg
[6]: https://www.linuxtechi.com/wp-content/uploads/2019/06/tagged-interface-status-ip-command-linux-server-1024x656.jpg
[7]: https://www.linuxtechi.com/wp-content/uploads/2019/06/VLAN-Tagged-NIC-Linux-Server.jpg

View File

@ -0,0 +1,272 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Add storage to your Fedora system with LVM)
[#]: via: (https://fedoramagazine.org/add-storage-to-your-fedora-system-with-lvm/)
[#]: author: (Tim Bosse https://fedoramagazine.org/author/maztaim/)
使用 LVM 为你的 Fedora 系统添加存储
======
![][1]
有时需要在系统中添加另一块磁盘。这就是逻辑卷管理 LVM 的用武之地。LVM 的好处之处在于它相当灵活。有几种方法可以添加一块磁盘。这篇文章介绍了一种方法。
### 注意!
这篇文章并不包括将新的磁盘物理地安装到系统中的过程。请查阅你的系统和磁盘文档,了解如何正确地进行安装。
**重要:**一定要确保你已经备份重要数据。如果新磁盘已有数据,那么本文中描述的步骤将破坏数据。
### 最好了解
本文并没有深入介绍 LVM 的每一个功能重点是添加磁盘。但基本上LVM 有_卷组_它由一个或多个分区和/或磁盘组成。你把这些分区或磁盘添加为_物理卷_。一个卷组可以分成许多_逻辑卷_。逻辑卷可以作为文件系统、ramdisk 等其他存储使用。更多信息可以在[这里][2]中找到。
把物理卷看作是形成一个存储池(一个卷组),然后从这个存储池中划分出逻辑卷,供你的系统直接使用。
### 准备
确保你能看到你要添加的磁盘。在添加磁盘之前使用 _lsblk_ 查看哪些存储空间已经可用或正在使用。
```
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
zram0 251:0 0 989M 0 disk [SWAP]
vda 252:0 0 20G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 19G 0 part
└─fedora_fedora-root 253:0 0 19G 0 lvm /
```
本文使用的是带有虚拟存储的虚拟机,因此设备名称以 _vda_ 开头代表第一个磁盘_vdb_ 代表第二个磁盘,以此类推。你的设备名称可能不同。许多系统会将 _sda_ 作为第一个物理磁盘_sdb_ 代表第二个磁盘,以此类推。
当已连接新磁盘,并且你的系统已备份且正在运行,再次使用 _lsblk_ 来查看新的块设备。
```
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
zram0 251:0 0 989M 0 disk [SWAP]
vda 252:0 0 20G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 19G 0 part
└─fedora_fedora-root 253:0 0 19G 0 lvm /
vdb 252:16 0 10G 0 disk
```
现在有一个名为 _vdb_ 的新设备。该设备的位置是 _/dev/vdb_
```
$ ls -l /dev/vdb
brw-rw----. 1 root disk 252, 16 Nov 24 12:56 /dev/vdb
```
我们可以看到磁盘,但我们还不能用 LVM 来使用它。如果你运行 _blkid_,你应该不会看到它被列出。对于这个和之后的命令,你需要确保你的系统[已配置,这样你可以使用 _sudo_][3]
```
$ sudo blkid
/dev/vda1: UUID="4847cb4d-6666-47e3-9e3b-12d83b2d2448" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="830679b8-01"
/dev/vda2: UUID="k5eWpP-6MXw-foh5-Vbgg-JMZ1-VEf9-ARaGNd" TYPE="LVM2_member" PARTUUID="830679b8-02"
/dev/mapper/fedora_fedora-root: UUID="f8ab802f-8c5f-4766-af33-90e78573f3cc" BLOCK_SIZE="4096" TYPE="ext4"
/dev/zram0: UUID="fc6d7a48-2bd5-4066-9bcf-f062b61f6a60" TYPE="swap"
```
### 将磁盘添加到 LVM 中
使用 _pvcreate_ 初始化磁盘。你需要传递设备的完整路径。在这个例子中,它是 _/dev/vdb_。在你的系统中,它可能是 _/dev/sdb_ 或其他设备名。
```
$ sudo pvcreate /dev/vdb
Physical volume "/dev/vdb" successfully created.
```
当你运行 _blkid_ 时,你应该看到磁盘已经被初始化为一个 LVM2_member
```
$ sudo blkid
/dev/vda1: UUID="4847cb4d-6666-47e3-9e3b-12d83b2d2448" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="830679b8-01"
/dev/vda2: UUID="k5eWpP-6MXw-foh5-Vbgg-JMZ1-VEf9-ARaGNd" TYPE="LVM2_member" PARTUUID="830679b8-02"
/dev/mapper/fedora_fedora-root: UUID="f8ab802f-8c5f-4766-af33-90e78573f3cc" BLOCK_SIZE="4096" TYPE="ext4"
/dev/zram0: UUID="fc6d7a48-2bd5-4066-9bcf-f062b61f6a60" TYPE="swap"
/dev/vdb: UUID="4uUUuI-lMQY-WyS5-lo0W-lqjW-Qvqw-RqeroE" TYPE="LVM2_member"
```
你可以使用 _pvs_ 列出当前所有可用的物理卷:
```
$ sudo pvs
PV VG Fmt Attr PSize PFree
/dev/vda2 fedora_fedora lvm2 a-- <19.00g 0
/dev/vdb lvm2 --- 10.00g 10.00g
```
_/dev/vdb_ 被列为一个 PV (物理卷),但还没有分配到一个 VG (卷组)。
### 将物理卷添加到一个卷组
你可以使用 _vgs_ 找到可用的卷组列表:
```
$ sudo vgs
VG #PV #LV #SN Attr VSize VFree
fedora_fedora 1 1 0 wz--n- 19.00g 0
```
在本例中,只有一个卷组可用。接下来,将物理卷添加到 _fedora_fedora_
```
$ sudo vgextend fedora_fedora /dev/vdb
Volume group "fedora_fedora" successfully extended
```
你现在应该看到物理卷已被添加到卷组中:
```
$ sudo pvs
PV VG Fmt Attr PSize PFree
/dev/vda2 fedora_fedora lvm2 a <19.00g 0
/dev/vdb fedora_fedora lvm2 a <10.00g <10.00g
```
看一下卷组:
```
$ sudo vgs
VG #PV #LV #SN Attr VSize VFree
fedora_fedora 2 1 0 wzn- 28.99g <10.00g
```
你也可以获得具体卷组和物理卷的详细列表:
```
$ sudo vgdisplay fedora_fedora
--- Volume group ---
VG Name fedora_fedora
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 28.99 GiB
PE Size 4.00 MiB
Total PE 7422
Alloc PE / Size 4863 / 19.00 GiB
Free PE / Size 2559 / 10.00 GiB
VG UUID C5dL2s-dirA-SQ15-TfQU-T3yt-l83E-oI6pkp
```
看下物理卷:
```
$ sudo pvdisplay /dev/vdb
--- Physical volume ---
PV Name /dev/vdb
VG Name fedora_fedora
PV Size 10.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 2559
Free PE 2559
Allocated PE 0
PV UUID 4uUUuI-lMQY-WyS5-lo0W-lqjW-Qvqw-RqeroE
```
现在我们已经添加了磁盘,我们可以为逻辑卷 LV 分配空间:
```
$ sudo lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root fedora_fedora -wi-ao---- 19.00g
```
看一下逻辑卷。下面是详细的逻辑卷信息:
```
$ sudo lvdisplay fedora_fedora/root
--- Logical volume ---
LV Path /dev/fedora_fedora/root
LV Name root
VG Name fedora_fedora
LV UUID yqc9cw-AvOw-G1Ni-bCT3-3HAa-qnw3-qUSHGM
LV Write Access read/write
LV Creation host, time fedora, 2020-11-24 11:44:36 -0500
LV Status available
LV Size 19.00 GiB
Current LE 4863
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
```
查看根文件系统的大小,并将它与逻辑卷大小进行比较。
```
$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/fedora_fedora-root 19G 1.4G 17G 8% /
```
逻辑卷和文件系统大小都为 19G。让我们给根逻辑卷增加 5G。
```
$ sudo lvresize -L +5G fedora_fedora/root
Size of logical volume fedora_fedora/root changed from 19.00 GiB (4863 extents) to 24.00 GiB (6143 extents).
Logical volume fedora_fedora/root successfully resized.
```
我们现在有 24G 的逻辑卷可用。看看 _/_ 文件系统。
```
$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/fedora_fedora-root 19G 1.4G 17G 8% /
```
我们仍然显示只有 19G 的空闲空间,这是因为逻辑卷与文件系统不一样。要使用增加到逻辑卷的新空间,请调整文件系统的大小。
```
$ sudo resize2fs /dev/fedora_fedora/root
resize2fs 1.45.6 (20-Mar-2020)
Filesystem at /dev/fedora_fedora/root is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 3
The filesystem on /dev/fedora_fedora/root is now 6290432 (4k) blocks long.
```
看看文件系统的大小。
```
$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/fedora_fedora-root 24G 1.4G 21G 7% /
```
正如你所看到的,根文件系统 _/_ 已经占用了逻辑卷上的所有可用空间,而且不需要重新启动。
现在你已经将一个磁盘初始化为物理卷,并使用新的物理卷扩展了卷组。之后,你增加了逻辑卷的大小,并调整了文件系统的大小,以使用逻辑卷的新空间。
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/add-storage-to-your-fedora-system-with-lvm/
作者:[Tim Bosse][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://fedoramagazine.org/author/maztaim/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2020/11/lvm-add-disk-816x345.jpg
[2]: https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)
[3]: https://fedoramagazine.org/howto-use-sudo/

View File

@ -0,0 +1,69 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Make medit your next Linux terminal text editor)
[#]: via: (https://opensource.com/article/20/12/medit)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
让 medit 成为你的下一个 Linux 终端文本编辑器
======
这款经典的文本编辑器提供了所有的基本功能和一些让你自定义你的体验的令人兴奋的功能。
![Person drinking a hot drink at the computer][1]
这里有 [XEDIT][2]、jEdit、NEdit、[gedit][3],最后还有 [medit][4]。 
在我开始搜索我还没有尝试过的编辑器之前,我还没有听说过 medit但我很高兴发现了它。如果你正在寻找经典的 gedit 体验(大约是 Gnome 2那么 medit 可能无意间是一种出色且现代的近似。它也有许多额外的功能,比如可以用 Python、Lua 或 C 语言编写插件,以及将 shell 脚本集成到菜单系统。所有其他常用的功能也都在这里:标签式界面、一个按需的 shell、缩进管理、语法高亮等等。
### 安装 medit
你可以从 [mooedit.sourceforge.net][5] 下载 medit。它确认可以在 Linux 和 Windows 上工作。如果你使用的是 Linux你也可以在你的仓库中找到它。在 Slackware 上,我从 [slackbuilds.org][6] 安装了它。
![Medit terminal showing examples of Bash script in editor][7]
### 使用 medit
medit 标称自己是一个“为编程和围绕编程”的编辑器,事实上,它是作为一个名为 [GAPGroups、Algorithms、Programming][8] 的更大项目的一部分开始的。它的大部分功能都是针对典型的开发者期望的。例如,在 **Edit**菜单中,有增加和减少缩进的选项,这对于任何试图以视觉方式指示范围的程序员来说都是一个常见的任务 (对于 Python 程序员来说也是一个字面要求),还有注释或取消注释文本块的选项。
有些功能对普通用户也很有用。medit 有一个易于使用的标签式界面 (既在窗口顶部,也在侧面的弹出式列表中),一个用于快速浏览文件系统的侧板,在文件中添加书签的功能等等。它还具有针对两种编程语言以及标记和 markdown 语言的语法高亮显示功能,因此它是代码和散文的有用编辑器。
### 颜色方案
当编辑没有语法关联的纯文本或像 Asciidoc 这样的格式时medit 没有预设的高亮方案,编辑器会采用你的系统默认值。我使用的是黑暗主题,所以 medit 在深灰色背景上显示白色文本。
不过对于语法高亮,文本会根据每个单词在其结构化语言中扮演的角色而变成彩色。一开始,我对 medit 的一些选择有些失望,很多颜色在我的深色背景下太暗,无法辨认,而且我觉得所有重要的元素都不够独特。如果你不同意 medit 的选择,这个问题的答案在 **Preferences** 中,你可以更改颜色主题。我把我的颜色改成了 Tango它呈现出一个日光照射的颜色阵列在我的深色编辑器背景下非常突出甚至给在 medit 主题下保持白色的元素添加了颜色。
![Medit terminal showing examples of Bash script in editor using Tango color scheme against dark background][9]
### 弹出式 Python
在 medit 窗口的底部,有一个弹出的终端,用于快速访问 shell。这是一个很好的功能但坦率地说在你体验过 Emacs 和 [Kate][10]之后这感觉很普通。medit 让我惊讶的是它的弹出式 Python 控制台,它从 **Tools** 菜单中启动,并预先导入了 **moo****gtk** 模块。换句话说,当你启动 medit 的 Python shell 时,你可以查看 medit 自身部分构建的 Python 和 GTK 模块。这是一个很好的功能,也许会给你写插件的灵感(终端弹出的是一个用 Python 编写的插件,所以你也可以通过它的代码来了解一个插件是如何编写的)。
### 经典编辑
medit 是一个出色的基于 GTK 的编辑器,它具有所有重要的基本功能和一些诱人的额外功能,可以帮助你扩展应用并使其成为你自己的。因为它接受 C、Python、Lua 和 Bash所以有几个切入点可以做到这一点。如果你正在为你的写作寻找一个有用的编辑器无论是代码还是 markdown 或介于两者之间的东西,给 medit 一个机会。
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/medit
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_tea_laptop_computer_work_desk.png?itok=D5yMx_Dr (Person drinking a hot drink at the computer)
[2]: https://opensource.com/article/20/12/xedit
[3]: https://opensource.com/article/20/12/gedit
[4]: http://mooedit.sourceforge.net/
[5]: https://sourceforge.net/projects/mooedit/files/medit/
[6]: https://slackbuilds.org/repository/14.2/development/medit
[7]: https://opensource.com/sites/default/files/uploads/medit-31_days_medit-opensource.png (Medit terminal showing examples of Bash script in editor)
[8]: https://www.gap-system.org/
[9]: https://opensource.com/sites/default/files/uploads/medit-tango-colour-31_days_medit-opensource.png (Medit terminal showing examples of Bash script in editor using Tango color scheme against dark background)
[10]: https://opensource.com/article/20/12/kate-text-editor

View File

@ -0,0 +1,71 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (What web developers love about the Brackets text editor)
[#]: via: (https://opensource.com/article/20/12/brackets)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Web 开发人员喜欢 Brackets 文本编辑器的原因
======
这个编辑器是面向 Web 开发人员的,它支持多种编程语言,并提供了大量的扩展,使其成为你自己的编辑器。
![Text editor on a browser, in blue][1]
Brackets 文本编辑器是主要面向 Web 开发人员的编辑器。恰如其分的是,它的“编辑”菜单中充满了对 Web 编程语言用户特别有用的功能,主要是 HTML、CSS 和 Javascript 的经典组合。
但是,它还支持许多与互联网相关的语言和格式,包括 XML、Markdown、YAML 和 JSON、PHP、Lua、Java 和 Python以及一些常见的通用语言例如 C、C ++,甚至是 `diff` 命令的输出。
### 安装 Brackets
Brackets 可以从 [Brackets 网站][2]安装到 Linux、Windows 和 macOS上。
另外,在 Linux 上,你可以从 [flathub.org][3] 将其作为 Flatpak 安装。
![Brackets editor][4]
### 使用 Brackets
在大多数时候Brackets 是一个“普通”的文本编辑器,其功能类似于 jEdit 或 Medit。有语法高亮、可配置的 tab 间距、字符编码设置等等。这些都可以在窗口底部的状态栏中找到。
在“视图”菜单中,有主题设置、行号、自动换行,甚至还有分割窗口的选项,这样你可以在一个窗口中看到两个文件。
然而,在“编辑”菜单中,有一些编程的特殊功能。以下是我最喜欢的一些功能:
* 使用 **Ctrl+[** 或 **Ctrl+]** 键盘快捷键来缩进和取消缩进文本块,这不仅对保持 HTML、CSS 和 Javascript 的整洁很有用,而且对 Python 代码也很重要。
* 用 **Ctrl+/** 把一行变成注释。Brackets 标记注释的方式取决于你所使用的语言,所以无论你的文档是否使用斜线、破折号、箭头、井号或其他任何类型注释,这个功能都可以使用。
* 用 **Shift+Ctrl+Up** 或 **Shift+Ctrl+Down** 在文档中向上或向下移动一行。
* 用 **Shift+Ctrl+D** 删除整行。
* 用 **Ctrl+D** 复制一行。
这些都是看似小众的功能,你可能认为不会经常使用,但一旦你拥有了它们,你就会对它们产生依赖。
### 扩展
Brackets 还可以接受扩展,因此你和其他编码者可以添加扩展到功能中。要查看有哪些可用的扩展,请单击“文件”菜单并选择“扩展管理器”。有各种各样的扩展,包括用于调整代码格式的 Beautify、用于其他语言的多个支持包、用于转到标签开头或结尾的功能等等。
无论编辑器是否适合你,扩展可以使一个编辑器变得不同,所以如果你尝试 Brackets 并享受它的一切,但缺少一些重要的功能,在你放弃它之前,请浏览一下可用的扩展。
### 尝试 Brackets
Brackets 是一个有点低调的编辑器。虽然它宣传自己是 “Web 代码编辑器”,但实际上它是一个不错的通用编辑器,并为常见的 Web 工具链加入了一些额外的功能。如果你喜欢 Brackets 的外观和它所提供的功能,不妨一试!
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/brackets
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_blue_text_editor_web.png?itok=lcf-m6N7 (Text editor on a browser, in blue)
[2]: http://brackets.io/
[3]: https://flathub.org/apps/details/io.brackets.Brackets
[4]: https://opensource.com/sites/default/files/screenshot_2020-12-02_at_16.26.58.png (Brackets editor)