mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-28 23:20:10 +08:00
Merge branch 'master' of github.com:LCTT/TranslateProject
update
This commit is contained in:
commit
0a8d9502d6
@ -7,34 +7,34 @@
|
||||
[#]: author: (John Goerzen http://changelog.complete.org/archives/author/jgoerzen)
|
||||
[#]: url: (https://linux.cn/article-10312-1.html)
|
||||
|
||||
Emacs 系列(二):org 模式介绍
|
||||
Emacs 系列(二):Org 模式介绍
|
||||
======
|
||||
|
||||
在我 Emacs 系列中的[第一篇文章][1]里,我介绍了我在用了几十年的 vim 后转向了 Emacs,org 模式就是我为什么这样做的原因。
|
||||
在我 Emacs 系列中的[第一篇文章][1]里,我介绍了我在用了几十年的 vim 后转向了 Emacs,Org 模式就是我为什么这样做的原因。
|
||||
|
||||
org 模式的精简和高效真的震惊了我,它真的是个“杀手”应用。
|
||||
Org 模式的精简和高效真的震惊了我,它真的是个“杀手”应用。
|
||||
|
||||
### 所以,org 模式到底是什么呢?
|
||||
### 所以,Org 模式到底是什么呢?
|
||||
|
||||
这是我昨天写的:
|
||||
|
||||
> 它是一个组织信息的平台,它的主页上这样写着:“一切都是纯文本:org 模式用于记笔记、维护待办事项列表、计划项目和使用快速有效的纯文本系统编写文档。”
|
||||
> 它是一个组织信息的平台,它的主页上这样写着:“一切都是纯文本:Org 模式用于记笔记、维护待办事项列表、计划项目和使用快速有效的纯文本系统编写文档。”
|
||||
|
||||
这是事实,但并不是很准确。org 模式是一个你用来组织事务的小工具。它有一些非常合理的默认设置,但也允许你自己定制。
|
||||
这是事实,但并不是很准确。Org 模式是一个你用来组织事务的小工具。它有一些非常合理的默认设置,但也允许你自己定制。
|
||||
|
||||
主要突出在这几件事上:
|
||||
|
||||
* **维护待办事项列表**:项目可以分散在 org 文件中,包含附件,有标签、截止日期、时间表。有一个方便的“日程”视图,显示需要做什么。项目也可以重复。
|
||||
* **编写文档**:org 模式有个特殊的功能来生成 HTML、LaTeX、幻灯片(用 LaTeX beamer)和其他所有的格式。它也支持直接在缓冲区中运行和以 Emacs 所支持的的语言进行<ruby>文学编程<rt>literate programming</rt></ruby>。如果你想要深入了解这项功能的话,参阅[这篇文学式 DevOps 的文章][2]。而 [整个 Worg 网站][3] 是用 org 模式开发的。
|
||||
* **维护待办事项列表**:项目可以分散在 Org 文件中,包含附件,有标签、截止日期、时间表。有一个方便的“日程”视图,显示需要做什么。项目也可以重复。
|
||||
* **编写文档**:Org 模式有个特殊的功能来生成 HTML、LaTeX、幻灯片(用 LaTeX beamer)和其他所有的格式。它也支持直接在缓冲区中运行和以 Emacs 所支持的的语言进行<ruby>文学编程<rt>literate programming</rt></ruby>。如果你想要深入了解这项功能的话,参阅[这篇文学式 DevOps 的文章][2]。而 [整个 Worg 网站][3] 是用 Org 模式开发的。
|
||||
* **记笔记**:对,它也能做笔记。通过全文搜索,文件的交叉引用(类似 wiki),UUID,甚至可以与其他的系统进行交互(通过 Message-ID 与 mu4e 交互,通过 ERC 的日志等等……)。
|
||||
|
||||
### 入门
|
||||
|
||||
我强烈建议去阅读 [Carsten Dominik 关于 org 模式的一篇很棒的 Google 讲话][4]。那篇文章真的很赞。
|
||||
我强烈建议去阅读 [Carsten Dominik 关于 Org 模式的一篇很棒的 Google 讲话][4]。那篇文章真的很赞。
|
||||
|
||||
在 Emacs 中带有 org 模式,但如果你想要个比较新的版本的话,Debian 用户可以使用命令 `apt-get install org-mode` 来更新,或者使用 Emacs 的包管理系统命令 `M-x package-install RET org-mode RET`。
|
||||
在 Emacs 中带有 Org 模式,但如果你想要个比较新的版本的话,Debian 用户可以使用命令 `apt-get install org-mode` 来更新,或者使用 Emacs 的包管理系统命令 `M-x package-install RET org-mode RET`。
|
||||
|
||||
现在,你可能需要阅读一下 org 模式的精简版教程中的[导读部分][5],特别注意,你要设置下[启动部分][6]中提到的那些键的绑定。
|
||||
现在,你可能需要阅读一下 Org 模式的精简版教程中的[导读部分][5],特别注意,你要设置下[启动部分][6]中提到的那些键的绑定。
|
||||
|
||||
### 一份好的教程
|
||||
|
||||
@ -51,7 +51,7 @@ org 模式的精简和高效真的震惊了我,它真的是个“杀手”应
|
||||
(set-language-environment "UTF-8")
|
||||
```
|
||||
|
||||
org 模式中可以打开 URL。默认的,它会在 Firefox 中打开,但我喜欢用 Chromium。
|
||||
Org 模式中可以打开 URL。默认的,它会在 Firefox 中打开,但我喜欢用 Chromium。
|
||||
|
||||
```
|
||||
(setq browse-url-browser-function 'browse-url-chromium)
|
||||
@ -91,7 +91,7 @@ org 模式中可以打开 URL。默认的,它会在 Firefox 中打开,但我
|
||||
(setq org-irc-link-to-logs t)
|
||||
```
|
||||
|
||||
我喜欢通过 UUID 来建立链接,这让我在文件之间移动而不会破坏位置。当我要 org 存储一个链接目标以便将来插入时,以下配置有助于生成 UUID。
|
||||
我喜欢通过 UUID 来建立链接,这让我在文件之间移动而不会破坏位置。当我要 Org 存储一个链接目标以便将来插入时,以下配置有助于生成 UUID。
|
||||
|
||||
```
|
||||
(require 'org-id)
|
||||
@ -138,7 +138,7 @@ org 模式中可以打开 URL。默认的,它会在 Firefox 中打开,但我
|
||||
|
||||
### 外观配置
|
||||
|
||||
我喜欢一个较漂亮的的屏幕。在你开始习惯 org 模式之后,你可以试试这个。
|
||||
我喜欢一个较漂亮的的屏幕。在你开始习惯 Org 模式之后,你可以试试这个。
|
||||
|
||||
```
|
||||
(add-hook 'org-mode-hook
|
||||
@ -149,7 +149,7 @@ org 模式中可以打开 URL。默认的,它会在 Firefox 中打开,但我
|
||||
|
||||
### 下一篇
|
||||
|
||||
希望这篇文章展示了 org 模式的一些功能。接下来,我将介绍如何定制 `TODO` 关键字和标记、归档旧任务、将电子邮件转发到 org 模式,以及如何使用 `git` 在不同电脑之间进行同步。
|
||||
希望这篇文章展示了 Org 模式的一些功能。接下来,我将介绍如何定制 `TODO` 关键字和标记、归档旧任务、将电子邮件转发到 Org 模式,以及如何使用 `git` 在不同电脑之间进行同步。
|
||||
|
||||
你也可以查看[本系列的所有文章列表][9]。
|
||||
|
||||
|
130
published/20180302 Emacs -3- More on org-mode.md
Normal file
130
published/20180302 Emacs -3- More on org-mode.md
Normal file
@ -0,0 +1,130 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (oneforalone)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: subject: (Emacs #3: More on org-mode)
|
||||
[#]: via: (https://changelog.complete.org/archives/9877-emacs-3-more-on-org-mode)
|
||||
[#]: author: (John Goerzen http://changelog.complete.org/archives/author/jgoerzen)
|
||||
[#]: url: (https://linux.cn/article-10327-1.html)
|
||||
|
||||
Emacs 系列(三): Org 模式的补充
|
||||
======
|
||||
|
||||
这是 [Emacs 和 Org 模式系列][1]的第三篇。
|
||||
|
||||
### Todo 的跟进及关键字
|
||||
|
||||
当你使用 Org 模式来跟进你的 TODO 时,它有多种状态。你可以用 `C-c C-t` 来快速切换状态。我将它设为这样:
|
||||
|
||||
```
|
||||
(setq org-todo-keywords '(
|
||||
(sequence "TODO(t!)" "NEXT(n!)" "STARTED(a!)" "WAIT(w@/!)" "OTHERS(o!)" "|" "DONE(d)" "CANCELLED(c)")
|
||||
))
|
||||
```
|
||||
|
||||
在这里,我设置了一个任务未完成的五种状态:`TODO`、`NEXT`、`STARTED`、`WAIT` 及 `OTHERS`。每一个状态都有单个字的快捷键(`t`、`n`、`a` 等)。管道符(`|`)之后的状态被认为是“完成”的状态。我有两个“完成”状态:`DONE`(已经完成)及 `CANCELLED`(还没完成,但由于其它的原因无法完成)。
|
||||
|
||||
`!` 的含义是记录某项更改为状态的时间。我不把这个添加到完成的状态,是因为它们已经被记录了。`@` 符号表示带理由的提示,所以当切换到 `WAIT` 时,Org 模式会问我为什么,并将这个添加到笔记中。
|
||||
|
||||
以下是项目状态发生变化的例子:
|
||||
|
||||
```
|
||||
** DONE This is a test
|
||||
CLOSED: [2018-03-02 Fri 03:05]
|
||||
|
||||
- State "DONE" from "WAIT" [2018-03-02 Fri 03:05]
|
||||
- State "WAIT" from "TODO" [2018-03-02 Fri 03:05] \\
|
||||
waiting for pigs to fly
|
||||
- State "TODO" from "NEXT" [2018-03-02 Fri 03:05]
|
||||
- State "NEXT" from "TODO" [2018-03-02 Fri 03:05]
|
||||
```
|
||||
|
||||
在这里,最新的项目在最上面。
|
||||
|
||||
### 议程模式,日程及期限
|
||||
|
||||
当你处在一个待办事项时,`C-c C-s` 或 `C-c C-d` 可以为其设置相应的日程或期限。这些都是在议程模式中的功能。它们的区别在于其意图和表现。日程是你希望在某个时候完成的事情,而期限是在某个特定的时间应该完成的事情。默认情况下,议程视图将在项目的截止日期前提醒你。
|
||||
|
||||
在此过程中,[议程视图][3]将显示即将出现的项目,提供了一种基于纯文本或标记搜索项目的方法,甚至可以进行跨多个文件处理项目的批量操作。我在本系列的[第 2 部分][4]中介绍了为议程模式配置。
|
||||
|
||||
### 标签
|
||||
|
||||
Org 模式当然也支持标签了。你可以通过 `C-c C-q` 快速的建立标签。
|
||||
|
||||
你可能会想为一些常用的标签设置快捷键。就像这样:
|
||||
|
||||
```
|
||||
(setq org-tag-persistent-alist
|
||||
'(("@phone" . ?p)
|
||||
("@computer" . ?c)
|
||||
("@websurfing" . ?w)
|
||||
("@errands" . ?e)
|
||||
("@outdoors" . ?o)
|
||||
("MIT" . ?m)
|
||||
("BIGROCK" . ?b)
|
||||
("CONTACTS" . ?C)
|
||||
("INBOX" . ?i)
|
||||
))
|
||||
```
|
||||
|
||||
你还可以按文件向该列表添加标记,也可以按文件为某些内容设置标记。我就在我的 `inbox.org` 和 `email.org` 文件中设置了一个 `INBOX` 的标签。然后我可以每天从日程视图中查看所有标记为 `INBOX` 的项目,像将它们重新归档到其他文件中的这样的简单操作将让它们去掉 `INBOX` 标记。
|
||||
|
||||
### 重新归档
|
||||
|
||||
“重新归档”就是在文件中或其他地方移动。它是使用标题来完成的。`C-c C-w` 就是做这个的。我设置成这样:
|
||||
|
||||
```
|
||||
(setq org-outline-path-complete-in-steps nil) ; Refile in a single go
|
||||
(setq org-refile-use-outline-path 'file)
|
||||
```
|
||||
|
||||
### 归档分类
|
||||
|
||||
一段时间后,你的文件就会被已经完成的事情弄得乱七八糟。Org 模式有一个[归档][6]特性,可以将主 `.org` 文件移到其他文件中,以备将来参考。如果你在 `git` 或其他软件中 有 Org 文件,你可能希望删除这些其他文件,因为无论如何都会在历史中拥有这些文件,但是我发现它们对于析取和搜索非常方便。
|
||||
|
||||
我会定期检查并归档文件中的所有内容。基于 [stackoverflow 的讨论][7],我有以下代码:
|
||||
|
||||
```
|
||||
(defun org-archive-done-tasks ()
|
||||
(interactive)
|
||||
(org-map-entries
|
||||
(lambda ()
|
||||
(org-archive-subtree)
|
||||
(setq org-map-continue-from (outline-previous-heading)))
|
||||
"/DONE" 'file)
|
||||
(org-map-entries
|
||||
(lambda ()
|
||||
(org-archive-subtree)
|
||||
(setq org-map-continue-from (outline-previous-heading)))
|
||||
"/CANCELLED" 'file)
|
||||
)
|
||||
```
|
||||
|
||||
这基于[一个特定的答案][8] —— 你可以从评论那获得一些额外的提示。现在你可以运行 `M-x org-archive-done-tasks`,当前文件中所有标记为 `DONE` 或 `CANCELED` 的内容都将放到另一个文件中。
|
||||
|
||||
### 下一篇
|
||||
|
||||
我将通过讨论在 Org 模式中自动接受邮件以及在不同的机器上同步来对 Org 模式进行总结。
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://changelog.complete.org/archives/9877-emacs-3-more-on-org-mode
|
||||
|
||||
作者:[John Goerzen][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[oneforalone](https://github.com/oneforalone)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://changelog.complete.org/archives/author/jgoerzen
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://changelog.complete.org/archives/tag/emacs2018
|
||||
[2]: https://orgmode.org/guide/TODO-Items.html#TODO-Items
|
||||
[3]: https://orgmode.org/guide/Agenda-Views.html#Agenda-Views
|
||||
[4]: https://linux.cn/article-10312-1.html
|
||||
[5]: https://orgmode.org/guide/Tags.html#Tags
|
||||
[6]: https://orgmode.org/guide/Archiving.html#Archiving
|
||||
[7]: https://stackoverflow.com/questions/6997387/how-to-archive-all-the-done-tasks-using-a-single-command
|
||||
[8]: https://stackoverflow.com/a/27043756
|
@ -0,0 +1,122 @@
|
||||
NASA 在开放科学方面做了些什么
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
最近我们刚为开设了一个新的“[科学类][2]”的文章分类。其中发表的最新一篇文章名为:[开源是怎样影响科学的][3]。在这篇文章中我们主要讨论了 [NASA][4] 的积极努力,这些努力包括他们通过开源实践来促进科学研究的积极作用。
|
||||
|
||||
### NASA 是怎样使用开源手段促进科学研究的
|
||||
|
||||
NASA 将他们的整个研究库对整个公共领域开放,这是一项[壮举][5]。
|
||||
|
||||
没错!每个人都能访问他们的整个研究库,并能从他们的研究中获益。
|
||||
|
||||
他们现已开放的资料可以大致分为以下三类:
|
||||
|
||||
* 开源 NASA
|
||||
* 开放 API
|
||||
* 开放数据
|
||||
|
||||
### 1、开源 NASA
|
||||
|
||||
这里有一份 [GitHub][7] 的联合创始人之一和执行总裁 [Chris Wanstrath][6] 的采访,他向我们介绍道,一切都是从很多年前开始的。
|
||||
|
||||
- [Chris Wanstrath on NASA, open source and Github](https://youtu.be/dUFzMe8GM3M)
|
||||
|
||||
该项目名为 “[code.nasa.gov][8]”,截至本文发表为止,NASA 已经[通过 GitHub 开源][9]了 365 个科学软件(LCTT 译注:本文原文发表于 2018/3/28,截止至本译文发布,已经有 454 个项目了)。对于一位热爱程序的开发者来说,即使一天研究一个软件,想把 NASA 的这些软件全部研究过来也要整整一年的时间。
|
||||
|
||||
即使你不是一位开发者,你也可以在这个门户网站浏览这个壮观的软件合集。
|
||||
|
||||
其中就有[阿波罗 11 号][10]的制导计算机的源代码。阿波罗 11 号空间飞行器[首次将两名人类带上月球][11],分别是 [Neil Armstrong][12] 和 [Edwin Aldrin][13] 。如果你对 Edwin Aldrin 感兴趣,可以点击[这里][14]了解更多。
|
||||
|
||||
#### NASA 开源代码促进会使用的开源代码许可
|
||||
|
||||
它们采用了几种[开源许可证][15],其分类如下:
|
||||
|
||||
- [Apache 许可证 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
||||
- [Nasa 开源许可证 3.0](https://opensource.org/licenses/NASA-1.3)
|
||||
- [GPL v3](https://www.gnu.org/licenses/gpl.html)
|
||||
- [MIT 许可证](https://en.wikipedia.org/wiki/MIT_License)
|
||||
|
||||
### 2、开放 API
|
||||
|
||||
开放 [API][16] 在推行开放科学中起到了很大作用。与[开源促进会][17]类似,对于 API,也有一个 [开放 API 促进会][18]。下面这张示意图可以告诉你 API 是怎样将应用程序和它的开发者连接起来的。
|
||||
|
||||
![][19]
|
||||
|
||||
记得点击这个[链接](https://sproutsocial.com/insights/what-is-an-api/)看看。链接内的文章使用了简单易懂的方法解读了 API ,文末总结了五大要点。
|
||||
|
||||
![][20]
|
||||
|
||||
这会让你感受到专有 API 和开放 API 会有多么大的不同。
|
||||
|
||||
![][22]
|
||||
|
||||
[NASA 的 Open API][23] 主要针对应用程序开发者,旨在显著改善数据的可访问性,也包括图片内容在内。该网站有一个实时编辑器,可供你调用[每日天文一图(APOD)][24] 的 API。
|
||||
|
||||
#### 3、开放数据
|
||||
|
||||
![][25]
|
||||
|
||||
在[我们发布的第一篇开放科学的文章][3]中,我们在“开放科学”段落下提到的三个国家 —— 法国、印度和美国的多种开放数据形式。NASA 有着类似的想法和行为。这种重要的意识形态已经被[多个国家][26]所接受。
|
||||
|
||||
[NASA 的开放数据门户][27]致力于开放,拥有不断增长的可供大众自由使用的开放数据。将数据集纳入到这个数据集对于任何研究活动来说都是必要且重要的。NASA 还在他们的门户网站上征集各方的数据需求,以一同收录在他们的数据库中。这一举措不仅是领先的、创新的,还顺应了[数据科学][28]、[AI 和深度学习][29]的趋势。
|
||||
|
||||
下面的视频讲的是学者和学生们是怎样通过大量研究得出对数据科学的定义的。这个过程十分的激动人心。瑞尔森大学罗杰斯商学院的 [Murtaza Haider 教授][30]在视频结尾中提到了开源的出现对数据科学的改变,尤其让是旧有的闭源方式逐渐变得开放。而这也确实成为了现实。
|
||||
|
||||
- [What is Data Science? Data Science 101](https://youtu.be/z1kPKBdYks4)
|
||||
|
||||
![][31]
|
||||
|
||||
现在任何人都能在 NASA 上征集数据。正如前面的视频中所说,NASA 的举措很大程度上与征集和分析优化数据有关。
|
||||
|
||||
![][32]
|
||||
|
||||
你只需要免费注册即可。考虑到论坛上的公开讨论以及数据集在可能存在的每一类分析领域中的重要性,这一举措在未来会有非常积极的影响,对数据的统计分析当然也会大幅进展。在之后的文章中我们还会具体讨论这些细节,还有它们和开源模式之间的相关性。
|
||||
|
||||
以上就是对 NASA 开放科学模式的一些探索成就,希望您能继续关注我们接下来的相关文章!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/nasa-open-science/
|
||||
|
||||
作者:[Avimanyu Bandyopadhyay][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[Valoniakim](https://github.com/Valoniakim)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/avimanyu/
|
||||
[1]:https://itsfoss.com/wp-content/uploads/2018/03/tux-in-space.jpg
|
||||
[2]:https://itsfoss.com/category/science/
|
||||
[3]:https://itsfoss.com/open-source-impact-on-science/
|
||||
[4]:https://www.nasa.gov/
|
||||
[5]:https://futurism.com/free-science-nasa-just-opened-its-entire-research-library-to-the-public/
|
||||
[6]:http://chriswanstrath.com/
|
||||
[7]:https://github.com/
|
||||
[8]:http://code.nasa.gov
|
||||
[9]:https://github.com/open-source
|
||||
[10]:https://www.nasa.gov/mission_pages/apollo/missions/apollo11.html
|
||||
[11]:https://www.space.com/16758-apollo-11-first-moon-landing.html
|
||||
[12]:https://www.jsc.nasa.gov/Bios/htmlbios/armstrong-na.html
|
||||
[13]:https://www.jsc.nasa.gov/Bios/htmlbios/aldrin-b.html
|
||||
[14]:https://buzzaldrin.com/the-man/
|
||||
[15]:https://itsfoss.com/open-source-licenses-explained/
|
||||
[16]:https://en.wikipedia.org/wiki/Application_programming_interface
|
||||
[17]:https://opensource.org/
|
||||
[18]:https://www.openapis.org/
|
||||
[19]:https://itsfoss.com/wp-content/uploads/2018/03/api-bridge.jpeg
|
||||
[20]:https://itsfoss.com/wp-content/uploads/2018/03/open-api-diagram.jpg
|
||||
[21]:http://www.apiacademy.co/resources/api-strategy-lesson-201-private-apis-vs-open-apis/
|
||||
[22]:https://itsfoss.com/wp-content/uploads/2018/03/nasa-open-api-live-example.jpg
|
||||
[23]:https://api.nasa.gov/
|
||||
[24]:https://apod.nasa.gov/apod/astropix.html
|
||||
[25]:https://itsfoss.com/wp-content/uploads/2018/03/nasa-open-data-portal.jpg
|
||||
[26]:https://www.xbrl.org/the-standard/why/ten-countries-with-open-data/
|
||||
[27]:https://data.nasa.gov/
|
||||
[28]:https://en.wikipedia.org/wiki/Data_science
|
||||
[29]:https://www.kdnuggets.com/2017/07/ai-deep-learning-explained-simply.html
|
||||
[30]:https://www.ryerson.ca/tedrogersschool/bm/programs/real-estate-management/murtaza-haider/
|
||||
[31]:https://itsfoss.com/wp-content/uploads/2018/03/suggest-dataset-nasa-1.jpg
|
||||
[32]:https://itsfoss.com/wp-content/uploads/2018/03/suggest-dataset-nasa-2-1.jpg
|
@ -1,4 +1,4 @@
|
||||
Emacs 系列(一):抛掉一切,投入 Emacs 和 org 模式的怀抱
|
||||
Emacs 系列(一):抛掉一切,投入 Emacs 和 Org 模式的怀抱
|
||||
======
|
||||
|
||||
我必须承认,在使用了几十年的 vim 后, 我被 [Emacs][1] 吸引了。
|
||||
@ -9,22 +9,22 @@ Emacs 系列(一):抛掉一切,投入 Emacs 和 org 模式的怀抱
|
||||
|
||||
许多 TODO 管理工具与电子邮件集成的很差。当你想做“提醒我在一周内回复这个邮件”之类的事时,很多时候是不可能的,因为这个工具不能以一种能够轻松回复的方式存储邮件。而这个问题在 Slack 上更为严重。
|
||||
|
||||
就在那时,我偶然发现了 [Carsten Dominik 在 Google Talk 上关于 org 模式的讲话][4]。Carsten 是 org 模式的作者,即便是这个讲话已经有 10 年了,但它仍然很具有参考价值。
|
||||
就在那时,我偶然发现了 [Carsten Dominik 在 Google Talk 上关于 Org 模式的讲话][4]。Carsten 是 Org 模式的作者,即便是这个讲话已经有 10 年了,但它仍然很具有参考价值。
|
||||
|
||||
我之前有用过 [org 模式][5],但是每次我都没有真正的深入研究它,
|
||||
因为我当时的反应是“一个大纲编辑器?但我需要的是待办事项列表”。我就这么错过了它。但实际上 org 模式就是我所需要的。
|
||||
我之前有用过 [Org 模式][5],但是每次我都没有真正的深入研究它,
|
||||
因为我当时的反应是“一个大纲编辑器?但我需要的是待办事项列表”。我就这么错过了它。但实际上 Org 模式就是我所需要的。
|
||||
|
||||
### 什么是 Emacs?什么是 org 模式?
|
||||
### 什么是 Emacs?什么是 Org 模式?
|
||||
|
||||
Emacs 最初是一个文本编辑器,现在依然是一个文本编辑器,而且这种传统无疑贯穿始终。但是说 Emacs 是个编辑器是很不公平的。
|
||||
|
||||
Emacs 更像一个平台或是工具包。你不仅可以用它来编辑源代码,而且配置 Emacs 本身也是编程,里面有很多模式。就像编写一个 Firefox 插件一样简单,只要几行代码,然后,模式里的操作就改变了。
|
||||
|
||||
org 模式也一样。确实,它是一个大纲编辑器,但它真正所包含的不止如此。它是一个信息组织平台。它的网站上写着,“你可以用纯文本来记录你的生活:你可以用 org 模式来记笔记,处理待办事项,规划项目和使用快速有效的纯文本系统编写文档。”
|
||||
Org 模式也一样。确实,它是一个大纲编辑器,但它真正所包含的不止如此。它是一个信息组织平台。它的网站上写着,“你可以用纯文本来记录你的生活:你可以用 Org 模式来记笔记,处理待办事项,规划项目和使用快速有效的纯文本系统编写文档。”
|
||||
|
||||
### 捕获
|
||||
|
||||
如果你读过基于 GTD 的生产力指南,那么他们强调的一件事就是毫不费力地获取项目。这个想法是,当某件事突然出现在你的脑海里时,把它迅速输入一个受信任的系统,这样你就可以继续做你正在做的事情。org 模式有一个专门的捕获系统。我可以在 Emacs 的任何地方按下 `C-c c` 键,它就会空出一个位置来记录我的笔记。最关键的是,自动嵌入到笔记中的链接可以链接到我按下 `C-c c` 键时正在编辑的那一行。如果我正在编辑文件,它会链回到那个文件和我所在的行。如果我正在浏览邮件,它就会链回到那封邮件(通过邮件的 Message-Id,这样它就可以在任何一个文件夹中找到邮件)。聊天时也一样,甚至是当你在另一个 org 模式中也可也这样。
|
||||
如果你读过基于 GTD 的生产力指南,那么他们强调的一件事就是毫不费力地获取项目。这个想法是,当某件事突然出现在你的脑海里时,把它迅速输入一个受信任的系统,这样你就可以继续做你正在做的事情。Org 模式有一个专门的捕获系统。我可以在 Emacs 的任何地方按下 `C-c c` 键,它就会空出一个位置来记录我的笔记。最关键的是,自动嵌入到笔记中的链接可以链接到我按下 `C-c c` 键时正在编辑的那一行。如果我正在编辑文件,它会链回到那个文件和我所在的行。如果我正在浏览邮件,它就会链回到那封邮件(通过邮件的 Message-Id,这样它就可以在任何一个文件夹中找到邮件)。聊天时也一样,甚至是当你在另一个 Org 模式中也可也这样。
|
||||
|
||||
这样我就可以做一个笔记,它会提醒我在一周内回复某封邮件,当我点击这个笔记中的链接时,它会在我的邮件阅读器中弹出这封邮件 —— 即使我随后将它从收件箱中存档。
|
||||
|
||||
@ -32,7 +32,7 @@ org 模式也一样。确实,它是一个大纲编辑器,但它真正所包
|
||||
|
||||
### 工具套件
|
||||
|
||||
一旦你开始使用 org 模式,很快你就会想将所有的事情都集成到里面。有可以从网络上捕获内容的浏览器插件,也有多个 Emacs 邮件或新闻阅读器与之集成,ERC(IRC 客户端)也不错。所以我将自己从 Thunderbird 和 mairix + mutt (用于邮件归档)换到了 mu4e,从 xchat + slack 换到了 ERC。
|
||||
一旦你开始使用 Org 模式,很快你就会想将所有的事情都集成到里面。有可以从网络上捕获内容的浏览器插件,也有多个 Emacs 邮件或新闻阅读器与之集成,ERC(IRC 客户端)也不错。所以我将自己从 Thunderbird 和 mairix + mutt (用于邮件归档)换到了 mu4e,从 xchat + slack 换到了 ERC。
|
||||
|
||||
你可能不明白,我喜欢这些基于 Emacs 的工具,而不是具有相同功能的单独的工具。
|
||||
|
||||
@ -54,7 +54,7 @@ org 模式也一样。确实,它是一个大纲编辑器,但它真正所包
|
||||
|
||||
接下来我将讨论我的使用情况,并展示以下的配置:
|
||||
|
||||
* org 模式,包括计算机之间的同步、捕获、日程和待办事项、文件、链接、关键字和标记、各种导出(幻灯片)等。
|
||||
* Org 模式,包括计算机之间的同步、捕获、日程和待办事项、文件、链接、关键字和标记、各种导出(幻灯片)等。
|
||||
* mu4e,用于电子邮件,包括多个账户,bbdb 集成
|
||||
* ERC,用于 IRC 和即时通讯
|
||||
|
||||
|
@ -1,66 +1,59 @@
|
||||
|
||||
Openstack 30个经典面试问题和解答
|
||||
30 个 Openstack 经典面试问题和解答
|
||||
======
|
||||
|
||||
现在,大多数公司都试图将它们的 IT 基础设施和 Telco Infra 迁移到私有云,即OpenStack。如果你打算面试 OpenStack 管理员这个岗位,那么下面列出的这些面试问题可能会帮助你通过面试。
|
||||
现在,大多数公司都试图将它们的 IT 基础设施和电信设施迁移到私有云, 如 OpenStack。如果你打算面试 OpenStack 管理员这个岗位,那么下面列出的这些面试问题可能会帮助你通过面试。
|
||||
|
||||
![](https://www.linuxtechi.com/wp-content/uploads/2018/11/OpenStack-Interview-Questions.jpg)
|
||||
|
||||
### Q:1 说一下 OpenStack 及其主要组件?
|
||||
|
||||
Ans: OpenStack 是一系列开源软件,这些软件组成了一个云提供软件,也就是 OpenStack,被称为开源软件或项目栈。
|
||||
答: OpenStack 是一系列开源软件,这些软件组成了一个云供给软件,也就是 OpenStack,意即开源软件或项目栈。
|
||||
|
||||
下面是 OpenStack 的主要关键组件:
|
||||
|
||||
* **Nova** – 用于计算级别管理虚拟机,并在计算或管理程序级别执行其他计算任务。
|
||||
* **Nova** – 用于在计算级别管理虚拟机,并在计算或管理程序级别执行其他计算任务。
|
||||
* **Neutron** – 为虚拟机、计算和控制节点提供网络功能。
|
||||
* **Keystone** – 为所有云用户和 OpenStack 云服务提供身份认证服务。换句话说,我们可以说 Keystone 是一个提供给云用户和云服务访问权限的方法。
|
||||
* **Horizon** – 用于提供图形用户界面。使用图形化管理界面可以很轻松地完成各种日常操作任务。
|
||||
* **Cinder** – 用于提供块存储功能。通常来说 OpenStack 的 Cinder 中集成了 Chef 和 ScaleIO 来共同为计算和控制节点提供块存储服务。
|
||||
* **Swift** – 用于提供对象存储功能。通常来说,Glance 管理的镜像是存储在对象存储空间的。扩展存储就像 ScaleIO 也可以提供对象存储,可以很容易的集成 Glance 服务。
|
||||
* **Swift** – 用于提供对象存储功能。通常来说,Glance 管理的镜像是存储在对象存储空间的。像 ScaleIO 这样的外部存储也可以提供对象存储,可以很容易的集成 Glance 服务。
|
||||
* **Glance** – 用于提供镜像服务。使用 Glance 的管理平台来上传和下载云镜像。
|
||||
* **Heat** – 用于提供编排服务或功能。使用 Heat 管理平台可以轻松地将虚拟机作为堆栈,并且根据需要可以将虚拟机扩展或收缩。
|
||||
* **Ceilometer** – 用于提供计量与监控功能。
|
||||
|
||||
|
||||
|
||||
### Q:2 什么服务通常在控制节点上运行?
|
||||
|
||||
Ans: 以下服务通常在控制节点上运行:
|
||||
答: 以下服务通常在控制节点上运行:
|
||||
|
||||
* 认证服务 ( KeyStone)
|
||||
* 镜像服务 ( Glance)
|
||||
* Nova 服务比如 Nova API, Nova Scheduler 和 Nova DB
|
||||
* 认证服务(KeyStone)
|
||||
* 镜像服务(Glance)
|
||||
* Nova 服务比如 Nova API、Nova Scheduler 和 Nova DB
|
||||
* 块存储和对象存储服务
|
||||
* Ceilometer 服务
|
||||
* MariaDB / MySQL 和 RabbitMQ 服务
|
||||
* 网络(Neutron)和网络代理的管理服务
|
||||
* 编排服务 (Heat)
|
||||
|
||||
|
||||
* 编排服务(Heat)
|
||||
|
||||
### Q:3 什么服务通常在计算节点上运行?
|
||||
|
||||
Ans: 以下服务通常在计算节点运行:
|
||||
答: 以下服务通常在计算节点运行:
|
||||
|
||||
* Nova 计算
|
||||
* 网络服务,比如 OVS
|
||||
|
||||
|
||||
|
||||
### Q:4 计算节点上虚拟机的默认地址是什么?
|
||||
|
||||
Ans: 虚拟机存储在计算节点的 “ **/var/lib/nova/instances** ”
|
||||
答: 虚拟机存储在计算节点的 `/var/lib/nova/instances`。
|
||||
|
||||
### Q:5 Glance 镜像的默认地址是什么?
|
||||
|
||||
Ans: 因为Glance 服务运行在控制节点上,所以 Glance 镜像都被存储在控制节点的“ **/var/lib/glance/images** ”文件夹下。
|
||||
答: 因为 Glance 服务运行在控制节点上,所以 Glance 镜像都被存储在控制节点的 `/var/lib/glance/images` 文件夹下。
|
||||
|
||||
想了解更多请访问 : [**在 OpenStack 中如何使用命令行创建和删除虚拟机**][1]
|
||||
想了解更多请访问:[在 OpenStack 中如何使用命令行创建和删除虚拟机][1]
|
||||
|
||||
### Q:6 说一下如何使用命令行启动一个虚拟机?
|
||||
|
||||
Ans: 我们可以使用如下 OpenStack 命令来启动一个新的虚拟机:
|
||||
答: 我们可以使用如下 OpenStack 命令来启动一个新的虚拟机:
|
||||
|
||||
```
|
||||
# openstack server create --flavor {flavor-name} --image {Image-Name-Or-Image-ID} --nic net-id={Network-ID} --security-group {Security_Group_ID} –key-name {Keypair-Name} <VM_Name>
|
||||
@ -68,7 +61,7 @@ Ans: 我们可以使用如下 OpenStack 命令来启动一个新的虚拟机:
|
||||
|
||||
### Q:7 如何在 OpenStack 中显示用户的网络命名空间列表?
|
||||
|
||||
Ans: 可以使用 “ip net ns” 命令来列出用户的网络命名空间。
|
||||
答: 可以使用 `ip net ns` 命令来列出用户的网络命名空间。
|
||||
|
||||
```
|
||||
~# ip netns list
|
||||
@ -79,9 +72,9 @@ vrouter
|
||||
|
||||
### Q:8 如何在 OpenStack 中执行网络命名空间内的命令?
|
||||
|
||||
Ans: 假设我们想在 “qdhcp-a51635b1-d023-419a-93b5-39de47755d2d” 网络命名空间中执行 “ifconfig” 命令,我们可以执行如下命令。
|
||||
答: 假设我们想在 `qdhcp-a51635b1-d023-419a-93b5-39de47755d2d` 网络命名空间中执行 `ifconfig` 命令,我们可以执行如下命令。
|
||||
|
||||
命令格式 : ip netns exec {network-space} <command>
|
||||
命令格式 : `ip netns exec {network-space} <command>`:
|
||||
|
||||
```
|
||||
~# ip netns exec qdhcp-a51635b1-d023-419a-93b5-39de47755d2d "ifconfig"
|
||||
@ -89,7 +82,7 @@ Ans: 假设我们想在 “qdhcp-a51635b1-d023-419a-93b5-39de47755d2d” 网络
|
||||
|
||||
### Q:9 在 Glance 服务中如何使用命令行上传和下载镜像?
|
||||
|
||||
Ans: Glance 服务中云镜像上传可以使用如下 OpenStack 命令:
|
||||
答: Glance 服务中云镜像上传可以使用如下 OpenStack 命令:
|
||||
|
||||
```
|
||||
~# openstack image create --disk-format qcow2 --container-format bare --public --file {Name-Cloud-Image}.qcow2 <Cloud-Image-Name>
|
||||
@ -103,7 +96,7 @@ Ans: Glance 服务中云镜像上传可以使用如下 OpenStack 命令:
|
||||
|
||||
### Q:10 OpenStack 如何将虚拟机从错误状态转换为活动状态?
|
||||
|
||||
Ans: 在某些情况下虚拟机可能会进入错误状态,可以使用如下命令将错误状态转换为活动状态:
|
||||
答: 在某些情况下虚拟机可能会进入错误状态,可以使用如下命令将错误状态转换为活动状态:
|
||||
|
||||
```
|
||||
~# nova reset-state --active {Instance_id}
|
||||
@ -111,7 +104,7 @@ Ans: 在某些情况下虚拟机可能会进入错误状态,可以使用如下
|
||||
|
||||
### Q:11 如何使用命令行来获取可使用的浮动 IP 列表?
|
||||
|
||||
Ans: 可使用如下命令来显示可用浮动 IP 列表:
|
||||
答: 可使用如下命令来显示可用浮动 IP 列表:
|
||||
|
||||
```
|
||||
~]# openstack ip floating list | grep None | head -10
|
||||
@ -119,7 +112,7 @@ Ans: 可使用如下命令来显示可用浮动 IP 列表:
|
||||
|
||||
### Q:12 如何在特定可用区域中或在计算主机上配置虚拟机?
|
||||
|
||||
Ans: 假设我们想在 compute-02 中的可用区 NonProduction 上配置虚拟机,可以使用如下命令:
|
||||
答: 假设我们想在 compute-02 中的可用区 NonProduction 上配置虚拟机,可以使用如下命令:
|
||||
|
||||
```
|
||||
~]# openstack server create --flavor m1.tiny --image cirros --nic net-id=e0be93b8-728b-4d4d-a272-7d672b2560a6 --security-group NonProd_SG --key-name linuxtec --availability-zone NonProduction:compute-02 nonprod_testvm
|
||||
@ -127,17 +120,17 @@ Ans: 假设我们想在 compute-02 中的可用区 NonProduction 上配置虚拟
|
||||
|
||||
### Q:13 如何在特定计算节点上获取配置的虚拟机列表?
|
||||
|
||||
Ans: 假设我们想要获取在 compute-0-19 中配置的虚拟机列表,可以使用如下命令:
|
||||
答: 假设我们想要获取在 compute-0-19 中配置的虚拟机列表,可以使用如下命令:
|
||||
|
||||
命令格式: openstack server list –all-projects –long -c Name -c Host | grep -i {Compute-Node-Name}
|
||||
命令格式: `openstack server list –all-projects –long -c Name -c Host | grep -i {Compute-Node-Name}`:
|
||||
|
||||
```
|
||||
~# openstack server list --all-projects --long -c Name -c Host | grep -i compute-0-19
|
||||
```
|
||||
|
||||
### Q:14 如何使用命令行查看 OpenStack 实例的打印信息?
|
||||
### Q:14 如何使用命令行查看 OpenStack 实例的控制台日志?
|
||||
|
||||
Ans: 使用如下命令可查看实例的命令行打印信息:
|
||||
答: 使用如下命令可查看实例的控制台日志。
|
||||
|
||||
首先获取实例的 ID,然后使用如下命令:
|
||||
|
||||
@ -147,7 +140,7 @@ Ans: 使用如下命令可查看实例的命令行打印信息:
|
||||
|
||||
### Q:15 如何获取 OpenStack 实例的控制台的 URL 地址?
|
||||
|
||||
Ans: 可以使用以下 OpenStack 命令从命令行检索实例的控制台 URL 地址:
|
||||
答: 可以使用以下 OpenStack 命令从命令行检索实例的控制台 URL 地址:
|
||||
|
||||
```
|
||||
~# openstack console url show {Instance-id}
|
||||
@ -155,28 +148,23 @@ Ans: 可以使用以下 OpenStack 命令从命令行检索实例的控制台 URL
|
||||
|
||||
### Q:16 如何使用命令行创建可启动的 cinder / block 存储卷?
|
||||
|
||||
Ans: 假设创建一个 8GB 可启动存储卷,可参考如下步骤:
|
||||
答: 假设创建一个 8GB 可启动存储卷,可参考如下步骤:
|
||||
|
||||
* 使用如下命令获取镜像列表
|
||||
|
||||
|
||||
|
||||
```
|
||||
```
|
||||
~# openstack image list | grep -i cirros
|
||||
| 89254d46-a54b-4bc8-8e4d-658287c7ee92 | cirros | active |
|
||||
```
|
||||
|
||||
* 使用 cirros 镜像创建 8GB 的可启动存储卷
|
||||
|
||||
|
||||
|
||||
```
|
||||
```
|
||||
~# cinder create --image-id 89254d46-a54b-4bc8-8e4d-658287c7ee92 --display-name cirros-bootable-vol 8
|
||||
```
|
||||
|
||||
### Q:17 如何列出所有在你的 OpenStack 中创建的项目或用户?
|
||||
|
||||
Ans: 可以使用如下命令来检索所有项目和用户:
|
||||
答: 可以使用如下命令来检索所有项目和用户:
|
||||
|
||||
```
|
||||
~# openstack project list --long
|
||||
@ -184,14 +172,12 @@ Ans: 可以使用如下命令来检索所有项目和用户:
|
||||
|
||||
### Q:18 如何显示 OpenStack 服务端点列表?
|
||||
|
||||
Ans: OpenStack 服务端点被分为 3 类:
|
||||
答: OpenStack 服务端点被分为 3 类:
|
||||
|
||||
* 公共端点
|
||||
* 内部端点
|
||||
* 管理端点
|
||||
|
||||
|
||||
|
||||
使用如下 OpenStack 命令来查看各种 OpenStack 服务端点:
|
||||
|
||||
```
|
||||
@ -204,23 +190,21 @@ Ans: OpenStack 服务端点被分为 3 类:
|
||||
~# openstack catalog show keystone
|
||||
```
|
||||
|
||||
想了解更多请访问 : [**OpenStack 中的实例创建流程**][2]
|
||||
想了解更多请访问:[OpenStack 中的实例创建流程][2]。
|
||||
|
||||
### Q:19 在控制节点上你应该按照什么步骤来重启 nova 服务?
|
||||
|
||||
Ans: 应该按照如下步骤来重启 OpenStack 控制节点的 nova 服务:
|
||||
|
||||
* service nova-api restart
|
||||
* service nova-cert restart
|
||||
* service nova-conductor restart
|
||||
* service nova-consoleauth restart
|
||||
* service nova-scheduler restart
|
||||
|
||||
答: 应该按照如下步骤来重启 OpenStack 控制节点的 nova 服务:
|
||||
|
||||
* `service nova-api restart`
|
||||
* `service nova-cert restart`
|
||||
* `service nova-conductor restart`
|
||||
* `service nova-consoleauth restart`
|
||||
* `service nova-scheduler restart`
|
||||
|
||||
### Q:20 假如计算节点上为数据流量配置了一些 DPDK 端口,你如何检查 DPDK 端口的状态呢?
|
||||
|
||||
Ans: 因为我们使用 openvSwitch (OVS) 来配置 DPDK 端口,因此可以使用如下命令来检查端口的状态:
|
||||
答: 因为我们使用 openvSwitch (OVS) 来配置 DPDK 端口,因此可以使用如下命令来检查端口的状态:
|
||||
|
||||
```
|
||||
root@compute-0-15:~# ovs-appctl bond/show | grep dpdk
|
||||
@ -231,9 +215,9 @@ root@compute-0-15:~#
|
||||
root@compute-0-15:~# dpdk-devbind.py --status
|
||||
```
|
||||
|
||||
### Q:21 How to add new rules to the existing SG(Security Group) from command line in openstack?如何使用命令行在 OpenStack 中向存在的安全组 SG(Security Group)中添加新规则?
|
||||
### Q:21 如何使用命令行在 OpenStack 中向存在的安全组 SG(安全组)中添加新规则?
|
||||
|
||||
Ans: 可以使用 neutron 命令向 OpenStack 已存在的安全组中添加新规则:
|
||||
答: 可以使用 `neutron` 命令向 OpenStack 已存在的安全组中添加新规则:
|
||||
|
||||
```
|
||||
~# neutron security-group-rule-create --protocol <tcp or udp> --port-range-min <port-number> --port-range-max <port-number> --direction <ingress or egress> --remote-ip-prefix <IP-address-or-range> Security-Group-Name
|
||||
@ -241,37 +225,37 @@ Ans: 可以使用 neutron 命令向 OpenStack 已存在的安全组中添加新
|
||||
|
||||
### Q:22 如何查看控制节点和计算节点的 OVS 桥配置?
|
||||
|
||||
Ans: 控制节点和计算节点的 OVS 桥配置可使用以下命令来查看:
|
||||
答: 控制节点和计算节点的 OVS 桥配置可使用以下命令来查看:
|
||||
|
||||
```
|
||||
~]# ovs-vsctl show
|
||||
```
|
||||
|
||||
### Q:23 计算节点上的集成桥(br-int)的作用是什么?
|
||||
### Q:23 计算节点上的集成桥(br-int)的作用是什么?
|
||||
|
||||
Ans: 集成桥(br-int)对来自和运行在计算节点上的实例的流量执行 VLAN 标记和取消标记。
|
||||
答: 集成桥(br-int)对来自和运行在计算节点上的实例的流量执行 VLAN 标记和取消标记。
|
||||
|
||||
数据包从实例的 n/w 接口发出使用虚拟接口 qvo 通过 linux 桥(qbr)。qvb接口是用来连接 Linux 桥的,qvo 接口是用来连接集成桥(br-int)的。集成桥上的 qvo 端口有一个内部 VLAN 标签,这个标签是用于当数据包到达集成桥的时候贴到数据包头部的。
|
||||
数据包从实例的 n/w 接口发出使用虚拟接口 qvo 通过 Linux 桥(qbr)。qvb 接口是用来连接 Linux 桥的,qvo 接口是用来连接集成桥的。集成桥上的 qvo 端口有一个内部 VLAN 标签,这个标签是用于当数据包到达集成桥的时候贴到数据包头部的。
|
||||
|
||||
### Q:24 隧道桥(br-tun)在计算节点上的作用是什么?
|
||||
|
||||
Ans: 隧道网桥(br-tun)根据 OpenFlow 规则将 VLAN 标记的流量从集成网桥转换为隧道 ID。
|
||||
答: 隧道桥(br-tun)根据 OpenFlow 规则将 VLAN 标记的流量从集成网桥转换为隧道 ID。
|
||||
|
||||
br-tun(tunnel bridge,即隧道桥)允许不同网络的实例彼此进行通信。隧道有利于封装在非安全网络上传输的流量,br-tun 支持两层网络,即 GRE 和 VXLAN。
|
||||
隧道桥允许不同网络的实例彼此进行通信。隧道有利于封装在非安全网络上传输的流量,它支持两层网络,即 GRE 和 VXLAN。
|
||||
|
||||
### Q:25 外部 OVS 桥(br-ex)的作用是什么?
|
||||
|
||||
Ans: 顾名思义,此网桥转发来往网络的流量,以允许外部访问实例。br-ex 连接物理接口比如 eth2,这样用户网络的浮动 IP 数据从物理网络接收并路由到用户网络端口。
|
||||
答: 顾名思义,此网桥转发来往网络的流量,以允许外部访问实例。br-ex 连接物理接口比如 eth2,这样用户网络的浮动 IP 数据从物理网络接收并路由到用户网络端口。
|
||||
|
||||
### Q:26 OpenStack 网络中 OpenFlow 规则的作用是什么?
|
||||
|
||||
Ans: OpenFlow 规则是一种机制,这种机制定义了一个数据包如何从源到达目的地。OpenFlow 规则存储在 flow 表中。flow 表是 OpenFlow 交换机的一部分。
|
||||
答: OpenFlow 规则是一种机制,这种机制定义了一个数据包如何从源到达目的地。OpenFlow 规则存储在 flow 表中。flow 表是 OpenFlow 交换机的一部分。
|
||||
|
||||
当一个数据包到达交换机就会被第一个 flow 表检查,如果不匹配 flow 表中的任何入口,那这个数据包就会被丢弃或者转发到其他 flow 表中。
|
||||
|
||||
### Q:27 怎样查看 OpenFlow 交换机的信息(比如端口、表编号、缓存编号等)?
|
||||
|
||||
Ans: 假如我们要显示 OpenFlow 交换机的信息(br-int),需要执行如下命令:
|
||||
答: 假如我们要显示 OpenFlow 交换机的信息(br-int),需要执行如下命令:
|
||||
|
||||
```
|
||||
root@compute-0-15# ovs-ofctl show br-int
|
||||
@ -293,9 +277,9 @@ actions: output enqueue set_vlan_vid set_vlan_pcp strip_vlan mod_dl_src mod_dl_d
|
||||
|
||||
### Q:28 如何显示交换机中的所有 flow 的入口?
|
||||
|
||||
Ans: 可以使用命令 ‘ **ovs-ofctl dump-flows** ‘ 来查看交换机的 flow 入口
|
||||
答: 可以使用命令 `ovs-ofctl dump-flows` 来查看交换机的 flow 入口。
|
||||
|
||||
假设我们想显示 OVS 集成桥(br-int)的所有 flow 入口,可以使用如下命令:
|
||||
假设我们想显示 OVS 集成桥(br-int)的所有 flow 入口,可以使用如下命令:
|
||||
|
||||
```
|
||||
[root@compute01 ~]# ovs-ofctl dump-flows br-int
|
||||
@ -303,7 +287,7 @@ Ans: 可以使用命令 ‘ **ovs-ofctl dump-flows** ‘ 来查看交换机的 f
|
||||
|
||||
### Q:29 什么是 Neutron 代理?如何显示所有 Neutron 代理?
|
||||
|
||||
Ans: OpenStack Neutron 服务器充当中心控制器,实际网络配置是在计算节点或者网络节点上执行的。Neutron 代理是计算节点或者网络节点上进行配置更新的软件实体。Neutron 代理通过 Neuron 服务和消息队列来和中心 Neutron 服务通信。
|
||||
答: OpenStack Neutron 服务器充当中心控制器,实际网络配置是在计算节点或者网络节点上执行的。Neutron 代理是计算节点或者网络节点上进行配置更新的软件实体。Neutron 代理通过 Neuron 服务和消息队列来和中心 Neutron 服务通信。
|
||||
|
||||
可通过如下命令查看 Neutron 代理列表:
|
||||
|
||||
@ -313,14 +297,12 @@ Ans: OpenStack Neutron 服务器充当中心控制器,实际网络配置是
|
||||
|
||||
### Q:30 CPU Pinning 是什么?
|
||||
|
||||
Ans: CPU Pinning 是指为某个虚拟机保留物理核心。它也称为 CPU 隔离或处理器关联。有两个目的:
|
||||
答: CPU Pinning 是指为某个虚拟机保留物理核心。它也称为 CPU 隔离或处理器关联。有两个目的:
|
||||
|
||||
* 它确保虚拟机只能在专用核心上运行
|
||||
* 它还确保公共主机进程不在这些核心上运行
|
||||
|
||||
|
||||
|
||||
我们也可以认为 Pinning 是物理核心到一个用户虚拟 CPU(vCPU) 的一对一映射。
|
||||
我们也可以认为 Pinning 是物理核心到一个用户虚拟 CPU(vCPU)的一对一映射。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -329,7 +311,7 @@ via: https://www.linuxtechi.com/openstack-interview-questions-answers/
|
||||
作者:[Pradeep Kumar][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[ScarboroughCoral](https://github.com/ScarboroughCoral)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -0,0 +1,142 @@
|
||||
一个免费、安全、跨平台的密码管理器
|
||||
======
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-Password-Manager-720x340.png)
|
||||
|
||||
在这个现代化的互联网时代,你一定在许多网站上有多个账户,它可能是个人或官方邮箱账户、社交或专业网络账户、GitHub 账户和电子商务账户等。因此,对于不同的账户,你应该设置多个不同的密码。我相信你应该已经意识到为多个账户设置相同的密码是件疯狂又危险的事情。如果攻击者设法破解了你的一个账户,那么他/她很可能尝试使用相同的密码访问你的其他账户。所以,**强烈建议为不同的账户设置不同的密码**。
|
||||
|
||||
不过,记住好几个密码是很困难的。你可以把它们写在纸上,但那也不是一个有效的方法,你可能会在一段时间后失去它们。这时密码管理器就派上用场了。密码管理器就像一个存储库,你可以在其中存储不同账户的所有密码,并用一个主密码将其锁定。这样,你需要记住的就只剩下主密码了。之前我们介绍过一个叫 [KeeWeb][1] 的开源密码管理器,今天,我们将介绍另外一款密码管理器 ——— Buttercup。
|
||||
|
||||
### 关于 Buttercup
|
||||
|
||||
Buttercup 是一个自由、开源、安全、跨平台的密码管理器,使用 **NodeJS** 编写。它可以帮助你将不同账户的所有登录凭证存储到加密存档中,该存档可以保存在本地系统或任何远程服务(如 DropBox、OwnCloud、NextCloud 和基于 WebDAV 的服务)中。它使用强大的 **256 位 AES 加密算法**,用主密码保存你的敏感数据。所以,除了拥有主密码的人以外,没有人可以访问你的登录信息。Buttercup 目前支持 Linux、Mac OS 和 Windows,还提供了一个浏览器扩展和移动应用程序。因此,你也可以在 Android 和 iOS 设备中的桌面应用程序和浏览器扩展程序中使用相同的存档。
|
||||
|
||||
### 安装 Buttercup 密码管理器
|
||||
|
||||
Buttercup 目前在 Linux 平台上有 .deb、.rpm 软件包、可移植的 AppImage 和 tar 归档文件等安装包。转到其 [发布页][2] 下载安装你想要的版本。
|
||||
|
||||
Buttercup 桌面应用程序在 [AUR][3] 中也可用,你可以使用 AUR 帮助程序(如 [Yay][4])在基于 Arch 的系统上安装,如下所示:
|
||||
|
||||
```
|
||||
$ yay -S buttercup-desktop
|
||||
```
|
||||
|
||||
如果你已经下载了方便的 AppImage 文件,使用如下命令让它执行:
|
||||
|
||||
```
|
||||
$ chmod +x buttercup-desktop-1.11.0-x86_64.AppImage
|
||||
```
|
||||
|
||||
然后,使用命令启动它:
|
||||
|
||||
```
|
||||
$ ./buttercup-desktop-1.11.0-x86_64.AppImage
|
||||
```
|
||||
|
||||
运行此命令后,会提示是否要将 Buttercup AppImage 集成到你的系统中。如果选择 “Yes”,则会将其添加到应用程序菜单并安装图标。如果不这样做,你仍然可以通过双击 AppImage 或在终端中使用上述命令启动应用程序。
|
||||
|
||||
### 添加存档
|
||||
|
||||
第一次启动时,会看到下面的欢迎界面:
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-1.png)
|
||||
|
||||
我们还没有添加任何存档,所以让我们添加一个吧。单击 “New Archive File” 按钮,输入存档文件的名称,并选择它的保存位置。
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-2.png)
|
||||
|
||||
你可以随意命名。我把它命名为 “mypass”,存档将以 .bcup 为扩展名保存在你选择的位置。
|
||||
|
||||
如果你已经创建了一个,只需单击 “Open Archive File” 来选择它。
|
||||
|
||||
接下来,Buttercup 将提示你为新创建的存档输入主密码,建议提供一个强级别的密码,以保护存档不会被未经授权访问。
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-3.png)
|
||||
|
||||
现在我们已经创建了一个存档并使用主密码对其进行了保护。类似地,你可以创建任意数量的存档,并使用密码保护它们。
|
||||
|
||||
让我们继续在存档中添加账户的详细信息。
|
||||
|
||||
### 在存档中添加条目(登录凭证)
|
||||
|
||||
创建或打开存档后,你将看到下面的界面。
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-4.png)
|
||||
|
||||
它就像一个保险库,我们将保存不同账户的登录凭证。如你所见,我们并没有添加任何条目。让我们添加一些。
|
||||
|
||||
点击右下角的 “ADD ENTRY” 按钮来添加新的条目,输入你想要保存的账户的信息。
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-5-1.png)
|
||||
|
||||
在每个条目下面都有一个 “ADD NEW FIELD” 选项,可以用来添加其他的细节。只需点击它,然后添加要包含在条目中的字段。
|
||||
|
||||
添加完所有条目后,你将在 Buttercup 界面的右侧窗格中看到它们。
|
||||
|
||||
![][6]
|
||||
|
||||
### 添加新的分组
|
||||
|
||||
你还可以将登录的详细信息分组到不同的名称下,以便于识别。例如,你可以将所有邮箱账户分组到一个名为 “my_mails” 的名称下。默认情况下,你的登录详细信息将保存在 “General” 群组下。要创建新的群组,请点击 “NEW GROUP” 按钮并输入名称。在新的群组中创建新条目时,与上述的步骤相同,只需单击组名并开始添加条目。
|
||||
|
||||
### 管理和访问登录的详细信息
|
||||
|
||||
存储在存档中的数据可以随时编辑、移动到其他组或彻底删除。例如,如果要将用户名或密码复制到剪切板,请右击该条目,然后选择 “Copy to Clipboard”。
|
||||
|
||||
![][7]
|
||||
|
||||
要进一步编辑/修改数据,只需点击所选条目下的 “Edit” 按钮。
|
||||
|
||||
### 在远程保存存档
|
||||
|
||||
默认情况下,Buttercup 会将数据保存在本地系统上。但是,你可以将它们保存在不同的远程服务(例如 Dropbox、OwnCloud、NextCloud 和基于 WebDAV 的服务)上。
|
||||
|
||||
要连接这些服务,请点击 “File -> Connect Cloud Sources”。
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-8.png)
|
||||
|
||||
接下来,选择要连接的服务并对其授权以保存数据。
|
||||
|
||||
![][8]
|
||||
|
||||
你还可以在添加存档时在 Buttercup 的欢迎界面连接这些服务。
|
||||
|
||||
### 导入/导出
|
||||
|
||||
Buttercup 允许你向其他密码管理器(例如 1Password、Lastpass 和 KeePass)导入导出数据。你也可以导出数据,在另一个系统或设备(例如 Android)中访问它们。你还可以将 Buttercup 保险库导出为 CSV 格式文件。
|
||||
|
||||
![][9]
|
||||
|
||||
Buttercup 是一个简单但成熟、功能齐全的密码管理器。多年来它一直在积极开发。如果你需要密码管理器,Buttercup 可能是个不错的选择。有关更多的详细信息,请参阅项目网站和 GitHub 页面。
|
||||
|
||||
那就介绍到这里,希望它对你有用。更多的精彩内容即将到来,敬请关注!
|
||||
|
||||
谢谢!
|
||||
|
||||
### 资源
|
||||
|
||||
- [Buttercup 网站](https://buttercup.pw/)
|
||||
- [Buttercup GitHub 仓库](https://github.com/buttercup/buttercup-desktop)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/buttercup-a-free-secure-and-cross-platform-password-manager/
|
||||
|
||||
作者:[SK][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[seriouszyx](https://github.com/seriouszyx)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.ostechnix.com/author/sk/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://linux.cn/article-10211-1.html
|
||||
[2]: https://github.com/buttercup/buttercup-desktop/releases/latest
|
||||
[3]: https://aur.archlinux.org/packages/buttercup-desktop/
|
||||
[4]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/
|
||||
[5]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
|
||||
[6]: http://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-6.png
|
||||
[7]: http://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-7.png
|
||||
[8]: http://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-9.png
|
||||
[9]: http://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-10.png
|
@ -1,17 +1,19 @@
|
||||
Udev 入门:管理设备事件的 Linux 子系统
|
||||
udev 入门:管理设备事件的 Linux 子系统
|
||||
======
|
||||
创建这样一个脚本,当指定的设备插入时触发你的计算机去做一个指定动作。
|
||||
|
||||
> 创建这样一个脚本,当指定的设备插入时触发你的计算机去做一个指定动作。
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_520x292_opensourceprescription.png?itok=gFrc_GTH)
|
||||
|
||||
Udev 是一个让你的计算机使用设备事件的 Linux 子系统。通俗来讲就是,当你的计算机上插入了像网卡、外置硬盘(包括 U 盘)、鼠标、键盘、游戏操纵杆和手柄、DVD-ROM 驱动器等等设备时,代码能够检测到它们。这样就能写出很多可能非常有用的实用程序,而它已经很好了,普通用户就可以写出脚本去做一些事情,比如当某个硬盘驱动器插入时,执行某个任务。
|
||||
udev 是一个为你的计算机提供设备事件的 Linux 子系统。通俗来讲就是,当你的计算机上插入了像网卡、外置硬盘(包括 U 盘)、鼠标、键盘、游戏操纵杆和手柄、DVD-ROM 驱动器等等设备时,代码能够检测到它们。这样就能写出很多可能非常有用的实用程序,而它已经很好了,普通用户就可以写出脚本去做一些事情,比如当某个硬盘驱动器插入时,执行某个任务。
|
||||
|
||||
这篇文章教你去如何写一个由一些 udev 事件触发的 [udev][1] 脚本,比如插入了一个 U 盘。当你理解了 udev 的工作原理,你就可以用它去做各种事情,比如当一个游戏手柄连接后加载一个指定的驱动程序,或者当你用于备份的驱动器连接后,自动执行备份工作。
|
||||
|
||||
### 一个初级的脚本
|
||||
|
||||
使用 udev 的最佳方式是让它工作在一个小的代码块中。不要指望从一开始就写出完整的脚本,而是从最简单的确认 udev 触发了某些指定的事件开始。
|
||||
使用 udev 的最佳方式是从一个小的代码块开始。不要指望从一开始就写出完整的脚本,而是从最简单的确认 udev 触发了某些指定的事件开始。
|
||||
|
||||
对于你的脚本,依据你的目标,并不是在任何情况下都能保证你亲眼看到你的脚本运行结果的,因此需要在你的脚本日志中确认它成功触发了。而日志文件通常放在 **/var** 目录下,但那个目录通常是 root 用户的领地。对于测试目的,可以使用 **/tmp**,它可以被普通用户访问并且在重启动后就被清除了。
|
||||
对于你的脚本,依据你的目标,并不是在任何情况下都能保证你亲眼看到你的脚本运行结果的,因此需要在你的脚本日志中确认它成功触发了。而日志文件通常放在 `/var` 目录下,但那个目录通常是 root 用户的领地。对于测试目的,可以使用 `/tmp`,它可以被普通用户访问并且在重启动后就被清除了。
|
||||
|
||||
打开你喜欢的文本编辑器,然后输入下面的简单脚本:
|
||||
|
||||
@ -21,14 +23,14 @@ Udev 是一个让你的计算机使用设备事件的 Linux 子系统。通俗
|
||||
echo $date > /tmp/udev.log
|
||||
```
|
||||
|
||||
把这个脚本放在 **/usr/local/bin** 或缺省可运行路径的位置中。将它命名为 **trigger.sh**,并运行 **chmod +x** 授予可运行权限:
|
||||
把这个脚本放在 `/usr/local/bin` 或缺省可运行路径的位置中。将它命名为 `trigger.sh`,并运行 `chmod +x` 授予可运行权限:
|
||||
|
||||
```
|
||||
$ sudo mv trigger.sh /usr/local/bin
|
||||
$ sudo chmod +x /usr/local/bin/trigger.sh
|
||||
```
|
||||
|
||||
udev 用这个脚本并不做任何事情。当它运行时,这个脚本将在文件 **/tmp/udev.log** 中放入当前的时间戳。你可以自己测试一下这个脚本:
|
||||
这个脚本没有任何和 udev 有关的事情。当它运行时,这个脚本将在文件 `/tmp/udev.log` 中放入当前的时间戳。你可以自己测试一下这个脚本:
|
||||
|
||||
```
|
||||
$ /usr/local/bin/trigger.sh
|
||||
@ -42,33 +44,31 @@ Tue Oct 31 01:05:28 NZDT 2035
|
||||
|
||||
为了让你的脚本能够被一个设备事件触发,udev 必须要知道在什么情况下调用该脚本。在现实中,你可以通过它的颜色、制造商、以及插入到你的计算机这一事实来识别一个 U 盘。而你的计算机,它需要一系列不同的标准。
|
||||
|
||||
Udev 通过序列号、制造商、以及提供商 ID 和产品 ID 号来识别设备。由于现在你的 udev 脚本还处于它的生命周期的早期阶段,因此要尽可能地宽泛、非特定和全包括。换句话说就是,你希望首先去捕获尽可能多的有效 udev 事件来触发你的脚本。
|
||||
udev 通过序列号、制造商、以及提供商 ID 和产品 ID 号来识别设备。由于现在你的 udev 脚本还处于它的生命周期的早期阶段,因此要尽可能地宽泛、非特定和包容。换句话说就是,你希望首先去捕获尽可能多的有效 udev 事件来触发你的脚本。
|
||||
|
||||
使用 **udevadm monitor** 命令你可以实时利用 udev,并且可以看到当你插入不同设备时发生了什么。用 root 权限试一试。
|
||||
使用 `udevadm monitor` 命令你可以实时利用 udev,并且可以看到当你插入不同设备时发生了什么。用 root 权限试一试。
|
||||
|
||||
```
|
||||
$ su
|
||||
# udevadm monitor
|
||||
```
|
||||
|
||||
监视函数输出接收到的事件:
|
||||
该监视函数输出接收到的事件:
|
||||
|
||||
* UDEV:在规则处理之后发出 udev 事件
|
||||
* KERNEL:内核发送 uevent 事件
|
||||
|
||||
在 `udevadm monitor` 命令运行时,插入一个 U 盘,你将看到各种信息在你的屏幕上滚动而出。注意那一个 `ADD` 事件的事件类型。这是你所需要的识别事件类型的一个好方法。
|
||||
|
||||
|
||||
在 **udevadm monitor** 命令运行时,插入一个 U 盘,你将看到各种信息在你的屏幕上滚动而出。注意那一个 **ADD** 事件的事件类型。这是你所需要的识别事件类型的一个好方法。
|
||||
|
||||
**udevadm monitor** 命令提供了许多很好的信息,但是你可以使用 **udevadm info** 命令以更好看的格式来看到它,假如你知道你的 U 盘当前已经位于你的 **/dev** 树。如果不在这个树下,拔下它并重新插入,然后立即运行这个命令:
|
||||
`udevadm monitor` 命令提供了许多很好的信息,但是你可以使用 `udevadm info` 命令以更好看的格式来看到它,假如你知道你的 U 盘当前已经位于你的 `/dev` 树。如果不在这个树下,拔下它并重新插入,然后立即运行这个命令:
|
||||
|
||||
```
|
||||
$ su -c 'dmesg | tail | fgrep -i sd*'
|
||||
```
|
||||
|
||||
举例来说,如果那个命令返回 **sdb: sdb1**,说明内核已经给你的 U 盘分配了 **sdb** 卷标。
|
||||
举例来说,如果那个命令返回 `sdb: sdb1`,说明内核已经给你的 U 盘分配了 `sdb` 卷标。
|
||||
|
||||
或者,你可以使用 **lsblk** 命令去查看所有附加到你的系统上的驱动器,包括它的大小和分区。
|
||||
或者,你可以使用 `lsblk` 命令去查看所有连接到你的系统上的驱动器,包括它的大小和分区。
|
||||
|
||||
现在,你的驱动器已经处于你的文件系统中了,你可以使用下面的命令去查看那个设备的相关 udev 信息:
|
||||
|
||||
@ -80,7 +80,7 @@ $ su -c 'dmesg | tail | fgrep -i sd*'
|
||||
|
||||
你的任务是从 udev 的报告中找出能唯一标识那个设备的部分,然后当计算机检测到这些唯一属性时,告诉 udev 去触发你的脚本。
|
||||
|
||||
**udevadm info** 命令处理一个(由设备路径指定的)设备上的报告,接着“遍历”父级设备链。对于找到的大多数设备,它以一个“键值对”格式输出所有可能的属性。你可以写一个规则,从一个单个的父级设备属性上去匹配插入设备的属性。
|
||||
`udevadm info` 命令处理一个(由设备路径指定的)设备上的报告,接着“遍历”父级设备链。对于找到的大多数设备,它以一个“键值对”格式输出所有可能的属性。你可以写一个规则,从一个单个的父级设备属性上去匹配插入设备的属性。
|
||||
|
||||
```
|
||||
looking at device '/devices/000:000/blah/blah//block/sdb':
|
||||
@ -98,11 +98,11 @@ looking at device '/devices/000:000/blah/blah//block/sdb':
|
||||
|
||||
一个 udev 规则必须包含来自单个父级设备的一个属性。
|
||||
|
||||
父级属性是描述一个设备的最基本的东西,比如它是插入到一个物理端口的东西、或是一个多大的东西、或这是一个可移除的设备。
|
||||
父级属性是描述一个设备的最基本的东西,比如它是插入到一个物理端口的东西、或是一个容量多大的东西、或这是一个可移除的设备。
|
||||
|
||||
由于内核卷标 **sdb** 可能会由于分配给在它之前插入的其它驱动器而发生变化,因此卷标并不是一个 udev 规则的父级属性的好选择。但是,在做概念论证时你可以使用它。一个事件的最佳候选者是 SUBSYSTEM 属性,它表示那个设备是一个 “block” 系统设备(也就是为什么我们要使用 **lsblk** 命令来列出设备的原因)。
|
||||
由于 `KERNEL` 卷标 `sdb` 可能会由于分配给在它之前插入的其它驱动器而发生变化,因此卷标并不是一个 udev 规则的父级属性的好选择。但是,在做概念论证时你可以使用它。一个事件的最佳候选者是 `SUBSYSTEM` 属性,它表示那个设备是一个 “block” 系统设备(也就是为什么我们要使用 `lsblk` 命令来列出设备的原因)。
|
||||
|
||||
在 **/etc/udev/rules.d** 目录中打开一个名为 **80-local.rules** 的文件,然后输入如下代码:
|
||||
在 `/etc/udev/rules.d` 目录中打开一个名为 `80-local.rules` 的文件,然后输入如下代码:
|
||||
|
||||
```
|
||||
SUBSYSTEM=="block", ACTION=="add", RUN+="/usr/local/bin/trigger.sh"
|
||||
@ -112,9 +112,9 @@ SUBSYSTEM=="block", ACTION=="add", RUN+="/usr/local/bin/trigger.sh"
|
||||
|
||||
等等,重启动 Linux 机器?
|
||||
|
||||
理论上说,你只需要运行 **udevadm control —reload** 即可,它将重新加载所有规则,但是在我们实验的现阶段,最好要排除可能影响实验结果的所有因素。Udev 是非常复杂的,为了不让你躺在床上整晚都在思考为什么这个规则不能正常工作,是因为语法错误吗?还是应该重启动一下。所以,不管 POSIX 自负地告诉你过什么,你都应该去重启动一下。
|
||||
理论上说,你只需要运行 `udevadm control —reload` 即可,它将重新加载所有规则,但是在我们实验的现阶段,最好要排除可能影响实验结果的所有因素。udev 是非常复杂的,为了不让你躺在床上整晚都在思考为什么这个规则不能正常工作,是因为语法错误吗?还是应该重启动一下。所以,不管 POSIX 自负地告诉你过什么,你都应该去重启动一下。
|
||||
|
||||
当你的系统重启动完毕之后,(使用 Ctl+Alt+F3 或类似快捷键)切换到一个文本控制台,并插入你的 U 盘。如果你运行了一个最新的内核,当你插入 U 盘后你或许可以看到一大堆输出。如果看到一个错误信息,比如 “Could not execute /usr/local/bin/trigger.sh”,或许是因为你忘了授予这个脚本可运行的权限。否则你将看到的是,一个设备插入,它得到内核设备分配的一些东西,等等。
|
||||
当你的系统重启动完毕之后,(使用 `Ctl+Alt+F3` 或类似快捷键)切换到一个文本控制台,并插入你的 U 盘。如果你运行了一个最新的内核,当你插入 U 盘后你或许可以看到一大堆输出。如果看到一个错误信息,比如 “Could not execute /usr/local/bin/trigger.sh”,或许是因为你忘了授予这个脚本可运行的权限。否则你将看到的是,一个设备插入,它得到内核设备分配的一些东西,等等。
|
||||
|
||||
现在,见证奇迹的时刻到了。
|
||||
|
||||
@ -123,13 +123,13 @@ $ cat /tmp/udev.log
|
||||
Tue Oct 31 01:35:28 NZDT 2035
|
||||
```
|
||||
|
||||
如果你在 **/tmp/udev.log** 中看到了最新的日期和时间,那么说明 udev 已经成功触发了你的脚本。
|
||||
如果你在 `/tmp/udev.log` 中看到了最新的日期和时间,那么说明 udev 已经成功触发了你的脚本。
|
||||
|
||||
### 改进规则做一些有用的事情
|
||||
|
||||
现在的问题是使用的规则太通用了。插入一个鼠标、一个 U 盘、或某个人的 U 盘都将盲目地触发这个脚本。现在,我们开始专注于希望触发你的脚本的是确定的某个 U 盘。
|
||||
|
||||
实现上述目标的一种方式是使用提供商 ID 和产品 ID。你可以使用 **lsusb** 命令去得到这些数字。
|
||||
实现上述目标的一种方式是使用提供商 ID 和产品 ID。你可以使用 `lsusb` 命令去得到这些数字。
|
||||
|
||||
```
|
||||
$ lsusb
|
||||
@ -140,7 +140,7 @@ Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 hub
|
||||
Bus 001 Device 003: ID 13d3:5165 SBo Networks
|
||||
```
|
||||
|
||||
在这个例子中,**TyCoon Corp** 前面的 **03f0:3307** 就表示了提供商 ID 和产品 ID 的属性。你也可以通过 **udevadm info -a -n /dev/sdb | grep vendor** 的输出来查看这些数字,但是从 **lsusb** 的输出中可以很容易地一眼找到这些数字。
|
||||
在这个例子中,`TyCoon Corp` 前面的 `03f0:3307` 就表示了提供商 ID 和产品 ID 的属性。你也可以通过 `udevadm info -a -n /dev/sdb | grep vendor` 的输出来查看这些数字,但是从 `lsusb` 的输出中可以很容易地一眼找到这些数字。
|
||||
|
||||
现在,可以在你的脚本中包含这些属性了。
|
||||
|
||||
@ -150,7 +150,7 @@ SUBSYSTEM=="block", ATTRS{idVendor}=="03f0", ACTION=="add", RUN+="/usr/local/bin
|
||||
|
||||
测试它(是的,为了确保不会有来自 udev 的影响因素,我们仍然建议先重新启动一下),它应该会像前面一样工作,现在,如果你插入一个不同公司制造的 U 盘(因为它们的提供商 ID 不一样)、或插入一个鼠标、或插入一个打印机,这个脚本将不会被触发。
|
||||
|
||||
继续添加新属性来进一步专注于你希望去触发你的脚本的那个唯一的 U 盘。使用 **udevadm info -a -n /dev/sdb** 命令,你可以找出像提供商名字、序列号、或产品名这样的东西。
|
||||
继续添加新属性来进一步专注于你希望去触发你的脚本的那个唯一的 U 盘。使用 `udevadm info -a -n /dev/sdb` 命令,你可以找出像提供商名字、序列号、或产品名这样的东西。
|
||||
|
||||
为了保证思路清晰,确保每次只添加一个新属性。我们(和在网上看到的其他人)在 udev 规则中所遇到的大多数错误都是因为一次添加了太多的属性,而奇怪为什么不能正常工作了。逐个测试属性是最安全的作法,这样可以确保 udev 能够成功识别到你的设备。
|
||||
|
||||
@ -163,15 +163,13 @@ SUBSYSTEM=="block", ATTRS{idVendor}=="03f0", ACTION=="add", RUN+="/usr/local/bin
|
||||
1. 聚焦于你的 udev 规则,当你真实地使用它们时,一旦让规则发挥作用将触发脚本。执行一个脚本去盲目地复制数据到你的计算上,或从你的计算机上复制出数据,是一个很糟糕的主意,因为有可能会遇到一个人拿着和你相同品牌的 U 盘插入到你的机器上的情况。
|
||||
2. 不要在写了 udev 规则和脚本后忘记了它们的存在。我知道哪个计算上有我的 udev 规则,这些机器一般是我的个人计算机,而不是那些我带着去开会或办公室工作的计算机。一台计算机的 “社交” 程度越高,它就越不能有 udev 规则存在于它上面,因为它将潜在地导致我的数据最终可能会出现在某个人的设备、或某个人的数据中、或在我的设备上出现恶意程序。
|
||||
|
||||
|
||||
|
||||
换句话说就是,随着一个 GNU 系统提供了一个这么强大的功能,你的任务是小心地如何使用它们的强大功能。如果你滥用它或不小心谨慎地使用它,最终将让你出问题,它非常可能会导致可怕的问题。
|
||||
|
||||
### 现实中的 Udev
|
||||
|
||||
现在,你可以确认你的脚本是由 udev 触发的,那么,可以将你的关注点转到脚本功能上了。到目前为止,这个脚本是没有用的,它除了记录脚本已经运行过了这一事实外,再没有做更多的事情。
|
||||
|
||||
我使用 udev 去触发我的 U 盘的 [自动备份][2] 。这个创意是,将我正在处理的文档的主复本保存在我的 U 盘上(因为我随身带着它,这样就可以随时处理它),并且在我每次将 U 盘插入到那台机器上时,这些主文档将备份回我的计算机上。换句话说就是,我的计算机是备份驱动器,而产生的数据是移动的。源代码是可用的,你可以随意查看 attachup 的代码,以进一步限制你的 udev 的测试示例。
|
||||
我使用 udev 去触发我的 U 盘的 [自动备份][2] 。这个创意是,将我正在处理的文档的主副本保存在我的 U 盘上(因为我随身带着它,这样就可以随时处理它),并且在我每次将 U 盘插入到那台机器上时,这些主文档将备份回我的计算机上。换句话说就是,我的计算机是备份驱动器,而产生的数据是移动的。源代码是可用的,你可以随意查看 `attachup` 的代码,以进一步限制你的 udev 的测试示例。
|
||||
|
||||
虽然我使用 udev 最多的情况就是这个例子,但是 udev 能抓取很多的事件,像游戏手柄(当连接游戏手柄时,让系统去加载 xboxdrv 模块)、摄像头、麦克风(当指定的麦克风连接时用于去设置输入),所以应该意识到,它能做的事情远比这个示例要多。
|
||||
|
||||
@ -182,7 +180,7 @@ SUBSYSTEM=="block", ATTRS{idVendor}=="03f0", ACTION=="add", SYMLINK+="safety%n"
|
||||
SUBSYSTEM=="block", ATTRS{idVendor}=="03f0", ACTION=="add", RUN+="/usr/local/bin/trigger.sh"
|
||||
```
|
||||
|
||||
第一行使用属性去检测我的 U 盘,这在前面已经讨论过了,接着在设备树中为我的 U 盘分配一个符号链接,给它分配的符号连接是 **safety%n**。这个 **%n** 是一个 udev 宏,它是内核分配给这个设备的任意数字,比如 sdb1、sdb2、sdb3、等等。因此 **%n** 应该是 1 或 2 或 3。
|
||||
第一行使用属性去检测我的 U 盘,这在前面已经讨论过了,接着在设备树中为我的 U 盘分配一个符号链接,给它分配的符号连接是 `safety%n`。这个 `%n` 是一个 udev 宏,它是内核分配给这个设备的任意数字,比如 sdb1、sdb2、sdb3、等等。因此 `%n` 应该是 1 或 2 或 3。
|
||||
|
||||
这将在 dev 树中创建一个符号链接,因此它不会干涉插入一个设备的正常过程。这意味着,如果你在自动挂载设备的桌面环境中使用它,将不会出现问题。
|
||||
|
||||
@ -198,13 +196,13 @@ sleep 2
|
||||
rsync -az /mnt/hd/ /home/seth/backups/ && umount /dev/safety1
|
||||
```
|
||||
|
||||
这个脚本使用符号链接,这将避免出现 udev 命名导致的意外情况(例如,假设一个命名为 DISK 的 U 盘已经插入到我的计算机上,而我插入的其它 U 盘恰好名字也是 DISK,那么第二个 U 盘的卷标将被命名为 `DISK_`,这将导致我的脚本不会正常运行),它在我喜欢的挂载点 **/mnt/hd** 上挂载了 **safety1**(驱动器的第一个分区)。
|
||||
这个脚本使用符号链接,这将避免出现 udev 命名导致的意外情况(例如,假设一个命名为 DISK 的 U 盘已经插入到我的计算机上,而我插入的其它 U 盘恰好名字也是 DISK,那么第二个 U 盘的卷标将被命名为 `DISK_`,这将导致我的脚本不会正常运行),它在我喜欢的挂载点 `/mnt/hd` 上挂载了 `safety1`(驱动器的第一个分区)。
|
||||
|
||||
一旦 safely 挂载之后,它将使用 [rsync][3] 将驱动器备份到我的备份文件夹(我真实使用的脚本用的是 rdiff-backup,而你可以使用任何一个你喜欢的自动备份解决方案)。
|
||||
一旦 `safely` 挂载之后,它将使用 [rsync][3] 将驱动器备份到我的备份文件夹(我真实使用的脚本用的是 `rdiff-backup`,而你可以使用任何一个你喜欢的自动备份解决方案)。
|
||||
|
||||
### Udev 让你的设备你做主
|
||||
### udev 让你的设备你做主
|
||||
|
||||
Udev 是一个非常灵活的系统,它可以让你用其它系统很少敢提供给用户的方式去定义规则和功能。学习它,使用它,去享受 POSIX 的强大吧。
|
||||
udev 是一个非常灵活的系统,它可以让你用其它系统很少敢提供给用户的方式去定义规则和功能。学习它,使用它,去享受 POSIX 的强大吧。
|
||||
|
||||
本文内容来自 [Slackermedia Handbook][4],它以 [GNU Free Documentation License 1.3][5] 许可证授权使用。
|
||||
|
||||
@ -215,7 +213,7 @@ via: https://opensource.com/article/18/11/udev
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[qhwdw](https://github.com/qhwdw)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,116 +0,0 @@
|
||||
translating by valoniakim
|
||||
|
||||
What NASA Has Been Doing About Open Science
|
||||
======
|
||||
![][1]
|
||||
|
||||
We have recently started a new [Science category][2] on It’s FOSS. We covered [how open source approach is impacting Science][3] in the last article. In this open science article, we discuss [NASA][4]‘s actively growing efforts that involve their dynamic role in boosting scientific research by encouraging open source practices.
|
||||
|
||||
### How NASA is using Open Source approach to improve science
|
||||
|
||||
It was a great [initiative][5] by NASA that they made their entire research library freely available on the public domain.
|
||||
|
||||
Yes! Entire research library for everyone to access and get benefit from it in their research.
|
||||
|
||||
Their open science resources can now be mainly classified into these three categories as follows:
|
||||
|
||||
* Open Source NASA
|
||||
* Open API
|
||||
* Open Data
|
||||
|
||||
|
||||
|
||||
#### 1\. Open Source NASA
|
||||
|
||||
Here’s an interesting interview of [Chris Wanstrath][6], co-founder and CEO of [GitHub][7], about how it all began to form many years ago:
|
||||
|
||||
Uniquely named “[code.nasa.gov][8]“, NASA now has precisely 365 scientific software available as [open source via GitHub][9] as of the time of this post. So if you are a developer who loves coding, you can study each one of them every day for a year’s time!
|
||||
|
||||
Even if you are not a developer, you can still browse through the fantastic collection of open source packages enlisted on the portal!
|
||||
|
||||
One of the interesting open source packages listed here is the source code of [Apollo 11][10]‘s guidance computer. The Apollo 11 spaceflight took [the first two humans to the Moon][11], namely, [Neil Armstrong][12] and [Edwin Aldrin][13] ! If you want to know more about Edwin Aldrin, you might want to pay a visit [here][14].
|
||||
|
||||
##### Licenses being used by NASA’s Open Source Initiative:
|
||||
|
||||
Here are the different [open source licenses][15] categorized as under:
|
||||
|
||||
#### 2\. Open API
|
||||
|
||||
An Open [Application Programming Interface][16] or API plays a significant role in practicing Open Science. Just like [The Open Source Initiative][17], there is also one for API, called [The Open API Initiative][18]. Here is a simple illustration of how an API bridges an application with its developer:
|
||||
|
||||
![][19]
|
||||
|
||||
Do check out the link in the caption in the image above. The API has been explained in a straightforward manner. It concludes with five exciting takeaways in the end.
|
||||
|
||||
![][20]
|
||||
|
||||
Makes one wonder how different [an open vs a proprietary API][21] would be.
|
||||
|
||||
![][22]
|
||||
|
||||
Targeted towards application developers, [NASA’s open API][23] is an initiative to significantly improve the accessibility of data that could also contain image content. The site has a live editor, allowing you check out the [API][16] behind [Astronomy Picture of the Day (APOD)][24].
|
||||
|
||||
#### 3\. Open Data
|
||||
|
||||
![][25]
|
||||
|
||||
In [our first science article][3], we shared with you the various open data models of three countries mentioned under the “Open Science” section, namely, France, India and the U.S. NASA also has a similar approach towards the same idea. This is a very important ideology that is being adopted by [many countries][26].
|
||||
|
||||
[NASA’s Open Data Portal][27] focuses on openness by having an ever-growing catalog of data, available for anyone to access freely. The inclusion of datasets within this collection is an essential and radical step towards the development of research of any kind. NASA have even taken a fantastic initiative to ask for dataset suggestions for submission on their portal and that’s really very innovative, considering the growing trends of [data science][28], [AI and deep learning][29].
|
||||
|
||||
The following video shows students and scientists coming up with their own definitions of Data Science based on their personal experience and research. That is really encouraging! [Dr. Murtaza Haider][30], Ted Rogers School of Management, Ryerson University, mentions the difference Open Source is making in the field of Data Science before the video ends. He explains in very simple terms, how development models transitioned from a closed source approach to an open one. The vision has proved to be sufficiently true enough in today’s time.
|
||||
|
||||
![][31]
|
||||
|
||||
Now anyone can suggest a dataset of any kind on NASA. Coming back to the video above, NASA’s initiative can be related so much with submitting datasets and working on analyzing them for better Data Science!
|
||||
|
||||
![][32]
|
||||
|
||||
You just need to signup for free. This initiative will have a very positive effect in the future, considering open discussions on the public forum and the significance of datasets in every type of analytical field that could exist. Statistical studies will also significantly improve for sure. We will talk about these concepts in detail in a future article and also about their relativeness to an open source model.
|
||||
|
||||
So thus concludes an exploration into NASA’s open science model. See you soon in another open science article!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/nasa-open-science/
|
||||
|
||||
作者:[Avimanyu Bandyopadhyay][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/avimanyu/
|
||||
[1]:https://itsfoss.com/wp-content/uploads/2018/03/tux-in-space.jpg
|
||||
[2]:https://itsfoss.com/category/science/
|
||||
[3]:https://itsfoss.com/open-source-impact-on-science/
|
||||
[4]:https://www.nasa.gov/
|
||||
[5]:https://futurism.com/free-science-nasa-just-opened-its-entire-research-library-to-the-public/
|
||||
[6]:http://chriswanstrath.com/
|
||||
[7]:https://github.com/
|
||||
[8]:http://code.nasa.gov
|
||||
[9]:https://github.com/open-source
|
||||
[10]:https://www.nasa.gov/mission_pages/apollo/missions/apollo11.html
|
||||
[11]:https://www.space.com/16758-apollo-11-first-moon-landing.html
|
||||
[12]:https://www.jsc.nasa.gov/Bios/htmlbios/armstrong-na.html
|
||||
[13]:https://www.jsc.nasa.gov/Bios/htmlbios/aldrin-b.html
|
||||
[14]:https://buzzaldrin.com/the-man/
|
||||
[15]:https://itsfoss.com/open-source-licenses-explained/
|
||||
[16]:https://en.wikipedia.org/wiki/Application_programming_interface
|
||||
[17]:https://opensource.org/
|
||||
[18]:https://www.openapis.org/
|
||||
[19]:https://itsfoss.com/wp-content/uploads/2018/03/api-bridge.jpeg
|
||||
[20]:https://itsfoss.com/wp-content/uploads/2018/03/open-api-diagram.jpg
|
||||
[21]:http://www.apiacademy.co/resources/api-strategy-lesson-201-private-apis-vs-open-apis/
|
||||
[22]:https://itsfoss.com/wp-content/uploads/2018/03/nasa-open-api-live-example.jpg
|
||||
[23]:https://api.nasa.gov/
|
||||
[24]:https://apod.nasa.gov/apod/astropix.html
|
||||
[25]:https://itsfoss.com/wp-content/uploads/2018/03/nasa-open-data-portal.jpg
|
||||
[26]:https://www.xbrl.org/the-standard/why/ten-countries-with-open-data/
|
||||
[27]:https://data.nasa.gov/
|
||||
[28]:https://en.wikipedia.org/wiki/Data_science
|
||||
[29]:https://www.kdnuggets.com/2017/07/ai-deep-learning-explained-simply.html
|
||||
[30]:https://www.ryerson.ca/tedrogersschool/bm/programs/real-estate-management/murtaza-haider/
|
||||
[31]:https://itsfoss.com/wp-content/uploads/2018/03/suggest-dataset-nasa-1.jpg
|
||||
[32]:https://itsfoss.com/wp-content/uploads/2018/03/suggest-dataset-nasa-2-1.jpg
|
@ -1,3 +1,5 @@
|
||||
translating by valoniakim
|
||||
|
||||
Person with diabetes finds open source and builds her own medical device
|
||||
======
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/health_heartbeat.png?itok=P-GXea-p)
|
||||
|
@ -1,58 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (10 ways to give thanks to open source and free software maintainers)
|
||||
[#]: via: (https://opensource.com/article/18/11/ways-give-thanks-open-source)
|
||||
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
|
||||
[#]: url: ( )
|
||||
|
||||
10 ways to give thanks to open source and free software maintainers
|
||||
======
|
||||
How to express your gratitude.
|
||||
![](https://opensource.com/users/moshez)
|
||||
|
||||
Every day, I use high-quality software that is developed and maintained by people who do not ask for payment, who respect my freedoms, and who are generous with their time and energy.
|
||||
|
||||
In this season of giving thanks, I encourage those of you who also use and appreciate the work of open source and free software maintainers to express your gratitude. Here are ten ways to do that:
|
||||
|
||||
### Easy to do
|
||||
|
||||
1. Send an e-mail thanking the developers. Be specific—tell them what you are using their software for and how it has benefited you.
|
||||
2. Use your favorite social media platform to spread the word.
|
||||
3. Write a blog post about your favorite software.
|
||||
|
||||
|
||||
|
||||
### Give money
|
||||
|
||||
4. If your favorite open source projects accept donations, send money.
|
||||
5. If you are employed by a company that uses open source software, see if you can convince management to sponsor some of the projects.
|
||||
6. Offer to match donations up to a set amount. It is amazing what social motivation can do!
|
||||
|
||||
|
||||
|
||||
### Give time
|
||||
|
||||
7. Help review patches.
|
||||
8. Help triage bugs.
|
||||
9. Answer questions on IRC, mailing lists, or [Stack Overflow][1].
|
||||
|
||||
|
||||
|
||||
**10. Bonus:** If you are like me, you have at some point said harsh words to other people in the open source community. Commit to do better: Communicate with kindness and openness. The best way to give thanks is to make the open source community a place where people feel comfortable communicating.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/11/ways-give-thanks-open-source
|
||||
|
||||
作者:[Moshe Zadka][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/moshez
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://meta.stackoverflow.com/
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (alim0x)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (DevOps is for everyone)
|
||||
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (seriouszyx)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (What the open source community means to me)
|
||||
|
@ -1,60 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (3 implications of serverless)
|
||||
[#]: via: (https://opensource.com/article/18/12/serverless-podcast-command-line-heros)
|
||||
[#]: author: (Jen Wike Huger https://opensource.com/users/remyd)
|
||||
[#]: url: ( )
|
||||
|
||||
3 implications of serverless
|
||||
======
|
||||
Plus, when to go serverless and when to not?
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux11x_cc.png?itok=XMDOouJR)
|
||||
|
||||
If you strip away all of the modern conveniences and features that make up your internet experience today, what you're left with is the client-server model. This distributed network was what the internet was built on in the beginning, and that part hasn't changed. You could say, it is still serving us well.
|
||||
|
||||
So, when people talk about serverless, what does it mean? Well, it doesn't mean servers are GONE. Of course not: That "client-server model" is still the backbone of how things are getting done.
|
||||
|
||||
Serverless refers to a developer's ability to code, deploy, and create applications without having to know how to do the rest of it, like rack the servers, patch the operating system, and create container images.
|
||||
|
||||
### Top 3 implications of serverless
|
||||
|
||||
1. People who might not have been before are becoming developers now. Why? They have to learn less of that kind of stuff and get to do more of the creative stuff.
|
||||
2. Developers don't have the recreate the wheel. Why? They let serverless providers do what they do best: run and maintain the servers, patch the operating systems, and build containers.
|
||||
3. Reality check: Someone on your team still has to think about the big picture, about operations. Why? Because when your server crashes or any decision at all needs to be made about the server-side of your project or product, your phone will ring and someone has to pick up. Preferably someone who knows the gameplan, your strategy for going serverless.
|
||||
|
||||
|
||||
|
||||
### When to serverless and when to not?
|
||||
|
||||
So, serverless is great, right? But, the truth is it isn't always the right call. What are the factors that should be considered?
|
||||
|
||||
1. Cost
|
||||
2. Scale
|
||||
3. Time
|
||||
4. Control
|
||||
|
||||
|
||||
|
||||
The last one, control, is where things get interesting. Projects like [Apache OpenWhisk][1] have developed processes and tools to make it possible for you, as a developer, to operate and control your serverless computing environments.
|
||||
|
||||
### Why open source serverless?
|
||||
|
||||
For more on this, check out conversations with leading serverless thinkers and host Saron Yitbarek in [Episode 7 of Command Line Heroes podcast][2].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/12/serverless-podcast-command-line-heros
|
||||
|
||||
作者:[Jen Wike Huger][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/remyd
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/article/18/11/developing-functions-service-apache-openwhisk
|
||||
[2]: https://www.redhat.com/en/command-line-heroes
|
@ -0,0 +1,78 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (5 reasons to give Linux for the holidays)
|
||||
[#]: via: (https://opensource.com/article/18/12/reasons-give-linux-holidays)
|
||||
[#]: author: (Don Watkins https://opensource.com/users/don-watkins)
|
||||
[#]: url: ( )
|
||||
|
||||
5 reasons to give Linux for the holidays
|
||||
======
|
||||
If a computer is on your gift-giving list, here's why it should be Linux.
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tux_linux_penguin_code_binary.jpg?itok=TxGxW0KY)
|
||||
|
||||
Every year around this time, people ask me about the best computer to give (or get) for the holidays. I always give the same answer: Linux. After all, if you want your recipients to be happy, why wouldn't you give them the best operating system on the planet?
|
||||
|
||||
Many people don't realize they have options when it comes to computer operating systems. Just recently, two friends (who didn't do their research) fell for the clever marketing and bought brand-new systems at premium prices. I'm willing to bet that within six months they'll be dissatisfied with those expensive computers.
|
||||
|
||||
In contrast, I recently purchased a four-year-old computer with an i5 processor, 4GB of RAM, and a 128GB SSD drive, and I love it. It's fast and has all the applications I need to be successful and happy. That's because I'm running Linux. Whether I'm using Firefox or Chrome, all my websites load quickly and the video is great. In fact, the web is faster on Linux than it is on MacOS or Windows.
|
||||
|
||||
So, if you're in the mood to give a computer for the holidays, here are five good reasons it should be Linux.
|
||||
|
||||
### 1\. Linux is easy to use
|
||||
|
||||
Linux distributions like [Fedora][1], [Ubuntu][2], [PopOS][3], [Linux Mint][4], and [Raspbian][5] come with loads of documentation and access to a user community eager to help. And desktop environments such as [GNOME][6], [KDE][7], and [LXDE][8] mean the Linux operating system is just plain easy. If you have a problem with a Linux operating system, you won't have to wait in a long telephone queue for an answer—you can tap into the community's knowledge.
|
||||
|
||||
### 2\. Free applications for practically anything you need
|
||||
|
||||
There are hundreds of high-quality, free software packages available for Linux. My favorites are [LibreOffice][9] and [GnuCash][10]. I cannot imagine any writing task that is beyond the scope of LibreOffice. I use it and recommend it to everyone I know. Why spend money on a name-brand productivity suite when LibreOffice, the best one out there, is free? (If you agree and you're able, you really ought to consider contributing to the project.)
|
||||
|
||||
### 3\. Security
|
||||
|
||||
Linux is secure, an important fact in an age when security tops most people's essential features list. On Linux, viruses and malware are minimal. I spend many days each year helping friends recover their Windows systems that have been hacked or infected with malware. That's rare on Linux, and if you want to be doubly sure no one gains improper access to your computer, there are plenty of open source solutions that can help prevent it. My favorites are [ClamAV][11] and [Rootkit Hunter][12]. Linux respects your privacy. It does not upload user data to Redmond or Cupertino.
|
||||
|
||||
### 4\. Freedom
|
||||
|
||||
Linux gives me the freedom to use my operating system however I choose, whether that is as a standalone workstation for personal productivity, a content server, a firewall for my home network, or something else. Unlike proprietary desktop operating systems, you don't have to purchase an upgrade or extension to expand your system's capabilities. There are no limitations. Best of all, I can give all of this knowledge away and encourage others to do the same. Isn't giving to others the spirit of holiday traditions?
|
||||
|
||||
### 5\. Stability
|
||||
|
||||
Linux is reliable and stable. The operating system does not crash. When you get updates, they don't require you to reboot while you're in the middle of doing something else. If you're using an older version of Fedora, Ubuntu, or Linux Mint and are happy with the status quo, you don't have to upgrade. Linux also offers more support for drivers of legacy printers and other peripherals than other operating systems.
|
||||
|
||||
### How to give Linux
|
||||
|
||||
Linux could be the best present your friends ever receive. Instead of buying holiday gifts from your favorite retailer, buy some 8GB or 16GB USB drives, download your favorite distribution, and [make some bootable USB][13] drives to give away. Volunteer your time (or include instructions) to help your friends to explore the "live" editions of these distributions before they install the operating system. Or, if you have an old, unused laptop or desktop, consider installing Linux and loaning it out for training purposes. Most of your friends will have no idea what a wonderful gift you are giving them—in the process, you will discover the joy of giving yourself to others.
|
||||
|
||||
If you really want to buy a new computer, this year I recommend you look at [System 76][14] or Dell's [XPS Developer][15] edition. If you don't want a new model, there are plenty of great offerings on [eBay][16], [DellRefurbished.com][17], and other sites that sell good-quality older laptops that are great candidates for an easy Linux install.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/12/reasons-give-linux-holidays
|
||||
|
||||
作者:[Don Watkins][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/don-watkins
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://getfedora.org/
|
||||
[2]: https://www.ubuntu.com/
|
||||
[3]: https://system76.com/pop
|
||||
[4]: https://linuxmint.com/
|
||||
[5]: https://www.raspbian.org/
|
||||
[6]: https://www.gnome.org/
|
||||
[7]: https://www.kde.org/
|
||||
[8]: https://lxde.org/
|
||||
[9]: https://www.libreoffice.org/
|
||||
[10]: https://www.gnucash.org/
|
||||
[11]: https://www.clamav.net/
|
||||
[12]: http://rkhunter.sourceforge.net/
|
||||
[13]: https://opensource.com/article/18/7/getting-started-etcherio
|
||||
[14]: https://system76.com/
|
||||
[15]: https://www.dell.com/en-us/work/shop/dell-laptops-and-notebooks/xps-13-developer-edition/spd/xps-13-9370-laptop?appliedRefinements=302
|
||||
[16]: https://www.ebay.com/b/Computers-Tablets-Network-Hardware/58058/bn_1865247
|
||||
[17]: http://DellRefurbished.com
|
@ -0,0 +1,81 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (F-Words in Linux Kernel Code Replaced with "Hug"?)
|
||||
[#]: via: (https://itsfoss.com/swear-words-linux-kernel/)
|
||||
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
|
||||
[#]: url: ( )
|
||||
|
||||
F-Words in Linux Kernel Code Replaced with "Hug"?
|
||||
======
|
||||
|
||||
**Brief: To comply with the new code of conduct, a developer from Intel proposes to replace F-words in the Linux kernel code with “hug”.**
|
||||
|
||||
![Polite Linus Torvalds after Code of Conduct][1]
|
||||
|
||||
Change is in air for the Linux Kernel Community.
|
||||
|
||||
Ever since the introduction of the [Linux code of conduct][2], things are going in a ‘polite direction’.
|
||||
|
||||
To refresh your memory, a few months back a new code of conduct was introduced for the Linux kernel developers. This code of conduct asks the developers to be nice and welcoming to other developers and be more open to diversity.
|
||||
|
||||
The new code of conduct caused a huge controversy as many Linux users and developers saw it as a conspiracy by Social Justice Warriors (SJW) to infiltrate Linux. The rumors were especially boosted by the [controversial past of the Contributor Covenant creator Coraline Ada Ehmke][2]. The Linux code of conduct is based on the same Contributor Covenant.
|
||||
|
||||
Right after signing the new code of conduct, Linux creator [Linus Torvalds took a month-long break to improve his behavior][3].
|
||||
|
||||
Torvalds who is known for being ruthless against poor code is a changed man now. After [coming back from the break][4], Torvalds controlled his rage and instead of lashing out against a developer, he replied nicely and pointed his mistake in a polite way.
|
||||
|
||||
### No more F-words in the Linux Kernel code?
|
||||
|
||||
There have been F-words in the Linux kernel code. To be clear, these F-words are in the code comments, not in the actual code.
|
||||
|
||||
You might expect that there will be way too many F-words in the 15+ millions of lines of Linux kernel code but that’s not the case.
|
||||
|
||||
Jarkko Sakkinen from Intel pushed [these patches][5] that replace the F-words 33 times in the 3.3 million lines of code comments.
|
||||
|
||||
Interestingly, the patch email is titled “ **Zero ****s, hugload of hugs <3**“:
|
||||
|
||||
> In order to comply with the CoC, replace 选题模板.txt 中文排版指北.md core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LCTT翻译规范.md LICENSE published README.md scripts sources translated with a hug.
|
||||
|
||||
So now comments have become:
|
||||
|
||||
* Only Sun can take such nice parts and **hug** up the programming interface like this
|
||||
* IOC3 is **hugging** **hugged** beyond belief
|
||||
* **Hug** , we are miserable poor guys…
|
||||
|
||||
|
||||
|
||||
### Do you give a ‘hug’ about these changes?
|
||||
|
||||
At this point, it’s not clear if this ‘hugging’ patch has been accepted or not. It’s more of an attempt to bring attention to profanity inside the kernel code.
|
||||
|
||||
So, we have to wait and watch if this patch sets a trend for removing offensive words from the Linux kernel code.
|
||||
|
||||
What do you think of it? Is using ‘hug’ a good choice or do you have a better word for replacing the F-words?
|
||||
|
||||
And what do you think of these changes altogether. Do you think all these are unnecessary and futile exercises?
|
||||
|
||||
And when you comment, please replace your F-words with hugs :)
|
||||
|
||||
Story source: [Phoronix][6]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/swear-words-linux-kernel/
|
||||
|
||||
作者:[Abhishek Prakash][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/abhishek/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/12/hug-you-linus-torvalds.jpeg?resize=800%2C450&ssl=1
|
||||
[2]: https://itsfoss.com/linux-code-of-conduct/
|
||||
[3]: https://itsfoss.com/torvalds-takes-a-break-from-linux/
|
||||
[4]: https://itsfoss.com/torvalds-is-back/
|
||||
[5]: https://lists.freedesktop.org/archives/dri-devel/2018-November/198581.html
|
||||
[6]: https://www.phoronix.com/scan.php?page=news_item&px=Linux-Kernel-Hugs
|
@ -0,0 +1,94 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (6 steps to optimize software delivery with value stream mapping)
|
||||
[#]: via: (https://opensource.com/article/18/12/optimizing-delivery-value-stream-mapping)
|
||||
[#]: author: (Dominika Bula https://opensource.com/users/dominika)
|
||||
|
||||
6 steps to optimize software delivery with value stream mapping
|
||||
======
|
||||
Learn how VSM can help you streamline processes, boost efficiency, and better meet customer expectations.
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_hands_team_collaboration.png?itok=u82QepPk)
|
||||
|
||||
Do your efforts to improve software development fall short due to confusion and too much debate? Does your organization have a clear picture of what is achievable, and are you sure you’re moving in the right direction? Can you determine how much business value you've delivered so far? Are the bottlenecks in your process known? Do you know how to optimize your current process?
|
||||
|
||||
If you are looking for a tool that will help you answer these questions, consider integrating [value stream mapping][1] and [lean concepts][2] into the way you deliver software.
|
||||
|
||||
### What is value stream mapping (VSM)?
|
||||
|
||||
Popularized in the ‘90s by James Womack and Daniel Jones, value stream mapping is a lean enterprise technique that is currently used by many organizations. In short, the value stream is the sequence of activities that are performed by the organization to deliver customer requests. Value stream mapping helps determine what is valuable and what doesn’t bring value by identifying activities that matter to your customer. The ultimate benefit of using VSM is a better understanding of how to improve your current development process to generate more value and impact.
|
||||
|
||||
### 6 steps to optimizing software delivery
|
||||
|
||||
1. **Select the process**
|
||||
|
||||
Any process can be modeled as a sequence of activities. For example, a [system development life cycle][3] is a value stream consisting of product specification, design, development, deployment, operation and maintenance, and finally, disposition. In this example, product design can be viewed as a value stream segment.
|
||||
|
||||
2. **Identify the parties involved in the project**
|
||||
|
||||
Select a project sponsor and team. Keep in mind that each area of the process should be represented. Holistic thinking helps identify and set expectations, which in turn reduces resistance to change.
|
||||
|
||||
3. **Create the current state map**
|
||||
|
||||
Creating the current state map helps establish a better understanding of how work is currently done. Documenting your current process is key to success at this stage. The goal is to identify the specific items that flow through your value stream.
|
||||
|
||||
4. **Challenge the current thinking**
|
||||
|
||||
Make sure that what you are doing adds value—if there are actions in your process that do not add value, stop doing them. Look at the [software development waste types][2] for ideas. Mary Poppendieck and Tom Poppendieck identify these and transfer them from manufacturing to software engineering in their book, [Lean Software Development: An Agile Toolkit][4]. The waste types are:
|
||||
|
||||
* Partially done work
|
||||
* Extra processes
|
||||
* Extra features
|
||||
* Task switching
|
||||
* Waiting
|
||||
* Motion
|
||||
* Defects
|
||||
* Management activities
|
||||
|
||||
|
||||
5. **Generate the future state map and execute improvements**
|
||||
|
||||
Think of what can be done to reduce or ideally eliminate the identified wastes.
|
||||
|
||||
While working on the future state map, follow the principle that humans should do only what they can do best, and the rest should be [automated][5]. The future state design should aim to eliminate hands-on work and deliver completed software projects in less time with higher quality.
|
||||
|
||||
Talk about the changes, let people ask questions—this will help reduce resistance to change. As you start executing improvements, remember that value stream mapping is an evolutionary process, and you might need to adjust the original plan. The value stream should be continuously improved; it will not be perfect the first time.
|
||||
|
||||
6. ****Measure benefits****
|
||||
|
||||
Karen Martin and Mike Osterling identify key performance metrics for software delivery in their book, [Value Stream Mapping][6]:
|
||||
|
||||
* Total lead time: the total time it takes to deliver on a customer request
|
||||
|
||||
* Total process time: the total work effort required by all functions on the timeline critical path of the value stream
|
||||
|
||||
* Activity ratio: the degree of flow in the value stream
|
||||
|
||||
* Compounded effect: the quality of output across the value stream
|
||||
|
||||
|
||||
Well-executed value stream mapping not only improves the way work gets delivered, but it also provides a transformational opportunity for your organization and a tool to facilitate a shift in mindsets and behaviors.
|
||||
|
||||
### What to read next
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/12/optimizing-delivery-value-stream-mapping
|
||||
|
||||
作者:[Dominika Bula][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/dominika
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://en.wikipedia.org/wiki/Value_stream_mapping
|
||||
[2]: https://en.wikipedia.org/wiki/Lean_software_development
|
||||
[3]: https://en.wikipedia.org/wiki/Systems_development_life_cycle
|
||||
[4]: https://www.oreilly.com/library/view/lean-software-development/0321150783/
|
||||
[5]: https://xkcd.com/1205/
|
||||
[6]: https://mhebooklibrary.com/doi/book/10.1036/9780071828949
|
File diff suppressed because it is too large
Load Diff
316
sources/tech/20171227 YAML- probably not so great after all.md
Normal file
316
sources/tech/20171227 YAML- probably not so great after all.md
Normal file
@ -0,0 +1,316 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (YAML: probably not so great after all)
|
||||
[#]: via: (https://arp242.net/weblog/yaml_probably_not_so_great_after_all.html)
|
||||
[#]: author: (Martin Tournoij https://arp242.net/)
|
||||
|
||||
YAML: probably not so great after all
|
||||
======
|
||||
|
||||
|
||||
I previously wrote [why using JSON for human-editable configuration files is a bad idea][1]. Today we’re going to look at some general problems with the YAML format.
|
||||
|
||||
### Insecure by default
|
||||
|
||||
YAML is insecure by default. Loading a user-provided (untrusted) YAML string needs careful consideration.
|
||||
|
||||
```
|
||||
!!python/object/apply:os.system
|
||||
args: ['ls /']
|
||||
```
|
||||
|
||||
Running it with `print(yaml.load(open('a.yaml')))` should give you something like:
|
||||
|
||||
```
|
||||
bin etc lib lost+found opt root sbin tmp var sys
|
||||
boot dev efi home lib64 mnt proc run srv usr
|
||||
0
|
||||
```
|
||||
|
||||
Many other languages (including Ruby and PHP) are also unsafe by default. [Searching for `yaml.load` on GitHub][2] gives a whopping 2.8 million results. [`yaml.safe_load`][3] only gives 26,000 results.
|
||||
|
||||
Mind you, many of those `yaml.load()`s are fine – loading in a config file with `yaml.load()` is often okay since it’s usually (though not always!) from a ‘trusted source’, and many are from test files with static YAML. But still, one can’t help but wonder how many exploits are hidden in those 2.8 million results.
|
||||
|
||||
This is not a theoretical problem. In 2013 [every Ruby on Rails application ever written was found to be vulnerable][4] to remote code execution due to exactly this problem.
|
||||
|
||||
One might argue this is not really the fault of the YAML format as such, but rather the fault of the libraries implementing it wrong, but it seems to be the case that the majority of libraries are unsafe by default (especially the dynamic languages), so de-facto it is a problem with YAML.
|
||||
|
||||
One might also argue that fixing it is as easy as replacing `load()` with `safe_load()`, but many people are unaware of the problem, and even if you’re aware of it, it’s one of those things that can be easy to forget. It’s pretty bad API design.
|
||||
|
||||
### Can be hard to edit, especially for large files
|
||||
|
||||
YAML files can be hard to edit, and this difficulty grows fast as the file gets larger.
|
||||
|
||||
A good example of this are Ruby on Rails’ translation files; for example:
|
||||
|
||||
```
|
||||
en:
|
||||
formtastic:
|
||||
labels:
|
||||
title: "Title" # Default global value
|
||||
article:
|
||||
body: "Article content"
|
||||
post:
|
||||
new:
|
||||
title: "Choose a title..."
|
||||
body: "Write something..."
|
||||
edit:
|
||||
title: "Edit title"
|
||||
body: "Edit body"
|
||||
```
|
||||
|
||||
This still looks okay, right? But what if this file has 100 lines? Or 1,000 lines? It is difficult to see “where” in the file you are because it may be off the screen. You’ll need to scroll up, but then you need to keep track of the indentation, which can be pretty hard even with indentation guides, especially since 2-space indentation is the norm and [tab indentation is forbidden][5].
|
||||
|
||||
And accidentally getting the indentation wrong often isn’t an error; it will often just deserialize to something you didn’t intend. Happy debugging!
|
||||
|
||||
I’ve been happily programming Python for over a decade, so I’m used to significant whitespace, but sometimes I’m still struggling with YAML. In Python the drawbacks and loss of clarity are contained by not having functions that are several pages long, but data or configuration files have no such natural limits to their length.
|
||||
|
||||
For small files this is not a problem; but it really doesn’t scale well to larger files, especially not if you want to edit them later on.
|
||||
|
||||
### It’s pretty complex
|
||||
|
||||
YAML may seem ‘simple’ and ‘obvious’ when glancing at a basic example, but turns out it’s not. The [YAML spec][6] is 23,449 words; for comparison, [TOML][7] is 3,339 words, [JSON][8] is 1,969 words, and [XML][9] is 20,603 words.
|
||||
|
||||
Who among us have read all that? Who among us have read and understood all of that? Who among of have read, understood, and **remembered** all of that?
|
||||
|
||||
For example did you know there are [nine ways to write a multi-line string in YAML][10] with subtly different behaviour?
|
||||
|
||||
Yeah :-/
|
||||
|
||||
That post gets even more interesting if you look at [its revision history][11], as the author of the post discovers more and more ways to do this and more of the subtleties involved.
|
||||
|
||||
It’s telling that the YAML spec starts with a preview, which states (emphases mine):
|
||||
|
||||
> This section provides a quick glimpse into the expressive power of YAML. **It is not expected that the first-time reader grok all of the examples**. Rather, these selections are used as motivation for the remainder of the specification.
|
||||
|
||||
#### Surprising behaviour
|
||||
|
||||
What does this parse to (examples courtesy of [Colm O’Connor][12]):
|
||||
|
||||
```
|
||||
- Don Corleone: Do you have faith in my judgment?
|
||||
- Clemenza: Yes
|
||||
- Don Corleone: Do I have your loyalty?
|
||||
```
|
||||
|
||||
Yup!
|
||||
|
||||
```
|
||||
[
|
||||
{'Don Corleone': 'Do you have faith in my judgment?'},
|
||||
{'Clemenza': True},
|
||||
{'Don Corleone': 'Do I have your loyalty?'}
|
||||
]
|
||||
```
|
||||
|
||||
Or what about:
|
||||
|
||||
```
|
||||
python: 3.5.3
|
||||
postgres: 9.3
|
||||
```
|
||||
|
||||
`3.5.3` gets recognized as as string, but `9.3` gets recognized as a number instead of a string:
|
||||
|
||||
```
|
||||
{'python': '3.5.3', 'postgres': 9.3}
|
||||
```
|
||||
|
||||
Or what about:
|
||||
|
||||
```
|
||||
Effenaar: Eindhoven
|
||||
013: Tilburg
|
||||
```
|
||||
|
||||
013 is a popular music Venue in Tilburg, but YAML will send you the wrong way since it’s parsed as an octal number:
|
||||
|
||||
```
|
||||
{11: 'Tilburg', 'Effenaar': 'Eindhoven'}
|
||||
```
|
||||
|
||||
All of this – and more – is why many experienced YAMLers will often quote all strings, even when it’s not strictly required. Many people don’t use quotes, and it can be easy to forget especially if the rest of the file – possibly written by other people – doesn’t use quotes.
|
||||
|
||||
#### It’s not portable
|
||||
|
||||
Because it’s so complex, its claims of portability have been greatly exaggerated. For example consider this example taken from the YAML spec:
|
||||
|
||||
```
|
||||
? - Detroit Tigers
|
||||
- Chicago cubs
|
||||
:
|
||||
- 2001-07-23
|
||||
|
||||
? [ New York Yankees,
|
||||
Atlanta Braves ]
|
||||
: [ 2001-07-02, 2001-08-12,
|
||||
2001-08-14 ]
|
||||
```
|
||||
|
||||
Aside from the fact that most readers of this probably won’t even know what this does, try parsing it in Python with PyYAML:
|
||||
|
||||
```
|
||||
yaml.constructor.ConstructorError: while constructing a mapping
|
||||
in "a.yaml", line 1, column 1
|
||||
found unhashable key
|
||||
in "a.yaml", line 1, column 3
|
||||
```
|
||||
|
||||
In Ruby it works:
|
||||
|
||||
```
|
||||
{
|
||||
["Detroit Tigers", "Chicago cubs"] => [
|
||||
#<Date: 2001-07-23 ((2452114j,0s,0n),+0s,2299161j)>
|
||||
],
|
||||
["New York Yankees", "Atlanta Braves"] => [
|
||||
#<Date: 2001-07-02 ((2452093j,0s,0n),+0s,2299161j)>,
|
||||
#<Date: 2001-08-12 ((2452134j,0s,0n),+0s,2299161j)>,
|
||||
#<Date: 2001-08-14 ((2452136j,0s,0n),+0s,2299161j)>
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
The reason for this is because you can’t use a list as a dict key in Python:
|
||||
|
||||
```
|
||||
>>> {['a']: 'zxc'}
|
||||
Traceback (most recent call last):
|
||||
File "<stdin>", line 1, in <module>
|
||||
TypeError: unhashable type: 'list'
|
||||
```
|
||||
|
||||
And this restriction is not unique to Python; common languages such as PHP, JavaScript, and Go all share this restriction.
|
||||
|
||||
So use this in a YAML file, and you won’t be able to read it in most languages.
|
||||
|
||||
Here’s another example again taken from the examples section of the YAML spec:
|
||||
|
||||
```
|
||||
# Ranking of 1998 home runs
|
||||
---
|
||||
- Mark McGwire
|
||||
- Sammy Sosa
|
||||
- Ken Griffey
|
||||
|
||||
# Team ranking
|
||||
---
|
||||
- Chicago Cubs
|
||||
- St Louis Cardinals
|
||||
```
|
||||
|
||||
Python says:
|
||||
|
||||
```
|
||||
yaml.composer.ComposerError: expected a single document in the stream
|
||||
in "a.yaml", line 3, column 1
|
||||
but found another document
|
||||
in "a.yaml", line 8, column 1
|
||||
```
|
||||
|
||||
While Ruby outputs:
|
||||
|
||||
```
|
||||
["Mark McGwire", "Sammy Sosa", "Ken Griffey"]
|
||||
```
|
||||
|
||||
The reason for this is that there are multiple YAML documents in a single file (`---` start the document). In Python there is the `load_all()` function to parse all documents. Ruby’s `load()` just loads the first document, and as near as I can tell, doesn’t have a way to load multiple documents.
|
||||
|
||||
There are [many more incompatibilities between implementations][13].
|
||||
|
||||
### Goals achieved?
|
||||
|
||||
The spec states:
|
||||
|
||||
> The design goals for YAML are, in decreasing priority:
|
||||
>
|
||||
> 1. YAML is easily readable by humans.
|
||||
> 2. YAML data is portable between programming languages.
|
||||
> 3. YAML matches the native data structures of agile languages.
|
||||
> 4. YAML has a consistent model to support generic tools.
|
||||
> 5. YAML supports one-pass processing.
|
||||
> 6. YAML is expressive and extensible.
|
||||
> 7. YAML is easy to implement and use.
|
||||
>
|
||||
|
||||
|
||||
So how well does it do?
|
||||
|
||||
> YAML is easily readable by humans.
|
||||
|
||||
True only if you stick to a small subset. The full set is complex – much more so than XML or JSON.
|
||||
|
||||
> YAML data is portable between programming languages.
|
||||
|
||||
Not really true, as it’s too easy to create constructs that are not supported by common languages.
|
||||
|
||||
> YAML matches the native data structures of agile languages.
|
||||
|
||||
See above. Plus, why only support agile (or dynamic) languages? What about other languages?
|
||||
|
||||
> YAML has a consistent model to support generic tools.
|
||||
|
||||
I am not even sure what this means and I can’t find any elaboration.
|
||||
|
||||
> YAML supports one-pass processing.
|
||||
|
||||
I’ll take their word for it.
|
||||
|
||||
> YAML is expressive and extensible.
|
||||
|
||||
Well, it is, but it’s too expressive (e.g. too complex).
|
||||
|
||||
> YAML is easy to implement and use.
|
||||
|
||||
```
|
||||
$ cat `ls -1 ~/gocode/src/github.com/go-yaml/yaml/*.go | grep -v _test` | wc -l
|
||||
9247
|
||||
|
||||
$ cat /usr/lib/python3.5/site-packages/yaml/*.py | wc -l
|
||||
5713
|
||||
```
|
||||
|
||||
### Conclusion
|
||||
|
||||
Don’t get me wrong, it’s not like YAML is absolutely terrible – it’s certainly not as [problematic as using JSON][1] – but it’s not exactly great either. There are some drawbacks and surprises that are not at all obvious at first, and there are a number of better alternatives such as [TOML][7] and other more specialized formats.
|
||||
|
||||
Personally, I’m not likely to use it again when I’ve got a choice.
|
||||
|
||||
If you must use YAML then I recommend you use [StrictYAML][14], which removes some (though not all) of the more hairy parts.
|
||||
|
||||
### Feedback
|
||||
|
||||
You can mail me at [martin@arp242.net][15] or [create a GitHub issue][16] for feedback, questions, etc.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://arp242.net/weblog/yaml_probably_not_so_great_after_all.html
|
||||
|
||||
作者:[Martin Tournoij][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://arp242.net/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: http://arp242.net/weblog/JSON_as_configuration_files-_please_dont.html
|
||||
[2]: https://github.com/search?q=yaml.load&type=Code&utf8=%E2%9C%93
|
||||
[3]: https://github.com/search?q=yaml.safe_load&type=Code&utf8=%E2%9C%93
|
||||
[4]: https://www.sitepoint.com/anatomy-of-an-exploit-an-in-depth-look-at-the-rails-yaml-vulnerability/
|
||||
[5]: http://www.yaml.org/faq.html
|
||||
[6]: http://yaml.org/spec/1.2/spec.pdf
|
||||
[7]: https://github.com/toml-lang/toml
|
||||
[8]: http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf
|
||||
[9]: https://www.w3.org/TR/REC-xml/
|
||||
[10]: http://stackoverflow.com/a/21699210/660921
|
||||
[11]: http://stackoverflow.com/posts/21699210/revisions
|
||||
[12]: https://github.com/crdoconnor/strictyaml/blob/master/FAQ.rst#what-is-wrong-with-implicit-typing
|
||||
[13]: https://github.com/cblp/yaml-sucks
|
||||
[14]: https://github.com/crdoconnor/strictyaml
|
||||
[15]: mailto:martin@arp242.net
|
||||
[16]: https://github.com/Carpetsmoker/arp242.net/issues/new
|
@ -1,128 +0,0 @@
|
||||
Translating by Guevaraya
|
||||
|
||||
'Getting to Done' on the Linux command line
|
||||
======
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_terminals.png?itok=CfBqYBah)
|
||||
There is a lot of talk about getting things done at the command line. How many articles are there about using obscure flags with `ls`, nifty regular expressions with Sed and Awk, and how to parse out lots of text with Perl? That isn't what this is about.
|
||||
|
||||
This is about [Getting _to_ Done][1], making sure that the stuff we have to do actually gets tracked and done using tools that don't require a graphical desktop, a web browser, or an internet connection. To do this, we'll look at four ways of tracking your to-do list: plaintext files, Todo.txt, TaskWarrior, and Org-mode.
|
||||
|
||||
### Plain (and simple) text
|
||||
|
||||
|
||||
![plaintext][3]
|
||||
|
||||
I like to use Vim, but you can use Nano too.
|
||||
|
||||
The most straightforward way to manage your to-do list is using a plaintext file in your editor of choice. Just open an empty file and add tasks, one per line. When you are done, delete the line. Simple, effective, and it doesn't matter what you use to do it. There are a couple of drawbacks to this method, though. Once you delete a line and save the file, it is gone forever. That can be a problem if you have to report on what you have done this week or last week. And while using a simple file is flexible, it can also get cluttered really easily.
|
||||
|
||||
### Todo.txt: Plaintext leveled up
|
||||
|
||||
|
||||
![todo.txt screen][5]
|
||||
|
||||
Neat, organized, and easy to use
|
||||
|
||||
That leads us to the [Todo.txt][6] file format and application. Installation is simple—[download][7] the latest release from GitHub and run `sudo make install` from the unpacked archive.
|
||||
|
||||
|
||||
![Installing todo.txt][9]
|
||||
|
||||
It works from a Git clone as well.
|
||||
|
||||
Todo.txt makes it very easy to add tasks, list tasks, and mark them as done:
|
||||
|
||||
| `todo.sh add "Some Task"` | add "Some Task" to my todo list |
|
||||
| `todo.sh ls` | list all my tasks |
|
||||
| `todo.sh ls due:2018-02-15` | list all tasks due on February 15, 2018 |
|
||||
| `todo.sh do 3` | mark task number 3 as "done" |
|
||||
|
||||
The actual list is still in plaintext, and you can edit it with your favorite text editor as long as you follow the [correct format][10].
|
||||
|
||||
There is also a very robust help built into the application.
|
||||
|
||||
|
||||
![Syntax highlighting in todo.txt][12]
|
||||
|
||||
You can even get syntax highlighting.
|
||||
|
||||
There is also a large selection of add-ons, as well as specifications for writing your own. There are even browser extensions, mobile apps, and desktop apps that support the Todo.txt format.
|
||||
|
||||
|
||||
![GNOME extensions in todo.txt][14]
|
||||
|
||||
Even GNOME extensions.
|
||||
|
||||
The biggest drawback to Todo.txt is the lack of an automatic or built-in synchronization mechanism. Most (if not all) of the browser extensions and mobile apps require Dropbox to perform synchronization between the app and the copy on your desktop. If you would like something with sync built-in, we have...
|
||||
|
||||
### Taskwarrior: Now we're cooking with Python
|
||||
|
||||
[Taskwarrior][15] is a Python application with many of the same features as Todo.txt. However, it stores the data in a database and has built-in synchronization capabilities. It also keeps track of what is next, notes how old tasks are, and will warn you if you have something more important to do than what you just did.
|
||||
|
||||
[Installation][16] of Taskwarrior can be done either with your distribution's package manager, through Python's `pip` utility, or built from source. Using it is also pretty straightforward, with commands similar to Todo.txt:
|
||||
|
||||
| `task add "Some Task"` | Add "Some Task" to the list |
|
||||
| `task list` | List all tasks |
|
||||
| `task list due ``:today` | List all tasks due on today's date |
|
||||
| `task do 3` | Complete task number 3 |
|
||||
|
||||
Taskwarrior also has some pretty nice text user interfaces.
|
||||
|
||||
![Taskwarrior in Vit][18]
|
||||
|
||||
I like Vit, which was inspired by Vim.
|
||||
|
||||
Unlike Todo.txt, Taskwarrior can synchronize with a local or remote server. A very basic synchronization server called `taskd` is available if you wish to run your own, and there are several services available if you do not.
|
||||
|
||||
Taskwarrior also has a thriving and extensive ecosystem of add-ons and extensions, as well as mobile and desktop apps.
|
||||
|
||||
![Taskwarrior on GNOME][20]
|
||||
|
||||
Taskwarrior looks really nice on GNOME.
|
||||
|
||||
The only disadvantage to Taskwarrior is that, unlike the other programs listed here, you cannot directly modify the to-do list itself. You can export the task list to various formats, modify the export, and then re-import the files, but it is a lot clunkier than just opening the file directly in a text editor.
|
||||
|
||||
Which brings us to the most powerful of them all...
|
||||
|
||||
### Emacs Org-mode: Hulk smash tasks
|
||||
|
||||
![Org-mode][22]
|
||||
|
||||
Emacs has everything.
|
||||
|
||||
Emacs [Org-mode][23] is by far the most powerful, most flexible open source to-do list manager out there. It supports multiple files, uses plaintext, is almost infinitely customizable, and understands calendars, due dates, and schedules. It is also significantly more complicated to set up than the other applications listed here. But once it is set up, it does everything the other applications do and more. If you are familiar with or a fan of [Bullet Journals][24], Org-mode is possibly the closest you can get on a computer.
|
||||
|
||||
Org-mode will run anywhere Emacs runs, and there are a few mobile applications that can interact with it as well. Unfortunately, there are no desktop apps or browser extensions that support Org. Despite all that, Org-mode is still one of the best applications for tracking your to-do list, since it is so very powerful.
|
||||
|
||||
### Choose your tool
|
||||
|
||||
In the end, the goal of all these programs is to help you track what you need to do and make sure you don't forget to do something. While they all have the same basic functions, choosing which one is right for you depends on a lot of factors. Do you want synchronization built-in or not? Do you need a mobile app? Do any of the add-ons include a "must have" feature? Whatever your choice, remember that the program alone cannot make you more organized, but it can help.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/2/getting-to-done-agile-linux-command-line
|
||||
|
||||
作者:[Kevin Sonney][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:
|
||||
[1]:https://www.scruminc.com/getting-done/
|
||||
[3]:https://opensource.com/sites/default/files/u128651/plain-text.png (plaintext)
|
||||
[5]:https://opensource.com/sites/default/files/u128651/todo-txt.png (todo.txt screen)
|
||||
[6]:http://todotxt.org/
|
||||
[7]:https://github.com/todotxt/todo.txt-cli/releases
|
||||
[9]:https://opensource.com/sites/default/files/u128651/todo-txt-install.png (Installing todo.txt)
|
||||
[10]:https://github.com/todotxt/todo.txt
|
||||
[12]:https://opensource.com/sites/default/files/u128651/todo-txt-vim.png (Syntax highlighting in todo.txt)
|
||||
[14]:https://opensource.com/sites/default/files/u128651/tod-txt-gnome.png (GNOME extensions in todo.txt)
|
||||
[15]:https://taskwarrior.org/
|
||||
[16]:https://taskwarrior.org/download/
|
||||
[18]:https://opensource.com/sites/default/files/u128651/taskwarrior-vit.png (Taskwarrior in Vit)
|
||||
[20]:https://opensource.com/sites/default/files/u128651/taskwarrior-gnome.png (Taskwarrior on GNOME)
|
||||
[22]:https://opensource.com/sites/default/files/u128651/emacs-org-mode.png (Org-mode)
|
||||
[23]:https://orgmode.org/
|
||||
[24]:http://bulletjournal.com/
|
@ -1,236 +0,0 @@
|
||||
Manage your workstation with Ansible: Automating configuration Translating By FelixYFZ
|
||||
======
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/robot_arm_artificial_ai.png?itok=8CUU3U_7)
|
||||
Ansible is an amazing automation and configuration management tool. It is mainly used for servers and cloud deployments, and it gets far less attention for its use in workstations, both desktops and laptops, which is the focus of this series.
|
||||
|
||||
In the [first part][1] of this series, I showed you basic usage of the `ansible-pull` command, and we created a playbook that installs a handful of packages. That wasn't extremely useful by itself, but it set the stage for further automation.
|
||||
|
||||
In this article, everything comes together full circle, and by the end we will have a fully working solution for automating workstation configuration. This time, we'll set up our Ansible configuration such that future changes we make will automatically be applied to our workstations. At this point, I'm assuming you already worked through part one. If you haven't, feel free to do that now and then return to this article when you're done. You should already have a GitHub repository with the code from the first article inside it. We're going to build directly on what we did before.
|
||||
|
||||
First, we need to do some reorganization because we're going to do more than just install packages. At this point, we currently have a playbook named `local.yml` with the following content:
|
||||
```
|
||||
- hosts: localhost
|
||||
|
||||
become: true
|
||||
|
||||
tasks:
|
||||
|
||||
- name: Install packages
|
||||
|
||||
apt: name={{item}}
|
||||
|
||||
with_items:
|
||||
|
||||
- htop
|
||||
|
||||
- mc
|
||||
|
||||
- tmux
|
||||
|
||||
```
|
||||
|
||||
That's all well and good if we only want to perform one task. As we add new things to our configuration, this file will become quite large and get very cluttered. It's better to organize our plays into individual files with each responsible for a different type of configuration. To achieve this, create what's called a taskbook, which is very much like a playbook but the contents are more streamlined. Let's create a directory for our taskbooks inside our Git repository:
|
||||
```
|
||||
mkdir tasks
|
||||
|
||||
```
|
||||
|
||||
The code inside our current `local.yml` playbook lends itself well to become a taskbook for installing packages. Let's move this file into the `tasks` directory we just created with a new name:
|
||||
```
|
||||
mv local.yml tasks/packages.yml
|
||||
|
||||
```
|
||||
|
||||
Now, we can edit our `packages.yml` taskbook and strip it down quite a bit. In fact, we can strip everything except for the individual task itself. Let's make `packages.yml` look like this:
|
||||
```
|
||||
- name: Install packages
|
||||
|
||||
apt: name={{item}}
|
||||
|
||||
with_items:
|
||||
|
||||
- htop
|
||||
|
||||
- mc
|
||||
|
||||
- tmux
|
||||
|
||||
```
|
||||
|
||||
As you can see, it uses the same syntax, but we stripped out everything that isn't necessary to the task it's performing. Now we have a dedicated taskbook for installing packages. However, we still need a file named `local.yml`, since `ansible-pull` still expects to find a file with that name. So we'll create a fresh one with this content in the root of our repository (not in the `tasks` directory):
|
||||
```
|
||||
- hosts: localhost
|
||||
|
||||
become: true
|
||||
|
||||
pre_tasks:
|
||||
|
||||
- name: update repositories
|
||||
|
||||
apt: update_cache=yes
|
||||
|
||||
changed_when: False
|
||||
|
||||
|
||||
|
||||
tasks:
|
||||
|
||||
- include: tasks/packages.yml
|
||||
|
||||
```
|
||||
|
||||
This new `local.yml` acts as an index that will import all our taskbooks. I've added a few new things to this file that you haven't seen yet in this series. First, at the beginning of the file, I added `pre_tasks`, which allows us to have Ansible perform a task before all the other tasks run. In this case, we're telling Ansible to update our distribution's repository index. This line does that for us:
|
||||
```
|
||||
apt: update_cache=yes
|
||||
|
||||
```
|
||||
|
||||
Normally the `apt` module allows us to install packages, but we can also tell it to update our repository index. The idea is that we want all our individual plays to work with a fresh index each time Ansible runs. This will help ensure we don't have an issue with a stale index while attempting to install a package. Note that the `apt` module works only with Debian, Ubuntu, and their derivatives. If you're running a different distribution, you'll want to use a module specific to your distribution rather than `apt`. See the documentation for Ansible if you need to use a different module.
|
||||
|
||||
The following line is also worth further explanation:
|
||||
```
|
||||
changed_when: False
|
||||
|
||||
```
|
||||
|
||||
This line on an individual task stops Ansible from reporting the results of the play as changed even when it results in a change in the system. In this case, we don't care if the repository index contains new data; it almost always will, since repositories are always changing. We don't care about changes to `apt` repositories, as index changes are par for the course. If we omit this line, we'll see the summary at the end of the process report that something has changed, even if it was merely about the repository being updated. It's better to ignore these types of changes.
|
||||
|
||||
Next is our normal tasks section, and we import the taskbook we created. Each time we add another taskbook, we add another line here:
|
||||
```
|
||||
tasks:
|
||||
|
||||
- include: tasks/packages.yml
|
||||
|
||||
```
|
||||
|
||||
If you were to run the `ansible-pull` command here, it should essentially do the same thing as it did in the last article. The difference is that we have improved our organization and we can more efficiently expand on it. The `ansible-pull` command syntax, to save you from finding the previous article, is this:
|
||||
```
|
||||
sudo ansible-pull -U https://github.com/<github_user>/ansible.git
|
||||
|
||||
```
|
||||
|
||||
If you recall, the `ansible-pull` command pulls down a Git repository and applies the configuration it contains.
|
||||
|
||||
Now that our foundation is in place, we can expand upon our Ansible config and add features. Specifically, we'll add configuration to automate the deployment of future changes to our workstations. To support this goal, the first thing we should do is to create a user specifically to apply our Ansible configuration. This isn't required—we can continue to run our Ansible configuration under our own user. But using a separate user segregates this to a system process that will run in the background, without our involvement.
|
||||
|
||||
We could create this user with the normal method, but since we're using Ansible, we should shy away from manual changes. Instead, we'll create a taskbook to handle user creation. This taskbook will create just one user for now, but you can always add additional plays to this taskbook to add additional users. I'll call this user `ansible`, but you can name it something else if you wish (if you do, make sure to update all occurrences). Let's create a taskbook named `users.yml` and place this code inside of it:
|
||||
```
|
||||
- name: create ansible user
|
||||
|
||||
user: name=ansible uid=900
|
||||
|
||||
```
|
||||
|
||||
Next, we need to edit our `local.yml` file and append this new taskbook to the file, so it will look like this:
|
||||
```
|
||||
- hosts: localhost
|
||||
|
||||
become: true
|
||||
|
||||
pre_tasks:
|
||||
|
||||
- name: update repositories
|
||||
|
||||
apt: update_cache=yes
|
||||
|
||||
changed_when: False
|
||||
|
||||
|
||||
|
||||
tasks:
|
||||
|
||||
- include: tasks/users.yml
|
||||
|
||||
- include: tasks/packages.yml
|
||||
|
||||
```
|
||||
|
||||
Now when we run our `ansible-pull` command, a user named `ansible` will be created on the system. Note that I specifically declared `User ID 900` for this user by using the `UID` option. This isn't required, but it's recommended. The reason is that UIDs under 1,000 are typically not shown on the login screen, which is great because there's no reason we would need to log into a desktop session as our `ansible` user. UID 900 is arbitrary; it should be any number under 1,000 that's not already in use. You can find out if UID 900 is in use on your system with the following command:
|
||||
```
|
||||
cat /etc/passwd |grep 900
|
||||
|
||||
```
|
||||
|
||||
However, you shouldn't run into a problem with this UID because I've never seen it used by default in any distribution I've used so far.
|
||||
|
||||
Now, we have an `ansible` user that will later be used to apply our Ansible configuration automatically. Next, we can create the actual cron job that will be used to automate this. Rather than place this in the `users.yml` taskbook we just created, we should separate this into its own file. Create a taskbook named `cron.yml` in the tasks directory and place the following code inside:
|
||||
```
|
||||
- name: install cron job (ansible-pull)
|
||||
|
||||
cron: user="ansible" name="ansible provision" minute="*/10" job="/usr/bin/ansible-pull -o -U https://github.com/<github_user>/ansible.git > /dev/null"
|
||||
|
||||
```
|
||||
|
||||
The syntax for the cron module should be fairly self-explanatory. With this play, we're creating a cron job to be run as the `ansible` user. The job will execute every 10 minutes, and the command it will execute is this:
|
||||
```
|
||||
/usr/bin/ansible-pull -o -U https://github.com/<github_user>/ansible.git > /dev/null
|
||||
|
||||
```
|
||||
|
||||
Also, we can put additional cron jobs we want all our workstations to have into this one file. We just need to add additional plays to add new cron jobs. However, simply adding a new taskbook for cron isn't enough—we'll also need to add it to our `local.yml` file so it will be called. Place the following line with the other includes:
|
||||
```
|
||||
- include: tasks/cron.yml
|
||||
|
||||
```
|
||||
|
||||
Now when `ansible-pull` is run, it will set up a new cron job that will be run as the `ansible` user every 10 minutes. But, having an Ansible job running every 10 minutes isn't ideal because it will take considerable CPU power. It really doesn't make sense for Ansible to run every 10 minutes unless we've changed something in the Git repository.
|
||||
|
||||
However, we've already solved this problem. Notice the `-o` option I added to the `ansible-pull` command in the cron job that we've never used before. This option tells Ansible to run only if the repository has changed since the last time `ansible-pull` was called. If the repository hasn't changed, it won't do anything. This way, you're not wasting valuable CPU for no reason. Sure, some CPU will be used when it pulls down the repository, but not nearly as much as it would use if it were applying your entire configuration all over again. When `ansible-pull` does run, it will go through all the tasks in the Playbook and taskbooks, but at least it won't run for no purpose.
|
||||
|
||||
Although we've added all the required components to automate `ansible-pull`, it actually won't work properly yet. The `ansible-pull` command will run with `sudo`, which would give it access to perform system-level commands. However, our `ansible` user is not set up to perform tasks as `sudo`. Therefore, when the cron job triggers, it will fail. Normally we could just use `visudo` and manually set the `ansible` user up to have this access. However, we should do things the Ansible way from now on, and this is a great opportunity to show you how the `copy` module works. The `copy` module allows you to copy a file from your Ansible repository to somewhere else in the filesystem. In our case, we'll copy a config file for `sudo` to `/etc/sudoers.d/` so that the `ansible` user can perform administrative tasks.
|
||||
|
||||
Open up the `users.yml` taskbook, and add the following play to the bottom:
|
||||
```
|
||||
- name: copy sudoers_ansible
|
||||
|
||||
copy: src=files/sudoers_ansible dest=/etc/sudoers.d/ansible owner=root group=root mode=0440
|
||||
|
||||
```
|
||||
|
||||
The `copy` module, as we can see, copies a file from our repository to somewhere else. In this case, we're grabbing a file named `sudoers_ansible` (which we will create shortly) and copying it to `/etc/sudoers.d/ansible` with `root` as the owner.
|
||||
|
||||
Next, we need to create the file that we'll be copying. In the root of your Ansible repository, create a `files` directory:
|
||||
```
|
||||
mkdir files
|
||||
|
||||
```
|
||||
|
||||
Then, in the `files` directory we just created, create the `sudoers_ansible` file with the following content:
|
||||
```
|
||||
ansible ALL=(ALL) NOPASSWD: ALL
|
||||
|
||||
```
|
||||
|
||||
Creating a file in `/etc/sudoers.d`, like we're doing here, allows us to configure `sudo` for a specific user. Here we're allowing the `ansible` user full access to the system via `sudo` without a password prompt. This will allow `ansible-pull` to run as a background task without us needing to run it manually.
|
||||
|
||||
Now, you can run `ansible-pull` again to pull down the latest changes:
|
||||
```
|
||||
sudo ansible-pull -U https://github.com/<github_user>/ansible.git
|
||||
|
||||
```
|
||||
|
||||
From this point forward, the cron job for `ansible-pull` will run every 10 minutes in the background and check your repository for changes. If it finds changes, it will run your playbook and apply your taskbooks.
|
||||
|
||||
So now we have a fully working solution. When you first set up a new laptop or desktop, you'll run the `ansible-pull` command manually, but only the first time. From that point forward, the `ansible` user will take care of subsequent runs in the background. When you want to make a change to your workstation machines, you simply pull down your Git repository, make the changes, then push those changes back to the repository. Then, the next time the cron job fires on each machine, it will pull down those changes and apply them. You now only have to make changes once, and all your workstations will follow suit. This method may be a bit unconventional though. Normally, you'd have an `inventory` file with your machines listed and several roles each machine could be a member of. However, the `ansible-pull` method, as described in this article, is a very efficient way of managing workstation configuration.
|
||||
|
||||
I have updated the code in my [GitHub repository][2] for this article, so feel free to browse the code there and check your syntax against mine. Also, I moved the code from the previous article into its own directory in that repository.
|
||||
|
||||
In part 3, we'll close out the series by using Ansible to configure GNOME desktop settings. I'll show you how to set your wallpaper and lock screen, apply a desktop theme, and more.
|
||||
|
||||
In the meantime, it's time for a little homework assignment. Most of us have configuration files we like to maintain for various applications we use. This could be configuration files for Bash, Vim, or whatever tools you use. I challenge you now to automate copying these configuration files to your machines via the Ansible repository we've been working on. In this article, I've shown you how to copy a file, so take a look at that and see if you can apply that knowledge to your personal files.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/3/manage-your-workstation-configuration-ansible-part-2
|
||||
|
||||
作者:[Jay LaCroix][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/jlacroix
|
||||
[1]:https://opensource.com/article/18/3/manage-workstation-ansible
|
||||
[2]:https://github.com/jlacroix82/ansible_article.git
|
@ -1,3 +1,5 @@
|
||||
ScarboroughCoral translating!
|
||||
|
||||
Migrating to Linux: Network and System Settings
|
||||
======
|
||||
|
||||
|
291
sources/tech/20181003 Manage NTP with Chrony.md
Normal file
291
sources/tech/20181003 Manage NTP with Chrony.md
Normal file
@ -0,0 +1,291 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Manage NTP with Chrony)
|
||||
[#]: via: (https://opensource.com/article/18/12/manage-ntp-chrony)
|
||||
[#]: author: (David Both https://opensource.com/users/dboth)
|
||||
|
||||
Manage NTP with Chrony
|
||||
======
|
||||
Chronyd is a better choice for most networks than ntpd for keeping computers synchronized with the Network Time Protocol.
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/clocks_time.png?itok=_ID09GDk)
|
||||
|
||||
> "Does anybody really know what time it is? Does anybody really care?"
|
||||
> – [Chicago][1], 1969
|
||||
|
||||
Perhaps that rock group didn't care what time it was, but our computers do need to know the exact time. Timekeeping is very important to computer networks. In banking, stock markets, and other financial businesses, transactions must be maintained in the proper order, and exact time sequences are critical for that. For sysadmins and DevOps professionals, it's easier to follow the trail of email through a series of servers or to determine the exact sequence of events using log files on geographically dispersed hosts when exact times are kept on the computers in question.
|
||||
|
||||
I used to work at an organization that received over 20 million emails per day and had four servers just to accept and do a basic filter on the incoming flood of email. From there, emails were sent to one of four other servers to perform more complex anti-spam assessments, then they were delivered to one of several additional servers where the emails were placed in the correct inboxes. At each layer, the emails would be sent to one of the next-level servers, selected only by the randomness of round-robin DNS. Sometimes we had to trace a new message through the system until we could determine where it "got lost," according to the pointy-haired bosses. We had to do this with frightening regularity.
|
||||
|
||||
Most of that email turned out to be spam. Some people actually complained that their [joke, cat pic, recipe, inspirational saying, or other-strange-email]-of-the-day was missing and asked us to find it. We did reject those opportunities.
|
||||
|
||||
Our email and other transactional searches were aided by log entries with timestamps that—today—can resolve down to the nanosecond in even the slowest of modern Linux computers. In very high-volume transaction environments, even a few microseconds of difference in the system clocks can mean sorting thousands of transactions to find the correct one(s).
|
||||
|
||||
### The NTP server hierarchy
|
||||
|
||||
Computers worldwide use the [Network Time Protocol][2] (NTP) to synchronize their times with internet standard reference clocks via a hierarchy of NTP servers. The primary servers are at stratum 1, and they are connected directly to various national time services at stratum 0 via satellite, radio, or even modems over phone lines. The time service at stratum 0 may be an atomic clock, a radio receiver tuned to the signals broadcast by an atomic clock, or a GPS receiver using the highly accurate clock signals broadcast by GPS satellites.
|
||||
|
||||
To prevent time requests from time servers lower in the hierarchy (i.e., with a higher stratum number) from overwhelming the primary reference servers, there are several thousand public NTP stratum 2 servers that are open and available for anyone to use. Many organizations with large numbers of hosts that need an NTP server will set up their own time servers so that only one local host accesses the stratum 2 time servers, then they configure the remaining network hosts to use the local time server which, in my case, is a stratum 3 server.
|
||||
|
||||
### NTP choices
|
||||
|
||||
The original NTP daemon, **ntpd** , has been joined by a newer one, **chronyd**. Both keep the local host's time synchronized with the time server. Both services are available, and I have seen nothing to indicate that this will change anytime soon.
|
||||
|
||||
Chrony has features that make it the better choice for most environments for the following reasons:
|
||||
|
||||
* Chrony can synchronize to the time server much faster than NTP. This is good for laptops or desktops that don't run constantly.
|
||||
|
||||
* It can compensate for fluctuating clock frequencies, such as when a host hibernates or enters sleep mode, or when the clock speed varies due to frequency stepping that slows clock speeds when loads are low.
|
||||
|
||||
* It handles intermittent network connections and bandwidth saturation.
|
||||
|
||||
* It adjusts for network delays and latency.
|
||||
|
||||
* After the initial time sync, Chrony never steps the clock. This ensures stable and consistent time intervals for system services and applications.
|
||||
|
||||
* Chrony can work even without a network connection. In this case, the local host or server can be updated manually.
|
||||
|
||||
|
||||
|
||||
|
||||
The NTP and Chrony RPM packages are available from standard Fedora repositories. You can install both and switch between them, but modern Fedora, CentOS, and RHEL releases have moved from NTP to Chrony as their default time-keeping implementation. I have found that Chrony works well, provides a better interface for the sysadmin, presents much more information, and increases control.
|
||||
|
||||
Just to make it clear, NTP is a protocol that is implemented with either NTP or Chrony. If you'd like to know more, read this [comparison between NTP and Chrony][3] as implementations of the NTP protocol.
|
||||
|
||||
This article explains how to configure Chrony clients and servers on a Fedora host, but the configuration for CentOS and RHEL current releases works the same.
|
||||
|
||||
### Chrony structure
|
||||
|
||||
The Chrony daemon, **chronyd** , runs in the background and monitors the time and status of the time server specified in the **chrony.conf** file. If the local time needs to be adjusted, **chronyd** does it smoothly without the programmatic trauma that would occur if the clock were instantly reset to a new time.
|
||||
|
||||
Chrony's **chronyc** tool allows someone to monitor the current status of Chrony and make changes if necessary. The **chronyc** utility can be used as a command that accepts subcommands, or it can be used as an interactive text-mode program. This article will explain both uses.
|
||||
|
||||
### Client configuration
|
||||
|
||||
The NTP client configuration is simple and requires little or no intervention. The NTP server can be defined during the Linux installation or provided by the DHCP server at boot time. The default **/etc/chrony.conf** file (shown below in its entirety) requires no intervention to work properly as a client. For Fedora, Chrony uses the Fedora NTP pool, and CentOS and RHEL have their own NTP server pools. Like many Red Hat-based distributions, the configuration file is well commented.
|
||||
|
||||
```
|
||||
# Use public servers from the pool.ntp.org project.
|
||||
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
|
||||
pool 2.fedora.pool.ntp.org iburst
|
||||
|
||||
# Record the rate at which the system clock gains/losses time.
|
||||
driftfile /var/lib/chrony/drift
|
||||
|
||||
# Allow the system clock to be stepped in the first three updates
|
||||
# if its offset is larger than 1 second.
|
||||
makestep 1.0 3
|
||||
|
||||
# Enable kernel synchronization of the real-time clock (RTC).
|
||||
|
||||
|
||||
# Enable hardware timestamping on all interfaces that support it.
|
||||
#hwtimestamp *
|
||||
|
||||
# Increase the minimum number of selectable sources required to adjust
|
||||
# the system clock.
|
||||
#minsources 2
|
||||
|
||||
# Allow NTP client access from local network.
|
||||
#allow 192.168.0.0/16
|
||||
|
||||
# Serve time even if not synchronized to a time source.
|
||||
#local stratum 10
|
||||
|
||||
# Specify file containing keys for NTP authentication.
|
||||
keyfile /etc/chrony.keys
|
||||
|
||||
# Get TAI-UTC offset and leap seconds from the system tz database.
|
||||
leapsectz right/UTC
|
||||
|
||||
# Specify directory for log files.
|
||||
logdir /var/log/chrony
|
||||
|
||||
# Select which information is logged.
|
||||
#log measurements statistics tracking
|
||||
```
|
||||
|
||||
Let's look at the current status of NTP on a virtual machine I use for testing. The **chronyc** command, when used with the **tracking** subcommand, provides statistics that report how far off the local system is from the reference server.
|
||||
|
||||
```
|
||||
[root@studentvm1 ~]# chronyc tracking
|
||||
Reference ID : 23ABED4D (ec2-35-171-237-77.compute-1.amazonaws.com)
|
||||
Stratum : 3
|
||||
Ref time (UTC) : Fri Nov 16 16:21:30 2018
|
||||
System time : 0.000645622 seconds slow of NTP time
|
||||
Last offset : -0.000308577 seconds
|
||||
RMS offset : 0.000786140 seconds
|
||||
Frequency : 0.147 ppm slow
|
||||
Residual freq : -0.073 ppm
|
||||
Skew : 0.062 ppm
|
||||
Root delay : 0.041452706 seconds
|
||||
Root dispersion : 0.022665167 seconds
|
||||
Update interval : 1044.2 seconds
|
||||
Leap status : Normal
|
||||
[root@studentvm1 ~]#
|
||||
```
|
||||
|
||||
The Reference ID in the first line of the result is the server the host is synchronized to—in this case, a stratum 3 reference server that was last contacted by the host at 16:21:30 2018. The other lines are described in the [chronyc(1) man page][4].
|
||||
|
||||
The **sources** subcommand is also useful because it provides information about the time source configured in **chrony.conf**.
|
||||
|
||||
```
|
||||
[root@studentvm1 ~]# chronyc sources
|
||||
210 Number of sources = 5
|
||||
MS Name/IP address Stratum Poll Reach LastRx Last sample
|
||||
===============================================================================
|
||||
^+ 192.168.0.51 3 6 377 0 -2613us[-2613us] +/- 63ms
|
||||
^+ dev.smatwebdesign.com 3 10 377 28m -2961us[-3534us] +/- 113ms
|
||||
^+ propjet.latt.net 2 10 377 465 -1097us[-1085us] +/- 77ms
|
||||
^* ec2-35-171-237-77.comput> 2 10 377 83 +2388us[+2395us] +/- 95ms
|
||||
^+ PBX.cytranet.net 3 10 377 507 -1602us[-1589us] +/- 96ms
|
||||
[root@studentvm1 ~]#
|
||||
```
|
||||
|
||||
The first source in the list is the time server I set up for my personal network. The others were provided by the pool. Even though my NTP server doesn't appear in the Chrony configuration file above, my DHCP server provides its IP address for the NTP server. The "S" column—Source State—indicates with an asterisk ( ***** ) the server our host is synced to. This is consistent with the data from the **tracking** subcommand.
|
||||
|
||||
The **-v** option provides a nice description of the fields in this output.
|
||||
|
||||
```
|
||||
[root@studentvm1 ~]# chronyc sources -v
|
||||
210 Number of sources = 5
|
||||
|
||||
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
|
||||
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
|
||||
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|
||||
|| .- xxxx [ yyyy ] +/- zzzz
|
||||
|| Reachability register (octal) -. | xxxx = adjusted offset,
|
||||
|| Log2(Polling interval) --. | | yyyy = measured offset,
|
||||
|| \ | | zzzz = estimated error.
|
||||
|| | | \
|
||||
MS Name/IP address Stratum Poll Reach LastRx Last sample
|
||||
===============================================================================
|
||||
^+ 192.168.0.51 3 7 377 28 -2156us[-2156us] +/- 63ms
|
||||
^+ triton.ellipse.net 2 10 377 24 +5716us[+5716us] +/- 62ms
|
||||
^+ lithium.constant.com 2 10 377 351 -820us[ -820us] +/- 64ms
|
||||
^* t2.time.bf1.yahoo.com 2 10 377 453 -992us[ -965us] +/- 46ms
|
||||
^- ntp.idealab.com 2 10 377 799 +3653us[+3674us] +/- 87ms
|
||||
[root@studentvm1 ~]#
|
||||
```
|
||||
|
||||
If I wanted my server to be the preferred reference time source for this host, I would add the line below to the **/etc/chrony.conf** file.
|
||||
|
||||
```
|
||||
server 192.168.0.51 iburst prefer
|
||||
```
|
||||
|
||||
I usually place this line just above the first pool server statement near the top of the file. There is no special reason for this, except I like to keep the server statements together. It would work just as well at the bottom of the file, and I have done that on several hosts. This configuration file is not sequence-sensitive.
|
||||
|
||||
The **prefer** option marks this as the preferred reference source. As such, this host will always be synchronized with this reference source (as long as it is available). We can also use the fully qualified hostname for a remote reference server or the hostname only (without the domain name) for a local reference time source as long as the search statement is set in the **/etc/resolv.conf** file. I prefer the IP address to ensure that the time source is accessible even if DNS is not working. In most environments, the server name is probably the better option, because NTP will continue to work even if the server's IP address changes.
|
||||
|
||||
If you don't have a specific reference source you want to synchronize to, it is fine to use the defaults.
|
||||
|
||||
### Configuring an NTP server with Chrony
|
||||
|
||||
The nice thing about the Chrony configuration file is that this single file configures the host as both a client and a server. To add a server function to our host—it will always be a client, obtaining its time from a reference server—we just need to make a couple of changes to the Chrony configuration, then configure the host's firewall to accept NTP requests.
|
||||
|
||||
Open the **/etc/ ** **chrony****.conf** file in your favorite text editor and uncomment the **local stratum 10** line. This enables the Chrony NTP server to continue to act as if it were connected to a remote reference server if the internet connection fails; this enables the host to continue to be an NTP server to other hosts on the local network.
|
||||
|
||||
Let's restart **chronyd** and track how the service is working for a few minutes. Before we enable our host as an NTP server, we want to test a bit.
|
||||
|
||||
```
|
||||
[root@studentvm1 ~]# systemctl restart chronyd ; watch chronyc tracking
|
||||
```
|
||||
|
||||
The results should look like this. The **watch** command runs the **chronyc tracking** command every two seconds so we can watch changes occur over time.
|
||||
|
||||
```
|
||||
Every 2.0s: chronyc tracking studentvm1: Fri Nov 16 20:59:31 2018
|
||||
|
||||
Reference ID : C0A80033 (192.168.0.51)
|
||||
Stratum : 4
|
||||
Ref time (UTC) : Sat Nov 17 01:58:51 2018
|
||||
System time : 0.001598277 seconds fast of NTP time
|
||||
Last offset : +0.001791533 seconds
|
||||
RMS offset : 0.001791533 seconds
|
||||
Frequency : 0.546 ppm slow
|
||||
Residual freq : -0.175 ppm
|
||||
Skew : 0.168 ppm
|
||||
Root delay : 0.094823152 seconds
|
||||
Root dispersion : 0.021242738 seconds
|
||||
Update interval : 65.0 seconds
|
||||
Leap status : Normal
|
||||
```
|
||||
|
||||
Notice that my NTP server, the **studentvm1** host, synchronizes to the host at 192.168.0.51, which is my internal network NTP server, at stratum 4. Synchronizing directly to the Fedora pool machines would result in synchronization at stratum 3. Notice also that the amount of error decreases over time. Eventually, it should stabilize with a tiny variation around a fairly small range of error. The size of the error depends upon the stratum and other network factors. After a few minutes, use Ctrl+C to break out of the watch loop.
|
||||
|
||||
To turn our host into an NTP server, we need to allow it to listen on the local network. Uncomment the following line to allow hosts on the local network to access our NTP server.
|
||||
|
||||
```
|
||||
# Allow NTP client access from local network.
|
||||
allow 192.168.0.0/16
|
||||
```
|
||||
|
||||
Note that the server can listen for requests on any local network it's attached to. The IP address in the "allow" line is just intended for illustrative purposes. Be sure to change the IP network and subnet mask in that line to match your local network's.
|
||||
|
||||
Restart **chronyd**.
|
||||
|
||||
```
|
||||
[root@studentvm1 ~]# systemctl restart chronyd
|
||||
```
|
||||
|
||||
To allow other hosts on your network to access this server, configure the firewall to allow inbound UDP packets on port 123. Check your firewall's documentation to find out how to do that.
|
||||
|
||||
### Testing
|
||||
|
||||
Your host is now an NTP server. You can test it with another host or a VM that has access to the network on which the NTP server is listening. Configure the client to use the new NTP server as the preferred server in the **/etc/chrony.conf** file, then monitor that client using the **chronyc** tools we used above.
|
||||
|
||||
### Chronyc as an interactive tool
|
||||
|
||||
As I mentioned earlier, **chronyc** can be used as an interactive command tool. Simply run the command without a subcommand and you get a **chronyc** command prompt.
|
||||
|
||||
```
|
||||
[root@studentvm1 ~]# chronyc
|
||||
chrony version 3.4
|
||||
Copyright (C) 1997-2003, 2007, 2009-2018 Richard P. Curnow and others
|
||||
chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and
|
||||
you are welcome to redistribute it under certain conditions. See the
|
||||
GNU General Public License version 2 for details.
|
||||
|
||||
chronyc>
|
||||
```
|
||||
|
||||
You can enter just the subcommands at this prompt. Try using the **tracking** , **ntpdata** , and **sources** commands. The **chronyc** command line allows command recall and editing for **chronyc** subcommands. You can use the **help** subcommand to get a list of possible commands and their syntax.
|
||||
|
||||
### Conclusion
|
||||
|
||||
Chrony is a powerful tool for synchronizing the times of client hosts, whether they are all on the local network or scattered around the globe. It's easy to configure because, despite the large number of options available, only a few configurations are required for most circumstances.
|
||||
|
||||
After my client computers have synchronized with the NTP server, I like to set the system hardware clock from the system (OS) time by using the following command:
|
||||
|
||||
```
|
||||
/sbin/hwclock --systohc
|
||||
```
|
||||
|
||||
This command can be added as a cron job or a script in **cron.daily** to keep the hardware clock synced with the system time.
|
||||
|
||||
Chrony and NTP (the service) both use the same configuration, and the files' contents are interchangeable. The man pages for [chronyd][5], [chronyc][4], and [chrony.conf][6] contain an amazing amount of information that can help you get started or learn about esoteric configuration options.
|
||||
|
||||
Do you run your own NTP server? Let us know in the comments and be sure to tell us which implementation you are using, NTP or Chrony.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/12/manage-ntp-chrony
|
||||
|
||||
作者:[David Both][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/dboth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://en.wikipedia.org/wiki/Does_Anybody_Really_Know_What_Time_It_Is%3F
|
||||
[2]: https://en.wikipedia.org/wiki/Network_Time_Protocol
|
||||
[3]: https://chrony.tuxfamily.org/comparison.html
|
||||
[4]: https://linux.die.net/man/1/chronyc
|
||||
[5]: https://linux.die.net/man/8/chronyd
|
||||
[6]: https://linux.die.net/man/5/chrony.conf
|
@ -1,3 +1,12 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (Create a containerized machine learning model)
|
||||
[#]: via: (https://fedoramagazine.org/create-containerized-machine-learning-model/)
|
||||
[#]: author: (Sven Bösiger)
|
||||
[#]: url: ( )
|
||||
|
||||
Create a containerized machine learning model
|
||||
======
|
||||
|
||||
|
191
sources/tech/20181108 My Google-free Android life.md
Normal file
191
sources/tech/20181108 My Google-free Android life.md
Normal file
@ -0,0 +1,191 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (My Google-free Android life)
|
||||
[#]: via: (https://lushka.al/my-android-setup/)
|
||||
[#]: author: (Anxhelo Lushka https://lushka.al/)
|
||||
|
||||
My Google-free Android life
|
||||
======
|
||||
|
||||
People have been asking me a lot lately about my phone, my Android setup and how I manage to use my smartphone without Google Services. Well, this is a post that aims to address precisely that. I would like to make this article really beginner-friendly so I’ll try to go slow, going through things one by one and including screenshots so you can have a better view on how things happen and work like.
|
||||
|
||||
At first I’ll start with why Google Services are (imo) bad for your device. I could cut it short and guide you to this [post][1] by [Richard Stallman][2], but I’m grabbing a few main points from it and adding them here.
|
||||
|
||||
* Nonfree software required
|
||||
* In general, most Google services require running nonfree Javascript code. Nowadays, nothing whatsoever appears if Javascript is disabled, even making a Google account requires running nonfree software (Javascript sent by the site), same thing for logging in.
|
||||
* Surveillance
|
||||
* Google quietly combines its ad-tracking profiles with its browsing profiles and stores a huge amount of data on each user.
|
||||
* Terms of Service
|
||||
* Google cuts off accounts for users that resell Pixel phones. They lose access to all of their mail and documents stored in Google servers under that account.
|
||||
* Censorship
|
||||
* Amazon and Google have cut off domain-fronting, a feature used to enable people in tyrannical countries to reach communication systems that are banned there.
|
||||
* Google has agreed to perform special censorship of Youtube for the government of Pakistan, deleting views that the state opposes. This will help the illiberal Pakistani state suppress dissent.
|
||||
* Youtube’s “content ID” automatically deletes posted videos in a way copyright law does not require.
|
||||
|
||||
|
||||
|
||||
These are just a few reasons, but you can read the post by RMS I linked above in which he tries to explain these points in detail. Although it may look like a tinfoil hat reaction to you, all these actions already happen everyday in real life.
|
||||
|
||||
### Next on the list, my setup and a tutorial on how I achieved it
|
||||
|
||||
I own a **[Xiaomi Redmi Note 5 Pro][3]** smartphone (codename **whyred** ), produced in China by [Xiaomi][4], which I bought for around 185 EUR 4 months ago (from the time of writing this post).
|
||||
|
||||
Now you might be thinking, ‘but why did you buy a Chinese brand, they are not reliable’. Yes, it is not made from the usuals as you would expect, such as Samsung (which people often associate with Android, which is plain wrong), OnePlus, Nokia etc, but you should know almost every phone is produced in China.
|
||||
|
||||
There were a few reasons I chose this phone, first one of course being the price. It is a quite **budget-friendly** device, so most people are able to afford it. Next one would be the specs, which on paper (not only) are pretty decents for the price tag. With a 6 inch screen (Full HD resolution), a **4000 mAh battery** (superb battery life), 4GB of RAM, 64GB of storage, dual back cameras (12MP + 5MP), a front camera with flash (13MP) and a decent efficient Snapdragon 636, it was probably the best choice at that moment.
|
||||
|
||||
The issue with it was that it came with [MIUI][5], the Android skin that Xiaomi ships with most of its devices (except the Android One project devices). Yes, it is not that horrible, it has some extra features, but the problems lie deeper within. One of the reasons these devices from Xiaomi are so cheap (afaik they only have 5-10% win margin from sales) is that **they include data mining and ads in the system altogether with MIUI**. In this way, the system apps requires extra unnecessary permissions that mine your data and bombard you with ads, from which Xiaomi earns money.
|
||||
|
||||
Funnily enough, the Weather app included wanted access to my contacts and to make calls, why would it need that if it would just show the weather? Another case was with the Recorder app, it also required contacts and internet permissions, probably to send those recordings back to Xiaomi.
|
||||
|
||||
To fix this, I’d have to format the phone and get rid of MIUI. This has become increasingly difficult with the latest phones in the market.
|
||||
|
||||
The concept of formatting a phone is simple, you remove the existing system and install a new one of your preference (Android-only in this case). To do that, you have to have your [bootloader][6] unlocked.
|
||||
|
||||
> A bootloader is a computer program that loads an operating system (OS) or runtime environment for the computer after completion of the self-tests. — [Wikipedia][7]
|
||||
|
||||
The problem here is that Xiaomi has a specific policy about the bootloader unlocking. A few months ago, the process was like this. You would have to [make a request][8] to Xiaomi to obtain an unlock code for your phone, by giving a valid reason, but this would not always work, as they could just refuse your request without reason and explanation.
|
||||
|
||||
Now, that process has changed. You’ll have to download a specific software from Xiaomi, called [Mi Unlock][9], install it in your Windows PC, [activate Debugging Settings in Developer Options][10] on your phone, reboot to the bootloader mode (by holding the Volume Down + Power button while the phone is off) and connect the phone to your computer to start a process called “Approval”. This process starts a timer on the Xiaomi servers that will allow you to **unlock the phone only after a period of 15 days** (or a month in some rare cases, totally random) goes by.
|
||||
|
||||
![Mi Unlock app][11]
|
||||
|
||||
After this period of 15 days has passed, you have to re-connect your phone and do the same procedure as above, then by pressing the Unlock button your bootloader will be unlocked and this will allow you to install other ROM-s (systems). **Careful, make sure to backup your data because unlocking the bootloader deletes everything in the phone**.
|
||||
|
||||
The next step would be finding a system ([ROM][12]) that works for your device. I searched through the [XDA Developers Forum][13], which is a place where Android developers and users exchange ideas, apps etc. Fortunately, my phone is quite popular so it had [its own forum category][14]. There, I skimmed through some popular ROM-s for my device and decided to use the [AOSiP ROM][15] (AOSiP standing for Android Open Source illusion Project).
|
||||
|
||||
**EDIT** : Someone emailed me to say that my article is exactly what [/e/][16] does and is targeted to. I wanted to say thank you for reaching out but that is not true at all. The reasoning behind my opinion about /e/ can also be found in this [website][17], but I’ll list a few of the reasons here.
|
||||
|
||||
eelo is a “foundation” that got over 200K € in funding from Kickstarter and IndieGoGo, promising to create a mobile OS and web services that are open and secure and protect your privacy.
|
||||
|
||||
1. Their OS is based on LineageOS 14.1 (Android 7.1) with microG and other open source apps with it, which already exists for a long time now and it’s called [Lineage for microG][18].
|
||||
2. Instead of building all apps from the source code, they download the APKs from [APKPure][19] and put them in the ROM, without knowing if those APKs contain proprietary code/malware in them.
|
||||
3. At one point, they were literally just removing the Lineage copyright header from their code and adding theirs.
|
||||
4. They love to delete negative feedback and censor their users’ opinions in their Telegram group chat.
|
||||
|
||||
|
||||
|
||||
In conclusion, I **don’t recommend using /e/** ROM-s (at least until now).
|
||||
|
||||
Another thing you would likely want to do is have [root access][20] to your phone, to make it truly yours and modify files in the system, such as use a system-wide adblocker etc. To do this, I decided to use [Magisk][21], a godsend app developed by a student to help you gain root access on your device and install what are called [modules][22], basically software.
|
||||
|
||||
After downloading the ROM and Magisk, I had to install them on my phone. To do that, I moved the files to my SD card on the phone. Now, to install the system, I had to use something called a [recovery system][23]. The one I use is called [TWRP][24] (standing for TeamWin Recovery Project), a popular solution.
|
||||
|
||||
To install the recovery system (sounds hard, I know), I had to [flash][20] the file on the phone. To do that, I connected my phone with the computer (Fedora Linux system) and with something called [ADB Tools][25] I issued a command that overwrites the system recovery with the custom one I had.
|
||||
|
||||
> fastboot flash recovery twrp.img
|
||||
|
||||
After this was done, I turned off the phone and kept Volume Up + Power button pressed until I saw the TWRP screen show up. That meant I was good to go and it was ready to receive my commands.
|
||||
|
||||
![TWRP screen][26]
|
||||
|
||||
Next step was to **issue a Wipe command** , necessary when you first install a custom ROM on your phone. As you can see from the image above, the Wipe command clears the Data, Cache and Dalvik (there is also an advanced option that allows us to tick a box to delete the System one too, as we don’t need the old one anymore).
|
||||
|
||||
This takes a few moments and after that, your phone is basically clean. Now it’s time to **install the system**. By pressing the Install button on the main screen, we select the zip file we added there before (the ROM file) and swipe the screen to install it. Next, we have to install Magisk, which gives us root access to the device.
|
||||
|
||||
**EDIT** : As some more experienced/power Android users might have noticed until now, there is no [GApps][27] (Google Apps) included. This is what we call GApps-less in the Android world, not having those packages installed at all.
|
||||
|
||||
Note that one of the downsides of not having Google Services installed is that some of your apps might not work, for example their notifications might take longer to arrive or might not even work at all (this is what happens with Mattermost app for me). This happens because these apps use [Google Cloud Messaging][28] (now called [Firebase][29]) to wake the phone and push notifications to your phone.
|
||||
|
||||
You can solve this (partially) by installing and using [microG][30] which provides some features of Google Services but allows for more control on your side. I don’t recommend using this because it still helps Google Services and you don’t really give up on them, but it’s a good start if you want to quit Google slowly and not go cold turkey on it.
|
||||
|
||||
After successfully installing both, now we reboot the phone and **tada** 🎉, we are in the main screen.
|
||||
|
||||
### Next part, installing the apps and configuring everything
|
||||
|
||||
This is where things start to get easier. To install the apps, I use [F-Droid][31], an alternative app store that includes **only free and open source apps**. If you need apps that are not available there, you can use [Aurora Store][32], a client to download apps from the Play Store without using your Google account or getting tracked.
|
||||
|
||||
F-Droid has what are called repos, a “storehouse” that contains apps you can install. I use the default ones and have added another one from [IzzyOnDroid][33], that contains some more apps not available from the default F-Droid repo and is updated more often.
|
||||
|
||||
![My repos][34]
|
||||
|
||||
Below you will find a list of the apps I have installed, what they replace and their use.
|
||||
|
||||
This is pretty much **my list of the most useful F-Droid apps** I use, but unfortunately these are NOT the only apps I use. The proprietary apps I use (I know, I might sound a hypocrite, but not everything is replaceable, not yet at least) are as below:
|
||||
|
||||
* AliExpress
|
||||
* Boost for Reddit
|
||||
* Google Camera (coupled with Camera API 2, this app allows me to take wonderful pictures with a 185 EUR phone, it’s just too impressive)
|
||||
* Instagram
|
||||
* MediaBox HD (allows me to stream movies)
|
||||
* Mi Fit (an app that pairs with my Mi Band 2)
|
||||
* MyVodafoneAL (the carrier app)
|
||||
* ProtonMail (email app)
|
||||
* Shazam Encore (to find those songs you usually listen in coffee shops)
|
||||
* Snapseed (photo editing app, really simple, powerful and quite good)
|
||||
* Spotify (music streaming)
|
||||
* Titanium Backup (to backup my app data, wifi passwords, calls log etc.)
|
||||
* ViPER4Android FX (music equalizer)
|
||||
* VSCO (photo editing, never use it really)
|
||||
* WhatsApp (E2E proprietary messaging app, almost everyone I know has it)
|
||||
* WiFi Map (mapped hotspots that are available, handy when abroad)
|
||||
|
||||
|
||||
|
||||
This is pretty much it, all the apps I use on my phone. **The configs are then pretty simple and straightforward and I can give a few tips**.
|
||||
|
||||
1. Read and check the permissions of apps carefully, don’t click ‘Install’ mindlessly.
|
||||
2. Try to use as many open source apps as possible, they both respect your privacy and are free (as in both free beer and freedom).
|
||||
3. Use a VPN as much as you can, find a reputable one and don’t use free ones, otherwise you get to be the product and you’ll get your data harvested.
|
||||
4. Don’t keep your WiFi/mobile data/location on all the time, it might be a security risk.
|
||||
5. Try not to rely on fingerprint unlock only, or better yet use only PIN/password/pattern unlock, as biometric data can be cloned and used against you, for example to unlock your phone and steal your data.
|
||||
|
||||
|
||||
|
||||
And as a bonus for reading far down here, **a screenshot of my home screen** right now.
|
||||
|
||||
![Screenshot][35]
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://lushka.al/my-android-setup/
|
||||
|
||||
作者:[Anxhelo Lushka][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://lushka.al/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://stallman.org/google.html
|
||||
[2]: https://en.wikipedia.org/wiki/Richard_Stallman
|
||||
[3]: https://www.gsmarena.com/xiaomi_redmi_note_5_pro-8893.php
|
||||
[4]: https://en.wikipedia.org/wiki/Xiaomi
|
||||
[5]: https://en.wikipedia.org/wiki/MIUI
|
||||
[6]: https://forum.xda-developers.com/wiki/Bootloader
|
||||
[7]: https://en.wikipedia.org/wiki/Booting
|
||||
[8]: https://en.miui.com/unlock/
|
||||
[9]: http://www.miui.com/unlock/apply.php
|
||||
[10]: https://www.youtube.com/watch?v=7zhEsJlivFA
|
||||
[11]: https://lushka.al//assets/img/posts/mi-unlock.png
|
||||
[12]: https://www.xda-developers.com/what-is-custom-rom-android/
|
||||
[13]: https://forum.xda-developers.com/
|
||||
[14]: https://forum.xda-developers.com/redmi-note-5-pro
|
||||
[15]: https://forum.xda-developers.com/redmi-note-5-pro/development/rom-aosip-8-1-t3804473
|
||||
[16]: https://e.foundation
|
||||
[17]: https://ewwlo.xyz/evil
|
||||
[18]: https://lineage.microg.org/
|
||||
[19]: https://apkpure.com/
|
||||
[20]: https://lifehacker.com/5789397/the-always-up-to-date-guide-to-rooting-any-android-phone
|
||||
[21]: https://forum.xda-developers.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445
|
||||
[22]: https://forum.xda-developers.com/apps/magisk
|
||||
[23]: http://www.smartmobilephonesolutions.com/content/android-system-recovery
|
||||
[24]: https://dl.twrp.me/whyred/
|
||||
[25]: https://developer.android.com/studio/command-line/adb
|
||||
[26]: https://lushka.al//assets/img/posts/android-twrp.png
|
||||
[27]: https://opengapps.org/
|
||||
[28]: https://developers.google.com/cloud-messaging/
|
||||
[29]: https://firebase.google.com/docs/cloud-messaging/
|
||||
[30]: https://microg.org/
|
||||
[31]: https://f-droid.org/
|
||||
[32]: https://f-droid.org/en/packages/com.dragons.aurora/
|
||||
[33]: https://android.izzysoft.de/repo
|
||||
[34]: https://lushka.al//assets/img/posts/android-fdroid-repos.jpg
|
||||
[35]: https://lushka.al//assets/img/posts/android-screenshot.jpg
|
||||
[36]: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
@ -1,139 +0,0 @@
|
||||
translating by seriouszyx
|
||||
|
||||
A Free, Secure And Cross-platform Password Manager
|
||||
======
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-Password-Manager-720x340.png)
|
||||
|
||||
In this modern Internet era, you will surely have multiple accounts on lot of websites. It could be a personal or official mail account, social or professional network account, GitHub account, and ecommerce account etc. So you should have several different passwords for different accounts. I am sure that you are already aware that setting up same password to multiple accounts is crazy and dangerous practice. If an attacker managed to breach one of your accounts, it’s highly likely he/she will try to access other accounts you have with the same password. So, it is **highly recommended to set different passwords** to different accounts.
|
||||
|
||||
However, remembering several passwords might be difficult. You can write them in a paper. But it is not an efficient method either and you might lose them over a period of time. This is where the password managers comes in help. The password managers are like a repository where you can store all your passwords for different accounts and lock them down with a master password. By this way, all you need to remember is just the master password. We already have reviewed an open source password manager named [**KeeWeb**][1]. Today, we are going to see yet another password manager called **Buttercup**.
|
||||
|
||||
### About Buttercup
|
||||
|
||||
Buttercup is a free, open source, secure and cross-platform password manager written using **NodeJS**. It helps you to store all your login credentials of different accounts in an encrypted archive, which can be stored in your local system or any remote services like DropBox, ownCloud, NextCloud and WebDAV-based services. It uses strong **256bit AES encryption** method to save your sensitive data with a master password. So, no one can access your login details except those who have the master password. Buttercup currently supports Linux, Mac OS and Windows. It is also available a browser extension and mobile app. so, you can access the same archive you use on the desktop application and browser extension in your Android or iOS devices as well.
|
||||
|
||||
### Installing Buttercup Password Manager
|
||||
|
||||
Buttercup is currently available as **.deb** , **.rpm** packages, portable AppImage and tar archives for Linux platform. Head over to the [**releases pages**][2] and download and install the version you want to use.
|
||||
|
||||
Buttercup desktop application is also available in [**AUR**][3], so you can install on Arch-based systems using AUR helper programs, such as [**Yay**][4], as shown below:
|
||||
|
||||
```
|
||||
$ yay -S buttercup-desktop
|
||||
```
|
||||
|
||||
If you have downloaded the portable AppImage file, make it executable using command:
|
||||
|
||||
```
|
||||
$ chmod +x buttercup-desktop-1.11.0-x86_64.AppImage
|
||||
```
|
||||
|
||||
Then, launch it using command:
|
||||
|
||||
```
|
||||
$ ./buttercup-desktop-1.11.0-x86_64.AppImage
|
||||
```
|
||||
|
||||
Once you run this command, it will prompt whether you like to integrate Buttercup AppImage with your system. If you choose ‘Yes’, this will add it to your applications menu and install icons. If you don’t do this, you can still launch the application by double-clicking on the AppImage or using the above command from the Terminal.
|
||||
|
||||
### Add archives
|
||||
|
||||
When you launch it for the first time, you will see the following welcome screen:
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-1.png)
|
||||
|
||||
We haven’t added any archives yet, so let us add one. To do so, click on the “New Archive File” button and type the name of the archive file and choose the location to save it.
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-2.png)
|
||||
|
||||
You can name it as you wish. I named it mine as “mypass”. The archives will have extension **.bcup** at the end and saved in the location of your choice.
|
||||
|
||||
If you already have created one, simply choose it by clicking on “Open Archive File”.
|
||||
|
||||
Next, buttercup will prompt you to enter a master password to the newly created archive. It is recommended to provide a strong password to protect the archives from the unauthorized access.
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-3.png)
|
||||
|
||||
We have now created an archive and secured it with a master password. Similarly, you can create any number of archives and protect them with a password.
|
||||
|
||||
Let us go ahead and add the account details in the archives.
|
||||
|
||||
### Adding entries (login credentials) in the archives
|
||||
|
||||
Once you created or opened the archive, you will see the following screen.
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-4.png)
|
||||
|
||||
It is like a vault where we are going to save our login credentials of different online accounts. As you can see, we haven’t added any entries yet. Let us add some.
|
||||
|
||||
To add a new entry, click “ADD ENTRY” button on the lower right corner and enter your account information you want to save.
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-5-1.png)
|
||||
|
||||
If you want to add any extra detail, there is an “ADD NEW FIELD” option right under the each entry. Just click on it and add as many as fields you want to include in the entries.
|
||||
|
||||
Once you added all entries, you will see them on the right pane of the Buttercup interface.
|
||||
|
||||
![][6]
|
||||
|
||||
### Creating new groups
|
||||
|
||||
You can also group login details under different name for easy recognition. Say for example, you can group all your mail accounts under a distinct name named “my_mails”. By default, your login details will be saved under “General” group. To create a new group, click “NEW GROUP” button and provide the name for the group. When creating new entries inside a new group, just click on the group name and start adding the entries as shown above.
|
||||
|
||||
### Manage and access login details
|
||||
|
||||
The data stored in the archives can be edited, moved to different groups, or entirely deleted at anytime. For instance, if you want to copy the username or password to clipboard, right click on the entry and choose “Copy to Clipboard” option.
|
||||
|
||||
![][7]
|
||||
|
||||
To edit/modify the data in the future, just click “Edit” button under the selected entry.
|
||||
|
||||
### Save archives on remote location
|
||||
|
||||
By default, Buttercup will save your data on the local system. However, you can save them on different remote services, such as Dropbox, ownCloud/NextCloud, WebDAV-based service.
|
||||
|
||||
To connect to these services, go to **File - > Connect Cloud Sources**.
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-8.png)
|
||||
|
||||
And, choose the service you want to connect and authorize it to save your data.
|
||||
|
||||
![][8]
|
||||
|
||||
You can also connect those services from the Buttercup welcome screen while adding the archives.
|
||||
|
||||
### Import/Export
|
||||
|
||||
Buttercup allows you to import or export data to or from other password managers, such as 1Password, Lastpass and KeePass. You can also export your data and access them from another system or device, for example on your Android phone. You can export Buttercup vaults to CSV format as well.
|
||||
|
||||
![][9]
|
||||
|
||||
Buttercup is a simple, yet mature and fully functional password manager. It is being actively developed for years. If you ever in need of a password manager, Buttercup might a good choice. For more details, refer the project website and github page.
|
||||
|
||||
And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned!
|
||||
|
||||
Cheers!
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/buttercup-a-free-secure-and-cross-platform-password-manager/
|
||||
|
||||
作者:[SK][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.ostechnix.com/author/sk/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.ostechnix.com/keeweb-an-open-source-cross-platform-password-manager/
|
||||
[2]: https://github.com/buttercup/buttercup-desktop/releases/latest
|
||||
[3]: https://aur.archlinux.org/packages/buttercup-desktop/
|
||||
[4]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/
|
||||
[5]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
|
||||
[6]: http://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-6.png
|
||||
[7]: http://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-7.png
|
||||
[8]: http://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-9.png
|
||||
[9]: http://www.ostechnix.com/wp-content/uploads/2018/11/buttercup-10.png
|
@ -1,129 +0,0 @@
|
||||
Translating by Jamskr
|
||||
|
||||
Coupled commands with control operators in Bash
|
||||
======
|
||||
Add logic to the command line with control operators in compound commands.
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-lead-yearbook-best-couple.png?itok=a_99oCdE)
|
||||
|
||||
Simple compound commands—such as stringing several commands together in a sequence on the command line—are used often. Such commands are separated by semicolons, which define the end of a command. To create a simple series of shell commands on a single line, simply separate each command using a semicolon, like this:
|
||||
|
||||
```
|
||||
command1 ; command2 ; command3 ; command4 ;
|
||||
```
|
||||
|
||||
You don't need to add a final semicolon because pressing the Enter key implies the end of the final command, but it's fine to add it for consistency.
|
||||
|
||||
**& &** and **||** control operators built into Bash. These two control operators provide some flow control and enable us to alter the code-execution sequence. The semicolon and the **newline** character are also considered to be Bash control operators.
|
||||
|
||||
All the commands will run without a problem—as long as no error occurs. But what happens if an error happens? We can anticipate and allow for errors using theandcontrol operators built into Bash. These two control operators provide some flow control and enable us to alter the code-execution sequence. The semicolon and thecharacter are also considered to be Bash control operators.
|
||||
|
||||
The **& &** operator simply says "if command1 is successful, then run command2." If command1 fails for any reason, command2 won't run. That syntax looks like:
|
||||
|
||||
```
|
||||
command1 && command2
|
||||
```
|
||||
|
||||
This works because every command returns a code to the shell that indicates whether it completed successfully or failed during execution. By convention, a return code (RC) of 0 (zero) indicates success and any positive number indicates some type of failure. Some sysadmin tools just return a 1 to indicate any failure, but many use other positive numerical codes to indicate the type of failure.
|
||||
|
||||
The Bash shell's **$?** variable can be checked very easily by a script, by the next command in a list of commands, or even directly by a sysadmin. Let's look at RCs. We can run a simple command and immediately check the RC, which will always pertain to the last command that ran.
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ ll ; echo "RC = $?"
|
||||
total 284
|
||||
-rw-rw-r-- 1 student student 130 Sep 15 16:21 ascii-program.sh
|
||||
drwxrwxr-x 2 student student 4096 Nov 10 11:09 bin
|
||||
<snip>
|
||||
drwxr-xr-x. 2 student student 4096 Aug 18 10:21 Videos
|
||||
RC = 0
|
||||
[student@studentvm1 ~]$
|
||||
```
|
||||
|
||||
This RC is 0, which means the command completed successfully. Now try the same command on a directory where we don't have permissions.
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ ll /root ; echo "RC = $?"
|
||||
ls: cannot open directory '/root': Permission denied
|
||||
RC = 2
|
||||
[student@studentvm1 ~]$
|
||||
```
|
||||
|
||||
This RC's meaning can be found in the [**ls** command's man page][1].
|
||||
|
||||
Let's try the **& &** control operator as it might be used in a command-line program. We'll start with something simple: Create a new directory and, if that is successful, create a new file in it.
|
||||
|
||||
We need a directory where we can create other directories. First, create a temporary directory in your home directory where you can do some testing.
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ cd ; mkdir testdir
|
||||
```
|
||||
|
||||
Create a new directory in **~/testdir** , which should be empty because you just created it, and then create a new, empty file in that new directory. The following command will do those tasks.
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ mkdir ~/testdir/testdir2 && touch ~/testdir/testdir2/testfile1
|
||||
[student@studentvm1 ~]$ ll ~/testdir/testdir2/
|
||||
total 0
|
||||
-rw-rw-r-- 1 student student 0 Nov 12 14:13 testfile1
|
||||
[student@studentvm1 ~]$
|
||||
```
|
||||
|
||||
We know everything worked as it should because the **testdir** directory is accessible and writable. Change the permissions on **testdir** so it is no longer accessible to the user **student** as follows:
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ chmod 076 testdir ; ll | grep testdir
|
||||
d---rwxrw-. 3 student student 4096 Nov 12 14:13 testdir
|
||||
[student@studentvm1 ~]$
|
||||
```
|
||||
|
||||
Using the **grep** command after the long list ( **ll** ) shows the listing for **testdir**. You can see that the user **student** no longer has access to the **testdir** directory. Now let's run almost the same command as before but change it to create a different directory name inside **testdir**.
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ mkdir ~/testdir/testdir3 && touch ~/testdir/testdir3/testfile1
|
||||
mkdir: cannot create directory ‘/home/student/testdir/testdir3’: Permission denied
|
||||
[student@studentvm1 ~]$
|
||||
```
|
||||
|
||||
Although we received an error message, using the **& &** control operator prevents the **touch** command from running because there was an error in creating **testdir3**. This type of command-line logical flow control can prevent errors from compounding and making a real mess of things. But let's make it a little more complicated.
|
||||
|
||||
The **||** control operator allows us to add another command that executes when the initial program statement returns a code larger than zero.
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ mkdir ~/testdir/testdir3 && touch ~/testdir/testdir3/testfile1 || echo "An error occurred while creating the directory."
|
||||
mkdir: cannot create directory ‘/home/student/testdir/testdir3’: Permission denied
|
||||
An error occurred while creating the directory.
|
||||
[student@studentvm1 ~]$
|
||||
```
|
||||
|
||||
Our compound command syntax using flow control takes this general form when we use the **& &** and **||** control operators:
|
||||
|
||||
```
|
||||
preceding commands ; command1 && command2 || command3 ; following commands
|
||||
```
|
||||
|
||||
The compound command using the control operators may be preceded and followed by other commands that can be related to the ones in the flow-control section but which are unaffected by the flow control. All of those commands will execute without regard to anything that takes place inside the flow-control compound command.
|
||||
|
||||
These flow-control operators can make working at the command line more efficient by handling decisions and letting us know when a problem has occurred. I use them directly on the command line as well as in scripts.
|
||||
|
||||
You can clean up as the root user to delete the directory and its contents.
|
||||
|
||||
```
|
||||
[root@studentvm1 ~]# rm -rf /home/student/testdir
|
||||
```
|
||||
|
||||
How do you use Bash control operators? Let us know in the comment section.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/11/control-operators-bash-shell
|
||||
|
||||
作者:[David Both][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/dboth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: http://man7.org/linux/man-pages/man1/ls.1.html
|
@ -0,0 +1,192 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (The Top Command Tutorial With Examples For Beginners)
|
||||
[#]: via: (https://www.ostechnix.com/the-top-command-tutorial-with-examples-for-beginners/)
|
||||
[#]: author: ([SK](https://www.ostechnix.com/author/sk/))
|
||||
[#]: url: ( )
|
||||
|
||||
The Top Command Tutorial With Examples For Beginners
|
||||
======
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/top-command-720x340.png)
|
||||
|
||||
As a Linux administrator, you may need to need to know some basic details of your Linux system, such as the currently running processes, average system load, cpu and memory usage etc., at some point. Thankfully, we have a command line utility called **“top”** to get such details. The top command is a well-known and most widely used utility to display dynamic real-time information about running processes in Unix-like operating systems. In this brief tutorial, we are going to see some common use cases of top command.
|
||||
|
||||
### Top Command Examples
|
||||
|
||||
**Monitor all processes**
|
||||
|
||||
To start monitoring the running processes, simply run the top command without any options:
|
||||
|
||||
```
|
||||
$ top
|
||||
```
|
||||
|
||||
Sample output:
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/top-command-1.png)
|
||||
|
||||
As you see in the above screenshot, top command displays the list of processes in multiple columns. Each column displays details such as pid, user, cpu usage, memory usage. Apart from the list of processes, you will also see the brief stats about average system load, number of tasks, cpu usage, memory usage and swap usage on the top.
|
||||
|
||||
Here is the explanation of the parameters mentioned above.
|
||||
|
||||
* **PID** – Process id of the task.
|
||||
* **USER** – Username of the the task’s owner.
|
||||
* **PR** – Priority of the task.
|
||||
* **NI** – Nice value of the task. If the nice value is negative, the process gets higher priority. If the nice value is positive, the priority is low. Refer [**this guide**][1] to know more about nice.
|
||||
* **VIRT** – Total amount of virtual memory used by the task.
|
||||
* **RES** – Resident Memory Size, the non-swapped physical memory a task is currently using.
|
||||
* **SHR** – Shared Memory Size. The amount of shared memory used by a task.
|
||||
* **S** – The status of the process (S=sleep R=running Z=zombie).
|
||||
* **%CPU** – CPU usage. The task’s share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.
|
||||
* **%MEM** – Memory Usage. A task’s currently resident share of available physical memory.
|
||||
* **TIME+** – Total CPU time used by the task since it has started, precise to the hundredths of a second.
|
||||
* **COMMAND** – Name of the running program.
|
||||
|
||||
|
||||
|
||||
**Display path of processes**
|
||||
|
||||
If you want to see the absolute path of the running processes, just press **‘c’**. Now you will see the actual path of the programs under the COMMAND column in the below screenshot.
|
||||
|
||||
![][3]
|
||||
|
||||
**Monitor processes owned by a specific user**
|
||||
|
||||
If you run top command without any options, it will list all running processes owned by all users. How about displaying processes owned by a specific user? It is easy! To show the processes owned by a given user, for example **sk** , simply run:
|
||||
|
||||
```
|
||||
$ top -u sk
|
||||
```
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/11/top-command-3.png)
|
||||
|
||||
**Do not show idle/zombie processes**
|
||||
|
||||
Instead of viewing all processes, you can simply ignore the idle or zombie processes. The following command will not show any idle or zombie processes:
|
||||
|
||||
```
|
||||
$ top -i
|
||||
```
|
||||
|
||||
**Monitor processes with PID**
|
||||
|
||||
If you know the PID of any processes, for example 21180, you can monitor that process using **-p** flag.
|
||||
|
||||
```
|
||||
$ top -p 21180
|
||||
```
|
||||
|
||||
You can specify multiple PIDs with comma-separated values.
|
||||
|
||||
**Monitor processes with process name**
|
||||
|
||||
I don’t know PID, but know only the process name. How to monitor it? Simple!
|
||||
|
||||
```
|
||||
$ top -p $(pgrep -d ',' firefox)
|
||||
```
|
||||
|
||||
Here, **firefox** is the process name and **‘pgrep -d’** picks the respective PID from the process name.
|
||||
|
||||
**Display processes by CPU usage**
|
||||
|
||||
Sometimes, you might want to display processes sorted by CPU usage. If so, use the following command:
|
||||
|
||||
```
|
||||
$ top -o %CPU
|
||||
```
|
||||
|
||||
![][4]
|
||||
|
||||
The processes with higher CPU usage will be displayed on the top. Alternatively, you sort the processes by CPU usage by pressing **SHIFT+p**.
|
||||
|
||||
**Display processes by Memory usage**
|
||||
|
||||
Similarly, to order processes by memory usage, the command would be:
|
||||
|
||||
```
|
||||
$ top -o %MEM
|
||||
```
|
||||
|
||||
**Renice processes**
|
||||
|
||||
You can change the priority of a process at any time using the option **‘r’**. Run the top command and press **r** and type the PID of a process to change its priority.
|
||||
|
||||
![][5]
|
||||
|
||||
Here, **‘r’** refers renice.
|
||||
|
||||
**Set update interval**
|
||||
|
||||
Top program has an option to specify the delay between screen updates. If want to change the delay-time, say 5 seconds, run:
|
||||
|
||||
```
|
||||
$ top -d 5
|
||||
```
|
||||
|
||||
The default value is **3.0** seconds.
|
||||
|
||||
If you already started the top command, just press **‘d’** and type delay-time and hit ENTER key.
|
||||
|
||||
![][6]
|
||||
|
||||
**Set number of iterations (repetition)**
|
||||
|
||||
By default, top command will keep running until you press **q** to exit. However, you can set the number of iterations after which top will end. For instance, to exit top command automatically after 5 iterations, run:
|
||||
|
||||
```
|
||||
$ top -n 5
|
||||
```
|
||||
|
||||
**Kill running processes**
|
||||
|
||||
To kill a running process, simply press **‘k’** and type its PID and hit ENTER key.
|
||||
|
||||
![][7]
|
||||
|
||||
Top command supports few other options as well. For example, press **‘z’** to switch between mono and color output. It will help you to easily highlight running processes.
|
||||
|
||||
![][8]
|
||||
|
||||
Press **‘h’** to view all available keyboard shortcuts and help section.
|
||||
|
||||
To quit top, just press **q**.
|
||||
|
||||
At this stage, you will have a basic understanding of top command. For more details, refer man pages.
|
||||
|
||||
```
|
||||
$ man top
|
||||
```
|
||||
|
||||
As you can see, using Top command to monitor the running processes isn’t that hard. Top command is easy to learn and use!
|
||||
|
||||
And, that’s all for now. More good stuffs to come. Stay tuned!
|
||||
|
||||
Cheers!
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/the-top-command-tutorial-with-examples-for-beginners/
|
||||
|
||||
作者:[SK][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.ostechnix.com/author/sk/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.ostechnix.com/change-priority-process-linux/
|
||||
[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
|
||||
[3]: http://www.ostechnix.com/wp-content/uploads/2018/11/top-command-2.png
|
||||
[4]: http://www.ostechnix.com/wp-content/uploads/2018/11/top-command-4.png
|
||||
[5]: http://www.ostechnix.com/wp-content/uploads/2018/11/top-command-8.png
|
||||
[6]: http://www.ostechnix.com/wp-content/uploads/2018/11/top-command-7.png
|
||||
[7]: http://www.ostechnix.com/wp-content/uploads/2018/11/top-command-5.png
|
||||
[8]: http://www.ostechnix.com/wp-content/uploads/2018/11/top-command-6.png
|
@ -0,0 +1,108 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (ANGRYsearch – Quick Search GUI Tool for Linux)
|
||||
[#]: via: (https://itsfoss.com/angrysearch/)
|
||||
[#]: author: (John Paul https://itsfoss.com/author/john/)
|
||||
[#]: url: ( )
|
||||
|
||||
ANGRYsearch – Quick Search GUI Tool for Linux
|
||||
======
|
||||
|
||||
A search application is one of the most important tools you can have on your computer. Most are slow to indexes your system and find results. However, today we will be looking at an application that can display results as you type. Today, we will be looking at ANGRYsearch.
|
||||
|
||||
### What is ANGRYsearch?
|
||||
|
||||
![][1]
|
||||
Newly installed ANGRYsearch
|
||||
|
||||
[ANGRYsearch][2] is a Python-based application that delivers results as you type your search query. The overall idea and design of the application are both inspired by [Everything][3] a search tool for Windows. (I discovered Everything ad couple of years ago and install it wherever I use Windows.)
|
||||
|
||||
ANGRYsearch is able to display the search results so quickly because it only indexes filenames. After you install ANGRYsearch, you create a database of filenames by indexing your system. ANGRYsearch then quickly filters filenames as you type your query.
|
||||
|
||||
Even though there is not much to ANGRYsearch, there are several things you can do to customize the experience. First, ANGRYsearch has two different display modes: lite and full. Lite mode only shows the filename and path. Full mode displays filename, path, size, and date of the last modification. Full mode, obviously, takes longer to display. The default is lite mode. In order to switch to full mode, you need to edit the config file at `~/.config/angrysearch/angrysearch.conf`. In that file change the `angrysearch_lite` value to false.
|
||||
|
||||
ANGRYsearch also has three different search modes: fast, slow, and regex. Fast mode displays filenames that start with your search term. For example, if you had a folder full of the latest releases of a bunch of Linux distros and you searched “Ubuntu”, ANGRYsearch would display Ubuntu, Ubuntu Mate, Ubuntu Budgie, but not Kubuntu, Xubuntu, or Lubuntu. Fast mode is on by default and can be turned off by unchecking the checkbox next to the “update” button. Slow mode is slightly slower (obviously), but it will display files that have your search term anywhere in their name. In the previous example, ANGRYsearch would show all Ubuntu distros. Regex mode is the slowest and most precise. It uses [regular expressions][4] and is case insensitive. Regex mode is activated by pressing F8.
|
||||
|
||||
You can also tell ANGRYsearch to ignore certain folders when it indexes your system. Just click the “update” button and enter the names of the folders you want to be ignored in the space provided. You can also choose from several icon themes, though it doesn’t make that much difference.
|
||||
|
||||
![][5]Fast mode results
|
||||
|
||||
### Installing ANGRYsearch on Linux
|
||||
|
||||
ANGRYsearch is available in the [Arch User Repository][6]. It has also been packaged for [Fedora and openSUSE][7].
|
||||
|
||||
To install on other distros, follow these instructions. Instructions are written for a Debian or Ubuntu based system.
|
||||
|
||||
ANGRYsearch depends on `python3-pyqt5` and`xdg-utils` so you will need to install them first. Most distros have `xdg-utils`already installed.
|
||||
|
||||
`sudo apt install python3-pyqt5`
|
||||
|
||||
Next. download the latest version (1.0.1).
|
||||
|
||||
`wget https://github.com/DoTheEvo/ANGRYsearch/archive/v1.0.1.zip`
|
||||
|
||||
Now, unzip the archive file.
|
||||
|
||||
`unzip v1.0.1.zip`
|
||||
|
||||
Next, we will navigate to the new folder (ANGRYsearch-1.0.1) and run the installer.
|
||||
|
||||
`cd ANGRYsearch-1.0.1`
|
||||
|
||||
`chmod +x install.sh`
|
||||
|
||||
`sudo ./install.sh`
|
||||
|
||||
The installation process is very quick, so don’t be surprised when a new command line is displayed as soon as you hit `Enter`.
|
||||
|
||||
The first time that you start ANGRYsearch, you will need to index your system. ANGRYsearch does not automatically keep its database updated. You can use `crontab` to schedule a system scan.
|
||||
|
||||
To open a text editor to create a new cronjob, use `crontab -e`. To make sure that the ANGRYsearch database is updated every 6 hours, use this command `0 */6 选题模板.txt 中文排版指北.md core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LCTT翻译规范.md LICENSE published README.md scripts sources translated 选题模板.txt 中文排版指北.md core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LCTT翻译规范.md LICENSE published README.md scripts sources translated 选题模板.txt 中文排版指北.md core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LCTT翻译规范.md LICENSE published README.md scripts sources translated /usr/share/angrysearch/angrysearch_update_database.py`. `crontab` does not run the job if it is powered off when the timer does off. In some case, you may need to manually update the database, but it should not take long.
|
||||
|
||||
![][8]ANGRYsearch update/options menu
|
||||
|
||||
### Experience
|
||||
|
||||
In the past, I was always frustrated by how painfully slow it was to search my computer. I knew that Windows had the Everything app, but I thought Linux out of luck. It didn’t even occur to me to look for something similar on Linux. I’m glad I accidentally stumbled upon ANGRYsearch.
|
||||
|
||||
I know there will be quite a few people complaining that ANGRYsearch only searches filenames, but most of the time that is all I need. Thankfully, most of the time I only need to remember part of the name to find what I am looking for.
|
||||
|
||||
The only thing that annoys me about ANGRYsearch is that fact that it does not automatically update its database. You’d think there would be a way for the installer to create a cron job when you install it.
|
||||
|
||||
![][9]Slow mode results
|
||||
|
||||
### Final Thoughts
|
||||
|
||||
Since ANGRYsearch is basically a Linux port of one of my favorite Windows apps, I’m pretty happy with it. I plan to install it on all my systems going forward.
|
||||
|
||||
I know that I have ragged on other Linux apps for not being packaged for easy install, but I can’t do the same for ANGRYsearch. The installation process is pretty easy. I would definitely recommend it for Linux noobs.
|
||||
|
||||
Have you ever used [ANGRYsearch][2]? If not, what is your favorite Linux search application? Let us know in the comments below.
|
||||
|
||||
If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][10].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/angrysearch/
|
||||
|
||||
作者:[John Paul][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/john/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/11/angrysearch3.jpg?resize=800%2C627&ssl=1
|
||||
[2]: https://github.com/dotheevo/angrysearch/
|
||||
[3]: https://www.voidtools.com/
|
||||
[4]: http://www.aivosto.com/articles/regex.html
|
||||
[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/11/angrysearch1.jpg?resize=800%2C627&ssl=1
|
||||
[6]: https://aur.archlinux.org/packages/angrysearch/
|
||||
[7]: https://software.opensuse.org/package/angrysearch
|
||||
[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/11/angrysearch2.jpg?resize=800%2C626&ssl=1
|
||||
[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/11/angrysearch4.jpg?resize=800%2C627&ssl=1
|
||||
[10]: http://reddit.com/r/linuxusersgroup
|
@ -0,0 +1,86 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (How to bring good fortune to your Linux terminal)
|
||||
[#]: via: (https://opensource.com/article/18/12/linux-toy-fortune)
|
||||
[#]: author: (Jason Baker https://opensource.com/users/jason-baker)
|
||||
[#]: url: ( )
|
||||
|
||||
How to bring good fortune to your Linux terminal
|
||||
======
|
||||
Bring quotes and quips to the command line with the fortune utility.
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-fortune.png?itok=5PVVZVer)
|
||||
|
||||
It's December, and if you haven't found a [tech advent calendar][1] that sparks your fancy yet, well, maybe this one will do the trick. Every day, from now to the 24th, we're bringing you a different Linux command-line toy. What's a command-line toy, you ask? It could be a game or any simple diversion to bring a little happiness to your terminal.
|
||||
|
||||
You may have seen some of these before. We hope you'll find something new, too. Either way, we hope you have fun following along.
|
||||
|
||||
Today's toy, **fortune** , is an old one. Versions of it date back to the 1980s when it was included with Unix. The version I installed in Fedora was available under a BSD license, and I grabbed it with the following.
|
||||
|
||||
```
|
||||
$ sudo dnf install fortune-mod -y
|
||||
```
|
||||
|
||||
Your distribution may be different. On some, you may need to install the fortunes separately from **fortune** itself (try searching your package manager for "fortunes*"). You can also check out the source code on [GitHub][2]. Then, just run **fortune** to get, well, a fortune.
|
||||
|
||||
```
|
||||
$ fortune
|
||||
"Time is an illusion. Lunchtime doubly so."
|
||||
-- Ford Prefect, _Hitchhiker's Guide to the Galaxy_
|
||||
```
|
||||
|
||||
So why do you need fortunes at the terminal? For fun, of course. Perhaps you'd like to add them to the message of the day on your system?
|
||||
|
||||
Personally, I like using the **fortune** command as a built-in piece of dummy data when I'm using the terminal to parse text, particularly with [regular expressions][3], and want something simple to try it out on.
|
||||
|
||||
For example, let's say I was testing our a transformation with the **tr** command to replace letter the letter e with a numeral 3.
|
||||
|
||||
```
|
||||
$ fortune | tr 'eE' '3'
|
||||
Unix 3xpr3ss:
|
||||
All pass3ng3r bring a pi3c3 of th3 a3roplan3 and a box of tools with th3m to
|
||||
th3 airport. Th3y gath3r on th3 tarmac, arguing constantly about what kind
|
||||
of plan3 th3y want to build and how to put it tog3th3r. 3v3ntually, th3
|
||||
pass3ng3rs split into groups and build s3v3ral diff3r3nt aircraft, but giv3
|
||||
th3m all th3 sam3 nam3. Som3 pass3ng3rs actually r3ach th3ir d3stinations.
|
||||
All pass3ng3rs b3li3v3 th3y got th3r3.
|
||||
```
|
||||
|
||||
So what fortunes come with your distribution? Take a look in your **/usr/share/games/fortune** directory to find them all. Here are a few of my favorites.
|
||||
|
||||
```
|
||||
Never laugh at live dragons.
|
||||
-- Bilbo Baggins [J.R.R. Tolkien, "The Hobbit"]
|
||||
|
||||
I dunno, I dream in Perl sometimes...
|
||||
-- Larry Wall in <8538@jpl-devvax.JPL.NASA.GOV>
|
||||
|
||||
I have an existential map. It has "You are here" written all over it.
|
||||
-- Steven Wright
|
||||
```
|
||||
|
||||
Looking for more on **fortune**? You can, of course, always check out the man page to learn more about the options, or read a little bit more about the history of the command on [Wikipedia][4].
|
||||
|
||||
Do you have a favorite command-line toy that you think I ought to profile? The calendar for this series is mostly filled out but I've got a few spots left. Let me know in the comments below, and I'll check it out. If there's space, I'll try to include it. If not, but I get some good submissions, I'll do a round-up of honorable mentions at the end.
|
||||
|
||||
Check out yesterday's toy, [Drive a locomotive through your Linux terminal][5], and check back tomorrow for another!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/12/linux-toy-fortune
|
||||
|
||||
作者:[Jason Baker][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/jason-baker
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/article/16/11/7-tech-advent-calendars-holiday-season
|
||||
[2]: https://github.com/shlomif/fortune-mod
|
||||
[3]: https://opensource.com/article/18/5/getting-started-regular-expressions
|
||||
[4]: https://en.wikipedia.org/wiki/Fortune_%28Unix%29
|
||||
[5]: https://opensource.com/article/18/12/linux-toy-sl
|
@ -0,0 +1,222 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (Bash Variables: Environmental and Otherwise)
|
||||
[#]: via: (https://www.linux.com/blog/learn/2018/12/bash-variables-environmental-and-otherwise)
|
||||
[#]: author: (Paul Brown https://www.linux.com/users/bro66)
|
||||
[#]: url: ( )
|
||||
|
||||
Bash Variables: Environmental and Otherwise
|
||||
======
|
||||
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/wynand-van-poortvliet-40467-unsplash.jpg?itok=tr6Eb4N0)
|
||||
|
||||
Bash variables, including those pesky _environment variables_ , have been popped up several times in previous articles, and it’s high time you get to know them better and how they can help you.
|
||||
|
||||
So, open your terminal window and let's get started.
|
||||
|
||||
### Environment Variables
|
||||
|
||||
Consider `HOME`. Apart from the cozy place where you lay down your hat, in Linux it is a variable that contains the path to the current user's home directory. Try this:
|
||||
|
||||
```
|
||||
echo $HOME
|
||||
```
|
||||
|
||||
This will show the path to your home directory, usually _/home/_.
|
||||
|
||||
As the name indicates, variables can change according to the context. Indeed, each user on a Linux system will have a `HOME` variable containing a different value. You can also change the value of a variable by hand:
|
||||
|
||||
```
|
||||
HOME=/home/<your username>/Documents
|
||||
```
|
||||
|
||||
will make `HOME` point to your _Documents/_ folder.
|
||||
|
||||
There are three things to notice here:
|
||||
|
||||
1. There are no spaces between the name of the variable and the `=` or between the `=` and the value you are putting into the variable. Spaces have their own meaning in the shell and cannot be used any old way you want.
|
||||
2. If you want to put a value into a variable or manipulate it in any way, you just have to write the name of the variable. If you want to see or use the contents of a variable, you put a `$` in front of it.
|
||||
3. Changing `HOME` is risky! A lot programs rely on `HOME` to do stuff and changing it can have unforeseeable consequences. For example, just for laughs, change `HOME` as shown above and try typing `cd` and then [Enter]. As we have seen elsewhere in this series, you use `cd` to _c_ hange to another _d_ irectory. Without any parameters, `cd` takes you to your home directory. If you change the `HOME` variable, `cd` will take you to the new directory `HOME` points to.
|
||||
|
||||
|
||||
|
||||
Changes to environment variables like the one described in point 3 above are not permanent. If you close your terminal and open it back up, or even open a new tab in your terminal window and move there, `echo $HOME` will show its original value.
|
||||
|
||||
Before we go on to how you make changes permanent, let's look at another environment variable that it does make sense changing.
|
||||
|
||||
### PATH
|
||||
|
||||
The `PATH` variable lists directories that contain executable programs. If you ever wondered where your applications go when they are installed and how come the shell seems to magically know which programs it can run without you having to tell it where to look for them, `PATH` is the reason.
|
||||
|
||||
Have a look inside `PATH` and you will see something like this:
|
||||
|
||||
```
|
||||
$ echo $PATH
|
||||
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
|
||||
```
|
||||
|
||||
Each directory is separated by a colon (`:`) and if you want to run an application installed in any directory other than the ones listed in `PATH`, you will have to tell the shell where to find it:
|
||||
|
||||
```
|
||||
/home/<user name>/bin/my_program.sh
|
||||
```
|
||||
|
||||
This will run a program calle _my_program.sh_ you have copied into a _bin/_ directory in your home directory.
|
||||
|
||||
This is a common problem: you don't want to clutter up your system's _bin/_ directories, or you don't want other users running your own personal scripts, but you don't want to have to type out the complete path every time you need to run a script you use often. The solution is to create your own _bin/_ directory in your home directory:
|
||||
|
||||
```
|
||||
mkdir $HOME/bin
|
||||
```
|
||||
|
||||
And then tell `PATH` all about it:
|
||||
|
||||
```
|
||||
PATH=$PATH:$HOME/bin
|
||||
```
|
||||
|
||||
After that, your _/home//bin_ will show up in your `PATH` variable. But... Wait! We said that the changes you make in a given shell will not last and will lose effect when that shell is closed.
|
||||
|
||||
To make changes permanent for your user, instead of running them directly in the shell, put them into a file that gets run every time a shell is started. That file already exists and lives in your home directory. It is called _.bashrc_ and the dot in front of the name makes it a hidden file -- a regular `ls` won't show it, but `ls -a` will.
|
||||
|
||||
You can open it with a text editor like [kate][1], [gedit][2], [nano][3], or [vim][4] (NOT LibreOffice Writer -- that's a word processor. Different beast entirely). You will see that _.bashrc_ is full of shell commands the purpose of which are to set up the environment for your user.
|
||||
|
||||
Scroll to the bottom and add the following on a new, empty line:
|
||||
|
||||
```
|
||||
export PATH=$PATH:$HOME/bin
|
||||
```
|
||||
|
||||
Save and close the file. You'll be seeing what `export` does presently. In the meantime, to make sure the changes take effect immediately, you need to `source` _.bashrc_ :
|
||||
|
||||
```
|
||||
source .bashrc
|
||||
```
|
||||
|
||||
What `source` does is execute _.bashrc_ for the current open shell, and all the ones that come after it. The alternative would be to log out and log back in again for the changes to take effect, and who has the time for that?
|
||||
|
||||
From now on, your shell will find every program you dump in _/home//bin_ without you having to specify the whole path to the file.
|
||||
|
||||
### DYI Variables
|
||||
|
||||
You can, of course, make your own variables. All the ones we have seen have been written with ALL CAPS, but [you can call a variable more or less whatever you want][5].
|
||||
|
||||
Creating a new variables is straightforward: just set a value within it:
|
||||
|
||||
```
|
||||
new_variable="Hello"
|
||||
```
|
||||
|
||||
And you already know how to recover a value contained within a variable:
|
||||
|
||||
```
|
||||
echo $new_variable
|
||||
```
|
||||
|
||||
You often have a program that will require you set up a variable for things to work properly. The variable may set an option to "on", or help the program find a library it needs, and so on. When you run a program in Bash, the shell spawns a daughter process. This means it is not exactly the same shell that executes your program, but a related mini-shell that inherits some of the mother's characteristics. Unfortunately, variables, by default, are not one of them. This is because, by default again, variables are _local_. This means that, for security reasons, a variable set in one shell cannot be read in another, even if it is a daughter shell.
|
||||
|
||||
To see what I mean, set a variable:
|
||||
|
||||
```
|
||||
robots="R2D2 & C3PO"
|
||||
```
|
||||
|
||||
... and run:
|
||||
|
||||
```
|
||||
bash
|
||||
```
|
||||
|
||||
You just ran a Bash shell program within a Bash shell program.
|
||||
|
||||
Now see if you can read the contents of you variable with:
|
||||
|
||||
```
|
||||
echo $robots
|
||||
```
|
||||
|
||||
You should draw a blank.
|
||||
|
||||
Still inside your bash-within-bash shell, set `robots` to something different:
|
||||
|
||||
```
|
||||
robots="These aren't the ones you are looking for"
|
||||
```
|
||||
|
||||
Check `robots`' value:
|
||||
|
||||
```
|
||||
$ echo $robots
|
||||
These aren't the ones you are looking for
|
||||
```
|
||||
|
||||
Exit the bash-within-bash shell:
|
||||
|
||||
```
|
||||
exit
|
||||
```
|
||||
|
||||
And re-check the value of `robots`:
|
||||
|
||||
```
|
||||
$ echo $robots
|
||||
R2D2 & C3P0
|
||||
```
|
||||
|
||||
This is very useful to avoid all sorts of messed up configurations, but this presents a problem also: if a program requires you set up a variable, but the program can't access it because Bash will execute it in a daughter process, what can you do? That is exactly what `export` is for.
|
||||
|
||||
Try doing the prior experiment, but, instead of just starting off by setting `robots="R2D2 & C3PO"`, export it at the same time:
|
||||
|
||||
```
|
||||
export robots="R2D2 & C3PO"
|
||||
```
|
||||
|
||||
You'll notice that, when you enter the bash-within-bash shell, `robots` still retains the same value it had at the outset.
|
||||
|
||||
**Interesting fact:** While the daughter process will "inherit" the value of an exported variable, if the variable is changed within the daughter process, changes will not flow upwards to the mother process. In other words, changing the value of an exported variable in a daughter process does not change the value of the original variable in the mother process.
|
||||
|
||||
You can see all exported variables by running
|
||||
|
||||
```
|
||||
export -p
|
||||
```
|
||||
|
||||
The variables you create should be at the end of the list. You will also notice some other interesting variables in the list: `USER`, for example, contains the current user's user name; `PWD` points to the current directory; and `OLDPWD` contains the path to the last directory you visited and since left. That's because, if you run:
|
||||
|
||||
```
|
||||
cd -
|
||||
```
|
||||
|
||||
You will go back to the last directory you visited and `cd` gets the information from `OLDPWD`.
|
||||
|
||||
You can also see all the environment variables using the `env` command.
|
||||
|
||||
To un-export a variable, use the `-n` option:
|
||||
|
||||
```
|
||||
export -n robots
|
||||
```
|
||||
|
||||
### Next Time
|
||||
|
||||
You have now reached a level in which you are dangerous to yourself and others. It is time you learned how to protect yourself from yourself by making your environment safer and friendlier through the use of _aliases,_ and that is exactly what we'll be tackling in the next episode. See you then.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linux.com/blog/learn/2018/12/bash-variables-environmental-and-otherwise
|
||||
|
||||
作者:[Paul Brown][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/users/bro66
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.kde.org/applications/utilities/kate/
|
||||
[2]: https://help.gnome.org/users/gedit/stable/
|
||||
[3]: https://www.nano-editor.org/
|
||||
[4]: https://www.vim.org/
|
||||
[5]: https://bash.cyberciti.biz/guide/Rules_for_Naming_variable_name
|
@ -0,0 +1,60 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (Bring some color to your Linux terminal with lolcat)
|
||||
[#]: via: (https://opensource.com/article/18/12/linux-toy-lolcat)
|
||||
[#]: author: (Jason Baker https://opensource.com/users/jason-baker)
|
||||
[#]: url: ( )
|
||||
|
||||
Bring some color to your Linux terminal with lolcat
|
||||
======
|
||||
With this simple utility, you can add a rainbow of color to the output of any program you want.
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-lolcat.png?itok=Es6dYcph)
|
||||
|
||||
Today marks the fifth day of the Linux command-line toys advent calendar. If this is your first visit to the series, you might be asking yourself, what’s a command-line toy. Even I'm not quite sure, but generally, it could be a game, or any simple diversion that helps you have fun at the terminal.
|
||||
|
||||
It's quite possible that some of you will have seen various selections from our calendar before, but we hope there’s at least one new thing for everyone.
|
||||
|
||||
Today's selection, **lolcat** , is the first utility I'm including that wasn't packaged for my Linux distribution, but it was still an easy install. It's a Ruby program that you ought to be able to easily add to your system with the following.
|
||||
|
||||
```
|
||||
$ gem install lolcat
|
||||
```
|
||||
|
||||
After that, simply pipe some text to it to see the output in the colors of the rainbow. For example, using a couple of utilities from earlier days in our advent calendar, try the following:
|
||||
|
||||
```
|
||||
$ fortune | boxes -a c -d parchment | lolcat
|
||||
```
|
||||
|
||||
Depending on what good fortune you have, you'll likely get something like this:
|
||||
![](https://opensource.com/sites/default/files/uploads/linux-toy-lolcat-parchment.png)
|
||||
|
||||
There are a few parameters you can pass to **lolcat** , and rather than repeat them all here, I'd suggest you either visit the **lolcat** [GitHub page][1] or just see them at the terminal by typing **lolcat --help**. But generally, they're helpful to set the spread and frequency of your rainbow, and my personal favorite, enabling animation. Who doesn't like animated rainbow printing at the terminal? Let's try the above again, with a different box (cat-themed, of course) and a cat-appropriate fortune that was in my fortunes list, with the following.
|
||||
|
||||
```
|
||||
fortune -m "nine tails" | boxes -a c -d cat | lolcat -a
|
||||
```
|
||||
![](https://opensource.com/sites/default/files/uploads/linux-toy-lolcat-animated.gif)
|
||||
**lolcat** is open source under a BSD license.
|
||||
|
||||
Do you have a favorite command-line toy that you think I ought to profile? The calendar for this series is mostly filled out but I've got a few spots left. Let me know in the comments below, and I'll check it out. If there's space, I'll try to include it. If not, but I get some good submissions, I'll do a round-up of honorable mentions at the end.
|
||||
|
||||
Check out yesterday's toy, [Have a cow at the Linux command line][2], and check back tomorrow for another!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/12/linux-toy-lolcat
|
||||
|
||||
作者:[Jason Baker][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/jason-baker
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://github.com/busyloop/lolcat
|
||||
[2]: https://opensource.com/article/18/12/linux-toy-cowsay
|
@ -0,0 +1,78 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (How To Fix Broken Ubuntu OS Without Reinstalling It)
|
||||
[#]: via: (https://www.ostechnix.com/how-to-fix-broken-ubuntu-os-without-reinstalling-it/)
|
||||
[#]: author: (SK https://www.ostechnix.com/author/sk/)
|
||||
[#]: url: ( )
|
||||
|
||||
How To Fix Broken Ubuntu OS Without Reinstalling It
|
||||
======
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/12/Fix-Broken-Ubuntu-OS-720x340.jpg)
|
||||
|
||||
Today, I was upgrading my Ubuntu 18.04 LTS system. Unfortunately, the power has gone in mid-way and the system powered off while updating Ubuntu OS. When the power is back, I boot the system again. Right after entering the password at the login screen, it’s gone blank and didn’t respond. Keyboard and mouse also didn’t work. All I see is just a blank screen! Thankfully, It’s just a test machine and there were no important data in it. I can simply wipe off the entire OS and install it again. But, I don’t want to do that. Since I have nothing to lose, I just wanted to repair my broken Ubuntu system without reinstalling it completely and it worked!!! If you ever find yourself in a situation like mine, don’t panic. This brief tutorial describes how to easily fix broken Ubuntu OS without losing data and without reinstalling it completely.
|
||||
|
||||
### Fix Broken Ubuntu OS
|
||||
|
||||
First of all, try to login with live cd and **backup your data** in an external drive. Just in case, if this method didn’t work, you can still have your data and reinstall everything!
|
||||
|
||||
At the login screen, press **CTRL+ALT+F1** to switch to **tty1**. You can learn more about switching between TTYs [**here**][1].
|
||||
|
||||
Now, type the following commands one by one to fix the broken Ubuntu Linux.
|
||||
|
||||
```
|
||||
$ sudo rm /var/lib/apt/lists/lock
|
||||
|
||||
$ sudo rm /var/lib/dpkg/lock
|
||||
|
||||
$ sudo rm /var/lib/dpkg/lock-frontend
|
||||
|
||||
$ sudo dpkg --configure -a
|
||||
|
||||
$ sudo apt clean
|
||||
|
||||
$ sudo apt update --fix-missing
|
||||
|
||||
$ sudo apt install -f
|
||||
|
||||
$ sudo dpkg --configure -a
|
||||
|
||||
$ sudo apt upgrade
|
||||
|
||||
$ sudo apt dist-upgrade
|
||||
```
|
||||
|
||||
Finally, reboot the system using command:
|
||||
|
||||
```
|
||||
$ sudo reboot
|
||||
```
|
||||
|
||||
You can now be able to login to your Ubuntu system as usual.
|
||||
|
||||
After I followed these steps, all of my data in Ubuntu 18.04 test system was there and everything is the same as I left it. This method may not work for everyone. However, this small tip worked for me and saved a couple minutes from reinstalling. If you know any other better way, please let me know in the comment section. I will add them in this guide as well.
|
||||
|
||||
And, that’s all for now. Hope this was useful.
|
||||
|
||||
More good stuffs to come. Stay tuned!
|
||||
|
||||
Cheers!
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/how-to-fix-broken-ubuntu-os-without-reinstalling-it/
|
||||
|
||||
作者:[SK][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.ostechnix.com/author/sk/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.ostechnix.com/how-to-switch-between-ttys-without-using-function-keys-in-linux/
|
@ -0,0 +1,106 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How To Boot Into Rescue Mode Or Emergency Mode In Ubuntu 18.04)
|
||||
[#]: via: (https://www.ostechnix.com/how-to-boot-into-rescue-mode-or-emergency-mode-in-ubuntu-18-04/)
|
||||
[#]: author: (SK https://www.ostechnix.com/author/sk/)
|
||||
|
||||
How To Boot Into Rescue Mode Or Emergency Mode In Ubuntu 18.04
|
||||
======
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/12/Boot-Into-Rescue-Mode-Or-Emergency-Mode-720x340.png)
|
||||
|
||||
As you might already know, **Runlevels** are replaced with **Systemd targets** in many recent Linux distributions like RHEL 7 and Ubuntu 16.04 LTS. For more details about runlevels and systemd target, refer [**this guide**][1]. In this brief tutorial, we are going to see how to boot into **rescue mode** and/or **emergency mode**. This guide is tested in Ubuntu 18.04 LTS, however the steps given below would work on most Linux distributions that uses Systemd as default service manager. Before going further, let me clarify what is rescue mode and emergency mode and what is the purpose of the both modes.
|
||||
|
||||
### What is Rescue mode?
|
||||
|
||||
The **rescue mode** is equivalent to **single user mode** in Linux distributions that uses **SysV** as the default service manager. In rescue mode, all local filesystems will be mounted, only some important services will be started. However, no normal services (E.g network services) won’t be started. The rescue mode is helpful in situations where the system can’t boot normally. Also, we can perform some important rescue operations, such as [**reset root password**][2], in rescue mode.
|
||||
|
||||
### What is Emergency mode?
|
||||
|
||||
In contrast to the rescue mode, nothing is started in the **emergency mode**. No services are started, no mount points mounted, no sockets established, nothing. All you will have is just a **raw shell**. Emergency mode is suitable for debugging purposes.
|
||||
|
||||
### Boot Into Rescue Mode In Ubuntu 18.04 LTS
|
||||
|
||||
Boot your Ubuntu system. When Grub menu appears, choose the first entry and press **e** to edit.
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/12/Grub-menu.png)
|
||||
|
||||
If you don’t see the Grub menu, just hit ESC key right after the BIOS logo disappears.
|
||||
|
||||
Find the line that starts with word **“linux”** and add the following line at the end of that line (To reach the end, just press **CTRL+e** or use END key or LEFT/RIGHT arrows in your keyboard):
|
||||
|
||||
```
|
||||
systemd.unit=rescue.target
|
||||
```
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/12/Edit-grub-menu.png)
|
||||
|
||||
Once you added the above line, just press **CTRL+x** or **F10** to continue to boot into rescue mode. After a few seconds, you will be ended up in the rescue mode (single user mode) as root user. Here is how rescue mode looks like in Ubuntu 18.04 LTS server:
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/12/Ubuntu-rescue-mode.png)
|
||||
|
||||
Next, type the following command to mount root (/) file system into read/write mode.
|
||||
|
||||
```
|
||||
mount -n -o remount,rw /
|
||||
```
|
||||
|
||||
### Boot Into Emergency Mode
|
||||
|
||||
Booting your Ubuntu into emergency is as same as above method. All you have to do is replace “systemd.unit=rescue.target” with “systemd.unit=emergency.target” when editing grub menu.
|
||||
|
||||
[![emergency mode][3]][4]
|
||||
|
||||
Once you added “systemd.unit=emergency.target”, press **Ctrl+x** or **F10** to continue booting into emergency mode.
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/12/emergency-mode-1.png)
|
||||
|
||||
Finally, you can mount root filesystem into read/write mode with command:
|
||||
|
||||
```
|
||||
mount -n -o remount,rw /
|
||||
```
|
||||
|
||||
### Switch between Rescue to Emergency mode and vice versa
|
||||
|
||||
If you are in rescue mode, you don’t have to edit the grub boot entry as I mentioned above. Instead, just type the following command to switch to emergency mode instantly:
|
||||
|
||||
```
|
||||
systemctl emergency
|
||||
```
|
||||
|
||||
Similarly, to switch from emergency to rescue mode, type:
|
||||
|
||||
```
|
||||
systemctl rescue
|
||||
```
|
||||
|
||||
You know now what is rescue and emergency modes and how to boot into those modes in Ubuntu 18.04. Like I already mentioned, the steps provided here will work on many recent Linux versions that uses Systemd.
|
||||
|
||||
And, that’s all for now. Hope this was useful.
|
||||
|
||||
More good stuffs to come. Stay tuned!
|
||||
|
||||
Cheers!
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/how-to-boot-into-rescue-mode-or-emergency-mode-in-ubuntu-18-04/
|
||||
|
||||
作者:[SK][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.ostechnix.com/author/sk/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.ostechnix.com/check-runlevel-linux/
|
||||
[2]: https://www.ostechnix.com/how-to-reset-or-recover-root-user-password-in-linux/
|
||||
[3]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
|
||||
[4]: http://www.ostechnix.com/wp-content/uploads/2018/12/emergency-mode.png
|
109
sources/tech/20181206 How to view XML files in a web browser.md
Normal file
109
sources/tech/20181206 How to view XML files in a web browser.md
Normal file
@ -0,0 +1,109 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to view XML files in a web browser)
|
||||
[#]: via: (https://opensource.com/article/18/12/xml-browser)
|
||||
[#]: author: (Greg Pittman https://opensource.com/users/greg-p)
|
||||
|
||||
How to view XML files in a web browser
|
||||
======
|
||||
Turn XML files into something more useful.
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web_browser_desktop_devlopment_design_system_computer.jpg?itok=pfqRrJgh)
|
||||
|
||||
Once you learn that HTML is a form of XML, you might wonder what would happen if you tried to view an XML file in a browser. The results are quite disappointing—Firefox shows you a banner at the top of the page that says, "This XML file does not appear to have any style information associated with it. The document tree is shown below." The document tree looks like the file would look in an editor:
|
||||
![](https://opensource.com/sites/default/files/uploads/xml_menu.png)
|
||||
This is the beginning of the **menu.xml** file for the online manual that comes with [Scribus][1], to which I'm a contributor. Although you see blue text, they are not clickable links. I wanted to be able to view this in a regular browser, since sometimes I need to go back and forth from the canvas in Scribus to the manual to figure out how to do something (maybe to see if I need to edit the manual to straighten out some misinformation or to add some missing information).
|
||||
|
||||
The way to help a browser know what to do with these XML tags is by using XSLT—Extensible Stylesheet Language Transformations. In a broad sense, you could use XSLT to transform XML to a variety of outputs, or even HTML to XML. Here I want to use it to present the XML tags to a browser as suitable HTML.
|
||||
|
||||
One slight modification needs to happen to the XML file:
|
||||
|
||||
![](https://opensource.com/sites/default/files/uploads/xml_modified-menu.png)
|
||||
|
||||
Adding this second line to the file tells the browser to look for a file named **scribus-manual.xsl** for the style information. The more important part is to create this XSL file. Here is the complete listing of **scribus-manual.xsl** for the Scribus manual:
|
||||
|
||||
```
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:template match="/">
|
||||
<html>
|
||||
<title>Scribus Online Manual</title>
|
||||
<style type="text/css">
|
||||
h2,h3,h4 { text-indent: 50px;}
|
||||
ul { margin-left: 100px;}
|
||||
</style>
|
||||
<table border="0" cellspacing="0" cellpadding="0" width="100%"
|
||||
bgcolor="#183867" >
|
||||
<tr>
|
||||
<td align="left"><img src="images/docheader1.png" width="222"
|
||||
height="87"/></td>
|
||||
<td align="right"><img src="images/docheader2.png" width="318"
|
||||
height="87"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<body bgcolor="#ffffff">
|
||||
|
||||
<xsl:for-each select="menu">
|
||||
<xsl:for-each select="area">
|
||||
<h3><a href="{@file}" ><xsl:value-of select = "@text" /></a></h3>
|
||||
<xsl:for-each select="submenuitem">
|
||||
<h4><a href="{@file}" ><xsl:value-of select = "@text" /></a></h4>
|
||||
<xsl:for-each select="submenuitem">
|
||||
<p><ul>
|
||||
<li><a href="{@file}" ><xsl:value-of select = "@text" /></a></li>
|
||||
</ul></p>
|
||||
</xsl:for-each>
|
||||
</xsl:for-each>
|
||||
<xsl:for-each select="area">
|
||||
<h3><a href="{@file}" ><xsl:value-of select = "@text" /></a></h3>
|
||||
</xsl:for-each>
|
||||
</xsl:for-each>
|
||||
</xsl:for-each>
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
```
|
||||
|
||||
This looks a lot more like HTML, and you can see it contains a number of HTML tags. After some preliminary tags and some particulars about displaying H2, H3, and H4 tags, you see a Table tag. This adds a graphical heading at the top of the page and uses some images already in the documentation files.
|
||||
|
||||
After this, you get into the process of dissecting the various **submenuitem** tags, trying to create the nested listing structure as it appears in Scribus when you view the manual. One feature I did not try to duplicate is the ability to collapse and expand **submenuitem** areas. As you can imagine, it takes some time to sort through the number of nested lists you need to create, but when I finished, here is how it looked:
|
||||
|
||||
![](https://opensource.com/sites/default/files/uploads/xml_scribusmenuinbrowser.png)
|
||||
|
||||
This minimal editing to **menu.xml** does not interfere with Scribus' ability to show the manual in its own browser. I put this modified **menu.xml** file and the **scribus-manual.xsl** in the English documentation folder for 1.5.x versions of Scribus, so anyone using these versions can simply point their browser to the **menu.xml** file and it should show up just like you see above.
|
||||
|
||||
A much bigger chore I took on a few years ago was to create a version of the ICD10 (International Classification of Diseases, version 10) when it came out. Many changes were made from the previous version (ICD9) to 10. These are important since these codes must be used for diagnostic purposes in medical practice. You can easily download XML files from the US [Centers for Medicare and Medicaid][2] website since it is public information, but—just as with the Scribus manual—these files are hard to use.
|
||||
|
||||
Here is the beginning of the tabular listing of diseases:
|
||||
|
||||
![](https://opensource.com/sites/default/files/uploads/xml_tabular_begin.png)
|
||||
|
||||
One of the features I created was the color coding used in the listing shown here:
|
||||
|
||||
![](https://opensource.com/sites/default/files/uploads/xml_tabular_body.png)
|
||||
|
||||
As with **menu.xml** , the only editing I did in this **Tabular.xml** file was to add **<?xml-stylesheet type="text/xsl" href="tabular.xsl"? >** as the second line of the file. I started this project with the 2014 version, and I was quite pleased to find that the original **tabular.xsl** stylesheet worked perfectly when the 2016 version came out, which is the last one I worked on. The** Tabular.xml** file is 8.4MB, quite large for a plaintext file. It takes a few seconds to load into a browser, but once it's loaded, navigation is fast.
|
||||
|
||||
While you may not often have to deal with an XML file in this way, if you do, I hope this article shows that your file can easily be turned into something much more usable.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/12/xml-browser
|
||||
|
||||
作者:[Greg Pittman][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/greg-p
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.scribus.net/
|
||||
[2]: https://www.cms.gov/
|
@ -0,0 +1,61 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (Take a break at the Linux command line with Nyan Cat)
|
||||
[#]: via: (https://opensource.com/article/18/12/linux-toy-nyancat)
|
||||
[#]: author: (Jason Baker https://opensource.com/users/jason-baker)
|
||||
[#]: url: ( )
|
||||
|
||||
Take a break at the Linux command line with Nyan Cat
|
||||
======
|
||||
Rainbows, Pop-Tarts, and cats in space: What more could you want at your terminal?
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-nyancat.png?itok=eg1aEmBw)
|
||||
|
||||
We're now on day six of the Linux command-line toys advent calendar, where we explore some of the fun, entertaining, and in some cases, utterly useless toys available for your Linux terminal. All are available under an open source license.
|
||||
|
||||
Will they all be unique? Yes. Will they all be unique to you? I don't know, but, chances are you'll find at least one new toy to play with by the time our advent calendar is done.
|
||||
|
||||
Today's selection is a continuation on the [theme][1] we started yesterday: cats and rainbows. Wait, there's more cat-related rainbow fun to be had at the Linux command line? You bet there is.
|
||||
|
||||
So let's make a throwback all the way to 2011's [Nyan Cat][2] with a command-line toy call, not surprisingly, **nyancat**. Did you miss the cultural phenomenon that was Nyan Cat? Watch the embed below, I'll wait.
|
||||
|
||||
<https://www.youtube.com/embed/QH2-TGUlwu4>
|
||||
|
||||
Now, let's recreate that amazing experience in your terminal. **Nyancat** is packaged for many distributions (Arch, Debian, Gentoo, Ubuntu, etc.) but not for mine (Fedora), but compiling from source was simple. In fact, I grabbed the source, built it, and launched it in one line:
|
||||
|
||||
```
|
||||
git clone https://github.com/klange/nyancat.git && cd nyancat && make && cd src && ./nyancat
|
||||
```
|
||||
|
||||
This launched straight into a **nyancat** experience complete with a counter of how long I had been enjoying the **nyancat** magic for.
|
||||
|
||||
![](https://opensource.com/sites/default/files/uploads/linux-toy-nyancat-animated.gif)
|
||||
|
||||
You can find the source for **nyancat** [on GitHub][3] under an [NCSA open source license][4].
|
||||
|
||||
The command-line version of Nyan Cat used to be [accessible by a public Telnet server][5] (or, for even more pun, with [netcat][6]) so that you didn't even have to install it, but sadly was shut down due to bandwidth limitations. Nevertheless, the [gallery][5] from the old Telnet server running Nyan Cat on a variety of old devices is well-worth checking out, and maybe you'd like to do the community a favor by launching your own public mirror and letting the author know so that they may share it with the public yet again?
|
||||
|
||||
Do you have a favorite command-line toy that you think I ought to profile? The calendar for this series is mostly filled out but I've got a few spots left. Let me know in the comments below, and I'll check it out. If there's space, I'll try to include it. If not, but I get some good submissions, I'll do a round-up of honorable mentions at the end.
|
||||
|
||||
Check out yesterday's toy, [Bring some color to your Linux terminal with lolcat][1], and check back tomorrow for another!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/12/linux-toy-nyancat
|
||||
|
||||
作者:[Jason Baker][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/jason-baker
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/article/18/12/linux-toy-lolcat
|
||||
[2]: https://en.wikipedia.org/wiki/Nyan_Cat
|
||||
[3]: https://github.com/klange/nyancat
|
||||
[4]: http://en.wikipedia.org/wiki/University_of_Illinois/NCSA_Open_Source_License
|
||||
[5]: http://nyancat.dakko.us/
|
||||
[6]: http://netcat.sourceforge.net/
|
@ -0,0 +1,177 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (5 Screen Recorders for the Linux Desktop)
|
||||
[#]: via: (https://www.linux.com/blog/intro-to-linux/2018/12/5-screen-recorders-linux-desktop)
|
||||
[#]: author: (Jack Wallen https://www.linux.com/users/jlwallen)
|
||||
|
||||
5 Screen Recorders for the Linux Desktop
|
||||
======
|
||||
|
||||
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/screen-record.png?itok=tKWx29k8)
|
||||
|
||||
There are so many reasons why you might need to record your Linux desktop. The two most important are for training and for support. If you are training users, a video recording of the desktop can go a long way to help them understand what you are trying to impart. Conversely, if you’re having trouble with one aspect of your Linux desktop, recording a video of the shenanigans could mean the difference between solving the problem and not. But what tools are available for the task? Fortunately, for every Linux user (regardless of desktop), there are options available. I want to highlight five of my favorite screen recorders for the Linux desktop. Among these five, you are certain to find one that perfectly meets your needs. I will only be focusing on those screen recorders that save as video. What video format you prefer may or may not dictate which tool you select.
|
||||
|
||||
And, without further ado, let’s get on with the list.
|
||||
|
||||
### Simple Screen Recorder
|
||||
|
||||
I’m starting out with my go-to screen recorder. I use [Simple Screen Recorder][1] on a daily basis, and it never lets me down. This particular take on the screen recorder is available for nearly every flavor of Linux and is, as the name implies, very simple to use. With Simple Screen Recorder you can select a single window, a portion of the screen, or the entire screen to record. One of the best features of Simple Screen Recorder is the ability to save profiles (Figure 1), which allows you to configure the input for a recording (including scaling, frame rate, width, height, left edge and top edge spacing, and more). By saving profiles, you can easily use a specific profile to meet a unique need, without having to go through the customization every time. This is handy for those who do a lot of screen recording, with different input variables for specific jobs.
|
||||
|
||||
![Simple Screen Recorder ][3]
|
||||
|
||||
Figure 1: Simple Screen Recorder input profile window.
|
||||
|
||||
[Used with permission][4]
|
||||
|
||||
Simple screen recorder also:
|
||||
|
||||
* Records audio input
|
||||
|
||||
* Allows you to pause and resume recording
|
||||
|
||||
* Offers a preview during recording
|
||||
|
||||
* Allows for the selection of video containers and codecs
|
||||
|
||||
* Adds timestamp to file name (optional)
|
||||
|
||||
* Includes hotkey recording and sound notifications
|
||||
|
||||
* Works well on slower machines
|
||||
|
||||
* And much more
|
||||
|
||||
|
||||
|
||||
|
||||
Simple Screen Recorder is one of the most reliable screen recording tools I have found for the Linux desktop. Simple Screen Recorder can be installed from the standard repositories on many desktops, or via easy to follow instructions on the [application download page][5].
|
||||
|
||||
### Gtk-recordmydesktop
|
||||
|
||||
The next entry, [gtk-recordmydesktop][6], doesn’t give you nearly the options found in Simple Screen Recorder, but it does offer a command line component (for those who prefer not working with a GUI). The simplicity that comes along with this tool also means you are limited to a specific video output format (.ogv). That doesn’t mean gtk-recordmydesktop isn’t without appeal. In fact, there are a few features that make this option in the genre fairly appealing. First and foremost, it’s very simple to use. Second, the record window automatically gets out of your way while you record (as opposed to Simple Screen Recorder, where you need to minimize the recording window when recording full screen). Another feature found in gtk-recordmydesktop is the ability to have the recording follow the mouse (Figure 2).
|
||||
|
||||
![gtk-recordmydesktop][8]
|
||||
|
||||
Figure 2: Some of the options for gtk-recordmydesktop.
|
||||
|
||||
[Used with permission][4]
|
||||
|
||||
Unfortunately, the follow the mouse feature doesn’t always work as expected, so chances are you’ll be using the tool without this interesting option. In fact, if you opt to go the gtk-recordmydesktop route, you should understand the GUI frontend isn’t nearly as reliable as is the command line version of the tool. From the command line, you could record a specific position of the screen like so:
|
||||
|
||||
```
|
||||
recordmydesktop -x X_POS -y Y_POS --width WIDTH --height HEIGHT -o FILENAME.ogv
|
||||
```
|
||||
|
||||
where:
|
||||
|
||||
* X_POS is the offset on the X axis
|
||||
|
||||
* Y_POS is the offset on the Y axis
|
||||
|
||||
* WIDTH is the width of the screen to be recorded
|
||||
|
||||
* HEIGHT is the height of the screen to be recorded
|
||||
|
||||
* FILENAME is the name of the file to be saved
|
||||
|
||||
|
||||
|
||||
|
||||
To find out more about the command line options, issue the command man recordmydesktop and read through the manual page.
|
||||
|
||||
### Kazam
|
||||
|
||||
If you’re looking for a bit more than just a recorded screencast, you might want to give Kazam a go. Not only can you record a standard screen video (with the usual—albeit limited amount of—bells and whistles), you can also take screenshots and even broadcast video to YouTube Live (Figure 3).
|
||||
|
||||
![Kazam][10]
|
||||
|
||||
Figure 3: Setting up YouTube Live broadcasting in Kazam.
|
||||
|
||||
[Used with permission][4]
|
||||
|
||||
Kazam falls in line with gtk-recordmydesktop, when it comes to features. In other words, it’s slightly limited in what it can do. However, that doesn’t mean you shouldn’t give Kazam a go. In fact, Kazam might be one of the best screen recorders out there for new Linux users, as this app is pretty much point and click all the way. But if you’re looking for serious bells and whistles, look away.
|
||||
|
||||
The version of Kazam, with broadcast goodness, can be found in the following repository:
|
||||
|
||||
```
|
||||
ppa:sylvain-pineau/kazam
|
||||
```
|
||||
|
||||
For Ubuntu (and Ubuntu-based distributions), install with the following commands:
|
||||
|
||||
```
|
||||
sudo apt-add-repository ppa:sylvain-pineau/kazam
|
||||
|
||||
sudo apt-get update
|
||||
|
||||
sudo apt-get install kazam -y
|
||||
```
|
||||
|
||||
### Vokoscreen
|
||||
|
||||
The [Vokoscreen][11] recording app is for new-ish users who need more options. Not only can you configure the output format and the video/audio codecs, you can also configure it to work with a webcam (Figure 4).
|
||||
|
||||
![Vokoscreen][13]
|
||||
|
||||
Figure 4: Configuring a web cam for a Vokoscreen screen recording.
|
||||
|
||||
[Used with permission][4]
|
||||
|
||||
As with most every screen recording tool, Vokoscreen allows you to specify what on your screen to record. You can record the full screen (even selecting which display on multi-display setups), window, or area. Vokoscreen also allows you to select a magnification level (200x200, 400x200, or 600x200). The magnification level makes for a great tool to highlight a specific section of the screen (the magnification window follows your mouse).
|
||||
|
||||
Like all the other tools, Vokoscreen can be installed from the standard repositories or cloned from its [GitHub repository][14].
|
||||
|
||||
### OBS Studio
|
||||
|
||||
For many, [OBS Studio][15] will be considered the mack daddy of all screen recording tools. Why? Because OBS Studio is as much a broadcasting tool as it is a desktop recording tool. With OBS Studio, you can broadcast to YouTube, Smashcast, Mixer.com, DailyMotion, Facebook Live, Restream.io, LiveEdu.tv, Twitter, and more. In fact, OBS Studio should seriously be considered the de facto standard for live broadcasting the Linux desktop.
|
||||
|
||||
Upon installation (the software is only officially supported for Ubuntu Linux 14.04 and newer), you will be asked to walk through an auto-configuration wizard, where you setup your streaming service (Figure 5). This is, of course, optional; however, if you’re using OBS Studio, chances are this is exactly why, so you won’t want to skip out on configuring your default stream.
|
||||
|
||||
![OBS Studio][17]
|
||||
|
||||
Figure 5: Configuring your streaming service for OBS Studio.
|
||||
|
||||
[Used with permission][4]
|
||||
|
||||
I will warn you: OBS Studio isn’t exactly for the faint of heart. Plan on spending a good amount of time getting the streaming service up and running and getting up to speed with the tool. But for anyone needing such a solution for the Linux desktop, OBS Studio is what you want. Oh … it can also record your desktop screencast and save it locally.
|
||||
|
||||
### There’s More Where That Came From
|
||||
|
||||
This is a short list of screen recording solutions for Linux. Although there are plenty more where this came from, you should be able to fill all your desktop recording needs with one of these five apps.
|
||||
|
||||
Learn more about Linux through the free ["Introduction to Linux" ][18]course from The Linux Foundation and edX.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linux.com/blog/intro-to-linux/2018/12/5-screen-recorders-linux-desktop
|
||||
|
||||
作者:[Jack Wallen][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/users/jlwallen
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: http://www.maartenbaert.be/simplescreenrecorder/
|
||||
[2]: /files/images/screenrecorder1jpg
|
||||
[3]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/screenrecorder_1.jpg?itok=hZJ5xugI (Simple Screen Recorder )
|
||||
[4]: /licenses/category/used-permission
|
||||
[5]: http://www.maartenbaert.be/simplescreenrecorder/#download
|
||||
[6]: http://recordmydesktop.sourceforge.net/about.php
|
||||
[7]: /files/images/screenrecorder2jpg
|
||||
[8]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/screenrecorder_2.jpg?itok=TEGXaVYI (gtk-recordmydesktop)
|
||||
[9]: /files/images/screenrecorder3jpg
|
||||
[10]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/screenrecorder_3.jpg?itok=cvtFjxen (Kazam)
|
||||
[11]: https://github.com/vkohaupt/vokoscreen
|
||||
[12]: /files/images/screenrecorder4jpg
|
||||
[13]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/screenrecorder_4.jpg?itok=c3KVS954 (Vokoscreen)
|
||||
[14]: https://github.com/vkohaupt/vokoscreen.git
|
||||
[15]: https://obsproject.com/
|
||||
[16]: /files/images/desktoprecorder5jpg
|
||||
[17]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/desktoprecorder_5.jpg?itok=xyM-dCa7 (OBS Studio)
|
||||
[18]: https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux
|
@ -0,0 +1,102 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Automatic continuous development and delivery of a hybrid mobile app)
|
||||
[#]: via: (https://opensource.com/article/18/12/hybrid-mobile-app-development)
|
||||
[#]: author: (Angelo Manganiello https://opensource.com/users/amanganiello90)
|
||||
|
||||
Automatic continuous development and delivery of a hybrid mobile app
|
||||
======
|
||||
Hybrid apps are a good middle ground between native and web apps.
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/idea_innovation_mobile_phone.png?itok=RqVtvxkd)
|
||||
|
||||
Offering a mobile app is essentially a business requirement for organizations today. One of the first steps in developing an app is to understand the different types—native, hybrid (or cross-platform), and web—so you can decide which one will best meet your needs.
|
||||
|
||||
### Native is better, right?
|
||||
|
||||
**Native apps** represent the vast majority of applications that people download every day. Native applications are developed specifically for an operating system. Thus, a native iOS application will not work on an Android system and vice versa. To develop a native app, you need to know two things:
|
||||
|
||||
1. How to develop in a specific programming language (e.g., Swift for Apple devices; Java for Android)
|
||||
2. The app will not work for other platforms
|
||||
|
||||
|
||||
|
||||
Even though native apps will work only on the platform they're developed for, they have several notable advantages over hybrid and web apps:
|
||||
|
||||
* Increased speed, reliability, and responsiveness and higher resolution, all of which provide a better user experience
|
||||
* May work offline/without internet service
|
||||
* Easier access to all phone features (e.g., accelerometer, camera, microphone)
|
||||
|
||||
|
||||
|
||||
### But my business is still linked to the web…
|
||||
|
||||
Most companies have focused their resources on web development and now want to enter the mobile market. But many don't have the right technical resources to develop a native app for each platform. For these companies, **hybrid** development is the right choice. In this model, developers can use their existing frontend skills to develop a single, cross-platform mobile app.
|
||||
|
||||
![Hybrid mobile apps][2]
|
||||
|
||||
Hybrid apps are a good middle ground: they're faster and less expensive to develop than native apps, and they offer more possibilities than web apps. The tradeoffs are they don't perform as well as native apps and developers can't maintain their existing tight focus on web development (as they could with web apps).
|
||||
|
||||
If you already are a fan of the [Angular][3] cross-platform development framework, I recommend trying the [Ionic][4] framework, which "lets web developers build, test, and deploy cross-platform hybrid mobile apps." I see Ionic as an extension of the [Apache Cordova][5] framework, which enables a normal web app (JS, HTML, or CSS) to run as a mobile app in a container. Ionic uses the base Cordova features that support the Angular development for its user interface.
|
||||
|
||||
The advantage of this approach is simple: the Angular paradigm is maintained, so developers can continue writing [TypeScript][6] files but target a build for Android, iOS, and Windows by properly configuring the development environment. It also provides two important tools:
|
||||
|
||||
* An appealing design and widget that are very similar to a native app's, so your hybrid app will look less "web"
|
||||
* Cordova Plugins allow the app to communicate with all phone features
|
||||
|
||||
|
||||
|
||||
### What about the Node.js backend?
|
||||
|
||||
The programming world likes to standardize, which is why hybrid apps are so popular. Frontend developers' common skills are useful in the mobile world. But if we have a technology stack for the user interface, why not focus on a single backend with the same programming paradigm?
|
||||
|
||||
This makes [Node.js][7] an appealing option. Node.js is a JavaScript runtime built on the Chrome V8 JavaScript engine. It can make the API development backend very fast and easy, and it integrates fully with web technologies. You can develop a Cordova plugin, using your Node.js backend, internally in your hybrid app, as I did with the [nodejs-cordova-plugin][8]. This plugin, following the Cordova guidelines, integrates a mobile-compatible version of the Node.js platform to provide a full-stack mobile app.
|
||||
|
||||
If you need a simple CRUD Node.js backend, you can use my [API][9] [node generator][9] that generates an app using a [MongoDB][10] embedded database.
|
||||
|
||||
![Cordova Full Stack application][12]
|
||||
|
||||
### Deploying your app
|
||||
|
||||
Open source offers everything you need to deploy your app in the best way. You just need a GitHub repository and a good continuous integration tool. I recommend [Travis-ci][13], an excellent tool that allows you to build and deploy your product for every commit.
|
||||
|
||||
Travis-ci is a fork of the better known [Jenkins][14]. Like with Jenkins, you have to configure your pipeline through a configuration file (in this case a **.travis.yml** file) in your GitHub repo. See the [.travis.yml file][15] in my repository as an example.
|
||||
|
||||
![](https://opensource.com/sites/default/files/uploads/3-travis-ci-process.png)
|
||||
|
||||
In addition, this pipeline automatically delivers and installs your app on [Appetize.io][16], a web-based iOS simulator and Android emulator, for testing.
|
||||
|
||||
You can learn more in the [Cordova Android][17] section of my GitHub repository.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/12/hybrid-mobile-app-development
|
||||
|
||||
作者:[Angelo Manganiello][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/amanganiello90
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: /file/416441
|
||||
[2]: https://opensource.com/sites/default/files/uploads/1-title.png (Hybrid mobile apps)
|
||||
[3]: https://angular.io/
|
||||
[4]: https://ionicframework.com/
|
||||
[5]: https://cordova.apache.org/
|
||||
[6]: https://www.typescriptlang.org/
|
||||
[7]: https://nodejs.org/
|
||||
[8]: https://github.com/fullStackApp/nodejs-cordova-plugin
|
||||
[9]: https://github.com/fullStackApp/generator-full-stack-api
|
||||
[10]: https://www.mongodb.com/
|
||||
[11]: /file/416351
|
||||
[12]: https://opensource.com/sites/default/files/uploads/2-cordova-full-stack-app.png (Cordova Full Stack application)
|
||||
[13]: https://travis-ci.org/
|
||||
[14]: https://jenkins.io/
|
||||
[15]: https://github.com/amanganiello90/java-angular-web-app/blob/master/.travis.yml
|
||||
[16]: https://appetize.io/
|
||||
[17]: https://github.com/amanganiello90/java-angular-web-app#cordova-android
|
@ -0,0 +1,132 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Plan your own holiday calendar at the Linux command line)
|
||||
[#]: via: (https://opensource.com/article/18/12/linux-toy-cal)
|
||||
[#]: author: (Jason Baker https://opensource.com/users/jason-baker)
|
||||
|
||||
Plan your own holiday calendar at the Linux command line
|
||||
======
|
||||
Link commands together to build a colorful calendar, and then whisk it away in a snowstorm.
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-cal.png?itok=S0F8RY9k)
|
||||
|
||||
Welcome to today's installment of the Linux command-line toys advent calendar. If this is your first visit to the series, you might be asking yourself, what’s a command-line toy. Even I'm not quite sure, but generally, it could be a game or any simple diversion that helps you have fun at the terminal.
|
||||
|
||||
It's quite possible that some of you will have seen various selections from our calendar before, but we hope there’s at least one new thing for everyone.
|
||||
|
||||
We've somehow made it to the seventh day of our series without creating an actual calendar to celebrate with, so let's use a command-line tool to do that today: **cal**. By itself, **cal** is perhaps not the most amazing of tools, but we can use a few other utilities to spice it up a bit.
|
||||
|
||||
Chances are, **cal** is installed on your system already. To use it in this instance, just type **cal**.
|
||||
|
||||
```
|
||||
$ cal
|
||||
December 2018
|
||||
Su Mo Tu We Th Fr Sa
|
||||
1
|
||||
2 3 4 5 6 7 8
|
||||
9 10 11 12 13 14 15
|
||||
16 17 18 19 20 21 22
|
||||
23 24 25 26 27 28 29
|
||||
30 31
|
||||
```
|
||||
|
||||
We aren't going to go into advanced usage in this article, so if you want to learn more about **cal** , go check out Opensource.com Community Moderator Don Watkin's excellent [overview of the date and cal commands][1].
|
||||
|
||||
Now, let's spice it up with a pretty box, as we covered in our previous Linux toy article. I'll use the diamonds box, and use a little bit of padding to get it nicely aligned.
|
||||
|
||||
```
|
||||
$ cal | boxes -d diamonds -p a1l4t2
|
||||
/\ /\ /\
|
||||
/\//\\/\ /\//\\/\ /\//\\/\
|
||||
/\//\\\///\\/\//\\\///\\/\//\\\///\\/\
|
||||
//\\\//\/\\///\\\//\/\\///\\\//\/\\///\\
|
||||
\\//\/ \/\\//
|
||||
\/ \/
|
||||
/\ December 2018 /\
|
||||
//\\ Su Mo Tu We Th Fr Sa //\\
|
||||
\\// 1 \\//
|
||||
\/ 2 3 4 5 6 7 8 \/
|
||||
/\ 9 10 11 12 13 14 15 /\
|
||||
//\\ 16 17 18 19 20 21 22 //\\
|
||||
\\// 23 24 25 26 27 28 29 \\//
|
||||
\/ 30 31 \/
|
||||
/\ /\
|
||||
//\\/\ /\//\\
|
||||
\\///\\/\//\\\///\\/\//\\\///\\/\//\\\//
|
||||
\/\\///\\\//\/\\///\\\//\/\\///\\\//\/
|
||||
\/\\//\/ \/\\//\/ \/\\//\/
|
||||
\/ \/ \/
|
||||
```
|
||||
|
||||
That looks nice, but for good measure, let's put the whole thing in a second box, just for fun. We'll use the scoll design this time.
|
||||
|
||||
```
|
||||
cal | boxes -d diamonds -p a1t2l3 | boxes -a c -d scroll
|
||||
/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \
|
||||
| /~~\ /~~\ |
|
||||
|\ \ | /\ /\ /\ | / /|
|
||||
| \ /| /\//\\/\ /\//\\/\ /\//\\/\ |\ / |
|
||||
| ~~ | /\//\\\///\\/\//\\\///\\/\//\\\///\\/\ | ~~ |
|
||||
| | //\\\//\/\\///\\\//\/\\///\\\//\/\\///\\ | |
|
||||
| | \\//\/ \/\\// | |
|
||||
| | \/ \/ | |
|
||||
| | /\ December 2018 /\ | |
|
||||
| | //\\ Su Mo Tu We Th Fr Sa //\\ | |
|
||||
| | \\// 1 \\// | |
|
||||
| | \/ 2 3 4 5 6 7 8 \/ | |
|
||||
| | /\ 9 10 11 12 13 14 15 /\ | |
|
||||
| | //\\ 16 17 18 19 20 21 22 //\\ | |
|
||||
| | \\// 23 24 25 26 27 28 29 \\// | |
|
||||
| | \/ 30 31 \/ | |
|
||||
| | /\ /\ | |
|
||||
| | //\\/\ /\//\\ | |
|
||||
| | \\///\\/\//\\\///\\/\//\\\///\\/\//\\\// | |
|
||||
| | \/\\///\\\//\/\\///\\\//\/\\///\\\//\/ | |
|
||||
| | \/\\//\/ \/\\//\/ \/\\//\/ | |
|
||||
| | \/ \/ \/ | |
|
||||
| | | |
|
||||
\ |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| /
|
||||
\ / \ /
|
||||
~~~ ~~~
|
||||
```
|
||||
|
||||
Perfect. Now, here's where things get a little crazy. I like our design, but, I'd like to go all out. So I'm going to colorize it. But here in the Raleigh, NC office where Opensource.com's staff are based, there's a good chance for snow this weekend. So let's enjoy our colorized advent calendar, and then wipe it out with snow.
|
||||
|
||||
For the snow, I'm grabbing a nifty [snippet][2] of Bash and Gawk goodness I found over on CLIMagic. If you're not familiar with CLIMagic, go check out their [website][3] and follow them on [Twitter][4]. You'll be glad you did.
|
||||
|
||||
So here we go. Let's clear the screen, throw up our boxy calendar, colorize it, wait a few seconds, then snowstorm it away. All here at the terminal, in one line.
|
||||
|
||||
```
|
||||
$ clear;cal|boxes -d diamonds -p a1t2l3|boxes -a c -d scroll|lolcat;sleep 3;while :;do echo $LINES $COLUMNS $(($RANDOM%$COLUMNS)) $(printf "\u2744\n");sleep 0.1;done|gawk '{a[$3]=0;for(x in a) {o=a[x];a[x]=a[x]+1;printf "\033[%s;%sH ",o,x;printf "\033[%s;%sH%s \033[0;0H",a[x],x,$4;}}'
|
||||
```
|
||||
|
||||
And there we go.
|
||||
|
||||
![](https://opensource.com/sites/default/files/uploads/linux-toy-cal-animated.gif)
|
||||
|
||||
For this to work on your system, you'll need all of the referenced utilities (boxes, lolcat, cal, gawk, etc.), and you'll need to use a terminal emulator that supports Unicode.
|
||||
|
||||
Do you have a favorite command-line toy that you think I ought to profile? The calendar for this series is mostly filled out but I've got a few spots left. Let me know in the comments below, and I'll check it out. If there's space, I'll try to include it. If not, but I get some good submissions, I'll do a round-up of honorable mentions at the end.
|
||||
|
||||
Check out yesterday's toy, [Take a break at the Linux command line with Nyan Cat][5], and check back tomorrow for another!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/12/linux-toy-cal
|
||||
|
||||
作者:[Jason Baker][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/jason-baker
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/article/16/12/using-calendar-function-linux
|
||||
[2]: http://climagic.org/coolstuff/let-it-snow.html
|
||||
[3]: http://climagic.org/
|
||||
[4]: https://twitter.com/climagic
|
||||
[5]: https://opensource.com/article/18/12/linux-toy-nyancat
|
57
sources/tech/20181208 Play Tetris at your Linux terminal.md
Normal file
57
sources/tech/20181208 Play Tetris at your Linux terminal.md
Normal file
@ -0,0 +1,57 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Play Tetris at your Linux terminal)
|
||||
[#]: via: (https://opensource.com/article/18/12/linux-toy-tetris)
|
||||
[#]: author: (Jason Baker https://opensource.com/users/jason-baker)
|
||||
|
||||
Play Tetris at your Linux terminal
|
||||
======
|
||||
|
||||
Recreate the magic of the 1980s with everyone's favorite tile-matching game, Tetris.
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-tetris.png?itok=_UXtpgzN)
|
||||
|
||||
Thanks for joining us for today's installment of the Linux command-line toys advent calendar. If this is your first visit to the series, you might be asking yourself, what’s a command-line toy. Even I'm not quite sure, but generally, it could be a game or any simple diversion that helps you have fun at the terminal.
|
||||
|
||||
It's quite possible that some of you will have seen various selections from our calendar before, but we hope there’s at least one new thing for everyone.
|
||||
|
||||
I promised when I started this series I'd be including games, but so far I've neglected to, so let's fix that with today's selection: Tetris.
|
||||
|
||||
Tetris and I are almost exactly the same age, having first come into the world in the summer of 1984. Instead of rural North Carolina, though, Tetris originated in Moscow in what was at the time the Soviet Union.
|
||||
|
||||
After taking the world by storm, Tetris was cloned many, many times. I would suspect you could find a Tetris clone for just about any operating system in any language you looked for. Seriously, go look. There are some fun ones out there.
|
||||
|
||||
The [version][1] I'm bringing you for today's command-line toy is [written in Haskell,][1] and it's one of the better-done versions I've seen, with on-screen preview, score, help, and a clean look.
|
||||
|
||||
If you're willing to run a compiled binary from an untrusted source (I wouldn't recommend it), you can grab that directly, but for a safer approach, it's also easy to use a containerized version with [dex][2], or to install from source with [stack][3].
|
||||
|
||||
This particular Tetris clone is by Sam Tay and available under a BSD license. [Check it out][1]!
|
||||
|
||||
![](https://opensource.com/sites/default/files/uploads/linux-toy-tetris-animated.gif)
|
||||
|
||||
If you've got your own favorite Tetris clone (or maybe you've written your own?), let us know!
|
||||
|
||||
Do you have a favorite command-line toy that you think I ought to profile? The calendar for this series is mostly filled out but I've got a few spots left. Let me know in the comments below, and I'll check it out. If there's space, I'll try to include it. If not, but I get some good submissions, I'll do a round-up of honorable mentions at the end.
|
||||
|
||||
Check out yesterday's toy, [Plan your own holiday calendar at the Linux command line][4], and check back tomorrow for another!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/12/linux-toy-tetris
|
||||
|
||||
作者:[Jason Baker][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/jason-baker
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://github.com/samtay/tetris
|
||||
[2]: https://github.com/dockerland/dex
|
||||
[3]: https://docs.haskellstack.org/en/stable/README/#how-to-install
|
||||
[4]: https://opensource.com/article/18/12/linux-toy-cal
|
@ -0,0 +1,52 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Powers of two, powers of Linux: 2048 at the command line)
|
||||
[#]: via: (https://opensource.com/article/18/12/linux-toy-2048)
|
||||
[#]: author: (Jason Baker https://opensource.com/users/jason-baker)
|
||||
|
||||
Powers of two, powers of Linux: 2048 at the command line
|
||||
======
|
||||
Looking for a terminal-based game to pass the time? Look no further than 2048-cli.
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-2048.png?itok=3M6S-n1a)
|
||||
|
||||
Hello and welcome to today's installment of the Linux command-line toys advent calendar. Every day, we look at a different toy for your terminal: it could be a game or any simple diversion that helps you have fun.
|
||||
|
||||
Maybe you have seen various selections from our calendar before, but we hope there’s at least one new thing for everyone.
|
||||
|
||||
Today's toy is a [command-line version][1] of one of my all-time favorite casual games, [2048][2] (which itself is a clone of another clone).
|
||||
|
||||
To play, you just slide blocks up, down, left, and right to combine matching pairs and increment numbers, until you've made a block that is 2048 in size. The catch (and the challenge), is that you can't just move one block; instead, you move every block on the screen.
|
||||
|
||||
It's simple, fun, and easy to get lost in it for hours. This 2048 clone, [2048-][1][cli][1], is by Marc Tiehuis and written in C, and made available as open source under an MIT license. You can find the source code [on GitHub][1], where you can also get installation instructions for your platform. Since it was packaged for Fedora, for me, installing it was as simple as:
|
||||
|
||||
```
|
||||
$ sudo dnf install 2048-cli
|
||||
```
|
||||
|
||||
That's it, have fun!
|
||||
|
||||
![](https://opensource.com/sites/default/files/uploads/linux-toy-2048-animated_0.gif)
|
||||
|
||||
Do you have a favorite command-line toy that you think I ought to profile? The calendar for this series is mostly filled out but I've got a few spots left. Let me know in the comments below, and I'll check it out. If there's space, I'll try to include it. If not, but I get some good submissions, I'll do a round-up of honorable mentions at the end.
|
||||
|
||||
Check out yesterday's toy, [Play Tetris at your Linux terminal][3], and check back tomorrow for another!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/12/linux-toy-2048
|
||||
|
||||
作者:[Jason Baker][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/jason-baker
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://github.com/tiehuis/2048-cli
|
||||
[2]: https://github.com/gabrielecirulli/2048
|
||||
[3]: https://opensource.com/article/18/12/linux-toy-tetris
|
@ -0,0 +1,174 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to Update Ubuntu [Terminal & GUI Methods] It's FOSS)
|
||||
[#]: via: (https://itsfoss.com/update-ubuntu/)
|
||||
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
|
||||
|
||||
How to Update Ubuntu [Terminal & GUI Methods] It's FOSS
|
||||
======
|
||||
|
||||
**This tutorial shows you how to update Ubuntu for both server and desktop versions. It also explains the difference between update and upgrade along with a few other things you should know about updates in Ubuntu Linux.**
|
||||
|
||||
If you are a new user and have been using Ubuntu for a few days or weeks, you might be wondering how to update your [Ubuntu][1] system for security patches, bug fixes and application upgrades.
|
||||
|
||||
Updating Ubuntu is absolutely simple. I am not exaggerating. It’s as simple as running two commands. Let me give you more details on it.
|
||||
|
||||
Please note that the tutorial is valid for Ubuntu 18.04, 16.04 or any other version. The command line way is also valid for Ubuntu-based distributions like Linux Mint, Linux Lite, elementary OS etc.
|
||||
|
||||
### Update Ubuntu via Command Line
|
||||
|
||||
![How to Update Ubuntu][2]
|
||||
|
||||
On the desktop, open the terminal. You can find it in the menu or use the Ctrl+Alt+T [keyboard shortcut][3]. If you are logged on to an [Ubuntu server][4], you already have access to a terminal.
|
||||
|
||||
In the terminal, you just have to use the following command:
|
||||
|
||||
```
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
```
|
||||
|
||||
It will ask for password and you can use your account’s password. You won’t see the anything on the screen while typing so keep on typing your password and hit enter.
|
||||
|
||||
Now let me explain the above command.
|
||||
|
||||
Actually, it’s not a single command. It’s a combination of two commands. The && is a way to combine two commands in a way that the second command runs only when the previous command ran successfully.
|
||||
|
||||
The ‘-y’ in the end automatically enters yes when the command ‘apt upgrade’ ask for your confirmation before installing the updates.
|
||||
|
||||
Note that you can also use the two commands separately, one by one:
|
||||
|
||||
```
|
||||
sudo apt update
|
||||
sudo apt upgrade
|
||||
```
|
||||
|
||||
It will take a little longer because you have to wait for one command to finish and then enter the second command.
|
||||
|
||||
#### Explanation: sudo apt update
|
||||
|
||||
This command updates the local database of available packages. If you won’t run this command, the local database won’t be updated and your system will not know if there are any new versions available.
|
||||
|
||||
This is why when you run the sudo apt update, you’ll see lots of URLs in the output. The command fetches the package information from the respective repositories (the URLs you see in the output).
|
||||
|
||||
![Updating Ubuntu Linux][5]
|
||||
|
||||
At the end of the command, it tells you how many packages can be upgraded. You can see these packages by running the following command:
|
||||
|
||||
```
|
||||
apt list --upgradable
|
||||
```
|
||||
|
||||
**Additional Reading:** Read this article to learn [what is Ign, Hit and Get in the apt update command output][6].
|
||||
|
||||
#### Explanation: sudo apt upgrade
|
||||
|
||||
This command matches the versions of installed packages with the local database. It collects all of them and then it will list all of the packages that have a newer version available. At this point, it will ask if you want to upgrade (the installed packages to the newer version).
|
||||
|
||||
![Update Ubuntu Linux via Command Line][7]
|
||||
|
||||
You can type ‘yes’, ‘y’ or just press enter to confirm the installation of updates.
|
||||
|
||||
So the bottom line is that the sudo apt update checks for the availability of new versions while as the sudo apt upgrade actually performs the update.
|
||||
|
||||
The term update might be confusing as you might expect the apt update command to update the system by installing the updates but that doesn’t happen.
|
||||
|
||||
### Update Ubuntu via GUI [For Desktop Users]
|
||||
|
||||
If you are using Ubuntu as a desktop, you don’t have to go to terminal just for updating the system. You can still use the command line but it’s optional for you.
|
||||
|
||||
In the menu, look for ‘Software Updater’ and run it.
|
||||
|
||||
![Run Software Updater in Ubuntu][8]
|
||||
|
||||
It will check if there are updates available for your system.
|
||||
|
||||
![Checking if updates are available for Ubuntu][9]
|
||||
|
||||
If there are updates available, it will give provide you with options to install the updates.
|
||||
|
||||
![Install Updates via Update Manager in Ubuntu][10]
|
||||
|
||||
Click on Install Now, it may ask for your password.
|
||||
|
||||
![Installing Updates in Ubuntu Linux via GUI][11]
|
||||
|
||||
Once you enter your password, it will start installing the updates.
|
||||
|
||||
![Updating Ubuntu via GUI][12]
|
||||
|
||||
In some cases, you may need to reboot the system for the installed updates to work properly. You’ll be notified at the end of the update if you need to restart the system.
|
||||
|
||||
![Updating Ubuntu via GUI][12]
|
||||
|
||||
You can choose to restart later if you don’t want to reboot your system straightaway.
|
||||
|
||||
![Installing updates via GUI in Ubuntu][13]
|
||||
|
||||
Tip: If the software updater returns an error, you should use the command ‘sudo apt update’ in the terminal. The last few lines of the output will contain the actual error message. You can search on the internet for that error and fix the problem.
|
||||
|
||||
### Few things to keep in mind abou updating Ubuntu
|
||||
|
||||
You just learned how to update your Ubuntu system. If you are interested, you should also know these few things around Ubuntu updates.
|
||||
|
||||
#### Clean up after an update
|
||||
|
||||
Your system will have some unnecessary packages that won’t be required after the updates. You can remove such packages and [free up some space][14] using this command:
|
||||
|
||||
```
|
||||
sudo apt autoremove
|
||||
```
|
||||
|
||||
#### Live patching kernel in Ubuntu Server to avoid rebooting
|
||||
|
||||
In case of a Linux kernel updates, you’ll have to restart the system after the update. This is an issue when you don’t want downtime for your server.
|
||||
|
||||
[Live patching][15] feature allows the patching of Linux kernel while the kernel is still running. In other words, you don’t have to reboot your system.
|
||||
|
||||
If you manage servers, you may want to [enable live patching in Ubuntu][16].
|
||||
|
||||
#### Version upgrades are different
|
||||
|
||||
The updates discussed here is to keep your Ubuntu install fresh and updated. It doesn’t cover the [version upgrades][17] (for example upgrading Ubuntu 16.04 to 18.04).
|
||||
|
||||
[Ubuntu version][18] upgrades are entirely a different thing. It updates the entire operating system core. You need to make proper backups before starting this lengthy process.
|
||||
|
||||
### Conclusion
|
||||
|
||||
I hope you liked this tutorial on updating the Ubuntu system and you learned a few new things.
|
||||
|
||||
If you have any questions, please fee free to ask. If you are an experienced Linux users and have some tip that can make this tutorial more useful, please share it with the rest of us.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/update-ubuntu/
|
||||
|
||||
作者:[Abhishek Prakash][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/abhishek/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.ubuntu.com/
|
||||
[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/12/how-to-update-ubuntu.png?resize=800%2C450&ssl=1
|
||||
[3]: https://itsfoss.com/ubuntu-shortcuts/
|
||||
[4]: https://www.ubuntu.com/download/server
|
||||
[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/12/update-ubunt-1.jpeg?resize=800%2C357&ssl=1
|
||||
[6]: https://itsfoss.com/apt-get-linux-guide/
|
||||
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/12/update-ubunt-2.jpeg?ssl=1
|
||||
[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/12/update-ubuntu-via-GUI-1.jpeg?resize=800%2C250&ssl=1
|
||||
[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/12/update-ubuntu-via-GUI-2.jpeg?resize=800%2C250&ssl=1
|
||||
[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/12/update-ubuntu-GUI-3.jpeg?resize=800%2C365&ssl=1
|
||||
[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/12/install-update-ubuntu-1.jpg?resize=800%2C450&ssl=1
|
||||
[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/12/installing-updates-ubuntu.jpg?ssl=1
|
||||
[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/12/installing-updates-ubuntu-2.jpeg?ssl=1
|
||||
[14]: https://itsfoss.com/free-up-space-ubuntu-linux/
|
||||
[15]: https://www.ubuntu.com/livepatch
|
||||
[16]: https://www.cyberciti.biz/faq/howto-live-patch-ubuntu-linux-server-kernel-without-rebooting/
|
||||
[17]: https://itsfoss.com/upgrade-ubuntu-version/
|
||||
[18]: https://itsfoss.com/how-to-know-ubuntu-unity-version/
|
@ -43,7 +43,7 @@
|
||||
via: https://opensource.com/article/18/1/creative-commons-real-world
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[Valoniakim](https://github.com/Valoniakim)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -0,0 +1,58 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (10 ways to give thanks to open source and free software maintainers)
|
||||
[#]: via: (https://opensource.com/article/18/11/ways-give-thanks-open-source)
|
||||
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
|
||||
[#]: url: ( )
|
||||
|
||||
感谢开源和自由软件维护者的 10 种方法
|
||||
======
|
||||
如何表达你的感激之情。
|
||||
![](https://opensource.com/users/moshez)
|
||||
|
||||
每天,我都使用高质量的软件,这些软件由没有要求付款的人开发和维护,他们尊重我的自由,并且慷慨地付出时间和精力。
|
||||
|
||||
在这个感恩的季节,我鼓励那些也使用和欣赏开源和自由软件维护者工作的人表达你的感激之情。以下是十种方法:
|
||||
|
||||
### 容易做到的
|
||||
|
||||
1. 发送电子邮件,感谢开发人员。具体点说,告诉他们你使用他们的什么软件以及你如何获益的。
|
||||
2. 使用你最喜爱的社交媒体平台宣传它。
|
||||
3. 写一篇关于你最喜欢的软件的博客文章。
|
||||
|
||||
|
||||
|
||||
### 捐款
|
||||
|
||||
4. 如果你最喜欢的开源项目接受捐款,请汇款。
|
||||
5. 如果你受雇于使用开源软件的公司,看你是否可以说服管理层赞助某些项目。
|
||||
6. 提供最高设置额度的捐款。社交动机能做的不可思议!
|
||||
|
||||
|
||||
|
||||
### 花费时间
|
||||
|
||||
7. 帮助查看补丁。
|
||||
8. 帮助分类 bug。
|
||||
9. 回答 IRC、邮件列表或 [Stack Overflow][1] 中的问题。
|
||||
|
||||
|
||||
|
||||
**10. 额外的:**如果你像我一样,你在某个时候对开源社区的其他人说了一些严厉的话。承诺做得更好:用善良和开放沟通。感谢的最好方式是让开源社区成为人们能舒适沟通的地方。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/11/ways-give-thanks-open-source
|
||||
|
||||
作者:[Moshe Zadka][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/moshez
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://meta.stackoverflow.com/
|
51
translated/talk/20181204 3 implications of serverless.md
Normal file
51
translated/talk/20181204 3 implications of serverless.md
Normal file
@ -0,0 +1,51 @@
|
||||
无服务器架构的三个意义
|
||||
======
|
||||
对于<ruby>无服务器<rt>Serverless</rt></ruby>架构,什么时候该用,什么时候不该用呢?
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux11x_cc.png?itok=XMDOouJR)
|
||||
|
||||
如果将如今互联网体验中最方便实用的那一部分去掉,那么留下来的基本就是<ruby>客户端-服务端<rt>client-server</rt></ruby>模式了。这一个模式在互联网建立初期就已经在使用了,直到目前都没有太大的变化,也就是说,这个模式仍然在为我们服务。
|
||||
|
||||
那么,当人们谈论无服务器架构的时候,到底是指什么呢?其实,无服务器架构并不是说不使用服务器了。恰恰相反,客户端-服务端模式仍然在其中发挥着重要的作用。
|
||||
|
||||
无服务器架构实际上指的是能够让开发者在不需要关心服务器上架、为操作系统打补丁、创建容器镜像这些工作的情况下,就能够完成编码、部署和创建应用这一整套流程的架构。
|
||||
|
||||
### 无服务器架构的三个重要意义
|
||||
|
||||
1. 一些缺乏开发经验的人员现在要参与到开发工作中来了。无服务器架构能够让他们尽量只学习必要的工作内容,把更多的时间放在更具创造性的开发工作中。
|
||||
2. 开发者不再需要重复造轮子。运行和维护服务器、为操作系统打补丁、创建容器等这一系列工作,都可以由更专业的无服务器架构提供商来完成。
|
||||
3. 最现实的一点是,如果不使用无服务器架构,那么在服务器管理方面,总需要有一个作最终决策的人。当服务器发生崩溃时,或是需要在服务器上执行某些操作时,总是需要这样一个统领全局的人来作出决策。因此最佳的方案是使用无服务器架构。
|
||||
|
||||
|
||||
|
||||
### 什么时候该用或者不该用无服务器架构?
|
||||
|
||||
听起来无服务器架构是个好东西。但事实上,无服务器架构并不是万能的,在使用之前还需要考虑以下这些因素:
|
||||
|
||||
1. 成本
|
||||
2. 使用范围
|
||||
3. 时间
|
||||
4. 控制方式
|
||||
|
||||
其中值得注意的是控制方式。现在已经有一些项目为开发者提供了操作和控制无服务器架构计算环境的工具了,[Apache OpenWhisk][1] 就是其中之一。
|
||||
|
||||
### 为什么要将无服务器架构开源?
|
||||
|
||||
关于这方面的更多内容,可以观看无服务器架构方面的专家 Saron Yitbarek 在 [Command Line Heroes][2] 节目中的访谈。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/12/serverless-podcast-command-line-heros
|
||||
|
||||
作者:[Jen Wike Huger][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[HankChow](https://github.com/HankChow)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/remyd
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/article/18/11/developing-functions-service-apache-openwhisk
|
||||
[2]: https://www.redhat.com/en/command-line-heroes
|
||||
|
@ -0,0 +1,128 @@
|
||||
享受Linux下命令行全操作
|
||||
======
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_terminals.png?itok=CfBqYBah)
|
||||
很多文章讨论关于命令行下如何做事情。有多少文章要么用晦涩的方式介绍 `ls` ,要么介绍关于 Sed 和 Awk 一些有意思的正则表达式,要么就是介绍一大堆的 perl 脚本是如何解析的?这些都不是命令行操作的重点。
|
||||
|
||||
本文章是关于[享受命令行全操作][1],在我们不需要图形桌面,网络浏览器或网络连接情况下,用命令行操作能完成实际事务的跟踪。为了达到这一点,我们将介绍四个途径跟踪你的待办清单:纯文件文件,Todo.txt,TaskWarrior,Org-mode。
|
||||
|
||||
### 纯文本
|
||||
|
||||
![plaintext][3]
|
||||
|
||||
我喜欢用 Vim ,其实你也可以喜欢 Nano。
|
||||
|
||||
最直接管理管理你的待办清单的方式就是用纯文本文件来编辑。只需要打开一个空文件,每一行添加一个任务。当任务完成后,删除这一行,简单有效,不用再关心这一行之前干什么用的了。不过这个方法也有缺点,一点你删除一行并保存了文件,它就是永远消失了。如果你想知道本周或者上周都做了哪些事情,就成了问题。使用简单文本文件很方便却也容易导致混乱。
|
||||
|
||||
### Todo.txt: 纯文件的升级版
|
||||
|
||||
|
||||
![todo.txt screen][5]
|
||||
|
||||
整洁,有条理,易用
|
||||
|
||||
这就是我们要说的 [Todo.txt][6] 格式文件和应用程序。安装可从 GitHub [下载][7]最新的版本解压后并执行命令 `sudo make install`
|
||||
|
||||
![安装 todo.txt][9]
|
||||
|
||||
也可以从 Git 克隆一个。
|
||||
|
||||
Todo.txt 可以很容易的增加新任务,并能显示任务列表和已完成任务的标记:
|
||||
|
||||
|||
|
||||
| ------------- |:-------------|
|
||||
| `todo.sh add "某任务"` | 增加 "某任务" 到你的待办列表 |
|
||||
| `todo.sh ls` | 显示所有的任务 |
|
||||
| `todo.sh ls due:2018-02-15` | 显示2018-02-15之前的所有任务 |
|
||||
| `todo.sh do 3` | 标记任务3 为已完成任务 |
|
||||
|
||||
清单实际上仍然是纯文本,你可以用你喜欢的编辑器遵循[正确的格式][10]编辑它。
|
||||
|
||||
应用程序同时也内置了一个强大的帮助。
|
||||
|
||||
|
||||
![在 todo.txt 中语法高亮][12]
|
||||
|
||||
你可以使用语法高亮的功能
|
||||
|
||||
此外,还有许多附加组件可供选择,以及编写自己的附件组件规范。甚至有浏览器组件,移动设备应用程序和桌面应用程序支持 Todo.txt 的格式。
|
||||
|
||||
|
||||
![GNOME extensions in todo.txt][14]
|
||||
|
||||
GNOME的扩展组件
|
||||
|
||||
Todo.txt 最大的缺点是缺少自动或内置的同步机制。大多数(不是全部)的浏览器扩展程序和移动应用程序需要用 Dropbox 实现桌面系统和应用程序直接的数据同步。如果你想内置同步机制,我们也有……
|
||||
|
||||
### Taskwarrior: 现在我们用 Python 做事了
|
||||
|
||||
[Taskwarrior][15] 是一个与Todo.txt 有许多相同功能的 Python 工具。但不同的是它的数据保存在数据库里并具有内置的数据同步功能。它还可以跟踪即将要做的任务,可以提醒某个任务持续了多久,可以提醒你一些重要的事情应该马上去做。
|
||||
|
||||
[安装][16] Taskwarrior 可以通过通过发行版自带的包管理器,或通过 Python 命令 `pip`安装,或者用源码编译。用法也和 Todo.txt 的命令完全一样:
|
||||
|
||||
|||
|
||||
| ------------- |:-------------|
|
||||
| `task add "某任务"` | 增加 "某任务" 到任务清单 |
|
||||
| `task list` | 列出所有任务 |
|
||||
| `task list due ``:today` |列出截止今天的任务 |
|
||||
| `task do 3` | 标记编号是3的任务为完成状态 |
|
||||
|
||||
Taskwarrior 还有漂亮的文本用户界面。
|
||||
|
||||
![Taskwarrior in Vit][18]
|
||||
|
||||
我喜欢 Vit, 它的设计灵感来自 Vim.
|
||||
|
||||
不同于 Todo.txt,Taskwarrior 可以和本地或远程服务器同步信息。如果你希望运行自己的同步服务器可以使用名为 `taskd` 的基础服务器,如果不使用自己的服务器也有好几个可用服务器。
|
||||
|
||||
Taskwarriot 还拥有一个蓬勃发展的插件和扩展生态系统,这和移动和桌面系统的应用生态类似。
|
||||
|
||||
![GNOME in Taskwarrior ][20]
|
||||
|
||||
在 GNOME 下的 Taskwarrior 看起来还是很漂亮的。
|
||||
|
||||
Taskwarrior 有一个唯一的缺点,你是不能直接修改待办任务的,这和其他的工具不一样。你只能把任务清单按照格式导出,然后修改导出文件后,重新再导入,这样相对于编辑器直接编辑任务还是挺麻烦的。
|
||||
|
||||
谁能给我们带来最大的希望呢......
|
||||
|
||||
### Emacs Org-mode: 牛逼的任务收割机
|
||||
|
||||
![Org-mode][22]
|
||||
|
||||
Emacs 具有所有优点。
|
||||
|
||||
Emacs [Org-mode][23] 是目前为止最强大,最灵活的开源待办任务管理器。它支持多文件,使用纯文本,高度定制和自动识别日期,截止日期和任务计划。相对于我们这里介绍的其他工具,它的配置也更复杂一些。但是一旦配置好,她可以比其他工具完成更多功能。如果你是熟悉或者是 [Bullet Journals][24] 的粉丝,Org-mode 可能是在桌面程序里最像[Bullet Journals][24]的了。
|
||||
|
||||
Org-mode 可以运行在任何 Emacs 运行的地方,一些移动应用程序可以和它很好交互。但是不幸的是,目前没有桌面程序或浏览器插件支持Org-mode。尽管如此,Org-mode仍然是跟踪待办事项最好的应用程序之一,因为他确实很强大。
|
||||
|
||||
### 选择适合自己的工具
|
||||
|
||||
最后,这些程序目的是帮助你跟踪待办事务并确保不会忘记做某个事情。这些程序的基础功能都大同小异,那一款适合你取决于多种因素。有的人需要自带同步功能,有的人需要一个移动客户端,有的人要必须支持插件。不管你选择什么,请记住程序本身不会让你更有调理,但是可以帮助你。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/2/getting-to-done-agile-linux-command-line
|
||||
|
||||
作者:[Kevin Sonney][a]
|
||||
译者:[guevaraya](https://github.com/guevaraya)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/ksonney (Kevin Sonney)
|
||||
[1]:https://www.scruminc.com/getting-done/
|
||||
[3]:https://opensource.com/sites/default/files/u128651/plain-text.png (plaintext)
|
||||
[5]:https://opensource.com/sites/default/files/u128651/todo-txt.png (todo.txt screen)
|
||||
[6]:http://todotxt.org/
|
||||
[7]:https://github.com/todotxt/todo.txt-cli/releases
|
||||
[9]:https://opensource.com/sites/default/files/u128651/todo-txt-install.png (Installing todo.txt)
|
||||
[10]:https://github.com/todotxt/todo.txt
|
||||
[12]:https://opensource.com/sites/default/files/u128651/todo-txt-vim.png (Syntax highlighting in todo.txt)
|
||||
[14]:https://opensource.com/sites/default/files/u128651/tod-txt-gnome.png (GNOME extensions in todo.txt)
|
||||
[15]:https://taskwarrior.org/
|
||||
[16]:https://taskwarrior.org/download/
|
||||
[18]:https://opensource.com/sites/default/files/u128651/taskwarrior-vit.png (Taskwarrior in Vit)
|
||||
[20]:https://opensource.com/sites/default/files/u128651/taskwarrior-gnome.png (Taskwarrior on GNOME)
|
||||
[22]:https://opensource.com/sites/default/files/u128651/emacs-org-mode.png (Org-mode)
|
||||
[23]:https://orgmode.org/
|
||||
[24]:http://bulletjournal.com/
|
@ -1,131 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (oneforalone)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (Emacs #3: More on org-mode)
|
||||
[#]: via: (https://changelog.complete.org/archives/9877-emacs-3-more-on-org-mode)
|
||||
[#]: author: (John Goerzen http://changelog.complete.org/archives/author/jgoerzen)
|
||||
[#]: url: ( )
|
||||
|
||||
Emacs 系列(三): `Org` 模式的补充
|
||||
======
|
||||
|
||||
这是 [Emacs 和 `Org` 模式系列][1]的第三篇。
|
||||
|
||||
**Todo 的跟进及关键字**
|
||||
|
||||
当你使用 `Org` 模式来跟进的的 TODO 时,它有多种状态。你可以用 `C-c C-t` 来快速切换状态。我将它设为这样:
|
||||
|
||||
```
|
||||
(setq org-todo-keywords '(
|
||||
(sequence "TODO(t!)" "NEXT(n!)" "STARTED(a!)" "WAIT(w@/!)" "OTHERS(o!)" "|" "DONE(d)" "CANCELLED(c)")
|
||||
))
|
||||
```
|
||||
|
||||
在这里,我设置了一个任务未完成的五种状态:`TODO`、`NEXT`、`STARTED`、`WAIT` 及 `OTHERS`。每一个状态都单个字的快捷键(t,n,a 等)。这些符号之后的状态被认为是“完成”的状态。我有两个“完成”状态:`DONE`(已经完成)及 `CANCELLED`(还没完成,但由于其它的原因无法完成)。
|
||||
|
||||
`!` 的含义是记录某项更改为状态的时间。我不把这个添加到完成的状态,是因为它们已经被记录了。`@` 符号表示带理由的提示,所以当切换到 `WAIT` 时,`Org` 会问我为什么,并将这个添加到笔记中。
|
||||
|
||||
以下是项目状态发生变化的例子:
|
||||
|
||||
```
|
||||
** DONE This is a test
|
||||
CLOSED: [2018-03-02 Fri 03:05]
|
||||
|
||||
- State "DONE" from "WAIT" [2018-03-02 Fri 03:05]
|
||||
- State "WAIT" from "TODO" [2018-03-02 Fri 03:05] \\
|
||||
waiting for pigs to fly
|
||||
- State "TODO" from "NEXT" [2018-03-02 Fri 03:05]
|
||||
- State "NEXT" from "TODO" [2018-03-02 Fri 03:05]
|
||||
```
|
||||
|
||||
在这里,最新的项目在最上面。
|
||||
|
||||
**议程模式,日程及期限**
|
||||
|
||||
当你处在一个待办项时,`C-c C-s` 或 `C-c C-d` 可以为其设置相应的日程或期限。这些都是在议程模式中的功能。区别在于意图和表现。日程是你希望在某个时候完成的事情,而期限是在某个特定的时间应该完成的事情。默认情况下,议程视图将在项目的截止日期前提醒你。
|
||||
|
||||
在此过程中,[议程视图][3]将显示即将出现的项目,提供了一种基于纯文本或标记搜索项目的方法,甚至可以进行跨多个文件处理项目的批量操作。我在本系列的[第 2 部分][4]中介绍了为议程模式配置。
|
||||
|
||||
**标签**
|
||||
|
||||
`Org` 模式当然也支持标签了。你可以通过 `C-c C-q` 快速的建立标签。
|
||||
|
||||
你可能会想为一些常用的标签设置快捷键。就像这样:
|
||||
|
||||
```
|
||||
(setq org-tag-persistent-alist
|
||||
'(("@phone" . ?p)
|
||||
("@computer" . ?c)
|
||||
("@websurfing" . ?w)
|
||||
("@errands" . ?e)
|
||||
("@outdoors" . ?o)
|
||||
("MIT" . ?m)
|
||||
("BIGROCK" . ?b)
|
||||
("CONTACTS" . ?C)
|
||||
("INBOX" . ?i)
|
||||
))
|
||||
```
|
||||
|
||||
你还可以根据每个文件向该列表添加标记,也可以根据每个文件为某些内容设置标记。我就在我的 `inbox.org` 和 `email.org` 文件中设置了一个 `INBOX` 的标签。然后我可以每天从日程视图中查看所有标记为 `INBOX` 的项目,像将它们重新归档到其他文件中的简单操作将让它们去掉 `INBOX` 标记。
|
||||
|
||||
**重新归档**
|
||||
|
||||
“重新归档”就是在文件中或其他地方移动。它是使用标来题完成。`C-c C-w` 就是做这个的。我设置成这样:
|
||||
|
||||
```
|
||||
(setq org-outline-path-complete-in-steps nil) ; Refile in a single go
|
||||
(setq org-refile-use-outline-path 'file)
|
||||
```
|
||||
|
||||
**归档分类**
|
||||
|
||||
一段时间后,你的文件就会被已经完成的事情弄得乱七八糟。`Org` 模式有一个[归档][6]特性,可以将主 `.org` 文件移到其他文件中,以备将来参考。如果你在 `git` 或其他软件中 有 `Org` 文件,你可能希望删除这些其他文件,因为无论如何都会在历史中拥有这些文件,但是我发现它们对于 `grepping` 和搜索非常方便。
|
||||
|
||||
我会定期检查并归档文件中的所有内容。基于 [stackoverflow 的讨论][7],我有以下代码:
|
||||
|
||||
```
|
||||
(defun org-archive-done-tasks ()
|
||||
(interactive)
|
||||
(org-map-entries
|
||||
(lambda ()
|
||||
(org-archive-subtree)
|
||||
(setq org-map-continue-from (outline-previous-heading)))
|
||||
"/DONE" 'file)
|
||||
(org-map-entries
|
||||
(lambda ()
|
||||
(org-archive-subtree)
|
||||
(setq org-map-continue-from (outline-previous-heading)))
|
||||
"/CANCELLED" 'file)
|
||||
)
|
||||
```
|
||||
|
||||
这基于[一个特定的答案][8]——你可以从评论那获得一些额外的提示。现在你可以运行 `M-x org-archive-done-tasks`,当前文件中所有标记为 `DONE` 或 `CANCELED` 的内容都将放到另一个文件中。
|
||||
|
||||
**下一篇**
|
||||
|
||||
我将通过讨论在 `Org` 模式中自动接受邮件以及在不同的机子上同步来对 `Org` 模式进行总结。
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://changelog.complete.org/archives/9877-emacs-3-more-on-org-mode
|
||||
|
||||
作者:[John Goerzen][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[oneforalone](https://github.com/oneforalone)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://changelog.complete.org/archives/author/jgoerzen
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://changelog.complete.org/archives/tag/emacs2018
|
||||
[2]: https://orgmode.org/guide/TODO-Items.html#TODO-Items
|
||||
[3]: https://orgmode.org/guide/Agenda-Views.html#Agenda-Views
|
||||
[4]: https://changelog.complete.org/archives/9865-emacs-2-introducing-org-mode
|
||||
[5]: https://orgmode.org/guide/Tags.html#Tags
|
||||
[6]: https://orgmode.org/guide/Archiving.html#Archiving
|
||||
[7]: https://stackoverflow.com/questions/6997387/how-to-archive-all-the-done-tasks-using-a-single-command
|
||||
[8]: https://stackoverflow.com/a/27043756
|
@ -0,0 +1,231 @@
|
||||
使用Ansible来管理你的工作站:配置自动化
|
||||
======
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/robot_arm_artificial_ai.png?itok=8CUU3U_7)
|
||||
|
||||
Ansible是一个令人惊讶的自动化的配置管理工具。主要应用在服务器和云部署上,但在工作站上的应用(无论是台式机还是笔记本)却得到了很少的关注,这就是本系列所要关注的。
|
||||
|
||||
在这个系列的第一部分,我会向你展示'ansible-pull'命令的基本用法,我们创建了一个安装了少量包的palybook.它本身是没有多大的用处的,但是它为后续的自动化做了准备。
|
||||
|
||||
在这篇文章中,所有的事件操作都是闭环的,而且在最后部分,我们将会有一个针对工作站自动配置的完整的工作解决方案。现在,我们将要设置Ansible的配置,这样未来将要做的改变将会自动的部署应用到我们的工作站上。现阶段,假设你已经完成了第一部分的工作。如果没有的话,当你完成的时候回到本文。你应该已经有一个包含第一篇文章中代码的Github库。我们将直接按照之前的方式创建。
|
||||
|
||||
首先,因为我们要做的不仅仅是安装包文件,所以我们要做一些重新的组织工作。现在,我们已经有一个名为'local.yml'并包含以下内容的playbook:
|
||||
```
|
||||
- hosts: localhost
|
||||
|
||||
become: true
|
||||
|
||||
tasks:
|
||||
|
||||
- name: Install packages
|
||||
|
||||
apt: name={{item}}
|
||||
|
||||
with_items:
|
||||
|
||||
- htop
|
||||
|
||||
- mc
|
||||
|
||||
- tmux
|
||||
|
||||
```
|
||||
|
||||
如果我们仅仅想实现一个任务那么上面的配置就足够了。随着向我们的配置中不断的添加内容,这个文件将会变的相当的庞大和杂乱。最好能够根据不同类型的配置将play文件分为独立的文件。为了达到这个要求,创建一个名为taskbook的文件,它和playbook很像但内容更加的流线型。让我们在Git库中为taskbook创建一个目录。
|
||||
```
|
||||
mkdir tasks
|
||||
|
||||
```
|
||||
|
||||
在'local.yml'playbook中的代码使它很好过过渡到成为安装包文件的taskbook.让我们把这个文件移动到刚刚创建好并新命名的目录中。
|
||||
|
||||
```
|
||||
mv local.yml tasks/packages.yml
|
||||
|
||||
```
|
||||
现在,我们编辑'packages.yml'文件将它进行大幅的瘦身,事实上,我们可以精简除了独立任务本身之外的所有内容。让我们把'packages.yml'编辑成如下的形式:
|
||||
```
|
||||
- name: Install packages
|
||||
|
||||
apt: name={{item}}
|
||||
|
||||
with_items:
|
||||
|
||||
- htop
|
||||
|
||||
- mc
|
||||
|
||||
- tmux
|
||||
|
||||
```
|
||||
|
||||
正如你所看到的,它使用同样的语法,但我们去掉了对这个任务无用没有必要的所有内容。现在我们有了一个专门安装包文件的taskbook.然而我们仍然需要一个名为'local.yml'的文件,因为执行'ansible-pull'命令时仍然会去发现这个文件。所以我们将在我们库的根目录下(不是在'task'目录下)创建一个包含这些内容的全新文件:
|
||||
```
|
||||
- hosts: localhost
|
||||
|
||||
become: true
|
||||
|
||||
pre_tasks:
|
||||
|
||||
- name: update repositories
|
||||
|
||||
apt: update_cache=yes
|
||||
|
||||
changed_when: False
|
||||
|
||||
|
||||
|
||||
tasks:
|
||||
|
||||
- include: tasks/packages.yml
|
||||
|
||||
```
|
||||
|
||||
这个新的'local.yml'扮演的是将要导入我们的taksbooks的主页的角色。我已经在这个文件中添加了一些你在这个系列中看不到的内容。首先,在这个文件的开头处,我添加了'pre——tasks',这个任务的作用是在其他所有任务运行之前先运行某个任务。在这种情况下,我们给Ansible的命令是让它去更新我们的分布存储库主页,下面的配置将执行这个任务要求:
|
||||
|
||||
```
|
||||
apt: update_cache=yes
|
||||
|
||||
```
|
||||
通常'apt'模块是用来安装包文件的,但我们也能够让它来更新库索引。这样做的目的是让我们的每个play在Ansible运行的时候能够以最新的索引工作。这将确保我们在使用一个老旧的索引安装一个包的时候不会出现问题。因为'apt'模块仅仅在Debian,Ubuntu和他们的衍生环境下工作。如果你运行的一个不同的环境,你期望在你的环境中使用一个特殊的模块而不是'apt'。如果你需要使用一个不同的模块请查看Ansible的相关文档。
|
||||
|
||||
下面这行值得以后解释:
|
||||
```
|
||||
changed_when: False
|
||||
|
||||
```
|
||||
在独立任务中的这行阻止了Ansible去报告play改变的结果即使是它本身在系统中导致的一个改变。在这中情况下,我们不会去在意库索引是否包含新的数据;它几乎总是会的,因为库总是在改变的。我们不会去在意'apt'库的改变,因为索引的改变是正常的过程。如果我们删除这行,我们将在过程保告的后面看到所有的变动,即使仅仅库的更新而已。最好能够去忽略这类的改变。
|
||||
|
||||
接下来是常规任务的阶段,我们将创建好的taskbook导入。我们每次添加另一个taskbook的时候,要添加下面这一行:
|
||||
```
|
||||
tasks:
|
||||
|
||||
- include: tasks/packages.yml
|
||||
|
||||
```
|
||||
|
||||
如果你将要运行'ansible-pull'命令,他应该向上一篇文章中的那样做同样重要的事情。 不同的是我们已经提高了我们的组织并且能够更有效的扩展它。'ansible-pull'命令的语法,为了节省你到上一篇文章中去寻找,参考如下:
|
||||
```
|
||||
sudo ansible-pull -U https://github.com/<github_user>/ansible.git
|
||||
|
||||
```
|
||||
如果你还记得话,'ansible-pull'的命令拉取一个Git库并且应用了它所包含的配置。
|
||||
|
||||
既然我们的基础已经搭建好,我们现在可以扩展我们的Ansible并且添加功能。更特别的是,我们将添加配置来自动化的部署对工作站要做的改变。为了支撑这个要求,首先我们要创建一个特殊的账户来应用我们的Ansible配置。这个不是必要的,我们仍然能够在我们自己的用户下运行Ansible配置。但是使用一个隔离的用户能够将其隔离到不需要我们参与的在后台运行的一个系统进程中,
|
||||
|
||||
我们可以使用常规的方式来创建这个用户,但是既然我们正在使用Ansible,我们应该尽量避开使用手动的改变。替代的是,我们将会创建一个taskbook来处理用户的创建任务。这个taskbook目前将会仅仅创建一个用户,但你可以在这个taskbook中添加额外的plays来创建更多的用户。我将这个用户命名为'ansible',你可以按照自己的想法来命名(如果你做了这个改变要确保更新所有的变动)。让我们来创建一个名为'user.yml'的taskbook并且将以下代码写进去:
|
||||
|
||||
```
|
||||
- name: create ansible user
|
||||
|
||||
user: name=ansible uid=900
|
||||
|
||||
```
|
||||
下一步,我们需要编辑'local.yml'文件,将这个新的taskbook添加进去,像如下这样写:
|
||||
|
||||
```
|
||||
- hosts: localhost
|
||||
|
||||
become: true
|
||||
|
||||
pre_tasks:
|
||||
|
||||
- name: update repositories
|
||||
|
||||
apt: update_cache=yes
|
||||
|
||||
changed_when: False
|
||||
|
||||
|
||||
|
||||
tasks:
|
||||
|
||||
- include: tasks/users.yml
|
||||
|
||||
- include: tasks/packages.yml
|
||||
|
||||
```
|
||||
现在当我们运行'ansible-pull'命令的时候,一个名为'ansible'的用户将会在系统中被创建。注意我特地通过参数'UID'为这个用户声明了用户ID为900。这个不是必须的,但建议直接创建好UID。因为在1000以下的UID在登陆界面是不会显示的,这样是很棒的因为我们根本没有需要去使用'ansibe'账户来登陆我们的桌面。UID 900是固定的;它应该是在1000以下没有被使用的任何一个数值。你可以使用以下命令在系统中去验证UID 900是否已经被使用了:
|
||||
|
||||
```
|
||||
cat /etc/passwd |grep 900
|
||||
|
||||
```
|
||||
然而,你使用这个UID应该不会遇到什么问题,因为迄今为止在我使用的任何发行版中我还没遇到过它是被默认使用的。
|
||||
|
||||
现在,我们已经拥有了一个名为'ansible'的账户,它将会在之后的自动化配置中使用。接下来,我们可以创建实际的定时作业来自动操作它。而不是将其放置到我们刚刚创建的'users.yml'文件中,我们应该将其分开放到它自己的文件中。在任务目录中创建一个名为'cron.yml'的taskbook并且将以下的代买写进去:
|
||||
```
|
||||
- name: install cron job (ansible-pull)
|
||||
|
||||
cron: user="ansible" name="ansible provision" minute="*/10" job="/usr/bin/ansible-pull -o -U https://github.com/<github_user>/ansible.git > /dev/null"
|
||||
|
||||
```
|
||||
定时模块的语法几乎是不需加以说明的。通过这个play,我们创建了一个通过用户'ansible'运行的定时作业。这个作业将每隔10分钟执行一次,下面是它将要执行的命令:
|
||||
|
||||
```
|
||||
/usr/bin/ansible-pull -o -U https://github.com/<github_user>/ansible.git > /dev/null
|
||||
|
||||
```
|
||||
同样,我们也可以添加想要我们的所有工作站部署的额外定时作业到这个文件中。我们只需要在新的定时作业中添加额外的palys即可。然而,仅仅是添加一个定时的taskbook是不够的,我们还需要将它添加到'local.yml'文件中以便它能够被调用。将下面的一行添加到末尾:
|
||||
```
|
||||
- include: tasks/cron.yml
|
||||
|
||||
```
|
||||
现在当'ansible-pull'命令执行的时候,它将会以通过用户'ansible'每个十分钟设置一个新的定时作业。但是,每个十分钟运行一个Ansible作业并不是一个好的方式因为这个将消耗很多的CPU资源。每隔十分钟来运行对于Ansible来说是毫无意义的除非欧文已经在Git库中改变一些东西。
|
||||
|
||||
然而,我们已经解决了这个问题。注意到我在定时作业中的命令'ansible-pill'添加的我们之前从未用到过的参数'-o'.这个参数告诉Ansible只有在从上次'ansible-pull'被调用以后库有了变化后才会运行。如果库没有任何变化,他将不会做任何事情。通过这个方法,你将不会无端的浪费CPU资源。当然,一些CPU资源将会在下来存储库的时候被使用,但不会像再一次应用整个配置的时候使用的那么多。当'ansible-pull'执行的时候,它将会遍历在playbooks和taskbooks中的所有任务,但至少它不会毫无目的的运行。
|
||||
|
||||
尽管我们已经添加了所有必须的配置要素来自动化'ansible-pull',它任然还不能正常的工作。'ansible-pull'命令需要sudo的权限来运行,这将允许它执行系统级的命令。然而我们创建的用户'ansible'并没有被设置为以'sudo'的权限来执行命令,因此当定时作业触发的时候,执行将会失败。通常沃恩可以使用命令'visudo'来手动的去设置用户'ansible'的拥有这个权限。然而我们现在应该以Ansible的方式来操作,而且这将会是一个向你展示'copy'模块是如何工作的机会。'copy'模块允许你从库复制一个文件到文件系统的任何位置。在这个案列中,我们将会复制'sudo'的一个配置文件到'/etc/sudoers.d/'以便用户'ansible'能够以管理员的权限执行任务。
|
||||
|
||||
打开'users.yml',将下面的play添加到文件末尾。
|
||||
|
||||
```
|
||||
- name: copy sudoers_ansible
|
||||
|
||||
copy: src=files/sudoers_ansible dest=/etc/sudoers.d/ansible owner=root group=root mode=0440
|
||||
|
||||
```
|
||||
'copy'模块,正如我们看到的,从库复制一个文件到其他任何位置。在这个过程中,我们正在抓取一个名为'sudoers_ansible'(我们将在后续创建)的文件并将它复制到拥有者为'root'的'/etc/sudoers/ansible'中。
|
||||
|
||||
接下来,我们需要创建我们将要复制的文件。在你的库的根目录下,创建一个名为'files'的目录:
|
||||
|
||||
```
|
||||
mkdir files
|
||||
|
||||
```
|
||||
然后,在我们刚刚创建的'files'目录里,创建包含以下内容的名为'sudoers_ansible'的文件:
|
||||
```
|
||||
ansible ALL=(ALL) NOPASSWD: ALL
|
||||
|
||||
```
|
||||
在'/etc/sudoer.d'目录里创建一个文件,就像我们正在这样做的,允许我们为一个特殊的用户配置'sudo'权限。现在我们正在通过'sudo'允许用户'ansible'不需要密码拥有完全控制权限。这将允许'ansible-pull'以后台任务的形式运行而不需要手动去运行。
|
||||
|
||||
现在,你可以通过再次运行'ansible-pull'来拉取最新的变动:
|
||||
```
|
||||
sudo ansible-pull -U https://github.com/<github_user>/ansible.git
|
||||
|
||||
```
|
||||
从这个节点开始,'ansible-pull'的定时作业将会在后台每隔十分钟运行一次来检查你的库是否有变化,如果它发现有变化,将会运行你的palybook并且应用你的taskbooks.
|
||||
|
||||
所以现在我们有了一个完整的工作方案。当你第一次设置一台新的笔记本或者台式机的时候,你要去手动的运行'ansible-pull'命令,但仅仅是在第一次的时候。从第一次之后,用户'ansible'将会在后台接手后续的运行任务。当你想对你的机器做变动的时候,你只需要简单的去拉取你的Git库来做变动,然后将这些变化回传到库中。接着,当定时作业下次在每台机器上运行的时候,它将会拉取变动的部分并应用它们。你现在只需要做一次变动,你的所有工作站将会跟着一起变动。这方法尽管有一点不方便,通常,你会有一个你的机器列表的文件和包含不同机器的规则。不管怎样,'ansible-pull'的方法,就像在文章中描述的,是管理工作站配置的非常有效的方法。
|
||||
|
||||
我已经在我的[Github repository]中更新了这篇文章中的代码,所以你可以随时去浏览来再一次检查你的语法。同时我将前一篇文章中的代码移到了它自己的目录中。
|
||||
|
||||
在第三部分,我们将通过介绍使用Ansible来配置GNOME桌面设置来结束这个系列。我将会告诉你如何设置你的墙纸和锁屏壁纸,应用一个桌面主题以及更多的东西。
|
||||
|
||||
同时,到了布置一些作业的时候了,大多数人有我们使用的各种应用的配置文件。可能是Bash,Vim或者其他你使用的工具的配置文件。现在你可以尝试通过我们在使用的Ansible库来自动复制这些配置到你的机器中。在这篇文章中,我已将想你展示了如何去复制文件,所以去尝试以下看看你是都已经能应用这些知识。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/3/manage-your-workstation-configuration-ansible-part-2
|
||||
|
||||
作者:[Jay LaCroix][a]
|
||||
译者:[FelixYFZ](https://github.com/FelixYFZ)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/jlacroix
|
||||
[1]:https://opensource.com/article/18/3/manage-workstation-ansible
|
||||
[2]:https://github.com/jlacroix82/ansible_article.git
|
@ -0,0 +1,125 @@
|
||||
Bash 中使用控制运算符连接命令
|
||||
======
|
||||
在命令行中,使用控制运算符为复合命令添加逻辑。
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-lead-yearbook-best-couple.png?itok=a_99oCdE)
|
||||
|
||||
一些简单的复合指令——比如说在一个命令行中连接几个命令——是经常使用的。这些命令使用分号分隔,表示一个命令结束。为了在一个命令行中创建一系列简单的 shell 命令,只需要使用分号把每一条命令分隔开,就像下面这样:
|
||||
|
||||
```
|
||||
command1 ; command2 ; command3 ; command4 ;
|
||||
```
|
||||
|
||||
最后一个分号你可以不用添加,因为当你按下回车键时就表示一个命令的结束,但是为了和其它的保持一致,还是建议加上比较好。
|
||||
|
||||
所有的命令执行都没有什么问题——只要没有什么意外发生。但是当出问题时到底发生了什么呢?我们可以预测,并且通过 Bash 中内置的 `&&` 和 `||` 运算符跟踪这些错误。这两个控制运算符提供了一些流控制,可以让我们改变代码执行队列的顺序。分号和 **换行符** 也被认为是 Bash 的控制运算符。
|
||||
|
||||
`&&` 运算符意义简单来说就是“如果 `command1` 执行成功,就接着执行 `command2`。”如果 `command1` 因为任何原因执行失败,那么 `command2` 将不执行。这个语法看下来像这样:
|
||||
|
||||
```
|
||||
command1 && command2
|
||||
```
|
||||
|
||||
这样写是允许的,因为每一个命令都会返回一个值给 shell 来表示这个命令在执行的过程中是否执行成功或者失败。通常,返回值是 0 表示成功,而一个正数值表示不同种类的错误。有一些系统管理工具仅仅返回一个 1 来表示所有的错误,但是也有很多工具使用其它的正数的返回值来表示各种类型错误。
|
||||
|
||||
我们可以很容易的使用脚本, 命令列表中的下一个命令,或者可以直接使用系统管理工具来检查 shell 变量 `$?` 。我们一起来看这些返回值。运行一个简单的命令然后立即检查它的返回值,这个返回值始终是属于最后一个运行的命令。
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ ll ; echo "RC = $?"
|
||||
total 284
|
||||
-rw-rw-r-- 1 student student 130 Sep 15 16:21 ascii-program.sh
|
||||
drwxrwxr-x 2 student student 4096 Nov 10 11:09 bin
|
||||
<snip>
|
||||
drwxr-xr-x. 2 student student 4096 Aug 18 10:21 Videos
|
||||
RC = 0
|
||||
[student@studentvm1 ~]$
|
||||
```
|
||||
|
||||
这个返回值是 0,表示这个命令执行成功了。现在尝试使用同样的命令在一些我们没有权限的目录上。
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ ll /root ; echo "RC = $?"
|
||||
ls: cannot open directory '/root': Permission denied
|
||||
RC = 2
|
||||
[student@studentvm1 ~]$
|
||||
```
|
||||
|
||||
这个返回值的含义可以在 [`ls` 命令的 man 页面][1] 中找到。
|
||||
|
||||
现在我们来试试 `&&` 这个控制运算符,因为它也可能会被用在一个命令行程序中。我们将从一个简单的示例开始:创建一个新目录,如果创建成功就在这个目录中创建一个文件。
|
||||
|
||||
我们需要一个目录可以创建其它的目录。首先,在你的家目录中创建一个临时的目录用来做测试。
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ cd ; mkdir testdir
|
||||
```
|
||||
|
||||
在 `~/testdir` 中新建一个目录,这也应该是一个空目录,因为是你刚刚创建的,然后创建一个新的,空文件在这个新目录中。下面的命令可以做这些事情。
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ mkdir ~/testdir/testdir2 && touch ~/testdir/testdir2/testfile1
|
||||
[student@studentvm1 ~]$ ll ~/testdir/testdir2/
|
||||
total 0
|
||||
-rw-rw-r-- 1 student student 0 Nov 12 14:13 testfile1
|
||||
[student@studentvm1 ~]$
|
||||
```
|
||||
|
||||
我们看到一切都运行得很好,因为 `testdir` 目录是访问且可写的。然后我们改变 `testdir` 目录的权限,让用户 **student** 不再具有访问的权限。操作如下:
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ chmod 076 testdir ; ll | grep testdir
|
||||
d---rwxrw-. 3 student student 4096 Nov 12 14:13 testdir
|
||||
[student@studentvm1 ~]$
|
||||
```
|
||||
|
||||
在长列表(`ll`)命令后面使用 `grep` 命令来列出 `testdir` 目录。你可以看到用户 `student` 不再有 `testdir` 目录的访问权限。现在我们像之前一样运行同样的命令,但是在 `testdir` 目录中创建的是一个不同的目录。
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ mkdir ~/testdir/testdir3 && touch ~/testdir/testdir3/testfile1
|
||||
mkdir: cannot create directory ‘/home/student/testdir/testdir3’: Permission denied
|
||||
[student@studentvm1 ~]$
|
||||
```
|
||||
|
||||
尽管我们也同样得到了一个错误的消息,但 `&&` 控制运算符阻止了 `touch` 命令的运行,因为在创建 `testdir3` 目录的时候发生了错误。通过这种复合的流控制可以阻止一些错误的发生使事情变乱。但是这样看起来变得稍微复杂了一些。
|
||||
|
||||
`||` 控制运算符允许添加另一个命令,这个命令在初始程序语句返回值大于 0 时执行。
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ mkdir ~/testdir/testdir3 && touch ~/testdir/testdir3/testfile1 || echo "An error occurred while creating the directory."
|
||||
mkdir: cannot create directory ‘/home/student/testdir/testdir3’: Permission denied
|
||||
An error occurred while creating the directory.
|
||||
[student@studentvm1 ~]$
|
||||
```
|
||||
|
||||
当我们使用 `&&` 和 `||` 控制运算符时,使用流控制的复合命令的语法格式通常是下面这样的形式。
|
||||
|
||||
```
|
||||
preceding commands ; command1 && command2 || command3 ; following commands
|
||||
```
|
||||
|
||||
使用控制运算符的复合命令可以在其它命令之前或者之后,这些和控制运算符流控制有关系,但是不受控制运算符流控制的影响。如果不考虑复合命令的流控制中发生的任何事情那么所有的命令都将执行。
|
||||
|
||||
当程序出问题时,这些流控制运算符使得在命令中处理出错和通知我们变得更有效率。我直接在命令行中使用它们,也在脚本中使用。
|
||||
|
||||
你可以以 root 用户的身份来删除这个目录和它里面的内容。
|
||||
|
||||
```
|
||||
[root@studentvm1 ~]# rm -rf /home/student/testdir
|
||||
```
|
||||
|
||||
你是怎样使用 Bash 控制运算符的呢?在评论区中告诉我们。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/11/control-operators-bash-shell
|
||||
|
||||
作者:[David Both][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[Jamskr](https://github.com/Jamskr)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/dboth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: http://man7.org/linux/man-pages/man1/ls.1.html
|
Loading…
Reference in New Issue
Block a user