diff --git a/published/20180810 Use Plank On Multiple Monitors Without Creating Multiple Docks With autoplank.md b/published/20180810 Use Plank On Multiple Monitors Without Creating Multiple Docks With autoplank.md new file mode 100644 index 0000000000..f2cfed5680 --- /dev/null +++ b/published/20180810 Use Plank On Multiple Monitors Without Creating Multiple Docks With autoplank.md @@ -0,0 +1,76 @@ +用 autoplank 在多个显示器上使用 Plank 扩展坞 +====== + +![](https://3.bp.blogspot.com/-BNHa6rP_kGk/W22cJrT3ghI/AAAAAAAABWA/TAKZgxJfYuwz-Me-M135-LWYl5qvs6cIwCLcBGAs/s640/plank-dock.png) + +[autoplank][1] 是用 Go 语言编写的小型工具,它为 Plank 扩展坞增加了多显示器支持,而无需创建[多个][2]扩展坞。 + +当你将鼠标光标移动到显示器的底部时,`autoplank` 会使用 `xdotool` 检测到你的鼠标移动,并且自动将 Plank 扩展坞移动到该显示器。该工具仅在将 Plank 设置为在屏幕底部的情况下工作(至少目前如此)。 + +在 Plank 实际出现在鼠标所在的显示器上前会稍有延迟。开发人员说这是有意设计的,以确保你确实要在该显示器上访问 Plank。显示 Plank 之前的时间延迟目前尚不可配置,但将来可能会改变。 + +`autoplank` 可以在 elementary OS 以及其它的桌面环境或发行版上使用。 + +Plank 是一个简单的扩展坞,它显示了正在运行的应用程序/窗口的图标。它允许将应用程序固定到扩展坞,并带有一些内置的简单“扩展组件”:剪贴板管理器、时钟、CPU 监视器、显示桌面和垃圾桶。要访问其设置,请按住 `Ctrl` 键,同时右键单击 Plank 扩展坞上的任意位置,然后单击 “Preferences”。 + +Plank 默认用在 elementary OS 中,但也可以在任何桌面环境或 Linux 发行版中使用。 + +### 安装 autoplank + +在其 GitHub 页面上,提到你需要 Go 1.8 或更高版本才能构建 `autoplank`,但我能够在 Ubuntu 16.04(elementary OS 0.4 Loki)中使用 Go 1.6 成功构建它。 + +开发者说: + +1、安装所需的依赖项。 + +要构建 `autoplank`,你需要 Go(在 Debian、Ubuntu、elementary OS 等中使用 golang-go)。要获取最新的 Git 代码,你还需要 `git`,要在显示器上检测你的鼠标移动,还需要安装 `xdotool`。 + +使用以下命令将它们安装在 Ubuntu、Debian、elementary OS 等中: + +``` +sudo apt install git golang-go xdotool +``` + +2、从 [Git][1] 获取最新的 `autoplank`,构建并将其安装在 `/usr/local/bin` 中: + +``` +git clone https://github.com/abiosoft/autoplank +cd autoplank +go build -o autoplank +sudo mv autoplank /usr/local/bin/ +``` + +你现在可以从主目录中删除 `autoplank` 文件夹。 + +当你想卸载 `autoplank` 时,只需删除 `/usr/local/bin/autoplank` 二进制文件(`sudo rm /usr/local/bin/autoplank`)。 + +3、将 `autoplank` 添加到启动中。 + +如果你想在将 `autoplank` 添加到启动项或为其创建 systemd 服务之前尝试使用 `autoplank`,则只需在终端中键入 `/usr/local/bin/autoplank` 即可启动它。 + +要使 `autoplank` 在重新启动后起作用,你需要将其添加到启动项中。确切的操作步骤取决于你的桌面环境,因此我不会确切告诉你如何在每个桌面环境中执行此操作,但是请记住在启动项中将 `/usr/local/bin/autoplank` 设置为可执行文件。 + +在 elementary OS 中,你可以打开“系统设置”,然后在“应用程序”的“启动”选项卡上,单击窗口左下角的“+”按钮,然后在“键入自定义命令”字段中添加 “/usr/local/bin/autoplank”: + +![](https://4.bp.blogspot.com/-hbh1PLDX-0A/W22eIhEQ1iI/AAAAAAAABWM/GkgrzaPPjA8CHnxF5L4UPPUG_vPa9VT-gCLcBGAs/s640/autoplank-startup-elementaryos.png) + +如[此处][3]的解释,使用 `autoplank` 的另一种方法是通过为其创建 systemd 服务。将 systemd 服务用于 autoplank 的优点是,无论它出于何种原因而崩溃,都可以重新启动 `autoplank`。可以使用 systemd 服务或将 `autoplank` 添加到启动应用程序中(但不要同时使用两者)。 + +4、完成此操作后,注销、登录,`autoplank` 应该已在运行,因此你可以将鼠标移至显示器底部以将 Plank 停靠此处。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxuprising.com/2018/08/use-plank-on-multiple-monitors-without.html + +作者:[Logix][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://plus.google.com/118280394805678839070 +[1]:https://github.com/abiosoft/autoplank +[2]:https://answers.launchpad.net/plank/+question/204593 +[3]:https://github.com/abiosoft/autoplank#optional-create-a-service +[4]:https://www.reddit.com/r/elementaryos/comments/95a879/autoplank_use_plank_on_multimonitor_setup/e3r9saq/ diff --git a/published/20181109 Must-Have Tools for Writers on the Linux Platform.md b/published/20181109 Must-Have Tools for Writers on the Linux Platform.md new file mode 100644 index 0000000000..c82c4f1fe2 --- /dev/null +++ b/published/20181109 Must-Have Tools for Writers on the Linux Platform.md @@ -0,0 +1,101 @@ +Linux 平台上的写作者必备工具 +====== + +![](https://img.linux.net.cn/data/attachment/album/201911/25/000129eee2zydelz22vj9h.jpg) + +我从事作家已有 20 多年了。我撰写了数千篇有关各种技术主题的文章和指南,并撰写了 40 多本小说。因此,书面文字不仅对我很重要,还很熟悉,成为了我的第二种自然交流的方式。在过去的二十年中(而且还在继续),我几乎都是在 Linux 平台上完成的所有工作。我必须承认,在早期,这并不总是那么容易。格式并不总是与编辑器所需要的相吻合,在某些情况下,开源平台根本没有完成工作所需的必要工具。 + +那时已经过去,现在已经不同了。 + +Linux 演进和基于 Web 的工具的相得益彰使得它可以让任何写作者都能在 Linux 上完成工作(并且做得很好)。但是你需要什么工具?你可能会惊讶地发现,在某些情况下,使用 100% 开源的工具无法有效完成这项工作。不过即使如此,工作总是可以完成的。让我们来看看我作为技术作家和小说作者一直使用的工具。我将通过小说和非小说类的写作过程来概述这一点(因为过程不同,需要特定的工具)。 + +对认真的 Linux 硬核用户预先做个预警。很久以前,我就放弃了使用 LaTeX 和 DocBook 之类的工具进行写作。为什么?因为对我而言,重点必须放在内容上,而不是过程上。当你面临最后期限时,必须以效率为先。 + +### 非小说类 + +我们将从非虚构写作入手,因为这是两者中较简单的过程。为了编写技术指南,我与不同的编辑人员合作,并且在某些情况下,必须将内容复制/粘贴到 CMS 中。但是就像我的小说一样,整个过程总是从 Google 云端硬盘开始。在这一点上,许多开源纯粹主义者会转身走开。不用担心,你始终可以选择将所有文件保存在本地,也可以使用更开放友好的云服务(例如 [Zoho][1] 或 [nextCloud][2])。 + +为什么要从云端开始?多年来,我发现我需要能够随时随地访问那些内容。最简单的解决方案是迁移到云上。我对丢失工作成果这件事也很偏执。为此,我使用了 [Insync][3] 之类的工具来使我的 Google 云端硬盘与桌面保持同步。有了桌面同步功能,我知道我的工作成果总是有备份,以防万一 Google 云端硬盘出了问题。 + +对于那些我必须与之一起将内容输入到内容管理系统(CMS)的客户,该过程到此结束。我可以直接从 Google 文档复制/粘贴到 CMS 中,并完成此操作。当然,对于技术内容,总是涉及到屏幕截图。为此,我使用 [Gimp][4],它使得截取屏幕截图变得简单: + +![screenshot with Gimp][6] + +*图 1:使用 Gimp 截屏。* + +1. 打开 Gimp。 +2. 单击“文件>创建>屏幕快照”。 +3. 选择单个窗口、整个屏幕或要抓取的区域(图 1)。 +4. 单击“抓取”。 + +我的大多数客户倾向于使用 Google 文档,因为我可以共享文件夹,以便他们可以可靠地访问该内容。我有一些无法使用 Google 文档的客户,因此我必须将文件下载为可以使用的格式。为此,我要做的是下载 .odt 格式,以 [LibreOffice][8] 打开文档(图 2),根据需要设置格式,保存为客户所需的格式,然后发送文档。 + +![Google Doc][10] + +*图 2:在 LibreOffice 中打开我下载的 Google 文档。* + +非小说类作品这样就行了。 + +### 小说类 + +这里会稍微变得有点复杂。开始的步骤是相同的​​,因为我总是在 Google 文档中写小说的每个初稿。完成后,我将文件下载到 Linux 桌面,在 LibreOffice 中打开文件,根据需要设置格式,然后另存为编辑器支持的文件类型(不幸的是,这意味着是 .docx)。 + +该过程的下一步变得有些琐碎。我的编辑更喜欢使用注释来跟踪更改(因为这使我们俩阅读文档和做出更改一样容易)。因此,一个 60k 的 word 文档可以包含成百上千的注释,这会使 LibreOffice 慢的像爬一样。从前,你可以增加用于文档的内存,但是从 LibreOffice 6 开始,这不再可行。这意味着任何较大的、像小说一样长的、带有大量注释的文档都将无法使用。因此,我不得不采取一些极端的措施,使用 [WPS Office][11](图 3)。尽管这不是开源解决方案,但 WPS Office 在文档中包含大量注释的情况下做得很好,因此无需处理 LibreOffice 所带来的麻烦(当处理带有数百个注释的大型文件时)。 + +![comments][13] + +*图 3:WPS 可以轻松处理大量注释。* + +一旦我和我的编辑完成了对书的编辑(所有评论都已删除),我就可以在 LibreOffice 中打开文件进行最终格式化。格式化完成后,我将文件保存为 .html 格式,然后以 [Calibre][14] 打开文件以将文件导出为 .mobi 和 .epub 格式。 + +对于希望在 Amazon、Barnes&Noble、Smashwords 或其他平台上出版的任何人,Calibre 都是必备工具。Caliber 比其他类似解决方案更好地方是,它使你可以直接编辑 .epub 文件(图 4)。对于 Smashword 来说,这是绝对必要的(因为导出过程将添加 Smashwords 转换工具上不接受的元素)。 + +![Calibre][16] + +*图 4:直接在 Calibre 中编辑 epub 文件。* + +写作过程结束后(或有时在等待编辑完成一校时),我将开始为书制作封面。该任务完全在 Gimp 中处理(图 5)。 + +![Using Gimp][19] + +*图 5:在 Gimp 中创建 POTUS 的封面。* + +这样就完成了在 Linux 平台上创建小说的过程。由于文档的篇幅以及某些编辑人员的工作方式,与创建非小说类的过程相比,它可能会变得有些复杂,但这远没有挑战性。实际上,在 Linux 上创建小说与其他平台一样简单(并且更可靠)。 + +### 希望这可以帮助你 + +我希望这可以帮助有抱负的作家有信心在 Linux 平台上进行写作。还有许多其他工具可供使用,但是多年来我在这里列出的工具很好地服务了我。而且,尽管我确实使用了几个专有的工具,但只要它们在 Linux 上都能正常运行,我觉得是可以的。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/2018/11/must-have-tools-writers-linux-platform + +作者:[Jack Wallen][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/jlwallen +[b]: https://github.com/lujun9972 +[1]: https://www.zoho.com/ +[2]: https://nextcloud.com/ +[3]: https://www.insynchq.com +[4]: https://www.gimp.org/ +[5]: /files/images/writingtools1jpg +[6]: https://lcom.static.linuxfound.org/sites/lcom/files/writingtools_1.jpg (screenshot with Gimp) +[7]: /licenses/category/used-permission +[8]: https://www.libreoffice.org/ +[9]: /files/images/writingtools2jpg +[10]: https://lcom.static.linuxfound.org/sites/lcom/files/writingtools_2.jpg (Google Doc) +[11]: https://www.wps.com/en-US/ +[12]: /files/images/writingtools3jpg +[13]: https://lcom.static.linuxfound.org/sites/lcom/files/writingtools_3.jpg (comments) +[14]: https://calibre-ebook.com/ +[15]: /files/images/writingtools4jpg +[16]: https://lcom.static.linuxfound.org/sites/lcom/files/writingtools_4.jpg (Calibre) +[17]: /licenses/category/creative-commons-zero +[18]: /files/images/writingtools5jpg +[19]: https://lcom.static.linuxfound.org/sites/lcom/files/writingtools_5.jpg (Using Gimp) +[20]: https://training.linuxfoundation.org/training/introduction-to-open-source-development-git-and-linux/?utm_source=linux.com&utm_medium=article&utm_campaign=lfd201 diff --git a/published/20190328 Can Better Task Stealing Make Linux Faster.md b/published/20190328 Can Better Task Stealing Make Linux Faster.md new file mode 100644 index 0000000000..338343daee --- /dev/null +++ b/published/20190328 Can Better Task Stealing Make Linux Faster.md @@ -0,0 +1,77 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11607-1.html) +[#]: subject: (Can Better Task Stealing Make Linux Faster?) +[#]: via: (https://www.linux.com/blog/can-better-task-stealing-make-linux-faster) +[#]: author: (Oracle ) + +更好的任务窃取可以使 Linux 更快吗? +====== + +![](https://img.linux.net.cn/data/attachment/album/201911/23/235729l71755he6e4mpvkq.jpg) + +> Oracle Linux 内核开发人员 Steve Sistare 参与了这场有关内核调度程序改进的讨论。 + +### 通过可扩展的任务窃取进行负载平衡 + +Linux 任务调度程序通过将唤醒的任务推送到空闲的 CPU,以及在 CPU 空闲时从繁忙的 CPU 中拉取任务来平衡整个系统的负载。在大型系统上的推送侧和拉取侧,有效的伸缩都是挑战。对于拉取,调度程序搜索连续的更大范围中的所有 CPU,直到找到过载的 CPU,然后从最繁忙的组中拉取任务。这代价非常昂贵,在大型系统上要花费 10 到 100 微秒,因此搜索时间受到平均空闲时间的限制,并且某些范围不会被搜索。并非总能达到平衡,而且闲置的 CPU 依旧闲置。 + +我实现了一种备用机制,该机制在 `idle_balance()` 中的现有搜索中自身受限并且没有找到之后被调用。我维护了一个过载的 CPU 的位图,当可运行的 CFS 任务计数超过 1 时,CPU 会设置该位。这个位图是稀疏的,每个高速缓存线的有效位数量有限。当许多线程同时设置、清除和访问元素时,这可以减少缓存争用。每个末级缓存都有一个位图。当 CPU 空闲时,它将搜索该位图以查找第一个具有可迁移任务的过载 CPU,然后将其窃取。这种简单的窃取会比单独的 `idle_balance()` 产生更高的 CPU 利用率,因为该搜索的成本很便宜,花费 1 到 2 微秒,因此每次 CPU 即将空闲时都可以调用它。窃取不会减轻全局最繁忙的队列的负担,但是它比根本不执行任何操作要好得多。 + +### 结果 + +偷窃仅在调度程序代码中占用少量 CPU 开销即可提高利用率。在以下实验中,以不同数量的组(每个组 40 个任务)运行 hackbench,并对每次运行结果显示 `/proc/schedstat` 中的增量(按 CPU 平均),并增加了这些非标准的统计信息: + +* `%find`:在旧函数和新函数中花费的时间百分比,这些函数用于搜索空闲的 CPU 和任务以窃取并设置过载的 CPU 位图。 +* `steal`:任务从另一个 CPU 窃取的次数。经过的时间增加了 8% 到 36%,最多增加了 0.4% 的发现时间。 + +![load balancing][1] + +​​如下图的绿色曲线所示,新内核的 CPU 繁忙利用率接近 100%,作为比较的基线内核是橙色曲线: +​​ +![][3] + +根据负载的不同,窃取可将 Oracle 数据库 OLTP 性能提高多达 9%,并且我们已经看到 MySQL、Pgsql、gcc、Java 和网络方面有了一些不错的改进。通常,窃取对上下文切换率高的工作负载最有帮助。 + +### 代码 + +截至撰写本文时,这项工作尚未完成,但最新的修补程序系列位于 [https://lkml.org/lkml/2018/12/6/1253][4]。如果你的内核是使用 `CONFIG_SCHED_DEBUG=y` 构建的,则可以使用以下命令验证其是否包含窃取优化: + +``` +# grep -q STEAL /sys/kernel/debug/sched_features && echo Yes +Yes +``` + +如果要尝试使用,请注意,对于具有 2 个以上 NUMA 节点的系统,禁用了窃取功能,因为 hackbench 在此类系统上发生了回归,正如我在 [https://lkml.org/lkml/2018/12/6/1250][5] 中解释的那样。但是,我怀疑这种影响是特定于 hackbench 的,并且窃取将有助于多节点系统上的其他工作负载。要尝试使用它,请用内核参数 `sched_steal_node_limit=8`(或更大)重新启动。 + +### 进一步工作 + +在将基本盗用算法推向上游之后,我正在考虑以下增强功能: + +* 如果在末级缓存中进行窃取找不到候选者,在 LLC 和 NUMA 节点之间进行窃取。 +* 维护稀疏位图以标识 RT 调度类中的偷窃候选者。当前 `pull_rt_task()` 搜索所有运行队列。 +* 从 `idle_balance()` 中删除核心和套接字级别,因为窃取会处理这些级别。当支持跨 LLC 窃取时,完全删除 `idle_balance()`。 +* 维护位图以标识空闲核心和空闲 CPU,以实现推平衡。 + +这篇文章最初发布于 [Oracle Developers Blog][6]。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/can-better-task-stealing-make-linux-faster + +作者:[Oracle][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/author/oracle/ +[b]: https://github.com/lujun9972 +[1]: https://lcom.static.linuxfound.org/sites/lcom/files/linux-load-balancing.png (load balancing) +[3]: https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/b7a700fe-edc3-4ea0-876a-c91e1850b59b/Image/00c074f4282bcbaf0c10dd153c5dfa76/steal_graph.png +[4]: https://lkml.org/lkml/2018/12/6/1253 +[5]: https://lkml.org/lkml/2018/12/6/1250 +[6]: https://blogs.oracle.com/linux/can-better-task-stealing-make-linux-faster diff --git a/published/20190404 Why blockchain (might be) coming to an IoT implementation near you.md b/published/20190404 Why blockchain (might be) coming to an IoT implementation near you.md new file mode 100644 index 0000000000..4a23ddda05 --- /dev/null +++ b/published/20190404 Why blockchain (might be) coming to an IoT implementation near you.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11575-1.html) +[#]: subject: (Why blockchain (might be) coming to an IoT implementation near you) +[#]: via: (https://www.networkworld.com/article/3386881/why-blockchain-might-be-coming-to-an-iot-implementation-near-you.html) +[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) + +为什么区块链(可能会)来到你身边的物联网 +====== + +![MF3D / Getty Images][1] + +各个公司发现,物联网与最近其他许多流行的企业级计算技术有着良好的合作关系,以支持加密货币而闻名的创新的分布式信任系统的区块链也不例外。然而,在物联网应用中实施区块链可能具有挑战性,并且需要对技术有深入的了解。 + +区块链是一个跟踪各种交易的分布式账本。链上的每个“块”都包含要防止篡改的交易记录或其他数据,并通过加密散列链接到前一个,这意味着对块的任何篡改都将使该链接无效。节点(几乎可以是其中装有 CPU 的任何节点)通过分布式的对等网络进行通信,以共享数据并确保链中数据的有效性。 + +北卡罗来纳大学格林波若分校的管理学教授 Nir Kshetri 表示,区块链系统之所以有效,是因为所有的块都必须就它们所保护的数据的细节达成一致。如果有人尝试更改给定节点上先前的事务,则存储在网络上的其余数据会回推回来。“数据的旧记录仍然存在,” Kshetri 说。 + +这是一项强大的安全技术 —— 如果没有坏人成功控制给定区块链上的所有(LCTT 译注:应为“大部分”)节点([著名的“51% 攻击”][4]),那么该区块链保护的数据就不会被伪造或以其他方式弄乱。因此,对于在物联网世界某些角落的公司来说,使用区块链是一种有吸引力的选择也就不足为奇了。 + +物联网安全初创企业 NXMLabs 的首席技术官兼联合创始人 Jay Fallah 认为,除了区块链能够在网络上安全地分发可信信息的能力这一事实之外,部分原因还在于区块链在技术堆栈中的地位。 + +“区块链站在一个非常有趣的交叉点。在过去的 15 年中,在存储、CPU 等方面,计算技术一直在加速发展,但是直到最近,网络技术并没有发生太大变化。”他说,“ 区块链不是网络技术、不是数据技术,而是二者兼具。” + +### 区块链和物联网 + +区块链作为物联网世界的部分意义取决于你在和谁交谈以及他们在出售什么,但是最接近的概括可能来自企业区块链供应商 Filament 的首席执行官 Allison Clift-Jenning。 + +她说:“在任何地方,人们都想互相信任,并且用的是非常古老的方式,这通常是进入场景的好地方。” + +直接从 Filament 自己的客户群中挑选出来的一个例子是二手车销售。Filament 与“一家主要的底特律汽车制造商”合作,创建了一个受信任的车辆历史平台,该平台基于一种设备,该设备可插入二手车的诊断端口,从那里获取信息,并将该数据写入区块链。像这样,二手车的历史记录就是不可变的,包括它的安全气囊是否曾经打开过,是否被水淹过等等。任何不道德的二手车或不诚实的前车主都无法更改数据,甚至拔掉设备也将意味着记录中存在可疑的空白期。 + +SAP 物联网高级副总裁兼全球负责人 Elvira Wallis 表示,当今大多数区块链物联网方案都与信任和数据验证有关。 + +她说:“我们遇到的大多数用例都在项目的跟踪和溯源领域,”她举例说明了高端食品的农场到餐桌跟踪系统,该系统使用安装在板条箱和卡车上的区块链节点,这样就可以为物品在运输基础设施中创建无懈可击的记录。(例如,该牛排在这样的温度下冷藏了多长时间,今天运输了多长时间,等等。) + +### 将区块链与物联网一起使用是个好主意吗? + +不同的供应商针对不同的用例出售不同的基于区块链的产品,这些产品使用不同的区块链技术实现,其中一些与加密货币中所使用的经典的、线性的、挖矿式交易区块链不太一样。 + +这意味着你目前需要从供应商那里购买特定功能。451 Research 高级分析师 Csilla Zsigri 表示,很少有客户组织拥有可以实施区块链安全系统的内部专家。 + +她说,区块链技术的任何智能应用的想法都是发挥其优势,为关键信息创建可信赖的平台。 + +Zsigri 说:“这就是我真正看到增值的地方,只是增加了一层信任和验证。” + +专家们一致认为,尽管相当了解基于区块链的物联网应用程序的基本概念,但它并不适用于每个物联网用例。 将区块链应用于非交易系统(尽管有例外,包括 NXM Labs 的用于物联网设备的基于区块链配置的产品)通常不是正确的举动。 + +如果不需要在两个不同的参与方之间共享数据,而是简单地将数据从传感器移到后端,那么区块链通常就没有意义,因为它实际上并没有为当前大多数物联网实现中的数据分析增加任何关键的增值。 + +“今天,我们仍处于区块链的早期拨号时代。”Clift-Jennings 说,“它比典型的数据库要慢,它甚至无法读取,也常常没有查询引擎。从本质上讲,你并没有真正获得隐私。” + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3386881/why-blockchain-might-be-coming-to-an-iot-implementation-near-you.html + +作者:[Jon Gold][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Jon-Gold/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/02/chains_binary_data_blockchain_security_by_mf3d_gettyimages-941175690_2400x1600-100788434-large.jpg +[2]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html +[3]: https://www.networkworld.com/article/3291790/data-center/how-edge-networking-and-iot-will-reshape-data-centers.html +[4]: https://bitcoinist.com/51-percent-attack-hackers-steals-18-million-bitcoin-gold-btg-tokens/ +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/20190610 Why containers and Kubernetes have the potential to run almost anything.md b/published/20190610 Why containers and Kubernetes have the potential to run almost anything.md new file mode 100644 index 0000000000..50b74ce4a8 --- /dev/null +++ b/published/20190610 Why containers and Kubernetes have the potential to run almost anything.md @@ -0,0 +1,63 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11565-1.html) +[#]: subject: (Why containers and Kubernetes have the potential to run almost anything) +[#]: via: (https://opensource.com/article/19/6/kubernetes-potential-run-anything) +[#]: author: (Scott McCarty https://opensource.com/users/fatherlinux) + +为什么容器和 Kubernetes 有潜力运行一切 +====== + +> 不仅可以部署简单的应用程序,还可以用 Kubernetes 运维器应对第 2 天运营。 + +![](https://img.linux.net.cn/data/attachment/album/201911/12/011140mp75sd0ynppd77da.jpg) + +在我的第一篇文章 [为什么说 Kubernetes 是一辆翻斗车][2] 中,我谈到了 Kubernetes 如何在定义、分享和运行应用程序方面很出色,类似于翻斗车在移动垃圾方面很出色。在第二篇中,[如何跨越 Kubernetes 学习曲线][3],我解释了 Kubernetes 的学习曲线实际上与运行任何生产环境中的应用程序的学习曲线相同,这确实比学习所有传统组件要容易(如负载均衡器、路由器、防火墙、交换机、集群软件、集群文件系统等)。这是 DevOps,是开发人员和运维人员之间的合作,用于指定事物在生产环境中的运行方式,这意味着双方都需要学习。在第三篇 [Kubernetes 基础:首先学习如何使用][4] 中,我重新设计了 Kubernetes 的学习框架,重点是驾驶翻斗车而不是制造或装备翻斗车。在第四篇文章 [帮助你驾驭 Kubernetes 的 4 个工具][5] 中,我分享了我喜爱的工具,这些工具可帮助你在 Kubernetes 中构建应用程序(驾驶翻斗车)。 + +在这最后一篇文章中,我会分享我为什么对在 Kubernetes 上运行应用程序的未来如此兴奋的原因。 + +从一开始,Kubernetes 就能够很好地运行基于 Web 的工作负载(容器化的)。Web 服务器、Java 和相关的应用程序服务器(PHP、Python等)之类的工作负载都可以正常工作。该平台处理诸如 DNS、负载平衡和 SSH(由 `kubectl exec` 取代)之类的支持服务。在我的职业生涯的大部分时间里,这些都是我在生产环境中运行的工作负载,因此,我立即意识到,除了 DevOps 之外,除了敏捷之外,使用 Kubernetes 运行生产环境工作负载的强大功能。即使是我们几乎不改变我们的文化习惯,也可以提高效率。调试和退役变得非常容易,而这对于传统 IT 来说是极为困难的。因此,从早期开始,Kubernetes 就用一种单一的配置语言(Kube YAML/Json)为我提供了对生产环境工作负载进行建模所需的所有基本原语。 + +但是,如果你需要运行具有复制功能的多主 MySQL,会发生什么情况?使用 Galera 的冗余数据呢?你如何进行快照和备份?那么像 SAP 这样复杂的工作呢?使用 Kubernetes,简单的应用程序(Web 服务器等)的第 0 天(部署)相当简单,但是没有解决第 2 天的运营和工作负载。这并不是说,具有复杂工作负载的第 2 天运营要比传统 IT 难解决,而是使用 Kubernetes 并没有使它们变得更容易。每个用户都要设计自己的天才想法来解决这些问题,这基本上是当今的现状。在过去的五年中,我遇到的第一类问题是复杂工作负载的第 2 天操作。(LCTT 译注:在软件生命周期中,第 0 天是指软件的设计阶段;第 1 天是指软件的开发和部署阶段;第 2 天是指生产环境中的软件运维阶段。) + +值得庆幸的是,随着 Kubernetes 运维器Operator的出现,这种情况正在改变。随着运维器的出现,我们现在有了一个框架,可以将第 2 天的运维知识汇总到平台中。现在,我们可以应用我在 [Kubernetes 基础:首先学习如何使用][4] 中描述的相同的定义状态、实际状态的方法,现在我们可以定义、自动化和维护各种各样的系统管理任务。 + +(LCTT 译注: Operator 是 Kubernetes 中的一种可以完成运维工程师的特定工作的组件,业界大多没有翻译这个名词,此处仿运维工程师例首倡翻译为“运维器”。) + +我经常将运维器称为“系统管理机器人”,因为它们实质上是在第 2 天的工作中整理出一堆运维知识,该知识涉及主题专家Subject Matter Expert(SME、例如数据库管理员或系统管理员)针对的工作负载类型(数据库、Web 服务器等),通常会记录在 Wiki 中的某个地方。这些知识放在 Wiki 中的问题是,为了将该知识应用于解决问题,我们需要: + +1. 生成事件,通常监控系统会发现故障,然后我们创建故障单 +2. SME 人员必须对此问题进行调查,即使这是我们之前见过几百万次的问题 +3. SME 人员必须执行该知识(执行备份/还原、配置 Galera 或事务复制等) + +通过运维器,所有这些 SME 知识都可以嵌入到单独的容器镜像中,该镜像在有实际工作负荷之前就已部署。 我们部署运维器容器,然后运维器部署和管理一个或多个工作负载实例。然后,我们使用“运维器生命周期管理器”(Katacoda 教程)之类的方法来管理运维器。 + +因此,随着我们进一步使用 Kubernetes,我们不仅简化了应用程序的部署,而且简化了整个生命周期的管理。运维器还为我们提供了工具,可以管理具有深层配置要求(群集、复制、修复、备份/还原)的非常复杂的有状态应用程序。而且,最好的地方是,构建容器的人员可能是做第 2 天运维的主题专家,因此现在他们可以将这些知识嵌入到操作环境中。 + +### 本系列的总结 + +Kubernetes 的未来是光明的,就像之前的虚拟化一样,工作负载的扩展是不可避免的。学习如何驾驭 Kubernetes 可能是开发人员或系统管理员可以对自己的职业发展做出的最大投资。随着工作负载的增多,职业机会也将增加。因此,这是驾驶一辆令人惊叹的 [在移动垃圾时非常优雅的翻斗车][2]…… + +你可能想在 Twitter 上关注我,我在 [@fatherlinux][6] 上分享有关此主题的很多内容。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/kubernetes-potential-run-anything + +作者:[Scott McCarty][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/fatherlinux +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fail_progress_cycle_momentum_arrow.png?itok=q-ZFa_Eh (arrows cycle symbol for failing faster) +[2]: https://opensource.com/article/19/6/kubernetes-dump-truck +[3]: https://opensource.com/article/19/6/kubernetes-learning-curve +[4]: https://opensource.com/article/19/6/kubernetes-basics +[5]: https://opensource.com/article/19/6/tools-drive-kubernetes +[6]: https://twitter.com/fatherlinux diff --git a/published/20190718 What you need to know to be a sysadmin.md b/published/20190718 What you need to know to be a sysadmin.md new file mode 100644 index 0000000000..02361c4766 --- /dev/null +++ b/published/20190718 What you need to know to be a sysadmin.md @@ -0,0 +1,122 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11608-1.html) +[#]: subject: (What you need to know to be a sysadmin) +[#]: via: (https://opensource.com/article/19/7/be-a-sysadmin) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +你需要知道什么才能成为系统管理员? +====== + +> 通过获得这些起码的能力,开始你的系统管理员职业。 + +![](https://img.linux.net.cn/data/attachment/album/201911/24/103900w5m09jyyyeyrnovu.jpg) + +昔日的系统管理员整天都在调教用户和摆弄服务器,一天的时间都奔波在几百米长的电缆之间。随着云计算、容器和虚拟机的复杂性的增加,而今依然如此。 + +以外行人来看,很难准确确定系统管理员的确切职能,因为他们在许多地方都扮演着一个不起眼的角色。没人能在培训中知道自己工作中所需要的一切知识,但是每个人其实都需要一个坚实的基础。如果你想走上系统管理的道路,那么这是你个人自学或在正式培训中应重点关注的内容。 + +### Bash + +当你学习 Bash Shell 时,你学习的不仅是 Bash Shell,你学习的也是 Linux、BSD、MacOS 甚至Windows(在适当条件下)的通用界面。你将了解语法的重要性,因此可以快速适应思科路由器的命令行或微软 PowerShell 等系统,最终你甚至可以学习更强大的语言,如 Python 或 Go。而且,你还会开始进行程序性思考,以便可以分析复杂的问题并将其分解为单个组件,这很关键,因为这就是系统(例如互联网、组织的内部网、Web 服务器、备份解决方案)是如何设计的。 + +不止于此,还有更多。 + +由于最近 DevOps 和[容器][2]的发展趋势,了解 Bash shell 变得尤为重要。你的系统管理员职业可能会将你带入一个视基础设施为代码的世界,这通常意味着你必须了解脚本编写的基础知识、[基于 YAML][3]配置的结构,以及如何与[容器][5](运行在[沙盒文件][6]内部的微型 Linux 系统)[交互][4]。你会知道 Bash 是高效管理激动人心的开源技术的门户,因此请进入 [Bash][7] 世界吧。 + +#### 资源 + +有很多方法可以在 Bash shell 中进行练习。 + +尝试一下[便携式 Linux 发行版][8]。你无需安装 Linux 即可使用 Linux,因此,请拿一块闲置的 U 盘,花个晚上或周末的空闲时光,来适应基于文本的界面。 + +这里有[几篇很棒的][10] [Bash 文章][9]。 + +要注意的是 Bash 练习的关键在于要练习,你必须有要做的练习才行。而且,在你知道如何使用 Bash 之前,你可能不知道该练习什么。如果是这样,请去 Over The Wire 玩一下 [Bandit][11] 游戏。这是一款针对绝对初学者的游戏,具有 34 个级别的交互式基本技巧,可让你熟悉 Linux shell。 + +### Web 服务器设置 + +一旦你习惯了 Bash,你应该尝试设置一个 Web 服务器。并不是所有的系统管理员都会四处设置 Web 服务器甚至维护 Web 服务器,但是你在安装和启动 HTTP 守护程序、配置 Apache 或 Nginx,设置[正确权限][12]和[配置防火墙][13]时所掌握的技能是你每天都需要使用的技能。经过一些努力,你可能会开始注意到自己的某些工作模式。在尝试管理可用于生产环境的软件和硬件之前,你可能认为某些概念是理所当然的,而你在成为新手的管理员角色时,将不再受到它们的影响。起初这可能会令人沮丧,因为每个人都喜欢在自己做好所做的事情,但这实际上是一件好事。让自己接触新技能,那就是你学习的方式。 + +此外,你在第一步中付出的努力越多,最终当你在默认的 index.html 上看到胜利的“it works!”就越甜蜜! + +#### 资源 + +David Both 撰写了有关 [Apache Web 服务器][14]配置的出色文章。值得一提的是,请逐步阅读他的后续文章,其中介绍了如何在一台计算机上[托管多个站点][15]。 + +### DHCP + +动态主机配置协议(DHCP)是为网络上的设备分配 IP 地址的系统。在家里,ISP(互联网服务提供商)支持的调制解调器或路由器可能内置了 DHCP 服务器,因此可能不在你的权限范围内。如果你曾经登录家用路由器来调整 IP 地址范围或为某些网络设备设置了静态地址,那么你至少对该概念有所了解。你可能会将其理解为对网络上的设备分配了一种 IP 地址形式的电话号码,并且你可能会意识到计算机之间通过广播发送到特定 IP 地址的消息彼此进行通信。消息标头由路径上的路由器读取,每个消息标头都将消息定向到路径上的第二个逻辑路由器,以达到其最终目标。 + +即使你了解了这些概念,要从对 DHCP 的基本了解再进一步是架设 DHCP 服务器。安装和配置自己的 DHCP 服务器可能会导致家庭网络中的 DHCP 冲突(如果可以的话,请尽量避免这样做,因为它肯定会干掉你的网络,直到解决为止),要控制地址的分配、创建子网,并监控连接和租赁时间。 + +更重要的是,设置 DHCP 并尝试不同的配置有助于你了解网络之间的关系。你会了解网络如何在数据传输中表示“分区”,以及必须采取哪些步骤才能将信息从一个网络传递到另一个。这对于系统管理员来说至关重要,因为网络肯定是工作中最重要的方面之一。 + +#### 资源 + +在运行自己的 DHCP 服务器之前,请确保家庭路由器(如果有)中的 DHCP 服务器处于非活动状态。一旦启动并运行了 DHCP 服务器,请阅读 Archit Modi 的[网络命令指南][16],以获取有关如何探索网络的提示。 + +### 网络电缆 + +这听起来很普通,但是熟悉网络电缆的工作方式不仅使你的周末变得非常有趣,而且还使你对数据是如何通过缆线的得到了全新的了解。最好的学习方法是去当地的业余爱好商店并购买五类线剥线钳和压线钳以及一些五类线水晶头。然后回家,拿一根备用的以太网电缆,切断水晶头,花一些时间重新制作网线接头,将电缆重新投入使用。 + +解决了这个难题后,请再做一次,这次创建一条有效的[交叉电缆][17]。 + +你现在应该还在沉迷于有关电缆管理。如果你有些强迫症,喜欢沿着地板线或桌子的边缘整齐地排列电缆,或者将电缆绑在一起以保持它们的整齐有序,那么就可以使自己免受永久混乱的电缆困扰。你一开始可能不会理解这样做的必要性,但是当你第一次走进服务器机房时,你会马上知道原因。 + +### Ansible + +[Ansible][18] 是配置管理软件,它在系统管理员和 DevOps 之间架起了一座桥梁。系统管理员使用 Ansible 来配置全新安装的操作系统并在计算机上维护特定的状态。DevOps 使用 Ansible 减少了在工具上花费的时间和精力,从而在开发上可以花费更多的时间和精力。作为系统管理员培训的一部分,你应该学习 Ansible,并着眼于 DevOps 实践,因为 DevOps 现在开创的大多数功能将最终成为将来系统管理中工作流的一部分。 + +Ansible 的好处是你可以立即开始使用它。它是跨平台的,并且可以向上和向下缩放。对于单用户计算机, Ansible 可能是小题大做,但是话又说回来,Ansible 可能会改变你启动虚拟机的方式,或者可以帮助你同步家庭或[家庭实验室][19]中所有计算机的状态。 + + +#### 资源 + +阅读 Jay LaCroix 的[如何使用 Ansible 管理工作站配置][20]中的典型介绍,以轻松地在日常之中开始使用 Ansible。 + +### 破坏 + +由于用户的错误、软件的错误、管理员(就是你!)的错误以及许多其他因素,计算机上会出现问题。无法预测将要失败的原因,因此你的个人系统管理员培训制度的一部分应该是破坏你设置的系统,直到它们失败为止。你自己的实验室基础设施越是脆弱,发现弱点的可能性就越大。而且,你越是经常修复这些弱点,你对解决问题的能力就越有信心。 + +除了严格设置所有常见的软件和硬件之外,作为系统管理员的主要工作是查找解决方案。有时候,你可能会遇到职位描述之外的问题,甚至可能无法解决,但这完全取决于你的解决方法。 + +现在,你越多地折腾并努力加以解决,则以系统管理员的身份进行的准备就越充分。 + +你是系统管理员吗?你是否希望自己为更好的任务做好准备?在下面的评论中写下它们! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/be-a-sysadmin + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux11x_cc.png?itok=XMDOouJR (People work on a computer server with devices) +[2]: https://opensource.com/article/19/6/kubernetes-dump-truck +[3]: https://www.redhat.com/sysadmin/yaml-tips +[4]: https://opensource.com/article/19/6/how-ssh-running-container +[5]: https://opensource.com/resources/what-are-linux-containers +[6]: https://opensource.com/article/18/11/behind-scenes-linux-containers +[7]: https://opensource.com/article/18/7/admin-guide-bash +[8]: https://opensource.com/article/19/6/linux-distros-to-try +[9]: https://opensource.com/tags/bash +[10]: https://www.redhat.com/sysadmin/managing-files-linux-terminal +[11]: http://overthewire.org/wargames/bandit +[12]: https://opensource.com/article/19/6/understanding-linux-permissions +[13]: https://www.redhat.com/sysadmin/secure-linux-network-firewall-cmd +[14]: https://opensource.com/article/18/2/how-configure-apache-web-server +[15]: https://opensource.com/article/18/3/configuring-multiple-web-sites-apache +[16]: https://opensource.com/article/18/7/sysadmin-guide-networking-commands +[17]: https://en.wikipedia.org/wiki/Ethernet_crossover_cable +[18]: https://opensource.com/sitewide-search?search_api_views_fulltext=ansible +[19]: https://opensource.com/article/19/6/create-centos-homelab-hour +[20]: https://opensource.com/article/18/3/manage-workstation-ansible diff --git a/published/20190801 Linux permissions 101.md b/published/20190801 Linux permissions 101.md new file mode 100644 index 0000000000..b64c6f314a --- /dev/null +++ b/published/20190801 Linux permissions 101.md @@ -0,0 +1,322 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11553-1.html) +[#]: subject: (Linux permissions 101) +[#]: via: (https://opensource.com/article/19/8/linux-permissions-101) +[#]: author: (Alex Juarez https://opensource.com/users/mralexjuarezhttps://opensource.com/users/marcobravohttps://opensource.com/users/greg-p) + +全面介绍 Linux 权限 +====== + +> 知道如何控制用户对文件的访问是一项基本的系统管理技能。 + +![](https://img.linux.net.cn/data/attachment/album/201911/08/233101y043rn4ua00r3lqn.jpg) + +了解 Linux 权限以及如何控制哪些用户可以访问文件是系统管理的一项基本技能。 + +本文将介绍标准 Linux 文件系统权限,并进一步研究特殊权限,以及使用 `umask` 来解释默认权限作为文章的结束。 + +### 理解 ls 命令的输出 + +在讨论如何修改权限之前,我们需要知道如何查看权限。通过 `ls` 命令的长列表参数(`-l`)为我们提供了有关文件的许多信息。 + +``` +$ ls -lAh +total 20K +-rwxr-xr--+ 1 root root    0 Mar  4 19:39 file1 +-rw-rw-rw-. 1 root root    0 Mar  4 19:39 file10 +-rwxrwxr--+ 1 root root    0 Mar  4 19:39 file2 +-rw-rw-rw-. 1 root root    0 Mar  4 19:39 file8 +-rw-rw-rw-. 1 root root    0 Mar  4 19:39 file9 +drwxrwxrwx. 2 root root 4.0K Mar  4 20:04 testdir +``` + +为了理解这些是什么意思,让我们将关于权限的输出分解为各个部分。单独理解每个部分会更容易。 + +让我们看看在上面的输出中的最后一行的每个组件: + +``` +drwxrwxrwx. 2 root root 4.0K Mar  4 20:04 testdir +``` + +第 1 节 | 第 2 节 | 第 3 节 | 第 4 节 | 第 5 节 | 第 6 节 | 第 7 节 +---|---|---|---|---|---|--- +`d` | `rwx` | `rwx` | `rwx` | `.` | `root` | `root` + +第 1 节(左侧)显示文件的类型。 + +符号 | 类型 +---|--- +`d` | 目录 +`-` | 常规文件 +`l` | 软链接 + +`ls` 的 [info 页面][2]完整列出了不同的文件类型。 + +每个文件都有三种访问方式: + +* 属主 +* 组 +* 所有其他人 +   +第 2、3 和 4 节涉及用户(属主)、组和“其他用户”权限。每个部分都可以包含 `r`(读取)、`w`(写入)和 `x`(执行)权限的组合。 + +每个权限还分配了一个数值,这在以八进制表示形式讨论权限时很重要。 + +权限 | 八进制值 +---|--- +`r` | 4 +`w` | 2 +`x` | 1 + +第 5 节描述了其他替代访问方法,例如 SELinux 或文件访问控制列表(FACL)。 + +访问方法 | 字符 +---|--- +没有其它访问方法 | `-` +SELinux | `.` +FACL | `+` +各种方法的组合 | `+` + +第 6 节和第 7 节分别是属主和组的名称。 + +### 使用 chown 和 chmod + +#### chown 命令 + +`chown`(更改所有权)命令用于更改文件的用户和组的所有权。 + +要将文件 `foo` 的用户和组的所有权更改为 `root`,我们可以使用以下命令: + +``` +$ chown root:root foo +$ chown root: foo +``` + +在用户名后跟冒号(`:`)运行该命令将同时设置用户和组所有权。 + +要仅将文件 `foo` 的用户所有权设置为 `root` 用户,请输入: + +``` +$ chown root foo +``` + +要仅更改文件 `foo` 的组所有权,请在组之前加冒号: + +``` +$ chown :root foo +``` + +#### chmod 命令 + +`chmod`(更改模式)命令控制属主、组以及既不是属主也不属于与文件关联的组的所有其他用户的文件许可权。 + +`chmod` 命令可以以八进制(例如 `755`、`644` 等)和符号(例如 `u+rwx`、`g-rwx`、`o=rw`)格式设置权限。 + +八进制表示法将 4 个“点”分配给“读取”,将 2 个“点”分配给“写入”,将 1 个点分配给“执行”。如果要给用户(属主)分配“读取”权限,则将 4 分配给第一个插槽,但是如果要添加“写入”权限,则必须添加 2。如果要添加“执行”,则要添加 1。我们对每种权限类型执行此操作:属主、组和其他。 + +例如,如果我们想将“读取”、“写入”和“执行”分配给文件的属主,但仅将“读取”和“执行”分配给组成员和所有其他用户,则我们应使用 `755`(八进制格式)。这是属主的所有权限位(`4+2+1`),但组和其他权限的所有权限位只有 `4` 和 `1`(`4+1`)。 + +> 细分为:4+2+1=7,4+1=5 和 4+1=5。 + +如果我们想将“读取”和“写入”分配给文件的属主,而只将“读取”分配给组的成员和所有其他用户,则可以如下使用 `chmod`: + +``` +$ chmod 644 foo_file +``` + +在下面的示例中,我们在不同的分组中使用符号表示法。注意字母 `u`、`g` 和 `o` 分别代表“用户”(属主)、“组”和“其他”。我们将 `u`、`g` 和 `o` 与 `+`、`-` 或 `=` 结合使用来添加、删除或设置权限位。 + +要将“执行”位添加到所有权权限集中: + +``` +$ chmod u+x foo_file +``` + +要从组成员中删除“读取”、“写入”和“执行”: + +``` +$ chmod g-rwx foo_file +``` + +要将所有其他用户的所有权设置为“读取”和“写入”: + +``` +$ chmod o=rw +``` + +### 特殊位:设置 UID、设置 GID 和粘滞位 + +除了标准权限外,还有一些特殊的权限位,它们具有一些别的用处。 + +#### 设置用户 ID(suid) + +当在文件上设置 `suid` 时,将以文件的属主的身份而不是运行该文件的用户身份执行操作。一个[好的例子][3]是 `passwd` 命令。它需要设置 `suid` 位,以便更改密码的操作具有 root 权限。 + +``` +$ ls -l /bin/passwd +-rwsr-xr-x. 1 root root 27832 Jun 10  2014 /bin/passwd +``` + +设置 `suid` 位的示例: + +``` +$ chmod u+s /bin/foo_file_name +``` + +#### 设置组 ID(sgid) + +`sgid` 位与 `suid` 位类似,操作是在目录的组所有权下完成的,而不是以运行命令的用户身份。 + +一个使用 `sgid` 的例子是,如果多个用户正在同一个目录中工作,并且目录中创建的每个文件都需要具有相同的组权限。下面的示例创建一个名为 `collab_dir` 的目录,设置 `sgid` 位,并将组所有权更改为 `webdev`。 + +``` +$ mkdir collab_dir +$ chmod g+s collab_dir +$ chown :webdev collab_dir +``` + +现在,在该目录中创建的任何文件都将具有 `webdev` 的组所有权,而不是创建该文件的用户的组。 + +``` +$ cd collab_dir +$ touch file-sgid +$ ls -lah file-sgid +-rw-r--r--. 1 root webdev 0 Jun 12 06:04 file-sgid +``` + +#### “粘滞”位 + +粘滞位表示,只有文件所有者才能删除该文件,即使组权限允许该文件可以删除。通常,在 `/tmp` 这样的通用或协作目录上,此设置最有意义。在下面的示例中,“所有其他人”权限集的“执行”列中的 `t` 表示已应用粘滞位。 + +``` +$ ls -ld /tmp +drwxrwxrwt. 8 root root 4096 Jun 12 06:07 /tmp/ +``` + +请记住,这不会阻止某个人编辑该文件,它只是阻止他们删除该目录的内容(LCTT 译注:即删除目录下文件)。 + +我们将粘滞位设置为: + +``` +$ chmod o+t foo_dir +``` + +你可以自己尝试在目录上设置粘滞位并赋予其完整的组权限,以便多个属于同一组的用户可以在目录上进行读取、写入和执行。 + +接着,以每个用户的身份创建文件,然后尝试以另一个用户的身份删除它们。 + +如果一切配置正确,则一个用户应该不能从另一用户那里删除文件。 + +请注意,这些位中的每个位也可以用八进制格式设置:SUID = 4、SGID = 2 和 粘滞位 = 1。(LCTT 译注:这里是四位八进制数字) + +``` +$ chmod 4744 +$ chmod 2644 +$ chmod 1755 +``` + +#### 大写还是小写? + +如果要设置特殊位时看到大写的 `S` 或 `T` 而不是小写的字符(如我们之前所见),那是因为不存在(对应的)底层的执行位。为了说明这一点,下面的示例创建一个设置了粘滞位的文件。然后,我们可以添加和删除执行位以演示大小写更改。 + +``` +$ touch file cap-ST-demo +$ chmod 1755 cap-ST-demo +$ ls -l cap-ST-demo +-rwxr-xr-t. 1 root root 0 Jun 12 06:16 cap-ST-demo + +$ chmod o-x cap-X-demo +$ ls -l cap-X-demo +-rwxr-xr-T. 1 root root 0 Jun 12 06:16 cap-ST-demo +``` + +#### 有条件地设置执行位 + +至此,我们使用小写的 `x` 设置了执行位,而无需询问任何问题即可对其进行设置。我们还有另一种选择:使用大写的 `X` 而不是小写的,它将仅在权限组中某个位置已经有执行位时才设置执行位。这可能是一个很难解释的概念,但是下面的演示将帮助说明它。请注意,在尝试将执行位添加到组特权之后,该位没有被设置上。 + +``` +$ touch cap-X-file +$ ls -l cap-X-file +-rw-r--r--. 1 root root 0 Jun 12 06:31 cap-X-file +$ chmod g+X cap-X-file +$ ls -l cap-X-file +-rw-r--r--. 1 root root 0 Jun 12 06:31 cap-X-file +``` + +在这个类似的例子中,我们首先使用小写的 `x` 将执行位添加到组权限,然后使用大写的 `X` 为所有其他用户添加权限。这次,大写的 `X`设置了该权限。 + +``` +$ touch cap-X-file +$ ls -l cap-X-file +-rw-r--r--. 1 root root 0 Jun 12 06:31 cap-X-file +$ chmod g+x cap-X-file +$ ls -l cap-X-file +-rw-r-xr--. 1 root root 0 Jun 12 06:31 cap-X-file +$ chmod o+X cap-X-file +ls -l cap-X-file +-rw-r-xr-x. 1 root root 0 Jun 12 06:31 cap-X-file +``` + +### 理解 umask + +`umask` 会屏蔽(或“阻止”)默认权限集中的位,以定义文件或目录的权限。例如,`umask`输出中的 `2` 表示它至少在默认情况下阻止了文件的“写入”位。 + +使用不带任何参数的 `umask` 命令可以使我们看到当前的 `umask` 设置。共有四列:第一列为特殊的`suid`、`sgid` 或粘滞位而保留,其余三列代表属主、组和其他人的权限。 + +``` +$ umask +0022 +``` + +为了理解这意味着什么,我们可以用 `-S` 标志来执行 `umask`(如下所示)以解释屏蔽位的结果。例如,由于第三列中的值为 `2`,因此将“写入”位从组和其他部分中屏蔽掉了;只能为它们分配“读取”和“执行”。 + +``` +$ umask -S +u=rwx,g=rx,o=rx +``` + +要查看文件和目录的默认权限集是什么,让我们将 `umask` 设置为全零。这意味着我们在创建文件时不会掩盖任何位。 + +``` +$ umask 000 +$ umask -S +u=rwx,g=rwx,o=rwx + +$ touch file-umask-000 +$ ls -l file-umask-000 +-rw-rw-rw-. 1 root root 0 Jul 17 22:03 file-umask-000 +``` + +现在,当我们创建文件时,我们看到所有部分的默认权限分别为“读取”(`4`)和“写入”(`2`),相当于八进制表示 `666`。 + +我们可以对目录执行相同的操作,并看到其默认权限为 `777`。我们需要在目录上使用“执行”位,以便可以遍历它们。 + +``` +$ mkdir dir-umask-000 +$ ls -ld dir-umask-000 +drwxrwxrwx. 2 root root 4096 Jul 17 22:03 dir-umask-000/ +``` + +### 总结 + +管理员还有许多其他方法可以控制对系统文件的访问。这些权限是 Linux 的基本权限,我们可以在这些基础上进行构建。如果你的工作为你引入了 FACL 或 SELinux,你会发现它们也建立在这些文件访问的首要规则之上。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/linux-permissions-101 + +作者:[Alex Juarez][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mralexjuarezhttps://opensource.com/users/marcobravohttps://opensource.com/users/greg-p +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux-penguins.png?itok=yKOpaJM_ (Penguins) +[2]: https://www.gnu.org/software/texinfo/manual/info-stnd/info-stnd.html +[3]: https://www.theurbanpenguin.com/using-a-simple-c-program-to-explain-the-suid-permission/ diff --git a/published/20190822 11 Essential Keyboard Shortcuts Google Chrome-Chromium Users Should Know.md b/published/20190822 11 Essential Keyboard Shortcuts Google Chrome-Chromium Users Should Know.md new file mode 100644 index 0000000000..b7d6d63551 --- /dev/null +++ b/published/20190822 11 Essential Keyboard Shortcuts Google Chrome-Chromium Users Should Know.md @@ -0,0 +1,131 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11556-1.html) +[#]: subject: (11 Essential Keyboard Shortcuts Google Chrome/Chromium Users Should Know) +[#]: via: (https://itsfoss.com/google-chrome-shortcuts/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Chrome/Chromium 用户必知必会的 11 个基本快捷键 +====== + +> 掌握这些 Google Chrome 键盘快捷键,以获得更好、更流畅、更高效的 Web 浏览体验。还包括可下载的备忘单。 + +![](https://img.linux.net.cn/data/attachment/album/201911/09/214207wh96q76ejacnn5as.png) + +无可否认,Google Chrome 是[最受欢迎的网络浏览器][1]。它的开源版本 [Chromium][2] 也越来越受欢迎,现在一些 Linux 发行版将其作为默认的网络浏览器。 + +如果你经常在台式机上使用它,则可以使用 Google Chrome 键盘快捷键来改善浏览体验。没有必要用你的鼠标移来移去、点来点去。只要掌握这些快捷方式,你可以节省一些时间并提高工作效率。 + +我这里使用的名称是 Google Chrome,但是这些快捷方式同样适用于 Chromium 浏览器。 + +### 你应该使用的 11 个酷炫的 Chrome 键盘快捷键 + +如果你是专业人士,可能已经知道其中一些 Chrome 快捷方式,但是有可能你仍然可以在这里找到一些隐藏的宝石。让我们来看看。 + +**键盘快捷键** | **动作** +---|--- +`Ctrl+T` | 打开一个新标签页 +`Ctrl+N` | 打开一个新窗口 +`Ctrl+Shift+N` | 打开一个新无痕式窗口 +`Ctrl+W` | 关闭当前标签页 +`Ctrl+Shift+T` | 重新打开上一个关闭的标签页 +`Ctrl+Shift+W` | 关闭窗口 +`Ctrl+Tab` 和 `Ctrl+Shift+Tab` | 切换到右侧或左侧的标签页 +`Ctrl+L` | 访问搜索/地址栏 +`Ctrl+D` | 将网址放入书签 +`Ctrl+H` | 访问浏览历史 +`Ctrl+J` | 访问下载历史 +`Shift+Esc` | 打开 Chrome 任务管理器 + +你可以[下载这份有用的 Chrome 键盘快捷键列表来作为快速参考][3]。 + +#### 1、用 `Ctrl+T` 打开一个新标签页 + +需要打开一个新标签页吗?只需同时按 `Ctrl` 和 `T` 键,你就会打开一个新标签。 + +#### 2、使用 `Ctrl+N` 打开一个新窗口 + +已经打开太多标签页?是时候打开一个新的窗口。使用 `Ctrl` 和 `N` 键打开一个新的浏览器窗口。 + +#### 3、使用 `Ctrl+Shift+N` 隐身 + +在线查询航班或酒店价格?隐身可能会有所帮助。使用 `Ctrl+Shift+N` 在 Chrome 中打开一个隐身窗口。 + +#### 4、使用 `Ctrl+W` 关闭标签页 + +使用 `Ctrl` 和 `W` 键关闭当前标签页。无需将鼠标移到顶部并寻找 `x` 按钮。 + +#### 5、不小心关闭了标签页?用 `Ctrl+Shift+T` 重新打开 + +这是我最喜欢的 Google Chrome 浏览器快捷方式。当你关闭了原本不想关的标签页时,就不用再懊悔了。使用 `Ctrl+Shift+T`,它将打开最后一个关闭的选项卡。继续按此组合键,它把关闭的选项卡再次打开。 + +#### 6、使用 `Ctrl+Shift+W` 关闭整个浏览器窗口 + +完成工作了吗?是时候关闭带有所有标签页的整个浏览器窗口了。使用 `Ctrl+Shift+W` 键,浏览器窗口将消失,就像以前不存在一样。 + +#### 7、使用 `Ctrl+Tab` 在标签之间切换 + +打开的标签页太多了吗?你可以使用 `Ctrl+Tab` 移至右侧标签页。想左移吗?使用 `Ctrl+Shift+Tab`。重复按这些键,你可以在当前浏览器窗口的所有打开的标签页之间移动。 + +你也可以使用 `Ctrl+0` 直到 `Ctrl+9` 转到前 10 个标签页之一。但是此 Chrome 键盘快捷键不适用于第 11 个及更多标签页。 + +#### 8、使用 `Ctrl+L` 转到搜索/地址栏 + +想要输入新的 URL 或快速搜索一些内容。你可以使用 `Ctrl+L`,它将在顶部突出显示地址栏。 + +#### 9、用 `Ctrl+D` 收藏当前网站 + +找到了有趣的东西?使用 `Ctrl+D` 组合键将其保存在书签中。 + +#### 10、使用 `Ctrl+H` 返回历史记录 + +你可以使用 `Ctrl+H` 键打开浏览器历史记录。如果你正在寻找前一段时间访问过的页面,或者删除你不想再看到的页面,可以搜索历史记录。 + +#### 11、使用 `Ctrl+J` 查看下载 + +在 Chrome 中按 `Ctrl+J` 键将带你进入下载页面。此页面将显示你执行的所有下载操作。 + +#### 意外惊喜:使用 `Shift+Esc` 打开 Chrome 任务管理器 + +很多人甚至都不知道 Chrome 浏览器中有一个任务管理器。Chrome 以消耗系统内存而臭名昭著。而且,当你打开大量标签时,找到罪魁祸首并不容易。 + +使用 Chrome 任务管理器,你可以查看所有打开的标签页及其系统利用率统计信息。你还可以看到各种隐藏的进程,例如 Chrome 扩展程序和其他服务。 + +![Google Chrome 任务管理器][6] + +### 下载 Chrome 快捷键备忘单 + +我知道掌握键盘快捷键取决于习惯,你可以通过反复使用使其习惯。为了帮助你完成此任务,我创建了此 Google Chrome 键盘快捷键备忘单。 + +![Google Chrome键盘快捷键备忘单][7] + +你可以[下载以下 PDF 格式的图像][8],进行打印并将其放在办公桌上。这样,你可以一直练习快捷方式。 + +如果你对掌握快捷方式感兴趣,还可以查看 [Ubuntu 键盘快捷键][9]。 + +顺便问一下,你最喜欢的 Chrome 快捷方式是什么? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/google-chrome-shortcuts/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Usage_share_of_web_browsers +[2]: https://www.chromium.org/Home +[3]: tmp.3qZNXSy2FC#download-cheatsheet +[4]: https://itsfoss.com/command-line-text-editors-linux/ +[5]: https://itsfoss.com/rid-google-chrome-icons-dock-elementary-os-freya/ +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/08/google-chrome-task-manager.png?w=800&ssl=1 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/08/google-chrome-keyboard-shortcuts-cheat-sheet.png?ssl=1 +[8]: https://drive.google.com/open?id=1lZ4JgRuFbXrnEXoDQqOt7PQH6femIe3t +[9]: https://itsfoss.com/ubuntu-shortcuts/ diff --git a/published/20190826 How RPM packages are made- the source RPM.md b/published/20190826 How RPM packages are made- the source RPM.md new file mode 100644 index 0000000000..222ec93038 --- /dev/null +++ b/published/20190826 How RPM packages are made- the source RPM.md @@ -0,0 +1,235 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11527-1.html) +[#]: subject: (How RPM packages are made: the source RPM) +[#]: via: (https://fedoramagazine.org/how-rpm-packages-are-made-the-source-rpm/) +[#]: author: (Ankur Sinha "FranciscoD" https://fedoramagazine.org/author/ankursinha/) + +RPM 包是如何从源 RPM 制作的 +====== + +![][1] + +在[上一篇文章中,我们研究了什么是 RPM 软件包][2]。它们是包含文件和元数据的档案文件。当安装或卸载 RPM 时,此元数据告诉 RPM 在哪里创建或删除文件。正如你将在上一篇文章中记住的,元数据还包含有关“依赖项”的信息,它可以是“运行时”或“构建时”的依赖信息。 + +例如,让我们来看看 `fpaste`。你可以使用 `dnf` 下载该 RPM。这将下载 Fedora 存储库中可用的 `fpaste` 最新版本。在 Fedora 30 上,当前版本为 0.3.9.2: + +``` +$ dnf download fpaste + +... +fpaste-0.3.9.2-2.fc30.noarch.rpm +``` + +由于这是个构建 RPM,因此它仅包含使用 `fpaste` 所需的文件: + +``` +$ rpm -qpl ./fpaste-0.3.9.2-2.fc30.noarch.rpm +/usr/bin/fpaste +/usr/share/doc/fpaste +/usr/share/doc/fpaste/README.rst +/usr/share/doc/fpaste/TODO +/usr/share/licenses/fpaste +/usr/share/licenses/fpaste/COPYING +/usr/share/man/man1/fpaste.1.gz +``` + +### 源 RPM + +在此链条中的下一个环节是源 RPM。Fedora 中的所有软件都必须从其源代码构建。我们不包括预构建的二进制文件。因此,要制作一个 RPM 文件,RPM(工具)需要: + +* 给出必须要安装的文件, +* 例如,如果要编译出这些文件,则告诉它们如何生成这些文件, +* 告知必须在何处安装这些文件, +* 该特定软件需要其他哪些依赖才能正常工作。 + +源 RPM 拥有所有这些信息。源 RPM 与构建 RPM 相似,但顾名思义,它们不包含已构建的二进制文件,而是包含某个软件的源文件。让我们下载 `fpaste` 的源 RPM: + +``` +$ dnf download fpaste --source + +... +fpaste-0.3.9.2-2.fc30.src.rpm +``` + +注意文件的结尾是 `src.rpm`。所有的 RPM 都是从源 RPM 构建的。你也可以使用 `dnf` 轻松检查“二进制” RPM 的源 RPM: + +``` +$ dnf repoquery --qf "%{SOURCERPM}" fpaste +fpaste-0.3.9.2-2.fc30.src.rpm +``` + +另外,由于这是源 RPM,因此它不包含构建的文件。相反,它包含有关如何从中构建 RPM 的源代码和指令: + +``` +$ rpm -qpl ./fpaste-0.3.9.2-2.fc30.src.rpm +fpaste-0.3.9.2.tar.gz +fpaste.spec +``` + +这里,第一个文件只是 `fpaste` 的源代码。第二个是 spec 文件。spec 文件是个配方,可告诉 RPM(工具)如何使用源 RPM 中包含的源代码创建 RPM(档案文件)— 它包含 RPM(工具)构建 RPM(档案文件)所需的所有信息。在 spec 文件中。当我们软件包维护人员添加软件到 Fedora 中时,我们大部分时间都花在编写和完善 spec 文件上。当软件包需要更新时,我们会回过头来调整 spec 文件。你可以在 的源代码存储库中查看 Fedora 中所有软件包的 spec 文件。 + +请注意,一个源 RPM 可能包含构建多个 RPM 的说明。`fpaste` 是一款非常简单的软件,一个源 RPM 生成一个“二进制” RPM。而 Python 则更复杂。虽然只有一个源 RPM,但它会生成多个二进制 RPM: + +``` +$ sudo dnf repoquery --qf "%{SOURCERPM}" python3 +python3-3.7.3-1.fc30.src.rpm +python3-3.7.4-1.fc30.src.rpm + +$ sudo dnf repoquery --qf "%{SOURCERPM}" python3-devel +python3-3.7.3-1.fc30.src.rpm +python3-3.7.4-1.fc30.src.rpm + +$ sudo dnf repoquery --qf "%{SOURCERPM}" python3-libs +python3-3.7.3-1.fc30.src.rpm +python3-3.7.4-1.fc30.src.rpm + +$ sudo dnf repoquery --qf "%{SOURCERPM}" python3-idle +python3-3.7.3-1.fc30.src.rpm +python3-3.7.4-1.fc30.src.rpm + +$ sudo dnf repoquery --qf "%{SOURCERPM}" python3-tkinter +python3-3.7.3-1.fc30.src.rpm +python3-3.7.4-1.fc30.src.rpm +``` + +用 RPM 行话来讲,“python3” 是“主包”,因此该 spec 文件将称为 `python3.spec`。所有其他软件包均为“子软件包”。你可以下载 python3 的源 RPM,并查看其中的内容。(提示:补丁也是源代码的一部分): + +``` +$ dnf download --source python3 +python3-3.7.4-1.fc30.src.rpm + +$ rpm -qpl ./python3-3.7.4-1.fc30.src.rpm +00001-rpath.patch +00102-lib64.patch +00111-no-static-lib.patch +00155-avoid-ctypes-thunks.patch +00170-gc-assertions.patch +00178-dont-duplicate-flags-in-sysconfig.patch +00189-use-rpm-wheels.patch +00205-make-libpl-respect-lib64.patch +00251-change-user-install-location.patch +00274-fix-arch-names.patch +00316-mark-bdist_wininst-unsupported.patch +Python-3.7.4.tar.xz +check-pyc-timestamps.py +idle3.appdata.xml +idle3.desktop +python3.spec +``` + +### 从源 RPM 构建 RPM + +现在我们有了源 RPM,并且其中有什么内容,我们可以从中重建 RPM。但是,在执行此操作之前,我们应该设置系统以构建 RPM。首先,我们安装必需的工具: + +``` +$ sudo dnf install fedora-packager +``` + +这将安装 `rpmbuild` 工具。`rpmbuild` 需要一个默认布局,以便它知道源 RPM 中每个必需组件的位置。让我们看看它们是什么: + +``` +# spec 文件将出现在哪里? +$ rpm -E %{_specdir} +/home/asinha/rpmbuild/SPECS + +# 源代码将出现在哪里? +$ rpm -E %{_sourcedir} +/home/asinha/rpmbuild/SOURCES + +# 临时构建目录是哪里? +$ rpm -E %{_builddir} +/home/asinha/rpmbuild/BUILD + +# 构建根目录是哪里? +$ rpm -E %{_buildrootdir} +/home/asinha/rpmbuild/BUILDROOT + +# 源 RPM 将放在哪里? +$ rpm -E %{_srcrpmdir} +/home/asinha/rpmbuild/SRPMS + +# 构建的 RPM 将放在哪里? +$ rpm -E %{_rpmdir} +/home/asinha/rpmbuild/RPMS +``` + +我已经在系统上设置了所有这些目录: + +``` +$ cd +$ tree -L 1 rpmbuild/ +rpmbuild/ +├── BUILD +├── BUILDROOT +├── RPMS +├── SOURCES +├── SPECS +└── SRPMS + +6 directories, 0 files +``` + +RPM 还提供了一个为你全部设置好的工具: + +``` +$ rpmdev-setuptree +``` + +然后,确保已安装 `fpaste` 的所有构建依赖项: + +``` +sudo dnf builddep fpaste-0.3.9.2-3.fc30.src.rpm +``` + +对于 `fpaste`,你只需要 Python,并且它肯定已经安装在你的系统上(`dnf` 也使用 Python)。还可以给 `builddep` 命令一个 spec 文件,而不是源 RPM。在手册页中了解更多信息: + +``` +$ man dnf.plugin.builddep +``` + +现在我们有了所需的一切,从源 RPM 构建一个 RPM 就像这样简单: + +``` +$ rpmbuild --rebuild fpaste-0.3.9.2-3.fc30.src.rpm +.. +.. + +$ tree ~/rpmbuild/RPMS/noarch/ +/home/asinha/rpmbuild/RPMS/noarch/ +└── fpaste-0.3.9.2-3.fc30.noarch.rpm + +0 directories, 1 file +``` + +`rpmbuild` 将安装源 RPM 并从中构建你的 RPM。现在,你可以使用 `dnf` 安装 RPM 以使用它。当然,如前所述,如果你想在 RPM 中进行任何更改,则必须修改 spec 文件,我们将在下一篇文章中介绍 spec 文件。 + +### 总结 + +总结一下这篇文章有两点: + +* 我们通常安装使用的 RPM 是包含软件的构建版本的 “二进制” RPM +* 构建 RPM 来自于源 RPM,源 RPM 包括用于生成二进制 RPM 所需的源代码和规范文件。 + +如果你想开始构建 RPM,并帮助 Fedora 社区维护我们提供的大量软件,则可以从这里开始: + +如有任何疑问,请发邮件到 [Fedora 开发人员邮件列表][3],我们随时乐意为你提供帮助! + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/how-rpm-packages-are-made-the-source-rpm/ + +作者:[Ankur Sinha "FranciscoD"][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/ankursinha/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/06/rpm.png-816x345.jpg +[2]: https://linux.cn/article-11452-1.html +[3]: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/ diff --git a/published/20190828 Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word.md b/published/20190828 Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word.md new file mode 100644 index 0000000000..70abe7d3c9 --- /dev/null +++ b/published/20190828 Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word.md @@ -0,0 +1,84 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11529-1.html) +[#]: subject: (Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word) +[#]: via: (https://itsfoss.com/gimp-fork-glimpse/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +由于 GIMP 是令人反感的字眼,有人将它复刻了 +====== + +在开源应用程序世界中,当社区成员希望以与其他人不同的方向来开发应用程序时,复刻fork是很常见的。最新的具有新闻价值的一个复刻称为 [Glimpse][1],旨在解决用户在使用 [GNU 图像处理程序][2]GNU Image Manipulation Program(通常称为 GIMP)时遇到的某些问题。 + +### 为什么创建 GIMP 的复刻? + +![][3] + +当你访问 Glimpse 应用的[主页][1]时,它表示该项目的目标是“尝试其他设计方向并修复长期存在的错误。”这听起来并不奇怪。但是,如果你开始阅读该项目的博客文章,则是另外一种印象。 + +根据该项目的[第一篇博客文章][4],他们创建了这个复刻是因为他们不喜欢 GIMP 这个名称。根据该帖子,“我们中的许多人不认为该软件的名称适用于所有用户,并且在拒绝该项目的 13 年后,我们决定复刻!” + +如果你想知道为什么这些人认为 GIMP 令人讨厌,他们在[关于页面][5]中回答该问题: + +> “如果英语不是你的母语,那么你可能没有意识到 ‘gimp’ 一词有问题。在某些国家,这被视为针对残疾人的侮辱和针对不受欢迎儿童的操场侮辱。它也可以与成年人同意的某些‘天黑后’活动联系起来。” + +他们还指出,他们并没有使这一举动脱离政治正确或过于敏感。“除了可能给边缘化社区带来的痛苦外,我们当中许多人都有过倡导自由软件的故事,比如在 GNU 图像处理程序没有被专业环境中的老板或同事视为可选项这件事上。” + +他们似乎在回答许多质疑,“不幸的是,我们不得不复刻整个项目来更改其名称,我们认为有关此问题的讨论陷入了僵局,而这是最积极的前进方向。 ” + +看起来 Glimpse 这个名称不是确定不变的。他们的 GitHub 页面上有个关于可能选择其他名称的[提案][7]。也许他们应该放弃 GNU 这个词,我认为 IMP 这个词没有不好的含义。(LCTT 译注:反讽) + +### 分叉之路 + +![GIMP 2.10][8] + +[GIMP][6] 已经存在了 20 多年,因此任何形式的复刻都是一项艰巨的任务。当前,[他们正在计划][9]首先在 2019 年 9 月发布 Glimpse 0.1。这将是一个软复刻,这意味着在迁移到新身份时的更改将主要是装饰性的。(LCTT 译注:事实上到本译文发布时,该项目仍然处于蛋疼的 0.1 beta,也许 11 月,也许 12 月,才能发布 0.1 的正式版本。) + +Glimpse 1.0 将是一个硬复刻,他们将积极更改代码库并将其添加到代码库中。他们想将 1.0 移植到 GTK3 并拥有自己的文档。他们估计,直到 2020 年 GIMP 3 发布之后才能做到。 + +除了 1.0,Glimpse 团队还计划打响自己的名声。他们计划进行“前端 UI 重写”。他们目前正在讨论[改用哪种语言][10]。D 和 Rust 似乎有很多支持者。随着时间的流逝,他们也[希望][4]“添加新功能以解决普通用户的抱怨”。 + +### 最后的思考 + +我过去曾经使用过一点 GIMP,但从来没有对它的名称感到困扰。老实说,我很长一段时间都不知道这意味着什么。有趣的是,当我在 Wikipedia 上搜索 GIMP 时,看到了一个 [GIMP 项目][11]的条目,这是纽约的一个现代舞蹈项目,其中包括残疾人。我想 gimp 并不是每个人视为一个贬低词汇的。 + +对我来说,更改名称似乎需要大量工作。似乎改写 UI 的想法会使项目看起来更有价值一些。我想知道他们是否会调整它以带来更经典的 UI,例如[使用 Ctrl + S 保存到 GIMP][12] / Glimpse。让我们拭目以待。 + +如果你对该项目感兴趣,可以在 [Twitter][14] 上关注他们,查看其 [GitHub 帐户][15],或查看其 [Patreon 页面][16]。 + +你觉得被 GIMP 名称冒犯了吗?你是否认为值得对应用程序进行复刻,以便你可以对其进行重命名?在下面的评论中让我们知道。 + +如果你觉得这篇文章有趣,请花一点时间在社交媒体、Hacker News 或 [Reddit][17] 上分享。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/gimp-fork-glimpse/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://getglimpse.app/ +[2]: https://www.gimp.org/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/08/gimp-fork-glimpse.png?resize=800%2C450&ssl=1 +[4]: https://getglimpse.app/posts/so-it-begins/ +[5]: https://getglimpse.app/about/ +[6]: https://itsfoss.com/gimp-2-10-release/ +[7]: https://github.com/glimpse-editor/Glimpse/issues/92 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/08/gimp-screenshot.jpg?resize=800%2C508&ssl=1 +[9]: https://getglimpse.app/posts/six-week-checkpoint/ +[10]: https://github.com/glimpse-editor/Glimpse/issues/70 +[11]: https://en.wikipedia.org/wiki/The_Gimp_Project +[12]: https://itsfoss.com/how-to-solve-gimp-2-8-does-not-save-in-jpeg-or-png-format/ +[13]: https://itsfoss.com/wps-office-2016-linux/ +[14]: https://twitter.com/glimpse_editor +[15]: https://github.com/glimpse-editor/Glimpse +[16]: https://www.patreon.com/glimpse +[17]: https://reddit.com/r/linuxusersgroup diff --git a/published/20190902 How RPM packages are made- the spec file.md b/published/20190902 How RPM packages are made- the spec file.md new file mode 100644 index 0000000000..30542ef8de --- /dev/null +++ b/published/20190902 How RPM packages are made- the spec file.md @@ -0,0 +1,289 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11538-1.html) +[#]: subject: (How RPM packages are made: the spec file) +[#]: via: (https://fedoramagazine.org/how-rpm-packages-are-made-the-spec-file/) +[#]: author: (Ankur Sinha "FranciscoD" https://fedoramagazine.org/author/ankursinha/) + +如何编写 RPM 的 spec 文件 +====== + +![][1] + +在[关于 RPM 软件包构建的上一篇文章][2]中,你了解到了源 RPM 包括软件的源代码以及 spec 文件。这篇文章深入研究了 spec 文件,该文件中包含了有关如何构建 RPM 的指令。同样,本文以 `fpaste` 为例。 + +### 了解源代码 + +在开始编写 spec 文件之前,你需要对要打包的软件有所了解。在这里,你正在研究 `fpaste`,这是一个非常简单的软件。它是用 Python 编写的,并且是一个单文件脚本。当它发布新版本时,可在 Pagure 上找到:。 + +如该档案文件所示,当前版本为 0.3.9.2。下载它,以便你查看该档案文件中的内容: + +``` +$ wget https://pagure.io/releases/fpaste/fpaste-0.3.9.2.tar.gz +$ tar -tvf fpaste-0.3.9.2.tar.gz +drwxrwxr-x root/root 0 2018-07-25 02:58 fpaste-0.3.9.2/ +-rw-rw-r-- root/root 25 2018-07-25 02:58 fpaste-0.3.9.2/.gitignore +-rw-rw-r-- root/root 3672 2018-07-25 02:58 fpaste-0.3.9.2/CHANGELOG +-rw-rw-r-- root/root 35147 2018-07-25 02:58 fpaste-0.3.9.2/COPYING +-rw-rw-r-- root/root 444 2018-07-25 02:58 fpaste-0.3.9.2/Makefile +-rw-rw-r-- root/root 1656 2018-07-25 02:58 fpaste-0.3.9.2/README.rst +-rw-rw-r-- root/root 658 2018-07-25 02:58 fpaste-0.3.9.2/TODO +drwxrwxr-x root/root 0 2018-07-25 02:58 fpaste-0.3.9.2/docs/ +drwxrwxr-x root/root 0 2018-07-25 02:58 fpaste-0.3.9.2/docs/man/ +drwxrwxr-x root/root 0 2018-07-25 02:58 fpaste-0.3.9.2/docs/man/en/ +-rw-rw-r-- root/root 3867 2018-07-25 02:58 fpaste-0.3.9.2/docs/man/en/fpaste.1 +-rwxrwxr-x root/root 24884 2018-07-25 02:58 fpaste-0.3.9.2/fpaste +lrwxrwxrwx root/root 0 2018-07-25 02:58 fpaste-0.3.9.2/fpaste.py -> fpaste +``` + +你要安装的文件是: + +* `fpaste.py`:应该安装到 `/usr/bin/`。 +* `docs/man/en/fpaste.1`:手册,应放到 `/usr/share/man/man1/`。 +* `COPYING`:许可证文本,应放到 `/usr/share/license/fpaste/`。 +* `README.rst`、`TODO`:放到 `/usr/share/doc/fpaste/` 下的其它文档。 + +这些文件的安装位置取决于文件系统层次结构标准(FHS)。要了解更多信息,可以在这里阅读: 或查看 Fedora 系统的手册页: + +``` +$ man hier +``` + +#### 第一部分:要构建什么? + +现在我们知道了源文件中有哪些文件,以及它们要存放的位置,让我们看一下 spec 文件。你可以在此处查看这个完整的文件:。 + +这是 spec 文件的第一部分: + +``` +Name: fpaste +Version: 0.3.9.2 +Release: 3%{?dist} +Summary: A simple tool for pasting info onto sticky notes instances +BuildArch: noarch +License: GPLv3+ +URL: https://pagure.io/fpaste +Source0: https://pagure.io/releases/fpaste/fpaste-0.3.9.2.tar.gz + +Requires: python3 + +%description +It is often useful to be able to easily paste text to the Fedora +Pastebin at http://paste.fedoraproject.org and this simple script +will do that and return the resulting URL so that people may +examine the output. This can hopefully help folks who are for +some reason stuck without X, working remotely, or any other +reason they may be unable to paste something into the pastebin +``` + +`Name`、`Version` 等称为*标签*,它们定义在 RPM 中。这意味着你不能只是随意写点标签,RPM 无法理解它们!需要注意的标签是: + +* `Source0`:告诉 RPM 该软件的源代码档案文件所在的位置。 +* `Requires`:列出软件的运行时依赖项。RPM 可以自动检测很多依赖项,但是在某些情况下,必须手动指明它们。运行时依赖项是系统上必须具有的功能(通常是软件包),才能使该软件包起作用。这是 [dnf][3] 在安装此软件包时检测是否需要拉取其他软件包的方式。 +* `BuildRequires`:列出了此软件的构建时依赖项。这些通常必须手动确定并添加到 spec 文件中。 +* `BuildArch`:此软件为该计算机体系结构所构建。如果省略此标签,则将为所有受支持的体系结构构建该软件。值 `noarch` 表示该软件与体系结构无关(例如 `fpaste`,它完全是用 Python 编写的)。 + +本节提供有关 `fpaste` 的常规信息:它是什么,正在将什么版本制作为 RPM,其许可证等等。如果你已安装 `fpaste`,并查看其元数据时,则可以看到该 RPM 中包含的以下信息: + +``` +$ sudo dnf install fpaste +$ rpm -qi fpaste +Name : fpaste +Version : 0.3.9.2 +Release : 2.fc30 +... +``` + +RPM 会自动添加一些其他标签,以代表它所知道的内容。 + +至此,我们掌握了要为其构建 RPM 的软件的一般信息。接下来,我们开始告诉 RPM 做什么。 + +#### 第二部分:准备构建 + +spec 文件的下一部分是准备部分,用 `%prep` 代表: + +``` +%prep +%autosetup +``` + +对于 `fpaste`,这里唯一的命令是 `%autosetup`。这只是将 tar 档案文件提取到一个新文件夹中,并为下一部分的构建阶段做好了准备。你可以在此处执行更多操作,例如应用补丁程序,出于不同目的修改文件等等。如果你查看过 Python 的源 RPM 的内容,那么你会在那里看到许多补丁。这些都将在本节中应用。 + +通常,spec 文件中带有 `%` 前缀的所有内容都是 RPM 以特殊方式解释的宏或标签。这些通常会带有大括号,例如 `%{example}`。 + +#### 第三部分:构建软件 + +下一部分是构建软件的位置,用 `%build` 表示。现在,由于 `fpaste` 是一个简单的纯 Python 脚本,因此无需构建。因此,这里是: + +``` +%build +#nothing required +``` + +不过,通常来说,你会在此处使用构建命令,例如: + +``` +configure; make +``` + +构建部分通常是 spec 文件中最难的部分,因为这是从源代码构建软件的地方。这要求你知道该工具使用的是哪个构建系统,该系统可能是许多构建系统之一:Autotools、CMake、Meson、Setuptools(用于 Python)等等。每个都有自己的命令和语法样式。你需要充分了解这些才能正确构建软件。 + +#### 第四部分:安装文件 + +软件构建后,需要在 `%install` 部分中安装它: + +``` +%install +mkdir -p %{buildroot}%{_bindir} +make install BINDIR=%{buildroot}%{_bindir} MANDIR=%{buildroot}%{_mandir} +``` + +在构建 RPM 时,RPM 不会修改你的系统文件。在一个可以正常运行的系统上添加、删除或修改文件的风险太大。如果发生故障怎么办?因此,RPM 会创建一个专门打造的文件系统并在其中工作。这称为 `buildroot`。 因此,在 `buildroot` 中,我们创建由宏 `%{_bindir}` 代表的 `/usr/bin` 目录,然后使用提供的 `Makefile` 将文件安装到其中。 + +至此,我们已经在专门打造的 `buildroot` 中安装了 `fpaste` 的构建版本。 + +#### 第五部分:列出所有要包括在 RPM 中的文件 + +spec 文件其后的一部分是文件部分:`%files`。在这里,我们告诉 RPM 从该 spec 文件创建的档案文件中包含哪些文件。`fpaste` 的文件部分非常简单: + +``` +%files +%{_bindir}/%{name} +%doc README.rst TODO +%{_mandir}/man1/%{name}.1.gz +%license COPYING +``` + +请注意,在这里,我们没有指定 `buildroot`。所有这些路径都是相对路径。`%doc` 和 `%license`命令做的稍微多一点,它们会创建所需的文件夹,并记住这些文件必须放在那里。 + +RPM 很聪明。例如,如果你在 `%install` 部分中安装了文件,但未列出它们,它会提醒你。 + +#### 第六部分:在变更日志中记录所有变更 + +Fedora 是一个基于社区的项目。许多贡献者维护或共同维护软件包。因此,当务之急是不要被软件包做了哪些更改所搞混。为了确保这一点,spec 文件包含的最后一部分是变更日志 `%changelog`: + +``` +%changelog +* Thu Jul 25 2019 Fedora Release Engineering < ...> - 0.3.9.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Thu Jan 31 2019 Fedora Release Engineering < ...> - 0.3.9.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Tue Jul 24 2018 Ankur Sinha - 0.3.9.2-1 +- Update to 0.3.9.2 + +* Fri Jul 13 2018 Fedora Release Engineering < ...> - 0.3.9.1-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Wed Feb 07 2018 Fedora Release Engineering < ..> - 0.3.9.1-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Sun Sep 10 2017 Vasiliy N. Glazov < ...> - 0.3.9.1-2 +- Cleanup spec + +* Fri Sep 08 2017 Ankur Sinha - 0.3.9.1-1 +- Update to latest release +- fixes rhbz 1489605 +... +.... +``` + +spec 文件的*每项*变更都必须有一个变更日志条目。如你在此处看到的,虽然我以维护者身份更新了该 spec 文件,但其他人也做过更改。清楚地记录变更内容有助于所有人知道该 spec 文件的当前状态。对于系统上安装的所有软件包,都可以使用 `rpm` 来查看其更改日志: + +``` +$ rpm -q --changelog fpaste +``` + +### 构建 RPM + +现在我们准备构建 RPM 包。如果要继续执行以下命令,请确保遵循[上一篇文章][2]中的步骤设置系统以构建 RPM。 + +我们将 `fpaste` 的 spec 文件放置在 `~/rpmbuild/SPECS` 中,将源代码档案文件存储在 `~/rpmbuild/SOURCES/` 中,现在可以创建源 RPM 了: + +``` +$ cd ~/rpmbuild/SPECS +$ wget https://src.fedoraproject.org/rpms/fpaste/raw/master/f/fpaste.spec + +$ cd ~/rpmbuild/SOURCES +$ wget https://pagure.io/fpaste/archive/0.3.9.2/fpaste-0.3.9.2.tar.gz + +$ cd ~/rpmbuild/SOURCES +$ rpmbuild -bs fpaste.spec +Wrote: /home/asinha/rpmbuild/SRPMS/fpaste-0.3.9.2-3.fc30.src.rpm +``` + +让我们看一下结果: + +``` +$ ls ~/rpmbuild/SRPMS/fpaste* +/home/asinha/rpmbuild/SRPMS/fpaste-0.3.9.2-3.fc30.src.rpm + +$ rpm -qpl ~/rpmbuild/SRPMS/fpaste-0.3.9.2-3.fc30.src.rpm +fpaste-0.3.9.2.tar.gz +fpaste.spec +``` + +我们看到源 RPM 已构建。让我们同时构建源 RPM 和二进制 RPM: + +``` +$ cd ~/rpmbuild/SPECS +$ rpmbuild -ba fpaste.spec +.. +.. +.. +``` + +RPM 将向你显示完整的构建输出,并在我们之前看到的每个部分中详细说明它的工作。此“构建日志”非常重要。当构建未按预期进行时,我们的打包人员将花费大量时间来遍历它们,以跟踪完整的构建路径来查看出了什么问题。 + +就是这样!准备安装的 RPM 应该位于以下位置: + +``` +$ ls ~/rpmbuild/RPMS/noarch/ +fpaste-0.3.9.2-3.fc30.noarch.rpm +``` + +### 概括 + +我们已经介绍了如何从 spec 文件构建 RPM 的基础知识。这绝不是一份详尽的文档。实际上,它根本不是文档。它只是试图解释幕后的运作方式。简短回顾一下: + +* RPM 有两种类型:源 RPM 和 二进制 RPM。 +* 二进制 RPM 包含要安装以使用该软件的文件。 +* 源 RPM 包含构建二进制 RPM 所需的信息:完整的源代码,以及 spec 文件中的有关如何构建 RPM 的说明。 +* spec 文件包含多个部分,每个部分都有其自己的用途。 +   +在这里,我们已经在安装好的 Fedora 系统中本地构建了 RPM。虽然这是个基本的过程,但我们从存储库中获得的 RPM 是建立在具有严格配置和方法的专用服务器上的,以确保正确性和安全性。这个 Fedora 打包流程将在以后的文章中讨论。 + +你想开始构建软件包,并帮助 Fedora 社区维护我们提供的大量软件吗?你可以[从这里开始加入软件包集合维护者][4]。 + +如有任何疑问,请发布到 [Fedora 开发人员邮件列表][5],我们随时乐意为你提供帮助! + +### 参考 + +这里有一些构建 RPM 的有用参考: + +* +* +* +* + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/how-rpm-packages-are-made-the-spec-file/ + +作者:[Ankur Sinha "FranciscoD"][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/ankursinha/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/06/rpm.png-816x345.jpg +[2]: https://linux.cn/article-11527-1.html +[3]: https://fedoramagazine.org/managing-packages-fedora-dnf/ +[4]: https://fedoraproject.org/wiki/Join_the_package_collection_maintainers +[5]: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/ diff --git a/published/20190905 Building CI-CD pipelines with Jenkins.md b/published/20190905 Building CI-CD pipelines with Jenkins.md new file mode 100644 index 0000000000..378ad6728a --- /dev/null +++ b/published/20190905 Building CI-CD pipelines with Jenkins.md @@ -0,0 +1,246 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11546-1.html) +[#]: subject: (Building CI/CD pipelines with Jenkins) +[#]: via: (https://opensource.com/article/19/9/intro-building-cicd-pipelines-jenkins) +[#]: author: (Bryant Son https://opensource.com/users/brson) + +用 Jenkins 构建 CI/CD 流水线 +====== + +> 通过这份 Jenkins 分步教程,构建持续集成和持续交付(CI/CD)流水线。 + +![](https://img.linux.net.cn/data/attachment/album/201911/07/001349rbbbswpeqnnteeee.jpg) + +在我的文章《[使用开源工具构建 DevOps 流水线的初学者指南][2]》中,我分享了一个从头开始构建 DevOps 流水线的故事。推动该计划的核心技术是 [Jenkins][3],这是一个用于建立持续集成和持续交付(CI/CD)流水线的开源工具。 + +在花旗,有一个单独的团队为专用的 Jenkins 流水线提供稳定的主从节点环境,但是该环境仅用于质量保证(QA)、构建阶段和生产环境。开发环境仍然是非常手动的,我们的团队需要对其进行自动化以在加快开发工作的同时获得尽可能多的灵活性。这就是我们决定为 DevOps 建立 CI/CD 流水线的原因。Jenkins 的开源版本由于其灵活性、开放性、强大的插件功能和易用性而成为显而易见的选择。 + +在本文中,我将分步演示如何使用 Jenkins 构建 CI/CD 流水线。 + +### 什么是流水线? + +在进入本教程之前,了解有关 CI/CD 流水线pipeline的知识会很有帮助。 + +首先,了解 Jenkins 本身并不是流水线这一点很有帮助。只是创建一个新的 Jenkins 作业并不能构建一条流水线。可以把 Jenkins 看做一个遥控器,在这里点击按钮即可。当你点击按钮时会发生什么取决于遥控器要控制的内容。Jenkins 为其他应用程序 API、软件库、构建工具等提供了一种插入 Jenkins 的方法,它可以执行并自动化任务。Jenkins 本身不执行任何功能,但是随着其它工具的插入而变得越来越强大。 + +流水线是一个单独的概念,指的是按顺序连接在一起的事件或作业组: + +> “流水线pipeline”是可以执行的一系列事件或作业。 + +理解流水线的最简单方法是可视化一系列阶段,如下所示: + +![Pipeline example][4] + +在这里,你应该看到两个熟悉的概念:阶段Stage步骤Step。 + +* 阶段:一个包含一系列步骤的块。阶段块可以命名为任何名称;它用于可视化流水线过程。 +* 步骤:表明要做什么的任务。步骤定义在阶段块内。 + +在上面的示例图中,阶段 1 可以命名为 “构建”、“收集信息”或其它名称,其它阶段块也可以采用类似的思路。“步骤”只是简单地说放上要执行的内容,它可以是简单的打印命令(例如,`echo "Hello, World"`)、程序执行命令(例如,`java HelloWorld`)、shell 执行命令( 例如,`chmod 755 Hello`)或任何其他命令,只要通过 Jenkins 环境将其识别为可执行命令即可。 + +Jenkins 流水线以**编码脚本**的形式提供,通常称为 “Jenkinsfile”,尽管可以用不同的文件名。下面这是一个简单的 Jenkins 流水线文件的示例: + +``` +// Example of Jenkins pipeline script + +pipeline { +  stages { +    stage("Build") { +      steps { +          // Just print a Hello, Pipeline to the console +          echo "Hello, Pipeline!" +          // Compile a Java file. This requires JDKconfiguration from Jenkins +          javac HelloWorld.java +          // Execute the compiled Java binary called HelloWorld. This requires JDK configuration from Jenkins +          java HelloWorld +          // Executes the Apache Maven commands, clean then package. This requires Apache Maven configuration from Jenkins +          mvn clean package ./HelloPackage +          // List the files in current directory path by executing a default shell command +          sh "ls -ltr" +      } +   } +   // And next stages if you want to define further... +  } // End of stages +} // End of pipeline +``` + +从此示例脚本很容易看到 Jenkins 流水线的结构。请注意,默认情况下某些命令(如 `java`、`javac`和 `mvn`)不可用,需要通过 Jenkins 进行安装和配置。 因此: + +> Jenkins 流水线是一种以定义的方式依次执行 Jenkins 作业的方法,方法是将其编码并在多个块中进行结构化,这些块可以包含多个任务的步骤。 + +好。既然你已经了解了 Jenkins 流水线是什么,我将向你展示如何创建和执行 Jenkins 流水线。在本教程的最后,你将建立一个 Jenkins 流水线,如下所示: + +![Final Result][5] + +### 如何构建 Jenkins 流水线 + +为了便于遵循本教程的步骤,我创建了一个示例 [GitHub 存储库][6]和一个视频教程。 + +- [视频](https://img.linux.net.cn/static/video/_-jDPwYgDVKlg.mp4) + +开始本教程之前,你需要: + +* Java 开发工具包(JDK):如果尚未安装,请安装 JDK 并将其添加到环境路径中,以便可以通过终端执行 Java 命令(如 `java jar`)。这是利用本教程中使用的 Java Web Archive(WAR)版本的 Jenkins 所必需的(尽管你可以使用任何其他发行版)。 +* 基本计算机操作能力:你应该知道如何键入一些代码、通过 shell 执行基本的 Linux 命令以及打开浏览器。 + +让我们开始吧。 + +#### 步骤一:下载 Jenkins + +导航到 [Jenkins 下载页面][7]。向下滚动到 “Generic Java package (.war)”,然后单击下载文件;将其保存在易于找到的位置。(如果你选择其他 Jenkins 发行版,除了步骤二之外,本教程的其余步骤应该几乎相同。)使用 WAR 文件的原因是它是个一次性可执行文件,可以轻松地执行和删除。 + +![Download Jenkins as Java WAR file][8] + +#### 步骤二:以 Java 二进制方式执行 Jenkins + +打开一个终端窗口,并使用 `cd ` 进入下载 Jenkins 的目录。(在继续之前,请确保已安装 JDK 并将其添加到环境路径。)执行以下命令,该命令将 WAR 文件作为可执行二进制文件运行: + +``` +java -jar ./jenkins.war +``` + +如果一切顺利,Jenkins 应该在默认端口 8080 上启动并运行。 + +![Execute as an executable JAR binary][9] + +#### 步骤三:创建一个新的 Jenkins 作业 + +打开一个 Web 浏览器并导航到 `localhost:8080`。除非你有以前安装的 Jenkins,否则应直接转到 Jenkins 仪表板。点击 “Create New Jobs”。你也可以点击左侧的 “New Item”。 + +![Create New Job][10] + +#### 步骤四:创建一个流水线作业 + +在此步骤中,你可以选择并定义要创建的 Jenkins 作业类型。选择 “Pipeline” 并为其命名(例如,“TestPipeline”)。单击 “OK” 创建流水线作业。 + +![Create New Pipeline Job][11] + +你将看到一个 Jenkins 作业配置页面。向下滚动以找到 “Pipeline” 部分。有两种执行 Jenkins 流水线的方法。一种方法是在 Jenkins 上直接编写流水线脚本,另一种方法是从 SCM(源代码管理)中检索 Jenkins 文件。在接下来的两个步骤中,我们将体验这两种方式。 + +#### 步骤五:通过直接脚本配置并执行流水线作业 + +要使用直接脚本执行流水线,请首先从 GitHub 复制该 [Jenkinsfile 示例][6]的内容。选择 “Pipeline script” 作为 “Destination”,然后将该 Jenkinsfile 的内容粘贴到 “Script” 中。花一些时间研究一下 Jenkins 文件的结构。注意,共有三个阶段:Build、Test 和 Deploy,它们是任意的,可以是任何一个。每个阶段中都有一些步骤;在此示例中,它们只是打印一些随机消息。 + +单击 “Save” 以保留更改,这将自动将你带回到 “Job Overview” 页面。 + +![Configure to Run as Jenkins Script][12] + +要开始构建流水线的过程,请单击 “Build Now”。如果一切正常,你将看到第一个流水线(如下面的这个)。 + +![Click Build Now and See Result][13] + +要查看流水线脚本构建的输出,请单击任何阶段,然后单击 “Log”。你会看到这样的消息。 + +![Visit sample GitHub with Jenkins get clone link][14] + +#### 步骤六:通过 SCM 配置并执行流水线作业 + +现在,换个方式:在此步骤中,你将通过从源代码控制的 GitHub 中复制 Jenkinsfile 来部署相同的 Jenkins 作业。在同一个 [GitHub 存储库][6]中,通过单击 “Clone or download” 并复制其 URL 来找到其存储库 URL。 + +![Checkout from GitHub][15] + +单击 “Configure” 以修改现有作业。滚动到 “Advanced Project Options” 设置,但这一次,从 “Destination” 下拉列表中选择 “Pipeline script from SCM” 选项。将 GitHub 存储库的 URL 粘贴到 “Repository URL” 中,然后在 “Script Path” 中键入 “Jenkinsfile”。 单击 “Save” 按钮保存。 + +![Change to Pipeline script from SCM][16] + +要构建流水线,回到 “Task Overview” 页面后,单击 “Build Now” 以再次执行作业。结果与之前相同,除了多了一个称为 “Declaration: Checkout SCM” 的阶段。 + +![Build again and verify][17] + +要查看来自 SCM 构建的流水线的输出,请单击该阶段并查看 “Log” 以检查源代码控制克隆过程的进行情况。 + +![Verify Checkout Procedure][18] + +### 除了打印消息,还能做更多 + +恭喜你!你已经建立了第一个 Jenkins 流水线! + +“但是等等”,你说,“这太有限了。除了打印无用的消息外,我什么都做不了。”那没问题。到目前为止,本教程仅简要介绍了 Jenkins 流水线可以做什么,但是你可以通过将其与其他工具集成来扩展其功能。以下是给你的下一个项目的一些思路: + +* 建立一个多阶段的 Java 构建流水线,从以下阶段开始:从 Nexus 或 Artifactory 之类的 JAR 存储库中拉取依赖项、编译 Java 代码、运行单元测试、打包为 JAR/WAR 文件,然后部署到云服务器。 +* 实现一个高级代码测试仪表板,该仪表板将基于 Selenium 的单元测试、负载测试和自动用户界面测试,报告项目的运行状况。 +* 构建多流水线或多用户流水线,以自动化执行 Ansible 剧本的任务,同时允许授权用户响应正在进行的任务。 +* 设计完整的端到端 DevOps 流水线,该流水线可提取存储在 SCM 中的基础设施资源文件和配置文件(例如 GitHub),并通过各种运行时程序执行该脚本。 + +学习本文结尾处的任何教程,以了解这些更高级的案例。 + +#### 管理 Jenkins + +在 Jenkins 主面板,点击 “Manage Jenkins”。 + +![Manage Jenkins][19] + +#### 全局工具配置 + +有许多可用工具,包括管理插件、查看系统日志等。单击 “Global Tool Configuration”。 + +![Global Tools Configuration][20] + +#### 增加附加能力 + +在这里,你可以添加 JDK 路径、Git、Gradle 等。配置工具后,只需将该命令添加到 Jenkinsfile 中或通过 Jenkins 脚本执行即可。 + +![See Various Options for Plugin][21] + +### 后继 + +本文为你介绍了使用酷炫的开源工具 Jenkins 创建 CI/CD 流水线的方法。要了解你可以使用 Jenkins 完成的许多其他操作,请在 Opensource.com 上查看以下其他文章: + +* [Jenkins X 入门][22] +* [使用 Jenkins 安装 OpenStack 云][23] +* [在容器中运行 Jenkins][24] +* [Jenkins 流水线入门][25] +* [如何与 Jenkins 一起运行 JMeter][26] +* [将 OpenStack 集成到你的 Jenkins 工作流中][27] + +你可能对我为你的开源之旅而写的其他一些文章感兴趣: + +* [9 个用于构建容错系统的开源工具][28] +* [了解软件设计模式][29] +* [使用开源工具构建 DevOps 流水线的初学者指南][2] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/9/intro-building-cicd-pipelines-jenkins + +作者:[Bryant Son][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/brson +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/pipe-pipeline-grid.png?itok=kkpzKxKg (pipelines) +[2]: https://linux.cn/article-11307-1.html +[3]: https://jenkins.io/ +[4]: https://opensource.com/sites/default/files/uploads/diagrampipeline.jpg (Pipeline example) +[5]: https://opensource.com/sites/default/files/uploads/0_endresultpreview_0.jpg (Final Result) +[6]: https://github.com/bryantson/CICDPractice +[7]: https://jenkins.io/download/ +[8]: https://opensource.com/sites/default/files/uploads/2_downloadwar.jpg (Download Jenkins as Java WAR file) +[9]: https://opensource.com/sites/default/files/uploads/3_runasjar.jpg (Execute as an executable JAR binary) +[10]: https://opensource.com/sites/default/files/uploads/4_createnewjob.jpg (Create New Job) +[11]: https://opensource.com/sites/default/files/uploads/5_createpipeline.jpg (Create New Pipeline Job) +[12]: https://opensource.com/sites/default/files/uploads/6_runaspipelinescript.jpg (Configure to Run as Jenkins Script) +[13]: https://opensource.com/sites/default/files/uploads/7_buildnow4script.jpg (Click Build Now and See Result) +[14]: https://opensource.com/sites/default/files/uploads/8_seeresult4script.jpg (Visit sample GitHub with Jenkins get clone link) +[15]: https://opensource.com/sites/default/files/uploads/9_checkoutfromgithub.jpg (Checkout from GitHub) +[16]: https://opensource.com/sites/default/files/uploads/10_runsasgit.jpg (Change to Pipeline script from SCM) +[17]: https://opensource.com/sites/default/files/uploads/11_seeresultfromgit.jpg (Build again and verify) +[18]: https://opensource.com/sites/default/files/uploads/12_verifycheckout.jpg (Verify Checkout Procedure) +[19]: https://opensource.com/sites/default/files/uploads/13_managingjenkins.jpg (Manage Jenkins) +[20]: https://opensource.com/sites/default/files/uploads/14_globaltoolsconfiguration.jpg (Global Tools Configuration) +[21]: https://opensource.com/sites/default/files/uploads/15_variousoptions4plugin.jpg (See Various Options for Plugin) +[22]: https://opensource.com/article/18/11/getting-started-jenkins-x +[23]: https://opensource.com/article/18/4/install-OpenStack-cloud-Jenkins +[24]: https://linux.cn/article-9741-1.html +[25]: https://opensource.com/article/18/4/jenkins-pipelines-with-cucumber +[26]: https://opensource.com/life/16/7/running-jmeter-jenkins-continuous-delivery-101 +[27]: https://opensource.com/business/15/5/interview-maish-saidel-keesing-cisco +[28]: https://opensource.com/article/19/3/tools-fault-tolerant-system +[29]: https://opensource.com/article/19/7/understanding-software-design-patterns diff --git a/published/20190906 6 Open Source Paint Applications for Linux Users.md b/published/20190906 6 Open Source Paint Applications for Linux Users.md new file mode 100644 index 0000000000..72eecbff38 --- /dev/null +++ b/published/20190906 6 Open Source Paint Applications for Linux Users.md @@ -0,0 +1,214 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11554-1.html) +[#]: subject: (6 Open Source Paint Applications for Linux Users) +[#]: via: (https://itsfoss.com/open-source-paint-apps/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +6 款面向 Linux 用户的开源绘图应用程序 +====== + +小时候,当我开始使用计算机(在 Windows XP 中)时,我最喜欢的应用程序是微软的“画图”。我能在它上面涂鸦数个小时。出乎意料,孩子们仍然喜欢这个“画图”应用程序。不仅仅是孩子们,这个简单的“画图”应用程序,在很多情况下都能派上用场。 + +你可以找到一堆可以让你绘制/绘图或操作图片的应用程序。然而,其中一些是专有软件。既然你是一名 Linux 用户,为什么不关注一下开源绘图应用程序呢? + +在这篇文章中,我们将列出一些最好的开源绘图应用程序,它们可以替代可用于 Linux 的专有绘画软件。 + +### 开源绘图 & 绘制应用程序 + +![][1] + +**注意:** 该列表没有特别的排名顺序。 + +#### 1、Pinta + +![][2] + +主要亮点: + + * Paint.NET / 微软“画图”的极好替代品 + * 支持附加组件(有对 WebP 图像的支持) + * 支持图层 + +[Pinta][3] 是一款令人赞叹的开源绘图应用程序,非常适合绘图和简单的图片编辑。换句话说,它是一款具有精美功能的简单绘图应用程序。 + +你可以将 [Pinta][4] 视为 Linux 上的“画图”的一个替代品,但是带有图层支持等等。不仅仅是“画图”,它也可以替代 Windows 上的 Paint.NET。尽管 Paint.NET 更好一些,但 Pinta 似乎是个不错的选择。 + +几个附加组件可以用于增强功能,例如[在 Linux 上支持 WebP 图像][5]。除了图层支持之外,你还可以轻松地调整图片大小、添加特效、进行调整(亮度、对比度等等),以及在导出图片时调整其质量。 + +##### 如何安装 Pinta ? + +你应该能够在软件中心/应用程序中心/软件包管理器中简单地找到它。只需要输入 “Pinta”,并开始安装它。要么也可以尝试 [Flatpak][6] 软件包。 + +或者,你可以在终端中输入下面的命令(Ubuntu/Debian): + +``` +sudo apt install pinta +``` + +下载软件包和安装指南的更多信息,参考[官方下载页面][7]。 + +#### 2、Krita + +![][8] + +主要亮点: + + * HDR 绘图 + * 支持 PSD + * 支持图层 + * 笔刷稳定器 + * 二维动画 + +Krita 是 Linux 上最高级的开源绘图应用程序之一。当然,对于本文而言,它可以帮助你绘制草图和在画布上胡写乱画。除此之外,它还提供很多功能。 + +例如,如果你的手有点颤抖,它可以帮助你稳定笔刷的笔划。你可以使用内置的矢量工具来创建漫画画板和其它有趣的东西。如果你正在寻找具有全面的颜色管理支持、绘图助理和图层管理的软件,Krita 应该是你最好的选择。 + +##### 如何安装 Krita ? + +类似于 pinta,你可以在软件中心/应用程序中心或软件包管理器的列表中找到它。它也可以 [Flatpak 存储库][10]中找到。 + +考虑通过终端安装它?输入下面的命令: + +``` +sudo apt install krita +``` + +要么你也可以前往它们的[官方下载页面][11]来获取 AppImage 文件并运行它。 + +如果你对 AppImage 文件一无所知,查看我们的指南 —— [如何使用 AppImage][12]。 + +#### 3、Tux Paint + +![][13] + +主要亮点: + + * 给儿童用的一个简单直接的绘图应用程序 + +我不是开玩笑,对于 3-12 岁儿童来说,Tux Paint 是最好的开源绘图应用程序之一。当然,当你只想乱画时,那无需选择,所以,在这种情况下,Tux Paint 似乎是最好的选择(即使是成年人!)。 + +##### 如何安装 Tuxpaint ? + +Tuxpaint 可以从软件中心或软件包管理器下载。无论哪种情况,在 Ubuntu/Debian 上安装它,在终端中输入下面的命令: + +``` +sudo apt install tuxpaint +``` + +关于它的更多信息,前往[官方站点][14]。 + +#### 4、Drawpile + +![][15] + +主要亮点: + + * 协同绘制 + * 内置聊天功能,可与其他用户互动 + * 图层支持 + * 记录绘制会话 + +Drawpile 是一个有趣的开源绘图应用程序,在该程序中,你可以与其他用户实时协作。确切地说,你们可以单个画布中同时绘制。除了这个独特的功能,它还有图层支持、记录绘制会话的能力,甚至还有与协作用户进行交互的聊天功能。 + +你可以主持或加入一个公共会话,或通过一个密码与你的朋友建立私有会话。默认情况下,服务器将是你的计算机,但是如果你需要远程服务器那也可以。 + +注意,你将需要[注册一个 Drawpile 账户][16] 才能进行协作。 + +##### 如何安装 Drawpile ? + +据我所知,你只能在 [Flatpak 存储库][17]的列表中找到它。 + +#### 5、MyPaint + +![][19] + +主要亮点: + + * 易用的数码画家工具 + * 支持图层管理 + * 很多微调你的画笔和绘制的选项 + +对于数码画家来说,[MyPaint][20] 是一个简单而强大的工具。它具有许多选项,可以调整以制作出完美的数字画笔笔触。我不是一个数字艺术家(但我是一个涂鸦者),但是我注意到有很多调整笔刷、颜色的选项,和一个添加中间结果暂存器面板的选项。 + +它也支持图层管理,也许你需要它。最新的稳定版本已经有几年没有更新了,但是当前的 alpha 构建版本(我测试过)运行良好。如果你正在 Linux 上寻找一个开源绘图应用程序 —— 试试这个。 + +##### 如何安装 MyPaint ? + +MyPaint 可在官方存储库中获得。然而,这是老旧的版本。如果你仍然想继续,你可以在软件中心搜索它,或在终端中输入下面的命令: + +``` +sudo apt install mypaint +``` + +你可以前往它的官方 [GitHub 发布页面][21]获取最新的 alpha 构建版本,获取 [AppImage 文件][12](任意版本)并使它可执行并启动应用程序。 + +#### 6、KolourPaint + +![][22] + +主要亮点: + + * 一个 Linux 上的“画图”的简单替代品 + * 不支持图层管理 + +如果你不需要任何图层管理的支持,而只是想要一个开源绘图应用程序来绘制东西 —— 那就是它了。 + +[KolourPaint][23] 最初是为 KDE 桌面环境定制的,但是它在其它的桌面环境中也能完美地工作。 + +##### 如何安装 KolourPaint ? + +你可以从软件中心安装 KolourPaint,或通过终端使用下面的命令: + +``` +sudo apt install kolourpaint4 +``` + +你总可以试试 [Flathub][24]。 + +### 总结 + +如果你在考虑如 GIMP/Inkscape 这样的应用程序,我们在另一篇关于[给数码艺术家的最好 Linux 工具][25]的文章中列出。如果你对更多的选择好奇,我建议你去查看它。 + +在这里,我们尝试编写一份 Linux 可用的最佳开源绘图应用程序列表。如果你认为我们错过一些东西,请在下面的评论区告诉我们! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/open-source-paint-apps/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/open-source-paint-apps.png?resize=800%2C450&ssl=1 +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/pinta.png?ssl=1 +[3]: https://pinta-project.com/pintaproject/pinta/ +[4]: https://itsfoss.com/pinta-1-6-ubuntu-linux-mint/ +[5]: https://itsfoss.com/webp-ubuntu-linux/ +[6]: https://www.flathub.org/apps/details/com.github.PintaProject.Pinta +[7]: https://pinta-project.com/pintaproject/pinta/releases +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/krita-paint.png?ssl=1 +[9]: https://itsfoss.com/things-to-do-after-installing-fedora-24/ +[10]: https://www.flathub.org/apps/details/org.kde.krita +[11]: https://krita.org/en/download/krita-desktop/ +[12]: https://itsfoss.com/use-appimage-linux/ +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/tux-paint.jpg?ssl=1 +[14]: http://www.tuxpaint.org/ +[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/09/drawpile.png?ssl=1 +[16]: https://drawpile.net/accounts/signup/ +[17]: https://flathub.org/apps/details/net.drawpile.drawpile +[18]: https://itsfoss.com/ocs-store/ +[19]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/mypaint.png?ssl=1 +[20]: https://mypaint.org/ +[21]: https://github.com/mypaint/mypaint/releases +[22]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/09/kolourpaint.png?ssl=1 +[23]: http://kolourpaint.org/ +[24]: https://flathub.org/apps/details/org.kde.kolourpaint +[25]: https://itsfoss.com/best-linux-graphic-design-software/ diff --git a/published/20190912 How to fix common pitfalls with the Python ORM tool SQLAlchemy.md b/published/20190912 How to fix common pitfalls with the Python ORM tool SQLAlchemy.md new file mode 100644 index 0000000000..b7f51e093b --- /dev/null +++ b/published/20190912 How to fix common pitfalls with the Python ORM tool SQLAlchemy.md @@ -0,0 +1,194 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11590-1.html) +[#]: subject: (How to fix common pitfalls with the Python ORM tool SQLAlchemy) +[#]: via: (https://opensource.com/article/19/9/common-pitfalls-python) +[#]: author: (Zach Todd https://opensource.com/users/zchtoddhttps://opensource.com/users/lauren-pritchetthttps://opensource.com/users/liranhaimovitchhttps://opensource.com/users/moshez) + +如何修复使用 Python ORM 工具 SQLAlchemy 时的常见陷阱 +====== + +> 在使用 SQLAlchemy 时,那些看似很小的选择可能对这种对象关系映射工具包的性能产生重要影响。 + +![A python with a package.][1] + +对象关系映射Object-relational mapping([ORM][2])使应用程序开发人员的工作更轻松,在很大程度是因为它允许你使用你可能知道的语言(例如 Python)与数据库交互,而不是使用原始 SQL 语句查询。[SQLAlchemy][3] 是一个 Python ORM 工具包,它提供使用 Python 访问 SQL 数据库的功能。它是一个成熟的 ORM 工具,增加了模型关系、强大的查询构造范式、简单的序列化等优点。然而,它的易用性使得人们很容易忘记其背后发生了什么。使用 SQLAlchemy 时做出的看似很小的选择可能产生非常大的性能影响。 + +本文解释了开发人员在使用 SQLAlchemy 时遇到的一些最重要的性能问题,以及如何解决这些问题。 + +### 只需要计数但检索整个结果集 + +有时开发人员只需要一个结果计数,但是没有使用数据库计数功能,而是获取了所有结果,然后使用 Python 中的 `len` 完成计数。 + +``` +count = len(User.query.filter_by(acct_active=True).all()) +``` + +相反,使用 SQLAlchemy 的 `count` 方法将在服务器端执行计数,从而减少发送到客户端的数据。在前面的例子中调用 `all()` 也会导致模型对象的实例化,如果有很多数据,那么时间代价可能会非常昂贵。 + +除非还需要做其他的事情,否则只需使用 `count` 方法: + +``` +count = User.query.filter_by(acct_active=True).count() +``` + +### 只需要几列时检索整个模型 + +在许多情况下,发出查询时只需要几列数据。SQLAlchemy 可以只获取你想要的列,而不是返回整个模型实例。这不仅减少了发送的数据量,还避免了实例化整个对象。使用列数据的元组而不是模型可以快得多。 + +``` +result = User.query.all() +for user in result: +    print(user.name, user.email) +``` + +反之,使用 `with_entities` 方法只选择所需要的内容: + +``` +result = User.query.with_entities(User.name, User.email).all() +for (username, email) in result: +    print(username, email) +``` + +### 每次循环都更新一个对象 + +避免使用循环来单独更新集合。虽然数据库可以非常快地执行单个更新,但应用程序和数据库服务器之间的往返时间将快速累加。通常,在合理的情况下争取更少的查询。 + +``` +for user in users_to_update: +  user.acct_active = True +  db.session.add(user) +``` + +改用批量更新方法: + +``` +query = User.query.filter(user.id.in_([user.id for user in users_to_update])) +query.update({"acct_active": True}, synchronize_session=False) +``` + +### 触发级联删除 + +ORM 允许在模型关系上进行简单的配置,但是有一些微妙的行为可能会令人吃惊。大多数数据库通过外键和各种级联选项维护关系完整性。SQLAlchemy 允许你使用外键和级联选项定义模型,但是 ORM 具有自己的级联逻辑,可以取代数据库。 + +考虑以下模型: + +``` +class Artist(Base): +    __tablename__ = "artist" + +    id = Column(Integer, primary_key=True) +    songs = relationship("Song", cascade="all, delete") + + +class Song(Base): +    __tablename__ = "song" + +    id = Column(Integer, primary_key=True) +    artist_id = Column(Integer, ForeignKey("artist.id", ondelete="CASCADE")) +``` + +删除歌手将导致 ORM 在 `song` 表上发出 `delete` 查询,从而防止由于外键导致的删除操作。这种行为可能会成为复杂关系和大量记录的瓶颈。 + +请包含 `passive_deletes` 选项,以确保让数据库来管理关系。但是,请确保你的数据库具有此功能。例如,SQLite 默认情况下不管理外键。 + +``` +songs = relationship("Song", cascade all, delete", passive_deletes=True) +``` + +### 当要使用贪婪加载时,应使用延迟加载 + +延迟加载是 SQLAlchemy 处理关系的默认方法。从上一个例子构建来看,加载一个歌手时不会同时加载他或她的歌曲。这通常是一个好主意,但是如果总是需要加载某些关系,单独的查询可能会造成浪费。 + +如果允许以延迟方式加载关系,像 [Marshmallow][4] 这样流行的序列化框架可以触发级联查询。 + +有几种方法可以控制此行为。最简单的方法是通过 relationship 函数本身。 + +``` +songs = relationship("Song", lazy="joined", cascade="all, delete") +``` + +这将导致一个左连接被添加到任何歌手的查询中,因此,`songs` 集合将立即可用。尽管有更多数据返回给客户端,但往返次数可能会少得多。 + +SQLAlchemy 为无法采用这种综合方法的情况提供了更细粒度的控制,可以使用 `joinedload()` 函数在每个查询的基础上切换连接的加载。 + +``` +from sqlalchemy.orm import joinedload + +artists = Artist.query.options(joinedload(Artist.songs)) +print(artists.songs) # Does not incur a roundtrip to load +``` + +### 使用 ORM 进行批量记录导入 + +导入成千上万条记录时,构建完整模型实例的开销会成为主要瓶颈。想象一下,从一个文件中加载数千首歌曲记录,其中每首歌曲都先被转换为字典。 + +``` +for song in songs: +    db.session.add(Song(`song)) +``` + +相反,绕过 ORM,只使用核心的 SQLAlchemy 参数绑定功能。 + +``` +batch = [] +insert_stmt = Song.__table__.insert() +for song in songs: +    if len(batch) > 1000: +       db.session.execute(insert_stmt, batch) +       batch.clear() +    batch.append(song) +if batch: +    db.session.execute(insert_stmt, batch) +``` + +请记住,此方法会自然而然地跳过你可能依赖的任何客户端 ORM 逻辑,例如基于 Python 的列默认值。尽管此方法比将对象加载为完整的模型实例要快,但是你的数据库可能具有更快的批量加载方法。例如,PostgreSQL 的 `COPY` 命令为加载大量记录提供了最佳性能。 + +### 过早调用提交或刷新 + +在很多情况下,你需要将子记录与其父记录相关联,反之亦然。一种显然的方法是刷新会话,以便为有问题的记录分配一个 ID。 + +``` +artist = Artist(name="Bob Dylan") +song = Song(title="Mr. Tambourine Man") + +db.session.add(artist) +db.session.flush() + +song.artist_id = artist.id +``` + +对于每个请求,多次提交或刷新通常是不必要的,也是不可取的。数据库刷新涉及强制在数据库服务器上进行磁盘写入,在大多数情况下,客户端将阻塞,直到服务器确认已写入数据为止。 + +SQLAlchemy 可以在幕后跟踪关系和管理相关键。 + +``` +artist = Artist(name="Bob Dylan") +song = Song(title="Mr. Tambourine Man") + +artist.songs.append(song) +``` + +### 总结 + +我希望这一系列常见的陷阱可以帮助你避免这些问题,并使你的应用平稳运行。通常,在诊断性能问题时,测量是关键。大多数数据库都提供性能诊断功能,可以帮助你定位问题,例如 PostgreSQL 的 `pg_stat_statements` 模块。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/9/common-pitfalls-python + +作者:[Zach Todd][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/zchtoddhttps://opensource.com/users/lauren-pritchetthttps://opensource.com/users/liranhaimovitchhttps://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python_snake_file_box.jpg?itok=UuDVFLX- (A python with a package.) +[2]: https://en.wikipedia.org/wiki/Object-relational_mapping +[3]: https://www.sqlalchemy.org/ +[4]: https://marshmallow.readthedocs.io/en/stable/ diff --git a/published/20140510 Managing Digital Files (e.g., Photographs) in Files and Folders.md b/published/201910/20140510 Managing Digital Files (e.g., Photographs) in Files and Folders.md similarity index 100% rename from published/20140510 Managing Digital Files (e.g., Photographs) in Files and Folders.md rename to published/201910/20140510 Managing Digital Files (e.g., Photographs) in Files and Folders.md diff --git a/published/20180706 Building a Messenger App- OAuth.md b/published/201910/20180706 Building a Messenger App- OAuth.md similarity index 100% rename from published/20180706 Building a Messenger App- OAuth.md rename to published/201910/20180706 Building a Messenger App- OAuth.md diff --git a/published/20180906 What a shell dotfile can do for you.md b/published/201910/20180906 What a shell dotfile can do for you.md similarity index 100% rename from published/20180906 What a shell dotfile can do for you.md rename to published/201910/20180906 What a shell dotfile can do for you.md diff --git a/published/20190214 The Earliest Linux Distros- Before Mainstream Distros Became So Popular.md b/published/201910/20190214 The Earliest Linux Distros- Before Mainstream Distros Became So Popular.md similarity index 100% rename from published/20190214 The Earliest Linux Distros- Before Mainstream Distros Became So Popular.md rename to published/201910/20190214 The Earliest Linux Distros- Before Mainstream Distros Became So Popular.md diff --git a/published/20190301 Guide to Install VMware Tools on Linux.md b/published/201910/20190301 Guide to Install VMware Tools on Linux.md similarity index 100% rename from published/20190301 Guide to Install VMware Tools on Linux.md rename to published/201910/20190301 Guide to Install VMware Tools on Linux.md diff --git a/published/20190320 Move your dotfiles to version control.md b/published/201910/20190320 Move your dotfiles to version control.md similarity index 100% rename from published/20190320 Move your dotfiles to version control.md rename to published/201910/20190320 Move your dotfiles to version control.md diff --git a/published/20190404 How writers can get work done better with Git.md b/published/201910/20190404 How writers can get work done better with Git.md similarity index 100% rename from published/20190404 How writers can get work done better with Git.md rename to published/201910/20190404 How writers can get work done better with Git.md diff --git a/published/20190513 Blockchain 2.0 - Introduction To Hyperledger Fabric -Part 10.md b/published/201910/20190513 Blockchain 2.0 - Introduction To Hyperledger Fabric -Part 10.md similarity index 100% rename from published/20190513 Blockchain 2.0 - Introduction To Hyperledger Fabric -Part 10.md rename to published/201910/20190513 Blockchain 2.0 - Introduction To Hyperledger Fabric -Part 10.md diff --git a/published/20190614 What is a Java constructor.md b/published/201910/20190614 What is a Java constructor.md similarity index 100% rename from published/20190614 What is a Java constructor.md rename to published/201910/20190614 What is a Java constructor.md diff --git a/published/20190627 RPM packages explained.md b/published/201910/20190627 RPM packages explained.md similarity index 100% rename from published/20190627 RPM packages explained.md rename to published/201910/20190627 RPM packages explained.md diff --git a/published/20190701 Learn how to Record and Replay Linux Terminal Sessions Activity.md b/published/201910/20190701 Learn how to Record and Replay Linux Terminal Sessions Activity.md similarity index 100% rename from published/20190701 Learn how to Record and Replay Linux Terminal Sessions Activity.md rename to published/201910/20190701 Learn how to Record and Replay Linux Terminal Sessions Activity.md diff --git a/published/20190719 Buying a Linux-ready laptop.md b/published/201910/20190719 Buying a Linux-ready laptop.md similarity index 100% rename from published/20190719 Buying a Linux-ready laptop.md rename to published/201910/20190719 Buying a Linux-ready laptop.md diff --git a/published/20190805 How to Install and Configure PostgreSQL on Ubuntu.md b/published/201910/20190805 How to Install and Configure PostgreSQL on Ubuntu.md similarity index 100% rename from published/20190805 How to Install and Configure PostgreSQL on Ubuntu.md rename to published/201910/20190805 How to Install and Configure PostgreSQL on Ubuntu.md diff --git a/published/20190809 Mutation testing is the evolution of TDD.md b/published/201910/20190809 Mutation testing is the evolution of TDD.md similarity index 100% rename from published/20190809 Mutation testing is the evolution of TDD.md rename to published/201910/20190809 Mutation testing is the evolution of TDD.md diff --git a/published/20190822 A Raspberry Pi Based Open Source Tablet is in Making and it-s Called CutiePi.md b/published/201910/20190822 A Raspberry Pi Based Open Source Tablet is in Making and it-s Called CutiePi.md similarity index 100% rename from published/20190822 A Raspberry Pi Based Open Source Tablet is in Making and it-s Called CutiePi.md rename to published/201910/20190822 A Raspberry Pi Based Open Source Tablet is in Making and it-s Called CutiePi.md diff --git a/published/20190823 The lifecycle of Linux kernel testing.md b/published/201910/20190823 The lifecycle of Linux kernel testing.md similarity index 100% rename from published/20190823 The lifecycle of Linux kernel testing.md rename to published/201910/20190823 The lifecycle of Linux kernel testing.md diff --git a/published/20190824 How to compile a Linux kernel in the 21st century.md b/published/201910/20190824 How to compile a Linux kernel in the 21st century.md similarity index 100% rename from published/20190824 How to compile a Linux kernel in the 21st century.md rename to published/201910/20190824 How to compile a Linux kernel in the 21st century.md diff --git a/published/20190826 Introduction to the Linux chown command.md b/published/201910/20190826 Introduction to the Linux chown command.md similarity index 100% rename from published/20190826 Introduction to the Linux chown command.md rename to published/201910/20190826 Introduction to the Linux chown command.md diff --git a/published/20190830 How to Install Linux on Intel NUC.md b/published/201910/20190830 How to Install Linux on Intel NUC.md similarity index 100% rename from published/20190830 How to Install Linux on Intel NUC.md rename to published/201910/20190830 How to Install Linux on Intel NUC.md diff --git a/published/20190901 Best Linux Distributions For Everyone in 2019.md b/published/201910/20190901 Best Linux Distributions For Everyone in 2019.md similarity index 100% rename from published/20190901 Best Linux Distributions For Everyone in 2019.md rename to published/201910/20190901 Best Linux Distributions For Everyone in 2019.md diff --git a/published/20190911 4 open source cloud security tools.md b/published/201910/20190911 4 open source cloud security tools.md similarity index 100% rename from published/20190911 4 open source cloud security tools.md rename to published/201910/20190911 4 open source cloud security tools.md diff --git a/published/20190916 Copying large files with Rsync, and some misconceptions.md b/published/201910/20190916 Copying large files with Rsync, and some misconceptions.md similarity index 100% rename from published/20190916 Copying large files with Rsync, and some misconceptions.md rename to published/201910/20190916 Copying large files with Rsync, and some misconceptions.md diff --git a/published/20190916 Linux commands to display your hardware information.md b/published/201910/20190916 Linux commands to display your hardware information.md similarity index 100% rename from published/20190916 Linux commands to display your hardware information.md rename to published/201910/20190916 Linux commands to display your hardware information.md diff --git a/published/20190918 Adding themes and plugins to Zsh.md b/published/201910/20190918 Adding themes and plugins to Zsh.md similarity index 100% rename from published/20190918 Adding themes and plugins to Zsh.md rename to published/201910/20190918 Adding themes and plugins to Zsh.md diff --git a/published/20190920 Hone advanced Bash skills by building Minesweeper.md b/published/201910/20190920 Hone advanced Bash skills by building Minesweeper.md similarity index 100% rename from published/20190920 Hone advanced Bash skills by building Minesweeper.md rename to published/201910/20190920 Hone advanced Bash skills by building Minesweeper.md diff --git a/published/20190923 Installation Guide of Manjaro 18.1 (KDE Edition) with Screenshots.md b/published/201910/20190923 Installation Guide of Manjaro 18.1 (KDE Edition) with Screenshots.md similarity index 100% rename from published/20190923 Installation Guide of Manjaro 18.1 (KDE Edition) with Screenshots.md rename to published/201910/20190923 Installation Guide of Manjaro 18.1 (KDE Edition) with Screenshots.md diff --git a/published/20190923 Mutation testing by example- How to leverage failure.md b/published/201910/20190923 Mutation testing by example- How to leverage failure.md similarity index 100% rename from published/20190923 Mutation testing by example- How to leverage failure.md rename to published/201910/20190923 Mutation testing by example- How to leverage failure.md diff --git a/published/20190924 Fedora and CentOS Stream.md b/published/201910/20190924 Fedora and CentOS Stream.md similarity index 100% rename from published/20190924 Fedora and CentOS Stream.md rename to published/201910/20190924 Fedora and CentOS Stream.md diff --git a/published/20190924 How DevOps professionals can become security champions.md b/published/201910/20190924 How DevOps professionals can become security champions.md similarity index 100% rename from published/20190924 How DevOps professionals can become security champions.md rename to published/201910/20190924 How DevOps professionals can become security champions.md diff --git a/published/20190924 Java still relevant, Linux desktop, and more industry trends.md b/published/201910/20190924 Java still relevant, Linux desktop, and more industry trends.md similarity index 100% rename from published/20190924 Java still relevant, Linux desktop, and more industry trends.md rename to published/201910/20190924 Java still relevant, Linux desktop, and more industry trends.md diff --git a/published/20190924 Mutation testing by example- Failure as experimentation.md b/published/201910/20190924 Mutation testing by example- Failure as experimentation.md similarity index 100% rename from published/20190924 Mutation testing by example- Failure as experimentation.md rename to published/201910/20190924 Mutation testing by example- Failure as experimentation.md diff --git a/published/20190925 3 quick tips for working with Linux files.md b/published/201910/20190925 3 quick tips for working with Linux files.md similarity index 100% rename from published/20190925 3 quick tips for working with Linux files.md rename to published/201910/20190925 3 quick tips for working with Linux files.md diff --git a/published/20190925 Essential Accessories for Intel NUC Mini PC.md b/published/201910/20190925 Essential Accessories for Intel NUC Mini PC.md similarity index 100% rename from published/20190925 Essential Accessories for Intel NUC Mini PC.md rename to published/201910/20190925 Essential Accessories for Intel NUC Mini PC.md diff --git a/published/20190925 Mirror your Android screen on your computer with Guiscrcpy.md b/published/201910/20190925 Mirror your Android screen on your computer with Guiscrcpy.md similarity index 100% rename from published/20190925 Mirror your Android screen on your computer with Guiscrcpy.md rename to published/201910/20190925 Mirror your Android screen on your computer with Guiscrcpy.md diff --git a/published/20190926 How to Execute Commands on Remote Linux System over SSH.md b/published/201910/20190926 How to Execute Commands on Remote Linux System over SSH.md similarity index 100% rename from published/20190926 How to Execute Commands on Remote Linux System over SSH.md rename to published/201910/20190926 How to Execute Commands on Remote Linux System over SSH.md diff --git a/published/20190926 You Can Now Use OneDrive in Linux Natively Thanks to Insync.md b/published/201910/20190926 You Can Now Use OneDrive in Linux Natively Thanks to Insync.md similarity index 100% rename from published/20190926 You Can Now Use OneDrive in Linux Natively Thanks to Insync.md rename to published/201910/20190926 You Can Now Use OneDrive in Linux Natively Thanks to Insync.md diff --git a/published/20190927 CentOS 8 Installation Guide with Screenshots.md b/published/201910/20190927 CentOS 8 Installation Guide with Screenshots.md similarity index 100% rename from published/20190927 CentOS 8 Installation Guide with Screenshots.md rename to published/201910/20190927 CentOS 8 Installation Guide with Screenshots.md diff --git a/published/20190929 Bash Script to Generate System Uptime Reports on Linux.md b/published/201910/20190929 Bash Script to Generate System Uptime Reports on Linux.md similarity index 100% rename from published/20190929 Bash Script to Generate System Uptime Reports on Linux.md rename to published/201910/20190929 Bash Script to Generate System Uptime Reports on Linux.md diff --git a/published/20190929 How to Install and Use Cockpit on CentOS 8 - RHEL 8.md b/published/201910/20190929 How to Install and Use Cockpit on CentOS 8 - RHEL 8.md similarity index 100% rename from published/20190929 How to Install and Use Cockpit on CentOS 8 - RHEL 8.md rename to published/201910/20190929 How to Install and Use Cockpit on CentOS 8 - RHEL 8.md diff --git a/published/20191002 3 command line games for learning Bash the fun way.md b/published/201910/20191002 3 command line games for learning Bash the fun way.md similarity index 100% rename from published/20191002 3 command line games for learning Bash the fun way.md rename to published/201910/20191002 3 command line games for learning Bash the fun way.md diff --git a/published/20191002 7 Bash history shortcuts you will actually use.md b/published/201910/20191002 7 Bash history shortcuts you will actually use.md similarity index 100% rename from published/20191002 7 Bash history shortcuts you will actually use.md rename to published/201910/20191002 7 Bash history shortcuts you will actually use.md diff --git a/published/20191003 How to Run the Top Command in Batch Mode.md b/published/201910/20191003 How to Run the Top Command in Batch Mode.md similarity index 100% rename from published/20191003 How to Run the Top Command in Batch Mode.md rename to published/201910/20191003 How to Run the Top Command in Batch Mode.md diff --git a/published/20191004 9 essential GNU binutils tools.md b/published/201910/20191004 9 essential GNU binutils tools.md similarity index 100% rename from published/20191004 9 essential GNU binutils tools.md rename to published/201910/20191004 9 essential GNU binutils tools.md diff --git a/published/20191004 All That You Can Do with Google Analytics, and More.md b/published/201910/20191004 All That You Can Do with Google Analytics, and More.md similarity index 100% rename from published/20191004 All That You Can Do with Google Analytics, and More.md rename to published/201910/20191004 All That You Can Do with Google Analytics, and More.md diff --git a/published/20191004 In Fedora 31, 32-bit i686 is 86ed.md b/published/201910/20191004 In Fedora 31, 32-bit i686 is 86ed.md similarity index 100% rename from published/20191004 In Fedora 31, 32-bit i686 is 86ed.md rename to published/201910/20191004 In Fedora 31, 32-bit i686 is 86ed.md diff --git a/published/20191005 Use GameHub to Manage All Your Linux Games in One Place.md b/published/201910/20191005 Use GameHub to Manage All Your Linux Games in One Place.md similarity index 100% rename from published/20191005 Use GameHub to Manage All Your Linux Games in One Place.md rename to published/201910/20191005 Use GameHub to Manage All Your Linux Games in One Place.md diff --git a/published/20191006 How to Install and Configure VNC Server on Centos 8 - RHEL 8.md b/published/201910/20191006 How to Install and Configure VNC Server on Centos 8 - RHEL 8.md similarity index 100% rename from published/20191006 How to Install and Configure VNC Server on Centos 8 - RHEL 8.md rename to published/201910/20191006 How to Install and Configure VNC Server on Centos 8 - RHEL 8.md diff --git a/published/20191007 IceWM - A really cool desktop.md b/published/201910/20191007 IceWM - A really cool desktop.md similarity index 100% rename from published/20191007 IceWM - A really cool desktop.md rename to published/201910/20191007 IceWM - A really cool desktop.md diff --git a/published/20191008 7 steps to securing your Linux server.md b/published/201910/20191008 7 steps to securing your Linux server.md similarity index 100% rename from published/20191008 7 steps to securing your Linux server.md rename to published/201910/20191008 7 steps to securing your Linux server.md diff --git a/published/20191008 How to manage Go projects with GVM.md b/published/201910/20191008 How to manage Go projects with GVM.md similarity index 100% rename from published/20191008 How to manage Go projects with GVM.md rename to published/201910/20191008 How to manage Go projects with GVM.md diff --git a/published/20191009 Command line quick tips- Locate and process files with find and xargs.md b/published/201910/20191009 Command line quick tips- Locate and process files with find and xargs.md similarity index 100% rename from published/20191009 Command line quick tips- Locate and process files with find and xargs.md rename to published/201910/20191009 Command line quick tips- Locate and process files with find and xargs.md diff --git a/published/20191009 Top 10 open source video players for Linux.md b/published/201910/20191009 Top 10 open source video players for Linux.md similarity index 100% rename from published/20191009 Top 10 open source video players for Linux.md rename to published/201910/20191009 Top 10 open source video players for Linux.md diff --git a/published/20191010 DevSecOps pipelines and tools- What you need to know.md b/published/201910/20191010 DevSecOps pipelines and tools- What you need to know.md similarity index 100% rename from published/20191010 DevSecOps pipelines and tools- What you need to know.md rename to published/201910/20191010 DevSecOps pipelines and tools- What you need to know.md diff --git a/published/20191010 Viewing files and processes as trees on Linux.md b/published/201910/20191010 Viewing files and processes as trees on Linux.md similarity index 100% rename from published/20191010 Viewing files and processes as trees on Linux.md rename to published/201910/20191010 Viewing files and processes as trees on Linux.md diff --git a/published/20191011 How to Unzip a Zip File in Linux -Beginner-s Tutorial.md b/published/201910/20191011 How to Unzip a Zip File in Linux -Beginner-s Tutorial.md similarity index 100% rename from published/20191011 How to Unzip a Zip File in Linux -Beginner-s Tutorial.md rename to published/201910/20191011 How to Unzip a Zip File in Linux -Beginner-s Tutorial.md diff --git a/published/20191011 How to use IoT devices to keep children safe.md b/published/201910/20191011 How to use IoT devices to keep children safe.md similarity index 100% rename from published/20191011 How to use IoT devices to keep children safe.md rename to published/201910/20191011 How to use IoT devices to keep children safe.md diff --git a/published/20191013 Object-Oriented Programming and Essential State.md b/published/201910/20191013 Object-Oriented Programming and Essential State.md similarity index 100% rename from published/20191013 Object-Oriented Programming and Essential State.md rename to published/201910/20191013 Object-Oriented Programming and Essential State.md diff --git a/published/20191014 Use sshuttle to build a poor man-s VPN.md b/published/201910/20191014 Use sshuttle to build a poor man-s VPN.md similarity index 100% rename from published/20191014 Use sshuttle to build a poor man-s VPN.md rename to published/201910/20191014 Use sshuttle to build a poor man-s VPN.md diff --git a/translated/tech/20191015 10 Ways to Customize Your Linux Desktop With GNOME Tweaks Tool.md b/published/201910/20191015 10 Ways to Customize Your Linux Desktop With GNOME Tweaks Tool.md similarity index 69% rename from translated/tech/20191015 10 Ways to Customize Your Linux Desktop With GNOME Tweaks Tool.md rename to published/201910/20191015 10 Ways to Customize Your Linux Desktop With GNOME Tweaks Tool.md index 44ccc28328..c9adda9a5d 100644 --- a/translated/tech/20191015 10 Ways to Customize Your Linux Desktop With GNOME Tweaks Tool.md +++ b/published/201910/20191015 10 Ways to Customize Your Linux Desktop With GNOME Tweaks Tool.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (wxy) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11523-1.html) [#]: subject: (10 Ways to Customize Your Linux Desktop With GNOME Tweaks Tool) [#]: via: (https://itsfoss.com/gnome-tweak-tool/) [#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) @@ -10,7 +10,8 @@ 使用 GNOME 优化工具自定义 Linux 桌面的 10 种方法 ====== -![GNOME Tweak Tool Icon][1] + +![][7] 你可以通过多种方法来调整 Ubuntu,以自定义其外观和行为。我发现最简单的方法是使用 [GNOME 优化工具][2]。它也被称为 GNOME Tweak 或简单地称为 Tweak(优化)。 @@ -20,11 +21,11 @@ ### 在 Ubuntu 18.04 或其它版本上安装 GNOME 优化工具 -Gnome 优化工具可从 [Ubuntu 中的 Universe 存储库][3]中安装,因此请确保已在“软件和更新”工具中启用了该工具: +GNOME 优化工具可从 [Ubuntu 中的 Universe 存储库][3]中安装,因此请确保已在“软件和更新”工具中启用了该仓库: ![在 Ubuntu 中启用 Universe 存储库][4] -之后,你可以从软件中心安装 GNOME 优化工具。只需打开软件中心并搜索 “GNOME Tweaks”并从那里安装它: +之后,你可以从软件中心安装 GNOME 优化工具。只需打开软件中心并搜索 “GNOME Tweaks” 并从那里安装它: ![从软件中心安装 GNOME 优化工具][5] @@ -36,45 +37,43 @@ sudo apt install gnome-tweaks ### 用优化工具定制 GNOME 桌面 -![][7] - GNOME 优化工具使你可以进行许多设置更改。其中的某些更改(例如墙纸更改、启动应用程序等)也可以在官方的“系统设置”工具中找到。我将重点介绍默认情况下“设置”中不可用的优化。 #### 1、改变主题 你可以通过各种方式[在 Ubuntu 中安装新主题][8]。但是,如果要更改为新安装的主题,则必须安装GNOME 优化工具。 -你可以在外观部分找到主题和图标设置。你可以浏览可用的主题和图标并设置所需的主题和图标。更改将立即生效。 +你可以在“外观Appearance”部分找到主题和图标设置。你可以浏览可用的主题和图标并设置你喜欢的主题和图标。更改将立即生效。 ![通过 GNOME 优化更改主题][9] -#### 2\、禁用动画以提速你的桌面体验 +#### 2、禁用动画以提速你的桌面体验 -应用程序窗口的打开、关闭、最大化等都有一些细微的动画。你可以禁用这些动画以稍微加快系统的速度,因为它会使用较少的资源。 +应用程序窗口的打开、关闭、最大化等操作都有一些细微的动画。你可以禁用这些动画以稍微加快系统的速度,因为它会稍微使用一点资源。 ![禁用动画以获得稍快的桌面体验][10] #### 3、控制桌面图标 -至少在 Ubuntu 中,你会在桌面上看到“主目录”和“垃圾箱”图标。如果你不喜欢,可以选择禁用它。你还可以选择要在桌面上显示的图标。 +至少在 Ubuntu 中,你会在桌面上看到“家目录Home”和“垃圾箱Trash”图标。如果你不喜欢,可以选择禁用它。你还可以选择要在桌面上显示的图标。 ![在 Ubuntu 中控制桌面图标][11] #### 4、管理 GNOME 扩展 -我想可能知道 [GNOME 扩展][12]。这些是用于桌面的小型“插件”,可扩展 GNOME 桌面的功能。有[大量的 GNOME 扩展][13],可用于在顶部面板中查看 CPU 消耗、获取剪贴板历史记录等。 +我想你可能知道 [GNOME 扩展][12]。这些是用于桌面的小型“插件”,可扩展 GNOME 桌面的功能。有[大量的 GNOME 扩展][13],可用于在顶部面板中查看 CPU 消耗、获取剪贴板历史记录等等。 -我已经写了一篇[安装和使用 GNOME 扩展][14]的详细文章。在这里,我假设你已经在使用它们,如果是这种情况,那么可以从 GNOME 优化工具中对其进行管理。 +我已经写了一篇[安装和使用 GNOME 扩展][14]的详细文章。在这里,我假设你已经在使用它们,如果是这样,可以从 GNOME 优化工具中对其进行管理。 ![管理 GNOME 扩展][15] #### 5、改变字体和缩放比例 -你可以[在 Ubuntu 中安装新字体][16],并使用优化工具在系统范围应用字体更改。如果你认为桌面上的图标和文本太小,也可以更改缩放比例。 +你可以[在 Ubuntu 中安装新字体][16],并使用这个优化工具在系统范围应用字体更改。如果你认为桌面上的图标和文本太小,也可以更改缩放比例。 ![更改字体和缩放比例][17] -#### 6、控制触摸板行为,例如在键入时禁用触摸板,右键单击触摸板即可正常工作 +#### 6、控制触摸板行为,例如在键入时禁用触摸板,使触摸板右键单击可以工作 GNOME 优化工具还允许你在键入时禁用触摸板。如果你在笔记本电脑上快速键入,这将很有用。手掌底部可能会触摸触摸板,并导致光标移至屏幕上不需要的位置。 @@ -84,35 +83,35 @@ GNOME 优化工具还允许你在键入时禁用触摸板。如果你在笔记 你还会注意到[当你按下触摸板的右下角以进行右键单击时,什么也没有发生][19]。你的触摸板并没有问题。这是一项系统设置,可对没有实体右键按钮的任何触摸板(例如旧的 Thinkpad 笔记本电脑)禁用这种右键单击功能。两指点击可为你提供右键单击操作。 -你也可以通过在“鼠标单击模拟”下的“区域”中而不是“手指”中找到它。 +你也可以通过在“鼠标单击模拟Mouse Click Simulation”下设置为“区域Area”中而不是“手指Fingers”来找回这项功能。 ![修复右键单击问题][20] -你可能必须[重新启动 Ubuntu][21] 才能生效。如果你是 Emacs 爱好者,还可以从 Emacs 强制进行键盘绑定。 +你可能必须[重新启动 Ubuntu][21] 来使这项更改生效。如果你是 Emacs 爱好者,还可以强制使用 Emacs 键盘绑定。 #### 7、改变电源设置 -电源这里只有一个设置。盖上盖子后,你可以将笔记本电脑置于挂起模式。 +电源这里只有一个设置。它可以让你在盖上盖子后将笔记本电脑置于挂起模式。 ![GNOME 优化工具中的电源设置][22] #### 8、决定什么显示在顶部面板 -桌面的顶部面板显示了一些重要的信息。在这里有日历、网络图标、系统设置和“活动”选项。 +桌面的顶部面板显示了一些重要的信息。在这里有日历、网络图标、系统设置和“活动Activities”选项。 -你还可以[显示电池百分比][23]、添加日期以及日期和时间,并显示星期数。你还可以启用鼠标热点,以便将鼠标移至屏幕的左上角时可以获得所有正在运行的应用程序的活动视图。 +你还可以[显示电池百分比][23]、添加日期及时间,并显示星期数。你还可以启用鼠标热角,以便将鼠标移至屏幕的左上角时可以获得所有正在运行的应用程序的活动视图。 ![GNOME 优化工具中的顶部面板设置][24] -如果将鼠标将焦点放在应用程序窗口上,则会注意到其菜单显示在顶部面板中。如果你不喜欢这样,可以将其关闭,然后应用程序菜单将显示应用程序本身。 +如果将鼠标焦点放在应用程序窗口上,你会注意到其菜单显示在顶部面板中。如果你不喜欢这样,可以将其关闭,然后应用程序菜单将显示应用程序本身。 #### 9、配置应用窗口 -你可以决定是否在应用程序窗口中显示最大化和最小化选项(右上角的按钮)。你也可以在左右两边改变它们的位置。 +你可以决定是否在应用程序窗口中显示最大化和最小化选项(右上角的按钮)。你也可以改变它们的位置到左边或右边。 ![应用程序窗口配置][25] -还有其他一些配置选项。我不使用它们,但你可以自行探索。 +这里还有其他一些配置选项。我不使用它们,但你可以自行探索。 #### 10、配置工作区 @@ -122,7 +121,7 @@ GNOME 优化工具还允许你围绕工作区配置一些内容。 ### 总结 -对于任何 GNOME 用户,GNOME 优化(Tweaks)工具都是必备工具。它可以帮助你配置桌面的外观和功能。 我感到惊讶的是,该工具甚至没有出现在 Ubuntu 的主存储库中。我认为应该默认安装它,要不,你将需得在 Ubuntu 中手动安装 GNOME 优化工具。 +对于任何 GNOME 用户,GNOME 优化(Tweaks)工具都是必备工具。它可以帮助你配置桌面的外观和功能。 我感到惊讶的是,该工具甚至没有出现在 Ubuntu 的主存储库中。我认为应该默认安装它,要不,你就得在 Ubuntu 中手动安装 GNOME 优化工具。 如果你在 GNOME 优化工具中发现了一些此处没有讨论的隐藏技巧,为什么不与大家分享呢? @@ -133,7 +132,7 @@ via: https://itsfoss.com/gnome-tweak-tool/ 作者:[Abhishek Prakash][a] 选题:[lujun9972][b] 译者:[wxy](https://github.com/wxy) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20191015 4 Free and Open Source Alternatives to Adobe Photoshop.md b/published/201910/20191015 4 Free and Open Source Alternatives to Adobe Photoshop.md similarity index 100% rename from published/20191015 4 Free and Open Source Alternatives to Adobe Photoshop.md rename to published/201910/20191015 4 Free and Open Source Alternatives to Adobe Photoshop.md diff --git a/published/20191015 Bash Script to Delete Files-Folders Older Than -X- Days in Linux.md b/published/201910/20191015 Bash Script to Delete Files-Folders Older Than -X- Days in Linux.md similarity index 100% rename from published/20191015 Bash Script to Delete Files-Folders Older Than -X- Days in Linux.md rename to published/201910/20191015 Bash Script to Delete Files-Folders Older Than -X- Days in Linux.md diff --git a/published/20191016 Linux sudo flaw can lead to unauthorized privileges.md b/published/201910/20191016 Linux sudo flaw can lead to unauthorized privileges.md similarity index 100% rename from published/20191016 Linux sudo flaw can lead to unauthorized privileges.md rename to published/201910/20191016 Linux sudo flaw can lead to unauthorized privileges.md diff --git a/published/20191018 How to Configure Rsyslog Server in CentOS 8 - RHEL 8.md b/published/201910/20191018 How to Configure Rsyslog Server in CentOS 8 - RHEL 8.md similarity index 100% rename from published/20191018 How to Configure Rsyslog Server in CentOS 8 - RHEL 8.md rename to published/201910/20191018 How to Configure Rsyslog Server in CentOS 8 - RHEL 8.md diff --git a/published/20191021 Kubernetes networking, OpenStack Train, and more industry trends.md b/published/201910/20191021 Kubernetes networking, OpenStack Train, and more industry trends.md similarity index 100% rename from published/20191021 Kubernetes networking, OpenStack Train, and more industry trends.md rename to published/201910/20191021 Kubernetes networking, OpenStack Train, and more industry trends.md diff --git a/published/20191021 Pylint- Making your Python code consistent.md b/published/201910/20191021 Pylint- Making your Python code consistent.md similarity index 100% rename from published/20191021 Pylint- Making your Python code consistent.md rename to published/201910/20191021 Pylint- Making your Python code consistent.md diff --git a/published/20191021 Transition to Nftables.md b/published/201910/20191021 Transition to Nftables.md similarity index 100% rename from published/20191021 Transition to Nftables.md rename to published/201910/20191021 Transition to Nftables.md diff --git a/published/20191022 How to Get the Size of a Directory in Linux.md b/published/201910/20191022 How to Get the Size of a Directory in Linux.md similarity index 100% rename from published/20191022 How to Get the Size of a Directory in Linux.md rename to published/201910/20191022 How to Get the Size of a Directory in Linux.md diff --git a/published/20191023 Building container images with the ansible-bender tool.md b/published/201910/20191023 Building container images with the ansible-bender tool.md similarity index 100% rename from published/20191023 Building container images with the ansible-bender tool.md rename to published/201910/20191023 Building container images with the ansible-bender tool.md diff --git a/published/20191023 Using SSH port forwarding on Fedora.md b/published/201910/20191023 Using SSH port forwarding on Fedora.md similarity index 100% rename from published/20191023 Using SSH port forwarding on Fedora.md rename to published/201910/20191023 Using SSH port forwarding on Fedora.md diff --git a/published/20191025 MX Linux 19 Released With Debian 10.1 ‘Buster- - Other Improvements.md b/published/201910/20191025 MX Linux 19 Released With Debian 10.1 ‘Buster- - Other Improvements.md similarity index 100% rename from published/20191025 MX Linux 19 Released With Debian 10.1 ‘Buster- - Other Improvements.md rename to published/201910/20191025 MX Linux 19 Released With Debian 10.1 ‘Buster- - Other Improvements.md diff --git a/translated/news/20191029 Fedora 31 is officially here.md b/published/201910/20191029 Fedora 31 is officially here.md similarity index 98% rename from translated/news/20191029 Fedora 31 is officially here.md rename to published/201910/20191029 Fedora 31 is officially here.md index 3d880492ca..d3af75f5cd 100644 --- a/translated/news/20191029 Fedora 31 is officially here.md +++ b/published/201910/20191029 Fedora 31 is officially here.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (wxy) [#]: reviewer: (wxy) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11522-1.html) [#]: subject: (Fedora 31 is officially here!) [#]: via: (https://fedoramagazine.org/announcing-fedora-31/) [#]: author: (Matthew Miller https://fedoramagazine.org/author/mattdm/) diff --git a/published/20191007 7 Java tips for new developers.md b/published/20191007 7 Java tips for new developers.md new file mode 100644 index 0000000000..c2c90f8679 --- /dev/null +++ b/published/20191007 7 Java tips for new developers.md @@ -0,0 +1,215 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11620-1.html) +[#]: subject: (7 Java tips for new developers) +[#]: via: (https://opensource.com/article/19/10/java-basics) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +给新手 Java 开发者的 7 点提示 +====== + +> 如果你才刚开始学习 Java 编程,这里有七个你需要知道的基础知识。 + +![](https://img.linux.net.cn/data/attachment/album/201911/28/120421di3744urqnyyr6xi.jpg) + +Java 是一个多功能的编程语言,在某种程度上,它用在几乎所有可能涉及计算机的行业了里。Java 的最大优势是,它运行在一个 Java 虚拟机(JVM)中,这是一个翻译 Java 代码为与操作系统兼容的字节码的层。只要有 JVM 存在于你的操作系统上 —— 不管这个操作系统是在一个服务器(或“[无服务器][2]”,也是同样的)、桌面电脑、笔记本电脑、移动设备,或嵌入式设备 —— 那么,Java 应用程序就可以运行在它上面。 + +这使得 Java 成为程序员和用户的一种流行语言。程序员知道,他们只需要写一个软件版本就能最终得到一个可以运行在任何平台上的应用程序;用户知道,应用程序可以运行在他们的计算机上,而不用管他们使用的是什么样的操作系统。 + +很多语言和框架是跨平台的,但是没有实现同样的抽象层。使用 Java,你针对的是 JVM,而不是操作系统。对于程序员,当面对一些编程难题时,这是阻力最小的线路,但是它仅在当你知道如何编程 Java 时有用。如果你刚开始学习 Java 编程,这里有你需要知道的七个基础的提示。 + +但是,首先,如果你不确定是否你安装了 Java ,你可以在一个终端(例如 [Bash][3] 或 [PowerShell][4])中找出来,通过运行: + +``` +$ java --version +openjdk 12.0.2 2019-07-16 +OpenJDK Runtime Environment 19.3 (build 12.0.2+9) +OpenJDK 64-Bit Server VM 19.3 (build 12.0.2+9, mixed mode, sharing) +``` + +如果你得到一个错误,或未返回任何东西,那么你应该安装 [Java 开发套件][5](JDK)来开始 Java 开发。或者,安装一个 Java 运行时环境(JRE),如果你只是需要来运行 Java 应用程序。 + +### 1、Java 软件包 + +在 Java 语言中,相关的类被分组到一个*软件包*中。当你下载 JDK 时所获得的 Java 基础库将被分组到以 `java` 或 `javax` 开头的软件包中。软件包提供一种类似于计算机上的文件夹的功能:它们为相关的元素提供结构和定义(以编程术语说,*命名空间*)。额外的软件包可以从独立开发者、开源项目和商业供应商获得,就像可以为任何编程语言获得库一样。 + +当你写一个 Java 程序时,你应该在你的代码是顶部声明一个软件包名称。如果你只是编写一个简单的应用程序来入门 Java,你的软件包名称可以简单地用你的项目名称。如果你正在使用一个 Java 集成开发环境,如 [Eclipse][6],当你启动一个新的项目时,它为你生成一个合乎情理的软件包名称。 + +``` +package helloworld; + +/** + * @author seth + * An application written in Java. + */ +``` + +除此之外,你可以通过查找它相对于你的项目整体的路径来确定你的软件包名称。例如,如果你正在写一组类来帮助游戏开发,并且该集合被称为 `jgamer`,那么你可能在其中有一些唯一的类。 + +``` +package jgamer.avatar; + +/** + * @author seth + * An imaginary game library. + */ +``` + +你的软件包的顶层是 `jgamer`,并且在其内部中每个软件包都是一个独立的派生物,例如 `jgamer.avatar` 和 `jgamer.score` 等等。在你的文件系统里,其目录结构反映了这一点,`jgamer` 是包含文件 `avatar.java` 和 `score.java` 的顶级目录。 + +### 2、Java 导入 + +作为一名通晓多种语言的程序员,最大的乐趣是找出是否用 `include`、`import`、`use`、`require`,或一些其它术语来引入你不管使用何种编程语言编写的库。在 Java 中,顺便说一句,当导入你的代码的需要的库时,使用 `import` 关键字。 + +``` +package helloworld; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +/** + * @author seth + * A GUI hello world. + */ +``` + +导入是基于该环境的 Java 路径。如果 Java 不知道 Java 库存储在系统上的何处,那么,就不能成功导入。只要一个库被存储在系统的 Java 路径中,那么导入能够成功,并且库能够被用于构建和运行一个 Java 应用程序。 + +如果一个库并不在 Java 路径中(因为,例如,你正在写你自己的库),那么该库可以与你的应用程序绑定在一起(协议许可),以便导入可以按预期地工作。 + +### 3、Java 类 + +Java 类使用关键字 `public class` 声明,以及一个唯一的对应于它的文件名的类名。例如,在项目 `helloworld` 中的一个文件 `Hello.java` 中: + +``` +package helloworld; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +/** + * @author seth + * A GUI hello world. + */ + +public class Hello { +        // this is an empty class +} +``` + +你可以在一个类内部声明变量和函数。在 Java 中,在一个类中的变量被称为*字段*。 + +### 4、Java 方法 + +Java 的方法本质上是对象中的函数。基于预期返回的数据类型(例如 `void`、`int`、`float` 等等),它们被定义为 `public`(意味着它们可以被任何其它类访问)或 `private`(限制它们的使用)。 + + +``` + public void helloPrompt(ActionEvent event) { + String salutation = "Hello %s"; + + string helloMessage = "World"; + message = String.format(salutation, helloMessage); + JOptionPane.showMessageDialog(this, message); + } + + private int someNumber (x) { + return x*2; + } +``` + +当直接调用一个方法时,以其类和方法名称来引用。例如,`Hello.someNumber` 指向在 `Hello` 类中的 `someNumber` 方法。 + +### 5、static + +Java 中的 `static` 关键字使代码中的成员可以独立于包含其的对象而被访问。 + +在面向对象编程中,你编写的代码用作“对象”的模板,这些对象在应用程序运行时产生。例如,你不需要编写一个具体的窗口,而是编写基于 Java 中的窗口类的窗口实例(并由你的代码修改)。由于在应用程序生成它的实例之前,你编写的所有代码都不会“存在”,因此在创建它们所依赖的对象之前,大多数方法和变量(甚至是嵌套类)都无法使用。 + +然而,有时,在对象被通过应用程序创建前,你需要访问或使用其中的数据。(例如,除非事先知道球是红色时,应用程序无法生成一个红色的球)。对于这些情况,请使用 `static` 关键字。 + +### 6、try 和 catch + +Java 擅长捕捉错误,但是,只有你告诉它遇到错误时该做什么,它才能优雅地恢复。在 Java 中,尝试执行一个动作的级联层次结构以 `try` 开头,出现错误时回落到 `catch`,并以 `finally` 结束。如果 `try` 子句失败,则将调用 `catch`,最后,不管结果如何,总是由 `finally` 来执行一些合理的动作。这里是一个示例: + +``` +try { + cmd = parser.parse(opt, args); + + if(cmd.hasOption("help")) { + HelpFormatter helper = new HelpFormatter(); + helper.printHelp("Hello ", opt); + System.exit(0); + } + else { + if(cmd.hasOption("shell") || cmd.hasOption("s")) { + String target = cmd.getOptionValue("tgt"); + } // else + } // fi +} catch (ParseException err) { + System.out.println(err); + System.exit(1); + } //catch + finally { + new Hello().helloWorld(opt); + } //finally +} //try +``` + +这是一个健壮的系统,它试图避免无法挽回的错误,或者,至少,为你提供让用户提交有用的反馈的选项。经常使用它,你的用户将会感谢你! + +### 7、运行 Java 应用程序 + +Java 文件,通常以 `.java` 结尾,理论上说,可以使用 `java` 命令运行。然而,如果一个应用程序很复杂,运行一个单个文件是否会产生有意义的结果是另外一个问题。 + +来直接运行一个 `.java` 文件: + +``` +$ java ./Hello.java +``` + +通常,Java 应用程序以 Java 存档(JAR)文件的形式分发,以 `.jar` 结尾。一个 JAR 文件包含一个清单文件(可以指定主类、项目结构的一些元数据),以及运行应用程序所需的所有代码部分。 + +要运行一个 JAR 文件,你可以双击它的图标(取决于你的操作系统设置),你也可以从终端中启动它: + +``` +$ java -jar ./Hello.jar +``` + +### 适合所有人的 Java + +Java 是一种强大的语言,由于有了 [OpenJDK][12] 项目及其它的努力,它是一种开放式规范,允许像 [IcedTea][13]、[Dalvik][14] 和 [Kotlin][15] 项目的茁壮成长。学习 Java 是一种准备在各种行业中工作的好方法,而且,[使用 Java 的理由很多][16]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/java-basics + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_cafe_brew_laptop_desktop.jpg?itok=G-n1o1-o (Coffee and laptop) +[2]: https://www.redhat.com/en/resources/building-microservices-eap-7-reference-architecture +[3]: https://www.gnu.org/software/bash/ +[4]: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-6 +[5]: http://openjdk.java.net/ +[6]: http://www.eclipse.org/ +[7]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+actionevent +[8]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string +[9]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+joptionpane +[10]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system +[11]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+parseexception +[12]: https://openjdk.java.net/ +[13]: https://icedtea.classpath.org/wiki/Main_Page +[14]: https://source.android.com/devices/tech/dalvik/ +[15]: https://kotlinlang.org/ +[16]: https://opensource.com/article/19/9/why-i-use-java diff --git a/translated/tech/20191008 5 Best Password Managers For Linux Desktop.md b/published/20191008 5 Best Password Managers For Linux Desktop.md similarity index 63% rename from translated/tech/20191008 5 Best Password Managers For Linux Desktop.md rename to published/20191008 5 Best Password Managers For Linux Desktop.md index 63f9c21656..ebdda1f376 100644 --- a/translated/tech/20191008 5 Best Password Managers For Linux Desktop.md +++ b/published/20191008 5 Best Password Managers For Linux Desktop.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11531-1.html) [#]: subject: (5 Best Password Managers For Linux Desktop) [#]: via: (https://itsfoss.com/password-managers-linux/) [#]: author: (Ankush Das https://itsfoss.com/author/ankush/) @@ -10,11 +10,13 @@ 5 个 Linux 桌面上的最佳密码管理器 ====== -_ **密码管理器是创建唯一密码并安全存储它们的有用工具,这样你无需记住密码。了解适用于 Linux 桌面的最佳密码管理器。** _ +> 密码管理器是创建唯一密码并安全存储它们的有用工具,这样你无需记住密码。了解一下适用于 Linux 桌面的最佳密码管理器。 -密码无处不在。网站、论坛、Web 应用等,你需要为其创建帐户和密码。麻烦的是密码。为各个帐户使用相同的密码会带来安全风险,因为[如果其中一个网站遭到入侵,黑客也会在其他网站上尝试相同的电子邮件密码组合][1]。 +![](https://img.linux.net.cn/data/attachment/album/201911/03/102528e97mr0ls89lz9rrr.jpg) -但是,为所有新帐户设置唯一的密码意味着你必须记住所有密码,这对普通人而言不太可能。这就是密码管理器可以提供帮助的地方。 +密码无处不在。网站、论坛、Web 应用等,你需要为其创建帐户和密码。麻烦在于密码,为各个帐户使用相同的密码会带来安全风险,因为[如果其中一个网站遭到入侵,黑客也会在其他网站上尝试相同的电子邮件密码组合][1]。 + +但是,为所有新帐户设置独有的密码意味着你必须记住所有密码,这对普通人而言不太可能。这就是密码管理器可以提供帮助的地方。 密码管理应用会为你建议/创建强密码,并将其存储在加密的数据库中。你只需要记住密码管理器的主密码即可。 @@ -26,121 +28,111 @@ _ **密码管理器是创建唯一密码并安全存储它们的有用工具, ### Linux 密码管理器 -可能的非 FOSS 警报! +> 可能的非 FOSS 警报! -我们优先考虑开源软件(有一些专有软件,请不要讨厌我!),并提供适用于 Linux 的独立桌面应用(GUI)。专有软件已高亮显示。 +> 我们优先考虑开源软件(有一些专有软件,请不要讨厌我!),并提供适用于 Linux 的独立桌面应用(GUI)。专有软件已高亮显示。 -#### 1\. Bitwarden +#### 1、Bitwarden ![][3] 主要亮点: - * 开源 -  * 免费供个人使用(可选付费升级) -  * 云服务器的端到端加密 -  * 跨平台 -  * 有浏览器扩展 -  * 命令行工具 - - +* 开源 +* 免费供个人使用(可选付费升级) +* 云服务器的端到端加密 +* 跨平台 +* 有浏览器扩展 +* 命令行工具 Bitwarden 是 Linux 上最令人印象深刻的密码管理器之一。老实说,直到现在我才知道它。我已经从 [LastPass][4] 切换到了它。我能够轻松地从 LastPass 导入数据,而没有任何问题和困难。 -高级版本的价格仅为每年 10 美元。这似乎是值得的(我已经为个人使用进行了升级)。 +付费版本的价格仅为每年 10 美元。这似乎是值得的(我已经为个人使用进行了升级)。 它是一个开源解决方案,因此没有任何可疑之处。你甚至可以将其托管在自己的服务器上,并为你的组织创建密码解决方案。 -除此之外,你还将获得所有必需的功能,例如用于登录的两步验证、导入/导出凭据,指纹短语(唯一键),密码生成器等等。 +除此之外,你还将获得所有必需的功能,例如用于登录的两步验证、导入/导出凭据、指纹短语(唯一键)、密码生成器等等。 -你可以免费将帐户升级为组织帐户,以便最多与 2 个用户共享你的信息。但是,如果你想要额外的加密存储以及与 5 个用户共享密码的功能,那么高级升级的费用低至每月 1 美元。我认为绝对值得一试! +你可以免费将帐户升级为组织帐户,以便最多与 2 个用户共享你的信息。但是,如果你想要额外的加密存储以及与 5 个用户共享密码的功能,那么付费升级的费用低至每月 1 美元。我认为绝对值得一试! -[Bitwarden][5] +- [Bitwarden][5] -#### 2\. Buttercup +#### 2、Buttercup ![][6] 主要亮点: - * 开源 -  * 免费,没有高级选项。 -  * 跨平台 -  * 有浏览器扩展 +* 开源 +* 免费,没有付费方式。 +* 跨平台 +* 有浏览器扩展 +这是 Linux 中的另一个开源密码管理器。Buttercup 可能不是一个非常流行的解决方案。但是,如果你在寻找一种更简单的保存凭据的方法,那么这将是一个不错的开始。 - -Linux 中的另一个开源密码管理器。Buttercup 可能不是一个非常流行的解决方案。但是,如果你在寻找一种更简单的方法来保存凭据,那么这将是一个不错的开始。 - -与其他软件不同,你不必对其云服务器持怀疑态度,因为它只支持离线使用并支持连接 [Dropbox][7]、[OwnCloud] [8]、[Nextcloud][9] 和 [WebDAV][10] 等云服务。 +与其他软件不同,你不必对怀疑其云服务器的安全,因为它只支持离线使用并支持连接 [Dropbox][7]、[OwnCloud] [8]、[Nextcloud][9] 和 [WebDAV][10] 等云服务。 因此,如果需要同步数据,那么可以选择云服务。你有不同选择。 -[Buttercup][11] +- [Buttercup][11] -#### 3\. KeePassXC +#### 3、KeePassXC ![][12] 主要亮点: - * 开源 -  * 简单的密码管理器 -  * 跨平台 -  * 没有移动支持 +* 开源 +* 简单的密码管理器 +* 跨平台 +* 没有移动设备支持 - - -KeePassXC 是 [KeePassX][13] 的社区分支,它最初是 Windows 上 [KeePass][14] 的 Linux 移植。 +KeePassXC 是 [KeePassX][13] 的社区分支,它最初是 Windows 上 [KeePass][14] 的 Linux 移植版本。 除非你没意识到,KeePassX 已经多年没有维护。因此,如果你在寻找简单易用的密码管理器,那么 KeePassXC 是一个不错的选择。KeePassXC 可能不是最漂亮或最好的密码管理器,但它确实可以做到该做的事。 它也是安全和开源的。我认为这值得一试,你说呢? -[KeePassXC][15] +- [KeePassXC][15] -#### 4\. Enpass (非开源) +#### 4、Enpass (非开源) ![][16] 主要亮点: - * 专有 -  * 许多功能-包括“可穿戴”设备支持。 -  * Linux 完全免费(具有高级功能) - - +* 专有软件 +* 有许多功能,包括对“可穿戴”设备支持。 +* Linux 完全免费(具有付费支持) Enpass 是非常流行的跨平台密码管理器。即使它不是开源解决方案,但还是有很多人依赖它。因此,至少可以肯定它是可行的。 -它提供了很多功能,如果你有可穿戴设备,它也将支持它,这点很少见。 +它提供了很多功能,如果你有可穿戴设备,它也可以支持它,这点很少见。 -很高兴看到 Enpass 积极管理 Linux 发行版的软件包。另外,请注意,它仅适用于 64 位系统。你可以在它的网站上找到[官方的安装说明] [17]。它需要使用终端,但是我按照步骤进行了测试,它非常好用。 +很高兴能看到 Enpass 积极管理 Linux 发行版的软件包。另外,请注意,它仅适用于 64 位系统。你可以在它的网站上找到[官方的安装说明] [17]。它需要使用终端,但是我按照步骤进行了测试,它非常好用。 -[Enpass][18] +- [Enpass][18] -#### 5\. myki (非开源) +#### 5、myki (非开源) ![][19] 主要亮点: - * 专有 -  * 不使用云服务器存储密码 -  * 专注于本地点对点同步 -  * 能够在移动设备上用指纹 ID 替换密码 +* 专有软件 +* 不使用云服务器存储密码 +* 专注于本地点对点同步 +* 能够在移动设备上用指纹 ID 替换密码 +这可能不是一个受欢迎的建议,但我发现它很有趣。它是专有软件密码管理器,它让你避免使用云服务器,而是依靠点对点同步。 +因此,如果你不想使用任何云服务器来存储你的信息,那么它适合你。另外值得注意的是,用于 Android 和 iOS 的程序可让你用指纹 ID 替换密码。如果你希望便于在手机上使用,又有桌面密码管理器的基本功能,这似乎是个不错的选择。 -这可能不是一个受欢迎的建议,但我发现它很有趣。它是专有的密码管理器,它让你避免使用云服务器,并依靠点对点同步。 - -因此,如果你不想使用任何云服务器来存储你的信息,那么它适合你。另外值得注意的是,用于 Android 和 iOS 的程序可帮助你用指纹 ID 替换密码。如果你希望在手机上使用方便,还有桌面密码管理器的基本功能,这似乎是个不错的选择。 - -但是,如果你选择升级到高级版,这有个付费计划供你判断,绝对不便宜。 +但是,如果你选择升级到付费版,这有个付费计划供你判断,绝对不便宜。 尝试一下,让我们知道它如何! -[myki][20] +- [myki][20] ### 其他一些值得说的密码管理器 @@ -150,13 +142,13 @@ Enpass 是非常流行的跨平台密码管理器。即使它不是开源解决 如果你正在寻找命令行密码管理器,那你应该试试 [Pass][25]。 -[Password Safe][26] 也是种选择,但它的 Linux 客户端还处于 beta。我不建议依靠 “beta” 程序来存储密码。还有 [Universal Password Manager][27],但它不再维护。你可能也听说过 [Password Gorilla][28],但并它没有积极维护。 +[Password Safe][26] 也是种选择,但它的 Linux 客户端还处于 beta 阶段。我不建议依靠 “beta” 程序来存储密码。还有 [Universal Password Manager][27],但它不再维护。你可能也听说过 [Password Gorilla][28],但并它没有积极维护。 -**总结** +### 总结 -目前,Bitwarden 似乎是我个人的最爱。但是,在 Linux 上有几个选项可供选择。你可以选择提供原生应用的程序,也可选择浏览器插件,选择权在你。 +目前,Bitwarden 似乎是我个人的最爱。但是,在 Linux 上有几个替代品可供选择。你可以选择提供原生应用的程序,也可选择浏览器插件,选择权在你。 -如果有错过值得尝试的密码管理器,请在下面的评论中告诉我们。与往常一样,我们会根据你的建议扩展列表。 +如果我有错过值得尝试的密码管理器,请在下面的评论中告诉我们。与往常一样,我们会根据你的建议扩展列表。 -------------------------------------------------------------------------------- @@ -165,7 +157,7 @@ via: https://itsfoss.com/password-managers-linux/ 作者:[Ankush Das][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/tech/20191013 How to Enable EPEL Repository on CentOS 8 and RHEL 8 Server.md b/published/20191013 How to Enable EPEL Repository on CentOS 8 and RHEL 8 Server.md similarity index 57% rename from sources/tech/20191013 How to Enable EPEL Repository on CentOS 8 and RHEL 8 Server.md rename to published/20191013 How to Enable EPEL Repository on CentOS 8 and RHEL 8 Server.md index 718f41ebc9..c71aa58995 100644 --- a/sources/tech/20191013 How to Enable EPEL Repository on CentOS 8 and RHEL 8 Server.md +++ b/published/20191013 How to Enable EPEL Repository on CentOS 8 and RHEL 8 Server.md @@ -1,65 +1,63 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11535-1.html) [#]: subject: (How to Enable EPEL Repository on CentOS 8 and RHEL 8 Server) [#]: via: (https://www.linuxtechi.com/enable-epel-repo-centos8-rhel8-server/) [#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) -How to Enable EPEL Repository on CentOS 8 and RHEL 8 Server +如何在 CentOS 8 和 RHEL 8 服务器上启用 EPEL 仓库 ====== -**EPEL** Stands for Extra Packages for Enterprise Linux, it is a free and opensource additional packages repository available for **CentOS** and **RHEL** servers. As the name suggests, EPEL repository provides extra and additional packages which are not available in the default package repositories of [CentOS 8][1] and [RHEL 8][2]. +EPEL 代表 “Extra Packages for Enterprise Linux”,它是一个自由开源的附加软件包仓库,可用于 CentOS 和 RHEL 服务器。顾名思义,EPEL 仓库提供了额外的软件包,这些软件在 [CentOS 8][1] 和 [RHEL 8][2] 的默认软件包仓库中不可用。 -In this article we will demonstrate how to enable and use epel repository on CentOS 8 and RHEL 8 Server. +在本文中,我们将演示如何在 CentOS 8 和 RHEL 8 服务器上启用和使用 EPEL 存储库。 -[![EPEL-Repo-CentOS8-RHEL8][3]][4] +![](https://img.linux.net.cn/data/attachment/album/201911/04/113307wz4y3lnczzlxzn2j.jpg) -### Prerequisites of EPEL Repository +### EPEL 仓库的先决条件 - * Minimal CentOS 8 and RHEL 8 Server - * Root or sudo admin privileges - * Internet Connection + * 最小化安装的 CentOS 8 和 RHEL 8 服务器 + * root 或 sudo 管理员权限 + * 网络连接 +### 在 RHEL 8.x 服务器上安装并启用 EPEL 仓库 - -### Install and Enable EPEL Repository on RHEL 8.x Server - -Login or ssh to your RHEL 8.x server and execute the following dnf command to install EPEL rpm package, +登录或 SSH 到你的 RHEL 8.x 服务器,并执行以下 `dnf` 命令来安装 EPEL rpm 包, ``` [root@linuxtechi ~]# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y ``` -Output of above command would be something like below, +上面命令的输出将如下所示, -![dnf-install-epel-repo-rehl8][3] +![dnf-install-epel-repo-rehl8][5] -Once epel rpm package is installed successfully then it will automatically enable and configure its yum / dnf repository.  Run following dnf or yum command to verify whether EPEL repository is enabled or not, +EPEL rpm 包成功安装后,它将自动启用并配置其 yum/dnf 仓库。运行以下 `dnf` 或 `yum` 命令,以验证是否启用了 EPEL 仓库, ``` [root@linuxtechi ~]# dnf repolist epel -Or +或者 [root@linuxtechi ~]# dnf repolist epel -v ``` -![epel-repolist-rhel8][3] +![epel-repolist-rhel8][6] -### Install and Enable EPEL Repository on CentOS 8.x Server +### 在 CentOS 8.x 服务器上安装并启用 EPEL 仓库 -Login or ssh to your CentOS 8 server and execute following dnf or yum command to install ‘**epel-release**‘ rpm package. In CentOS 8 server, epel rpm package is available in its default package repository. +登录或 SSH 到你的 CentOS 8 服务器,并执行以下 `dnf` 或 `yum` 命令来安装 `epel-release` rpm 软件包。在 CentOS 8 服务器中,EPEL rpm 在其默认软件包仓库中。 ``` [root@linuxtechi ~]# dnf install epel-release -y -Or +或者 [root@linuxtechi ~]# yum install epel-release -y ``` -Execute the following commands to verify the status of epel repository on CentOS 8 server, +执行以下命令来验证 CentOS 8 服务器上 EPEL 仓库的状态, ``` - [root@linuxtechi ~]# dnf repolist epel +[root@linuxtechi ~]# dnf repolist epel Last metadata expiration check: 0:00:03 ago on Sun 13 Oct 2019 04:18:05 AM BST. repo id repo name status *epel Extra Packages for Enterprise Linux 8 - x86_64 1,977 @@ -82,11 +80,11 @@ Total packages: 1,977 [root@linuxtechi ~]# ``` -Above command’s output confirms that we have successfully enabled epel repo. Let’s perform some basic operations on EPEL repo. +以上命令的输出说明我们已经成功启用了 EPEL 仓库。让我们在 EPEL 仓库上执行一些基本操作。 -### List all available packages from epel repository +### 列出 EPEL 仓库种所有可用包 -If you want to list all the packages from epel repository then run the following dnf command, +如果要列出 EPEL 仓库中的所有的软件包,请运行以下 `dnf` 命令, ``` [root@linuxtechi ~]# dnf repository-packages epel list @@ -116,33 +114,35 @@ zvbi-fonts.noarch 0.2.35-9.el8 epel [root@linuxtechi ~]# ``` -### Search a package from epel repository +### 从 EPEL 仓库中搜索软件包 -Let’s assume if we want to search Zabbix package in epel repository, execute the following dnf command, +假设我们要搜索 EPEL 仓库中的 Zabbix 包,请执行以下 `dnf` 命令, ``` [root@linuxtechi ~]# dnf repository-packages epel list | grep -i zabbix ``` -Output of above command would be something like below, +上面命令的输出类似下面这样, -![epel-repo-search-package-centos8][3] +![epel-repo-search-package-centos8][7] -### Install a package from epel repository +### 从 EPEL 仓库安装软件包 -Let’s assume we want to install htop package from epel repo, then issue the following dnf command, +假设我们要从 EPEL 仓库安装 htop 包,运行以下 `dnf` 命令, -Syntax: +语法: -# dnf –enablerepo=”epel” install <pkg_name> +``` +# dnf –enablerepo=”epel” install <包名> +``` ``` [root@linuxtechi ~]# dnf --enablerepo="epel" install htop -y ``` -**Note:** If we don’t specify the “**–enablerepo=epel**” in above command then it will look for htop package in all available package repositories. +注意:如果我们在上面的命令中未指定 `–enablerepo=epel`,那么它将在所有可用的软件包仓库中查找 htop 包。 -That’s all from this article, I hope above steps helps you to enable and configure EPEL repository on CentOS 8 and RHEL 8 Server, please don’t hesitate to share your comments and feedback in below comments section. +本文就是这些内容了,我希望上面的步骤能帮助你在 CentOS 8 和 RHEL 8 服务器上启用并配置 EPEL 仓库,请在下面的评论栏分享你的评论和反馈。 -------------------------------------------------------------------------------- @@ -150,8 +150,8 @@ via: https://www.linuxtechi.com/enable-epel-repo-centos8-rhel8-server/ 作者:[Pradeep Kumar][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -161,3 +161,6 @@ via: https://www.linuxtechi.com/enable-epel-repo-centos8-rhel8-server/ [2]: https://www.linuxtechi.com/install-configure-kvm-on-rhel-8/ [3]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 [4]: https://www.linuxtechi.com/wp-content/uploads/2019/10/EPEL-Repo-CentOS8-RHEL8.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/10/dnf-install-epel-repo-rehl8.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/10/epel-repolist-rhel8.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/10/epel-repo-search-package-centos8.jpg diff --git a/published/20191018 How to use Protobuf for data interchange.md b/published/20191018 How to use Protobuf for data interchange.md new file mode 100644 index 0000000000..cecba89611 --- /dev/null +++ b/published/20191018 How to use Protobuf for data interchange.md @@ -0,0 +1,489 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11600-1.html) +[#]: subject: (How to use Protobuf for data interchange) +[#]: via: (https://opensource.com/article/19/10/protobuf-data-interchange) +[#]: author: (Marty Kalin https://opensource.com/users/mkalindepauledu) + +如何使用 Protobuf 做数据交换 +====== + +> 在以不同语言编写并在不同平台上运行的应用程序之间交换数据时,Protobuf 编码可提高效率。 + +![](https://img.linux.net.cn/data/attachment/album/201911/22/075757pn2fxfth30ntwefg.jpg) + +协议缓冲区Protocol Buffers([Protobufs][2])像 XML 和 JSON 一样,可以让用不同语言编写并在不同平台上运行的应用程序交换数据。例如,用 Go 编写的发送程序可以在 Protobuf 中对以 Go 表示的销售订单数据进行编码,然后用 Java 编写的接收方可以对它进行解码,以获取所接收订单数据的 Java 表示方式。这是在网络连接上的结构示意图: + +> Go 销售订单 ---> Pbuf 编码 ---> 网络 ---> Pbuf 界面 ---> Java 销售订单 + +与 XML 和 JSON 相比,Protobuf 编码是二进制而不是文本,这会使调试复杂化。但是,正如本文中的代码示例所确认的那样,Protobuf 编码在大小上比 XML 或 JSON 编码要有效得多。 + +Protobuf 以另一种方式提供了这种有效性。在实现级别,Protobuf 和其他编码系统对结构化数据进行序列化serialize反序列化deserialize。序列化将特定语言的数据结构转换为字节流,反序列化是将字节流转换回特定语言的数据结构的逆运算。序列化和反序列化可能成为数据交换的瓶颈,因为这些操作会占用大量 CPU。高效的序列化和反序列化是 Protobuf 的另一个设计目标。 + +最近的编码技术,例如 Protobuf 和 FlatBuffers,源自 1990 年代初期的 [DCE/RPC][3](分布式计算环境/远程过程调用Distributed Computing Environment/Remote Procedure Call)计划。与 DCE/RPC 一样,Protobuf 在数据交换中为 [IDL][4](接口定义语言)和编码层做出了贡献。 + +本文将着眼于这两层,然后提供 Go 和 Java 中的代码示例以充实 Protobuf 的细节,并表明 Protobuf 是易于使用的。 + +### Protobuf 作为一个 IDL 和编码层 + +像 Protobuf 一样,DCE/RPC 被设计为与语言和平台无关。适当的库和实用程序允许任何语言和平台用于 DCE/RPC 领域。此外,DCE/RPC 体系结构非常优雅。IDL 文档是一侧的远程过程与另一侧的调用者之间的协定。Protobuf 也是以 IDL 文档为中心的。 + +IDL 文档是文本,在 DCE/RPC 中,使用基本 C 语法以及元数据的语法扩展(方括号)和一些新的关键字,例如 `interface`。这是一个例子: + +``` +[uuid (2d6ead46-05e3-11ca-7dd1-426909beabcd), version(1.0)] +interface echo { +   const long int ECHO_SIZE = 512; +   void echo( +      [in]          handle_t h, +      [in, string]  idl_char from_client[ ], +      [out, string] idl_char from_service[ECHO_SIZE] +   ); +} +``` + +该 IDL 文档声明了一个名为 `echo` 的过程,该过程带有三个参数:类型为 `handle_t`(实现指针)和 `idl_char`(ASCII 字符数组)的 `[in]` 参数被传递给远程过程,而 `[out]` 参数(也是一个字符串)从该过程中传回。在此示例中,`echo` 过程不会显式返回值(`echo` 左侧的 `void`),但也可以返回值。返回值,以及一个或多个 `[out]` 参数,允许远程过程任意返回许多值。下一节将介绍 Protobuf IDL,它的语法不同,但同样用作数据交换中的协定。 + +DCE/RPC 和 Protobuf 中的 IDL 文档是创建用于交换数据的基础结构代码的实用程序的输入: + +> IDL 文档 ---> DCE/PRC 或 Protobuf 实用程序 ---> 数据交换的支持代码 + +作为相对简单的文本,IDL 是同样便于人类阅读的关于数据交换细节的文档(特别是交换的数据项的数量和每个项的数据类型)。 + +Protobuf 可用于现代 RPC 系统,例如 [gRPC][5];但是 Protobuf 本身仅提供 IDL 层和编码层,用于从发送者传递到接收者的消息。与原本的 DCE/RPC 一样,Protobuf 编码是二进制的,但效率更高。 + +目前,XML 和 JSON 编码仍在通过 Web 服务等技术进行的数据交换中占主导地位,这些技术利用 Web 服务器、传输协议(例如 TCP、HTTP)以及标准库和实用程序等原有的基础设施来处理 XML 和 JSON 文档。 此外,各种类型的数据库系统可以存储 XML 和 JSON 文档,甚至旧式关系型系统也可以轻松生成查询结果的 XML 编码。现在,每种通用编程语言都具有支持 XML 和 JSON 的库。那么,是什么让我们回到 Protobuf 之类的**二进制**编码系统呢? + +让我们看一下负十进制值 `-128`。以 2 的补码二进制表示形式(在系统和语言中占主导地位)中,此值可以存储在单个 8 位字节中:`10000000`。此整数值在 XML 或 JSON 中的文本编码需要多个字节。例如,UTF-8 编码需要四个字节的字符串,即 `-128`,即每个字符一个字节(十六进制,值为 `0x2d`、`0x31`、`0x32` 和 `0x38`)。XML 和 JSON 还添加了标记字符,例如尖括号和大括号。有关 Protobuf 编码的详细信息下面就会介绍,但现在的关注点是一个通用点:文本编码的压缩性明显低于二进制编码。 + +### 在 Go 中使用 Protobuf 的示例 + +我的代码示例着重于 Protobuf 而不是 RPC。以下是第一个示例的概述: + +* 名为 `dataitem.proto` 的 IDL 文件定义了一个 Protobuf 消息,它具有六个不同类型的字段:具有不同范围的整数值、固定大小的浮点值以及两个不同长度的字符串。 +* Protobuf 编译器使用 IDL 文件生成 Go 版本(以及后面的 Java 版本)的 Protobuf 消息及支持函数。 +* Go 应用程序使用随机生成的值填充原生的 Go 数据结构,然后将结果序列化为本地文件。为了进行比较, XML 和 JSON 编码也被序列化为本地文件。 +* 作为测试,Go 应用程序通过反序列化 Protobuf 文件的内容来重建其原生数据结构的实例。 +* 作为语言中立性测试,Java 应用程序还会对 Protobuf 文件的内容进行反序列化以获取原生数据结构的实例。 + +[我的网站][6]上提供了该 IDL 文件以及两个 Go 和一个 Java 源文件,打包为 ZIP 文件。 + +最重要的 Protobuf IDL 文档如下所示。该文档存储在文件 `dataitem.proto` 中,并具有常规的`.proto` 扩展名。 + +#### 示例 1、Protobuf IDL 文档 + +``` +syntax = "proto3"; + +package main; + +message DataItem { +  int64  oddA  = 1; +  int64  evenA = 2; +  int32  oddB  = 3; +  int32  evenB = 4; +  float  small = 5; +  float  big   = 6; +  string short = 7; +  string long  = 8; +} +``` + +该 IDL 使用当前的 proto3 而不是较早的 proto2 语法。软件包名称(在本例中为 `main`)是可选的,但是惯例使用它以避免名称冲突。这个结构化的消息包含八个字段,每个字段都有一个 Protobuf 数据类型(例如,`int64`、`string`)、名称(例如,`oddA`、`short`)和一个等号 `=` 之后的数字标签(即键)。标签(在此示例中为 1 到 8)是唯一的整数标识符,用于确定字段序列化的顺序。 + +Protobuf 消息可以嵌套到任意级别,而一个消息可以是另外一个消息的字段类型。这是一个使用 `DataItem` 消息作为字段类型的示例: + +``` +message DataItems { +  repeated DataItem item = 1; +} +``` + +单个 `DataItems` 消息由重复的(零个或多个)`DataItem` 消息组成。 + +为了清晰起见,Protobuf 还支持枚举类型: + +``` +enum PartnershipStatus { +  reserved "FREE", "CONSTRAINED", "OTHER"; +} +``` + +`reserved` 限定符确保用于实现这三个符号名的数值不能重复使用。 + +为了生成一个或多个声明 Protobuf 消息结构的特定于语言的版本,包含这些结构的 IDL 文件被传递到`protoc` 编译器(可在 [Protobuf GitHub 存储库][7]中找到)。对于 Go 代码,可以以通常的方式安装支持的 Protobuf 库(这里以 `%` 作为命令行提示符): + +``` +% go get github.com/golang/protobuf/proto +``` + +将 Protobuf IDL 文件 `dataitem.proto` 编译为 Go 源代码的命令是: + +``` +% protoc --go_out=. dataitem.proto +``` + +标志 `--go_out` 指示编译器生成 Go 源代码。其他语言也有类似的标志。在这种情况下,结果是一个名为 `dataitem.pb.go` 的文件,该文件足够小,可以将其基本内容复制到 Go 应用程序中。以下是生成的代码的主要部分: + +``` +var _ = proto.Marshal + +type DataItem struct { + OddA int64 `protobuf:"varint,1,opt,name=oddA" json:"oddA,omitempty"` + EvenA int64 `protobuf:"varint,2,opt,name=evenA" json:"evenA,omitempty"` + OddB int32 `protobuf:"varint,3,opt,name=oddB" json:"oddB,omitempty"` + EvenB int32 `protobuf:"varint,4,opt,name=evenB" json:"evenB,omitempty"` + Small float32 `protobuf:"fixed32,5,opt,name=small" json:"small,omitempty"` + Big float32 `protobuf:"fixed32,6,opt,name=big" json:"big,omitempty"` + Short string `protobuf:"bytes,7,opt,name=short" json:"short,omitempty"` + Long string `protobuf:"bytes,8,opt,name=long" json:"long,omitempty"` +} + +func (m *DataItem) Reset() { *m = DataItem{} } +func (m *DataItem) String() string { return proto.CompactTextString(m) } +func (*DataItem) ProtoMessage() {} +func init() {} +``` + +编译器生成的代码具有 Go 结构 `DataItem`,该结构导出 Go 字段(名称现已大写开头),该字段与 Protobuf IDL 中声明的名称匹配。该结构字段具有标准的 Go 数据类型:`int32`、`int64`、`float32` 和 `string`。在每个字段行的末尾,是描述 Protobuf 类型的字符串,提供 Protobuf IDL 文档中的数字标签及有关 JSON 信息的元数据,这将在后面讨论。 + +此外也有函数;最重要的是 `Proto.Marshal`,用于将 `DataItem` 结构的实例序列化为 Protobuf 格式。辅助函数包括:清除 `DataItem` 结构的 `Reset`,生成 `DataItem` 的单行字符串表示的 `String`。 + +描述 Protobuf 编码的元数据应在更详细地分析 Go 程序之前进行仔细研究。 + +### Protobuf 编码 + +Protobuf 消息的结构为键/值对的集合,其中数字标签为键,相应的字段为值。字段名称(例如,`oddA` 和 `small`)是供人类阅读的,但是 `protoc` 编译器的确使用了字段名称来生成特定于语言的对应名称。例如,Protobuf IDL 中的 `oddA` 和 `small` 名称在 Go 结构中分别成为字段 `OddA` 和 `Small`。 + +键和它们的值都被编码,但是有一个重要的区别:一些数字值具有固定大小的 32 或 64 位的编码,而其他数字(包括消息标签)则是 `varint` 编码的,位数取决于整数的绝对值。例如,整数值 1 到 15 需要 8 位 `varint` 编码,而值 16 到 2047 需要 16 位。`varint` 编码在本质上与 UTF-8 编码类似(但细节不同),它偏爱较小的整数值而不是较大的整数值。(有关详细分析,请参见 Protobuf [编码指南][8])结果是,Protobuf 消息应该在字段中具有较小的整数值(如果可能),并且键数应尽可能少,但每个字段至少得有一个键。 + +下表 1 列出了 Protobuf 编码的要点: + +编码 | 示例类型 | 长度 +---|---|--- +`varint` | `int32`、`uint32`、`int64` | 可变长度 +`fixed` | `fixed32`、`float`、`double` | 固定的 32 位或 64 位长度 +字节序列 | `string`、`bytes` | 序列长度 + +*表 1. Protobuf 数据类型* + +未明确固定长度的整数类型是 `varint` 编码的;因此,在 `varint` 类型中,例如 `uint32`(`u` 代表无符号),数字 32 描述了整数的范围(在这种情况下为 0 到 2^32 - 1),而不是其位的大小,该位大小取决于值。相比之下,对于固定长度类型(例如 `fixed32` 或 `double`),Protobuf 编码分别需要 32 位和 64 位。Protobuf 中的字符串是字节序列;因此,字段编码的大小就是字节序列的长度。 + +另一个高效的方法值得一提。回想一下前面的示例,其中的 `DataItems` 消息由重复的 `DataItem` 实例组成: + +``` +message DataItems { +  repeated DataItem item = 1; +} +``` + +`repeated` 表示 `DataItem` 实例是*打包的*:集合具有单个标签,在这里是 1。因此,具有重复的 `DataItem` 实例的 `DataItems` 消息比具有多个但单独的 `DataItem` 字段、每个字段都需要自己的标签的消息的效率更高。 + +了解了这一背景,让我们回到 Go 程序。 + +### dataItem 程序的细节 + +`dataItem` 程序创建一个 `DataItem` 实例,并使用适当类型的随机生成的值填充字段。Go 有一个 `rand` 包,带有用于生成伪随机整数和浮点值的函数,而我的 `randString` 函数可以从字符集中生成指定长度的伪随机字符串。设计目标是要有一个具有不同类型和位大小的字段值的 `DataItem` 实例。例如,`OddA` 和 `EvenA` 值分别是 64 位非负整数值的奇数和偶数;但是 `OddB` 和 `EvenB` 变体的大小为 32 位,并存放 0 到 2047 之间的小整数值。随机浮点值的大小为 32 位,字符串为 16(`Short`)和 32(`Long`)字符的长度。这是用随机值填充 `DataItem` 结构的代码段: + +``` +// 可变长度整数 +n1 := rand.Int63() // 大整数 +if (n1 & 1) == 0 { n1++ } // 确保其是奇数 +... +n3 := rand.Int31() % UpperBound // 小整数 +if (n3 & 1) == 0 { n3++ } // 确保其是奇数 + +// 固定长度浮点数 +... +t1 := rand.Float32() +t2 := rand.Float32() +... +// 字符串 +str1 := randString(StrShort) +str2 := randString(StrLong) + +// 消息 +dataItem := &DataItem { + OddA: n1, + EvenA: n2, + OddB: n3, + EvenB: n4, + Big: f1, + Small: f2, + Short: str1, + Long: str2, +} +``` + +创建并填充值后,`DataItem` 实例将以 XML、JSON 和 Protobuf 进行编码,每种编码均写入本地文件: + +``` +func encodeAndserialize(dataItem *DataItem) { + bytes, _ := xml.MarshalIndent(dataItem, "", " ") // Xml to dataitem.xml + ioutil.WriteFile(XmlFile, bytes, 0644) // 0644 is file access permissions + + bytes, _ = json.MarshalIndent(dataItem, "", " ") // Json to dataitem.json + ioutil.WriteFile(JsonFile, bytes, 0644) + + bytes, _ = proto.Marshal(dataItem) // Protobuf to dataitem.pbuf + ioutil.WriteFile(PbufFile, bytes, 0644) +} +``` + +这三个序列化函数使用术语 `marshal`,它与 `serialize` 意思大致相同。如代码所示,三个 `Marshal` 函数均返回一个字节数组,然后将其写入文件。(为简单起见,忽略可能的错误处理。)在示例运行中,文件大小为: + +``` +dataitem.xml:  262 bytes +dataitem.json: 212 bytes +dataitem.pbuf:  88 bytes +``` + +Protobuf 编码明显小于其他两个编码方案。通过消除缩进字符(在这种情况下为空白和换行符),可以稍微减小 XML 和 JSON 序列化的大小。 + +以下是 `dataitem.json` 文件,该文件最终是由 `json.MarshalIndent` 调用产生的,并添加了以 `##` 开头的注释: + +``` +{ + "oddA": 4744002665212642479, ## 64-bit >= 0 + "evenA": 2395006495604861128, ## ditto + "oddB": 57, ## 32-bit >= 0 but < 2048 + "evenB": 468, ## ditto + "small": 0.7562016, ## 32-bit floating-point + "big": 0.85202795, ## ditto + "short": "ClH1oDaTtoX$HBN5", ## 16 random chars + "long": "xId0rD3Cri%3Wt%^QjcFLJgyXBu9^DZI" ## 32 random chars +} +``` + +尽管这些序列化的数据写入到本地文件中,但是也可以使用相同的方法将数据写入网络连接的输出流。 + +### 测试序列化和反序列化 + +Go 程序接下来通过将先前写入 `dataitem.pbuf` 文件的字节反序列化为 `DataItem` 实例来运行基本测试。这是代码段,其中去除了错误检查部分: + +``` +filebytes, err := ioutil.ReadFile(PbufFile) // get the bytes from the file +... +testItem.Reset() // clear the DataItem structure +err = proto.Unmarshal(filebytes, testItem) // deserialize into a DataItem instance +``` + +用于 Protbuf 反序列化的 `proto.Unmarshal` 函数与 `proto.Marshal` 函数相反。原始的 `DataItem` 和反序列化的副本将被打印出来以确认完全匹配: + +``` +Original: +2041519981506242154 3041486079683013705 1192 1879 +0.572123 0.326855 +boPb#T0O8Xd&Ps5EnSZqDg4Qztvo7IIs 9vH66AiGSQgCDxk& + +Deserialized: +2041519981506242154 3041486079683013705 1192 1879 +0.572123 0.326855 +boPb#T0O8Xd&Ps5EnSZqDg4Qztvo7IIs 9vH66AiGSQgCDxk& +``` + +### 一个 Java Protobuf 客户端 + +用 Java 写的示例是为了确认 Protobuf 的语言中立性。原始 IDL 文件可用于生成 Java 支持代码,其中涉及嵌套类。但是,为了抑制警告信息,可以进行一些补充。这是修订版,它指定了一个 `DataMsg` 作为外部类的名称,内部类在该 Protobuf 消息后面自动命名为 `DataItem`: + +``` +syntax = "proto3"; + +package main; + +option java_outer_classname = "DataMsg"; + +message DataItem { +... +``` + +进行此更改后,`protoc` 编译与以前相同,只是所期望的输出现在是 Java 而不是 Go: + +``` +% protoc --java_out=. dataitem.proto +``` + +生成的源文件(在名为 `main` 的子目录中)为 `DataMsg.java`,长度约为 1,120 行:Java 并不简洁。编译然后运行 Java 代码需要具有 Protobuf 库支持的 JAR 文件。该文件位于 [Maven 存储库][9]中。 + +放置好这些片段后,我的测试代码相对较短(并且在 ZIP 文件中以 `Main.java` 形式提供): + +``` +package main; +import java.io.FileInputStream; + +public class Main { + public static void main(String[] args) { + String path = "dataitem.pbuf"; // from the Go program's serialization + try { + DataMsg.DataItem deserial = + DataMsg.DataItem.newBuilder().mergeFrom(new FileInputStream(path)).build(); + + System.out.println(deserial.getOddA()); // 64-bit odd + System.out.println(deserial.getLong()); // 32-character string + } + catch(Exception e) { System.err.println(e); } + } +} +``` + +当然,生产级的测试将更加彻底,但是即使是该初步测试也可以证明 Protobuf 的语言中立性:`dataitem.pbuf` 文件是 Go 程序对 Go 语言版的 `DataItem` 进行序列化的结果,并且该文件中的字节被反序列化以产生一个 Java 语言的 `DataItem` 实例。Java 测试的输出与 Go 测试的输出相同。 + +### 用 numPairs 程序来结束 + +让我们以一个示例作为结尾,来突出 Protobuf 效率,但又强调在任何编码技术中都会涉及到的成本。考虑以下 Protobuf IDL 文件: + +``` +syntax = "proto3"; +package main; + +message NumPairs { + repeated NumPair pair = 1; +} + +message NumPair { + int32 odd = 1; + int32 even = 2; +} +``` + +`NumPair` 消息由两个 `int32` 值以及每个字段的整数标签组成。`NumPairs` 消息是嵌入的 `NumPair` 消息的序列。 + +Go 语言的 `numPairs` 程序(如下)创建了 200 万个 `NumPair` 实例,每个实例都附加到 `NumPairs` 消息中。该消息可以按常规方式进行序列化和反序列化。 + +#### 示例 2、numPairs 程序 + +``` +package main + +import ( + "math/rand" + "time" + "encoding/xml" + "encoding/json" + "io/ioutil" + "github.com/golang/protobuf/proto" +) + +// protoc-generated code: start +var _ = proto.Marshal +type NumPairs struct { + Pair []*NumPair `protobuf:"bytes,1,rep,name=pair" json:"pair,omitempty"` +} + +func (m *NumPairs) Reset() { *m = NumPairs{} } +func (m *NumPairs) String() string { return proto.CompactTextString(m) } +func (*NumPairs) ProtoMessage() {} +func (m *NumPairs) GetPair() []*NumPair { + if m != nil { return m.Pair } + return nil +} + +type NumPair struct { + Odd int32 `protobuf:"varint,1,opt,name=odd" json:"odd,omitempty"` + Even int32 `protobuf:"varint,2,opt,name=even" json:"even,omitempty"` +} + +func (m *NumPair) Reset() { *m = NumPair{} } +func (m *NumPair) String() string { return proto.CompactTextString(m) } +func (*NumPair) ProtoMessage() {} +func init() {} +// protoc-generated code: finish + +var numPairsStruct NumPairs +var numPairs = &numPairsStruct + +func encodeAndserialize() { + // XML encoding + filename := "./pairs.xml" + bytes, _ := xml.MarshalIndent(numPairs, "", " ") + ioutil.WriteFile(filename, bytes, 0644) + + // JSON encoding + filename = "./pairs.json" + bytes, _ = json.MarshalIndent(numPairs, "", " ") + ioutil.WriteFile(filename, bytes, 0644) + + // ProtoBuf encoding + filename = "./pairs.pbuf" + bytes, _ = proto.Marshal(numPairs) + ioutil.WriteFile(filename, bytes, 0644) +} + +const HowMany = 200 * 100 * 100 // two million + +func main() { + rand.Seed(time.Now().UnixNano()) + + // uncomment the modulus operations to get the more efficient version + for i := 0; i < HowMany; i++ { + n1 := rand.Int31() // % 2047 + if (n1 & 1) == 0 { n1++ } // ensure it's odd + n2 := rand.Int31() // % 2047 + if (n2 & 1) == 1 { n2++ } // ensure it's even + + next := &NumPair { + Odd: n1, + Even: n2, + } + numPairs.Pair = append(numPairs.Pair, next) + } + encodeAndserialize() +} +``` + +每个 `NumPair` 中随机生成的奇数和偶数值的范围在 0 到 20 亿之间变化。就原始数据(而非编码数据)而言,Go 程序中生成的整数总共为 16MB:每个 `NumPair` 为两个整数,总计为 400 万个整数,每个值的大小为四个字节。 + +为了进行比较,下表列出了 XML、JSON 和 Protobuf 编码的示例 `NumsPairs` 消息的 200 万个 `NumPair` 实例。原始数据也包括在内。由于 `numPairs` 程序生成随机值,因此样本运行的输出有所不同,但接近表中显示的大小。 + +编码 | 文件 | 字节大小 | Pbuf/其它 比例 +---|---|---|--- +无 | pairs.raw | 16MB | 169% +Protobuf | pairs.pbuf | 27MB | — +JSON | pairs.json | 100MB | 27% +XML | pairs.xml | 126MB | 21% + +*表 2. 16MB 整数的编码开销* + +不出所料,Protobuf 和之后的 XML 和 JSON 差别明显。Protobuf 编码大约是 JSON 的四分之一,是 XML 的五分之一。但是原始数据清楚地表明 Protobuf 也会产生编码开销:序列化的 Protobuf 消息比原始数据大 11MB。包括 Protobuf 在内的任何编码都涉及结构化数据,这不可避免地会增加字节。 + +序列化的 200 万个 `NumPair` 实例中的每个实例都包含**四**个整数值:Go 结构中的 `Even` 和 `Odd` 字段分别一个,而 Protobuf 编码中的每个字段、每个标签一个。对于原始数据(而不是编码数据),每个实例将达到 16 个字节,样本 `NumPairs` 消息中有 200 万个实例。但是 Protobuf 标记(如 `NumPair` 字段中的 `int32` 值)使用 `varint` 编码,因此字节长度有所不同。特别是,小的整数值(在这种情况下,包括标签在内)需要不到四个字节进行编码。 + +如果对 `numPairs` 程序进行了修改,以使两个 `NumPair` 字段的值小于 2048,且其编码为一或两个字节,则 Protobuf 编码将从 27MB 下降到 16MB,这正是原始数据的大小。下表总结了样本运行中的新编码大小。 + +编码 | 文件 | 字节大小 | Pbuf/其它 比例 +---|---|---|--- +None | pairs.raw | 16MB | 100% +Protobuf | pairs.pbuf | 16MB | — +JSON | pairs.json | 77MB | 21% +XML | pairs.xml | 103MB | 15% + +*表 3. 编码 16MB 的小于 2048 的整数* + +总之,修改后的 `numPairs` 程序的字段值小于 2048,可减少原始数据中每个四字节整数值的大小。但是 Protobuf 编码仍然需要标签,这些标签会在 Protobuf 消息中添加字节。Protobuf 编码确实会增加消息大小,但是如果要编码相对较小的整数值(无论是字段还是键),则可以通过 `varint` 因子来减少此开销。 + +对于包含混合类型的结构化数据(且整数值相对较小)的中等大小的消息,Protobuf 明显优于 XML 和 JSON 等选项。在其他情况下,数据可能不适合 Protobuf 编码。例如,如果两个应用程序需要共享大量文本记录或大整数值,则可以采用压缩而不是编码技术。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/protobuf-data-interchange + +作者:[Marty Kalin][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mkalindepauledu +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_data_dashboard_system_computer_analytics.png?itok=oxAeIEI- (metrics and data shown on a computer screen) +[2]: https://developers.google.com/protocol-buffers/ +[3]: https://en.wikipedia.org/wiki/DCE/RPC +[4]: https://en.wikipedia.org/wiki/Interface_description_language +[5]: https://grpc.io/ +[6]: http://condor.depaul.edu/mkalin +[7]: https://github.com/protocolbuffers/protobuf +[8]: https://developers.google.com/protocol-buffers/docs/encoding +[9]: https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java diff --git a/published/20191021 How to program with Bash- Syntax and tools.md b/published/20191021 How to program with Bash- Syntax and tools.md new file mode 100644 index 0000000000..3f044598b4 --- /dev/null +++ b/published/20191021 How to program with Bash- Syntax and tools.md @@ -0,0 +1,251 @@ +[#]: collector: (lujun9972) +[#]: translator: (jdh8383) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11552-1.html) +[#]: subject: (How to program with Bash: Syntax and tools) +[#]: via: (https://opensource.com/article/19/10/programming-bash-part-1) +[#]: author: (David Both https://opensource.com/users/dboth) + +怎样用 Bash 编程:语法和工具 +====== + +> 让我们通过本系列文章来学习基本的 Bash 编程语法和工具,以及如何使用变量和控制运算符,这是三篇中的第一篇。 + +![](https://img.linux.net.cn/data/attachment/album/201911/08/092559r5wdg0w97dtf350j.jpg) + +Shell 是操作系统的命令解释器,其中 Bash 是我最喜欢的。每当用户或者系统管理员将命令输入系统的时候,Linux 的 shell 解释器就会把这些命令转换成操作系统可以理解的形式。而执行结果返回 shell 程序后,它会将结果输出到 STDOUT(标准输出),默认情况下,这些结果会[显示在你的终端][2]。所有我熟悉的 shell 同时也是一门编程语言。 + +Bash 是个功能强大的 shell,包含众多便捷特性,比如:tab 补全、命令回溯和再编辑、别名等。它的命令行默认编辑模式是 Emacs,但是我最喜欢的 Bash 特性之一是我可以将其更改为 Vi 模式,以使用那些储存在我肌肉记忆中的的编辑命令。 + +然而,如果你把 Bash 当作单纯的 shell 来用,则无法体验它的真实能力。我在设计一套包含三卷的 [Linux 自学课程][3]时(这个系列的文章正是基于此课程),了解到许多 Bash 的知识,这些是我在过去 20 年的 Linux 工作经验中所没有掌握的,其中的一些知识就是关于 Bash 的编程用法。不得不说,Bash 是一门强大的编程语言,是一个能够同时用于命令行和 shell 脚本的完美设计。 + +本系列文章将要探讨如何使用 Bash 作为命令行界面(CLI)编程语言。第一篇文章简单介绍 Bash 命令行编程、变量以及控制运算符。其他文章会讨论诸如:Bash 文件的类型;字符串、数字和一些逻辑运算符,它们能够提供代码执行流程中的逻辑控制;不同类型的 shell 扩展;通过 `for`、`while` 和 `until` 来控制循环操作。 + +### Shell + +Bash 是 Bourne Again Shell 的缩写,因为 Bash shell 是 [基于][4] 更早的 Bourne shell,后者是 Steven Bourne 在 1977 年开发的。另外还有很多[其他的 shell][5] 可以使用,但下面四个是我经常见到的: + +* `csh`:C shell 适合那些习惯了 C 语言语法的开发者。 +* `ksh`:Korn shell,由 David Korn 开发,在 Unix 用户中更流行。 +* `tcsh`:一个 csh 的变种,增加了一些易用性。 +* `zsh`:Z shell,集成了许多其他流行 shell 的特性。 + +所有 shell 都有内置命令,用以补充或替代核心工具集。打开 shell 的 man 说明页,找到“BUILT-INS”那一段,可以查看都有哪些内置命令。 + +每种 shell 都有它自己的特性和语法风格。我用过 csh、ksh 和 zsh,但我还是更喜欢 Bash。你可以多试几个,寻找更适合你的 shell,尽管这可能需要花些功夫。但幸运的是,切换不同 shell 很简单。 + +所有这些 shell 既是编程语言又是命令解释器。下面我们来快速浏览一下 Bash 中集成的编程结构和工具。 + +### 作为编程语言的 Bash + +大多数场景下,系统管理员都会使用 Bash 来发送简单明了的命令。但 Bash 不仅可以输入单条命令,很多系统管理员可以编写简单的命令行程序来执行一系列任务,这些程序可以作为通用工具,能节省时间和精力。 + +编写 CLI 程序的目的是要提高效率(做一个“懒惰的”系统管理员)。在 CLI 程序中,你可以用特定顺序列出若干命令,逐条执行。这样你就不用盯着显示屏,等待一条命令执行完,再输入另一条,省下来的时间就可以去做其他事情了。 + +### 什么是“程序”? + +自由在线计算机词典([FOLDOC][6])对于程序的定义是:“由计算机执行的指令,而不是运行它们的物理硬件。”普林斯顿大学的 [WordNet][7] 将程序定义为:“……计算机可以理解并执行的一系列指令……”[维基百科][8]上也有一条不错的关于计算机程序的条目。 + +总结下,程序由一条或多条指令组成,目的是完成一个具体的相关任务。对于系统管理员而言,一段程序通常由一系列的 shell 命令构成。Linux 下所有的 shell (至少我所熟知的)都有基本的编程功能,Bash 作为大多数 linux 发行版的默认 shell,也不例外。 + +本系列用 Bash 举例(因为它无处不在),假如你使用一个不同的 shell 也没关系,尽管结构和语法有所不同,但编程思想是相通的。有些 shell 支持某种特性而其他 shell 则不支持,但它们都提供编程功能。Shell 程序可以被存在一个文件中被反复使用,或者在需要的时候才创建它们。 + +### 简单 CLI 程序 + +最简单的命令行程序只有一或两条语句,它们可能相关,也可能无关,在按回车键之前被输入到命令行。程序中的第二条语句(如果有的话)可能取决于第一条语句的操作,但也不是必须的。 + +这里需要特别讲解一个标点符号。当你在命令行输入一条命令,按下回车键的时候,其实在命令的末尾有一个隐含的分号(`;`)。当一段 CLI shell 程序在命令行中被串起来作为单行指令使用时,必须使用分号来终结每个语句并将其与下一条语句分开。但 CLI shell 程序中的最后一条语句可以使用显式或隐式的分号。 + +### 一些基本语法 + +下面的例子会阐明这一语法规则。这段程序由单条命令组成,还有一个显式的终止符: + +``` +[student@studentvm1 ~]$ echo "Hello world." ; +Hello world. +``` + +看起来不像一个程序,但它确是我学习每个新编程语言时写下的第一个程序。不同语言可能语法不同,但输出结果是一样的。 + +让我们扩展一下这段微不足道却又无所不在的代码。你的结果可能与我的有所不同,因为我的家目录有点乱,而你可能是在 GUI 桌面中第一次登录账号。 + +``` +[student@studentvm1 ~]$ echo "My home directory." ; ls ; +My home directory. +chapter25 TestFile1.Linux dmesg2.txt Downloads newfile.txt softlink1 testdir6 +chapter26 TestFile1.mac dmesg3.txt file005 Pictures Templates testdir +TestFile1 Desktop dmesg.txt link3 Public testdir Videos +TestFile1.dos dmesg1.txt Documents Music random.txt testdir1 +``` + +现在是不是更明显了。结果是相关的,但是两条语句彼此独立。你可能注意到我喜欢在分号前后多输入一个空格,这样会让代码的可读性更好。让我们再运行一遍这段程序,这次不要带结尾的分号: + +``` +[student@studentvm1 ~]$ echo "My home directory." ; ls +``` + +输出结果没有区别。 + +### 关于变量 + +像所有其他编程语言一样,Bash 支持变量。变量是个象征性的名字,它指向内存中的某个位置,那里存着对应的值。变量的值是可以改变的,所以它叫“变~量”。 + +Bash 不像 C 之类的语言,需要强制指定变量类型,比如:整型、浮点型或字符型。在 Bash 中,所有变量都是字符串。整数型的变量可以被用于整数运算,这是 Bash 唯一能够处理的数学类型。更复杂的运算则需要借助 [bc][9] 这样的命令,可以被用在命令行编程或者脚本中。 + +变量的值是被预先分配好的,这些值可以用在命令行编程或者脚本中。可以通过变量名字给其赋值,但是不能使用 `$` 符开头。比如,`VAR=10` 这样会把 `VAR` 的值设为 `10`。要打印变量的值,你可以使用语句 `echo $VAR`。变量名必须以文本(即非数字)开始。 + +Bash 会保存已经定义好的变量,直到它们被取消掉。 + +下面这个例子,在变量被赋值前,它的值是空(`null`)。然后给它赋值并打印出来,检验一下。你可以在同一行 CLI 程序里完成它: + +``` +[student@studentvm1 ~]$ echo $MyVar ; MyVar="Hello World" ; echo $MyVar ; + +Hello World +[student@studentvm1 ~]$ +``` + +*注意:变量赋值的语法非常严格,等号(`=`)两边不能有空格。* + +那个空行表明了 `MyVar` 的初始值为空。变量的赋值和改值方法都一样,这个例子展示了原始值和新的值。 + +正如之前说的,Bash 支持整数运算,当你想计算一个数组中的某个元素的位置,或者做些简单的算术运算,这还是挺有帮助的。然而,这种方法并不适合科学计算,或是某些需要小数运算的场景,比如财务统计。这些场景有其它更好的工具可以应对。 + +下面是个简单的算术题: + +``` +[student@studentvm1 ~]$ Var1="7" ; Var2="9" ; echo "Result = $((Var1*Var2))" +Result = 63 +``` + +好像没啥问题,但如果运算结果是浮点数会发生什么呢? + +``` +[student@studentvm1 ~]$ Var1="7" ; Var2="9" ; echo "Result = $((Var1/Var2))" +Result = 0 +[student@studentvm1 ~]$ Var1="7" ; Var2="9" ; echo "Result = $((Var2/Var1))" +Result = 1 +[student@studentvm1 ~]$ +``` + +结果会被取整。请注意运算被包含在 `echo` 语句之中,其实计算在 echo 命令结束前就已经完成了,原因是 Bash 的内部优先级。想要了解详情的话,可以在 Bash 的 man 页面中搜索 “precedence”。 + +### 控制运算符 + +Shell 的控制运算符是一种语法运算符,可以轻松地创建一些有趣的命令行程序。在命令行上按顺序将几个命令串在一起,就变成了最简单的 CLI 程序: + +``` +command1 ; command2 ; command3 ; command4 ; . . . ; etc. ; +``` + +只要不出错,这些命令都能顺利执行。但假如出错了怎么办?你可以预设好应对出错的办法,这就要用到 Bash 内置的控制运算符, `&&` 和 `||`。这两种运算符提供了流程控制功能,使你能改变代码执行的顺序。分号也可以被看做是一种 Bash 运算符,预示着新一行的开始。 + +`&&` 运算符提供了如下简单逻辑,“如果 command1 执行成功,那么接着执行 command2。如果 command1 失败,就跳过 command2。”语法如下: + +``` +command1 && command2 +``` + +现在,让我们用命令来创建一个新的目录,如果成功的话,就把它切换为当前目录。确保你的家目录(`~`)是当前目录,先尝试在 `/root` 目录下创建,你应该没有权限: + +``` +[student@studentvm1 ~]$ Dir=/root/testdir ; mkdir $Dir/ && cd $Dir +mkdir: cannot create directory '/root/testdir/': Permission denied +[student@studentvm1 ~]$ +``` + +上面的报错信息是由 `mkdir` 命令抛出的,因为创建目录失败了。`&&` 运算符收到了非零的返回码,所以 `cd` 命令就被跳过,前者阻止后者继续运行,因为创建目录失败了。这种控制流程可以阻止后面的错误累积,避免引发更严重的问题。是时候讲点更复杂的逻辑了。 + +当一段程序的返回码大于零时,使用 `||` 运算符可以让你在后面接着执行另一段程序。简单语法如下: + +``` +command1 || command2 +``` + +解读一下,“假如 command1 失败,执行 command2”。隐藏的逻辑是,如果 command1 成功,跳过 command2。下面实践一下,仍然是创建新目录: + +``` +[student@studentvm1 ~]$ Dir=/root/testdir ; mkdir $Dir || echo "$Dir was not created." +mkdir: cannot create directory '/root/testdir': Permission denied +/root/testdir was not created. +[student@studentvm1 ~]$ +``` + +正如预期,因为目录无法创建,第一条命令失败了,于是第二条命令被执行。 + +把 `&&` 和 `||` 两种运算符结合起来才能发挥它们的最大功效。请看下面例子中的流程控制方法: + +``` +前置 commands ; command1 && command2 || command3 ; 跟随 commands +``` + +语法解释:“假如 command1 退出时返回码为零,就执行 command2,否则执行 command3。”用具体代码试试: + +``` +[student@studentvm1 ~]$ Dir=/root/testdir ; mkdir $Dir && cd $Dir || echo "$Dir was not created." +mkdir: cannot create directory '/root/testdir': Permission denied +/root/testdir was not created. +[student@studentvm1 ~]$ +``` + +现在我们再试一次,用你的家目录替换 `/root` 目录,你将会有权限创建这个目录了: + +``` +[student@studentvm1 ~]$ Dir=~/testdir ; mkdir $Dir && cd $Dir || echo "$Dir was not created." +[student@studentvm1 testdir]$ +``` + +像 `command1 && command2` 这样的控制语句能够运行的原因是,每条命令执行完毕时都会给 shell 发送一个返回码,用来表示它执行成功与否。默认情况下,返回码为 `0` 表示成功,其他任何正值表示失败。一些系统管理员使用的工具用值为 `1` 的返回码来表示失败,但其他很多程序使用别的数字来表示失败。 + +Bash 的内置变量 `$?` 可以显示上一条命令的返回码,可以在脚本或者命令行中非常方便地检查它。要查看返回码,让我们从运行一条简单的命令开始,返回码的结果总是上一条命令给出的。 + +``` +[student@studentvm1 testdir]$ ll ; echo "RC = $?" +total 1264 +drwxrwxr-x 2 student student 4096 Mar 2 08:21 chapter25 +drwxrwxr-x 2 student student 4096 Mar 21 15:27 chapter26 +-rwxr-xr-x 1 student student 92 Mar 20 15:53 TestFile1 +drwxrwxr-x. 2 student student 663552 Feb 21 14:12 testdir +drwxr-xr-x. 2 student student 4096 Dec 22 13:15 Videos +RC = 0 +[student@studentvm1 testdir]$ +``` + +在这个例子中,返回码为零,意味着命令执行成功了。现在对 root 的家目录测试一下,你应该没有权限: + +``` +[student@studentvm1 testdir]$ ll /root ; echo "RC = $?" +ls: cannot open directory '/root': Permission denied +RC = 2 +[student@studentvm1 testdir]$ +``` + +本例中返回码是 `2`,表明非 root 用户没有权限进入这个目录。你可以利用这些返回码,用控制运算符来改变程序执行的顺序。 + +### 总结 + +本文将 Bash 看作一门编程语言,并从这个视角介绍了它的简单语法和基础工具。我们学习了如何将数据输出到 STDOUT,怎样使用变量和控制运算符。在本系列的下一篇文章中,将会重点介绍能够控制指令执行流程的逻辑运算符。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/programming-bash-part-1 + +作者:[David Both][a] +选题:[lujun9972][b] +译者:[jdh8383](https://github.com/jdh8383) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dboth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bash_command_line.png?itok=k4z94W2U (bash logo on green background) +[2]: https://opensource.com/article/18/10/linux-data-streams +[3]: http://www.both.org/?page_id=1183 +[4]: https://opensource.com/19/9/command-line-heroes-bash +[5]: https://en.wikipedia.org/wiki/Comparison_of_command_shells +[6]: http://foldoc.org/program +[7]: https://wordnet.princeton.edu/ +[8]: https://en.wikipedia.org/wiki/Computer_program +[9]: https://www.gnu.org/software/bc/manual/html_mono/bc.html diff --git a/published/20191022 Initializing arrays in Java.md b/published/20191022 Initializing arrays in Java.md new file mode 100644 index 0000000000..80177952cb --- /dev/null +++ b/published/20191022 Initializing arrays in Java.md @@ -0,0 +1,361 @@ +[#]: collector: (lujun9972) +[#]: translator: (laingke) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11533-1.html) +[#]: subject: (Initializing arrays in Java) +[#]: via: (https://opensource.com/article/19/10/initializing-arrays-java) +[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen) + +Java 中初始化数组 +====== + +> 数组是一种有用的数据类型,用于管理在连续内存位置中建模最好的集合元素。下面是如何有效地使用它们。 + +![Coffee beans and a cup of coffee][1] + +有使用 C 或者 FORTRAN 语言编程经验的人会对数组的概念很熟悉。它们基本上是一个连续的内存块,其中每个位置都是某种数据类型:整型、浮点型或者诸如此类的数据类型。 + +Java 的情况与此类似,但是有一些额外的问题。 + +### 一个数组的示例 + +让我们在 Java 中创建一个长度为 10 的整型数组: + +``` +int[] ia = new int[10]; +``` + +上面的代码片段会发生什么?从左到右依次是: + + 1. 最左边的 `int[]` 将变量的*类型*声明为 `int` 数组(由 `[]` 表示)。 + 2. 它的右边是变量的名称,当前为 `ia`。 + 3. 接下来,`=` 告诉我们,左侧定义的变量赋值为右侧的内容。 + 4. 在 `=` 的右侧,我们看到了 `new`,它在 Java 中表示一个对象正在*被初始化中*,这意味着已为其分配存储空间并调用了其构造函数([请参见此处以获取更多信息][2])。 + 5. 然后,我们看到 `int[10]`,它告诉我们正在初始化的这个对象是包含 10 个整型的数组。 + +因为 Java 是强类型的,所以变量 `ia` 的类型必须跟 `=` 右侧表达式的类型兼容。 + +### 初始化示例数组 + +让我们把这个简单的数组放在一段代码中,并尝试运行一下。将以下内容保存到一个名为 `Test1.java` 的文件中,使用 `javac` 编译,使用 `java` 运行(当然是在终端中): + +``` +import java.lang.*; + +public class Test1 { + + public static void main(String[] args) { + int[] ia = new int[10]; // 见下文注 1 + System.out.println("ia is " + ia.getClass()); // 见下文注 2 + for (int i = 0; i < ia.length; i++) // 见下文注 3 + System.out.println("ia[" + i + "] = " + ia[i]); // 见下文注 4 + } + +} +``` + +让我们来看看最重要的部分。 + + 1. 我们声明和初始化了长度为 10 的整型数组,即 `ia`,这显而易见。 + 2. 在下面的行中,我们看到表达式 `ia.getClass()`。没错,`ia` 是属于一个*类*的*对象*,这行代码将告诉我们是哪个类。 + 3. 在紧接的下一行中,我们看到了一个循环 `for (int i = 0; i < ia.length; i++)`,它定义了一个循环索引变量 `i`,该变量遍历了从 0 到比 `ia.length` 小 1 的序列,这个表达式告诉我们在数组 `ia` 中定义了多少个元素。 + 4. 接下来,循环体打印出 `ia` 的每个元素的值。 + +当这个程序编译和运行时,它产生以下结果: + +``` +me@mydesktop:~/Java$ javac Test1.java +me@mydesktop:~/Java$ java Test1 +ia is class [I +ia[0] = 0 +ia[1] = 0 +ia[2] = 0 +ia[3] = 0 +ia[4] = 0 +ia[5] = 0 +ia[6] = 0 +ia[7] = 0 +ia[8] = 0 +ia[9] = 0 +me@mydesktop:~/Java$ +``` + +`ia.getClass()` 的输出的字符串表示形式是 `[I`,它是“整数数组”的简写。与 C 语言类似,Java 数组以第 0 个元素开始,扩展到第 `<数组大小> - 1` 个元素。如上所见,我们可以看到数组 `ia` 的每个元素都(似乎由数组构造函数)设置为零。 + +所以,就这些吗?声明类型,使用适当的初始化器,就完成了吗? + +好吧,并没有。在 Java 中有许多其它方法来初始化数组。 + +### 为什么我要初始化一个数组,有其它方式吗? + +像所有好的问题一样,这个问题的答案是“视情况而定”。在这种情况下,答案取决于初始化后我们希望对数组做什么。 + +在某些情况下,数组自然会作为一种累加器出现。例如,假设我们正在编程实现计算小型办公室中一组电话分机接收和拨打的电话数量。一共有 8 个分机,编号为 1 到 8,加上话务员的分机,编号为 0。 因此,我们可以声明两个数组: + +``` +int[] callsMade; +int[] callsReceived; +``` + +然后,每当我们开始一个新的累计呼叫统计数据的周期时,我们就将每个数组初始化为: + +``` +callsMade = new int[9]; +callsReceived = new int[9]; +``` + +在每个累计通话统计数据的最后阶段,我们可以打印出统计数据。粗略地说,我们可能会看到: + +``` +import java.lang.*; +import java.io.*; + +public class Test2 { + + public static void main(String[] args) { + + int[] callsMade; + int[] callsReceived; + + // 初始化呼叫计数器 + + callsMade = new int[9]; + callsReceived = new int[9]; + + // 处理呼叫…… + // 分机拨打电话:callsMade[ext]++ + // 分机接听电话:callsReceived[ext]++ + + // 汇总通话统计 + + System.out.printf("%3s%25s%25s\n", "ext", " calls made", + "calls received"); + for (int ext = 0; ext < callsMade.length; ext++) { + System.out.printf("%3d%25d%25d\n", ext, + callsMade[ext], callsReceived[ext]); + } + + } + +} +``` + +这会产生这样的输出: + +``` +me@mydesktop:~/Java$ javac Test2.java +me@mydesktop:~/Java$ java Test2 +ext calls made calls received + 0 0 0 + 1 0 0 + 2 0 0 + 3 0 0 + 4 0 0 + 5 0 0 + 6 0 0 + 7 0 0 + 8 0 0 +me@mydesktop:~/Java$ +``` + +看来这一天呼叫中心不是很忙。 + +在上面的累加器示例中,我们看到由数组初始化程序设置的零起始值可以满足我们的需求。但是在其它情况下,这个起始值可能不是正确的选择。 + +例如,在某些几何计算中,我们可能需要将二维数组初始化为单位矩阵(除沿主对角线———左上角到右下角——以外所有全是零)。我们可以选择这样做: + + +``` +double[][] m = new double[3][3]; +for (int d = 0; d < 3; d++) { + m[d][d] = 1.0; +} +``` + +在这种情况下,我们依靠数组初始化器 `new double[3][3]` 将数组设置为零,然后使用循环将主对角线上的元素设置为 1。在这种简单情况下,我们可以使用 Java 提供的快捷方式: + +``` +double[][] m = { + {1.0, 0.0, 0.0}, + {0.0, 1.0, 0.0}, + {0.0, 0.0, 1.0}}; +``` + +这种可视结构特别适用于这种应用程序,在这种应用程序中,它便于复查数组的实际布局。但是在这种情况下,行数和列数只在运行时确定时,我们可能会看到这样的东西: + +``` +int nrc; +// 一些代码确定行数和列数 = nrc +double[][] m = new double[nrc][nrc]; +for (int d = 0; d < nrc; d++) { + m[d][d] = 1.0; +} +``` + +值得一提的是,Java 中的二维数组实际上是数组的数组,没有什么能阻止无畏的程序员让这些第二层数组中的每个数组的长度都不同。也就是说,下面这样的事情是完全合法的: + +``` +int [][] differentLengthRows = { + {1, 2, 3, 4, 5}, + {6, 7, 8, 9}, + {10, 11, 12}, + {13, 14}, + {15}}; +``` + +在涉及不规则形状矩阵的各种线性代数应用中,可以应用这种类型的结构(有关更多信息,请参见[此 Wikipedia 文章][5])。除此之外,既然我们了解到二维数组实际上是数组的数组,那么以下内容也就不足为奇了: + +``` +differentLengthRows.length +``` + +可以告诉我们二维数组 `differentLengthRows` 的行数,并且: + +``` +differentLengthRows[i].length +``` + +告诉我们 `differentLengthRows` 第 `i` 行的列数。 + +### 深入理解数组 + +考虑到在运行时确定数组大小的想法,我们看到数组在实例化之前仍需要我们知道该大小。但是,如果在处理完所有数据之前我们不知道大小怎么办?这是否意味着我们必须先处理一次以找出数组的大小,然后再次处理?这可能很难做到,尤其是如果我们只有一次机会使用数据时。 + +[Java 集合框架][6]很好地解决了这个问题。提供的其中一项是 `ArrayList` 类,它类似于数组,但可以动态扩展。为了演示 `ArrayList` 的工作原理,让我们创建一个 `ArrayList` 对象并将其初始化为前 20 个[斐波那契数字][7]: + +``` +import java.lang.*; +import java.util.*; + +public class Test3 { + + public static void main(String[] args) { + + ArrayList fibos = new ArrayList(); + + fibos.add(0); + fibos.add(1); + for (int i = 2; i < 20; i++) { + fibos.add(fibos.get(i - 1) + fibos.get(i - 2)); + } + + for (int i = 0; i < fibos.size(); i++) { + System.out.println("fibonacci " + i + " = " + fibos.get(i)); + } + + } +} +``` + +上面的代码中,我们看到: + + * 用于存储多个 `Integer` 的 `ArrayList` 的声明和实例化。 + * 使用 `add()` 附加到 `ArrayList` 实例。 + * 使用 `get()` 通过索引号检索元素。 + * 使用 `size()` 来确定 `ArrayList` 实例中已经有多少个元素。 + +这里没有展示 `put()` 方法,它的作用是将一个值放在给定的索引号上。 + +该程序的输出为: + +``` +fibonacci 0 = 0 +fibonacci 1 = 1 +fibonacci 2 = 1 +fibonacci 3 = 2 +fibonacci 4 = 3 +fibonacci 5 = 5 +fibonacci 6 = 8 +fibonacci 7 = 13 +fibonacci 8 = 21 +fibonacci 9 = 34 +fibonacci 10 = 55 +fibonacci 11 = 89 +fibonacci 12 = 144 +fibonacci 13 = 233 +fibonacci 14 = 377 +fibonacci 15 = 610 +fibonacci 16 = 987 +fibonacci 17 = 1597 +fibonacci 18 = 2584 +fibonacci 19 = 4181 +``` + +`ArrayList` 实例也可以通过其它方式初始化。例如,可以给 `ArrayList` 构造器提供一个数组,或者在编译过程中知道初始元素时也可以使用 `List.of()` 和 `array.aslist()` 方法。我发现自己并不经常使用这些方式,因为我对 `ArrayList` 的主要用途是当我只想读取一次数据时。 + +此外,对于那些喜欢在加载数据后使用数组的人,可以使用 `ArrayList` 的 `toArray()` 方法将其实例转换为数组;或者,在初始化 `ArrayList` 实例之后,返回到当前数组本身。 + +Java 集合框架提供了另一种类似数组的数据结构,称为 `Map`(映射)。我所说的“类似数组”是指 `Map` 定义了一个对象集合,它的值可以通过一个键来设置或检索,但与数组(或 `ArrayList`)不同,这个键不需要是整型数;它可以是 `String` 或任何其它复杂对象。 + +例如,我们可以创建一个 `Map`,其键为 `String`,其值为 `Integer` 类型,如下: + +``` +Map stoi = new Map(); +``` + +然后我们可以对这个 `Map` 进行如下初始化: + +``` +stoi.set("one",1); +stoi.set("two",2); +stoi.set("three",3); +``` + +等类似操作。稍后,当我们想要知道 `"three"` 的数值时,我们可以通过下面的方式将其检索出来: + +``` +stoi.get("three"); +``` + +在我的认知中,`Map` 对于将第三方数据集中出现的字符串转换为我的数据集中的一致代码值非常有用。作为[数据转换管道][8]的一部分,我经常会构建一个小型的独立程序,用作在处理数据之前清理数据;为此,我几乎总是会使用一个或多个 `Map`。 + +值得一提的是,`ArrayList` 的 `ArrayList` 和 `Map` 的 `Map` 是很可能的,有时也是合理的。例如,假设我们在看树,我们对按树种和年龄范围累计树的数目感兴趣。假设年龄范围定义是一组字符串值(“young”、“mid”、“mature” 和 “old”),物种是 “Douglas fir”、“western red cedar” 等字符串值,那么我们可以将这个 `Map` 中的 `Map` 定义为: + +``` +Map> counter = new Map>(); +``` + +这里需要注意的一件事是,以上内容仅为 `Map` 的*行*创建存储。因此,我们的累加代码可能类似于: + +``` +// 假设我们已经知道了物种和年龄范围 +if (!counter.containsKey(species)) { + counter.put(species,new Map()); +} +if (!counter.get(species).containsKey(ageRange)) { + counter.get(species).put(ageRange,0); +} +``` + +此时,我们可以这样开始累加: + +``` +counter.get(species).put(ageRange, counter.get(species).get(ageRange) + 1); +``` + +最后,值得一提的是(Java 8 中的新特性)Streams 还可以用来初始化数组、`ArrayList` 实例和 `Map` 实例。关于此特性的详细讨论可以在[此处][9]和[此处][10]中找到。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/initializing-arrays-java + +作者:[Chris Hermansen][a] +选题:[lujun9972][b] +译者:[laingke](https://github.com/laingke) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clhermansen +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/java-coffee-mug.jpg?itok=Bj6rQo8r (Coffee beans and a cup of coffee) +[2]: https://opensource.com/article/19/8/what-object-java +[3]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string +[4]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system +[5]: https://en.wikipedia.org/wiki/Irregular_matrix +[6]: https://en.wikipedia.org/wiki/Java_collections_framework +[7]: https://en.wikipedia.org/wiki/Fibonacci_number +[8]: https://towardsdatascience.com/data-science-for-startups-data-pipelines-786f6746a59a +[9]: https://stackoverflow.com/questions/36885371/lambda-expression-to-initialize-array +[10]: https://stackoverflow.com/questions/32868665/how-to-initialize-a-map-using-a-lambda diff --git a/published/20191023 How to dual boot Windows 10 and Debian 10.md b/published/20191023 How to dual boot Windows 10 and Debian 10.md new file mode 100644 index 0000000000..b50292a234 --- /dev/null +++ b/published/20191023 How to dual boot Windows 10 and Debian 10.md @@ -0,0 +1,261 @@ +[#]: collector: (lujun9972) +[#]: translator: (wenwensnow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11557-1.html) +[#]: subject: (How to dual boot Windows 10 and Debian 10) +[#]: via: (https://www.linuxtechi.com/dual-boot-windows-10-debian-10/) +[#]: author: (James Kiarie https://www.linuxtechi.com/author/james/) + +如何拥有一个 Windows 10 和 Debian 10 的双系统 +====== + +在无数次劝说自己后,你终于做出了一个大胆的决定,试试 Linux。不过,在完全熟悉 Linux 之前,你依旧需要使用 Windows 10 系统。幸运的是,通过一个双系统引导设置,能让你在启动时,选择自己想要进入的系统。在这个指南中,你会看到如何 如何双重引导 Windows 10 和 Debian 10。 + +![如何拥有一个 Windows 10 和 Debian 10 的双系统][2] + +### 前提条件 + +在开始之前,确保你满足下列条件: + + * 一个 Debian 10 的可引导 USB 或 DVD + * 一个快速且稳定的网络(为了安装更新以及第三方软件) + +另外,记得注意你系统的引导策略(UEFI 或 Legacy),需要确保两个系统使用同一种引导模式。 + +### 第一步:在硬盘上创建一个空余分区 + +第一步,你需要在你的硬盘上创建一个空余分区。之后,这将是我们安装 Debian 系统的地方。为了实现这一目的,需要使用下图所示的磁盘管理器: + +同时按下 `Windows + R` 键,启动“运行程序”。接下来,输入 `diskmgmt.msc`,按回车键。 + +![启动“运行程序”][3] + +这会启动“磁盘管理”窗口,它会显示你 Windows 上所有已有磁盘。 + +![磁盘管理][4] + +接下来,你需要为安装的 Debian 系统创建空余空间。为此,你需要缩小其中一个磁盘(卷)上的分区,从而创建一个未分配的新分区。在这个例子里,我会从 D 盘中创建一个 30 GB 的新分区。 + +为了缩小一个卷,右键点击它,然后选中选项 “缩小Shrink volume...”。 + +![缩小卷][5] + +在弹出窗口中,定义你想缩小的空间大小。记住,这是将来要安装 Debian 10 的磁盘空间。我选择了 30000MB(大约 30 GB)。压缩完成后,点击“缩小Shrink”。 + +![缩小空间][6] + +在缩小操作结束后,你会看到一个如下图所示的未分配分区: + +![未分配分区][7] + +完美!现在可以准备开始安装了。 + +### 第二步:开始安装 Debian 10 + +空余分区已经创建好了,将你的可引导 USB 或安装 DVD 插入电脑,重新启动系统。记得更改 BIOS 中的引导顺序,需要在启动时按住功能键(通常,根据品牌不同,是 `F9`、`F10` 或 `F12` 中的某一个)。 这一步骤,对系统是否能进入安装媒体来说,至关重要。保存 BIOS 设置,并重启电脑。 + +如下图所示,界面会显示一个新的引导菜单:点击 “Graphical install”。 + +![图形化界面安装][8] + +下一步,选择你的偏好语言,然后点击 “继续Continue”。 + +![设置语言-Debian10][9] + +接着,选择你的地区,点击“继续Continue”。 根据地区,系统会自动选择当地对应的时区。如果你无法找到你所对应的地区,将界面往下拉, 点击“其他Other”后,选择相对应位置。 + +![选择地区-Debain10][10] + +而后,选择你的键盘布局。 + +![设置键盘-Debain10][11] + +接下来,设置系统的主机名,点击 “继续Continue”。 + +![设置主机名-Debian10][12] + +下一步,确定域名。如果你的电脑不在域中,直接点击 “继续Continue”按钮。 + +![设置域名-Debian10][13] + +然后,如图所示,设置 root 密码,点击 “继续Continue”。 + +![设置 root 密码-Debian10][14] + +下一步骤,设置账户的用户全名,点击 “继续Continue”。 + +![设置用户全名-debain10][15] + +接着,设置与此账户相关联的用户名。 + +![指定用户名-Debian10][16] + +下一步,设置用户密码,点击“继续Continue”。 + +![设置用户密码-Debian10][17] + +然后,设置时区。 + +![设置时区-Debian10][18] + +这时,你要为 Debian10 安装创建分区。如果你是新手用户,点击菜单中的第一个选项,“使用最大的连续空余空间Use the largest continuous free space”,点击“继续Continue”。 + +![使用最大的连续空余空间-debian10][19] + +不过,如果你对创建分区有所了解的话,选择“手动Manual” 选项,点击 “继续Continue”。 + +![选择手动-Debain10][20] + +接着,选择被标记为 “空余空间FREE SPACE” 的磁盘,点击 “继续Continue” 。接下来,点击“创建新分区Create a new partition”。 + +![创建新分区-Debain10][21] + +下一界面,首先确定交换空间大小。我的交换空间大小为 2GB,点击 “继续Continue”。 + +![确定交换空间大小-debian10][22] + +点击下一界面的 “主分区Primary”,点击“继续Continue”。 + +![磁盘主分区-Debian10][23] + +选择在磁盘 “初始位置beginning” 创建新分区后,点击继续。 + +![在初始位置创建-Debain10][24] + +选择 “Ext 4 日志文件系统Ext 4 journaling file system”,点击 “继续Continue”。 + +![选择 Ext4 日志文件系统-debain10][25] + +下个界面选择“交换空间swap space” ,点击 “继续Continue”。 + +![选择交换空间-debian10][26] + +选中 “完成此分区设置done setting the partition”,点击 “继续Continue”。 + +![完成此分区设置-debian10][27] + +返回磁盘分区界面,点击 “空余空间FREE SPACE”,点击 “继续Continue”。 + +![点击空余空间-Debain10][28] + +为了让自己能轻松一点,选中 “自动为空余空间分区Automatically partition the free space”后,点击 “继续Continue”。 + +![自动为空余空间分区-Debain10][29] + +接着点击 “将所有文件存储在同一分区(新手用户推荐)All files in one partition (recommended for new users)”。 + +![将所有文件存储在同一分区-debian10][30] + +最后, 点击 “完成分区设置,并将改动写入磁盘Finish partitioning and write changes to disk” ,点击 “继续Continue”。 + +![完成分区设置,并将改动写入磁盘][31] + +确定你要将改动写入磁盘,点击 “Yes”。 + +![将改动写入磁盘-Debian10][32] + +而后,安装程序会开始安装所有必要的软件包。 + +当系统询问是否要扫描其他 CD 时,选择 “No” ,并点击 “继续Continue”。 + +![扫描其他CD-No-Debain10][33] + +接着,选择离你最近的镜像站点地区,点击 “继续Continue”。 + +![Debian-镜像站点-国家][34] + +然后,选择最适合你的镜像站点,点击“继续Continue”。 + +![选择镜像站点][35] + +如果你打算使用代理服务器,在下面输入具体信息,没有的话就留空,点击 “继续Continue”。 + +![输入代理信息-debian10][36] + +随着安装进程的继续, 你会被问到,是否想参加一个软件包用途调查。你可以选择任意一个选项,之后点击“继续Continue”,我选择了“No”。 + +![参与调查-debain10][37] + +在软件选择窗口选中你想安装的软件包,点击“继续Continue”。 + +![软件选择-debian10][38] + +安装程序会将选中的软件一一安装,在这期间,你可以去喝杯咖啡休息一下。 + +系统将会询问你,是否要将 grub 的引导装载程序安装到主引导记录表(MBR)上。点击 “Yes”,而后点击 “继续Continue”。 + +![安装-grub-bootloader-debian10][39] + +接着,选中你想安装 grub 的硬盘,点击“继续Continue”。 + +![选择硬盘-安装 grub-Debian10][40] + +最后,安装完成,直接点击 “继续Continue”。 + +![安装完成-重新启动-debian10][41] + +你现在应该会有一个列出 Windows 和 Debian 的 grub 菜单。为了引导 Debian 系统,往下选择 Debian。之后,你就能看见登录界面。输入密码之后,按回车键。 + +![Debian10-登录][42] + +这就完成了!这样,你就拥有了一个全新的 Debian 10 和 Windows 10 双系统。 + +![Debian10-Buster-Details][43] + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/dual-boot-windows-10-debian-10/ + +作者:[James Kiarie][a] +选题:[lujun9972][b] +译者:[wenwensnow](https://github.com/wenwensnow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/james/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/10/How-to-dual-boot-Windows-and-Debian10.jpg +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Launch-Run-dialogue.jpg +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Disk-management.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Shrink-volume.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Shrink-space.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Unallocated-partition.jpg +[8]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Graphical-Install-Debian10.jpg +[9]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Select-Language-Debian10.jpg +[10]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Select-location-Debain10.jpg +[11]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Configure-Keyboard-layout-Debain10.jpg +[12]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Set-hostname-Debian10.jpg +[13]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Set-domain-name-Debian10.jpg +[14]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Set-root-Password-Debian10.jpg +[15]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Specify-fullname-user-debain10.jpg +[16]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Specify-username-Debian10.jpg +[17]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Specify-user-password-Debian10.jpg +[18]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Configure-timezone-Debian10.jpg +[19]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Use-largest-continuous-free-space-debian10.jpg +[20]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Select-Manual-Debain10.jpg +[21]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Create-new-partition-Debain10.jpg +[22]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Define-swap-space-debian10.jpg +[23]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Partition-Disks-Primary-Debain10.jpg +[24]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Start-at-the-beginning-Debain10.jpg +[25]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Select-Ext4-Journaling-system-debain10.jpg +[26]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Select-swap-debain10.jpg +[27]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Done-setting-partition-debian10.jpg +[28]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Click-Free-space-Debain10.jpg +[29]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Automatically-partition-free-space-Debain10.jpg +[30]: https://www.linuxtechi.com/wp-content/uploads/2019/10/All-files-in-one-partition-debian10.jpg +[31]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Finish-partitioning-write-changes-to-disk.jpg +[32]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Write-changes-to-disk-Yes-Debian10.jpg +[33]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Scan-another-CD-No-Debain10.jpg +[34]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Debian-archive-mirror-country.jpg +[35]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Select-Debian-archive-mirror.jpg +[36]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Enter-proxy-details-debian10.jpg +[37]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Participate-in-survey-debain10.jpg +[38]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Software-selection-debian10.jpg +[39]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Install-grub-bootloader-debian10.jpg +[40]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Select-hard-drive-install-grub-Debian10.jpg +[41]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Installation-complete-reboot-debian10.jpg +[42]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Debian10-log-in.jpg +[43]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Debian10-Buster-Details.jpg diff --git a/published/20191024 Open Source CMS Ghost 3.0 Released with New features for Publishers.md b/published/20191024 Open Source CMS Ghost 3.0 Released with New features for Publishers.md new file mode 100644 index 0000000000..1879697316 --- /dev/null +++ b/published/20191024 Open Source CMS Ghost 3.0 Released with New features for Publishers.md @@ -0,0 +1,116 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11534-1.html) +[#]: subject: (Open Source CMS Ghost 3.0 Released with New features for Publishers) +[#]: via: (https://itsfoss.com/ghost-3-release/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +开源 CMS Ghost 3.0 发布,带来新功能 +====== + +[Ghost][1] 是一个自由开源的内容管理系统(CMS)。如果你还不了解 CMS,那我在此解释一下。CMS 是一种软件,用它可以构建主要专注于创建内容的网站,而无需了解 HTML 和其他与 Web 相关的技术。 + +事实上,Ghost 是目前[最好的开源 CMS][2] 之一。它主要聚焦于创建轻量级、快速加载、界面美观的博客。 + +Ghost 系统有一个现代直观的编辑器,该编辑器内置 SEO(搜索引擎优化)功能。你也可以用本地桌面(包括 Linux 系统)和移动应用程序。如果你喜欢终端,也可以使用其提供的 CLI(命令行界面)工具。 + +让我们看看 Ghost 3.0 带来了什么新功能。 + +### Ghost 3.0 的新功能 + +![][3] + +我通常对开源的 CMS 解决方案很感兴趣。因此,在阅读了官方公告后,我通过在 Digital Ocean 云服务器上安装新的 Ghost 实例来进一步尝试它。 + +与以前的版本相比,Ghost 3.0 在功能和用户界面上的改进给我留下了深刻的印象。 + +在此,我将列出一些值得一提的关键点。 + +#### 书签卡 + +![][5] + +除了编辑器的所有细微更改之外,3.0 版本现在支持通过输入 URL 添加漂亮的书签卡。 + +如果你使用过 WordPress(你可能已经注意到,WordPress 需要添加一个插件才能添加类似的卡片),所以该功能绝对是 Ghost 3.0 系统的一个最大改进。 + +#### 改进的 WordPress 迁移插件 + +我没有专门对此进行测试,但它更新了 WordPress 的迁移插件,可以让你轻松地将帖子(带有图片)克隆到 Ghost CMS。 + +基本上,使用该插件,你就能够创建一个存档(包含图片)并将其导入到 Ghost CMS。 + +#### 响应式图像库和图片 + +为了使用户体验更好,Ghost 团队还更新了图像库(现已为响应式),以便在所有设备上舒适地呈现你的图片集。 + +此外,帖子和页面中的图片也更改为响应式的了。 + +#### 添加成员和订阅选项 + +![Ghost Subscription Model][6] + +虽然,该功能目前还处于测试阶段,但如果你是以此平台作为维持你业务关系的重要发布平台,你可以为你的博客添加成员、订阅选项。 + +该功能可以确保只有订阅的成员才能访问你的博客,你也可以选择让未订阅者也可以访问。 + +#### Stripe:集成支付功能 + +默认情况下,该版本支持 Stripe 付款网关,帮助你轻松启用订阅功能(或使用任何类型的付款的付款方式),而 Ghost 不收取任何额外费用。 + +#### 新的应用程序集成 + +![][7] + +你现在可以在 Ghost 3.0 的博客中集成各种流行的应用程序/服务。它可以使很多事情自动化。 + +#### 默认主题改进 + +引入的默认主题(设计)已得到改进,现在也提供了夜间模式。 + +你也可以随时选择创建自定义主题(如果没有可用的预置主题)。 + +#### 其他小改进 + +除了所有关键亮点以外,用于创建帖子/页面的可视编辑器也得到了改进(具有某些拖放功能)。 + +我确定还有很多技术方面的更改,如果你对此感兴趣,可以在他们的[更改日志][8]中查看。 + +### Ghost 影响力渐增 + +要在以 WordPress 为主导的世界中获得认可并不是一件容易的事。但 Ghost 逐渐形成了它的一个专门的发布者社区。 + +不仅如此,它的托管服务 [Ghost Pro][9] 现在拥有像 NASA、Mozilla 和 DuckDuckGo 这样的客户。 + +在过去的六年中,Ghost 从其 Ghost Pro 客户那里获得了 500 万美元的收入。就从它是致力于开源系统解决方案的非营利组织这一点来讲,这确实是一项成就。 + +这些收入有助于它们保持独立,避免风险投资家的外部资金投入。Ghost CMS 的托管客户越多,投入到免费和开源的 CMS 的研发款项就越多。 + +总体而言,Ghost 3.0 是迄今为止提供的最好的升级版本。这些功能给我留下了深刻的印象。 + +如果你拥有自己的网站,你会使用什么 CMS?你曾经使用过 Ghost 吗?你的体验如何?请在评论部分分享你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ghost-3-release/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/recommends/ghost/ +[2]: https://itsfoss.com/open-source-cms/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/ghost-3.jpg?ssl=1 +[4]: https://itsfoss.com/recommends/digital-ocean/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/ghost-editor-screenshot.png?ssl=1 +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/ghost-subscription-model.jpg?resize=800%2C503&ssl=1 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/ghost-app-integration.jpg?ssl=1 +[8]: https://ghost.org/faq/upgrades/ +[9]: https://itsfoss.com/recommends/ghost-pro/ diff --git a/translated/tech/20191025 4 cool new projects to try in COPR for October 2019.md b/published/20191025 4 cool new projects to try in COPR for October 2019.md similarity index 85% rename from translated/tech/20191025 4 cool new projects to try in COPR for October 2019.md rename to published/20191025 4 cool new projects to try in COPR for October 2019.md index 24cdca0fb8..73682ef6e5 100644 --- a/translated/tech/20191025 4 cool new projects to try in COPR for October 2019.md +++ b/published/20191025 4 cool new projects to try in COPR for October 2019.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11528-1.html) [#]: subject: (4 cool new projects to try in COPR for October 2019) [#]: via: (https://fedoramagazine.org/4-cool-new-projects-to-try-in-copr-for-october-2019/) [#]: author: (Dominik Turecek https://fedoramagazine.org/author/dturecek/) @@ -18,8 +18,7 @@ COPR 是个人软件仓库[集合][2],它不在 Fedora 中。这是因为某 ### Nu -[Nu][4] 或称为 Nushell 是受 PowerShell 和现代 CLI 工具启发的 shell。通过使用基于结构化数据的方法,Nu 可轻松处理命令的输出,并通过管道传输其他命令。然后将结果显示在可以轻松排序或过滤的表中,并可以用作其他命令的输入。最后,Nu 提供了几个内置命令、多 shell 和对插件的支持。 - +[Nu][4] 也被称为 Nushell,是受 PowerShell 和现代 CLI 工具启发的 shell。通过使用基于结构化数据的方法,Nu 可轻松处理命令的输出,并通过管道传输其他命令。然后将结果显示在可以轻松排序或过滤的表中,并可以用作其他命令的输入。最后,Nu 提供了几个内置命令、多 shell 和对插件的支持。 #### 安装说明 @@ -58,7 +57,7 @@ sudo dnf install crow-translate ### dnsmeter -[dnsmeter][10] 是用于测试域名服务器及其基础设施性能的命令行工具。为此,它发送 DNS 查询并计算答复数,从而测量各种统计数据。除此之外,dnsmeter 可以使用不同的加载步骤,使用 PCAP 文件中的 payload 和欺骗发送者地址。 +[dnsmeter][10] 是用于测试域名服务器及其基础设施性能的命令行工具。为此,它发送 DNS 查询并计算答复数,从而测量各种统计数据。除此之外,dnsmeter 可以使用不同的加载步骤,使用 PCAP 文件中的载荷和欺骗发送者地址。 #### 安装说明 @@ -76,7 +75,7 @@ via: https://fedoramagazine.org/4-cool-new-projects-to-try-in-copr-for-october-2 作者:[Dominik Turecek][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -91,4 +90,4 @@ via: https://fedoramagazine.org/4-cool-new-projects-to-try-in-copr-for-october-2 [7]: https://copr.fedorainfracloud.org/coprs/lyessaadi/notekit/ [8]: https://github.com/crow-translate/crow-translate [9]: https://copr.fedorainfracloud.org/coprs/faezebax/crow-translate/ -[10]: https://github.com/DNS-OARC/dnsmeter \ No newline at end of file +[10]: https://github.com/DNS-OARC/dnsmeter diff --git a/published/20191025 How I used the wget Linux command to recover lost images.md b/published/20191025 How I used the wget Linux command to recover lost images.md new file mode 100644 index 0000000000..274a70fff2 --- /dev/null +++ b/published/20191025 How I used the wget Linux command to recover lost images.md @@ -0,0 +1,132 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11592-1.html) +[#]: subject: (How I used the wget Linux command to recover lost images) +[#]: via: (https://opensource.com/article/19/10/how-community-saved-artwork-creative-commons) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +丢失的开放剪贴画库和新的公共艺术品图书馆 FreeSVG.org 的诞生 +====== + +> 开放剪贴画库兴衰的故事以及一个新的公共艺术品图书馆 FreeSVG.org 的诞生。 + +![](https://img.linux.net.cn/data/attachment/album/201911/19/102040imbybpl32vgdibbm.jpg) + +开放剪贴画库Open Clip Art Library(OCAL)发布于 2004 年,成为了免费插图的来源,任何人都可以出于任何目的使用它们,而无需注明出处或提供任何回报。针对 1990 年代每个家庭办公室书架上的大量剪贴画 CD 以及由闭源公司和艺术品软件提供的艺术品转储,这个网站是开源世界的回应。 + +最初,这个剪贴画库主要由一些贡献者提供,但是在 2010 年,它重新打造成了一个全新的交互式网站,可以让任何人使用矢量插图应用程序创建和贡献剪贴画。该网站立即获得了来自全球的、各种形式的自由软件和自由文化项目的贡献。[Inkscape][2] 中甚至包含了该库的专用导入器。 + +但是,在 2019 年初,托管开放剪贴画库的网站离线了,没有任何警告或解释。它已经成长为有着成千上万的人的社区,起初以为这是暂时的故障。但是,这个网站一直离线已超过六个月,而没有任何清楚的解释。 + +谣言开始膨胀。该网站一直在更新中(“要偿还数年的技术债务”,网站开发者 Jon Philips 在一封电子邮件中说)。一个 Twitter 帐户声称,该网站遭受了猖狂的 DDoS 攻击。另一个 Twitter 帐户声称,该网站维护者已经成为身份盗用的牺牲品。今天,在撰写本文时,该网站的一个且唯一的页面声明它处于“维护和保护模式”,其含义不清楚,只是用户无法访问其内容。 + +### 恢复公地 + +网站会随着时间的流逝而消失,但是对其社区而言,开放剪贴画库的丢失尤其令人惊讶,因为它被视为一个社区项目。很少有社区成员知道托管该库的网站已经落入单个维护者手中,因此,由于 [CC0 许可证][3],该库中的艺术品归所有人所有,但对它的访问是由单个维护者功能性拥有的。而且,由于该社区通过网站彼此保持联系,因此该维护者实际上拥有该社区。 + +当网站发生故障时,社区以及成员彼此之间都无法访问剪贴画。没有该网站,就没有社区。 + +最初,该网站离线后其上的所有东西都是被封锁的。不过,在几个月之后,用户开始意识到该网站的数据仍然在线,这意味着用户能够通过输入精确的 URL 访问单个剪贴画。换句话说,你不能通过在网站上到处点击来浏览剪贴画文件,但是如果你确切地知道该地址,你就可以在浏览器中访问它。类似的,技术型(或偷懒的)用户意识到能够通过类似 `wget` 的自动 Web 浏览器将网站“抓取”下来。 + +Linux 的 `wget` 命令从技术上来说是一个 Web 浏览器,虽然它不能让你像用 Firefox 一样交互式地浏览。相反,`wget` 可以连到互联网,获取文件或文件集,并下载到你的本次硬盘。然后,你可以在 Firefox、文本编辑器或最合适的应用程序中打开这些文件,查看内容。 + +通常,`wget` 需要知道要提取的特定文件。如果你使用的是安装了 `wget` 的 Linux 或 macOS,则可以通过下载 [example.com][4] 的索引页来尝试此过程: + +``` +$ wget example.org/index.html +[...] +$ tail index.html + +
+

Example Domain

+

This domain is for illustrative examples in documents. + You may use this domain in examples without permission.

+

More info

+
+``` + +为了抓取 OCAL,我使用了 `--mirror` 选项,以便可以只是将 `wget` 指向到包含剪贴画的目录,就可以下载该目录中的所有内容。此操作持续下载了连续四天(96 个小时),最终得到了超过 50,000 个社区成员贡献的 100,000 个 SVG 文件。不幸的是,任何没有适当元数据的文件的作者信息都是无法恢复的,因为此信息被锁定在该数据库中不可访问的文件中,但是 CC0 许可证意味着此问题*在技术上*无关紧要(因为 CC0 文件不需要归属)。 + +随意分析了一下下载的文件进行还显示,其中近 45,000 个文件是同一个文件(该网站的徽标)的副本。这是由于指向该网站徽标的重定向引起的(原因未知),仔细分析能够提取到原始的文件,又过了 96 个小时,并且恢复了直到最后一天发布在 OCAL 上的所有剪贴画:总共约有 156,000 张图像。 + +SVG 文件通常很小,但这仍然是大量工作,并且会带来一些非常实际的问题。首先,将需要数 GB 的在线存储空间,这样这些剪贴画才能供其先前的社区使用。其次,必须使用一种搜索剪贴画的方法,因为手动浏览 55,000 个文件是不现实的。 + +很明显,社区真正需要的是一个平台。 + +### 构建新的平台 + +一段时间以来,[公共领域矢量图][6] 网站一直在发布公共领域的矢量图。虽然它仍然是一个受欢迎的网站,但是开源用户通常只是将其用作辅助的图片资源,因为其中大多数文件都是 EPS 和 AI 格式的,这两者均与 Adobe 相关。这两种文件格式通常都可以转换为 SVG,但是特性会有所损失。 + +当公共领域矢量图网站的维护者(Vedran 和 Boris)得知 OCAL 丢失时,他们决定创建一个面向开源社区的网站。诚然,他们选择了开源 [Laravel][7] 框架作为后端,该框架为网站提供了管理控制台和用户访问权限。该框架功能强大且开发完善,还使他们能够快速响应错误报告和功能请求,并根据需要升级网站。他们正在建立的网站称为 [FreeSVG.org][8],已经是一个强大而繁荣的公共艺术品图书馆。 + +从那时起,他们就一直从 OCAL 上载所有剪贴画,并且他们甚至在努力地对这些剪贴画进行标记和分类。作为公共领域矢量图网站的创建者,他们还以 SVG 格式贡献了自己的图像。他们的目标是成为互联网上具有 CC0 许可证的 SVG 图像的主要资源。 + +### 贡献 + +[FreeSVG.org][8] 的维护者意识到他们已经继承了重要的管理权。他们正在努力对网站上的所有图像加上标题和描述,以便用户可以轻松找到这些剪贴画,并在准备就绪后将其提供给社区,同时坚信同这些剪贴画一样,与这些剪贴画有关的元数据属于创建和使用它们的人。他们还意识到可能会发生无法预料的情况,因此他们会定期为其网站和内容创建备份,并打算在其网站出现故障时向公众提供最新备份。 + +如果要为 [FreeSVG.org][9]的知识共享内容添砖加瓦,请下载 [Inkscape][10] 并开始绘制。世界上有很多公共领域的艺术品,例如[历史广告][11]、[塔罗牌][12]和[故事书][13],只是在等待转换为 SVG,因此即使你对自己的绘画技巧没有信心你也可以做出贡献。访问 [FreeSVG 论坛][14]与其他贡献者联系并支持他们。 + +*公地*的概念很重要。无论你是学生、老师、图书馆员、小企业主还是首席执行官,[知识共享都会使所有人受益][15]。如果你不直接捐款,那么你随时可以帮助推广。 + +这是自由文化的力量:它不仅可以扩展,而且随着更多人的参与,它会变得更好。 + +### 艰辛的教训 + +从 OCAL 的消亡到 FreeSVG.org 的兴起,开放文化社区已经吸取了一些艰辛的经验。对于以后,以下是我认为最重要的那些。 + +#### 维护你的元数据 + +如果你是内容创建者,请帮助将来的档案管理员,将元数据添加到文件中。大多数图像、音乐、字体和视频文件格式都可以嵌入 EXIF 数据,其他格式在创建它们的应用程序中具有元数据输入界面。勤于用你的姓名、网站或公共电子邮件以及许可证来标记你的作品。 + +#### 做个副本 + +不要以为别人在做备份。如果你关心公用数字内容,请自己备份,否则不要指望永远提供它。无论*任何上传到互联网上的内容是永久的*的说法是不是正确的,但这并不意味着你永远可以使用。如果 OCAL 文件不再暗地可用,那么任何人都不太可能成功地从网络上的某个位置或从全球范围内的人们的硬盘中成功地发现全部的 55,000 张图像。 + +#### 创建外部渠道 + +如果一个社区是由单个网站或实际位置来定义的,那么该社区失去访问该空间的能力就如同解散了一样。如果你是由单个组织或网站驱动的社区的成员,则你应该自己与关心的人共享联系信息,并即使在该网站不可用时也可以建立沟通渠道。 + +例如,[Opensource.com][16] 本身维护其作者和通讯者的邮件列表和其他异地渠道,以便在有或没有网站干预或甚至没有网站的情况下相互交流。 + +#### 自由文化值得为此努力 + +互联网有时被视为懒人社交俱乐部。你可以在需要时登录并在感到疲倦时将其关闭,也可以漫步到所需的任何社交圈。 + +但实际上,自由文化可能是项艰难的工作。但是这种艰难从某种意义上讲并不是说要成为其中的一分子很困难,而是你必须努力维护。如果你忽略你所在的社区,那么该社区可能会在你意识到之前就枯萎并褪色。 + +花点时间环顾四周,确定你属于哪个社区,如果不是,那么请告诉某人你对他们带给你生活的意义表示赞赏。同样重要的是,请记住,这样你也为社区的生活做出了贡献。 + +几周前,知识共享组织在华沙举行了它的全球峰会,令人惊叹的国际盛会... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/how-community-saved-artwork-creative-commons + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tribal_pattern_shoes.png?itok=e5dSf2hS (White shoes on top of an orange tribal pattern) +[2]: https://opensource.com/article/18/1/inkscape-absolute-beginners +[3]: https://creativecommons.org/share-your-work/public-domain/cc0/ +[4]: http://example.com +[5]: http://www.iana.org/domains/example"\>More +[6]: http://publicdomainvectors.org +[7]: https://github.com/viralsolani/laravel-adminpanel +[8]: https://freesvg.org +[9]: http://freesvg.org +[10]: http://inkscape.org +[11]: https://freesvg.org/drinking-coffee-vector-drawing +[12]: https://freesvg.org/king-of-swords-tarot-card +[13]: https://freesvg.org/space-pioneers-135-scene-vector-image +[14]: http://forum.freesvg.org/ +[15]: https://opensource.com/article/18/1/creative-commons-real-world +[16]: http://Opensource.com diff --git a/published/20191025 Understanding system calls on Linux with strace.md b/published/20191025 Understanding system calls on Linux with strace.md new file mode 100644 index 0000000000..fd88408ae4 --- /dev/null +++ b/published/20191025 Understanding system calls on Linux with strace.md @@ -0,0 +1,406 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11545-1.html) +[#]: subject: (Understanding system calls on Linux with strace) +[#]: via: (https://opensource.com/article/19/10/strace) +[#]: author: (Gaurav Kamathe https://opensource.com/users/gkamathe) + +在 Linux 上用 strace 来理解系统调用 +====== + +> 使用 strace 跟踪用户进程和 Linux 内核之间的交互。 + +![Hand putting a Linux file folder into a drawer][1] + +系统调用system call是程序从内核请求服务的一种编程方式,而 `strace` 是一个功能强大的工具,可让你跟踪用户进程与 Linux 内核之间的交互。 + +要了解操作系统的工作原理,首先需要了解系统调用的工作原理。操作系统的主要功能之一是为用户程序提供抽象机制。 + +操作系统可以大致分为两种模式: + +* 内核模式:操作系统内核使用的一种强大的特权模式 +* 用户模式:大多数用户应用程序运行的地方 +   +用户大多使用命令行实用程序和图形用户界面(GUI)来执行日常任务。系统调用在后台静默运行,与内核交互以完成工作。 + +系统调用与函数调用非常相似,这意味着它们都接受并处理参数然后返回值。唯一的区别是系统调用进入内核,而函数调用不进入。从用户空间切换到内核空间是使用特殊的 [trap][2] 机制完成的。 + +通过使用系统库(在 Linux 系统上又称为 glibc),大部分系统调用对用户隐藏了。尽管系统调用本质上是通用的,但是发出系统调用的机制在很大程度上取决于机器(架构)。 + +本文通过使用一些常规命令并使用 `strace` 分析每个命令进行的系统调用来探索一些实际示例。这些示例使用 Red Hat Enterprise Linux,但是这些命令运行在其他 Linux 发行版上应该也是相同的: + +``` +[root@sandbox ~]# cat /etc/redhat-release +Red Hat Enterprise Linux Server release 7.7 (Maipo) +[root@sandbox ~]# +[root@sandbox ~]# uname -r +3.10.0-1062.el7.x86_64 +[root@sandbox ~]# +``` + +首先,确保在系统上安装了必需的工具。你可以使用下面的 `rpm` 命令来验证是否安装了 `strace`。如果安装了,则可以使用 `-V` 选项检查 `strace` 实用程序的版本号: + +``` +[root@sandbox ~]# rpm -qa | grep -i strace +strace-4.12-9.el7.x86_64 +[root@sandbox ~]# +[root@sandbox ~]# strace -V +strace -- version 4.12 +[root@sandbox ~]# +``` + +如果没有安装,运行命令安装: + +``` +yum install strace +``` + +出于本示例的目的,在 `/tmp` 中创建一个测试目录,并使用 `touch` 命令创建两个文件: + +``` +[root@sandbox ~]# cd /tmp/ +[root@sandbox tmp]# +[root@sandbox tmp]# mkdir testdir +[root@sandbox tmp]# +[root@sandbox tmp]# touch testdir/file1 +[root@sandbox tmp]# touch testdir/file2 +[root@sandbox tmp]# +``` + +(我使用 `/tmp` 目录是因为每个人都可以访问它,但是你可以根据需要选择另一个目录。) + +在 `testdir` 目录下使用 `ls` 命令验证该文件已经创建: + +``` +[root@sandbox tmp]# ls testdir/ +file1  file2 +[root@sandbox tmp]# +``` + +你可能每天都在使用 `ls` 命令,而没有意识到系统调用在其下面发挥的作用。抽象地来说,该命令的工作方式如下: + +> 命令行工具 -> 从系统库(glibc)调用函数 -> 调用系统调用 + +`ls` 命令内部从 Linux 上的系统库(即 glibc)调用函数。这些库去调用完成大部分工作的系统调用。 + +如果你想知道从 glibc 库中调用了哪些函数,请使用 `ltrace` 命令,然后跟上常规的 `ls testdir/`命令: + +``` +ltrace ls testdir/ +``` + +如果没有安装 `ltrace`,键入如下命令安装: + +``` +yum install ltrace +``` + +大量的输出会被堆到屏幕上;不必担心,只需继续就行。`ltrace` 命令输出中与该示例有关的一些重要库函数包括: + +``` +opendir("testdir/") = { 3 } +readdir({ 3 }) = { 101879119, "." } +readdir({ 3 }) = { 134, ".." } +readdir({ 3 }) = { 101879120, "file1" } +strlen("file1") = 5 +memcpy(0x1665be0, "file1\0", 6) = 0x1665be0 +readdir({ 3 }) = { 101879122, "file2" } +strlen("file2") = 5 +memcpy(0x166dcb0, "file2\0", 6) = 0x166dcb0 +readdir({ 3 }) = nil +closedir({ 3 })                     +``` + +通过查看上面的输出,你或许可以了解正在发生的事情。`opendir` 库函数打开一个名为 `testdir` 的目录,然后调用 `readdir` 函数,该函数读取目录的内容。最后,有一个对 `closedir` 函数的调用,该函数将关闭先前打开的目录。现在请先忽略其他 `strlen` 和 `memcpy` 功能。 + +你可以看到正在调用哪些库函数,但是本文将重点介绍由系统库函数调用的系统调用。 + +与上述类似,要了解调用了哪些系统调用,只需将 `strace` 放在 `ls testdir` 命令之前,如下所示。 再次,一堆乱码丢到了你的屏幕上,你可以按照以下步骤进行操作: + +``` +[root@sandbox tmp]# strace ls testdir/ +execve("/usr/bin/ls", ["ls", "testdir/"], [/* 40 vars */]) = 0 +brk(NULL) = 0x1f12000 +<<< truncated strace output >>> +write(1, "file1 file2\n", 13file1 file2 +) = 13 +close(1) = 0 +munmap(0x7fd002c8d000, 4096) = 0 +close(2) = 0 +exit_group(0) = ? ++++ exited with 0 +++ +[root@sandbox tmp]# +``` + +运行 `strace` 命令后屏幕上的输出就是运行 `ls` 命令的系统调用。每个系统调用都为操作系统提供了特定的用途,可以将它们大致分为以下几个部分: + +* 进程管理系统调用 +* 文件管理系统调用 +* 目录和文件系统管理系统调用 +* 其他系统调用 + +分析显示到屏幕上的信息的一种更简单的方法是使用 `strace` 方便的 `-o` 标志将输出记录到文件中。在 `-o` 标志后添加一个合适的文件名,然后再次运行命令: + +``` +[root@sandbox tmp]# strace -o trace.log ls testdir/ +file1  file2 +[root@sandbox tmp]# +``` + +这次,没有任何输出干扰屏幕显示,`ls` 命令如预期般工作,显示了文件名并将所有输出记录到文件 `trace.log` 中。仅仅是一个简单的 `ls` 命令,该文件就有近 100 行内容: + +``` +[root@sandbox tmp]# ls -l trace.log +-rw-r--r--. 1 root root 7809 Oct 12 13:52 trace.log +[root@sandbox tmp]# +[root@sandbox tmp]# wc -l trace.log +114 trace.log +[root@sandbox tmp]# +``` + +让我们看一下这个示例的 `trace.log` 文件的第一行: + +``` +execve("/usr/bin/ls", ["ls", "testdir/"], [/* 40 vars */]) = 0 +``` + +* 该行的第一个单词 `execve` 是正在执行的系统调用的名称。 +* 括号内的文本是提供给该系统调用的参数。 +* 符号 `=` 后的数字(在这种情况下为 `0`)是 `execve` 系统调用的返回值。 + +现在的输出似乎还不太吓人,对吧。你可以应用相同的逻辑来理解其他行。 + +现在,将关注点集中在你调用的单个命令上,即 `ls testdir`。你知道命令 `ls` 使用的目录名称,那么为什么不在 `trace.log` 文件中使用 `grep` 查找 `testdir` 并查看得到的结果呢?让我们详细查看一下结果的每一行: + +``` +[root@sandbox tmp]# grep testdir trace.log +execve("/usr/bin/ls", ["ls", "testdir/"], [/* 40 vars */]) = 0 +stat("testdir/", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0 +openat(AT_FDCWD, "testdir/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 +[root@sandbox tmp]# +``` + +回顾一下上面对 `execve` 的分析,你能说一下这个系统调用的作用吗? + +``` +execve("/usr/bin/ls", ["ls", "testdir/"], [/* 40 vars */]) = 0 +``` + +你无需记住所有系统调用或它们所做的事情,因为你可以在需要时参考文档。手册页可以解救你!在运行 `man` 命令之前,请确保已安装以下软件包: + +``` +[root@sandbox tmp]# rpm -qa | grep -i man-pages +man-pages-3.53-5.el7.noarch +[root@sandbox tmp]# +``` + +请记住,你需要在 `man` 命令和系统调用名称之间添加 `2`。如果使用 `man man` 阅读 `man` 命令的手册页,你会看到第 2 节是为系统调用保留的。同样,如果你需要有关库函数的信息,则需要在 `man` 和库函数名称之间添加一个 `3`。 + +以下是手册的章节编号及其包含的页面类型: + +* `1`:可执行的程序或 shell 命令 +* `2`:系统调用(由内核提供的函数) +* `3`:库调用(在程序的库内的函数) +* `4`:特殊文件(通常出现在 `/dev`) + +使用系统调用名称运行以下 `man` 命令以查看该系统调用的文档: + +``` +man 2 execve +``` + +按照 `execve` 手册页,这将执行在参数中传递的程序(在本例中为 `ls`)。可以为 `ls` 提供其他参数,例如本例中的 `testdir`。因此,此系统调用仅以 `testdir` 作为参数运行 `ls`: + +``` +execve - execute program + +DESCRIPTION + execve() executes the program pointed to by filename +``` + +下一个系统调用,名为 `stat`,它使用 `testdir` 参数: + +``` +stat("testdir/", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0 +``` + +使用 `man 2 stat` 访问该文档。`stat` 是获取文件状态的系统调用,请记住,Linux 中的一切都是文件,包括目录。 + +接下来,`openat` 系统调用将打开 `testdir`。密切注意返回的 `3`。这是一个文件描述符,将在以后的系统调用中使用: + +``` +openat(AT_FDCWD, "testdir/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 +``` + +到现在为止一切都挺好。现在,打开 `trace.log` 文件,并转到 `openat` 系统调用之后的行。你会看到 `getdents` 系统调用被调用,该调用完成了执行 `ls testdir` 命令所需的大部分操作。现在,从 `trace.log` 文件中用 `grep` 获取 `getdents`: + +``` +[root@sandbox tmp]# grep getdents trace.log +getdents(3, /* 4 entries */, 32768)     = 112 +getdents(3, /* 0 entries */, 32768)     = 0 +[root@sandbox tmp]# +``` + +`getdents` 的手册页将其描述为 “获取目录项”,这就是你要执行的操作。注意,`getdents` 的参数是 `3`,这是来自上面 `openat` 系统调用的文件描述符。 + +现在有了目录列表,你需要一种在终端中显示它的方法。因此,在日志中用 `grep` 搜索另一个用于写入终端的系统调用 `write`: + +``` +[root@sandbox tmp]# grep write trace.log +write(1, "file1  file2\n", 13)          = 13 +[root@sandbox tmp]# +``` + +在这些参数中,你可以看到将要显示的文件名:`file1` 和 `file2`。关于第一个参数(`1`),请记住在 Linux 中,当运行任何进程时,默认情况下会为其打开三个文件描述符。以下是默认的文件描述符: + +* `0`:标准输入 +* `1`:标准输出 +* `2`:标准错误 + +因此,`write` 系统调用将在标准显示(就是这个终端,由 `1` 所标识的)上显示 `file1` 和 `file2`。 + +现在你知道哪个系统调用完成了 `ls testdir/` 命令的大部分工作。但是在 `trace.log` 文件中其它的 100 多个系统调用呢?操作系统必须做很多内务处理才能运行一个进程,因此,你在该日志文件中看到的很多内容都是进程初始化和清理。阅读整个 `trace.log` 文件,并尝试了解 `ls` 命令是怎么工作起来的。 + +既然你知道了如何分析给定命令的系统调用,那么就可以将该知识用于其他命令来了解正在执行哪些系统调用。`strace` 提供了许多有用的命令行标志,使你更容易使用,下面将对其中一些进行描述。 + +默认情况下,`strace` 并不包含所有系统调用信息。但是,它有一个方便的 `-v` 冗余选项,可以在每个系统调用中提供附加信息: + +``` +strace -v ls testdir +``` + +在运行 `strace` 命令时始终使用 `-f` 选项是一种好的作法。它允许 `strace` 对当前正在跟踪的进程创建的任何子进程进行跟踪: + +``` +strace -f ls testdir +``` + +假设你只需要系统调用的名称、运行的次数以及每个系统调用花费的时间百分比。你可以使用 `-c` 标志来获取这些统计信息: + +``` +strace -c ls testdir/ +``` + +假设你想专注于特定的系统调用,例如专注于 `open` 系统调用,而忽略其余部分。你可以使用`-e` 标志跟上系统调用的名称: + +``` +[root@sandbox tmp]# strace -e open ls testdir +open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 +open("/lib64/libselinux.so.1", O_RDONLY|O_CLOEXEC) = 3 +open("/lib64/libcap.so.2", O_RDONLY|O_CLOEXEC) = 3 +open("/lib64/libacl.so.1", O_RDONLY|O_CLOEXEC) = 3 +open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 +open("/lib64/libpcre.so.1", O_RDONLY|O_CLOEXEC) = 3 +open("/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3 +open("/lib64/libattr.so.1", O_RDONLY|O_CLOEXEC) = 3 +open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3 +open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3 +file1  file2 ++++ exited with 0 +++ +[root@sandbox tmp]# +``` + +如果你想关注多个系统调用怎么办?不用担心,你同样可以使用 `-e` 命令行标志,并用逗号分隔开两个系统调用的名称。例如,要查看 `write` 和 `getdents` 系统调用: + +``` +[root@sandbox tmp]# strace -e write,getdents ls testdir +getdents(3, /* 4 entries */, 32768)     = 112 +getdents(3, /* 0 entries */, 32768)     = 0 +write(1, "file1  file2\n", 13file1  file2 +)          = 13 ++++ exited with 0 +++ +[root@sandbox tmp]# +``` + +到目前为止,这些示例是明确地运行的命令进行了跟踪。但是,要跟踪已经运行并正在执行的命令又怎么办呢?例如,如果要跟踪用来长时间运行进程的守护程序,该怎么办?为此,`strace` 提供了一个特殊的 `-p` 标志,你可以向其提供进程 ID。 + +我们的示例不在守护程序上运行 `strace`,而是以 `cat` 命令为例,如果你将文件名作为参数,通常 `cat` 会显示文件的内容。如果没有给出参数,`cat` 命令会在终端上等待用户输入文本。输入文本后,它将重复给定的文本,直到用户按下 `Ctrl + C` 退出为止。 + +从一个终端运行 `cat` 命令;它会向你显示一个提示,并等待在那里(记住 `cat` 仍在运行且尚未退出): + +``` +[root@sandbox tmp]# cat +``` + +在另一个终端上,使用 `ps` 命令找到进程标识符(PID): + +``` +[root@sandbox ~]# ps -ef | grep cat +root      22443  20164  0 14:19 pts/0    00:00:00 cat +root      22482  20300  0 14:20 pts/1    00:00:00 grep --color=auto cat +[root@sandbox ~]# +``` + +现在,使用 `-p` 标志和 PID(在上面使用 `ps` 找到)对运行中的进程运行 `strace`。运行 `strace` 之后,其输出说明了所接驳的进程的内容及其 PID。现在,`strace` 正在跟踪 `cat` 命令进行的系统调用。看到的第一个系统调用是 `read`,它正在等待文件描述符 `0`(标准输入,这是运行 `cat` 命令的终端)的输入: + +``` +[root@sandbox ~]# strace -p 22443 +strace: Process 22443 attached +read(0, +``` + +现在,返回到你运行 `cat` 命令的终端,并输入一些文本。我出于演示目的输入了 `x0x0`。注意 `cat` 是如何简单地重复我输入的内容的。因此,`x0x0` 出现了两次。我输入了第一个,第二个是 `cat` 命令重复的输出: + +``` +[root@sandbox tmp]# cat +x0x0 +x0x0 +``` + +返回到将 `strace` 接驳到 `cat` 进程的终端。现在你会看到两个额外的系统调用:较早的 `read` 系统调用,现在在终端中读取 `x0x0`,另一个为 `write`,它将 `x0x0` 写回到终端,然后是再一个新的 `read`,正在等待从终端读取。请注意,标准输入(`0`)和标准输出(`1`)都在同一终端中: + +``` +[root@sandbox ~]# strace -p 22443 +strace: Process 22443 attached +read(0, "x0x0\n", 65536)                = 5 +write(1, "x0x0\n", 5)                   = 5 +read(0, +``` + +想象一下,对守护进程运行 `strace` 以查看其在后台执行的所有操作时这有多大帮助。按下 `Ctrl + C` 杀死 `cat` 命令;由于该进程不再运行,因此这也会终止你的 `strace` 会话。 + +如果要查看所有的系统调用的时间戳,只需将 `-t` 选项与 `strace` 一起使用: + +``` +[root@sandbox ~]#strace -t ls testdir/ + +14:24:47 execve("/usr/bin/ls", ["ls", "testdir/"], [/* 40 vars */]) = 0 +14:24:47 brk(NULL)                      = 0x1f07000 +14:24:47 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2530bc8000 +14:24:47 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) +14:24:47 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 +``` + +如果你想知道两次系统调用之间所花费的时间怎么办?`strace` 有一个方便的 `-r` 命令,该命令显示执行每个系统调用所花费的时间。非常有用,不是吗? + +``` +[root@sandbox ~]#strace -r ls testdir/ + +0.000000 execve("/usr/bin/ls", ["ls", "testdir/"], [/* 40 vars */]) = 0 +0.000368 brk(NULL)                 = 0x1966000 +0.000073 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb6b1155000 +0.000047 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) +0.000119 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 +``` + +### 总结 + +`strace` 实用程序非常有助于理解 Linux 上的系统调用。要了解它的其它命令行标志,请参考手册页和在线文档。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/strace + +作者:[Gaurav Kamathe][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/gkamathe +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/yearbook-haff-rx-linux-file-lead_0.png?itok=-i0NNfDC (Hand putting a Linux file folder into a drawer) +[2]: https://en.wikipedia.org/wiki/Trap_(computing) diff --git a/published/20191025 Why I made the switch from Mac to Linux.md b/published/20191025 Why I made the switch from Mac to Linux.md new file mode 100644 index 0000000000..3a9b399734 --- /dev/null +++ b/published/20191025 Why I made the switch from Mac to Linux.md @@ -0,0 +1,79 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11586-1.html) +[#]: subject: (Why I made the switch from Mac to Linux) +[#]: via: (https://opensource.com/article/19/10/why-switch-mac-linux) +[#]: author: (Matthew Broberg https://opensource.com/users/mbbroberg) + +为什么我从 Mac 换到了 Linux +====== + +> 感谢这么多的开源开发人员,日常使用 Linux 比以往任何时候都容易得多。 + +![](https://img.linux.net.cn/data/attachment/album/201911/17/203212qes7o7zpeefbpffe.jpg) + +自 2004 年开始从事 IT 工作以来,我一直是 Mac 的忠实粉丝。但是几个月前,由于种种原因,我决定将 Linux 用作日常使用的系统。这不是我第一次尝试完全采用 Linux,但是我发现它比以往更加容易。下面是促使我转换的原因。 + +### 我在个人电脑上的首次 Linux 体验 + +我记得,我抬头看着投影机,而它和我面面相觑。我们俩都不明白为什么它不显示。VGA 线完全接好了,针脚也没有弯折。我按了我所有想到的可能的按键组合,以向我的笔记本电脑发出信号,想让它克服“舞台恐惧症”。 + +我在大学里运行 Linux 只是作为实验。而我在 IT 部门的经理是多种口味的倡导者,随着我对桌面支持和编写脚本的信心增强,我想了解更多 Linux 的信息。对我来说,IT 比我的计算机科学学位课程有趣得多,课程的感觉是如此抽象和理论化:“二叉树有啥用?”,我如是想 —— 而我们的系统管理员团队的工作却是如此的真真切切。 + +这个故事的结尾是,我登录到 Windows 工作站完成了我的课堂演讲,这标志着我将 Linux 作为我的日常操作系统的第一次尝试的终结。我很欣赏 Linux 的灵活性,但是它缺乏兼容性。我偶尔会写个脚本,脚本通过 SSH 连接到一个机器中以运行另一个脚本,但是我对 Linux 的日常使用仅止于此。 + +### 对 Linux 兼容性的全新印象 + +几个月前,当我决定再试一次 Linux 时,我曾觉得我遇到更多的兼容性噩梦,但我错了。 + +安装过程完成后,我立即插入了 USB-C 集线器以了解兼容性到底如何。一切立即工作。连接 HDMI 的超宽显示器作为镜像显示器弹出到我的笔记本电脑屏幕上,我轻松地将其调整为第二台显示器。USB 连接的网络摄像头对我的[在家工作方式][2]至关重要,它可以毫无问题地显示视频。甚至自从我使用 Mac 以来就一直插在集线器的 Mac 充电器可以为我的非常不 Mac 的硬件充电。 + +我的正面体验可能与 USB-C 的一些更新有关,它在 2018 年得到一些所需的关注,因此才能与其他操作系统的体验相媲美。正如 [Phoronix 解释的那样][3]: + +> “USB Type-C 接口为非 USB 信号提供了‘替代模式’扩展,在规范中该替代模式的最大使用场景是支持 DisplayPort。除此之外,另一个替代模式是支持 Thunderbolt 3。DisplayPort 替代模式支持 4K 甚至 8Kx4K 的视频输出,包括多声道音频。 +> +> “虽然 USB-C 替代模式和 DisplayPort 已经存在了一段时间,并且在 Windows 上很常见,但是主线 Linux 内核不支持此功能。所幸的是,多亏英特尔,这种情况正在改变。” +> + +而在端口之外,快速浏览一下 [笔记本电脑 Linux][4] 的硬件选择,列出了比我 2000 年代初期所经历的更加完整的选择集。 + +与我第一次尝试采用 Linux 相比,这已经天差地别,这是我张开双臂欢迎的。 + +### 突破 Apple 的樊篱 + +使用 Linux 给我的日常工作流程增加了一些新的麻烦,而我喜欢这种麻烦。 + +我的 Mac 工作流程是无缝的:早上打开 iPad,写下关于我今天想要做什么的想法,然后开始在 Safari 中阅读一些文章;移到我的 iPhone 上可以继续阅读;然后登录我的 MacBook,这些地方我进行了多年的微调,已经弄清楚了所有这些部分之间的连接方式。键盘快捷键已内置在我的大脑中;用户体验一如既往。简直不要太舒服了。 + +这种舒适需要付出代价。我基本上忘记了我的环境如何运作的,也无法解答我想解答的问题。我是否自定义了一些 [PLIST 文件][5]以获得快捷方式,是不是记得将其签入[我的 dotfiles][6] 当中?当 Firefox 的功能更好时,我为何还如此依赖 Safari 和 Chrome?为什么我不使用基于 Android 的手机代替我的 i-系列产品呢? + +关于这一点,我经常考虑改用基于 Android 的手机,但是我会失去在所有这些设备之间的连接性以及为这种生态系统设计的一些便利。例如,我将无法在 iPhone 上为 Apple TV 输入搜索内容,也无法与其他用 Apple 的朋友用 AirDrop 共享密码。这些功能是同类设备环境的巨大好处,并且是一项了不起的工程。也就是说,这些便利是被生态系统所困的代价。 + +我喜欢了解设备的工作方式。我希望能够解释使我的系统变得有趣或容易使用的环境配置,但我也想看看增加一些麻烦对我的观点有什么影响。用 [Marcel Proust][7] 的话来说,“真正的发现之旅不在于寻找新的土地,而在于用新的眼光来看待。”技术的使用是如此的方便,以至于我不再对它的工作原理感到好奇,而 Linux 使我有机会再次有了新的眼光。 + +### 受你的启发 + +以上所有内容足以成为探索 Linux 的理由,但我也受到了你的启发。尽管所有操作系统都受到开源社区的欢迎,但 Opensource.com 的作者和读者对 Linux 的喜悦是充满感染力的。它激发了我重新潜入的乐趣,我享受这段旅途的乐趣。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/why-switch-mac-linux + +作者:[Matthew Broberg][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mbbroberg +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop.png?itok=pGfEfu2S (Hands programming) +[2]: https://opensource.com/article/19/8/rules-remote-work-sanity +[3]: https://www.phoronix.com/scan.php?page=news_item&px=Linux-USB-Type-C-Port-DP-Driver +[4]: https://www.linux-laptop.net/ +[5]: https://fileinfo.com/extension/plist +[6]: https://opensource.com/article/19/3/move-your-dotfiles-version-control +[7]: https://www.age-of-the-sage.org/quotations/proust_having_seeing_with_new_eyes.html diff --git a/published/20191027 How to Install and Configure Nagios Core on CentOS 8 - RHEL 8.md b/published/20191027 How to Install and Configure Nagios Core on CentOS 8 - RHEL 8.md new file mode 100644 index 0000000000..e57a711a68 --- /dev/null +++ b/published/20191027 How to Install and Configure Nagios Core on CentOS 8 - RHEL 8.md @@ -0,0 +1,282 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11572-1.html) +[#]: subject: (How to Install and Configure Nagios Core on CentOS 8 / RHEL 8) +[#]: via: (https://www.linuxtechi.com/install-nagios-core-rhel-8-centos-8/) +[#]: author: (James Kiarie https://www.linuxtechi.com/author/james/) + +如何在 CentOS 8/RHEL 8 上安装和配置 Nagios Core +====== + +Nagios 是一个自由开源的网络和警报引擎,它用于监控各种设备,例如网络设备和网络中的服务器。它支持 Linux 和 Windows,并提供了直观的 Web 界面,可让你轻松监控网络资源。经过专业配置后,它可以在服务器或网络设备下线或者故障时向你发出邮件警报。在本文中,我们说明了如何在 RHEL 8/CentOS 8 上安装和配置 Nagios Core。 + +![Install-Nagios-Core-RHEL8-CentOS8][2] + +### Nagios Core 的先决条件 + +在开始之前,请先检查并确保有以下各项: + + * RHEL 8/CentOS 8 环境 + * 能通过 SSH 访问该环境 + * 快速稳定的互联网连接 + +满足上述要求后,我们开始吧! + +### 步骤 1:安装 LAMP + +为了使 Nagios 能够按预期工作,你需要安装 LAMP 或其他 Web 软件,因为它们将在浏览器上运行。为此,请执行以下命令: + +``` +# dnf install httpd mariadb-server php-mysqlnd php-fpm +``` + +![Install-LAMP-stack-CentOS8][3] + +你需要确保 Apache Web 服务器已启动并正在运行。为此,请使用以下命令启用并启动 Apache 服务器: + +``` +# systemctl start httpd +# systemctl enable httpd +``` + +![Start-enable-httpd-centos8][4] + +检查 Apache 服务器运行状态: + +``` +# systemctl status httpd +``` + +![Check-status-httpd-centos8][5] + +接下来,我们需要启用并启动 MariaDB 服务器,运行以下命令: + +``` +# systemctl start mariadb +# systemctl enable mariadb +``` + +![Start-enable-MariaDB-CentOS8][6] + +要检查 MariaDB 状态,请运行: + +``` +# systemctl status mariadb +``` + +![Check-MariaDB-status-CentOS8][7] + +另外,你可能会考虑加强或保护服务器,使其不容易受到未经授权的访问。要保护服务器,请运行以下命令: + +``` +# mysql_secure_installation +``` + +确保为你的 MySQL 实例设置一个强密码。对于后续提示,请输入 “Y” 并按回车。 + +![Secure-MySQL-server-CentOS8][8] + +### 步骤 2:安装必需的软件包 + +除了安装 LAMP 外,还需要一些其他软件包来安装和正确配置 Nagios。因此,如下所示安装软件包: + +``` +# dnf install gcc glibc glibc-common wget gd gd-devel perl postfix +``` + +![Install-requisite-packages-CentOS8][9] + +### 步骤 3:创建 Nagios 用户帐户 + +接下来,我们需要为 Nagios 用户创建一个用户帐户。为此,请运行以下命令: + +``` +# adduser nagios +# passwd nagios +``` + +![Create-new-user-for-Nagios][10] + +现在,我们需要为 Nagios 创建一个组,并将 Nagios 用户添加到该组中。 + +``` +# groupadd nagiosxi +``` + +现在添加 Nagios 用户到组中: + +``` +# usermod -aG nagiosxi nagios +``` + +另外,将 Apache 用户添加到 Nagios 组: + +``` +# usermod -aG nagiosxi apache +``` + +![Add-Nagios-group-user][11] + +### 步骤 4:下载并安装 Nagios Core + +现在,我们可以继续安装 Nagios Core。Nagios 4.4.5 的最新稳定版本于 2019 年 8 月 19 日发布。但首先,请从它的官方网站下载 Nagios tarball 文件。 + +要下载 Nagios Core,请首进入 `/tmp` 目录: + +``` +# cd /tmp +``` + +接下来下载 tarball 文件: + +``` +# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz +``` + +![Download-Nagios-CentOS8][12] + +下载完 tarball 文件后,使用以下命令将其解压缩: + +``` +# tar -xvf nagios-4.4.5.tar.gz +``` + +接下来,进入未压缩的文件夹: + +``` +# cd nagios-4.4.5 +``` + +按此顺序运行以下命令: + +``` +# ./configure --with-command-group=nagcmd +# make all +# make install +# make install-init +# make install-daemoninit +# make install-config +# make install-commandmode +# make install-exfoliation +``` + +要配置 Apache,请运行以下命令: + +``` +# make install-webconf +``` + +### 步骤 5:配置 Apache Web 服务器身份验证 + +接下来,我们将为用户 `nagiosadmin` 设置身份验证。请注意不要更改该用户名,否则,可能会要求你进一步的配置,这可能很繁琐。 + +要设置身份验证,请运行以下命令: + +``` +# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin +``` + +![Configure-Apache-webserver-authentication-CentOS8][13] + +系统将提示你输入 `nagiosadmin` 用户的密码。输入并按要求确认密码。在本教程结束时,你将使用该用户登录 Nagios。 + +为使更改生效,请重新启动 Web 服务器: + +``` +# systemctl restart httpd +``` + +### 步骤 6:下载并安装 Nagios 插件 + +插件可以扩展 Nagios 服务器的功能。它们将帮助你监控各种服务、网络设备和应用。要下载插件的 tarball 文件,请运行以下命令: + +``` +# wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz +``` + +接下来,解压 tarball 文件并进入到未压缩的插件文件夹: + +``` +# tar -xvf nagios-plugins-2.2.1.tar.gz +# cd nagios-plugins-2.2.1 +``` + +要安装插件,请编译源代码,如下所示: + +``` +# ./configure --with-nagios-user=nagios --with-nagios-group=nagiosxi +# make +# make install +``` + +### 步骤 7:验证和启动 Nagios + +成功安装 Nagios 插件后,验证 Nagios 配置以确保一切良好,并且配置中没有错误: + +``` +# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg +``` + +![Verify-Nagios-settings-CentOS8][14] + +接下来,启动 Nagios 并验证其状态: + +``` +# systemctl start nagios +# systemctl status nagios +``` + +![Start-check-status-Nagios-CentOS8][15] + +如果系统中有防火墙,那么使用以下命令允许 ”80“ 端口: + +``` +# firewall-cmd --permanent --add-port=80/tcp# firewall-cmd --reload +``` + +### 步骤 8:通过 Web 浏览器访问 Nagios 面板 + +要访问 Nagios,请打开服务器的 IP 地址,如下所示: 。 + +这将出现一个弹出窗口,提示输入我们在步骤 5 创建的用户名和密码。输入凭据并点击“Sign In”。 + +![Access-Nagios-via-web-browser-CentOS8][16] + +这将引导你到 Nagios 面板,如下所示: + +![Nagios-dashboard-CentOS8][17] + +我们终于成功地在 CentOS 8 / RHEL 8 上安装和配置了 Nagios Core。欢迎你的反馈。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/install-nagios-core-rhel-8-centos-8/ + +作者:[James Kiarie][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/james/ +[b]: https://github.com/lujun9972 +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Install-Nagios-Core-RHEL8-CentOS8.jpg +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Install-LAMP-stack-CentOS8.jpg +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Start-enable-httpd-centos8.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Check-status-httpd-centos8.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Start-enable-MariaDB-CentOS8.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Check-MariaDB-status-CentOS8.jpg +[8]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Secure-MySQL-server-CentOS8.jpg +[9]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Install-requisite-packages-CentOS8.jpg +[10]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Create-new-user-for-Nagios.jpg +[11]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Add-Nagios-group-user.jpg +[12]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Download-Nagios-CentOS8.jpg +[13]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Configure-Apache-webserver-authentication-CentOS8.jpg +[14]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Verify-Nagios-settings-CentOS8.jpg +[15]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Start-check-status-Nagios-CentOS8.jpg +[16]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Access-Nagios-via-web-browser-CentOS8.jpg +[17]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Nagios-dashboard-CentOS8.jpg + diff --git a/published/20191028 SQLite is really easy to compile.md b/published/20191028 SQLite is really easy to compile.md new file mode 100644 index 0000000000..54afd887f0 --- /dev/null +++ b/published/20191028 SQLite is really easy to compile.md @@ -0,0 +1,114 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11536-1.html) +[#]: subject: (SQLite is really easy to compile) +[#]: via: (https://jvns.ca/blog/2019/10/28/sqlite-is-really-easy-to-compile/) +[#]: author: (Julia Evans https://jvns.ca/) + +SQLite 真的很容易编译 +====== + +![](https://img.linux.net.cn/data/attachment/album/201911/04/120656cedfznzenxxvmxq1.jpg) + +上周,我一直在做一个 SQL 网站(,一个 SQL 示例列表)。我使用 sqlite 运行网站上的所有查询,并且我想在其中一个例子([这个][1])中使用窗口函数。 + +但是我使用的是 Ubuntu 18.04 中的 sqlite 版本,它太旧了,不支持窗口函数。所以我需要升级 sqlite! + +事实证明,这个过程超麻烦(如通常一样),但是非常有趣!我想起了一些有关可执行文件和共享库如何工作的信息,结论令人满意。所以我想在这里写下来。 + +(剧透: 中解释了如何编译 SQLite,它只需花费 5 秒左右,这比我平时从源码编译的体验容易了许多。) + +### 尝试 1:从它的网站下载 SQLite 二进制文件 + +[SQLite 的下载页面][2]有一个用于 Linux 的 SQLite 命令行工具的二进制文件的链接。我下载了它,它可以在笔记本电脑上运行,我以为这就完成了。 + +但是后来我尝试在构建服务器(Netlify) 上运行它,得到了这个极其奇怪的错误消息:“File not found”。我进行了追踪,并确定 `execve` 返回错误代码 ENOENT,这意味着 “File not found”。这有点令人发狂,因为该文件确实存在,并且有正确的权限。 + +我搜索了这个问题(通过搜索 “execve enoen”),找到了[这个 stackoverflow 中的答案][3],它指出要运行二进制文件,你不仅需要二进制文件存在!你还需要它的**加载程序**才能存在。(加载程序的路径在二进制文件内部) + +要查看加载程序的路径,可以使用 `ldd`,如下所示: + +``` +$ ldd sqlite3 + linux-gate.so.1 (0xf7f9d000) + libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf7f70000) + libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf7e6e000) + libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0xf7e4f000) + libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7c73000) + /lib/ld-linux.so.2 +``` + +所以 `/lib/ld-linux.so.2` 是加载程序,而该文件在构建服务器上不存在,可能是因为 Xenial(Xenial 是 Ubuntu 16.04,本文应该使用的是 18.04 “Bionic Beaver”)安装程序不支持 32 位二进制文​​件(?),因此我需要尝试一些不同的东西。 + +### 尝试 2:安装 Debian sqlite3 软件包 + +好吧,我想我也许可以安装来自 [debian testing 的 sqlite 软件包][4]。尝试从另一个我不使用的 Debian 版本安装软件包并不是一个好主意,但是出于某种原因,我还是决定尝试一下。 + +这次毫不意外地破坏了我计算机上的 sqlite(这也破坏了 git),但我设法通过 `sudo dpkg --purge --force-all libsqlite3-0` 恢复了,并使所有依赖于 sqlite 的软件再次工作。 + +### 尝试 3:提取 Debian sqlite3 软件包 + +我还尝试仅从 Debian sqlite 软件包中提取 sqlite3 二进制文件并运行它。毫不意外,这也行不通,但这个更容易理解:我有旧版本的 libreadline(`.so.7`),但它需要 `.so.8`。 + +``` +$ ./usr/bin/sqlite3 +./usr/bin/sqlite3: error while loading shared libraries: libreadline.so.8: cannot open shared object file: No such file or directory +``` + +### 尝试 4:从源代码进行编译 + +我花费这么多时间尝试下载 sqlite 二进制的原因是我认为从源代码编译 sqlite 既烦人又耗时。但是显然,下载随便一个 sqlite 二进制文件根本不适合我,因此我最终决定尝试自己编译它。 + +这有指导:[如何编译 SQLite][5]。它是宇宙中最简单的东西。通常,编译的感觉是类似这样的: + + * 运行 `./configure` + * 意识到我缺少依赖 + * 再次运行 `./configure` + * 运行 `make` + * 编译失败,因为我安装了错误版本的依赖 + * 去做其他事,之后找到二进制文件 + +编译 SQLite 的方式如下: + + * [从下载页面下载整合的 tarball][2] + * 运行 `gcc shell.c sqlite3.c -lpthread -ldl` + * 完成!!! + +所有代码都在一个文件(`sqlite.c`)中,并且没有奇怪的依赖项!太奇妙了。 + +对我而言,我实际上并不需要线程支持或 readline 支持,因此我用编译页面上的说明来创建了一个非常简单的二进制文件,它仅使用了 libc 而没有其他共享库。 + +``` +$ ldd sqlite3 + linux-vdso.so.1 (0x00007ffe8e7e9000) + libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbea4988000) + /lib64/ld-linux-x86-64.so.2 (0x00007fbea4d79000) +``` + +### 这很好,因为它使体验 sqlite 变得容易 + +我认为 SQLite 的构建过程如此简单很酷,因为过去我很乐于[编辑 sqlite 的源码][6]来了解其 B 树的实现方式。 + +鉴于我对 SQLite 的了解,这并不令人感到意外(它在受限环境/嵌入式中确实可以很好地工作,因此可以以一种非常简单/最小的方式进行编译是有意义的)。 但这真是太好了! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/10/28/sqlite-is-really-easy-to-compile/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://sql-steps.wizardzines.com/lag.html +[2]: https://www.sqlite.org/download.html +[3]: https://stackoverflow.com/questions/5234088/execve-file-not-found-when-stracing-the-very-same-file +[4]: https://packages.debian.org/bullseye/amd64/sqlite3/download +[5]: https://www.sqlite.org/howtocompile.html +[6]: https://jvns.ca/blog/2014/10/02/how-does-sqlite-work-part-2-btrees/ diff --git a/published/20191029 Collapse OS - An OS Created to Run After the World Ends.md b/published/20191029 Collapse OS - An OS Created to Run After the World Ends.md new file mode 100644 index 0000000000..9044248779 --- /dev/null +++ b/published/20191029 Collapse OS - An OS Created to Run After the World Ends.md @@ -0,0 +1,100 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11525-1.html) +[#]: subject: (Collapse OS – An OS Created to Run After the World Ends) +[#]: via: (https://itsfoss.com/collapse-os/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +Collapse OS:为世界末日创建的操作系统 +====== + +当大多数人考虑为末日后的世界做准备时,想到的第一件事就是准备食物和其他生活必需品。最近,有一个程序员觉得,在社会崩溃之后,创建一个多功能的、且可生存的操作系统同样重要。我们今天将尽我们所能地来了解一下它。 + +### Collapse OS:当文明被掩埋在垃圾中 + +![][1] + +这里说的操作系统称为 [Collapse OS(崩溃操作系统)][2]。根据该官方网站的说法,Collapse OS 是 “z80 内核以及一系列程序、工具和文档的集合”。 它可以让你: + +* 可在最小的和临时拼凑的机器上运行。 +* 通过临时拼凑的方式(串行、键盘、显示)进行接口。 +* 可编辑文本文件。 +* 编译适用于各种 MCU 和 CPU 的汇编源代码文件。 +* 从各种存储设备读取和写入。 +* 自我复制。 + +其创造者 [Virgil Dupras][3] 之所以开始这个项目,是因为[他认为][4]“我们的全球供应链在我们到达 2030 年之前就会崩溃”。他是根据巴勃罗·塞维尼Pablo Servigne的作品得出了这一结论的。他似乎也觉得并非所有人都会认可[他的观点][4],“话虽如此,我认为不相信到 2030 年可能会发生崩溃也是可以理解的,所以请不要为我的信念而感到受到了冲击。” + +该项目的总体目标是迅速让瓦解崩溃后的文明重新回到计算机时代。电子产品的生产取决于非常复杂的供应链。一旦供应链崩溃,人类将回到一个技术水平较低的时代。要恢复我们以前的技术水平,将需要数十年的时间。Dupras 希望通过创建一个生态系统来跨越几个步骤,该生态系统将与从各种来源搜寻到的更简单的芯片一起工作。 + +### z80 是什么? + +最初的 Collapse OS 内核是为 [z80 芯片][5]编写的。作为复古计算机历史的爱好者,我对 [Zilog][6] 和 z80 芯片很熟悉。在 1970 年代后期,Zilog 公司推出了 z80,以和 [Intel 的 8080][7] CPU 竞争。z80 被用于许多早期的个人计算机中,例如 [Sinclair ZX Spectrum][8] 和 [Tandy TRS-80][9]。这些系统中的大多数使用了 [CP/M 操作系统] [10],这是当时最流行的操作系统。(有趣的是,Dupras 最初希望使用[一个开源版本的 CP/M][11],但最终决定[从头开始][12]。) + +在 1981 年 [IBM PC][13] 发布之后,z80 和 CP/M 的普及率开始下降。Zilog 确实发布了其它几种微处理器(Z8000 和 Z80000),但并没有获得成功。该公司将重点转移到了微控制器上。今天,更新后的 z80 后代产品可以在图形计算器、嵌入式设备和消费电子产品中找到。 + +Dupras 在 [Reddit][14] 上说,他为 z80 编写了 Collapse OS,因为“它已经投入生产很长时间了,并且因为它被用于许多机器上,所以拾荒者有很大的机会拿到它。” + +### 该项目的当前状态和未来发展 + +Collapse OS 的起步相当不错。有足够的内存和存储空间它就可以进行自我复制。它可以在 [RC2014 家用计算机][15]或世嘉 Master System / MegaDrive(Genesis)上运行。它可以读取 SD 卡。它有一个简单的文本编辑器。其内核由用粘合代码连接起来的模块组成。这是为了使系统具有灵活性和适应性。 + +还有一个详细的[路线图][16]列出了该项目的方向。列出的目标包括: + +* 支持其他 CPU,例如 8080 和 [6502][17]。 +* 支持临时拼凑的外围设备,例如 LCD 屏幕、电子墨水显示器和 [ACIA 设备][18]。 +* 支持更多的存储方式,例如软盘、CD、SPI RAM/ROM 和 AVR MCU。 +* 使它可以在其他 z80 机器上工作,例如 [TI-83+][19] 和 [TI-84+][20] 图形计算器和 TRS-80s。 + +如果你有兴趣帮助或只是想窥视一下这个项目,请访问其 [GitHub 页面][21]。 + +### 最后的思考 + +坦率地说,我认为 Collapse OS 与其说是一个有用的项目,倒不如说更像是一个有趣的爱好项目(对于那些喜欢构建操作系统的人来说)。当崩溃真的到来时,我认为 GitHub 也会宕机,那么 Collapse OS 将如何分发?我无法想像,得具有多少技能的人才能够从捡来的零件中创建出一个系统。到时候会有新一代的创客们,但大多数创客们会习惯于选择 Arduino 或树莓派来构建项目,而不是从头开始。 + +与 Dupras 相反,我最担心的是[电磁脉冲炸弹(EMP)][22] 的使用。这些东西会炸毁所有的电气系统,这意味着将没有任何构建系统的可能。如果没有发生这种事情,我想我们将能够找到过去 30 年制造的那么多的 x86 组件,以保持它们运行下去。 + +话虽如此,对于那些喜欢为奇奇怪怪的应用编写低级代码的人来说,Collapse OS 听起来是一个有趣且具有高度挑战性的项目。如果你是这样的人,去检出 [Collapse OS][2] 代码吧。 + +让我提个假设的问题:你选择的世界末日操作系统是什么?请在下面的评论中告诉我们。 + +如果你觉得这篇文章有趣,请花一点时间在社交媒体、Hacker News 或 [Reddit][23] 上分享。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/collapse-os/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/10/Collapse_OS.jpg?ssl=1 +[2]: https://collapseos.org/ +[3]: https://github.com/hsoft +[4]: https://collapseos.org/why.html +[5]: https://en.m.wikipedia.org/wiki/Z80 +[6]: https://en.wikipedia.org/wiki/Zilog +[7]: https://en.wikipedia.org/wiki/Intel_8080 +[8]: https://en.wikipedia.org/wiki/ZX_Spectrum +[9]: https://en.wikipedia.org/wiki/TRS-80 +[10]: https://en.wikipedia.org/wiki/CP/M +[11]: https://github.com/davidgiven/cpmish +[12]: https://github.com/hsoft/collapseos/issues/52 +[13]: https://en.wikipedia.org/wiki/IBM_Personal_Computer +[14]: https://old.reddit.com/r/collapse/comments/dejmvz/collapse_os_bootstrap_postcollapse_technology/f2w3sid/?st=k1gujoau&sh=1b344da9 +[15]: https://rc2014.co.uk/ +[16]: https://collapseos.org/roadmap.html +[17]: https://en.wikipedia.org/wiki/MOS_Technology_6502 +[18]: https://en.wikipedia.org/wiki/MOS_Technology_6551 +[19]: https://en.wikipedia.org/wiki/TI-83_series#TI-83_Plus +[20]: https://en.wikipedia.org/wiki/TI-84_Plus_series +[21]: https://github.com/hsoft/collapseos +[22]: https://en.wikipedia.org/wiki/Electromagnetic_pulse +[23]: https://reddit.com/r/linuxusersgroup diff --git a/published/20191029 Upgrading Fedora 30 to Fedora 31.md b/published/20191029 Upgrading Fedora 30 to Fedora 31.md new file mode 100644 index 0000000000..b6b1d4793c --- /dev/null +++ b/published/20191029 Upgrading Fedora 30 to Fedora 31.md @@ -0,0 +1,96 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11541-1.html) +[#]: subject: (Upgrading Fedora 30 to Fedora 31) +[#]: via: (https://fedoramagazine.org/upgrading-fedora-30-to-fedora-31/) +[#]: author: (Ben Cotton https://fedoramagazine.org/author/bcotton/) + +将 Fedora 30 升级到 Fedora 31 +====== + +![][1] + +Fedora 31 [日前发布了][2]。你也许想要升级系统来获得 Fedora 中的最新功能。Fedora 工作站有图形化的升级方式。另外,Fedora 提供了一种命令行方式来将 Fedora 30 升级到 Fedora 31。 + +### 将 Fedora 30 工作站升级到 Fedora 31 + +在该发布不久之后,就会有通知告诉你有可用升级。你可以点击通知打开 GNOME “软件”。或者在 GNOME Shell 选择“软件”。 + +在 GNOME 软件中选择*更新*,你应该会看到告诉你有 Fedora 31 更新的提示。 + +如果你在屏幕上看不到任何内容,请尝试使用左上方的重新加载按钮。在发布后,所有系统可能需要一段时间才能看到可用的升级。 + +选择*下载*以获取升级包。你可以继续工作,直到下载完成。然后使用 GNOME “软件”重启系统并应用升级。升级需要时间,因此你可能需要喝杯咖啡,稍后再返回系统。 + +### 使用命令行 + +如果你是从 Fedora 以前的版本升级的,那么你可能对 `dnf upgrade` 插件很熟悉。这是推荐且支持的从 Fedora 30 升级到 Fedora 31 的方法。使用此插件能让你轻松地升级到 Fedora 31。 + +#### 1、更新软件并备份系统 + +在开始升级之前,请确保你安装了 Fedora 30 的最新软件。如果你安装了模块化软件,这点尤为重要。`dnf` 和 GNOME “软件”的最新版本对某些模块化流的升级过程进行了改进。要更新软件,请使用 GNOME “软件” 或在终端中输入以下命令: + +``` +sudo dnf upgrade --refresh +``` + +此外,在继续操作之前,请确保备份系统。有关备份的帮助,请参阅 Fedora Magazine 上的[备份系列][3]。 + +#### 2、安装 DNF 插件 + +接下来,打开终端并输入以下命令安装插件: + +``` +sudo dnf install dnf-plugin-system-upgrade +``` + +#### 3、使用 DNF 开始更新 + +现在,你的系统是最新的,已经备份并且安装了 DNF 插件,你可以通过在终端中使用以下命令来开始升级: + +``` +sudo dnf system-upgrade download --releasever=31 +``` + +该命令将开始在本地下载计算机的所有升级。如果由于缺乏更新包、损坏的依赖项或已淘汰的软件包而在升级时遇到问题,请在输入上面的命令时添加 `‐-allowerasing` 标志。这将使 DNF 删除可能阻止系统升级的软件包。 + +#### 4、重启并升级 + +上面的命令下载更新完成后,你的系统就可以重启了。要将系统引导至升级过程,请在终端中输入以下命令: + +``` +sudo dnf system-upgrade reboot +``` + +此后,你的系统将重启。在许多版本之前,`fedup` 工具会在内核选择/引导页面上创建一个新选项。使用 `dnf-plugin-system-upgrade` 软件包,你的系统将重新引导到当前 Fedora 30 使用的内核。这很正常。在内核选择页面之后不久,你的系统会开始升级过程。 + +现在也许可以喝杯咖啡休息下!升级完成后,系统将重启,你将能够登录到新升级的 Fedora 31 系统。 + +![][4] + +### 解决升级问题 + +有时,升级系统时可能会出现意外问题。如果遇到任何问题,请访问 [DNF 系统升级文档][5],以获取有关故障排除的更多信息。 + +如果升级时遇到问题,并且系统上安装了第三方仓库,那么在升级时可能需要禁用这些仓库。对于 Fedora 不提供的仓库的支持,请联系仓库的提供者。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/upgrading-fedora-30-to-fedora-31/ + +作者:[Ben Cotton][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/bcotton/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/10/f30-f31-816x345.jpg +[2]: https://linux.cn/article-11522-1.html +[3]: https://fedoramagazine.org/taking-smart-backups-duplicity/ +[4]: https://cdn.fedoramagazine.org/wp-content/uploads/2016/06/Screenshot_f23-ws-upgrade-test_2016-06-10_110906-1024x768.png +[5]: https://docs.fedoraproject.org/en-US/quick-docs/dnf-system-upgrade/#Resolving_post-upgrade_issues diff --git a/published/20191029 What you probably didn-t know about sudo.md b/published/20191029 What you probably didn-t know about sudo.md new file mode 100644 index 0000000000..ce4502ba8a --- /dev/null +++ b/published/20191029 What you probably didn-t know about sudo.md @@ -0,0 +1,187 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11595-1.html) +[#]: subject: (What you probably didn’t know about sudo) +[#]: via: (https://opensource.com/article/19/10/know-about-sudo) +[#]: author: (Peter Czanik https://opensource.com/users/czanik) + +关于 sudo 你可能不知道的 +====== + +> 觉得你已经了解了 sudo 的所有知识了吗?再想想。 + +![](https://img.linux.net.cn/data/attachment/album/201911/20/091740ape5b74jppjj4q36.jpg) + +大家都知道 `sudo`,对吗?默认情况下,该工具已安装在大多数 Linux 系统上,并且可用于大多数 BSD 和商业 Unix 变体。不过,在与数百名 `sudo` 用户交谈之后,我得到的最常见的答案是 `sudo` 是一个使生活复杂化的工具。 + +有 root 用户和 `su` 命令,那么为什么还要使用另一个工具呢?对于许多人来说,`sudo` 只是管理命令的前缀。只有极少数人提到,当你在同一个系统上有多个管理员时,可以使用 `sudo` 日志查看谁做了什么。 + +那么,`sudo` 是什么? 根据 [sudo 网站][2]: + +> “sudo 允许系统管理员通过授予某些用户以 root 用户或其他用户身份运行某些命令的能力,同时提供命令及其参数的审核记录,从而委派权限。” + +默认情况下,`sudo` 只有简单的配置,一条规则允许一个用户或一组用户执行几乎所有操作(在本文后面的配置文件中有更多信息): + +``` +%wheel ALL=(ALL) ALL +``` + +在此示例中,参数表示以下含义: + +* 第一个参数(`%wheel`)定义组的成员。 +* 第二个参数(`ALL`)定义组成员可以在其上运行命令的主机。 +* 第三个参数(`(ALL)`)定义了可以执行命令的用户名。 +* 最后一个参数(`ALL`)定义可以运行的应用程序。 + +因此,在此示例中,`wheel` 组的成员可以以所有主机上的所有用户身份运行所有应用程序。但即使是这个一切允许的规则也很有用,因为它会记录谁在计算机上做了什么。 + +### 别名 + +当然,它不仅可以让你和你最好的朋友管理一个共享机器,你还可以微调权限。你可以将以上配置中的项目替换为列表:用户列表、命令列表等。多数情况下,你可能会复制并粘贴配置中的一些列表。 + +在这种情况下,别名可以派上用场。在多个位置维护相同的列表容易出错。你可以定义一次别名,然后可以多次使用。因此,当你对一位管理员不再信任时,将其从别名中删除就行了。使用多个列表而不是别名,很容易忘记从具有较高特权的列表之一中删除用户。 + +### 为特定组的用户启用功能 + +`sudo` 命令带有大量默认设置。不过,在某些情况下,你想覆盖其中的一些情况,这时你可以在配置中使用 `Defaults` 语句。通常,对每个用户都强制使用这些默认值,但是你可以根据主机、用户名等将设置缩小到一部分用户。这里有个我那一代的系统管理员都喜欢玩的一个示例:“羞辱”。这些只不过是一些有人输入错误密码时的有趣信息: + +``` +czanik@linux-mewy:~> sudo ls +[sudo] password for root: +Hold it up to the light --- not a brain in sight! # 把灯举高点,脑仁太小看不到 +[sudo] password for root: +My pet ferret can type better than you! # 我的宠物貂也比你输入的好 +[sudo] password for root: +sudo: 3 incorrect password attempts +czanik@linux-mewy:~> +``` + +由于并非所有人都喜欢系统管理员的这种幽默,因此默认情况下会禁用这些羞辱信息。以下示例说明了如何仅对经验丰富的系统管理员(即 `wheel` 组的成员)启用此设置: + +``` +Defaults !insults +Defaults:%wheel insults +``` + +我想,感谢我将这些消息带回来的人用两只手也数不过来吧。 + +### 摘要验证 + +当然,`sudo` 还有更严肃的功能。其中之一是摘要验证。你可以在配置中包括应用程序的摘要: + +``` +peter ALL = sha244:11925141bb22866afdf257ce7790bd6275feda80b3b241c108b79c88 /usr/bin/passwd +``` + +在这种情况下,`sudo` 在运行应用程序之前检查应用程序摘要,并将其与配置中存储的摘要进行比较。如果不匹配,`sudo` 拒绝运行该应用程序。尽管很难在配置中维护此信息(没有用于此目的的自动化工具),但是这些摘要可以为你提供额外的保护层。 + +### 会话记录 + +会话记录也是 `sudo` 鲜为人知的功能。在演示之后,许多人离开我的演讲后就计划在其基础设施上实施它。为什么?因为使用会话记录,你不仅可以看到命令名称,还可以看到终端中发生的所有事情。你可以看到你的管理员在做什么,要不他们用 shell 访问了机器而日志仅会显示启动了 `bash`。 + +当前有一个限制。记录存储在本地,因此具有足够的权限的话,用户可以删除他们的痕迹。所以请继续关注即将推出的功能。 + +### 插件 + +从 1.8 版开始,`sudo` 更改为基于插件的模块化体系结构。通过将大多数功能实现为插件,你可以编写自己的功能轻松地替换或扩展 `sudo` 的功能。已经有了 `sudo` 上的开源和商业插件。 + +在我的演讲中,我演示了 `sudo_pair` 插件,该插件可在 [GitHub][3] 上获得。这个插件是用 Rust 开发的,这意味着它不是那么容易编译,甚至更难以分发其编译结果。另一方面,该插件提供了有趣的功能,需要第二个管理员通过 `sudo` 批准(或拒绝)运行命令。不仅如此,如果有可疑活动,可以在屏幕上跟踪会话并终止会话。 + +在最近的 All Things Open 会议上的一次演示中,我做了一个臭名昭著的演示: + +``` +czanik@linux-mewy:~> sudo  rm -fr / +``` + +看着屏幕上显示的命令。每个人都屏住呼吸,想看看我的笔记本电脑是否被毁了,然而它逃过一劫。 + +### 日志 + +正如我在开始时提到的,日志记录和警报是 `sudo` 的重要组成部分。如果你不会定期检查 `sudo` 日志,那么日志在使用 `sudo` 中并没有太多价值。该工具通过电子邮件提醒配置中指定的事件,并将所有事件记录到 syslog 中。可以打开调试日志用于调试规则或报告错误。 + +### 警报 + +电子邮件警报现在有点过时了,但是如果你使用 syslog-ng 来收集日志消息,则会自动解析 `sudo` 日志消息。你可以轻松创建自定义警报并将其发送到各种各样的目的地,包括 Slack、Telegram、Splunk 或 Elasticsearch。你可以从[我在 syslong-ng.com 上的博客][4]中了解有关此功能的更多信息。 + +### 配置 + +我们谈论了很多 `sudo` 功能,甚至还看到了几行配置。现在,让我们仔细看看 `sudo` 的配置方式。配置本身可以在 `/etc/sudoers` 中获得,这是一个简单的文本文件。不过,不建议直接编辑此文件。相反,请使用 `visudo`,因为此工具还会执行语法检查。如果你不喜欢 `vi`,则可以通过将 `EDITOR` 环境变量指向你的首选编辑器来更改要使用的编辑器。 + +在开始编辑 `sudo` 配置之前,请确保你知道 root 密码。(是的,即使在默认情况下 root 用户没有密码的 Ubuntu 上也是如此。)虽然 `visudo` 会检查语法,但创建语法正确而将你锁定在系统之外的配置也很容易。 + +如果在紧急情况下,而你手头有 root 密码,你也可以直接编辑配置。当涉及到 `sudoers` 文件时,有一件重要的事情要记住:从上到下读取该文件,以最后的设置为准。这个事实对你来说意味着你应该从通用设置开始,并在末尾放置例外情况,否则,通用设置会覆盖例外情况。 + +你可以在下面看到一个基于 CentOS 的简单 `sudoers` 文件,并添加我们之前讨论的几行: + +``` +Defaults !visiblepw +Defaults always_set_home +Defaults match_group_by_gid +Defaults always_query_group_plugin +Defaults env_reset +Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS" +Defaults env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE" +Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin +root ALL=(ALL) ALL +%wheel ALL=(ALL) ALL +Defaults:%wheel insults +Defaults !insults +Defaults log_output +``` + +该文件从更改多个默认值开始。然后是通常的默认规则:`root` 用户和 `wheel` 组的成员对计算机具有完全权限。接下来,我们对 `wheel` 组启用“羞辱”,但对其他所有人禁用它们。最后一行启用会话记录。 + +上面的配置在语法上是正确的,但是你可以发现逻辑错误吗?是的,有一个:后一个通用设置覆盖了先前的更具体设置,让所有人均禁用了“羞辱”。一旦交换了这两行的位置,设置就会按预期进行:`wheel` 组的成员会收到有趣的消息,但其他用户则不会收到。 + +### 配置管理 + +一旦必须在多台机器上维护 `sudoers` 文件,你很可能希望集中管理配置。这里主要有两种可能的开源方法。两者都有其优点和缺点。 + +你可以使用也用来配置其余基础设施的配置管理应用程序之一:Red Hat Ansible、Puppet 和 Chef 都具有用于配置 `sudo` 的模块。这种方法的问题在于更新配置远非实时。同样,用户仍然可以在本地编辑 `sudoers` 文件并更改设置。 + +`sudo` 工具也可以将其配置存储在 LDAP 中。在这种情况下,配置更改是实时的,用户不能弄乱`sudoers` 文件。另一方面,该方法也有局限性。例如,当 LDAP 服务器不可用时,你不能使用别名或使用 `sudo`。 + +### 新功能 + +新版本的 `sudo` 即将推出。1.9 版将包含许多有趣的新功能。以下是最重要的计划功能: + +* 记录服务可集中收集会话记录,与本地存储相比,它具有许多优点: + * 在一个地方搜索更方便。 + * 即使发送记录的机器关闭,也可以进行记录。 + * 记录不能被想要删除其痕迹的人删除。 +* audit 插件没有向 `sudoers` 添加新功能,而是为插件提供了 API,以方便地访问任何类型的 `sudo` 日志。这个插件允许使用插件从 `sudo` 事件创建自定义日志。 +* approval 插件无需使用第三方插件即可启用会话批准。 +* 以及我个人最喜欢的:插件的 Python 支持,这使你可以轻松地使用 Python 代码扩展 `sudo`,而不是使用 C 语言进行原生编码。 +   +### 总结 + +希望本文能向你证明 `sudo` 不仅仅是一个简单的命令前缀。有无数种可能性可以微调系统上的权限。你不仅可以微调权限,还可以通过检查摘要来提高安全性。会话记录使你能够检查系统上正在发生的事情。你也可以使用插件扩展 `sudo` 的功能,或者使用已有的插件或编写自己的插件。最后,从即将发布的功能列表中你可以看到,即使 `sudo` 已有数十年的历史,它也是一个不断发展的有生命力的项目。 + +如果你想了解有关 `sudo` 的更多信息,请参考以下资源: + +* [sudo 网站][5] +* [sudo 博客][6] +* [在 Twitter 上关注我们][7] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/know-about-sudo + +作者:[Peter Czanik][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/czanik +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/command_line_prompt.png?itok=wbGiJ_yg (Command line prompt) +[2]: https://www.sudo.ws +[3]: https://github.com/square/sudo_pair/ +[4]: https://www.syslog-ng.com/community/b/blog/posts/alerting-on-sudo-events-using-syslog-ng +[5]: https://www.sudo.ws/ +[6]: https://blog.sudo.ws/ +[7]: https://twitter.com/sudoproject diff --git a/published/20191030 Getting started with awk, a powerful text-parsing tool.md b/published/20191030 Getting started with awk, a powerful text-parsing tool.md new file mode 100644 index 0000000000..14571dd892 --- /dev/null +++ b/published/20191030 Getting started with awk, a powerful text-parsing tool.md @@ -0,0 +1,158 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11543-1.html) +[#]: subject: (Getting started with awk, a powerful text-parsing tool) +[#]: via: (https://opensource.com/article/19/10/intro-awk) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +awk 入门 —— 强大的文本分析工具 +====== + +> 让我们开始使用它。 + +![](https://img.linux.net.cn/data/attachment/album/201911/06/114421e006e9mbh0xxe8bb.jpg) + +`awk` 是用于 Unix 和类 Unix 系统的强大文本解析工具,但是由于它有可编程函数,因此你可以用它来执行常规解析任务,因此它也被视为一种编程语言。你可能不会使用 `awk` 开发下一个 GUI 应用,并且它可能不会代替你的默认脚本语言,但是它是用于特定任务的强大程序。 + +这些任务或许是惊人的多样化。了解 `awk` 可以解决你的哪些问题的最好方法是学习 `awk`。你会惊讶于 `awk` 如何帮助你完成更多工作,却花费更少的精力。 + +`awk` 的基本语法是: + +``` +awk [options] 'pattern {action}' file +``` + +首先,创建此示例文件并将其保存为 `colours.txt`。 + +``` +name       color  amount +apple      red    4 +banana     yellow 6 +strawberry red    3 +grape      purple 10 +apple      green  8 +plum       purple 2 +kiwi       brown  4 +potato     brown  9 +pineapple  yellow 5 +``` + +数据被一个或多个空格分隔为列。以某种方式组织要分析的数据是很常见的。它不一定总是由空格分隔的列,甚至可以不是逗号或分号,但尤其是在日志文件或数据转储中,通常有一个可预测的格式。你可以使用数据格式来帮助 `awk` 提取和处理你关注的数据。 + +### 打印列 + +在 `awk` 中,`print` 函数显示你指定的内容。你可以使用许多预定义的变量,但是最常见的是文本文件中以整数命名的列。试试看: + +``` +$ awk '{print $2;}' colours.txt +color +red +yellow +red +purple +green +purple +brown +brown +yellow +``` + +在这里,`awk` 显示第二列,用 `$2` 表示。这是相对直观的,因此你可能会猜测 `print $1` 显示第一列,而 `print $3` 显示第三列,依此类推。 + +要显示*全部*列,请使用 `$0`。 + +美元符号(`$`)后的数字是*表达式*,因此 `$2` 和 `$(1+1)` 是同一意思。 + +### 有条件地选择列 + +你使用的示例文件非常结构化。它有一行充当标题,并且各列直接相互关联。通过定义*条件*,你可以限定 `awk` 在找到此数据时返回的内容。例如,要查看第二列中与 `yellow` 匹配的项并打印第一列的内容: + +``` +awk '$2=="yellow"{print $1}' file1.txt +banana +pineapple +``` + +正则表达式也可以工作。此表达式近似匹配 `$2` 中以 `p` 开头跟上任意数量(一个或多个)字符后继续跟上 `p` 的值: + +``` +$ awk '$2 ~ /p.+p/ {print $0}' colours.txt +grape   purple  10 +plum    purple  2 +``` + +数字能被 `awk` 自然解释。例如,要打印第三列包含大于 5 的整数的行: + +``` +awk '$3>5 {print $1, $2}' colours.txt +name    color +banana  yellow +grape   purple +apple   green +potato  brown +``` + +### 字段分隔符 + +默认情况下,`awk` 使用空格作为字段分隔符。但是,并非所有文本文件都使用空格来定义字段。例如,用以下内容创建一个名为 `colours.csv` 的文件: + +``` +name,color,amount +apple,red,4 +banana,yellow,6 +strawberry,red,3 +grape,purple,10 +apple,green,8 +plum,purple,2 +kiwi,brown,4 +potato,brown,9 +pineapple,yellow,5 +``` + +只要你指定将哪个字符用作命令中的字段分隔符,`awk` 就能以完全相同的方式处理数据。使用 `--field-separator`(或简称为 `-F`)选项来定义分隔符: + +``` +$ awk -F"," '$2=="yellow" {print $1}' file1.csv +banana +pineapple +``` + +### 保存输出 + +使用输出重定向,你可以将结果写入文件。例如: + +``` +$ awk -F, '$3>5 {print $1, $2} colours.csv > output.txt +``` + +这将创建一个包含 `awk` 查询内容的文件。 + +你还可以将文件拆分为按列数据分组的多个文件。例如,如果要根据每行显示的颜色将 `colours.txt` 拆分为多个文件,你可以在 `awk` 中包含重定向语句来重定向*每条查询*: + +``` +$ awk '{print > $2".txt"}' colours.txt +``` + +这将生成名为 `yellow.txt`、`red.txt` 等文件。 + +在下一篇文章中,你将了解有关字段,记录和一些强大的 awk 变量的更多信息。 + +本文改编自社区技术播客 [Hacker Public Radio][2]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/intro-awk + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop-music-headphones.png?itok=EQZ2WKzy (Woman programming) +[2]: http://hackerpublicradio.org/eps.php?id=2114 diff --git a/sources/tech/20191030 How to Find Out Top Memory Consuming Processes in Linux.md b/published/20191030 How to Find Out Top Memory Consuming Processes in Linux.md similarity index 73% rename from sources/tech/20191030 How to Find Out Top Memory Consuming Processes in Linux.md rename to published/20191030 How to Find Out Top Memory Consuming Processes in Linux.md index 9e30fad132..2268cb8f17 100644 --- a/sources/tech/20191030 How to Find Out Top Memory Consuming Processes in Linux.md +++ b/published/20191030 How to Find Out Top Memory Consuming Processes in Linux.md @@ -1,40 +1,28 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (lnrCoder) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11542-1.html) [#]: subject: (How to Find Out Top Memory Consuming Processes in Linux) [#]: via: (https://www.2daygeek.com/linux-find-top-memory-consuming-processes/) [#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) -How to Find Out Top Memory Consuming Processes in Linux +如何在 Linux 中找出内存消耗最大的进程 ====== -You may have seen your system consumes too much of memory many times. +![](https://img.linux.net.cn/data/attachment/album/201911/06/110149r81efjx12afjat7f.jpg) -If that’s the case, what would be the best thing you can do to identify processes that consume too much memory on a Linux machine. +很多次,你可能遇见过系统消耗了过多的内存。如果是这种情况,那么最好的办法是识别出 Linux 机器上消耗过多内存的进程。我相信,你可能已经运行了下文中的命令以进行检查。如果没有,那你尝试过哪些其他的命令?我希望你可以在评论中更新这篇文章,它可能会帮助其他用户。 -I believe, you may have run one of the below commands to check it out. +使用 [top 命令][1] 和 [ps 命令][2] 可以轻松的识别这种情况。我过去经常同时使用这两个命令,两个命令得到的结果是相同的。所以我建议你从中选择一个喜欢的使用就可以。 -If not, what is the other commands you tried? +### 1) 如何使用 ps 命令在 Linux 中查找内存消耗最大的进程 -I would request you to update it in the comment section, it may help other users. +`ps` 命令用于报告当前进程的快照。`ps` 命令的意思是“进程状态”。这是一个标准的 Linux 应用程序,用于查找有关在 Linux 系统上运行进程的信息。 -This can be easily identified using the **[top command][1]** and the **[ps command][2]**. +它用于列出当前正在运行的进程及其进程 ID(PID)、进程所有者名称、进程优先级(PR)以及正在运行的命令的绝对路径等。 -I used to check both commands simultaneously, and both were given the same result. - -So i suggest you to use one of the command that you like. - -### 1) How to Find Top Memory Consuming Process in Linux Using the ps Command - -The ps command is used to report a snapshot of the current processes. The ps command stands for process status. - -This is a standard Linux application that looks for information about running processes on a Linux system. - -It is used to list the currently running processes and their process ID (PID), process owner name, process priority (PR), and the absolute path of the running command, etc,. - -The below ps command format provides you more information about top memory consumption process. +下面的 `ps` 命令格式为你提供有关内存消耗最大进程的更多信息。 ``` # ps aux --sort -rss | head @@ -51,7 +39,7 @@ root 1135 0.0 0.9 86708 37572 ? S 05:37 0:20 cwpsrv: worker root 1133 0.0 0.9 86708 37544 ? S 05:37 0:05 cwpsrv: worker process ``` -Use the below ps command format to include only specific information about the process of memory consumption in the output. +使用以下 `ps` 命令格式可在输出中仅展示有关内存消耗过程的特定信息。 ``` # ps -eo pid,ppid,%mem,%cpu,cmd --sort=-%mem | head @@ -68,7 +56,7 @@ Use the below ps command format to include only specific information about the p 1135 3034 0.9 0.0 cwpsrv: worker process ``` -If you want to see only the command name instead of the absolute path of the command, use the ps command format below. +如果你只想查看命令名称而不是命令的绝对路径,请使用下面的 `ps` 命令格式。 ``` # ps -eo pid,ppid,%mem,%cpu,comm --sort=-%mem | head @@ -85,15 +73,11 @@ If you want to see only the command name instead of the absolute path of the com 1133 3034 0.9 0.0 cwpsrv ``` -### 2) How to Find Out Top Memory Consuming Process in Linux Using the top Command +### 2) 如何使用 top 命令在 Linux 中查找内存消耗最大的进程 -The Linux top command is the best and most well known command that everyone uses to monitor Linux system performance. +Linux 的 `top` 命令是用来监视 Linux 系统性能的最好和最知名的命令。它在交互界面上显示运行的系统进程的实时视图。但是,如果要查找内存消耗最大的进程,请 [在批处理模式下使用 top 命令][3]。 -It displays a real-time view of the system process running on the interactive interface. - -But if you want to find top memory consuming process then **[use the top command in the batch mode][3]**. - -You should properly **[understand the top command output][4]** to fix the performance issue in system. +你应该正确地 [了解 top 命令输出][4] 以解决系统中的性能问题。 ``` # top -c -b -o +%MEM | head -n 20 | tail -15 @@ -114,7 +98,7 @@ You should properly **[understand the top command output][4]** to fix the perfor 968 nobody 20 0 1356216 30544 2348 S 0.0 0.8 0:19.95 /usr/local/apache/bin/httpd -k start ``` -If you only want to see the command name instead of the absolute path of the command, use the below top command format. +如果你只想查看命令名称而不是命令的绝对路径,请使用下面的 `top` 命令格式。 ``` # top -b -o +%MEM | head -n 20 | tail -15 @@ -135,15 +119,11 @@ If you only want to see the command name instead of the absolute path of the com 968 nobody 20 0 1356216 30544 2348 S 0.0 0.8 0:19.95 httpd ``` -### 3) Bonus Tips: How to Find Out Top Memory Consuming Process in Linux Using the ps_mem Command +### 3) 奖励技巧:如何使用 ps_mem 命令在 Linux 中查找内存消耗最大的进程 -The **[ps_mem utility][5]** is used to display the core memory used per program (not per process). +[ps_mem 程序][5] 用于显示每个程序(而不是每个进程)使用的核心内存。该程序允许你检查每个程序使用了多少内存。它根据程序计算私有和共享内存的数量,并以最合适的方式返回已使用的总内存。 -This utility allows you to check how much memory is used per program. - -It calculates the amount of private and shared memory against a program and returns the total used memory in the most appropriate way. - -It uses the following logic to calculate RAM usage. Total RAM = sum (private RAM for program processes) + sum (shared RAM for program processes) +它使用以下逻辑来计算内存使用量。总内存使用量 = sum(用于程序进程的专用内存使用量) + sum(用于程序进程的共享内存使用量)。 ``` # ps_mem @@ -204,8 +184,8 @@ via: https://www.2daygeek.com/linux-find-top-memory-consuming-processes/ 作者:[Magesh Maruthamuthu][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[lnrCoder](https://github.com/lnrCoder) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -213,6 +193,6 @@ via: https://www.2daygeek.com/linux-find-top-memory-consuming-processes/ [b]: https://github.com/lujun9972 [1]: https://www.2daygeek.com/linux-top-command-linux-system-performance-monitoring-tool/ [2]: https://www.2daygeek.com/linux-ps-command-find-running-process-monitoring/ -[3]: https://www.2daygeek.com/linux-run-execute-top-command-in-batch-mode/ +[3]: https://linux.cn/article-11491-1.html [4]: https://www.2daygeek.com/understanding-linux-top-command-output-usage/ [5]: https://www.2daygeek.com/ps_mem-report-core-memory-usage-accurately-in-linux/ diff --git a/sources/tech/20191030 Viewing network bandwidth usage with bmon.md b/published/20191030 Viewing network bandwidth usage with bmon.md similarity index 67% rename from sources/tech/20191030 Viewing network bandwidth usage with bmon.md rename to published/20191030 Viewing network bandwidth usage with bmon.md index d8d2b2e1c9..53a16c45b8 100644 --- a/sources/tech/20191030 Viewing network bandwidth usage with bmon.md +++ b/published/20191030 Viewing network bandwidth usage with bmon.md @@ -1,39 +1,33 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11547-1.html) [#]: subject: (Viewing network bandwidth usage with bmon) [#]: via: (https://www.networkworld.com/article/3447936/viewing-network-bandwidth-usage-with-bmon.html) [#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) -Viewing network bandwidth usage with bmon +用 bmon 查看网络带宽使用情况 ====== -Introducing bmon, a monitoring and debugging tool that captures network statistics and makes them easily digestible. -Sandra Henry-Stocker -Bmon is a monitoring and debugging tool that runs in a terminal window and captures network statistics, offering options on how and how much data will be displayed and displayed in a form that is easy to understand. +> 介绍一下 bmon,这是一个监视和调试工具,可捕获网络统计信息并使它们易于理解。 -To check if **bmon** is installed on your system, use the **which** command: +![](https://img.linux.net.cn/data/attachment/album/201911/07/010237a8gb5oqddvl3bnd0.jpg) + +`bmon` 是一种监视和调试工具,可在终端窗口中捕获网络统计信息,并提供了如何以易于理解的形式显示以及显示多少数据的选项。 + +要检查系统上是否安装了 `bmon`,请使用 `which` 命令: ``` $ which bmon /usr/bin/bmon ``` -### Getting bmon +### 获取 bmon -On Debian systems, use **sudo apt-get install bmon** to install the tool. +在 Debian 系统上,使用 `sudo apt-get install bmon` 安装该工具。 -[][1] - -BrandPost Sponsored by HPE - -[Take the Intelligent Route with Consumption-Based Storage][1] - -Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. - -For Red Hat and related distributions, you might be able to install with **yum install bmon** or **sudo dnf install bmon**. Alternately, you may have to resort to a more complex install with commands like these that first set up the required **libconfuse** using the root account or sudo: +对于 Red Hat 和相关发行版,你可以使用 `yum install bmon` 或 `sudo dnf install bmon` 进行安装。或者,你可能必须使用更复杂的安装方式,例如使用以下命令,这些命令首先使用 root 帐户或 sudo 来设置所需的 `libconfuse`: ``` # wget https://github.com/martinh/libconfuse/releases/download/v3.2.2/confuse-3.2.2.zip @@ -48,15 +42,13 @@ For Red Hat and related distributions, you might be able to install with **yum i # sudo make install ``` -The first five lines will install **libconfuse** and the second five will grab and install **bmon** itself. +前面五行会安装 `libconfuse`,而后面五行会获取并安装 `bmon` 本身。 -### Using bmon +### 使用 bmon -The simplest way to start **bmon** is simply to type **bmon** on the command line. Depending on the size of the window you are using, you will be able to see and bring up a variety of data. +启动 `bmon` 的最简单方法是在命令行中键入 `bmon`。根据你正在使用的窗口的大小,你能够查看并显示各种数据。 -The top portion of your display will display stats on your network interfaces – the loopback (lo) and network-accessible (e.g., eth0). If you terminal window has few lines, this is all you may see, and it will look something like this: - -[RELATED: 11 pointless but awesome Linux terminal tricks][2] +显示区域的顶部将显示你的网络接口的统计信息:环回接口(lo)和可通过网络访问的接口(例如 eth0)。如果你的终端窗口只有区区几行高,下面这就是你可能会看到的所有内容,它将看起来像这样: ``` lo bmon 4.0 @@ -73,7 +65,7 @@ q Press i to enable additional information qq Wed Oct 23 14:36:27 2019 Press ? for help ``` -In this example, the network interface is enp0s25. Notice the helpful "Increase screen height" hint below the listed interfaces. Stretch your screen to add sufficient lines (no need to restart bmon) and you will see some graphs: +在此示例中,网络接口是 enp0s25。请注意列出的接口下方的有用的 “Increase screen height” 提示。拉伸屏幕以增加足够的行(无需重新启动 bmon),你将看到一些图形: ``` Interfaces x RX bps pps %x TX bps pps % @@ -100,7 +92,7 @@ qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqvqqqqqqqqqqqqqqqqqqqqqqqvqqqqqqqqqqqqqqqqqqqqqqqq 1 5 10 15 20 25 30 35 40 45 50 55 60 ``` -Notice, however, that the graphs are not showing values. This is because it is displaying the loopback **>lo** interface. Arrow your way down to the public network interface and you will see some traffic. +但是请注意,该图形未显示值。这是因为它正在显示环回 “>lo” 接口。按下箭头键指向公共网络接口,你将看到一些流量。 ``` Interfaces x RX bps pps %x TX bps pps % @@ -132,11 +124,11 @@ q Press i to enable additional information qq Wed Oct 23 16:42:06 2019 Press ? for help ``` -The change allows you to view a graph displaying network traffic. Note, however, that the default is to display bytes per second. To display bits per second instead, you would start the tool using **bmon -b** +通过更改接口,你可以查看显示了网络流量的图表。但是请注意,默认值是按每秒字节数显示的。要按每秒位数来显示,你可以使用 `bmon -b` 启动该工具。 -Detailed statistics on network traffic can be displayed if your window is large enough and you press **d**. An example of the stats you will see is displayed below. This display was split into left and right portions because of its width. +如果你的窗口足够大并按下 `d` 键,则可以显示有关网络流量的详细统计信息。你看到的统计信息示例如下所示。由于其宽度太宽,该显示分为左右两部分。 -##### left side: +左侧: ``` RX TX │ RX TX │ @@ -154,7 +146,7 @@ RX TX │ RX TX │ Window Error - 0 │ │ ``` -##### right side +右侧: ``` │ RX TX │ RX TX @@ -171,9 +163,9 @@ RX TX │ RX TX │ │ No Handler 0 - │ Over Error 0 - ``` -Additional information on the network interface will be displayed if you press **i** +如果按下 `i` 键,将显示网络接口上的其他信息。 -##### left side: +左侧: ``` MTU 1500 | Flags broadcast,multicast,up | @@ -181,7 +173,7 @@ Address 00:1d:09:77:9d:08 | Broadcast ff:ff:ff:ff:ff:ff | Family unspec | Alias | ``` -##### right side: +右侧: ``` | Operstate up | IfIndex 2 | @@ -189,19 +181,15 @@ Family unspec | Alias | | Qdisc fq_codel | ``` -A help menu will appear if you press **?** with brief descriptions of how to move around the screen, select data to be displayed and control the graphs. +如果你按下 `?` 键,将会出现一个帮助菜单,其中简要介绍了如何在屏幕上移动光标、选择要显示的数据以及控制图形如何显示。 -To quit **bmon**, you would type **q** and then **y** in response to the prompt to confirm your choice to exit. +要退出 `bmon`,输入 `q`,然后输入 `y` 以响应提示来确认退出。 -Some of the important things to note are that: +需要注意的一些重要事项是: - * **bmon** adjusts its display to the size of the terminal window - * some of the choices shown at the bottom of the display will only function if the window is large enough to accomodate the data - * the display is updated every second unless you slow this down using the **-R** (e.g., **bmon -R 5)** option - - - -Join the Network World communities on [Facebook][3] and [LinkedIn][4] to comment on topics that are top of mind. +* `bmon` 会将其显示调整为终端窗口的大小 +* 显示区域底部显示的某些选项仅在窗口足够大可以容纳数据时才起作用 +* 除非你使用 `-R`(例如 `bmon -R 5`)来减慢显示速度,否则每秒更新一次显示 -------------------------------------------------------------------------------- @@ -209,8 +197,8 @@ via: https://www.networkworld.com/article/3447936/viewing-network-bandwidth-usag 作者:[Sandra Henry-Stocker][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20191031 Why you don-t have to be afraid of Kubernetes.md b/published/20191031 Why you don-t have to be afraid of Kubernetes.md new file mode 100644 index 0000000000..1d2f7711ce --- /dev/null +++ b/published/20191031 Why you don-t have to be afraid of Kubernetes.md @@ -0,0 +1,101 @@ +[#]: collector: (lujun9972) +[#]: translator: (laingke) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11539-1.html) +[#]: subject: (Why you don't have to be afraid of Kubernetes) +[#]: via: (https://opensource.com/article/19/10/kubernetes-complex-business-problem) +[#]: author: (Scott McCarty https://opensource.com/users/fatherlinux) + +为什么你不必害怕 Kubernetes +====== + +> Kubernetes 绝对是满足复杂 web 应用程序需求的最简单、最容易的方法。 + +![Digital creative of a browser on the internet][1] + +在 90 年代末和 2000 年代初,在大型网站工作很有趣。我的经历让我想起了 American Greetings Interactive,在情人节那天,我们拥有了互联网上排名前 10 位之一的网站(以网络访问量衡量)。我们为 [AmericanGreetings.com][2]、[BlueMountain.com][3] 等公司提供了电子贺卡,并为 MSN 和 AOL 等合作伙伴提供了电子贺卡。该组织的老员工仍然深切地记得与 Hallmark 等其它电子贺卡网站进行大战的史诗般的故事。顺便说一句,我还为 Holly Hobbie、Care Bears 和 Strawberry Shortcake 运营过大型网站。 + +我记得那就像是昨天发生的一样,这是我们第一次遇到真正的问题。通常,我们的前门(路由器、防火墙和负载均衡器)有大约 200Mbps 的流量进入。但是,突然之间,Multi Router Traffic Grapher(MRTG)图示突然在几分钟内飙升至 2Gbps。我疯了似地东奔西跑。我了解了我们的整个技术堆栈,从路由器、交换机、防火墙和负载平衡器,到 Linux/Apache web 服务器,到我们的 Python 堆栈(FastCGI 的元版本),以及网络文件系统(NFS)服务器。我知道所有配置文件在哪里,我可以访问所有管理界面,并且我是一位经验丰富的,打过硬仗的系统管理员,具有多年解决复杂问题的经验。 + +但是,我无法弄清楚发生了什么…… + +当你在一千个 Linux 服务器上疯狂地键入命令时,五分钟的感觉就像是永恒。我知道站点可能会在任何时候崩溃,因为当它被划分成更小的集群时,压垮上千个节点的集群是那么的容易。 + +我迅速*跑到*老板的办公桌前,解释了情况。他几乎没有从电子邮件中抬起头来,这使我感到沮丧。他抬头看了看,笑了笑,说道:“是的,市场营销可能会开展广告活动。有时会发生这种情况。”他告诉我在应用程序中设置一个特殊标志,以减轻 Akamai 的访问量。我跑回我的办公桌,在上千台 web 服务器上设置了标志,几分钟后,站点恢复正常。灾难也就被避免了。 + +我可以再分享 50 个类似的故事,但你脑海中可能会有一点好奇:“这种运维方式将走向何方?” + +关键是,我们遇到了业务问题。当技术问题使你无法开展业务时,它们就变成了业务问题。换句话说,如果你的网站无法访问,你就不能处理客户交易。 + +那么,所有这些与 Kubernetes 有什么关系?一切!世界已经改变。早在 90 年代末和 00 年代初,只有大型网站才出现大型的、规模级web-scale的问题。现在,有了微服务和数字化转型,每个企业都面临着一个大型的、规模级的问题——可能是多个大型的、规模级的问题。 + +你的企业需要能够通过许多不同的人构建的许多不同的、通常是复杂的服务来管理复杂的规模级的网站。你的网站需要动态地处理流量,并且它们必须是安全的。这些属性需要在所有层(从基础结构到应用程序层)上由 API 驱动。 + +### 进入 Kubernetes + +Kubernetes 并不复杂;你的业务问题才复杂。当你想在生产环境中运行应用程序时,要满足性能(伸缩性、性能抖动等)和安全性要求,就需要最低程度的复杂性。诸如高可用性(HA)、容量要求(N+1、N+2、N+100)以及保证最终一致性的数据技术等就会成为必需。这些是每家进行数字化转型的公司的生产要求,而不仅仅是 Google、Facebook 和 Twitter 这样的大型网站。 + +在旧时代,我还在 American Greetings 任职时,每次我们加入一个新的服务,它看起来像这样:所有这些都是由网站运营团队来处理的,没有一个是通过订单系统转移给其他团队来处理的。这是在 DevOps 出现之前的 DevOps: + + 1. 配置 DNS(通常是内部服务层和面向公众的外部) + 2. 配置负载均衡器(通常是内部服务和面向公众的) + 3. 配置对文件的共享访问(大型 NFS 服务器、群集文件系统等) + 4. 配置集群软件(数据库、服务层等) + 5. 配置 web 服务器群集(可以是 10 或 50 个服务器) + +大多数配置是通过配置管理自动完成的,但是配置仍然很复杂,因为每个系统和服务都有不同的配置文件,而且格式完全不同。我们研究了像 [Augeas][4] 这样的工具来简化它,但是我们认为使用转换器来尝试和标准化一堆不同的配置文件是一种反模式。 + +如今,借助 Kubernetes,启动一项新服务本质上看起来如下: + + 1. 配置 Kubernetes YAML/JSON。 + 2. 提交给 Kubernetes API(`kubectl create -f service.yaml`)。 + +Kubernetes 大大简化了服务的启动和管理。服务所有者(无论是系统管理员、开发人员还是架构师)都可以创建 Kubernetes 格式的 YAML/JSON 文件。使用 Kubernetes,每个系统和每个用户都说相同的语言。所有用户都可以在同一 Git 存储库中提交这些文件,从而启用 GitOps。 + +而且,可以弃用和删除服务。从历史上看,删除 DNS 条目、负载平衡器条目和 Web 服务器的配置等是非常可怕的,因为你几乎肯定会破坏某些东西。使用 Kubernetes,所有内容都处于命名空间下,因此可以通过单个命令删除整个服务。尽管你仍然需要确保其它应用程序不使用它(微服务和函数即服务 [FaaS] 的缺点),但你可以更加确信:删除服务不会破坏基础架构环境。 + +### 构建、管理和使用 Kubernetes + +太多的人专注于构建和管理 Kubernetes 而不是使用它(详见 [Kubernetes 是一辆翻斗车][5])。 + +在单个节点上构建一个简单的 Kubernetes 环境并不比安装 LAMP 堆栈复杂得多,但是我们无休止地争论着构建与购买的问题。不是 Kubernetes 很难;它以高可用性大规模运行应用程序。建立一个复杂的、高可用性的 Kubernetes 集群很困难,因为要建立如此规模的任何集群都是很困难的。它需要规划和大量软件。建造一辆简单的翻斗车并不复杂,但是建造一辆可以运载 [10 吨垃圾并能以 200 迈的速度稳定行驶的卡车][6]则很复杂。 + +管理 Kubernetes 可能很复杂,因为管理大型的、规模级的集群可能很复杂。有时,管理此基础架构很有意义;而有时不是。由于 Kubernetes 是一个社区驱动的开源项目,它使行业能够以多种不同方式对其进行管理。供应商可以出售托管版本,而用户可以根据需要自行决定对其进行管理。(但是你应该质疑是否确实需要。) + +使用 Kubernetes 是迄今为止运行大规模网站的最简单方法。Kubernetes 正在普及运行一组大型、复杂的 Web 服务的能力——就像当年 Linux 在 Web 1.0 中所做的那样。 + +由于时间和金钱是一个零和游戏,因此我建议将重点放在使用 Kubernetes 上。将你的时间和金钱花费在[掌握 Kubernetes 原语][7]或处理[活跃度和就绪性探针][8]的最佳方法上(表明大型、复杂的服务很难的另一个例子)。不要专注于构建和管理 Kubernetes。(在构建和管理上)许多供应商可以为你提供帮助。 + +### 结论 + +我记得对无数的问题进行了故障排除,比如我在这篇文章的开头所描述的问题——当时 Linux 内核中的 NFS、我们自产的 CFEngine、仅在某些 Web 服务器上出现的重定向问题等)。开发人员无法帮助我解决所有这些问题。实际上,除非开发人员具备高级系统管理员的技能,否则他们甚至不可能进入系统并作为第二双眼睛提供帮助。没有带有图形或“可观察性”的控制台——可观察性在我和其他系统管理员的大脑中。如今,有了 Kubernetes、Prometheus、Grafana 等,一切都改变了。 + +关键是: + + 1. 时代不一样了。现在,所有 Web 应用程序都是大型的分布式系统。就像 AmericanGreetings.com 过去一样复杂,现在每个网站都有扩展性和 HA 的要求。 + 2. 运行大型的分布式系统是很困难的。绝对是。这是业务的需求,不是 Kubernetes 的问题。使用更简单的编排系统并不是解决方案。 + +Kubernetes 绝对是满足复杂 Web 应用程序需求的最简单,最容易的方法。这是我们生活的时代,而 Kubernetes 擅长于此。你可以讨论是否应该自己构建或管理 Kubernetes。有很多供应商可以帮助你构建和管理它,但是很难否认这是大规模运行复杂 Web 应用程序的最简单方法。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/kubernetes-complex-business-problem + +作者:[Scott McCarty][a] +选题:[lujun9972][b] +译者:[laingke](https://github.com/laingke) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/fatherlinux +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet) +[2]: http://AmericanGreetings.com +[3]: http://BlueMountain.com +[4]: http://augeas.net/ +[5]: https://linux.cn/article-11011-1.html +[6]: http://crunchtools.com/kubernetes-10-ton-dump-truck-handles-pretty-well-200-mph/ +[7]: https://linux.cn/article-11036-1.html +[8]: https://srcco.de/posts/kubernetes-liveness-probes-are-dangerous.html diff --git a/published/20191101 Keyboard Shortcuts to Speed Up Your Work in Linux.md b/published/20191101 Keyboard Shortcuts to Speed Up Your Work in Linux.md new file mode 100644 index 0000000000..e7b0bf62e0 --- /dev/null +++ b/published/20191101 Keyboard Shortcuts to Speed Up Your Work in Linux.md @@ -0,0 +1,114 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11549-1.html) +[#]: subject: (Keyboard Shortcuts to Speed Up Your Work in Linux) +[#]: via: (https://opensourceforu.com/2019/11/keyboard-shortcuts-to-speed-up-your-work-in-linux/) +[#]: author: (S Sathyanarayanan https://opensourceforu.com/author/s-sathyanarayanan/) + +在 Linux 中加速工作的键盘快捷键 +====== + +![Google Keyboard][2] + +> 操作鼠标、键盘和菜单会占用我们很多时间,这些可以使用键盘快捷键来节省时间。这不仅节省时间,还可以使用户更高效。 + +你是否意识到每次在打字时从键盘切换到鼠标需要多达两秒钟?如果一个人每天工作八小时,每分钟从键盘切换到鼠标一次,并且一年中大约有 240 个工作日,那么所浪费的时间(根据 Brainscape 的计算)为: +[每分钟浪费 2 秒] x [每天 480 分钟] x 每年 240 个工作日 = 每年浪费 64 小时 +这相当于损失了八个工作日,因此学习键盘快捷键将使生产率提高 3.3%()。 + +键盘快捷键提供了一种更快的方式来执行任务,不然就需要使用鼠标和/或菜单分多个步骤来完成。图 1 列出了 Ubuntu 18.04 Linux 和 Web 浏览器中一些最常用的快捷方式。我省略了非常有名的快捷方式,例如复制、粘贴等,以及不经常使用的快捷方式。读者可以参考在线资源以获得完整的快捷方式列表。请注意,Windows 键在 Linux 中被重命名为 Super 键。 + +### 常规快捷方式 + +下面列出了常规快捷方式。 + +![][4] + +### 打印屏幕和屏幕录像 + +以下快捷方式可用于打印屏幕或录制屏幕视频。 + +![][6] + +### 在应用之间切换 + +此处列出的快捷键可用于在应用之间切换。 + +![][8] + +### 平铺窗口 + +可以使用下面提供的快捷方式以不同方式将窗口平铺。 + +![][10] + +### 浏览器快捷方式 + +此处列出了浏览器最常用的快捷方式。大多数快捷键对于 Chrome/Firefox 浏览器是通用的。 + +**组合键** | **行为** +---|--- +`Ctrl + T` | 打开一个新标签。 +`Ctrl + Shift + T` | 打开最近关闭的标签。 +`Ctrl + D` | 添加一个新书签。 +`Ctrl + W` | 关闭浏览器标签。 +`Alt + D` | 将光标置于浏览器的地址栏中。 +`F5 或 Ctrl-R` | 刷新页面。 +`Ctrl + Shift + Del` | 清除私人数据和历史记录。 +`Ctrl + N` | 打开一个新窗口。 +`Home` | 滚动到页面顶部。 +`End` | 滚动到页面底部。 +`Ctrl + J` | 打开下载文件夹(在 Chrome 中) +`F11` | 全屏视图(切换效果) + +### 终端快捷方式 + +这是终端快捷方式的列表。 + +![][12] + +你还可以在 Ubuntu 中配置自己的自定义快捷方式,如下所示: + +* 在 Ubuntu Dash 中单击设置。 +* 在“设置”窗口的左侧菜单中选择“设备”选项卡。 +* 在设备菜单中选择键盘标签。 +* 右面板的底部有个 “+” 按钮。点击 “+” 号打开自定义快捷方式对话框并配置新的快捷方式。 + +学习本文提到的三个快捷方式可以节省大量时间,并使你的工作效率更高。 + +### 引用 + +Cohen, Andrew. How keyboard shortcuts could revive America’s economy; www.brainscape.com. [Online] Brainscape, 26 May 2017; + + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/keyboard-shortcuts-to-speed-up-your-work-in-linux/ + +作者:[S Sathyanarayanan][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensourceforu.com/author/s-sathyanarayanan/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2016/12/Google-Keyboard.jpg?resize=696%2C418&ssl=1 (Google Keyboard) +[2]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2016/12/Google-Keyboard.jpg?fit=750%2C450&ssl=1 +[3]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/1.png?resize=350%2C319&ssl=1 +[4]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/1.png?ssl=1 +[5]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/NW.png?resize=350%2C326&ssl=1 +[6]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/NW.png?ssl=1 +[7]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/2.png?resize=350%2C264&ssl=1 +[8]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/2.png?ssl=1 +[9]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/3.png?resize=350%2C186&ssl=1 +[10]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/3.png?ssl=1 +[11]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/7.png?resize=350%2C250&ssl=1 +[12]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/7.png?ssl=1 +[13]: http://www.brainscape.com +[14]: https://secure.gravatar.com/avatar/736684a2707f2ed7ae72675edf7bb3ee?s=100&r=g +[15]: https://opensourceforu.com/author/s-sathyanarayanan/ +[16]: mailto:sathyanarayanan.brn@gmail.com diff --git a/published/20191104 Cloning a MAC address to bypass a captive portal.md b/published/20191104 Cloning a MAC address to bypass a captive portal.md new file mode 100644 index 0000000000..3445d2f52b --- /dev/null +++ b/published/20191104 Cloning a MAC address to bypass a captive portal.md @@ -0,0 +1,57 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11564-1.html) +[#]: subject: (Cloning a MAC address to bypass a captive portal) +[#]: via: (https://fedoramagazine.org/cloning-a-mac-address-to-bypass-a-captive-portal/) +[#]: author: (Esteban Wilson https://fedoramagazine.org/author/swilson/) + +克隆 MAC 地址来绕过强制门户 +====== + +![][1] + +如果你曾经在家和办公室之外连接到 WiFi,那么通常会看到一个门户页面。它可能会要求你接受服务条款或其他协议才能访问。但是,当你无法通过这类门户进行连接时会发生什么?本文向你展示了如何在 Fedora 上使用 NetworkManager 在某些故障情况下让你仍然可以访问互联网。 + +### 强制门户如何工作 + +强制门户是新设备连接到网络时显示的网页。当用户首次访问互联网时,门户网站会捕获所有网页请求并将其重定向到单个门户页面。 + +然后,页面要求用户采取一些措施,通常是同意使用政策。用户同意后,他们可以向 RADIUS 或其他类型的身份验证系统进行身份验证。简而言之,强制门户根据设备的 MAC 地址和终端用户接受条款来注册和授权设备。(MAC 地址是附加到任何网络接口的[基于硬件的值][2],例如 WiFi 芯片或卡。) + +有时设备无法加载强制门户来进行身份验证和授权以使用 WiFI 接入。这种情况的例子包括移动设备和游戏机(Switch、Playstation 等)。当连接到互联网时,它们通常不会打开强制门户页面。连接到酒店或公共 WiFi 接入点时,你可能会看到这种情况。 + +不过,你可以在 Fedora 上使用 NetworkManager 来解决这些问题。Fedora 可以使你临时克隆要连接的设备的 MAC 地址,并代表该设备通过强制门户进行身份验证。你需要得到连接设备的 MAC 地址。通常,它被打印在设备上的某个地方并贴上标签。它是一个六字节的十六进制值,因此看起来类似 `4A:1A:4C:B0:38:1F`。通常,你也可以通过设备的内置菜单找到它。 + +### 使用 NetworkManager 克隆 + +首先,打开 `nm-connection-editor`,或通过“设置”打开 WiFi 设置。然后,你可以使用 NetworkManager 进行克隆: + +* 对于以太网:选择已连接的以太网连接。然后选择 “Ethernet” 选项卡。记录或复制当前的 MAC 地址。在 “克隆 MAC 地址Cloned MAC address” 字段中输入游戏机或其他设备的 MAC 地址。 +* 对于 WiFi:选择 WiFi 配置名。然后选择 “WiFi” 选项卡。记录或复制当前的 MAC 地址。在 “克隆 MAC 地址Cloned MAC address” 字段中输入游戏机或其他设备的 MAC 地址。 + +### 启动所需的设备 + +当 Fedora 系统与以太网或 WiFi 配置连接,克隆的 MAC 地址将用于请求 IP 地址,并加载强制门户。输入所需的凭据和/或选择用户协议。该 MAC 地址将获得授权。 + +现在,断开 WiF i或以太网配置连接,然后将 Fedora 系统的 MAC 地址更改回其原始值。然后启动游戏机或其他设备。该设备现在应该可以访问互联网了,因为它的网络接口已通过你的 Fedora 系统进行了授权。 + +不过,这不是 NetworkManager 全部能做的。例如,请参阅[随机化系统硬件地址][3],来获得更好的隐私保护。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/cloning-a-mac-address-to-bypass-a-captive-portal/ + +作者:[Esteban Wilson][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/swilson/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/10/clone-mac-nm-816x345.jpg +[2]: https://en.wikipedia.org/wiki/MAC_address +[3]: https://linux.cn/article-10028-1.html diff --git a/published/20191104 Fields, records, and variables in awk.md b/published/20191104 Fields, records, and variables in awk.md new file mode 100644 index 0000000000..259bde6f89 --- /dev/null +++ b/published/20191104 Fields, records, and variables in awk.md @@ -0,0 +1,234 @@ +[#]: collector: (lujun9972) +[#]: translator: (wenwensnow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11611-1.html) +[#]: subject: (Fields, records, and variables in awk) +[#]: via: (https://opensource.com/article/19/11/fields-records-variables-awk) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +awk 中的字段、记录和变量 +====== + +> 这个系列的第二篇,我们会学习字段,记录和一些非常有用的 Awk 变量。 + +![](https://img.linux.net.cn/data/attachment/album/201911/25/090333m34qx395vwtxx5vx.jpg) + +Awk 有好几个变种:最早的 `awk`,是 1977 年 AT&T 贝尔实验室所创。它还有一些重构版本,例如 `mawk`、`nawk`。在大多数 Linux 发行版中能见到的,是 GNU awk,也叫 `gawk`。在大多数 Linux 发行版中,`awk` 和 `gawk` 都是指向 GNU awk 的软链接。输入 `awk`,调用的是同一个命令。[GNU awk 用户手册][2]中,能看到 `awk` 和 `gawk` 的全部历史。 + +这一系列的[第一篇文章][3] 介绍了 `awk` 命令的基本格式: + +``` +$ awk [选项] '模式 {动作}' 输入文件 +``` + +`awk` 是一个命令,后面要接选项 (比如用 `-F` 来定义字段分隔符)。想让 `awk` 执行的部分需要写在两个单引号之间,至少在终端中需要这么做。在 `awk` 命令中,为了进一步强调你想要执行的部分,可以用 `-e` 选项来突出显示(但这不是必须的): + +``` +$ awk -F, -e '{print $2;}' colours.txt +yellow +blue +green +[...] +``` + +### 记录和字段 + +`awk` 将输入数据视为一系列*记录*,通常是按行分割的。换句话说,`awk` 将文本中的每一行视作一个记录。每一记录包含多个*字段*。一个字段由*字段分隔符*分隔开来,字段是记录的一部分。 + +默认情况下,`awk` 将各种空白符,如空格、制表符、换行符等视为分隔符。值得注意的是,在 `awk` 中,多个*空格*将被视为一个分隔符。所以下面这行文本有两个字段: + +``` +raspberry red +``` + +这行也是: + + +``` +tuxedo                  black +``` + +其他分隔符,在程序中不是这么处理的。假设字段分隔符是逗号,如下所示的记录,就有三个字段。其中一个字段可能会是 0 个字节(假设这一字段中不包含隐藏字符) + +``` +a,,b +``` + +### awk 程序 + +`awk` 命令的*程序部分*是由一系列规则组成的。通常来说,程序中每个规则占一行(尽管这不是必须的)。每个规则由一个模式,或一个或多个动作组成: + +``` +模式 { 动作 } +``` + +在一个规则中,你可以通过定义模式,来确定动作是否会在记录中执行。模式可以是简单的比较条件、正则表达式,甚至两者结合等等。 + +这个例子中,程序*只会*显示包含单词 “raspberry” 的记录: + +``` +$ awk '/raspberry/ { print $0 }' colours.txt +raspberry red 99 +``` + +如果没有文本符合模式,该动作将会应用到所有记录上。 + +并且,在一条规则只包含模式时,相当于对整个记录执行 `{ print }`,全部打印出来。 + +Awk 程序本质上是*数据驱动*的,命令执行结果取决于数据。所以,与其他编程语言中的程序相比,它还是有些区别的。 + +### NF 变量 + +每个字段都有指定变量,但针对字段和记录,也存在一些特殊变量。`NF` 变量,能存储 `awk` 在当前记录中找到的字段数量。其内容可在屏幕上显示,也可用于测试。下面例子中的数据,来自上篇文章[文本][3]: + +``` +$ awk '{ print $0 " (" NF ")" }' colours.txt +name       color  amount (3) +apple      red    4 (3) +banana     yellow 6 (3) +[...] +``` + +`awk` 的 `print` 函数会接受一系列参数(可以是变量或者字符串),并将它们拼接起来。这就是为什么在这个例子里,每行结尾处,`awk` 会以一个被括号括起来的整数表示字段数量。 + +### NR 变量 + +另外,除了统计每个记录中的字段数,`awk` 也统计输入记录数。记录数被存储在变量 `NR` 中,它的使用方法和其他变量没有任何区别。例如,为了在每一行开头显示行号: + +``` +$ awk '{ print NR ": " $0 }' colours.txt +1: name       color  amount +2: apple      red    4 +3: banana     yellow 6 +4: raspberry  red    3 +5: grape      purple 10 +[...] +``` + +注意,写这个命令时可以不在 `print` 后的多个参数间添加空格,尽管这样会降低可读性: + +``` +$ awk '{print NR": "$0}' colours.txt +``` + +### printf() 函数 + +为了让输出结果时格式更灵活,你可以使用 `awk` 的 `printf()` 函数。 它与 C、Lua、Bash 和其他语言中的 `printf` 相类似。它也接受以逗号分隔的*格式*参数。参数列表需要写在括号里。 + +``` +$ printf 格式, 项目1, 项目2, ... +``` + +格式这一参数(也叫*格式符*)定义了其他参数如何显示。这一功能是用*格式修饰符*实现的。`%s` 输出字符,`%d` 输出十进制数字。下面的 `printf` 语句,会在括号内显示字段数量: + +``` +$ awk 'printf "%s (%d)\n",$0,NF}' colours.txt +name       color  amount (3) +raspberry  red    4 (3) +banana     yellow 6 (3) +[...] +``` + +在这个例子里,`%s (%d)` 确定了每一行的输出格式,`$0,NF` 定义了插入 `%s` 和 `%d` 位置的数据。注意,和 `print` 函数不同,在没有明确指令时,输出不会转到下一行。出现转义字符 `\n` 时才会换行。 + +### Awk 脚本编程 + +这篇文章中出现的所有 `awk` 代码,都在 Bash 终端中执行过。面对更复杂的程序,将命令放在文件(*脚本*)中会更容易。`-f FILE` 选项(不要和 `-F` 弄混了,那个选项用于字段分隔符),可用于指明包含可执行程序的文件。 + +举个例子,下面是一个简单的 awk 脚本。创建一个名为 `example1.awk` 的文件,包含以下内容: + +``` +/^a/ {print "A: " $0} +/^b/ {print "B: " $0} +``` + +如果一个文件包含 `awk` 程序,那么在给文件命名时,最好写上 `.awk` 的扩展名。 这样命名不是强制的,但这么做,会给文件管理器、编辑器(和你)一个关于文件内容的很有用的提示。 + +执行这一脚本: + +``` +$ awk -f example1.awk colours.txt +A: raspberry  red    4 +B: banana     yellow 6 +A: apple      green  8 +``` + +一个包含 `awk` 命令的文件,在最开头一行加上释伴 `#!`,就能变成可执行脚本。创建一个名为 `example2.awk` 的文件,包含以下内容: + +``` +#!/usr/bin/awk -f +# +# 除了第一行,在其他行前显示行号 +# + +NR > 1 { + printf "%d: %s\n",NR,$0 +} +``` + +可以说,脚本中只有一行,大多数情况下没什么用。但在某些情况下,执行一个脚本,比记住,然后打一条命令要容易的多。一个脚本文件,也提供了一个记录命令具体作用的好机会。以 `#` 号开头的行是注释,`awk` 会忽略它们。 + +给文件可执行权限: + +``` +$ chmod u+x example2.awk +``` + +执行脚本: + +``` +$ ./example2.awk colours.txt +2: apple      red    4 +2: banana     yellow 6 +4: raspberry red    3 +5: grape      purple 10 +[...] +``` + +将 `awk` 命令放在脚本文件中,有一个好处就是,修改和格式化输出会更容易。在终端中,如果能用一行执行多条 `awk` 命令,那么输入多行,才能达到同样效果,就显得有些多余了。 + +### 试一试 + +你现在已经足够了解,`awk` 是如何执行指令的了。现在你应该能编写复杂的 `awk` 程序了。试着编写一个 awk 脚本,它需要: 至少包括一个条件模式,以及多个规则。如果你想使用除 `print` 和 `printf` 以外的函数,可以参考在线 [gawk 手册][4]。 + +下面这个例子是个很好的切入点: + +``` +#!/usr/bin/awk -f +# +# 显示所有记录 除了出现以下情况 +# 如果第一个记录 包含 “raspberry” +# 将 “red” 替换成 “pi” + +$1 == "raspberry" { +        gsub(/red/,"pi") +} + +{ print } +``` + +试着执行这个脚本,看看输出是什么。接下来就看你自己的了。 + +这一系列的下一篇文章,将会介绍更多,能在更复杂(更有用!) 脚本中使用的函数。 + +这篇文章改编自 [Hacker Public Radio][5] 系列,一个技术社区博客。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/fields-records-variables-awk + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wenwensnow](https://github.com/wenwensnow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_laptop_code_programming_mountain_view.jpg?itok=yx5buqkr (Man at laptop on a mountain) +[2]: https://www.gnu.org/software/gawk/manual/html_node/History.html#History +[3]: https://linux.cn/article-11543-1.html +[4]: https://www.gnu.org/software/gawk/manual/ +[5]: http://hackerpublicradio.org/eps.php?id=2129 diff --git a/published/20191104 How To Update a Fedora Linux System -Beginner-s Tutorial.md b/published/20191104 How To Update a Fedora Linux System -Beginner-s Tutorial.md new file mode 100644 index 0000000000..4992e41050 --- /dev/null +++ b/published/20191104 How To Update a Fedora Linux System -Beginner-s Tutorial.md @@ -0,0 +1,90 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11550-1.html) +[#]: subject: (How To Update a Fedora Linux System [Beginner’s Tutorial]) +[#]: via: (https://itsfoss.com/update-fedora/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +初级:如何更新 Fedora Linux 系统 +====== + +> 本快速教程介绍了更新 Fedora Linux 安装的多种方法。 + +前几天,我安装了[新发布的 Fedora 31][1]。老实说,这是我第一次使用[非 Ubuntu 发行版][2]。 + +安装 Fedora 之后,我做的第一件事就是尝试安装一些软件。我打开软件中心,发现该软件中心已“损坏”。 我无法从中安装任何应用程序。 + +我不确定我的系统出了什么问题。在团队内部讨论时,Abhishek 建议我先更新系统。我更新了,更新后一切恢复正常。更新 [Fedora][3] 系统后,软件中心也能正常工作了。 + +有时我们一直尝试解决我们所面临的问题,而忽略了对系统的更新。不管问题有多大或多小,为了避免它们,你都应该保持系统更新。 + +在本文中,我将向你展示更新 Fedora Linux 系统的多种方法。 + +* 使用软件中心更新 Fedora +* 使用命令行更新 Fedora +* 从系统设置更新 Fedora + +请记住,更新 Fedora 意味着安装安全补丁、更新内核和软件。如果要从 Fedora 的一个版本更新到另一个版本,这称为版本升级,你可以[在此处阅读有关 Fedora 版本升级过程的信息][7]。 + +### 从软件中心更新 Fedora + +![软件中心][8] + +你很可能会收到通知,通知你有一些系统更新需要查看,你应该在单击该通知时启动软件中心。 + +你所要做的就是 —— 点击“更新”,并验证 root 密码开始更新。 + +如果你没有收到更新的通知,则只需启动软件中心并转到“更新”选项卡即可。现在,你只需要继续更新。 + +### 使用终端更新 Fedora + +如果由于某种原因无法加载软件中心,则可以使用 `dnf` 软件包管理命令轻松地更新系统。 + +只需启动终端并输入以下命令即可开始更新(系统将提示你确认 root 密码): + +``` +sudo dnf upgrade +``` + +> **dnf 更新 vs dnf 升级 ** + +> 你会发现有两个可用的 dnf 命令:`dnf update` 和 `dnf upgrade`。这两个命令执行相同的工作,即安装 Fedora 提供的所有更新。那么,为什么要会有这两个呢,你应该使用哪一个?`dnf update` 基本上是 `dnf upgrade` 的别名。尽管 `dnf update` 可能仍然有效,但最好使用 `dnf upgrade`,因为这是真正的命令。 + +### 从系统设置中更新 Fedora + +![][9] + +如果其它方法都不行(或者由于某种原因已经进入“系统设置”),请导航至“设置”底部的“详细信息”选项。 + +如上图所示,该选项中显示操作系统和硬件的详细信息以及一个“检查更新”按钮。你只需要单击它并提供 root 密码即可继续安装可用的更新。 + +### 总结 + +如上所述,更新 Fedora 系统非常容易。有三种方法供你选择,因此无需担心。 + +如果你按上述说明操作时发现任何问题,请随时在下面的评论部分告诉我。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/update-fedora/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/fedora-31-release/ +[2]: https://itsfoss.com/non-ubuntu-beginner-linux/ +[3]: https://getfedora.org/ +[4]: tmp.Lqr0HBqAd9#software-center +[5]: tmp.Lqr0HBqAd9#command-line +[6]: tmp.Lqr0HBqAd9#system-settings +[7]: https://itsfoss.com/upgrade-fedora-version/ +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/software-center.png?ssl=1 +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/system-settings-fedora-1.png?ssl=1 diff --git a/published/20191106 Bash Script to Generate Patching Compliance Report on CentOS-RHEL Systems.md b/published/20191106 Bash Script to Generate Patching Compliance Report on CentOS-RHEL Systems.md new file mode 100644 index 0000000000..8631d45fd7 --- /dev/null +++ b/published/20191106 Bash Script to Generate Patching Compliance Report on CentOS-RHEL Systems.md @@ -0,0 +1,218 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11580-1.html) +[#]: subject: (Bash Script to Generate Patching Compliance Report on CentOS/RHEL Systems) +[#]: via: (https://www.2daygeek.com/bash-script-to-generate-patching-compliance-report-on-centos-rhel-systems/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +在 CentOS/RHEL 系统上生成补丁合规报告的 Bash 脚本 +====== + +![](https://img.linux.net.cn/data/attachment/album/201911/16/101428n1nsj74wifp4k1dz.jpg) + +如果你运行的是大型 Linux 环境,那么你可能已经将 Red Hat 与 Satellite 集成了。如果是的话,你不必担心补丁合规性报告,因为有一种方法可以从 Satellite 服务器导出它。 + +但是,如果你运行的是没有 Satellite 集成的小型 Red Hat 环境,或者它是 CentOS 系统,那么此脚本将帮助你创建该报告。 + +补丁合规性报告通常每月创建一次或三个月一次,具体取决于公司的需求。根据你的需要添加 cronjob 来自动执行此功能。 + +此 [bash 脚本][1] 通常适合于少于 50 个系统运行,但没有限制。 + +保持系统最新是 Linux 管理员的一项重要任务,它使你的计算机非常稳定和安全。 + +以下文章可以帮助你了解有关在红帽 (RHEL) 和 CentOS 系统上安装安全修补程序的更多详细信息。 + + * [如何在 CentOS 或 RHEL 系统上检查可用的安全更新?][2] + * [在 RHEL 和 CentOS 系统上安装安全更新的四种方法][3] + * [在 RHEL 和 CentOS 上检查或列出已安装的安全更新的两种方法][4] + +此教程中包含四个 [shell 脚本][5],请选择适合你的脚本。 + +### 方法 1:为 CentOS / RHEL 系统上的安全修补生成补丁合规性报告的 Bash 脚本 + +此脚本只会生成安全修补合规性报告。它会通过纯文本发送邮件。 + +``` +# vi /opt/scripts/small-scripts/sec-errata.sh + +#!/bin/sh +/tmp/sec-up.txt +SUBJECT="Patching Reports on "date"" +MESSAGE="/tmp/sec-up.txt" +TO="[email protected]" +echo "+---------------+-----------------------------+" >> $MESSAGE +echo "| Server_Name | Security Errata |" >> $MESSAGE +echo "+---------------+-----------------------------+" >> $MESSAGE +for server in `more /opt/scripts/server.txt` +do +sec=`ssh $server yum updateinfo summary | grep 'Security' | grep -v 'Important|Moderate' | tail -1 | awk '{print $1}'` +echo "$server $sec" >> $MESSAGE +done +echo "+---------------------------------------------+" >> $MESSAGE +mail -s "$SUBJECT" "$TO" < $MESSAGE +``` + +添加完上面的脚本后运行它。 + +``` +# sh /opt/scripts/small-scripts/sec-errata.sh +``` + +你会看到下面的输出。 + +``` +# cat /tmp/sec-up.txt + ++---------------+-------------------+ +| Server_Name | Security Errata | ++---------------+-------------------+ +server1 +server2 +server3 21 +server4 ++-----------------------------------+ +``` + +添加下面的 cronjob 来每个月得到一份补丁合规性报告。 + +``` +# crontab -e + +@monthly /bin/bash /opt/scripts/system-uptime-script-1.sh +``` + +### 方法 1a:为 CentOS / RHEL 系统上的安全修补生成补丁合规性报告的 Bash 脚本 + +脚本会为你生成安全修补合规性报告。它会通过 CSV 文件发送邮件。 + +``` +# vi /opt/scripts/small-scripts/sec-errata-1.sh + +#!/bin/sh +echo "Server Name, Security Errata" > /tmp/sec-up.csv +for server in `more /opt/scripts/server.txt` +do +sec=`ssh $server yum updateinfo summary | grep 'Security' | grep -v 'Important|Moderate' | tail -1 | awk '{print $1}'` +echo "$server, $sec" >> /tmp/sec-up.csv +done +echo "Patching Report for `date +"%B %Y"`" | mailx -s "Patching Report on `date`" -a /tmp/sec-up.csv [email protected] +rm /tmp/sec-up.csv +``` + +添加完上面的脚本后运行它。 + +``` +# sh /opt/scripts/small-scripts/sec-errata-1.sh +``` + +你会看到下面的输出。 + +![][6] + +### 方法 2:为 CentOS / RHEL 系统上的安全修补、bugfix、增强生成补丁合规性报告的 Bash 脚本 + +脚本会为你生成安全修补、bugfix、增强的补丁合规性报告。它会通过纯文本发送邮件。 + +``` +# vi /opt/scripts/small-scripts/sec-errata-bugfix-enhancement.sh + +#!/bin/sh +/tmp/sec-up.txt +SUBJECT="Patching Reports on "`date`"" +MESSAGE="/tmp/sec-up.txt" +TO="[email protected]" +echo "+---------------+-------------------+--------+---------------------+" >> $MESSAGE +echo "| Server_Name | Security Errata | Bugfix | Enhancement |" >> $MESSAGE +echo "+---------------+-------------------+--------+---------------------+" >> $MESSAGE +for server in `more /opt/scripts/server.txt` +do +sec=`ssh $server yum updateinfo summary | grep 'Security' | grep -v 'Important|Moderate' | tail -1 | awk '{print $1}'` +bug=`ssh $server yum updateinfo summary | grep 'Bugfix' | tail -1 | awk '{print $1}'` +enhance=`ssh $server yum updateinfo summary | grep 'Enhancement' | tail -1 | awk '{print $1}'` +echo "$server $sec $bug $enhance" >> $MESSAGE +done +echo "+------------------------------------------------------------------+" >> $MESSAGE +mail -s "$SUBJECT" "$TO" < $MESSAGE +``` + +添加完上面的脚本后运行它。 + +``` +# sh /opt/scripts/small-scripts/sec-errata-bugfix-enhancement.sh +``` + +你会看到下面的输出。 + +``` +# cat /tmp/sec-up.txt + ++---------------+-------------------+--------+---------------------+ +| Server_Name | Security Errata | Bugfix | Enhancement | ++---------------+-------------------+--------+---------------------+ +server01 16 +server02 5 16 +server03 21 266 20 +server04 16 ++------------------------------------------------------------------+ +``` + +添加下面的 cronjob 来每三个月得到补丁合规性报告。该脚本计划在一月、四月、七月、十月的 1 号运行。 + +``` +# crontab -e + +0 0 01 */3 * /bin/bash /opt/scripts/system-uptime-script-1.sh +``` + +### 方法 2a:为 CentOS / RHEL 系统上的安全修补、bugfix、增强生成补丁合规性报告的 Bash 脚本 + +脚本会为你生成安全修补、bugfix、增强的补丁合规性报告。它会通过 CSV 文件发送邮件。 + +``` +# vi /opt/scripts/small-scripts/sec-errata-bugfix-enhancement-1.sh + +#!/bin/sh +echo "Server Name, Security Errata,Bugfix,Enhancement" > /tmp/sec-up.csv +for server in `more /opt/scripts/server.txt` +do +sec=`ssh $server yum updateinfo summary | grep 'Security' | grep -v 'Important|Moderate' | tail -1 | awk '{print $1}'` +bug=`ssh $server yum updateinfo summary | grep 'Bugfix' | tail -1 | awk '{print $1}'` +enhance=`ssh $server yum updateinfo summary | grep 'Enhancement' | tail -1 | awk '{print $1}'` +echo "$server,$sec,$bug,$enhance" >> /tmp/sec-up.csv +done +echo "Patching Report for `date +"%B %Y"`" | mailx -s "Patching Report on `date`" -a /tmp/sec-up.csv [email protected] +rm /tmp/sec-up.csv +``` + +添加完上面的脚本后运行它。 + +``` +# sh /opt/scripts/small-scripts/sec-errata-bugfix-enhancement-1.sh +``` + +你会看到下面的输出。 + +![][7] + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/bash-script-to-generate-patching-compliance-report-on-centos-rhel-systems/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/category/bash-script/ +[2]: https://linux.cn/article-10938-1.html +[3]: https://www.2daygeek.com/install-security-updates-on-redhat-rhel-centos-system/ +[4]: https://linux.cn/article-10960-1.html +[5]: https://www.2daygeek.com/category/shell-script/ +[6]: https://www.2daygeek.com/wp-content/uploads/2019/11/bash-script-to-generate-patching-compliance-report-on-centos-rhel-systems-2.png +[7]: https://www.2daygeek.com/wp-content/uploads/2019/11/bash-script-to-generate-patching-compliance-report-on-centos-rhel-systems-3.png diff --git a/published/20191106 How to Schedule and Automate tasks in Linux using Cron Jobs.md b/published/20191106 How to Schedule and Automate tasks in Linux using Cron Jobs.md new file mode 100644 index 0000000000..93727092b0 --- /dev/null +++ b/published/20191106 How to Schedule and Automate tasks in Linux using Cron Jobs.md @@ -0,0 +1,290 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11571-1.html) +[#]: subject: (How to Schedule and Automate tasks in Linux using Cron Jobs) +[#]: via: (https://www.linuxtechi.com/schedule-automate-tasks-linux-cron-jobs/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +如何使用 cron 任务在 Linux 中计划和自动化任务 +====== + +有时,你可能需要定期或以预定的时间间隔执行任务。这些任务包括备份数据库、更新系统、执行定期重新引导等。这些任务称为 “cron 任务”。cron 任务用于“自动执行的任务”,它有助于简化重复的、有时是乏味的任务的执行。cron 是一个守护进程,可让你安排这些任务,然后按指定的时间间隔执行这些任务。在本教程中,你将学习如何使用 cron 来安排任务。 + +![Schedule -tasks-in-Linux-using cron][2] + +### crontab 文件 + +crontab 即 “cron table”,是一个简单的文本文件,其中包含指定任务执行时间间隔的规则和命令。 crontab 文件分为两类: + +1)系统范围的 crontab 文件 + +这些通常由需要 root 特权的 Linux 服务及关键应用程序使用。系统 crontab 文件位于 `/etc/crontab` 中,并且只能由 root 用户访问和编辑。通常用于配置系统范围的守护进程。`crontab` 文件的看起来类似如下所示: + +![etc-crontab-linux][3] + +2)用户创建的 crontab 文件 + +Linux 用户还可以在 `crontab` 命令的帮助下创建自己的 cron 任务。创建的 cron 任务将以创建它们的用户身份运行。 + +所有 cron 任务都存储在 `/var/spool/cron`(对于 RHEL 和 CentOS 发行版)和 `/var/spool/cron/crontabs`(对于 Debian 和 Ubuntu 发行版)中,cron 任务使用创建该文件的用户的用户名列出。 + +cron 守护进程在后台静默地检查 `/etc/crontab` 文件和 `/var/spool/cron` 及 `/etc/cron.d*/` 目录。 + +`crontab` 命令用于编辑 cron 文件。让我们看一下 crontab 文件的结构。 + +### crontab 文件剖析 + +在继续之前,我们要首先探索 crontab 文件的格式。crontab 文件的基本语法包括 5 列,由星号表示,后跟要执行的命令。 + +``` +*    *    *    *    *    command +``` + +此格式也可以表示如下: + +``` +m h d moy dow command +``` + +或 + +``` +m h d moy dow /path/to/script +``` + +让我们来解释一下每个条目 + +* `m`:代表分钟。范围是 0 到 59 +* `h`:表示小时,范围是 0 到 23 +* `d`:代表一个月中的某天,范围是 1 到 31 +* `moy`:这是一年中的月份。范围是 1 到 12 +* `dow`:这是星期几。范围是 0 到 6,其中 0 代表星期日 +* `command`:这是要执行的命令,例如备份命令、重新启动和复制命令等 + +### 管理 cron 任务 + +看完 crontab 文件的结构之后,让我们看看如何创建、编辑和删除 cron 任务。 + +#### 创建 cron 任务 + +要以 root 用户身份创建或编辑 cron 任务,请运行以下命令: + +``` +# crontab -e +``` + +要为另一个用户创建或安排 cron 任务,请使用以下语法: + +``` +# crontab -u username -e +``` + +例如,要以 Pradeep 用户身份运行 cron 任务,请发出以下命令: + +``` +# crontab -u Pradeep -e +``` + +如果该 crontab 文件尚不存在,那么你将打开一个空白文本文件。如果该 crontab 文件已经存在,则 `-e` 选项会让你编辑该文件, + +#### 列出 crontab 文件 + +要查看已创建的 cron 任务,只需传递 `-l` 选项: + +``` +# crontab -l +``` + +#### 删除 crontab 文件 + +要删除 cron 任务,只需运行 `crontab -e` 并删除所需的 cron 任务行,然后保存该文件。 + +要删除所有的 cron 任务,请运行以下命令: + +``` +# crontab -r +``` + +然后,让我们看一下安排任务的不同方式。 + +### 使用 crontab 安排任务示例 + +如图所示,所有 cron 任务文件都带有释伴shebang标头。 + +``` +#!/bin/bash +``` + +这表示你正在使用的 shell,在这种情况下,即 bash shell。 + +接下来,使用我们之前指定的 cron 任务条目指定要安排任务的时间间隔。 + +要每天下午 12:30 重启系统,请使用以下语法: + +``` +30  12 *  *  * /sbin/reboot +``` + +要安排在凌晨 4:00 重启,请使用以下语法: + +``` +0  4  *  *  *  /sbin/reboot +``` + +注:星号 `*` 用于匹配所有记录。 + +要每天两次运行脚本(例如,凌晨 4:00 和下午 4:00),请使用以下语法: + +``` +0  4,16  *  *  *  /path/to/script +``` + +要安排 cron 任务在每个星期五下午 5:00 运行,请使用以下语法: + +``` +0  17  *  *  Fri  /path/to/script +``` + +或 + +``` +0 17  *  *  *  5  /path/to/script +``` + +如果你希望每 30 分钟运行一次 cron 任务,请使用: + +``` +*/30  *  *  *  * /path/to/script +``` + +要安排 cron 任务每 5 小时运行一次,请运行: + +``` +*  */5  *  *  *  /path/to/script +``` + +要在选定的日期(例如,星期三和星期五的下午 6:00)运行脚本,请执行以下操作: + +``` +0  18  *  *  wed,fri  /path/to/script +``` + +要使用单个 cron 任务运行多个命令,请使用分号分隔任务,例如: + +``` +*  *  *  *  *  /path/to/script1 ; /path/to/script2 +``` + +### 使用特殊字符串节省编写 cron 任务的时间 + +某些 cron 任务可以使用对应于特定时间间隔的特殊字符串轻松配置。例如, + +1)`@hourly` 时间戳等效于 `0 * * * *` + +它将在每小时的第一分钟执行一次任务。 + +``` +@hourly /path/to/script +``` + +2)`@daily` 时间戳等效于 `0 0 * * *` + +它在每天的第一分钟(午夜)执行任务。它可以在执行日常工作时派上用场。 + +``` +@daily /path/to/script +``` + +3)`@weekly` 时间戳等效于 `0 0 * * 0` + +它在每周的第一分钟执行 cron 任务,一周第一天是从星期日开始的。 + +``` +@weekly /path/to/script +``` + +3)`@monthly` 时间戳等效于 `0 0 1 * *` + +它在每月第一天的第一分钟执行任务。 + +``` +@monthly /path/to/script +``` + +4)`@yearly` 时间戳等效于 `0 0 1 1 *` + +它在每年的第一分钟执行任务,可以用于发送新年问候。 + +``` +@yearly /path/to/script +``` + +### 限制 crontab + +作为 Linux 用户,你可以控制谁有权使用 `crontab` 命令。可以使用 `/etc/cron.deny` 和 `/etc/cron.allow` 文件来控制。默认情况下,只有一个 `/etc/cron.deny` 文件,并且不包含任何条目。要限制用户使用 `crontab` 实用程序,只需将用户的用户名添加到该文件中即可。当用户添加到该文件中,并且该用户尝试运行 `crontab` 命令时,他/她将遇到以下错误。 + +![restricted-cron-user][4] + +要允许用户继续使用 `crontab` 实用程序,只需从 `/etc/cron.deny` 文件中删除用户名即可。 + +如果存在 `/etc/cron.allow` 文件,则仅文件中列出的用户可以访问和使用 `crontab` 实用程序。 + +如果两个文件都不存在,则只有 root 用户具有使用 `crontab` 命令的特权。 + +### 备份 crontab 条目 + +始终建议你备份 crontab 条目。为此,请使用语法: + +``` +# crontab -l > /path/to/file.txt +``` + +例如: + +``` +# crontab -l > /home/james/backup.txt +``` + +### 检查 cron 日志 + +cron 日志存储在 `/var/log/cron` 文件中。要查看 cron 日志,请运行以下命令: + +``` +# cat /var/log/cron +``` + +![view-cron-log-files-linux][5] + +要实时查看日志,请使用 `tail` 命令,如下所示: + +``` +# tail -f /var/log/cron +``` + +![view-live-cron-logs][6] + +### 总结 + +在本指南中,你学习了如何创建 cron 任务以自动执行重复性任务,如何备份和查看 cron 日志。我们希望本文提供有关 cron 作业的有用见解。请随时分享你的反馈和意见。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/schedule-automate-tasks-linux-cron-jobs/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Schedule-tasks-in-Linux-using-cron.jpg +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/11/etc-crontab-linux.png +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/11/restricted-cron-user.png +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/11/view-cron-log-files-linux.png +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/11/view-live-cron-logs.png diff --git a/published/20191107 How to add a user to your Linux desktop.md b/published/20191107 How to add a user to your Linux desktop.md new file mode 100644 index 0000000000..9242826ebe --- /dev/null +++ b/published/20191107 How to add a user to your Linux desktop.md @@ -0,0 +1,88 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11584-1.html) +[#]: subject: (How to add a user to your Linux desktop) +[#]: via: (https://opensource.com/article/19/11/add-user-gui-linux) +[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss) + +如何在 Linux 桌面添加用户 +====== + +> 无论是在安装过程中还是在桌面中,通过图形界面管理用户都非常容易。 + +![Team of people around the world][1] + +添加用户是你在一个新系统上要做的第一件事。而且,你通常需要在计算机的整个生命周期中管理用户。 + +我的关于 [useradd 命令][2]文章提供了更深入的对 Linux 的用户管理的了解。`useradd` 是一个命令行工具,但是你也可以在 Linux 上以图形方式管理用户。这就是本文的主题。 + +### 在 Linux 安装过程中添加用户 + +大多数 Linux 发行版都提供了在安装过程中创建用户的步骤。例如,Fedora 30 安装程序 Anaconda 创建标准的 `root` 用户和另一个本地用户帐户。在安装过程中进入“配置”页面时,单击“用户设置”下的“用户创建”。 + +![Fedora Anaconda Installer - Add a user][3] + +在用户创建页面上,输入用户的详细信息:全名、用户名和密码。你还可以选择是否使用户成为管理员。 + +![Create a user during installation][4] + +点击“高级”按钮打开“高级用户配置”页面。如果需要除默认设置以外的其他设置,那么可以在此处指定主目录的路径以及用户和组 ID。你也可以输入用户所属的其他组。 + +![Advanced user configuration][5] + +### 在 Linux 桌面上添加用户 + +#### GNOME + +许多 Linux 发行版都使用 GNOME 桌面。以下截图来自 Red Hat Enterprise Linux 8.0,但是在其他发行版(如 Fedora、Ubuntu 或 Debian)中,该过程相似。 + +首先打开“设置”。然后打开“详细”,选择“用户”,单击“解锁”,然后输入密码(除非你已经以 root 用户登录)。这样将用“添加用户”按钮代替“解锁”按钮。 + +![GNOME user settings][6] + +现在,你可以通过单击“添加用户”,然后选择“帐户类型”然后输入“用户名”和“密码”来添加用户。 + +在下面的截图中,已经输入了用户名,设置保留为默认设置。我不必输入“用户名”,因为它是在我在“全名”字段中输入时自动创建的。如果你不喜欢自动补全,你仍然可以对其进行修改。 + +![GNOME settings - add user][7] + +这将为名为 Sonny 的用户创建一个标准帐户。Sonny 首次登录时需要提供密码。 + +接下来,将显示用户。在此页面可以选择每个用户进行自定义或者删除。例如,你可能想选择一个头像或设置默认语言。 + +![GNOME new user][8] + +#### KDE + +KDE 是另一个流行的 Linux 桌面环境。下面是 Fedora 30 上 KDE Plasma 的截图。你可以看到,在 KDE 中添加用户与在 GNOME 中添加用户非常相似。 + +![KDE settings - add user][9] + +### 总结 + +除 GNOME 和 KDE 外,其他桌面环境和窗口管理器也有图形用户管理工具。无论是在安装时还是安装后,在 Linux 中以图形方式添加用户都是快速简便的。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/add-user-gui-linux + +作者:[Alan Formy-Duval][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alanfdoss +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/team_global_people_gis_location.png?itok=Rl2IKo12 (Team of people around the world) +[2]: https://opensource.com/article/19/10/linux-useradd-command +[3]: https://opensource.com/sites/default/files/uploads/screenshot_fedora30_anaconda2.png (Fedora Anaconda Installer - Add a user) +[4]: https://opensource.com/sites/default/files/uploads/screenshot_fedora30_anaconda3.png (Create a user during installation) +[5]: https://opensource.com/sites/default/files/uploads/screenshot_fedora30_anaconda4.png (Advanced user configuration) +[6]: https://opensource.com/sites/default/files/uploads/gnome_settings_user_unlock.png (GNOME user settings) +[7]: https://opensource.com/sites/default/files/uploads/gnome_settings_adding_user.png (GNOME settings - add user) +[8]: https://opensource.com/sites/default/files/uploads/gnome_settings_user_new.png (GNOME new user) +[9]: https://opensource.com/sites/default/files/uploads/kde_settings_adding_user.png (KDE settings - add user) diff --git a/published/20191107 Tuning your bash or zsh shell on Fedora Workstation and Silverblue.md b/published/20191107 Tuning your bash or zsh shell on Fedora Workstation and Silverblue.md new file mode 100644 index 0000000000..e0878cfbe5 --- /dev/null +++ b/published/20191107 Tuning your bash or zsh shell on Fedora Workstation and Silverblue.md @@ -0,0 +1,258 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11560-1.html) +[#]: subject: (Tuning your bash or zsh shell on Fedora Workstation and Silverblue) +[#]: via: (https://fedoramagazine.org/tuning-your-bash-or-zsh-shell-in-workstation-and-silverblue/) +[#]: author: (George Luiz Maluf https://fedoramagazine.org/author/georgelmaluf/) + +在 Fedora 上优化 bash 或 zsh +====== + +![][1] + +本文将向你展示如何在 Fedora 的命令行解释器(CLI)Shell 中设置一些强大的工具。如果使用bash(默认)或zsh,Fedora 可让你轻松设置这些工具。 + +### 前置需求 + +这需要一些已安装的软件包。在 Fedora 工作站上,运行以下命令: + +``` +sudo dnf install git wget curl ruby ruby-devel zsh util-linux-user redhat-rpm-config gcc gcc-c++ make +``` + +在 Silverblue 上运行: + +``` +sudo rpm-ostree install git wget curl ruby ruby-devel zsh util-linux-user redhat-rpm-config gcc gcc-c++ make +``` + +注意:在 Silverblue 上,你需要重新启动才能继续。 + +### 字体 + +你可以通过安装新字体使终端焕然一新。为什么不使用可以同时显示字符和图标的字体呢? + +#### Nerd-Fonts + +打开一个新终端,然后键入以下命令: + +``` +git clone https://github.com/ryanoasis/nerd-fonts ~/.nerd-fonts +cd .nerd-fonts +sudo ./install.sh +``` + +#### Awesome-Fonts + +在工作站上,使用以下命令进行安装: + +``` +sudo dnf fontawesome-fonts +``` + +在 Silverblue 上键入: + +``` +sudo rpm-ostree install fontawesome-fonts +``` + +### Powerline + +Powerline 是 vim 的状态行插件,并为其他几个应用程序也提供了状态行和提示符,包括 bash、zsh、tmus、i3、Awesome、IPython 和 Qtile。你也可以在官方[文档站点][3]上找到更多信息。 + +#### 安装 + +要在 Fedora 工作站上安装 Powerline 实用程序,请打开一个新终端并运行: + +``` +sudo dnf install powerline vim-powerline tmux-powerline powerline-fonts +``` + +在 Silverblue 上,命令更改为: + +``` +sudo rpm-ostree install powerline vim-powerline tmux-powerline powerline-fonts +``` + +注意:在 Silverblue 上,你需要重新启动才能继续。 + +#### 激活 Powerline + +要使 Powerline 默认处于活动状态,请将下面的代码放在 `~/.bashrc` 文件的末尾: + +``` +if [ -f `which powerline-daemon` ]; then + powerline-daemon -q + POWERLINE_BASH_CONTINUATION=1 + POWERLINE_BASH_SELECT=1 + . /usr/share/powerline/bash/powerline.sh +fi +``` + +最后,关闭终端并打开一个新终端。它看起来像这样: + +![][4] + +### Oh-My-Zsh + +[Oh-My-Zsh][5] 是用于管理 Zsh 配置的框架。它捆绑了有用的功能、插件和主题。要了解如何将 Zsh 设置为默认外壳程序,请参见[这篇文章][6]。 + +#### 安装 + +在终端中输入: + +``` +sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" +``` + +或者,你也可以输入以下内容: + +``` +sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" +``` + +最后,你将看到如下所示的终端: + +![][7] + +恭喜,Oh-my-zsh 已安装成功。 + +#### 主题 + +安装后,你可以选择主题。我喜欢使用 powerlevel10k。优点之一是它比 powerlevel9k 主题快 100 倍。要安装它,请运行以下命令行: + +``` +git clone https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/themes/powerlevel10k +``` + +并在你的 `~/.zshrc` 文件设置 `ZSH_THEME`: + +``` +ZSH_THEME=powerlevel10k/powerlevel10k +``` + +关闭终端。再次打开终端时,powerlevel10k 配置向导将询问你几个问题以正确配置提示符。 + +![][8] + +完成 powerline10k 配置向导后,你的提示符将如下所示: + +![][9] + +如果你不喜欢它。你可以随时使用 `p10k configure` 命令来运行 powerline10k 向导。 + +#### 启用插件 + +插件存储在 `.oh-my-zsh/plugins` 文件夹中。要激活插件,你需要编辑 `~/.zshrc` 文件。安装插件意味着你创建了一系列执行特定功能的别名或快捷方式。 + +例如,要启用 firewalld 和 git 插件,请首先编辑 `~/.zshrc`: + +``` +plugins=(firewalld git) +``` + +注意:使用空格分隔插件名称列表。 + +然后重新加载配置: + +``` +source ~/.zshrc +``` + +要查看创建的别名,请使用以下命令: + +``` +alias | grep firewall +``` + +![][10] + +#### 更多配置 + +我建议安装语法高亮和语法自动建议插件。 + +``` +git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting +git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions +``` + +将它们添加到文件 `~/.zshrc` 的插件列表中。 + +``` +plugins=( [plugins...] zsh-syntax-highlighting zsh-autosuggestions) +``` + +重新加载配置。 + +``` +source ~/.zshrc +``` + +查看结果: + +![][11] + +### 彩色的文件夹和图标 + +`colorls` 是一个 ruby gem,可使用颜色和超棒的字体图标美化终端的 `ls` 命令。你可以访问官方[网站][12]以获取更多信息。 + +因为它是个 ruby gem,所以请按照以下简单步骤操作: + +``` +sudo gem install colorls +``` + +要保持最新状态,只需执行以下操作: + +``` +sudo gem update colorls +``` + +为防止每次输入 `colorls`,你可以在 `~/.bashrc` 或 `~/.zshrc` 中创建别名。 + +``` +alias ll='colorls -lA --sd --gs --group-directories-first' +alias ls='colorls --group-directories-first' +``` + +另外,你可以为 `colorls` 的选项启用制表符补完功能,只需在 shell 配置末尾输入以下行: + +``` +source $(dirname ($gem which colorls))/tab_complete.sh +``` + +重新加载并查看会发生什么: + +![][13] + +![][14] + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/tuning-your-bash-or-zsh-shell-in-workstation-and-silverblue/ + +作者:[George Luiz Maluf][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/georgelmaluf/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/10/tuning-shell-816x345.jpg +[2]: https://fedoramagazine.org/add-power-terminal-powerline/ +[3]: https://powerline.readthedocs.io/en/latest/ +[4]: https://fedoramagazine.org/wp-content/uploads/2019/10/terminal_bash_powerline.png +[5]: https://ohmyz.sh +[6]: https://fedoramagazine.org/set-zsh-fedora-system/ +[7]: https://fedoramagazine.org/wp-content/uploads/2019/10/oh-my-zsh.png +[8]: https://fedoramagazine.org/wp-content/uploads/2019/10/powerlevel10k_config_wizard.png +[9]: https://fedoramagazine.org/wp-content/uploads/2019/10/powerlevel10k.png +[10]: https://fedoramagazine.org/wp-content/uploads/2019/10/aliases_plugin.png +[11]: https://fedoramagazine.org/wp-content/uploads/2019/10/sintax.png +[12]: https://github.com/athityakumar/colorls +[13]: https://fedoramagazine.org/wp-content/uploads/2019/10/ls-1024x495.png +[14]: https://fedoramagazine.org/wp-content/uploads/2019/10/ll-1024x495.png diff --git a/published/20191108 7 Best Open Source Tools that will help in AI Technology.md b/published/20191108 7 Best Open Source Tools that will help in AI Technology.md new file mode 100644 index 0000000000..11c0950e34 --- /dev/null +++ b/published/20191108 7 Best Open Source Tools that will help in AI Technology.md @@ -0,0 +1,142 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11587-1.html) +[#]: subject: (7 Best Open Source Tools that will help in AI Technology) +[#]: via: (https://opensourceforu.com/2019/11/7-best-open-source-tools-that-will-help-in-ai-technology/) +[#]: author: (Nitin Garg https://opensourceforu.com/author/nitin-garg/) + +7 个有助于 AI 技术的最佳开源工具 +====== + +![][1] + +> 人工智能是一种紧跟未来道路的卓越技术。在这个不断发展的时代,它吸引了所有跨国组织的关注。谷歌、IBM、Facebook、亚马逊、微软等业内知名公司不断投资于这种新时代技术。 + +预测业务需求需要利用人工智能,并在另一个层面上进行研发。这项先进技术正成为提供超智能解决方案的研发组织不可或缺的一部分。它可以帮助你保持准确性并以更好的结果提高生产率。 + +AI 开源工具和技术以频繁且准确的结果吸引了每个行业的关注。这些工具可帮助你分析绩效,同时为你带来更大的收益。 + +无需赘言,这里我们列出了一些最佳的开源工具,来帮助你更好地了解人工智能。 + +### 1、TensorFlow + +TensorFlow 是用于人工智能的开源机器学习框架。它主要是为了进行机器学习和深度学习的研究和生产而开发的。TensorFlow 允许开发者创建数据流的图结构,它会在网络或系统节点中移动,图提供了数据的多维数组或张量。 + +TensorFlow 是一个出色的工具,它有无数的优势。 + +* 简化数值计算 +* TensorFlow 在多种模型上提供了灵活性。 +* TensorFlow 提高了业务效率 +* 高度可移植 +* 自动区分能力 + +### 2、Apache SystemML + +Apache SystemML 是由 IBM 创建的非常流行的开源机器学习平台,它提供了使用大数据的良好平台。它可以在 Apache Spark 上高效运行,并自动扩展数据,同时确定代码是否可以在磁盘或 Apache Spark 集群上运行。不仅如此,它丰富的功能使其在行业产品中脱颖而出; + +* 算法自定义 +* 多种执行模式 +* 自动优化 + +它还支持深度学习,让开发者更有效率地实现机器学习代码并优化。 + +### 3、OpenNN + +OpenNN 是用于渐进式分析的开源人工智能神经网络库。它可帮助你使用 C++ 和 Python 开发健壮的模型,它还包含用于处理机器学习解决方案(如预测和分类)的算法和程序。它还涵盖了回归和关联,可提供业界的高性能和技术演化。 + +它有丰富的功能,如: + +* 数字化协助 +* 预测分析 +* 快速的性能 +* 虚拟个人协助 +* 语音识别 +* 高级分析 + +它可帮助你设计实现数据挖掘的先进方案,而从取得丰硕结果。 + +### 4、Caffe + +Caffe(快速特征嵌入的卷积结构)是一个开源深度学习框架。它优先考虑速度、模块化和表达式。Caffe 最初由加州大学伯克利分校视觉和学习中心开发,它使用 C++ 编写,带有 Python 接口。能在 Linux、macOS 和 Windows 上顺利运行。 + +Caffe 中的一些有助于 AI 技术的关键特性。 + +1. 具有表现力的结构 +2. 具有扩展性的代码 +3. 大型社区 +4. 开发活跃 +5. 性能快速 + +它可以帮助你激发创新,同时引入刺激性增长。充分利用此工具来获得所需的结果。 + +### 5、Torch + +Torch 是一个开源机器学习库,通过提供多种方便的功能,帮助你简化序列化、面向对象编程等复杂任务。它在机器学习项目中提供了最大的灵活性和速度。Torch 使用脚本语言 Lua 编写,底层使用 C 实现。它用于多个组织和研究实验室中。 + +Torch 有无数的优势,如: + +* 快速高效的 GPU 支持 +* 线性代数子程序 +* 支持 iOS 和 Android 平台 +* 数值优化子程序 +* N 维数组 + +### 6、Accord .NET + +Accord .NET 是著名的自由开源 AI 开发工具之一。它有一组库,可以用来组合使用 C# 编写的音频和图像处理库。从计算机视觉到计算机听觉、信号处理和统计应用,它可以帮助你构建用于商业用途一切需求。它附带了一套全面的示例应用来快速运行各类库。 + +你可以使用 Accord .NET 引人注意的功能开发一个高级应用,例如: + +* 统计分析 +* 数据接入 +* 自适应 +* 深度学习 +* 二阶神经网络学习算法 +* 数字协助和多语言 +* 语音识别 + +### 7、Scikit-Learn + +Scikit-Learn 是流行的辅助 AI 技术的开源工具之一。它是 Python 中用于机器学习的一个很有价值的库。它包括机器学习和统计建模(包括分类、聚类、回归和降维)等高效工具。 + +让我们了解下 Scikit-Learn 的更多功能: + +* 交叉验证 +* 聚类和分类 +* 流形学习 +* 机器学习 +* 虚拟流程自动化 +* 工作流自动化 + +从预处理到模型选择,Scikit-learn 可帮助你处理所有问题。它简化了从数据挖掘到数据分析的所有任务。 + +### 总结 + +这些是一些流行的开源 AI 工具,它们提供了全面的功能。在开发新时代应用之前,人们必须选择其中一个工具并做相应的工作。这些工具提供先进的人工智能解决方案,并紧跟最新趋势。 + +人工智能在全球范围内应用,无处不在。借助 Amazon Alexa、Siri 等应用,AI 为客户提供了很好的用户体验。它在吸引用户关注的行业中具有显著优势。在医疗保健、银行、金融、电子商务等所有行业中,人工智能在促进增长和生产力的同时节省了大量的时间和精力。 + +选择这些开源工具中的任何一个,获得更好的用户体验和令人难以置信的结果。它将帮助你成长,并在质量和安全性方面获得更好的结果。 + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/7-best-open-source-tools-that-will-help-in-ai-technology/ + +作者:[Nitin Garg][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensourceforu.com/author/nitin-garg/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2018/05/Artificial-Intelligence_EB-June-17.jpg?resize=696%2C464&ssl=1 (Artificial Intelligence_EB June 17) +[2]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2018/05/Artificial-Intelligence_EB-June-17.jpg?fit=1000%2C667&ssl=1 +[3]: https://secure.gravatar.com/avatar/d4e6964b80590824b981f06a451aa9e6?s=100&r=g +[4]: https://opensourceforu.com/author/nitin-garg/ +[5]: https://www.brsoftech.com/bi-consulting-services.html +[6]: https://opensourceforu.com/wp-content/uploads/2019/11/assoc.png +[7]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/published/20191108 Budget-friendly Linux Smartphone PinePhone Will be Available to Pre-order Next Week.md b/published/20191108 Budget-friendly Linux Smartphone PinePhone Will be Available to Pre-order Next Week.md new file mode 100644 index 0000000000..a41d338c6b --- /dev/null +++ b/published/20191108 Budget-friendly Linux Smartphone PinePhone Will be Available to Pre-order Next Week.md @@ -0,0 +1,101 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11559-1.html) +[#]: subject: (Budget-friendly Linux Smartphone PinePhone Will be Available to Pre-order Next Week) +[#]: via: (https://itsfoss.com/pinephone/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +低价 Linux 智能手机 PinePhone 即将接受预订 +====== + +![PinePhone Prototype | Image by Martjin Braam][3] + +你还记得[在 2017 年首次披露][1]的 Pine64 正在开发一个基于 Linux(可以运行 KDE Plasma 及其他发行版)的智能手机的事情吗?从那以后已经有一段时间了,但是好消息是 PinePhone 将从 11 月 15 日开始接受预订。 + +让我来为你提供有关 PinePhone 的更多详细信息,例如其规格、价格和发布日期。 + +### PinePhone:基于 Linux 的廉价智能手机 + +PinePhone 开发者套件已经经过了一些开发人员的测试,更多此类套件将于 11 月 15 日发货。你可以查看下面的照片: + +![](https://img.apester.com/insecure/fit/0/520/ce/0/plain/user-images%2F43%2F43b54bb2e341a0ddba3a2e5c5add438c.jpg) + +![](https://img.apester.com/insecure/fit/0/520/ce/0/plain/user-images%2F55%2F558329908500e3f69f0ab03cd3fc0e62.jpg) + +![](https://img.apester.com/insecure/fit/0/520/ce/0/plain/user-images%2F8d%2F8df9d93a240237b45cdef9615c8fd5de.jpg) + +开发者套件是由 PINE A64 基板 + SOPine 模块 + 7 英寸触摸屏显示器 + 摄像头 + Wifi / BT + 外壳 + 锂离子电池盒 + LTE cat 4 USB 软件狗组成的组合套件。 + +这些组合套件可以使开发人员快速开始 PinePhone 开发。由于 PINE64 社区和 [KDE neon][2] 的支持,主线 Linux 操作系统已经可以在 PINE A64 平台上构建。 + +#### PinePhone 规格 + +* Allwinner A64 四核 SoC,带有 Mali 400 MP2 GPU +* 2GB 的 LPDDR3 RAM +* 5.95 英寸 LCD 1440×720,长宽比 18:9(钢化玻璃) +* 可启动的 Micro SD +* 16GB eMMC +* 高清数字视频输出 +* USB Type-C(电源、数据和视频输出) +* Quectel EG-25G 全球波段 +* WiFi:802.11 b/g/n,单频,支持热点 +* 蓝牙:4.0,A2DP +* GNSS:GPS,GPS-A,GLONASS +* 振动器 +* RGB 状态 LED +* 自拍和主摄像头(分别为 2/5 Mpx) +* 主摄像头:单颗 OV6540、5MP,1/4 英寸,LED 闪光灯 +* 自拍相机:单 GC2035、2MP,f/2.8、1/5 英寸 +* 传感器:加速器、陀螺仪、距离感应器、罗盘、气压计、环境光感 +* 3 个外部开关:上、下和电源 +* 硬件开关:LTE/GNSS、WiFi、麦克风、扬声器、USB +* 三星 J7 外形尺寸 3000mAh 电池 +* 外壳是磨砂黑色成品塑料 +* 耳机插孔 + +#### 产品、价格和交付时间 + +PinePhone 的价格约为 150 美元。尝鲜版命名为“勇敢的心”,将于 2019 年 11 月 15 日开始销售。如上图所示,[Pine64 的主页][5]包含了用于首次预订 PinePhone 的计时器。 + +预期“勇敢的心”尝鲜版在 2019 年 12 月或 2020 年 1 月之前发货。 + +大规模生产将在中国的农历新年后开始,也就是说在 2020 年第二季度早期或最早 2020 年 3 月开始。 + +该电话尚未在 Pine Store 中列出,因此,如果你想成为尝鲜者之一,请务必查看 [Pine64 在线商店][6]以预订“勇敢的心”版本。 + +#### 你对 PinePhone 如何看? + +Pine64 已经开发了一款名为 [Pinebook][7] 的廉价笔记本电脑和一款功能相对强大的 [Pinebook Pro][8] 笔记本电脑。因此,PinePhone 至少在 DIY 爱好者和 Linux 忠实拥护者的狭窄市场中绝对有希望获得成功。与其他价格超过 600 美元的 [Linux 智能手机 Librem5][9] 相比,低廉的价格绝对是一个巨大的优势。 + +PinePhone 的另一个优点是,你可以通过安装 Ubuntu Touch、Plasma Mobile 或 Aurora OS/Sailfish OS 来试验操作系统。 + +这些基于 Linux 的智能手机尚不具备取代 Android 或 iOS 的功能。如果你正在寻找功能全面的智能手机来替代你的 Android 智能手机,那么 PinePhone 当然不适合你。但对于喜欢尝试并且不害怕排除故障的人来说,它的优势更大。 + +如果你想购买 PinePhone,请记住这个日期并设置提醒。供应应该是限量的,到目前为止,我所了解的,Pine 设备很快就会脱销。 + +你要预订 PinePhone 吗?在评论部分将你的意见告知我们。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/pinephone/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/pinebook-kde-smartphone/ +[2]: https://neon.kde.org/ +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/pinephone-prototype.jpeg?ssl=1 +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/pinephone-brave-heart-pre-order.jpg?ssl=1 +[5]: https://www.pine64.org/ +[6]: https://store.pine64.org/ +[7]: https://itsfoss.com/pinebook-linux-notebook/ +[8]: https://itsfoss.com/pinebook-pro/ +[9]: https://itsfoss.com/librem-linux-phone/ diff --git a/published/20191108 How to manage music tags using metaflac.md b/published/20191108 How to manage music tags using metaflac.md new file mode 100644 index 0000000000..91943bccbc --- /dev/null +++ b/published/20191108 How to manage music tags using metaflac.md @@ -0,0 +1,145 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11579-1.html) +[#]: subject: (How to manage music tags using metaflac) +[#]: via: (https://opensource.com/article/19/11/metaflac-fix-music-tags) +[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen) + +如何使用 metaflac 管理音乐标签 +====== + +> 使用这个强大的开源工具可以在命令行中纠正音乐标签错误。 + +![](https://img.linux.net.cn/data/attachment/album/201911/16/093629njth88bej8ttekh2.jpg) + +很久以来我就将 CD 翻录到电脑。在此期间,我用过几种不同的翻录工具,观察到每种工具在标记上似乎有不同的做法,特别是在保存哪些音乐元数据上。所谓“观察”,我是指音乐播放器似乎按照有趣的顺序对专辑进行排序,它们将一个目录中的曲目分为两张专辑,或者产生了其他令人沮丧的烦恼。 + +我还看到有些标签非常不明确,许多音乐播放器和标签编辑器没有显示它们。即使这样,在某些极端情况下,它们仍可以使用这些标签来分类或显示音乐,例如播放器将所有包含 XYZ 标签的音乐文件与不包含该标签的所有文件分离到不同的专辑中。 + +那么,如果标记应用和音乐播放器没有显示“奇怪”的标记,但是它们受到了某种影响,你该怎么办? + +### Metaflac 来拯救! + +我一直想要熟悉 [metaflac][2],它是一款开源命令行 [FLAC 文件][3]元数据编辑器,这是我选择的开源音乐文件格式。并不是说 [EasyTAG][4] 这样出色的标签编辑软件有什么问题,但我想起“如果你手上有个锤子……”这句老话(LCTT 译注:指如果你手上有个锤子,那么所有的东西看起来都像钉子。意指人们惯于用熟悉的方式解决问题,而不管合不合适)。另外,从实际的角度来看,带有 [Armbian][5] 和 [MPD][6] 的小型专用服务器,音乐存储在本地、运行精简的仅限音乐的无头环境就可以满足我的家庭和办公室的立体音乐的需求,因此命令行元数据管理工具将非常有用。 + +下面的截图显示了我的长期翻录过程中产生的典型问题:Putumayo 的哥伦比亚音乐汇编显示为两张单独的专辑,一张包含单首曲目,另一张包含其余 11 首: + +![Album with incorrect tags][7] + +我使用 `metaflac` 为目录中包含这些曲目的所有 FLAC 文件生成了所有标签的列表: + +``` +rm -f tags.txt +for f in *.flac; do +        echo $f >> tags.txt +        metaflac --export-tags-to=tags.tmp "$f" +        cat tags.tmp >> tags.txt +        rm tags.tmp +done +``` + +我将其保存为可执行的 shell 脚本(请参阅我的同事 [David Both][8] 关于 Bash shell 脚本的精彩系列专栏文章,[特别是关于循环这章][9])。基本上,我在这做的是创建一个文件 `tags.txt`,包含文件名(`echo` 命令),后面是它的所有标签,然后是下一个文件名,依此类推。这是结果的前几行: + + +``` +A Guapi.flac +TITLE=A Guapi +ARTIST=Grupo Bahia +ALBUMARTIST=Various Artists +ALBUM=Putumayo Presents: Colombia +DATE=2001 +TRACKTOTAL=12 +GENRE=Latin Salsa +MUSICBRAINZ_ALBUMARTISTID=89ad4ac3-39f7-470e-963a-56509c546377 +MUSICBRAINZ_ALBUMID=6e096386-1655-4781-967d-f4e32defb0a3 +MUSICBRAINZ_ARTISTID=2993268d-feb6-4759-b497-a3ef76936671 +DISCID=900a920c +ARTISTSORT=Grupo Bahia +MUSICBRAINZ_DISCID=RwEPU0UpVVR9iMP_nJexZjc_JCc- +COMPILATION=1 +MUSICBRAINZ_TRACKID=8a067685-8707-48ff-9040-6a4df4d5b0ff +ALBUMARTISTSORT=50 de Joselito, Los +Cumbia Del Caribe.flac +``` + +经过一番调查,结果发现我同时翻录了很多 Putumayo CD,并且当时我所使用的所有软件似乎给除了一个之外的所有文件加上了 `MUSICBRAINZ_*` 标签。(是 bug 么?大概吧。我在六张专辑中都看到了。)此外,关于有时不寻常的排序,我注意到,`ALBUMARTISTSORT` 标签将西班牙语标题 “Los” 移到了标题的最后面(逗号之后)。 + +我使用了一个简单的 `awk` 脚本来列出 `tags.txt` 中报告的所有标签: + +``` +awk -F= 'index($0,"=") > 0 {print $1}' tags.txt | sort -u +``` + +这会使用 `=` 作为字段分隔符将所有行拆分为字段,并打印包含等号的行的第一个字段。结果通过使用 `sort` 及其 `-u` 标志来传递,从而消除了输出中的所有重复项(请参阅我的同事 Seth Kenlon 的[关于 `sort` 程序的文章][10])。对于这个 `tags.txt` 文件,输出为: + +``` +ALBUM +ALBUMARTIST +ALBUMARTISTSORT +ARTIST +ARTISTSORT +COMPILATION +DATE +DISCID +GENRE +MUSICBRAINZ_ALBUMARTISTID +MUSICBRAINZ_ALBUMID +MUSICBRAINZ_ARTISTID +MUSICBRAINZ_DISCID +MUSICBRAINZ_TRACKID +TITLE +TRACKTOTAL +``` + +研究一会后,我发现 `MUSICBRAINZ_*` 标签出现在除了一个 FLAC 文件之外的所有文件上,因此我使用 `metaflac` 命令删除了这些标签: + +``` +for f in *.flac; do metaflac --remove-tag MUSICBRAINZ_ALBUMARTISTID "$f"; done +for f in *.flac; do metaflac --remove-tag MUSICBRAINZ_ALBUMID "$f"; done +for f in *.flac; do metaflac --remove-tag MUSICBRAINZ_ARTISTID "$f"; done +for f in *.flac; do metaflac --remove-tag MUSICBRAINZ_DISCID "$f"; done +for f in *.flac; do metaflac --remove-tag MUSICBRAINZ_TRACKID "$f"; done +``` + +完成后,我可以使用音乐播放器重建 MPD 数据库。结果如下: + +![Album with correct tags][11] + +完成了,12 首曲目出现在了一张专辑中。 + +太好了,我很喜欢 `metaflac`。我希望我会更频繁地使用它,因为我会试图去纠正最后一些我弄乱的音乐收藏标签。强烈推荐! + +### 关于音乐 + +我花了几个晚上在 CBC 音乐(CBC 是加拿大的公共广播公司)上收听 Odario Williams 的节目 After Dark。感谢 Odario,我听到了让我非常享受的 [Kevin Fox 的 Songs for Cello and Voice] [12]。在这里,他演唱了 Eurythmics 的歌曲 “[Sweet Dreams(Are Made of This)][13]”。 + +我购买了这张 CD,现在它在我的音乐服务器上,还有组织正确的标签! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/metaflac-fix-music-tags + +作者:[Chris Hermansen][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clhermansen +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web-design-monitor-website.png?itok=yUK7_qR0 (website design image) +[2]: https://xiph.org/flac/documentation_tools_metaflac.html +[3]: https://xiph.org/flac/index.html +[4]: https://wiki.gnome.org/Apps/EasyTAG +[5]: https://www.armbian.com/ +[6]: https://www.musicpd.org/ +[7]: https://opensource.com/sites/default/files/uploads/music-tags1_before.png (Album with incorrect tags) +[8]: https://opensource.com/users/dboth +[9]: https://opensource.com/article/19/10/programming-bash-loops +[10]: https://opensource.com/article/19/10/get-sorted-sort +[11]: https://opensource.com/sites/default/files/uploads/music-tags2_after.png (Album with correct tags) +[12]: https://burlingtonpac.ca/events/kevin-fox/ +[13]: https://www.youtube.com/watch?v=uyN66XI1zp4 diff --git a/published/20191111 Confirmed- Microsoft Edge Will be Available on Linux.md b/published/20191111 Confirmed- Microsoft Edge Will be Available on Linux.md new file mode 100644 index 0000000000..0b6d422bd0 --- /dev/null +++ b/published/20191111 Confirmed- Microsoft Edge Will be Available on Linux.md @@ -0,0 +1,90 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11562-1.html) +[#]: subject: (Confirmed! Microsoft Edge Will be Available on Linux) +[#]: via: (https://itsfoss.com/microsoft-edge-linux/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +确认了!微软 Edge 浏览器将发布 Linux 版 +====== + +![](https://img.linux.net.cn/data/attachment/album/201911/11/164600uv7yrbe7gtkxi4xg.jpg) + +> 微软正在全面重制其 Edge Web 浏览器,它将基于开源 [Chromium][2] 浏览器。微软还要将新的 Edge 浏览器带到 Linux 桌面上,但是 Linux 版本可能会有所延迟。 + +微软的 Internet Explorer 曾经一度统治了浏览器市场,但在过去的十年中,它将统治地位丢给了谷歌的 Chrome。 + +微软试图通过创造 Edge 浏览器来找回失去的位置,Edge 是一种使用 EdgeHTML 和 [Chakra 引擎][6]构建的全新 Web 浏览器。它与 Microsoft 的数字助手 [Cortana][7] 和 Windows 10 紧密集成。 + +但是,它仍然无法夺回冠军位置,截至目前,它处于[桌面浏览器使用份额的第四位][8]。 + +最近,微软决定通过基于[开源 Chromium 项目][9]重新对 Edge 进行大修。谷歌的 Chrome 浏览器也是基于 Chromium 的。[Chromium 还可以作为独立的 Web 浏览器使用][2],某些 Linux 发行版将其用作默认的 Web 浏览器。 + +### Linux 上新的微软 Edge Web 浏览器 + +经过最初的犹豫和不确定性之后,微软似乎最终决定把新的 Edge 浏览器引入到 Linux。 + +在其年度开发商大会 [Microsoft Ignite][10] 中,[关于 Edge 浏览器的演讲][11]中提到了它未来将进入 Linux 中。 + +![微软确认 Edge 未来将进入 Linux 中][12] + +新的 Edge 浏览器将于 2020 年 1 月 15 日发布,但我认为 Linux 版本会推迟。 + +### 微软 Edge 进入 Linux 真的重要吗? + +微软 Edge 进入 Linux 有什么大不了的吗?我们又不是没有很多[可用于 Linux 的 Web 浏览器][13]? + +我认为这与 “微软 Linux 竞争”(如果有这样的事情)有关。微软为 Linux(特别是 Linux 桌面)做的任何事情,都会成为新闻。 + +我还认为 Linux 上的 Edge 对于微软和 Linux 用户都有好处。这就是为什么。 + +#### 对于微软有什么用? + +当谷歌在 2008 年推出其 Chrome 浏览器时,没有人想到它会在短短几年内占领市场。但是,为什么作为一个搜索引擎会在一个“免费的 Web 浏览器”后面投入如此多的精力呢? + +答案是谷歌是一家搜索引擎,它希望有更多的人使用其搜索引擎和其他服务,以便它可以从广告服务中获得收入。使用 Chrome,Google 是默认的搜索引擎。在 Firefox 和 Safari 等其他浏览器上,谷歌支付了数亿美元作为默认 Web 浏览器的费用。如果没有 Chrome,则谷歌必须完全依赖其他浏览器。 + +微软也有一个名为 Bing 的搜索引擎。Internet Explorer 和 Edge 使用 Bing 作为默认搜索引擎。如果更多用户使用 Edge,它可以增加将更多用户带到 Bing 的机会。而微软显然希望拥有更多的 Bing 用户。 + +#### 对 Linux 用户有什么用? + +对于 Linux 桌面用户,我看到有两个好处。借助 Edge,你可以在 Linux 上使用某些微软特定的产品。 例如,微软的流式游戏服务 [xCloud][14] 可能仅能在 Edge 浏览器上使用。另一个好处是提升了 [Linux 上的 Netflix 体验][15]。当然,你可以在 Linux 上使用 Chrome 或 [Firefox 观看 Netflix][16],但可能无法获得全高清或超高清流。 + +据我所知,[全高清和超高清 Netflix 流仅在微软 Edge 上可用][17]。这意味着你可以使用 Linux 上的 Edge 以高清格式享受 Netflix。 + +### 你怎么看? + +你对微软 Edge 进入 Linux 有什么感觉?当 Linux 版本可用时,你会使用吗?请在下面的评论部分中分享你的观点。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/microsoft-edge-linux/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/microsoft_edge_logo_transparent.png?ssl=1 +[2]: https://itsfoss.com/install-chromium-ubuntu/ +[3]: https://twitter.com/hashtag/opensource?src=hash&ref_src=twsrc%5Etfw +[4]: https://t.co/Co5Xj3dKIQ +[5]: https://twitter.com/abhishek_foss/status/844666818665025537?ref_src=twsrc%5Etfw +[6]: https://itsfoss.com/microsoft-chakra-core/ +[7]: https://www.microsoft.com/en-in/windows/cortana +[8]: https://en.wikipedia.org/wiki/Usage_share_of_web_browsers +[9]: https://www.chromium.org/Home +[10]: https://www.microsoft.com/en-us/ignite +[11]: https://myignite.techcommunity.microsoft.com/sessions/79341?source=sessions +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/Microsoft_Edge_Linux.jpg?ssl=1 +[13]: https://itsfoss.com/open-source-browsers-linux/ +[14]: https://www.pocket-lint.com/games/news/147429-what-is-xbox-project-xcloud-cloud-gaming-service-price-release-date-devices +[15]: https://itsfoss.com/watch-netflix-in-ubuntu-linux/ +[16]: https://itsfoss.com/netflix-firefox-linux/ +[17]: https://help.netflix.com/en/node/23742 diff --git a/published/20191112 Getting started with PostgreSQL.md b/published/20191112 Getting started with PostgreSQL.md new file mode 100644 index 0000000000..6a987c22c0 --- /dev/null +++ b/published/20191112 Getting started with PostgreSQL.md @@ -0,0 +1,201 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11593-1.html) +[#]: subject: (Getting started with PostgreSQL) +[#]: via: (https://opensource.com/article/19/11/getting-started-postgresql) +[#]: author: (Greg Pittman https://opensource.com/users/greg-p) + +PostgreSQL 入门 +====== + +> 安装、设置、创建和开始使用 PostgreSQL 数据库。 + +![](https://img.linux.net.cn/data/attachment/album/201911/20/085936u10q7eme1euu4ak3.jpg) + +每个人或许都有需要在数据库中保存的东西。即使你执着于使用纸质文件或电子文件,它们也会变得很麻烦。纸质文档可能会丢失或混乱,你需要访问的电子信息可能会隐藏在段落和页面的深处。 + +在我从事医学工作的时候,我使用 [PostgreSQL][2] 来跟踪我的住院患者名单并提交有关住院患者的信息。我将我的每日患者名单打印在口袋里,以便快速了解患者房间、诊断或其他细节的任何变化并做出快速记录。 + +我以为一切没问题,直到去年我妻子决定买一辆新车,我“接手”了她以前的那辆车。她保留了汽车维修和保养服务收据的文件夹,但随着时间的流逝,它变得杂乱。与其花时间筛选所有纸条以弄清楚什么时候做了什么,我认为 PostgreSQL 将是更好的跟踪此信息的方法。 + +### 安装 PostgreSQL + +自上次使用 PostgreSQL 以来已经有一段时间了,我已经忘记了如何使用它。实际上,我甚至没有在计算机上安装它。安装它是第一步。我使用 Fedora,因此在控制台中运行: + +``` +dnf list postgresql* +``` + +请注意,你无需使用 `sudo` 即可使用 `list` 选项。该命令返回了很长的软件包列表。看了眼后,我决定只需要三个:postgresql、postgresql-server 和 postgresql-docs。 + +为了了解下一步需要做什么,我决定查看 [PostgreSQL 文档][3]。文档参考内容非常丰富,实际上,丰富到令人生畏。幸运的是,我发现我在升级 Fedora 时曾经做过的一些笔记,希望有效地导出数据库,在新版本上重新启动 PostgreSQL,以及导入旧数据库。 + +### 设置 PostgreSQL + +与大多数其他软件不同,你不能只是安装好 PostgreSQL 就开始使用它。你必须预先执行两个基本步骤:首先,你需要设置 PostgreSQL,第二,你需要启动它。你必须以 `root` 用户身份执行这些操作(`sudo` 在这里不起作用)。 + +要设置它,请输入: + +``` +postgresql-setup –initdb +``` + +这将确定 PostgreSQL 数据库在计算机上的位置。然后(仍为 `root`)输入以下两个命令: + +``` +systemctl start postgresql.service +systemctl enable postgresql.service +``` + +第一个命令为当前会话启动 PostgreSQL(如果你关闭机器,那么 PostgreSQL 也将关闭)。第二个命令使 PostgreSQL 在随后的重启中自动启动。 + +### 创建用户 + +PostgreSQL 正在运行,但是你仍然不能使用它,因为你还没有用户。为此,你需要切换到特殊用户 `postgres`。当你仍以 `root` 身份运行时,输入: + +``` +su postgres +``` + +由于你是以 `root` 的身份执行此操作的,因此无需输入密码。root 用户可以在不知道密码的情况下以任何用户身份操作;这就是使其强大而危险的原因之一。 + +现在你就是 `postgres` 了,请运行下面两个命令,如下所示创建用户(创建用户 `gregp`): + +``` +createuser gregp +createdb gregp +``` + +你可能会看到错误消息,如:`Could not switch to /home/gregp`。这只是意味着用户 `postgres`不能访问该目录。尽管如此,你的用户和数据库已创建。接下来,输入 `exit` 并按回车两次,这样就回到了原来的用户下(`root`)。 + +### 设置数据库 + +要开始使用 PostgreSQL,请在命令行输入 `psql`。你应该在每行左侧看到类似 `gregp=>` 的内容,以显示你使用的是 PostgreSQL,并且只能使用它理解的命令。你自动获得一个数据库(我的名为 `gregp`),它里面完全没有内容。对 PostgreSQL 来说,数据库只是一个工作空间。在空间内,你可以创建*表*。表包含变量列表,而表中的每个变量是构成数据库的数据。 + +以下是我设置汽车服务数据库的方式: + +``` +CREATE TABLE autorepairs ( +        date            date, +        repairs         varchar(80), +        location        varchar(80), +        cost            numeric(6,2) +); +``` + +我本可以在一行内输入,但为了更好地说明结构,并表明 PostgreSQL 不会解释制表符和换行的空白,我分成了多行。字段包含在括号中,每个变量名和数据类型与下一个变量用逗号分隔(最后一个除外),命令以分号结尾。所有命令都必须以分号结尾! + +第一个变量名是 `date`,它的数据类型也是 `date`,这在 PostgreSQL 中没关系。第二个和第三个变量 `repairs` 和 `location` 都是 `varchar(80)` 类型,这意味着它们可以是最多 80 个任意字符(字母、数字等)。最后一个变量 `cost` 使用 `numeric` 类型。括号中的数字表示最多有六位数字,其中两位是小数。最初,我尝试了 `real` 类型,这将是一个浮点数。`real` 类型的问题是作为数据类型在使用时,在遇到 `WHERE` 子句,类似 `WHERE cost = 0` 或其他任何特定数字。由于 `real` 值有些不精确,因此特定数字将永远不会匹配。 + +### 输入数据 + +接下来,你可以使用 `INSERT INTO` 命令添加一些数据(在 PostgreSQL 中称为*行*): + +``` +INSERT INTO autorepairs VALUES ('2017-08-11', 'airbag recall', 'dealer', 0); +``` + +请注意,括号构成了一个值的容器,它必须以正确的顺序,用逗号分隔,并在命令末尾加上分号。`date` 和 `varchar(80)` 类型的值必须包含在单引号中,但数字值(如 `numeric`)不用。作为反馈,你应该会看到: + +``` +INSERT 0 1 +``` + +与常规终端会话一样,你会有输入命令的历史记录,因此,在输入后续行时,通常可以按向上箭头键来显示最后一个命令并根据需要编辑数据,从而节省大量时间。 + +如果出了什么问题怎么办?使用 `UPDATE` 更改值: + +``` +UPDATE autorepairs SET date = '2017-11-08' WHERE repairs = 'airbag recall'; +``` + +或者,也许你不再需要表中的行。使用 `DELETE`: + +``` +DELETE FROM autorepairs WHERE repairs = 'airbag recall'; +``` + +这将删除整行。 + +最后一件事:即使我在 PostgreSQL 命令中一直使用大写字母(在大多数文档中也这么做),你也可以用小写字母输入,我也经常如此。 + +### 输出数据 + +如果你想展示数据,使用 `SELECT`: + +``` +SELECT * FROM autorepairs ORDER BY date; +``` + +没有 `ORDER BY` 的话,行将不管你输入的内容来显示。例如,以下就是我终端中输出的我的汽车服务数据: + +``` +SELECT date, repairs FROM autorepairs ORDER BY date; + +    date   |                             repairs                              +-----------+----------------------------------------------------------------- +2008-08-08 | oil change, air filter, spark plugs +2011-09-30 | 35000 service, oil change, rotate tires/balance wheels +2012-03-07 | repl battery +2012-11-14 | 45000 maint, oil/filter +2014-04-09 | 55000 maint, oil/filter, spark plugs, air/dust filters +2014-04-21 | replace 4 tires +2014-04-21 | wheel alignment +2016-06-01 | 65000 mile service, oil change +2017-05-16 | oil change, replce oil filt housing +2017-05-26 | rotate tires +2017-06-05 | air filter, cabin filter,spark plugs +2017-06-05 | brake pads and rotors, flush brakes +2017-08-11 | airbag recall +2018-07-06 | oil/filter change, fuel filter, battery svc +2018-07-06 | transmission fl, p steering fl, rear diff fl +2019-07-22 | oil & filter change, brake fluid flush, front differential flush +2019-08-20 | replace 4 tires +2019-10-09 | replace passenger taillight bulb +2019-10-25 | replace passenger taillight assembly +(19 rows) +``` + +要将此发送到文件,将输出更改为: + + +``` +\o autorepairs.txt +``` + +然后再次运行 `SELECT` 命令。 + +### 退出 PostgreSQL + +最后,在终端中退出 PostgreSQL,输入: + +``` +quit +``` + +或者它的缩写版: + +``` +\q +``` + +虽然这只是 PostgreSQL 的简要介绍,但我希望它展示了将数据库用于这样的简单任务既不困难也不费时。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/getting-started-postgresql + +作者:[Greg Pittman][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/greg-p +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_code_programming_laptop.jpg?itok=ormv35tV (Guy on a laptop on a building) +[2]: https://www.postgresql.org/ +[3]: http://www.postgresql.org/docs diff --git a/published/20191113 Getting Started With ZFS Filesystem on Ubuntu 19.10.md b/published/20191113 Getting Started With ZFS Filesystem on Ubuntu 19.10.md new file mode 100644 index 0000000000..f416b4e5b7 --- /dev/null +++ b/published/20191113 Getting Started With ZFS Filesystem on Ubuntu 19.10.md @@ -0,0 +1,166 @@ +[#]: collector: (lujun9972) +[#]: translator: (guevaraya) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11598-1.html) +[#]: subject: (Getting Started With ZFS Filesystem on Ubuntu 19.10) +[#]: via: (https://itsfoss.com/zfs-ubuntu/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +在 Ubuntu 19.10 上入门 ZFS 文件系统 +====== + +![][4] + +Ubuntu 19.10 的主要新特性之一就是 [ZFS][2]。现在你可以很容易的无需额外努力就可以在 Ubuntu 系统上安装 ZFS了。 + +一般情况下,安装 Linux 都会选择 Ext4 文件系统。但是如果是全新安装 Ubuntu 19.10,在安装的启动阶段可以看到 ZFS 选项。 + +![你可以在安装 Ubuntu 19.10 的时候选择 ZFS][3] + +让我们看看 ZFS 为何重要,以及如何在已经安装了 ZFS 的 Ubuntu 上使用它。 + +### ZFS 与其他文件系统有哪些区别? + +ZFS 的设计初衷是:处理海量存储和避免数据损坏。ZFS 可以处理 256 千万亿的 ZB 数据。(这就是 ZFS 的 Z)且它可以处理最大 16 EB 的文件。 + +如果你仅有一个单磁盘的笔记本电脑,你可以体验 ZFS 的数据保护特性。写时复制(COW)特性确保正在使用的数据不会被覆盖,相反,新的数据会被写到一个新的块中,同时文件系统的元数据会被更新到新块中。ZFS 可容易的创建文件系统的快照。这个快照可追踪文件系统的更改,并共享数据块确保节省数据空间。 + +ZFS 为磁盘上的每个文件分配一个校验和。它会不断的校验文件的状态和校验和。如果发现文件被损坏了,它就会尝试修复文件。 + +我写过一个文章详细介绍 [什么是 ZFS以及它有哪些特性][2]。如果你感兴趣可以去阅读下。 + +注:请谨记 ZFS 的数据保护特性会导致性能下降。 + +### Ubuntu 下使用 ZFS [适用于中高级用户] + +一旦你在你的主磁盘上全新安装了带有 ZFS 的 Ubuntu,你就可以开始体验它的特性。 + +请注意所有的 ZFS 设置过程都需要命令行。我不知道它有任何 GUI 工具。 + +#### 创建一个 ZFS 池 + +**这段仅针对拥有多个磁盘的系统。如果你只有一个磁盘,Ubuntu 会在安装的时候自动创建池。** + +在创建池之前,你需要为池找到磁盘的 id。你可以用命令 `lsblk` 查询出这个信息。 + +为三个磁盘创建一个基础池,用以下命令: + +``` +sudo zpool create pool-test /dev/sdb /dev/sdc /dev/sdd +``` + +请记得替换 `pool-test` 为你选择的的命名。 + +这个命令将会设置“无冗余 RAID-0 池”。这意味着如果一个磁盘被破坏或有故障,你将会丢失数据。如果你执行以上命令,还是建议做一个常规备份。 + +你可以用下面命令将另一个磁盘增加到池中: + +``` +sudo zpool add pool-name /dev/sdx +``` + +#### 查看 ZFS 池的状态 + +你可以用这个命令查询新建池的状态: + +``` +sudo zpool status pool-test +``` + +![Zpool 状态][6] + +#### 镜像一个 ZFS 池 + +为确保数据的安全性,你可以创建镜像。镜像意味着每个磁盘包含同样的数据。使用镜像设置,你可能会丢失三个磁盘中的两个,并且仍然拥有所有信息。 + +要创建镜像你可以用下面命令: + +``` +sudo zpool create pool-test mirror /dev/sdb /dev/sdc /dev/sdd +``` + +#### 创建 ZFS 用于备份恢复的快照 + +快照允许你创建一个后备,以防某个文件被删除或被覆盖。比如,我们创建一个快照,当在用户主目录下删除一些目录后,然后把它恢复。 + +首先,你需要找到你想要的快照数据集。你可以这样做: + +``` +zfs list +``` + +![Zfs List][7] + +你可以看到我的家目录位于 `rpool/USERDATA/johnblood_uwcjk7`。 + +我们用下面命令创建一个名叫 `1910` 的快照: + +``` +sudo zfs snapshot rpool/USERDATA/johnblood_uwcjk7@1019 +``` + +快照很快创建完成。现在你可以删除 `Downloads` 和 `Documents` 目录。 + +现在你用以下命令恢复快照: + +``` +sudo zfs rollback rpool/USERDATA/johnblood_uwcjk7@1019 +``` + +回滚的时间长短取决于有多少信息改变。现在你可以查看家目录,被删除的目录(和它的内容)将会被恢复过来。 + +### 要不要试试 ZFS ? + +这篇文章仅简单介绍的 Ubuntu下 ZFS 的用法。更多的信息请参考 [Ubuntu 的 ZFS Wiki页面][5]。我也推荐阅读 [ArsTechnica 的精彩文章][8]。 + +这个是试验性的功能。如果你还不了解 ZFS,你想用一个简单稳定的系统,请安装标准文件系统 EXT4。如果你想用闲置的机器体验,可以参照上面了解 ZFS。如果你是一个“专家”,并且知道自己在做什么,则可以随时随地随意尝试ZFS。 + +你之前用过 ZFS 吗?请在下面留言。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/zfs-ubuntu/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[guevaraya](https://github.com/guevaraya) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/ubuntu-19-04-release-features/ +[2]: https://itsfoss.com/what-is-zfs/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/zfs-ubuntu-19-10.jpg?ssl=1 +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/Using_ZFS_Ubuntu.jpg?resize=800%2C450&ssl=1 +[5]: https://wiki.ubuntu.com/Kernel/Reference/ZFS +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/zpool-status.png?ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/zfs-list.png?ssl=1 +[8]: https://arstechnica.com/information-technology/2019/10/a-detailed-look-at-ubuntus-new-experimental-zfs-installer/ +[9]: https://reddit.com/r/linuxusersgroup + 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][9]. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/zfs-ubuntu/ + +作者:[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://itsfoss.com/ubuntu-19-04-release-features/ +[2]: https://linux.cn/article-10034-1.html +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/zfs-ubuntu-19-10.jpg?ssl=1 +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/Using_ZFS_Ubuntu.jpg?resize=800%2C450&ssl=1 +[5]: https://wiki.ubuntu.com/Kernel/Reference/ZFS +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/zpool-status.png?ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/zfs-list.png?ssl=1 +[8]: https://arstechnica.com/information-technology/2019/10/a-detailed-look-at-ubuntus-new-experimental-zfs-installer/ +[9]: https://reddit.com/r/linuxusersgroup diff --git a/published/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md b/published/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md new file mode 100644 index 0000000000..6fa7ef3d4f --- /dev/null +++ b/published/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md @@ -0,0 +1,345 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11597-1.html) +[#]: subject: (How to install and Configure Postfix Mail Server on CentOS 8) +[#]: via: (https://www.linuxtechi.com/install-configure-postfix-mailserver-centos-8/) +[#]: author: (James Kiarie https://www.linuxtechi.com/author/james/) + +如何在 CentOS 8 上安装和配置 Postfix 邮件服务器 +====== + +Postfix 是一个自由开源的 MTA(邮件传输代理),用于在 Linux 系统上路由或传递电子邮件。在本指南中,你将学习如何在 CentOS 8 上安装和配置 Postfix。 + +![Install-configure-Postfx-Server-CentOS8][2] + +实验室设置: + + * 系统:CentOS 8 服务器 + * IP 地址:192.168.1.13 + * 主机名:server1.crazytechgeek.info(确保域名指向服务器的 IP) + +### 步骤 1)更新系统 + +第一步是确保系统软件包是最新的。为此,请按如下所示更新系统: + +``` +# dnf update +``` + +继续之前,还请确保不存在其他 MTA(如 Sendmail),因为这将导致与 Postfix 配置冲突。例如,要删除 Sendmail,请运行以下命令: + +``` +# dnf remove sendmail +``` + +### 步骤 2)设置主机名并更新 /etc/hosts + +使用下面的 `hostnamectl` 命令在系统上设置主机名: + +``` +# hostnamectl set-hostname server1.crazytechgeek.info +# exec bash +``` + +此外,你需要在 `/etc/hosts` 中添加系统的主机名和 IP: + +``` +# vim /etc/hosts +192.168.1.13 server1.crazytechgeek.info +``` + +保存并退出文件。 + +### 步骤 3)安装 Postfix 邮件服务器 + +验证系统上没有其他 MTA 在运行后,运行以下命令安装 Postfix: + +``` +# dnf install postfix +``` + +![Install-Postfix-Centos8][3] + +### 步骤 4)启动并启用 Postfix 服务 + +成功安装 Postfix 后,运行以下命令启动并启用 Postfix 服务: + +``` +# systemctl start postfix +# systemctl enable postfix +``` + +要检查 Postfix 状态,请运行以下 `systemctl` 命令: + +``` +# systemctl status postfix +``` + +![Start-Postfix-check-status-centos8][9] + +太好了,我们已经验证了 Postfix 已启动并正在运行。接下来,我们将配置 Postfix 从本地发送邮件到我们的服务器。 + +### 步骤 5)安装 mailx 邮件客户端 + +在配置 Postfix 服务器之前,我们需要安装 `mailx`,要安装它,请运行以下命令: + +``` +# dnf install mailx +``` + +![Install-Mailx-CentOS8][10] + +### 步骤 6)配置 Postfix 邮件服务器 + +Postfix 的配置文件位于 `/etc/postfix/main.cf` 中。我们需要对配置文件进行一些修改,因此请使用你喜欢的文本编辑器将其打开: + +``` +# vi /etc/postfix/main.cf +``` + +更改以下几行: + +``` +myhostname = server1.crazytechgeek.info +mydomain = crazytechgeek.info +myorigin = $mydomain +## 取消注释并将 inet_interfaces 设置为 all## +inet_interfaces = all +## 更改为 all ## +inet_protocols = all +## 注释 ## +#mydestination = $myhostname, localhost.$mydomain, localhost +## 取消注释 ## +mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain +## 取消注释并添加 IP 范围 ## +mynetworks = 192.168.1.0/24, 127.0.0.0/8 +## 取消注释 ## +home_mailbox = Maildir/ +``` + +完成后,保存并退出配置文件。重新启动 postfix 服务以使更改生效: + +``` +# systemctl restart postfix +``` + +### 步骤 7)测试 Postfix 邮件服务器 + +测试我们的配置是否有效,首先,创建一个测试用户。 + +``` +# useradd postfixuser +# passwd postfixuser +``` + +接下来,运行以下命令,从本地用户 `pkumar` 发送邮件到另一个用户 `postfixuser`。 + +``` +# telnet localhost smtp +或者 +# telnet localhost 25 +``` + +如果未安装 telnet 服务,那么可以使用以下命令进行安装: + +``` +# dnf install telnet -y +``` + +如前所述运行命令时,应获得如下输出: + +``` +[root@linuxtechi ~]# telnet localhost 25 +Trying 127.0.0.1... +Connected to localhost. +Escape character is '^]'. +220 server1.crazytechgeek.info ESMTP Postfix +``` + +上面的结果确认与 postfix 邮件服务器的连接正常。接下来,输入命令: + +``` +# ehlo localhost +``` + +输出看上去像这样: + +``` +250-server1.crazytechgeek.info +250-PIPELINING +250-SIZE 10240000 +250-VRFY +250-ETRN +250-STARTTLS +250-ENHANCEDSTATUSCODES +250-8BITMIME +250-DSN +250 SMTPUTF8 +``` + +接下来,运行橙色高亮的命令,例如 `mail from`、`rcpt to`、`data`,最后输入 `quit`: + +``` +mail from: +250 2.1.0 Ok +rcpt to: +250 2.1.5 Ok +data +354 End data with . +Hello, Welcome to my mailserver (Postfix) +. +250 2.0.0 Ok: queued as B56BF1189BEC +quit +221 2.0.0 Bye +Connection closed by foreign host +``` + +完成 `telnet` 命令可从本地用户 `pkumar` 发送邮件到另一个本地用户 `postfixuser`,如下所示: + +![Send-email-with-telnet-centos8][11] + +如果一切都按计划进行,那么你应该可以在新用户的家目录中查看发送的邮件: + +``` +# ls /home/postfixuser/Maildir/new +1573580091.Vfd02I20050b8M635437.server1.crazytechgeek.info +# +``` + +要阅读邮件,只需使用 cat 命令,如下所示: + +``` +# cat /home/postfixuser/Maildir/new/1573580091.Vfd02I20050b8M635437.server1.crazytechgeek.info +``` + +![Read-postfix-email-linux][12] + +### Postfix 邮件服务器日志 + +Postfix 邮件服务器邮件日志保存在文件 `/var/log/maillog` 中,使用以下命令查看实时日志, + +``` +# tail -f /var/log/maillog +``` + +![postfix-maillogs-centos8][13] + +### 保护 Postfix 邮件服务器 + +建议始终确保客户端和 Postfix 服务器之间的通信安全,这可以使用 SSL 证书来实现,它们可以来自受信任的权威机构或自签名证书。在本教程中,我们将使用 `openssl` 命令生成用于 Postfix 的自签名证书, + +我假设 `openssl` 已经安装在你的系统上,如果未安装,请使用以下 `dnf` 命令: + +``` +# dnf install openssl -y +``` + +使用下面的 `openssl` 命令生成私钥和 CSR(证书签名请求): + +``` +# openssl req -nodes -newkey rsa:2048 -keyout mail.key -out mail.csr +``` + +![Postfix-Key-CSR-CentOS8][14] + +现在,使用以下 openssl 命令生成自签名证书: + +``` +# openssl x509 -req -days 365 -in mail.csr -signkey mail.key -out mail.crt +Signature ok +subject=C = IN, ST = New Delhi, L = New Delhi, O = IT, OU = IT, CN = server1.crazytechgeek.info, emailAddress = root@linuxtechi +Getting Private key +# +``` + +现在将私钥和证书文件复制到 `/etc/postfix` 目录下: + +``` +# cp mail.key mail.crt /etc/postfix +``` + +在 Postfix 配置文件中更新私钥和证书文件的路径: + +``` +# vi /etc/postfix/main.cf +……… +smtpd_use_tls = yes +smtpd_tls_cert_file = /etc/postfix/mail.crt +smtpd_tls_key_file = /etc/postfix/mail.key +smtpd_tls_security_level = may +……… +``` + +重启 Postfix 服务以使上述更改生效: + +``` +# systemctl restart postfix +``` + +让我们尝试使用 `mailx` 客户端将邮件发送到内部本地域和外部域。 + +从 `pkumar` 发送内部本地邮件到 `postfixuser` 中: + +``` +# echo "test email" | mailx -s "Test email from Postfix MailServer" -r root@linuxtechi root@linuxtechi +``` + +使用以下命令检查并阅读邮件: + +``` +# cd /home/postfixuser/Maildir/new/ +# ll +total 8 +-rw-------. 1 postfixuser postfixuser 476 Nov 12 17:34 1573580091.Vfd02I20050b8M635437.server1.crazytechgeek.info +-rw-------. 1 postfixuser postfixuser 612 Nov 13 02:40 1573612845.Vfd02I20050bbM466643.server1.crazytechgeek.info +# cat 1573612845.Vfd02I20050bbM466643.server1.crazytechgeek.info +``` + +![Read-Postfixuser-Email-CentOS8][15] + +从 `postfixuser` 发送邮件到外部域(`root@linuxtechi.com`): + +``` +# echo "External Test email" | mailx -s "Postfix MailServer" -r root@linuxtechi root@linuxtechi +``` + +注意:如果你的 IP 没有被任何地方列入黑名单,那么你发送到外部域的邮件将被发送,否则它将被退回,并提示你的 IP 被 spamhaus 之类的数据库列入黑名单。 + +### 检查 Postfix 邮件队列 + +使用 `mailq` 命令列出队列中的邮件: + +``` +# mailq +Mail queue is empty +# +``` + +完成!我们的 Postfix 配置正常工作了!目前就这样了。我们希望你觉得本教程有见地,并且你可以轻松地设置本地 Postfix 服务器。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/install-configure-postfix-mailserver-centos-8/ + +作者:[James Kiarie][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/james/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Install-configure-Postfx-Server-CentOS8.jpg +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Install-Postfix-Centos8.png +[4]: https://www.linuxtechi.com/cdn-cgi/l/email-protection +[9]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Start-Postfix-check-status-centos8.png +[10]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Install-Mailx-CentOS8.png +[11]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Send-email-with-telnet-centos8.png +[12]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Read-postfix-email-linux.png +[13]: https://www.linuxtechi.com/wp-content/uploads/2019/11/postfix-maillogs-centos8.png +[14]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Postfix-Key-CSR-CentOS8.png +[15]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Read-Postfixuser-Email-CentOS8.png diff --git a/published/20191114 Cleaning up with apt-get.md b/published/20191114 Cleaning up with apt-get.md new file mode 100644 index 0000000000..7ae6d9779b --- /dev/null +++ b/published/20191114 Cleaning up with apt-get.md @@ -0,0 +1,87 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11601-1.html) +[#]: subject: (Cleaning up with apt-get) +[#]: via: (https://www.networkworld.com/article/3453032/cleaning-up-with-apt-get.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +使用 apt-get 清理 +====== + +> 大多数使用基于 Debian 的系统的人通常会使用 apt-get 来安装软件包和升级,但是我们多久才清理一次?让我们看下该工具本身的一些清理选项。 + +![](https://img.linux.net.cn/data/attachment/album/201911/22/082025p39oeuufdote517e.jpg) + +在基于 Debian 的系统上运行 `apt-get` 命令是很常规的。软件包的更新相当频繁,诸如 `apt-get update` 和 `apt-get upgrade` 之类的命令使此过程非常容易。另一方面,你多久使用一次 `apt-get clean`、`apt-get autoclean` 或 `apt-get autoremove`? + +这些命令会在 `apt-get` 的安装操作后清理并删除仍在系统上但不再需要的文件,这通常是因为需要它们的程序已经卸载。 + +### apt-get clean + +`apt-get clean` 命令清除遗留在 `/var/cache` 中的已取回的包文件的本地仓库。它清除的目录是 `/var/cache/apt/archives/` 和 `/var/cache/apt/archives/partial/`。它留在 `/var/cache/apt/archives` 中的唯一文件是 `lock` 文件和 `partial` 子目录。 + +在运行清理操作之前,目录中可能包含许多文件: + +``` +/var/cache/apt/archives/db5.3-util_5.3.28+dfsg1-0.6ubuntu1_amd64.deb +/var/cache/apt/archives/db-util_1%3a5.3.21~exp1ubuntu2_all.deb +/var/cache/apt/archives/lock +/var/cache/apt/archives/postfix_3.4.5-1ubuntu1_amd64.deb +/var/cache/apt/archives/sasl2-bin_2.1.27+dfsg-1build3_amd64.deb +``` + +之后,只会存在这些: + +``` +$ sudo ls -lR /var/cache/apt/archives +/var/cache/apt/archives: +total 4 +-rw-r----- 1 root root 0 Jan 5 2018 lock +drwx------ 2 _apt root 4096 Nov 12 07:24 partial + +/var/cache/apt/archives/partial: +total 0 <== 空 +``` + +`apt-get clean` 命令通常用于根据需要清除磁盘空间,一般作为定期计划维护的一部分。 + +### apt-get autoclean + +`apt-get autoclean` 类似于 `apt-get clean`,它会清除已检索包文件的本地仓库,但它只会删除不会再下载且几乎无用的文件。它有助于防止缓存过大。 + +### apt-get autoremove + +`apt-get autoremove` 将删除自动安装的软件包,因为某些其他软件包需要它们,但是在删除了其他软件包之后,而不再需要它们。有时会在升级时建议运行此命令。 + +``` +The following packages were automatically installed and are no longer required: + g++-8 gir1.2-mutter-4 libapache2-mod-php7.2 libcrystalhd3 + libdouble-conversion1 libgnome-desktop-3-17 libigdgmm5 libisl19 libllvm8 + liblouisutdml8 libmutter-4-0 libmysqlclient20 libpoppler85 libstdc++-8-dev + libtagc0 libvpx5 libx265-165 php7.2 php7.2-cli php7.2-common php7.2-json + php7.2-opcache php7.2-readline +Use 'sudo apt autoremove' to remove them. <== +``` + +要删除的软件包通常称为“未使用的依赖项”。实际上,一个好的做法是在卸载软件包后使用 `autoremove`,以确保不会留下不需要的文件。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3453032/cleaning-up-with-apt-get.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://unsplash.com/photos/nbKaLT4cmRM +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.networkworld.com/newsletters/signup.html +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/20191114 Microsoft Defender ATP is Coming to Linux- What Does it Mean.md b/published/20191114 Microsoft Defender ATP is Coming to Linux- What Does it Mean.md new file mode 100644 index 0000000000..4c755bdcf7 --- /dev/null +++ b/published/20191114 Microsoft Defender ATP is Coming to Linux- What Does it Mean.md @@ -0,0 +1,66 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11576-1.html) +[#]: subject: (Microsoft Defender ATP is Coming to Linux! What Does it Mean?) +[#]: via: (https://itsfoss.com/microsoft-defender-atp-linux/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +微软 Defender ATP 要出 Linux 版了! +====== + +> 微软宣布将于 2020 年将其企业安全产品 Defender 高级威胁防护(ATP)引入 Linux。 + +![](https://img.linux.net.cn/data/attachment/album/201911/14/183733rllau7hvkgzkuwgg.jpg) + +微软的年度开发者大会 Microsoft Ignite 刚刚结束,会上发布了一些与 Linux 有关的重要公告。你可能已经知道[微软将 Edge Web 浏览器引入 Linux][1],而下一个大新闻是微软将 Defender ATP 引入 Linux! + +让我们详细介绍一下它是什么,以及微软为何不厌其烦为 Linux 开发某些东西。 + +### 微软 Defender ATP 是什么? + +如果你过去几年使用过 Windows,那么你一定遇到过 Windows Defender。它基本上可以说是微软的防病毒产品,通过检测病毒和恶意软件来提供一定程度的安全性。 + +微软通过引入 Windows Defender ATP(高级威胁防护)来为其企业用户改进了此功能。Defender ATP 致力于行为分析。它收集使用使用数据并将其存储在同一系统上。但是,当发现行为不一致时,它将数据发送到 Azure 服务(微软的云服务)。在这里,它将收集行为数据和异常信息。 + +例如,如果你收到一封包含 PDF 附件的电子邮件,你将其打开并打开了命令提示符,Defender ATP 就会注意到此异常行为。我建议[阅读本文以了解有关 Defender 和 Defender ATP 之间的区别的更多信息] [2]。 + +现在,这完全是一种企业级产品。在具有成百上千个端点(计算机)的大型企业中,Defender ATP 提供了很好的保护层。IT 管理员可以在其 Azure 实例上集中查看端点的视图,可以分析威胁并采取相应措施。 + +### 适用于 Linux(和 Mac)的微软 Defender ATP + +通常,企业的计算机上装有 Windows,但 Mac 和 Linux 在开发人员中也特别受欢迎。在混合了 Mac 和 Linux 的 Windows 机器环境中,Defender ATP 必须将其服务扩展到这些操作系统,以便它可以为网络上的所有设备提供整体防御。 + +请注意,微软先是[在 2019 年 3 月将 Windows Defender ATP 更改为微软 Defender ATP][3],这表明该产品不仅限于 Windows 操作系统。 + +此后不久微软[宣布推出 Mac 版 Defender ATP][4]。 + +现在,为了涵盖企业环境中的所有主要操作系统,[微软将于 2020 年将 Defender ATP 引入到 Linux][5]。 + +### Linux 上的微软 Defender ATP 对 Linux 用户有何影响? + +由于 Defender ATP 是企业产品,因此我认为你无需为此而烦恼。组织需要保护其端点免受威胁,因此,微软也在改进其产品以使其涵盖 Linux。 + +对于像你我这样的普通 Linux 用户,这没有任何区别。我不会用它“保护”我的三个 Linux 系统,并为此而向微软付费。 + +请随时在评论部分中分享你对微软将 Defender ATP 引入 Linux 的看法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/microsoft-defender-atp-linux/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/microsoft-edge-linux/ +[2]: https://www.concurrency.com/blog/november-2017/windows-defender-vs-windows-defender-atp +[3]: https://www.theregister.co.uk/2019/03/21/microsoft_defender_atp/ +[4]: https://techcommunity.microsoft.com/t5/Microsoft-Defender-ATP/Announcing-Microsoft-Defender-ATP-for-Mac/ba-p/378010 +[5]: https://www.zdnet.com/article/microsoft-defender-atp-is-coming-to-linux-in-2020/ diff --git a/published/20191114 Red Hat Responds to Zombieload v2.md b/published/20191114 Red Hat Responds to Zombieload v2.md new file mode 100644 index 0000000000..ef755c9c78 --- /dev/null +++ b/published/20191114 Red Hat Responds to Zombieload v2.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11583-1.html) +[#]: subject: (Red Hat Responds to Zombieload v2) +[#]: via: (https://www.networkworld.com/article/3453596/red-hat-responds-to-zombieload-v2.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +红帽对 Zombieload v2 缺陷的应对 +====== +![](https://images.techhive.com/images/article/2015/10/20151027-red-hat-logo-100625237-large.jpg) + +> 红帽呼吁更新 Linux 软件,以解决可能导致数据盗用的英特尔处理器缺陷。 + +前两天公开的三个“常见漏洞和披露”(CVE)跟踪的是某些英特尔处理器中的三个漏洞,如果利用这些漏洞,可能会使敏感数据面临风险。 + +在报告的缺陷中,新发现的英特尔处理器缺陷是今年早些时候发现的 Zombieload 攻击的变种,并且仅会影响英特尔的 Cascade Lake 芯片。 + +红帽强烈建议,所有的红帽系统即使不认为其配置构成直接威胁,也要对其进行更新,并且红帽正在向其客户和企业 IT 社区提供资源。 + +这三个 CVE 是: + +* CVE-2018-12207:页面大小更改时的机器检查错误 +* CVE-2019-11135:TSX异步中止 +* CVE-2019-0155 和 CVE-2019-0154:i915 图形驱动程序 + +### CVE-2018-12207 + +红帽将该漏洞评为重要。此漏洞可能使本地和非特权的攻击者绕过安全控制并导致系统范围的拒绝服务。 + +硬件缺陷是在英特尔微处理器中发现的,并且与指令翻译后备缓冲区(ITLB)有关。它缓存从虚拟地址到物理地址的转换,旨在提高性能。但是,在缓存页面更改后,使缓存的条目无效的延迟可能导致处理器使用无效的地址转换,从而导致机器检查错误异常并使系统进入挂起状态。 + +攻击者可以制作这种情况来关闭系统。 + +### CVE-2019-11135 + +红帽将此漏洞评为中级。这个事务同步扩展(TSX)异步中止是一个微体系结构数据采样(MDS)缺陷。使用定制代码的本地攻击者可以利用此漏洞从处理器以及支持同时多线程(SMT)和 TSX 的处理器上的缓存内容中收集信息。 + +### CVE-2019-0155,CVE-2019-0154 + +红帽将 CVE-2019-0155 漏洞评为重要,将 CVE-2019-0154 漏洞评为中级。这两个缺陷都与 i915 图形驱动程序有关。 + +CVE-2019-0155 允许攻击者绕过常规的内存安全限制,从而允许对应该受到限制的特权内存进行写访问。 + +当图形处理单元(GPU)处于低功耗模式时,CVE-2019-0154 可能允许本地攻击者创建无效的系统状态,从而导致系统无法访问。 + +唯一受 CVE-2019-0154 影响的的显卡在 i915 内核模块上受到影响。`lsmod` 命令可用于指示该漏洞。 如下所示的任何输出(即以 i915 开头)都表明该系统易受攻击: + +``` +$ lsmod | grep ^i915 +i915 2248704 10 +``` + +### 更多资源 + +红帽在以下链接中向其客户和其他人提供了详细信息和进一步的说明: + +- +- +- + + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3453596/red-hat-responds-to-zombieload-v2.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://access.redhat.com/solutions/tsx-asynchronousabort%20 +[4]: https://access.redhat.com/solutions/i915-graphics +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/20191115 Developing a Simple Web Application Using Flutter.md b/published/20191115 Developing a Simple Web Application Using Flutter.md new file mode 100644 index 0000000000..e52d81885a --- /dev/null +++ b/published/20191115 Developing a Simple Web Application Using Flutter.md @@ -0,0 +1,150 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11604-1.html) +[#]: subject: (Developing a Simple Web Application Using Flutter) +[#]: via: (https://opensourceforu.com/2019/11/developing-a-simple-web-application-using/) +[#]: author: (Jis Joe Mathew https://opensourceforu.com/author/jis-joe/) + +使用 Flutter 开发简单的 Web 应用 +====== + +![][2] + +> 本文指导读者如何使用 Flutter 运行和部署第一个 Web 应用。 + +Flutter 在 Android 和 iOS 开发方面走了很长一段路之后,已经迈入了一个新的阶段,即 Web 开发。Google 发布了 Flutter 1.5,同时支持 Web 应用开发。 + +### 为 Web 开发配置 Flutter + +为了使用 Web 包,输入命令 `flutter upgrade` 更新到 Flutter 1.5.4。 + + * 打开终端 + * 输入 `flutter upgrade` + * 输入 `flutter –version` 检查版本 + + +![图 1: 升级 Flutter 到最新版][3] + +也可以将 Android Studio 3.0 或更高版本用于 Flutter Web 开发,但在本教程中,我们使用 Visual Studio Code。 + +### 使用 Flutter Web 创建新项目 + +打开 Visual Studio Code,然后按 `Shift+Ctrl+P` 开始一个新项目。输入 `flutter` 并选择 “New Web Project”。 + +![图 2:在 VSC 中开始一个新的 Flatter 项目][4] + +现在,为项目命名。我将其命名为 `open_source_for_you`。 + +![图 3: 给项目命名][5] + +在 VSC 中打开终端窗口,然后输入以下命令: + +``` +flutter packages pub global activate webdev +flutter packages upgrade +``` + +现在,使用以下命令在 localhost 上运行网站,IP 地址是 127.0.0.1。 + +``` +flutter packages pub global run webdev serve +``` + +打开任何浏览器,然后输入 `http://127.0.0.1:8080/`。 + + +![图 4:运行于 8080 端口的 Flutter 演示应用][6] + +在项目目录中有个 Web 文件夹,其中包含了 `index.html`。`dart` 文件被编译成 JavaScript 文件,并使用以下代码包含在 HTML 文件中: + +``` + +``` + +### 编码和修改演示页面 + +让我们创建一个简单的应用,它会在网页上打印 “Welcome to OSFY”。 + +现在打开 Dart 文件,它位于 `lib` 文件夹 `main.dart`(默认名)中(参见图 5)。 + +![图 5:main.dart 文件的位置][7] + +现在,我们可以在 `MaterialApp` 的属性中删除调试标记,如下所示: + +``` +debugShowCheckedModeBanner: false +``` + +现在,向 Dart 中添加更多内容与用 Dart 编写 Flutter 很类似。为此,我们可以声明一个名为 `MyClass` 的类,它继承了 `StatelessWidget`。 + +我们使用 `Center` 部件将元素定位到中心。我们还可以添加 `Padding` 部件来添加填充。使用以下代码获得图 5 所示的输出。使用刷新按钮查看更改。 + +``` +class MyClass extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: EdgeInsets.all(20.0), + child: Text( + 'Welcome to OSFY', + style: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold), + ), + ), + ], + ), + ), + ); + } +} +``` + +![图 6:MyClass 的输出][8] + +让我们从互联网中添加一张图片,我已经从一个杂志网站选择了一张 “Open Source for You” 徽标。我们使用 `Image.network`。 + +``` +Image.network( + 'https://opensourceforu.com/wp-content/uploads/2014/03/OSFY-Logo.jpg', + height: 100, + width: 150 +), +``` + +最终输出如图 7 所示。 + +![图 7:最终输出][9] + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/developing-a-simple-web-application-using/ + +作者:[Jis Joe Mathew][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensourceforu.com/author/jis-joe/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Screenshot-from-2019-11-15-16-20-30.png +[2]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Screenshot-from-2019-11-15-16-20-30.png +[3]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-1-Upgrading-Flutter-to-the-latest-version.jpg +[4]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-2-Starting-a-new-Flutter-Web-project-in-VSC.jpg +[5]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-3-Naming-the-project.jpg +[6]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-4-The-Flutter-demo-application-running-on-port-8080.jpg +[7]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-5-Location-of-main.dart-file.jpg +[8]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-6-Output-of-MyClass.jpg +[9]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-7-Final-output.jpg +[10]: https://secure.gravatar.com/avatar/64db0e07799ae14fd1b51d0633db6593?s=100&r=g +[11]: https://opensourceforu.com/author/jis-joe/ +[12]: mailto:jisjoemathew@gmail.com +[13]: https://opensourceforu.com/wp-content/uploads/2019/11/assoc.png +[14]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/published/20191118 How containers work- overlayfs.md b/published/20191118 How containers work- overlayfs.md new file mode 100644 index 0000000000..294e55e42b --- /dev/null +++ b/published/20191118 How containers work- overlayfs.md @@ -0,0 +1,166 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11605-1.html) +[#]: subject: (How containers work: overlayfs) +[#]: via: (https://jvns.ca/blog/2019/11/18/how-containers-work--overlayfs/) +[#]: author: (Julia Evans https://jvns.ca/) + +容器如何工作:OverlayFS +====== + +今天早上,我为未来潜在容器[杂志][1]画了一幅 OverlayFS 的漫画,我对这个主题感到兴奋,想写一篇关于它的博客来提供更多详细信息。 + +![](https://jvns.ca/images/overlay.jpeg) + +### 容器镜像很大 + +容器镜像可能会很大(尽管有些很小,例如 [alpine linux 才 2.5MB][2])。Ubuntu 16.04 约为 27 MB,[Anaconda Python 发行版为 800MB 至 1.5GB][3]。 + +你以镜像启动的每个容器都是原始空白状态,仿佛它只是为使用容器而复制的一份镜像拷贝一样。但是对于大的容器镜像,像 800MB 的 Anaconda 镜像,复制一份拷贝既浪费磁盘空间也很慢。因此 Docker 不会复制,而是采用**叠加**。 + +### 叠加如何工作 + +OverlayFS,也被称为 **联合文件系统**或 **联合挂载**,它可让你使用 2 个目录挂载文件系统:“下层”目录和“上层”目录。 + +基本上: + + * 文件系统的**下层**目录是只读的 + * 文件系统的**上层**目录可以读写 + +当进程“读取”文件时,OverlayFS 文件系统驱动将在上层目录中查找并从该目录中读取文件(如果存在)。否则,它将在下层目录中查找。 + +当进程“写入”文件时,OverlayFS 会将其写入上层目录。 + +### 让我们使用 mount 制造一个叠加层! + +这有点抽象,所以让我们制作一个 OverlayFS 并尝试一下!这将只包含一些文件:我将创建上、下层目录,以及用来挂载合并的文件系统的 `merged ` 目录: + +``` +$ mkdir upper lower merged work +$ echo "I'm from lower!" > lower/in_lower.txt +$ echo "I'm from upper!" > upper/in_upper.txt +$ # `in_both` is in both directories +$ echo "I'm from lower!" > lower/in_both.txt +$ echo "I'm from upper!" > upper/in_both.txt +``` + +合并上层目录和下层目录非常容易:我们可以通过 `mount` 来完成! + +``` +$ sudo mount -t overlay overlay + -o lowerdir=/home/bork/test/lower,upperdir=/home/bork/test/upper,workdir=/home/bork/test/work + /home/bork/test/merged +``` + +在执行此操作时,我不断收到一条非常烦人的错误消息,内容为:`mount: /home/bork/test/merged: special device overlay does not exist.`。这条消息是错误的,实际上只是意味着我指定的一个目录缺失(我写成了 `~/test/merged`,但它没有被展开)。 + +让我们尝试从 OverlayFS 中读取其中一个文件!文件 `in_both.txt` 同时存在于 `lower/` 和 `upper/` 中,因此应从 `upper/` 目录中读取该文件。 + +``` +$ cat merged/in_both.txt +"I'm from upper! +``` + +可以成功! + +目录的内容就是我们所期望的: + +``` +find lower/ upper/ merged/ +lower/ +lower/in_lower.txt +lower/in_both.txt +upper/ +upper/in_upper.txt +upper/in_both.txt +merged/ +merged/in_lower.txt +merged/in_both.txt +merged/in_upper.txt +``` + +### 创建新文件时会发生什么? + +``` +$ echo 'new file' > merged/new_file +$ ls -l */new_file +-rw-r--r-- 1 bork bork 9 Nov 18 14:24 merged/new_file +-rw-r--r-- 1 bork bork 9 Nov 18 14:24 upper/new_file +``` + +这是有作用的,新文件会在 `upper` 目录创建。 + +### 删除文件时会发生什么? + +读写似乎很简单。但是删除会发生什么?开始试试! + +``` +$ rm merged/in_both.txt +``` + +发生了什么?让我们用 `ls` 看下: + +``` +ls -l upper/in_both.txt lower/lower1.txt merged/lower1.txt +ls: cannot access 'merged/in_both.txt': No such file or directory +-rw-r--r-- 1 bork bork 6 Nov 18 14:09 lower/in_both.txt +c--------- 1 root root 0, 0 Nov 18 14:19 upper/in_both.txt +``` + +所以: + + * `in_both.txt` 仍在 `lower` 目录中,并且保持不变 + * 它不在 `merged` 目录中。到目前为止,这就是我们所期望的。 + * 但是在 `upper` 中发生的事情有点奇怪:有一个名为 `upper/in_both.txt` 的文件,但是它是字符设备?我想这就是 overlayfs 驱动表示删除的文件的方式。 + +如果我们尝试复制这个奇怪的字符设备文件,会发生什么? + +``` +$ sudo cp upper/in_both.txt upper/in_lower.txt +cp: cannot open 'upper/in_both.txt' for reading: No such device or address +``` + +好吧,这似乎很合理,复制这个奇怪的删除信号文件并没有任何意义。 + +### 你可以挂载多个“下层”目录 + +Docker 镜像通常由 25 个“层”组成。OverlayFS 支持具有多个下层目录,因此你可以运行: + +``` +mount -t overlay overlay + -o lowerdir:/dir1:/dir2:/dir3:...:/dir25,upperdir=... +``` + +因此,我假设这是有多个 Docker 层的容器的工作方式,它只是将每个层解压缩到一个单独的目录中,然后要求 OverlayFS 将它们全部合并在一起,并使用一个空的上层目录,容器将对其进行更改。 + +### Docker 也可以使用 btrfs 快照 + +现在,我使用的是 ext4,而 Docker 使用 OverlayFS 快照来运行容器。但是我曾经用过 btrfs,接着 Docker 将改为使用 btrfs 的写时复制快照。(这是 Docker 何时使用哪种[存储驱动][4]的列表) + +以这种方式使用 btrfs 快照会产生一些有趣的结果:去年某个时候,我在笔记本上运行了数百个临时的 Docker 容器,这导致我用尽了 btrfs 元数据空间(像[这个人][5]一样)。这真的很令人困惑,因为我以前从未听说过 btrfs 元数据,而且弄清楚如何清理文件系统以便再次运行 Docker 容器非常棘手。([这个 docker github 上的提案][6]描述了 Docker 和 btrfs 的类似问题) + +### 以简单的方式尝试容器功能很有趣! + +我认为容器通常看起来像是在做“复杂的”事情,我认为将它们分解成这样很有趣。你可以运行一条 `mount` 咒语,而实际上并没有做任何与容器相关的其他事情,看看叠加层是如何工作的! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/11/18/how-containers-work--overlayfs/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://wizardzines.com +[2]: https://hub.docker.com/_/alpine?tab=tags +[3]: https://hub.docker.com/r/continuumio/anaconda3/tags +[4]: https://docs.docker.com/storage/storagedriver/select-storage-driver/ +[5]: https://www.reddit.com/r/archlinux/comments/5jrmfe/btrfs_metadata_and_docker/ +[6]: https://github.com/moby/moby/issues/27653 diff --git a/published/20191119 How to use pkgsrc on Linux.md b/published/20191119 How to use pkgsrc on Linux.md new file mode 100644 index 0000000000..8ca44c9dcc --- /dev/null +++ b/published/20191119 How to use pkgsrc on Linux.md @@ -0,0 +1,204 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11613-1.html) +[#]: subject: (How to use pkgsrc on Linux) +[#]: via: (https://opensource.com/article/19/11/pkgsrc-netbsd-linux) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何在 Linux 上使用 pkgsrc +====== + +> NetBSD 的软件包管理器通用、灵活又容易。下面是如何使用它。 + +![](https://img.linux.net.cn/data/attachment/album/201911/26/064538fbktfzxba18wykde.jpg) + +NetBSD 以能在几乎所有平台上运行而闻名,但你知道它*第二*有名的 [pkgsrc][2] 包管理器吗?像 NetBSD 一样,pkgsrc 基本上可以在任何系统上运行,或者至少在任意 Unix 和类 Unix 的系统上上运行。你可以在 BSD、Linux、Illumos、Solaris 和 Mac 上安装 pkgsrc。它总共支持 20 多种操作系统。 + +### 为什么使用 pkgsrc? + +除了 MacOS 之外,所有 Unix 操作系统均自带包管理器。你不一定*需要* pkgsrc,但这可能是你想尝试的三个重要原因: + +* **打包**。如果你对打包感到好奇,但尚未尝试自己创建一个软件包,那么 pkgsrc 是一个相对简单的系统,尤其是如果你已经熟悉 Makefile 和类似 [GNU Autotools][3] 之类的构建系统时。 +* **通用**。如果你使用多个操作系统或发行版,那么可能会遇到每个系统的包管理器。你可以在不同的系统上使用 pkgsrc,以便你为一个系统打包了程序,就为所有系统打包了。 +* **灵活**。在许多打包系统中,如何选择二进制包或源码包并不总是很明显。使用 pkgsrc,区别很明显,两种安装方法都一样容易,并且都可以为你解决依赖关系。 + +### 如何安装 pkgsrc + +无论你使用的是 BSD、Linux、Illumos、Solaris 还是 MacOS,安装过程都基本相同: + +1. 使用 CVS 检出 pkgsrc 树 +2. 引导 pkgsrc 系统 +3. 安装软件包 + +#### 使用 CVS 检出 pkgsrc 树 + +在 Git 和 Subversion 之前,就有了 [CVS][4]。要检出代码你无需了解 CVS 太多,如果你习惯 Git,那么可以将检出checkout称为克隆clone。当你用 CVS 检出 pkgsrc 时,你就下载了详细说明如何构建每个软件包的“配方recipes”。它有很多文件,但是它们都很小,因为你实际上并没有拉取每个包的源码,而只有按需构建时需要的构建基础架构和 Makefile。使用 CVS,你可以轻松地在新版本发布时更新 pkgsrc 检出。 + +pkgsrc 文档建议将其源码树放在 `/usr` 目录下,因此你必须使用 `sudo`(或成为 root)运行此命令: + +``` +$ cd /usr +$ sudo cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2019Q3 -P pkgsrc +``` + +在我撰写本文时,最新版本是 2019Q3。请检查 [pkgsrc.org][6] 主页的新闻部分或 [NetBSD文档][7],以确定最新版本。 + +#### 引导 pkgsrc + +pkgsrc 树复制到你的计算机后,你会看到一个充满构建脚本的 `/usr/pkgsrc` 目录。在使用之前,你必须引导 pkgsrc,以便你可以轻松地访问构建和安装软件所需的相关命令。 + +引导 pkgsrc 的方式取决于你所使用操作系统。 + +对于 NetBSD,你只需使用捆绑的引导器: + +``` +# cd pkgsrc/bootstrap +# ./bootstrap +``` + +在其他系统上,还有更好的方法,包括一些自定义功能,它是由 Joyent 提供的。要了解运行的确切命令,请访问 [pkgsrc.joyent.com][8]。比如,在 Linux(Fedora、Debian、Slackware 等)上: + +``` +$ curl -O https://pkgsrc.joyent.com/packages/Linux/el7/bootstrap/bootstrap-trunk-x86_64-20170127.tar.gz +$ BOOTSTRAP_SHA="eb0d6911489579ca893f67f8a528ecd02137d43a" +``` + +尽管路径暗示文件适用于 RHEL 7,但二进制文件往往与所有(最前沿的 Linux 发行版)兼容。如果你发现二进制文件与你的发行版不兼容,你可以选择从源码构建。 + +验证 SHA1 校验和: + +``` +$ echo "${BOOTSTRAP_SHA}" bootstrap-trunk*gz > check-shasum +sha1sum -c check-shasum +``` + +你还可以验证 PGP 签名: + +``` +$ curl -O https://pkgsrc.joyent.com/packages/Linux/el7/bootstrap/bootstrap-trunk-x86_64-20170127.tar.gz.asc +$ curl -sS https://pkgsrc.joyent.com/pgp/56AAACAF.asc | gpg --import +$ gpg --verify ${BOOTSTRAP_TAR}{.asc,} +``` + +当你确认你已有正确的引导套件,将其安装到 `/usr/pkg`: + +``` +sudo tar -zxpf ${BOOTSTRAP_TAR} -C / +``` + +它为你提供了通常的 pkgsrc 命令。将这些位置添加到[你的 PATH 环境变量中][9]: + +``` +$ echo "PATH=/usr/pkg/sbin:/usr/pkg/bin:$PATH" >> ~/.bashrc +$ echo "MANPATH=/usr/pkg/man:$MANPATH" >> ~/.bashrc +``` + +如果你宁愿使用 pkgsrc 而不依赖于 Joyent 的构建,那么只需运行 pkgsrc 源码树的引导脚本即可。在运行特定于系统的脚本之前,请先阅读 `bootstrap` 目录中相关 `README` 文件。 + +![Bootstrapping pkgsrc on NetBSD][10] + +### 如何使用 pkgsrc 安装软件 + +使用 pkgsrc 安装预编译的二进制文件(就像使用 DNF 或 Apt 一样)是很容易的。二进制安装的命令是 `pgkin`,它有自己的专门网站 [pkgin.net][11]。对于任何用过 Linux 的人来说,这个过程应该感觉相当熟悉。 + +要搜索 `tmux` 包: + +``` +$ pkgin search tmux +``` + +要安装 tmux 包: + +``` +$ sudo pkgin install tmux +``` + +`pkgin` 命令的目的是模仿典型的 Linux 包管理器的行为,因此有选项可以列出可用的包、查找包提供的特定可执行文件,等等。 + +### 如何使用 pkgsrc 从源码构建 + +然而,pkgsrc 真正强大的地方是方便地从源码构建包。你在第一步中检出了所有 20000 多个构建脚本,你可以直接进入 pkgsrc 源码树来访问这些脚本。 + +例如,要从源码构建 `tcsh`,首先找到构建脚本: + +``` +$ find /usr/pkgsrc -type d -name "tcsh" +/usr/pkgsrc/shells/tcsh +``` + +接下来,进入源码目录: + +``` +$ cd /usr/pgksrc/shells/tcsh +``` + +构建脚本目录包含许多文件来帮助在你的系统上构建应用,但值得注意的是,这里面有包含了软件说明的 `DESCR` 文件,以及触发构建的 `Makefile`。 + +``` +$ ls +CVS    DESCR     Makefile +PLIST  distinfo  patches +$ cat DESCR +TCSH is an extended C-shell with many useful features like +filename completion, history editing, etc. +$ +``` + +准备就绪后,构建并安装: + +``` +$ sudo bmake install +``` + +pkgsrc 系统使用 `bmake` 命令(在第一步检出 pkgsrc 后提供),因此请务必使用 `bmake`(而不是出于习惯使用 `make`)。 + +如果要为多个系统构建,那么你可以创建一个包,而不是立即安装: + +``` +$ cd /usr/pgksrc/shells/tcsh +$ sudo bmake package +[...] +=> Creating binary package in /usr/pkgsrc/packages/All/tcsh-X.Y.Z.tgz +``` + +pkgsrc 创建的包是标准的 tarball,但它可以方便地通过 `pkg_add` 安装: + +``` +$ sudo pkg_add /usr/pkgsrc/packages/All/tcsh-X.Y.Z.tgz +tcsh-X.Y.Z: adding /usr/pkg/bin/tcsh to /etc/shells +$ tcsh +localhost% +``` + +pkgsrc 的 pkgtools 集合提供 `pkg_add`、`pkg_info`、`pkg_admin`、`pkg_create` 和 `pkg_delete` 命令,来帮助管理你在系统上构建和维护软件包。 + +### pkgsrc,易于管理 + +pkgsrc 系统提供了直接,容易上手的软件包管理方法。如果你正在寻找一个不妨碍你并且可以定制的包管理器,请在任何运行 Unix 或类 Unix 的系统上试试 pkgsrc。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/pkgsrc-netbsd-linux + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb (A person programming) +[2]: http://pkgsrc.org +[3]: https://opensource.com/article/19/7/introduction-gnu-autotools +[4]: http://www.netbsd.org/developers/cvs-repos/cvs_intro.html#intro +[5]: mailto:anoncvs@anoncvs.NetBSD.org +[6]: http://pkgsrc.org/ +[7]: http://www.netbsd.org/docs/pkgsrc/getting.html +[8]: http://pkgsrc.joyent.com/ +[9]: https://opensource.com/article/17/6/set-path-linux +[10]: https://opensource.com/sites/default/files/uploads/pkgsrc-bootstrap.jpg (Bootstrapping pkgsrc on NetBSD) +[11]: http://pkgin.net diff --git a/published/20191120 How to Use TimeShift to Backup and Restore Ubuntu Linux.md b/published/20191120 How to Use TimeShift to Backup and Restore Ubuntu Linux.md new file mode 100644 index 0000000000..e40aebfa8d --- /dev/null +++ b/published/20191120 How to Use TimeShift to Backup and Restore Ubuntu Linux.md @@ -0,0 +1,155 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11619-1.html) +[#]: subject: (How to Use TimeShift to Backup and Restore Ubuntu Linux) +[#]: via: (https://www.linuxtechi.com/timeshift-backup-restore-ubuntu-linux/) +[#]: author: (James Kiarie https://www.linuxtechi.com/author/james/) + +如何使用 TimeShift 备份和还原 Ubuntu Linux +====== + +你是否曾经想过如何备份和还原 Ubuntu 或 Debian 系统?Timeshift 是一款自由开源工具,可让你创建文件系统的增量快照。你可以使用 RSYNC 或 BTRFS 两种方式创建快照。 + +![](https://img.linux.net.cn/data/attachment/album/201911/27/235959fejmb080e7z0jnu0.jpg) + +让我们深入研究并安装 Timeshift。在本教程,我们将安装在 Ubuntu 18.04 LTS 系统上。 + +### 在 Ubuntu / Debian Linux 上安装 TimeShift + +TimeShift 尚未正式托管在 Ubuntu 和 Debian 仓库中。考虑到这一点,我们将运行以下命令来添加 PPA: + +``` +# add-apt-repository -y ppa:teejee2008/ppa +``` + +![Add timeshift repository][3] + +接下来,使用以下命令更新系统软件包: + +``` +# apt update +``` + +成功更新系统后,使用以下 `apt` 命令安装 Timeshift: + +``` +# apt install timeshift +``` + +![apt install timeshift][4] + +### 准备备份存储设备 + +最佳实践要求我们将系统快照保存在系统硬盘之外的单独的存储卷上。对于本指南,我们将使用 16GB 闪存作为第二个驱动器,并在该驱动器上保存快照。 + +``` +# lsblk | grep sdb +``` + +![lsblk sdb ubuntu][5] + +为了将闪存用作快照的备份位置,我们需要在设备上创建一个分区表。运行以下命令: + +``` +# parted /dev/sdb mklabel gpt +# parted /dev/sdb mkpart primary 0% 100% +# mkfs.ext4 /dev/sdb1 +``` + +![create partition table on drive ubuntu][6] + +在 USB 闪存上创建分区表后,我们可以开始创建文件系统的快照! + +### 使用 Timeshift 创建快照 + +要启动 Timeshift,使用应用程序菜单搜索 “Timeshift”。 + +![Access timeshift][7] + +单击 Timeshift 图标,系统将提示你输入管理员密码。提供密码,然后单击验证。 + +![Authentication required][8] + +接下来,选择你喜欢的快照类型。 + +![Select rsync option][9] + +点击 “Next”。选择快照的目标驱动器。在这里,我的位置是标记为 `/dev/sdb` 的外部 USB 驱动器。 + +![Select snapshot location][10] + +接下来,定义快照级别。级别是指创建快照的时间间隔。你可以选择每月、每周、每天或每小时的快照级别。 + +![Select snapshot levels][11] + +点击 “Finish”。 + +在下一个窗口中,单击 “Create” 按钮开始创建快照。此后,系统将开始创建快照。 + +![Create snapshot][12] + +最后,你的快照将显示如下: + +![Snapshot created][13] + +### 从快照还原 Ubuntu / Debian + +创建系统快照后,现在让我们看看如何从同一快照还原系统。在同一个 Timeshift 中,单击快照,然后单击 “Restore” 按钮,如图所示。 + +![Restore snapshot][14] + +接下来,将提示你选择目标设备。保留默认选择,然后点击 “Next”。 + +![Select target device][15] + +恢复过程开始之前,Timeshift 将会试运行。 + +![Comparing files dry run][16] + +在下一个窗口中,点击 “Next” 按钮确认显示的操作。 + +![Confirm actions][17] + +如图所示,你会看到警告和免责声明。点击 “Next” 初始化恢复过程。 + +此后,将开始还原过程,最后,系统之后将重新启动到快照定义的早期版本。 + +![Restoring snapshot][18] + +### 总结 + +如你所见,使用 TimeShift 从快照还原系统非常容易。在备份系统文件时,它非常方便,并允许你在系统故障时进行恢复。因此,不要害怕修改系统或弄乱系统。TimeShift 使你能够返回到一切运行平稳的时间点。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/timeshift-backup-restore-ubuntu-linux/ + +作者:[James Kiarie][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/james/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/11/TimeShift-Backup-Restore-Tool-Ubuntu.png +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Add-timeshift-repository.png +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/11/apt-install-timeshift.png +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/11/lsblk-sdb-ubuntu.png +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/11/create-partition-table-on-drive-ubuntu.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Access-Timeshift-Ubuntu.jpg +[8]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Authentication-required-ubuntu.jpg +[9]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Select-Rsync-option-timeshift.jpg +[10]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Select-snapshot-location.png +[11]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Select-snapshot-levels-Timeshift.jpg +[12]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Create-snapshot-timeshift.jpg +[13]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Snapshot-created-TimeShift.jpg +[14]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Restore-snapshot-timeshift.jpg +[15]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Select-target-device-timeshift.jpg +[16]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Comparing-files-Dry-Run-timeshift.jpg +[17]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Confirm-actions-timeshift.jpg +[18]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Restoring-snapshot-timeshift.png diff --git a/published/20191120 How to install Java on Linux.md b/published/20191120 How to install Java on Linux.md new file mode 100644 index 0000000000..db94ace738 --- /dev/null +++ b/published/20191120 How to install Java on Linux.md @@ -0,0 +1,215 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11614-1.html) +[#]: subject: (How to install Java on Linux) +[#]: via: (https://opensource.com/article/19/11/install-java-linux) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何在 Linux 上安装 Java +====== + +> 在桌面上拥抱 Java 应用程序,然后在所有桌面上运行它们。 + +![](https://img.linux.net.cn/data/attachment/album/201911/26/065307hk22caubakkos0u0.jpg) + +无论你运行的是哪种操作系统,通常都有几种安装应用程序的方法。有时你可能会在应用程序商店中找到一个应用程序,或者使用 Fedora 上的 DNF 或 Mac 上的 Brew 这样的软件包管理器进行安装,而有时你可能会从网站上下载可执行文件或安装程序。因为 Java 是这么多流行的应用程序的后端,所以最好了解安装它的不同方法。好消息是你有很多选择,本文涵盖了所有这些内容。 + +坏消息是 Java *太大*,我说的不仅仅是文件大小。Java 是一种开放源代码语言和规范,这意味着从理论上讲,任何人都可以创建它的实现版本。这意味着,在安装任何东西之前,必须确定要安装的 Java 发行版。 + +### 我需要 JVM 还是 JRE 或者 JDK? + +Java 大致分为两个下载类别。Java 虚拟机Java Virtual Machine(JVM)是运行时组件;它是使 Java 应用程序能够在计算机上启动和运行的“引擎”。它包含在 Java 运行时环境Java Runtime Environment(JRE)中。 + +Java 开发工具包Java Development Kit(JDK)是一个开发工具包:你可以将其视为一个车库,修理工可以坐在那里进行调整、修理和改进。JDK 包含 Java 运行时环境(JRE)。 + +以下载来说,这意味着: + +* 如果你是希望运行 Java 应用程序的用户,则只需 JRE(包括了 JVM)。 +* 如果你是希望使用 Java 进行编程的开发人员,则需要 JDK(包括 JRE 库,而 JRE 库又包括 JVM)。 +   +### OpenJDK、IcedTea 和 OracleJDK 有什么不同? + +当太阳微系统Sun Microsystems被 Oracle 收购时,Java 是该交易的主要部分。幸运的是,Java 是一种开源技术,因此,如果你对 Oracle 维护该项目的方式不满意,则可以选择其他方法。Oracle 将专有组件与 Java 下载捆绑在一起,而 OpenJDK 项目是完全开源的。 + +IcedTea 项目本质上是 OpenJDK,但其目标是使用户在使用完全自由开源的工具时更容易构建和部署 OpenJDK。 + +(LCTT 译注:阿里巴巴也有一个它自己维护的 Open JDK 发行版“龙井Dragonwell”。以下引自其官网:“Alibaba Dragonwell 是一款免费的,生产就绪型 Open JDK 发行版,提供长期支持,包括性能增强和安全修复。……Alibaba Dragonwell 作为 Java 应用的基石,支撑了阿里经济体内所有的 Java 业务。Alibaba Dragonwell 完全兼容 Java SE 标准,……”) + +### 我应该安装哪个 Java? + +如果你对这些选择感到不知所措,那么简单的答案就是你应该安装的 Java 实现应该是最容易安装的那个。当应用程序告诉你需要 Java 12,但你的存储库中只有 Java 8 时,可以安装可以从可靠来源中找到的 Java 12 的任何实现。在 Linux 上,你可以一次安装几个不同版本的 Java,它们不会互相干扰。 + +如果你是需要选择使用哪个版本的开发人员,则应考虑所需的组件。如果选择 Oracle 的版本,请注意,软件包中包含专有的插件和字体,可能会[影响你分发你的应用程序][2]。在 IcedTea 或 OpenJDK 上进行开发是最安全的。 + +### 从存储库安装 OpenJDK? + +现在,你已经知道要选择什么了,你可以使用软件包管理器搜索 OpenJDK 或 IcedTea,然后安装所需的版本。有些发行版使用关键字 `latest` 来指示最新版本,这通常是你要运行的应用程序所需要的。根据你使用的软件包管理器,你甚至可以考虑使用 `grep` 过滤搜索结果以仅包括最新版本。例如,在 Fedora 上: + +``` +$ sudo dnf search openjdk | grep latest | cut -f1 -d':' + +java-latest-openjdk-demo.x86_64 +java-openjdk.i686 +java-openjdk.x86_64 +java-latest-openjdk-jmods.x86_64 +java-latest-openjdk-src.x86_64 +java-latest-openjdk.x86_64 +[...] +``` + +只有当你尝试运行的应用程序坚持要求你使用 Java 的旧版本时,你才应该看看 `latest` 之前的版本。 + +在 Fedora 或类似系统上安装 Java: + +``` +$ sudo dnf install java-latest-openjdk +``` + +如果你的发行版不使用 `latest` 标签,则可以使用其他关键字,例如 `default`。以下是在 Debian 上搜索 OpenJDK 的信息: + +``` +$ sudo apt search openjdk | less +default-jdk +  Standard Java development kit + +default-jre +  Standard Java runtime + +openjdk-11-jdk +  OpenJDK development kit (JDK) + +[...] +``` + +在这种情况下,`default-jre` 软件包适合用户,而 `default-jdk` 则适合开发人员。 + +例如,要在 Debian 上安装 JRE: + +``` +$ sudo apt install default-jre +``` + +现在已安装好 Java。 + +你的存储库中可能有*许多*与 Java 相关的软件包。要搜索 OpenJDK,如果你是用户,则查找最新的 JRE 或 JVM,如果你是开发人员,则查找最新的 JDK。 + +### 从互联网上安装 Java + +如果在存储库中找不到 JRE 或 JDK,或者找不到满足你需求的 JRE 或 JDK,则可以从互联网上下载开源的 Java 软件包。你可以在 [openjdk.java.net][3] 中找到需要手动安装的 tar 形式的 OpenJDK 下载文件,或者可以从 Azul 下载 tar 形式的 [Zulu 社区版][4]或其可安装的 RPM 或 DEB 软件包。 + +#### 从 TAR 文件安装 Java + +如果从 Java.net 或 Azul 下载 TAR 文件,则必须手动安装。这通常称为“本地”安装,因为你没有将 Java 安装到“全局”位置。你可以在 `PATH` 中选择一个合适的位置。 + +如果你不知道 `PATH` 中包含什么,请查看一下以找出: + +``` +$ echo $PATH +/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/seth/bin +``` + +在此示例 `PATH` 中,位置 `/usr/local/bin` 和 `/home/seth/bin` 是不错的选择。如果你是计算机上的唯一用户,那么你自己的家目录就很有意义。如果你的计算机上有很多用户,则最好选择一个通用位置,例如 `/usr/local` 或 `/opt`。 + +如果你无权访问需要 `sudo` 权限的 `/usr/local` 之类的系统级目录,则可以在你自己的家目录中创建一个本地 `bin`(意思是 “二进制binary”,而不是“垃圾箱waste bin”)或 `Applications` 文件夹: + +``` +$ mkdir ~/bin +``` + +如果它不在你的 `PATH` 中,请将其添加到其中: + +``` +$ echo PATH=$PATH:$HOME/bin >> ~/.bashrc +$ source ~/.bashrc +``` + +最后,将压缩包解压缩到你选择的目录中。 + +``` +$ tar --extract --file openjdk*linux-x64_bin.tar.gz --directory=$HOME/bin +``` + +Java 现在安装好了。 + +#### 从 RPM 或 DEB 安装 Java + +如果从 Azul.com 下载 RPM 或 DEB 文件,则可以使用软件包管理器进行安装。 + +对于 Fedora、CentOS、RHEL 等,请下载 RPM 并使用 DNF 进行安装: + +``` +$ sudo dnf install zulu*linux.x86_64.rpm +``` + +对于 Debian、Ubuntu、Pop_OS 和类似发行版,请下载 DEB 软件包并使用 Apt 安装它: + +``` +$ sudo dpkg -i zulu*linux_amd64.deb +``` + +Java 现在安装好了。 + +#### 用 alternatives 安装你的 Java 版本 + +一些应用程序是为特定版本的 Java 开发的,不能与其他任何版本一起使用。这种情况很少见,但确实会发生,在 Linux 上,你可以使用本地安装方法(请参阅上面“从 TAR 文件安装 Java”一节)或使用 `alternatives` 应用程序来解决此冲突。 + +`alternatives` 命令会查找 Linux 系统上安装的应用程序,并让你选择要使用的版本。有些发行版,例如 Slackware,不提供 `alternatives` 命令,因此你必须使用本地安装方法。在 Fedora、CentOS 和类似的发行版上,该命令是 `alternatives`。在 Debian、Ubuntu 和类似的系统上,该命令是 `update-alternatives`。 + +要获取当前已安装在 Fedora 系统上的应用程序的可用版本列表: + +``` +$ alternatives --list +``` + +在 Debian 上,你必须指定可供替代的应用程序: + +``` +$ update-alternatives --list java +``` + +在 Fedora 上选择要使系统将哪个版本作为默认版本: + +``` +$ sudo alternatives --config java +``` + +在 Debian 上: + +``` +$ sudo updates-alternatives --config java +``` + +你可以根据需要运行的应用程序,根据需要更改默认的 Java 版本。 + +### 运行 Java 应用 + +Java 应用程序通常以 JAR 文件的形式分发。根据你安装 Java 的方式,你的系统可能已经为运行 Java 应用程序配置好了,这使你只需双击应用程序图标(或从应用程序菜单中选择它)即可运行。如果必须执行未与系统其余部分集成的本地 Java 安装,则可以直接从终端启动 Java 应用程序: + +``` +$ java -jar ~/bin/example.jar & +``` + +### Java 是个好东西 + +Java 是少数将跨平台开发放在首位的编程环境之一。没有什么比问一个应用程序是否能在你的平台上运行然后发现该应用程序是用 Java 编写要让人感到松一口气的了。它是如此简单,无论你是开发人员还是用户,你都可以摆脱任何平台上的焦虑。在桌面上拥抱 Java 应用程序,然后在*所有*桌面上运行它们吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/install-java-linux + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/java-coffee-beans.jpg?itok=3hkjX5We (Coffee beans) +[2]: https://www.oracle.com/technetwork/java/javase/overview/oracle-jdk-faqs.html +[3]: http://openjdk.java.net +[4]: https://www.azul.com/downloads/zulu-community +[5]: tmp.wuzOCnXHry#installing-java-from-a-tar-file diff --git a/published/20191122 Zorin OS 15 Lite Release- Good Looking Lightweight Linux.md b/published/20191122 Zorin OS 15 Lite Release- Good Looking Lightweight Linux.md new file mode 100644 index 0000000000..2f1932ddec --- /dev/null +++ b/published/20191122 Zorin OS 15 Lite Release- Good Looking Lightweight Linux.md @@ -0,0 +1,125 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11603-1.html) +[#]: subject: (Zorin OS 15 Lite Release: Good Looking Lightweight Linux) +[#]: via: (https://itsfoss.com/zorin-os-lite/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Zorin OS 15 Lite 发布:好看的轻量级 Linux +====== + +> Zorin OS 15 Lite 版刚刚发布。我们将向你展示此新版本的桌面体验,并向你重点展示其主要功能。 + +[Zorin OS][1] 是一款日益流行的 Linux 发行版。它基于 Ubuntu,因此,毫不奇怪,它也正是[适合初学者的最佳 Linux 发行版][2]之一。 类似 Windows 的界面是许多从 Windows 到 Linux 的迁移者偏爱它的主要原因之一。 + +Zorin OS 有两个主要变体: + +* Zorin Core:它使用 GNOME 桌面,用于较新的机器。 +* Zorin Lite:它使用轻量级的 [Xfce 桌面][3],可以用作[老旧的笔记本电脑和计算机的 Linux][4]。 + +### Zorin OS 15 Lite:新特性 + +Zorin OS 15 Core 发布之后过了很久,Zorin OS 15 Lite 版终于出现了。你现在就可以使用免费的 Lite 版或付费的 Lite Ultimate 版。 + +我尝试了 Zorin OS 15 Lite Ultimate 版。在本文中,我将介绍此版本的详细信息以及在为你的计算机下载 Zorin OS 15 Lite 之前应了解的知识。 + +Zorin OS 15 Lite 与全面的 Zorin OS 15 版本基本差不多。你可以在我们的原来的报道中查看 [Zorin OS 15 的功能][6]。 + +此发行版重点关注资源,因此过去十年中任何类型的旧硬件配置都可以轻松地在其上运行。 + +![][7] + +在此版本中,它们依靠基于 Xfce 4.14 的轻量级桌面环境在低规格计算机上提供了最佳体验。除了 Xfce 桌面环境外,与使用 GNOME 的完整版本相比,它还做了一些底层更改。 + +#### Zorin OS 15 Lite 是针对 Windows 7 用户的 + +![][8] + +Zorin OS 15 Lite 主要针对 Windows 7 用户,因为对 Windows 7 的官方支持结束于今年 1 月。因此,如果你对 Windows 7 感到满意,可以尝试一下,切换到此版本应该是一种流畅的体验。 + +Zorin OS 15 Lite 允许你在 “Zorin 外观”设置中将布局切换为 macOS 风格/ Windows 风格的外观。 + +#### 32 位和 64 位支持 + +很高兴看到 Zorin OS 考虑到对 32 位/ 64 位 ISO 的支持,因为 Lite 版本是针对具有低规格硬件的用户的。 + +#### 默认启用 Flatpak 支持 + +![][9] + +你可以使用软件中心利用 Flathub 来立即安装 Flatpak 软件包。如果你不确定该怎么做,请务必查看有关[使用 Flatpak][10]的指南。 + +除此之外,你已经拥有 Snap 软件包支持。因此,通过软件中心安装任何内容应该更容易。 + +#### 用户界面的印象 + +![][11] + +老实说,默认的 Xfce 界面看起来很陈旧。有一些方法可以 [定制 Xfce][12],但是 Zorin 也可以开箱即用。定制外观给人以良好印象。它看起来非常整洁,可以按预期工作。 + +#### 性能 + +![][13] + +即使我没有在超级老旧的系统上尝试过,但我也在老式硬盘上安装了它,它难以启动 Ubuntu 或类似发行版。 + +根据我的体验,我可以肯定该性能非常出色。感觉就好像我将其安装在 SSD 上。这显然是一件好事。如果你碰巧在超级老旧的系统上尝试使用它,可以在本文底部的评论部分中告诉我您的经验。 + +### Ultimate Lite 版和免费的 Lite 版有何区别? + +![][14] + +没错,你可以免费下载 Zorin OS 15。 + +但是,有一个单独的“终极版”(Ultimate),其基本目的是用来支持该项目及其开发者。除此之外,它还捆绑了许多预安装的软件,作为计算机的“最终”软件包。 + +因此,如果你购买 Ultimate 版,则可以访问 Lite 版和完整版。 + +如果你不想为此付费,仍然可以根据需要选择免费版本(Core、Lite、Education)。你可以在它们的[下载页面][15]上了解更多信息。 + +### 如何下载 Zorin OS 15 Lite? + +你可以转到其[官方下载网页][15],然后向下滚动找到 Zorin OS 15 Lite 版。 + +你可以找到 32 位/ 64 位的 ISO,可以下载所需的 ISO。 + +- [Zorin OS 15 Lite] [15] + +安装 Zorin OS 与安装 Ubuntu 类似。 + +### 总结 + +虽然 Zorin OS 15 作为向 Windows / macOS 老手提供的 Linux 发行版已经是一个不错的产品,但新的 Lite 版本肯定会吸引更多的眼球。 + +您是否尝试过 Lite 版?在下面的评论中让我知道你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/zorin-os-lite/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://zorinos.com/ +[2]: https://itsfoss.com/best-linux-beginners/ +[3]: https://www.xfce.org/ +[4]: https://itsfoss.com/lightweight-linux-beginners/ +[5]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 +[6]: https://linux.cn/article-11058-1.html +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/file-explorer-zorin-os-15-lite.jpg?ssl=1 +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/zorin-lite-ultimate-appearance.jpg?ssl=1 +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/zorin-os-software.png?ssl=1 +[10]: https://itsfoss.com/flatpak-guide/ +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/zorin-os-15-lite-appearance.jpg?ssl=1 +[12]: https://itsfoss.com/customize-xfce/ +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/homescreen-zorin-os-15-lite.jpg?ssl=1 +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/zorin-os-ultimate.jpg?ssl=1 +[15]: https://zorinos.com/download/ diff --git a/published/20191124 Bauh - Manage Snaps, Flatpaks and AppImages from One Interface.md b/published/20191124 Bauh - Manage Snaps, Flatpaks and AppImages from One Interface.md new file mode 100644 index 0000000000..cc418f1713 --- /dev/null +++ b/published/20191124 Bauh - Manage Snaps, Flatpaks and AppImages from One Interface.md @@ -0,0 +1,141 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11617-1.html) +[#]: subject: (Bauh – Manage Snaps, Flatpaks and AppImages from One Interface) +[#]: via: (https://itsfoss.com/bauh-package-manager/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +bauh:在一个界面中管理 Snap、Flatpak 和 AppImage +====== + +![](https://img.linux.net.cn/data/attachment/album/201911/27/092926pzzdtytda80yaany.jpg) + +[Snap][1]、[Flatpak][2] 和 [AppImage][3] 等通用软件包的最大问题之一就是管理它们。大多数内置的软件包管理器都不能全部支持这些新格式。 + +幸运的是,我偶然发现了一个支持这几种通用包格式的应用程序。 + +### bauh:多包装需求的管理器 + +[bauh][4](LCTT:我给该软件建议一个中文名:“包豪”)最初名为 fpakman,旨在处理 Flatpak、Snap、[AppImage][5] 和 [AUR][6] 软件包。创建者 [vinifmor][7] 在 2019 年 6 月启动了该项目,[意图][8]“为 Manjaro 用户提供管理 Flatpak 的图形界面”。此后,他扩展了该应用程序,以添加对基于 Debian 的系统的支持。 + +![Bauh About][9] + +首次打开 bauh 时,它将扫描已安装的应用程序并检查更新。如果有任何需要更新的内容,它们将列在前面并居中。更新所有软件包后,你将看到已安装的软件包列表。你可以取消选择不需要更新的软件包,以防止其被更新。你也可以选择安装该应用程序的早期版本。 + +![With Bauh you can manage various types of packages from one application][10] + +你也可以搜索应用程序。bauh 提供了有关已安装和已搜索软件包的详细信息。如果你对一种(或多种)软件包类型不感兴趣,则可以在设置中取消选择它们。 + +![Bauh Search][22] + +![Bauh Package Info][13] + +![Bauh Updating][19] + +### 在你的 Linux 发行版上安装 bauh + +让我们看看如何安装 bauh。 + +#### 基于 Arch 的发行版 + +如果你安装的是最近的 [Manjaro][11],则应该一切已经就绪。bauh 默认情况下已安装。如果你安装的是较早版本的 Manjaro(如我一样)或其他基于 Arch 的发行版,则可以在终端中输入以下内容从 [AUR][12] 中进行安装: + +``` +sudo pacman -S bauh +``` + +#### 基于 Debian/Ubuntu 的发行版 + +如果你拥有基于 Debian 或 Ubuntu 的 Linux 发行版,则可以使用 `pip` 安装 bauh。首先,请确保[在 Ubuntu 上安装了 pip][14]。 + +``` +sudo apt install python3-pip +``` + +然后使用它来安装 bauh: + +``` +pip3 install bauh +``` + +但是,该软件的创建者建议[手动][15]安装它,以避免弄乱系统的库。 + +要手动安装 bauh,你必须先下载其[最新版本][16]。下载后,可以[使用图形工具][17]或 [unzip 命令][18]解压缩。接下来,在终端中打开该文件夹。你将需要使用以下步骤来完成安装。 + +首先,在名为 `env` 的文件夹中创建一个虚拟环境: + +``` +python3 -m venv env +``` + +现在在该环境中安装该应用程序的代码: + +``` +env/bin/pip install . +``` + +启动该应用程序: + +``` +env/bin/bauh +``` + +一旦完成了 bauh 的安装,就可以通过更改环境设置和参数来对其进行[微调][20]。 + +### bauh 的未来之路 + +bauh 在短短的几个月中增长了很多。它有计划继续增长。当前的[路线图][21]包括: + +* 支持其他打包技术 +* 每种打包技术一个单独模块 +* 内存和性能改进 +* 改善用户体验 + +### 结语 + +当我尝试 bauh 时,遇到了两个问题。当我第一次打开它时,它告诉我尚未安装 Snap,如果要使用 Snap 软件包,则必须安装它。我知道我已经安装了 Snap,因为我在终端中运行了 `snap list`,并且可以正常工作。我重新启动系统,Snap 才工作正常。 + +我遇到的另一个问题是我的一个 AUR 软件包无法更新。我可以用 `yay` 更新软件包,而没有任何问题。可能是我的 Manjaro 有问题,我已经使用了它 3 到 4 年。 + +总体而言,bauh 可以工作。它做到了宣称的功能。我不能要求更多。 + +你有没有用过 hauh?如果有的话,你最喜欢的用于管理不同打包格式的工具是什么?在下面的评论中让我们知道。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/bauh-package-manager/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://snapcraft.io/ +[2]: https://flatpak.org/ +[3]: https://appimage.org/ +[4]: https://github.com/vinifmor/bauh +[5]: https://itsfoss.com/use-appimage-linux/ +[6]: https://itsfoss.com/best-aur-helpers/ +[7]: https://github.com/vinifmor +[8]: https://forum.manjaro.org/t/bauh-formerly-known-as-fpakman-a-gui-for-flatpak-and-snap-management/96180 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/bauh-about.jpg?ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/bauh.jpg?ssl=1 +[11]: https://manjaro.org/ +[12]: https://aur.archlinux.org/packages/bauh +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/bauh-package-info.jpg?ssl=1 +[14]: https://itsfoss.com/install-pip-ubuntu/ +[15]: https://github.com/vinifmor/bauh#manual-installation +[16]: https://github.com/vinifmor/bauh/releases +[17]: https://itsfoss.com/unzip-linux/ +[18]: https://linuxhandbook.com/unzip-command/ +[19]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/bauh-updating.jpg?ssl=1 +[20]: https://github.com/vinifmor/bauh#general-settings +[21]: https://github.com/vinifmor/bauh#roadmap +[22]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/bauh-search.png?resize=800%2C319&ssl=1 +[23]: https://reddit.com/r/linuxusersgroup diff --git a/published/20191126 Google to Add Mainline Linux Kernel Support to Android.md b/published/20191126 Google to Add Mainline Linux Kernel Support to Android.md new file mode 100644 index 0000000000..479ef5cdde --- /dev/null +++ b/published/20191126 Google to Add Mainline Linux Kernel Support to Android.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11616-1.html) +[#]: subject: (Google to Add Mainline Linux Kernel Support to Android) +[#]: via: (https://itsfoss.com/mainline-linux-kernel-android/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +谷歌为安卓添加主线 Linux 内核支持 +====== + +当前的安卓生态系统被数百种不同版本的安卓所污染,每种版本都运行着 Linux 内核的不同变体。每个版本均针对不同的手机和不同的配置而设计。谷歌试图通过将主线 Linux 内核添加到安卓来解决该问题。 + +### 当前在安卓中是如何处理 Linux 内核的 + +在到达你的手机之前,你手机上的 Linux 内核经历了[三个主要步骤][1]。 + +首先,谷歌采用了 Linux 内核的 LTS(长期支持)版本,并添加了所有的安卓专用代码。这将成为“安卓通用内核”。 + +然后,谷歌将此代码发送给创建可运行在手机的片上系统(SoC)的公司。这通常是高通公司。 + +SoC 制造商添加了支持 CPU 和其他芯片的代码后,便会将该内核传递给实际的设备制造商,例如三星和摩托罗拉。然后,设备制造商添加代码以支持手机的其余部分,例如显示屏和摄像头。 + +每个步骤都需要一段时间才能完成,并且会导致该内核无法与其他任何设备一起使用。这也意味着内核会非常旧,通常是大约两年前的内核。例如,上个月交付的谷歌 Pixel 4 带有来自 2017 年 11 月的内核,而且它将永远不会得到更新。 + +谷歌承诺会为较旧的设备创建安全补丁,这意味着他们会一直盯着大量的旧代码。 + +### 将来 + +![][2] + +去年,谷歌宣布[计划][3]解决此问题。今年,他们在 2019 Linux Plumbers Conference 上展示了他们取得的进展。 + +> “我们知道运行安卓需要什么,但不一定是在任何给定的硬件上。因此,我们的目标是从根本上找出所有这些,然后将其交给上游,并尝试尽可能接近主线。” +> +> Sandeep Patil,[安卓内核团队负责人][1] + +他们确实炫耀了运行带有合适的 Linux 内核的小米 Poco F1。但是,有些东西[似乎没有工作][4],例如电池电量百分比一直留在 0%。 + +那么,谷歌计划如何使其工作呢?从他们的 [Treble 项目][5]计划中摘录。在 Treble 项目之前,与设备和安卓本身交互的底层代码是一大堆代码。Treble 项目将两者分开,并使它们模块化,以便可以更快地交付安卓更新,并且在更新时,这些低级代码可以保持不变。 + +谷歌希望为内核带来同样的模块化。他们的[计划][1]“涉及稳定 Linux 的内核 ABI,并为 Linux 内核和硬件供应商提供稳定的接口来进行写入。谷歌希望将 Linux 内核与其硬件支持脱钩。” + +因此,这意味着谷歌将交付一个内核,而硬件驱动程序将作为内核模块加载。目前,这只是一个草案。仍然有很多技术问题有待解决。因此,这不会很快有结果。 + +### 来自开源的反对意见 + +开源社区不会对将专有代码放入内核的想法感到满意。[Linux 内核准则][6]指出,驱动程序必须具有 GPL 许可证才能包含在内核中。他们还指出,如果驱动程序的更改导致错误,应由导致该错误的人来解决。从长远来看,这意味着设备制造商的工作量将减少。 + +### 关于将主线内核包含到安卓中的最终想法 + +到目前为止,这只是一个草案。谷歌有很大的可能会开始进行该项目,除非他们意识到这将需要多少工作后才会放弃。看看谷歌[已经放弃][7]了多少个项目! + +[Android Police][4] 指出谷歌正在开发其 [Fuchsia 操作系统][8],这似乎是为了有一天取代安卓。 + +那么,问题是谷歌会尝试完成那些艰巨的任务,使安卓以主线 Linux 内核运行,还是完成他们统一的安卓替代产品的工作?只有时间可以回答。 + +你对此话题有何看法?请在下面的评论中告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/mainline-linux-kernel-android/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://arstechnica.com/gadgets/2019/11/google-outlines-plans-for-mainline-linux-kernel-support-in-android/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/mainline_linux_kernel_android.png?ssl=1 +[3]: https://lwn.net/Articles/771974/ +[4]: https://www.androidpolice.com/2019/11/19/google-wants-android-to-use-regular-linux-kernel-potentially-improving-updates-and-security/ +[5]: https://www.computerworld.com/article/3306443/what-is-project-treble-android-upgrade-fix-explained.html +[6]: https://www.kernel.org/doc/Documentation/process/stable-api-nonsense.rst +[7]: https://killedbygoogle.com/ +[8]: https://itsfoss.com/fuchsia-os-what-you-need-to-know/ +[9]: https://reddit.com/r/linuxusersgroup diff --git a/sources/news/20191104 Hypervisor comeback, Linus says no and reads email, and more industry trends.md b/sources/news/20191104 Hypervisor comeback, Linus says no and reads email, and more industry trends.md new file mode 100644 index 0000000000..b8a6aafc80 --- /dev/null +++ b/sources/news/20191104 Hypervisor comeback, Linus says no and reads email, and more industry trends.md @@ -0,0 +1,70 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Hypervisor comeback, Linus says no and reads email, and more industry trends) +[#]: via: (https://opensource.com/article/19/11/hypervisor-stable-kernel-and-more-industry-trends) +[#]: author: (Tim Hildred https://opensource.com/users/thildred) + +Hypervisor comeback, Linus says no and reads email, and more industry trends +====== +A weekly look at open source community and industry trends. +![Person standing in front of a giant computer screen with numbers, data][1] + +As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update. + +## [Containers in 2019: They're calling it a [hypervisor] comeback][2] + +> So what does all this mean as we continue with rapid adoption and hyper-ecosystem growth around Kubernetes and containers? Let’s try and break that down into a few key areas and see what all the excitement is about. + +**The impact**: I'm pretty sure that the title of the article is an LL Cool J reference, which I wholeheartedly approve of. Even more important though is a robust unpacking of developments in the hypervisor space over the last year and how they square up against the trend towards cloud-native and container-based development. + +## [Linux kernel is getting more reliable, says Linus Torvalds. Plus: What do you need to do to be him?][3] + +> "In the end my job is to say no. Somebody has to be able to say no, because other developers know that if they do something bad I will say no. They hopefully in turn are more careful. But in order to be able to say no, I have to know the background, because otherwise I can't do my job. I spend all my time basically reading email about what people are working on. + +**The impact**: The rehabilitation of Linus as a much chiller guy continues; this one has some good advice for people leading distributed teams. + +## [Automated infrastructure in the on-premise datacenter—OpenShift 4.2 on OpenStack 15 (Stein)][4] + +> Up until now IPI (Installer Provision Infrastructure) has only supported public clouds: AWS, Azure, and Google. Now with OpenShift 4.2 it is supporting OpenStack. For the first time we can bring IPI into the on-premise datacenter where it is IMHO most needed. This single feature has the potential to revolutionize on-premise environments and bring them into the cloud-age with a single click and that promise is truly something to get excited about! + +**The impact**: So much tech press has started with the assumption that every company should run their infrastructure like a hyperscaler. The technology is catching up to make the user experience of that feasible. + +## [Kubernetes autoscaling 101: Cluster autoscaler, horizontal autoscaler, and vertical pod autoscaler][5] + +> I’m providing in this post a high-level overview of different scalability mechanisms inside Kubernetes and best ways to make them serve your needs. Remember, to truly master Kubernetes, you need to master different ways to manage the scale of cluster resources, that’s [the core of promise of Kubernetes][6]. +> +> _Configuring Kubernetes clusters to balance resources and performance can be challenging, and requires expert knowledge of the inner workings of Kubernetes. Just because your app or services’ workload isn’t constant, it rather fluctuates throughout the day if not the hour. Think of it as a journey and ongoing process._ + +**The impact**: You can tell whether someone knows what they're talking about if they can represent it in a simple diagram. Thanks to the excellent diagrams in this post, I know more day 2 concerns of Kubernetes operators than I ever wanted to. + +## [GitHub: All open source developers anywhere are welcome][7] + +> Eighty percent of all open-source contributions today, come from outside of the US. The top two markets for open source development outside of the US are China and India. These markets, although we have millions of developers in them, are continuing to grow faster than any others at about 30% year-over-year average. + +**The impact**: One of my open source friends likes to muse on the changing culture within the open source community. He posits that the old guard gatekeepers are already becoming irrelevant. I don't know if I completely agree, but I think you can look at the exponentially increasing contributions from places that haven't been on the open source map before and safely speculate that the open source culture of tomorrow will be radically different than that of today. + +_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/hypervisor-stable-kernel-and-more-industry-trends + +作者:[Tim Hildred][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/thildred +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) +[2]: https://www.infoq.com/articles/containers-hypervisors-2019/ +[3]: https://www.theregister.co.uk/2019/10/30/linux_kernel_is_getting_more_reliable_says_linus_torvalds/ +[4]: https://keithtenzer.com/2019/10/29/automated-infrastructure-in-the-on-premise-datacenter-openshift-4-2-on-openstack-15-stein/ +[5]: https://www.cncf.io/blog/2019/10/29/kubernetes-autoscaling-101-cluster-autoscaler-horizontal-autoscaler-and-vertical-pod-autoscaler/ +[6]: https://speakerdeck.com/thockin/everything-you-ever-wanted-to-know-about-resource-scheduling-dot-dot-dot-almost +[7]: https://www.zdnet.com/article/github-all-open-source-developers-anywhere-are-welcome/#ftag=RSSbaffb68 diff --git a/sources/news/20191105 Red Hat announces RHEL 8.1 with predictable release cadence.md b/sources/news/20191105 Red Hat announces RHEL 8.1 with predictable release cadence.md new file mode 100644 index 0000000000..9addd4102c --- /dev/null +++ b/sources/news/20191105 Red Hat announces RHEL 8.1 with predictable release cadence.md @@ -0,0 +1,92 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Red Hat announces RHEL 8.1 with predictable release cadence) +[#]: via: (https://www.networkworld.com/article/3451367/red-hat-announces-rhel-8-1-with-predictable-release-cadence.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +Red Hat announces RHEL 8.1 with predictable release cadence +====== + +[Clkr / Pixabay][1] [(CC0)][2] + +[Red Hat][3] has just today announced the availability of Red Hat Enterprise Linux (RHEL) 8.1, promising improvements in manageability, security and performance. + +RHEL 8.1 will enhance the company’s open [hybrid-cloud][4] portfolio and continue to provide a consistent user experience between on-premises and public-cloud deployments. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][5] + +RHEL 8.1 is also the first release that will follow what Red Hat is calling its "predictable release cadence". Announced at Red Hat Summit 2019, this means that minor releases will be available every six months. The expectation is that this rhythmic release cycle will make it easier both for customer organizations and other software providers to plan their upgrades. + +[][6] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][6] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +Red Hat Enterprise Linux 8.1 provides product enhancements in many areas. + +### Enhanced automation + +All supported RHEL subscriptions now include access to Red Hat's proactive analytics, **Red Hat Insights**. With more than 1,000 rules for operating RHEL systems whether on-premises or cloud deployments, Red Hat Insights help IT administrators flag potential configuration, security, performance, availability and stability issues before they impact production. + +### New system roles + +RHEL 8.1 streamlines the process for setting up subsystems to handle specific functions such as storage, networking, time synchronization, kdump and SELinux. This expands on the variety of Ansible system roles. + +### Live kernel patching + +RHEL 8.1 adds full support for live kernel patching. This critically important feature allows IT operations teams to deal with ongoing threats without incurring excessive system downtime. Kernel updates can be applied to remediate common vulnerabilities and exposures (CVE) while reducing the need for a system reboot. Additional security enhancements include enhanced CVE remediation, kernel-level memory protection and application whitelisting. + +### Container-centric SELinux profiles + +These profiles allow the creation of more tailored security policies to control how containerized services access host-system resources, making it easier to harden systems against security threats. + +### Enhanced hybrid-cloud application development + +A reliably consistent set of supported development tools is included, among them the latest stable versions of popular open-source tools and languages like golang and .NET Core as well as the ability to power modern data-processing workloads such as Microsoft SQL Server and SAP solutions. + +Red Hat Linux 8.1 is available now for RHEL subscribers via the [Red Hat Customer Portal][7]. Red Hat Developer program members may obtain the latest releases at no cost at the [Red Hat Developer][8] site. + +#### Additional resources + +Here are some links to  additional information: + + * More about [Red Hat Enterprise Linux][9] + * Get a [RHEL developer subscription][10] + * More about the latest features at [Red Hat Insights][11] + + + +Join the Network World communities on [Facebook][12] and [LinkedIn][13] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3451367/red-hat-announces-rhel-8-1-with-predictable-release-cadence.html + +作者:[Sandra Henry-Stocker][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.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://pixabay.com/vectors/red-hat-fedora-fashion-style-26734/ +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.networkworld.com/article/3316960/ibm-closes-34b-red-hat-deal-vaults-into-multi-cloud.html +[4]: https://www.networkworld.com/article/3268448/what-is-hybrid-cloud-really-and-whats-the-best-strategy.html +[5]: https://www.networkworld.com/newsletters/signup.html +[6]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[7]: https://access.redhat.com/ +[8]: https://developer.redhat.com +[9]: https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux +[10]: https://developers.redhat.com/ +[11]: https://www.redhat.com/en/blog/whats-new-red-hat-insights-november-2019 +[12]: https://www.facebook.com/NetworkWorld/ +[13]: https://www.linkedin.com/company/network-world diff --git a/sources/news/20191105 System76 introduces laptops with open source BIOS coreboot.md b/sources/news/20191105 System76 introduces laptops with open source BIOS coreboot.md new file mode 100644 index 0000000000..4d9c336304 --- /dev/null +++ b/sources/news/20191105 System76 introduces laptops with open source BIOS coreboot.md @@ -0,0 +1,57 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (System76 introduces laptops with open source BIOS coreboot) +[#]: via: (https://opensource.com/article/19/11/coreboot-system76-laptops) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +System76 introduces laptops with open source BIOS coreboot +====== +The company answers open hardware fans by revealing two laptops powered +with open source firmware coreboot. +![Guy on a laptop on a building][1] + +In mid-October, [System76][2] made an exciting announcement for open source hardware fans: It would soon begin shipping two of its laptop models, [Galago Pro][3] and [Darter Pro][4], with the open source BIOS [coreboot][5]. + +The coreboot project [says][6] its open source firmware "is a replacement for your BIOS / UEFI with a strong focus on boot speed, security, and flexibility. It is designed to boot your operating system as fast as possible without any compromise to security, with no back doors, and without any cruft from the '80s." Coreboot was previously known as LinuxBIOS, and the engineers who work on coreboot have also contributed to the Linux kernel. + +Most firmware on computers sold today is proprietary, which means even if you are running an open source operating system, you have no access to your machine's BIOS. This is not so with coreboot. Its developers share the improvements they make, rather than keeping them secret from other vendors. Coreboot's source code can be inspected, learned from, and modified, just like any other open source code. + +[Joshua Woolery][7], marketing director at System76, says coreboot differs from a proprietary BIOS in several important ways. "Traditional firmware is closed source and impossible to review and inspect. It's bloated with unnecessary features and unnecessarily complex [ACPI][8] implementations that lead to PCs operating in unpredictable ways. System76 Open Firmware, on the other hand, is lightweight, fast, and cleanly written." This means your computer boots faster and is more secure, he says. + +I asked Joshua about the impact of coreboot on open hardware overall. "The combination of open hardware and open firmware empowers users beyond what's possible when one or the other is proprietary," he says. "Imagine an open hardware controller like [System76's] [Thelio Io][9] without open source firmware. One could read the schematic and write software to control it, but why? With open firmware, the user starts from functioning hardware and software and can expand from there. Open hardware and firmware enable the community to learn from, adapt, and expand on our work, thus moving technology forward as a whole rather than requiring individuals to constantly re-implement what's already been accomplished." + +Joshua says System76 is working to open source all aspects of the computer, and we will see coreboot on other System76 machines. The hardware and firmware in Thelio Io, the controller board in the company's Thelio desktops, are both open. Less than a year after System76 introduced Thelio, the company is now marketing two laptops with open firmware. + +If you would like to see System76's firmware contributions to the coreboot project, visit the code repository on [GitHub][10]. You can also see the schematics for any supported System76 model by sending an [email][11] with the subject line: _Schematics for <MODEL>_. (Bear in mind that the only currently supported models are darp6 and galp4.) Using the coreboot firmware on other devices is not supported and may render them inoperable, + +Coreboot is licensed under the GNU Public License. You can view the [documentation][12] on the project's website and find out how to [contribute][13] to the project on GitHub. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/coreboot-system76-laptops + +作者:[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://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_code_programming_laptop.jpg?itok=ormv35tV (Guy on a laptop on a building) +[2]: https://opensource.com/article/19/5/system76-secret-sauce +[3]: https://system76.com/laptops/galago +[4]: https://system76.com/laptops/darter +[5]: https://www.coreboot.org/ +[6]: https://www.coreboot.org/users.html +[7]: https://www.linkedin.com/in/joshuawoolery +[8]: https://en.wikipedia.org/wiki/Advanced_Configuration_and_Power_Interface +[9]: https://opensource.com/article/18/11/system76-thelio-desktop-computer +[10]: https://github.com/system76/firmware-open +[11]: mailto:productdev@system76.com +[12]: https://doc.coreboot.org/index.html +[13]: https://github.com/coreboot/coreboot diff --git a/sources/news/20191112 GitHub report surprises, serverless hotness, and more industry trends.md b/sources/news/20191112 GitHub report surprises, serverless hotness, and more industry trends.md new file mode 100644 index 0000000000..df2db0d6f8 --- /dev/null +++ b/sources/news/20191112 GitHub report surprises, serverless hotness, and more industry trends.md @@ -0,0 +1,74 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (GitHub report surprises, serverless hotness, and more industry trends) +[#]: via: (https://opensource.com/article/19/11/github-report-serverless-hotness-more-industry-trends) +[#]: author: (Tim Hildred https://opensource.com/users/thildred) + +GitHub report surprises, serverless hotness, and more industry trends +====== +A weekly look at open source community and industry trends. +![Person standing in front of a giant computer screen with numbers, data][1] + +As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update. + +## [GitHub tops 40 million developers as Python, data science, machine learning popularity surges][2] + +> In its annual Octoverse report, GitHub, owned by Microsoft, said it had more than 10 million new users, 44 million repositories created and 87 million pull requests in the last 12 months. The report is a good view of open source software and where the community is headed. + +**The impact:** The finding that hit home hardest for me is that "nearly 80% of GitHub users are outside of the US." While an important part of open source history comes from the east and west coasts of America, there is a good chance that the future of the movement will happen elsewhere. + +## [Serverless: Is it the Kubernetes killer?][3] + +> Serverless isn't here to destroy Kubernetes. The cloud infrastructure space race isn't a zero-sum game. Kubernetes is an obvious evolution following OpenStack and can be run successfully inside of it. There will be OpenStack users for a long time to come, and there are also reasons many companies have moved on from there. Serverless is another tool in the belt of forward-thinking development teams. And increasingly, it can be [run on top of Kubernetes][4] (see Knative), enabling you to get the benefits of the simplicity of serverless and the complexity of Kubernetes where it makes sense for both in your stack. + +**The impact:** The moral of the story is that legacy doesn't really go away, it just gets built in and around. + +## [When Quarkus meets Knative serverless workloads][5] + +> Now, let's discuss how developers can use Quarkus to bring Java into serverless, a place where previously, it was unable to go. Quarkus introduces a comprehensive and seamless approach to generating an operating system specific (aka native) executable from your Java code, as you do with languages like Go and C/C++. Environments such as event-driven and serverless, where you need to start a service to react to an event, require a low time-to-first-response, and traditional Java stacks simply cannot provide this. Knative enables developers to run cloud-native applications as serverless containers in seconds and the containers will go down to zero on demand. +> +> In addition to compiling Java to Knative, Quarkus aims to improve developer productivity. Quarkus works out of the box with popular Java standards, frameworks and libraries like Eclipse MicroProfile, Apache Kafka, RESTEasy, Hibernate, Spring, and many more. Developers familiar with these will feel at home with Quarkus, which should streamline code for the majority of common use cases while providing the flexibility to cover others that come up. + +**The impact:** It's good to start getting specific with how and where the new hotness can be used. The answer, in this case, is "with the other new hotness." + +## [Why you should join the CNCF Meetup Program][6] + +> With the recent changes to Meetup’s [policies][7], we wanted to share a reminder of the benefits of joining the [CNCF Meetup Program][8] and encourage Meetups in the CNCF ecosystem to apply.  +> +> As part of our Meetup Pro membership, CNCF is able to organize a network with an unlimited number of groups on a single account. + +**The impact:** The long term response to this unfortunate fallout from the WeWork debacle is to build a distributed open source Meetup alternative. Thankfully in the meantime, the CNCF has a more pragmatic response. + +## [Introducing your friends to automation (and overcoming their fear)][9] + +> My team and I were in a meeting a little while back with a third party vendor when they asked us what our stance was on automation. My reply was, "We want to automate everything." On top of my reply, my teammates added, "Well, we don’t want to automate ourselves out of a job." + +**The impact:** I've always thought it was a bit cavalier when someone would say, "I think it's my job to automate myself out of a job." There is plenty of circumstances where that is the last measure of success someone would want to be measured by. I'm happy to see this addressed head-on. + +_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/github-report-serverless-hotness-more-industry-trends + +作者:[Tim Hildred][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/thildred +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) +[2]: https://www.zdnet.com/article/github-tops-40-million-developers-as-python-data-science-machine-learning-popularity-surges/#ftag=RSSbaffb68 +[3]: https://www.forbes.com/sites/forbestechcouncil/2019/11/04/serverless-is-it-the-kubernetes-killer/#7e6740711f77 +[4]: https://github.com/knative +[5]: https://vmblog.com/archive/2019/10/29/when-quarkus-meets-knative-serverless-workloads.aspx#.XbiN1JNKiuN +[6]: https://www.cncf.io/blog/2019/11/01/why-you-should-join-the-cncf-meetup-program/ +[7]: https://www.meetup.com/lp/paymentchanges?mpId=9038 +[8]: https://www.meetup.com/pro/cncf +[9]: https://www.redhat.com/sysadmin/introducing-automation diff --git a/sources/news/20191121 The Cross-Platform Source Explorer Sourcetrail is Now Open Source.md b/sources/news/20191121 The Cross-Platform Source Explorer Sourcetrail is Now Open Source.md new file mode 100644 index 0000000000..c4f25f1419 --- /dev/null +++ b/sources/news/20191121 The Cross-Platform Source Explorer Sourcetrail is Now Open Source.md @@ -0,0 +1,79 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (The Cross-Platform Source Explorer Sourcetrail is Now Open Source) +[#]: via: (https://itsfoss.com/sourcetrail/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +The Cross-Platform Source Explorer Sourcetrail is Now Open Source +====== + +[Sourcetrail][1] is a cross-platform source explorer that lets you visualize the unfamiliar source code by using graph visualization. + +![][2] + +In other words, it makes it easy to understand the structure of source code and how it works (technically) by visually representing them using a graph. + +This is particularly helpful when you join a project and you have to work on existing code written in the past by several developers. + +You can use it with your favorite IDE like Eclipse, IntelliJ IDEA, PyCharm or code editors like Atom, Visual Studio Code, Sublime Text etc. It supports C, C++, Java and Python. + +This old video gives you the introduction to Sourcetrail: + +Even though it was free for non-commercial use, they charged for a commercial license. However, they recently decided to make the whole thing free and open source. + +So, yes, you can find their source code listed on [GitHub][3] now. + +### What Has Changed for Sourcetrail? + +The reason they switched as an open-source solution is that they wanted their tool to be accessible to more developers. + +Their commercial licensing plan was supposed to help them make money – however, it limited the reach of their project. + +In their [announcement post][4], they mentioned their idea of this decision as follows: + +> We have been going back and forth, discussing and testing potential solutions to many of those issues for a long time now. Many of our thoughts revolved around how to make more money and use it to solve those issues. Looking at other companies in the field, it seemed that to make more money, our only option was making our licenses more and more expensive, which in turn would limit our audience to fewer developers. We always dismissed the idea because **we started to make Sourcetrail to benefit as many developers as possible** and not to be a premium product for a few people in a handful of companies. + +Also, they found it tough to provide cross-platform support while trying to reproduce the issues and apply a fix to them, especially for Linux distros. So, making their project open source was an ideal choice. + +To further clarify the situation they also explained why their commercial licensing plan wasn’t working out: + +> Initially we received a couple of public grants that allowed us to launch Sourcetrail publicly. We decided to go down the traditional road of selling software licenses to sustain further development. Of course that meant to keep the code private if we wanted to protect our business…In retrospect, this decision really narrowed down our user base, making it hard for developers to start using Sourcetrail for multiple reasons + +You can find all the details for what they plan for the future in their [announcement post][4]. + +### How to get Sourcetrail on Linux? + +You can find and download the latest release of Sourcetrail on its release page on GitHub: + +[Download Sourcetrail][5] + +Extract the downloaded file and you’ll see a Sourcetrail.sh shell script. Run this script with sudo to install Sourcerail. + +You should [read the documentation][6] for the project setup. They also have some [useful tutorial videos on their YouTube channel][7]. + +Sourcetrail was free before but now it’s free in the true sense. It’s good to see that the developers have made it open source and now more programmers can use this tool to understand large, shared code base. You may also checkout a slightly similar open source tool [Sourcegraph][8]. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/sourcetrail/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://www.sourcetrail.com/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/sourcetrail-ui.png?ssl=1 +[3]: https://github.com/CoatiSoftware/Sourcetrail +[4]: https://www.sourcetrail.com/blog/open_source/ +[5]: https://github.com/CoatiSoftware/Sourcetrail/releases +[6]: https://www.sourcetrail.com/documentation/#PROJECTSETUP +[7]: https://www.youtube.com/channel/UCuKthdG-V4n2RZ1HDJhGVpQ/videos +[8]: https://itsfoss.com/sourcegraph/ diff --git a/sources/news/20191125 Fail-free Kubernetes, significant events, and more industry trends.md b/sources/news/20191125 Fail-free Kubernetes, significant events, and more industry trends.md new file mode 100644 index 0000000000..009e30cd40 --- /dev/null +++ b/sources/news/20191125 Fail-free Kubernetes, significant events, and more industry trends.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Fail-free Kubernetes, significant events, and more industry trends) +[#]: via: (https://opensource.com/article/19/11/fail-free-kubernetes-and-more-trends) +[#]: author: (Tim Hildred https://opensource.com/users/thildred) + +Fail-free Kubernetes, significant events, and more industry trends +====== +A weekly look at open source community, market, and industry trends. +![Person standing in front of a giant computer screen with numbers, data][1] + +As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update. + +## [Why teams fail with Kubernetes—and what to do about it][2] + +> Fail to address the questions "Who is responsible for _x_?" and "Who is affected by _y_?" and you'll put all your efforts at risk. For example, replace "_x_" above with "deciding on namespaces versus clusters for service and environment isolation" or "upgrading all clusters to a new Kubernetes version," and you start to see why you need to clarify the boundaries of responsibility and their impacts. + +**The impact**: Wouldn't it be nice if operators and role-based access control could make the messiness of human interaction go away? Why can't auto-scaling just mean auto-scaling? Tough luck! You're going to have to figure out the people side of it too! + +## [The New Stack Context: The past, present, and future of Kubernetes][3] + +> What have been some of the most significant events in the Kubernetes and cloud native community over the past year? A lot of work has been done in slimming and stabilizing the core. Operators were a growing trend over the past year—operators are mechanisms to expand the number of things you can build on top of Kubernetes. We are seeing Kubernetes expand into new workloads as well. + +**The impact**: In some way, Kubernetes is an ongoing effort in re-building the airplane mid-flight. The good news is that we're getting better at doing that, and the future holds ubiquity, according to this podcast. + +## [Q&A: Fidelity invests in cloud-native, open source projects to step up innovation][4] + +> “We are seeing that Kubernetes, CNCF, and cloud-native technology are the key players for us when we go multicloud and hybrid-cloud model,” said [Amr Abdelhalem][5] (pictured), head of cloud platforms at Fidelity Investments. “That’s why we are here. We are here actually in Kubernetes and KubeCon for that reason. That’s where we see this abstract layer that guarantees you the portability for moving your application from one cloud provider to another.” + +**The impact**: Think about this: Fidelity is a member of the CNCF. What does that mean about the distance between the creator and consumer of open source software? It's exciting because it exemplifies the participatory ideals of open source; its a new challenge for the ecosystem because participants are starting to represent industry verticals that might not have much overlap whose needs need reconciliation. Fun times! + +## [The future of hybrid cloud is bright as 73% of enterprises moving apps back on Prem][6] + +> This year’s report illustrated that creating and executing a cloud strategy has become a multidimensional challenge. At one time, a primary value proposition associated with the public cloud was substantial upfront capex savings. Now, enterprises have discovered that there are other considerations when selecting the best cloud for the business as well, and that one size cloud strategy doesn’t fit all use cases. For example, while applications with unpredictable usage may be best suited to the public clouds offering elastic IT resources, workloads with more predictable characteristics can often run on-premises at a lower cost than public cloud. Savings are also dependent on businesses’ ability to match each application to the appropriate cloud service and pricing tier, and to remain diligent about regularly reviewing service plans and fees, which change frequently. + +**The impact**: The short version is that cost is not the only, or even the most important factor, in choosing where to run a workload. More and more often it is the nature of the workload itself. + +_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/fail-free-kubernetes-and-more-trends + +作者:[Tim Hildred][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/thildred +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) +[2]: https://techbeacon.com/enterprise-it/why-teams-fail-kubernetes-what-do-about-it +[3]: https://thenewstack.io/the-new-stack-context-the-past-present-and-future-of-kubernetes/ +[4]: https://siliconangle.com/2019/11/21/qa-fidelity-invests-cloud-native-open-source-projects-step-innovation-kubecon/ +[5]: https://www.linkedin.com/in/amrhalem/ +[6]: https://www.dqindia.com/the-future-of-hybrid-cloud-is-bright-as-73-of-enterprises-moving-apps-back-on-prem/ diff --git a/sources/news/20191127 Nvidia quietly unveils faster, lower power Tesla GPU accelerator.md b/sources/news/20191127 Nvidia quietly unveils faster, lower power Tesla GPU accelerator.md new file mode 100644 index 0000000000..cc2a666e32 --- /dev/null +++ b/sources/news/20191127 Nvidia quietly unveils faster, lower power Tesla GPU accelerator.md @@ -0,0 +1,70 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Nvidia quietly unveils faster, lower power Tesla GPU accelerator) +[#]: via: (https://www.networkworld.com/article/3482097/nvidia-quietly-unveils-faster-lower-power-tesla-gpu-accelerator.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Nvidia quietly unveils faster, lower power Tesla GPU accelerator +====== +Nvidia has upgraded its Volta line of Tesla GPU-accelerator cards to work faster using the same power as its old model. +client + +Nvidia was all over Supercomputing 19 last week, not surprisingly, and made a lot of news which we will get into later. But overlooked was perhaps the most interesting news of all: a new generation graphics-acceleration card that is faster and way more power efficient. + +Multiple attendees and news sites spotted it at the show, and Nvidia confirmed to me that this is indeed a new card. Nvidia’s “Volta” generation of Tesla GPU-accelerator cards has been out since 2017, so an upgrade was well overdue. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][1] + +The V100S comes only in PCI Express 3 form factor for now but is expected to eventually support Nvidia’s SXM2 interface. SXM is a dual-slot card design by Nvidia that requires no connection to the power supply, unlike the PCIe cards. SXM2 allows the GPU to communicate either with each other or to the CPU through Nvidia’s NVLink, a high-bandwidth, energy-efficient interconnect that can transfer data up to ten times faster than PCIe. + +[][2] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][2] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +With this card, Nvidia is claiming 16.4 single-precision TFLOPS, 8.2 double-precision TFLOPS, and Tensor Core performance of up to 130 TFLOPS. That is only a 4-to-5 percent improvement over the V100 SXM2 design, but 16-to-17 percent faster than the PCIe V100 variant. + +Memory capacity remains at 32GB but Nvidia added High Bandwidth Memory 2 (HBM2) to increase memory performance to 1,134GB/s, a 26 percent improvement over both PCIe and SXM2. + +Now normally a performance boost would see a concurrent increase in power demand, but in this case, the power envelope for the PCIe card is 250 watts, same as the prior generation PCIe card. So this card delivers 16-to-17 percent more compute performance and 26 percent more memory bandwidth at the same power draw. + +**Other News** + +Nvidia made some other news at the conference: + + * A new reference design and ecosystem support for its GPU-accelerated Arm-based reference servers for high-performance computing. The company says it has support from HPE/Cray, Marvell, Fujitsu, and Ampere, the startup led by former Intel executive Renee James looking to build Arm-based server processors. + * These companies will use Nvidia's reference design, which consists of hardware and software components, to build their own GPU-accelerated servers for everything from hyperscale cloud providers to high-performance storage and exascale supercomputing. The design also comes with CUDA-X, a special version of Nvidia’s CUDA GPU development language for Arm processors. + * Launch of Nvidia Magnum IO suite of software designed to help data scientists and AI and high-performance-computing researchers process massive amounts of data in minutes rather than hours. It is optimized to eliminate storage and I/O bottlenecks to deliver up to 20x faster data processing for multi-server, multi-GPU computing nodes. + * Nvidia and DDN, developer of AI and multicloud data management, announced a bundling of DDN’s A3ITM data management system with Nvidia’s DGX SuperPOD systems with so customers can deploy HPC infrastructure with minimal complexity and reduced timelines. The SuperPODs would also come with the new NVIDIA Magnum IO software stack. + * DDN said that SuperPOD was able to be deployed within hours and a single appliance could scale all to 80 nodes.  Benchmarks over a variety of different deep-learning models showed that the DDN system could keep a DGXSuperPOD system fully saturated with data. + + + +**Now see** [**10 of the world's fastest supercomputers**][3] + +Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3482097/nvidia-quietly-unveils-faster-lower-power-tesla-gpu-accelerator.html + +作者:[Andy Patrizio][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.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.networkworld.com/article/3236875/embargo-10-of-the-worlds-fastest-supercomputers.html +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/sources/news/20191127 Zorin OS Responds to the Privacy Concerns.md b/sources/news/20191127 Zorin OS Responds to the Privacy Concerns.md new file mode 100644 index 0000000000..51151d2e87 --- /dev/null +++ b/sources/news/20191127 Zorin OS Responds to the Privacy Concerns.md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Zorin OS Responds to the Privacy Concerns) +[#]: via: (https://itsfoss.com/zorin-os-privacy-concerns/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Zorin OS Responds to the Privacy Concerns +====== + +_**There were some privacy concerns around ‘data collection’ in Zorin OS. It’s FOSS spoke to Zorin OS CEO and here is his response to the controversy.**_ + +After a few days of [Zorin OS 15 Lite][1] release, a Reddit thread surfaced which flagged a privacy concern regarding the Linux distribution. + +The [Reddit thread][2] focuses on the [privacy policy][3] of Zorin OS and warns users that Zorin OS is sending anonymous pings every 60 minutes without users’ consent, which is potentially a privacy issue. + +![][4] + +The policy in question can be quoted here as: + +> _**Anonymous pings**: When using Zorin OS, your computer may occasionally send us a ping which includes an anonymous unique identifier for your computer. We use this information to count the number of active users of Zorin OS. The unique identifier does not identify you unless you (or someone acting on your behalf) discloses it separately. You may choose to disable these pings by uninstalling the “Zorin-os-census” package from your computer_ + +Now, there’s a lot of [discussions][5] surrounding the concern. There’s also a [YouTube video][6] talking about it. + +In a nutshell, it’s a mess. Some insist that they collect our IP addresses and some users complain that they should ask about it while installing Zorin OS. + +While I agree that they could add an opt-out option in the installation process – so I reached out to **Artyom Zorin** (_CEO, Zorin Group_) to clarify the situation. + +### Zorin’s Clarification On What They Collect With Every Anonymous Ping + +When I asked for an elaborate explanation of what the “**anonymous unique identifier**” includes, Artyom mentioned – “_It appears that there are some inaccuracies and misconceptions about the census in the comments sections_“. + +To continue the explanation about the unique identifier, he assured that **their servers do not log IP addresses** when a ping arrives. + +The zorin-os-census script **simply counts the number of unique computers using Zorin OS** and no personal data is being collected along with it. + +Artyom explained in detail: + +> The anonymous identifier is a series of letters and numbers which is randomly generated (not based on any external data) and only used for the Zorin OS Census. Its single purpose is to make sure that the computer isn’t double-counted when a ping is sent from a computer to the server. On a fully-installed Zorin OS system, the anonymous identifier can be found in /var/lib/zorin-os-census/uuid and should look like this:_68f2d95b-f51f-4a5d-9b48-a99c28691b89_ +> * +> *We would like to clarify that no personal or personally-identifiable data is being collected by us and the server does not log IP addresses when pings arrive. The zorin-os-census script is only used to count the number of computers and users running Zorin OS after installation. Even I wouldn’t be able to tell which computer is my own from looking at the server-side database. I have attached a screenshot of a snippet of the database table displaying the information we store. + +He also stressed his ‘commitment on privacy’: + +> Privacy is an essential human right. It’s a core tenet of our mission to give you back control of your technology, and not the other way around. We make privacy a priority with every decision we make, and we’re committed to protecting it in every level of the software we build. + +As you can observe in the response above, he shared a screenshot of how their database of unique identifiers looks like: + +![][7] + +If you’re still curious, you can also check out the [source code][8] for the zorin-os-census script. + +### Can We Opt-Out Of It? + +While the data collected may be ‘harmless’, it is important to give the option to the user whether or not they want Zorin OS to collect the data, right? + +So, when I inquired about the same, he mentioned that i**t was already something planned for Zorin OS 15 Lite release**. + +However, they did not want to rush to add it before properly testing it. Hence, they decided to keep it for the upcoming release (**Zorin OS 15.1**) which is planned to arrive in **early-to-mid December this year.** + +> We have in fact been working on implementing an opt-out option for this into the Zorin OS installer (Ubiquity). To ensure the stability and accessibility of this new functionality we’re adding to Ubiquity, we have scheduled a period of time to translate the text strings and rigorously test the software (in order to avoid regressions), as the installer is a critical component of the operating system. Unfortunately, the testing period for the opt-out option didn’t complete before our planned release of Zorin OS 15 Lite, and we, therefore, decided not to risk adding it before we could guarantee its stability. However, we are on track to include the opt-out option in the upcoming Zorin OS 15.1 release, which we plan to release in early-to-mid December. + +### Will It Be Something Similar To What Ubuntu Does? + +Ubuntu does let you opt-out from collecting information about your computer. + +So, when I asked if Zorin OS will add something similar to that, he responded with some details about how Ubuntu collects data and how Zorin OS is different from that. + +He mentioned the fact that Ubuntu comes pre-installed with a **popularity-contest** package that **occasionally sends data of what packages the user has installed** to the Ubuntu Developers. + +And, further clarified that **Zorin OS does not include that**. + +> While Ubuntu’s telemetry tool gives users the option to not send extensive information about the computers to the Ubuntu developers, selecting the “No” option still sends a ping to Ubuntu’s servers . +> +> From our research, it is not clear whether Ubuntu’s servers store logs of users’ IP addresses when they receive telemetry data. In addition, Zorin OS does not include the “popularity-contest” package that is pre-installed in Ubuntu. This package is designed to occasionally send a list of all packages a user has installed on their computer to the Ubuntu developers. + +**In the end…** + +While the concern regarding the anonymous pings may not seem to a privacy threat, an opt-out option should be presented to the user while installing Zorin OS. Let’s wait and watch if it should arrive in the upcoming Zorin OS 15.1 release. + +What do you think about the privacy concern mentioned above? Let us know your thoughts in the comments down below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/zorin-os-privacy-concerns/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/zorin-os-lite/ +[2]: https://www.reddit.com/r/FreeAsInFreedom/comments/e0yhw4/beware_zorin_os_sends_anonymous_pings_every_60/ +[3]: https://zorinos.com/legal/privacy/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/zorin-os-privacy-reddit.jpg?ssl=1 +[5]: https://www.reddit.com/r/linux/comments/e0zd5n/beware_zorin_os_sends_anonymous_pings_every_60/ +[6]: https://www.youtube.com/watch?v=bcgk9LvC36Y&feature=youtu.be&t=860 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/zorin-census-database.png?ssl=1 +[8]: https://launchpad.net/~zorinos/+archive/ubuntu/stable/+sourcepub/10183568/+listing-archive-extra diff --git a/sources/news/20191128 Open Source Music Notations Software MuseScore 3.3 Released.md b/sources/news/20191128 Open Source Music Notations Software MuseScore 3.3 Released.md new file mode 100644 index 0000000000..2835a5d06a --- /dev/null +++ b/sources/news/20191128 Open Source Music Notations Software MuseScore 3.3 Released.md @@ -0,0 +1,89 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Open Source Music Notations Software MuseScore 3.3 Released!) +[#]: via: (https://itsfoss.com/musescore/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Open Source Music Notations Software MuseScore 3.3 Released! +====== + +_**Brief: MuseScore is an open-source software to help you create, play, and print sheet music. They released a major update recently. So, we take a look at what MuseScore has to offer**_ _**overall.**_ + +### MuseScore: A Music Composition and Notation Software + +![][1] + +[MuseScore][2] is open-source software that lets you create, play, and print [sheet music][3]. + +You can even use a MIDI keyboard as input and simply play the tune you want to create the notation of. + +In order to make use of it, you need to know how sheet music notations work. In either case, you can just play something using your MIDI keyboard or any other instrument and learn how the music notations work while using it. + +So, it should come in handy for beginners and experts as well. + +You can download and use MuseScore for free. However, if you want to share your music/composition and reach out to a wider community on the MuseScore platform, you can opt to create a free or premium account on [MuseScore.com][4]. + +### Features of MuseScore + +![Musescore 3 Screenshot][5] + +MuseScore includes a lot of things that can be highlighted. If you are someone who is not involved in making music notations for your compositions – you might have to dig deeper just like me. + +Usually, I just head over to any [DAW available on Linux][6] and start playing something to record/loop it without needing to create the music notations. So, for me, MuseScore definitely presents a learning curve with all the features offered. + +I’ll just list out the features with some brief descriptions – so you can explore them if it sounds interesting to you. + + * Supports Input via MIDI keyboard + * You can transfer to/from other programs via [MusicXML][7], MIDI, and other options. + * A Huge collection of palettes (music symbols) to choose from. + * You also get the ability to re-arrange the palettes and create your own list of most-used palettes or edit them. + * Some plugins supported to extend the functionality + * Import PDFs to read and play notations + * Several instruments supported + * Basic or Advanced layout of palettes to get started + + + +Some of the recent key changes include the palettes redesign, accessibility, and the not input workflow. For reference, you can check out how the new palettes work: + +### Installing MuseScore 3.3.3 on Ubuntu/Linux + +The latest version of MuseScore is 3.3.3 with all the bug fixes and improvements to its recent [MuseScore 3.3 release][8]. + +You may find an older release in your Software Center (or your official repo). So, you can either opt for a Flatpak package, Snap, or maybe an AppImage from its [download page][9] with links for different Linux distributions. + +[Download MuseScore][9] + +**Wrapping Up** + +I was quite fascinated to learn about MuseScore being an open-source and free solution to create, play, and print sheet music. + +It may not be the most easy-to-use software there is – but when considering the work with music notations, it will help you learn more about it and help you with your work as well. + +What do you think about MuseScore? Do share your thoughts in the comments below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/musescore/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/musescore-3.jpg?ssl=1 +[2]: https://musescore.org/en +[3]: https://en.wikipedia.org/wiki/Sheet_music +[4]: https://musescore.com/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/musescore-3-screenshot.jpg?ssl=1 +[6]: https://itsfoss.com/best-audio-editors-linux/ +[7]: https://en.wikipedia.org/wiki/MusicXML +[8]: https://musescore.org/en/3.3 +[9]: https://musescore.org/en/download diff --git a/sources/talk/20181018 Think global- How to overcome cultural communication challenges.md b/sources/talk/20181018 Think global- How to overcome cultural communication challenges.md index 1d36d5e88d..1244f13079 100644 --- a/sources/talk/20181018 Think global- How to overcome cultural communication challenges.md +++ b/sources/talk/20181018 Think global- How to overcome cultural communication challenges.md @@ -1,3 +1,5 @@ +translating + Think global: How to overcome cultural communication challenges ====== Use these tips to ensure that every member of your global development team feels involved and understood. diff --git a/sources/talk/20190828 Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word.md b/sources/talk/20190828 Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word.md deleted file mode 100644 index ab1ad90fe7..0000000000 --- a/sources/talk/20190828 Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word.md +++ /dev/null @@ -1,92 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word) -[#]: via: (https://itsfoss.com/gimp-fork-glimpse/) -[#]: author: (John Paul https://itsfoss.com/author/john/) - -Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word -====== - -In the world of open source applications, forking is common when members of the community want to take an application in a different direction than the rest. The latest newsworthy fork is named [Glimpse][1] and is intended to fix certain issues that users have with the [GNU Image Manipulation Program][2], commonly known as GIMP. - -### Why create a fork of GIMP? - -![][3] - -When you visit the [homepage][1] of the Glimpse app, it says that the goal of the project is to “experiment with other design directions and fix longstanding bugs.” That doesn’t sound too much out of the ordinary. However, if you start reading the project’s blog posts, a different image appears. - -According to the project’s [first blog post][4], they created this fork because they did not like the GIMP name. According to the post, “A number of us disagree that the name of the software is suitable for all users, and after 13 years of the project refusing to budge on this have decided to fork!” - -If you are wondering why these people find the work GIMP disagreeable they answer that question on the [About page][5]: - -> “If English is not your first language, then you may not have realised that the word “gimp” is problematic. In some countries it is considered a slur against disabled people and a playground insult directed at unpopular children. It can also be linked to certain “after dark” activities performed by consenting adults.” - -They also point out that they are not making this move out of political correctness or being oversensitive. “In addition to the pain it can cause to marginalized communities many of us have our own free software advocacy stories about the GNU Image Manipulation Program not being taken seriously as an option by bosses or colleagues in professional settings.” - -As if to answer many questions, they also said, “It is unfortunate that we have to fork the whole project to change the name, but we feel that discussions about the issue are at an impasse and that this is the most positive way forward.” - -[][6] - -Suggested read  After 6 Years, GIMP 2.10 is Here With Ravishing New Looks and Tons of New Features - -It looks like the Glimpse name is not written in stone. There is [an issue][7] on their GitHub page about possibly picking another name. Maybe they should just drop GNU. I don’t think the word IMP has a bad connotation. - -### A diverging path - -![GIMP 2.10][8] - -[GIMP][6] has been around for over twenty years, so any kind of fork is a big task. Currently, [they are planning][9] to start by releasing Glimpse 0.1 in September 2019. This will be a soft fork, meaning that changes will be mainly cosmetic as they migrate to a new identity. - -Glimpse 1.0 will be a hard fork where they will be actively changing the codebase and adding to it. They want 1.0 to be a port to GTK3 and have its own documentation. They estimate that this will not take place until GIMP 3 is released in 2020. - -Beyond the 1.0, the Glimpse team has plans to forge their own identity. They plan to work on a “front-end UI rewrite”. They are currently discussing [which language][10] they should use for the rewrite. There seems to be a lot of push for D and Rust. They also [hope to][4] “add new functionality that addresses common user complaints” as time goes on. - -### Final Thoughts - -I have used GIMP a little bit in the past but was never too bothered by the name. To be honest, I didn’t know what it meant for quite a while. Interestingly, when I searched Wikipedia for GIMP, I came across an entry for the [GIMP Project][11], which is a modern dance project in New York that includes disabled people. I guess gimp isn’t considered a derogatory term by everyone. - -To me, it seems like a lot of work to go through to change a name. It also seems like the idea of rewriting the UI was tacked to make the project look more worthwhile. I wonder if they will tweak it to bring a more classic UI like [using Ctrl+S to save in GIMP][12]/Glimpse. Let’s wait and watch. - -[][13] - -Suggested read  Finally! WPS Office Has A New Release for Linux - -If you are interested in the project, you can follow them on [Twitter][14], check out their [GitHub account][15], or take a look at their [Patreon page][16]. - -Are you offended by the GIMP name? Do you think it is worthwhile to fork an application, just so you can rename it? 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][17]. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/gimp-fork-glimpse/ - -作者:[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://getglimpse.app/ -[2]: https://www.gimp.org/ -[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/08/gimp-fork-glimpse.png?resize=800%2C450&ssl=1 -[4]: https://getglimpse.app/posts/so-it-begins/ -[5]: https://getglimpse.app/about/ -[6]: https://itsfoss.com/gimp-2-10-release/ -[7]: https://github.com/glimpse-editor/Glimpse/issues/92 -[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/08/gimp-screenshot.jpg?resize=800%2C508&ssl=1 -[9]: https://getglimpse.app/posts/six-week-checkpoint/ -[10]: https://github.com/glimpse-editor/Glimpse/issues/70 -[11]: https://en.wikipedia.org/wiki/The_Gimp_Project -[12]: https://itsfoss.com/how-to-solve-gimp-2-8-does-not-save-in-jpeg-or-png-format/ -[13]: https://itsfoss.com/wps-office-2016-linux/ -[14]: https://twitter.com/glimpse_editor -[15]: https://github.com/glimpse-editor/Glimpse -[16]: https://www.patreon.com/glimpse -[17]: https://reddit.com/r/linuxusersgroup diff --git a/sources/talk/20191004 What-s in an open source name.md b/sources/talk/20191004 What-s in an open source name.md index e15ac57a28..ae5ce6ee65 100644 --- a/sources/talk/20191004 What-s in an open source name.md +++ b/sources/talk/20191004 What-s in an open source name.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (laingke) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) @@ -152,7 +152,7 @@ via: https://opensource.com/article/19/10/open-source-name-origins 作者:[Joshua Allen Holm][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) +译者:[laingke](https://github.com/laingke) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/talk/20191025 Why I made the switch from Mac to Linux.md b/sources/talk/20191025 Why I made the switch from Mac to Linux.md deleted file mode 100644 index 342a6c9bd3..0000000000 --- a/sources/talk/20191025 Why I made the switch from Mac to Linux.md +++ /dev/null @@ -1,77 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Why I made the switch from Mac to Linux) -[#]: via: (https://opensource.com/article/19/10/why-switch-mac-linux) -[#]: author: (Matthew Broberg https://opensource.com/users/mbbroberg) - -Why I made the switch from Mac to Linux -====== -Thanks to a lot of open source developers, it's a lot easier to use -Linux as your daily driver than ever before. -![Hands programming][1] - -I have been a huge Mac fan and power user since I started in IT in 2004. But a few months ago—for several reasons—I made the commitment to shift to Linux as my daily driver. This isn't my first attempt at fully adopting Linux, but I'm finding it easier than ever. Here is what inspired me to switch. - -### My first attempt at Linux on the desktop - -I remember looking up at the projector, and it looking back at me. Neither of us understood why it wouldn't display. VGA cords were fully seated with no bent pins to be found. I tapped every key combination I could think of to signal my laptop that it's time to get over the stage fright. - -I ran Linux in college as an experiment. My manager in the IT department was an advocate for the many flavors out there, and as I grew more confident in desktop support and writing scripts, I wanted to learn more about it. IT was far more interesting to me than my computer science degree program, which felt so abstract and theoretical—"who cares about binary search trees?" I thought—while our sysadmin team's work felt so tangible. - -This story ends with me logging into a Windows workstation to get through my presentation for class, and marks the end of my first attempt at Linux as my day-to-day OS. I admired its flexibility, but compatibility was lacking. I would occasionally write a script that SSHed into a box to run another script, but I stopped using Linux on a day-to-day basis. - -### A fresh look at Linux compatibility - -When I decided to give Linux another go a few months ago, I expected more of the same compatibility nightmare, but I couldn't be more wrong. - -Right after the installation process completed, I plugged in a USB-C hub to see what I'd gotten myself into. Everything worked immediately. The HDMI-connected extra-wide monitor popped up as a mirrored display to my laptop screen, and I easily adjusted it to be a second monitor. The USB-connected webcam, which is essential to my [work-from-home life][2], showed up as a video with no trouble at all. Even my Mac charger, which was already plugged into the hub since I've been using a Mac, started to charge my very-not-Mac hardware. - -My positive experience was probably related to some updates to USB-C, which received some needed attention in 2018 to compete with other OS experiences. As [Phoronix explained][3]: - -> "The USB Type-C interface offers an 'Alternate Mode' extension for non-USB signaling and the biggest user of this alternate mode in the specification is allowing DisplayPort support. Besides DP, another alternate mode is the Thunderbolt 3 support. The DisplayPort Alt Mode supports 4K and even 8Kx4K video output, including multi-channel audio. -> -> "While USB-C alternate modes and DisplayPort have been around for a while now and is common in the Windows space, the mainline Linux kernel hasn't supported this functionality. Fortunately, thanks to Intel, that is now changing." - -Thinking beyond ports, a quick scroll through the [Linux on Laptops][4] hardware options shows a much more complete set of choices than I experienced in the early 2000s. - -This has been a night-and-day difference from my first attempt at Linux adoption, and it's one I welcome with open arms. - -### Breaking out of Apple's walled garden - -Using Linux has added new friction to my daily workflow, and I love that it has. - -My Mac workflow was seamless: hop on an iPad in the morning, write down some thoughts on what my day will look like, and start to read some articles in Safari; slide over my iPhone to continue reading; then log into my MacBook where years of fine-tuning have worked out how all these pieces connect. Keyboard shortcuts are built into my brain; user experiences are as they've mostly always been. It's wildly comfortable. - -That comfort comes with a cost. I largely forgot how my environment functions, and I couldn't answer questions I wanted to answer. Did I customize some [PLIST files][5] to get that custom shortcut, or did I remember to check it into [my dotfiles][6]? How did I get so dependent on Safari and Chrome when Firefox has a much better mission? Or why, specifically, won't I use an Android-based phone instead of my i-things? - -On that note, I've often thought about shifting to an Android-based phone, but I would lose the connection I have across all these devices and the little conveniences designed into the ecosystem. For instance, I wouldn't be able to type in searches from my iPhone for the Apple TV or share a password with AirDrop with my other Apple-based friends. Those features are great benefits of homogeneous device environments, and it is remarkable engineering. That said, these conveniences come at a cost of feeling trapped by the ecosystem. - -I love being curious about how devices work. I want to be able to explain environmental configurations that make it fun or easy to use my systems, but I also want to see what adding some friction does for my perspective. To paraphrase [Marcel Proust][7], "The real voyage of discovery consists not in seeking new lands but seeing with new eyes." My use of technology has been so convenient that I stopped being curious about how it all works. Linux gives me an opportunity to see with new eyes again. - -### Inspired by you - -All of the above is reason enough to explore Linux, but I have also been inspired by you. While all operating systems are welcome in the open source community, Opensource.com writers' and readers' joy for Linux is infectious. It inspired me to dive back in, and I'm enjoying the journey. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/why-switch-mac-linux - -作者:[Matthew Broberg][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/mbbroberg -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop.png?itok=pGfEfu2S (Hands programming) -[2]: https://opensource.com/article/19/8/rules-remote-work-sanity -[3]: https://www.phoronix.com/scan.php?page=news_item&px=Linux-USB-Type-C-Port-DP-Driver -[4]: https://www.linux-laptop.net/ -[5]: https://fileinfo.com/extension/plist -[6]: https://opensource.com/article/19/3/move-your-dotfiles-version-control -[7]: https://www.age-of-the-sage.org/quotations/proust_having_seeing_with_new_eyes.html diff --git a/sources/talk/20191028 6 signs you might be a Linux user.md b/sources/talk/20191028 6 signs you might be a Linux user.md index d66d08cf35..977c586516 100644 --- a/sources/talk/20191028 6 signs you might be a Linux user.md +++ b/sources/talk/20191028 6 signs you might be a Linux user.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (wxy) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/talk/20191030 Watson IoT chief- AI can broaden IoT services.md b/sources/talk/20191030 Watson IoT chief- AI can broaden IoT services.md new file mode 100644 index 0000000000..eaab58b886 --- /dev/null +++ b/sources/talk/20191030 Watson IoT chief- AI can broaden IoT services.md @@ -0,0 +1,64 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Watson IoT chief: AI can broaden IoT services) +[#]: via: (https://www.networkworld.com/article/3449243/watson-iot-chief-ai-can-broaden-iot-services.html) +[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) + +Watson IoT chief: AI can broaden IoT services +====== +IBM’s Kareem Yusuf talks smart maintenance systems, workforce expertise and some IoT use cases you might not have thought of. +IBM + +IBM thrives on the complicated, asset-intensive part of the enterprise [IoT][1] market, according to Kareem Yusuf, GM of the company’s Watson IoT business unit. From helping seaports manage shipping traffic to keeping technical knowledge flowing within an organization, Yusuf said that the idea is to teach [artificial intelligence][2] to provide insights from the reams of data generated by such complex systems. + +[Predictive maintenance][3] is probably the headliner in terms of use cases around asset-intensive IoT, and Yusuf said that it’s a much more complicated task than many people might think. It isn’t simply a matter of monitoring, say, pressure levels in a pipe somewhere and throwing an alert when they move outside of norms. It’s about aggregate information on failure rates and asset planning, that a company can have replacements and contingency plans ready for potential failures. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][4] + +“It’s less to do with ‘Is that thing going to fail on that day?’ more to do with, because I'm now leveraging all these technologies, I have more insights to make the decision to say, ‘this is my more optimal work-management route,’” he said. “And that’s how I save money.” + +For that to work, of course, AI has to be trained. Yusuf uses the example of a drone-based system to detect worrisome cracks in bridges, a process that usually involves sending technicians out to look at the bridge in person. Allowing AI to differentiate between serious and trivial damage means showing it reams of images of both types, and sourcing that kind of information isn’t always straightforward. + +“So when a client says they want that [service], often clients themselves will say, ‘Here's some training data sets we’d like you to start with,’” he said, noting that there are also open-source and government data sets available for some applications. + +IBM itself collects a huge amount of data from its various AI implementations, and, with the explicit permission of its existing clients, uses some of that information to train new systems that do similar things. + +“You get this kind of collaborative cohesion going on,” said Yusuf. “So when you think about, say[, machine-learning][5] models to help predict foot traffic for space planning and building usage … we can build that against data we have, because we already drive a lot of that kind of test data through our systems.” + +Another non-traditional use case is for the design of something fantastically complicated, like an autonomous car. There are vast amounts of engineering requirements involved in such a process, governing the software, orchestration, hardware specs, regulatory compliance and more. A system with a particular strength in natural-language processing (NLP) could automatically understand what the various requirements actually mean and relate them to one another, detecting conflicts and impossibilities, said Yusuf. + +“We’ve trained up Watson using discovery services and NLP to be able to tell you whether your requirements are clear,” he said. “It will find duplicates or conflicting requirements.” + +Nor is it simply a matter of enabling AI-based IoT systems on the back end. Helping technicians do work is a critical part of IBM’s strategy in the IoT sector, and the company has taken aim at the problem of knowledge transfer via mobility solutions. + +Take, for example, a newer technician dispatched to repair an elevator or other complex piece of machinery. With a mobile assistant app on his or her smartphone, the tech can do more than simply referencing error codes – an AI-driven system can cross reference an error code against the history of a specific elevator, noting what, in the past, has tended to be the root of a given problem, and what needs to be done to fix it. + +The key, said Yusuf, is to enable that kind of functionality without disrupting the standard workflow that’s already in place. + +“When we think about leveraging AI, it has to like seamlessly integrate into the [existing] way of working,” he said. + +Join the Network World communities on [Facebook][6] and [LinkedIn][7] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3449243/watson-iot-chief-ai-can-broaden-iot-services.html + +作者:[Jon Gold][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.networkworld.com/author/Jon-Gold/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[2]: https://www.networkworld.com/article/3243925/artificial-intelligence-may-not-need-networks-at-all.html +[3]: https://www.networkworld.com/article/3340132/why-predictive-maintenance-hasn-t-taken-off-as-expected.html +[4]: https://www.networkworld.com/newsletters/signup.html +[5]: https://www.networkworld.com/article/3202701/the-inextricable-link-between-iot-and-machine-learning.html +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191031 A Bird-s Eye View of Big Data for Enterprises.md b/sources/talk/20191031 A Bird-s Eye View of Big Data for Enterprises.md new file mode 100644 index 0000000000..c62169b830 --- /dev/null +++ b/sources/talk/20191031 A Bird-s Eye View of Big Data for Enterprises.md @@ -0,0 +1,62 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A Bird’s Eye View of Big Data for Enterprises) +[#]: via: (https://opensourceforu.com/2019/10/a-birds-eye-view-of-big-data-for-enterprises/) +[#]: author: (Swapneel Mehta https://opensourceforu.com/author/swapneel-mehta/) + +A Bird’s Eye View of Big Data for Enterprises +====== + +[![][1]][2] + +_Entrepreneurial decisions are made using data and business acumen. Big Data is today a tool that helps to maximise revenue and customer engagement. Open source tools like Hadoop, Apache Spark and Apache Storm are the popular choices when it comes to analysing Big Data. As the volume and variety of data in the world grows by the day, there is great scope for the discovery of trends as well as for innovation in data analysis and storage._ + +In the past five years, the spate of research focused on machine learning has resulted in a boom in the nature and quality of heterogeneous data sources that are being tapped by providers for their customers. Cheaper compute and widespread storage makes it so much easier to apply bulk data processing techniques, and derive insights from existing and unexplored sources of rich user data including logs and traces of activity whilst using software products. Business decision making and strategy has been primarily dictated by data and is usually supported by business acumen. But in recent times it has not been uncommon to see data providing conclusions seemingly in contrast with conventional business logic. + +One could take the simple example of the baseball movie ‘Moneyball’, in which the protagonist defies all notions of popular wisdom in looking solely at performance statistics to evaluate player viability, eventually building a winning team of players – a team that would otherwise never have come together. The advantage of Big Data for enterprises, then, becomes a no brainer for most corporate entities looking to maximise revenue and engagement. At the back-end, this is accomplished by popular combinations of existing tools specially designed for large scale, multi-purpose data analysis. Apache, Hadoop and Spark are some of the most widespread open source tools used in this space in the industry. Concomitantly, it is easy to imagine that there are a number of software providers offering B2B services to corporate clients looking to outsource specific portions of their analytics. Therefore, there is a bustling market with customisable, proprietary technological solutions in this space as well. + +Traditionally, Big Data refers to the large volumes of unstructured and heterogeneous data that is often subject to processing in order to provide insights and improve decision-making regarding critical business processes. The McKinsey Global institute estimates that data volumes have been growing at 40 per cent per year and will grow 44x between the years 2009 and 2020. But there is more to Big Data than just its immense volume. The rate of data production is an important factor given that smaller data streams generated at faster rates produce larger pools than their counterparts. Social media is a great example of how small networks can expand rapidly to become rich sources of information — up to massive, billion-node scales. + +Structure in data is a highly variable attribute given that data is now extracted from across the entire spectrum of user activity. Conventional formats of storage, including relational databases, have been virtually replaced by massively unstructured data pools designed to be leveraged in manners unique to their respective use cases. In fact, there has been a huge body of work on data storage in order to leverage various write formats, compression algorithms, access methods and data structures to arrive at the best combination for improving productivity of the workflow reliant on that data. A variety of these combinations has emerged to set the industry standards in their respective verticals, with the benefits ranging from efficient storage to faster access. + +Finally, we have the latent value in these data pools that remains to be exploited by the use of emerging trends in artificial intelligence and machine learning. Personalised advertising recommendations are a huge factor driving revenue for social media giants like Facebook and companies like Google that offer a suite of products and an ecosystem to use them. The well-known Silicon Valley giant started out as a search provider, but now controls a host of apps and most of the entry points for the data generated in the course of people using a variety of electronic devices across the world. Established financial institutions are now exploring the possibility of a portion of user data being put on an immutable public ledger to introduce a blockchain-like structure that can open the doors to innovation. The pace is picking up as product offerings improve in quality and expand in variety. Let’s get a bird’s eye view of this subject to understand where the market stands. + +The idea behind building better frameworks is increasingly turning into a race to provide more add-on features and simplify workflows for the end user to engage with. This means the categories have many blurred lines because most products and tools present themselves as end-to-end platforms to manage Big Data analytics. However, we’ll attempt to divide this broadly into a few categories and examine some providers in each of these. + +**Big Data storage and processing** +Infrastructure is the key to building a reliable workflow when it comes to enterprise use cases. Earlier, relational databases were worthwhile to invest in for small and mid-sized firms. However, when the data starts pouring in, it is usually the scalability that is put to the test first. Building a flexible infrastructure comes at the cost of complexity. It is likely to have more moving parts that can cause failure in the short-term. However, if done right – something that will not be easy because it has to be tailored exactly to your company – it can result in life-changing improvements for both users and the engineers working with the said infrastructure to build and deliver state-of-the-art products. + +There are many alternatives to SQL, with the NoSQL paradigm being adopted and modified for building different types of systems. Cassandra, MongoDB and CouchDB are some well-known alternatives. Most emerging options can be distinguished based on their disruption, which is aimed at the fundamental ACID properties of databases. To recall, a transaction in a database system must maintain atomicity, consistency, isolation, and durability − commonly known as ACID properties − in order to ensure accuracy, completeness, and data integrity (from Tutorialspoint). For instance, CockroachDB, an open source offshoot of Google’s Spanner database system, has gained traction due to its support for being distributed. Redis and HBase offer a sort of hybrid storage solution while Neo4j remains a flag bearer for graph structured databases. However, traditional areas aside, there are always new challenges on the horizon for building enterprise software. + +![Figure 1: A crowded landscape to follow \(Source: Forbes\)][3] + +Backups are one such area where startups have found viable disruption points to enter the market. Cloud backups for enterprise software are expensive, non-trivial procedures and offloading this work to proprietary software offers a lucrative business opportunity. Rubrik and Cohesity are two companies that originally started out in this space and evolved to offer added services atop their primary offerings. Clumio is a recent entrant, purportedly creating a data fabric that the promoters expect will serve as a foundational layer to run analytics on top of. It is interesting to follow recent developments in this burgeoning space as we see competitors enter the market and attempt to carve a niche for themselves with their product offerings. + +**Big Data analytics in the cloud** +Apache Hadoop remains the popular choice for many organisations. However, many successors have emerged to offer a set of additional analytical capabilities: Apache Spark, commonly hailed as an improvement to the Hadoop ecosystem; Apache Storm that offers real-time data processing capabilities; and Google’s BigQuery, which is supposedly a full-fledged platform for Big Data analytics. + +Typically, cloud providers such as Amazon Web Services and Google Cloud Platform tend to build in-house products leveraging these capabilities, or replicate them entirely and offer them as hosted services to businesses. This helps them provide enterprise offerings that are closely integrated within their respective cloud computing ecosystem. There has been some discussion about the moral consequences of replicating open source products to profit off closed source versions of the same, but there has been no consensus on the topic, nor any severe consequences suffered on account of this questionable approach to boost revenue. + +Another hosted service offering a plethora of Big Data analytics tools is Cloudera which has an established track record in the market. It has been making waves since its merger with Hortonworks earlier this year, giving it added fuel to compete with the giants in its bid to become the leading enterprise cloud provider in the market. + +Overall, we’ve seen interesting developments in the Big Data storage and analysis domain and as the volume and variety of data grows, so do the opportunities to innovate in the field. + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/10/a-birds-eye-view-of-big-data-for-enterprises/ + +作者:[Swapneel Mehta][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://opensourceforu.com/author/swapneel-mehta/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/10/Figure-1-Big-Data-analytics-and-processing-for-the-enterprise.jpg?resize=696%2C449&ssl=1 (Figure 1 Big Data analytics and processing for the enterprise) +[2]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/10/Figure-1-Big-Data-analytics-and-processing-for-the-enterprise.jpg?fit=900%2C580&ssl=1 +[3]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/10/Figure-2-A-crowded-landscape-to-follow.jpg?resize=350%2C254&ssl=1 diff --git a/sources/talk/20191031 The Best Reasons To Use Enterprise Network Management Software.md b/sources/talk/20191031 The Best Reasons To Use Enterprise Network Management Software.md new file mode 100644 index 0000000000..654078f72a --- /dev/null +++ b/sources/talk/20191031 The Best Reasons To Use Enterprise Network Management Software.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (The Best Reasons To Use Enterprise Network Management Software) +[#]: via: (https://opensourceforu.com/2019/10/the-best-reasons-to-use-enterprise-network-management-software/) +[#]: author: (Ruby Hamilton https://opensourceforu.com/author/ruby-hamilton/) + +The Best Reasons To Use Enterprise Network Management Software +====== + +[![][1]][2] + +_Your company has workers in the field all day every day. You have sent them out with tablets, phones, and minicomputers, but you need to connect these devices back to the home network. When you begin shopping for enterprise software, you will find that it should provide you with all five benefits listed below. You can reorganize your business, streamline all the things that you do, and reduce the headaches that come along with mobile device management._ + +**1\. Increased Security** + +When you begin shopping for [_Micro Focus enterprise network management software_][3], you will improve security instantly. Devices that are not managed are inherently unsafe. The device becomes a security risk every time it logs on to a new WiFi network or it uses Bluetooth in a new place. + +If a hacker wanted access to your network, they could hack a mobile device for each access. You may have staff members who use Bluetooth, and Bluetooth could cause security concerns for you. This is especially important if your company has a lot of sensitive information on each device. + +**2\. Easier Workflow** + +Workflow improves instantly when all your mobile devices are connected. Your staff can access all their assignments, appointments, and numbers for the day. You can send messages to your staff, and you can check on their progress using the enterprise software. Your staff members can ask you questions through the system instead of sending emails that are too difficult to check. Plus, you can hand out only mobile devices so that your staff members are not carrying too many devices. + +If your staff members need to communicate with each other to complete a project, they can share information with ease. You can load all your manuals and pricing charts so that your staff can access this information, and you can offer fast service to each customer. Your company can use its quick service and abundance of information as selling points for customers. + +**3\. Your Staff Can Go Anywhere** + +Your staff can go anywhere while still working diligently. The phone, tablet, or computer that they are using will still receive all the information that you would get if you were in the office. You can send your staff on trips to work on behalf of the company, and they will have all the information that is required to handle big projects. + +When your staff members need to present information to clients, they can pull that information from the cloud on their devices. This is a much easier way for you to store information, and you do not need to carry a massive laptop around. Plus, you can give everyone on your staff a mobile device instead of filling your office with clunky computers. + +**4\. Lower Costs** + +The [_enterprise software_][4] that you use will instantly lower your costs. You save time when managing these devices because the software does so much of it for you. You do not lose money due to hacking, and you can create reports from the information on each device. + +Your company will spend less time selling new services or products to customers, and you will find that the devices last longer because they are consistently updated. The software is updated online when the developer builds a new version, and you can hand out just one device to everyone on your staff. There is no need for you to spend extra money on new devices, extra security software, or more man-hours. + +**5\. Lower IT Demands** + +Your IT team is not swamped by the amount of activity on your network. When your IT demands are lower, your carbon footprint drops. The servers in your office will not work as hard as they once did, and you can easily upgrade your servers without bogging them down with information. + +The enterprise system can clean up junk files on every device, and you will not need to hire extra people in the IT department just to manage these devices. It is very easy for you to maintain the IT network, and you will save money on hardware. If your company has a small budget, you need to use the enterprise system to cut back on costs. + +**Conclusion** + +It is very easy for you to install enterprise software when your company is using mobile devices every day. The best part of using enterprise software is that you can streamline what you do, only use mobile devices, and reduce your costs over time. You can send your staff into the field with mobile devices, and you also have the capacity to send information to your staff instead of forcing them to use papers all day every day. You can save money on devices, and you can maintain your system using the software instead of forcing your IT team to do all the work for you. + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/10/the-best-reasons-to-use-enterprise-network-management-software/ + +作者:[Ruby Hamilton][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://opensourceforu.com/author/ruby-hamilton/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2016/08/Computer-network-connectivity.jpg?resize=696%2C391&ssl=1 (Computer network connectivity) +[2]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2016/08/Computer-network-connectivity.jpg?fit=800%2C449&ssl=1 +[3]: https://www.microfocus.com/en-us/products/network-operations-management-suite/overview +[4]: https://en.wikipedia.org/wiki/Enterprise_software diff --git a/sources/talk/20191031 Wireless noise protocol can extend IoT range.md b/sources/talk/20191031 Wireless noise protocol can extend IoT range.md new file mode 100644 index 0000000000..bafa9c53e1 --- /dev/null +++ b/sources/talk/20191031 Wireless noise protocol can extend IoT range.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Wireless noise protocol can extend IoT range) +[#]: via: (https://www.networkworld.com/article/3449819/wireless-noise-protocol-can-extend-iot-range.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +Wireless noise protocol can extend IoT range +====== +On-off noise power communication (ONPC) protocol creates a long-distance carrier of noise energy in Wi-Fi to ping IoT devices. +Thinkstock + +The effective range of [Wi-Fi][1], and other wireless communications used in [Internet of Things][2] networks could be increased significantly by adding wireless noise, say scientists. + +This counter-intuitive solution could extend the range of an off-the-shelf Wi-Fi radio by 73 yards, a group led by Brigham Young University says. Wireless noise, a disturbance in the signal, is usually unwanted. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][3] + +The remarkably simple concept sends wireless noise-energy over-the-top of Wi-Fi data traffic in an additional, unrelated channel. That second channel, or carrier, which is albeit at a much lower data rate than the native Wi-Fi, travels further, and when encoded can be used to ping a sensor, say, to find out if the device is alive when the Wi-Fi link itself may have lost association through distance-caused, poor handshaking. + +[][4] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][4] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +The independent, additional noise channel travels further than the native Wi-Fi. “It works beyond the range of Wi-Fi,” [the scientists say in their paper][5]. + +Applications could be found in hard-to-reach sensor locations where the sensor might still be usefully collecting data, just be offline on the network through an iffy Wi-Fi link. Ones-and-zeroes can be encoded in the add-on channel to switch sensors on and off too. + +### How it works + +The on-off noise power communication (ONPC) protocol, as it’s called, works via a software hack on commodity Wi-Fi access points. Through software, part of the transmitter is converted to an RF power source, and then elements in the receiver are turned into a power measuring device. Noise energy, created by the power source is encoded, emitted and picked up by the measuring setup at the other end. + +“If the access point, [or] router hears this code, it says, ‘OK, I know the sensor is still alive and trying to reach me, it’s just out of range,’” Neal Patwari of Washington University says in a Brigham Young University (BYU) [press release][6]. “It’s basically sending one bit of information that says it’s alive.” + +The noise channel is much leaner than the Wi-Fi one, BYU explains. “While Wi-Fi requires speeds of at least one megabit per second to maintain a signal, ONPC can maintain a signal on as low as one bit per second—one millionth of the data speed required by Wi-Fi.” That’s enough for IoT sensor housekeeping, conceivably. Additionally, “one bit of information is sufficient for many Wi-Fi enabled devices that simply need an on [and] off message,” the school says. It uses the example of an irrigation system. + +Assuring up-time, though, in hard-to-reach, dynamic environments, is where the school got the idea from. Researchers found that they were continually implementing sensors for environmental IoT experiments in hard to reach spots. + +The team use an example of a sensor placed in a student’s bedroom where the occupant had placed a laundry basket in front of the important device. It had blocked the native Wi-Fi signal. The scientists, then, couldn’t get a site appointment for some weeks due to the vagaries of the subject student’s life, and they didn’t know if the trouble issue was sensor or link during that crucial time. ONPC would have allowed them to be reassured that data was still being collected and stored—or not—without the tricky-to-obtain site visit. + +The researchers reckon cellular, [Bluetooth][7] and also [LoRa][8] could use ONPC, too. “We can send and receive data regardless of what Wi-Fi is doing; all we need is the ability to transmit energy and then receive noise measurements,” Phil Lundrigan of BYU says. + +Join the Network World communities on [Facebook][9] and [LinkedIn][10] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3449819/wireless-noise-protocol-can-extend-iot-range.html + +作者:[Patrick Nelson][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.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3258807/what-is-802-11ax-wi-fi-and-what-will-it-mean-for-802-11ac.html +[2]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[3]: https://www.networkworld.com/newsletters/signup.html +[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[5]: https://dl.acm.org/citation.cfm?id=3345436 +[6]: https://news.byu.edu/byu-created-software-could-significantly-extend-wi-fi-range-for-smart-home-devices +[7]: https://www.networkworld.com/article/3434526/bluetooth-finds-a-role-in-the-industrial-internet-of-things.html +[8]: https://www.networkworld.com/article/3211390/lorawan-key-to-building-full-stack-production-iot-networks.html +[9]: https://www.facebook.com/NetworkWorld/ +[10]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191101 Big Four carriers want to rule IoT by simplifying it.md b/sources/talk/20191101 Big Four carriers want to rule IoT by simplifying it.md new file mode 100644 index 0000000000..4194e97438 --- /dev/null +++ b/sources/talk/20191101 Big Four carriers want to rule IoT by simplifying it.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Big Four carriers want to rule IoT by simplifying it) +[#]: via: (https://www.networkworld.com/article/3449820/big-four-carriers-want-to-rule-iot-by-simplifying-it.html) +[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) + +Big Four carriers want to rule IoT by simplifying it +====== +A look at some of the pros and cons of IoT services from AT&T, Sprint, T-Mobile and Verizon +Natalya Burova / Getty Images + +The [Internet of Things][1] promises a transformative impact on a wide range of industries, but along with that promise comes an enormous new level of complexity for the network and those in charge of maintaining it. For the major mobile data carriers in the U.S., that fact suggests an opportunity. + +The core of the carriers’ appeal for IoT users is simplicity. Opting for Verizon or AT&T instead of in-house connectivity removes a huge amount of the work involved in pulling an IoT implementation together. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][2] + +Operationally, it’s the same story. The carrier is handling the network management and security functionality, and everything involved in the connectivity piece is available through a centralized management console. + +[][3] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][3] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +The carriers’ approach to the IoT market is two-pronged, in that they sell connectivity services directly to end-users as well as selling connectivity wholesale to device makers. For example, one customer might buy a bunch of sensors directly from Verizon, while another might buy equipment from a specialist manufacturer that contracts with Verizon to provide connectivity. + +There are, experts agree, numerous advantages to simply handing off the wireless networking of an IoT project to a major carrier. Licensed networks are largely free of interference – the carriers own the exclusive rights to the RF spectrum being used in a designated area, so no one else is allowed to use it without risking the wrath of the FCC. In contrast, a company using unlicensed technologies like Wi-Fi might be competing for the same spectrum area with half a dozen other organizations. + +It’s also better-secured than most unlicensed technologies or at least easier to secure, according to former chair of the IEEE’s IoT [smart cities][4] working group Shawn Chandler. Buying connectivity services that will have to be managed and secured in-house can be a lot more work than letting one of the carriers take care of it. + +“If you’re going to use mesh networks and RF networks,” he said, “then the enterprise is looking at [buying] a full security solution.” + +There are, of course, downsides as well. Plenty of businesses with a lot of institutional experience on the networking side are going to have trust issues with handing over control of mission-critical networks to a third party, said 451 Research vice president Christian Renaud. + +“For someone to come in over the top with, ‘Oh we’ll manage everything for you,’” he said, might draw a response along the lines of, “Wait, what?” from the networking staff. Carriers promise a lot of visibility into the logical relationships between endpoints, edge modules and the cloud – but the actual topology of the network itself may be abstracted out. + +And despite a generally higher level of security, carrier networks aren’t completely bulletproof. Several research teams have demonstrated attack techniques that, although unlikely to be seen in the wild, at least have the potential to compromise modern LTE networks. An example: researchers at Ruhr-University Bochum in 2018 [published a paper detailing potential attack vectors][5] that could allow a bad actor to target unencrypted metadata, which details users connected to a given mobile node, in order to spoof DNS requests. + +Nevertheless, carriers are set to play a crucially important part in the future evolution of enterprise IoT, and each of the big four U.S. carriers has a robust suite of offerings. + +### T-Mobile + +T-Mobile’s focus is on asset tracking, smart city technology, smart buildings and vehicular fleet management, which makes sense, given that those areas are a natural fit for carrier-based IoT. All except smart buildings require a large geographical coverage area, and the ability to bring a large number of diverse endpoints from diverse sources onto the network is a strength. + +The company also runs the CONNECT partner program, aimed at makers of IoT solutions who want to use T-Mobile’s network for connectivity. It offers the option to sell hardware, software or specialist IoT platforms through the main T-Mobile for Business program, as well as, of course, close technical integration with T-Mobile’s network. + +Finally, T-Mobile offers the option of using [narrow-band IoT technology, or NB-IoT][6]. This refers to the practice of using a small slice of the network’s spectrum to provide low-throughput connectivity to a large number of devices at the same time. It’s purpose-built for IoT, and although it won’t work for something like streaming video, where a lot of data has to be moved quickly, it’s well-suited to an asset tracking system that merely has to send brief status reports. The company even sells five-dollar systems-on-a-chip in bulk for organizations that want to integrate existing hardware or sensors into T-Mobile’s network. + +### AT&T + +Like the rest of the big four, AT&T does business both by selling their own IoT services – most of it under the umbrella of the Multi-Network Connect platform, a single pane of glass offering designed to streamline the management of many types of IoT product – and by partnering with an array of hardware and other product makers who want to use the company’s network. + +Along with NB-IoT, AT&T provides LTE-M connectivity, a similar but slightly more capable IoT-focused network technology that adds voice support and more throughput to the NB-IoT playbook. David Allen, director of advanced product development at AT&T’s advanced mobility and enterprise solutions division, said that LTE-M and NB-IoT are powerful tools in the company’s IoT arsenal. + +“These are small slivers of spectrum that offer an instant national footprint,” he said. + +MNC is advertised as a broad-based platform that can bring together input from nearly any type of licensed network, from 2G up through satellite, and even integrate with other connectivity management platforms – so a company that uses multiple operators could bring trhem all under the roof of MNC. + +### Verizon + +Verizon’s IoT platform, and the focus of its efforts to do business in the IoT realm is Thingspace, which is similar to AT&T’s MNC in many respects. The company also offers both NB-IoT and LTE-M for flexible IoT-specific connectivity options, as well as support for traditional SIM-based networking. As with the rest of the big four, Verizon also sells connectivity services to third parties. + +While the company said that it doesn’t break down its IoT business into third-party/first-party sales, Verizon says it has had success in several verticals, including telematics for the energy and healthcare industries. The first use case involves using current sensors on the grid and smart meters at the home to study sustainability and track usage more closely. The second involves working on remote monitoring of patient data, and the company said it will hav announcements around that in the future. + +While the focus is obviously on connectivity, Verizon also does something slightly unusual for the carrier IoT market by selling a one-size-fits-most sensor of its own creation, called the Critical Asset Sensor. This is a small sensor module that contains acceleration, temperature, pressure, light, humidity and shock sensors, along with GPS and network connectivity, so that it can fit a huge variety of IoT use cases. The idea is that they can be bought in bulk for an IoT implementation direct from Verizon, obviating the need to deal with a separate sensor vendor. + +### Sprint + +Sprint’s IoT offerings are partially provided under the umbrella of the company’s IoT Factory store, and the emphasis has been on various types of sensor-based service, including restaurant and food-service storage temperatures, smart building solutions for offices and other commercial property, as well as fleet management for terrestrial and marine vehicles. + +Most of these are offered through Sprint via partnerships with vertical specialists in those areas, like Apptricity, CU Trak, M2M in Motion and Rently, among many others. + +The company also has a dedicated IoT platform offering called Curiosity IoT, which leans on [Arm’s][7] platform security and connectivity management for basic functionality, but it promises most of the same functionality as the other Big Four vendors’ platforms. It provides a single pane of glass that integrates management and monitoring for every sensor on the network and shapes data into a standardized format for analysis on the back end. + +Join the Network World communities on [Facebook][8] and [LinkedIn][9] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3449820/big-four-carriers-want-to-rule-iot-by-simplifying-it.html + +作者:[Jon Gold][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.networkworld.com/author/Jon-Gold/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[2]: https://www.networkworld.com/newsletters/signup.html +[3]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[4]: https://www.networkworld.com/article/3411561/report-smart-city-iot-isnt-smart-enough-yet.html +[5]: https://alter-attack.net/media/breaking_lte_on_layer_two.pdf +[6]: https://www.networkworld.com/article/3227206/faq-what-is-nb-iot.html +[7]: https://www.networkworld.com/article/3294781/arm-flexes-flexibility-with-pelion-iot-announcement.html +[8]: https://www.facebook.com/NetworkWorld/ +[9]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191101 Micron finally delivers its answer to Optane.md b/sources/talk/20191101 Micron finally delivers its answer to Optane.md new file mode 100644 index 0000000000..84b63007ec --- /dev/null +++ b/sources/talk/20191101 Micron finally delivers its answer to Optane.md @@ -0,0 +1,63 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Micron finally delivers its answer to Optane) +[#]: via: (https://www.networkworld.com/article/3449576/micron-finally-delivers-its-answer-to-optane.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Micron finally delivers its answer to Optane +====== +New drive offers DRAM-like performance and is targeted at analytics and transaction workloads. +Intel + +Micron Technology partnered with Intel back in 2015 to develop 3D XPoint, a new type of memory that has the storage capability of NAND flash but speed almost equal to DRAM. However, the two companies parted ways in 2018 before either of them could bring a product to market. They had completed the first generation, agreed to work on the second generation together, and decided to part after that and do their own thing for the third generation. + +Intel released its product under the [Optane][1] brand name. Now Micron is hitting the market with its own product under the QuantX brand. At its Insight 2019 show in San Francisco, Micron unveiled the X100, a new solid-state drive the company claims is the fastest in the world. + +On paper, this thing is fast: + + * Up to 2.5 million IOPS, which it claims is the fastest in the world. + * More than 9GB per second bandwidth for read, write, and mixed workloads, which it claims is three times faster than comparable NAND drives. + * Read-write latency of less than 8 microseconds, which it claims is 11 times better than NAND-based SSDs. + + + +Micron sees the X100 serving data to the world’s most demanding analytics and transactional applications, “a role that’s befitting the world’s fastest drive,” it said in a statement. + +The company also launched the Micron 7300, a NVMe SSD for data center use with capacities from 400GB to 8TB, depending on the form factor. It comes in SATA and U.2 form factors, the latter of which is like the M.2 PCI Express drives that are the size of a stick of gum and mount on the motherboard. + +Also released is the Micron 5300, a SATA drive with capacities from 240GB to nearly 8TB. This drive is the first to use 96-layer 3D TLC NAND, hence its high capacity. It can deliver random read performance of up to 95K IOPS and random write IOPS of 75K. + +Micron also announced it had acquired FWDNXT, an AI startup that develop deep learning solutions. Micron says it’s integrating the compute, memory, tools, and software from FWDNXT into a “comprehensive AI development platform,” which it calls the Micron Deep Learning Accelerator (DLA). + + * [Backup vs. archive: Why it’s important to know the difference][2] + * [How to pick an off-site data-backup method][3] + * [Tape vs. disk storage: Why isn’t tape dead yet?][4] + * [The correct levels of backup save time, bandwidth, space][5] + + + +Join the Network World communities on [Facebook][6] and [LinkedIn][7] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3449576/micron-finally-delivers-its-answer-to-optane.html + +作者:[Andy Patrizio][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.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3387117/intel-formally-launches-optane-for-data-center-memory-caching.html +[2]: https://www.networkworld.com/article/3285652/storage/backup-vs-archive-why-its-important-to-know-the-difference.html +[3]: https://www.networkworld.com/article/3328488/backup-systems-and-services/how-to-pick-an-off-site-data-backup-method.html +[4]: https://www.networkworld.com/article/3315156/storage/tape-vs-disk-storage-why-isnt-tape-dead-yet.html +[5]: https://www.networkworld.com/article/3302804/storage/the-correct-levels-of-backup-save-time-bandwidth-space.html +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191101 Product vs. project in open source.md b/sources/talk/20191101 Product vs. project in open source.md new file mode 100644 index 0000000000..f4fb128368 --- /dev/null +++ b/sources/talk/20191101 Product vs. project in open source.md @@ -0,0 +1,85 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Product vs. project in open source) +[#]: via: (https://opensource.com/article/19/11/product-vs-project) +[#]: author: (Mike Bursell https://opensource.com/users/mikecamel) + +Product vs. project in open source +====== +What's the difference between an open source product and an open source +project? Not all open source is created (and maintained) equal. +![Bees on a hive, connected by dots][1] + +Open source is a good thing. Open source is a particularly good thing for security. I've written about this before (notably in [_Disbelieving the many eyes hypothesis_][2] and [_The commonwealth of open source_][3]), and I'm going to keep writing about it. In this article, however, I want to talk a little more about a feature of open source that is arguably both a possible disadvantage and a benefit: the difference between a project and a product. I'll come down firmly on one side (spoiler alert: for organisations, it's "product"), but I'd like to start with a little disclaimer. I am employed by Red Hat, and we are a company that makes money from supporting open source. I believe this is a good thing, and I approve of the model that we use, but I wanted to flag any potential bias early in the article. + +The main reason that open source is good for security is that you can see what's going on when there's a problem, and you have a chance to fix it. Or, more realistically, unless you're a security professional with particular expertise in the open source project in which the problem arises, somebody _else_ has a chance to fix it. We hope that there are sufficient security folks with the required expertise to fix security problems and vulnerabilities in software projects about which we care. + +It's a little more complex than that, however. As an organisation, there are two main ways to consume open source: + + * As a **project**: you take the code, choose which version to use, compile it yourself, test it, and then manage it. + * As a **product**: a vendor takes the project, chooses which version to package, compiles it, tests it, and then sells support for the package, typically including docs, patching, and updates. + + + +Now, there's no denying that consuming a project "raw" gives you more options. You can track the latest version, compiling and testing as you go, and you can take security patches more quickly than the product version may supply them, selecting those that seem most appropriate for your business and use cases. On the whole, this seems like a good thing. There are, however, downsides that are specific to security. These include: + + 1. Some security fixes come with an [embargo][4], to which only a small number of organisations (typically the vendors) have access. Although you may get access to fixes at the same time as the wider ecosystem, you will need to check and test them (unless you blindly apply them—don't do that), which will already have been performed by the vendors. + 2. The _huge_ temptation to make changes to the code that don't necessarily—or immediately—make it into the upstream project means that you are likely to be running a fork of the code. Even if you _do_ manage to get these upstream in time, during the period that you're running the changes but they're not upstream, you run a major risk that any security patches will not be immediately applicable to your version. (This is, of course, true for non-security patches, but security patches are typically more urgent.) One option, of course, if you believe that your version is likely to consumed by others, is to make an _official_ fork of the project and try to encourage a community to grow around that; but in the end, you will still have to decide whether to support the _new_ version internally or externally. + 3. Unless you ensure that _all_ instances of the software are running the same version in your deployment, any back-porting of security fixes to older versions will require you to invest in security expertise equal (or close to equal) to that of the people who created the fix in the first place. In this case, you are giving up the "commonwealth" benefit of open source, as you need to pay experts who duplicate the skills of the community. + + + +What you are basically doing, by choosing to deploy a _project_ rather than a _product_ is taking the decision to do _internal productisation_ of the project. You lose not only the commonwealth benefit of security fixes but also the significant _economies of scale_ that are intrinsic to the vendor-supported product model. There may also be _economies of scope_ that you miss: many vendors will have multiple products that they support and will be able to apply security expertise across those products in ways that may not be possible for an organisation whose core focus is not on product support. + +These economies are reflected in another possible benefit to the commonwealth of using a vendor: The very fact that multiple customers are consuming their products means that vendors have an incentive and a revenue stream to spend on security fixes and general features. There are other types of fixes and improvements on which they may apply resources, but the relative scarcity of skilled security experts means that the [principle of comparative advantage][5] suggests that they should be in the best position to apply them for the benefit of the wider community.[1][6] + +What if a vendor you use to provide a productised version of an open source project goes bust or decides to drop support for that product? Well, this is a problem in the world of proprietary software as well, of course. But in the case of proprietary software, there are three likely outcomes: + + * You now have no access to the software source, and therefore no way to make improvements. + * You _are_ provided access to the software source, but it is not available to the wider world, and therefore you are on your own. + * _Everyone_ is provided with the software source, but no existing community exists to improve it, and it either dies or takes significant time for a community to build around it. + + + +In the case of open source, however, if the vendor you have chosen goes out of business, there is always the option to use another vendor, encourage a new vendor to take it on, productise it yourself (and supply it to other organisations), or, if the worst comes to the worst, take the internal productisation route while you search for a scalable long-term solution. + +In the modern open source world, we (the community) have gotten quite good at managing these options, as the growth of open source consortia[2][7] shows. In a consortium, groups of organisations and individuals cluster around a software project or a set of related projects to encourage community growth, alignment around feature and functionality additions, general security work, and productisation for use cases that may as yet be ill-defined, all the while trying to exploit the economies of scale and scope outlined above. An example of this would be the Linux Foundation's [Confidential Computing Consortium][8], to which the [Enarx project][9] aims to be contributed. + +Choosing to consume open source software as a product instead of as a project involves some trade-offs, but, from a security point of view at least, the economics for organisations are fairly clear: unless you are in a position to employ ample security experts, products are most likely to suit your needs. + +* * * + +1\. Note: I'm not an economist, but I believe that this holds in this case. Happy to have comments explaining why I'm wrong (if I am…). + +2\. "Consortiums" if you _really_ must. + +* * * + +_This article was originally published on [Alice, Eve, and Bob][10] and is reprinted with the author's permission._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/product-vs-project + +作者:[Mike Bursell][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/mikecamel +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_bees_network.png?itok=NFNRQpJi (Bees on a hive, connected by dots) +[2]: https://opensource.com/article/17/10/many-eyes +[3]: https://opensource.com/article/17/11/commonwealth-open-source +[4]: https://aliceevebob.com/2018/01/09/meltdown-and-spectre-thinking-about-embargoes-and-disclosures/ +[5]: https://en.wikipedia.org/wiki/Comparative_advantage +[6]: tmp.ov8Yhb4jS4#1 +[7]: tmp.ov8Yhb4jS4#2 +[8]: https://confidentialcomputing.io/ +[9]: https://enarx.io/ +[10]: https://aliceevebob.com/2019/10/15/of-projects-products-and-security-community/ diff --git a/sources/talk/20191101 Retro computing with FPGAs and MiSTer.md b/sources/talk/20191101 Retro computing with FPGAs and MiSTer.md new file mode 100644 index 0000000000..8674863561 --- /dev/null +++ b/sources/talk/20191101 Retro computing with FPGAs and MiSTer.md @@ -0,0 +1,166 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Retro computing with FPGAs and MiSTer) +[#]: via: (https://opensource.com/article/19/11/fpga-mister) +[#]: author: (Sarah Thornton https://opensource.com/users/sarah-thornton) + +Retro computing with FPGAs and MiSTer +====== +Field-programmable gate arrays are used in devices like smartphones, +medical devices, aircraft, and—here—emulating an old-school Amiga. +![Mesh networking connected dots][1] + +Another weekend rolls around, and I can spend some time working on my passion projects, including working with single-board computers, playing with emulators, and general tinkering with a soldering iron. Earlier this year, I wrote about [resurrecting the Commodore Amiga on the Raspberry Pi][2]. A colleague referred to our shared obsession with old technology as a "[passion for preserving our digital culture][3]." + +In my travels in the world of "digital archeology," I heard about a new way to emulate old systems by using [field-programmable gate arrays][4] (FPGAs). I was intrigued by the concept, so I dedicated a weekend to learn more. Specifically, I wanted to know if I could use an FPGA to emulate a Commodore Amiga. + +### What is an FPGA? + +When you build a circuit board, everything is literally etched in silicon. You can change the software that runs on it, but the physical circuit is immutable. So if you want to add a new component to it or modify it later, you are limited by the physical nature of the hardware. With an FPGA, you can program the hardware to simulate new components or change existing ones. This is achieved through programmable logic gates (hence the name). This provides a lot of flexibility for Internet-of-Things (IoT) devices, as they can be changed later to meet new requirements. + +![Terasic DE10-Nano][5] + +FPGAs are used in many devices today, including smartphones, medical devices, motor vehicles, and aircraft. Because FPGAs can be easily modified and generally have low power requirements, these devices are everywhere! They are also inexpensive to manufacture and can be configured for multiple uses. + +The Commodore Amiga was designed with chips that had specific uses and fun names. For example, "Gary" was a gate array that later became "Fat Gary" when "he" was upgraded on the A3000 and A4000. "Bridgette" was an integrated bus buffer, and the delightful "Amber" was a "flicker fixer" on the A3000. The ability to simulate these chips with programmable gates makes an ideal platform for Amiga emulation. + +When you use an emulator, you are tricking an application into using software to find the architecture it expects. The primary limitations are the accuracy of the emulation and the sequential nature of how the commands are processed through the CPU. With an FPGA, you can teach the hardware what chips are in play, and software can talk to each chip as if it was native and in parallel. It also means applications can thread as if they were running on the original hardware. This makes FGPAs especially good for emulating old systems. + +### Introducing the MiSTer project + +The board I have been working with is [Terasic][6]'s [DE10-Nano][7]. Out of the box, this device is excellent for learning how FPGAs work and gives you access to tools to get you started. + +![Terasic DE10-Nano][8] + +The [MiSTer project][9] is built on top of this board and employs daughter boards to provide memory expansion, SDRAM, and improved I/O, all built on a Linux-based distribution. To use it as a platform for emulation, it's expanded through the use of "cores" that define the architecture the board will emulate. + +Once you have flashed the device with the MiSTer distro, you can load a "core," which is a combination of a definition for the chips you want to use and the associated menus to manage the emulated system. + +![Terasic DE10-Nano][10] + +Compared to a Raspberry Pi running emulation software, these cores provide a more native experience for emulation, and often apps that don't run perfectly on software-based emulators will run fine on a MiSTer. + +### How to get started + +There are excellent resources online to help get you started. The first stop is the [documentation][11] on MiSTer's [GitHub page][12], which has step-by-step instructions on putting everything together. If you prefer a visual walkthrough of the board, check out [this video][13] from the [Retro Man Cave][14] YouTube channel. For more information on configuring the [Minimig][15] (short for mini Amiga) core to load disks or using Amiga's classic [Workbench][16] and [WHDLoad][17], check out this great [tutorial][18] from [Phil's Computer Lab][19] on YouTube. + +### Cores + +MiSTer has cores available for a multitude of systems; my main interest is in Amiga emulation, which is provided by the Minimig core. I'm also interested in the Commodore 64 and PET and the BBC microcomputer, which I used at college. I also have a soft spot for playing [Space Invaders on the Commodore PET][20], which I will admit (many years later!) was the real reason I booked time in the college computer lab at the end of the week. + +Once a core is loaded, you can interact with it through a connected keyboard and by pressing F12 to access the "core" menu. To access a shell, you can log in by using the F9 key, which presents you with a login prompt. You will need a [kickstart ROM][21] (the equivalent of a PC's BIOS), to get your Amiga running. You can obtain these from [Cloanto][22], which sells the [Amiga Forever][23] kickstart that contains the ROMs required to boot a system as well as games, demos, and hard drive files that can be used on your MiSTer. Store the kickstart ROM in the root of your SD card and name it "KICK.ROM." + +On my MiSTer board, I can run Amiga demos that don't run on my Raspberry Pi, even though my Pi has much more memory available. The emulation is more accurate and runs more efficiently. Through the expansion board, I can even use old hardware, such as an original Commodore monitor and Amiga joysticks. + +### Source code + +All code for the MiSTer project is available in its [GitHub repo][12]. You have access to the cores as well as the main MiSTer setup, associated scripts, and menu files. These are actively updated, and there is a solid community actively developing, bug fixing, and improving all contributions, so check back regularly for updates. The repo has a wealth of information available to help get you up and running. + +### Security considerations + +With the flexibility of customization comes the potential for [security vulnerabilities][24]. All MiSTer installs come with a preset password on the root account, so one of the first things you want to do is to change the password. If you are using the device to build a cabinet for a game and you have given the device access to your network, it can be exploited using the default login credentials, and that can lead to giving a third party access to your network. + +For non-MiSTer projects, FPGAs expose the ability for one process to be able to listen in on another process, so limiting access to the device should be one of the first things you do. When you build your application, you should isolate processes to prevent unwanted access. This is especially important if you intend to deploy your board where access is open to other users or with shared applications. + +### Find more information + +There is a lot of information about this type of project online. Here are some of the resources you may find helpful. + +#### Community + + * [MiSTer wiki][9] + * [Setup guide][11] + * [Internet connections on supporting cores][25] + * [Discussion forums][26] + * [MiSTer add-ons][27] (public Facebook group) + + + +#### Daughter boards + + * [SDRAM board][28] + * [I/O board][29] + * [RTC board][30] + * [USB hub][31] + + + +#### Videos and walkthroughs + + * [Exploring the MiSTer and DE-10 Nano FPGA][32]: Is this the future of retro? + * [FPGA emulation MiSTer project on the Terasic DE10-Nano][33] + * [Amiga OS 3.1 on FPGA—DE10-Nano running MisTer][34] + + + +#### Where to buy the hardware + +##### MiSTer project + + * [DE10-Nano][35] (Amazon) + * [Ultimate Mister][36] + * [MiSTer Add-ons][37] + + + +##### Other FPGAs + + * [TinyFPGA BX—ICE40 FPGA development board with USB][38] (Adafruit) + * [Terasic][6], makers of the DE10-Nano and other high-performance FPGAs + + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/fpga-mister + +作者:[Sarah Thornton][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/sarah-thornton +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/mesh_networking_dots_connected.png?itok=ovINTRR3 (Mesh networking connected dots) +[2]: https://opensource.com/article/19/3/amiga-raspberry-pi +[3]: https://www.linkedin.com/pulse/passion-preserving-digital-culture-%C3%B8ivind-ekeberg/ +[4]: https://en.wikipedia.org/wiki/Field-programmable_gate_array +[5]: https://opensource.com/sites/default/files/uploads/image5_0.jpg (Terasic DE10-Nano) +[6]: https://www.terasic.com.tw/en/ +[7]: https://www.terasic.com.tw/cgi-bin/page/archive.pl?Language=English&CategoryNo=165&No=1046 +[8]: https://opensource.com/sites/default/files/uploads/image2_0.jpg (Terasic DE10-Nano) +[9]: https://github.com/MiSTer-devel/Main_MiSTer/wiki +[10]: https://opensource.com/sites/default/files/uploads/image1_0.jpg (Terasic DE10-Nano) +[11]: https://github.com/MiSTer-devel/Main_MiSTer/wiki/Setup-Guide +[12]: https://github.com/MiSTer-devel +[13]: https://www.youtube.com/watch?v=e5yPbzD-W-I&t=2s +[14]: https://www.youtube.com/channel/UCLEoyoOKZK0idGqSc6Pi23w +[15]: https://github.com/MiSTer-devel/Minimig-AGA_MiSTer +[16]: https://en.wikipedia.org/wiki/Workbench_%28AmigaOS%29 +[17]: https://en.wikipedia.org/wiki/WHDLoad +[18]: https://www.youtube.com/watch?v=VFespp1adI0 +[19]: https://www.youtube.com/channel/UCj9IJ2QvygoBJKSOnUgXIRA +[20]: https://www.youtube.com/watch?v=hqs6gIZbpxo +[21]: https://en.wikipedia.org/wiki/Kickstart_(Amiga) +[22]: https://cloanto.com/ +[23]: https://www.amigaforever.com/ +[24]: https://www.helpnetsecurity.com/2019/06/03/vulnerability-in-fpgas/ +[25]: https://github.com/MiSTer-devel/Main_MiSTer/wiki/Internet-and-console-connection-from-supported-cores +[26]: http://www.atari-forum.com/viewforum.php?f=117 +[27]: https://www.facebook.com/groups/251655042432052/ +[28]: https://github.com/MiSTer-devel/Main_MiSTer/wiki/SDRAM-Board +[29]: https://github.com/MiSTer-devel/Main_MiSTer/wiki/IO-Board +[30]: https://github.com/MiSTer-devel/Main_MiSTer/wiki/RTC-board +[31]: https://github.com/MiSTer-devel/Main_MiSTer/wiki/USB-Hub-daughter-board +[32]: https://www.youtube.com/watch?v=e5yPbzD-W-I +[33]: https://www.youtube.com/watch?v=1jb8YPXc8DA +[34]: https://www.youtube.com/watch?v=tAz8VRAv7ig +[35]: https://www.amazon.com/Terasic-Technologies-P0496-DE10-Nano-Kit/dp/B07B89YHSB/ +[36]: https://ultimatemister.com/ +[37]: https://misteraddons.com/ +[38]: https://www.adafruit.com/product/4038 diff --git a/sources/talk/20191102 6 remarkable features of the new United Nations open source initiative.md b/sources/talk/20191102 6 remarkable features of the new United Nations open source initiative.md new file mode 100644 index 0000000000..a5394515d4 --- /dev/null +++ b/sources/talk/20191102 6 remarkable features of the new United Nations open source initiative.md @@ -0,0 +1,56 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (6 remarkable features of the new United Nations open source initiative) +[#]: via: (https://opensource.com/article/19/11/united-nations-goes-open-source) +[#]: author: (Frank Karlitschek https://opensource.com/users/frankkarlitschek) + +6 remarkable features of the new United Nations open source initiative +====== +What does it mean when the UN goes open source? +![Globe up in the clouds][1] + +Three months, ago the United Nations asked me to join a new advisory board to help them develop their open source strategy and policy. I’m honored to have the opportunity to work together with a group of established experts in open source licensing and policy areas. + +The United Nations wants to make technology, software, and intellectual property available to everyone, including developing countries. Open source and free software are great tools to achieve this goal since open source is all about empowering people and global collaboration while protecting the personal data and privacy of users. So, the United Nations and the open source community share the same values. + +This new open source strategy and policy is developed by the [United Nations Technology Innovation Labs][2] (UNTIL). Last month, we had our first in-person meeting in Helsinki in the UNTIL offices. I find this initiative remarkable for several reasons: + + * **Sharing:** The United Nations wants to have a positive impact on everyone on this planet. For that goal, it is important that software, data, and services are available for everyone independent of their language, budget, education, or other factors. Open source is perfect to guarantee that result. + + * **Contributing:** It should be possible that everyone can contribute to the software, data, and services of the United Nations. The goal is to not depend on a single software vendor alone, but instead, build a bigger ecosystem that drives innovation together. + + * **Empowering:** Open source makes it possible for underdeveloped countries and regions to foster local companies and expertise by building on top of existing open source software—standing on the shoulders of giants. + + * **Sustainability:** Open source guarantees more sustainable software, data, and services by not relying on a single entity to support, maintain, and develop it. Open source helps to avoid a single point of failure by creating an equal playing field for everyone. + + * **Security:** Open source software is more secure than proprietary software because the code can be constantly reviewed and audited. This fact is especially important for security-sensitive applications that require [transparency and openness][3]. + + * **Decentralization:** An open source strategy enables decentralized hosting of software and data. This fact makes it possible to be compliant with all data protection and privacy regulations and enables a more free and open internet. + + + + +We discussed that a fair business model like the one from Nextcloud should be encouraged and recommended. Specifically, we discussed that that 100% of the code should be placed under an [OSI-approved open source license][4]. There should be no open core, proprietary extensions, dual licensing, or other limited-access components to ensure that everyone is on the same playing field. + +I’m excited to have the opportunity to advise the United Nations in this matter, and I hope to have a positive influence on the future of IT, especially in developing countries. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/united-nations-goes-open-source + +作者:[Frank Karlitschek][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/frankkarlitschek +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cloud-globe.png?itok=_drXt4Tn (Globe up in the clouds) +[2]: https://until.un.org +[3]: https://until.un.org/content/governance +[4]: https://opensource.org/licenses diff --git a/sources/talk/20191102 Can Data Scientists be Replaced by Automation.md b/sources/talk/20191102 Can Data Scientists be Replaced by Automation.md new file mode 100644 index 0000000000..89b4e8b77a --- /dev/null +++ b/sources/talk/20191102 Can Data Scientists be Replaced by Automation.md @@ -0,0 +1,66 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Can Data Scientists be Replaced by Automation?) +[#]: via: (https://opensourceforu.com/2019/11/can-data-scientists-be-replaced-by-automation/) +[#]: author: (Preet Gandhi https://opensourceforu.com/author/preet-gandhi/) + +Can Data Scientists be Replaced by Automation? +====== + +[![][1]][2] + +_The advent of AI, automation and smart bots triggers the question: Is it possible that data scientists will become redundant in the future? Are they indispensable? The ideal approach appears to be automation complementing the work data scientists do. This would better utilise the tremendous data being generated throughout the world every day._ + +Data scientists are currently very much in demand. But there is the question about whether they can automate themselves out of their jobs. Can artificial intelligence replace data scientists? If so, up to what extent can their tasks be automated? Gartner recently reported that 40 per cent of data science tasks will be automated by 2020. So what kind of skills can be efficiently handled by automation? All this speculation adds fuel to the ongoing ‘Man vs Machine’ debate. + +Data scientists need a strong mathematical mind, quantitative skills, computer programming skills and business acumen to make decisions. They need to gather large unstructured data and transform it into results and insights, which can be understood by laymen or business executives. The whole process is highly customised, depending on the type of application domain. Some degree of human interaction will always be needed due to the subjective nature of the process, and what percentage of the task is automated depends in the specific use case and is open to debate. To understand how much or what parts can be automated, we need to have a deep understanding of the process. + +Data scientists are expensive to hire and there is a shortage of this skill in the industry as it’s a relatively new field. Many companies try to look for alternative solutions. Several AI algorithms have now been developed, which can analyse data and provide insights similar to a data scientist. The algorithm has to provide the data output and make accurate predictions, which can be done by using Natural Language Processing (NLP). + +NLP can be used to communicate with AI in the same way that laymen interact with data scientists to put forth their demands. For example, IBM Watson has NLP facilities which interact with business intelligence (BI) tools to perform data science tasks. Microsoft’s Cortana also has a powerful BI tool, and users can process Big Data sets by just speaking to it. All these are simple forms of automation which are widely available already. Data engineering tasks such as cleansing, normalisation, skewness removal, transformation, etc, as well as modelling methods like champion model selection, feature selection, algorithm selection, fitness metric selection, etc, are tasks for which automated tools are currently available in the market. + +Automation in data science will squeeze some manual labour out of the workflow instead of completely replacing the data scientists. Low-level functions can be efficiently handled by AI systems. There are many technologies to do this. The Alteryx Designer tool automatically generates customised REST APIs and Docker images around machine learning models during the promotion and deployment stage. + +Designer workflows can also be set up to automatically retrain machine learning models, using fresh data, and then to automatically redeploy them. Data integration, model building, and optimising model hyper parameters are areas where automation can be helpful. Data integration combines data from multiple sources to provide a uniform data set. Automation here can pull trusted data from multiple sources for a data scientist to analyse. Collecting data, searching for patterns and making predictions are required for model building, which can be automated as machines can collect data to find patterns. + +Machines are getting smarter everyday due to the integration of AI principles that help them learn from the types of patterns they were historically trying to detect. An added advantage here is that machines will not make the kinds of errors that humans do. + +Automation has its own set of limitations, however. It can only go so far. Artificial intelligence can automate data engineering and machine learning processes but AI can’t automate itself. Data wrangling (data munging) consists of manually converting raw data to an easily consumable form. The process still requires human judgment to turn raw data into insights that make sense for an organisation, and take all of an organisation’s complexities into account. Even unsupervised learning is not entirely automated. Data scientists still prepare sets, clean them, specify which algorithms to use, and interpret the findings. Data visualisation, most of the time, needs a human as the findings to be presented to laymen have to be highly customised, depending on the technical knowledge of the audience. A machine can’t possibly be trained to do that. + +Low-level visualisations can be automated, but human intelligence would be required to interpret and explain the data. It will also be needed to write AI algorithms that can handle mundane visualisation tasks. Moreover, intangibles like human curiosity, intuition or the desire to create/validate experiments can’t be simulated by AI. This aspect of data science probably won’t be ever handled by AI in the near future as the technology hasn’t evolved to that extent. + +While thinking about automation, we should also consider the quality of the output. Here, output means the validity or relevance of the insights. With automation, the quantity and throughput of data science artefacts will increase, but that doesn’t translate to an increase in quality. The process of extracting insights and applying them within the context of particular data driven applications is still inherently a creative, exploratory process that demands human judgment. To get a deeper understanding of the data, feature engineering is a very essential portion of the process. It allows us to make maximum use of the data available to us. Automating feature engineering is really difficult as it requires human domain knowledge and a real-world understanding, which is tough for a machine to acquire. Even if AI is used, it can’t provide the same level of feedback that a human expert in that domain can. While automation can help identify patterns in an organisation, machines cannot truly understand what data means for an organisation and its relationships between different, unconnected operations. + +You can’t teach a machine to be creative. After getting results from a pipeline, a data scientist can seek further domain knowledge in order to add value and improve the pipeline.Collaborating alongside marketing, sales and engineering teams, solutions will need to be implemented and deployed based on these findings to improve the model. It’s an iterative process and after each iteration, the creativity with which data scientists plan on adding to the next phase is what differentiates them from bots. The interactions and conversations driving these initiatives, which are fuelled by abstract, creative thinking, surpass the capabilities of any modern-day machine. + +Current data scientists shouldn’t be worried about losing their jobs to computers due to automation, as they are an amalgamation of thought leaders, coders and statisticians. A successful data science project will always need a strong team of humans to work together and collaborate to synergistically solve a problem. AI will have a tough time collaborating, which is essential in order to transform data to actionable data. Even if automation is used to some extent, a data scientist will always have to manually validate the results of a pipeline in order to make sure it makes sense in the real world. Automation can be thought of as a supplementary tool which will help scale data science and make the work more efficient. Bots can handle lower-level tasks and leave the problem-solving tasks to human experts. The combination of automation with human problem-solving will actually empower, rather than threaten, the jobs of data scientists as bots will be like assistants to the former. + +Automation can never completely replace a data scientist because no amount of advanced AI can emulate the most important quality a skilful data scientist must possess – intuition. + +![Avatar][3] + +[Preet Gandhi][4] + +The author is an avid Big Data and data science enthusiast. You can contact her at [gandhipreet1995@gmail.com][5]. + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/can-data-scientists-be-replaced-by-automation/ + +作者:[Preet Gandhi][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://opensourceforu.com/author/preet-gandhi/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Data-Scientist-automation.jpg?resize=696%2C458&ssl=1 (Data Scientist automation) +[2]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Data-Scientist-automation.jpg?fit=727%2C478&ssl=1 +[3]: https://secure.gravatar.com/avatar/4603e91c8ba6455d0d817c912a8985bf?s=100&r=g +[4]: https://opensourceforu.com/author/preet-gandhi/ +[5]: mailto:gandhipreet1995@gmail.com diff --git a/sources/talk/20191104 My first contribution to open source- Impostor Syndrome.md b/sources/talk/20191104 My first contribution to open source- Impostor Syndrome.md new file mode 100644 index 0000000000..645684e77f --- /dev/null +++ b/sources/talk/20191104 My first contribution to open source- Impostor Syndrome.md @@ -0,0 +1,76 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (My first contribution to open source: Impostor Syndrome) +[#]: via: (https://opensource.com/article/19/11/my-first-open-source-contribution-impostor-syndrome) +[#]: author: (Galen Corey https://opensource.com/users/galenemco) + +My first contribution to open source: Impostor Syndrome +====== +A new open source contributor documents a series of five mistakes she +made starting out in open source. +![Dandelion held out over water][1] + +The story of my first mistake goes back to the beginning of my learn-to-code journey. I taught myself the basics through online resources. I was working through tutorials and projects, making progress but also looking for the next way to level up. Pretty quickly, I came across a blog post that told me the best way for beginners _just like me_ to take their coding skills to the next level was to contribute to open source. + +> "Anyone can do this," insisted the post, "and it is a crucial part of participating in the larger developer community." + +My internal impostor (who, for the purpose of this post, is the personification of my imposter syndrome) latched onto this idea. "Look, Galen," she said. "The only way to be a real developer is to contribute to open source." "Alrighty," I replied, and started following the instructions in the blog post to make a [GitHub][2] account. It took me under ten minutes to get so thoroughly confused that I gave up on the idea entirely. It wasn’t that I was unwilling to learn, but the resources that I was depending on expected me to have quite a bit of preexisting knowledge about [Git][3], GitHub, and how these tools allowed multiple developers to collaborate on a single project. + +"Maybe I’m not ready for this yet," I thought, and went back to my tutorials. "But the blog post said that anyone can do it, even beginners," my internal impostor nagged. Thus began a multi-year internal battle between the idea that contributing to open source was easy and valuable and I should be doing it, and the impression I was not yet _ready_ to write code for open source projects. + +Even once I became comfortable with Git, my internal impostor was always eager to remind me of why I was not yet ready to contribute to open source. When I was in coding Bootcamp, she whispered: "Sure, you know Git and you write code, but you’ve never written ‘real’ code before, only fake Bootcamp code. You’re not qualified to contribute to real projects that people use and depend on." When I was working my first year at work as a Software Engineer, she chided, "Okay maybe the code you write is 'real,' but you only work with one codebase! What makes you think you can write high-quality code somewhere else with different conventions, frameworks, or even languages?" + +It took me about a year and a half of fulltime work to finally feel confident enough to shut down my internal impostor’s arguments and go for my first pull request (PR). The irony here is that my internal imposter was the one talking me both into and out of contributing to open source. + +### Harmful myths + +There are two harmful myths here that I want to debunk. + +#### Myth 1: Contributing to open source is "easy" + +Throughout this journey, I frequently ran across the message that contributing to open source was supposed to be easy. This made me question my own skills when I found myself unable to "easily" get started. + +I understand why people might say that contributing to open source is easy, but I suspect what they actually mean is "it’s an attainable goal," "it’s accessible to beginners if they put in the work," or "it is possible to contribute to open source without writing a ton of really complex code." + +All of these things are true, but it is equally important to note that contributing to open source is difficult. It requires you to take the time to understand a new codebase _and_ understand the tools that developers use. + +I definitely don’t want to discourage beginners from trying. It is just important to remember that running into challenges is an expected part of the process. + +#### Myth 2: All "real" or "good" developers contribute to open source + +My internal impostor was continually reminding me that my lack of open source contributions was a blight on my developer career. In fact, even as I write this post, I feel guilty that I have not contributed more to open source. But while working on open source is a great way to learn and participate in the broader community of developers, it is not the only way to do this. You can also blog, attend meetups, work on side projects, read, mentor, or go home at the end of a long day at work and have a lovely relaxing evening. Contributing to open source is a challenge that can be fun and rewarding if it is the challenge you choose. + +Julia Evans wrote a blog post called [Don’t feel guilty about not contributing to open source][4], which is a healthy reminder that there are many productive ways to use your time as a developer. I highly recommend bookmarking it for any time you feel that guilt creeping in. + +### Mistake number one + +Mistake number one was letting my internal impostor guide me. I let her talk me out of contributing to open source for years by telling me I was not ready. Instead, I just did not understand the amount of work I would need to put in to get to the level where I felt confident in my ability to write code for an unfamiliar project (I am still working toward this). I also let her talk me into it, with the idea that I had to contribute to open source to prove my worth as a developer. The end result was still my first merged pull request in a widely used project, but the insecurity made my entire experience less enjoyable. + +### Don't let Git get you down + +If you want to learn more about Git, or if you are a beginner and Git is a blocker toward making your first open-source contribution, don’t panic. Git is very complicated, and you are not expected to know what it is already. Once you get the hang of it, you will find that Git is a handy tool that lets many different developers work on the same project at the same time, and then merge their individual changes together. + +There are many resources to help you learn about Git and Github (a site that hosts code so that people can collaborate on it with Git). Here are some suggestions on where to start: [_Hello World_ intro to GitHub][5] and _[Resources to learn Git][6]_. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/my-first-open-source-contribution-impostor-syndrome + +作者:[Galen Corey][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/galenemco +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/dandelion_blue_water_hand.jpg?itok=QggW8Wnw (Dandelion held out over water) +[2]: https://github.com +[3]: https://git-scm.com +[4]: https://jvns.ca/blog/2014/04/26/i-dont-feel-guilty-about-not-contributing-to-open-source/ +[5]: https://guides.github.com/activities/hello-world/ +[6]: https://try.github.io/ diff --git a/sources/talk/20191104 Open Source Big Data Solutions Support Digital Transformation.md b/sources/talk/20191104 Open Source Big Data Solutions Support Digital Transformation.md new file mode 100644 index 0000000000..e8c2073444 --- /dev/null +++ b/sources/talk/20191104 Open Source Big Data Solutions Support Digital Transformation.md @@ -0,0 +1,107 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Open Source Big Data Solutions Support Digital Transformation) +[#]: via: (https://opensourceforu.com/2019/11/open-source-big-data-solutions-support-digital-transformation/) +[#]: author: (Vinayak Ramachandra Adkoli https://opensourceforu.com/author/vinayak-adkoli/) + +Open Source Big Data Solutions Support Digital Transformation +====== + +[![][1]][2] + +_The digital transformation (DT) of enterprises is enabled by the judicious use of Big Data. And it’s open source technologies that are the driving force behind the power of Big Data and DT._ + +Digital Transformation (DT) and Big Data combine to offer several advantages. Big Data based digitally transformed systems make life easier and smarter, whether in the field of home automation or industrial automation. The digital world tracks Big Data generated by IoT devices, etc. It tries to make this data more productive and hence, DT should be taken for granted as the world progresses. + +For example, NASA ‘s rover ‘Curiosity’ is sending Big Data from Mars to the Earth. As compared to data sent by NASA’s satellites that are revolving around Mars, this data is nothing but digitally transformed Big Data, which works with DT to provide a unique platform for open source applications. Today, ‘Curiosity’ has its own Twitter account with four million followers. + +A Digital Transformation isn’t complete unless a business adopts Big Data. The phrase “Data is the new crude oil,” is not new. However, crude oil itself has no value, unless it is refined into petrol, diesel, tar, wax, etc. Similarly, in our daily lives, we deal with tons of data. If this data is refined to a useful form, only then is it of some real use. + +As an example, we can see the transformation televisions have undergone, in appearance. We once had picture tube based TVs. Today, we have LEDs, OLEDs, LCD based TVs, curved TVs, Internet enabled TVs, and so on. Such transformation is also quite evident in the digital world. + +In a hospital, several patients may be diagnosed with cancer, each year. The patient data generated is voluminous, including treatment methods, diverse drug therapies, patient responses, genetic histories, etc. But such vast pools of information, i.e., Big Data, would serve no useful purpose without proper analysis. So DT, coupled with Big Data and open source applications, can create a more patient-focused and effective treatment – one that might have higher recovery rates. + +Big Data combines structured data with unstructured data to give us new business insights that we’ve never had before. Structured data may be traditional spreadsheets, your customer list, information about your products and business processes, etc. Unstructured data may include Google Trends data, feeds from IoT sensors, etc. When a layer of unstructured data is placed on top of structured data and analysed, that’s where the magic happens. + +Let’s look into a typical business situation. Let’s suppose a century old car-making company asks its data team to use Big Data concepts to find an efficient way to make safe sales forecasts. In the past, the team would look at the number of products it had sold in the previous month, as well as the number of cars it had sold a year ago and use that data to make a safe forecast. But now the Big Data teams use sentiment analysis on Twitter and look at what people are saying about its products and brand. They also look at Google Trends to see which similar products and brands are being searched the most. Then they correlate such data from the preceding few months with the actual current sales figures to check if the former was predictive – i.e., had Google Trends over the past few months actually predicted the firm’s current sales figures? + +In the case of the car company, while making sales forecasts, the team used structured data (how many cars sold last month, a year ago, etc) and layers of unstructured data (sentiment analysis from Twitter and Google Trends) and it resulted in a smart forecast. Thus, Big Data is today becoming more effective in business situations like sales planning, promotions, market campaigns, etc. + +**Open source is the key to DT** + +Open source, nowadays, clearly dominates domains like Big Data, mobile and cloud platforms. Once open source becomes a key component that delivers a good financial performance, the momentum is unstoppable. Open source (often coupled with the cloud) is giving Big Data based companies like Google, Facebook and other Web giants flexibility to innovate faster. + +Big Data companies are using DT to understand their processes, so that they can employ technologies like IoT, Big Data analytics, AI, etc, better. The journey of enterprises migrating from old digital infrastructure to new platforms is an exciting trend in the open source environment. +Organisations are relying on data warehouses and business intelligence applications to help make important data driven business decisions. Different types of data, such as audio, video or unstructured data, is organised in formats to help identify it for making future decisions. + +**Open source tools used in DT** +Several open source tools are becoming popular for dealing with Big Data and DT. Some of them are listed below. + + * **Hadoop** is known for the ability to process extremely large data volumes in both structured and unstructured formats, reliably placing Big Data to nodes in the group and making it available locally on the processing machine. + * **MapReduce** happens to be a crucial component of Hadoop. It works rapidly to process vast amounts of data in parallel on large clusters of computer nodes. It was originally developed by Google. + * **Storm** is different from other tools with its distributed, real-time, fault-tolerant processing system, unlike the batch processing of Hadoop. It is fast and highly scalable. It is now owned by Twitter. + * **Apache Cassandra** is used by many organisations with large, active data sets, including Netflix, Twitter, Urban Airship, Cisco and Digg. Originally developed by Facebook, it is now managed by the Apache Foundation. + * **Kaggle** is the world’s largest Big Data community. It helps organisations and researchers to post their data and statistics. It is an open source Big Data tool that allows programmers to analyse large data sets on Hadoop. It helps with querying and managing large data sets really fast. + + + +**DT: A new innovation** +DT is the result of IT innovation. It is driven by well-planned business strategies, with the goal of inventing new business models. Today, any organisation can undergo business transformation because of three main business-focused essentials — intelligence, the ability to decide more quickly and a customer-centric outlook. + +DT, which includes establishing Big Data analytics capabilities, poses considerable challenges for traditional manufacturing organisations, such as car companies. The successful introduction of Big Data analytics often requires substantial organisational transformation including new organisational structures and business processes. + +Retail is one of the most active sectors when it comes to DT. JLab is an innovative DT venture by retail giant John Lewis, which offers lots of creativity and entrepreneurial dynamism. It is even encouraging five startups each year and helps them to bring their technologies to market. For example, Digital Bridge, a startup promoted by JLab, has developed a clever e-commerce website that allows shoppers to snap photos of their rooms and see what furniture and other products would look like in their own homes. It automatically detects walls and floors, and creates a photo realistic virtual representation of the customer’s room. Here, lighting and decoration can be changed and products can be placed, rotated and repositioned with a realistic perspective. + +Companies across the globe are going through digital business transformation as it helps to improve their business processes and leads to new business opportunities. The importance of Big Data in the business world can’t be ignored. Nowadays, it is a key factor for success. There is a huge amount of valuable data which companies can use to improve their results and strategies. Today, every important decision can and should be supported by the application of data analytics. + +Big Data and open source help DT do more for businesses. DT helps companies become digitally mature and gain a solid presence on the Internet. It helps companies to identify any drawbacks that may exist in their e-commerce system. + +**Big Data in DT** +Data is critical, but it can’t be used as a replacement for creativity. In other words, DT is not all about creativity versus data, but it’s about creativity enhanced by data. + +Companies gather data to analyse and improve the customer experience, and then to create targeted messages emphasising the brand promise. But emotion, story-telling and human connections remain as essential as ever. The DT world today is dominated by Big Data. This is inevitable given the fact that business organisations always want DT based Big Data, so that data is innovative, appealing, useful to attract customers and hence to increase their sales. + +Tesla cars today are equipped with sensors and IoT connections to gather a vast amount of data. Improvements based on this data are then fed back into the cars, creating a better driving experience. + +**DT in India** +DT can transform businesses across every vertical in India. Data analytics has changed from being a good-to-have to a must-have technology. + +According to a survey by Microsoft in partnership with International Data Corporation (IDC), by 2021, DT will add an estimated US$ 154 billion to India’s GDP and increase the growth rate by 1 per cent annually. Ninety per cent of Indian organisations are in the midst of their DT journey. India is the biggest user and contributor to open source technology. DT has created a new ripple across the whole of India and is one of the major drivers for the growth of open source. The government of India has encouraged the adoption of this new technology in the Digital India initiative, and this has further encouraged the CEOs of enterprises and other government organisations to make a move towards this technology. + +The continuous DT in India is being driven faster with the adoption of emerging technologies like Big Data. That’s one of the reasons why organisations today are investing in these technological capabilities. Businesses in India are recognising the challenges of DT and embracing them. Overall, it may be said that the new DT concept is more investor and technology friendly, in tune with the ‘Make in India’ programme of the present government. + +From finding ways to increase business efficiency and trimming costs, to retaining high-value customers, determining new revenue opportunities and preventing fraud, advanced analytics is playing an important role in the DT of Big Data based companies. + +**The way forward** +Access to Big Data has changed the game for small and large businesses alike. Big Data can help businesses to solve almost every problem. DT helps companies to embrace a culture of change and remain competitive in a global environment. Losing weight is a life style change and so is the incorporation of Big Data into business strategies. + +Big Data is the currency of tomorrow, and today, it is the fuel running a business. DT can harness it to a greater level. + +![Avatar][3] + +[Vinayak Ramachandra Adkoli][4] + +The author is a B.E. in industrial production, and has been a lecturer in the mechanical engineering department for ten years at three different polytechnics. He is also a freelance writer and cartoonist. He can be contacted at [karnatakastory@gmail.com][5] or [vradkoli@rediffmail.com][6]. + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/open-source-big-data-solutions-support-digital-transformation/ + +作者:[Vinayak Ramachandra Adkoli][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://opensourceforu.com/author/vinayak-adkoli/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Big-Data-.jpg?resize=696%2C517&ssl=1 (Big Data) +[2]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Big-Data-.jpg?fit=800%2C594&ssl=1 +[3]: https://secure.gravatar.com/avatar/7b4383616c8708e3417051b3afd64bbc?s=100&r=g +[4]: https://opensourceforu.com/author/vinayak-adkoli/ +[5]: mailto:karnatakastory@gmail.com +[6]: mailto:vradkoli@rediffmail.com diff --git a/sources/talk/20191105 A Bird-s Eye View of Big Data for Enterprises.md b/sources/talk/20191105 A Bird-s Eye View of Big Data for Enterprises.md new file mode 100644 index 0000000000..efca1529ab --- /dev/null +++ b/sources/talk/20191105 A Bird-s Eye View of Big Data for Enterprises.md @@ -0,0 +1,69 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A Bird’s Eye View of Big Data for Enterprises) +[#]: via: (https://opensourceforu.com/2019/11/a-birds-eye-view-of-big-data-for-enterprises-2/) +[#]: author: (Swapneel Mehta https://opensourceforu.com/author/swapneel-mehta/) + +A Bird’s Eye View of Big Data for Enterprises +====== + +[![][1]][2] + +_Entrepreneurial decisions are made using data and business acumen. Big Data is today a tool that helps to maximise revenue and customer engagement. Open source tools like Hadoop, Apache Spark and Apache Storm are the popular choices when it comes to analysing Big Data. As the volume and variety of data in the world grows by the day, there is great scope for the discovery of trends as well as for innovation in data analysis and storage._ + +In the past five years, the spate of research focused on machine learning has resulted in a boom in the nature and quality of heterogeneous data sources that are being tapped by providers for their customers. Cheaper compute and widespread storage makes it so much easier to apply bulk data processing techniques, and derive insights from existing and unexplored sources of rich user data including logs and traces of activity whilst using software products. Business decision making and strategy has been primarily dictated by data and is usually supported by business acumen. But in recent times it has not been uncommon to see data providing conclusions seemingly in contrast with conventional business logic. + +One could take the simple example of the baseball movie ‘Moneyball’, in which the protagonist defies all notions of popular wisdom in looking solely at performance statistics to evaluate player viability, eventually building a winning team of players – a team that would otherwise never have come together. The advantage of Big Data for enterprises, then, becomes a no brainer for most corporate entities looking to maximise revenue and engagement. At the back-end, this is accomplished by popular combinations of existing tools specially designed for large scale, multi-purpose data analysis. Apache, Hadoop and Spark are some of the most widespread open source tools used in this space in the industry. Concomitantly, it is easy to imagine that there are a number of software providers offering B2B services to corporate clients looking to outsource specific portions of their analytics. Therefore, there is a bustling market with customisable, proprietary technological solutions in this space as well. + +![Figure 1: A crowded landscape to follow \(Source: Forbes\)][3] + +Traditionally, Big Data refers to the large volumes of unstructured and heterogeneous data that is often subject to processing in order to provide insights and improve decision-making regarding critical business processes. The McKinsey Global institute estimates that data volumes have been growing at 40 per cent per year and will grow 44x between the years 2009 and 2020. But there is more to Big Data than just its immense volume. The rate of data production is an important factor given that smaller data streams generated at faster rates produce larger pools than their counterparts. Social media is a great example of how small networks can expand rapidly to become rich sources of information — up to massive, billion-node scales. + +Structure in data is a highly variable attribute given that data is now extracted from across the entire spectrum of user activity. Conventional formats of storage, including relational databases, have been virtually replaced by massively unstructured data pools designed to be leveraged in manners unique to their respective use cases. In fact, there has been a huge body of work on data storage in order to leverage various write formats, compression algorithms, access methods and data structures to arrive at the best combination for improving productivity of the workflow reliant on that data. A variety of these combinations has emerged to set the industry standards in their respective verticals, with the benefits ranging from efficient storage to faster access. + +Finally, we have the latent value in these data pools that remains to be exploited by the use of emerging trends in artificial intelligence and machine learning. Personalised advertising recommendations are a huge factor driving revenue for social media giants like Facebook and companies like Google that offer a suite of products and an ecosystem to use them. The well-known Silicon Valley giant started out as a search provider, but now controls a host of apps and most of the entry points for the data generated in the course of people using a variety of electronic devices across the world. Established financial institutions are now exploring the possibility of a portion of user data being put on an immutable public ledger to introduce a blockchain-like structure that can open the doors to innovation. The pace is picking up as product offerings improve in quality and expand in variety. Let’s get a bird’s eye view of this subject to understand where the market stands. +The idea behind building better frameworks is increasingly turning into a race to provide more add-on features and simplify workflows for the end user to engage with. This means the categories have many blurred lines because most products and tools present themselves as end-to-end platforms to manage Big Data analytics. However, we’ll attempt to divide this broadly into a few categories and examine some providers in each of these. + +**Big Data storage and processing** +Infrastructure is the key to building a reliable workflow when it comes to enterprise use cases. Earlier, relational databases were worthwhile to invest in for small and mid-sized firms. However, when the data starts pouring in, it is usually the scalability that is put to the test first. Building a flexible infrastructure comes at the cost of complexity. It is likely to have more moving parts that can cause failure in the short-term. However, if done right – something that will not be easy because it has to be tailored exactly to your company – it can result in life-changing improvements for both users and the engineers working with the said infrastructure to build and deliver state-of-the-art products. + +There are many alternatives to SQL, with the NoSQL paradigm being adopted and modified for building different types of systems. Cassandra, MongoDB and CouchDB are some well-known alternatives. Most emerging options can be distinguished based on their disruption, which is aimed at the fundamental ACID properties of databases. To recall, a transaction in a database system must maintain atomicity, consistency, isolation, and durability − commonly known as ACID properties − in order to ensure accuracy, completeness, and data integrity (from Tutorialspoint). For instance, CockroachDB, an open source offshoot of Google’s Spanner database system, has gained traction due to its support for being distributed. Redis and HBase offer a sort of hybrid storage solution while Neo4j remains a flag bearer for graph structured databases. However, traditional areas aside, there are always new challenges on the horizon for building enterprise software. + +Backups are one such area where startups have found viable disruption points to enter the market. Cloud backups for enterprise software are expensive, non-trivial procedures and offloading this work to proprietary software offers a lucrative business opportunity. Rubrik and Cohesity are two companies that originally started out in this space and evolved to offer added services atop their primary offerings. Clumio is a recent entrant, purportedly creating a data fabric that the promoters expect will serve as a foundational layer to run analytics on top of. It is interesting to follow recent developments in this burgeoning space as we see competitors enter the market and attempt to carve a niche for themselves with their product offerings. + +**Big Data analytics in the cloud** +Apache Hadoop remains the popular choice for many organisations. However, many successors have emerged to offer a set of additional analytical capabilities: Apache Spark, commonly hailed as an improvement to the Hadoop ecosystem; Apache Storm that offers real-time data processing capabilities; and Google’s BigQuery, which is supposedly a full-fledged platform for Big Data analytics. + +Typically, cloud providers such as Amazon Web Services and Google Cloud Platform tend to build in-house products leveraging these capabilities, or replicate them entirely and offer them as hosted services to businesses. This helps them provide enterprise offerings that are closely integrated within their respective cloud computing ecosystem. There has been some discussion about the moral consequences of replicating open source products to profit off closed source versions of the same, but there has been no consensus on the topic, nor any severe consequences suffered on account of this questionable approach to boost revenue. + +Another hosted service offering a plethora of Big Data analytics tools is Cloudera which has an established track record in the market. It has been making waves since its merger with Hortonworks earlier this year, giving it added fuel to compete with the giants in its bid to become the leading enterprise cloud provider in the market. + +Overall, we’ve seen interesting developments in the Big Data storage and analysis domain and as the volume and variety of data grows, so do the opportunities to innovate in the field. + +![Avatar][4] + +[Swapneel Mehta][5] + +The author has worked at Microsoft Research, CERN and startups in AI and cyber security. He is an open source enthusiast who enjoys spending time organising software development workshops for school and college students. You can contact him at ; or . + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/a-birds-eye-view-of-big-data-for-enterprises-2/ + +作者:[Swapneel Mehta][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://opensourceforu.com/author/swapneel-mehta/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-1-Big-Data-analytics-and-processing-for-the-enterprise.jpg?resize=696%2C449&ssl=1 (Figure 1 Big Data analytics and processing for the enterprise) +[2]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-1-Big-Data-analytics-and-processing-for-the-enterprise.jpg?fit=900%2C580&ssl=1 +[3]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-2-A-crowded-landscape-to-follow.jpg?resize=350%2C254&ssl=1 +[4]: https://secure.gravatar.com/avatar/2ba7abaf240a1f6166d506dccdcda00f?s=100&r=g +[5]: https://opensourceforu.com/author/swapneel-mehta/ diff --git a/sources/talk/20191105 AI and 5G- Entering a new world of data.md b/sources/talk/20191105 AI and 5G- Entering a new world of data.md new file mode 100644 index 0000000000..0edac458c9 --- /dev/null +++ b/sources/talk/20191105 AI and 5G- Entering a new world of data.md @@ -0,0 +1,94 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (AI and 5G: Entering a new world of data) +[#]: via: (https://www.networkworld.com/article/3451718/ai-and-5g-entering-a-new-world-of-data.html) +[#]: author: (Matt Conran https://www.networkworld.com/author/Matt-Conran/) + +AI and 5G: Entering a new world of data +====== +The deployment model of vendor-centric equipment cannot sustain this exponential growth in traffic. +[Stinging Eyes][1] [(CC BY-SA 2.0)][2] + +Today the telecom industry has identified the need for faster end-user-data rates. Previously users were happy to call and text each other. However, now mobile communication has converted our lives in such a dramatic way it is hard to imagine this type of communication anymore. + +Nowadays, we are leaning more towards imaging and VR/AR video-based communication. Therefore, considering such needs, these applications are looking for a new type of network. Immersive experiences with 360° video applications require a lot of data and a zero-lag network. + +To give you a quick idea, VR with a resolution equivalent to 4K TV resolution would require a bandwidth of 1Gbps for a smooth play or 2.5 Gbps for interactive; both requiring a minimal latency of 10ms and minimal delay. And that's for round-trip time. Soon these applications will target the smartphone, putting additional strains on networks. As AR/VR services grow in popularity, the proposed 5G networks will yield the speed and the needed performance. + +Every [IoT device][3] _[Disclaimer: The author works for Network Insight]_, no matter how dumb it is, will create data and this data is the fuel for the engine of AI. AI enables us to do more interesting things with the data. The ultimate goal of the massive amount of data we will witness is the ability to turn this data into value. The rise in data from the enablement of 5G represents the biggest opportunity for AI. + +There will be unprecedented levels of data that will have to move across the network for processing and in some cases be cached locally to ensure low latency. For this, we primarily need to move the processing closer to the user to utilize ultra-low latency and ultra-high throughput. + +### Some challenges with 5G + +The introduction of 5G is not without challenges. It's expensive and is distributed in ways that have not been distributed in the past. There is an extensive cost involved in building this type of network. Location is central to effective planning, deployment and optimization of 5G networks. + +Also, the 5G millimeter wave comes with its own challenges. There are techniques that allow you to take the signal and send it towards a specific customer instead of sending it to every direction. The old way would be similar to a light bulb that reaches all the parts of the room, as opposed to a flashlight that targets specific areas. + +[The time of 5G is almost here][4] + +So, choosing the right location plays a key role in the development and deployment of 5G networks. Therefore, you must analyze if you are building in the right place, and are marketing to the right targets. How many new subscribers do you expect to sign up for the services if you choose one area over the other? You need to take into account the population that travels around that area, the building structures and how easy it is to get the signal. + +Moreover, we must understand the potential of flooding and analyze real-time weather to predict changes in traffic. So, if there is a thunderstorm, we need to understand how such events influence the needs of the networks and then make predictive calculations. AI can certainly assist in predicting these events. + +### AI, a doorway to opportunity + +5G is introducing new challenges, but by integrating AI techniques into networks is one way the industry is addressing these complexities. AI techniques is a key component that needs to be adapted to the network to help manage and control this change. Another important use case for AI is for network planning and operations. + +With 5G, we will have 100,000s of small cells everywhere where each cell is connected to a fiber line. It has been predicted that we can have 10 million cells globally. Figuring out how to plan and design all these cells would be beyond human capability. This is where AI can do site evaluations and tell you what throughput you have with certain designs. + +AI can help build out the 5G infrastructure and map out the location of cell towers to pinpoint the best location for the 5G rollout. It can continuously monitor how the network is being used. If one of the cell towers is not functioning as expected, AI can signal to another cell tower to take over. + +### Vendor-centric equipment cannot sustain 5G + +With the enablement of 5G networks, we have a huge amount of data. In some cases, this could be high in the PB region per day; the majority of this will be due to video-based applications. A deployment model of vendor-centric equipment cannot sustain this exponential growth in traffic. + +We will witness a lot of open source in this area, with the movement of the processing and compute, storage and network functionality to the edge. Eventually, this will create a real-time network at the edge. + +### More processing at the edge + +Edge computing involves having the computer, server and network at the very edge of the network that is closer to the user. It provides intelligence at the edge, thereby reducing the amount of traffic going to the backbone. + +Edge computing can result in for example AI object identification to reach the target recognition in under .35 seconds. Essentially, we have the image recognition deep learning algorithm that is sitting on the edge. The algorithm sitting on the edge of the network will help to reduce the traffic sent to the backbone. + +However, this also opens up a new attack surface and luckily AI plays well with cybersecurity. A closed-loop system will collect data at the network edge, identity threats and take real-time action. + +### Edge and open source + +We have a few popular open-source options available at our disposal. Some examples of open source edge computing could be Akraino Edge Stack, ONAP Open Network Animation Platform and Airship Open Infrastructure Project. + +The Akraino Edge Stack creates an open-source software stack that supports high-availability cloud services. These services are optimized for edge computing systems and applications. + +The Akraino R1 release includes 10 “ready and proven” blueprints and delivers a fully functional edge stack for edge use cases. These range from Industrial IoT, Telco 5G Core & vRAN, uCPE, SDWAN, edge media processing and carrier edge media processing. + +The ONAP (Open Network Platform) provides a comprehensive platform for real-time, policy-driven orchestration and automation of physical and virtual network functions. It is an open-source networking project hosted by the Linux Foundation. + +Finally, the Airship Open Infrastructure Project is a collection of open-source tools for automating cloud provisioning and management. These tools include OpenStack for virtual machines, Kubernetes for container orchestration and MaaS for bare metal, with planned support for OpenStack Ironic. + +**This article is published as part of the IDG Contributor Network. [Want to Join?][5]** + +Join the Network World communities on [Facebook][6] and [LinkedIn][7] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3451718/ai-and-5g-entering-a-new-world-of-data.html + +作者:[Matt Conran][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.networkworld.com/author/Matt-Conran/ +[b]: https://github.com/lujun9972 +[1]: https://www.flickr.com/photos/martinlatter/4233363677 +[2]: https://creativecommons.org/licenses/by-sa/2.0/legalcode +[3]: https://network-insight.net/2017/10/internet-things-iot-dissolving-cloud/ +[4]: https://www.networkworld.com/article/3354477/mobile-world-congress-the-time-of-5g-is-almost-here.html +[5]: https://www.networkworld.com/contributor-network/signup.html +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191105 Conquering documentation challenges on a massive project.md b/sources/talk/20191105 Conquering documentation challenges on a massive project.md new file mode 100644 index 0000000000..79dab63e8a --- /dev/null +++ b/sources/talk/20191105 Conquering documentation challenges on a massive project.md @@ -0,0 +1,155 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Conquering documentation challenges on a massive project) +[#]: via: (https://opensource.com/article/19/11/documentation-challenges-tom-caswell-matplotlib) +[#]: author: (Gina Helfrich, Ph.D. https://opensource.com/users/ginahelfrich) + +Conquering documentation challenges on a massive project +====== +Learn more about documentation at scale in this interview with Tom +Caswell, Matplotlib lead developer. +![Files in a folder][1] + +Given the recent surge in popularity of open source data science projects like pandas, NumPy, and [Matplotlib][2], it’s probably no surprise that the increased level of interest is generating user complaints about documentation. To help shed light on what’s at stake, we talked to someone who knows a lot about the subject: [Thomas Caswell][3], the lead developer of Matplotlib. + +Matplotlib is a flexible and customizable tool for producing static and interactive data visualizations since 2001 and is a foundational project in the scientific Python stack. Matplotlib became a [NumFOCUS-sponsored project][4] in 2015. + +Tom has been working on Matplotlib for the past five years and got his start answering questions about the project on Stack Overflow. Answering questions became submitting bug reports, which became writing patches, which became maintaining the project, which ultimately led to him becoming the lead developer. + +**Fun fact:** Tom’s advancement through the open source community follows exactly the [path described by Brett Cannon][5], a core Python maintainer. + +NumFOCUS Communications Director, Gina Helfrich, sat down with Tom to discuss the challenges of managing documentation on a project as massive and as fundamental as Matplotlib. + +**Gina Helfrich:** Thanks so much for taking the time to talk with us about Matplotlib and open source documentation, Tom. To contextualize our conversation a bit, can you speak a little to your impression of the [back-and-forth][6] on Twitter with Wes McKinney about pandas and user complaints about the documentation? + +**Thomas Caswell:** I only kind of saw the edges, but I see both sides. On one hand, I think something Mike Pope said was, "if it’s not documented, it doesn’t exist." If you are writing open source tools, + +part of that work is documenting them, and doing so clearly in a way that users can discover and actually use, short of going to the source [code]. It’s not good enough to dump code on the internet—you have to do the whole thing. + +On the other hand, if you’re not paying [for the software], you don’t get to make demands. The attitude I think Wes was reacting to, which you see a lot, is: "You built this tool that is useful to me, therefore I expect enterprise-grade paid support because it’s obviously critical to what I’m doing." + +But I think the part Eric O. Lebigot was responding to is the first part. Part of building a tool is the documentation, not just the code. But Wes is responding to the entitlement, the expectation of free work, so I see both sides. + +**GH:** Looking at Matplotlib specifically, which is facing many of the same issues as pandas, I know you have some big challenges with your documentation. I get the impression that there’s this notion out there from new users that getting started with Matplotlib is super frustrating and the docs don’t really help. Can you tell me about the history there and how the project came to have this problem? + +**TC:** So, Matplotlib is a humongous library. I’ve been working on it for five years, and around once a month (or every other month), there’s a bug report where my first reaction is, "Wait… we do _what_?" + +A lot of the library is under-documented. This library survived at least two generations of partial conversion to standardized docstring formats. As I understand it (I wasn’t around at the time), we were one of the first projects outside of core Python to adopt Sphinx to build our docs—possibly a little too early. We have a lot of weird customizations since Sphinx didn’t have those features yet [at the time]. Other people have built better versions of those features since then, but because Matplotlib is so huge, migrating them is hard. + +I think if you build the PDF version of our docs, it’s around 3,000 pages, and I would say that the library has maybe half the documentation it really needs. + +We are woefully under-documented in the sense that not every feature has good docs. On the other hand, we are over-documented in that what we have is not well organized and there’s no clear entry point. If I want to find out how to do something, even I have a hard time finding where something is documented. And if _I_ [the lead developer] have issues finding that information, there’s no prayer of new users finding it. So in that sense, we are both drastically under-documented and drastically over-documented. + +**[Read next: [Syadmins: Poor documentation is not a job insurance strategy][7]]** + +**GH:** Given that Matplotlib is over 15 years old, do you have a sense of who has been writing the documentation? How does your documentation actually get developed? + +**TC:** Historically, much like the code, the documentation was organically developed. We’ve had a lot of investment in examples and docstrings, and a few entries labeled as tutorials that teach you one specific skill. For example, we’ve got prose on the "rough theory of colormaps," and how to make a colormap. + +A lot of Matplotlib’s documentation is examples, and the examples overlap. Over the past few years, when I see interesting examples go by on the mailing list or on Stack Overflow, I’ll say, "Can you put this example in the docs?" So, I guess I’ve been actively contributing to the problem that there’s too much stuff to wade through. + +Part of the issue is that people will do a six-hour tutorial and then some of those examples end up in the docs. Then, someone _else_ will do a six-hour tutorial (you can’t cover the whole library in six hours) and the basics are probably similar, but they may format the tutorial differently. + +**GH:** Wow, that sounds pretty challenging to inherit and try to maintain. What kinds of improvements have you been working on for the documentation? + +**TC:** There’s been an effort over the past couple of years to move to numpydoc format, away from the home-grown scheme we had previously. Also, [Nelle Varoquaux][8] recently did a tremendous amount of work and led the effort to move from how we were doing examples to using Sphinx-Gallery, which makes it much easier to put good prose into examples. This practice was picked up by [Chris Holdgraf][9] recently, as well. Sphinx-Gallery went live on our main docs with Matplotlib 2.1, which was a huge improvement for users. Nelle also organized a distributed [docathon][10]. + +We’ve been trying to get better about new features. When there’s a new feature, you must add an example to the docs for that feature, which helps make things discoverable. We’ve been trying to get better about making sure docstrings exist, are accurate, and that they document all of the parameters. + +**GH:** If you could wave a magic wand and have the Matplotlib docs that you want, what would they look like? + +**TC:** Well, as I mentioned, the docs grew organically, and that means we have no consistent voice across them. It also means there’s no single point of truth for various things. When you write an example, how far back down the basics do you go? So, it’s not clear what you need to know before you can understand the example. Either you explain just enough, all the way back (so we’ve got a random assortment of the basics smeared everywhere), or you have examples that, unless you’re already a heavy user, make no sense. + +So, to answer the question, having someone who can actually _write_ and has empathy for users go through and write a 200-page intro to Matplotlib book, and have that be the main entry to the docs. That’s my current vision of what I want. + +**GH:** If you were introducing a new user to Matplotlib today, what would you have her read? Where would you point her in the docs? + +**TC:** Well, there isn’t a good, clear option for, "You’ve been told you need to use Matplotlib. Go spend an afternoon and read this." I’m not sure where I’d point people to for that right now. [Nicolas Rougier][11] has written some [good][12] [stuff][13] on that front, such as a tutorial for beginners, and some of that has migrated into the docs. + +There’s a lot out there, but it’s not collated centrally, or linked from our docs as "START HERE." I should also add that I might not have the best view of this issue anymore because I haven’t actively gone looking for this information, so maybe I just never found it because I don’t need it. I don’t know that it exists. (This topic actually [came up recently][14] on the mailing list.) + +The place we do point people to is: Go look at the gallery and click on the thumbnail that looks closest to what you want to do. + +Ben Root presented an [Anatomy of Matplotlib tutorial][15] at SciPy several times. There’s a number of Matplotlib books that exist. It’s mixed whether the authors were contributors [to the project]. Ben Root recently wrote one about [interactive figures][16]. I’ve been approached and have turned this task down a couple of times, just because I don’t have time to write a book. So my thought for getting a technical writer was to get a technical writer to write the book, and instead of publishing the result as a book, put it in the online docs. + +**GH:** Is there anyone in the Matplotlib contributor community who specializes in the documentation part of things, or takes a lot of ownership around documentation? + +Nelle was doing this for Matplotlib for a bit but has stepped back. Chris Holdgraf is taking the lead on some doc-related things now. Nicholas Rougier has written a number of [extremely good tutorials][17] outside of the project's documentation. + +I mean, no one uses _just_ Matplotlib. You don’t use us but not use SciPy, NumPy, or pandas. You have to be using something else to do the actual work that you now need to visualize. There are many "clean" introductions to Matplotlib in other places. For example, both Jake VanderPlas’s [analysis book][18] and Katy Huff and Anthony Scopatz’s [book][19] have introductions to Matplotlib that cover this topic to the degree they felt was needed for their purposes. + +**GH:** I’d love to hear your thoughts on the role of Stack Overflow in all of this. + +**TC:** That actually is how I got into the project. My Stack Overflow number is large, and it’s almost all Matplotlib questions. And how I got started is that I answered questions. A lot of the questions on Stack Overflow are, "Please read the docs for me." Which, fine. But actually, a great way to learn the library is to answer questions on Stack Overflow, because people who have problems that you don’t personally have will ask, "How do I do this?" and now you have to go figure out how to do it. It’s kind of fun. + +But sometimes people ask questions and they’ve actually found a bug. And in determining that they’ve actually found a bug, I tried to figure out how to fix the bugs. So, I started some reports, which led to, "Here’s a pull request to fix the bug I found." And then when I started entering a lot of PRs, they were like, "You need to start reviewing them now," so they gave me commit rights and made me review things. And then they put me in charge. + +I do like Stack Overflow. I think that to a large extent, what it replaced is the mailing list. If I have any criticism of Stack Overflow, I think it’s convincing people who are answering questions to upstream more of the results. + +There are some good examples on Stack Overflow. Here’s a complex one: You have to touch these seven different functions, each of which are relatively well documented, but you have to put them together in just the right way. Some of those answers should probably go in the gallery with our annotations about how they work. Basically, if you go through Joe Kington’s top 50 answers, they should probably all go in the docs. + +In other cases, the question is asked because the docstring is not clear. We need to convince people who are answering those questions to use those moments as a survey of where our documentation is not clear, instead of just answering [on Stack Overflow], and then move those answers back [to the docs]. + +**GH:** What’s it like managing PRs for documentation as opposed to patches and bug fixes? + +**TC:** We’ve tried to streamline how we do documentation PRs. Writing documentation PRs is the most painful thing ever in open source because you get copyediting via pull request. You get picky proofreading and copyediting via GitHub comments. Like, "there’s a missing comma," or "two spaces!" And again, I keep using myself as a weird outlier benchmark, _I_ get disheartened when I write doc pull requests and then I get 50 comments regarding picky little things. + +What I’ve started trying to push as the threshold on docs is, "Did [the change] make it worse?" If it didn’t make it worse, merge the change. Frequently, it takes more time to leave a GitHub comment than to fix the problem. + +> "If you can use Matplotlib, you are qualified to contribute to it." +>      — Tom Caswell, Matplotlib lead developer + +**GH:** What’s one action you’d like members of the community who are reading this interview to take? What is one way they could make a difference on this issue? + +**TC:** One thing I’d like to see more of—and I acknowledge that how to contribute to open source is a big hurdle to get over—I’ve said previously that if you can use Matplotlib, you are qualified to contribute to it. That’s a message I would like to get out more broadly. + +If you’re a user and you read the docstring to something and it doesn’t make sense, and then you play around a bit and you understand that function well enough to use it—you could then start clarifying docstrings. + +Because one of the things I have the hardest time with is that I personally am bad at putting myself in other people’s shoes when writing docs. I don’t know from a user’s point of view—and this sounds obnoxious but I’m deep enough in the code—what they know coming into the library as a new person. I don’t know the right things to tell them in the docstring that will actually help them. I can try to guess and I’ll probably write too much, or the wrong things. Or worse, I’ll write a bunch of stuff that refers to things they don’t know about, and now I’ve just made the function more confusing. + +Whereas a user who has just encountered this function for the first time, and sorted out how to make it do what they need it to do for their purposes, is in the right mindset to write what they wish the docs had said that would have saved them an hour. + +**GH:** That’s a great message, I think. Thanks for talking with me, Tom! + +**TC:** You’re welcome. Thank you. + +_This article was originally published on the [NumFOCUS blog][20] in 2017 and is just as relevant today. It’s republished with permission by the original interviewer and has been lightly edited for style, length, and clarity. If you want to support NumFOCUS in person, attend one of the local [PyData events][21] happening around the world. Learn more about NumFOCUS on our website: [numfocus.org][22]_ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/documentation-challenges-tom-caswell-matplotlib + +作者:[Gina Helfrich, Ph.D.][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/ginahelfrich +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/files_documents_paper_folder.png?itok=eIJWac15 (Files in a folder) +[2]: https://matplotlib.org +[3]: https://twitter.com/tacaswell +[4]: https://numfocus.org/sponsored-projects +[5]: https://snarky.ca/why-i-took-october-off-from-oss-volunteering/ +[6]: https://twitter.com/wesmckinn/status/909772652532953088 +[7]: https://www.redhat.com/sysadmin/poor-documentation +[8]: https://twitter.com/nvaroqua +[9]: https://twitter.com/choldgraf +[10]: https://www.numfocus.org/blog/numfocus-projects-participate-in-docathon-2017/ +[11]: https://twitter.com/NPRougier +[12]: https://github.com/rougier/matplotlib-tutorial +[13]: http://www.labri.fr/perso/nrougier/teaching/matplotlib/matplotlib.html +[14]: https://mail.python.org/pipermail/matplotlib-users/2017-September/001031.html +[15]: https://github.com/matplotlib/AnatomyOfMatplotlib +[16]: https://www.amazon.com/Interactive-Applications-using-Matplotlib-Benjamin/dp/1783988843 +[17]: http://www.labri.fr/perso/nrougier/teaching/ +[18]: http://shop.oreilly.com/product/0636920034919.do +[19]: http://shop.oreilly.com/product/0636920033424.do +[20]: https://numfocus.org/blog/matplotlib-lead-developer-explains-why-he-cant-fix-the-docs-but-you-can +[21]: https://pydata.org/ +[22]: https://numfocus.org diff --git a/sources/talk/20191105 Forrester- Edge computing is about to bloom.md b/sources/talk/20191105 Forrester- Edge computing is about to bloom.md new file mode 100644 index 0000000000..c483ef661c --- /dev/null +++ b/sources/talk/20191105 Forrester- Edge computing is about to bloom.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Forrester: Edge computing is about to bloom) +[#]: via: (https://www.networkworld.com/article/3451532/forrester-edge-computing-is-about-to-bloom.html) +[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) + +Forrester: Edge computing is about to bloom +====== +2020 is set to be a “breakout year” for edge computing technology, according to the latest research from Forrester Research +Getty Images + +The next calendar year will be the one that propels [edge computing][1] into the enterprise technology limelight for good, according to a set of predictions from Forrester Research. + +While edge computing is primarily an [IoT][2]-related phenomenon, Forrester said that addressing the need for on-demand compute and real-time app engagements will also play a role in driving the growth of edge computing in 2020. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][3] + +What it all boils down to, in some ways, is that form factors will shift sharply away from traditional rack, blade or tower servers in the coming year, depending on where the edge technology is deployed. An autonomous car, for example, won’t be able to run a traditionally constructed server. + +[][4] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][4] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +It’ll also mean that telecom companies will begin to feature a lot more heavily in the cloud and distributed-computing markets. Forrester said that CDNs and [colocation vendors][5] could become juicy acquisition targets for big telecom, which missed the boat on cloud computing to a certain extent, and is eager to be a bigger part of the edge. They’re also investing in open-source projects like Akraino, an edge software stack designed to support carrier availability. + +But the biggest carrier impact on edge computing in 2020 will undoubtedly be the growing availability of [5G][6] network coverage, Forrester says. While that availability will still mostly be confined to major cities, that should be enough to prompt reconsideration of edge strategies by businesses that want to take advantage of capabilities like smart, real-time video processing, 3D mapping for worker productivity and use cases involving autonomous robots or drones. + +Beyond the carriers, there’s a huge range of players in the edge computing, all of which have their eyes firmly on the future. Operational-device makers in every field from medicine to utilities to heavy industry will need custom edge devices for connectivity and control, huge cloud vendors will look to consolidate their hold over that end of the market and AI/ML startups will look to enable brand-new levels of insight and functionality. + +What’s more, the average edge-computing implementation will often use many of them at the same time, according to Forrester, which noted that integrators who can pull products and services from many different vendors into a single system will be highly sought-after in the coming year. Multivendor solutions are likely to be much more popular than single-vendor, in large part because few individual companies have products that address all parts of the edge and IoT stacks. + +Join the Network World communities on [Facebook][7] and [LinkedIn][8] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3451532/forrester-edge-computing-is-about-to-bloom.html + +作者:[Jon Gold][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.networkworld.com/author/Jon-Gold/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3224893/what-is-edge-computing-and-how-it-s-changing-the-network.html +[2]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[3]: https://www.networkworld.com/newsletters/signup.html +[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[5]: https://www.networkworld.com/article/3407756/colocation-facilities-buck-the-cloud-data-center-trend.html +[6]: https://www.networkworld.com/article/3203489/what-is-5g-how-is-it-better-than-4g.html +[7]: https://www.facebook.com/NetworkWorld/ +[8]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191105 My first contribution to open source- Making a decision.md b/sources/talk/20191105 My first contribution to open source- Making a decision.md new file mode 100644 index 0000000000..0640ff1cf4 --- /dev/null +++ b/sources/talk/20191105 My first contribution to open source- Making a decision.md @@ -0,0 +1,58 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (My first contribution to open source: Making a decision) +[#]: via: (https://opensource.com/article/19/11/my-first-open-source-contribution-mistake-decisions) +[#]: author: (Galen Corey https://opensource.com/users/galenemco) + +My first contribution to open source: Making a decision +====== +A new open source contributor documents a series of five mistakes she +made starting out in open source. +![Lightbulb][1] + +Previously, I put a lot of [blame on impostor syndrome][2] for delaying my first open source contribution. But there was another factor that I can’t ignore: I can’t make a decision to save my life. And with [millions][3] of open source projects to choose from, choosing one to contribute to is overwhelming. So overwhelming that I would often end up closing my laptop, thinking, "Maybe I’ll just do this another day." + +Mistake number two was letting my fear of making a decision get in the way of making my first contribution. In an ideal world, perhaps I would have come into my open source journey with a specific project in mind that I genuinely cared about and wanted to work on, but all I had was a vague goal of contributing to open source somehow. For those of you in the same position, here are strategies that helped me pick out the right project (or at least a good one) for my contribution. + +### Tools that I used frequently + +At first, I did not think it would be necessary to limit myself to tools or projects with which I was already familiar. There were projects that I had never used before but seemed like appealing candidates because of their active community, or the interesting problems that they solved. + +However, given that I had a limited amount of time to devote to this project, I decided to stick with a tool that I already knew. To understand what a tool needs, you need to be familiar with how it is supposed to work. If you want to contribute to a project that you are unfamiliar with, you need to complete an additional step of getting to know the functionality and goals of the code. This extra load can be fun and rewarding, but it can also double your work time. Since my goal was primarily to contribute, sticking to what I knew was a helpful way to narrow things down. It is also rewarding to give back to a project that you have found useful. + +### An active and friendly community + +When choosing my project, I wanted to feel confident that someone would be there to review the code that I wrote. And, of course, I wanted the person who reviewed my code to be a nice person. Putting your work out there for public scrutiny is scary, after all. While I was open to constructive feedback, there were toxic corners of the developer community that I hoped to avoid. + +To evaluate the community that I would be joining, I checked out the _issues_ sections of the repos that I was considering. I looked to see if someone from the core team responded regularly. More importantly, I tried to make sure that no one was talking down to each other in the comments (which is surprisingly common in issues discussions). I also looked out for projects that had a code of conduct, outlining what was appropriate vs. inappropriate behavior for online interaction. + +### Clear contribution guidelines + +Because this was my first time contributing to open source, I had a lot of questions around the process. Some project communities are excellent about documenting the procedures for choosing an issue and making a pull request. Although I did not select them at the time because I had never worked with the product before, [Gatsby][4] is an exemplar of this practice. + +This type of clear documentation helped ease some of my insecurity about not knowing what to do. It also gave me hope that the project was open to new contributors and would take the time to look at my work. In addition to contribution guidelines, I looked in the issues section to see if the project was making use of the "good first issue" flag. This is another indication that the project is open to beginners (and helps you discover what to work on). + +### Conclusion + +If you don’t already have a project in mind, choosing the right place to make your first open source contribution can be overwhelming. Coming up with a list of standards helped me narrow down my choices and find a great project for my first pull request. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/my-first-open-source-contribution-mistake-decisions + +作者:[Galen Corey][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/galenemco +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lightbulb-idea-think-yearbook-lead.png?itok=5ZpCm0Jh (Lightbulb) +[2]: https://opensource.com/article/19/10/my-first-open-source-contribution-mistakes +[3]: https://github.blog/2018-02-08-open-source-project-trends-for-2018/ +[4]: https://www.gatsbyjs.org/contributing/ diff --git a/sources/talk/20191105 Open by nature- What building a platform for activists taught me about playful development.md b/sources/talk/20191105 Open by nature- What building a platform for activists taught me about playful development.md new file mode 100644 index 0000000000..2f594f2abe --- /dev/null +++ b/sources/talk/20191105 Open by nature- What building a platform for activists taught me about playful development.md @@ -0,0 +1,100 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Open by nature: What building a platform for activists taught me about playful development) +[#]: via: (https://opensource.com/open-organization/19/11/open-by-nature) +[#]: author: (Laura Hilliger https://opensource.com/users/laurahilliger) + +Open by nature: What building a platform for activists taught me about playful development +====== +Building a global platform for environmental activists revealed a spirit +of openness that's central to human nature—and taught me how to design +for it. +![The Open Organization at Greenpeace][1] + +"Open" isn't just a way we can build software. It's an attitude we can adopt toward anything we do. + +And when we adopt it, we can move mountains. + +Participating in a design sprint with colleagues at Greenpeace reminded me of that. As I explained in the first [two][2] [parts][3] of this [series][4], learning to think, plan, and work the open way is helping us build something truly great—a new, global platform for engaging activists who want to take action on behalf of our planet. + +The sprint experience (part of a collaboration with Red Hat) reinforced several lessons about openness I've learned throughout my career as an advocate for open source, an architect of change, and a community organizer. + +It also taught me a few new ones. + +### An open nature + +The design sprint experience reminded me just how central "openness" is to human nature. We all cook, sew, construct, write, play music, tinker, paint, tell stories—engage in the world through the creation of thousands of artifacts that allow others to understand our outlooks and worldviews. We express ourselves through our creations. We always have. + +We express ourselves through our creations. We always have. + +And throughout all of our expressive making, we reflect on and _share_ what we've created. We ask for feedback: _"Do you like my new recipe?" "What do you think of my painting?"_ + +We learn. Through trial and error (and ever-important failure), we learn what to do and what _not_ to do. Learning to make something work involves discovery and wonder in a spiral of [intrinsic motivation][5]; each new understanding unlocks new questions. We improve our skills as we create, and when we share. + +I noticed something critically important while our teams were collaborating: learning to work openly can liberate a certain playfulness that often gets ignored (or buried) in many organizations today—and that playfulness can help us solve complex problems. When we're having fun learning, creating, and sharing, we're often in a flow, truly interested in our work, creating environments that others want to join. Openness can be a fount of innovation. + +While our mission is a serious one, the more joy we find in it, the more people we'll attract to it. Discovery is a delightful process, and agency is empowering. The design sprint allowed us to finish with something that spurred reflection of our project—and do so with both humor and passion. The sprint left a lot of room for play, connection between participants, collaboration to solve problems, and decision-making. + +### Positively open + +Watching Red Hatters and Greenpeacers interact—many just having met one another for the first time—also crystallized for me some important impressions of open leadership. + +Open leadership took many forms throughout the sprint. The Red Hat team showed open leadership when they adapted the agenda on the first day. Greenpeace was further ahead than other groups they'd planned for, so their plan wouldn't work. Greenpeacers were transparent about certain internal politics (because it's no use planning something that's impossible to build). + +Open leaders are beacons of positivity. They assume best intentions in others. They truly listen. They live open principles. They build people up. + +People left their baggage at the door. We showed up, all of us, and were present together. + +Open leaders are beacons of positivity. They assume best intentions in others. They truly listen. They live open principles. They build people up. They remember to move as a collective, to ask for the insight of the collective, to thank the collective. + +And in the spirit of positive, open leadership, I want to offer my own thanks. + +Thanks to the Planet 4 team, a small group of people who kept pushing forward, despite the difficulties of a global project like this—a group that fought, made mistakes, and kept going despite them. They continue to pull together, and behind the scenes they're trying to be more open as they inspire the entire organization on an open journey with them (and build a piece of software at the same time!). + +Thanks to the others at Greenpeace who have supported this work and those who have participated in it. Thanks to the leaders in other departments, who saw the potential of this work and helped us socialize it. + +Thanks, too, to [the open organization community at Opensource.com][6] and [long-time colleagues][7] who modeled the behaviours and lent their open spirit to helping the Planet 4 team get started. + +### Open returns + +If openness is a way of being, then central to that way of being is [a spirit of reciprocity and exchange][8]. + +We belong to our communities and thus we contribute to them. We strive to be transparent so that our communities can grow and welcome new collaborators. When we infuse positivity into the world and into our projects, we create an atmosphere that invites innovation. + +Our success in open source means working to nurture those ecosystems of passionate contributors. Our success as a species demands the same kind of care for our natural ecosystems, too. + +Both Red Hat and Greenpeace understand the importance of ecosystems—and that shared understanding powered our collaboration on Planet 4. + +As an open source software company, Red Hat both benefits from and contributes to open source software communities across the world—communities forming a technological ecosystem of passionate contributors that must always be in delicate balance. Greenpeace is also focused on the importance of maintaining ecosystems—the natural ecosystems of which we are all, irrevocably, a part. Our success in open source means working to nurture those ecosystems of passionate contributors. Our success as a species demands the same kind of care for our natural ecosystems, too, and Planet 4 is a platform that helps everyone do exactly that. For both organizations, innovation is _social_ innovation; what we create _with_ others ultimately _benefits_ others, enhancing their lives. + +_Listen to Alexandra Machado of Red Hat explain social innovation._ + +So, really, the end of this story is just the beginning of so many others that will spawn from Planet 4. + +Yours can begin immediately. [Join the Planet 4 project][9] and advocate for a greener, more peaceful future—the open way. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/19/11/open-by-nature + +作者:[Laura Hilliger][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/laurahilliger +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/images/open-org/open-org-greenpeace-article-3-blog-thumbnail-500x283.png?itok=aK5TOqSS +[2]: https://opensource.com/open-organization/19/10/open-platform-greenpeace +[3]: https://opensource.com/open-organization/19/10/collaboration-breakthrough-greenpeace +[4]: https://opensource.com/tags/open-organization-greenpeace +[5]: http://en.wikipedia.org/wiki/Motivation#Intrinsic_and_extrinsic_motivation +[6]: https://opensource.com/open-organization/resources/meet-ambassadors +[7]: https://medium.com/planet4/how-to-prepare-for-planet-4-user-interviews-a3a8cd627fe +[8]: https://opensource.com/open-organization/19/9/peanuts-community-reciprocity +[9]: https://planet4.greenpeace.org/create/contribute/ diff --git a/sources/talk/20191106 A Quick Look at Some of the Best Cloud Platforms for High Performance Computing Applications.md b/sources/talk/20191106 A Quick Look at Some of the Best Cloud Platforms for High Performance Computing Applications.md new file mode 100644 index 0000000000..f684d6a5d7 --- /dev/null +++ b/sources/talk/20191106 A Quick Look at Some of the Best Cloud Platforms for High Performance Computing Applications.md @@ -0,0 +1,152 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A Quick Look at Some of the Best Cloud Platforms for High Performance Computing Applications) +[#]: via: (https://opensourceforu.com/2019/11/a-quick-look-at-some-of-the-best-cloud-platforms-for-high-performance-computing-applications/) +[#]: author: (Dr Kumar Gaurav https://opensourceforu.com/author/dr-gaurav-kumar/) + +A Quick Look at Some of the Best Cloud Platforms for High Performance Computing Applications +====== + +[![][1]][2] + +_Cloud platforms enable high performance computing without the need to purchase the required infrastructure. Cloud services are available on a ‘pay per use’ basis which is very economical. This article takes a look at cloud platforms like Neptune, BigML, Deep Cognition and Google Colaboratory, all of which can be used for high performance applications._ + +Software applications, smart devices and gadgets face many performance issues which include load balancing, turnaround time, delay, congestion, Big Data, parallel computations and others. These key issues traditionally consume enormous computational resources and low-configuration computers are not able to work on high performance tasks. The laptops and computers available in the market are designed for personal use; so these systems face numerous performance issues when they are tasked with high performance jobs. + +For example, a desktop computer or laptop with a 3GHz processor is able to perform approximately 3 billion computations per second. However, high performance computing (HPC) is focused on solving complex problems and working on quadrillions or trillions of computations with high speed and maximum accuracy. + +![Figure 1: The Neptune portal][3] + +![Figure 2: Creating a new project on the Neptune platform][4] + +**Application domains and use cases** +High performance computing applications are used in domains where speed and accuracy levels are quite high as compared to those in traditional scenarios, and the cost factor is also very high. + +The following are the use cases where high performance implementations are required: + + * Nuclear power plants + * Space research organisations + * Oil and gas exploration + * Artificial intelligence and knowledge discovery + * Machine learning and deep learning + * Financial services and digital forensics + * Geographical and satellite data analytics + * Bio-informatics and molecular sciences + + + +**Working with cloud platforms for high performance applications** +There are a number of cloud platforms on which high performance computing applications can be launched without users having actual access to the supercomputer. The billing for these cloud services is done on a usage basis and costs less compared to purchasing the actual infrastructure required to work with high performance computing applications. +The following are a few of the prominent cloud based platforms that can be used for advanced implementations including data science, data exploration, machine learning, deep learning, artificial intelligence, etc. + +**Neptune** +URL: __ +Neptune is a lightweight cloud based service for high performance applications including data science, machine learning, predictive knowledge discovery, deep learning, modelling training curves and many others. Neptune can be integrated with Jupyter notebooks so that Python programs can be easily executed for multiple applications. + +The Neptune dashboard is available at on which multiple experiments can be performed. Neptune works as a machine learning lab on which assorted algorithms can be programmed and their outcomes can be visualised. The platform is available as Software as a Service (SaaS) so that the deployment can be done on the cloud. The deployments can be done on the users’ own hardware and can be mapped with the Neptune cloud. + +In addition to having a pre-built cloud based platform, Neptune can be integrated with Python and R programming so that high performance applications can be programmed. Python and R are prominent programming environments for data science, machine learning, deep learning, Big Data and many other applications. + +For Python programming, Neptune provides neptune-client so that communication with the Neptune server can be achieved, and advanced data analytics can be implemented on its advanced cloud. +For integration of Neptune with R, there is an amazing and effective library ‘reticulate’ which integrates the use of neptune-client. + +The detailed documentation for the integration of R and Python with Neptune is available at _ and _. + +![Figure 3: Integration of Neptune with Jupyter Notebook][5] + +![Figure 4: Dashboard of BigML][6] + +In addition, integration with MLflow and TensorBoard is also available. MLflow is an open source platform for managing the machine learning life cycle with reproducibility, advanced experiments and deployments. It has three key components — tracking, projects and models. These can be programmed and controlled using the Neptune – MLflow integration. + +The association of TensorFlow with Neptune is possible using Neptune-TensorBoard. TensorFlow is one of the powerful frameworks for the deep learning and advanced knowledge discovery approaches. +With the use of assorted features and dimensions, the Neptune cloud can be used for high performance research based implementations. + +**BigML** +URL: __ + +BigML is a cloud based platform for the implementation of advanced algorithms with assorted data sets. This cloud based platform has a panel for implementing multiple machine learning algorithms with ease. +The BigML dashboard has access to different data sets and algorithms under supervised and unsupervised taxonomy, as shown in Figure 4. The researcher can use the algorithm from the menu according to the requirements of the research domain. + +![Figure 5: Algorithms and techniques integrated with BigML][7] + +A number of tools, libraries and repositories are integrated with BigML so that the programming, collaboration and reporting can be done with a higher degree of performance and minimum error levels. +Algorithms and techniques can be attached to specific data sets for evaluation and deep analytics, as shown in Figure 5. Using this methodology, the researcher can work with the code as well as the data set on easier platforms. + +The following are the tools and libraries associated with BigML for multiple applications of high performance computing: + + * Node-Red for flow diagrams + * GitHub repos + * BigMLer as the command line tool + * Alexa Voice Service + * Zapier for machine learning workflows + * Google Sheets + * Amazon EC2 Image PredictServer + * BigMLX app for MacOS + + + +![Figure 6: Enabling Google Colaboratory from Google Drive][8] + +![Figure 7: Activation of the hardware accelerator with Google Colaboratory notebook][9] + +**Google Colaboratory** +URL: __ +Google Colaboratory is one of the cloud platforms for the implementation of high performance computing tasks including artificial intelligence, machine learning, deep learning and many others. It is a cloud based service which integrates Jupyter Notebook so that Python code can be executed as per the application domain. +Google Colaboratory is available as a Google app in Google Cloud Services. It can be invoked from Google Drive as depicted in Figure 6 or directly at __. + +The Jupyter notebook in Google Colaboratory is associated with the CPU, by default. If a hardware accelerator is required, like the tensor processing unit (TPU) or the graphics processing unit (GPU), it can be activated from _Notebook Settings_, as shown in Figure 7. +Figure 8 presents a view of Python code that is imported in the Jupyter Notebook. The data set can be placed in Google Drive. The data set under analysis is mapped with the code so that the script can directly perform the operations as programmed in the code. The outputs and logs are presented on the Jupyter Notebook in the platform of Google Colaboratory. + +![Figure 8: Implementation of the Python code on the Google Colaboratory Jupyter Notebook][10] + +**Deep Cognition** +URL: __ +Deep Cognition provides the platform to implement advanced neural networks and deep learning models. AutoML with Deep Cognition provides an autonomous integrated development environment (IDE) so that the coding, testing and debugging of advanced models can be done. +It has a visual editor so that the multiple layers of different types can be programmed. The layers that can be imported are core layers, hidden layers, convolutional layers, recurrent layers, pooling layers and many others. +The platform provides the features to work with advanced frameworks and libraries of MXNet and TensorFlow for scientific computations and deep neural networks. + +![Figure 9: Importing layers in neural network models on Deep Cognition][11] + +**Scope for research and development** +Research scholars, academicians and practitioners can work on advanced algorithms and their implementations using cloud based platforms dedicated to high performance computing. With this type of implementation, there is no need to purchase the specific infrastructure or devices; rather, the supercomputing environment can be hired on the cloud. + +![Avatar][12] + +[Dr Kumar Gaurav][13] + +The author is the managing director of Magma Research and Consultancy Pvt Ltd, Ambala Cantonment, Haryana. He has 16 years experience in teaching, in industry and in research. He is a projects contributor for the Web-based source code repository SourceForge.net. He is associated with various central, state and deemed universities in India as a research guide and consultant. He is also an author and consultant reviewer/member of advisory panels for various journals, magazines and periodicals. The author can be reached at [kumargaurav.in@gmail.com][14]. + +[![][15]][16] + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/a-quick-look-at-some-of-the-best-cloud-platforms-for-high-performance-computing-applications/ + +作者:[Dr Kumar Gaurav][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://opensourceforu.com/author/dr-gaurav-kumar/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Big-ML-Colab-and-Deep-cognition.jpg?resize=696%2C384&ssl=1 (Big ML Colab and Deep cognition) +[2]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Big-ML-Colab-and-Deep-cognition.jpg?fit=900%2C497&ssl=1 +[3]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-1-The-Neptune-portal.jpg?resize=350%2C122&ssl=1 +[4]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-2-Creating-a-new-project-on-the-Neptune-platform.jpg?resize=350%2C161&ssl=1 +[5]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-3-Integration-of-Neptune-with-Jupyter-Notebook.jpg?resize=350%2C200&ssl=1 +[6]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-4-Dashboard-of-BigML.jpg?resize=350%2C193&ssl=1 +[7]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-5-Algorithms-and-techniques-integrated-with-BigML.jpg?resize=350%2C200&ssl=1 +[8]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-6-Enabling-Google-Colaboratory-from-Google-Drive.jpg?resize=350%2C253&ssl=1 +[9]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-7-Activation-of-the-hardware-accelerator-with-Google-Colaboratory-notebook.jpg?resize=350%2C264&ssl=1 +[10]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-8-Implementation-of-the-Python-code-on-the-Google-Colaboratory-Jupyter-Notebook.jpg?resize=350%2C253&ssl=1 +[11]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-9-Importing-layers-in-neural-network-models-on-Deep-Cognition.jpg?resize=350%2C254&ssl=1 +[12]: https://secure.gravatar.com/avatar/4a506881730a18516f8f839f49527105?s=100&r=g +[13]: https://opensourceforu.com/author/dr-gaurav-kumar/ +[14]: mailto:kumargaurav.in@gmail.com +[15]: http://opensourceforu.com/wp-content/uploads/2013/10/assoc.png +[16]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/sources/talk/20191106 Getting started with Pimcore- An open source alternative for product information management.md b/sources/talk/20191106 Getting started with Pimcore- An open source alternative for product information management.md new file mode 100644 index 0000000000..9e875a5019 --- /dev/null +++ b/sources/talk/20191106 Getting started with Pimcore- An open source alternative for product information management.md @@ -0,0 +1,130 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Getting started with Pimcore: An open source alternative for product information management) +[#]: via: (https://opensource.com/article/19/11/pimcore-alternative-product-information-management) +[#]: author: (Dietmar Rietsch https://opensource.com/users/erinmcmahon) + +Getting started with Pimcore: An open source alternative for product information management +====== +PIM software enables sellers to centralize sales, marketing, and +technical product information to engage better with customers. +![Pair programming][1] + +Product information management (PIM) software enables sellers to consolidate product data into a centralized repository that acts as a single source of truth, minimizing errors and redundancies in product data. This, in turn, makes it easier to share high-quality, clear, and accurate product information across customer touchpoints, paving the way for rich, consistent, readily accessible content that's optimized for all the channels customers use, including websites, social platforms, marketplaces, apps, IoT devices, conversational interfaces, and even print catalogs and physical stores. Being able to engage with customers on their favorite platform is essential for increasing sales and expanding into new markets. For years, there have been proprietary products that address some of these needs, like Salsify for data management, Adobe Experience Manager, and SAP Commerce Cloud for experience management, but now there's an open source alternative called Pimcore. + +[Pimcore PIM][2] is an open source enterprise PIM, dual-[licensed][3] under GPLv3 and Pimcore Enterprise License (PEL) that enables sellers to centralize and harmonize sales, marketing, and technical product information. Pimcore can acquire, manage, and share any digital data and integrate easily into an existing IT system landscape. Its API-driven, service-oriented architecture enables fast and seamless connection to third-party software such as enterprise resource planning (ERP), customer relationship management (CRM), business intelligence (BI), and more. + +### Open source vs. proprietary PIM software + +There are at least four significant differences between open source and proprietary software that PIM users should consider. + + * **Vendor lock-in:** It is more difficult to customize proprietary software. If you want to develop a new feature or modify an existing one, proprietary software lock-in makes you dependent on the vendor. On the other hand, open source provides unlimited access and flexibility to modify the source code and leverage it to your advantage, as well as the opportunity to freely access contributions made by the community behind it. + * **Interoperability:** Open source PIM software offers greater interoperability capabilities with APIs for integration with third-party business applications. Since the source code is open and available, users can customize or build connectors to meet their needs, which is not possible with proprietary software. + * **Community:** Open source solutions are supported by vibrant communities of contributors, implementers, developers, and other enthusiasts working towards enhancing the solution. Proprietary PIM software typically depends on commercial partnerships for implementation assistance and customizations. + * **Total cost of ownership:** Proprietary software carries a significant license fee for deployment, which includes implementation, customization, and system maintenance. In contrast, open source software development can be done in-house or through an IT vendor. This becomes a huge advantage for enterprises with tight budgets, as it slashes PIM operating costs. + + + +### Pimcore features + +Pimcore's platform is divided into two core offerings: data management and experience management. In addition to being open source and free to download and use, its features include the following. + +#### Data modeling + +Pimcore's web-based data modeling engine has over 40 high-performance data types that can help companies easily manage zillions of products or other master data with thousands of attributes. It also offers multilingual data management, object relations, data classification, digital asset management (DAM), and data modeling supported by data inheritance. + +![Pimcore translations inheritance][4] + +#### Data management + +Pimcore enables efficient enterprise data management that focuses on ease of use; consistency in aggregation, organization, classification, and translation of product information; and sound data governance to enable optimization, flexibility, and scalability. + +![PIM batch change][5] + +#### Data quality + +Data quality management is the basis for analytics and business intelligence (BI). Pimcore supports data quality, completeness, and validation, and includes rich auditing and versioning features to help organizations meet revenue goals, compliance requirements, and productivity objectives. Pimcore also offers a configurable dashboard, custom reports capabilities, filtering, and export functionalities. + +![PIM data quality and completeness][6] + +#### Workflow management + +Pimcore's advanced workflow engine makes it easy to build and modify workflows to improve accuracy and productivity and reduce risks. Drop-downs enable enterprises to chalk out workflow paths to define business processes and editorial workflows with ease, and the customizable management and administration interface makes it easy to integrate workflows into an organization's application infrastructure. + +![Pimcore workflow management][7] + +#### Data consolidation + +Pimcore eliminates data silos by consolidating data in a central place and creating a single master data record or a single point of truth. It does this by gathering data lying in disparate systems spread across geographic locations, departments, applications, hard drives, vendors, suppliers, and more. By consolidating data, enterprises can get improved accuracy, reliability, and efficacy of information, lower cost of compliance, and decreased time-to-market. + +#### Synchronization across channels + +Pimcore's tools for gathering and managing digital data enable sellers to deliver it across any channel or device to reach individual customers on their preferred platforms. This helps enterprises enrich the user experience, leverage a single point of control to optimize performance, improve data governance, streamline product data lifecycle management, and boost productivity to reduce time-to-market and meet customers' expectations. + +### Installing, trying, and using Pimcore + +The best way to start exploring Pimcore is with a guided tour or demo; before you begin, make sure that you have the [system requirements][8] in place. + +#### Demo Pimcore + +Navigate to the [Pimcore demo][9] page and either register for a guided tour or click on one of the products in the "Try By Yourself" column for a self-guided demo. Enter the username **admin** and password **demo** to begin the demo. + +![Pimcore demo page][10] + +#### Download and install Pimcore + +If you want to take a deeper dive, you can [download Pimcore][11]; you can choose the data management or the experience management offering or both. You will need to enter your contact information and then immediately receive installation instructions. + +![Pimcore download interface][12] + +You can also choose from four installation packages: three are demo packages for beginners, and one is a skeleton for experienced developers. All contain: + + * Complete Pimcore platform + * Latest open source version + * Quick-start guide + * Demo data for getting started + + + +If you are installing Pimcore on a typical [LAMP][13] environment (which is recommended), see the [Pimcore installation guide][14]. If you're using another setup (e.g., Nginx), see the [installation, setup, and upgrade guide][15] for details. + +![Pimcore installation documentation][16] + +### Contribute to Pimcore + +As open source software, users are encouraged to engage with, [contribute][17] to, and fork Pimcore. For tracking bugs and features, as well as for software management, Pimcore relies exclusively on [GitHub][18], where contributions are assessed and carefully curated to uphold Pimcore's quality standards. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/pimcore-alternative-product-information-management + +作者:[Dietmar Rietsch][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/erinmcmahon +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/collab-team-pair-programming-code-keyboard.png?itok=kBeRTFL1 (Pair programming) +[2]: https://pimcore.com/en +[3]: https://github.com/pimcore/pimcore/blob/master/LICENSE.md +[4]: https://opensource.com/sites/default/files/uploads/pimcoretranslationinheritance.png (Pimcore translations inheritance) +[5]: https://opensource.com/sites/default/files/uploads/pimcorebatchchange.png (PIM batch change) +[6]: https://opensource.com/sites/default/files/uploads/pimcoredataquality.png (PIM data quality and completeness) +[7]: https://opensource.com/sites/default/files/pimcore-workflow-management.jpg (Pimcore workflow management) +[8]: https://pimcore.com/docs/5.x/Development_Documentation/Installation_and_Upgrade/System_Requirements.html +[9]: https://pimcore.com/en/try +[10]: https://opensource.com/sites/default/files/uploads/pimcoredemopage.png (Pimcore demo page) +[11]: https://pimcore.com/en/download +[12]: https://opensource.com/sites/default/files/uploads/pimcoredownload.png (Pimcore download interface) +[13]: https://en.wikipedia.org/wiki/LAMP_(software_bundle) +[14]: https://pimcore.com/docs/5.x/Development_Documentation/Getting_Started/Installation.html +[15]: https://pimcore.com/docs/5.x/Development_Documentation/Installation_and_Upgrade/index.html +[16]: https://opensource.com/sites/default/files/uploads/pimcoreinstall.png (Pimcore installation documentation) +[17]: https://github.com/pimcore/pimcore/blob/master/CONTRIBUTING.md +[18]: https://github.com/pimcore/pimcore diff --git a/sources/talk/20191106 How Much of a Genius-Level Move Was Using Binary Space Partitioning in Doom.md b/sources/talk/20191106 How Much of a Genius-Level Move Was Using Binary Space Partitioning in Doom.md new file mode 100644 index 0000000000..3bea7df831 --- /dev/null +++ b/sources/talk/20191106 How Much of a Genius-Level Move Was Using Binary Space Partitioning in Doom.md @@ -0,0 +1,173 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How Much of a Genius-Level Move Was Using Binary Space Partitioning in Doom?) +[#]: via: (https://twobithistory.org/2019/11/06/doom-bsp.html) +[#]: author: (Two-Bit History https://twobithistory.org) + +How Much of a Genius-Level Move Was Using Binary Space Partitioning in Doom? +====== + +In 1993, id Software released the first-person shooter _Doom_, which quickly became a phenomenon. The game is now considered one of the most influential games of all time. + +A decade after _Doom_’s release, in 2003, journalist David Kushner published a book about id Software called _Masters of Doom_, which has since become the canonical account of _Doom_’s creation. I read _Masters of Doom_ a few years ago and don’t remember much of it now, but there was one story in the book about lead programmer John Carmack that has stuck with me. This is a loose gloss of the story (see below for the full details), but essentially, early in the development of _Doom_, Carmack realized that the 3D renderer he had written for the game slowed to a crawl when trying to render certain levels. This was unacceptable, because _Doom_ was supposed to be action-packed and frenetic. So Carmack, realizing the problem with his renderer was fundamental enough that he would need to find a better rendering algorithm, starting reading research papers. He eventually implemented a technique called “binary space partitioning,” never before used in a video game, that dramatically sped up the _Doom_ engine. + +That story about Carmack applying cutting-edge academic research to video games has always impressed me. It is my explanation for why Carmack has become such a legendary figure. He deserves to be known as the archetypal genius video game programmer for all sorts of reasons, but this episode with the academic papers and the binary space partitioning is the justification I think of first. + +Obviously, the story is impressive because “binary space partitioning” sounds like it would be a difficult thing to just read about and implement yourself. I’ve long assumed that what Carmack did was a clever intellectual leap, but because I’ve never understood what binary space partitioning is or how novel a technique it was when Carmack decided to use it, I’ve never known for sure. On a spectrum from Homer Simpson to Albert Einstein, how much of a genius-level move was it really for Carmack to add binary space partitioning to _Doom_? + +I’ve also wondered where binary space partitioning first came from and how the idea found its way to Carmack. So this post is about John Carmack and _Doom_, but it is also about the history of a data structure: the binary space partitioning tree (or BSP tree). It turns out that the BSP tree, rather interestingly, and like so many things in computer science, has its origins in research conducted for the military. + +That’s right: E1M1, the first level of _Doom_, was brought to you by the US Air Force. + +### The VSD Problem + +The BSP tree is a solution to one of the thorniest problems in computer graphics. In order to render a three-dimensional scene, a renderer has to figure out, given a particular viewpoint, what can be seen and what cannot be seen. This is not especially challenging if you have lots of time, but a respectable real-time game engine needs to figure out what can be seen and what cannot be seen at least 30 times a second. + +This problem is sometimes called the problem of visible surface determination. Michael Abrash, a programmer who worked with Carmack on _Quake_ (id Software’s follow-up to _Doom_), wrote about the VSD problem in his famous _Graphics Programming Black Book_: + +> I want to talk about what is, in my opinion, the toughest 3-D problem of all: visible surface determination (drawing the proper surface at each pixel), and its close relative, culling (discarding non-visible polygons as quickly as possible, a way of accelerating visible surface determination). In the interests of brevity, I’ll use the abbreviation VSD to mean both visible surface determination and culling from now on. + +> Why do I think VSD is the toughest 3-D challenge? Although rasterization issues such as texture mapping are fascinating and important, they are tasks of relatively finite scope, and are being moved into hardware as 3-D accelerators appear; also, they only scale with increases in screen resolution, which are relatively modest. + +> In contrast, VSD is an open-ended problem, and there are dozens of approaches currently in use. Even more significantly, the performance of VSD, done in an unsophisticated fashion, scales directly with scene complexity, which tends to increase as a square or cube function, so this very rapidly becomes the limiting factor in rendering realistic worlds.[1][1] + +Abrash was writing about the difficulty of the VSD problem in the late ’90s, years after _Doom_ had proved that regular people wanted to be able to play graphically intensive games on their home computers. In the early ’90s, when id Software first began publishing games, the games had to be programmed to run efficiently on computers not designed to run them, computers meant for word processing, spreadsheet applications, and little else. To make this work, especially for the few 3D games that id Software published before _Doom_, id Software had to be creative. In these games, the design of all the levels was constrained in such a way that the VSD problem was easier to solve. + +For example, in _Wolfenstein 3D_, the game id Software released just prior to _Doom_, every level is made from walls that are axis-aligned. In other words, in the Wolfenstein universe, you can have north-south walls or west-east walls, but nothing else. Walls can also only be placed at fixed intervals on a grid—all hallways are either one grid square wide, or two grid squares wide, etc., but never 2.5 grid squares wide. Though this meant that the id Software team could only design levels that all looked somewhat the same, it made Carmack’s job of writing a renderer for _Wolfenstein_ much simpler. + +The _Wolfenstein_ renderer solved the VSD problem by “marching” rays into the virtual world from the screen. Usually a renderer that uses rays is a “raycasting” renderer—these renderers are often slow, because solving the VSD problem in a raycaster involves finding the first intersection between a ray and something in your world, which in the general case requires lots of number crunching. But in _Wolfenstein_, because all the walls are aligned with the grid, the only location a ray can possibly intersect a wall is at the grid lines. So all the renderer needs to do is check each of those intersection points. If the renderer starts by checking the intersection point nearest to the player’s viewpoint, then checks the next nearest, and so on, and stops when it encounters the first wall, the VSD problem has been solved in an almost trivial way. A ray is just marched forward from each pixel until it hits something, which works because the marching is so cheap in terms of CPU cycles. And actually, since all walls are the same height, it is only necessary to march a single ray for every _column_ of pixels. + +This rendering shortcut made _Wolfenstein_ fast enough to run on underpowered home PCs in the era before dedicated graphics cards. But this approach would not work for _Doom_, since the id team had decided that their new game would feature novel things like diagonal walls, stairs, and ceilings of different heights. Ray marching was no longer viable, so Carmack wrote a different kind of renderer. Whereas the _Wolfenstein_ renderer, with its ray for every column of pixels, is an “image-first” renderer, the _Doom_ renderer is an “object-first” renderer. This means that rather than iterating through the pixels on screen and figuring out what color they should be, the _Doom_ renderer iterates through the objects in a scene and projects each onto the screen in turn. + +In an object-first renderer, one easy way to solve the VSD problem is to use a z-buffer. Each time you project an object onto the screen, for each pixel you want to draw to, you do a check. If the part of the object you want to draw is closer to the player than what was already drawn to the pixel, then you can overwrite what is there. Otherwise you have to leave the pixel as is. This approach is simple, but a z-buffer requires a lot of memory, and the renderer may still expend a lot of CPU cycles projecting level geometry that is never going to be seen by the player. + +In the early 1990s, there was an additional drawback to the z-buffer approach: On IBM-compatible PCs, which used a video adapter system called VGA, writing to the output frame buffer was an expensive operation. So time spent drawing pixels that would only get overwritten later tanked the performance of your renderer. + +Since writing to the frame buffer was so expensive, the ideal renderer was one that started by drawing the objects closest to the player, then the objects just beyond those objects, and so on, until every pixel on screen had been written to. At that point the renderer would know to stop, saving all the time it might have spent considering far-away objects that the player cannot see. But ordering the objects in a scene this way, from closest to farthest, is tantamount to solving the VSD problem. Once again, the question is: What can be seen by the player? + +Initially, Carmack tried to solve this problem by relying on the layout of _Doom_’s levels. His renderer started by drawing the walls of the room currently occupied by the player, then flooded out into neighboring rooms to draw the walls in those rooms that could be seen from the current room. Provided that every room was convex, this solved the VSD issue. Rooms that were not convex could be split into convex “sectors.” You can see how this rendering technique might have looked if run at extra-slow speed [in this video][2], where YouTuber Bisqwit demonstrates a renderer of his own that works according to the same general algorithm. This algorithm was successfully used in Duke Nukem 3D, released three years after _Doom_, when CPUs were more powerful. But, in 1993, running on the hardware then available, the _Doom_ renderer that used this algorithm struggled with complicated levels—particularly when sectors were nested inside of each other, which was the only way to create something like a circular pit of stairs. A circular pit of stairs led to lots of repeated recursive descents into a sector that had already been drawn, strangling the game engine’s speed. + +Around the time that the id team realized that the _Doom_ game engine might be too slow, id Software was asked to port _Wolfenstein 3D_ to the Super Nintendo. The Super Nintendo was even less powerful than the IBM-compatible PCs of the day, and it turned out that the ray-marching _Wolfenstein_ renderer, simple as it was, didn’t run fast enough on the Super Nintendo hardware. So Carmack began looking for a better algorithm. It was actually for the Super Nintendo port of _Wolfenstein_ that Carmack first researched and implemented binary space partitioning. In _Wolfenstein_, this was relatively straightforward because all the walls were axis-aligned; in _Doom_, it would be more complex. But Carmack realized that BSP trees would solve _Doom_’s speed problems too. + +### Binary Space Partitioning + +Binary space partitioning makes the VSD problem easier to solve by splitting a 3D scene into parts ahead of time. For now, you just need to grasp why splitting a scene is useful: If you draw a line (really a plane in 3D) across your scene, and you know which side of the line the player or camera viewpoint is on, then you also know that nothing on the other side of the line can obstruct something on the viewpoint’s side of the line. If you repeat this process many times, you end up with a 3D scene split into many sections, which wouldn’t be an improvement on the original scene except now you know more about how different parts of the scene can obstruct each other. + +The first people to write about dividing a 3D scene like this were researchers trying to establish for the US Air Force whether computer graphics were sufficiently advanced to use in flight simulators. They released their findings in a 1969 report called “Study for Applying Computer-Generated Images to Visual Simulation.” The report concluded that computer graphics could be used to train pilots, but also warned that the implementation would be complicated by the VSD problem: + +> One of the most significant problems that must be faced in the real-time computation of images is the priority, or hidden-line, problem. In our everyday visual perception of our surroundings, it is a problem that nature solves with trivial east; a point of an opaque object obscures all other points that lie along the same line of sight and are more distant. In the computer, the task is formidable. The computations required to resolve priority in the general case grow exponentially with the complexity of the environment, and soon they surpass the computing load associated with finding the perspective images of the objects.[2][3] + +One solution these researchers mention, which according to them was earlier used in a project for NASA, is based on creating what I am going to call an “occlusion matrix.” The researchers point out that a plane dividing a scene in two can be used to resolve “any priority conflict” between objects on opposite sides of the plane. In general you might have to add these planes explicitly to your scene, but with certain kinds of geometry you can just rely on the faces of the objects you already have. They give the example in the figure below, where (p_1), (p_2), and (p_3) are the separating planes. If the camera viewpoint is on the forward or “true” side of one of these planes, then (p_i) evaluates to 1. The matrix shows the relationships between the three objects based on the three dividing planes and the location of the camera viewpoint—if object (a_i) obscures object (a_j), then entry (a_{ij}) in the matrix will be a 1. + +![][4] + +The researchers propose that this matrix could be implemented in hardware and re-evaluated every frame. Basically the matrix would act as a big switch or a kind of pre-built z-buffer. When drawing a given object, no video would be output for the parts of the object when a 1 exists in the object’s column and the corresponding row object is also being drawn. + +The major drawback with this matrix approach is that to represent a scene with (n) objects you need a matrix of size (n^2). So the researchers go on to explore whether it would be feasible to represent the occlusion matrix as a “priority list” instead, which would only be of size (n) and would establish an order in which objects should be drawn. They immediately note that for certain scenes like the one in the figure above no ordering can be made (since there is an occlusion cycle), so they spend a lot of time laying out the mathematical distinction between “proper” and “improper” scenes. Eventually they conclude that, at least for “proper” scenes—and it should be easy enough for a scene designer to avoid “improper” cases—a priority list could be generated. But they leave the list generation as an exercise for the reader. It seems the primary contribution of this 1969 study was to point out that it should be possible to use partitioning planes to order objects in a scene for rendering, at least _in theory_. + +It was not until 1980 that a paper, titled “On Visible Surface Generation by A Priori Tree Structures,” demonstrated a concrete algorithm to accomplish this. The 1980 paper, written by Henry Fuchs, Zvi Kedem, and Bruce Naylor, introduced the BSP tree. The authors say that their novel data structure is “an alternative solution to an approach first utilized a decade ago but due to a few difficulties, not widely exploited”—here referring to the approach taken in the 1969 Air Force study.[3][5] A BSP tree, once constructed, can easily be used to provide a priority ordering for objects in the scene. + +Fuchs, Kedem, and Naylor give a pretty readable explanation of how a BSP tree works, but let me see if I can provide a less formal but more concise one. + +You begin by picking one polygon in your scene and making the plane in which the polygon lies your partitioning plane. That one polygon also ends up as the root node in your tree. The remaining polygons in your scene will be on one side or the other of your root partitioning plane. The polygons on the “forward” side or in the “forward” half-space of your plane end in up in the left subtree of your root node, while the polygons on the “back” side or in the “back” half-space of your plane end up in the right subtree. You then repeat this process recursively, picking a polygon from your left and right subtrees to be the new partitioning planes for their respective half-spaces, which generates further half-spaces and further sub-trees. You stop when you run out of polygons. + +Say you want to render the geometry in your scene from back-to-front. (This is known as the “painter’s algorithm,” since it means that polygons further from the camera will get drawn over by polygons closer to the camera, producing a correct rendering.) To achieve this, all you have to do is an in-order traversal of the BSP tree, where the decision to render the left or right subtree of any node first is determined by whether the camera viewpoint is in either the forward or back half-space relative to the partitioning plane associated with the node. So at each node in the tree, you render all the polygons on the “far” side of the plane first, then the polygon in the partitioning plane, then all the polygons on the “near” side of the plane—”far” and “near” being relative to the camera viewpoint. This solves the VSD problem because, as we learned several paragraphs back, the polygons on the far side of the partitioning plane cannot obstruct anything on the near side. + +The following diagram shows the construction and traversal of a BSP tree representing a simple 2D scene. In 2D, the partitioning planes are instead partitioning lines, but the basic idea is the same in a more complicated 3D scene. + +![][6] _Step One: The root partitioning line along wall D splits the remaining geometry into two sets._ + +![][7] _Step Two: The half-spaces on either side of D are split again. Wall C is the only wall in its half-space so no split is needed. Wall B forms the new partitioning line in its half-space. Wall A must be split into two walls since it crosses the partitioning line._ + +![][8] _A back-to-front ordering of the walls relative to the viewpoint in the top-right corner, useful for implementing the painter’s algorithm. This is just an in-order traversal of the tree._ + +The really neat thing about a BSP tree, which Fuchs, Kedem, and Naylor stress several times, is that it only has to be constructed once. This is somewhat surprising, but the same BSP tree can be used to render a scene no matter where the camera viewpoint is. The BSP tree remains valid as long as the polygons in the scene don’t move. This is why the BSP tree is so useful for real-time rendering—all the hard work that goes into constructing the tree can be done beforehand rather than during rendering. + +One issue that Fuchs, Kedem, and Naylor say needs further exploration is the question of what makes a “good” BSP tree. The quality of your BSP tree will depend on which polygons you decide to use to establish your partitioning planes. I skipped over this earlier, but if you partition using a plane that intersects other polygons, then in order for the BSP algorithm to work, you have to split the intersected polygons in two, so that one part can go in one half-space and the other part in the other half-space. If this happens a lot, then building a BSP tree will dramatically increase the number of polygons in your scene. + +Bruce Naylor, one of the authors of the 1980 paper, would later write about this problem in his 1993 paper, “Constructing Good Partitioning Trees.” According to John Romero, one of Carmack’s fellow id Software co-founders, this paper was one of the papers that Carmack read when he was trying to implement BSP trees in _Doom_.[4][9] + +### BSP Trees in Doom + +Remember that, in his first draft of the _Doom_ renderer, Carmack had been trying to establish a rendering order for level geometry by “flooding” the renderer out from the player’s current room into neighboring rooms. BSP trees were a better way to establish this ordering because they avoided the issue where the renderer found itself visiting the same room (or sector) multiple times, wasting CPU cycles. + +“Adding BSP trees to _Doom_” meant, in practice, adding a BSP tree generator to the _Doom_ level editor. When a level in _Doom_ was complete, a BSP tree was generated from the level geometry. According to Fabien Sanglard, the generation process could take as long as eight seconds for a single level and 11 minutes for all the levels in the original _Doom_.[5][10] The generation process was lengthy in part because Carmack’s BSP generation algorithm tries to search for a “good” BSP tree using various heuristics. An eight-second delay would have been unforgivable at runtime, but it was not long to wait when done offline, especially considering the performance gains the BSP trees brought to the renderer. The generated BSP tree for a single level would have then ended up as part of the level data loaded into the game when it starts. + +Carmack put a spin on the BSP tree algorithm outlined in the 1980 paper, because once _Doom_ is started and the BSP tree for the current level is read into memory, the renderer uses the BSP tree to draw objects front-to-back rather than back-to-front. In the 1980 paper, Fuchs, Kedem, and Naylor show how a BSP tree can be used to implement the back-to-front painter’s algorithm, but the painter’s algorithm involves a lot of over-drawing that would have been expensive on an IBM-compatible PC. So the _Doom_ renderer instead starts with the geometry closer to the player, draws that first, then draws the geometry farther away. This reverse ordering is easy to achieve using a BSP tree, since you can just make the opposite traversal decision at each node in the tree. To ensure that the farther-away geometry is not drawn over the closer geometry, the _Doom_ renderer uses a kind of implicit z-buffer that provides much of the benefit of a z-buffer with a much smaller memory footprint. There is one array that keeps track of occlusion in the horizontal dimension, and another two arrays that keep track of occlusion in the vertical dimension from the top and bottom of the screen. The _Doom_ renderer can get away with not using an actual z-buffer because _Doom_ is not technically a fully 3D game. The cheaper data structures work because certain things never appear in _Doom_: The horizontal occlusion array works because there are no sloping walls, and the vertical occlusion arrays work because no walls have, say, two windows, one above the other. + +The only other tricky issue left is how to incorporate _Doom_’s moving characters into the static level geometry drawn with the aid of the BSP tree. The enemies in _Doom_ cannot be a part of the BSP tree because they move; the BSP tree only works for geometry that never moves. So the _Doom_ renderer draws the static level geometry first, keeping track of the segments of the screen that were drawn to (with yet another memory-efficient data structure). It then draws the enemies in back-to-front order, clipping them against the segments of the screen that occlude them. This process is not as optimal as rendering using the BSP tree, but because there are usually fewer enemies visible then there is level geometry in a level, speed isn’t as much of an issue here. + +Using BSP trees in _Doom_ was a major win. Obviously it is pretty neat that Carmack was able to figure out that BSP trees were the perfect solution to his problem. But was it a _genius_-level move? + +In his excellent book about the _Doom_ game engine, Fabien Sanglard quotes John Romero saying that Bruce Naylor’s paper, “Constructing Good Partitioning Trees,” was mostly about using BSP trees to cull backfaces from 3D models.[6][11] According to Romero, Carmack thought the algorithm could still be useful for _Doom_, so he went ahead and implemented it. This description is quite flattering to Carmack—it implies he saw that BSP trees could be useful for real-time video games when other people were still using the technique to render static scenes. There is a similarly flattering story in _Masters of Doom_: Kushner suggests that Carmack read Naylor’s paper and asked himself, “what if you could use a BSP to create not just one 3D image but an entire virtual world?”[7][12] + +This framing ignores the history of the BSP tree. When those US Air Force researchers first realized that partitioning a scene might help speed up rendering, they were interested in speeding up _real-time_ rendering, because they were, after all, trying to create a flight simulator. The flight simulator example comes up again in the 1980 BSP paper. Fuchs, Kedem, and Naylor talk about how a BSP tree would be useful in a flight simulator that pilots use to practice landing at the same airport over and over again. Since the airport geometry never changes, the BSP tree can be generated just once. Clearly what they have in mind is a real-time simulation. In the introduction to their paper, they even motivate their research by talking about how real-time graphics systems must be able to create an image in at least 1/30th of a second. + +So Carmack was not the first person to think of using BSP trees in a real-time graphics simulation. Of course, it’s one thing to anticipate that BSP trees might be used this way and another thing to actually do it. But even in the implementation Carmack may have had more guidance than is commonly assumed. The [Wikipedia page about BSP trees][13], at least as of this writing, suggests that Carmack consulted a 1991 paper by Chen and Gordon as well as a 1990 textbook called _Computer Graphics: Principles and Practice_. Though no citation is provided for this claim, it is probably true. The 1991 Chen and Gordon paper outlines a front-to-back rendering approach using BSP trees that is basically the same approach taken by _Doom_, right down to what I’ve called the “implicit z-buffer” data structure that prevents farther polygons being drawn over nearer polygons. The textbook provides a great overview of BSP trees and some pseudocode both for building a tree and for displaying one. (I’ve been able to skim through the 1990 edition thanks to my wonderful university library.) _Computer Graphics: Principles and Practice_ is a classic text in computer graphics, so Carmack might well have owned it. + +Still, Carmack found himself faced with a novel problem—”How can we make a first-person shooter run on a computer with a CPU that can’t even do floating-point operations?”—did his research, and proved that BSP trees are a useful data structure for real-time video games. I still think that is an impressive feat, even if the BSP tree had first been invented a decade prior and was pretty well theorized by the time Carmack read about it. Perhaps the accomplishment that we should really celebrate is the _Doom_ game engine as a whole, which is a seriously nifty piece of work. I’ve mentioned it once already, but Fabien Sanglard’s book about the _Doom_ game engine (_Game Engine Black Book: DOOM_) is an excellent overview of all the different clever components of the game engine and how they fit together. We shouldn’t forget that the VSD problem was just one of many problems that Carmack had to solve to make the _Doom_ engine work. That he was able, on top of everything else, to read about and implement a complicated data structure unknown to most programmers speaks volumes about his technical expertise and his drive to perfect his craft. + +_If you enjoyed this post, more like it come out every four weeks! Follow [@TwoBitHistory][14] on Twitter or subscribe to the [RSS feed][15] to make sure you know when a new post is out._ + +_Previously on TwoBitHistory…_ + +> I've wanted to learn more about GNU Readline for a while, so I thought I'd turn that into a new blog post. Includes a few fun facts from an email exchange with Chet Ramey, who maintains Readline (and Bash): +> +> — TwoBitHistory (@TwoBitHistory) [August 22, 2019][16] + + 1. Michael Abrash, “Michael Abrash’s Graphics Programming Black Book,” James Gregory, accessed November 6, 2019, . [↩︎][17] + + 2. R. Schumacher, B. Brand, M. Gilliland, W. Sharp, “Study for Applying Computer-Generated Images to Visual Simulation,” Air Force Human Resources Laboratory, December 1969, accessed on November 6, 2019, . [↩︎][18] + + 3. Henry Fuchs, Zvi Kedem, Bruce Naylor, “On Visible Surface Generation By A Priori Tree Structures,” ACM SIGGRAPH Computer Graphics, July 1980. [↩︎][19] + + 4. Fabien Sanglard, Game Engine Black Book: DOOM (CreateSpace Independent Publishing Platform, 2018), 200. [↩︎][20] + + 5. Sanglard, 206. [↩︎][21] + + 6. Sanglard, 200. [↩︎][22] + + 7. David Kushner, Masters of Doom (Random House Trade Paperbacks, 2004), 142. [↩︎][23] + + + + +-------------------------------------------------------------------------------- + +via: https://twobithistory.org/2019/11/06/doom-bsp.html + +作者:[Two-Bit History][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://twobithistory.org +[b]: https://github.com/lujun9972 +[1]: tmp.BANyYeM4Vm#fn:1 +[2]: https://youtu.be/HQYsFshbkYw?t=822 +[3]: tmp.BANyYeM4Vm#fn:2 +[4]: https://twobithistory.org/images/matrix_figure.png +[5]: tmp.BANyYeM4Vm#fn:3 +[6]: https://twobithistory.org/images/bsp.svg +[7]: https://twobithistory.org/images/bsp1.svg +[8]: https://twobithistory.org/images/bsp2.svg +[9]: tmp.BANyYeM4Vm#fn:4 +[10]: tmp.BANyYeM4Vm#fn:5 +[11]: tmp.BANyYeM4Vm#fn:6 +[12]: tmp.BANyYeM4Vm#fn:7 +[13]: https://en.wikipedia.org/wiki/Binary_space_partitioning +[14]: https://twitter.com/TwoBitHistory +[15]: https://twobithistory.org/feed.xml +[16]: https://twitter.com/TwoBitHistory/status/1164631020353859585?ref_src=twsrc%5Etfw +[17]: tmp.BANyYeM4Vm#fnref:1 +[18]: tmp.BANyYeM4Vm#fnref:2 +[19]: tmp.BANyYeM4Vm#fnref:3 +[20]: tmp.BANyYeM4Vm#fnref:4 +[21]: tmp.BANyYeM4Vm#fnref:5 +[22]: tmp.BANyYeM4Vm#fnref:6 +[23]: tmp.BANyYeM4Vm#fnref:7 diff --git a/sources/talk/20191106 My first contribution to open source- Make a fork of the repo.md b/sources/talk/20191106 My first contribution to open source- Make a fork of the repo.md new file mode 100644 index 0000000000..a19be04897 --- /dev/null +++ b/sources/talk/20191106 My first contribution to open source- Make a fork of the repo.md @@ -0,0 +1,50 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (My first contribution to open source: Make a fork of the repo) +[#]: via: (https://opensource.com/article/19/11/first-open-source-contribution-fork-clone) +[#]: author: (Galen Corey https://opensource.com/users/galenemco) + +My first contribution to open source: Make a fork of the repo +====== +Which comes first, to clone or fork a repo? +![User experience vs. design][1] + +Previously, I explained [how I ultimately chose a project][2] for my contributions. Once I finally picked that project and a task to work on, I felt like the hard part was over, and I slid into cruise control. I knew what to do next, no question. Just clone the repository so that I have the code on my computer, make a new branch for my work, and get coding, right? + +It turns out I made a crucial mistake at this step. Unfortunately, I didn’t realize that I had made a mistake until several hours later when I tried to push my completed code back up to GitHub and got a permission denied error. My third mistake was trying to work directly from a clone of the repo. + +When you want to contribute to someone else’s repo, in most cases, you should not clone the repo directly. Instead, you should make a fork of the repo and clone that. You do all of your work on a branch of your fork. Then, when you are ready to make a pull request, you can compare your branch on the fork against the master branch of the original repo. + +Before this, I had only ever worked on repos that I either created or had collaborator permissions for, so I could work directly from a clone of the main repo. I did not realize that GitHub even offered the capability to make a pull request from a repo fork onto the original repo. Now that I’ve learned a bit about this option, it is a great feature that makes sense. Forking allows a project to open the ability to contribute to anyone with a GitHub account without having to add them all as "contributors." It also helps keep the main project clean by keeping most new branches on forks, so that they don’t create clutter. + +I would have preferred to know this before I started writing my code (or, in this case, finished writing my code, since I didn’t attempt to push any of my changes to GitHub until the end). Moving my changes over from the main repo that I originally worked on into the fork was non-trivial. + +For those of you getting started, here are the steps to make a PR on a repository that you do not own, or where you are not a collaborator. I highly recommend trying to push your code to GitHub and at least going through the steps of creating a PR before you get too deep into coding, just to make sure you have everything set up the right way: + + 1. Make a fork of the repo you’ve chosen for your contributions. + 2. From the fork, click **Clone or download** to create a copy on your computer. +**Optional:** [Add the base repository as a remote "upstream,"][3] which is helpful if you want to pull down new changes from the base repository into your fork. + 3. [Create a pull request from the branch on your fork into the master branch of the base repository.][4] + + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/first-open-source-contribution-fork-clone + +作者:[Galen Corey][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/galenemco +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LIFE_DesirePath.png?itok=N_zLVWlK (User experience vs. design) +[2]: https://opensource.com/article/19/10/first-open-source-contribution-mistake-two +[3]: https://help.github.com/en/articles/configuring-a-remote-for-a-fork +[4]: https://help.github.com/en/articles/creating-a-pull-request-from-a-fork diff --git a/sources/talk/20191106 What it Takes to Be a Successful Network Engineer.md b/sources/talk/20191106 What it Takes to Be a Successful Network Engineer.md new file mode 100644 index 0000000000..dc79765c7d --- /dev/null +++ b/sources/talk/20191106 What it Takes to Be a Successful Network Engineer.md @@ -0,0 +1,78 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What it Takes to Be a Successful Network Engineer) +[#]: via: (https://opensourceforu.com/2019/11/what-it-takes-to-be-a-successful-network-engineer/) +[#]: author: (Christopher Nichols https://opensourceforu.com/author/christopher-nichols/) + +What it Takes to Be a Successful Network Engineer +====== + +[![][1]][2] + +_Network engineering is an excellent field filled with complex and fulfilling work, and many job opportunities. As companies end up with networks that continue to become more complex and connect more devices together, network engineers are in high-demand. Being successful in this role requires several characteristics and skill sets that serve employees well in this fast-paced and mission-critical environment._ + +**Deep Understanding of Networking Technologies** +Some people might think that this characteristic is assumed when it comes to network engineering. However, there’s a distinct difference between knowing enough about networking to manage and monitor the system, and having a truly in-depth understanding of the subject matter. The best network engineers eat, breathe, and drink this type of technology. They keep up on top of the latest trends during their free time and are thrilled to learn about new developments in the field. + +**Detail Oriented** +Networking has a lot of moving parts and various types of software and hardware to work with. Paying close attention to all of the details ensures that the system is being monitored correctly and nothing gets lost in the shuffle. When data breaches are prevalent in the business world, stopping an intrusion could mean identifying a small red flag that popped up the day before. Without being alert to these details, the network ends up being vulnerable. + +**Problem Solving** +One of the most used skills in network engineering is problem-solving. Everything from troubleshooting issues for users to look for ways to improve the performance of the network requires it. When a worker in this field can quickly and efficiently solve issues through an analytical mindset, they free up a lot of time for strategic decision-making. + +**Team Coordination** +Many organizations have teams collaborating together across departments. The network engineer role may be a small part of the team or put in a management position based on the resources required for the project. Working with multiple teams requires strong people management skills and understanding how to move towards a common goal. + +**Ongoing Education** +Many continued education opportunities exist for network engineering. Many organizations offer certifications in specific networking technologies, whether the person is learning about a particular server operating system or branching out into subject areas that are related to networking. A drive for ongoing education means that the network engineer will always have their skills updated to adapt to the latest technology changes in the marketplace. Additionally, when these workers love to learn, they also seek out self-instruction opportunities. For example, they could [_read this guide_][3] to learn more about how VPN protocols work. + +**Documentation** +Strong writing skills may not be the first characteristic that comes to mind when someone thinks about a network engineer. However, it’s essential when it comes to writing technical documentation. Well-structured and clear documentation allows the network engineer to share information about the network with other people in the organization. If that person ends up leaving the company, the networking protocols, procedures and configuration remain in place because all of the data is available and understandable. + +**Jargon-free Communication** +Network engineers have frequent conversations with stakeholders and end users, who may not have a strong IT background. The common jargon used for talking with other members of the IT teams would leave this group confused and not understanding what you’re saying. When the network engineer can explain technology in simple terms, it makes it easier to get the resources and budget that they need to effectively support the company’s networking needs. + +**Proactive Approaches** +Some network engineers rely on reactive approaches to fix problems when they occur. If data breaches aren’t prevented before they impact the organization, then it ends up being an expensive endeavor. A reactive approach is sometimes compared to running around and putting out fires the entire day. A proactive approach is more strategic. Network engineers put systems, policies and procedures in place that prevent the intrusion in the first place. They pick up on small issues and tackle them as soon as they show up, rather than waiting for something to break. It’s easier to improve network performance because many of the low-level problems are eliminated through the network design or other technology that was implemented. + +**Independent** +Network engineers often have to work on tasks without a lot of oversight. Depending on the company’s budget, they may be the only person in their role in the entire organization. Working independently requires the employee to be driven and a self-starter. They must be able to keep themselves on task and stick to the schedule that’s laid out for that particular project. In the event of a disaster, the network engineer may need to step into a leadership role to guide the recovery process. + +**Fast Learner** +Technology changes all the time, and the interactions between new hardware and software may not be expected. A fast learner can quickly pick up the most important details about a piece of technology so that they can effectively troubleshoot it or optimize it. + +**On-Call** +Disasters can strike a network at any time, and unexpected downtime is one of the worst things that can happen to a modern business. The mission-critical systems have to come up as soon as possible, which means that network engineers may need to take on-call shifts. One of the keys to being on-call is to be ready to act at a moment’s notice, even if it’s the middle of the night. + +**Reliability** +Few businesses can operate without their network being up and available. If critical software or hardware are not available, then the entire business may find itself at a standstill. Customers get upset that they can’t access the website or reach anyone in the company, employees are frustrated because they’re falling behind on their projects, and management is running around trying to get everything back up and running. As a network engineer, reliability is the key. Being available makes a big difference in resolving these types of problems, and always showing up on time and on schedule goes a long way towards cementing someone as a great network engineer. + +![Avatar][4] + +[Christopher Nichols][5] + +[![][6]][7] + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/what-it-takes-to-be-a-successful-network-engineer/ + +作者:[Christopher Nichols][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://opensourceforu.com/author/christopher-nichols/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2015/03/Network-cable-with-router.jpg?resize=696%2C372&ssl=1 (Network cable with router) +[2]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2015/03/Network-cable-with-router.jpg?fit=1329%2C710&ssl=1 +[3]: https://surfshark.com/learn/vpn-protocols +[4]: https://secure.gravatar.com/avatar/92e286970e06818292d5ce792b67a662?s=100&r=g +[5]: https://opensourceforu.com/author/christopher-nichols/ +[6]: http://opensourceforu.com/wp-content/uploads/2013/10/assoc.png +[7]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/sources/talk/20191107 My first open source contribution- Keep the code relevant.md b/sources/talk/20191107 My first open source contribution- Keep the code relevant.md new file mode 100644 index 0000000000..f435d2e10c --- /dev/null +++ b/sources/talk/20191107 My first open source contribution- Keep the code relevant.md @@ -0,0 +1,51 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (My first open source contribution: Keep the code relevant) +[#]: via: (https://opensource.com/article/19/11/first-open-source-contribution-relevant-code) +[#]: author: (Galen Corey https://opensource.com/users/galenemco) + +My first open source contribution: Keep the code relevant +====== +Be aware of what development tools you have running in the background. +![Filing cabinet for organization][1] + +Previously, I explained [the importance of forking repositories][2]. Once I finished the actual "writing the code" part of making my first open source pull request, I felt excellent. It seemed like the hard part was finally over. What’s more, I felt great about the code that I wrote. + +One thing that I decided to do (which turned out to be an excellent choice) was to use [test-driven development][3] (TDD) to write the code. Using TDD was helpful because it gave me a place to start, and a way to know if what I was doing actually worked. Because my background was in building web apps, I rarely ran into the problem of writing code that didn’t have a tangible, visible output. The test-first approach helped me make the leap into working on a tool where you can’t evaluate your progress manually. The fact that I had written a clear test also helped me ultimately get my pull request accepted. The reviewer highlighted the test in his comments on my code. + +Another thing I felt great about was that I had accomplished the whole thing in around 20 lines of code. I know from experience that shorter pull requests are much easier to review. Such short pieces generally take less time, and the reviewer can concentrate on only the small number of lines that were changed. I hoped that this would increase my chances that one of the maintainers would look at my work and feel confident in it. + +Much to my surprise, when I finally pushed my branch to GitHub, the diff was showing that I had changed multiple lines of code. I ran into trouble here because I had become too comfortable with my usual development setup. Because I typically work on a single project, I barely think about some of the tools I have working in the background to make my life easier. The culprit here was [`prettier`][4], a code formatter that automatically fixes all of my minor spacing and syntax discrepancies when I save an edited file. In my usual workflow, this tool is extremely helpful. Most of the developers I work with have `prettier` installed, so all of the code that we write obeys the same style rules. + +In this new project, however, style rules had fallen by the wayside. The project did, in fact, contain an eslint config stating that single quotes should be used instead of double-quotes. However, the developers who were contributing to the project ignored this rule and used both single- and double-quotes. Unlike human beings, `prettier` never ignores the rules. While I was working, it took the initiative to turn every double quote in every file I changed to a single quote, causing hundreds of unintentional changes. + +I tried for a few minutes to remove these changes, but because they had been continually happening as I worked, they were embedded in all of my commits. Then the type-B in me took over and decided to leave the changes in. "Maybe this is not a big deal," I thought. "They said they wanted single quotes, after all." + +My mistake was including these unrelated changes in my PR. While I was technically right that this wasn’t a "big deal," the maintainer who reviewed my code asked me to revert the changes. My initial instinct, that keeping my pull request small and to the point, was correct. + +The lesson here is that you should keep your changes as minimal and to-the-point as possible. Be mindful of any tools you have that might apply to your normal workflow, but aren’t as useful if you are working on a new project. + +**Free idea:** If you are looking for a way to get an open source PR in without writing any code, pick a project that doesn’t adhere to its style guide, run `prettier` on it, and make the result your whole pull request. It’s not guaranteed that every project community will appreciate this, but it’s worth a shot. + +There are lots of non-code ways to contribute to open source: Here are three alternatives. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/first-open-source-contribution-relevant-code + +作者:[Galen Corey][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/galenemco +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/files_documents_organize_letter.png?itok=GTtiiabr (Filing cabinet for organization) +[2]: https://opensource.com/article/19/10/first-open-source-contribution-fork-clone +[3]: https://opensource.com/article/19/10/test-driven-development-best-practices +[4]: https://prettier.io/ diff --git a/sources/talk/20191108 My Linux story- Learning Linux in the 90s.md b/sources/talk/20191108 My Linux story- Learning Linux in the 90s.md new file mode 100644 index 0000000000..ae9bb5c230 --- /dev/null +++ b/sources/talk/20191108 My Linux story- Learning Linux in the 90s.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (My Linux story: Learning Linux in the 90s) +[#]: via: (https://opensource.com/article/19/11/learning-linux-90s) +[#]: author: (Mike Harris https://opensource.com/users/mharris) + +My Linux story: Learning Linux in the 90s +====== +This is the story of how I learned Linux before the age of WiFi, when +distributions came in the form of a CD. +![Sky with clouds and grass][1] + +Most people probably don't remember where they, the computing industry, or the everyday world were in 1996. But I remember that year very clearly. I was a sophomore in high school in the middle of Kansas, and it was the start of my journey into free and open source software (FOSS). + +I'm getting ahead of myself here. I was interested in computers even before 1996. I was born and raised on my family's first Apple ][e, followed many years later by the IBM Personal System/2. (Yes, there were definitely some generational skips along the way.) The IBM PS/2 had a very exciting feature: a 1200 baud Hayes modem. + +I don't remember how, but early on, I got the phone number of a local [BBS][2]. Once I dialed into it, I could get a list of other BBSes in the local area, and my adventure into networked computing began. + +In 1995, the people [lucky enough][3] to have a home internet connection spent less than 30 minutes a month using it. That internet was nothing like our modern services that operate over satellite, fiber, CATV coax, or any version of copper lines. Most homes dialed in with a modem, which tied up their phone line. (This was also long before cellphones were pervasive, and most people had just one home phone line.) I don't think there were many independent internet service providers (ISPs) back then, although that may have depended upon where you were located, so most people got service from a handful of big names, including America Online, CompuServe, and Prodigy. + +And the service you did get was very slow; even at dial-up's peak evolution at 56K, you could only expect to get a maximum of about 3.5 Kbps. If you wanted to try Linux, downloading a 200MB to 800MB ISO image or (more realistically) a disk image set was a dedication to time, determination, and lack of phone usage. + +I went with the easier route: In 1996, I ordered a "tri-Linux" CD set from a major Linux distributor. These tri-Linux disks provided three distributions; mine included Debian 1.1 (the first stable release of Debian), Red Hat Linux 3.0.3, and Slackware 3.1 (nicknamed Slackware '96). As I recall, the discs were purchased from an online store called [Linux Systems Labs][4]. The online store doesn't exist now, but in the 90s and early 00s, such distributors were common. And so were multi-disc sets of Linux. This one's from 1998 but gives you an idea of what they involved: + +![A tri-linux CD set][5] + +![A tri-linux CD set][6] + +On a fateful day in the summer of 1996, while living in a new and relatively rural city in Kansas, I made my first attempt at installing and working with Linux. Throughout the summer of '96, I tried all three distributions on that tri-Linux CD set. They all ran beautifully on my mom's older Pentium 75MHz computer. + +I ended up choosing [Slackware][7] 3.1 as my preferred distribution, probably more because of the terminal's appearance than the other, more important reasons one should consider before deciding on a distribution. + +I was up and running. I was connecting to an "off-brand" ISP (a local provider in the area), dialing in on my family's second phone line (ordered to accommodate all my internet use). I was in heaven. I had a dual-boot (Microsoft Windows 95 and Slackware 3.1) computer that worked wonderfully. I was still dialing into the BBSes that I knew and loved and playing online BBS games like Trade Wars, Usurper, and Legend of the Red Dragon. + +I can remember spending days upon days of time in #Linux on EFNet (IRC), helping other users answer their Linux questions and interacting with the moderation crew. + +More than 20 years after taking my first swing at using the Linux OS at home, I am now entering my fifth year as a consultant for Red Hat, still using Linux (now Fedora) as my daily driver, and still on IRC helping people looking to use Linux. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/learning-linux-90s + +作者:[Mike Harris][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/mharris +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus-cloud.png?itok=vz0PIDDS (Sky with clouds and grass) +[2]: https://en.wikipedia.org/wiki/Bulletin_board_system +[3]: https://en.wikipedia.org/wiki/Global_Internet_usage#Internet_users +[4]: https://web.archive.org/web/19961221003003/http://lsl.com/ +[5]: https://opensource.com/sites/default/files/20191026_142009.jpg (A tri-linux CD set) +[6]: https://opensource.com/sites/default/files/20191026_142020.jpg (A tri-linux CD set) +[7]: http://slackware.com diff --git a/sources/talk/20191108 My first open source contribution- Talk about your pull request.md b/sources/talk/20191108 My first open source contribution- Talk about your pull request.md new file mode 100644 index 0000000000..04e78e7b39 --- /dev/null +++ b/sources/talk/20191108 My first open source contribution- Talk about your pull request.md @@ -0,0 +1,45 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (My first open source contribution: Talk about your pull request) +[#]: via: (https://opensource.com/article/19/11/first-open-source-contribution-communicate-pull-request) +[#]: author: (Galen Corey https://opensource.com/users/galenemco) + +My first open source contribution: Talk about your pull request +====== +I finally heard back from the project and my code was merged. +![speech bubble that says tell me more][1] + +Previously, I wrote about [keeping your code relevant][2] when making a contribution to an open source project. Now, you finally click **Create pull request**. You're elated, you're done. + +At first, I didn’t even care whether my code would get merged or not. I had done my part. I knew I could do it. The future lit up with the many future pull requests that I would make to open source projects. + +But of course, I did want my code to become a part of my chosen project, and soon I found myself googling, "How long does it take for an open source pull request to get merged?" The results weren’t especially conclusive. Due to the nature of open source (the fact that anyone can participate in it), processes for maintaining projects vary widely. But I found a tweet somewhere that confidently said: "If you don’t hear back in two months, you should reach out to the maintainers." + +Well, two months came and went, and I heard nothing. I also did not reach out to the maintainers, since talking to people and asking them to critique your work is scary. But I wasn’t overly concerned. I told myself that two months was probably an average, so I put it in the back of my mind. + +At four months, there was still no response. I opted for the passive approach again. I decided not to try to get in touch with the maintainers, but my reasoning this time was more negative. I started to wonder if some of my earlier assumptions about how actively maintained the project was were wrong—maybe no one was keeping up with incoming pull requests. Or maybe they didn’t look at pull requests from random people. I put the issue in the back of my mind again, this time with less hope of ever seeing a result. + +I had nearly given up hope entirely and forgotten about the whole thing when, six months after I made my original pull request, I finally heard back. After making a few small changes that they requested, my code was approved and merged. My fifth mistake was giving up on my contribution when I did not hear back and failing to be communicative about my work. + +Don’t be afraid to communicate about your pull request. Doing so could mean something as simple as adding a comment to your issue that says, “Hey, I’m working on this!" And don’t give up hope just because you don’t get a response for a while. The amount of time that it takes will vary based on who is maintaining the project and how much time they have to devote to maintaining it. + +This story has a happy ending. My code was merged. I hope that by sharing some parts of the experience that tripped me up on my first open source journey, I can smooth the path for some of you who want to explore open source for the first time. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/first-open-source-contribution-communicate-pull-request + +作者:[Galen Corey][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/galenemco +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSCD_MPL3_520x292_FINAL.png?itok=cp6TbjVI (speech bubble that says tell me more) +[2]: https://opensource.com/article/19/10/my-first-open-source-contribution-relevant-code diff --git a/sources/talk/20191110 How universities are using open source to attract students.md b/sources/talk/20191110 How universities are using open source to attract students.md new file mode 100644 index 0000000000..466ec93c9f --- /dev/null +++ b/sources/talk/20191110 How universities are using open source to attract students.md @@ -0,0 +1,209 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How universities are using open source to attract students) +[#]: via: (https://opensource.com/article/19/11/open-source-universities) +[#]: author: (Joshua Pearce https://opensource.com/users/jmpearce) + +How universities are using open source to attract students +====== +Many universities have begun new initiatives to attract students that +are excited about technical freedom and open source. +![Open education][1] + +Michigan Tech just launched [opensource.mtu.edu][2], a virtual one-stop free shop for all things open source on campus. According to their site, _[Tech Today][3]_: + +> "With the [majority of big companies now contributing to open source projects][4] it is clearly a major trend. [All [major] supercomputers][5] (including our own supercomputer: [Superior][6]), 90% of cloud servers, 82% of smartphones, and 62% of embedded systems run on open source operating systems. More than 70% of ‘internet of things’ devices also use open source software. 90% of the Fortune Global 500 pay for the open source Linux operating system from Red Hat, a company that makes billions of dollars a year for the service they provide on top of the product that can be downloaded for free." + +The publication also says that "the open source hardware movement is [roughly 15 years][7] behind its software counterpart," but it appears to be catching up quickly. Given their mandate to "attract students that are excited about technical freedom and open source," many universities have started a new front in the battle for educational supremacy. + +Unlike conventional warfare, this is a battle that benefits the public. The more universities share using the open source paradigm, the faster technology moves forward with all of its concomitant benefits. The resources available through [opensource.mtu.edu][2] include: + + * [Thousands of free and open access articles in their Digital Commons][8]. + * Free data, including housing the [Free Inactive Patent Search][9], a tool to help find inactive patents that have fallen into the public domain. + * Free open source courses like [FOSS101][10]: Essentials of Free and Open Source Software, which teaches Linux commands and the Git revision control system, or [Open source 3D printing][11], which teaches OpenSCAD, FreeCAD, Blender, Arduino, and RepRap 3D printing. + * Student organizations like the [Open Source Hardware Enterprise][12], which is dedicated to the development and availability of open source hardware, and the [Open Source Club][13], which develops open source software. + * Free software, including the [Astrophysics Source Code Library (ASCL)][14] open repository, which now lists over 2,000 codes and the [Psychology Experiment Building Language (PEBL)][15] software for psychological testing used in laboratories and by clinicians around the world. + * Free hardware, including hundreds of digitally manufactured designs and dozens of complex machines for everything from [plastic recycling systems][16] to [open source lab equipment][17]. + + + +Michigan Tech is hardly alone with major initiatives across a broad swath of academia. Open access databases like [Academia][18], [OSF preprints][19], [ResearchGate][20], [PrePrints][21], and [Science Open][22] swell with millions of free, open access, peer-reviewed articles. The Center for Open Science supports the [Open Science Framework][23], which is a "free and open source project management tool that supports researchers throughout their entire project" lifecycle, including storing Gigabytes of data: + +![Open Source Framework \(OSF\) workflow.][24] + +_Source: [OSF][25]_ + +You can choose from a wide variety of course options at other institutions as well, and are generally able to take these courses at your own pace: + + * Rochester Institute of Technology students can [earn a minor in free and open source software][26] and free culture. + * Many of the world’s most renowned colleges and universities offer free courses to self-learners through [OpenCourseWare (OCW)][27]. None of the courses offered through OCW award credit, though. For that, you need to pay. + * Schools like [MIT][28], the University of Notre Dame, Yale, Carnegie Mellon, Delft, Stanford, Johns Hopkins, University of California Berkeley and the Open University (among many more) offer free academic content, such as syllabi, lecture notes, assignments, and examinations. + + + +Many universities also contribute to free and open source software (FOSS) and free and open source hardware (FOSH). In fact, many universities—including American International University West Africa, Brandeis University, Indiana University, and the University of Southern Queensland—are [Open Source Initiative (OSI) Affiliates][29]. The University of Texas even has [formal policies][30] in place for contributing to open source. + +### Universities using open source in higher education + +In addition, the vast majority of universities use FOSS. [PortalProgramas][31] ranked Tufts University as the top higher education user of FOSS. Even more representative is [Apereo][32], which is a network of universities actively supporting the use of open source in higher education. This network includes a long list of [member institutions][33]: + + * American Public University System   + * Beijing Open-mindness Technology Co., Ltd.   + * Blindside Networks   + * Boston University Questrom School of Business   + * Brigham Young University   + * Brock University   + * Brown University   + * California Community Colleges Technology Center + * California State University, Sacramento   + * Cirrus Identity   + * Claremont Colleges   + * Clark County School District   + * Duke University   + * Edalex   + * Educational Service Unit Coordinating Council   + * ELAN e.V.   + * Entornos de Formación S.L (EDF)   + * ETH Zürich   + * Gert Sibande TVET College   + * HEC Montreal   + * Hosei University   + * Hotelschool the Hague   + * IlliniCloud   + * Instructional Media & Magic   + * JISC   + * Kyoto University   + * LAMP + * Learning Experiences   + * Longsight. Inc.   + * MPL, Ltda.   + * Nagoya University   + * New York University   + * North-West University   + * Oakland University   + * OPENCOLLAB + * Oxford University   + * Pepperdine University   + * Princeton University   + * Rice University   + * Roger Williams University   + * Rutgers University   + * Sinclair Community College   + * SWITCH   + * Texas State University, San Marcos   + * Unicon   + * Universidad Politecnica de Valencia   + * Universidad Publica de Navarra   + * Universitat de Lleida   + * Universite de Rennes 1   + * Universite de Valenciennes   + * University of Amsterdam   + * University of California, Berkeley   + * University of Cape Town   + * University of Edinburgh   + * University of Illinois   + * University of Kansas   + * University of Manchester   + * University of Michigan   + * University of North Carolina, Chapel Hill   + * University of Notre Dame   + * University of South Africa UNISA   + * University of Virginia   + * University of Wisconsin-Madison   + * University of Witwatersrand   + * Western University   + * Whitman College +  + + + +Another popular organization is [Kuali][34], which is a nonprofit that produces open source administrative software for higher education institutions. Their members include: + + * Boston University + * California State University, Office of the Chancellor + * Colorado State University + * Cornell University + * Drexel University + * Indiana University + * Marist College + * Massachusetts Institute of Technology + * Michigan State University + * North-West University, South Africa + * Research Foundation of The City University of New York + * Stevens Institute of Technology + * Strathmore University + * Tufts University + * University Corporation for Atmospheric Research + * Universidad del Sagrado Corazon + * University of Arizona + * University of California, Davis + * University of California, Irvine + * University of Connecticut + * University of Hawaii + * University of Illinois + * University of Maryland, Baltimore + * University of Maryland, College Park + * University of Toronto + * West Virginia University + + + +Didn't see your favorite university on the list? If that school has been involved in open source, please leave a comment below telling me what your school is doing in open source. If you want to see your favorite school on the list and they aren't doing much in open source, you can encourage them by sending a letter asking the program heads to: + + * Institutionalize sharing their research open access in their own Digital Commons and/or use one of the many free repositories. + * Share research data on the Open Science Framework. + * Provide OCW and/or offer courses and programs specifically focused on open source. + * Start and/or expand their use of FOSS and FOSH on campus, and/or join or . + + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/open-source-universities + +作者:[Joshua Pearce][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/jmpearce +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_OER_520x292_FINAL.png?itok=DBCJ4H1s (Open education) +[2]: https://opensource.mtu.edu/ +[3]: https://www.mtu.edu/ttoday/?issue=20191022 +[4]: https://opensource.com/business/16/5/2016-future-open-source-survey +[5]: https://www.zdnet.com/article/supercomputers-all-linux-all-the-time/ +[6]: https://hpc.mtu.edu/ +[7]: https://www.mdpi.com/2411-5134/3/3/44 +[8]: https://digitalcommons.mtu.edu/ +[9]: https://opensource.com/article/17/1/making-us-patent-system-useful-again +[10]: https://mtu.instructure.com/courses/1147020 +[11]: https://opensource.com/article/19/2/3d-printing-course +[12]: http://openhardware.eit.mtu.edu/ +[13]: http://mtuopensource.club/ +[14]: https://ascl.net/ +[15]: http://pebl.sourceforge.net/ +[16]: https://www.appropedia.org/Recyclebot +[17]: https://www.appropedia.org/Open-source_Lab +[18]: https://www.academia.edu/ +[19]: https://cos.io/our-products/osf-preprints/ +[20]: https://www.researchgate.net/ +[21]: https://www.preprints.org/ +[22]: https://www.scienceopen.com/ +[23]: https://osf.io/ +[24]: https://opensource.com/sites/default/files/uploads/osf_workflow_-_hero.original600_copy_0.png +[25]: https://cdn.cos.io/media/images/OSF_workflow_-_hero.original.png +[26]: http://www.rit.edu/news/story.php?id=50590 +[27]: https://learn.org/articles/25_Colleges_and_Universities_Ranked_by_Their_OpenCourseWare.html +[28]: https://ocw.mit.edu/index.htm +[29]: https://opensource.org/affiliates +[30]: https://it.utexas.edu/policies/releasing-software-open-source +[31]: http://www.portalprogramas.com/en/open-source-universities-ranking/about +[32]: https://www.apereo.org/ +[33]: https://www.apereo.org/content/apereo-member-organizations +[34]: https://www.kuali.org/ diff --git a/sources/talk/20191111 Best Tools-Latest Tools to Use in Programming.md b/sources/talk/20191111 Best Tools-Latest Tools to Use in Programming.md new file mode 100644 index 0000000000..0e62c22619 --- /dev/null +++ b/sources/talk/20191111 Best Tools-Latest Tools to Use in Programming.md @@ -0,0 +1,85 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Best Tools/Latest Tools to Use in Programming) +[#]: via: (https://opensourceforu.com/2019/11/best-tools-latest-tools-to-use-in-programming/) +[#]: author: (Daniil Balabushkin https://opensourceforu.com/author/daniil-balabushkin/) + +Best Tools/Latest Tools to Use in Programming +====== + +[![computer programming][1]][2] + +_[Programming languages][3] can be termed as the process in which a person called a programmer writes computer programs. It can also be defined as a set of instructions to facilitate specific actions. A computer understands this language and translates it into a form that can be read or understood by the human eye. It is divided into generations that are from the first generation to the fifth-generation programming languages._ + +There are four types of programming languages: + + * Python + * C + * C++ + * Java + + + +Programming has helped a-lot in the development of new and diverse computational languages. + +**Computer Programming Uses in the Society and the World at Large** + +And these uses include: + + * Computer programming helps in developing programming languages that are used for transforming computing problems into instructions. This allows programmers to build source codes much quicker. + * Programming languages have supported the development of the internet, which has brought people closer and made the world one. + * Programming is one of the main stages of the software development process. Software development involves several steps, including programming, testing, bug fixing documenting, etc. A programmer has to know all the stages and also a specialized knowledge about one particular field. + * Programming helps students to understand how to solve computing problems. As you develop more and more programs, your confidence level rises and boosts your educational exposure on programming. + * As innovations come up, programmers are forced to cope up with these new technologies. Because technology is being used all over the world, clients need and want more natural ways to use technology. Programmers have been tasked with developing new ways of building software that can be used in the technology market to make it easier for these innovations to be used by people. + + + +The rise of a more technological world has immensely influenced programming through the following ways: + +**Internet** +The internet has been built on programming languages that the computer understands and in turn, creates a worldwide link through an informal network, e.g., Google, Wikipedia, and [_paper writing service_][4] companies. As the world and technology rise, it leads to the consumer wanting more straightforward means to get information and also a fast means of networking hence better services are leading to the high demand for assistance from the programmers. + +**Employment** +Due to a rise in technology, programmers are on high demand for their services, and this leads to the need for well-trained and learned programming technicians due to the high demand for programs and applications by the consumer. This, in turn, builds and uplifts the programming sector. + +**Socialization** +In the past, people only made calls and sent messages. These were older ways of programming to convey information. But due to a rise in the technological industry, people have come up with ideas like WhatsApp, Twitter, and Facebook. These applications need programmers for them to fix, create, and debug the programs, and this leads to better and new communication services from the specified uses. Due to the rise in technology and social needs, programmers have achieved better employment opportunities and made programming an essential requirement in the technological world. + +**Transport industry** +By this, I mean cars of the future, trains of the future, and even airlines of the future. Companies like Tesla have taken programming to the next level. From vehicles that speak to you to cars that can drive by themselves, to name but a few. For that to be achieved, you need a programmer to create a primary interface and language that will link the car to the software and in turn, give feedback to the system. Without programmers, this would not be possible. The rise in the transport industry has been influenced tremendously by programming and technological advancements. + +**Author’s Note** +_[Programming][5] and the rise in technology go hand in hand. The more technology grows, the more the need to have programmers in the market._ +_Every discovery in the technology industry needs an application or program, thus leading to the boom in the programming and coding sector._ + +![Avatar][6] + +[Daniil Balabushkin][7] + +[![][8]][9] + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/best-tools-latest-tools-to-use-in-programming/ + +作者:[Daniil Balabushkin][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://opensourceforu.com/author/daniil-balabushkin/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2016/06/computer-programming.jpg?resize=696%2C441&ssl=1 (computer programming) +[2]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2016/06/computer-programming.jpg?fit=700%2C444&ssl=1 +[3]: https://www.softwaretestinghelp.com/software-development-tools/ +[4]: https://expert-writers.net/ +[5]: https://www.computerscience.org/resources/computer-programming-languages/ +[6]: https://secure.gravatar.com/avatar/5f72f6534155d49b49e0f0b9eab2e7be?s=100&r=g +[7]: https://opensourceforu.com/author/daniil-balabushkin/ +[8]: https://opensourceforu.com/wp-content/uploads/2019/11/assoc.png +[9]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/sources/talk/20191112 Migrating to SD-WAN- Avoid these Pitfalls, Say IT Leaders.md b/sources/talk/20191112 Migrating to SD-WAN- Avoid these Pitfalls, Say IT Leaders.md new file mode 100644 index 0000000000..e292bdc712 --- /dev/null +++ b/sources/talk/20191112 Migrating to SD-WAN- Avoid these Pitfalls, Say IT Leaders.md @@ -0,0 +1,93 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Migrating to SD-WAN? Avoid these Pitfalls, Say IT Leaders) +[#]: via: (https://www.networkworld.com/article/3453198/migrating-to-sd-wan-avoid-these-pitfalls-say-it-leaders.html) +[#]: author: (Cato Networks https://www.networkworld.com/author/Matt-Conran/) + +Migrating to SD-WAN? Avoid these Pitfalls, Say IT Leaders +====== +Every network migration has its hidden challenges. Here are practical tips from IT pros who've already made the switch to SD-WAN +phototechno + +Whether you’re switching from MPLS or Internet VPNs, [SD-WAN][1] can jumpstart network performance, agility, and scalability, particularly for cloud applications. However, as with any migration, there can be challenges and surprises. Don’t squash productivity with unplanned outages or security breaches. Plan your migration carefully, ask the right questions, and cover your bases. Here are some key pitfalls to avoid from those who’ve been there. + +### Security Should Work with Your SD-WAN + +If you’re used to backhauling cloud traffic through data-center security via MPLS, you’re bound to see a big boost in branch office cloud performance using direct Internet access. However, bypassing data-center security means you must find a way to deliver the same level of security at the branch-office level or risk a data breach. Last year, enterprises with completed SD-WAN deployments were 1.3 times more likely to experience a branch-office security breach than without, Shamus McGillicudy, Research Director at analyst firm Enterprise Management Associates reported on a [recent webinar][2]. + +In most cases, you’ll need a full suite of security functions at each location, including next-generation firewalls, IPS, malware protection, a secure Web gateway, and a cloud security broker. Andrew Thomson, director of IT systems and services at [BioIVT, a provider of biological products to life sciences and pharmaceutical firms,][3] found out just how much work securing the branch office could be when he was looking at telco SD-WAN solutions. + +“Updating our security architecture was going to require running to different vendors, piecing together a solution, and going through all the deployment and management pains,” says Thomson. A simpler option may be to move traffic inspection and security policy enforcement into the cloud. + +### Size Appliances with Room to Grow + +Costs may be lowering when comparing [SD-WAN vs. MPLS][4], but that initial SD-WAN appliance purchase can be daunting, especially when you add on all the security functions you need to integrate and deploy. Don’t let the cost scare you into skimping on sizing, especially if you’re a growing business. Your branch offices will likely grow, which means more tunnels, features, and bandwidth. Even if they don’t, WAN usage tends to grow with digital transformation and new applications and cloud services + +A good rule of thumb is to price another 20% capacity beyond what you think you need today and compare that cost to the cost of upgrading or replacing your appliance in three years. You may want to spring for that capacity now. + +### Plan for High Availability + +If your business depends on network uptime, you’d better have a solid plan in place for high availability. This means two SD-WAN appliances with failover capabilities at each location AND dual homing with more than one ISP across diversely routed connections for that precious last mile. (Since it’s often hard to be sure last-mile providers don’t share the same underlying infrastructure, it's even better to use LTE with terrestrial connections.) When you’re planning your SD-WAN budget, make sure to account for the licensing fees for those additional backup appliances. + +[Salcomp, a manufacturer of adapters for mobile phone companies][5], had to rely on backup local Internet connections to compensate for the erratic connectivity of its MPLS provider’s global last mile connectivity partners. + +“In Brazil we had a problem with an MPLS circuit, and the office was out for six months,” says Ville Sarja, CIO and Group Security Officer. “Luckily we had Internet redundancy, so we were able to direct traffic to the Internet, and bandwidth and connectivity were good enough.” + +### Test Your Application Performance + +Make sure your evaluation includes testing your data-center and cloud applications at different times of the day to ensure they perform as expected under various loads and conditions. If you’re a global organization, make sure you test those applications globally at different times as well. As pointed out in the eBook, [The Internet is Broken][6], global connectivity often depends more on service provider commercial peering relationships than actual best path selection or network congestion. This means that packets may travel across longer distances and more hops than they should, with unnecessarily high latency as a result. + +For its SD-WAN evaluation, Salcomp tested SharePoint file transfers and sharing, SAP user experience, and Office 365 performance from its Finland data-center locations across China, Taiwan, and India. By switching from MPLS to a global private backbone, Salcomp was able to reduce costs and improve application performance. + +“Users just aren’t complaining anymore,” says Sarja, “And that’s a very good thing.”  + +### Make Some Changes and See How Long It Takes + +Okay, your SD-WAN seems to be performing, but what about your SD-WAN provider? Are they responsive and competent when you need to make a change or troubleshoot a problem? The only way to find out is to test them as well. Your provider should be able to tell you what its timetable is for every type of change, whether it’s QOS or something else. Ask. Then include a set of predefined changes during the evaluation phase and see if your provider comes through. + +[Fisher & Company][7], parent of a precision metal parts company, was glad it tested changes with its chosen SD-WAN provider. + +“We trialed a telco-managed SD-WAN service, but the provider was difficult to work with,” says Systems Manager Kevin McDaid. “They wanted us to submit requests for configuration changes; it was like our MPLS provider all over again.” + +One way to save valuable time is to choose an SD-WAN provider with a co-management or self-service management model that allows the customer to make some network and security changes directly through a portal. You shouldn’t have to rely on the provider’s staff to make every single change. + +### One Step at a Time + +Transitions can stumble, so most IT managers prefer a phased migration, with the new SD-WAN functioning side by side with your legacy WAN for a time to permit a quick cutover when necessary. + +Draw up a migration plan with your supplier that will cause the least business disruption possible. At minimum, you should be able to transition one network at a time. However, if you want to minimize disruption even further you may want to consider a segment-by-segment transition. If your business depends on application performance, you may even want to transition one business-critical application at a time.  + +Make sure your network and security policies are configured and ready to go with each step. You don’t want to leave your organization open to malware and security breaches during the transition by configuring these on the fly. + +[Financial information provider FDMG Mediagroep][8] used a carefully planned, phased approach when transitioning to a global private backbone to allay internal concerns about working with a new company. It started by connecting a few users at the Amsterdam office. It then connected an internal AWS site to evaluate cloud connectivity. Once those transitions succeeded it began converting individual production sites to SD-WAN. + +And in the end, be sure to have a backup plan if something goes wrong during the cutover to SD-WAN.  Find out how long it takes your vendor to respond when issues come up or even to cut back to your legacy WAN if necessary. + +SD-WAN migration can seem overwhelming when you’ve been relying for so long on MPLS. There’s no question there are potential pitfalls, but if you plan carefully and evaluate your strategy step by step along the way, you can reap all the benefits of SD-WAN without the migration headaches.  + +** ** + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3453198/migrating-to-sd-wan-avoid-these-pitfalls-say-it-leaders.html + +作者:[Cato Networks][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.networkworld.com/author/Matt-Conran/ +[b]: https://github.com/lujun9972 +[1]: https://www.catonetworks.com/sd-wan?utm_source=idg +[2]: https://go.catonetworks.com/VOD_The-6-Keys-to-Successful-WAN-Transformation?utm_source=idg +[3]: https://www.catonetworks.com/customers/bioivt-connects-and-secures-global-network-with-cato-cloud-and-the-cato-managed-threat-detection-and-response-mdr-service?utm_source=idg +[4]: https://www.catonetworks.com/blog/sd-wan-vs-mpls-vs-public-internet?utm_source=idg +[5]: https://www.catonetworks.com/customers/salcomp-replaces-global-mpls-firewalls-and-wan-optimizers-with-cato-cloud?utm_source=idg +[6]: https://go.catonetworks.com/The_Internet_is_Broken?utm_source=idg +[7]: https://www.catonetworks.com/customers/fisher-company-lowers-mpls-costs-improves-wan-performance?utm_source=idg +[8]: https://www.catonetworks.com/customers/fdmg-cuts-costs-revolutionizes-mobile-experience-by-replacing-mpls-and-mobile-vpn?utm_source=idg diff --git a/sources/talk/20191112 What open communities teach us about empowering customers.md b/sources/talk/20191112 What open communities teach us about empowering customers.md new file mode 100644 index 0000000000..263a0f407d --- /dev/null +++ b/sources/talk/20191112 What open communities teach us about empowering customers.md @@ -0,0 +1,75 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What open communities teach us about empowering customers) +[#]: via: (https://opensource.com/open-organization/19/11/customer-empowerment-open-communities) +[#]: author: (TracyG https://opensource.com/users/tgiuliani23) + +What open communities teach us about empowering customers +====== +Granting customers more autonomy and control can be scary. It's also an +inevitable consequence of digital transformation. Time to open up our +relationships. +![Shaking hands, networking][1] + +When it comes to digital transformation, businesses seem to be on the right track improving their customers' experiences through the use of technologies. Today, so much [digital transformation literature][2] describes the benefits of "delivering new value to customers" or "delivering value to customers in new ways." + +But "bringing new value to customers" is just the beginning. An even more powerful effect of digital transformation efforts is _empowering customers_. + +"What?" you may be saying. "How could I _possibly_ empower customers? What does that even mean?" + +With this series, we're here to help. In this article specifically, we'll define customer empowerment and explain why it should be a concern for any organization facing the possibility of transformation. + +### Defining customer empowerment + +Customer empowerment begins with the idea of giving customers access to the information, knowledge, opportunities, and authority to act in their own best interests inside the boundaries of their organizations and industries. This translates into an ability for customers to do _more for themselves_. + +Creating systems for customer empowerment means doing more than merely adding value to existing customer relationships. It means developing entirely _new_ kinds of relationships—more _open_ relationships—with customers. And that, in turn, means organizations undergoing digital transformations will need to understand how openness affects not only the _technical_ connections they make with people but also the _social_ connections responsible for the success of the new systems they're putting in place. + +The customer relationships you want to create are not merely the result of saying "Here's what we do for you, dear customer"; they are like the relationships you have in _other_ areas of your life: Trusting. Reciprocal. Authentic. + +Creating systems for customer empowerment means doing more than merely adding value to existing customer relationships. + +In short, customer empowerment is a natural, inevitable step in digital transformation. It involves using open values, open processes, and open software to transform the relationship with the customer by trusting them and giving them the information and opportunities to engage differently with your company. + +Think of [the way employee empowerment works in open organizations][3]. Leaders in these organizations make information, opportunities, and authority available to stakeholders so they feel empowered to make decisions and solve problems in ways leaders might not have predicted. _Customer_ empowerment works the same way—though in this case, the _organization itself_ provides _external_ parties with materials that empower their _own_ innovative activities. Typically, they do this through new, customer-facing processes. It's imperative that businesses interested in customer empowerment have enough data and sufficiently frequent interactions with their customers to be able to understand them, and that _associates_ in these businesses have a customer-centric mindset accompanied by the tools, processes, and training to make decisions that focus on customers' empowerment. + +Makes sense, right? But what does it look like? + +### An empowerment continuum + +Let's begin with one example from the retail industry. Nordstrom is a company that repeatedly earns high marks for its empowered employees and its superior customer service. Nordstrom customers feel empowered when they interact with the brand because the organization goes to great lengths to ensure that information on sizes for each item is correct, that pictures are color-true, that the opportunity to shop is convenient through online sites and mobile apps, and that trying new brands is risk-free for customers (because shipping is free). Nordstrom even manages return shipping through printable labels directly on its website. The company is trusting customers not to order clothes and return them after wearing them. + +Customer empowerment is a natural, inevitable step in digital transformation. + +This is an example of a company operating at the far end of a customer empowerment continuum. The empowerment practices we describe are low-risk—that is, the customer behaviors Nordstrom is trying to cultivate are aimed at helping customers do more of what Nordstrom expects them to do (buy goods). + +But we can follow that customer empowerment continuum to identify various ways companies might empower customers (and in the process grant them the power to innovate and surprise). [Kelvin Claveria][4], for example, outlines several examples: Mountain Dew collaborated with customers on their new flavor, "Voltage"; Buffer was transparent with customers and businesses about their security breach; Coca-Cola involved its fan community in building marketing content. These examples (all of which focus on marketing) demonstrate a higher degree of risk, but they're not quite on the far edge of our customer empowerment continuum. + +At that edge is full-on customer empowerment, where a trusted relationship with the customer lays the foundation of interactions. We might think of open source communities as exemplary in this regard: customers have access to the source code of the application they're using and are actively modifying the products they receive. What's more trusting and empowering than that? + +In open source communities, which leverage collaborative development methods, anyone can share information, get feedback, and take advantage of numerous opportunities to write code and participate in the community projects. The community is trusting user-collaborators to participate honestly (and without malicious intent) at the same time that the community manages itself and bans users who don't participate with community values or take advantage. + +What might customer empowerment in _this_ sense look like for organizations? + +In our next installment, we'll explore that question. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/19/11/customer-empowerment-open-communities + +作者:[TracyG][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/tgiuliani23 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/network_team_career_hand.png?itok=_ztl2lk_ (Shaking hands, networking) +[2]: https://enterprisersproject.com/what-is-digital-transformation +[3]: https://opensource.com/open-organization/18/10/understanding-engagement-and-empowerment +[4]: https://www.visioncritical.com/blog/power-of-customer diff --git a/sources/talk/20191113 How to drive customer experience with agile principles.md b/sources/talk/20191113 How to drive customer experience with agile principles.md new file mode 100644 index 0000000000..aa78563a36 --- /dev/null +++ b/sources/talk/20191113 How to drive customer experience with agile principles.md @@ -0,0 +1,110 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to drive customer experience with agile principles) +[#]: via: (https://opensource.com/article/19/11/apply-devops-agile-principles-customer-experience) +[#]: author: (Matt Shealy https://opensource.com/users/mshealy) + +How to drive customer experience with agile principles +====== +Increasing customer satisfaction scores is one of the most important +ways to grow a business. +![People meeting][1] + +Customer experience has never been more important. People can find out just about anything with a few clicks or a voice search on their phones. They can research products, services, and companies. They can do business with organizations all over the world. They can buy with a swipe and have things shipped right to their home within a day. + +Consumers now demand instant access, frictionless transactions, and [superior customer experience][2] (CX). Not only do they want efficiency, but they also want personalized interactions. + +### Customer experience as a competitive advantage + +CX is also becoming a way to distinguish yourself from the competition. More than 80% of organizations say that they expect to [compete mainly based on the customer experience][3] they provide. Companies that excel at customer experience have higher brand awareness, higher employee satisfaction, higher customer retention, higher customer satisfaction rates, and higher average order value. + +### Using agile and DevOps principles to compete + +Customer-forward applications, such as websites, apps, chatbots, call center tech, and e-commerce toolkits, define customer service and CX. They can positively shape a brand or push customers away. Organizations need to be in a continuous improvement cycle to improve these products. + +Competing successfully in a CX-driven world can happen only by applying agile and DevOps principals throughout the organization. + +### What is DevOps? + +[DevOps][4] is designed to deliver apps and services rapidly within a continuous development (CD) and continuous integration (CI) cycle. Products are developed, released, tested, and updated continuously rather than once or twice a year. + +To make this happen, cross-functional teams work in an agile environment rather than in a linear development cycle. Instead of working in silos, engineers work across application lifecycles. + +### The DevOps cycle + +By forgoing the traditional software development and infrastructure management process, organizations can launch products more quickly, identify problems to apply patches, and serve customers better. + +There are various iterations of the DevOps cycle, but they typically boil down to a few common elements in an infinite loop, starting with planning and looping back to the start. + + 1. Plan + 2. Build + 3. Continuous integration + 4. Deployment + 5. Operate + 6. Continuous feedback + + + +The idea is to constantly be in development and improving the application to provide a better customer experience. + +### Building a DevOps strategy + +The DevOps process brings together stakeholders from different disciplines into one project team. Instead of building things in an assembly-line manner, where one task follows another, the team works holistically across multiple disciplines at the same time. + +This helps bring business intelligence and strategy teams into the design phase. It keeps engineers in the customer feedback loop. For everyone in the agile development team, it provides tighter integration and keeps everyone focused on the larger goals. It allows developers to work towards customer and business outcomes rather than delivery feature sets. + +Customer feedback is one of the most important phases in improving CX. It doesn't matter how clean your code is or how innovative your app is if customers don't find it useful. Quality service starts with understanding customer needs and delivering intuitive ways to meet them. + +Automation is crucial to improving speed. Try to automate as much of the process as possible. There are technology tools—many of which are free and open source solutions—that can handle parts of the software delivery lifecycle smoothly. + +The DevOps strategy was developed as a way to speed software to market, but it can also be applied to nearly any process. A continuous development, deployment, test, and feedback loop creates a way to improve systems continuously. This makes for better workflows, stronger employee and customer engagement, and more iterative development. + +### The benefits of agile teams and DevOps strategies + +There are real and tangible benefits of improving CX. For one: [86% of consumers report they are willing to pay more for great customer experience][5]. + +Also, [improving customer experience][6] creates more brand loyalty. Keeping customers involved in the feedback loop and building on their suggestions to enhance usability can improve customer satisfaction. + +In addition, organizations can see multiple internal benefits, including: + + * Faster deployment times + * Higher product quality + * Increased project control and transparency + * Risk mitigation + * Faster adaptation + * More predictable costs and schedules + + + +Finally, agile development is iterative. A functional product may be market-ready after only a few iterations, and this can create a first-mover advantage. In fast-moving markets, this eliminates long delivery cycles. Fast releases can stimulate customer feedback, which can be turned into additional features to keep you ahead of competitors. + +Organizations with high agility are nearly [20% more likely to meet their business goals][7] than less agile teams. They finish projects on time 50% more often and [deliver software to market 37% faster][8]. + +The better your customer-facing products are, the more time call center and customer support teams will have available to work on customer problems. When patterns and concerns are recognized, they can be added to applications in a more seamless manner using the DevOps strategy. + +Raising the bar on customer experience takes an across-the-board commitment—from senior management to line-level employees. Raising customer satisfaction scores is one of the most important things you can do to grow any business. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/apply-devops-agile-principles-customer-experience + +作者:[Matt Shealy][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/mshealy +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/people_team_community_group.png?itok=Nc_lTsUK (People meeting) +[2]: https://www.chamberofcommerce.com/business-advice/master-a-great-experience-for-your-customers +[3]: https://www.gartner.com/en/doc/3874972-realizing-the-benefits-of-superior-customer-experience-a-gartner-trend-insight-report +[4]: https://opensource.com/resources/devops +[5]: https://www.walkerinfo.com/knowledge-center/featured-research-reports/customers-2020-a-progress-report +[6]: https://www.avoxi.com/blog/how-to-improve-csat-scores-in-your-call-center/ +[7]: https://www.pmi.org/-/media/pmi/documents/public/pdf/learning/thought-leadership/pulse/pulse-of-the-profession-2015.pdf +[8]: http://nyspin.org/QSMA-Rally%20Agile%20Impact%20Report.pdf diff --git a/sources/talk/20191113 USPS invests in GPU-driven servers to speed package processing.md b/sources/talk/20191113 USPS invests in GPU-driven servers to speed package processing.md new file mode 100644 index 0000000000..9c998d457b --- /dev/null +++ b/sources/talk/20191113 USPS invests in GPU-driven servers to speed package processing.md @@ -0,0 +1,60 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (USPS invests in GPU-driven servers to speed package processing) +[#]: via: (https://www.networkworld.com/article/3452521/usps-invests-in-gpu-driven-servers-to-speed-package-processing.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +USPS invests in GPU-driven servers to speed package processing +====== +U.S. Postal Service plans to use servers powered by Nvidia GPUs and deep learning software to train multiple AI algorithms for image recognition, yielding a tenfold increase in package-processing speed. +Thinkstock + +The U.S. Postal Service is set to purchase GPU-accelerated servers from Hewlett Packard Enterprise that it expects will help accelerate package data processing up to 10 times over previous methods. + +The plan is for a spring 2020 deployment, using HPE's Apollo 6500 servers, which come with up to eight Nvidia V100 Tensor Core GPUs. The Postal Service also will use Nvidia's EGX edge computing servers at nearly 200 of its processing locations in the U.S. + +**READ MORE:** [How AI can improve network capacity planning][1] + +Nvidia announced the USPS's plans at its GPU Technology Conference in Washington, D.C. Ian Buck, the former Stanford professor who created the CUDA language for programming Nvidia GPUs before joining the company to head AI initiatives, made the announcement in an opening keynote focused on AI. + +Buck said half of the world’s enterprises today rely on AI for network protection and security, and 80% of the telcos will rely on it to protect their networks. “AI is a wonderful tool for looking at massive amounts of data and finding anomalies, pulling needles out of a haystack,” he told the audience. + +The USPS — which processes 485 million pieces of mail per day, or 146 billion pieces of mail per year — plans to use servers powered by Nvidia's GPUs and deep learning software to train multiple AI algorithms for image recognition, according to Buck. Those algorithms would then be deployed to the EGX systems at the Postal Service's package processing sites. + +The aim is to improve the speed and accuracy of recognizing package labels, which would improve the speed of package delivery and reduce the need for manual involvement. + +### Nvidia AI deployments and market initiatives + +AI is being embraced by a number of industries, to varying degrees of success. Nvidia uses itself as a guinea pig: + +“At Nvidia we have a fleet of self-driving vehicles, which we use for both collecting data and testing our self-driving capabilities. We ingest and create literally petabytes of data every week that has to be processed by our own team of labelers and processed by AIs,” Buck told the crowd. “We have literally thousands of GPUs doing training every day, which are supporting hundreds of data scientists, which are defining the self-driving car capabilities.” + +The module in Nvidia’s self-driving car is called Pegasus and consists of two Volta GPUs and two Tegra SOCs. “It’s basically an AI supercomputer inside every car processing hundreds of petabytes of data,” Buck said. + +The challenge now is to actually apply AI, he said. To do so, Nvidia has a number of AI projects for the automotive, healthcare, robotics and 5G industries. For healthcare, for example, Nvidia has its Clara software development kit with pretrained models to tackle tasks such as looking for a particular kind of cancer in minutes or hours. + +For IoT, Nvidia has the Metropolis Internet of Things application framework as cities build out sensors to detect unsafe driving conditions, such as a vehicle driving the wrong way onto a freeway. Nvidia also has the DRIVE autonomous vehicle platform, which spans everything from cars to trucks to robotaxis to industrial vehicles. Nvidia's Omniverse kit targets design and media, and its Aerial products are for telcos moving to 5G, along with the EGX server. + +To train new developers to build AI apps on GPUs, Nvidia announced that its Deep Learning Institute just added 12 new courses focused on AI training. So far, DLI has trained more than 180,000 AI workers. + +Join the Network World communities on [Facebook][2] and [LinkedIn][3] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3452521/usps-invests-in-gpu-driven-servers-to-speed-package-processing.html + +作者:[Andy Patrizio][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.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3338100/using-ai-to-improve-network-capacity-planning-what-you-need-to-know.html +[2]: https://www.facebook.com/NetworkWorld/ +[3]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191114 Space-sourced power could beam electricity where needed.md b/sources/talk/20191114 Space-sourced power could beam electricity where needed.md new file mode 100644 index 0000000000..c095747b36 --- /dev/null +++ b/sources/talk/20191114 Space-sourced power could beam electricity where needed.md @@ -0,0 +1,65 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Space-sourced power could beam electricity where needed) +[#]: via: (https://www.networkworld.com/article/3453601/space-sourced-power-could-beam-electricity-where-needed.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +Space-sourced power could beam electricity where needed +====== +Harvesting solar energy in space would provide off-grid electricity at night, and for areas that don’t receive much sunlight. A project has just received funding. +[dimitrisvetsikas1969][1] [(CC0)][2] + +Capturing solar energy in space and then beaming it down to Earth could provide consistent electricity supplies in places that have never seen it before. Should the as-yet untested idea work and be scalable, it has applications in [IoT][3]-sensor deployments, wireless mobile network mast installs and remote edge data centers. + +The radical idea is that super-efficient solar cells collect the sun’s power in space, convert it to radio waves, and then squirt the energy down to Earth, where it is converted into usable power. The defense industry, which is championing the concept, wants to use the satellite-based tech to provide remote power for forward-operating bases that currently require difficult and sometimes dangerous-to-obtain, escorted fuel deliveries to power electricity generators. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][4] + +This replacement system could provide directed solar-produced energy at night or electricity in places without grid delivery. It could also eliminate the alternatives: expensive, wind-solutions and mechanical generators that require maintenance. Extreme northern regions (good spots for [data centers][5] because they’re cold, allowing for ambient cooling), could have, conceivably, for the first time, usable solar power in the predominantly dark winter. + +[][6] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][6] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +“Developers envision a system that is a constellation of satellites with solar panels, about 10,000-square meters, or about the size of a football field or tennis court,” [writes Scott Turner of the Albuquerque Journal][7]. The Air Force Research Laboratory (AFRL), in Albuquerque, along with defense technology company Northrop Grumman have just announced that they plan to spend $100 million dollars developing the hardware, called the Space Solar Power Incremental Demonstrations and Research (SSPIDR) project. + +Two kinds of solar-panel technology are in common use on land now. Photovoltaic solar panels work by converting energy from the sun into electricity. They don’t have moving parts, so are inexpensive to maintain, unlike turbines. Another kind of solar panel uses mirrors and lenses. They grab, and then concentrate sunlight, producing heat, which then operates steam turbines. + +“This whole project is building toward wireless power transmission,” Maj. Tim Allen, a manager on the project, told Turner. It will “beam power down when and where we choose.” Precise power beams will automatically track the target that needs the power, too. “We can put them down in specific locations and keep them there,” he says. + +A significant advantage to placing solar panels in space, as opposed to on land, is that spacecraft get near constant sunlight, explains Rachel Delaney, a systems engineer on the project. Weather also becomes a non-issue, she says. It lets us “capture solar energy in space and precisely beam it to where it is needed,” Col. Eric Felt, director of the Space Vehicles Directorate at AFRL [says in a separate news release][8]. That could be as remote as the satellite footprint allows; single satellites are limited in reach as they only see the part of the Earth that’s in perspective. + +“I believe the commercial industry will be happy to mimic what we’re doing and start providing this power commercially and not just for the military,” Turner quotes Allen as saying. + +Join the Network World communities on [Facebook][9] and [LinkedIn][10] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3453601/space-sourced-power-could-beam-electricity-where-needed.html + +作者:[Patrick Nelson][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.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://pixabay.com/en/sun-bright-yellow-sunset-sky-1953052/ +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[4]: https://www.networkworld.com/newsletters/signup.html +[5]: https://www.networkworld.com/article/3223692/what-is-a-data-centerhow-its-changed-and-what-you-need-to-know.html +[6]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[7]: https://www.abqjournal.com/1386648/afrl-looks-to-beam-solar-energy-from-space.html +[8]: https://afresearchlab.com/news/u-s-air-force-research-laboratory-developing-space-solar-power-beaming/ +[9]: https://www.facebook.com/NetworkWorld/ +[10]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191115 Cray to license Fujitsu Arm processor for supercomputers.md b/sources/talk/20191115 Cray to license Fujitsu Arm processor for supercomputers.md new file mode 100644 index 0000000000..5d075bae54 --- /dev/null +++ b/sources/talk/20191115 Cray to license Fujitsu Arm processor for supercomputers.md @@ -0,0 +1,66 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Cray to license Fujitsu Arm processor for supercomputers) +[#]: via: (https://www.networkworld.com/article/3453341/cray-to-license-fujitsu-arm-processor-for-supercomputers.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Cray to license Fujitsu Arm processor for supercomputers +====== +HPE's Cray will co-develop Fujitsu's A64FX CPU to meet the requirements of likely customers such as universities and national research laboratories. +Riken Advanced Institute for Computational Science + +Cray says it will be the first supercomputer vendor to license Fujitsu’s A64FX Arm-based processor with high-bandwidth memory (HBM) for exascale computing. + +Under the agreement, Cray – now a part of HPE – is developing the first-ever commercial supercomputer powered by the A64FX processor, with initial customers being the usual suspects in HPC: Los Alamos National Laboratory, Oak Ridge National Laboratory, RIKEN, Stony Brook University, and University of Bristol. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][1] + +As part of this new partnership, Cray and Fujitsu will explore engineering collaboration, co-development, and joint go-to-market to meet customer demand in the supercomputing space. Cray will also bring its Cray Programming Environment (CPE) for Arm processors over to the A64FX to optimize applications and take full advantage of SVE and HBM2. + +[][2] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][2] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +The A64FX was announced last year as the processor for Fujitsu’s next supercomputer, known as [Post-K][3]. The K supercomputer is a massive system at Japan’s RIKEN Center for Computational Science, based on the Sparc architecture. Fujitsu had a Sparc license from Sun Microsystems and made its own chips for the Japanese market. + +A64FX is the first CPU to adopt the [Scalable Vector Extension][4] (SVE), an extension of Armv8-A instruction set architecture for supercomputers. SVE is focused on parallel processing to run applications faster. + +The A64FX also uses HBM2, which has much greater memory performance than DDR4, the memory standard in servers. The A64FX has a maximum theoretical memory bandwidth greater than 1 terabyte per second (TB/s). + +Fujitsu claims the A64FX will offer a peak double precision (64-bit) floating-point operations performance of over 2.7 teraflops. That pales in comparison to the 100 TFlops for an Nvidia Tesla V100, but the A64FX has a power draw of 160 watts vs. 300 watts for the Tesla. + +However, there is more going on. The 32GB of on-chip HBM2 and high-speed interconnects mean a much faster internal chip, and in early tests, Fujitsu is claiming a 2.5-times performance improvement over the Sparc XIIfx chips used in the K computer. + +The Cray supercomputer powered by Fujitsu A64FX will be available through Cray to customers in mid-2020. + +**Now see** [**10 of the world's fastest supercomputers**][5] + +Join the Network World communities on [Facebook][6] and [LinkedIn][7] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3453341/cray-to-license-fujitsu-arm-processor-for-supercomputers.html + +作者:[Andy Patrizio][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.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.networkworld.com/article/3389748/fujitsu-completes-design-of-exascale-supercomputer-promises-to-productize-it.html +[4]: http://www.datacenterdynamics.com/content-tracks/servers-storage/arm-boosts-supercomputing-potential-with-long-vector-support/96823.fullarticle +[5]: https://www.networkworld.com/article/3236875/embargo-10-of-the-worlds-fastest-supercomputers.html +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191115 Hiring a technical writer in the age of DevOps.md b/sources/talk/20191115 Hiring a technical writer in the age of DevOps.md new file mode 100644 index 0000000000..6716e71f20 --- /dev/null +++ b/sources/talk/20191115 Hiring a technical writer in the age of DevOps.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Hiring a technical writer in the age of DevOps) +[#]: via: (https://opensource.com/article/19/11/hiring-technical-writers-devops) +[#]: author: (Will Kelly https://opensource.com/users/willkelly) + +Hiring a technical writer in the age of DevOps +====== +As organizations mature their DevOps practices, it's time to make the +technical writer a bigger part of the team. +![Women talking][1] + +It's common for enterprises to leave the technical writer's role out of the DevOps discussion. Even the marketing department [joins the discussion][2] in some DevOps-first organizations—so why not the writers? + +Our industry doesn't ask enough of its technical writers. Documentation is an afterthought. Companies farm out technical writing to contractors at the end of the project lifecycle. Corners get cut. Likewise, technical writers don't ask enough of their industry. The expectations for the role vary from company to company. Both circumstances lead to technical writers being left out of the DevOps discussion. + +As your organization matures its DevOps practices, it's time to revisit the role of your technical writer. + +### Recast your technical writer for DevOps + +I remember one of the first agile projects I ever worked on, back when I was still writing technical documentation. One of the other writers on the team had a hard time grasping the fact that we had to write about a product that wasn't 100% complete. Those days are gone. Thank you, DevOps and agile. + +It's time for organizations to revisit how they hire technical writers. Throw out your waterfall technical writer job description. Right. Now. I've always divided up technical writers into operations technical writers, who document infrastructure, and software development technical writers, who document software development. The writers flit back and forth. But, finding a technical writer with a grounding in software development and operations can be helpful for staffing a technical writer position on your DevOps team. + +DevOps means you may need to make changes to your standard "corporate technical writer" job description. For instance, weigh software and operations documentation experience higher than before because the flexibility will only help your team. The same goes for writers with experience creating more modular online documentation using tools such as Twiki or Atlassian Confluence. + +DevOps also requires technical writers who can be full participants. Writers can no longer add value if they expect features to be complete before they get involved. Look for writers with experience driving documentation efforts. Your goal should be to find a technical writer who can work with fewer dependencies that you can plug into various parts of your delivery cycle. This can be easier said than done when it comes to hiring. The only advice I can give is to color outside the lines of the traditional technical writer role and be prepared to pay for it. + +Another skill to seek in a technical writer for your DevOps team is collaboration platform management. Adding that duty to your technical writer job description takes a non-critical task off of a developer's to-do list. + +The DevOps technical writer should take the same onboarding path as the developers and other project team members you bring on board. Give them access to the systems they need to document in a sandbox running the same builds as everybody else. + +Measuring the technical writer's success in a DevOps world takes on some new shades of meaning. You can tie your online documentation to analytics to track readership. You also need to track the technical writer's work the same way you're tracking developers' work. Documentation has bugs, too. + +### Retool your documentation process + +Technical documentation has to take a more toolchain velocity-driven approach to keep pace with DevOps. There have been some stops and starts in rethinking documentation publishing in a high-velocity DevOps world. + +A movement called [DocOps][3], out of CA (now part of Broadcom), brought together technical documentation and DevOps practices, but the original team behind the concept appears to have moved on. The effort fizzled out, but I still recommend researching it online. You will get the [CA.com][4] documentation subsite in your search returns. It's running on Atlassian Confluence with CA branding and other customizations. It's been migrated from the more traditional documentation formats of Webhelp and PDF to separate documentation away from the applications they support. While the development team and documentation still have to be in sync for releases, they aren't as dependent on each other for maintenance and updates. + +[Content-as-Code][5] also holds value for your move to a more DevOps-friendly documentation strategy. It uses software engineering practices to support content reuse. It breaks away from the traditional content management system (CMS) model; it uses Git for content versioning, and technical writers and other content authors use Markdown for authoring. Content-as-Code as a development model supports static website generators such as [Jekyll][6] and [Hugo][7] with interoperability with CMSes. + +Whatever direction you choose for publishing your documentation, it's important to do the upfront work. Start with a small proof of concept. Experiment with tools and workflows. Involve your development team in the initial process to get their feedback on the new publishing model you are building. Make sure to document your publishing tools and workflow, just as you've done with your DevOps toolchain. + +### The DevOps technical writer's time is now + +The cultural and technology transformation DevOps brings to organizations means there could be more work for an experienced and well-placed technical writer. Just as you brought your developers and system administrators into the DevOps age, do the same with your technical writers. + +How is your organization adjusting the technical writer role for DevOps? Please share in the comments. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/hiring-technical-writers-devops + +作者:[Will Kelly][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/willkelly +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/conversation-interview-mentor.png?itok=HjoOPcrB (Women talking) +[2]: https://martechseries.com/mts-insights/guest-authors/marketing-team-can-learn-devops/ +[3]: https://contentmarketinginstitute.com/2015/04/intelligent-content-application-economy/ +[4]: http://CA.com +[5]: https://iilab.github.io/contentascode/ +[6]: https://jekyllrb.com/ +[7]: https://gohugo.io/ diff --git a/sources/talk/20191116 4 critical growth opportunities for open source.md b/sources/talk/20191116 4 critical growth opportunities for open source.md new file mode 100644 index 0000000000..f6faf87deb --- /dev/null +++ b/sources/talk/20191116 4 critical growth opportunities for open source.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (4 critical growth opportunities for open source) +[#]: via: (https://opensource.com/article/19/11/open-source-growth-opportunities) +[#]: author: (Tony Wasserman https://opensource.com/users/tonywasserman) + +4 critical growth opportunities for open source +====== +There has been tremendous growth in open source; now the issue is +predicting its strongest opportunities. +![Green graph of measurements][1] + +I recently served on a panel about growth opportunities in open source at the [Open Source India][2] conference in Bengaluru. As you might expect, my fellow panelists and I approached the topic from widely varying perspectives, and I came away with the feeling that we may have confused many in the audience rather than enlightening them. With that in mind, I thought it would be useful to consolidate the panel's ideas about open source growth opportunities, drawing upon many of the points put forth in the session as well as my own thoughts. + +### The state of open source + +Adoption and use of free and open source software (FOSS) in India (and elsewhere) have grown remarkably over the past 15 years, going back to the first Open Source India conference (then called Linux Asia). At that time, FOSS was largely the province of technologists and developers, with very little adoption by governments, industry, and other organizations. On the contrary, there was some active resistance to FOSS, with Microsoft's then-CEO, Steve Ballmer, calling it a "Communist plot." The earliest commercial ventures in FOSS started a decade earlier with leaders such as Red Hat, [Mandrake][3], and MySQL. Traditional system integrators, such as TCS and Wipro, built their customer solutions with proprietary, closed source software. + +Today, the picture is very different. Microsoft's current CEO, Satya Nadella, said Microsoft is "all-in on open source" when he announced its US$ 7.5 billion acquisition of GitHub earlier this year and the appointment of Nat Friedman, former CEO of a commercial FOSS business, as the new head of GitHub. + +There are now hundreds of companies all over the world that have developed businesses that provide FOSS and related services. Beyond that, many companies have moved up the FOSS adoption curve, going from initial experimentation, through using FOSS in their products, then contributing FOSS code to various projects, and releasing their own FOSS projects (such as [Cassandra][4] and [TensorFlow][5]) as open source. + +One significant outcome of this shift is that FOSS has moved from a "copycat" of proprietary software to being the basis for innovative advances. Much of the leading software in areas such as management of large data sets, microservices, and Internet of Things (IoT) has been released under an Open Source Initiative [(OSI)-approved open source license][6]. More than a third of all servers worldwide and all supercomputers run Linux. On the consumer side, more than 80% of all smartphones run the Linux-based Android operating system, with many vendors adding their own enhancements to the foundation code. + +In short, there has already been tremendous growth in the adoption and use of FOSS. It's unusual to find large companies whose developers don't make extensive use of open source components and libraries in their products. The issues now are projecting where FOSS is headed and identifying the areas with sizeable growth potential. + +### Technology growth opportunities + +The number of FOSS projects has grown exponentially. GitHub hosts more than 100 million projects from more than 40 million contributors. Only a tiny percentage of these projects are suitable to be adopted for production use in business-critical systems; millions have been abandoned by their creator(s). Perhaps 0.01% (10,000) of them would satisfy the needs of someone building product-quality software. There are ample evidence and general agreement that the best FOSS code is equal in quality to, if not better than, closed proprietary code. + +But there's a lot of room for technology growth. First, there's growing adoption of FOSS technology—from programming languages to specialized libraries and from infrastructure software to end-user applications—particularly among developers. Next, the size of communities around successful projects (such as Python) is growing quickly, not only with new versions of projects and numbers of maintainers but also with organizations that provide support services, including documentation, translation, and extensions and add-ons, for these technology projects. In some cases, these extensions and add-ons are proprietary, yielding an "open core" approach, where the core retains its FOSS status but customers must pay for some of the add-ons. + +Software developers have been on the leading edge of this technology growth. Expensive commercial developer tools have largely been displaced by FOSS tools. An excellent example is the [Eclipse][7] environment, supported by contributors to the Eclipse Foundation, which was derived from IBM's commercial VisualAge tools. Microsoft's Visual Studio once sold for as much as US$ 2,000 per user. Today's tools for coding, testing, continuous integration, DevOps, and collaboration are often free, and developers, particularly in startups, have chosen them over other options. + +There's also a place for new FOSS projects as technology evolves and traditional products become increasingly software-dependent. Automobiles and medical devices fall into this category. Newer automobiles are highly dependent on software in virtually every aspect of their operation, not just for autonomous operation but also for overall efficiency, self-detection of faults, and over-the-air software updates. Today, much of that software is proprietary, but it contains vast amounts of FOSS. For example, many of the entertainment systems offered by commercial airlines are built on Linux. It's possible that regulatory agencies or public sentiment will eventually require life-critical applications to be open. + +The venture capitalist Mark Andreesen is known (among other things) for saying "software is eating the world." That means not only more software but also more societal dependence on that software's secure and proper functioning. There's a great impact on FOSS as user expectations for usability, reliability, and overall quality continue to grow. The role of open source foundations is also important here because the larger foundations host more projects, involve more contributors in their projects, and maintain governance over those projects, all of which give users greater confidence in the quality and long-term viability of these FOSS projects. + +### Employment growth + +These trends point clearly to the need for a big jump in jobs for professionals interested in working with open source. While developers are an obvious need, the range of employment opportunities is much larger and includes quality assurance (QA) and release engineers, engineering managers, support engineers, consultants, service providers, executives, and even legal experts to help with licenses and contracts that involve FOSS. For example, many companies will need to establish an open source project office (OSPO) to keep track of their use of FOSS code and staff it with FOSS-knowledgeable people who can work with internal groups on the company's use of FOSS and their contributions to various external FOSS projects and organizations, such as the Apache Foundation. Another example is the growth of information services related to FOSS, including publications, conferences, newsletters, blogs, and consultancies. + +These requirements suggest the need for expanded educational programs related to FOSS. Many programs are emerging to encourage young people to learn how to code, and it is a straightforward extension to introduce FOSS at an early stage to create a growing pool of talent coming through secondary and university-level educational programs to meet employment needs. This also increases the demand for experienced FOSS-aware professionals to teach technology and related topics to students. + +### Business growth + +The growth of FOSS use implies growth opportunities for businesses that develop FOSS and provide FOSS-related services, including project hosting, system integration, and commercial support (e.g., training and QA). As noted above, companies and governments will need people within their organizations and in the broader community around the projects that are most important to their businesses. + +The economies of the world have natural business cycles, with newer companies growing and often displacing incumbents. For example, early database systems were replaced by relational database systems such as Oracle and DB2, which are now competing for market share with non-relational database applications, many of them open source, such as Apache CouchDB and [Neo4j][8]. The former are mature businesses, while the latter are growing at a rapid rate. Employment applicants seek out these growing companies since they not only provide greater internal career advancement opportunities but also the chance to work on leading-edge technology and potentially to benefit from the increased value of such companies as they grow. For example, GitHub and Red Hat employees benefited when these companies were acquired by Microsoft and IBM, respectively, earlier this year. + +Technology customers reinforce these patterns since few want to spend their money on the trailing edge of technology. Unless they regularly update their systems, they will fall behind competitors that make more effective use of technology. Walmart, one of the world's largest retailers, ascribes much of its historic growth to the software technology used to manage its supply chain; by contrast, the international retail clothing chain Forever21 recently filed for bankruptcy, with analysts noting that the company made very poor use of technology. + +These corporate technology buying decisions often create situations where a small number of software vendors come to dominate the market. For a long time, those decisions favored proprietary technology vendors, in part because industry analysts recommended them over FOSS. Now, however, FOSS companies are receiving greater attention, not only because they offer a lower total cost of ownership for their customers, but also because these commercially-focused FOSS businesses have added support services and service level agreements to match traditional vendors. These developments suggest that the leading FOSS companies and products will continue to grow as technology buyers become more comfortable with these newer entries in the software market. + +### Investment growth + +With the topic of "growth opportunities" as the Open Source India panel's theme, one natural aspect for discussion involved opportunities for angel investors, business accelerators, venture capitalists, and others to benefit financially from funding commercial FOSS companies or investing in publicly traded companies with a significant role in FOSS. + +The [OSS Capital][9] website has a tab labeled COSSCI (for Commercial Open Source Software Company Index) that lists more than 40 FOSS companies with annual revenue exceeding US$ 100 million and valuations in excess of US$ 1 billion. All but three of the companies on the list have received venture capital funding averaging US$ 240 million. At that level, not all of the FOSS companies will provide a return to their investors, but the overall data shows that a growing number of knowledgeable investors are acting on the belief that FOSS companies will continue to grow their revenue and profitability, whether they are entries in a new market segment or capturing market share in market segments historically dominated by proprietary vendors. + +It's not that technology customers will abandon the systems on which they manage their businesses, but rather that decision-makers in up-and-coming companies will be more likely to choose FOSS solutions than their counterparts in legacy businesses. One can also view IBM's acquisition of Red Hat in this light, using Red Hat's products as a FOSS alternative to IBM's previous generations of software products. + +It's clear that such investments of capital can assist companies from their earliest stages through their lifetimes, often resulting in their acquisition or public offering. Companies need funding to grow beyond their initial development, especially to generate awareness of their products and services through marketing programs, create auxiliary support services, and invest in further product development in response to customer requirements, changing markets, and evolving platforms. The founders of such companies spend a disproportionate amount of time seeking investment funding and negotiating the terms of such funding since their growth potential depends on their ability to hire and adequately compensate their employees, as well as to launch their products and build the sales and marketing channels to establish themselves in the market. + +Over time, though, these companies must generate revenue and profits from customer purchases so that they are no longer dependent on investor funding. Some companies, such as WhatsApp, are acquired while they are very small, as larger companies see their potential, and are then in a position to fund their ongoing growth. Nonetheless, many startup companies fail to achieve "liftoff" and join the large percentage of startups that don't make it past the initial development stage. These companies tend to fail from being underfunded, from poor management decisions related to hiring, and from an inability to identify a market need that will attract customers. + +### Conclusion + +In summary, the past growth and the potential for continued growth in FOSS-related products and services have far exceeded the expectations of experts from a decade ago. Looking back, it's clear that the worldwide [Great Recession][10] caused many companies to explore FOSS more thoroughly. Also, FOSS's growing availability and quality led organizations to expand its use beyond developers and pilot projects into business-critical situations. Investors were attracted by the US$ 1 billion acquisition of MySQL AB by Sun Microsystems, more than 15x the annual sales revenue of MySQL at that time. + +However, there are still many opportunities for growth. Only a tiny percentage of apps for mobile devices are open source (see [F-Droid][11] for open source Android apps). Also, technology companies, including telecommunications and computer systems, are much more likely to have made significant FOSS deployments. Adoption has been much slower in domains such as insurance, but they are now using machine-learning (ML) and artificial intelligence (AI) tools, such as the FOSS R statistical package, to help them with decision-making. Beyond that, the growth of "smart devices" and "smart cities" draws heavily upon the use of these ML and AI tools, ensuring that the world will become more and more dependent not just upon software, but upon open source. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/open-source-growth-opportunities + +作者:[Tony Wasserman][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/tonywasserman +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_lead-steps-measure.png?itok=DG7rFZPk (Green graph of measurements) +[2]: https://www.opensourceindia.in/ +[3]: https://openmandriva.org/ +[4]: https://opensource.com/life/16/5/basics-cassandra-and-spark-data-processing +[5]: https://opensource.com/article/17/2/machine-learning-projects-tensorflow-raspberry-pi +[6]: https://opensource.org/licenses +[7]: https://opensource.com/education/16/4/5-great-eclipse-scientific-workbenches +[8]: https://opensource.com/article/17/7/fundamentals-graph-databases-neo4j +[9]: https://oss.capital/ +[10]: https://en.wikipedia.org/wiki/Great_Recession +[11]: https://f-droid.org/ diff --git a/sources/talk/20191116 IoT in 2020- The awkward teenage years.md b/sources/talk/20191116 IoT in 2020- The awkward teenage years.md new file mode 100644 index 0000000000..7997d95629 --- /dev/null +++ b/sources/talk/20191116 IoT in 2020- The awkward teenage years.md @@ -0,0 +1,96 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (IoT in 2020: The awkward teenage years) +[#]: via: (https://www.networkworld.com/article/3453643/iot-in-2020-the-awkward-teenage-years.html) +[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) + +IoT in 2020: The awkward teenage years +====== +The internet of things will see more growth in 2020, along with more growing pains - security, lack of complete solutions +Thinkstock + +Much of the hyperbole around the [Internet of Things][1] isn’t really hyperbole anymore – the instrumentation of everything from cars to combine harvesters to factories is just a fact of life these days. IoT’s here to stay. + +Yet despite the explosive growth – one widely cited prediction from Gartner says that the number of enterprise and automotive IoT endpoints will reach 5.8 billion in 2020 – the IoT market’s ability to address its known flaws and complications has progressed at a far more pedestrian pace. That means ongoing security woes and a lack of complete solutions are most of what can be safely predicted for the coming year. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][2] + +Part of the problem, according to experts, is that there are still two distinct, recognizable types of vendor competing in the IoT market: IT companies with plenty of technological expertise but little hands-on operational experience, and established vendors across the various verticals without much IT sophistication. + +**[ [Prepare to become a Certified Information Security Systems Professional with this comprehensive online course from PluralSight. Now offering a 10-day free trial!][3] ]** + +What this means from a practical standpoint is that, most of the time, no single vendor is able to offer a complete solution to a given IoT problem and, therefore, unable to solve the broader issues with IoT technology in a unitary way. + +### Security + +The main issue, of course, remains security. From the standpoint of the IT networking professional, implementing IoT can be like actively inviting security breaches, according to IDC senior research analyst Patrick Filkins. + +“IoT is a massive challenge for an IT admin,” he said. “You’re putting hundreds of thousands of low-cost, high-risk devices on the network.” + +The  divide between IT and OT is one of the central causes of the security problem. The companies that make most of the sensors for IoT are companies that have experience in their particular area – oil drilling equipment makers, industrial vendors, medical device manufacturers, and so on. Such companies are used to delivering value for money. + +“If you want [IoT at scale], you need to bring the price point down on all those sensors, and that affects security,” Filkins said. + +451 Research vice president Christian Renaud said that despite the fact that there’s a growing recognition that the security issue is very serious, the sheer volume of new endpoints and types of endpoints flooding into the market in the next few years makes a serious breach all but certain. + +One of the keys to securing the IoT, he said, is the use of behavioral analytics on the network – even if individual IoT devices remain difficult to secure, a machine-learning-based system that recognizes malicious traffic – what he calls the “Why is my sensor calling the Ukraine?” problem – could help address the problem. + +### IT– OT collaboration + +What’s coming, according to Renaud, is a more pragmatic understanding of what IoT means. + +“More than anything, we’ve matured past the early confusion, ambiguity and hyperbole,” he said, “to understanding that it’s a whole bunch of different technologies across dozens of use cases in dozens of markets.” + +And what that implies is an even greater degree of collaboration throughout the IoT sector. IT companies have been aggressive in partnering up with OT companies, and there’s a general recognition that most complete IoT solutions will involve products from multiple vendors. + +Part of the reason for that is money. An IT mega-giant like Google or Microsoft could, in theory, target a particular IoT vertical, acquire existing companies for their operational know-how, and offer a floor-to-ceiling, say, medical-device management system. But the sense is that it simply wouldn’t be cost-effective, according to Filkins. + +“It’s less advantageous for them to do vertical solutions,” he said,” because those cost more money for a smaller market.” + +That isn’t to say that the major IT players aren’t targeting different verticals, just that they’re doing it in what, for them, is a somewhat uncharacteristic manner – repackaging their offerings for different industries and partnering with OT companies, said Renaud. + +“What we’re accustomed to is a winner-take all mentality, where someone in IT just owns a sector,” he said. “But if you look at the [IoT] verticals, a lot of it is dominated by incumbents.” + +It doesn’t help that the IoT sector has only recently begun to realize that many verticals have enormously long equipment lifecycles, meaning that the brownfield is infinitely larger than the greenfield. For IT companies used to dominating particular corners of their industry – or, indeed, creating new markets altogether – the idea that nothing gets fully ripped-and-replaced is an adjustment. + +### Edge networking + +Another one of the major trends for 2020, Filkins noted, will be that enterprises start to move away from cloud-driven IoT deployments and more toward systems that do their computing close to the edge – [edge computing][4]. The cloud can be a limiting factor in a lot of IoT deployments, mostly due to the fact that having to send information from a sensor all the way back to a public cloud, processing it there, and having the results sent from the cloud to the user involves delay. + +“That’s limiting from an application performance point of view,” said Filkins. “We’ve all heard about the edge, I think it’s overhyped, but I think it’s happening.” + +**Read more about edge networking** + + * [How edge networking and IoT will reshape data centers][5] + * [Edge computing best practices][6] + * [How edge computing can help secure the IoT][7] + + + +Join the Network World communities on [Facebook][8] and [LinkedIn][9] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3453643/iot-in-2020-the-awkward-teenage-years.html + +作者:[Jon Gold][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.networkworld.com/author/Jon-Gold/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[2]: https://www.networkworld.com/newsletters/signup.html +[3]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr +[4]: https://www.networkworld.com/article/3224893/what-is-edge-computing-and-how-it-s-changing-the-network.html +[5]: https://www.networkworld.com/article/3291790/data-center/how-edge-networking-and-iot-will-reshape-data-centers.html +[6]: https://www.networkworld.com/article/3331978/lan-wan/edge-computing-best-practices.html +[7]: https://www.networkworld.com/article/3331905/internet-of-things/how-edge-computing-can-help-secure-the-iot.html +[8]: https://www.facebook.com/NetworkWorld/ +[9]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191116 Should I Choose a Managed WordPress Hosting.md b/sources/talk/20191116 Should I Choose a Managed WordPress Hosting.md new file mode 100644 index 0000000000..240adb355c --- /dev/null +++ b/sources/talk/20191116 Should I Choose a Managed WordPress Hosting.md @@ -0,0 +1,87 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Should I Choose a Managed WordPress Hosting?) +[#]: via: (https://opensourceforu.com/2019/11/should-i-choose-a-managed-wordpress-hosting/) +[#]: author: (Mark Hanson https://opensourceforu.com/author/mark-hanson/) + +Should I Choose a Managed WordPress Hosting? +====== + +[![WordPress][1]][2] + +_After the first wave of the great eCommerce revolution of the 21st century, businesses began to question what it is they really needed out of a website. Web 1.0 was fraught with false starts: guestbooks, webrings, Flash intro pages, and all sorts of frills. Then online commerce began to dial it back. It turns out that for many businesses, a blog really is all you need._ + +For a vast chunk of the online business world, that means “a WordPress install,” and then you’re done. [_WordPress makes up a whopping one-third_][3] of the top 10 million websites. Not only is this an overwhelming vote of confidence, but it also means that most bloggers, editors, website maintainers, and social media marketers will be trained in WordPress as a standard tool, so it’s easy to find staff to maintain it and difficult to find anybody experienced in other content management systems. + +**Other Options** + +Before most businesses stumble upon the idea of managed WordPress hosting, they typically go to one of the cheaper routes: + + * Building a freebie blog on Blogger or Wix + * Shared hosting on some third-rate server warehouse + * Getting a “web guy” who knows how to maintain a VPS + + + +All of these options are rock-bottom cheap, but the old axiom “you get what you pay for” soon becomes apparent. Small sites hosted by the hundreds on the same server tend to get small traffic, be prone to break and end up being tougher to maintain. + +At the opposite end is the dedicated server, which, while it is just the thing for a Fortune 500 company, is far more than any start-up needs. Full server hosting will typically require someone to maintain it 24/7, with more sophisticated skills required. + +**A WordPress Site That Runs Itself** + +More businesses are turning to managed WordPress hosting for the practical advantage it offers. It’s a right-size fit offering the balance between heavy-duty enough to take a pounding in web traffic, but not so massive that it’s a time and money sink to maintain. + + * Support on a managed account beats any other service. + * The site is tuned to run WordPress better without bothering with peripheral matters. + * Maintenance tasks like backups and are handled automatically. + * Easier maintenance. + * More robust security than the average WordPress install. + * Better performance overall. + + + +Since you’re not on a shared server, a managed WordPress host gives you better DNS access, and lets you use tools like SSH, Git, and WP-CLI. Whoever you get to mage your online presence, they’ll appreciate the greater selection of tools at their disposal. + +**Staging with Softaculous** + +There is one important aspect to managed WordPress hosting which is often overlooked: [_Staging_][4]. When you need to install new plugins or templates on a site, it’s a risky proposition every time. If you install something that breaks the site, it’s messy to remove and costs you downtime. Manually backing-up the site, testing on the scratch copy, then figuring out how to port the changes back to the main site is also time-consuming. + +Staged installs allow a one-click managed scripting process which tests the proposed install before you commit to it. It’s like a virtual sandbox where you can freely test changes before committing to them. Softaculous, an open-source script library for website maintenance, is a typical managed WordPress package manager that supports staging. You can even [_install WordPress with Softaculous_][5], and from there other package additions are a breeze. + +**A Worry-Free Website** + +The biggest plus to getting a host with a managed WordPress plan is that the set-up is done for you. You simply pick up your blog and go, as simply as you would open a notebook and begin writing. New website owners are best off if they leave the engineering details to an expert. Between coming up with content, priming it for SEO, posting it, and promoting it through social media, you’ll have plenty to worry about as it is. + +Managed WordPress hosting is great for beginners or those who are more focused on the content itself than the nuts and bolts of network engineering. The only partial caveats is, of course, if your online presence will hinge on something besides WordPress, perhaps needing Drupal or Joomla, then you’d be better off getting a more sophisticated package deal. But for most web businesses, from sole proprietors to budding enterprises, WordPress is a flexible one-size-fits-all solution. + +![Avatar][6] + +[Mark Hanson][7] + +[![][8]][9] + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/should-i-choose-a-managed-wordpress-hosting/ + +作者:[Mark Hanson][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://opensourceforu.com/author/mark-hanson/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2016/09/WordPress.jpg?resize=696%2C421&ssl=1 (WordPress) +[2]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2016/09/WordPress.jpg?fit=750%2C454&ssl=1 +[3]: https://en.wikipedia.org/wiki/WordPress +[4]: https://www.softaculous.com/docs/enduser/create-staging/ +[5]: https://www.greengeeks.com/tutorials/article/how-to-install-wordpress-using-softaculous/ +[6]: https://secure.gravatar.com/avatar/e827144d3e2406d876d7222a4ac74782?s=100&r=g +[7]: https://opensourceforu.com/author/mark-hanson/ +[8]: https://opensourceforu.com/wp-content/uploads/2019/11/assoc.png +[9]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/sources/talk/20191119 Fortinet CEO- Network and security technologies give rise to security-driven networking.md b/sources/talk/20191119 Fortinet CEO- Network and security technologies give rise to security-driven networking.md new file mode 100644 index 0000000000..6a0ace8da9 --- /dev/null +++ b/sources/talk/20191119 Fortinet CEO- Network and security technologies give rise to security-driven networking.md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Fortinet CEO: Network and security technologies give rise to security-driven networking) +[#]: via: (https://www.networkworld.com/article/3453326/fortinet-ceo-network-and-security-technologies-give-rise-to-security-driven-networking.html) +[#]: author: (Zeus Kerravala https://www.networkworld.com/author/Zeus-Kerravala/) + +Fortinet CEO: Network and security technologies give rise to security-driven networking +====== +A conversation about the future of network security with Fortinet CEO Ken Xie +The network and security industries both continue to evolve at a rate never seen before.  Historically, security and network operation teams have worked in parallel with one another, sometimes being at odds with each other's goals. + +However, that is changing as businesses rely on their networks to operate. It’s fair to say that today, for many companies, the network is the business. As this happens, network and security technologies need to be more closely aligned giving rise to the concept of security-driven networking. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][1] + +In this post, ZK Research had a chance to sit down with the co-founder and CEO of Fortinet Ken Xie to discuss the future of networking and security.  + +[][2] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][2] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +**ZK: With things like digital transformation and [5G][3] constantly changing networks, where are we in terms of security today? Is security keeping up?** + +**Xie:** Security has to always be evolving. For a long time, security was all about securing connections. First-generation [firewalls][4] were placed between a LAN and the Internet to prevent criminals from gaining access to network resources. As those connections became faster, and more data was embedded in applications, security had to switch its focus from connections to the content. That’s when the second generation of network security began, with the introduction of the [next-generation firewall] NGFW. + +While those second-generation security tools have served their purposes, they no longer meet the needs of today’s digital businesses. Security can no longer function as a moat around a castle. Instead, today’s digital networks and data are distributed across growing numbers of virtual clouds, edges, and physical devices. Data is not only highly mobile, but it is also at greater risk as the attack surface increases. And as new edge networks emerge, driven by 5G and [SD-WAN][5], the challenges will only get bigger. + +In this new digital world, security needs to not only be integrated into the network but also help drive its development. With many new networking environments, such as [multi-cloud][6], next-gen branch, and the mobile edge, the challenge many organizations face is building a consistent and manageable security framework that can span digital innovation. Achieving this requires a security-driven networking strategy that not only asks, “How do we secure this?” but also, “How will this become part of our larger security-fabric architecture?”  + +Part of the answer involves solutions that seamlessly interoperate with security deployed across the network, such as in the cloud. Security-driven networking ensures that whenever networking infrastructures evolve or expand, security automatically adapts as an integrated part of the network rather than waiting to respond to changes, as traditional overlay security solutions do, which can introduce security gaps and inefficiencies. + +Other top concerns for both networks and security are performance and interconnectivity. Network and security policies both need to follow applications at digital speeds, especially as they move across and between different connected networks. The days of bolting on security and expecting it to protect businesses and consumers are over. To keep pace with the ongoing digital transformation of our interconnected environments, security and the network will have to converge. This is the only way that threat detection and prevention can continue to span the evolving network and respond at network speeds. + +Only security-driven and security-enabled networks will be able to ensure that detection and prevention are woven into every transaction, and then follow those transactions from origin to completion to ensure they are protected along their entire data path. + +**ZK: How does [the edge][7] factor into security, both today and going forward?** + +**Xie**: Traditionally, we interacted with the cyber world through a specific interface, such as a laptop or smart device. However, in this new digital world, traditional networks are being completely transformed. [Data centers][8] are moving to the cloud. Technology is converging with our physical world in the form of smart cars and wearables and even embedded devices and interactive communities. And for that to work, data and compute services will also need to be positioned at the edge, processing data locally. And rather than relying on one or two interfaces, we are now interacting with technology everywhere. + +The number of connected things already outnumbers people and will continue to grow quickly. A smart home today can have many different edges – smart appliances, voice-activated assistants, laptops, smartphones, connected security systems such as smart locks, and entertainment systems. To provide consistent protection for all of these connections, security will have to exist simultaneously in all of them. It has to be woven directly into the infrastructure. There is really no other way for this to work. + +**ZK:** **What are some of the security challenges of the growing [WAN][9] edge?** + +**Xie:** Next-gen branches and SD-WAN are perfect examples of how second-generation security no longer supports modern networking challenges. Organizations are moving to SD-WAN because their [MPLS][10] connections are too rigid for device and application interconnectivity. Traditional hub and spoke models don’t work because the central network hub is disappearing. And while an overlay [VPN][11] solution can support meshed connections between different branch offices, encrypting traffic isn’t enough either. + +SD-WAN is a great starting point to deeply interconnect security and networking into a single solution and where Fortinet has focused. SD-WAN needs to provide connectivity plus support advanced routing protocols, such as load balancing and optimizing connections and provide advanced security. If not, that branch will become the weakest link in your security chain. By tying those elements together into a single solution, and integrating network and security management into a single interface, organizations can realize the performance and interconnectivity benefits of tying networking and security solutions together. +A Secure SD-WAN strategy not only provides business-critical SaaS and productivity applications, and enables and secures live connections between all branch and cloud environments, it can also tie the local-branch LAN to the WAN to support and secure its functions as well. A truly integrated solution can support things like true zero-touch deployment, integrated and centralized management, and advanced traffic and connection management for network and security functions. + +**ZK: How do we provide adequate security performance as the edge becomes everywhere?** + +**Xie:** As end-user devices, applications and [IoT][12] grow and converge, billions of new edges will be created. Many of these edges will create and enable new immersive technologies, such as VR and AR-based communications and interactive tools that tie multiple services together, which will further enable things like autonomous cars and smart cities.  As solutions like these continue to evolve, they will further converge the physical and cyber worlds. Transactions and decisions will need to be made in microseconds, and they will need to be made locally, which means that decision-making can no longer rely on human intervention, whether you are talking about routing traffic, reacting to a physical event or responding to a cyber threat. + +In this new digital world, performance and interconnectivity are table stakes. So network and security convergence is not just about policies and protocols. The true performance will require the implementation of specialized physical and virtual processors that can accelerate decision making. We have spent years refining specially designed security processors that provide unmatched performance at a fraction of the cost of the traditional CPUs used by other vendors. And these aren’t just limited to security. Our new SD-WAN solutions include the world’s first customized processors designed to accelerate both security and networking functions so branch offices can function at the speeds that the digital marketplace requires. +We have also taken those same specialized engineering skills and developed new virtual ASICs to provide the same level of performance acceleration in a virtual environment. These new virtual security processors provide up to two to three  times the performance of traditional virtualized security solutions. This enables us to extend full advanced security solutions to the new 5G-powered network edge and still inspect encrypted data, accelerate local decision making, and support edge networking and computing at network-required speeds. + +**ZK: Is the edge going to replace the cloud?** + +**Xie:** We are going to need both, and they are going to have to be closely aligned. But the edge is going to push digital transformation in another new direction, and organizations need to get ready for that now. +Because of transactional timing requirements, compute resources have always had to be as physically close to data as possible. Mainframes were deployed inside physical data centers for this reason. Applications forced smartphones to be faster and smarter so decisions didn’t have to be made on some remote server. Today, as we move data from the physical data center to the cloud, compute resources have been deployed there as well so that the large amounts of data being collected by today’s businesses can be processed with scale and agility. + +The next big migration of data will be to the remote edge. IoT and mobile devices will need to support immersive technologies, which will require massive amounts of data and processing power. And for those services to respond at the speeds that applications and consumers require, data and computing resources will need to be placed on edge devices. This change will not only have a significant impact on networks but on how and where we deploy and manage security. + +This will affect security in two ways. First, to secure an edge built from an enormous number of interconnected devices, security will need to focus on prevention, which is a lot harder. And second, security will need to operate natively on those edge devices. That’s because high-performance transactions will not only require immediate decision-making, but they will also be rapidly moving across any number of edge devices through new edge-based networks. If security is to keep up, it will need to be converged with the edge and live on new edge-based IoT and networking devices.   + +And even then, things like AI are going to have to be built into the next generation of security solutions to meet the performance demands of 5G networks and beyond. Which is why Fortinet has spent the past decade building, training, and refining the largest and most comprehensive artificial neural network designed for security in the world. This AI network currently includes over billions of interconnected nodes, and since its training cycles were completed, it has now taken over critical threat detection and analysis functions that previously required teams of trained researchers to accomplish. And this success is why we have now begun to weave its advanced AI technology into our portfolio of security solutions – a feat that, like our advanced security and networking processors, no other vendor is even close to replicating. + +**Now see** [**Network pros react to new Cisco certification curriculum**][13] + +Join the Network World communities on [Facebook][14] and [LinkedIn][15] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3453326/fortinet-ceo-network-and-security-technologies-give-rise-to-security-driven-networking.html + +作者:[Zeus Kerravala][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.networkworld.com/author/Zeus-Kerravala/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.networkworld.com/article/3203489/what-is-5g-how-is-it-better-than-4g.html +[4]: https://www.networkworld.com/article/3230457/what-is-a-firewall-perimeter-stateful-inspection-next-generation.html +[5]: https://www.networkworld.com/article/3031279/sd-wan-what-it-is-and-why-you-ll-use-it-one-day.html +[6]: https://www.networkworld.com/article/3429258/real-world-tools-for-multi-cloud-management.html +[7]: https://www.networkworld.com/article/3224893/what-is-edge-computing-and-how-it-s-changing-the-network.html +[8]: https://www.networkworld.com/article/3223692/what-is-a-data-centerhow-its-changed-and-what-you-need-to-know.html +[9]: https://www.networkworld.com/article/3248989/what-is-a-wan-wide-area-network-definition-and-examples.html +[10]: https://www.networkworld.com/article/2297171/network-security-mpls-explained.html +[11]: https://www.networkworld.com/article/3268744/understanding-virtual-private-networks-and-why-vpns-are-important-to-sd-wan.html +[12]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[13]: https://www.networkworld.com/article/3446044/network-pros-react-to-new-cisco-certification-curriculum.html +[14]: https://www.facebook.com/NetworkWorld/ +[15]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191119 SD-WANs Enable Scalable Local Internet Breakout but Pose Security Risk.md b/sources/talk/20191119 SD-WANs Enable Scalable Local Internet Breakout but Pose Security Risk.md new file mode 100644 index 0000000000..00d559727b --- /dev/null +++ b/sources/talk/20191119 SD-WANs Enable Scalable Local Internet Breakout but Pose Security Risk.md @@ -0,0 +1,58 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (SD-WANs Enable Scalable Local Internet Breakout but Pose Security Risk) +[#]: via: (https://www.networkworld.com/article/3454282/sd-wans-enable-scalable-local-internet-breakout-but-pose-security-risk.html) +[#]: author: (Zeus Kerravala https://www.networkworld.com/author/Zeus-Kerravala/) + +SD-WANs Enable Scalable Local Internet Breakout but Pose Security Risk +====== + +NatalyaBurova/istock + +SD-WAN streamlines how application traffic is routed from the branch, making it easier to create local internet breakout and allowing users to access cloud services directly from the branch. In an ideal [SD-WAN][1] scenario, every remote location and device has its own local internet breakout and corresponding security services. Yet, reality looks a lot different for many companies.  + +This is something network professionals have wanted to enable for decades. The problem was that setting up local internet breakout using traditional routers was not trivial and required a tremendous amount of engineering work so most businesses, except for the ones that had high levels of technical talent shied away. The shift to cloud and edge computing has made local internet breakout almost mandatory today, so businesses have turned to SD-WAN as a simpler path to enable it. As this happens, organizations need to understand the security risks.  + +Using broadband internet services to quickly send enterprise application traffic has many benefits, but it’s also risky since it exposes users and their local networks to the untrusted public internet. As [previously mentioned][2] in another post, EMA’s [WAN Transformation research][3] found companies that exclusively relied on the native security features in their SD-WAN devices were 1.3 times more likely to have a data breach, compared to those who supplemented their SD-WAN with additional layers of security.  + +Local internet breakout is a modern approach to the SD-WAN; it provides application awareness and automation that cannot be achieved with traditional routers. However, security shouldn’t be an afterthought when deploying it. Not all local internet breakout solutions can administer application-specific security policies in real-time or keep up with SaaS/IaaS changes and updates. + +In order to deliver the highest SaaS and IaaS performance, there are several local internet breakout requirements that must be addressed: + + * Application-driven security policies must be supported for all apps running over broadband internet + * Performance must be optimized without compromising security + * Security must be enforced with an integrated firewall to safeguard the branch from potential threats + * Service chaining to next generation firewalls or cloud-delivered security services must be automated + + + +When security enforcement is positioned close to branch locations, local internet breakout can provide enterprises with the desired application performance and protection. + +That’s where moving security to the cloud comes in. Cloud-hosted security services help enterprises centralize the entire security stack in the cloud instead of deploying costly security appliances at each branch location. A cloud-hosted security stack, like [Zscaler][4] or [Check Point][5], includes next-gen firewall services, as well as intrusion detection and prevention, URL filtering, antivirus protection, sandboxing, and much more. + +By shifting away from a hub-and-spoke architecture to a cloud-enabled architecture, enterprises can reduce cost and complexity, offer a better user experience, simplify their operations, and deploy new services faster—all without compromising security.  + +Learn more about how we can help with secure local internet breakout with SD -WAN at [SilverPeak.com][6] + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3454282/sd-wans-enable-scalable-local-internet-breakout-but-pose-security-risk.html + +作者:[Zeus Kerravala][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.networkworld.com/author/Zeus-Kerravala/ +[b]: https://github.com/lujun9972 +[1]: https://www.silver-peak.com/sd-wan/sd-wan-explained +[2]: https://blog.silver-peak.com/integrations-are-essential-to-secure-sd-wan +[3]: https://www.enterprisemanagement.com/research/asset.php/3683/Wide-Area-Network-Transformation:-How-Enterprises-Succeed-with-Software-Defined-WAN +[4]: https://www.silver-peak.com/sites/default/files/infoctr/zscaler-silver-peak-solution-brief.pdf +[5]: https://www.silver-peak.com/sites/default/files/infoctr/silver-peak-solution-brief-point-silver-peak-1019.pdf +[6]: http://www.silverpeak.com/ diff --git a/sources/talk/20191120 3 emerging open source projects to keep an eye on.md b/sources/talk/20191120 3 emerging open source projects to keep an eye on.md new file mode 100644 index 0000000000..937dde5839 --- /dev/null +++ b/sources/talk/20191120 3 emerging open source projects to keep an eye on.md @@ -0,0 +1,102 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (3 emerging open source projects to keep an eye on) +[#]: via: (https://opensource.com/article/19/11/emerging-projects) +[#]: author: (James Mawson https://opensource.com/users/dxmjames) + +3 emerging open source projects to keep an eye on +====== +Check out these early-stage open source projects that show real promise. +![One lightbulb lit out of several][1] + +The exciting thing about open source is that nobody needs permission to try something new. That's a formula that allows new ideas to emerge all the time. + +Here are three open source projects that are still in their early stages but show real promise. + +### Glimpse + +[Glimpse][2] is a recent fork of the [GNU Image Manipulation Program][3], a well-known and long-running open source project. It's unusual in that the biggest (but not the only) reason for forking is to rebrand it. + +So what's wrong with the name GNU Image Manipulation Program? Well, it abbreviates as "gimp," and in large parts of the English-speaking world, that is a slang word with a variety of derogatory and sexual meanings. + +Headlines have characterized the problem as "[the name is offensive][4]." I'm not sure that totally nails the issue—when I dug into it, I couldn't find anyone claiming strong offense. + +What _does_ come up again and again is that people can't get a fair hearing for the application because of the name. In any kind of grown-up or professional context, the suggestion to use GIMP isn't taken seriously. For most of the world, there's probably little at stake in this, but English-speaking countries account for almost a quarter of the world's economy. That's not nothing. + +Tech journalist Bryan Lunduke thinks [Glimpse isn't ideal branding, either][5], and perhaps he has a point. But for everyone who just wants the open source option to get a fair hearing, that's a second-order concern. + +The Glimpse team has not declared any hostility to the parent project and has even shared some donation money upstream. + +One of the exciting possibilities of this friendlier brand name is that it could open the software up as an option in education settings. This would be a win for the free software movement as a whole. + +### The Editable PDF Initiative + +Anyone with a desk job eventually learns the displeasure of using multiple software packages to put together a really complex document. It's one thing to write a quick letter or article in a word processor. But when you're jugging charts, graphs, tables, data, and images between applications, databases, and programming libraries, it can be quite a headache. + +Often, people end up solving the problem by cutting-and-pasting things using the mouse—especially for the one-off jobs that crop up all the time. We do this manually, even when there are ways to automate the task, because the tools don't work the way we want them to, and different programs aren't written to talk to each other. + +Dr. Tamir Hassan is a document engineering veteran on a one-man mission to fix this with the [Editable PDF Initiative][6]. It is an open, universal standard for document files that any program could use to interact with a document or its individual elements, such as images or tables. + +Editable PDF aims to be an extension of existing PDF standards, which provide the only guarantee of consistent presentation across applications and devices. At the moment, PDF documents are basically just vector files, not built to edit at all. + +[As Dr. Hassan said recently][7]: "Perhaps you would like to edit the text in Word, but make fine adjustments to the layout in InDesign? It's very difficult to switch between different programs today, but Editable PDF, a universally editable format, will let you do exactly that." + +Editable PDF has great potential to benefit open source software in particular. In contrast to non-standard file formats, a universal format that's truly portable creates an even playing field for the best software to win. + +Moreover, one of the big barriers for Linux to go mainstream on the desktop is that so many business users feel extremely attached to Microsoft Word. The open source movement has replied by saying, "well, if we try, we could make ours just as good." But maybe the mindset we really need is, "hey, let's do something many times better." + +### Endeavour OS + +Ahh… [Arch][8]: the Linux so notorious, it became a meme. + +But there's more going on than just, "I use Arch, btw." Part of Arch's notoriety is how intimidating it can be to install. + +This is why some people have gravitated to other distributions built on Arch, such as [Manjaro][9] and—until recently—[Antergos][10]. + +When the Antergos developers had to abandon the project due to lack of time, they left quite a community behind. Out of this, [EndeavourOS][11] was born. + +EndeavourOS might be a spiritual successor to Antergos, but it's not a fork. The team has come up with a lightweight, Arch-based operating system of its own. + +So if Manjaro offers an "Arch made easy" experience, why would you install Endeavour OS? Well, while Manjaro is based on Arch, it's got quite a lot of its own thing going on as well. EndeavourOS is quite close to pure Arch—with an Xfce desktop environment and a graphical installer along for the ride. + +EndeavourOS also advertises an open and friendly community for curious beginners—its front page even says: "Stupid questions simply don't exist with us." + +In just a few months, EndeavourOS has already delivered its first stable release, but it is still an extremely young initiative. + +One thing that really appeals to me about EndeavourOS is the clarity of its ethos. Some Linuxes are all about the data center and the server room; others aim to be the most user-friendly desktop daily driver for the broadest audience. A few have an identity crisis, caught between these things. So, where does EndeavourOS fit in all this? + +This Linux is utterly unapologetic in catering to technology hobbyists, enthusiasts, and power users. It's for the amateurs, in that best and most original sense of the word—those who love what they do. Awesome. So isn't Endeavour the perfect name? + +If what you want is to roll your sleeves up and level up while still enjoying a gentle start and a friendly community, this could be a great way to go about it. + +_What other new open source projects are you keeping an eye on? Please share in the comments._ + +Explore the open source alternatives to Adobe Acrobat for reading, creating, and editing PDF files. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/emerging-projects + +作者:[James Mawson][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/dxmjames +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_lightbulbs.png?itok=pwp22hTw (One lightbulb lit out of several) +[2]: https://glimpse-editor.org/ +[3]: https://www.gimp.org/ +[4]: https://itsfoss.com/gimp-fork-glimpse/ +[5]: https://www.youtube.com/watch?v=CV1HZU4KFHc +[6]: https://editablepdf.org/ +[7]: https://dxmtechsupport.com.au/editable-pdf-interview +[8]: https://www.archlinux.org/ +[9]: https://manjaro.org/ +[10]: https://antergos.com/ +[11]: https://endeavouros.com/ diff --git a/sources/talk/20191120 Intel targets Nvidia (again) with GPU and cross-processor API.md b/sources/talk/20191120 Intel targets Nvidia (again) with GPU and cross-processor API.md new file mode 100644 index 0000000000..b145a22fc0 --- /dev/null +++ b/sources/talk/20191120 Intel targets Nvidia (again) with GPU and cross-processor API.md @@ -0,0 +1,80 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Intel targets Nvidia (again) with GPU and cross-processor API) +[#]: via: (https://www.networkworld.com/article/3454497/intel-targets-nvidia-again-with-gpu-and-cross-processor-api.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Intel targets Nvidia (again) with GPU and cross-processor API +====== +Intel is looking to offer a unified CPU, GPU, and platform architecture that Nvidia doesn’t have but AMD does. +Martyn Williams/IDG + +Third time’s the charm? Intel is hoping so. It released details of its Xe Graphics Architecture, with which it plans to span use cases from mobility to high-performance computing (HPC) servers – and which it hopes will succeed where its [Larrabee][1] GPU and [Xeon Phi][2] manycore processors failed. + +It’s no secret Intel wants a piece of the high-performance computing HPC action, given that it introduced the chip and other products at it Intel HPC Developer Conference in Denver, Colo., this week just ahead of the Supercomputing ’19 tradeshow. + +**Don't miss** [**10 of the world's fastest supercomputers**][3] + +[][4] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][4] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +Intel bills the Xe Graphics Architecture card as its first "exascale graphics card," based on a new 7nm architecture called “Ponte Vecchio.” Intel is splitting the Xe Architecture into three designs for different segments: [data center][5], consumer graphics cards, and AI use-cases; integrated graphics for processors; and the high-tier Xe HPC for high performance computing. + +Rather than use the large die for its graphics chips the way Nvidia and AMD do it, Intel is using the Multi-Chip Module (MCM) design that breaks up one big chip into smaller “chiplets” that are connected via a high speed fabric. This is how AMD designed the [Ryzen and EPYC CPUs][6], something Intel initially pooh-poohed but is since [adopting][7] for its Xeons. + +These modules also use other packaging technology advancements such as Foveros 3D chip-packaging technology, which allows for 3D stacking of dies and mixing of CPU, AI, and GPU processors, High Bandwidth Memory (HMB) and Embedded Multi-Die Bridge (EMIB) technology to tie the HBM packages to the compute die. + +Xe Architecture cards will also come with a new scalable fabric called XE Memory Fabric (XEMF), which ties compute and memory together with a coherent memory interface that Intel claims will allow Xe to scale to thousands of nodes. + +Kevin Krewell, principal analyst with Tirias Research, noted that this is not a brand-new graphic architecture, it’s an evolution from Intel’s integrated GPU technology that has been a part of its consumer Core CPUs for several years and has been steadily maturing. + +“This is a design that is more like traditional graphics. [Intel is starting] with their traditional integrated graphics cores and building on top of that. Larrabee tried a GPU built on a CPU. In this case they are building a ground up GPU with GPU-like features and not trying to do anything too weird. And now they've got a real GPU guy running the group,” he said. + +Krewell is referring to Raja Koduri, senior vice president of the company's Core and Visual Computing Group. Koduri has one hell of a resume. He was the brains behind AMD integrating CPU and GPU cores on one die (yet another example of AMD leading) and then went to Apple where he pioneered the [Retina display][8]. So if Intel can’t get graphics right with this guy there is no hope. + +### Taking Aim At CUDA + +One thing that has been a huge boon to Nvidia is its CUDA language for programming GPUs. Intel is taking aim and then some at CUDA with its new OneAPI programming model, which Intel designed to simplify programming across not only its GPU but CPU, FPGA, and AI accelerators as well. + +This means applications can move seamlessly between Intel's different types of compute architectures. If an application is best processed on an FPGA, then it will be processed there. Same for CPUs, GPUs, and AI accelerators. If that’s not enough, Intel has the Data Parallel C++ Conversion Tool to take CUDA code and port it to OneAPI. If they pull this off, it would be a huge advantage over Nvidia, since CUDA is only for its GPUs. + +Interestingly, Intel said OneAPI will be open-source and will also work with other vendors' hardware, although they didn’t say whose. If it ends up ported to AMD’s platform, well, that would be entertaining. + +“It’s more than a shot at CUDA because they want to replace CUDA,” said Krewell. “OneAPI is a very ambitious program, trying to combine all of the different processor elements under one umbrella API. So it’s a very aggressive program and they are building it out piece by piece.  But right now it’s at version 0.5. CUDA is at version ten. So they've got a ways to catch up.” + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][9] + +Join the Network World communities on [Facebook][10] and [LinkedIn][11] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3454497/intel-targets-nvidia-again-with-gpu-and-cross-processor-api.html + +作者:[Andy Patrizio][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.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/2239992/intel-nurses--black-eye--on-larrabee--as-amd--nvidia-get-to-work.html +[2]: https://www.networkworld.com/article/3296004/intel-ends-the-xeon-phi-product-line.html +[3]: https://www.networkworld.com/article/3236875/embargo-10-of-the-worlds-fastest-supercomputers.html +[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[5]: https://www.networkworld.com/article/3223692/what-is-a-data-centerhow-its-changed-and-what-you-need-to-know.html +[6]: https://www.networkworld.com/article/3321943/amd-s-road-to-the-data-center-and-hpc-isn-t-as-long-as-you-think.html +[7]: https://www.networkworld.com/article/3408177/intel-unveils-new-3d-chip-packaging-design.html +[8]: https://www.networkworld.com/article/2211314/iphone-4-s-retina-display-explained.html +[9]: https://www.networkworld.com/newsletters/signup.html +[10]: https://www.facebook.com/NetworkWorld/ +[11]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191120 What makes a programming exercise good.md b/sources/talk/20191120 What makes a programming exercise good.md new file mode 100644 index 0000000000..e924ffc090 --- /dev/null +++ b/sources/talk/20191120 What makes a programming exercise good.md @@ -0,0 +1,158 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What makes a programming exercise good?) +[#]: via: (https://jvns.ca/blog/2019/11/20/what-makes-a-programming-exercise-good/) +[#]: author: (Julia Evans https://jvns.ca/) + +What makes a programming exercise good? +====== + +I’ve been thinking about programming exercises lately, because I want to move into teaching people skills. But what makes a good programming exercise? I [asked about this on Twitter today][1] and got some useful responses so here are some criteria: + +### it’s fun + +This one is sort of self-explanatory and I think it’s really important. Programming is fun and learning is fun so I can’t see why programming exercises would need to be boring. + +### it teaches you something you care about + +I don’t think this has to strictly mean “relevant to your job right this second” – people don’t just have jobs, we also want to make art and games and fun personal projects and sometimes just understand the world around us. But it’s important to know what goals the exercise can help you with and what it’s related to! + +Some arbitrary examples: + + * take an image of something from a website and reproduce it from scratch with CSS (towards using CSS to make your own websites that look awesome) + * write a webserver from scratch without any frameworks (to learn the HTTP protocol, so that you can debug issues with a real webserver more easily) + * write a small raytracer (so you can make cool art with raytracing techniques on shaderhub!) + * write a tiny bit of assembly (as a very initial step towards understanding of what Spectre and Meltdown are even about and why we need to make all our computers run slower to prevent them) + + + +### it’s a challenge + +I don’t know if this is everyone’s experience but I often start programming exercises and get bored quickly (“oh, I know how to do this, this is boring”). For me it’s really important for the exercise to teach me something I really don’t know how to do and that’s a little bit hard for me. + +My favourite set of programming exercises is the [cryptopals crypto challenges][2] because they get harder pretty fast – by exercise #6, you’re already breaking toy encryption protocols, and by #12 you’re breaking an Actual Encryption Protocol (AES in ECB mode)! + +### you can tell if you succeeded + +It’s easy to write exercises that are too vaguely specified (“write a toy tcp stack!“). But what does that mean? How much of a TCP stack am I supposed to write? Having test cases and clear criteria for “yay! you did it! congratulations!” is really important. + +### you can do it quickly + +In less than 2-3 hours (an evening after work), say. It’s hard to find time to spend like 8 hours on an exercise unless it’s REALLY exciting. + +I also think that giving some specific real-world benchmark data seems nice (“I did this from scratch in 97 minutes”). + +### the author believes in you + +This is a bit fuzzier but very lovely – [this person on Twitter wrote][3]: + +> Similar to that, the writing is patient and gives me the impression that it believes in my ability to accomplish the task. … I learned a ton in the early days from Linux HOWTOs. Some gave me the sense that it was impossible to fail. Just follow the steps. It’s all there. + +Especially if you’re doing a somewhat challenging exercise like we talked about above, I think it’s nice for the author to believe in your! (and of course it’s crucial that they’ve actually written the exercises so that they’re _right_ and you can likely do the thing!) + +### it’s been tested + +I read the (great) biography [Dearie: The Remarkable Life of Julia Child][4] recently and one thing that stood out to me is that she _tested_ all of the recipes in Mastering the Art Of French Cooking. It took her _years_ to write the book and test the recipes and make sure that American home cooks actually had access to all the ingredients and had the. + +I don’t think all cookbook authors test their recipes, but I think testing really improves cookbooks. + +I started writing some SQL exercises (like [this prototype of one on GROUP BY][5]) a while back, and at some point I realized the big thing holding me back was that I didn’t have testers! I couldn’t find out if people were actually learning from them or not! + +This is a new thing for me because when I write blog posts I don’t test them (I barely even proofread them!). I just write them and publish and people often like them and that’s it! I said to [Amy Hoy][6] (who is amazing) on Twitter that I didn’t understand why you have to test exercises if you don’t have to test blog posts and she [pointed out][7] that people have much higher expectations for exercises than for blog posts – with the blog posts you maybe expect to learn 1-2 new facts, but with exercises you expect to actually develop a new skill! + +Also, people are often investing a lot more time in exercises (especially if they have to set up a dev environment or something!), so it’s extra important to make sure that they actually work. + +### you won’t get stuck + +It’s SO EASY to get stuck on some random irrelevant point in a programming exercise that’s totally unrelated to the skill you’re trying to learn. For example there might be an easily-avoidable mistake that you can make with the exercise and spend a lot of time debugging but it doesn’t actually teach you a lot. + +### it’s easy to get help + +If you’re doing a challenging exercise, you might want to get help from your friends / colleagues / the internet! + +Some things that can go wrong: + + * None of your friends have ever heard of the thing the exercise is teaching so you can’t talk about it with them + * The exercise expects you to be using the newest version of some software, but actually all the examples on the internet are for some older version so it’s difficult to search for help even though the exercise is technically correct + * The community around the tech used in the exercise is hostile/unhelpful + + + +One obvious way to accomplish this is by letting people use the programming language they’re most comfortable in, because they probably already know how to Google for help in that environment. + +### no time-consuming setup required + +Installing software is boring, and a lot of programming projects require installing software! A few things that can go wrong with this (though there are a lot more than this!) + + * I get a compiler error when I try to install this package on my computer + * The example actually requires some very specific package versions to work properly and if you don’t have those exact versions installed you get a bunch of cryptic errors and need to google for 3 hours to fix them + + + +This kind of thing is a huge waste of time and super demoralizing. And it’s not trivial to avoid! If you’re trying to teach someone a specific piece of software, often that software + +A few options I’ve seen or used to manage this: + + * tell people what you know works (“I’ve tested this in Mac/Linux but not Windows”) + * avoid requiring any software to be installed (“just use python”) + * use Docker to run everything + * run all the code in the person’s browser (because browsers usually do about the same thing) + * use a cloud system (so everything runs on someone else’s computer). This is what I do for my [pandas cookbook][8], which lets you run it in Binder, this really great free service for hosting Jupyter notebooks. + + + +### it’s easy to extend + +@tef has this great talk on Scratch [A million things to do with a computer!][9] which explains the 3 ideas of Scratch: + + * low floors + * wide walls + * high ceilings + + + +It sucks when you start learning something and then learn that what you can do with the Thing is very limited! It’s exciting when you learn something and see “oh, wow, there are SO MANY POSSIBILITIES, what if I did X instead?” + +### that’s a lot of things! + +The criteria we arrived at: + + * fun exercises + * that teach you something you care about + * that are challenging + * with clear success criteria + * that can be done quickly + * with no complicated setup + * and few hidden gotchas + * using a tech stack that’s easy for you to get help with + * where there’s a lot of room to grow + + + +That seems pretty hard, but it seems like a good goal to aspire to! I’m going to keep very slowly working on exercises! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/11/20/what-makes-a-programming-exercise-good/ + +作者:[Julia Evans][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://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://twitter.com/b0rk/status/1197282185230860288 +[2]: https://cryptopals.com/ +[3]: https://twitter.com/mojavelinux/status/1197323090427953152 +[4]: https://www.amazon.com/exec/obidos/ASIN/0307473414/metafilter-20/ref=nosim/ +[5]: https://joins-238123.netlify.com/aggregations/ +[6]: https://stackingthebricks.com/ +[7]: https://twitter.com/amyhoy/status/1197291805449940993 +[8]: https://github.com/jvns/pandas-cookbook +[9]: https://www.youtube.com/watch?v=vU9myNJI9l4 diff --git a/sources/talk/20191121 Cumulus Networks updates its network-centric Linux distribution.md b/sources/talk/20191121 Cumulus Networks updates its network-centric Linux distribution.md new file mode 100644 index 0000000000..77c718bde7 --- /dev/null +++ b/sources/talk/20191121 Cumulus Networks updates its network-centric Linux distribution.md @@ -0,0 +1,64 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Cumulus Networks updates its network-centric Linux distribution) +[#]: via: (https://www.networkworld.com/article/3454338/cumulus-networks-updates-its-network-centric-linux-distribution.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Cumulus Networks updates its network-centric Linux distribution +====== +Company says its Linux is to networking what Red Hat is to servers. +Thinkstock + +The [Linux][1] distribution ecosystem is pretty set, with Red Hat and Canonical in the leadership positions, followed closely by SuSe and home brews from the likes of IBM and other major vendors. Even Microsoft has its own distro for Azure users. + +And then there is Cumulus Networks, which specializes in networking software. It just released Cumulus Linux 4.0 and NetQ 2.4, its cloud network deployment and management console. With this release, Cumulus is claiming its Linux is its most stable and reliable software stack yet and NetQ is the most comprehensive end-to-end network automation product. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][2] + +Roopa Prabhu, chief Linux architect at Cumulus, said that just as Red Hat Enterprise Linux is designed for servers, Cumulus Linux is specifically designed for networking. + +**[ [Become a Microsoft Office 365 administrator in record time with this quick start course from PluralSight.][3] ]** + +"Unlike RHEL, Ubuntu or Suse, Cumulus Linux is specially designed for the unique needs of a network device, like a [data-center][4] switch," he said in an email to me. "Cumulus Linux comes packaged with drivers for data-center switch hardware, the latest and greatest in Linux-kernel networking, a rich networking protocol stack with Free Range Routing (FRR), multi-homing protocol software, networking tools and Linux defaults optimized for networking.” + +“RHEL for example, complements Cumulus Linux in the data center, rather than compete with it, allowing similar management and orchestration tools across compute and network devices," he added. + +By being native Linux, Cumulus says it provides support for all the tooling and applications of the Linux ecosystem while providing advanced networking features and support, including kernel additions for VRF, VxLAN or the upstreamed ifupdown2 network-interface manager.  + +Cumulus Linux 4.0 includes: + + * Support for 134 hardware platforms across 14 ASICs. + * Support for Mellanox’s Spectrum-2 chipset for faster performance, Broadcom’s Qumran chipset for deep buffering at the top of rack, Facebook’s Minipack – an open, modular chassis with a single 12.8TB chip, and additional campus networking platforms with Dell. + * Migration to the latest and most advanced Linux kernel for greater route scale, the latest security updates, and thousands of contributions from the broader Linux community. + * Support for SwitchDev, an open source in-kernel abstraction model, providing a standardized way to program switch ASICs and speed development time. + * Enhancements to its EVPN implementation (EVPN-PIM and EVPN multi-homing) for Layer 2/Layer3 connectivity. + * Comprehensive end-to-end automation for CI/CD workflows including simulation, validation, troubleshooting and NetDevOps practices such as Infrastructure-as-Code (IaC). + * The ability to build a single fabric across data center and campus environments enabling a common operational model. + *   + + + +Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3454338/cumulus-networks-updates-its-network-centric-linux-distribution.html + +作者:[Andy Patrizio][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.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3215226/what-is-linux-uses-featres-products-operating-systems.html +[2]: https://www.networkworld.com/newsletters/signup.html +[3]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fcourses%2Fadministering-office-365-quick-start +[4]: https://www.networkworld.com/article/3223692/what-is-a-data-centerhow-its-changed-and-what-you-need-to-know.html +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191121 IoT sensors must have two radios for efficiency.md b/sources/talk/20191121 IoT sensors must have two radios for efficiency.md new file mode 100644 index 0000000000..174b47e53f --- /dev/null +++ b/sources/talk/20191121 IoT sensors must have two radios for efficiency.md @@ -0,0 +1,71 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (IoT sensors must have two radios for efficiency) +[#]: via: (https://www.networkworld.com/article/3454404/iot-sensors-must-have-two-radios-for-efficiency.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +IoT sensors must have two radios for efficiency +====== +To extend battery life, IoT radios that send data should be powered only when there's data to send, and a second, power-sipper radio should just listen for a wake-up signal for the principal radio. Academics say they’re making progress getting that all to work. +Jorgen Norgaard / WhatAWin / Getty Images + +For the [Internet of Things][1] to become ubiquitous, many believe that inefficiencies in the powering of sensors and radios has got to be eliminated. Battery chemistry just isn’t good enough, and it’s simply too expensive to continually perform truck-rolls, for example, whenever batteries need changing out. In many cases, solar battery-top-ups aren’t the solution because that, usually-fixed, technology isn’t particularly suited to mobile, or impromptu, ad hoc networks. + +Consequently, there’s a dash going on to try to find either better chemistries that allow longer battery life or more efficient chips and electronics that just sip electricity. An angle of thought being followed is to wake-up network radios only when they need to transmit a burst of data. Universities say they are making significant progress in this area. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][2] + +“The problem now is that these [existing] devices do not know exactly when to synchronize with the network, so they periodically wake up to do this even when there’s nothing to communicate,” explains Patrick Mercier, a professor of electrical and computer engineering at the University of California, San Diego, in a [media release][3]. “By adding a wake-up receiver, we could improve the battery life of small IoT devices from months to years,” he says. + +[][4] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][4] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +### Wake-up + +The school says that the key to getting the wake-up receivers to be useful is to implement them at very high frequencies. The reason: everything gets smaller, including antennas the higher in spectrum one goes. It “allowed researchers to shrink everything, including the antenna, transformer and other off-chip components down into a much smaller package,” the school explains. The school’s solution is at 9 GHz, in X Band. + +The device functions using specific radio signals, called a wake-up signature, being directed at an IoT sensor’s dedicated wake-up receiver chip. That radio can operate with less energy consumption than the data radio chip because its only purpose is to listen for the wake-up signature. UC San Diego’s device uses only 22.3 nanowatts. That’s around half-a-millionth of the power that an LED night light uses, the school claims. Another, more energy-consuming radio, then, which is switched on as necessary by the wake-up radio, performs the more heavy-duty tasks – like actually sending the data. + +Stanford University has also been working on IoT wake-up solutions. [I wrote about its one nanowatt, ultrasound device in 2018][5]. That’s dog-whistle-like frequency. That school, too, is working on the premise that using higher frequencies means one can design smaller electronics packages. The university claimed then on its website that its chip used “about a billionth the power it takes to light a single old-fashioned Christmas bulb.” + +Importantly, both universities’ solutions allow the actual power-hog data radio to be off while not in use, not just dormant or sleeping as is common now. + +### High sensitivity + +UC San Diego believes its X Band device has advantages over anything that has come before on two additional counts. It explains that its design performs well in varied ambient temperatures: It claims usability from 14 F to 104 F. That temperature range means wake-up could be used in implementations outside, such as in the maritime vertical, for example. + +The university also says its sensitivity numbers are the best that have ever been [published in a study][6] at -69.5 dBm. Latency is a trade-off, though, as there’s a 540ms delay. But that’s likely not a problem for much IoT use, like short burst, periodic data sends, such as are used for environmental sensing, for example. + +“These numbers are pretty impressive in the field of wireless communications. Power consumption that low, while still retaining temperature robustness, all in a small, highly sensitive system,” Mercier says. "This will enable all sorts of new IoT applications.” + +Join the Network World communities on [Facebook][7] and [LinkedIn][8] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3454404/iot-sensors-must-have-two-radios-for-efficiency.html + +作者:[Patrick Nelson][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.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[2]: https://www.networkworld.com/newsletters/signup.html +[3]: https://ucsdnews.ucsd.edu/pressrelease/new-chip-for-waking-up-small-wireless-devices-could-extend-battery-life +[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[5]: https://www.networkworld.com/article/3254200/small-wake-up-receivers-could-extend-iot-sensor-life.html +[6]: https://ieeexplore.ieee.org/document/8890666 +[7]: https://www.facebook.com/NetworkWorld/ +[8]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191121 Three-course professional specialization aims to close the gap between the use and understanding of open source in business.md b/sources/talk/20191121 Three-course professional specialization aims to close the gap between the use and understanding of open source in business.md new file mode 100644 index 0000000000..c2f840d1b5 --- /dev/null +++ b/sources/talk/20191121 Three-course professional specialization aims to close the gap between the use and understanding of open source in business.md @@ -0,0 +1,115 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Three-course professional specialization aims to close the gap between the use and understanding of open source in business) +[#]: via: (https://opensource.com/article/19/11/open-source-management-course) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +Three-course professional specialization aims to close the gap between the use and understanding of open source in business +====== +Quickly climb the learning curve of open source with lessons distilled +from experienced practitioners. +![Coding on a computer][1] + +Even though open source software (OSS) is pervasive in IT, many people in business don't understand what open source is and how it differs from proprietary software. [According to Brandeis University][2], "open source software now accounts for between 78% and 98% of all core digital infrastructure, yet few organizational managers understand the business behind it." + +In an effort to close the gap between open source usage and understanding, Brandeis and the [Open Source Initiative][3] (OSI) have launched a three-course specialization in [Open Source Technology Management][4]. After attending an information session about the new program at [All Things Open 2019][5], I was eager to learn more about it and how it will be delivered and assessed, so I reached out to the leadership at Brandeis and the OSI over email for more information. (The interview has been slightly edited for length and clarity.) + +**Don Watkins:** **How will the course prepare students to successfully deploy open source software and effectively engage in open source production?** + +[**Patrick Masson**][6]**,** **OSI general manager and board director:** The OSI receives many questions from all sorts of organizations—companies, governments, non-profits—and individuals who are just beginning to explore open source software. Many of these inquiries share a few common themes around acquisition, implementation, support, and development, such as: How do we "buy" open source software, and where do we send the RFP? Do we need to hire a programmer if we use open source software? Will the open source project provide end-user or technical support? + +The OSI hopes the courses can prepare students by introducing the business case for open source, including business models, the value proposition, organizational practices, and operational and community processes. There are actually three courses: [The Business of Open Source][2], [Open Source Community Development][7], and [Open Source Development Fundamentals][8]. + +**DW:** **How will students be challenged to assess traditional organizational practices and measure their capacity to manage reform in light of the differences presented by open source? Can you teach open source? How do you assess community building? Can it be assessed?** + +[**James Vasile**][9]**, Open Source Technology Management faculty:** I don't want to frame these classes as presenting an approach in opposition to traditional development models. Free and open source software (FOSS) is its own way of fostering technical collaboration. To think of it as "reform" or to define it in terms of other models is to miss the point. Open source strategies are useful, and they often appear right alongside other approaches. + +Open source is a range of practices, a set of licenses, a diverse community, a strategic approach, and even an ethos. There's no one thing to teach. Rather, it's a whole field. Engaging that field can be useful if you know what you're doing. Right now, the primary way people learn the field is by spending a decade contributing to open source efforts. We are distilling the lessons learned by many experienced practitioners and trying to help people climb the learning curve quicker. + +Metrics are, of course, a huge topic in the FOSS world right now. There's no one-size-fits-all way to measure or assess community health and growth. What we do have is a set of context-specific indicators that can fit narratives. These indicators tell you where to dig. You don't know whether you've struck truth or not until you get below the surface. + +**PM:** I'll echo James' comments. From an OSI perspective, we see successful open source projects using a variety of tools and techniques for governance and decision-making, communication and collaboration, community development, project management, design and development, etc. There is no single path to open source, so rather than telling students "how" to do open source, I am hoping we can help students understand "what" makes open source. I think it's about behavior and principles vs. step-by-step processes. + +That's not to say that working with open source software and communities won't introduce change into how organizations operate. Many examples exist. If an organization has formal procurement processes, it may need to reassess how to include open source options that may not be able to participate in typical RFI/RFPs. If an organization is accustomed to driving development around their technologies, they will need to adjust their practices to work with communities. + +One of the really exciting things the courses can provide is real-world case studies that exemplify how organizations—companies, governments, etc.—are successfully engaging with, contributing to, and developing open source software. Each of these companies, I expect, will have discovered unique approaches, but I suspect there will be common themes. The students will learn to identify and understand those so they can take them back to their own organizations. + +**DW:** **What best practice models will be used?** + +**PM:** Each faculty member will employ teaching methods they are most comfortable with. Brandeis also has a fantastic instructional design group that can help faculty develop the courses, create learning resources, and design activities. + +As to the course content, the courses will introduce successful open source projects, as well as provide case studies showing companies that are successful in their adoption of open source. Students will look at what the companies are doing to create community, raise awareness and adoption, manage development, and all the other things vital to open source communities of practice. Then students are tasked to find common themes, shared practices, and even unique traits. These will inform their own work as they move into open source careers. + +[**Carol Damm**][10]**,** **director of programs and assessment for graduate professional studies at Brandeis:** As Patrick explained, students will review examples or case studies of OSS adoption. This is an established teaching approach that enables students to apply the concepts that they are learning to real-world situations. + +**DW:** **How will students learn about the community? Will there be opportunities for them to join open source communities as members? How?** + +**PM:** We have a dedicated course, "[Open Source Community Development][7]," that is designed to help students understand the various roles in communities of practice supporting open source software development, adoption, and maintenance. + +This course presents a great opportunity to have students involved in open source communities as part of the course. The students may not be contributing directly to the projects, but they can do field observations. Getting students to engage with projects to discover how they share information, foster communication, manage financials, make decisions, and all the other critical practices that open source communities need to be successful. + +I'll also offer that the courses can incorporate any open source projects students' companies may be working with—especially if internal contributions are being made upstream. This would provide a powerful opportunity to assess the issues the students' companies are going through, how they resolved them, and what remains. + +**DW: The production of open, distributed, and community-driven software requires design and development methodologies and workflows that support the advantages of peer-to-peer, highly collaborative, iterative production. How will that be facilitated?** + +**CD**: The intent is to create activities and assignments around the workflow and processes that are part of the OSS organizational practices. These activities and assignments will require students to collaborate, creating a relational experience, common to the OSS community. + +**[Ken Udas][11], Open Source Initiative program chair at Brandeis**: Learning is an iterative process and will be facilitated in these courses through exposure to the practice of experienced faculty members and guest lecturers to guide hands-on practice. Although the activities will be determined and developed by the teaching staff, we all want the students to leave with the benefit of practicing under the guidance of knowledgeable practitioners and teachers. + +So, in a particular class, the production process might be introduced through a semester-long case study, perhaps based on an active OSS community or a situation in which there is an internal development or perhaps an effort within an organization to adopt an open source technology and contribute to a community. We are committed to having the teacher and course designer build learning experiences that expose students to practice such that learning can be meaningfully facilitated and iteratively applied. This process will be unique for each teacher. In short, the learner will participate in learning experiences that are facilitated by the instructor with OSS experience, based on practice. + +Iterative and peer-based production in the courses is promoted through exposure through faculty modeling and observation of active OSS communities in practice. Iterative methodologies will be embedded in weekly forum activities and assignments in each course. In addition, it is important to remember that the course itself is subject to interactive development and improvement. Students will also be expected to contribute, using iterative design principles, to the ongoing development of the course along with the teacher and staff. + +**DW:** **What metrics will be used to assess the effectiveness of instruction? How will credit be assigned? What will assessments look like?** + +**CD:** The students will work collaboratively on assignments that present cases either that are given to them or of their choosing, depending on the course, in which they apply the practice that they are learning about. Problem-based learning is a student-centered approach that creates a space for critical thinking and collaborative work. These assignments are graded and aligned to the course outcomes to evaluate students' achievement. + +**KU:** Instructional effectiveness is a matter of student assessment and self-assessment, which is also reflected in the success of learners, as illustrated through the products created during the class. Although the assessments will vary from class-to-class and teacher-to-teacher, they will take the form of artifacts and evidence of methodology in practice. Credit within the class will be in large part determined by the course developer and learning designer but will generally be a balance between group and individual assignment. + +**DW:** **What** **are** **the** **outcomes for students? An MBA focus? Digital badges?** + +**CD: **With the completion of the three courses, students will receive a digital credential in the form of a badge that will carry the details of the credential in its metadata. + +**DW:** **What's in it for the Open Source Initiative? What are the takeaways for the OSI?** + +**PM:** These courses fit squarely into the OSI's mission to "educate about and advocate for the benefits of open source and to build bridges among different constituencies in the open source community." We currently have several other educational initiatives, for example, in K-12 ([FLOSS Desktops for Kids][12]) and for government ([Open Source and Standards Working Group][13]). + +While the OSI has always been active in education and advocacy, our interest in formal educational opportunities was sparked after reading the [Open Source Program Management 2018 Survey][14]. Its key findings highlighted a growing demand for professionals, not necessarily from technical backgrounds, who may be supporting open source within a company: HR staff hiring for roles that support external projects, procurement officers and contract managers who need to engage open source communities, project and product managers who need to work with external organizations, budgeting staff who need to assess ROI on open source implementations. Where are students from MBA or marketing and communications programs, who are interested in working with technology, learning about open source software? + +There are a small but growing number of individual faculty and departments within colleges and universities that include open source software development in their curriculum—usually for technical programs (e.g., CompSci, EE)—however, open source specializations for non-technical disciplines are rare. I only know of [one][15]. The Brandeis specialization allows us to introduce open source into traditional academic programs. + +The Brandeis specialization also allows us to introduce open source to non-traditional learners. The OSI also needs to help the self-directed, self-motivated learners who may have discovered open source software and development through their own personal educational experiences. One of the great opportunities, rightly, touted by open source advocates is access to "learning by doing" made possible through open source communities. Open source projects can reduce barriers to access, allowing non-traditional students to learn to program, discover the latest technologies, gain new skills, even network to build professional relationships. Again, these opportunities are not limited to those seeking technical skills. Open source projects rely on those with business, finance, marketing, communications, and many other skills. Brandeis will also be offering the three courses as a digital badge for individuals who may not be interested in a degree program. + +The OSI recognizes that open source now spans all industries and impacts every department within the organization, from simple end users to maintainers of internally developed projects. The OSI wants to help both those seeking careers in open source and the industries that need those professionals. As a trusted source and recognized authority within the open source community, we feel we can provide guidance on the design and development of courses and content and lend credibility to assure both students and employers that the program will provide a quality, relevant, educational experience. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/open-source-management-course + +作者:[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://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: https://www.brandeis.edu/gps/future-students/learn-about-our-programs/open-source-technology-management.html#business +[3]: https://opensource.org/ +[4]: https://www.brandeis.edu/gps/future-students/learn-about-our-programs/open-source-technology-management.html# +[5]: https://allthingsopen.org/ +[6]: https://www.linkedin.com/in/patrick-masson-4a09b53/ +[7]: https://www.brandeis.edu/gps/future-students/learn-about-our-programs/open-source-technology-management.html#community +[8]: https://www.brandeis.edu/gps/future-students/learn-about-our-programs/open-source-technology-management.html#development +[9]: https://www.linkedin.com/in/jamesvasile/ +[10]: https://www.linkedin.com/in/carol-damm-id/ +[11]: https://www.brandeis.edu/facultyguide/person.html?emplid=9ea81c0b94ebc262f10d2065827733c2e903cafd +[12]: https://opensource.com/article/17/9/floss-desktops-kids +[13]: https://wiki.opensource.org/bin/Working+Groups+%26+Incubator+Projects/OSandStandardsWG/ +[14]: https://todogroup.org/blog/survey-2018/ +[15]: https://www.rit.edu/study/free-and-open-source-software-and-free-culture-minor diff --git a/sources/talk/20191125 8 ways to prepare your data center for AI-s power draw.md b/sources/talk/20191125 8 ways to prepare your data center for AI-s power draw.md new file mode 100644 index 0000000000..2b05df201a --- /dev/null +++ b/sources/talk/20191125 8 ways to prepare your data center for AI-s power draw.md @@ -0,0 +1,142 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (8 ways to prepare your data center for AI’s power draw) +[#]: via: (https://www.networkworld.com/article/3454626/8-ways-to-prepare-your-data-center-for-ai-s-power-draw.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +8 ways to prepare your data center for AI’s power draw +====== +Artificial intelligence requires greater processor density, which increases the demand for cooling and raises power requirements. +Thinkstock + +As artificial intelligence takes off in enterprise settings, so will data center power usage. AI is many things, but power efficient is not one of them. + +For data centers running typical enterprise applications, the average power consumption for a rack is around 7 kW. Yet it’s common for AI applications to use more than 30 kW per rack, according to data center organization [AFCOM][1]. That’s because AI requires much higher processor utilization, and the processors – especially GPUs – are power hungry. Nvidia GPUs, for example, may run several orders of magnitude faster than a CPU, but they also consume twice as much power per chip. Complicating the issue is that many data centers are already power constrained. + +**READ MORE:** [Do you really need high performance computing?][2] + +Cooling is also an issue: AI-oriented servers require greater processor density, which means more chips crammed into the box, and they all run very hot. Greater density, along with higher utilization, increases the demand for cooling as compared to a typical back-office server. Higher cooling requirements in turn raise power demands.  + +[][3] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][3] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +So what can you do if you want to embrace AI for competitive reasons but the power capacity of your existing facility isn’t up to the high-density infrastructure requirements of AI? Here are some options. + +### Consider liquid cooling + +Fan cooling typically loses viability once a rack exceeds 15 kW. Water, however, has 3,000 times the heat capacity of air, according to [CoolIT Systems][4], a maker of enterprise liquid cooling products. As a result, server cabinet makers have been adding liquid pipes to their cabinets and connecting water piping to their heat sinks instead of fans. + +“Liquid cooling is definitely a very good option for higher density loads,” says John Sasser, senior vice president for data center operations at [Sabey][5], a developer and operator of data centers. “That removes the messy airflow issue. Water removes a lot more heat than air does, and you can direct it through pipes. A lot of HPC [high performance computing] is done with liquid cooling.” + +Most data centers are set up for air cooling, so liquid cooling will require a capital investment, “but that might be a much more sensible solution for these efforts, especially if a company decides to move in the direction [of AI],” Sasser says. + +### Run AI workloads at lower resolutions + +Existing data centers might be able to handle AI computational workloads but in a reduced fashion, says Steve Conway, senior research vice president for [Hyperion Research][6]. Many, if not most, workloads can be operated at half or quarter precision rather than 64-bit double precision. + +“For some problems, half precision is fine,” Conway says. “Run it at lower resolution, with less data. Or with less science in it.” + +Double-precision floating point calculations are primarily needed in scientific research, which is often done at the molecular level. Double precision is not typically used in AI training or inference on deep learning models because it is not needed. Even Nvidia [advocates][7] for use of single- and half-precision calculations in deep neural networks. + +### Build an AI containment segment + +AI will be a part of your business but not all, and that should be reflected in your data center. “The new facilities that are being built are contemplating allocating some portion of their facilities to higher power usage,” says Doug Hollidge, a partner with [Five 9s Digital][8], which builds and operates data centers. “You’re not going to put all of your facilities to higher density because there are other apps that have lower draw.” + +The first thing to do is assess the energy supply to the building, Hollidge says. “If you are going to increase energy use in the building, you’ve got to make sure the power provider can increase the power supply.” + +Bring in an engineer to assess which portion of the data center is best equipped for higher density capabilities. Workload requirements will determine the best solution, whether it be hot aisle containment or liquid cooling or some other technology. “It’s hard to give one-size-fits-all solution since all data centers are different,” Hollidge says. + +### Spread out your AI systems + +An alternative approach – rather than crowding all your AI systems into one spot hotter than Death Valley in August – is to spread them out among the racks. + +“Most of the apps are not high density. They run at eight to 10 kilowatts and up to 15 kilowatts. You can handle that with air,” says David McCall, chief innovation officer with [QTS][9], a builder of data centers. + +In an optimized heterogeneous environment, a collocation provider might have a rack or two in a cabinet to host an HPC or AI environment, and the rest of the racks in the cabinet are dedicated to hosting less power-hungry applications, such as databases and back-office apps. That won't yield a 5 kW rack, but it gets a rack closer to 12 kW or 15 kW, which is an environment that air cooling can handle, McCall says. + +### Control hot air flow in the data center + +Standard data center layout is hot aisle/cold aisle, where the cabinets are laid out in alternating rows so that cold air intakes face each other on one front-facing aisle, and hot air exhausts face each other on the alternating back-facing aisle. That works fine, but access can be tricky if an IT worker needs to get behind a cabinet to work on a server. + +The other problem is that air is “messy,” as Sasser put it. Power is often easier to model because it flows through conductors, and you can control (and thus plan and model) where power goes. Air goes where it wants and is hard to control. + +Sabey customers that want higher density environments use a hot aisle containment pod to control air flow. The company puts doors at the end of the hot aisle and plastic plates over the top, so heat is directed into a ceiling intake pipe and the barriers keep hot air and cold air from mixing. + +"In an air-cooled server world, the advice I give is go with a hot aisle containment environment,” Sasser says. "The other advice I would give is make sure the data center is tested for air flow, not just modeled for airflow. Modeling is dependent on a lot of variables, and they easily change." + +### Consider a chimney cabinet + +Another way to help manage temperatures in data centers is to use a chimney cabinet. Instead of venting the hot air out the back, a chimney cabinet uses good old physics convection to send hot air up into a chimney, which is then connected to an air conditioning vent. [Chatsworth Systems][10] is best known for this style of cabinets. + +“The air pathway is more constrained this way,” Sasser says. “Since that air pathway is more constrained, you can get greater density into a cabinet than with a hot aisle pod.” + +### Process data where it resides + +Moving data around has a very high energy cost: It can take up to 100 times more energy to move data than it takes to process data, Conway says. Any form of data movement requires electricity, and that power drain increases with the volume of data – a significant issue for data-intensive AI applications. “You want to move data as rarely and as little distance as you can,” Conway says. + +“The solution is not to have to move the data any more or further than is absolutely necessary. So people are striving to put data closer to where it is processed. One thing cloud services providers and people who use cloud services agree on is it doesn’t make sense to move a massive amount of data to a third-party cloud,” he says. + +### Consider leasing data center space + +Most of the companies looking to implement AI are corporations that lease data center space from a data center operator, Hollidge says. There are some data center operators that are not capable of handling high density AI computation, but some have transitioned to offering a portion of high density environments for AI. + +“You might have to go through a few providers before finding it, but there is more attention being paid to that on the data center operations side,” Hollidge says. And a third-party data center provider gives you more growth options. “Most of the time you are better off entering into a flexible lease that allows you to expand and grow your AI business as opposed to building ground up.” + +### Wait for next-generation servers + +Supercomputers to date haven’t been very data friendly, Conway says. As supercomputers have gotten bigger, the designs have gotten less data-centric. The result is that more data has to be moved around and shuttled between processors, memory, and storage systems. And as discussed above, it costs more power to move data than to process it. + +The first exascale systems will come with more accelerators and more powerful interconnections for moving around data. And many innovations that start in supercomputing, including GPUs and storage-class memory (SCM), eventually work their way down to more mainstream servers. + +Future servers also will come with a more heterogeneous chip layout; instead of all x86 CPUs, they will include GPUs, FPGAs, and AI accelerators. And for high speed storage, NVMe-over-Fabric and SCM will become more affordable. Servers are set to change in the coming years, and many of the advances will benefit enterprise AI application environments. + +**Learn more about HPC and supercomputers** + + * [HPE to buy Cray, offer HPC as a service][11] + * [Decommissioning the Titan supercomputer][12] + * [10 of the world's fastest supercomputers][13] + * [What’s quantum computing and why should enterprises care?][14] + * [Who’s developing quantum computers?][15] + + + +Join the Network World communities on [Facebook][16] and [LinkedIn][17] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3454626/8-ways-to-prepare-your-data-center-for-ai-s-power-draw.html + +作者:[Andy Patrizio][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.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.afcom.com/ +[2]: https://www.networkworld.com/article/3444399/high-performance-computing-do-you-need-it.html +[3]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[4]: https://www.coolitsystems.com/ +[5]: https://sabeydatacenters.com/ +[6]: https://hyperionresearch.com/ +[7]: https://devblogs.nvidia.com/mixed-precision-training-deep-neural-networks/ +[8]: https://five9sdigital.com/ +[9]: https://www.qtsdatacenters.com/ +[10]: https://www.chatsworth.com/en-us/products/families/teraframe +[11]: https://www.networkworld.com/article/3396220/hpe-to-buy-cray-offer-hpc-as-a-service.html +[12]: https://www.networkworld.com/article/3408176/the-titan-supercomputer-is-being-decommissioned-a-costly-time-consuming-project.html +[13]: https://www.networkworld.com/article/3236875/embargo-10-of-the-worlds-fastest-supercomputers.html#slide1 +[14]: https://www.networkworld.com/article/3275367/what-s-quantum-computing-and-why-enterprises-need-to-care.html#nww-fsb +[15]: https://www.networkworld.com/article/3275385/who-s-developing-quantum-computers.html +[16]: https://www.facebook.com/NetworkWorld/ +[17]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191125 My journey to becoming an open source maintainer.md b/sources/talk/20191125 My journey to becoming an open source maintainer.md new file mode 100644 index 0000000000..aee390002d --- /dev/null +++ b/sources/talk/20191125 My journey to becoming an open source maintainer.md @@ -0,0 +1,251 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (My journey to becoming an open source maintainer) +[#]: via: (https://opensource.com/article/19/11/journey-open-source-maintainer) +[#]: author: (Juliano Alves https://opensource.com/users/juliano) + +My journey to becoming an open source maintainer +====== +Hacktoberfest got me thinking. My first contribution to open source was +challenging, but everything I've learned since then has made me a better +developer. +![Guy on a laptop on a building][1] + +[Hacktoberfest][2] is an initiative that invites developers from around the world to participate and contribute to open source. This is the second year in a row that I participated to completion of the challenge, and I was so inspired by it that I want to share my slightly longer journey to open source software. + +### A long time ago, in a galaxy far, far away… + +The year was 2010. The universe made its move to make me cross paths with my good friend, [Jonas Abreu][3]. Jonas is the creator of [Mirror][4], a simple domain-specific language (DSL) layer over the Java Reflection API, which makes [meta-programming][5] easier. There was a feature request open for a proxy creation capability, and Jonas asked me if I was interested in implementing it. I accepted the challenge. + +I suffered for three days, dealing with code that I didn’t understand… until I did. I still remember the feeling that my triumph brought me that day. That pain was knowledge invading my brain! + +This code was my first contribution to open source. I took quite a lot away from my experience contributing to Mirror: + + * A lot about Java meta-programming + * The concept of proxy classes + * [Javassist][6] and [cglib][7] frameworks + * How to receive and provide useful and respectful feedback + * How to design a tool that will be used by others + * Some interesting [dark magic][8] + + + +Most importantly, I took away a sense of purpose. I love the idea of contributing to the greater good while challenging myself and working with brilliant engineers who were way smarter than me. + +### Exploring ways to contribute to open source + +I started taking part in community initiatives, like running coding dojos. While doing this, I met more great devs, and we started a small group. At some point, that group decided to learn Scala. We studied and coded together, and eventually started [Scaladores][9], the Scala user group of São Paulo. + +Eventually, Jonas started talking about a different approach for learning, called [deliberate practice][10]. + +> _What if we could put all this recently acquired knowledge altogether?_ + +The resulting project from studying this practice is [Aprenda][11], a learning platform that mixes gamification and deliberate practice to make it easier to learn HTML, regular expressions, or Git. Building something this significant felt like leveling up in my pursuit of open source contribution. I also found that I picked up more knowledge about programming and practices to motivate both others and myself.  + +As much as I enjoyed this pursuit, I couldn’t dedicate a lot of time to this project. At the same time as I was making progress on Aprenda, I had to shift focus to a new job. + +### Contributing through my own Ruby gem + +My new work had me in a common pattern: Every problem was solved by writing code that creates, reads, updates, or deletes data (CRUD). It gave me an idea, so I started a new project. I wanted to generate code the same way Ruby on Rails, a powerful web framework, allowed me to set up an environment with a simple command: **rails g scaffold**. Using [Thor][12], the same gem that powers Rails generators, I created [Spring MVC Scaffold][13]. Now, any time I needed to create a CRUD I typed: + + +``` +$ springmvc scaffold product name:string value:double active:boolean +``` + +The code I wrote reducing the work my team had to do to get their job done, and I shared it further by posting it publicly. Here are some of the highlights of what I learned: + + * Generating code and files with Thor + * Defining commands for a CLI + * Organizing Ruby lib code + * Creating a Ruby gem + * Building projects with [Travis CI][14] + * Publishing to RubyGems + + + +> _After solving a common problem, think about making that solution available. Most likely, other people have similar problems._ + +Even though it’s not being maintained anymore, Spring MVC Scaffold is still available on [RubyGems][15]. And I tell you what, after that project, I went to work in a tech environment full of problems. + +### Shifting technology + +My new work required a shift in languages. I started working with Microsoft .NET, and I found issues that other communities had already solved. That recognition excited me because I knew it was my opportunity. My new opportunity to contribute came in the form of porting those solutions. + +#### Selenia + +[Selenium][16] is the dominate way to programmatically interact with websites as if the code is a "real" user (accessing it via a web browser). The API has always been too complex in my opinion. So I built a tool, we called Selenia, that could be used to write concise UI tests in C#, so instead of using: + + +``` +IWebDriver driver; +ChromeOptions options = [new][17] ChromeOptions(); +options.addExtensions([new][17] File("/path/to/extension.crx")); +ChromeDriver driver = [new][17] ChromeDriver(options); +driver = [new][17] ChromeDriver(); +driver.Navigate().GoToUrl(""); + +IWebElement query = driver.FindElement(By.Name("q")); +query.SendKeys("Selenium"); +query.Submit(); + +driver.Quit(); +``` + +We can write as: + + +``` +Open(""); +S(By.Name("q").Value("Selenia").Enter(); +``` + +Selenium users may have a question at this point. If you are wondering, the answer is "no." It’s not necessary to close the driver yourself. + +#### Designing for immutability with Ioget + +Immutability, which means never changing an object that already exists, makes a developer’s life easy. This opinion is a newer one, however. Back in the day, ASP.NET MVCs would recommend updating information in place. The only way to instantiate objects was via **setters**. + +I built [Ioget][18] to help with unmarshalling request parameters in web applications. HTTP request parameters are strings, so Ioget looks for the best way to parse those params according to the given class, instantiating objects via their constructors and therefore making them immutable. + +I published this project publicly to NuGet, but I never managed to integrate Ioget with ASP.NET like I intended to. I stopped working with Microsoft technology, and thus this project fell behind from its once lofty goals. + +Continuing with my deliberate practice, I kept track of the lessons learned along the way. + + * [Reification][19] + * ASP.NET MVC internals + * Monad implementation + * .NET framework internals + + + +I also took note of a pattern I used with Selenia. I really like this snippet, which I used to close the driver: + + +``` +private void MarkForAutoClose(IWebDriver driver) => +  AppDomain.CurrentDomain.DomainUnload += (s, e) => driver.Quit(); +``` + +### Contributing to Quill + +I moved to London in 2016, which paused my contributions for a while. Eventually, I watched a talk by [Gustavo Amigo][20] about his project, [quill-pgsql][21], which is an extension to support PostgreSQL data types with [Quill][22]. He mentioned that this project was in its early moments, which meant it was ideal for someone to join, and I was interested in writing in Scala. After a few pull requests, I decided to contribute to the main project. + +Quill transforms regular collection-like code into SQL queries in compile-time. I consider it the most challenging (and interesting) project I have ever contributed to. It’s been a few years since I started, and today I am [one of the maintainers][23]. + +Here’s what I learned by working on Quill: + + * Abstract syntax trees (AST) + * The Dark Arts (also known as [Scala macros][24]) + * How to make code extensible via [implicits][25] + * Exclusive and weird [SQL rules][26] + + + +Quill has a module called quill-async, which uses [an asynchronous database driver][27] that is no longer maintained. Quill’s creator, [Flavio Brasil][28], suggested that we could write a new async driver. That’s how [Non-Blocking Database Connectivity (NDBC)][29] got started. + +NDBC is a fully async alternative to Java Database Connectivity (JDBC). Its architecture was designed to provide high-performance, non-blocking connectivity to the database on top of [Trane.io Futures][30] and [Netty 4][31]: + + +``` +// Create a Config with an Embedded Postgres +Config config = Config.create("io.trane.ndbc.postgres.netty4.DataSourceSupplier", "localhost", 0, "user") +                      .database("test_schema") +                      .password("test") +                      .embedded("io.trane.ndbc.postgres.embedded.EmbeddedSupplier"); + +// Create a DataSource +DataSource<[PreparedStatement][32], Row> ds = DataSource.fromConfig(config); + +// Define a timeout +Duration timeout = Duration.ofSeconds(10); + +// Send a query to the db defining a timeout and receiving back a List +List<Row> rows = ds.query("SELECT 1 AS value").get(timeout); + +// iterate over awesome strongly typed rows +rows.forEach(row -> [System][33].out.println(row.getLong("value"))); +``` + +More knowledge was acquired along the way: + + * Understanding binary protocols + * Using Netty 4 + * Weaknesses of the Java type system + * Fully implementing functional structures + + + +That’s where I am at the moment. I divide my attention between Quill and NDBC, trying to make them work together. + +### Plans for the future + +The contributions I have in mind for the near future are implementing: + + * Array support in [Finagle Postgres][34] + * A Clojure wrapper for NDBC + * A ndbc-spring module + * A CLI in [Rust][35] + + + +I now have almost 10 years of open source in my journey, and it taught me something extremely valuable: Open source is about sharing knowledge. When I am solving an issue, I am acquiring knowledge. When I send a pull request, I am spreading that knowledge. Knowledge brings more knowledge! + +I strongly recommend that you become part of the open source community. It can be difficult, especially in the beginning, but everything you will learn will make you a better developer. I promise. + +> _Open source is about sharing knowledge. When I am solving an issue, I am acquiring knowledge. When I send a pull request, I am spreading that knowledge. Knowledge brings more knowledge!_ + +_This article was originally posted on [Juliano Alves' Programming Blog][36]. It has been edited for style and clarity._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/journey-open-source-maintainer + +作者:[Juliano Alves][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/juliano +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_code_programming_laptop.jpg?itok=ormv35tV (Guy on a laptop on a building) +[2]: https://hacktoberfest.digitalocean.com/ +[3]: https://twitter.com/jonasabreu +[4]: http://projetos.vidageek.net/mirror/mirror/ +[5]: https://www.ibm.com/developerworks/library/l-metaprog1/index.html +[6]: https://www.javassist.org/ +[7]: https://github.com/cglib/cglib +[8]: https://github.com/vidageek/mirror/blob/master/src/main/java/net/vidageek/mirror/provider/java/ObjenesisConstructorBypassingReflectionProvider.java +[9]: https://www.meetup.com/scaladores/ +[10]: https://jamesclear.com/deliberate-practice-theory +[11]: https://aprenda.vidageek.net/ +[12]: http://whatisthor.com/ +[13]: https://github.com/juliano/springmvc-scaffold +[14]: https://travis-ci.com/ +[15]: https://rubygems.org/gems/springmvc-scaffold +[16]: https://www.seleniumhq.org/ +[17]: http://www.google.com/search?q=new+msdn.microsoft.com +[18]: https://www.nuget.org/packages/Ioget/ +[19]: https://en.wikipedia.org/wiki/Reification_(computer_science) +[20]: https://github.com/gustavoamigo +[21]: https://github.com/gustavoamigo/quill-pgsql +[22]: https://getquill.io/ +[23]: https://github.com/getquill/quill +[24]: http://scalamacros.org/ +[25]: https://docs.scala-lang.org/tour/implicit-parameters.html +[26]: https://teamsql.io/blog/?p=923 +[27]: https://github.com/mauricio/postgresql-async +[28]: https://twitter.com/flaviowbrasil +[29]: https://ndbc.io/ +[30]: http://trane.io/ +[31]: https://netty.io/ +[32]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+preparedstatement +[33]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system +[34]: https://github.com/finagle/finagle-postgres/issues/55 +[35]: https://opensource.com/tags/rust +[36]: https://juliano-alves.com/2019/11/02/the-journey-of-an-open-source-developer/ diff --git a/sources/talk/20191126 A framework for building products from open source projects.md b/sources/talk/20191126 A framework for building products from open source projects.md new file mode 100644 index 0000000000..2a8a109e07 --- /dev/null +++ b/sources/talk/20191126 A framework for building products from open source projects.md @@ -0,0 +1,124 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A framework for building products from open source projects) +[#]: via: (https://opensource.com/article/19/11/products-open-source-projects) +[#]: author: (Kevin Xu https://opensource.com/users/kevin-xu) + +A framework for building products from open source projects +====== +Here is a roadmap for turning a project into a commercial open source +product. +![An airplane.][1] + +My first memory of playing with a computer was through an [MS-DOS][2] terminal on the x86 PC in my grandfather's pharmaceutical research lab in the early '90s—playing games stored on 3.5" floppy disks and doing touch-typing exercises. As technology improved, I spent an obscene amount of time taking my computer apart to add more RAM, a new graphics card, or a new fan, mostly so I could play cooler games. It was a fun, ongoing project, and I bonded with my father over it. It was also way cheaper than buying a new computer. + +What's the point of this in the context of open source? + +Well, even though I had no idea what "open source" was at the time, I was behaving like a typical developer does with open source projects today—spending my free time to piece together and build things I wanted, sometimes for a specific goal, sometimes to learn new things, sometimes as a way to connect with others. + +But, over time, I stopped tinkering. For whatever reason, I decided that my time was becoming too "valuable" to retrofit my older computers. I started using a MacBook, and when my older MacBook wasn't functioning well, I paid a pretty penny for a new one with a better configuration instead of unscrewing the bottom to see if I could jam in a new RAM card. + +My behavior became more like that of an enterprise buyer—saving time and trouble by spending money. + +### An open source software project is not a product you sell + +If your experience with technology resembles mine in any way, you know intuitively that the _projects_ we [DIY][3] are not the same as the _products_ we spend money buying. + +This isn't a new observation in the open source community. + +[Stephen Walli][4], an IT industry veteran and part of the [Open Container Initiative][5], has written [numerous detailed blog posts][6] on this topic. [Sarah Novotny][7], who led the Kubernetes community and was heavily involved in the Nginx and MySQL communities, [emphatically articulated][8] at the inaugural [Open Core Summit][9] that the open source project a company shepherds and the product that a company sells are two completely _different_ things. + +Yet, project and product continue to be conflated by maintainers-turned-founders of commercial open source software (COSS) companies, especially (and ironically) when the open source project gets traction. + +This mistake gets repeated, I believe, because it's hard to mentally conceptualize how and why a commercial product should be different when the open source project is already being used widely. + +### What makes a COSS product different? + +Two core elements differentiate a commercial product from its open source root: packaged experience and buyer-specific features. + +#### Packaged experience + +Packaging your project so that it has that out-of-the-box user experience isn't just about a polished user interface (UI) or hosting it on your server as SaaS (although that could be part of it). It's an expressed opinion of how you, the creator or maintainer of the project turned founder of the company, believe the technology should be used to solve your customer's business problem. That "opinion" is essentially the product experience the customer is paying for. + +When you are running an open source community project, it's usually good to be _not_ opinionated and let your community organically flourish. When you are developing a product for customers, it's usually good to _be_ opinionated. + +It's the retrofitted x86 PC versus the MacBook dynamic. + +[Dave McJannet][10], CEO of Hashicorp, and [Peter Reinhardt][11], CEO of Segment, both cited packaging as a crucial step to get right in order to turn an open source project into a scalable commercial product. + +#### Buyer-specific features + +A well-packaged product must also have the features that are necessary for your targeted buyer to justify a purchase. What these features are depends on the profile of your buyer, but the possibilities are finite and manageable. + +An enterprise buyer, say a Global 2000, will have a relatively consistent set of features that it must have to purchase a product. ([EnterpriseReady.io][12] is a great resource about what those features tend to be.) + +A small- or medium-sized business buyer, say your local mom-and-pop bakery, that has less financial resources and people power and is more price-sensitive, will need different things to be convinced to buy. + +A consumer service monetized via ads, where your buyers are the advertisers while your users are everyday people, will be different still. + +One thing is for sure: your buyer is almost _never_ your open source community. + +Know what your buyer requires for a purchase, and package that with your expert opinion on how to solve the buyer's problem; **that's what differentiates a product from a project.** + +Sid Sijbrandij's articulation of GitLab's [buyer-based open core][13] model is a good example for enterprises. + +Certainly, other elements can be added to further the differentiation. But a packaged experience with buyer-specific features is essential. Without one or the other, your prospective customers might as well just tinker on their own for free. + +### One metric that matters: Time-to-value + +A perennially difficult thing in product development is measuring progress and establishing a data-driven framework to determine whether you are on the right path or not. I'm a fan of the One Metric That Matters (OMTM) mentality, elaborated in [_Lean Analytics_][14], where you focus on one single number (above everything else) for your current stage. This approach enforces focus and discipline among a sea of data you can gather and distract yourself with (oftentimes vanity metrics like download numbers or GitHub stars). The single metric can effectively rally your entire company around one tangible goal or mission—especially critical for an early-stage company. And the metric you focus on will be different at different stages. + +So what's the right OMTM in the early days of product development? + +I propose **time-to-value** + +"Time" here is straightforward—the lower, the better. + +"Value" needs a precise, rigorous definition that is technology- and problem-specific. Your distributed database is valuable because it can serve data with no downtime when servers fail. Your continuous integration tool is valuable because it enables application developers to push improvements faster without breaking the application. You get the idea. + +How quickly can a customer see or feel the _one core piece of value_ that you measure and optimize for? Whatever is "a sufficiently short time" depends on the use case, but given the increasing consumerization of enterprise technology, any product's time-to-value that's more than 30 minutes is probably too long. + +Finding and tightly defining that "value" is hard and iterative, but also table stakes if you are looking to build a product company around an open source project. Without a deep understanding of what that value is for your customer, there's probably not much of a company to build. + +At the end of the day, as much fun as it was to "beef up" my x86 PC, I'm pretty satisfied with my MacBook and happy to pay the premium. So don't get too enamored with the joy of tinkering if your goal is actually to sell MacBook. + +(P.S. The mental framework outlined here may not apply if you are building a consultancy or support-oriented company that services open source project users. For more expansive reading on different COSS business models, see _[_COSS business model progressions_][15]_ by Joseph Jacks.) + +_Special thanks to Sarah Novotny for her feedback on this post's draft._ + +* * * + +_This article was [previously published on COSS Media][16] and is edited and republished with permission._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/products-open-source-projects + +作者:[Kevin Xu][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/kevin-xu +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/206308main_image_976_946-710.jpg?itok=U6hh3EIO (An airplane.) +[2]: https://en.wikipedia.org/wiki/MS-DOS +[3]: https://en.wikipedia.org/wiki/Do_it_yourself +[4]: https://stephesblog.blogs.com/about.html +[5]: https://www.opencontainers.org/ +[6]: https://medium.com/@stephenrwalli +[7]: https://sarahnovotny.com/about/ +[8]: https://www.linkedin.com/pulse/personal-reflection-open-core-summit-kevin-xu/ +[9]: https://opencoresummit.com/#speakers +[10]: https://founderrealtalk.ggvc.com/2019/04/25/episode-23-hashicorp-ceo-dave-mcjannet-reveals-the-secrets-of-commercializing-open-source-selling-to-enterprises-and-building-successful-relationships-with-founders/ +[11]: https://www.youtube.com/watch?v=Q75V35unztw&feature=youtu.be +[12]: https://www.enterpriseready.io/# +[13]: https://www.youtube.com/watch?v=G6ZupYzr_Zg +[14]: http://leananalyticsbook.com/ +[15]: https://coss.media/coss-business-model-progressions/ +[16]: https://coss.media/deriving-product-from-open-source/ diff --git a/sources/talk/20191126 How cloud providers- performance differs.md b/sources/talk/20191126 How cloud providers- performance differs.md new file mode 100644 index 0000000000..0abb0f11b7 --- /dev/null +++ b/sources/talk/20191126 How cloud providers- performance differs.md @@ -0,0 +1,88 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How cloud providers' performance differs) +[#]: via: (https://www.networkworld.com/article/3455197/how-cloud-providers-performance-differs.html) +[#]: author: (Zeus Kerravala https://www.networkworld.com/author/Zeus-Kerravala/) + +How cloud providers' performance differs +====== +The 2019 ThousandEyes Benchmark report shows that not all cloud providers are created equal across all regions +Denis Isakov / Getty Images + +Not all public cloud service providers are the same when it comes to network performance. + +Each one’s connectivity approach varies, which causes geographical discrepancies in network performance and predictability. As businesses consider moving to the cloud, especially software-defined wide-area networks ([SD-WAN][1]) and [multi-cloud][2], it’s important to understand what each public cloud service provider brings to the table and how they compare. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][3] + +In 2018, ThousandEyes first conducted [a benchmark study assessing three major public cloud providers][4]: Amazon Web Services (AWS), Microsoft Azure (Azure), and Google Cloud Platform (GCP). The study gathered data on network performance and connectivity architecture to guide businesses in the planning stage. + +[][5] + +BrandPost Sponsored by HPE + +[HPE Synergy For Dummies][5] + +Here’s how IT can provide an anytime, anywhere, any workload infrastructure. + +[This year’s study][6] offers a more comprehensive view of the competition, with two more providers added to the list: Alibaba Cloud and IBM Cloud. It compares 2018 and 2019 data to show changes that took place year-over-year and what triggered them. + +ThousandEyes periodically collected bi-directional network performance metrics—such as latency, packet loss and jitter—from 98 user vantage points in global [data centers][7] across all five public cloud providers over a four-week period. Additionally, it looked at network performance from leading U.S. broadband internet service providers (ISPs), including AT&T, Verizon, Comcast, CenturyLink, Cox, and Charter. + +The network management company then analyzed more than 320 million data points to create the benchmark. Here are the results. + +### Inconsistencies among providers + +In its initial study, ThousandEyes revealed that some cloud providers rely heavily on the public internet to carry user traffic while others don’t. In this year’s study, the cloud providers generally showed similar performance in bi-directional network latency. + +However, ThousandEyes found architectural and connectivity differences have a big impact on how traffic travels between users and certain cloud hosting regions. AWS and Alibaba mostly rely on the internet to transport user traffic. Azure and GCP use their private backbone networks. IBM is different from the rest and takes a hybrid approach. + +ThousandEyes tested the theory of whether AWS Global Accelerator out-performs the internet. AWS Global Accelerator launched in November 2018, offering users the option to utilize the AWS private backbone network for a fee instead of the default public internet. Although performance did improve in some regions around the world, there where other instances where the internet was faster and more reliable than AWS Global Accelerator. + +Broadband ISPs that businesses use to connect to each cloud also showed inconsistencies, even in the mature U.S. market. After evaluating network performance from the six U.S. ISPs, sub-optimal routing results were recorded, with up to 10 times the expected network latency in some cases. + +**Location, location, location** + +Cloud providers commonly experience packet loss when crossing through China’s content-filtering firewall, even those from the region like Alibaba. The 2019 study closely examined the performance toll cloud providers pay in China, which has a notoriously challenging geography for online businesses. For those with customers in China, ThousandEyes recommends Hong Kong as a hosting region since Alibaba Cloud traffic experienced the least packet loss there, followed by Azure and IBM. + +In other parts of the world, Latin America and Asia showed the highest performance variations for all cloud providers. For example, network latency was six times higher from Rio de Janeiro to GCP’s São Paulo hosting region because of a suboptimal reverse path, compared to other providers. But across North America and Western Europe, all five cloud providers demonstrated comparable, robust network performance. + +The study’s results confirm that location is a major factor, therefore, user-to-hosting-region performance data should be considered when selecting a public cloud provider. + +**Multi-cloud connectivity** + +In 2018, ThousandEyes discovered extensive connectivity between the backbone networks of AWS, GCP, and Azure. An interesting finding in this year’s study shows multi-cloud connectivity was erratic when IBM and Alibaba Cloud were added to the list. + +ThousandEyes found IBM and Alibaba Cloud don’t have fully established, direct connectivity with other providers. That’s because they typically use ISPs to connect their clouds to other providers. AWS, Azure, and GCP, on the other hand, peer directly with each other and don’t require third-party ISPs for multi-cloud communication. + +With multi-cloud initiatives on the rise, network performance should be included as a metric in evaluating multi-cloud connectivity since it appears to be inconsistent across providers and geographical boundaries. + +ThousandEyes’ comprehensive performance benchmark can serve as a guide for businesses deciding which public cloud provider best meets their needs. But to err on the side of caution, businesses selecting public cloud connectivity should consider the unpredictable nature of the internet, how it affects performance, creates risk, and increases operational complexity. Businesses should address those challenges by gathering their own network intelligence on a case-by-case basis. Only then they will benefit fully from what cloud providers have to offer. + +Join the Network World communities on [Facebook][8] and [LinkedIn][9] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3455197/how-cloud-providers-performance-differs.html + +作者:[Zeus Kerravala][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.networkworld.com/author/Zeus-Kerravala/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3031279/sd-wan-what-it-is-and-why-you-ll-use-it-one-day.html +[2]: https://www.networkworld.com/article/3429258/real-world-tools-for-multi-cloud-management.html +[3]: https://www.networkworld.com/newsletters/signup.html +[4]: https://www.networkworld.com/article/3319776/the-network-matters-for-public-cloud-performance.html +[5]: https://www.networkworld.com/article/3399618/hpe-synergy-for-dummies.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE19718&utm_content=sidebar (HPE Synergy For Dummies) +[6]: https://www.thousandeyes.com/press-releases/second-annual-cloud-performance-benchmark-research +[7]: https://www.networkworld.com/article/3223692/what-is-a-data-centerhow-its-changed-and-what-you-need-to-know.html +[8]: https://www.facebook.com/NetworkWorld/ +[9]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191126 SASE- Redefining the network and security architecture.md b/sources/talk/20191126 SASE- Redefining the network and security architecture.md new file mode 100644 index 0000000000..c92cb9eeda --- /dev/null +++ b/sources/talk/20191126 SASE- Redefining the network and security architecture.md @@ -0,0 +1,138 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (SASE: Redefining the network and security architecture) +[#]: via: (https://www.networkworld.com/article/3481519/sase-redefining-the-network-and-security-architecture.html) +[#]: author: (Matt Conran https://www.networkworld.com/author/Matt-Conran/) + +SASE: Redefining the network and security architecture +====== +Adoption of SASE reduces complexity and overhead, improves security and boosts application performance. +Getty Images + +In a cloud-centric world, users and devices require access to services everywhere. The focal point has changed. Now it is the identity of the user and device as opposed to the traditional model that focused solely on the data center. As a result, these environmental changes have created a new landscape that we need to protect and connect. + +This new landscape is challenged by many common problems. The enterprises are loaded with complexity and overhead due to deployed appliances for different technology stacks. The legacy network and security designs increase latency. In addition, the world is encrypted; this dimension needs to be inspected carefully, without degrading the application performance. + +These are some of the reasons that surface the need for a cloud-delivered secure access service edge (SASE). SASE consists of a tailored network fabric optimization where it makes the most sense for the user, device and application - at geographically dispersed PoPs. To deliver optimum network experience everywhere you should avoid the unpredictability of the Internet core. In the requirements for SASE, Gartner recommends that this backbone should not be based on AWS or Azure. Their PoP density is insufficient. It is not sufficient to offer a SASE service built solely on a hyper-scale. + +[][1] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][1] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +There are clear benefits that can be achieved by redefining the network and security architecture. Yes, the adoption of SASE reduces complexity and overhead, improves security. It increases the application performance, but practically, what does that mean? + +[Linda Musthaler had a great example in her conversation with Andrew Thomson, Director of IT at BioIVT,][2] a provider of biological materials and scientific services to research and development organizations, who adopted Cato Networks’ SASE platform nearly two years ago: + +_“We positioned it as a platform for everything that we wanted to be able to do over the next three years with the business,” he told Linda, “The big goal, the business strategy, is growth and acquisition. We presented this as a platform, as a base service that we just had to have in place in order to leverage things like voice over IP, Office 365, Azure, cloud-based computing services, hosting servers in the cloud. Without a common core solid foundation, we wouldn't have been able to do any of those things reliably without adding staff to do monitoring or maintenance or administrative overhead.”_ + +It’s that last line – “without adding staff to do monitoring or maintenance or administrative overhead” – that I found particularly striking. So, let’s understand why SASE can be so impactful from an architectural perspective. + +**[ Now read [20 hot jobs ambitious IT pros should shoot for][3]. ]** + +### Complexity and overhead + +Traditional mechanisms are limited by the hardware capacity of the physical appliances located at the customer's site. Such mechanisms create a lag in the hardware refresh rates that are needed to add new functionality. + +Hardware-based network and security solutions build into the hardware the differentiator of the offering. Primarily, with different hardware, you can accelerate the services and add new features. There are some features that are available only on the specific hardware, not the hardware you already have onsite. In this case, heavy lifting by the customer will be required. + +As the environment evolves, we should not depend on the new network and security features coming from the new generation of an appliance. Typically, this model is inefficient and complex. It creates high operational overhead and management complexity. + +Device upgrades for new features require a lot of management. From past experience, to change out a line card would involve multiple teams. The line card might run out of ports or you may simply need additional features from a new generation. Largely, this would involve project planning, on-site engineers, design guides, hopefully, line card testing and hours of work. For critical sites to ensure a successful refresh, team members may need to be backed up. Therefore, there are many touches that need to be managed. + +### SASE – Easing management + +The cloud-based SASE enables the updates for new features and functionality without the need for new deployments of appliances (physical or virtual) and software versions on the customer side. This has an immediate effect on the ease of management. + +Now the network and security deployment can occur without ever touching the enterprise network. This allows enterprises to adopt new capabilities quickly. Once the tight coupling between the features and the customer appliance is removed, this increases the agility and simplicity for the deployment of network and security services. + +With a SASE platform, when we create an object, such as a policy in the networking domain, it is then available in other domains as well. So any policies assigned to users are tied to that user, regardless of the network location. This significantly removes the complexity of managing both; network and security policies across multiple locations, users and types of devices. Supremely, all of this can be done from one platform. + +Also, when we examine the security solution, many buy individual appliances that focus just on one job. To troubleshoot, you need to gather information, such as the logs from each device. This is what a SIEM is useful for but it can only be used in some organizations as it’s resource-heavy. For the ones who don’t have ample resources, the process is backbreaking and there will be false positives. + +In addition, SASE enables easier troubleshooting because all the data is in one common repository. You no longer have normalized data from different appliances/solution and then import the data into a database for a common view. + +### Consolidation of vendors and technology stacks + +I recall an experience from a previous consultancy, wherein we were planning the next year's security budget. The network was packed with numerous security solutions. All these point solutions are expensive and there is never a fixed price. So how do you actually plan for this? + +Some new solutions we were considering charge on the usage models which at that time we didn’t have the quantity. SASE removes these types of headaches. By consolidating services into a single provider, there will be a reduction in the number of vendors and agents/clients on the end-user device. + +Overall, there will be high complexity saving from the consolidation of vendors and technology stacks. The complexity is pushed to the cloud away from the on-premise enterprise network. The SASE fabric abstracts the complexity and reduces costs. + +From a hardware point of view: for scale and additional capacity, the cloud-based SASE can add more PoPs of the same instance. This is known as vertical scaling. This scaling can also be carried in new locations, known as horizontal scaling. + +Additionally, the SASE-based cloud takes care of intensive processing. For example, since a large proportion of internet traffic is now encrypted, malware can use encryption to evade and hide from detection. Here, each of the PoPs can perform DPI on TLS-encrypted traffic. + +Traditional firewalls are not capable of inspecting encrypted traffic. Performing DPI on TLS-encrypted traffic would require extra modules or a new appliance. A SASE solution ensures that the decryption and inspection are done at the PoP. Consequently, there is no performance-hit or the need for new appliances on the customer sites. + +### Ways to improve performance + +Network congestion resulting in dropped and out of order packets is bad for applications. Latency-sensitive applications, such as collaboration, video, VoIP and web conferencing are hit hardest because of packet drops. Luckily, there are options to minimize latency and the effects of packet loss. + +SD-WAN solutions have WAN optimization features that can be applied on an application-by-application or site-by-site basis. Along with WAN optimization features, there are protocol and application acceleration techniques that can be employed. + +On top of the existing techniques to reduce the packet loss and latency, we can privatize the WAN as much as possible. You can control the adverse and varying effects that the last mile and middle mile have on the applications by privatizing with a global backbone consisting of a fabric of PoPs. + +Once privatized, we can have more control over traffic paths, packet loss and latency. A private network fabric is a key benefit gained from SASE as it drives the application performance. + +### SASE PoP optimizations + +Each PoP in the SASE cloud-based solution optimizes where it makes the most sense, not just at the WAN edge. Within the backbone, we have global route optimizations to determine which path is the best at the current time and it can also be changed for all traffic or certain applications. + +These routing algorithms factor in the performance metrics, such as latency, packet loss and jitter. These algorithms can help in selecting the optimal route for every network packet. The WAN backbone constantly analyzes and tries to improve the performance. This is unlike internet routing that favors cost over performance. + +As everything is privatized, we have all the information to create the largest packet size and use rate-based algorithms over traditional loss-based algorithms. As a result, you don't need to learn anything, and the end-to-end throughput can be maintained. + +As each PoP acts as a TCP proxy server, certain techniques are employed so that the TCP client and server think that they are closer. Therefore, a larger TCP window is set, allowing more data to be passed before waiting for an acknowledgment. + +### Preferred egress points + +We can also define preferred egress points to exit the cloud application traffic. These could be the points closest to the customer's application instance. The optimal global routing algorithms determine the best path to the customer's cloud application instance from anywhere in the world. + +The PoPs can be collocated in the data centers directly connected to the IXP that connects to all major Infrastructures as service providers. This provides a good on-ramp to access the services from Amazon AWS, Microsoft Azure and Google cloud. + +Therefore, you can keep the traffic on the private cloud for the majority of the time. Within a SASE design, the internet is used only to provide a short hop to the SASE fabric. + +### Security – Identity-centric perimeter + +SASE converges the networking and security pillars into a single platform. This allows multiple security solutions into a cloud service that enforces a unified policy across all the corporate locations, users and data. + +SASE recommends you employ the zero-trust principles. The initial path to zero trust starts with identifying that network access is based on the identity of user, device and application. It is not based on the IP address or physical location of the device. And this is for a good reason as there is no contextual information. + +The identity of the user/device must reflect the business context as opposed to being associated with binary constructs that are completely disjointed from the upper layers. This binds the identity to the world of networking and is the best way forward for policy enforcement. This way, the dependency on IP or applications as identifiers is removed. Now, the policy can be applied consistently, regardless of where the user/device is located. At the same time, the identity of the user/device/service can be factored into the applied policy. + +The SASE stack is dynamically applied based on the identity and context while serving zero trust at strategic points in the cloud. This is what enforces an identity-centric perimeter. + +_You can learn more about SASE and how it relates to [SD-WAN architectures][4] in a recent course I’ve rolled out. The course shines the torch on various SD-WAN solutions from Silver Peak, VMware, Cisco and Cato._ + +**This article is published as part of the IDG Contributor Network. [Want to Join?][5]** + +Join the Network World communities on [Facebook][6] and [LinkedIn][7] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3481519/sase-redefining-the-network-and-security-architecture.html + +作者:[Matt Conran][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.networkworld.com/author/Matt-Conran/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[2]: https://www.networkworld.com/article/3453030/sase-is-more-than-a-buzzword-for-bioivt.html +[3]: https://www.networkworld.com/article/3276025/careers/20-hot-jobs-ambitious-it-pros-should-shoot-for.html +[4]: https://www.pluralsight.com/courses/sd-wan-architectures-big-picture +[5]: https://www.networkworld.com/contributor-network/signup.html +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191127 Is your code inclusive.md b/sources/talk/20191127 Is your code inclusive.md new file mode 100644 index 0000000000..5cb264032b --- /dev/null +++ b/sources/talk/20191127 Is your code inclusive.md @@ -0,0 +1,70 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Is your code inclusive?) +[#]: via: (https://opensource.com/article/19/11/inclusive-design-code) +[#]: author: (Peter Cheer https://opensource.com/users/petercheer) + +Is your code inclusive? +====== +Learn how developers can support assistive technology projects and +inclusivity. +![plastic game pieces on a board][1] + +I have been involved with assistive technology for about ten years now, beginning with a stint as an assistive technology tutor with the [Kenya Society for the Blind][2]. + +Assistive technology helps improve the lives of people with cognitive, physical or sensory challenges. It comprises a wide range of hardware, specialist software such as screen readers, as well as accessibility features in general software. + +Over the ten years that I have worked with assistive technology, it has vastly improved. This is due in part to the advent of more powerful technologies, as well as better education and stronger disability rights legislation across much of the world. However, progress has been uneven and much of the legislation, well-meaning as it is, is poorly enforced, so there is still work to be done. + +[The Association for the Advancement of Assistive Technology in Europe (AAATE)][3] is an interdisciplinary pan-European association devoted to all aspects of assistive technology, such as use, research, development, manufacture, supply, provision, and policy. Following the AAATE 2019 Conference in Bologna, the association published ["The Bologna Declaration."][4] + +The declaration is a call to action "to improve access to quality assistive technology for realizing fundamental human rights and achieving the sustainable development goals in a fully inclusive manner." + +It includes a list of ten important steps in an agenda for action. These points are not specifically aimed at the open source community; they are intended for policymakers and the whole assistive technology sector. This agenda for action is well thought out and deserves to be widely read across the technology sector. + +### Examples of open source assistive technology + +A look at the projects listed at [Open Assistive][5] offers an idea of the range of open source assistive technology projects that are already out there. A good example of mainstream open source software embracing accessibility is the Mozilla Firefox web browser "reader view" feature, which removes ads, background images, and other clutter for distraction-free viewing. The spoken text option in "reader view" also aids accessibility. This feature has certainly improved my user experience and has the great advantage of being a standard option rather than an add-on. + +Some of the open source assistive tools that I have used with my clients include: + + * [Vinux][6] — a Linux distro that is optimized for users with visual impairments + * [NVDA][7] — a capable screen reader for MS Windows + * [Autohotkey][8] — automates almost anything in MS Windows by sending keystrokes and mouse clicks + * [Mulberry symbol set][9] — Mulberry symbols, or pictograms, are a set of scalable SVG graphic images designed for communications use. They are ideal for software, devices, or any online accessibility use. + + + +There is a huge range of open source assistive technology projects; one large subset that I am interested to explore is the growing list of open source assistive technology hardware projects. If you have a favorite project that you use or contribute to, share it with us in the comments! + +You can support assistive technology by encouraging users to try it, by contributing coding work to assistive technology projects, or by working on documentation and user guides. Even if they’re not working specifically on assistive technology, all developers should keep in mind the need for inclusive design in their projects. If you would like to endorse the Bologna Declaration "to raise awareness so people take action and do everything in their power to actively implementing the points on the agenda," please visit .  + +Assistive technology such as Augmented/Assisted Communication (AAC), Text-to-Speech and Speech-to-... + +Assistive technology software is any program or operating system feature designed to let a user... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/inclusive-design-code + +作者:[Peter Cheer][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/petercheer +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/team-game-play-inclusive-diversity-collaboration.png?itok=8sUXV7W1 (plastic game pieces on a board) +[2]: http://www.ksblind.org/ +[3]: https://opensource.com/article/19/11/www.aaate.net +[4]: https://aaate.net/the-bologna-declaration/ +[5]: https://openassistive.org +[6]: https://wiki.vinuxproject.org/ +[7]: https://www.nvaccess.org/ +[8]: https://www.autohotkey.com/ +[9]: https://mulberrysymbols.org/ diff --git a/sources/talk/20191127 Why do we contribute to open source software.md b/sources/talk/20191127 Why do we contribute to open source software.md new file mode 100644 index 0000000000..3277dcf6f8 --- /dev/null +++ b/sources/talk/20191127 Why do we contribute to open source software.md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Why do we contribute to open source software?) +[#]: via: (https://opensource.com/article/19/11/why-contribute-open-source-software) +[#]: author: (Gordon Haff https://opensource.com/users/ghaff) + +Why do we contribute to open source software? +====== +Dive into the research supporting the open source ecosystem and +developers’ motivations for participating. +![question mark in chalk][1] + +Organizations as a whole contribute to open source software projects for a variety of reasons. + +One of the most important is that the open source development model is such an effective way to collaborate with other companies on projects of mutual interest. But they also want to better understand the technologies they use. They also want to influence direction. + +The specific rationale will vary by organization but it usually boils down to the simple fact that working in open source benefits their business. + +But why do individuals contribute to open source? They mostly see some kind of personal benefit too, but what specifically motivates them? + +### The types of motivation + +When we talk about motivations, one common way to do so is in terms of incentive theory. This theory began to emerge during the 1940s and 1950s, building on the earlier drive-reduction theories established by psychologists such as Clark Hull and Kenneth Spence. Incentive theory was originally based on the idea that motivation is largely fueled by the prospect of an external reward or incentive. + +Money is a classic extrinsic motivator. So is winning an award, getting a grade, or obtaining a certification that is likely to lead to a better job. + +However, in the 1970s, researchers began to also consider intrinsic motivations, which do not require an apparent reward other than the activity itself. Self-determination theory, developed by Edward Deci and Richard Ryan, would later evolve from studies comparing intrinsic and extrinsic motives, and from a growing understanding of the dominant role intrinsic motivations can play in behavior. + +While intrinsic motivations can come from a number of different sources, the most straightforward one is the simple enjoyment of a particular activity. You play in a softball league after work because you like playing softball. You enjoy the exercise, the camaraderie, the game itself. + +Researchers have also proposed a further distinction between this enjoyment-based intrinsic motivation and obligation/community-based intrinsic motivation, which is more about adherence to social or community norms. Maybe you don’t really like having the relatives over for Thanksgiving but you do it anyway because you know you should. + +Today’s psychology literature also includes the idea of internalized extrinsic motivations. These are extrinsic motivations such as gaining skills to enhance career opportunities—but they’ve been internalized so that the motivation comes from within rather than the desire for whatever carrot is being dangled by someone else. + +### What motivates open source developers? + +In 2012, four researchers at [ETH Zurich][2] surveyed the prior ten years of study into open source software contribution. Among their results, they were able to group study findings into the following three categories: extrinsic motivation, intrinsic motivation, and internalized extrinsic motivation—as well as some common sub-groupings within those broader categories. + +No surprise that money showed up as an extrinsic motivator. During the period studied, there were fewer large projects associated with successful commercially-supported products than is the case today. Even so, most of the open source projects the researchers examined had a significant number of contributors whose companies had paid them to work on open source. + +Career obviously goes hand in hand with pay, but is open source software any different from proprietary software development in this regard? There’s some evidence that it is. + +Lerner and Tirole [first suggested in 2002][3] that "individual developers would be motivated by career concerns when developing open source software. By publishing software that was free for all to inspect, they could signal their talent to potential employers and thus increase their value in the labor market." + +More recently, there’s been significant empirical evidence that there are career advantages to developing code and making it available for others to see and work with. It has become almost an expectation in some industry segments for job applicants to have public GitHub code repositories, which are effectively part of their resume. + +It’s reasonable to ask whether this trend has gone too far. After all, many highly qualified developers work on proprietary code. But it’s clear that, fair or not, at least some career prospects can come specifically from being an open source developer. + +Among intrinsic motivators, ideology and altruism often seem closely related. + +Free software was primarily an ideological statement at first, even if user control also had an important practical side; several researchers have found support for ideological motives in developer surveys. + +Altruism can also be a developer motive, though research on this is mixed. One paper identified the “desire to give a present to the programmer community” as a crucial pattern in open source software. But other studies have qualified the importance of altruism as a motive, especially among programmers getting a paycheck. Other work found that altruism could be a motivator but only among developers who were otherwise satisfied. + +There’s also the motivational power of fun and enjoyment, a classic intrinsic motivator. This should come as no surprise to anyone who hangs around open source developers. Almost all of them like working on open source projects. One large 2007 study determined that fun accounted for 28 percent of the effort (in terms of number of hours) dedicated to projects. One implication of this research is that activities developers typically enjoy less–tech support often tops this list–may require alternative forms of motivation. + +Much of the research into reputation as an internalized extrinsic motivator has focused specifically on peer recognition. Your reputation among your peers can be a source of your own pride, but it also signals your talent to community insiders and potential employers. The suggestion that reputation could be an important motivator in contributing to open source goes back at least as far as 1998, in Eric Raymond’s essay ["Homesteading the Noosphere."][4] However, since then, a variety of surveys have supported the idea that peer reputation is a driver for participation. + +Another motivator in this category is what researchers call "own-use value" but is more recognizably described as something like "scratch your own itch"–develop something that you want for yourself and in the process, create something valuable to others. The initial motivation essentially comes from a selfish need but that can evolve into more of an internalized desire to contribute. + +Its unsurprising research would identify own-use value as a good motivator. Certainly, the folk wisdom is that many developers get into open source by developing something they themselves need—such as when Linus Torvalds wrote Git because Linux needed an appropriate distributed version control system. + +As we’ve seen, contributors to open source software have a variety of different motivations but there are a few general threads worth highlighting in closing. + +Motivators can actually be counterproductive when a single motivator is relied upon too heavily. One study reported that developers scratching their own itch worked "eclectically," fixing bugs that annoyed them and then quitting until the next time. + +In particular, don’t expect non-extrinsic motivators to carry too much of the load. Fun isn’t a good motivator if the task is not actually fun. Altruism motivates some but it also doesn’t pay their bills. + +That said, developers do contribute for reasons that aren’t purely about money or other extrinsic reasons. Learning, peer reputation, and recognition are important to many (and not just in open source development.) Organizations should not neglect the role these can play in motivating developers and should implement incentive programs around them, such as peer reward systems. + +* * * + +This post is based on material from _[How Open Source Ate Software][5]_ (Apress, 2018) by the author. + +There are lots of non-code ways to contribute to open source: Here are three alternatives. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/why-contribute-open-source-software + +作者:[Gordon Haff][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/ghaff +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/question-mark_chalkboard.jpg?itok=DaG4tje9 (question mark in chalk) +[2]: https://pdfs.semanticscholar.org/7712/3726f65f8fd88126357c12cad230cc832f41.pdf +[3]: https://onlinelibrary.wiley.com/doi/abs/10.1111/1467-6451.00174 +[4]: https://pdfs.semanticscholar.org/98a6/c566a7e28a48facb664c8689607a52c57a5d.pdf +[5]: https://www.apress.com/gp/book/9781484238936 diff --git a/sources/tech/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md b/sources/tech/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md index 356a64222f..d307c4f436 100644 --- a/sources/tech/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md +++ b/sources/tech/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md @@ -1,3 +1,4 @@ +lixin555 is translating Share And Upload Files To Compatible Hosting Sites Automatically ====== ![](https://www.ostechnix.com/wp-content/uploads/2017/10/Upload-720x340.png) diff --git a/sources/tech/20180810 Use Plank On Multiple Monitors Without Creating Multiple Docks With autoplank.md b/sources/tech/20180810 Use Plank On Multiple Monitors Without Creating Multiple Docks With autoplank.md deleted file mode 100644 index 29164e3510..0000000000 --- a/sources/tech/20180810 Use Plank On Multiple Monitors Without Creating Multiple Docks With autoplank.md +++ /dev/null @@ -1,77 +0,0 @@ -Use Plank On Multiple Monitors Without Creating Multiple Docks With autoplank -====== - -![](https://3.bp.blogspot.com/-BNHa6rP_kGk/W22cJrT3ghI/AAAAAAAABWA/TAKZgxJfYuwz-Me-M135-LWYl5qvs6cIwCLcBGAs/s640/plank-dock.png) - -**[autoplank][1] is a small tool written in Go which adds multi-monitor support to Plank dock without having to create [multiple][2] docks.** - -**When you move your mouse cursor to the bottom of a monitor, autoplank detect your mouse movement using** `xdotool` and it automatically moves Plank to that monitor. This tool **only works if Plank is set to run at the bottom of the screen** , at least for now. - -There's a slight delay until Plank actually shows up on the monitor where the mouse is though. The developer says this is intentional, to make sure you actually want to access Plank on that monitor. The time delay before showing plank is not currently configurable, but that may change in the future. - -autoplank should work with elementary OS, as well as any desktop environment or Linux distribution you use Plank dock on. - -Plank is a simple dock that shows icons of running applications / windows. The application allows pinning applications to the dock, and comes with a few built-in simple "docklets": a clipboard manager, clock, CPU monitor, show desktop and trash. To access its settings, hold down the `Ctrl` key while right clicking anywhere on the Plank dock, and then clicking on `Preferences` . - -Plank is used by default in elementary OS, but it can be used on any desktop environment or Linux distribution you wish. - -### Install autoplank - -On its GitHub page, it's mentioned that you need Go 1.8 or newer to build autoplank but I was able to successfully build it with Go 1.6 in Ubuntu 16.04 (elementary OS 0.4 Loki). - -The developer has said on - -**1\. Install required dependencies.** - -To build autoplank you'll need Go (`golang-go` in Debian, Ubuntu, elementary OS, etc.). To get the latest Git code you'll also need `git` , and for detecting the monitor on which you move the mose, you'll also need to install `xdotool` . - -Install these in Ubuntu, Debian, elementary OS and so on, by using this command: -``` -sudo apt install git golang-go xdotool - -``` - -**2\. Get the latest autoplank from[Git][1], build it, and install it in** `/usr/local/bin` : -``` -git clone https://github.com/abiosoft/autoplank -cd autoplank -go build -o autoplank -sudo mv autoplank /usr/local/bin/ - -``` - -You can remove the autoplank folder from your home directory now. - -When you want to uninstall autoplank, simply remove the `/usr/local/bin/autoplank` binary (`sudo rm /usr/local/bin/autoplank`). - -**3\. Add autoplank to startup.** - -If you want to try autoplank before adding it to startup or creating a systemd service for it, you can simply type `autoplank` in a terminal to start it. - -To have autoplank work between reboots, you'll need to add it to your startup applications. The exact steps for doing this depend on your desktop environments, so I won't tell you exactly how to do that for every desktop environment, but remember to use `/usr/local/bin/autoplank` as the executable in Startup Applications. - -In elementary OS, you can open `System Settings` , then in `Applications` , on the `Startup` tab, click the `+` button in the bottom left-hand side corner of the window, then add `/usr/local/bin/autoplank` in the `Type in a custom command` field: - -![](https://4.bp.blogspot.com/-hbh1PLDX-0A/W22eIhEQ1iI/AAAAAAAABWM/GkgrzaPPjA8CHnxF5L4UPPUG_vPa9VT-gCLcBGAs/s640/autoplank-startup-elementaryos.png) - -**Another way of using autoplank is by creating a systemd service for it, as explained[here][3].** Using a systemd service for autoplank has the advantage of restarting autoplank if it crashes for whatever reason. Use either the systemd service or add autoplank to your startup applications (don't use both). - -**4\. After you do this, logout, login and autoplank should be running so you can move the mouse at the bottom of a monitor to move Plank dock there.** - - --------------------------------------------------------------------------------- - -via: https://www.linuxuprising.com/2018/08/use-plank-on-multiple-monitors-without.html - -作者:[Logix][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://plus.google.com/118280394805678839070 -[1]:https://github.com/abiosoft/autoplank -[2]:https://answers.launchpad.net/plank/+question/204593 -[3]:https://github.com/abiosoft/autoplank#optional-create-a-service -[4]:https://www.reddit.com/r/elementaryos/comments/95a879/autoplank_use_plank_on_multimonitor_setup/e3r9saq/ diff --git a/sources/tech/20181109 Must-Have Tools for Writers on the Linux Platform.md b/sources/tech/20181109 Must-Have Tools for Writers on the Linux Platform.md deleted file mode 100644 index 0ab375a008..0000000000 --- a/sources/tech/20181109 Must-Have Tools for Writers on the Linux Platform.md +++ /dev/null @@ -1,118 +0,0 @@ -Must-Have Tools for Writers on the Linux Platform -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/writing-main.jpg?itok=qe96IkKm) -I’ve been a writer for more than 20 years. I’ve written thousands of articles and how-tos on various technical topics and have penned more than 40 works of fiction. So, the written word is not only important to me, it’s familiar to the point of being second nature. And through those two decades (and counting) I’ve done nearly all my work on the Linux platform. I must confess, during those early years it wasn’t always easy. Formats didn’t always mesh with what an editor required and, in some cases, the open source platform simply didn’t have the necessary tools required to get the job done. - -That was then, this is now. - -A perfect storm of Linux evolution and web-based tools have made it such that any writer can get the job done (and done well) on Linux. But what tools will you need? You might be surprised to find out that, in some instances, the job cannot be efficiently done with 100% open source tools. Even with that caveat, the job can be done. Let’s take a look at the tools I’ve been using as both a tech writer and author of fiction. I’m going to outline this by way of my writing process for both nonfiction and fiction (as the process is different and requires specific tools). - -A word of warning to seriously hard-core Linux users. A long time ago, I gave up on using tools like LaTeX and DocBook for my writing. Why? Because, for me, the focus must be on the content, not the process. When you’re facing deadlines, efficiency must take precedent. - -### Nonfiction - -We’ll start with nonfiction, as that process is the simpler of the two. For writing technical how-tos, I collaborate with different editors and, in some cases, have to copy/paste content into a CMS. But like with my fiction, the process always starts with Google Drive. This is the point at which many open source purists will check out. Fear not, you can always opt to either keep all of your files locally, or use a more open-friendly cloud service (such as [Zoho][1] or [nextCloud][2]). - -Why start on the cloud? Over the years, I’ve found I need to be able to access that content from anywhere at any time. The simplest solution was to migrate the cloud. I’ve also become paranoid about losing work. To that end, I make use of a tool like [Insync][3] to keep my Google Drive in sync with my desktop. With that desktop sync in place, I know there’s always a backup of my work, in case something should go awry with Google Drive. - -For those clients with whom I must enter content into a Content Management System (CMS), the process ends there. I can copy/paste directly from a Google Doc into the CMS and be done with it. Of course, with technical content, there are always screenshots involved. For that, I use [Gimp][4], which makes taking screenshots simple: - -![screenshot with Gimp][6] - -Figure 1: Taking a screenshot with Gimp. - -[Used with permission][7] - - 1. Open Gimp. - - 2. Click File > Create > Screenshot. - - 3. Select from a single window, the entire screen, or a region to grab (Figure 1). - - 4. Click Snap. - - - - -The majority of my clients tend to prefer I work with Google Docs, because I can share folders so that they have reliable access to the content. There are a few clients I have that do not work with Google Docs, and so I must download the files into a format that can be used. What I do for this is download in .odt format, open the document in [LibreOffice][8] (Figure 2), format as needed, save in a format required by the client, and send the document on. - -![Google Doc][10] - -Figure 2: My Google Doc download opened in LibreOffice. - -[Used with permission][7] - -And that, is the end of the line for nonfiction. - -### Fiction - -This is where it gets a bit more complicated. The beginning steps are the same, as I always write every first draft of a novel in Google Docs. Once that is complete, I then download the file to my Linux desktop, open the file in LibreOffice, format as necessary, and then save as a file type supported by my editor (unfortunately, that means .docx). - -The next step in the process gets a bit dicey. My editor prefers to use comments over track changes (as it makes it easier for both of us to read the document as we make changes). Because of this, a 60k word doc can include hundreds upon hundreds of comments, which slows LibreOffice to a useless crawl. Once upon a time, you could up the memory used for documents, but as of LibreOffice 6, that is no longer possible. This means any larger, novel-length, document with numerous comments will become unusable. Because of that, I’ve had to take drastic measures and use [WPS Office][11] (Figure 3). Although this isn’t an open source solution, WPS Office does a fine job with numerous comments in a document, so there’s no need to deal with the frustration that is LibreOffice (when working with these large files with hundreds of comments). - -![comments][13] - -Figure 3: WPS handles numerous comments with ease. - -[Used with permission][7] - -Once my editor and I finish up the edits for the book (and all comments have been removed), I can then open the file in LibreOffice for final formatting. When the formatting is complete, I save the file in .html format and then open the file in [Calibre][14] for exporting the file to .mobi and .epub formats. - -Calibre is a must-have for anyone looking to publish on Amazon, Barnes & Noble, Smashwords, or other platforms. One thing Calibre does better than other, similar, solutions is enable you to directly edit the .epub files (Figure 4). For the likes of Smashword, this is an absolute necessity (as the export process will add elements not accepted on the Smashwords conversion tool). - -![Calibre][16] - -Figure 4: Editing an epub file directly in Calibre. - -[Creative Commons Zero][17] - -After the writing process is over (or sometimes while waiting for an editor to complete a pass), I’ll start working on the cover for the book. That task is handled completely in Gimp (Figure 5). - -![Using Gimp][19] - -Figure 5: Creating the cover of POTUS in Gimp. - -[Used with permission][7] - -And that finishes up the process of creating a work of fiction on the Linux platform. Because of the length of the documents, and how some editors work, it can get a bit more complicated than the process of creating nonfiction, but it’s far from challenging. In fact, creating fiction on Linux is just as simple (and more reliable) than other platforms. - -### HTH - -I hope this helps aspiring writers to have the confidence to write on the Linux platform. There are plenty of other tools available to use, but the ones I have listed here have served me quite well over the years. And although I do make use of a couple of proprietary tools, as long as they keep working well on Linux, I’m okay with that. - -Learn more about Linux in the[ Introduction to Open Source Development, Git, and Linux (LFD201) ][20]training course from The Linux Foundation, and sign up now to start your open source journey. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/2018/11/must-have-tools-writers-linux-platform - -作者:[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]: https://www.zoho.com/ -[2]: https://nextcloud.com/ -[3]: https://www.insynchq.com -[4]: https://www.gimp.org/ -[5]: /files/images/writingtools1jpg -[6]: https://www.linux.com/sites/lcom/files/styles/floated_images/public/writingtools_1.jpg?itok=Uko7DZ8U (screenshot with Gimp) -[7]: /licenses/category/used-permission -[8]: https://www.libreoffice.org/ -[9]: /files/images/writingtools2jpg -[10]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/writingtools_2.jpg?itok=vDgxd8hu (Google Doc) -[11]: https://www.wps.com/en-US/ -[12]: /files/images/writingtools3jpg -[13]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/writingtools_3.jpg?itok=AYrsfz01 (comments) -[14]: https://calibre-ebook.com/ -[15]: /files/images/writingtools4jpg -[16]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/writingtools_4.jpg?itok=wFMEsL7b (Calibre) -[17]: /licenses/category/creative-commons-zero -[18]: /files/images/writingtools5jpg -[19]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/writingtools_5.jpg?itok=e7SZCgip (Using Gimp) -[20]: https://training.linuxfoundation.org/training/introduction-to-open-source-development-git-and-linux/?utm_source=linux.com&utm_medium=article&utm_campaign=lfd201 diff --git a/sources/tech/20190328 Can Better Task Stealing Make Linux Faster.md b/sources/tech/20190328 Can Better Task Stealing Make Linux Faster.md deleted file mode 100644 index bae14a2f5c..0000000000 --- a/sources/tech/20190328 Can Better Task Stealing Make Linux Faster.md +++ /dev/null @@ -1,133 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Can Better Task Stealing Make Linux Faster?) -[#]: via: (https://www.linux.com/blog/can-better-task-stealing-make-linux-faster) -[#]: author: (Oracle ) - -Can Better Task Stealing Make Linux Faster? -====== - -_Oracle Linux kernel developer Steve Sistare contributes this discussion on kernel scheduler improvements._ - -### Load balancing via scalable task stealing - -The Linux task scheduler balances load across a system by pushing waking tasks to idle CPUs, and by pulling tasks from busy CPUs when a CPU becomes idle. Efficient scaling is a challenge on both the push and pull sides on large systems. For pulls, the scheduler searches all CPUs in successively larger domains until an overloaded CPU is found, and pulls a task from the busiest group. This is very expensive, costing 10's to 100's of microseconds on large systems, so search time is limited by the average idle time, and some domains are not searched. Balance is not always achieved, and idle CPUs go unused. - -I have implemented an alternate mechanism that is invoked after the existing search in idle_balance() limits itself and finds nothing. I maintain a bitmap of overloaded CPUs, where a CPU sets its bit when its runnable CFS task count exceeds 1. The bitmap is sparse, with a limited number of significant bits per cacheline. This reduces cache contention when many threads concurrently set, clear, and visit elements. There is a bitmap per last-level cache. When a CPU becomes idle, it searches the bitmap to find the first overloaded CPU with a migratable task, and steals it. This simple stealing yields a higher CPU utilization than idle_balance() alone, because the search is cheap, costing 1 to 2 microseconds, so it may be called every time the CPU is about to go idle. Stealing does not offload the globally busiest queue, but it is much better than running nothing at all. - -### Results - -Stealing improves utilization with only a modest CPU overhead in scheduler code. In the following experiment, hackbench is run with varying numbers of groups (40 tasks per group), and the delta in /proc/schedstat is shown for each run, averaged per CPU, augmented with these non-standard stats: - - * %find - percent of time spent in old and new functions that search for idle CPUs and tasks to steal and set the overloaded CPUs bitmap. - * steal - number of times a task is stolen from another CPU. Elapsed time improves by 8 to 36%, costing at most 0.4% more find time. - - - -![load balancing][1] - -[Used with permission][2] - -​​CPU busy utilization is close to 100% for the new kernel, as shown by the green curve in the following graph, versus the orange curve for the baseline kernel: - -![][3] - -Stealing improves Oracle database OLTP performance by up to 9% depending on load, and we have seen some nice improvements for mysql, pgsql, gcc, java, and networking. In general, stealing is most helpful for workloads with a high context switch rate. - -### The code - -As of this writing, this work is not yet upstream, but the latest patch series is at [https://lkml.org/lkml/2018/12/6/1253. ][4]If your kernel is built with CONFIG_SCHED_DEBUG=y, you can verify that it contains the stealing optimization using - -``` -# grep -q STEAL /sys/kernel/debug/sched_features && echo Yes -Yes -``` - -If you try it, note that stealing is disabled for systems with more than 2 NUMA nodes, because hackbench regresses on such systems, as I explain in [https://lkml.org/lkml/2018/12/6/1250 .][5]However, I suspect this effect is specific to hackbench and that stealing will help other workloads on many-node systems. To try it, reboot with kernel parameter sched_steal_node_limit = 8 (or larger). - -### Future work - -After the basic stealing algorithm is pushed upstream, I am considering the following enhancements: - - * If stealing within the last-level cache does not find a candidate, steal across LLC's and NUMA nodes. - * Maintain a sparse bitmap to identify stealing candidates in the RT scheduling class. Currently pull_rt_task() searches all run queues. - * Remove the core and socket levels from idle_balance(), as stealing handles those levels. Remove idle_balance() entirely when stealing across LLC is supported. - * Maintain a bitmap to identify idle cores and idle CPUs, for push balancing. - - - -_This article originally appeared at[Oracle Developers Blog][6]._ - -_Oracle Linux kernel developer Steve Sistare contributes this discussion on kernel scheduler improvements._ - -### Load balancing via scalable task stealing - -The Linux task scheduler balances load across a system by pushing waking tasks to idle CPUs, and by pulling tasks from busy CPUs when a CPU becomes idle. Efficient scaling is a challenge on both the push and pull sides on large systems. For pulls, the scheduler searches all CPUs in successively larger domains until an overloaded CPU is found, and pulls a task from the busiest group. This is very expensive, costing 10's to 100's of microseconds on large systems, so search time is limited by the average idle time, and some domains are not searched. Balance is not always achieved, and idle CPUs go unused. - -I have implemented an alternate mechanism that is invoked after the existing search in idle_balance() limits itself and finds nothing. I maintain a bitmap of overloaded CPUs, where a CPU sets its bit when its runnable CFS task count exceeds 1. The bitmap is sparse, with a limited number of significant bits per cacheline. This reduces cache contention when many threads concurrently set, clear, and visit elements. There is a bitmap per last-level cache. When a CPU becomes idle, it searches the bitmap to find the first overloaded CPU with a migratable task, and steals it. This simple stealing yields a higher CPU utilization than idle_balance() alone, because the search is cheap, costing 1 to 2 microseconds, so it may be called every time the CPU is about to go idle. Stealing does not offload the globally busiest queue, but it is much better than running nothing at all. - -### Results - -Stealing improves utilization with only a modest CPU overhead in scheduler code. In the following experiment, hackbench is run with varying numbers of groups (40 tasks per group), and the delta in /proc/schedstat is shown for each run, averaged per CPU, augmented with these non-standard stats: - - * %find - percent of time spent in old and new functions that search for idle CPUs and tasks to steal and set the overloaded CPUs bitmap. - * steal - number of times a task is stolen from another CPU. Elapsed time improves by 8 to 36%, costing at most 0.4% more find time. - - - -![load balancing][1] - -[Used with permission][2] - -​​CPU busy utilization is close to 100% for the new kernel, as shown by the green curve in the following graph, versus the orange curve for the baseline kernel: - -![][3] - -Stealing improves Oracle database OLTP performance by up to 9% depending on load, and we have seen some nice improvements for mysql, pgsql, gcc, java, and networking. In general, stealing is most helpful for workloads with a high context switch rate. - -### The code - -As of this writing, this work is not yet upstream, but the latest patch series is at [https://lkml.org/lkml/2018/12/6/1253. ][4]If your kernel is built with CONFIG_SCHED_DEBUG=y, you can verify that it contains the stealing optimization using - -``` -# grep -q STEAL /sys/kernel/debug/sched_features && echo Yes -Yes -``` - -If you try it, note that stealing is disabled for systems with more than 2 NUMA nodes, because hackbench regresses on such systems, as I explain in [https://lkml.org/lkml/2018/12/6/1250 .][5]However, I suspect this effect is specific to hackbench and that stealing will help other workloads on many-node systems. To try it, reboot with kernel parameter sched_steal_node_limit = 8 (or larger). - -### Future work - -After the basic stealing algorithm is pushed upstream, I am considering the following enhancements: - - * If stealing within the last-level cache does not find a candidate, steal across LLC's and NUMA nodes. - * Maintain a sparse bitmap to identify stealing candidates in the RT scheduling class. Currently pull_rt_task() searches all run queues. - * Remove the core and socket levels from idle_balance(), as stealing handles those levels. Remove idle_balance() entirely when stealing across LLC is supported. - * Maintain a bitmap to identify idle cores and idle CPUs, for push balancing. - - - -_This article originally appeared at[Oracle Developers Blog][6]._ - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/can-better-task-stealing-make-linux-faster - -作者:[Oracle][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: -[b]: https://github.com/lujun9972 -[1]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/linux-load-balancing.png?itok=2Uk1yALt (load balancing) -[2]: /LICENSES/CATEGORY/USED-PERMISSION -[3]: https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/b7a700fe-edc3-4ea0-876a-c91e1850b59b/Image/00c074f4282bcbaf0c10dd153c5dfa76/steal_graph.png -[4]: https://lkml.org/lkml/2018/12/6/1253 -[5]: https://lkml.org/lkml/2018/12/6/1250 -[6]: https://blogs.oracle.com/linux/can-better-task-stealing-make-linux-faster diff --git a/sources/tech/20190404 Why blockchain (might be) coming to an IoT implementation near you.md b/sources/tech/20190404 Why blockchain (might be) coming to an IoT implementation near you.md deleted file mode 100644 index f5915aebe7..0000000000 --- a/sources/tech/20190404 Why blockchain (might be) coming to an IoT implementation near you.md +++ /dev/null @@ -1,79 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Why blockchain (might be) coming to an IoT implementation near you) -[#]: via: (https://www.networkworld.com/article/3386881/why-blockchain-might-be-coming-to-an-iot-implementation-near-you.html#tk.rss_all) -[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) - -Why blockchain (might be) coming to an IoT implementation near you -====== - -![MF3D / Getty Images][1] - -Companies have found that IoT partners well with a host of other popular enterprise computing technologies of late, and blockchain – the innovative system of distributed trust most famous for underpinning cryptocurrencies – is no exception. Yet while the two phenomena can be complementary in certain circumstances, those expecting an explosion of blockchain-enabled IoT technologies probably shouldn’t hold their breath. - -Blockchain technology can be counter-intuitive to understand at a basic level, but it’s probably best thought of as a sort of distributed ledger keeping track of various transactions. Every “block” on the chain contains transactional records or other data to be secured against tampering, and is linked to the previous one by a cryptographic hash, which means that any tampering with the block will invalidate that connection. The nodes – which can be largely anything with a CPU in it – communicate via a decentralized, peer-to-peer network to share data and ensure the validity of the data in the chain. - -**[ Also see[What is edge computing?][2] and [How edge networking and IoT will reshape data centers][3].]** - -The system works because all the blocks have to agree with each other on the specifics of the data that they’re safeguarding, according to Nir Kshetri, a professor of management at the University of North Carolina – Greensboro. If someone attempts to alter a previous transaction on a given node, the rest of the data on the network pushes back. “The old record of the data is still there,” said Kshetri. - -That’s a powerful security technique – absent a bad actor successfully controlling all of the nodes on a given blockchain (the [famous “51% attack][4]”), the data protected by that blockchain can’t be falsified or otherwise fiddled with. So it should be no surprise that the use of blockchain is an attractive option to companies in some corners of the IoT world. - -Part of the reason for that, over and above the bare fact of blockchain’s ability to securely distribute trusted information across a network, is its place in the technology stack, according to Jay Fallah, CTO and co-founder of NXMLabs, an IoT security startup. - -“Blockchain stands at a very interesting intersection. Computing has accelerated in the last 15 years [in terms of] storage, CPU, etc, but networking hasn’t changed that much until recently,” he said. “[Blockchain]’s not a network technology, it’s not a data technology, it’s both.” - -### Blockchain and IoT** - -** - -Where blockchain makes sense as a part of the IoT world depends on who you speak to and what they are selling, but the closest thing to a general summation may have come from Allison Clift-Jenning, CEO of enterprise blockchain vendor Filament. - -“Anywhere where you've got people who are kind of wanting to trust each other, and have very archaic ways of doing it, that is usually a good place to start with use cases,” she said. - -One example, culled directly from Filament’s own customer base, is used car sales. Filament’s working with “a major Detroit automaker” to create a trusted-vehicle history platform, based on a device that plugs into the diagnostic port of a used car, pulls information from there, and writes that data to a blockchain. Just like that, there’s an immutable record of a used car’s history, including whether its airbags have ever been deployed, whether it’s been flooded, and so on. No unscrupulous used car lot or duplicitous former owner could change the data, and even unplugging the device would mean that there’s a suspicious blank period in the records. - -Most of present-day blockchain IoT implementation is about trust and the validation of data, according to Elvira Wallis, senior vice president and global head of IoT at SAP. - -“Most of the use cases that we have come across are in the realm of tracking and tracing items,” she said, giving the example of a farm-to-fork tracking system for high-end foodstuffs, using blockchain nodes mounted on crates and trucks, allowing for the creation of an un-fudgeable record of an item’s passage through transport infrastructure. (e.g., how long has this steak been refrigerated at such-and-such a temperature, how far has it traveled today, and so on.) - -### **Is using blockchain with IoT a good idea?** - -Different vendors sell different blockchain-based products for different use cases, which use different implementations of blockchain technology, some of which don’t bear much resemblance to the classic, linear, mined-transaction blockchain used in cryptocurrency. - -That means it’s a capability that you’d buy from a vendor for a specific use case, at this point. Few client organizations have the in-house expertise to implement a blockchain security system, according to 451 Research senior analyst Csilla Zsigri. - -The idea with any intelligent application of blockchain technology is to play to its strengths, she said, creating a trusted platform for critical information. - -“That’s where I see it really adding value, just in adding a layer of trust and validation,” said Zsigri. - -Yet while the basic idea of blockchain-enabled IoT applications is fairly well understood, it’s not applicable to every IoT use case, experts agree. Applying blockchain to non-transactional systems – although there are exceptions, including NXM Labs’ blockchain-based configuration product for IoT devices – isn’t usually the right move. - -If there isn’t a need to share data between two different parties – as opposed to simply moving data from sensor to back-end – blockchain doesn’t generally make sense, since it doesn’t really do anything for the key value-add present in most IoT implementations today: data analysis. - -“We’re still in kind of the early dial-up era of blockchain today,” said Clift-Jennings. “It’s slower than a typical database, it often isn't even readable, it often doesn't have a query engine tied to it. You don't really get privacy, by nature of it.” - -Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3386881/why-blockchain-might-be-coming-to-an-iot-implementation-near-you.html#tk.rss_all - -作者:[Jon Gold][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.networkworld.com/author/Jon-Gold/ -[b]: https://github.com/lujun9972 -[1]: https://images.idgesg.net/images/article/2019/02/chains_binary_data_blockchain_security_by_mf3d_gettyimages-941175690_2400x1600-100788434-large.jpg -[2]: https://www.networkworld.com/article/3224893/internet-of-things/what-is-edge-computing-and-how-it-s-changing-the-network.html -[3]: https://www.networkworld.com/article/3291790/data-center/how-edge-networking-and-iot-will-reshape-data-centers.html -[4]: https://bitcoinist.com/51-percent-attack-hackers-steals-18-million-bitcoin-gold-btg-tokens/ -[5]: https://www.facebook.com/NetworkWorld/ -[6]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md b/sources/tech/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md deleted file mode 100644 index e3a533b3b2..0000000000 --- a/sources/tech/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md +++ /dev/null @@ -1,200 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server) -[#]: via: (https://www.linuxtechi.com/install-lemp-stack-fedora-30-server/) -[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) - -How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server -====== - -In this article, we’ll be looking at how to install **LEMP** stack on Fedora 30 Server. LEMP Stands for: - - * L -> Linux - * E -> Nginx - * M -> Maria DB - * P -> PHP - - - -I am assuming **[Fedora 30][1]** is already installed on your system. - -![LEMP-Stack-Fedora30][2] - -LEMP is a collection of powerful software setup that is installed on a Linux server to help in developing popular development platforms to build websites, LEMP is a variation of LAMP wherein instead of **Apache** , **EngineX (Nginx)** is used as well as **MariaDB** used in place of **MySQL**. This how-to guide is a collection of separate guides to install Nginx, Maria DB and PHP. - -### Install Nginx, PHP 7.3 and PHP-FPM on Fedora 30 Server - -Let’s take a look at how to install Nginx and PHP along with PHP FPM on Fedora 30 Server. - -### Step 1) Switch to root user - -First step in installing Nginx in your system is to switch to root user. Use the following command : - -``` -root@linuxtechi ~]$ sudo -i -[sudo] password for pkumar: -[root@linuxtechi ~]# -``` - -### Step 2) Install Nginx, PHP 7.3 and PHP FPM using dnf command - -Install Nginx using the following dnf command: - -``` -[root@linuxtechi ~]# dnf install nginx php php-fpm php-common -y -``` - -### Step 3) Install Additional PHP modules - -The default installation of PHP only comes with the basic and the most needed modules installed. If you need additional modules like GD, XML support for PHP, command line interface Zend OPCache features etc, you can always choose your packages and install everything in one go. See the sample command below: - -``` -[root@linuxtechi ~]# sudo dnf install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-pecl-mongodb php-pecl-redis php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml -y -``` - -### Step 4) Start & Enable Nginx and PHP-fpm Service - -Start and enable Nginx service using the following command - -``` -[root@linuxtechi ~]# systemctl start nginx && systemctl enable nginx -Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service. -[root@linuxtechi ~]# -``` - -Use the following command to start and enable PHP-FPM service - -``` -[root@linuxtechi ~]# systemctl start php-fpm && systemctl enable php-fpm -Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service. -[root@linuxtechi ~]# -``` - -**Verify Nginx (Web Server) and PHP installation,** - -**Note:** In case OS firewall is enabled and running on your Fedora 30 system, then allow 80 and 443 ports using beneath commands, - -``` -[root@linuxtechi ~]# firewall-cmd --permanent --add-service=http -success -[root@linuxtechi ~]# -[root@linuxtechi ~]# firewall-cmd --permanent --add-service=https -success -[root@linuxtechi ~]# firewall-cmd --reload -success -[root@linuxtechi ~]# -``` - -Open the web browser, type the following URL: http:// - -[![Test-Page-HTTP-Server-Fedora-30][3]][4] - -Above screen confirms that NGINX is installed successfully. - -Now let’s verify PHP installation, create a test php page(info.php) using the beneath command, - -``` -[root@linuxtechi ~]# echo "" > /usr/share/nginx/html/info.php -[root@linuxtechi ~]# -``` - -Type the following URL in the web browser, - -http:///info.php - -[![Php-info-page-fedora30][5]][6] - -Above page confirms that PHP 7.3.5 has been installed successfully. Now let’s install MariaDB database server. - -### Install MariaDB on Fedora 30 - -MariaDB is a great replacement for MySQL DB as it is works much similar to MySQL and also compatible with MySQL steps too. Let’s look at the steps to install MariaDB on Fedora 30 Server - -### Step 1) Switch to Root User - -First step in installing MariaDB in your system is to switch to root user or you can use a local user who has root privilege. Use the following command below: - -``` -[root@linuxtechi ~]# sudo -i -[root@linuxtechi ~]# -``` - -### Step 2) Install latest version of MariaDB (10.3) using dnf command - -Use the following command to install MariaDB on Fedora 30 Server - -``` -[root@linuxtechi ~]# dnf install mariadb-server -y -``` - -### Step 3) Start and enable MariaDB Service - -Once the mariadb is installed successfully in step 2), next step is to start the MariaDB service. Use the following command: - -``` -[root@linuxtechi ~]# systemctl start mariadb.service ; systemctl enable mariadb.service -``` - -### Step 4) Secure MariaDB Installation - -When we install MariaDB server, so by default there is no root password, also anonymous users are created in database. So, to secure MariaDB installation, run the beneath “mysql_secure_installation” command - -``` -[root@linuxtechi ~]# mysql_secure_installation -``` - -Next you will be prompted with some question, just answer the questions as shown below: - -![Secure-MariaDB-Installation-Part1][7] - -![Secure-MariaDB-Installation-Part2][8] - -### Step 5) Test MariaDB Installation - -Once you have installed, you can always test if MariaDB is successfully installed on the server. Use the following command: - -``` -[root@linuxtechi ~]# mysql -u root -p -Enter password: -``` - -Next you will be prompted for a password. Enter the password same password that you have set during MariaDB secure installation, then you can see the MariaDB welcome screen. - -``` -Welcome to the MariaDB monitor. Commands end with ; or \g. -Your MariaDB connection id is 17 -Server version: 10.3.12-MariaDB MariaDB Server - -Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. - -Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. - -MariaDB [(none)]> -``` - -And finally, we’ve completed everything to install LEMP (Linux, Nginx, MariaDB and PHP) on your server successfully. Please post all your comments and suggestions in the feedback section below and we’ll respond back at the earliest. - --------------------------------------------------------------------------------- - -via: https://www.linuxtechi.com/install-lemp-stack-fedora-30-server/ - -作者:[Pradeep Kumar][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.linuxtechi.com/author/pradeep/ -[b]: https://github.com/lujun9972 -[1]: https://www.linuxtechi.com/fedora-30-workstation-installation-guide/ -[2]: https://www.linuxtechi.com/wp-content/uploads/2019/06/LEMP-Stack-Fedora30.jpg -[3]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Test-Page-HTTP-Server-Fedora-30-1024x732.jpg -[4]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Test-Page-HTTP-Server-Fedora-30.jpg -[5]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Php-info-page-fedora30-1024x732.jpg -[6]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Php-info-page-fedora30.jpg -[7]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Secure-MariaDB-Installation-Part1.jpg -[8]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Secure-MariaDB-Installation-Part2.jpg diff --git a/sources/tech/20190718 What you need to know to be a sysadmin.md b/sources/tech/20190718 What you need to know to be a sysadmin.md deleted file mode 100644 index 55947b8456..0000000000 --- a/sources/tech/20190718 What you need to know to be a sysadmin.md +++ /dev/null @@ -1,121 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (What you need to know to be a sysadmin) -[#]: via: (https://opensource.com/article/19/7/be-a-sysadmin) -[#]: author: (Seth Kenlon https://opensource.com/users/sethhttps://opensource.com/users/marcobravohttps://opensource.com/users/kimvila) - -What you need to know to be a sysadmin -====== -Kickstart your sysadmin career by gaining these minimum competencies. -![People work on a computer server with devices][1] - -The system administrator of yesteryear jockeyed users and wrangled servers all day, in between mornings and evenings spent running hundreds of meters of hundreds of cables. This is still true today, with the added complexity of cloud computing, containers, and virtual machines. - -Looking in from the outside, it can be difficult to pinpoint what exactly a sysadmin does, because they play at least a small role in so many places. Nobody goes into a career already knowing everything they need for a job, but everyone needs a strong foundation. If you're looking to start down the path of system administration, here's what you should be concentrating on in your personal or formal training. - -### Bash - -When you learn the Bash shell, you don't just learn the Bash shell. You learn a common interface to Linux systems, BSD, MacOS, and even Windows (under the right conditions). You learn the importance of syntax, so you can quickly adapt to systems like Cisco routers' command line or Microsoft's PowerShell, and eventually, you can even learn more powerful languages like Python or Go. And you also begin to think procedurally so you can analyze complex problems and break them down into individual components, which is key because _that's_ how systems, like the internet, or an organization's intranet, or a web server, or a backup solution, are designed. - -But wait. There's more. - -Knowing the Bash shell has become particularly important because of the recent trend toward DevOps and [containers][2]. Your career as a sysadmin may lead you into a world where infrastructure is treated like code, which usually means you'll have to know the basics of scripting, the structure of [YAML-based][3] configuration, and how to [interact][4] with [containers][5] (tiny Linux systems running inside a [sandboxed file][6]). Knowing Bash is the gateway to efficient management of the most exciting open source technology, so go get [Bourne Again][7]. - -#### Resources - -There are many ways to get practice in the Bash shell. - -Try a [portable Linux distribution][8]. You don't have to install Linux to use Linux, so grab a spare thumb drive and spend your evenings or weekends getting comfortable with a text-based interface. - -There are several excellent [Bash articles][9] available here on opensource.com as well as [on Enable SysAdmin][10]. - -The problem with telling someone to practice with Bash is that to practice, you must have something to do. And until you know how to use Bash, you probably won't be able to think of anything to do. If that's your situation, go to Over The Wire and play [Bandit][11]. It's a game aimed at absolute beginners, with 34 levels of interactive basic hacking to get you comfortable with the Linux shell. - -### Web server setup - -Once you're comfortable with Bash, you should try setting up a web server. Not all sysadmins go around setting up web servers or even maintain web servers, but the skills you acquire while installing and starting the HTTP daemon, configuring Apache or Nginx, setting up the [correct permissions][12], and [configuring a firewall][13], are the same skills you need on a daily basis. After a little bit of effort, you may start to notice certain patterns in your labor. There are concepts you probably took for granted before trying to administer production-ready software and hardware, and you're no longer shielded from them in your fledgling role as an administrator. It might be frustrating at first because everyone likes to be good at everything they do, but that's actually a good thing. Let yourself be bad at new skills. That's how you learn. - -And besides, the more you struggle through your first steps, the sweeter it is when you finally see that triumphant "it works!" default index.html. - -#### Resources - -David Both wrote an excellent article on [Apache web server][14] configuration. For extra credit, step through his follow-up article on how to [host multiple sites][15] on one machine. - -### DHCP - -The Dynamic Host Configuration Protocol (DHCP) is the system that assigns IP addresses to devices on a network. At home, the modem or router your ISP (internet service provider) supports probably has an embedded DHCP server in it, so it's likely out of your purview. If you've ever logged into your home router to adjust the IP address range or set up a static address for some of your network devices, then you're at least somewhat familiar with the concept. You may understand that devices on a network are assigned the equivalent of phone numbers in the form of IP addresses, and you may realize that computers communicate with one another by broadcasting messages addressed to a specific IP address. Message headers are read by routers along the path, each of which works to direct the message to the next most logical router along the path toward its ultimate goal. - -Even if you understand these concepts, the inevitable escalation of basic familiarity with DHCP is to set up a DHCP server. Installing and configuring your own DHCP server provides you the opportunity to introduce DHCP collisions on your home network (try to avoid that, if you can, as it will definitely kill your network until it's resolved), control the distribution of addresses, create subnets, and monitor connections and lease times. - -More importantly, setting up DHCP and experimenting with different configurations helps you understand inter-networking. You understand how networks represent "partitions" in data transference and what steps you have to take to pass information from one to the other. That's vital for a sysadmin to know because the network is easily one of the most important aspects of the job. - -#### Resources - -Before running your own DHCP server, ensure that the DHCP server in your home router (if you have one) is inactive. Once you have it up and running, read Archit Modi's [guide to network commands][16] for tips on how to explore your network. - -### Network cables - -It might sound mundane, but getting familiar with how network cables work not only makes for a really fun weekend but also gives you a whole new understanding of how data gets across the wires. The best way to learn is to go to your local hobby shop and purchase a Cat 5 cutter and crimper and a few Cat 5 terminators. Then head home, grab a spare Ethernet cable, and cut the terminators off. Spend whatever amount of time it takes to get that cable back in commission. - -Once you have solved that puzzle, do it again, this time creating a working [crossover cable][17]. - -You should also start obsessing _now_ about cable management. If you're not naturally inclined to run cables neatly along the floor molding or the edges of a desk or to bind cables together to keep them orderly, then make it a goal to permanently condition yourself with a phobia of messy cables. You won't understand why this is necessary at first, but the first time you walk into a server room, you will immediately know. - -### Ansible - -[Ansible][18] is configuration management software, and it's a bit of a bridge between sysadmin and DevOps. Sysadmins use Ansible to configure fresh installs of an operating system and to maintain specific states on machines. DevOps uses Ansible to reduce time and effort spent on tooling so that more time and effort gets spent on developing. You should learn Ansible as part of your sysadmin training, with an eye toward the practices of DevOps, because most of what DevOps is pioneering now will end up as part of your workflow in the system administration of the future. - -The good thing about Ansible is that you can start using it now. It's cross-platform, and it scales both up and down. Ansible may be overkill for a single-user computer, but then again, Ansible could change the way you spin up virtual machines, or it could help you synchronize the states of all the computers in your home or [home lab][19]. - -#### Resources - -Read "[How to manage your workstation configuration with Ansible][20]" by Jay LaCroix for the quintessential introduction to get started with Ansible on a casual basis. - -### Break stuff - -Problems arise on computers because of user error, buggy software, administrator (that's you!) error, and any number of other factors. There's no way to predict what's going to fail or why, so part of your personal sysadmin training regime should be to poke at the systems you set up until they fail. The worse you are to your own lab infrastructure, the more likely you are to find weak points. And the more often you repair those weak spots, the more confident you become in your problem-solving skills. - -Aside from the rigors of setting up all the usual software and hardware, your primary job as a sysadmin is to find solutions. There will be times when you encounter a problem outside your job description, and it may not even be possible for you to fix it, but it'll be up to you to find a workaround. - -The more you break stuff now and work to fix it, the better prepared you will be to work as a sysadmin. - -* * * - -Are you a working sysadmin? Are there tasks you wish you'd prepared better for? Add them in the comments below! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/7/be-a-sysadmin - -作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/sethhttps://opensource.com/users/marcobravohttps://opensource.com/users/kimvila -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux11x_cc.png?itok=XMDOouJR (People work on a computer server with devices) -[2]: https://opensource.com/article/19/6/kubernetes-dump-truck -[3]: https://www.redhat.com/sysadmin/yaml-tips -[4]: https://opensource.com/article/19/6/how-ssh-running-container -[5]: https://opensource.com/resources/what-are-linux-containers -[6]: https://opensource.com/article/18/11/behind-scenes-linux-containers -[7]: https://opensource.com/article/18/7/admin-guide-bash -[8]: https://opensource.com/article/19/6/linux-distros-to-try -[9]: https://opensource.com/tags/bash -[10]: https://www.redhat.com/sysadmin/managing-files-linux-terminal -[11]: http://overthewire.org/wargames/bandit -[12]: https://opensource.com/article/19/6/understanding-linux-permissions -[13]: https://www.redhat.com/sysadmin/secure-linux-network-firewall-cmd -[14]: https://opensource.com/article/18/2/how-configure-apache-web-server -[15]: https://opensource.com/article/18/3/configuring-multiple-web-sites-apache -[16]: https://opensource.com/article/18/7/sysadmin-guide-networking-commands -[17]: https://en.wikipedia.org/wiki/Ethernet_crossover_cable -[18]: https://opensource.com/sitewide-search?search_api_views_fulltext=ansible -[19]: https://opensource.com/article/19/6/create-centos-homelab-hour -[20]: https://opensource.com/article/18/3/manage-workstation-ansible diff --git a/sources/tech/20190801 Linux permissions 101.md b/sources/tech/20190801 Linux permissions 101.md deleted file mode 100644 index cfbc3d0a29..0000000000 --- a/sources/tech/20190801 Linux permissions 101.md +++ /dev/null @@ -1,346 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Linux permissions 101) -[#]: via: (https://opensource.com/article/19/8/linux-permissions-101) -[#]: author: (Alex Juarez https://opensource.com/users/mralexjuarezhttps://opensource.com/users/marcobravohttps://opensource.com/users/greg-p) - -Linux permissions 101 -====== -Knowing how to control users' access to files is a fundamental system -administration skill. -![Penguins][1] - -Understanding Linux permissions and how to control which users have access to files is a fundamental skill for systems administration. - -This article will cover standard Linux file systems permissions, dig further into special permissions, and wrap up with an explanation of default permissions using **umask**. - -### Understanding the ls command output - -Before we can talk about how to modify permissions, we need to know how to view them. The **ls** command with the long listing argument (**-l**) gives us a lot of information about a file. - - -``` -$ ls -lAh -total 20K --rwxr-xr--+ 1 root root    0 Mar  4 19:39 file1 --rw-rw-rw-. 1 root root    0 Mar  4 19:39 file10 --rwxrwxr--+ 1 root root    0 Mar  4 19:39 file2 --rw-rw-rw-. 1 root root    0 Mar  4 19:39 file8 --rw-rw-rw-. 1 root root    0 Mar  4 19:39 file9 -drwxrwxrwx. 2 root root 4.0K Mar  4 20:04 testdir -``` - -To understand what this means, let's break down the output regarding the permissions into individual sections. It will be easier to reference each section individually. - -Take a look at each component of the final line in the output above: - - -``` -`drwxrwxrwx. 2 root root 4.0K Mar  4 20:04 testdir` -``` - -Section 1 | Section 2 | Section 3 | Section 4 | Section 5 | Section 6 | Section 7 ----|---|---|---|---|---|--- -d | rwx | rwx | rwx | . | root | root - -Section 1 (on the left) reveals what type of file it is. - -d | Directory ----|--- -- | Regular file -l | A soft link - -The [info page][2] for **ls** has a full listing of the different file types. - -Each file has three modes of access: - - * the owner - * the group - * all others - - - -Sections 2, 3, and 4 refer to the user, group, and "other users" permissions. And each section can include a combination of **r** (read), **w** (write), and **x** (executable) permissions. - -Each of the permissions is also assigned a numerical value, which is important when talking about the octal representation of permissions. - -Permission | Octal Value ----|--- -Read | 4 -Write | 2 -Execute | 1 - -Section 5 details any alternative access methods, such as SELinux or File Access Control List (FACL). - -Method | Character ----|--- -No other method | - -SELinux | . -FACLs | + -Any combination of methods | + - -Sections 6 and 7 are the names of the owner and the group, respectively. - -### Using chown and chmod - -#### The chown command - -The **chown** (change ownership) command is used to change a file's user and group ownership. - -To change both the user and group ownership of the file **foo** to **root**, we can use these commands: - - -``` -$ chown root:root foo -$ chown root: foo -``` - -Running the command with the user followed by a colon (**:**) sets both the user and group ownership. - -To set only the user ownership of the file **foo** to the **root** user, enter: - - -``` -`$ chown root foo` -``` - -To change only the group ownership of the file **foo**, precede the group with a colon: - - -``` -`$ chown :root foo` -``` - -#### The chmod command - -The **chmod** (change mode) command controls file permissions for the owner, group, and all other users who are neither the owner nor part of the group associated with the file. - -The **chmod** command can set permissions in both octal (e.g., 755, 644, etc.) and symbolic (e.g., u+rwx, g-rwx, o=rw) formatting. - -Octal notation assigns 4 "points" to **read**, 2 to **write**, and 1 to **execute**. If we want to assign the user **read** permissions, we assign 4 to the first slot, but if we want to add **write** permissions, we must add 2. If we want to add **execute**, then we add 1. We do this for each permission type: owner, group, and others. - -For example, if we want to assign **read**, **write**, and **execute** to the owner of the file, but only **read** and **execute** to group members and all other users, we would use 755 in octal formatting. That's all permission bits for the owner (4+2+1), but only a 4 and 1 for the group and others (4+1). - -> The breakdown for that is: 4+2+1=7; 4+1=5; and 4+1=5. - -If we wanted to assign **read** and **write** to the owner of the file but only **read** to members of the group and all other users, we could use **chmod** as follows: - - -``` -`$ chmod 644 foo_file` -``` - -In the examples below, we use symbolic notation in different groupings. Note the letters **u**, **g**, and **o** represent **user**, **group**, and **other**. We use **u**, **g**, and **o** in conjunction with **+**, **-**, or **=** to add, remove, or set permission bits. - -To add the **execute** bit to the ownership permission set: - - -``` -`$ chmod u+x foo_file` -``` - -To remove **read**, **write**, and **execute** from members of the group: - - -``` -`$ chmod g-rwx foo_file` -``` - -To set the ownership for all other users to **read** and **write**: - - -``` -`$ chmod o=rw` -``` - -### The special bits: Set UID, set GID, and sticky bits - -In addition to the standard permissions, there are a few special permission bits that have some useful benefits. - -#### Set user ID (suid) - -When **suid** is set on a file, an operation executes as the owner of the file, not the user running the file. A [good example][3] of this is the **passwd** command. It needs the **suid** bit to be set so that changing a password runs with root permissions. - - -``` -$ ls -l /bin/passwd --rwsr-xr-x. 1 root root 27832 Jun 10  2014 /bin/passwd -``` - -An example of setting the **suid** bit would be: - - -``` -`$ chmod u+s /bin/foo_file_name` -``` - -#### Set group ID (sgid) - -The **sgid** bit is similar to the **suid** bit in the sense that the operations are done under the group ownership of the directory instead of the user running the command. - -An example of using **sgid** would be if multiple users are working out of the same directory, and every file created in the directory needs to have the same group permissions. The example below creates a directory called **collab_dir**, sets the **sgid** bit, and changes the group ownership to **webdev**. - - -``` -$ mkdir collab_dir -$ chmod g+s collab_dir -$ chown :webdev collab_dir -``` - -Now any file created in the directory will have the group ownership of **webdev** instead of the user who created the file. - - -``` -$ cd collab_dir -$ touch file-sgid -$ ls -lah file-sgid --rw-r--r--. 1 root webdev 0 Jun 12 06:04 file-sgid -``` - -#### The "sticky" bit - -The sticky bit denotes that only the owner of a file can delete the file, even if group permissions would otherwise allow it. This setting usually makes the most sense on a common or collaborative directory such as **/tmp**. In the example below, the **t** in the **execute** column of the **all others** permission set indicates that the sticky bit has been applied. - - -``` -$ ls -ld /tmp -drwxrwxrwt. 8 root root 4096 Jun 12 06:07 /tmp/ -``` - -Keep in mind this does not prevent somebody from editing the file; it just keeps them from deleting the contents of a directory. - -We set the sticky bit with: - - -``` -`$ chmod o+t foo_dir` -``` - -On your own, try setting the sticky bit on a directory and give it full group permissions so that multiple users can read, write and execute on the directory because they are in the same group. - -From there, create files as each user and then try to delete them as the other. - -If everything is configured correctly, one user should not be able to delete users from the other user. - -Note that each of these bits can also be set in octal format with SUID=4, SGID=2, and Sticky=1. - - -``` -$ chmod 4744 -$ chmod 2644 -$ chmod 1755 -``` - -#### Uppercase or lowercase? - -If you are setting the special bits and see an uppercase **S** or **T** instead of lowercase (as we've seen until this point), it is because the underlying execute bit is not present. To demonstrate, the following example creates a file with the sticky bit set. We can then add/remove the execute bit to demonstrate the case change. - - -``` -$ touch file cap-ST-demo -$ chmod 1755 cap-ST-demo -$ ls -l cap-ST-demo --rwxr-xr-t. 1 root root 0 Jun 12 06:16 cap-ST-demo - -$ chmod o-x cap-X-demo -$ ls -l cap-X-demo --rwxr-xr-T. 1 root root 0 Jun 12 06:16 cap-ST-demo -``` - -#### Setting the execute bit conditionally - -To this point, we've set the **execute** bit using a lowercase **x**, which sets it without asking any questions. We have another option: using an uppercase **X** instead of lowercase will set the **execute** bit only if it is already present somewhere in the permission group. This can be a difficult concept to explain, but the demo below will help illustrate it. Notice here that after trying to add the **execute** bit to the group privileges, it is not applied. - - -``` -$ touch cap-X-file -$ ls -l cap-X-file --rw-r--r--. 1 root root 0 Jun 12 06:31 cap-X-file -$ chmod g+X cap-X-file -$ ls -l cap-X-file --rw-r--r--. 1 root root 0 Jun 12 06:31 cap-X-file -``` - -In this similar example, we add the execute bit first to the group permissions using the lowercase **x** and then use the uppercase **X** to add permissions for all other users. This time, the uppercase **X** sets the permissions. - - -``` -$ touch cap-X-file -$ ls -l cap-X-file --rw-r--r--. 1 root root 0 Jun 12 06:31 cap-X-file -$ chmod g+x cap-X-file -$ ls -l cap-X-file --rw-r-xr--. 1 root root 0 Jun 12 06:31 cap-X-file -$ chmod g+x cap-X-file -$ chmod o+X cap-X-file -ls -l cap-X-file --rw-r-xr-x. 1 root root 0 Jun 12 06:31 cap-X-file -``` - -### Understanding umask - -The **umask** masks (or "blocks off") bits from the default permission set in order to define permissions for a file or directory. For example, a 2 in the **umask** output indicates it is blocking the **write** bit from a file, at least by default. - -Using the **umask** command without any arguments allows us to see the current **umask** setting. There are four columns: the first is reserved for the special suid, sgid, or sticky bit, and the remaining three represent the owner, group, and other permissions. - - -``` -$ umask -0022 -``` - -To understand what this means, we can execute **umask** with a **-S** (as shown below) to get the result of masking the bits. For instance, because of the **2** value in the third column, the **write** bit is masked off from the group and other sections; only **read** and **execute** can be assigned for those. - - -``` -$ umask -S -u=rwx,g=rx,o=rx -``` - -To see what the default permission set is for files and directories, let's set our **umask** to all zeros. This means that we are not masking off any bits when we create a file. - - -``` -$ umask 000 -$ umask -S -u=rwx,g=rwx,o=rwx - -$ touch file-umask-000 -$ ls -l file-umask-000 --rw-rw-rw-. 1 root root 0 Jul 17 22:03 file-umask-000 -``` - -Now when we create a file, we see the default permissions are **read** (4) and **write** (2) for all sections, which would equate to 666 in octal representation. - -We can do the same for a directory and see its default permissions are 777. We need the **execute** bit on directories so we can traverse through them. - - -``` -$ mkdir dir-umask-000 -$ ls -ld dir-umask-000 -drwxrwxrwx. 2 root root 4096 Jul 17 22:03 dir-umask-000/ -``` - -### Conclusion - -There are many other ways an administrator can control access to files on a system. These permissions are basic to Linux, and we can build upon these fundamental aspects. If your work takes you into FACLs or SELinux, you will see that they also build upon these first rules of file access. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/8/linux-permissions-101 - -作者:[Alex Juarez][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/mralexjuarezhttps://opensource.com/users/marcobravohttps://opensource.com/users/greg-p -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux-penguins.png?itok=yKOpaJM_ (Penguins) -[2]: https://www.gnu.org/software/texinfo/manual/info-stnd/info-stnd.html -[3]: https://www.theurbanpenguin.com/using-a-simple-c-program-to-explain-the-suid-permission/ diff --git a/sources/tech/20190822 11 Essential Keyboard Shortcuts Google Chrome-Chromium Users Should Know.md b/sources/tech/20190822 11 Essential Keyboard Shortcuts Google Chrome-Chromium Users Should Know.md deleted file mode 100644 index 4e2693f079..0000000000 --- a/sources/tech/20190822 11 Essential Keyboard Shortcuts Google Chrome-Chromium Users Should Know.md +++ /dev/null @@ -1,141 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (11 Essential Keyboard Shortcuts Google Chrome/Chromium Users Should Know) -[#]: via: (https://itsfoss.com/google-chrome-shortcuts/) -[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) - -11 Essential Keyboard Shortcuts Google Chrome/Chromium Users Should Know -====== - -_**Brief: Master these Google Chrome keyboard shortcuts for a better, smoother and more productive web browsing experience. Downloadable cheatsheet is also included.**_ - -Google Chrome is the [most popular web browser][1] and there is no denying it. It’s open source version [Chromium][2] is also getting popularity and some Linux distributions now include it as the default web browser. - -If you use it on desktop a lot, you can improve your browsing experience by using Google Chrome keyboard shortcuts. No need to go up to your mouse and spend time finding your way around. Just master these shortcuts and you’ll even save some time and be more productive. - -I am using the term Google Chrome but these shortcuts are equally applicable to the Chromium browser. - -### 11 Cool Chrome Keyboard shortcuts you should be using - -If you are a pro, you might know a few of these Chrome shortcuts already but the chances are that you may still find some hidden gems here. Let’s see. - -**Keyboard Shortcuts** | **Action** ----|--- -Ctrl+T | Open a new tab -Ctrl+N | Open a new window -Ctrl+Shift+N | Open incognito window -Ctrl+W | Close current tab -Ctrl+Shift+T | Reopen last closed tab -Ctrl+Shift+W | Close the window -Ctrl+Tab and Ctrl+Shift+Tab | Switch to right or left tab -Ctrl+L | Go to search/address bar -Ctrl+D | Bookmark the website -Ctrl+H | Access browsing history -Ctrl+J | Access downloads history -Shift+Esc | Open Chrome task manager - -You can [download this list of useful Chrome keyboard shortcut for quick reference][3]. - -#### 1\. Open a new tab with Ctrl+T - -Need to open a new tab? Just press Ctrl and T keys together and you’ll have a new tab opened. - -#### 2\. Open a new window with Ctrl+N - -Too many tabs opened already? Time to open a fresh new window. Use Ctrl and N keys to open a new browser window. - -#### 3\. Go incognito with Ctrl+Shift+N - -Checking flight or hotel prices online? Going incognito might help. Open an incognito window in Chrome with Ctrl+Shift+N. - -[][4] - -Suggested read  Best Text Editors for Linux Command Line - -#### 4\. Close a tab with Ctrl+W - -Close the current tab with Ctrl and W key. No need to take the mouse to the top and look for the x button. - -#### 5\. Accidentally closed a tab? Reopen it with Ctrl+Shift+T - -This is my favorite Google Chrome shortcut. No more ‘oh crap’ when you close a tab you didn’t mean to. Use the Ctrl+Shift+T and it will open the last closed tab. Keep hitting this key combination and it will keep on bringing the closed tabs. - -#### 6\. Close the entire browser window with Ctrl+Shift+W - -Done with you work? Time to close the entire browser window with all the tabs. Use the keys Ctrl+Shift+W and the browser window will disappear like it never existed. - -#### 7\. Switch between tabs with Ctrl+Tab - -Too many tabs open? You can move to right tab with Ctrl+Tab. Want to move left? Use Ctrl+Shift+Tab. Press these keys repeatedly and you can move between all the open tabs in the current browser window. - -You can also use Ctrl+0 till Ctrl+9 to go to one of the first 10 tabs. But this Chrome keyboard shortcut doesn’t work for the 11th tabs onward. - -#### 8\. Go to the search/address bar with Ctrl+L - -Want to type a new URL or search something quickly. You can use Ctrl+L and it will highlight the address bar on the top. - -#### 9\. Bookmark the current website with Ctrl+D - -Found something interesting? Save it in your bookmarks with Ctrl+D keys combination. - -#### 10\. Go back in history with Ctrl+H - -You can open up your browser history with Ctrl+H keys. Search through the history if you are looking for a page visited some time ago or delete something that you don’t want to be seen anymore. - -#### 11\. See your downloads with Ctrl+J - -Pressing the Ctrl+J keys in Chrome will take you to the Downloads page. This page will show you all the downloads action you performed. - -[][5] - -Suggested read  Get Rid Of Two Google Chrome Icons From Dock In Elementary OS Freya [Quick Tip] - -#### Bonus shortcut: Open Chrome task manager with Shift+Esc - -Many people doesn’t even know that there is a task manager in Chrome browser. Chrome is infamous for eating up your system’s RAM. And when you have plenty of tabs opened, finding the culprit is not easy. - -With Chrome task manager, you can see all the open tabs and their system utilization stats. You can also see various hidden processes such as Chrome extensions and other services. - -![Google Chrome Task Manager][6] - -I am going to this table here for a quick reference. - -### Download Chrome shortcut cheatsheet - -I know that mastering keyboard shortcuts depends on habit and you can make it a habit by using it again and again. To help you in this task, I have created this Google Chrome keyboard shortcut cheatsheet. - -You can download the below image in PDF form, print it and put it on your desk. This way you can use practice the shortcuts all the time. - -![Google Chrome Keyboard Shortcuts Cheat Sheet][7] - -[Download Chrome Shortcut Cheatsheet][8] - -If you are interested in mastering shortcuts, you may also have a look at [Ubuntu keyboard shortcuts][9]. - -By the way, what’s your favorite Chrome shortcut? - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/google-chrome-shortcuts/ - -作者:[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://en.wikipedia.org/wiki/Usage_share_of_web_browsers -[2]: https://www.chromium.org/Home -[3]: tmp.3qZNXSy2FC#download-cheatsheet -[4]: https://itsfoss.com/command-line-text-editors-linux/ -[5]: https://itsfoss.com/rid-google-chrome-icons-dock-elementary-os-freya/ -[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/google-chrome-task-manager.png?resize=800%2C300&ssl=1 -[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/08/google-chrome-keyboard-shortcuts-cheat-sheet.png?ssl=1 -[8]: https://drive.google.com/open?id=1lZ4JgRuFbXrnEXoDQqOt7PQH6femIe3t -[9]: https://itsfoss.com/ubuntu-shortcuts/ diff --git a/sources/tech/20190826 How RPM packages are made- the source RPM.md b/sources/tech/20190826 How RPM packages are made- the source RPM.md deleted file mode 100644 index 4629db3580..0000000000 --- a/sources/tech/20190826 How RPM packages are made- the source RPM.md +++ /dev/null @@ -1,238 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How RPM packages are made: the source RPM) -[#]: via: (https://fedoramagazine.org/how-rpm-packages-are-made-the-source-rpm/) -[#]: author: (Ankur Sinha "FranciscoD" https://fedoramagazine.org/author/ankursinha/) - -How RPM packages are made: the source RPM -====== - -![][1] - -In a [previous post, we looked at what RPM packages are][2]. They are archives that contain files and metadata. This metadata tells RPM where to create or remove files from when an RPM is installed or uninstalled. The metadata also contains information on “dependencies”, which you will remember from the previous post, can either be “runtime” or “build time”. - -As an example, we will look at _fpaste_. You can download the RPM using _dnf_. This will download the latest version of _fpaste_ that is available in the Fedora repositories. On Fedora 30, this is currently 0.3.9.2: - -``` -$ dnf download fpaste - -... -fpaste-0.3.9.2-2.fc30.noarch.rpm -``` - -Since this is the built RPM, it contains only files needed to use _fpaste_: - -``` -$ rpm -qpl ./fpaste-0.3.9.2-2.fc30.noarch.rpm -/usr/bin/fpaste -/usr/share/doc/fpaste -/usr/share/doc/fpaste/README.rst -/usr/share/doc/fpaste/TODO -/usr/share/licenses/fpaste -/usr/share/licenses/fpaste/COPYING -/usr/share/man/man1/fpaste.1.gz -``` - -### Source RPMs - -The next link in the chain is the source RPM. All software in Fedora must be built from its source code. We do not include pre-built binaries. So, for an RPM file to be made, RPM (the tool) needs to be: - - * given the files that have to be installed, - * told how to generate these files, if they are to be compiled, for example, - * told where these files must be installed, - * what other dependencies this particular software needs to work properly. - - - -The source RPM holds all of this information. Source RPMs are similar archives to RPM, but as the name suggests, instead of holding the built binary files, they contain the source files for a piece of software. Let’s download the source RPM for _fpaste_: - -``` -$ dnf download fpaste --source -... -fpaste-0.3.9.2-2.fc30.src.rpm -``` - -Notice how the file ends with “src.rpm”. All RPMs are built from source RPMs. You can easily check what source RPM a “binary” RPM comes from using dnf too: - -``` -$ dnf repoquery --qf "%{SOURCERPM}" fpaste -fpaste-0.3.9.2-2.fc30.src.rpm -``` - -Also, since this is the source RPM, it does not contain built files. Instead, it contains the sources and instructions on how to build the RPM from them: - -``` -$ rpm -qpl ./fpaste-0.3.9.2-2.fc30.src.rpm -fpaste-0.3.9.2.tar.gz -fpaste.spec -``` - -Here, the first file is simply the source code for _fpaste_. The second is the “spec” file. The spec file is the recipe that tells RPM (the tool) how to create the RPM (the archive) using the sources contained in the source RPM—all the information that RPM (the tool) needs to build RPMs (the archives) are contained in spec files. When we package maintainers add software to Fedora, most of our time is spent writing and perfecting the individual spec files. When a software package needs an update, we go back and tweak the spec file. You can see the spec files for ALL packages in Fedora at our source repository at - -Note that one source RPM may contain the instructions to build multiple RPMs. _fpaste_ is a very simple piece of software, where one source RPM generates one “binary” RPM. Python, on the other hand is more complex. While there is only one source RPM, it generates multiple binary RPMs: - -``` -$ sudo dnf repoquery --qf "%{SOURCERPM}" python3 -python3-3.7.3-1.fc30.src.rpm -python3-3.7.4-1.fc30.src.rpm - -$ sudo dnf repoquery --qf "%{SOURCERPM}" python3-devel -python3-3.7.3-1.fc30.src.rpm -python3-3.7.4-1.fc30.src.rpm - -$ sudo dnf repoquery --qf "%{SOURCERPM}" python3-libs -python3-3.7.3-1.fc30.src.rpm -python3-3.7.4-1.fc30.src.rpm - -$ sudo dnf repoquery --qf "%{SOURCERPM}" python3-idle -python3-3.7.3-1.fc30.src.rpm -python3-3.7.4-1.fc30.src.rpm - -$ sudo dnf repoquery --qf "%{SOURCERPM}" python3-tkinter -python3-3.7.3-1.fc30.src.rpm -python3-3.7.4-1.fc30.src.rpm -``` - -In RPM jargon, “python3” is the “main package”, and so the spec file will be called “python3.spec”. All the other packages are “sub-packages”. You can download the source RPM for python3 and see what’s in it too. (Hint: patches are also part of the source code): - -``` -$ dnf download --source python3 -python3-3.7.4-1.fc30.src.rpm - -$ rpm -qpl ./python3-3.7.4-1.fc30.src.rpm -00001-rpath.patch -00102-lib64.patch -00111-no-static-lib.patch -00155-avoid-ctypes-thunks.patch -00170-gc-assertions.patch -00178-dont-duplicate-flags-in-sysconfig.patch -00189-use-rpm-wheels.patch -00205-make-libpl-respect-lib64.patch -00251-change-user-install-location.patch -00274-fix-arch-names.patch -00316-mark-bdist_wininst-unsupported.patch -Python-3.7.4.tar.xz -check-pyc-timestamps.py -idle3.appdata.xml -idle3.desktop -python3.spec -``` - -### Building an RPM from a source RPM - -Now that we have the source RPM, and know what’s in it, we can rebuild our RPM from it. Before we do so, though, we should set our system up to build RPMs. First, we install the required tools: - -``` -$ sudo dnf install fedora-packager -``` - -This will install the rpmbuild tool. rpmbuild requires a default layout so that it knows where each required component of the source rpm is. Let’s see what they are: - -``` -# Where should the spec file go? -$ rpm -E %{_specdir} -/home/asinha/rpmbuild/SPECS - -# Where should the sources go? -$ rpm -E %{_sourcedir} -/home/asinha/rpmbuild/SOURCES - -# Where is temporary build directory? -$ rpm -E %{_builddir} -/home/asinha/rpmbuild/BUILD - -# Where is the buildroot? -$ rpm -E %{_buildrootdir} -/home/asinha/rpmbuild/BUILDROOT - -# Where will the source rpms be? -$ rpm -E %{_srcrpmdir} -/home/asinha/rpmbuild/SRPMS - -# Where will the built rpms be? -$ rpm -E %{_rpmdir} -/home/asinha/rpmbuild/RPMS -``` - -I have all of this set up on my system already: - -``` -$ cd -$ tree -L 1 rpmbuild/ -rpmbuild/ -├── BUILD -├── BUILDROOT -├── RPMS -├── SOURCES -├── SPECS -└── SRPMS - -6 directories, 0 files -``` - -RPM provides a tool that sets it all up for you too: - -``` -$ rpmdev-setuptree -``` - -Then we ensure that we have all the build dependencies for _fpaste_ installed: - -``` -sudo dnf builddep fpaste-0.3.9.2-3.fc30.src.rpm -``` - -For _fpaste_ you only need Python and that must already be installed on your system (dnf uses Python too). The builddep command can also be given a spec file instead of an source RPM. Read more in the man page: - -``` -$ man dnf.plugin.builddep -``` - -Now that we have all that we need, building an RPM from a source RPM is as simple as: - -``` -$ rpmbuild --rebuild fpaste-0.3.9.2-3.fc30.src.rpm -.. -.. - -$ tree ~/rpmbuild/RPMS/noarch/ -/home/asinha/rpmbuild/RPMS/noarch/ -└── fpaste-0.3.9.2-3.fc30.noarch.rpm - -0 directories, 1 file -``` - -rpmbuild will install the source RPM and build your RPM from it. You can now install the RPM to use it as you do–using dnf. Of course, as said before, if you want to change anything in the RPM, you must modify the spec file—we’ll cover spec files in next post. - -### Summary - -To summarise this post in two short points: - - * the RPMs we generally install to use software are “binary” RPMs that contain built versions of the software - * these are built from source RPMs that include the source code and the spec file that are needed to generate the binary RPMs. - - - -If you’d like to get started with building RPMs, and help the Fedora community maintain the massive amount of software we provide, you can start here: - -For any queries, post to the [Fedora developers mailing list][3]—we’re always happy to help! - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/how-rpm-packages-are-made-the-source-rpm/ - -作者:[Ankur Sinha "FranciscoD"][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/ankursinha/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2019/06/rpm.png-816x345.jpg -[2]: https://fedoramagazine.org/rpm-packages-explained/ -[3]: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/ diff --git a/sources/tech/20190902 How RPM packages are made- the spec file.md b/sources/tech/20190902 How RPM packages are made- the spec file.md deleted file mode 100644 index c5dace0332..0000000000 --- a/sources/tech/20190902 How RPM packages are made- the spec file.md +++ /dev/null @@ -1,299 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How RPM packages are made: the spec file) -[#]: via: (https://fedoramagazine.org/how-rpm-packages-are-made-the-spec-file/) -[#]: author: (Ankur Sinha "FranciscoD" https://fedoramagazine.org/author/ankursinha/) - -How RPM packages are made: the spec file -====== - -![][1] - -In the [previous article on RPM package building][2], you saw that source RPMS include the source code of the software, along with a “spec” file. This post digs into the spec file, which contains instructions on how to build the RPM. Again, this article uses _fpaste_ as an example. - -### Understanding the source code - -Before you can start writing a spec file, you need to have some idea of the software that you’re looking to package. Here, you’re looking at fpaste, a very simple piece of software. It is written in Python, and is a one file script. When a new version is released, it’s provided here on Pagure: - -The current version, as the archive shows, is 0.3.9.2. Download it so you can see what’s in the archive: - -``` -$ wget https://pagure.io/releases/fpaste/fpaste-0.3.9.2.tar.gz -$ tar -tvf fpaste-0.3.9.2.tar.gz -drwxrwxr-x root/root 0 2018-07-25 02:58 fpaste-0.3.9.2/ --rw-rw-r-- root/root 25 2018-07-25 02:58 fpaste-0.3.9.2/.gitignore --rw-rw-r-- root/root 3672 2018-07-25 02:58 fpaste-0.3.9.2/CHANGELOG --rw-rw-r-- root/root 35147 2018-07-25 02:58 fpaste-0.3.9.2/COPYING --rw-rw-r-- root/root 444 2018-07-25 02:58 fpaste-0.3.9.2/Makefile --rw-rw-r-- root/root 1656 2018-07-25 02:58 fpaste-0.3.9.2/README.rst --rw-rw-r-- root/root 658 2018-07-25 02:58 fpaste-0.3.9.2/TODO -drwxrwxr-x root/root 0 2018-07-25 02:58 fpaste-0.3.9.2/docs/ -drwxrwxr-x root/root 0 2018-07-25 02:58 fpaste-0.3.9.2/docs/man/ -drwxrwxr-x root/root 0 2018-07-25 02:58 fpaste-0.3.9.2/docs/man/en/ --rw-rw-r-- root/root 3867 2018-07-25 02:58 fpaste-0.3.9.2/docs/man/en/fpaste.1 --rwxrwxr-x root/root 24884 2018-07-25 02:58 fpaste-0.3.9.2/fpaste -lrwxrwxrwx root/root 0 2018-07-25 02:58 fpaste-0.3.9.2/fpaste.py -> fpaste -``` - -The files you want to install are: - - * _fpaste.py_: which should go be installed to /usr/bin/. - * _docs/man/en/fpaste.1_: the manual, which should go to /usr/share/man/man1/. - * _COPYING_: the license text, which should go to /usr/share/license/fpaste/. - * _README.rst, TODO_: miscellaneous documentation that goes to /usr/share/doc/fpaste. - - - -Where these files are installed depends on the Filesystem Hierarchy Standard. To learn more about it, you can either read here: or look at the man page on your Fedora system: - -``` -$ man hier -``` - -#### Part 1: What are we building? - -Now that we know what files we have in the source, and where they are to go, let’s look at the spec file. You can see the full file here: - -Here is the first part of the spec file: - -``` -Name: fpaste -Version: 0.3.9.2 -Release: 3%{?dist} -Summary: A simple tool for pasting info onto sticky notes instances -BuildArch: noarch -License: GPLv3+ -URL: https://pagure.io/fpaste -Source0: https://pagure.io/releases/fpaste/fpaste-0.3.9.2.tar.gz - -Requires: python3 - -%description -It is often useful to be able to easily paste text to the Fedora -Pastebin at http://paste.fedoraproject.org and this simple script -will do that and return the resulting URL so that people may -examine the output. This can hopefully help folks who are for -some reason stuck without X, working remotely, or any other -reason they may be unable to paste something into the pastebin -``` - -_Name_, _Version_, and so on are called _tags_, and are defined in RPM. This means you can’t just make up tags. RPM won’t understand them if you do! The tags to keep an eye out for are: - - * _Source0_: tells RPM where the source archive for this software is located. - * _Requires_: lists run-time dependencies for the software. RPM can automatically detect quite a few of these, but in some cases they must be mentioned manually. A run-time dependency is a capability (often a package) that must be on the system for this package to function. This is how _[dnf][3]_ detects whether it needs to pull in other packages when you install this package. - * _BuildRequires_: lists the build-time dependencies for this software. These must generally be determined manually and added to the spec file. - * _BuildArch_: the computer architectures that this software is being built for. If this tag is left out, the software will be built for all supported architectures. The value _noarch_ means the software is architecture independent (like fpaste, which is written purely in Python). - - - -This section provides general information about fpaste: what it is, which version is being made into an RPM, its license, and so on. If you have fpaste installed, and look at its metadata, you can see this information included in the RPM: - -``` -$ sudo dnf install fpaste -$ rpm -qi fpaste -Name : fpaste -Version : 0.3.9.2 -Release : 2.fc30 -... -``` - -RPM adds a few extra tags automatically that represent things that it knows. - -At this point, we have the general information about the software that we’re building an RPM for. Next, we start telling RPM what to do. - -#### Part 2: Preparing for the build - -The next part of the spec is the preparation section, denoted by _%prep_: - -``` -%prep -%autosetup -``` - -For fpaste, the only command here is %autosetup. This simply extracts the tar archive into a new folder and keeps it ready for the next section where we build it. You can do more here, like apply patches, modify files for different purposes, and so on. If you did look at the contents of the source rpm for Python, you would have seen lots of patches there. These are all applied in this section. - -Typically anything in a spec file with the **%** prefix is a macro or label that RPM interprets in a special way. Often these will appear with curly braces, such as _%{example}_. - -#### Part 3: Building the software - -The next section is where the software is built, denoted by “%build”. Now, since fpaste is a simple, pure Python script, it doesn’t need to be built. So, here we get: - -``` -%build -#nothing required -``` - -Generally, though, you’d have build commands here, like: - -``` -configure; make -``` - -The build section is often the hardest section of the spec, because this is where the software is being built from source. This requires you to know what build system the tool is using, which could be one of many: Autotools, CMake, Meson, Setuptools (for Python) and so on. Each has its own commands and style. You need to know these well enough to get the software to build correctly. - -#### Part 4: Installing the files - -Once the software is built, it needs to be installed in the _%install_ section: - -``` -%install -mkdir -p %{buildroot}%{_bindir} -make install BINDIR=%{buildroot}%{_bindir} MANDIR=%{buildroot}%{_mandir} -``` - -RPM doesn’t tinker with your system files when building RPMs. It’s far too risky to add, remove, or modify files to a working installation. What if something breaks? So, instead RPM creates an artificial file system and works there. This is referred to as the _buildroot_. So, here in the buildroot, we create _/usr/bin_, represented by the macro _%{_bindir}_, and then install the files to it using the provided Makefile. - -At this point, we have a built version of fpaste installed in our artificial buildroot. - -#### Part 5: Listing all files to be included in the RPM - -The last section of the spec file is the files section, _%files_. This is where we tell RPM what files to include in the archive it creates from this spec file. The fpaste file section is quite simple: - -``` -%files -%{_bindir}/%{name} -%doc README.rst TODO -%{_mandir}/man1/%{name}.1.gz -%license COPYING -``` - -Notice how, here, we do not specify the buildroot. All of these paths are relative to it. The _%doc_ and _%license_ commands simply do a little more—they create the required folders and remember that these files must go there. - -RPM is quite smart. If you’ve installed files in the _%install_ section, but not listed them, it’ll tell you this, for example. - -#### Part 6: Document all changes in the change log - -Fedora is a community based project. Lots of contributors maintain and co-maintain packages. So it is imperative that there’s no confusion about what changes have been made to a package. To ensure this, the spec file contains the last section, the Changelog, _%changelog_: - -``` -%changelog -* Thu Jul 25 2019 Fedora Release Engineering < ...> - 0.3.9.2-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild - -* Thu Jan 31 2019 Fedora Release Engineering < ...> - 0.3.9.2-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild - -* Tue Jul 24 2018 Ankur Sinha - 0.3.9.2-1 -- Update to 0.3.9.2 - -* Fri Jul 13 2018 Fedora Release Engineering < ...> - 0.3.9.1-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild - -* Wed Feb 07 2018 Fedora Release Engineering < ..> - 0.3.9.1-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild - -* Sun Sep 10 2017 Vasiliy N. Glazov < ...> - 0.3.9.1-2 -- Cleanup spec - -* Fri Sep 08 2017 Ankur Sinha - 0.3.9.1-1 -- Update to latest release -- fixes rhbz 1489605 -... -.... -``` - -There must be a changelog entry for _every_ change to the spec file. As you see here, while I’ve updated the spec as the maintainer, others have too. Having the changes documented clearly helps everyone know what the current status of the spec is. For all packages installed on your system, you can use rpm to see their changelogs: - -``` -$ rpm -q --changelog fpaste -``` - -### Building the RPM - -Now we are ready to build the RPM. If you want to follow along and run the commands below, please ensure that you followed the steps [in the previous post][2] to set your system up for building RPMs. - -We place the fpaste spec file in _~/rpmbuild/SPECS_, the source code archive in _~/rpmbuild/SOURCES/_ and can now create the source RPM: - -``` -$ cd ~/rpmbuild/SPECS -$ wget https://src.fedoraproject.org/rpms/fpaste/raw/master/f/fpaste.spec - -$ cd ~/rpmbuild/SOURCES -$ wget https://pagure.io/fpaste/archive/0.3.9.2/fpaste-0.3.9.2.tar.gz - -$ cd ~/rpmbuild/SOURCES -$ rpmbuild -bs fpaste.spec -Wrote: /home/asinha/rpmbuild/SRPMS/fpaste-0.3.9.2-3.fc30.src.rpm -``` - -Let’s have a look at the results: - -``` -$ ls ~/rpmbuild/SRPMS/fpaste* -/home/asinha/rpmbuild/SRPMS/fpaste-0.3.9.2-3.fc30.src.rpm - -$ rpm -qpl ~/rpmbuild/SRPMS/fpaste-0.3.9.2-3.fc30.src.rpm -fpaste-0.3.9.2.tar.gz -fpaste.spec -``` - -There we are — the source rpm has been built. Let’s build both the source and binary rpm together: - -``` -$ cd ~/rpmbuild/SPECS -$ rpmbuild -ba fpaste.spec -.. -.. -.. -``` - -RPM will show you the complete build output, with details on what it is doing in each section that we saw before. This “build log” is extremely important. When builds do not go as expected, we packagers spend lots of time going through them, tracing the complete build path to see what went wrong. - -That’s it really! Your ready-to-install RPMs are where they should be: - -``` -$ ls ~/rpmbuild/RPMS/noarch/ -fpaste-0.3.9.2-3.fc30.noarch.rpm -``` - -### Recap - -We’ve covered the basics of how RPMs are built from a spec file. This is by no means an exhaustive document. In fact, it isn’t documentation at all, really. It only tries to explain how things work under the hood. Here’s a short recap: - - * RPMs are of two types: _source_ and _binary_. - * Binary RPMs contain the files to be installed to use the software. - * Source RPMs contain the information needed to build the binary RPMs: the complete source code, and the instructions on how to build the RPM in the spec file. - * The spec file has various sections, each with its own purpose. - - - -Here, we’ve built RPMs locally, on our Fedora installations. While this is the basic process, the RPMs we get from repositories are built on dedicated servers with strict configurations and methods to ensure correctness and security. This Fedora packaging pipeline will be discussed in a future post. - -Would you like to get started with building packages, and help the Fedora community maintain the massive amount of software we provide? You can [start here by joining the package collection maintainers][4]. - -For any queries, post to the [Fedora developers mailing list][5]—we’re always happy to help! - -### References - -Here are some useful references to building RPMs: - - * - * - * - * - - - -* * * - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/how-rpm-packages-are-made-the-spec-file/ - -作者:[Ankur Sinha "FranciscoD"][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/ankursinha/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2019/06/rpm.png-816x345.jpg -[2]: https://fedoramagazine.org/how-rpm-packages-are-made-the-source-rpm/ -[3]: https://fedoramagazine.org/managing-packages-fedora-dnf/ -[4]: https://fedoraproject.org/wiki/Join_the_package_collection_maintainers -[5]: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/ diff --git a/sources/tech/20190905 Building CI-CD pipelines with Jenkins.md b/sources/tech/20190905 Building CI-CD pipelines with Jenkins.md deleted file mode 100644 index 44b4d6cd24..0000000000 --- a/sources/tech/20190905 Building CI-CD pipelines with Jenkins.md +++ /dev/null @@ -1,255 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Building CI/CD pipelines with Jenkins) -[#]: via: (https://opensource.com/article/19/9/intro-building-cicd-pipelines-jenkins) -[#]: author: (Bryant Son https://opensource.com/users/brson) - -Building CI/CD pipelines with Jenkins -====== -Build continuous integration and continuous delivery (CI/CD) pipelines -with this step-by-step Jenkins tutorial. -![pipelines][1] - -In my article [_A beginner's guide to building DevOps pipelines with open source tools_][2], I shared a story about building a DevOps pipeline from scratch. The core technology driving that initiative was [Jenkins][3], an open source tool to build continuous integration and continuous delivery (CI/CD) pipelines. - -At Citi, there was a separate team that provided dedicated Jenkins pipelines with a stable master-slave node setup, but the environment was only used for quality assurance (QA), staging, and production environments. The development environment was still very manual, and our team needed to automate it to gain as much flexibility as possible while accelerating the development effort. This is the reason we decided to build a CI/CD pipeline for DevOps. And the open source version of Jenkins was the obvious choice due to its flexibility, openness, powerful plugin-capabilities, and ease of use. - -In this article, I will share a step-by-step walkthrough on how you can build a CI/CD pipeline using Jenkins. - -### What is a pipeline? - -Before jumping into the tutorial, it's helpful to know something about CI/CD pipelines. - -To start, it is helpful to know that Jenkins itself is not a pipeline. Just creating a new Jenkins job does not construct a pipeline. Think about Jenkins like a remote control—it's the place you click a button. What happens when you do click a button depends on what the remote is built to control. Jenkins offers a way for other application APIs, software libraries, build tools, etc. to plug into Jenkins, and it executes and automates the tasks. On its own, Jenkins does not perform any functionality but gets more and more powerful as other tools are plugged into it. - -A pipeline is a separate concept that refers to the groups of events or jobs that are connected together in a sequence: - -> A **pipeline** is a sequence of events or jobs that can be executed. - -The easiest way to understand a pipeline is to visualize a sequence of stages, like this: - -![Pipeline example][4] - -Here, you should see two familiar concepts: _Stage_ and _Step_. - - * **Stage:** A block that contains a series of steps. A stage block can be named anything; it is used to visualize the pipeline process. - * **Step:** A task that says what to do. Steps are defined inside a stage block. - - - -In the example diagram above, Stage 1 can be named "Build," "Gather Information," or whatever, and a similar idea is applied for the other stage blocks. "Step" simply says what to execute, and this can be a simple print command (e.g., **echo "Hello, World"**), a program-execution command (e.g., **java HelloWorld**), a shell-execution command (e.g., **chmod 755 Hello**), or any other command—as long as it is recognized as an executable command through the Jenkins environment. - -The Jenkins pipeline is provided as a _codified script_ typically called a **Jenkinsfile**, although the file name can be different. Here is an example of a simple Jenkins pipeline file. - - -``` -// Example of Jenkins pipeline script - -pipeline { -  stages { -    stage("Build") { -       steps { -          // Just print a Hello, Pipeline to the console -          echo "Hello, Pipeline!" -          // Compile a Java file. This requires JDKconfiguration from Jenkins -          javac HelloWorld.java -          // Execute the compiled Java binary called HelloWorld. This requires JDK configuration from Jenkins -          java HelloWorld -          // Executes the Apache Maven commands, clean then package. This requires Apache Maven configuration from Jenkins -          mvn clean package ./HelloPackage -          // List the files in current directory path by executing a default shell command -          sh "ls -ltr" -       } -   } -   // And next stages if you want to define further... - } // End of stages -} // End of pipeline -``` - -It's easy to see the structure of a Jenkins pipeline from this sample script. Note that some commands, like **java**, **javac**, and **mvn**, are not available by default, and they need to be installed and configured through Jenkins. Therefore: - -> A **Jenkins pipeline** is the way to execute a Jenkins job sequentially in a defined way by codifying it and structuring it inside multiple blocks that can include multiple steps containing tasks. - -OK. Now that you understand what a Jenkins pipeline is, I'll show you how to create and execute a Jenkins pipeline. At the end of the tutorial, you will have built a Jenkins pipeline like this: - -![Final Result][5] - -### How to build a Jenkins pipeline - -To make this tutorial easier to follow, I created a sample [GitHub repository][6] and a video tutorial. - -Before starting this tutorial, you'll need: - - * **Java Development Kit:** If you don't already have it, install a JDK and add it to the environment path so a Java command (like **java jar**) can be executed through a terminal. This is necessary to leverage the Java Web Archive (WAR) version of Jenkins that is used in this tutorial (although you can use any other distribution). - * **Basic computer operations:** You should know how to type some code, execute basic Linux commands through the shell, and open a browser. - - - -Let's get started. - -#### Step 1: Download Jenkins - -Navigate to the [Jenkins download page][7]. Scroll down to **Generic Java package (.war)** and click on it to download the file; save it someplace where you can locate it easily. (If you choose another Jenkins distribution, the rest of tutorial steps should be pretty much the same, except for Step 2.) The reason to use the WAR file is that it is a one-time executable file that is easily executable and removable. - -![Download Jenkins as Java WAR file][8] - -#### Step 2: Execute Jenkins as a Java binary - -Open a terminal window and enter the directory where you downloaded Jenkins with **cd <your path>**. (Before you proceed, make sure JDK is installed and added to the environment path.) Execute the following command, which will run the WAR file as an executable binary: - - -``` -`java -jar ./jenkins.war` -``` - -If everything goes smoothly, Jenkins should be up and running at the default port 8080. - -![Execute as an executable JAR binary][9] - -#### Step 3: Create a new Jenkins job - -Open a web browser and navigate to **localhost:8080**. Unless you have a previous Jenkins installation, it should go straight to the Jenkins dashboard. Click **Create New Jobs**. You can also click **New Item** on the left. - -![Create New Job][10] - -#### Step 4: Create a pipeline job - -In this step, you can select and define what type of Jenkins job you want to create. Select **Pipeline** and give it a name (e.g., TestPipeline). Click **OK** to create a pipeline job. - -![Create New Pipeline Job][11] - -You will see a Jenkins job configuration page. Scroll down to find** Pipeline section**. There are two ways to execute a Jenkins pipeline. One way is by _directly writing a pipeline script_ on Jenkins, and the other way is by retrieving the _Jenkins file from SCM_ (source control management). We will go through both ways in the next two steps. - -#### Step 5: Configure and execute a pipeline job through a direct script - -To execute the pipeline with a direct script, begin by copying the contents of the [sample Jenkinsfile][6] from GitHub. Choose **Pipeline script** as the **Destination** and paste the **Jenkinsfile** contents in **Script**. Spend a little time studying how the Jenkins file is structured. Notice that there are three Stages: Build, Test, and Deploy, which are arbitrary and can be anything. Inside each Stage, there are Steps; in this example, they just print some random messages. - -Click **Save** to keep the changes, and it should automatically take you back to the Job Overview. - -![Configure to Run as Jenkins Script][12] - -To start the process to build the pipeline, click **Build Now**. If everything works, you will see your first pipeline (like the one below). - -![Click Build Now and See Result][13] - -To see the output from the pipeline script build, click any of the Stages and click **Log**. You will see a message like this. - -![Visit sample GitHub with Jenkins get clone link][14] - -#### Step 6: Configure and execute a pipeline job with SCM - -Now, switch gears: In this step, you will Deploy the same Jenkins job by copying the **Jenkinsfile** from a source-controlled GitHub. In the same [GitHub repository][6], pick up the repository URL by clicking **Clone or download** and copying its URL. - -![Checkout from GitHub][15] - -Click **Configure** to modify the existing job. Scroll to the **Advanced Project Options** setting, but this time, select the **Pipeline script from SCM** option in the **Destination** dropdown. Paste the GitHub repo's URL in the **Repository URL**, and type **Jenkinsfile** in the **Script Path**. Save by clicking the **Save** button. - -![Change to Pipeline script from SCM][16] - -To build the pipeline, once you are back to the Task Overview page, click **Build Now** to execute the job again. The result will be the same as before, except you have one additional stage called **Declaration: Checkout SCM**. - -![Build again and verify][17] - -To see the pipeline's output from the SCM build, click the Stage and view the **Log** to check how the source control cloning process went. - -![Verify Checkout Procedure][18] - -### Do more than print messages - -Congratulations! You've built your first Jenkins pipeline! - -"But wait," you say, "this is very limited. I cannot really do anything with it except print dummy messages." That is OK. So far, this tutorial provided just a glimpse of what a Jenkins pipeline can do, but you can extend its capabilities by integrating it with other tools. Here are a few ideas for your next project: - - * Build a multi-staged Java build pipeline that takes from the phases of pulling dependencies from JAR repositories like Nexus or Artifactory, compiling Java codes, running the unit tests, packaging into a JAR/WAR file, and deploying to a cloud server. - * Implement the advanced code testing dashboard that will report back the health of the project based on the unit test, load test, and automated user interface test with Selenium.  - * Construct a multi-pipeline or multi-user pipeline automating the tasks of executing Ansible playbooks while allowing for authorized users to respond to task in progress. - * Design a complete end-to-end DevOps pipeline that pulls the infrastructure resource files and configuration files stored in SCM like GitHub and executing the scripts through various runtime programs. - - - -Follow any of the tutorials at the end of this article to get into these more advanced cases. - -#### Manage Jenkins - -From the main Jenkins dashboard, click **Manage Jenkins**. - -![Manage Jenkins][19] - -#### Global tool configuration - -There are many options available, including managing plugins, viewing the system log, etc. Click **Global Tool Configuration**. - -![Global Tools Configuration][20] - -#### Add additional capabilities - -Here, you can add the JDK path, Git, Gradle, and so much more. After you configure a tool, it is just a matter of adding the command into your Jenkinsfile or executing it through your Jenkins script. - -![See Various Options for Plugin][21] - -### Where to go from here? - -This article put you on your way to creating a CI/CD pipeline using Jenkins, a cool open source tool. To find out about many of the other things you can do with Jenkins, check out these other articles on Opensource.com: - - * [Getting started with Jenkins X][22] - * [Install an OpenStack cloud with Jenkins][23] - * [Running Jenkins builds in containers][24] - * [Getting started with Jenkins pipelines][25] - * [How to run JMeter with Jenkins][26] - * [Integrating OpenStack into your Jenkins workflow][27] - - - -You may be interested in some of the other articles I've written to supplement your open source journey: - - * [9 open source tools for building a fault-tolerant system][28] - * [Understanding software design patterns][29] - * [A beginner's guide to building DevOps pipelines with open source tools][2] - - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/9/intro-building-cicd-pipelines-jenkins - -作者:[Bryant Son][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/brson -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/pipe-pipeline-grid.png?itok=kkpzKxKg (pipelines) -[2]: https://opensource.com/article/19/4/devops-pipeline -[3]: https://jenkins.io/ -[4]: https://opensource.com/sites/default/files/uploads/diagrampipeline.jpg (Pipeline example) -[5]: https://opensource.com/sites/default/files/uploads/0_endresultpreview_0.jpg (Final Result) -[6]: https://github.com/bryantson/CICDPractice -[7]: https://jenkins.io/download/ -[8]: https://opensource.com/sites/default/files/uploads/2_downloadwar.jpg (Download Jenkins as Java WAR file) -[9]: https://opensource.com/sites/default/files/uploads/3_runasjar.jpg (Execute as an executable JAR binary) -[10]: https://opensource.com/sites/default/files/uploads/4_createnewjob.jpg (Create New Job) -[11]: https://opensource.com/sites/default/files/uploads/5_createpipeline.jpg (Create New Pipeline Job) -[12]: https://opensource.com/sites/default/files/uploads/6_runaspipelinescript.jpg (Configure to Run as Jenkins Script) -[13]: https://opensource.com/sites/default/files/uploads/7_buildnow4script.jpg (Click Build Now and See Result) -[14]: https://opensource.com/sites/default/files/uploads/8_seeresult4script.jpg (Visit sample GitHub with Jenkins get clone link) -[15]: https://opensource.com/sites/default/files/uploads/9_checkoutfromgithub.jpg (Checkout from GitHub) -[16]: https://opensource.com/sites/default/files/uploads/10_runsasgit.jpg (Change to Pipeline script from SCM) -[17]: https://opensource.com/sites/default/files/uploads/11_seeresultfromgit.jpg (Build again and verify) -[18]: https://opensource.com/sites/default/files/uploads/12_verifycheckout.jpg (Verify Checkout Procedure) -[19]: https://opensource.com/sites/default/files/uploads/13_managingjenkins.jpg (Manage Jenkins) -[20]: https://opensource.com/sites/default/files/uploads/14_globaltoolsconfiguration.jpg (Global Tools Configuration) -[21]: https://opensource.com/sites/default/files/uploads/15_variousoptions4plugin.jpg (See Various Options for Plugin) -[22]: https://opensource.com/article/18/11/getting-started-jenkins-x -[23]: https://opensource.com/article/18/4/install-OpenStack-cloud-Jenkins -[24]: https://opensource.com/article/18/4/running-jenkins-builds-containers -[25]: https://opensource.com/article/18/4/jenkins-pipelines-with-cucumber -[26]: https://opensource.com/life/16/7/running-jmeter-jenkins-continuous-delivery-101 -[27]: https://opensource.com/business/15/5/interview-maish-saidel-keesing-cisco -[28]: https://opensource.com/article/19/3/tools-fault-tolerant-system -[29]: https://opensource.com/article/19/7/understanding-software-design-patterns diff --git a/sources/tech/20190906 6 Open Source Paint Applications for Linux Users.md b/sources/tech/20190906 6 Open Source Paint Applications for Linux Users.md deleted file mode 100644 index d1523f33c3..0000000000 --- a/sources/tech/20190906 6 Open Source Paint Applications for Linux Users.md +++ /dev/null @@ -1,234 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (6 Open Source Paint Applications for Linux Users) -[#]: via: (https://itsfoss.com/open-source-paint-apps/) -[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) - -6 Open Source Paint Applications for Linux Users -====== - -As a child, when I started using computer (with Windows XP), my favorite application was Paint. I spent hours doodling on it. Surprisingly, children still love the paint apps. And not just children, the simple paint app comes handy in a number of situations. - -You will find a bunch of applications that let you draw/paint or manipulate images. However, some of them are proprietary. While you’re a Linux user – why not focus on open source paint applications? - -In this article, we are going to list some of the best open source paint applications which are worthy alternatives to proprietary painting software available on Linux. - -### Open Source paint & drawing applications - -![][1] - -**Note:** _The list is in no particular order of ranking._ - -#### 1\. Pinta - -![][2] - -Key Highlights: - - * Great alternative to Paint.NET / MS Paint - * Add-on support (WebP Image support available) - * Layer Support - - - -[Pinta][3] is an impressive open-source paint application which is perfect for drawing and basic image editing. In other words, it is a simple paint application with some fancy features. - -You may consider [Pinta][4] as an alternative to MS Paint on Linux – but with layer support and more. Not just MS Paint, but it acts as a Linux replacement for Paint.NET software available for Windows. Even though Paint.NET is better – Pinta seems to be a decent alternative to it. - -A couple of add-ons can be utilized to enhance the functionality, like the [support for WebP images on Linux][5]. In addition to the layer support, you can easily resize the images, add effects, make adjustments (brightness, contrast, etc.), and also adjust the quality when exporting the image. - -#### How to install Pinta? - -You should be able to easily find it in the Software Center / App Center / Package Manager. Just type in “**Pinta**” and get started installing it. In either case, try the [Flatpak][6] package. - -Or, you can enter the following command in the terminal (Ubuntu/Debian): - -``` -sudo apt install pinta -``` - -For more information on the download packages and installation instructions, refer the [official download page][7]. - -#### 2\. Krita - -![][8] - -Key Highlights: - - * HDR Painting - * PSD Support - * Layer Support - * Brush stabilizers - * 2D Animation - - - -Krita is one of the most advanced open source paint applications for Linux. Of course, for this article, it helps you draw sketches and wreak havoc upon the canvas. But, in addition to that, it offers a whole lot of features. - -[][9] - -Suggested read  Things To Do After Installing Fedora 24 - -For instance, if you have a shaky hand, it can help you stabilize the brush strokes. You also get built-in vector tools to create comic panels and other interesting things. If you are looking for a full-fledged color management support, drawing assistants, and layer management, Krita should be your preferred choice. - -#### How to install Krita? - -Similar to pinta, you should be able to find it listed in the Software Center/App Center or the package manager. It’s also available in the [Flatpak repository][10]. - -Thinking to install it via terminal? Type in the following command: - -``` -sudo apt install krita -``` - -In either case, you can head down to their [official download page][11] to get the **AppImage** file and run it. - -If you have no idea on AppImage files, check out our guide on – [how to use AppImage][12]. - -#### 3\. Tux Paint - -![][13] - -Key Highlights: - - * A no-nonsense paint application for kids - - - -I’m not kidding, Tux Paint is one of the best open-source paint applications for kids between 3-12 years of age. Of course, you do not want options when you want to just scribble. So, Tux Paint seems to be the best option in that case (even for adults!). - -#### How to install Tuxpaint? - -Tuxpaint can be downloaded from the Software Center or Package manager. In either case, to install it on Ubuntu/Debian, type in the following command in the terminal: - -``` -sudo apt install tuxpaint -``` - -For more information on it, head to the [official site][14]. - -#### 4\. Drawpile - -![][15] - -Key Highlights: - - * Collaborative Drawing - * Built-in chat to interact with other users - * Layer support - * Record drawing sessions - - - -Drawpile is an interesting open-source paint application where you get to collaborate with other users in real-time. To be precise, you can simultaneously draw in a single canvas. In addition to this unique feature, you have the layer support, ability to record your drawing session, and even a chat facility to interact with the users collaborating. - -You can host/join a public session or start a private session with your friend which requires a code. By default, the server will be your computer. But, if you want a remote server, you can select it as well. - -Do note, that you will need to [sign up for a Drawpile account][16] in order to collaborate. - -#### How to install Drawpile? - -As far as I’m aware of, you can only find it listed in the [Flatpak repository][17]. - -[][18] - -Suggested read  OCS Store: One Stop Shop All of Your Linux Software Customization Needs - -#### 5\. MyPaint - -![][19] - -Key Highlights: - - * Easy-to-use tool for digital painters - * Layer management support - * Lots of options to tweak your brush and drawing - - - -[MyPaint][20] is a simple yet powerful tool for digital painters. It features a lot of options to tweak in order to make the perfect digital brush stroke. I’m not much of a digital artist (but a scribbler) but I observed quite a few options to adjust the brush, the colors, and an option to add a scratchpad panel. - -It also supports layer management – in case you want that. The latest stable version hasn’t been updated for a few years now, but the recent alpha build (which I tested) works just fine. If you are looking for an open source paint application on Linux – do give this a try. - -#### How to install MyPaint? - -MyPaint is available in the official repository. However, that’s the old version. If you still want to proceed, you can search for it in the Software Center or type the following command in the terminal: - -``` -sudo apt install mypaint -``` - -You can head to its official [GitHub release page][21] for the latest alpha build and get the [AppImage file][12] (any version) to make it executable and launch the app. - -#### 6\. KolourPaint - -![][22] - -Key Highlights: - - * A simple alternative to MS Paint on Linux - * No layer management support - - - -If you aren’t looking for any Layer management support and just want an open source paint application to draw stuff – this is it. - -[KolourPaint][23] is originally tailored for KDE desktop environments but it works flawlessly on others too. - -#### How to install KolourPaint? - -You can install KolourPaint right from the Software Center or via the terminal using the following command: - -``` -sudo apt install kolourpaint4 -``` - -In either case, you can utilize [Flathub][24] as well. - -**Wrapping Up** - -If you are wondering about applications like GIMP/Inkscape, we have those listed in another separate article on the [best Linux Tools for digital artists][25]. If you’re curious about more options, I recommend you to check that out. - -Here, we try to compile a list of best open source paint applications available for Linux. If you think we missed something, feel free to tell us about it in the comments section below! - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/open-source-paint-apps/ - -作者:[Ankush Das][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/ankush/ -[b]: https://github.com/lujun9972 -[1]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/open-source-paint-apps.png?resize=800%2C450&ssl=1 -[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/pinta.png?ssl=1 -[3]: https://pinta-project.com/pintaproject/pinta/ -[4]: https://itsfoss.com/pinta-1-6-ubuntu-linux-mint/ -[5]: https://itsfoss.com/webp-ubuntu-linux/ -[6]: https://www.flathub.org/apps/details/com.github.PintaProject.Pinta -[7]: https://pinta-project.com/pintaproject/pinta/releases -[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/krita-paint.png?ssl=1 -[9]: https://itsfoss.com/things-to-do-after-installing-fedora-24/ -[10]: https://www.flathub.org/apps/details/org.kde.krita -[11]: https://krita.org/en/download/krita-desktop/ -[12]: https://itsfoss.com/use-appimage-linux/ -[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/tux-paint.jpg?ssl=1 -[14]: http://www.tuxpaint.org/ -[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/09/drawpile.png?ssl=1 -[16]: https://drawpile.net/accounts/signup/ -[17]: https://flathub.org/apps/details/net.drawpile.drawpile -[18]: https://itsfoss.com/ocs-store/ -[19]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/mypaint.png?ssl=1 -[20]: https://mypaint.org/ -[21]: https://github.com/mypaint/mypaint/releases -[22]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/09/kolourpaint.png?ssl=1 -[23]: http://kolourpaint.org/ -[24]: https://flathub.org/apps/details/org.kde.kolourpaint -[25]: https://itsfoss.com/best-linux-graphic-design-software/ diff --git a/sources/tech/20190912 How to fix common pitfalls with the Python ORM tool SQLAlchemy.md b/sources/tech/20190912 How to fix common pitfalls with the Python ORM tool SQLAlchemy.md deleted file mode 100644 index c373e85502..0000000000 --- a/sources/tech/20190912 How to fix common pitfalls with the Python ORM tool SQLAlchemy.md +++ /dev/null @@ -1,208 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (MjSeven ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to fix common pitfalls with the Python ORM tool SQLAlchemy) -[#]: via: (https://opensource.com/article/19/9/common-pitfalls-python) -[#]: author: (Zach Todd https://opensource.com/users/zchtoddhttps://opensource.com/users/lauren-pritchetthttps://opensource.com/users/liranhaimovitchhttps://opensource.com/users/moshez) - -How to fix common pitfalls with the Python ORM tool SQLAlchemy -====== -Seemingly small choices made when using SQLAlchemy can have important -implications on the object-relational mapping toolkit's performance. -![A python with a package.][1] - -Object-relational mapping ([ORM][2]) makes life easier for application developers, in no small part because it lets you interact with a database in a language you may know (such as Python) instead of raw SQL queries. [SQLAlchemy][3] is a Python ORM toolkit that provides access to SQL databases using Python. It is a mature ORM tool that adds the benefit of model relationships, a powerful query construction paradigm, easy serialization, and much more. Its ease of use, however, makes it easy to forget what is going on behind the scenes. Seemingly small choices made using SQLAlchemy can have important performance implications. - -This article explains some of the top performance issues developers encounter when using SQLAlchemy and how to fix them. - -### Retrieving an entire result set when you only need the count - -Sometimes a developer just needs a count of results, but instead of utilizing a database count, all the results are fetched and the count is done with **len** in Python. - - -``` -`count = len(User.query.filter_by(acct_active=True).all())` -``` - -Using SQLAlchemy's **count** method instead will do the count on the server side, resulting in far less data sent to the client. Calling **all()** in the prior example also results in the instantiation of model objects, which can become expensive quickly, given enough rows. - -Unless more than the count is required, just use the **count** method. - - -``` -`count = User.query.filter_by(acct_active=True).count()` -``` - -### Retrieving entire models when you only need a few columns - -In many cases, only a few columns are needed when issuing a query. Instead of returning entire model instances, SQLAlchemy can fetch only the columns you're interested in. This not only reduces the amount of data sent but also avoids the need to instantiate entire objects. Working with tuples of column data instead of models can be quite a bit faster. - - -``` -result = User.query.all() -for user in result: -    print(user.name, user.email) -``` - -Instead, select only what is needed using the **with_entities** method. - - -``` -result = User.query.with_entities(User.name, User.email).all() -for (username, email) in result: -    print(username, email) -``` - -### Updating one object at a time inside a loop - -Avoid using loops to update collections individually. While the database may execute a single update very quickly, the roundtrip time between the application and database servers will quickly add up. In general, strive for fewer queries where reasonable. - - -``` -for user in users_to_update: -  user.acct_active = True -  db.session.add(user) -``` - -Use the bulk update method instead. - - -``` -query = User.query.filter(user.id.in_([user.id for user in users_to_update])) -query.update({"acct_active": True}, synchronize_session=False) -``` - -### Triggering cascading deletes - -ORM allows easy configuration of relationships on models, but there are some subtle behaviors that can be surprising. Most databases maintain relational integrity through foreign keys and various cascade options. SQLAlchemy allows you to define models with foreign keys and cascade options, but the ORM has its own cascade logic that can preempt the database. - -Consider the following models. - - -``` -class Artist(Base): -    __tablename__ = "artist" - -    id = Column(Integer, primary_key=True) -    songs = relationship("Song", cascade="all, delete") - -class Song(Base): -    __tablename__ = "song" - -    id = Column(Integer, primary_key=True) -    artist_id = Column(Integer, ForeignKey("artist.id", ondelete="CASCADE")) -``` - -Deleting artists will cause the ORM to issue **delete** queries on the Song table, thus preventing the deletes from happening as a result of the foreign key. This behavior can become a bottleneck with complex relationships and a large number of records. - -Include the **passive_deletes** option to ensure that the database is managing relationships. Be sure, however, that your database is capable of this. SQLite, for example, does not manage foreign keys by default. - - -``` -`songs = relationship("Song", cascade="all, delete", passive_deletes=True)` -``` - -### Relying on lazy loading when eager loading should be used - -Lazy loading is the default SQLAlchemy approach to relationships. Building from the last example, this implies that loading an artist does not simultaneously load his or her songs. This is usually a good idea, but the separate queries can be wasteful if certain relationships always need to be loaded. - -Popular serialization frameworks like [Marshmallow][4] can trigger a cascade of queries if relationships are allowed to load in a lazy fashion. - -There are a few ways to control this behavior. The simplest method is through the relationship function itself. - - -``` -`songs = relationship("Song", lazy="joined", cascade="all, delete")` -``` - -This will cause a left join to be added to any query for artists, and as a result, the **songs** collection will be immediately available. Although more data is returned to the client, there are potentially far fewer roundtrips. - -SQLAlchemy offers finer-grained control for situations where such a blanket approach can't be taken. The **joinedload()** function can be used to toggle joined loading on a per-query basis. - - -``` -from sqlalchemy.orm import joinedload - -artists = Artist.query.options(joinedload(Artist.songs)) -print(artists.songs) # Does not incur a roundtrip to load -``` - -### Using the ORM for a bulk record import - -The overhead of constructing full model instances becomes a major bottleneck when importing thousands of records. Imagine, for example, loading thousands of song records from a file where each song has first been converted to a dictionary. - - -``` -for song in songs: -    db.session.add(Song(**song)) -``` - -Instead, bypass the ORM and use just the parameter binding functionality of core SQLAlchemy. - - -``` -batch = [] -insert_stmt = Song.__table__.insert() -for song in songs: -    if len(batch) > 1000: -       db.session.execute(insert_stmt, batch) -       batch.clear() -    batch.append(song) -if batch: -    db.session.execute(insert_stmt, batch) -``` - -Keep in mind that this method naturally skips any client-side ORM logic you might depend on, such as Python-based column defaults. While this method is faster than loading objects as full model instances, your database may have bulk loading methods that are faster. PostgreSQL, for example, has the **COPY** command that offers perhaps the best performance for loading large numbers of records. - -### Calling commit or flush prematurely - -There are many occasions when you need to associate a child record to its parent, or vice versa. One obvious way of doing this is to flush the session so that the record in question will be assigned an ID. - - -``` -artist = Artist(name="Bob Dylan") -song = Song(title="Mr. Tambourine Man") - -db.session.add(artist) -db.session.flush() - -song.artist_id = artist.id -``` - -Committing or flushing more than once per request is usually unnecessary and undesirable. A database flush involves forcing disk writes on the database server, and in most circumstances, the client will block until the server can acknowledge that the data has been written. - -SQLAlchemy can track relationships and manage keys behind the scenes. - - -``` -artist = Artist(name="Bob Dylan") -song = Song(title="Mr. Tambourine Man") - -artist.songs.append(song) -``` - -### Wrapping up - -I hope this list of common pitfalls can help you avoid these issues and keep your application running smoothly. As always, when diagnosing a performance problem, measurement is key. Most databases offer performance diagnostics that can help you pinpoint issues, such as the PostgreSQL **pg_stat_statements** module. - -* * * - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/9/common-pitfalls-python - -作者:[Zach Todd][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/zchtoddhttps://opensource.com/users/lauren-pritchetthttps://opensource.com/users/liranhaimovitchhttps://opensource.com/users/moshez -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python_snake_file_box.jpg?itok=UuDVFLX- (A python with a package.) -[2]: https://en.wikipedia.org/wiki/Object-relational_mapping -[3]: https://www.sqlalchemy.org/ -[4]: https://marshmallow.readthedocs.io/en/stable/ diff --git a/sources/tech/20190924 An advanced look at Python interfaces using zope.interface.md b/sources/tech/20190924 An advanced look at Python interfaces using zope.interface.md index 16b4780710..aa984555d8 100644 --- a/sources/tech/20190924 An advanced look at Python interfaces using zope.interface.md +++ b/sources/tech/20190924 An advanced look at Python interfaces using zope.interface.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (MjSeven) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20191007 7 Java tips for new developers.md b/sources/tech/20191007 7 Java tips for new developers.md deleted file mode 100644 index 6a560ceb2d..0000000000 --- a/sources/tech/20191007 7 Java tips for new developers.md +++ /dev/null @@ -1,222 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (7 Java tips for new developers) -[#]: via: (https://opensource.com/article/19/10/java-basics) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) - -7 Java tips for new developers -====== -If you're just getting started with Java programming, here are seven -basics you need to know. -![Coffee and laptop][1] - -Java is a versatile programming language used, in some way, in nearly every industry that touches a computer. Java's greatest power is that it runs in a Java Virtual Machine (JVM), a layer that translates Java code into bytecode compatible with your operating system. As long as a JVM exists for your operating system, whether that OS is on a server (or [serverless][2], for that matter), desktop, laptop, mobile device, or embedded device, then a Java application can run on it. - -This makes Java a popular language for both programmers and users. Programmers know that they only have to write one version of their software to end up with an application that runs on any platform, and users know that an application will run on their computer regardless of what operating system they use. - -Many languages and frameworks are cross-platform, but none deliver the same level of abstraction. With Java, you target the JVM, not the OS. For programmers, that's the path of least resistance when faced with several programming challenges, but it's only useful if you know how to program Java. If you're just getting started with Java programming, here are seven basic tips you need to know. - -But first, if you're not sure whether you have Java installed, you can find out in a terminal (such as [Bash][3] or [PowerShell][4]) by running: - - -``` -$ java --version -openjdk 12.0.2 2019-07-16 -OpenJDK Runtime Environment 19.3 (build 12.0.2+9) -OpenJDK 64-Bit Server VM 19.3 (build 12.0.2+9, mixed mode, sharing) -``` - -If you get an error or nothing in return, then you should install the [Java Development Kit][5] (JDK) to get started with Java development. Or install a Java Runtime Environment ****(JRE) if you just need to run Java applications. - -### 1\. Java packages - -In Java, related classes are grouped into a _package_. The basic Java libraries you get when you download the JDK are grouped into packages starting with **java** or **javax**. Packages serve a similar function as folders on your computer: they provide structure and definition for related elements (in programming terminology, a _namespace_). Additional packages can be obtained from independent coders, open source projects, and commercial vendors, just as libraries can be obtained for any programming language. - -When you write a Java program, you should declare a package name at the top of your code. If you're just writing a simple application to get started with Java, your package name can be as simple as the name of your project. If you're using a Java integrated development environment (IDE), like [Eclipse][6], it generates a sane package name for you when you start a new project. - - -``` -package helloworld; - -/** - * @author seth - * An application written in Java. - */ -``` - -Otherwise, you can determine the name of your package by looking at its path in relation to the broad definition of your project. For instance, if you're writing a set of classes to assist in game development and the collection is called **jgamer**, then you might have several unique classes within it. - - -``` -package jgamer.avatar; - -/** - * @author seth - * An imaginary game library. - */ -``` - -The top level of your package is **jgamer**, and each package inside it is a descendant, such as **jgamer.avatar** and **jgamer.score** and so on. In your filesystem, the structure reflects this, with **jgamer** being the top directory containing the files **avatar.java** and **score.java**. - -### 2\. Java imports - -The most fun you'll ever have as a polyglot programmer is trying to keep track of whether you **include**, **import**, **use**, **require**, or **some other term** a library in whatever programming language you're writing in. Java, for the record, uses the **import** keyword when importing libraries needed for your code. - - -``` -package helloworld; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; - -/** - * @author seth - * A GUI hello world. - */ -``` - -Imports work based on an environment's Java path. If Java doesn't know where Java libraries are stored on a system, then an import cannot be successful. As long as a library is stored in a system's Java path, then an import can succeed, and a library can be used to build and run a Java application. - -If a library is not expected to be in the Java path (because, for instance, you are writing the library yourself), then the library can be bundled with your application (license permitting) so that the import works as expected. - -### 3\. Java classes - -A Java class is declared with the keywords **public class** along with a unique class name mirroring its file name. For example, in a file **Hello.java** in project **helloworld**: - - -``` -package helloworld; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; - -/** - * @author seth - * A GUI hello world. - */ - -public class Hello { -        // this is an empty class -} -``` - -You can declare variables and functions inside a class. In Java, variables within a class are called _fields_. - -### 4\. Java methods - -Java methods are, essentially, functions within an object. They are defined as being **public** (meaning they can be accessed by any other class) or **private** (limiting their use) based on the expected type of returned data, such as **void**, **int**, **float**, and so on. - - -``` -    public void helloPrompt([ActionEvent][7] event) { -        [String][8] salutation = "Hello %s"; -  -        string helloMessage = "World"; -        message = [String][8].format(salutation, helloMessage); -        [JOptionPane][9].showMessageDialog(this, message); -    } -  -    private int someNumber (x) { -        return x*2; -    } -``` - -When calling a method directly, it is referenced by its class and method name. For instance, **Hello.someNumber** refers to the **someNumber** method in the **Hello** class. - -### 5\. Static - -The **static** keyword in Java makes a member in your code accessible independently of the object that contains it. - -In object-oriented programming, you write code that serves as a template for "objects" that get spawned as the application runs. You don't code a specific window, for instance, but an _instance_ of a window based upon a window class in Java (and modified by your code). Since nothing you are coding "exists" until the application generates an instance of it, most methods and variables (and even nested classes) cannot be used until the object they depend upon has been created. - -However, sometimes you need to access or use data in an object before it is created by the application (for example, an application can't generate a red ball without first knowing that the ball is meant to be red). For those cases, there's the **static** keyword. - -### 6\. Try and catch - -Java is excellent at catching errors, but it can only recover gracefully if you tell it what to do. The cascading hierarchy of attempting to perform an action in Java starts with **try**, falls back to **catch**, and ends with **finally**. Should the **try** clause fail, then **catch** is invoked, and in the end, there's always **finally** to perform some sensible action regardless of the results. Here's an example: - - -``` -try { -        cmd = parser.parse(opt, args);  -        -        if(cmd.hasOption("help")) { -                HelpFormatter helper = new HelpFormatter(); -                helper.printHelp("Hello <options>", opt); -                [System][10].exit(0); -                } -        else { -                if(cmd.hasOption("shell") || cmd.hasOption("s")) { -                [String][8] target = cmd.getOptionValue("tgt"); -                } // else -        } // fi -} catch ([ParseException][11] err) { -        [System][10].out.println(err); -        [System][10].exit(1); -        } //catch -        finally { -                new Hello().helloWorld(opt); -        } //finally -} //try -``` - -It's a robust system that attempts to avoid irrecoverable errors or, at least, to provide you with the option to give useful feedback to the user. Use it often, and your users will thank you! - -### 7\. Running a Java application - -Java files, usually ending in **.java**, theoretically can be run with the **java** command. If an application is complex, however, whether running a single file results in anything meaningful is another question. - -To run a **.java** file directly: - - -``` -`$ java ./Hello.java` -``` - -Usually, Java applications are distributed as Java Archives (JAR) files, ending in **.jar**. A JAR file contains a manifest file specifying the main class, some metadata about the project structure, and all the parts of your code required to run the application. - -To run a JAR file, you may be able to double-click its icon (depending on how you have your OS set up), or you can launch it from a terminal: - - -``` -`$ java -jar ./Hello.jar` -``` - -### Java for everyone - -Java is a powerful language, and thanks to the [OpenJDK][12] project and other initiatives, it's an open specification that allows projects like [IcedTea][13], [Dalvik][14], and [Kotlin][15] to thrive. Learning Java is a great way to prepare to work in a wide variety of industries, and what's more, there are plenty of [great reasons to use it][16]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/java-basics - -作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/seth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_cafe_brew_laptop_desktop.jpg?itok=G-n1o1-o (Coffee and laptop) -[2]: https://www.redhat.com/en/resources/building-microservices-eap-7-reference-architecture -[3]: https://www.gnu.org/software/bash/ -[4]: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-6 -[5]: http://openjdk.java.net/ -[6]: http://www.eclipse.org/ -[7]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+actionevent -[8]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string -[9]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+joptionpane -[10]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system -[11]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+parseexception -[12]: https://openjdk.java.net/ -[13]: https://icedtea.classpath.org/wiki/Main_Page -[14]: https://source.android.com/devices/tech/dalvik/ -[15]: https://kotlinlang.org/ -[16]: https://opensource.com/article/19/9/why-i-use-java diff --git a/sources/tech/20191007 Using the Java Persistence API.md b/sources/tech/20191007 Using the Java Persistence API.md index e911428044..6b16213fc1 100644 --- a/sources/tech/20191007 Using the Java Persistence API.md +++ b/sources/tech/20191007 Using the Java Persistence API.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (runningwater) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) @@ -255,7 +255,7 @@ via: https://opensource.com/article/19/10/using-java-persistence-api 作者:[Stephon Brown][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) +译者:[runningwater](https://github.com/runningwater) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/tech/20191018 How to use Protobuf for data interchange.md b/sources/tech/20191018 How to use Protobuf for data interchange.md deleted file mode 100644 index 4de9e2120a..0000000000 --- a/sources/tech/20191018 How to use Protobuf for data interchange.md +++ /dev/null @@ -1,516 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to use Protobuf for data interchange) -[#]: via: (https://opensource.com/article/19/10/protobuf-data-interchange) -[#]: author: (Marty Kalin https://opensource.com/users/mkalindepauledu) - -How to use Protobuf for data interchange -====== -Protobuf encoding increases efficiency when exchanging data between -applications written in different languages and running on different -platforms. -![metrics and data shown on a computer screen][1] - -Protocol buffers ([Protobufs][2]), like XML and JSON, allow applications, which may be written in different languages and running on different platforms, to exchange data. For example, a sending application written in Go could encode a Go-specific sales order in Protobuf, which a receiver written in Java then could decode to get a Java-specific representation of the received order. Here is a sketch of the architecture over a network connection: - - -``` -`Go sales order--->Pbuf-encode--->network--->Pbuf-decode--->Java sales order` -``` - -Protobuf encoding, in contrast to its XML and JSON counterparts, is binary rather than text, which can complicate debugging. However, as the code examples in this article confirm, the Protobuf encoding is significantly more efficient in size than either XML or JSON encoding. - -Protobuf is efficient in another way. At the implementation level, Protobuf and other encoding systems serialize and deserialize structured data. Serialization transforms a language-specific data structure into a bytestream, and deserialization is the inverse operation that transforms a bytestream back into a language-specific data structure. Serialization and deserialization may become the bottleneck in data interchange because these operations are CPU-intensive. Efficient serialization and deserialization is another Protobuf design goal. - -Recent encoding technologies, such as Protobuf and FlatBuffers, derive from the [DCE/RPC][3] (Distributed Computing Environment/Remote Procedure Call) initiative of the early 1990s. Like DCE/RPC, Protobuf contributes to both the [IDL][4] (interface definition language) and the encoding layer in data interchange. - -This article will look at these two layers then provide code examples in Go and Java to flesh out Protobuf details and show that Protobuf is easy to use. - -### Protobuf as an IDL and encoding layer - -DCE/RPC, like Protobuf, is designed to be language- and platform-neutral. The appropriate libraries and utilities allow any language and platform to play in the DCE/RPC arena. Furthermore, the DCE/RPC architecture is elegant. An IDL document is the contract between the remote procedure on the one side and callers on the other side. Protobuf, too, centers on an IDL document. - -An IDL document is text and, in DCE/RPC, uses basic C syntax along with syntactic extensions for metadata (square brackets) and a few new keywords such as **interface**. Here is an example: - - -``` -[uuid (2d6ead46-05e3-11ca-7dd1-426909beabcd), version(1.0)] -interface echo { -   const long int ECHO_SIZE = 512; -   void echo( -      [in]          handle_t h, -      [in, string]  idl_char from_client[ ], -      [out, string] idl_char from_service[ECHO_SIZE] -   ); -} -``` - -This IDL document declares a procedure named **echo**, which takes three arguments: the **[in]** arguments of type **handle_t** (implementation pointer) and **idl_char** (array of ASCII characters) are passed to the remote procedure, whereas the **[out]** argument (also a string) is passed back from the procedure. In this example, the **echo** procedure does not explicitly return a value (the **void** to the left of **echo**) but could do so. A return value, together with one or more **[out]** arguments, allows the remote procedure to return arbitrarily many values. The next section introduces a Protobuf IDL, which differs in syntax but likewise serves as a contract in data interchange. - -The IDL document, in both DCE/RPC and Protobuf, is the input to utilities that create the infrastructure code for exchanging data: - - -``` -`IDL document--->DCE/PRC or Protobuf utilities--->support code for data interchange` -``` - -As relatively straightforward text, the IDL is likewise human-readable documentation about the specifics of the data interchange—in particular, the number of data items exchanged and the data type of each item. - -Protobuf can used in a modern RPC system such as [gRPC][5]; but Protobuf on its own provides only the IDL layer and the encoding layer for messages passed from a sender to a receiver. Protobuf encoding, like the DCE/RPC original, is binary but more efficient. - -At present, XML and JSON encodings still dominate in data interchange through technologies such as web services, which make use of in-place infrastructure such as web servers, transport protocols (e.g., TCP, HTTP), and standard libraries and utilities for processing XML and JSON documents. Moreover, database systems of various flavors can store XML and JSON documents, and even legacy relational systems readily generate XML encodings of query results. Every general-purpose programming language now has libraries that support XML and JSON. What, then, recommends a return to a _binary_ encoding system such as Protobuf? - -Consider the negative decimal value **-128**. In the 2's complement binary representation, which dominates across systems and languages, this value can be stored in a single 8-bit byte: 10000000. The text encoding of this integer value in XML or JSON requires multiple bytes. For example, UTF-8 encoding requires four bytes for the string, literally **-128**, which is one byte per character (in hex, the values are 0x2d, 0x31, 0x32, and 0x38). XML and JSON also add markup characters, such as angle brackets and braces, to the mix. Details about Protobuf encoding are forthcoming, but the point of interest now is a general one: Text encodings tend to be significantly less compact than binary ones. - -### A code example in Go using Protobuf - -My code examples focus on Protobuf rather than RPC. Here is an overview of the first example: - - * The IDL file named _dataitem.proto_ defines a Protobuf **message** with six fields of different types: integer values with different ranges, floating-point values of a fixed size, and strings of two different lengths. - * The Protobuf compiler uses the IDL file to generate a Go-specific version (and, later, a Java-specific version) of the Protobuf **message** together with supporting functions. - * A Go app populates the native Go data structure with randomly generated values and then serializes the result to a local file. For comparison, XML and JSON encodings also are serialized to local files. - * As a test, the Go application reconstructs an instance of its native data structure by deserializing the contents of the Protobuf file. - * As a language-neutrality test, the Java application also deserializes the contents of the Protobuf file to get an instance of a native data structure. - - - -This IDL file and two Go and one Java source files are available as a ZIP file on [my website][6]. - -The all-important Protobuf IDL document is shown below. The document is stored in the file _dataitem.proto_, with the customary _.proto_ extension. - -#### Example 1. Protobuf IDL document - - -``` -syntax = "proto3"; - -package main; - -message DataItem { -  int64  oddA  = 1; -  int64  evenA = 2; -  int32  oddB  = 3; -  int32  evenB = 4; -  float  small = 5; -  float  big   = 6; -  string short = 7; -  string long  = 8; -} -``` - -The IDL uses the current proto3 rather than the earlier proto2 syntax. The package name (in this case, **main**) is optional but customary; it is used to avoid name conflicts. The structured **message** contains eight fields, each of which has a Protobuf data type (e.g., **int64**, **string**), a name (e.g., **oddA**, **short**), and a numeric tag (aka key) after the equals sign **=**. The tags, which are 1 through 8 in this example, are unique integer identifiers that determine the order in which the fields are serialized. - -Protobuf messages can be nested to arbitrary levels, and one message can be the field type in the other. Here's an example that uses the **DataItem** message as a field type: - - -``` -message DataItems { -  repeated DataItem item = 1; -} -``` - -A single **DataItems** message consists of repeated (none or more) **DataItem** messages. - -Protobuf also supports enumerated types for clarity: - - -``` -enum PartnershipStatus { -  reserved "FREE", "CONSTRAINED", "OTHER"; -} -``` - -The **reserved** qualifier ensures that the numeric values used to implement the three symbolic names cannot be reused. - -To generate a language-specific version of one or more declared Protobuf **message** structures, the IDL file containing these is passed to the _protoc_ compiler (available in the [Protobuf GitHub repository][7]). For the Go code, the supporting Protobuf library can be installed in the usual way (with **%** as the command-line prompt): - - -``` -`% go get github.com/golang/protobuf/proto` -``` - -The command to compile the Protobuf IDL file _dataitem.proto_ into Go source code is: - - -``` -`% protoc --go_out=. dataitem.proto` -``` - -The flag **\--go_out** directs the compiler to generate Go source code; there are similar flags for other languages. The result, in this case, is a file named _dataitem.pb.go_, which is small enough that the essentials can be copied into a Go application. Here are the essentials from the generated code: - - -``` -var _ = proto.Marshal - -type DataItem struct { -   OddA  int64   `protobuf:"varint,1,opt,name=oddA" json:"oddA,omitempty"` -   EvenA int64   `protobuf:"varint,2,opt,name=evenA" json:"evenA,omitempty"` -   OddB  int32   `protobuf:"varint,3,opt,name=oddB" json:"oddB,omitempty"` -   EvenB int32   `protobuf:"varint,4,opt,name=evenB" json:"evenB,omitempty"` -   Small float32 `protobuf:"fixed32,5,opt,name=small" json:"small,omitempty"` -   Big   float32 `protobuf:"fixed32,6,opt,name=big" json:"big,omitempty"` -   Short string  `protobuf:"bytes,7,opt,name=short" json:"short,omitempty"` -   Long  string  `protobuf:"bytes,8,opt,name=long" json:"long,omitempty"` -} - -func (m *DataItem) Reset()         { *m = DataItem{} } -func (m *DataItem) String() string { return proto.CompactTextString(m) } -func (*DataItem) ProtoMessage()    {} -func init() {} -``` - -The compiler-generated code has a Go structure **DataItem**, which exports the Go fields—the names are now capitalized—that match the names declared in the Protobuf IDL. The structure fields have standard Go data types: **int32**, **int64**, **float32**, and **string**. At the end of each field line, as a string, is metadata that describes the Protobuf types, gives the numeric tags from the Protobuf IDL document, and provides information about JSON, which is discussed later. - -There are also functions; the most important is **proto.Marshal** for serializing an instance of the **DataItem** structure into Protobuf format. The helper functions include **Reset**, which clears a **DataItem** structure, and **String**, which produces a one-line string representation of a **DataItem**. - -The metadata that describes Protobuf encoding deserves a closer look before analyzing the Go program in more detail. - -### Protobuf encoding - -A Protobuf message is structured as a collection of key/value pairs, with the numeric tag as the key and the corresponding field as the value. The field names, such as **oddA** and **small**, are for human readability, but the _protoc_ compiler does use the field names in generating language-specific counterparts. For example, the **oddA** and **small** names in the Protobuf IDL become the fields **OddA** and **Small**, respectively, in the Go structure. - -The keys and their values both get encoded, but with an important difference: some numeric values have a fixed-size encoding of 32 or 64 bits, whereas others (including the **message** tags) are _varint_ encoded—the number of bits depends on the integer's absolute value. For example, the integer values 1 through 15 require 8 bits to encode in _varint_, whereas the values 16 through 2047 require 16 bits. The _varint_ encoding, similar in spirit (but not in detail) to UTF-8 encoding, favors small integer values over large ones. (For a detailed analysis, see the Protobuf [encoding guide][8].) The upshot is that a Protobuf **message** should have small integer values in fields, if possible, and as few keys as possible, but one key per field is unavoidable. - -Table 1 below gives the gist of Protobuf encoding: - -**Table 1. Protobuf data types** - -Encoding | Sample types | Length ----|---|--- -varint | int32, uint32, int64 | Variable length -fixed | fixed32, float, double | Fixed 32-bit or 64-bit length -byte sequence | string, bytes | Sequence length - -Integer types that are not explicitly **fixed** are _varint_ encoded; hence, in a _varint_ type such as **uint32** (**u** for unsigned), the number 32 describes the integer's range (in this case, 0 to 232 \- 1) rather than its bit size, which differs depending on the value. For fixed types such as **fixed32** or **double**, by contrast, the Protobuf encoding requires 32 and 64 bits, respectively. Strings in Protobuf are byte sequences; hence, the size of the field encoding is the length of the byte sequence. - -Another efficiency deserves mention. Recall the earlier example in which a **DataItems** message consists of repeated **DataItem** instances: - - -``` -message DataItems { -  repeated DataItem item = 1; -} -``` - -The **repeated** means that the **DataItem** instances are _packed_: the collection has a single tag, in this case, 1. A **DataItems** message with repeated **DataItem** instances is thus more efficient than a message with multiple but separate **DataItem** fields, each of which would require a tag of its own. - -With this background in mind, let's return to the Go program. - -### The dataItem program in detail - -The _dataItem_ program creates a **DataItem** instance and populates the fields with randomly generated values of the appropriate types. Go has a **rand** package with functions for generating pseudo-random integer and floating-point values, and my **randString** function generates pseudo-random strings of specified lengths from a character set. The design goal is to have a **DataItem** instance with field values of different types and bit sizes. For example, the **OddA** and **EvenA** values are 64-bit non-negative integer values of odd and even parity, respectively; but the **OddB** and **EvenB** variants are 32 bits in size and hold small integer values between 0 and 2047. The random floating-point values are 32 bits in size, and the strings are 16 (**Short**) and 32 (**Long**) characters in length. Here is the code segment that populates the **DataItem** structure with random values: - - -``` -// variable-length integers -n1 := rand.Int63()        // bigger integer -if (n1 & 1) == 0 { n1++ } // ensure it's odd -... -n3 := rand.Int31() % UpperBound // smaller integer -if (n3 & 1) == 0 { n3++ }       // ensure it's odd - -// fixed-length floats -... -t1 := rand.Float32() -t2 := rand.Float32() -... -// strings -str1 := randString(StrShort) -str2 := randString(StrLong) - -// the message -dataItem := &DataItem { -   OddA:  n1, -   EvenA: n2, -   OddB:  n3, -   EvenB: n4, -   Big:   f1, -   Small: f2, -   Short: str1, -   Long:  str2, -} -``` - -Once created and populated with values, the **DataItem** instance is encoded in XML, JSON, and Protobuf, with each encoding written to a local file: - - -``` -func encodeAndserialize(dataItem *DataItem) { -   bytes, _ := xml.MarshalIndent(dataItem, "", " ")  // Xml to dataitem.xml -   ioutil.WriteFile(XmlFile, bytes, 0644)            // 0644 is file access permissions - -   bytes, _ = json.MarshalIndent(dataItem, "", " ")  // Json to dataitem.json -   ioutil.WriteFile(JsonFile, bytes, 0644) - -   bytes, _ = proto.Marshal(dataItem)                // Protobuf to dataitem.pbuf -   ioutil.WriteFile(PbufFile, bytes, 0644) -} -``` - -The three serializing functions use the term _marshal_, which is roughly synonymous with _serialize_. As the code indicates, each of the three **Marshal** functions returns an array of bytes, which then are written to a file. (Possible errors are ignored for simplicity.) On a sample run, the file sizes were: - - -``` -dataitem.xml:  262 bytes -dataitem.json: 212 bytes -dataitem.pbuf:  88 bytes -``` - -The Protobuf encoding is significantly smaller than the other two. The XML and JSON serializations could be reduced slightly in size by eliminating indentation characters, in this case, blanks and newlines. - -Below is the _dataitem.json_ file resulting eventually from the **json.MarshalIndent** call, with added comments starting with **##**: - - -``` -{ - "oddA":  4744002665212642479,                ## 64-bit >= 0 - "evenA": 2395006495604861128,                ## ditto - "oddB":  57,                                 ## 32-bit >= 0 but < 2048 - "evenB": 468,                                ## ditto - "small": 0.7562016,                          ## 32-bit floating-point - "big":   0.85202795,                         ## ditto - "short": "ClH1oDaTtoX$HBN5",                 ## 16 random chars - "long":  "xId0rD3Cri%3Wt%^QjcFLJgyXBu9^DZI"  ## 32 random chars -} -``` - -Although the serialized data goes into local files, the same approach would be used to write the data to the output stream of a network connection. - -### Testing serialization/deserialization - -The Go program next runs an elementary test by deserializing the bytes, which were written earlier to the _dataitem.pbuf_ file, into a **DataItem** instance. Here is the code segment, with the error-checking parts removed: - - -``` -filebytes, err := ioutil.ReadFile(PbufFile) // get the bytes from the file -... -testItem.Reset()                            // clear the DataItem structure -err = proto.Unmarshal(filebytes, testItem)  // deserialize into a DataItem instance -``` - -The **proto.Unmarshal** function for deserializing Protbuf is the inverse of the **proto.Marshal** function. The original **DataItem** and the deserialized clone are printed to confirm an exact match: - - -``` -Original: -2041519981506242154 3041486079683013705 1192 1879 -0.572123 0.326855 -boPb#T0O8Xd&Ps5EnSZqDg4Qztvo7IIs 9vH66AiGSQgCDxk& - -Deserialized: -2041519981506242154 3041486079683013705 1192 1879 -0.572123 0.326855 -boPb#T0O8Xd&Ps5EnSZqDg4Qztvo7IIs 9vH66AiGSQgCDxk& -``` - -### A Protobuf client in Java - -The example in Java is to confirm Protobuf's language neutrality. The original IDL file could be used to generate the Java support code, which involves nested classes. To suppress warnings, however, a slight addition can be made. Here is the revision, which specifies a **DataMsg** as the name for the outer class, with the inner class automatically named **DataItem** after the Protobuf message: - - -``` -syntax = "proto3"; - -package main; - -option java_outer_classname = "DataMsg"; - -message DataItem { -... -``` - -With this change in place, the _protoc_ compilation is the same as before, except the desired output is now Java rather than Go: - - -``` -`% protoc --java_out=. dataitem.proto` -``` - -The resulting source file (in a subdirectory named _main_) is _DataMsg.java_ and about 1,120 lines in length: Java is not terse. Compiling and then running the Java code requires a JAR file with the library support for Protobuf. This file is available in the [Maven repository][9]. - -With the pieces in place, my test code is relatively short (and available in the ZIP file as _Main.java_): - - -``` -package main; -import java.io.FileInputStream; - -public class Main { -   public static void main(String[] args) { -      String path = "dataitem.pbuf";  // from the Go program's serialization -      try { -         DataMsg.DataItem deserial = -           DataMsg.DataItem.newBuilder().mergeFrom(new FileInputStream(path)).build(); - -         System.out.println(deserial.getOddA()); // 64-bit odd -         System.out.println(deserial.getLong()); // 32-character string -      } -      catch(Exception e) { System.err.println(e); } -    } -} -``` - -Production-grade testing would be far more thorough, of course, but even this preliminary test confirms the language-neutrality of Protobuf: the _dataitem.pbuf_ file results from the Go program's serialization of a Go **DataItem**, and the bytes in this file are deserialized to produce a **DataItem** instance in Java. The output from the Java test is the same as that from the Go test. - -### Wrapping up with the numPairs program - -Let's end with an example that highlights Protobuf efficiency but also underscores the cost involved in any encoding technology. Consider this Protobuf IDL file: - - -``` -syntax = "proto3"; -package main; - -message NumPairs { -  repeated NumPair pair = 1; -} - -message NumPair { -  int32 odd = 1; -  int32 even = 2; -} -``` - -A **NumPair** message consists of two **int32** values together with an integer tag for each field. A **NumPairs** message is a sequence of embedded **NumPair** messages. - -The _numPairs_ program in Go (below) creates 2 million **NumPair** instances, with each appended to the **NumPairs** message. This message can be serialized and deserialized in the usual way. - -#### Example 2. The numPairs program - - -``` -package main - -import ( -   "math/rand" -   "time" -   "encoding/xml" -   "encoding/json" -   "io/ioutil" -   "github.com/golang/protobuf/proto" -) - -// protoc-generated code: start -var _ = proto.Marshal -type NumPairs struct { -   Pair []*NumPair `protobuf:"bytes,1,rep,name=pair" json:"pair,omitempty"` -} - -func (m *NumPairs) Reset()         { *m = NumPairs{} } -func (m *NumPairs) String() string { return proto.CompactTextString(m) } -func (*NumPairs) ProtoMessage()    {} -func (m *NumPairs) GetPair() []*NumPair { -   if m != nil { return m.Pair } -   return nil -} - -type NumPair struct { -   Odd  int32 `protobuf:"varint,1,opt,name=odd" json:"odd,omitempty"` -   Even int32 `protobuf:"varint,2,opt,name=even" json:"even,omitempty"` -} - -func (m *NumPair) Reset()         { *m = NumPair{} } -func (m *NumPair) String() string { return proto.CompactTextString(m) } -func (*NumPair) ProtoMessage()    {} -func init() {} -// protoc-generated code: finish - -var numPairsStruct NumPairs -var numPairs = &numPairsStruct - -func encodeAndserialize() { -   // XML encoding -   filename := "./pairs.xml" -   bytes, _ := xml.MarshalIndent(numPairs, "", " ") -   ioutil.WriteFile(filename, bytes, 0644) - -   // JSON encoding -   filename = "./pairs.json" -   bytes, _ = json.MarshalIndent(numPairs, "", " ") -   ioutil.WriteFile(filename, bytes, 0644) - -   // ProtoBuf encoding -   filename = "./pairs.pbuf" -   bytes, _ = proto.Marshal(numPairs) -   ioutil.WriteFile(filename, bytes, 0644) -} - -const HowMany = 200 * 100  * 100 // two million - -func main() { -   rand.Seed(time.Now().UnixNano()) - -   // uncomment the modulus operations to get the more efficient version -   for i := 0; i < HowMany; i++ { -      n1 := rand.Int31() // % 2047 -      if (n1 & 1) == 0 { n1++ } // ensure it's odd -      n2 := rand.Int31() // % 2047 -      if (n2 & 1) == 1 { n2++ } // ensure it's even - -      next := &NumPair { -                 Odd:  n1, -                 Even: n2, -              } -      numPairs.Pair = append(numPairs.Pair, next) -   } -   encodeAndserialize() -} -``` - -The randomly generated odd and even values in each **NumPair** range from zero to 2 billion and change. In terms of raw rather than encoded data, the integers generated in the Go program add up to 16MB: two integers per **NumPair** for a total of 4 million integers in all, and each value is four bytes in size. - -For comparison, the table below has entries for the XML, JSON, and Protobuf encodings of the 2 million **NumPair** instances in the sample **NumsPairs** message. The raw data is included, as well. Because the _numPairs_ program generates random values, output differs across sample runs but is close to the sizes shown in the table. - -**Table 2. Encoding overhead for 16MB of integers** - -Encoding | File | Byte size | Pbuf/other ratio ----|---|---|--- -None | pairs.raw | 16MB | 169% -Protobuf | pairs.pbuf | 27MB | — -JSON | pairs.json | 100MB | 27% -XML | pairs.xml | 126MB | 21% - -As expected, Protobuf shines next to XML and JSON. The Protobuf encoding is about a quarter of the JSON one and about a fifth of the XML one. But the raw data make clear that Protobuf incurs the overhead of encoding: the serialized Protobuf message is 11MB larger than the raw data. Any encoding, including Protobuf, involves structuring the data, which unavoidably adds bytes. - -Each of the serialized 2 million **NumPair** instances involves _four_ integer values: one apiece for the **Even** and **Odd** fields in the Go structure, and one tag per each field in the Protobuf encoding. As raw rather than encoded data, this would come to 16 bytes per instance, and there are 2 million instances in the sample **NumPairs** message. But the Protobuf tags, like the **int32** values in the **NumPair** fields, use _varint_ encoding and, therefore, vary in byte length; in particular, small integer values (which include the tags, in this case) require fewer than four bytes to encode. - -If the _numPairs_ program is revised so that the two **NumPair** fields hold values less than 2048, which have encodings of either one or two bytes, then the Protobuf encoding drops from 27MB to 16MB—the very size of the raw data. The table below summarizes the new encoding sizes from a sample run. - -**Table 3. Encoding with 16MB of integers < 2048** - -Encoding | File | Byte size | Pbuf/other ratio ----|---|---|--- -None | pairs.raw | 16MB | 100% -Protobuf | pairs.pbuf | 16MB | — -JSON | pairs.json | 77MB | 21% -XML | pairs.xml | 103MB | 15% - -In summary, the modified _numPairs_ program, with field values less than 2048, reduces the four-byte size for each integer value in the raw data. But the Protobuf encoding still requires tags, which add bytes to the Protobuf message. Protobuf encoding does have a cost in message size, but this cost can be reduced by the _varint_ factor if relatively small integer values, whether in fields or keys, are being encoded. - -For moderately sized messages consisting of structured data with mixed types—and relatively small integer values—Protobuf has a clear advantage over options such as XML and JSON. In other cases, the data may not be suited for Protobuf encoding. For example, if two applications need to share a huge set of text records or large integer values, then compression rather than encoding technology may be the way to go. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/protobuf-data-interchange - -作者:[Marty Kalin][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/mkalindepauledu -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_data_dashboard_system_computer_analytics.png?itok=oxAeIEI- (metrics and data shown on a computer screen) -[2]: https://developers.google.com/protocol-buffers/ -[3]: https://en.wikipedia.org/wiki/DCE/RPC -[4]: https://en.wikipedia.org/wiki/Interface_description_language -[5]: https://grpc.io/ -[6]: http://condor.depaul.edu/mkalin -[7]: https://github.com/protocolbuffers/protobuf -[8]: https://developers.google.com/protocol-buffers/docs/encoding -[9]: https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java diff --git a/sources/tech/20191021 How to program with Bash- Syntax and tools.md b/sources/tech/20191021 How to program with Bash- Syntax and tools.md deleted file mode 100644 index ae17b836d5..0000000000 --- a/sources/tech/20191021 How to program with Bash- Syntax and tools.md +++ /dev/null @@ -1,272 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to program with Bash: Syntax and tools) -[#]: via: (https://opensource.com/article/19/10/programming-bash-part-1) -[#]: author: (David Both https://opensource.com/users/dboth) - -How to program with Bash: Syntax and tools -====== -Learn basic Bash programming syntax and tools, as well as how to use -variables and control operators, in the first article in this three-part -series. -![bash logo on green background][1] - -A shell is the command interpreter for the operating system. Bash is my favorite shell, but every Linux shell interprets the commands typed by the user or sysadmin into a form the operating system can use. When the results are returned to the shell program, it sends them to STDOUT which, by default, [displays them in the terminal][2]. All of the shells I am familiar with are also programming languages. - -Features like tab completion, command-line recall and editing, and shortcuts like aliases all contribute to its value as a powerful shell. Its default command-line editing mode uses Emacs, but one of my favorite Bash features is that I can change it to Vi mode to use editing commands that are already part of my muscle memory. - -However, if you think of Bash solely as a shell, you miss much of its true power. While researching my three-volume [Linux self-study course][3] (on which this series of articles is based), I learned things about Bash that I'd never known in over 20 years of working with Linux. Some of these new bits of knowledge relate to its use as a programming language. Bash is a powerful programming language, one perfectly designed for use on the command line and in shell scripts. - -This three-part series explores using Bash as a command-line interface (CLI) programming language. This first article looks at some simple command-line programming with Bash, variables, and control operators. The other articles explore types of Bash files; string, numeric, and miscellaneous logical operators that provide execution-flow control logic; different types of shell expansions; and the **for**, **while**, and **until** loops that enable repetitive operations. They will also look at some commands that simplify and support the use of these tools. - -### The shell - -A shell is the command interpreter for the operating system. Bash is my favorite shell, but every Linux shell interprets the commands typed by the user or sysadmin into a form the operating system can use. When the results are returned to the shell program, it displays them in the terminal. All of the shells I am familiar with are also programming languages. - -Bash stands for Bourne Again Shell because the Bash shell is [based upon][4] the older Bourne shell that was written by Steven Bourne in 1977. Many [other shells][5] are available, but these are the four I encounter most frequently: - - * **csh:** The C shell for programmers who like the syntax of the C language - * **ksh:** The Korn shell, written by David Korn and popular with Unix users - * **tcsh:** A version of csh with more ease-of-use features - * **zsh:** The Z shell, which combines many features of other popular shells - - - -All shells have built-in commands that supplement or replace the ones provided by the core utilities. Open the shell's man page and find the "BUILT-INS" section to see the commands it provides. - -Each shell has its own personality and syntax. Some will work better for you than others. I have used the C shell, the Korn shell, and the Z shell. I still like the Bash shell more than any of them. Use the one that works best for you, although that might require you to try some of the others. Fortunately, it's quite easy to change shells. - -All of these shells are programming languages, as well as command interpreters. Here's a quick tour of some programming constructs and tools that are integral parts of Bash. - -### Bash as a programming language - -Most sysadmins have used Bash to issue commands that are usually fairly simple and straightforward. But Bash can go beyond entering single commands, and many sysadmins create simple command-line programs to perform a series of tasks. These programs are common tools that can save time and effort. - -My objective when writing CLI programs is to save time and effort (i.e., to be the lazy sysadmin). CLI programs support this by listing several commands in a specific sequence that execute one after another, so you do not need to watch the progress of one command and type in the next command when the first finishes. You can go do other things and not have to continually monitor the progress of each command. - -### What is "a program"? - -The Free On-line Dictionary of Computing ([FOLDOC][6]) defines a program as: "The instructions executed by a computer, as opposed to the physical device on which they run." Princeton University's [WordNet][7] defines a program as: "…a sequence of instructions that a computer can interpret and execute…" [Wikipedia][8] also has a good entry about computer programs. - -Therefore, a program can consist of one or more instructions that perform a specific, related task. A computer program instruction is also called a program statement. For sysadmins, a program is usually a sequence of shell commands. All the shells available for Linux, at least the ones I am familiar with, have at least a basic form of programming capability, and Bash, the default shell for most Linux distributions, is no exception. - -While this series uses Bash (because it is so ubiquitous), if you use a different shell, the general programming concepts will be the same, although the constructs and syntax may differ somewhat. Some shells may support some features that others do not, but they all provide some programming capability. Shell programs can be stored in a file for repeated use, or they may be created on the command line as needed. - -### Simple CLI programs - -The simplest command-line programs are one or two consecutive program statements, which may be related or not, that are entered on the command line before the **Enter** key is pressed. The second statement in a program, if there is one, might be dependent upon the actions of the first, but it does not need to be. - -There is also one bit of syntactical punctuation that needs to be clearly stated. When entering a single command on the command line, pressing the **Enter** key terminates the command with an implicit semicolon (**;**). When used in a CLI shell program entered as a single line on the command line, the semicolon must be used to terminate each statement and separate it from the next one. The last statement in a CLI shell program can use an explicit or implicit semicolon. - -### Some basic syntax - -The following examples will clarify this syntax. This program consists of a single command with an explicit terminator: - - -``` -[student@studentvm1 ~]$ echo "Hello world." ; -Hello world. -``` - -That may not seem like much of a program, but it is the first program I encounter with every new programming language I learn. The syntax may be a bit different for each language, but the result is the same. - -Let's expand a little on this trivial but ubiquitous program. Your results will be different from mine because I have done other experiments, while you may have only the default directories and files that are created in the account home directory the first time you log into an account via the GUI desktop. - - -``` -[student@studentvm1 ~]$ echo "My home directory." ; ls ; -My home directory. -chapter25   TestFile1.Linux  dmesg2.txt  Downloads  newfile.txt  softlink1  testdir6 -chapter26   TestFile1.mac    dmesg3.txt  file005    Pictures     Templates  testdir -TestFile1      Desktop       dmesg.txt   link3      Public       testdir    Videos -TestFile1.dos  dmesg1.txt    Documents   Music      random.txt   testdir1 -``` - -That makes a bit more sense. The results are related, but the individual program statements are independent of each other. Notice that I like to put spaces before and after the semicolon because it makes the code a bit easier to read. Try that little CLI program again without an explicit semicolon at the end: - - -``` -`[student@studentvm1 ~]$ echo "My home directory." ; ls` -``` - -There is no difference in the output. - -### Something about variables - -Like all programming languages, the Bash shell can deal with variables. A variable is a symbolic name that refers to a specific location in memory that contains a value of some sort. The value of a variable is changeable, i.e., it is variable. - -Bash does not type variables like C and related languages, defining them as integers, floating points, or string types. In Bash, all variables are strings. A string that is an integer can be used in integer arithmetic, which is the only type of math that Bash is capable of doing. If more complex math is required, the [**bc** command][9] can be used in CLI programs and scripts. - -Variables are assigned values and can be used to refer to those values in CLI programs and scripts. The value of a variable is set using its name but not preceded by a **$** sign. The assignment **VAR=10** sets the value of the variable VAR to 10. To print the value of the variable, you can use the statement **echo $VAR**. Start with text (i.e., non-numeric) variables. - -Bash variables become part of the shell environment until they are unset. - -Check the initial value of a variable that has not been assigned; it should be null. Then assign a value to the variable and print it to verify its value. You can do all of this in a single CLI program: - - -``` -[student@studentvm1 ~]$ echo $MyVar ; MyVar="Hello World" ; echo $MyVar ; - -Hello World -[student@studentvm1 ~]$ -``` - -_Note: The syntax of variable assignment is very strict. There must be no spaces on either side of the equal (**=**) sign in the assignment statement._ - -The empty line indicates that the initial value of **MyVar** is null. Changing and setting the value of a variable are done the same way. This example shows both the original and the new value. - -As mentioned, Bash can perform integer arithmetic calculations, which is useful for calculating a reference to the location of an element in an array or doing simple math problems. It is not suitable for scientific computing or anything that requires decimals, such as financial calculations. There are much better tools for those types of calculations. - -Here's a simple calculation: - - -``` -[student@studentvm1 ~]$ Var1="7" ; Var2="9" ; echo "Result = $((Var1*Var2))" -Result = 63 -``` - -What happens when you perform a math operation that results in a floating-point number? - - -``` -[student@studentvm1 ~]$ Var1="7" ; Var2="9" ; echo "Result = $((Var1/Var2))" -Result = 0 -[student@studentvm1 ~]$ Var1="7" ; Var2="9" ; echo "Result = $((Var2/Var1))" -Result = 1 -[student@studentvm1 ~]$ -``` - -The result is the nearest integer. Notice that the calculation was performed as part of the **echo** statement. The math is performed before the enclosing echo command due to the Bash order of precedence. For details see the Bash man page and search "precedence." - -### Control operators - -Shell control operators are one of the syntactical operators for easily creating some interesting command-line programs. The simplest form of CLI program is just stringing several commands together in a sequence on the command line: - - -``` -`command1 ; command2 ; command3 ; command4 ; . . . ; etc. ;` -``` - -Those commands all run without a problem so long as no errors occur. But what happens when an error occurs? You can anticipate and allow for errors using the built-in **&&** and **||** Bash control operators. These two control operators provide some flow control and enable you to alter the sequence of code execution. The semicolon is also considered to be a Bash control operator, as is the newline character. - -The **&&** operator simply says, "if command1 is successful, then run command2. If command1 fails for any reason, then command2 is skipped." That syntax looks like this: - - -``` -`command1 && command2` -``` - -Now, look at some commands that will create a new directory and—if it's successful—make it the present working directory (PWD). Ensure that your home directory (**~**) is the PWD. Try this first in **/root**, a directory that you do not have access to: - - -``` -[student@studentvm1 ~]$ Dir=/root/testdir ; mkdir $Dir/ && cd $Dir -mkdir: cannot create directory '/root/testdir/': Permission denied -[student@studentvm1 ~]$ -``` - -The error was emitted by the **mkdir** command. You did not receive an error indicating that the file could not be created because the creation of the directory failed. The **&&** control operator sensed the non-zero return code, so the **touch** command was skipped. Using the **&&** control operator prevents the **touch** command from running because there was an error in creating the directory. This type of command-line program flow control can prevent errors from compounding and making a real mess of things. But it's time to get a little more complicated. - -The **||** control operator allows you to add another program statement that executes when the initial program statement returns a code greater than zero. The basic syntax looks like this: - - -``` -`command1 || command2` -``` - -This syntax reads, "If command1 fails, execute command2." That implies that if command1 succeeds, command2 is skipped. Try this by attempting to create a new directory: - - -``` -[student@studentvm1 ~]$ Dir=/root/testdir ; mkdir $Dir || echo "$Dir was not created." -mkdir: cannot create directory '/root/testdir': Permission denied -/root/testdir was not created. -[student@studentvm1 ~]$ -``` - -This is exactly what you would expect. Because the new directory could not be created, the first command failed, which resulted in the execution of the second command. - -Combining these two operators provides the best of both. The control operator syntax using some flow control takes this general form when the **&&** and **||** control operators are used: - - -``` -`preceding commands ; command1 && command2 || command3 ; following commands` -``` - -This syntax can be stated like so: "If command1 exits with a return code of 0, then execute command2, otherwise execute command3." Try it: - - -``` -[student@studentvm1 ~]$ Dir=/root/testdir ; mkdir $Dir && cd $Dir || echo "$Dir was not created." -mkdir: cannot create directory '/root/testdir': Permission denied -/root/testdir was not created. -[student@studentvm1 ~]$ -``` - -Now try the last command again using your home directory instead of the **/root** directory. You will have permission to create this directory: - - -``` -[student@studentvm1 ~]$ Dir=~/testdir ; mkdir $Dir && cd $Dir || echo "$Dir was not created." -[student@studentvm1 testdir]$ -``` - -The control operator syntax, like **command1 && command2**, works because every command sends a return code (RC) to the shell that indicates if it completed successfully or whether there was some type of failure during execution. By convention, an RC of zero (0) indicates success, and any positive number indicates some type of failure. Some of the tools sysadmins use just return a one (1) to indicate a failure, but many use other codes to indicate the type of failure that occurred. - -The Bash shell variable **$?** contains the RC from the last command. This RC can be checked very easily by a script, the next command in a list of commands, or even the sysadmin directly. Start by running a simple command and immediately checking the RC. The RC will always be for the last command that ran before you looked at it. - - -``` -[student@studentvm1 testdir]$ ll ; echo "RC = $?" -total 1264 -drwxrwxr-x  2 student student   4096 Mar  2 08:21 chapter25 -drwxrwxr-x  2 student student   4096 Mar 21 15:27 chapter26 --rwxr-xr-x  1 student student     92 Mar 20 15:53 TestFile1 -<snip> -drwxrwxr-x. 2 student student 663552 Feb 21 14:12 testdir -drwxr-xr-x. 2 student student   4096 Dec 22 13:15 Videos -RC = 0 -[student@studentvm1 testdir]$ -``` - -The RC, in this case, is zero, which means the command completed successfully. Now try the same command on root's home directory, a directory you do not have permissions for: - - -``` -[student@studentvm1 testdir]$ ll /root ; echo "RC = $?" -ls: cannot open directory '/root': Permission denied -RC = 2 -[student@studentvm1 testdir]$ -``` - -In this case, the RC is two; this means permission was denied for a non-root user to access a directory to which the user is not permitted access. The control operators use these RCs to enable you to alter the sequence of program execution. - -### Summary - -This article looked at Bash as a programming language and explored its basic syntax as well as some basic tools. It showed how to print data to STDOUT and how to use variables and control operators. The next article in this series looks at some of the many Bash logical operators that control the flow of instruction execution. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/programming-bash-part-1 - -作者:[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://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bash_command_line.png?itok=k4z94W2U (bash logo on green background) -[2]: https://opensource.com/article/18/10/linux-data-streams -[3]: http://www.both.org/?page_id=1183 -[4]: https://opensource.com/19/9/command-line-heroes-bash -[5]: https://en.wikipedia.org/wiki/Comparison_of_command_shells -[6]: http://foldoc.org/program -[7]: https://wordnet.princeton.edu/ -[8]: https://en.wikipedia.org/wiki/Computer_program -[9]: https://www.gnu.org/software/bc/manual/html_mono/bc.html diff --git a/sources/tech/20191022 Initializing arrays in Java.md b/sources/tech/20191022 Initializing arrays in Java.md deleted file mode 100644 index 7971ec104b..0000000000 --- a/sources/tech/20191022 Initializing arrays in Java.md +++ /dev/null @@ -1,389 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (laingke) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Initializing arrays in Java) -[#]: via: (https://opensource.com/article/19/10/initializing-arrays-java) -[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen) - -Initializing arrays in Java -====== -Arrays are a helpful data type for managing collections elements best -modeled in contiguous memory locations. Here's how to use them -effectively. -![Coffee beans and a cup of coffee][1] - -People who have experience programming in languages like C or FORTRAN are familiar with the concept of arrays. They’re basically a contiguous block of memory where each location is a certain type: integers, floating-point numbers, or what-have-you. - -The situation in Java is similar, but with a few extra wrinkles. - -### An example array - -Let’s make an array of 10 integers in Java: - - -``` -int[] ia = new int[10]; -``` - -What’s going on in the above piece of code? From left to right: - - 1. The **int[]** to the extreme left declares the _type_ of the variable as an array (denoted by the **[]**) of **int**. - - 2. To the right is the _name_ of the variable, which in this case is **ia**. - - 3. Next, the **=** tells us that the variable defined on the left side is set to what’s to the right side. - - 4. To the right of the **=** we see the word **new**, which in Java indicates that an object is being _initialized_, meaning that storage is allocated and its constructor is called ([see here for more information][2]). - - 5. Next, we see **int[10]**, which tells us that the specific object being initialized is an array of 10 integers. - - - - -Since Java is strongly-typed, the type of the variable **ia** must be compatible with the type of the expression on the right-hand side of the **=**. - -### Initializing the example array - -Let’s put this simple array in a piece of code and try it out. Save the following in a file called **Test1.java**, use **javac** to compile it, and use **java** to run it (in the terminal of course): - - -``` -import java.lang.*; - -public class Test1 { - -    public static void main([String][3][] args) { -        int[] ia = new int[10];                              // See note 1 below -        [System][4].out.println("ia is " + ia.getClass());        // See note 2 below -        for (int i = 0; i < ia.length; i++)                  // See note 3 below -            [System][4].out.println("ia[" + i + "] = " + ia[i]);  // See note 4 below -    } - -} -``` - -Let’s work through the most important bits. - - 1. Our declaration and initialization of the array of 10 integers, **ia**, is easy to spot. - 2. In the line just following, we see the expression **ia.getClass()**. That’s right, **ia** is an _object_ belonging to a _class_, and this code will let us know which class that is. - 3. In the next line following that, we see the start of the loop **for (int i = 0; i < ia.length; i++)**, which defines a loop index variable **i** that runs through a sequence from zero to one less than **ia.length**, which is an expression that tells us how many elements are defined in the array **ia**. - 4. Next, the body of the loop prints out the values of each element of **ia**. - - - -When this program is compiled and run, it produces the following results: - - -``` -me@mydesktop:~/Java$ javac Test1.java -me@mydesktop:~/Java$ java Test1 -ia is class [I -ia[0] = 0 -ia[1] = 0 -ia[2] = 0 -ia[3] = 0 -ia[4] = 0 -ia[5] = 0 -ia[6] = 0 -ia[7] = 0 -ia[8] = 0 -ia[9] = 0 -me@mydesktop:~/Java$ -``` - -The string representation of the output of **ia.getClass()** is **[I**, which is shorthand for "array of integer." Similar to the C programming language, Java arrays begin with element zero and extend up to element **<array size> – 1**. We can see above that each of the elements of **ia** are set to zero (by the array constructor, it seems). - -So, is that it? We declare the type, use the appropriate initializer, and we’re done? - -Well, no. There are many other ways to initialize an array in Java.  - -### Why do I want to initialize an array, anyway? - -The answer to this question, like that of all good questions, is "it depends." In this case, the answer depends on what we expect to do with the array once it is initialized. - -In some cases, arrays emerge naturally as a type of accumulator. For example, suppose we are writing code for counting the number of calls received and made by a set of telephone extensions in a small office. There are eight extensions, numbered one through eight, plus the operator’s extension, numbered zero. So we might declare two arrays: - - -``` -int[] callsMade; -int[] callsReceived; -``` - -Then, whenever we start a new period of accumulating call statistics, we initialize each array as: - - -``` -callsMade = new int[9]; -callsReceived = new int[9]; -``` - -At the end of each period of accumulating call statistics, we can print out the stats. In very rough terms, we might see: - - -``` -import java.lang.*; -import java.io.*; - -public class Test2 { - -    public static void main([String][3][] args) { - -        int[] callsMade; -        int[] callsReceived; - -        // initialize call counters - -        callsMade = new int[9]; -        callsReceived = new int[9]; - -        // process calls... -        //   an extension makes a call: callsMade[ext]++ -        //   an extension receives a call: callsReceived[ext]++ - -        // summarize call statistics - -        [System][4].out.printf("%3s%25s%25s\n","ext"," calls made", -            "calls received"); -        for (int ext = 0; ext < callsMade.length; ext++) -            [System][4].out.printf("%3d%25d%25d\n",ext, -                callsMade[ext],callsReceived[ext]); - -    } - -} -``` - -Which would produce output something like this: - - -``` -me@mydesktop:~/Java$ javac Test2.java -me@mydesktop:~/Java$ java Test2 -ext               calls made           calls received -  0                        0                        0 -  1                        0                        0 -  2                        0                        0 -  3                        0                        0 -  4                        0                        0 -  5                        0                        0 -  6                        0                        0 -  7                        0                        0 -  8                        0                        0 -me@mydesktop:~/Java$ -``` - -Not a very busy day in the call center. - -In the above example of an accumulator, we see that the starting value of zero as set by the array initializer is satisfactory for our needs. But in other cases, this starting value may not be the right choice. - -For example, in some kinds of geometric computations, we might need to initialize a two-dimensional array to the identity matrix (all zeros except for the ones along the main diagonal). We might choose to do this as: - - -``` - double[][] m = new double[3][3]; -        for (int d = 0; d < 3; d++) -            m[d][d] = 1.0; -``` - -In this case, we rely on the array initializer **new double[3][3]** to set the array to zeros, and then use a loop to set the diagonal elements to ones. In this simple case, we might use a shortcut that Java provides: - - -``` - double[][] m = { -         {1.0, 0.0, 0.0}, -         {0.0, 1.0, 0.0}, -         {0.0, 0.0, 1.0}}; -``` - -This type of visual structure is particularly appropriate in this sort of application, where it can be a useful double-check to see the actual layout of the array. But in the case where the number of rows and columns is only determined at run time, we might instead see something like this: - - -``` - int nrc; - // some code determines the number of rows & columns = nrc - double[][] m = new double[nrc][nrc]; - for (int d = 0; d < nrc; d++) -     m[d][d] = 1.0; -``` - -It’s worth mentioning that a two-dimensional array in Java is actually an array of arrays, and there’s nothing stopping the intrepid programmer from having each one of those second-level arrays be a different length. That is, something like this is completely legitimate: - - -``` -int [][] differentLengthRows = { -     { 1, 2, 3, 4, 5}, -     { 6, 7, 8, 9}, -     {10,11,12}, -     {13,14}, -     {15}}; -``` - -There are various linear algebra applications that involve irregularly-shaped matrices, where this type of structure could be applied (for more information see [this Wikipedia article][5] as a starting point). Beyond that, now that we understand that a two-dimensional array is actually an array of arrays, it shouldn’t be too much of a surprise that: - - -``` -differentLengthRows.length -``` - -tells us the number of rows in the two-dimensional array **differentLengthRows**, and: - - -``` -differentLengthRows[i].length -``` - -tells us the number of columns in row **i** of **differentLengthRows**. - -### Taking the array further - -Considering this idea of array size that is determined at run time, we see that arrays still require us to know that size before instantiating them. But what if we don’t know the size until we’ve processed all of the data? Does that mean we have to process it once to figure out the size of the array, and then process it again? That could be hard to do, especially if we only get one chance to consume the data. - -The [Java Collections Framework][6] solves this problem in a nice way. One of the things provided there is the class **ArrayList**, which is like an array but dynamically extensible. To demonstrate the workings of **ArrayList**, let’s create one and initialize it to the first 20 [Fibonacci numbers][7]: - - -``` -import java.lang.*; -import java.util.*; - -public class Test3 { -        -        public static void main([String][3][] args) { - -                ArrayList<Integer> fibos = new ArrayList<Integer>(); - -                fibos.add(0); -                fibos.add(1); -                for (int i = 2; i < 20; i++) -                        fibos.add(fibos.get(i-1) + fibos.get(i-2)); - -                for (int i = 0; i < fibos.size(); i++) -                        [System][4].out.println("fibonacci " + i + -                       " = " + fibos.get(i)); - -        } -} -``` - -Above, we see: - - * The declaration and instantiation of an **ArrayList** that is used to store **Integer**s. - * The use of **add()** to append to the **ArrayList** instance. - * The use of **get()** to retrieve an element by index number. - * The use of **size()** to determine how many elements are already in the **ArrayList** instance. - - - -Not shown is the **put()** method, which places a value at a given index number. - -The output of this program is: - - -``` -fibonacci 0 = 0 -fibonacci 1 = 1 -fibonacci 2 = 1 -fibonacci 3 = 2 -fibonacci 4 = 3 -fibonacci 5 = 5 -fibonacci 6 = 8 -fibonacci 7 = 13 -fibonacci 8 = 21 -fibonacci 9 = 34 -fibonacci 10 = 55 -fibonacci 11 = 89 -fibonacci 12 = 144 -fibonacci 13 = 233 -fibonacci 14 = 377 -fibonacci 15 = 610 -fibonacci 16 = 987 -fibonacci 17 = 1597 -fibonacci 18 = 2584 -fibonacci 19 = 4181 -``` - -**ArrayList** instances can also be initialized by other techniques. For example, an array can be supplied to the **ArrayList** constructor, or the **List.of()** and **Arrays.asList()** methods can be used when the initial elements are known at compile time. I don’t find myself using these options all that often since my primary use case for an **ArrayList** is when I only want to read the data once. - -Moreover, an **ArrayList** instance can be converted to an array using its **toArray()** method, for those who prefer to work with an array once the data is loaded; or, returning to the current topic, once the **ArrayList** instance is initialized. - -The Java Collections Framework provides another kind of array-like data structure called a **Map**. What I mean by "array-like" is that a **Map** defines a collection of objects whose values can be set or retrieved by a key, but unlike an array (or an **ArrayList**), this key need not be an integer; it could be a **String** or any other complex object. - -For example, we can create a **Map** whose keys are **String**s and whose values are **Integer**s as follows: - - -``` -Map<[String][3],Integer> stoi = new Map<[String][3],Integer>(); -``` - -Then we can initialize this **Map** as follows: - - -``` -stoi.set("one",1); -stoi.set("two",2); -stoi.set("three",3); -``` - -And so on. Later, when we want to know the numeric value of **"three"**, we can retrieve it as: - - -``` -stoi.get("three"); -``` - -In my world, a **Map** is useful for converting strings occurring in third-party datasets into coherent code values in my datasets. As a part of a [data transformation pipeline][8], I will often build a small standalone program to clean the data before processing it; for this, I will almost always use one or more **Map**s. - -Worth mentioning is that it’s quite possible, and sometimes reasonable, to have **ArrayLists** of **ArrayLists** and **Map**s of **Map**s. For example, let’s assume we’re looking at trees, and we’re interested in accumulating the count of the number of trees by tree species and age range. Assuming that the age range definition is a set of string values ("young," "mid," "mature," and "old") and that the species are string values like "Douglas fir," "western red cedar," and so forth, then we might define a **Map** of **Map**s as: - - -``` -Map<[String][3],Map<[String][3],Integer>> counter = -        new Map<[String][3],Map<[String][3],Integer>>(); -``` - -One thing to watch out for here is that the above only creates storage for the _rows_ of **Map**s. So, our accumulation code might look like: - - -``` -// assume at this point we have figured out the species -// and age range -if (!counter.containsKey(species)) -        counter.put(species,new Map<[String][3],Integer>()); -if (!counter.get(species).containsKey(ageRange)) -        counter.get(species).put(ageRange,0); -``` - -At which point, we can start accumulating as: - - -``` -counter.get(species).put(ageRange, -        counter.get(species).get(ageRange) + 1); -``` - -Finally, it’s worth mentioning that the (new in Java 8) Streams facility can also be used to initialize arrays, **ArrayList** instances, and **Map** instances. A nice discussion of this feature can be found [here][9] and [here][10]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/initializing-arrays-java - -作者:[Chris Hermansen][a] -选题:[lujun9972][b] -译者:[laingke](https://github.com/laingke) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/clhermansen -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/java-coffee-mug.jpg?itok=Bj6rQo8r (Coffee beans and a cup of coffee) -[2]: https://opensource.com/article/19/8/what-object-java -[3]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string -[4]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system -[5]: https://en.wikipedia.org/wiki/Irregular_matrix -[6]: https://en.wikipedia.org/wiki/Java_collections_framework -[7]: https://en.wikipedia.org/wiki/Fibonacci_number -[8]: https://towardsdatascience.com/data-science-for-startups-data-pipelines-786f6746a59a -[9]: https://stackoverflow.com/questions/36885371/lambda-expression-to-initialize-array -[10]: https://stackoverflow.com/questions/32868665/how-to-initialize-a-map-using-a-lambda diff --git a/sources/tech/20191023 How to dual boot Windows 10 and Debian 10.md b/sources/tech/20191023 How to dual boot Windows 10 and Debian 10.md deleted file mode 100644 index d445417c83..0000000000 --- a/sources/tech/20191023 How to dual boot Windows 10 and Debian 10.md +++ /dev/null @@ -1,263 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (wenwensnow) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to dual boot Windows 10 and Debian 10) -[#]: via: (https://www.linuxtechi.com/dual-boot-windows-10-debian-10/) -[#]: author: (James Kiarie https://www.linuxtechi.com/author/james/) - -How to dual boot Windows 10 and Debian 10 -====== - -So, you finally made the bold decision to try out **Linux** after much convincing. However, you do not want to let go of your Windows 10 operating system yet as you will still be needing it before you learn the ropes on Linux. Thankfully, you can easily have a dual boot setup that allows you to switch to either of the operating systems upon booting your system. In this guide, you will learn how to **dual boot  Windows 10 alongside Debian 10**. - -[![How-to-dual-boot-Windows-and-Debian10][1]][2] - -### Prerequisites - -Before you get started, ensure you have the following: - - * A bootable USB  or DVD of Debian 10 - * A fast and stable internet connection ( For installation updates & third party applications) - - - -Additionally, it worth paying attention to how your system boots (UEFI or Legacy) and ensure both the operating systems boot using the same boot mode. - -### Step 1: Create a free partition on your hard drive - -To start off, you need to create a free partition on your hard drive. This is the partition where Debian will be installed during the installation process. To achieve this, you will invoke the disk management utility as shown: - -Press **Windows Key + R** to launch the Run dialogue. Next, type **diskmgmt.msc** and hit **ENTER** - -[![Launch-Run-dialogue][1]][3] - -This launches the **disk management** window displaying all the drives existing on your Windows system. - -[![Disk-management][1]][4] - -Next, you need to create a free space for Debian installation. To do this, you need to shrink a partition from one of the volumes and create a new unallocated partition. In this case, I will create a **30 GB** partition from Volume D. - -To shrink a volume, right-click on it and select the ‘**shrink**’ option - -[![Shrink-volume][1]][5] - -In the pop-up dialogue, define the size that you want to shrink your space. Remember, this will be the disk space on which Debian 10 will be installed. In my case, I selected **30000MB  ( Approximately 30 GB)**. Once done, click on ‘**Shrink**’. - -[![Shrink-space][1]][6] - -After the shrinking operation completes, you should have an unallocated partition as shown: - -[![Unallocated-partition][1]][7] - -Perfect! We are now good to go and ready to begin the installation process. - -### Step 2: Begin the installation of Debian 10 - -With the free partition already created, plug in your bootable USB drive or insert the DVD installation medium in your PC and reboot your system. Be sure to make changes to the **boot order** in the **BIOS** set up by pressing the function keys (usually, **F9, F10 or F12** depending on the vendor). This is crucial so that the PC boots into your installation medium. Saves the BIOS settings and reboot. - -A new grub menu will be displayed as shown below: Click on ‘**Graphical install**’ - -[![Graphical-Install-Debian10][1]][8] - -In the next step, select your **preferred language** and click ‘**Continue**’ - -[![Select-Language-Debian10][1]][9] - -Next, select your **location** and click ‘**Continue**’. Based on this location the time will automatically be selected for you. If you cannot find you located, scroll down and click on ‘**other**’ then select your location. - -[![Select-location-Debain10][1]][10] - -Next, select your **keyboard** layout. - -[![Configure-Keyboard-layout-Debain10][1]][11] - -In the next step, specify your system’s **hostname** and click ‘**Continue**’ - -[![Set-hostname-Debian10][1]][12] - -Next, specify the **domain name**. If you are not in a domain environment, simply click on the ‘**continue**’ button. - -[![Set-domain-name-Debian10][1]][13] - -In the next step, specify the **root password** as shown and click ‘**continue**’. - -[![Set-root-Password-Debian10][1]][14] - -In the next step, specify the full name of the user for the account and click ‘**continue**’ - -[![Specify-fullname-user-debain10][1]][15] - -Then set the account name by specifying the **username** associated with the account - -[![Specify-username-Debian10][1]][16] - -Next, specify the username’s password as shown and click ‘**continue**’ - -[![Specify-user-password-Debian10][1]][17] - -Next, specify your **timezone** - -[![Configure-timezone-Debian10][1]][18] - -At this point, you need to create partitions for your Debian 10 installation. If you are an inexperienced user, Click on the ‘**Use the largest continuous free space**’ and click ‘**continue**’. - -[![Use-largest-continuous-free-space-debian10][1]][19] - -However, if you are more knowledgeable about creating partitions, select the ‘**Manual**’ option and click ‘**continue**’ - -[![Select-Manual-Debain10][1]][20] - -Thereafter, select the partition labeled ‘**FREE SPACE**’  and click ‘**continue**’ . Next click on ‘**Create a new partition**’. - -[![Create-new-partition-Debain10][1]][21] - -In the next window, first, define the size of swap space, In my case, I specified **2GB**. Click **Continue**. - -[![Define-swap-space-debian10][1]][22] - -Next, click on ‘’**Primary**’ on the next screen and click ‘**continue**’ - -[![Partition-Disks-Primary-Debain10][1]][23] - -Select the partition to **start at the beginning** and click continue. - -[![Start-at-the-beginning-Debain10][1]][24] - -Next, click on **Ext 4 journaling file system** and click ‘**continue**’ - -[![Select-Ext4-Journaling-system-debain10][1]][25] - -On the next window, select **swap  **and click continue - -[![Select-swap-debain10][1]][26] - -Next, click on **done setting the partition** and click continue. - -[![Done-setting-partition-debian10][1]][27] - -Back to the **Partition disks** page, click on **FREE SPACE** and click continue - -[![Click-Free-space-Debain10][1]][28] - -To make your life easy select **Automatically partition the free space** and click **continue**. - -[![Automatically-partition-free-space-Debain10][1]][29] - -Next click on **All files in one partition (recommended for new users)** - -[![All-files-in-one-partition-debian10][1]][30] - -Finally, click on **Finish partitioning and write changes to disk** and click **continue**. - -[![Finish-partitioning-write-changes-to-disk][1]][31] - -Confirm that you want to write changes to disk and click ‘**Yes**’ - -[![Write-changes-to-disk-Yes-Debian10][1]][32] - -Thereafter, the installer will begin installing all the requisite software packages. - -When asked if you want to scan another CD, select **No** and click continue - -[![Scan-another-CD-No-Debain10][1]][33] - -Next, select the mirror of the Debian archive closest to you and click ‘Continue’ - -[![Debian-archive-mirror-country][1]][34] - -Next, select the **Debian mirror** that is most preferable to you and click ‘**Continue**’ - -[![Select-Debian-archive-mirror][1]][35] - -If you plan on using a proxy server, enter its details as shown below, otherwise leave it blank and click ‘continue’ - -[![Enter-proxy-details-debian10][1]][36] - -As the installation proceeds, you will be asked if you would like to participate in a **package usage survey**. You can select either option and click ‘continue’ . In my case, I selected ‘**No**’ - -[![Participate-in-survey-debain10][1]][37] - -Next, select the packages you need in the **software selection** window and click **continue**. - -[![Software-selection-debian10][1]][38] - -The installation will continue installing the selected packages. At this point, you can take a coffee break as the installation goes on. - -You will be prompted whether to install the grub **bootloader** on **Master Boot Record (MBR)**. Click **Yes** and click **Continue**. - -[![Install-grub-bootloader-debian10][1]][39] - -Next, select the hard drive on which you want to install **grub** and click **Continue**. - -[![Select-hard-drive-install-grub-Debian10][1]][40] - -Finally, the installation will complete, Go ahead and click on the ‘**Continue**’ button - -[![Installation-complete-reboot-debian10][1]][41] - -You should now have a grub menu with both **Windows** and **Debian** listed. To boot to Debian, scroll and click on Debian. Thereafter, you will be prompted with a login screen. Enter your details and hit ENTER. - -[![Debian10-log-in][1]][42] - -And voila! There goes your fresh copy of Debian 10 in a dual boot setup with Windows 10. - -[![Debian10-Buster-Details][1]][43] - --------------------------------------------------------------------------------- - -via: https://www.linuxtechi.com/dual-boot-windows-10-debian-10/ - -作者:[James Kiarie][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.linuxtechi.com/author/james/ -[b]: https://github.com/lujun9972 -[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[2]: https://www.linuxtechi.com/wp-content/uploads/2019/10/How-to-dual-boot-Windows-and-Debian10.jpg -[3]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Launch-Run-dialogue.jpg -[4]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Disk-management.jpg -[5]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Shrink-volume.jpg -[6]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Shrink-space.jpg -[7]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Unallocated-partition.jpg -[8]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Graphical-Install-Debian10.jpg -[9]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Select-Language-Debian10.jpg -[10]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Select-location-Debain10.jpg -[11]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Configure-Keyboard-layout-Debain10.jpg -[12]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Set-hostname-Debian10.jpg -[13]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Set-domain-name-Debian10.jpg -[14]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Set-root-Password-Debian10.jpg -[15]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Specify-fullname-user-debain10.jpg -[16]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Specify-username-Debian10.jpg -[17]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Specify-user-password-Debian10.jpg -[18]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Configure-timezone-Debian10.jpg -[19]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Use-largest-continuous-free-space-debian10.jpg -[20]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Select-Manual-Debain10.jpg -[21]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Create-new-partition-Debain10.jpg -[22]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Define-swap-space-debian10.jpg -[23]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Partition-Disks-Primary-Debain10.jpg -[24]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Start-at-the-beginning-Debain10.jpg -[25]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Select-Ext4-Journaling-system-debain10.jpg -[26]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Select-swap-debain10.jpg -[27]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Done-setting-partition-debian10.jpg -[28]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Click-Free-space-Debain10.jpg -[29]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Automatically-partition-free-space-Debain10.jpg -[30]: https://www.linuxtechi.com/wp-content/uploads/2019/10/All-files-in-one-partition-debian10.jpg -[31]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Finish-partitioning-write-changes-to-disk.jpg -[32]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Write-changes-to-disk-Yes-Debian10.jpg -[33]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Scan-another-CD-No-Debain10.jpg -[34]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Debian-archive-mirror-country.jpg -[35]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Select-Debian-archive-mirror.jpg -[36]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Enter-proxy-details-debian10.jpg -[37]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Participate-in-survey-debain10.jpg -[38]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Software-selection-debian10.jpg -[39]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Install-grub-bootloader-debian10.jpg -[40]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Select-hard-drive-install-grub-Debian10.jpg -[41]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Installation-complete-reboot-debian10.jpg -[42]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Debian10-log-in.jpg -[43]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Debian10-Buster-Details.jpg diff --git a/sources/tech/20191024 Open Source CMS Ghost 3.0 Released with New features for Publishers.md b/sources/tech/20191024 Open Source CMS Ghost 3.0 Released with New features for Publishers.md deleted file mode 100644 index 60f5d8f421..0000000000 --- a/sources/tech/20191024 Open Source CMS Ghost 3.0 Released with New features for Publishers.md +++ /dev/null @@ -1,116 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( Morisun029) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Open Source CMS Ghost 3.0 Released with New features for Publishers) -[#]: via: (https://itsfoss.com/ghost-3-release/) -[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) - -Open Source CMS Ghost 3.0 Released with New features for Publishers -====== - -[Ghost][1] is a free and open source content management system (CMS). If you are not aware of the term, a CMS is a software that allows you to build a website that is primarily focused on creating content without knowledge of HTML and other web-related technologies. - -Ghost is in fact one of the [best open source CMS][2] out there. It’s main focus is on creating lightweight, fast loading and good looking blogs. - -It has a modern intuitive editor with built-in SEO features. You also have native desktop (Linux including) and mobile apps. If you like terminal, you can also use the CLI tools it provides. - -Let’s see what new feature Ghost 3.0 brings. - -### New Features in Ghost 3.0 - -![][3] - -I’m usually intrigued by open source CMS solutions – so after reading the official announcement post, I went ahead and gave it a try by installing a new Ghost instance via [Digital Ocean cloud server][4]. - -I was really impressed with the improvements they’ve made with the features and the UI compared to the previous version. - -Here, I shall list out the key changes/additions worth mentioning. - -#### Bookmark Cards - -![][5] - -In addition to all the subtle change to the editor, it now lets you add a beautiful bookmark card by just entering the URL. - -If you have used WordPress – you may have noticed that you need to have a plugin in order to add a card like that – so it is definitely a useful addition in Ghost 3.0. - -#### Improved WordPress Migration Plugin - -I haven’t tested this in particular but they have updated their WordPress migration plugin to let you easily clone the posts (with images) to Ghost CMS. - -Basically, with the plugin, you will be able to create an archive (with images) and import it to Ghost CMS. - -#### Responsive Image Galleries & Images - -To make the user experience better, they have also updated the image galleries (which is now responsive) to present your picture collection comfortably across all devices. - -In addition, the images in post/pages are now responsive as well. - -#### Members & Subscriptions option - -![Ghost Subscription Model][6] - -Even though the feature is still in the beta phase, it lets you add members and a subscription model for your blog if you choose to make it a premium publication to sustain your business. - -With this feature, you can make sure that your blog can only be accessed by the subscribed members or choose to make it available to the public in addition to the subscription. - -#### Stripe: Payment Integration - -It supports Stripe payment gateway by default to help you easily enable the subscription (or any type of payments) with no additional fee charged by Ghost. - -#### New App Integrations - -![][7] - -You can now integrate a variety of popular applications/services with your blog on Ghost 3.0. It could come in handy to automate a lot of things. - -#### Default Theme Improvement - -The default theme (design) that comes baked in has improved and now offers a dark mode as well. - -You can always choose to create a custom theme as well (if not pre-built themes available). - -#### Other Minor Improvements - -In addition to all the key highlights, the visual editor to create posts/pages has improved as well (with some drag and drop capabilities). - -I’m sure there’s a lot of technical changes as well – which you can check it out in their [changelog][8] if you’re interested. - -### Ghost is gradually getting good traction - -It’s not easy to make your mark in a world dominated by WordPress. But Ghost has gradually formed a dedicated community of publishers around it. - -Not only that, their managed hosting service [Ghost Pro][9] now has customers like NASA, Mozilla and DuckDuckGo. - -In last six years, Ghost has made $5 million in revenue from their Ghost Pro customers . Considering that they are a non-profit organization working on open source solution, this is indeed an achievement. - -This helps them remain independent by avoiding external funding from venture capitalists. The more customers for managed Ghost CMS hosting, the more funds goes into the development of the free and open source CMS. - -Overall, Ghost 3.0 is by far the best upgrade they’ve offered. I’m personally impressed with the features. - -If you have websites of your own, what CMS do you use? Have you ever used Ghost? How’s your experience with it? Do share your thoughts in the comment section. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/ghost-3-release/ - -作者:[Ankush Das][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/ankush/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/recommends/ghost/ -[2]: https://itsfoss.com/open-source-cms/ -[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/ghost-3.jpg?ssl=1 -[4]: https://itsfoss.com/recommends/digital-ocean/ -[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/ghost-editor-screenshot.png?ssl=1 -[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/ghost-subscription-model.jpg?resize=800%2C503&ssl=1 -[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/ghost-app-integration.jpg?ssl=1 -[8]: https://ghost.org/faq/upgrades/ -[9]: https://itsfoss.com/recommends/ghost-pro/ diff --git a/sources/tech/20191025 How I used the wget Linux command to recover lost images.md b/sources/tech/20191025 How I used the wget Linux command to recover lost images.md deleted file mode 100644 index 08dd80f053..0000000000 --- a/sources/tech/20191025 How I used the wget Linux command to recover lost images.md +++ /dev/null @@ -1,132 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How I used the wget Linux command to recover lost images) -[#]: via: (https://opensource.com/article/19/10/how-community-saved-artwork-creative-commons) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) - -How I used the wget Linux command to recover lost images -====== -The story of the rise and fall of the Open Clip Art Library and the -birth of FreeSVG.org, a new library of communal artwork. -![White shoes on top of an orange tribal pattern][1] - -In 2004, the Open Clip Art Library (OCAL) was launched as a source of free illustrations for anyone to use, for any purpose, without requiring attribution or anything in return. This site was the open source world’s answer to the big stacks of clip art CDs on the shelf of every home office in the 1990s, and to the art dumps provided by the closed-source office and artistic software titles. - -In the beginning, the clip art library consisted mostly of work by a few contributors, but in 2010 it went live with a brand new interactive website, allowing anyone to create and contribute clip art with a vector illustration application. The site immediately garnered contributions from around the globe, and from all manner of free software and free culture projects. A special importer for this library was even included in [Inkscape][2]. - -However, in early 2019, the website hosting the Open Clip Art Library went offline with no warning or explanation. Its community, which had grown to number in the thousands, assumed at first that this was a temporary glitch. The site remained offline, however, for over six months without any clear explanation of what had happened. - -Rumors started to swell. The site was being updated ("There is years of technical debt to pay off," said site developer Jon Philips in an email). The site had fallen to rampant DDOS attacks, claimed a Twitter account. The maintainer had fallen prey to identity theft, another Twitter account claimed. Today, as of this writing, the site’s one and only remaining page declares that it is in "maintenance and protected mode," the meaning of which is unclear, except that users cannot access its content. - -### Recovering the commons - -Sites appear and disappear over the course of time, but the loss of the Open Clip Art Library was particularly surprising to its community because it was seen as a community project. Few community members understood that the site hosting the library had fallen into the hands of a single maintainer, so while the artwork in the library was owned by everyone due to its [Creative Commons 0 License][3], access to it was functionally owned by a single maintainer. And, because the site’s community kept in touch with one another through the site, that same maintainer effectively owned the community. - -When the site failed, the community lost access to its artwork as well as each other. And without the site, there was no community. - -Initially, everything on the site was blocked when it went down. After several months, though, users started recognizing that the site’s database was still online, which meant that a user could access an individual art file by entering its exact URL. In other words, you couldn’t navigate to the art file through clicking around a website, but if you already knew the address, then you could bring it up in your browser. Similarly, technical (or lazy) users realized it was also possible to "scrape" the site with an automated web browser like **wget**. - -The **wget** Linux command is _technically_ a web browser, although it doesn’t let you browse interactively the way you do with Firefox. Instead, **wget** goes out onto the internet and retrieves a file or a collection of files and downloads them to your hard drive. You can then open those files in Firefox or a text editor, or whatever application is most appropriate, and view the content. - -Usually, **wget** needs to know a specific file to fetch. If you’re on Linux or macOS with **wget** installed, you can try this process by downloading the index page for [example.com][4]: - - -``` -$ wget example.org/index.html -[...] -$ tail index.html - -<body><div> -    <h1>Example Domain</h1> -    <p>This domain is for illustrative examples in documents. -    You may use this domain in examples without permission.</p> -        <p><a href="[http://www.iana.org/domains/example"\>More][5] info</a></p> -</div></body></html> -``` - -To scrape the Open Clip Art Library, I used the **\--mirror** option, so that I could point **wget** to just the directory containing the artwork so it could download everything within that directory. This action resulted in four straight days (96 hours) of constant downloading, ending with an excess of 100,000 SVG files that had been contributed by over 5,000 community members. Unfortunately, the author of any file that did not have proper metadata was irrecoverable because this information was locked in inaccessible files in the database, but the CC0 license meant that this issue _technically_ didn’t matter (because no attribution is required with CC0 files). - -A casual analysis of the downloaded files also revealed that nearly 45,000 of them were copies of the same single file (the site’s logo). This was caused by redirects pointing to the site's logo (for reasons unknown), and careful parsing could extract the original destination. Another 96 hours, and all clip art posted on OCAL up to its last day was recovered: **a total of about 156,000 images.** - -SVG files tend to be small, but this is still an enormous amount of work that poses a few very real problems. First of all, several gigabytes of online storage would be needed so the artwork could be made available to its former community. Secondly, a means of searching the artwork would be necessary, because it’s just not realistic to browse through 55,000 files manually. - -It became apparent that what the community really needed was a platform. - -### Building a new platform - -For some time, the site [Public Domain Vectors][6] had been publishing vector art that was in the public domain. While it remains a popular site, open source users often used it only as a secondary source of art because most of the files there were in the EPS and AI formats, both of which are associated with Adobe. Both file formats can generally be converted to SVG but at a loss of features. - -When the Public Domain Vectors site’s maintainers (Vedran and Boris) heard about the loss of the Open Clip Art Library, they decided to create a site oriented toward the open source community. True to form, they chose the open source [Laravel][7] framework as the backend, which provided the site with an admin dashboard and user access. The framework, being robust and well-developed, also allowed them to respond quickly to bug reports and feature requests, and to upgrade the site as needed. The site they are building is called [FreeSVG.org][8], and is already a robust and thriving library of communal artwork. - -Since then they have been uploading all of the clip art from the Open Clip Art Library, and they're even diligently tagging and categorizing the art as they go. As creators of Public Domain Vectors, they are also contributing their own images in SVG format. Their aim is to become the primary resource for SVG images with a CC0 license on the internet. - -### Contributing - -The maintainers of [FreeSVG.org][8] are aware that they have inherited significant stewardship. They are working to title and describe all images on the site so that users can easily find artwork, and will provide this file to the community once it is ready, believing strongly that the metadata about the art belongs to the people that create and use the art as much as the art itself does. They're also aware that unforeseen circumstances can arise, so they create regular backups of their site and content, and intend to make the most recent backup available to the public, should their site fail. - -If you want to add to the Creative Commons content of [FreeSVG.org][9], then download [Inkscape][10] and start drawing. There’s plenty of public domain artwork out there in the world, like [historical advertisements][11], [tarot cards][12], and [storybooks][13] just waiting to be converted to SVG, so you can contribute even if you aren’t confident in your drawing skills. Visit the [FreeSVG forum][14] to connect with and support other contributors. - -The concept of the _commons_ is important. [Creative Commons benefits everyone][15], whether you’re a student, teacher, librarian, small business owner, or CEO. If you don’t contribute directly, then you can always help promote it. - -That’s a strength of free culture: It doesn’t just scale, it gets better when more people participate. - -### Hard lessons learned - -From the demise of the Open Clip Art Library to the rise of FreeSVG.org, the open culture community has learned several hard lessons. For posterity, here are the ones that I believe are most important. - -#### Maintain your metadata - -If you’re a content creator, help the archivists of the future and add metadata to your files. Most image, music, font, and video file formats can have EXIF data embedded into them, and others have metadata entry interfaces in the applications that create them. Be diligent in tagging your work with your name, website or public email, and license. - -#### Make copies - -Don’t assume that somebody else is doing backups. If you care about communal digital content, then back it up yourself, or else don’t count on having it available forever. The trope that _whatever’s uploaded to the internet is forever_ may be true, but that doesn’t mean it’s _available to you_ forever. If the Open Clip Art Library files hadn’t become secretly available again, it’s unlikely that anyone would have ever successfully uncovered all 55,000 images from random places on the web, or from personal stashes on people’s hard drives around the globe. - -#### Create external channels - -If a community is defined by a single website or physical location, then that community is as good as dissolved should it lose access to that space. If you’re a member of a community that’s driven by a single organization or site, you owe it to yourselves to share contact information with those you care about and to establish a channel for communication even when that site is not available. - -For example, [Opensource.com][16] itself maintains mailing lists and other off-site channels for its authors and correspondents to communicate with one another, with or without the intervention or even existence of the website. - -#### Free culture is worth working for - -The internet is sometimes seen as a lazy person’s social club. You can log on when you want and turn it off when you’re tired, and you can wander into whatever social circle you want. - -But in reality, free culture can be hard work. It’s not hard in the sense that it’s difficult to be a part of, but it’s something you have to work to maintain. If you ignore the community you’re in, then the community may wither and fade before you realize it. - -Take a moment to look around you and identify what communities you’re a part of, and if nothing else, tell someone that you appreciate what they bring to your life. And just as importantly, keep in mind that you’re contributing to the lives of your communities, too. - -Creative Commons held its Gl obal Summit a few weeks ago in Warsaw, with amazing international... - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/how-community-saved-artwork-creative-commons - -作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/seth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tribal_pattern_shoes.png?itok=e5dSf2hS (White shoes on top of an orange tribal pattern) -[2]: https://opensource.com/article/18/1/inkscape-absolute-beginners -[3]: https://creativecommons.org/share-your-work/public-domain/cc0/ -[4]: http://example.com -[5]: http://www.iana.org/domains/example"\>More -[6]: http://publicdomainvectors.org -[7]: https://github.com/viralsolani/laravel-adminpanel -[8]: https://freesvg.org -[9]: http://freesvg.org -[10]: http://inkscape.org -[11]: https://freesvg.org/drinking-coffee-vector-drawing -[12]: https://freesvg.org/king-of-swords-tarot-card -[13]: https://freesvg.org/space-pioneers-135-scene-vector-image -[14]: http://forum.freesvg.org/ -[15]: https://opensource.com/article/18/1/creative-commons-real-world -[16]: http://Opensource.com diff --git a/sources/tech/20191025 Understanding system calls on Linux with strace.md b/sources/tech/20191025 Understanding system calls on Linux with strace.md deleted file mode 100644 index 7628cfa545..0000000000 --- a/sources/tech/20191025 Understanding system calls on Linux with strace.md +++ /dev/null @@ -1,452 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Understanding system calls on Linux with strace) -[#]: via: (https://opensource.com/article/19/10/strace) -[#]: author: (Gaurav Kamathe https://opensource.com/users/gkamathe) - -Understanding system calls on Linux with strace -====== -Trace the thin layer between user processes and the Linux kernel with -strace. -![Hand putting a Linux file folder into a drawer][1] - -A system call is a programmatic way a program requests a service from the kernel, and **strace** is a powerful tool that allows you to trace the thin layer between user processes and the Linux kernel. - -To understand how an operating system works, you first need to understand how system calls work. One of the main functions of an operating system is to provide abstractions to user programs. - -An operating system can roughly be divided into two modes: - - * **Kernel mode:** A privileged and powerful mode used by the operating system kernel - * **User mode:** Where most user applications run - - - -Users mostly work with command-line utilities and graphical user interfaces (GUI) to do day-to-day tasks. System calls work silently in the background, interfacing with the kernel to get work done. - -System calls are very similar to function calls, which means they accept and work on arguments and return values. The only difference is that system calls enter a kernel, while function calls do not. Switching from user space to kernel space is done using a special [trap][2] mechanism. - -Most of this is hidden away from the user by using system libraries (aka **glibc** on Linux systems). Even though system calls are generic in nature, the mechanics of issuing a system call are very much machine-dependent. - -This article explores some practical examples by using some general commands and analyzing the system calls made by each command using **strace**. These examples use Red Hat Enterprise Linux, but the commands should work the same on other Linux distros: - - -``` -[root@sandbox ~]# cat /etc/redhat-release -Red Hat Enterprise Linux Server release 7.7 (Maipo) -[root@sandbox ~]# -[root@sandbox ~]# uname -r -3.10.0-1062.el7.x86_64 -[root@sandbox ~]# -``` - -First, ensure that the required tools are installed on your system. You can verify whether **strace** is installed using the RPM command below; if it is, you can check the **strace** utility version number using the **-V** option: - - -``` -[root@sandbox ~]# rpm -qa | grep -i strace -strace-4.12-9.el7.x86_64 -[root@sandbox ~]# -[root@sandbox ~]# strace -V -strace -- version 4.12 -[root@sandbox ~]# -``` - -If that doesn't work, install **strace** by running: - - -``` -`yum install strace` -``` - -For the purpose of this example, create a test directory within **/tmp** and create two files using the **touch** command using: - - -``` -[root@sandbox ~]# cd /tmp/ -[root@sandbox tmp]# -[root@sandbox tmp]# mkdir testdir -[root@sandbox tmp]# -[root@sandbox tmp]# touch testdir/file1 -[root@sandbox tmp]# touch testdir/file2 -[root@sandbox tmp]# -``` - -(I used the **/tmp** directory because everybody has access to it, but you can choose another directory if you prefer.) - -Verify that the files were created using the **ls** command on the **testdir** directory: - - -``` -[root@sandbox tmp]# ls testdir/ -file1  file2 -[root@sandbox tmp]# -``` - -You probably use the **ls** command every day without realizing system calls are at work underneath it. There is abstraction at play here; here's how this command works: - - -``` -`Command-line utility -> Invokes functions from system libraries (glibc) -> Invokes system calls` -``` - -The **ls** command internally calls functions from system libraries (aka **glibc**) on Linux. These libraries invoke the system calls that do most of the work. - -If you want to know which functions were called from the **glibc** library, use the **ltrace** command followed by the regular **ls testdir/** command: - - -``` -`ltrace ls testdir/` -``` - -If **ltrace** is not installed, install it by entering: - - -``` -`yum install ltrace` -``` - -A bunch of output will be dumped to the screen; don't worry about it—just follow along. Some of the important library functions from the output of the **ltrace** command that are relevant to this example include: - - -``` -opendir("testdir/")                                  = { 3 } -readdir({ 3 })                                       = { 101879119, "." } -readdir({ 3 })                                       = { 134, ".." } -readdir({ 3 })                                       = { 101879120, "file1" } -strlen("file1")                                      = 5 -memcpy(0x1665be0, "file1\0", 6)                      = 0x1665be0 -readdir({ 3 })                                       = { 101879122, "file2" } -strlen("file2")                                      = 5 -memcpy(0x166dcb0, "file2\0", 6)                      = 0x166dcb0 -readdir({ 3 })                                       = nil -closedir({ 3 })                       -``` - -By looking at the output above, you probably can understand what is happening. A directory called **testdir** is being opened by the **opendir** library function, followed by calls to the **readdir** function, which is reading the contents of the directory. At the end, there is a call to the **closedir** function, which closes the directory that was opened earlier. Ignore the other **strlen** and **memcpy** functions for now. - -You can see which library functions are being called, but this article will focus on system calls that are invoked by the system library functions. - -Similar to the above, to understand what system calls are invoked, just put **strace** before the **ls testdir** command, as shown below. Once again, a bunch of gibberish will be dumped to your screen, which you can follow along with here: - - -``` -[root@sandbox tmp]# strace ls testdir/ -execve("/usr/bin/ls", ["ls", "testdir/"], [/* 40 vars */]) = 0 -brk(NULL)                               = 0x1f12000 -<<< truncated strace output >>> -write(1, "file1  file2\n", 13file1  file2 -)          = 13 -close(1)                                = 0 -munmap(0x7fd002c8d000, 4096)            = 0 -close(2)                                = 0 -exit_group(0)                           = ? -+++ exited with 0 +++ -[root@sandbox tmp]# -``` - -The output on the screen after running the **strace** command was simply system calls made to run the **ls** command. Each system call serves a specific purpose for the operating system, and they can be broadly categorized into the following sections: - - * Process management system calls - * File management system calls - * Directory and filesystem management system calls - * Other system calls - - - -An easier way to analyze the information dumped onto your screen is to log the output to a file using **strace**'s handy **-o** flag. Add a suitable file name after the **-o** flag and run the command again: - - -``` -[root@sandbox tmp]# strace -o trace.log ls testdir/ -file1  file2 -[root@sandbox tmp]# -``` - -This time, no output dumped to the screen—the **ls** command worked as expected by showing the file names and logging all the output to the file **trace.log**. The file has almost 100 lines of content just for a simple **ls** command: - - -``` -[root@sandbox tmp]# ls -l trace.log --rw-r--r--. 1 root root 7809 Oct 12 13:52 trace.log -[root@sandbox tmp]# -[root@sandbox tmp]# wc -l trace.log -114 trace.log -[root@sandbox tmp]# -``` - -Take a look at the first line in the example's trace.log: - - -``` -`execve("/usr/bin/ls", ["ls", "testdir/"], [/* 40 vars */]) = 0` -``` - - * The first word of the line, **execve**, is the name of a system call being executed. - * The text within the parentheses is the arguments provided to the system call. - * The number after the **=** sign (which is **0** in this case) is a value returned by the **execve** system call. - - - -The output doesn't seem too intimidating now, does it? And you can apply the same logic to understand other lines. - -Now, narrow your focus to the single command that you invoked, i.e., **ls testdir**. You know the directory name used by the command **ls**, so why not **grep** for **testdir** within your **trace.log** file and see what you get? Look at each line of the results in detail: - - -``` -[root@sandbox tmp]# grep testdir trace.log -execve("/usr/bin/ls", ["ls", "testdir/"], [/* 40 vars */]) = 0 -stat("testdir/", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0 -openat(AT_FDCWD, "testdir/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 -[root@sandbox tmp]# -``` - -Thinking back to the analysis of **execve** above, can you tell what this system call does? - - -``` -`execve("/usr/bin/ls", ["ls", "testdir/"], [/* 40 vars */]) = 0` -``` - -You don't need to memorize all the system calls or what they do, because you can refer to documentation when you need to. Man pages to the rescue! Ensure the following package is installed before running the **man** command: - - -``` -[root@sandbox tmp]# rpm -qa | grep -i man-pages -man-pages-3.53-5.el7.noarch -[root@sandbox tmp]# -``` - -Remember that you need to add a **2** between the **man** command and the system call name. If you read **man**'s man page using **man man**, you can see that section 2 is reserved for system calls. Similarly, if you need information on library functions, you need to add a **3** between **man** and the library function name. - -The following are the manual's section numbers and the types of pages they contain: - - -``` -1\. Executable programs or shell commands -2\. System calls (functions provided by the kernel) -3\. Library calls (functions within program libraries) -4\. Special files (usually found in /dev) -``` - -Run the following **man** command with the system call name to see the documentation for that system call: - - -``` -`man 2 execve` -``` - -As per the **execve** man page, this executes a program that is passed in the arguments (in this case, that is **ls**). There are additional arguments that can be provided to **ls**, such as **testdir** in this example. Therefore, this system call just runs **ls** with **testdir** as the argument: - - -``` -'execve - execute program' - -'DESCRIPTION -       execve()  executes  the  program  pointed to by filename' -``` - -The next system call, named **stat**, uses the **testdir** argument: - - -``` -`stat("testdir/", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0` -``` - -Use **man 2 stat** to access the documentation. **stat** is the system call that gets a file's status—remember that everything in Linux is a file, including a directory. - -Next, the **openat** system call opens **testdir.** Keep an eye on the **3** that is returned. This is a file description, which will be used by later system calls: - - -``` -`openat(AT_FDCWD, "testdir/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3` -``` - -So far, so good. Now, open the **trace.log** file and go to the line following the **openat** system call. You will see the **getdents** system call being invoked, which does most of what is required to execute the **ls testdir** command. Now, **grep getdents** from the **trace.log** file: - - -``` -[root@sandbox tmp]# grep getdents trace.log -getdents(3, /* 4 entries */, 32768)     = 112 -getdents(3, /* 0 entries */, 32768)     = 0 -[root@sandbox tmp]# -``` - -The **getdents** man page describes it as **get directory entries**, which is what you want to do. Notice that the argument for **getdents** is **3**, which is the file descriptor from the **openat** system call above. - -Now that you have the directory listing, you need a way to display it in your terminal. So, **grep** for another system call, **write**, which is used to write to the terminal, in the logs: - - -``` -[root@sandbox tmp]# grep write trace.log -write(1, "file1  file2\n", 13)          = 13 -[root@sandbox tmp]# -``` - -In these arguments, you can see the file names that will be displayed: **file1** and **file2**. Regarding the first argument (**1**), remember in Linux that, when any process is run, three file descriptors are opened for it by default. Following are the default file descriptors: - - * 0 - Standard input - * 1 - Standard out - * 2 - Standard error - - - -So, the **write** system call is displaying **file1** and **file2** on the standard display, which is the terminal, identified by **1**. - -Now you know which system calls did most of the work for the **ls testdir/** command. But what about the other 100+ system calls in the **trace.log** file? The operating system has to do a lot of housekeeping to run a process, so a lot of what you see in the log file is process initialization and cleanup. Read the entire **trace.log** file and try to understand what is happening to make the **ls** command work. - -Now that you know how to analyze system calls for a given command, you can use this knowledge for other commands to understand what system calls are being executed. **strace** provides a lot of useful command-line flags to make it easier for you, and some of them are described below. - -By default, **strace** does not include all system call information. However, it has a handy **-v verbose** option that can provide additional information on each system call: - - -``` -`strace -v ls testdir` -``` - -It is good practice to always use the **-f** option when running the **strace** command. It allows **strace** to trace any child processes created by the process currently being traced: - - -``` -`strace -f ls testdir` -``` - -Say you just want the names of system calls, the number of times they ran, and the percentage of time spent in each system call. You can use the **-c** flag to get those statistics: - - -``` -`strace -c ls testdir/` -``` - -Suppose you want to concentrate on a specific system call, such as focusing on **open** system calls and ignoring the rest. You can use the **-e** flag followed by the system call name: - - -``` -[root@sandbox tmp]# strace -e open ls testdir -open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 -open("/lib64/libselinux.so.1", O_RDONLY|O_CLOEXEC) = 3 -open("/lib64/libcap.so.2", O_RDONLY|O_CLOEXEC) = 3 -open("/lib64/libacl.so.1", O_RDONLY|O_CLOEXEC) = 3 -open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 -open("/lib64/libpcre.so.1", O_RDONLY|O_CLOEXEC) = 3 -open("/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3 -open("/lib64/libattr.so.1", O_RDONLY|O_CLOEXEC) = 3 -open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3 -open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3 -file1  file2 -+++ exited with 0 +++ -[root@sandbox tmp]# -``` - -What if you want to concentrate on more than one system call? No worries, you can use the same **-e** command-line flag with a comma between the two system calls. For example, to see the **write** and **getdents** systems calls: - - -``` -[root@sandbox tmp]# strace -e write,getdents ls testdir -getdents(3, /* 4 entries */, 32768)     = 112 -getdents(3, /* 0 entries */, 32768)     = 0 -write(1, "file1  file2\n", 13file1  file2 -)          = 13 -+++ exited with 0 +++ -[root@sandbox tmp]# -``` - -The examples so far have traced explicitly run commands. But what about commands that have already been run and are in execution? What, for example, if you want to trace daemons that are just long-running processes? For this, **strace** provides a special **-p** flag to which you can provide a process ID. - -Instead of running a **strace** on a daemon, take the example of a **cat** command, which usually displays the contents of a file if you give a file name as an argument. If no argument is given, the **cat** command simply waits at a terminal for the user to enter text. Once text is entered, it repeats the given text until a user presses Ctrl+C to exit. - -Run the **cat** command from one terminal; it will show you a prompt and simply wait there (remember **cat** is still running and has not exited): - - -``` -`[root@sandbox tmp]# cat` -``` - -From another terminal, find the process identifier (PID) using the **ps** command: - - -``` -[root@sandbox ~]# ps -ef | grep cat -root      22443  20164  0 14:19 pts/0    00:00:00 cat -root      22482  20300  0 14:20 pts/1    00:00:00 grep --color=auto cat -[root@sandbox ~]# -``` - -Now, run **strace** on the running process with the **-p** flag and the PID (which you found above using **ps**). After running **strace**, the output states what the process was attached to along with the PID number. Now, **strace** is tracing the system calls made by the **cat** command. The first system call you see is **read**, which is waiting for input from 0, or standard input, which is the terminal where the **cat** command ran: - - -``` -[root@sandbox ~]# strace -p 22443 -strace: Process 22443 attached -read(0, -``` - -Now, move back to the terminal where you left the **cat** command running and enter some text. I entered **x0x0** for demo purposes. Notice how **cat** simply repeated what I entered; hence, **x0x0** appears twice. I input the first one, and the second one was the output repeated by the **cat** command: - - -``` -[root@sandbox tmp]# cat -x0x0 -x0x0 -``` - -Move back to the terminal where **strace** was attached to the **cat** process. You now see two additional system calls: the earlier **read** system call, which now reads **x0x0** in the terminal, and another for **write**, which wrote **x0x0** back to the terminal, and again a new **read**, which is waiting to read from the terminal. Note that Standard input (**0**) and Standard out (**1**) are both in the same terminal: - - -``` -[root@sandbox ~]# strace -p 22443 -strace: Process 22443 attached -read(0, "x0x0\n", 65536)                = 5 -write(1, "x0x0\n", 5)                   = 5 -read(0, -``` - -Imagine how helpful this is when running **strace** against daemons to see everything it does in the background. Kill the **cat** command by pressing Ctrl+C; this also kills your **strace** session since the process is no longer running. - -If you want to see a timestamp against all your system calls, simply use the **-t** option with **strace**: - - -``` -[root@sandbox ~]#strace -t ls testdir/ - -14:24:47 execve("/usr/bin/ls", ["ls", "testdir/"], [/* 40 vars */]) = 0 -14:24:47 brk(NULL)                      = 0x1f07000 -14:24:47 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2530bc8000 -14:24:47 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) -14:24:47 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 -``` - -What if you want to know the time spent between system calls? **strace** has a handy **-r** command that shows the time spent executing each system call. Pretty useful, isn't it? - - -``` -[root@sandbox ~]#strace -r ls testdir/ - -0.000000 execve("/usr/bin/ls", ["ls", "testdir/"], [/* 40 vars */]) = 0 -0.000368 brk(NULL)                 = 0x1966000 -0.000073 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb6b1155000 -0.000047 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) -0.000119 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 -``` - -### Conclusion - -The **strace** utility is very handy for understanding system calls on Linux. To learn about its other command-line flags, please refer to the man pages and online documentation. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/strace - -作者:[Gaurav Kamathe][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/gkamathe -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/yearbook-haff-rx-linux-file-lead_0.png?itok=-i0NNfDC (Hand putting a Linux file folder into a drawer) -[2]: https://en.wikipedia.org/wiki/Trap_(computing) diff --git a/sources/tech/20191027 How to Install and Configure Nagios Core on CentOS 8 - RHEL 8.md b/sources/tech/20191027 How to Install and Configure Nagios Core on CentOS 8 - RHEL 8.md deleted file mode 100644 index bcbf0c27ec..0000000000 --- a/sources/tech/20191027 How to Install and Configure Nagios Core on CentOS 8 - RHEL 8.md +++ /dev/null @@ -1,271 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to Install and Configure Nagios Core on CentOS 8 / RHEL 8) -[#]: via: (https://www.linuxtechi.com/install-nagios-core-rhel-8-centos-8/) -[#]: author: (James Kiarie https://www.linuxtechi.com/author/james/) - -How to Install and Configure Nagios Core on CentOS 8 / RHEL 8 -====== - -**Nagios** is a free and opensource network and alerting engine used to monitor various devices, such as network devices, and servers in a network. It supports both **Linux** and **Windows OS** and provides an intuitive web interface that allows you to easily monitor network resources. When professionally configured, it can alert you in the event a server or a network device goes down or malfunctions via email alerts. In this topic, we shed light on how you can install and configure Nagios core on **RHEL 8** / **CentOS 8**. - -[![Install-Nagios-Core-RHEL8-CentOS8][1]][2] - -### Prerequisites of Nagios Core - -Before we begin, perform a flight check and ensure you have the following: - - * An instance of RHEL 8 / CentOS 8 - * SSH access to the instance - * A fast and stable internet connection - - - -With the above requirements in check, let’s roll our sleeves! - -### Step 1: Install LAMP Stack - -For Nagios to work as expected, you need to install LAMP stack or any other web hosting stack since it’s going to run on a browser. To achieve this, execute the command: - -``` -# dnf install httpd mariadb-server php-mysqlnd php-fpm -``` - -![Install-LAMP-stack-CentOS8][1] - -You need to ensure that Apache web server is up and running. To do so, start and enable Apache server using the commands: - -``` -# systemctl start httpd -# systemctl enable httpd -``` - -![Start-enable-httpd-centos8][1] - -To check the status of Apache server run - -``` -# systemctl status httpd -``` - -![Check-status-httpd-centos8][1] - -Next, we need to start and enable MariaDB server, run the following commands - -``` -# systemctl start mariadb -# systemctl enable mariadb -``` - -![Start-enable-MariaDB-CentOS8][1] - -To check MariaDB status run: - -``` -# systemctl status mariadb -``` - -![Check-MariaDB-status-CentOS8][1] - -Also, you might consider hardening or securing your server and making it less susceptible to unauthorized access. To secure your server, run the command: - -``` -# mysql_secure_installation -``` - -Be sure to set a strong password for your MySQL instance. For the subsequent prompts, Type **Yes** and hit **ENTER** - -![Secure-MySQL-server-CentOS8][1] - -### Step 2: Install Required packages - -Apart from installing the LAMP server, some additional packages are needed for the installation and proper configuration of Nagios. Therefore, install the packages as shown below: - -``` -# dnf install gcc glibc glibc-common wget gd gd-devel perl postfix -``` - -![Install-requisite-packages-CentOS8][1] - -### Step 3: Create a Nagios user account - -Next, we need to create a user account for the Nagios user. To achieve this , run the command: - -``` -# adduser nagios -# passwd nagios -``` - -![Create-new-user-for-Nagios][1] - -Now, we need to create a group for Nagios and add the Nagios user to this group. - -``` -# groupadd nagiosxi -``` - -Now add the Nagios user to the group - -``` -# usermod -aG nagiosxi nagios -``` - -Also, add Apache user to the Nagios group - -``` -# usermod -aG nagiosxi apache -``` - -![Add-Nagios-group-user][1] - -### Step 4: Download and install Nagios core - -We can now proceed and install Nagios Core. The latest stable version in Nagios 4.4.5 which was released on August 19, 2019.  But first, download the Nagios tarball file from its official site. - -To download Nagios core, first head to the tmp directory - -``` -# cd /tmp -``` - -Next download the tarball file - -``` -# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz -``` - -![Download-Nagios-CentOS8][1] - -After downloading the tarball file, extract it using the command: - -``` -# tar -xvf nagios-4.4.5.tar.gz -``` - -Next, navigate to the uncompressed folder - -``` -# cd nagios-4.4.5 -``` - -Run the commands below in this order - -``` -# ./configure --with-command-group=nagcmd -# make all -# make install -# make install-init -# make install-daemoninit -# make install-config -# make install-commandmode -# make install-exfoliation -``` - -To setup Apache configuration issue the command: - -``` -# make install-webconf -``` - -### Step 5: Configure Apache Web Server Authentication - -Next, we are going to setup authentication for the user **nagiosadmin**. Please be mindful not to change the username or else, you may be required to perform further configuration which may be quite tedious. - -To set up authentication run the command: - -``` -# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin -``` - -![Configure-Apache-webserver-authentication-CentOS8][1] - -You will be prompted for the password of the nagiosadmin user. Enter and confirm the password as requested. This is the user that you will use to login to Nagios towards the end of this tutorial. - -For the changes to come into effect, restart your web server. - -``` -# systemctl restart httpd -``` - -### Step 6: Download & install Nagios Plugins - -Plugins will extend the functionality of the Nagios Server. They will help you monitor various services, network devices, and applications. To download the plugin tarball file run the command: - -``` -# wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz -``` - -Next, extract the tarball file and navigate to the uncompressed plugin folder - -``` -# tar -xvf nagios-plugins-2.2.1.tar.gz -# cd nagios-plugins-2.2.1 -``` - -To install the plugins compile the source code as shown - -``` -# ./configure --with-nagios-user=nagios --with-nagios-group=nagiosxi -# make -# make install -``` - -### Step 7: Verify and Start Nagios - -After the successful installation of Nagios plugins, verify the Nagios configuration to ensure that all is well and there is no error in the configuration: - -``` -# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg -``` - -![Verify-Nagios-settings-CentOS8][1] - -Next, start Nagios and verify its status - -``` -# systemctl start nagios -# systemctl status nagios -``` - -![Start-check-status-Nagios-CentOS8][1] - -In case Firewall is running on system then allow “80” using the following command - -``` -# firewall-cmd --permanent --add-port=80/tcp# firewall-cmd --reload -``` - -### Step 8: Access Nagios dashboard via the web browser - -To access Nagios, browse your server’s IP address as shown - - - -A pop-up will appear prompting for the username and the password of the user we created earlier in Step 5. Enter the credentials and hit ‘**Sign In**’ - -![Access-Nagios-via-web-browser-CentOS8][1] - -This ushers you to the Nagios dashboard as shown below - -![Nagios-dashboard-CentOS8][1] - -We have finally successfully installed and configured Nagios Core on CentOS 8 / RHEL 8. Your feedback is most welcome. - --------------------------------------------------------------------------------- - -via: https://www.linuxtechi.com/install-nagios-core-rhel-8-centos-8/ - -作者:[James Kiarie][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.linuxtechi.com/author/james/ -[b]: https://github.com/lujun9972 -[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[2]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Install-Nagios-Core-RHEL8-CentOS8.jpg diff --git a/sources/tech/20191028 SQLite is really easy to compile.md b/sources/tech/20191028 SQLite is really easy to compile.md deleted file mode 100644 index 3201612f3d..0000000000 --- a/sources/tech/20191028 SQLite is really easy to compile.md +++ /dev/null @@ -1,116 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (SQLite is really easy to compile) -[#]: via: (https://jvns.ca/blog/2019/10/28/sqlite-is-really-easy-to-compile/) -[#]: author: (Julia Evans https://jvns.ca/) - -SQLite is really easy to compile -====== - -In the last week I’ve been working on another SQL website (, a list of SQL examples). I’m running all the queries on that site with sqlite, and I wanted to use window functions in one of the examples ([this one][1]). - -But I’m using the version of sqlite from Ubuntu 18.04, and that version is too old and doesn’t support window functions. So I needed to upgrade sqlite! - -This turned to out be surprisingly annoying (as usual), but in a pretty interesting way! I was reminded of some things about how executables and shared libraries work and it had a very satisfying conclusion. So I wanted to write it up here. - -(spoiler: the summary is that explains how to compile SQLite and it takes like 5 seconds to do and it’s 20x easier than my usual experiences compiling software from source) - -### attempt 1: download a SQLite binary from their website - -The [SQLite download page][2] has a link to a Linux binary for the SQLite command line tool. I downloaded it, it worked on my laptop, and I thought I was done. - -But then I tried to run it on a build server I was using (Netlify), and I got this extremely strange error message: “File not found”. I straced it, and sure enough `execve` was returning the error code ENOENT, which means “File not found”. This was kind of maddening because the file was DEFINITELY there and it had the correct permissions and everything. - -I googled this problem (by searching “execve enoent”), found [this stack overflow answer][3], which pointed out that to run a binary, you don’t just need the binary to exist! You also need its **loader** to exist. (the path to the loader is inside the binary) - -To see the path for the loader you can use `ldd`, like this: - -``` -$ ldd sqlite3 - linux-gate.so.1 (0xf7f9d000) - libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf7f70000) - libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf7e6e000) - libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0xf7e4f000) - libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7c73000) - /lib/ld-linux.so.2 -``` - -So `/lib/ld-linux.so.2` is the loader,and that file doesn’t exist on the build server, probably because that Xenial installation didn’t have support for 32-bit binaries (?), and I needed to try something different. - -### attempt 2: install the Debian sqlite3 package - -Okay, I thought, maybe I can install the [sqlite package from debian testing][4]. Trying to install a package from a different Debian version that I’m not using is literally never a good idea, but for some reason I decided to try it anyway. - -Doing this completely unsurprisingly broke the sqlite installation on my computer (which also broke git), but I managed to recover from that with a bunch of `sudo dpkg --purge --force-all libsqlite3-0` and make everything that depended on sqlite work again. - -### attempt 3: extract the Debian sqlite3 package - -I also briefly tried to just extract the sqlite3 binary from the Debian sqlite package and run it. Unsurprisingly, this also didn’t work, but in a more understandable way: I had an older version of libreadline (.so.7) and it wanted .so.8. - -``` -$ ./usr/bin/sqlite3 -./usr/bin/sqlite3: error while loading shared libraries: libreadline.so.8: cannot open shared object file: No such file or directory -``` - -### attempt 4: compile it from source - -The whole reason I spent all this time trying to download sqlite binaries is that I assumed it would be annoying or time consuming to compile sqlite from source. But obviously downloading random sqlite binaries was not working for me at all, so I finally decided to try to compile it myself. - -Here are the directions: [How to compile SQLite][5]. And they’re the EASIEST THING IN THE UNIVERSE. Often compiling things feels like this: - - * run `./configure` - * realize i’m missing a dependency - * run `./configure` again - * run `make` - * the compiler fails because actually i have the wrong version of some dependency - * go do something else and try to find a binary - - - -Compiling SQLite works like this: - - * download an [amalgamation tarball from the download page][2] - * run `gcc shell.c sqlite3.c -lpthread -ldl` - * that’s it!!! - - - -All the code is in one file (`sqlite.c`), and there are no weird dependencies! It’s amazing. - -For my specific use case I didn’t actually need threading support or readline support or anything, so I used the instructions on the compile page to create a very simple binary that only used libc and no other shared libraries. - -``` -$ ldd sqlite3 - linux-vdso.so.1 (0x00007ffe8e7e9000) - libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbea4988000) - /lib64/ld-linux-x86-64.so.2 (0x00007fbea4d79000) -``` - -### this is nice because it makes it easy to experiment with sqlite - -I think it’s cool that SQLite’s build process is so simple because in the past I’ve had fun [editing sqlite’s source code][6] to understand how its btree implementation works. - -This isn’t really super surprising given what I know about SQLite (it’s made to work really well in restricted / embedded contexts, so it makes sense that it would be possible to compile it in a really simple/minimal way). But it is super nice! - --------------------------------------------------------------------------------- - -via: https://jvns.ca/blog/2019/10/28/sqlite-is-really-easy-to-compile/ - -作者:[Julia Evans][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://jvns.ca/ -[b]: https://github.com/lujun9972 -[1]: https://sql-steps.wizardzines.com/lag.html -[2]: https://www.sqlite.org/download.html -[3]: https://stackoverflow.com/questions/5234088/execve-file-not-found-when-stracing-the-very-same-file -[4]: https://packages.debian.org/bullseye/amd64/sqlite3/download -[5]: https://www.sqlite.org/howtocompile.html -[6]: https://jvns.ca/blog/2014/10/02/how-does-sqlite-work-part-2-btrees/ diff --git a/sources/tech/20191029 Collapse OS - An OS Created to Run After the World Ends.md b/sources/tech/20191029 Collapse OS - An OS Created to Run After the World Ends.md deleted file mode 100644 index 456372ab38..0000000000 --- a/sources/tech/20191029 Collapse OS - An OS Created to Run After the World Ends.md +++ /dev/null @@ -1,104 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Collapse OS – An OS Created to Run After the World Ends) -[#]: via: (https://itsfoss.com/collapse-os/) -[#]: author: (John Paul https://itsfoss.com/author/john/) - -Collapse OS – An OS Created to Run After the World Ends -====== - -When most people think about preparing for a post-apocalyptic world, the first time that comes to mind is food and other living essentials. Recently, a programmer has decided that it would be just as important to create a versatile and survivable operating system after the collapse of society. We will be taking a look at it today, as best we can. - -### Collapse OS – For when the fecal matter hits the rotating device - -![][1] - -The operating system in question is called [Collapse OS][2]. According to the website, Collapse OS is a “z80 kernel and a collection of programs, tools and documentation”. It would allow you to: - - * Run on minimal and improvised machines. - * Interface through improvised means (serial, keyboard, display). - * Edit text files. - * Compile assembler source files for a wide range of MCUs and CPUs. - * Read and write from a wide range of storage devices. - * Replicate itself. - - - -The creator, [Virgil Dupras][3], started the project because [he sees][4] “our global supply chain to collapse before we reach 2030”. He bases this conclusion on the works of Pablo Servigne. He seems to understand that not everyone shares [his views][4]. “That being said, I don’t consider it unreasonable to not believe that collapse is likely to happen by 2030, so please, don’t feel attacked by my beliefs.” - -The overall goal of the project is to jumpstart a post-collapse civilization’s return to the computer age. The production of electronics depends on a very complex supply chain. Once that supply chain crumbles, man will go back to a less technical age. It would take decades to regain our previous technical position. Dupras hopes to jump several steps by creating an ecosystem that will work with simpler chips that can be scavenged from a wide variety of sources. - -### What is the z80? - -The initial CollapseOS kernel is written for the [z80 chip][5]. As a retro computing history buff, I am familiar with [Zilog][6] and it’s z80 chip. In the late 1970s, Zilog introduced the z80 to compete with [Intel’s 8080][7] CPU. The z80 was used in a whole bunch of early personal computers, such as the [Sinclair ZX Spectrum][8] and the [Tandy TRS-80][9]. The majority of these systems used the [CP/M operating system][10], which was the top operating system of the time. (Interestingly, Dupras was originally looking to use an [open-source implementation o][11][f][11] [CP/M][11], but ultimately decided to [start from scratch][12].) - -Both the z80 and CP/M started to decline in popularity after the [IBM PC][13] was released in 1981. Zilog did release several other microprocessors (Z8000 and Z80000), but these did not take off. The company switched its focus to microcontrollers. Today, an updated descendant of the z80 can be found in graphic calculators, embedded devices and consumer electronics. - -Dupras said on [Reddit][14] that he wrote Collapse OS for the z80 because “it’s been in production for so long and because it’s been used in so many machines, scavenger have good chances of getting their hands on it.” - -### Current status and future of the project - -Collapse OS has a pretty decent start. It can self replicate with enough RAM and storage. It is capable of running on an [RC2014 homebrew computer][15] or a Sega Master System/MegaDrive (Genesis). It can read SD cards. It has a simple text editor. The kernel is made up of modules that are connected with glue code. This is designed to make the system flexible and adaptable. - -There is also a detailed [roadmap][16] laying out the direction of the project. Listed goals include: - - * Support for other CPUs, such as 8080 and [6502][17] - * Support for improvised peripherals, such as LCD screens, E-ink displays, and [ACIA devices][18]. - * Support for more storage options, such as floppys, CDs, SPI RAM/ROMs, and AVR MCUs - * Get it to work on other z80 machines, such as [TI-83+][19] and [TI-84+][20] graphing calculators and TRS-80s - - - -If you are interested in helping out or just taking a peek at the project, be sure to visit their [GitHub page][21]. - -### Final Thoughts - -To put it bluntly, I see Collapse OS as more of a fun hobby project (for those who like building operating systems), than something useful. When a collapse does come, how will Collapse OS get distributed, since I imagine that GitHub will be down? I can’t imagine more than a handful of skill people being able to create a system from scavenged parts. There is a whole new generation of makers out there, but most of them are used to picking up an Arduino or a Raspberry Pi and building their project than starting from scratch. - -Contrary to Dupras, my biggest concern is the use of [EMPs][22]. These things fry all electrical systems, meaning there would be nothing left to scavenge to build system. If that doesn’t happen, I imagine that we would be able to find enough x86 components made over the past 30 years to keep things going. - -That being said, Collapse OS sounds like a fun and challenging project to people who like to program in low-level code for strange applications. If you are such a person, check out [Collapse OS][2]. - -Hypothetical question: what is your post-apocalyptic operating system of choice? Please 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][23]. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/collapse-os/ - -作者:[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/2019/10/Collapse_OS.jpg?ssl=1 -[2]: https://collapseos.org/ -[3]: https://github.com/hsoft -[4]: https://collapseos.org/why.html -[5]: https://en.m.wikipedia.org/wiki/Z80 -[6]: https://en.wikipedia.org/wiki/Zilog -[7]: https://en.wikipedia.org/wiki/Intel_8080 -[8]: https://en.wikipedia.org/wiki/ZX_Spectrum -[9]: https://en.wikipedia.org/wiki/TRS-80 -[10]: https://en.wikipedia.org/wiki/CP/M -[11]: https://github.com/davidgiven/cpmish -[12]: https://github.com/hsoft/collapseos/issues/52 -[13]: https://en.wikipedia.org/wiki/IBM_Personal_Computer -[14]: https://old.reddit.com/r/collapse/comments/dejmvz/collapse_os_bootstrap_postcollapse_technology/f2w3sid/?st=k1gujoau&sh=1b344da9 -[15]: https://rc2014.co.uk/ -[16]: https://collapseos.org/roadmap.html -[17]: https://en.wikipedia.org/wiki/MOS_Technology_6502 -[18]: https://en.wikipedia.org/wiki/MOS_Technology_6551 -[19]: https://en.wikipedia.org/wiki/TI-83_series#TI-83_Plus -[20]: https://en.wikipedia.org/wiki/TI-84_Plus_series -[21]: https://github.com/hsoft/collapseos -[22]: https://en.wikipedia.org/wiki/Electromagnetic_pulse -[23]: https://reddit.com/r/linuxusersgroup diff --git a/sources/tech/20191029 Upgrading Fedora 30 to Fedora 31.md b/sources/tech/20191029 Upgrading Fedora 30 to Fedora 31.md deleted file mode 100644 index 4e27e83d0d..0000000000 --- a/sources/tech/20191029 Upgrading Fedora 30 to Fedora 31.md +++ /dev/null @@ -1,96 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Upgrading Fedora 30 to Fedora 31) -[#]: via: (https://fedoramagazine.org/upgrading-fedora-30-to-fedora-31/) -[#]: author: (Ben Cotton https://fedoramagazine.org/author/bcotton/) - -Upgrading Fedora 30 to Fedora 31 -====== - -![][1] - -Fedora 31 [is available now][2]. You’ll likely want to upgrade your system to get the latest features available in Fedora. Fedora Workstation has a graphical upgrade method. Alternatively, Fedora offers a command-line method for upgrading Fedora 30 to Fedora 31. - -### Upgrading Fedora 30 Workstation to Fedora 31 - -Soon after release time, a notification appears to tell you an upgrade is available. You can click the notification to launch the **GNOME Software** app. Or you can choose Software from GNOME Shell. - -Choose the _Updates_ tab in GNOME Software and you should see a screen informing you that Fedora 31 is Now Available. - -If you don’t see anything on this screen, try using the reload button at the top left. It may take some time after release for all systems to be able to see an upgrade available. - -Choose _Download_ to fetch the upgrade packages. You can continue working until you reach a stopping point, and the download is complete. Then use GNOME Software to restart your system and apply the upgrade. Upgrading takes time, so you may want to grab a coffee and come back to the system later. - -### Using the command line - -If you’ve upgraded from past Fedora releases, you are likely familiar with the _dnf upgrade_ plugin. This method is the recommended and supported way to upgrade from Fedora 30 to Fedora 31. Using this plugin will make your upgrade to Fedora 31 simple and easy. - -#### 1\. Update software and back up your system - -Before you do start the upgrade process, make sure you have the latest software for Fedora 30. This is particularly important if you have modular software installed; the latest versions of dnf and GNOME Software include improvements to the upgrade process for some modular streams. To update your software, use _GNOME Software_ or enter the following command in a terminal. - -``` -sudo dnf upgrade --refresh -``` - -Additionally, make sure you back up your system before proceeding. For help with taking a backup, see [the backup series][3] on the Fedora Magazine. - -#### 2\. Install the DNF plugin - -Next, open a terminal and type the following command to install the plugin: - -``` -sudo dnf install dnf-plugin-system-upgrade -``` - -#### 3\. Start the update with DNF - -Now that your system is up-to-date, backed up, and you have the DNF plugin installed, you can begin the upgrade by using the following command in a terminal: - -``` -sudo dnf system-upgrade download --releasever=31 -``` - -This command will begin downloading all of the upgrades for your machine locally to prepare for the upgrade. If you have issues when upgrading because of packages without updates, broken dependencies, or retired packages, add the _‐‐allowerasing_ flag when typing the above command. This will allow DNF to remove packages that may be blocking your system upgrade. - -#### 4\. Reboot and upgrade - -Once the previous command finishes downloading all of the upgrades, your system will be ready for rebooting. To boot your system into the upgrade process, type the following command in a terminal: - -``` -sudo dnf system-upgrade reboot -``` - -Your system will restart after this. Many releases ago, the _fedup_ tool would create a new option on the kernel selection / boot screen. With the _dnf-plugin-system-upgrade_ package, your system reboots into the current kernel installed for Fedora 30; this is normal. Shortly after the kernel selection screen, your system begins the upgrade process. - -Now might be a good time for a coffee break! Once it finishes, your system will restart and you’ll be able to log in to your newly upgraded Fedora 31 system. - -![][4] - -### Resolving upgrade problems - -On occasion, there may be unexpected issues when you upgrade your system. If you experience any issues, please visit the [DNF system upgrade quick docs][5] for more information on troubleshooting. - -If you are having issues upgrading and have third-party repositories installed on your system, you may need to disable these repositories while you are upgrading. For support with repositories not provided by Fedora, please contact the providers of the repositories. - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/upgrading-fedora-30-to-fedora-31/ - -作者:[Ben Cotton][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/bcotton/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2019/10/f30-f31-816x345.jpg -[2]: https://fedoramagazine.org/announcing-fedora-31/ -[3]: https://fedoramagazine.org/taking-smart-backups-duplicity/ -[4]: https://cdn.fedoramagazine.org/wp-content/uploads/2016/06/Screenshot_f23-ws-upgrade-test_2016-06-10_110906-1024x768.png -[5]: https://docs.fedoraproject.org/en-US/quick-docs/dnf-system-upgrade/#Resolving_post-upgrade_issues diff --git a/sources/tech/20191029 What you probably didn-t know about sudo.md b/sources/tech/20191029 What you probably didn-t know about sudo.md deleted file mode 100644 index e58c092602..0000000000 --- a/sources/tech/20191029 What you probably didn-t know about sudo.md +++ /dev/null @@ -1,200 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (What you probably didn’t know about sudo) -[#]: via: (https://opensource.com/article/19/10/know-about-sudo) -[#]: author: (Peter Czanik https://opensource.com/users/czanik) - -What you probably didn’t know about sudo -====== -Think you know everything about sudo? Think again. -![Command line prompt][1] - -Everybody knows **sudo**, right? This tool is installed by default on most Linux systems and is available for most BSD and commercial Unix variants. Still, after talking to hundreds of **sudo** users, the most common answer I received was that **sudo** is a tool to complicate life. - -There is a root user and there is the **su** command, so why have yet another tool? For many, **sudo** was just a prefix for administrative commands. Only a handful mentioned that when you have multiple administrators for the same system, you can use **sudo** logs to see who did what. - -So, what is **sudo**? According to the [**sudo** website][2]: - -> _"Sudo allows a system administrator to delegate authority by giving certain users the ability to run some commands as root or another user while providing an audit trail of the commands and their arguments."_ - -By default, **sudo** comes with a simple configuration, a single rule allowing a user or a group of users to do practically anything (more on the configuration file later in this article): - - -``` -`%wheel ALL=(ALL) ALL` -``` - -In this example, the parameters mean the following: - - * The first parameter defines the members of the group. - * The second parameter defines the host(s) the group members can run commands on. - * The third parameter defines the usernames under which the command can be executed. - * The last parameter defines the applications that can be run. - - - -So, in this example, the members of the **wheel** group can run all applications as all users on all hosts. Even this really permissive rule is useful because it results in logs of who did what on your machine. - -### Aliases - -Of course, once it is not just you and your best friend administering a shared box, you will start to fine-tune permissions. You can replace the items in the above configuration with lists: a list of users, a list of commands, and so on. Most likely, you will copy and paste some of these lists around in your configuration. - -This situation is where aliases can come handy. Maintaining the same list in multiple places is error-prone. You define an alias once and then you can use it many times. Therefore, when you lose trust in one of your administrators, you can remove them from the alias and you are done. With multiple lists instead of aliases, it is easy to forget to remove the user from one of the lists with elevated privileges.  - -### Enable features for a certain group of users - -The **sudo** command comes with a huge set of defaults. Still, there are situations when you want to override some of these. This is when you use the **Defaults** statement in the configuration. Usually, these defaults are enforced on every user, but you can narrow the setting down to a subset of users based on host, username, and so on. Here is an example that my generation of sysadmins loves to hear about: insults. These are just some funny messages for when someone mistypes a password: - - -``` -czanik@linux-mewy:~> sudo ls -[sudo] password for root: -Hold it up to the light --- not a brain in sight! -[sudo] password for root: -My pet ferret can type better than you! -[sudo] password for root: -sudo: 3 incorrect password attempts -czanik@linux-mewy:~> -``` - -Because not everyone is a fan of sysadmin humor, these insults are disabled by default. The following example shows how to enable this setting only for your seasoned sysadmins, who are members of the **wheel** group: - - -``` -Defaults !insults -Defaults:%wheel insults -``` - -I do not have enough fingers to count how many people thanked me for bringing these messages back. - -### Digest verification - -There are, of course, more serious features in **sudo** as well. One of them is digest verification. You can include the digest of applications in your configuration:  - - -``` -`peter ALL = sha244:11925141bb22866afdf257ce7790bd6275feda80b3b241c108b79c88 /usr/bin/passwd` -``` - -In this case, **sudo** checks and compares the digest of the application to the one stored in the configuration before running the application. If they do not match, **sudo** refuses to run the application. While it is difficult to maintain this information in your configuration—there are no automated tools for this purpose—these digests can provide you with an additional layer of protection. - -### Session recording - -Session recording is also a lesser-known feature of **sudo**. After my demo, many people leave my talk with plans to implement it on their infrastructure. Why? Because with session recording, you see not just the command name, but also everything that happened in the terminal. You can see what your admins are doing even if they have shell access and logs only show that **bash** is started. - -There is one limitation, currently. Records are stored locally, so with enough permissions, users can delete their traces. Stay tuned for upcoming features. - -### Plugins - -Starting with version 1.8, **sudo** changed to a modular, plugin-based architecture. With most features implemented as plugins, you can easily replace or extend the functionality of **sudo** by writing your own. There are both open source and commercial plugins already available for **sudo**. - -In my talk, I demonstrated the **sudo_pair** plugin, which is available [on GitHub][3]. This plugin is developed in Rust, meaning that it is not so easy to compile, and it is even more difficult to distribute the results. On the other hand, the plugin provides interesting functionality, requiring a second admin to approve (or deny) running commands through **sudo**. Not just that, but sessions can be followed on-screen and terminated if there is suspicious activity. - -In a demo I did during a recent talk at the All Things Open conference, I had the infamous: - - -``` -`czanik@linux-mewy:~> sudo  rm -fr /` -``` - -command displayed on the screen. Everybody was holding their breath to see whether my laptop got destroyed, but it survived. - -### Logs - -As I already mentioned at the beginning, logging and alerting is an important part of **sudo**. If you do not check your **sudo** logs regularly, there is not much worth in using **sudo**. This tool alerts by email on events specified in the configuration and logs all events to **syslog**. Debug logs can be turned on and used to debug rules or report bugs. - -### Alerts - -Email alerts are kind of old-fashioned now, but if you use **syslog-ng** for collecting your log messages, your **sudo** log messages are automatically parsed. You can easily create custom alerts and send those to a wide variety of destinations, including Slack, Telegram, Splunk, or Elasticsearch. You can learn more about this feature from [my blog on syslong-ng.com][4]. - -### Configuration - -We talked a lot about **sudo** features and even saw a few lines of configuration. Now, let’s take a closer look at how **sudo** is configured. The configuration itself is available in **/etc/sudoers**, which is a simple text file. Still, it is not recommended to edit this file directly. Instead, use **visudo**, as this tool also does syntax checking. If you do not like **vi**, you can change which editor to use by pointing the **EDITOR** environment variable at your preferred option. - -Before you start editing the **sudo** configuration, make sure that you know the root password. (Yes, even on Ubuntu, where root does not have a password by default.) While **visudo** checks the syntax, it is easy to create a syntactically correct configuration that locks you out of your system. - -When you have a root password at hand in case of an emergency, you can start editing your configuration. When it comes to the **sudoers** file, there is one important thing to remember: This file is read from top to bottom, and the last setting wins. What this fact means for you is that you should start with generic settings and place exceptions at the end, otherwise exceptions are overridden by the generic settings. - -You can find a simple **sudoers** file below, based on the one in CentOS, and add a few lines we discussed previously: - - -``` -Defaults !visiblepw -Defaults always_set_home -Defaults match_group_by_gid -Defaults always_query_group_plugin -Defaults env_reset -Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS" -Defaults env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE" -Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin -root ALL=(ALL) ALL -%wheel ALL=(ALL) ALL -Defaults:%wheel insults -Defaults !insults -Defaults log_output -``` - -This file starts by changing a number of defaults. Then come the usual default rules: The **root** user and members of the **wheel** group have full permissions over the machine. Next, we enable insults for the **wheel** group, but disable them for everyone else. The last line enables session recording. - -The above configuration is syntactically correct, but can you spot the logical error? Yes, there is one: Insults are disabled for everyone since the last, generic setting overrides the previous, more specific setting. Once you switch the two lines, the setup works as expected: Members of the **wheel** group receive funny messages, but the rest of the users do not receive them. - -### Configuration management - -Once you have to maintain the **sudoers** file on multiple machines, you will most likely want to manage your configuration centrally. There are two major open source possibilities here. Both have their advantages and drawbacks. - -You can use one of the configuration management applications that you also use to configure the rest of your infrastructure. Red Hat Ansible, Puppet, and Chef all have modules to configure **sudo**. The problem with this approach is that updating configurations is far from real-time. Also, users can still edit the **sudoers** file locally and change settings. - -The **sudo** tool can also store its configuration in LDAP. In this case, configuration changes are real-time and users cannot mess with the **sudoers** file. On the other hand, this method also has limitations. For example, you cannot use aliases or use **sudo** when the LDAP server is unavailable. - -### New features - -There is a new version of **sudo** right around the corner. Version 1.9 will include many interesting new features. Here are the most important planned features: - - * A recording service to collect session recordings centrally, which offers many advantages compared to local storage: - * It is more convenient to search in one place. - * Recordings are available even if the sender machine is down. - * Recordings cannot be deleted by someone who wants to delete their tracks. - * The **audit** plugin does not add new features to **sudoers**, but instead provides an API for plugins to easily access any kind of **sudo** logs. This plugin enables creating custom logs from **sudo** events using plugins. - * The **approval** plugin enables session approvals without using third-party plugins. - * And my personal favorite: Python support for plugins, which enables you to easily extend **sudo** using Python code instead of coding natively in C. - - - -### Conclusion - -I hope this article proved to you that **sudo** is a lot more than just a simple prefix. There are tons of possibilities to fine-tune permissions on your system. You cannot just fine-tune permissions, but also improve security by checking digests. Session recordings enable you to check what is happening on your systems. You can also extend the functionality of **sudo** using plugins, either using something already available or writing your own. Finally, given the list of upcoming features you can see that even if **sudo** is decades old, it is a living project that is constantly evolving. - -If you want to learn more about **sudo**, here are a few resources: - - * [The **sudo** website][5] - - * [The **sudo** blog][6] - - * [Follow us on Twitter][7] - - - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/know-about-sudo - -作者:[Peter Czanik][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/czanik -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/command_line_prompt.png?itok=wbGiJ_yg (Command line prompt) -[2]: https://www.sudo.ws -[3]: https://github.com/square/sudo_pair/ -[4]: https://www.syslog-ng.com/community/b/blog/posts/alerting-on-sudo-events-using-syslog-ng -[5]: https://www.sudo.ws/ -[6]: https://blog.sudo.ws/ -[7]: https://twitter.com/sudoproject diff --git a/sources/tech/20191030 Test automation without assertions for web development.md b/sources/tech/20191030 Test automation without assertions for web development.md new file mode 100644 index 0000000000..7940402936 --- /dev/null +++ b/sources/tech/20191030 Test automation without assertions for web development.md @@ -0,0 +1,163 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Test automation without assertions for web development) +[#]: via: (https://opensource.com/article/19/10/test-automation-without-assertions) +[#]: author: (Jeremias Roessler https://opensource.com/users/roesslerj) + +Test automation without assertions for web development +====== +Recheck-web promises the benefits of golden master-based testing without +the drawbacks. +![Coding on a computer][1] + +Graphical user interface (GUI) test automation is broken. Regression testing is not testing; it's version control for a software's behavior. Here's my assertion: test automation _without_ _assertions_ works better! + +In software development and test automation, an assertion is a means to check the result of a calculation, typically by comparing it to a singular expected value. While this is very well suited for unit-based test automation (i.e. testing the system from within), applying it to testing an interface (specifically the user interface) has proven to be problematic, as this post will explain. + +The number of tools that work according to the [golden master][2] approach to testing, characterization testing, and approval testing—such as [Approval Tests][3], [Jest][4], or [recheck-web][5] ([retest][6])—is constantly increasing. This approach promises more robust tests with less effort (for both creation and maintenance) while testing more thoroughly. + +The examples in this article are available on [GitHub][7]. + +### A basic Selenium test + +Here's a simple example of a traditional test running against a web application's login page. Using [Selenium][8] as the testing framework, the code could look like this: + + +``` +public class MySeleniumTest { + +        RemoteWebDriver driver; + +        @Before +        public void setup() { +                driver =  new ChromeDriver(); +        } + +        @Test +        public void login() throws Exception { +                driver.get(""); + +                driver.findElement(By.id("username")).sendKeys("Simon"); +                driver.findElement(By.id("password")).sendKeys("secret"); +                driver.findElement(By.id("sign-in")).click(); + +                assertEquals(driver.findElement(By.tagName("h4")).getText(), "Success!"); +        } + +        @After +        public void tearDown() throws InterruptedException { +                driver.quit(); +        } +} +``` + +This is a very simple test. It opens a specific URL, then finds input fields by their invisible element IDs. It enters the user name and password, then clicks the login button. + +As is currently best practice, this test then uses a unit-test library to check the correct outcome by means of an _assert_ statement. + +In this example, the test determines whether the text "Success!" is displayed. + +You can run the test a few times to verify success, but it's important to experience failure, as well. To create an error, change the HTML of the website being tested. You could, for instance, edit the CSS declaration: + + +``` +`` +``` + +Changing or removing as much as a single character of the URL (e.g. change "main" to "min") changes the website to display as raw HTML without a layout. + +![Website login form displayed as raw HTML][9] + +This small change is definitely an error. However, when the test is executed, it shows no problem and still passes. To outright ignore such a blatant error clearly is not what you would expect of your tests. They should guard against you involuntarily breaking your website after all. + +Now instead, change or remove the element IDs of the input fields. Since these IDs are invisible, this change doesn't have any impact on the website from a user's perspective. But when the test executes, it fails with a **NoSuchElementException**. This essentially means that this irrelevant change _broke the test_. Tests that ignore major changes but fail on invisible and hence irrelevant ones are the current standard in test automation. This is basically the _opposite_ of how a test should behave. + +Now, take the original test and wrap the driver in a RecheckDriver: + + +``` +`driver = new RecheckDriver( new ChromeDriver() );` +``` + +Then either replace the assertion with a call to **driver.capTest();** at the end of the test or add a Junit 5 rule: **@ExtendWith(RecheckExtension.class)**. If you remove the CSS from the website, the test fails, as it should: + +![Failed test][10] + +But if you change or remove the element IDs instead, the test still passes. + +This surprising ability, coming from the "unbreakable" feature of recheck-web, is explained in detail below. This is how a test should behave: detect changes important to the user, and do not break on changes that are irrelevant to the user. + +### How it works + +The [recheck-web][5] project is a free, open source tool that operates on top of Selenium. It is golden master-based, which essentially means that it creates a copy of the rendered website the first time the test is executed, and subsequent runs of the test compare the current state against that copy (the golden master). This is how it can detect that the website has changed in unfavorable ways. It is also how it can still identify an element after its ID has changed: It simply peeks into the golden master (where the ID is still present) and finds the element there. Using additional properties like XPath, HTML name, and CSS classes, recheck-web identifies the element on the changed website and returns it to Selenium. The test can then interact with the element, just as before, and report the change. + +![recheck-web's process][11] + +#### Problems with golden master testing + +Golden master testing, in general, has two essential drawbacks: + + 1. It is often difficult to ignore irrelevant changes. Many changes are not problematic (e.g., date and time changes, random IDs, etc.). For the same reason that Git features the **.gitignore** file, recheck-web features the **recheck.ignore** file. And its Git-like syntax makes it easy to specify which differences to ignore. + 2. It is often cumbersome to maintain redundancy. Golden masters usually have quite an overlap. Often, the same change has to be approved multiple times, nullifying the efficiency gained during the fast test creation. For that, recheck comes complete with its own [command-line interface (CLI)][12] that takes care of this annoying task. The CLI (and the [commercial GUI][13]) lets users easily apply the same change to the same element in all instances or simply apply or ignore all changes at once. + + + +The example above illustrates both drawbacks and their respective solutions: the changed ID was detected, but not reported because the ID attribute in the **recheck.ignore** file was specified to be ignored with **attribute=id**. Removing that rule makes the test fail, but it does not _break_ (the test still executes and reports the changed ID). + +The example test uses the implicit checking mechanism, which automatically checks the result after every action. (Note that if you prefer to do explicit checking (e.g. by calling **re.check**) this is entirely possible.) Opening the URL, entering the user name, and entering the password are three actions that are being performed on the same page, therefore three golden masters are created for the same page. The changed ID thus is reported three times. All three instances can be treated with a single call to **recheck commit --all tests.report** on the command line. Applying the change makes the recheck-web test fail because the ID is removed from the golden master. This calls for anther neat feature of recheck-web: the **retestId**. + +### Virtual constant IDs + +The basic idea of the **retestId** is to introduce an additional attribute in the copy of the website. Since this attribute lives only in the website copy, not on the live site, it can never be affected by a change (unless the element is completely removed). This is called a _virtual constant ID_. + +Now, this **retestId** can be referred to in the test. Simply replace the call to, for instance, **By._id_("username")** with **By._retestId_("username")**, and this problem is solved for good. This also addresses instances where elements are hard to reference because they have no ID to begin with. + +### Filter mechanism + +What would Git be without the **.gitignore** file? Filtering out irrelevant changes is one of the most important features of a version-control system. Traditional assertion-based testing ignores more than 99% of the changes. Instead, similar to Git without a **.gitignore** file, recheck-web reports any and all changes. + +It's up to the user to ignore changes that aren't of interest. Recheck-web can be used for cross-browser testing, cross-device testing, deep visual regression testing, and functional regression testing, depending on what you do or do not ignore. + +The filtering mechanism is as simple (based on the **.gitignore** file) as it is powerful. Single attributes can be filtered globally or for certain elements. Single elements—or even whole parts of the page—can be ignored. If this is not powerful enough, you can implement filter rules in JavaScript to, for example, ignore different URLs with the same base or position differences of less than five pixels. + +A good starting point for understanding this is the [predefined filter files][14] that are distributed with recheck-web. Ignoring element positioning is usually a good idea. If you want to learn more about how to maintain your **recheck.ignore** file or create your own filters, see the [documentation][15]. + +### Summary + +Recheck-web is one of the few golden master-based testing tools available; alternatives include Approval Tests and Jest. + +Recheck-web provides the ability to quickly and easily create tests that are more complete and robust than traditional tests. Because it compares rendered websites (or parts of them) with each other, cross-browser testing, cross-platform testing, and other test scenarios can be realized. Also, this kind of testing is an "enabler" technology that will enable artificial intelligence to generate additional tests. + +Recheck-web is free and open source, so please [try it out][5]. The company's business model is to offer additional services (e.g., storing golden masters and reports as well as an AI to generate tests) and to have a commercial GUI on top of the CLI for maintaining the golden masters. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/test-automation-without-assertions + +作者:[Jeremias Roessler][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/roesslerj +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: https://opensource.com/article/19/7/what-golden-image +[3]: https://approvaltests.com +[4]: https://jestjs.io/ +[5]: https://github.com/retest/recheck-web +[6]: http://retest.de +[7]: https://github.com/retest/recheck-web-example +[8]: https://www.seleniumhq.org/ +[9]: https://opensource.com/sites/default/files/uploads/webformerror.png (Website login form displayed as raw HTML) +[10]: https://opensource.com/sites/default/files/uploads/testfails.png (Failed test) +[11]: https://opensource.com/sites/default/files/uploads/recheck-web-process.png (recheck-web's process) +[12]: https://github.com/retest/recheck.cli +[13]: https://retest.de/review/ +[14]: https://github.com/retest/recheck/tree/master/src/main/resources/filter/web +[15]: https://docs.retest.de/recheck/usage/filter diff --git a/sources/tech/20191031 4 Python tools for getting started with astronomy.md b/sources/tech/20191031 4 Python tools for getting started with astronomy.md new file mode 100644 index 0000000000..79e64651b3 --- /dev/null +++ b/sources/tech/20191031 4 Python tools for getting started with astronomy.md @@ -0,0 +1,69 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (4 Python tools for getting started with astronomy) +[#]: via: (https://opensource.com/article/19/10/python-astronomy-open-data) +[#]: author: (Gina Helfrich, Ph.D. https://opensource.com/users/ginahelfrich) + +4 Python tools for getting started with astronomy +====== +Explore the universe with NumPy, SciPy, Scikit-Image, and Astropy. +![Person looking up at the stars][1] + +NumFOCUS is a nonprofit charity that supports amazing open source toolkits for scientific computing and data science. As part of the effort to connect Opensource.com readers with the NumFOCUS community, we are republishing some of the most popular articles from [our blog][2]. To learn more about our mission and programs, please visit [numfocus.org][3]. If you're interested in participating in the NumFOCUS community in person, check out a local [PyData event][4] happening near you. + +* * * + +### Astronomy with Python + +Python is a great language for science, and specifically for astronomy. The various packages such as [NumPy][5], [SciPy][6], [Scikit-Image][7] and [Astropy][8] (to name but a few) are all a great testament to the suitability of Python for astronomy, and there are plenty of use cases. [NumPy, Astropy, and SciPy are NumFOCUS fiscally sponsored projects; Scikit-Image is an affiliated project.] Since leaving the field of astronomical research behind more than 10 years ago to start a second career as software developer, I have always been interested in the evolution of these packages. Many of my former colleagues in astronomy used most if not all of these packages for their research work. I have since worked on implementing professional astronomy software packages for instruments for the Very Large Telescope (VLT) in Chile, for example. + +It struck me recently that the Python packages have evolved to such an extent that it is now fairly easy for anyone to build [data reduction][9] scripts that can provide high-quality data products. Astronomical data is ubiquitous, and what is more, it is almost all publicly available—you just need to look for it. + +For example, ESO, which runs the VLT, offers the data for download on their site. Head over to [www.eso.org/UserPortal][10] and create a user name for their portal. If you look for data from the instrument SPHERE you can download a full dataset for any of the nearby stars that have exoplanet or proto-stellar discs. It is a fantastic and exciting project for any Pythonista to reduce that data and make the planets or discs that are deeply hidden in the noise visible. + +I encourage you to download the ESO or any other astronomy imaging dataset and go on that adventure. Here are a few tips: + + 1. Start off with a good dataset. Have a look at papers about nearby stars with discs or exoplanets and then search, for example: . Notice that some data on this site is marked as red and some as green. The red data is not publicly available yet — it will say under “release date” when it will be available. + 2. Read something about the instrument you are using the data from. Try and get a basic understanding of how the data is obtained and what the standard data reduction should look like. All telescopes and instruments have publicly available documents about this. + 3. You will need to consider the standard problems with astronomical data and correct for them: + 1. Data comes in FITS files. You will need **pyfits** or **astropy** (which contains pyfits) to read them into **NumPy** arrays. In some cases the data comes in a cube and you should to use **numpy.median **along the z-axis to turn them into 2-D arrays. For some SPHERE data you get two copies of the same piece of sky on the same image (each has a different filter) which you will need to extract using **indexing and slicing.** + 2. The master dark and bad pixel map. All instruments will have specific images taken as “dark frames” that contain images with the shutter closed (no light at all). Use these to extract a mask of bad pixels using **NumPy masked arrays** for this. This mask of bad pixels will be very important — you need to keep track of it as you process the data to get a clean combined image in the end. In some cases it also helps to subtract this master dark from all scientific raw images. + 3. Instruments will typically also have a master flat frame. This is an image or series of images taken with a flat uniform light source. You will need to divide all scientific raw images by this (again, using numpy masked array makes this an easy division operation). + 4. For planet imaging, the fundamental technique to make planets visible against a bright star rely on using a coronagraph and a technique known as angular differential imaging. To that end, you need to identify the optical centre on the images. This is one of the most tricky steps and requires finding some artificial helper images embedded in the images using **skimage.feature.blob_dog**. + 4. Be patient. It can take a while to understand the data format and how to handle it. Making some plots and histograms of the pixel data can help you to understand it. It is well worth it to be persistent! You will learn a lot about imaging data and processing. + + + +Using the tools offered by NumPy, SciPy, Astropy, scikit-image and more in combination, with some patience and persistence, it is possible to analyse the vast amount of available astronomical data to produce some stunning results. And who knows, maybe you will be the first one to find a planet that was previously overlooked! Good luck! + +_This article was originally published on the NumFOCUS blog and is republished with permission. It is based on [a talk][11] by [Ole Moeller-Nilsson][12], CTO at Pivigo. If you want to support NumFOCUS, you can donate [here][13] or find your local [PyData event][4] happening around the world._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/python-astronomy-open-data + +作者:[Gina Helfrich, Ph.D.][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/ginahelfrich +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/space_stars_cosmos_person.jpg?itok=XUtz_LyY (Person looking up at the stars) +[2]: https://numfocus.org/blog +[3]: https://numfocus.org +[4]: https://pydata.org/ +[5]: http://numpy.scipy.org/ +[6]: http://www.scipy.org/ +[7]: http://scikit-image.org/ +[8]: http://www.astropy.org/ +[9]: https://en.wikipedia.org/wiki/Data_reduction +[10]: http://www.eso.org/UserPortal +[11]: https://www.slideshare.net/OleMoellerNilsson/pydata-lonon-finding-planets-with-python +[12]: https://twitter.com/olly_mn +[13]: https://numfocus.org/donate diff --git a/sources/tech/20191031 Advance your awk skills with two easy tutorials.md b/sources/tech/20191031 Advance your awk skills with two easy tutorials.md new file mode 100644 index 0000000000..f84e4ebe3a --- /dev/null +++ b/sources/tech/20191031 Advance your awk skills with two easy tutorials.md @@ -0,0 +1,287 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Advance your awk skills with two easy tutorials) +[#]: via: (https://opensource.com/article/19/10/advanced-awk) +[#]: author: (Dave Neary https://opensource.com/users/dneary) + +Advance your awk skills with two easy tutorials +====== +Go beyond one-line awk scripts with mail merge and word counting. +![a checklist for a team][1] + +Awk is one of the oldest tools in the Unix and Linux user's toolbox. Created in the 1970s by Alfred Aho, Peter Weinberger, and Brian Kernighan (the A, W, and K of the tool's name), awk was created for complex processing of text streams. It is a companion tool to sed, the stream editor, which is designed for line-by-line processing of text files. Awk allows more complex structured programs and is a complete programming language. + +This article will explain how to use awk for more structured and complex tasks, including a simple mail merge application. + +### Awk program structure + +An awk script is made up of functional blocks surrounded by **{}** (curly brackets). There are two special function blocks, **BEGIN** and **END**, that execute before processing the first line of the input stream and after the last line is processed. In between, blocks have the format: + + +``` +`pattern { action statements }` +``` + +Each block executes when the line in the input buffer matches the pattern. If no pattern is included, the function block executes on every line of the input stream. + +Also, the following syntax can be used to define functions in awk that can be called from any block: + + +``` +`function name(parameter list) { statements }` +``` + +This combination of pattern-matching blocks and functions allows the developer to structure awk programs for reuse and readability. + +### How awk processes text streams + +Awk reads text from its input file or stream one line at a time and uses a field separator to parse it into a number of fields. In awk terminology, the current buffer is a _record_. There are a number of special variables that affect how awk reads and processes a file: + + * **FS** (field separator): By default, this is any whitespace (spaces or tabs) + * **RS** (record separator): By default, a newline (**\n**) + * **NF** (number of fields): When awk parses a line, this variable is set to the number of fields that have been parsed + * **$0:** The current record + * **$1, $2, $3, etc.:** The first, second, third, etc. field from the current record + * **NR** (number of records): The number of records that have been parsed so far by the awk script + + + +There are many other variables that affect awk's behavior, but this is enough to start with. + +### Awk one-liners + +For a tool so powerful, it's interesting that most of awk's usage is basic one-liners. Perhaps the most common awk program prints selected fields from an input line from a CSV file, a log file, etc. For example, the following one-liner prints a list of usernames from **/etc/passwd**: + + +``` +`awk -F":" '{print $1 }' /etc/passwd` +``` + +As mentioned above, **$1** is the first field in the current record. The **-F** option sets the FS variable to the character **:**. + +The field separator can also be set in a BEGIN function block: + + +``` +`awk 'BEGIN { FS=":" } {print $1 }' /etc/passwd` +``` + +In the following example, every user whose shell is not **/sbin/nologin** can be printed by preceding the block with a pattern match: + + +``` +`awk 'BEGIN { FS=":" } ! /\/sbin\/nologin/ {print $1 }' /etc/passwd` +``` + +### Advanced awk: Mail merge + +Now that you have some of the basics, try delving deeper into awk with a more structured example: creating a mail merge. + +A mail merge uses two files, one (called in this example **email_template.txt**) containing a template for an email you want to send: + + +``` +From: Program committee <[pc@event.org][2]> +To: {firstname} {lastname} <{email}> +Subject: Your presentation proposal + +Dear {firstname}, + +Thank you for your presentation proposal: +  {title} + +We are pleased to inform you that your proposal has been successful! We +will contact you shortly with further information about the event +schedule. + +Thank you, +The Program Committee +``` + +And the other is a CSV file (called **proposals.csv**) with the people you want to send the email to: + + +``` +firstname,lastname,email,title +Harry,Potter,[hpotter@hogwarts.edu][3],"Defeating your nemesis in 3 easy steps" +Jack,Reacher,[reacher@covert.mil][4],"Hand-to-hand combat for beginners" +Mickey,Mouse,[mmouse@disney.com][5],"Surviving public speaking with a squeaky voice" +Santa,Claus,[sclaus@northpole.org][6],"Efficient list-making" +``` + +You want to read the CSV file, replace the relevant fields in the first file (skipping the first line), then write the result to a file called **acceptanceN.txt**, incrementing **N** for each line you parse. + +Write the awk program in a file called **mail_merge.awk**. Statements are separated by **;** in awk scripts. The first task is to set the field separator variable and a couple of other variables the script needs. You also need to read and discard the first line in the CSV, or a file will be created starting with _Dear firstname_. To do this, use the special function **getline** and reset the record counter to 0 after reading it. + + +``` +BEGIN { +  FS=","; +  template="email_template.txt"; +  output="acceptance"; +  getline; +  NR=0; +} +``` + +The main function is very straightforward: for each line processed, a variable is set for the various fields—**firstname**, **lastname**, **email**, and **title**. The template file is read line by line, and the function **sub** is used to substitute any occurrence of the special character sequences with the value of the relevant variable. Then the line, with any substitutions made, is output to the output file. + +Since you are dealing with the template file and a different output file for each line, you need to clean up and close the file handles for these files before processing the next record. + + +``` +{ +        # Read relevant fields from input file +        firstname=$1; +        lastname=$2; +        email=$3; +        title=$4; + +        # Set output filename +        outfile=(output NR ".txt"); + +        # Read a line from template, replace special fields, and +        # print result to output file +        while ( (getline ln < template) > 0 ) +        { +                sub(/{firstname}/,firstname,ln); +                sub(/{lastname}/,lastname,ln); +                sub(/{email}/,email,ln); +                sub(/{title}/,title,ln); +                print(ln) > outfile; +        } + +        # Close template and output file in advance of next record +        close(outfile); +        close(template); +} +``` + +You're done! Run the script on the command line with: + + +``` +`awk -f mail_merge.awk proposals.csv` +``` + +or + + +``` +`awk -f mail_merge.awk < proposals.csv` +``` + +and you will find text files generated in the current directory. + +### Advanced awk: Word frequency count + +One of the most powerful features in awk is the associative array. In most programming languages, array entries are typically indexed by a number, but in awk, arrays are referenced by a key string. You could store an entry from the file _proposals.txt_ from the previous section. For example, in a single associative array, like this: + + +``` +        proposer["firstname"]=$1; +        proposer["lastname"]=$2; +        proposer["email"]=$3; +        proposer["title"]=$4; +``` + +This makes text processing very easy. A simple program that uses this concept is the idea of a word frequency counter. You can parse a file, break out words (ignoring punctuation) in each line, increment the counter for each word in the line, then output the top 20 words that occur in the text. + +First, in a file called **wordcount.awk**, set the field separator to a regular expression that includes whitespace and punctuation: + + +``` +BEGIN { +        # ignore 1 or more consecutive occurrences of the characters +        # in the character group below +        FS="[ .,:;()<>{}@!\"'\t]+"; +} +``` + +Next, the main loop function will iterate over each field, ignoring any empty fields (which happens if there is punctuation at the end of a line), and increment the word count for the words in the line. + + +``` +{ +        for (i = 1; i <= NF; i++) { +                if ($i != "") { +                        words[$i]++; +                } +        } +} +``` + +Finally, after the text is processed, use the END function to print the contents of the array, then use awk's capability of piping output into a shell command to do a numerical sort and print the 20 most frequently occurring words: + + +``` +END { +        sort_head = "sort -k2 -nr | head -n 20"; +        for (word in words) { +                printf "%s\t%d\n", word, words[word] | sort_head; +        } +        close (sort_head); +} +``` + +Running this script on an earlier draft of this article produced this output: + + +``` +[[dneary@dhcp-49-32.bos.redhat.com][7]]$ awk -f wordcount.awk < awk_article.txt +the     79 +awk     41 +a       39 +and     33 +of      32 +in      27 +to      26 +is      25 +line    23 +for     23 +will    22 +file    21 +we      16 +We      15 +with    12 +which   12 +by      12 +this    11 +output  11 +function        11 +``` + +### What's next? + +If you want to learn more about awk programming, I strongly recommend the book [_Sed and awk_][8] by Dale Dougherty and Arnold Robbins. + +One of the keys to progressing in awk programming is mastering "extended regular expressions." Awk offers several powerful additions to the sed [regular expression][9] syntax you may already be familiar with. + +Another great resource for learning awk is the [GNU awk user guide][10]. It has a full reference for awk's built-in function library, as well as lots of examples of simple and complex awk scripts. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/advanced-awk + +作者:[Dave Neary][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/dneary +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_hands_team_collaboration.png?itok=u82QepPk (a checklist for a team) +[2]: mailto:pc@event.org +[3]: mailto:hpotter@hogwarts.edu +[4]: mailto:reacher@covert.mil +[5]: mailto:mmouse@disney.com +[6]: mailto:sclaus@northpole.org +[7]: mailto:dneary@dhcp-49-32.bos.redhat.com +[8]: https://www.amazon.com/sed-awk-Dale-Dougherty/dp/1565922255/book +[9]: https://en.wikibooks.org/wiki/Regular_Expressions/POSIX-Extended_Regular_Expressions +[10]: https://www.gnu.org/software/gawk/manual/gawk.html diff --git a/sources/tech/20191031 Looping your way through bash.md b/sources/tech/20191031 Looping your way through bash.md new file mode 100644 index 0000000000..f53d3c8089 --- /dev/null +++ b/sources/tech/20191031 Looping your way through bash.md @@ -0,0 +1,236 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Looping your way through bash) +[#]: via: (https://www.networkworld.com/article/3449116/looping-your-way-through-bash.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +Looping your way through bash +====== +There are many ways to loop through data in a bash script and on the command line. Which way is best depends on what you're trying to do. +[Alan Levine / Flickr][1] [(CC BY 2.0)][2] + +There are a lot of options for looping in bash whether on the command line or in a script. The choice depends on what you're trying to do. + +You may want to loop indefinitely or quickly run through the days of the week. You might want to loop once for every file in a directory or for every account on a server. You might want to loop through every line in a file or have the number of loops be a choice when the script is run. Let's check out some of the options. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][3] + +### Simple loops + +Probably the simplest loop is a **for** loop like the one below. It loops as many times as there are pieces of text on the line. We could as easily loop through the words **cats are smart** as the numbers 1, 2, 3 and 4. + +[][4] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][4] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +``` +#!/bin/bash + +for num in 1 2 3 4 +do + echo $num +done +``` + +And, to prove it, here's a similar loop run on the command line: + +``` +$ for word in cats are smart +> do +> echo $word +> done +cats +are +smart +``` + +### for vs while + +Bash provides both a **for** and a **while** looping command. In **while** loops, some condition is tested each time through the loop to determine whether the loop should continue. This example is practically the same as the one before in how it works, but imagine what a difference it would make if we wanted to loop 444 times instead of just 4. + +``` +#!/bin/bash + +n=1 + +while [ $n -le 4 ] +do + echo $n + ((n++)) +done +``` + +### Looping through value ranges + +If you want to loop through every letter of the alphabet or some more restricted range of letters, you can use syntax like this: + +``` +#!/bin/bash + +for x in {a..z} +do + echo $x +done +``` + +If you used **{d..f}**, you would only loop three times. + +### Looping inside loops + +There's also nothing stopping you from looping inside a loop. In this example, we're using a **for** loop inside a **while** loop. + +``` +#!/bin/bash + +n=1 + +while [ $n -lt 6 ] +do + for l in {a..d} + do + echo $n$l + done + ((n++)) +done +``` + +The output would in this example include 1a, 1b, 1c, 1d, 2a and so on, ending at 5d. Note that **((n++))** is used to increment the value of $n so that **while** has a stopping point. + +### Looping through variable data + +If you want to loop through every account on the system, every file in a directory or some other kind of variable data, you can issue a command within your loop to generate the list of values to loop through. In this example, we loop through every account (actually every file) in **/home** – assuming, as we should expect, that there are no other files or directories in **/home**. + +``` +#!/bin/bash + +for user in `ls /home` +do + echo $user +done +``` + +If the command were **date** instead of **ls /home**, we'd run through each of the 7 pieces of text in the output of the date command. + +``` +$ for word in `date` +> do +> echo $word +> done +Thu +31 +Oct +2019 +11:59:59 +PM +EDT +``` + +### Looping by request + +It's also very easy to allow the person running the script to determine how many times a loop should run. If you want to do this, however, you should test the response provided to be sure that it's numeric. This example shows three ways to do that. + +``` +#!/bin/bash + +echo -n "How many times should I say hello? " +read ans + +if [ "$ans" -eq "$ans" ]; then + echo ok1 +fi + +if [[ $ans = *[[:digit:]]* ]]; then + echo ok2 +fi + +if [[ "$ans" =~ ^[0-9]+$ ]]; then + echo ok3 +fi +``` + +The first option above shown might look a little odd, but it works because the **-eq** test only works if the values being compared are numeric. If the test came down to asking if **"f" -eq "f"**, it would fail. The second test uses the bash character class for digits. The third tests the variable to ensure that it contains only digits. + +Of course, once you've selected how you prefer to test a user response to be sure that it's numeric, you need to follow through on the loop. In this next example, we'll print "hello" as many times as the user wants to see it. The **le** does a "less than or equal" test. + +``` +#!/bin/bash + +echo -n "How many times should I say hello? " +read ans + +if [ "$ans" -eq "$ans" ]; then + n=1 + while [ $n -le $ans ] + do + echo hello + ((n++)) + done +fi +``` + +### Looping through the lines in a file + +If you want to loop through the contents of a file line by line (i.e., NOT word by word), you can use a loop like this one: + +``` +#!/bin/bash + +echo -n "File> " +read file +n=0 + +while read line; do + ((n++)) + echo "$n: $line" +done < $file +``` + +The word "line" used in the above script is for clarity, but you could use any variable name. The **while read** and the redirection of the file content on the last line of the script is what provides the line-by-line reading. + +### Looping forever + +If you want to loop forever or until, well, someone gets tired of seeing the script's output and decides to kill it, you can simple use the **while true** syntax. + +``` +#!/bin/bash + +while true +do + echo -n "Still running at " + date + sleep 10 +done +``` + +The examples shown above are basically only (excuse the pun) "shells" for the kind of real work that you might need to do and are meant simply to provide the basic syntax for running undoubtedly far more useful commands. + +### Now see: + +Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3449116/looping-your-way-through-bash.html + +作者:[Sandra Henry-Stocker][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.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.flickr.com/photos/cogdog/7778741378/in/photolist-cRo5NE-8HFUGG-e1kzG-4TFXrc-D3mM8-Lzx7h-LzGRB-fN3CY-LzwRo-8mWuUB-2jJ2j8-AABU8-eNrDET-eND7Nj-eND6Co-pNq3ZR-3bndB2-dNobDn-3brHfC-eNrSXv-4z4dNn-R1i2P5-eNDvyQ-agaw5-eND55q-4KQnc9-eXg6mo-eNscpF-eNryR6-dTGEqg-8uq9Wm-eND54j-eNrKD2-cynYp-eNrJsk-eNCSSj-e9uAD5-25xTWb-eNrJ3e-eNCW8s-7nKXtJ-5URF1j-8Y253Z-oaNVEQ-4AUK9b-6SJiLP-7GL54w-25yEqLa-fN3gL-dEgidW +[2]: https://creativecommons.org/licenses/by/2.0/legalcode +[3]: https://www.networkworld.com/newsletters/signup.html +[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20191101 Awk one-liners and scripts to help you sort text files.md b/sources/tech/20191101 Awk one-liners and scripts to help you sort text files.md new file mode 100644 index 0000000000..2ce53e1d7e --- /dev/null +++ b/sources/tech/20191101 Awk one-liners and scripts to help you sort text files.md @@ -0,0 +1,254 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Awk one-liners and scripts to help you sort text files) +[#]: via: (https://opensource.com/article/19/11/how-sort-awk) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Awk one-liners and scripts to help you sort text files +====== +Awk is a powerful tool for doing tasks that might otherwise be left to +other common utilities, including sort. +![Green graph of measurements][1] + +Awk is the ubiquitous Unix command for scanning and processing text containing predictable patterns. However, because it features functions, it's also justifiably called a programming language. + +Confusingly, there is more than one awk. (Or, if you believe there can be only one, then there are several clones.) There's **awk**, the original program written by Aho, Weinberger, and Kernighan, and then there's **nawk**, **mawk**, and the GNU version, **gawk**. The GNU version of awk is a highly portable, free software version of the utility with several unique features, so this article is about GNU awk. + +While its official name is gawk, on GNU+Linux systems it's aliased to awk and serves as the default version of that command. On other systems that don't ship with GNU awk, you must install it and refer to it as gawk, rather than awk. This article uses the terms awk and gawk interchangeably. + +Being both a command and a programming language makes awk a powerful tool for tasks that might otherwise be left to **sort**, **cut**, **uniq**, and other common utilities. Luckily, there's lots of room in open source for redundancy, so if you're faced with the question of whether or not to use awk, the answer is probably a solid "maybe." + +The beauty of awk's flexibility is that if you've already committed to using awk for a task, then you can probably stay in awk no matter what comes up along the way. This includes the eternal need to sort data in a way other than the order it was delivered to you. + +### Sample set + +Before exploring awk's sorting methods, generate a sample dataset to use. Keep it simple so that you don't get distracted by edge cases and unintended complexity. This is the sample set this article uses: + + +``` +Aptenodytes;forsteri;Miller,JF;1778;Emperor +Pygoscelis;papua;Wagler;1832;Gentoo +Eudyptula;minor;Bonaparte;1867;Little Blue +Spheniscus;demersus;Brisson;1760;African +Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed +Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper +Torvaldis;linux;Ewing,L;1996;Tux +``` + +It's a small dataset, but it offers a good variety of data types: + + * A genus and species name, which are associated with one another but considered separate + * A surname, sometimes with first initials after a comma + * An integer representing a date + * An arbitrary term + * All fields separated by semi-colons + + + +Depending on your educational background, you may consider this a 2D array or a table or just a line-delimited collection of data. How you think of it is up to you, because awk doesn't expect anything more than text. It's up to you to tell awk how you want to parse it. + +### The sort cheat + +If you just want to sort a text dataset by a specific, definable field (think of a "cell" in a spreadsheet), then you can use the [sort command][2]. + +### Fields and records + +Regardless of the format of your input, you must find patterns in it so that you can focus on the parts of the data that are important to you. In this example, the data is delimited by two factors: lines and fields. Each new line represents a new _record_, as you would likely see in a spreadsheet or database dump. Within each line, there are distinct _fields_ (think of them as cells in a spreadsheet) that are separated by semicolons (;). + +Awk processes one record at a time, so while you're structuring the instructions you will give to awk, you can focus on just one line. Establish what you want to do with one line, then test it (either mentally or with awk) on the next line and a few more. You'll end up with a good hypothesis on what your awk script must do in order to provide you with the data structure you want. + +In this case, it's easy to see that each field is separated by a semicolon. For simplicity's sake, assume you want to sort the list by the very first field of each line. + +Before you can sort, you must be able to focus awk on just the first field of each line, so that's the first step. The syntax of an awk command in a terminal is **awk**, followed by relevant options, followed by your awk command, and ending with the file of data you want to process. + + +``` +$ awk --field-separator=";" '{print $1;}' penguins.list +Aptenodytes +Pygoscelis +Eudyptula +Spheniscus +Megadyptes +Eudyptes +Torvaldis +``` + +Because the field separator is a character that has special meaning to the Bash shell, you must enclose the semicolon in quotes or precede it with a backslash. This command is useful only to prove that you can focus on a specific field. You can try the same command using the number of another field to view the contents of another "column" of your data: + + +``` +$ awk --field-separator=";" '{print $3;}' penguins.list +Miller,JF +Wagler +Bonaparte +Brisson +Milne-Edwards +Viellot +Ewing,L +``` + +Nothing has been sorted yet, but this is good groundwork. + +### Scripting + +Awk is more than just a command; it's a programming language with indices and arrays and functions. That's significant because it means you can grab a list of fields you want to sort by, store the list in memory, process it, and then print the resulting data. For a complex series of actions such as this, it's easier to work in a text file, so create a new file called **sort.awk** and enter this text: + + +``` +#!/bin/gawk -f + +BEGIN { +        FS=";"; +} +``` + +This establishes the file as an awk script that executes the lines contained in the file. + +The **BEGIN** statement is a special setup function provided by awk for tasks that need to occur only once. Defining the built-in variable **FS**, which stands for _field separator_ and is the same value you set in your awk command with **\--field-separator**, only needs to happen once, so it's included in the **BEGIN** statement. + +#### Arrays in awk + +You already know how to gather the values of a specific field by using the **$** notation along with the field number, but in this case, you need to store it in an array rather than print it to the terminal. This is done with an awk array. The important thing about an awk array is that it contains keys and values. Imagine an array about this article; it would look something like this: **author:"seth",title:"How to sort with awk",length:1200**. Elements like **author** and **title** and **length** are keys, with the following contents being values. + +The advantage to this in the context of sorting is that you can assign any field as the key and any record as the value, and then use the built-in awk function **asorti()** (sort by index) to sort by the key. For now, assume arbitrarily that you _only_ want to sort by the second field. + +Awk statements _not_ preceded by the special keywords **BEGIN** or **END** are loops that happen at each record. This is the part of the script that scans the data for patterns and processes it accordingly. Each time awk turns its attention to a record, statements in **{}** (unless preceded by **BEGIN** or **END**) are executed. + +To add a key and value to an array, create a variable (in this example script, I call it **ARRAY**, which isn't terribly original, but very clear) containing an array, and then assign it a key in brackets and a value with an equals sign (**=**). + + +``` +{   # dump each field into an array +    ARRAY[$2] = $R; +} +``` + +In this statement, the contents of the second field (**$2**) are used as the key term, and the current record (**$R**) is used as the value. + +### The asorti() function + +In addition to arrays, awk has several basic functions that you can use as quick and easy solutions for common tasks. One of the functions introduced in GNU awk, **asorti()**, provides the ability to sort an array by key (or _index_) or value. + +You can only sort the array once it has been populated, meaning that this action must not occur with every new record but only the final stage of your script. For this purpose, awk provides the special **END** keyword. The inverse of **BEGIN**, an **END** statement happens only once and only after all records have been scanned. + +Add this to your script: + + +``` +END { +    asorti(ARRAY,SARRAY); +    # get length +    j = length(SARRAY); +    +    for (i = 1; i <= j; i++) { +        printf("%s %s\n", SARRAY[i],ARRAY[SARRAY[i]]) +    } +} +``` + +The **asorti()** function takes the contents of **ARRAY**, sorts it by index, and places the results in a new array called **SARRAY** (an arbitrary name I invented for this article, meaning _Sorted ARRAY_). + +Next, the variable **j** (another arbitrary name) is assigned the results of the **length()** function, which counts the number of items in **SARRAY**. + +Finally, use a **for** loop to iterate through each item in **SARRAY** using the **printf()** function to print each key, followed by the corresponding value of that key in **ARRAY**. + +### Running the script + +To run your awk script, make it executable: + + +``` +`$ chmod +x sorter.awk` +``` + +And then run it against the **penguin.list** sample data: + + +``` +$ ./sorter.awk penguins.list +antipodes Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed +chrysocome Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper +demersus Spheniscus;demersus;Brisson;1760;African +forsteri Aptenodytes;forsteri;Miller,JF;1778;Emperor +linux Torvaldis;linux;Ewing,L;1996;Tux +minor Eudyptula;minor;Bonaparte;1867;Little Blue +papua Pygoscelis;papua;Wagler;1832;Gentoo +``` + +As you can see, the data is sorted by the second field. + +This is a little restrictive. It would be better to have the flexibility to choose at runtime which field you want to use as your sorting key so you could use this script on any dataset and get meaningful results. + +### Adding command options + +You can add a command variable to an awk script by using the literal value **var** in your script. Change your script so that your iterative clause uses **var** when creating your array: + + +``` +{ # dump each field into an array +    ARRAY[$var] = $R; +} +``` + +Try running the script so that it sorts by the third field by using the **-v var** option when you execute it: + + +``` +$ ./sorter.awk -v var=3 penguins.list +Bonaparte Eudyptula;minor;Bonaparte;1867;Little Blue +Brisson Spheniscus;demersus;Brisson;1760;African +Ewing,L Torvaldis;linux;Ewing,L;1996;Tux +Miller,JF Aptenodytes;forsteri;Miller,JF;1778;Emperor +Milne-Edwards Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed +Viellot Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper +Wagler Pygoscelis;papua;Wagler;1832;Gentoo +``` + +### Fixes + +This article has demonstrated how to sort data in pure GNU awk. The script can be improved so, if it's useful to you, spend some time researching [awk functions][3] on gawk's man page and customizing the script for better output. + +Here is the complete script so far: + + +``` +#!/usr/bin/awk -f +# GPLv3 appears here +# usage: ./sorter.awk -v var=NUM FILE + +BEGIN { FS=";"; } + +{ # dump each field into an array +    ARRAY[$var] = $R; +} + +END { +    asorti(ARRAY,SARRAY); +    # get length +    j = length(SARRAY); +    +    for (i = 1; i <= j; i++) { +        printf("%s %s\n", SARRAY[i],ARRAY[SARRAY[i]]) +    } +} +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/how-sort-awk + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_lead-steps-measure.png?itok=DG7rFZPk (Green graph of measurements) +[2]: https://opensource.com/article/19/10/get-sorted-sort +[3]: https://www.gnu.org/software/gawk/manual/html_node/Built_002din.html#Built_002din diff --git a/sources/tech/20191104 How to Add Windows and Linux host to Nagios Server for Monitoring.md b/sources/tech/20191104 How to Add Windows and Linux host to Nagios Server for Monitoring.md new file mode 100644 index 0000000000..6f49e48f98 --- /dev/null +++ b/sources/tech/20191104 How to Add Windows and Linux host to Nagios Server for Monitoring.md @@ -0,0 +1,308 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Add Windows and Linux host to Nagios Server for Monitoring) +[#]: via: (https://www.linuxtechi.com/add-windows-linux-host-to-nagios-server/) +[#]: author: (James Kiarie https://www.linuxtechi.com/author/james/) + +How to Add Windows and Linux host to Nagios Server for Monitoring +====== + +In the previous article, we demonstrated how to install [Nagios Core on CentOS 8 / RHEL 8][1] server. In this guide, we will dive deeper and add Linux and Windows hosts to the Nagios Core server for monitoring. + +![Add-Linux-Windows-Host-Nagios-Server][2] + +### Adding a Remote Windows Host to Nagios Server + +In this section, you will learn how to add a **Windows host** system to the **Nagios server**. For this to be possible, you need to install **NSClient++** agent on the Windows Host system. In this guide, we are going to install the NSClient++ on a Windows Server 2019 Datacenter edition. + +On the Windows host system,  head out to the download link as specified and download NSClient ++ agent. + +Once downloaded, double click on the downloaded installation file to launch the installation wizard. + +[![NSClient-installer-Windows][2]][3] + +On the first step on the installation procedure click ‘**Next**’ + +[![click-nex-to-install-NSClient][2]][4] + +In the next section, check off the ‘**I accept the terms in the license Agreement**’ checkbox and click ‘**Next**’ + +[![Accept-terms-conditions-NSClient][2]][5] + +Next, click on the ‘**Typical**’ option from the list of options and click ‘**Next**’ + +[![click-on-Typical-option-NSClient-Installation][2]][6] + +In the next step, leave the default settings as they are and click ‘**Next**’. + +[![Define-path-NSClient-Windows][2]][7] + +On the next page, specify your Nagios Server core’s IP address and tick off all the modules and click ‘**Next**’ as shown below. + +[![Specify-Nagios-Server-IP-address-NSClient-Windows][2]][8] + +Next, click on the ‘**Install**’ option to commence the installation process.[![Click-install-to-being-the-installation-NSClient][2]][9] + +The installation process will start and will take a couple of seconds to complete. On the last step. Click ‘**Finish**’ to complete the installation and exit the Wizard. + +[![Click-finish-NSClient-Windows][2]][10] + +To start the NSClient service, click on the **Start** menu and click on the ‘**Start NSClient ++**’ option. + +[![Click-start-NSClient-service-windows][2]][11] + +To confirm that indeed the service is running, press **Windows Key + R**, type services.msc and hit **ENTER**. Scroll and search for the **NSClient** service and ensure it’s running + +[![NSClient-running-windows][2]][12] + +At this point, we have successfully installed NSClient++ on Windows Server 2019 host and verified that it’s running. + +### Configure Nagios Server to monitor Windows host + +After the successful installation of the NSClient ++ on the Windows host PC, log in to the Nagios server Core system and configure it to monitor the Windows host system. + +Open the windows.cfg file using your favorite text editor + +``` +# vim /usr/local/nagios/etc/objects/windows.cfg +``` + +In the configuration file, ensure that the host_name attribute matches the hostname of your Windows client system. In our case, the hostname for the Windows server PC is windows-server. This hostname should apply for all the host_name attributes. + +For the address attribute, specify your Windows host IP address. , In our case, this was 10.128.0.52. + +![Specify-hostname-IP-Windows][2] + +After you are done, save the changes and exit the text editor. + +Next, open the Nagios configuration file. + +``` +# vim /usr/local/nagios/etc/nagios.cfg +``` + +Uncomment the line below and save the changes. + +cfg_file=/usr/local/nagios/etc/objects/windows.cfg + +![Uncomment-Windows-cfg-Nagios][2] + +Finally, to verify that Nagios configuration is free from any errors, run the command: + +``` +# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg +``` + +Output + +![Verify-configuration-for-errors-Nagios][2] + +As you can see from the output, there are no warnings or errors. + +Now browse your Nagios Server IP address, log in and click on Hosts. Your Windows hostname, in this case, windows-server will appear on the dashboard. + +![Windows-Host-added-Nagios][2] + +### Adding a remote Linux Host to Nagios Server + +Having added a Windows host to the Nagios server, let’s add a Linux host system. In our case, we are going to add a **Ubuntu 18.04 LTS** to the Nagios monitoring server. To monitor a Linux host, we need to install an agent on the remote Linux system called **NRPE**. NRPE is short for **Nagios Remote Plugin Executor**. This is the plugin that will allow you to monitor Linux host systems. It allows you to monitor resources such as Swap, memory usage, and CPU load to mention a few on remote Linux hosts. So the first step is to install NRPE on Ubuntu 18.04 LTS remote system. + +But first, update Ubuntu system + +``` +# sudo apt update +``` + +Next,  install Nagios NRPE by running the command as shown: + +``` +# sudo apt install nagios-nrpe-server nagios-plugins +``` + +![Install-nrpe-server-nagios-plugins][2] + +After the successful installation of  NRPE and Nagios plugins, configure NRPE by opening its configuration file in /etc/nagios/nrpe.cfg + +``` +# vim /etc/nagios/nrpe.cfg +``` + +Append the Linux host IP address to the **server_address** attribute. In this case, 10.128.0.53 is the IP address of the Ubuntu 18.04 LTS system. + +![Specify-server-address-Nagios][2] + +Next, add Nagios server IP address in the ‘allowed_hosts’ attribute, in this case, 10.128.0.50 + +![Allowed-hosts-Nagios][2] + +Save and exit the configuration file. + +Next, restart NRPE service and verify its status + +``` +# systemctl restart nagios-nrpe-server +# systemctl enable nagios-nrpe-server +# systemctl status nagios-nrpe-server +``` + +![Restart-nrpe-check-status][2] + +### Configure Nagios Server to monitor Linux host + +Having successfully installed NRPE and nagios plugins on the remote linux server, log in to Nagios Server and install EPEL (Extra packages for Enterprise Linux) package. + +``` +# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm +``` + +Next, install NRPE plugin on the server + +``` +# dnf install nagios-plugins-nrpe -y +``` + +After the installation of the NRPE plugin, open the Nagios configuration file “/usr/local/nagios/etc/nagios.cfg” + +``` +# vim /usr/local/nagios/etc/nagios.cfg +``` + +Next, uncomment the line below in the configuration file + +cfg_dir=/usr/local/nagios/etc/servers + +![uncomment-servers-line-Nagios-Server-CentOS8][2] + +Next, create a configuration directory + +``` +# mkdir /usr/local/nagios/etc/servers +``` + +Then create client configuration file + +``` +# vim /usr/local/nagios/etc/servers/ubuntu-host.cfg +``` + +Copy and paste the configuration below to the file. This configuration monitors swap space, system load, total processes, logged in users, and disk usage. + +``` +define host{ + use linux-server + host_name ubuntu-nagios-client + alias ubuntu-nagios-client + address 10.128.0.53 + +} + +define hostgroup{ + hostgroup_name linux-server + alias Linux Servers + members ubuntu-nagios-client +} + +define service{ + use local-service + host_name ubuntu-nagios-client + service_description SWAP Uasge + check_command check_nrpe!check_swap + +} + +define service{ + use local-service + host_name ubuntu-nagios-client + service_description Root / Partition + check_command check_nrpe!check_root + +} + +define service{ + use local-service + host_name ubuntu-nagios-client + service_description Current Users + check_command check_nrpe!check_users +} + +define service{ + use local-service + host_name ubuntu-nagios-client + service_description Total Processes + check_command check_nrpe!check_total_procs +} + +define service{ + use local-service + host_name ubuntu-nagios-client + service_description Current Load + check_command check_nrpe!check_load +} +``` + +Save and exit the configuration file. + +Next, verify that there are no errors in Nagios configuration + +``` +# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg +``` + +Now restart Nagios service and ensure that it is up and running. + +``` +# systemctl restart nagios +``` + +Remember to open port 5666 which is used by NRPE plugin on the firewall of the Nagios server. + +``` +# firewall-cmd --permanent --add-port=5666/tcp +# firewall-cmd --reload +``` + +![Allow-firewall-Nagios-server][2] + +Likewise, head out to your Linux host (Ubuntu 18.04 LTS) and allow the port on UFW firewall + +``` +# ufw allow 5666/tcp +# ufw reload +``` + +![Allow-NRPE-service][2] + +Finally, head out to the Nagios Server’s URL and click on ‘**Hosts**’. Your Ubuntu system will be displayed on the dashboard alongside the Windows host machine we added earlier on. + +![Linux-host-added-monitored-Nagios][2] + +And this wraps up our 2-part series on Nagios installation and adding remote hosts. Feel free to get back to us with your feedback. + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/add-windows-linux-host-to-nagios-server/ + +作者:[James Kiarie][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.linuxtechi.com/author/james/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/install-nagios-core-rhel-8-centos-8/ +[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/11/NSClient-installer-Windows.jpg +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/11/click-nex-to-install-NSClient.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Accept-terms-conditions-NSClient.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/11/click-on-Typical-option-NSClient-Installation.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Define-path-NSClient-Windows.png +[8]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Specify-Nagios-Server-IP-address-NSClient-Windows.jpg +[9]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Click-install-to-being-the-installation-NSClient.jpg +[10]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Click-finish-NSClient-Windows.jpg +[11]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Click-start-NSClient-service-windows.jpg +[12]: https://www.linuxtechi.com/wp-content/uploads/2019/11/NSClient-running-windows.jpg diff --git a/sources/tech/20191106 An introduction to monitoring with Prometheus.md b/sources/tech/20191106 An introduction to monitoring with Prometheus.md new file mode 100644 index 0000000000..4a6db0757f --- /dev/null +++ b/sources/tech/20191106 An introduction to monitoring with Prometheus.md @@ -0,0 +1,434 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (An introduction to monitoring with Prometheus) +[#]: via: (https://opensource.com/article/19/11/introduction-monitoring-prometheus) +[#]: author: (Yuri Grinshteyn https://opensource.com/users/yuri-grinshteyn) + +An introduction to monitoring with Prometheus +====== +Prometheus is a popular and powerful toolkit to monitor Kubernetes. This +is a tutorial on how to get started. +![Wheel of a ship][1] + +[Metrics are the primary way][2] to represent both the overall health of your system and any other specific information you consider important for monitoring and alerting or observability. [Prometheus][3] is a leading open source metric instrumentation, collection, and storage toolkit [built at SoundCloud][4] beginning in 2012. Since then, it's [graduated][5] from the Cloud Native Computing Foundation and become the de facto standard for Kubernetes monitoring. It has been covered in some detail in: + + * [Getting started with Prometheus][6] + * [5 examples of Prometheus monitoring success][7] + * [Achieve high-scale application monitoring with Prometheus][8] + * [Tracking the weather with Python and Prometheus][9] + + + +However, none of these articles focus on how to use Prometheus on Kubernetes. This article: + + * Describes the Prometheus architecture and data model to help you understand how it works and what it can do + * Provides a tutorial on setting Prometheus up in a Kubernetes cluster and using it to monitor clusters and applications + + + +### Architecture + +While knowing how Prometheus works may not be essential to using it effectively, it can be helpful, especially if you're considering using it for production. The [Prometheus documentation][10] provides this graphic and details about the essential elements of Prometheus and how the pieces connect together. + +[![Prometheus architecture][11]][10] + +For most use cases, you should understand three major components of Prometheus: + + 1. The Prometheus **server** scrapes and stores metrics. Note that it uses a **persistence** layer, which is part of the server and not expressly mentioned in the documentation. Each node of the server is autonomous and does not rely on distributed storage. I'll revisit this later when looking to use a dedicated time-series database to store Prometheus data, rather than relying on the server itself. + 2. The web **UI** allows you to access, visualize, and chart the stored data. Prometheus provides its own UI, but you can also configure other visualization tools, like [Grafana][12], to access the Prometheus server using PromQL (the Prometheus Query Language). + 3. **Alertmanager** sends alerts from client applications, especially the Prometheus server. It has advanced features for deduplicating, grouping, and routing alerts and can route through other services like PagerDuty and OpsGenie. + + + +The key to understanding Prometheus is that it fundamentally relies on **scraping**, or pulling, metrics from defined endpoints. This means that your application needs to expose an endpoint where metrics are available and instruct the Prometheus server how to scrape it (this is covered in the tutorial below). There are [exporters][13] for many applications that do not have an easy way to add web endpoints, such as [Kafka][14] and [Cassandra][15] (using the JMX exporter). + +### Data model + +Now that you understand how Prometheus works to scrape and store metrics, the next thing to learn is the kinds of metrics Prometheus supports. Some of the following information (noted with quotation marks) comes from the [metric types][16] section of the Prometheus documentation. + +#### Counters and gauges + +The two simplest metric types are **counter** and **gauge**. When getting started with Prometheus (or with time-series monitoring more generally), these are the easiest types to understand because it's easy to connect them to values you can imagine monitoring, like how much system resources your application is using or how many events it has processed. + +> "A **counter** is a cumulative metric that represents a single monotonically increasing counter whose value can only **increase** or be **reset** to zero on restart. For example, you can use a counter to represent the number of requests served, tasks completed, or errors." + +Because you cannot decrease a counter, it can and should be used only to represent cumulative metrics. + +> "A **gauge** is a metric that represents a single numerical value that can arbitrarily go up and down. Gauges are typically used for measured values like [CPU] or current memory usage, but also 'counts' that can go up and down, like the number of concurrent requests." + +#### Histograms and summaries + +Prometheus supports two more complex metric types: [**histograms**][17] [and][17] [**summaries**][17]. There is ample opportunity for confusion here, given that they both track the number of observations _and_ the sum of observed values. One of the reasons you might choose to use them is that you need to calculate an average of the observed values. Note that they create multiple time series in the database; for example, they each create a sum of the observed values with a **_sum** suffix. + +> "A **histogram** samples observations (usually things like request durations or response sizes) and counts them in configurable buckets. It also provides a sum of all observed values." + +This makes it an excellent candidate to track things like latency that might have a service level objective (SLO) defined against it. From the [documentation][17]: + +> You might have an SLO to serve 95% of requests within 300ms. In that case, configure a histogram to have a bucket with an upper limit of 0.3 seconds. You can then directly express the relative amount of requests served within 300ms and easily alert if the value drops below 0.95. The following expression calculates it by job for the requests served in the last 5 minutes. The request durations were collected with a histogram called **http_request_duration_seconds**. +> +> [code]`sum(rate(http_request_duration_seconds_bucket{le="0.3"}[5m])) by (job) / sum(rate(http_request_duration_seconds_count[5m])) by (job)` +``` +> +>   + +Returning to definitions: + +> "Similar to a histogram, a **summary** samples observations (usually things like request durations and response sizes). While it also provides a total count of observations and a sum of all observed values, it calculates configurable quantiles over a sliding time window." + +The essential difference between summaries and histograms is that summaries calculate streaming φ-quantiles on the client-side and expose them directly, while histograms expose bucketed observation counts, and the calculation of quantiles from the buckets of a histogram happens on the server-side using the **histogram_quantile()** function. + +If you are still confused, I suggest taking the following approach: + + * Use gauges most of the time for straightforward time-series metrics. + * Use counters for things you know to increase monotonically, e.g., if you are counting the number of times something happens. + * Use histograms for latency measurements with simple buckets, e.g., one bucket for "under SLO" and another for "over SLO." + + + +This should be sufficient for the overwhelming majority of use cases, and you should rely on a statistical analysis expert to help you with more advanced scenarios. + +Now that you have a basic understanding of what Prometheus is, how it works, and the kinds of data it can collect and store, you're ready to begin the tutorial. + +## Prometheus and Kubernetes hands-on tutorial + +This tutorial covers the following: + + * Installing Prometheus in your cluster + * Downloading the sample application and reviewing the code + * Building and deploying the app and generating load against it + * Accessing the Prometheus UI and reviewing the basic metrics + + + +This tutorial assumes: + + * You already have a Kubernetes cluster deployed. + * You have configured the **kubectl** command-line utility for access. + * You have the **cluster-admin** role (or at least sufficient privileges to create namespaces and deploy applications). + * You are running a Bash-based command-line interface. Adjust this tutorial if you run other operating systems or shell environments. + + + +If you don't have Kubernetes running yet, this [Minikube tutorial][18] is an easy way to set it up on your laptop. + +If you're ready now, let's go. + +### Install Prometheus + +In this section, you will clone the sample repository and use Kubernetes' configuration files to deploy Prometheus to a dedicated namespace. + + 1. Clone the sample repository locally and use it as your working directory: [code] $ git clone +$ cd  prometheus-demo +$ WORKDIR=$(pwd) +``` + 2. Create a dedicated namespace for the Prometheus deployment: [code]`$ kubectl create namespace prometheus` +``` + 3. Give your namespace the cluster reader role: [code] $ kubectl apply -f $WORKDIR/kubernetes/clusterRole.yaml +clusterrole.rbac.authorization.k8s.io/prometheus created +clusterrolebinding.rbac.authorization.k8s.io/prometheus created +``` + 4. Create a Kubernetes configmap with scraping and alerting rules: [code] $ kubectl apply -f $WORKDIR/kubernetes/configMap.yaml -n prometheus +configmap/prometheus-server-conf created +``` + 5. Deploy Prometheus: [code] $ kubectl create -f prometheus-deployment.yaml -n prometheus +deployment.extensions/prometheus-deployment created +``` + 6. Validate that Prometheus is running: [code] $ kubectl get pods -n prometheus +NAME                                     READY   STATUS    RESTARTS   AGE +prometheus-deployment-78fb5694b4-lmz4r   1/1     Running   0          15s +``` +### Review basic metrics + +In this section, you'll access the Prometheus UI and review the metrics being collected. + + 1. Use port forwarding to enable web access to the Prometheus UI locally: +**Note:** Your **prometheus-deployment** will have a different name than this example. Review and replace the name of the pod from the output of the previous command. [code] $ kubectl port-forward prometheus-deployment-7ddb99dcb-fkz4d 8080:9090 -n prometheus +Forwarding from 127.0.0.1:8080 -> 9090 +Forwarding from [::1]:8080 -> 9090 +``` + + 2. Go to in a browser: +![Prometheus console][19] + +You are now ready to query Prometheus metrics! + + + + 3. Some basic machine metrics (like the number of CPU cores and memory) are available right away. For example, enter **machine_memory_bytes** in the expression field, switch to the Graph view, and click Execute to see the metric charted: + + + +![Prometheus metric channel][20] + + 4. Containers running in the cluster are also automatically monitored. For example, enter **rate(container_cpu_usage_seconds_total{container_name="prometheus"}[1m])** as the expression and click Execute to see the rate of CPU usage by Prometheus: + + + +![CPU usage metric][21] + +Now that you know how to install Prometheus and use it to measure some out-of-the-box metrics, it's time for some real monitoring. + +#### Golden signals + +As described in the "[Monitoring Distributed Systems][22]" chapter of [Google's SRE][23] book: + +> "The four golden signals of monitoring are latency, traffic, errors, and saturation. If you can only measure four metrics of your user-facing system, focus on these four." + +The book offers thorough descriptions of all four, but this tutorial focuses on the three signals that most easily serve as proxies for user happiness: + + * **Traffic:** How many requests you're receiving + * **Error rate:** How many of those requests you can successfully serve + * **Latency:** How quickly you can serve successful requests + + + +As you probably realize by now, Prometheus does not measure any of these for you; you'll have to instrument any application you deploy to emit them. Following is an example implementation. + +Open the **$WORKDIR/node/golden_signals/app.js** file, which is a sample application written in Node.js (recall we cloned **yuriatgoogle/prometheus-demo** and exported **$WORKDIR** earlier). Start by reviewing the first section, where the metrics to be recorded are defined: + + +``` +// total requests - counter +const nodeRequestsCounter = new prometheus.Counter({ +    name: 'node_requests', +    help: 'total requests' +}); +``` + +The first metric is a counter that will be incremented for each request; this is how the total number of requests is counted: + + +``` +// failed requests - counter +const nodeFailedRequestsCounter = new prometheus.Counter({ +    name: 'node_failed_requests', +    help: 'failed requests' +}); +``` + +The second metric is another counter that increments for each error to track the number of failed requests: + + +``` +// latency - histogram +const nodeLatenciesHistogram = new prometheus.Histogram({ +    name: 'node_request_latency', +    help: 'request latency by path', +    labelNames: ['route'], +    buckets: [100, 400] +}); +``` + +The third metric is a histogram that tracks request latency. Working with a very basic assumption that the SLO for latency is 100ms, you will create two buckets: one for 100ms and the other 400ms latency. + +The next section handles incoming requests, increments the total requests metric for each one, increments failed requests when there is an (artificially induced) error, and records a latency histogram value for each successful request. I have chosen not to record latencies for errors; that implementation detail is up to you. + + +``` +app.get('/', (req, res) => { +    // start latency timer +    const requestReceived = new Date().getTime(); +    console.log('request made'); +    // increment total requests counter +    nodeRequestsCounter.inc(); +    // return an error 1% of the time +    if ((Math.floor(Math.random() * 100)) == 100) { +        // increment error counter +        nodeFailedRequestsCounter.inc(); +        // return error code +        res.send("error!", 500); +    } +    else { +        // delay for a bit +        sleep.msleep((Math.floor(Math.random() * 1000))); +        // record response latency +        const responseLatency = new Date().getTime() - requestReceived; +        nodeLatenciesHistogram +            .labels(req.route.path) +            .observe(responseLatency); +        res.send("success in " + responseLatency + " ms"); +    } +}) +``` + +#### Test locally + +Now that you've seen how to implement Prometheus metrics, see what happens when you run the application. + + 1. Install the required packages: [code] $ cd $WORKDIR/node/golden_signals +$ npm install --save +``` +2. Launch the app: [code]`$ node app.js` +``` + 3. Open two browser tabs: one to and another to . + 4. When you go to the **/metrics** page, you can see the Prometheus metrics being collected and updated every time you reload the home page: + + + +![Prometheus metrics being collected][24] + +You're now ready to deploy the sample application to your Kubernetes cluster and test your monitoring. + +#### Deploy monitoring to Prometheus on Kubernetes + +Now it's time to see how metrics are recorded and represented in the Prometheus instance deployed in your cluster by: + + * Building the application image + * Deploying it to your cluster + * Generating load against the app + * Observing the metrics recorded + + + +##### Build the application image + +The sample application provides a Dockerfile you'll use to build the image. This section assumes that you have: + + * Docker installed and configured locally + * A Docker Hub account + * Created a repository + + + +If you're using Google Kubernetes Engine to run your cluster, you can use Cloud Build and the Google Container Registry instead. + + 1. Switch to the application directory: [code]`$ cd $WORKDIR/node/golden_signals` +``` +2. Build the image with this command: [code]`$ docker build . --tag=/prometheus-demo-node:latest` +``` + 3. Make sure you're logged in to Docker Hub: [code]`$ docker login` +``` +4. Push the image to Docker Hub using this command: [code]`$ docker push /prometheus-demo-node:latest` +``` + 5. Verify that the image is available: [code]`$ docker images` +``` +#### Deploy the application + +Now that the application image is in the Docker Hub, you can deploy it to your cluster and run the application. + + 1. Modify the **$WORKDIR/node/golden_signals/prometheus-demo-node.yaml** file to pull the image from Docker Hub: [code] spec: +      containers: +      - image: docker.io/<Docker username>/prometheus-demo-node:latest +``` + 2. Deploy the image: [code] $ kubectl apply -f $WORKDIR/node/golden_signals/prometheus-demo-node.yaml +deployment.extensions/prometheus-demo-node created +``` + 3. Verify that the application is running: [code] $ kubectl get pods +NAME                                    READY   STATUS    RESTARTS   AGE +prometheus-demo-node-69688456d4-krqqr   1/1     Running   0          65s +``` + 4. Expose the application using a load balancer: [code] $ kubectl expose deployment prometheus-node-demo --type=LoadBalancer --name=prometheus-node-demo --port=8080 +service/prometheus-demo-node exposed +``` + 5. Confirm that your service has an external IP address: [code] $ kubectl get services +NAME                   TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)          AGE +kubernetes             ClusterIP      10.39.240.1     <none>           443/TCP          23h +prometheus-demo-node   LoadBalancer   10.39.248.129   35.199.186.110   8080:31743/TCP   78m +``` + + + +##### Generate load to test monitoring + +Now that your service is up and running, generate some load against it by using [Apache Bench][25]. + + 1. Get the IP address of your service as a variable: [code]`$ export SERVICE_IP=$(kubectl get svc prometheus-demo-node -ojson | jq -r '.status.loadBalancer.ingress[].ip')` +``` +2. Use **ab** to generate some load. You may want to run this in a separate terminal window. [code]`$ ab -c 3 -n 1000 http://${SERVICE_IP}:8080/` +``` + + + +##### Review metrics + +While the load is running, access the Prometheus UI in the cluster again and confirm that the "golden signal" metrics are being collected. + + 1. Establish a connection to Prometheus: [code] + +$ kubectl get pods -n prometheus +NAME                                     READY   STATUS    RESTARTS   AGE +prometheus-deployment-78fb5694b4-lmz4r   1/1     Running   0          15s + +$ kubectl port-forward prometheus-deployment-78fb5694b4-lmz4r 8080:9090 -n prometheus +Forwarding from 127.0.0.1:8080 -> 9090 +Forwarding from [::1]:8080 -> 9090 + +``` +**Note:** Make sure to replace the name of the pod in the second command with the output of the first. + + 2. Open in a browser: + + + + +![Prometheus console][26] + + 3. Use this expression to measure the request rate: [code]`rate(node_requests[1m])` +``` + + + +![Measuring the request rate][27] + + 4. Use this expression to measure your error rate: [code]`rate(node_failed_requests[1m])` +``` +![Measuring the error rate][28] + + 5. Finally, use this expression to validate your latency SLO. Remember that you set up two buckets, 100ms and 400ms. This expression returns the percentage of requests that meet the SLO : [code]`sum(rate(node_request_latency_bucket{le="100"}[1h])) / sum(rate(node_request_latency_count[1h]))` +``` + + + +![SLO query graph][29] + +About 10% of the requests are within SLO. This is what you should expect since the code sleeps for a random number of milliseconds between 0 and 1,000. As such, about 10% of the time, it returns in more than 100ms, and this graph shows that you can't meet the latency SLO as a result. + +### Summary + +Congratulations! You've completed the tutorial and hopefully have a much better understanding of how Prometheus works, how to instrument your application with custom metrics, and how to use it to measure your SLO compliance. The next article in this series will look at another metric instrumentation approach using OpenCensus. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/introduction-monitoring-prometheus + +作者:[Yuri Grinshteyn][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/yuri-grinshteyn +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/kubernetes.png?itok=PqDGb6W7 (Wheel of a ship) +[2]: https://opensource.com/article/19/10/open-source-observability-kubernetes +[3]: https://prometheus.io/ +[4]: https://en.wikipedia.org/wiki/Prometheus_(software)#History +[5]: https://www.cncf.io/announcement/2018/08/09/prometheus-graduates/ +[6]: https://opensource.com/article/18/12/introduction-prometheus +[7]: https://opensource.com/article/18/9/prometheus-operational-advantage +[8]: https://opensource.com/article/19/10/application-monitoring-prometheus +[9]: https://opensource.com/article/19/4/weather-python-prometheus +[10]: https://prometheus.io/docs/introduction/overview/ +[11]: https://opensource.com/sites/default/files/uploads/prometheus-architecture.png (Prometheus architecture) +[12]: https://grafana.com/ +[13]: https://prometheus.io/docs/instrumenting/exporters/ +[14]: https://github.com/danielqsj/kafka_exporter +[15]: https://github.com/prometheus/jmx_exporter +[16]: https://prometheus.io/docs/concepts/metric_types/ +[17]: https://prometheus.io/docs/practices/histograms/ +[18]: https://opensource.com/article/18/10/getting-started-minikube +[19]: https://opensource.com/sites/default/files/uploads/prometheus-console.png (Prometheus console) +[20]: https://opensource.com/sites/default/files/uploads/prometheus-machine_memory_bytes.png (Prometheus metric channel) +[21]: https://opensource.com/sites/default/files/uploads/prometheus-cpu-usage.png (CPU usage metric) +[22]: https://landing.google.com/sre/sre-book/chapters/monitoring-distributed-systems/ +[23]: https://landing.google.com/sre/sre-book/toc/ +[24]: https://opensource.com/sites/default/files/uploads/prometheus-metrics-collected.png (Prometheus metrics being collected) +[25]: https://httpd.apache.org/docs/2.4/programs/ab.html +[26]: https://opensource.com/sites/default/files/uploads/prometheus-enable-query-history.png (Prometheus console) +[27]: https://opensource.com/sites/default/files/uploads/prometheus-request-rate.png (Measuring the request rate) +[28]: https://opensource.com/sites/default/files/uploads/prometheus-error-rate.png (Measuring the error rate) +[29]: https://opensource.com/sites/default/files/uploads/prometheus-slo-query.png (SLO query graph) diff --git a/sources/tech/20191107 A guide to open source for microservices.md b/sources/tech/20191107 A guide to open source for microservices.md new file mode 100644 index 0000000000..5731e85cf5 --- /dev/null +++ b/sources/tech/20191107 A guide to open source for microservices.md @@ -0,0 +1,309 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A guide to open source for microservices) +[#]: via: (https://opensource.com/article/19/11/microservices-cheat-sheet) +[#]: author: (Girish Managoli https://opensource.com/users/gammay) + +A guide to open source for microservices +====== +Build and manage high-scale microservices networks and solve the +challenges of running services without fault that scale based on +business demand. +![Text editor on a browser, in blue][1] + +Microservices—applications broken down into smaller, composable pieces that work together—are getting as much attention as the hottest new restaurant in town. (If you're not yet familiar, dive into [What Are Microservices][2] before continuing here.) + +However, if you have moved on from "Hello, World" and running a simple handful of microservices, and are building hundreds of microservices and running thousands of instances, you know there is nothing "micro" about them. You want your instances to increase when users increase and decrease when users decrease. You want to distribute requests effectively between instances. You want to build and run your services intelligently. You need a clear view of the service instances that are running or going down. How can you manage all of this complexity? + +This article looks at some of the key terminologies in the microservices ecosystem and some of the open source software available to build out a microservices architecture. The focus is on building and managing high-scale microservices networks and solving the challenges of running services without fault and that scale correctly based on business demand. + +Here is a wholesome, lavish spread of open source cuisine that is sure to be gastronomically, "_microservically"_ appetizing. I'm sure I've overlooked some open source applications in this area; please let me know about them in the comments. + +**[Download the PDF version of this cheat sheet [here][3]]** + +### Containers + +The right way to deploy applications is in [containers][4]. Briefly, a container is a miniature virtual server packed with the software required to run an application. The container pack is small, smart, and easy to deploy and maintain. And deploying your application in a container is clever. You can deploy as many instances as you need and scale up or down as needed to meet the current load. + +**Open source containers** + +**Software** | **Code** | **License** +---|---|--- +[rkt][5] | [GitHub][6] | Apache License 2.0 +[Docker][7] | [GitHub][8] | Apache License 2.0 +[FreeBSD Jail][9] | [GitHub][10] | FreeBSD License +[LXC][11] | [GitHub][12] | GNU LGPL v.2.1 +[OpenVZ][13] | [GitHub][14] | GNU General Public License v2.0 + +### Container orchestrators + +If you have hundreds or thousands of service instances deployed on containers, you need a good way to manage them. Container orchestration is the right solution for deploying and managing all of these containers. Orchestrators can move across; scale up, down, or out; manage higher or lower loads; regulate added, removed, and dead containers; and much more. + +**Open source container orchestrators** + +**Software** | **Code** | **License** +---|---|--- +[Kubernetes][15] | [GitHub][16] | Apache License 2.0 +[OpenShift][17] | [GitHub][18] | Apache License 2.0 +[Nomad][19] | [GitHub][20] | Mozilla Public License 2.0 +[LXD][21] | [GitHub][22] | Apache License 2.0 + +### API gateways + +An API gateway is a watchman that controls and monitors API calls to your application. An API gateway has three key roles: + + 1. **API data and management:** API listing, API subscription, API documentation, community support + 2. **API viewpoint and billing:** Analytics, metrics, billing + 3. **API control and security:** Subscription caller management, rate control, blocking, data conversion, production and sandbox support, key management + + + +API gateways are usually multi-tenant solutions to deploy multiple applications on the same gateway. + +**Open source API gateways** + +Not all of the following API gateways support every function mentioned above, so pick and choose depending on your needs. + +**Software** | **Code** | **License** +---|---|--- +[3scale][23] | [GitHub][24] | Apache License 2.0 +[API Umbrella][25] | [GitHub][26] | MIT License +[Apigee][27] | [GitHub][28] | Apache License 2.0 +[Apiman][29] | [GitHub][30] | Apache License 2.0 +[DreamFactory][31] | [GitHub][32] | Apache License 2.0 +[Fusio][33] | [GitHub][34] | GNU Affero General Public License v3.0 +[Gravitee][35] | [GitHub][36] | Apache License 2.0 +[Kong][37] | [GitHub][38] | Apache License 2.0 +[KrakenD][39] | [GitHub][40] | Apache License 2.0 +[Tyk][41] | [GitHub][42] | Mozilla Public License 2.0 + +### CI/CD + +Continuous integration (CI) and continuous deployment (CD; it may also stand for continuous delivery) are the net sum of processes to build and run your processes. [CI/CD][43] is a philosophy that ensures your microservices are built and run correctly to meet users' expectations. Automation is the critical CI/CD factor that makes the build and run process easy and structured. CI's primary processes are build and test, and CD's are deploy and monitor. + +All of the CI/CD tools and platforms listed below are open source. I don't include SaaS platforms that are free for hosting open source. GitHub also isn't on the list because it is not open source and does not have built-in CI/CD; it uses third-party CI/CD product integrations instead. GitLab is open source and has a built-in CI/CD service, so it is on this list. + +**Open source CI/CD tools** + +**Software** | **Code** | **License** +---|---|--- +[Jenkins][44] | [GitHub][45] | MIT License +[GitLab][46] | [GitLab][47] | MIT License +[Buildbot][48] | [GitHub][49] | GNU General Public License v2.0 +[Concourse][50] | [GitHub][51] | Apache License 2.0 +[GoCD][52] | [GitHub][53] | Apache License 2.0 +[Hudson][54] | [GitHub][55] | MIT License +[Spinnaker][56] | [GitHub][57] | Apache License 2.0 + +### Load balancers + +When your number of requests scale, you must deploy multiple instances of your application and share requests across those instances. The application that manages the requests between instances is called a load balancer. A load balancer can be configured to distribute requests based on round-robin scheduling, IP routing, or another algorithm. The load balancer automatically manages request distributions when new instances are added (to support higher load) or decommissioned (when load scales down). Session persistence is another load-balancing feature that redirects new requests to the previous instance when needed (for example, to maintain a session). There are hardware- and software-based load balancers. + +**Open source load balancers** + +**Software** | **Code** | **License** +---|---|--- +[HAProxy][58] | [GitHub][59] | HAPROXY's license / GPL v2.0 +[Apache modules][60] (mod_athena, mod_proxy_balancer) | [SourceForge][61] or +[Code.Google][62] or +[GitHub][63] | Apache License 2.0 +[Balance][64] | [SourceForge][65] | GNU General Public License v2.0 +[Distributor][66] | [SourceForge][67] | GNU General Public License v2.0 +[GitHub Load Balancer (GLB) Director][68] | [GitHub][69] | BSD 3-Clause License +[Neutrino][70] | [GitHub][71] | Apache License 2.0 +[OpenLoBa][72] | [SourceForge][73] | Not known +[Pen][74] | [GitHub][75] | GNU General Public License, v2.0 +[Seesaw][76] | [GitHub][77] | Apache License 2.0 +[Synapse][78] | [GitHub][79] | Apache License 2.0 +[Traefik][80] | [GitHub][81] | MIT License + +### Service registry and service discovery + +When several hundreds or thousands of service instances are deployed and talking to each other, how do requester services know how to connect the right responder services, given that deployment points are dynamic as services are scaled in and out? A service registry and service discovery service solves this problem. These systems are essentially key-value stores that maintain configuration information and naming and provide distributed synchronization. + +**Open source service registry and discovery services** + +**Software** | **Code** | **License** +---|---|--- +[Baker Street][82] | [GitHub][83] | Apache License 2.0 +[Consul][84] | [GitHub][85] | Mozilla Public License 2.0 +[etcd][86] | [GitHub][87] | Apache License 2.0 +[Registrator][88] | [GitHub][89] | MIT License +[Serf][90] | [GitHub][91] | Mozilla Public License 2.0 +[ZooKeeper][92] | [GitHub][93] | Apache License 2.0 + +### Monitoring + +When your microservices and their instances cater to users' needs, you need to maintain a good view of their performance. Monitoring tools to the rescue! + +Open source monitoring tools and software come in numerous flavors, some barely better than [top][94]. Other options include OS-specific; enterprise-grade; tool collections that provide complete integration; do-one-thing tools that merely monitor or report or visualize and integrate with third-party tools; and tools that monitor specific or multiple components such as networks, log files, web requests, and databases. Monitoring tools can be web-based or standalone tools, and notification options range from passive reporting to active alerting. + +Choose one or more of these tools to enjoy a chewy crunch of your microservices network. + +**Open source monitoring software** + +**Software** | **Code** | **License** +---|---|--- +[OpenNMS][95] | [GitHub][96] | GNU Affero General Public License +[Grafana][97] | [GitHub][98] | Apache License 2.0 +[Graphite][99] | [GitHub][100] | Apache License 2.0 +[Icinga][101] | [GitHub][102] | GNU General Public License v2.0 +[InfluxDB][103] | [GitHub][104] | MIT License +[LibreNMS][105] | [GitHub][106] | GNU General Public License v3.0 +[Naemon][107] | [GitHub][108] | GNU General Public License v2.0 +[Nagios][109] | [GitHub][110] | GNU General Public License v2.0 +[ntop][111] | [GitHub][112] | GNU General Public License v3.0 +[ELK][113] | [GitHub][114] | Apache License 2.0 +[Prometheus][115] | [GitHub][116] | Apache License 2.0 +[Sensu][117] | [GitHub][118] | MIT License +[Zabbix][119] | [Self-hosted repo][120] | GNU General Public License v2.0 +[Zenoss][121] | [SourceForge][122] | GNU General Public License v2.0 + +### The right ingredients + +Pure open source solutions can offer the right ingredients for deploying and running microservices at high scale. I hope you find them to be relishing, gratifying, satiating, and most of all, _microservicey_! + +### Download the [Microservices cheat sheet][3].  + +What are microservices? Opensource.com created a new resource page which gently introduces... + +What are microservices, how do container technologies allow for their use, and what other tools do... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/microservices-cheat-sheet + +作者:[Girish Managoli][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/gammay +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_blue_text_editor_web.png?itok=lcf-m6N7 (Text editor on a browser, in blue) +[2]: https://opensource.com/resources/what-are-microservices +[3]: https://opensource.com/content/microservices-cheat-sheet +[4]: https://opensource.com/resources/what-are-linux-containers +[5]: https://coreos.com/rkt/ +[6]: https://github.com/rkt/rkt/ +[7]: https://www.docker.com/ +[8]: https://github.com/docker +[9]: https://www.freebsd.org/doc/handbook/jails-build.html +[10]: https://github.com/freebsd/freebsd +[11]: https://linuxcontainers.org/lxc/ +[12]: https://github.com/lxc/lxc +[13]: https://openvz.org/ +[14]: https://github.com/OpenVZ +[15]: https://kubernetes.io/ +[16]: https://github.com/kubernetes/kubernetes +[17]: https://www.openshift.com/ +[18]: https://github.com/openshift +[19]: https://www.nomadproject.io/ +[20]: https://github.com/hashicorp/nomad +[21]: https://linuxcontainers.org/lxd/introduction/ +[22]: https://github.com/lxc/lxd +[23]: https://www.redhat.com/en/technologies/jboss-middleware/3scale +[24]: https://github.com/3scale/APIcast +[25]: https://apiumbrella.io/ +[26]: https://github.com/NREL/api-umbrella +[27]: https://cloud.google.com/apigee/ +[28]: https://github.com/apigee/microgateway-core +[29]: http://www.apiman.io/ +[30]: https://github.com/apiman/apiman +[31]: https://www.dreamfactory.com/ +[32]: https://github.com/dreamfactorysoftware/dreamfactory +[33]: https://www.fusio-project.org/ +[34]: https://github.com/apioo/fusio +[35]: https://gravitee.io/ +[36]: https://github.com/gravitee-io/gravitee-gateway +[37]: https://konghq.com/kong/ +[38]: https://github.com/Kong/ +[39]: https://www.krakend.io/ +[40]: https://github.com/devopsfaith/krakend +[41]: https://tyk.io/ +[42]: https://github.com/TykTechnologies/tyk +[43]: https://opensource.com/article/18/8/what-cicd +[44]: https://jenkins.io/ +[45]: https://github.com/jenkinsci/jenkins +[46]: https://gitlab.com/ +[47]: https://gitlab.com/gitlab-org +[48]: https://buildbot.net/ +[49]: https://github.com/buildbot/buildbot +[50]: https://concourse-ci.org/ +[51]: https://github.com/concourse/concourse +[52]: https://www.gocd.org/ +[53]: https://github.com/gocd/gocd +[54]: http://hudson-ci.org/ +[55]: https://github.com/hudson +[56]: https://www.spinnaker.io/ +[57]: https://github.com/spinnaker/spinnaker +[58]: http://www.haproxy.org/ +[59]: https://github.com/haproxy/haproxy +[60]: https://httpd.apache.org/docs/2.4/mod/mod_proxy_balancer.html +[61]: http://ath.sourceforge.net/ +[62]: https://code.google.com/archive/p/ath/ +[63]: https://github.com/omnigroup/Apache/blob/master/httpd/modules/proxy/mod_proxy_balancer.c +[64]: https://www.inlab.net/balance/ +[65]: https://sourceforge.net/projects/balance/ +[66]: http://distributor.sourceforge.net/ +[67]: https://sourceforge.net/projects/distributor/files/ +[68]: https://github.blog/2016-09-22-introducing-glb/ +[69]: https://github.com/github/glb-director +[70]: https://neutrinoslb.github.io/ +[71]: https://github.com/eBay/Neutrino +[72]: http://openloba.sourceforge.net/ +[73]: https://sourceforge.net/p/openloba/code/HEAD/tree/ +[74]: http://siag.nu/pen/ +[75]: https://github.com/UlricE/pen +[76]: https://opensource.google.com/projects/seesaw +[77]: https://github.com/google/seesaw +[78]: https://synapse.apache.org/ +[79]: https://github.com/apache/synapse/tree/master +[80]: https://traefik.io/ +[81]: https://github.com/containous/traefik +[82]: http://bakerstreet.io/ +[83]: https://github.com/datawire/bakerstreet +[84]: https://www.consul.io/ +[85]: https://github.com/hashicorp/consul +[86]: https://etcd.io/ +[87]: https://github.com/etcd-io/etcd +[88]: https://gliderlabs.github.io/registrator/latest/ +[89]: https://github.com/gliderlabs/registrator +[90]: https://www.serf.io/ +[91]: https://github.com/hashicorp/serf +[92]: https://zookeeper.apache.org/ +[93]: https://github.com/apache/zookeeper +[94]: https://en.wikipedia.org/wiki/Top_(software) +[95]: https://www.opennms.com/ +[96]: https://github.com/OpenNMS/opennms +[97]: https://grafana.com +[98]: https://github.com/grafana/grafana +[99]: https://graphiteapp.org/ +[100]: https://github.com/graphite-project +[101]: https://icinga.com/ +[102]: https://github.com/icinga/ +[103]: https://www.influxdata.com/ +[104]: https://github.com/influxdata/influxdb +[105]: https://www.librenms.org/ +[106]: https://github.com/librenms/librenms +[107]: http://www.naemon.org/ +[108]: https://github.com/naemon +[109]: https://www.nagios.org/ +[110]: https://github.com/NagiosEnterprises/nagioscore +[111]: https://www.ntop.org/ +[112]: https://github.com/ntop/ntopng +[113]: https://www.elastic.co/ +[114]: https://github.com/elastic +[115]: https://prometheus.io/ +[116]: https://github.com/prometheus/prometheus +[117]: https://sensu.io/ +[118]: https://github.com/sensu +[119]: https://www.zabbix.com/ +[120]: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse +[121]: https://www.zenoss.com/ +[122]: https://sourceforge.net/projects/zenoss/ diff --git a/sources/tech/20191108 Managing software and services with Cockpit.md b/sources/tech/20191108 Managing software and services with Cockpit.md new file mode 100644 index 0000000000..c2039de262 --- /dev/null +++ b/sources/tech/20191108 Managing software and services with Cockpit.md @@ -0,0 +1,129 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Managing software and services with Cockpit) +[#]: via: (https://fedoramagazine.org/managing-software-and-services-with-cockpit/) +[#]: author: (Shaun Assam https://fedoramagazine.org/author/sassam/) + +Managing software and services with Cockpit +====== + +![][1] + +The Cockpit series continues to focus on some of the tools users and administrators can use to perform everyday tasks within the web user-interface. So far we’ve covered [introducing the user-interface][2], [storage][3] and [network management][4], and [user accounts][5]. Hence, this article will highlight how Cockpit handles software and services. + +The menu options for Applications and Software Updates are available through Cockpit’s PackageKit feature. To install it from the command-line, run: + +``` +sudo dnf install cockpit-packagekit +``` + +For [Fedora Silverblue][6], [Fedora CoreOS][7], and other ostree-based operating systems, install the _cockpit-ostree_ package and reboot the system: + +``` +sudo rpm-ostree install cockpit-ostree; sudo systemctl reboot +``` + +### Software updates + +On the main screen, Cockpit notifies the user whether the system is updated, or if any updates are available. Click the **Updates Available** link on the main screen, or **Software Updates** in the menu options, to open the updates page. + +#### RPM-based updates + +The top of the screen displays general information such as the number of updates and the number of security-only updates. It also shows when the system was last checked for updates, and a button to perform the check. Likewise, this button is equivalent to the command **sudo dnf check-update**. + +Below is the **Available Updates** section, which lists the packages requiring updates. Furthermore, each package displays the name, version, and best of all, the severity of the update. Clicking a package in the list provides additional information such as the CVE, the Bugzilla ID, and a brief description of the update. For details about the CVE and related bugs, click their respective links. + +Also, one of the best features about Software Updates is the option to only install security updates. Distinguishing which updates to perform makes it simple for those who may not need, or want, the latest and greatest software installed. Of course, one can always use [Red Hat Enterprise Linux][8] or [CentOS][9] for machines requiring long-term support. + +The example below demonstrates how Cockpit applies RPM-based updates. + +![][10] + +#### OSTree-based updates + +The popular article [What is Silverblue][11] states: + +> OSTree is used by rpm-ostree, a hybrid package/image based system… It atomically replicates a base OS and allows the user to “layer” the traditional RPM on top of the base OS if needed. + +Because of this setup, Cockpit uses a snapshot-like layout for these operating systems. As seen in the demo below, the top of the screen displays the repository (_fedora_), the base OS image, and a button to **Check for Updates**. + +Clicking the repository name (_fedora_ in the demo below) opens the **Change Repository** screen. From here one can **Add New Repository**, or click the pencil icon to edit an existing repository. Editing provides the option to delete the repository, or **Add Another Key**. To add a new repository, enter the name and URL. Also, select whether or not to **Use trusted GPG key**. + +There are three categories that provide details of its respective image: Tree, Packages, and Signature. **Tree** displays basic information such as the operating system, version of the image, how long ago it was released, and the origin of the image. **Packages** displays a list of installed packages within that image. **Signature** verifies the integrity of the image such as the author, date, RSA key ID, and status. + +The current, or running, image displays a green check-mark beside it. If something happens, or an update causes an issue, click the **Roll Back and Reboot** button. This restores the system to a previous image. + +![][12] + +### Applications + +The **Applications** screen displays a list of add-ons available for Cockpit. This makes it easy to find and install the plugins required by the user. At the time of this article, some of the options include the 389 Directory Service, Fleet Commander, and Subscription Manager. The demo below shows a complete list of available Cockpit add-ons. + +Also, each item displays the name, a brief description, and a button to install, or remove, the add-on. Furthermore, clicking the item displays more information (if available). To refresh the list, click the icon at the top-right corner. + +![][13] + +### Subscription Management + +Subscription managers allow admins to attach subscriptions to the machine. Even more, subscriptions give admins control over user access to content and packages. One example of this is the famous [Red Hat subscription model][14]. This feature works in relation to the **subscription-manager** command + +The Subscriptions add-on can be installed via Cockpit’s Applications menu option. It can also be installed from the command-line with: + +``` +sudo dnf install cockpit-subscriptions +``` + +To begin, click **Subscriptions** in the main menu. If the machine is currently unregistered, it opens the **Register System** screen. Next, select the URL. You can choose **Default**, which uses Red Hat’s subscription server, or enter a **Custom URL**. Enter the **Login**, **Password**, **Activation Key**, and **Organization** ID. Finally, to complete the process, click the **Register** button. + +The main page for Subscriptions show if the machine is registered, the System Purpose, and a list of installed products. + +![][15] + +### Services + +To start, click the **Services** menu option. Because Cockpit uses _[systemd][16]_, we get the options to view **System Services**, **Targets**, **Sockets**, **Timers**, and **Paths**. Cockpit also provides an intuitive interface to help users search and find the service they want to configure. Services can also be filtered by it’s state: **All**, **Enabled**, **Disabled**, or **Static**. Below this is the list of services. Each row displays the service name, description, state, and automatic startup behavior. + +For example, let’s take _bluetooth.service_. Typing _bluetooth_ in the search bar automatically displays the service. Now, select the service to view the details of that service. The page displays the status and path of the service file. It also displays information in the service file such as the requirements and conflicts. Finally, at the bottom of the page, are the logs pertaining to that service. + +Also, users can quickly start and stop the service by toggling the switch beside the service name. The three-dots to the right of that switch expands those options to **Enable**, **Disable**, **Mask/Unmask** the service + +To learn more about _systemd_, check out the series in the Fedora Magazine starting with [What is an init system?][17] + +![][18] + +In the next article we’ll explore the security features available in Cockpit. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/managing-software-and-services-with-cockpit/ + +作者:[Shaun Assam][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/sassam/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/11/cockpit-sw-services-816x345.jpg +[2]: https://fedoramagazine.org/cockpit-and-the-evolution-of-the-web-user-interface/ +[3]: https://fedoramagazine.org/performing-storage-management-tasks-in-cockpit/ +[4]: https://fedoramagazine.org/managing-network-interfaces-and-firewalld-in-cockpit/ +[5]: https://fedoramagazine.org/managing-user-accounts-with-cockpit/ +[6]: https://silverblue.fedoraproject.org/ +[7]: https://getfedora.org/en/coreos/ +[8]: https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux?intcmp=701f2000001OEGhAAO +[9]: https://www.centos.org/ +[10]: https://fedoramagazine.org/wp-content/uploads/2019/11/cockpit-software-updates-rpm.gif +[11]: https://fedoramagazine.org/what-is-silverblue/ +[12]: https://fedoramagazine.org/wp-content/uploads/2019/11/cockpit-software-updates-ostree.gif +[13]: https://fedoramagazine.org/wp-content/uploads/2019/11/cockpit-applications.gif +[14]: https://www.redhat.com/en/about/value-of-subscription +[15]: https://fedoramagazine.org/wp-content/uploads/2019/11/cockpit-subscriptions.gif +[16]: https://fedoramagazine.org/series/systemd-series/ +[17]: https://fedoramagazine.org/what-is-an-init-system/ +[18]: https://fedoramagazine.org/wp-content/uploads/2019/11/cockpit-services.gif diff --git a/sources/tech/20191110 How to Create Affinity and Anti-Affinity Policy in OpenStack.md b/sources/tech/20191110 How to Create Affinity and Anti-Affinity Policy in OpenStack.md new file mode 100644 index 0000000000..8e65ed8a02 --- /dev/null +++ b/sources/tech/20191110 How to Create Affinity and Anti-Affinity Policy in OpenStack.md @@ -0,0 +1,214 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Create Affinity and Anti-Affinity Policy in OpenStack) +[#]: via: (https://www.linuxtechi.com/create-affinity-anti-affinity-policy-openstack/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +How to Create Affinity and Anti-Affinity Policy in OpenStack +====== + +In the organizations where the **OpenStack** is used aggressively, so in such organizations application and database teams can come up with requirement that their application and database instances are required to launch either on same **compute nodes** (hypervisor) or different compute nodes. + +[![OpenStack-VMs-Affinity-AntiAffinity-Policy][1]][2] + +So, this requirement in OpenStack is fulfilled via **server groups** with **affinity** and **anti-affinity** policies. Server Group is used control affinity and anti-affinity rules for scheduling openstack instances. + +When we try to provision virtual machines with affinity server group then all virtual machines will be launched on same compute node. When VMs are provisioned with ant-affinity server group then all VMs will be launched in different compute nodes. In this article we will demonstrate how to create OpenStack server groups with Affinity and Anti-Affinity rules. + +Let’s first verify whether your OpenStack setup support Affinity and Anti-Affinity Policies or not, execute the following grep command from your controller nodes, + +``` +# grep -i "scheduler_default_filters" /etc/nova/nova.conf +``` + +Output should be something like below, + +![Affinity-AntiAffinity-Filter-Nova-Conf-OpenStack][1] + +As we can see Affinity and Ant-Affinity filters are enabled but in case if these are not enabled then add these filters in **/etc/nova/nova.conf**  file of controller nodes under “**scheduler_default_filters**” parameters. + +``` +# vi /etc/nova/nova.conf +……………… +scheduler_default_filters=xx,xxx,xxx,xxxxx,xxxx,xxx,xxx,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,xx,xxx,xxxx,xx +……………… +``` + +Save and exit the file + +To make above changes into the effect, restart the following services + +``` +# systemctl restart openstack-nova-scheduler +# systemctl restart openstack-nova-conductor +``` + +Now let’s create OpenStack Server Groups with Affinity and Anti-Affinity Policies + +### Server Group with Affinity Policy + +To create a server group with name “app” for affinity policy, execute the following openstack command from controller node, + +**Syntax:** + +# openstack server group create –policy affinity <Server-Group-Name> + +Or + +# nova server-group-create <Server-Group-Name> affinity + +**Note:** Before start executing openstack command, please make sure you source project credential file, in my case project credential file is “**openrc**” + +Example: + +``` +# source openrc +# openstack server group create --policy affinity app +``` + +### Server Group with Anti-Affinity Policy + +To create a server group with anti-affinity policy, execute the following openstack command from controller node, I am assuming server group name is “database” + +**Syntax:** + +# openstack server group create –policy anti-affinity <Server-Group-Name> + +Or + +# nova server-group-create <Server-Group-Name> anti-affinity + +Example: + +``` +# source openrc +# openstack server group create --policy anti-affinity database +``` + +### List Server Group’s ID and Policies + +Execute either nova command or Openstack command to get server group’s id and their policies + +``` +# nova server-group-list | grep -Ei "Policies|database" +Or +# openstack server group list --long | grep -Ei "Policies|app|database" +``` + +Output would be something like below, + +![Server-Group-Policies-OpenStack][1] + +### [Launch Virtual Machines (VMs)][3] with Affinity Policy + +Let’s assume we want to launch 4 vms with affinity policy, run the following “**openstack server create**” command + +**Syntax:** + +# openstack server create –image <img-name> –flavor <id-or-flavor-name> –security-group <security-group-name> –nic net-id=<network-id> –hint group=<Server-Group-ID> –max <number-of-vms>  <VM-Name> + +**Example:** + +``` +# openstack server create --image Cirros --flavor m1.small --security-group default --nic net-id=37b9ab9a-f198-4db1-a5d6-5789b05bfb4c --hint group="a9847c7f-b7c2-4751-9c9a-03b117e704ff" --max 4 affinity-test +``` + +Output of above command, + +![OpenStack-Server-create-with-hint-option][1] + +Let’s verify whether VMs are launched on same compute node or not, run following command + +``` +# openstack server list --long -c Name -c Status -c Host -c "Power State" | grep -i affinity-test +``` + +![Affinity-VMs-Status-OpenStack][1] + +This confirms that our affinity policy is working fine as all the VMs are launched on same compute node. + +Now let’s test anti-affinity policy + +### Launch Virtual Machines (VMs) with Anti-Affinity Policy + +For anti-affinity policy we will launch 4 VMs, in above ‘openstack server create’ command, we need to replace Anti-Affinity Server Group’s ID. In our case we will be using database server group id. + +Run the following openstack command to launch 4 VMs on different computes with anti-affinity policy, + +``` +# openstack server create --image Cirros --flavor m1.small --security-group default --nic net-id=37b9ab9a-f198-4db1-a5d6-5789b05bfb4c --hint group="498fd41b-8a8a-497a-afd8-bc361da2d74e" --max 4 anti-affinity-test +``` + +Output + +![Openstack-server-create-anti-affinity-hint-option][1] + +Use below openstack command to verify whether VMs are launched on different compute nodes or not + +``` +# openstack server list --long -c Name -c Status -c Host -c "Power State" | grep -i anti-affinity-test +``` + +![Anti-Affinity-VMs-Status-OpenStack][1] + +Above output confirms that our anti-affinity policy is also working fine. + +**Note:** Default Quota for Server group is 10 for every tenant , it means we can max launch 10 VMs inside a server group. + +Use below command to view Server Group quota for a specific tenant, replace the tenant id that suits to your setup + +``` +# openstack quota show f6852d73eaee497a8a640757fe02b785 | grep -i server_group +| server_group_members | 10 | +| server_groups | 10 | +# +``` + +To update Server Group Quota, execute the following commands + +``` +# nova quota-update --server-group-members 15 f6852d73eaee497a8a640757fe02b785 +# nova quota-update --server-groups 15 f6852d73eaee497a8a640757fe02b785 +``` + +Now re-run the openstack quota command to verify server group quota + +``` +# openstack quota show f6852d73eaee497a8a640757fe02b785 | grep -i server_group +| server_group_members | 15 | +| server_groups | 15 | +# +``` + +That’s all, we have successfully updated Server Group quota for the tenant. This conclude the article as well, please do hesitate to share it among your technical friends. + + * [Facebook][4] + * [Twitter][5] + * [LinkedIn][6] + * [Reddit][7] + + + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/create-affinity-anti-affinity-policy-openstack/ + +作者:[Pradeep Kumar][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.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/11/OpenStack-VMs-Affinity-AntiAffinity-Policy.jpg +[3]: https://www.linuxtechi.com/create-delete-virtual-machine-command-line-openstack/ +[4]: http://www.facebook.com/sharer.php?u=https%3A%2F%2Fwww.linuxtechi.com%2Fcreate-affinity-anti-affinity-policy-openstack%2F&t=How%20to%20Create%20Affinity%20and%20Anti-Affinity%20Policy%20in%20OpenStack +[5]: http://twitter.com/share?text=How%20to%20Create%20Affinity%20and%20Anti-Affinity%20Policy%20in%20OpenStack&url=https%3A%2F%2Fwww.linuxtechi.com%2Fcreate-affinity-anti-affinity-policy-openstack%2F&via=Linuxtechi +[6]: http://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.linuxtechi.com%2Fcreate-affinity-anti-affinity-policy-openstack%2F&title=How%20to%20Create%20Affinity%20and%20Anti-Affinity%20Policy%20in%20OpenStack +[7]: http://www.reddit.com/submit?url=https%3A%2F%2Fwww.linuxtechi.com%2Fcreate-affinity-anti-affinity-policy-openstack%2F&title=How%20to%20Create%20Affinity%20and%20Anti-Affinity%20Policy%20in%20OpenStack diff --git a/sources/tech/20191111 3 approaches to secrets management for Flatpak applications.md b/sources/tech/20191111 3 approaches to secrets management for Flatpak applications.md new file mode 100644 index 0000000000..fd33e978f4 --- /dev/null +++ b/sources/tech/20191111 3 approaches to secrets management for Flatpak applications.md @@ -0,0 +1,133 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (3 approaches to secrets management for Flatpak applications) +[#]: via: (https://opensource.com/article/19/11/secrets-management-flatpak-applications) +[#]: author: (Daiki Ueno https://opensource.com/users/ueno) + +3 approaches to secrets management for Flatpak applications +====== +Flatpak secrets management is getting an upgrade. Here's what's coming. +![A top secret file.][1] + +[Flatpak][2] enables desktop applications to run in isolated sandboxes, which significantly improves security as it prevents applications from affecting one another and impacting the host system. In practice, however, typical applications still need to access services and user data that are shared among other applications and the host. This situation has been improved [by hardening permissions around the portal mechanism][3], though there was a long-standing issue: How to manage user secrets. + +In this article, we present our approach to managing user secrets for Flatpak applications. While most applications can transparently take advantage of the proposed mechanism, some applications need code modification. The migration steps are also presented. + +### How secrets are managed on the Linux desktop + +On a modern Linux desktop, most of the secrets—passwords, tokens, and so on, with their associated attributes—are centrally managed by the daemon process **gnome-keyring-daemon**. Applications access this daemon through [the Secret Service API][4], which is exposed through D-Bus. This process is done under the hood if the application is using a client library like **libsecret**.  + +**Note:** For the same purpose, there is a library called **libgnome-keyring**, which is now obsolete. Note that, despite the name, **libgnome-keyring** is a separate project from **gnome-keyring**, which is NOT obsolete and still maintains the central role of secrets management. + +On the daemon side, the secrets are stored on the filesystem and encrypted. Other than that, the daemon is nothing but a normal storage service, meaning that any application can store data on arbitrary "paths" that other applications can also see. While this model is sufficient as long as we trust all applications, it negates one of Flatpak’s security goals: [Increase the security of desktop systems by isolating applications from one another][5]. + +Therefore, when installing a Flatpak application that uses the Secret Service API, the user is asked to grant the necessary permissions to the application. In the example below, you can see that the application requires access to the Secret Service API (**org.freedesktop.secrets**). If the user doesn’t want to allow this application to access the service, their only option is to forfeit installation: + + +``` +$ flatpak install org.gnome.Epiphany +… +org.gnome.Epiphany permissions: +        ipc                     network         pulseaudio      wayland +        x11                     dri             file access [1] dbus access [2] +        system dbus access [3] + +        [1] xdg-download, xdg-run/dconf, ~/.config/dconf:ro +        [2] ca.desrt.dconf, org.freedesktop.Notifications, org.freedesktop.secrets +        [3] org.freedesktop.GeoClue2 +Proceed with these changes to the Default system installation? [Y/n]: +``` + +This is clearly an undesirable outcome. + +### The local storage approach + +The basic idea to tackle this problem is to store the secrets on the application side, rather than the host side (**gnome-keyring-daemon**). This practice is analogous to [the recent work on GSettings][6], where applications store the settings data in a local file instead of in a [**dconf**][7] service running on the host. + +When it comes to secrets, however, there is a bootstrapping problem: The application has to encrypt secrets when storing them in a local file, but it doesn’t know the encryption key yet. To provision the application with an encryption key, we rely on the [Flatpak portal][8] mechanism, which sits between the application and the host to let the two communicate through a restricted interface. + +We also added [a new portal][9] that allows applications to retrieve encryption keys. First, the application sends a request to the portal (the request contains a Unix file descriptor where the encryption key is written). Then, the portal delegates the request to the back-end implementation in **gnome-keyring-daemon**, which sends a unique encryption key for the sandboxed application through the file descriptor. + +With the received encryption key, the application encrypts the secrets and stores them in the application data directory (**~/.var/app/$APPID/data/keyrings**), which is **bind**-mounted and accessible from both the host and the sandbox. + +### The libsecret API + +The **libsecret** project provides two different sets of APIs. One is [the simple API][10], and the other is [the complete API][11]. The former provides simpler, stateless operations for retrieving and storing secrets, while the latter provides a more complete, object-oriented API that maps the D-Bus interface to the C API. + +Local storage is only supported in the simple API. If your applications are already using the simple API, then they will automatically use local storage when running under Flatpak. Otherwise, to enable local storage, the applications need to be ported to the simple API. See [the migration patch in Epiphany][12] as an example. + +Having a distinction between the two API sets also makes it possible for the applications to opt-out from using local storage. For example, if your application is a password manager that needs full access to user keyrings, you can bypass local storage by using the complete API. + +### The keyring format + +Although ideally, we should be able to use the same keyring format for both local storage and **gnome-keyring-daemon**, we realized that the keyring format used by **gnome-keyring-daemon** has limitations. Secrets, including associated attributes, are encrypted as a single chunk, meaning that they can consume an unnecessary amount of locked memory. Also, attributes are hashed without a key, meaning that it is possible to guess which secrets are stored in the file. + +Therefore, instead of implementing this format in two places, we decided to define a new version of the keyring file format, with the following characteristics: Secrets are encrypted individually and attribute hashes are now a [message authentication code (MAC)][13] over the attributes. + +This new format is based on [the][14] [GVariant serialization format][14], except for the header, and this change allows us to reuse most of the code for encoding, decoding, and lookup. + +### What's next for Flatpak secrets management + +The necessary patches are (currently) only available in the Git repositories of the relevant components (**xdg-desktop-portal**, **gnome-keyring**, and **libsecret**). They will be included in the next releases leading up to GNOME 3.36. + +If you are a developer, there is still room for improvement in this area. Here is where your help would be greatly appreciated: + + * **Session keyrings:** The Secret Service API supports "session" keyrings, which only last for the duration of the user session. The local storage backend doesn’t support this feature yet. This code could be implemented using the session keyring in the Linux kernel. + + * **Management and backup application:** Application secrets are now stored in multiple locations, and not just the host keyrings. It would be useful if there were a tool to manage application secrets and make backups. This process should be possible by enhancing GNOME’s Seahorse to look at application secrets. + + * **Online accounts portal:** These days, it is common for web applications to be integrated with web-based access delegation protocols such as OAuth 2.0. These protocols are supported by **gnome-online-accounts**, which in turn uses **gnome-keyring-daemon** for storing the tokens. A portal interface for online accounts would be useful for restricting access per application. + + * **Wider adoption of the new keyring format:** While the new format has several advantages, it is currently only used by **libsecret** on the application side. It would be beneficial if **gnome-keyring-daemon** on the host side also used the same format. + + * **Hardening the reinstall process:** By default, the application’s keyring file (**~/.var/app/$APPID/data/keyrings**) persists after uninstall, along with other data. This persistence is vulnerable in case the application ID is reused by an untrusted publisher. Currently, we recommend using the **\--delete-data** option to ensure that such application data is removed. This procedure could be improved if a publisher’s ID was associated with the application. + + + + +### Summary + +This article presented a mechanism to provision Flatpak applications with user secrets. This mechanism was designed based on the following principles: + + * Minimize the host interface. + * Let applications interact with the host through a Flatpak portal. + * Store the application data in a common data format. + + + +Although the mechanism is transparent, as long as you use **libsecret**, the mechanism is only enabled through **libsecret**’s simple API. For a smoother transition, we suggest migrating applications to this API. More information about the project’s background and the design rationale is available in the GUADEC presentation ([slides][15], [recording][16]). + +Fragmentation is a longstanding Achilles heel for the Linux desktop. In a world of myriad... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/secrets-management-flatpak-applications + +作者:[Daiki Ueno][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/ueno +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/topsecret_folder_file_security.jpg?itok=y0P2GC5K (A top secret file.) +[2]: https://opensource.com/article/19/10/how-build-flatpak-packaging +[3]: https://blog.tingping.se/2019/10/06/hardening-flatpak-permissions.html +[4]: https://specifications.freedesktop.org/secret-service/ +[5]: http://docs.flatpak.org/en/latest/sandbox-permissions.html#sandbox-permissions +[6]: https://blogs.gnome.org/mclasen/2019/07/12/settings-in-a-sandbox-world/ +[7]: https://wiki.gnome.org/Projects/dconf +[8]: https://flatpak.github.io/xdg-desktop-portal/portal-docs.html +[9]: https://github.com/flatpak/xdg-desktop-portal/pull/359 +[10]: https://developer.gnome.org/libsecret/unstable/simple.html +[11]: https://developer.gnome.org/libsecret/unstable/complete.html +[12]: https://gitlab.gnome.org/GNOME/epiphany/commit/ed514f3ef43b323c51fb539274bef9dce0907ff2 +[13]: https://en.wikipedia.org/wiki/Message_authentication_code +[14]: https://people.gnome.org/~desrt/gvariant-serialisation.pdf +[15]: https://people.gnome.org/~dueno/libsecret-guadec.pdf +[16]: https://guadec.ubicast.tv/videos/desktop-secrets-management-for-the-future/ diff --git a/sources/tech/20191111 A guide to intermediate awk scripting.md b/sources/tech/20191111 A guide to intermediate awk scripting.md new file mode 100644 index 0000000000..7e788b2adc --- /dev/null +++ b/sources/tech/20191111 A guide to intermediate awk scripting.md @@ -0,0 +1,140 @@ +[#]: collector: (lujun9972) +[#]: translator: (lnrCoder) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A guide to intermediate awk scripting) +[#]: via: (https://opensource.com/article/19/11/intermediate-awk-scripting) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +A guide to intermediate awk scripting +====== +Learn how to structure commands into executable scripts. +![Coding on a computer][1] + +This article explores awk's capabilities, which are easier to use now that you know how to structure your command into an executable script. + +### Logical operators and conditionals + +You can use the logical operators **and** (written **&&**) and **or** (written **||**) to add specificity to your conditionals. + +For example, to select and print only records with the string "purple" in the second column _and_ an amount less than five in the third column: + + +``` +`$2 == "purple" && $3 < 5 {print $1}` +``` + +If a record has "purple" in column two but a value greater than five in column three, then it is _not_ selected. Similarly, if a record matches column three's requirement but lacks "purple" in column two, it is also _not_ selected. + +### Next command + +Say you want to select every record in your file where the amount is greater than or equal to eight and print a matching record with two asterisks (******). You also want to flag every record with a value between five (inclusive) and eight with only one asterisk (*****). There are a few ways to do this, and one way is to use the **next** command to instruct awk that after it takes an action, it should stop scanning and proceed to the _next_ record. + +Here's an example: + + +``` +NR == 1 { +  print $0; +  next; +} + +$3 >= 8 { +  printf "%s\t%s\n", $0, "**"; +  next; +} + +$3 >= 5 { +  printf "%s\t%s\n", $0, "*"; +  next; +} + +$3 < 5 { +  print $0; +} +``` + +### BEGIN command + +The **BEGIN** command lets you print and set variables before awk starts scanning a text file. For instance, you can set the input and output field separators inside your awk script by defining them in a **BEGIN** statement. This example adapts the simple script from the previous article for a file with fields delimited by commas instead of whitespace: + + +``` +#!/usr/bin/awk -f +# +# Print each record EXCEPT +# IF the first record contains "raspberry", +# THEN replace "red" with "pi" + +BEGIN { +        FS=","; +} + +$1 == "raspberry" { +        gsub(/red/,"pi") +} +``` + +### END command + +The **END** command, like **BEGIN**, allows you to perform actions in awk after it completes its scan through the text file you are processing. If you want to print cumulative results of some value in all records, you can do that only after all records have been scanned and processed. + +The **BEGIN** and **END** commands run only once each. All rules between them run zero or more times on _each record_. In other words, most of your awk script is a loop that is executed at every new line of the text file you're processing, with the exception of the **BEGIN** and **END** rules, which run before and after the loop. + +Here is an example that wouldn't be possible without the **END** command. This script accepts values from the output of the **df** Unix command and increments two custom variables (**used** and **available**) with each new record. + + +``` +$1 != "tempfs" { +    used += $3; +    available += $4; +} + +END { +    printf "%d GiB used\n%d GiB available\n", used/2^20, available/2^20; +} +``` + +Save the script as **total.awk** and try it: + + +``` +`df -l | awk -f total.awk` +``` + +The **used** and **available** variables act like variables in many other programming languages. You create them arbitrarily and without declaring their type, and you add values to them at will. At the end of the loop, the script adds the records in the respective columns together and prints the totals. + +### Math + +As you can probably tell from all the logical operators and casual calculations so far, awk does math quite naturally. This arguably makes it a very useful calculator for your terminal. Instead of struggling to remember the rather unusual syntax of **bc**, you can just use awk along with its special **BEGIN** function to avoid the requirement of a file argument: + + +``` +$ awk 'BEGIN { print 2*21 }' +42 +$ awk 'BEGIN {print 8*log(4) }' +11.0904 +``` + +Admittedly, that's still a lot of typing for simple (and not so simple) math, but it wouldn't take much effort to write a frontend, which is an exercise for you to explore. + +* * * + +_This article is adapted from an episode of [Hacker Public Radio][2], a community technology podcast._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/intermediate-awk-scripting + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/lnrCoder) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: http://hackerpublicradio.org/eps.php?id=2129 diff --git a/sources/tech/20191111 Bash Script to Monitor Disk Space Usage on Multiple Remote Linux Systems With eMail Alert.md b/sources/tech/20191111 Bash Script to Monitor Disk Space Usage on Multiple Remote Linux Systems With eMail Alert.md new file mode 100644 index 0000000000..136748169d --- /dev/null +++ b/sources/tech/20191111 Bash Script to Monitor Disk Space Usage on Multiple Remote Linux Systems With eMail Alert.md @@ -0,0 +1,200 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Bash Script to Monitor Disk Space Usage on Multiple Remote Linux Systems With eMail Alert) +[#]: via: (https://www.2daygeek.com/linux-bash-script-to-monitor-disk-space-usage-on-multiple-remote-linux-systems-send-email/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +Bash Script to Monitor Disk Space Usage on Multiple Remote Linux Systems With eMail Alert +====== + +Some time ago, we had wrote **[Bash script to monitor disk space usage on a Linux][1]** system with an email alert. + +That script works on a single machine, and you have to put the script on the corresponding machine. + +If you want to set disk space usage alerts on multiple computers at the same time, that script does not help you. + +So we have written this new **[shell script][2]** to achieve this. + +To do so, you need a JUMP server (centralized server) that can communicate with any other computer without a password. + +This means that password-less authentication must be set as a prerequisite. + +When the prerequisite is complete, run the script on the JUMP server. + +Finally add a **[cronjob][3]** to completely automate this process. + +Three shell scripts are included in this article, and choose the one you like. + +### 1) Bash Script-1: Bash Script to Check Disk Space Usage on Multiple Remote Linux Systems and Print Output on Terminal + +This **[bash script][4]** checks the disk space usage on a given remote machine and print the output to the terminal if the system reaches the specified threshold. + +In this example, we set the threshold limit to 80% for testing purpose and you can adjust this limit to suit your needs. + +Also, replace your email id instead of us to receive this alert. + +``` +# vi /opt/scripts/disk-usage-multiple.sh + +#!/bin/sh +output1=/tmp/disk-usage.out +echo "---------------------------------------------------------------------------" +echo "HostName Filesystem Size Used Avail Use% Mounted on" +echo "---------------------------------------------------------------------------" +for server in `more /opt/scripts/servers.txt` +do +output=`ssh $server df -Ph | tail -n +2 | sed s/%//g | awk '{ if($5 > 80) print $0;}'` +echo "$server: $output" >> $output1 +done +cat $output1 | grep G | column -t +rm $output1 +``` + +Run the script file once you have added the above script to a file. + +``` +# sh /opt/scripts/disk-usage-multiple.sh +``` + +You get an output like the one below. + +``` +------------------------------------------------------------------------------------------------ +HostName Filesystem Size Used Avail Use% Mounted on +------------------------------------------------------------------------------------------------ +server01: /dev/mapper/vg_root-lv_red 5.0G 4.3G 784M 85 /var/log/httpd +server02: /dev/mapper/vg_root-lv_var 5.8G 4.5G 1.1G 81 /var +server03: /dev/mapper/vg01-LogVol01 5.7G 4.5G 1003M 82 /usr +server04: /dev/mapper/vg01-LogVol04 4.9G 3.9G 711M 85 /usr +server05: /dev/mapper/vg_root-lv_u01 74G 56G 15G 80 /u01 +``` + +### 2) Shell Script-2: Shell Script to Monitor Disk Space Usage on Multiple Remote Linux Systems With eMail Alerts + +This shell script checks the disk space usage on a given remote machine and sends the output via a mail in a simple text once the system reaches the specified threshold. + +``` +# vi /opt/scripts/disk-usage-multiple-1.sh + +#!/bin/sh +SUBJECT="Disk Usage Report on "`date`"" +MESSAGE="/tmp/disk-usage.out" +MESSAGE1="/tmp/disk-usage-1.out" +TO="[email protected]" +echo "---------------------------------------------------------------------------------------------------" >> $MESSAGE1 +echo "HostName Filesystem Size Used Avail Use% Mounted on" >> $MESSAGE1 +echo "---------------------------------------------------------------------------------------------------" >> $MESSAGE1 +for server in `more /opt/scripts/servers.txt` +do +output=`ssh $server df -Ph | tail -n +2 | sed s/%//g | awk '{ if($5 > 80) print $0;}'` +echo "$server: $output" >> $MESSAGE +done +cat $MESSAGE | grep G | column -t >> $MESSAGE1 +mail -s "$SUBJECT" "$TO" < $MESSAGE1 +rm $MESSAGE +rm $MESSAGE1 +``` + +Run the script file once you have added the above script to a file. + +``` +# sh /opt/scripts/disk-usage-multiple-1.sh +``` + +You get an output like the one below. + +``` +------------------------------------------------------------------------------------------------ +HostName Filesystem Size Used Avail Use% Mounted on +------------------------------------------------------------------------------------------------ +server01: /dev/mapper/vg_root-lv_red 5.0G 4.3G 784M 85 /var/log/httpd +server02: /dev/mapper/vg_root-lv_var 5.8G 4.5G 1.1G 81 /var +server03: /dev/mapper/vg01-LogVol01 5.7G 4.5G 1003M 82 /usr +server04: /dev/mapper/vg01-LogVol04 4.9G 3.9G 711M 85 /usr +server05: /dev/mapper/vg_root-lv_u01 74G 56G 15G 80 /u01 +``` + +Finally add a cronjob to automate this. It will run every 10 minutes. + +``` +# crontab -e + +*/10 * * * * /bin/bash /opt/scripts/disk-usage-multiple-1.sh +``` + +### 3) Bash Script-3: Bash Script to Monitor Disk Space Usage on Multiple Remote Linux Systems With eMail Alerts + +This shell script checks the disk space usage on a given remote machine and sends the output via the mail with a CSV file if the system reaches the specified threshold. + +``` +# vi /opt/scripts/disk-usage-multiple-2.sh + +#!/bin/sh +MESSAGE="/tmp/disk-usage.out" +MESSAGE2="/tmp/disk-usage-1.csv" +echo "Server Name, Filesystem, Size, Used, Avail, Use%, Mounted on" > $MESSAGE2 +for server in thvtstrhl7 thvrhel6 +for server in `more /opt/scripts/servers-disk-usage.txt` +do +output1=`ssh $server df -Ph | tail -n +2 | sed s/%//g | awk '{ if($5 > 80) print $0;}'` +echo "$server $output1" >> $MESSAGE +done +cat $MESSAGE | grep G | column -t | while read output; +do +Sname=$(echo $output | awk '{print $1}') +Fsystem=$(echo $output | awk '{print $2}') +Size=$(echo $output | awk '{print $3}') +Used=$(echo $output | awk '{print $4}') +Avail=$(echo $output | awk '{print $5}') +Use=$(echo $output | awk '{print $6}') +Mnt=$(echo $output | awk '{print $7}') +echo "$Sname,$Fsystem,$Size,$Used,$Avail,$Use,$Mnt" >> $MESSAGE2 +done +echo "Disk Usage Report for `date +"%B %Y"`" | mailx -s "Disk Usage Report on `date`" -a /tmp/disk-usage-1.csv [email protected] +rm $MESSAGE +rm $MESSAGE2 +``` + +Run the script file once you have added the above script to a file. + +``` +# sh /opt/scripts/disk-usage-multiple-2.sh +``` + +You get an output like the one below. + +![][5] + +Finally add a cronjob to automate this. It will run every 10 minutes. + +``` +# crontab -e + +*/10 * * * * /bin/bash /opt/scripts/disk-usage-multiple-1.sh +``` + +**Note:** Because the script is scheduled to run once every 10 minutes, you will receive an email alert every 10 minutes. + +If your system reaches a given limit after 18 minutes, you will receive an email alert on the second cycle, such as after 20 minutes (2nd 10 minute cycle). + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-bash-script-to-monitor-disk-space-usage-on-multiple-remote-linux-systems-send-email/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/linux-shell-script-to-monitor-disk-space-usage-and-send-email/ +[2]: https://www.2daygeek.com/category/shell-script/ +[3]: https://www.2daygeek.com/crontab-cronjob-to-schedule-jobs-in-linux/ +[4]: https://www.2daygeek.com/category/bash-script/ +[5]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 diff --git a/sources/tech/20191111 The Top Nine Open Source Cloud Management Platforms.md b/sources/tech/20191111 The Top Nine Open Source Cloud Management Platforms.md new file mode 100644 index 0000000000..7801a465d0 --- /dev/null +++ b/sources/tech/20191111 The Top Nine Open Source Cloud Management Platforms.md @@ -0,0 +1,302 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (The Top Nine Open Source Cloud Management Platforms) +[#]: via: (https://opensourceforu.com/2019/11/the-top-nine-open-source-cloud-management-platforms/) +[#]: author: (Dr Anand Nayyar https://opensourceforu.com/author/anand-nayyar/) + +The Top Nine Open Source Cloud Management Platforms +====== + +[![][1]][2] + +_A cloud management platform (CMP) is a comprehensive software suite with integrated tools that an enterprise can use to monitor and control cloud computing resources. There are many CMPs out there, both open source and proprietary. This article explores how cloud platforms work, their capabilities, as well as a selection of the top open source cloud platforms of the day._ + +In recent times, all the enterprises that have started or have adopted cloud computing face new challenges with regard to ensuring the same visibility in cloud applications as they have with their on-premise apps. With any cloud-based full implementation, the issues that users face include preserving the integrity, usability and security of all the data migrated online. According to John Webster, senior partner and analyst for the Evaluator Group, and whose research area is the hybrid cloud and Big Data, “As enterprise IT operations start to expand our capabilities and resources into the cloud, we now want to manage cloud resources with the same policy, procedure, guidance and expectations that we have over our existing IT environment.” + +The only solution to all the issues arising from cloud-based implementations is a cloud management platform (CMP). This provides a rich set of capabilities for discovery, template-based provisioning, orchestration and automation. It also enables operational monitoring and management, governance and cost optimisation across multiple public and private clouds as well as virtual and bare-metal servers. + +A CMP is a comprehensive suite with integrated software tools that an enterprise can use to monitor and control cloud computing resources. An enterprise can use a CMP for either a private or public cloud, but CMPs facilitate toolsets for hybrid and multi-cloud models to centralise the control of various cloud-based infrastructures. + +A wide range of tools is available to deal with these challenges and help companies efficiently operate applications and services in the cloud. Vendors offer a variety of cloud management tools that enable IT organisations to build, purchase, manage, monitor, track and optimise their cloud resources. With the help of these tools, organisations can save time and effort while allowing IT staff to focus on more strategic goals. These tools also help in monitoring users’ interactions with the cloud infrastructure and in managing resource allocation. + +In the cloud marketplace, different tools have unique feature sets. Capabilities include unified management across multiple clouds, integration with third-party tools for configuration and monitoring purposes, dashboards and reports for detailed information about resource consumption, notifications and alerts when predefined thresholds are reached, and controlled access to resources to avoid over usage or unauthorised access. By simplifying the management of cloud environments and reducing the complexity and cost of managing multiple activities, the right cloud management tool can bring speed, flexibility, security and cost efficiency to any organisation. + +![Figure 1: Cloudstack architecture][3] + +So the important question is, “Which CMP is the best?” Well, there are both commercial and open source options. Nowadays, open source technology has become a central facet of cloud computing for many users around the world. In this article, we discuss the top open source cloud management platforms to assist admins, systems analysts, network security as well as cloud computing professionals select the best platform, based on the requirements of the enterprise. + +Before we dive into the types of open source CMPs, let’s discuss some of their broad capabilities and how they work. + +According to analysis by Market Research Future (MRF), the global CMP market was valued at US$ 8.18 billion in 2018 and is expected to reach US$ 26.77 billion by 2022, registering a CAGR of 18.4 per cent during the forecast period. The market growth is attributed to the rising need for enterprises to have greater control over IT spending, the surge in the adoption of heterogeneous and multi-modal IT service delivery environments, the rapid deployment of virtualised workloads, and improved operational efficiency. On the other hand, insufficient technical expertise and the rising security concerns for platforms developed in-house are some of the factors expected to hinder the market growth during the assessment period. + +**How cloud management platforms work** +A CMP is deployed into existing cloud environments as a virtual machine (VM) consisting of a database and server. The server communicates with application programming interfaces (APIs) to connect the database and virtual resources held in the cloud. The database collects the information on how the virtual infrastructure is performing and sends an analysis to the Web interface, where systems administrators can analyse the cloud performance. The whole interconnectivity relies on the operating system, which commands all the different technologies that make up clouds and also deploys cloud management tools. + +A CMP should be capable of the following things. + + * **Strong integration with IT infrastructure:** CMPs should be customised as per the enterprise’s needs, and must meet the requirements of the operating systems, apps, storage frameworks and anything else running in the cloud. + * **Automating manual tasks:** CMPs should have self-service capabilities to automate everything, with no human involvement. + * **Cost management:** CMPs should assist organisations with precision cost forecasting and reporting to easily use and manage all sorts of cloud services. + * **Service management:** They should assist the IT team to monitor cloud-based services to help in capacity planning, workload deployment, asset management and incident management. + * **Governance and security:** CMPs should enable administrators to enforce policy-based control of cloud resources, and offer security features like encryption as well as identity and access management. + + + +**Top open source CMPs** +The following are the top open source cloud management platform providers. + +**Apache CloudStack** +Apache CloudStack is an open source, multi-hypervisor, multi-tenant, high-availability Infrastructure-as-a-Service CMP, which facilitates creating, deploying and managing cloud services by providing a complete stack of features and components for cloud environments. It uses existing hypervisors such as KVM, VMware vSphere, VMware ESXi, VMware vCenter and XenServer/XCP for virtualisation. CloudStack can also orchestrate the non-technical elements of service delivery such as billing and metering. It presents a range of APIs, allowing it to be integrated with any other platform. + +The main components of CloudStack are: + + 1. Compute nodes (CNs), which are servers when VM instances are instantiated. + 2. A cluster, which is composed of several CNs that share the same hypervisor and primary storage system. + 3. Pod is a rack of hardware including Layer-2 switches and one or more clusters. It is responsible for storing the VM files, which represent the primary storage. + 4. The Availability Zone is made up of one or more pods, with secondary storage forming a zone. This is equivalent to a single data centre, representing geographic allocations. The secondary storage stores VM templates, ISO images and disk volume snapshots. + 5. The management server is a single point of configuration that provides Web user interfaces and APIs, and manages the assignment of VM instances to particular hosts and of public and private IP addresses to particular accounts, as well as the allocation of storage. + + + +_**Features**_ + + * _Self-service user interface:_ AJAX console access, multi-role support, network virtualisation, hypervisor agnostic, usage metering, virtual routers. + * _LVM support:_ Block storage volumes, NetScaler support, OpenStack Swift integration, LDAP integration, domains and delegated administration. + + + +_**Official website:**_ __ +_**Latest version:**_ 4.12.0.0 + +![Figure 2: Openstack components][4] + +**OpenStack** +OpenStack consists of a set of software tools for building and managing cloud computing platforms for public and private clouds using pooled virtual resources. The tools comprising the OpenStack platform are called projects. They handle core cloud computing services of compute, networking, storage, identity and image services. OpenStack software controls large pools of compute, storage and networking resources throughout a data centre, and is managed through a dashboard or via the OpenStack API. + +OpenStack consists of the following nine components. + + * **Nova:** This is the primary computing engine used for deploying and managing a large number of virtual machines and instances to handle computing tasks. + * **Swift:** This is a storage system for objects and files. + * **Cinder:** This is a persistent block storage component for compute instances. + * **Neutron:** This provides networking capability so that all components can communicate quickly. + * **Horizon:** This is a GUI interface for OpenStack. + * **Keystone:** This provides identity services for OpenStack. + * **Glance:** This provides image services and allows images (virtual copies of hard disks) to be used as templates for deploying new virtual machine instances. + * **Ceilometer:** This provides telemetry services, and billing services to individuals. + * **Heat:** This is an orchestration component that allows developers to store the requirements of cloud applications in files. + + + +_**Features**_ + + * _Services:_ Messaging, clustering, containers, compute, identity, app data protection as a service, events, metadata indexing as service, workflows, DNS, database as a service, bare metal provisioning, optimisation and deployment, governance, and benchmarking. + * Web front-end, Big Data processing framework, container orchestration engine, key management, and NFV orchestration. + + + +_**Official website:** _ +**Latest version:** Stein + +**ManageIQ** +This is an open source CMP for hybrid IT environments, with a mix of public and private clouds. It provides tools for managing small and large environments as well as supports multiple technologies like virtual machines, public clouds and containers. It allows users to download any virtual appliance and deploy copies of it into virtualisation platforms like OpenStack or VMware. Three main variants of ManageIQ are available: Vagrant, Docker and Public Cloud. + +ManageIQ is written in Ruby and uses the Ruby on Rails framework. The ManageIQ software is shipped as a pre-built virtual appliance, roughly 1GB in size. The appliance is based on the CentOS operating system and includes an embedded PostgreSQL database. Since the Darga release, a container based version has also been made available. An appliance can be used on its own, or it can be part of a three-tier federated architecture. In the latter case, the operator configures zones, regions and a single super-region. Appliances can be assigned to a specific zone or region and are configured with specific roles so that work is coordinated within the region. Most roles are multi-master and distribute work automatically in a queue, but some roles like the database are singletons. + +**Features** + + * Offers insights through discovery, monitoring, utilisation, performance, reporting, analytics, chargeback and trending. + * Controls security, compliance, alerting, policy-based resource and configuration management. + * Automates IT processes, tasks and events, provisioning, workload management and orchestration. + * Integrates systems management, tools and processes, event consoles, CMDB, RBA and Web services. + + + +_**Official website:** _ +**Latest version:** Hammer-10 + +**Cloudify** +Cloudify is an open source software cloud and NFV orchestration product that uses OASIS TOSCA technology. It is designed using Python. Cloudify allows users to model and automate an application’s entire life cycle. This includes deployment to a cloud or data centre environment, the management of the deployed application, failure detection and ongoing maintenance. The platform is ideal for users who want to launch prebuilt applications in the cloud without handling the technical aspects. + +_**How it works:**_ It translates applications into a blueprint configuration written in the YAML format and describes how the application should be deployed, managed and automated. It identifies the resources and events for every application tier. The cloud orchestrator uses blueprints to install applications in the cloud using a cloud API, which creates VMs and installs Cloudify agents, and is used to orchestrate, install and start the application. Cloudify monitors the application for any pre-defined metrics and displays results on the dashboard. + +Cloudify enables users to deploy applications using two main methods — by using the CLI and by using a Cloudify manager. The latter is a dedicated environment comprising an open source stack which enables the user to: + + * Use plugins (such as Docker, Script, Chef and Puppet plugins) to manage application hosts. + * Keep a directory of the user’s blueprints. + * Create multiple deployments for each blueprint and install them. + * Execute healing, scaling and other custom workflows on installed applications. + * Run multiple workflows concurrently. + * View an application’s topology. + * Perform different tasks using the Cloudify Web UI view metrics. + + + +Cloudify performs the following tasks. + + * _Application modelling:_ This describes the application with all its resources. + * _Orchestration:_ This maintains and runs an application, and performs ongoing operations such as scaling, healing and maintenance. + * _Pluggability:_ This provides reusable component abstraction for the system. + * _Security:_ This provides secure communication via SSL, which enables clients to ensure that the data set received is encrypted. + + + +_**Features**_ +Easy orchestration, built-in node types, a blueprints catalogue, role-based access control, IT security and governance, network and TOSCA orchestration, new NFV capabilities, custom widgets and LDAP integration. + +_**Official website:**_ +_**Latest version:**_ 5.0 + +**Mist.io** +Mist.io is a platform that simplifies cloud management and helps users prevent vendor and complexity lock-in. It offers cost and usage reporting, RBAC, management, provisioning, orchestration, monitoring and automation for servers across public and private clouds, Docker containers and KVM hypervisors. It gives actionable alerts so users can address operational issues from anywhere, using any Web-connected device. + +Mist.io offers a unified interface for performing common management tasks like provisioning, orchestration, monitoring and automation. It works from any device, including laptops, tablets and phones, to help users take action from where ever they are. Due to the RESTful API and command line tools, it’s easy to integrate it in the user’s existing workflow. Because Mist.io abstracts the infrastructure level, users can replicate the entire setup across providers in a matter of seconds. It’s a freemium service with an open source component that aims to become the de facto standard for multi-cloud management and a broker of cloud computing services. It’s targeted at developers, systems administrators and any organisation that performs on-premise, remote, or hybrid computing. + +_**Features**_ + + * Controls public and private clouds, containers, bare metal servers and more. + * Has fine grained controls for delegating access to team members. + * Enables cost and usage reporting across the whole infrastructure. + * Orchestrates repeatable deployments, and automates common responses. + * Enforces policies consistently, across any computing platform. + + + +_**Official website:** _ + +**VirtEngine** +VirtEngine is an open source CMP that can be used to build private or public clouds, which support IaaS, PaaS and SaaS. This Platform as a Service system allows customers to deploy applications in a few clicks. VirtEngine has a wide range of applications and a simple user interface for customers to self-serve their needs. It helps users build both public and private clouds within very little time, and supports infrastructure platforms and other storage devices. It is also very scalable and comes with automation tools that provide companies a competitive advantage. VirtEngine by DET.io is available as two different solutions for the public and private cloud. The public cloud allows users to build their own cloud and offer servers to customers. It is available as a mini edition as well as a complete solution. The private cloud is available as an open source and free solution as well as a powerful solution for enterprises that supports HA and other enterprise features. + +_**Features**_ + + * Access control, demand and supply monitoring, cost management, multi-cloud management, one-click apps, and automatic launch. + * DNS support, self-healing, cloud-native, multi-locations, Docker containers, cloud virtual machines and migration tools. + + + +_**Official website:**_ __ + +![Figure 3: OpenNebula components][5] + +**openQRM** +openQRM is a free and open source cloud computing management platform for managing heterogeneous data centre infrastructures. It provides a complete, automated workflow engine for all bare metal and VM deployment, as well as for all IT sub-systems, enabling professional management and monitoring of the data centre and cloud capacities. The openQRM platform manages a data centre’s infrastructure to build private, public and hybrid Infrastructure as a Service clouds. openQRM orchestrates storage, networks, virtualisation, monitoring and security implementation technologies to deploy multi-tier services as virtual machines on distributed infrastructures, combining both data centre resources and remote cloud resources, according to allocation policies. + +openQRM provides a Web-based, open source data centre management and cloud platform with the help of which various internal and external technologies can be abstracted and grouped within a common management tool. This management system also takes care of provisioning, high availability and the monitoring of services offered. Instead of providing individual tools for individual tasks, such as configuration management and system monitoring, openQRM integrates proven open source management tools such as Nagios and Zabbix. + +_**Architecture:**_ The openQRM system architecture comprises three components — data centre management and cloud platform, the plugin API, and the hybrid cloud connector. + +The data centre management and cloud platform provides the basic functionality of openQRM, and uses the plugin API to communicate with the data centre’s resources that are also installed on the local network (hypervisor, storage and network). openQRM comes with support for five virtualisation environments — VMware ESX, Citrix XenServer, KVM, LXC and OpenVZ. + +openQRM can handle LVM, iSCSI, NFS, ATA over Ethernet, SAN Boot and Tmpfs storage. For the network configuration, openQRM integrates critical network services such as DNS, DHCP, TFTP and Wake-on-LAN. The network manager included with the package helps administrators configure the network bridges required for these services. The hybrid cloud connector takes care of connecting with external data centre resources, such as Amazon Web Services, Eucalyptus, or OpenStack cloud. +The openQRM cloud portal provides a Web interface that internal or external users can access to compile IT resources, as needed. + +_**Features**_ + + * Supports P2V, P2P, V2P, V2V migrations and high availability. + * Integrates with all major open and commercial storage technologies. + * Integrated billing system that maps CCU/h (cloud computing units) to real currency. + * Self-service portal for end users provisions new servers and application stacks in minutes! + + + +_**Official website:** _ + +**OpenNebula** +OpenNebula is a simple yet powerful and flexible turnkey open source solution to build private clouds and manage data centre virtualisation. The OpenNebula platform manages a data centre’s virtual infrastructure to build private, public and hybrid implementations of Infrastructure as a Service. The two primary uses of the OpenNebula platform are data centre virtualisation solutions and cloud infrastructure solutions. + +OpenNebula was designed to help companies build simple, cost-effective, reliable, open enterprise clouds on existing IT infrastructure. It provides flexible tools that orchestrate storage, network and virtualisation technologies to enable the dynamic placement of services. The design of OpenNebula is flexible and modular, to allow integration with different storage and network infrastructure and hypervisor technologies. + +OpenNebula components include the following three layers: + +1\. The driver layer is responsible for the creation, start-up and shutdown of virtual machines (VMs), for allocating storage to VMs, and for monitoring the operational status of physical machines (PMs). +2\. The core layer manages the VMs’ full life cycle, including setting up virtual networks dynamically, dynamic IP address allocation for VMs and managing VMs’ storage. +3\. The tool layer provides interfaces, such as the command line interface (CLI), to communicate with users. + +_**Features**_ + + * Supports numerous APIs like AWS EC2, EBS and OGF OCCI. + * Powerful UNIX based CLI for administration. + * GUI for cloud customers and data centre professionals. + * Resource allocation via fine-grained ACLs; load balancing, high availability, high performance computing. + * Powerful scheduling for task management. + * Supports integration with LDAP and Active directory. + * Supports SSH and X.509 for security, and even supports login token functionality. + + + +_**Official website:** _ +_**Latest version:**_ 5.8.4 + +**Eucalyptus** +Eucalyptus is an acronym for Elastic Utility Computing Architecture for Linking Your Programs to Useful Systems. It is an open source software framework that provides the platform for private cloud computing implementation on computer clusters. Eucalyptus implements Infrastructure as a Service (IaaS) methodology for solutions in private and hybrid clouds. + +Eucalyptus provides a platform for a single interface so that users can calculate the resources available in private clouds and the resources available externally in public cloud services. It is designed with extensible and modular architecture for Web services. It also implements the industry standard Amazon Web Services (AWS) API. + +![Figure 4: Eucalyptus architecture][6] + +The Eucalyptus user console provides an interface for users to provision and configure compute, network and storage resources on their own. Eucalyptus can run multiple versions of Windows and Linux virtual machine images. Users can build a library of Eucalyptus machine images (EMIs) with application metadata that is decoupled from infrastructure details to allow them to run on Eucalyptus clouds. + +Amazon Machine Images are also compatible with Eucalyptus clouds. VMware images and vApps can be converted to run on Eucalyptus clouds and AWS public clouds. Eucalyptus user identity management can be integrated with existing Microsoft Active Directory or LDAP systems to have fine-grained role-based access control over cloud resources. Eucalyptus supports storage area network devices to take advantage of storage arrays, thus improving performance and reliability. Eucalyptus machine images can be backed by EBS-like persistent storage volumes, improving the performance of image launch time and enabling fully persistent virtual machine instances. Eucalyptus also supports direct-attached storage. + +_**Architecture:**_ The Eucalyptus architecture has the following five main components. + + * **Cloud controller (CLC):** CLC acts as the administrative interface for cloud management and performs high-level resource scheduling and system accounting. The CLC accepts user API requests from command-line interfaces like euca2ools or GUI-based tools like the Eucalyptus management console, and manages the underlying computer storage and network resources. + * **Scalable object storage (SOS):** This is a pluggable service that allows infrastructure administrators the flexibility to implement scale-out storage on top of commodity resources using open source and commercial solutions that implement the S3 interface. + * **Cluster controller (CC):** Written in C, this acts as the front-end for clusters within the Eucalyptus cloud and communicates with the storage and node controllers. + * **Storage controller (SC):** Written in Java, this communicates with the cluster controller and the node controller, managing Eucalyptus block volumes and snapshots to instances within its specific cluster. It interfaces with storage systems including Local, NFS, iSCSI and SAN. + * **Node controller (NC):** This is written in C, hosts the virtual machine instances and manages the virtual network endpoints. It caches images from scalable object storage, and creates and caches instances. + + + +_**Features**_ + + * Works with multiple hypervisors including VMware, Xen and KVM. + * Communication within internal processes is secured through SOAP and WS-Security. + * Offers administrative features such as user and group management, and reports. + * Well-defined interfaces (via WSDL, since they are Web services) and thus can be easily swapped out for custom components. + * Flexible and can be installed on a very minimal setup. + + + +_**Official website:** _ +_**Latest version:**_ 4.4.3 + +![Avatar][7] + +[Dr Anand Nayyar][8] + +The author works in a Graduate School, Duy Tan University in +Vietnam. He loves to work and research on open source technologies, +sensor communications, network security, Internet of Things etc. He +can be reached at [anandnayyar@duytan.edu.vn][9]. YouTube channel: +Gyaan with Anand Nayyar at [www.youtube.com/anandnayyar][10]. + +[![][11]][12] + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/the-top-nine-open-source-cloud-management-platforms/ + +作者:[Dr Anand Nayyar][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://opensourceforu.com/author/anand-nayyar/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/09/Young-man-with-the-head-in-the-clouds-thinking_15259762_xl.jpg?resize=505%2C487&ssl=1 (Young-man-with-the-head-in-the-clouds-thinking_15259762_xl) +[2]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/09/Young-man-with-the-head-in-the-clouds-thinking_15259762_xl.jpg?fit=505%2C487&ssl=1 +[3]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-1-CloudStack-architecture.jpg?resize=350%2C250&ssl=1 +[4]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-2-OpenStack-components.jpg?resize=350%2C226&ssl=1 +[5]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-3-OpenNebula-components.jpg?resize=350%2C196&ssl=1 +[6]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-4-Eucalyptus-architecture.jpg?resize=350%2C241&ssl=1 +[7]: https://secure.gravatar.com/avatar/ab87a2bd63788f386c2d815c0f7d2d29?s=100&r=g +[8]: https://opensourceforu.com/author/anand-nayyar/ +[9]: mailto:anandnayyar@duytan.edu.vn +[10]: http://www.youtube.com/anandnayyar +[11]: https://opensourceforu.com/wp-content/uploads/2019/11/assoc.png +[12]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/sources/tech/20191111 Understanding -disk space math.md b/sources/tech/20191111 Understanding -disk space math.md new file mode 100644 index 0000000000..fbbe9d3aa7 --- /dev/null +++ b/sources/tech/20191111 Understanding -disk space math.md @@ -0,0 +1,124 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Understanding “disk space math”) +[#]: via: (https://fedoramagazine.org/understanding-disk-space-math/) +[#]: author: (Pat Kelly https://fedoramagazine.org/author/tablepc/) + +Understanding “disk space math” +====== + +![][1] + +Everything in a PC, laptop, or server is represented as binary digits (a.k.a. _bits,_ where each bit can only be 1 or 0). There are no characters like we use for writing or numbers as we write them anywhere in a computer’s memory or secondary storage such as disk drives. For general purposes, the unit of measure for groups of binary bits is the byte — eight bits. Bytes are an agreed-upon measure that helped standardize computer memory, storage, and how computers handled data. + +There are various terms in use to specify the capacity of a disk drive (either magnetic or electronic). The same measures are applied to a computers random access memory (RAM) and other memory devices that inhabit your computer. So now let’s see how the numbers are made up. + +Suffixes are used with the number that specifies the capacity of the device. The suffixes designate a multiplier that is to be applied to the number that preceded the suffix. Commonly used suffixes are: + + * Kilo = 103 = 1,000 (one thousand) + * Mega = 106 = 1,000,000 (one million) + * Giga = 109 = 1000,000,000 (one billion) + * Tera = 1012 = 1,000,000,000,000 (one trillion) + + + +As an example 500 GB (gigabytes) is 500,000,000,000 bytes. + +The units that memory and storage are specified in  advertisements, on boxes in the store, and so on are in the decimal system as shown above. However since computers only use binary bits, the actual capacity of these devices is different than the advertised capacity. + +You saw that the decimal numbers above were shown with their equivalent powers of ten. In the binary system numbers can be represented as powers of two. The table below shows how bits are used to represent powers of two in an 8 bit Byte. At the bottom of the table there is an example of how the decimal number 109 can be represented as a binary number that can be held in a single byte of 8 bits (01101101). + +Eight bit binary number | | | | | | | | +---|---|---|---|---|---|---|---|--- +| Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 +Power of 2 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 +Decimal Value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 +Example Number | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 + +The example bit values comprise the binary number 01101101. To get the equivalent decimal value just add the decimal values from the table where the bit is set to 1. That is 64 + 32 + 8 + 4 + 1 = 109. + +By the time you get out to 230 you have decimal 1,073,741,824 with just 31 bits (don’t forget the 20) You’ve got a large enough number to start specifying memory and storage sizes. + +Now comes what you have been waiting for. The table below lists common designations as they are used for labeling decimal and binary values. + +Decimal + +| + +Binary + +---|--- + +KB (Kilobyte) + +1KB = 1,000 bytes + +| + +KiB (Kibibyte) + +1KiB = 1,024 bytes + +MB (Megabyte) + +1MB = 1,000,000 bytes + +| + +MiB (Mebibyte) + +1MiB = 1,048,576 bytes + +GB (Gigabyte) + +1GB = 1,000,000,000 bytes + +| + +GiB (Gibibyte) + +1 GiB (Gibibyte) = 1,073,741,824 bytes + +TB (Terabyte) + +1TB = 1,000,000,000,000 + +| + +TiB (Tebibyte) + +1TiB = 1,099,511,627,776 bytes + +Note that all of the quantities of bytes in the table above are expressed as decimal numbers. They are not shown as binary numbers because those numbers would be more than 30 characters long. + +Most users and programmers need not be concerned with the small differences between the binary and decimal storage size numbers. If you’re developing software or hardware that deals with data at the binary level you may need the binary numbers. + +As for what this means to your PC: Your PC will make use of the full capacity of your storage and memory devices. If you want to see the capacity of your disk drives, thumb drives, etc, the Disks utility in Fedora will show you the actual capacity of the storage device in number of bytes as a decimal number. + +There are also command line tools that can provide you with more flexibility in seeing how your storage bytes are being used. Two such command line tools are [_du_][2] (for files and directories) and [_df_][3] (for file systems). You can read about these by typing _man du_ or _man df_ at the command line in a terminal window. + +* * * + +*Photo by _[_Franck V._][4]_ on *[_Unsplash_][5]. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/understanding-disk-space-math/ + +作者:[Pat Kelly][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/tablepc/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/11/disk-space-math-816x345.jpg +[2]: https://linux.die.net/man/1/du +[3]: https://linux.die.net/man/1/df +[4]: https://unsplash.com/@franckinjapan?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[5]: https://unsplash.com/s/photos/math?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/sources/tech/20191112 5 open source plugins for Flutter apps.md b/sources/tech/20191112 5 open source plugins for Flutter apps.md new file mode 100644 index 0000000000..2f529b9303 --- /dev/null +++ b/sources/tech/20191112 5 open source plugins for Flutter apps.md @@ -0,0 +1,853 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (5 open source plugins for Flutter apps) +[#]: via: (https://opensource.com/article/19/11/open-source-plugins-flutter-apps) +[#]: author: (Baradwaj Varadharajan https://opensource.com/users/baradwaj) + +5 open source plugins for Flutter apps +====== +Create more useful and attractive apps faster with these plugins for +Google's cross-platform development language. +![][1] + +[Flutter][2] is the newest addition to Google's programming cadre. Following the success of Android, Kotlin, and Golang, [Flutter][3] was created as a cross-platform application development language. It is primarily based on the Dart programming construct and is considered to be the next big programming paradigm because its code can run as a mobile app, a web app, and even a desktop app without any major changes. Supposedly it will support Google's upcoming [Fuschia][4] operating system. + +Flutter plugins are simple dependencies that extend the language's capabilities. This list of the top five open source Flutter plugins includes both user interface (UI)-related and function-related plugins. + +The plugins must be included in your **pubspec.yaml** file before they can be used; they are required to make modifications to the **pubspec.yaml** file in the **lib** folder inside the project. + +### Flutter video-player plugin + +The video_player plugin allows you to embed videos to play in Flutter apps.  + +_Note: Up to Flutter 1.9, there is no video player support present in Flutter, so you have to depend on external plugins like video_player. This provides us with the VideoPlayer class which we will be using here._ + +Before using the VideoPlayer class in Flutter, you have to do the following for iOS and Android applications. + +#### Prerequisites + +**For Android:** + +Make sure that the minimum SDK is set to 21. You can modify this through the Build Gradle inside the **android>app** folder. + +Next, make sure that the **AndroidManifest.xml** file has internet permission enabled by adding the following line in the **AndroidManifest.xml** file: + + +``` +`` +``` + +**For iOS:** + +To give permission to use the internet to render the videos (if required), add the following lines to the **info.plist** file in **<project root>/ios/Runner/Info.plist**: + + +``` +<key>NSAppTransportSecurity</key> +<dict> +  <key>NSAllowsArbitraryLoads</key> +  <true/> +</dict> +``` + +Once the prerequisites for Android and iOS are done, add the following line to the **pubspec.yaml** file in the **dependency** section: + + +``` +`dependencies: video_player: ^0.10.1+3` +``` + +Then use **get packages** to sync the project. + +#### Video_Player plugin basics + +The Video_Player plugin provides support for playing network and local videos on a device by creating a simple API to call the videos. The example application below shows how the Video_Player plugin uses the controller object and how to create the **Future<> Builder** to play the video on loading. + +Start by using the [Scaffold widget][5] as the parent body widget. The goal is for the user to be able to play and pause a video using button controls. + +In order to call the video player object from anywhere, you need a controller to hold it. The VideoPlayerController class makes this possible. The example application pieces it all together. + +#### Example Flutter Video Player app + + +``` +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:video_player/video_player.dart'; + +void main() => runApp(VideoPlayerApp()); + +class VideoPlayerApp extends StatelessWidget { +  @override +  Widget build(BuildContext context) { +    return MaterialApp( +      title: 'Video Player Demo', +      home: VideoPlayerScreen(), +    ); +  } +} + +class VideoPlayerScreen extends StatefulWidget { +  VideoPlayerScreen({Key key}) : super(key: key); + +  @override +  _VideoPlayerScreenState createState() => _VideoPlayerScreenState(); +} + +class _VideoPlayerScreenState extends State<VideoPlayerScreen> { +  VideoPlayerController _controller; +  Future<void> _initializeVideoPlayerFuture; + +  @override +  void initState() { +    _controller = VideoPlayerController.network( +      '', +    ); + +    // Initialize the controller and store the Future for later use. +    _initializeVideoPlayerFuture = _controller.initialize(); + +    // Use the controller to loop the video. +    _controller.setLooping(true); +    super.initState(); +  } + +  @override +  void dispose() { +    // Ensure disposing of the VideoPlayerController to free up resources. +    _controller.dispose(); + +    super.dispose(); +  } + +  @override +  Widget build(BuildContext context) { +    return Scaffold( +      drawer: Drawer(), +      backgroundColor: Colors.orangeAccent, +      appBar: AppBar( +        title: Text('Bee Video'), +        backgroundColor: Colors.black87, +      ), +      // Use a FutureBuilder to display a loading spinner while waiting for the +      // VideoPlayerController to finish initializing. +      body: Stack( +        children: <Widget>[ +          Center(child:FutureBuilder( +            future: _initializeVideoPlayerFuture, +            builder: (context, snapshot) { +              if (snapshot.connectionState == ConnectionState.done) { +                // If the VideoPlayerController has finished initialization, use +                // the data it provides to limit the aspect ratio of the video. +                return AspectRatio( +                  aspectRatio: _controller.value.aspectRatio, +                  // Use the VideoPlayer widget to display the video. +                  child: VideoPlayer(_controller), +                ); +              } else { +                // If the VideoPlayerController is still initializing, show a +                // loading spinner. +                return Center(child: CircularProgressIndicator()); +              } +            }, +          )), +          Center( +              child: +             ButtonTheme( +                  height: 100.0, +                  minWidth: 200.0, +                  child: RaisedButton( +                    padding: EdgeInsets.all(60.0), +                    color: Colors.transparent, +                    textColor: Colors.white, +                    onPressed: () { +                      // Wrap the play or pause in a call to `setState`. This ensures the +                      // correct icon is shown. +                      setState(() { +                        // If the video is playing, pause it. +                        if (_controller.value.isPlaying) { +                          _controller.pause(); +                        } else { +                          // If the video is paused, play it. +                          _controller.play(); +                        } +                      }); +                    }, +                    child: Icon( +                      _controller.value.isPlaying ? Icons.pause : Icons.play_arrow, +                      size: 120.0, +                    ), +                  )) +          ) +        ], +      ), +    ); +  } +} +``` + +Here's the resulting application. + +![Flutter Video Plugin][6] + +![Flutter Video Plugin][7] + +### Flutter Shimmer Effect plugin + +The Flutter [Shimmer Effect][8] UI plugin is fairly straightforward: You just make use of only one class in your widget tree, and the work is done. Here is what the Shimmer Effect looks like: + +![Flutter Shimmer Effect plugin][9] + +To implement this effect, jump into the widget definition and use the **Shimmer** class in your widget tree with this option: + + +``` +`Shimmer.fromColors` +``` + +Next, finalize the application by filling out the properties described below. + +#### Shimmer.fromColors properties + +**Shimmer.fromColors** has the following properties: + + * **baseColor:** This is the shimmer's base color that gets shown on the widget. This is the primary color and the one the child widget will use. + * **HighlightColor:** This is the color that produces the shimmer-like effect by continually waving across the child widget. + * **Child:** This holds whatever widget produces the Shimmer Effect. It could be a Text widget or any complex structure. + + + +The example program shows how these attributes work across complex widgets. + +#### Example Flutter Shimmer Effect app + +This example produces the Shimmer Effect for two important widgets: the Text widget and the [Listview widget][10]. + + +``` +import 'dart:async'; +import 'package:flutter/material.dart'; +import 'package:shimmer/shimmer.dart'; + +void main() => runApp(ShimmerEffectApp()); + +class ShimmerEffectApp extends StatelessWidget { +@override +Widget build(BuildContext context) { +return MaterialApp( +title: 'Sample ShimmerEffect Widget', +home: ShimmerWidget(), +); +} +} + +class ShimmerWidget extends StatefulWidget { +ShimmerWidget({Key key}) : super(key: key); + +@override +_ShimmerWidgetState createState() => _ShimmerWidgetState(); +} + +class _ShimmerWidgetState extends State { + +@override +void initState() { +super.initState(); +} + +@override +Widget build(BuildContext context) { +return Scaffold( +appBar: AppBar(title: Text("Shimmer effect"),), +body: Container( +padding: EdgeInsets.all(25.0), +child:Center( +child: Shimmer.fromColors( +direction: ShimmerDirection.rtl, +period: Duration(seconds:5), +child: Column( +children: [0, 1, 2, 3] +.map((_) => Padding( +padding: const EdgeInsets.only(bottom: 8.0), +child: Row( +crossAxisAlignment: CrossAxisAlignment.start, +children: [ +Container( +width: 48.0, +height: 48.0, +color: Colors.white, +), +Padding( +padding: +const EdgeInsets.symmetric(horizontal: 8.0), +), +Expanded( +child: Column( +crossAxisAlignment: CrossAxisAlignment.start, +children: [ +Container( +width: double.infinity, +height: 8.0, +color: Colors.white, +), +Padding( +padding: +const EdgeInsets.symmetric(vertical: 2.0), +), +Container( +width: double.infinity, +height: 8.0, +color: Colors.white, +), +Padding( +padding: +const EdgeInsets.symmetric(vertical: 2.0), +), +Container( +width: 40.0, +height: 8.0, +color: Colors.white, +), +], +), +) +], +), +)) +.toList(), +), +baseColor: Colors.grey[700], +highlightColor: Colors.grey[100]), +) +), +); +} +} +``` + +Here's the resulting application. + +![Flutter Shimmer Effect plugin][11] + +![Flutter Shimmer Effect plugin][12] + +### Flutter Badges plugin + +[Flutter Badges][13] is a very useful UI plugin that marks a notification count, a count of items in an e-commerce basket, etc. + +To use the Flutter Badges plugin, add the following dependency in your **pubspec.yaml** file: + + +``` +dependencies: +    badges: ^1.1.0 +``` + +Then, import the following line into your **main.dart** file: + + +``` +`import 'package:badges/badges.dart';` +``` + +Now, you can create badges with a simple call to the **Badge class.** + +#### Badge class properties + +Following are the Badge class's available properties: + + * **badgeContent:** This is the attribute that takes in the value of the Badge. It could be a number, a letter, etc. Make sure to make it as small as possible! + * **BadgeColor:** Control the color of the badge by adjusting the BadgeColor colors property. + * **AnimationType:** This enables three animations for the Badge: + * **BadgeAnimationType.scale:** Scales animation once loading happens. + * **BadgeAnimationType.fade:** Fades animation once loading happens + * **BadgeAnimationType.slide:** Slides animation once loading happens + * **shape:** This controls the shape of the badge; it could be a circle or a square. + * **AnimationDuration:** This takes in a Duration class as its value to set how long the animation should last. + + + +Once these attributes are set, you can create a simple app like the following. + +#### Example Flutter Badge application + +Add the following to your **main.dart** file and run the application. + + +``` +import 'dart:async'; +import 'package:flutter/material.dart'; +import 'package:badges/badges.dart'; + +void main() => runApp(BadgesApp()); + +class BadgesApp extends StatelessWidget { +@override +Widget build(BuildContext context) { +return new MaterialApp( +title: 'APP', +home: BadgesWidget(), +); +} +} + +class BadgesWidget extends StatefulWidget { +BadgesWidget({Key key}) : super(key: key); + +@override +_BadgesWidgetState createState() => _BadgesWidgetState(); +} + +class _BadgesWidgetState extends State { + +int value = 0; + +@override +void initState() { +super.initState(); +} + +@override +Widget build(BuildContext context) { +return Scaffold( +appBar: AppBar(title:Text("Sample Badges")), +body: Center( +child: Container( +padding: EdgeInsets.all(25.0), +child: Column( +children: [ +Spacer(), +Badge( +child: RaisedButton( +color: Colors.blueGrey, +child: Text("Notifications", style: TextStyle(color: Colors.white),), +onPressed: (){ +setState(() { +value = value + 1; +}); +},), +badgeContent: Text('$value',style: TextStyle(color: Colors.white),), +badgeColor: Colors.red, +animationType: BadgeAnimationType.scale, +animationDuration: Duration(milliseconds: 500), +shape: BadgeShape.circle, +), +Spacer(), +Badge( +child: RaisedButton( +color: Colors.blueGrey, +child: Text("Messages", style: TextStyle(color: Colors.white),), +onPressed: (){ + +},), +badgeContent: Text("2",style: TextStyle(color: Colors.white),), +badgeColor: Colors.red, +animationType: BadgeAnimationType.scale, +animationDuration: Duration(seconds: 1), +shape: BadgeShape.circle, +), +Spacer(), +Badge( +child: RaisedButton( +color: Colors.blueGrey, +child: Text("Notifications", style: TextStyle(color: Colors.white),), +onPressed: (){ +},), +badgeContent: Text("2",style: TextStyle(color: Colors.white),), +badgeColor: Colors.red, +animationType: BadgeAnimationType.scale, +animationDuration: Duration(seconds: 1), +shape: BadgeShape.circle, +), +Spacer(flex: 4,) +], +), +), +) +); +} +} +``` + +Here's the resulting application. + +![Flutter Badges plugin][14] + +### Flutter Google Maps plugin + +Adding Google Maps in Flutter apps is a very easy process with the help of the **google_maps_flutter** plugin. + +_Note: The Google Maps Flutter plugin is still in developer preview (so it cannot be released to the app store yet). Make sure to wait for the stable release before using it._ + +The main prerequisites for using this plugin are to have a [Google Cloud Platform][15] account and to create a Google Maps API key. If you do not know how to obtain a key, see [Google Maps Integration in Flutter][16]. + +Once the Google Maps SDK is enabled with a credential/API key, you can use it in your Flutter app. Fill out the following with the key. + +**For Android:** + +Go to **android>app>src>main>Androidmanifest.xml** and make sure that the manifest looks like the following (replacing YOUR KEY HERE with your API key): + + +``` +<manifest ... +  <application ... +    <meta-data android:name="com.google.android.geo.API_KEY" +               android:value="YOUR KEY HERE"/> +``` + +**For iOS:** + +Edit the **Appdelegate.m** file as follows (replacing YOUR KEY HERE with your API key): + + +``` +@implementation AppDelegate + +\- (BOOL)application:(UIApplication *)application +    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { +  [GMSServices provideAPIKey:@"YOUR KEY HERE"]; +  [GeneratedPluginRegistrant registerWithRegistry:self]; +  return [super application:application didFinishLaunchingWithOptions:launchOptions]; +} +@end +``` + +#### GoogleMaps widget basics + +Now it's time to bring the Maps inside the Flutter application. To begin, add the following dependency in the **pubspec.yaml** file: + + +``` +dependencies: + google_maps_flutter: ^0.5.21 +``` + +Import the following package to the **main.dart** file: + + +``` +`import 'package:google_maps_flutter/google_maps_flutter.dart';` +``` + +This package provides the following widgets: + +##### GoogleMap + +The GoogleMap widget provides the main control over Google Maps inside a Flutter application. It has several important attributes that help create the maps you require. They are: + + * **mapType:** This attribute defines what type of map (satellite, hybrid, or normal) is shown. Select one by with the value MapType.satellite, MapType.hybrid, or MapType.normal. + * **InitialCameraPosition:** The initial camera position is important for rendering the map on the Flutter UI and setting the camera position (from which the camera will move). Set the initial camera position by creating a variable with the **CameraPosition** class as its value. + * **OnMapCreated:** This is a callback that fires whenever the camera position changes (e.g., whenever the user moves the map by pinching or swiping it). To move the camera angle programmatically, use GoogleMapController instead. + + + +##### GoogleMapController + +This class controls the Google Map by creating an instance of it. There is no explicit way to change the camera position of the Google Map, but you can use the GoogleMapController to control all sorts of activities on the GoogleMap class. + +##### CameraPosition + +The CameraPosition class provides the camera position values that are required to show any position on the GoogleMap. + + +``` +CameraPosition initPosition = CameraPosition( +target: LatLng(14.5, 25.7), zoom: 7, ); +``` + +The CameraPosition class takes in various attributes, like target, zoom, etc. The **Target** attribute marks the latitude and longitude position on the Google Map. The class takes in a double value like **LatLng(double, double)** to mark it at that position. + +#### Example Flutter GoogleMaps app + +This example app creates an animated camera transition on a Google Map. This is a very useful way to provide [Google Maps in Flutter][16] applications. + + +``` +import 'dart:async'; +import 'package:flutter/material.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; + +void main() => runApp(GoogleMapApp()); + +class GoogleMapApp extends StatelessWidget { +@override +Widget build(BuildContext context) { +return MaterialApp( +title: 'Sample GoogleMap Widget', +home: GoogleMapWidget(), +); +} +} + +class GoogleMapWidget extends StatefulWidget { +GoogleMapWidget({Key key}) : super(key: key); + +@override +_GoogleMapWidgetState createState() => _GoogleMapWidgetState(); +} + +class _GoogleMapWidgetState extends State { + +Completer _controller = Completer(); + +@override +void initState() { +super.initState(); +} + +CameraPosition initPosition = CameraPosition( +target: LatLng(14.5, 25.7), +zoom: 7, +); + +void updateGoogleMap() +async{ +GoogleMapController cont = await _controller.future; +setState(() { +CameraPosition newtPosition = CameraPosition( +target: LatLng(14.5, 28.7), +zoom: 4, +); +cont.animateCamera(CameraUpdate.newCameraPosition(newtPosition)); +}); + +} + +@override +Widget build(BuildContext context) { +return Scaffold( +appBar: AppBar( +backgroundColor: Colors.black45, +title: Text("Update Google Map"), +), +body: Center( +child: Column( +children: [ +Container( +height: 400.0, +child: GoogleMap( +mapType: MapType.hybrid, +initialCameraPosition: initPosition, +onMapCreated: (GoogleMapController controller){ +_controller.complete(controller); +}, +), +), +FlatButton( +child: Text("Update Map", style: TextStyle(color: Colors.white),), +color: Colors.deepOrange, +onPressed: (){ +updateGoogleMap(); +}, +) +], +), +)); +} +} +``` + +Here's the resulting application. + +![Flutter Google Maps plugin][17] + +![Flutter Google Maps plugin][18] + +### Flutter ImagePicker image gallery plugin + +The ImagePicker plugin integrates an image gallery into a Flutter app. + +To begin using the [**image_picker**][19] plugin, add the following dependency in the **pubspec.yaml** file: + + +``` +dependencies: +  image_picker: ^0.6.1+4 +``` + +This requires you to add an import statement in your main file, e.g., **main.dart** file: + + +``` +`import 'package:image_picker/image_picker.dart';` +``` + +To use the Flutter application in iOS, make the following changes in the **info.plist** file: + + * **NSPhotoLibraryUsageDescription:** This describes why the app needs permission to use the photo library. This is called _Privacy - Photo Library Usage Description_ in the visual editor. + * **NSCameraUsageDescription:** This describes why your app needs access to the camera. This is called _Privacy - Camera Usage Description_ in the visual editor. + * **NSMicrophoneUsageDescription:** This describes why your app needs access to the microphone if you intend to record videos. This is called _Privacy - Microphone Usage Description_ in the visual editor. + + + +#### Image Picker widget basics + +To use the ImagePicker widget, just call the class [**ImagePicker**][20]. There are two options for this class: + + * Choose an image or choose a video + * Choose an image or video directly from a gallery or a camera source + + + +This is possible through two method callbacks: + + * **ImagePicker.pickImage()** with the source **ImageSource.gallery** or **ImageSource.camera** + * **ImagePicker.pickVideo()** with the above sources + + + +Both of these calls are async calls, which require **setState()** on the image or video that is selected. + +**ImagePicker.<source call>** returns the file location of the image/video. You must load the image using the **Image.file()** call. + +All of this is explained in the example application. + +#### Example Flutter ImagePicker widget app + +This example app creates an [Image Picker button][20] to select an image from the gallery or directly from the camera. + + +``` +import 'dart:async'; +import 'dart:io'; +import 'package:flutter/material.dart'; +import 'package:image_picker/image_picker.dart'; + +void main() => runApp(ImagePickerApp()); + +class ImagePickerApp extends StatelessWidget { +@override +Widget build(BuildContext context) { +return MaterialApp( +title: 'Sample Imagepicker Widget', +home: ImagePickerWidget(), +); +} +} + +class ImagePickerWidget extends StatefulWidget { +ImagePickerWidget({Key key}) : super(key: key); + +@override +_ImagePickerWidgetState createState() => _ImagePickerWidgetState(); +} + +class _ImagePickerWidgetState extends State { + +File _image; +@override +void initState() { +super.initState(); +} + +void open_camera() +async { +var image = await ImagePicker.pickImage(source: ImageSource.camera); +setState(() { +_image = image; +}); + +} +void open_gallery() +async { +var image = await ImagePicker.pickImage(source: ImageSource.gallery); +setState(() { +_image = image; +}); +} +@override +Widget build(BuildContext context) { +return Scaffold( +appBar: AppBar(title: Text("Sample Imagepicker Widget"), +backgroundColor: Colors.black45,), +body: Center( +child: Container( +child: Column( +children: [ +Container( +color: Colors.black12, +height: 300.0, +width: 900.0, +child: _image == null ? Text("Still waiting!") : Image.file(_image),), +FlatButton( +color: Colors.deepOrangeAccent, +child: Text("Open Camera", style: TextStyle(color: Colors.white),), +onPressed: (){ +open_camera(); +},), +FlatButton( +color: Colors.limeAccent, + +child:Text("Open Gallery", style: TextStyle(color: Colors.black),), +onPressed: (){ +open_gallery(); +}, +) +], +), +), +) + +); + +} +} +``` + +Here's the resulting application. + +![Flutter ImagePicker widget][21] + +![Flutter ImagePicker widget][22] + +![Flutter ImagePicker widget][23] + +### Summary + +These five plugins are very important for creating a neater UI experience in Flutter apps. They will also help you ramp up faster with Flutter app development. + +* * * + +_Some of the information in this article was previously published at [Android Monks][24]._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/open-source-plugins-flutter-apps + +作者:[Baradwaj Varadharajan][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/baradwaj +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bug-insect-butterfly-diversity-inclusion-2.png?itok=TcC9eews +[2]: https://opensource.com/article/18/6/flutter +[3]: https://flutter.dev/ +[4]: https://en.wikipedia.org/wiki/Google_Fuchsia +[5]: https://androidmonks.com/scaffold-flutter/ +[6]: https://opensource.com/sites/default/files/uploads/flutter1_videoplayer.png (Flutter Video Plugin) +[7]: https://opensource.com/sites/default/files/uploads/flutter2_videoplayer.png (Flutter Video Plugin) +[8]: https://androidmonks.com/shimmer-effect-flutter/ +[9]: https://opensource.com/sites/default/files/uploads/flutter3_shimmergif.gif (Flutter Shimmer Effect plugin) +[10]: https://androidmonks.com/listview-flutter/ +[11]: https://opensource.com/sites/default/files/uploads/flutter4_shimmer.png (Flutter Shimmer Effect plugin) +[12]: https://opensource.com/sites/default/files/uploads/flutter5_shimmer.png (Flutter Shimmer Effect plugin) +[13]: https://androidmonks.com/flutter-badges/ +[14]: https://opensource.com/sites/default/files/uploads/flutter6_samplebadges.png (Flutter Badges plugin) +[15]: https://cloud.google.com/maps-platform/ +[16]: https://androidmonks.com/google-maps-flutter/ +[17]: https://opensource.com/sites/default/files/uploads/flutter7_googlemap.png (Flutter Google Maps plugin) +[18]: https://opensource.com/sites/default/files/uploads/flutter8_googlemap.png (Flutter Google Maps plugin) +[19]: https://pub.dev/packages/image_picker +[20]: https://androidmonks.com/imagepicker-flutter/ +[21]: https://opensource.com/sites/default/files/uploads/flutter9_imagepicker.png (Flutter ImagePicker widget) +[22]: https://opensource.com/sites/default/files/uploads/flutter10_imagepicker.png (Flutter ImagePicker widget) +[23]: https://opensource.com/sites/default/files/uploads/flutter11_imagepicker.png (Flutter ImagePicker widget) +[24]: https://androidmonks.com/flutter-open-source-plugins/ diff --git a/sources/tech/20191112 8 great podcasts for open source enthusiasts.md b/sources/tech/20191112 8 great podcasts for open source enthusiasts.md new file mode 100644 index 0000000000..c0d249d754 --- /dev/null +++ b/sources/tech/20191112 8 great podcasts for open source enthusiasts.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (8 great podcasts for open source enthusiasts) +[#]: via: (https://opensource.com/article/19/11/open-source-podcasts) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +8 great podcasts for open source enthusiasts +====== +Expand your knowledge about Linux, Python, and open source generally +while you're doing other things. +![Woman programming][1] + +Where I live, almost everything is a 20- or 30-minute drive from my home, and I'm always looking for ways to use my car time productively. One way is by listening to podcasts on topics that interest me, so as an open source enthusiast, I subscribe to a variety of open source-related podcasts. + +Here are eight Linux and open source podcasts that I Iook forward to every week. + +### Linux4Everyone + +[Linux4Everyone][2] by Jason Evangelho (whom I [recently interviewed][3]) is a favorite. The podcasts always offer fresh insights on Linux along with thoughtful interviews, including his conversations with [Barton George][4] of Dell and [Christopher Scott][5] of Microsoft. Jason's only been at this gig for a few months, but he already has a loyal following supporting him on Patreon. + +I have recently been listening to [**Command Line Heroes**][6]. Its host, Saron Yitbarek, is a developer and the founder of [CodeNewbie][7]. I've learned about how [C and Unix][8] laid important groundwork for the development and growth of Linux, as well as the evolution of the [Python community][9]—which will continue since founder Guido Van Rossum stepped down from his benevolent dictatorship role. + +### Linux Headlines + +[Linux Headlines][10] from [Jupiter Broadcasting][11] never fails to pique my interest in what's happening in the Linux world. Hosts [Chris Fisher][12], [Joe Ressington][13], [Wes Payne][14], and [Drew Davore][15] are always dishing up the latest developments that inspire me to learn and explore more. If you only have a few minutes to spare, this podcast is for you. + +### Self-Hosted + +[Self-Hosted][16] is a new podcast about home networks that hooked me immediately. With all the emphasis on containers and the cloud, you might think your local network doesn't have much to offer anymore. Hosts [Alex Kretzschmar][17] and Chris Fisher are two longtime self-hosters who share their learnings with listeners. + +### Online Life is Real Life + +In [Online Life is Real Life][18], sponsored by Firefox, "host [Manoush Zomorodi][19] shares real stories of life online and real talk about the future of the web." A recent show, "[Privacy or Profit—Why Not Both?][20]," dug into the concept that "privacy" means different things to different people. Do you know how your personal data is being used? Do you care? If so, this podcast might interest you. + +### The Changelog + +[The Changelog][21] bills itself as "conversations with the hackers, leaders, and innovators of software development." In a recent episode, [Chris Anderson][22], former editor-in-chief of _Wired_, shared how his hobby with drones started out terribly wrong but led him to 3D robotics, do-it-yourself drones, and the [Dronecode][23] project. + +### Destination Linux + +[Destination Linux][24], where "Linux is our passion," is a weekly show hosted by [Ryan][25], [Michael][26], [Zebediah][27], and [Noah][28]. The show started in 2017, and all of its content is licensed under Creative Commons 4.0 ShareAlike. One recent podcast focused on the addition of ZFS to Ubuntu 19.10 and how Project Trident ditched FreeBSD for Linux. + +### Talk Python to Me + +[Talk Python To Me][29] with host [Michael Kennedy][30] keeps me growing on my Python learning curve. + +In one of my favorite shows, "[Python in digital humanities research][31]," Michael interviewed Cornelius Van Lit, a medieval Islamic philosophy scholar, who is using Python to parse ancient manuscripts. + +Most of these podcasts come with show notes, which include links to the content they cover. Since I can't take notes when I'm driving, the show notes help me review what I hear and learn more about the topics mentioned. + +I am always eager to learn, so please share your favorite open source-related podcasts in the comments section. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/open-source-podcasts + +作者:[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://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop-music-headphones.png?itok=EQZ2WKzy (Woman programming) +[2]: https://linuxforeveryone.fireside.fm/ +[3]: https://opensource.com/article/19/9/found-linux-video-gaming +[4]: https://twitter.com/barton808?lang=en +[5]: https://opensource.com/article/19/10/trust-linux-community +[6]: https://www.redhat.com/en/command-line-heroes +[7]: https://www.codenewbie.org/ +[8]: https://opensource.com/article/19/10/command-line-heroes-c +[9]: https://opensource.com/article/19/6/command-line-heroes-python +[10]: https://linuxheadlines.show/ +[11]: https://opensource.com/article/19/10/linux-podcasts-Jupiter-Broadcasting +[12]: https://twitter.com/ChrisLAS +[13]: https://twitter.com/JoeRessington +[14]: https://twitter.com/wespayne?lang=en +[15]: https://twitter.com/drewofdoom +[16]: https://selfhosted.show/ +[17]: https://twitter.com/ironicbadger?lang=en +[18]: https://irlpodcast.org/ +[19]: https://twitter.com/manoushz +[20]: https://irlpodcast.org/season5/episode7/ +[21]: https://changelog.com/podcast +[22]: https://twitter.com/chr1sa +[23]: https://www.dronecode.org/ +[24]: https://destinationlinux.org/ +[25]: https://destinationlinux.org/ryan/#contact +[26]: https://twitter.com/michaeltunnell?lang=en +[27]: https://twitter.com/zebedeeboss +[28]: https://destinationlinux.org/noah/ +[29]: https://talkpython.fm/ +[30]: https://twitter.com/mkennedy?lang=en +[31]: https://talkpython.fm/episodes/show/230/python-in-digital-humanities-research diff --git a/sources/tech/20191113 How to cohost GitHub and GitLab with Ansible.md b/sources/tech/20191113 How to cohost GitHub and GitLab with Ansible.md new file mode 100644 index 0000000000..a635054dae --- /dev/null +++ b/sources/tech/20191113 How to cohost GitHub and GitLab with Ansible.md @@ -0,0 +1,175 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to cohost GitHub and GitLab with Ansible) +[#]: via: (https://opensource.com/article/19/11/how-host-github-gitlab-ansible) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +How to cohost GitHub and GitLab with Ansible +====== +Protect your access to important projects by mirroring Git repositories +with Ansible. +![Hands programming][1] + +Open source is everywhere. It's in your computer at home, it's in your computer at work, it's on the internet, and a lot of it is managed with [Git][2]. Because Git is decentralized, many people also think of it as a kind of crowdsourced backup solution. The theory is that each time someone clones a Git repository to their local computer, they are creating a backup of the project's source code. If 100 people do that, then there are 100 backup copies of a repository. + +This, in theory, mitigates "disasters" such as a project maintainer [suddenly deciding to remove a repository][3] or [inexplicably blocking all traffic][4] and leaving developers scrambling to figure out who has the latest version of the master branch. Similarly, entire code-hosting sites have disappeared in the past. Nobody anticipated the closure of Google Code, Microsoft CodePlex, or Gitorious when they were at their peak. + +In short, if the internet has taught us anything over the past few decades, it's that relying on the internet to magically create backups isn't the most reliable road to redundancy. + +Besides, it's a problem for a lot of people that many open source projects are hosted on GitHub, which is not an open platform. Many developers and users would prefer to support and interact with a stack such as GitLab, which has an open source community edition. + +### Using Ansible for Git + +Git's decentralization is useful in solving this problem. Using pure Git, you can easily push to two or more repositories with a single **push** command. However, for that to be useful against unexpected failure, you must be interacting (and pushing, specifically) with a Git repository frequently. Furthermore, there may be repositories out there that you want to back up, even though you may never push or pull the code yourself. + +But using Ansible, you can automate Git pulls of a project's master branch (or any other branch, for that matter) and then automate Git pushes of the repository to an "offsite" mirror. In other words, you can have your computer regularly pull from GitHub and push to GitLab or [Gitolite][5] or Gitea (or whatever Git host you prefer). + +### Ansible modules + +There wouldn't be much to Ansible if it weren't for its excellent collection of modules. Like third-party libraries for Python or applications for Linux, the technical _driver_ of the useful and surprisingly easy tricks Ansible is famous for are the parts that other people have already figured out for you. Because this article is tackling how to effectively and reliably backup a Git repository, the modules used here are the [Git module][6] and the [ini_file][7] module. + +To begin, create a file called **mirror.yaml** to serve as the playbook. You can start mostly as you usually do with Ansible, with **name** and **task** entries. This example adds **localhost** to the **hosts** list so that the play runs on the controller machine (the computer you're sitting at right now), but in real life, you would probably run this on a specific host or group of hosts on your network. + + +``` +\--- +\- name: "Mirror a Git repo with Ansible" +  hosts: localhost +  tasks: +``` + +### Git pull and clone + +If you're going to make a backup, then you need a copy of the latest code. The obvious way to make that happen with a Git repository is to perform a **git pull**. However, **pull** assumes that a clone already exists, and a well-written Ansible _play_ (an Ansible script) assumes as little as possible. It's better to tell Ansible to **clone** a repository first. + +Add your first task to your playbook: + + +``` +\--- +\- name: "Mirror a Git repo with Ansible" +  hosts: localhost +  vars: +    git_dir: /tmp/soso.git +  tasks: + +  - name: "Clone the git repo" +    git: +       repo: '' +       dest: '{{ git_dir }}' +       clone: yes +       update: yes +``` + +This example uses the open source, Unix-like operating system **soso** as the repository I want to mirror. This is a completely arbitrary choice and in no way implies a lack of confidence in this repository's future. It also uses a variable to refer to the destination folder, **/tmp/soso.git**, which is convenient now and also beneficial later should you want to scale this out to be a generic mirroring script. In real life, you would probably have a more permanent location than **/tmp**, such as **/home/gitmirrors/soso.git** or **/opt/gitmirrors/soso.git**, on your worker machine. + +Run your playbook: + + +``` +`$ ansible-playbook mirror.yaml` +``` + +The first time you run the playbook, Ansible correctly detects that the Git repository does not yet exist locally, so it clones it. + + +``` +PLAY [Ansible Git mirror] ******** + +TASK [Gathering Facts] *********** +ok: [localhost] + +TASK [Clone git repo] ************ +changed: [localhost] + +PLAY RECAP *********************** +localhost: ok=2 changed=1 failed=0 [...] +``` + +Should you run the playbook again, Ansible correctly detects that there have been no changes since the last time it was run and it reports that no actions were performed: + + +``` +`localhost: ok=2 changed=0 failed=0 [...]` +``` + +Next, Ansible must be instructed to push the repository to another Git server. + +### Git push + +The Git module in Ansible doesn't provide a **push** function, so that part of the process is manual. However, before you can push the repo to an alternate mirror, you have to have a mirror, and you have to configure the mirror as an alternate remote. + +First, you must add an alternate remote to your Git configuration. Because the Git config file is an INI-style configuration, you can use the **ini_file** Ansible module to append the required information easily. Add this to your playbook: + + +``` + - name: "Add alternate remote" +    ini_file: dest={{ git_dir }}/.git/config section='remote \"mirrored\"' option=url value='[git@gitlab.com][8]:example/soso-mirror.git' +    tags: configuration +``` + +For this to work, you must have an empty repository on your destination server (in this case, [GitLab.com][9]). If you need to create destination repositories in your playbook, you can do that by following Steve Ovens' excellent article "[How to use Ansible to set up a Git server over SSH][10]." + +Finally, use Git directly to push HEAD to your alternate remote: + + +``` + - name: "Push the repo to alternate remote" +    shell: 'git --verbose --git-dir={{ git_dir }}/.git push mirrored HEAD' +``` + +Run the playbook as usual, and then automate the process so that you never have to run it directly again. You can adjust the script with variables and specific Git commands to suit your needs, but with regular pulls and pushes, you can be sure that an important project that lives on one server is safely mirrored on another. + +Here is the full playbook for reference: + + +``` +\--- +\- name: "Mirror a Git repository with Ansible" +  hosts: localhost +  vars: +    git_dir: /tmp/soso.git + +  tasks: + +  - name: "Clone the Git repo" +    git: +       repo: '' +       dest: '{{ git_dir }}' +       clone: yes +       update: yes + +  - name: "Add alternate remote" +    ini_file: dest={{ git_dir }}/.git/config section='remote \"mirrored\"' option=url value='[git@gitlab.com][8]:example/soso-mirror.git' +    tags: configuration +  +  - name: "Push the repo to alternate remote" +    shell: 'git --verbose --git-dir={{ git_dir }}/.git push mirrored HEAD' +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/how-host-github-gitlab-ansible + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop.png?itok=pGfEfu2S (Hands programming) +[2]: https://opensource.com/resources/what-is-git +[3]: https://github.com/AntiMicro/antimicro/issues/3 +[4]: https://opensource.com/article/19/10/how-community-saved-artwork-creative-commons +[5]: https://opensource.com/article/19/4/server-administration-git +[6]: https://docs.ansible.com/ansible/latest/modules/git_module.html +[7]: https://docs.ansible.com/ansible/latest/modules/ini_file_module.html +[8]: mailto:git@gitlab.com +[9]: http://GitLab.com +[10]: https://opensource.com/article/17/8/ansible-environment-management diff --git a/sources/tech/20191114 Creating Custom Themes in Drupal 8.md b/sources/tech/20191114 Creating Custom Themes in Drupal 8.md new file mode 100644 index 0000000000..f2ebf73568 --- /dev/null +++ b/sources/tech/20191114 Creating Custom Themes in Drupal 8.md @@ -0,0 +1,229 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Creating Custom Themes in Drupal 8) +[#]: via: (https://opensourceforu.com/2019/11/creating-custom-themes-in-drupal-8/) +[#]: author: (Bhanu Prakash Poluparthi https://opensourceforu.com/author/bhanu-poluparthi/) + +Creating Custom Themes in Drupal 8 +====== + +[![][1]][2] + +_A theme in a website is a set of files that defines the overall look and the user experience of a website. It usually comprises all the graphical elements such as colours and window decorations that help the user to customise the website. Drupal provides the user with a bunch of basic themes for a website that are very generic. However, these default themes do not suit all types of users. So there is a need to build themes that meet one’s requirements._ + +Creating and customising themes in Drupal 8 is easy because of a modern template engine for PHP named Twig, which is a part of the Symfony 2 framework. Moving from a PHP template to Twig, and from the INI format to YAML, are some of the main changes in Drupal 8 theming. These changes in Drupal 8 have improved the security and inheritance, making theming more distinguished. + +With reference to Figure 1, + + * _.info_ provides information about your theme. + * _html.tpl.php_ displays the basic HTML structure of a single Drupal page. + * _page.tpl.php_ is the main template that defines the contents on most of the pages. + * _style.css_ is the CSS file that sets the CSS rules for the template. + * _node.tpl.php_ defines the contents of the nodes. + * _block.tpl.php_ defines the contents in the blocks. + * _comment.tpl.php_ defines the contents in the comments. + * _Template.php_ is used to hold preprocessors for generating variables before they are merged with the markup inside .tpl.php files. + * _Theme-settings.php_ is used to modify the entire theme settings form. + * _.libraries.yml_ defines your libraries (mostly your JS, CSS files). + * _.breakpoints.yml_ defines the points to fit different screen devices. + * _.theme_ is the PHP file that stores conditional logic and data preprocessing of the variables before they are merged with markup inside the .html.twig file. + * _/includes_ is where third-party libraries (like Bootstrap, Foundation, Font Awesome, etc) are put. It is a standard convention to store them in this folder. + + + +The basic requirement to create a new Drupal theme is to have Drupal localhost installed on your system. + +![Figure 1: Drupal 7 theme structure \(https://www.drupal.org/docs/7/theming/ overview-of-theme-files\)][3] + +**Drupal 8 theme structure** +A custom theme can be made by following the steps mentioned below. + +_**Step 1: Creating the custom themes folder**_ +Go to the Drupal folder in which you can find a folder named Theme. + + * Enter the folder ‘theme’. + * Create a folder ‘custom’. + * Enter the folder ‘custom’. + * Create a folder ‘osfy’. + + + +Start creating your theme files over here. The theme name taken here is osfy. + +_**Step 2: Creating a YML file**_ +To inform the website about the existence of this theme, we use _.yml_ files. The basic details required in the YML are mentioned below: +1\. Name +2\. Description +3\. Type +4\. Core + +``` +name: osfy +description: My first responsive custom theme. +type: theme +package: custom +base theme: classy +core: 8.x + +regions: +head: head +header: header +content: content +sidebar: sidebar +footer: Footer + +Stylesheets-remove: +-”Remove Stylesheets” +``` + +We can proceed once the theme appears in the uninstalled section of your website’s _Appearance_ tab. +Open the Drupal website and check for the new theme in the _Appearance_ section. It will be under the uninstalled list of themes in the _Appearance_ tab. + +**Note:** 1\. Base theme indicates which base theme your custom theme is going to inherit. The default base theme provided by Drupal is ‘Stable’. + +2\. Regions defines the regions in which your blocks are to be placed in your theme. If not declared, Drupal uses default regions from the core. + +--- + +_**Step 3: Adding the .libraries.yml file:**_ +We have indicated all the libraries comprising JavaScript and CSS styling, and now we will define them in the _libraries.yml_ file. + +``` +global-components: +version: 1.x +css: +theme: +css/style.css: {} +includes/bootstrap/css/bootstrap.css: {} +``` + +We will use _style.css_ for the theme styling and bootstrap.css for responsive display using Bootstrap libraries. Style.css resides in the core/css folder, whereas bootstrap.css resides in the _includes/bootstrap/css_ folder. + +![Figure 2: Drupal 8 theme structure][4] + +_**Step 4: Creating theme regions**_ +To better understand how Twig has made things easier, use the following code: + +``` + + +

+ +

+ + +{{ title_prefix }} +{% if title %} +

+{{ title }} +

+{% endif %} +``` + +The template file functions are: + +_html.html.twig_ – Theme implementation for the basic structure of a single page +_page.html.twig_ – Theme implementation to display a single page +_node.html.twig_ – Default theme implementation to display a node +_region.html.twig_ – Default theme implementation to display a region +_block.html.twig_ – Default theme implementation to display a block +_field.html.twig_ – Theme implementation for a field + +To create the page.html.twig file, give the following commands: + +``` +/** +* @file +* Default theme implementation to display a single page. +* +* example code for basic header, footer and content page +**/ + +
+{% if page.head %} + +{% endif %} + +
+
+
+
+{{ page.content }} +
+{% if page.sidebar %} + +{% endif %} +
+
+
+{% if page.footer %} +
+
+{{ page.footer }} +
+
+{% endif %} +
+``` + +_**Step 5: Enabling the theme**_ +To place content in the respective regions, in the Manage administrative menu, navigate to _Structure > Block layout > Custom block library (admin/structure/block/block-content)_. Click Add custom block. The Add custom block page appears. Fill in the fields and click on _Save_. +The block design used here is as in Figure 2. + +**A few more things to do** + + * Place a _logo.svg_ file in the theme folder. Drupal will look for it by default and enable the logo for the theme. + * To show your theme picture in the admin interface next to your theme name, place an image screenshot.png in your theme directory itself. + * Use your creativity from here onwards to style and customise the appearance of your theme. + * While writing the code for Twig files, remember to comment all the important information for future reference. + + + +To make your theme work on your Drupal localhost, go to _/admin/appearance_ where you can find the theme ‘osfy’. Choose the option ‘Set as default’. + +You can start using your theme from now. + +![Avatar][5] + +[Bhanu Prakash Poluparthi][6] + +The author is an open source enthusiast and has been a part of +the Drupal organisation since 2017. He was an intern at Google +Summer of Code 2017 and a mentor at Google Code-In 2018. + +[![][7]][8] + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/creating-custom-themes-in-drupal-8/ + +作者:[Bhanu Prakash Poluparthi][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://opensourceforu.com/author/bhanu-poluparthi/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/d8-1.jpg?resize=696%2C397&ssl=1 (d8) +[2]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/d8-1.jpg?fit=788%2C449&ssl=1 +[3]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-1-Drupal-7-theme-structure.jpg?resize=350%2C308&ssl=1 +[4]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Screenshot-from-2019-11-14-16-13-53.png?resize=350%2C298&ssl=1 +[5]: https://secure.gravatar.com/avatar/a0a27865017dd4456f47f0a9e7d964a6?s=100&r=g +[6]: https://opensourceforu.com/author/bhanu-poluparthi/ +[7]: https://opensourceforu.com/wp-content/uploads/2019/11/assoc.png +[8]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/sources/tech/20191114 Debugging Software Deployments with strace.md b/sources/tech/20191114 Debugging Software Deployments with strace.md new file mode 100644 index 0000000000..1754792ab5 --- /dev/null +++ b/sources/tech/20191114 Debugging Software Deployments with strace.md @@ -0,0 +1,347 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Debugging Software Deployments with strace) +[#]: via: (https://theartofmachinery.com/2019/11/14/deployment_debugging_strace.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +Debugging Software Deployments with strace +====== + +Most of my paid work involves deploying software systems, which means I spend a lot of time trying to answer the following questions: + + * This software works on the original developer’s machine, so why doesn’t it work on mine? + * This software worked on my machine yesterday, so why doesn’t it work today? + + + +That’s a kind of debugging, but it’s a different kind of debugging from normal software debugging. Normal debugging is usually about the logic of the code, but deployment debugging is usually about the interaction between the code and its environment. Even when the root cause is a logic bug, the fact that the software apparently worked on another machine means that the environment is usually involved somehow. + +So, instead of using normal debugging tools like `gdb`, I have another toolset for debugging deployments. My favourite tool for “Why isn’t this software working on this machine?” is `strace`. + +### What is `strace`? + +[`strace`][1] is a tool for “system call tracing”. It’s primarily a Linux tool, but you can do the same kind of debugging tricks with tools for other systems (such as [DTrace][2] and [ktrace][3]). + +The basic usage is very simple. Just run it against a command and it dumps all the system calls (you’ll probably need to install `strace` first): + +``` +$ strace echo Hello +...Snip lots of stuff... +write(1, "Hello\n", 6) = 6 +close(1) = 0 +close(2) = 0 +exit_group(0) = ? ++++ exited with 0 +++ +``` + +What are these system calls? They’re like the API for the operating system kernel. Once upon a time, software used to have direct access to the hardware it ran on. If it needed to display something on the screen, for example, it could twiddle with ports and/or memory-mapped registers for the video hardware. That got chaotic when multitasking computer systems became popular because different applications would “fight” over hardware, and bugs in one application could crash other applications, or even bring down the whole system. So CPUs started supporting different privilege modes (or “protection rings”). They let an operating system kernel run in the most privileged mode with full hardware access, while spawning less-privileged software applications that must ask the kernel to interact with the hardware for them using system calls. + +At the binary level, making a system call is a bit different from making a simple function call, but most programs use wrappers in a standard library. E.g. the POSIX C standard library contains a `write()` function call that contains all the architecture-dependent code for making the `write` system call. + +![][4] + +In short, an application’s interaction with its environment (the computer system) is all done through system calls. So when software works on one machine but not another, looking at system call traces is a good way to find what’s wrong. More specifically, here are the typical things you can analyse using a system call trace: + + * Console input and output (IO) + * Network IO + * Filesystem access and file IO + * Process/thread lifetime management + * Raw memory management + * Access to special device drivers + + + +### When can `strace` be used? + +In theory, `strace` can be used with any userspace program because all userspace programs have to make system calls. It’s more effective with compiled, lower-level programs, but still works with high-level languages like Python if you can wade through the extra noise from the runtime environment and interpreter. + +`strace` shines with debugging software that works fine on one machine, but on another machine fails with a vague error message about files or permissions or failure to run some command or something. Unfortunately, it’s not so great with higher-level problems, like a certificate verification failure. They usually need a combination of `strace`, sometimes [`ltrace`][5], and higher-level tooling (like the `openssl` command line tool for certificate debugging). + +The examples in this post are based on a standalone server, but system call tracing can often be done on more complicated deployment platforms, too. Just search for appropriate tooling. + +### A simple debugging example + +Let’s say you’re trying to run an awesome server application called foo, but here’s what happens: + +``` +$ foo +Error opening configuration file: No such file or directory +``` + +Obviously it’s not finding the configuration file that you’ve written. This can happen because package managers sometimes customise the expected locations of files when compiling an application, so following an installation guide for one distro leads to files in the wrong place on another distro. You could fix the problem in a few seconds if only the error message told you where the configuration file is expected to be, but it doesn’t. How can you find out? + +If you have access to the source code, you could read it and work it out. That’s a good fallback plan, but not the fastest solution. You also could use a stepping debugger like `gdb` to see what the program does, but it’s more efficient to use a tool that’s specifically designed to show the interaction with the environment: `strace`. + +The output of `strace` can be a bit overwhelming at first, but the good news is that you can ignore most of it. It often helps to use the `-o` switch to save the trace to a separate file: + +``` +$ strace -o /tmp/trace foo +Error opening configuration file: No such file or directory +$ cat /tmp/trace +execve("foo", ["foo"], 0x7ffce98dc010 /* 16 vars */) = 0 +brk(NULL) = 0x56363b3fb000 +access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) +openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 +fstat(3, {st_mode=S_IFREG|0644, st_size=25186, ...}) = 0 +mmap(NULL, 25186, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2f12cf1000 +close(3) = 0 +openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 +read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260A\2\0\0\0\0\0"..., 832) = 832 +fstat(3, {st_mode=S_IFREG|0755, st_size=1824496, ...}) = 0 +mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2f12cef000 +mmap(NULL, 1837056, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2f12b2e000 +mprotect(0x7f2f12b50000, 1658880, PROT_NONE) = 0 +mmap(0x7f2f12b50000, 1343488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f2f12b50000 +mmap(0x7f2f12c98000, 311296, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16a000) = 0x7f2f12c98000 +mmap(0x7f2f12ce5000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b6000) = 0x7f2f12ce5000 +mmap(0x7f2f12ceb000, 14336, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2f12ceb000 +close(3) = 0 +arch_prctl(ARCH_SET_FS, 0x7f2f12cf0500) = 0 +mprotect(0x7f2f12ce5000, 16384, PROT_READ) = 0 +mprotect(0x56363b08b000, 4096, PROT_READ) = 0 +mprotect(0x7f2f12d1f000, 4096, PROT_READ) = 0 +munmap(0x7f2f12cf1000, 25186) = 0 +openat(AT_FDCWD, "/etc/foo/config.json", O_RDONLY) = -1 ENOENT (No such file or directory) +dup(2) = 3 +fcntl(3, F_GETFL) = 0x2 (flags O_RDWR) +brk(NULL) = 0x56363b3fb000 +brk(0x56363b41c000) = 0x56363b41c000 +fstat(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x8), ...}) = 0 +write(3, "Error opening configuration file"..., 60) = 60 +close(3) = 0 +exit_group(1) = ? ++++ exited with 1 +++ +``` + +The first page or so of `strace` output is typically low-level process startup. (You can see a lot of `mmap`, `mprotect`, `brk` calls for things like allocating raw memory and mapping dynamic libraries.) Actually, when debugging an error, `strace` output is best read from the bottom up. You can see the `write` call that outputs the error message at the end. If you work up, the first failing system call is the `openat` call that fails with `ENOENT` (“No such file or directory”) trying to open `/etc/foo/config.json`. And now we know where the configuration file is supposed to be. + +That’s a simple example, but I’d say at least 90% of the time I use `strace`, I’m not doing anything more complicated. Here’s the complete debugging formula step-by-step: + + 1. Get frustrated by a vague system-y error message from a program + 2. Run the program again with `strace` + 3. Find the error message in the trace + 4. Work upwards to find the first failing system call + + + +There’s a very good chance the system call in step 4 shows you what went wrong. + +### Some tips + +Before walking through a more complicated example, here are some useful tips for using `strace` effectively: + +#### `man` is your friend + +On many *nix systems, you can get a list of all kernel system calls by running `man syscalls`. You’ll see things like `brk(2)`, which means you can get more information by running `man 2 brk`. + +One little gotcha: `man 2 fork` shows me the man page for the `fork()` wrapper in GNU `libc`, which is actually now implemented using the `clone` system call instead. The semantics of `fork` are the same, but if I write a program using `fork()` and `strace` it, I won’t find any `fork` calls in the trace, just `clone` calls. Gotchas like that are only confusing if you’re comparing source code to `strace` output. + +#### Use `-o` to save output to a file + +`strace` can generate a lot of output so it’s often helpful to store the trace in a separate file (as in the example above). It also avoids mixing up program output with `strace` output in the console. + +#### Use `-s` to see more argument data + +You might have noticed that the second part of the error message doesn’t appear in the example trace above. That’s because `strace` only shows the first 32 bytes of string arguments by default. If you need to capture more, add something like `-s 128` to the `strace` invocation. + +#### `-y` makes it easier to track files/sockets/etc + +“Everything is a file” means *nix systems do all IO using file descriptors, whether it’s to an actual file or over networks or through interprocess pipes. That’s convenient for programming, but makes it harder to follow what’s really going on when you see generic `read` and `write` in the system call trace. + +Adding the `-y` switch makes `strace` annotate every file descriptor in the output with a note about what it points to. + +#### Attach to an already-running process with `-p` + +As we’ll see in the example later, sometimes you want to trace a program that’s already running. If you know it’s running as process 1337 (say, by looking at the output of `ps`), you can trace it like this: + +``` +$ strace -p 1337 +...system call trace output... +``` + +You probably need root. + +#### Use `-f` to follow child processes + +By default, `strace` only traces the one process. If that process spawns a child process, you’ll see the system call for spawning the process (normally `clone` nowadays), but not any of the calls made by the child process. + +If you think the bug is in a child process, you’ll need to use the `-f` switch to enable tracing it. A downside is that the output can be more confusing. When tracing one process and one thread, `strace` can show you a single stream of call events. When tracing multiple processes, you might see the start of a call cut off with ``, then a bunch of calls for other threads of execution, before seeing the end of the original call with `<... foocall resumed>`. Alternatively, you can separate all the traces into different files by using the `-ff` switch as well (see [the `strace` manual][6] for details). + +#### You can filter the trace with `-e` + +As you’ve seen, the default trace output is a firehose of all system calls. You can filter which calls get traced using the `-e` flag (see [the `strace` manual][6]). The main advantage is that it’s faster to run the program under a filtered `strace` than to trace everything and `grep` the results later. Honestly, I don’t bother most of the time. + +#### Not all errors are bad + +A simple and common example is a program searching for a file in multiple places, like a shell searching for which `bin/` directory has an executable: + +``` +$ strace sh -c uname +... +stat("/home/user/bin/uname", 0x7ffceb817820) = -1 ENOENT (No such file or directory) +stat("/usr/local/bin/uname", 0x7ffceb817820) = -1 ENOENT (No such file or directory) +stat("/usr/bin/uname", {st_mode=S_IFREG|0755, st_size=39584, ...}) = 0 +... +``` + +The “last failed call before the error message” heuristic is pretty good at finding relevent errors. In any case, working from the bottom up makes sense. + +#### C programming guides are good for understanding system calls + +Standard C library calls aren’t system calls, but they’re only thin layers on top. So if you understand (even just roughly) how to do something in C, it’s easier to read a system call trace. For example, if you’re having trouble debugging networking system calls, you could try skimming through [Beej’s classic Guide to Network Programming][7]. + +### A more complicated debugging example + +As I said, that simple debugging example is representative of most of my `strace` usage. However, sometimes a little more detective work is required, so here’s a slightly more complicated (and real) example. + +[`bcron`][8] is a job scheduler that’s yet another implementation of the classic *nix `cron` daemon. It’s been installed on a server, but here’s what happens when someone tries to edit a job schedule: + +``` +# crontab -e -u logs +bcrontab: Fatal: Could not create temporary file +``` + +Okay, so bcron tried to write some file, but it couldn’t, and isn’t telling us why. This is a debugging job for `strace`: + +``` +# strace -o /tmp/trace crontab -e -u logs +bcrontab: Fatal: Could not create temporary file +# cat /tmp/trace +... +openat(AT_FDCWD, "bcrontab.14779.1573691864.847933", O_RDONLY) = 3 +mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f82049b4000 +read(3, "#Ansible: logsagg\n20 14 * * * lo"..., 8192) = 150 +read(3, "", 8192) = 0 +munmap(0x7f82049b4000, 8192) = 0 +close(3) = 0 +socket(AF_UNIX, SOCK_STREAM, 0) = 3 +connect(3, {sa_family=AF_UNIX, sun_path="/var/run/bcron-spool"}, 110) = 0 +mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f82049b4000 +write(3, "156:Slogs\0#Ansible: logsagg\n20 1"..., 161) = 161 +read(3, "32:ZCould not create temporary f"..., 8192) = 36 +munmap(0x7f82049b4000, 8192) = 0 +close(3) = 0 +write(2, "bcrontab: Fatal: Could not creat"..., 49) = 49 +unlink("bcrontab.14779.1573691864.847933") = 0 +exit_group(111) = ? ++++ exited with 111 +++ +``` + +There’s the error message `write` near the end, but a couple of things are different this time. First, there’s no relevant system call error that happens before it. Second, we see that the error message has just been `read` from somewhere else. It looks like the real problem is happening somewhere else, and `bcrontab` is just replaying the message. + +If you look at `man 2 read`, you’ll see that the first argument (the 3) is a file descriptor, which is what *nix uses for all IO handles. How do you know what file descriptor 3 represents? In this specific case, you could run `strace` with the `-y` switch (as explained above) and it would tell you automatically, but it’s useful to know how to read and analyse traces to figure things like this out. + +A file descriptor can come from one of many system calls (depending on whether it’s a descriptor for the console, a network socket, an actual file, or something else), but in any case we can search for calls returning 3 (i.e., search for “= 3” in the trace). There are two in this trace: the `openat` at the top, and the `socket` in the middle. `openat` opens a file, but the `close(3)` afterwards shows that it gets closed again. (Gotcha: file descriptors can be reused as they’re opened and closed.) The `socket` call is the relevant one (it’s the last one before the `read`), which tells us `bcrontab` is talking to something over a network socket. The next line, `connect` shows file descriptor 3 being configured as a Unix domain socket connection to `/var/run/bcron-spool`. + +So now we need to figure out what’s listening on the other side of the Unix socket. There are a couple of neat tricks for that, both useful for debugging server deployments. One is to use `netstat` or the newer `ss` (“socket status”). Both commands describe active network sockets on the system, and take the `-l` switch for describing listening (server) sockets, and the `-p` switch to get information about what program is using the socket. (There are many more useful options, but those two are enough to get this job done.) + +``` +# ss -pl | grep /var/run/bcron-spool +u_str LISTEN 0 128 /var/run/bcron-spool 1466637 * 0 users:(("unixserver",pid=20629,fd=3)) +``` + +That tells us that the listener is a command `unixserver` running as process ID 20629. (It’s a coincidence that it’s also using file descriptor 3 for the socket.) + +The second really useful tool for finding the same information is `lsof`. It can list all open files (or file descriptors) on the system. Alternatively, we can get information about a specific file: + +``` +# lsof /var/run/bcron-spool +COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME +unixserve 20629 cron 3u unix 0x000000005ac4bd83 0t0 1466637 /var/run/bcron-spool type=STREAM +``` + +Process 20629 is a long-running server, so we can attach `strace` to it using something like `strace -o /tmp/trace -p 20629`. If we then try to edit the cron schedule in another terminal, we can capture a trace while the error is happening. Here’s the result: + +``` +accept(3, NULL, NULL) = 4 +clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7faa47c44810) = 21181 +close(4) = 0 +accept(3, NULL, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set) +--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=21181, si_uid=998, si_status=0, si_utime=0, si_stime=0} --- +wait4(0, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG|WSTOPPED, NULL) = 21181 +wait4(0, 0x7ffe6bc36764, WNOHANG|WSTOPPED, NULL) = -1 ECHILD (No child processes) +rt_sigaction(SIGCHLD, {sa_handler=0x55d244bdb690, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7faa47ab9840}, {sa_handler=0x55d244bdb690, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7faa47ab9840}, 8) = 0 +rt_sigreturn({mask=[]}) = 43 +accept(3, NULL, NULL) = 4 +clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7faa47c44810) = 21200 +close(4) = 0 +accept(3, NULL, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set) +--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=21200, si_uid=998, si_status=111, si_utime=0, si_stime=0} --- +wait4(0, [{WIFEXITED(s) && WEXITSTATUS(s) == 111}], WNOHANG|WSTOPPED, NULL) = 21200 +wait4(0, 0x7ffe6bc36764, WNOHANG|WSTOPPED, NULL) = -1 ECHILD (No child processes) +rt_sigaction(SIGCHLD, {sa_handler=0x55d244bdb690, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7faa47ab9840}, {sa_handler=0x55d244bdb690, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7faa47ab9840}, 8) = 0 +rt_sigreturn({mask=[]}) = 43 +accept(3, NULL, NULL +``` + +(The last `accept` doesn’t complete during the trace period.) Unfortunately, once again, this trace doesn’t contain the error we’re after. We don’t see any of the messages that we saw `bcrontab` sending to and receiving from the socket. Instead, we see a lot of process management (`clone`, `wait4`, `SIGCHLD`, etc.). This process is spawning a child process, which we can guess is doing the real work. If we want to catch a trace of that, we have to add `-f` to the `strace` invocation. Here’s what we find if we search for the error message after getting a new trace with `strace -f -o /tmp/trace -p 20629`: + +``` +21470 openat(AT_FDCWD, "tmp/spool.21470.1573692319.854640", O_RDWR|O_CREAT|O_EXCL, 0600) = -1 EACCES (Permission denied) +21470 write(1, "32:ZCould not create temporary f"..., 36) = 36 +21470 write(2, "bcron-spool[21470]: Fatal: logs:"..., 84) = 84 +21470 unlink("tmp/spool.21470.1573692319.854640") = -1 ENOENT (No such file or directory) +21470 exit_group(111) = ? +21470 +++ exited with 111 +++ +``` + +Now we’re getting somewhere. Process ID 21470 is getting a permission denied error trying to create a file at the path `tmp/spool.21470.1573692319.854640` (relative to the current working directory). If we just knew the current working directory, we would know the full path and could figure out why the process can’t create create its temporary file there. Unfortunately, the process has already exited, so we can’t just use `lsof -p 21470` to find out the current directory, but we can work backwards looking for PID 21470 system calls that change directory. (If there aren’t any, PID 21470 must have inherited it from its parent, and we can `lsof -p` that.) That system call is `chdir` (which is easy to find out using today’s web search engines). Here’s the result of working backwards through the trace, all the way to the server PID 20629: + +``` +20629 clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7faa47c44810) = 21470 +... +21470 execve("/usr/sbin/bcron-spool", ["bcron-spool"], 0x55d2460807e0 /* 27 vars */) = 0 +... +21470 chdir("/var/spool/cron") = 0 +... +21470 openat(AT_FDCWD, "tmp/spool.21470.1573692319.854640", O_RDWR|O_CREAT|O_EXCL, 0600) = -1 EACCES (Permission denied) +21470 write(1, "32:ZCould not create temporary f"..., 36) = 36 +21470 write(2, "bcron-spool[21470]: Fatal: logs:"..., 84) = 84 +21470 unlink("tmp/spool.21470.1573692319.854640") = -1 ENOENT (No such file or directory) +21470 exit_group(111) = ? +21470 +++ exited with 111 +++ +``` + +(If you’re getting lost here, you might want to read [my previous post about *nix process management and shells][9].) Okay, so the server PID 20629 doesn’t have permission to create a file at `/var/spool/cron/tmp/spool.21470.1573692319.854640`. The most likely reason would be classic *nix filesystem permission settings. Let’s check: + +``` +# ls -ld /var/spool/cron/tmp/ +drwxr-xr-x 2 root root 4096 Nov 6 05:33 /var/spool/cron/tmp/ +# ps u -p 20629 +USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND +cron 20629 0.0 0.0 2276 752 ? Ss Nov14 0:00 unixserver -U /var/run/bcron-spool -- bcron-spool +``` + +There’s the problem! The server is running as user `cron`, but only `root` has permissions to write to that `/var/spool/cron/tmp/` directory. A simple `chown cron /var/spool/cron/tmp/` makes `bcron` work properly. (If that weren’t the problem, the next most likely suspect would be a kernel security module like SELinux or AppArmor, so I’d check the kernel logs with `dmesg`.) + +### Summary + +System call traces can be overwhelming at first, but I hope I’ve shown that they’re a fast way to debug a whole class of common deployment problems. Imagine trying to debug that multi-process `bcron` problem using a stepping debugger. + +Working back through a chain of system calls takes practice, but as I said, most of the time I use `strace` I just get a trace and look for errors, working from the bottom up. In any case, `strace` has saved me hours and hours of debugging time. I hope it’s useful for you, too. + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2019/11/14/deployment_debugging_strace.html + +作者:[Simon Arneaud][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://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: https://strace.io/ +[2]: http://dtrace.org/blogs/about/ +[3]: https://man.openbsd.org/ktrace +[4]: https://theartofmachinery.com/images/strace/system_calls.svg +[5]: https://linux.die.net/man/1/ltrace +[6]: https://linux.die.net/man/1/strace +[7]: https://beej.us/guide/bgnet/html/index.html +[8]: https://untroubled.org/bcron/ +[9]: https://theartofmachinery.com/2018/11/07/writing_a_nix_shell.html diff --git a/sources/tech/20191115 How to port an awk script to Python.md b/sources/tech/20191115 How to port an awk script to Python.md new file mode 100644 index 0000000000..2476fb079d --- /dev/null +++ b/sources/tech/20191115 How to port an awk script to Python.md @@ -0,0 +1,212 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to port an awk script to Python) +[#]: via: (https://opensource.com/article/19/11/awk-to-python) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +How to port an awk script to Python +====== +Porting an awk script to Python is more about code style than +transliteration. +![Woman sitting in front of her laptop][1] + +Scripts are potent ways to solve a problem repeatedly, and awk is an excellent language for writing them. It excels at easy text processing in particular, and it can bring you through some complicated rewriting of config files or reformatting file names in a directory.  + +### When to move from awk to Python + +At some point, however, awk's limitations start to show. It has no real concept of breaking files into modules, it lacks quality error reporting, and it's missing other things that are now considered fundamentals of how a language works. When these rich features of a programming language are helpful to maintain a critical script, porting becomes a good option. + +My favorite modern programming language that is perfect for porting awk is Python. + +Before porting an awk script to Python, it is often worthwhile to consider its original context. For example, because of awk's limitations, the awk code is commonly called from a Bash script and includes some calls to other command-line favorites like sed, sort, and the gang. It's best to convert all of it into one coherent Python program. Other times, the script makes overly broad assumptions; for example, the code might allow for any number of files, even though it's run with only one in practice. + +After carefully considering the context and determining the thing to substitute with Python, it is time to write code. + +### Standard awk to Python functionality + +The following Python functionality is useful to remember: + + +``` +with open(some_file_name) as fpin: +    for line in fpin: +        pass # do something with line +``` + +This code will loop through a file line-by-line and process the lines. + +If you want to access a line number (equivalent to awk's **NR**), you can use the following code: + + +``` +with open(some_file_name) as fpin: +    for nr, line in enumerate(fpin): +        pass # do something with line +``` + +### awk-like behavior over multiple files in Python + +If you need to be able to iterate through any number of files while keeping a persistent count of the number of lines (like awk's **FNR**), this loop can do it: + + +``` +def awk_like_lines(list_of_file_names): +    def _all_lines(): +        for filename in list_of_file_names: +            with open(filename) as fpin: +                yield from fpin +    yield from enumerate(_all_lines()) +``` + +This syntax uses Python's _generators_ and **yield from** to build an _iterator_ that loops through all lines and keeps a persistent count. + +If you need the equivalent of both **FNR** and **NR**, here is a more sophisticated loop: + + +``` +def awk_like_lines(list_of_file_names): +    def _all_lines(): +        for filename in list_of_file_names: +            with open(filename) as fpin: +                yield from enumerate(fpin) +    for nr, (fnr, line) in _all_lines: +        yield nr, fnr, line +``` + +### More complex awk functionality with FNR, NR, and line + +The question remains if you need all three: **FNR**, **NR**, and **line**. If you really do, using a three-tuple where two of the items are numbers can lead to confusion. Named parameters can make this code easier to read, so it's better to use a **dataclass**: + + +``` +import dataclass + +@dataclass.dataclass(frozen=True) +class AwkLikeLine: +    content: str +    fnr: int +    nr: int + +def awk_like_lines(list_of_file_names): +    def _all_lines(): +        for filename in list_of_file_names: +            with open(filename) as fpin: +                yield from enumerate(fpin) +    for nr, (fnr, line) in _all_lines: +        yield AwkLikeLine(nr=nr, fnr=fnr, line=line) +``` + +You might wonder, why not start with this approach? The reason to start elsewhere is that this is almost always too complicated. If your goal is to make a generic library that makes porting awk to Python easier, then consider doing so. But writing a loop that gets you exactly what you need for a specific case is usually easier to do and easier to understand (and thus maintain). + +### Understanding awk fields + +Once you have a string that corresponds to a line, if you are converting an awk program, you often want to break it up into _fields_. Python has several ways of doing that. This will return a list of strings, splitting the line on any number of consecutive whitespaces: + + +``` +`line.split()` +``` + +If another field separator is needed, something like this will split the line by **:**; the **rstrip** method is needed to remove the last newline: + + +``` +`line.rstrip("\n").split(":")` +``` + +After doing the following, the list **parts** will have the broken-up string: + + +``` +`parts = line.rstrip("\n").split(":")` +``` + +This split is good for choosing what to do with the parameters, but we are in an [off-by-one error][2] scenario. Now **parts[0]** will correspond to awk's **$1**, **parts[1]** will correspond to awk's **$2**, etc. This off-by-one is because awk starts counting the "fields" from 1, while Python counts from 0. In awk's **$0** is the whole line -- equivalent to **line.rstrip("\n") **and awk's **NF** (number of fields) is more easily retrieved as **len(parts)**. + +### Porting awk fields in Python + +As an example, let's convert the one-liner from "[How to remove duplicate lines from files with awk][3]" to Python. + +The original in awk is: + + +``` +`awk '!visited[$0]++' your_file > deduplicated_file` +``` + +An "authentic" Python conversion would be: + + +``` +import collections +import sys + +visited = collections.defaultdict(int) +for line in open("your_file"): +    did_visit = visited[line] +    visited[line] += 1 +    if not did_visit: +        sys.stdout.write(line) +``` + +However, Python has more data structures than awk. Instead of _counting_ visits (which we do not use, except to know whether we saw a line), why not record the visited lines? + + +``` +import sys + +visited = set() +for line in open("your_file"): +    if line in visited: +        continue +    visited.add(line) +    sys.stdout.write(line) +``` + +### Making Pythonic awk code + +The Python community advocates for writing Pythonic code, which means it follows a commonly agreed-upon code style. An even more Pythonic approach will separate the concerns of _uniqueness_ and _input/output_. This change would make it easier to unit test your code: + + +``` +def unique_generator(things): +    visited = set() +    for thing in things: +        if thing in visited: +            continue +        visited.add(things) +        yield thing + +import sys +    +for line in unique_generator(open("your_file")): +    sys.stdout.write(line) +``` + +Putting all logic away from the input/output code leads to better separation of concerns and more usability and testability of code. + +### Conclusion: Python can be a good choice  + +Porting an awk script to Python is often more a matter of reimplementing the core requirements while thinking about proper Pythonic code style than a slavish transliteration of condition/action by condition/action. Take the original context into account and produce a quality Python solution. While there are times when a Bash one-liner with awk can get the job done, Python coding is a path toward more easily maintainable code. + +Also, if you're writing awk scripts, I am confident you can learn Python as well! Let me know if you have any questions in the comments. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/awk-to-python + +作者:[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://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_4.png?itok=VGZO8CxT (Woman sitting in front of her laptop) +[2]: https://en.wikipedia.org/wiki/Off-by-one_error +[3]: https://opensource.com/article/19/10/remove-duplicate-lines-files-awk diff --git a/sources/tech/20191115 PyRadio- An open source alternative for internet radio.md b/sources/tech/20191115 PyRadio- An open source alternative for internet radio.md new file mode 100644 index 0000000000..85dd5f2296 --- /dev/null +++ b/sources/tech/20191115 PyRadio- An open source alternative for internet radio.md @@ -0,0 +1,106 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (PyRadio: An open source alternative for internet radio) +[#]: via: (https://opensource.com/article/19/11/pyradio) +[#]: author: (Lee Tusman https://opensource.com/users/leeto) + +PyRadio: An open source alternative for internet radio +====== +Play your favorite internet radio stations—while keeping your personal +data private—with PyRadio. +![Stereo radio with dials][1] + +[PyRadio][2] is a convenient, open source, command-line application for playing any radio station that has a streaming link. And in 2019, almost every radio station (certainly, every one that has a web presence) has a way to listen online. Using the free PyRadio program, you can add, edit, play and switch between your own selected list of streaming radio stations. It is a command-line tool for Linux that can run on many computers, including Macintosh and tiny computers like Raspberry Pi. To some, a command-line client for playing music might sound needlessly complicated, but it's actually a simple alternative and one that serves as an instant text-based dashboard to easily select music to listen to. + +A little background about myself: I spend a lot of time browsing for and listening to new music on [Bandcamp][3], on various blogs, and even Spotify. I don't spend time casually listening to app *radio* stations, which are really algorithmically-generated continuous streams of similarly tagged music. Rather, I prefer listening to non-profit, college and locally-produced independent radio stations that are run by a community and don't rely on advertisements to sustain themselves. + +I have always been a huge fan of community radio, from Drexel University's great reggae weekends on WKDU; the uncanny experimental WFMU from Orange, N.J.; and WNYC's eclectic schedule, including New Sounds. In my college days, I was a DJ on Brandeis' WBRS 100.1FM, playing experimental electronic music on the show Frequency. And as recently as 2018, I helped manage the station managers and schedule for [KCHUNG Radio][4], an artist-run internet and low-power AM station run out of Chinatown, Los Angeles. + +![The PyRadio interface][5] + +Just as a car radio (in days of yore) had buttons with presets for the owner's favorite radio stations, PyRadio lets me create a very simple list of radio stations that I can easily turn on and switch between. Since I spend most days working, researching, or writing to music, it's become my go-to software for listening. In an era where many people are used to commercial streaming services like curated Spotify mood playlists or Pandora "stations," it's nice to be able to set my own radio stations from a variety of sources outside of a commercial app and sans additional advertising. + +Importantly, by not using commercial clients in the cloud, nothing is sending my user data or preferences to a company for whatever purposes they see fit. Nothing is collecting my preferences to build a profile to sell me more things. + +PyRadio just works, and it's easy to use. Like some other Linux software, the hardest part of using PyRadio is installing it. This tutorial will help you install and run PyRadio for the first time. It assumes some basic knowledge of the command line. If you have no experience working in the terminal, I recommend reading a beginner-friendly [introduction to the command line][6] first. + +### Installing PyRadio + +In the past, I've used the Python package installer [pip][7] to install PyRadio, but the latest version is not yet installable from pip, and I couldn't find a package on Homebrew for my Mac. On my laptop running Ubuntu, I really wanted the latest version of PyRadio for its excellent new features, but I couldn't find an installation on Apt. + +**[[Download our pip cheat sheet][8]]** + +To get the current version on these computers, I built it from source. You can download the latest release from [github.com/coderholic/pyradio/releases][9], and then unzip or [untar][10] it. Change directory into the PyRadio source folder, and you're ready to begin. + +Install the dependencies using your distribution's package manager (such as **dnf** on Fedora or **apt** on Ubuntu): + + * python3-setuptools + * git + * MPV, MPlayer, or VLC + + + +On a Mac, install [Git][11], [sed][12], and [MPlayer][13] dependencies using Homebrew: + + +``` +brew install git +brew install gnu-sed --default-names +brew install mplayer +``` + +Once all dependencies are resolved, run the installer script, using the argument **3** to indicate that you want PyRadio to build for Python3: + + +``` +`$ sh devel/build_install_pyradio 3` +``` + +The installation process takes about a minute. + +### Using and tweaking the station list + +To launch the application, just run **pyradio**. You can navigate up and down the default station list with the arrow or [Vim][14] keys and select a station with Enter. The artist name and track title currently streaming from the station should be displayed, if they are available. Typing **?** brings up a help text box that lists available commands. You can change the interface color themes with **t** or modify your configuration with **c**. + +Out of the box, PyRadio comes with an extensive list of internet streaming stations. But I wanted to add my favorite public radio and college radio stations to the list, as well as some online music playlists. You can find streaming URLs on your favorite radio stations' websites or by browsing online station directories such as [Shoutcast][15]. In particular, I recommend the variety of excellent stations from [Soma FM][16]. You'll need to input the station's streaming playlist file, a URL that ends in **.pls**. You can also enter direct links to streaming audio files, such as MP3s. + +The easiest way to add a station is to type **a**. PyRadio will ask you for the name of the station and its streaming URL, and you can press Enter to add it to your **stations** file. To delete any station, navigate to it and press **x**. You'll be prompted to confirm. The default station list is stored in **~/.config/pyradio/stations.csv**. The station list is a two-column CSV file with the station names and the stream URLs. + +![Adding a station to PyRadio][17] + +Those are the basics of PyRadio. You can find additional information in its [GitHub repo][18]. I hope you have many hours of audio enjoyment ahead of you. If you have any other PyRadio tips or suggestions for stations, please leave a comment below. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/pyradio + +作者:[Lee Tusman][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/leeto +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-lead-stereo-radio-music.png?itok=st66SdwS (Stereo radio with dials) +[2]: http://www.coderholic.com/pyradio/ +[3]: http://bandcamp.com +[4]: https://kchungradio.org/ +[5]: https://opensource.com/sites/default/files/interface_0.png (The PyRadio interface) +[6]: https://www.redhat.com/sysadmin/navigating-filesystem-linux-terminal +[7]: https://pypi.org/project/pip/ +[8]: https://opensource.com/article/19/11/introducing-our-python-pip-cheat-sheet +[9]: https://github.com/coderholic/pyradio/releases +[10]: https://opensource.com/article/17/7/how-unzip-targz-file +[11]: https://git-scm.com/ +[12]: https://www.gnu.org/software/sed/manual/sed.html +[13]: http://www.mplayerhq.hu/design7/news.html +[14]: https://www.vim.org/ +[15]: https://directory.shoutcast.com/ +[16]: https://somafm.com/ +[17]: https://opensource.com/sites/default/files/pyradio-add.png (Adding a station to PyRadio) +[18]: https://github.com/coderholic/pyradio diff --git a/sources/tech/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md b/sources/tech/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md new file mode 100644 index 0000000000..85e70ba6a8 --- /dev/null +++ b/sources/tech/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md @@ -0,0 +1,457 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (6 Methods to Quickly Check if a Website is up or down from the Linux Terminal) +[#]: via: (https://www.2daygeek.com/linux-command-check-website-is-up-down-alive/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +6 Methods to Quickly Check if a Website is up or down from the Linux Terminal +====== + +This tutorial shows you how to quickly check whether a given website is up (alive) or down from a Linux terminal. + +You may already know some of these commands to verify about this, namely ping, curl, and wget. + +But we have added some other commands as well in this tutorial. + +Also, we have added various options to check this information for single host and multiple hosts. + +This article will help you to check whether the website is up or down. + +But if you maintain some websites and want to get real-time alerts when the website is down. + +I recommend you to use real-time website monitoring tools. There are many tools for this, and some are free and most of them are paid. + +So choose the preferred one based on your needs. We will cover this topic in our upcoming article. + +### Method-1: How to Check if a Website is up or down Using the fping Command + +**[fping command][1]** is a program such as ping, which uses the Internet Control Message Protocol (ICMP) echo request to determine whether a target host is responding. + +fping differs from ping because it allows users to ping any number of host in parallel. Also, hosts can be entered from a text file. + +fping sends an ICMP echo request, moves the next target in a round-robin fashion, and does not wait until the target host responds. + +If a target host replies, it is noted as active and removed from the list of targets to check; if a target does not respond within a certain time limit and/or retry limit it is designated as unreachable. + +``` +# fping 2daygeek.com linuxtechnews.com magesh.co.in + +2daygeek.com is alive +linuxtechnews.com is alive +magesh.co.in is alive +``` + +### Method-2: How to Quickly Check Whether a Website is up or down Using the http Command + +HTTPie (pronounced aitch-tee-tee-pie) is a command line HTTP client. + +The **[httpie tool][2]** is a modern command line http client which makes CLI interaction with web services. + +It provides a simple http command that allows for sending arbitrary HTTP requests using a simple and natural syntax, and displays colorized output. + +HTTPie can be used for testing, debugging, and generally interacting with HTTP servers. + +``` +# http 2daygeek.com + +HTTP/1.1 301 Moved Permanently +CF-RAY: 535b66722ab6e5fc-LHR +Cache-Control: max-age=3600 +Connection: keep-alive +Date: Thu, 14 Nov 2019 19:30:28 GMT +Expires: Thu, 14 Nov 2019 20:30:28 GMT +Location: https://2daygeek.com/ +Server: cloudflare +Transfer-Encoding: chunked +Vary: Accept-Encoding +``` + +### Method-3: How to Check if a Website is up or down Using the curl Command + +**[curl command][3]** is a tool to transfer data from a server or to server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP). + +The command is designed to work without user interaction. + +Also curl support proxy support, user authentication, FTP upload, HTTP post, SSL connections, cookies, file transfer resume, Metalink, and more. + +curl is powered by libcurl for all transfer-related features. + +``` +# curl -I https://www.magesh.co.in + +HTTP/2 200 +date: Thu, 14 Nov 2019 19:39:47 GMT +content-type: text/html +set-cookie: __cfduid=db16c3aee6a75c46a504c15131ead3e7f1573760386; expires=Fri, 13-Nov-20 19:39:46 GMT; path=/; domain=.magesh.co.in; HttpOnly +vary: Accept-Encoding +last-modified: Sun, 14 Jun 2015 11:52:38 GMT +x-cache: HIT from Backend +cf-cache-status: DYNAMIC +expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" +server: cloudflare +cf-ray: 535b74123ca4dbf3-LHR +``` + +Use the following curl command if you want to see only the HTTP status code instead of entire output. + +``` +# curl -I "www.magesh.co.in" 2>&1 | awk '/HTTP\// {print $2}' + 200 +``` + +If you want to see if a given website is up or down, use the following Bash script. + +``` +# vi curl-url-check.sh + +#!/bin/bash +if curl -I "https://www.magesh.co.in" 2>&1 | grep -w "200\|301" ; then + echo "magesh.co.in is up" +else + echo "magesh.co.in is down" +fi +``` + +Once you have added the above script to a file, run the file to see the output. + +``` +# sh curl-url-check.sh + +HTTP/2 200 +magesh.co.in is up +``` + +Use the following shell script if you want to see the status of multiple websites. + +``` +# vi curl-url-check-1.sh + +#!/bin/bash +for site in www.google.com google.co.in www.xyzzz.com +do +if curl -I "$site" 2>&1 | grep -w "200\|301" ; then + echo "$site is up" +else + echo "$site is down" +fi +echo "----------------------------------" +done +``` + +Once you have added the above script to a file, run the file to see the output. + +``` +# sh curl-url-check-1.sh + +HTTP/1.1 200 OK +www.google.com is up +---------------------------------- +HTTP/1.1 301 Moved Permanently +google.co.in is up +---------------------------------- +www.xyzzz.com is down +---------------------------------- +``` + +### Method-4: How to Quickly Check Whether a Website is up or down Using the wget Command + +**[wget command][4]** (formerly known as Geturl) is a Free, open source, command line download tool which is retrieving files using HTTP, HTTPS and FTP, the most widely-used Internet protocols. + +It is a non-interactive command line tool and Its name is derived from World Wide Web and get. + +wget handle download pretty much good compared with other tools, futures included working in background, recursive download, multiple file downloads, resume downloads, non-interactive downloads & large file downloads. + +``` +# wget -S --spider https://www.magesh.co.in + +Spider mode enabled. Check if remote file exists. +--2019-11-15 01:22:00-- https://www.magesh.co.in/ +Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt' +Resolving www.magesh.co.in (www.magesh.co.in)… 104.18.35.52, 104.18.34.52, 2606:4700:30::6812:2334, … +Connecting to www.magesh.co.in (www.magesh.co.in)|104.18.35.52|:443… connected. +HTTP request sent, awaiting response… + HTTP/1.1 200 OK + Date: Thu, 14 Nov 2019 19:52:01 GMT + Content-Type: text/html + Connection: keep-alive + Set-Cookie: __cfduid=db73306a2f1c72c1318ad4709ef49a3a01573761121; expires=Fri, 13-Nov-20 19:52:01 GMT; path=/; domain=.magesh.co.in; HttpOnly + Vary: Accept-Encoding + Last-Modified: Sun, 14 Jun 2015 11:52:38 GMT + X-Cache: HIT from Backend + CF-Cache-Status: DYNAMIC + Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: cloudflare + CF-RAY: 535b85fe381ee684-LHR +Length: unspecified [text/html] +Remote file exists and could contain further links, +but recursion is disabled -- not retrieving. +``` + +Use the following wget command if you want to see only the HTTP status code instead of entire output. + +``` +# wget --spider -S "www.magesh.co.in" 2>&1 | awk '/HTTP\// {print $2}' + 200 +``` + +If you want to see if a given website is up or down, use the following Bash script. + +``` +# vi wget-url-check.sh + +#!/bin/bash +if wget --spider -S "https://www.google.com" 2>&1 | grep -w "200\|301" ; then + echo "Google.com is up" +else + echo "Google.com is down" +fi +``` + +Once you have added the above script to a file, run the file to see the output. + +``` +# wget-url-check.sh + +HTTP/1.1 200 OK +Google.com is up +``` + +Use the following shell script if you want to see the status of multiple websites. + +``` +# vi curl-url-check-1.sh + +#!/bin/bash +for site in www.google.com google.co.in www.xyzzz.com +do +if wget --spider -S "$site" 2>&1 | grep -w "200\|301" ; then + echo "$site is up" +else + echo "$site is down" +fi +echo "----------------------------------" +done +``` + +Once you have added the above script to a file, run the file to see the output. + +``` +# sh wget-url-check-1.sh + +HTTP/1.1 200 OK +www.google.com is up +---------------------------------- +HTTP/1.1 301 Moved Permanently +google.co.in is up +---------------------------------- +www.xyzzz.com is down +---------------------------------- +``` + +### Method-5: How to Quickly Check Whether a Website is up or down Using the lynx Command + +**[lynx][5]** is a highly configurable text-based web browser for use on cursor-addressable character cell terminals. It’s the oldest web browser and it’s still in active development. + +``` +# lynx -head -dump http://www.magesh.co.in + +HTTP/1.1 200 OK +Date: Fri, 15 Nov 2019 08:14:23 GMT +Content-Type: text/html +Connection: close +Set-Cookie: __cfduid=df3cb624024b81df7362f42ede71300951573805662; expires=Sat, 1 +4-Nov-20 08:14:22 GMT; path=/; domain=.magesh.co.in; HttpOnly +Vary: Accept-Encoding +Last-Modified: Sun, 14 Jun 2015 11:52:38 GMT +X-Cache: HIT from Backend +CF-Cache-Status: DYNAMIC +Server: cloudflare +CF-RAY: 535fc5704a43e694-LHR +``` + +Use the following lynx command if you want to see only the HTTP status code instead of entire output. + +``` +# lynx -head -dump https://www.magesh.co.in 2>&1 | awk '/HTTP\// {print $2}' + 200 +``` + +If you want to see if a given website is up or down, use the following Bash script. + +``` +# vi lynx-url-check.sh + +#!/bin/bash +if lynx -head -dump http://www.magesh.co.in 2>&1 | grep -w "200\|301" ; then + echo "magesh.co.in is up" +else + echo "magesh.co.in is down" +fi +``` + +Once you have added the above script to a file, run the file to see the output. + +``` +# sh lynx-url-check.sh + +HTTP/1.1 200 OK +magesh.co.in is up +``` + +Use the following shell script if you want to see the status of multiple websites. + +``` +# vi lynx-url-check-1.sh + +#!/bin/bash +for site in http://www.google.com https://google.co.in http://www.xyzzz.com +do +if lynx -head -dump "$site" 2>&1 | grep -w "200\|301" ; then + echo "$site is up" +else + echo "$site is down" +fi +echo "----------------------------------" +done +``` + +Once you have added the above script to a file, run the file to see the output. + +``` +# sh lynx-url-check-1.sh + +HTTP/1.0 200 OK +http://www.google.com is up +---------------------------------- +HTTP/1.0 301 Moved Permanently +https://google.co.in is up +---------------------------------- +www.xyzzz.com is down +---------------------------------- +``` + +### Method-6: How to Check if a Website is up or down Using the ping Command + +**[ping command][1]** stands for (Packet Internet Groper) command is a networking utility that used to test the target of a host availability/connectivity on an Internet Protocol (IP) network. + +It’s verify a host availability by sending Internet Control Message Protocol (ICMP) Echo Request packets to the target host and waiting for an ICMP Echo Reply. + +It summarize statistical results based on the packets transmitted, packets received, packet loss, typically including the min/avg/max times. + +``` +# ping -c 5 2daygeek.com + +PING 2daygeek.com (104.27.157.177) 56(84) bytes of data. +64 bytes from 104.27.157.177 (104.27.157.177): icmp_seq=1 ttl=58 time=228 ms +64 bytes from 104.27.157.177 (104.27.157.177): icmp_seq=2 ttl=58 time=227 ms +64 bytes from 104.27.157.177 (104.27.157.177): icmp_seq=3 ttl=58 time=250 ms +64 bytes from 104.27.157.177 (104.27.157.177): icmp_seq=4 ttl=58 time=171 ms +64 bytes from 104.27.157.177 (104.27.157.177): icmp_seq=5 ttl=58 time=193 ms + +--- 2daygeek.com ping statistics --- +5 packets transmitted, 5 received, 0% packet loss, time 13244ms +rtt min/avg/max/mdev = 170.668/213.824/250.295/28.320 ms +``` + +### Method-7: How to Quickly Check Whether a Website is up or down Using the telnet Command + +The Telnet command is an old network protocol used to communicate with another host over a TCP/IP network using the TELNET protocol. + +It uses port 23 to connect to other devices, such as computer and network equipment. + +Telnet is not a secure protocol and is now not recommended to use because the data sent to the protocol is not encrypted and can be intercepted by hackers. + +Everyone uses SSH protocol instead of telnet, which is encrypted and very secure. + +``` +# telnet google.com 80 + +Trying 216.58.194.46… +Connected to google.com. +Escape character is '^]'. +^] +telnet> quit +Connection closed. +``` + +### Method-8: How to Check if a Website is up or down Using the Bash Script + +In simple words, a **[shell script][6]** is a file that contains a series of commands. The shell reads this file and executes the commands one by one as they are entered directly on the command line. + +To make this more useful we can add some conditions. This reduces the Linux admin task. + +If you want to see the status of multiple websites using the wget command, use the following shell script. + +``` +# vi wget-url-check-2.sh + +#!/bin/bash +for site in www.google.com google.co.in www.xyzzz.com +do +if wget --spider -S "$site" 2>&1 | grep -w "200\|301" > /dev/null ; then + echo "$site is up" +else + echo "$site is down" +fi +done +``` + +Once you have added the above script to a file, run the file to see the output. + +``` +# sh wget-url-check-2.sh + +www.google.com is up +google.co.in is up +www.xyzzz.com is down +``` + +If you want to see the status of multiple websites using the curl command, use the following **[bash script][7]**. + +``` +# vi curl-url-check-2.sh + +#!/bin/bash +for site in www.google.com google.co.in www.xyzzz.com +do +if curl -I "$site" 2>&1 | grep -w "200\|301" > /dev/null ; then + echo "$site is up" +else + echo "$site is down" +fi +done +``` + +Once you have added the above script to a file, run the file to see the output. + +``` +# sh curl-url-check-2.sh + +www.google.com is up +google.co.in is up +www.xyzzz.com is down +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-command-check-website-is-up-down-alive/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/how-to-use-ping-fping-gping-in-linux/ +[2]: https://www.2daygeek.com/httpie-curl-wget-alternative-http-client-linux/ +[3]: https://www.2daygeek.com/curl-linux-command-line-download-manager/ +[4]: https://www.2daygeek.com/wget-linux-command-line-download-utility-tool/ +[5]: https://www.2daygeek.com/best-text-mode-based-command-line-web-browser-for-linux/ +[6]: https://www.2daygeek.com/category/shell-script/ +[7]: https://www.2daygeek.com/category/bash-script/ diff --git a/sources/tech/20191116 Troubleshooting -E- Unable to locate package- Error on Ubuntu -Beginner-s Tutorial.md b/sources/tech/20191116 Troubleshooting -E- Unable to locate package- Error on Ubuntu -Beginner-s Tutorial.md new file mode 100644 index 0000000000..d386cdc24e --- /dev/null +++ b/sources/tech/20191116 Troubleshooting -E- Unable to locate package- Error on Ubuntu -Beginner-s Tutorial.md @@ -0,0 +1,166 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Troubleshooting “E: Unable to locate package” Error on Ubuntu [Beginner’s Tutorial]) +[#]: via: (https://itsfoss.com/unable-to-locate-package-error-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Troubleshooting “E: Unable to locate package” Error on Ubuntu [Beginner’s Tutorial] +====== + +_**This beginner tutorial shows how to go about fixing the E: Unable to locate package error on Ubuntu Linux.**_ + +One of the [many ways of installing software in Ubuntu][1] is to use the [apt-get][2] or the [apt command][3]. You open a terminal and use the program name to install it like this: + +``` +sudo apt install package_name +``` + +Sometimes, you may encounter an error while trying to install application in this manner. The error reads: + +``` +sudo apt-get install package_name +Reading package lists... Done +Building dependency tree +Reading state information... Done +E: Unable to locate package package_name +``` + +The error is self explanatory. Your Linux system cannot find the package that you are trying to install. But why is it so? Why can it not find the package? Let’s see some of the actions you can take to fix this issue. + +### Fixing ‘Unable to locate package error’ on Ubuntu + +![][4] + +Let’s see how to troubleshoot this issue one step at a time. + +#### 1\. Check the package name (no, seriously) + +This should be the first thing to check. Did you make a typo in the package name? I mean, if you are trying to [install vlc][5] and you typed vcl, it will surely fail. Typos are common so make sure that you have not made any mistakes in typing the name of the package. + +#### 2\. Update the repository cache + +If this is the first time you are using your system after installing, you should run the update command: + +``` +sudo apt update +``` + +This command won’t [update Ubuntu][6] straightaway. I recommend to get through the [concept of Ubuntu repositories][7]. Basically, the ‘apt update’ command builds a local cache of available packages. + +When you use the install command, apt package manager searches the cache to get the package and version information and then download it from its repositories over the network. If the package is not in this cache, your system won’t be able to install it. + +When you have a freshly installed Ubuntu system, the cache is empty. This is why you should run the apt update command right after installing Ubuntu or any other distributions based on Ubuntu (like Linux Mint). + +Even if its not a fresh install, your apt cache might be outdated. It’s always a good idea to update it. + +#### 3\. Check if package is available for your Ubuntu version + +Alright! You checked the name of the package and it is correct. You run the update command to rebuild the cache and yet you see the unable to locate package error. + +It is possible that the package is really not available. But you are following the instructions mentioned on some website and everyone else seems to be able to install it like that. What could be the issue? + +I can see two things here. Either the package available in Universe repository and your system hasn’t enabled it or the package is not available on your Ubuntu version altogether. Don’t get confused. I’ll explain it for you. + +First step, [check the Ubuntu version you are running][8]. Open a terminal and use the following command: + +``` +lsb_release -a +``` + +You’ll get the Ubuntu version number and the codename in the output. The codename is what important here: + +``` +[email protected]:~$ lsb_release -a +No LSB modules are available. +Distributor ID: Ubuntu +Description: Ubuntu 18.04.3 LTS +Release: 18.04 +Codename: bionic +``` + +![Ubuntu Version Check][9] + +As you can see here, I am using Ubuntu 18.04 and its codename is _bionic_. You may have something else but you get the gist of what you need to note here. + +Once you have the version number and the codename, head over to the Ubuntu packages website: + +[Ubuntu Packages][10] + +Scroll down a bit on this page and go to the Search part. You’ll see a keyword field. Enter the package name (which cannot be found by your system) and then set the correct distribution codename. The section should be ‘any’. When you have set these three details, hit the search button. + +![Ubuntu Package Search][11] + +This will show if the package is available for your Ubuntu version and if yes, which repository it belongs to. In my case, I searched for [Shutter screenshot tool][12] and this is what it showed me for Ubuntu 18.04 Bionic version: + +![Package Search Result][13] + +In my case, the package name is an exact match. This means the package shutter is available for Ubuntu 18.04 Bionic but in the ‘Universe repository’. If you are wondering what the heck is Universe repository, please [refer to the Ubuntu repository article I had mentioned earlier][7]. + +If the intended package is available for your Ubuntu version but it a repository like universe or multiverse, you should enable these additional repositories: + +``` +sudo add-apt-repository universe multiverse +``` + +You must also update the cache so that your system is aware of the new packages available through these repositories: + +``` +sudo apt update +``` + +Now if you try to install the package, things should be fine. + +#### Nothing works, what now? + +If Ubuntu Packages website also shows that the package is not available for your specific version, then you’ll have to find some other ways to install the package. + +Take Shutter for example. It’s an [excellent screenshot tool for Linux][14] but it hasn’t been updated in years and thus Ubuntu has dropped it from Ubuntu 18.10 and newer versions. How to install it now? Thankfully, some third party developer created a personal repository (PPA) and you can install it using that. [Please read this detailed guide to [understand PPA in Ubuntu][15].] You can search for packages and their PPA on Ubuntu’s Launchpad website. + +Do keep in mind that you shouldn’t add random (unofficial) PPAs to your repositories list. I advise sticking with what your distribution provides. + +If there are no PPAs, check the official website of the project and see if they provide some alternative ways of installing the application. Some projects provide .[DEB files][16] or [AppImage][17] files. Some projects have switched to [Snap packages][18]. + +In other words, check the official website of the project and check if they have changed their installation method. + +If nothing works, perhaps the project itself is discontinued and if that’s the case, you should look for its alternative application. + +**In the end…** + +If you are new to Ubuntu or Linux, things could be overwhelming. This is why I am covering some basic topics like this so that you get a better understanding of how things work in your system. + +I hope this tutorial helps you handling the package error in Ubuntu. If you have questions or suggestions, please feel free to ask in the comment section. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/unable-to-locate-package-error-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://itsfoss.com/remove-install-software-ubuntu/ +[2]: https://itsfoss.com/apt-get-linux-guide/ +[3]: https://itsfoss.com/apt-command-guide/ +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/unable_to_locate_package_error_ubuntu.png?ssl=1 +[5]: https://itsfoss.com/install-latest-vlc/ +[6]: https://itsfoss.com/update-ubuntu/ +[7]: https://itsfoss.com/ubuntu-repositories/ +[8]: https://itsfoss.com/how-to-know-ubuntu-unity-version/ +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/ubuntu_version_check.jpg?ssl=1 +[10]: https://packages.ubuntu.com/ +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/ubuntu_package_search.png?ssl=1 +[12]: https://itsfoss.com/install-shutter-ubuntu/ +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/package_search_result.png?resize=800%2C311&ssl=1 +[14]: https://itsfoss.com/take-screenshot-linux/ +[15]: https://itsfoss.com/ppa-guide/ +[16]: https://itsfoss.com/install-deb-files-ubuntu/ +[17]: https://itsfoss.com/use-appimage-linux/ +[18]: https://itsfoss.com/use-snap-packages-ubuntu-16-04/ diff --git a/sources/tech/20191118 Creating a Chat Bot with Recast.AI.md b/sources/tech/20191118 Creating a Chat Bot with Recast.AI.md new file mode 100644 index 0000000000..0b86e74c72 --- /dev/null +++ b/sources/tech/20191118 Creating a Chat Bot with Recast.AI.md @@ -0,0 +1,181 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Creating a Chat Bot with Recast.AI) +[#]: via: (https://opensourceforu.com/2019/11/creating-a-chat-bot-with-recast-ai/) +[#]: author: (Athira Lekshmi C.V https://opensourceforu.com/author/athira-lekshmi/) + +Creating a Chat Bot with Recast.AI +====== + +[![][1]][2] + +_According to a Gartner report from February 2018, “25 per cent of customer service and support operations will integrate virtual customer assistant (VCA) or chatbot technology across engagement channels by 2020, up from less than 2 per cent in 2017.” In the light of this, readers will find this tutorial on how the open source Recast. AI bot-creating platform works, helpful._ + +Chat bots, both voice based and others, have been in use for quite a while now. From chatbots that engage the user in a murder mystery game to bots which help in real estate deals and medical diagnosis, chatbots have traversed across domains. + +There are many platforms which enable users to create and deploy bots. Recast.AI (now known as SAP Conversational AI after its acquisition by SAP) is a forerunner amongst these. + +The cool interface, its collaborative nature and the analytics tools it provides, make it a popular choice. +As the Recast official site says, “It is an ultimate collaborative platform to build, train, deploy and monitor intelligent bots.” + +![Figure 1: Setting the bot properties][3] + +![Figure 2: Bot dashboard][4] + +![Figure 3: Searching an intent][5] + +**Building a basic bot in Recast** +Let us look at how to build a basic bot in Recast. + + 1. Create an account in __. Signing up can be done either with an email ID or with a GitHub account. + 2. Once you log in, you will land on the dashboard. Click on the + New Bot icon on the top right-hand side to create a new bot. + 3. On the next screen, you will see that there is a set of predefined skills you can select. Select Greetings for the time being (Figure 1). This bot is already trained to understand basic greetings. + 4. Provide a name for your bot. For now, since this is a very basic bot, you can have the bot crack some jokes, so let us name it Joke Bot and select the default language as English. + 5. Select Non-personal data under the data policy since you won’t be dealing with any sensitive information; then select the Public bot option and click on Create a bot. + + + +So that’s your bot created on the Recast platform. + +![Figure 4: @joke intent][6] + +![Figure 5: Predefined expressions][7] + +**The five stages of developing a bot** +To use the words from the official Recast blog, there are five stages in a bot’s life. + + * Training – Teaching your bot what it needs to understand + * Building – Creating your conversational flow with the Bot Builder tool + * Coding – Connecting your bot with external APIs or a database + * Connecting – Shipping your bot to one or several messaging platforms + * Monitoring – Training your bot to make it sharper and get insights on its usage + + + +**Training a bot through intents** +You will be able to see the options to either search, fork or create an intent in the dashboard. +“An intent is a box of expressions that mean the same thing but which are constructed in different ways. Intents are the heart of your bot’s understanding. Each one of your intents represents an idea your bot is able to understand.” (from the _Recast.AI_ website) +As decided earlier, you need the bot to be able to crack jokes. So the base line is that the bot should be able to understand that the user is asking it to tell a joke; it shouldn’t be that even when the user just says, “Hi,” the bot responds with a joke – that would not be good. +So group the utterances that the user might make, like: + +``` +Tell me a joke. +Tell me a funny fact. +Can you crack a joke? +What’s funny today? +``` + +………………… + +Before going on to create the intent from scratch, let us explore the Search/fork option. Type _Joke_ in the search field (Figure 3). This gives a list of intents created by users of Recast around the globe, which is public, and this is why Recast is said to be collaborative in nature. So there’s no need to create all intents from scratch, one can build upon intents already created. This brings down the effort needed to train the bot with common intents. + + * Select the first intent in the list and fork it into the bot. + * Click on the Fork button. The intent is now added to the bot (Figure 4). + * Click on the intent @joke, and a list of expressions which already exist in the intent will be displayed (Figure 5). + * Add a few more expressions to it (Figure 6). + + + +![Figure 6: Suggested expressions][8] + +![Figure 7: Suggested expressions][9] + +Once a few expressions are added, the bot gives suggestions like shown in Figure 7. Select a few and add them to the intent (Figure 7). +You can also tag your own custom entities to detect keywords, depending on your bot’s context. + +**Skills** +A skill is a block of conversation that has a clear purpose and that your bot can execute to achieve a goal. It can be as simple as the ability to greet someone, but it can also be more complex, like giving movie suggestions based on information provided by the user. + +It need not be just a one query-answer set, but rather, skills running through multiple exchanges. For example, consider a bot which helps you learn about currency exchange rates. It starts by asking the source currency, then the target currency, before giving the exact response. Skills can be combined to create complex conversational flows. +Here’s how you create a skill for the joke bot: + + * Go to the _Build_ tab. Click on the + icon to create a skill. + * Name the skill _Joke_ (Figure 8) + * Once created, click on the skill. You will see four tabs. _Read me, Triggers, Requirements and Actions_. + * Navigate to the Requirements tab. You should store the information only if the intent joke is present. So, add a requirement as shown in Figure 9. + + + +![Figure 8: Skills dashboard][10] + +![Figure 9: Adding a trigger][11] + +Since this is a simple use case, you needn’t consider any specific requirements in the Requirement tab but consider a case for which a response needs to be triggered only if certain keywords or entities are present – in such a case you will need ‘requirements’. + +Requirements are either intents or entities that your skill needs to retrieve before executing actions. Requirements are pieces of information that are important in the conversation and that your bot can use; for example, the user’s name or a location. Once a requirement is completed, the associated value is stored in the bot’s memory for the entire conversation. + +Now let us move to the Action tab to set the responses (see Figure 10). +Click on Add _new message group_. Then select _Send message_ and add a text message, which can be any joke in this case. Also, since you don’t want your bot to crack the same joke each time, you can add multiple messages which will be randomly picked each time. + +![Figure 10: Adding actions][12] + +![Figure 11: Adding text messages][13] + +![Figure 12: Setting up webchat][14] + +**Channel integrations** +Well, the success of a bot also depends upon how easily it is accessible. Recast has built-in integrations with many messaging channels such as Skype for Business, Kik Messenger, Telegram, Line, Facebook Messenger, Slack, Alexa, etc. In addition to that, Recast also provides SDKs to develop custom channels. + +Also, there is a ready-to-use Web chat provided by Recast (in the Connect tab). You can customise the colour schemes, headers, bot pictures, etc. It provides you with a script tag to be injected into the page. Your interface is now up (Figure 12). + +The Web chat code base is open sourced, which makes it easier for developers to play around with the look and feel, the standard response types and much more. +The dashboard provides step-by-step procedures on how to deploy the bot on various channels. The joke bot was deployed in Telegram and in Web chat, as shown in Figure 13. + +![Figure 13: Webchat deployed][15] + +![Figure 14: Bot deployed in Telegram][16] + +![Figure 15: Multi-language bot][17] + +**And there is more** +Recast supports multiple languages, Select one language as the base while creating the bot, but then you also have the option to add as many languages as you want. + +The example considered here is a simple static joke bot, but actual use cases will need interaction with various systems. Recast has a Web hook feature which allows users to connect with various systems to get responses. Also, there is detailed API documentation to help leverage each independent feature of the platform. + +As for analytics, Recast has a monitoring dashboard which helps you understand the accuracy of the bot and train it further. + +![Avatar][18] + +[Athira Lekshmi C.V][19] + +The author is an open-source enthusiast. + +[![][20]][21] + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/creating-a-chat-bot-with-recast-ai/ + +作者:[Athira Lekshmi C.V][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://opensourceforu.com/author/athira-lekshmi/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/04/Build-ChatBoat.jpg?resize=696%2C442&ssl=1 (Build ChatBoat) +[2]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/04/Build-ChatBoat.jpg?fit=900%2C572&ssl=1 +[3]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-1-Setting-the-bot-properties.jpg?resize=350%2C201&ssl=1 +[4]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-2-Setting-the-bot-properties.jpg?resize=350%2C217&ssl=1 +[5]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-3-Searching-an-intent.jpg?resize=350%2C271&ssl=1 +[6]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-4-@joke-intent.jpg?resize=350%2C214&ssl=1 +[7]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-5-Predefined-expressions-350x227.jpg?resize=350%2C227&ssl=1 +[8]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-6-Suggested-expressions-350x197.jpg?resize=350%2C197&ssl=1 +[9]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-7-Suggested-expressions-350x248.jpg?resize=350%2C248&ssl=1 +[10]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-8-Skills-dashboard.jpg?resize=350%2C187&ssl=1 +[11]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-9-Adding-a-trigger.jpg?resize=350%2C197&ssl=1 +[12]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-10-Adding-actions.jpg?resize=350%2C175&ssl=1 +[13]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-11-Adding-text-messages.jpg?resize=350%2C255&ssl=1 +[14]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-12-Setting-up-webchat.jpg?resize=350%2C326&ssl=1 +[15]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-13-Webchat-deployed.jpg?resize=350%2C425&ssl=1 +[16]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-14-Bot-deployed-in-Telegram.jpg?resize=350%2C269&ssl=1 +[17]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-15-Multi-language-bot.jpg?resize=350%2C419&ssl=1 +[18]: https://secure.gravatar.com/avatar/d24503a2a0bb8bd9eefe502587d67323?s=100&r=g +[19]: https://opensourceforu.com/author/athira-lekshmi/ +[20]: https://opensourceforu.com/wp-content/uploads/2019/11/assoc.png +[21]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/sources/tech/20191118 How internet security works- TLS, SSL, and CA.md b/sources/tech/20191118 How internet security works- TLS, SSL, and CA.md new file mode 100644 index 0000000000..0247b43ef1 --- /dev/null +++ b/sources/tech/20191118 How internet security works- TLS, SSL, and CA.md @@ -0,0 +1,57 @@ +[#]: collector: (lujun9972) +[#]: translator: (hopefully2333) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How internet security works: TLS, SSL, and CA) +[#]: via: (https://opensource.com/article/19/11/internet-security-tls-ssl-certificate-authority) +[#]: author: (Bryant Son https://opensource.com/users/brson) + +How internet security works: TLS, SSL, and CA +====== +What's behind that lock icon in your web browser? +![Lock][1] + +Multiple times every day, you visit websites that ask you to log in with your username or email address and password. Banking websites, social networking sites, email services, e-commerce sites, and news sites are just a handful of the types of sites that use this mechanism. + +Every time you sign into one of these sites, you are, in essence, saying, "yes, I trust this website, so I am willing to share my personal information with it." This data may include your name, gender, physical address, email address, and sometimes even credit card information. + +But how do you know you can trust a particular website? To put this a different way, what is the website doing to secure your transaction so that you can trust it? + +This article aims to demystify the mechanisms that make a website secure. I will start by discussing the web protocols HTTP and HTTPS and the concept of Transport Layer Security (TLS), which is one of the cryptographic protocols in the internet protocol's (IP) layers. Then, I will explain certificate authorities (CAs) and self-signed certificates and how they can help secure a website. Finally, I will introduce some open source tools you can use to create and manage certificates. + +## Securing routes through HTTPS + +The easiest way to understand a secured website is to see it in action. Fortunately, it is far easier to find a secured website than an unsecured website on the internet today. But, since you are already on Opensource.com, I'll use it as an example. No matter what browser you're using, you should see an icon that looks like a lock next to the address bar. Click on the lock icon, and you should see something similar to this. + +![Certificate information][2] + +By default, a website is not secure if it uses the HTTP protocol. Adding a certificate configured through the website host to the route can transform the website from an unsecured HTTP site to a secured HTTPS site. The lock icon usually indicates that the site is secured through HTTPS. + +Click on Certificate to see the site's CA. Depending on your browser, you may need to download the certificate to see it. + +![Certificate information][3] + +Here, you can learn something about Opensource.com's certificate. For example, you can see that the CA is DigiCert, and it is given to Red Hat under the name Opensource.com. + +This certificate information enables the end user to check that the website is safe to visit. + +> WARNING: If you do not see a certificate sign on a website—or if you see a sign that indicates that the website is not secure—please do not log in or do any activity that requires your private data. Doing so is quite dangerous! + +If you see a warning sign, which is rare for most publicly facing websites, it usually means that the certificate is expired or uses a self-signed certificate instead of one issued through a trusted CA. Before we get into those topics, I want to explain the TLS and SSL. + +## Internet protocols with TLS and SSL + +TLS is the current generation of the old Secure Socket Layer (SSL) protocol. The best way to understand this is by examining the different layers of the IP. + +![IP layers][4] + +There are six layers that make up the internet as we know it today: physical, data, network, transport, security, and application. The physical layer is the base foundation, and it is closest to the actual hardware. The application layer is the most abstract layer and the one closest to the end user. The security layer can be considered a part of the application layer, and TLS and SSL, which are the cryptographic protocols designed to provide communications security over a computer network, are in the security layer. + +This process ensures that communication is secure and encrypted when an end user consumes the service. + +## Certificate authorities and self-signed certificates + +A CA is a trusted organization that can issue a digital certificate. + +TLS and SSL can make a connection secure, but the encryption mechanism needs a way to validate it; this is the SSL/TLS certificate. TLS uses a mechanism called asymmetric encryption, which i diff --git a/sources/tech/20191118 How to use regular expressions in awk.md b/sources/tech/20191118 How to use regular expressions in awk.md new file mode 100644 index 0000000000..cdf1468369 --- /dev/null +++ b/sources/tech/20191118 How to use regular expressions in awk.md @@ -0,0 +1,279 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to use regular expressions in awk) +[#]: via: (https://opensource.com/article/19/11/how-regular-expressions-awk) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +How to use regular expressions in awk +====== +Use regex to search code using dynamic and complex pattern definitions. +![Coding on a computer][1] + +In awk, regular expressions (regex) allow for dynamic and complex pattern definitions. You're not limited to searching for simple strings but also patterns within patterns. + +The syntax for using regular expressions to match lines in awk is: + + +``` +`word ~ /match/` +``` + +The inverse of that is _not_ matching a pattern: + + +``` +`word !~ /match/` +``` + +If you haven't already, create the sample file from our [previous article][2]: + + +``` +name       color  amount +apple      red    4 +banana     yellow 6 +strawberry red    3 +raspberry  red    99 +grape      purple 10 +apple      green  8 +plum       purple 2 +kiwi       brown  4 +potato     brown  9 +pineapple  yellow 5 +``` + +Save the file as **colours.txt** and run: + + +``` +$ awk -e '$1 ~ /p[el]/ {print $0}' colours.txt +apple      red    4 +grape      purple 10 +apple      green  8 +plum       purple 2 +pineapple  yellow 5 +``` + +You have selected all records containing the letter **p** followed by _either_ an **e** or an **l**. + +Adding an **o** inside the square brackets creates a new pattern to match: + + +``` +$ awk -e '$1 ~ /p[el]/ {print $0}' colours.txt +apple      red    4 +grape      purple 10 +apple      green  8 +plum       purple 2 +pineapple  yellow 5 +potato     brown  9 +``` + +### Regular expression basics + +Certain characters have special meanings when they're used in regular expressions. + +#### Anchors + +Anchor | Function +---|--- +**^** | Indicates the beginning of the line +**$** | Indicates the end of a line +**\A** | Denotes the beginning of a string +**\z** | Denotes the end of a string +**\b** | Marks a word boundary + +For example, this awk command prints any record containing an **r** character: + + +``` +$ awk -e '$1 ~ /r/ {print $0}' colours.txt +strawberry red    3 +raspberry  red    99 +grape      purple 10 +``` + +Add a **^** symbol to select only records where **r** occurs at the beginning of the line: + + +``` +$ awk -e '$1 ~ /^r/ {print $0}' colours.txt +raspberry  red    99 +``` + +#### Characters + +Character | Function +---|--- +**[ad]** | Selects **a** or **d** +**[a-d]** | Selects any character **a** through **d** (a, b, c, or d) +**[^a-d]** | Selects any character _except_ **a** through **d** (e, f, g, h…) +**\w** | Selects any word +**\s** | Selects any whitespace character +**\d** | Selects any digit + +The capital versions of w, s, and d are negations; for example, **\D** _does not_ select any digit. + +[POSIX][3] regex offers easy mnemonics for character classes: + +POSIX mnemonic | Function +---|--- +**[:alnum:]** | Alphanumeric characters +**[:alpha:]** | Alphabetic characters +**[:space:]** | Space characters (such as space, tab, and formfeed) +**[:blank:]** | Space and tab characters +**[:upper:]** | Uppercase alphabetic characters +**[:lower:]** | Lowercase alphabetic characters +**[:digit:]** | Numeric characters +**[:xdigit:]** | Characters that are hexadecimal digits +**[:punct:]** | Punctuation characters (i.e., characters that are not letters, digits, control characters, or space characters) +**[:cntrl:]** | Control characters +**[:graph:]** | Characters that are both printable and visible (e.g., a space is printable but not visible, whereas an **a** is both) +**[:print:]** | Printable characters (i.e., characters that are not control characters) + +### Quantifiers + +Quantifier | Function +---|--- +**.** | Matches any character +**+** | Modifies the preceding set to mean _one or more times_ +***** | Modifies the preceding set to mean _zero or more times_ +**?** | Modifies the preceding set to mean _zero or one time_ +**{n}** | Modifies the preceding set to mean _exactly n times_ +**{n,}** | Modifies the preceding set to mean _n or more times_ +**{n,m}** | Modifies the preceding set to mean _between n and m times_ + +Many quantifiers modify the character sets that precede them. For example, **.** means any character that appears exactly once, but **.*** means _any or no_ character. Here's an example; look at the regex pattern carefully: + + +``` +$ printf "red\nrd\n" +red +rd +$ printf "red\nrd\n" | awk -e '$0 ~ /^r.d/ {print}' +red +$ printf "red\nrd\n" | awk -e '$0 ~ /^r.*d/ {print}' +red +rd +``` + +Similarly, numbers in braces specify the number of times something occurs. To find records in which an **e** character occurs exactly twice: + + +``` +$ awk -e '$2 ~ /e{2}/ {print $0}' colours.txt +apple      green  8 +``` + +### Grouped matches + +Quantifier | Function +---|--- +**(red)** | Parentheses indicate that the enclosed letters must appear contiguously +** | ** + +For instance, the pattern **(red)** matches the word **red** and **ordered** but not any word that contains all three of those letters in another order (such as the word **order**). + +### Awk like sed with sub() and gsub() + +Awk features several functions that perform find-and-replace actions, much like the Unix command **sed**. These are functions, just like **print** and **printf**, and can be used in awk rules to replace strings with a new string, whether the new string is a string or a variable. + +The **sub** function substitutes the _first_ matched entity (in a record) with a replacement string. For example, if you have this rule in an awk script: + + +``` +{ sub(/apple/, "nut", $1); +    print $1 } +``` + +running it on the example file **colours.txt** produces this output: + + +``` +name +nut +banana +raspberry +strawberry +grape +nut +plum +kiwi +potato +pinenut +``` + +The reason both **apple** and **pineapple** were replaced with **nut** is that both are the first match of their records. If the records were different, then the results could differ: + + +``` +$ printf "apple apple\npineapple apple\n" | \ +awk -e 'sub(/apple/, "nut")' +nut apple +pinenut apple +``` + +The **gsub** command substitutes _all_ matching items: + + +``` +$ printf "apple apple\npineapple apple\n" | \ +awk -e 'gsub(/apple/, "nut")' +nut nut +pinenut nut +``` + +#### Gensub + +An even more complex version of these functions, called **gensub()**, is also available. + +The **gensub** function allows you to use the **&** character to recall the matched text. For example, if you have a file with the word **Awk** and you want to change it to **GNU Awk**, you could use this rule: + + +``` +`{ print gensub(/(Awk)/, "GNU &", 1) }` +``` + +This searches for the group of characters **Awk** and stores it in memory, represented by the special character **&**. Then it substitutes the string for **GNU &**, meaning **GNU Awk**. The **1** character at the end tells **gensub()** to replace the first occurrence. + + +``` +$ printf "Awk\nAwk is not Awkward" \ +| awk -e ' { print gensub(/(Awk)/, "GNU &",1) }' +GNU Awk +GNU Awk is not Awkward +``` + +### There's a time and a place + +Awk is a powerful tool, and regex are complex. You might think awk is so very powerful that it could easily replace **grep** and **sed** and **tr** and [**sort**][4] and many more, and in a sense, you'd be right. However, awk is just one tool in a toolbox that's overflowing with great options. You have a choice about what you use and when you use it, so don't feel that you have to use one tool for every job great and small. + +With that said, awk really _is_ a powerful tool with lots of great functions. The more you use it, the better you get to know it. Remember its capabilities, and fall back on it occasionally so can you get comfortable with it. + +Our next article will cover looping in Awk, so come back soon! + +* * * + +_This article is adapted from an episode of [Hacker Public Radio][5], a community technology podcast._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/how-regular-expressions-awk + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: https://opensource.com/article/19/10/intro-awk +[3]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains +[4]: https://opensource.com/article/19/10/get-sorted-sort +[5]: http://hackerpublicradio.org/eps.php?id=2129 diff --git a/sources/tech/20191118 Some notes on vector drawing apps.md b/sources/tech/20191118 Some notes on vector drawing apps.md new file mode 100644 index 0000000000..7c57682fc6 --- /dev/null +++ b/sources/tech/20191118 Some notes on vector drawing apps.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Some notes on vector drawing apps) +[#]: via: (https://jvns.ca/blog/2019/11/18/some-notes-on-vector-drawing-apps/) +[#]: author: (Julia Evans https://jvns.ca/) + +Some notes on vector drawing apps +====== + +For the last year and a half I’ve been using the iPad Notability app to draw my [zines][1]. Last week I decided I wanted more features, did a bit of research, and decided to switch to Affinity Designer (a much more complicated program). So here are a few quick notes about it. + +The main difference between them is that Notability is a simple note taking app (aimed at regular people), and Affinity Designer is a vector graphics app (aimed at illustrators / graphic designers), like Adobe Illustrator. + +I’ve never used a serious vector graphics program before, so it’s been cool to learn what kinds of features are available! + +### Notability is super simple + +This is what the Notability UI looks like. There’s a pencil, an eraser, a text tool, and a selection tool. That’s basically it. I LOVED this simplicity when I started using Notability, and I made 4 zines using it (help! i have a manager!, oh shit, git!, bite size networking!, and http: use your browser’s language). + + + +Recently though, I’ve had a couple of problems with it, the main one being that text boxes and things drawn with the pencil tool don’t mix well. (In general Notability has been GREAT though and their support team has always been incredibly helpful when I’ve had questions.) + +### Affinity Designer is really complicated + +Affinity Designer, by comparison, is WAY more complicated. Here’s what the UI looks like: + + + +There are + + * 14 tools on the left + * 14 more panels on the right that alter what the tools do + * a bottom toolbar which has different options for each tool + * 2 menus which together have another 25 things or so that you can do + + + +I still don’t understand what all the tools do (what’s the difference between Pencil and Vector Brush? I don’t know!). But I’m pretty excited about this because (unlike with Notability) there are so many options that if I’m frustrated about something, 90% of the time there’s a way to do the thing I want! + +### switching from Notability to Affinity Designer is really easy + +Switching to Notability wasn’t the best: I [reverse engineered the file format][2] to transfer some files over but the quality was never the best (probably because of problems with my script) and I ended up having to redraw a lot of them in practice. + +With Affinity Designer, I can just + + * export a PDF with Notability (or anything else) + * import the PDF with Affinity Designer + * and then I can easily edit it and that’s it?!? + + + +It’s not perfect – the vector paths it comes up with are kind of weird, probably because of the way the PDF is – but it’s very good! It makes me feel confident that if I need to make a small edit to something I made in the past I can just import the PDF! + +### what can a vector drawing app do? + +here are a few things Affinity Designer can do that Notability can’t: + + * **custom paper sizes**: In Notability every page is 8.5x11, but usually I want something more like 5.5x8.5 which is a different aspect ratio (this is technically sort of possible in Notability by importing a PDF of the correct size but it’s a pain and it means you can’t use a grid) + * **custom colour palettes**: I can have the 10 colours I like to use in my comics all in one place + * **grouping objects together** – I can “group” a bunch of objects together so that I can easily resize and move them all together + * **two kinds of text box**. This is the kind of thing that I wouldn’t have understood 2 years ago but that now I LOVE – you can either have “art text” that acts like an image (no word wrap, gets bigger when you resize it) or “frame text” that has word wrap and doesn’t get bigger when you resize it. + * **really great import** – I can import a PDF or SVG and individually edit / move around parts of the PDF. Notability doesn’t have any import tools that let you edit after importing. + * **custom export options for printing**. I don’t understand what it **does** yet but there are export presets for print PDFs and it fixes some printing problems I was having! + + + +There are also a LOT more features that I’m not interested in but I’m pretty excited about those 6 things and it feels like an app that I won’t grow out of. + +### iPad apps are great + +I’ve been exclusively using Linux for the last 15 years where the image editing/media tools aren’t always great (though I really like Inkscape and I hear good things about Krita!), so it’s really cool to have access to all these great iPad apps. And the prices seem pretty reasonable: + + * Notability is $12 + * Affinity Designer is $20 + * LumaFusion (a nice video editor I’ve been using a little) is $30 + + + +It doesn’t make me want a Mac (I like the Linux desktop experience!), but it’s nice to have access to a bunch of these great tools. And I think a lot of these art tools work better on an iPad than on a computer anyway since you can just draw on the screen :) + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/11/18/some-notes-on-vector-drawing-apps/ + +作者:[Julia Evans][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://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://wizardzines.com +[2]: https://jvns.ca/blog/2018/03/31/reverse-engineering-notability-format/ diff --git a/sources/tech/20191119 App Highlight- Flameshot for Taking and Editing Screenshots.md b/sources/tech/20191119 App Highlight- Flameshot for Taking and Editing Screenshots.md new file mode 100644 index 0000000000..bc287325cd --- /dev/null +++ b/sources/tech/20191119 App Highlight- Flameshot for Taking and Editing Screenshots.md @@ -0,0 +1,153 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (App Highlight: Flameshot for Taking and Editing Screenshots) +[#]: via: (https://itsfoss.com/flameshot/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +App Highlight: Flameshot for Taking and Editing Screenshots +====== + +If you have been following It’s FOSS regularly, you might have come across my coverage on the [best ways to take a screenshot in Linux][1]. + +![][2] + +I did recommend using Flameshot as well because it happens to be my personal favorite to take screenshots. In case you didn’t know, [Flameshot][3] is an open source screenshot tool available for Linux. + +However, in this article, I shall be focusing on ‘Flameshot’ to help you install it, configure it, and highlight the features it has to offer. + +### Flameshot Features + +Flameshot offers almost all the essential features that you would ever require on a screenshot tool in Linux. Here are some of the key features in video format: + +[Subscribe to our YouTube channel for more Linux videos][4] + +#### Upload screenshot to Imgur + +![][5] + +A lot of users want to simply upload their screenshots directly to the cloud in order to easily share it with others. + +You can do that by syncing your saved files to a cloud storage solution and share them later. But, that’s quite a few steps to follow in order to share your screenshot, right? + +So, here, Flameshot lets you upload your image directly to [Imgur][6] with a single click. All you have to do is share the URL. + +Do note that these uploads will not be associated with your Imgur account (if you have one) and will be only accessible to the ones with the link. + +#### Annotation Options + +![][7] + +The whole point of having a 3rd party screenshot utility is the ability to annotate the pictures. + +You can choose to add an arrow mark, highlight a text, blur a section, add a text, draw something, add a rectangular/circular shaped border, and add a solid color box. + +![][8] + +You can take a closer look at the options with the help of the GIF above (from their official [GitHub page][9]): + +#### Customization Options + +![][10] + +In addition to all the useful features, it also gives you the ability to customize the UI, filename (when you save a screenshot), and some general options as well. + +### Installing Flameshot on Linux + +Before configuring Flameshot, you need to get it installed on your Linux system. + +You might find it in your Software Center/App Center/Package Manager, simply search for “flameshot” and get it installed. + +In case you do not find it there, you can head on to its [GitHub releases page][11] and download the setup file suitable for your Linux distro. It is available in DEB (for Ubuntu), RPM (for Fedora) and AppImage (for all Linux distributions) format. + +[Download Flameshot][11] + +### How To Setup Flameshot? + +Now that you are aware of the features (and probably have it installed), how do you use it? + +Of course, you don’t want to launch a screenshot tool by searching for it in the list of applications installed. + +So, the best way to access it would be to press the **PRT SC** key, right? + +But, by default, when you press the **Print Screen** button, it will launch the default screenshot tool (or directly take a full-screen screenshot). + +Fret not, you can easily change it. Here’s how you can set flameshot to launch upon pressing the ‘**Prt Sc**‘ button: + +1\. Head to the system settings and navigate your way to the “**Device**” options. + +2\. Next, head inside the “**Keyboard Shortcuts**” option. + +3\. Now, you need to change the keyboard shortcut for “**Saving a screenshot to Pictures**” from **Prt Sc** to anything else (a button you don’t use frequently). + +![Assign a custom keyboard shortcut to Flameshot][12] + +Refer to the image above to understand it better. + +4\. Once you have done this, scroll down to the bottom and add a new keyboard shortcut by clicking on the “**+**” button. + +5\. Here, you will get the option to name the shortcut (it can be anything) and in place of the command, you will have to enter: + +``` +flameshot gui +``` + +And, hit the **Prt Sc** button when you set the shortcut. That’s it! + +Here’s how it should look after configuration: + +![][13] + +Now, you should be able to launch Flameshot by pressing the **Prt Sc** button. + +### Few Tips To Note + +![][14] + + * By default, Flameshot saves the pictures in [PNG][15] format. So, if you need a [JPEG][16] file, you can simply rename the file extension. + * You can change the color of the text/arrow mark by performing a right-click before adding it. Once you change it, the color remains the same even when you use it the next time. You can change the color again, the same way. + * If you want the option to choose a custom color (instead of the pre-defined color selection), just hit the **SPACE** **bar** after you select a region to take the screenshot. + * If you cannot access the Flameshot configuration option via the app drawer, simply type in “**flameshot config**” in the terminal. + + + +**Wrapping Up** + +Even though there are alternatives to Flameshot available, I find it to be the best screenshot tool for my usage. + +If you found this tutorial helpful, do share it with other Linux users. If you find Flameshot useful, please do consider making a [donation to its developer][17]. + +In either case, if you already use a screenshot tool, which one is it? Do you know of something that happens to be better than Flameshot? Let me know your thoughts in the comments below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/flameshot/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/take-screenshot-linux/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/flameshot.png?ssl=1 +[3]: https://flameshot.js.org/ +[4]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/flameshot-cloud-upload-feature.jpg?ssl=1 +[6]: https://imgur.com/ +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/flameshot-options.jpg?ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/10/flameshot-usage.gif?ssl=1 +[9]: https://github.com/lupoDharkael/flameshot +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/flameshot-customization.jpg?ssl=1 +[11]: https://github.com/lupoDharkael/flameshot/releases +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/10/keyboard-shortcut-option.jpg?ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/flameshot-shortcut-config.jpg?ssl=1 +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/flameshot-tips.jpg?ssl=1 +[15]: https://en.wikipedia.org/wiki/Portable_Network_Graphics +[16]: https://en.wikipedia.org/wiki/JPEG +[17]: https://flameshot.js.org/#/ diff --git a/sources/tech/20191119 Container reality checks and more industry trends.md b/sources/tech/20191119 Container reality checks and more industry trends.md new file mode 100644 index 0000000000..5f5477e0aa --- /dev/null +++ b/sources/tech/20191119 Container reality checks and more industry trends.md @@ -0,0 +1,53 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Container reality checks and more industry trends) +[#]: via: (https://opensource.com/article/19/11/container-reality-checks-and-more-industry-trends) +[#]: author: (Tim Hildred https://opensource.com/users/thildred) + +Container reality checks and more industry trends +====== +A weekly look at open source community, market, and industry trends. +![Person standing in front of a giant computer screen with numbers, data][1] + +As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update. + +## [The benefits of gamification in business][2] + +> While its value as an industry is still growing each year, it seems that some organisations are still struggling to implement gamification technology in the first place or engage employees once they have. Early difficulties revolved around a lack of real clarity as to what gamification is and how it can help an organisation. This fed into poor initial results that have dampened enthusiasm among early adopters. There was also a belief that a one-size-fits-all approach could be used, regardless of the circumstances, the demographics of the teams involved or the processes being gamified. For the persistent, these early forays provided valuable lessons that rendered future projects more successful. + +**The impact**: The science fiction fan in me always found the idea of gamification dystopian; a way to trick employees into caring about things they otherwise wouldn't. The summer camp counselor in me recognizes the power of play in learning and teaching. Hopefully, that is the way the pendulum is swinging. + +## [Compare three distinct types of Kubernetes platforms][3] + +> Let's explore the benefits and risks of three types of Kubernetes platforms: the native open source tool, managed cloud services, and integrated ecosystems. We'll examine the technical features each option offers, the extent to which it supports enterprise container and cloud environments, and ease of use. + +**The impact**: This is all the other stuff that you should have been thinking about when you started to get hype on containers, and none of it comes for free. + +## [Deeply understanding the difference between portability, compatibility, and supportability][4] + +> Since the OCI standard governs the images specification, a container image can be created with Podman, pushed to almost any container registry, shared with the world, and consumed by almost any container engine including Docker, RKT, CRI-O, containerd and, of course, other Podman instances. Standardizing on this image format lets us build infrastructure like registry servers which can be used to store any container image, be it RHEL 6, RHEL 7, RHEL8, Fedora, or even Windows container images. + +**The impact**: Another container reality check that also drives home why going through the trouble of standards can be worth it in the long run. + +_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/container-reality-checks-and-more-industry-trends + +作者:[Tim Hildred][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/thildred +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) +[2]: https://social.hays.com/2019/11/05/benefits-of-gamification-in-business/ +[3]: https://searchitoperations.techtarget.com/feature/Compare-3-distinct-types-of-Kubernetes-platforms +[4]: http://crunchtools.com/deeply-understanding-the-different-between-portability-compatibility-and-supportability/ diff --git a/sources/tech/20191119 Loops in Emacs Lisp.md b/sources/tech/20191119 Loops in Emacs Lisp.md new file mode 100644 index 0000000000..66422100bf --- /dev/null +++ b/sources/tech/20191119 Loops in Emacs Lisp.md @@ -0,0 +1,321 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Loops in Emacs Lisp) +[#]: via: (https://opensourceforu.com/2019/11/loops-in-emacs-lisp/) +[#]: author: (Shakthi Kannan https://opensourceforu.com/author/shakthi-kannan/) + +Loops in Emacs Lisp +====== + +[![][1]][2] + +_This article in the Emacs series explores looping techniques that are available with Emacs Lisp._ + +T here are built-in constructs such as _while_ and _dolist_ that are shipped with the default GNU Emacs. The dash.el library provides functions to iterate over lists, and is written by Magnar Sveen. The latest release of dash.el is v2.16.0, and its source code is available at __ under the GNU General Public License v3.0. +Let us also explore the structures available in loop.el, another library for implementing imperative loops. This has been written by Wilfred Hughes, and has also been released under the GNU General Public License v3.0. + +**Installation** +The dash.el and loop.el packages are available in Milkypostman’s Emacs Lisp Package Archive (MELPA) and in the Marmalede repo. You can install the package using the following commands in GNU Emacs: + +``` +M-x package-install dash +M-x package-install loop +``` + +The other method of installation is to copy the dash.el and loop.el source files to your Emacs load path and load them. In order to get syntax highlighting of dash functions in Emacs buffers, you can add the following command to your Emacs initialisation settings: + +``` +(eval-after-load 'dash '(dash-enable-font-lock)) +``` + +If you are using Cask (__) to manage your Emacs configuration, then you can simply add the following code to your Cask file: + +``` +(depends-on "dash") +(depends-on "loop") +``` + +The usage of various loop construct is as follows. + +**Built-in** +GNU Emacs has built-in loop constructs. The _while_ function, for example, has the following syntax: + +``` +(while TEST BODY...) +``` + +The BODY code segment is evaluated if the result of TEST is not nil. Until TEST returns nil, the BODY will continue to be executed. An example of _while_ function usage is given below: + +``` +(setq alphabets '(a b c d e)) + +(defun print-list-elements (list) +"Print each element of the input LIST" +(while list +(print (car list)) +(setq list (cdr list)))) + +(print-list-elements alphabets) +``` + +The output is as follows: + +``` +a +b +c +d +e +nil +``` + +The ‘dolist’ macro loops over a list and is also built-in with Emacs. Its definition is as follows: + +``` +(dolist (VAR LIST [RESULT]) BODY...) +``` + +The VAR argument represents each element in LIST for every iteration in the BODY segment. The value in RESULT is returned by the function, and is optional. By default, a nil is returned. The ‘alphabet’ list elements can be printed using the _dolist_ macro as shown below: + +``` +(setq alphabets '(a b c d e)) +(dolist (element alphabets) +(print element)) +``` + +The resultant output is the same. + +``` +a +b +c +d +e +nil +``` + +**dash.el** +The dash.el list library provides functions to iterate over lists. The -each function, for example, takes a list and a function, and applies the function to every element in the list. In the following example, a reverse of the input list is created by doubling each element’s value. + +``` +(-each list function) ;; Syntax + +(let (s) (-each '(1 2 3) (lambda (item) (setq s (cons (* item 2) s)))) s) +(6 4 2) +``` + +Another function API from the dash.el library is the -each-while function, which takes three arguments – a list, a predicate and a function. The function is applied to every element in the list that satisfies the predicate. For example: + +``` +(-each-while list predicate function) ;; Syntax + +(defun even? (num) (= 0 (% num 2))) +(let (s) (--each-while '(1 2 3 4) (< it 3) (!cons it s)) s) +(2 1) +``` + +The _-each-r_ function takes a list and a function, and applies the function on every item in the list in the reverse order. An example is given below: + +``` +(-each-r list function) ;; Syntax + +(let (s) (-each-r '(1 2 3) (lambda (item) (setq s (cons (* item 2) s)))) s) + +(2 4 6) +``` + +If you would like to use a predicate function with _-each-r_, you can use the _-each-r-while_ function as illustrated below: + +``` +(-each-r-while list predicate function) ;; Syntax + +(let (s) (-each-r-while '(1 2 3 4 5 6) 'even? (lambda (item) (!cons item s))) s) +(6) +``` + +The _-dotimes_ function will repeatedly call a function from 0 to the input number, minus 1. + +``` +(-dotimes number function) ;; Syntax + +(let (s) (-dotimes 3 (lambda (n) (!cons n s))) s) +(2 1 0) +``` + +You can explore more of the iterative functions available in dash.el under the Side-effects section in the GitHub source repository available at __. + +**loop.el** +We shall now explore the constructs available in the _loop.el_ library. The loop-while construct executes the body of the loop while the condition is true. In the following example, the sum of the numbers from 0 to 5 is computed. + +``` +(require 'loop) + +;; loop-while +loop-while (condition body...) ;; Syntax + +(let ((x 0) +(sum 0)) +;; sum of 0..5 +(loop-while (< x 5) +(setq sum (+ sum x)) +(setq x (1+ x))) +sum) +10 +``` + +If you want to evaluate the body at least once before checking the condition, you can use the _loop-do-while_ construct. In the following example, the value of x is incremented by one and then the condition is satisfied for the loop execution. + +``` +loop-do-while (condition body...) ;; Syntax + +(let ((x 0) +(sum 0)) +;; sum of 1..4 +(loop-do-while (and (> x 0) (< x 5)) +(setq sum (+ sum x)) +(setq x (1+ x))) +sum) +10 +``` + +The _loop-until_ construct repeatedly evaluates the body of the code until the condition becomes true. For example: + +``` +loop-until (condition body...) ;; Syntax + +(let ((x 0) +(sum 0)) +;; sum of 0..4 +(loop-until (= x 5) +(setq sum (+ sum x)) +(setq x (1+ x))) +sum) +10 +``` + +The _loop-for-each_ construct takes three arguments – a var, a list and a body. The var represents an element in the list for the iteration. In the following example, the sum of numbers from 1 to 5 is calculated. + +``` +loop-for-each (var list body...) ;; Syntax + +(let ((sum 0)) +(loop-for-each x (list 1 2 3 4 5) +(setq sum (+ sum x))) +sum) +15 +``` + +A couple of constructs are available to break or continue execution within a loop. The _loop-break_ construct breaks out of the innermost loop. For example: + +``` +loop-break () ;; Syntax + +(let ((sum 0)) +;; sum 1..5 +(loop-for-each x (list 1 2 3 4 5 6) +(setq sum (+ sum x)) +(when (= x 5) +(loop-break))) +sum) +15 +``` + +The _loop-continue_ construct will skip the rest of the current loop-while, loop-do-while or loop-for-each block and will proceed to the next iteration in the loop. In the following example, the list is iterated for elements between 1 and 6, and is skipped when the iteration matches the element 2. + +``` +loop-continue () ;; Syntax + +(let ((sum 0)) +;; sum the numbers 1, 3, 5 +(loop-for-each x (list 1 2 3 4 5 6) +(when (= x 2) +(loop-continue)) +(setq sum (+ sum x))) +sum) +19 +``` + +The loop.el library has unit tests included in the source code, which you can run to validate the defined constructs. In order to run the tests, you need to first clone the source repository using the following commands: + +``` +$ git clone https://github.com/Wilfred/loop.el +Cloning into 'loop.el'... +remote: Enumerating objects: 232, done. +remote: Total 232 (delta 0), reused 0 (delta 0), pack-reused 232 +Receiving objects: 100% (232/232), 31.29 KiB | 801.00 KiB/s, done. +Resolving deltas: 100% (117/117), done. +``` + +If you do not have Cask, install it using the instructions provided in the README file at __. +You can then change the directory into the cloned loop.el folder, and run cask install. This will locally install the required dependencies for running the tests. + +``` +$ cd loop.el/ +$ cask install +Loading package information... Select coding system (default utf-8): +done +Package operations: 3 installs, 0 removals +- Installing [ 1/3] undercover (latest)... done +- Installing [ 2/3] ert-runner (latest)... done +- Installing [ 3/3] f (latest)... already present +``` + +A _Makefile_ exists in the top-level directory, the contents of which are provided below for reference: + +``` +$ cat Makefile +CASK ?= cask +EMACS ?= emacs + +all: test +test: unit + +unit: +${CASK} exec ert-runner + +install: +${CASK} install +``` + +You can now simply run _make_ test at the shell prompt to execute the tests as shown below: + +``` +$ make test +cask exec ert-runner +................. + +Ran 17 tests in 0.001 seconds +``` + +Readers are encouraged to go through the README file at for more information. + +![Avatar][3] + +[Shakthi Kannan][4] + +The author is a free software developer at the Fedora project, and also a blogger. He co-maintains the Fedora Electronic Lab project. + +[![][5]][6] + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/loops-in-emacs-lisp/ + +作者:[Shakthi Kannan][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://opensourceforu.com/author/shakthi-kannan/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/01/Tips-to-hire-a-web-developer-with-skills-in-2019.jpg?resize=696%2C365&ssl=1 (Tips to hire a web developer with skills in 2019) +[2]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/01/Tips-to-hire-a-web-developer-with-skills-in-2019.jpg?fit=1200%2C630&ssl=1 +[3]: https://secure.gravatar.com/avatar/d6df0aa46ea197a6e5a6b80bba666830?s=100&r=g +[4]: https://opensourceforu.com/author/shakthi-kannan/ +[5]: https://opensourceforu.com/wp-content/uploads/2019/11/assoc.png +[6]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/sources/tech/20191119 Top 10 Vim plugins for programming in multiple languages.md b/sources/tech/20191119 Top 10 Vim plugins for programming in multiple languages.md new file mode 100644 index 0000000000..26a719c8fd --- /dev/null +++ b/sources/tech/20191119 Top 10 Vim plugins for programming in multiple languages.md @@ -0,0 +1,138 @@ +[#]: collector: (lujun9972) +[#]: translator: (hello-wn) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Top 10 Vim plugins for programming in multiple languages) +[#]: via: (https://opensource.com/article/19/11/vim-plugins) +[#]: author: (Maxim Burgerhout https://opensource.com/users/wzzrd) + +Top 10 Vim plugins for programming in multiple languages +====== +Make your life as a programmer or sysadmin a little better with these 10 +plugins for Vim. +![OpenStack source code \(Python\) in VIM][1] + +I've been a user of the [Vim][2] text editor for about two decades. For a little while, I have been customizing my Vim configuration, only using plugins for the last couple of years. + +Recently, when I was redoing my setup (as I do every so often), I decided it was a good opportunity to identify the best Vim plugins for programming in multiple languages and a way to combine those plugins for each language I program in. + +I do use certain plugins for specific languages and profiles (e.g., I only install Rocannon in my Ansible profile), and I won't go into those here—that would be a _long_ list. But the 10 Vim plugins described below are my favorites, the ones I use in virtually every profile I have, no matter what programming language I'm using. + +### 1\. Volt + +My number one pick isn't even a plugin; rather, it replaces plugins like [Vundle][3], so I'm listing it here. + +[Volt][4] is a Vim plugin manager that lives outside Vim. You can use it to install plugins and create combinations of plugins called "profiles." You can enable a new profile with a single command: **volt profile set myprofile**. That way, I can do things like enable the [indentpython][5] plugin for just my Python profile. Volt also offers a simple way to do per-plugin configurations. The configuration is shared between profiles, so you can install plugins once and use them in multiple profiles. + +Volt is still relatively new and not perfect (e.g., you can have just one configuration file per plugin, no matter how many profiles you are using), but apart from that, I find it extremely handy, extremely fast, and extremely simple. + +![Volt plugin][6] + +### 2\. Vim-Rainbow + +Except for Python, virtually all major programming languages use brackets. Round ones, square ones, and curly ones. Often, they use multiple pairs of brackets, with one pair embedded in another. Figuring out which closing bracket belongs to what opening bracket can become difficult and annoying. I often find myself counting round brackets—especially in complicated Bash scripts—to make sure I got everything right. + +Here's the [vim-rainbow][7] plugin to the rescue! It gives every pair of brackets a unique color, so it's easy to identify which brackets belong to each other. It's very useful and very colorful, too. + +![vim-rainbow plugin][8] + +### 3\. lightline + +There are a lot of plugins for Vim, such as [Powerline][9], that put a bar at the bottom of the screen to show you what file you are working on, where you are in the file, what type of file it is, etc. Each of these plugins has advantages and disadvantages, and after briefly weighing them, I chose [lightline][10]. It's relatively small, easy to set up, quite extensible if you are into that kind of thing, and doesn't require any other tooling or plugins. + +![Lightline plugin][11] + +### 4\. NERDTree + +[NERDTree][12] is a classic. In large projects, it can be hard to find the exact name and location of the one file that includes the one line you need to edit. With a quick keystroke (**F7**, in my case, as I bound NERDTree to F7 in my .vimrc configuration file), an explorer window opens in a vertical split, and I can easily browse to the file I want and open it. It's a must for large bodies of code. Or for people that tend to forget filenames, like me. + +![NERDTree vim plugin][13] + +### 5\. NERD Commenter + +All programmers, at some time, write code that introduces a hard-to-debug problem that leads them to decide to comment out or undo the code. This is where [NERD Commenter][14] comes in. Select the code, hit **Leader+cc**, and your code is commented. (The standard Vim Leader key is the **/** character.) Hit **Leader+cn,** and your code is uncommented. NERD Commenter should automatically use the right commenting character for most file types. For example, if you are editing a [BIND zone file][15] and set the file type to bind zone, Vim will correctly use the **;** (semicolon) character to comment lines out. + +![NERD Commenter][16] + +### 6\. Solarized + +I love my Vim colors. Really, I love terminal colors in general. I've been using the [Solarized][17] color scheme for Vim for a long time, and I set up my terminal, dir_colors, and Vim to be consistent. + +Every now and then, though, I toggle between light and dark modes, depending on what kind of environment I'm in, the amount of light falling on my screen, and whether I need to put something on a big screen for others to read. + +Obviously, you can grab any ol' color scheme you like, but I like the fact that Solarized has light and dark modes, an easy way to switch between the two, and it's not too intrusive. My second choice is [Monokai][18]. The Volt plugin manager makes it easy for me to switch between the two, so I can use Monokai for Python programming and Solarized for Bash. + +I'm not including an image for Solarized, because all the other images in this article use Solarized light or dark, so check them out. + +### 7\. fzf + +When you're looking for a file, sometimes you want a file explorer, and sometimes you just want to ram something on your keyboard that vaguely resembles the filename you are looking for, amirite? + +The [fzf][19] (or "fuzzy finder") plugin gives you just that. Hit **:FZF** and start typing. An ever-shortening list will show you files that more or less match what you are looking for. I use this a lot, probably even more than NERDTree these days. A slight downside is that this plugin has an external dependency in the fzf binary, so you'll have to install that, too. It's available for Fedora, Debian and, Arch, but I don't think it exists for EPEL. + +![fzf Vim plugin][20] + +### 8\. ack + +Every once in a while, you want to search for a file that contains a certain line or a certain word. I really like the [ack][21] plugin for this, preferably in combination with **ag**, a command known as "the [silver searcher][22]." This combination is phenomenally fast and covers the vast majority of things I would use **grep** or **vimgrep** for. The downside is you'll need to install either ack or ag for it to work. The good news is that both ag and ack are available for Fedora and EPEL7. + +![ack vim plugin][23] + +### 9\. gitgutter + +The majority of IT folks have worked with [Git][24] and files in Git repositories. The [gitgutter][25] plugin adds a column near your line numbers that shows symbols for changed (**~**), added (**+**), and removed (**-**) lines. This is quite useful for keeping track of what you have changed, and it keeps you focused on the task at hand, like writing a patch to fix one key bug. This plugin has a slight performance gap, and it sometimes takes a quick second for the plugin to catch up with your changes, but it's still quite useful. + +![gitgutter vim plugin][26] + +### 10\. Tag List + +If you are programming in a file of any significant size, it's easy to lose track of where you are, and you might find yourself scrolling up and down looking for a certain function. With the [Tag List][27] plugin, you can just type **:Tlist** and get a vertical split with variables, types, classes, and functions that you can easily jump to. This works for a host of languages, like Java, Python, and any other file type the **ctags** utility works with … which is a lot. + +![Tag List vim plugin][28] + +So there you are: the 10 plugins for Vim that have made my life as a sysadmin and part-time programmer a little easier and a little better. What Vim plugins you are using? Please share your favorites in the comments. + +Vim offers great benefits to writers, regardless of whether they are technically minded or not. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/vim-plugins + +作者:[Maxim Burgerhout][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/wzzrd +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openstack_python_vim_1.jpg?itok=lHQK5zpm (OpenStack source code (Python) in VIM) +[2]: https://www.vim.org/ +[3]: https://github.com/VundleVim/Vundle.vim +[4]: https://github.com/vim-volt/volt +[5]: https://github.com/vim-scripts/indentpython.vim +[6]: https://opensource.com/sites/default/files/uploads/vim-volt.gif (Volt plugin) +[7]: http://github.com/frazrepo/vim-rainbow +[8]: https://opensource.com/sites/default/files/uploads/vim-rainbox.png (vim-rainbow plugin) +[9]: https://github.com/powerline/powerline +[10]: http://github.com/itchyny/lightline.vim +[11]: https://opensource.com/sites/default/files/uploads/lightline.png (Lightline plugin) +[12]: http://github.com/scrooloose/nerdtree +[13]: https://opensource.com/sites/default/files/uploads/nerdtree.gif (NERDTree vim plugin) +[14]: http://github.com/scrooloose/nerdcommenter +[15]: https://en.wikipedia.org/wiki/Zone_file#File_format +[16]: https://opensource.com/sites/default/files/uploads/nerdcommenter.gif (NERD Commenter) +[17]: https://github.com/altercation/vim-colors-solarized +[18]: https://github.com/sickill/vim-monokai +[19]: https://github.com/junegunn/fzf.vim +[20]: https://opensource.com/sites/default/files/uploads/fzf.gif (fzf Vim plugin) +[21]: https://github.com/mileszs/ack.vim +[22]: https://github.com/ggreer/the_silver_searcher +[23]: https://opensource.com/sites/default/files/uploads/ack.gif (ack vim plugin) +[24]: https://opensource.com/resources/what-is-git +[25]: https://github.com/airblade/vim-gitgutter +[26]: https://opensource.com/sites/default/files/uploads/gitgutter.png (gitgutter vim plugin) +[27]: https://github.com/vim-scripts/taglist.vim +[28]: https://opensource.com/sites/default/files/uploads/taglist.gif (Tag List vim plugin) diff --git a/sources/tech/20191119 What is a community of practice in an open organization.md b/sources/tech/20191119 What is a community of practice in an open organization.md new file mode 100644 index 0000000000..65e9ce464c --- /dev/null +++ b/sources/tech/20191119 What is a community of practice in an open organization.md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What is a community of practice in an open organization?) +[#]: via: (https://opensource.com/open-organization/19/11/what-is-community-practice) +[#]: author: (Tracy Buckner https://opensource.com/users/tracyb) + +What is a community of practice in an open organization? +====== +If organizational silos are slowing your teams down, consider building +communities of practice to supercharge collaboration. +![Open community, gardeners and food co-op][1] + +Community is a fundamental component of open organizations. The [Open Organization Definition][2] notes that: + +> Shared values and purpose guide participation in open organizations, and these values—more so than arbitrary geographical locations or hierarchical positions—help determine the organization's boundaries and conditions of participation. + +In other words, people in open organizations often define their roles, responsibilities, and affiliations through shared interests and passions—not title, role, or position on an organizational chart. + +That means organizational leaders will find themselves invested in building communities inside their organizations, connecting like-minded people with one another to accelerate business objectives. + +For this reason, communities of practice can be a useful component of open organizations. In this three-part series, I'll explain what communities of practice are, why they are beneficial to an organization, and how you can start a community of practice.  + +### Community at the core + +Community has always been central to organizations built on open principles. In fact, [The Open Source Way][3] explains community as: + +> … the group of people who form intentionally and spontaneously around something important to them. It includes the people who use or benefit from the project, those who participate and share the project to wider audiences, and the contributors who are essential to growth and survival. + +This definition informs our vision for communities of practice (CoPs) at Red Hat. + +In 1991, cognitive anthropologists [Jean Lave][4] and [Etienne Wenger][5] first coined the term "community of practice" while studying group learning. They defined it as “a group of people who share an interest, a craft, and/or a profession.” Communities of practice have been around since the beginning of civilization. Groups of people have come together telling stories, imparting wisdom, and passing on tradition. Any group of people can form a CoP—a group of teachers exploring a new topic, for example, or architects discussing a typical customer problem and identifying a resolution. + +Not all groups are communities of practice. A CoP must have a shared domain of interest, practitioners who share resources (tools, techniques, and ideas), and community members. A CoP forms at the intersection of those factors (see Figure 1). + +![][6] + +### Domain + +A community of practice is defined by a shared _domain_ of interest. It's not merely a group of friends hanging out together; members have a commitment to the success of the domain and a desire to share their knowledge. They value use cases, success stories, feedback, and learning from the other members. + +### Practice  + +A community of practice is not simply a group of people who like the same things (such as certain kinds of music). Members of CoPs are _practitioners_ who engage in shared activities, share resources, tools, techniques, and ideas. Together they develop ways of addressing problems in new ways. Members value interactions and seek knowledge from each other. Many often become thought leaders and experts in the domain. + +### Members + +Not all groups are communities of practice. A CoP must have a shared domain of interest, practitioners who share resources (tools, techniques, and ideas), and community members. + +Community of practice _members_ engage in joint activities and discussions, assist each other, and share their knowledge. They build relationships that enable them to learn from each other; they care about their standing with each other. Members of a community of practice participate regularly but do not necessarily work together on a daily basis.  + +[Wenger][7] suggests several characteristics and potential activities of communities of practice, including: + + * Problem-solving + * Making recommendations + * Sharing experiences + * Hosting community forums + * Developing shared measurement tools + * Building an argument for a policy campaign + * Growing confidence and encouraging representatives to speak out + * Discussing developments in communities and solutions to challenges + * Documenting data needed to move communities forward + * Coordinating visits to participants' sites to learn more about different approaches and perspectives + * Mapping knowledge and identifying gaps + + + +Communities of practice can form inside and across roles and departments in an open organization. When they do, they can help dissolve organizational silos by providing safe spaces for practitioners to come together as a community and work on a domain the members enjoy. + +Together, members can solve current problems—and innovative on new products and solutions. Communities of practice also provide an opportunity to learn from the interaction and open communication in the group. Members mentor and encourage each other to learn more and do more within the community. CoPs provide a place to begin personal branding and to find the confidence to reach out for other thought leadership activities. + +Communities of practice drawn together domain, practice, and members to provide benefits for both the members and the organization. They are a cost-effective way to enhance learning, reduce silos, and promote innovation. And as [Wegner][7] said, “We need others to complement and develop our own expertise.” + +In the next article in this series, we will discuss the benefits of a CoP in an organization. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/19/11/what-is-community-practice + +作者:[Tracy Buckner][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/tracyb +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/open_community_lead.jpg?itok=F9KKLI7x (Open community, gardeners and food co-op) +[2]: https://opensource.com/open-organization/resources/open-org-definition +[3]: http://www.theopensourceway.org/book/index.html +[4]: http://en.wikipedia.org/wiki/Jean_Lave +[5]: http://en.wikipedia.org/wiki/Etienne_Wenger +[6]: https://opensource.com/sites/default/files/resize/images/open-org/cop_figure1-500x460.png +[7]: https://wenger-trayner.com/wp-content/uploads/2015/04/07-Brief-introduction-to-communities-of-practice.pdf diff --git a/sources/tech/20191120 Set up single sign-on for Fedora Project services.md b/sources/tech/20191120 Set up single sign-on for Fedora Project services.md new file mode 100644 index 0000000000..e580b1dd21 --- /dev/null +++ b/sources/tech/20191120 Set up single sign-on for Fedora Project services.md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Set up single sign-on for Fedora Project services) +[#]: via: (https://fedoramagazine.org/set-up-single-sign-on-for-fedora-project-services/) +[#]: author: (Stephen Gallagher https://fedoramagazine.org/author/sgallagh/) + +Set up single sign-on for Fedora Project services +====== + +![][1] + +In addition to an operating system, the Fedora Project provides [services][2] for users and developers. Services such as [Ask Fedora][3], the [Fedora Project wiki][4] and the [Fedora Project mailing lists][5] help users [learn][6] how to best take advantage of Fedora. For developers of Fedora, there are many other services such as [dist-git][7], [Pagure][8], [Bodhi][9], [COPR][10] and [Bugzilla][11] for the packaging and release process. + +These services are available with a free account from the [Fedora Accounts System][12] (FAS). This account is the passport to all things Fedora! This article covers how to get set up with an account and configure [Fedora Workstation][13] for browser single sign-on. + +### Signing up for a Fedora account + +To create a FAS account, browse to the [account creation page][14]. Here, you will fill out your basic identity data: + +![Account creation page][15] + +Once you enter your data, the account system sends an email to the address you provided, with a temporary password. Pick a strong password and use it. + +![Password reset page][16] + +Next, the account details page appears. If you want to contribute to the Fedora Project, you should complete the [Contributor Agreement][17] now. Otherwise, you are done and you can use your account to log into the various Fedora services. + +![Account details page][18] + +### Configuring Fedora Workstation for single sign-On + +Now that you have your account, you can sign into any of the Fedora Project services. Most of these services support single sign-on (SSO), so you can sign in without re-entering your username and password. + +Fedora Workstation provides an easy workflow to add your Fedora credentials. The GNOME Online Accounts tool helps you quickly set up your system to access many popular services. To access it, go to the _Settings_ menu. + +![][19] + +Click on the option labeled _Fedora_. A prompt opens for you to provide your username and password for your Fedora Account. + +![][20] + +GNOME Online Accounts stores your password in [GNOME Keyring][21] and automatically acquires your single-sign-on credentials for you when you log in. + +### Single sign-on with a web browser + +Today, Fedora Workstation supports three web browsers out of the box with support for single sign-on with the Fedora Project services. These are [Mozilla Firefox][22], [GNOME Web][23], and [Google Chrome][24]. + +Due to a [bug][25] in Chromium, single sign-on doesn’t work currently if you have more than one set of Kerberos (SSO) credentials active on your session. As a result, Fedora doesn’t enable this function out of the box for Chromium in Fedora. + +To sign on to a service, browse to it and select the _login_ option for that service. For most Fedora services, this is all you need to do; the browser handles the rest. Some services such as the [Fedora mailing lists][26] and [Bugzilla][11] support multiple login types. For them, select the _Fedora_ or _Fedora Account System_ login type. + +That’s it! You can now log into any of the Fedora Project services without re-entering your password. + +##### Special consideration for Google Chrome + +To enable single sign-on out of the box for Google Chrome, Fedora takes advantage of certain features in Chrome that are intended for use in “managed” environments. A managed environment is traditionally a corporate or other organization that sets certain security and/or monitoring requirements on the browser. + +Recently, Google Chrome changed its behavior and it now reports _Managed by your organization_ or possibly _Managed by fedoraproject.org_ under the ⋮ menu in Google Chrome. That [link][27] leads to a page that says, “If your Chrome browser is managed, your administrator can set up or restrict certain features, install extensions, monitor activity, and control how you use Chrome.” However, **[Fedora will never monitor your browser activity or restrict your actions][28].** + +Enter _chrome://policy_ in the address bar to see exactly what settings Fedora has enabled in the browser. The _AuthNegotiateDelegateWhitelist_ and _AuthServerWhitelist_ options will be set to _*.fedoraproject.or_g. These are the only changes Fedora makes. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/set-up-single-sign-on-for-fedora-project-services/ + +作者:[Stephen Gallagher][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/sgallagh/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/05/sso-fedora-web-services-816x345.jpg +[2]: https://apps.fedoraproject.org/ +[3]: https://ask.fedoraproject.org/ +[4]: https://fedoraproject.org/wiki/Fedora_Project_Wiki +[5]: https://lists.fedoraproject.org/archives/ +[6]: https://fedoramagazine.org/check-out-the-new-askfedora/ +[7]: http://src.fedoraproject.org/ +[8]: https://pagure.io +[9]: https://bodhi.fedoraproject.org +[10]: https://copr.fedorainfracloud.org/ +[11]: https://bugzilla.redhat.com +[12]: https://admin.fedoraproject.org/accounts +[13]: https://getfedora.org/ +[14]: https://admin.fedoraproject.org/accounts/user/new +[15]: https://fedoramagazine.org/wp-content/uploads/2019/05/FAS-new.png +[16]: https://fedoramagazine.org/wp-content/uploads/2019/05/changepass-1024x318.png +[17]: https://admin.fedoraproject.org/accounts/fpca/ +[18]: https://fedoramagazine.org/wp-content/uploads/2019/05/account-blurred.png +[19]: https://fedoramagazine.org/wp-content/uploads/2019/09/goa-toplevel.png +[20]: https://fedoramagazine.org/wp-content/uploads/2019/09/goa-fedora-creds.png +[21]: https://wiki.gnome.org/Projects/GnomeKeyring +[22]: https://www.mozilla.org/en-US/firefox +[23]: https://wiki.gnome.org/Apps/Web +[24]: https://www.google.com/chrome/ +[25]: https://bugzilla.redhat.com/show_bug.cgi?id=1640158 +[26]: https://lists.fedoraproject.org +[27]: https://support.google.com/chrome/answer/9281740 +[28]: https://fedoraproject.org/wiki/Legal:PrivacyPolicy diff --git a/sources/tech/20191120 Switching from Python 2 to Python 3- What you need to know.md b/sources/tech/20191120 Switching from Python 2 to Python 3- What you need to know.md new file mode 100644 index 0000000000..fe5115256e --- /dev/null +++ b/sources/tech/20191120 Switching from Python 2 to Python 3- What you need to know.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Switching from Python 2 to Python 3: What you need to know) +[#]: via: (https://opensource.com/article/19/11/end-of-life-python-2) +[#]: author: (Katie McLaughlin https://opensource.com/users/glasnt) + +Switching from Python 2 to Python 3: What you need to know +====== +Python 2 will reach its end of life in mere weeks. Here's what to know +before you migrate to Python 3. +![A sunrise][1] + +Python 2.7 will officially become unsupported beginning January 1, 2020. There is one [final bugfix][2] planned after this date, but then that's it. + +What does this end of life (EOL) mean for you? If you run Python 2, you need to migrate. + +### Who decided to EOL Python 2? + +In [2012][3], the team maintaining the Python programming language reviewed its options. There were two increasingly different codebases, Python 2 and Python 3. Both were popular, but the newer version was not as widely adopted. + +In addition to Python 3's disruption of changing the underlying way data is handled by completely reworking Unicode support, a major version change allowed non-backward-compatible changes to happen all at once. This decision was documented [in 2006][4]. To ease the disruption, Python 2 continued to be maintained, with some features backported. To further help the community transition, the EOL date was extended [from 2015 to 2020][5], another five years. + +Maintaining divergent codebases was a hassle the team knew it had to resolve. Ultimately, a decision was [announced][6]: + +> "We are volunteers who make and take care of the Python programming language. We have decided that January 1, 2020, will be the day that we sunset Python 2. That means that we will not improve it anymore after that day, even if someone finds a security problem in it. You should upgrade to Python 3 as soon as you can." + +[Nick Coghlan][7], a core CPython developer and current member of the Python steering council, [adds more information in his blog][8]. And [PEP 404][9], written by [Barry Warsaw][10] (also a member of the Python steering council), details why Python 2.8 will never be a thing. + +### Is anyone still supporting Python 2? + +Support for Python 2 from providers and vendors will vary. [Google Cloud has announced][11] how it plans to support Python 2 going forward. Red Hat has also [announced plans for Red Hat Enterprise Linux (RHEL)][12], and AWS has announced [minor version update requirements][13] for the AWS command-line interface and [SDK][14]. + +You can also read the Stack Overflow blog post "[Why is the Migration to Python 3 Taking So Long?][15]" by [Vicki Boykis][16], in which she identifies three reasons why Python 3 adoption is slow.  + +### Reasons to use Python 3 + +Regardless of ongoing support, it's a really good idea to migrate to Python 3 as soon as you can. Python 3 will continue to be supported, and it has some really neat things that Python 2 just doesn't have. + +The recently released [Python 3.8][17] includes such [features][18] as the [walrus operator][19], [positional-only parameters][20], and [self-documenting f-strings][21]. Earlier releases of Python 3 introduced [features][22] such as [asyncio][23], [f-strings][24], [type hints][25], and [pathlib][26], just to name a few. + +The top 360 most-downloaded packages [have already migrated to Python 3][27]. You can check your requirements.txt file using the [caniusepython3][28] package to see if any packages you depend on haven't yet been migrated. + +### Resources for porting Python 2 to Python 3 + +There are many resources available to ease your migration to Python 3. For example, the [Porting Python 2 to Python 3 guide][29] lists a bunch of tools and tricks to help you achieve single-source Python 2/3 compatibility. There are also some useful tips on [Python3statement.org][30]. + +[Dustin Ingram][31] and [Chris Wilcox][32] gave a [presentation at Cloud Next '19][33] detailing some of the motivations and migration patterns for the transition into Python 3. [Trey Hunner][34] gave a [presentation at PyCon 2018][35] about Python 3's most useful features to encourage you to migrate so you can take advantage of them. + +### Join us! + +January 1, 2020, is now just weeks away. If you need daily reminders of just how soon that is (and you use Twitter), follow the [Countdown to Python 2 sunset][36] Twitter bot. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/end-of-life-python-2 + +作者:[Katie McLaughlin][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/glasnt +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/govt_a%20new%20dawn.png?itok=b4zU-VAY (A sunrise) +[2]: https://www.python.org/dev/peps/pep-0373/#maintenance-releases +[3]: https://github.com/python/peps/commit/a733bc927acbca16bfa3de486fb2c7d3f767a748 +[4]: https://www.python.org/dev/peps/pep-3000/#compatibility-and-transition +[5]: https://github.com/python/peps/commit/f82462002b86feff36215b4230be28967039b0cc +[6]: https://www.python.org/doc/sunset-python-2/ +[7]: https://twitter.com/ncoghlan_dev +[8]: http://python-notes.curiousefficiency.org/en/latest/python3/questions_and_answers.html +[9]: https://www.python.org/dev/peps/pep-0404/ +[10]: https://twitter.com/pumpichank +[11]: https://cloud.google.com/python/docs/python2-sunset/?utm_source=osdc&utm_medium=blog&utm_campaign=pysunset +[12]: https://access.redhat.com/solutions/4455511 +[13]: https://aws.amazon.com/blogs/developer/deprecation-of-python-2-6-and-python-3-3-in-botocore-boto3-and-the-aws-cli/ +[14]: https://aws.amazon.com/sdk-for-python/ +[15]: https://stackoverflow.blog/2019/11/14/why-is-the-migration-to-python-3-taking-so-long/ +[16]: https://twitter.com/vboykis +[17]: https://www.python.org/downloads/ +[18]: https://docs.python.org/3.8/whatsnew/3.8.html +[19]: https://docs.python.org/3.8/whatsnew/3.8.html#assignment-expressions +[20]: https://docs.python.org/3.8/whatsnew/3.8.html#positional-only-parameters +[21]: https://docs.python.org/3.8/whatsnew/3.8.html#f-strings-support-for-self-documenting-expressions-and-debugging +[22]: https://docs.python.org/3.8/whatsnew/index.html +[23]: https://docs.python.org/3.8/library/asyncio.html#module-asyncio +[24]: https://docs.python.org/3.7/whatsnew/3.6.html#pep-498-formatted-string-literals +[25]: https://docs.python.org/3.7/whatsnew/3.5.html#pep-484-type-hints +[26]: https://docs.python.org/3.8/library/pathlib.html#module-pathlib +[27]: http://py3readiness.org/ +[28]: https://pypi.org/project/caniusepython3/ +[29]: https://docs.python.org/3/howto/pyporting.html +[30]: https://python3statement.org/practicalities/ +[31]: https://twitter.com/di_codes +[32]: https://twitter.com/chriswilcox47 +[33]: https://www.youtube.com/watch?v=Bye7Rms0Vgw&utm_source=osdc&utm_medium=blog&utm_campaign=pysunset +[34]: https://twitter.com/treyhunner +[35]: https://www.youtube.com/watch?v=klaGx9Q_SOA +[36]: https://twitter.com/python2sunset diff --git a/sources/tech/20191120 Tools that Accelerate a Newbie-s Understanding of Machine Learning.md b/sources/tech/20191120 Tools that Accelerate a Newbie-s Understanding of Machine Learning.md new file mode 100644 index 0000000000..0b41f3e7f2 --- /dev/null +++ b/sources/tech/20191120 Tools that Accelerate a Newbie-s Understanding of Machine Learning.md @@ -0,0 +1,215 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Tools that Accelerate a Newbie’s Understanding of Machine Learning) +[#]: via: (https://opensourceforu.com/2019/11/tools-that-accelerate-a-newbies-understanding-of-machine-learning/) +[#]: author: (Jatin Karthik Tripathy https://opensourceforu.com/author/jatin-tripathy/) + +Tools that Accelerate a Newbie’s Understanding of Machine Learning +====== + +[![][1]][2] + +_The world of machine learning (ML) and deep learning (DL) is a fascinating one. Many newbies would like to dabble in this field but have some inhibitions. This article introduces readers to some of the best tools to kickstart their journey into the ML/ DL domain._ + +Machine learning is a term that is applied to a broad range of topics which have one thing in common – the use of algorithms and other statistical models to improve the performance of a particular task. All machine learning (ML) models are used to build a mathematical model of the data provided, to help the user predict or make decisions with a very high level of accuracy; thereby considerably reducing the strain of manually sifting through the data. Currently, there are several fields in which ML is used extensively, from filtering out emails and computer vision, to choosing a smart assistant. Readers are urged to spend some time researching only the topics that they are interested in and not get overwhelmed or distracted by the countless other applications of ML. + +Deep learning can be considered a subset of machine learning, though to call it that really does not do it justice. Currently, most applications have moved on from the somewhat old fashioned ML algorithms to employ deep learning (DL) algorithms. The latter provide much more support for the building of more complex mathematical models which cannot be provided by ML. Deep learning algorithms employ multiple ML algorithms in a manner vaguely inspired by how the human brain works, and hence the term‘neural networks’. Deep learning algorithms have been developed to the point where it has been proved that computers can indeed be smarter than humans. + +![Figure 1: Creating a notebook][3] + +This article explores five of the most user-friendly, highly scaleable ML libraries/tools available. These are: + + * Scikit-learn + * OpenCV + * TensorFlow + * Keras + * Google Colaboratory + + + +Some of you may be familiar with a couple of these libraries and even know how to use them. This is not meant to be an in-depth tutorial for any of these tools. The idea is that, hopefully, by the end of this article, readers will discover which of the five libraries featured, interests them enough to read further on the topic. + +**Scikit-learn** +The founders of Scikit-learn started off by trying to find answers to simple problems. I believe that any aspirant must follow the pioneer’s footsteps. Scikit-learn is a free library written for Python which lets users do exactly that. It operates using Python’s NumPy and SciPy libraries to achieve multiple aspects of machine learning with ease, such as various algorithms for classification, regression and clustering. It lets the user easily step into the world of artificial intelligence (AI) without making them feel that they’ve taken too big a leap. With its easy-to-use libraries, you can easily incorporate any of the above ML algorithms into your code. While Scikit-learn is essentially for older ML algorithms, beginners will have their hands full trying to implement various algorithms to see how they affect a particular use case. +This library is largely implemented in Python with some parts of it written in Cython, thus restricting its usage to how much Python you know. Python, incidentally, has a tremendous collection of libraries and third party APIs. + +The advantage of starting off with Scikit-learn is that most programmers with similar aspirations have also started off along the same path. There is huge support for Scikit-learn with the entire code written using the Scikit-learn library, making the learning process fairly simple. It also helps that the official documentation of Scikit-learn is one of the more refined and well written. So, most of your doubts will probably get clarified by just going through the documentation. +To start off with Scikit Learn, just follow the instructions available at the official site, at __. + +![Figure 2: Accessing notebook settings][4] + +**OpenCV** +OpenCV is a cross platform library that lets the user tackle any kind of real-time computer vision. + +**Note:** _Computer vision is a field of computer science that deals with how computers can be made to acquire a high level knowledge from photos or videos. It includes the tasks of acquiring, processing, analysing and understanding the data._ + +OpenCV has a wide range of applications, starting with simple algorithms that deal with 2D images, all the way up to augmented reality, motion tracking, etc. OpenCV is not as user-friendly as Scikit-learn, yet, with a little time anyone can easily understand the flow of things – well enough to use OpenCV to its maximum extent. OpenCV, unlike Scikit-learn, is mostly written in C/C++ and is a cross platform library. This means that the users can truly optimise their code by using lower level and complied languages such as C/C++ or Java. OpenCV also includes a statistical ML library with which it can stand alone to some extent. OpenCV also has integrations with leading DL frameworks such as TensorFlow and Torch/PyTorch, making it a very versatile tool which can be used even if the provided ML library does not meet the user’s demands. + +One of the notable things about OpenCV is that it supports hardware acceleration in three different cases, namely: + + * Intel’s Integrated Performance Primitives + * A CUDA based GPU interface + * An OpenCL based GPU interface + + + +The fact that OpenCV can use hardware acceleration means that the user can easily increase the performance of the code with simple modifications, thereby resulting in smoother real-time applications due to faster code execution. + +**Note:** _It is advisable to use hardware accelerations that are mathematically intensive to perform, else there is a chance of a drop in performance due to the time it takes to shift resources to the GPU from the CPU._ + +Detailed installation instructions for OpenCV are available from the official documentation for the Python programming language at _ py_setup/py_setup_in_windows/py_setup_in_windows.html_. Other installations can also be found in the documentation. + +**TensorFlow** +TensorFlow is an open source library which tackles data flow programming across a range of applications, from a symbolical mathematical library to the core library in neural network programming. Developed by the Google Brain team for the search giant’s internal use, today it is used within the firm for purposes ranging from research to production. + +**Note:** _The TensorFlow library is so named because it operates on multi-dimensional data arrays called tensors, whilst performing calculations for neural networks._ + +Unlike the earlier libraries, TensorFlow has been streamlined to make neural networks and is optimised for DL applications. TensorFlow is best at data crunching at a scale where data can be realistically processed using any other older technique. You can do all this while keeping the usage so simple, that, any devoted Python user will feel right at home with the line-by-line implementation of the neural network, allowing the user to easily implement high level concepts that involve a huge amount of mathematical theory behind them, with the call of a single function. This allows the user to quickly create a neural model and focus on refining it rather than worry about the mathematics behind it, making for faster prototyping. + +Like OpenCV, TensorFlow is not restricted to Python but supports other languages. Support ranges from having direct support to having third party APIs taking care of that. TensorFlow has a very flexible architecture system that allows it to be used in various devices, whether it is CPUs, GPUs or even TPUs (tensor processing units), as well as clustered servers or even handheld devices such as mobile phones. This allows TensorFlow to have a hardware acceleration capability that is unrivalled by most other libraries. + +**Note:** _Keras is a pure Python library unlike TensorFlow_ + +TensorFlow can take code to the browser with the use of TensorFlow.js, making DL projects lightweight and easily scaleable. TensorFlow Lite, which was built for using TensorFlow, specifically for Android development (beginning from Android Oreo) is even lighter. It has a wide reach. There are several applications of this library for different use cases, from being the foundation of some new technologies such as Deep Dream, an automated image captioning software, to being the core in many users’neural network projects. While it can be applied for a great many things, getting started off is not that hard. TensorFlow has huge support online with no lack of example code to go through before you tackle your first project. + +You can begin your TensorFlow journey by getting the Python library at _. org/install/_ and if you have a GPU that meets CUDA requirements, you can even optimise your execution using hardware acceleration. + +![Figure 3: Hardware accelerator][5] + +**Keras** +Keras is an open source Python library which runs on top of other Python libraries such as TensorFlow, Microsoft Cognitive Toolkit, or Theano. Keras focuses on being more user-friendly, modular and extensible compared to the libraries that it runs on top of. +Keras has official support from Google’s TensorFlow team (for the TensorFlow core library), allowing users to quickly build their code using the numerous implementations of commonly used neural networks methods already predefined in the Keras package. Like TensorFlow, Keras also supports hardware acceleration by the use of GPUs or TPUs, allowing the user far easier coding in almost the same execution time. + +Unlike the other tools mentioned in our list, Keras is not a standalone library. Rather, it acts as a high-level API to other libraries that require comparatively more complex ways of coding. This allows users to achieve far more rapid prototyping with their code. As a trade-off for this level of user-friendly Python coding, you lose some level of control over your code. For example, in Keras, while you do have considerable control over your network, any of the lower level packages that implement Keras will control the finer things of the network. + +This might lead you to wonder, why one should even use Keras? The sole reason is that most of the time, while trying out new implementations of neural networks, that high level of control over the hyper parameters isn’t required. The trade-off obtained by dropping that functionality makes far more sense to any programmer who only wants to see how the network performs. You can think of Keras as a way of getting the feel of what you are trying to build before trying to optimise it at a much lower level so that your networks perform the best. Keras has one of the most user-friendly approaches to coding neural networks. For anyone who just wants to try out the latest advances in current technology, Keras will almost always meet such a user’s demands. One small shortcoming is that Keras is a pure Python library unlike TensorFlow. + +**Note:** _As of June 2019, Keras has officially been ported together with Tensorflow to bcome Tensorflow 2.0. This new version of Tensorflow cuts back on a lot of extras previously available, resulting in a more standardised approach of writing code using the Keras API. Tensorflow 2.0 is currently in beta stage, but it already implements a lot of the more commonly used features, so if you feel like foraging into the new and improved library, head over to: _ + +It is possible for one to transform Keras models from Python to lower level languages such as C/C++. +As an example of how easy it is to understand and use Keras as compared to TensorFlow, let us take a look at both these libraries when used for the same application – the classification of handwritten numbers using the Mnist data set. +First let us look at an example of using pure TensorFlow to finish the task, as shown below: + +``` +import tensorflow as tf +mnist = tf.keras.datasets.mnist + +n_nodes = 512 +n_classes = 10 +batch_size = 100 + +x = tf.placeholder('float', [None, 784]) +y = tf.placeholder('float') + +def neural_network_model(data): +layer_1 = {'weights':tf.Variable(tf.random_normal([784, n_nodes])), +'biases':tf.Variable(tf.random_normal([n_nodes]))} +output_layer = {'weights':tf.Variable(tf.random_normal([n_nodes, n_classes])), +'biases':tf.Variable(tf.random_normal([n_classes])),} +l1 = tf.add(tf.matmul(data,layer_1['weights']), layer_1['biases']) +l1 = tf.nn.relu(l1) +output = tf.matmul(l1,output_layer['weights']) + output_layer['biases'] +return output + +def train_neural_network(x): +prediction = neural_network_model(x) +cost = tf.reduce_mean( tf.nn.sparse_softmax_cross_entropy_with_logits(logits=prediction,labels=y) ) +optimizer = tf.train.AdamOptimizer().minimize(cost) +hm_epochs = 5 +with tf.Session() as sess: +sess.run(tf.initialize_all_variables()) +for epoch in range(hm_epochs): +epoch_loss = 0 +for _ in range(int(mnist.train.num_examples/batch_size)): +epoch_x, epoch_y = mnist.train.next_batch(batch_size) +_, c = sess.run([optimizer, cost], feed_dict={x: epoch_x, y: epoch_y}) +epoch_loss += c +print('Epoch', epoch, 'completed out of',hm_epochs,'loss:',epoch_loss) + +correct = tf.equal(tf.argmax(prediction, 1), tf.argmax(y, 1)) +accuracy = tf.reduce_mean(tf.cast(correct, 'float')) +print('Accuracy:',accuracy.eval({x:mnist.test.images, y:mnist.test.labels})) + +train_neural_network(x) +``` + +Now that we have that part done, let us take a look at the same implementation using _tf.keras_ : + +``` +import tensorflow as tf +mnist = tf.keras.datasets.mnist + +(x_train, y_train),(x_test, y_test) = mnist.load_data() +x_train, x_test = x_train / 255.0, x_test / 255.0 + +model = tf.keras.models.Sequential([ +tf.keras.layers.Flatten(), +tf.keras.layers.Dense(512, activation=tf.nn.relu), +tf.keras.layers.Dense(10, activation=tf.nn.softmax) +]) +model.compile(optimizer='adam', +loss='sparse_categorical_crossentropy', +metrics=['accuracy']) +print("running...") +model.fit(x_train, y_train, epochs=5) +model.evaluate(x_test, y_test) +``` + +The Keras code is far simpler and the language is at a higher level than TensorFlow. + +**Colaboratory by Google** +Increased performance in the execution of code is possible through the use of hardware like GPUs or TPUs rather than by running it solely on the CPUs. This is because CPUs, unlike the other two, have a limited number of cores and cannot process the vast mathematical calculations required even for quite a simple neural network. However, what can be done if your GPU is not supported by CUDA or you simply do not have one? + +That is where services such as Colaboratory come into play. Colaboratory is an online service that lets you use an online notebook system called Jupyter to write and execute code which is wholly based on the cloud. This avoids investing in expensive hardware such as a GPU to optimise code. Google Colaboratory gives you access to a Nvidia Tesla K80 GPU at no cost at all. The Colaboratory environment is exactly the same as any offline Python implementation. This means that there is absolutely no learning curve prior to starting off with Colaboratory. The fact that you run you code completely online means that you do not have to install any of the dependencies on your personal computer and this means that you are not restrained from implementing the latest ideas. +Putting your projects completely on the cloud allows you far more freedom and the access to Google TPUs which power the Colaboratory project. Unlike the Nvidia Tesla K80 GPU, the TPU does not come free, but you can use it for a basic fee calculated on TPU usage per second. This allows for the least possible execution time at the cheapest possible price. Like the TPU, Colaboratory also has several plans for other more powerful GPU prices, which are lower than the TPU rates, allowing you to choose what you feel is best for your particular use case. + +As mentioned earlier, Colaboratory is the same as any offline Python development environment that you may already be used to, thus allowing you to use packages that you normally do, such as OpenCV, TensorFlow, Keras, etc. A simple implementation of TensorFlow using Google Colaboratory is given below, starting from the official welcome page, __. + +To start off, first create your Python3 notebook in Colaboratory as shown in Figure 1. +Once you have done that, navigate to the notebook settings (_Edit > Notebook Settings_) as shown in Figure 2. + +Once you have selected the notebook settings, you can now change the runtime type to Python2 or Python3 and you can also change the hardware accelerator. It is here that you will decide on whether you want use the free Nvidia Tesla K80 GPU or the TPU provided by the service (Figure 3). + +![Figure 4: Mnist example][6] + +Now that the environment is set up, we can finally try out some program to test it. The purpose of this article is not to take you through any specific machine learning or deep learning example. For the sake of testing Colaboratory, let’s use the classic Mnist example that has been taken directly from the TensorFlow website __ +Once you have grabbed the code, simply execute it in the notebook and you should see an output as shown in Figure 4. + +Using Colaboratory, you have executed a basic classification example within minutes, without the need for any extra installations of TensorFlow (or even Python) on your computer. Thus, you can fully concentrate only on what you want to achieve and not bother about the dependencies needed for your project. + +We have seen only five of the vast number libraries that are available in the open source world. These five tools will provide the reader with a strong-enough footing to push forward and explore more complex tools that are streamlined for a particular use case. I urge you to also try to learn the mathematics of any new technology that you implement as it gives you a finer understanding of the how and whys of each thing. A nice start to any theory is the Machine Learning Cheatsheet, __ which, while barely scratching the surface of the mathematics behind the implementations, gives a very clear idea about the concepts and code examples to lead you in the right direction + +![Avatar][7] + +[Jatin Karthik Tripathy][8] + +The author takes a keen interest in graphics programming, graphics modelling, artificial intelligence, etc. He can be reached at jatinkarthik (dot) tripathy (at) vitap(dot) ac(dot) in. + +[![][9]][10] + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/tools-that-accelerate-a-newbies-understanding-of-machine-learning/ + +作者:[Jatin Karthik Tripathy][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://opensourceforu.com/author/jatin-tripathy/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Deep-Learning-Machine-learning-Artificial-intelligence.jpg?resize=696%2C502&ssl=1 (Deep Learning Machine learning Artificial intelligence) +[2]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Deep-Learning-Machine-learning-Artificial-intelligence.jpg?fit=700%2C505&ssl=1 +[3]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-1-Creating-a-notebook.jpg?resize=350%2C175&ssl=1 +[4]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-2-Accessing-notebook-settings.jpg?resize=350%2C280&ssl=1 +[5]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-3-Hardware-accelerator.jpg?resize=350%2C256&ssl=1 +[6]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-4-Mnist-example-350x281.jpg?resize=350%2C281&ssl=1 +[7]: https://secure.gravatar.com/avatar/19d277f27f20b7db95dacaff344a6948?s=100&r=g +[8]: https://opensourceforu.com/author/jatin-tripathy/ +[9]: https://opensourceforu.com/wp-content/uploads/2019/11/assoc.png +[10]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/sources/tech/20191120 Troubleshooting PCIe Bus Error severity Corrected on Ubuntu and Linux Mint.md b/sources/tech/20191120 Troubleshooting PCIe Bus Error severity Corrected on Ubuntu and Linux Mint.md new file mode 100644 index 0000000000..e2051d7401 --- /dev/null +++ b/sources/tech/20191120 Troubleshooting PCIe Bus Error severity Corrected on Ubuntu and Linux Mint.md @@ -0,0 +1,160 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Troubleshooting PCIe Bus Error severity Corrected on Ubuntu and Linux Mint) +[#]: via: (https://itsfoss.com/pcie-bus-error-severity-corrected/) +[#]: author: (Community https://itsfoss.com/author/itsfoss/) + +Troubleshooting PCIe Bus Error severity Corrected on Ubuntu and Linux Mint +====== + +Recently I was trying to install Mint on several nodes in my institute. At times, I was not able to install and got lots of ‘PCIe Bus’ errors on the screen. I have also observed similar issue with Ubuntu 18.04. + +I got stuck into it for more than a month, after using many solution and observations (solution is the same, but observation and treatment may be different), I found something which was helpful for me and I think could be helpful for other Ubuntu and Linux Mint users. + +### Observations about PCIe Bus Error severity Corrected + +![][1] + +It happened with my HP system and it seems that there is some compatibility issues with the HP hardware. The PCIe Bus Error is basically the Linux kernel reporting the hardware issue. + +This error reporting turns into nightmare because of the frequency of error messages generated by the system. I have noticed in various [Linux forums][2] that many HP user have encountered this error, probably HP needs to improve Linux support for their hardware. + +Do note that this doesn’t necessarily mean that you cannot use Linux on your HP system. You might be able to use Linux like everyone else. It’s just that seeing this message flashing on the screen on every boot is annoying and sometimes, it could lead to bigger troubles. + +If the system keeps on reporting, it will increase the log size. If you have limited space for root, it could mean that your system will stuck at the black screen displaying the PCIe error message and your system won’t be able to boot. + +Now that you know a few things, let’s see how to tackle this error. + +### Handling PCIe Bus Error messages if you can boot in to your Linux system + +If you see the PCIe Bus Error message on the screen while booting but you are still able to log in, you could do a workaround for this annoyance. + +You can do little on the hardware compatibility front. I mean you (most probably) cannot go ahead and start coding drivers for your hardware or fix the existing drivers code. If your system works fine, your main concern should be that too much of error reporting doesn’t eat up the disk space. + +In that regard, you can change the Linux kernel parameter and ask it to stop reporting the PCIe errors. To do that, you need to edit the grub configuration. + +Basically, you just have to use a text editor for editing the file. + +First thing first, make a backup of your grub config file so that you can revert in case if you are not sure of things you changed. Open a terminal and use the following command: + +``` +cp /etc/default/grub ~/grub.back +``` + +Now open the file with Gedit for editing: + +``` +sudo gedit /etc/default/grub +``` + +Look for the line that has **GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”** + +Add pci=noaer in this line. AER stands for Advanced Error Reporting and ‘noaer’ asks the kernel to not use/log Advanced Error Reporting. The changed line should look like this: + +``` +GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=noaer" +``` + +Once you have saved the file, you should update the grub using this command: + +``` +sudo update-grub +``` + +[Restart Ubuntu][3] and you shouldn’t see the ‘PCIe Bus Error severity Corrected messages’ anymore. + +If this doesn’t fix the issue for you, you can try to change other kernel parameters. + +#### Further troubleshooting: Disable MSI + +Now you are resorting to hit and trial. You may try disabling [MSI][4]. Though Linux kernel supports MSI for several years now, a wrong implementation of MSI from some hardware manufacturer may lead to the PCIe errors. + +The drill is practically the same as you saw in the previous section. You edit the grub configuration and make the GRUB_CMDLINE_LINUX_DEFAULT line look like this: + +``` +GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=nomsi" +``` + +Update grub and reboot the system: + +``` +sudo update-grub +``` + +#### Even further troubleshooting: Disable mmconf + +I know it’s getting repetitive but if you are still facing the issue, it could be worth to give this a last try. This time, disable the mmconf parameter in Linux kernel. + +mmconf means memory mapped config and if you have an old computer, a buggy BIOS may lead to this issue. + +The steps remain the same. Just change the line GRUB_CMDLINE_LINUX_DEFAULT in your grub config to make it look like: + +``` +GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=nommconf" +``` + +#### Can’t boot! How to edit grub config now? + +In some cases, if you are not even able to boot at all, perhaps your root is out of space. An idea here would be to delete old log files and see if you could boot now and if yes, change the grub config. + +On reboot, if you stuck with logs on the screen and do a hard boot (use power button to turn it off and on again). When you power on, choose to go in to recovery mode from the grub screen. It should be under Advanced options. + +![][5] + +If your system doesn’t show the grub screen, press and hold shift key at boot. In some systems, pressing the Esc key brings the grub screen. + +In the advanced option->recovery mode: + +![][6] + +Drop into root shell: + +![][7] + +If you use the ls command to find large files, you’ll see that sys.log and kern.log take huge space: + +``` +ls -s -S /var/log +``` + +You can [empty the log files in Linux command line][8] this way: + +``` +$ > syslog +$ > kern.log +``` + +Once that is done, reboot your system. You should be able to log in. You should quickly change the grub parameters as discussed above. Adding pci=noaer should help you in this case. + +I know it’s more of a workaround than solution. But this is something that troubled me long and helped me get around the error. Otherwise I had to reinstall the system. + +I just wanted to share what worked for me with the community here. I hope it helps you as well. + +This article is written by Arun Shrimali. Arun is IT Head at Resonance Institute in India and he tries to implement Open Source Software across his organization. + +The article has been edited by Abhishek Prakash. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/pcie-bus-error-severity-corrected/ + +作者:[Community][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/itsfoss/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/troubleshooting_linux.png?ssl=1 +[2]: https://itsfoss.community/ +[3]: https://linuxhandbook.com/restart-ubuntu-server/ +[4]: https://en.wikipedia.org/wiki/Message_Signaled_Interrupts +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2012/07/new-grub-menu-ubuntu.png?ssl=1 +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2012/07/boot-into-recovery-mode-ubuntu-1.jpg?ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2012/07/drop-to-root-prompt-1.png?ssl=1 +[8]: https://linuxhandbook.com/empty-file-linux/ diff --git a/sources/tech/20191121 Bash Script to View System Information on Linux Every Time You Log into Shell.md b/sources/tech/20191121 Bash Script to View System Information on Linux Every Time You Log into Shell.md new file mode 100644 index 0000000000..9efdc87ec1 --- /dev/null +++ b/sources/tech/20191121 Bash Script to View System Information on Linux Every Time You Log into Shell.md @@ -0,0 +1,218 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Bash Script to View System Information on Linux Every Time You Log into Shell) +[#]: via: (https://www.2daygeek.com/bash-shell-script-view-linux-system-information/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +Bash Script to View System Information on Linux Every Time You Log into Shell +====== + +There are several commands in Linux to obtain system information such as processor information, manufacturer name, and serial number, etc,. + +You may need to run several commands to collect this information. + +Also, it is very difficult to remember all the commands and their options. + +Instead you can write a **[shell script][1]** to customize the output based on your needs. + +In the past we have written many **[bash scripts][2]** for a variety of purposes. + +Today, we came up with a new shell script, which shows you the required system information every time you log into the shell. + +There are six parts to this script, and more details below. + + * **Part-1:** General System Information + * **Part-2:** CPU/Memory Current Usage + * **Part-3:** Disk Usage >80% + * **Part-4:** List System WWN Details + * **Part-5:** Oracle DB Instances + * **Part-6:** Available Package Updates + + + +We’ve added potential information to each area based on our needs. You can further customize this script to your needs if you wish. + +There are many tools for this, most of which we have already covered. + +To read them, go to the following articles. + + * **[inxi – A Great Tool to Check Hardware Information on Linux][3]** + * **[Dmidecode – Easy Way To Get Linux System Hardware Information][3]** + * **[LSHW (Hardware Lister) – A Nifty Tool To Get A Hardware Information On Linux][3]** + * **[hwinfo (Hardware Info) – A Nifty Tool To Detect System Hardware Information On Linux][3]** + * **[python-hwinfo : Display Summary Of Hardware Information Using Standard Linux Utilities][3]** + * **[How To Use lspci, lsscsi, lsusb, And lsblk To Get Linux System Devices Information][3]** + * **[How To Check System Hardware Manufacturer, Model And Serial Number In Linux][3]** + * **[How To Find WWN, WWNN and WWPN Number Of HBA Card In Linux][3]** + * **[How to check HP iLO Firmware version from Linux command line][3]** + * **[How to check Wireless network card and WiFi information from Linux Command Line][3]** + * **[How to check CPU & Hard Disk temperature on Linux][3]** + * **[Hegemon – A modular System & Hardware monitoring tool for Linux][3]** + * **[How to Check System Configuration and Hardware Information on Linux][3]** + + + +If anyone wants to add any other information in the script, please let us know your requirements in the comment section so that we can help you. + +### Bash Script to View System Information on Linux Every Time You Log into the Shell + +This basic script will bring the system information to your terminal whenever you log into the shell. + +``` +#vi /opt/scripts/system-info.sh + +#!/bin/bash +echo -e "-------------------------------System Information----------------------------" +echo -e "Hostname:\t\t"`hostname` +echo -e "uptime:\t\t\t"`uptime | awk '{print $3,$4}' | sed 's/,//'` +echo -e "Manufacturer:\t\t"`cat /sys/class/dmi/id/chassis_vendor` +echo -e "Product Name:\t\t"`cat /sys/class/dmi/id/product_name` +echo -e "Version:\t\t"`cat /sys/class/dmi/id/product_version` +echo -e "Serial Number:\t\t"`cat /sys/class/dmi/id/product_serial` +echo -e "Machine Type:\t\t"`vserver=$(lscpu | grep Hypervisor | wc -l); if [ $vserver -gt 0 ]; then echo "VM"; else echo "Physical"; fi` +echo -e "Operating System:\t"`hostnamectl | grep "Operating System" | cut -d ' ' -f5-` +echo -e "Kernel:\t\t\t"`uname -r` +echo -e "Architecture:\t\t"`arch` +echo -e "Processor Name:\t\t"`awk -F':' '/^model name/ {print $2}' /proc/cpuinfo | uniq | sed -e 's/^[ \t]*//'` +echo -e "Active User:\t\t"`w | cut -d ' ' -f1 | grep -v USER | xargs -n1` +echo -e "System Main IP:\t\t"`hostname -I` +echo "" +echo -e "-------------------------------CPU/Memory Usage------------------------------" +echo -e "Memory Usage:\t"`free | awk '/Mem/{printf("%.2f%"), $3/$2*100}'` +echo -e "Swap Usage:\t"`free | awk '/Swap/{printf("%.2f%"), $3/$2*100}'` +echo -e "CPU Usage:\t"`cat /proc/stat | awk '/cpu/{printf("%.2f%\n"), ($2+$4)*100/($2+$4+$5)}' | awk '{print $0}' | head -1` +echo "" +echo -e "-------------------------------Disk Usage >80%-------------------------------" +df -Ph | sed s/%//g | awk '{ if($5 > 80) print $0;}' +echo "" + +echo -e "-------------------------------For WWN Details-------------------------------" +vserver=$(lscpu | grep vendor | wc -l) +if [ $vserver -gt 0 ] +then +echo "$(hostname) is a VM" +else +systool -c fc_host -v | egrep "(Class Device path | port_name |port_state)" > systool.out +fi +echo "" + +echo -e "-------------------------------Oracle DB Instances---------------------------" +if id oracle >/dev/null 2>&1; then +/bin/ps -ef|grep pmon +then +else +echo "oracle user does not exist on $(hostname)" +fi +echo "" + +if (( $(cat /etc/*-release | grep -w "Oracle|Red Hat|CentOS|Fedora" | wc -l) > 0 )) +then +echo -e "-------------------------------Package Updates-------------------------------" +yum updateinfo summary | grep 'Security|Bugfix|Enhancement' +echo -e "-----------------------------------------------------------------------------" +else +echo -e "-------------------------------Package Updates-------------------------------" +cat /var/lib/update-notifier/updates-available +echo -e "-----------------------------------------------------------------------------" +fi +``` + +Once the above script is added to a file. Set the executable permission for the “system-info.sh” file. + +``` +# chmod +x ~root/system-info.sh +``` + +When the script is ready, add the file path at the end of the “.bash_profile” file in RHEL-based systems CentOS, Oracle Linux and Fedora. + +``` +# echo "/root/system-info.sh" >> ~root/.bash_profile +``` + +To take this change effect, run the following command. + +``` +# source ~root/.bash_profile +``` + +For Debian-based systems, you may need to add a file path to the “.profile” file. + +``` +# echo "/root/system-info.sh" >> ~root/.profile +``` + +Run the following command to take this change effect. + +``` +# source ~root/.profile +``` + +You may have seen an output like the one below when running the above “source” command. + +From next time on-wards, you will get this information every time you log into the shell. + +Alternatively, you can manually run this script at any time if you need to. + +``` +-------------------------------System Information--------------------------- +Hostname: daygeek-Y700 +uptime: 1:20 1 +Manufacturer: LENOVO +Product Name: 80NV +Version: Lenovo ideapad Y700-15ISK +Serial Number: AA0CMRN1 +Machine Type: Physical +Operating System: Manjaro Linux +Kernel: 4.19.80-1-MANJARO +Architecture: x86_64 +Processor Name: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz +Active User: daygeek renu thanu +System Main IP: 192.168.1.6 192.168.122.1 + +-------------------------------CPU/Memory Usage------------------------------ +Memory Usage: 37.28% +Swap Usage: 0.00% +CPU Usage: 15.43% + +-------------------------------Disk Usage >80%------------------------------- +Filesystem Size Used Avail Use Mounted on +/dev/nvme0n1p1 217G 202G 4.6G 98 / +/dev/loop0 109M 109M 0 100 /var/lib/snapd/snap/odrive-unofficial/2 +/dev/loop1 91M 91M 0 100 /var/lib/snapd/snap/core/6405 +/dev/loop2 90M 90M 0 100 /var/lib/snapd/snap/core/7713 + +-------------------------------For WWN Details------------------------------- +CentOS8.2daygeek.com is a VM + +-------------------------------Oracle DB Instances--------------------------- +oracle user does not exist on CentOS8.2daygeek.com + +-------------------------------Package Updates------------------------------- + 13 Security notice(s) + 9 Important Security notice(s) + 3 Moderate Security notice(s) + 1 Low Security notice(s) + 35 Bugfix notice(s) + 1 Enhancement notice(s) +----------------------------------------------------------------------------- +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/bash-shell-script-view-linux-system-information/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/category/shell-script/ +[2]: https://www.2daygeek.com/category/bash-script/ +[3]: https://www.2daygeek.com/inxi-system-hardware-information-on-linux/ diff --git a/sources/tech/20191121 Simulate gravity in your Python game.md b/sources/tech/20191121 Simulate gravity in your Python game.md new file mode 100644 index 0000000000..977c234d8d --- /dev/null +++ b/sources/tech/20191121 Simulate gravity in your Python game.md @@ -0,0 +1,399 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Simulate gravity in your Python game) +[#]: via: (https://opensource.com/article/19/11/simulate-gravity-python) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Simulate gravity in your Python game +====== +Learn how to program video games with Python's Pygame module and start +manipulating gravity. +![Cosmic stars in outer space][1] + +The real world is full of movement and life. The thing that makes the real world so busy and dynamic is physics. Physics is the way matter moves through space. Since a video game world has no matter, it also has no physics, so game programmers have to _simulate_ physics. + +In terms of most video games, there are basically only two aspects of physics that are important: gravity and collision. + +You implemented some collision detection when you [added an enemy][2] to your game, but this article adds more because gravity requires collision detection. Think about why gravity might involve collisions. If you can't think of any reasons, don't worry—it'll become apparent as you work through the sample code. + +Gravity in the real world is the tendency for objects with mass to be drawn toward one another. The larger the object, the more gravitational influence it exerts. In video game physics, you don't have to create objects with mass great enough to justify a gravitational pull; you can just program a tendency for objects to fall toward the presumed largest object in the video game world: the world itself. + +### Adding a gravity function + +Remember that your player already has a property to determine motion. Use this property to pull the player sprite toward the bottom of the screen. + +In Pygame, higher numbers are closer to the bottom edge of the screen. + +In the real world, gravity affects everything. In platformers, however, gravity is selective—if you add gravity to your entire game world, all of your platforms would fall to the ground. Instead, you add gravity just to your player and enemy sprites. + +First, add a **gravity** function in your **Player** class: + + +``` +    def gravity(self): +        self.movey += 3.2 # how fast player falls +``` + +This is a simple function. First, you set your player in vertical motion, whether your player wants to be in motion or not. In other words, you have programmed your player to always be falling. That's basically gravity. + +For the gravity function to have an effect, you must call it in your main loop. This way, Python applies the falling motion to your player once every clock tick. + +In this code, add the first line to your loop: + + +``` +    player.gravity() # check gravity +    player.update() +``` + +Launch your game to see what happens. Look sharp, because it happens fast: your player falls out of the sky, right off your game screen. + +Your gravity simulation is working, but maybe too well. + +As an experiment, try changing the rate at which your player falls. + +### Adding a floor to gravity + +The problem with your character falling off the world is that there's no way for your game to detect it. In some games, if a player falls off the world, the sprite is deleted and respawned somewhere new. In other games, the player loses points or a life. Whatever you want to happen when a player falls off the world, you have to be able to detect when the player disappears offscreen. + +In Python, to check for a condition, you can use an **if** statement. + +You must check to see **if** your player is falling and how far your player has fallen. If your player falls so far that it reaches the bottom of the screen, then you can do _something_. To keep things simple, set the position of the player sprite to 20 pixels above the bottom edge. + +Make your **gravity** function look like this: + + +``` +    def gravity(self): +        self.movey += 3.2 # how fast player falls +        +        if self.rect.y > worldy and self.movey >= 0: +            self.movey = 0 +            self.rect.y = worldy-ty +``` + +Then launch your game. Your sprite still falls, but it stops at the bottom of the screen. You may not be able to _see_ your sprite behind the ground layer, though. An easy fix is to make your player sprite bounce higher by adding another **-ty** to its new Y position after it hits the bottom of the game world: + + +``` +    def gravity(self): +        self.movey += 3.2 # how fast player falls +        +        if self.rect.y > worldy and self.movey >= 0: +            self.movey = 0 +            self.rect.y = worldy-ty-ty +``` + +Now your player bounces at the bottom of the screen, just behind your ground sprites. + +What your player really needs is a way to fight gravity. The problem with gravity is, you can't fight it unless you have something to push off of. So, in the next article, you'll add ground and platform collision and the ability to jump. In the meantime, try applying gravity to the enemy sprite. + +Here's all the code so far: + + +``` +#!/usr/bin/env python3 +# draw a world +# add a player and player control +# add player movement +# add enemy and basic collision +# add platform +# add gravity + +# GNU All-Permissive License +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved.  This file is offered as-is, +# without any warranty. + +import pygame +import sys +import os + +''' +Objects +''' + +class Platform(pygame.sprite.Sprite): +    # x location, y location, img width, img height, img file     +    def __init__(self,xloc,yloc,imgw,imgh,img): +        pygame.sprite.Sprite.__init__(self) +        self.image = pygame.image.load(os.path.join('images',img)).convert() +        self.image.convert_alpha() +        self.rect = self.image.get_rect() +        self.rect.y = yloc +        self.rect.x = xloc + +class Player(pygame.sprite.Sprite): +    ''' +    Spawn a player +    ''' +    def __init__(self): +        pygame.sprite.Sprite.__init__(self) +        self.movex = 0 +        self.movey = 0 +        self.frame = 0 +        self.health = 10 +        self.score = 1 +        self.images = [] +        for i in range(1,9): +            img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert() +            img.convert_alpha() +            img.set_colorkey(ALPHA) +            self.images.append(img) +            self.image = self.images[0] +            self.rect  = self.image.get_rect() + +    def gravity(self): +        self.movey += 3.2 # how fast player falls +        +        if self.rect.y > worldy and self.movey >= 0: +            self.movey = 0 +            self.rect.y = worldy-ty-ty +        +    def control(self,x,y): +        ''' +        control player movement +        ''' +        self.movex += x +        self.movey += y +        +    def update(self): +        ''' +        Update sprite position +        ''' + +        self.rect.x = self.rect.x + self.movex +        self.rect.y = self.rect.y + self.movey + +        # moving left +        if self.movex < 0: +            self.frame += 1 +            if self.frame > ani*3: +                self.frame = 0 +            self.image = self.images[self.frame//ani] + +        # moving right +        if self.movex > 0: +            self.frame += 1 +            if self.frame > ani*3: +                self.frame = 0 +            self.image = self.images[(self.frame//ani)+4] + +        # collisions +        enemy_hit_list = pygame.sprite.spritecollide(self, enemy_list, False) +        for enemy in enemy_hit_list: +            self.health -= 1 +            print(self.health) + +        ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) +        for g in ground_hit_list: +            self.health -= 1 +            print(self.health) + +class Enemy(pygame.sprite.Sprite): +    ''' +    Spawn an enemy +    ''' +    def __init__(self,x,y,img): +        pygame.sprite.Sprite.__init__(self) +        self.image = pygame.image.load(os.path.join('images',img)) +        #self.image.convert_alpha() +        #self.image.set_colorkey(ALPHA) +        self.rect = self.image.get_rect() +        self.rect.x = x +        self.rect.y = y +        self.counter = 0 +        +    def move(self): +        ''' +        enemy movement +        ''' +        distance = 80 +        speed = 8 + +        if self.counter >= 0 and self.counter <= distance: +            self.rect.x += speed +        elif self.counter >= distance and self.counter <= distance*2: +            self.rect.x -= speed +        else: +            self.counter = 0 + +        self.counter += 1 + +class Level(): +    def bad(lvl,eloc): +        if lvl == 1: +            enemy = Enemy(eloc[0],eloc[1],'yeti.png') # spawn enemy +            enemy_list = pygame.sprite.Group() # create enemy group +            enemy_list.add(enemy)              # add enemy to group +            +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return enemy_list + +    def loot(lvl,lloc): +        print(lvl) + +    def ground(lvl,gloc,tx,ty): +        ground_list = pygame.sprite.Group() +        i=0 +        if lvl == 1: +            while i < len(gloc): +                ground = Platform(gloc[i],worldy-ty,tx,ty,'ground.png') +                ground_list.add(ground) +                i=i+1 + +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return ground_list + +    def platform(lvl,tx,ty): +        plat_list = pygame.sprite.Group() +        ploc = [] +        i=0 +        if lvl == 1: +            ploc.append((0,worldy-ty-128,3)) +            ploc.append((300,worldy-ty-256,3)) +            ploc.append((500,worldy-ty-128,4)) + +            while i < len(ploc): +                j=0 +                while j <= ploc[i][2]: +                    plat = Platform((ploc[i][0]+(j*tx)),ploc[i][1],tx,ty,'ground.png') +                    plat_list.add(plat) +                    j=j+1 +                print('run' + str(i) + str(ploc[i])) +                i=i+1 + +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return plat_list + +''' +Setup +''' +worldx = 960 +worldy = 720 + +fps = 40 # frame rate +ani = 4  # animation cycles +clock = pygame.time.Clock() +pygame.init() +main = True + +BLUE  = (25,25,200) +BLACK = (23,23,23 ) +WHITE = (254,254,254) +ALPHA = (0,255,0) + +world = pygame.display.set_mode([worldx,worldy]) +backdrop = pygame.image.load(os.path.join('images','stage.png')).convert() +backdropbox = world.get_rect() +player = Player() # spawn player +player.rect.x = 0 +player.rect.y = 0 +player_list = pygame.sprite.Group() +player_list.add(player) +steps = 10 # how fast to move + +eloc = [] +eloc = [200,20] +gloc = [] +#gloc = [0,630,64,630,128,630,192,630,256,630,320,630,384,630] +tx = 64 #tile size +ty = 64 #tile size + +i=0 +while i <= (worldx/tx)+tx: +    gloc.append(i*tx) +    i=i+1 + +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) +plat_list = Level.platform( 1,tx,ty ) + +''' +Main loop +''' +while main == True: +    for event in pygame.event.get(): +        if event.type == pygame.QUIT: +            pygame.quit(); sys.exit() +            main = False + +        if event.type == pygame.KEYDOWN: +            if event.key == pygame.K_LEFT or event.key == ord('a'): +                print("LEFT") +                player.control(-steps,0) +            if event.key == pygame.K_RIGHT or event.key == ord('d'): +                print("RIGHT") +                player.control(steps,0) +            if event.key == pygame.K_UP or event.key == ord('w'): +                print('jump') + +        if event.type == pygame.KEYUP: +            if event.key == pygame.K_LEFT or event.key == ord('a'): +                player.control(steps,0) +            if event.key == pygame.K_RIGHT or event.key == ord('d'): +                player.control(-steps,0) +            if event.key == pygame.K_UP or event.key == ord('w'): +                print('jump') + +            if event.key == ord('q'): +                pygame.quit() +                sys.exit() +                main = False + +    world.blit(backdrop, backdropbox) +    player.gravity() # check gravity +    player.update() +    player_list.draw(world) +    enemy_list.draw(world) +    ground_list.draw(world) +    plat_list.draw(world) +    for e in enemy_list: +        e.move() +    pygame.display.flip() +    clock.tick(fps) +``` + +* * * + +This is part 6 in an ongoing series about creating video games in [Python 3][3] using the [Pygame][4] module. Previous articles are: + + * [Learn how to program in Python by building a simple dice game][5] + * [Build a game framework with Python using the Pygame module][6] + * [How to add a player to your Python game][7] + * [Using Pygame to move your game character around][8] + * [What's a hero without a villain? How to add one to your Python game][2] + + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/simulate-gravity-python + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/space_stars_cosmic.jpg?itok=bE94WtN- (Cosmic stars in outer space) +[2]: https://opensource.com/article/18/5/pygame-enemy +[3]: https://www.python.org/ +[4]: https://www.pygame.org +[5]: https://opensource.com/article/17/10/python-101 +[6]: https://opensource.com/article/17/12/game-framework-python +[7]: https://opensource.com/article/17/12/game-python-add-a-player +[8]: https://opensource.com/article/17/12/game-python-moving-player diff --git a/sources/tech/20191122 How to use Bitwarden for password protection on Active Directory.md b/sources/tech/20191122 How to use Bitwarden for password protection on Active Directory.md new file mode 100644 index 0000000000..67b79f1c64 --- /dev/null +++ b/sources/tech/20191122 How to use Bitwarden for password protection on Active Directory.md @@ -0,0 +1,219 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to use Bitwarden for password protection on Active Directory) +[#]: via: (https://opensource.com/article/19/11/bitwarden-password-protection-active-directory) +[#]: author: (Stephen Bancroft https://opensource.com/users/stevereaver) + +How to use Bitwarden for password protection on Active Directory +====== +Integrate your Linux self-hosted Bitwarden instance with AD using +Bitwarden Directory Connector. +![A lock on the side of a building][1] + +[Bitwarden][2] is a fantastic tool for managing passwords. It has applications for every platform, a browser plugin, and a self-hosted version, and it offers some great password management tricks like folders and collections. One of my favorite features is that it will keep a history of your old passwords, which is a great feature for enterprise users. + +If you are an enterprise user, you are probably self-hosting Bitwarden and want to sync your users with a staff directory. My organization uses Active Directory (AD), which is the standard for user directories and integrates seamlessly with Windows desktops. I also need it to work with our open source tools, and herein lies the secret sauce shared in this article. + +The tool that allows you to do this is [Bitwarden Directory Connector][3] (BWDC). If you do a Google search, you will not find much information on using BWDC with AD on Linux. [Bitwarden's blog][4] is a great starting point if you're using the Windows version but it won't help you integrate it into your Linux environment. You can find instructions to do that on Bitwarden's GitHub page, but they aren't very clear. So, here I'll explain how to get your Linux self-hosted version of Bitwarden to integrate with your enterprise Active Directory (and, hopefully, provide more fruitful results for future Google searchers looking for this information). + +In my setup, both Bitwarden and Active Directory are hosted on AWS, the former in an EC2 instance and the latter in AWS Simple Directory. The Bitwarden Docker container is installed in the home directory of a user called **bitwarden**. [Bitwarden's instructions][5] make this easy to set up. But setting up BWDC is not as clear, so I will try to fix that here. + +### Install BWDC + +Start by setting up a directory for BWDC, then download the ZIP file and unzip it: + + +``` +cd /home/bitwarden +mkdir directory-connector +cd directory-connector +wget +unzip bwdc-linux-2.6.2.zip +chmod +x bwdc +``` + +(At the time of this writing, BWDC 2.6.2 was the current version; that may change, so make sure to download the latest release.) + +You will now have a binary file called **bwdc** and a file called **keytar.node**; leave both files right where they are. + +Next, edit the profile of the **bitwarden** user: + + +``` +`vi /home/bitwarden/.profile` +``` + +and add the lines: + + +``` +export BITWARDENCLI_CONNECTOR_PLAINTEXT_SECRETS=true +export PATH=$PATH:/home/bitwarden/directory-connector +``` + +Log out and back in to pick up the new settings, or you can source the profile with: + + +``` +`  . ~/.profile` +``` + +The line **BITWARDENCLI_CONNECTOR_PLAINTEXT_SECRETS=true** tells BWDC not to use any desktop-based keystore. Since this is a server and it's unlikely to have a desktop installed, you will have to keep the password in plain text (but you will take precautions to protect it later). The second line sets up a path to the **bwdc** binary so it can run from any directory you are in. + +### Configure BWDC + +Once BWDC is installed, configure it to connect to your Bitwarden instance: + + +``` +bwdc login +? Email address: <your email for your master account> +? Master password: [hidden] +``` + +After you are logged in, you're ready to work on the **data.json** file. + +If you set up BWDC using the steps above, its configuration information will be stored in **/home/bitwarden/.config/Bitwarden Directory Connector/data.json**. This file contains the **appId** and **access token**; these are the login credentials for your Bitwarden instance. But what about Active Directory, you say? You can add that manually by editing your **data.json** file (I assume you are on a server and are using Vi): + + +``` +`vi '/home/bitwarden/.config/Bitwarden Directory Connector/data.json'` +``` + +Add the following just underneath the **appId** line: + + +``` +"rememberEmail": true, +  "rememberedEmail": "<the email address you logged in with>", +  "organizationId": "<your organization id>", +  "directoryType": 0, +  "directoryConfig_0": { +    "ssl": false, +    "sslAllowUnauthorized": false, +    "port": 389, +    "currentUser": false, +    "ad": true, +    "hostname": "<hostname of your active directory>", +    "rootPath": "<root path of AD, something like; dc=com,dc=au>", +    "username": "<username with privilege to read the AD; DOMAIN\\\Username>", +    "password": "<password for the above account>" +  }, +  "directoryConfig_2": {}, +  "directoryConfig_1": {}, +  "directoryConfig_3": {}, +  "syncConfig": { +    "users": true, +    "groups": true, +    "interval": 5, +    "removeDisabled": true, +    "overwriteExisting": true, +    "useEmailPrefixSuffix": false, +    "creationDateAttribute": "whenCreated", +    "revisionDateAttribute": "whenChanged", +    "emailPrefixAttribute": "sAMAccountName", +    "memberAttribute": "member", +    "userObjectClass": "person", +    "groupObjectClass": "group", +    "userEmailAttribute": "mail", +    "groupNameAttribute": "name", +    "userFilter": "(&(memberOf=CN=bitwarden,OU=groups,DC=work,DC=corp))", +    "groupPath": "OU=Groups", +    "userPath": "CN=Users" +  }, +  "environmentUrls": { +    "base": "<base url of your bitwarden instance; [https://bitwarden.yourdomain\>][6]", +    "api": null, +    "identity": null, +    "webVault": null, +    "icons": null, +    "notifications": null, +    "events": null +  }, +``` + +If you look through this, you'll see that you need to change several values in this entry, including the **userFilter**, **groupPath**, and **userPath**. (I will assume you are familiar with LDAP and AD and know what those values should be for your instance.) Keep the **CN=bitwarden** part for the Bitwarden AD group you will create later. The other value you need to change is **organizationID**, which you can find in your **bwdata** directory as the name of one of the JSON files. List the files: + + +``` +`ls /home/bitwarden/bwdata/core/licenses/organization` +``` + +This should return a directory listing, containing a single filename in the form **<organization id>.json**. The filename itself is your organization's ID. Insert it into the **organizationID** line in the code above. + +Once you get your **data.json** file right, _I **highly** recommend you back up this file_. There seems to be an issue that sets this file back to default settings if BWDC finds a problem with it. This means if you innocently make a change to the file and there is a mistake, you will lose the entire configuration. + +Next, test connectivity to your AD as the **bitwarden** user: + + +``` +`bwdc test` +``` + +This should return a dump of the groups in your AD. To protect your password, set the permissions on that file so that only the **bitwarden** user can read it: + + +``` +`chmod 700 '/home/bitwarden/.config/Bitwarden Directory Connector/data.json'` +``` + +### Set up your group + +Now add a group to your AD (my group is called **bitwarden**), where you will add and remove users as they need access to Bitwarden. This group is necessary because, if you don't filter the users based on this group, BWDC will try to use ALL users in your AD. If the number of users is greater than your Bitwarden license allows, BWDC will fail silently, and you will hate yourself for a long time…. much like I did! + +Once the group is set up and has at least one user, run the test again. You should see your user's email address in the output. + +Now it is time to sync. Once you sync, any users that appear in the **bitwarden** group will be added to Bitwarden, and an email will be sent to them to invite them to sign up. Working as the **bitwarden** user, sync the directories with: + + +``` +`bwdc sync` +``` + +Given that **removeDisabled** is set to **true** in the **data.json** file, you can set up a cron job to keep the members of the **bitwarden** group and the Bitwarden users in constant sync so that any changes you make in your AD are immediately reflected in your Bitwarden instance. Add the following to your **/etc/crontab**: + + +``` +# Sync for Active Directory to Bitwarden +* *     * * *   bitwarden export BITWARDENCLI_CONNECTOR_PLAINTEXT_SECRETS=true ; /home/bitwarden/directory-connector/bwdc sync >/dev/null 2>&1 +``` + +Once you have auto-sync going, you will have a complete list of all your AD groups in Bitwarden. From there, it's just a simple matter of assigning a group to a collection and then adding members to groups in your AD. The users will be automatically assigned to the correct password collections and see the passwords they need. + +### Potential traps + +Finally, I will tell you about a few little traps that I fell into when setting this up. First, be aware of the **AD Primary Group**. You may have set this for a user if any of your Linux or other POSIX systems get login credentials from AD. It seems that AD will not include a user in group search results if that group is set as the primary group; this could remove a user from a group and therefore lose access to a collection. + +Second, when you need to delete a user, you might think that removing an account from the group in AD would remove the user… wrong! It seems that Bitwarden keeps some user information hanging around in its database. This became painfully obvious when I removed my own account and then discovered that I was no longer able to log in after recreating it because the multi-factor authentication (MFA) was still active and the token had expired, effectively locking me out. You must explicitly tell Bitwarden to remove that stuff in the database. To do so, go to the URL: + + +``` +`https:///#/recover-delete` +``` + +Enter the email address the user signed up with. They will get an email instructing them to click a link to confirm to remove the account. Once that is done, the user can be put back in the Bitwarden AD group and go through the sign-on process again. + +Now you know how to get your self-hosted Bitwarden working with your AD. I think you will still experience a few issues, but with a little bit of patience and tinkering with the configuration, it will work. Just don't muck around with it too much once it is working! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/bitwarden-password-protection-active-directory + +作者:[Stephen Bancroft][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/stevereaver +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_3reasons.png?itok=k6F3-BqA (A lock on the side of a building) +[2]: https://bitwarden.com/ +[3]: https://github.com/bitwarden/directory-connector +[4]: https://blog.bitwarden.com/organization-user-groups-directory-sync-ba674cb78a5c +[5]: https://help.bitwarden.com/article/install-on-premise/ +[6]: https://bitwarden.yourdomain\> diff --git a/sources/tech/20191125 25 Raspberry Pi Project Ideas to Put Your Pi to Some Good Use.md b/sources/tech/20191125 25 Raspberry Pi Project Ideas to Put Your Pi to Some Good Use.md new file mode 100644 index 0000000000..37912e7e20 --- /dev/null +++ b/sources/tech/20191125 25 Raspberry Pi Project Ideas to Put Your Pi to Some Good Use.md @@ -0,0 +1,303 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (25 Raspberry Pi Project Ideas to Put Your Pi to Some Good Use) +[#]: via: (https://itsfoss.com/raspberry-pi-projects/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +25 Raspberry Pi Project Ideas to Put Your Pi to Some Good Use +====== + +It won’t be an exaggeration if I call Raspberry Pi a revolutionary gadget. When it was first launched in the year 2011-12, people just couldn’t believe that a computer can be available in just $25. + +If you bought a Pi and wondering what should do with my Raspberry Pi, I have got your back. I am going to list some cool Raspberry Pi projects that you can start following in your free time. + +These Raspberry Pi project ideas are not limited to Pi. You can use them with other [Raspberry Pi like devices such as Orange Pi, Khadas][1] etc. + +### 25 Cool Raspberry Pi Projects + +I have listed several these project ideas by categorizing them in terms of the level of complexity (beginner, intermediate, and advanced). Some projects need additional equipment and sensors as well. + +Of course, it is worth noting that it will be subjective to what expertise you have. So, let us take a look at the project ideas. + +**Beginner Level Raspberry Pi Projects** + +#### 1\. Media Server + +Building a media server using Rasberry Pi is the most common and probably the easiest project there is. + +You can take a look at some of the [best media server software][2] available for Linux and get started. + +To know more about it, you can refer to the official documentation of [using Kodi with Raspberry Pi][3] (which is one of the media server software available). + +[Using Kodi On Raspberry Pi][3] + +#### 2\. Weather Station + +![][4] + +If you’re good at building projects with electronic components, building a weather station using Raspberry Pi should be fun for you. + +This may not be the easiest one to start with – but it’s quite simple if you carefully look into the project requirements. + +You will be able to collect weather data using a variety of sensors as per your requirements. The project has been listed on the official website to help you build it as easily as possible. + +[Weather Station Project][5] + +#### 3\. The Parent Detector + +![][6] + +Yet another project from Raspberry Pi’s official website, this project uses minimal hardware to set up a motion detector which then triggers a video recording using the Raspberry Pi camera module. + +The use-case for this can be a lot of things. If you are a parent, you can keep an eye on your child when they enter their room. In either case, this can also come in handy to keep an eye on your door as a security measure to check when someone arrives. + +You can find all the necessary details on Raspberry Pi’s official site. + +[The Parent Detector][7] + +#### 4\. FM Radio Station + +Raspberry Pi is an inexpensive device for making an FM radio station. The pre-requisites may not be much but is worth exploring for fun. + +Do note that you may not want to interfere with the local FM frequencies. You can find all the details to set it up by clicking the button below. + +[FM Radio Transmitter][8] + +#### 5\. Minecraft Game Sever + +![][9] + +Minecraft is a quite popular game. However, if you want a personal server, you might have to pay a premium. + +Fret not, you can use your Raspberry Pi to build a local server, create your own world and have fun with your family/friends. + +[Minecraft Game Server][10] + +#### 6\. Temperature Log + +It was something interesting I found on the official website to help you learn a few things like – how to write data to a file etc. + +Here, you will be recording the temperature using the sensor present. + +For this, you will be utilizing the command-line to monitor the temperature of Raspberry Pi. + +[Temperature Log][11] + +#### 7\. Retro Gaming Console + +You can turn your Raspberry Pi into a gaming console by simply installing an OS on an SD card and transfer a few files to it. + +We also have an article on how you can [turn your old PC into a Retrogaming console][12] if you are curious. + +I have linked a resource to help you make this project in the button below: + +[Retro Gaming Console][13] + +#### 8\. Full-Fledged Desktop + +![][14] + +If you do not want to invest a lot to build a PC, you can easily utilize your Raspberry Pi to build one. + +Technically, your Raspberry Pi will be the heart of your PC and you will need to add accessories (monitor, keyboard, mouse, etc) to turn it into a PC. You can also choose to build a custom case for the board if you want – which is totally optional. + +Obviously, the PC won’t be powerful enough for all kinds of tasks – but it will be usable. You can also check out the experience of having [Raspberry Pi 4 as a desktop replacement][15] on their official website as a reference to this project. + +[Full-Fledged Desktop][16] + +**Intermediate Level Raspberry Pi Project Ideas** + +#### 9\. Build a LAMP Web Server with WordPress + +If you are into web development, you can try setting up a LAMP (Linux + Apache + MySQL + PHP) server and install WordPress to create a website. You can also choose to make something else from scratch without installing WordPress. + +You will be able to access the site on any device on the same network as your Raspberry Pi. + +[Build a LAMP Web Server][17] + +#### 10\. Laser Tripwire + +It is a similar concept to the parent detector that uses a motion sensor. In this case, a laser beam is used to detect activity whenever someone breaks the beam. + +You just need a few things to set up the alarm and complete the tripwire. Of course, this is a simple project to start with that has potentially different applications. + +[Laser Tripwire][18] + +#### 11\. Print Server + +What if you can turn your old printer to work on a network of devices even without requiring a built-in WiFi feature? + +Well, that’s what this project is about. You will be able to access your printer from multiple devices using a print server. Check out all the details to help build one by clicking the button below. + +[Raspberry Pi Print Server][19] + +#### 12\. Time Lapse Camera + +Looking for a cheap dedicated time-lapse camera? Well, you can do it yourself with a Raspberry Pi. + +You can use the Pi camera module or explore other options as well. + +[Time-Lapse Camera][20] + +#### 13\. Music Box + +You can build a button-controlled music box using Raspberry Pi to have a great time with your kids or anyone who loves music. + +When you press a button, it will play a sound. You can find the short description of the project in the video above, for more details click on the button below. + +[Music Box][21] + +#### 14\. Google Home On Raspberry Pi + +If you could configure and set up Google Assistant on your Raspberry Pi, you can turn it into an inexpensive Google Home DIY alternative, right? + +Fortunately, you can achieve that with your Raspberry Pi. Find out more about it in the video above. + +#### 15\. Build Smart TV Box + +If you know how to set up a media server on Raspberry Pi (as mentioned in the first project idea of this article), you can make this happen too. + +With the help of the Kodi box (or similar), you can build your own personal smart TV box powered by the media server of your choice. + +[Smart TV Box][22] + +#### 16\. Add Gesture Controls To Raspberry Pi + +You can add the ability to have gesture controls for any of your projects on Raspberry Pi using a [Flick board][23]. + +It may not be the cheapest project but it is an impressive touch for your Raspberry Pi project. + +[Gesture Controls][23] + +**Advanced Level Raspberry Pi Project Ideas** + +#### 17\. Tor Router + +If you are someone who wants to explore ways to enhance your personal digital privacy, you can start by building your own local Tor onion router. + +With this, you can scramble your Internet connection and remain anonymous with your browsing activities. It is just something like a VPN but technically different. + +[Tor Router][24] + +#### 18\. Control LEDs with your voice + +![][25] + +This is quite interesting. I have already mentioned a project where you can set up Google Assistant on your Raspberry Pi. However, in this case, you will be able to control the LEDs with your voice. + +You will not need the assistant this time, all you need is the [Google AIY voice kit][26]. This has been featured on the list of official DIY projects using Raspberry Pi, you can get more information there. + +[Control LEDs With Voice][27] + +#### 19\. WiFi Extender + +If you want to increase the range of your WiFi network, you might have to opt for a premium gadget that can help you do that or you can utilize Raspberry Pi to get the job done. + +Yes, that’s right, you can build a WiFi extender by just using your Raspberry Pi. + +[WiFi Extender][28] + +#### 20\. VPN Server + +You do not need to trust the VPN providers if you can build your own local VPN server. It can be quite challenging to make it happen. + +So, if you are up for some action, you can use your Raspberry Pi to make a private VPN server for your connection. Explore more about it here: + +[VPN Server][29] + +#### 21\. Home Automation Using Raspberry Pi + +A lot of powerful projects can be done using the Raspberry Pi, one of which is – ‘Home Automation’. + +If I want to implement home automation, it will be expensive. But, if I end up using Raspberry Pi to create something similar, it will require less investment. Of course, you will have to explore and improve to make it a reliable system but you can get started with the basics. + +[Home Automation][30] + +#### 22\. Local Cloud Server + +You can also build your own cloud using Raspberry Pi. You can also install Nextcloud on it to protect and store your data. + +A lot of exciting things to explore once you have your own cloud, right? + +[Local Cloud Server][31] + +#### 23\. Portable Hacking Device + +Let me make one thing clear, I am not encouraging you to do something illegal (just like the movies) by building a portable hacking device. + +So, just for educational/testing purposes, feel free to try making your own portable device for hacking using Raspberry Pi. + +[Portable Hacking Device][32] + +#### 24\. Smart Gloves + +Making a pair of smart gloves is really a cool project with Raspberry Pi. In my college days, I witnessed a senior make this thing, it was interesting. + +You can refer to the official resource for this project and get started. + +[Smart Gloves][33] + +#### 25\. Ad Blocker + +With Raspberry Pi, you can easily implement a network-wide Adblocker so that you won’t have to install adblockers separately on devices or browsers. + +You need to utilize Pi-Hole (the ad blocker) to set it up. Check out the video above and the official resource through the button below. + +[Ad Blocker][34] + +**Wrapping Up** + +Here, I listed some of the most interesting projects that I could find that might come in handy for you. + +If you know some other cool ideas, let me know in the comments down below. I might update this list of Raspberry Pi projects with your idea. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/raspberry-pi-projects/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/raspberry-pi-alternatives/ +[2]: https://itsfoss.com/best-linux-media-server/ +[3]: https://www.raspberrypi.org/documentation/usage/kodi/ +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/diy-weather-station.jpg?ssl=1 +[5]: https://projects.raspberrypi.org/en/projects/build-your-own-weather-station +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/parents-detector-pi.png?ssl=1 +[7]: https://projects.raspberrypi.org/en/projects/parent-detector +[8]: https://circuitdigest.com/microcontroller-projects/raspberry-pi-fm-transmitter +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/minecraft-game-server.jpg?ssl=1 +[10]: https://www.makeuseof.com/tag/setup-minecraft-server-raspberry-pi/ +[11]: https://projects.raspberrypi.org/en/projects/temperature-log +[12]: https://itsfoss.com/lakka-retrogaming-linux/ +[13]: https://lifehacker.com/how-to-turn-your-raspberry-pi-into-a-retro-game-console-498561192 +[14]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/raspberry-pi-desktop.jpg?ssl=1 +[15]: https://www.raspberrypi.org/blog/raspberry-pi-4-a-full-desktop-replacement/ +[16]: https://www.makeuseof.com/tag/use-your-raspberry-pi-like-a-desktop-pc/ +[17]: https://projects.raspberrypi.org/en/projects/lamp-web-server-with-wordpress +[18]: https://projects.raspberrypi.org/en/projects/laser-tripwire +[19]: https://circuitdigest.com/microcontroller-projects/raspberry-pi-print-server +[20]: https://projects.raspberrypi.org/en/projects/raspberry-pi-zero-time-lapse-cam +[21]: https://projects.raspberrypi.org/en/projects/gpio-music-box +[22]: https://www.modmy.com/kodi-box-guide +[23]: https://magpi.raspberrypi.org/articles/flick-hat-swipe-gestures-raspberry-pi +[24]: https://magpi.raspberrypi.org/articles/tor-router +[25]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/control-led-voice-raspberry-pi.jpg?fit=800%2C450&ssl=1 +[26]: https://aiyprojects.withgoogle.com/voice +[27]: https://projects.raspberrypi.org/en/projects/google-voice-aiy/ +[28]: https://pimylifeup.com/raspberry-pi-wifi-extender/ +[29]: https://www.comparitech.com/blog/vpn-privacy/raspberry-pi-vpn/ +[30]: https://circuitdigest.com/microcontroller-projects/iot-raspberry-pi-home-automation +[31]: https://opensource.com/article/18/9/host-cloud-nas-raspberry-pi +[32]: https://www.hackster.io/mehedishakeel/portable-hacking-machine-kali-linux-raspberry-pi-touch-18b7c3 +[33]: https://www.raspberrypi.org/blog/raspberry-pi-glove/ +[34]: https://www.raspberrypi.org/blog/pi-hole-raspberry-pi/ diff --git a/sources/tech/20191125 Challenge- Write a bouncy window manager.md b/sources/tech/20191125 Challenge- Write a bouncy window manager.md new file mode 100644 index 0000000000..601e231f53 --- /dev/null +++ b/sources/tech/20191125 Challenge- Write a bouncy window manager.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Challenge: Write a bouncy window manager) +[#]: via: (https://jvns.ca/blog/2019/11/25/challenge--make-a-bouncy-window-manager/) +[#]: author: (Julia Evans https://jvns.ca/) + +Challenge: Write a bouncy window manager +====== + +Hello! I’m writing a short series of programming challenges with [Julian][1], and this is the first one! + +### the challenge + +![][2] + +**requirements** + +The goal here is to make a very silly Linux window manager that bounces its windows around the screen, like in the gif above. + +**anti-requirements** + +The window manager doesn’t need to do anything else! It doesn’t need to support: + + * moving or resizing windows + * switching between windows + * minimizing windows + * literally any of the other things you might normally expect a window manager to do + + + +It turns out implementing this kind of toy window manager is surprisingly approachable! + +### the setup: start with tinywm + +All the instructions here only work on Linux (since this is about writing a Linux window manager). + +**starter kit: tinywm** + +Writing a window manager from scratch seems intimidating (at first I didn’t even know how to start!). But then I found **[tinywm][3]**, which is a tiny window manager written in only **50 lines of C**. This is a GREAT starting point and there’s an annotated version of the source code which explains a lot of the details. There’s a Python version of tinywm too, but I wasn’t able to get it to work. + +I did this challenge by modifying [tinywm][3] and it worked really well. + +**tools** + + * **Xephyr** lets you embed an X session in a window in your regular desktop, so that you can develop your toy window manager without breaking your usual desktop. I ran it like this: `Xephyr -ac -screen 1280x1024 -br -reset -terminate 2> /dev/null :1 &` + * You can start an xterm in the Xephyr desktop with `xterm -display :1` + * I compiled my window manager with `gcc bouncewm.c -g -o bouncewm -lX11` and ran it with `env DISPLAY=:1 ./bouncewm` + * **xtrace** lets you trace all requests to the X windows system that your window manager is making. I found it really helpful when debugging. (run it like `xtrace ./bouncewm`) + + + +**documentation** + +Some useful references: + + * the [dwm source code][4] (dwm is a 2000-line-of-C window manager) + * the [Xlib programming manual][5] + + + +If you’re not comfortable writing C, there are also libraries that let you work with X in other languages. I personally found C easier to use because a lot of the window manager documentation and examples I found were for the Xlib C library. + +### my experience: 5 hours, 50 lines of code + +To give you a very rough idea of the difficulty of this exercise: I did this in 4 or 5 hours this morning and last night, producing the window manager you see in the gif at the top of the blog post (which is 50 lines of code). I’d never looked at the source code for a window manager before yesterday. + +As usual when working with a new library I spent most of that time being confused about various basic things about how X works. (and as a result I learned several new things about X!) + +For me this challenge was a fun way to: + + * learn some basics about the X window system protocol (I’ve been using window managers for 15 years, today I got to write one!) + * research an unfamiliar library (“ooh, what does this function do?”) + * use a C library, since I don’t usually write C + + + +### send me your solution if you do this! + +I’ll post the solution I came up in a week. If you think this window manager challenge sounds fun and end up doing it, I’d love it if you sent me your solution (to [[email protected]][6])! + +I’d be delighted to post any solutions you send me in the solutions blog post. + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/11/25/challenge--make-a-bouncy-window-manager/ + +作者:[Julia Evans][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://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: http://www.cipht.net/2017/10/03/are-jump-tables-always-fastest.html +[2]: https://jvns.ca/images/bouncewm.gif +[3]: http://incise.org/tinywm.html +[4]: https://git.suckless.org/dwm/file/dwm.c.html +[5]: https://tronche.com/gui/x/xlib/ +[6]: https://jvns.ca/cdn-cgi/l/email-protection diff --git a/sources/tech/20191125 How to use loops in awk.md b/sources/tech/20191125 How to use loops in awk.md new file mode 100644 index 0000000000..cf7abb6f62 --- /dev/null +++ b/sources/tech/20191125 How to use loops in awk.md @@ -0,0 +1,162 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to use loops in awk) +[#]: via: (https://opensource.com/article/19/11/loops-awk) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +How to use loops in awk +====== +Learn how to use different types of loops to run commands on a record +multiple times. +![arrows cycle symbol for failing faster][1] + +Awk scripts have three main sections: the optional BEGIN and END functions and the functions you write that are executed on each record. In a way, the main body of an awk script is a loop, because the commands in the functions run for each record. However, sometimes you want to run commands on a record more than once, and for that to happen, you must write a loop. + +There are several kinds of loops, each serving a unique purpose. + +### While loop + +A **while** loop tests a condition and performs commands _while_ the test returns _true_. Once a test returns _false_, the loop is broken. + + +``` +#!/bin/awk -f + +BEGIN { +        # Print the squares from 1 to 10 + +    i=1; +    while (i <= 10) { +        print "The square of ", i, " is ", i*i; +        i = i+1; +    } +exit; +} +``` + +In this simple example, awk prints the square of whatever integer is contained in the variable _i_. The **while (i <= 10)** phrase tells awk to perform the loop only as long as the value of _i_ is less than or equal to 10. After the final iteration (while _i_ is 10), the loop ends. + +### Do while loop + +The **do while** loop performs commands after the keyword **do**. It performs a test afterward to determine whether the stop condition has been met. The commands are repeated only _while_ the test returns true (that is, the end condition has _not_ been met). If a test fails, the loop is broken because the end condition has been met. + + +``` +#!/usr/bin/awk -f +BEGIN { + +        i=2; +        do { +                print "The square of ", i, " is ", i*i; +                i = i + 1 +        } +        while (i < 10) + +exit; +} +``` + +### For loops + +There are two kinds of **for** loops in awk. + +One kind of **for** loop initializes a variable, performs a test, and increments the variable together, performing commands while the test is true. + + +``` +#!/bin/awk -f + +BEGIN { +    for (i=1; i <= 10; i++) { +        print "The square of ", i, " is ", i*i; +    } +exit; +} +``` + +Another kind of **for** loop sets a variable to successive indices of an array, performing a collection of commands for each index. In other words, it uses an array to "collect" data from a record. + +This example implements a simplified version of the Unix command **uniq**. By adding a list of strings into an array called **a** as a key and incrementing the value each time the same key occurs, you get a count of the number of times a string appears (like the **\--count** option of **uniq**). If you print the keys of the array, you get every string that appears one or more times. + +For example, using the demo file **colours.txt** (from the previous articles): + + +``` +name       color  amount +apple      red    4 +banana     yellow 6 +raspberry  red    99 +strawberry red    3 +grape      purple 10 +apple      green  8 +plum       purple 2 +kiwi       brown  4 +potato     brown  9 +pineapple  yellow 5 +``` + +Here is a simple version of **uniq -c** in awk form: + + +``` +#! /usr/bin/awk -f + +NR != 1 { +    a[$2]++ +} +END { +    for (key in a) { +                print a[key] " " key +    } +} +``` + +The third column of the sample data file contains the number of items listed in the first column. You can use an array and a **for** loop to tally the items in the third column by color: + + +``` +#! /usr/bin/awk -f + +BEGIN { +    FS=" "; +    OFS="\t"; +    print("color\tsum"); +} +NR != 1 { +    a[$2]+=$3; +} +END { +    for (b in a) { +        print b, a[b] +    } +} +``` + +As you can see, you are also printing a header column in the BEFORE function (which always happens only once) prior to processing the file. + +### Loops + +Loops are a vital part of any programming language, and awk is no exception. Using loops can help you control how your awk script runs, what information it's able to gather, and how it processes your data. Our next article will cover switch statements, **continue**, and **next**. + +* * * + +Would you rather listen to this article? It was adapted from an episode of [Hacker Public Radio][2], a community technology podcast by hackers, for hackers. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/loops-awk + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fail_progress_cycle_momentum_arrow.png?itok=q-ZFa_Eh (arrows cycle symbol for failing faster) +[2]: http://hackerpublicradio.org/eps.php?id=2330 diff --git a/sources/tech/20191125 My top 5 Ansible modules.md b/sources/tech/20191125 My top 5 Ansible modules.md new file mode 100644 index 0000000000..9a76342854 --- /dev/null +++ b/sources/tech/20191125 My top 5 Ansible modules.md @@ -0,0 +1,74 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (My top 5 Ansible modules) +[#]: via: (https://opensource.com/article/19/11/ansible-modules) +[#]: author: (Mark Phillips https://opensource.com/users/markp) + +My top 5 Ansible modules +====== +Learn how to achieve almost anything with these Ansible modules. +![][1] + +When I was growing up, my grandfather had a shed in his garden. He would spend hours in there, making and fixing things. This was way before we had the internet, so I spent a lot of time studying him creating things in that shed. Although the shed was full of many tools, from drills to lathes to electrical gubbins and lots of things I doubt I could identify even today, he made use of only a tiny subset of what he had at hand. Yet there never seemed to be limits to what he could achieve. + +I tell you that story because I feel like my career has been spent in a metaphorical shed. Computers are so many tools, all in a small (virtual?) space. And there are tool sheds within tool sheds—my favourite being Ansible. The recent 2.9 release ships with 3,681 modules! **3,681!** When I first started using Ansible in the summer of 2013, version 1.2.1 had just 113 modules, yet, as [I wrote at the time][2], I could still achieve anything I imagined. + +Modules are the backbone of Ansible, the gears to make light of heavy lifting. They're designed to do one job well, thus realising [the Unix philosophy][3]. This is how we've come to bundle so many of them; Ansible as the conductor of the orchestra now has a lot of instruments at its command. + +Reviewing a Git repository of my Ansible plays and roles over the years reveals that I have used just 35 modules. This small subset was used to build large infrastructures. I wonder what could be achieved with an even smaller subset, though? As I reviewed those 35, I pondered if I could achieve the same results with only five modules at my disposal. So here are my five favourite modules, in a rather tenuous order of precedence. + +### 5. [authorized_key][4] + +Secure shell (SSH) is at the heart of Ansible, at least for almost everything besides Windows. Key (no pun intended) to using SSH efficiently with Ansible is… [keys][5]! Slight aside—there are a lot of very cool things you can do for security with SSH keys. It's worth perusing the **authorized_keys** section of the [sshd manual page][6]. Managing SSH keys can become laborious if you're getting into the realms of granular user access, and although we could do it with either of my next two favourites, I prefer to use the module because it [enables easy management through variables][7]. + +### 4. [file][8] + +Besides the obvious function of placing a file somewhere, the **file** module also sets ownership and permissions. I'd say that's a lot of _bang for your buck_ with one module. I'd proffer a substantial portion of security relates to setting permissions too, so the **file** module plays nicely with **authorized_keys**. + +### 3. [template][9] + +There are so many ways to manipulate the contents of files, and I see lots of folk use **[lineinfile][10]**. I've used it myself for small tasks. However, the **template** module is so much clearer because you maintain the entire file for context. My preference is to write Ansible content in such a way that anyone can understand it _easily_—which to me means not making it hard to understand what is happening. Use of **template** means being able to see the entire file you're putting into place, complete with the variables you are using to change pieces. + +### 2. [uri][11] + +Many modules in the current distribution leverage Ansible as an orchestrator. They talk to another service, rather than doing something specific like putting a file into place. Usually, that talking is over HTTP too. In the days before many of these modules existed, you _could_ program an API directly using the **uri** module. It's a powerful access tool, enabling you to do a lot. I wouldn't be without it in my fictitious Ansible shed. + +### 1. [shell][12] + +The joker card in our pack. The Swiss Army Knife. If you're absolutely stuck for how to control something else, use **shell**. Some will argue we're now talking about making Ansible a Bash script—but, I would say it's still better because with the use of the **name** parameter in your plays and roles, you document every step. To me, that's as big a bonus as anything. Back in the days when I was still consulting, I once helped a database administrator (DBA) migrate to Ansible. The DBA wasn't one for change and pushed back at changing working methods. So, to ease into the Ansible way, we called some existing DB management scripts from Ansible using the **shell** module. With an informative **name** statement to accompany the task. + +You can achieve a lot with these five modules. Yes, modules designed to do a specific task will make your life even easier. But with a smidgen of engineering simplicity, you can achieve a lot with very little. Ansible developer Brian Coca is a master at it, and [his tips and tricks talk][13] is always worth a watch. + +* * * + +What do you think about my top five? What five modules would you pick and why, if you were so limited? Let me know in the comments below! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/ansible-modules + +作者:[Mark Phillips][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/markp +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/mandelbrot_set.png?itok=bmPc0np5 +[2]: http://probably.co.uk/post/puppet-vs-chef-vs-ansible/ +[3]: https://en.wikipedia.org/wiki/Unix_philosophy#Do_One_Thing_and_Do_It_Well +[4]: https://docs.ansible.com/ansible/latest/modules/authorized_key_module.html +[5]: https://linux.die.net/man/1/ssh-keygen +[6]: https://linux.die.net/man/8/sshd +[7]: https://github.com/phips/ansible-demos/blob/3bf59df1eb2390b31b5c42333197e2fbb7fec93f/roles/ansible-users/tasks/main.yml#L35 +[8]: https://docs.ansible.com/ansible/latest/modules/file_module.html +[9]: https://docs.ansible.com/ansible/latest/modules/template_module.html +[10]: https://docs.ansible.com/ansible/latest/modules/lineinfile_module.html +[11]: https://docs.ansible.com/ansible/latest/modules/uri_module.html +[12]: https://docs.ansible.com/ansible/latest/modules/shell_module.html +[13]: https://www.ansible.com/ansible-tips-and-tricks diff --git a/sources/tech/20191125 The many faces of awk.md b/sources/tech/20191125 The many faces of awk.md new file mode 100644 index 0000000000..0d498605f8 --- /dev/null +++ b/sources/tech/20191125 The many faces of awk.md @@ -0,0 +1,234 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (The many faces of awk) +[#]: via: (https://www.networkworld.com/article/3454979/the-many-faces-of-awk.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +The many faces of awk +====== +The awk command provides a lot more than simply selecting fields from input strings, including pulling out columns of data, printing simple text, evaluating content – even doing math. +Thinkstock + +If you only use **awk** when you need to select a specific field from lines of text, you might be missing out on a lot of other services that the command can provide. In this post, we'll look at this simple use along with some of the other things that **awk** can do for you and provide some examples. + +### Plucking out columns of data + +The easiest and most commonly used service that **awk** provides is selecting specific fields from files or from data that is piped to it. With the default of using white space as a field separator, this is very simple. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][1] + +``` +$ echo one two three four five | awk ‘{print $4}’ +four +$ who | awk ‘{print $1}’ +jdoe +fhenry +``` + +White space is any sequence of blanks and tabs. In the commands shown above, **awk** is extracting just the fourth and first fields from the data provided. + +[][2] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][2] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +Awk can also pull text from files by just adding the name of the file after the **awk** command. + +``` +$ awk '{print $1,$5,$NF}' HelenKellerQuote +The beautiful heart. +``` + +In this case, **awk** has picked out the first, fifth and last words in the single line of test. + +The **$NF** specification in the command picks the last piece of text on each line. That is because **NF** represents the number of fields in a line (23) while **$NF** then represents the _value_ of that field ("heart."). The period is included because it's part of the final text string. + +Fields can be printed in any order that you might find useful. In this example, we are rearranging the fields in **date** command output. + +``` +$ date | awk '{print $4,$3,$2}' +2019 Nov 22 +``` + +If you omit the commas between the field designators in an **awk** command, the output will be pushed into a single string. + +``` +$ date | awk '{print $4 $3 $2}' +2019Nov21 +``` + +If you replace the usual commas with hyphens, **awk** will attempt to subtract one field from another – probably not what you intended. It doesn't take the hyphens as characters to be inserted into the print output. Instead, it puts some of its mathematical prowess into play. + +``` +$ date | awk '{print $4-$3-$2}' +1997 +``` + +In this case, it's subtracting 22 (the day of the month) from the year (2019) and simply ignoring "Nov". + +If you want your output to be separated by something other than white space, you can specify your output separator with **OFS** (output field separator) like this: + +``` +$ date | awk '{OFS="-"; print $4,$3,$2}' +2019-Nov-22 +``` + +### Printing simple text + +You can also use **awk** to simply display some text. Of course, if all you want to do is print a line of text, you'd be better off using an **echo** command. On the other hand, as part of an **awk** script, printing some relevant text can be very useful. Here's a practically useless example: + +``` +$ awk 'BEGIN {print "Hello, World" }' +Hello, World +``` + +Here's a more sensible example in which adding a line of text to label your data can help identify what you're looking at: + +``` +$ who | awk 'BEGIN {print "Current logins:"} {print $1}' +Current logins: +shs +nemo +``` + +### Specifying a field separator + +Not all input is going to be separated by white space. If your text is separated by some other character (e.g., commas, colons or semicolons), you can inform **awk** by using the **-F** (input separator) option as shown here: + +``` +$ cat testfile +a:b:c,d:e +$ awk -F : '{print $2,$3}' testfile +b c,d +``` + +Here's a more useful example – pulling a field from the colon-separated **/etc/passwd** file: + +``` +$ awk -F: '{print $1}' /etc/passwd | head -11 +root +daemon +bin +sys +sync +games +man +lp +mail +news +uucp +``` + +### Evaluating content + +You can also evaluate fields using **awk**. If you, for example, want to list only _user accounts_ in **/etc/passwd**, you can include a test for the 3rd field. Here we're only going after UIDs that are 1000 and above: + +``` +$ awk -F":" ' $3 >= 1000 ' /etc/passwd +nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin +shs:x:1000:1000:Sandra Henry-Stocker,,,:/home/shs:/bin/bash +nemo:x:1001:1001:Nemo,,,:/home/nemo:/usr/bin/zsh +dory:x:1002:1002:Dory,,,:/home/dory:/bin/bash +... +``` + +If you want to add a title for your listing, you can add a BEGIN clause: + +``` +$ awk -F":" 'BEGIN {print "user accounts:"} $3 >= 1000 ' /etc/passwd +user accounts: +nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin +shs:x:1000:1000:Sandra Henry-Stocker,,,:/home/shs:/bin/bash +nemo:x:1001:1001:Nemo,,,:/home/nemo:/usr/bin/zsh +dory:x:1002:1002:Dory,,,:/home/dory:/bin/bash +``` + +If you want more than one line in your title, you can separate your intended output lines with "\n" (newline characters). + +``` +$ awk -F":" 'BEGIN {print "user accounts\n============="} $3 >= 1000 ' /etc/passwd +user accounts +============= +nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin +shs:x:1000:1000:Sandra Henry-Stocker,,,:/home/shs:/bin/bash +nemo:x:1001:1001:Nemo,,,:/home/nemo:/usr/bin/zsh +dory:x:1002:1002:Dory,,,:/home/dory:/bin/bash +``` + +### Doing math with awk + +**awk** provides a surprising mathematical ability and can calculate square roots, logs, tangents, etc. + +Here are a couple examples: + +``` +$ awk 'BEGIN {print sqrt(2019)}' +44.9333 +$ awk 'BEGIN {print log(2019)}' +7.61036 +``` + +For more details on **awk**'s mathematical skills, check out [Doing math with awk][3]. + +### awk scripts + +You can also write standalone scripts with **awk**. Here's an example that mimics one of the examples provided earlier, but also counts the number of users with accounts on the system. + +``` +#!/usr/bin/awk -f + +# This line is a comment + +BEGIN { + printf "%s\n","User accounts:" + print "==============" + FS=":" + n=0 +} + +# Now we'll run through the data +{ + if ($3 >= 1000) { + print $1 + n ++ + } +} + +END { + print "==============" + print n " accounts" +} +``` + +Notice how the BEGIN section, which is run only when the script starts, provides a heading, dictates the field separator and sets up a counter to start with 0. The script also includes an END section which only runs after all the lines in the text provided to the script have been processed. It displays the final count of lines that meet the specification in the middle section (third field is 1,000 or larger) + +A long-standing Unix command, **awk** still provides very useful services and remains one of the reasons that I fell in love with Unix many decades ago. + +To see **awk** in action, click below. + +Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3454979/the-many-faces-of-awk.html + +作者:[Sandra Henry-Stocker][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.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.networkworld.com/article/2974753/doing-math-with-awk.html +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md b/sources/tech/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md new file mode 100644 index 0000000000..866d5df482 --- /dev/null +++ b/sources/tech/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md @@ -0,0 +1,275 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (5 Commands to Find the IP Address of a Domain in the Linux Terminal) +[#]: via: (https://www.2daygeek.com/linux-command-find-check-domain-ip-address/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +5 Commands to Find the IP Address of a Domain in the Linux Terminal +====== + +This tutorial shows you how to verify a domain name’s or computer name IP address from a Linux terminal. + +This tutorial will allow you to check multiple domains at once. + +You may have already used these commands to verify information. + +However, we will teach you how to use these commands effectively to identify multiple domain IP address information from the Linux terminal. + +This can be done using the following 5 commands. + + * **dig Command:** dig is a flexible cli tool for interrogating DNS name servers. + * **host Command:** host is a simple utility for performing DNS lookups. + * **nslookup Command:** Nslookup command is used to query Internet domain name servers. + * **fping Command:** fping command is used to send ICMP ECHO_REQUEST packets to network hosts. + * **ping Command:** ping command is used to send ICMP ECHO_REQUEST packets to network hosts. + + + +To test this, we created a file called “domains-list.txt” and added the below domains. + +``` +# vi /opt/scripts/domains-list.txt + +2daygeek.com +magesh.co.in +linuxtechnews.com +``` + +### Method-1: How to Find a IP Address of the Domain Using the dig Command + +**[dig command][1]** stands for “domain information groper”‘ is a powerful and flexible command-line tool for querying DNS name servers. + +It performs DNS lookups and displays the answers that are returned from the name server(s) that were queried. + +Most DNS administrators use dig command to troubleshoot DNS problems because of its flexibility, ease of use and clarity of output. + +It also has a batch mode functionality to read search requests from a file. + +``` +# dig 2daygeek.com | awk '{print $1,$5}' + +2daygeek.com. 104.27.157.177 +2daygeek.com. 104.27.156.177 +``` + +Use the following bash script to find the multiple domain’s IP address. + +``` +# vi /opt/scripts/dig-command.sh + +#!/bin/bash +for server in `cat /opt/scripts/domains-list.txt` +do echo $server "-" +dig $server +short +done | paste -d " " - - - +``` + +Once the above script is added to a file. Set the executable permission for the “dig-command.sh” file. + +``` +# chmod +x /opt/scripts/dig-command.sh +``` + +Finally run the bash script to get the output. + +``` +# sh /opt/scripts/dig-command.sh + +2daygeek.com - 104.27.156.177 104.27.157.177 +magesh.co.in - 104.18.35.52 104.18.34.52 +linuxtechnews.com - 104.27.144.3 104.27.145.3 +``` + +If you want to run the above script in one line, use the following script. + +``` +# for server in 2daygeek.com magesh.co.in linuxtechnews.com; do echo $server "-"; dig $server +short; done | paste -d " " - - - +``` + +Alternatively, you can use the following shell script to find the IP address of the multiple domain. + +``` +# for server in 2daygeek.com magesh.co.in linuxtechnews.com; do dig $server | awk '{print $1,$5}'; done + +2daygeek.com. 104.27.157.177 +2daygeek.com. 104.27.156.177 +magesh.co.in. 104.18.34.52 +magesh.co.in. 104.18.35.52 +linuxtechnews.com. 104.27.144.3 +linuxtechnews.com. 104.27.145.3 +``` + +### Method-2: How to Find a Domain’s IP Address Using the host Command + +**[Host Command][2]** is a simple CLI application to perform **[DNS lookup][3]**. + +It is commonly used to convert names to IP addresses and vice versa. + +When no arguments or options are given, host prints a short summary of its command line arguments and options. + +You can view all types of records in the domain by adding a specific option or type of record in the host command. + +``` +# host 2daygeek.com | grep "has address" | sed 's/has address/-/g' + +2daygeek.com - 104.27.157.177 +2daygeek.com - 104.27.156.177 +``` + +Use the following bash script to find the multiple domain’s IP address. + +``` +# vi /opt/scripts/host-command.sh + +for server in `cat /opt/scripts/domains-list.txt` +do host $server | grep "has address" | sed 's/has address/-/g' +done +``` + +Once the above script is added to a file. Set the executable permission for the “host-command.sh” file. + +``` +# chmod +x /opt/scripts/host-command.sh +``` + +Finally run the bash script to get the output. + +``` +# sh /opt/scripts/host-command.sh + +2daygeek.com - 104.27.156.177 +2daygeek.com - 104.27.157.177 +magesh.co.in - 104.18.35.52 +magesh.co.in - 104.18.34.52 +linuxtechnews.com - 104.27.144.3 +linuxtechnews.com - 104.27.145.3 +``` + +### Method-3: How to Find the IP Address of a Domain Using the nslookup Command + +**[nslookup command][4]** is a program for querying Internet **[domain name servers (DNS)][5]**. + +nslookup has two modes, which are interactive and interactive. + +Interactive mode allows the user to query name servers for information about various hosts and domains or to print a list of hosts in a domain. + +Non-interactive mode is used to print just the name and requested information for a host or domain. + +It is a network administration tool that helps diagnose and resolve DNS related issues. + +``` +# nslookup -q=A 2daygeek.com | tail -n+4 | sed -e '/^$/d' -e 's/Address://g' | grep -v 'Name|answer' | xargs -n1 + +104.27.157.177 +104.27.156.177 +``` + +Use the following bash script to find the multiple domain’s IP address. + +``` +# vi /opt/scripts/nslookup-command.sh + +#!/bin/bash +for server in `cat /opt/scripts/domains-list.txt` +do echo $server "-" +nslookup -q=A $server | tail -n+4 | sed -e '/^$/d' -e 's/Address://g' | grep -v 'Name|answer' | xargs -n1 done | paste -d " " - - - +``` + +Once the above script is added to a file. Set the executable permission for the “nslookup-command.sh” file. + +``` +# chmod +x /opt/scripts/nslookup-command.sh +``` + +Finally run the bash script to get the output. + +``` +# sh /opt/scripts/nslookup-command.sh + +2daygeek.com - 104.27.156.177 104.27.157.177 +magesh.co.in - 104.18.35.52 104.18.34.52 +linuxtechnews.com - 104.27.144.3 104.27.145.3 +``` + +### Method-4: How to Find a Domain’s IP Address Using the fping Command + +**[fping command][6]** is a program such as ping, which uses the Internet Control Message Protocol (ICMP) echo request to determine whether a target host is responding. + +fping differs from ping because it allows users to ping any number of host in parallel. Also, hosts can be entered from a text file. + +fping sends an ICMP echo request, moves the next target in a round-robin fashion, and does not wait until the target host responds. + +If a target host replies, it is noted as active and removed from the list of targets to check; if a target does not respond within a certain time limit and/or retry limit it is designated as unreachable. + +``` +# fping -A -d 2daygeek.com magesh.co.in linuxtechnews.com + +104.27.157.177 (104.27.157.177) is alive +104.18.35.52 (104.18.35.52) is alive +104.27.144.3 (104.27.144.3) is alive +``` + +### Method-5: How to Find the IP Address of the Domain Using the ping Command + +**[ping command][6]** stands for (Packet Internet Groper) command is a networking utility that used to test the target of a host availability/connectivity on an Internet Protocol (IP) network. + +It’s verify a host availability by sending Internet Control Message Protocol (ICMP) Echo Request packets to the target host and waiting for an ICMP Echo Reply. + +It summarize statistical results based on the packets transmitted, packets received, packet loss, typically including the min/avg/max times. + +``` +# ping -c 2 2daygeek.com | head -2 | tail -1 | awk '{print $5}' | sed 's/[(:)]//g' + +104.27.157.177 +``` + +Use the following bash script to find the multiple domain’s IP address. + +``` +# vi /opt/scripts/ping-command.sh + +#!/bin/bash +for server in `cat /opt/scripts/domains-list.txt` +do echo $server "-" +ping -c 2 $server | head -2 | tail -1 | awk '{print $5}' | sed 's/[(:)]//g' +done | paste -d " " - - +``` + +Once the above script is added to a file. Set the executable permission for the “dig-command.sh” file. + +``` +# chmod +x /opt/scripts/ping-command.sh +``` + +Finally run the bash script to get the output. + +``` +# sh /opt/scripts/ping-command.sh + +2daygeek.com - 104.27.156.177 +magesh.co.in - 104.18.35.52 +linuxtechnews.com - 104.27.144.3 +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-command-find-check-domain-ip-address/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/dig-command-check-find-dns-records-lookup-linux/ +[2]: https://www.2daygeek.com/linux-host-command-check-find-dns-records-lookup/ +[3]: https://www.2daygeek.com/category/dns-lookup/ +[4]: https://www.2daygeek.com/nslookup-command-check-find-dns-records-lookup-linux/ +[5]: https://www.2daygeek.com/check-find-dns-records-of-domain-in-linux-terminal/ +[6]: https://www.2daygeek.com/how-to-use-ping-fping-gping-in-linux/ diff --git a/sources/tech/20191126 App Highlight- Penguin Subtitle Player for Adding Subtitles to Online Videos.md b/sources/tech/20191126 App Highlight- Penguin Subtitle Player for Adding Subtitles to Online Videos.md new file mode 100644 index 0000000000..9907322467 --- /dev/null +++ b/sources/tech/20191126 App Highlight- Penguin Subtitle Player for Adding Subtitles to Online Videos.md @@ -0,0 +1,122 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (App Highlight: Penguin Subtitle Player for Adding Subtitles to Online Videos) +[#]: via: (https://itsfoss.com/penguin-subtitle-player/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +App Highlight: Penguin Subtitle Player for Adding Subtitles to Online Videos +====== + +I must confess. I am addicted to subtitles. It helps me understand the dialogues completely, specially if some dialogues are in a different accent or in a different language. + +This has led to a habit of watching online videos with subtitles. + +While streaming services like Netflix and Amazon Prime provide subtitles for their content, the same is not true for all the websites. + +I often discover interesting content that are on YouTube, Dailymotion or other websites. And that becomes a problem because most of the time, these videos don’t have subtitles. + +The good news is that you have the possibility to watch any online video content with subtitles and I’ll share that neat little trick with you in this article. + +### Watch any online video with subtitles using Penguin subtitle player + +![][1] + +What the heck is a Subtitle player? + +The [open source video players][2] you use allow you to add subtitles. Players like [VLC allow you to download subtitles automatically][3]. + +But they are video player and their main task is to play video. + +A subtitle player on the other hand has only one task and that is to play subtitles. Confused? Let me explain. + +A subtitle player basically provides an interface where you can add subtitle file and play the subtitles with a semi transparent background. The trick here is that this player will be visible all the time on top of any other application. + +So if you are running the subtitle player even while using a website, it will still be visible. That actually is the trick to watch any online video with subtitles. + +![An external subtitle playing on top of YouTube video][4] + +All you have to do is to find appropriate subtitles from an online website like OpenSubtitles and add it to the subtitle player. Now open the website where you want to watch the video. Play it full screen (if that option is available) and it will feel like that the subtitles are part of the video itself. + +![][5] + +#### Install Penguin subtitle player + +[Penguin][6] is a free and open source subtitle player. It is available for Linux, macOS and Windows. + +If you are using Ubuntu-based distribution, you can [use this PPA][7] to easily install Penguin subtitle player. + +``` +sudo add-apt-repository ppa:nilarimogard/webupd8 +sudo apt update +sudo apt install penguin-subtitle-player +``` + +For other Linux distributions, Windows and macOS, you can download the installer files from SourceForge: + +[Download Penguin Subtitle Player][8] + +#### Using Penguin subtitle player + +Once you have installed the application, look for it in the menu and start it. You’ll see an interface like this: + +![Penguin Subtitle Player Interface][9] + +If you have already downloaded the .srt subtitle file, you can add it to the player by clicking the folder icon. + +![Add Subtitle In Penguin Subtitle Player][10] + +You can play/pause the subtitles, skip it to a new time. This helps in adjusting the subtitles with the video. + +![Adjust Subtitle In Penguin Subtitle Player][11] + +You can also tweak the appearance of the subtitles and subtitle player. + +![Configure Penguin Subtitle Player][12] + +You also have the option to change the fonts, font size and color of the subtitle text. You may also increase or decrease the transparency and color of the background. + +![Config Options In Penguin Subtitle Player][13] + +You can also resize the subtitle player interface and move it around anywhere on the screen. + +#### Keep in mind + +There are a few things to keep in mind while using Penguin subtitle player. + +Not all video files and subtitle files are made for each other. Subtitle synchronization is a common problem so you’ll have to make sure that the subtitle you downloaded is best suited for the video you want to play. + +Most video players, even the one embedded on the websites, allow to pause and play the video with the space key. Unfortunately, there is no keyboard shortcut to pause the Penguin subtitle player. In other words, you cannot pause the video and the subtitle player in one keystroke. + +With this much configuration, you should be set for watching online videos with subtitles. + +I hope you enjoy this nifty little open source application. Do let me know whether you find it useful or not. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/penguin-subtitle-player/ + +作者:[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://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/Add_subtitle_online_videos.png?ssl=1 +[2]: https://itsfoss.com/video-players-linux/ +[3]: https://itsfoss.com/download-subtitles-automatically-vlc-media-player-ubuntu/ +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/penguin_subtitle_player.jpg?ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2015/05/Penguin_Subtitle_Player.jpg?ssl=1 +[6]: https://github.com/carsonip/Penguin-Subtitle-Player +[7]: https://itsfoss.com/ppa-guide/ +[8]: https://sourceforge.net/projects/penguinsubtitleplayer/ +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/penguin-subtitle-player-interface.jpg?ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/add_subtitle_in_penguin_subtitle_player.jpg?ssl=1 +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/adjust_subtitle_in_penguin_subtitle_player.jpg?ssl=1 +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/configure_penguin_subtitle_player.jpg?ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/config_options_in_penguin_subtitle_player.jpg?ssl=1 diff --git a/sources/tech/20191126 Calculator N- is an open source scientific calculator for your smartphone.md b/sources/tech/20191126 Calculator N- is an open source scientific calculator for your smartphone.md new file mode 100644 index 0000000000..32d467465a --- /dev/null +++ b/sources/tech/20191126 Calculator N- is an open source scientific calculator for your smartphone.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Calculator N+ is an open source scientific calculator for your smartphone) +[#]: via: (https://opensource.com/article/19/11/calculator-n-mobile) +[#]: author: (Ricardo Berlasso https://opensource.com/users/rgb-es) + +Calculator N+ is an open source scientific calculator for your smartphone +====== +The Android app does a wide range of advanced mathematical functions in +the palm of your hand. +![scientific calculator][1] + +Mobile phones are becoming more powerful every day, so it is no surprise that they can beat most computers from the not-so-distant past. This also means the tools available on them are getting more powerful every day. + +Previously, I wrote about [scientific calculators for the Linux desktop][2], and I'm following that up here with information about [Calculator N+][3], an awesome GPL v3.0-licensed computer algebra system (CAS) app for Android devices. + +Calculator N+ is presented as a "powerful calculator for Android," but that's a humble statement; the app not only works with arbitrary precision, displaying results with roots and fractions in all their glory, it does a _lot_ more. + +Finding polynomial roots? Check. Factorization? Check. Symbolic derivatives, integrals, and limits? Check. Number theory (modular arithmetic, combinatorics, prime factorization)? Check. + +You can also solve systems of equations, simplify expressions (including trigonometric ones), convert units… you name it! + +![Calculator N+ graphical interface][4] + +Results are output in LaTeX. The menu in the top-left provides many powerful functions ready to use with a simple touch. Also in that menu, you'll find Help files for all of the app's functions. At the top-right of the screen, you can toggle between exact and decimal representation. Finally, tapping the blue bar at the bottom of the screen gives you access to the whole library of functions available in the app. But be careful! If you are not a mathematician, physicist, or engineer, such a long list may seem overwhelming. + +All of this power comes from the [Symja library][5], another great GPL 3 project. + +Both projects are under active development, and they are getting better with each version. In particular, version 3.4.6 of Calculator N+ gets a major leap in user interface (UI) quality. And yes, there are still some rough corners here and there, but taming this much power in the tiny UI of a smartphone is a difficult task, and I think the app developers are solving its remaining issues quite well. Kudos to them! + +If you are a teacher, a student, or work on a STEM field, check out Calculator N+. It's free, no ads, open source, and covers all your math needs. (Except, of course, during math exams, where smartphones should never be allowed to prevent cheating.) + +Calculator N+ is available in the [Google Play Store][6], or you can [build it from source code][7] using the instructions on the GitHub page. + +If you know any other useful open source apps for science or engineering, let us know in the comments. + +The app makes use of the sensors on your phone and offers a digital science notebook to record your... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/calculator-n-mobile + +作者:[Ricardo Berlasso][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/rgb-es +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/calculator_money_currency_financial_tool.jpg?itok=2QMa1y8c (scientific calculator) +[2]: https://opensource.com/article/18/1/scientific-calculators-linux +[3]: https://github.com/tranleduy2000/ncalc +[4]: https://opensource.com/sites/default/files/uploads/calculatornplus_sqrt-frac.png (Calculator N+ graphical interface) +[5]: https://github.com/axkr/symja_android_library +[6]: https://play.google.com/store/apps/details?id=com.duy.calculator.free +[7]: https://github.com/tranleduy2000/ncalc/blob/master/README.md diff --git a/sources/tech/20191126 Make Lua development easy with Luarocks.md b/sources/tech/20191126 Make Lua development easy with Luarocks.md new file mode 100644 index 0000000000..23a636b826 --- /dev/null +++ b/sources/tech/20191126 Make Lua development easy with Luarocks.md @@ -0,0 +1,233 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Make Lua development easy with Luarocks) +[#]: via: (https://opensource.com/article/19/11/getting-started-luarocks) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Make Lua development easy with Luarocks +====== +Luarocks makes it easy to get started with Lua, a lightweight, +efficient, and embeddable scripting language. +![Coding on a computer][1] + +Bash too basic? Too much whitespace in Python? Go too corporate? + +You should try Lua, a lightweight, efficient, and embeddable scripting language supporting procedural programming, object-oriented programming, functional programming, data-driven programming, and data description. And best of all, it uses explicit syntax for scoping! + +Lua is also small. Lua's source code is just 24,000 lines of C, the Lua interpreter (on 64-bit Linux) built with all standard Lua libraries is 247K, and the Lua library is 421K. + +You might think that such a small language must be too simplistic to do any real work, but in fact Lua has a vast collection of third-party libraries (including GUI toolkits), it's used extensively in video game and film production for 3D shaders, and is a common scripting language for video game engines. To make it easy to get started with Lua, there's even a package manager called [Luarocks][2]. + +### What is Luarocks? + +Python has PIP, Ruby has Gems, Java has Maven, Node has npm, and Lua has Luarocks. Luarocks is a website and a command. The website is home to open source libraries available for programmers to add to their Lua projects. The command searches the site and installs libraries (defined as "rocks") upon demand. + +### What is a programming library? + +If you're new to programming, you might think of a "library" as just a place where books are stored. Programming libraries ("lib" or "libs" for short) are a little like a book library in the sense that both of these things contain information that someone else has already worked to discover, and which you can borrow so you have to do less work. + +For example, if you were writing code that measures how much stress a special polymer can withstand before breaking, you might think you'd have to be pretty clever with math. But if there was already an open source library specifically designed for exactly that sort of calculation, then you could include that library in your code and let it solve that problem for you (provided you give the library's internal functions the numbers it needs in order to perform an accurate calculation). + +In open source programming, you can install libraries freely and use other people's work at will. Luarocks is the mechanism for Lua that makes it quick and easy to find and use a Lua library. + +### Installing Luarocks + +The **luarocks** command isn't actually _required_ to use packages from the Luarocks website, but it does keep you from having to leave your text editor and venture onto the worldwide web [of potential distractions]. To install Luarocks, you first need to install Lua. + +Lua is available from [lua.org][3] or, on Linux, from your distribution's software repository. For example, on Fedora, CentOS, or RHEL: + + +``` +`$ sudo dnf install lua` +``` + +On Debian and Ubuntu: + + +``` +`$ sudo apt install lua` +``` + +On Windows and Mac, you can download and install Lua from the website. + +Once Lua is installed, install Luarocks. If you're on Linux, the **luarocks** command is available in your distribution's repository. + +On Mac, you can install it with [Brew][4] or compile from source: + + +``` +$ wget +$ tar zxpf luarocks-X.Y.Z.tar.gz +$ cd luarocks-X.Y.Z +$ ./configure; sudo make bootstrap +``` + +On Windows, follow the [install instructions][5] on the Luarocks wiki. + +### Search for a library with Luarocks + +The typical usage of the **luarocks** command, from the perspective of a user rather than a developer, involves searching for a library required by some Lua application you want to run and installing that library. + +To search for the Lua package **luasec** (a library providing HTTPS support for **luarocks**), try this command: + + +``` +$ luarocks search luasec +Warning: falling back to curl - +install luasec to get native HTTPS support + +Search results: +=============== + +Rockspecs and source rocks: +\--------------------------- + +luasec +   0.9-1 (rockspec) - +   0.9-1 (src) - +   0.8.2-1 (rockspec) - +[...] +``` + +### Install a library with Luarocks + +To install the **luasec** library: + + +``` +$ luarocks install --local luasec +[...] +gcc -shared -o ssl.so -L/usr/lib64 +src/config.o src/ec.o src/x509.o [...] +-L/usr/lib -Wl,-rpath,/usr/lib: -lssl -lcrypto + +luasec 0.9-1 is now installed in +/home/seth/.luarocks (license: MIT) +``` + +You can install Lua libraries locally or on a systemwide basis. A _local_ install indicates that the Lua library you install is available to you, but no other user of the computer. If you share your computer with someone else, and you each have your own [login account][6], then you probably want to install a library systemwide. However, if you're the only user of your computer, it's a good habit to install libraries locally, if only because that's the appropriate method when you develop with Lua. + +If you're _developing_ a Lua application, then you probably want to install a library to a project directory instead. In Luarocks terminology, this is a _tree_. Your default tree when installing libraries locally is **$HOME/.luarocks**, but you can redefine it arbitrarily. + + +``` +$ mkdir local +$ luarocks --tree=./local install cmark +Installing +gcc -O2 -fPIC -I/usr/include -c cmark_wrap.c [..] +gcc -O2 -fPIC -I/usr/include -c ext/blocks.c -o ext/blocks.o [..] +[...] +No existing manifest. Attempting to rebuild... +cmark 0.29.0-1 is now installed in +/home/seth/downloads/osdc/example-lua/./local +(license: BSD2) +``` + +The library (in this example, the **cmark** library) is installed to the path specified by the **\--tree** option. You can verify it by listing the contents of the destination: + + +``` +$ find ./local/ -type d -name "cmark" +./local/share/lua/5.1/cmark +./local/lib/luarocks/rocks/cmark +``` + +You can use the library in your Lua code by defining the **package.path** variable to point to your local rocks directory: + + +``` +package.path = package.path .. ';local/share/lua/5.3/?.lua' + +require("cmark") +``` + +### Getting information about an installed rock + +You can see information about an installed rock with the **show** option: + + +``` +$ luarocks show luasec +LuaSec 0.9-1 - A binding for OpenSSL library +to provide TLS/SSL communication over LuaSocket. + +This version delegates to LuaSocket the TCP +connection establishment between +the client and server. Then LuaSec uses this +connection to start a secure TLS/SSL session. + +License:        MIT +Homepage:       +Installed in:   /home/seth/.luarocks +[...] +``` + +This provides you with a summary of what a library provides from a user's perspective, displays the project homepage in case you want to investigate further, and shows you where the library is installed. In this example, it's installed in my home directory in a **.luarocks** folder. This assures me that it's installed locally, which means that if I migrate my home directory to a different computer, I'll retain my Luarocks configuration and installs. + +### Get a list of installed rocks + +You can list all installed rocks on your system with the **list** option: + + +``` +$ luarocks list + +Installed rocks: +\---------------- + +luasec +   0.9-1 (installed) - /home/seth/.luarocks/lib/luarocks/rocks + +luasocket +   3.0rc1-2 (installed) - /home/seth/.luarocks/lib/luarocks/rocks + +luce +   scm-0 (installed) - /home/seth/.luarocks/lib/luarocks/rocks + +tekui +   1.07-1 (installed) - /home/seth/.luarocks/lib/luarocks/rocks +``` + +This displays the rocks you have installed in the default install location. Developers can override this by using the **\--tree** option to redefine the active tree. + +### Remove a rock + +If you want to remove a rock, you can do that with Luarocks using the **remove** option: + + +``` +`$ luarocks remove --local cmark` +``` + +This removes a library (in this example, the **cmark** library) from your local tree. Developers can override this by using the **\--tree** option to redefine the active tree. + +If you want to remove _all_ the rocks you have installed, use the **purge** option instead. + +### Luarocks rocks + +Whether you're a user exploring exciting new Lua applications and need to install some dependencies or you're a developer using Lua to create exciting new applications, Luarocks makes your job easy. Lua is a beautiful and simple language, and Luarocks is perfectly suited to be its package manager. Give both a try today! + +Discussing Tarantool this year at the Percona Live Data Performance Conference. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/getting-started-luarocks + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: http://luarocks.org +[3]: http://lua.org +[4]: http://brew.sh +[5]: https://github.com/luarocks/luarocks/wiki/Installation-instructions-for-Windows +[6]: https://opensource.com/article/19/11/add-user-gui-linux diff --git a/sources/tech/20191127 Create virtual machines with Cockpit in Fedora.md b/sources/tech/20191127 Create virtual machines with Cockpit in Fedora.md new file mode 100644 index 0000000000..853ad5c501 --- /dev/null +++ b/sources/tech/20191127 Create virtual machines with Cockpit in Fedora.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Create virtual machines with Cockpit in Fedora) +[#]: via: (https://fedoramagazine.org/create-virtual-machines-with-cockpit-in-fedora/) +[#]: author: (Karlis KavacisPaul W. Frields https://fedoramagazine.org/author/karlisk/https://fedoramagazine.org/author/pfrields/) + +Create virtual machines with Cockpit in Fedora +====== + +![][1] + +This article shows you how to install the software you need to use Cockpit to create and manage virtual machines on Fedora 31. Cockpit is [an interactive admin interface][2] that lets you access and manage systems from any supported web browser. With [virt-manager being deprecated][3] users are encouraged to use Cockpit instead, which is meant to replace it. + +Cockpit is an actively developed project, with many plugins available that extend how it works. For example, one such plugin is “Machines,” which interacts with libvirtd and lets users create and manage virtual machines. + +### Installing software + +The required software prerequisites are _libvirt_, _cockpit_ and _cockpit-machines_. To install them on Fedora 31, run the following command from a terminal [using sudo][4]: + +``` +$ sudo dnf install libvirt cockpit cockpit-machines +``` + +Cockpit is also included as part of the “Headless Management” package group. This group is useful for a Fedora based server that you only access through a network. In that case, to install it, use this command: + +``` +$ sudo dnf groupinstall "Headless Management" +``` + +### Setting up Cockpit services + +After installing the necessary packages it’s time to enable the services. The _libvirtd_ service runs the virtual machines, while Cockpit has a socket activated service to let you access the Web GUI: + +``` +$ sudo systemctl enable libvirtd --now +$ sudo systemctl enable cockpit.socket --now +``` + +This should be enough to run virtual machines and manage them through Cockpit. Optionally, if you want to access and manage your machine from another device on your network, you need to expose the service to the network. To do this, add a new rule in your firewall configuration: + +``` +$ sudo firewall-cmd --zone=public --add-service=cockpit --permanent +$ sudo firewall-cmd --reload +``` + +To confirm the services are running and no issues occurred, check the status of the services: + +``` +$ sudo systemctl status libvirtd +$ sudo systemctl status cockpit.socket +``` + +At this point everything should be working. The Cockpit web GUI should be available at or . Or, enter the local network IP in a web browser on any other device connected to the same network. (Without SSL certificates setup, you may need to allow a connection from your browser.) + +### Creating and installing a machine + +Log into the interface using the user name and password for that system. You can also choose whether to allow your password to be used for administrative tasks in this session. + +Select _Virtual Machines_ and then select _Create VM_ to build a new box. The console gives you several options: + + * Download an OS using Cockpit’s built in library + * Use install media already downloaded on the system you’re managing + * Point to a URL for an OS installation tree + * Boot media over the network via the [PXE][5] protocol + + + +Enter all the necessary parameters. Then select _Create_ to power up the new virtual machine. + +At this point, a graphical console appears. Most modern web browsers let you use your keyboard and mouse to interact with the VM console. Now you can complete your installation and use your new VM, just as you would [via virt-manager in the past][6]. + +* * * + +_Photo by [Miguel Teixeira][7] on [Flickr][8] (CC BY-SA 2.0)._ + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/create-virtual-machines-with-cockpit-in-fedora/ + +作者:[Karlis KavacisPaul W. Frields][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/karlisk/https://fedoramagazine.org/author/pfrields/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/11/create-vm-cockpit-816x345.jpg +[2]: https://cockpit-project.org/ +[3]: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/8.0_release_notes/rhel-8_0_0_release#virtualization_4 +[4]: https://fedoramagazine.org/howto-use-sudo/ +[5]: https://en.wikipedia.org/wiki/Preboot_Execution_Environment +[6]: https://fedoramagazine.org/full-virtualization-system-on-fedora-workstation-30/ +[7]: https://flickr.com/photos/miguelteixeira/ +[8]: https://flickr.com/photos/miguelteixeira/2964851828/ diff --git a/sources/tech/20191127 How to Manage Remote Windows Host using Ansible.md b/sources/tech/20191127 How to Manage Remote Windows Host using Ansible.md new file mode 100644 index 0000000000..fa82225b79 --- /dev/null +++ b/sources/tech/20191127 How to Manage Remote Windows Host using Ansible.md @@ -0,0 +1,233 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Manage Remote Windows Host using Ansible) +[#]: via: (https://www.linuxtechi.com/manage-windows-host-using-ansible/) +[#]: author: (James Kiarie https://www.linuxtechi.com/author/james/) + +How to Manage Remote Windows Host using Ansible +====== + +**Ansible** is increasingly becoming the go-to platform for application deployment, and software provisioning among developers owing to its ease of use and flexibility. Furthermore, it is easy to set up and no agent is required to be installed on remote nodes, instead, Ansible uses password less SSH authentication to manage remote Unix/Linux hosts. In this topic, however, we are going to see how you can manage Windows Host using Ansible. + +[![Manage-Windows-Hosts-using-Ansible][1]][2] + +**Lab setup** + +We shall use the setup below to accomplish our objective + + * Ansible Control node   –    CentOS 8          –     IP: 192.168.43.13 + * Windows 10 node         –    Windows 10     –     IP: 192.168.43.147 + + + +### Part 1: Installing Ansible on the Control node (CentOS 8) + +Before anything else, we need to get Ansible installed on the Control node which is the CentOS 8 system. + +#### Step 1: Verify that Python3 is installed on Ansible control node + +Firstly, we need to confirm if Python3 is installed. CentOS 8 ships with Python3 but if it’s missing for any reason, install using the command: + +``` +# sudo dnf install python3 +``` + +Next, make Python3 the default Python version by running: + +``` +# sudo alternatives --set python /usr/bin/python3 +``` + +To verify if python3 is installed, run the command: + +``` +# python --version +``` + +**![check-python-version][1] ** + +**Read Also :** **[How to Install Ansible (Automation Tool) on CentOS 8/RHEL 8][3]** + +#### Step 2: Install a virtual environment for running Ansible + +For this exercise, an isolated environment for running and testing Ansible is preferred. This will keep at bay issues such as dependency problems and package conflicts. The isolated environment we are going to create is called a virtual environment. + +Firstly, let’s begin with the installation of the virtual environment on CentOS 8. + +``` +# sudo dnf install python3-virtualenv +``` + +![install-python3-virtualenv][1] + +After the installation of the virtual environment, create a virtual workspace by running: + +``` +# virtualenv env +``` + +![virtualenv-env-ansible][1] + +``` +# source env/bin/activate +``` + +![source-env-bin-activate-ansible][1] + +Great! Observer that the prompt has now changed to (env). + +#### Step 3: Install Ansible + +After the creation of the virtual environment, proceed and install Ansible automation tool using pip as shown: + +``` +# pip install ansible +``` + +![pip-install-Ansible][1] + +You can later confirm the installation of Ansible using the command: + +``` +# ansible --version +``` + +![check-ansible-version][1] + +To test Ansible and see if it’s working on our Ansible Control server run: + +``` +# ansible localhost -m ping +``` + +![Test-ansible-for-connectivity][1] + +Great! Next, we need to define the Windows host or system on a host file on the Ansible control node. Therefore, open the default hosts file + +``` +# vim /etc/ansible/hosts +``` + +Define the Windows hosts as shown below. + +![Ansible-hosts-file][1] + +**Note:** The username and password point to the user on the Windows host system. + +Next, save and exit the configuration file. + +#### Step 4: Install Pywinrm + +Unlike in Unix systems where Ansible uses SSH to communicate with remote hosts, with Windows it’s a different story altogether. To communicate with Windows hosts, you need to install Winrm. + +To install winrm, once again, use pip tool as shown: + +``` +# pip install pywinrm +``` + +![install-pywinrm][1] + +### Part 2: Configuring Windows Host + +In this section, we are going to configure our Windows 10 remote host system to connect with the Ansible Control node. We are going to install the **WinRM listener-** short for **Windows Remote** – which will allow the connection between the Windows host system and the Ansible server. + +But before we do so, your Windows host system needs to fulfill a few requirements for the installation to succeed: + + * Your Windows host system should be **Windows 7 or later**. For Servers, ensure that you are using **Windows Server 2008** and later versions. + * Ensure your system is running **.NET Framework 4.0** and later. + * Windows **PowerShell** should be Version 3.0 & later + + + +With all the requirements met, now follow the steps stipulated below: + +#### Step 1: Download the WinRM script on Windows 10 host + +WinRM can be installed using a script that you can download from this [link][4]. Copy the entire script and paste it onto the notepad editor. Thereafter, ensure you save the WinRM script at the most convenient location. In our case, we have saved the file on the Desktop under the name  ConfigureRemotingForAnsible.ps1 + +#### Step 2: Run the WinRM script on Windows 10 host + +Next, run PowerShell as the Administrator + +![Run-PowerShell-as-Administrator][1] + +Navigate to the script location and run it. In this case, we have navigated to the Desktop location where we saved the script. Next, proceed and execute the WinRM script on the WIndows host: + +``` +.\ConfigureRemotingForAnsible.ps1 +``` + +This takes about a minute and you should get the output shown below. The output shows that WinRM has successfully been installed. + +![set-up-WinRM-on-Windows10][1] + +### Part 3: Connecting to Windows Host from Ansible Control Node + +To test connectivity to the Windows 10 host, run the command: + +``` +# ansible winhost -m win_ping +``` + +![Ansible-ping-windows-host-machine][1] + +The output shows that we have indeed established a connection to the remote Windows 10 host from the Ansible Control node. This implies that we can now manage the remote Windows host using Ansible Playbooks. Let’s create a sample playbook for the Windows host system. + +### Part 4: Creating and running a playbook for Windows 10 host + +In this final section, we shall create a playbook and create a task that will install Chocolatey on the remote host. Chocolatey is a package manager for Windows system. The play is defined as shown: + +``` +# vim chocolatey.yml +--- +- host: winhost + gather_facts: no + tasks: + - name: Install Chocolatey on Windows10 + win_chocolatey: name=procexp status=present +``` + +![Ansible-Playbook-install-chocolatey][1] + +Save and close the yml file. Next, execute the playbook as shown + +``` +# ansible-playbook chocolatey.yml +``` + +![Ansible-playBook-succeeded][1] + +The output is a pointer that all went well. And this concludes this topic on how you can manage Windows host using Ansible. + + * [Facebook][5] + * [Twitter][6] + * [LinkedIn][7] + * [Reddit][8] + + + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/manage-windows-host-using-ansible/ + +作者:[James Kiarie][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.linuxtechi.com/author/james/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: http://www.linuxtechi.com/wp-content/uploads/2019/11/Manage-Windows-Hosts-using-Ansible.jpg +[3]: http://www.linuxtechi.com/install-ansible-centos-8-rhel-8/ +[4]: https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 +[5]: http://www.facebook.com/sharer.php?u=https%3A%2F%2Fwww.linuxtechi.com%2Fmanage-windows-host-using-ansible%2F&t=How%20to%20Manage%20Remote%20Windows%20Host%20using%20Ansible +[6]: http://twitter.com/share?text=How%20to%20Manage%20Remote%20Windows%20Host%20using%20Ansible&url=https%3A%2F%2Fwww.linuxtechi.com%2Fmanage-windows-host-using-ansible%2F&via=Linuxtechi +[7]: http://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.linuxtechi.com%2Fmanage-windows-host-using-ansible%2F&title=How%20to%20Manage%20Remote%20Windows%20Host%20using%20Ansible +[8]: http://www.reddit.com/submit?url=https%3A%2F%2Fwww.linuxtechi.com%2Fmanage-windows-host-using-ansible%2F&title=How%20to%20Manage%20Remote%20Windows%20Host%20using%20Ansible diff --git a/sources/tech/20191127 How to write a Python web API with Flask.md b/sources/tech/20191127 How to write a Python web API with Flask.md new file mode 100644 index 0000000000..e3d7a7790e --- /dev/null +++ b/sources/tech/20191127 How to write a Python web API with Flask.md @@ -0,0 +1,146 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to write a Python web API with Flask) +[#]: via: (https://opensource.com/article/19/11/python-web-api-flask) +[#]: author: (Rachel Waston https://opensource.com/users/rachelwaston) + +How to write a Python web API with Flask +====== +Use Flask, one of the fastest-growing Python frameworks, to fetch data +from a server, in this quick tutorial. +![spiderweb diagram][1] + +[Python][2] is a high-level, object-oriented programming language known for its simple syntax. It is consistently among the top-rated programming languages for building RESTful APIs. + +[Flask][3] is a customizable Python framework that gives developers complete control over how users access data. Flask is a "micro-framework" based on Werkzeug's [WSGI][4] toolkit and Jinja 2's templating engine. It is designed as a web framework for RESTful API development. + +Flask is one of the fastest-growing Python frameworks, and popular websites, including Netflix, Pinterest, and LinkedIn, have incorporated Flask into their development stacks. Here's an example of how Flask can permit users to fetch data from a server using the HTTP GET method. + +### Set up a Flask application + +First, create a structure for your Flask application. You can do this at any location on your system. + + +``` +$ mkdir tutorial +$ cd tutorial +$ touch main.py +$ python3 -m venv env +$ source env/bin/activate +(env) $ pip3 install flask-restful +Collecting flask-restful +Downloading +Collecting Flask>=0.8 (from flask-restful) +[...] +``` + +### Import the Flask modules + +Next, import the **flask** module and its **flask_restful** library into your **main.py** code: + + +``` +from flask import Flask +from flask_restful import Resource, Api + +app = Flask(__name__) +api = Api(app) + +class Quotes(Resource): +    def get(self): +        return { +            'William Shakespeare': { +                'quote': ['Love all,trust a few,do wrong to none', +                'Some are born great, some achieve greatness, and some greatness thrust upon them.'] +        }, +        'Linus': { +            'quote': ['Talk is cheap. Show me the code.'] +            } +        } + +api.add_resource(Quotes, '/') + +if __name__ == '__main__': +    app.run(debug=True) +``` + +### Run the app + +Flask includes a built-in HTTP server for testing. Test the simple API you built: + + +``` +(env) $ python main.py + * Serving Flask app "main" (lazy loading) + * Environment: production +   WARNING: This is a development server. Do not use it in a production deployment. +   Use a production WSGI server instead. + * Debug mode: on + * Running on (Press CTRL+C to quit) +``` + +Starting the development server starts your Flask application, which contains a method named **get** to respond to a simple HTTP GET request. You can test it using **wget** or **curl** or any web browser. The URL to use is provided in Flask's output after you start the server. + + +``` +$ curl +{ +    "William Shakespeare": { +        "quote": [ +            "Love all,trust a few,do wrong to none", +            "Some are born great, some achieve greatness, and some greatness thrust upon them." +        ] +    }, +    "Linus": { +        "quote": [ +            "Talk is cheap. Show me the code." +        ] +    } +} +``` + +To see a more complex version of a similar web API using Python and Flask, navigate to the Library of Congress' [Chronicling America][5] website, which provides access to information about historic newspapers and digitized newspaper pages. + +### Why use Flask? + +Flask has several major benefits: + + 1. Python is popular and widely used, so anyone who knows Python can develop for Flask. + 2. It's lightweight and minimalistic. + 3. Built with security in mind. + 4. Great documentation with plenty of clear, working example code. + + + +There are also some potential drawbacks: + + 1. It's lightweight and minimalistic. If you're looking for a framework with lots of bundled libraries and prefabricated components, this may not be your best option. + 2. If you have to build your own framework around Flask, you might find that the cost of maintaining your customization negates the benefit of using Flask. + + + +If you're looking to build a web app or API, Flask is a good option to consider. It's powerful and robust, and the project documentation makes it easy to get started. Try it out, evaluate it, and see if it's right for your project. + +Learn more in this lesson in Python exception handling and how to do it in a secure manner. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/python-web-api-flask + +作者:[Rachel Waston][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/rachelwaston +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web-cms-build-howto-tutorial.png?itok=bRbCJt1U (spiderweb diagram) +[2]: https://www.python.org/ +[3]: https://palletsprojects.com/p/flask/ +[4]: https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface +[5]: https://chroniclingamerica.loc.gov/about/api diff --git a/translated/tech/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md b/translated/tech/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md new file mode 100644 index 0000000000..37a5ad1488 --- /dev/null +++ b/translated/tech/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md @@ -0,0 +1,200 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server) +[#]: via: (https://www.linuxtechi.com/install-lemp-stack-fedora-30-server/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +如何在 Fedora 30 Server 上安装 LEMP (Linux, Nginx, MariaDB, PHP) +====== + +在这篇文章中,我们将看看如何在 Fedora 30 Server 上安装 **LEMP** 。LEMP 代表: + + * L -> Linux + * E -> Nginx + * M -> Maria DB + * P -> PHP + + + +我假设 **[Fedora 30][1]** 已经安装在你的电脑系统上。 + +![LEMP-Stack-Fedora30][2] + +LEMP 是一组强大的软件设置集合,它安装在一个 Linux 服务器上以帮助使用流行的开发平台来构建网站,LEMP 是 LAMP 的一个变种,在其中不是 **Apache** ,而是使用 **EngineX (Nginx)** , 此外,使用 **MariaDB** 代替 **MySQL** 。这篇入门指南是一个安装 Nginx, Maria DB 和 PHP 的独立指南的作品集合。 + +### 在 Fedora 30 Server 上安装 Nginx ,PHP 7.3 和 PHP-FPM + +让我们看看如何在 Fedora 30 Server 上安装 Nginx 和 PHP 以及 PHP FPM 。 + +### 步骤 1) 切换到 root 用户 + +在系统上安装 Nginx 的第一步是切换到 root 用户。使用下面的命令: + +``` +root@linuxtechi ~]$ sudo -i +[sudo] password for pkumar: +[root@linuxtechi ~]# +``` + +### 步骤 2) 使用 dnf 命令安装 Nginx ,PHP 7.3 和 PHP FPM + +使用下面的 dnf 命令安装 Nginx : + +``` +[root@linuxtechi ~]# dnf install nginx php php-fpm php-common -y +``` + +### 步骤 3) 安装额外的 PHP 模块 + +PHP 的默认安装仅自带基本模块和最需要的模块,如果你需要额外的模块,像 PHP 支持的 GD ,XML ,命令行接口 Zend OPCache 功能等等,你总是能够选择你的软件包,并一次性安装所有的东西。查看下面的示例命令: + +``` +[root@linuxtechi ~]# sudo dnf install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-pecl-mongodb php-pecl-redis php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml -y +``` + +### 步骤 4) 开始 & 启用 Nginx 和 PHP-fpm 服务 + +使用下面的命令来开始并启用 Nginx 服务 + +``` +[root@linuxtechi ~]# systemctl start nginx && systemctl enable nginx +Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service. +[root@linuxtechi ~]# +``` + +使用下面的命令来开始并启用 PHP-FPM 服务 + +``` +[root@linuxtechi ~]# systemctl start php-fpm && systemctl enable php-fpm +Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service. +[root@linuxtechi ~]# +``` + +**核实 Nginx (Web 服务) 和 PHP 安装,** + +**注意:** 假使操作系统防火墙是启用的,并运行在你的 Fedora 30 系统上,那么使用下面的命令来准许 80 和 443 端口, + +``` +[root@linuxtechi ~]# firewall-cmd --permanent --add-service=http +success +[root@linuxtechi ~]# +[root@linuxtechi ~]# firewall-cmd --permanent --add-service=https +success +[root@linuxtechi ~]# firewall-cmd --reload +success +[root@linuxtechi ~]# +``` + +打开网页浏览器,输入下面的 URL: http:// + +[![Test-Page-HTTP-Server-Fedora-30][3]][4] + +上面的屏幕证实 NGINX 已经成功地安装。 + +现在,让我们核实 PHP 安装,使用下面的命令创建一个测试 php 页(info.php), + +``` +[root@linuxtechi ~]# echo "" > /usr/share/nginx/html/info.php +[root@linuxtechi ~]# +``` + +在网页浏览器中输入下面的 URL , + +http:///info.php + +[![Php-info-page-fedora30][5]][6] + +上面的页面验证 PHP 7.3.5 已经被成功地安装。现在,让我们安装 MariaDB 数据库服务器。 + +### 在 Fedora 30 上安装 MariaDB + +MariaDB 是 MySQL 数据库的一个极好的替代品,因为它的工作方式与 MySQL 非常类似,并且兼容性也与 MySQL 一致。让我们看看在 Fedora 30 Server 上安装 MariaDB 的步骤。 + +### 步骤 1) 切换到 root 用户 + +在系统上安装 MariaDB 的第一步是切换到 root 用户,或者你可以使用有 root 权限的本地用户。使用下面的命令: + +``` +[root@linuxtechi ~]# sudo -i +[root@linuxtechi ~]# +``` + +### 步骤 2) 使用 dnf 命令安装 MariaDB (10.3) 的最新版本 + +在 Fedora 30 Server 上使用下面的命令来安装 MariaDB + +``` +[root@linuxtechi ~]# dnf install mariadb-server -y +``` + +### 步骤 3) 开启并启用 MariaDB 服务 + +在步骤2中成功地安装 mariadb 后,接下来的步骤是开启 MariaDB 服务。使用下面的命令: + +``` +[root@linuxtechi ~]# systemctl start mariadb.service ; systemctl enable mariadb.service +``` + +### 步骤 4) 保护 MariaDB 安装 + +当我们安装 MariaDB 服务器时,因为默认情况下没有 root密码,在数据库中也创建匿名用户。因此,来保护 MariaDB 安装,运行下面的 “mysql_secure_installation” 命令 + +``` +[root@linuxtechi ~]# mysql_secure_installation +``` + +接下来你将被提示一些问题,仅回答下面展示的问题: + +![Secure-MariaDB-Installation-Part1][7] + +![Secure-MariaDB-Installation-Part2][8] + +### 步骤 5) 测试 MariaDB 安装 + +在你安装后,你总是能够测试是否 MariaDB 被成功地安装在 Fedora 30 Server 上。使用下面的命令: + +``` +[root@linuxtechi ~]# mysql -u root -p +Enter password: +``` + +接下来,你将被提示一个密码。输入在 MariaDB 保护安装期间你设置的密码,接下来你可以看到 MariaDB 欢迎屏幕。 + +``` +Welcome to the MariaDB monitor. Commands end with ; or \g. +Your MariaDB connection id is 17 +Server version: 10.3.12-MariaDB MariaDB Server + +Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. + +Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. + +MariaDB [(none)]> +``` + +最后,我们已经在你的 Fedora 30 Server 上成功地完成安装 LEMP (Linux, Nginx, MariaDB and PHP) 的所有工作。请在下面的反馈部分发布你的评论和建议,我们将尽快在后面回应。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/install-lemp-stack-fedora-30-server/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/fedora-30-workstation-installation-guide/ +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/06/LEMP-Stack-Fedora30.jpg +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Test-Page-HTTP-Server-Fedora-30-1024x732.jpg +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Test-Page-HTTP-Server-Fedora-30.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Php-info-page-fedora30-1024x732.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Php-info-page-fedora30.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Secure-MariaDB-Installation-Part1.jpg +[8]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Secure-MariaDB-Installation-Part2.jpg diff --git a/translated/tech/20191107 Demystifying Kubernetes.md b/translated/tech/20191107 Demystifying Kubernetes.md new file mode 100644 index 0000000000..396fac1f8e --- /dev/null +++ b/translated/tech/20191107 Demystifying Kubernetes.md @@ -0,0 +1,231 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Demystifying Kubernetes) +[#]: via: (https://opensourceforu.com/2019/11/demystifying-kubernetes/) +[#]: author: (Abhinav Nath Gupta https://opensourceforu.com/author/abhinav-gupta/) + +揭开 Kubernetes 的神秘面纱 +====== + +[![][1]][2] + +_Kubernetes 是一款生产级的开源系统,用于容器化应用程序的自动部署,扩展和管理。本文关于使用 Kubernetes 来管理容器。_ + + + “容器”已成为最新的流行语之一。 但是,这个词到底意味着什么呢? 说起“容器”,人们通常会把它和 Docker 联系起来,Docker 是一个被定义为软件的标准化单元容器。 该容器将软件和运行软件所需的环境封装到一个易于交付的单元中。 容器是一个软件的标准单元,用它来打包代码及其所有依赖项,这样应用程序就可以从一个计算环境快速可靠地运行到另一个计算环境。 容器通过创建类似于ISO 映像的方式来实现此目的。 容器镜像是一个轻量级的,独立的,可执行的软件包,其中包含运行应用程序所需的所有信息,包括代码,运行时,系统工具,系统库和设置。 + +容器镜像在运行时变成容器,对于Docker 容器,映像在 Docker 引擎上运行时变成容器。 容器将软件与环境隔离开来,确保不同环境下的实例,都可以正常运行。 + +**什么是容器管理?** +容器管理是组织,添加或替换大量软件容器的过程。 容器管理使用软件来自动化创建,部署和扩展容器。 这一过程就需要容器编排。容器编排是一个基于应用程序进行自动部署,管理,扩展,联网的可用容器。 + +**Kubernetes** +Kubernetes 是一个可移植的,可扩展的开源平台,用于管理容器化的工作负载和服务,它有助于配置和自动化。 它最初由 Google 开发, 拥有一个庞大且快速增长的生态系统。 Kubernetes 的服务,技术支持和工具得到广泛应用。 + +Google 在2014年将 Kubernetes 项目开源化。Kubernetes 建立在 Google 十五年大规模运行生产工作负载的经验基础上并结合了社区中最好的想法和实践以及声明式句法的使用。 +下面列出了与Kubernetes生态系统相关的一些常用术语。 + +_**Pods:**_ pod 是 Kubernetes 应用程序的基本执行单元,是你创建或部署的 Kubernetes 对象模型中的最小和最简单的单元。pod 代表在 Kubernetes 集群上运行的进程。 +Pod 将运行中的容器,存储,网络IP(唯一)和控制容器应如何运行的命令封装起来。它代表 Kubernetes 生态系统内的单个部署单元,代表一个应用程序的单个实例,该程序可能包含一个或多个紧密耦合并共享资源的容器。 + +Kubernetes 集群中的Pod有两种主要的使用方式。 第一种是运行单个容器。 即“一个容器一个pod”,这种方式是最常见的。 第二种是运行多个需要一起工作的容器。 +Pod 可能封装一个应用程序,该应用程序由紧密关联且需要共享资源的多个同位容器组成。 + +_**ReplicaSet:**_ ReplicaSet 的目的是维护在任何给定时间运行的一组稳定的副本容器集。 ReplicaSet 包含有关一个特定 Pod 应该运行多少个副本的信息。 为了创建多个Pod 以匹配 ReplicaSet 条件,Kubernetes 使用 Pod 模板。 ReplicaSet 与其 pod 的链接是通过后者的 metas.ownerReferences 字段实现,该字段指定哪个资源拥有当前对象。 + +_**Services:**_ 服务是公开一组 Pod 功能的抽象。 使用 Kubernetes,你无需修改应用程序即可使用陌生的服务发现机制。 Kubernetes 为 Pod 提供了自己的IP地址和一组Pod 的单个DNS 名称,并且可以在它们之间负载平衡。 + +服务解决的一个主要问题是Web应用程序前端和后端的集成。 由于 Kubernetes 将幕后 IP 地址提供给 Pod,因此当 Pod 被杀死并复活时,IP 地址会更改。 这给给定的后端 IP 地址连接到相应的前端 IP 地址带来一个大问题。 服务通过在 Pod 上提供抽象来解决此问题,类似于负载均衡器。 + +_**Volumes:**_ Kubernetes Volumes 具有明确的生命周期-与包围它的 Pod 相同。 因此,Volumes 超过了pod 中运行的任何容器的寿命,并且在容器重新启动后保留了数据。 当然,当 pod 不存在时,该体积也将不再存在。 也许比这更重要的是 Kubernetes 支持多种类型的 Volumes,并且 Pod 可以同时使用任意数量的 Volumes。 + +Volumes 的核心只是一个目录,其中可能包含一些数据,pod 中的容器可以访问该目录。 该目录是如何产生的, 它后端基于什么存储介质,其中的数据内容是什么,这些都由使用的特定 volumes 类型来决定的。 + +**为什么选择 Kubernetes?** +容器是捆绑和运行应用程序的好方法。 在生产环境中,你需要管理运行应用程序的容器,并确保没有停机时间。 例如,如果一个容器发生故障,则需要启动另一个容器。 如果由系统自动实现这一操作,岂不是更好? Kubernetes 就是来解决这个问题的! Kubernetes 提供了一个框架来弹性运行分布式系统。 该框架负责扩展需求,故障转移,部署模式等。 例如,Kubernetes 可以轻松管理系统的 Canary 部署。 + +Kubernetes 为用户提供了: +1\. 服务发现和负载平衡 +2\. 存储编排 +3\. 自动退出和回退 +4\. 自动打包 +5\. 自我修复 +6\. 秘密配置管理 + +**Kubernetes 可以做什么?** + +在本文中,我们将会看到一些从头构建 Web 应用程序时如何使用 Kubernetes 的代码示例。我们将在 Python 中使用 Flask 创建一个简单的后端服务器。 +对于那些想从头开始构建 Web 应用程序的人,有一些前提条件,即: + +1\. 对 Docker,Docker 容器和 Docker 映像的基本了解。可以访问该网站 + __快速了解。 +2\. 系统中应该安装Docker。 +3\. 系统中应该安装Kubernetes,有关如何在本地计算机上安装的说明,请访问网站 __. + +现在,创建一个目录,如下代码片段所示: +``` +mkdir flask-kubernetes/app && cd flask-kubernetes/app +``` + +接下来,在 _flask-kubernetes/app_ 目录中,创建一个名为 main.py 的文件,如下面的代码片段所示: +``` +touch main.py +``` + +在新创建的 _main.py,_ 文件中,粘贴下面代码: + +``` +from flask import Flask +app = Flask(__name__) + +@app.route("/") +def hello(): +return "Hello from Kubernetes!" + +if __name__ == "__main__": +app.run(host='0.0.0.0') +``` + +使用下面命令在本地安装 Flask: + +``` +pip install Flask==0.10.1 +``` + +Flask 安装后,执行下面的命令: +``` +python app.py +``` + + +应该在本地运行Flask服务器,Flask应用程序的默认端口是5000,并且你可以在 * 上看到输出‘Hello from Kubernetes!’。 一旦服务器在本地运行,我们就创建一个供 Kubernetes 使用的 Docker 映像。 创建一个名为 Dockerfile 的文件,并将以下代码片段粘贴到其中: + + +``` +FROM python:3.7 + +RUN mkdir /app +WORKDIR /app +ADD . /app/ +RUN pip install -r requirements.txt + +EXPOSE 5000 +CMD ["python", "/app/main.py"] +``` + +_Dockerfile_文件的说明如下: + +1\. Docker 将从 Docker 集线器获取 Python 3.7 映像。 +2\. 将在映像中创建一个应用程序目录。 +3\. 它将一个应用程序设置为工作目录。 +4\. 将内容从主机中的应用程序目录复制到映像应用程序目录。 +5\. 暴露端口5000。 +6\. 最后,它运行命令,启动 Flask 服务器。 +接下来,我们将使用以下命令创建 Docker 映像: + +``` +docker build -f Dockerfile -t flask-kubernetes:latest . +``` + +创建Docker映像后,我们可以使用以下命令在本地运行该映像进行测试: + +``` +docker run -p 5001:5000 flask-kubernetes +``` + +通过运行容器在本地完成测试之后,我们需要在 Kubernetes 中部署它。 我们将首先使用 kubectl 命令验证 Kubernetes 是否正在运行。 如果没有报错,则说明它正在工作。 如果有报错,请参考该网站信息: __. + +接下来, 我们创建一个部署文件。 这是一个Yaml文件,其中包含有关 Kubernetes 的说明,该说明涉及如何以声明性的方式创建 pod 和服务。 因为我们有 Flask Web 应用程序,我们将在其中包含 pod 和 services 声明的情况下创建一个deployment.yaml文件。 +创建一个名为 deployment.yaml 的文件并向其中添加以下内容,然后保存: + +``` +apiVersion: v1 +kind: Service +metadata: +name: flask-kubernetes -service +spec: +selector: +app: flask-kubernetes +ports: +- protocol: "TCP" +port: 6000 +targetPort: 5000 +type: LoadBalancer + + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: +name: flask-kubernetes +spec: +replicas: 4 +template: +metadata: +labels: +app: flask-kubernetes +spec: +containers: +- name: flask-kubernetes +image: flask-kubernetes:latest +imagePullPolicy: Never +ports: +- containerPort: 5000 +``` + +使用以下命令将 yaml 文件发送到 Kubernete: + +``` +kubectl apply -f deployment.yaml +``` + +如果执行以下命令,你会看到 pods 正在运行: + +``` +kubectl get pods +``` + + +现在,导航至__,你应该会看到‘Hello from Kubernetes!’消息。 成功了! 该应用程序现在正在 Kubernetes 中运行! + +**Kubernetes 做不了什么 ** +Kubernetes 不是一个传统的,包罗万象的 PaaS(平台即服务)系统。 由于 Kubernetes 运行在容器级别而非硬件级别,因此它提供了 PaaS 产品共有的一些普遍适用功能,如部署,扩展,负载平衡,日志记录和监控。 Kubernetes 为开发人员平台提供了构建块,但在重要的地方保留了用户的选择和灵活性。 + + * Kubernetes 不限制所支持的应用程序的类型。 如果应用程序可以在容器中运行,那么它应该可以在 Kubernetes 上更好地运行。 + * 它不部署和构建源代码。 + * 它不决定日志记录,监视或警报解决方案。 + * 它不提供或不要求配置语言/系统。 它提供了一个声明的API供所有人使用。 + * 它不提供或不采用任何全面的机器配置,维护,管理或自我修复系统。 + + +![Avatar][3] + +[Abhinav Nath Gupta][4] + +本文作者 Abhinav 是班加罗尔 Cleo 软件公司的一名软件开发工程师。他对密码学、数据安全、虚拟货币及云计算方面很感兴趣,可以通过 [abhi.aec89@gmail.com][5] 与他联系。. + +[![][6]][7] + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/demystifying-kubernetes/ + +作者:[Abhinav Nath Gupta][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensourceforu.com/author/abhinav-gupta/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Gear-kubernetes.jpg?resize=696%2C457&ssl=1 (Gear kubernetes) +[2]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Gear-kubernetes.jpg?fit=800%2C525&ssl=1 +[3]: https://secure.gravatar.com/avatar/f65917facf5f28936663731fedf545c4?s=100&r=g +[4]: https://opensourceforu.com/author/abhinav-gupta/ +[5]: mailto:abhi.aec89@gmail.com +[6]: http://opensourceforu.com/wp-content/uploads/2013/10/assoc.png +[7]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/translated/tech/20191113 Edit images on Fedora easily with GIMP.md b/translated/tech/20191113 Edit images on Fedora easily with GIMP.md new file mode 100644 index 0000000000..97470082ae --- /dev/null +++ b/translated/tech/20191113 Edit images on Fedora easily with GIMP.md @@ -0,0 +1,85 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Edit images on Fedora easily with GIMP) +[#]: via: (https://fedoramagazine.org/edit-images-on-fedora-easily-with-gimp/) +[#]: author: (Mehdi Haghgoo https://fedoramagazine.org/author/powergame/) + +在 Fedora 上使用 GIMP 简单地编辑图像 +====== + +![][1] + +GIMP ( GNU Image Manipulation Program 的缩写) 是自由和开源图像处理软件。有很多的功能,从简单地编辑图像,到复杂的滤镜,脚本,甚至是动画,它是一款很好的流行的商业选项的替代品。 + +继续阅读来学习如何在 Fedora 上安装和使用 GIMP 。这篇文章涉及基本的日常图像编辑。 + +### 安装 GIMP + +GIMP 在官方 Fedora 存储库中可获得。为安装它,运行: + +``` +sudo dnf install gimp +``` + +### 单个窗口模式 + +在你打开应用程序后,它显示带有工具箱和主编辑区的暗色主题窗口。注意,它有两种窗口模式,你可以通过选择 _窗口_ -> _单个窗口模式_ 在其中切换。通过选中这个选项,用户界面的所有组件将显示在单个窗口中。否则,它们将是分开的。 + +### 加载一个图像 + +![][2] + +为加载一个图像,转到 _文件_ -> _打开_ ,然后选择你的文件并选择你的图像文件。 + +### 重新调整一个图像的大小 + +为重新调整图像大小,你有以一对参数为基础的重新调整大小的选项,包括像素和百分比 — 在编辑图像时,这两个参数很方便。 + +让我们假使我们需要缩小 Fedora 30 背景图像到它当前大小的75%。为此,选择 _图像_ -> _比例_ ,然后在比例对话框上,选择在单位下拉列表中的百分比。接下来,输入 _75_ 作为宽度或高度,然后按 **Tab** 键。默认情况下,为保持纵横比,其它尺寸将自动地与更改的尺寸对应来重新调整大小。现在,保存其它选项不变,并按比例。 + +![][3] + +该图像缩小到其原始尺寸的75%。 + +### 旋转图像 + +旋转是一种变换操作,因此,你可以从主菜单下的 _图像_ -> _变换_ 的下面找到它,其中有图像旋转90°或180°的选项。在上述选项下也有垂直或水平翻转图像的选项。 + +让我们假使我们需要旋转图像90°。在应用一次90°顺时针旋转和水平翻转后,我们的图像将看起来像这样: + +![Transforming an image with GIMP][4] + +### 添加文本 + +添加文本非常简单。只需要从工具箱中选择 A 图标,然后,在你的图像上,单击你想要添加文本的位置上一点。如果工具箱不可见,从 窗口->新建工具箱 打开它。 + +当你编辑文本时,你可能注意到,文本对话框有字体自定义选项,包括字体系列,字体大小等等。 + +![Adding text to image in GIMP][5] + +### 保存和导出 + +你可以从 _文件_ -> _保存_ 或通过按 **Ctrl+S** 来保存你的编辑为一个带有 _xcf_ 扩展名的 GIMP 工程。或者,你可以导出你的图像,例如,以 PNG 或 JPEG 格式。为导出,转到 _文件_ -> _导出为_ 或按 **Ctrl+Shift+E** ,接下来,在你面前将产生一个你可以选择输出图像和名称的对话框。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/edit-images-on-fedora-easily-with-gimp/ + +作者:[Mehdi Haghgoo][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/powergame/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/10/gimp-magazine-816x346.jpg +[2]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-00-44-300x165.png +[3]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-17-33-300x262.png +[4]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-41-28-300x243.png +[5]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-47-54-300x237.png + diff --git a/translated/tech/20191117 How to Install VirtualBox 6.0 on CentOS 8 - RHEL 8.md b/translated/tech/20191117 How to Install VirtualBox 6.0 on CentOS 8 - RHEL 8.md new file mode 100644 index 0000000000..e1b325f4d4 --- /dev/null +++ b/translated/tech/20191117 How to Install VirtualBox 6.0 on CentOS 8 - RHEL 8.md @@ -0,0 +1,158 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Install VirtualBox 6.0 on CentOS 8 / RHEL 8) +[#]: via: (https://www.linuxtechi.com/install-virtualbox-6-centos-8-rhel-8/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +如何在 CentOS 8 / RHEL 8 上安装 VirtualBox 6.0 +====== + +**VirtualBox** 是一款免费的开源**虚拟化工具**,它允许技术人员同时运行多个不同风格的虚拟机。它通常用于运行桌面(Linux 和 Windows),当人们尝试探索新的 Linux 发行版的功能或希望在 VM 中安装 **OpenStack**、**Ansible** 和 **Puppet** 等软件时,它会非常方便,在这种情况下,我们可以使用 VirtualBox 启动 VM。 + +VirtualBox 被分类为**2 类虚拟机管理程序**,这意味着它需要一个现有的操作系统,在上面安装 VirtualBox 软件。VirtualBox 提供功能来创建本机网络或 NAT 网络。在本文中,我们将演示如何在 CentOS 8 和 RHEL 8 系统上安装最新版本的 VirtualBox 6.0,并演示如何安装 VirtualBox 扩展。 + +### 在 CentOS 8 / RHEL 8 上安装 VirtualBox 6.0 的安装步骤 + +#### 步骤 1: 启用 VirtualBox 和 EPEL 仓库 + +登录到你的 CentOS 8 或 RHEL 8 系统并打开终端,执行以下命令并启用 VirtualBox 和 EPEL 包仓库。 + +``` +[root@linuxtechi ~]# dnf config-manager --add-repo=https://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo +``` + +使用以下 rpm 命令导入 Oracle VirtualBox 公钥 + +``` +[root@linuxtechi ~]# rpm --import https://www.virtualbox.org/download/oracle_vbox.asc +``` + +使用以下 dnf 命令启用 EPEL 仓库, + +``` +[root@linuxtechi ~]# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y +``` + +#### 步骤 2: 安装 VirtualBox 构建工具和依赖项 + +运行以下命令来安装所有 VirtualBox 构建工具和依赖项, + +``` +[root@linuxtechi ~]# dnf install binutils kernel-devel kernel-headers libgomp make patch gcc glibc-headers glibc-devel dkms -y +``` + +成功安装上面的依赖项和构建工具后,使用 dnf 命令继续安装 VirtualBox, + +#### 步骤 3: 在 CentOS 8 / RHEL 8 上安装 VirtualBox 6.0 + +如果希望在安装之前列出 VirtualBox 的可用版本,请执行以下 [dnf 命令][1], + +``` +[root@linuxtechi ~]# dnf search virtualbox +Last metadata expiration check: 0:14:36 ago on Sun 17 Nov 2019 04:13:16 AM GMT. +=============== Summary & Name Matched: virtualbox ===================== +VirtualBox-5.2.x86_64 : Oracle VM VirtualBox +VirtualBox-6.0.x86_64 : Oracle VM VirtualBox +[root@linuxtechi ~]# +``` + +让我们使用以下 dnf 命令安装最新版本的 VirtualBox 6.0, + +``` +[root@linuxtechi ~]# dnf install VirtualBox-6.0 -y +``` + +如果有本地用户希望将 usb 设备连接到 VirtualBox VM,那么他/她应该是 “**vboxusers**” 组的一员,请使用下面的 usermod 命令将本地用户添加到 “vboxusers” 组。 + + +``` +[root@linuxtechi ~]# usermod -aG vboxusers pkumar +``` + +#### 步骤 4: 访问 CentOS 8 / RHEL 8 上的 VirtualBox + +有两种方法可以访问 VirtualBox,在命令行输入 “**virtualbox**” 然后回车: + +``` +[root@linuxtechi ~]# virtualbox +``` + +在桌面环境中,在搜索框中搜索 “VirtualBox”。 + +[![Access-VirtualBox-CentOS8][2]][3] + +单击 VirtualBox 图标, + +[![VirtualBox-CentOS8][2]][4] + +这确认 VirtualBox 6.0 已成功安装,让我们安装它的扩展包。 + +#### 步骤 5: 安装 VirtualBox 6.0 扩展包 + +顾名思义,VirtualBox 扩展包用于扩展 VirtualBox 的功能。它添加了以下功能: + + * USB 2.0 和 USB 3.0 支持 + * 虚拟 RDP(VRDP) + * 磁盘镜像加密 + * Intel PXE 启动 + * 主机网络摄像头 + + + +使用下面的 wget 命令下载 Virtualbox 扩展包到下载文件夹中, + +``` +[root@linuxtechi ~]$ cd Downloads/ +[root@linuxtechi Downloads]$ wget https://download.virtualbox.org/virtualbox/6.0.14/Oracle_VM_VirtualBox_Extension_Pack-6.0.14.vbox-extpack +``` + +下载后,打开 VirtualBox 并依次点击 **File** –>**Preferences** –> **Extension**,然后点击 “+” 号图标添加下载的扩展包, + +[![Install-VirtualBox-Extension-Pack-CentOS8][2]][5] + +单击 “Install” 开始安装扩展包。 + +[![Accept-VirtualBox-Extension-Pack-License-CentOS8][2]][6] + +单击 "I Agree" 接受 VirtualBox 扩展包许可证。 + +成功安装 VirtualBox 扩展包后,我们将看到下面的页面,单击 OK 并开始使用 VirtualBox。 + +[![VirtualBox-Extension-Pack-Install-Message-CentOS8][2]][7] + +本文就是这些了,我希望这些步骤可以帮助你在 CentOS 8 和 RHEL 8 系统上安装 VirtualBox 6.0。请分享你的宝贵反馈和意见。 + + * [Facebook][9] + * [Twitter][10] + * [LinkedIn][11] + * [Reddit][12] + + + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/install-virtualbox-6-centos-8-rhel-8/ + +作者:[Pradeep Kumar][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://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/dnf-command-examples-rpm-management-fedora-linux/ +[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Access-VirtualBox-CentOS8.jpg +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/11/VirtualBox-CentOS8.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Install-VirtualBox-Extension-Pack-CentOS8.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Accept-VirtualBox-Extension-Pack-License-CentOS8.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/11/VirtualBox-Extension-Pack-Install-Message-CentOS8.jpg +[9]: http://www.facebook.com/sharer.php?u=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-virtualbox-6-centos-8-rhel-8%2F&t=How%20to%20Install%20VirtualBox%206.0%20on%20CentOS%208%20%2F%20RHEL%208 +[10]: http://twitter.com/share?text=How%20to%20Install%20VirtualBox%206.0%20on%20CentOS%208%20%2F%20RHEL%208&url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-virtualbox-6-centos-8-rhel-8%2F&via=Linuxtechi +[11]: http://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-virtualbox-6-centos-8-rhel-8%2F&title=How%20to%20Install%20VirtualBox%206.0%20on%20CentOS%208%20%2F%20RHEL%208 +[12]: http://www.reddit.com/submit?url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-virtualbox-6-centos-8-rhel-8%2F&title=How%20to%20Install%20VirtualBox%206.0%20on%20CentOS%208%20%2F%20RHEL%208 diff --git a/translated/tech/20191121 How to document Python code with Sphinx.md b/translated/tech/20191121 How to document Python code with Sphinx.md new file mode 100644 index 0000000000..8c7cc395ad --- /dev/null +++ b/translated/tech/20191121 How to document Python code with Sphinx.md @@ -0,0 +1,181 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to document Python code with Sphinx) +[#]: via: (https://opensource.com/article/19/11/document-python-sphinx) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +如何使用 Sphinx 给 Python 代码写文档 +====== +最好将文档作为开发过程的一部分。Sphinx 加上 Tox,让文档可以轻松书写,并且外观漂亮。 +![Python in a coffee cup.][1] + +Python 代码可以在源码中包含文档。这种方式默认依靠 **docstring**,它以三引号格式定义。虽然文档的价值是很大的,但是代码没有充足的文档还是很常见。让我们演练一个场景,了解出色的文档的强大功能。 + +经历了太多白板技术面试,要求你实现斐波那契数列,你已经受够了。你回家用 Python 写了一个可重用的斐波那契计算器,使用浮点技巧来实现 O(1) 复杂度。 + + +代码很简单: + + +``` +# fib.py +import math + +_SQRT_5 = math.sqrt(5) +_PHI = (1 + _SQRT_5) / 2 + +def approx_fib(n): + return round(_PHI**(n+1) / _SQRT_5) +``` + +(该斐波那契数列是四舍五入到最接近的整数的几何序列,这是我最喜欢的鲜为人知的数学事实之一。) + +作为一个好人,你可以将代码开源,并将它放在 [PyPI][2] 上。setup.py 文件很简单: + + +``` +import setuptools + +setuptools.setup( + name='fib', + version='2019.1.0', + description='Fibonacci', + py_modules=["fib"], +) +``` + +但是,没有文档的代码是没有用的。因此,你可以向函数添加 docstring。我最喜欢的 docstring 样式之一是 [“Google” 样式][3]。标记很轻量,这在它位于源代码中时很好。 + + +``` +def approx_fib(n): + """ + Approximate Fibonacci sequence + + Args: + n (int): The place in Fibonacci sequence to approximate + + Returns: + float: The approximate value in Fibonacci sequence + """ + # ... +``` + +但是函数的文档只是成功的一半。普通文档对于情境化代码用法很重要。在这种情况下,上下文是恼人的技术面试。 + +有一种添加更多文档的方式,Pythonic 模式通常是在 **docs/** 添加 **rst** 文件 ( [reStructuredText][4] 的缩写)。因此**docs/index.rst** 文件最终看起来像这样: + + +``` +Fibonacci +========= + +Are you annoyed at tech interviewers asking you to implement +the Fibonacci sequence? +Do you want to have some fun with them? +A simple +:code:`pip install fib` +is all it takes to tell them to, +um, +fib off. + +.. automodule:: fib + :members: +``` + +我们完成了,对吧?我们已经将文本放在了文件中。人们应该看看。 + +### 使 Python 文档更漂亮 + +为了使你的文档看起来更漂亮,你可以利用 [Sphinx][5],它旨在制作漂亮的 Python 文档。这三个 Sphinx 扩展特别有用: + +* **sphinx.ext.autodoc**:从模块内部获取文档 + * **sphinx.ext.napoleon**:支持 Google 样式的 docstring + * **sphinx.ext.viewcode**:将 ReStructured Text 源码与生成的文档打包在一起 + + + + +为了告诉 Sphinx 该生成什么以及如何生成,我们在 **docs/conf.py** 中配置一个辅助文件: + + +``` +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.napoleon', + 'sphinx.ext.viewcode', +] +# The name of the entry point, without the ".rst" extension. +# By convention this will be "index" +master_doc = "index" +# This values are all used in the generated documentation. +# Usually, the release and version are the same, +# but sometimes we want to have the release have an "rc" tag. +project = "Fib" +copyright = "2019, Moshe Zadka" +author = "Moshe Zadka" +version = release = "2019.1.0" +``` + +此文件使我们可以使用所需的所有元数据来发布代码,并注意扩展名(上面的注释说明了方式)。最后,要确保生成我们想要的文档,请使用 [Tox][6] 管理虚拟环境以确保我们顺利生成文档: + + +``` +[tox] +# By default, .tox is the directory. +# Putting it in a non-dot file allows opening the generated +# documentation from file managers or browser open dialogs +# that will sometimes hide dot files. +toxworkdir = {toxinidir}/build/tox + +[testenv:docs] +# Running sphinx from inside the "docs" directory +# ensures it will not pick up any stray files that might +# get into a virtual environment under the top-level directory +# or other artifacts under build/ +changedir = docs +# The only dependency is sphinx +# If we were using extensions packaged separately, +# we would specify them here. +# A better practice is to specify a specific version of sphinx. +deps = + sphinx +# This is the sphinx command to generate HTML. +# In other circumstances, we might want to generate a PDF or an ebook +commands = + sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html +# We use Python 3.7. Tox sometimes tries to autodetect it based on the name of +# the testenv, but "docs" does not give useful clues so we have to be explicit. +basepython = python3.7 +``` + +现在,无论何时运行T ox,它都会为你的 Python 代码生成漂亮的文档。 + +### 在 Python 中写文档很好 + +作为 Python 开发人员,我们可以使用的工具链很棒。 我们可以从 **docstring** 开始,添加 **.rst** 文件,然后添加 Sphinx 和 Tox 来为用户美化结果。 + +你对好的文档有何评价? 你还有其他喜欢的方式么? 请在评论中分享它们! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/document-python-sphinx + +作者:[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://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_python.jpg?itok=G04cSvp_ (Python in a coffee cup.) +[2]: https://pypi.org/ +[3]: http://google.github.io/styleguide/pyguide.html#381-docstrings +[4]: http://docutils.sourceforge.net/rst.html +[5]: http://www.sphinx-doc.org/en/master/ +[6]: https://tox.readthedocs.io/en/latest/ \ No newline at end of file diff --git a/translated/tech/20191125 How to Install Ansible (Automation Tool) on CentOS 8-RHEL 8.md b/translated/tech/20191125 How to Install Ansible (Automation Tool) on CentOS 8-RHEL 8.md new file mode 100644 index 0000000000..8cd9c01c5f --- /dev/null +++ b/translated/tech/20191125 How to Install Ansible (Automation Tool) on CentOS 8-RHEL 8.md @@ -0,0 +1,210 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Install Ansible (Automation Tool) on CentOS 8/RHEL 8) +[#]: via: (https://www.linuxtechi.com/install-ansible-centos-8-rhel-8/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +如何在 CentOS 8/RHEL 8 上安装 Ansible(自动化工具) +====== + +**Ansible** 是给 Linux 系统管理员使用的出色自动化工具。它是一种开源配置工具,能让系统管理员可以从一个中心节点(即 **Ansible 服务器**)管理数百台服务器。将 Ansible 与 **Puppet**、**Chef** 和 **Salt**等类似工具进行比较时,它是首选的配置工具,因为它不需要任何代理,并且可以工作在 SSH 和 python 上。 + +[![Install-Ansible-CentOS8-RHEL8][1]][2] + +在本教程中,我们将学习如何在 CentOS 8 和 RHEL 8 系统上安装和使用 Ansble + +Ansible 实验环境信息: + + * Minimal CentOS 8 / RHEL 8 服务器(192.168.1.10),且有互联网连接 + * 两个 Ansible 节点 - Ubuntu 18.04 LTS (192.168.1.20) 和 CentOS 7 (192.168.1.30) + + + +### CentOS 8 上的 Ansible 安装步骤 + + +Ansible 包不在 CentOS 8 默认的软件包仓库中。因此,我们需要执行以下命令启用 [EPEL 仓库][3], + +``` +[root@linuxtechi ~]$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y +``` + +启用 epel 仓库后,执行以下 dnf 命令安装 Ansble。 + +``` +[root@linuxtechi ~]$ sudo dnf install ansible +``` + +上面命令的输出: + +![dnf-install-ansible-centos8][1] + +成功安装 ansible 后,运行以下命令验证它的版本。 + +``` +[root@linuxtechi ~]$ sudo ansible --version +``` + +![Ansible-version-CentOS8][1] + +上面的输出确认在 CentOS 8 上安装完成。 + +让我们看下 RHEL 8 系统。 + +### RHEL 8 上的 Ansible 安装步骤 + +如果你有有效的 RHEL 8 订阅,请使用以下订阅管理器命令启用 Ansble 仓库, + +``` +[root@linuxtechi ~]$ sudo subscription-manager repos --enable ansible-2.8-for-rhel-8-x86_64-rpms +``` + +启用仓库后,执行以下 dnf 命令安装 Ansible, + +``` +[root@linuxtechi ~]$ sudo dnf install ansible -y +``` + +安装 ansible 及其依赖包后,执行以下命令来验证它的版本, + +``` +[root@linuxtechi ~]$ sudo ansible --version +``` + +### 在 CentOS 8 / RHEL 8 上通过 pip3 安装 Ansible 的可选方法 + +如果你希望使用 **pip**(python 的包管理器)安装 Ansible,请首先使用以下命令安装 pyhton3 和 python3-pip 包, + +``` +[root@linuxtechi ~]$ sudo dnf install python3 python3-pip -y +``` + +安装 python3 后,运行以下命令来验证它的版本。 + +``` +[root@linuxtechi ~]$ python3 -V +Python 3.6.8 +[root@linuxtechi ~]$ +``` + +命令下面的 pip3 命令安装 Ansible, + +``` +[root@linuxtechi ~]$ pip3 install ansible --user +``` + +输出, + +![Ansible-Install-pip3-centos8][1] + +上面的输出确认 Ansible 已成功使用 pip3 安装。让我们看下如何使用 Ansible。 + +### 如何使用 Ansible 自动化工具? + +当我们使用 yum 或 dnf 命令安装 Ansible 时,它的配置文件、清单文件和角色目录会自动在 /etc/ansible 文件夹下创建。 + +让我们添加一个名称为 “**labservers**” 的组,并在 **/etc/ansible/hosts** 文件中给该组添加 Ubuntu 18.04 和 CentOS 7 的系统 IP 地址。 + +``` +[root@linuxtechi ~]$ sudo vi /etc/ansible/hosts +… +[labservers] +192.168.1.20 +192.168.1.30 +… +``` + +保存并退出文件。 + +更新清单文件(/etc/ansible/hosts)后,将用户的 ssh 公钥与作为 “labservers” 组一部分的远程系统交换。 + +让我们首先使用 ssh-keygen 命令生成本地用户的公钥和私钥, + +``` +[root@linuxtechi ~]$ ssh-keygen +``` + +现在使用以下命令在 ansible 服务器及其客户端之间交换公钥, + +``` +[root@linuxtechi ~]$ ssh-copy-id root@linuxtechi +[root@linuxtechi ~]$ ssh-copy-id root@linuxtechi +``` + +现在,让我们尝试几个 Ansible 命令,首先使用 ping 模块验证 Ansible 服务器与客户端的连接, + +``` +[root@linuxtechi ~]$ ansible -m ping "labservers" +``` + +**注意:** 如果我们没有在上面的命令中指定清单文件,那么它将引用默认主机文件(即 /etc/ansible/hosts) + +输出: + +![ansible-ping-module-centos8][1] + +让我们使用 Ansible shell 命令检查每个客户端的内核版本, + +``` +[root@linuxtechi ~]$ ansible -m command -a "uname -r" "labservers" +192.168.1.30 | CHANGED | rc=0 >> +4.15.0-20-generic +192.168.1.20 | CHANGED | rc=0 >> +3.10.0-327.el7.x86_64 +[root@linuxtechi ~]$ +``` + +使用以下命令列出清单文件中的所有主机, + +``` +[root@linuxtechi ~]$ ansible all -i /etc/ansible/hosts --list-hosts + hosts (4): + 192.168.100.1 + 192.168.100.10 + 192.168.1.20 + 192.168.1.30 +[root@linuxtechi ~]$ +``` + +使用以下 ansible 命令仅列出 “labservers” 组中的主机。 + +``` +root@linuxtechi ~]$ ansible labservers -i /etc/ansible/hosts --list-hosts + hosts (2): + 192.168.1.20 + 192.168.1.30 +[root@linuxtechi ~]$ +``` + +本文就是这些了,我们成功演示了如何在 CentOS 8 和 RHEL 8 系统中安装和使用 Ansible。请分享你的反馈和意见。 + + * [Facebook][4] + * [Twitter][5] + * [LinkedIn][6] + * [Reddit][7] + + + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/install-ansible-centos-8-rhel-8/ + +作者:[Pradeep Kumar][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://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: http://www.linuxtechi.com/wp-content/uploads/2019/11/Install-Ansible-CentOS8-RHEL8.png +[3]: http://www.linuxtechi.com/enable-epel-repo-centos8-rhel8-server/ +[4]: http://www.facebook.com/sharer.php?u=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-ansible-centos-8-rhel-8%2F&t=How%20to%20Install%20Ansible%20%28Automation%20Tool%29%20on%20CentOS%208%2FRHEL%208 +[5]: http://twitter.com/share?text=How%20to%20Install%20Ansible%20%28Automation%20Tool%29%20on%20CentOS%208%2FRHEL%208&url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-ansible-centos-8-rhel-8%2F&via=Linuxtechi +[6]: http://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-ansible-centos-8-rhel-8%2F&title=How%20to%20Install%20Ansible%20%28Automation%20Tool%29%20on%20CentOS%208%2FRHEL%208 +[7]: http://www.reddit.com/submit?url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-ansible-centos-8-rhel-8%2F&title=How%20to%20Install%20Ansible%20%28Automation%20Tool%29%20on%20CentOS%208%2FRHEL%208 diff --git a/translated/tech/20191127 Displaying dates and times your way.md b/translated/tech/20191127 Displaying dates and times your way.md new file mode 100644 index 0000000000..e0ccbb3142 --- /dev/null +++ b/translated/tech/20191127 Displaying dates and times your way.md @@ -0,0 +1,166 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Displaying dates and times your way) +[#]: via: (https://www.networkworld.com/article/3481602/displaying-dates-and-times-your-way-with-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +按你的方式显示日期和时间 +====== + +> Linux date 命令提供了很多显示日期和时间的选项,要比你想的还要多。这是一些更有用的选择。 + +在 Linux 系统上,`date` 命令非常简单。你键入 `date`,日期和时间将以一种有用的方式显示。它包括星期几、日期、时间和时区: + +``` +$ date +Tue 26 Nov 2019 11:45:11 AM EST +``` + +只要你的系统配置正确,你就会看到日期和当前时间以及时区。 + +但是,该命令还提供了许多选项来以不同方式显示日期和时间信息。例如,如果要显示日期以进行排序,则可能需要使用如下命令: + +``` +$ date "+%Y-%m-%d" +2019-11-26 +``` + +在这种情况下,年、月和日按该顺序排列。请注意,我们使用大写字母 `Y` 来获得四位数的年份。如果我们使用小写的 `y`,则只会看到两位数字的年份(例如 19)。不要让这种想法使你联想到,如果 `%m` 给你一个数字月份,`%M` 可能会给你月份的名称。不,`%M` 将给你分钟数。要以缩写名称格式获得月份,你要使用 `%b`,而对于完全拼写的月份,则要使用 `%B`。 + +``` +$ date "+%b %B" +Nov November +``` + +或者,你可能希望以这种常用格式显示日期: + +``` +$ date +%D +11/26/19 +``` + +如果你需要四位数的年份,则可以执行以下操作: + +``` +$ date "+%x" +11/26/2019 +``` + +下面是一个可能有用的示例。假设你需要创建一个每日报告并在文件名中包含日期,则可以使用以下命令来创建文件(可能用在脚本中): + +``` +$ touch Report-`date "+%Y-%m-%d"` +``` + +当你列出你的报告时,它们将按日期顺序或反向日期顺序(如果你添加 `-r`)列出。 + +``` +$ ls -r Report* +Report-2019-11-26 +Report-2019-11-25 +Report-2019-11-22 +Report-2019-11-21 +Report-2019-11-20 +``` + +你还可以在日期字符串中添加其他详细信息。可用的各种选项令人惊讶。你可以使用 `date "+%q"` 来显示你所在的一年中的哪个季度,或使用类似以下命令来显示两个月前的日期: + +``` +$ date --date="2 months ago" +Thu 26 Sep 2019 09:02:43 AM EDT +``` + +是否想知道下周四的日期?你可以使用类似 `date --date="next thu"` 的命令,但是要理解,对于Linux,下个周四意味着今天之后的周四。如果今天是星期三,那就是明天,而不是下周的星期四。但是,你可以像下面的第二个命令一样指定下周的星期四。 + +``` +$ date --date="next thu" +Thu 28 Nov 2019 12:00:00 AM EST +$ date --date="next week thu" +Thu 05 Dec 2019 12:00:00 AM EST +``` + +`date` 命令的手册页列出了其所有选项。该列表令人难以置信,但是你可能会发现一些日期/时间显示选项非常适合您。以下是一些你可能会发现有趣的东西。 + +世界标准时间(UTC): + +``` +$ date -u +Tue 26 Nov 2019 01:13:59 PM UTC +``` + +自 1970 年 1 月 1 日以来的秒数(与 Linux 系统上日期的存储方式有关): + +``` +$ date +%s +1574774137 +``` + +这是 `date` 命令选项的完整列表。正如我所说,它比我们大多数人想象的要广泛得多。 + +- `%%` 字母 % +- `%a` 语言环境的缩写星期名称(例如,日 / Sun) +- `%A` 语言环境的完整星期名称(例如,星期日 / Sunday) +- `%b` 语言环境的缩写月份名称(例如 一 / Jan) +- `%B` 语言环境的完整月份名称(例如,一月 / January) +- `%c` 语言环境的日期和时间(例如 2005年3月3日 星期四 23:05:25 / Thu Mar 3 23:05:25 2005) +- `%C` 世纪;类似于 `%Y`,但省略了后两位数字(例如,20) +- `%d` 月份的天(例如,01) +- `%D` 日期;与 `%m/%d/%y` 相同 +- `%e` 月份的天,填充前缀空格;与 `%_d` 相同 +- `%F` 完整日期;与 `%Y-%m-%d` 相同 +- `%g` ISO 周号的年份的后两位数字(请参见 `%G`) +- `%G` ISO 周号的年份(请参阅 `%V`);通常仅配合 `%V`有用 +- `%h` 与 `%b` 相同 +- `%H` 小时(00..23) +- `%I` 小时(01..12) +- `%j` 一年的天(001..366) +- `%k` 小时,填充前缀空格( 0..23);与 `%_H` 相同 +- `%l` 小时,填充前缀空格( 1..12);与 `%_I` 相同 +- `%m` 月份(01..12) +- `%M` 分钟(00..59) +- `%n` 换行符 +- `%N` 纳秒(000000000..999999999) +- `%p` 语言环境中等同于 AM 或 PM 的字符串;如果未知,则为空白 +- `%P` 像 `%p`,但使用小写 +- `%q` 季度(1..4) +- `%r` 语言环境的 12 小时制时间(例如,晚上 11:11:04 / 11:11:04 PM) +- `%R` 24 小时制的小时和分钟;与 `%H:%M` 相同 +- `%s` 自 1970-01-01 00:00:00 UTC 以来的秒数 +- `%S` 秒(00..60) +- `%t` 制表符 +- `%T` 时间;与 `%H:%M:%S` 相同 +- `%u` 星期(1..7);1 是星期一 +- `%U` 年的周数,以星期日为一周的第一天(00..53) +- `%V` ISO 周号,以星期一为一周的第一天(01..53) +- `%w` 星期(0..6);0 是星期日 +- `%W` 年的周数,星期一为一周的第一天(00..53) +- `%x` 语言环境的日期表示形式(例如,1999年12月31日 / 12/31/99) +- `%X` 语言环境的时间表示形式(例如,23:13:48) +- `%y` 年的最后两位数字(00..99) +- `%Y` 年 +- `%z` +hhmm 格式的数字时区(例如,-0400) +- `%:z` +hh:mm 格式的数字时区(例如,-04:00) +- `%::z` +hh:mm:ss 格式的时区(例如 -04:00:00) +- `%:::z` 数字时区,带有 `:` 达到必要的精度(例如 -04,+05:30) +- `%Z` 字母时区缩写(例如,EDT) + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3481602/displaying-dates-and-times-your-way-with-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world