diff --git a/published/20210104 Learn Fortran by writing a -guess the number- game.md b/published/20210104 Learn Fortran by writing a -guess the number- game.md new file mode 100644 index 0000000000..a39854453d --- /dev/null +++ b/published/20210104 Learn Fortran by writing a -guess the number- game.md @@ -0,0 +1,130 @@ +[#]: collector: (lujun9972) +[#]: translator: (unigeorge) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13849-1.html) +[#]: subject: (Learn Fortran by writing a "guess the number" game) +[#]: via: (https://opensource.com/article/21/1/fortran) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) + +通过写“猜数字”游戏学习 Fortran +====== + +> Fortran 是在打孔卡时代编写的语言,因此它的语法非常有限。但你仍然可以用它编写有用和有趣的程序。 + +![](https://img.linux.net.cn/data/attachment/album/202110/04/125311k6uwzpybabayyoag.jpg) + +Fortran 77 是我学习的第一门编译型编程语言。一开始时,我自学了如何在 Apple II 上用 BASIC 编写程序,后来又学会在 DOS 上用 QBasic 编写程序。但是当我去大学攻读物理学时,我又学习了 [Fortran][2]。 + +Fortran 曾经在科学计算中很常见。曾几何时,所有计算机系统都有一个 Fortran 编译器。Fortran 曾经像今天的 Python 一样无处不在。因此,如果你是像我这样的物理学专业学生,在 1990 年代工作,那你肯定学习了 Fortran。 + +我一直认为 Fortran 与 BASIC 有点相似,所以每当我需要编写一个简短程序,来分析实验室数据或执行其他一些数值分析时,我都会很快想到 Fortran。我在空闲时用 Fortran 编写了一个“猜数字”游戏,其中计算机会在 1 到 100 之间选择一个数字,并让我猜这个数字。程序会一直循环,直到我猜对了为止。 + +“猜数字”程序练习了编程语言中的几个概念:如何为变量赋值、如何编写语句以及如何执行条件判断和循环。这是学习新编程语言时一个很好的的实践案例。 + +### Fortran 编程基础 + +虽然 Fortran 这些年来一直在更新,但我最熟悉的还是 Fortran 77,这是我多年前学习的实现版本。Fortran 是程序员还在打孔卡上编程的年代创建的,因此“经典” Fortran 仅限于处理可以放在打孔卡上的数据。这意味着你只能编写符合以下限制条件的经典 Fortran 程序(LCTT 译注:后来的 Fortran 95 等版本已经对这些限制做了很大的改进,如有兴趣**建议直接学习新版**): + + * 每张卡只允许一行源代码。 + * 仅识别第 1-72 列(最后八列,73-80,保留给卡片分类器)。 + * 行号(“标签”)位于第 1-5 列。 + * 程序语句在第 7-72 列。 + * 要表示跨行,请在第 6 列中输入一个连续字符(通常是 `+`)。 + * 要创建注释行,请在第 1 列中输入 `C` 或 `*`。 + * 只有字符 `A` 到`Z`(大写字母)、`0` 到`9`(数字)和特殊字符 `= + - * / ( ) , . $ ' :` 和空格能够使用。 + +虽然有这些限制,你仍然可以编写非常有用和有趣的程序。 + +### 在 Fortran 中猜数字 + +通过编写“猜数字”游戏来探索 Fortran。这是我的实现代码: + +``` +CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC +C     PROGRAM TO GUESS A NUMBER 1-100 +CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC +      PROGRAM GUESSNUM +      INTEGER SEED, NUMBER, GUESS + +      PRINT *, 'ENTER A RANDOM NUMBER SEED' +      READ *, SEED +      CALL SRAND(SEED) + +      NUMBER = INT( RAND(0) * 100 + 1 ) + +      PRINT *, 'GUESS A NUMBER BETWEEN 1 AND 100' + 10   READ *, GUESS + +      IF (GUESS.LT.NUMBER) THEN +         PRINT *, 'TOO LOW' +      ELSE IF (GUESS.GT.NUMBER) THEN +         PRINT *, 'TOO HIGH' +      ENDIF + +      IF (GUESS.NE.NUMBER) GOTO 10 + +      PRINT *, 'THATS RIGHT!' +      END +``` + +如果你熟悉其他编程语言,你大概可以通过阅读源代码来弄清楚这个程序在做什么。前三行是注释块,表示程序的功能。第四行 `PROGRAM GUESSNUM` 将其标识为一个 程序program,并由最后一行的 `END` 语句关闭。 + +定义变量后,程序会提示用户输入随机数种子。Fortran 程序无法从操作系统初始化随机数生成器,因此你必须始终使用“种子”值和 `SRAND` 子程序subroutine 启动随机数生成器。 + +Fortran 使用 `RAND(0)` 函数生成 0 到 0.999…… 之间的随机数。参数 `0` 告诉 `RAND` 函数生成一个随机数。将此随机数乘以 100 以生成 0 到 99.999…… 之间的数字,然后加 1 得到 1 到 100.999…… 之间的值。`INT` 函数将结果截断为整数;因此,变量 `NUMBER` 就是一个介于 1 到 100 之间的随机数。 + +程序会给出提示,然后进入一个循环。Fortran 不支持更现代的编程语言中可用的 `while` 或 `do-while` 循环(LCTT 译注:Fortran 95 等新版支持,也因此在一定程度上减少了 `GOTO` 的使用)。相反,你必须使用标签(行号)和 `GOTO` 语句来构建自己的循环。这就是 `READ` 语句有一个行号的原因:你可以在循环末尾使用 `GOTO` 跳转到此标签。 + +穿孔卡片没有 `<`(小于)和 `>`(大于)符号,因此 Fortran 采用了另一种语法来进行值比较。要测试一个值是否小于另一个值,请使用 `.LT.`(小于)。要测试一个值是否大于另一个值,请使用 `.GT.`(大于)。等于和不等于分别是 `.EQ.` 和 `.NE.`。 + +在每次循环中,程序都会验证用户的猜测值。如果用户的猜测值小于随机数,程序打印 `TOO LOW`,如果猜测大于随机数,程序打印 `TOO HIGH`。循环会一直持续,直到用户的猜测值等于目标随机数为止。 + +当循环退出时,程序打印 `THATS RIGHT!` 并立即结束运行。 + +``` +$ gfortran -Wall -o guess guess.f + +$ ./guess + ENTER A RANDOM NUMBER SEED +93759 + GUESS A NUMBER BETWEEN 1 AND 100 +50 + TOO LOW +80 + TOO HIGH +60 + TOO LOW +70 + TOO LOW +75 + TOO HIGH +73 + TOO LOW +74 + THATS RIGHT! +``` + +每次运行程序时,用户都需要输入不同的随机数种子。如果你总是输入相同的种子,程序给出的随机数也会一直不变。 + +### 在其他语言中尝试 + +在学习一门新的编程语言时,这个“猜数字”游戏是一个很好的入门程序,因为它以非常简单的方式练习了几个常见的编程概念。通过用不同的编程语言实现这个简单的游戏,你可以弄清一些核心概念以及比较每种语言的细节。 + +你有最喜欢的编程语言吗?如何用你最喜欢的语言来编写“猜数字”游戏?跟随本系列文章来查看你可能感兴趣的其他编程语言示例吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/1/fortran + +作者:[Jim Hall][a] +选题:[lujun9972][b] +译者:[unigeorge](https://github.com/unigeorge) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jim-hall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/1980s-computer-yearbook.png?itok=eGOYEKK- (Person typing on a 1980's computer) +[2]: https://en.wikipedia.org/wiki/Fortran diff --git a/published/20210607 Comparing Linux Mint and Fedora- Which One Should You Use.md b/published/20210607 Comparing Linux Mint and Fedora- Which One Should You Use.md new file mode 100644 index 0000000000..a53b8aef60 --- /dev/null +++ b/published/20210607 Comparing Linux Mint and Fedora- Which One Should You Use.md @@ -0,0 +1,186 @@ +[#]: subject: (Comparing Linux Mint and Fedora: Which One Should You Use?) +[#]: via: (https://itsfoss.com/linux-mint-vs-fedora/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Linux Mint 和 Fedora:应该使用哪一个? +====== + +![](https://img.linux.net.cn/data/attachment/album/202110/04/123523kzzm3x4yr2ppmfj9.jpg) + +Linux Mint 是一个 [为初学者定制的流行的 Linux 发行版][1],同时为用户提供了与 Windows 类似的体验。事实上,它有 [一些地方比 Ubuntu 做的更好][2],这使它成为每一类用户的合适选择。 + +它是基于 Ubuntu 的,完全由社区所支持。 + +另一方面,Fedora 是一个尝鲜发行版,它专注于纳入令人兴奋的变化,最终使其成为红帽企业 Linux(RHEL)的一部分。 + +与 Linux Mint 不同,Fedora 并不完全专注于个人(或非开发者)使用。即使他们提供了一个工作站版本,其目标也是开发者和有经验的 Linux 用户。 + +### Fedora 或 Mint,应该根据什么选择? + +虽然我们知道 Fedora 并不是完全面向 Linux 新手的,但许多用户喜欢使用 Fedora 作为他们的日常系统。因此,在这篇文章中,我们将阐明两者之间的一些区别,以帮助你选择一个在你的台式机上使用的操作系统。 + +#### 系统要求 & 硬件兼容性 + +![][3] + +在选择任何 Linux 发行版之前,你都应该看一下它的系统要求,并检查硬件兼容性。 + +在这方面,Linux Mint 和 Fedora 都需要至少 2GB 的内存、20GB 的磁盘空间,以及 1024 x 768 分辨率的显示器来获得入门级的体验。 + +是的,官方文件可能提到 1GB 内存就可以起步,但要看实际使用情况。除非你有一台复古的电脑,想为一个特定的目的恢复它,否则它就不在考虑范围之内。 + +![Linux Mint 资源使用情况][4] + +在技术上,两者都支持现代的和陈旧的硬件,你只有在安装时才会知道软件/驱动是否支持它。除非你有一个特殊的外围设备或具有特殊功能的硬件组件,否则硬件支持可能不是什么大问题。 + +Linux Mint 19 系列仍然提供了对 32 位系统的支持,你可以使用它到 2023 年 4 月。而 Fedora 已经不支持 32 位系统了。 + +#### 软件更新周期 + +![Linux Mint 更新管理器][5] + +Linux Mint 专注于长期发布版(LTS),支持时间为五年。它的维护方式与 Ubuntu 相同。但没有像 Ubuntu 那样提供付费的扩展支持。 + +Fedora 不提供 LTS 版本,而是每 6 个月推送一次新的更新,每个版本都会得到 13 个月的软件支持。如果你愿意,你可以跳过一个版本。 + +如果你只是想安装一个可以使用多年的 Linux 发行版,而不在乎是不是最新的技术/功能,那么 Linux Mint 是个不错的选择。 + +但是,如果你想要最新的和最伟大的 Linux 技术(在一些罕见的情况下,这也可能破坏你的计算体验),并接受适应 Fedora 推动的重大变化,Fedora 可以是一个选择。 + +#### 桌面环境的选择 + +![Linux Mint Cinnamon 版][6] + +Linux Mint 提供三种不同的 [桌面环境][7]:MATE、Cinnamon 和 Xfce。它们有相同的更新周期,并从发布之日起支持 5 年。 + +尽管 Fedora 不提供 LTS 版本,但你可以通过 Fedora spins 的形式选择各种桌面。你可以得到 KDE、LXQt、MATE、Cinnamon、LXDE,以及一个内置 i3 平铺窗口管理器的版本。 + +![Fedora 34 with GNOME 40][8] + +所以,如果你想有更多的选择,Fedora 可以是一个相当令人激动的选择。 + +#### 软件可用性 + +![Linux Mint 的软件中心和软件包管理器][9] + +Linux Mint(或 Ubuntu)的默认软件库提供了大量可以安装的软件,而 Fedora 的默认软件库只坚持提供开源软件。 + +不仅仅限于此,Linux Mint 还配备了 [Synaptic 软件包管理器][10],这是一个令人印象深刻的安装软件的轻量级工具。 + +尽管你可以 [在 Fedora 中启用第三方软件库][11],但这又是一个额外的步骤。而且,RPM Fusion 存储库可能没有 Ubuntu 的 universe 存储库那么庞大。 + +![Fedora 34 软件中心][12] + +所以,对于 Linux Mint 来说,总的来说,你可以得到更多可安装的软件包和各种安装软件的方法,开箱即用。 + +#### 使用和安装的便利性 + +对于一个 Linux 的新嫩用户来说,Ubuntu 或任何基于 Ubuntu 的发行版通常都是一个很好的开端。 + +从 [Ubuntu 的安装体验][13],到 [安装软件][14] 的简便性,同时还可以选择 LTS 版本,这让初学者觉得很方便。 + +而且,借助 Ubiquity 安装程序,Linux Mint 自然也有与 Ubuntu 相同的好处,因此,它的学习曲线最小,易于安装,易于使用。 + +虽然从表面上看 Fedora 并不复杂,但安装选项、软件包管理器以及默认存储库中缺乏的软件可能是一个耗时的因素。 + +如果你没有尝试过,我建议你试试我们的 [VirtualBox 版的 Fedora 安装指南][15]。这是一个测试安装体验的好方法,然后再在你的任何生产系统上进行尝试。 + +#### 开箱即用的体验 + +最省事的体验通常是令人愉快的选择。嗯,对大多数人来说。 + +现在,你需要明白,根据硬件配置的不同,每个用户最终可能会有不同的“开箱即用”体验。 + +但是,作为参考,让我给你举个 Fedora 和 Linux Mint 的例子。 + +考虑到我的电脑上使用的是 NVIDIA GPU,我需要安装专有的驱动程序以获得最佳性能。 + +![][16] + +而且,当我启动 Linux Mint 时,使用“驱动程序管理器”应用程序,安装驱动程序相当容易。 + +但是,对于 Fedora,即使我按照我们的 [在 Fedora 中安装 Nvidia 驱动程序][17] 的指南,我在重启时还是出现了一个错误。 + +![在 Fedora 中安装 NVIDIA 驱动程序][18] + +不仅如此,由于某些原因,我的有线网络似乎没有被激活,因此,我没有互联网连接。 + +是的,当你遇到问题时,你总是可以尝试着去排除故障,但是对于 Linux Mint,我不需要这么做。所以,根据我的经验,我会推荐 Linux Mint,它有更好的开箱体验。 + +#### 文档 + +如果你依赖于文档资源并想在这个过程中挑战自己,获得不错的学习经验,我推荐你去看看 [Fedora 的文档][19]。 + +你会发现最近和最新的 Fedora 版本的最新信息,这是件好事。 + +另一方面,[Linux Mint 的文档][20] 没有定期更新,但在你想深入挖掘时很有用。 + +#### 社区支持 + +你会得到一个良好的社区支持。[Linux Mint 的论坛][21] 是一个很基础的平台,容易使用并能解决问题。 + +[Fedora 的论坛][22] 是由 Discourse 驱动的,它是最 [流行的现代开源论坛软件][23] 之一。 + +#### 企业与社区的角度 + +Fedora 得到了最大的开源公司 [红帽][24] 的支持 —— 因此你可以得到良好的持续创新和长期的支持。 + +然而,正因为 Fedora 并不是为日常电脑用户而建立的,每一个版本的选择都可能完全影响你的用户体验。 + +另一方面,Linux Mint 完全由一个充满激情的 Linux 社区所支持,专注于使 Linux 在日常使用中更加容易和可靠。当然,它依赖于 Ubuntu 作为基础,但如果社区不喜欢上游的东西,Linux Mint 也会做出大胆的改变。 + +例如,Linux Mint 与 Ubuntu 官方发行版不同,默认情况下禁用了 snap。所以,如果你想使用它们,你就必须 [在 Linux Mint 中启用 snap][25]。 + +### 总结 + +如果你想为你的家用电脑选择一个没有问题的、易于使用的操作系统,我的建议是 Linux Mint。但是,如果你想体验最新的、最伟大的 Linux 操作系统,同时在你的 Linux 学习经历中进行一次小小的冒险,Fedora 可以是一个不错的选择。 + +虽然每个操作系统都需要某种形式的故障排除,没有什么能保证你的硬件完全不出问题,但我认为 Linux Mint 对大多数用户来说可能没有问题。 + +在任何情况下,你可以重新审视上面提到的比较点,看看什么对你的电脑最重要。 + +你怎么看?你会选择 Fedora 而不是 Mint 吗?还有,为什么?请在下面的评论中告诉我。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/linux-mint-vs-fedora/ + +作者:[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/best-linux-beginners/ +[2]: https://itsfoss.com/linux-mint-vs-ubuntu/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/fedora-34-about.png?resize=1020%2C709&ssl=1 +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/linux-mint-resources.png?resize=800%2C293&ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/linux-mint-update-manager.png?resize=819%2C612&ssl=1 +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/linux-mint-cinnamon-desktop.png?resize=800%2C450&ssl=1 +[7]: https://itsfoss.com/best-linux-desktop-environments/ +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/fedora-34-desktop.png?resize=800%2C478&ssl=1 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/linux-mint-software-sources.png?resize=800%2C385&ssl=1 +[10]: https://itsfoss.com/synaptic-package-manager/ +[11]: https://itsfoss.com/fedora-third-party-repos/ +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/05/fedora-34-software.png?resize=1055%2C691&ssl=1 +[13]: https://itsfoss.com/install-ubuntu/ +[14]: https://itsfoss.com/remove-install-software-ubuntu/ +[15]: https://itsfoss.com/install-fedora-in-virtualbox/ +[16]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/linux-mint-driver-manager.jpg?resize=800%2C548&ssl=1 +[17]: https://itsfoss.com/install-nvidia-drivers-fedora/ +[18]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/fedora-nvidia-driver-installation.png?resize=706%2C516&ssl=1 +[19]: https://docs.fedoraproject.org/en-US/docs/ +[20]: https://linuxmint.com/documentation.php +[21]: https://forums.linuxmint.com +[22]: https://ask.fedoraproject.org +[23]: https://itsfoss.com/open-source-forum-software/ +[24]: https://www.redhat.com/en +[25]: https://itsfoss.com/enable-snap-support-linux-mint/ diff --git a/published/20210616 Top 5 Chrome-like Browsers That Are Better Than Google Chrome in 2021.md b/published/20210616 Top 5 Chrome-like Browsers That Are Better Than Google Chrome in 2021.md new file mode 100644 index 0000000000..ea7ebdd97e --- /dev/null +++ b/published/20210616 Top 5 Chrome-like Browsers That Are Better Than Google Chrome in 2021.md @@ -0,0 +1,180 @@ +[#]: subject: (Top 5 Chrome-like Browsers That Are Better Than Google Chrome in 2021) +[#]: via: (https://news.itsfoss.com/chrome-like-browsers-2021/) +[#]: author: (Jacob Crume https://news.itsfoss.com/author/jacob/) +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13858-1.html) + +Linux 上 5 个基于 Chromium 的浏览器 +====== + +> 谷歌浏览器可能不是 Linux 用户的最佳浏览器。在这里,我们探讨了 Linux 平台的其他潜在选择。 + +![](https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/chrome-alternatives-2021.png?w=1200&ssl=1) + +想摆脱谷歌?想为你的 Linux 系统寻找可能比谷歌浏览器(和类似的)更好的浏览器? + +幸运的是,有多个谷歌浏览器的替代品,你可以试试。 + +它们中的每一个都带来了一些有趣的东西,同时也保持了 Chrome 所特有的奇妙兼容性。请继续阅读,了解这些浏览器的更多信息。 + +### 比谷歌浏览器更好的选择 + +> 注:虽然 [自由和开源软件在取代科技巨头方面扮演着关键角色][1],但除了谷歌浏览器之外,Linux 上的任何选择都是一个好的开始。因此,你也会发现一些非 FOSS 的选择。 + +在我看来,Chrome 的最佳替代品是基于 Chromium 的浏览器,这意味着它们与 Chrome 共享相同的基因。这样做的好处是,它们已经拥有与 Chrome 相同的功能,同时有更多时间来增加自己的功能。 + +另外,如果你愿意,你可以了解一下不基于 Chromium 的 [Chrome 开源替代品][2]。 + +无论如何,即使谷歌浏览器的替代品对你来说并不优越,也值得尝试远离科技巨头。 + +我们收集了一些在各方面与 Chrome 相当或更好的浏览器。闲话少说,以下是我挑选的五款比 Chrome 本身更好的类似 Chrome 的浏览器: + + * UnGoogled Chromium + * Brave + * Edge + * Vivaldi + * Opera + +这份名单没有排名顺序。 + +### 1、UnGoogled Chromium + +![][13] + +特点: + + * 移除针对谷歌域名的功能 + * 在运行时阻止对 Google 的内部请求 + * 从源代码中剥离谷歌的二进制文件 + * 许多新的命令行开关和 `chrome://flags` 条目 + * 强制所有弹出式窗口为标签 + +对于那些隐私爱好者来说,[UnGoogled Chromium][4] 浏览器将是一个天赐良机。虽然它可能看起来与 Chrome 相同,但它有许多隐私方面的调整。 + +顾名思义,对于 Chrome 浏览器的用户来说,最大的倒退将是没有谷歌的服务集成。但这也意味着不再有对谷歌的内部请求、谷歌网址跟踪等等。 + +它没有吹嘘任何非凡的东西来保护你的隐私,但它应该比谷歌浏览器更好。 + +你也可以选择通过 `chrome://flags` 设置来探索和切换隐私设置。 + +总而言之,UnGoogled Chromium 提供了一种熟悉的浏览体验,同时还加入了一套隐私功能。它是可靠的,而且还与 Chrome 扩展程序庞大的生态系统兼容。 + +### 2、Brave + +![][14] + +特点: + + * 内置广告拦截器 + * 更快的页面加载时间 + * Brave 奖励计划 + * 能够在设备之间进行同步 + * 支持 Chrome Web 商店 + +当 [Brave][6] 在 2016 年首次登上舞台时,世界各地的人们都震惊于它的隐私和性能特点。在发布时,这包括了一个内置的广告屏蔽器和一个新的用户界面。 + +从那时起,该浏览器有了更多的功能,包括奖励计划和 [Tor][5] 整合。这使得它成为增长最快的浏览器之一。 + +### 3、Edge + +![][15] + +特点: + + * 支持 Chrome Web 商店 + * 儿童浏览模式(额外的保护和更简单的用户界面) + * 良好的 PDF 编辑工具 + * 内置优惠券搜索器 + * 阅读模式 + * 内置密码生成器 + +当微软 [Edge][7] 在 2015 年首次与 Windows 10 一起发布时,它因缓慢和有缺陷而被广泛批评。然而,在 2020 年初,它使用 Chromium Web 引擎完全重新制作了。 + +这也是 Chrome 浏览器所基于的引擎,这提供了现代和快速的浏览体验。这种转变的一个好处是 Web 浏览器能够在许多不同的平台上运行,从 Windows 7 和 macOS 到 Ubuntu 和其他基于 Linux 的发行版。 + +我知道,如果你因为某些原因讨厌微软,这可能不会吸引你 —— 但 Linux 版的微软 Edge 是谷歌 Chrome 浏览器的一个重要替代品。 + +### 4、Vivaldi + +![][16] + +特点: + + * 内置翻译器 + * Vivaldi Email(Beta) + * Feed 阅读器(Beta) + * Vivaldi 日历(Beta) + * 可高度定制的用户界面 + * 内置广告拦截器 + * 支持 Chrome Web 商店 + * 标签分组 + * 分屏标签 + +[Vivaldi][11] 于 2016 年首次发布,它在浏览器大战中迅速崛起。它最初是为对 [Presto][8] [布局引擎][9] 过渡不满的 Opera 用户设计的,它已经成功地重新实现了 Opera 过渡到 Chromium 期间失去的许多功能。 + +令人惊讶的是,它在基于 Chromium 的情况下还能做到这一点(正是 Opera 放弃这些功能的原因)。 + +最新的 [Vivaldi 4.0 版本][10] 也为高级用户提供了一些功能。 + +虽然它不是 100% 的自由软件,但其 93% 的源代码是可用的,只有用户界面是专有的。考虑到 Vivaldi 的开发团队积极关注着 Linux 用户的改进,Vivaldi 提供了大量的功能,这可能是一个值得权衡的结果。 + +### 5、Opera + +![][17] + +特点: + + * 内置虚拟专用网络 + * 轻松访问社交媒体 + * 内置加密货币钱包 + * 欺诈和恶意软件保护 + * 高度可见的网站安全徽章 + +虽然 [Opera][12] 从未成为 Web 浏览器之王,但它一直存在于关于使用何种浏览器的争论中。它最初是基于其内部的 Presto 布局引擎的,在 2013 年切换到 Chromium。 + +不幸的是,这一转换意味着 Opera 团队被迫放弃了其最知名的一些功能,为 Vivaldi 和 Firefox 等替代品填补 Opera 留下的空间铺平道路。 + +这并不是说 Opera 缺乏功能,它包含了许多功能。 + +### 总结 + +在这里,我们列出了为 Linux 桌面平台上用户量身定做的浏览器。 + +无论你是想要更多的功能、更好的用户界面,还是想要帮助你摆脱谷歌的束缚,都有一个选择适合你。 + +由于所有这些浏览器都是基于 Chromium 的,它们都能像 Chrome 一样提供良好的兼容性和用户体验。因此,请切换到这些类似 Chrome 的浏览器中,享受它们各自赋予的自由吧。 + +2021 年,你最喜欢的 Linux 上谷歌浏览器的替代品是什么?请在下面的评论中告诉我。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/chrome-like-browsers-2021/ + +作者:[Jacob Crume][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://news.itsfoss.com/author/jacob/ +[b]: https://github.com/lujun9972 +[1]: https://news.itsfoss.com/save-privacy-with-foss/ +[2]: https://itsfoss.com/open-source-browsers-linux/ +[4]: https://github.com/Eloston/ungoogled-chromium +[5]: https://itsfoss.com/tor-guide/ +[6]: https://brave.com +[7]: https://www.microsoftedgeinsider.com/en-us/download +[8]: https://en.wikipedia.org/wiki/Presto_(browser_engine) +[9]: https://en.wikipedia.org/wiki/Browser_engine +[10]: https://news.itsfoss.com/vivaldi-4-0-release/ +[11]: https://vivaldi.com +[12]: https://www.opera.com +[13]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/05/ungoogled-chromium-screenshot.png?w=1366&ssl=1 +[14]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/brave-homepage.png?w=1366&ssl=1 +[15]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/edge-homepage.png?w=1366&ssl=1 +[16]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/vivaldi-4.0-homepage.png?w=1366&ssl=1 +[17]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/opera-homepage.png?w=1366&ssl=1 \ No newline at end of file diff --git a/published/20210702 Creating a PKGBUILD to Make Packages for Arch Linux.md b/published/20210702 Creating a PKGBUILD to Make Packages for Arch Linux.md new file mode 100644 index 0000000000..1303a2a5ee --- /dev/null +++ b/published/20210702 Creating a PKGBUILD to Make Packages for Arch Linux.md @@ -0,0 +1,263 @@ +[#]: subject: (Creating a PKGBUILD to Make Packages for Arch Linux) +[#]: via: (https://itsfoss.com/create-pkgbuild/) +[#]: author: (Hunter Wittenborn https://itsfoss.com/author/hunter/) +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13843-1.html) + +Arch Linux 软件包制作入门 +====== + +![](https://img.linux.net.cn/data/attachment/album/202110/02/130702ybexb5tsvkx1xbs1.jpg) + +`PKGBUILD` 文件是为 Arch Linux 及其衍生版(如 Manjaro)构建和创建软件包的方式。 + +如果你曾经使用过 [AUR][1](即 Arch Linux 的用户维护的 `PKGBUILD` 存储库),你甚至可能也遇到过它们。 + +但是,到底是如何从 `PKGBUILD` 到可安装软件包的呢?这两者之间到底发生了什么,如何把自己的软件制作成软件包呢?你将在这篇文章中了解这些。 + +### PKGBUILD 基础知识 + +对于那些熟悉 Bash 或其他 shell 的人来说,你可能知道,`PKGBUILD` 就是一个带有一些变量的 shell 脚本。 + +`PKGBUILD` 文件由变量和函数组成,所有这些都是用来定义软件包本身,以及如何构建它。 + +为了从 `PKGBUILD` 中创建一个软件包,需要使用 `makepkg` 命令行工具。在获得 `PKGBUILD` 文件后,你只需在包含 `PKGBUILD` 的目录中运行 `makepkg',就可以得到一个可安装的软件包了。 + +![][2] + +在本教程中,你将会看到我刚刚制作的软件包,它在运行时打印出 “Hello World!”。 + +![][3] + +### 准备 + +为了继续学习本教程,你需要创建几个文件。 + +首先,你需要创建一个名为 `PKGBUILD` 的文件,它将作为构建你的软件包的“配方”。 + +你需要做的另一个文件是一个叫 `hello-world.sh` 的文件。我稍后会解释它的用途。 + +你也可以用一个命令来创建这两个文件: + +``` +touch PKGBUILD hello-world.sh +``` + +你可以用 `ls` 命令检查这些文件是否被创建。 + +![][4] + +然后你就可以开始了! + +### 设置你的 PKGBUILD 文件 + +我不会让你复制粘贴整个文件,而是和你一起键入每一行,这样你就能更好地理解每一行的目的。如果你不喜欢这种学习方式,我强烈推荐 [Arch 维基][5] 中为 Arch Linux 创建软件包的文章。 + +这篇文章也没有介绍 `PKGBUILD` 中可以设置的每一个选项,只是介绍了一些常用的选项,以便你能尽快上手。 + +说完了这些,打开你的文本编辑器,让我们直接进入正题吧。 + +#### pkgname + +首先是 `pkgname` 变量。这是安装时定义软件包名称的东西,也是 [Arch Linux 的软件包管理器 pacman][6] 跟踪软件包的方式。 + +这个变量(以及其他一些变量)的格式是 `variable=value`,变量名在左边,变量的值在右边,用等号隔开。 + +要设置包的名称,请在 `PKGBUILD` 中输入以下内容: + +``` +pkgname="hello-world" +``` + + * 要设置一个不同的软件包名称,用你的软件包的名称替换 `hello-world`。 + * 这并不设置用于运行程序的命令,这将在下面的 `package()` 部分中处理。 + +#### pkgver + +正如变量名称本身所述,它设置了你的软件包的版本(即 `1.0.0`)。这在用户更新他们的系统时很有用,因为设置更高的版本会提示用户升级。 + +要设置版本号,请在 `PKGBUILD` 中输入以下内容(在前一行之后): + +``` +pkgver="1.0.0" +``` + +#### pkgrel + +这与 `pkgver` 变量有关,通常不需要知道。不过和 `pkgver` 变量一样,如果它被换到一个更高的数字,就将通知用户进行升级。 + +它适用于任何需要保持 `pkgver` 不变的情况下,例如 `PKGBUILD` 本身发生了变化。如果你为一个你使用的程序创建了一个 `PKGBUILD`(并希望保持软件包的版本相同),而你需要修复 `PKGBUILD` 本身的一个错误,这将是非常有用的。 + +要设置这个变量,请在 `PKGBUILD` 中输入以下内容: + +``` +pkgver="1" +``` + +这个变量应该 **总是** 从 `1` 开始,然后一次一次地向上移动。当 `pkgver` 本身向上移动时,这个变量可以(也应该)重置为 `1`,因为 `pkgver` 本身会通知用户升级。 + +#### pkgdesc + +这将设置软件包的描述,用于帮助更好地识别该软件包。 + +要设置它,只需将描述放在引号内: + +``` +pkgdesc="Hello world in your terminal!" +``` + +#### arch + +这个变量设置软件包所兼容的 [硬件架构][7]。如果你不明白什么是架构,那也没关系,因为在大多数情况下,这个变量几乎是无用的。 + +无论如何,`makepkg` 仍然需要设置它,这样它就知道这个软件包与我们的系统是兼容的。 + +这个变量支持设置多个值,所以 `makepkg` 需要一个不同的语法,如下所示。 + +要设置它,请在 `PKGBUILD` 中输入以下内容: + +``` +arch=("x86_64") +``` + +如果你要设置多个值,需要用空格和引号分隔每个值,像这样。`arch=(“x86_x64" "arm")`。 + +#### depends + +这列出了提供了我们的软件包所需功能的所有软件包。与 `arch` 一样,它也可以包含多个值,因此必须使用括号语法。 + +由于我们的软件包没有任何依赖关系,所以我们不需要在 `PKGBUILD` 中输入这个字段。然而,如果我们的软件包有依赖关系,我们就会使用与 `arch` 相同的语法。 + +#### optdepends + +这里列出了那些并不是提供所需功能而是额外功能的软件包。 + +这与 `depends` 的语法相同。 + +#### conflicts + +这告诉 `pacman` 哪些软件包会导致我们的软件包出现问题,或者以我们不希望的方式行事。 + +这里列出的任何软件包都会在我们的软件包被安装之前被卸载。 + +这与 `depends` 的语法相同。 + +#### license + +这定义了你的程序所采用的 [软件许可证][8]。如果你需要帮助你选择一个许可证,[Arch 维基][9] 提供了一些信息。如果你不知道该怎么设置,将其设置为 `custom` 也可以。 + +这与 `arch` 和 `depends` 的语法相同: + +``` +license=("custom") +``` + +#### source + +这就是 `makepkg` 如何知道要用什么文件来构建我们的软件包。它可以包含各种不同类型的源,包括本地文件和 URL。 + +在添加本地文件时,要输入相对于 `PKGBUILD` 文件的文件路径,比如以下目录布局: + +``` +PKGBUILD +file.txt +src/file.sh +``` + +如果你想在我们的 `PKGBUILD` 中包括 `file.sh`,你需要输入 `src/file.sh` 作为其名称。 + +当输入 URL 时,你只需输入完整的 URL,即 `https://mirrors.creativecommons.org/presskit/logos/cc.logo.large.png`。 + +你的这个软件包只需要 `hello-world.sh` 文件,由于它和 `PKGBUILD` 在同一个目录中,你只需输入它的名字作为 `source` 的值。 + +这个变量也使用与 `arch` 和 `depends` 相同的语法: + +``` +source=("hello-world.sh") +``` + +#### sha512sums + +这是用来验证 `source` 中的文件没有被修改或下载错误。如何获得这个值的信息可以在 [Arch 维基关于 PKGBUILD 的文章][10] 中找到。 + +如果你宁愿不设置这个(或者你只是不需要,例如对于本地文件),你可以为 `source` 变量中的每个文件输入 `SKIP`: + +``` +sha512sums=("SKIP") +``` + +#### package() + +这是最后一个,也是实际制作我们的包的最重要的部分。在处理这个问题时,知道两个变量很重要。 + + * `${srcdir}`:这是 `makepkg` 放置 `source` 变量中文件的地方。在这个目录中,你可以与这些文件进行交互,并对文件进行任何其他需要的修改。 + * `${pkgdir}`:这是我们放置将被安装在系统中的文件的地方。 +`${pkgdir}` 的文件夹结构是按照实际系统中的情况设置的(例如,使用 `pacman` 安装时,`${pkgdir}/usr/bin/hello-world` 会创建文件 `/usr/bin/hello-world`)。 + +`package()` 包含一个用于创建软件包的命令列表。 + +因此,如果(假设)你需要有个在 `/usr/share/motto.txt` 写着 “Linux is superior to Windows ”的文件,你会运行这样的东西: + +``` +package() { + mkdir -p "${pkgdir}/usr/share" + echo "Linux is superior to Windows" | tee "${pkgdir}/usr/share/motto.txt" +} +``` + +关于上述命令的一些说明: + + * `${pkgdir}` 里面最初是 **不包含** 目录的。如果你跳过了 [mkdir 命令][11],`tee` 会输出一个错误,说这个目录不存在。 + * 在指定目录时,**总是** 在它们前面加上 `${pkgdir}` 或 `${srcdir}` 变量。如果输入 `/usr/share/motto.txt`,就会按照字面意义指向你当前运行的系统中的 `/usr/share/motto.txt`。 + +对于你的 `PKGBUILD`,你将把 `hello-world.sh` 文件放在目标系统的 `/usr/bin/hello-world` 中。你还将使该文件在运行时说 “Hello to you!”。 + +要做到这一点,请在 `PKGBUILD` 中输入以下内容: + +``` +package() { + echo 'Hello to you!' > "${srcdir}/hello-world.sh" + mkdir -p "${pkgdir}/usr/bin" + cp "${srcdir}/hello-world.sh" "${pkgdir}/usr/bin/hello-world" + chmod +x "${pkgdir}/usr/bin/hello-world" +} +``` + +然后就完成了!用 `makepkg -si` 构建和安装软件包,然后在终端运行 `hello-world`,查看其输出。 + +![][12] + +### 总结 + +就这样,你已经制作了你的第一个 `PKGBUILD`!你走在了为自己甚至是为 AUR 制作实际的软件包的路上。 + +有什么问题,或者有什么地方不对吗?请随时在下面的评论区发表。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/create-pkgbuild/ + +作者:[Hunter Wittenborn][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/hunter/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/aur-arch-linux/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/image.png?resize=748%2C689&ssl=1 +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/image-2.png?resize=682%2C260&ssl=1 +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/05/image-3.png?resize=682%2C265&ssl=1 +[5]: https://wiki.archlinux.org/title/Creating_packages +[6]: https://itsfoss.com/pacman-command/ +[7]: https://www.quora.com/What-is-CPU-architecture +[8]: https://en.wikipedia.org/wiki/Software_license +[9]: https://wiki.archlinux.org/title/PKGBUILD#license +[10]: https://wiki.archlinux.org/title/PKGBUILD#Integrity +[11]: https://linuxhandbook.com/mkdir-command/ +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/image-1.png?resize=561%2C281&ssl=1 diff --git a/sources/tech/20210721 Run GitHub Actions on Fedora CoreOS.md b/published/20210721 Run GitHub Actions on Fedora CoreOS.md similarity index 57% rename from sources/tech/20210721 Run GitHub Actions on Fedora CoreOS.md rename to published/20210721 Run GitHub Actions on Fedora CoreOS.md index c4b80e2b99..0a6ce8b4b6 100644 --- a/sources/tech/20210721 Run GitHub Actions on Fedora CoreOS.md +++ b/published/20210721 Run GitHub Actions on Fedora CoreOS.md @@ -2,31 +2,29 @@ [#]: via: (https://fedoramagazine.org/run-github-actions-on-fedora-coreos/) [#]: author: (Clément Verna https://fedoramagazine.org/author/cverna/) [#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13846-1.html) -Run GitHub Actions on Fedora CoreOS +在 Fedora CoreOS 上运行 GitHub Actions ====== ![][1] -[United Artists][2], Public domain, via Wikimedia Commons +[GitHub Actions][3] 是一项为快速建立持续集成和交付(CI/CD)工作流程而提供的服务。这些工作流程在被称为“运行器runner”的主机上运行。GitHub 提供的 [托管运行器][4] 的操作系统的选择是有限的(Windows Server、Ubuntu、MacOS)。 -[GitHub Actions][3] is a service provided to quickly setup continuous integration and delivery (CI/CD) workflows . These workflows run on hosts called _runners_. GitHub provides [hosted runners][4] with a limited set of operating system choice (Windows Server, Ubuntu, MacOS). +另一个选择是使用 [自托管][5] 的运行器,这让仓库管理员对运行器有更多控制。自托管的运行程序是专门为某个存储库或组织服务的。下面的文章介绍了使用 Fedora CoreOS 配置自托管运行程序的步骤。 -Another option is to use [self-hosted][5] runners which gives the repository administrator more control on the runners. Self-hosted runners are dedicated to a repository or organization. The following article goes through the steps of configuring self-hosted runners using Fedora CoreOS. +### 入门 -### Getting Started +Fedora CoreOS 是一个精简的操作系统,旨在便于大规模的部署和维护。该操作系统会自动更新,并默认提供运行容器所需的工具。由于这些原因,Fedora CoreOS 是运行 CI/CD 工作流程的一个极佳选择。 -Fedora CoreOS is a minimalist operating system designed to be easy to deploy and maintain at scale. The operating system will automaticaly update and provide, by default, the tools needed to run containers. For all of these reasons, Fedora CoreOS is a great choice to consider for running CI/CD workflows. +配置和配备 Fedora CoreOS 机器的第一步是生成一个 [Ignition][6] 文件。[Butane][7] 允许你使用更友好的格式(YAML)生成 Ignition 文件。 -The first step to configure and provision a Fedora CoreOS machine is to generate an [Ignition][6] file. [Butane][7] allows you to generate Ignition’s file using a friendlier format (YAML). +#### 配置一个 Fedora CoreOS 运行器 -#### Configure a Fedora CoreOS runner - -To execute GitHub actions on Fedora CoreOS, the host needs the binaries and scripts used to register and run the runner. Download the binaries and scripts from the [actions runner project][8] and deploy under _/usr/local/sbin/actions-runner_. +要在 Fedora CoreOS 上执行 GitHub Actions,托管主机需要用于注册和运行该运行器的二进制文件和脚本。从 [Actions 运行器项目][8] 下载二进制文件和脚本,并部署在 `/usr/local/sbin/actions-runner` 下。 ``` version: "1.3.0" @@ -51,13 +49,13 @@ storage: name: core ``` -#### Registration and Removal token +#### 注册和删除令牌 -Configuring runners for a project requires a “token”. This prevents registering or removing self-hosted runners from projects without the correct permissions. Tokens provided by Github have a one hour expiration time. If the runner restarts after this time it will require a new registration token. +为一个项目配置运行器需要一个“令牌token”。这可以防止在没有正确权限的情况下从项目中注册或删除自托管的运行器。GitHub 提供的令牌有一个小时的过期时间。如果运行器在这个时间之后重新启动,它将需要一个新的注册令牌。 -The token can be problematic, in particular with Fedora CoreOS automatic updates. The update process expects that the host will restart at least once every couple weeks after receiving new data. +该令牌可能出问题,特别是在 Fedora CoreOS 自动更新时。更新过程希望托管主机在收到新数据后至少每隔几周重启一次。 -Luckily, it is possible to use GitHub REST API to obtain these tokens and automatically configure the runner every time the host restarts. The following _manage-runner.sh_ script uses the APIs to retrieve a token, remove any runner already configured and register the runner with a new token. +幸运的是,可以使用 GitHub REST API 来获取这些令牌,并在托管主机每次重启时自动配置运行器。下面的 `manage-runner.sh` 脚本使用 API 来获取令牌,删除任何已经配置好的运行器,并用新的令牌注册运行器。 ``` #!/bin/bash @@ -75,7 +73,7 @@ REGISTRATION_TOKEN=$(curl -u ${GITHUB_USER}:${GITHUB_TOKEN} -X POST -H "Accept: /usr/local/sbin/actions-runner/config.sh --url https://github.com/cverna/fcos-actions-runner --token ${REGISTRATION_TOKEN} --labels fcos --unattended ``` -The script above uses a few environment variables that contain a GitHub username and a [Personal Access Token][9] used to authenticate the REST API requests. The Personal Access Token requires the repo permissions in order to successfully retrieve the runner registration and removal tokens. The token is security sensitive so it is better to store it in a different file with stricter permissions. In this example that file is _actions-runner_. +上面的脚本使用了一些环境变量,包含 GitHub 用户名和用于验证 REST API 请求的 [个人访问令牌][9]Personal Access Token。个人访问令牌需要存储库权限,以便成功检索运行器的注册和移除令牌。该令牌是安全敏感信息,所以最好将其存储在一个具有更严格权限的不同文件中。在这个例子中,这个文件是 `actions-runner`。 ``` GITHUB_USER= @@ -83,7 +81,7 @@ GITHUB_REPO= GITHUB_TOKEN= ``` -Following is the Butane snippet that creates these two files – _manage-runner.sh_ and _actions-runner_. +以下是创建这两个文件 `manage-runner.sh` 和 `actions-runner` 的 Butane 片段。 ``` - path: /usr/local/sbin/actions-runner/manage-runner.sh @@ -104,9 +102,9 @@ Following is the Butane snippet that creates these two files – _manage-runner. name: core ``` -### Running Actions on Fedora CoreOS +### 在 Fedora CoreOS 上运行 Actions -Finally, create the systemd services that will configure and start the runner. Define the services in the Butane configuration file. +最后,创建用于配置和启动运行器的 systemd 服务。在 Butane 配置文件中定义这些服务。 ``` systemd: @@ -142,21 +140,19 @@ systemd: WantedBy=multi-user.target ``` -This creates two services, _github-runner-configure.service_ (running once when the host has finished booting) and _github-runner.service_ (running the Actions runner binaries and waiting for new CI/CD jobs). +这将创建两个服务:`github-runner-configure.service`(在主机启动完成后运行一次)和 `github-runner.service`(运行 Actions 运行器二进制文件并等待新的 CI/CD 作业)。 -Now that the Butane configuration is complete, generate an Ignition file out of it and provision a Fedora CoreOS Actions runner. +现在 Butane 配置已经完成,从中生成一个 Ignition 文件并配备一个 Fedora CoreOS Actions 运行器。 ``` $ podman run -i --rm -v $PWD:/code:z --workdir /code quay.io/coreos/butane:release --pretty --strict --files-dir /code config.yaml -o config.ignition ``` -Once the Ignition file is generated, it can be used to provision a runner on the platforms where Fedora CoreOS is [available][10]. +一旦 Ignition 文件生成,它就可以用来在 [支持][10] Fedora CoreOS 的平台上配备一个运行器。 -> [Getting started with Fedora CoreOS][11] +### 配置一个 Action 来使用一个自托管的运行器 -### Configure an Action to use a self-hosted runner - -The following test Action workflow will test the FCOS self-hosted worker. Create the following file in your git repository _.github/workflows/main.yml_ +下面的测试 Action 工作流程将测试 FCOS 的自托管的运行器。在你的 git 存储库中创建以下文件 `.github/workflows/main.yml`。 ``` # This is a basic workflow to help you get started with Actions @@ -188,9 +184,9 @@ jobs: run: podman run --rm fedora-minimal:34 echo Hello World ! ``` -Note that the _runs-on_ configuration is set up to use a runner with the label _fcos_. +请注意,`runs-on` 的配置被设置为使用标签为 `fcos` 的运行器。 -The code presented in this article is available [here][12]. +本文介绍的代码可以在 [这里][12] 中找到。 -------------------------------------------------------------------------------- @@ -198,8 +194,8 @@ via: https://fedoramagazine.org/run-github-actions-on-fedora-coreos/ 作者:[Clément Verna][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/20210728 Kernel tracing with trace-cmd.md b/published/20210728 Kernel tracing with trace-cmd.md new file mode 100644 index 0000000000..1b4f6dfc9f --- /dev/null +++ b/published/20210728 Kernel tracing with trace-cmd.md @@ -0,0 +1,354 @@ +[#]: subject: (Kernel tracing with trace-cmd) +[#]: via: (https://opensource.com/article/21/7/linux-kernel-trace-cmd) +[#]: author: (Gaurav Kamathe https://opensource.com/users/gkamathe) +[#]: collector: (lujun9972) +[#]: translator: (mengxinayan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13852-1.html) + +使用 trace-cmd 追踪内核 +====== + +> trace-cmd 是一个易于使用,且特性众多、可用来追踪内核函数的命令。 + +![](https://img.linux.net.cn/data/attachment/album/202110/05/145818d2i9tgjetzj8itqg.jpg) + +在 [之前的文章][2] 里,我介绍了如何利用 `ftrace` 来追踪内核函数。通过写入和读出文件来使用 `ftrace` 会变得很枯燥,所以我对它做了一个封装来运行带有选项的命令,以启用和禁用追踪、设置过滤器、查看输出、清除输出等等。 + +[trace-cmd][3] 命令是一个可以帮助你做到这一点的工具。在这篇文章中,我使用 `trace-cmd` 来执行我在 `ftrace` 文章中所做的相同任务。由于会经常参考那篇文章,建议在阅读这篇文章之前先阅读它。 + +### 安装 trace-cmd + +本文中所有的命令都运行在 root 用户下。 + +因为 `ftrace` 机制被内置于内核中,因此你可以使用下面的命令进行验证它是否启用: + +``` +# mount | grep tracefs +none on /sys/kernel/tracing type tracefs (rw,relatime,seclabel) +``` + +不过,你需要手动尝试安装 `trace-cmd` 命令: + +``` +# dnf install trace-cmd -y +``` + +### 列出可用的追踪器 + +当使用 `ftrace` 时,你必须查看文件的内容以了解有哪些追踪器可用。但使用 `trace-cmd`,你可以通过以下方式获得这些信息: + +``` +# trace-cmd list -t +hwlat blk mmiotrace function_graph wakeup_dl wakeup_rt wakeup function nop +``` + +### 启用函数追踪器 + +在我 [之前的文章][2] 中,我使用了两个追踪器,在这里我也会这么做。用 `function` 启用你的第一个追踪器: + +``` +$ trace-cmd start -p function +  plugin 'function' +``` + +### 查看追踪输出 + +一旦追踪器被启用,你可以通过使用 `show` 参数来查看输出。这只显示了前 20 行以保持例子的简短(见我之前的文章对输出的解释): + +``` +# trace-cmd show | head -20 +## tracer: function +# +# entries-in-buffer/entries-written: 410142/3380032 #P:8 +# +# _-----=> irqs-off +# / _----=> need-resched +# | / _---=> hardirq/softirq +# || / _--=> preempt-depth +# ||| / delay +# TASK-PID CPU# |||| TIMESTAMP FUNCTION +# | | | |||| | | + gdbus-2606 [004] ..s. 10520.538759: __msecs_to_jiffies <-rebalance_domains + gdbus-2606 [004] ..s. 10520.538760: load_balance <-rebalance_domains + gdbus-2606 [004] ..s. 10520.538761: idle_cpu <-load_balance + gdbus-2606 [004] ..s. 10520.538762: group_balance_cpu <-load_balance + gdbus-2606 [004] ..s. 10520.538762: find_busiest_group <-load_balance + gdbus-2606 [004] ..s. 10520.538763: update_group_capacity <-update_sd_lb_stats.constprop.0 + gdbus-2606 [004] ..s. 10520.538763: __msecs_to_jiffies <-update_group_capacity + gdbus-2606 [004] ..s. 10520.538765: idle_cpu <-update_sd_lb_stats.constprop.0 + gdbus-2606 [004] ..s. 10520.538766: __msecs_to_jiffies <-rebalance_domains +``` + +### 停止追踪并清除缓冲区 + +追踪将会在后台继续运行,你可以继续用 `show` 查看输出。 + +要停止追踪,请运行带有 `stop` 参数的 `trace-cmd` 命令: + +``` +# trace-cmd stop +``` + +要清除缓冲区,用 `clear` 参数运行它: + +``` +# trace-cmd clear +``` + +### 启用函数调用图追踪器 + +运行第二个追踪器,通过 `function_graph` 参数来启用它。 + +``` +# trace-cmd start -p function_graph + Plugin 'function_graph' +``` + +再次使用 `show` 参数查看输出。正如预期的那样,输出与第一次追踪输出略有不同。这一次,它包括一个**函数调用**链: + +``` +# trace-cmd show | head -20 +## tracer: function_graph +# +# CPU DURATION FUNCTION CALLS +# | | | | | | | + 4) 0.079 us | } /* rcu_all_qs */ + 4) 0.327 us | } /* __cond_resched */ + 4) 0.081 us | rcu_read_unlock_strict(); + 4) | __cond_resched() { + 4) 0.078 us | rcu_all_qs(); + 4) 0.243 us | } + 4) 0.080 us | rcu_read_unlock_strict(); + 4) | __cond_resched() { + 4) 0.078 us | rcu_all_qs(); + 4) 0.241 us | } + 4) 0.080 us | rcu_read_unlock_strict(); + 4) | __cond_resched() { + 4) 0.079 us | rcu_all_qs(); + 4) 0.235 us | } + 4) 0.095 us | rcu_read_unlock_strict(); + 4) | __cond_resched() { +``` + +使用 `stop` 和 `clear` 命令来停止追踪和清除缓存区: + +``` +# trace-cmd stop +# trace-cmd clear +``` + +### 调整追踪以增加深度 + +如果你想在函数调用中看到更多的深度,你可以对追踪器进行调整: + +``` +# trace-cmd start -p function_graph --max-graph-depth 5 + plugin 'function_graph' +``` + +现在,当你将这个输出与你之前看到的进行比较时,你应该看到更多的嵌套函数调用: + +``` +# trace-cmd show | head -20 +## tracer: function_graph +# +# CPU DURATION FUNCTION CALLS +# | | | | | | | + 6) | __fget_light() { + 6) 0.804 us | __fget_files(); + 6) 2.708 us | } + 6) 3.650 us | } /* __fdget */ + 6) 0.547 us | eventfd_poll(); + 6) 0.535 us | fput(); + 6) | __fdget() { + 6) | __fget_light() { + 6) 0.946 us | __fget_files(); + 6) 1.895 us | } + 6) 2.849 us | } + 6) | sock_poll() { + 6) 0.651 us | unix_poll(); + 6) 1.905 us | } + 6) 0.475 us | fput(); + 6) | __fdget() { +``` + +### 了解可被追踪的函数 + +如果你想只追踪某些函数而忽略其他的,你需要知道确切的函数名称。你可以用 `list -f` 参数来得到它们。例如搜索常见的内核函数 `kmalloc`,它被用来在内核中分配内存: + +``` +# trace-cmd list -f | grep kmalloc +bpf_map_kmalloc_node +mempool_kmalloc +__traceiter_kmalloc +__traceiter_kmalloc_node +kmalloc_slab +kmalloc_order +kmalloc_order_trace +kmalloc_large_node +__kmalloc +__kmalloc_track_caller +__kmalloc_node +__kmalloc_node_track_caller +[...] +``` + +下面是我的测试系统中可被追踪的函数总数: + +``` +# trace-cmd list -f | wc -l +63165 +``` + +### 追踪内核模块相关的函数 + +你也可以追踪与特定内核模块相关的函数。假设你想追踪 `kvm` 内核模块相关的功能,你可以通过以下方式来实现。请确保该模块已经加载: + +``` +# lsmod | grep kvm_intel +kvm_intel 335872 0 +kvm 987136 1 kvm_intel +``` + +再次运行 `trace-cmd`,使用 `list` 参数,并从输出结果中,`grep` 查找以 `]` 结尾的行。这将过滤掉内核模块。然后 `grep` 内核模块 `kvm_intel` ,你应该看到所有与该内核模块有关的函数。 + +``` +# trace-cmd list -f | grep ]$ | grep kvm_intel +vmx_can_emulate_instruction [kvm_intel] +vmx_update_emulated_instruction [kvm_intel] +vmx_setup_uret_msr [kvm_intel] +vmx_set_identity_map_addr [kvm_intel] +handle_machine_check [kvm_intel] +handle_triple_fault [kvm_intel] +vmx_patch_hypercall [kvm_intel] + +[...] + +vmx_dump_dtsel [kvm_intel] +vmx_dump_sel [kvm_intel] +``` + +### 追踪特定函数 + +现在你知道了如何找到感兴趣的函数,请用一个例子把这些内容用于时间。就像前面的文章一样,试着追踪与文件系统相关的函数。我的测试系统上的文件系统是 `ext4`。 + +这个过程略有不同;你在运行命令时,不使用 `start` 参数,而是在 `record` 参数后面加上你想追踪的函数的“模式”。你还需要指定你想要的追踪器;在这种情况下,就是 `function_graph`。该命令会继续记录追踪,直到你用 `Ctrl+C` 停止它。所以几秒钟后,按 `Ctrl+C` 停止追踪: + +``` +# trace-cmd list -f | grep ^ext4_ + +# trace-cmd record -l ext4_* -p function_graph + plugin 'function_graph' +Hit Ctrl^C to stop recording +^C +CPU0 data recorded at offset=0x856000 + 8192 bytes in size +[...] +``` + +### 查看追踪记录 + +要查看你之前的追踪记录,运行带有 `report` 参数的命令。从输出结果来看,很明显过滤器起作用了,你只看到 `ext4` 相关的函数追踪: + +``` +# trace-cmd report | head -20 +[...] +cpus=8 + trace-cmd-12697 [000] 11303.928103: funcgraph_entry: | ext4_show_options() { + trace-cmd-12697 [000] 11303.928104: funcgraph_entry: 0.187 us | ext4_get_dummy_policy(); + trace-cmd-12697 [000] 11303.928105: funcgraph_exit: 1.583 us | } + trace-cmd-12697 [000] 11303.928122: funcgraph_entry: | ext4_create() { + trace-cmd-12697 [000] 11303.928122: funcgraph_entry: | ext4_alloc_inode() { + trace-cmd-12697 [000] 11303.928123: funcgraph_entry: 0.101 us | ext4_es_init_tree(); + trace-cmd-12697 [000] 11303.928123: funcgraph_entry: 0.083 us | ext4_init_pending_tree(); + trace-cmd-12697 [000] 11303.928123: funcgraph_entry: 0.141 us | ext4_fc_init_inode(); + trace-cmd-12697 [000] 11303.928123: funcgraph_exit: 0.931 us | } + trace-cmd-12697 [000] 11303.928124: funcgraph_entry: 0.081 us | ext4_get_dummy_policy(); + trace-cmd-12697 [000] 11303.928124: funcgraph_entry: 0.133 us | ext4_get_group_desc(); + trace-cmd-12697 [000] 11303.928124: funcgraph_entry: 0.115 us | ext4_free_inodes_count(); + trace-cmd-12697 [000] 11303.928124: funcgraph_entry: 0.114 us | ext4_get_group_desc(); +``` + +### 追踪一个特定的 PID + +假设你想追踪与一个进程(PID)有关的函数。打开另一个终端,注意运行中的 shell 的PID: + +``` +# echo $$ +10885 +``` + +再次运行 `record` 命令,用 `-P` 选项传递PID。这一次,让终端运行(也就是说,先不要按 `Ctrl+C` ): + +``` +# trace-cmd record -P 10885 -p function_graph + Plugin 'function_graph' +Hit Ctrl^C to stop recording +``` + +### 在 shell 上运行一些命令 + +移动到另一个终端,在那里你有一个以特定 PID 运行的 shell,并运行任何命令,例如,`ls` 命令用来列出文件: + +``` +# ls +Temp-9b61f280-fdc1-4512-9211-5c60f764d702 +tracker-extract-3-files.1000 +v8-compile-cache-1000 +[...] +``` + +移动到你启用追踪的终端,按 `Ctrl+C` 停止追踪: + +``` +# trace-cmd record -P 10885 -p function_graph + plugin 'function_graph' +Hit Ctrl^C to stop recording +^C +CPU1 data recorded at offset=0x856000 + 618496 bytes in size +[...] +``` + +在追踪的输出中,你可以看到左边是 PID 和 Bash shell,右边是与之相关的函数调用。这对于缩小你的追踪范围是非常方便的: + +``` +# trace-cmd report | head -20 + +cpus=8 + -0 [001] 11555.380581: funcgraph_entry: | switch_mm_irqs_off() { + -0 [001] 11555.380583: funcgraph_entry: 1.703 us | load_new_mm_cr3(); + -0 [001] 11555.380586: funcgraph_entry: 0.493 us | switch_ldt(); + -0 [001] 11555.380587: funcgraph_exit: 7.235 us | } + bash-10885 [001] 11555.380589: funcgraph_entry: 1.046 us | finish_task_switch.isra.0(); + bash-10885 [001] 11555.380591: funcgraph_entry: | __fdget() { + bash-10885 [001] 11555.380592: funcgraph_entry: 2.036 us | __fget_light(); + bash-10885 [001] 11555.380594: funcgraph_exit: 3.256 us | } + bash-10885 [001] 11555.380595: funcgraph_entry: | tty_poll() { + bash-10885 [001] 11555.380597: funcgraph_entry: | tty_ldisc_ref_wait() { + bash-10885 [001] 11555.380598: funcgraph_entry: | ldsem_down_read() { + bash-10885 [001] 11555.380598: funcgraph_entry: | __cond_resched() { +``` + +### 试一试 + +这些简短的例子显示了使用 `trace-cmd` 命令而不是底层的 `ftrace` 机制,是如何实现既容易使用又拥有丰富的功能,许多内容本文并没有涉及。要想了解更多信息并更好地使用它,请查阅它的手册,并尝试使用其他有用的命令。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/linux-kernel-trace-cmd + +作者:[Gaurav Kamathe][a] +选题:[lujun9972][b] +译者:[萌新阿岩](https://github.com/mengxinayan) +校对:[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/puzzle_computer_solve_fix_tool.png?itok=U0pH1uwj (Puzzle pieces coming together to form a computer screen) +[2]: https://linux.cn/article-13752-1.html +[3]: https://lwn.net/Articles/410200/ diff --git a/sources/tech/20210809 NMState- A declarative networking config tool.md b/published/20210809 NMState- A declarative networking config tool.md similarity index 69% rename from sources/tech/20210809 NMState- A declarative networking config tool.md rename to published/20210809 NMState- A declarative networking config tool.md index 21e95b6ea9..2f15c78d84 100644 --- a/sources/tech/20210809 NMState- A declarative networking config tool.md +++ b/published/20210809 NMState- A declarative networking config tool.md @@ -2,43 +2,41 @@ [#]: via: "https://fedoramagazine.org/nmstate-a-declarative-networking-config-tool/" [#]: author: "Maurizio Garcia https://fedoramagazine.org/author/malgnuz/" [#]: collector: "lujun9972" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13861-1.html" -NMState: A declarative networking config tool +NMState:一个声明式网络配置工具 ====== -![][1] +![](https://img.linux.net.cn/data/attachment/album/202110/08/145714mqcyh6sshchomyot.jpg) -Comic excerpted from photo by [Bee Felten-Leidel][2] on [Unsplash][3] +这篇文章描述并演示了 NMState,这是一个使用声明式方法配置主机的网络管理器。这意味着你可以通过 API 定义所需的配置状态,而工具则通过提供者provider来应用配置。 -This article describes and demonstrates NMState, a network manager that uses a declarative approach to configure hosts. This means you define the desired configuration state through an API and the tool applies the configuration through a provider. +### 配置方法:命令式与声明式 -### Configuration approaches: imperative vs declarative +网络管理有时候是一项非常复杂的任务,这取决于环境的规模和多样性。在 IT 的早期,网络管理依赖于网络管理员在网络设备上手动执行命令。如今,基础设施即代码Infrastructure as Code(IaC)允许以不同的方式将这些任务自动化。z这基本上有两种方法:命令式或声明式。 -Networking management can be a very complex task depending on the size and diversity of the environment. In the early days of IT, networking management relied on manual procedures performed by network administrators over networking devices. Nowadays, Infrastructure as Code (IaC) allows automation of those tasks in a different way. There are, essentially two approaches: imperative or declarative. +在命令式方法中,你会定义“如何”达到所需的配置状态。而在声明式范式里则定义了“什么”是所需的配置状态,所以它不确定哪些步骤是必需的,也不确定它们必须以何种顺序执行。这种方法目前正在聚集更多的人员参与,你可以在目前使用的大多数管理和编排工具上找到它。 -In an imperative approach you define “how” you will arrive at a desired configuration state. The declarative paradigm defines “what” is the desired configuration state, so it does not shape which steps are required nor in which order they must be performed. This approach is currently gathering more adepts and you can find it on most of the management and orchestration tools currently used. +### NMState:一个声明式的工具 -### NMState: a declarative tool +NMState 是一个网络管理器,允许你按照声明式方法配置主机。这意味着你通过一个北向的声明式 API 定义所需的配置状态,这个工具通过南向的提供者provider应用配置。 -NMState is a network manager that allows you to configure hosts following a declarative approach. It means you define the desired configuration state through a northbound declarative API and this tool applies the configuration through a southbound provider. +目前 NMState 支持的唯一的提供者是 NetworkManager,它是为 Fedora Linux 提供网络功能的主要服务。不过,NMState 的开发计划中将逐渐增加其他提供者。 -Currently the only provider supported by NMState is NetworkManager, which is the main service to address networking capabilities on Fedora Linux. However, the development life cycle of NMState will add other providers gradually. +关于 NMState 的进一步信息,请访问其项目 [站点][4] 或 GitHub [仓库][5]。 -For further information regarding NMState please visit either its project [site][4] or github [repository][5]. +### 安装 -### Installation - -NMState is available on Fedora Linux 29+ and requires NetworkManager 1.26 or later installed and running on the system. The following shows the installation on Fedora Linux 34: +NMState 在 Fedora Linux 29+ 上可用,需要在系统上安装并运行 NetworkManager 1.26 或更高版本。下面是在 Fedora Linux 34 上的安装情况: ``` $ sudo dnf -y install nmstate -… -output omitted -… +... +输出节略 +... Installed: NetworkManager-config-server-1:1.30.4-1.fc34.noarch gobject-introspection-1.68.0-3.fc34.x86_64 nispor-1.0.1-2.fc34.x86_64 nmstate-1.0.3-2.fc34.noarch python3-gobject-base-3.40.1-1.fc34.x86_64 python3-libnmstate-1.0.3-2.fc34.noarch python3-nispor-1.0.1-2.fc34.noarch python3-varlink-30.3.1-2.fc34.noarch @@ -46,18 +44,18 @@ Installed: Complete! ``` -At this point you can use _nmstatectl_ as a command line tool for NMState. Please refer to either _nmstatectl –help_ or _man nmstatectl_ for further information about this tool. +这样,你可以使用 `nmstatectl` 作为 NMState 的命令行工具。请参考 `nmstatectl -help` 或 `man nmstatectl` 以了解关于这个工具的进一步信息。 -### Using NMstate +### 使用 NMstate -Start by checking the NMState version installed in the system: +首先要检查系统中安装的 NMState 版本: ``` $ nmstatectl version 1.0.3 ``` -Check the current configuration of a networking interface, e.g. the _eth0_ configuration: +检查一个网络接口的当前配置,例如 `eth0` 的配置: ``` $ nmstatectl show eth0 @@ -124,29 +122,23 @@ interfaces: mtu: 1500 ``` - As you can see above the networking configuration shows four main sections: +正如你在上面看到的,这个网络配置显示了四个主要部分: - * **dns-resolver**: this section has the nameserver configuration for this interface. - * **route-rules**: it states the routing rules.  - * **routes**: it includes both dynamic and static routes. - * **Interfaces**: this section describes both ipv4 and ipv6 settings. + * `dns-resolver`:这部分是这个接口的名字服务器配置。 + * `route-rules`:它说明了路由规则。  + * `routes`:它包括动态和静态路由。 + * `interfaces`:这部分描述了 ipv4 和 ipv6 设置。 +### 修改配置 +你可以在两种模式下修改所需的配置状态: -### Modify the configuration + * 交互式:通过 `nmstatectl edit` 编辑接口配置。这个命令调用环境变量 `EDITOR` 定义的文本编辑器,因此可以用 yaml 格式编辑网络状态。完成编辑后,NMState 将应用新的网络配置,除非有语法错误。 + * 基于文件的:使用 `nmstatectl apply` 应用接口配置,它从先前创建的 yaml 或 json 文件中导入一个所需的配置状态。 -You can modify the desired configuration state in two modes:  +下面几节告诉你如何使用 NMState 来改变网络配置。这些改变可能会对系统造成破坏,所以建议在测试系统或客户虚拟机上执行这些任务,直到你对 NMState 有更好的理解。 - * **Interactive**: editing the interface configuration through _nmstatectl edit_. This command invokes the text editor defined by the environment variable EDITOR so the network state can be edited in yaml format. After finishing the edition NMState will apply the new network configuration unless there are syntax errors. - - - * **File-based**: applying the interface configuration using _nmstatectl apply_ which imports a desired configuration state from a yaml or json file earlier created. - - - -The following sections show you how to change the networking configuration using NMState. These changes can be disruptive to the system so the recommendation is to perform these tasks on a test system or guest VM till you get a better understanding of NMState. - -The test system in use herehas two Ethernet interfaces: _eth0_ and _eth1_: +这里使用的测试系统有两个以太网接口,`eth0` 和 `eth1`: ``` $ ip -br -4 a @@ -155,11 +147,9 @@ eth0 UP 192.168.122.238/24 eth1 UP 192.168.122.108/24 ``` -#### Example of interactive configuration mode: +#### 互动配置模式的例子 -``` -Change the MTU of eth0 interface to 9000 bytes using the nmstatectl edit command as follows (all changes are in bold): -``` +使用 `nmstatectl edit` 命令将 `eth0` 接口的 MTU 改为 9000 字节,如下所示: ``` $ sudo nmstatectl edit eth0 @@ -222,7 +212,7 @@ interfaces: mtu: 9000 ``` -After saving and exiting the edito, NMState applies the new network desired state: +在保存并退出编辑器后,NMState 应用新的网络期望状态: ``` 2021-06-29 11:29:05,726 root DEBUG Nmstate version: 1.0.3 @@ -232,7 +222,7 @@ After saving and exiting the edito, NMState applies the new network desired stat 2021-06-29 11:29:05,792 root DEBUG Async action: Update profile uuid:2bdee700-f62b-365a-bd1d-69d9c31a9f0c iface:eth0 type:ethernet finished ``` -Now, use both the _ip_ command and also the _eth0_ configuration file to check that the _MTU_ of _eth0_ is 9000 bytes. +现在,使用 `ip` 命令和 `eth0` 的配置文件来检查 `eth0` 的 `MTU` 是不是 9000 字节。 ``` $ ip link show eth0 @@ -273,11 +263,11 @@ ra-timeout=2147483647 [proxy] ``` -#### Example of file-based configuration mode: +#### 基于文件的配置模式的例子 -Let’s use the file-based approach to set a new config state. In this case disable the IPv6 configuration in _eth1_ interface. +让我们使用基于文件的方法来设置一个新的配置状态。这里我们禁用 `eth1` 接口的 IPv6 配置。 -First, create a yaml file to define the desired state of the _eth1_ interface. Use _nmstatectl show_ to save the current settings then _nmstatectl edit_ to disable IPv6. Again, all changes are in bold and deletions are shown with strike-through: +首先,创建一个 yaml 文件来定义 `eth1` 接口的期望状态。使用 `nmstatectl show` 来保存当前设置,然后使用 `nmstatectl edit` 来禁用 IPv6。 ``` $ nmstatectl show eth1 > eth1.yaml @@ -341,7 +331,7 @@ interfaces: mtu: 1500 ``` -After saving the new configuration, use it to apply the new state: +保存新的配置后,用它来应用新的状态: ``` $ sudo nmstatectl apply eth1.yaml @@ -402,7 +392,7 @@ interfaces: mtu: 1500 ``` -You can check that the _eth1_ interface does not have any IPv6 configured: +你可以检查看到 `eth1` 接口没有配置任何 IPv6: ``` $ ip -br a @@ -440,11 +430,11 @@ method=disabled [proxy] ``` -#### Applying changes temporarily +#### 临时应用改变 -An interesting feature of NMState allows you to configure a desired networking state temporarily. In case you are satisfied with the configuration you can commit it afterwards. Otherwise it will rollback when the timeout expires (default is 60 sec). +NMState 的一个有趣的功能允许你临时配置一个期望的网络状态。如果你对这个配置感到满意,你可以事后提交。否则,当超时(默认为 60 秒)过后,它将回滚。 -Modify the _eth1_ configuration from the previous example so it has an IPv4 static address instead of getting it dynamically by DHCP. +修改前面例子中的 `eth1` 配置,使它有一个 IPv4 静态地址,而不是通过 DHCP 动态获得。 ``` $ vi eth1.yaml @@ -498,7 +488,7 @@ interfaces: mtu: 1500 ``` -Now, apply this config temporarily using the option _no-commit_ so it will be valid only for 30 seconds. This can be done adding the option _–timeout_. Meanwhile, we will run the _ip  -br a_ command three times to see how the IPv4 address configured in _eth1_ interface changes and then the configuration rolls back. +现在,使用选项 `no-commit` 临时应用这个配置,让它只在 30 秒内有效。这可以通过添加选项 `timeout` 来完成。同时,我们将运行 `ip -br a` 命令三次,看看配置在 `eth1` 接口的 IPv4 地址是如何变化的,然后配置就会回滚。 ``` $ ip -br a && sudo nmstatectl apply --no-commit --timeout 30 eth1.yaml && sleep 10 && ip -br a && sleep 25 && ip -br a @@ -561,13 +551,13 @@ eth0 UP 192.168.122.238/24 fe80::5054:ff:fe91:e44e/64 eth1 UP 192.168.122.108/24 ``` -As you can see from above, the _eth1_ IP address changed temporarily from 192.168.122.108 to 192.168.122.110 and then it returned to 192.168.122.108 after the timeout expired. +从上面可以看到,`eth1` 的 IP 地址从 `192.168.122.108` 暂时变成了 `192.168.122.110`,然后在超时结束后又回到了 `192.168.122.108`。 -### Conclusion +### 总结 -NMState is a declarative networking configuration tool that currently applies the desired networking configuration state in a host through the NetworkManager API. This state can be defined either interactively using a text editor or with a file-based approach creating a yaml or json file. +NMState 是一个声明式的网络配置工具,目前可以通过 NetworkManager API 在主机中应用所需的网络配置状态。这种状态既可以用文本编辑器交互式地定义,也可以用基于文件的方法创建一个 yaml 或 json 文件。 -This kind of tool provides Infrastructure as Code, it allows the automation of networking tasks and also reduces potential misconfigurations or unstable networking scenarios that could arise using legacy configuration methods. +这种工具提供了“基础设施即代码”,它可以自动化网络任务,也减少了使用传统配置方法可能出现的潜在错误配置或不稳定的网络情况。 -------------------------------------------------------------------------------- @@ -575,8 +565,8 @@ via: https://fedoramagazine.org/nmstate-a-declarative-networking-config-tool/ 作者:[Maurizio Garcia][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/20210813 Code memory safety and efficiency by example.md b/published/20210813 Code memory safety and efficiency by example.md new file mode 100644 index 0000000000..d962653d8f --- /dev/null +++ b/published/20210813 Code memory safety and efficiency by example.md @@ -0,0 +1,666 @@ +[#]: subject: "Code memory safety and efficiency by example" +[#]: via: "https://opensource.com/article/21/8/memory-programming-c" +[#]: author: "Marty Kalin https://opensource.com/users/mkalindepauledu" +[#]: collector: "lujun9972" +[#]: translator: "unigeorge" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13845-1.html" + +实例讲解代码之内存安全与效率 +====== + +> 了解有关内存安全和效率的更多信息。 + +![](https://img.linux.net.cn/data/attachment/album/202110/03/101238cd0hgdrhamzab7hj.jpg) + +C 是一种高级语言,同时具有“接近金属close-to-the-metal”(LCTT 译注:即“接近人类思维方式”的反义词)的特性,这使得它有时看起来更像是一种可移植的汇编语言,而不像 Java 或 Python 这样的兄弟语言。内存管理作为上述特性之一,涵盖了正在执行的程序对内存的安全和高效使用。本文通过 C 语言代码示例,以及现代 C 语言编译器生成的汇编语言代码段,详细介绍了内存安全性和效率。 + +尽管代码示例是用 C 语言编写的,但安全高效的内存管理指南对于 C++ 是同样适用的。这两种语言在很多细节上有所不同(例如,C++ 具有 C 所缺乏的面向对象特性和泛型),但在内存管理方面面临的挑战是一样的。 + +### 执行中程序的内存概述 + +对于正在执行的程序(又名 _进程process_),内存被划分为三个区域:**stack**、**heap** 和 **静态区static area**。下文会给出每个区域的概述,以及完整的代码示例。 + +作为通用 CPU 寄存器的替补,_栈_ 为代码块(例如函数或循环体)中的局部变量提供暂存器存储。传递给函数的参数在此上下文中也视作局部变量。看一下下面这个简短的示例: + +``` +void some_func(int a, int b) { +   int n; +   ... +} +``` + +通过 `a` 和 `b` 传递的参数以及局部变量 `n` 的存储会在栈中,除非编译器可以找到通用寄存器。编译器倾向于优先将通用寄存器用作暂存器,因为 CPU 对这些寄存器的访问速度很快(一个时钟周期)。然而,这些寄存器在台式机、笔记本电脑和手持机器的标准架构上很少(大约 16 个)。 + +在只有汇编语言程序员才能看到的实施层面,栈被组织为具有 `push`(插入)和 `pop`(删除)操作的 LIFO(后进先出)列表。 `top` 指针可以作为偏移的基地址;这样,除了 `top` 之外的栈位置也变得可访问了。例如,表达式 `top+16` 指向堆栈的 `top` 指针上方 16 个字节的位置,表达式 `top-16` 指向 `top` 指针下方 16 个字节的位置。因此,可以通过 `top` 指针访问实现了暂存器存储的栈的位置。在标准的 ARM 或 Intel 架构中,栈从高内存地址增长到低内存地址;因此,减小某进程的 `top` 就是增大其栈规模。 + +使用栈结构就意味着轻松高效地使用内存。编译器(而非程序员)会编写管理栈的代码,管理过程通过分配和释放所需的暂存器存储来实现;程序员声明函数参数和局部变量,将实现过程交给编译器。此外,完全相同的栈存储可以在连续的函数调用和代码块(如循环)中重复使用。精心设计的模块化代码会将栈存储作为暂存器的首选内存选项,同时优化编译器要尽可能使用通用寄存器而不是栈。 + +**堆** 提供的存储是通过程序员代码显式分配的,堆分配的语法因语言而异。在 C 中,成功调用库函数 `malloc`(或其变体 `calloc` 等)会分配指定数量的字节(在 C++ 和 Java 等语言中,`new` 运算符具有相同的用途)。编程语言在如何释放堆分配的存储方面有着巨大的差异: + + * 在 Java、Go、Lisp 和 Python 等语言中,程序员不会显式释放动态分配的堆存储。 + + 例如,下面这个 Java 语句为一个字符串分配了堆存储,并将这个堆存储的地址存储在变量 `greeting` 中: + + ``` + String greeting = new String("Hello, world!"); + ``` + + Java 有一个垃圾回收器,它是一个运行时实用程序,如果进程无法再访问自己分配的堆存储,回收器可以使其自动释放。因此,Java 堆释放是通过垃圾收集器自动进行的。在上面的示例中,垃圾收集器将在变量 `greeting` 超出作用域后,释放字符串的堆存储。 + + * Rust 编译器会编写堆释放代码。这是 Rust 在不依赖垃圾回收器的情况下,使堆释放实现自动化的开创性努力,但这也会带来运行时复杂性和开销。向 Rust 的努力致敬! + * 在 C(和 C++)中,堆释放是程序员的任务。程序员调用 `malloc` 分配堆存储,然后负责相应地调用库函数 `free` 来释放该存储空间(在 C++ 中,`new` 运算符分配堆存储,而 `delete` 和 `delete[]` 运算符释放此类存储)。下面是一个 C 语言代码示例: + + ``` + char* greeting = malloc(14);       /* 14 heap bytes */ + strcpy(greeting, "Hello, world!"); /* copy greeting into bytes */ + puts(greeting);                    /* print greeting */ + free(greeting);                    /* free malloced bytes */ + ``` + + C 语言避免了垃圾回收器的成本和复杂性,但也不过是让程序员承担了堆释放的任务。 + +内存的 **静态区** 为可执行代码(例如 C 语言函数)、字符串文字(例如“Hello, world!”)和全局变量提供存储空间: + +``` +int n;                       /* global variable */ +int main() {                 /* function */ +   char* msg = "No comment"; /* string literal */ +   ... +} +``` + +该区域是静态的,因为它的大小从进程执行开始到结束都固定不变。由于静态区相当于进程固定大小的内存占用,因此经验法则是通过避免使用全局数组等方法来使该区域尽可能小。 + +下文会结合代码示例对本节概述展开进一步讲解。 + +### 栈存储 + +想象一个有各种连续执行的任务的程序,任务包括了处理每隔几分钟通过网络下载并存储在本地文件中的数字数据。下面的 `stack` 程序简化了处理流程(仅是将奇数整数值转换为偶数),而将重点放在栈存储的好处上。 + + +``` +#include +#include + +#define Infile   "incoming.dat" +#define Outfile  "outgoing.dat" +#define IntCount 128000  /* 128,000 */ + +void other_task1() { /*...*/ } +void other_task2() { /*...*/ } + +void process_data(const char* infile, +          const char* outfile, +          const unsigned n) { +  int nums[n]; +  FILE* input = fopen(infile, "r"); +  if (NULL == infile) return; +  FILE* output = fopen(outfile, "w"); +  if (NULL == output) { +    fclose(input); +    return; +  } + +  fread(nums, n, sizeof(int), input); /* read input data */ +  unsigned i; +  for (i = 0; i < n; i++) { +    if (1 == (nums[i] & 0x1))  /* odd parity? */ +      nums[i]--;               /* make even */ +  } +  fclose(input);               /* close input file */ + +  fwrite(nums, n, sizeof(int), output); +  fclose(output); +} + +int main() { +  process_data(Infile, Outfile, IntCount); +   +  /** now perform other tasks **/ +  other_task1(); /* automatically released stack storage available */ +  other_task2(); /* ditto */ +   +  return 0; +} +``` + +底部的 `main` 函数首先调用 `process_data` 函数,该函数会创建一个基于栈的数组,其大小由参数 `n` 给定(当前示例中为 128,000)。因此,该数组占用 `128000 * sizeof(int)` 个字节,在标准设备上达到了 512,000 字节(`int` 在这些设备上是四个字节)。然后数据会被读入数组(使用库函数 `fread`),循环处理,并保存到本地文件 `outgoing.dat`(使用库函数 `fwrite`)。 + +当 `process_data` 函数返回到其调用者 `main` 函数时,`process_data` 函数的大约 500MB 栈暂存器可供 `stack` 程序中的其他函数用作暂存器。在此示例中,`main` 函数接下来调用存根函数 `other_task1` 和 `other_task2`。这三个函数在 `main` 中依次调用,这意味着所有三个函数都可以使用相同的堆栈存储作为暂存器。因为编写栈管理代码的是编译器而不是程序员,所以这种方法对程序员来说既高效又容易。 + +在 C 语言中,在块(例如函数或循环体)内定义的任何变量默认都有一个 `auto` 存储类,这意味着该变量是基于栈的。存储类 `register` 现在已经过时了,因为 C 编译器会主动尝试尽可能使用 CPU 寄存器。只有在块内定义的变量可能是 `register`,如果没有可用的 CPU 寄存器,编译器会将其更改为 `auto`。基于栈的编程可能是不错的首选方式,但这种风格确实有一些挑战性。下面的 `badStack` 程序说明了这点。 + +``` +#include ; + +const int* get_array(const unsigned n) { +  int arr[n]; /* stack-based array */ +  unsigned i; +  for (i = 0; i < n; i++) arr[i] = 1 + 1; + +  return arr;  /** ERROR **/ +} + +int main() { +  const unsigned n = 16; +  const int* ptr = get_array(n); +   +  unsigned i; +  for (i = 0; i < n; i++) printf("%i ", ptr[i]); +  puts("\n"); + +  return 0; +} +``` + +`badStack` 程序中的控制流程很简单。`main` 函数使用 16(LCTT 译注:原文为 128,应为作者笔误)作为参数调用函数 `get_array`,然后被调用函数会使用传入参数来创建对应大小的本地数组。`get_array` 函数会初始化数组并返回给 `main` 中的数组标识符 `arr`。 `arr` 是一个指针常量,保存数组的第一个 `int` 元素的地址。 + +当然,本地数组 `arr` 可以在 `get_array` 函数中访问,但是一旦 `get_array` 返回,就不能合法访问该数组。尽管如此,`main` 函数会尝试使用函数 `get_array` 返回的堆栈地址 `arr` 来打印基于栈的数组。现代编译器会警告错误。例如,下面是来自 GNU 编译器的警告: + +``` +badStack.c: In function 'get_array': +badStack.c:9:10: warning: function returns address of local variable [-Wreturn-local-addr] +return arr;  /** ERROR **/ +``` + +一般规则是,如果使用栈存储实现局部变量,应该仅在该变量所在的代码块内,访问这块基于栈的存储(在本例中,数组指针 `arr` 和循环计数器 `i` 均为这样的局部变量)。因此,函数永远不应该返回指向基于栈存储的指针。 + +### 堆存储 + +接下来使用若干代码示例凸显在 C 语言中使用堆存储的优点。在第一个示例中,使用了最优方案分配、使用和释放堆存储。第二个示例(在下一节中)将堆存储嵌套在了其他堆存储中,这会使其释放操作变得复杂。 + +``` +#include +#include + +int* get_heap_array(unsigned n) { +  int* heap_nums = malloc(sizeof(int) * n);  +   +  unsigned i; +  for (i = 0; i < n; i++) +    heap_nums[i] = i + 1;  /* initialize the array */ +   +  /* stack storage for variables heap_nums and i released +     automatically when get_num_array returns */ +  return heap_nums; /* return (copy of) the pointer */ +} + +int main() { +  unsigned n = 100, i; +  int* heap_nums = get_heap_array(n); /* save returned address */ +   +  if (NULL == heap_nums) /* malloc failed */ +    fprintf(stderr, "%s\n", "malloc(...) failed..."); +  else { +    for (i = 0; i < n; i++) printf("%i\n", heap_nums[i]); +    free(heap_nums); /* free the heap storage */ +  } +  return 0;  +} +``` + +上面的 `heap` 程序有两个函数: `main` 函数使用参数(示例中为 100)调用 `get_heap_array` 函数,参数用来指定数组应该有多少个 `int` 元素。因为堆分配可能会失败,`main` 函数会检查 `get_heap_array` 是否返回了 `NULL`;如果是,则表示失败。如果分配成功,`main` 将打印数组中的 `int` 值,然后立即调用库函数 `free` 来对堆存储解除分配。这就是最优的方案。 + +`get_heap_array` 函数以下列语句开头,该语句值得仔细研究一下: + +``` +int* heap_nums = malloc(sizeof(int) * n); /* heap allocation */ +``` + +`malloc` 库函数及其变体函数针对字节进行操作;因此,`malloc` 的参数是 `n` 个 `int` 类型元素所需的字节数(`sizeof(int)` 在标准现代设备上是四个字节)。`malloc` 函数返回所分配字节段的首地址,如果失败则返回 `NULL` . + +如果成功调用 `malloc`,在现代台式机上其返回的地址大小为 64 位。在手持设备和早些时候的台式机上,该地址的大小可能是 32 位,或者甚至更小,具体取决于其年代。堆分配数组中的元素是 `int` 类型,这是一个四字节的有符号整数。这些堆分配的 `int` 的地址存储在基于栈的局部变量 `heap_nums` 中。可以参考下图: + +``` +                 heap-based + stack-based        / +     \        +----+----+   +----+ + heap-nums--->|int1|int2|...|intN| +              +----+----+   +----+ +``` + +一旦 `get_heap_array` 函数返回,指针变量 `heap_nums` 的栈存储将自动回收——但动态 `int` 数组的堆存储仍然存在,这就是 `get_heap_array` 函数返回这个地址(的副本)给 `main` 函数的原因:它现在负责在打印数组的整数后,通过调用库函数 `free` 显式释放堆存储: + +``` +free(heap_nums); /* free the heap storage */ +``` + +`malloc` 函数不会初始化堆分配的存储空间,因此里面是随机值。相比之下,其变体函数 `calloc` 会将分配的存储初始化为零。这两个函数都返回 `NULL` 来表示分配失败。 + +在 `heap` 示例中,`main` 函数在调用 `free` 后会立即返回,正在执行的程序会终止,这会让系统回收所有已分配的堆存储。尽管如此,程序员应该养成在不再需要时立即显式释放堆存储的习惯。 + +### 嵌套堆分配 + +下一个代码示例会更棘手一些。C 语言有很多返回指向堆存储的指针的库函数。下面是一个常见的使用情景: + +1、C 程序调用一个库函数,该函数返回一个指向基于堆的存储的指针,而指向的存储通常是一个聚合体,如数组或结构体: + +``` +SomeStructure* ptr = lib_function(); /* returns pointer to heap storage */ +``` + +2、 然后程序使用所分配的存储。 + +3、 对于清理而言,问题是对 `free` 的简单调用是否会清理库函数分配的所有堆分配存储。例如,`SomeStructure` 实例可能有指向堆分配存储的字段。一个特别麻烦的情况是动态分配的结构体数组,每个结构体有一个指向又一层动态分配的存储的字段。下面的代码示例说明了这个问题,并重点关注了如何设计一个可以安全地为客户端提供堆分配存储的库。 + +``` +#include +#include + +typedef struct { +  unsigned id; +  unsigned len; +  float*   heap_nums; +} HeapStruct; +unsigned structId = 1; + +HeapStruct* get_heap_struct(unsigned n) { +  /* Try to allocate a HeapStruct. */ +  HeapStruct* heap_struct = malloc(sizeof(HeapStruct)); +  if (NULL == heap_struct) /* failure? */ +    return NULL;           /* if so, return NULL */ + +  /* Try to allocate floating-point aggregate within HeapStruct. */ +  heap_struct->heap_nums = malloc(sizeof(float) * n); +  if (NULL == heap_struct->heap_nums) {  /* failure? */ +    free(heap_struct);                   /* if so, first free the HeapStruct */ +    return NULL;                         /* then return NULL */ +  } + +  /* Success: set fields */ +  heap_struct->id = structId++; +  heap_struct->len = n; + +  return heap_struct; /* return pointer to allocated HeapStruct */ +} + +void free_all(HeapStruct* heap_struct) { +  if (NULL == heap_struct) /* NULL pointer? */ +    return;                /* if so, do nothing */ +   +  free(heap_struct->heap_nums); /* first free encapsulated aggregate */ +  free(heap_struct);            /* then free containing structure */   +} + +int main() { +  const unsigned n = 100; +  HeapStruct* hs = get_heap_struct(n); /* get structure with N floats */ + +  /* Do some (meaningless) work for demo. */ +  unsigned i; +  for (i = 0; i < n; i++) hs->heap_nums[i] = 3.14 + (float) i; +  for (i = 0; i < n; i += 10) printf("%12f\n", hs->heap_nums[i]); + +  free_all(hs); /* free dynamically allocated storage */ +   +  return 0; +} +``` + +上面的 `nestedHeap` 程序示例以结构体 `HeapStruct` 为中心,结构体中又有名为 `heap_nums` 的指针字段: + +``` +typedef struct { +  unsigned id; +  unsigned len; +  float*   heap_nums; /** pointer **/ +} HeapStruct; +``` + +函数 `get_heap_struct` 尝试为 `HeapStruct` 实例分配堆存储,这需要为字段 `heap_nums` 指向的若干个 `float` 变量分配堆存储。如果成功调用 `get_heap_struct` 函数,并将指向堆分配结构体的指针以 `hs` 命名,其结果可以描述如下: + +``` +hs-->HeapStruct instance +        id +        len +        heap_nums-->N contiguous float elements +``` + +在 `get_heap_struct` 函数中,第一个堆分配过程很简单: + +``` +HeapStruct* heap_struct = malloc(sizeof(HeapStruct)); +if (NULL == heap_struct) /* failure? */ +  return NULL;           /* if so, return NULL */ +``` + +`sizeof(HeapStruct)` 包括了 `heap_nums` 字段的字节数(32 位机器上为 4,64 位机器上为 8),`heap_nums` 字段则是指向动态分配数组中的 `float` 元素的指针。那么,问题关键在于 `malloc` 为这个结构体传送了字节空间还是表示失败的 `NULL`;如果是 `NULL`,`get_heap_struct` 函数就也返回 `NULL` 以通知调用者堆分配失败。 + +第二步尝试堆分配的过程更复杂,因为在这一步,`HeapStruct` 的堆存储已经分配好了: + +``` +heap_struct->heap_nums = malloc(sizeof(float) * n); +if (NULL == heap_struct->heap_nums) {  /* failure? */ +  free(heap_struct);                   /* if so, first free the HeapStruct */ +  return NULL;                         /* and then return NULL */ +} +``` + +传递给 `get_heap_struct` 函数的参数 `n` 指明动态分配的 `heap_nums` 数组中应该有多少个 `float` 元素。如果可以分配所需的若干个 `float` 元素,则该函数在返回 `HeapStruct` 的堆地址之前会设置结构的 `id` 和 `len` 字段。 但是,如果尝试分配失败,则需要两个步骤来实现最优方案: + +1、 必须释放 `HeapStruct` 的存储以避免内存泄漏。对于调用 `get_heap_struct` 的客户端函数而言,没有动态 `heap_nums` 数组的 `HeapStruct` 可能就是没用的;因此,`HeapStruct` 实例的字节空间应该显式释放,以便系统可以回收这些空间用于未来的堆分配。 + +2、 返回 `NULL` 以标识失败。 + +如果成功调用 `get_heap_struct` 函数,那么释放堆存储也很棘手,因为它涉及要以正确顺序进行的两次 `free` 操作。因此,该程序设计了一个 `free_all` 函数,而不是要求程序员再去手动实现两步释放操作。回顾一下,`free_all` 函数是这样的: + +``` +void free_all(HeapStruct* heap_struct) { +  if (NULL == heap_struct) /* NULL pointer? */ +    return;                /* if so, do nothing */ +   +  free(heap_struct->heap_nums); /* first free encapsulated aggregate */ +  free(heap_struct);            /* then free containing structure */   +} +``` + +检查完参数 `heap_struct` 不是 `NULL` 值后,函数首先释放 `heap_nums` 数组,这步要求 `heap_struct` 指针此时仍然是有效的。先释放 `heap_struct` 的做法是错误的。一旦 `heap_nums` 被释放,`heap_struct` 就可以释放了。如果 `heap_struct` 被释放,但 `heap_nums` 没有被释放,那么数组中的 `float` 元素就会泄漏:仍然分配了字节空间,但无法被访问到——因此一定要记得释放 `heap_nums`。存储泄漏将一直持续,直到 `nestedHeap` 程序退出,系统回收泄漏的字节时为止。 + +关于 `free` 库函数的注意事项就是要有顺序。回想一下上面的调用示例: + +``` +free(heap_struct->heap_nums); /* first free encapsulated aggregate */ +free(heap_struct);            /* then free containing structure */ +``` + +这些调用释放了分配的存储空间——但它们并 _不是_ 将它们的操作参数设置为 `NULL`(`free` 函数会获取地址的副本作为参数;因此,将副本更改为 `NULL` 并不会改变原地址上的参数值)。例如,在成功调用 `free` 之后,指针 `heap_struct` 仍然持有一些堆分配字节的堆地址,但是现在使用这个地址将会产生错误,因为对 `free` 的调用使得系统有权回收然后重用这些分配过的字节。 + +使用 `NULL` 参数调用 `free` 没有意义,但也没有什么坏处。而在非 `NULL` 的地址上重复调用 `free` 会导致不确定结果的错误: + +``` +free(heap_struct);  /* 1st call: ok */ +free(heap_struct);  /* 2nd call: ERROR */ +``` + +### 内存泄漏和堆碎片化 + +“内存泄漏”是指动态分配的堆存储变得不再可访问。看一下相关的代码段: + +``` +float* nums = malloc(sizeof(float) * 10); /* 10 floats */ +nums[0] = 3.14f;                          /* and so on */ +nums = malloc(sizeof(float) * 25);        /* 25 new floats */ +``` + +假如第一个 `malloc` 成功,第二个 `malloc` 会再将 `nums` 指针重置为 `NULL`(分配失败情况下)或是新分配的 25 个 `float` 中第一个的地址。最初分配的 10 个 `float` 元素的堆存储仍然处于被分配状态,但此时已无法再对其访问,因为 `nums` 指针要么指向别处,要么是 `NULL`。结果就是造成了 40 个字节(`sizeof(float) * 10`)的泄漏。 + +在第二次调用 `malloc` 之前,应该释放最初分配的存储空间: + +``` +float* nums = malloc(sizeof(float) * 10); /* 10 floats */ +nums[0] = 3.14f;                          /* and so on */ +free(nums);                               /** good **/ +nums = malloc(sizeof(float) * 25);        /* no leakage */ +``` + +即使没有泄漏,堆也会随着时间的推移而碎片化,需要对系统进行碎片整理。例如,假设两个最大的堆块当前的大小分别为 200MB 和 100MB。然而,这两个堆块并不连续,进程 `P` 此时又需要分配 250MB 的连续堆存储。在进行分配之前,系统可能要对堆进行 _碎片整理_ 以给 `P` 提供 250MB 连续存储空间。碎片整理很复杂,因此也很耗时。 + +内存泄漏会创建处于已分配状态但不可访问的堆块,从而会加速碎片化。因此,释放不再需要的堆存储是程序员帮助减少碎片整理需求的一种方式。 + +### 诊断内存泄漏的工具 + +有很多工具可用于分析内存效率和安全性,其中我最喜欢的是 [valgrind][11]。为了说明该工具如何处理内存泄漏,这里给出 `leaky` 示例程序: + +``` +#include +#include + +int* get_ints(unsigned n) { +  int* ptr = malloc(n * sizeof(int)); +  if (ptr != NULL) { +    unsigned i; +    for (i = 0; i < n; i++) ptr[i] = i + 1; +  } +  return ptr; +} + +void print_ints(int* ptr, unsigned n) { +  unsigned i; +  for (i = 0; i < n; i++) printf("%3i\n", ptr[i]); +} + +int main() { +  const unsigned n = 32; +  int* arr = get_ints(n); +  if (arr != NULL) print_ints(arr, n); + +  /** heap storage not yet freed... **/ +  return 0; +} +``` + +`main` 函数调用了 `get_ints` 函数,后者会试着从堆中 `malloc` 32 个 4 字节的 `int`,然后初始化动态数组(如果 `malloc` 成功)。初始化成功后,`main` 函数会调用 `print_ints`函数。程序中并没有调用 `free` 来对应 `malloc` 操作;因此,内存泄漏了。 + +如果安装了 `valgrind` 工具箱,下面的命令会检查 `leaky` 程序是否存在内存泄漏(`%` 是命令行提示符): + +``` +% valgrind --leak-check=full ./leaky +``` + +绝大部分输出都在下面给出了。左边的数字 207683 是正在执行的 `leaky` 程序的进程标识符。这份报告给出了泄漏发生位置的详细信息,本例中位置是在 `main` 函数所调用的 `get_ints` 函数中对 `malloc` 的调用处。 + +``` +==207683== HEAP SUMMARY: +==207683==   in use at exit: 128 bytes in 1 blocks +==207683==   total heap usage: 2 allocs, 1 frees, 1,152 bytes allocated +==207683==  +==207683== 128 bytes in 1 blocks are definitely lost in loss record 1 of 1 +==207683==   at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) +==207683==   by 0x109186: get_ints (in /home/marty/gc/leaky) +==207683==   by 0x109236: main (in /home/marty/gc/leaky) +==207683==  +==207683== LEAK SUMMARY: +==207683==   definitely lost: 128 bytes in 1 blocks +==207683==   indirectly lost: 0 bytes in 0 blocks +==207683==   possibly lost: 0 bytes in 0 blocks +==207683==   still reachable: 0 bytes in 0 blocks +==207683==   suppressed: 0 bytes in 0 blocks +``` + +如果把 `main` 函数改成在对 `print_ints` 的调用之后,再加上一个对 `free` 的调用,`valgrind` 就会对 `leaky` 程序给出一个干净的内存健康清单: + +``` +==218462== All heap blocks were freed -- no leaks are possible +``` + +### 静态区存储 + +在正统的 C 语言中,函数必须在所有块之外定义。这是一些 C 编译器支持的特性,杜绝了在另一个函数体内定义一个函数的可能。我举的例子都是在所有块之外定义的函数。这样的函数要么是 `static` ,即静态的,要么是 `extern`,即外部的,其中 `extern` 是默认值。 + +C 语言中,以 `static` 或 `extern` 修饰的函数和变量驻留在内存中所谓的 **静态区** 中,因为在程序执行期间该区域大小是固定不变的。这两个存储类型的语法非常复杂,我们应该回顾一下。在回顾之后,会有一个完整的代码示例来生动展示语法细节。在所有块之外定义的函数或变量默认为 `extern`;因此,函数和变量要想存储类型为 `static` ,必须显式指定: + +``` +/** file1.c: outside all blocks, five definitions  **/ +int foo(int n) { return n * 2; }     /* extern by default */ +static int bar(int n) { return n; }  /* static */ +extern int baz(int n) { return -n; } /* explicitly extern */ + +int num1;        /* extern */ +static int num2; /* static */ +``` + +`extern` 和 `static` 的区别在于作用域:`extern` 修饰的函数或变量可以实现跨文件可见(需要声明)。相比之下,`static` 修饰的函数仅在 _定义_ 该函数的文件中可见,而 `static` 修饰的变量仅在 _定义_ 该变量的文件(或文件中的块)中可见: + +``` +static int n1;    /* scope is the file */ +void func() { +   static int n2; /* scope is func's body */ +   ... +} +``` + +如果在所有块之外定义了 `static` 变量,例如上面的 `n1`,该变量的作用域就是定义变量的文件。无论在何处定义 `static` 变量,变量的存储都在内存的静态区中。 + +`extern` 函数或变量在给定文件中的所有块之外定义,但这样定义的函数或变量也可以在其他文件中声明。典型的做法是在头文件中 _声明_ 这样的函数或变量,只要需要就可以包含进来。下面这些简短的例子阐述了这些棘手的问题。 + +假设 `extern` 函数 `foo` 在 `file1.c` 中 _定义_,有无关键字 `extern` 效果都一样: + +``` +/** file1.c **/ +int foo(int n) { return n * 2; } /* definition has a body {...} */ +``` + +必须在其他文件(或其中的块)中使用显式的 `extern` _声明_ 此函数才能使其可见。以下是使 `extern` 函数 `foo` 在文件 `file2.c` 中可见的声明语句: + +``` +/** file2.c: make function foo visible here **/ +extern int foo(int); /* declaration (no body) */ +``` + +回想一下,函数声明没有用大括号括起来的主体,而函数定义会有这样的主体。 + +为了便于查看,函数和变量声明通常会放在头文件中。准备好需要声明的源代码文件,然后就可以 `#include` 相关的头文件。下一节中的 `staticProg` 程序演示了这种方法。 + +至于 `extern` 的变量,规则就变得更棘手了(很抱歉增加了难度!)。任何 `extern` 的对象——无论函数或变量——必须 _定义_ 在所有块之外。此外,在所有块之外定义的变量默认为 `extern`: + +``` +/** outside all blocks **/ +int n; /* defaults to extern */ +``` + +但是,只有在变量的 _定义_ 中显式初始化变量时,`extern` 才能在变量的 _定义_ 中显式修饰(LCTT 译注:换言之,如果下列代码中的 `int n1;` 行前加上 `extern`,该行就由 _定义_ 变成了 _声明_): + +``` +/** file1.c: outside all blocks **/ +int n1;             /* defaults to extern, initialized by compiler to zero */ +extern int n2 = -1; /* ok, initialized explicitly */ +int n3 = 9876;      /* ok, extern by default and initialized explicitly */ +``` + +要使在 `file1.c` 中定义为 `extern` 的变量在另一个文件(例如 `file2.c`)中可见,该变量必须在 `file2.c` 中显式 _声明_ 为 `extern` 并且不能初始化(初始化会将声明转换为定义): + +``` +/** file2.c **/ +extern int n1; /* declaration of n1 defined in file1.c */ +``` + +为了避免与 `extern` 变量混淆,经验是在 _声明_ 中显式使用 `extern`(必须),但不要在 _定义_ 中使用(非必须且棘手)。对于函数,`extern` 在定义中是可选使用的,但在声明中是必须使用的。下一节中的 `staticProg` 示例会把这些点整合到一个完整的程序中。 + +### staticProg 示例 + +`staticProg` 程序由三个文件组成:两个 C 语言源文件(`static1.c` 和 `static2.c`)以及一个头文件(`static.h`),头文件中包含两个声明: + +``` +/** header file static.h **/ +#define NumCount 100               /* macro */ +extern int global_nums[NumCount];  /* array declaration */ +extern void fill_array();          /* function declaration */ +``` + +两个声明中的 `extern`,一个用于数组,另一个用于函数,强调对象在别处(“外部”)_定义_:数组 `global_nums` 在文件 `static1.c` 中定义(没有显式的 `extern`),函数 `fill_array` 在文件 `static2.c` 中定义(也没有显式的 `extern`)。每个源文件都包含了头文件 `static.h`。`static1.c` 文件定义了两个驻留在内存静态区域中的数组(`global_nums` 和 `more_nums`)。第二个数组有 `static` 修饰,这将其作用域限制为定义数组的文件 (`static1.c`)。如前所述, `extern` 修饰的 `global_nums` 则可以实现在多个文件中可见。 + +``` +/** static1.c **/ +#include +#include + +#include "static.h"             /* declarations */ + +int global_nums[NumCount];      /* definition: extern (global) aggregate */ +static int more_nums[NumCount]; /* definition: scope limited to this file */ + +int main() { +  fill_array(); /** defined in file static2.c **/ + +  unsigned i; +  for (i = 0; i < NumCount; i++) +    more_nums[i] = i * -1; + +  /* confirm initialization worked */ +  for (i = 0; i < NumCount; i += 10)  +    printf("%4i\t%4i\n", global_nums[i], more_nums[i]); +     +  return 0;   +} +``` + +下面的 `static2.c` 文件中定义了 `fill_array` 函数,该函数由 `main`(在 `static1.c` 文件中)调用;`fill_array` 函数会给名为 `global_nums` 的 `extern` 数组中的元素赋值,该数组在文件 `static1.c` 中定义。使用两个文件的唯一目的是凸显 `extern` 变量或函数能够跨文件可见。 + +``` +/** static2.c **/ +#include "static.h" /** declarations **/ + +void fill_array() { /** definition **/ +  unsigned i; +  for (i = 0; i < NumCount; i++) global_nums[i] = i + 2; +} +``` + +`staticProg` 程序可以用如下编译: + +``` +% gcc -o staticProg static1.c static2.c +``` + +### 从汇编语言看更多细节 + +现代 C 编译器能够处理 C 和汇编语言的任意组合。编译 C 源文件时,编译器首先将 C 代码翻译成汇编语言。这是对从上文 `static1.c` 文件生成的汇编语言进行保存的命令: + +``` +% gcc -S static1.c +``` + +生成的文件就是 `static1.s`。这是文件顶部的一段代码,额外添加了行号以提高可读性: + +``` +    .file    "static1.c"          ## line  1 +    .text                         ## line  2 +    .comm    global_nums,400,32   ## line  3 +    .local    more_nums           ## line  4 +    .comm    more_nums,400,32     ## line  5 +    .section    .rodata           ## line  6 +.LC0:                             ## line  7 +    .string    "%4i\t%4i\n"       ## line  8 +    .text                         ## line  9 +    .globl    main                ## line 10 +    .type    main, @function      ## line 11 +main:                             ## line 12 +... +``` + +诸如 `.file`(第 1 行)之类的汇编语言指令以句点开头。顾名思义,指令会指导汇编程序将汇编语言翻译成机器代码。`.rodata` 指令(第 6 行)表示后面是只读对象,包括字符串常量 `"%4i\t%4i\n"`(第 8 行),`main` 函数(第 12 行)会使用此字符串常量来实现格式化输出。作为标签引入(通过末尾的冒号实现)的 `main` 函数(第 12 行),同样也是只读的。 + +在汇编语言中,标签就是地址。标签 `main:`(第 12 行)标记了 `main` 函数代码开始的地址,标签 `.LC0:`(第 7 行)标记了格式化字符串开头所在的地址。 + +`global_nums`(第 3 行)和 `more_nums`(第 4 行)数组的定义包含了两个数字:400 是每个数组中的总字节数,32 是每个数组(含 100 个 `int` 元素)中每个元素的比特数。(第 5 行中的 `.comm` 指令表示 `common name`,可以忽略。) + +两个数组定义的不同之处在于 `more_nums` 被标记为 `.local`(第 4 行),这意味着其作用域仅限于其所在文件 `static1.s`。相比之下,`global_nums` 数组就能在多个文件中实现可见,包括由 `static1.c` 和 `static2.c` 文件翻译成的汇编文件。 + +最后,`.text` 指令在汇编代码段中出现了两次(第 2 行和第 9 行)。术语“text”表示“只读”,但也会涵盖一些读/写变量,例如两个数组中的元素。尽管本文展示的汇编语言是针对 Intel 架构的,但 Arm6 汇编也非常相似。对于这两种架构,`.text` 区域中的变量(本例中为两个数组中的元素)会自动初始化为零。 + +### 总结 + +C 语言中的内存高效和内存安全编程准则很容易说明,但可能会很难遵循,尤其是在调用设计不佳的库的时候。准则如下: + + * 尽可能使用栈存储,进而鼓励编译器将通用寄存器用作暂存器,实现优化。栈存储代表了高效的内存使用并促进了代码的整洁和模块化。永远不要返回指向基于栈的存储的指针。 + * 小心使用堆存储。C(和 C++)中的重难点是确保动态分配的存储尽快解除分配。良好的编程习惯和工具(如 `valgrind`)有助于攻关这些重难点。优先选用自身提供释放函数的库,例如 `nestedHeap` 代码示例中的 `free_all` 释放函数。 + * 谨慎使用静态存储,因为这种存储会自始至终地影响进程的内存占用。特别是尽量避免使用 `extern` 和 `static` 数组。 + +本文 C 语言代码示例可在我的网站()上找到。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/8/memory-programming-c + +作者:[Marty Kalin][a] +选题:[lujun9972][b] +译者:[unigeorge](https://github.com/unigeorge) +校对:[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/code_computer_development_programming.png?itok=4OM29-82 (Code going into a computer.) +[2]: http://www.opengroup.org/onlinepubs/009695399/functions/fopen.html +[3]: http://www.opengroup.org/onlinepubs/009695399/functions/fclose.html +[4]: http://www.opengroup.org/onlinepubs/009695399/functions/fread.html +[5]: http://www.opengroup.org/onlinepubs/009695399/functions/fwrite.html +[6]: http://www.opengroup.org/onlinepubs/009695399/functions/printf.html +[7]: http://www.opengroup.org/onlinepubs/009695399/functions/puts.html +[8]: http://www.opengroup.org/onlinepubs/009695399/functions/malloc.html +[9]: http://www.opengroup.org/onlinepubs/009695399/functions/fprintf.html +[10]: http://www.opengroup.org/onlinepubs/009695399/functions/free.html +[11]: https://www.valgrind.org/ diff --git a/published/20210818 below- a time traveling resource monitor.md b/published/20210818 below- a time traveling resource monitor.md new file mode 100644 index 0000000000..7212fecec1 --- /dev/null +++ b/published/20210818 below- a time traveling resource monitor.md @@ -0,0 +1,110 @@ +[#]: subject: "below: a time traveling resource monitor" +[#]: via: "https://fedoramagazine.org/below-a-time-traveling-resource-monitor/" +[#]: author: "Daniel Xu https://fedoramagazine.org/author/dxuu/" +[#]: collector: "lujun9972" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13854-1.html" + +Below:一个时间旅行的资源监控器 +====== + +![](https://img.linux.net.cn/data/attachment/album/202110/06/093522hdsb82nm1cb4b4b6.jpg) + +在这篇文章中,我们将介绍 `below`:一个用于现代 Linux 系统的 Apache 2.0 许可的资源监视器。`below` 可以让你重放以前记录的数据。 + +![][1] + +### 背景 + +内核的主要职责之一是调度对资源的访问。有时这可能意味着分配物理内存,使多个进程可以共享同一主机。其他时候,它可能意味着确保 CPU 时间的公平分配。在这些场景里,内核提供了机制,而将策略留给了“别人”。近来,这个“别人”通常是 systemd 或 dockerd 这样的运行时。运行时接受来自调度器或最终用户的输入(类似于运行什么和如何运行)并在内核上转动正确的旋钮和拉动正确的杠杆,从而使工作负载能够*好好*工作。 + +在一个完美的世界里,故事就到此结束了。然而,现实情况是,资源管理是一个复杂的、相当不透明的技术混合体,在几十年里计算技术不断发展。尽管其中一些技术有各种缺陷和死角,但最终的结果是,容器运作得比较好。虽然用户通常不需要关心这些细节,但对于基础设施运营商来说,对他们的技术架构拥有可见性是至关重要的。可见性和可调试性对于检测和调查错误的配置、问题和系统性故障至关重要。 + +让事情变得更加复杂的是,资源中断往往难以重现。经常需要花费数周时间等待一个问题重新出现,以便调查其根本原因。规模的扩大进一步加剧了这个问题:我们不能在*每台*主机上运行一个自定义脚本,希望在错误再次发生时记录下关键状态的片段。因此,需要更复杂的工具。这就出现了 `below`。 + +### 动机 + +历史上,Facebook 一直是 [atop][5] 的忠实用户。`atop` 是一个用于 Linux 的性能监视器,能够报告所有进程的活动以及各种系统级活动。与 `htop` 等工具相比,`atop` 最引人注目的功能之一是能够作为一个守护程序记录历史数据。这听起来是一个简单的功能,但在实践中,这使得调试无数的生产问题成为可能。有了足够长的数据保留,就有可能在时间上回溯,查看在问题或故障发生之前、期间和之后的主机状态。 + +不幸的是,随着时间的推移,人们发现`atop` 有某些不足之处。首先,[控制组][6]cgroup 已经成为控制和监视 Linux 机器上资源的实际方式。`atop` 仍然缺乏对这一基本构建模块的支持。第二,`atop` 用自定义的 delta 压缩方法在磁盘上存储数据。这在正常情况下运行良好,但在沉重的资源压力下,主机很可能会丢失数据点。由于使用了 delta 压缩,在数据最重要的时间段内,数据可能会大面积丢失。第三,用户体验有一个陡峭的学习曲线。我们经常听到 `atop` 的资深用户说,他们喜欢密集的布局和众多的键盘绑定。然而,这也是一把双刃剑。当一个刚进入这个领域的人想要调试一个生产问题时,他们现在要同时解决两个问题:手头的问题和如何使用 `atop`。 + +`below` 是由 Facebook 的资源控制团队为其设计和开发的,并得到了 `atop` 生产环境用户的支持。顾名思义,资源控制团队负责的是规模化的资源管理。该团队由内核开发人员、容器运行时开发人员和硬件人员组成。认识到下一代系统监控器的机会,我们在设计 `below` 时考虑到以下几点: + + * 易用性:`below` 必须既能为新用户提供直观的体验,又能为日常用户提供强大的功能。 + *有意义的统计数据:`below` 显示准确和有用的统计数据。即便可以,但我们尽量避免收集和倾倒统计数字。 + * 灵活性:当默认设置不合适时,我们允许用户自定义他们的体验。例如包括可配置的键绑定、可配置的默认视图,以及脚本界面(默认为终端用户接口)。 + +### 安装 + +安装该软件包: + +``` +# dnf install -y below +``` + +打开记录守护进程: + +``` +# systemctl enable --now below +``` + +### 快速介绍 + +`below` 最常用的模式是重放模式。顾名思义,重放模式是重放以前记录的数据。假设你已经启动了记录守护程序,那么通过运行以下程序启动一个会话: + +``` +$ below replay --time "5 minutes ago" +``` + +然后你会看到控制组视图: + +![][2] + +如果你不知道该怎么操作,或者忘记了一个键位,按 `?` 可以进入帮助菜单。 + +屏幕的最上方是状态栏。状态栏显示关于当前样本的信息。你可以通过按 `t` 和 `T` 分别向前和向后移动样本。中间的部分是系统概览。系统概览包含了关于整个系统的统计数据,一般来说,这些数据总是很有用的。第三部分也是最下面的部分是多用途视图。上面的图片显示了控制组视图。此外,还有进程和系统视图,分别通过按 `p` 和` s` 来访问。 + +按 `↑` 和 `↓` 来移动列表选择。按回车键来折叠和展开控制组。假设你发现了一个感兴趣的控制组,你想看看它里面有哪些进程在运行。要放大进程视图,选择控制组并按 `z`: + +![][3] + +再按 `z` 返回到控制组视图。这个视图有时会有点长。如果你对你要找的东西有一个模糊的概念,你可以通过按 `/` 并输入一个过滤器来过滤控制组名称。 + +![][4] + +在这一点上,你可能已经注意到了一个我们还没有探索过的标签系统。要在标签中向前和向后循环,可以分别按 `Tab` 和 `Shift` + `Tab`。我们把这个问题留给读者去做练习。 + +### 其他功能 + +在底层,`below` 有一个强大的设计和架构。Facebook 正在不断升级到更新的内核,所以我们从不假设数据源是可用的。这种默契的假设使得内核和 `below `版本之间能够完全向前和向后兼容。此外,每个数据点都用 zstd 压缩并完整地存储。这解决了我们看到的 `atop` 在大规模时的 delta 压缩问题。根据我们的测试,我们的每个样本压缩可以达到平均 5 倍的压缩率。 + +`below` 也使用 [eBPF][8] 来收集关于短暂进程(生存时间短于数据收集间隔的进程)的信息。相比之下,`atop` 使用 BSD 进程核算来实现这一功能,这是一个已知缓慢且容易发生优先级转换的内核接口。 + +对于用户来说,`below` 还支持实时模式和一个转储接口。实时模式将记录守护程序和 TUI 会话合并到一个进程中。这对于浏览系统状态是很方便的,不需要为数据存储投入长期运行的守护程序或磁盘空间。转储接口是一个可编写脚本的接口,用于所有的 `below` 数据存储。转储既强大又灵活,详细的数据以 CSV、JSON 和人类可读格式提供。 + +### 总结 + +`below` 是一个 Apache 2.0 许可的开源项目,我们(`below` 的开发者)认为它比资源监控领域的现有工具具有引人注目的优势。我们已经花了大量的精力来准备 `below`,以提供开源使用,所以我们希望读者和社区有机会尝试 `below`,并报告错误和功能要求。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/below-a-time-traveling-resource-monitor/ + +作者:[Daniel Xu][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/dxuu/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2021/08/below_resource_monitor-816x345.jpg +[2]: https://fedoramagazine.org/wp-content/uploads/2021/08/image-1024x800.png +[3]: https://fedoramagazine.org/wp-content/uploads/2021/08/image-1-1024x800.png +[4]: https://fedoramagazine.org/wp-content/uploads/2021/08/image-2-1024x800.png +[5]: +[6]: +[7]: \ No newline at end of file diff --git a/published/20200121 13 of the best React JavaScript frameworks.md b/published/202109/20200121 13 of the best React JavaScript frameworks.md similarity index 100% rename from published/20200121 13 of the best React JavaScript frameworks.md rename to published/202109/20200121 13 of the best React JavaScript frameworks.md diff --git a/published/20200211 Using external libraries in Java.md b/published/202109/20200211 Using external libraries in Java.md similarity index 100% rename from published/20200211 Using external libraries in Java.md rename to published/202109/20200211 Using external libraries in Java.md diff --git a/published/20200908 Deploy a deep learning model on Kubernetes.md b/published/202109/20200908 Deploy a deep learning model on Kubernetes.md similarity index 100% rename from published/20200908 Deploy a deep learning model on Kubernetes.md rename to published/202109/20200908 Deploy a deep learning model on Kubernetes.md diff --git a/published/20210228 What is GNU-Linux Copypasta.md b/published/202109/20210228 What is GNU-Linux Copypasta.md similarity index 100% rename from published/20210228 What is GNU-Linux Copypasta.md rename to published/202109/20210228 What is GNU-Linux Copypasta.md diff --git a/published/20210424 Can We Recommend Linux for Gaming in 2021.md b/published/202109/20210424 Can We Recommend Linux for Gaming in 2021.md similarity index 100% rename from published/20210424 Can We Recommend Linux for Gaming in 2021.md rename to published/202109/20210424 Can We Recommend Linux for Gaming in 2021.md diff --git a/published/202109/20210622 What is a config file.md b/published/202109/20210622 What is a config file.md new file mode 100644 index 0000000000..704240b003 --- /dev/null +++ b/published/202109/20210622 What is a config file.md @@ -0,0 +1,174 @@ +[#]: subject: (What is a config file?) +[#]: via: (https://opensource.com/article/21/6/what-config-files) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: (unigeorge) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13832-1.html) + +浅谈配置文件格式 +====== + +> 流行的配置文件格式有若干种,每种都有其自身优势。从中找到最适合你的格式吧! + +![](https://img.linux.net.cn/data/attachment/album/202109/29/134955py5ypl58dgplyx4x.jpg) + +计算机上有数以千计的配置文件。你可能永远不会直接与其中的大部分文件打交道,但它们确实散落在你的 `/etc` 以及 `~/.config`、`~/.local`、`/usr` 文件夹中。还有一些可能在 `/var`,甚至 `/opt` 文件夹中。如果无意中打开过或更改过它们,你就可能会有疑问:为什么有些配置文件看起来是某一种格式,而另一些则是看起来完全不同的格式? + +存储配置是一项很灵活的任务,因为只要开发人员知道他们的代码是如何将数据存入文件的,他们就可以轻松编写代码来根据需要提取数据。然而,科技行业非常青睐有详细文档的标准化事物,因此多年来出现了几种比较普遍的格式用来简化配置任务。 + +### 为什么我们需要配置文件 + +配置文件对于现代计算来说很重要。它们使你能够自定义与应用程序交互的方式,或自定义应用程序与系统内其他程序的交互方式。有了配置文件,每当你启动某个应用程序时,它都会有“记忆”,记录了你喜欢如何去使用该程序。 + +配置文件的结构可以很简单,而且通常确实也很简单。例如,如果你要编写一个应用程序,程序唯一需要知道的是其用户的偏好名字,那么它的唯一配置文件就可以只包含一个词:用户名。就像下面这样: + +``` +Tux +``` + +但通常应用程序需要追踪的不仅仅是一条信息,因此配置文件通常会有一个键和一个值: + +``` +NAME='Tux' +SPECIES='Penguin' +``` + +即使没有编程经验,你也可以想象出代码如何解析这些数据。这里有两个简单的例子,一个使用 [awk 命令][2],另一个使用 [grep 命令][3]。两个例子都是只关注包含 `NAME` “键”的行,并返回出现在等号 (`=`) 之后的“值”: + +``` +$ awk -F'=' '/NAME/ { print $2; }' myconfig.ini +'Tux' +$ grep NAME fake.txt | cut -d'=' -f2 +'Tux' +``` + +同样的原则适用于任何编程语言和任何配置文件。只要你有统一的数据结构,就可以在需要的时候编写简单的代码来提取和解析它。 + +### 选择格式 + +为了保证普遍有效性,配置文件最重要的一点是它们是一致的和可预测的。你绝对不会想做这样的事:以保存用户首选项的名义,将信息随意存储到文件中,然后花好几天时间逆向工程,来找到最终出现在文件中的随机信息。 + +流行的配置文件格式有若干种,每种格式都有自己的优势。 + +#### INI + +INI 文件采用了键值对的格式: + +``` +[example] +name=Tux +style=widgety,fidgety +enabled=1 +``` + +这种简单的配置风格很直观,只要你别选择使用糟糕的键名(比如用 `unampref` 这样的神秘键名来代替 `name`)就好。这些键值对很容易解析和编辑。 + +除了键和值之外,INI 格式还可以分 section。在下列示例代码中,`[example]` 和 `[demo]` 就是配置文件中的两个节: + +``` +[example] +name=Tux +style=widgety,fidgety +enabled=1 + +[demo] +name=Beastie +fullscreen=1 +``` + +这几个配置语句解析起来有点复杂,因为有两个 `name` 键。想象一下,一个粗心的程序员在这个配置文件中查询 `name`,结果总是返回 `Beastie`,因为这是文件中对 `name` 的最后一个定义值。在解析这样的文件时,开发人员必须加倍小心地在各节中搜索键,这可能会很棘手,具体取决于用来解析该文件的语言。然而,它仍然是一种很流行的格式,大多数语言都会有一个现成的库来帮助程序员解析 INI 文件。 + +#### YAML + +[YAML 文件][4] 是结构化列表,可以包含值或者键值对: + +``` +--- +Example: +  Name: 'Tux' +  Style: +   - 'widgety' +    - 'fidgety' +  Enabled: 1 +``` + +YAML 格式很流行,部分原因是它看起来很整洁。数据要放置到相对其上层数据的特定位置,除此之外没有太多其他语法。然而,对于某些人来说的这种特色,在其他人眼中可能就是一个问题。许多开发人员不愿使用 YAML,正是因为它很看重本质上 _不存在_ 的东西。如果你在 YAML 中缩进错误,YAML 解析器可能会将你的文件视为无效文件,即使不视为无效,返回的数据也可能是错误的。 + +大多数语言都有 YAML 解析器,并且有很好的开源 YAML linters(验证语法的应用程序)来帮你确保 YAML 文件的完整性。 + +#### JSON + +JSON 文件在技术上来说是 YAML 的子集,因此其数据结构是相同的,尽管其语法完全不同: + +``` +{ +  "Example": { +    "Name": [ +      "Tux" +    ], +    "Style": [ +      "widgety", +      "fidgety" +    ], +    "Enabled": 1 +  } +} +``` + +JSON 在 JavaScript 程序员中很流行,这并不奇怪,因为 JSON 全称为JavaScript 对象符号JavaScript Object Notation。由于与 Web 开发密切相关,JSON 是 Web API 的常见输出格式。大多数编程语言都有解析 JSON 的库。 + +#### XML + +XML 使用标签作为键,将配置值围绕起来: + +``` +Tux1 + +``` + +XML 经常被 Java 程序员使用,Java 有一套丰富的 XML 解析器。虽然 XML 以非常严格而著称,但同时也非常灵活。与有一系列特定标签的 HTML 不同,XML 中可以随意发明自己的标签。只要始终坚持相同的构建规则,并有一个良好的库来解析它,你就可以准确而轻松地提取数据。 + +有一些很好的开源 linter 可以帮你验证 XML 文件,并且大多数编程语言都提供用于解析 XML 的库。 + +#### 二进制格式 + +Linux 以纯文本配置为傲。这样做的优点是可以使用 [cat][5] 等基本工具查看配置数据,甚至可以使用你 [最喜欢的文本编辑器][6] 来编辑配置。 + +但是,某些应用程序使用二进制格式配置,就意味着数据以某种非自然语言的格式进行编码。这些文件通常需要一个特殊的应用程序(通常是它们要配置的应用程序)来解释它们的数据。你无法查看这些文件,至少无法以任何有意义的方式查看,并且无法在其宿主应用程序之外编辑它们。选用二进制格式的一些原因如下: + + * **速度:** 程序员可以使用自定义符号在二进制配置文件中的某些点注册特定的信息位。提取数据时不涉及搜索,因为所有内容都已标注了索引。 + * **大小:** 文本文件可能会变大,如果选择压缩文本文件,实际上是在将其转换为二进制格式。二进制文件可以通过编码技巧变得更小(文本文件也是如此,但在某些时候,你的优化会使数据变得晦涩,以至于文件也成了二进制文件)。 + * **晦涩:** 一些程序员甚至不希望人们查看他们的配置文件,因此将它们编码为二进制数据。这通常只会让用户感到沮丧,并不是使用二进制格式的好理由。 + +如果必须使用二进制格式进行配置,请使用已作为开放标准存在的格式,例如 [NetCDF][7]。 + +### 找到有效的配置格式 + +配置格式帮助开发人员存储应用程序所需的数据,并帮助用户存储他们希望应用程序如何操作的偏好项。对于应该使用什么格式的问题,可能没有错误的答案,只要你觉得所使用的语言能很好地支持就可以。在开发应用程序时,查看可用格式,用一些样例数据建模,查看和评估你的编程语言提供的库和实用程序,然后选择你觉得最合适的一种格式吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/what-config-files + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[unigeorge](https://github.com/unigeorge) +校对:[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/browser_screen_windows_files.png?itok=kLTeQUbY (Computer screen with files or windows open) +[2]: https://opensource.com/article/20/9/awk-ebook +[3]: https://opensource.com/downloads/grep-cheat-sheet +[4]: https://www.redhat.com/sysadmin/yaml-beginners +[5]: https://opensource.com/article/19/2/getting-started-cat-command +[6]: https://opensource.com/article/21/2/open-source-text-editors +[7]: https://www.unidata.ucar.edu/software/netcdf/ diff --git a/published/20210719 Apps for daily needs part 2- office suites.md b/published/202109/20210719 Apps for daily needs part 2- office suites.md similarity index 100% rename from published/20210719 Apps for daily needs part 2- office suites.md rename to published/202109/20210719 Apps for daily needs part 2- office suites.md diff --git a/published/20210727 Analyze the Linux kernel with ftrace.md b/published/202109/20210727 Analyze the Linux kernel with ftrace.md similarity index 100% rename from published/20210727 Analyze the Linux kernel with ftrace.md rename to published/202109/20210727 Analyze the Linux kernel with ftrace.md diff --git a/published/20210804 Apps for daily needs part 3- image editors.md b/published/202109/20210804 Apps for daily needs part 3- image editors.md similarity index 100% rename from published/20210804 Apps for daily needs part 3- image editors.md rename to published/202109/20210804 Apps for daily needs part 3- image editors.md diff --git a/published/20210819 A guide to understanding your team-s implicit values and needs.md b/published/202109/20210819 A guide to understanding your team-s implicit values and needs.md similarity index 100% rename from published/20210819 A guide to understanding your team-s implicit values and needs.md rename to published/202109/20210819 A guide to understanding your team-s implicit values and needs.md diff --git a/published/20210819 Debian vs Ubuntu- What-s the Difference- Which One Should You Use.md b/published/202109/20210819 Debian vs Ubuntu- What-s the Difference- Which One Should You Use.md similarity index 100% rename from published/20210819 Debian vs Ubuntu- What-s the Difference- Which One Should You Use.md rename to published/202109/20210819 Debian vs Ubuntu- What-s the Difference- Which One Should You Use.md diff --git a/published/20210820 Check file status on Linux with the stat command.md b/published/202109/20210820 Check file status on Linux with the stat command.md similarity index 100% rename from published/20210820 Check file status on Linux with the stat command.md rename to published/202109/20210820 Check file status on Linux with the stat command.md diff --git a/published/20210820 How to Download Audio Only Using youtube-dl.md b/published/202109/20210820 How to Download Audio Only Using youtube-dl.md similarity index 100% rename from published/20210820 How to Download Audio Only Using youtube-dl.md rename to published/202109/20210820 How to Download Audio Only Using youtube-dl.md diff --git a/published/20210821 10 Things to Do After Installing elementary OS 6 -Odin.md b/published/202109/20210821 10 Things to Do After Installing elementary OS 6 -Odin.md similarity index 100% rename from published/20210821 10 Things to Do After Installing elementary OS 6 -Odin.md rename to published/202109/20210821 10 Things to Do After Installing elementary OS 6 -Odin.md diff --git a/published/20210821 How to set up your printer on Linux.md b/published/202109/20210821 How to set up your printer on Linux.md similarity index 100% rename from published/20210821 How to set up your printer on Linux.md rename to published/202109/20210821 How to set up your printer on Linux.md diff --git a/published/20210823 Apps for daily needs part 4- audio editors.md b/published/202109/20210823 Apps for daily needs part 4- audio editors.md similarity index 100% rename from published/20210823 Apps for daily needs part 4- audio editors.md rename to published/202109/20210823 Apps for daily needs part 4- audio editors.md diff --git a/published/20210824 Ulauncher- A Super Useful Application Launcher for Linux.md b/published/202109/20210824 Ulauncher- A Super Useful Application Launcher for Linux.md similarity index 100% rename from published/20210824 Ulauncher- A Super Useful Application Launcher for Linux.md rename to published/202109/20210824 Ulauncher- A Super Useful Application Launcher for Linux.md diff --git a/published/20210826 Elementary OS 6 Odin Review - Late Arrival but a Solid One.md b/published/202109/20210826 Elementary OS 6 Odin Review - Late Arrival but a Solid One.md similarity index 100% rename from published/20210826 Elementary OS 6 Odin Review - Late Arrival but a Solid One.md rename to published/202109/20210826 Elementary OS 6 Odin Review - Late Arrival but a Solid One.md diff --git a/published/20210827 How to Easily Install Debian Linux.md b/published/202109/20210827 How to Easily Install Debian Linux.md similarity index 100% rename from published/20210827 How to Easily Install Debian Linux.md rename to published/202109/20210827 How to Easily Install Debian Linux.md diff --git a/published/20210827 Linux kernel modules we can-t live without.md b/published/202109/20210827 Linux kernel modules we can-t live without.md similarity index 100% rename from published/20210827 Linux kernel modules we can-t live without.md rename to published/202109/20210827 Linux kernel modules we can-t live without.md diff --git a/published/20210829 Position text on your screen in Linux with ncurses.md b/published/202109/20210829 Position text on your screen in Linux with ncurses.md similarity index 100% rename from published/20210829 Position text on your screen in Linux with ncurses.md rename to published/202109/20210829 Position text on your screen in Linux with ncurses.md diff --git a/published/20210830 Linux Jargon Buster- What is sudo rm -rf- Why is it Dangerous.md b/published/202109/20210830 Linux Jargon Buster- What is sudo rm -rf- Why is it Dangerous.md similarity index 100% rename from published/20210830 Linux Jargon Buster- What is sudo rm -rf- Why is it Dangerous.md rename to published/202109/20210830 Linux Jargon Buster- What is sudo rm -rf- Why is it Dangerous.md diff --git a/published/20210830 Write a guessing game in ncurses on Linux.md b/published/202109/20210830 Write a guessing game in ncurses on Linux.md similarity index 100% rename from published/20210830 Write a guessing game in ncurses on Linux.md rename to published/202109/20210830 Write a guessing game in ncurses on Linux.md diff --git a/published/20210831 What is a container image.md b/published/202109/20210831 What is a container image.md similarity index 100% rename from published/20210831 What is a container image.md rename to published/202109/20210831 What is a container image.md diff --git a/published/20210831 Zulip- An Interesting Open-Source Alternative to Slack.md b/published/202109/20210831 Zulip- An Interesting Open-Source Alternative to Slack.md similarity index 100% rename from published/20210831 Zulip- An Interesting Open-Source Alternative to Slack.md rename to published/202109/20210831 Zulip- An Interesting Open-Source Alternative to Slack.md diff --git a/published/20210901 20 essential Linux commands for every user.md b/published/202109/20210901 20 essential Linux commands for every user.md similarity index 100% rename from published/20210901 20 essential Linux commands for every user.md rename to published/202109/20210901 20 essential Linux commands for every user.md diff --git a/published/20210901 What are container runtimes.md b/published/202109/20210901 What are container runtimes.md similarity index 100% rename from published/20210901 What are container runtimes.md rename to published/202109/20210901 What are container runtimes.md diff --git a/published/20210902 4 Linux technologies fundamental to containers.md b/published/202109/20210902 4 Linux technologies fundamental to containers.md similarity index 100% rename from published/20210902 4 Linux technologies fundamental to containers.md rename to published/202109/20210902 4 Linux technologies fundamental to containers.md diff --git a/published/20210904 How to Install Dropbox on Ubuntu Linux.md b/published/202109/20210904 How to Install Dropbox on Ubuntu Linux.md similarity index 100% rename from published/20210904 How to Install Dropbox on Ubuntu Linux.md rename to published/202109/20210904 How to Install Dropbox on Ubuntu Linux.md diff --git a/translated/tech/20210905 Neither Windows, nor Linux- Shrine is ‘God-s Operating System.md b/published/202109/20210905 Neither Windows, nor Linux- Shrine is ‘God-s Operating System.md similarity index 85% rename from translated/tech/20210905 Neither Windows, nor Linux- Shrine is ‘God-s Operating System.md rename to published/202109/20210905 Neither Windows, nor Linux- Shrine is ‘God-s Operating System.md index 2fdc0afe51..aac67eb493 100644 --- a/translated/tech/20210905 Neither Windows, nor Linux- Shrine is ‘God-s Operating System.md +++ b/published/202109/20210905 Neither Windows, nor Linux- Shrine is ‘God-s Operating System.md @@ -3,13 +3,15 @@ [#]: author: "John Paul https://itsfoss.com/author/john/" [#]: collector: "lujun9972" [#]: translator: "wxy" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13831-1.html" 不是 Windows,也不是 Linux,Shrine 才是 “神之操作系统” ====== +![](https://img.linux.net.cn/data/attachment/album/202109/28/154516dcc5u1a50zfn4abw.jpg) + 在生活中,我们都曾使用过多种操作系统。有些好,有些坏。但你能说你使用过由“神”设计的操作系统吗?今天,我想向你介绍 Shrine(圣殿)。 ### 什么是 Shrine? @@ -18,21 +20,21 @@ 从介绍里,你可能想知道这到底是怎么回事。嗯,这一切都始于一个叫 Terry Davis 的人。在我们进一步介绍之前,我最好提醒你,Terry 在生前患有精神分裂症,而且经常不吃药。正因为如此,他在生活中说过或做过一些不被社会接受的事情。 -总之,让我们回到故事的主线。在 21 世纪初,Terry 发布了一个简单的操作系统。多年来,它不停地换了几个名字,有 J Operating System、LoseThos 和 SparrowOS 等等。他最终确定了 [TempleOS][2] 这个名字。他选择这个名字(神庙系统)是因为这个操作系统将成为神的圣殿。因此,神给 Terry 的操作系统规定了以下 [规格][3]: +总之,让我们回到故事的主线。在 21 世纪初,Terry 发布了一个简单的操作系统。多年来,它不停地换了几个名字,有 J Operating System、LoseThos 和 SparrowOS 等等。他最终确定了 [TempleOS][2](神庙系统)这个名字。他选择这个名字是因为这个操作系统将成为“神的圣殿”。因此,“神”给 Terry 的操作系统规定了以下 [规格][3]: ![video](https://youtu.be/LtlyeDAJR7A) - * 它将有 640×480 的 16 色图形 - * 它将使用“单声道 8 位带符号的类似 MIDI 的声音采样” + * 它将有 640×480 的 16 色图形显示 + * 它将使用 “单声道 8 位带符号的类似 MIDI 的声音采样” * 它将追随 Commodore 64,即“一个非网络化的简单机器,编程是目标,而不仅仅是达到目的的手段” - * 它将只支持一个文件系统(名为 “Red Sea”)。 - * 它将被限制在 10 万行代码内,以使它 “整体易于学习”。 - * “只支持 Ring-0 级,一切都在内核模式下运行,包括用户应用程序 + * 它将只支持一个文件系统(名为 “Red Sea”) + * 它将被限制在 10 万行代码内,以使它 “整体易于学习” + * “只支持 Ring-0 级,一切都在内核模式下运行,包括用户应用程序” * 字体将被限制为 “一种 8×8 等宽字体” * “对一切都可以完全访问。所有的内存、I/O 端口、指令和类似的东西都绝无限制。所有的函数、变量和类成员都是可访问的” * 它将只支持一个平台,即 64 位 PC -Terry 用一种他称之为 HolyC(神圣 C 语言)的编程语言编写了这个操作系统。TechRepublic 称其为一种 “C++ 的修改版(‘比 C 多,比 C++ 少’)”。如果你有兴趣了解 HolyC,我推荐,[这篇文章][4] 和 [RosettaCode][5] 上的 HolyC 条目。 +Terry 用一种他称之为 HolyC(神圣 C 语言)的编程语言编写了这个操作系统。TechRepublic 称其为一种 “C++ 的修改版(‘比 C 多,比 C++ 少’)”。如果你有兴趣了解 HolyC,我推荐 [这篇文章][4] 和 [RosettaCode][5] 上的 HolyC 条目。 2013 年,Terry 在他的网站上宣布,TempleOS 已经完成。不幸的是,几年后的 2018 年 8 月,Terry 被火车撞死了。当时他无家可归。多年来,许多人通过他在该操作系统上的工作关注着他。大多数人对他在如此小的体积中编写操作系统的能力印象深刻。 @@ -45,6 +47,8 @@ Terry 用一种他称之为 HolyC(神圣 C 语言)的编程语言编写了 minexew 正计划在未来增加更多的功能,但还没有宣布具体会包括什么。他有计划为 Linux 制作一个完整的 TempleOS 环境。 +![video](https://youtu.be/UCgoxQCf5Jg) + ### 体验 让 Shrine 在虚拟机中运行是相当容易的。你所需要做的就是安装你选择的虚拟化软件。(我的是 VirtualBox)当你为 Shrine 创建一个虚拟机时,确保它是 64 位的,并且至少有 512MB 的内存。 @@ -62,7 +66,7 @@ via: https://itsfoss.com/shrine-os/ 作者:[John Paul][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/20210906 Getting the Top Indicator Panel Back in GNOME.md b/published/202109/20210906 Getting the Top Indicator Panel Back in GNOME.md similarity index 100% rename from published/20210906 Getting the Top Indicator Panel Back in GNOME.md rename to published/202109/20210906 Getting the Top Indicator Panel Back in GNOME.md diff --git a/published/20210906 Resize an image from the Linux terminal.md b/published/202109/20210906 Resize an image from the Linux terminal.md similarity index 100% rename from published/20210906 Resize an image from the Linux terminal.md rename to published/202109/20210906 Resize an image from the Linux terminal.md diff --git a/published/20210907 How to Stop a Program in Linux Terminal.md b/published/202109/20210907 How to Stop a Program in Linux Terminal.md similarity index 100% rename from published/20210907 How to Stop a Program in Linux Terminal.md rename to published/202109/20210907 How to Stop a Program in Linux Terminal.md diff --git a/published/20210907 OpenWrt 21.02 Arrives With Linux Kernel 5.4 - WPA3 Support.md b/published/202109/20210907 OpenWrt 21.02 Arrives With Linux Kernel 5.4 - WPA3 Support.md similarity index 100% rename from published/20210907 OpenWrt 21.02 Arrives With Linux Kernel 5.4 - WPA3 Support.md rename to published/202109/20210907 OpenWrt 21.02 Arrives With Linux Kernel 5.4 - WPA3 Support.md diff --git a/published/20210907 Run Web Applications in Linux Using Tangram Browser.md b/published/202109/20210907 Run Web Applications in Linux Using Tangram Browser.md similarity index 100% rename from published/20210907 Run Web Applications in Linux Using Tangram Browser.md rename to published/202109/20210907 Run Web Applications in Linux Using Tangram Browser.md diff --git a/published/20210907 Use lspci on Linux to see your hardware.md b/published/202109/20210907 Use lspci on Linux to see your hardware.md similarity index 100% rename from published/20210907 Use lspci on Linux to see your hardware.md rename to published/202109/20210907 Use lspci on Linux to see your hardware.md diff --git a/published/20210908 Apps for daily needs part 5- video editors.md b/published/202109/20210908 Apps for daily needs part 5- video editors.md similarity index 100% rename from published/20210908 Apps for daily needs part 5- video editors.md rename to published/202109/20210908 Apps for daily needs part 5- video editors.md diff --git a/published/20210908 Debug a web page error from the command line.md b/published/202109/20210908 Debug a web page error from the command line.md similarity index 100% rename from published/20210908 Debug a web page error from the command line.md rename to published/202109/20210908 Debug a web page error from the command line.md diff --git a/published/20210908 How to Run Java Programs in Ubuntu.md b/published/202109/20210908 How to Run Java Programs in Ubuntu.md similarity index 100% rename from published/20210908 How to Run Java Programs in Ubuntu.md rename to published/202109/20210908 How to Run Java Programs in Ubuntu.md diff --git a/published/20210908 How to Use the dd Command to Create a Live USB Drive in Linux Terminal -For Experts and Adventurers.md b/published/202109/20210908 How to Use the dd Command to Create a Live USB Drive in Linux Terminal -For Experts and Adventurers.md similarity index 100% rename from published/20210908 How to Use the dd Command to Create a Live USB Drive in Linux Terminal -For Experts and Adventurers.md rename to published/202109/20210908 How to Use the dd Command to Create a Live USB Drive in Linux Terminal -For Experts and Adventurers.md diff --git a/published/20210909 Adobe Kills Brackets Code Editor - Suggests Using Visual Studio Code.md b/published/202109/20210909 Adobe Kills Brackets Code Editor - Suggests Using Visual Studio Code.md similarity index 100% rename from published/20210909 Adobe Kills Brackets Code Editor - Suggests Using Visual Studio Code.md rename to published/202109/20210909 Adobe Kills Brackets Code Editor - Suggests Using Visual Studio Code.md diff --git a/published/20210910 Building an open source community health analytics platform.md b/published/202109/20210910 Building an open source community health analytics platform.md similarity index 100% rename from published/20210910 Building an open source community health analytics platform.md rename to published/202109/20210910 Building an open source community health analytics platform.md diff --git a/published/20210910 Quadratic algorithms are slow (and hashmaps are fast).md b/published/202109/20210910 Quadratic algorithms are slow (and hashmaps are fast).md similarity index 100% rename from published/20210910 Quadratic algorithms are slow (and hashmaps are fast).md rename to published/202109/20210910 Quadratic algorithms are slow (and hashmaps are fast).md diff --git a/published/20210911 Here-s Why Firefox is Seeing a Continuous Decline for Last 12 Years.md b/published/202109/20210911 Here-s Why Firefox is Seeing a Continuous Decline for Last 12 Years.md similarity index 100% rename from published/20210911 Here-s Why Firefox is Seeing a Continuous Decline for Last 12 Years.md rename to published/202109/20210911 Here-s Why Firefox is Seeing a Continuous Decline for Last 12 Years.md diff --git a/published/20210913 Replace smart quotes with the Linux sed command.md b/published/202109/20210913 Replace smart quotes with the Linux sed command.md similarity index 100% rename from published/20210913 Replace smart quotes with the Linux sed command.md rename to published/202109/20210913 Replace smart quotes with the Linux sed command.md diff --git a/published/20210915 How to check for update info and changelogs with rpm-ostree db.md b/published/202109/20210915 How to check for update info and changelogs with rpm-ostree db.md similarity index 100% rename from published/20210915 How to check for update info and changelogs with rpm-ostree db.md rename to published/202109/20210915 How to check for update info and changelogs with rpm-ostree db.md diff --git a/published/20210915 Raspberry Pi Zero vs Zero W- What-s the Difference.md b/published/202109/20210915 Raspberry Pi Zero vs Zero W- What-s the Difference.md similarity index 100% rename from published/20210915 Raspberry Pi Zero vs Zero W- What-s the Difference.md rename to published/202109/20210915 Raspberry Pi Zero vs Zero W- What-s the Difference.md diff --git a/published/20210915 Screen Recording in Linux With OBS and Wayland.md b/published/202109/20210915 Screen Recording in Linux With OBS and Wayland.md similarity index 100% rename from published/20210915 Screen Recording in Linux With OBS and Wayland.md rename to published/202109/20210915 Screen Recording in Linux With OBS and Wayland.md diff --git a/published/20210916 Kali Linux 2021.3 Brings in Kali Live VM Support, New Tools, and Other Improvements.md b/published/202109/20210916 Kali Linux 2021.3 Brings in Kali Live VM Support, New Tools, and Other Improvements.md similarity index 100% rename from published/20210916 Kali Linux 2021.3 Brings in Kali Live VM Support, New Tools, and Other Improvements.md rename to published/202109/20210916 Kali Linux 2021.3 Brings in Kali Live VM Support, New Tools, and Other Improvements.md diff --git a/published/20210916 Watch commands and tasks with the Linux watch command.md b/published/202109/20210916 Watch commands and tasks with the Linux watch command.md similarity index 100% rename from published/20210916 Watch commands and tasks with the Linux watch command.md rename to published/202109/20210916 Watch commands and tasks with the Linux watch command.md diff --git a/published/20210917 How to Install Kali Linux in VMware.md b/published/202109/20210917 How to Install Kali Linux in VMware.md similarity index 100% rename from published/20210917 How to Install Kali Linux in VMware.md rename to published/202109/20210917 How to Install Kali Linux in VMware.md diff --git a/published/20210917 Start using YAML now.md b/published/202109/20210917 Start using YAML now.md similarity index 100% rename from published/20210917 Start using YAML now.md rename to published/202109/20210917 Start using YAML now.md diff --git a/published/20210918 How to Install Ubuntu Desktop on Raspberry Pi 4.md b/published/202109/20210918 How to Install Ubuntu Desktop on Raspberry Pi 4.md similarity index 100% rename from published/20210918 How to Install Ubuntu Desktop on Raspberry Pi 4.md rename to published/202109/20210918 How to Install Ubuntu Desktop on Raspberry Pi 4.md diff --git a/published/202109/20210920 Use Vagrant to test your scripts on different operating systems.md b/published/202109/20210920 Use Vagrant to test your scripts on different operating systems.md new file mode 100644 index 0000000000..b105bb5413 --- /dev/null +++ b/published/202109/20210920 Use Vagrant to test your scripts on different operating systems.md @@ -0,0 +1,135 @@ +[#]: subject: "Use Vagrant to test your scripts on different operating systems" +[#]: via: "https://opensource.com/article/21/9/test-vagrant" +[#]: author: "Ayush Sharma https://opensource.com/users/ayushsharma" +[#]: collector: "lujun9972" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13829-1.html" + +使用 Vagrant 在不同的操作系统上测试你的脚本 +====== + +> Vagrant 可以帮助你在你的电脑上运行其他操作系统,这意味着你可以构建、测试、疯狂折腾而不毁坏你的系统。 + +![](https://img.linux.net.cn/data/attachment/album/202109/28/115827gv75kkrhnnhvkhcf.jpg) + +我使用 Vagrant 已经很长时间了。我使用几种 DevOps 工具,把它们全安装在一个系统上会搞得很乱。Vagrant 可以让你在不破坏系统的情况下随意折腾,因为你根本不需要在生产系统上做实验。 + +如果你熟悉 [VirtualBox][2] 或 [GNOME Boxes][3],那么学习 Vagrant 很容易。Vagrant 有一个简单而干净的界面用于管理虚拟机。一个名为 `Vagrantfile` 的配置文件,允许你定制你的虚拟机(称为 “Vagrant 盒子box”)。一个简单的命令行界面让你启动、停止、暂停或销毁你的“盒子”。 + +考虑一下这个简单的例子。 + +假设你想写 Ansible 或 shell 脚本,在一个新的服务器上安装 Nginx。你不能在你自己的系统上这样做,因为你运行的可能不是你想测试的操作系统,或者没有所有的依赖项。启动新的云服务器进行测试可能会很费时和昂贵。这就是 Vagrant 派上用处的地方。你可以用它来启动一个虚拟机,用你的脚本来配备provision它,并证明一切按预期工作。然后,你可以删除这个“盒子”,重新配备它,并重新运行你的脚本来验证它。你可以多次重复这个过程,直到你确信你的脚本在所有条件下都能工作。你可以将你的 Vagrantfile 提交给 Git,以确保你的团队正在测试完全相同的环境(因为他们将使用完全相同的测试机)。不会再有“但它在我的机器上运行良好!”这事了。 + +### 开始使用 + +首先,[在你的系统上安装 Vagrant][4],然后创建一个新的文件夹进行实验。在这个新文件夹中,创建一个名为 `Vagrantfile` 的新文件,内容如下: + +``` +Vagrant.configure("2") do |config| + + config.vm.box = "ubuntu/hirsute64" + +end +``` + +你也可以运行 `vagrant init ubuntu/hirsute64`,它将为你生成一个新的 Vagrant 文件。现在运行 `vagrant up`。这个命令将从 Vagrant 仓库中下载 `ubuntu/hirsuite64` 镜像。 + +``` +Bringing machine 'default' up with 'virtualbox' provider... +==> default: Importing base box 'ubuntu/hirsute64'... +==> default: Matching MAC address for NAT networking... +==> default: Checking if box 'ubuntu/hirsute64' version '20210820.0.0' is up to date... +==> default: Setting the name of the VM: a_default_1630204214778_76885 +==> default: Clearing any previously set network interfaces... +==> default: Preparing network interfaces based on configuration... + default: Adapter 1: nat + default: Adapter 2: hostonly +==> default: Forwarding ports... + default: 22 (guest) => 2222 (host) (adapter 1) +==> default: Running 'pre-boot' VM customizations... +==> default: Booting VM... +==> default: Waiting for machine to boot. This may take a few minutes... + default: SSH address: 127.0.0.1:2222 + default: SSH username: vagrant + default: SSH auth method: private key + default: Warning: Remote connection disconnect. Retrying... + default: Warning: Connection reset. Retrying... + default: + default: Vagrant insecure key detected. Vagrant will automatically replace + default: this with a newly generated keypair for better security. + default: + default: Inserting generated public key within guest... + default: Removing insecure key from the guest if it's present... + default: Key inserted! Disconnecting and reconnecting using new SSH key... +==> default: Machine booted and ready! +``` + +此时,如果你打开你的 Vagrant 后端(如 VirtualBox 或 virt-manager),你会看到你的“盒子”已经有了。接下来,运行 `vagrant ssh` 登录到“盒子”。如果你能看到 Vagrant 的提示符,那么你就进入了! + +``` +~ vagrant ssh +Welcome to Ubuntu 21.04 (GNU/Linux 5.11.0-31-generic x86_64) + +* Documentation: +* Management: +* Support: + + System information as of Sun Aug 29 02:33:51 UTC 2021 + + System load: 0.01 Processes: 110 + Usage of /: 4.1% of 38.71GB Users logged in: 0 + Memory usage: 17% IPv4 address for enp0s3: 10.0.2.15 + Swap usage: 0% IPv4 address for enp0s8: 192.168.1.20 + +0 updates can be applied immediately. + +vagrant@ubuntu-hirsute:~$ +``` + +Vagrant 使用“基础盒子”来建立你的本地机器。在我们的例子中,Vagrant 从 [Hashicorp 的 Vagrant 目录][5]下载 `ubuntu/hirsuite64` 镜像,并插入 VirtualBox 来创建实际的“盒子”。 + +### 共享文件夹 + +Vagrant 将你的当前文件夹映射到 Vagrant “盒子”中的 `/vagrant`。这允许你在你的系统和“盒子”里保持文件同步。这很适合测试 Nginx 网站,通过将你的文件根目录指向 `/vagrant`。你可以使用 IDE 进行修改,“盒子”里的 Nginx 会提供这些修改。 + +### Vagrant 命令 + +有几个 Vagrant 命令,你可以用它们来控制你的“盒子”。 + +其中一些重要的命令是: + + * `vagrant up`:启动一个“盒子”。 + * `vagrant status`:显示当前“盒子”的状态。 + * `vagrant suspend`:暂停当前的“盒子”。 + * `vagrant resume`:恢复当前的“盒子”。 + * `vagrant halt`:关闭当前的“盒子”。 + * `vagrant destroy`:销毁当前的“盒子”。通过运行此命令,你将失去存储在“盒子”上的任何数据。 + * `vagrant snapshot`:对当前的“盒子”进行快照。 + +### 试试 Vagrant + +Vagrant 是一个使用 DevOps 原则进行虚拟机管理的工具,久经时间考验。配置你的测试机,与你的团队分享配置,并在一个可预测和可重复的环境中测试你的项目。如果你正在开发软件,那么通过使用 Vagrant 进行测试,你将为你的用户提供良好的服务。如果你不开发软件,但你喜欢尝试新版本的操作系统,那么没有比这更简单的方法了。今天就试试 Vagrant 吧! + +这篇文章最初发表在 [作者的个人博客][6] 上,经许可后被改编。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/9/test-vagrant + +作者:[Ayush Sharma][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/ayushsharma +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-concentration-focus-windows-office.png?itok=-8E2ihcF (Woman using laptop concentrating) +[2]: https://opensource.com/article/21/6/try-linux-virtualbox +[3]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization +[4]: https://www.vagrantup.com/docs/installation +[5]: https://app.vagrantup.com/boxes/search +[6]: https://notes.ayushsharma.in/2021/08/introduction-to-vagrant diff --git a/published/20210920 Use this Linux command-line tool to learn more about your NVMe drives.md b/published/202109/20210920 Use this Linux command-line tool to learn more about your NVMe drives.md similarity index 100% rename from published/20210920 Use this Linux command-line tool to learn more about your NVMe drives.md rename to published/202109/20210920 Use this Linux command-line tool to learn more about your NVMe drives.md diff --git a/published/20210921 Run containers on your Mac with Lima.md b/published/202109/20210921 Run containers on your Mac with Lima.md similarity index 100% rename from published/20210921 Run containers on your Mac with Lima.md rename to published/202109/20210921 Run containers on your Mac with Lima.md diff --git a/published/20210923 GNOME 41 Released- The Most Popular Linux Desktop Environment Gets Better.md b/published/202109/20210923 GNOME 41 Released- The Most Popular Linux Desktop Environment Gets Better.md similarity index 100% rename from published/20210923 GNOME 41 Released- The Most Popular Linux Desktop Environment Gets Better.md rename to published/202109/20210923 GNOME 41 Released- The Most Popular Linux Desktop Environment Gets Better.md diff --git a/published/202109/20210924 An open source alternative to Microsoft Exchange.md b/published/202109/20210924 An open source alternative to Microsoft Exchange.md new file mode 100644 index 0000000000..31cd9853e0 --- /dev/null +++ b/published/202109/20210924 An open source alternative to Microsoft Exchange.md @@ -0,0 +1,81 @@ +[#]: subject: "An open source alternative to Microsoft Exchange" +[#]: via: "https://opensource.com/article/21/9/open-source-groupware-grommunio" +[#]: author: "Markus Feilner https://opensource.com/users/mfeilner" +[#]: collector: "lujun9972" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13833-1.html" + +微软 Exchange 的一个开源替代方案 +====== + +> 开源用户现在有了一个强大的、功能齐全的群件选择。 + +![](https://img.linux.net.cn/data/attachment/album/202109/29/141404pesw8xgh8oohwhjh.jpg) + +多年来,微软 Exchange 作为一个平台牢牢统治着群件环境。然而,在 2020 年末,一个奥地利的开源软件开发商推出了 [grommunio][2],这是一个群件服务器和客户端,其外观和感觉让 Exchange 和 Outlook 用户感到很熟悉。 + +grmmunio 项目可以很好地替代 Exchange。开发者以与微软相同的方式将组件连接到平台上,它们支持 RPC (远程过程调用)与 HTTP 协议。据开发者介绍,grommunio 还包括许多常见的群件接口,如 IMAP、POP3、SMTP、EAS(Exchange ActiveSync)、EWS(Exchange Web Services)、CalDAV 和 CardDAV。有了这样广泛的支持,grommunio 可以顺利地整合到现有的基础设施中。 + +用户会注意到对 Outlook、Android 和 iOS 客户端来说几乎没有区别。当然,作为开源软件,它也支持其他客户端。由于集成了原生的 Exchange 协议,Outlook 和智能手机与 grommunio 的通信就像与微软 Exchange 服务器一样。日常的企业用户可以继续使用他们现有的客户端,而 grommunio 服务器则在后台安静地运行。 + +### 不仅仅是邮件 + +除了邮件功能外,grommunio 界面还提供了日历系统。可以直接在日历显示中或在一个新标签中点击创建约会。这很直观,正如你对现代工具的期望。用户可以创建、管理和分享日历以及地址簿。私人联系人或普通联系人都支持,而且你可以与同事分享一切。 + +任务管理在左边的下拉菜单中显示任务列表,它们可以有一个所有者和多个合作者。你可以为每个任务指定截止日期、类别、附件和其他属性。笔记可以以同样的方式被管理并与其他团队成员共享。 + +### 聊天、视频会议和文件同步 + +除了现代群件的所有标准功能外,grommunio 还提供聊天、视频会议和文件同步功能。它为企业实现了大规模的全面整合,具有极高的性能。对于开源的推动者来说,这是一个简单的选择,对于系统管理员来说,这是一个强大的选择。因为 grommunio 的目标是整合而不是重新发明,所以所有的组件都是标准的开源工具。 + +![Screenshot of grommunio meeting space][3] + +*用于高级视频会议的 Jitsi 集成(Markus Feilner, [CC BY-SA 4.0][4])* + +在 grommunio 会议功能的背后是 [Jitsi][5],它以熟悉的用户界面顺利地集成到 grommunio 的用户界面中。完全集成和集中管理的聊天功能是基于 [Mattermost][6]。 + +![Screenshot of grommunio's town square for chat][7] + +*用于聊天的 Mattermost(Markus Feilner,[CC BY-SA 4.0][4])* + +[ownCloud][8] 承诺提供企业级的文件共享和同步,在点击“文件”按钮后开始。 + +![Screenshot of grommunio file sharing space][9] + +*用于文件同步和交换的 ownCloud(Markus Feilner,[CC BY-SA 4.0][4])* + +grommunio 项目有一个强大的管理界面,包括角色、域和组织管理、预测性监测和自助服务门户。基于 shell 的向导指导管理员完成安装和从微软 Exchange 迁移数据。开发团队正在不断努力,以实现更好的整合和更集中的管理,并随之为管理员提供更好的工作流程。 + +![Screenshot of grommunio dashboards][10] + +*grommunio 的管理界面(Markus Feilner, [CC BY-SA 4.0][4])* + +### 探索 grommunio + +grommunio 项目的目标很高,但它的开发者已经付出了努力,这一点很明显。一家专门从事税务咨询的德国托管服务机构最近宣布,他们的客户可以使用 grommunio,这是一个德国数据保护法特别严厉的行业。grommunio 项目做得很好:将现有的、成功的概念干净地结合在一起,实现了开放、安全和符合隐私的通信。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/9/open-source-groupware-grommunio + +作者:[Markus Feilner][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/mfeilner +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/team_dev_email_chat_video_work_wfm_desk_520.png?itok=6YtME4Hj (Working on a team, busy worklife) +[2]: https://grommunio.com/en/ +[3]: https://opensource.com/sites/default/files/uploads/jitsi_0.png (grommunio meeting space) +[4]: https://creativecommons.org/licenses/by-sa/4.0/ +[5]: https://opensource.com/article/20/5/open-source-video-conferencing +[6]: https://opensource.com/education/16/3/mattermost-open-source-chat +[7]: https://opensource.com/sites/default/files/uploads/mattermost.png (grommunio's town square for chat) +[8]: https://owncloud.com/ +[9]: https://opensource.com/sites/default/files/uploads/owncloud_0.png (Owncloud for file synchronization and exchange) +[10]: https://opensource.com/sites/default/files/uploads/grommunio_interface_0.png (Screenshot of grommunio dashboards) diff --git a/published/20210924 Linux Gamers Can Finally Play Games like Apex Legends, Fortnite, Thanks to Easy Anti-Cheat Support.md b/published/202109/20210924 Linux Gamers Can Finally Play Games like Apex Legends, Fortnite, Thanks to Easy Anti-Cheat Support.md similarity index 100% rename from published/20210924 Linux Gamers Can Finally Play Games like Apex Legends, Fortnite, Thanks to Easy Anti-Cheat Support.md rename to published/202109/20210924 Linux Gamers Can Finally Play Games like Apex Legends, Fortnite, Thanks to Easy Anti-Cheat Support.md diff --git a/published/202109/20210927 5 open source alternatives to Zoom.md b/published/202109/20210927 5 open source alternatives to Zoom.md new file mode 100644 index 0000000000..64e4bd65c2 --- /dev/null +++ b/published/202109/20210927 5 open source alternatives to Zoom.md @@ -0,0 +1,73 @@ +[#]: subject: "5 open source alternatives to Zoom" +[#]: via: "https://opensource.com/article/21/9/alternatives-zoom" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lujun9972" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13836-1.html" + +5 个替代 Zoom 的开源软件 +====== + +> 试试这些开源视频会议服务之一。 + +![](https://img.linux.net.cn/data/attachment/album/202109/30/114413ylalu7dcl5au575v.jpg) + +我最近参加了 [实用开源信息(POSI)][2] 会议,它是在一个自由开源的视频会议平台上举行的。当我参加了一系列关于开源软件的实际用途的精彩讲座时,我意识到视频会议在过去几年里已经变得非常普遍。 + +如果说开源做了什么,那就是提供了选择,现在越来越多的工人有了远程工作的自由,在你的连接方式上有一个选择是非常有意义的。 + +有时,你需要一个全功能的视频会议应用,其中包括审核、演示模式和分组讨论室,而其他时候,你想做的只是给朋友打一个快速电话,以便看到对方的脸。 + +### Jitsi + +[Jitsi][3] 是一个简单、随意、但强大的视频通话平台。你可以自己托管它,也可以在 [meet.jit.si][4] 的公共实例上使用它。它有可定制的 URL,可以很容易地与你想见面的朋友分享链接、通话中的聊天、管理控制,和通话录音。它的开发非常活跃,每年都会测试和发布一大批新功能。它是 Opensource.com 用于我们每周会议的平台。 + +### Signal + +[Signal][5] 已经是一个流行的以安全为重点的聊天应用,最近它又增加了 [团体视频通话][6] 的功能。视频通话非常适合简单的会议,而且因为你只能与你的 Signal 联系人列表中的其他人见面,所以不用担心你的视频通话会议上有不速之客。当你尝试定位你应该参与开会的虚拟房间时,也没有来回的“电话标签”。这一切都发生在 Signal 中,因此无需猜测。 + +Signal 本身是非常直观的,视频功能非常适合其现有惯例。简而言之,只要你的联系人在使用 Signal,这就是一个不费力的视频通话平台。这是我用于个人联系的应用,我经常使用其视频通话功能与朋友和家人联系。 + +### P2p.chat + +[P2p.chat][7] 是这些中最简单的一个,无论是设计还是实现。通过 WebRTC 工作,p2p.chat 是一个 Web 应用,允许你直接连接到你正在呼叫的人,而不需要托管服务器。p2p.chat 的界面并不多,但这也是其吸引力的另一部分。没有管理控制或演示模式,因为 p2p.chat 在很大程度上是科幻片中承诺的“视频电话”:与远方的人进行轻松的人对人(或人们对人们)视频通话。 + +你可以使用自定义的 URL 来动态地创建一个会议空间,所以它们相对容易记忆(除了小的随机部分)和输入。我和不在 Signal 上的朋友使用 p2p.chat,它从未让我失望过。 + +### BigBlueButton + +如果你需要严格的管理控制和极端的灵活性,[BigBlueButton][8] 是你正在寻找的解决方案,它专为教室、会议和演讲而设计。有了 BigBlueButton,你可以让所有与会者静音,阻止和踢走一个与会者,创建分组讨论室,创建协作式白板,共享屏幕,进行演讲,以及记录会议。与会者可以“举起手”表示注意,并将他们的状态设定为非语言交流方式。它很容易使用,但它是一个严肃的平台,适用于重点和非常大的群体。我参加过一些使用 BigBlueButton 的技术会议,包括 [实用开源信息(POSI)][2]会议。 + +### Wire + +[Wire][9] 是寻找托管视频聊天和群件客户端的企业客户的绝佳选择。它是 [AGPL][10] 许可,这个开源项目可用于桌面和服务器、安卓和 iOS。它具有视频通话、发信和文件共享的功能,因此,即使是远程会议,基本上也有亲自开会的所有便利。你可以在有限的时间内免费试用 Wire,然后为你的公司购买一份支持合同。另外,你也可以自己托管它。 + +### 开源视频聊天 + +没有理由满足于由你可能不完全信任的公司托管的专有视频通话。今天可用的开源选项对于与你的职业和个人生活中的所有人保持联系是非常好的。下次你想和朋友见面时,不妨试试这些解决方案之一。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/9/alternatives-zoom + +作者:[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/chat_video_conference_talk_team.png?itok=t2_7fEH0 (Two people chatting via a video conference app) +[2]: https://opensource.org/posicfp +[3]: http://jitsi.org +[4]: http://meet.jit.si +[5]: https://signal.org +[6]: https://support.signal.org/hc/en-us/articles/360052977792-Group-Calling-Voice-or-Video-with-Screen-Sharing +[7]: https://p2p.chat/ +[8]: https://bigbluebutton.org/ +[9]: https://wire.com/en/ +[10]: https://opensource.org/licenses/AGPL-3.0 diff --git a/published/202109/20210929 Manage CentOS Stream with Foreman.md b/published/202109/20210929 Manage CentOS Stream with Foreman.md new file mode 100644 index 0000000000..52d66d056a --- /dev/null +++ b/published/202109/20210929 Manage CentOS Stream with Foreman.md @@ -0,0 +1,164 @@ +[#]: subject: "Manage CentOS Stream with Foreman" +[#]: via: "https://opensource.com/article/21/9/centos-stream-foreman" +[#]: author: "Melanie Corr https://opensource.com/users/melanie-corr" +[#]: collector: "lujun9972" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13837-1.html" + +用 Foreman 管理 CentOS Stream +====== + +> 这个例子让我们看到了在 Foreman 中管理和配置 CentOS Stream 内容的许多选项。 + +![](https://img.linux.net.cn/data/attachment/album/202109/30/133541s3e3s31yzmnugl1s.jpg) + +2021 年 12 月,CentOS 8 将达到生命终点,被 CentOS Stream 取代。CentOS Stream 和 CentOS 之前的迭代之间的主要变化之一是没有小版本。Centos Stream 采用了一个连续的发布周期。从今年年初开始,Foreman 社区的开发者开始看到 CentOS Stream 由于持续发布而提供的更早的错误检测和补丁的好处。我们不再需要等待下一个版本来利用最新的变化和错误修复。[一位资深的 Linux 社区爱好者][2] 指出,此举也使 RHEL 开发者比以往更接近 FOSS 社区。 + +然而,如果你是一个拥有数百或数千台服务器的管理员,你可能想控制新的软件包何时被添加到特定的服务器。如果你正在寻找一个免费的开源工具,帮助你确保生产服务器的稳定性,同时允许你安全地从 Centos Stream 中拉入最新的变化用于开发和测试,这就是 Foreman 可以帮助你的地方。有了 Foreman,你可以在生命周期环境的各个阶段管理你的 Centos Stream 内容。 + +### Foreman 介绍 + +Foreman 是一个完整的物理和虚拟服务器的生命周期管理工具。有了 Foreman,系统管理员有能力轻松实现重复性任务的自动化,快速部署应用程序,并主动管理内部或云中的服务器。Foreman 为配备provisioning管理、配置管理和监控提供了企业级解决方案。由于其插件架构,Foreman 可以以无数种方式进行扩展。使用 Katello 插件,你可以把 Foreman 作为一个完整的内容管理content management工具来管理 CentOS Stream,以及其他许多内容类型。 + +通过 Foreman 和 Katello,你可以准确地定义你希望每个环境包含哪些软件包。例如,生产环境可能使用已被验证为稳定的软件包,而开发环境可能需要最新、最先进的软件包版本。你还可以跨生命周期环境推广内容视图content view。让我们来看看 Foreman 是如何完成这个任务的。 + +我们在这篇文章中使用了网页用户界面,但 Foreman 也有一个强大的 CLI 和 API。Katello 插件为 Pulp 项目提供了一个工作流和网页用户界面,你可以在 [这篇文章][3] 中了解更多。我们在这里也提供了一个简单的工作流程,但是 Foreman 和 Katello 项目提供了许多不同的配置选项来满足你的具体需求。 + +本文假设 Foreman 和 Katello 已经安装完毕。关于如何安装的更多信息,请参阅 [Katello 安装手册][4]。 + +### 创建一个产品 + +第一步是在 Foreman 中创建一个产品product。该产品的功能是作为一个内部标签来存储 CentOS Stream 存储库。 + + 1. 在 Foreman 网页用户界面,导航到“内容Content > 产品Products”,并点击“创建产品Create Product”。 + 2. 在“名称Name”字段中,为产品输入一个名称。Foreman会根据你输入的“名称Name”自动完成“标签Label”字段,以后不能再更改。 + +### 将 CentOS Stream 存储库添加到产品中 + +现在你有了一个产品,你可以使用 AppStream 和 BaseOS 存储库的 URL,并将它们添加到你的新产品中。 + + 1. 在 Foreman 网页用户界面中,导航到 “内容Content > 产品Products”,选择你要使用的产品,然后点击 “新存储库New Repository”。 + 2. 在“名称Name”字段中,为存储库输入一个名称;例如,“Centos8StreamBaseOS”。Foreman 会根据你输入的“名称Name”,自动完成“标签Label”字段。 + 3. 从“类型Type”列表中,选择存储库的类型,然后选择“Yum”。 + 4. 在 “URL” 字段中,输入 CentOS Stream Baseos 存储库的 URL,作为源: `http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/`。 + 5. 选择“下载规则Download Policy”列表。默认的是“按需On Demand”,这意味着 Katello 将只下载元数据。如果你想下载所有的软件包,请改成“即时Immediate”,它可以下载所有的软件包,可能会达到 20-30GB。 + 6. 确保“与镜像同步Mirror on Sync”复选框被选中。这个选项确保在同步过程中,不再是上游存储库的一部分的内容被删除。 + 7. 点击“保存Save”。 + + + +重复这些步骤,添加 AppStream 存储库及其 URL,例如,`http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/`。确保你使用最近的官方 CentOS 镜像来代替它。 + +要执行立即同步,在你的产品窗口,点击“立即同步Sync Now”。最初的同步可能需要一些时间。你可以从“内容Content > 同步状态Sync Status”查看同步状态。 + +同步完成后,你可以在“主机 Hosts > 操作系统Operating System”中查看新的 CentOS Stream 操作系统。请随意编辑名称和描述以满足你的要求。 + +如果你打算使用 Ansible 或 Puppet 等配置管理软件,Foreman 会自动创建一个操作系统报告。你可以在“管理Administe > 设置Settings > 忽略操作系统状况Ignore facts for operating system”中关闭这个选项。重命名操作系统以匹配配置管理软件中的名称是一个好主意。例如,对于 Puppet,这将是“CentOS 8”。 + +### 定义你的基础设施的生命周期环境 + +应用程序生命周期是 Foreman 的内容管理功能的一个核心概念。应用程序的生命周期定义了一个特定的系统和它的软件在特定阶段的状况。例如,一个应用程序的生命周期可能很简单,你可能只有一个“开发”阶段和“生产”阶段。Foreman 提供了一些方法来以可控的方式定制每个应用生命周期阶段,以适应你的规范。 + +在这一点上,你必须创建你的生命周期环境路径。 + + 1. 在 Foreman 网页用户界面中,导航到“内容Content > 生命周期环境Lifecycle Environments”。 + 2. 点击“新环境路径New Environment Path”,开始一个新的应用生命周期。 + 3. 在“名称Name”字段中,为你的环境输入一个名称。 + 4. 在“描述Description”字段中,为你的环境输入一个描述。 + 5. 点击“保存Save”。 + 6. 根据你的需要添加尽可能多的环境路径。例如,你可以创建“dev”、“test”、“stage” 和 “production” 环境。要添加这些环境,点击“添加新环境”,完成“名称Name”和“描述Description”字段,并从“优先环境Prior Environment*”列表中选择先前的环境,这样你就可以按照你预期使用的顺序将它们串联起来。 + + + +### 创建和发布一个内容视图 + +在 Foreman 中,“内容视图Content View”是你的存储库在某个特定时间点的快照。内容视图提供了隔离软件包版本到你想保留的状态的机制。内容视图有很多可配置的功能,你可以用它来进一步细化。为了本教程的目的,让我们保持简单。 + + 1. 在 Foreman 网页用户界面中,导航到“内容Content > 内容视图Content View”,并点击“创建新视图Create New View”。 + 2. 在“名称Name”字段中,为视图输入一个名称。Foreman 会根据你输入的名称自动完成“标签Label”字段。 + 3. 在“描述Description”字段中,输入视图的描述。 + 4. 单击“保存Save”以创建内容视图。 + 5. 在新的内容视图中,点击“Yum 内容Yum Contents > 添加存储库Add Repositories”,在“存储库选择Repository Selection”区域,点击“添加Add”。对于 BaseOS 和 Appstream 存储库,选择你想包括的软件包,然后点击“添加存储库Add Repositories”。 + 6. 点击“发布新版本Publish New Version”,在“描述Description”区域,输入关于版本的信息以记录变化。 + 7. 单击“保存Save”。 + +当你点击“发布新版本Publish New Version”时,你创建了一个你已同步的所有内容的快照。这意味着你订阅此内容视图的每台服务器将只能访问与此生命周期环境相关的内容视图中的软件包版本。 + +每一个新的内容视图和后续版本都会首先发布到库环境,然后你可以在那里推广到其他环境。 + +### 跨生命周期环境推广内容 + +如果你已经测试了新的软件包,并且确信一切都很稳定,你可以把你的内容视图推广到另一个生命周期环境中。 + + 1. 导航到“内容Content > 内容视图Content Views”,选择你想推广的内容视图。 + 2. 点击内容视图的“版本Versions”标签。 + 3. 选择你想推广的版本,并在“操作Action”栏中,点击“推广Promote”。 + 4. 选择你要推广内容视图的环境,并点击“推广版本Promote Version”。 + 5. 再次点击“推广Promote”按钮。这次选择生命周期环境,例如,“Test”,然后单击“推广版本Promote Version”。 + 6. 最后,再次点击“推广Promote”按钮。例如,选择“Production”环境并点击“推广版本Promote Version”。 + +被分配到该特定环境的服务器现在可以从一套更新的软件包中提取。 + +### 创建一个激活密钥 + +为了将 CentOS Stream 服务器注册到你在特定生命周期中定义的内容,你必须创建一个激活密钥。激活密钥是一种与服务器共享凭证的安全方法。这使用了一个叫做“订阅管理器subscription-manager的工具来订阅 CentOS Stream 服务器的内容。 + +当你创建了激活密钥后,将 CentOS Stream 订阅添加到激活密钥中。 + + 1. 在 Foreman 网页用户界面中,导航到“内容Content > 激活密钥Activation keys”,并点击“创建激活密钥Create Activation Key”。 + 2. 在“名称Name”栏中,输入激活密钥的名称。 + 3. 在“描述Description”栏中,输入激活密钥的描述。 + 4. 从“环境Environment”列表中,选择要使用的环境。 + 5. 从“内容视图Content View”列表中,选择你刚才创建的内容视图。 + 6. 点击“保存Save”。 + +###从 Foreman 管理的内容中创建一个 CentOS Stream 主机 + +现在一切都准备好了。随着你创建的内容包含在内容视图中,并在整个生命周期中推广,你现在可以准确地用你想使用的内容来配置主机,并订阅你想让它们接收的更新。 + +要在 Foreman 中创建一个主机,请导航到“主机 > 创建主机”。 + + 1. 在“名称Name”字段中,为主机输入一个名称。 + 2. 单击“组织Organization”和“位置Location”选项卡,以确保配置环境自动设置为当前环境。 + 3. 从“部署在Deploy On”列表中,选择“裸金属Bare Metal”。 + 4. 单击“操作系统Operating System”选项卡。 + 5. 从“架构Architectures”列表中,选择“x86_64”。 + 6. 从“操作系统Operating System”列表中,选择“CentOS_Stream 8”。 + 7. 勾选“构建模式Build Mode”框。 + 8. 对于“媒体选择Media Selection”,选择“同步的内容Synced Content”来使用你之前同步的 CentOS Stream 内容。 + 9. 从“同步的内容Synced Content”列表中,确保选择 “CentOS Stream”。 + 10. 从“分区表Partition Table”列表中,对于这个演示,选择默认的 “Kickstart”,但有许多可用的选项。 + 11. 在“Root 密码Root Password”栏中,为你的新主机输入一个 root 密码。 + 12. 点击“接口Interface”标签,并点击“编辑Edit”,并添加一个 “Mac 地址Mac address”。 + 13. 点击“参数Parameters”标签,并确保存在一个提供激活密钥的参数。如果没有,添加一个激活密钥。 + 14. 点击“提交Submit”以保存主机条目。 + + + +现在,新的主机处于构建模式,这意味着当你打开它时,它将开始安装操作系统。 + +如果你导航到“主机Hosts > 内容主机Content Hosts”,你可以看到你的主机所订阅的订阅、生命周期环境和内容视图的全部细节。 + +这个例子只是对你在 Foreman 中管理和配置 CentOS Stream 内容的众多选项的一个小窥视。如果你想了解更多关于如何管理 CentOS Stream 版本,控制你的服务器可以访问的内容,以及控制和保护你的基础设施的稳定性的详细信息,请查看 [Foreman 内容管理][5] 文档。当所有 CentOS Stream 内容在你的控制之下时,你可以创建和注册 Centos Stream,只使用你指定的内容。有关配备的更多详细信息,请参见 [Foreman 配备][6] 文档。如果你有任何问题、反馈或建议,你可以在 找到 Foreman 社区。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/9/centos-stream-foreman + +作者:[Melanie Corr][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/melanie-corr +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/puzzle_computer_solve_fix_tool.png?itok=U0pH1uwj (Puzzle pieces coming together to form a computer screen) +[2]: https://twitter.com/Det_Conan_Kudo/status/1337366036023218177?s=20 +[3]: https://opensource.com/article/20/8/manage-repositories-pulp +[4]: https://docs.theforeman.org/3.0/Installing_Server_on_Red_Hat/index-katello.html +[5]: https://docs.theforeman.org/master/Content_Management_Guide/index-foreman.html +[6]: https://docs.theforeman.org/master/Provisioning_Guide/index-foreman.html diff --git a/published/20210907 How to use BusyBox on Linux.md b/published/20210907 How to use BusyBox on Linux.md new file mode 100644 index 0000000000..3b2744163a --- /dev/null +++ b/published/20210907 How to use BusyBox on Linux.md @@ -0,0 +1,181 @@ +[#]: subject: "How to use BusyBox on Linux" +[#]: via: "https://opensource.com/article/21/8/what-busybox" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lujun9972" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13840-1.html" + +如何在 Linux 上使用 BusyBox +====== + +> BusyBox 是一个开源(GPL)项目,提供了近 400 个常用命令的简单实现。 + +![](https://img.linux.net.cn/data/attachment/album/202110/01/185208x6ckkmvi0silk3vk.jpg) + +我们很容易认为 Linux 的命令是理所当然的。当你安装 Linux 时,它们与系统捆绑在一起,而我们常常不问为什么它们会在那里。一些基本的命令,如 [cd][2]、[kill][3] 和 echo,并不总是独立的应用程序,而是实际上内置于你的 shell 中。其他如 [ls][4]、[mv][5] 和 [cat][6] 是核心工具包(通常是 GNU `coreutils`)的一部分。但在开源的世界里,总是有一些替代品,其中最有趣的是 [BusyBox][7]。 + +### Linux 中的 BusyBox 简介 + +BusyBox 是一个开源(GPL)项目,提供近 400 个常用命令的简单实现,包括 `ls`、`mv`、`ln`、`mkdir`、`more`、`ps`、`gzip`、`bzip2`、`tar` 和 `grep`。它还包含了编程语言 `awk`、流编辑器 `sed`、文件系统检查工具 `fsck`、`rpm` 和 `dpkg` 软件包管理器,当然还有一个可以方便的访问所有这些命令的 shell(`sh`)。简而言之,它包含了所有 POSIX 系统需要的基本命令,以执行常见的系统维护任务以及许多用户和管理任务。 + +事实上,它甚至包含一个 `init` 命令,可以作为 PID 1 启动,以作为所有其它系统服务的父进程。换句话说,BusyBox 可以作为 [systemd][8]、OpenRC、sinit、init 和其他初始化系统的替代品。 + +BusyBox 非常小。作为一个可执行文件,它不到 1MB,所以它在 [嵌入式][9]、[边缘计算][10] 和 [物联网][11] 领域很受欢迎,因为这些场景的存储空间是很宝贵的。在容器和云计算的世界里,它作为精简的 Linux 容器镜像的基础镜像也很受欢迎。 + +### 极简主义 + +BusyBox 的部分魅力在于它的极简主义。它的所有命令都被编译到一个二进制文件里(`busybox`),它的手册只有 81 页(根据我对 `man` 送到 `pr` 管道的计算),但它涵盖了近 400 条命令。 + +作为一个例子的比较,这是 “原版” 的 `useradd —help` 的输出: + +``` + -b, --base-dir BASE_DIR       base directory for home + -c, --comment COMMENT         GECOS field of the new account + -d, --home-dir HOME_DIR       home directory of the new account + -D, --defaults                print or change the default config + -e, --expiredate EXPIRE_DATE  expiration date of the new account + -f, --inactive INACTIVE       password inactivity + -g, --gid GROUP               name or ID of the primary group + -G, --groups GROUPS           list of supplementary groups + -h, --help                    display this help message and exit + -k, --skel SKEL_DIR           alternative skeleton dir + -K, --key KEY=VALUE           override /etc/login.defs + -l, --no-log-init             do not add the user to the lastlog + -m, --create-home             create the user's home directory + -M, --no-create-home          do not create the user's home directory + -N, --no-user-group           do not create a group with the user's name + -o, --non-unique              allow users with non-unique UIDs + -p, --password PASSWORD       encrypted password of the new account + -r, --system                  create a system account + -R, --root CHROOT_DIR         directory to chroot into + -s, --shell SHELL             login shell of the new account + -u, --uid UID                 user ID of the new account + -U, --user-group              create a group with the same name as a user +``` + +而这是是同一命令的 BusyBox 版本: + +``` + -h DIR    Home directory + -g GECOS  GECOS field + -s SHELL  Login shell + -G GRP    Group + -S            Create a system user + -D            Don't assign a password + -H            Don't create home directory + -u UID    User id + -k SKEL   Skeleton directory (/etc/skel) +``` + +这种差异是一种特性还是一种限制,取决于你是喜欢你的命令拥有 20 个选项还是 10 个选项。对于一些用户和某些用例来说,BusyBox 的极简主义刚刚满足所需。对于其他人来说,它是一个很好的最小化环境,可以作为一个后备工具,或者作为安装更强大的工具的基础,比如 [Bash][12]、[Zsh][13]、GNU [Awk][14] 等等。 + +### 安装 BusyBox + +在 Linux 上,你可以使用你的软件包管理器安装 BusyBox。例如,在 Fedora 及类似发行版: + +``` +$ sudo dnf install busybox +``` + +在 Debian 及其衍生版: + +``` +$ sudo apt install busybox +``` + +在 MacOS 上,可以使用 [MacPorts][15] 或 [Homebrew][16]。在 Windows 上,可以使用 [Chocolatey][17]。 + +你可以将 BusyBox 设置为你的 shell,使用 `chsh —shell` 命令,然后再加上 BusyBox `sh` 应用程序的路径。我把 BusyBox 放在 `/lib64` 中,但它的位置取决于你的发行版的安装位置。 + +``` +$ which busybox +/lib64/busybox/busybox +$ chsh --shell /lib64/busybox/sh +``` + +用 BusyBox 全盘替换所有常见的命令要复杂一些,因为大多数发行版都是“硬接线”,会在特定的软件包寻找特定的命令。换句话说,虽然技术上可以用 BusyBox 的 `init` 替换系统的 `init`,但你的软件包管理器可能会拒绝让你删除包含 `init` 的软件包,以免你担心删除会导致系统无法启动。有一些发行版是建立在 BusyBox 之上的,所以从新环境开始可能是体验 BusyBox 系统的最简单方法。 + +### 试试 BusyBox + +你不必为了尝试 BusyBox 而将你的 shell 永久改为 BusyBox。你可以从你当前的 shell 中启动一个 BusyBox shell。 + +``` +$ busybox sh +~ $ +``` + +不过你的系统仍然有安装的非 BusyBox 版本的命令,所以要体验 BusyBox 的工具,你必须把命令作为参数发给 `busybox` 可执行文件: + +``` +~ $ busybox echo $0 +sh +~ $ busybox ls --help +BusyBox vX.YY.Z (2021-08-25 07:31:48 NZST) multi-call binary. + +Usage: ls [-1AaCxdLHRFplinshrSXvctu] [-w WIDTH] [FILE]... + +List directory contents + + -1  One column output + -a  Include entries that start with . + -A  Like -a, but exclude . and .. + -x  List by lines +[...] +``` + +为了获得“完整”的 BusyBox 体验,你可以为每个命令创建一个 `busybox` 的符号链接。这很容易,只要你使用 [for 循环][18] 就行: + +``` +$ mkdir bbx +$ for i in $(bbx --list); do \ + ln -s /path/to/busybox bbx/$i \ +done +``` + +在你的 [路径][19] 的 _开头_ 添加这个符号链接目录,并启动 BusyBox: + +``` +$ PATH=$(pwd)/bbx:$PATH bbx/sh +``` + +### 用起来 + +BusyBox 是一个有趣的项目,也是一个可以实现 _极简_ 计算的例子。无论你是把 BusyBox 作为 [你唤醒的][21] [古老的计算机][20] 的轻量级环境,还是作为 [嵌入式设备][22] 的用户界面,抑或试用一个新的初始化系统,就算是为了好奇,让自己重新认识那些熟悉而又陌生的命令,都会很有意思。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/8/what-busybox + +作者:[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/bash_command_line.png?itok=k4z94W2U (bash logo on green background) +[2]: https://opensource.com/article/21/8/navigate-linux-directories +[3]: https://opensource.com/article/18/5/how-kill-process-stop-program-linux +[4]: https://opensource.com/article/19/7/master-ls-command +[5]: https://opensource.com/article/19/8/moving-files-linux-depth +[6]: https://opensource.com/article/19/2/getting-started-cat-command +[7]: https://www.busybox.net +[8]: https://opensource.com/article/20/4/systemd +[9]: https://opensource.com/article/21/3/rtos-embedded-development +[10]: https://opensource.com/article/17/9/what-edge-computing +[11]: https://opensource.com/article/21/3/iot-measure-raspberry-pi +[12]: https://opensource.com/article/20/4/bash-sysadmins-ebook +[13]: https://opensource.com/article/19/9/getting-started-zsh +[14]: https://opensource.com/article/20/9/awk-ebook +[15]: https://opensource.com/article/20/11/macports +[16]: https://opensource.com/article/20/6/homebrew-mac +[17]: https://opensource.com/article/20/3/chocolatey +[18]: https://opensource.com/article/19/10/programming-bash-loops +[19]: https://opensource.com/article/17/6/set-path-linux +[20]: https://opensource.com/article/20/2/restore-old-computer-linux +[21]: https://opensource.com/article/19/7/how-make-old-computer-useful-again +[22]: https://opensource.com/article/20/6/open-source-rtos diff --git a/published/20210922 Install AnyDesk on Ubuntu Linux -GUI and Terminal Methods.md b/published/20210922 Install AnyDesk on Ubuntu Linux -GUI and Terminal Methods.md new file mode 100644 index 0000000000..2820edd9a1 --- /dev/null +++ b/published/20210922 Install AnyDesk on Ubuntu Linux -GUI and Terminal Methods.md @@ -0,0 +1,151 @@ +[#]: subject: "Install AnyDesk on Ubuntu Linux [GUI and Terminal Methods]" +[#]: via: "https://itsfoss.com/install-anydesk-ubuntu/" +[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" +[#]: collector: "lujun9972" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13839-1.html" + +在 Ubuntu Linux 上安装 AnyDesk +====== + +> 这个初学者的教程讨论了在基于 Ubuntu 的 Linux 发行版上安装 AnyDesk 的 GUI 和终端方法。 + +![](https://img.linux.net.cn/data/attachment/album/202110/01/165758y9aaiix7yu88ayui.jpg) + +[AnyDesk][1] 是一个流行的远程桌面软件,可用于 Linux、Windows、BSD、macOS 和移动平台。 + +有了 AnyDesk,你可以用它远程访问其他电脑,或者让别人远程访问你的系统。不是每个人都可以访问它,因为需要两台设备都使用 AnyDesk。你必须接受传入的连接和/或提供一个安全连接的密码。 + +这对于向朋友、家人、同事甚至客户提供技术支持很有帮助。 + +在本教程中,我将向你展示在 Ubuntu 上安装 AnyDesk 的图形和命令行两种方法。你可以根据自己的喜好使用这两种方法。这两种方法都会在你的 Ubuntu 系统上安装相同的 AnyDesk 版本。 + +同样的方法应该适用于 Debian 和其他基于 Debian 和 Ubuntu 的发行版,如 Linux Mint,Linux Lite 等。 + +> **非 FOSS 警告!** +> +> AnyDesk 不是开源软件。这里涉及它是因为它在 Linux 上可用,而文章的重点是 Linux。 + +### 方法 1:使用终端在 Ubuntu 上安装 AnyDesk + +在你的系统上 [打开终端程序][2]。你需要一个像 `wget` 这样的工具来 [在终端下载文件][3],使用以下命令: + +``` +sudo apt update +sudo apt install wget +``` + +下一步是下载 AnyDesk 仓库的 GPG 密钥,并将其添加到你的系统的可信密钥中。这样,你的系统就会信任来自这个[外部仓库][4]的软件。 + +``` +wget -qO - https://keys.anydesk.com/repos/DEB-GPG-KEY | sudo apt-key add - +``` + +你可以暂时忽略关于 `apt-key` 命令的废弃警告。下一步是将 AnyDesk 仓库添加到系统的仓库源中: + +``` +echo "deb http://deb.anydesk.com/ all main" | sudo tee /etc/apt/sources.list.d/anydesk-stable.list +``` + +更新包缓存,这样你的系统就能通过新添加的仓库了解到新应用的可用性。 + +``` +sudo apt update +``` + +现在,你可以安装 AnyDesk 了: + +``` +sudo apt install anydesk +``` + +完成后,你可以从系统菜单或从终端本身启动 AnyDesk: + +``` +anydesk +``` + +你现在可以享受 AnyDesk 了。 + +![AnyDesk running in Ubuntu][5] + +### 方法 2:在 Ubuntu 上以图形方式安装 AnyDesk + +如果你不习惯使用命令行,不用担心。你也可以不进入终端安装 AnyDesk。 + +你可以从 AnyDesk 官网下载 Ubuntu 上的 AnyDesk: + +- [下载 Linux 上的 Anydesk][6] + +你会看到一个“Download Now”的按钮。点击它。 + +![Download AnyDesk][7] + +当你点击下载按钮时,它会给你提供各种 Linux 发行版的选项。选择 Ubuntu 的那个: + +![Download the appropriate file][8] + +它将下载 AnyDesk 的 DEB 文件。[安装 DEB 文件][9]很简单。要么双击它,要么右击并使用软件安装打开。 + +![Right click on deb file and open with software center][10] + +软件中心应用将被打开,你可以在那里安装它。 + +![Installing AnyDesk in Ubuntu software center][11] + +安装后,在系统菜单中搜索它并从那里开始。 + +![AnyDesk installed in Ubuntu][12] + +这就好了。不是太难,是吗? + +我不打算展示使用 AnyDesk 的步骤。我想你已经对这个问题有了一些了解。如果没有,请参考 [这篇文章][13]。 + +#### 故障排除提示 + +当我试图从系统菜单中运行 AnyDesk 时,它没有启动。于是,我从终端启动它,它显示了这个错误: + +``` +[email protected]:~$ anydesk +anydesk: error while loading shared libraries: libpangox-1.0.so.0: cannot open shared object file: No such file or directory +``` + +如果你看到 “[error while loading shared libraries][14]” 信息,你要安装它所报错的软件包。在我的例子中,我是这样做的: + +``` +sudo apt install libpangox-1.0-0 +``` + +这解决了我的问题,我希望它也能为你解决。 + +如果你有任何与此主题相关的问题,请在评论区告诉我。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-anydesk-ubuntu/ + +作者:[Abhishek Prakash][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://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://anydesk.com/en +[2]: https://itsfoss.com/open-terminal-ubuntu/ +[3]: https://itsfoss.com/download-files-from-linux-terminal/ +[4]: https://itsfoss.com/adding-external-repositories-ubuntu/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/anydesk-running-in-ubuntu.png?resize=800%2C418&ssl=1 +[6]: https://anydesk.com/en/downloads/linux +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/any-desk-ubuntu-download.webp?resize=800%2C312&ssl=1 +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/any-desk-ubuntu-download-1.webp?resize=800%2C427&ssl=1 +[9]: https://itsfoss.com/install-deb-files-ubuntu/ +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/install-anaydesk-ubuntu.png?resize=800%2C403&ssl=1 +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/installing-anydesk-in-ubuntu-software-center.png?resize=781%2C405&ssl=1 +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/anydesk-installed-in-ubuntu.png?resize=759%2C196&ssl=1 +[13]: https://support.anydesk.com/Access +[14]: https://itsfoss.com/solve-open-shared-object-file-quick-tip/ diff --git a/published/20210923 Build your website with Jekyll.md b/published/20210923 Build your website with Jekyll.md new file mode 100644 index 0000000000..b0b5ccd10d --- /dev/null +++ b/published/20210923 Build your website with Jekyll.md @@ -0,0 +1,173 @@ +[#]: subject: "Build your website with Jekyll" +[#]: via: "https://opensource.com/article/21/9/build-website-jekyll" +[#]: author: "Ayush Sharma https://opensource.com/users/ayushsharma" +[#]: collector: "lujun9972" +[#]: translator: "perfiffer" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13875-1.html" + +使用 Jekyll 构建你的网站 +====== + +> Jekyll 是一个开源的静态网站生成器。你可以使用 Markdown 编写内容,使用 HTML/CSS 来构建和展示,Jekyll 会将其编译为静态的 HTML。 + +![](https://img.linux.net.cn/data/attachment/album/202110/12/145349rblj459naj74j5nr.jpg) + +近年来开始流行静态网站生成器和 JAMStack,而且理由很充分,它们不需要复杂的后端,只需要静态的 HTML、CSS 和 Javascript。没有后端意味着更好的安全性、更低的运营开销和更便宜的托管。双赢! + +在本文中,我将讨论 Jekyll。在撰写本文时,[我的个人网站使用的是 Jekyll][2]。Jekyll 使用 Ruby 引擎将用 Markdown 编写的文章转换成 HTML。[Sass][3] 可以将复杂的 CSS 规则应用到普通文本文件中。[Liquid][4] 允许对静态内容进行编程控制。 + +### 安装 Jekyll + +[Jekyll 网站][5] 提供了 Linux、MacOS 和 Windows 安装说明。安装完成之后,[快速引导][6] 将会安装一个基础的 Hello-World 项目。 + +现在在你的浏览器访问 `http://localhost:4000`,你可以看到你的默认“真棒”博客。 + +![Default "awesome" blog][7] + +### 目录结构 + +这个默认站点包含以下的文件和文件夹: + + * `_posts`: 你的博客文章。 + * `_site`: 最终编译成的静态网站文件。 + * `about.markdown`: “关于页”的内容。 + * `index.markdown`: “主页”的内容。 + * `404.html`: “404 页”的内容。 + * `_config.yml`: Jekyll 的全站配置文件。 + +### 创建新的博客帖子 + +创建帖子很简单。你需要做的就是在 `_post` 目录下使用正确的格式和扩展名创建一个新文件,这样就完成了。 + +有效的文件名像 `2021-08-29-welcome-to-jekyll.markdown` 这样。一个博客文件必须包含 Jekyll 所谓的 YAML 卷首块Front Matter。它是文件开头的一个包含元数据的特殊部分。如果你查看默认的帖子,你可以看到以下内容: + +``` +--- +layout: post +title: "Welcome to Jekyll!" +date:  2021-08-29 11:28:12 +0530 +categories: jekyll update +--- +``` + +Jekyll 会使用上面的元数据,你也可以自定义 `key: value` 键值对。如果你需要一些提示,[请查看我的网站的卷首][9]。除了前面的问题,你还可以 [使用内置的 Jekyll 变量][10] 来自定义你的网站。 + +让我们创建一个新的帖子。在 `_posts` 文件夹下创建 `2021-08-29-ayushsharma.markdown`。内容如下: + +``` +--- +layout: post +title:  "Check out ayushsharma.in!" +date:   2021-08-29 12:00:00 +0530 +categories: mycategory +--- +This is my first post. + +# This is a heading. + +## This is another heading. + +This is a [link]() + +This is my category: +``` + +如果 `jekyll serve` 命令仍在运行,刷新页面,你将看到下面的新帖子。 + +![New blog entry][11] + +恭喜你创建了你的第一篇帖子!这个过程看起来很简单,但是你可以通过 Jekyll 做很多事情。使用简单的 Markdown,你可以归档博客、高亮显示代码片段以及分类管理帖子。 + +### 草稿 + +如果你还没准备好发布你的内容,你可以创建一个 `_drafts` 文件夹。此文件夹中的 Markdown 文件仅通过传递 `--drafts--` 参数来呈现。 + +### 布局和包含 + +请注意 `_post` 文件夹中两篇文章的卷首块,你将在其中看到 `layout: post`。`_layout` 文件夹中包含所有布局。你不会在源代码中找到它们,因为 Jekyll 默认加载它们。Jekyll 使用的默认源代码在 [这里][12]。如果你点击该链接,你可以看到 `post` 的布局使用了默认(`default`)布局。默认布局包含的代码 `{{ content }}` 是注入内容的地方。布局文件还将包含 `include` 指令。它们从 [`include` 文件夹][14] 加载文件,并使用不同的组件组成页面。 + +总的来说,这就是布局的工作方式:你在卷首块定义它们并将你的内容注入其中。而包含则提供了页面的其它部分以组成整个页面。这是一种标准的网页设计技术:定义页眉、页脚、旁白和内容元素,然后在其中注入内容。这就是静态站点生成器的真正威力,完全以编程的方式控制,将你的网站组装起来并最终编译成静态的 HTML。 + +### 页面 + +你网站上的所有内容并不都是文章或博客。你需要“关于”页面、“联系”页面、“项目”页面或“作品”页面。这就是“页面”的用武之地。它们的工作方式与“帖子”完全一样,这意味着它们是带有卷首块的 Markdown 文件。但它们不会放到 `_posts` 目录。它们要么保留在你的项目根目录中,要么保留在它们自己的文件夹中。对于布局和包含,你可以使用与帖子相同的布局或创建新帖子。 Jekyll 非常灵活,你可以随心所欲地发挥你的创意!你的默认博客已经有 `index.markdown` 和 `about.markdown`。请随意自定义它们。 + +### 数据文件 + +数据文件位于 `_data` 目录中,可以是 `.yml`、`.json`、`.csv` 等格式的文件。例如,一个 `_data/members.yml` 文件可能包含: + +``` +- name: A + github: a@a + +- name: B + github: b@b + +- name: C + github: c@c +``` + +Jekyll 在网站生成的时候读取这些内容。你可以通过 `site.data.members` 访问它们。 + +``` + +``` + +### 永久链接 + +你的 `_config.yml` 文件定义了永久链接的格式。你可以使用各种默认变量来组合你自己的自定义永久链接。 + +### 构建你最终的网站 + +命令 `jekyll serve` 非常适合本地测试。但是一旦你完成了本地测试,你将需要构建要发布的最终工作。命令 `jekyll build --source source_dir --destination destination_dir` 将你的网站构建到 `_site` 文件夹中。请注意,此文件夹在每次构建之前都会被清理,所以不要将重要的东西放在那里。生成内容后,你可以将其托管在你的静态托管服务上。 + +你现在应该对 Jekyll 的功能以及主要部分的功能有一个全面的了解。如果你正在寻找灵感,官方 [JAMStack 网站上有一些很棒的例子][17]。 + +![Example Jekyll sites from JAMStack][18] + +编码快乐。 + +本文首发于 [作者个人博客][19],经授权改编。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/9/build-website-jekyll + +作者:[Ayush Sharma][a] +选题:[lujun9972][b] +译者:[perfiffer](https://github.com/perfiffer) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ayushsharma +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/laptop_screen_desk_work_chat_text.png?itok=UXqIDRDD (Person using a laptop) +[2]: https://gitlab.com/ayush-sharma/ayushsharma-in +[3]: https://sass-lang.com/ +[4]: https://shopify.github.io/liquid/ +[5]: https://jekyllrb.com/docs/installation/ +[6]: https://jekyllrb.com/docs/ +[7]: https://opensource.com/sites/default/files/uploads/2016-08-15-introduction-to-jekyll-welcome-to-jekyll.png (Default "awesome" blog) +[8]: https://creativecommons.org/licenses/by-sa/4.0/ +[9]: https://gitlab.com/ayush-sharma/ayushsharma-in/-/blob/2.0/_posts/2021-07-15-the-evolution-of-ayushsharma-in.md +[10]: https://jekyllrb.com/docs/variables/ +[11]: https://opensource.com/sites/default/files/uploads/2016-08-15-introduction-to-jekyll-new-article.png (New blog entry) +[12]: https://github.com/jekyll/minima/blob/master/_layouts/post.html +[13]: https://github.com/jekyll/minima/blob/master/_layouts/default.html#L12 +[14]: https://github.com/jekyll/minima/tree/master/_includes +[15]: https://github.com/"\> +[16]: https://jekyllrb.com/docs/permalinks/ +[17]: https://jamstack.org/examples/ +[18]: https://opensource.com/sites/default/files/uploads/2016-08-15-introduction-to-jekyll-jamstack-examples.png (Example Jekyll sites from JAMStack) +[19]: https://notes.ayushsharma.in/2021/08/introduction-to-jekyll diff --git a/published/20210927 Install Java from your Linux distribution-s repositories.md b/published/20210927 Install Java from your Linux distribution-s repositories.md new file mode 100644 index 0000000000..f2de6c0c60 --- /dev/null +++ b/published/20210927 Install Java from your Linux distribution-s repositories.md @@ -0,0 +1,117 @@ +[#]: subject: "Install Java from your Linux distribution's repositories" +[#]: via: "https://opensource.com/article/21/9/install-java-linux-repositories" +[#]: author: "Chris Hermansen https://opensource.com/users/clhermansen" +[#]: collector: "lujun9972" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13864-1.html" + +如何从 Linux 发行版的仓库中安装 Java +====== + +> 无论你喜欢哪个发行版和包管理器,都可以都很容易地在你的 Linux 系统上安装 Java。 + +![](https://img.linux.net.cn/data/attachment/album/202110/09/092717ean17be0alz10kt5.jpg) + +把 Java 安装到你的 Linux 桌面上有多种方法。一个明显的方式是使用你的 Linux 发行版中提供的软件包。请注意,这并不适合所有人。例如,有些用户可能需要一个非常具体的 Java 版本。 + +在你开始之前,你必须确定你需要“哪种 Java”。你是否只需要运行一些 `.class` 文件或 `.jar` 文件?还是你正在编写一些需要编译的代码? + +就我而言,我运行的大部分 Java 都是我自己(至少部分)编写的 Java,所以安装完整的 Java 开发工具包(或称 JDK)总是有意义的,它包含了 Java 编译器、库和一些非常有用的工具。当然,在这里,我们更倾向于使用开源的 JDK,称为 [OpenJDK][2]。 + +由于我主要在 Ubuntu Linux 发行版上工作,我的软件包管理器是 `apt`。我可以用 `apt` 来查找哪些 OpenJDK 包是可用的: + +``` +apt list OpenJDK\* +``` + +这个命令的输出看起来像这样: + +``` +Listing... Done +openjdk-11-dbg/hirsute-updates,hirsute-security 11.0.11+9-0ubuntu2 amd64 +openjdk-11-dbg/hirsute-updates,hirsute-security 11.0.11+9-0ubuntu2 i386 +openjdk-11-demo/hirsute-updates,hirsute-security 11.0.11+9-0ubuntu2 amd64 +openjdk-11-demo/hirsute-updates,hirsute-security 11.0.11+9-0ubuntu2 i386 +openjdk-11-doc/hirsute-updates,hirsute-updates,hirsute-security,hirsute-security 11.0.11+9-0ubuntu2 all +openjdk-11-jdk-headless/hirsute-updates,hirsute-security 11.0.11+9-0ubuntu2 amd64 +openjdk-11-jdk-headless/hirsute-updates,hirsute-security 11.0.11+9-0ubuntu2 i386 +openjdk-11-jdk/hirsute-updates,hirsute-security 11.0.11+9-0ubuntu2 amd64 +openjdk-11-jdk/hirsute-updates,hirsute-security 11.0.11+9-0ubuntu2 i386 +openjdk-11-jre-dcevm/hirsute 11.0.10+1-1 amd64 +openjdk-11-jre-headless/hirsute-updates,hirsute-security 11.0.11+9-0ubuntu2 amd64 +openjdk-11-jre-headless/hirsute-updates,hirsute-security 11.0.11+9-0ubuntu2 i386 +openjdk-11-jre-zero/hirsute-updates,hirsute-security 11.0.11+9-0ubuntu2 amd64 +openjdk-11-jre-zero/hirsute-updates,hirsute-security 11.0.11+9-0ubuntu2 i386 +openjdk-11-jre/hirsute-updates,hirsute-security 11.0.11+9-0ubuntu2 amd64 +openjdk-11-jre/hirsute-updates,hirsute-security 11.0.11+9-0ubuntu2 i386 +openjdk-11-source/hirsute-updates,hirsute-updates,hirsute-security,hirsute-security 11.0.11+9-0ubuntu2 all +openjdk-15-dbg/hirsute 15.0.3+3-1 amd64 +openjdk-15-dbg/hirsute 15.0.3+3-1 i386 +openjdk-15-demo/hirsute 15.0.3+3-1 amd64 +... +openjdk-8-jre/hirsute-updates,hirsute-security 8u292-b10-0ubuntu1 i386 +openjdk-8-source/hirsute-updates,hirsute-updates,hirsute-security,hirsute-security 8u292-b10-0ubuntu1 all +``` + +我在上面用 `...` 省略了不少行。 + +事实证明,即使限制在 OpenJDK 中,我仍然有很多选择: + + * 不同的架构(在我的例子中,i386 还是 amd64)。 + * 不同的 Java 版本(就我而言,有 8、11、15、16、17 等)。 + * 纯粹的 OpenJDK 或无头版本。 + * Java 运行时环境(JRE)。 + * 用于调试、演示,以及是否包含源代码等。 + +同样,在我的情况中,我主要对纯粹的普通 OpenJDK 感兴趣。 + +假设我想为我的 amd64 架构安装 Java 11 版本的普通 OpenJDK,我可以输入: + +``` +sudo apt install -a=amd64 openjdk-11-jdk +``` + +几分钟后,我就可以编译、运行、调试和打包我的 Java 代码了。 + +注意,很有可能需要同时安装多个版本的 Java,有时甚至是必要的。在 Ubuntu 中,有一个有用的工具,叫做 `update-java-alternatives`,它可以 [显示并配置在使用哪个 Java 环境][3]。 + +那些使用不同 Linux 发行版的人,一般来说,可以采取类似的方法。其他的几个发行版(如 Debian 和 Mint)也使用 `apt` ,尽管可用的软件包可能不同。发行版可能使用不同的软件包管理器。例如, [Fedora 安装 Java 的文档页面][4] 显示了如何使用 Fedora `dnf` 包管理器来处理安装。首先,为了显示可用的版本,输入: + +``` +dnf search openjdk +``` + +接下来,要安装完整的开发 x86_64 架构版本,请输入: + +``` +sudo dnf install java-11-openjdk-devel.x86_64 +``` + +同样地,Fedora 提供了 `alternatives` 工具来 [显示和配置 Java 环境][5]。 + +再比如,[很棒的 Arch Linux 维基][6] 显示对应的软件包是 `jdk11-openjdk`。该维基还解释了许多在 Arch 中使用 Java 的其他重要细节,比如使用 `archlinux-java` 工具来显示安装了哪些 Java 环境或选择一个不同的默认环境。Arch 使用一个叫 `pacman` 的包管理器,它也有文档 [在 Arch Linux 维基上][7]。 + +不管你喜欢哪个发行版和软件包管理器,在你的 Linux 系统上获得 Java 是很容易的。当然,在安装之前,要考虑版本和功能。还要记住,在同一台电脑上有管理两个或多个 Java 版本的方法。我的大多数例子都使用了 `apt`,但也要记得可以选择使用 `dnf`。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/9/install-java-linux-repositories + +作者:[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/java-coffee-mug.jpg?itok=Bj6rQo8r (Coffee beans and a cup of coffee) +[2]: https://openjdk.java.net/ +[3]: http://manpages.ubuntu.com/manpages/hirsute/man8/update-java-alternatives.8.html +[4]: https://docs.fedoraproject.org/en-US/quick-docs/installing-java/ +[5]: https://tecadmin.net/install-java-on-fedora/ +[6]: https://wiki.archlinux.org/title/java#OpenJDK +[7]: https://wiki.archlinux.org/title/pacman#Querying_package_databases diff --git a/published/20210929 Dialect- An Open-Source Translation App for Linux.md b/published/20210929 Dialect- An Open-Source Translation App for Linux.md new file mode 100644 index 0000000000..073ad4a64f --- /dev/null +++ b/published/20210929 Dialect- An Open-Source Translation App for Linux.md @@ -0,0 +1,100 @@ +[#]: subject: "Dialect: An Open-Source Translation App for Linux" +[#]: via: "https://itsfoss.com/dialect/" +[#]: author: "Ankush Das https://itsfoss.com/author/ankush/" +[#]: collector: "lujun9972" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13868-1.html" + +Dialect:Linux 下的开源翻译应用 +====== + +![](https://img.linux.net.cn/data/attachment/album/202110/10/115724t5xgx8agu8asag0u.jpg) + +> Dialect 是一个简单明了的应用,可以让你使用 Web 服务进行语言间的翻译。想要了解更多的话,让我们来一窥究竟。 + +虽然你可以启动 Web 浏览器并直接使用任何翻译服务来完成工作,但桌面应用有时会派上用场。 + +Dialect 是一个简单的翻译应用,可以利用 Web 服务进行翻译,同时给你一些额外的能力。 + +### 使用谷歌翻译和 LibreTranslate 的开源翻译应用 + +![][1] + +Dialect 是一个主要为 GNOME 桌面定制的应用,但它在其他桌面环境下也应该能正常工作。 + +它可以让你快速翻译语言,同时还有一些额外的选项。 + +在其核心部分,你可以选择谷歌翻译或 LibreTranslate 翻译服务。 + +尽管 LibreTranslate 达不到谷歌翻译的准确性,但把它作为一个选项来切换是一个很好的补充。至少,对于一些基本的用法,如果用户不想利用谷歌的服务,你的桌面上就有一个备选方案。 + +### Dialect 的特点 + +![][2] + +除了切换翻译服务外,你还能得到如下个功能: + + * 发音 + * 文本到语音(TTS)功能(谷歌) + * 黑暗模式 + * 翻译快捷方式 + * 实时翻译 + * 剪贴板按钮可快速复制/粘贴 + * 翻译历史(撤销/重做) + +正如你在截图中所注意到的,实时翻译功能可能会因为滥用 API 而使你的 IP 地址被禁止使用服务。 + +![][3] + +我试着使用 LibreTranslate(如上图所示)和谷歌翻译,并启用实时翻译功能,它工作得很好。 + +也许,如果你经常依赖翻译,你可能想避免这个实时翻译。但是,对于我的临时使用,在相当多的测试中,该服务并没有导致 IP 地址被禁止。 + +重要的是要注意,如果你想,你可以指定一个自定义的 LibreTranslate 实例。默认情况下,它使用 “translate.astian.org” 作为实例。 + +你可能找不到一个单独显示的翻译历史区域,但窗口左上角的箭头按钮会让你看到你以前的翻译,以及翻译设置。 + +所以,它也可以作为一个重做/撤销的功能。 + +### 在 Linux 中安装 Dialect + +[Dialect][7] 是以 [Flatpak][4] 的形式提供的。所以,你应该能够在你选择的任何 Linux 发行版上安装它。如果你是新手,你可能想看看我们的 [Flatpak 指南][5] 以获得帮助。 + +首先,添加 Flathub 仓库: + +``` +flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo +``` + +然后安装应用: + +``` +flatpak install flathub com.github.gi_lom.dialect +``` + +安装后,在系统菜单中寻找它,并从那里启动它。 + +你也可以浏览它的 [GitHub 页面][6] 了解更多信息。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/dialect/ + +作者:[Ankush Das][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://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/dialect-screenshot.png?resize=800%2C331&ssl=1 +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/dialect-app-options.png?resize=800%2C470&ssl=1 +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/dialect-libretranslate.png?resize=800%2C326&ssl=1 +[4]: https://itsfoss.com/what-is-flatpak/ +[5]: https://itsfoss.com/flatpak-guide/ +[6]: https://github.com/dialect-app/dialect/ +[7]: https://flathub.org/apps/details/com.github.gi_lom.dialect diff --git a/published/20210929 Install Java manually on Linux.md b/published/20210929 Install Java manually on Linux.md new file mode 100644 index 0000000000..32ba846089 --- /dev/null +++ b/published/20210929 Install Java manually on Linux.md @@ -0,0 +1,118 @@ +[#]: subject: "Install Java manually on Linux" +[#]: via: "https://opensource.com/article/21/9/install-java-manually-linux" +[#]: author: "Alan Formy-Duval https://opensource.com/users/alanfdoss" +[#]: collector: "lujun9972" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13869-1.html" + +如何在 Linux 上手动安装 Java +====== + +> 手动安装可以让用户更好的控制 Java 运行时环境。 + +![](https://img.linux.net.cn/data/attachment/album/202110/10/143844wm2x4d18b1mb8md1.jpg) + +[使用 Linux 发行版的软件包管理工具来安装 Java 软件包][6] 是很容易的。然而,有时你需要手动安装 Java。这对基于 Java 的应用服务器(如 Tomcat 或 JBoss)的管理员特别重要。许多开源和专有软件产品都依赖于这些服务。 + +### 开发者或运行时套件? + +Java 虚拟机Java Virtual Machine(JVM)以两种不同的形式提供:Java 开发工具包Java Development Kit(JDK)或 Java 运行时环境Java Runtime Environment(JRE)。 + +软件开发人员通常需要 JDK。它包含编译、运行和测试源代码所需的二进制文件。部署一个预先建立的 Java 应用程序通常只需要 JRE。它不包括编译器和其他开发工具。由于安全性的提高和空间的限制,通常在生产环境中安装 JRE。 + +### 获取 Java + +你可以从网上下载开源的 Java 软件。你可以在 [Red Hat Developer][2]、[Adoptium.net][3] 下载 OpenJDK 打包文件,或从 Azul 下载 [Zulu 社区版][4] 。 + +### 安装 Java + +设置一个目录来存放 Java 文件。我喜欢创建一个简单的名为 `java` 的目录,这样我就可以在一个专门的目录中下载并解压打包文件: + +``` +$ mkdir -p java/jdk +``` + +让我们在这个例子中使用 JDK。将下载的文件保存到 `jdk` 目录下。然后换到该目录: + +``` +$ cd java/jdk +$ ls +OpenJDK11U-jdk_x64_linux_hotspot_11.0.12_7.tar.gz +``` + +提取该打包文件。注意,`tar` 会创建一个新的目录: + +``` +$ tar xvzf OpenJDK11U-jdk_x64_linux_hotspot_11.0.12_7.tar.gz +$ ls +jdk-11.0.12+7 OpenJDK11U-jdk_x64_linux_hotspot_11.0.12_7.tar.gz +``` + +使用 `-version` 选项确认新 JVM 的版本。 + +``` +$ cd jdk-11.0.12+7/bin +$ ./java -version +``` + +JVM 的版本输出看起来类似这样: + +``` +openjdk version "11.0.12" 2021-07-20 +OpenJDK Runtime Environment Temurin-11.0.12+7 (build 11.0.12+7) +OpenJDK 64-Bit Server VM Temurin-11.0.12+7 (build 11.0.12+7, mixed mode) +``` + +#### 环境变量 + +为了确保一个特定的应用程序能够正常工作,它需要确切地知道如何定位 JVM。有两个主要的变量需要设置:`JAVA_HOME` 和 `PATH`。 + +``` +$ echo $JAVA_HOME +$ echo $PATH +``` + +这些可以在用户的 `.bashrc` 文件中设置。确保这些变量出现在 [任何设置 PATH 的现有代码][5] 之后: + +``` +#Set the JAVA_HOME +export JAVA_HOME=~/java/jdk/jdk-11.0.12+7 +#Add the JAVA_HOME to the PATH +export PATH="$JAVA_HOME/bin:$PATH" +``` + +### 手动安装的情况 + +有几种情况需要手动安装 Java。请考虑以下三种情况: + +一种情况可能是要求使用不同的,也许是较早的,在你的 Linux 发行版的软件库中已经没有的 Java 版本。 + +另一个例子可能是由安全推动的决定,即 Java 不会被默认安装在操作系统上或在“根级别”上。 + +第三种情况是可能需要几个不同版本的 Java,通常是因为 J2EE Web 应用程序的多个实例在同一台服务器上运行。由于越来越多地使用虚拟机和容器来隔离进程,这种操作系统共享在今天已经不太常见了。然而,由于需要维护不同的容器镜像,对手动安装的理解仍然至关重要。 + +### 总结 + +我演示了我手动安装 Java 运行时环境的方式,但你可以制定一个最适合你需求的惯例。最终,手动安装让用户可以更好的控制 Java 运行时环境。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/9/install-java-manually-linux + +作者:[Alan Formy-Duval][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/alanfdoss +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/car-penguin-drive-linux-yellow.png?itok=twWGlYAc (Penguin driving a car with a yellow background) +[2]: https://developers.redhat.com/products/openjdk/download +[3]: https://adoptium.net/ +[4]: https://www.azul.com/downloads/zulu-community +[5]: https://opensource.com/article/17/6/set-path-linux +[6]: https://linux.cn/article-13864-1.html \ No newline at end of file diff --git a/published/20210930 Make YAML as easy as it looks.md b/published/20210930 Make YAML as easy as it looks.md new file mode 100644 index 0000000000..88330932b8 --- /dev/null +++ b/published/20210930 Make YAML as easy as it looks.md @@ -0,0 +1,154 @@ +[#]: subject: "Make YAML as easy as it looks" +[#]: via: "https://opensource.com/article/21/9/yaml-cheat-sheet" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lujun9972" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13842-1.html" + +让 YAML 变得像它看起来一样简单 +====== + +> YAML 看起来很简单,为什么它这么难写呢?了解成功使用 YAML 的两个秘诀。 + +![](https://img.linux.net.cn/data/attachment/album/202110/02/101824shamurmpvldpu29a.jpg) + +如果你曾经尝试过写 YAML,你可能一开始会对它看起来很容易感到高兴。乍一看,经常用于配置文件、Ansible 剧本和普通文件数据库的 YAML 看起来就像购物清单一样直观。然而,YAML 的结构中有很多细微的差别,它隐藏着一个危险的秘密:YAML 实际上是一种高度精确、结构化和令人惊讶的严格语言。好消息是,你只需要了解两件事就可以知道 YAML 的工作原理。 + +关于 YAML 的真相是,YAML 中只有两种数据结构:序列sequence映射mapping。这是两个花哨的名字,你会发现它代表了你非常熟悉的概念。这篇文章解释了这两种结构,更重要的是,介绍了它们是如何协同工作,使 YAML 成为表示你所关心的数据的强大方式。 + +### YAML 序列 + +YAML 序列是一个列表。在其最简单的形式中,每行有一个项目,每行以破折号和空格开始。 + +下面是一个例子: + +``` +--- +- Linux +- BSD +- Illumos +``` + +不同的语言有不同的方式来表示这种数据。例如,在 Python 中,同一个列表可以写成 `['Linux', 'BSD', 'Illumos']`。当你在现实生活中写一个列表时,例如在你去买菜之前,你写的可能近似于 YAML 序列。 + +### YAML 映射 + +YAML 映射是一个关键术语与该术语的定义相结合。在其他语言中,映射被称为“键值对”或“词典”。 + +这里有一个例子: + +``` +--- +Kernel: Linux +CPU: AMD +RAM: '16 GB' +``` + +不同的语言有不同的方式来表示这种数据。[在 Python 中][2],例如,同样的数据可以写成 `{"Kernel": "Linux", "CPU": "AMD", "RAM": "16 GB"}`。在现实生活中,你可能会使用这种结构来计划,例如,与朋友的游戏之夜。一个朋友报名带零食,另一个报名带一副牌,另一个报名带一个棋盘游戏,等等。 + +### 组合序列和映射 + +你现在知道 YAML 的语法了。序列和映射是 YAML 中仅有的两种构件,你想在 YAML 中表示的任何东西都可以放在序列或映射中。 + +或者同时使用这二者! + +是的,序列和映射可以被组合和嵌套,这就是 YAML 看起来很直观,但同时又感觉很复杂的原因之一。不过,只有四种可能的组合,一旦你学会如何看它们,YAML 就会觉得像它看起来一样简单。 + +### 序列的映射 + +当你想让一个键项有许多值时,你可以使用一个序列的映射。也就是说,你从一个映射(键)开始,但是给值一个列表: + +``` +--- +Linux: +  - Fedora +  - Slackware +BSD: +  - FreeBSD +  - NetBSD +``` + +在这个示例代码中,`Linux` 是第一个键,它的值是一个序列,其中包含 `Fedora` 和 `Slackware`。第二个键是 `BSD`,它的值是一个序列,包含 `FreeBSD` 和 `NetBSD`。 + +### 映射的映射 + +当你想让一个键项的值中既有键又有值时,你可以使用映射的映射。也就是说,你从一个映射(键)开始,但是给值另一个映射。 + +这可能有点欺骗性,但它揭示了 YAML 中使用特定术语的原因:因为你只不过是创建了一个映射的列表,并不意味着你创建了一个序列。这里是一个映射的映射: + +``` +--- +Desktop: +  CPU: RISC-V +  RAM: '32 GB' +Laptop: +  CPU: AMD +  RAM: '16 GB' +``` + +对大多数人来说,这看起来像一个列表。而且从技术上讲,它是一个列表。但重要的是要认识到,它不是 YAML 序列。它是一个映射,其中包含映射。作为半个 YAML 专家,你可以从明显缺少破折号的地方看出区别。 + +在 Ansible 剧本的所有结构中,我发现这个结构最容易欺骗人。作为人类,我们喜欢列表,当我们看到一个数据结构 _在字面上_ 是列表时,大多数人会把它当成 YAML 序列。但是在 YAML 中,虽然序列是列表,但是列表并不总是序列。 + +### 序列的序列 + +就像你可以嵌套映射一样,你可以将一个序列嵌套到一个序列中: + +``` +--- +- [Linux, FreeBSD, Illumos] +- [YAML, XML, JSON] +``` + +这可能是我在 YAML 的实际使用中遇到的最不常见的数据结构,但有时你需要一个列表的列表。 + +### 映射的序列 + +你也可以创建一个包含映射的序列。对于人类排序数据的方式来说,这并不太常见,但对于计算机来说,这可能是一个重要的结构。 + +这里有一个例子: + +``` +--- +- +  CPU: AMD +  RAM: '16 GB' +- +  CPU: Intel +  RAM: '16 GB' +``` + +对于 YAML,这可能是最不直观的语法。我发现它在 Python 中呈现时更清晰: + +``` +[{"CPU": "AMD", "RAM": "16 GB"}, {"CPU": "Intel", "RAM": "16 GB"}] +``` + +方括号代表一个列表结构,这个列表包含两个字典。每个字典都包含键值对。 + +### 构建更好的 YAML + +现在你知道了 YAML 的两个组成部分,以及它们如何被组合起来以表示复杂的数据结构。问题是:你要用 YAML 构建什么? + +和很多人一样,我也使用 YAML 来编写 Ansible 剧本。我还用它作为一种简单的配置格式、作为 D&D 的角色表、表示项目组织所需的目录结构,等等。只要你能适应序列和映射的概念,你会发现 YAML 是一种很容易编写、阅读和(如果有合适的库)解析的格式。 + +如果你发现自己经常使用 YAML,请下载我们的 [YAML 速查表][3],以帮助你直观地了解基本数据结构及其组合,并帮助你记住一些额外的语法约定。通过一点点的练习,你会发现 YAML 真的和它看起来一样简单! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/9/yaml-cheat-sheet + +作者:[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/laptop_screen_desk_work_chat_text.png?itok=UXqIDRDD (Person using a laptop) +[2]: https://opensource.com/article/21/3/dictionary-values-python +[3]: https://opensource.com/downloads/yaml-cheat-sheet diff --git a/published/20211001 -e- cloud is a deGoogled Alternative to Google Drive.md b/published/20211001 -e- cloud is a deGoogled Alternative to Google Drive.md new file mode 100644 index 0000000000..6234cfe8b9 --- /dev/null +++ b/published/20211001 -e- cloud is a deGoogled Alternative to Google Drive.md @@ -0,0 +1,77 @@ +[#]: subject: "/e/ cloud is a deGoogled Alternative to Google Drive" +[#]: via: "https://news.itsfoss.com/e-cloud/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lujun9972" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13874-1.html" + +/e/ 云:一个去谷歌化的 Google Drive 替代方案 +====== + +![](https://img.linux.net.cn/data/attachment/album/202110/12/122933awf0z9vnqdzslv1q.jpg) + +> /e/ 云是 e.foundation 使用 Nextcloud 等开源工具创立的,以作为 Google Drive 和 Gmail 的替代品。 + +![](https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/10/ecloud-ft.png?w=1200&ssl=1) + +Google Drive 是一种流行的云存储服务,在大多数情况下效果很好。 + +然而,它可能不是最关注隐私的选择。因此,要完全控制你的数据,最好的办法是启动一个 [Nextcloud][1] 实例,存储你的基本数据,并可以访问其他协作工具。 + +虽然这听起来不错,但不是每个人都能投入精力来创建和维护他们的实例。这就是 /e/ 云上场的时候了,它是由 [去谷歌化的安卓操作系统 /e/ 操作系统][2] 背后的同一个团队建立的。 + +/e/ 云主要将自己定位为一个新的 Google Drive 私人替代品,并提供一个取代 Gmail 的邮箱。 + +### /e/ 云:带有邮箱的 Nextcloud 及 OnlyOffice + +![][3] + +当你创建一个 /e/ 账户时,它会给你一个私人电子邮件地址 [xyz@e.email][4]。 + +而且,同邮箱地址一起,你会得到 1GB 的免费 /e/ 云存储空间和一个由 Nextcloud 和 OnlyOffice 为核心的协作平台。 + +因此,如果你想利用 Nextcloud 和 OnlyOffice 来取代谷歌的工具套件,而不需要自己全部设置,/e/ 云可以成为一个引人注目的以隐私为中心的选择。 + +![][5] + +除了 OnlyOffice 的文件存储和文档支持外,你还可以使用日历,存储笔记,并添加任务。 + +因此,它也可以成为一个正式的以隐私为中心的协作平台,你可以免费使用。 + +如果你想要更多的存储空间,你可以将你的订阅升级到付费计划,你可以根据需要选择 20 到 1TB 的存储空间,并按月/年计费。定价计划起价低至 3 美元/月。 + +毫无疑问,如果你在手机上使用 /e/ 操作系统或使用一个 /e/ 智能电话,这应该是一种无缝体验。 + +但是,你也可以使用第三方邮件客户端和 Nextcloud 移动应用在任何设备上使用它。 + +- [注册 /e/ 云][6] + +### 总结 + +考虑到它相对较新,正计划增加几个功能,包括端到端加密,从 Google Drive 迁移等。 + +你可以注册一个帐户并免费试用。 + +对于像 /e/ 云这样以 Nextcloud 为核心的主流解决方案,除了电子邮件和协作服务外,还能帮助你安全地管理/存储文件,你觉得怎么样? + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/e-cloud/ + +作者:[Ankush Das][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://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/nextcloud/ +[2]: https://itsfoss.com/e-os-review/ +[3]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/10/ecloud.png?resize=1568%2C772&ssl=1 +[4]: mailto:xyz@e.email +[5]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/10/ecloud-files.png?resize=1568%2C787&ssl=1 +[6]: https://e.foundation/e-email-invite/ diff --git a/published/20211001 8 reasons why I learned Core Java.md b/published/20211001 8 reasons why I learned Core Java.md new file mode 100644 index 0000000000..b7359fbbf1 --- /dev/null +++ b/published/20211001 8 reasons why I learned Core Java.md @@ -0,0 +1,97 @@ +[#]: subject: "8 reasons why I learned Core Java" +[#]: via: "https://opensource.com/article/21/10/why-i-learned-core-java" +[#]: author: "Shantam Sahai https://opensource.com/users/shantam-sahai" +[#]: collector: "lujun9972" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13855-1.html" + +学习 Core Java 的 8 个原因 +====== + +> 在学习建立在 Java 之上的所有相关工具时,了解 Core Java 会给你带来很大的优势。 + +![](https://img.linux.net.cn/data/attachment/album/202110/06/094720iax1d49c5sc0sd48.jpg) + +计算机编程(也被称为 *编码*)的重点不是使用哪种编程语言,而是发展编程逻辑和学习像程序员一样思考。你一开始使用的编程语言应该是在这一努力过程中对你帮助最大的语言。因此,你必须问自己一个问题,“作为一个程序员,你想开发什么?” + +例如,如果你想从事安卓应用开发、视频游戏开发、桌面 GUI 应用,或者只是一般的软件开发,我认为学习 Java 是一个很好的选择。我选择的语言是 Java,它为我提供了一个完整的编程世界。在我居住的印度,Java 程序员的平均工资约为每年 59 万印度卢比(LPA)(根据你的经验,可以高达 100 LPA)。 + +不过,Java 是一种庞大的语言,有很多框架和变体可供选择。Core Java 是科技行业发展出来的术语,指的是 Java 语言的中心组件,人们用它来编写框架,并围绕 Java 发展了丰富的产业。我认为,Core Java 是你能获得的最强大的技能之一,因为在学习建立在它之上的所有相关工具时,了解 Java 的基础知识会给你带来巨大的优势。 + +以下是我选择 Core Java 的八大理由,我想你也会认可: + +### 1、Java 是一种不断发展的编程语言 + +Java 有重要的企业支持,但 Java 开发中最重要的组成部分是 [OpenJDK][2],这是个开源的 Java 开发工具包。OpenJDK 社区以促进和维护开发源码、开放创新和开放标准为使命,致力于改进和维护 Java 及其工具链的开源实现。 + +它的每一个版本都会增加创新和便利,使 Java 对开发者和用户都更容易。例如,就在 Java 11 中,他们增加了运行 .java 文件的能力。现在,运行一个单文件的 Java 应用程序所需要的只是 `java` 命令,不需要进行编译: + +``` +$ java ./hello.java + +Hello world +``` + +你可以使用 Java 做 Web、移动或桌面的应用程序编程。它是一种高度通用的语言。它有许多有趣的特点,如动态编码、多种安全功能、平台无关的特点和以网络为中心的设计。 + +### 2、Java 锚定了安卓应用开发 + +你可以使用 Java 来创建安卓用程序。安卓市场巨大,对移动程序员的需求只会越来越大。即使你对成为一个专业的应用程序开发人员不感兴趣,定制你的移动体验的能力也是很强大的,而 Java 使之成为可能。 + +而且,这比你想象的要容易得多!学习 Core Java 可以让你轻松地掌握安卓开发工具包或可以输出到移动平台的框架,如 [Processing][3]。 + +### 3、丰富的 API 使得 Java 易于使用 + +Java 的 API(应用编程接口Application Programming Interface)包括类、包、接口等。Java 主要有三种类型的 API: + + * 官方的 Java Core API + * 最佳的官方 Java API + * 非官方的 API + +API 使编程更容易,因为你可以在不知道其内部实现的情况下构建应用程序。根据我的经验,许多公司喜欢用 Java 而不是其他选择,就是因为 Java API 的力量。 + +### 4、开源库 + +几乎有无穷无尽的 Java 开源库,包括 Maven、Guava、Apache Commons、Jhipster,等等。你可以复制、学习和分享这些库的资源。它们使编程更容易获得、更快、更便宜,也更有教育意义。 + +### 5、Java 有可靠的开发工具 + +Java 有一些我最喜欢的 IDE(集成开发环境Integrated Development Environments),包括 [Eclipse][4]、[NetBeans][5]、[BlueJ][6] 和 IntelliJ IDEA。它们提供了调试、语法高亮、代码补完、语言支持、自动重构等功能。简而言之,IDE 在 Java 的成功和你在 Java 学习中起着至关重要的作用! + +### 6、印度对 Java 开发人员的需求 + +谷歌、Netflix 和 Instagram 等巨头都使用 Java 进行后台开发。印度公司正在积极寻找雇用 Java 程序员来开发安卓应用程序、新的 API 和云上的微服务。这种需求转化为更多的工作机会。 + +### 7、Java 有庞大的编程社区 + +Java 程序员的社区庞大,囊括了从初学者到专家的所有人。我发现这个社区很热情待人,当你寻求支持的时候,他们会给予帮助。最重要的是,通过参与在线讨论,我学到了大量的新技巧。作为社区的一分子,这是我了解最新趋势、学习更多语言和跟上发展的重要途径。 + +### 8、Java 是独立于平台 + +Java 是平台无关的,这一点使它具有很高的价值。Java 源代码被编译成字节码,在 Java 虚拟机(JVM)上运行。任何运行 JVM 的平台(支持所有主要平台)都可以运行你的 Java 应用程序。你只需写一次,就可以在任何地方运行!这并不只是理论上的,Java 实际上已经实现了这一点。你可以在你开发的任何平台上编写 Java,并将其交付给你的所有目标平台。 + +网上有很多学习 Java 的资源,包括 Opensource.com 上有一个 [速查表][7]。还有一个很好的 [在线 Java 课程][8],可以用印地语免费学习。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/10/why-i-learned-core-java + +作者:[Shantam Sahai][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/shantam-sahai +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/studying-books-java-couch-education.png?itok=C9gasCXr (Learning and studying technology is the key to success) +[2]: https://developer.ibm.com/components/open-jdk/ +[3]: http://processing.org/ +[4]: https://opensource.com/article/20/12/eclipse +[5]: https://opensource.com/article/20/12/netbeans +[6]: https://opensource.com/article/20/7/ide-java#bluej +[7]: https://opensource.com/downloads/java-cheat-sheet +[8]: https://www.learnvern.com/course/core-java-programming-tutorial diff --git a/published/20211001 The Official Raspberry Pi 4 Case Sucks- Here-s What You Can do to Reduce the Overheating.md b/published/20211001 The Official Raspberry Pi 4 Case Sucks- Here-s What You Can do to Reduce the Overheating.md new file mode 100644 index 0000000000..8b1b953f84 --- /dev/null +++ b/published/20211001 The Official Raspberry Pi 4 Case Sucks- Here-s What You Can do to Reduce the Overheating.md @@ -0,0 +1,128 @@ +[#]: subject: "The Official Raspberry Pi 4 Case Sucks! Here’s What You Can do to Reduce the Overheating" +[#]: via: "https://itsfoss.com/raspberry-pi-case-overheating/" +[#]: author: "Avimanyu Bandyopadhyay https://itsfoss.com/author/avimanyu/" +[#]: collector: "lujun9972" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13851-1.html" + +官方的树莓派 4 外壳很烂!怎么样减少过热? +====== + +![](https://img.linux.net.cn/data/attachment/album/202110/04/201826ghpecyb43cxehi4y.jpg) + +[树莓派 4][1] 绝对是数百万人的最爱,特别是在极客社区里,我也不例外。但是你知道树莓派在没有适当冷却的情况下会限制性能吗? + +在这里,我将介绍 [树莓派 4 官方外壳][2] 的一些严重缺点,同时也分享一些缓解这些缺点的方法。 + +![树莓派 4 官方外壳][3] + +在第一次启动后,我的安装在 [树莓派 4 官方外壳][2] 内的树莓派 4(8GB 内存版),在无人值守的升级启动时,会高达 80℃。我在 Ubuntu 上进行了所有的 [固件更新][4],显然是为了 [解决发热问题][5]。 + +就算在空闲时,这个烫手的香草和草莓蛋糕也绝不会低于 75℃。 + +我几乎无法使用它,直到我取下外壳顶部的白色盖子。它闲置时的温度降到只有 67℃ 左右 —— 你相信吗?即使是在我重新启动一段时间后再次检查也是这样。很明显,这仍然是不太可接受。如果我买了这个外壳并打算长期使用,我为什么要一直把盖子打开? + +为什么会发生这样的事情?这都是因为官方的树莓派外壳的设计非常糟糕。 + +### 官方的树莓派 4 外壳是一个发热怪物! + +简单地说,[热节流][6] 就是降低你的树莓派处理器(CPU)的性能,以使温度不超过极限高温(如 80℃)而 [导致损坏][7]。 + +这个外壳是由塑料制成的,它是热的不良导体(简单的 [传统物理学][8] 知识),因此无法将热量有效地散布到整个外壳和板子之外。因此,板上的处理器会发热,一旦温度达到惊人的程度,它的性能就会被降到一个极低的水平。我注意到,在第一次开机后,在**无人值守**的情况下进行升级时,CPU 的温度为 80℃,CPU 的使用率为 100%。 + +虽然这个官方的外壳看起来很美,但它对树莓派的性能造成了很大的影响。 + +如果你真的想让你的树莓派发挥最大的性能,你也必须负责它的冷却。这些发热问题不能被简单地忽视。 + +#### 热量被困在内部 + +一旦你把树莓派安装在这个外壳里,它甚至没有一个通风口可以让多余的热量排出。所以热量就一直在里面积累,直到达到那些疯狂的温度并触发了节流阀。 + +#### 没有风扇通风口(非常需要) + +顶部的白色盖子上可以有一个圆形的通风口,至少可以把 [树莓派 4 的官方风扇][9] 放在上面使用。 + +#### 没有被动冷却 + +如果外壳是金属的,它就可以作为散热器,有效地将树莓派板上的处理器的热量散发出去。 + +#### 除了发热问题之外,还有其他的缺点 + +树莓派 4 官方外壳还有一些缺点: + + 1. 不便于 SD 卡管理:将树莓派板子装入外壳内,并将 SD 卡端口放在正确的方向上,以便以后能够换卡,这不是很方便。 + 2. 没有螺丝钉系统:没有提供螺丝,也许是因为它可能会破坏机箱底座上的假支架,这些假支架看起来就像你可以用四颗螺丝把板子牢牢地固定在底座上。 + +### 你可以做什么来控制树莓派 4 的过热? + +在做了一些紧张的研究之后,我找到了市场上一些最好的冷却解决方案 —— 这一切都要归功于我们了不起的改装社区。 + +#### 使用冰塔式冷却器 + +我首先发现了 [Jeff Geerling's][10] 对各种树莓派散热器的深入性能评估,他在网上被称为 [geerlingguy][11]。在看完温度统计后,我直接选择了冰塔式散热器,并组装了它: + +![树莓派 4 冰塔冷却器][12] + +它空闲和低载时的温度下降到 30℃,现在保持在 45℃ 左右。我还没有为它改装一个合适的外壳。我准备找个给冷却器提供了足够的空间的现成外壳。也许可以在亚马逊或其他网上商店找到这种外壳。 + +但我没有找到这种产品。 + +#### 使用铝制散热器进行被动散热 + +网上也有一个关于 [被动冷却][17] 的出色视频,测评了一个用铝制散热片做的外壳。 + +它提供了一个热垫,它相当于台式机处理器上使用的散热膏。按照视频中显示的方式放置它,热量就会从树莓派板上的处理器散发到整个外壳内。这就是科学的神奇之处! + +#### 改装官方的树莓派外壳 + +如果你仍然想买官方的外壳,建议你至少要做一个风扇的改装。 + +### 潜在的制造解决方案 + +这里有一些解决方案,通过应用 [DevOps][21] 启发的改进,可以使整个制造过程更容易。 + + * 想一想,从外壳顶部切下的那块圆形塑料可以回收,用来制造更多的树莓派 4 外壳,不是吗?这显然会是一个双赢的局面,同时也降低了成本! + * 铝是地球上最丰富的金属,但 [全球供应中断][22] 可能是一个挑战。即使如此,还有其他的 [导电性解决方案][23] 来探索用于设计案例的材料! + +### 总结 + +希望这篇文章能帮助你从树莓派 4 中获得最大的收益。我很想知道你的想法、建议和经验,请在下面的评论中留言。请不要犹豫地分享。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/raspberry-pi-case-overheating/ + +作者:[Avimanyu Bandyopadhyay][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/avimanyu/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/raspberry-pi-4/ +[2]: https://www.raspberrypi.org/products/raspberry-pi-4-case/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/raspberry-pi-4-official-case.webp?resize=800%2C533&ssl=1 +[4]: https://www.einfochips.com/blog/understanding-firmware-updates-the-whats-whys-and-hows/ +[5]: https://www.seeedstudio.com/blog/2019/11/29/raspberry-pi-4-firmware-update-pi-4-now-runs-cooler-than-ever/ +[6]: https://www.pcmag.com/encyclopedia/term/thermal-throttling +[7]: https://www.pcgamer.com/cpu-temperature-overheat/ +[8]: https://thermtest.com/stay-colder-for-longer-in-a-container-made-of-plastic-or-metal +[9]: https://www.raspberrypi.org/products/raspberry-pi-4-case-fan/ +[10]: https://www.jeffgeerling.com/blog/2019/best-way-keep-your-cool-running-raspberry-pi-4 +[11]: https://www.jeffgeerling.com/about +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/raspberry-pi-4-ice-tower-cooler.webp?resize=480%2C360&ssl=1 +[13]: https://i0.wp.com/m.media-amazon.com/images/I/51g9gQC9k7L._SL160_.jpg?ssl=1 +[14]: https://www.amazon.com/dp/B07V35SXMC?tag=chmod7mediate-20&linkCode=ogi&th=1&psc=1 (GeeekPi Raspberry Pi Cooling Fan, Raspberry Pi ICE Tower Cooler, RGB Cooling Fan with Raspberry Pi Heatsink for Raspberry Pi 4 Model B & Raspberry Pi 3B+ & Raspberry Pi 3 Model B) +[15]: https://www.amazon.com/gp/prime/?tag=chmod7mediate-20 (Amazon Prime) +[16]: https://www.amazon.com/dp/B07V35SXMC?tag=chmod7mediate-20&linkCode=ogi&th=1&psc=1 (Buy on Amazon) +[17]: https://buildabroad.org/2016/11/05/passive-cooling/ +[18]: https://i2.wp.com/m.media-amazon.com/images/I/41XGLQONCVS._SL160_.jpg?ssl=1 +[19]: https://www.amazon.com/dp/B07VD568FB?tag=chmod7mediate-20&linkCode=osi&th=1&psc=1 (Geekworm Raspberry Pi 4 Armor Case, Raspberry Pi 4 Computer Model B Armor Aluminum Alloy Passive Cooling Case Compatible with Raspberry Pi 4 Model B Only) +[20]: https://www.amazon.com/dp/B07VD568FB?tag=chmod7mediate-20&linkCode=osi&th=1&psc=1 (Buy on Amazon) +[21]: https://linuxhandbook.com/what-is-devops/ +[22]: https://www.reuters.com/article/global-metals-idUSL1N2Q90GA +[23]: https://news.mit.edu/2018/engineers-turn-plastic-insulator-heat-conductor-0330 diff --git a/published/20211002 Monitor your Java on Linux with jconsole.md b/published/20211002 Monitor your Java on Linux with jconsole.md new file mode 100644 index 0000000000..737b990907 --- /dev/null +++ b/published/20211002 Monitor your Java on Linux with jconsole.md @@ -0,0 +1,104 @@ +[#]: subject: "Monitor your Java on Linux with jconsole" +[#]: via: "https://opensource.com/article/21/10/monitor-java-linux-jconsole" +[#]: author: "Alan Formy-Duval https://opensource.com/users/alanfdoss" +[#]: collector: "lujun9972" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13860-1.html" + +用 jconsole 在 Linux 上监控你的 Java +====== + +> 如何使用 Java 开发工具包中的 Java 监控和管理控制台。 + +![](https://img.linux.net.cn/data/attachment/album/202110/08/131129bf3h3gv18388fl11.jpg) + +Java 开发工具包(JDK)提供了开发 Java 应用程序的二进制文件、工具和编译器。其中一个有用的工具是 `jconsole`。 + +为了演示,我将使用 WildFly J2EE 应用服务器,它是 JBOSS 开源应用服务器项目的一部分。首先,我启动了一个独立的实例。 + +``` +~/wildfly/24.0.1/bin$ ./standalone.sh +========================================================================= +  JBoss Bootstrap Environment +  JBOSS_HOME: /home/alan/wildfly/24.0.1 +  JAVA: /usr/lib/jvm/java-11-openjdk-11.0.11.0.9-5.fc34.x86_64/bin/java +``` + +现在,在另一个终端,输入 `jconsole`。 + +``` +$ jconsole +``` + +启动后,jconsole 会列出本地实例。选择“本地进程Local Process”,然后选择进程的名称并点击“连接Connect”。这就是连接并开始使用运行中的 Java 虚拟机(JVM)的 jconsole 的全部过程。 + +![jconsole 与本地进程的新连接屏幕][2] + +### 概述 + +这个 Java 监控和管理控制台在仪表板的顶部显示进程标识符(PID)。“概述Overview”标签有四个图表,显示“堆内存使用情况Heap Memory Usage”、“线程Threads”、“Classes”和“CPU 使用情况CPU Usage”的重要信息。 + +![jconsole 仪表板显示堆内存使用量、线程、类和 CPU 使用量][4] + +沿着顶部的标签提供每个区域的更详细的视图。 + +### 内存 + +“内存Memory”标签显示 JVM 所使用的内存的各个方面的图表。分配给 JVM 的服务器系统内存量被称为“Heap”。这个屏幕还提供了关于堆的内部组件使用情况的详细信息,例如 “伊甸园Eden Space”、“老年代Old Gen” 和 “幸存者区Survivor Space”。你也可以手动请求一个垃圾收集动作。 + +![jconsole 内存标签][5] + +### 线程 + +“线程Threads”标签显示有多少线程在运行。你也可以手动检查是否存在死锁。 + +![jconsole 线程仪表板显示了随时间变化的线程数量和滚动的线程列表][6] + +### 类 + +“Classes”标签告诉你有多少类被加载,有多少被卸载。 + +![jconsole 类标签显示随着时间推移加载的类数量][7] + +### 虚拟机摘要 + +“虚拟机摘要VM Summary”标签提供了许多关于应用程序和主机系统的细节。你可以了解你所处的操作系统和架构、系统内存总量、CPU 数量,甚至交换空间。 + +![jconsole 虚拟机摘要标签][8] + +摘要中显示的关于 JVM 的进一步细节,包括当前和最大的堆大小以及正在使用的垃圾收集器的信息。底部的窗格列出了传递给 JVM 的所有参数。 + +### MBeans + +最后一个标签,MBeans,让你通过所有的 MBeans 向下钻取,以查看每个 MBeans 的属性和值。 + +![MBeans 标签][9] + +### 总结 + +Java 已经存在了很长时间,它将继续为全球数百万的系统提供动力。有很多开发环境和监控系统可以使用,但像 `jconsole` 这样的包含在基本工具包中的工具非常有价值。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/10/monitor-java-linux-jconsole + +作者:[Alan Formy-Duval][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/alanfdoss +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/puzzle_computer_solve_fix_tool.png?itok=U0pH1uwj (Puzzle pieces coming together to form a computer screen) +[2]: https://opensource.com/sites/default/files/uploads/jconsole_new_connection_local.png (new connection) +[3]: https://creativecommons.org/licenses/by-sa/4.0/deed.ast +[4]: https://opensource.com/sites/default/files/uploads/jconsole_tab_overview.png (tab overview) +[5]: https://opensource.com/sites/default/files/uploads/jconsole_tab_memory.png (memory tab) +[6]: https://opensource.com/sites/default/files/uploads/jconsole_tab_threads.png (threads tab) +[7]: https://opensource.com/sites/default/files/uploads/jconsole_tab_classes.png (classes tab) +[8]: https://opensource.com/sites/default/files/uploads/jconsole_tab_vm-summary.png (VMsummary tab ) +[9]: https://opensource.com/sites/default/files/uploads/jconsole_tab_mbeans.png (MBeans tab) diff --git a/published/20211005 Tools to explore BGP.md b/published/20211005 Tools to explore BGP.md new file mode 100644 index 0000000000..5b9e728692 --- /dev/null +++ b/published/20211005 Tools to explore BGP.md @@ -0,0 +1,364 @@ +[#]: subject: "Tools to explore BGP" +[#]: via: "https://jvns.ca/blog/2021/10/05/tools-to-look-at-bgp-routes/" +[#]: author: "Julia Evans https://jvns.ca/" +[#]: collector: "lujun9972" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13857-1.html" + +由 Facebook 事故引发的 BGP 工具探索 +====== + +![](https://img.linux.net.cn/data/attachment/album/202110/07/093743krr8ftrpvgfrvffx.jpg) + +昨天,Facebook 发生了由 BGP 引起的离线事故。我对学习更多关于 BGP 的知识已经隐约感兴趣了很长时间,所以我阅读了一些文章。 + +我感到很沮丧,因为没有一篇文章告诉我如何在我的电脑上实际查找与 BGP 有关的信息,因此我 [写了一条询问有关工具的推特][1]。 + +我一如既往地得到了一堆有用的回复,所以这篇博文展示了一些你可以用来查询 BGP 信息的工具。这篇文章中可能会有较多的错误,因为我对 BGP 不是很了解。 + +### 我不能发布 BGP 路由 + +我从来没有了解过 BGP 的原因之一是,据我所知,我没有在互联网上发布 BGP 路由的权限。 + +对于大多数网络协议,如果需要,你可以非常轻松地自己实现该协议。例如,你可以: + + * 发行你自己的 TLS 证书 + * 编写你自己的 HTTP 服务器 + * 编写你自己的 TCP 实现 + * 为你的域名编写你自己的权威 DNS 服务器(我现在正在为一个小项目尝试这样做) + * 建立你自己的证书机构(CA) + +但是对于 BGP,我认为除非你拥有自己的 ASN,否则你不能自己发布路由(你*可以*在你的家庭网络上实现 BGP,但这对我来说有点无聊,当我做实验的时候,我希望它们真的在真正的互联网上)。 + +无论如何,尽管我不能用它做实验,但我仍然认为它超级有趣,因为我喜欢网络,所以我将向你展示我找到的一些用来学习 BGP 的工具。 + +首先我们来谈谈 BGP 的一些术语。我打算很快掠过,因为我对工具更感兴趣,而且网上有很多关于 BGP 的高水平解释(比如这篇 [cloudflare 的文章][2])。 + +### AS 是什么? + +我们首先需要了解的是 AS(“自治系统autonomous system”)。每个 AS: + + 1. 由一个组织拥有(通常是一个大型组织,如你的 ISP、政府、大学、Facebook 等)。 + 2. 控制一组特定的 IP 地址(例如,我的 ISP 的 AS 包括 247,808 个 IP 地址)。 + 3. 有一个编号 ASN(如 1403)。 + +下面是我通过做一些实验对 AS 的一些观察: + + * 一些相当大的科技公司并没有自己的 AS。例如,我在 BGPView 上查看了 Patreon,就我所知,他们没有自己的 AS,他们的主要网站(`patreon.com`,[104.16.6.49][3])在 Cloudflare 的 AS 中。 + * 一个 AS 可以包括许多国家的 IP。Facebook 的 AS([AS32934][4])肯定有新加坡、加拿大、尼日利亚、肯尼亚、美国和其他国家的 IP 地址。 + * 似乎 IP 地址可以在一个以上的 AS 中。例如,如果我查找 [209.216.230.240][5],它有 2 个 ASN 与之相关:`AS6130` 和 `AS21581`。显然,当这种情况发生时,更具体的路线会被优先考虑 —— 所以到该 IP 的数据包会被路由到 `AS21581`。 + +### 什么是 BGP 路由? + +互联网上有很多的路由器。例如,我的 ISP 就有路由器。 + +当我给我的 ISP 发送一个数据包时(例如通过运行 `ping 129.134.30.0`),我的 ISP 的路由器需要弄清楚如何将我的数据包实际送到 IP 地址 `129.134.30.0`。 + +路由器计算的方法是,它有一个**路由表**:这是个有一堆 IP 地址范围的列表(比如 `129.134.30.0/23`),以及它知道的到达该子网的路由。 + +下面是一个 `129.134.30.0/23` (Facebook 的一个子网)的真实路由的例子。这不是来自我的 ISP。 + +``` +11670 32934 + 206.108.35.2 from 206.108.35.254 (206.108.35.254) + Origin IGP, metric 0, valid, external + Community: 3856:55000 + Last update: Mon Oct 4 21:17:33 2021 +``` + +我认为这是在说通往 `129.134.30.0` 的一条路径是通过机器 `206.108.35.2`,这是在它的本地网络上。所以路由器接下来可能会把我的 ping 包发送到 `206.108.35.2`,然后 `206.108.35.2` 会知道如何把它送到 Facebook。开头的两个数字(`11670 32934`)是 ASN。 + +### BGP 是什么? + +我对 BGP 的理解非常浅薄,它是一个公司用来公布 BGP 路由的协议。 + +昨天发生在 Facebook 身上的事情基本上是他们发布了一个 BGP 公告,撤销了他们所有的 BGP 路由,所以世界上的每个路由器都删除了所有与 Facebook 有关的路由,没有流量可以到达那里。 + +好了,现在我们已经涵盖了一些基本的术语,让我们来谈谈你可以用来查看 AS 和 BGP 的工具吧! + +### 工具 1:用 BGPView 查看你的 ISP 的 AS + +为了使 AS 这个东西不那么抽象,让我们用一个叫做 [BGPView][6]的 工具来看看一个真实的 AS。 + +我的 ISP(EBOX)拥有 [AS 1403][7]。这是 [我的 ISP 拥有的 IP 地址][8]。如果我查找我的计算机的公共 IPv4 地址,我可以看到它是我的 ISP 拥有的IP地址之一:它在 `104.163.128.0/17` 块中。 + +BGPView 也有这个图,显示了我的 ISP 与其他 AS 的连接情况。 + +![][9] + +### 工具 2:traceroute -A 和 mtr -z + +好了,我们感兴趣的是 AS 。让我们看看我从哪些 AS 中穿过。 + +`traceroute` 和 `mtr` 都有选项可以告诉你每个 IP 的 ASN。其选项分别是 `traceroute -A` 和 `mtr -z`。 + +让我们看看我用 `mtr` 在去 `facebook.com` 的路上经过了哪些 AS! + +``` +$ mtr -z facebook.com + 1. AS??? LEDE.lan + 2. AS1403 104-163-190-1.qc.cable.ebox.net + 3. AS??? 10.170.192.58 + 4. AS1403 0.et-5-2-0.er1.mtl7.yul.ebox.ca + 5. AS1403 0.ae17.er2.mtl3.yul.ebox.ca + 6. AS1403 0.ae0.er1.151fw.yyz.ebox.ca + 7. AS??? facebook-a.ip4.torontointernetxchange.net + 8. AS32934 po103.psw01.yyz1.tfbnw.net + 9. AS32934 157.240.38.75 +10. AS32934 edge-star-mini-shv-01-yyz1.facebook.com +``` + +这很有意思,看起来我们直接从我的 ISP 的 AS(`1403`)到 Facebook 的 AS(`32934`),中间有一个“互联网交换”。 + +> 我不确定 [互联网交换][10]internet exchange(IX)是什么,但我知道它是互联网的一个极其重要的部分。不过这将是以后的事了。我猜是,它是互联网中实现“对等”的部分,就假设它是一个有巨大的交换机的机房,里面有无限的带宽,一堆不同的公司把他们的电脑放在里面,这样他们就可以互相发送数据包。 + +#### mtr 用 DNS 查找 ASN + +我对 `mtr` 如何查找 ASN 感到好奇,所以我使用了 `strace`。我看到它看起来像是在使用 DNS,所以我运行了 [dnspeep][11],然后就看到了! + +``` +$ sudo dnspeep +... +TXT 1.190.163.104.origin.asn.cymru.com 192.168.1.1 TXT: 1403 | 104.163.176.0/20 | CA | arin | 2014-08-14, TXT: 1403 | 104.163.160.0/19 | CA | arin | 2014-08-14, TXT: 1403 | 104.163.128.0/17 | CA | arin | 2014-08-14 +... +``` + +所以,看起来我们可以通过查找 `1.190.163.104.origin.asn.cymru.com` 上的 `txt` 记录找到 `104.163.190.1` 的 ASN,像这样: + +``` +$ dig txt 1.190.163.104.origin.asn.cymru.com +1.190.163.104.origin.asn.cymru.com. 13911 IN TXT "1403 | 104.163.160.0/19 | CA | arin | 2014-08-14" +1.190.163.104.origin.asn.cymru.com. 13911 IN TXT "1403 | 104.163.128.0/17 | CA | arin | 2014-08-14" +1.190.163.104.origin.asn.cymru.com. 13911 IN TXT "1403 | 104.163.176.0/20 | CA | arin | 2014-08-14" +``` + +这很好!让我们继续前进吧。 + +### 工具 3:数据包交换所的观察镜 + +PCH(“数据包交换所packet clearing house”)是运行大量互联网交换点的组织。“观察镜looking glass”似乎是一个通用术语,指的是让你从另一个人的计算机上运行网络命令的 Web 表单。有一些观察镜不支持 BGP,但我只对那些能显示 BGP 路由信息的观察镜感兴趣。 + +这里是 PCH 的观察镜: 。 + +在该网站的 Web 表单中,我选择了多伦多 IX(“TORIX”),因为 `mtr` 说我是用它来访问 `facebook.com` 的。 + +#### 操作 1:显示 ip bgp 摘要 + +下面是输出结果。我修改了其中的一些内容: + +``` +IPv4 Unicast Summary: +BGP router identifier 74.80.118.4, local AS number 3856 vrf-id 0 +BGP table version 33061919 +RIB entries 513241, using 90 MiB of memory +Peers 147, using 3003 KiB of memory +Peer groups 8, using 512 bytes of memory + +Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd +... +206.108.34.248 4 1403 484672 466938 0 0 0 05w3d03h 50 +... +206.108.35.2 4 32934 482088 466714 0 0 0 01w6d07h 38 +206.108.35.3 4 32934 482019 466475 0 0 0 01w0d06h 38 +... + +Total number of neighbors 147 +``` + +我的理解是,多伦多 IX(“TORIX”)直接连接到我的 ISP (EBOX,AS 1403)和 Facebook(AS 32934)。 + +#### 操作 2:显示 ip bgp 129.134.30.0 + +这是筛选自 `show ip bgp` 对 `129.134.30.0`(Facebook 的一个 IP 地址)的输出: + +``` +BGP routing table entry for 129.134.30.0/23 +Paths: (4 available, best #4, table default) + Advertised to non peer-group peers: + 206.220.231.55 + 11670 32934 + 206.108.35.2 from 206.108.35.254 (206.108.35.254) + Origin IGP, metric 0, valid, external + Community: 3856:55000 + Last update: Mon Oct 4 21:17:33 2021 + + 11670 32934 + 206.108.35.2 from 206.108.35.253 (206.108.35.253) + Origin IGP, metric 0, valid, external + Community: 3856:55000 + Last update: Mon Oct 4 21:17:31 2021 + + 32934 + 206.108.35.3 from 206.108.35.3 (157.240.58.225) + Origin IGP, metric 0, valid, external, multipath + Community: 3856:55000 + Last update: Mon Oct 4 21:17:27 2021 + + 32934 + 206.108.35.2 from 206.108.35.2 (157.240.58.182) + Origin IGP, metric 0, valid, external, multipath, best (Older Path) + Community: 3856:55000 + Last update: Mon Oct 4 21:17:27 2021 +``` + +这似乎是在说,从该 IX 到 Facebook 有 4 条路线。 + +**魁北克 IX 似乎对 Facebook 一无所知**。 + +我也试过从魁北克 IX(“QIX”,它可能离我更近,因为我住在蒙特利尔而不是多伦多)做同样的事情。但 QIX 似乎对 Facebook 一无所知:当我输入`129.134.30.0` 时,它只是说 “% 网络不在表中”。 + +所以我想这就是为什么我被送到多伦多 IX 而不是魁北克的 IX。 + +#### 更多的 BGP 观察镜 + +这里还有一些带观察镜的网站,可以从其他角度给你类似的信息。它们似乎都支持相同的 `show ip bgp` 语法,也许是因为他们运行的是同一个软件?我不太确定。 + + * + * + * + +似乎有很多这样的观察镜服务,远不止这 3 个列表。 + +这里有一个与这个列表上的一个服务器进行会话的例子:`route-views.routeviews.org`。这次我是通过 telnet 连接的,而不是通过 Web 表单,但输出的格式看起来是一样的。 + +``` +$ telnet route-views.routeviews.org + +route-views>show ip bgp 31.13.80.36 + +BGP routing table entry for 31.13.80.0/24, version 1053404087 +Paths: (23 available, best #2, table default) + Not advertised to any peer + Refresh Epoch 1 + 3267 1299 32934 + 194.85.40.15 from 194.85.40.15 (185.141.126.1) + Origin IGP, metric 0, localpref 100, valid, external + path 7FE0C3340190 RPKI State valid + rx pathid: 0, tx pathid: 0 + Refresh Epoch 1 + 6939 32934 + 64.71.137.241 from 64.71.137.241 (216.218.252.164) + Origin IGP, localpref 100, valid, external, best + path 7FE135DB6500 RPKI State valid + rx pathid: 0, tx pathid: 0x0 + Refresh Epoch 1 + 701 174 32934 + 137.39.3.55 from 137.39.3.55 (137.39.3.55) + Origin IGP, localpref 100, valid, external + path 7FE1604D3AF0 RPKI State valid + rx pathid: 0, tx pathid: 0 + Refresh Epoch 1 + 20912 3257 1299 32934 + 212.66.96.126 from 212.66.96.126 (212.66.96.126) + Origin IGP, localpref 100, valid, external + Community: 3257:8095 3257:30622 3257:50001 3257:53900 3257:53904 20912:65004 + path 7FE1195AF140 RPKI State valid + rx pathid: 0, tx pathid: 0 + Refresh Epoch 1 + 7660 2516 1299 32934 + 203.181.248.168 from 203.181.248.168 (203.181.248.168) + Origin IGP, localpref 100, valid, external + Community: 2516:1030 7660:9001 + path 7FE0D195E7D0 RPKI State valid + rx pathid: 0, tx pathid: 0 +``` + +这里有几个路由的选择: + + * `3267 1299 32934` + * `6939 32934` + * `701 174 32934` + * `20912 3257 1299 32934` + * `7660 2516 1299 32934` + +我想这些都有不止一个 AS 的原因是,`31.13.80.36` 是 Facebook 在多伦多的 IP 地址,所以这个服务器(可能在美国西海岸,我不确定)不能直接连接到它,它需要先到另一个 AS。所以所有的路由都有一个或多个 ASN。 + +最短的是 `6939`(“Hurricane Electric”),它是一个 “全球互联网骨干”。他们也有自己的 [Hurricane Electric 观察镜][12] 页面。 + +### 工具 4:BGPlay + +到目前为止,所有其他的工具都只是向我们展示了 Facebook 路由的当前状态,其中一切正常,但这第四个工具让我们看到了这个 Facebook BGP 互联网灾难的历史。这是一个 GUI 工具,所以我将包括一堆屏幕截图。 + +该工具在 。我输入了 IP 地址 `129.134.30.12`(Facebook 的一个 IP),如果你想一起试试。 + +首先,让我们看看一切出错之前的状态。我点击了在 10 月 4 日 13:11:28 的时间线,得到了这个结果: + +![][13] + +我最初发现这很让人不知所措。发生了什么事?但后来有人在推特上指出,下一个要看的地方是点击 Facebook 灾难发生后的时间线(10 月 4 日 18 点 38 分)。 + +![][14] + +很明显,这张图有问题:所有的 BGP 路线都不见了!哦,不要! + +顶部的文字显示了最后一条 Facebook BGP 路由的消失: + +``` +Type: W > withdrawal Involving: 129.134.30.0/24 +Short description: The route 50869, 25091, 32934 has been withdrawn. +Date and time: 2021-10-04 16:02:33 Collected by: 20-91.206.53.12 +``` + +如果我再点击“快进fast forward”按钮,我们看到 BGP 路由开始回来了。 + +![][15] + +第一个宣告的是 `137409 32934`。但我不认为这实际上是第一个宣布的,在同一秒内有很多路由宣告(在 2021-10-04 21:00:40),我认为 BGPlay 内部的排序是任意的。 + +如果我再次点击“快进fast forward”按钮,越来越多的路由开始回来,路由开始恢复正常。 + +我发现在 BGPlay 里看这个故障真的很有趣,尽管一开始界面很混乱。 + +### 也许了解一下 BGP 是很重要的? + +我在这篇文章的开头说,你不能改变 BGP 路由,但后来我想起在 2016 年或 2017 年,有一个 [Telia 路由问题][16],给我们的工作造成了一些小的网络问题。而当这种情况发生时,了解为什么你的客户无法到达你的网站其实是很有用的,即使它完全不受你控制。当时我不知道这些工具,但我希望能知道! + +我认为对于大多数公司来说,应对由其他人的错误 BGP 路由造成的中断,你所能做的就是“什么都不做,等待它得到修复”,但能够_自信地_什么都不做是很好的。 + +### 一些发布 BGP 路由的方法 + +如果你想(作为一个业余爱好者)真正发布 BGP 路由,这里有一些评论中的链接: + + * [获取你自己的 ASN 的指南][17] + * [dn42][18] 似乎有一个 BGP 的实验场(它不在公共互联网上,但确实有其他人在上面,这似乎比自己在家里做 BGP 实验更有趣) + +### 目前就这些了 + +我想还有很多 BGP 工具(比如 PCH 有一堆 [路由数据的每日快照][19],看起来很有趣),但这篇文章已经很长了,而且我今天还有其他事情要做。 + +我对我作为一个普通人可以得到这么多关于 BGP 的信息感到惊讶,我一直认为它是一个“秘密的网络巫师”这样的东西,但显然有各种公共机器,任何人都可以直接 telnet 到它并用来查看路由表!没想到! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2021/10/05/tools-to-look-at-bgp-routes/ + +作者:[Julia Evans][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://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://twitter.com/b0rk/status/1445199475195236356 +[2]: https://blog.cloudflare.com/october-2021-facebook-outage/ +[3]: https://bgpview.io/ip/104.16.6.49 +[4]: https://bgpview.io/asn/32934#prefixes-v4 +[5]: https://bgpview.io/ip/209.216.230.240 +[6]: https://bgpview.io +[7]: https://bgpview.io/asn/1403 +[8]: https://bgpview.io/asn/1403#prefixes-v4 +[9]: https://jvns.ca/images/ebox-graph.png +[10]: https://en.wikipedia.org/wiki/Internet_exchange_point +[11]: https://github.com/jvns/dnspeep/ +[12]: https://lg.he.net/ +[13]: https://jvns.ca/images/bgplay-before.png +[14]: https://jvns.ca/images/bgplay-after.png +[15]: https://jvns.ca/images/bgplay-return.png +[16]: https://news.ycombinator.com/item?id=14246888 +[17]: https://labs.ripe.net/author/samir_jafferali/build-your-own-anycast-network-in-nine-steps/ +[18]: https://dn42.eu/Home +[19]: https://www.pch.net/resources/Routing_Data/IPv4_daily_snapshots/ diff --git a/published/20211006 Check Java processes on Linux with the jps command.md b/published/20211006 Check Java processes on Linux with the jps command.md new file mode 100644 index 0000000000..b43db9696d --- /dev/null +++ b/published/20211006 Check Java processes on Linux with the jps command.md @@ -0,0 +1,70 @@ +[#]: subject: "Check Java processes on Linux with the jps command" +[#]: via: "https://opensource.com/article/21/10/check-java-jps" +[#]: author: "Alan Formy-Duval https://opensource.com/users/alanfdoss" +[#]: collector: "lujun9972" +[#]: translator: "unigeorge" +[#]: reviewer: "turbokernel" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13871-1.html" + +在 Linux 上使用 jps 命令检查 Java 进程 +====== + +> 系统上运行着诸多进程,通过 `jps` 命令能够快速有效识别 Java 进程。 + +![](https://img.linux.net.cn/data/attachment/album/202110/11/102806lhhtyalq2lv2vbte.jpg) + +在 Linux 中,有一些用于查看系统上运行进程的命令。进程是指由内核管理的正在进行的事件。每启动一个应用程序时,就会产生一个进程,但也有许多在计算机后台运行的进程,如保持系统时间准确的进程、监听新文件系统的进程、索引化文件的进程等。有一些可以用来监测这些进程的实用程序,比如包含在 [procps-ng 包][2] 中的程序,但它们往往都是对各种进程通用的。它们会查看计算机上的所有进程,你可以根据需要过滤结果列表。 + +在 Linux 中,可以通过 `ps` 命令查看进程。这是查看当前系统上运行进程最简单的方法。 + +``` +$ ps +    PID TTY          TIME CMD +   4486 pts/0    00:00:00 bash +  66930 pts/0    00:00:00 ps +``` + +你也可以通过 `ps` 命令,并配合结果输出管道符进行 `grep`,从而查看系统上运行的 Java 进程,。 + +``` +$ ps ax |grep java + 67604 pts/1 Sl+ 0:18 /usr/lib/jvm/java-11-openjdk-11.0.12.0.7-4.fc34.x86_64/bin/java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true --add-exports=java.desktop/sun.awt=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.management/javax.management=ALL-UNNAMED --add-opens=java.naming/javax.naming=ALL-UNNAMED -Dorg.jboss.boot.log.file=/home/alan/wildfly/24.0.1/standalone/log/server.log -Dlogging.configuration=file:/home/alan/wildfly/24.0.1/standalone/configuration/logging.properties -jar /home/alan/wildfly/24.0.1/jboss-modules.jar -mp /home/alan/wildfly/24.0.1/modules org.jboss.as.standalone -Djboss.home.dir=/home/alan/wildfly/24.0.1 -Djboss.server.base.dir=/home/alan/wildfly/24.0.1/standalone +``` + +然而,OpenJDK 有自己专属的进程监视器。Java 虚拟机进程状态Java Virtual Machine Process Status(jps)工具可以帮你扫描系统上所有运行的 Java 虚拟机(JVM)实例。 + +要想实现与 `ps` 命令类似的输出,可以使用 `-v` 选项。这很实用,这与 `ps` 相比,可以减少你的输入。 + +``` +$ jps -v +67604 jboss-modules.jar -D[Standalone] -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true --add-exports=java.desktop/sun.awt=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.management/javax.management=ALL-UNNAMED --add-opens=java.naming/javax.naming=ALL-UNNAMED -Dorg.jboss.boot.log.file=/home/alan/wildfly/24.0.1/standalone/log/server.log -Dlogging.configuration=file:/home/alan/wildfly/24.0.1/standalone/configuration/logging.properties +``` + +`jps` 命令的默认输出包含进程标识符,类名或 Jar 文件名。 + +``` +$ jps +67604 jboss-modules.jar +69430 Jps +``` + +**注意:** `jps` 的手册页指出此命令是试验性且不受支持的。尽管如此,它仍然是一个不错的选择,因为一个系统通常运行着许多进程,这种只识别 Java 进程的快速方法是很有用的。 + +当下的 Java 仍然是一种流行的语言,所以熟悉 Java 开发工具包和运行时环境仍然很重要。它们包含着许多适用于 Java 应用程序开发和维护的工具。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/10/check-java-jps + +作者:[Alan Formy-Duval][a] +选题:[lujun9972][b] +译者:[unigeorge](https://github.com/unigeorge) +校对:[turbokernel](https://github.com/turbokernel) + +本文由 [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/java-coffee-beans.jpg?itok=3hkjX5We (Coffee beans) +[2]: https://opensource.com/article/21/8/linux-procps-ng diff --git a/published/20211006 DirectX 11-12 Games like Cyberpunk 2077 Can Use NVIDIA DLSS With Proton Experimental on Linux.md b/published/20211006 DirectX 11-12 Games like Cyberpunk 2077 Can Use NVIDIA DLSS With Proton Experimental on Linux.md new file mode 100644 index 0000000000..6ae2ebe009 --- /dev/null +++ b/published/20211006 DirectX 11-12 Games like Cyberpunk 2077 Can Use NVIDIA DLSS With Proton Experimental on Linux.md @@ -0,0 +1,94 @@ +[#]: subject: "DirectX 11/12 Games like Cyberpunk 2077 Can Use NVIDIA DLSS With Proton Experimental on Linux" +[#]: via: "https://news.itsfoss.com/nvidia-dlss-dx-11-12-proton/" +[#]: author: "Rishabh Moharir https://news.itsfoss.com/author/rishabh/" +[#]: collector: "lujun9972" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13865-1.html" + +《赛博朋克 2077》等 DirectX 11/12 游戏可在 Linux 上体验 DLSS 了 +====== + +> 通过 Steam Proton 的实验版本,期待已久的 Nvidia DLSS 支持在 Linux 上的 DirectX 11/12 大作中出现。 + +![](https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/10/nvidia-dlss-proton.png?w=1200&ssl=1) + +6 月,英伟达 [宣布][1] 通过 Steam Proton 支持 Linux 中的 DLSS,并为基于 Vulkan 的游戏提供了测试版驱动程序。 + +DLSS 是指深度学习超级采样Deep Learning Super Sampling。它利用由 RTX GPU 中的 Tensor 核心提供支持的深度学习算法来提升游戏中的图像。这将使图像更清晰、更锐利,并提高帧率。 + +![来源:英伟达][2] + +这种 [升级技术][3] 类似于 AMD 的 Fidelity FX,甚至更接近于英特尔即将推出的 XeSS,与 DLSS 不同的是这两者都是开源的。玩家已经可以通过 [GloriousEggroll][4] 的定制 Proton GE 版本体验到 Fidelity FX。 + +此外,英伟达还计划在今年秋天之前将支持范围扩大到 DirectX 游戏。 + +而且,随着最新的 Proton 实验性支持,这一切终于实现了。使用英伟达 GPU 的 Linux 游戏玩家现在可以用 DLSS 玩他们最喜欢的基于 DX11/12 的游戏。 + +考虑到我们很快就能在 Linux 上玩各种多人游戏,并且 [Proton 中添加了对 BattleEye & Easy-Anti Cheat 的支持][5],这是进行这项添加的最好时机。 + +### Steam Porton 的重大更新 + +几天前,伴随着 Proton 6.3-7 的一波改进,Valve 终于设法将 DLSS 支持添加到 Proton 的 DirectX 11/12 游戏实验分支中。 + +在此之前,需要一个测试版驱动程序才能将 DLSS 用于基于 Vulkan 的游戏,例如 DOOM Eternal。 + +但是,现在不再如此 —— 尽管推荐使用最新的驱动程序。 + +作为补充,DXVK 和 Steamworks SDK 也已经更新到最新的开发版本。此外,还修复了特定游戏的性能问题和其他错误。 + +你可以查看 Proton 的 [官方 GitHub 更新日志][6] 来了解到目前为止支持的所有游戏的改进列表。 + +### 为 DX11/12 游戏启用 DLSS + +启用 DLSS 是一个简单明了的过程。 + +首先,你必须确保你的 Windows 游戏可以在 Proton Experimental 上运行。 + +这可以通过右键点击游戏并选择“属性Properties”来完成。然后在“兼容性Compatibility”下,你需要勾选“强制使用特定的 Steam Play 兼容工具Force the use of a specific Steam Play compatibility tool”复选框。接下来,从下拉菜单中选择 “Proton Experimental”。 + +![][7] + +最后,你需要在“启动选项Launch Options”中插入命令:`PROTON_HIDE_NVIDIA_GPU=0 PROTON_ENABLE_NVAPI=1 %command%` 。 + +![][8] + +这就行了。你就可以用 DLSS 玩你的游戏了! + +### 总结 + +英伟达 DLSS 对于许多游戏来说是一个非常需要的功能,因为它的作用很大。 + +Linux 从一开始就没有对 DLSS 的全面支持。但是,看起来它很快就会在未来的 Proton 稳定版本中提供,并进行必要的改进。 + +Linux 玩家终于可以用基于 RTX 的 GPU 在许多游戏中体验到更好的帧率和视觉质量。 + +虽然我在 AMD 显卡上使用 Fidelity FX,但我仍然渴望在 RTX GPU 上尝试 DLSS! + +你对英伟达 DLSS 的到来有什么感觉?你会很快尝试它吗?欢迎在下面分享你的评论。 + +转自:[GamingOnLinux][9]。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/nvidia-dlss-dx-11-12-proton/ + +作者:[Rishabh Moharir][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://news.itsfoss.com/author/rishabh/ +[b]: https://github.com/lujun9972 +[1]: https://www.nvidia.com/en-us/geforce/news/june-2021-rtx-dlss-game-update/ +[2]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/10/DLSS_RDD2.jpg?w=800&ssl=1 +[3]: https://news.itsfoss.com/intel-xess-open-source/ +[4]: https://github.com/GloriousEggroll/proton-ge-custom +[5]: https://news.itsfoss.com/easy-anti-cheat-linux/ +[6]: https://github.com/ValveSoftware/Proton/wiki/Changelog +[7]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/10/Compatibility.png?w=836&ssl=1 +[8]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/10/Commands-1.png?w=831&ssl=1 +[9]: https://www.gamingonlinux.com/2021/10/proton-experimental-expands-nvidia-dlss-support-on-linux-to-directx-11-titles diff --git a/published/20211010 Best Linux Distributions Based on KDE.md b/published/20211010 Best Linux Distributions Based on KDE.md new file mode 100644 index 0000000000..3c4f2d2fe5 --- /dev/null +++ b/published/20211010 Best Linux Distributions Based on KDE.md @@ -0,0 +1,193 @@ +[#]: subject: "Best Linux Distributions Based on KDE" +[#]: via: "https://itsfoss.com/best-kde-distributions/" +[#]: author: "Ankush Das https://itsfoss.com/author/ankush/" +[#]: collector: "lujun9972" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13872-1.html" + +基于 KDE 的最佳 Linux 发行版 +====== + +![](https://img.linux.net.cn/data/attachment/album/202110/11/115436wngdi7vndoodjnfd.jpg) + +KDE 是目前最具定制性和最快速的桌面环境之一。虽然你可以随时安装 KDE,但最好选择一个 KDE 开箱即用的 Linux 发行版。 + +在这里,让我列出一些最好的基于 KDE 的 Linux 发行版。 + +无论你选择什么作为你的首选发行版,你都可以参考我们的 [KDE 定制指南][1] 来调整你的体验。 + +注意:该列表没有特定的排名顺序。 + +### 1、KDE Neon + +![][2] + +主要亮点: + + * 官方 KDE 发行版 + * 最新的 KDE Plasma 稳定版 + * 专注于最新的 KDE 软件 + * 不是桌面发行版的完美替代品 + +如果你想获得 KDE Plasma 的最新体验,[KDE Neon][4] 是最佳选择之一。 + +即使它是建立在稳定版的 Ubuntu LTS 基础之上,你也总是能在最新的 KDE 版本发布后立即得到交付。 + +与其他发行版不同,它不注重完整的桌面用户体验,而是重点关注在 KDE 软件包上。所以,它可能不是每个人的完美桌面替代品。然而,如果你希望使用最新的 KDE 软件,KDE Neon 是一个不错的选择。 + +其“用户版”应该是你需要的,但如果你愿意尝试预先发布的功能,你也可以选择尝试“测试版”或“不稳定版”。 + +如果你想知道它与 Kubuntu 有什么不同,你应该查看 [KDE Neon vs Kubuntu][3] 的比较来探索它。 + +### 2、Kubuntu + +![][5] + +主要亮点: + + * 基于 Ubuntu 的以桌面为重点的 Linux 发行版 + * 提供 LTS 和非 LTS 版本 + * 良好的硬件兼容性 + +如果 KDE 软件套件不是你关注的重点,那么 Kubuntu 应该是你可以作为 Linux 桌面使用的一个优秀发行版。 + +Kubuntu 是 Ubuntu 的一个官方版本,它为其 LTS 版本提供了三年的更新支持。与 KDE Neon 不同的是,你可以得到对各种应用程序更好的支持,而不仅仅是局限于 KDE 软件。 + +你可以选择 LTS 版或非 LTS 版来获得最新的 Ubuntu 功能。 + +与其他一些基于 KDE 的发行版相比,Kubuntu 具有更好的硬件兼容性。考虑到它可以为各种笔记本电脑提供动力,如 Kubuntu Focus、Slimbook 等,其硬件兼容性是你可以信赖的。 + +### 3、Manjaro KDE + +![][6] + +主要亮点: + + * 基于 Arch 的 Linux 发行版 + * 滚动式发布更新 + * 对于新的 Linux 用户来说学习难度不大 + +Manjaro 是一个基于 Arch Linux 的发行版,它使得使用 Arch 作为桌面 Linux 平台变得容易。 + +它按照滚动发布的时间表进行发布,这应该有助于你快速获得最新的软件包,而不必担心软件更新时间。 + +如果你是一个新的 Linux 用户,你可以考虑一直使用 Flatpak 或 Snaps 来安装各种应用程序。虽然 Manjaro 让你很容易使用 Arch,但它对新用户来说多多少少还是有一点学习曲线。所以,你可能需要查看 [Arch 维基][7] 来了解更多信息。 + +### 4、Fedora KDE Spin + +主要亮点: + + * 一个独特的基于 KDE 的 Linux 发行版(如果你不喜欢主流的 Ubuntu/Arch 发行版) + * 为工作站和服务器量身定做 + * 对于新的 Linux 用户来说可能需要适应 + * 硬件兼容性可能是个问题 + +Fedora 是一个独立的发行版(不基于 Ubuntu/Arch),作为 Red Hat Enterprise Linux 的上游。 + +而 Fedora Spin 版为用户提供了各种备用的桌面。如果你想要 KDE,你需要下载 Fedora 的 KDE Spin。 + +像 KDE Neon 一样,Fedora 并不专注于提供一个最佳的桌面体验,而是旨在实验对工作站或服务器有用的最新技术。 + +因此,如果你有信心解决 Linux 发行版上较新技术实现所带来的任何问题/挑战,[Fedora KDE Spin][8] 是一个不错的选择。 + +### 5、openSUSE + +![][9] + +主要亮点: + + * 适用于需要使用多种工具的系统管理员和开发人员 + * 有两个不同的版本,包括稳定版和滚动版 + +[openSUSE][10] 是另一个独立的 Linux 发行版,默认采用 KDE 桌面。虽然它把自己定位为桌面用户的选择之一,但我在过去曾遇到过硬件兼容性问题。 + +然而,对于想在桌面上使用 YaST、Open Build Service、Kiwi 等工具的系统管理员或开发者来说,它是一个很好的选择,开箱即用。 + +它提供了一个稳定版和一个滚动发布版。根据你的要求选择最适合你的。 + +### 6、Garuda Linux + +![][11] + +主要亮点: + + * 滚动发布的发行版 + * BTRFS 作为默认文件系统 + * 预装了基本的 GUI 工具,使 Arch Linux 的使用变得简单 + +[Garuda Linux][12] 是一个基于 Arch 的现代发行版,专注于开箱即用的定制体验。 + +KDE 版本(或 Dr460nized 版本)提供了漂亮的体验,同时可使用类似 macOS 的工作流程进行调整。 + +当然,如果你是一个有经验的 Linux 用户,你可以定制你现有的发行版来模仿同样的体验。 + +锦上添花的是,Garuda Linux 还提供了其 KDE 版本的不同变体,一个预装了游戏工具,一个用于渗透测试,另一个作为基本的 Linux 桌面系统。 + +### 7、Nitrux OS + +![][13] + +主要亮点: + + * 基于 Debian 的发行版,不同的风格 + * 独特的桌面体验 + +一个基于 Debian 的 Linux 发行版,具有开箱即用的 KDE。与 Kubuntu 不同,Nitrux 最终可能提供的是一个更快的 KDE Plasma 更新和较新的 Linux 内核升级。 + +[Nitrux OS][14] 在以其 NX 桌面为特色的同时,提供了一个美丽而独特的体验。 + +如果你想尝试一些不同的 KDE 搭载,Nitrux OS 将是一个不错的选择。 + +### 8、MX Linux KDE + +![][15] + +主要亮点: + + * 基于 Debian 的发行版 + * 轻量级 + * 预装了有用的 MX 工具 + +不在意外观,但想要一个简单的、可定制的、基于 Debian 的 KDE 桌面?[MX Linux KDE 版][16] 应该是一个很好的选择,因为它以迅捷的性能和预装的基本工具而闻名。 + +如果你想调整默认的用户体验,你还可以得到几个 KDE 主题。 + +### 总结 + +在这个列表之外,其他几个 Linux 发行版也将 KDE 桌面作为他们的首选。 + +总体来说,Nitrux OS 应该是一个独特的选择,如果你想远离基于 Ubuntu 的发行版,还有像 Garuda Linux 和 Manjaro 这样基于 Arch 的可靠发行版可以尝试。 + +你最喜欢的基于 KDE 的 Linux 发行版是什么?你是专注于开箱即用的定制,还是喜欢自己定制 KDE 体验? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/best-kde-distributions/ + +作者:[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/kde-customization +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/08/kde-neon-information-20-04.jpg?resize=800%2C397&ssl=1 +[3]: https://itsfoss.com/kde-neon-vs-kubuntu/ +[4]: https://neon.kde.org/index +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/kubuntu-kde.jpg?resize=800%2C450&ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/manjaro-20-desktop.jpeg?resize=800%2C440&ssl=1 +[7]: https://wiki.archlinux.org +[8]: https://spins.fedoraproject.org/en/kde/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/10/opensuse-kde.png?resize=800%2C423&ssl=1 +[10]: https://www.opensuse.org +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/12/Garuda-Linux-review.png?resize=800%2C450&ssl=1 +[12]: https://garudalinux.org +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/10/nitrux-os-kde.png?resize=800%2C450&ssl=1 +[14]: https://nxos.org +[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/08/mx-linux-19-2-kde.jpg?resize=800%2C452&ssl=1 +[16]: https://mxlinux.org diff --git a/sources/news/20210915 Open-Source Frontend for Emulators -RetroArch- Now Available on Steam for Windows and Linux Users.md b/sources/news/20210915 Open-Source Frontend for Emulators -RetroArch- Now Available on Steam for Windows and Linux Users.md deleted file mode 100644 index 2c34c768a2..0000000000 --- a/sources/news/20210915 Open-Source Frontend for Emulators -RetroArch- Now Available on Steam for Windows and Linux Users.md +++ /dev/null @@ -1,103 +0,0 @@ -[#]: subject: "Open-Source Frontend for Emulators “RetroArch” Now Available on Steam for Windows and Linux Users" -[#]: via: "https://news.itsfoss.com/retroarch-steam/" -[#]: author: "Rishabh Moharir https://news.itsfoss.com/author/rishabh/" -[#]: collector: "lujun9972" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -Open-Source Frontend for Emulators “RetroArch” Now Available on Steam for Windows and Linux Users -====== - -Since its release way back in 2010, [RetroArch][1] has been one of the most popular game emulator interfaces. Over the years, it has received numerous upgrades and lets you play classic games from various retro consoles ranging from the Atari 2600 to the PlayStation 2. - -While the RetroArch team has been planning to launch this on Steam for more than a year, it is finally available to the masses! - -This means you can now emulate and play your favorite retro games without having to leave Steam. - -Sure, you can download it from their official website, but launching it directly from your Steam collection proves to be a hassle-free way for most users. - -Not to forget, RetroArch’s presence on Steam will put this on a lot of people’s radars. So, this should give RetroArch’s popularity a boost on both Windows and Linux platforms. - -![RetroArch on Steam][2] - -Keep in mind that the RetroArch version available on Steam lacks certain features and most cores compared to the official one. Let us take a look at them. - -### Key Highlights - -#### Emulator Cores - -Unlike the standard way of using the _Core Downloader_, Cores (Emulators) can be installed as **DLCs** from Steam. This can be easily done by navigating to **“Manage DLC”** on Steam’s Retroarch browser page. - -Only 10 cores are available at launch. Here’s the list of cores – - - * Mupen64 Plus Next – Nintendo N64 - * Kronos – Sega Saturn - * PCSX ReARMed – PlayStation 1 - * Stella – Atari 2600 - * SameBoy – Game Boy & Game Boy Colour - * mGBA – Game Boy Advance - * Mesen – Nintendo Entertainment System - * Mesen S – Super Nintendo Entertainment System - * Genesis Plus GX – Sega SG-1000, Master System, Game Gear, Genesis and Mega CD - * Final Burn Neo – Arcade - - - -Additional cores will certainly be released in the future. According to the developer: - -> More cores will be coming as DLC soon. We have no ETA on when these will arrive, but it will likely be a dripfeed of new cores on a periodic basis as it takes a lot of time preparing the pages, descriptions, logos, previews and whatnot that a Steam page requires. - -RetroArch Blog - -![Retroarch Main Menu \(Source: Retroarch\)][3] - -#### Other Highlights - -RetroArch UI stays the same. This may be overwhelming for users who will be using RetroArch for the first time. The developers have plans to revamp its UI soon enough. - -Remote Play and Steam Cloud sync should also work. - -Do note that RetroArch will only be available for 64-bit Linux or Windows PCs. As of now, there are no plans for macOS yet. - -You can learn more about RetroArch’s availability on Steam on their [official blog post][4]. - -### Wrapping Up - -The addition of RetroArch to Steam will certainly increase their userbase. Initial reviews seem to be very positive, which is a good thing! - -They should get better financial support from new users on [Patreon][5] as well. You might as well start helping them out if interested. - -If you want to try it out, head to your Steam client and search for it. Or, click on the link below to explore it on Steam store along with its system requirements. - -[RetroArch on Steam][6] - -**Via**: [GamingOnLinux][7] - -#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! - -If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. - -I'm not interested - --------------------------------------------------------------------------------- - -via: https://news.itsfoss.com/retroarch-steam/ - -作者:[Rishabh Moharir][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://news.itsfoss.com/author/rishabh/ -[b]: https://github.com/lujun9972 -[1]: https://www.retroarch.com/ -[2]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjM3NSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= -[3]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQyOSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= -[4]: https://www.libretro.com/index.php/retroarch-finally-released-on-steam/ -[5]: https://www.patreon.com/libretro -[6]: https://store.steampowered.com/app/1118310/RetroArch/ -[7]: https://www.gamingonlinux.com/2021/09/retroarch-gets-a-steam-release-bringing-emulation-to-even-more-gamers diff --git a/sources/news/20210917 After Chromium, Ubuntu Now Converts Firefox to Snap by Default.md b/sources/news/20210917 After Chromium, Ubuntu Now Converts Firefox to Snap by Default.md deleted file mode 100644 index afd9c82492..0000000000 --- a/sources/news/20210917 After Chromium, Ubuntu Now Converts Firefox to Snap by Default.md +++ /dev/null @@ -1,86 +0,0 @@ -[#]: subject: "After Chromium, Ubuntu Now Converts Firefox to Snap by Default" -[#]: via: "https://news.itsfoss.com/ubuntu-firefox-snap-default/" -[#]: author: "Abhishek https://news.itsfoss.com/author/root/" -[#]: collector: "lujun9972" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -After Chromium, Ubuntu Now Converts Firefox to Snap by Default -====== - -One of the major and controversial [changes in the upcoming Ubuntu 21.10][1] is the conversion of Firefox from deb to snap. - -Yes, you heard it right. The default Firefox will be a Snap application, not the regular DEB version. - -As [spotted by OMG! Ubuntu][2], this is done as per an agreement between Mozilla and Canonical (Ubuntu’s parent company). - -The [feature freeze exception (FFE)][3] mentions it clearly: - -> Per Canonical’s distribution agreement with Mozilla, we’re making the snap the default installation of Firefox on desktop ISOs starting with Ubuntu 21.10. - -With this change, the Firefox deb package will be converted to Firefox snap package. - -This means that going forward, Firefox will be available as Snap. I think this change also means that even if you use apt command to install it, you’ll be getting the Snap package. - -### Deja vu? - -If you feel that this has been done in the past, you have got the right feeling. In the past, Ubuntu converted the Chromium browser to Snap. - -Today, if you use apt install chromium-browser, you still get the Snap version. There is no DEB package for Chromium in Ubuntu anymore. - -When Ubuntu made this sudden change on its own, there was an uproar. The conversion of Firefox to Snap will also create controversy. But this time, Ubuntu shares the blame with Mozilla. - -### Mozilla wants Snap - -![][4] - -Interestingly, it was [Mozilla that approached Canonical for this change][5]. Mozilla will maintain the Snap version of Firefox and the end users will get quick updates directly from the source. - -After all, it takes a few days before a new Firefox release lands in Ubuntu. With the Snap move, your Firefox will be updated to the new version the same day. - -### Concerns? - -A few for sure. I know there are a few people completely averted to Snap, I am not one of them. - -I have three major complaints with Snap packages: slow start up speed, poor system integration and high disk space. - -Over the time, Snaps have improved on the disk space front. But despite all the improvements, Snap packages still take longer to start. This could be tolerable with an IDE but it may ruin the browsing experience. - -This slow startup speed makes me wonder why it is called ‘Snap’ because surely, it doesn’t start in a snap. - -Another thing that bothers me is the Snap auto-refresh. Snap apps are updated automatically. If Mozilla starts pushing updates more frequently, this [Firefox restart annoyance][6] in the middle of work will be more frequently as well. - -![][7] - -The change will impact you when you install or upgrade to Ubuntu 21.10. The change will eventually propagate to Ubuntu 22.04 LTS. - -What do you think of this change? Yeah or neah? - -#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! - -If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. - -I'm not interested - --------------------------------------------------------------------------------- - -via: https://news.itsfoss.com/ubuntu-firefox-snap-default/ - -作者:[Abhishek][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://news.itsfoss.com/author/root/ -[b]: https://github.com/lujun9972 -[1]: https://news.itsfoss.com/ubuntu-21-10-release-schedule/ -[2]: https://www.omgubuntu.co.uk/2021/09/ubuntu-makes-firefox-snap-default -[3]: https://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+bug/1943840 -[4]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjI1NCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= -[5]: https://discourse.ubuntu.com/t/feature-freeze-exception-seeding-the-official-firefox-snap-in-ubuntu-desktop/24210 -[6]: https://news.itsfoss.com/mozilla-annoying-new-tab/ -[7]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjMwOCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= diff --git a/sources/news/20210917 Linux Mint-s Website Has a Much Needed Minty Fresh New Look.md b/sources/news/20210917 Linux Mint-s Website Has a Much Needed Minty Fresh New Look.md deleted file mode 100644 index 8458af1ffe..0000000000 --- a/sources/news/20210917 Linux Mint-s Website Has a Much Needed Minty Fresh New Look.md +++ /dev/null @@ -1,65 +0,0 @@ -[#]: subject: "Linux Mint’s Website Has a Much Needed Minty Fresh New Look" -[#]: via: "https://news.itsfoss.com/linux-mint-new-website-design/" -[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" -[#]: collector: "lujun9972" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -Linux Mint’s Website Has a Much Needed Minty Fresh New Look -====== - -Linux Mint is one of the [best Linux distributions][1] available while offering a modern user experience. - -However, Linux Mint’s original website looked dated and potentially unattractive to new-age computer users. - -Many suggested a visual makeover to reflect Linux Mint’s taste through a modern website design. And, only recently the developers started working on a redesign in collaboration with the community members, asking for feedback and getting insights on proposed designs. - -Finally, a design was finalized and applied to [Linux M][2][i][2][nt’s official website][2]. - -The website looks clean and informative, great on desktop, and perfectly fits mobile phone browsers! - -![][3] - -Every new Linux user should be able to evaluate their requirements by looking at the features offered easily. - -The information is well-presented to convince users why they should try out Linux Mint on their desktop system. - -![][4] - -The key highlights of the website would be the homepage, download page, and donation page. - -Of course, you can choose to explore more about Linux Mint and how everything works through individual resources (like our articles), but the official website should be the essential starting point, which it is now. - -The accent color and the theme combination feels just like what Linux Mint needed! Navigating through various web pages and the menu is a breeze. I don’t think there is any unnecessary element on the website; everything fits perfectly in the first look. The page load time is faster as well. - -The blog/monthly news section continues to use the same design. And, I’m not certain if they intend to refresh that by applying the same design anytime soon. But, I think that should happen to ensure consistency between their web pages. - -_What do you think about Linux Mint’s new website design? Do you like it? Do you think this would help them get more attention from new-age users?_ - -_You are welcome to share your thoughts in the comments down below._ - -### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! - -If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. - -I'm not interested - --------------------------------------------------------------------------------- - -via: https://news.itsfoss.com/linux-mint-new-website-design/ - -作者:[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://news.itsfoss.com/author/ankush/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/best-linux-distributions/ -[2]: https://linuxmint.com -[3]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjUzOSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= -[4]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjUzMSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= diff --git a/sources/news/20210922 Ubuntu Touch OTA-19 Brings in Support for New Devices With Multiple Bug Fixes.md b/sources/news/20210922 Ubuntu Touch OTA-19 Brings in Support for New Devices With Multiple Bug Fixes.md deleted file mode 100644 index ee950086fa..0000000000 --- a/sources/news/20210922 Ubuntu Touch OTA-19 Brings in Support for New Devices With Multiple Bug Fixes.md +++ /dev/null @@ -1,80 +0,0 @@ -[#]: subject: "Ubuntu Touch OTA-19 Brings in Support for New Devices With Multiple Bug Fixes" -[#]: via: "https://news.itsfoss.com/ubuntu-touch-ota-19/" -[#]: author: "Rishabh Moharir https://news.itsfoss.com/author/rishabh/" -[#]: collector: "lujun9972" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -Ubuntu Touch OTA-19 Brings in Support for New Devices With Multiple Bug Fixes -====== - -Ubuntu Touch is an open-source OS for mobile devices that respects user privacy, unlike Google’s Android for privacy-focused users. The UBports community has released yet another update of Ubuntu Touch that is based on Ubuntu 16.04. - -This release supports many new devices and contains significant updates on certain phones, along with numerous bug fixes. - -Let’s take a look at them. - -![Source: UBports][1] - -### What’s New? - -#### Framework and Packages - -The 16.04.7 Qt framework and packages like qml-module-qtwebview and libqt5webview5-dev have been added to the App framework. This improves application compatibility with other platforms. - -#### Imrpovements to Halium devices - -The gyroscope and magnetic field sensors can now be accessed on the Halium 5.1 and 7.1 devices. Do note that the functionality of the compass is still under development. The same applies to the magnetic field sensor for the Halium 9 and 10 devices that now use sensorfw, thus replacing the legacy platform-API. - -#### Pixel 3a - -You can completely shut down the device as intended. It no longer hangs in the process of the shutdown, so you should have better battery life. Additionally, the freezing of the camera app while capturing sounds when recording videos has also been fixed. - -#### Messaging App Fix - -The messaging app has also received a minor update. When messages arrive, the keyboard will no longer appear automatically but when needed. This is useful if the user doesn’t want to reply or access the keyboard on demand. - -#### Media Hub - -A bug that prevented the device from sleep when audio sounds were played in successions has been fixed. Another major bug that reduced battery life drastically, because of uncleared requested wake locks, has also been taken care of. - -### Other Improvements - -There are several new devices added to support Ubuntu Touch, along with fixes for the Wi-Fi, audio, and camera. - -You can look at the [official release notes][2] to check the list of devices added and explore more technical details. - -### Update or Installation - -Ubuntu Touch users should automatically receive an update or head to the updates in the System Settings to check for available updates. - -Those willing to try out Ubuntu Touch for the first time can explore the [official website][3] and check if their device is supported correctly before installation. - -I am particularly looking forward to the Ubuntu Touch OS update with Ubuntu 18.04 or newer as its base after several minor updates. - -_What do you think about this new update? Have you tried it yet?_ - -#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! - -If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. - -I'm not interested - --------------------------------------------------------------------------------- - -via: https://news.itsfoss.com/ubuntu-touch-ota-19/ - -作者:[Rishabh Moharir][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://news.itsfoss.com/author/rishabh/ -[b]: https://github.com/lujun9972 -[1]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQyMiIgd2lkdGg9IjM0MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= -[2]: https://ubports.com/blog/ubports-news-1/post/ubuntu-touch-ota-19-release-3779 -[3]: https://ubuntu-touch.io/get-ubuntu-touch diff --git a/sources/news/20210929 SuperTuxKart 1.3 Release- Open Source Game for Linux Adds Switch Support.md b/sources/news/20210929 SuperTuxKart 1.3 Release- Open Source Game for Linux Adds Switch Support.md new file mode 100644 index 0000000000..a953f29b63 --- /dev/null +++ b/sources/news/20210929 SuperTuxKart 1.3 Release- Open Source Game for Linux Adds Switch Support.md @@ -0,0 +1,88 @@ +[#]: subject: "SuperTuxKart 1.3 Release: Open Source Game for Linux Adds Switch Support" +[#]: via: "https://news.itsfoss.com/supertuxkart-1-3-release/" +[#]: author: "Rishabh Moharir https://news.itsfoss.com/author/rishabh/" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +SuperTuxKart 1.3 Release: Open Source Game for Linux Adds Switch Support +====== + +One of the most popular open-source games, SuperTuxKart, has finally received a significant update after a gap of almost a year. It is a free and cross-platform 3D kart-racing game available for Linux, macOS, Windows, and Android. + +Just like Mario Kart, you can choose from a vast catalog of characters (based on mascots of open-source projects) racing in unique karts using special items to win races in various arenas. The game also features various racing modes, including a story Mode and an online Mode, to keep you engaged. + +Let us see what’s new with the latest release. + +### Nintendo Switch Port + +![Source: blog.supertuxkart.net][1] + +SuperTuxKart is now (unofficially) playable on the Switch. This has been possible due to the SDL2 implementation that was already used in the previous 1.2 release. To play the game, you will need to have **Homebrew** installed on your console. + +Moreover, the game also supports force feedback for the Joy-Cons and other controllers. This will undoubtedly make the game more lively whenever there are effects on-screen. + +### New Arenas + +Two new arenas — Ancient Colosseum Labyrinth and Alien Signal — have been introduced. + +![Source: blog.supertuxkart.net][2] + +The Ancient Colosseum Labyrinth is based on the Roman Colosseum with a dark setting and a secret tunnel. On the other hand, the Alien Signal is another arena inspired by a SETI-styled location with strange markings on the ground. + +The Las Dunas Soccer Stadium has also been updated and now houses a symmetrical soccer field. + +Lastly, lap line extensions have been added to various tracks. This means the lap will be counted even if you drive slightly off the main road. + +### GUI Improvements + +A major feature that will improve the gameplay experience is the introduction of **render resolution**. Using the slider, you can sacrifice the resolution for better frame rates on low-end systems. + +The high score selection screen now has its independent menu and displays the best times for normal races, egg hunts, and time trials. + +You can also open links in the game. Specifically, the links in a text/instruction that pops up in the game. This is possible, thanks to the SDL2 SDL_OpenURL. + +Blender 2.8 was officially used by artists to create tracks, maps, and more. + +### Redesigned Karts + +![Source: blog.supertuxkart.net][3] + +Your favorite characters like GNU, Adiumy and Emule have undergone visual changes. Sara the Racer is now replaced by Pepper, the mascot of Pepper&Carrot. + +You can refer to the [official release notes][4] for detailed information about the update. + +[Download SuperTuxKart 1.3][5] + +### Wrapping Up + +Overall, SuperTuxKart 1.3 has brought in exciting changes and fixes. Nintendo Switch users will now have something fresh to try out and play! + +What do you think about this release? Will you be willing to try it out on your Switch? Do share your thoughts below. + +#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! + +If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. + +I'm not interested + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/supertuxkart-1-3-release/ + +作者:[Rishabh Moharir][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://news.itsfoss.com/author/rishabh/ +[b]: https://github.com/lujun9972 +[1]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjczMiIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[2]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjM2NSIgd2lkdGg9IjY0OSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[3]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjI2NCIgd2lkdGg9IjI0MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[4]: https://blog.supertuxkart.net/2021/09/supertuxkart-13-release.html +[5]: https://github.com/supertuxkart/stk-code/releases/tag/1.3 diff --git a/sources/news/20211003 Open Source Changed Linux Otherwise It Was Done- Linus Torvalds.md b/sources/news/20211003 Open Source Changed Linux Otherwise It Was Done- Linus Torvalds.md new file mode 100644 index 0000000000..2f3d727a51 --- /dev/null +++ b/sources/news/20211003 Open Source Changed Linux Otherwise It Was Done- Linus Torvalds.md @@ -0,0 +1,59 @@ +[#]: subject: "Open Source Changed Linux Otherwise It Was Done: Linus Torvalds" +[#]: via: "https://news.itsfoss.com/open-source-changed-linux-torvalds/" +[#]: author: "Abhishek https://news.itsfoss.com/author/root/" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Open Source Changed Linux Otherwise It Was Done: Linus Torvalds +====== + +You probably already know the story. 30 years ago, Finnish student Linus Torvalds created a UNIX-like operating system as a hobby project. + +What you do not know is that Torvalds thought that the hobby project was done, and he would have left it behind to work on some new and interesting project. + +So, what made his work on this ‘hobby project’ for 30 years? The answer is open source. + +### Open source changed Linux + +At the recently concluded [Open Source Summit North America event][1], Linus Torvalds shared some insights into the past, present and future of the Linux project. + +While remembering the beginning of the project, [Torvalds said][2] that he’d expected to leave behind Linux in a ‘done state’ to work for something new and interesting. + +> That was clearly then what open source changed. Because suddenly this project — that I probably would’ve left behind, if it was only up to me — I started getting questions about, and eventually patches — that just kept the motivation going. And here we are 30 years later, and it’s still what keeps the motivation going. + +Torvalds also added that as far as he is concerned, Linux is done for the past 29 years. Every other feature that has been added later is about what other people needed, wanted or were interested in. + +Many developers would relate to this. You work on a project and think that it has reached a ‘done’ state. If the project does not get enough traction, you lose interest to work on it and move to something ‘new and exciting’. The real motivation to continue the project comes from the users and the recognition. + +When asked about what they should be doing for the 50th anniversary of Linux, Torvalds said that he doesn’t see himself doing kernel programming at the age of 70. Then he also chipped in that he didn’t imagine himself doing kernel programming at the age of 50 as well and yet he is doing that at present. + +> “Somehow I don’t see myself doing kernel programming when I’m 70. But on the other hand, I didn’t see myself doing kernel programming when I was 50 either, a few years back. So… we’ll see.” + +It is always endearing to listen to Torvalds talking about Linux. So much to learn and to relate as an ardent Linux user, right? + +_Source: [The News Stack][2]_ + +#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! + +If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. + +I'm not interested + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/open-source-changed-linux-torvalds/ + +作者:[Abhishek][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://news.itsfoss.com/author/root/ +[b]: https://github.com/lujun9972 +[1]: https://events.linuxfoundation.org/open-source-summit-north-america/ +[2]: https://thenewstack.io/linus-torvalds-on-community-rust-and-linuxs-longevity/ diff --git a/sources/news/20211004 It Seems Pop OS Linux Will Soon be Available on Raspberry Pi and Other ARM Devices.md b/sources/news/20211004 It Seems Pop OS Linux Will Soon be Available on Raspberry Pi and Other ARM Devices.md new file mode 100644 index 0000000000..7a5d77b46d --- /dev/null +++ b/sources/news/20211004 It Seems Pop OS Linux Will Soon be Available on Raspberry Pi and Other ARM Devices.md @@ -0,0 +1,79 @@ +[#]: subject: "It Seems Pop OS Linux Will Soon be Available on Raspberry Pi and Other ARM Devices" +[#]: via: "https://news.itsfoss.com/pop-os-raspberry-pi-coming-soon/" +[#]: author: "Abhishek https://news.itsfoss.com/author/root/" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +It Seems Pop OS Linux Will Soon be Available on Raspberry Pi and Other ARM Devices +====== + +There was a time when only lightweight [operating systems were available for ARM devices like Ra][1]spberry Pi. Why? Because earlier ARM devices had low end hardware with limited RAM and CPU. + +It all changed when Raspberry Pi 4 targeted desktop users with its 8 GB variant and doubled down on it with the introduction of Raspberry Pi 400. + +This resulted in bringing the support of mainstream desktop Linux distributions to Raspberry Pi. Thanks to that, you can now [install Ubuntu desktop on Raspberry Pi][2]. + +Since Ubuntu desktop now supports ARM devices, other Ubuntu-based distros should join the ARM bandwagon soon. And it seems Pop!_OS is ready to board it. + +### Pop OS coming soon on Raspberry Pi! + +System76’s Principal Engineer and maintainer of Pop!_OS, Jeremy Soller shared a teaser photo on Twitter recently. The image is basically a screenshot of Neofetch running in terminal. + +> [pic.twitter.com/ehfGXwtsBf][3] +> +> — Jeremy Soller (@jeremy_soller) [September 28, 2021][4] + +If you look closely, you can see that some details that indicate that it is running on a Raspberry Pi device. + +![][5] + +The host name indicates Raspberry Pi and so does the BCM2835 CPU (chip used on Raspberry Pi devices). You can also notice the aarch64 in the OS name. + +In addition to that, Jeremy also shared a repository link that contains Pop OS packages for ARM devices. Here’s the [link][6]. + +> 😉 +> +> — Jeremy Soller (@jeremy_soller) [September 28, 2021][7] + +### How soon? + +There is no other information available from Systm76 on this front. But if I have to make a guess, I would say that the upcoming Pop!_OS 21.10 version will have an ARM version for Raspberry Pi like devices. + +This is not a blind guess. The ARM repository link shared by Jeremy clearly mentions ‘impish’ in its directory structure. Impish Indri is the codename for the upcoming [Ubuntu 21.10 slated for release][8] on 14th October. + +Pop!_OS 21.10 follows the release of Ubuntu 21.10 and should be released soon afterwards. All this gives us enough clue to surmise that Pop!_OS is coming to Raspberry Pi devices this month. + +This is indeed a good thing because Pop!_OS is popular among developers. This could mean more developers using Raspberry Pi as their development environment. + +I am delighted to see this development. How about you? + +#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! + +If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. + +I'm not interested + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/pop-os-raspberry-pi-coming-soon/ + +作者:[Abhishek][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://news.itsfoss.com/author/root/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/raspberry-pi-os/ +[2]: https://itsfoss.com/install-ubuntu-desktop-raspberry-pi/ +[3]: https://t.co/ehfGXwtsBf +[4]: https://twitter.com/jeremy_soller/status/1442977756623429640?ref_src=twsrc%5Etfw +[5]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQ2OCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[6]: https://apt.pop-os.org/release/dists/impish/main/binary-arm64/ +[7]: https://twitter.com/jeremy_soller/status/1442976088053796870?ref_src=twsrc%5Etfw +[8]: https://news.itsfoss.com/ubuntu-21-10-release-schedule/ diff --git a/sources/news/20211005 GNOME 42 to Introduce a System-wide Dark Style Preference, Thanks to elementary OS.md b/sources/news/20211005 GNOME 42 to Introduce a System-wide Dark Style Preference, Thanks to elementary OS.md new file mode 100644 index 0000000000..de58e11b9a --- /dev/null +++ b/sources/news/20211005 GNOME 42 to Introduce a System-wide Dark Style Preference, Thanks to elementary OS.md @@ -0,0 +1,79 @@ +[#]: subject: "GNOME 42 to Introduce a System-wide Dark Style Preference, Thanks to elementary OS" +[#]: via: "https://news.itsfoss.com/gnome-42-dark-style-preference/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +GNOME 42 to Introduce a System-wide Dark Style Preference, Thanks to elementary OS +====== + +There’s still time for GNOME 42, but it looks like it will implement a system-wide dark mode preference similar to [elementary OS 6][1]. + +If you have been reading our coverages, you must have noticed mentioning it as one of the [best elementary OS 6 features][2]. + +And for all the right reasons. Unlike a GTK theme change, elementary OS 6 approached the dark style preference as an opt-in preference that application developers can detect and choose to respect. + +Even though this means that there’s more to be expected from the app developers, but when successful, it should result in a consistent dark mode experience. + +In a [blog post][3] by GNOME developer _Alex_, he mentioned that GNOME would be following elementary OS’s approach while making it a standard to introduce a system-wide dark style preference in GNOME 42. + +### Consistent Dark Mode Experience Even with Flatpak Sandbox + +When it comes to a GTK theme, it is often a problem for Flatpak applications to inherit it because of the sandboxing. + +However, with an implementation planned for GNOME 42, any application (including Flatpak apps) can access the settings portal and know the dark style preference without cutting down the security provided by the sandboxing. + +This work aims to ensure that every type of application (built with any toolkit) and on any desktop should be able to detect and respect the dark style preference. + +The only difference between elementary OS and GNOME’s implementation will be the use of libadwaita API with GNOME 42. You may want to check out an older [blog post][4] by Adrien, another GNOME developer, to know more about Libadwaita. + +Alex also shared a video giving a sneak peek at how the transitions may look like (which is, of course, a work in progress). + +![][5] + +As you can notice, application developers need to update their applications to respect this preference to make the switch/transition from light/dark mode a seamless experience. + +And, further, to bring this change to GNOME 42, there is a couple of significant development work remaining: + + * A preference option in the settings menu that’s easy to use (probably under “Background/Appearance” settings) + * A switch in gnome-shell to quickly toggle the preference + * Day/night scheduling option + * A dark mode version of the wallpaper synchronized to the preference + + + +### Wrapping Up + +The core and first-party applications will have to support the dark style preference before GNOME 42 release to kick things off. + +While third-party developers should also get on the bandwagon, given the difference this makes, it would take time for all your essential/favorite tools to support it. + +_What do you think about GNOME 42 bringing a system-wide dark mode preference, following the footsteps of elementary OS? You are welcome to share your thoughts in the comments down below_. + +#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! + +If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. + +I'm not interested + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/gnome-42-dark-style-preference/ + +作者:[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://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://news.itsfoss.com/elementary-os-6-release/ +[2]: https://news.itsfoss.com/elementary-os-6-features/ +[3]: https://blogs.gnome.org/alexm/2021/10/04/dark-style-preference/ +[4]: https://aplazas.pages.gitlab.gnome.org/blog/blog/2021/03/31/introducing-libadwaita.html +[5]: https://i0.wp.com/i.ytimg.com/vi/urXch15ySGU/hqdefault.jpg?w=780&ssl=1 diff --git a/sources/news/20211008 Feren OS 2021.10 Release Introduces a New Firefox Configuration and UI Improvements.md b/sources/news/20211008 Feren OS 2021.10 Release Introduces a New Firefox Configuration and UI Improvements.md new file mode 100644 index 0000000000..863cd52336 --- /dev/null +++ b/sources/news/20211008 Feren OS 2021.10 Release Introduces a New Firefox Configuration and UI Improvements.md @@ -0,0 +1,93 @@ +[#]: subject: "Feren OS 2021.10 Release Introduces a New Firefox Configuration and UI Improvements" +[#]: via: "https://news.itsfoss.com/feren-os-2021-10-release/" +[#]: author: "Omar Maarof https://news.itsfoss.com/author/omar/" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Feren OS 2021.10 Release Introduces a New Firefox Configuration and UI Improvements +====== + +Feren OS is a Linux/GNU distribution based on Ubuntu. + +The latest 2021.10 release, codenamed ‘Gallium’, presents new features and changes. Let’s take a look at them. + +### Feren OS 2021.10: What’s New? + +#### A New Configuration For Mozilla Firefox + +![][1] + +Feren OS 2021.10 aims to offer a hassle-free Mozilla web browsing experience by removing the unnecessary elements of the browser. + +For new users, Mozilla Firefox comes pre-installed with a new configuration. Things like [removing the title bar from Mozilla Firefox][2], getting rid of distractions in a new tab, are some of the configurations made. + +Overall, these are the changes made to Firefox: + + * Compact Mode and no title bar by default + * No Pocket by default + * The Library is now in the toolbar (as was intended by Mozilla themselves during early Proton design ideas) instead of Pocket’s button + * Skipped Welcome Screens to allow you to get right into the action + + + +If you have never launched Firefox (or have a fresh install of Feren OS), you will get the configuration out-of-the-box. In either case, you will have to install the **firefox-config-feren** package from the web browser manager. + +#### New Splash Screen + +The new update comes with a redesigned splash screen. As a consequence, now it looks smoother and more elegant, especially when transitioning from the login screen to the desktop. + +![][3] + +#### Refreshed Lock Screen + +The new lock screen is a mixture of the Feren OS login screen’s design style and KDE plasma’s lock screen features. + +![Feren OS 2021.10 Lock Screen][4] + +As a result, it combines elegance and functionality. From the lock screen, you will have access to your music, a virtual keyboard, and more. + +![Feren OS 2021.10 Login Screen][4] + +#### New Wallpapers + +With every new release, you can notice some new wallpapers. And, Feren OS 2021.10 is no exception. + +Some interesting wallpapers have been added from sources like Unsplash and some were removed. + +### Upgrading & Downloading + +You should be easily able to get the new update from the update manager. In case you run into issues, you can refer to the [official blog post][5] for a solution to fix the most common problem encountered when updating. + +For more details on this release, refer to [the official announcement][6]. + +[Download Feren OS 2021.10][7] + +#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! + +If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. + +I'm not interested + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/feren-os-2021-10-release/ + +作者:[Omar Maarof][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://news.itsfoss.com/author/omar/ +[b]: https://github.com/lujun9972 +[1]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQzOSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[2]: https://itsfoss.com/remove-title-bar-firefox/ +[3]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjM5MyIgd2lkdGg9IjcwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[4]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjM1OCIgd2lkdGg9IjcwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[5]: https://medium.com/feren-os/the-repository-keyring-expired-heres-how-to-renew-it-bd50dd874aac +[6]: https://medium.com/feren-os/feren-os-2021-10-iterative-improvements-993aab5dba51 +[7]: https://ferenos.weebly.com/get-feren-os.html diff --git a/sources/news/20211008 TUXEDO-s Linux Gaming Ultrabook -InfinityBook Pro 14- Now Sports an RTX 3050 Ti and 3K Display.md b/sources/news/20211008 TUXEDO-s Linux Gaming Ultrabook -InfinityBook Pro 14- Now Sports an RTX 3050 Ti and 3K Display.md new file mode 100644 index 0000000000..019b613536 --- /dev/null +++ b/sources/news/20211008 TUXEDO-s Linux Gaming Ultrabook -InfinityBook Pro 14- Now Sports an RTX 3050 Ti and 3K Display.md @@ -0,0 +1,85 @@ +[#]: subject: "TUXEDO’s Linux Gaming Ultrabook “InfinityBook Pro 14” Now Sports an RTX 3050 Ti and 3K Display" +[#]: via: "https://news.itsfoss.com/tuxedos-infinitybook-14/" +[#]: author: "Rishabh Moharir https://news.itsfoss.com/author/rishabh/" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +TUXEDO’s Linux Gaming Ultrabook “InfinityBook Pro 14” Now Sports an RTX 3050 Ti and 3K Display +====== + +Tuxedo has recently unveiled its latest and exciting revision to its InfinityBook Pro 14. Despite weighing just around one kg, this sleek-looking ultrabook packs in impressive specs and can pretty much run various AAA games. Let’s take a look at what this laptop has to offer. + +### Updated Specifications + +![Source: Tuxedo][1] + +#### Processor Upgrade + +The refreshed offering has updated the processors to high-performance **Intel Core i5-11300H and Core i7-11370H** instead of the power-saving chips in the previous iteration. + +In case you didn’t know, the performance-oriented chips can utilize up to 60 watts (TDP) to provide you the enhanced performance. + +#### New-Gen RTX Graphics + +As for the graphics side, you’ll find NVIDIA’s mid-range **GeForce RTX 3050 Ti** along with the integrated Iris Xe graphics. This is a power-efficient MaxQ variant that promises a TGP of 35 watts. + +Considering this as a mid-tier GPU, it should be enough for gaming with 1080p settings. + +Do note there are no 3050ti available in the market separately. It is currently limited to OEMs/laptops. + +This graphics card is very beneficial for gamers on the go as it supports NVIDIA’s DLSS, like all RTX GPUs, for a stepped-up gaming experience. + +Also, it’s never been a better time because Linux gamers can now [enable DLSS for DX11/12 and Vulkan-based games like Cyberpunk 2077][2]. + +### Other Features + +If you’re worried about cooling, fret not. The laptop comes with an all-new cooling system that contains two heat pipes and two fans. Thus, working under heavy workloads is no longer an issue. + +As for the storage and memory, two M.2 NVME SSD slots and dual-channel RAM up to 64 GB can be seen. + +The I/O ports include an HDMI 2.0, USB-C 3.2 Gen2, two USB-A 3.2 Gen1 ports, an SD card reader, and a Thunderbolt 4 port. + +Finally, a large **53 Wh battery** is also included that ensures 12 hours (idle) of runtime. This is pretty helpful to that stunning 14 inch **Omnia 3K IPS display.** + +### Availability and Pricing + +The InfinityBook Pro 14 **starts at 1180 EUR** and goes all the way **up to 1770 EUR** if you need the 3K Omnia display and Core i7-11370H. + +Preorders have already started from Oct 6th. You can head to its official website to explore more about the product and its availability. + +[TUXEDO Computers][3] + +### Wrapping Up + +This is one beast of an ultrabook that doubles as a gaming laptop. However, I don’t understand the inclusion of 3050ti with a 3K display. So, if you are looking for other options, I would suggest [exploring other places to buy Linux laptops][4]. + +Users frequently on the go will find this laptop useful for both work and play, thanks to the laptop’s weight and power. + +_What do you think about this laptop? Do share your thoughts below_. + +#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! + +If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. + +I'm not interested + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/tuxedos-infinitybook-14/ + +作者:[Rishabh Moharir][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://news.itsfoss.com/author/rishabh/ +[b]: https://github.com/lujun9972 +[1]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjU2NyIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[2]: https://news.itsfoss.com/nvidia-dlss-dx-11-12-proton/ +[3]: https://www.tuxedocomputers.com/en/Linux-Hardware/Linux-Notebooks/10-14-inch/TUXEDO-InfinityBook-Pro-14-Gen6.tuxedo# +[4]: https://itsfoss.com/get-linux-laptops/ diff --git a/sources/news/20211010 Here-s Why You Can Consider Linux as a Content Creator.md b/sources/news/20211010 Here-s Why You Can Consider Linux as a Content Creator.md new file mode 100644 index 0000000000..79d986bf2a --- /dev/null +++ b/sources/news/20211010 Here-s Why You Can Consider Linux as a Content Creator.md @@ -0,0 +1,151 @@ +[#]: subject: "Here’s Why You Can Consider Linux as a Content Creator" +[#]: via: "https://news.itsfoss.com/linux-content-creator-choice/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Here’s Why You Can Consider Linux as a Content Creator +====== + +Rewind to four/five years back, I did not use Linux as my daily driver. Yes, in a virtual machine or dual-boot, sure. + +I stuck with Windows saying – “Linux isn’t user-friendly, and it’s all about the commands/terminal.” + +In my defense, I did not know a lot of things back then. But, when I finally took the leap of faith and started using Linux as a daily driver, I began to explore how things work and was blown away by many things. + +Including some of the compelling reasons why [Linux is better than Windows][1]. + +It took me a couple of days to understand the fundamentals and learn about the software utilities not available for Linux. + +But, surprisingly, I did not need to use Windows for most of my tasks, except multiplayer gaming. And, thanks to Valve, that’s about to change with the [support for BattleEye, and Easy-Anti Cheat added to Linux][2]. + +Fret not; I’m not one of those who recommends ditching other operating systems. You should always use what you are comfortable with. + +But, in this article, I want to highlight a few things why you may want to switch to Linux as a content creator like myself. + +### Efficient System Resource Usage + +![][3] + +I’m not exaggerating here, but if you are going to use [one of the best Linux distributions][4], your system resources will thank you for choosing Linux. + +Considering my scenario, I have an i5-7400 processor coupled with 16 GB of RAM. + +When I boot into Windows, the startup programs like the antivirus, software tools for peripherals, and others already eat up about 30-40% of my RAM. + +And, when I start using the browser or any other resource-intensive application, I barely get to multi-task freely. + +When it comes to Linux, unless I open many tabs in the browser or multiple programs, it does not consume a lot of memory out-of-the-box. + +Windows has a lot of services/processes running in the background, and you need to put in some effort to “de-bloat” your experience. But, Linux does not require such tweaks to manage the resources; it already does it well. + +I know it isn’t exactly an “Apples to Apples” comparison. Still, I would consider myself somewhat a power user with a lot of browser tabs active to research and multiple applications (communication, productivity, virtual machine program, etc.) while constantly monitoring system performance. + +Hence, in my experience, _I feel I can do more with Linux using the same resources compared to Windows._ + +And, as a content creator, you probably know how important it is to have an efficient system that maximizes your productivity without being a strain on your life. + +### Is It All About the Web Browsers? + +![][3] + +Let’s face it—most of the tools are being available as web services. While some programs/utilities may stick to native offerings, everything else is increasingly relying on cloud computing to help you get things done via the web browser. + +So, you should evaluate the tools you use and whether they are platform-dependent or not. + +If not, all you need to use is the web browser. + +To give you an example, I utilize a lot of tools right from the web browser like: + + * [Canva][5] + * [Microsoft Office 365][6] + * Web-based feed readers like Feedly, Inoreader + * Todist + * [CryptPad][7] + + + +And, if that’s the case, do you think there’s any reason to consider Windows? I’ll leave that up to you. + +Linux supports all the major web browsers, including Microsoft Edge. + +### Hassle-free Experience + +![][3] + +As a content creator, the less you worry about troubleshooting issues on your computer, the more time you save. + +I’m sure you know how Microsoft’s Windows fairs when it comes to buggy updates. Now and then, I will have to re-configure my audio settings or update the graphics driver, re-install programs, and clean junk files after an update. + +And, there have been a few instances where I just get stuck looking at the welcome screen after an update, annoyed by a feature added by Microsoft, and some more. + +Regarding my Linux experience, other than some NVIDIA graphics drivers issues (for some distributions like Fedora), I never had to troubleshoot for anything else. It has been a hassle-free journey so far! + +So, I focus on my work without even worrying about an update screwing up my system. + +The only inconvenience I found with Linux was developing the habit of – “_Distro hopping_,” meaning trying new Linux distributions. Considering there are a lot of choices for your desktop OS, you may be encouraged to try another distribution looking at its features. + +Here, let me point you to [Zorin OS 16][8] and [elementary OS 6][9] if you aren’t already using them (good luck!). + +### Applications for Audio, Video, and Digital Art/Photo + +While some users may warn you that Linux does not offer good application support, the answer isn’t that straightforward. + +Yes, you do not have the support for the Adobe suite and some commercial applications. But you do have alternatives. + +Of course, if you swear by a specific software tool, Linux is a big no for you. But, if you do not have specific requirements, you can always choose to explore the exciting alternatives available. + +You can find capable video editors like Kdenlive, tools like GIMP, and several other applications used by professionals. + +To get a better idea, you might want to check: + + * [Free video editors for Linux][10] + * [Tools for digital artists][11] + * [Audio editing tools][12] + + + +There are some decent, social media specific, browser-based video editors are also available. + +### Wrapping Up + +Overall, I believe that Linux can be a perfectly suitable choice for content creators and creative professionals. + +Linux as a desktop platform has improved a lot. And, with several Linux distributions pushing forward to enhance user experience, security, and reliability, it is an uncommon but beneficial choice that comes with benefits! + +What do you think about Linux as a choice for content creators? Let me know what you think in the comments! + +#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! + +If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. + +I'm not interested + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/linux-content-creator-choice/ + +作者:[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://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/linux-better-than-windows/ +[2]: https://news.itsfoss.com/easy-anti-cheat-linux/ +[3]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQzOSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[4]: https://itsfoss.com/best-linux-distributions/ +[5]: http://partner.canva.com/yRbxmN +[6]: https://www.office.com +[7]: https://itsfoss.com/cryptpad/ +[8]: https://news.itsfoss.com/zorin-os-16-features/ +[9]: https://news.itsfoss.com/elementary-os-6-features/ +[10]: https://itsfoss.com/best-video-editing-software-linux/ +[11]: https://itsfoss.com/best-linux-graphic-design-software/ +[12]: https://itsfoss.com/best-audio-editors-linux/ diff --git a/sources/talk/20210825 When Linus Torvalds Was Wrong About Linux (And I am Happy He Was Wrong).md b/sources/talk/20210825 When Linus Torvalds Was Wrong About Linux (And I am Happy He Was Wrong).md deleted file mode 100644 index 08548e553e..0000000000 --- a/sources/talk/20210825 When Linus Torvalds Was Wrong About Linux (And I am Happy He Was Wrong).md +++ /dev/null @@ -1,67 +0,0 @@ -[#]: subject: "When Linus Torvalds Was Wrong About Linux (And I am Happy He Was Wrong)" -[#]: via: "https://news.itsfoss.com/trovalds-linux-announcement/" -[#]: author: "Abhishek https://news.itsfoss.com/author/root/" -[#]: collector: "lujun9972" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -When Linus Torvalds Was Wrong About Linux (And I am Happy He Was Wrong) -====== - -Linus Torvalds, the creator of Linux kernel and Git, needs no introduction. - -A shy geek who does not talk much in public but prefers mailing lists. Loves codes and gadgets more than other things. Prefers working from home than spending time in shiny offices. - -Torvalds expresses his opinion on Linux related things quite vocally. We can’t forget the ‘finger to Nvidia’ moment that forced Nvidia to improve Linux support (it was way worse back in 2012). - -Generally, I agree with his opinion and most often his views have turned out to be correct. Except in this one case (and that’s a good thing). - -### Torvalds’ “incorrect prediction” on Linux - -30 years ago, Torvalds announced the Linux project. He was a university student at that time and wanted to create a UNIX-like operating system because UNIX itself was too costly. - -While announcing the project, Torvalds mentioned that the project was just a hobby and it won’t be big and professional like GNU. - -> I’m doing a (free) operating system (just a hobby, won’t be big and professional like gnu) for 386(486) AT clones. - -Linus Torvalds while announcing the Linux project - -Little did Torvalds knew that his ‘hobby’ will become the backbone of today’s IT world and the face of a successful open source project. - -Here’s the complete message he sent: - -Hello everybody out there using minix – - -I’ve currently ported bash(1.08) and gcc(1.40), and things seem to work. This implies that I’ll get something practical within a few months, and I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise I’ll implement them 🙂 - -Linus ([torv…@kruuna.helsinki.fi][1]) - -PS. Yes – it’s free of any minix code, and it has a multi-threaded fs. It is NOT protable (uses 386 task switching etc), and it probably never will support anything other than AT-harddisks, as that’s all I have :-(. - -That was on 25th August 1991. Torvalds announced the Linux project and then on 5th October 1991, he released the first Linux kernel. The [interesting fact about Linux][2] is that it was not open source initially. It was released under GPL license a year later. - -The Linux Kernel is 30 years old today. Happy 30th to this amazing open source project. - -#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! - -If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. - -I'm not interested - --------------------------------------------------------------------------------- - -via: https://news.itsfoss.com/trovalds-linux-announcement/ - -作者:[Abhishek][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://news.itsfoss.com/author/root/ -[b]: https://github.com/lujun9972 -[1]: https://groups.google.com/ -[2]: https://itsfoss.com/facts-linux-kernel/ diff --git a/sources/talk/20210927 Why nonprofit organizations choose open source software.md b/sources/talk/20210927 Why nonprofit organizations choose open source software.md new file mode 100644 index 0000000000..69c24ead75 --- /dev/null +++ b/sources/talk/20210927 Why nonprofit organizations choose open source software.md @@ -0,0 +1,90 @@ +[#]: subject: "Why nonprofit organizations choose open source software" +[#]: via: "https://opensource.com/article/21/9/nonprofit-open-source" +[#]: author: "Michael Korotaev https://opensource.com/users/michaelk" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Why nonprofit organizations choose open source software +====== +Open source software increases in importance as more European nonprofits +shift to products like Nextcloud and ONLYOFFICE. +![4 books that spell out open][1] + +With tech and data safety awareness rising, open source software is becoming a go-to option for organizations of all classes more than ever. Nonprofit organizations are particularly vulnerable on the financial side while at the same time dealing with vital social and environmental issues. + +This article observes the adoption of open source collaboration technologies in nonprofit organizations by using [Nextcloud][2] and [ONLYOFFICE][3] as examples. + +### Transparency and security + +Open source is basically democracy written in code: It liberates and democratizes knowledge, gives access to vital technology to governmental and social institutions in all communities, and pursues the idea of transparency. + +People and organizations can access and reuse the software code. At the same time, contributors bear individual responsibility for the quality of their products and are more driven by initiative and ideas and much less by profit. + +Open source applications are seen as more reliable than proprietary solutions with source code reserved to a single vendor who decides how user’s data is handled and is in many cases the only observing party to this process. + +According to the latest [State of Enterprise Open Source report][4], the enterprise use of open source is expected to grow with 79% of surveyed IT leaders willing to build up their use of open source in the next two years. + +### Universal access to collaborative tools + +For decades, Microsoft and Google have been the de-facto standard for collaboration tools. But privacy and security concerns, together with a massive boost in cloud collaboration usage over the pandemic, have ramped up nonprofits' preference for open source tools. + +For nonprofit organizations, open source is a way to cut expenses by providing their employees and contributors with core collaboration tools such as content management and sharing environments, online office, and communication tools to manage operations, organize data, and create content. + +One example of an all-in-one system that sees constant growth in popularity among nonprofit organizations in Europe is Nextcloud. It is a free and secure sharing platform that combines document management space with various productivity add-ons. It also integrates with ONLYOFFICE Docs for document editing and collaboration functionality. + +### ONLYOFFICE and Nextcloud in practice + +Over the past year, several nonprofit organizations with diversified profiles have joined the users of Nexcloud and ONLYOFFICE. Some are newly in business and some are switching from proprietary solutions seeking a better match to handle their jobs. + +#### Sea-Watch + +[Sea-Watch][5] is a rescue organization that provides emergency aid for civilians in the Mediterranean amidst the ongoing refugee crisis and has saved over 38,000 lives to date. It has deployed a collaborative system for its 90 employees and over 400 volunteers. + +After having tried several free online solutions to maintain internal document flow and collaboration, Sea-Watch now relies on open source software to be more and more protective of the security and privacy of the organization’s data and the personal information of its employees and volunteers. + +Sea-Watch finds the solution to this problem by combining the Nextcloud file sharing platform with ONLYOFFICE online editors to enable secure editing and collaboration on documents online using the organization’s own physical infrastructure. + +#### Vegan in Leipzig + +[Vegan in Leipzig][6], a young activist association in Germany, advocates for animal rights and promotes a vegan diet and lifestyle. Around 100 people in the organization’s team work on creating vegan dining maps, scheduling and promoting related events, and uniting online communities to collect and organize all information for Leipzig’s vegan community and allies in one place. + +Vegan in Leipzig has been using Nextcloud to facilitate the organization’s internal file management and content sharing. A reliable and free platform for community users, Nextcloud is built to provide a sharing space of required scale for distributed teams and incorporating online communication tools such as videoconferencing and chat. + +In March 2021, the organization introduced its contributors to ONLYOFFICE editors integrated with Nextcloud for online collaboration on shared files, including documents, spreadsheets, and presentations. + +“Our employees are almost 100% satisfied. For now, there have been no complaints, feature requests, or reports of technical problems. As an administrator, I would go even further and say that ONLYOFFICE is the part of our application landscape that requires by far the least maintenance,” says Christo H., a volunteer administrator with Vegan in Leipzig. + +#### Wegweiser + +Among various nonprofit organizations grounded in helping struggling societal groups, one plays a vital role in the German social agenda: Wegweiser. The organization helps people with mental and physical disabilities integrate into society by dealing with daycare organizations, outpatient care, and school-to-employment transfer. + +Wegwiser had been using SharePoint for managing its content and documentation, but with growing concerns for the privacy of processed data, the organization opted for a Nextcloud and ONLYOFFICE combination to ensure full control over data in its own sovereign infrastructure. Wegweiser uses Nextcloud to document daily work, accounting and controlling, simultaneous document editing, and working with Microsoft Office-formatted documents. + +### Wrap up + +The list can be continued by numerous nonprofit organizations that have recently become users of Nextcloud and ONLYOFFICE, including The German Life Saving Association, Foodsharing Austria, and International Youth Community Services. + +Stories like this show that it’s not only cost-cutting that defines the value of open source for the global community but also the vitality of universal access to technology and knowledge. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/9/nonprofit-open-source + +作者:[Michael Korotaev][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/michaelk +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDU_OSDC_BYU_520x292_FINAL.png?itok=NVY7vR8o (4 books that spell out open) +[2]: https://nextcloud.com/ +[3]: https://www.onlyoffice.com/ +[4]: https://www.redhat.com/en/enterprise-open-source-report/2021 +[5]: https://sea-watch.org/en/ +[6]: https://www.vegan-in-leipzig.de/ diff --git a/sources/talk/20210928 Modeling open management practices.md b/sources/talk/20210928 Modeling open management practices.md new file mode 100644 index 0000000000..d896968e50 --- /dev/null +++ b/sources/talk/20210928 Modeling open management practices.md @@ -0,0 +1,101 @@ +[#]: subject: "Modeling open management practices" +[#]: via: "https://opensource.com/open-organization/21/9/modeling-open-management" +[#]: author: "Heidi Hess von Ludewig https://opensource.com/users/heidi-hess-von-ludewig" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Modeling open management practices +====== +How can managers know if other leaders are cultivating an open culture? +Ask the people they impact every day. +![Women talking][1] + +In the [first part of my interview with Sam Knuth][2], a fellow [Open Organization Ambassador][3], we discussed how leaders need to make time to be open. Openness isn't effortless. + +In this second part, Sam and I discuss how executive leaders support their managers and teams in [leading with open values][4]. Because of the confidentiality of some of the answers (we're colleagues at Red Hat, after all), I am summarizing the interview in a series of articles that highlight and share some of Sam's most memorable observations and practices. + +### Managing managers + +Executive and senior leaders manage groups of managers, which means they may have little (or no) direct, routine contact with individual contributors in their organizations. So if they're interested in promoting open cultures throughout their organizations, they'll need to continuously model the open management practices they expect to see from all the managers in their team. + +Executive and senior leaders, however, don't only _promote_ open culture; they're also members of the organizational communities they want to see thrive, and like other members they shoulder some accountability for the health and vitality of that culture. Like all other members of an open organization community, managers are accountable for being _stewards_ (even protectors) of the values of the community as well. Senior leaders are responsible—as is any community member—for challenging behaviors that are unsupportive of open values. + +But this work is even more critical in the case of managers, especially because managers can enjoy enhanced decision-making power in many open organizations, and they influence more and more people the higher their role in an organization's hierarchy they sit. + +So how can executive leaders promote and protect open values in their organizations? Sam described a multi-factor approach to gathering and understanding associates' perspectives of their managers' leadership competencies. + +#### Meeting one-on-one + +As Sam's organization grew and more layers of management formed, Sam found he didn't have ongoing conversations with associates who weren't directly reporting to him, and was losing touch with how employees were feeling. Those _feelings_ are integral to any understanding of the organizational culture individual contributors experience every day. + +The bottom line? However you connect with associates, cultivating psychological safety is important for generating candid discussions. + +So Sam set up [one-on-one meetings][5] to connect with associates throughout the organization, choosing as randomly as he could. This helped create a safe space and develop trust in a confidential environment. Sam did this across his 250-associate organization by scheduling two to three meetings every week, because he felt it was the best way to get a sense of everyone's perspectives. It also gave him opportunities to share what he was learning with the managers in his organization and to coach them on becoming open leaders and champions of open values among their peers. + +During these discussions, he listened actively and asked many questions. Red Hatters can be quite forthcoming in their feedback, but asking questions helped Sam pick up on subtle cues when necessary. This way, he could ferret out an accurate sense of the situation, asking himself, "Does what the associates' say line up with what I think the leaders are intending? Where does it seem like alignment is not occurring? Why?" + +It's an individualized approach that's both time-consuming and candid, and Sam found it to be well worth the effort. + +It's also the opposite of a process I recalled from my past life in a conventional organization. As Sam and I chatted, I remembered "round tables," where an executive would set up team discussions to (allegedly) understand associates' perspectives. It was supposed to be a venue for collecting feedback and constructive criticism—but, in practice, no one said anything to the visiting executive that they hadn’t shared with team or department leaders, so there was no candid discussion _about_ those team or department leaders. I didn't feel any [sense of psychological safety][6], which is required in order for associates to share their thoughts. In my case, the round tables were completely ineffective. + +The bottom line? However you connect with associates—individually or in groups—cultivating psychological safety is important for generating candid discussions. + +Travelling to meet associates was ideal for these kinds of individual meetings to occur face-to-face, but the pandemic changed this tactic. On the other hand, workplaces across the world were already becoming more distributed before the pandemic; in fact, Sam struggled to meet associates in the United States because of the distribution of sites and even associates working remotely! To overcome this, leaders can set up one-on-one teleconferences with associates. In cases where associates seem to be less forthcoming or fearful of sharing their opinions, leaders can ask probing (but not direct) questions of the associates to get feedback as best as they can. For instance, leaders can glean a great deal of information from how associates answer questions such as: + + * How are you feeling about your work? + * What kinds of challenges do you encounter in your work? + * Do you feel like you get the support you need to do your work? + * How well do you feel you connect with your manager? Colleagues? + + + +#### On (not) using surveys + +Finally, Sam and I discussed surveys. After all, couldn't someone achieve the same results using a survey—without all that extra legwork? + +Surveys have their place in tracking the health of an open culture, Sam told me, but on their own they're rarely sufficient for doing this. For starters, Sam said, using surveys requires skill in both asking quantifiable questions and analyzing data, and that kind of skill isn't as common as we tend to think it is. Without proper expertise in using survey instruments, we may be letting data mislead us (for instance, when we gloss over problems because we see a high average score on another, similar question). So Sam finds surveys most useful for capturing a _broad perspective_ on team- or department-level experience of a culture and a manager's role in creating and maintaining it. + +Getting an accurate sense of specific details or issues is difficult when using surveys, which tend to ask for more generic feedback. Painting a more complete picture really requires sitting down with people and talking to them. + +Getting an accurate sense of specific details or issues is difficult when using surveys, which tend to ask for more generic feedback. Painting a more complete picture really requires sitting down with people and talking to them, Sam insisted. + +That's why it's important to investigate and spend time learning about the work culture in your organization from the associates themselves. Use a combination of techniques, and open multiple channels to facilitate feedback in as many forms as possible, as different people feel comfortable with different media. + +### When managers aren't open + +Like any role, managers learn skills and behaviors that help them succeed in particular organizations. When they get hired into an open organization (like Red Hat), they might experience some "abrasion" (my term), because there can be a genuine belief that a manager is managing with open values even though that person's _vision_ of open values doesn't match that of the organization. + +I recalled personal experience with this, where I had a manager who probably _thought_ they were being open, but really wasn't. + +"Exactly," Sam said, "and it's very painful." + +_Listen to Sam Knuth describe difficulties helping managers become more open._ + +When managers really aren't sufficiently "open," it's an issue that has to be addressed—because it can be damaging to teams. Sometimes managers can unlearn their conventional skills and behaviors. And sometimes they can't. Sometimes the change has to happen quickly so that the team doesn’t suffer. Ultimately, the organization's executive leader must embody that organization's culture. + +So "open management" then becomes a question of "open by whose standards?" and the organization must make those standards explicit in some way. That means deliberately codifying what the organization _means_ by "openness." Some organizations might draw up a simple social contract to accomplish this—a description of open principles and practices that all agree to let guide them. Other organizations might go so far as to formalize certain managerial competencies that align with the open culture an organization seeks to maintain. Regardless of the approach, however, it's important that an open organization fosters transparent discussions about behaviors it _does_ and _doesn't_ want to see its managers reflecting and encouraging. In this way, executive leaders can be those stewards for an organization's open culture. + +In the final part of my interview with Sam, I'll describe another important open management tactic I learned during our conversation: daring to be vulnerable. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/21/9/modeling-open-management + +作者:[Heidi Hess von Ludewig][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/heidi-hess-von-ludewig +[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://opensource.com/open-organization/21/3/open-practices-executive-leaders +[3]: https://github.com/open-organization/governance/blob/master/community-roster.md +[4]: https://opensource.com/open-organization/managing-with-open-values +[5]: https://opensource.com/open-organization/21/8/one-on-one-meeting-tips +[6]: https://opensource.com/open-organization/19/3/introduction-psychological-safety diff --git a/sources/tech/20200228 How to process real-time data with Apache.md b/sources/tech/20200228 How to process real-time data with Apache.md deleted file mode 100644 index 7bf16741b4..0000000000 --- a/sources/tech/20200228 How to process real-time data with Apache.md +++ /dev/null @@ -1,87 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to process real-time data with Apache) -[#]: via: (https://opensource.com/article/20/2/real-time-data-processing) -[#]: author: (Simon Crosby https://opensource.com/users/simon-crosby) - -How to process real-time data with Apache -====== -Open source is leading the way with a rich canvas of projects for -processing real-time events. -![Alarm clocks with different time][1] - -In the "always-on" future with billions of connected devices, storing raw data for analysis later will not be an option because users want accurate responses in real time. Prediction of failures and other context-sensitive conditions require data to be processed in real time—certainly before it hits a database. - -It's tempting to simply say "the cloud will scale" to meet demands to process streaming data in real time, but some simple examples show that it can never meet the need for real-time responsiveness to boundless data streams. In these situations—from mobile devices to IoT—a new paradigm is needed. Whereas cloud computing relies on a "store then analyze" big data approach, there is a critical need for software frameworks that are comfortable instantly processing endless, noisy, and voluminous streams of data as they arrive to permit a real-time response, prediction, or insight. - -For example, the city of Palo Alto, Calif. produces more streaming data from its traffic infrastructure per day than the Twitter Firehose. That's a lot of data. Predicting city traffic for consumers like Uber, Lyft, and FedEx requires real-time analysis, learning, and prediction. Event processing in the cloud leads to an inescapable latency of about half a second per event. - -We need a simple yet powerful programming paradigm that lets applications process boundless data streams on the fly in these and similar situations: - - * Data volumes are huge, or moving raw data is expensive. - * Data is generated by widely distributed assets (such as mobile devices). - * Data is of ephemeral value, and analysis can't wait. - * It is critical to always have the latest insight, and extrapolation won't do. - - - -### Publish and subscribe - -A key architectural pattern in the domain of event-driven systems is the concept of pub/sub or publish/subscribe messaging. This is an asynchronous communication method in which messages are delivered from _publishers_ (anything producing data) to *subscribers (*applications that process data). Pub/sub decouples arbitrary numbers of senders from an unknown set of consumers. - -In pub/sub, sources _publish_ events for a _topic_ to a _broker_ that stores them in the order in which they are received. An application _subscribes_ to one or more _topics_, and the _broker_ forwards matching events. Apache Kafka and Pulsar and CNCF NATS are pub/sub systems. Cloud services for pub/sub include Google Pub/Sub, AWS Kinesis, Azure Service Bus, Confluent Cloud, and others. - -Pub/sub systems do not _run_ subscriber applications—they simply _deliver_ data to topic subscribers. - -Streaming data often contains events that are updates to the state of applications or infrastructure. When choosing an architecture to process data, the role of a data-distribution system such as a pub/sub framework is limited. The "how" of the consumer application lies beyond the scope of the pub/sub system. This leaves an enormous amount of complexity for the developer to manage. So-called stream processors are a special kind of subscriber that analyzes data on the fly and delivers results back to the same broker. - -### Apache Spark - -[Apache Spark][2] is a unified analytics engine for large-scale data processing. Often, Apache Spark Streaming is used as a stream processor, for example, to feed machine learning models with new data. Spark Streaming breaks data into mini-batches that are each independently analyzed by a Spark model or some other system. The stream of events is grouped into mini-batches for analysis, but the stream processor itself must be elastic: - - * The stream processor must be capable of scaling with the data rate, even across servers and clouds, and also balance load across instances, ensuring resilience and other application-layer needs. - * It must be able to analyze data from sources that report at widely different rates, meaning it must be stateful—or store state in a database. This latter approach is often used when Spark Streaming is used as the stream processor and can cause performance problems when ultra-low latency responses are needed. - - - -A related project, [Apache Samza][3], offers a way to process real-time event streams, and to scale elastically using [Hadoop Yarn][4] or [Apache Mesos][5] to manage compute resources. - -### Solving the problem of scaling data - -It's important to note that even Samza cannot entirely alleviate data processing demands for the application developer. Scaling data rates mean that tasks to process events need to be load-balanced across many instances, and the only way to share the resulting application-layer state between instances is to use a database. However, the moment state coordination between tasks of an application devolves to a database, there is an inevitable knock-on effect upon performance. Moreover, the choice of database is crucial. As the system scales, cluster management for the database becomes the next potential bottleneck. - -This can be solved with alternative solutions that are stateful, elastic, and can be used in place of a stream processor. At the application level (within each container or instance), these solutions build a stateful model of concurrent, interlinked "web agents" on the fly from streaming updates. Agents are concurrent "nano-services" that consume raw data for a single source and maintain their state. Agents interlink to share state based on real-world relationships between sources found in the data, such as containment and proximity. Agents thus form a graph of concurrent services that can analyze their own state and the states of agents to which they are linked. Each agent provides a nano-service for a single data source that converts from raw data to state and analyzes, learns, and predicts from its own changes and those of its linked subgraph. - -These solutions simplify application architecture by allowing agents—digital twins of real-world sources—to be widely distributed, even while maintaining the distributed graph that interlinks them at the application layer. This is because the links are URLs that map to the current runtime execution instance of the solution and the agent itself. In this way, the application seamlessly scales across instances without DevOps concerns. Agents consume data and maintain state. They also compute over their own state and that of other agents. Because agents are stateful, there is no need for a database, and insights are computed at memory speed. - -### Reading world data with open source - -There is a sea change afoot in the way we view data: Instead of the database being the system of record, the real world is, and digital twins of real-world things can continuously stream their state. Fortunately, the open source community is leading the way with a rich canvas of projects for processing real-time events. From pub/sub, where the most active communities are Apache Kafka, Pulsar, and CNCF NATS, to the analytical frameworks that continually process streamed data, including Apache Spark, [Flink][6], [Beam][7], Samza, and Apache-licensed [SwimOS][8] and [Hazelcast][9], developers have the widest choices of software systems. Specifically, there is no richer set of proprietary software frameworks available. Developers have spoken, and the future of software is open source. - -Introduction to Apache Hadoop, an open source software framework for storage and large scale... - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/2/real-time-data-processing - -作者:[Simon Crosby][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/simon-crosby -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/clocks_time.png?itok=_ID09GDk (Alarm clocks with different time) -[2]: https://spark.apache.org/ -[3]: https://samza.apache.org/ -[4]: https://hadoop.apache.org/ -[5]: http://mesos.apache.org/ -[6]: https://flink.apache.org/ -[7]: https://beam.apache.org -[8]: https://github.com/swimos/swim -[9]: https://hazelcast.com/ diff --git a/sources/tech/20200307 Compose music as code using Sonic Pi.md b/sources/tech/20200307 Compose music as code using Sonic Pi.md index 6944a5f6ea..2f5d2a01a8 100644 --- a/sources/tech/20200307 Compose music as code using Sonic Pi.md +++ b/sources/tech/20200307 Compose music as code using Sonic Pi.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (anine09) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) @@ -108,7 +108,7 @@ via: https://opensource.com/article/20/3/sonic-pi 作者:[Matt Bargenquast][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) +译者:[译者ID](https://github.com/anine09) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/tech/20200515 How to examine processes running on Linux.md b/sources/tech/20200515 How to examine processes running on Linux.md index 92e75e679b..0659ab04f9 100644 --- a/sources/tech/20200515 How to examine processes running on Linux.md +++ b/sources/tech/20200515 How to examine processes running on Linux.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: (runningwater) +[#]: translator: ( ) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) @@ -221,7 +221,7 @@ via: https://www.networkworld.com/article/3543232/how-to-examine-processes-runni 作者:[Sandra Henry-Stocker][a] 选题:[lujun9972][b] -译者:[runningwater](https://github.com/runningwater) +译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/tech/20200519 How to use Windows Subsystem for Linux to open Linux on Windows 10 machines.md b/sources/tech/20200519 How to use Windows Subsystem for Linux to open Linux on Windows 10 machines.md index e610f7eb2f..9daaab2ddd 100644 --- a/sources/tech/20200519 How to use Windows Subsystem for Linux to open Linux on Windows 10 machines.md +++ b/sources/tech/20200519 How to use Windows Subsystem for Linux to open Linux on Windows 10 machines.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (Pinkerr) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20210104 Learn Fortran by writing a -guess the number- game.md b/sources/tech/20210104 Learn Fortran by writing a -guess the number- game.md deleted file mode 100644 index f4e8f0d2fe..0000000000 --- a/sources/tech/20210104 Learn Fortran by writing a -guess the number- game.md +++ /dev/null @@ -1,134 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Learn Fortran by writing a "guess the number" game) -[#]: via: (https://opensource.com/article/21/1/fortran) -[#]: author: (Jim Hall https://opensource.com/users/jim-hall) - -Learn Fortran by writing a "guess the number" game -====== -Because Fortran was written in the punched card era, its syntax is -pretty limited. But you can still write useful and interesting programs -with it. -![Person typing on a 1980's computer][1] - -The first compiled programming language I learned was Fortran 77. While growing up, I taught myself how to write programs in BASIC on the Apple II and later in QBasic on DOS. But when I went to university to study physics, I learned [Fortran][2]. - -Fortran used to be quite common in scientific computing. And once upon a time, all computer systems had a Fortran compiler. Fortran used to be as ubiquitous as Python is today. So if you were a physics student like me, working in the 1990s, you learned Fortran. - -I always thought Fortran was somewhat similar to BASIC, so I quickly took to Fortran whenever I needed to write a quick program to analyze lab data or perform some other numerical analysis. And when I got bored, I wrote a "Guess the number" game in Fortran, where the computer picks a number between one and 100 and asks me to guess the number. The program loops until I guess correctly. - -The "Guess the number" program exercises several concepts in programming languages: how to assign values to variables, how to write statements, and how to perform conditional evaluation and loops. It's a great practical experiment for learning a new programming language. - -### The basics of Fortran programming - -While Fortran has been updated over the years, I am most familiar with Fortran 77, the implementation I learned years ago. Fortran was created when programmers wrote programs on punched cards, so "classic" Fortran is limited to the data you could put on a punched card. That means you could only write classic Fortran programs with these limitations: - - * Only one line of source code per card is allowed. - * Only columns 1–72 are recognized (the last eight columns, 73-80, are reserved for the card sorter). - * Line numbers ("labels") are in columns 1–5. - * Program statements go in columns 7–72. - * To continue a program line, enter a continuation character (usually `+`) in column 6. - * To create a comment line, enter `C` or `*` in column 1. - * Only the characters `A` to `Z` (uppercase), `0` to `9` (numbers), and the special characters `= + - * / ( ) , . $ ' :` and space are used. - - - -With these limitations, you can still write very useful and interesting programs. - -### Guess the number in Fortran - -Explore Fortran by writing the "Guess the number" game. This is my implementation: - - -``` -CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC -C     PROGRAM TO GUESS A NUMBER 1-100 -CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC -      PROGRAM GUESSNUM -      INTEGER SEED, NUMBER, GUESS - -      PRINT *, 'ENTER A RANDOM NUMBER SEED' -      READ *, SEED -      CALL SRAND(SEED) - -      NUMBER = INT( RAND(0) * 100 + 1 ) - -      PRINT *, 'GUESS A NUMBER BETWEEN 1 AND 100' - 10   READ *, GUESS - -      IF (GUESS.LT.NUMBER) THEN -         PRINT *, 'TOO LOW' -      ELSE IF (GUESS.GT.NUMBER) THEN -         PRINT *, 'TOO HIGH' -      ENDIF - -      IF (GUESS.NE.NUMBER) GOTO 10 - -      PRINT *, 'THATS RIGHT!' -      END -``` - -If you are familiar with other programming languages, you can probably figure out what this program is doing by reading the source code. The first three lines are a comment block to indicate the program's function. The fourth line, `PROGRAM GUESSNUM`, identifies this as a program, and it is closed by the `END` statement on the last line. - -After defining a few variables, the program prompts the user to enter a random number seed. A Fortran program cannot initialize the random number generator from the operating system, so you must always start the random number generator with a "seed" value and the `SRAND` subroutine. - -Fortran generates random numbers between 0 and 0.999... with the `RAND(0)` function. The `0` value tells the `RAND` function to generate another random number. Multiply this random number by 100 to generate a number between 0 and 99.999…, and then add 1 to get a value between 1 and 100.999… The `INT` function truncates this to an integer; thus, the variable `NUMBER` is a random number between 1 and 100. - -The program prompts the user, then enters a loop. Fortran doesn't support the `while` or `do-while` loops available in more modern programming languages. Instead, you must construct your own using labels (line numbers) and `GOTO` statements. That's why the `READ` statement has a line number; you can jump to this label with the `GOTO` at the end of the loop. - -Punched cards did not have the `<` (less than) or `>` (greater than) symbols, so Fortran adopted a different syntax to compare values. To test if one value is less than another, use the `.LT.` (less than) comparison. To test if a value is greater than another, use `.GT.` (greater than). Equal and not equal are `.EQ.` and `.NE.`, respectively. - -In each iteration of the loop, the program tests the user's guess. If the user's guess is less than the random number, the program prints `TOO LOW`, and if the guess is greater than the random number, the program prints `TOO HIGH`. The loop continues until the user's guess is the same as the random number. - -When the loop exits, the program prints `THATS RIGHT!` and ends immediately. - - -``` -$ gfortran -Wall -o guess guess.f - -$ ./guess - ENTER A RANDOM NUMBER SEED -93759 - GUESS A NUMBER BETWEEN 1 AND 100 -50 - TOO LOW -80 - TOO HIGH -60 - TOO LOW -70 - TOO LOW -75 - TOO HIGH -73 - TOO LOW -74 - THATS RIGHT! -``` - -Every time you run the program, the user needs to enter a different random number seed. If you always enter the same seed, the program will always pick the same random number. - -### Try it in other languages - -This "guess the number" game is a great introductory program when learning a new programming language because it exercises several common programming concepts in a pretty straightforward way. By implementing this simple game in different programming languages, you can demonstrate some core concepts and compare each language's details. - -Do you have a favorite programming language? How would you write the "guess the number" game in it? Follow this article series to see examples of other programming languages that might interest you. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/1/fortran - -作者:[Jim Hall][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/jim-hall -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/1980s-computer-yearbook.png?itok=eGOYEKK- (Person typing on a 1980's computer) -[2]: https://en.wikipedia.org/wiki/Fortran diff --git a/sources/tech/20210607 Comparing Linux Mint and Fedora- Which One Should You Use.md b/sources/tech/20210607 Comparing Linux Mint and Fedora- Which One Should You Use.md deleted file mode 100644 index 631a60e504..0000000000 --- a/sources/tech/20210607 Comparing Linux Mint and Fedora- Which One Should You Use.md +++ /dev/null @@ -1,184 +0,0 @@ -[#]: subject: (Comparing Linux Mint and Fedora: Which One Should You Use?) -[#]: via: (https://itsfoss.com/linux-mint-vs-fedora/) -[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Comparing Linux Mint and Fedora: Which One Should You Use? -====== - -Linux Mint is a [popular Linux distribution tailored for beginners][1] while providing a similar experience to former Windows users. In fact, it does a [few things better than Ubuntu][2], which makes it a suitable choice for every type of user. - -It is completely community-powered, on top of Ubuntu as its base. - -On the other hand, Fedora is a cutting-edge distribution that focuses on incorporating exciting changes that eventually makes it way to Red Hat Enterprise Linux (RHEL). - -Unlike Linux Mint, Fedora does not exclusively focus on personal use (or non-developers). Even though they offer a workstation edition, they aim for developers and experienced Linux users. - -### Fedora or Mint: What Should You Go For? - -While we know that Fedora is not exactly geared towards Linux newbies, many users love using Fedora as their daily driver. So, in this article, we shall shed light on some differences between the two to help you pick one to use on your desktop machine. - -#### System Requirements & Hardware Compatibility - -![][3] - -Before choosing any Linux distribution, you should always go through the system requirements and check the hardware compatibility. - -Here, both Linux Mint and Fedora require at least 2 GB of RAM, 20 GB of disk space, and a 1024 x 768 resolution display to get an entry-level experience. - -Yes, the official documentation may mention 1 GB of RAM to start with but let us be practical of your use-case. Unless you have a vintage computer that you want to revive for a specific purpose, it is out of the equation. - -![Linux Mint Resource Usage][4] - -Technically, both support modern and old hardware. You will only know how it works along with the software/driver support when you get it installed. Unless you have a special peripheral or hardware component with specific features, hardware support may not be a big deal. - -Linux Mint 19 series still provide support for 32-bit systems and you can use it till April 2023. Fedora doesn’t support 32-bit systems anymore. - -#### Software Update Cycle - -![Linux Mint Update Manager][5] - -Linux Mint focuses on Long-Term Releases (LTS) with a five-year support. It will be maintained same as Ubuntu. But there is no paid extension like Ubuntu offers. - -Fedora does not offer an LTS release but pushes a new update every 6 months. Every version gets software support for 13 months. You get the ability to skip one version if you want. - -If you just want to have a Linux distro installed for years without requiring the latest technology/features in an update, Linux Mint is the way to go. - -But, if you want to the latest and greatest (which can also break your computing experience ins some rare cases) and accept to adapt with the major changes Fedora pushes, Fedora can be a choice. - -#### Desktop Environment Choices - -![Linux Mint Cinnamon Edition][6] - -Linux Mint provides three different [desktop environments][7] — **MATE, Cinnamon, and Xfce**. All of them will have the same update cycle and will be supported for five years from their release. - -Even though Fedora does not offer LTS releases, you get a variety of desktop choices in the form of Fedora spins. You get KDE, LXQt, MATE, Cinnamon, LXDE, and an edition with i3 tiling window manager baked in. - -![Fedora 34 with GNOME 40][8] - -So, if you want more choices out of the box, Fedora can be a quite exciting choice. - -#### Software Availability - -![Linux Mint’s Software Center and Package Manager][9] - -The default repositories of Linux Mint (or Ubuntu’s) offer a wide range of software to install. But Fedora’s default repository sticks only to open-source applications. - -Not just limited to that, Linux Mint also comes packed with [Synaptic Package Manager][10] which is an impressive lightweight tool to install software. - -Even though you can [enable third-party repositories in Fedora][11], it is yet an additional step. Also, the RPM Fusion repository may not be as huge as Ubuntu’s universe repository. - -![Fedora 34 Software Center][12] - -So, with Linux Mint, overall, you get more packages available to install and more ways to install software, out of the box. - -#### Ease of Use & Installation - -For an entirely new user, Ubuntu or any Ubuntu-based distribution generally fares well to start with. - -Starting from the [installation experience in Ubuntu][13] to the ease of [installing software][14] while having the option to opt for an LTS release is what a beginner finds handy. - -And, Linux Mint naturally presents the same benefits of Ubuntu with Ubiquity installer – hence, it offers a minimal learning curve, easy to install and easy to use. - -While Fedora is not complex by definition but the installation options, package manager, and lack of software in the default repositories may prove to be a time-consuming factor. - -If you’ve never tried it, I suggest you to go through our [Fedora installation guide for VirtualBox][15]. It is a good way to test the installation experience before trying it out on your production system of any sort. - -#### Out of the Box Experience - -The most hassle-free experience is usually the pleasant option. Well, for most people. - -Now, you need to understand that depending on the hardware configuration, every user might end up having a different “out-of-the-box” experience. - -But, for a reference, let me just give you my example for both Fedora and Linux Mint. - -Considering I’m rocking an NVIDIA GPU on my PC, I need to install the proprietary drivers for the best performance. - -![][16] - -And, when I booted up Linux Mint, installing the drivers were pretty easy using the **Driver Manager** app. - -But, with Fedora, even though I followed our guide on [installing Nvidia drivers in Fedora][17], I was presented with an error when I rebooted. - -![Installing NVIDIA drivers in Fedora][18] - -Not just that, for some reason, my wired network did not seem to be active – hence, I had no internet connectivity. - -Yes, you should always try to troubleshoot when you run into issues, but I did not need to do that for Linux Mint. So, in my experience, I will recommend Linux Mint with a better out of the experience. - -#### Documentation - -I would recommend going for [Fedora’s documentation][19] if you rely on resources and want to challenge yourself with a decent learning experience along the process. - -You will find up-to-date information for recent and latest Fedora releases, which is a good thing. - -On the other hand, [Linux Mint’s documentation][20] is not regularly updated but useful when you want to dig deeper. - -#### Community Support - -You will get a good community support for both. The [Linux Mint forums][21] is a basic platform which is easy to use and gets the job done. - -[Fedora’s forum][22] is powered by Discourse, which happens to be one of the most [popular modern open-source forum software][23]. - -#### Corporate vs Community Angle - -Fedora is backed up by the biggest open-source company [Red Hat][24] – so you get a good level of constant innovation and support for the long run. - -However, just because Fedora is not built for the daily computer users in mind, the choices made with every release may affect your user experience entirely. - -On the other hand, Linux Mint is completely backed up by a passionate Linux community focusing on making Linux easier and reliable for everyday use. Of course, it depends on Ubuntu as the base but Linux Mint does make bold changes if the community does not like something from the upstream. - -For instance, Linux Mint disabled snaps by default unlike official Ubuntu distro. So, you will have to [enable snaps in Linux Mint][25] if you want to use them. - -### Wrapping Up - -If you want a no-nonsense and easy to use operating system for your home computer, Linux Mint would be my suggestion. But, if you want to experience the latest and greatest, while taking a little adventure in your Linux learning experience, Fedora can be a good pick. - -While every operating system requires some form of troubleshooting and nothing can guarantee zero issues with your hardware, I think Linux Mint will have potentially no issues for the majority of the users. - -In any case, you can re-visit the comparison points mentioned above to see what matters most for your computer. - -What do you think? Would you pick Fedora over Mint? And, Why? Let me know in the comments below. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/linux-mint-vs-fedora/ - -作者:[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/best-linux-beginners/ -[2]: https://itsfoss.com/linux-mint-vs-ubuntu/ -[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/fedora-34-about.png?resize=1020%2C709&ssl=1 -[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/linux-mint-resources.png?resize=800%2C293&ssl=1 -[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/linux-mint-update-manager.png?resize=819%2C612&ssl=1 -[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/linux-mint-cinnamon-desktop.png?resize=800%2C450&ssl=1 -[7]: https://itsfoss.com/best-linux-desktop-environments/ -[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/fedora-34-desktop.png?resize=800%2C478&ssl=1 -[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/linux-mint-software-sources.png?resize=800%2C385&ssl=1 -[10]: https://itsfoss.com/synaptic-package-manager/ -[11]: https://itsfoss.com/fedora-third-party-repos/ -[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/05/fedora-34-software.png?resize=1055%2C691&ssl=1 -[13]: https://itsfoss.com/install-ubuntu/ -[14]: https://itsfoss.com/remove-install-software-ubuntu/ -[15]: https://itsfoss.com/install-fedora-in-virtualbox/ -[16]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/linux-mint-driver-manager.jpg?resize=800%2C548&ssl=1 -[17]: https://itsfoss.com/install-nvidia-drivers-fedora/ -[18]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/fedora-nvidia-driver-installation.png?resize=706%2C516&ssl=1 -[19]: https://docs.fedoraproject.org/en-US/docs/ -[20]: https://linuxmint.com/documentation.php -[21]: https://forums.linuxmint.com -[22]: https://ask.fedoraproject.org -[23]: https://itsfoss.com/open-source-forum-software/ -[24]: https://www.redhat.com/en -[25]: https://itsfoss.com/enable-snap-support-linux-mint/ diff --git a/sources/tech/20210616 Top 5 Chrome-like Browsers That Are Better Than Google Chrome in 2021.md b/sources/tech/20210616 Top 5 Chrome-like Browsers That Are Better Than Google Chrome in 2021.md deleted file mode 100644 index d0de8fbccf..0000000000 --- a/sources/tech/20210616 Top 5 Chrome-like Browsers That Are Better Than Google Chrome in 2021.md +++ /dev/null @@ -1,200 +0,0 @@ -[#]: subject: (Top 5 Chrome-like Browsers That Are Better Than Google Chrome in 2021) -[#]: via: (https://news.itsfoss.com/chrome-like-browsers-2021/) -[#]: author: (Jacob Crume https://news.itsfoss.com/author/jacob/) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Top 5 Chrome-like Browsers That Are Better Than Google Chrome in 2021 -====== - -Want to switch away from Google? But, looking for something potentially better than Google Chrome (and similar) for your Linux system? - -Fortunately, there are multiple Google Chrome alternatives that you can try. - -Each of them brings something interesting to the table, while also keeping the fantastic compatibility Chrome is known for. Read on to find out more about these browsers. - -### Options That Are Better Than Google Chrome - -**Note:** _While [free and open-source software plays a crucial role in replacing big tech][1], any choice available on Linux other than Google Chrome should be a good start. Hence, you will find some non-FOSS options as well._ - -In my opinion, the best alternatives to Chrome are Chromium-based, meaning that they share the same DNA with Chrome. The advantage of this is that they already have feature parity with Chrome, while having more time to add their own. - -Also, if you want, you can explore [opensource alternatives to Chrome][2] that are not based on Chromium. - -In any case, even if the alternatives to Google Chrome do not seem superior to you, it is worth a try to move away from Big Tech. - -The result of this is a collection of browsers that are equal or better than Chrome in various aspects. Without further ado, here are my top five picks for Chrome-like browsers that are better than Chrome itself: - - * **UnGoogled Chromium** - * **Brave** - * **Microsoft Edge** - * **Vivaldi** - * **Opera** - - - -This list is in no order of ranking. - -### 1\. UnGoogled Chromium - -![][3] - -**Features:** - - * Removal of functionality specific to Google domains. - * Blocking of internal requests to Google at runtime. - * Stripping Google binaries from the source code. - * Many new command-line switches and `chrome://flags` entries. - * Forces all pop-ups into tabs. - - - -For the privacy fans out there, this browser will be a godsend. While it may look identical to Chrome, it has many privacy tweaks under-the-hood. - -As the name suggests, the biggest setback for Chrome users will be the absence of Google’s service integrations. This also means no more internal requests to Google, Google URL tracking, and much more. - -It does not boast anything extraordinary to protect your privacy, but it should be better than Google Chrome. - -You can choose to explore and toggle privacy settings at will through the Chrome flags settings as well. - -All-in-all, UnGoogled Chromium provides a familiar browsing experience, with a suite of privacy features added in as well. It is reliable and is also compatible with the large ecosystem of Chrome extensions. - -[UnGoogled Chromium][4] - -### 2\. Brave - -![][3] - -**Features:** - - * Built-in ad blocker. - * Faster page loading times. - * Brave rewards program. - * Ability to synchronise between devices. - * Chrome web store support. - - - -When Brave first marched onto the stage in 2016, people around the world were gawking at its privacy and performance features. At launch, these included a built-in ad-blocker and a new UI. - -Since then, the browser has gained many more features, including a rewards program and [Tor][5] integration. This has led it to become one of the fastest-growing browsers. - -[Brave][6] - -### 3\. Microsoft Edge - -![][3] - -**Features:** - - * Chrome Web Store support - * Child browsing mode (additional protection and simpler UI) - * Good PDF editing tools - * Built-in coupon finder - * Reader Mode - * Built-in password generator - - - -When Microsoft Edge first released alongside Windows 10 in 2015, it was widely criticized for being slow and buggy. However, in early 2020 it was completely remade using the Chromium web engine. - -This is the same engine Chrome is based on. The result of this is a modern and fast browsing experience. One perk of this transition is the web browser’s ability to run on many different platforms, from Windows 7 and macOS to Ubuntu and other Linux-based distros. - -I know, if you hate Microsoft for some reason, this may not entice you – but Microsoft Edge for Linux is a serious alternative to Google Chrome. - -[Microsoft Edge (Beta)][7] - -### 4\. Vivaldi - -![][3] - -**Features:** - - * Built-in translator - * Vivaldi Email (Beta) - * Feed Reader (Beta) - * Vivaldi Calendar (Beta) - * Highly customizable UI - * Built-in Ad Blocker - * Chrome Web Store support - * Tab grouping - * Split-screen tabs - - - -First released in 2016, Vivaldi has quickly risen the ranks in browser wars. Originally designed for Opera users disgruntled by its transition from the [Presto][8] [layout engine][9], it has managed to re-implement many of the features lost during Opera’s transition to Chromium. - -Amazingly, it has managed to do this all while being based on Chromium (the very reason Opera dropped these features). - -The latest [Vivaldi 4.0 release][10] also turned the tables with several features for power users. - -While it isn’t 100% FOSS, 93% of its source code is available, with only the UI being proprietary. Considering Vivaldi’s development team actively focus on Linux users for improvement, this could be a worthy tradeoff due to the sheer number of features Vivaldi offers. - -[Vivaldi][11] - -### 5\. Opera - -![][3] - -**Features:** - - * Built-in VPN - * Easy access to social media - * Built-in cryptocurrency wallet - * Fraud and malware protection - * Highly visible website security badge - - - -While it has never been the king of web browsers, Opera has always been present in the debate over which browser to use. Originally based on its in-house Presto Layout Engine, it switched over to Chromium in 2013. - -Unfortunately, this switch meant that the Opera team was forced to drop some of its most well-known features, paving the way for alternatives such as Vivaldi and Firefox to fill the space Opera had left. - -That isn’t to say that Opera is without features. It contains many, some of which are listed below. - -[Opera][12] - -### Wrapping Up - -Here we have listed a wide variety of browsers tailored to all kinds of users on any desktop platform. - -No matter whether you want more features, a better user interface, or something that helps you get away from Google, there is an option for you. - -Since all these browsers are based on Chromium, they all offer a good compatibility and user experience like Chrome. So, switch to one of these Chrome-like browsers and enjoy the freedom that each of them grants! - -_What’s your favorite alternative to Google Chrome on Linux in 2021? Let me know in the comments down below._ - -#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! - -If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. - -I'm not interested - --------------------------------------------------------------------------------- - -via: https://news.itsfoss.com/chrome-like-browsers-2021/ - -作者:[Jacob Crume][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://news.itsfoss.com/author/jacob/ -[b]: https://github.com/lujun9972 -[1]: https://news.itsfoss.com/save-privacy-with-foss/ -[2]: https://itsfoss.com/open-source-browsers-linux/ -[3]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQxNiIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= -[4]: https://github.com/Eloston/ungoogled-chromium -[5]: https://itsfoss.com/tor-guide/ -[6]: https://brave.com -[7]: https://www.microsoftedgeinsider.com/en-us/download -[8]: https://en.wikipedia.org/wiki/Presto_(browser_engine) -[9]: https://en.wikipedia.org/wiki/Browser_engine -[10]: https://news.itsfoss.com/vivaldi-4-0-release/ -[11]: https://vivaldi.com -[12]: https://www.opera.com diff --git a/sources/tech/20210622 What is a config file.md b/sources/tech/20210622 What is a config file.md deleted file mode 100644 index db2c6325a2..0000000000 --- a/sources/tech/20210622 What is a config file.md +++ /dev/null @@ -1,184 +0,0 @@ -[#]: subject: (What is a config file?) -[#]: via: (https://opensource.com/article/21/6/what-config-files) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) -[#]: collector: (lujun9972) -[#]: translator: (unigeorge) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -What is a config file? -====== -There are several popular formats for configuration files, each with its -own strengths. Find what works best for you. -![Computer screen with files or windows open][1] - -There are thousands of configuration files on your computer. You may never directly interact with the bulk of them, but they're scattered throughout your `/etc` folder and in `~/.config` and `~/.local` and `/usr`. There are probably some in `/var` and possibly even in `/opt`. If you've ever opened one by accident or to make a change, you may have wondered why some configuration files look one way while others look completely different. - -Storing configurations is a flexible task because as long as developers know how their code puts data into a file, they can easily write code to extract that data as needed. However, the tech industry graciously favors well-documented standardization, so several well-known formats have evolved over the years to make configuration easy. - -### Why we need configuration - -Configuration files ("config files" for short) are important to modern computing. They allow you to customize how you interact with an application or how an application interacts with the rest of your system. It's thanks to config files that any time you launch an application, it has "memories" of how you like to use it. - -Configuration files can be, and often are, very simple in structure. For instance, if you were to write an application, and the only thing it ever needed to know was its user's preferred name, then its one and only config file could contain exactly one word: the name of the user. For example: - - -``` -`Tux` -``` - -Usually, though, an application needs to keep track of more than just one piece of information, so configuration often uses a key and a value: - - -``` -NAME='Tux' -SPECIES='Penguin' -``` - -Even without programming experience, you can imagine how code parses that data. Here are two simple examples, one using the [`awk` command][2] and the other using the [grep command][3], focusing on just the line containing the "key" of `NAME`, and returning the "value" appearing after the equal sign (`=`): - - -``` -$ awk -F'=' '/NAME/ { print $2; }' myconfig.ini -'Tux' -$ grep NAME fake.txt | cut -d'=' -f2 -'Tux' -``` - -The same principle applies to any programming language and any configuration file. As long as you have a consistent data structure, you can write simple code to extract and parse it when necessary. - -### Choose a format - -To be broadly effective, the most important thing about configuration files is that they are consistent and predictable. The last thing you want to do is dump information into a file under the auspices of saving user preferences and then spend days writing code to reverse-engineer the random bits of information that have ended up in the file. - -There are several popular formats for configuration files, each with its own strengths. - -#### INI - -INI files take the format of key and value pairs: - - -``` -[example] -name=Tux -style=widgety,fidgety -enabled=1 -``` - -This simple style of configuration can be intuitive, with the only point of confusion being poor key names (for example, cryptic names like `unampref` instead of `name`). They're easy to parse and easy to edit. - -The INI format features sections in addition to keys and values. In this sample code, `[example]` and `[demo]` are configuration sections: - - -``` -[example] -name=Tux -style=widgety,fidgety -enabled=1 - -[demo] -name=Beastie -fullscreen=1 -``` - -This is a little more complex to parse because there are _two_ `name` keys. You can imagine a careless programmer querying this config file for `name` and always getting back `Beastie` because that's the last name defined by the file. When parsing such a file, a developer must be careful to search within sections for keys, which can be tricky depending on the language used to parse the file. However, it's a popular enough format that most languages have an existing library to help programmers parse INI files. - -#### YAML - -[YAML files][4] are structured lists that can contain values or key and value pairs: - - -``` -\--- -Example: -  Name: 'Tux' -  Style: -   - 'widgety' -    - 'fidgety' -  Enabled: 1 -``` - -YAML is popular partly because it looks clean. It doesn't have much of a syntax aside from where you place the data in relation to previous data. What's a feature for some, though, is a bug for others, and many developers avoid YAML because of the significance it places on what is essentially _not there_. If you get indentation wrong in YAML, YAML parsers may see your file as invalid, and even if it's tolerated, it may return incorrect data. - -Most languages have YAML parsers, and there are good open source YAML linters (applications to validate syntax) to help you ensure the integrity of a YAML file. - -#### JSON - -JSON files are technically subsets of YAML, so its data structure is the same, although its syntax is completely different: - - -``` -{ -  "Example": { -    "Name": [ -      "Tux" -    ], -    "Style": [ -      "widgety", -      "fidgety" -    ], -    "Enabled": 1 -  } -} -``` - -JSON is popular among JavaScript programmers, which isn't surprising, given that JSON stands for JavaScript Object Notation. As a result of being strongly associated with web development, JSON is a common output format for web APIs. Most programming languages have libraries to parse JSON. - -#### XML - -XML uses tags as keys that surround a configuration value: - - -``` -<example> -  <name>Tux</name> -  <style priority="user">widgety</style> -  <style priority="fallback">fidgety</style> -  <enabled>1</enabled> -</example> -``` - -XML is often used by Java programmers, and Java has a rich set of XML parsers. While it has a reputation of being quite strict, XML is simultaneously very flexible. Unlike HTML, which has a set of tags you're allowed to use, you can arbitrarily invent your own XML tags. As long as you structure it consistently and have a good library to parse it, you can extract your data with precision and ease. - -There are some good open source linters to help you validate XML files, and most programming languages have a library to parse XML. - -#### Binary formats - -Linux prides itself on plain-text configuration. The advantage is that you can see configuration data using basic tools like [cat][5], and you can even edit a configuration with your [favorite text editor][6]. - -Some applications use binary formats, though, which means the data is encoded in some format that is not a natural language. These files usually require a special application (usually the application they're meant to configure) to interpret their data. -You can't view these files, at least not in a way that makes any sense, and you can't edit them outside of their host application. Some reasons for resorting to binary formats are: - - * **Speed:** A programmer can register specific bits of information at certain points within a binary's config file using custom notation. When the data is extracted, there's no searching involved because everything is already indexed. - * **Size:** Text files can get big, and should you choose to compress a text file, you're functionally turning it into a binary format. Binary files can be made smaller through tricks of encoding (the same is true of text files, but at some point, your optimizations make your data so obscure that it may as well be binary). - * **Obfuscation:** Some programmers don't want people even looking at their configuration files, so they encode them as binary data. This usually succeeds only in frustrating users. This is not a good reason to use binary formats. - - - -If you must use a binary format for configuration, use one that already exists as an open standard, such as [NetCDF][7]. - -### Find what works - -Configuration formats help developers store the data their applications need and help users store preferences for how they want applications to act. There's probably no wrong answer to the question of what format you should use, as long as you feel well supported by the language you're using. When developing your application, look at the formats available, model some sample data, review and evaluate the libraries and utilities your programming language provides, and choose the one you feel the most confident about. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/6/what-config-files - -作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[unigeorge](https://github.com/unigeorge) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/seth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_screen_windows_files.png?itok=kLTeQUbY (Computer screen with files or windows open) -[2]: https://opensource.com/article/20/9/awk-ebook -[3]: https://opensource.com/downloads/grep-cheat-sheet -[4]: https://www.redhat.com/sysadmin/yaml-beginners -[5]: https://opensource.com/article/19/2/getting-started-cat-command -[6]: https://opensource.com/article/21/2/open-source-text-editors -[7]: https://www.unidata.ucar.edu/software/netcdf/ diff --git a/sources/tech/20210702 Creating a PKGBUILD to Make Packages for Arch Linux.md b/sources/tech/20210702 Creating a PKGBUILD to Make Packages for Arch Linux.md deleted file mode 100644 index c3078135ca..0000000000 --- a/sources/tech/20210702 Creating a PKGBUILD to Make Packages for Arch Linux.md +++ /dev/null @@ -1,271 +0,0 @@ -[#]: subject: (Creating a PKGBUILD to Make Packages for Arch Linux) -[#]: via: (https://itsfoss.com/create-pkgbuild/) -[#]: author: (Hunter Wittenborn https://itsfoss.com/author/hunter/) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Creating a PKGBUILD to Make Packages for Arch Linux -====== - -PKGBUILD files are how packages are built and created for Arch Linux and its derivatives such as Manjaro. - -You may have even come across them a bit yourself if you’ve ever used the [AUR][1], Arch Linux’s user-curated repository of PKGBUILDs. - -But how exactly do you go from a PKGBUILD to an installable package? What exactly is going on between the two, and how can you make them for your own packages? You’ll learn them in this article. - -### PKGBUILD basics - -For those who are familiar with Bash or other shells, you’ll be delighted to know, if you didn’t already, that a PKGBUILD is pretty much just a shell script with some variables. - -PKGBUILD files consist of variables and functions, all of which are used to define the package itself, and how to build it. - -To create a package from a PKGBUILD, the makepkg command line utility is used. After obtaining a PKGBUILD, you simply run `makepkg` inside the directory containing the PKGBUILD, and voila, you have an installable package! - -![][2] - -In this tutorial, you’ll be going over the package I just made, which prints “Hello World!” when run: - -![][3] - -### Getting set up - -To follow along with this tutorial, you need to create a couple of files. - -First, you need to make a file called **PKGBUILD**. If it wasn’t already made clear, this will serve as the “recipe” for building your package. - -The other file you’ll need to make is a file called **hello-world.sh**. I’ll explain its purpose a bit later. - -You can create both of these files with a single command as well. - -``` -touch PKGBUILD hello-world.sh -``` - -You can check that the files were created with the ls command: - -![][4] - -And you’re ready to go! - -### Setting up your PKGBUILD file - -**Instead of having you copy paste the whole file, I’ll be going over entering every line with you, so you can better understand the purpose of everything that’s happening. If you don’t prefer to learn this way, I’d highly recommend the** [Arch Wiki article][5] _**on creating packages for Arch Linux.**_ - -_**This article also doesn’t go over every single option you can set in a PKGBUILD, but rather some commonly used ones so you can get going as quickly as possible.**_ - -With that out of the way, open up your text editor, and let’s get straight into it! - -#### pkgname - -First things first, the pkgname variable. This is what defines the name of your package when installing, and how [Arch Linux’s package manager pacman][6] keeps track of the package. - -The format of this variable (and some others) takes the form of variable=value, with the variable name on the left, the value of the variable on the right, separated by an equals sign. - -To set the package name, enter the following into the PKGBUILD: - -``` -pkgname="hello-world" -``` - - * To set a different package name, replace `hello-world` with the name of the package. - * This doesn’t set the command used to run the program. That’s handled a bit below in the `package()` section. - - - -#### pkgver - -As is stated in the variable name itself, this sets the version of your package (i.e. 1.0.0). This is useful when a user updates their system, as setting a higher version will result in the user being prompted for an upgrade. - -To set, enter the following into the PKGBUILD (after the previous line): - -``` -pkgver="1.0.0" -``` - -#### pkgrel - -This is related to the pkgver variable, and isn’t normally important to know about. Like the pkgver variable though, it will notify users for upgrades if it’s moved to a higher number. - -It serves for any changes that require the pkgver to remain the same, such as any changes to the PKGBUILD itself. This would be useful if you’ve created a PKGBUILD for a program you use (and want to keep the version the same as the package’s), and you need to fix a bug in the PKGBUILD itself. - -To set the variable, enter the following in the PKGBUILD: - -``` -pkgver="1" -``` - -This variable should **always** start at 1, and then move up one at a time. When the **pkgver** itself moves up, this can (and should) be reset to 1, as the pkgver itself will notify users that upgrades are available. - -#### pkgdesc - -This will set the description of the package, which is used to help better identify the package. - -To set it, just put the description inside of quotation marks: - -``` -pkgdesc="Hello world in your terminal!" -``` - -#### arch - -This variable sets the [architecture][7] the package is compatible with. It’s fine if you don’t understand what an architecture is, as it’s pretty much useless in most cases. - -Regardless, makepkg still needs it to be set so it knows the package is compatible with our system. - -This variable supports setting multiple values, so makepkg requires a different syntax as shown below. - -To set it, enter the following in the PKGBUILD: - -``` -arch=("x86_64") -``` - -If you were to set multiple values for this, you would separate each value with a space and quotation marks like so: **arch=(“x86_x64” “arm”)** - -#### depends - -This lists all of the packages that our package needs to function. Like **arch**, it can also contain multiple values, and thus must use the parenthesis syntax. - -Since our package won’t have any dependencies, we don’t have to enter this field in the PKGBUILD. If our package did have dependencies however, we’d just use the same syntax as **arch**. - -#### optdepends - -This lists packages that aren’t required to function, but that are needed for extra functionality. - -This follows the same syntax as **depends**. - -#### conflicts - -This tells pacman what packages would cause our package to act up or behave in a way we wouldn’t want. - -Any package listed here would be uninstalled before ours is installed. - -This follows the same syntax as **depends** as well. - -#### license - -This defines the [software license][8] that your program is licensed under. The [Arch Wiki][9] has some info if you need help choosing a license. Setting this to `custom` will work if you don’t know what to set this to. - -This takes the same syntax as **arch** and **depends**: - -``` -license=("custom") -``` - -#### source - -This is how makepkg knows what files to use to build our package. This can contain a variety of different kinds of sources, including local files and URLs. - -When adding local files, enter the file’s name relative to the PKGBUILD i.e. consider the following directory layout: - -``` -PKGBUILD -file.txt -src/file.sh -``` - -If you wanted to include **file.sh** in our PKGBUILD, you would enter **src/file.sh** as its name. - -When entering URLs, you simply enter the full URL, i.e. . - -Your package only needs the hello-world.sh file, and since it’s in the same directory as the PKGBUILD, you just type its name as the value for **source**. - -This variable also uses the same syntax as **arch** and **depends**: - -``` -source=("hello-world.sh") -``` - -#### sha512sums - -This is used to verify that the files in **source** haven’t been modified or downloaded incorrectly. Information on obtaining the values for this can be found in the [Arch Wiki article on PKGBUILDs][10]. - -If you’d rather just not set this (or you just don’t need to, i.e. for local files), you can just enter SKIP for every file in the **source** variable: - -``` -sha512sums=("SKIP") -``` - -#### package() - -This is the last, and most important part to actually making our package. It’s important to know two variables when working with this: - - * **${srcdir}**: This is where makepkg puts the files in the **source** variable. This is the directory where you can interact with the files, and do any other needed modification to the files. - - - * ${pkgdir}: This is where we place the files that will be installed on our system. -The folder structure for ${pkgdir} is set up as if it was on an actual system (i.e. ${pkgdir}/usr/bin/hello-world would create the file /usr/bin/hello-world when installing with pacman. - - - -package() contains a list of commands used create a package. - -So, if (hypothetically) you needed to have a file that reads Linux is superior to Windows at /usr/share/motto.txt, you would run something like this: - -``` -package() { - mkdir -p "${pkgdir}/usr/share" - echo "Linux is superior to Windows" | tee "${pkgdir}/usr/share/motto.txt" -} -``` - -A few notes on the above command: - - * ${pkgdir} contains **no** directories inside it at first. If you skipped the [mkdir command][11], tee would output an error saying the directory doesn’t exist. - - - * When specifying directories, **always** prepend them with the **${pkgdir}** or **${srcdir}** variable. Entering something like /usr/share/motto.txt without such would point to the literal directory /usr/share/motto.txt on your currently running system. - - - -For your PKGBUILD, you’re going to place the file hello-world.sh at /usr/bin/hello-world on your target system. You’ll also be making the file say “Hello to you!” when ran. - -To do so, enter the following into your PKGBUILD: - -``` -package() { - echo 'Hello to you!' > "${srcdir}/hello-world.sh" - mkdir -p "${pkgdir}/usr/bin" - cp "${srcdir}/hello-world.sh" "${pkgdir}/usr/bin/hello-world" - chmod +x "${pkgdir}/usr/bin/hello-world" -} -``` - -And you’re done! **Build and install the package with makepkg -si**, and then run hello-world in your terminal to see its output. - -![][12] - -### Wrapping Up - -And just like that, you have made your first PKGBUILD! You’re on your way to making actual packages for yourself, and maybe even the AUR. - -Got any questions, or something just not working right? Feel free to post it in the comment section below. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/create-pkgbuild/ - -作者:[Hunter Wittenborn][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/hunter/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/aur-arch-linux/ -[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/image.png?resize=748%2C689&ssl=1 -[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/image-2.png?resize=682%2C260&ssl=1 -[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/05/image-3.png?resize=682%2C265&ssl=1 -[5]: https://wiki.archlinux.org/title/Creating_packages -[6]: https://itsfoss.com/pacman-command/ -[7]: https://www.quora.com/What-is-CPU-architecture -[8]: https://en.wikipedia.org/wiki/Software_license -[9]: https://wiki.archlinux.org/title/PKGBUILD#license -[10]: https://wiki.archlinux.org/title/PKGBUILD#Integrity -[11]: https://linuxhandbook.com/mkdir-command/ -[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/image-1.png?resize=561%2C281&ssl=1 diff --git a/sources/tech/20210728 Kernel tracing with trace-cmd.md b/sources/tech/20210728 Kernel tracing with trace-cmd.md deleted file mode 100644 index cd5b549e40..0000000000 --- a/sources/tech/20210728 Kernel tracing with trace-cmd.md +++ /dev/null @@ -1,376 +0,0 @@ -[#]: subject: (Kernel tracing with trace-cmd) -[#]: via: (https://opensource.com/article/21/7/linux-kernel-trace-cmd) -[#]: author: (Gaurav Kamathe https://opensource.com/users/gkamathe) -[#]: collector: (lujun9972) -[#]: translator: (mengxinayan) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Kernel tracing with trace-cmd -====== -trace-cmd is an easy-to-use, feature-rich utility for tracing Linux -kernel functions. -![Puzzle pieces coming together to form a computer screen][1] - -In my [previous article][2], I explained how to use `ftrace` to trace kernel functions. Using `ftrace` by writing and reading from files can get tedious, so I used a wrapper around it to run commands with options to enable and disable tracing, set filters, view output, clear output, and more. - -The [trace-cmd][3] command is a utility that helps you do just this. In this article, I use `trace-cmd` to perform the same tasks I did in my `ftrace` article. Since I refer back to that article frequently, I recommend you read it before you read this one. - -### Install trace-cmd - -I run the commands in this article as the root user. - -The `ftrace` mechanism is built into the kernel, and you can verify it is enabled with: - - -``` -# mount | grep tracefs -none on /sys/kernel/tracing type tracefs (rw,relatime,seclabel) -``` - -However, you need to install the `trace-cmd` utility manually. - - -``` -`# dnf install trace-cmd -y` -``` - -### List available tracers - -When using `ftrace`, you must view a file's contents to see what tracers are available. But with `trace-cmd`, you can get this information with: - - -``` -# trace-cmd list -t -hwlat blk mmiotrace function_graph wakeup_dl wakeup_rt wakeup function nop -``` - -### Enable the function tracer - -In my [earlier article][2], I used two tracers, and I'll do the same here. Enable your first tracer, `function`, with: - - -``` -$ trace-cmd start -p function -  plugin 'function' -``` - -### View the trace output - -Once the tracer is enabled, you can view the output by using the `show` arguments. This shows only the first 20 lines to keep the example short (see my earlier article for an explanation of the output): - - -``` -# trace-cmd show | head -20 -## tracer: function -# -# entries-in-buffer/entries-written: 410142/3380032   #P:8 -# -#                                _-----=> irqs-off -#                               / _----=> need-resched -#                              | / _---=> hardirq/softirq -#                              || / _--=> preempt-depth -#                              ||| /     delay -#           TASK-PID     CPU#  ||||   TIMESTAMP  FUNCTION -#              | |         |   ||||      |         | -           gdbus-2606    [004] ..s. 10520.538759: __msecs_to_jiffies <-rebalance_domains -           gdbus-2606    [004] ..s. 10520.538760: load_balance <-rebalance_domains -           gdbus-2606    [004] ..s. 10520.538761: idle_cpu <-load_balance -           gdbus-2606    [004] ..s. 10520.538762: group_balance_cpu <-load_balance -           gdbus-2606    [004] ..s. 10520.538762: find_busiest_group <-load_balance -           gdbus-2606    [004] ..s. 10520.538763: update_group_capacity <-update_sd_lb_stats.constprop.0 -           gdbus-2606    [004] ..s. 10520.538763: __msecs_to_jiffies <-update_group_capacity -           gdbus-2606    [004] ..s. 10520.538765: idle_cpu <-update_sd_lb_stats.constprop.0 -           gdbus-2606    [004] ..s. 10520.538766: __msecs_to_jiffies <-rebalance_domains -``` - -### Stop tracing and clear the buffer - -Tracing continues to run in the background, and you can keep viewing the output using `show`. - -To stop tracing, run `trace-cmd` with the `stop` argument: - - -``` -`# trace-cmd stop` -``` - -To clear the buffer, run it with the `clear` argument: - - -``` -`# trace-cmd clear` -``` - -### Enable the function_graph tracer - -Enable the second tracer, `function_graph`, by running: - - -``` -# trace-cmd start -p function_graph -  plugin 'function_graph' -``` - -Once again, view the output using the `show` argument. As expected, the output is slightly different from the first trace output. This time it includes a `function calls` chain: - - -``` -# trace-cmd show | head -20 -## tracer: function_graph -# -# CPU  DURATION                  FUNCTION CALLS -# |     |   |                     |   |   |   | - 4)   0.079 us    |        } /* rcu_all_qs */ - 4)   0.327 us    |      } /* __cond_resched */ - 4)   0.081 us    |      rcu_read_unlock_strict(); - 4)               |      __cond_resched() { - 4)   0.078 us    |        rcu_all_qs(); - 4)   0.243 us    |      } - 4)   0.080 us    |      rcu_read_unlock_strict(); - 4)               |      __cond_resched() { - 4)   0.078 us    |        rcu_all_qs(); - 4)   0.241 us    |      } - 4)   0.080 us    |      rcu_read_unlock_strict(); - 4)               |      __cond_resched() { - 4)   0.079 us    |        rcu_all_qs(); - 4)   0.235 us    |      } - 4)   0.095 us    |      rcu_read_unlock_strict(); - 4)               |      __cond_resched() { -``` - -Use the `stop` and `clear` commands to stop tracing and clear the buffer: - - -``` -# trace-cmd stop -# trace-cmd clear -``` - -### Tweak tracing to increase depth - -If you want to see more depth in the function calls, you can tweak the tracer: - - -``` -# trace-cmd start -p function_graph --max-graph-depth 5 -  plugin 'function_graph' -``` - -Now when you compare this output with what you saw before, you should see more nested function calls: - - -``` -# trace-cmd show | head -20 -## tracer: function_graph -# -# CPU  DURATION                  FUNCTION CALLS -# |     |   |                     |   |   |   | - 6)               |        __fget_light() { - 6)   0.804 us    |          __fget_files(); - 6)   2.708 us    |        } - 6)   3.650 us    |      } /* __fdget */ - 6)   0.547 us    |      eventfd_poll(); - 6)   0.535 us    |      fput(); - 6)               |      __fdget() { - 6)               |        __fget_light() { - 6)   0.946 us    |          __fget_files(); - 6)   1.895 us    |        } - 6)   2.849 us    |      } - 6)               |      sock_poll() { - 6)   0.651 us    |        unix_poll(); - 6)   1.905 us    |      } - 6)   0.475 us    |      fput(); - 6)               |      __fdget() { -``` - -### Learn available functions to trace - -If you want to trace only certain functions and ignore the rest, you need to know the exact function names. You can get them with the `list` argument followed by `-f`. This example searches for the common kernel function `kmalloc`, which is used to allocate memory in the kernel: - - -``` -# trace-cmd list -f | grep kmalloc -bpf_map_kmalloc_node -mempool_kmalloc -__traceiter_kmalloc -__traceiter_kmalloc_node -kmalloc_slab -kmalloc_order -kmalloc_order_trace -kmalloc_large_node -__kmalloc -__kmalloc_track_caller -__kmalloc_node -__kmalloc_node_track_caller -[...] -``` - -Here's the total count of functions available on my test system: - - -``` -# trace-cmd list -f | wc -l -63165 -``` - -### Trace kernel module-related functions - -You can also trace functions related to a specific kernel module. Imagine you want to trace `kvm` kernel module-related functions. Ensure the module is loaded: - - -``` -# lsmod  | grep kvm_intel -kvm_intel             335872  0 -kvm                   987136  1 kvm_intel -``` - -Run `trace-cmd` again with the `list` argument, and from the output, `grep` for lines that end in `]`. This will filter out the kernel modules. Then `grep` the kernel module `kvm_intel`, and you should see all the functions related to that kernel module: - - -``` -# trace-cmd list -f | grep ]$  | grep kvm_intel -vmx_can_emulate_instruction [kvm_intel] -vmx_update_emulated_instruction [kvm_intel] -vmx_setup_uret_msr [kvm_intel] -vmx_set_identity_map_addr [kvm_intel] -handle_machine_check [kvm_intel] -handle_triple_fault [kvm_intel] -vmx_patch_hypercall [kvm_intel] - -[...] - -vmx_dump_dtsel [kvm_intel] -vmx_dump_sel [kvm_intel] -``` - -### Trace specific functions - -Now that you know how to find functions of interest, put that knowledge to work with an example. As in the earlier article, try to trace filesystem-related functions. The filesystem I had on my test system was `ext4`. - -This procedure is slightly different; instead of `start`, you run the command with the `record` argument followed by the "pattern" of the functions you want to trace. You also need to specify the tracer you want; in this case, that's `function_graph`. The command continues recording the trace until you stop it with **Ctrl+C**. So after a few seconds, hit **Ctrl+C** to stop tracing: - - -``` -# trace-cmd list -f | grep ^ext4_ - -# trace-cmd record -l ext4_* -p function_graph -  plugin 'function_graph' -Hit Ctrl^C to stop recording -^C -CPU0 data recorded at offset=0x856000 -    8192 bytes in size -[...] -``` - -### View the recorded trace - -To view the trace you recorded earlier, run the command with the `report` argument. From the output, it's clear that the filter worked, and you see only the ext4-related function trace: - - -``` -# trace-cmd report | head -20 -[...] -cpus=8 -       trace-cmd-12697 [000] 11303.928103: funcgraph_entry:                   |  ext4_show_options() { -       trace-cmd-12697 [000] 11303.928104: funcgraph_entry:        0.187 us   |    ext4_get_dummy_policy(); -       trace-cmd-12697 [000] 11303.928105: funcgraph_exit:         1.583 us   |  } -       trace-cmd-12697 [000] 11303.928122: funcgraph_entry:                   |  ext4_create() { -       trace-cmd-12697 [000] 11303.928122: funcgraph_entry:                   |    ext4_alloc_inode() { -       trace-cmd-12697 [000] 11303.928123: funcgraph_entry:        0.101 us   |      ext4_es_init_tree(); -       trace-cmd-12697 [000] 11303.928123: funcgraph_entry:        0.083 us   |      ext4_init_pending_tree(); -       trace-cmd-12697 [000] 11303.928123: funcgraph_entry:        0.141 us   |      ext4_fc_init_inode(); -       trace-cmd-12697 [000] 11303.928123: funcgraph_exit:         0.931 us   |    } -       trace-cmd-12697 [000] 11303.928124: funcgraph_entry:        0.081 us   |    ext4_get_dummy_policy(); -       trace-cmd-12697 [000] 11303.928124: funcgraph_entry:        0.133 us   |    ext4_get_group_desc(); -       trace-cmd-12697 [000] 11303.928124: funcgraph_entry:        0.115 us   |    ext4_free_inodes_count(); -       trace-cmd-12697 [000] 11303.928124: funcgraph_entry:        0.114 us   |    ext4_get_group_desc(); -``` - -### Trace a specific PID - -Say you want to trace functions related to a specific persistent identifier (PID). Open another terminal and note the PID of the running shell: - - -``` -# echo $$ -10885 -``` - -Run the `record` command again and pass the PID using the `-P` option. This time, let the terminal run (i.e., do not press **Ctrl+C** yet): - - -``` -# trace-cmd record -P 10885 -p function_graph -  plugin 'function_graph' -Hit Ctrl^C to stop recording -``` - -### Run some activity on the shell - -Move back to the other terminal where you had a shell running with a specific PID and run any command, e.g., `ls` to list files: - - -``` -# ls -Temp-9b61f280-fdc1-4512-9211-5c60f764d702 -tracker-extract-3-files.1000 -v8-compile-cache-1000 -[...] -``` - -Move back to the terminal where you enabled tracing and hit **Ctrl+C** to stop tracing: - - -``` -# trace-cmd record -P 10885 -p function_graph -  plugin 'function_graph' -Hit Ctrl^C to stop recording -^C -CPU1 data recorded at offset=0x856000 -    618496 bytes in size -[...] -``` - -In the trace's output, you can see the PID and the Bash shell on the left and the function calls related to it on the right. This can be pretty handy to narrow down your tracing: - - -``` -# trace-cmd report  | head -20 - -cpus=8 -          <idle>-0     [001] 11555.380581: funcgraph_entry:                   |  switch_mm_irqs_off() { -          <idle>-0     [001] 11555.380583: funcgraph_entry:        1.703 us   |    load_new_mm_cr3(); -          <idle>-0     [001] 11555.380586: funcgraph_entry:        0.493 us   |    switch_ldt(); -          <idle>-0     [001] 11555.380587: funcgraph_exit:         7.235 us   |  } -            bash-10885 [001] 11555.380589: funcgraph_entry:        1.046 us   |  finish_task_switch.isra.0(); -            bash-10885 [001] 11555.380591: funcgraph_entry:                   |  __fdget() { -            bash-10885 [001] 11555.380592: funcgraph_entry:        2.036 us   |    __fget_light(); -            bash-10885 [001] 11555.380594: funcgraph_exit:         3.256 us   |  } -            bash-10885 [001] 11555.380595: funcgraph_entry:                   |  tty_poll() { -            bash-10885 [001] 11555.380597: funcgraph_entry:                   |    tty_ldisc_ref_wait() { -            bash-10885 [001] 11555.380598: funcgraph_entry:                   |      ldsem_down_read() { -            bash-10885 [001] 11555.380598: funcgraph_entry:                   |        __cond_resched() { -``` - -### Give it a try - -These brief examples show how using `trace-cmd` instead of the underlying `ftrace` mechanism is both easy to use and rich in features, including many I didn't cover here. To learn more and get better at it, consult its man page and try out its other useful commands. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/7/linux-kernel-trace-cmd - -作者:[Gaurav Kamathe][a] -选题:[lujun9972][b] -译者:[萌新阿岩](https://github.com/mengxinayan) -校对:[校对者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/puzzle_computer_solve_fix_tool.png?itok=U0pH1uwj (Puzzle pieces coming together to form a computer screen) -[2]: https://opensource.com/article/21/7/analyze-linux-kernel-ftrace -[3]: https://lwn.net/Articles/410200/ diff --git a/sources/tech/20210818 below- a time traveling resource monitor.md b/sources/tech/20210818 below- a time traveling resource monitor.md deleted file mode 100644 index 0b55e8b14b..0000000000 --- a/sources/tech/20210818 below- a time traveling resource monitor.md +++ /dev/null @@ -1,111 +0,0 @@ -[#]: subject: "below: a time traveling resource monitor" -[#]: via: "https://fedoramagazine.org/below-a-time-traveling-resource-monitor/" -[#]: author: "Daniel Xu https://fedoramagazine.org/author/dxuu/" -[#]: collector: "lujun9972" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -below: a time traveling resource monitor -====== - -![][1] - -In this article, we introduce _below_: an Apache 2.0 licensed resource monitor for modern Linux systems. _below_ allows you to replay previously recorded data. - -### Background - -One of the kernel’s primary responsibilities is mediating access to resources. Sometimes this might mean parceling out physical memory such that multiple processes can share the same host. Other times it might mean ensuring equitable distribution of CPU time. In all these contexts, the kernel provides the mechanism and leaves the policy to “someone else”. In more recent times, this “someone else” is usually a runtime like systemd or dockerd. The runtime takes input from a scheduler or end user — something along the lines of what to run and how to run it — and turns the right knobs and pulls the right levers on the kernel such that the workload can —well — get to work. - -In a perfect world this would be the end of the story. However, the reality is that resource management is a complex and rather opaque amalgam of technologies that has evolved over decades of computing. Despite some of this technology having various warts and dead ends, the end result — a container — works relatively well. While the user does not usually need to concern themselves with the details, it is crucial for infrastructure operators to have visibility into their stack. Visibility and debuggability are essential for detecting and investigating misconfigurations, bugs, and systemic issues. - -To make matters more complicated, resource outages are often difficult to reproduce. It is not unusual to spend weeks waiting for an issue to reoccur so that the root cause can be investigated. Scale further compounds this issue: one cannot run a custom script on _every_ host in the hopes of logging bits of crucial state if the bug happens again. Therefore, more sophisticated tooling is required. Enter _below_. - -### Motivation - -Historically Facebook has been a heavy user of _atop_ [0]. _atop_ is a performance monitor for Linux that is capable of reporting the activity of all processes as well as various pieces of system level activity. One of the most compelling features _atop_ has over tools like _htop_ is the ability to record historical data as a daemon. This sounds like a simple feature, but in practice this has enabled debugging countless production issues. With long enough data retention, it is possible to go backwards in time and look at the host state before, during, and after the issue or outage. - -Unfortunately, it became clear over the years that _atop_ had certain deficiencies. First, cgroups [1] have emerged as the defacto way to control and monitor resources on a Linux machine. _atop_ still lacks support for this fundamental building block. Second, _atop_ stores data on disk with custom delta compression. This works fine under normal circumstances, but under heavy resource pressure the host is likely to lose data points. Since delta compression is in use, huge swaths of data can be lost for periods of time where the data is most important. Third, the user experience has a steep learning curve. We frequently heard from _atop_ power users that they love the dense layout and numerous keybindings. However, this is a double edged sword. When someone new to the space wants to debug a production issue, they’re solving two problems at once now: the issue at hand and how to use _atop_. - -_below_ was designed and developed by and for the resource control team at Facebook with input from production _atop_ users. The resource control team is responsible for, as the name suggests, resource management at scale. The team is comprised of kernel developers, container runtime developers, and hardware folks. Recognizing the opportunity for a next-generation system monitor, we designed _below_ with the following in mind: - - * Ease of use: _below_ must be both intuitive for new users as well as powerful for daily users - * Opinionated statistics: _below_ displays accurate and useful statistics. We try to avoid collecting and dumping stats just because we can. - * Flexibility: when the default settings are not enough, we allow the user to customize their experience. Examples include configurable keybindings, configurable default view, and a scripting interface (the default being a terminal user interface). - - - -### Install - -To install the package: - -``` -# dnf install -y below -``` - -To turn on the recording daemon: - -``` -# systemctl enable --now below -``` - -### Quick tour - -_below_’s most commonly used mode is replay mode. As the name implies, replay mode replays previously recorded data. Assuming you’ve already started the recording daemon, start a session by running: - -``` -$ below replay --time "5 minutes ago" -``` - -You will then see the cgroup view: - -![][2] - -If you get stuck or forget a keybinding, press **?** to access the help menu. - -The very top of the screen is the status bar. The status bar displays information about the current sample. You can move forwards and backwards through samples by pressing **t** and **T**, respectively. The middle section is the system overview. The system overview contains statistics about the system as a whole that are generally always useful to see. The third and lowest section is the multipurpose view. The image above shows the cgroup view. Additionally, there are process and system views, accessible by pressing **p** and **s**, respectively. - -Press **↑** and **↓** to move the list selection. Press **<Enter>** to collapse and expand cgroups. Suppose you’ve found an interesting cgroup and you want to see what processes are running inside it. To zoom into the process view, select the cgroup and press **z**: - -![][3] - -Press **z** again to return to the cgroup view. The cgroup view can be somewhat long at times. If you have a vague idea of what you’re looking for, you can filter by cgroup name by pressing **/** and entering a filter: - -![][4] - -At this point, you may have noticed a tab system we haven’t explored yet. To cycle forwards and backwards through tabs, press **<Tab>** and **<Shift> \+ <Tab>** respectively. We’ll leave this as an exercise to the reader. - -### Other features - -Under the hood, _below_ has a powerful design and architecture. Facebook is constantly upgrading to newer kernels, so we never assume a data source is available. This tacit assumption enables total backwards and forwards compatibility between kernels and _below_ versions. Furthermore, each data point is zstd compressed and stored in full. This solves the issues with delta compression we’ve seen _atop_ have at scale. Based on our tests, our per-sample compression can achieve on average a 5x compression ratio. - -_below_ also uses eBPF [2] to collect information about short-lived processes (processes that live for shorter than the data collection interval). In contrast, _atop_ implements this feature with BSD process accounting, a known slow and priority-inversion-prone kernel interface. - -For the user, _below_ also supports live-mode and a dump interface. Live mode combines the recording daemon and the TUI session into one process. This is convenient for browsing system state without committing to a long running daemon or disk space for data storage. The dump interface is a scriptable interface to all the data _below_ stores. Dump is both powerful and flexible — detailed data is available in CSV, JSON, and human readable format. - -### Conclusion - -_below_ is an Apache 2.0 licensed open source project that we (the _below_ developers) think offers compelling advantages over existing tools in the resource monitoring space. We’ve spent a great deal of effort preparing _below_ for open source use so we hope that readers and the community get a chance to try _below_ out and report back with bugs and feature requests. - -[0]: -[1]: -[2]: - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/below-a-time-traveling-resource-monitor/ - -作者:[Daniel 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://fedoramagazine.org/author/dxuu/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2021/08/below_resource_monitor-816x345.jpg -[2]: https://fedoramagazine.org/wp-content/uploads/2021/08/image-1024x800.png -[3]: https://fedoramagazine.org/wp-content/uploads/2021/08/image-1-1024x800.png -[4]: https://fedoramagazine.org/wp-content/uploads/2021/08/image-2-1024x800.png diff --git a/sources/tech/20210907 How to use BusyBox on Linux.md b/sources/tech/20210907 How to use BusyBox on Linux.md deleted file mode 100644 index dfcc7dbd6d..0000000000 --- a/sources/tech/20210907 How to use BusyBox on Linux.md +++ /dev/null @@ -1,189 +0,0 @@ -[#]: subject: "How to use BusyBox on Linux" -[#]: via: "https://opensource.com/article/21/8/what-busybox" -[#]: author: "Seth Kenlon https://opensource.com/users/seth" -[#]: collector: "lujun9972" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -How to use BusyBox on Linux -====== -BusyBox is an open source (GPL) project providing simple implementations -of nearly 400 common commands. -![bash logo on green background][1] - -It's easy to take Linux commands for granted. They come bundled with the system when you install Linux, and we often don't question why they're there. Some of the basic commands, such as [`cd`][2], [`kill`][3], and `echo` aren't always independent applications but are actually built into your shell. Others, such as [`ls`][4], [`mv`][5], and [`cat`][6] are part of a core utility package (often GNU `coreutils` specifically). But there are always alternatives in the world of open source, and one of the most interesting is [BusyBox][7]. - -### What is BusyBox in Linux? - -BusyBox is an open source (GPL) project providing simple implementations of nearly 400 common commands, including `ls`, `mv`, `ln`, `mkdir`, `more`, `ps`, `gzip`, `bzip2`, `tar`, and `grep`. It also contains a version of the programming language `awk`, the stream editor `sed`, the filesystem checker `fsck`, the `rpm` and `dpkg` package managers, and of course, a shell (`sh`) that provides easy access to all of these commands. In short, it contains all the essential commands required for a POSIX system to perform common system maintenance tasks as well as many user and administrative tasks. - -In fact, it even contains an `init` command which can be launched as PID 1 to serve as the parent process for all other system services. In other words, BusyBox can be used as an alternative to [systemd][8], OpenRC, sinit, init, and other launch daemons. - -BusyBox is very small. As an executable, it's under 1 MB, so it has gained much of its popularity in the [embedded][9], [Edge][10], and [IoT][11] space, where drive space is at a premium. In the world of containers and cloud computing, it's also popular as a foundation for minimal Linux container images. - -### Minimalism - -Part of the appeal of BusyBox is its minimalism. All of its commands are compiled into a single binary (`busybox`), and its man page is a mere 81 pages (by my calculation of piping `man` to `pr`) but covers nearly 400 commands. - -As an example comparison, here's the output of the `shadow` version of `useradd --help`: - - -``` - -b, --base-dir BASE_DIR       base directory for home - -c, --comment COMMENT         GECOS field of the new account - -d, --home-dir HOME_DIR       home directory of the new account - -D, --defaults                print or change the default config - -e, --expiredate EXPIRE_DATE  expiration date of the new account - -f, --inactive INACTIVE       password inactivity - -g, --gid GROUP               name or ID of the primary group - -G, --groups GROUPS           list of supplementary groups - -h, --help                    display this help message and exit - -k, --skel SKEL_DIR           alternative skeleton dir - -K, --key KEY=VALUE           override /etc/login.defs - -l, --no-log-init             do not add the user to the lastlog - -m, --create-home             create the user's home directory - -M, --no-create-home          do not create the user's home directory - -N, --no-user-group           do not create a group with the user's name - -o, --non-unique              allow users with non-unique UIDs - -p, --password PASSWORD       encrypted password of the new account - -r, --system                  create a system account - -R, --root CHROOT_DIR         directory to chroot into - -s, --shell SHELL             login shell of the new account - -u, --uid UID                 user ID of the new account - -U, --user-group              create a group with the same name as a user -``` - -And here's the BusyBox version of the same command: - - -``` - -h DIR    Home directory - -g GECOS  GECOS field - -s SHELL  Login shell - -G GRP    Group - -S            Create a system user - -D            Don't assign a password - -H            Don't create home directory - -u UID    User id - -k SKEL   Skeleton directory (/etc/skel) -``` - -Whether or not this difference is a feature or a limitation depends on whether you prefer to have 20 options or ten options in your commands. For some users and use-cases, BusyBox's minimalism provides just enough for what needs to be done. For others, it's a good minimal environment to have as a fallback or as a foundation for installing more robust tools like [Bash][12], [Zsh][13], GNU [Awk][14], and so on. - -### Installing BusyBox - -On Linux, you can install BusyBox using your package manager. For example, on Fedora and similar: - - -``` -`$ sudo dnf install busybox` -``` - -On Debian and derivatives: - - -``` -`$ sudo apt install busybox` -``` - -On macOS, use [MacPorts][15] or [Homebrew][16]. On Windows, use [Chocolatey][17]. - -You can set BusyBox as your shell using the `chsh --shell` command, followed by the path to the BusyBox `sh` application. I keep BusyBox in `/lib64`, but its location depends on where your distribution installed it. - - -``` -$ which busybox -/lib64/busybox/busybox -$ chsh --shell /lib64/busybox/sh -``` - -Replacing all common commands wholesale with BusyBox is a little more complex, because most distributions are "hard-wired" to look to specific packages for specific commands. In other words, while it's technically possible to replace `init` with BusyBox's `init`, your package manager may refuse to allow you to remove the package containing `init` for fear of you causing your system to become non-bootable. There are some distributions built upon BusyBox, so starting fresh is probably the easiest way to experience a system built around BusyBox. - -### Try BusyBox - -You don't have to change your shell to BusyBox permanently just to try it. You can launch a BusyBox shell from your current shell: - - -``` -$ busybox sh -~ $ -``` - -Your system still has the non-BusyBox versions of commands installed, though, so to experience BusyBox's tools, you must issue commands as arguments to the `busybox` executable: - - -``` -~ $ busybox echo $0 -sh -~ $ busybox ls --help -BusyBox vX.YY.Z (2021-08-25 07:31:48 NZST) multi-call binary. - -Usage: ls [-1AaCxdLHRFplinshrSXvctu] [-w WIDTH] [FILE]... - -List directory contents - - -1  One column output - -a  Include entries that start with . - -A  Like -a, but exclude . and .. - -x  List by lines -[...] -``` - -For the "full" BusyBox experience, you can create symlinks to `busybox` for each command. This is easier than it sounds, as long as you use a [for-loop][18]: - - -``` -$ mkdir bbx -$ for i in $(bbx --list); do \ -ln -s /path/to/busybox bbx/$i \ -done -``` - -Add your directory of symlinks at the _start_ of your [path][19], and launch BusyBox: - - -``` -`$ PATH=$(pwd)/bbx:$PATH bbx/sh` -``` - -### Get busy - -BusyBox is a fun project and an example of just how _minimal_ computing can be. Whether you use BusyBox as a lightweight environment for an [ancient computer][20] [you've rescued][21], as the userland for an [embedded device][22], to trial a new init system, or just as a curiosity, it can be fun reacquainting yourself with old familiar, yet somehow new, commands. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/8/what-busybox - -作者:[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/bash_command_line.png?itok=k4z94W2U (bash logo on green background) -[2]: https://opensource.com/article/21/8/navigate-linux-directories -[3]: https://opensource.com/article/18/5/how-kill-process-stop-program-linux -[4]: https://opensource.com/article/19/7/master-ls-command -[5]: https://opensource.com/article/19/8/moving-files-linux-depth -[6]: https://opensource.com/article/19/2/getting-started-cat-command -[7]: https://www.busybox.net -[8]: https://opensource.com/article/20/4/systemd -[9]: https://opensource.com/article/21/3/rtos-embedded-development -[10]: https://opensource.com/article/17/9/what-edge-computing -[11]: https://opensource.com/article/21/3/iot-measure-raspberry-pi -[12]: https://opensource.com/article/20/4/bash-sysadmins-ebook -[13]: https://opensource.com/article/19/9/getting-started-zsh -[14]: https://opensource.com/article/20/9/awk-ebook -[15]: https://opensource.com/article/20/11/macports -[16]: https://opensource.com/article/20/6/homebrew-mac -[17]: https://opensource.com/article/20/3/chocolatey -[18]: https://opensource.com/article/19/10/programming-bash-loops -[19]: https://opensource.com/article/17/6/set-path-linux -[20]: https://opensource.com/article/20/2/restore-old-computer-linux -[21]: https://opensource.com/article/19/7/how-make-old-computer-useful-again -[22]: https://opensource.com/article/20/6/open-source-rtos diff --git a/sources/tech/20210922 Install AnyDesk on Ubuntu Linux -GUI and Terminal Methods.md b/sources/tech/20210922 Install AnyDesk on Ubuntu Linux -GUI and Terminal Methods.md deleted file mode 100644 index 598d522f8d..0000000000 --- a/sources/tech/20210922 Install AnyDesk on Ubuntu Linux -GUI and Terminal Methods.md +++ /dev/null @@ -1,149 +0,0 @@ -[#]: subject: "Install AnyDesk on Ubuntu Linux [GUI and Terminal Methods]" -[#]: via: "https://itsfoss.com/install-anydesk-ubuntu/" -[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" -[#]: collector: "lujun9972" -[#]: translator: "geekpi" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -Install AnyDesk on Ubuntu Linux [GUI and Terminal Methods] -====== - -_**Brief: This beginner’s tutorial discusses both GUI and terminal methods of installing AnyDesk on Ubuntu-based Linux distributions.**_ - -[AnyDesk][1] is a popular remote desktop software available for Linux, Windows, BSD, macOS and mobile platforms. - -With this tool, you can remotely access other computer using AnyDesk or let someone else remotely access your system. Not everyone can access it just because two devices use AnyDesk. You have to accept the incoming connection and/or provide a password for secure connection. - -This is helpful in providing tech support to friend, family, colleagues or even to the customers. - -In this tutorial, I’ll show you both graphical and command line ways of installing AnyDesk on Ubuntu. You can use either method based on your preference. Both methods will install the same AnyDesk version on your Ubuntu system. - -The same method should be applicable to Debian and other Debian and Ubuntu based distributions such as Linux Mint, Linux Lite etc. - -Non-FOSS alert! - -AnyDesk is not open source software. It is covered here because it is available on Linux and the article’s focus is on Linux. - -### Method 1: Install AnyDesk on Ubuntu using terminal - -[Open the terminal application][2] on your system. You’ll need a tool like wget to [download files in the terminal. For th][3]at, use the following command: - -``` -sudo apt update -sudo apt install wget -``` - -The next step now is to download the GPG key of AnyDesk repository and add it to your system’s trusted keys. This way, your system will trust the software coming from this [external repository][4]. - -``` -wget -qO - https://keys.anydesk.com/repos/DEB-GPG-KEY | sudo apt-key add - -``` - -You may ignore the deprecated warning about apt-key command for now. The next step is to add the AnyDesk repository to your system’s repository sources: - -``` -echo "deb http://deb.anydesk.com/ all main" | sudo tee /etc/apt/sources.list.d/anydesk-stable.list -``` - -Update the package cache so that your system learns about the availability of new applications through the newly added repository. - -``` -sudo apt update -``` - -And now, you can install AnyDesk: - -``` -sudo apt install anydesk -``` - -Once that is done, you can start AnyDesk from the system menu or from the terminal itself: - -``` -anydesk -``` - -You can enjoy AnyDesk now. - -![AnyDesk running in Ubuntu][5] - -### Method 2: Install AnyDesk on Ubuntu graphically - -If you are not comfortable with the command line, no worries. You can also install AnyDesk without going into the terminal. - -You can download AnyDesk for Ubuntu from the official AnyDesk website: - -[Download AnyDesk for Linux][6] - -You’ll see a Download Now button. Click on it. - -![Download AnyDesk][7] - -When you click on the download button, it gives you options for various Linux distributions. Select the one for Ubuntu: - -![Download the appropriate file][8] - -It will download the DEB file of AnyDesk application. [Installing deb file][9] is easy. Either double click on it or right click and open with Software Install. - -![Right click on deb file and open with software center][10] - -Software Center application will be opened and you can install it from there. - -![Installing AnyDesk in Ubuntu software center][11] - -Once installed, search for it in the system menu and start from there. - -![AnyDesk installed in Ubuntu][12] - -That’s it. Not too hard, is it? - -I am not going to show the steps for using AnyDesk. I think you already have some idea about that. If not, refer to [this article][13], please. - -#### Troubleshooting tip - -When I tried to run AnyDesk from the system menu, it didn’t start. So, I started it from the terminal and it showed me this error: - -``` -[email protected]:~$ anydesk -anydesk: error while loading shared libraries: libpangox-1.0.so.0: cannot open shared object file: No such file or directory -``` - -If you see the [error while loading shared libraries][14] message, you install the package it is complaining about. Here’s what I did in my case: - -``` -sudo apt install libpangox-1.0-0 -``` - -That solved the issue for me and I hope it fixes for you as well. - -If you have any questions related to this topic, please let me know in the comment section. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/install-anydesk-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://anydesk.com/en -[2]: https://itsfoss.com/open-terminal-ubuntu/ -[3]: https://itsfoss.com/download-files-from-linux-terminal/ -[4]: https://itsfoss.com/adding-external-repositories-ubuntu/ -[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/anydesk-running-in-ubuntu.png?resize=800%2C418&ssl=1 -[6]: https://anydesk.com/en/downloads/linux -[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/any-desk-ubuntu-download.webp?resize=800%2C312&ssl=1 -[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/any-desk-ubuntu-download-1.webp?resize=800%2C427&ssl=1 -[9]: https://itsfoss.com/install-deb-files-ubuntu/ -[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/install-anaydesk-ubuntu.png?resize=800%2C403&ssl=1 -[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/installing-anydesk-in-ubuntu-software-center.png?resize=781%2C405&ssl=1 -[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/anydesk-installed-in-ubuntu.png?resize=759%2C196&ssl=1 -[13]: https://support.anydesk.com/Access -[14]: https://itsfoss.com/solve-open-shared-object-file-quick-tip/ diff --git a/sources/tech/20210923 Build your website with Jekyll.md b/sources/tech/20210923 Build your website with Jekyll.md deleted file mode 100644 index d177ed0d2c..0000000000 --- a/sources/tech/20210923 Build your website with Jekyll.md +++ /dev/null @@ -1,189 +0,0 @@ -[#]: subject: "Build your website with Jekyll" -[#]: via: "https://opensource.com/article/21/9/build-website-jekyll" -[#]: author: "Ayush Sharma https://opensource.com/users/ayushsharma" -[#]: collector: "lujun9972" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -Build your website with Jekyll -====== -Jekyll is an open source static site generator. You can write your -content in Markdown, use HTML/CSS for structure and presentation, and -Jekyll compiles it all into static HTML. -![Person using a laptop][1] - -Static website generators and JAMStack have taken off in recent years. And with good reason. There is no need for complex backends with only static HTML, CSS, and Javascript to serve. Not having backends means better security, lower operational overhead, and cheaper hosting. A win-win-win! - -In this article, I'm going to talk about Jekyll. As of this writing, [my personal website uses Jekyll][2]. Jekyll uses a Ruby engine to convert articles written in Markdown to generate HTML. [Sass][3] allows merging complex CSS rules into flat files. [Liquid][4] allows some programmatic control over otherwise static content. - -### Install Jekyll - -The [Jekyll website][5] has installation instructions for Linux, MacOS, and Windows. After installation, the [Quickstart guide][6] will set up a basic Hello-World project. - -Now visit `http://localhost:4000` in your browser. You should see your default "awesome" blog. - -![Default "awesome" blog][7] - -Screenshot by Ayush Sharma, [CC BY-SA 4.0][8] - -### Directory structure - -The default site contains the following files and folders: - - * `_posts`: Your blog entries. - * `_site`: The final compiled static website. - * `about.markdown`: Content for the about page. - * `index.markdown`: Content for the home page. - * `404.html`: Content for the 404 page. - * `_config.yml`: Site-wide configuration for Jekyll. - - - -### Creating new blog entries - -Creating posts is simple. All you need to do is create a new file under `_posts` with the proper format and extension, and you’re all set. - -A valid file name is `2021-08-29-welcome-to-jekyll.markdown`. A post file must contain what Jekyll calls the YAML Front Matter. It’s a special section at the beginning of the file with the metadata. If you see the default post, you’ll see the following: - - -``` -\--- -layout: post -title: "Welcome to Jekyll!" -date:  2021-08-29 11:28:12 +0530 -categories: jekyll update -\--- -``` - -Jekyll uses the above metadata, and you can also define custom `key: value` pairs. If you need some inspiration, [have a look at my website's front matter][9]. Aside from the front matter, you can [use in-built Jekyll variables][10] to customize your website. - -Let’s create a new post. Create `2021-08-29-ayushsharma.markdown` in the `_posts` folder. Add the following content: - - -``` -\--- -layout: post -title:  "Check out ayushsharma.in!" -date:   2021-08-29 12:00:00 +0530 -categories: mycategory -\--- -This is my first post. - -# This is a heading. - -## This is another heading. - -This is a [link]() - -This is my category: -``` - -If the `jekyll serve` command is still running, refresh the page, and you'll see the new entry below. - -![New blog entry][11] - -Screenshot by Ayush Sharma, [CC BY-SA 4.0][8] - -Congrats on creating your first article! The process may seem simple, but there's a lot you can do with Jekyll. Using simple markdown, you can generate an archive of posts, syntax highlighting for code snippets, and separate pages for posts in one category. - -### Drafts - -If you're not ready to publish your content yet, you can create a new `_drafts` folder. Markdown files in this folder are only rendered by passing the `--drafts` argument. - -### Layouts and Includes - -Note the front matter of the two articles in our `_posts` folder, and you'll see `layout: post` in the Front Matter. The `_layout` folder contains all the layouts. You won't find them in your source code because Jekyll loads them by default. The default source code used by Jekyll is [here][12]. If you follow the link, you'll see that the `post` layout uses the [`default` layout][13]. The default layout contains the code `{{ content }}` which is where content is injected. The layout files will also contain `include` directives. These load files from the [`includes` folder][14] and allow composing a page using different components. - -Overall, this is how layouts work—you define them in the front matter and inject your content within them. Includes provide other sections of the page to compose a whole page. This is a standard web-design technique—defining header, footer, aside, and content elements and then injecting content within them. This is the real power of static site generators—full programmatic control over assembling your website with final compilation into static HTML. - -### Pages - -Not all content on your website will be an article or a blog post. You'll need about pages, contact pages, project pages, or portfolio pages. This is where Pages come in. They work exactly like Posts do, meaning they're markdown files with front matter. But they don't go in the `_posts` directory. They either stay in your project root or in folders of their own. For Layouts and Includes, you can use the same ones as you do for your Posts or create new ones. Jekyll is very flexible and you can be as creative as you want! Your default blog already has `index.markdown` and `about.markdown`. Feel free to customize them as you wish. - -### Data files - -Data files live in the `_data` directory, and can be `.yml`, `.json`, or `.csv`. For example, a `_data/members.yml` file may contain: - - -``` -\- name: A - github: a@a - -\- name: B - github: b@b - -\- name: C - github: c@c -``` - -Jekyll reads these during site generation. You can access them using `site.data.members`. - - -``` -<ul> -{ % for member in site.data.members %} - <li> - <a href="[https://github.com/"\>][15] -      { { member.name }} - </a> - </li> -{ % endfor %} -</ul> -``` - -### Permalinks - -Your `_config.yml` file defines the format of your permalinks. You can [use a variety of default variables][16] to assemble your own custom permalink. - -### Building your final website - -The command `jekyll serve `is great for local testing. But once you're done with local testing, you'll want to build the final artifact to publish. The command `jekyll build --source source_dir --destination destination_dir` builds your website into the `_site` folder. Note that this folder is cleaned up before every build, so don't place important things in there. Once you have the content, you can host it on a static hosting service of your choosing. - -You should now have a decent overall grasp of what Jekyll is capable of and what the main bits and pieces do. If you’re looking for inspiration, the official [JAMStack website has some amazing examples][17]. - -![Example Jekyll sites from JAMStack][18] - -Screenshot by Ayush Sharma, [CC BY-SA 4.0][8] - -Happy coding :) - -* * * - -_This article was originally published on the [author's personal blog][19] and has been adapted with permission._ - -See how Jekyll, an open source generator of static HTML files, makes running a blog as easy as... - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/9/build-website-jekyll - -作者:[Ayush Sharma][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/ayushsharma -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/laptop_screen_desk_work_chat_text.png?itok=UXqIDRDD (Person using a laptop) -[2]: https://gitlab.com/ayush-sharma/ayushsharma-in -[3]: https://sass-lang.com/ -[4]: https://shopify.github.io/liquid/ -[5]: https://jekyllrb.com/docs/installation/ -[6]: https://jekyllrb.com/docs/ -[7]: https://opensource.com/sites/default/files/uploads/2016-08-15-introduction-to-jekyll-welcome-to-jekyll.png (Default "awesome" blog) -[8]: https://creativecommons.org/licenses/by-sa/4.0/ -[9]: https://gitlab.com/ayush-sharma/ayushsharma-in/-/blob/2.0/_posts/2021-07-15-the-evolution-of-ayushsharma-in.md -[10]: https://jekyllrb.com/docs/variables/ -[11]: https://opensource.com/sites/default/files/uploads/2016-08-15-introduction-to-jekyll-new-article.png (New blog entry) -[12]: https://github.com/jekyll/minima/blob/master/_layouts/post.html -[13]: https://github.com/jekyll/minima/blob/master/_layouts/default.html#L12 -[14]: https://github.com/jekyll/minima/tree/master/_includes -[15]: https://github.com/"\> -[16]: https://jekyllrb.com/docs/permalinks/ -[17]: https://jamstack.org/examples/ -[18]: https://opensource.com/sites/default/files/uploads/2016-08-15-introduction-to-jekyll-jamstack-examples.png (Example Jekyll sites from JAMStack) -[19]: https://notes.ayushsharma.in/2021/08/introduction-to-jekyll diff --git a/sources/tech/20210923 JingPad Review- A Real Linux Tab for True Linux Fans.md b/sources/tech/20210923 JingPad Review- A Real Linux Tab for True Linux Fans.md deleted file mode 100644 index 34a368bebd..0000000000 --- a/sources/tech/20210923 JingPad Review- A Real Linux Tab for True Linux Fans.md +++ /dev/null @@ -1,233 +0,0 @@ -[#]: subject: "JingPad Review: A Real Linux Tab for True Linux Fans" -[#]: via: "https://itsfoss.com/jingpad-a1-review/" -[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" -[#]: collector: "lujun9972" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -JingPad Review: A Real Linux Tab for True Linux Fans -====== - -If you follow Linux news enthusiastically, you might have come across a new name recently: [JingOS][1]. - -It is a new Linux distribution designed for touch devices. It can also be used as a regular desktop operating system on non-touch devices. - -![JingOS][2] - -JingOS is not the primary product for Beijing based JingLing tech. They have created this OS for their flagship product, JingPad, an ARM-based Linux tablet. - -This review focuses on two aspects: - - * The hardware side of JingPad tablet - * The software side of JingOS - - - -So that you know - -People at Jing sent me the JingPad for free to review the device. I can keep the device forever. However, this does not mean that review is biased in their favor to show only the positives. I am sharing my experience with the device and its operating system. - -### JingPad: The first impression - -![JingPad A1][3] - -To be frank with you, I was expecting a mediocre, generic tablet preinstalled with a Linux OS. I was wrong. - -The moment I unboxed the device and hold it in my hands, I got a feeling that I am looking at a premium device. The black colored tablet has a smooth finish. The back has a glossy finish and though I prefer matte usually, I liked the shiny body. I learned later that they used Corning Gorilla Glass for the back. - -The hardware specification of the gadget is more than just decent. Take a look: - - * 11 inches AMOLED screen with 4:3 aspect ratio - * 2K screen with 266PPI and 350nit - * Unisoc Tiger T7510 ARM Chip - * 8000mAh battery - * Weighs around 550g so not too heavy - * Around 7 mm in thickness - * 16 MP back camera and 8 MP front camera - * Dual band WiFi and Bluetooth 5.0 - * 8 GB RAM - * 256 GB UMCP storage which can be expanded by MicroSD of 512 GB in size - - - -JingPad also has companion stylus and keyboard. The review unit did not have the stylus but I did get the detachable keyboard. More on the keyboard later. - -Note - -JingOS is in alpha stage of development. A lot of things do not work as expected or promised at this moment. It should eventually get better in the later stages of development. - -### JingOS: Experience the user interface - -The JingOS will immediately remind you of iOS or Deepin OS, whichever you prefer. The interface is clean and the 2K display makes things look pretty. - -There are row of application icons and a dock at the bottom. Swiping up from the bottom brings an activity area displaying all the running applications. From here, you can drag an application upward to close it. Touching the trash will close all the running applications. To minimize an application, you have to swipe from right to left. - -![JingOS interface][4] - -Swiping down from the top left brings the notification center. Doing the same on the top right corner lets you access the Settings menu. - -The theming option is limited to light and dark themes but hey, you are getting the dark theme at least. Changing the theme requires a restart, which is an annoyance. - -![JingOS provides a dark mode][5] - -From what I see and experience, JingOS uses Ubuntu as base. For the interface, it is using KDE Plasma and probably some parts of GNOME underneath. The footprints of KDE Plasma are visible at places. For example, look at this screenshot notification. - -![JingOS is built on top of KDE Plasma][6] - -Since it is based on Ubuntu, you can use the apt-get commands in the terminal. The terminal (KDE’s Konsole) can be used with both keyboard and on-screen keyboard. You also have the option to split the terminal window. - -![Terminal][7] - -Something that bothered me with JingOS is that it only works in the landscape mode. I could not find a way to use it in the portrait mode. This creates an issue if you are trying to log into a website in the browser because the on-screen keyboard takes half of the screen and you cannot see the form fields properly. - -![Works only in landscape mode][8] - -There is also no tap to wake feature. Face unlock is also missing. There is a fingerprint reader on the power button but it does not work for now. JingOS will add this feature in the [next couple of months through software update][9]. - -Overall, JingOS is pretty to look at, pretty to use for most part of it. - -### Keyboard - -The review device I got came with the companion keyboard. The keyboard is made for JingPad. It is magnetic and the tab sticks to it. It is detected automatically, no wonder there. It doubles up as cover to give the device front and back protection. - -![JingPad with keyboard][10] - -You can tilt the device at certain angles to use it comfortably as a laptop. - -![JingPad with keyboard placed at angle][11] - -**At the time of writing this review, the keyboard support is in initial stages for JingOS. This is why it does not work as it should.** - -There are several function keys on the keyboard for controlling the volume, brightness, media playback, screen lock etc. - -Most function keys work, except the one for showing the desktop. The super key, which has JingPad logo, does not work as well. I was expecting it to bring the home screen from running applications but that did not work. - -The worst part is that when the keyboard is attached, it does not show the mouse pointer on the screen. That means going into a hybrid use mode where you touch the applications icon to open them and then use the keyboard for typing. This must be improved in the future. - -Coming to the typing, the keys are a bit tiny but not miniscule. I think that’s expected from the keyboard that has to match the 11 inches screen. The keys - -The added weight of the keyboard makes the device heavier than usual but I guess you’ll have to make a compromise with the ease of use and the increased weight. - -Another thing I noticed that when you put the lid down in the keyboard mode, the screen is not locked automatically. I expected a similar behavior to closing the lid of laptop. - -### Battery life, charging and performance - -JingPad comes with a 8000 mAh and claims to have up to 10 hours of battery life. They also claim that their 18W fast charger will charge the device completely in 3 hours. - -My review device did not come with the fast charger because it was still under manufacturing when they shipped the device. I got a travel adapter instead and it took slightly more than 5 hours to charge the device. - -I tested and found that if you keep the device on standby, the battery lasts around 42 hours. If you start using it continuously, it goes for 6 hours max. Now, this depends on what kind of work you are doing on the system. A few tweaks like reducing screen brightness, refresh rate, disabling connectivity could give it some extra battery life. - -### Camera and sound - -![][12] - -There are two cameras here. 16 MP back camera for taking pictures (well, why not) and 8 MP front camera for video calls and online meetings. - -Camera performance is okay. The default camera does not come with AI features like the smartphones but that’s fine. You are not going to use it primarily as a camera, after all. - -The front camera is good enough for the video calls. The placement of front camera is on the top so when you are using it in the landscape mode, it may seem that you are not looking directly into the camera. But people could still see and hear you well so that should not be an issue. - -Speaking of hearing, JingPad has 4 speakers, two on each side. They provide decent sound for causal YouTube and watching streaming content for a single person. No complaints in this department. - -### Applications - -JingPad comes pre-installed with some of its own applications. These applications include a file manager, camera app, voice recorder, camera app, gallery app, music and video applications. Many of these applications are open source and you can find the code on [their GitHub repository][13]. - -![The music app from JingOS][14] - -JingOS has an app store of its own where it provides a handful of applications that work on the touch devices. - -![JingOS App Store][15] - -The app store does not offer many applications at the moment but _**you can use the apt package manager**_ to get additional software (from JingOS’s repositories). - -My biggest complaint is not about the lack of applications. It’s about the versions of some of the offered applications. I downloaded Mozilla Firefox from the app store and it installed version 82. The current Firefox version is 92 at the time of writing the review. I tried updating the system, even in command line, to see if it gets updates but there were none. - -Because of this outdated version, I could not [play Netflix on Firefox][16]. There is no dedicated Netflix app so this was the only way to test it. - -![Issue with outdated Firefox][17] - -There are plans to add Android apps support as well. I cannot say how well it will work but something is better than nothing. - -### Using JingPad for coding - -I am not a programmer, not anymore at least. But since JingPad’s targeted customer include young coders who are frequently on the move, I tried using it for some simple coding. - -There is no IDE available from the App Store but VS Code was available to install from the APT repository as well as in DEB file format. I installed it and opened it but it never ran like it was supposed to be. - -So, I installed Gedit and wrote some sample bash scripts. Not much of coding but with the attached keyboard, it was not too bad. - -It would have been a lot better if the copy-paste worked but unfortunately, I was not able to select and copy the code from random websites like a true programmer of the 21st century. I hope this gets fixed in the future updates. - -### Android compatibility and other operating systems - -I know what you are thinking. The tab looks good hardware wise. It is designed to run a Linux distribution based on Ubuntu. So can I use Ubuntu or some other distributions? - -JingOS team says that you are free to install any other operating system on it. It uses ARM architecture so that is something to keep in mind while replacing the OS. - -You will also be able to install JingOS back. I am yet to experiment with this part. I’ll update the review when I do that. - -As per the [roadmap of JingOS][18], there are plans for adding Android compatibility. This means you should be able to install Android or Android based ROM/distributions. As per the JingOS team, they will be developing the solution in house instead of using tools like Anbox. That will be interesting to see. - -Here’s a demo video of an Android app running on JingPad under JingOS: - -### Conclusion - -JingOS is in alpha stage of development at the moment. Most of the issues I have encountered in this review should be addressed in the future OTA updates, as their roadmap suggests. The final stable version of JingPad should be available by March 2022. - -JingPad as a device comes on the pricey side but it also gives you a high-end gadget. 2K AMOLED display with Gorilla Glass, 8 GB RAM, 256 GB UMCP storage and other stuff you get only in high-end devices. The sound from the speakers is decent. - -The magnetic tab cover and the detachable keyboards are also of premium quality. These things matter because you are paying a good amount of money for it. - -The [JingPad with the Pencil][19] (stylus) and the keyboard costs $899. It comes with free international shipping and 1-year warranty. In many countries, there will also be additional custom duty levied on top of this price. - -That seems like a lot of money, right? If you compare it to the price of iPad Air with same specifications (256 GB storage, WiFi+Cellular), keyboard and Pencil, the Apple device price reaches $1300 in the USA. - -It is natural to compare JingPad with PineTab, another ARM-based Linux tablet. But PineTab is not a high-end gadget. It has modest specification and geared towards DIY tinkerers. JingPad, on the other hand, targets regular users, not just the DIY geeks. - -Altogether, JingPad is aiming to give you a true Linux tablet but in the premium range. You get what you are paying for. A premium device for a premium pricing, with the freedom to run Linux on it. - -_**But at this stage, JingOS has a lot of pending work to make JingPad a consumer level Linux tablet.**_ You should wait for the final device unless you really want your hands on it right away. - -I plan to make a video review of the device where you can see it in action. I am not very good at doing video reviews, so this will take some time. You may leave your comments on what you would like to see in the video review and I’ll try to cover it. - -_Meanwhile, you can follow the updates on JingPad and JingOS development on their [Telegram channel][20] or [Discord][21]. You may also watch the demos on [their YouTube channel][22]._ - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/jingpad-a1-review/ - -作者:[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.jingos.com/ -[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/jing-os-interaface.webp?resize=768%2C512&ssl=1 -[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/jingpad.jpeg?resize=800%2C529&ssl=1 -[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/jingos-interface.webp?resize=800%2C584&ssl=1 -[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/jingos-theme-change.webp?resize=800%2C584&ssl=1 -[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/jingos-plasma-notification.webp?resize=800%2C584&ssl=1 -[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/jingpad-terminal.webp?resize=800%2C584&ssl=1 -[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/jingpad-landscape.webp?resize=800%2C584&ssl=1 -[9]: https://forum-cdn.jingos.com/uploads/default/original/1X/4c6ef800ef62f0315852fde4f2c32958b32d93a9.png -[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/jingpad-with-keyboard.webp?resize=800%2C600&ssl=1 -[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/jingpad-keyboard-angle.webp?resize=800%2C600&ssl=1 -[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/jingpad-camera.png?resize=787%2C552&ssl=1 -[13]: https://github.com/JingOS-team/JingOS -[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/jingos-music-app.webp?resize=800%2C584&ssl=1 -[15]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/jingos-app-store.webp?resize=800%2C584&ssl=1 -[16]: https://itsfoss.com/netflix-firefox-linux/ -[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/JingPad-Netflix-Issue.webp?resize=800%2C584&ssl=1 -[18]: https://forum.jingos.com/t/feature-roadmap-of-jingos-arm-on-the-jingpad-a1/1708 -[19]: https://www.indiegogo.com/projects/jingpad-world-s-first-consumer-level-linux-tablet#/ -[20]: https://t.me/JingOS_Linux -[21]: https://discord.gg/uuWc8qKM -[22]: https://www.youtube.com/channel/UCRbaVa2v845SEtRadSlhWmA diff --git a/sources/tech/20210924 An open source alternative to Microsoft Exchange.md b/sources/tech/20210924 An open source alternative to Microsoft Exchange.md deleted file mode 100644 index 4d698eca5c..0000000000 --- a/sources/tech/20210924 An open source alternative to Microsoft Exchange.md +++ /dev/null @@ -1,80 +0,0 @@ -[#]: subject: "An open source alternative to Microsoft Exchange" -[#]: via: "https://opensource.com/article/21/9/open-source-groupware-grommunio" -[#]: author: "Markus Feilner https://opensource.com/users/mfeilner" -[#]: collector: "lujun9972" -[#]: translator: "geekpi" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -An open source alternative to Microsoft Exchange -====== -Open source users now have a robust and fully functional choice for -groupware. -![Working on a team, busy worklife][1] - -Microsoft Exchange has for many years been nearly unavoidable as a platform for groupware environments. Late in 2020, however, an Austrian open source software developer introduced [grommunio][2], a groupware server and client with a look and feel familiar to Exchange and Outlook users. - -The grommunio project functions well as a drop-in replacement for Exchange. The developers connect components to the platform the same way Microsoft does, and they support RPC (Remote Procedure Call) with the HTTP protocol. According to the developers, grommunio also includes numerous interfaces of common groupware such as IMAP, POP3, SMTP, EAS (Exchange ActiveSync), EWS (Exchange Web Services), CalDAV, and CardDAV. With such broad support, grommunio integrates smoothly into existing infrastructures. - -Users will notice little difference among Outlook, Android, and iOS clients. Of course, as open source software, it supports other clients, too. Outlook and smartphones communicate with grommunio just as they do with a Microsoft Exchange server, thanks to their integrated, native Exchange protocols. An everyday enterprise user can continue to use their existing clients with the grommunio server quietly running in the background. - -### More than just mail - -In addition to mail functions, a calendaring system is available in the grommunio interface. Appointments can be created by clicking directly in the calendar display or in a new tab. It's intuitive and just what you'd expect from a modern tool. Users can create, manage, and share calendars as well as address books. Private contacts or common contacts are possible, and you can share everything with colleagues. - -Task management shows a list of tasks on the left in a drop-down menu, and they can have both one owner and multiple collaborators. You can assign deadlines, categories, attachments, and other attributes to each task. In the same way, notes can be managed and shared with other team members. - -### Chat, video conferences, and file sync - -In addition to all the standard features of modern groupware, grommunio also offers chat, video conferencing, and file synchronization. It does this with full integration on a large scale for the enterprise, with extraordinarily high performance. It's an easy choice for promoters of open source and a powerful option for sysadmins. Because grommunio aims to integrate rather than reinvent, all components are standard open source tools. - -![Screenshot of grommunio meeting space][3] - -Jitsi integration for advanced video conferences (Markus Feilner, [CC BY-SA 4.0][4]) - -Behind the meeting function in grommunio is [Jitsi][5], smoothly integrated into the grommunio UI with a familiar user interface. The chat feature, fully integrated and centrally managed, is based on [Mattermost][6]. - -![Screenshot of grommunio's town square for chat][7] - -Mattermost for chat (Markus Feilner, [CC BY-SA 4.0][4]) - -[ownCloud][8], which promises enterprise-level file sharing and synchronization, starts after a click on the Files button. - -![Screenshot of grommunio file sharing space][9] - -ownCloud for file synchronization and exchange (Markus Feilner, [CC BY-SA 4.0][4]) - -The grommunio project has a powerful administrative interface, including roles, domain and organization management, predictive monitoring, and a self-service portal. Shell-based wizards guide admins through installation and migration of data from Microsoft Exchange. The development team is constantly working for better integration and more centralization for management, and with that comes a better workflow for admins. - -![Screenshot of grommunio dashboards][10] - -grommunio's admin interface (Markus Feilner, [CC BY-SA 4.0][4]) - -### Explore grommunio - -The grommunio project has lofty goals, but its developers have put in the work, and it shows. A German hosting service specializing in tax consultants—a sector where German data protection laws are especially tough—recently announced that grommunio is available to their customers. The grommunio project gets a lot right: a clean combination of existing, successful concepts working together to enable open, secure, and privacy-compliant communication. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/9/open-source-groupware-grommunio - -作者:[Markus Feilner][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/mfeilner -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/team_dev_email_chat_video_work_wfm_desk_520.png?itok=6YtME4Hj (Working on a team, busy worklife) -[2]: https://grommunio.com/en/ -[3]: https://opensource.com/sites/default/files/uploads/jitsi_0.png (grommunio meeting space) -[4]: https://creativecommons.org/licenses/by-sa/4.0/ -[5]: https://opensource.com/article/20/5/open-source-video-conferencing -[6]: https://opensource.com/education/16/3/mattermost-open-source-chat -[7]: https://opensource.com/sites/default/files/uploads/mattermost.png (grommunio's town square for chat) -[8]: https://owncloud.com/ -[9]: https://opensource.com/sites/default/files/uploads/owncloud_0.png (Owncloud for file synchronization and exchange) -[10]: https://opensource.com/sites/default/files/uploads/grommunio_interface_0.png (Screenshot of grommunio dashboards) diff --git a/sources/tech/20210927 Bash Shell Scripting for beginners (Part 1).md b/sources/tech/20210927 Bash Shell Scripting for beginners (Part 1).md new file mode 100644 index 0000000000..2e6a196059 --- /dev/null +++ b/sources/tech/20210927 Bash Shell Scripting for beginners (Part 1).md @@ -0,0 +1,223 @@ +[#]: subject: "Bash Shell Scripting for beginners (Part 1)" +[#]: via: "https://fedoramagazine.org/bash-shell-scripting-for-beginners-part-1/" +[#]: author: "zexcon https://fedoramagazine.org/author/zexcon/" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Bash Shell Scripting for beginners (Part 1) +====== + +![][1] + +Photo by [N Bandaru][2] on [Unsplash][3] + +As the title implies this article will be covering Bash Shell Scripting at a beginner level. I’m not going to review the history of Bash but there are many resources to fill you in or you can visit the GNU project at . We will start out with understanding some very basic concepts and then start to put things together. + +### Creating a script file + +The first thing to do is create a script file. First make sure the home directory is the current directory. + +``` +cd ~ +``` + +In the home directory, create the example file. This can be named anything but _learnToScript.sh_ will be used in this article. + +``` +touch learnToScript.sh +``` + +From this point there will be a file called _learnToScript.sh_ in your home directory. Verify it exists and also notice the privileges for that file are -rw-rw-r– by typing the following. + +``` +ls -l +``` + +``` +[zexcon@trinity ~]$ ls -l +total 7 +drwxr-xr-x. 1 zexcon zexcon 90 Aug 30 13:08 Desktop +drwxr-xr-x. 1 zexcon zexcon 80 Sep 16 08:53 Documents +drwxr-xr-x. 1 zexcon zexcon 1222 Sep 16 08:53 Downloads +-rw-rw-r--. 1 zexcon zexcon 70 Sep 17 10:10 learnToScript.sh +drwxr-xr-x. 1 zexcon zexcon 0 Jul 7 16:04 Music +drwxr-xr-x. 1 zexcon zexcon 318 Sep 15 13:53 Pictures +drwxr-xr-x. 1 zexcon zexcon 0 Jul 7 16:04 Public +drwxr-xr-x. 1 zexcon zexcon 0 Jul 7 16:04 Videos +[zexcon@trinity ~]$ +``` + +There is one more thing that needs to be done to get started. Let’s try and execute the script with nothing written in it. Type the following: + +``` +./learnToScript.sh +``` + +``` +[zexcon ~]$ ./learnToScript.sh +bash: ./learnToScript.sh: Permission denied +``` + +You get permission denied because there are no execute permissions on the file. You need to change the permissions of the file to be able to execute the script. If you are not familiar with permissions I would recommend reading the Fedora Magazine articles written by [Paul W. Frields][4] + +> [Command line quick tips: Permissions][5] + +> [Command line quick tips: More about permissions][6] + +At this point you’ve brushed up on permissions, so back to the terminal and let’s change the _learnToScript.sh_ file so it will execute. Type in the following to allow execution of the file. + +``` +chmod 755 learnToScript.sh +``` + +``` +[zexcon@trinity ~]$ ls -l +total 7 +drwxr-xr-x. 1 zexcon zexcon 90 Aug 30 13:08 Desktop +drwxr-xr-x. 1 zexcon zexcon 80 Sep 16 08:53 Documents +drwxr-xr-x. 1 zexcon zexcon 1222 Sep 16 08:53 Downloads +-rwxr-xr-x. 1 zexcon zexcon 70 Sep 17 10:10 learnToScript.sh +drwxr-xr-x. 1 zexcon zexcon 0 Jul 7 16:04 Music +drwxr-xr-x. 1 zexcon zexcon 318 Sep 15 13:53 Pictures +drwxr-xr-x. 1 zexcon zexcon 0 Jul 7 16:04 Public +drwxr-xr-x. 1 zexcon zexcon 0 Jul 7 16:04 Videos +[zexcon@trinity ~]$ +``` + +Okay now you’re ready, you have read, write and execute permissions (-rwxr-x r-x) to the _learnToScript.sh_ command. + +### Editing a script file + +Take a moment and make certain you are familiar with _vim_ or any text editor. Throughout this article I will be utilizing _vim_. At the command prompt type the following: + +``` +vim learnToScript.sh +``` + +This will bring you to an empty text file with a bunch of tildes in it. Type _i_ on your keyboard and this will move you into — INSERT — mode. You can see it’s in this mode by looking at the bottom left of the terminal window. (Note that an alternative editor is the [_nano_ editor][7].) + +From here you need to make sure that the file is recognized by the correct interpreter. So enter the shebang ( #! ) and the directory to your bash, /bin/bash: + +``` +#!/bin/bash +``` + +One last thing that you will use throughout the article is saving the document. Hit _Esc_ to leave input mode, then Shift + Colon. At the colon you will enter _wq_. This will write(_w_) the file and quit(_q_) _vim_ once you hit enter. + +A few things to remember while using _vi_m, anytime you want to write into a document you need to enter _i_ and you will see –INSERT– at the bottom. Anytime you want to save, you will need to hit _Esc_ to leave input mode, and then _Shift+:_ to enter _w_ to write the file or _Esc_ then _Shift+:_ to enter _q_ to quit and not save. Or add both _wq_ together and it will write and close. _Esc_ by itself will exit INSERT mode. You can find much more about _vim_ at it’s [website][8] or this [get started][9] site. + +## Lets start scripting… + +### echo + +The _echo_ command is used to return something to the terminal. You will notice that you can use single quotes, double quotes or no quotes. So let’s take a look at it with a traditional Hello World! + +``` +#!/bin/bash + +echo Hello World! +echo 'Hello World!' +echo "Hello World!" +``` + +``` +[zexcon ~]$ ./learnToScript.sh +Hello World! +Hello World! +Hello World! +[zexcon ~]$ +``` + +Notice that you get the same result with all three options. This is not always the case but in this basic script it is. In some circumstances the type of quotes will make a difference. By the way, congratulations you have written your first Bash script. Let’s look at a few things that you will want to know as you continue to create more scripts and let your mind run wild. + +### Command Substitution $( ) or ` ` + +Command substitution allows you to get the results of a command you might execute at the command line and write that result to a variable. For example if you type _ls_ at the command prompt you will get a list of the current working directory. So let’s put this into practice. You have two options for command substitution. Note that the first option uses a back tick found above the Tab key on the left side of the keyboard. It is paired with the tilde ~ key. The second option uses a shell variable. + +``` +#!/bin/bash + +command1=`ls` +echo $command1 + +command2=$(ls) +echo $command2 +``` + +``` +[zexcon ~]$ ./learnToScript.sh +Desktop Documents Downloads learnToScript.sh Music Pictures Public snap Videos +Desktop Documents Downloads learnToScript.sh Music Pictures Public snap Videos +[zexcon ~]$ +``` + +Notice no space between the variable, equal sign, and the start of the command. You get the exact same result with both options. Note that variables need to be led by a dollar sign. If you forget and you echo out the command variable without the dollar sign you will just see the name of the command as shown in the next example. + +``` +#!/bin/bash + +command1=`ls` +echo command1 + +command2=$(ls) +echo command2 +``` + +``` +[zexcon ~]$ ./learnToScript.sh +command1 +command2 +[zexcon ~]$ +``` + +### Double Parenthesis (()) + +So what are double parenthesis for? Double parenthesis are simple, they are for mathematical equations. + +``` +#!/bin/bash + +echo $((5+3)) +echo $((5-3)) +echo $((5*3)) +echo $((5/3)) +``` + +``` +[zexcon ~]$ ./learnToScript.sh +8 +2 +15 +1 +[zexcon ~]$ +``` + +## Conclusion + +At this point we have created our first script. We have an idea how to take several commands, place them in a script and run it to get the results. We will continue this discussion in the next article and look at redirection of input and output, the pipe command, using double brackets or maybe just adding some comments. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/bash-shell-scripting-for-beginners-part-1/ + +作者:[zexcon][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/zexcon/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2021/09/bash_shell_scripting_pt1-816x345.jpg +[2]: https://unsplash.com/@nbandana?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]: https://unsplash.com/s/photos/shell-scripting?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: http://pfrields.id.fedoraproject.org/ +[5]: https://fedoramagazine.org/command-line-quick-tips-permissions/ +[6]: https://fedoramagazine.org/command-line-quick-tips-more-about-permissions/ +[7]: https://fedoramagazine.org/gnu-nano-minimalist-console-editor/ +[8]: https://www.vim.org/docs.php +[9]: https://linuxhandbook.com/basic-vim-commands/ diff --git a/sources/tech/20210928 Convert your Raspberry Pi into a trading bot with Pythonic.md b/sources/tech/20210928 Convert your Raspberry Pi into a trading bot with Pythonic.md new file mode 100644 index 0000000000..c8d236dce4 --- /dev/null +++ b/sources/tech/20210928 Convert your Raspberry Pi into a trading bot with Pythonic.md @@ -0,0 +1,509 @@ +[#]: subject: "Convert your Raspberry Pi into a trading bot with Pythonic" +[#]: via: "https://opensource.com/article/21/9/raspberry-pi-trading-bot" +[#]: author: "Stephan Avenwedde https://opensource.com/users/hansic99" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Convert your Raspberry Pi into a trading bot with Pythonic +====== +Reduce your power consumption by setting up your cryptocurrency trading +bot on a Raspberry Pi. +![A dollar sign in a network][1] + +The current popularity of cryptocurrencies also includes trading in them. Last year, I wrote an article *[How to automate your cryptocurrency trades with Python][2] *which covered the setup of a trading bot based on the graphical programming framework [Pythonic][3], which I developed in my leisure. At that time, you still needed a desktop system based on x86 to run Pythonic. In the meantime, I have reconsidered the concept (web-based GUI). Today, it is possible to run Pythonic on a Raspberry Pi, which mainly benefits the power consumption because such a trading bot has to be constantly switched on. + +That previous article is still valid. If you want to create a trading bot based on the old version of Pythonic (0._x_), you can install it with `pip3 install Pythonic==0.19`. + +This article covers the setup of a trading bot running on a Raspberry Pi and executing a trading algorithm based on the [EMA crossover strategy][4]. + +### Install Pythonic on your Raspberry Pi + +Here, I only briefly touch on the subject of installation because you can find detailed installation instructions for Pythonic in my last article [_Control your Raspberry Pi remotely with your smartphone_][5]. In a nutshell: Download the Raspberry Pi image from [sourceforge.net][6] and flash it on the SD card. + +The PythonicRPI image has no preinstalled graphical desktop, so to proceed, you should be able to access the programming web GUI (http : //PythonicRPI:7000/): + +![Pythonic GUI overview][7] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +#### Example code + +Download the example code for the trading bot from [GitHub][9] (direct download link) and unzip the archive. The archive contains three different file types: + + * `\*.py-files`: Contains the actual implementation of certain functionality + * `current_config.json`: This file describes the configured elements, the links between the elements, and the variable configuration of elements + * `jupyter/backtest.ipynb`: A [Jupyter][10] notebook for backtesting + * `jupyter/ADAUSD_5m.df`: A minimal OHLCV dataset which I use in this example + + + +With the green outlined button, upload the `current_config.json` to the Raspberry Pi. You can upload only valid configuration files. With the yellow outlined button, upload all the `\*.py `files.  + +![Upload toolbar buttons][11] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +The `\*.py `files are uploaded to `/home/pythonic/Pythonic/executables` whereas the `current_config.json` is uploaded to `/home/pythonic/Pythonic/current_config.json`. After uploading the `current_config.json`, you should see a screen like this: + +![Pythonic screen after upload of config.json][12] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +Now I'll go step-by-step through each part of the trading bot. + +### Data acquisition + +Like in the last article, I begin with the data acquisition: + +![Pythonic area 2 data acquisition ][13] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +The data acquisition can be found on the **Area 2** tab and runs independently from the rest of the bot. It implements the following functionality: + + * **AcqusitionScheduler**: Trigger subsequent elements every five minutes + * **OHLCV_Query**: Prepares the OHLCV query method + * **KrakenConnector**: Establishes a connection with the Kraken cryptocurrency exchange + * **DataCollector**: Collect and process the new OHLCV data + + + +The _DataCollector_ gets a Python list of OHLCV data with a prefixed timestamp and converts it into a [Pandas DataFrame][14]. Pandas is a popular library for data analysis and manipulation. A _DataFrame_ is the base type for data of any kind to which arithmetic operation can be applied. + +The task of the DataCollector (`generic_pipe_3e059017.py`) is to load an existing DataFrame from file, append the latest OHLCV data, and save it back to file.  + + +``` +import time, queue +import pandas as pd +from pathlib import Path + +try: +    from element_types import Record, Function, ProcCMD, GuiCMD +except ImportError: +    from Pythonic.element_types import Record, Function, ProcCMD, GuiCMD + +class Element(Function): + +    def __init__(self, id, config, inputData, return_queue, cmd_queue): +        super().__init__(id, config, inputData, return_queue, cmd_queue) +         +    def execute(self): +        df_in = pd.DataFrame(self.inputData, columns=['close_time', 'open', 'high', 'low', 'close', 'volume']) +        df_in['close_time'] = df_in['close_time'].floordiv(1000) # remove milliseconds from timestamp + +        file_path = Path.home() / 'Pythonic' / 'executables' / 'ADAUSD_5m.df' + +        try: +            # load existing dataframe +            df = pd.read_pickle(file_path) +            # count existing rows +            n_row_cnt = df.shape[0] +            # concat latest OHLCV data +            df = pd.concat([df,df_in], ignore_index=True).drop_duplicates(['close_time']) +            # reset the index +            df.reset_index(drop=True, inplace=True) +            # calculate number of new rows +            n_new_rows = df.shape[0] - n_row_cnt +            log_txt = '{}: {} new rows written'.format(file_path, n_new_rows) + +        except Exception as e: +            log_txt = 'File error - writing new one' +            df = df_in  +             +        # save dataframe to file +        df.to_pickle(file_path) + +        logInfo = Record(None, log_txt) +        self.return_queue.put(logInfo) +``` + +This code is executed every full five minutes as the OHLCV data is also in 5-minute intervals. + +By default, the _OHLCV_Query_ element only downloads the dataset for the latest period. To have some data for developing the trading algorithm, right-click the **OHLCV_Query** element to open the configuration, set the _Limit_ to 500, and trigger the **AcquisitionScheduler**. This causes the download of 500 OHLCV values: + +![OHLCV_Query configuration][15] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +### Trading strategy + +Our trading strategy will be the popular [EMA crossover strategy][4]. The EMA indicator is a weighted moving average over the last _n_ close prices that gives more weight to recent price data. You calculate two EMA series, one for a longer period (for example, _n_ = 21, blue line) and one for a shorter period (for example, _n_ = 10, yellow line).  + +![Pythonic trading data graph][16] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +The bot should place a buy order (green circle) when the shorter-term EMA crosses above the longer-term EMA. The bot should place a sell order when the shorter-term EMA crosses below the longer-term EMA (orange circle). + +### Backtesting with Jupyter + +The example code on [GitHub][9] (direct download link) also contains a [Jupyter Notebook][10] file (`backtesting.ipynb`)  which you use to test and develop the trading algorithm. + +**Note:** Jupyter is not preinstalled on the Pythonic Raspberry Pi image. You can either install it also on the Raspberry Pi or install it on your regular PC. I  recommend the latter, as you will do some number crunching that is much faster on an ordinary x86 CPU. + +Start Jupyter and open the notebook. Make sure to have a DataFrame, downloaded by the _DataCollector_, available. With **Shift**+**Enter**, you can execute each cell individually. After executing the first three cells, you should get an output like this: + +![Output after executing the first three cells][17] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +Now calculate the EMA-10 and EMA-21 values. Luckily, pandas offers you the `ewm` function, which does exactly what is needed. The EMA values are added as separate columns to the DataFrame: + +![EMA values added as separate columns to dataframe][18] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +To determine if a buy or sell condition is met, you have to consider these four variables: + + * **emaLong0**: Current long-term (_ema-21_) EMA value + * **emaLong1**: Last long-term (_ema-21_) EMA value (the value before emaLong0) + * **emaShort0**: Current short-term (_ema-10_) EMA value + * **emaShort1**: Last short-term (_ema-10_) EMA value (the value before emaShort0) + + + +When the following situation comes into effect, a buy condition is met: + +![Buy condition met][19] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +In Python code: + + +``` +`emaLong1 > emaShort1 and emaShort0 > emaLong0` +``` + +A sell condition is met in the following situation: + +![Sell condition met][20] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +In Python code: + + +``` +`emaShort1 > emaLong1 and emaLong0 > emaShort0` +``` + +To test the DataFrame and evaluate the possible profit you could make, you could either iterate over each row and test for these conditions or, with a smarter approach, filter the dataset to only the relevant rows with built-in methods from Pandas. + +Under the hood, Pandas uses [NumPy][21], which is the method of choice for fast and efficient data operation on arrays. This is, of course, convenient because the later use is to take place on a Raspberry Pi with an ARM CPU. + +For the sake of clarity, the DataFrame from the example (`ADAUSD_5m.df`) with only 20 entries is used in the following examples. The following code appends a column of boolean values dependent on the condition `emaShort0 > emaLong0`: + +![Dataframe with 20 entries][22] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +The place of interest is when a _False_ switches to _True_ (buy) or when _True_ switches to _False_. To filter them apply a `diff` operation to the _condition_ column. The `diff `operation calculates the difference between the current and the previous line. In terms of boolean values, it results in: + + * _False_ `diff` _False_ = _False_ + * _False_ `diff` _True_ = _True_ + * _True_ `diff` _True_ = _False_ + * _True_ `diff` _False_ = _True_ + + + +With the following code, you apply the `diff` operation as a filter to the *condition *column without modifying it: + +![Applying the diff operation][23] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +As a result, you get the desired data: The first row (index 2) signalizes a buy condition and the second row (index 8) signalizes a sell condition. As you now have an efficient way of extracting relevant data, you can calculate possible profit. + +To do so, you have to iterate through the rows and calculate the possible profit based on simulated trades. The variable `bBought` saves the state if you already bought, and `buyPrice` stores the price you bought between the iterations. You also skip the first sell indicator as it doesn't make sense to sell before you've even bought. + + +``` +profit   = 0.0 +buyPrice = 0.0 +bBought  = False + +for index, row, in trades.iterrows(): +     +    # skip first sell-indicator +    if not row['condition'] and not bBought: +        continue +     +    # buy-indication +    if row['condition'] and not bBought: +        bBought = True +        buyPrice = row['close'] +         +         +    # sell-indication +    if not row['condition'] and bBought: +        bBought = False +        sellPrice = row['close'] + +        orderProfit = (sellPrice * 100) / buyPrice - 100 +         +        profit += orderProfit +``` + +Your one-trade mini dataset would provide you the following profit: + +![One-trade mini dataset profit][24] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +**Note:** As you can see, the strategy would have given a terrible result as you would have bought at $2.5204 and sold at  $2.5065, causing a loss of 0.55% (order fees not included). However, this is a real-world scenario: One strategy does not work for each scenario. It is on you to find the most promising parameters (for example, using OHLCV on an hourly basis would make more sense in general). + +### Implementation + +You can find the implementation of the decision on the **Area 1** tab.  + +![Decision-making implementation on area 1][25] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +It implements the following functionality: + + * **BotScheduler**: Same as the AcqusitionScheduler: Trigger subsequent elements every five minutes + * **Delay**: Delay the execution for 30 seconds to make sure that the latest OHLCV data was written to file + * **Evaluation**: Make the trading decision based on the EMA crossover strategy + + + +You now know how the decision makings work, so you can take a look at the actual implementation. Open the file `generic_pipe_29dfc189.py`. It corresponds to the **Evaluation** element on the screen: + + +``` +@dataclass +class OrderRecord: +    orderType:          bool  # True = Buy, False = Sell +    price:              float # close price +    profit:             float # profit in percent +    profitCumulative:   float # cumulative profit in percent + +class OrderType(Enum):  +    Buy  = True +    Sell = False + +class Element(Function): + +    def __init__(self, id, config, inputData, return_queue, cmd_queue): +        super().__init__(id, config, inputData, return_queue, cmd_queue) + +    def execute(self): + +        ### Load data ### + +        file_path = Path.home() / 'Pythonic' / 'executables' / 'ADAUSD_5m.df' + +        # only the last 21 columsn are considered +        self.ohlcv = pd.read_pickle(file_path)[-21:] + +        self.bBought             = False +        self.lastPrice           = 0.0 +        self.profit              = 0.0 +        self.profitCumulative    = 0.0    +        self.price               = self.ohlcv['close'].iloc[-1] +         +        # switches for simulation + +        self.bForceBuy  = False +        self.bForceSell = False + +        # load trade history from file +        self.trackRecord = ListPersist('track_record') + +        try: +            lastOrder = self.trackRecord[-1] + +            self.bBought          = lastOrder.orderType +            self.lastPrice        = lastOrder.price +            self.profitCumulative = lastOrder.profitCumulative + +        except IndexError: +            pass +         +        ### Calculate indicators ### + +        self.ohlcv['ema-10'] = self.ohlcv['close'].ewm(span = 10, adjust=False).mean() +        self.ohlcv['ema-21'] = self.ohlcv['close'].ewm(span = 21, adjust=False).mean() +        self.ohlcv['condition'] = self.ohlcv['ema-10'] > self.ohlcv['ema-21'] +         +        ### Check for Buy- / Sell-condition ### +        tradeCondition = self.ohlcv['condition'].iloc[-1] != self.ohlcv['condition'].iloc[-2] + +        if tradeCondition or self.bForceBuy or self.bForceSell: + +            orderType = self.ohlcv['condition'].iloc[-1] # True = BUY, False = SELL + +            if orderType and not self.bBought or self.bForceBuy: # place a buy order +                 +                msg         = 'Placing a  Buy-order' +                newOrder    = self.createOrder(True) + +            elif not orderType and self.bBought or self.bForceSell: # place a sell order + +                msg = 'Placing a  Sell-order' + +                sellPrice   = self.price +                buyPrice    = self.lastPrice + +                self.profit = (sellPrice * 100) / buyPrice - 100 +                self.profitCumulative += self.profit + +                newOrder = self.createOrder(False) + +            else: # Something went wrong +                msg = 'Warning: Condition for {}-order met but bBought is {}'.format(OrderType(orderType).name, self.bBought) +                newOrder = None +             + +            recordDone = Record(newOrder, msg)      +            self.return_queue.put(recordDone) + +    def createOrder(self, orderType: bool) -> OrderRecord: +         +        newOrder = OrderRecord( +                orderType=orderType, +                price=self.price, +                profit=self.profit, +                profitCumulative=self.profitCumulative +            ) +         +        self.trackRecord.append(newOrder) + +        return newOrder +``` + +As the general process is not that complicated, I want to highlight some of the peculiarities: + +##### Input data + +The trading bot only processes the last 21 elements as this is the range you consider when calculating the exponential moving average: + + +``` +`   self.ohlcv = pd.read_pickle(file_path)[-21:]` +``` + +##### Track record + +The type _ListPersist_ is an extended Python list object that writes itself to the file system when modified (when elements get added or removed). It creates the file `track_record.obj` under `~/Pythonic/executables/` once you run it the first time. + + +``` +`  self.trackRecord = ListPersist('track_record')` +``` + +Maintaining a track record helps to keep the state of recent bot activity. + +##### Plausibility + +The algorithm outputs an object of the type _OrderRecord_ in case conditions for a trade are met. It also keeps track of the overall situation: For example, if a buy signal was received, but `bBought` indicates that you already bought before, something must've gone wrong: + + +``` +else: # Something went wrong +    msg = 'Warning: Condition for {}-order met but bBought is {}'.format(OrderType(orderType).name, self.bBought) +    newOrder = None +``` + +In this scenario, _None_ is returned with a corresponding log message. + +### Simulation + +The Evaluation element (`generic_pipe_29dfc189.py`) contains these switches which enable you to force the execution of a buy or sell order: + + +``` +self.bForceBuy  = False +self.bForceSell = False +``` + +Open the code server IDE (http : //PythonicRPI:8000/), load `generic_pipe_29dfc189.py `and set one of the switches to _True_. Attach with the debugger and add a breakpoint where the execution path enters the _inner if_ conditions. + +![Add breakpoint for inner if conditions][26] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +Now open the programming GUI, add a **ManualScheduler **element (configured to _single fire_) and connect it directly to the **Evaluation** element to trigger it manually: + +![Add manual scheduler element][27] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +Click the play button. The **Evaluation **element is triggered directly, and the debugger stops at the previously set breakpoint. You are now able to add, remove, or modify orders from the track record manually to simulate certain scenarios: + +![Manually simulate scenarios ][28] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +Open the log message window (green outlined button) and the output data window (orange outlined button): + +![Pythonic trading output buttons][29] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +You will see the log messages and output of the **Evaluation** element and thus the behavior of the decision-making algorithm based on your input: + +### + +[19_pythonic_trading_simulate_orders_2.png][30] + +![Log messages and output of evaluation element][31] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +Summary + +The example stops here. The final implementation could notify the user about a trade indication, place an order on an exchange, or query the account balance in advance. At this point, you should feel that everything connects and be able to proceed on your own.  + +Using Pythonic as a base for your trading bot is a good choice because it runs on a Raspberry Pi, is entirely accessible by a web browser, and already has logging features. It is even possible to stop on a breakpoint without disturbing the execution of other tasks using Pythonic's multiprocessing capabilities. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/9/raspberry-pi-trading-bot + +作者:[Stephan Avenwedde][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/hansic99 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_whitehurst_money.png?itok=ls-SOzM0 (A dollar sign in a network) +[2]: https://opensource.com/article/20/4/python-crypto-trading-bot +[3]: https://github.com/hANSIc99/Pythonic +[4]: https://www.investopedia.com/articles/active-trading/052014/how-use-moving-average-buy-stocks.asp +[5]: https://opensource.com/article/21/9/raspberry-pi-remote-control +[6]: https://sourceforge.net/projects/pythonicrpi/ +[7]: https://opensource.com/sites/default/files/uploads/1_pythonic_trading_clear_2.png (Pythonic GUI overview) +[8]: https://creativecommons.org/licenses/by-sa/4.0/ +[9]: https://github.com/hANSIc99/Pythonic/raw/master/examples/trading_bot_crossing_ema/trading_bot_crossing_ema.zip +[10]: https://jupyter.org/ +[11]: https://opensource.com/sites/default/files/uploads/2_pythonic_trading_upload_buttons.png (Upload toolbar buttons) +[12]: https://opensource.com/sites/default/files/uploads/3_pythonic_trading_sample_loaded_2.png (Pythonic screen after upload of config.json) +[13]: https://opensource.com/sites/default/files/uploads/4_pythonic_trading_data_acquisition.png (Pythonic area 2 data acquisition) +[14]: https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html +[15]: https://opensource.com/sites/default/files/uploads/5_pythonic_trading_ohlcv_limit.png (OHLCV_Query configuration) +[16]: https://opensource.com/sites/default/files/uploads/6_pythonic_trading_ohlcv_data.png (Pythonic trading data graph) +[17]: https://opensource.com/sites/default/files/uploads/7_pythonic_trading_jupyter_a.png (Output after executing the first three cells) +[18]: https://opensource.com/sites/default/files/uploads/8_pythonic_trading_jupyter_calc_ema.png (EMA values added as separate columns to dataframe) +[19]: https://opensource.com/sites/default/files/uploads/9_pythonic_trading_buy_condition.png (Buy condition met) +[20]: https://opensource.com/sites/default/files/uploads/10_pythonic_trading_sell_condition.png (Sell condition met) +[21]: https://numpy.org/ +[22]: https://opensource.com/sites/default/files/uploads/11_pythonic_trading_jupyter_condition.png (Dataframe with 20 entries) +[23]: https://opensource.com/sites/default/files/uploads/12_pythonic_trading_jupyter_filter.png (Applying the diff operation) +[24]: https://opensource.com/sites/default/files/uploads/13_pythonic_trading_backtest_trades.png (One-trade mini dataset profit) +[25]: https://opensource.com/sites/default/files/uploads/14_pythonic_trading_implementation.png (Decision-making implementation on area 1) +[26]: https://opensource.com/sites/default/files/uploads/15_pythonic_trading_breakpoint_2.png (Add breakpoint for inner if conditions) +[27]: https://opensource.com/sites/default/files/uploads/16_pythonic_trading_manual_trigger.png (Add manual scheduler element) +[28]: https://opensource.com/sites/default/files/uploads/17_pythonic_trading_debugger_stop.png (Manually simulate scenarios) +[29]: https://opensource.com/sites/default/files/uploads/18_pythonic_trading_output_buttons.png (Pythonic trading output buttons) +[30]: https://opensource.com/file/512111 +[31]: https://opensource.com/sites/default/files/uploads/19_pythonic_trading_simulate_orders_2.png (Log messages and output of evaluation element) diff --git a/sources/tech/20210928 What is port forwarding.md b/sources/tech/20210928 What is port forwarding.md new file mode 100644 index 0000000000..0cccbb2063 --- /dev/null +++ b/sources/tech/20210928 What is port forwarding.md @@ -0,0 +1,98 @@ +[#]: subject: "What is port forwarding?" +[#]: via: "https://opensource.com/article/21/9/what-port-forwarding" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +What is port forwarding? +====== +This article demonstrates the most common scenarios for port forwarding. +![Multi-colored and directional network computer cables][1] + +Port forwarding transfers network traffic from one network listener (called a "port") to another, either on the same computer or a different computer. Ports, in this context, are not physical objects but a software routine listening for network activity. + +When traffic directed at a specific port arrives at a router or a firewall, or other networked application, the response it receives can be defined according to the port it's trying to communicate with. When you use port forwarding, you can catch communication coming in on port 8080, for instance, and forward it on to port 80 instead. The new destination port may be on the same device as the one receiving the signal or on a different device. There are many ways to forward ports, and there are different reasons for doing it. This article demonstrates the most common scenarios. + +### Port forwarding with your router + +You usually need to forward ports when you host a server at home. Your home router (usually the WiFi appliance you get from your ISP) has a built-in firewall designed to prevent the outside world from getting onto your home network. You can use port forwarding to allow traffic on a specific port through your router's firewall, sending it to a specific IP address on your network. + +For instance, say you're hosting a [Minetest server][2] and want to invite friends. For them to get through your router and into your Minetest server, you must forward a port from the router to the computer hosting Minetest. By default, a Minetest server runs on port 30000. You can port forward 30000 on your router to port 30000 on your Minetest server, or you could arbitrarily invent a simpler port for your players to remember and then forward that instead. I find that people inevitably miscount the zeroes in 30000 (especially without the benefit of a comma to help), so I use port 1234 and forward it to my internal 30000 port. + +Router interfaces differ from manufacturer to manufacturer, but the idea is the same regardless of what brand of router you have in your home. First, log in to your router. +Its IP address and login information is often printed on the router itself or in its documentation. I own a TP-Link GX90 router, and I log in to it by pointing my web browser to 10.0.1.1, but your router might be 192.168.0.1 or some other address. + +My GX90 router calls port forwarding "Virtual servers," which is a category found in the router's **NAT forwarding** tab. NAT stands for _Network Address Translation_. Other routers may just call it **Port forwarding** or **Firewall** or **Services**. It may take a little clicking around to find the right category, or you may need to spend some time studying your router's documentation. + +When you find the port forwarding setting, add a new rule that names an external port (1234, in my example) and an internal one (30000). Forward the external port to the internal port on the IP address of the computer you want people to be able to access. If you need help finding your IP address, read Archit Modi's _[How to find your IP address on Linux][3]_ article. + +![A sample port forwarding rule][4] + +A sample port forwarding rule +(Seth Kenlon, [CC BY-SA 4.0][5]) + +In this example, I'm forwarding traffic that reaches my home network at port 1234 to port 30000 of my home server located at 10.0.1.2. + +Save the rule to proceed. + +Next, you need to know your home network's public IP address. You can obtain this from websites like [ifconfig.me][6] or [icanhazip.com][7]. Either open a browser to one of those sites or get the IP using the [curl][8] command: + + +``` +$ curl ifconfig.me +93.184.216.34 +``` + +Your friends can now join your Minetest server by entering the `169.169.23.49:1234` into their Minetest client. + +### Port forwarding with a firewall + +Sysadmins sometimes need to forward ports for traffic reaching a server. For example, you may want to accept traffic to port 80 but present the user with a service running on port 8065. Without port forwarding, your users would have to remember to append a specific port at the end of the URL they enter into their browser, such as `example.com:8065`.  Most users aren't used to thinking about ports, so intercepting a call to the common web port 80 and redirecting it to the obscure one your web app runs on is a big convenience for your users. + +You can forward traffic on a server using [firewall-cmd][9], the front-end command to the `firewalld` daemon. + +First, set the ports and protocols you want to forward: + + +``` +$ sudo firewall-cmd \ +\--add-forward-port \ +port=80:proto=tcp:toport=8065 +``` + +To make the change permanent, use the `--runtime-to-permanent` option: + + +``` +`$ sudo firewall-cmd --runtime-to-permanent` +``` + +### Network forwarding + +In networking, there are other kinds of forwarding aside from port forwarding. For instance, both IP forwarding and proxying are forms of forwarding. As you get familiar with how network information is processed as it's routed, you can try different kinds of forwarding (and watch it with `tcpdump` or similar) to see what works best for your setup. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/9/what-port-forwarding + +作者:[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/connections_wires_sysadmin_cable.png?itok=d5WqHmnJ (Multi-colored and directional network computer cables) +[2]: https://opensource.com/alternatives/minecraft#minetest +[3]: https://opensource.com/article/18/5/how-find-ip-address-linux +[4]: https://opensource.com/sites/default/files/uploads/router-port-forward.jpg (A sample port forwarding rule) +[5]: https://creativecommons.org/licenses/by-sa/4.0/ +[6]: http://ifconfig.me +[7]: http://icanhazip.com +[8]: https://opensource.com/article/20/5/curl-cheat-sheet +[9]: https://www.redhat.com/sysadmin/secure-linux-network-firewall-cmd diff --git a/sources/tech/20210929 How I keep my file folders tidy with Ansible.md b/sources/tech/20210929 How I keep my file folders tidy with Ansible.md new file mode 100644 index 0000000000..aacc2f33b1 --- /dev/null +++ b/sources/tech/20210929 How I keep my file folders tidy with Ansible.md @@ -0,0 +1,183 @@ +[#]: subject: "How I keep my file folders tidy with Ansible" +[#]: via: "https://opensource.com/article/21/9/keep-folders-tidy-ansible" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +How I keep my file folders tidy with Ansible +====== +I try to use Ansible often, even for tasks that I know how to do with a +shell script because I know that Ansible is easy to scale. +![Filing cabinet for organization][1] + +I try to use Ansible often, even for tasks that I know how to do with a shell script because I know that Ansible is easy to scale. Even though I might develop an Ansible playbook just for my personal workstation, sometimes it ends up being a lot more useful than intended, and it's easy to apply that same playbook to all the computers on my network. And besides, sometimes the greatest enemy of getting really good at something is the impression that it's only meant for serious professionals, or big projects, or whatever you feel that you're not. I use Ansible because it's a great open source tool, but I benefit from it the most because it scales. + +One of the tasks I recently assigned to Ansible was the monumental one of keeping my Downloads folder tidy. If you're like me, you end up downloading many files from the Internet throughout the day and then forget that the files exist. On the one hand, I don't mind this habit. There have been times when I realize I still need a file in my Downloads folder, so forgetting about a file rather than promptly removing it can be helpful. However, there are other files that I download expressly to use once and then ought to remove. + +I decided to use a highly specific Ansible task to find files I know I don't need and then remove them. + +### Ansible boilerplate + +Ansible playbooks generally start in exactly the same way: Define your hosts and announce a task: + + +``` +\--- +\- hosts: localhost +  tasks: +``` + +Commit those three lines to memory. They're the "shebang" (`#!`) of Ansible playbooks. Once you have those lines in a text file, you can start defining the steps in your task. + +### Finding files with Ansible + +You can locate files on a system using the [`find` Ansible module][2]. If an Ansible module is a command, its parameters are its [command options][3]. In this example playbook, I want to find files explicitly located in the `~/Downloads` folder and I can define that using the `paths` parameter. + +This is my process when I start writing a playbook: I find a module in the Ansible module index that seems likely to do what I need, and then I read through its parameters to find out what kind of control I have over the module. + +In my case, the files I accidentally collect in my Downloads folder are CSV files. They get downloaded weekly, processed, and then ought to disappear. But they hang around for weeks until I get overwhelmed and delete them. Here's how to find CSV files in Downloads with Ansible: + + +``` +\--- +\- hosts: localhost +  tasks: +    - name: Find CSV in Downloads +      find: +        paths: ~/Downloads +        recurse: false +        patterns: '*.csv,*.CSV' +      register: result +``` + +The `paths` parameter tells Ansible where to search for files. + +The `recurse: false` parameter forbids Ansible from searching in subdirectories of Downloads. This gives me the ability to retain CSV files that I've downloaded and saved into a subdirectory. Ansible only targets the CSV files I save straight to Downloads (which is my habit). + +The `patterns` parameter tells Ansible what to count as a match. All of the CSV files I download end in .csv, but I'm confident that I'm willing to remove .CSV (in all capital letters) as well. + +The finishing touch to this step is to invoke the `register` module, which saves the results of the `find` process into a variable called `result`. + +This is important because I want Ansible to perform a second action on the results of `find`, so those results need to be stored somewhere for the next step. + +### Removing files with Ansible + +The next step in the task is to remove the files that `find` has uncovered. The module used to remove files is the [`file` module][4]. + +This step relies entirely on the `find` step, so it uses several variables: + + +``` +    - name: Remove CSV files +      file: +        path: "{{ item.path }}" +        state: absent +      with_items: "{{ result.files }}" +``` + +The `path` parameter uses the built-in `"{{ item.path }}"` variable, which confusingly isn't actually defined yet. The variable has no information on the path until the `file` module is used in a loop by the `with_items` keyword. The `with_items` step uses the contents of the `result` variable to extract one filename at a time, which becomes the `item` for the `path` parameter. Once the current item's path is extracted, Ansible uses the `state: absent` rule to ensure that the file located at that path is _not_ left on the system (in other words, it's deleted.) + +This is a _very_ dangerous step, especially during testing. If you get this step wrong, you can easily remove files you don't intend to delete. + +### Verify the playbook  + +Ansible playbooks are written in [YAML][5], which has a strict syntax. Verify that your YAML is correct using the `yamllint` command: + + +``` +$ yamllint cleanup.yaml +$ +``` + +No results means no errors. This playbook must have been written by someone who really [knows and loves YAML][6]! + +### Testing Ansible plays safely + +To avoid deleting my entire home directory by accident, I ran my first attempt with the `--check` option. This ensures that Ansible doesn't actually make changes to your system. + + +``` +$ ansible-playbook --check example.yaml +[WARNING]: provided hosts list is empty, only localhost is available. +'all' + +PLAY [localhost] **************************************************** + +TASK [Gathering Facts] ********************************************** +ok: [localhost] + +TASK [Find CSV files in Downloads] ********************************** +ok: [localhost] + +TASK [Remove CSV files] ********************************************* +changed: [localhost] => (item={'path': '/home/tux/Downloads/foo.csv', [...] +changed: [localhost] => (item={'path': '/home/tux/Downloads/bar.csv', [...] +changed: [localhost] => (item={'path': '/home/tux/Downloads/baz.csv', [...] + +PLAY RECAP ********************************************************** +localhost                  : ok=3    changed=1    unreachable=0 [...] +``` + +The output is very verbose, but it shows that my playbook is correct: Only CSV files within Downloads have been marked for removal. + +### Running Ansible playbooks + +To run an Ansible playbook, you use the `ansible-playbook` command: + + +``` +`$ ansible-playbook example.yaml` +``` + +Confirm the results: + + +``` +$ ls *.csv  ~/Downloads/ +ls: cannot access '*.csv': No such file or directory +/home/tux/Downloads/: +file.txt +``` + +### Schedule the Ansible playbook + +The Ansible playbook has been confirmed, but I want it to run at least every week. I use [Anacron][7] rather than Cron, so I created an Anacron job to run weekly: + + +``` +$ cat << EOF >> ~/.local/etc/cron.weekly/cleanup +#!/bin/sh +ansible-playbook $HOME/Ansible/cleanup.yaml +EOF +$ chmod +x ~/.local/etc/cron.daily/cleanup +``` + +### What can you do with Ansible? + +Generally, Ansible is meant as a system maintenance tool. It's finely tuned to bootstrap complex systems to help with course correction when something's gone wrong and to keep a system in a specific state. I've used it for simple but repetitive tasks, like setting up a complex directory tree that would typically require several commands or clicks. I've also used it for tasks I don't want to do wrong, like removing old files from directories. I've also used it for tasks that are just too complex for me to bother trying to remember, like synchronizing several changes made to a production system with its redundant backup system. + +I don't use this cleanup script on my servers because I don't download CSV files every week on my servers, but I do use a variation of it. Ansible isn't a replacement for shell or Python scripting, but for some tasks, it's a very precise method to perform some set of tasks that you might want to run on many more systems. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/9/keep-folders-tidy-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/files_documents_organize_letter.png?itok=GTtiiabr (Filing cabinet for organization) +[2]: https://docs.ansible.com/ansible/2.8/modules/find_module.html#find-module +[3]: https://opensource.com/article/21/8/linux-terminal#options +[4]: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/file_module.html +[5]: https://www.redhat.com/sysadmin/yaml-beginners +[6]: https://www.redhat.com/sysadmin/yaml-tips +[7]: https://opensource.com/article/21/2/linux-automation diff --git a/sources/tech/20210929 How to Install and Setup Flutter Development on Ubuntu and Other Linux.md b/sources/tech/20210929 How to Install and Setup Flutter Development on Ubuntu and Other Linux.md new file mode 100644 index 0000000000..11263c6eab --- /dev/null +++ b/sources/tech/20210929 How to Install and Setup Flutter Development on Ubuntu and Other Linux.md @@ -0,0 +1,191 @@ +[#]: subject: "How to Install and Setup Flutter Development on Ubuntu and Other Linux" +[#]: via: "https://itsfoss.com/install-flutter-linux/" +[#]: author: "Community https://itsfoss.com/author/itsfoss/" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +How to Install and Setup Flutter Development on Ubuntu and Other Linux +====== + +Google’s UI toolkit Flutter is getting increasingly popular for creating cross-platform applications for the mobile, web and desktop. + +[Flutter][1] is not a programming language but a software development kit. [Dart][2] is the programming language used underneath the Flutter SDK. + +Flutter is the main framework behind Google’s open source Fuchsia OS, Google STADIA and many other software and mobile apps. + +If you want to start developing with Flutter, this tutorial will help you to get your set-up ready on Ubuntu and hopefully other Linux distributions. + +### Installing Flutter on Ubuntu and other Linux with Snap + +The easiest way to install Flutter on Linux is by using Snap. If you are using Ubuntu, you already have got Snap. _**For other distributions, please make sure to [enable Snap support][3].**_ + +[Open a terminal][4] and use the following command in a terminal to install Flutter: + +``` +sudo snap install flutter --classic +``` + +You’ll see something like this on your terminal: + +![][5] + +Once the installation completes, it is time to verify it. Not just Flutter installation but also verify every dependency that needs to be satisfied for Flutter to function properly. + +#### Verify Flutter dependencies + +To verify that every dependency, for the correct work of Flutter, is installed, Flutter has a built-in option: + +``` +flutter doctor +``` + +The process will start, looking like this: + +![][6] + +And it will be finishing like this: + +![][7] + +As you can see, we need Android Studio for working. So let’s install it. How do we do that? [Installing Android Studio on Linux][8] is also effortless with Snap. + +#### Install and set up Android Studio + +In a terminal, use the following command to get Android Studio installed: + +``` +sudo snap install android-studio --classic +``` + +![][9] + +Once installed, open Android Studio from our operating system menu. + +![][10] + +You are almost done. It’s time for configuring Android Studio. + +![][11] + +Click next and select standard if you don’t want to complicate things. + +![][12] + +Select your preferred theme (I like the Dark one). + +![][13] + +Verify that everything is OK and click on Next. + +![][14] + +Finally, hit the Finish button. + +![][15] + +And wait until the download is finished. + +![][16] + +### Creating a sample Hello World Flutter app + +In Android Studio, go to Projects and select New Flutter Project. Flutter SDK path will be set by default. + +![][17] + +And here is where the magic starts to appear because this is where you set your project name, which in this case it will be called hello_world. + +Let’s select the three available platforms: **Android, iOS, and Web**. And finally, click on Finish. + +![][18] + +The principal file in the projects is located in `lib/main.dart`, as is shown in the next image. + +![][19] + +Once selected, erase everything contained inside the file and change it for this sample code: + +``` +// Copyright 2018 The Flutter team. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +void main() => runApp(MyApp()); + +class MyApp extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Welcome to Flutter', + home: Scaffold( + appBar: AppBar( + title: const Text('Welcome to Flutter'), + ), + body: const Center( + child: Text('Hello World'), + ), + ), + ); + } +} +``` + +It’s important to say that this is only for showing you how Flutter works, in case you’re convinced about learning this beautiful and incredible language, here is the [Documentation][20] to see more about it. **Try** it! + +Finally, select **Chome Web** device and do click on the **Run** button, as is shown below; and see the magic! + +![][21] + +It’s incredible how fast you can create a Flutter project. Say hello to your Hello World project. + +![][22] + +### In the end… + +Flutter and Dart are perfect if you want to contribute with beautiful mobile and Web interfaces in a short time. + +Now you know how to install Flutter on Ubuntu Linux and how to create your first app with it. I really enjoyed writing this post for you, hoping this helps you and if you have any questions, please let me know by leaving a comment or sending me an email to [[email protected]][23] Good luck! + +_**Tutorial contributed by Marco Antonio Carmona Galván, a student of physics and data science.**_ + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-flutter-linux/ + +作者:[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://flutter.dev/ +[2]: https://dart.dev/ +[3]: https://itsfoss.com/install-snap-linux/ +[4]: https://itsfoss.com/open-terminal-ubuntu/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/installing-flutter-ubuntu.png?resize=786%2C195&ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/verify-flutter-install.png?resize=786%2C533&ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/Flutter-verification-completes.png?resize=786%2C533&ssl=1 +[8]: https://itsfoss.com/install-android-studio-ubuntu-linux/ +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/install-android-studio-linux-snap.png?resize=786%2C187&ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/Open_Android_Studio.webp?resize=800%2C450&ssl=1 +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/Setting-Up-Android-Studio-1.png?resize=800%2C603&ssl=1 +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/Setting-Up-Android-Studio-2.png?resize=800%2C603&ssl=1 +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/Setting-Up-Android-Studio-3.png?resize=800%2C603&ssl=1 +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/Setting-Up-Android-Studio-4.png?resize=800%2C603&ssl=1 +[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/Setting-Up-Android-Studio-5.png?resize=800%2C603&ssl=1 +[16]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/Setting-Up-Android-Studio-6.png?resize=800%2C603&ssl=1 +[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/New_flutter_project.png?resize=800%2C639&ssl=1 +[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/sample-flutter-project.png?resize=800%2C751&ssl=1 +[19]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/sample-flutter-project-1.png?resize=800%2C435&ssl=1 +[20]: https://flutter.dev/docs +[21]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/sample-flutter-project-2.png?resize=800%2C450&ssl=1 +[22]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/sample-flutter-project-3.png?resize=800%2C549&ssl=1 +[23]: https://itsfoss.com/cdn-cgi/l/email-protection diff --git a/sources/tech/20210929 Troubleshooting -Bash- Command Not Found- Error in Linux.md b/sources/tech/20210929 Troubleshooting -Bash- Command Not Found- Error in Linux.md new file mode 100644 index 0000000000..3fd4ae17bb --- /dev/null +++ b/sources/tech/20210929 Troubleshooting -Bash- Command Not Found- Error in Linux.md @@ -0,0 +1,151 @@ +[#]: subject: "Troubleshooting “Bash: Command Not Found” Error in Linux" +[#]: via: "https://itsfoss.com/bash-command-not-found/" +[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Troubleshooting “Bash: Command Not Found” Error in Linux +====== + +_**This beginner tutorial shows how to go about fixing the Bash: command not found error on Debian, Ubuntu and other Linux distributions.**_ + +When you use commands in Linux, you expect to see an output. But sometimes, you’ll encounter issues where the terminal shows ‘command not found’ error. + +![][1] + +There is no straightforward, single solution to this error. You have to do a little bit of troubleshooting on your own. + +It’s not too difficult, honestly. The error gives some hint already when it says “bash: command not found”. Your shell (or Linux system) cannot find the command you entered. + +There could be three possible reasons why it cannot find the command: + + * It’s a typo and the command name is misspelled + * The command is not even installed + * The command is basically an executable script and its location is not known + + + +Let’s go in detail on each possible root cause. + +### Fixing “bash: command not found” error + +![][2] + +#### Method 1: Double check the command name (no, seriously) + +It is human to make mistakes, specially while typing. It is possible that the command you entered has a typo (spelling mistake). + +You should specially pay attention to: + + * The correct command name + * The spaces between the command and its options + * The use of 1 (numeral one), I (capital i) and l (lowercase L) + * Use of uppercase and lowercase characters + + + +Take a look at the example below, where I have misspelled the common ls command. + +![][3] + +So, make double sure what you are typing. + +#### Method 2: Ensure that the command is installed on your system + +This is another common reason behind the command not found error. You cannot run a command if it is not installed already. + +While your Linux distribution comes with a huge number of commands installed by default, it is not possible to pre-install all the command line tools in a system. If the command you are trying to run is not a popular, common command, you’ll have to install it first. + +You can use your distribution’s package manager to install it. + +![You may have to install the missing command][4] + +In some cases, popular commands may get discontinued and you may not even install it anymore. You’ll have to find an alternative command to achieve the result. + +Take the example of ipconfig command. This deprecated command was used for [getting Ip address][5] and other network interface information. Older tutorials on the web still mention using this command but you cannot use it anymore in newer Linux versions. It has been replaced by the ifconfig tool. + +![Some popular commands get discontinued over the time][1] + +Occasionally, your system won’t find even the extremely common commands. This is often the case when you are running a Linux distribution in Docker containers. To cut down on the size of the operating system image, the containers often do not include even the most common Linux commands. + +This is why Docker user stumble across things like [ping command not found error][6] etc. + +![Docker containers often have only a few commands installed][7] + +So, the solution is to either install the missing command or find a tool that could do the same thing you were trying to do with the missing command. + +#### Method 3: Check if it is an executable script with correct path + +This is a common mistake Linux rookies make while [running a shell script][8]. + +Even if you are in the same directory and try to run an executable script just by its name, it will show an error. + +``` +[email protected]:~/scripts# sample +-bash: sample: command not found +``` + +You need to either specify the shell interpreter explicitly or its absolute path. + +![][9] + +If you are in some other directory and try to execute the shell script without giving the correct path to the file, it will complain about not finding the file. + +![][10] + +##### Adding it to the PATH + +In some cases, you download the entire software in a tar file, extract it and find an executable file along with other program files. To run the program, you need to run the executable file. + +But for that, you need to be in the same directory or specify the entire path to the executable file. This is tiresome. + +Here, you can use the PATH variable. This variable has a collection of directories and these directories have the binary (executable) files of various Linux commands. When you run a command, your Linux system checks the mentioned directories in the PATH variable to look for the executable file of that command. + +You can check the location of the binary of a command by using the `which` command: + +![][11] + +If you want to run an executable file or script from anywhere on the system, you need to add the location of the file to this PATH variable. + +![][12] + +The PATH variable then needs to be added to the rc file of the shell so that the changes made to PATH variable is permanent. + +You get the gist here. It is important that your Linux system has the knowledge about the location of the executable script. Either you give the path while running it or you add its location to the PATH variable. + +### Did it help you? + +I understand that when you are new to Linux, things could be overwhelming. But when you understand the root cause of the problem, it gradually improved your knowledge. + +Here, there is no straightforward solution possible for the ‘command not found error’. I gave you some hints and pointers and that should help you in troubleshooting. + +If you still have doubt or need help, please let me know in the comment section. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/bash-command-not-found/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/bash-command-not-found-error.png?resize=741%2C291&ssl=1 +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/bash-command-not-found-error-1.png?resize=800%2C450&ssl=1 +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/command-not-found-error.png?resize=723%2C234&ssl=1 +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/command-not-found-debian.png?resize=741%2C348&ssl=1 +[5]: https://itsfoss.com/check-ip-address-ubuntu/ +[6]: https://linuxhandbook.com/ping-command-ubuntu/ +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/ping-command-not-found-ubuntu.png?resize=786%2C367&ssl=1 +[8]: https://itsfoss.com/run-shell-script-linux/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/bash-script-command-not-found-error-800x331.png?resize=800%2C331&ssl=1 +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/script-file-not-found-error-800x259.png?resize=800%2C259&ssl=1 +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/path-location.png?resize=800%2C241&ssl=1 +[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/adding-executable-to-PATH-variable-linux.png?resize=800%2C313&ssl=1 diff --git a/sources/tech/20210930 Using Ansible with REST APIs.md b/sources/tech/20210930 Using Ansible with REST APIs.md new file mode 100644 index 0000000000..4d05c8375b --- /dev/null +++ b/sources/tech/20210930 Using Ansible with REST APIs.md @@ -0,0 +1,212 @@ +[#]: subject: "Using Ansible with REST APIs" +[#]: via: "https://opensource.com/article/21/9/ansible-rest-apis" +[#]: author: "Vince Power https://opensource.com/users/vincepower" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Using Ansible with REST APIs +====== +You may have queried APIs with a web browser or curl, but one of the +overlooked capabilities of Ansible is how well it can leverage APIs as +part of any playbook. +![Looking at a map][1] + +Ansible is a top open source project which, on the surface, looks to provide a simple way to standardize your existing automation and allow it to run in parallel across multiple hosts, and it does this very successfully. Yet, in reality, Ansible has the capabilities to extend what your existing automation does to incorporate other systems and really simplify tasks across all aspects of your daily routine. + +This capability starts with the [collections][2] and [roles][3] that are included with Ansible and all the third-party utilities distributed through [Ansible Galaxy][4]. You may have queried APIs with a web browser or [curl][5], but one of the overlooked capabilities of Ansible is how well it can leverage APIs as part of any playbook. This is extremely useful because the number of REST APIs being built and deployed both internally and across the global internet is increasing exponentially. There's even a [public-apis GitHub repo][6] listing hundreds of free APIs across over a dozen categories just for a sense of scale. + +### A basic API playbook + +Well, it really comes down to a few key core capabilities within Ansible, which are exposed nicely with one specific built-in task, _uri_. In this post, I'll go through a fairly simple example of how to call a REST API and use the data from that call to decide what to do next. This works with Ansible 2.9 and higher. In later versions (specifically v4), the modules we use need to be prepended with _ansible.builtin_ like _ansible.builtin.set_fact_ instead of just _set_fact_. + +To get started, you need a basic playbook to build on. In this case, you're only using local calls, so you don't need to be a superuser. + +First, create this YAML file to establish a working baseline: + + +``` +\--- +\- name: Using a REST API +  become: false +  hosts: localhost +  gather_facts: false +  tasks: +    - debug: +        msg: “Let’s call an API” +``` + +Here's the output after running it: + + +``` +% ansible-playbook using-a-rest-api.yml + +PLAY [Using a REST API] ********************************************************************************************* + +TASK [debug] ******************************************************************************************************** +ok: [localhost] => { +    "msg": "“Let’s call an API”" +} + +PLAY RECAP ********************************************************************************************************** +localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   +``` + +### Calling an API + +To call an actual API, you can use the _uri_ module. Here are two examples. The first is just a GET and the second is a POST with parameters to show the different available options. + + +``` +\--- +\- name: Everyone loves a good Chuck Norris joke +  uri: +    url: +    method: GET + +\- name: Login to an API +  uri: +    url: +    method: POST +    body_format: json +    body: +      name: your_username +      password: your_password +      client_id: YOUR_CLIENT_ID +      access_token: ACCESS_TOKEN +      connection: CONNECTION +      scope: SCOPE +``` + +I use the first API for the rest of this article to show how the returned data can be used. The question is, how do you collect the data being returned, and what does it look like? + +To collect the output from any task running in Ansible, you use the _register_ attribute, and then you can use the _debug_ task to display the raw data. In the case of APIs called using _uri_, all the output is put under the .json. Subsection of the result. The _uri_ commands and other its output are also at that top level. These can be useful to make sure the API call works by looking at other data fields like status. + +These are the two tasks you must add to the original playbook to add the API call to the mix to later do something with. + + +``` +  - name: Getting the definition of awesome +      uri: +        url: +        method: GET +      register: results + +    - debug: +        var: results +``` + +Run it to see the output generated by debug: + + +``` +TASK [debug] ******************************************************************************************************** +ok: [localhost] => { +    "results": { +        "alt_svc": "h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400, h3-28=\":443\"; ma=86400, h3-27=\":443\"; ma=86400", +        "cf_cache_status": "DYNAMIC", +        "cf_ray": "694f7d791aeb19e7-EWR", +        "changed": false, +        "connection": "close", +        "content_type": "application/json;charset=UTF-8", +        "cookies": {}, +        "cookies_string": "", +        "date": "Sun, 26 Sep 2021 21:12:23 GMT", +        "elapsed": 0, +        "expect_ct": "max-age=604800, report-uri=\""", +        "failed": false, +        "json": { +            "categories": [], +            "created_at": "2020-01-05 13:42:26.991637", +            "icon_url": "", +            "id": "IjqNNWKvSDeVKaI82PaT1g", +            "updated_at": "2020-01-05 13:42:26.991637", +            "url": "", +            "value": "One person stated that Chuck Norris has forgotten more about killing than anyone will ever know. That is not true -- Chuck Norris never forgets. Ever." +        }, +        "msg": "OK (unknown bytes)", +        "nel": "{\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}", +        "redirected": false, +        "report_to": "{\"endpoints\":[{\"url\":\"https:\\\/\\\/a.nel.cloudflare.com\\\/report\\\/v3?s=HVPJYMVr%2B3wB1HSlgxv6GThBMjkBJgfdu0DPw%2BunjQzQ9YfXZqifggIJ%2FxOIKgOu6JP1SrPsx1jCCp3GQ9hZAp7NO0pmlTZ0y3ufbASGwLmCOV1zyaecUkSwQD%2Fv3RYYgZTkaSQ%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}", +        "server": "cloudflare", +        "status": 200, +        "transfer_encoding": "chunked", +        "url": "", +        "via": "1.1 vegur" +    } +} +``` + +Now that you can see all the output make a custom message listing the value returned by the API. Here is the completed playbook: + + +``` +\--- +\- name: Using a REST API +  become: false +  hosts: localhost +  gather_facts: false +  tasks: +    - debug: +        msg: “Let’s call an API” + +    - name: Everyone loves a good Chuck Norris joke +      uri: +        url: +        method: GET +      register: results + +    - debug: +        var: results.json.value +``` + +And now the complete output: + + +``` +PLAY [Using a REST API] ********************************************************************************************* + +TASK [debug] ******************************************************************************************************** +ok: [localhost] => { +    "msg": "“Let’s call an API”" +} + +TASK [Everyone loves a good Chuck Norris joke] ********************************************************************** +ok: [localhost] + +TASK [debug] ******************************************************************************************************** +ok: [localhost] => { +    "results.json.value": "Chuck Norris is the only computer system that beats a Mac or a PC. Too bad all it does is round house kicks the user." +} + +PLAY RECAP ********************************************************************************************************** +localhost                  : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   +``` + +### Next steps + +Things can get much more complicated than I've shown here. To get more details, head over to Ansible's [documentation][7]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/9/ansible-rest-apis + +作者:[Vince Power][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/vincepower +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tips_map_guide_ebook_help_troubleshooting_lightbulb_520.png?itok=L0BQHgjr (Looking at a map) +[2]: https://docs.ansible.com/ansible/latest/user_guide/collections_using.html +[3]: https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html +[4]: https://galaxy.ansible.com/ +[5]: https://www.redhat.com/sysadmin/use-curl-api +[6]: https://github.com/public-apis/public-apis +[7]: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/uri_module.html diff --git a/sources/tech/20211001 How to Install Google Chrome on Debian and Kali Linux.md b/sources/tech/20211001 How to Install Google Chrome on Debian and Kali Linux.md new file mode 100644 index 0000000000..a3fb8467ef --- /dev/null +++ b/sources/tech/20211001 How to Install Google Chrome on Debian and Kali Linux.md @@ -0,0 +1,160 @@ +[#]: subject: "How to Install Google Chrome on Debian and Kali Linux" +[#]: via: "https://itsfoss.com/install-chrome-debian-kali-linux/" +[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" +[#]: collector: "lujun9972" +[#]: translator: "geekpi" +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +How to Install Google Chrome on Debian and Kali Linux +====== + +Debian and Debian-based Kali Linux come with Firefox as the default web browser. But this does not mean that you cannot install other web browsers in it. + +Google Chrome is hugely popular and you probably already use it on other systems. If you want to install Chrome on Debian, you can surely do so. + +You won’t find Google Chrome in the repositories of Debian because it is not open source software but you can download and install it from Chrome website. + +In this tutorial, I’ll show you two methods of installing Chrome on Debian: + + * GUI method + * Command line method + + + +Let’s start with the GUI method first. + +_**Note: I am using Debian in the examples here but since Kali Linux is based on Debian, the same methods are also applicable to Kali Linux.**_ + +### Method 1: Installing Chrome on Debian Graphically + +This is a no-brainer. You go to the Google Chrome website, download the deb file and double lick on it to install it. I am going to show the steps in detail so that it is easy for you to follow it. + +Go to Google Chrome’s website. + +[Get Google Chrome][1] + +You’ll see the option to download Google Chrome. + +![Click on the Download Chrome button][2] + +When you click on the download button, it gives you two options for downloading the installer file. Go with the one that says Debian/Ubuntu. + +![Download the Chrome installer file for Debian][3] + +**Please note that Google Chrome is NOT available for 32-bit systems.** + +In the next screen, you should opt for saving the file to the computer instead of opening it in software center for installation. This way, the downloaded file will be saved in the Downloads folder instead of the temp directory. + +![Save the downloaded DEB file for Google Chrome][4] + +Go to the Download folders and right click on the downloaded deb file and choose to open it with Software Install. + +![Right click on the downloaded DEB file and open with Software Install][5] + +It will then open the software center and you should see the option to install Chrome now. Click on the install button. + +![Click on the install button][6] + +You’ll be asked to enter your account’s password. This is the same password you use to log into your system. + +![Enter your account’s password][7] + +In less than a minute, Google Chrome will be installed. You should see a remove option now which indicates that the software is installed. + +![Chrome is now installed][8] + +Once Chrome is installed on Debian, search for it in the system menu and start it. + +![Start Google Chrome][9] + +It will ask to be your default browser and send the crash reports to Google. You can uncheck either or both options. And then you can see Google Chrome browser window. + +![][10] + +If you log into your Google account, you should be able to sync your passwords, bookmarks and other browsing data here. Enjoy it! + +Another thing, after installing Chrome, you can delete the downloaded DEB file from your system. It is not needed anymore, not even for uninstalling Chrome. + +### Method 2: Install Google Chrome on Debian from the terminal + +What you just saw above can be easily achieved in the terminal. + +First, make sure that your package cache is refreshed and you have wget installed for [downloading files from the web in the terminal][11]. + +``` +sudo apt update && sudo apt install wget +``` + +The next option is to download the .deb file of Google Chrome: + +``` +wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb +``` + +Once downloaded, you can [install the deb file in the terminal][12] with apt command like this: + +``` +sudo apt install ./google-chrome-stable_current_amd64.deb +``` + +Once the installation completes, you can start using Chrome. + +### Bonus tip: Updating Google Chrome + +Both methods add Google’s repository to your system. You can see it in your sources.lis.d directory: + +``` +cat /etc/apt/sources.list.d/google-chrome.list +``` + +This means that Google Chrome will be updated with other system updates in Debian and Kali Linux. You know [how to update your Kali Linux][13] or Debian system in command line? Just use this command: + +``` +sudo apt update && sudo apt upgrade -y +``` + +### Uninstall Google Chrome from your system + +Even if you chose to install Chrome on Debian using the GUI method, you’ll have to use the terminal to remove it. + +Don’t worry. It’s really just one command: + +``` +sudo apt purge google-chrome-stable +``` + +Enter your account password when asked. Nothing is displayed on the screen when you type the password. That’s okay. Type it and press enter and confirm the deletion. + +![][14] + +Well, that’s about it. I hope you find this tutorial helpful. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-chrome-debian-kali-linux/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.google.com/chrome/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/download-chrome-on-debian.webp?resize=800%2C344&ssl=1 +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/downloading-google-chrome.webp?resize=800%2C512&ssl=1 +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/save-downloaded-chrome-installer-file-debian.webp?resize=800%2C430&ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/open-deb-file-with-software-install.webp?resize=800%2C419&ssl=1 +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/installing-chrome-debian.webp?resize=800%2C408&ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/09/enter-account-password-while-installing-deb-file.webp?resize=800%2C420&ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/chrome-installed-debian.webp?resize=800%2C384&ssl=1 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/start-chrome-debian.webp?resize=800%2C276&ssl=1 +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/09/Chrom-in-Debian.webp?resize=800%2C450&ssl=1 +[11]: https://itsfoss.com/download-files-from-linux-terminal/ +[12]: https://itsfoss.com/install-deb-files-ubuntu/ +[13]: https://linuxhandbook.com/update-kali-linux/ +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/09/remove-google-chrome-ubuntu.webp?resize=800%2C450&ssl=1 diff --git a/sources/tech/20211004 How I use Vagrant with libvirt.md b/sources/tech/20211004 How I use Vagrant with libvirt.md new file mode 100644 index 0000000000..198d512bc1 --- /dev/null +++ b/sources/tech/20211004 How I use Vagrant with libvirt.md @@ -0,0 +1,221 @@ +[#]: subject: "How I use Vagrant with libvirt" +[#]: via: "https://opensource.com/article/21/10/vagrant-libvirt" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +How I use Vagrant with libvirt +====== +When a virtual machine is what you need, Vagrant may be just the best +way to get it. +![Computer laptop in space][1] + +I'll admit it: I'm a fan of Linux. While I've used Slackware on workstations and Red Hat Enterprise Linux (RHEL) on servers for years, I love seeing how other distributions do things. What's more, I really like to test applications and scripts I write on other distributions to ensure portability. In fact, that's one of the great advantages of Linux, as I see it: You can download a distro and test your software on it for free. You can't do that with a closed OS, at least not without either breaking an EULA or paying to play, and even then, you're often signing up to download several gigabytes just to test an application that's no more than a few hundred megabytes. But Linux is open source, so there's rarely an excuse to ignore at least the three or four main distros, except that setting up a virtual machine can take a lot of clicks and sometimes complex virtual networking. At least, that used to be the excuse until Vagrant changed the virtual machine workflow for developers. + +### What is Vagrant + +Vagrant is a simple virtual machine manager for your terminal. It allows you to easily pull a minimal and pre-built virtual machine from the Internet, run it locally, and SSH into it in just a few steps. It's the quickest you'll ever set up a virtual machine. It's ideal for web developers needing a test web server, programmers who need to test an application across distributions, and hobbyists who enjoy seeing how different distributions work. + +Vagrant itself is relatively minimal, too. It's not a virtualization framework itself. It only manages your virtual machines ("boxes" in Vagrant terminology). It can use VirtualBox or, through a plug-in, the lightweight libvirt project as a backend. + +### What is libvirt + +The libvirt project is a toolkit designed to manage virtualization, with support for [KVM][2], [QEMU][3], [LXC][4], and more. You might think of it as a sort of virtual machine API, allowing developers to write friendly applications that make it easy for users to orchestrate virtualization through libvirt. I use libvirt as the backend for Vagrant because it's useful across several applications, including virt-manager and [GNOME Boxes][5]. + +### Installing Vagrant + +You can install Vagrant from [vagrantup.com/downloads][6]. There are builds available for Debian-based systems, CentOS-based systems, macOS, Windows, and more. + +For CentOS, Fedora, or similar, you get an RPM package, which you can install with `dnf`: + + +``` +`$ sudo dnf install ./vagrant_X.Y.ZZ_x86_64.rpm` +``` + +On Debian, Linux Mint, Elementary, and similar, you get a DEB package, which you can install with `apt`: + + +``` +`$ sudo apt install ./vagrant_X.Y.ZZ_x86_64.deb` +``` + +### Installing libvirt and support packages + +On Linux, your distribution may already have libvirt installed, but to enable integration with Vagrant you need a few other packages, too. Install these with your package manager. + +On Fedora, CentOS, and similar: + + +``` +$ sudo dnf install gcc libvirt \ +libvirt-devel libxml2-devel \ +make ruby-devel libguestfs-tools +``` + +On Debian, Linux Mint, and similar: + + +``` +$ sudo apt install build-dep vagrant ruby-libvirt \ +qemu libvirt-daemon-system libvirt-clients ebtables \ +dnsmasq-base libxslt-dev libxml2-dev libvirt-dev \ +zlib1g-dev ruby-dev libguestfs-tools +``` + +Depending on your distribution, you may have to start the `libvirt` daemon: + + +``` +`$ sudo systemctl start libvirtd` +``` + +### Installing the Vagrant-libvirt plugin + +In Vagrant, libvirt is enabled through a plug-in. Vagrant makes it easy to install a plug-in, so your first Vagrant command is one you'll rarely run again: + + +``` +`$ vagrant plugin install vagrant-libvirt` +``` + +Now that the libvirt plug-in is installed, you can start using virtual machines. + +### Setting up your Vagrant environment + +To start with Vagrant, create a directory called `~/Vagrant`. This is where your `Vagrantfiles` are stored. + + +``` +`$ mkdir ~/Vagrant` +``` + +In this directory, create a subdirectory to represent a distro you want to download. For instance, assume you need a CentOS test box. + +Create a CentOS directory, and then change to it: + + +``` +$ mkdir ~/Vagrant/centos +$ cd ~/Vagrant/centos +``` + +Now you need to find a virtual machine so you can convert the directory you've just made into a Vagrant environment. + +### Finding a Vagrant virtual machine + +Broadly speaking, Vagrant boxes come from three different places: Hashicorp (the maintainers of Vagrant), maintainers of distributions, and people like you and me. Some images are minimal, intended to serve as a base for customization. In contrast, others try to solve a specific need (for instance, you might find a LAMP stack image ready for web development). You can find images by browsing or searching the main hub for boxes [app.vagrantup.com/boxes/search][7]. + +For this example, search for "centos" and find the entry named `generic/centos8`. Click on the image for instructions on how to use the virtual machine. The instructions come in two varieties:  + + * The code you need for a Vagrantfile + * The command you need to use the box from a terminal + + + +The latter is the more straightforward method: + + +``` +`$ vagrant init generic/centos8` +``` + +The `init` subcommand creates a configuration file, called a Vagrantfile, in your current directory, which transforms that directory into a Vagrant environment. At any time, you can view a list of known Vagrant environments using the `global-status` subcommand: + + +``` +$ vagrant global-status +id       name    provider state   directory +\------------------------------------------- +49c797f  default libvirt running /home/tux/Vagrant/centos8 +``` + +### Starting a virtual machine with Vagrant + +Once you've run the `init` command, you can start your virtual machine with `vagrant up`: + + +``` +`$ vagrant up` +``` + +This causes Vagrant to download the virtual machine image if it doesn't already exist locally, set up a virtual network, and configure your box. + +### Entering a Vagrant virtual machine  + +Once your virtual machine is up and running, you can log in to it with `vagrant ssh`: + + +``` +$ vagrant ssh +box$ +``` + +You connect to the box running in your current Vagrant environment. Once logged in, you can run all the commands native to that host. It's a virtual machine running its own kernel, with emulated hardware and common Linux software. + +### Leaving a Vagrant virtual machine + +To leave your Vagrant virtual machine, log out of the host as you normally exit a Linux computer: + + +``` +`box$ exit` +``` + +Alternately, you can power the virtual machine down: + + +``` +`box$ sudo poweroff` +``` + +You can also stop the machine from running using the `vagrant` command: + + +``` +`box$ vagrant halt` +``` + +### Destroying a Vagrant virtual machine + +When finished with a Vagrant virtual machine, you can destroy it: + + +``` +`$ vagrant destroy` +``` + +Alternately, you can remove a virtual machine using the global `box` subcommand: + + +``` +`$ vagrant box remove generic/centos8` +``` + +### Vagrant is easy + +Vagrant makes virtual machines trivial, disposable, and fast. When you need a test environment or a fake server to ping or develop on, or a clean lab computer for experimentation or monitoring, you can get one with Vagrant. Some people think virtual machines aren't relevant now that containers have taken over servers, but virtual machines have unique traits that make them useful. They run their own kernel, have a full and unique stack separate from the host machine, and use emulated hardware. When a virtual machine is what you need, Vagrant may be just the best way to get it. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/10/vagrant-libvirt + +作者:[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/computer_space_graphic_cosmic.png?itok=wu493YbB (Computer laptop in space) +[2]: https://opensource.com/article/20/8/virt-tools#kvm +[3]: https://opensource.com/article/20/8/virt-tools#qemu +[4]: https://opensource.com/article/18/11/behind-scenes-linux-containers +[5]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization +[6]: https://www.vagrantup.com/downloads +[7]: https://app.vagrantup.com/boxes/search diff --git a/sources/tech/20211004 Launching a DevOps to DevSecOps transformation.md b/sources/tech/20211004 Launching a DevOps to DevSecOps transformation.md new file mode 100644 index 0000000000..250315de64 --- /dev/null +++ b/sources/tech/20211004 Launching a DevOps to DevSecOps transformation.md @@ -0,0 +1,64 @@ +[#]: subject: "Launching a DevOps to DevSecOps transformation" +[#]: via: "https://opensource.com/article/21/10/devops-to-devsecops" +[#]: author: "Will Kelly https://opensource.com/users/willkelly" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Launching a DevOps to DevSecOps transformation +====== +The move toward DevSecOps is accelerating—here's what you need to know. +![Tips and gears turning][1] + +Widespread adoption of DevSecOps is inevitable. Security and delivery velocity are unrealistic expectations as part of a [waterfall software development life cycle][2] (SDLC). Businesses and government agencies are under constant pressure to deliver new features and functionality to their customers, constituents, and employees. Recent high-profile software supply chain breaches and President Biden's [Executive Order][3] to improve the nation's cybersecurity also increases the urgency for businesses and governments to move to DevSecOps. + +All of that means, sooner or later, your enterprise will need to integrate security with its DevOps process. + +Historically, cybersecurity teams focused on app security only at the end of a long, laborious waterfall SDLC, after scanning and remediating security issues. This model has shown cracks with age. Customer and market demands for new features, security, and compliance are at the top of executives' minds. [Digital transformation][4] efforts aimed at adjusting to the new world of work during and after the pandemic have made software security a higher priority. A DevOps process that makes security an afterthought is out of step with software users and consumers. + +What's needed is a DevOps-to-DevSecOps transformation. Fortunately, cloud computing in the commercial and public sectors, combined with the influence of open source software (OSS), now gives development teams the tools, processes, and frameworks to deliver software at higher velocity while maintaining quality and security. + +DevSecOps brings your security and DevOps teams to work together during the development life cycle. To make that transition, you will need collaboration from your developers, cybersecurity experts, sysadmins, business stakeholders, and even your executives. + +### Assessing DevOps and DevSecOps + +DevOps combines cultural philosophies, best practices, and tools that allow your organization to deliver applications and services more rapidly. Shifting to daily and weekly releases enables you to reduce your quarterly or monthly releases. Using DevOps can also help you grow and improve your products more rapidly than traditional waterfall software development processes and siloed infrastructure management. + +While preserving the best qualities of DevOps, DevSecOps incorporates security in every stage of the cycle. It knocks down the silos standing between your development, security, and operations teams. Benefits of DevSecOps include: + + * Prevention of security incidents before they happen: By integrating DevSecOps within your CI/CD toolchain, you're helping your teams by detecting and resolving issues before they occur in production. + * Faster response to security issues: DevSecOps increases your security focus through continuous assessments while giving you actionable data to make informed decisions about the security posture of apps in development and ready to enter production. + * Accelerated feature velocity: DevSecOps teams have the data and tools to mitigate unforeseen risks better. + * Lower security budget: DevSecOps enables streamlined resources, solutions, and processes, allowing you to simplify your development lifecycle by design. + + + +We're at _peak Ops_ in many industries. Rest assured, the definitions of DevOps and DevSecOps will merge in the months and years to come, if only for the sake of enterprise sanity and management. + +### DevSecOps and OSS + +DevSecOps can also play a vital role in the integration of OSS into enterprise applications. OSS and DevSecOps are becoming increasingly intertwined, especially as enterprises seek to improve the security of their software supply chains. DevSecOps can serve as an OSS remediation tool because it permits scanning automation throughout each pipeline phase. OSS is also foundational for adopting and security software containers and Kubernetes. + +### Final thoughts + +Before your organization embarks on a DevOps to DevSecOps transformation, take a step back and define DevSecOps for your teams. Cut through the marketing. Talk about the results you hope your teams will achieve. Instill a culture of openness and collaboration, and be sure to listen to the positive and negative vantage points of your development, operations, and Quality Assurance (QA) teams. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/10/devops-to-devsecops + +作者:[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/gears_devops_learn_troubleshooting_lightbulb_tips_520.png?itok=HcN38NOk (Tips and gears turning) +[2]: https://en.wikipedia.org/wiki/Waterfall_model +[3]: https://www.whitehouse.gov/briefing-room/presidential-actions/2021/05/12/executive-order-on-improving-the-nations-cybersecurity/ +[4]: https://enterprisersproject.com/what-is-digital-transformation diff --git a/sources/tech/20211005 Get podman up and running on Windows using Linux.md b/sources/tech/20211005 Get podman up and running on Windows using Linux.md new file mode 100644 index 0000000000..ddbca0e519 --- /dev/null +++ b/sources/tech/20211005 Get podman up and running on Windows using Linux.md @@ -0,0 +1,146 @@ +[#]: subject: "Get podman up and running on Windows using Linux" +[#]: via: "https://opensource.com/article/21/10/podman-windows-wsl" +[#]: author: "Stephen Cuppett https://opensource.com/users/cuppett" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Get podman up and running on Windows using Linux +====== +Enable WSL 2 guests to run the podman, skopeo, or buildah commands from +within Windows using the Linux distribution of your choice. +![Penguin driving a car with a yellow background][1] + +WSL 2, the second iteration of the Windows Subsystem for Linux, allows you to run a Linux environment natively on Windows, without the overhead of a virtual machine (VM). It integrates nicely with Windows, too, and provides you access to most of the command-line tools, utilities, and applications you're used to on Linux. + +This guide shows you how to enable WSL 2 guests to run the `podman`, `skopeo`, or `buildah` commands from within Windows using the Linux distribution of your choice (available from the Microsoft store). Coming from a Fedora Linux host OS starting point, I was curious how to enable and use tools I'm most familiar with from within Windows. + +### Prerequisite: WSL 2 + +To install WSL 2, go to the [WSL installation][2] page. + +Use Powershell to ensure that WSL 2 is enabled by default: + +`PS> wsl –set-default-version 2` + +For information on key differences between WSL 1 and WSL 2, see the [WSL documentation][3]. + +The Windows Subsystem for Linux has come a long way. Microsoft has worked hard to make the separation between the host Windows OS and the guest Linux operating system virtually invisible. Special drivers in the kernels of each system make it easy to run commands between various shells and command windows and enable mutual filesystem access. + +You can confirm you are correctly using the WSL 2 kernel with the following command and output in any of the guests: + + +``` +$ uname -a +Linux BLD 5.10.16.3-microsoft.standard-WSL2 #1 SMP Fri Apr 2 22:23:49 +UTC 2021 x86_64 x86_64 GNU/Linux +``` + +WSL 1 guests report a kernel version as 4.14 or similar. + +Small touches in your guests can make the integration even more seamless, including symlinking of various home directory files (.aws, .sh, .config, and so on). There is a hint of how this can be achieved right from the $HOME directory: + +![$HOME directory][4] + +(Stephen Cuppett, [CC BY-SA 4.0][5]) + +### Install a Linux distribution + +To install a Linux distribution, find your favorite in the Microsoft Store. + +![screenshot of Fedora Remix purchase in the Microsoft store][6] + +(Stephen Cuppett, [CC BY-SA 4.0][5]) + +For this article, I'm using Fedora, but other distributions are available to try. Podman works well across distributions, so you can use whatever distribution you're most familiar with. There may be some minor configuration adjustments required, but those are generally documented by the distribution and podman documentation. I chose Fedora because it was the distribution that required no extra setup to get the latest podman working. + +On the first launch, the VM and related technologies are installed. You'll be prompted to select a password for the first user (which gets sudo access). + +### Install podman + +Once your Linux distribution has been installed and configured with a user, you can install podman as usual: + +`$ sudo dnf install podman` + +After a few moments, podman is installed and ready to go. You can check that everything is working as expected: + + +``` +$ podman info +host: +  arch: amd64 +  buildahVersion: 1.22.3 +  cgroupControllers: [] +  cgroupManager: cgroupfs +  cgroupVersion: v1 +[...] +version: +  APIVersion: 3.3.1 +  OsArch: linux/amd64 +  Version: 3.3.1 +``` + +From there, you can build images and use podman as you usually would. + +Thanks to WSL integration, podman is even accessible and usable from PowerShell or the command prompt: + +![screenshot example of Windows PowerShell][7] + +(Stephen Cuppett, [CC BY-SA 4.0][5]) + +Installing and using the `buildah` and `skopeo` commands is exactly the same process. + +### Busybox test + +As a simple test to see `podman` at work, you can pull and run a Busybox container. [BusyBox][8] is an open source (GPL) project providing simple implementations of nearly 400 common commands, including `ls, mv, ln, mkdir, more, ps, gzip, bzip2, tar`, and `grep`, which makes it a fittingly minimal environment for containers and for simple tests like this one. + +First, search the default image repository for a Busybox container. You can do this in either your Linux terminal or in Powershell. + + +``` +$ podman search busybox +INDEX       NAME                             DESCRIPTION                     +docker.io   docker.io/library/busybox        Busybox base image                   +docker.io   docker.io/radial/busyboxplus     Full-chain... +docker.io   docker.io/yauritux/busybox-curl  Busybox with CURL +``` + +Run the one you want to try: + + +``` +$ podman run -it docker.io/library/busybox +/ # +``` + +You can use the container, run a few commands to verify that everything works as expected, then leave it with the exit command. + +### Get started + +I'll admit I was surprised how readily the current Linux distributions out there, podman, and the Windows subsystem worked together here. It's obvious a lot of great work has gone into Windows' container tooling and integration with Linux. I'm hopeful this guide helps others get to this same launching point easily and start being productive. + +There are many good candidates for deep follow-up, including working with volumes, exposing networked services between the guest and the host, and exposing Linux capabilities in those containers. With so many tools available, I have great confidence that the community will make short work of digging through them! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/10/podman-windows-wsl + +作者:[Stephen Cuppett][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/cuppett +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/car-penguin-drive-linux-yellow.png?itok=twWGlYAc (Penguin driving a car with a yellow background) +[2]: https://docs.microsoft.com/en-us/windows/wsl/install +[3]: https://docs.microsoft.com/en-us/windows/wsl/about +[4]: https://opensource.com/sites/default/files/uploads/home_directory_0.png (directory) +[5]: https://creativecommons.org/licenses/by-sa/4.0/ +[6]: https://opensource.com/sites/default/files/uploads/fedora_remix_0.png (Fedora Remix) +[7]: https://opensource.com/sites/default/files/uploads/power_shell.png (Windows PowerShell) +[8]: https://opensource.com/article/21/8/what-busybox diff --git a/sources/tech/20211005 Markets- An Open-Source App to Keep Track of Your Investments for Linux Desktop and Phones.md b/sources/tech/20211005 Markets- An Open-Source App to Keep Track of Your Investments for Linux Desktop and Phones.md new file mode 100644 index 0000000000..ed5b98429f --- /dev/null +++ b/sources/tech/20211005 Markets- An Open-Source App to Keep Track of Your Investments for Linux Desktop and Phones.md @@ -0,0 +1,94 @@ +[#]: subject: "Markets: An Open-Source App to Keep Track of Your Investments for Linux Desktop and Phones" +[#]: via: "https://itsfoss.com/markets/" +[#]: author: "Ankush Das https://itsfoss.com/author/ankush/" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Markets: An Open-Source App to Keep Track of Your Investments for Linux Desktop and Phones +====== + +_**Brief:** A Linux app to help you quickly track market movements._ + +Usually, you would log in to a service on your web browser to monitor and track the market for investment opportunities if you’re an investor/trader. + +But, what if you want an app for your Linux desktop and Linux phone? Considering we do have a few for Android/iOS smartphones, it should come in handy for Linux devices as well! + +### Monitor Stocks From Across the Globe via Yahoo Finance + +![][1] + +“Markets” utilizes the data from Yahoo Finance to provide you the required information about stocks, cryptocurrencies, currencies, and more. + +While it is a simple desktop-focused app, it is available for Linux smartphones, and it offers a couple of valuable functionalities. Let me list the key highlights of what you can expect. + +![][2] + +### Features of Markets + +With Markets, you get to track, monitor, and analyze market trends and make investment decisions. + +There are a couple of features along the way that include: + + * Ability to customize the update interval + * Build a personal portfolio + * Add any symbol or currency + * View time in international format + * Dark mode + * Supports Linux phones (PinePhone, Librem5) + * Selectively delete stock monitors + + + +As mentioned previously, it is a dead-simple Linux application to help you track financial data. + +![][3] + +And, I’d say it works pretty well and lets you quickly search for a stock, commodity, and others to build a personal portfolio on your Linux desktop quickly. + +With a dark mode, it is a breeze to look at it and track market movements. + +You can select from the existing list of markets added and delete as per your selection. And, the international time format is useful. As you can notice in the screenshot, the time mentions the timezone you’re at by default, which should be useful. + +Also, from the listings, you can click on it to launch the browser window for full details on Yahoo Finance; this is how it’ll look like: + +![][4] + +### Installing Markets in Linux + +It is available as a Flatpak app for Linux distributions and can be found in [AUR][5] for Arch users. For Linux phones, they recommend installing it from the source. + +To install it from the terminal, you just need to type in: + +``` +flatpak install flathub com.bitstower.Markets +``` + +You can explorer building instructions and other information on their [GitHub page][6]. + +[Markets (Flathub)][7] + +Do you prefer to use an app on your Linux desktop to track financial data quickly? Let me know your thoughts in the comments. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/markets/ + +作者:[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/2021/10/markets.png?resize=741%2C626&ssl=1 +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/10/markets-search.png?resize=626%2C651&ssl=1 +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/markets-dark-mode.png?resize=559%2C475&ssl=1 +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/yahoo-tesla.png?resize=800%2C451&ssl=1 +[5]: https://itsfoss.com/aur-arch-linux/ +[6]: https://github.com/bitstower/markets +[7]: https://flathub.org/apps/details/com.bitstower.Markets diff --git a/sources/tech/20211006 Following a DevSecOps maturity model.md b/sources/tech/20211006 Following a DevSecOps maturity model.md new file mode 100644 index 0000000000..ed092f3416 --- /dev/null +++ b/sources/tech/20211006 Following a DevSecOps maturity model.md @@ -0,0 +1,66 @@ +[#]: subject: "Following a DevSecOps maturity model" +[#]: via: "https://opensource.com/article/21/10/devsecops-maturity-model" +[#]: author: "Will Kelly https://opensource.com/users/willkelly" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Following a DevSecOps maturity model +====== +Following a maturity model also helps tell a story that includes the +people, process, and technology changes that come with a +DevOps-to-DevSecOps transformation. +![Sunlight coming through the tree branches][1] + +[DevSecOps][2] is in many ways another level of DevOps maturity for an enterprise. Executive management and other stakeholders understand the concept of a maturity model, making it a helpful way to explain the value of this shift. Following a maturity model also helps you tell a story that includes the people, process, and technology changes that come with a DevOps-to-DevSecOps transformation. + +Here are four typical levels of DevSecOps maturity: + +### Level 1: pre-DevOps (no automation) + +At this level, developers perform every task manually, including creating and testing applications and systems. Team management, processes, and application security are still at a very ad hoc level. + +Take the extra step to capture your lessons learned and the challenges of your pre-DevOps development era. You need to know your history, so you don't repeat it in the future. + +### Level 2: early DevOps/DevSecOps (lightweight automation) + +Development teams standardize on some form of a DevOps toolchain to implement Infrastructure-as-Code and Compliance-as-Code. DevSecOps adoption is at the department or even just at the team level. + +Mentioning DevOps and DevSecOps interchangeably in this phase is deliberate. Some organizations will fast-forward from traditional waterfall development straight to a DevSecOps model. At level 2, DevOps/DevSecOps and lightweight automation is the domain of innovative and more forward-thinking development teams. Developers are driven to find a better way to do things, either as a result of their own initiative or because a customer is asking for a DevOps approach. + +Making it from level 2 to level 3 depends upon communicating and selling the successes of your early adopters of DevSecOps to the rest of your organization. Be sure to keep in touch with your early adopters and encourage them to share their DevOps and DevSecOps wins with the rest of their peers. Early win stories resonate much better than managerial mandates. + +### Level 3: DevOps to DevSecOps transition (advanced automation) + +DevSecOps grows into a corporate or agency-wide strategy. With organization-wide support, an automation strategy for application and infrastructure development and management takes form. DevOps teams can now improve their existing processes using containers, Kubernetes (K8s), and public cloud services. + +Bottom line: Organizations at this advanced phase of DevSecOps maturity are deploying applications at scale. + +### Level 4: full DevSecOps (full automation) + +Such an expert state of DevSecOps maturity will be elusive for all but the most prominent and well-funded enterprises, those who must routinely meet the most strict cybersecurity and compliance demands. An organization that reaches this level of maturity is API and cloud-native first. These organizations are also implementing emerging technologies such as [microservices][3], [serverless][4], and [artificial intelligence/machine learning (AI/ML)][5] to strengthen their application development and infrastructure security. + +### Final thoughts + +Only when you track the maturity of your processes, team culture, and tooling do you get the best current and future-state views of your organization's progress to DevSecOps. The pandemic pushed many teams to remote work in the past 18 months. As a result, teams had to mature their processes and mature them quickly to ensure their organization could still deliver to their customers. DevSecOps brings together the very cultural, collaboration, and toolchain improvements that development teams require to deliver secure and compliant software in their new world of work. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/10/devsecops-maturity-model + +作者:[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/jan-huber-tree.jpg?itok=CRBwhuMA (Sunlight coming through the tree branches) +[2]: https://www.redhat.com/en/topics/devops/what-is-devsecops +[3]: https://opensource.com/resources/what-are-microservices +[4]: https://opensource.com/article/21/1/devapps-strategies +[5]: https://opensource.com/tags/ai-and-machine-learning diff --git a/sources/tech/20211007 3 phases to start a DevSecOps transformation.md b/sources/tech/20211007 3 phases to start a DevSecOps transformation.md new file mode 100644 index 0000000000..3c671d4a86 --- /dev/null +++ b/sources/tech/20211007 3 phases to start a DevSecOps transformation.md @@ -0,0 +1,115 @@ +[#]: subject: "3 phases to start a DevSecOps transformation" +[#]: via: "https://opensource.com/article/21/10/first-phases-devsecops-transformation" +[#]: author: "Will Kelly https://opensource.com/users/willkelly" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +3 phases to start a DevSecOps transformation +====== +Taking the right steps at the right time smooths the path toward full +adoption. +![Green graph of measurements][1] + +DevSecOps is another step in the DevOps journey for your organization. Breaking down your transformation into phases facilitates working directly with developers and other team members. A phased approach also allows you to get feedback from those affected by the change and iterate as necessary. + +Here are the first three phases of a DevSecOps transformation: + +### Phase 1: analysis, education, and training + +In phase 1, you do the preliminary work necessary to make DevSecOps the next step in your DevOps journey. + +This phase is even more critical for your teams if you're moving from a waterfall software development lifecycle (SDLC) model. Making that leap may require you to put more time and effort into DevOps training to bridge any knowledge gaps between your current processes and DevSecOps. + +#### Analyze your development process maturity + +Whether DevSecOps is just the next step in your DevSecOps journey or you're making your initial foray into DevSecOps straight from a waterfall SDLC, analyzing the [maturity of your software development process][2] is a critical step. An effective analysis includes: + + * Documenting the current state of any processes + * Gathering any reporting data about your current development processes + * Identifying what's working and not working in your development processes by interviewing key developers + + + +#### Define DevSecOps for your organization + +DevOps and now DevSecOps can mean many things to people. Software vendor marketing and the open source software (OSS) community each put their spin on the definition of DevSecOps. Spare your teams from any misunderstandings and document your definition of DevSecOps. A clear definition includes: + + * What DevSecOps means to your organization + * The expected outcomes after moving to DevSecOps + * The tools and processes your organization is putting into place to ensure employee success + + + +Writing a definition is not merely creating a project charter for your DevOps to DevSecOps transformation; it identifies your true north. + +#### Foster a DevSecOps culture + +You can't _buy_ DevSecOps. Your managers and key technology team members need to work together to foster DevSecOps cultural philosophies to set a foundation for your DevOps to DevSecOps transformation. + +Here are some vital elements of DevSecOps culture that are important to foster during and after your transformation: + +##### Continuous feedback + +Remote DevSecOps teams have their advantages and disadvantages with continuous feedback. The manager's role is not simply to deliver feedback on the DevSecOps team's performance. Instead, the purpose of feedback is to enable teams to collaborate more effectively. [Open source chat tools][3] provide the instant communication necessary for DevSecOps teams to collaborate in real time. + +##### Container-based architectures + +DevSecOps sets the stage for moving to container-based architectures that can be another cultural change for DevOps teams. A proper and robust implementation of containers changes developer and operations cultures because it changes how architects design solutions, programmers create code, and operations teams maintain production applications. + +##### Team autonomy + +DevSecOps is no place for micromanagers at any level of your organization. A standard part of DevSecOps culture is enabling your teams to choose their tools and create processes based on their work. DevSecOps also promotes distributed decision making that supports greater agility and innovation. + +##### DevSecOps training + +Providing security training to your developers is another step towards making security part of everyone's job. Training could take the form of in-house developer training in casual formats such as lunch-and-learns, or it could include more formal training classes conducted by your organization's training department. + +Depending on your security ambitions (and budget), there is always the option to send your DevOps team members to get a DevSecOps vendor certification, such as the DevSecOps Foundation certification from the [DevOps Institute][4] or the Certified DevSecOps Professional (CDP) from [Practical DevSecOps][5]. + +### Phase 2: integrate security into your DevOps lifecycle + +During phase 2 of your DevOps to DevSecOps transformation, you integrate security processes and tools into your DevOps life cycle. If your enterprise is already using DevOps toolchains, this phase integrates security tools into your existing DevOps toolchains. This phase is also the time to perform a security audit on your continuous integration and continuous delivery/deployment (CI/CD) toolchains to ensure security. + +Suppose your organization takes the fast track to DevSecOps from a waterfall SDLC or other legacy development process. In that case, security needs to become a requirement of your CI/CD toolchain build. + +### Phase 3: introduce automation into your DevOps lifecycle + +The automation phase includes analysis, outreach, and experimentation. Applying automation to everyday software development tasks such as quality assurance and security checks isn't an exact science. Expect a push and pull between your executives and development teams. Executives often want to automate as much as possible, even to the extreme. Developers and sysadmins are going to approach automation more cautiously. + +Automation is foundational to DevSecOps because it removes the prospect of human error from some everyday build tasks and security checks. If you're building and running cloud workloads, you need automation. + +How well the automation tools are implemented determines how effectively you can enforce security practices and facilitate security sign-offs. + +Here are some tips for introducing automation into your DevOps toolchain: + + * Dispel the notion in your management and stakeholders that you'll be able to automate every task along with your toolchain. Engage with your stakeholders to learn their automation priorities and take that feedback into an automation strategy for your DevOps teams. + * Engage with your development teams — not just the team leads and managers — about how automation can help them perform their jobs. Listen to their concerns with empathy and answer their questions with definitive answers. + * Create an automation roadmap that charts how you'll introduce automation into your toolchains. Start small and expand with automation across your toolchains. Seek a small project such as a patch or a feature update to test your implementation plan. + * Automate one build, quality assurance, or security check for one of your DevOps teams as a proof-of-concept project. Document your findings from this small project, especially the lessons learned and any other feedback from the DevOps team members working on the project. + * Communicate the successes, lessons learned, and, yes, even the mistakes made on the pilot project to your stakeholders and internal DevOps community. + + + +You can use your existing DevOps center of excellence or DevSecOps center of excellence as an opportunity to gather input from employees from across your organization about how automation affects their work. Otherwise, look for formal and informal channels in your development and operations organizations to gain the input. For example, informal lunch and learns, group chat channels, or team meetings can be ideal for gathering input depending on your corporate culture. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/10/first-phases-devsecops-transformation + +作者:[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/metrics_lead-steps-measure.png?itok=DG7rFZPk (Green graph of measurements) +[2]: https://opensource.com/article/21/10/devsecops-maturity-model +[3]: https://opensource.com/article/20/4/open-source-chat +[4]: https://www.devopsinstitute.com/ +[5]: http://practical-devsecops.com/ diff --git a/sources/tech/20211007 Rotate and archive logs with the Linux logrotate command.md b/sources/tech/20211007 Rotate and archive logs with the Linux logrotate command.md new file mode 100644 index 0000000000..007e41cd22 --- /dev/null +++ b/sources/tech/20211007 Rotate and archive logs with the Linux logrotate command.md @@ -0,0 +1,228 @@ +[#]: subject: "Rotate and archive logs with the Linux logrotate command" +[#]: via: "https://opensource.com/article/21/10/linux-logrotate" +[#]: author: "Ayush Sharma https://opensource.com/users/ayushsharma" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Rotate and archive logs with the Linux logrotate command +====== +Keep log files fresh with this Linux command. Download the new logrotate +cheat sheet. +![Logs stacked up and to the right in front of a green tree forest][1] + +Logs are great for finding out what an application is doing or troubleshooting a possible problem. Almost every application we deal with generates logs, and we want the applications we develop ourselves to generate them too. The more verbose the logs, the more information we have. But left to themselves, logs can grow to an unmanageable size, and they can, in turn, become a problem of their own. So it's a good idea to keep them trimmed down, keep the ones we're going to need, and archive the rest. + +### Basics + +The `logrotate` utility is excellent at managing logs. It can rotate them, compress them, email them, delete them, archive them, and start fresh ones when you need them. + +Running `logrotate` is pretty simple—just run `logrotate -vs state-file config-file`. In the above command, the `v` option enables verbose mode, `s` specifies a state file, and the final `config-file` mentions the configuration file, where you specify what you need done. + +### Hands-on + +Let's check out a `logrotate` configuration that is running silently on our system, managing the wealth of logs we find in the `/var/log` directory. Check out the current files in that directory. Do you see a lot of `*.[number].gz` files? That’s what `logrotate` is doing. You can find the configuration file for this under `/etc/logrotate.d/rsyslog`. Mine looks like this: + + +``` +/var/log/syslog +{ +        rotate 7 +        daily +        missingok +        notifempty +        delaycompress +        compress +        postrotate +                reload rsyslog >/dev/null 2>&1 || true +        endscript +} + +/var/log/mail.info +/var/log/mail.warn +/var/log/mail.err +/var/log/mail.log +/var/log/daemon.log +/var/log/kern.log +/var/log/auth.log +/var/log/user.log +/var/log/lpr.log +/var/log/cron.log +/var/log/debug +/var/log/messages + +{ +        rotate 4 +        weekly +        missingok +        notifempty +        compress +        delaycompress +        sharedscripts +        postrotate +                reload rsyslog >/dev/null 2>&1 || true +        endscript +} +``` + +The file starts with defining the instructions for rotating the `/var/log/syslog` file and the instructions are contained within the curly braces that follow. Here’s what they mean: + + * `rotate 7`: Keep logs from the last seven rotations. Then start deleting them. + * `daily`: Rotate the log daily. Along with `rotate 7`, this would mean that logs would be kept for the last seven days. Other options are `weekly`, `monthly`, `yearly`. There is also a `size` parameter that will rotate log files if their size increases beyond a specified limit—for example, `size 10k`, `size 10M`, `size 10G`, etc. If nothing is specified, logs will be rotated whenever `logrotate` runs. You can even run `logrotate` in a `cron` to use it at more specific time intervals. + * `missingok`: It’s okay if the log file is missing. Don’t Panic. + * `notifempty`: Don’t rotate if the log file is empty. + * `delaycompress`: If compression is on, delay compression until the next rotation. This allows at least one rotated but uncompressed file to be present. Useful if you want yesterday’s logs to stay uncompressed for troubleshooting. It is also helpful if some program might still write to the old file until it is restarted/reloaded, like Apache. + * `compress`: Compression is on. Use `nocompress` to turn it off. + * `postrotate/endscript`: Run the script within this section after rotation. Helpful in doing cleanup stuff. There is also a `prerotate/endscript` for doing things before rotation begins. + + + +Can you figure out what the next section does for all those files mentioned in the configuration above? The only additional parameter in the second section is `sharedscripts`, which tells `logrotate` to not run the section within `postrotate/endscript` until all log rotation is complete. It prevents the script from being executed for every log rotated and runs once at the end. + +### Something New + +I’m using the following configuration for dealing with Nginx access and error logs on my system. + + +``` +/var/log/nginx/access.log +/var/log/nginx/error.log  { +        size 1 +        missingok +        notifempty +        create 544 www-data adm +        rotate 30 +        compress +        delaycompress +        dateext +        dateformat -%Y-%m-%d-%s +        sharedscripts +        extension .log +        postrotate +                service nginx reload +        endscript +} +``` + +The above script can be run using: + + +``` +logrotate -vs state-file /tmp/logrotate +``` + +Running the command for the first time gives this output: + + +``` +reading config file /tmp/logrotate +extension is now .log + +Handling 1 logs + +rotating pattern: /var/log/nginx/access.log +/var/log/nginx/error.log   1 bytes (30 rotations) +empty log files are not rotated, old logs are removed +considering log /var/log/nginx/access.log +  log needs rotating +considering log /var/log/nginx/error.log +  log does not need rotating +rotating log /var/log/nginx/access.log, log->rotateCount is 30 +Converted ' -%Y-%m-%d-%s' -> '-%Y-%m-%d-%s' +dateext suffix '-2021-08-27-1485508250' +glob pattern '-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' +glob finding logs to compress failed +glob finding old rotated logs failed +renaming /var/log/nginx/access.log to /var/log/nginx/access-2021-08-27-1485508250.log +creating new /var/log/nginx/access.log mode = 0544 uid = 33 gid = 4 +running postrotate script +* Reloading nginx configuration nginx +``` + +And running it a second time: + + +``` +reading config file /tmp/logrotate +extension is now .log + +Handling 1 logs + +rotating pattern: /var/log/nginx/access.log +/var/log/nginx/error.log   1 bytes (30 rotations) +empty log files are not rotated, old logs are removed +considering log /var/log/nginx/access.log +  log needs rotating +considering log /var/log/nginx/error.log +  log does not need rotating +rotating log /var/log/nginx/access.log, log->rotateCount is 30 +Converted ' -%Y-%m-%d-%s' -> '-%Y-%m-%d-%s' +dateext suffix '-2021-08-27-1485508280' +glob pattern '-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' +compressing log with: /bin/gzip +renaming /var/log/nginx/access.log to /var/log/nginx/access-2021-08-27-1485508280.log +creating new /var/log/nginx/access.log mode = 0544 uid = 33 gid = 4 +running postrotate script +* Reloading nginx configuration nginx +``` + +And running it a third time: + + +``` +reading config file /tmp/logrotate +extension is now .log + +Handling 1 logs + +rotating pattern: /var/log/nginx/access.log +/var/log/nginx/error.log   1 bytes (30 rotations) +empty log files are not rotated, old logs are removed +considering log /var/log/nginx/access.log +  log needs rotating +considering log /var/log/nginx/error.log +  log does not need rotating +rotating log /var/log/nginx/access.log, log->rotateCount is 30 +Converted ' -%Y-%m-%d-%s' -> '-%Y-%m-%d-%s' +dateext suffix '-2021-08-27-1485508316' +glob pattern '-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' +compressing log with: /bin/gzip +renaming /var/log/nginx/access.log to /var/log/nginx/access-2021-08-27-1485508316.log +creating new /var/log/nginx/access.log mode = 0544 uid = 33 gid = 4 +running postrotate script +* Reloading nginx configuration nginx +``` + +The contents of the state file look like this: + + +``` +logrotate state -- version 2 +"/var/log/nginx/error.log" 2021-08-27-9:0:0 +"/var/log/nginx/access.log" 2021-08-27-9:11:56 +``` + +[**Download the Linux logrotate cheat sheet.**][2] + +* * * + +_This article was originally published on the [author's personal blog][3] and has been adapted with permission._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/10/linux-logrotate + +作者:[Ayush Sharma][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ayushsharma +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/oliver-paaske-unsplash.jpg?itok=bv0sZSSB (Logs stacked up and to the right in front of a green tree forest) +[2]: https://opensource.com/downloads/logrotate-cheat-sheet +[3]: https://notes.ayushsharma.in/2017/01/fiddling-with-logrotate diff --git a/sources/tech/20211008 3 more phases of DevSecOps transformation.md b/sources/tech/20211008 3 more phases of DevSecOps transformation.md new file mode 100644 index 0000000000..9f4d5eeb0e --- /dev/null +++ b/sources/tech/20211008 3 more phases of DevSecOps transformation.md @@ -0,0 +1,65 @@ +[#]: subject: "3 more phases of DevSecOps transformation" +[#]: via: "https://opensource.com/article/21/10/last-phases-devsecops-transformation" +[#]: author: "Will Kelly https://opensource.com/users/willkelly" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +3 more phases of DevSecOps transformation +====== +Ensure you reach your goals by continuing a step-by-step approach to +DevSecOps. +![Gold trophy on green background][1] + +Making a major operations transition must be a long-term and well-planned process. Because DevSecOps is an important step in the DevOps journey for your organization, you are more likely to find success if you introduce and implement your transformation in phases. + +In my [previous article][2], I explained the first three phases of making this change. This article presents three additional phases of DevSecOps transformation you must work through to achieve your goals. Finishing these phases requires that you foster team collaboration to carry your organization through security changes, going live with DevSecOps, and putting the tools in place for continuous learning and iteration of your DevSecOps toolchain and processes. + +### Phase 4: collaborate on security changes to your DevOps toolchains + +Some security changes on the move to DevSecOps may adversely affect operations and even security compliance. Changes to tools, processes, and even staffing sometimes change the way teams work. + +Your development, operations, and security teams must collaborate before deployment and at other touchpoints to set priorities. Security teams sometimes prioritize a security measure that adversely impacts operations. Likewise, your developers probably overlook some holes caused by system configurations that could compromise the security and compliance of your systems. + +Predeployment reviews provide a prime collaboration channel. When you conduct predeployment reviews during your DevOps to DevSecOps transformation, you give your developers and security staff a forum through which they can educate each other on their team's priorities and informed tradeoffs. + +### Phase 5: execute on DevSecOps + +As your organization crosses into phase 5 of your DevOps to DevSecOps transformation, it's time to execute your plans with one or more teams. Don't move to Phase 5 as an entire organization. Instead, look for natural breaks in your project teams' schedules for them to move to a DevSecOps model. For example, say that one of your DevOps teams has just launched a new product release. After catching their collective breath, they're working on bug fixes that come in from the field. Don't interrupt their flow with a full-on move to DevSecOps during an in-progress project. + +Look for new project opportunities to begin executing on DevSecOps. Such an approach offers the following advantages: + + * Providing teams a clean slate to learn a new process from the beginning, not midstream during a project + * Enabling you to include process and tools training as part of the project kickoff process + * Affording the chance to bring your developers, operations, and security teams together to discuss mutual expectations for the project + * Giving teams a chance to learn to work together better during the new workflows that DevSecOps brings to an organization + + + +### Phase 6: pursue continuous learning and iteration + +There is no formal end to an adequately executed shift from DevOps to DevSecOps. After your organization moves to DevSecOps and adopts the principles and foundations, the learning and iteration need to continue past the transformation. + +As there is no single accepted DevSecOps definition for the industry, you can expect to learn a lot as your DevSecOps journey gains momentum and your processes mature. You also need to prepare your organization for changes in DevOps and DevSecOps philosophies that might benefit your internal efforts. + +### Final thoughts + +The phases I outline in this series are general guidelines for a path toward achieving your DevSecOps transformation. The emphasis on collaboration is deliberate because your enterprise's particular circumstances could require that you modify these phases to achieve your transformation. Even if you need to make substantial changes to these phases, having a graduated implementation roadmap will get you much closer to success. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/10/last-phases-devsecops-transformation + +作者:[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/trophy_celebrate.png?itok=jGnRHBq2 (Gold trophy on green background) +[2]: https://opensource.com/article/21/10/first-phases-devsecops-transformation diff --git a/sources/tech/20211011 What is a hostname.md b/sources/tech/20211011 What is a hostname.md new file mode 100644 index 0000000000..e4954843e0 --- /dev/null +++ b/sources/tech/20211011 What is a hostname.md @@ -0,0 +1,117 @@ +[#]: subject: "What is a hostname?" +[#]: via: "https://opensource.com/article/21/10/what-hostname" +[#]: author: "Alan Formy-Duval https://opensource.com/users/alanfdoss" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +What is a hostname? +====== +Hostnames are labels for humans to refer to a specific computer. +![Computer screen with files or windows open][1] + +Computers have network addresses, but they're usually difficult for humans to remember. Hostnames are labels intended to help humans refer to a specific computer. Instead of navigating to 192..168.1.4, for instance, you might navigate to  `linuxlaptop `or `linuxlaptop.local`. + +### Addresses and Names + +All networked computers (also referred to as hosts) need an address—a unique number associated with it that allows for datagrams to route among them for correct data communications. This is known as the Internet Protocol (IP) address. The number 54.204.39.132 is an Internet Protocol version 4 (IPv4) address. The newer IPv6 addresses are much longer, like this: 2001:0db6:3c4d:0017:0000:0000:2a2f:1a2b. WHOA! That is going to be hard to memorize! + + +``` +`$ ip addr show` +``` + +Computers can also be given labels. Known as the hostname, these are friendly names for easier reference. I could set my computer's hostname to be _copperhead_. As long as that name is unique on the network, all other users and computers can refer to it as copperhead instead of the IP address number. + + +``` +`$ hostname -s` +``` + +You can update your computer's hostname. + +Read Seth Kenlon's article [How to change a hostname on Linux][2] to learn how to do that on Linux. + +#### Fully qualified domain name + +Technically, the hostname includes a domain name. If my domain name is mycompany.com, then together—delimited by periods, my computer's hostname is copperhead.mycompany.com. This forms a fully qualified domain name (FQDN). This is important because the IP address resolves to the FQDN. + + +``` +`host.domain.topleveldomain` +``` + +For example: `www.example.com` is a fully qualified domain name. + +Your domain name is generally determined already, so you're only responsible for providing the host portion. This article focuses on the host.  + +#### Name resolution + +The process of translating the IP address to the corresponding hostname is known as name resolution. The first place that this occurs is in a local hosts table. Linux uses the file `/etc/hosts` to store this table. + + +``` +`cat /etc/hosts` +``` + +There is also a hierarchical and decentralized network-based system that provides resolution called the Domain Name System (DNS). This is when the FQDN becomes really important. + + +``` +`$ dig www.opensource.com` +``` + +### Fun with names + +It can be fun to think up names for our computers. If you have many, you could use a theme. I once worked for a company that named all of its servers after snakes. + +A later company I worked for, where I was a data center manager, used beer brands. It was exciting when we received a new server because I would email the development team for suggestions. We had roughly 100 servers. These provided an interesting list that reflected the diversity of the company. We had everything from coors and bud to amstel and deleriumtremens. We had tiger and singha and sapporo and many others too! + +We thought it was cool! Then again, imagine what happens when you try to remember that lowenbrau is the virtualization server with the most RAM and peroni is the SQL database server and heineken is the new domain controller, particularly for new employees in a rapidly growing company. + +### Conventions + +Hostnames are the choice of the owner, of course, so have fun with it. However, depending on the environment, it might make more sense to use names that are easy to remember or based on a naming convention that lends to being descriptive to the host.  + +#### Useful names + +If you want to forego the fun and helpfully name your systems, perhaps consider their function. Database servers might be named database1, database2, database3, and so on. Web servers might be webserver1, webserver2, and so on. + +#### Positional names + +I have used a technique with many clients to name server hosts with sets of characters in positions that describe an aspect of that system that helps identification. For example, if I were working on a Business Process Management (BPM) system for the Department of the Interior (DOI), I would incorporate their acronyms in the naming convention. + +Furthermore, just as with many large corporations, financial institutions, and governments, they might have various data centers located in disparate geographical locations for purposes of performance or disaster recovery. So, say, a data center on the East coast of the North American continent is referred to as ED, and those on the West coast are WD. East Data center and West Data center. + +All of this information would come together in a name such as doibpm1ed or doibpm1wd. So, while these names don't look like much, someone working on this project would readily be able to identify each as to their purpose and location, and the name may even help to obfuscate their usage to would-be mal-actors. In other words, the owner could choose naming that would only make sense to insiders.  + +### Internet standards + +Several standards govern hostnames. You can find these in Requests for Comment (RFC) maintained by The Internet Engineering Task Force (IETF). As of now, adhere to the following: + + *  A hostname should be between 1 and 63 ASCII characters in length + *  A FQDN has a maximum length of 253 ASCII characters + *  Case-insensitive + *  Allowed characters: a to z, 0 to 9, - (hyphen), and _ (underscore) + + + +I hope this article helps to clarify hostnames. Have some fun and be creative. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/10/what-hostname + +作者:[Alan Formy-Duval][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/alanfdoss +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_screen_windows_files.png?itok=kLTeQUbY (Computer screen with files or windows open) +[2]: https://opensource.com/article/21/10/how-change-hostname-linux diff --git a/sources/tech/20211012 Create a timer on Linux.md b/sources/tech/20211012 Create a timer on Linux.md new file mode 100644 index 0000000000..2cbfa013aa --- /dev/null +++ b/sources/tech/20211012 Create a timer on Linux.md @@ -0,0 +1,277 @@ +[#]: subject: "Create a timer on Linux" +[#]: via: "https://opensource.com/article/21/10/linux-timers" +[#]: author: "Stephan Avenwedde https://opensource.com/users/hansic99" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Create a timer on Linux +====== +A tutorial showing how to create a POSIX-compliant interval timer. +![Team checklist][1] + +The timing of certain events is a common task for a developer. Common scenarios for timers are watchdogs, cyclic execution of tasks, or scheduling events for a specific time. In this article, I show how to create a POSIX-compliant interval timer using [timer_create(...)][2]. + +You can download the source code for the following examples from [GitHub][3]. + +### Prepare Qt Creator + +I used [Qt Creator][4] as the IDE for this example. To run and debug the example code in Qt Creator, clone the [GitHub][3] repository, open Qt Creator, and go to **File -> Open File or Project...** and choose the **CMakeLists.txt**: + +![Qt Creator open project][5] + +Open a project in Qt Creator (CC-BY-SA 4.0) + +After selecting the toolchain, click on **Configure Project**. The project contains three independent examples (we will only cover two of them in this article). With the green-marked menu, switch between the configurations for each example and activate **Run in terminal** for each of them (see the yellow mark below). The currently active example for building and debugging can be selected over the **Debug** button on the bottom left corner (see the orange mark below): + +![Project configuration][6] + +Project configuration (CC-BY-SA 4.0) + +### Threading timer + +Let's take a look at the _simple_threading_timer.c_ example. This is the simplest one: It shows how an interval timer is created, which calls the function **expired** on expiration. On each expiration, a new thread is created in which the function **expiration** is called. + + +``` +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include <signal.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> + +void expired(union sigval timer_data); + +pid_t gettid(void); + +struct t_eventData{ +    int myData; +}; + +int main() +{ +    int res = 0; +    timer_t timerId = 0; + +    struct t_eventData eventData = { .myData = 0 }; + +    /*  sigevent specifies behaviour on expiration  */ +    struct sigevent sev = { 0 }; + +    /* specify start delay and interval +     * it_value and it_interval must not be zero */ + +    struct itimerspec its = {   .it_value.tv_sec  = 1, +                                .it_value.tv_nsec = 0, +                                .it_interval.tv_sec  = 1, +                                .it_interval.tv_nsec = 0 +                            }; + +    [printf][7]("Simple Threading Timer - thread-id: %d\n", gettid()); + +    sev.sigev_notify = SIGEV_THREAD; +    sev.sigev_notify_function = &expired; +    sev.sigev_value.sival_ptr = &eventData; + +    /* create timer */ +    res = timer_create(CLOCK_REALTIME, &sev, &timerId); + +    if (res != 0){ +        [fprintf][8](stderr, "Error timer_create: %s\n", [strerror][9](errno)); +        [exit][10](-1); +    } + +    /* start timer */ +    res = timer_settime(timerId, 0, &its, NULL); + +    if (res != 0){ +        [fprintf][8](stderr, "Error timer_settime: %s\n", [strerror][9](errno)); +        [exit][10](-1); +    } + +    [printf][7]("Press ETNER Key to Exit\n"); +    while([getchar][11]()!='\n'){} +    return 0; +} + +void expired(union sigval timer_data){ +    struct t_eventData *data = timer_data.sival_ptr; +    [printf][7]("Timer fired %d - thread-id: %d\n", ++data->myData, gettid()); +} +``` + +The advantage of this approach is its small footprint, in terms of code and simple debugging. The disadvantage is the additional overhead due to the creation of a new thread on expiration and, consequently, the less deterministic behavior. + +### Interrupt Signal Timer + +Another possibility to be notified by an expired timer is based on a [kernel signal][12]. Instead of creating a new thread each time the timer expires, the kernel sends a signal to the process, the process is interrupted, and the corresponding signal handler is called. + +As the default action when receiving a signal is to terminate the process (see [signal][13] man page), we have to prepare Qt Creator in advance so that properly debugging is possible. + +The default behavior of Qt Creator when the debuggee receives a signal is: + + * Interrupt execution and switch to the debugger context. + * Display a pop-up window that notifies the user about the reception of a signal. + + + +Both actions are not wanted as the reception of a signal is part of our application. + +Qt Creator uses GDB in the background. In order to prevent GDB from stopping the execution when the process receives a signal, go to **Tools** -> **Options**, select **Debugger**, and navigate to **Locals & Expressions**. Add the following expression to _Debugging Helper Customization_: + + +``` +`handle SIG34 nostop pass` +``` + +![Signal no stop with error][14] + +Sig 34 no stop with error (CC-BY-SA 4.0) + +You can find more information about GDB signal handling in the [GDB documentation][15]. + +Next, we want to suppress the pop-up window that notifies us every time a signal is received when we stop in the signal handler: + +![Signal 34 pop up box][16] + +Signal 34 pop-up box (CC-BY-SA 4.0) + +To do so, navigate to the tab **GDB** and uncheck the marked checkbox: + +![Timer signal windows][17] + +Timer signal windows (CC-BY-SA 4.0) + +Now you can properly debug the _signal_interrupt_timer_. The actual implementation of the signal timer is a bit more complex: + + +``` +#include <stdio.h> +#include <stdlib.h> +#include <signal.h> +#include <unistd.h> +#include <signal.h> +#include <time.h> +#include <unistd.h> +#include <errno.h> +#include <string.h> + +#define UNUSED(x) (void)(x) + +static void handler(int sig, siginfo_t *si, void *uc); +pid_t gettid(void); + +struct t_eventData{ +    int myData; +}; + +int main() +{ +    int res = 0; +    timer_t timerId = 0; + +    struct sigevent sev = { 0 }; +    struct t_eventData eventData = { .myData = 0 }; + +    /* specifies the action when receiving a signal */ +    struct sigaction sa = { 0 }; + +    /* specify start delay and interval */ +    struct itimerspec its = {   .it_value.tv_sec  = 1, +                                .it_value.tv_nsec = 0, +                                .it_interval.tv_sec  = 1, +                                .it_interval.tv_nsec = 0 +                            }; + +    [printf][7]("Signal Interrupt Timer - thread-id: %d\n", gettid()); + +    sev.sigev_notify = SIGEV_SIGNAL; // Linux-specific +    sev.sigev_signo = SIGRTMIN; +    sev.sigev_value.sival_ptr = &eventData; + +    /* create timer */ +    res = timer_create(CLOCK_REALTIME, &sev, &timerId); + +    if ( res != 0){ +        [fprintf][8](stderr, "Error timer_create: %s\n", [strerror][9](errno)); +        [exit][10](-1); +    } + +    /* specifz signal and handler */ +    sa.sa_flags = SA_SIGINFO; +    sa.sa_sigaction = handler; + +    /* Initialize signal */ +    sigemptyset(&sa.sa_mask); + +    [printf][7]("Establishing handler for signal %d\n", SIGRTMIN); + +    /* Register signal handler */ +    if (sigaction(SIGRTMIN, &sa, NULL) == -1){ +        [fprintf][8](stderr, "Error sigaction: %s\n", [strerror][9](errno)); +        [exit][10](-1); +    } + +    /* start timer */ +    res = timer_settime(timerId, 0, &its, NULL); + +    if ( res != 0){ +        [fprintf][8](stderr, "Error timer_settime: %s\n", [strerror][9](errno)); +        [exit][10](-1); +    } + +    [printf][7]("Press ENTER to Exit\n"); +    while([getchar][11]()!='\n'){} +    return 0; +} + +static void +handler(int sig, siginfo_t *si, void *uc) +{ +    UNUSED(sig); +    UNUSED(uc); +    struct t_eventData *data = (struct t_eventData *) si->_sifields._rt.si_sigval.sival_ptr; +    [printf][7]("Timer fired %d - thread-id: %d\n", ++data->myData, gettid()); +} +``` + +In contrast to the threading timer, we have to initialize the signal and register a signal handler. This approach is more performant as it won't cause the creation of additional threads. For this reason, the execution of the signal handler is also more deterministic. The drawback is clearly the extra configuration effort to debug this properly. + +### Summary + +Both methods described in this article are close-to-the-kernel implementations of timers. Even if the [timer_create(...)][2] function is part of the POSIX specification, it is not possible to compile the sample code on a FreeBSD system due to small differences in data structures. Besides this drawback, such an implementation gives you fine-grained control for general-purpose timing applications. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/10/linux-timers + +作者:[Stephan Avenwedde][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/hansic99 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_todo_clock_time_team.png?itok=1z528Q0y (Team checklist) +[2]: https://linux.die.net/man/2/timer_create +[3]: https://github.com/hANSIc99/posix_timers +[4]: https://www.qt.io/product/development-tools +[5]: https://opensource.com/sites/default/files/posix_timers_open_project_0.png +[6]: https://opensource.com/sites/default/files/posix_timers_project_configuration_2.png +[7]: http://www.opengroup.org/onlinepubs/009695399/functions/printf.html +[8]: http://www.opengroup.org/onlinepubs/009695399/functions/fprintf.html +[9]: http://www.opengroup.org/onlinepubs/009695399/functions/strerror.html +[10]: http://www.opengroup.org/onlinepubs/009695399/functions/exit.html +[11]: http://www.opengroup.org/onlinepubs/009695399/functions/getchar.html +[12]: https://man7.org/linux/man-pages/man3/signal.3p.html +[13]: https://linux.die.net/man/7/signal +[14]: https://opensource.com/sites/default/files/posix_timers_sig34_nostop_pass.png +[15]: https://sourceware.org/gdb/onlinedocs/gdb/Signals.html +[16]: https://opensource.com/sites/default/files/posix_timers_sig34_pop_up_2.png +[17]: https://opensource.com/sites/default/files/posix_timers_signal_windows.png diff --git a/sources/tech/20211012 Seahorse- Manage Your Passwords - Encryption Keys in Linux.md b/sources/tech/20211012 Seahorse- Manage Your Passwords - Encryption Keys in Linux.md new file mode 100644 index 0000000000..31c53b4e9c --- /dev/null +++ b/sources/tech/20211012 Seahorse- Manage Your Passwords - Encryption Keys in Linux.md @@ -0,0 +1,92 @@ +[#]: subject: "Seahorse: Manage Your Passwords & Encryption Keys in Linux" +[#]: via: "https://itsfoss.com/seahorse/" +[#]: author: "Ankush Das https://itsfoss.com/author/ankush/" +[#]: collector: "lujun9972" +[#]: translator: "geekpi" +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Seahorse: Manage Your Passwords & Encryption Keys in Linux +====== + +_**Brief:**_ _A simple open-source password and encryption key manager app, let’s explore what it has to offer and how you can get it installed._ + +We often tend to ignore many default/pre-installed applications, especially when numerous tools and utilities are baked in. + +One such helpful tool that you can use on various Linux distributions is **GNOME’s Seahorse**. + +### Seahorse: GNOME’s Password & Encryption Key Manager + +![][1] + +Primarily, Seahorse is an application that comes pre-installed with GNOME desktop and tailored for the same. + +However, you can use it on just about any Linux distribution of your choice. It is a simple and effective utility to manage your passwords and encryption keys / keyring locally. + +You might want to read about the [concept of keyring in Linux][2] if it’s a first for you. + +If you are not a fan of cloud-based password managers, Seahorse can be a great solution to your requirements. Even though it looks straightforward, there are a few essential features that you may find useful. + +Of course, you should also explore some of the [best password managers available for Linux][3] if your priority doesn’t involve managing encryption keys (or local storage). + +### Features of Seahorse + +While you can easily use it as a local (offline) password manager, there are a couple of things that you can do with Seahorse to step up your security management when dealing with encryption keys as well. + +![][4] + +Some key highlights are: + + * Ability to store Secure Shell key (used to access remote computers/servers) + * Store GPG keys used to secure emails and files + * Supports adding password keyring for application and networks + * Securely store private key of a certificate + * Store a password / secret phrase + * Ability to import files and quickly store them + * Find remote keys + * Sync and publish keys + * Ability to find/copy VPN password + + + +![][5] + +### Installing Seahorse in Linux + +If you are using a GNOME-based distribution, you should already have it installed. You need to look for “Seahorse” or “Passwords” to find it. + +In other cases, you can search for it in the software center. It should work fine with KDE, LXQt, and different desktop environments as per my quick tests. + +![][6] + +Moreover, you can find its [Flatpak package][7] available. So, no matter the Linux distribution you are using, Seahorse can be installed. + +If you are using Arch Linux, you should also find it in [AUR][8]. + +[Seahorse][9] + +What do you think about using Seahorse to replace other password managers? Were you already using it to manage encryption keys? Let me know your thoughts in the comments below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/seahorse/ + +作者:[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/2021/10/seahorse-password-keys.png?resize=800%2C613&ssl=1 +[2]: https://itsfoss.com/ubuntu-keyring/ +[3]: https://itsfoss.com/password-managers-linux/ +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/seahorse-login.png?resize=800%2C583&ssl=1 +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/seahorse-keys.png?resize=800%2C579&ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/10/seahorse-software.png?resize=800%2C508&ssl=1 +[7]: https://www.flathub.org/apps/details/org.gnome.seahorse.Application +[8]: https://itsfoss.com/aur-arch-linux/ +[9]: https://wiki.gnome.org/Apps/Seahorse/ diff --git a/sources/tech/20211013 Beginner-s Guide to Installing Pop-_OS Linux.md b/sources/tech/20211013 Beginner-s Guide to Installing Pop-_OS Linux.md new file mode 100644 index 0000000000..9652299ec8 --- /dev/null +++ b/sources/tech/20211013 Beginner-s Guide to Installing Pop-_OS Linux.md @@ -0,0 +1,211 @@ +[#]: subject: "Beginner’s Guide to Installing Pop!_OS Linux" +[#]: via: "https://itsfoss.com/install-pop-os/" +[#]: author: "Pratham Patel https://itsfoss.com/author/pratham/" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Beginner’s Guide to Installing Pop!_OS Linux +====== + +_**Brief: Learn to install Pop OS Linux distribution by replacing all other operating systems on your computer.**_ + +[Pop!_OS][1] is the Linux distribution created by System76 and is based on Ubuntu. Since System76 sells [Linux-first laptops and desktops][2], their Linux distribution, even though is based on Ubuntu, provides support for bleeding edge hardware (only if the newer Linux kernel does not create a conflict for currently supported hardware). + +Out of all the new Linux distributions out there, the user-base of Pop!_OS just “popped” out of nowhere. Considering it is a _relatively_ new distro among a plethora of other “well established distros” like Ubuntu, Manjaro, Mint etc; this is a big achievement! + +This isn’t an opinion article on why you should [use Pop OS over Ubuntu][3], but a guide, for you to get started with Linux on your PC by installing Pop!_OS on it. + +### Choosing the instllation method for Pop OS + +There are multiple ways to install Pop!_OS (and all other Linux distros) on your computer. + + 1. Install Pop!_OS as a Virtual Machine [using VirtualBox][4] on your PC **without affecting your current Windows install**. + 2. Install Pop!_OS alongside Windows; AKA [dual boot][5] (even though the linked guide is for Ubuntu, it should work for Pop!_OS; **make sure to turn off “Secure Boot”**). + 3. Replace Windows 10/11 with Pop!_OS. + + + +I highly recommend that you [try out Pop!_OS in VirtualBox][4] before installing it on your computer, specially if you are new to Linux. + +_**This tutorial covers installation of Pop!_OS replacing Windows**_, and below are the hardware requirements for Pop!_OS. + + * A 4 GB USB drive to create a Live USB drive + * Any 64-bit x86 CPU (any 64-bit Intel or AMD CPU) + * At least 4 GB of RAM is recommended + * A minimum of 20 GB of storage (to store the OS) + + + +_**WARNING: This guide assumes you want to replace Windows on your PC with a Linux distro of your choice (Pop!_OS in this case) and it results in wiping your drive clean. Please make sure you have backed up all of your important data before proceeding further.**_ + +### Choose the version of Pop!_OS to install + +![][6] + +Just like Ubuntu, Pop!_OS comes in two variants. All LTS releases are supported for 5 years from release date. Canonical releases a LTS version of Ubuntu in April of every even numbered year. + +A new Non-LTS version is released every 6 months (in April and September, every year) and that particular version is supported only for 9 months from release date. + +As of writing this article, Pop!_OS is available in two (technically four, but we will get to that later) versions. Current LTS release is “Pop!_OS 20.04 LTS” and “Pop!_OS 21.04”. And soon enough, version 21.10 will be released. + +Because Nvidia does not have open source drivers, installing Nvidia GPU Drivers ends up causing problems to your Linux installation if not done correctly. Therefore, System76 offers two variants for each version of Pop!_OS. + +Pop!_OS 20.04 LTS is [available in two variants][7] (more details in next section). + + * For users with a Nvidia GPU in their computer + * For users with an AMD (and/or an Intel for iGPU and for the [upcoming dGPU][8]) users. + + + +If you are not sure, [check the graphics card][9] on your system and choose the appropriate version while downloading. + +### Installing Pop!_OS + +In this guide, I’ll be using the non-Nvidia version of Pop!_OS 20.04 LTS (but the installer steps will be the same for every variant of the same version). + +#### Step 1: Create a live USB + +Visit System76’s website to download a copy of Pop!_OS. + +[Download Pop!_OS][1] + +![Pop!_OS ISO selection menu][10] + +Select “Pop!_OS 20.04 LTS” (#1) and then click on either the normal ISO (#2) or the Nvidia-specific ISO (#3) to start downloading it. + +After you have downloaded a copy of ISO that is suitable for your use case and machine, your next step will be to create a live installer for Pop!_OS. A live installer is a full copy of the OS for you to tinker with, before you feel that the OS of your liking and also compatible with your hardware. + +Sometimes the distribution of your choice might not have good support for the proprietary components like WiFi, GPU etc included in your laptop/desktop. Now is the time to test your hardware compatibility. + +_**NOTE: Any data stored on your USB stick will be erased at this step, make sure you do not have anything important on the flash drive.**_ + +You have access to numerous tools to create a live USB stick. Some of them are: + + * [balenaEtcher][11] (available on Mac, Windows and Linux) + * [UNetbootin][12] (available on Mac, Windows and Linux) + * [Rufus][13] (available only on Windows) + * [Ventoy][14] (available on Windows and Linux) + + + +On Windows, you can use Rufus to [create a live USB from Windows][15]. You may also use Etcher for Windows, Linux and macOS. It is really simple. Just start the application, browse the downloaded ISO and hit the flash button. + +![A generic example of creating live Linux USB with Etcher][16] + +#### Step 2: Booting from the live Pop OS USB + +Once you have created the live USB, you need to tell our computer to boot from the USB stick instead of the disk on which Windows is installed. + +To do that, restart your computer. And once you see your computer vendor’s logo (HP, Dell, Asus, Gigabyte, ASRock etc) press either the F2 or F10 or F12 or Delete key to enter your computer’s BIOS/UEFI. This key will differ based on your computer vendor, for most desktops it is usually the Delete key, and for most laptops it is the F2 key. If still in doubt, a quick web search should tell you which key to press for your system. + +![BIOS/UEFI boot menu keys][17] + +On modern computers with UEFI, you don’t even need to go in UEFI. You can directly hit a specific key like F12 (my computer vendor has F12) and you’ll see a boot menu. From there directly select your USB stick. + +![UEFI boot menu][18] + +For people who have an older BIOS/UEFI, go under the section where it says Boot (do note, the steps will vary from vendor to vendor) and select your USB drive instead of your SSD/HDD. And reboot. + +![UEFI/BIOS boot drive selection][19] + +Your computer should now boot from the live USB you just created. + +#### Step 4: Start installing Pop!_OS + +You should be in the Pop!_OS live environment now. On your computer screen, you will see an installer asking you for setup details like your preferred Language, Country and Keyboard Layout. + +![Pop!_OS Installation screen][20] + +Once you have selected your Language, Country and Keyboard Layout, you will see this screen. You technically have 3 options. + +![Pop!_OS Installation types, plus Demo Mode][21] + + * Clean Install (#1): This option will erase your entire disk and install Pop!_OS on it. + * Custom (Advanced) (#2): This option will allow you to specify things like root partition, if you want a different home partition, use another file system for your root partition, resize partitions, use a different sized swap partition etc. + * Try Demo Mode (#3): An option in the bottom left of the installer that allows you to test drive Pop!_OS as if it was actually installed on your computer without actually touching your drive contents. + + + +**For the scope of this tutorial, proceed by selecting Clean Install.** + +Next up, specify a drive where you want to install Pop!_OS on. In case your computer has multiple drives, you will see each drive labelled along with it’s size so you can be assured if the drive you have selected is the one you have decided to install Pop!_OS on. + +![Pop!_OS Drive selection options][22] + +You will be prompted to provide your name and a username for your user. Your username will be the name of your home folder. + +![Pop!_OS User’s Name and username input][23] + +Up next, set a password for your user. + +![Pop!_OS User password input][24] + +The final step includes setting up Drive Encryption. If someone has physical access to your computer, your data on the disk can be accessed using a live operating system (like the live USB you created). + +The disk encryption prevents that. However, you must never forget the password or you’ll never be able to use the disk again. + +It is up to you if you want to encrypt the disk. + +![Pop!_OS Drive Encryption options][25] + +The installer will give you three options for encryption. + + * Don’t Encrypt (#1): Does not encrypt your drive. Not recommended for security conscious users + * Use user password for drive encryption (#2): This will tell the installer to use the same password for your user and for drive encryption. If you use this option, make sure your user has a strong password. + * Set Password (#3): Use a different password for encrypting drive. + + + +Whichever you choose, the installation should start now. Below is a screenshot showing the installer screen. + +![Pop!_OS Installation screen, plus log button][26] + +Just in case you encounter any error(s) during this step, click on the button placed at the bottom right edge of installer with “$_” (annotated as “Log” in the screenshot above) in it. It is the installer log. Posting a few lines from the bottom of this log should help others from [our community forum][27] or any other forums help you diagnose the issue causing installation errors. + +Please wait for a few minutes for the installer to finish installing and it will provide you with two options, Reboot or Shut Down. Power off your computer and remove the USB drive. + +Congratulations! You just installed Pop!_OS on your computer! Let me know if you face any issues. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-pop-os/ + +作者:[Pratham Patel][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/pratham/ +[b]: https://github.com/lujun9972 +[1]: https://pop.system76.com/ +[2]: https://itsfoss.com/get-linux-laptops/ +[3]: https://itsfoss.com/pop-os-vs-ubuntu/ +[4]: https://itsfoss.com/install-linux-in-virtualbox/ +[5]: https://itsfoss.com/install-ubuntu-1404-dual-boot-mode-windows-8-81-uefi/ +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/10/POP_OS-Installation.png?resize=800%2C450&ssl=1 +[7]: https://pop.system76.com +[8]: https://www.phoronix.com/scan.php?page=news_item&px=Intel-DG1-Status-XDC2021 +[9]: https://itsfoss.com/check-graphics-card-linux/ +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/pop-os-download-options.webp?resize=800%2C740&ssl=1 +[11]: https://www.balena.io/etcher/ +[12]: https://unetbootin.github.io +[13]: https://rufus.ie/en/ +[14]: https://www.ventoy.net/en/index.html +[15]: https://itsfoss.com/create-live-usb-of-ubuntu-in-windows/%5D +[16]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/balena-etcher-create-linux-live-usb.png?resize=800%2C450&ssl=1 +[17]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/03-01-bios-uefi-boot-menu-keys.webp?resize=732%2C366&ssl=1 +[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/10/03-02-boot-menu.webp?resize=731%2C364&ssl=1 +[19]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/10/03-03-select-boot-drive-3.webp?resize=800%2C399&ssl=1 +[20]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/04-01-installer-init.webp?resize=800%2C595&ssl=1 +[21]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/04-02-installation-options.webp?resize=800%2C595&ssl=1 +[22]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/04-03-drive-selection.webp?resize=800%2C595&ssl=1 +[23]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/10/04-04-name-and-username-selection.webp?resize=800%2C595&ssl=1 +[24]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/04-05-password-setup-screen.webp?resize=800%2C595&ssl=1 +[25]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/10/04-06-drive-encryption-options.webp?resize=800%2C595&ssl=1 +[26]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/04-08-installation.webp?resize=800%2C595&ssl=1 +[27]: https://itsfoss.community/ diff --git a/translated/tech/20200228 How to process real-time data with Apache.md b/translated/tech/20200228 How to process real-time data with Apache.md new file mode 100644 index 0000000000..30a2909289 --- /dev/null +++ b/translated/tech/20200228 How to process real-time data with Apache.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (unigeorge) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to process real-time data with Apache) +[#]: via: (https://opensource.com/article/20/2/real-time-data-processing) +[#]: author: (Simon Crosby https://opensource.com/users/simon-crosby) + +如何使用 Apache 软件处理实时数据 +====== + +开源社区在处理实时事件的项目丰富度方面处于领先地位。 + +![Alarm clocks with different time][1] + +在“永不下线”的未来,入网设备规模可能会达到数十亿。存储原始数据,日后再进行分析的方案将不再能满足需求,因为用户需要实时且准确的响应。要对故障等敏感状况进行预测,实时处理数据也必不可少——数据到达数据库后再处理肯定是来不及的。 + +有人可能会说,“云可扩展性”能够满足实时处理流数据的需求,但一些简单的例子就能表明它永远无法满足对无界数据流进行实时响应的需求。从移动设备到物联网,都需要一种新的范式来满足需求。尽管云计算依赖对大数据“先存储后分析”的方案,但也迫切需要一种能够处理持续、杂乱和海量数据流的软件框架,并在数据流到达时立即对其进行处理,以保证实时的响应、预测和对数据的洞悉。 + +例如,在加利福尼亚州的帕洛阿尔托市,每天从基础交通设施产生的流数据比 Twitter Firehose 还要多。这是很大的数据量。为 Uber、Lyft 和 FedEx 等消费者预测城市交通需要实时的分析、学习和预测。云处理不可避免地导致每个事件大约会有半秒的延迟。 + +我们需要一个简单而强大的编程范式,让应用程序在类似下面的情况时能够动态处理无界数据流: + + * 数据量巨大,或原始数据的移动成本很高。 + * 数据由广泛分布的资产(例如移动设备)生成。 + * 数据具有转瞬即逝的价值,即时分析迫在眉睫。 + * 需要始终洞悉最新数据情况,外推法行不通。 + +### 发布和订阅 + +事件驱动系统领域中有一个关键架构模式:发布/订阅(publish/subscribe) 消息传递模式。这是一种异步通信方法,其中消息会从 _发布者_(数据产生方)传递到 _订阅者_(处理数据的应用程序)。发布/订阅模式可以将消息发送者与消费者分离开来。 + +在发布/订阅模式中,消息源会 _发布_ 针对某个 _topic_(主题) 的 事件(event) 至 _broker_(服务端),后者按接收顺序存储它们。应用程序可以 _订阅_ 一个或多个 _topic_,然后 _broker_ 会转发匹配的事件。 Apache Kafka 和 Pulsar 以及 CNCF NATS 是发布/订阅系统。 发布/订阅的云服务包括 Google Pub/Sub、AWS Kinesis、Azure Service Bus、Confluent Cloud 等。(LCTT译注:本段部分术语英文名称更为泛用,针对这些术语,正文采用英文,仅在括号中标注其对应中文。) + +发布/订阅系统不会 _运行_ 订阅者应用程序,它们只是 _传递_ 数据给相应 topic 的订阅者。 + +流数据通常包含应用程序或基础架构状态更新的事件。在选择架构来处理数据时,发布/订阅框架等数据分发系统的作用是有限的。消费者应用程序的“处理方式”超出了发布/订阅系统的范围。这让开发人员的管理变得极具复杂性。所谓的流处理器是一种特殊的订阅者,可以动态分析数据并将结果返回给同一个 broker。 + +### Apache Spark + +[Apache Spark][2] 是用于大规模数据处理的统一分析引擎。通常将 Apache Spark Streaming 用作流处理器,例如给机器学习模型提供新数据。Spark Streaming 将数据分成小批量,每个小批量都由 Spark 模型或其他系统独立分析。事件流可以被分组成小批量以进行分析,但流处理器本身必须具有弹性: + + * 流处理器必须能够根据数据速率进行扩展,甚至要能够跨越服务器和云,并且还可以跨实例实现负载均衡,以确保弹性和其他应用层的需求。 + * 它必须能够分析来自不同来源的数据,这些数据源的报告速率可能相差很大。这意味着它必须是有状态的,或者将状态存储在数据库中。当使用 Spark Streaming 作为流处理器时,通常会使用后一种方法,这种方法在需要超低延迟响应时可能会存在性能问题。 + +相关项目 [Apache Samza][3] 也提供了一种处理实时事件流的方法,并使用 [Hadoop Yarn][4] 或 [Apache Mesos][5] 来管理计算资源,以便进行弹性扩展。 + +### 解决数据扩展问题 + +需要注意的是,即使是 Samza 也不能完全减轻开发人员的数据处理需求。扩展数据规模意味着处理事件的任务需要跨多个实例进行负载均衡,而使用数据库是实例间共享结果应用层状态的唯一方法。然而,当应用程序任务之间的状态协调转移到数据库时,对性能会产生不可避免的连锁反应。此外,数据库的选择也至关重要。随着系统的扩展,数据库的集群管理会成为下一个潜在的瓶颈。 + +这个问题可以通过有状态、有弹性的替代方案来解决,并且这样的解决方案可以用来代替流处理器。在应用程序级别(容器或实例内),这些解决方案依据流的更新,动态构建并发、互连的“web 代理”的有状态模型。代理是并发的“微服务”,它们消费单一来源的原始数据并维护它们的状态。基于数据中发现的源之间的真实关系(如包含和临近),代理实现互连以共享状态。代理也因此形成了一个并发服务图,可以分析它们自己的状态和链接到的代理的状态。数据源将原始数据转换为状态,并根据自身及其链接子图的变化进行分析、学习和预测,每个代理都为单个这样的数据源提供微服务。 + +这些解决方案允许大量的代理(真实数据源的数字类比)分布,甚至还有在应用层使代理互连的分布式图,从而简化了应用架构。这是因为代理之间互连的本质,是映射到解决方案的当前运行时执行实例和代理本身的 URL。通过这种方式,应用程序可以跨实例无缝扩展,而无需担心 DevOps 问题。代理消费数据并维护状态,还会计算自己和其他代理的状态。由于代理是有状态的,因此不需要数据库,并且数据洞察是以内存速度计算的。 + +### 使用开源阅读数据世界 + +我们查看数据的方式正在发生翻天覆地的变化:不再将数据库用作记录系统,取而代之的是现实世界,现实世界事物的数字类比可以不断地传输它们的状态。幸运的是,开源社区在处理实时事件的项目丰富度方面处于领先地位。从发布/订阅模式(其中最活跃的社区是 Apache Kafka、Pulsar 和 CNCF NATS)到持续处理流数据的分析框架,包括 Apache Spark、[Flink][6]、[Beam][7]、Samza,以及 Apache 许可的 [SwimOS][8] 和 [Hazelcast][9],对开发人员来说,可选择项目非常之多。可以说,没有什么地方比开源社区的专有软件框架更多了。试看软件的未来,必是开源的天下。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/real-time-data-processing + +作者:[Simon Crosby][a] +选题:[lujun9972][b] +译者:[unigeorge](https://github.com/unigeorge) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/simon-crosby +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/clocks_time.png?itok=_ID09GDk (Alarm clocks with different time) +[2]: https://spark.apache.org/ +[3]: https://samza.apache.org/ +[4]: https://hadoop.apache.org/ +[5]: http://mesos.apache.org/ +[6]: https://flink.apache.org/ +[7]: https://beam.apache.org +[8]: https://github.com/swimos/swim +[9]: https://hazelcast.com/ diff --git a/sources/tech/20201029 Managing resources with cgroups in systemd.md b/translated/tech/20201029 Managing resources with cgroups in systemd.md similarity index 65% rename from sources/tech/20201029 Managing resources with cgroups in systemd.md rename to translated/tech/20201029 Managing resources with cgroups in systemd.md index f9c03cd94c..0a78495f78 100644 --- a/sources/tech/20201029 Managing resources with cgroups in systemd.md +++ b/translated/tech/20201029 Managing resources with cgroups in systemd.md @@ -7,30 +7,31 @@ [#]: via: (https://opensource.com/article/20/10/cgroups) [#]: author: (David Both https://opensource.com/users/dboth) -Managing resources with cgroups in systemd +在 systemd 中使用 cgroup 管理资源 ====== -Cgroups manage resources per application rather than by the individual -processes that make up an application. + +cgroup 按照应用管理资源,而不是按照组成应用的单个进程。 + ![Business woman on laptop sitting in front of window][1] -There is little more frustrating to me as a sysadmin than unexpectedly running out of a computing resource. On more than one occasion, I have filled all available disk space in a partition, run out of RAM, and not had enough CPU time to perform my tasks in a reasonable amount of time. Resource management is one of the most important tasks that sysadmins do. +作为一个系统管理员,没有事情比意外地耗尽计算资源让我更觉得沮丧。我曾不止一次填满了一个分区的所有可用磁盘空间、耗尽内存、以及没有足够的 CPU 时间在合理的时间内处理我的任务。资源管理是系统管理员最重要的工作之一。 -The point of resource management is to ensure that all processes have relatively equal access to the system resources they need. Resource management also involves ensuring that RAM, hard drive space, and CPU capacity are added when necessary or rationed when that is not possible. In addition, users who hog system resources, whether intentionally or accidentally, should be prevented from doing so. +资源管理的关键是保证所有的进程能够相对公平的访问需要的系统资源。资源管理还包括确保在需要时添加内存、硬盘驱动器空间、还有 CPU 容量;或者在无法添加时限制资源的使用。此外,应该阻止独占系统资源的用户,无论其是否有意。 -There are tools that enable sysadmins to monitor and manage various system resources. For example, [top][2] and similar tools allow you to monitor the use of memory, I/O, storage (disk, SSD, etc.), network, swap space, CPU usage, and more. These tools, particularly those that are CPU-centric, are mostly based on the paradigm that the running process is the unit of control. At best, they provide a way to adjust the nice number–and through that, the priority—or to kill a running process. (For information about nice numbers, see [_Monitoring Linux and Windows hosts with Glances_][3].) -Other tools based on traditional resource management in a SystemV environment are managed by the `/etc/security/limits.conf` file and the local configuration files located in the `/etc/security/limits.d` directory. Resources can be limited in a fairly crude but useful manner by user or group. Resources that can be managed include various aspects of RAM, total CPU time per day, total amount of data, priority, nice number, number of concurrent logins, number of processes, maximum file size, and more. +系统管理员可以通过一些工具监控和管理不同的系统资源。例如,[top][2] 和类似的工具允许你监控内存、I/O、存储(磁盘,SSD等)、网络、交换空间、CPU 的用量等。这些工具,尤其是以 CPU 为中心的工具,大部分基于运行的进程是控制的基本单位的模型。他们最多只是提供了一种方式来调整 nice 数字——从而修改优先级——或者杀死一个运行的进程。(要了解 nice 数字的信息,查看[_使用 Glances 监控 Linux 和 Windows 主机_][3])。 -### Using cgroups for process management +SystemV 环境中基于传统的资源管理的其他工具,由 `/etc/security/limits.conf` 文件和 `/etc/security/limits.d` 中的本地配置文件控制。资源可以按照用户或组以一种相当粗糙但实用的方式限制。可以管理的资源包括 RAM 的各个方面、每日的总 CPU 时间、数据总量、优先级、nice 数字、同时登陆的数量、进程数、文件大小的最大值等。 -One major difference between [systemd and SystemV][4] is how they handle processes. SystemV treats each process as an entity unto itself. systemd collects related processes into control groups, called [cgroups][5] (short for control groups), and manages system resources for the cgroup as a whole. This means resources can be managed per application rather than by the individual processes that make up an application. +### 使用 cgroup 管理进程 -The control units for cgroups are called slice units. Slices are a conceptualization that allows systemd to order processes in a tree format for ease of management. +[systemd 和 SystemV][4] 之间的一个主要差异是管理进程的方式。SystemV 将每个进程当做指向自身的一个实体。systemd 将相关的进程集中到一个控制组,称作 [cgroup][5](控制组的简称),并将 cgroup 作为一个整体管理系统资源。这意味着资源能够基于应用管理,而不是组成应用的单个进程。 -### Viewing cgroups +cgroup 的控制单元称作切片单元。切片是允许 systemd 以树状格式控制程序次序,从而简化管理的概念化。 -I'll start with some commands that allow you to view various types of information about cgroups. The `systemctl status ` command displays slice information about a specified service, including its slice. This example shows the `at` daemon: +### 查看 cgroup +我将从一些允许你查看不同类型 cgroup 信息的命令开始。 `systemctl status ` 命令显示一个特定服务的切片信息,包括服务的切片。这个例子展示了 `at` 守护进程: ``` [root@testvm1 ~]# systemctl status atd.service @@ -49,10 +50,9 @@ Sep 23 12:18:24 testvm1.both.org systemd[1]: Started Deferred execution schedule [root@testvm1 ~]# ``` -This is an excellent example of one reason that I find systemd more usable than SystemV and the old init program. There is so much more information here than SystemV could provide. The cgroup entry includes the hierarchical structure where the `system.slice` is systemd (PID 1), and the `atd.service` is one level below and part of the `system.slice`. The second line of the cgroup entry also shows the process ID (PID) and the command used to start the daemon. - -The `systemctl` command shows multiple cgroup entries. The `--all` option shows all slices, including those that are not currently active: +这是一个我感到 systemd 比 SystemV 和旧的初始化程序更好用的原因的绝佳示例。这里的信息远比 SystemV 能够提供的丰富。cgroup 项包括的层级结构中,`system.slice` 是 systemd(PID 1),`atd.service` 在下一层,是 `system.slice` 的一部分。cgroup 项的第二行还显示了进程 ID(PID)和启动守护进程使用的命令。 +`systemctl` 命令列出多个 cgroup 项,`--all` 参数列出所有的切片,包括当前没有激活的: ``` [root@testvm1 ~]# systemctl -t slice --all @@ -78,14 +78,13 @@ To show all installed unit files use 'systemctl list-unit-files'. [root@testvm1 ~]# ``` -The first thing to notice about this data is that it shows user slices for UIDs 0 (root) and 1000, which is my user login. This shows only the slices and not the services that are part of each slice. This data shows that a slice is created for each user at the time they log in. This can provide a way to manage all of a user's tasks as a single cgroup entity. +关于这个数据,第一个需要注意的是数据显示了 UID 0(root)和 1000 的用户切片,1000 是我登陆的用户。这里列出了组成每个切片的切片部分,而不是服务。还说明了每个用户登录时都会为其创建一个切片,这为将一个用户的所有任务作为单个 cgroup 项进行管理提供了一种方式。 -### Explore the cgroup hierarchy +### 探索 cgroup 层次结构 -All is well and good so far, but cgroups are hierarchical, and all of the service units run as members of one of the cgroups. Viewing that hierarchy is easy and uses one old command and one new one that is part of systemd. - -The `ps` command can be used to map the processes and their locations in the cgroup hierarchy. Note that it is necessary to specify the desired data columns when using the `ps` command. I significantly reduced the volume of output from this command below, but I tried to leave enough so you can get a feel for what you might find on your systems: +目前为止一切顺利,但是 cgroup 是分层的,所有的服务单元作为其中一个 cgroup 的成员运行。要查看这个层次结构很简单,使用 systemd 的一个旧命令和一个新命令即可。 +`ps` 命令可以用于映射进程的和其所处的 cgroup 层次。注意使用 `ps` 命令时需要指明想要的数据列。我大幅削减了下面命令的输出数量,但是试图保留足够的数据,以便你能够对自己系统上的输出有所感受: ``` [root@testvm1 ~]# ps xawf -eo pid,user,cgroup,args @@ -162,10 +161,9 @@ ons Action Buttons Log out, lock or other system actions <SNIP> ``` -You can view the entire hierarchy with the `systemd-cgls` command, which is a bit simpler because it does not require any complex options. - -I have shortened this tree view considerably. as well, but I left enough to give you some idea of the amount of data as well as the types of entries you should see when you do this on your system. I did this on one of my virtual machines, and it is about 200 lines long; the amount of data from my primary workstation is about 250 lines: +你可以使用 `systemd-cgls` 命令查看整个层次结构,这个命令不需要任何的复杂参数,更加简单。 +我也大幅缩短了这个树状结构,但是保留了足够多的输出,以便你能够了解在自己的系统上执行这个命令时应该看到的数据总量和条目类型。我在我的一个虚拟机上执行了这个命令,输出大概有 200 行;我的主要工作站的输出大概有 250 行。 ``` [root@testvm1 ~]# systemd-cgls @@ -263,43 +261,45 @@ Control group /:  <SNIP> ``` -This tree view shows all of the user and system slices and the services and programs running in each cgroup. Notice the units called "scopes," which group related programs into a management unit, within the `user-1000.slice` in the listing above. The `user-1000.slice/session-7.scope` cgroup contains the GUI desktop program hierarchy, starting with the LXDM display manager session and all of its subtasks, including things like the Bash shell and the Thunar GUI file manager. +这个树状视图显示了所有的用户和系统切片,以及每个 cgroup 内正在运行的服务和程序。注意叫作“范围”的单元,它将相关的程序组成一个管理单元,在上面列出的结果中就是 `user-1000.slice`。`user-1000.slice/session-7.scope` cgroup 包含了 GUI 桌面程序层次结构,以 LXDM 显示管理器会话和其所有的子任务开始,包括像 Bash 命令行解释器和 Thunar GUI 文件管理器之类的程序。 -Scope units are not defined in configuration files but are generated programmatically as the result of starting groups of related programs. Scope units do not create or start the processes running as part of that cgroup. All processes within the scope are equal, and there is no internal hierarchy. The life of a scope begins when the first process is created and ends when the last process is destroyed. +配置文件中不定义范围单元,而是作为启动相关程序组的结果程序化生成的。范围单元不创建或启动作为 cgroup 组成部分运行的进程。范围内的所有进程都是平等的,没有内部的层次结构。范围的生命周期在第一个进程创建时开始,在最后一个进程销毁时结束。 -Open several windows on your desktop, such as terminal emulators, LibreOffice, or whatever you want, then switch to an available virtual console and start something like `top` or [Midnight Commander][11]. Run the `systemd-cgls` command on your host, and take note of the overall hierarchy and the scope units. +在你的桌面打开多个窗口,比如终端模拟器、LibreOffice、或者任何你想打开的,然后切换到一个可用的虚拟控制台,启动类似 `top` 或 [Midnight Commander][11] 的程序。在主机运行 `systemd-cgls` 命令,留意整体的层次结构和范围单元。 -The `systemd-cgls` command provides a more complete representation of the cgroup hierarchy (and details of the units that make it up) than any other command I have found. I prefer its cleaner representation of the tree than what the `ps` command provides. +`systemd-cgls` 命令提供的 cgroup 层次结构表示(以及组成 cgroup 单元的细节),比我见过的其他任何指令都要完整。和 `ps` 命令提供的输出相比,我喜欢 `systemd-cgls` 命令更简洁的树形表示。 -### With a little help from my friends +### 来自朋友们的一点帮助 -After covering these basics, I had planned to go into more detail about cgroups and how to use them, but I discovered a series of four excellent articles by Red Hat's [Steve Ovens][12] on Opensource.com's sister site [Enable Sysadmin][13]. Rather then basically rewriting Steve's articles, I decided it would be much better to take advantage of his cgroup expertise by linking to them: +介绍完这些基础知识后,我曾计划过深入研究 cgroup 的更多细节,以及如何使用,但是我在 Opensource.com 的姐妹网站 [Enable Sysadmin][13] 上发现了一系列四篇优秀文章,由 Red Hat 公司的 [Steve Ovens][12] 所作。与其从头重写 Steve 的文章,我觉得倒不如通过链接到这些文章,利用他的 cgroup 专业知识: - 1. [A Linux sysadmin's introduction to cgroups][14] - 2. [How to manage cgroups with CPUShares][15] - 3. [Managing cgroups the hard way—manually][16] - 4. [Managing cgroups with systemd][17] + 1. [一个 Linux 系统管理员对 cgroup 的介绍][14] + 2. [如何用 CPUShares 管理 cgroup][15] + 3. [用更难的方式——手动管理 cgroup][16] + 4. [用 systemd 管理 cgroup][17] + +像我一样享受这些文章并从中汲取知识吧。 + +### 其他资源 + +因特网上充斥着大量关于 systemd 的信息,但大部分都简短生硬、愚钝、甚至令人误解。除了本文提到的资源,下面的网页提供了关于 systemd 启动更详细可靠的信息。自从我开始这一系列的文章来反映我所做的研究以来,这个的列表已经变长了。 + + * Fedora 项目有一个优质实用的 [systemd 指南][18],几乎有你使用 systemd 配置、管理、维 +护一个 Fedora 计算机需要知道的一切。 + * Fedora 项目还有一个好用的[速查表][19],交叉引用了古老的 SystemV 命令和对应的 systemd 命令。 + * [systemd.unit(5) 手册页][20]包含了一个不错的单元文件中段的列表,以及这些段的配置选项和简洁的描述。 + * Red Hat 文档包含了一个[单元文件结构][21]的有用描述,还有一些其他的重要信息。 + * 要获取 systemd 的详细技术信息和创立的原因,查看 Freedesktop.org 的 [systemd 描 +述][22]。这个使我发现过的最棒页面之一,因为其中包含了许多指向其他重要准确文档的链接。 + + * Linux.com 上 ”systemd 的更多乐趣 " 提供了更高级的 systemd [信息和提示][23]。 + * 查看 [systemd.resource-control(5)][24] 的手册页 + * 查看 [_Linux 内核用户和管理员指南_][25]中的[控制组 v2 条目][26]。 - -Enjoy and learn from them, as I did. - -### Other resources - -There is a great deal of information about systemd available on the internet, but much is terse, obtuse, or even misleading. In addition to the resources mentioned in this article, the following webpages offer more detailed and reliable information about systemd startup. This list has grown since I started this series of articles to reflect the research I have done. - - * The Fedora Project has a good, practical [guide][18] [to systemd][18]. It has pretty much everything you need to know in order to configure, manage, and maintain a Fedora computer using systemd. - * The Fedora Project also has a good [cheat sheet][19] that cross-references the old SystemV commands to comparable systemd ones. - * The [systemd.unit(5) manual page][20] contains a nice list of unit file sections and their configuration options along with concise descriptions of each. - * Red Hat documentation contains a good description of the [Unit file structure][21] as well as other important information. - * For detailed technical information about systemd and the reasons for creating it, check out Freedesktop.org's [description of systemd][22]. This page is one of the best I have found because it contains many links to other important and accurate documentation. - * Linux.com's "More systemd fun" offers more advanced systemd [information and tips][23]. - * See the man page for [systemd.resource-control(5)][24]. - * In [_The Linux kernel user's and administrator's guide_][25], see the [Control Group v2][26] entry. - - - -There is also a series of deeply technical articles for Linux sysadmins by Lennart Poettering, the designer and primary developer of systemd. These articles were written between April 2010 and September 2011, but they are just as relevant now as they were then. Much of everything else good that has been written about systemd and its ecosystem is based on these papers. +还有一系列针对系统管理员的深度技术文章,由 systemd 的设计者和主要开发者 Lennart +Poettering 所作。这些文章写于 2010 年 4 月到 2011 年 9 月之间,但在当下仍然像当时一样有 +价值。关于 systemd 及其生态的许多其他优秀的作品都是基于这些文章的。 * [Rethinking PID 1][27] * [systemd for Administrators, Part I][28] @@ -322,7 +322,7 @@ via: https://opensource.com/article/20/10/cgroups 作者:[David Both][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) +译者:[YungeG](https://github.com/YungeG) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/translated/tech/20210813 Code memory safety and efficiency by example.md b/translated/tech/20210813 Code memory safety and efficiency by example.md deleted file mode 100644 index 314853622a..0000000000 --- a/translated/tech/20210813 Code memory safety and efficiency by example.md +++ /dev/null @@ -1,666 +0,0 @@ -[#]: subject: "Code memory safety and efficiency by example" -[#]: via: "https://opensource.com/article/21/8/memory-programming-c" -[#]: author: "Marty Kalin https://opensource.com/users/mkalindepauledu" -[#]: collector: "lujun9972" -[#]: translator: "unigeorge" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -实例讲解代码之内存安全与效率 -====== - -了解有关内存安全和效率的更多信息。 -![Code going into a computer.][1] - -C 是一种高级语言,同时具有“接近金属”(LCTT 译注:即“接近人类思维方式”的反义词)的特性,这使得它有时看起来更像是一种可移植的汇编语言,而不是 Java 或 Python 的兄弟语言。内存管理作为上述特性之一,涵盖了正在执行的程序对内存的安全和高效使用。本文通过 C 语言代码示例,以及现代 C 语言编译器生成的汇编语言代码段,详细介绍了内存安全性和效率。 - -尽管代码示例是用 C 语言编写的,但安全高效的内存管理指南对于 C++ 是同样适用的。这两种语言在很多细节上有所不同(例如,C++ 具有 C 所缺乏的面向对象特性和泛型),但在内存管理方面面临的挑战是一样的。 - -### 执行中程序的内存概述 - -对于正在执行的程序(又名 _进程process_),内存被划分为三个区域:**stack**、**heap** 和 **静态区static area**。下文会给出每个区域的概述,以及完整的代码示例。 - -作为通用 CPU 寄存器的替补,_栈_ 为代码块(例如函数或循环体)中的局部变量提供暂存器存储。传递给函数的参数在此上下文中也视作局部变量。看一下下面这个简短的示例: - -``` -void some_func(int a, int b) { -   int n; -   ... -} -``` - -通过 **a** 和 **b** 传递的参数以及局部变量 **n** 的存储会在栈中,除非编译器可以找到通用寄存器。编译器倾向于优先将通用寄存器用作暂存器,因为 CPU 对这些寄存器的访问速度很快(一个时钟周期)。然而,这些寄存器在台式机、笔记本电脑和手持机器的标准架构上很少(大约 16 个)。 - -在只有汇编语言程序员才能看到的实施层面,栈被组织为具有 **push**(插入)和 **pop**(删除)操作的 LIFO(后进先出)列表。 **top** 指针可以作为偏移的基地址;这样,除了 **top** 之外的栈位置也变得可访问了。例如,表达式 **top+16** 指向堆栈的 **top** 指针上方 16 个字节的位置,表达式 **top-16** 指向 **top** 指针下方 16 个字节的位置。因此,可以通过 **top** 指针访问实现了暂存器存储的栈的位置。在标准的 ARM 或 Intel 架构中,栈从高内存地址增长到低内存地址;因此,减小某进程的 **top** 就是增大其栈规模。 - -使用栈结构就意味着轻松高效地使用内存。编译器(而非程序员)会编写管理栈的代码,管理过程通过分配和释放所需的暂存器存储来实现;程序员声明函数参数和局部变量,将实现过程交给编译器。此外,完全相同的栈存储可以在连续的函数调用和代码块(如循环)中重复使用。精心设计的模块化代码会将栈存储作为暂存器的首选内存选项,同时优化编译器要尽可能使用通用寄存器而不是栈。 - -**堆** 提供的存储是通过程序员代码显式分配的,堆分配的语法因语言而异。在 C 中,成功调用库函数 **malloc**(或其变体 **calloc** 等)会分配指定数量的字节(在 C++ 和 Java 等语言中,**new** 运算符具有相同的用途)。编程语言在如何释放堆分配的存储方面有着巨大的差异: - - * 在 Java、Go、Lisp 和 Python 等语言中,程序员不会显式释放动态分配的堆存储。 - -例如,下面这个 Java 语句为一个字符串分配了堆存储,并将这个堆存储的地址存储在变量 **greeting** 中: - - -``` -String greeting = new String("Hello, world!"); -``` - -Java 有一个垃圾回收器,它是一个运行时实用程序,如果进程无法再访问自己分配的堆存储,回收器可以使其自动释放。因此,Java 堆释放是通过垃圾收集器自动进行的。在上面的示例中,垃圾收集器将在变量 **greeting** 超出作用域后,释放字符串的堆存储。 - - * Rust 编译器会编写堆释放代码。这是 Rust 在不依赖垃圾回收器的情况下,使堆释放实现自动化的开创性努力,但这也会带来运行时复杂性和开销。向 Rust 的努力致敬! - * 在 C(和 C++)中,堆释放是程序员的任务。程序员调用 **malloc** 分配堆存储,然后负责相应地调用库函数 **free** 来释放该存储空间(在 C++ 中,**new** 运算符分配堆存储,而 **delete** 和 **delete[]** 运算符释放此类存储)。下面是一个 C 语言代码示例: - -``` -char* greeting = malloc(14);       /* 14 heap bytes */ -strcpy(greeting, "Hello, world!"); /* copy greeting into bytes */ -puts(greeting);                    /* print greeting */ -free(greeting);                    /* free malloced bytes */ -``` - -C 语言避免了垃圾回收器的成本和复杂性,但也不过是让程序员承担了堆释放的任务。 - -内存的 **静态区** 为可执行代码(例如 C 语言函数)、字符串文字(例如“Hello, world!”)和全局变量提供存储空间: - -``` -int n;                       /* global variable */ -int main() {                 /* function */ -   char* msg = "No comment"; /* string literal */ -   ... -} -``` - -该区域是静态的,因为它的大小从进程执行开始到结束都固定不变。由于静态区相当于进程固定大小的内存占用,因此经验法则是通过避免使用全局数组等方法来使该区域尽可能小。 - -下文会结合代码示例对本节概述展开进一步讲解。 - -### 栈存储 - -想象一个有各种连续执行的任务的程序,任务包括了处理每隔几分钟通过网络下载并存储在本地文件中的数字数据。下面的 **stack** 程序简化了处理流程(仅是将奇数整数值转换为偶数),而将重点放在栈存储的好处上。 - - -``` -#include -#include - -#define Infile   "incoming.dat" -#define Outfile  "outgoing.dat" -#define IntCount 128000  /* 128,000 */ - -void other_task1() { /*...*/ } -void other_task2() { /*...*/ } - -void process_data(const char* infile, -          const char* outfile, -          const unsigned n) { -  int nums[n]; -  FILE* input = fopen(infile, "r"); -  if (NULL == infile) return; -  FILE* output = fopen(outfile, "w"); -  if (NULL == output) { -    fclose(input); -    return; -  } - -  fread(nums, n, sizeof(int), input); /* read input data */ -  unsigned i; -  for (i = 0; i < n; i++) { -    if (1 == (nums[i] & 0x1))  /* odd parity? */ -      nums[i]--;               /* make even */ -  } -  fclose(input);               /* close input file */ - -  fwrite(nums, n, sizeof(int), output); -  fclose(output); -} - -int main() { -  process_data(Infile, Outfile, IntCount); -   -  /** now perform other tasks **/ -  other_task1(); /* automatically released stack storage available */ -  other_task2(); /* ditto */ -   -  return 0; -} -``` - -底部的 **main** 函数首先调用 **process_data** 函数,该函数会创建一个基于栈的数组,其大小由参数 **n** 给定(当前示例中为 128,000)。因此,该数组占用 128,000 x **sizeof(int)** 个字节,在标准设备上达到了 512,000 字节(**int** 在这些设备上是四个字节)。然后数据会被读入数组(使用库函数 **fread**),循环处理,并保存到本地文件 **outgoing.dat**(使用库函数**fwrite**)。 - -当 **process_data** 函数返回到其调用者 **main** 函数时,**process_data** 函数的大约 500MB 栈暂存器可供 **stack** 程序中的其他函数用作暂存器。在此示例中,**main** 函数接下来调用存根函数 **other_task1** 和 **other_task2**。这三个函数在 **main** 中依次调用,这意味着所有三个函数都可以使用相同的堆栈存储作为暂存器。因为编写栈管理代码的是编译器而不是程序员,所以这种方法对程序员来说既高效又容易。 - -在 C 语言中,在块(例如函数或循环体)内定义的任何变量默认都有一个 **auto** 存储类,这意味着该变量是基于栈的。存储类 **register** 现在已经过时了,因为 C 编译器会主动尝试尽可能使用 CPU 寄存器。只有在块内定义的变量可能是 **register**,如果没有可用的 CPU 寄存器,编译器会将其更改为 **auto**。基于栈的编程可能是不错的首选方式,但这种风格确实有一些挑战性。下面的 **badStack** 程序说明了这点。 - -``` -#include ; - -const int* get_array(const unsigned n) { -  int arr[n]; /* stack-based array */ -  unsigned i; -  for (i = 0; i < n; i++) arr[i] = 1 + 1; - -  return arr;  /** ERROR **/ -} - -int main() { -  const unsigned n = 16; -  const int* ptr = get_array(n); -   -  unsigned i; -  for (i = 0; i < n; i++) printf("%i ", ptr[i]); -  puts("\n"); - -  return 0; -} -``` - -**badStack** 程序中的控制流程很简单。**main** 函数使用 16(LCTT译注:原文为 128,应为作者笔误)作为参数调用函数 **get_array**,然后被调用函数会使用传入参数来创建对应大小的本地数组。**get_array** 函数会初始化数组并返回给 **main** 中的数组标识符 **arr**。 **arr** 是一个指针常量,保存数组的第一个 **int** 元素的地址。 - -当然,本地数组 **arr** 可以在 **get_array** 函数中访问,但是一旦 **get_array** 返回,就不能合法访问该数组。尽管如此,**main** 函数会尝试使用函数 **get_array** 返回的堆栈地址 **arr** 来打印基于栈的数组。现代编译器会警告错误。例如,下面是来自 GNU 编译器的警告: - -``` -badStack.c: In function 'get_array': -badStack.c:9:10: warning: function returns address of local variable [-Wreturn-local-addr] -return arr;  /** ERROR **/ -``` - -一般规则是,如果使用栈存储实现局部变量,应该仅在该变量所在的代码块内,访问这块基于栈的存储(在本例中,数组指针 **arr** 和循环计数器 **i** 均为这样的局部变量)。因此,函数永远不应该返回指向基于栈存储的指针。 - -### 堆存储 - -接下来使用若干代码示例凸显在 C 语言中使用堆存储的优点。在第一个示例中,使用了最优方案分配、使用和释放堆存储。第二个示例(在下一节中)将堆存储嵌套在了其他堆存储中,这会使其释放操作变得复杂。 - -``` -#include -#include - -int* get_heap_array(unsigned n) { -  int* heap_nums = malloc(sizeof(int) * n);  -   -  unsigned i; -  for (i = 0; i < n; i++) -    heap_nums[i] = i + 1;  /* initialize the array */ -   -  /* stack storage for variables heap_nums and i released -     automatically when get_num_array returns */ -  return heap_nums; /* return (copy of) the pointer */ -} - -int main() { -  unsigned n = 100, i; -  int* heap_nums = get_heap_array(n); /* save returned address */ -   -  if (NULL == heap_nums) /* malloc failed */ -    fprintf(stderr, "%s\n", "malloc(...) failed..."); -  else { -    for (i = 0; i < n; i++) printf("%i\n", heap_nums[i]); -    free(heap_nums); /* free the heap storage */ -  } -  return 0;  -} -``` - -上面的 **heap** 程序有两个函数: **main** 函数使用参数(示例中为 100)调用 **get_heap_array** 函数,参数用来指定数组应该有多少个 **int** 元素。因为堆分配可能会失败,**main** 函数会检查 **get_heap_array** 是否返回了 **NULL**;如果是,则表示失败。如果分配成功,**main** 将打印数组中的 **int** 值,然后立即调用库函数 **free** 来对堆存储解除分配。这就是最优的方案。 - -**get_heap_array** 函数以下列语句开头,该语句值得仔细研究一下: - -``` -int* heap_nums = malloc(sizeof(int) * n); /* heap allocation */ -``` - -**malloc** 库函数及其变体函数针对字节进行操作;因此,**malloc** 的参数是 **n** 个 **int** 类型元素所需的字节数(**sizeof(int)** 在标准现代设备上是四个字节)。**malloc** 函数返回所分配字节段的首地址,如果失败则返回 **NULL** . - -如果成功调用 **malloc**,在现代台式机上其返回的地址大小为 64 位。在手持设备和早些时候的台式机上,该地址的大小可能是 32 位,或者甚至更小,具体取决于其年代。堆分配数组中的元素是 **int** 类型,这是一个四字节的有符号整数。这些堆分配的 **int** 的地址存储在基于栈的局部变量 **heap_nums** 中。可以参考下图: - -``` -                 heap-based - stack-based        / -     \        +----+----+   +----+ - heap-nums--->|int1|int2|...|intN| -              +----+----+   +----+ -``` - -一旦 **get_heap_array** 函数返回,指针变量 **heap_nums** 的栈存储将自动回收——但动态 **int** 数组的堆存储仍然存在,这就是 **get_heap_array** 函数返回这个地址(的副本)给 **main** 函数的原因:它现在负责在打印数组的整数后,通过调用库函数 **free** 显式释放堆存储: - -``` -free(heap_nums); /* free the heap storage */ -``` - -**malloc** 函数不会初始化堆分配的存储空间,因此里面是随机值。相比之下,其变体函数 **calloc** 会将分配的存储初始化为零。这两个函数都返回 **NULL** 来表示分配失败。 - -在 **heap** 示例中,**main** 函数在调用 **free** 后会立即返回,正在执行的程序会终止,这会让系统回收所有已分配的堆存储。尽管如此,程序员应该养成在不再需要时立即显式释放堆存储的习惯。 - -### 嵌套堆分配 - -下一个代码示例会更棘手一些。C 语言有很多返回指向堆存储的指针的库函数。下面是一个常见的使用情景: - -1\. C 程序调用一个库函数,该函数返回一个指向基于堆的存储的指针,而指向的存储通常是一个聚合体,如数组或结构体: - -``` -SomeStructure* ptr = lib_function(); /* returns pointer to heap storage */ -``` - -2\. 然后程序使用所分配的存储。 - -3\. 对于清理而言,问题是对 **free** 的简单调用是否会清理库函数分配的所有堆分配存储。例如,**SomeStructure** 实例可能有指向堆分配存储的字段。一个特别麻烦的情况是动态分配的结构体数组,每个结构体有一个指向又一层动态分配的存储的字段。下面的代码示例说明了这个问题,并重点关注了如何设计一个可以安全地为客户端提供堆分配存储的库。 - -``` -#include -#include - -typedef struct { -  unsigned id; -  unsigned len; -  float*   heap_nums; -} HeapStruct; -unsigned structId = 1; - -HeapStruct* get_heap_struct(unsigned n) { -  /* Try to allocate a HeapStruct. */ -  HeapStruct* heap_struct = malloc(sizeof(HeapStruct)); -  if (NULL == heap_struct) /* failure? */ -    return NULL;           /* if so, return NULL */ - -  /* Try to allocate floating-point aggregate within HeapStruct. */ -  heap_struct->heap_nums = malloc(sizeof(float) * n); -  if (NULL == heap_struct->heap_nums) {  /* failure? */ -    free(heap_struct);                   /* if so, first free the HeapStruct */ -    return NULL;                         /* then return NULL */ -  } - -  /* Success: set fields */ -  heap_struct->id = structId++; -  heap_struct->len = n; - -  return heap_struct; /* return pointer to allocated HeapStruct */ -} - -void free_all(HeapStruct* heap_struct) { -  if (NULL == heap_struct) /* NULL pointer? */ -    return;                /* if so, do nothing */ -   -  free(heap_struct->heap_nums); /* first free encapsulated aggregate */ -  free(heap_struct);            /* then free containing structure */   -} - -int main() { -  const unsigned n = 100; -  HeapStruct* hs = get_heap_struct(n); /* get structure with N floats */ - -  /* Do some (meaningless) work for demo. */ -  unsigned i; -  for (i = 0; i < n; i++) hs->heap_nums[i] = 3.14 + (float) i; -  for (i = 0; i < n; i += 10) printf("%12f\n", hs->heap_nums[i]); - -  free_all(hs); /* free dynamically allocated storage */ -   -  return 0; -} -``` - -上面的 **nestedHeap** 程序示例以结构体 **HeapStruct** 为中心,结构体中又有名为 **heap_nums** 的指针字段: - -``` -typedef struct { -  unsigned id; -  unsigned len; -  float*   heap_nums; /** pointer **/ -} HeapStruct; -``` - -函数 **get_heap_struct** 尝试为 **HeapStruct** 实例分配堆存储,这需要为字段 **heap_nums** 指向的若干个 **float** 变量分配堆存储。如果成功调用 **get_heap_struct** 函数,并将指向堆分配结构体的指针以 **hs** 命名,其结果可以描述如下: - -``` -hs-->HeapStruct instance -        id -        len -        heap_nums-->N contiguous float elements -``` - -在 **get_heap_struct** 函数中,第一个堆分配过程很简单: - -``` -HeapStruct* heap_struct = malloc(sizeof(HeapStruct)); -if (NULL == heap_struct) /* failure? */ -  return NULL;           /* if so, return NULL */ -``` - -**sizeof(HeapStruct)** 包括了 **heap_nums** 字段的字节数(32 位机器上为 4,64 位机器上为 8),**heap_nums** 字段则是指向动态分配数组中的 **float** 元素的指针。那么,问题关键在于 **malloc** 为这个结构体传送了字节空间还是表示失败的 **NULL**;如果是 **NULL**,**get_heap_struct** 函数就也返回 **NULL** 以通知调用者堆分配失败。 - -第二步尝试堆分配的过程更复杂,因为在这一步,**HeapStruct** 的堆存储已经分配好了: - -``` -heap_struct->heap_nums = malloc(sizeof(float) * n); -if (NULL == heap_struct->heap_nums) {  /* failure? */ -  free(heap_struct);                   /* if so, first free the HeapStruct */ -  return NULL;                         /* and then return NULL */ -} -``` - -传递给 **get_heap_struct** 函数的参数 **n** 指明动态分配的 **heap_nums** 数组中应该有多少个 **float** 元素。如果可以分配所需的若干个 **float** 元素,则该函数在返回 **HeapStruct** 的堆地址之前会设置结构的 **id** 和 **len** 字段。 但是,如果尝试分配失败,则需要两个步骤来实现最优方案: - -1\. 必须释放 **HeapStruct** 的存储以避免内存泄漏。对于调用 **get_heap_struct** 的客户端函数而言,没有动态 **heap_nums** 数组的 **HeapStruct** 可能就是没用的;因此,**HeapStruct** 实例的字节空间应该显式释放,以便系统可以回收这些空间用于未来的堆分配。 - -2\. 返回 **NULL** 以标识失败。 - -如果成功调用 **get_heap_struct** 函数,那么释放堆存储也很棘手,因为它涉及要以正确顺序进行的两次 **free** 操作。因此,该程序设计了一个 **free_all** 函数,而不是要求程序员再去手动实现两步释放操作。回顾一下,**free_all** 函数是这样的: - -``` -void free_all(HeapStruct* heap_struct) { -  if (NULL == heap_struct) /* NULL pointer? */ -    return;                /* if so, do nothing */ -   -  free(heap_struct->heap_nums); /* first free encapsulated aggregate */ -  free(heap_struct);            /* then free containing structure */   -} -``` - -检查完参数 **heap_struct** 不是 **NULL** 值后,函数首先释放 **heap_nums** 数组,这步要求 **heap_struct** 指针此时仍然是有效的。先释放 **heap_struct** 的做法是错误的。一旦 **heap_nums** 被释放,**heap_struct** 就可以释放了。如果 **heap_struct** 被释放,但 **heap_nums** 没有被释放,那么数组中的 **float** 元素就会泄漏:仍然分配了字节空间,但无法被访问到——因此一定要记得释放 **heap_nums**。存储泄漏将一直持续,直到 **nestedHeap** 程序退出,系统回收泄漏的字节时为止。 - -关于 **free** 库函数的注意事项就是要有顺序。回想一下上面的调用示例: - -``` -free(heap_struct->heap_nums); /* first free encapsulated aggregate */ -free(heap_struct);            /* then free containing structure */ -``` - -这些调用释放了分配的存储空间——但它们并 _不是_ 将它们的操作参数设置为 **NULL**(**free** 函数会获取地址的副本作为参数;因此,将副本更改为 **NULL** 并不会改变原地址上的参数值)。例如,在成功调用 **free** 之后,指针 **heap_struct** 仍然持有一些堆分配字节的堆地址,但是现在使用这个地址将会产生错误,因为对 **free** 的调用使得系统有权回收然后重用这些分配过的字节。 - -使用 **NULL** 参数调用 **free** 没有意义,但也没有什么坏处。而在非 **NULL** 的地址上重复调用 **free** 会导致不确定结果的错误: - -``` -free(heap_struct);  /* 1st call: ok */ -free(heap_struct);  /* 2nd call: ERROR */ -``` - -### 内存泄漏和堆碎片化 - -“内存泄漏”是指动态分配的堆存储变得不再可访问。看一下相关的代码段: - -``` -float* nums = malloc(sizeof(float) * 10); /* 10 floats */ -nums[0] = 3.14f;                          /* and so on */ -nums = malloc(sizeof(float) * 25);        /* 25 new floats */ -``` - -假如第一个 **malloc** 成功,第二个 **malloc** 会再将 **nums** 指针重置为 **NULL**(分配失败情况下)或是新分配的 25 个 **float** 中第一个的地址。最初分配的 10 个 **float** 元素的堆存储仍然处于被分配状态,但此时已无法再对其访问,因为 **nums** 指针要么指向别处,要么是 **NULL**。结果就是造成了 40 个字节 (**sizeof(float) * 10**) 的泄漏。 - -在第二次调用 **malloc** 之前,应该释放最初分配的存储空间: - -``` -float* nums = malloc(sizeof(float) * 10); /* 10 floats */ -nums[0] = 3.14f;                          /* and so on */ -free(nums);                               /** good **/ -nums = malloc(sizeof(float) * 25);        /* no leakage */ -``` - -即使没有泄漏,堆也会随着时间的推移而碎片化,需要对系统进行碎片整理。例如,假设两个最大的堆块当前的大小分别为 200MB 和 100MB。然而,这两个堆块并不连续,进程 **P** 此时又需要分配 250MB 的连续堆存储。在进行分配之前,系统可能要对堆进行 _碎片整理_ 以给 **P** 提供 250MB 连续存储空间。碎片整理很复杂,因此也很耗时。 - -内存泄漏会创建处于已分配状态但不可访问的堆块,从而会加速碎片化。因此,释放不再需要的堆存储是程序员帮助减少碎片整理需求的一种方式。 - -### 诊断内存泄漏的工具 - -有很多工具可用于分析内存效率和安全性,其中我最喜欢的是 [valgrind][11]。为了说明该工具如何处理内存泄漏,这里给出 **leaky** 示例程序: - -``` -#include -#include - -int* get_ints(unsigned n) { -  int* ptr = malloc(n * sizeof(int)); -  if (ptr != NULL) { -    unsigned i; -    for (i = 0; i < n; i++) ptr[i] = i + 1; -  } -  return ptr; -} - -void print_ints(int* ptr, unsigned n) { -  unsigned i; -  for (i = 0; i < n; i++) printf("%3i\n", ptr[i]); -} - -int main() { -  const unsigned n = 32; -  int* arr = get_ints(n); -  if (arr != NULL) print_ints(arr, n); - -  /** heap storage not yet freed... **/ -  return 0; -} -``` - -**main** 函数调用了 **get_ints** 函数,后者会试着从堆中 **malloc** 32 个 4 字节的 **int**,然后初始化动态数组(如果 **malloc** 成功)。初始化成功后,**main** 函数会调用 **print_ints**函数。程序中并没有调用 **free** 来对应 **malloc** 操作;因此,内存泄漏了。 - -如果安装了 **valgrind** 工具箱,下面的命令会检查 **leaky** 程序是否存在内存泄漏(**%** 是命令行提示符): - -``` -% valgrind --leak-check=full ./leaky -``` - -绝大部分输出都在下面给出了。左边的数字 207683 是正在执行的 **leaky** 程序的进程标识符。这份报告给出了泄漏发生位置的详细信息,本例中位置是在 **main** 函数所调用的 **get_ints** 函数中对 **malloc** 的调用处。 - -``` -==207683== HEAP SUMMARY: -==207683==   in use at exit: 128 bytes in 1 blocks -==207683==   total heap usage: 2 allocs, 1 frees, 1,152 bytes allocated -==207683==  -==207683== 128 bytes in 1 blocks are definitely lost in loss record 1 of 1 -==207683==   at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) -==207683==   by 0x109186: get_ints (in /home/marty/gc/leaky) -==207683==   by 0x109236: main (in /home/marty/gc/leaky) -==207683==  -==207683== LEAK SUMMARY: -==207683==   definitely lost: 128 bytes in 1 blocks -==207683==   indirectly lost: 0 bytes in 0 blocks -==207683==   possibly lost: 0 bytes in 0 blocks -==207683==   still reachable: 0 bytes in 0 blocks -==207683==   suppressed: 0 bytes in 0 blocks -``` - -如果把 **main** 函数改成在对 **print_ints** 的调用之后,再加上一个对 **free** 的调用,**valgrind** 就会对 **leaky** 程序给出一个干净的内存健康清单: - -``` -==218462== All heap blocks were freed -- no leaks are possible -``` - -### 静态区存储 - -在正统的 C 语言中,函数必须在所有块之外定义。这是一些 C 编译器支持的特性,杜绝了在另一个函数体内定义一个函数的可能。我举的例子都是在所有块之外定义的函数。这样的函数要么是 **static** 即静态的,要么是 **extern** 即外部的,其中 **extern** 是默认值。 - -C 语言中,以 **static** 或 **extern** 修饰的函数和变量驻留在内存中所谓的 **静态区** 中,因为在程序执行期间该区域大小是固定不变的。这两个存储类型的语法非常复杂,我们应该回顾一下。在回顾之后,会有一个完整的代码示例来生动展示语法细节。在所有块之外定义的函数或变量默认为 **extern**;因此,函数和变量要想存储类型为 **static** ,必须显式指定: - -``` -/** file1.c: outside all blocks, five definitions  **/ -int foo(int n) { return n * 2; }     /* extern by default */ -static int bar(int n) { return n; }  /* static */ -extern int baz(int n) { return -n; } /* explicitly extern */ - -int num1;        /* extern */ -static int num2; /* static */ -``` - -**extern** 和 **static** 的区别在于作用域:**extern** 修饰的函数或变量可以实现跨文件可见(需要声明)。相比之下,**static** 修饰的函数仅在 _定义_ 该函数的文件中可见,而 **static** 修饰的变量仅在 _定义_ 该变量的文件(或文件中的块)中可见: - -``` -static int n1;    /* scope is the file */ -void func() { -   static int n2; /* scope is func's body */ -   ... -} -``` - -如果在所有块之外定义了 **static** 变量,例如上面的 **n1**,该变量的作用域就是定义变量的文件。无论在何处定义 **static** 变量,变量的存储都在内存的静态区中。 - -**extern** 函数或变量在给定文件中的所有块之外定义,但这样定义的函数或变量也可以在其他文件中声明。典型的做法是在头文件中 _声明_ 这样的函数或变量,只要需要就可以包含进来。下面这些简短的例子阐述了这些棘手的问题。 - -假设 **extern** 函数 **foo** 在 **file1.c** 中 _定义_,有无关键字 **extern** 效果都一样: - -``` -/** file1.c **/ -int foo(int n) { return n * 2; } /* definition has a body {...} */ -``` - -必须在其他文件(或其中的块)中使用显式的 **extern** _声明_ 此函数才能使其可见。以下是使 **extern** 函数 **foo** 在文件 **file2.c** 中可见的声明语句: - -``` -/** file2.c: make function foo visible here **/ -extern int foo(int); /* declaration (no body) */ -``` - -回想一下,函数声明没有用大括号括起来的主体,而函数定义会有这样的主体。 - -为了便于查看,函数和变量声明通常会放在头文件中。准备好需要声明的源代码文件,然后就可以 **#include** 相关的头文件。下一节中的 **staticProg** 程序演示了这种方法。 - -至于 **extern** 的变量,规则就变得更棘手了(很抱歉增加了难度!)。任何 **extern** 的对象——无论函数或变量——必须 _定义_ 在所有块之外。此外,在所有块之外定义的变量默认为 **extern**: - -``` -/** outside all blocks **/ -int n; /* defaults to extern */ -``` - -但是,只有在变量的 _定义_ 中显式初始化变量时,**extern** 才能在变量的 _定义_ 中显式修饰(LCTT译注:换言之,如果下列代码中的 `int n1;` 行前加上 **extern**,该行就由 _定义_ 变成了 _声明_): - -``` -/** file1.c: outside all blocks **/ -int n1;             /* defaults to extern, initialized by compiler to zero */ -extern int n2 = -1; /* ok, initialized explicitly */ -int n3 = 9876;      /* ok, extern by default and initialized explicitly */ -``` - -要使在 **file1.c** 中定义为 **extern** 的变量在另一个文件(例如 **file2.c**)中可见,该变量必须在 **file2.c** 中显式 _声明_ 为 **extern** 并且不能初始化(初始化会将声明转换为定义): - -``` -/** file2.c **/ -extern int n1; /* declaration of n1 defined in file1.c */ -``` - -为了避免与 **extern** 变量混淆,经验是在 _声明_ 中显式使用 **extern**(必须),但不要在 _定义_ 中使用(非必须且棘手)。对于函数,**extern** 在定义中是可选使用的,但在声明中是必须使用的。下一节中的 **staticProg** 示例会把这些点整合到一个完整的程序中。 - -### staticProg 示例 - -**staticProg** 程序由三个文件组成:两个 C 语言源文件(**static1.c** 和 **static2.c**)以及一个头文件(**static.h**),头文件中包含两个声明: - -``` -/** header file static.h **/ -#define NumCount 100               /* macro */ -extern int global_nums[NumCount];  /* array declaration */ -extern void fill_array();          /* function declaration */ -``` - -两个声明中的 **extern**,一个用于数组,另一个用于函数,强调对象在别处(“外部”)_定义_:数组 **global_nums** 在文件 **static1.c** 中定义(没有显式的 **extern**),函数 **fill_array** 在文件 **static2.c** 中定义(也没有显式的 **extern**)。每个源文件都包含了头文件 **static.h**。**static1.c** 文件定义了两个驻留在内存静态区域中的数组(**global_nums** 和 **more_nums**)。第二个数组有 **static** 修饰,这将其作用域限制为定义数组的文件 (**static1.c**)。如前所述, **extern** 修饰的 **global_nums** 则可以实现在多个文件中可见。 - -``` -/** static1.c **/ -#include -#include - -#include "static.h"             /* declarations */ - -int global_nums[NumCount];      /* definition: extern (global) aggregate */ -static int more_nums[NumCount]; /* definition: scope limited to this file */ - -int main() { -  fill_array(); /** defined in file static2.c **/ - -  unsigned i; -  for (i = 0; i < NumCount; i++) -    more_nums[i] = i * -1; - -  /* confirm initialization worked */ -  for (i = 0; i < NumCount; i += 10)  -    printf("%4i\t%4i\n", global_nums[i], more_nums[i]); -     -  return 0;   -} -``` - -下面的 **static2.c** 文件中定义了 **fill_array** 函数,该函数由 **main**(在 **static1.c** 文件中)调用;**fill_array** 函数会给名为 **global_nums** 的 **extern** 数组中的元素赋值,该数组在文件 **static1.c** 中定义。使用两个文件的唯一目的是凸显 **extern** 变量或函数能够跨文件可见。 - -``` -/** static2.c **/ -#include "static.h" /** declarations **/ - -void fill_array() { /** definition **/ -  unsigned i; -  for (i = 0; i < NumCount; i++) global_nums[i] = i + 2; -} -``` - -**staticProg** 程序可以如下编译: - -``` -% gcc -o staticProg static1.c static2.c -``` - -### 从汇编语言看更多细节 - -现代 C 编译器能够处理 C 和汇编语言的任意组合。编译 C 源文件时,编译器首先将 C 代码翻译成汇编语言。这是对从上文 **static1.c** 文件生成的汇编语言进行保存的命令: - -``` -% gcc -S static1.c -``` - -生成的文件就是 **static1.s**。这是文件顶部的一段代码,额外添加了行号以提高可读性: - -``` -    .file    "static1.c"          ## line  1 -    .text                         ## line  2 -    .comm    global_nums,400,32   ## line  3 -    .local    more_nums           ## line  4 -    .comm    more_nums,400,32     ## line  5 -    .section    .rodata           ## line  6 -.LC0:                             ## line  7 -    .string    "%4i\t%4i\n"       ## line  8 -    .text                         ## line  9 -    .globl    main                ## line 10 -    .type    main, @function      ## line 11 -main:                             ## line 12 -... -``` - -诸如 **.file**(第 1 行)之类的汇编语言指令以句点开头。顾名思义,指令会指导汇编程序将汇编语言翻译成机器代码。**.rodata** 指令(第 6 行)表示后面是只读对象,包括字符串常量 **"%4i\t%4i\n"**(第 8 行),**main** 函数(第 12 行)会使用此字符串常量来实现格式化输出。作为标签引入(通过末尾的冒号实现)的 **main** 函数(第 12 行),同样也是只读的。 - -在汇编语言中,标签就是地址。标签 **main:**(第 12 行)标记了 **main** 函数代码开始的地址,标签 **.LC0**:(第 7 行)标记了格式化字符串开头所在的地址。 - -**global_nums**(第 3 行)和 **more_nums**(第 4 行)数组的定义包含了两个数字:400 是每个数组中的总字节数,32 是每个数组(含 100 个 **int** 元素)中每个元素的比特数。(第 5 行中的 **.comm** 指令表示 **common name**,可以忽略。) - -两个数组定义的不同之处在于 **more_nums** 被标记为 **.local**(第 4 行),这意味着其作用域仅限于其所在文件 **static1.s**。相比之下,**global_nums** 数组就能在多个文件中实现可见,包括由 **static1.c** 和 **static2.c** 文件翻译成的汇编文件。 - -最后,**.text** 指令在汇编代码段中出现了两次(第 2 行和第 9 行)。术语“text”表示“只读”,但也会涵盖一些读/写变量,例如两个数组中的元素。尽管本文展示的汇编语言是针对 Intel 架构的,但 Arm6 汇编也非常相似。对于这两种架构,**.text** 区域中的变量(本例中为两个数组中的元素)会自动初始化为零。 - -### 总结 - -C 语言中的内存高效和内存安全编程准则很容易说明,但可能会很难遵循,尤其是在调用设计不佳的库的时候。准则如下: - - * 尽可能使用栈存储,进而鼓励编译器将通用寄存器用作暂存器,实现优化。栈存储代表了高效的内存使用并促进了代码的整洁和模块化。永远不要返回指向基于栈的存储的指针。 - * 小心使用堆存储。C(和 C++)中的重难点是确保动态分配的存储尽快解除分配。良好的编程习惯和工具(如 **valgrind**)有助于攻关这些重难点。优先选用自身提供释放函数的库,例如 **nestedHeap** 代码示例中的 **free_all** 释放函数。 - * 谨慎使用静态存储,因为这种存储会自始至终地影响进程的内存占用。特别是尽量避免使用 **extern** 和 **static** 数组。 - -本文 C 语言代码示例可在我的网站 () 上找到。 - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/8/memory-programming-c - -作者:[Marty Kalin][a] -选题:[lujun9972][b] -译者:[unigeorge](https://github.com/unigeorge) -校对:[校对者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/code_computer_development_programming.png?itok=4OM29-82 (Code going into a computer.) -[2]: http://www.opengroup.org/onlinepubs/009695399/functions/fopen.html -[3]: http://www.opengroup.org/onlinepubs/009695399/functions/fclose.html -[4]: http://www.opengroup.org/onlinepubs/009695399/functions/fread.html -[5]: http://www.opengroup.org/onlinepubs/009695399/functions/fwrite.html -[6]: http://www.opengroup.org/onlinepubs/009695399/functions/printf.html -[7]: http://www.opengroup.org/onlinepubs/009695399/functions/puts.html -[8]: http://www.opengroup.org/onlinepubs/009695399/functions/malloc.html -[9]: http://www.opengroup.org/onlinepubs/009695399/functions/fprintf.html -[10]: http://www.opengroup.org/onlinepubs/009695399/functions/free.html -[11]: https://www.valgrind.org/ diff --git a/translated/tech/20210920 Use Vagrant to test your scripts on different operating systems.md b/translated/tech/20210920 Use Vagrant to test your scripts on different operating systems.md deleted file mode 100644 index 6d034b1ace..0000000000 --- a/translated/tech/20210920 Use Vagrant to test your scripts on different operating systems.md +++ /dev/null @@ -1,141 +0,0 @@ -[#]: subject: "Use Vagrant to test your scripts on different operating systems" -[#]: via: "https://opensource.com/article/21/9/test-vagrant" -[#]: author: "Ayush Sharma https://opensource.com/users/ayushsharma" -[#]: collector: "lujun9972" -[#]: translator: "geekpi" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -使用 Vagrant 在不同的操作系统上测试你的脚本 -====== -Vagrant 可以帮助你在你的电脑上运行其他操作系统,这意味着你可以构建、测试、做古怪的事情而不毁坏你的系统。 -![Business woman on laptop sitting in front of window][1] - -我使用 Vagrant 已经很长时间了。我使用几种 DevOps 工具,在一个系统上安装它们可能会变得很复杂。Vagrant 让你在不破坏系统的情况下做一些很酷的事情,因为你根本不需要在生产系统上做实验。 - -如果你熟悉 [VirtualBox][2] 或 [GNOME Boxes][3],那么学习 Vagrant 很容易。Vagrant 有一个简单而干净的界面用于处理虚拟机。一个名为 `Vagrantfile` 的配置文件,允许你定制你的虚拟机(称为 _Vagrant boxes_)。一个简单的命令行界面让你启动、停止、暂停或销毁你的 box。 - -考虑一下这个简单的例子。 - -假设你想写 Ansible 或 shell 脚本,在一个新的服务器上安装 Nginx。你不能在自己的系统上这样做,因为你可能没有运行想测试的操作系统,或者可能没有你想做的所有依赖项。启动新的云服务器进行测试可能会很费时和昂贵。这就是 Vagrant 派上用处的地方。你可以用它来启动一个虚拟机,用你的脚本来配置它,并证明一切按预期工作。然后,你可以删除这个 box,重新配置它,并重新运行你的脚本来验证它。你可以多次重复这个过程,直到你确信你的脚本在所有条件下都能工作。你可以将你的 Vagrant 文件提交给 Git,以确保你的团队正在测试完全相同的环境(因为他们将使用完全相同的测试机)。不再有“但它在我的机器上运行良好!”这事了。 - -### 开始使用 - -First,[install Vagrant on your system][4]and then create a new folder to experiment in. In this new folder, create a new file namedwith these contents: -首先,[在你的系统上安装 Vagrant][4],然后创建一个新的文件夹进行实验。在这个新文件夹中,创建一个名为 `Vagrantfile` 的新文件,内容如下: - - -``` -Vagrant.configure("2") do |config| - - config.vm.box = "ubuntu/hirsute64" - -end -``` - -你也可以运行 `vagrant init ubuntu/hirsute64`,它将为你生成一个新的 Vagrant 文件。现在运行 `vagrant up`。这个命令将从 Vagrant 仓库中下载 `ubuntu/hirsuite64` 镜像。 - - -``` -Bringing machine 'default' up with 'virtualbox' provider... -==> default: Importing base box 'ubuntu/hirsute64'... -==> default: Matching MAC address for NAT networking... -==> default: Checking if box 'ubuntu/hirsute64' version '20210820.0.0' is up to date... -==> default: Setting the name of the VM: a_default_1630204214778_76885 -==> default: Clearing any previously set network interfaces... -==> default: Preparing network interfaces based on configuration... - default: Adapter 1: nat - default: Adapter 2: hostonly -==> default: Forwarding ports... - default: 22 (guest) => 2222 (host) (adapter 1) -==> default: Running 'pre-boot' VM customizations... -==> default: Booting VM... -==> default: Waiting for machine to boot. This may take a few minutes... - default: SSH address: 127.0.0.1:2222 - default: SSH username: vagrant - default: SSH auth method: private key - default: Warning: Remote connection disconnect. Retrying... - default: Warning: Connection reset. Retrying... - default: - default: Vagrant insecure key detected. Vagrant will automatically replace - default: this with a newly generated keypair for better security. - default: - default: Inserting generated public key within guest... - default: Removing insecure key from the guest if it's present... - default: Key inserted! Disconnecting and reconnecting using new SSH key... -==> default: Machine booted and ready! -``` - -此时,如果你打开你的 Vagrant 后端(如 VirtualBox 或 virt-manager),你会看到你的 box 在那里。接下来,运行 `vagrant ssh` 登录到 box。如果你能看到 Vagrant 的提示,那么你就进入了! - - -``` -~ vagrant ssh -Welcome to Ubuntu 21.04 (GNU/Linux 5.11.0-31-generic x86_64) - -* Documentation: -* Management: -* Support: - - System information as of Sun Aug 29 02:33:51 UTC 2021 - - System load: 0.01 Processes: 110 - Usage of /: 4.1% of 38.71GB Users logged in: 0 - Memory usage: 17% IPv4 address for enp0s3: 10.0.2.15 - Swap usage: 0% IPv4 address for enp0s8: 192.168.1.20 - -0 updates can be applied immediately. - -vagrant@ubuntu-hirsute:~$ -``` - -Vagrant 使用“基础 box” 来启动你的本地机器。在我们的例子中,Vagrant 从 [Hashicorp 的 Vagrant 目录][5]下载 `ubuntu/hirsuite64` 镜像,并插入 VirtualBox 来创建实际的 box。 - -### 共享文件夹 - -Vagrant 将你的当前文件夹映射到 Vagrant box 中的 `/vagrant`。这允许你在你的系统和 box 里保持文件同步。这对于测试 Nginx 网站是很好的,通过将你的文件根目录指向 `/vagrant`。你可以使用 IDE 进行修改,box 里的 Nginx 会提供这些修改。 - -### Vagrant 命令 - -有几个 Vagrant 命令,你可以用它们来控制你的 box。 - -其中一些重要的命令是: - - * `vagrant up`:启动一个 box。 - * `vagrant status`:显示当前 box 的状态。 - * `vagrant suspend`:暂停当前的 box。 - * `vagrant resume`:恢复当前的 box。 - * `vagrant halt`:关闭当前的 box。 - * `vagrant destroy`:销毁当前的 box。通过运行此命令,你将失去存储在 box 上的任何数据。 - * `vagrant snapshot`:对当前的 box 进行快照。 - - - -### 试试 Vagrant - -Vagrant 是一个使用 DevOps 原则进行虚拟机管理的经过时间考验的工具。配置你的测试机,与你的团队分享配置,并在一个可预测和可重复的环境中测试你的项目。如果你正在开发软件,那么通过使用 Vagrant 进行测试,你将为你的用户提供良好的服务。如果你不开发软件,但你喜欢尝试新版本的操作系统,那么没有比这更简单的方法了。今天就试试 Vagrant 吧! - -* * * - -_这篇文章最初发表在[作者的个人博客][6]上,经许可后被改编。_ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/9/test-vagrant - -作者:[Ayush Sharma][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/ayushsharma -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-concentration-focus-windows-office.png?itok=-8E2ihcF (Woman using laptop concentrating) -[2]: https://opensource.com/article/21/6/try-linux-virtualbox -[3]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization -[4]: https://www.vagrantup.com/docs/installation -[5]: https://app.vagrantup.com/boxes/search -[6]: https://notes.ayushsharma.in/2021/08/introduction-to-vagrant diff --git a/translated/tech/20210930 How I use Ansible and anacron for automation.md b/translated/tech/20210930 How I use Ansible and anacron for automation.md new file mode 100644 index 0000000000..879e79cb57 --- /dev/null +++ b/translated/tech/20210930 How I use Ansible and anacron for automation.md @@ -0,0 +1,134 @@ +[#]: subject: "How I use Ansible and anacron for automation" +[#]: via: "https://opensource.com/article/21/9/ansible-anacron-automation" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lujun9972" +[#]: translator: "geekpi" +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +我如何使用 Ansible 和 anacron 实现自动化 +====== +有了 anacron,我可以把脚本和 Ansible playbooks 放到合适的地方,以完成各种琐碎的任务。 +![Woman programming][1] + +自动化是很好的 IT 和 DevOps 的理想,但根据我的经验,任何不方便的东西可能根本不存在。有很多次,我为某些任务想出了一个很好的解决方案,我甚至会编写脚本,但我没有让它真正实现自动化,因为在我工作的机器上不存在易于自动化的基础设施。 + +我最喜欢的简易自动化工具曾经是 cron 系统,它古老、可靠、面向用户,而且(除了一个我永远无法记住的调度语法)简单。然而,cron 的问题是,它假定一台电脑每天 24 小时都在工作。在错过了太多预定的备份之后,我发现了 [anacron][2],一个基于时间戳而非预定时间的 cron 系统。如果你的电脑在通常情况下运行时处于关闭状态,Anacron 会确保它在电脑重新开启时运行。创建一个作业就像把一个 shell 脚本放到三个目录中一样简单。`cron.day`、`cron.weekly` 或者 `cron.monthly` (如果你想的话,你可以定义更多)。有了 anacron,我发现自己把脚本和 Ansible playbook 放到了各种琐碎的任务中,包括弹出到期和事件提醒。 + +这是一个现代问题的简单而明显的解决方案,但如果 anacron 没有安装在电脑上,它对我没有好处。 + +### 用 Ansible 进行软件设置 + +任何时候我设置一台新的计算机,无论是笔记本电脑、工作站还是服务器,我都会安装 anacron。这很简单,但是 anacron 的安装只提供了 anacron 命令。它并没有设置 Anacron 的用户环境。所以我创建了一个 Ansible playbook 来设置用户需要什么来使用 anacron 并安装 anacron 命令。 + +首先,标准的Ansible模板: + + +``` +\--- +\- hosts: localhost + tasks: +``` + +### 用 Ansible 创建目录 + +接下来,我创建了用于 Anacron 的目录树。你可以把它看成是一种透明的 crontab。 + + +``` + - name: create directory tree + ansible.builtin.file: + path: "{{ item }}" + state: directory + with_items: + - '~/.local/etc/cron.daily' + - '~/.local/etc/cron.weekly' + - '~/.local/etc/cron.monthly' + - '~/.var/spool/anacron' +``` + +这个语法可能看起来有点奇怪,但它实际上是一个循环。`with_items:` 指令定义了四个要创建的目录,Ansible 在 `ansible.buildin.file:` 指令中为每个目录迭代一次(目录名填充了 `{{ item }}` 变量)。与 Ansible 中的一切一样,如果目录已经存在,就不会有错误或冲突。 + +### 用 Ansible 复制文件 + +`ansible.buildin.copy` 模块将文件从一个地方复制到另一个地方。为了让它工作,我需要创建一个叫做 `anacrontab` 的文件。它不是 Ansible playbook,所以我把它放在我的 `~/Ansible/data` 目录下,那里是我的 playbook 的支持文件。 + + +``` + - name: copy anacrontab into place + ansible.builtin.copy: + src: ~/Ansible/data/anacrontab + dest: ~/.local/etc/anacrontab + mode: '0755' +``` + +我的 `anacrontab` 文件很简单,模仿了一些发行版默认安装在 `/etc/anacron` 中的文件: + + +``` +SHELL=/bin/sh +PATH=/sbin:/bin:/usr/sbin:/usr/bin +1 0 cron.day run-parts $HOME/.local/etc/cron.daily/ +7 0 cron.wek run-parts $HOME/.local/etc/cron.weekly/ +30 0 cron.mon run-parts $HOME/.local/etc/cron.monthly/ +``` + +### 登录时运行 anacron + +大多数 Linux 发行版将 anacron 配置为从 `/etc/anacron` 读取作业。我主要是作为一个普通用户使用 anacron,所以我从我的登录账号 `~/.profile`启动 anacron。我不想让自己记住这些配置,所以我让 Ansible 来做。我使用 `ansible.buildin.lineinfile` 模块,它会在 `~/.profile` 不存在时创建它,并插入 anacron 的启动行。 + + +``` + - name: add local anacrontab to .profile + ansible.builtin.lineinfile: + path: ~/.profile + regexp: '^/usr/sbin/anacron' + line: '/usr/sbin/anacron -t ~/.local/etc/anacrontab' + create: true +``` + +### 用 Ansible 安装 anacron + +对于我的大多数系统来说,`dnf` 模块可以用来安装软件包,但我的工作站运行的是 Slackware(使用 `slackpkg`),有时不同的 Linux 发行版也会进入我的收藏。`ansible.buildin.package` 模块提供了一个安装软件包的通用接口,所以我把它用在这个 playbook 上。幸运的是,我还没有遇到一个仓库将 `anacron` 命名为 `anacron`,所以现在,我不必考虑软件包名称的潜在差异。 + +这实际上是一个单独的 playbook,因为软件包的安装需要权限升级,它由 `becomes: true` 指令提供。 + + +``` +\- hosts: localhost + become: true + tasks: + - name: install anacron + ansible.builtin.package: + name: anacron + state: present +``` + +### 使用 anacron 和 Ansible 实现轻松自动化 + +为了用 Ansible 安装 anacron,我运行 playbook: + + +``` +`$ ansible-playbook ~/Ansible/setup-anacron.yaml` +``` + +从这里起,我就可以编写 shell 脚本来执行一些琐碎但重复的任务,然后把它复制到 `~/.local/etc/cron.daily`,让它每天自动运行一次(或者大约如此)。我还为诸如[清理下载文件夹][3]之类的任务编写了 Ansible playbook。我把我的 playbook 放在 `~/Ansible` 里,这是我保存 Ansible playbook 的地方,然后在 `~/.local/etc/cron.daily` 里创建一个 shell 脚本来执行这个 playbook。这很简单,不费吹灰之力,而且很快第二天也自然如此。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/9/ansible-anacron-automation + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop-music-headphones.png?itok=EQZ2WKzy (Woman programming) +[2]: https://opensource.com/article/21/2/linux-automation +[3]: https://opensource.com/article/21/9/keep-folders-tidy-ansible diff --git a/translated/tech/20211008 3 new features of the latest OpenPGP.js version.md b/translated/tech/20211008 3 new features of the latest OpenPGP.js version.md new file mode 100644 index 0000000000..0fc380ce85 --- /dev/null +++ b/translated/tech/20211008 3 new features of the latest OpenPGP.js version.md @@ -0,0 +1,70 @@ +[#]: subject: "3 new features of the latest OpenPGP.js version" +[#]: via: "https://opensource.com/article/21/10/openpgpjs" +[#]: author: "Daniel Huigens https://opensource.com/users/twiss" +[#]: collector: "lujun9972" +[#]: translator: "geekpi" +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +最新 OpenPGP.js 版本的 3 个新功能 +====== +OpenPGP.js 是一个实现了 OpenPGP 标准的密码学库,最常用于电子邮件加密。 +![email or newsletters via inbox and browser][1] + +[OpenPGP.js][2]是一个实现了 [OpenPGP 标准][3]的密码学库,最常用于电子邮件加密。ProtonMail、Mailvelope 和 FlowCrypt 都使用 OpenPGP.js,这仅仅是其中一些。这意味着 OpenPGP.js 库对数百万用户的信息进行了加密。 + +OpenPGP 标准首次发布于 20 世纪 90 年代,像几乎任何东西一样,需要维护和更新,以保证安全和可用性。该标准的“加密刷新”[正在进行中][4],它增加了现代的加密算法并废除了过时的算法。为了提高可用性,各种电子邮件应用程序现在允许用户无缝加密他们的通信,用户无需管理他们的密钥或他们的联系人的密钥。 + +OpenPGP.js 于 2014 年首次发布,开始基于一个名为 GPG4Browsers 的早期原型,该原型基于 Herbert Hanewinkel(以及其他贡献者)的几个脚本。OpenPGP.js 的第二个版本于 2016 年发布,完全重新设计,使用 Uint8Arrays 而不是字符串(这大大增加了其性能),并在内部使用现代 ES6 模块而不是 CommonJS 模块。第 3 和第 4 版都是在 2018 年发布的,分别增加了对椭圆曲线加密法(ECC)和流媒体的支持。 + +我和我的团队继续在 OpenPGP.js 上工作,以确保其发展为一个易于使用的强加密库。 + +### 1\. 默认的椭圆曲线加密 + +在 OpenPGP.js 第 4 版中,生成新密钥时默认使用 RSA。虽然 ECC 更快、更安全,但 Curve25519 还没有在 OpenPGP 规范中得到标准化。加密刷新草案包括了 Curve25519,并且预计它将“按原样”包含在下一版本的 OpenPGP 规范中,因此 OpenPGP.js 第 5 版现在默认使用 ECC 生成密钥。 + +### 2\. 只导入你需要的模块 + +同样,虽然 OpenPGP.js 内部使用 ES6 模块多年,但第 4 版仍然没有发布一个合适的 ES6 模块。相反,它只发布了一个通用模块定义(UMD)模块,可以在浏览器和 Node.js 上运行。在第 5 版中,这种情况有所改变,为浏览器和 Node.js 发布了单独的模块(包括 ES6 和非 ES6),使库用户更容易在所有平台上导入 OpenPGP.js ,且(当使用 ES6 模块时)只导入他们需要的部分。这在很大程度上是通过将构建系统切换到 [rollup][5] 来实现的。 + +### 3\. 拒绝弱加密技术 + +还有许多其他的安全改进。例如,1024 位 RSA 密钥、ElGamal 和 DSA 密钥被认为是不安全的,并被默认拒绝。此外,第 4 版已经默认使用 AES 加密,第 5 版现在完全默认拒绝使用较弱的算法进行加密,即使公钥声称只支持较弱的算法。相反,它假定所有的 OpenPGP 实现都支持 AES(这种情况已经存在很长时间了)。 + +### OpenPGP.js 的下一步是什么? + +展望未来,有一些安全方面的改进要做。用于识别公钥的密钥指纹仍然使用 SHA-1,尽管在加密技术更新中计划对此进行修复。同时,建议使用不同的方法来确定用于加密的任何公钥的真实性,例如使用提议的[网络密钥目录 (WKD)][6]标准直接从收件人的域中获取整个密钥,这已经由各种[电子邮件提供商][7]实现。WKD 支持内置于 OpenPGP.js 第 4 版,但在第 5 版中是一个单独的模块,以保持主库的精简。 + +同样,当用密码而不是公钥加密信息或文件时(例如:在使用 OpenPGP 进行电子邮件加密时不常见,但在用于加密备份时更常见),密码会使用相对较弱的密钥衍生函数(KDF)转换为对称密钥。因此,建议应用在将用户的密码传递给 OpenPGP.js 之前,先通过一个强大的 KDF,如 [Argon2][8] 或 [scrypt][9]。希望加密技术的刷新会包括这些算法中的一种,以便在未来的 OpenPGP.js 版本中实现。 + +### 如何使用 OpenPGP.js 第 5 版 + +不过现在,OpenPGP.js 第 5 版已经[发布][10]到 npm 仓库。如果你喜欢,可以随时试用!欢迎在 GitHub 的[讨论标签][11]中进行反馈。然而,请注意,虽然 OpenPGP.js 是一个通用的加密库,但它的主要使用情况是在需要与 OpenPGP 规范兼容的情况下(例如,在发送或接收 PGP 加密的电子邮件时)。对于其他的使用情况,不同的库可能是一个更合适或性能更好的选择。当然,总的来说,在推广任何加密技术时都要小心。 + +感谢阅读,这里是保护电子邮件的未来! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/10/openpgpjs + +作者:[Daniel Huigens][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/twiss +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/newsletter_email_mail_web_browser.jpg?itok=Lo91H9UH (email or newsletters via inbox and browser) +[2]: https://github.com/openpgpjs/openpgpjs +[3]: https://tools.ietf.org/html/rfc4880 +[4]: https://datatracker.ietf.org/doc/charter-ietf-openpgp/ +[5]: https://rollupjs.org/ +[6]: https://datatracker.ietf.org/doc/html/draft-koch-openpgp-webkey-service +[7]: https://wiki.gnupg.org/WKD#Mail_Service_Providers_offering_WKD +[8]: https://en.wikipedia.org/wiki/Argon2 +[9]: https://en.wikipedia.org/wiki/Scrypt +[10]: https://www.npmjs.com/package/openpgp +[11]: https://github.com/openpgpjs/openpgpjs/discussions diff --git a/translated/tech/20211008 How to Install Vivaldi Browser on Ubuntu and Other Linux Distributions.md b/translated/tech/20211008 How to Install Vivaldi Browser on Ubuntu and Other Linux Distributions.md new file mode 100644 index 0000000000..31dd4d01c2 --- /dev/null +++ b/translated/tech/20211008 How to Install Vivaldi Browser on Ubuntu and Other Linux Distributions.md @@ -0,0 +1,159 @@ +[#]: subject: "How to Install Vivaldi Browser on Ubuntu and Other Linux Distributions" +[#]: via: "https://itsfoss.com/install-vivaldi-ubuntu-linux/" +[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" +[#]: collector: "lujun9972" +[#]: translator: "imgradeone" +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +如何在 Ubuntu 和其他 Linux 发行版中安装 Vivaldi 浏览器 +====== + +> 您将在本篇新手教程中学习如何在 Ubuntu、Debian 及其他 Linux 发行版中安装 Vivaldi 网页浏览器,同时本教程也将介绍如何更新和卸载该软件。 + +[Vivaldi][1] 是一款关注度逐步上升的网页浏览器。它基于 Chromium 内核,因此它拥有和 Chrome 类似的功能,但它也新增了一些其他特色功能,让这款浏览器与众不同、更为直观。 + +它内置了标签组、广告拦截、鼠标手势、笔记管理,甚至还有命令连锁。你甚至可以借助页面平铺来一次性浏览多个页面。当然,相比于 Chrome,Vivaldi 更加尊重你的隐私。 + +![页面平铺,一次性浏览多个页面][2] + +你可以从 [Manjaro Linux 近期使用 Vivaldi 取代 Firefox 作为部分分支的默认浏览器][3] 这件事来了解 Vivaldi 浏览器的受欢迎程度。 + +如果你想尝试一下这款浏览器的话,接下来让我告诉你,如何在 Linux 上安装 Vivaldi。你将了解到: + + * 安装 Vivaldi 的 GUI 和命令行方式 + * 将 Vivaldi 更新到最新版本的提示 + * 在 Ubuntu 中卸载 Vivaldi 的方式 + +> 非自由软件(Non-FOSS)警告! +> +> Vivaldi 并非完全的开源软件。它的 UI 界面是闭源的。之所以在这里介绍这款浏览器,是因为 Vivaldi 团队正努力让该软件在 Linux 平台上可用。 + +### 在 Ubuntu 中安装 Vivaldi [GUI 方式] + +好消息是,Vivaldi 提供了预先构建好的安装包,包括 Ubuntu/Debian 的 DEB 文件,以及 Fedora、Red Hat、SUSE 的 RPM 文件、 + +它支持 32 位和 64 位平台,也支持 [像树莓派之类的 ARM 设备][4]。 + +![Vivaldi 为各类 Linux 发行版提供了安装包][5] + +安装过程非常简单。你只需要前往 Vivaldi 的官网下载正确的安装包文件,双击打开,然后安装,大功告成。 + +我将详细介绍在 Ubuntu/Debian 下的安装过程。对于其他类型的发行版,你可以使用类似的步骤。 + +#### 第 1 步:下载 Vivaldi + +前往 Vivaldi 的下载页面,下载支持 Ubuntu 的 DEB 格式安装包。 + +[下载 Vivaldi][6] + +![下载支持 Ubuntu/Debian 的 DEB 安装包][7] + +#### 第 2 步:安装刚刚下载的 DEB 文件 + +前往你刚刚下载 DEB 文件的下载文件夹。[安装 DEB 文件][8] 非常简单,只需要双击打开,或者右键后使用软件中心打开即可。 + +![右键点击下载的 DEB 文件并用软件中心打开以安装][9] + +这将打开软件中心,在这里可以看到安装 Vivaldi 的选项。点击安装按钮即可。 + +![点击安装按钮][10] + +您将需要输入系统账户的密码,输入密码授权后,Vivaldi 很快就能完成安装,随后安装按钮也变成了移除按钮。这表明 Vivaldi 已经安装完成了。 + +#### 第 3 步:使用 Vivaldi + +按下 Super(Windows)键打开系统菜单,搜索 Vivaldi,然后单击 Vivaldi 的图标。 + +![在系统菜单中搜索 Vivaldi][11] + +首次启动时,你将看到如下界面。 + +![运行于 Ubuntu 的 Vivaldi][12] + +既然你已经知道了这个方法,那我接下来将展示在 Ubuntu/Debian 使用终端安装 Vivaldi 的方法。 + +### 方式 2:借助终端,在 Ubuntu/Debian 上安装 Vivaldi + +打开终端,确认你已经安装了用于 [在命令行下下载文件][13] 的 wget。 + +``` +sudo apt install wget +``` + +接下来,获取 Vivaldi 仓库的公钥并添加到系统,以让系统信任该来源的软件包。如果你感兴趣的话,你可以阅读 [关于在 Ubuntu 添加第三方软件仓库的文章][14]。 + +``` +wget -qO- https://repo.vivaldi.com/archive/linux_signing_key.pub | sudo apt-key add - +``` + +添加完该密钥后,再添加 Vivaldi 的仓库: + +``` +sudo add-apt-repository 'deb https://repo.vivaldi.com/archive/deb/ stable main' +``` + +现在距离完成也只有一步之遥了。更新软件仓库缓存并安装 Vivaldi。 + +``` +sudo apt update && sudo apt install vivaldi-stable +``` + +大功告成。现在,前往系统菜单搜索并启动 Vivaldi 吧。 + +### 在 Ubuntu 中更新 Vivaldi + +GUI 和命令行这两种方式都会在系统里添加 Vivaldi 的仓库。这意味着,只要 Vivaldi 发布了新版本,你就可以在系统更新中一并获取 Vivaldi 的更新。 + +![已添加到系统中的 Vivaldi 仓库][15] + +一般情况下,你更新 Ubuntu 系统时,如果 Vivaldi 发布了新版本,那么 Vivaldi 也同时会被更新。 + +![Vivaldi 浏览器会跟随系统更新][16] + +### 在 Ubuntu 中卸载 Vivaldi + +如果你不喜欢 Vivaldi 或者不再使用,你可以直接卸载。现在,如果你想 [在 Ubuntu 中卸载软件][17],你可能会想到软件中心,但软件中心不会查找到外部和第三方的软件包。 + +目前你必须使用终端卸载 Vivaldi,即便你使用 GUI 方式安装。其实这也很简单,打开终端,输入以下命令: + +``` +sudo apt remove vivaldi-stable +``` + +sudo 会 [在 Ubuntu 中给予你 root 权限][18]。你需要输入当前账户的密码。输入密码时,你可能不会在屏幕上看见输入密码的痕迹。这是正常现象,直接输入密码即可,随后 Vivaldi 将被卸载。 + +希望这篇关于如何在 Linux 安装 Vivaldi 的教程对你有用。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-vivaldi-ubuntu-linux/ + +作者:[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://vivaldi.com/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/tab-tiling.webp?resize=800%2C448&ssl=1 +[3]: https://news.itsfoss.com/vivaldi-replaces-firefox-manjaro/ +[4]: https://itsfoss.com/raspberry-pi-alternatives/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/downloading-vivaldi-linux.webp?resize=800%2C541&ssl=1 +[6]: https://vivaldi.com/download/ +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/vivaldi-download-linux.webp?resize=800%2C438&ssl=1 +[8]: https://itsfoss.com/install-deb-files-ubuntu/ +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/installing-vivaldi-ubuntu.webp?resize=800%2C466&ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/10/install-vivaldi-ubuntu-software.png?resize=800%2C407&ssl=1 +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/10/running-vivaldi-in-ubuntu.png?resize=703%2C229&ssl=1 +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/10/Vivaldi-in-Ubuntu.webp?resize=800%2C450&ssl=1 +[13]: https://itsfoss.com/download-files-from-linux-terminal/ +[14]: https://itsfoss.com/adding-external-repositories-ubuntu/ +[15]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/Vivaldi-repo-ubuntu.png?resize=800%2C403&ssl=1 +[16]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/chrome-edge-update-ubuntu.png?resize=716%2C421&ssl=1 +[17]: https://itsfoss.com/uninstall-programs-ubuntu/ +[18]: https://itsfoss.com/root-user-ubuntu/