diff --git a/published/20210101 Djinn- A Code Generator and Templating Language Inspired by Jinja2.md b/published/20210101 Djinn- A Code Generator and Templating Language Inspired by Jinja2.md new file mode 100644 index 0000000000..e4fac67c25 --- /dev/null +++ b/published/20210101 Djinn- A Code Generator and Templating Language Inspired by Jinja2.md @@ -0,0 +1,267 @@ +[#]: collector: (lujun9972) +[#]: translator: (hanszhao80) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14792-1.html) +[#]: subject: (Djinn: A Code Generator and Templating Language Inspired by Jinja2) +[#]: via: (https://theartofmachinery.com/2021/01/01/djinn.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +Djinn:一个受 Jinja2 启发的代码生成器和模板语言 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/04/101711nq2we7z7x7wz2z7e.jpg) + +代码生成器是非常有用的工具。我有时使用 [jinja2][1] 的命令行版本来生成高度冗余的配置文件和其他文本文件,但它在转换数据方面功能有限。显然,Jinja2 的作者有不同的想法,而我想要类似于 列表推导list comprehensions 或 D 语言的 可组合范围composable range 算法之类的东西。 + +我决定制作一个类似于 Jinja2 的工具,但让我可以通过使用范围算法转换数据来生成复杂的文件。这个想法非常简单:一个直接用 D 语言代码重写的模板语言。因为它 _就是_ D 语言,它可以支持 D 语言所能做的一切。我想要一个独立的代码生成器,但是由于 [D 语言的 `mixin` 特性][2],同样的模板语言可以作为嵌入式模板语言工作(例如,Web 应用程序中的 HTML)。有关该技巧的更多信息,请参阅 [这篇关于在编译时使用 mixins 将 Brainfuck 转换为 D 和机器代码的文章][3]。 + +像往常一样,[源码在 GitLab 上][4]。[这篇文章中的例子也可以在这里找到][5]。 + +### Hello world 示例 + +这是一个演示这个想法的例子: + +``` +Hello [= retro("dlrow") ]! +[: enum one = 1; :] +1 + 1 = [= one + one ] +``` + +`[= some_expression ]` 类似于 Jinja2 中的 `{{ some_expression }}`,它在输出中呈现一个值。`[: some_statement; :]` 类似于 `{% some_statement %}` ,用于执行完整的代码语句。我更改了语法,因为 D 也大量使用花括号,并且将两者混合使模板难以阅读(还有一些特殊的非 D 指令,比如 `include`,它们被包裹在 `[<` 和 `>]` 中)。 + +如果你将上面的内容保存到一个名为 `hello.txt.dj` 的文件中并运行 `djinn` 命令行工具,你会得到一个名为 `hello.txt` 的文件,其中包含你可能猜到的内容: + +``` +Hello world! +1 + 1 = 2 +``` + +如果你使用过 Jinja2,你可能想知道第二行发生了什么。Djinn 有一个简化格式化和空格处理的特殊规则:如果源代码行包含 `[:` 语句或 `[<` 指令但不包含任何非空格输出,则整行都会被忽略输出。空行则仍会原样呈现。 + +### 生成数据 + +好的,现在来讲一些更实用的东西:生成 CSV 数据。 + +``` +x,f(x) +[: import std.mathspecial; +foreach (x; iota(-1.0, 1.0, 0.1)) :] +[= "%0.1f,%g", x, normalDistribution(x) ] +``` + +一个 `[=` 和 `]` 对可以包含多个用逗号分隔的表达式。如果第一个表达式是一个由双引号包裹的字符串,则会被解释为 [格式化字符串][6]。下面是输出结果: + +``` +x,f(x) +-1.0,0.158655 +-0.9,0.18406 +-0.8,0.211855 +-0.7,0.241964 +-0.6,0.274253 +-0.5,0.308538 +-0.4,0.344578 +-0.3,0.382089 +-0.2,0.42074 +-0.1,0.460172 +0.0,0.5 +0.1,0.539828 +0.2,0.57926 +0.3,0.617911 +0.4,0.655422 +0.5,0.691462 +0.6,0.725747 +0.7,0.758036 +0.8,0.788145 +0.9,0.81594 +``` + +### 制作图片 + +这个例子展示了一个图片的生成过程。[经典的 Netpbm 图像库定义了一堆图像格式][7],其中一些是基于文本的。例如,这是一个 3 x 3 向量的图像: + +``` +P2 # PGM 格式标识 +3 3 # 宽和高 +7 # 代表纯白色的值(0 代表黑色) +7 0 7 +0 0 0 +7 0 7 +``` + +你可以将上述文本保存到名为 `cross.pgm` 之类的文件中,很多图像工具都知道如何解析它。下面是一些 Djinn 代码,它以相同的格式生成 [Mandelbrot 集][8] 分形: + +``` +[: +import std.complex; +enum W = 640; +enum H = 480; +enum kMaxIter = 20; +ubyte mb(uint x, uint y) +{ + const c = complex(3.0 * (x - W / 1.5) / W, 2.0 * (y - H / 2.0) / H); + auto z = complex(0.0); + ubyte ret = kMaxIter; + while (abs(z) <= 2 && --ret) z = z * z + c; + return ret; +} +:] +P2 +[= W ] [= H ] +[= kMaxIter ] +[: foreach (y; 0..H) :] +[= "%(%s %)", iota(W).map!(x => mb(x, y)) ] +``` + +生成的文件大约为 800 kB,但它可以很好地被压缩为 PNG: + +``` +$ # 使用 GraphicsMagick 进行转换 +$ gm convert mandelbrot.pgm mandelbrot.png +``` + +结果如下: + +![][9] + +### 解决谜题 + +这里有一个谜题: + +![][10] + +一个 5 行 5 列的网格需要用 1 到 5 的数字填充,每个数字在每一行中限使用一次,在每列中限使用一次(即,制作一个 5 行 5 列的拉丁方格Latin square)。相邻单元格中的数字还必须满足所有 `>` 大于号表示的不等式。 + +[几个月前我使用了 线性规划linear programming(LP)][11]。线性规划问题是具有线性约束的连续变量系统。这次我将使用混合整数线性规划mixed integer linear programming(MILP),它通过允许整数约束变量来归纳 LP。事实证明,这足以成为 NP 完备的,而 MILP 恰好可以很好地模拟这个谜题。 + +在上一篇文章中,我使用 Julia 库 JuMP 来帮助解决这个问题。这次我将使用 [CPLEX:基于文本的格式][12],它受到多个 LP 和 MILP 求解器的支持(如果需要,可以通过现成的工具轻松转换为其他格式)。这是上一篇文章中 CPLEX 格式的 LP: + +``` +Minimize + obj: v +Subject To + ptotal: pr + pp + ps = 1 + rock: 4 ps - 5 pp - v <= 0 + paper: 5 pr - 8 ps - v <= 0 + scissors: 8 pp - 4 pr - v <= 0 +Bounds + 0 <= pr <= 1 + 0 <= pp <= 1 + 0 <= ps <= 1 +End +``` + +CPLEX 格式易于阅读,但复杂度高的问题需要大量变量和约束来建模,这使得手工编码既痛苦又容易出错。有一些特定领域的语言,例如 [ZIMPL][13],用于以高级方式描述 MILP 和 LP。对于许多问题来说,它们非常酷,但最终它们不如具有良好库(如 JuMP)支持的通用语言或使用 D 语言的代码生成器那样富有表现力。 + +我将使用两组变量来模拟这个谜题:`v_{r,c}` 和 `i_{r,c,v}`。`v_{r,c}` 将保存 r 行 c 列单元格的值(从 1 到 5)。`i_{r,c,v}` 是一个二进制指示器,如果 r 行 c 列的单元格的值是 v,则该指示器值为 1,否则为 0。这两组变量是网格的冗余表示,但第一种表示更容易对不等式约束进行建模,而第二种表示更容易对唯一性约束进行建模。我只需要添加一些额外的约束来强制这两个表示是一致的。但首先,让我们从每个单元格必须只有一个值的基本约束开始。从数学上讲,这意味着给定行和列的所有指示器都必须为 0,但只有一个值为 1 的例外。这可以通过以下等式强制约束: + +``` +[i_{r,c,1} + i_{r,c,2} + i_{r,c,3} + i_{r,c,4} + i_{r,c,5} = 1] +``` + +可以使用以下 Djinn 代码生成对所有行和列的 CPLEX 约束: + +``` +\ 单元格只有一个值 +[: +foreach (r; iota(N)) +foreach (c; iota(N)) +:] + [= "%-(%s + %)", vs.map!(v => ivar(r, c, v)) ] = 1 +[::] +``` + +`ivar()` 是一个辅助函数,它为我们提供变量名为 `i` 的字符串标识符,而 `vs` 存储从 1 到 5 的数字以方便使用。行和列内唯一性的约束完全相同,但在 `i` 的其他两个维度上迭代。 + +为了使变量组 `i` 与变量组 `v` 保持一致,我们需要如下约束(请记住,变量组 `i` 中只有一个元素的值是非零的): + +``` +[i_{r,c,1} + 2i_{r,c,2} + 3i_{r,c,3} + 4i_{r,c,4} + 5i_{r,c,5} = v_{r,c}] +``` + +CPLEX 要求所有变量都位于左侧,因此 Djinn 代码如下所示: + +``` +\ 连接变量组 i 和变量组 v +[: +foreach (r; iota(N)) +foreach (c; iota(N)) +:] + [= "%-(%s + %)", vs.map!(v => text(v, ' ', ivar(r, c, v))) ] - [= vvar(r,c) ] = 0 +[::] +``` + +不等符号相邻的和左下角值为为 4 单元格的约束写起来都很简单。剩下的便是将指示器变量声明为二进制,并为变量组 `v` 设置边界。加上变量的边界,总共有 150 个变量和 111 个约束 [你可以在仓库中看到完整的代码][14]。 + +[GNU 线性规划工具集][15] 有一个命令行工具可以解决这个 CPLEX MILP。不幸的是,它的输出是一个包含了所有内容的体积很大的转储,所以我使用 awk 命令来提取需要的内容: + +``` +$ time glpsol --lp inequality.lp -o /dev/stdout | awk '/v[0-9][0-9]/ { print $2, $4 }' | sort +v00 1 +v01 3 +v02 2 +v03 5 +v04 4 +v10 2 +v11 5 +v12 4 +v13 1 +v14 3 +v20 3 +v21 1 +v22 5 +v23 4 +v24 2 +v30 5 +v31 4 +v32 3 +v33 2 +v34 1 +v40 4 +v41 2 +v42 1 +v43 3 +v44 5 + +real 0m0.114s +user 0m0.106s +sys 0m0.005s +``` + +这是在原始网格中写出的解决方案: + +![][16] + +这些例子只是用来玩的,但我相信你已经明白了。顺便说一下,Djinn 代码仓库的 `README.md` 文件本身是使用 Djinn 模板生成的。 + +正如我所说,Djinn 也可以用作嵌入在 D 语言代码中的编译期模板语言。我最初只是想要一个代码生成器,得益于 D 语言的元编程功能,这算是一个额外获得的功能。 + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2021/01/01/djinn.html + +作者:[Simon Arneaud][a] +选题:[lujun9972][b] +译者:[hanszhao80](https://github.com/hanszhao80) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: https://jinja2docs.readthedocs.io/en/stable/ +[2]: https://dlang.org/articles/mixin.html +[3]: https://theartofmachinery.com/2017/12/31/compile_time_brainfuck.html +[4]: https://gitlab.com/sarneaud/djinn +[5]: https://gitlab.com/sarneaud/djinn/-/tree/v0.1.0/examples +[6]: https://dlang.org/phobos/std_format.html#format-string +[7]: http://netpbm.sourceforge.net/doc/#formats +[8]: https://en.wikipedia.org/wiki/Mandelbrot_set +[9]: https://theartofmachinery.com/images/djinn/mandelbrot.png +[10]: https://theartofmachinery.com/images/djinn/inequality.svg +[11]: https://theartofmachinery.com/2020/05/21/glico_weighted_rock_paper_scissors.html +[12]: http://lpsolve.sourceforge.net/5.0/CPLEX-format.htm +[13]: https://zimpl.zib.de/ +[14]: https://gitlab.com/sarneaud/djinn/-/tree/v0.1.0/examples/inequality.lp.dj +[15]: https://www.gnu.org/software/glpk/ +[16]: https://theartofmachinery.com/images/djinn/inequality_solution.svg diff --git a/published/20210107 A hands-on tutorial for using the GNU Project Debugger.md b/published/20210107 A hands-on tutorial for using the GNU Project Debugger.md new file mode 100644 index 0000000000..d4efbf9e65 --- /dev/null +++ b/published/20210107 A hands-on tutorial for using the GNU Project Debugger.md @@ -0,0 +1,547 @@ +[#]: subject: "A hands-on tutorial for using the GNU Project Debugger" +[#]: via: "https://opensource.com/article/21/1/gnu-project-debugger" +[#]: author: "Stephan Avenwedde https://opensource.com/users/hansic99" +[#]: collector: "lkxed" +[#]: translator: "Maisie-x" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14853-1.html" + +手把手教你使用 GNU 调试器 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/22/122211c2fgo53m9tw3xe2p.jpg) + +> GNU 调试器是一个发现程序缺陷的强大工具。 + +如果你是一个程序员,想在你的软件增加某些功能,你首先考虑实现它的方法:例如写一个方法、定义一个类,或者创建新的数据类型。然后你用编译器或解释器可以理解的编程语言来实现这个功能。但是,如果你觉得你所有代码都正确,但是编译器或解释器依然无法理解你的指令怎么办?如果软件大多数情况下都运行良好,但是在某些环境下出现缺陷怎么办?这种情况下,你得知道如何正确使用调试器找到问题的根源。 + +GNU 调试器GNU Project Debugger([GDB][2])是一个发现项目缺陷的强大工具。它通过追踪程序运行过程中发生了什么来帮助你发现程序错误或崩溃的原因。(LCTT 校注:GDB 全程是“GNU Project Debugger”,即 “GNU 项目调试器”,但是通常我们简称为“GNU 调试器”) + +本文是 GDB 基本用法的实践教程。请跟随示例,打开命令行并克隆此仓库: + +``` +git clone https://github.com/hANSIc99/core_dump_example.git +``` + +### 快捷方式 + +GDB 的每条命令都可以缩短。例如:显示设定的断点的 `info break` 命令可以被缩短为 `i break`。你可能在其他地方看到过这种缩写,但在本文中,为了清晰展现使用的函数,我将所写出整个命令。 + +### 命令行参数 + +你可以将 GDB 附加到每个可执行文件。进入你克隆的仓库(`core_dump_example`),运行 `make` 进行编译。你现在能看到一个名为 `coredump` 的可执行文件。(更多信息,请参考我的文章《[创建和调试 Linux 的转储文件][3]》。) + +要将 GDB 附加到这个可执行文件,请输入: `gdb coredump`。 + +你的输出应如下所示: + +![gdb coredump output][4] + +返回结果显示没有找到调试符号。 + +调试信息是目标文件object file(可执行文件)的组成部分,调试信息包括数据类型、函数签名、源代码和操作码之间的关系。此时,你有两种选择: + +* 继续调试汇编代码(参见下文“无符号调试”) +* 使用调试信息进行编译,参见下一节内容 + +### 使用调试信息进行编译 + +为了在二进制文件中包含调试信息,你必须重新编译。打开 `Makefile`,删除第 9 行的注释标签(`#`)后重新编译: + +``` +CFLAGS =-Wall -Werror -std=c++11 -g +``` + +`-g` 告诉编译器包含调试信息。运行 `make clean`,接着运行 `make`,然后再次调用 GDB。你得到如下输出后就可以调试代码了: + +![GDB output with symbols][5] + +新增的调试信息会增加可执行文件的大小。在这种情况下,执行文件增加了 2.5 倍(从 26,088 字节 增加到 65,480 字节)。 + +输入 `run -c1`,使用 `-c1` 开关启动程序。当程序运行到达 `State_4` 时将崩溃: + +![gdb output crash on c1 switch][6] + +你可以检索有关程序的其他信息,`info source` 命令提供了当前文件的信息: + +![gdb info source output][7] + +* 101 行代码 +* 语言: C++ +* 编译器(版本、调优、架构、调试标志、语言标准) +* 调试格式:[DWARF 2][8] +* 没有预处理器宏指令(使用 GCC 编译时,宏仅在 [使用 -g3 标志编译][9] 时可用)。 + +`info shared` 命令打印了动态库列表机器在虚拟地址空间的地址,它们在启动时被加载到该地址,以便程序运行: + +![gdb info shared output][10] + +如果你想了解 Linux 中的库处理方式,请参见我的文章 [在 Linux 中如何处理动态库和静态库][11]。 + +### 调试程序 + +你可能已经注意到,你可以在 GDB 中使用 `run` 命令启动程序。`run` 命令接受命令行参数,就像从控制台启动程序一样。`-c1` 开关会导致程序在第 4 阶段崩溃。要从头开始运行程序,你不用退出 GDB,只需再次运行 `run` 命令。如果没有 `-c1` 开关,程序将陷入死循环,你必须使用 `Ctrl+C` 来结束死循环。 + +![gdb output stopped by sigint][12] + +你也可以一步一步运行程序。在 C/C++ 中,入口是 `main` 函数。使用 `list main` 命令打开显示 `main` 函数的部分源代码: + +![gdb output list main][13] + +`main` 函数在第 33 行,因此可以输入 `break 33` 在 33 行添加断点: + +![gdb output breakpoint added][14] + +输入 `run` 运行程序。正如预期的那样,程序在 `main` 函数处停止。输入 `layout src` 并排查看源代码: + +![gdb output break at main][15] + +你现在处于 GDB 的文本用户界面(TUI)模式。可以使用键盘向上和向下箭头键滚动查看源代码。 + +GDB 高亮显示当前执行行。你可以输入 `next`(`n`)命令逐行执行命令。如果你没有指定新的命令,GBD 会执行上一条命令。要逐行运行代码,只需按回车键。 + +有时,你会发现文本的输出有点显示不正常: + +![gdb output corrupted][16] + +如果发生这种情况,请按 `Ctrl+L` 重置屏幕。 + +使用 `Ctrl+X+A` 可以随时进入和退出 TUI 模式。你可以在手册中找到 [其他的键绑定][17] 。 + +要退出 GDB,只需输入 `quit`。 + +### 设置监察点 + +这个示例程序的核心是一个在无限循环中运行的状态机。`n_state` 变量枚举了当前所有状态: + +``` +while(true){ +        switch(n_state){ +        case State_1: +                std::cout << "State_1 reached" << std::flush; +                n_state = State_2; +                break; +        case State_2: +                std::cout << "State_2 reached" << std::flush; +                n_state = State_3; +                break; +        +        (.....) +        +        } +} +``` + +如果你希望当 `n_state` 的值为 `State_5` 时停止程序。为此,请在 `main` 函数处停止程序并为 `n_state` 设置监察点: + +``` +watch n_state == State_5 +``` + +只有当所需的变量在当前上下文中可用时,使用变量名设置监察点才有效。 + +当你输入 `continue` 继续运行程序时,你会得到如下输出: + +![gdb output stop on watchpoint_1][18] + +如果你继续运行程序,当监察点表达式评估为 `false` 时 GDB 将停止: + +![gdb output stop on watchpoint_2][19] + +你可以为一般的值变化、特定的值、读取或写入时来设置监察点。 + +### 更改断点和监察点 + +输入 `info watchpoints` 打印先前设置的监察点列表: + +![gdb output info watchpoints][20] + +#### 删除断点和监察点 + +如你所见,监察点就是数字。要删除特定的监察点,请先输入 `delete` 后输入监察点的编号。例如,我的监察点编号为 2;要删除此监察点,输入 `delete 2`。 + +*注意:* 如果你使用 `delete` 而没有指定数字,*所有* 监察点和断点将被删除。 + +这同样适用于断点。在下面的截屏中,我添加了几个断点,输入 `info breakpoint` 打印断点列表: + +![gdb output info breakpoints][21] + +要删除单个断点,请先输入 `delete` 后输入断点的编号。另外一种方式:你可以通过指定断点的行号来删除断点。例如,`clear 78` 命令将删除第 78 行设置的断点号 7。 + +#### 禁用或启用断点和监察点 + +除了删除断点或监察点之外,你可以通过输入 `disable`,后输入编号禁用断点或监察点。在下文中,断点 3 和 4 被禁用,并在代码窗口中用减号标记: + +![disabled breakpoints][22] + +也可以通过输入类似 `disable 2 - 4` 修改某个范围内的断点或监察点。如果要重新激活这些点,请输入 `enable`,然后输入它们的编号。 + +### 条件断点 + +首先,输入 `delete` 删除所有断点和监察点。你仍然想使程序停在 `main` 函数处,如果你不想指定行号,可以通过直接指明该函数来添加断点。输入 `break main` 从而在 `main` 函数处添加断点。 + +输入 `run` 从头开始运行程序,程序将在 `main` 函数处停止。 + +`main` 函数包括变量 `n_state_3_count`,当状态机达到状态 3 时,该变量会递增。 + +基于 `n_state_3_count` 的值添加一个条件断点,请输入: + +``` +break 54 if n_state_3_count == 3 +``` + +![Set conditional breakpoint][23] + +继续运行程序。程序将在第 54 行停止之前运行状态机 3 次。要查看 `n_state_3_count` 的值,请输入: + +``` +print n_state_3_count +``` + +![print variable][24] + +#### 使断点成为条件断点 + +你也可以使现有断点成为条件断点。用 `clear 54` 命令删除最近添加的断点,并通过输入 `break 54` 命令添加一个简单的断点。你可以输入以下内容使此断点成为条件断点: + +``` +condition 3 n_state_3_count == 9 +``` + +`3` 指的是断点编号。 + +![modify breakpoint][25] + +#### 在其他源文件中设置断点 + +如果你的程序由多个源文件组成,你可以在行号前指定文件名来设置断点,例如,`break main. cpp:54`。 + +#### 捕捉点 + +除了断点和监察点之外,你还可以设置捕获点。捕获点适用于执行系统调用、加载共享库或引发异常等事件。 + +要捕获用于写入 STDOUT 的 `write` 系统调用,请输入: + +``` +catch syscall write +``` + +![catch syscall write output][26] + +每当程序写入控制台输出时,GDB 将中断执行。 + +在手册中,你可以找到一整章关于 [断点、监察点和捕捉点][27] 的内容。 + +### 评估和操作符号 + +用 `print` 命令可以打印变量的值。一般语法是 `print <表达式> <值>`。修改变量的值,请输入: + +``` +set variable . +``` + +在下面的截屏中,我将变量 `n_state_3_count` 的值设为 `123`。 + +![catch syscall write output][28] + +`/x` 表达式以十六进制打印值;使用 `&` 运算符,你可以打印虚拟地址空间内的地址。 + +如果你不确定某个符号的数据类型,可以使用 `whatis` 来查明。 + +![whatis output][29] + +如果你要列出 `main` 函数范围内可用的所有变量,请输入 `info scope main` : + +![info scope main output][30] + +`DW_OP_fbreg` 值是指基于当前子程序的堆栈偏移量。 + +或者,如果你已经在一个函数中并且想要列出当前堆栈帧上的所有变量,你可以使用 `info locals` : + +![info locals output][31] + +查看手册以了解更多 [检查符号][32] 的内容。 + +### 附加调试到一个正在运行的进程 + +`gdb attach <进程 ID>` 命令允许你通过指定进程 ID(PID)附加到一个已经在运行的进程进行调试。幸运的是,`coredump` 程序将其当前 PID 打印到屏幕上,因此你不必使用 [ps][33] 或 [top][34] 手动查找 PID。 + +启动 `coredump` 应用程序的一个实例: + +``` +./coredump +``` + +![coredump application][35] + +操作系统显示 PID 为 `2849`。打开一个单独的控制台窗口,移动到 `coredump` 应用程序的根目录,然后用 GDB 附加到该进程进行调试: + +``` +gdb attach 2849 +``` + +![attach GDB to coredump][36] + +当你用 GDB 附加到进程时,GDB 会立即停止进程运行。输入 `layout src` 和 `backtrace` 来检查调用堆栈: + +![layout src and backtrace output][37] + +输出显示在 `main.cpp` 第 92 行调用 `std::this_thread::sleep_for<...>(. ..)` 函数时进程中断。 + +只要你退出 GDB,该进程将继续运行。 + +你可以在 GDB 手册中找到有关 [附加调试正在运行的进程][38] 的更多信息。 + +#### 在堆栈中移动 + +在命令窗口,输入 `up` 两次可以在堆栈中向上移动到 `main.cpp` : + +![moving up the stack to main.cpp][39] + +通常,编译器将为每个函数或方法创建一个子程序。每个子程序都有自己的栈帧,所以在栈帧中向上移动意味着在调用栈中向上移动。 + +你可以在手册中找到有关 [堆栈计算][40] 的更多信息。 + +#### 指定源文件 + +当调试一个已经在运行的进程时,GDB 将在当前工作目录中寻找源文件。你也可以使用 [目录命令][41] 手动指定源目录。 + +### 评估转储文件 + +阅读 [创建和调试 Linux 的转储文件][42] 了解有关此主题的信息。 + +参考文章太长,简单来说就是: + +1. 假设你使用的是最新版本的 Fedora +2. 使用 `-c1` 开关调用 coredump:`coredump -c1` + + ![Crash meme][44] + +3. 使用 GDB 加载最新的转储文件:`coredumpctl debug` +4. 打开 TUI 模式并输入 `layout src` + +![coredump output][45] + +`backtrace` 的输出显示崩溃发生在距离 `main.cpp` 五个栈帧之外。回车直接跳转到 `main.cpp` 中的错误代码行: + +![up 5 output][46] + +看源码发现程序试图释放一个内存管理函数没有返回的指针。这会导致未定义的行为并引起 `SIGABRT`。 + +### 无符号调试 + +如果没有源代码,调试就会变得非常困难。当我在尝试解决逆向工程的挑战时,我第一次体验到了这一点。了解一些 [汇编语言][47] 的知识会很有用。 + +我们用例子看看它是如何运行的。 + +找到根目录,打开 `Makefile`,然后像下面一样编辑第 9 行: + +``` +CFLAGS =-Wall -Werror -std=c++11 #-g +``` + +要重新编译程序,先运行 `make clean`,再运行 `make`,最后启动 GDB。该程序不再有任何调试符号来引导源代码的走向。 + +![no debugging symbols][48] + +`info file` 命令显示二进制文件的内存区域和入口点: + +![info file output][49] + +`.text` 区段始终从入口点开始,其中包含实际的操作码。要在入口点添加断点,输入 `break *0x401110` 然后输入 `run` 开始运行程序: + +![breakpoint at the entry point][50] + +要在某个地址设置断点,使用取消引用运算符 `*` 来指定地址。 + +#### 选择反汇编程序风格 + +在深入研究汇编之前,你可以选择要使用的 [汇编风格][51]。 GDB 默认是 AT&T,但我更喜欢 Intel 语法。变更风格如下: + +``` +set disassembly-flavor intel +``` + +![changing assembly flavor][52] + +现在输入 `layout asm` 调出汇编代码窗口,输入 `layout reg` 调出寄存器窗口。你现在应该看到如下输出: + +![layout asm and layout reg output][53] + +#### 保存配置文件 + +尽管你已经输入了许多命令,但实际上还没有开始调试。如果你正在大量调试应用程序或尝试解决逆向工程的难题,则将 GDB 特定设置保存在文件中会很有用。 + +该项目的 GitHub 存储库中的 [gdbinit][54] 配置文件包含最近使用的命令: + +``` +set disassembly-flavor intel +set write on +break *0x401110 +run -c2 +layout asm +layout reg +``` + +`set write on` 命令使你能够在程序运行期间修改二进制文件。 + +退出 GDB 并使用配置文件重新启动 GDB : `gdb -x gdbinit coredump`。 + +#### 阅读指令 + +应用 `c2` 开关后,程序将崩溃。程序在入口函数处停止,因此你必须写入 `continue` 才能继续运行: + +![continuing execution after crash][55] + +`idiv` 指令进行整数除法运算:`RAX` 寄存器中为被除数,指定参数为除数。商被加载到 `RAX` 寄存器中,余数被加载到 `RDX` 中。 + +从寄存器角度,你可以看到 `RAX` 包含 `5`,因此你必须找出存储堆栈中位置为 `rbp-0x4` 的值。 + +#### 读取内存 + +要读取原始内存内容,你必须指定比读取符号更多的参数。在汇编输出中向上滚动一点,可以看到堆栈的划分: + +![stack division output][56] + +你最感兴趣的应该是 `rbp-0x4` 的值,因为它是 `idiv` 的存储参数。你可以从截图中看到`rbp-0x8` 位置的下一个变量,所以 `rbp-0x4` 位置的变量是 4 字节宽。 + +在 GDB 中,你可以使用 `x` 命令*查看*任何内存内容: + + +> `x/` < 可选参数 `n`、`f`、`u` > < 内存地址 `addr` > + +可选参数: + +* `n`:单元大小的重复计数(默认值:1) +* `f`:格式说明符,如 [printf][57] +* `u`:单元大小 + * `b`:字节 + * `h`:半字(2 个字节) + * w: 字(4 个字节)(默认) + * g: 双字(8 个字节) + +要打印 `rbp-0x4` 的值,请输入 `x/u $rbp-4` : + +![print value][58] + +如果你能记住这种模式,则可以直接查看内存。参见手册中的 [查看内存][59] 部分。 + +#### 操作汇编 + +子程序 `zeroDivide()` 发生运算异常。当你用向上箭头键向上滚动一点时,你会找到下面信息: + +``` +0x401211 <_Z10zeroDividev>              push   rbp +0x401212 <_Z10zeroDividev+1>            mov    rbp,rsp +``` + +这被称为 [函数前言][60]: + +1. 调用函数的基指针(`rbp`)存放在栈上 +2. 栈指针(`rsp`)的值被加载到基指针(`rbp`) + +完全跳过这个子程序。你可以使用 `backtrace` 查看调用堆栈。在 `main` 函数之前只有一个堆栈帧,所以你可以用一次 `up` 回到 `main` : + +![Callstack assembly][61] + +在你的 `main` 函数中,你会找到下面信息: + +``` +0x401431     cmp    BYTE PTR [rbp-0x12],0x0 +0x401435     je     0x40145f +0x401437     call   0x401211<_Z10zeroDividev> +``` + +子程序 `zeroDivide()` 仅在 `jump equal (je)` 为 `true` 时进入。你可以轻松地将其替换为 `jump-not-equal (jne)` 指令,该指令的操作码为 `0x75`(假设你使用的是 x86/64 架构;其他架构上的操作码不同)。输入 `run` 重新启动程序。当程序在入口函数处停止时,设置操作码: + +``` +set *(unsigned char*)0x401435 = 0x75 +``` + +最后,输入 `continue` 。该程序将跳过子程序 `zeroDivide()` 并且不会再崩溃。 + +### 总结 + +你会在许多集成开发环境(IDE)中发现 GDB 运行在后台,包括 Qt Creator 和 VSCodium 的 [本地调试][62] 扩展。 + +![GDB in VSCodium][63] + +了解如何充分利用 GDB 的功能很有用。一般情况下,并非所有 GDB 的功能都可以在 IDE 中使用,因此你可以从命令行使用 GDB 的经验中受益。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/1/gnu-project-debugger + +作者:[Stephan Avenwedde][a] +选题:[lkxed][b] +译者:[Maisie-x](https://github.com/Maisie-x) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/hansic99 +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/mistake_bug_fix_find_error.png +[2]: https://www.gnu.org/software/gdb/ +[3]: https://opensource.com/article/20/8/linux-dump +[4]: https://opensource.com/sites/default/files/uploads/gdb_output_no_dbg_symbols.png +[5]: https://opensource.com/sites/default/files/uploads/gdb_output_with_symbols.png +[6]: https://opensource.com/sites/default/files/uploads/gdb_output_crash_on_c1_switch.png +[7]: https://opensource.com/sites/default/files/uploads/gdb_output_info_source.png +[8]: http://dwarfstd.org/ +[9]: https://sourceware.org/gdb/current/onlinedocs/gdb/Compilation.html#Compilation +[10]: https://opensource.com/sites/default/files/uploads/gdb_output_info_shared.png +[11]: https://opensource.com/article/20/6/linux-libraries +[12]: https://opensource.com/sites/default/files/uploads/gdb_output_stopped_by_sigint.png +[13]: https://opensource.com/sites/default/files/uploads/gdb_output_list_main.png +[14]: https://opensource.com/sites/default/files/uploads/gdb_output_breakpoint_added.png +[15]: https://opensource.com/sites/default/files/uploads/gdb_output_break_at_main.png +[16]: https://opensource.com/sites/default/files/images/gdb_output_screen_corrupted.png +[17]: https://sourceware.org/gdb/onlinedocs/gdb/TUI-Keys.html#TUI-Keys +[18]: https://opensource.com/sites/default/files/uploads/gdb_output_stop_on_watchpoint_1.png +[19]: https://opensource.com/sites/default/files/uploads/gdb_output_stop_on_watchpoint_2.png +[20]: https://opensource.com/sites/default/files/uploads/gdb_output_info_watchpoints.png +[21]: https://opensource.com/sites/default/files/uploads/gdb_output_info_breakpoints.png +[22]: https://opensource.com/sites/default/files/uploads/gdb_output_disabled_breakpoints.png +[23]: https://opensource.com/sites/default/files/uploads/gdb_output_set_conditional_breakpoint.png +[24]: https://opensource.com/sites/default/files/uploads/gdb_output_print_variable.png +[25]: https://opensource.com/sites/default/files/uploads/gdb_output_modify_breakpoint.png +[26]: https://opensource.com/sites/default/files/uploads/gdb_output_syscall_catch.png +[27]: https://sourceware.org/gdb/current/onlinedocs/gdb/Breakpoints.html#Breakpoints +[28]: https://opensource.com/sites/default/files/uploads/gdb_output_print_and_modify.png +[29]: https://opensource.com/sites/default/files/uploads/gdb_output_whatis.png +[30]: https://opensource.com/sites/default/files/uploads/gdb_output_info_scope_main.png +[31]: https://opensource.com/sites/default/files/uploads/gdb_output_info_locals_main.png +[32]: https://sourceware.org/gdb/current/onlinedocs/gdb/Symbols.html +[33]: https://man7.org/linux/man-pages/man1/ps.1.html +[34]: https://man7.org/linux/man-pages/man1/top.1.html +[35]: https://opensource.com/sites/default/files/uploads/coredump_running.png +[36]: https://opensource.com/sites/default/files/uploads/gdb_output_attaching_to_process.png +[37]: https://opensource.com/sites/default/files/uploads/gdb_output_backtrace.png +[38]: https://sourceware.org/gdb/current/onlinedocs/gdb/Attach.html#Attach +[39]: https://opensource.com/sites/default/files/uploads/gdb_output_stackframe_up.png +[40]: https://sourceware.org/gdb/current/onlinedocs/gdb/Stack.html#Stack +[41]: https://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_48.html#SEC49 +[42]: https://opensource.com/article/20/8/linux-dump +[43]: https://creativecommons.org/licenses/by-sa/4.0/ +[44]: https://opensource.com/sites/default/files/uploads/crash.png +[45]: https://opensource.com/sites/default/files/uploads/gdb_output_coredump.png +[46]: https://opensource.com/sites/default/files/uploads/gdb_output_up_five.png +[47]: https://en.wikipedia.org/wiki/Assembly_language +[48]: https://opensource.com/sites/default/files/uploads/gdb_output_no_debugging_symbols.png +[49]: https://opensource.com/sites/default/files/uploads/gdb_output_info_file.png +[50]: https://opensource.com/sites/default/files/uploads/gdb_output_break_at_start.png +[51]: https://en.wikipedia.org/wiki/X86_assembly_language#Syntax +[52]: https://opensource.com/sites/default/files/uploads/gdb_output_disassembly_flavor.png +[53]: https://opensource.com/sites/default/files/uploads/gdb_output_layout_reg_asm.png +[54]: https://github.com/hANSIc99/core_dump_example/blob/master/gdbinit +[55]: https://opensource.com/sites/default/files/uploads/gdb_output_asm_div_zero.png +[56]: https://opensource.com/sites/default/files/uploads/gdb_output_stack_division.png +[57]: https://en.wikipedia.org/wiki/Printf_format_string#Type_field +[58]: https://opensource.com/sites/default/files/uploads/gdb_output_examine_1.png +[59]: https://sourceware.org/gdb/current/onlinedocs/gdb/Memory.html +[60]: https://en.wikipedia.org/wiki/Function_prologue +[61]: https://opensource.com/sites/default/files/uploads/gdb_output_callstack_assembly_0.png +[62]: https://github.com/WebFreak001/code-debug +[63]: https://opensource.com/sites/default/files/uploads/vs_codium_native_debug.png diff --git a/published/20210120 Highlighted Text Not Visible in gedit in Dark Mode- Here-s What You Can Do.md b/published/20210120 Highlighted Text Not Visible in gedit in Dark Mode- Here-s What You Can Do.md new file mode 100644 index 0000000000..a530d5f379 --- /dev/null +++ b/published/20210120 Highlighted Text Not Visible in gedit in Dark Mode- Here-s What You Can Do.md @@ -0,0 +1,84 @@ +[#]: collector: "lujun9972" +[#]: translator: "void-mori" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14833-1.html" +[#]: subject: "Highlighted Text Not Visible in gedit in Dark Mode? Here’s What You Can Do" +[#]: via: "https://itsfoss.com/gedit-dark-mode-problem/" +[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" + +gedit 深色模式下高亮文本不可见?以下是你能做的 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/16/094145b0gdwez5zo0zyuhz.jpg) + +我喜欢 [在 Ubuntu 中使用深色模式][1]。在我看来深色模式能够缓解视觉疲劳,让系统看起来更加的赏心悦目。 + +我发现了一个 [gedit][2] 文本编辑器的小麻烦,如果你在深色模式下使用它,你也许也会遇到。 + +默认情况下 gedit 高亮当前光标所在的行。这是一个非常有用的功能,但是如果你在 Linux 系统中开启了深色模式,那么你将会感到痛苦。为什么?因为被高亮的文本将不再变得可读。你自己看吧: + +![Text on the highlighted line is hardly visible][3] + +如果你选择文本,它将变得可读,但这并不是一个让人感到有多么愉快的阅读或者编辑体验。(LCTT 校注:在新的 Ubuntu 22.04 中,这一情况已经有所改善,“高亮当前行”已被取消勾选) + +![Selecting the text makes it better but that’s not a convenient thing to do for all lines][4] + +好消息是你不需要再忍受它。我将演示几个步骤让你能够同时享受 gedit 以及系统的深色模式。 + +### 让 gedit 在深色模式下阅读体验友好 + +你基本上有两个选择: + + 1. 禁用高亮当前行,但也同时意味着你必须清楚地知道你在哪一行。 + 2. 改变默认的颜色设置,但编辑器的颜色会变得稍微有些不同,而且如果你更改系统主题,它不会自动切换到浅色模式。 + +在 gedit 或者 GNOME 的开发者解决这个问题之前,这是你必须要做的应变和妥协。 + +#### 选项1: 禁止高亮当前行 + +当你打开 gedit 后,点击汉堡菜单然后选择“首选项Preferences”。 + +![Go to Preferences][5] + +在查看选项卡,你应该看到在 “高亮Highlighting” 区域的下方的 “高亮当前行Highlight current line” 选项。取消勾选这个选项,马上就可以看到效果。 + +![Disable highlighting current line][6] + +“高亮当前行”是一个有用的功能,如果你想继续使用它,请选择第二个选项。 + +#### 选项2: 更改编辑器的颜色主题 + +在“首选项Preferences”窗口,找到 “字体与颜色Font & Colors” 标签页,然后将颜色主题更改为 “Oblivion”、“Solarized Dark”,或者 “Cobalt”。 + +![Change the color scheme][7] + +正如我前面所提到的,缺点就是当你把系统主题切换为浅色模式时,编辑器将不会自动切换到浅色模式。 + +### 开发者应该修复的一个 bug + +这里 [有几个 Linux 可用的文本编辑器][8] ,但是为了快速阅读或编辑文本文件,我更推荐使用 gedit。尽管如此,小烦恼仍旧是小烦恼。开发者应该在将来的版本中为这个很好的文本编辑器修复这个问题,让我们不再求助于这些应对办法。 + +你呢?你在你的系统上使用深色模式还是浅色模式?你注意到 gedit 的这个问题了吗?你有使用什么方法去解决它吗?欢迎分享你的经验。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/gedit-dark-mode-problem/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[void-mori](https://github.com/void-mori) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/dark-mode-ubuntu/ +[2]: https://wiki.gnome.org/Apps/Gedit +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/01/gedit-dark-mode-problem.png?resize=779%2C367&ssl=1 +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/01/gedit-dark-mode-issue.png?resize=779%2C367&ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/01/gedit-preference.jpg?resize=777%2C527&ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/01/disable-highlight-line-gedit.jpg?resize=781%2C530&ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/01/change-color-scheme-gedit.jpg?resize=785%2C539&ssl=1 +[8]: https://itsfoss.com/best-modern-open-source-code-editors-for-linux/ diff --git a/published/20210511 What is fog computing.md b/published/20210511 What is fog computing.md new file mode 100644 index 0000000000..7984cc82d7 --- /dev/null +++ b/published/20210511 What is fog computing.md @@ -0,0 +1,67 @@ +[#]: subject: (What is fog computing?) +[#]: via: (https://opensource.com/article/21/5/fog-computing) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: (hanszhao80) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14782-1.html) + +什么是雾计算? +====== + +> 了解由我们生活中的所有连接设备组成的网络。 + +![](https://img.linux.net.cn/data/attachment/album/202207/01/120728yne9qv0e2vc5ucm3.jpg) + +在早期,计算机既笨重又昂贵,计算机用户很少,他们必须在计算机上的预留时间内亲自来处理他们的打孔卡punchcard。被称为 [大型机][2]Mainframe 的系统进行了许多创新,并在终端机terminal(没有自己的 CPU 的桌面计算机)上实现了分时time-shared任务。 + +时至今日,强大的计算设备能做到 [价格低至 35 美元,且大小不超过一张信用卡][3]。这甚至还没有涵盖现代生活中负责收集和处理数据的所有小设备。从高层次的角度来看这些计算机的集合,你可以想象得到,所有这些设备多得像云中的水滴一样。 + +碰巧“云计算cloud computing”一词已经被占用,因此需要为由物联网(IoT)和其他具有战略意义的服务器组成的网络提供一个独特的名称。此外,如果已经有一个代表数据中心节点的云,那么在云之外与我们交融的这些节点肯定有其独特之处。 + +### 欢迎来到雾计算 + +云通过互联网提供计算服务。构成云的数据中心很大,但与潜在客户的数量相比相对较少。这表明当数据在云及其众多用户之间来回传送时存在潜在的瓶颈。 + +相比之下,雾计算Fog Computing可以在数量上超过其潜在客户,而不会出现瓶颈,因为设备执行大部分数据的收集或计算。它是云的外部“边缘”,是云落地的部分。 + +### 雾和边缘计算 + +雾计算和 [边缘计算][4]edge computing 本质上是同义词。两者都与云和物联网密切相关,并做出相同的架构假设: + +- 你离 CPU 越近,数据传输就越快。 +- 像 [Linux][5] 一样,小型专用计算机,可以“做一件事并把它做好”,这是一个强大的优势(当然,我们的设备实际上不仅仅做一件事,但从高层次上看,你购买的用于监测健康的智能手表本质上是在做“一”件事)。 +- 离线是不可避免的,但好的设备可以在此期间同样有效地运行,然后在重新连接时同步。 +- 本地设备能比大型数据中心更简单、更便宜。 + +### 边缘网络 + +将雾计算视为与云完全分离的实体很诱人,但它们毕竟是组成一个整体的两个部分。云需要数字企业的基础设施,包括公共云提供商、电信公司,甚至是运行自己服务的专业公司。本地化服务也很重要,可以在云核心与其数以百万计的客户之间提供中转站waystations。 + +雾计算位于云的边缘,无论客户身在何处,都与他们紧密联系在一起。有时这是一个消费环境,例如你自己的家或汽车,而另一些时候这是一种商业利益,例如零售店中的价格监控设备或工厂车间的重要的安全传感器。 + +### 雾计算就在你身边 + +雾计算由我们生活中的所有连接设备组成:无人机drone、电话、手表、健身监视器、安全监视器、家庭自动化、便携式游戏设备、园艺自动化、天气传感器、空气质量监视器等等。理想情况下,它提供的数据有助于建立一个更好、更明智的未来。有许多伟大的开源项目正朝着改善健康的方向而努力 —— 甚至只是让生活变得更有趣一点儿 —— 这一切都得益于雾和云计算。无论如何,_我们的_ 工作是确保它 [保持开放][7]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/5/fog-computing + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[hanszhao80](https://github.com/hanszhao80) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_laptop_code_programming_mountain_view.jpg?itok=yx5buqkr (Man at laptop on a mountain) +[2]: https://opensource.com/article/19/9/linux-mainframes-part-1 +[3]: https://opensource.com/resources/raspberry-pi +[4]: https://www.redhat.com/en/topics/edge-computing/what-is-edge-computing +[5]: https://opensource.com/resources/linux +[6]: https://www.redhat.com/architect/edge-computing-essentials +[7]: https://opensource.com/article/20/10/keep-cloud-open diff --git a/published/20210511 What is the OSI model.md b/published/20210511 What is the OSI model.md new file mode 100644 index 0000000000..01b9089954 --- /dev/null +++ b/published/20210511 What is the OSI model.md @@ -0,0 +1,93 @@ +[#]: subject: (What is the OSI model?) +[#]: via: (https://jvns.ca/blog/2021/05/11/what-s-the-osi-model-/) +[#]: author: (Julia Evans https://jvns.ca/) +[#]: collector: (lujun9972) +[#]: translator: (hanszhao80) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14786-1.html) + +OSI 模型是什么? +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/02/153620k7nwc6nn2b6n6p2c.jpg) + +(LCTT 校注:作者原文已经大篇幅进行了修订更新,本文据之前的版本翻译。) + +今天我在推特上发布了一些关于 OSI 模型如何与 TCP/IP 工作原理的实际表现不相符的观点,这让我思考——OSI 模型到底是什么?通过阅读推特上的一些回复发现,似乎至少存在三种不同的思考方式: + +1. TCP/IP 工作原理的字面描述 +2. 一个可以用来描述和比较很多不同的网络协议的抽象模型 +3. 对 1980 年代的一些计算机网络协议的字面描述,这些协议如今大多已不再使用 + +在这篇文章中,我不打算试图争辩以上哪一个才是“真正”的 OSI 模型——似乎不同的人以所有这些方式思考它。这不重要。 + +### OSI 模型有七层 + +在我们讨论 OSI 模型的含义之前,让我们大致地讨论一下它是什么。它是一个抽象模型,用于描述网络如何在七个编号的层上工作: + +- 第一层:物理层 +- 第二层:数据链路层 +- 第三层:网络层 +- 第四层:传输层 +- 第五层:会话层 +- 第六层:表示层 +- 第七层:应用层 + +我不会再费时地去解释每一层的含义,网上有上千种解释可供查询。 + +### OSI 模型:TCP/IP 工作原理的字面描述 + +首先,我想谈谈人们在实践中使用 OSI 模型的一种常见方式:作为对 TCP/IP 工作原理的字面描述。OSI 模型的某些层非常容易映射到 TCP/IP: + +- 第二层对应以太网 +- 第三层对应 IP +- 第四层对应 TCP 或 UDP(或 ICMP 等) +- 第七层对应 TCP 或 UDP 包内的任何内容(例如 DNS 查询) + +这种映射对第二、三、四层很有意义——TCP 数据包有三个标头header对应于这三个层(以太网标头、IP 标头和 TCP 标头)。 + +用数字来描述 TCP 数据包中的不同标头非常有用——如果你说“第二层”,很显然它位于第三层“下方”,因为二比三小。 + +“OSI 模型作为字面描述”的古怪之处在于,第五层和第六层并不真正对应于 TCP/IP 中的任何内容——我听说过很多关于第五层或第六层可能是什么的不同解释(你可以说第五层是 TLS 或其他东西!)但它们没有像第二、三、四层那样“每一层在 TCP 数据包中都有相应的标头”这样的明确对应关系。 + +此外,TCP/IP 的某些部分即使在第二层到第四层也不能很好地适应 OSI 模型——例如,哪一层是 ARP 数据包?ARP 数据包发送一些带有以太网标头的数据,这是否意味着它们是第三层?或是第二层?列出不同 OSI 层的维基百科文章将其归类为“第 2.5 层”,这并不令人满意。 + +因为 OSI 模型有时用于教授 TCP/IP,若搞不清楚它的哪些部分可以映射到 TCP/IP,而哪些部分不能,则会令人困惑。这才是真的问题。 + +### OSI 模型:用于比较网络协议的一个抽象 + +我听说过的另一种关于 OSI 的思考方式是,它是一种抽象,可以用来在许多不同的网络协议之间进行类比。例如,如果你想了解蓝牙协议的工作原理,也许你可以使用 OSI 模型来帮助你——这是我在 [这个网页][1] 上找到的一张图表,显示了蓝牙协议如何适配 OSI 模型。 + +![][2] + +另一个例子是,[这篇维基百科文章][3] 有一个 OSI 层列表,详细划分了哪些特定的网络协议对应于这些 OSI 层。 + +### OSI 模型:一些过时协议的字面描述 + +维基百科上的一些非常简短的研究表明,除了对这七层的抽象描述之外,OSI 模型还包含了 [一组实现这些层的特定协议][4]。显然,这发生在 70 年代和 80 年代的 [协议战争][5] 时期,OSI 模型失败了,TCP/IP 则取得了胜利。 + +这就解释了为什么 OSI 模型无法与 TCP/IP 很好地对应,因为如果当时“获胜”的是 OSI 协议,那么 OSI 模型 _将_ 完全对应于互联网网络的实际工作方式。 + +### 结语 + +我写这篇文章的初衷是,当我最初学习 OSI 模型时,我发现它非常令人困惑(所有这些层是什么?它们是真实存在的吗?这是网络的实际工作原理吗?发生了什么?)我希望有人告诉我这个只使用 TCP/IP 网络协议的人,只需了解 OSI 模型第二、三、四和七层与 TCP/IP 的关系,然后忽略它的所有其他内容即可。所以我希望这篇文章对某些人能有所帮助! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2021/05/11/what-s-the-osi-model-/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[hanszhao80](https://github.com/hanszhao80) +校对:[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://flylib.com/books/en/4.215.1.116/1/ +[2]: https://jvns.ca/images/bluetooth.gif +[3]: https://en.wikipedia.org/wiki/List_of_network_protocols_(OSI_model) +[4]: https://en.wikipedia.org/wiki/OSI_protocols +[5]: https://en.wikipedia.org/wiki/Protocol_Wars diff --git a/published/20210602 Establish an SSH connection between Windows and Linux.md b/published/20210602 Establish an SSH connection between Windows and Linux.md new file mode 100644 index 0000000000..edc6789ac8 --- /dev/null +++ b/published/20210602 Establish an SSH connection between Windows and Linux.md @@ -0,0 +1,207 @@ +[#]: subject: (Establish an SSH connection between Windows and Linux) +[#]: via: (https://opensource.com/article/21/6/ssh-windows) +[#]: author: (Stephan Avenwedde https://opensource.com/users/hansic99) +[#]: collector: (lujun9972) +[#]: translator: (yjacks) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14855-1.html) + +如何从 Windows 上用 SSH 连接到 Linux +====== + +> 使用开源的 PuTTY 工具,从 Windows 建立到 Linux 的 SSH 连接。 + +![](https://img.linux.net.cn/data/attachment/album/202207/23/110039pjbd9jbbc84gbz2f.jpg) + +在 Linux 世界中,安全外壳secure shell(SSH)协议是最为常用的、通过命令行控制远程计算机的方式。SSH 是真正的 Linux 原创,但是它在 Windows 世界中也越来越流行。甚至有了一份官方的 [Windows 的 SSH 文档][2],那篇文档阐述了使用 [OpenSSH][3] 控制 Windows 的方法。 + +这篇文章展示了如何使用了流行的开源工具 [PuTTY][4],建立一个从 Windows 到 Fedora 33 Linux 系统的 SSH 连接。 + +### 使用 SSH 的方法 + +SSH 使用客户端-服务器模式,即 SSH 客户端会创建到 SSH 服务端的连接。SSH 服务器通常会作为守护进程Daemon运行,所以它常被称为 SSHD。你很难找到一个不自带 SSH 守护进程的 Linux 发行版。在 Fedora 33 中,已安装了 SSH 守护进程,但是并未激活。 + +你可以使用 SSH 控制几乎所有的 Linux 机器,无论它是作为虚拟机还是作为网络上的物理设备运行。一个常见的用例是无头headless配置的嵌入式设备,如树莓派。SSH 也可以用做一个其它网络服务的隧道。因为 SSH 连接是加密的,所以你可以使用 SSH 作为一个任何默认不提供加密的协议的传输层。 + +在这篇文章中,我将解释使用 SSH 的四个方式:1、如何在 Linux 端配置 SSH 守护进程;2、如何设置远程控制台连接;3、如何通过网络复制文件,4. 如何将 SSH 作为某些协议的隧道。 + +### 1、配置 SSHD + +将 Linux 系统(文中是 Fedora 33)作为 SSH 服务器,允许 PuTTY SSH 客户端进行连接。首先,检查守护进程的 SSH 配置。配置文件放在 `/etc/ssh/sshd_config`,它包含了许多选项,通过取消掉相关行的注释就可以激活: + +``` +#       $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $ + +# This is the sshd server system-wide configuration file.  See +# sshd_config(5) for more information. + +# This sshd was compiled with PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin + +# The strategy used for options in the default sshd_config shipped with +# OpenSSH is to specify options with their default value where +# possible, but leave them commented.  Uncommented options override the +# default value. + +Include /etc/ssh/sshd_config.d/*.conf + +#Port 22 +#AddressFamily any +#ListenAddress 0.0.0.0 +#ListenAddress :: +``` + +没有取消任何注释的默认配置在这个示例中应该是可以工作的。要检查 SSH 守护进程是否已经运行,输入 `systemctl status sshd`: + +``` +$ systemctl status sshd +● sshd.service - OpenSSH server daemon +   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) +   Active: active (running) since Fri 2018-06-22 11:12:05 UTC; 2 years 11 months ago +     Docs: man:sshd(8) +           man:sshd_config(5) + Main PID: 577 (sshd) +    Tasks: 1 (limit: 26213) +   CGroup: /system.slice/sshd.service +           └─577 /usr/sbin/sshd -D -oCiphers=[aes256-gcm@openssh.com][5],chacha20-[...] +``` + +如果它处于未激活inactive状态,使用 `systemctl start sshd` 命令启动它。 + +### 2、设置远程控制台 + +在 Windows 下 [下载 PuTTY 安装程序][6],然后安装并打开它。你应看到一个像这样的窗口: + +![PuTTY configuration screen][7] + +在“主机名(或 IP 地址)Host Name (or IP address)”输入框,键入你的 Linux 系统的连接信息。本文设置了一个 Fedora 33 虚拟机,它使用桥接网络适配器,使我可以由 IP 地址 `192.168.1.60` 连接这个系统。点击“打开Open”,应会如图示的打开一个窗口: + +![PutTTY security alert][9] + +这是 SSH 的安全措施之一,是为了防止[中间人攻击][10]man-in-the-middle attack。消息中的指纹应该匹配 Linux 系统中放在 `/etc/ssh/ssh_host_ed25519_key.pub` 的密钥。PuTTY 将这个密钥以 [MD5 哈希值][11] 的方式打印出来。要检查它的真实性,切换到 Linux 系统并打开一个控制台,然后输入: + +``` +ssh-keygen -l -E md5 -f /etc/ssh/ssh_host_ed25519_key.pub +``` + +输出应该和 PuTTY 展示的指纹一致: + +``` +$ ssh-keygen -l -E md5 -f /etc/ssh/ssh_host_ed25519_key.pub +256 MD5:E4:5F:01:05:D0:F7:DC:A6:32 no comment (ED25519) +``` + +点击“Yes”以确认 PuTTY 的安全提示。主机系统的指纹现在存储在 PuTTY 的信任列表中,其位于 Windows 的注册表中的: + +``` +HKEY_CURRENT_USER\SOFTWARE\SimonTatham\PuTTY\SshHostKeys +``` + +输入正确的登录凭证,然后你应该进入控制台了,位置在你的用户主目录。 + +![Logged in to SSH][12] + +### 3、通过网络复制文件 + +除了远程控制台,你同样可以使用 PuTTY 通过 SSH 来传输文件。PuTTY 的安装目录在 `C:\Program Files (x86)\PuTTY`,在该目录下寻找 `ppscp.exe`。你既可以使用它从 Linux 系统复制文件,也可以复制文件到 Linux 系统。 + +使用 `Windows + R` 然后输入 `cmd` 来打开命令提示符,从你的 Linux 用户主目录复制 `MYFile.txt` 到你的 Windows 主目录,输入: + +``` +C:\"Program Files (x86)"\PuTTY\pscp.exe stephan@192.168.1.60:/home/stephan/MyFile.txt . +``` + +要从 Windows 主目录复制文件到 Linux 用户主目录,输入: + +``` +C:\"Program Files (x86)"\PuTTY\pscp.exe MyFile.txt stephan@192.168.1.60:/home/stephan/ +``` + +就像你也许已经发现的那样,复制的命令通常构造为: + +``` +pscp.exe +``` + +### 4、隧道化一个协议 + +假设你拥有一个 Linux 机器,为某些特别的应用运行一个基于 HTTP 的服务。你想从你的 Windows 机器通过互联网访问这个 HTTP 服务。而且,你不能将相关的 TCP 端口暴露在公网,因为: + + 1. 这个服务通过 HTTP 而非 HTTPS 运行 + 2. 根本没有用户管理和登录系统 + +乍一看,建立这种架构不产生可怕的漏洞似乎是不可能的。但是 SSH 可简单的为这种情况建立一个安全的解决方案。 + +我将用我的软件项目 [Pythonic][13] 来演示这个过程。在容器中运行。Pythonic 作为容器运行,开放两个 TCP 端口:TCP 端口 7000(主要编辑器)和 TCP 端口 8000([code-server][14] 代码编辑器)。 + +要在一个 Linux 机器上安装 Pythonic ,运行: + +``` +podman pull pythonicautomation/pythonic +podman run -d -p 7000:7000 -p 8000:8000 pythonic +``` + +转向你的 Windows 机器,打开 PuTTy,转到 “连接Connection -> SSH -> 隧道Tunnels”。加入你要转发的两个 TCP 端口: + + * 源:`7000` / 目标:`localhost:7000` + * 源:`8000` / 目标:`localhost:8000` + +![Port forwarding in PuTTY][15] + +然后返回 “会话Session” 部分,并像之前那样建立一个 SSH 链接。打开网页浏览器,然后转到 `http://localhost:7000`;你应该看见像这样的窗口: + +![Pythonic][16] + +你成功的设置了端口转发! + +**警告**: 如果你选择在公网上暴露 TCP 端口 22 ,不要使用易于猜测的登录凭证。你将接受来自全世界的登录请求,它们使用常见的、标准的登录凭证以尝试登录你的 Linux 机器。相反,只允许已知的用户登录。这种登录限制可以通过 [公钥加密][17] 来实现,它使用一个密钥对,其中公钥存储在 SSH 主机上,而私钥保留在客户端。 + +### 调试 + +如果你难以连接你的 Linux 机器,你可以跟踪你的 SSH 守护进程的处理过程: + +``` +journalctl -f -u sshd +``` + +这是一个普通的登录进程,但是其日志级别为 DEBUG,它看起来是这样的 : + +![LogLevel DEBUG output][18] + +### 了解更多 + +这篇文章几乎没有涉及到使用 SSH 的方法。如果你正在寻找一个特定用例的信息,你也许可以在互联网中找到无数的教程。我在工作中使用 PuTTY ,因为它易于设置,在两个操作系统间又具有良好的可操作性,使得它成为连接解决方案里的瑞士军刀。 + +(文内图片来自:Stephan Avenwedde,[CC BY-SA 4.0][8]) + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/ssh-windows + +作者:[Stephan Avenwedde][a] +选题:[lujun9972][b] +译者:[yjacks](https://github.com/yjacks) +校对:[wxy](https://github.com/wxy) + +本文由 [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/cloud-windows-building-containers.png?itok=0XvZLZ8k (clouds in windows) +[2]: https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_overview +[3]: https://www.openssh.com/ +[4]: https://www.putty.org/ +[5]: mailto:aes256-gcm@openssh.com +[6]: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html +[7]: https://opensource.com/sites/default/files/uploads/putty_connection_settings.png (PuTTY configuration screen) +[8]: https://creativecommons.org/licenses/by-sa/4.0/ +[9]: https://opensource.com/sites/default/files/uploads/putty_host_key.png (PutTTY security alert) +[10]: https://en.wikipedia.org/wiki/Man-in-the-middle_attack +[11]: https://en.wikipedia.org/wiki/MD5 +[12]: https://opensource.com/sites/default/files/uploads/ssh_successfull_login.png (Logged in to SSH) +[13]: https://github.com/hANSIc99/Pythonic +[14]: https://github.com/cdr/code-server +[15]: https://opensource.com/sites/default/files/uploads/ssh_port_forwarding.png (Port forwarding in PuTTY) +[16]: https://opensource.com/sites/default/files/uploads/pythonic_screen.png (Pythonic) +[17]: https://opensource.com/article/21/4/encryption-decryption-openssl +[18]: https://opensource.com/sites/default/files/uploads/sshd_debug_log.png (LogLevel DEBUG output) diff --git a/published/20210611 How to use the FreeDOS text editor.md b/published/20210611 How to use the FreeDOS text editor.md new file mode 100644 index 0000000000..43f6816f64 --- /dev/null +++ b/published/20210611 How to use the FreeDOS text editor.md @@ -0,0 +1,80 @@ +[#]: subject: (How to use the FreeDOS text editor) +[#]: via: (https://opensource.com/article/21/6/freedos-text-editor) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: (yjacks) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14847-1.html) + +如何使用 FreeDOS Edit +====== + +> FreeDOS 提供了一个叫做 FreeDOS Edit 的用户友好的文本编辑器。 + +![](https://img.linux.net.cn/data/attachment/album/202207/20/173027t6ctk5cwf9u988p9.jpg) + +在任何操作系统中,编辑文件都是一项常有的任务。当你想去做一个某事的笔记、写封信给朋友或升级一个系统配置 —— 你需要一个文本编辑器。FreeDOS 提供了一个用户友好的文本编辑器(也许没啥想象力)叫做 “FreeDOS Edit”。 + +### 编辑文件 + +最简单的启用 FreeDOS Edit 的方式就就是输入 `EDIT`。它提供一个空的编辑器窗口。图案背景显示为一个空的“桌面”——提醒你没有编辑任何文件。 + +![FreeDOS Edit:未加载任何文件][2] + +就像多数 DOS 应用程序一样,你可以按下你键盘上的 `Alt` 键来访问 Edit 的菜单。这就激活了这个菜单。在你按下 `Alt` 后,Edit 将切换到“菜单”访问方式,并高亮 “文件File” 菜单。如果你想要访问菜单栏上的一个不同的菜单,可以使用左右方向键。按向下的方向键并按下回车键来“进入”菜单。 + +![高亮菜单][3] + +你注意到所有菜单标题的第一个字母是不同的颜色么?这种高亮字母显示了一种快捷方式。例如,“文件File”菜单的“F”高亮为红色。所以你可以按下 `Alt+F`(`Alt` 和 `F` 同时按下),Edit 会显示“文件File”菜单。 + +![文件菜单][4] + +你可以使用“文件File”菜单来开始一个新的(空)文件,或打开一个存在的文件。让我们开始一个新文件,使用方向键移动到“新建New“然后按下回车键。你也可以用 `Ctrl+N` (`Ctrl` 和 `N` 同时按下)打开一个新文件。 + +![编辑一个新的文件][5] + +此后,编辑文件应该非常简单。大多数熟悉的快捷键都可以在 FreeDOS Edit 中使用:`Ctrl+C` 复制文本,`Ctrl+X` 剪贴文本,和 `Ctrl+V` 将复制的或剪贴的文本粘贴到新的地方。如果你需要在一个长文档中寻找一个特殊文本,按下 `Ctrl+F`。保存你的工作成果,请使用 `Ctrl+S` 以将变更提交到硬盘。 + +### 在 Edit 中编程 + +如果你是个程序员,你也许会发现扩展的 ASCII 表是一个有用的工具。DOS 系统支持“拓展的” ASCII字符集,通常被称之为“代码页 437”。0 到 127 的标准字符包括字母 A 到 Z(大写和小写)、数字和特殊字符,如标点符号。但是,从 128 到 255 的 DOS 拓展字符包括其它语言字符和“画线”元素。DOS 程序员有时需要使用这些拓展 ASCII 字符,所以 FreeDOS Edit 可以很容易地查看所有 ASCII 码和它们的相关字符的表格。 + +要查看这个 ASCII 表,请使用“工具Utilities”菜单,选择“ASCII 表ASCII Table”菜单项,这将显示一个包含该表格的窗口。 + +![在工具菜单找到 ASCII 表][6] + +沿着左边,这张表显示十六进制值“00”到“F0”,顶部展示了单一值“0”到“F”。这些为每个字符的十六进制代码提供了一个快速参考。例如,第一行(00)和第一列(0)中的项目具有十六进制值 00 + 0,即0x00(“NULL”值)。而第五行(40)和第二列(1)中的字符,其数值为 40 + 1,即 0x41(字母 “A”)。 + +![ASCII 表提供一个便于参考的扩展字符表][7] + +当你在表格内移动光标高亮不同的字符时,你会看到表格底部的值发生变化,展示了字符的十进制、十六进制和八进制编码。例如,移动光标以高亮在 C0 行和第 5 列的“行交叉”字符,显示这个扩展字符的代码为 197(十进制)、0xc5(十六进制)和 305(八进制)。在一个程序中,你可以通过输入十六进制值 0xc5 或八进制“转义代码” \305 来引用这个扩展字符。 + +![“行交叉”字符是 197(十进制)、0xc5(十六进制)和 305(八进制)][8] + +请随意浏览 Edit 中的菜单,以发现其他不错的功能。例如,“选项Options”菜单允许你更改 Edit 的行为和外观。如果你喜欢使用更密集的显示,可以使用“显示Display”菜单(在“选项Options”下)将 Edit + 设置为 25、43 或 50 行。你还可以强制 Edit 以单色(黑底白字)或反转模式(白底黑字)显示。 + +(文内图片来自 Jim Hall,CC-BY SA 4.0) + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/freedos-text-editor + +作者:[Jim Hall][a] +选题:[lujun9972][b] +译者:[yjacks](https://github.com/yjacks) +校对:[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/laptop_screen_desk_work_chat_text.png?itok=UXqIDRDD (Person using a laptop) +[2]: https://opensource.com/sites/default/files/uploads/edit.png (FreeDOS Edit without any files loaded) +[3]: https://opensource.com/sites/default/files/uploads/edit-menu.png (Highlighting the menu) +[4]: https://opensource.com/sites/default/files/uploads/edit-file.png (The File menu) +[5]: https://opensource.com/sites/default/files/uploads/edit-new.png (Editing a new file) +[6]: https://opensource.com/sites/default/files/uploads/utilities-ascii.png (Find the ASCII Table in the Utilities menu) +[7]: https://opensource.com/sites/default/files/uploads/ascii-table-0x00.png (The ASCII Table provides a handy reference for extended characters) +[8]: https://opensource.com/sites/default/files/uploads/ascii-0xc5.png diff --git a/published/20210627 How to Convert File Formats With Pandoc in Linux -Quick Guide.md b/published/20210627 How to Convert File Formats With Pandoc in Linux -Quick Guide.md new file mode 100644 index 0000000000..6125218224 --- /dev/null +++ b/published/20210627 How to Convert File Formats With Pandoc in Linux -Quick Guide.md @@ -0,0 +1,137 @@ +[#]: subject: (How to Convert File Formats With Pandoc in Linux [Quick Guide]) +[#]: via: (https://itsfoss.com/pandoc-convert-file/) +[#]: author: (Bill Dyer https://itsfoss.com/author/bill/) +[#]: collector: (lujun9972) +[#]: translator: (lkxed) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14785-1.html) + +如何在 Linux 中使用 Pandoc 转换文件格式 +====== + +在之前的一篇文章中,我介绍了 [使用 pandoc 将少量 Markdown 文件批量转换为 HTML 的过程][1]。在那篇文章中,我创建了多个 HTML 文件,但 Pandoc 可以做的更多。它被称为文档转换的“瑞士军刀” —— 这是有充分理由的。很少有它做不到的事情。 + +[Pandoc][2] 可以将 .docx、.odt、.html、.epub、LaTeX、DocBook 等格式互相转换,或者转换为其他格式,例如 JATS、TEI Simple、AsciiDoc 等。 + +是的,这意味着 Pandoc 可以将 .docx 文件转换为 .pdf 和 .html 文件,但你可能会想:“Word 也可以将文件导出为 .pdf 和 .html。为什么我需要 Pandoc 呢?” + +嗯,本来呢,你这个说法也没错,但考虑到 Pandoc 可以转换这么多格式,它很可能成为你所有转换任务的首选工具。例如,我们中的许多人都知道 [Markdown 编辑器][3] 可以将其 Markdown 文件导出为 .html。而使用 Pandoc 文件也可以转换为许多其他格式。 + +我很少将 Markdown 导出为 HTML。我通常让 Pandoc 来做这件事。 + +### 使用 Pandoc 转换文件格式 + +![][4] + +本文中,我会将 Markdown 文件转换成几种不同的格式。我几乎所有的写作都使用 Markdown 语法,但我经常需要转换为另一种格式:学校作业通常需要的 .docx 格式;我创建的网页通常需要的 .html 格式;工作需要的 .epub 格式;传单和讲义需要的 .pdf 格式;甚至包括一个大学数字人文项目偶尔需要的 TEI Simple 格式。Pandoc 可以轻松处理所有这些格式,甚至更多。 + +首先,你需要 [安装 pandoc][5]。此外,要创建 .pdf 文件,还需要 LaTeX。我最喜欢的套件是 [TeX Live][6]。 + +**注意**:如果你想在安装前试用 pandoc,这里有一个在线试用页面:。 + +#### 安装 pandoc 和 texlive + +Ubuntu 和其他 Debian 发行版的用户可以在终端中输入以下命令: + +``` +sudo apt-get update +sudo apt-get install pandoc texlive +``` + +请注意第二行,你将一次性安装 `pandoc` 和 `texlive`。[apt-get 命令][7] 支持你这样做。不过,我建议你先去喝杯咖啡,因为这可能需要几分钟的时间。 + +#### 开始转换 + +安装完成 `pandoc` 和 `texlive` 后,你就可以尝试用它们来完成一些工作了! + +该项目的示例文档将是一篇文章,该文章于 1894 年 12 月首次发表在《北美评论》上,标题为“如何击退火车劫匪”。我将使用的 Markdown 文件是前一段时间创建的,该文章的一个恢复项目的一部分(LCTT 译注:这是篇一百多年前发表的文章,这是一个数字化“恢复”项目)。 + +我把这篇文章保存为 `how_to_repel_train_robbers.md`,它位于我的 `Documents` 目录下,名为 `samples` 的子目录中。它在 Ghostwriter 中看起来是这样的: + +![在 Ghostwriter 中查看原始的 Markdown 文件][8] + +我想创建此文件的 .docx、.pdf 和 .html 版本。 + +#### 第一次转换 + +首先,我将制作一个 .pdf 副本,因为我在安装 LaTeX 包时遇到了些麻烦。 + +在 `~/Documents/samples/` 目录中,我输入以下,以创建一个 .pdf 文件: + +``` +pandoc -o htrtr.pdf how_to_repel_train_robbers.md +``` + +上述命令将基于 `how_to_repel_train_robbers.md` 文件,创建一个名为 `htrtr.pdf` 的文件。我使用 `htrtr` 作为名称的原因是:嗯,它比 `how_to_repel_train_robbers` 短。`htrtr` 其实是长标题中的单词首字母排列。 + +这是 .pdf 文件制作完成后的一个截图: + +![在 Ocular 中查看的转换后的 PDF 文件][9] + +#### 第二次转换 + +接下来,我想创建一个 .docx 文件。该命令与我用来创建 .pdf 的命令几乎相同,它是: + +``` +pandoc -o htrtr.docx how_to_repel_train_robbers.md +``` + +很快,一个 .docx 文件就创建好了。这是它在 Libre Writer 中的样子: + +![在 Libre Writer 中查看转换后的 DOCX 文件][10] + +#### 第三次转换 + +我可能会想在网上发布这个,所以再多一个支持网页的格式也不错。我将使用以下命令创建一个 .html 文件: + +``` +pandoc -o htrtr.html how_to_repel_train_robbers.md +``` + +同样,创建它的命令与前两次转换非常相似。这是该 .html 文件在浏览器中的样子: + +![在 Firefox 中查看的转换后的 HTML 文件][11] + +#### 注意到什么了吗? + +让我们再看看之前的命令。它们是: + +``` +pandoc -o htrtr.pdf how_to_repel_train_robbers.md +pandoc -o htrtr.docx how_to_repel_train_robbers.md +pandoc -o htrtr.html how_to_repel_train_robbers.md +``` + +这三个命令唯一不同的是 `htrtr` 后的扩展名。这提示你 pandoc 会依赖于你提供的输出文件扩展名(来决定目标转换格式)。 + +### 总结 + +Pandoc 可以做的远不止这里完成的三个小转换。如果你选择使用一个首选格式编写文件,但时不时又需要将文件转换为另一种格式,pandoc 很大概率都能为你完成。 + +现在,既然你已经学会了,你会用它做什么呢?你会把它自动化吗?如果你有一个网站,想供读者下载文章怎么办?你可以修改这些小命令,把它们编写成一个脚本,你的读者可以决定他们想要哪种格式。你可以提供 .docx、.pdf、.odt、.epub 或更多格式。你的读者只需要选择一种格式,然后对应的转换脚本就会执行,最后,你的读者下载他们想要的文件。这是完全可以做到的。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/pandoc-convert-file/ + +作者:[Bill Dyer][a] +选题:[lujun9972][b] +译者:[lkxed](https://github.com/lkxed) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/bill/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/convert-markdown-files/ +[2]: https://pandoc.org/ +[3]: https://itsfoss.com/best-markdown-editors-linux/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/pandoc-quick-guide.png?resize=800%2C450&ssl=1 +[5]: https://pandoc.org/installing.html +[6]: https://www.tug.org/texlive/ +[7]: https://itsfoss.com/apt-get-linux-guide/ +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/convert_with_pandoc_ghostwriter.png?resize=800%2C516&ssl=1 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/convert_with_pandoc_ocular.png?resize=800%2C509&ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/convert_with_pandoc_libre_writer.png?resize=800%2C545&ssl=1 +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/convert_with_pandoc_firefox.png?resize=800%2C511&ssl=1 diff --git a/published/20211017 How I use open source to play RPGs.md b/published/20211017 How I use open source to play RPGs.md new file mode 100644 index 0000000000..b8ec151f5e --- /dev/null +++ b/published/20211017 How I use open source to play RPGs.md @@ -0,0 +1,107 @@ +[#]: subject: "How I use open source to play RPGs" +[#]: via: "https://opensource.com/article/21/10/open-source-rpgs" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lujun9972" +[#]: translator: "perfiffer" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14859-1.html" + +我如何使用开源玩 RPG 游戏 +====== + +> 为角色扮演游戏的所有元素找到一个开源工具。 + +![](https://img.linux.net.cn/data/attachment/album/202207/24/075445ymf5nvigh4t4htfd.jpg) + +我玩过很多桌面角色扮演游戏(RPG),无论是从频率还是种类来说。一般来说,我更喜欢和朋友一起玩 RPG,但在过去的 2 年里,我一直在玩网络游戏。(LCTT 校注:这里的 RPG 游戏指的是那种“传统”的面对面的桌面游戏,而非很多人最初接触的 RPG 电子游戏。) + +起初,我不确定如何在线长期的进行游戏。我知道有很多的工具可以实现,但直到我发现在线桌面游戏的开源世界之前,这些工具没有一个引起我的兴趣。通过一小部分开源应用程序,我已经能够在开源平台上进行我的所有游戏。 + +这也是一年中的好时机,因为最近是 [免费 RPG 日][2](LCTT 校注:今年的这个节日在 7 月 23 日举办)。在免费 RPG 日,桌面角色扮演游戏行业的发行商们会免费发放游戏,鼓励玩家尝试新游戏和新冒险。尽管它在 2020 年被取消了,但今年它又作为现场活动回归,并通过 [Dungeon Crawl Classics][3] 和 [Paizo][4] 的免费 RPG 示例下载提供了一些虚拟支持。 + +如果这个活动提供的虚拟产品还不够,我还整理了一份 [你可能尚未尝试过的 5 个开源桌面 RPG 游戏列表][5]。 + +当你准备好开始玩游戏时,请尝试其中一些开源工具,看看它们能在多大程度上增强你的游戏体验。 + +### 聊天 + +在线 RPG 游戏最基本的(从技术上讲,也是唯一的)要求是交流。这是游戏的媒介:玩家需要一种说话的途径。 + +有几个不错的选择。我发现 [Mumble][6] 是对带宽需求最低的工具。这是一个纯语音聊天应用程序,可以使用非常高效的 Opus 编解码器让每个人一次交谈数小时而不会中断。 + +![Mumble client][7] + +它在世界各地都运行有公共实例,所以下载 Mumble 客户端后,你可以加入其中任何一个开放的实例,并使用它来在线运行游戏。有一个“按下通话”设置,你可以用此来消除背景噪音,当你的其他家庭成员在进行其它工作而不想被你的桌面会话打扰时,这个功能将会非常实用。 + +还有一个文本聊天客户端。我的游戏组通常使用它来发布与游戏相关的链接,但你也可以将其用于其它无关内容的交谈,而让口头游戏保持在主题上。 + +如果你的玩家更喜欢看到面部表情,或者只是习惯于视频聊天网页应用。那么 [Jitsi][8] 是面对面围坐在桌子旁聚会的绝佳替代品。Jitsi 和你曾经使用过的其它视频聊天软件几乎一样,甚至更简单。你可以设置一个“房间”,邀请朋友,将陌生人拒之门外,并玩上几个小时。静音和关闭摄像都很直观,界面很吸引人,并且还定期开发和推出了新功能。 + +![Jitsi][9] + +Mumble 和 Jitsi 都有适用于台式机和移动设备的客户端,因此任何人都可以在任何设备上使用。 + +### 角色表 + +我发布了我的 [数字角色表][10] 解决方案,但任何 RPG 玩家都知道管理角色不仅仅是统计数据。 + +在延续多个会话的在线游戏中,我发现每次游戏之间有很长的停止时间。我突然想到,虽然我发现要求我的玩家在现场纸笔游戏中计算损耗是不合理的,但当一切都是数字化时,要求他们跟踪损耗很容易。 + +网上有很多可用的电子表格,但开源的选择是 [Ethercalc][11]。由于其实例遍布世界各地,因此很容易找到免费的 Ethercalc 主机。或者,你可以使用 Podman 或者 Docker 轻松安装和运行你自己的实例。 + +![Ethercalc spreadsheet of inventory][12] + +Etherclac 提供了一些基本要素:一个共享的账本,这样玩家就可以跟踪他们的团队所携带的物品(以及在任何给定的时间持有该物品的人)、每件物品的重量和价值。当队伍在游戏过程中收集到战利品时,就会输入该物品,所以他们知道什么自己何时会因为负担过重而无法拿起新物品。 + +在不同的游戏会话之间,可以引用和整理这份共享的电子表格,以便玩家(PC)知道哪些物品可以卖掉,哪些物品可以放入储物袋,哪些物品可以在下一次会话发现更好的战利品时安全的丢弃。 + +### 地图 + +Mythic Table 是一款开源的桌面游戏共享地图系统。这意味着你可以加载图片作为游戏地图,并在地图上移动数字标记以表示玩家角色所在的位置。 + +自从 [上次我介绍了关于 Mythic Table][13] 以来,它已经在 Kickstarter 上成功地进行了一次众筹,以确保它的持续发展。它还增加了一些新功能,其中最引人注目的是“战争迷雾”功能,它允许地下城主掩盖地图并仅显示玩家探索过的部分。 + +![A dungeon map rendered by Mythic Table and user interface choices for chat, maps, and characters][14] + +在过去的几个月里,我一直在 Mythic Table 上运行两款游戏,这是一款优秀且直观的地图系统。它还提供了一个数字骰子筒,所以如果你的玩家没有骰子,或者你更喜欢在公开场合掷骰子,你就可以用它作为共享的骰子池。 + +你可以在 [mythictable.com][15] 上试用 Mythic Table,或者访问他们在 [Github][16] 上的代码库。 + +### 开源的开放游戏 + +我使用的开源工具是通用的,因此它们适用于你想玩的任何游戏系统。因为它们都是开源的,所以无论你的玩家使用什么操作系统,他们都可以在线使用,并且它们都可以自托管。 + +如果你既是程序员又是游戏玩家,请访问他们的 Git 代码仓库,看看是否有任何你可以贡献的东西。如果你是游戏玩家或者游戏管理员,在下次坐在数字版的游戏桌前请尝试使用一下这些工具。你可能会惊讶于你只需要很少的在线账户就可以使用一些可用于游戏的最佳应用程序。 + +*(文内图片来自:Seth Kenlon,CC-BY-SA 4.0)* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/10/open-source-rpgs + +作者:[Seth Kenlon][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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/header_dice.png?itok=dOMrHopO (Dice as a random number generator) +[2]: https://www.freerpgday.com/ +[3]: https://goodman-games.com/blog/2021/10/06/pdf-previews-of-our-free-rpg-day-releases/ +[4]: https://paizo.com/community/blog/v5748dyo6shte +[5]: https://opensource.com/article/21/10/rpg-tabletop-games +[6]: http://mumble.info/ +[7]: https://opensource.com/sites/default/files/mumble-client.png (Mumble client) +[8]: https://jitsi.org/ +[9]: https://opensource.com/sites/default/files/jitsi-client.jpg (Jitsi) +[10]: https://opensource.com/article/21/10/3-ways-manage-your-character-sheets-open-source +[11]: http://ethercalc.net/ +[12]: https://opensource.com/sites/default/files/uploads/ethercalc.jpeg (Ethercalc) +[13]: https://opensource.com/article/20/11/open-source-battle-maps +[14]: https://opensource.com/sites/default/files/uploads/mythic.jpeg (Mythic Table) +[15]: http://mythictable.com/ +[16]: https://gitlab.com/mythicteam/mythictable diff --git a/published/20211104 Beginner-s Guide to Installing Arch Linux on VirtualBox.md b/published/20211104 Beginner-s Guide to Installing Arch Linux on VirtualBox.md new file mode 100644 index 0000000000..28d6c3f008 --- /dev/null +++ b/published/20211104 Beginner-s Guide to Installing Arch Linux on VirtualBox.md @@ -0,0 +1,270 @@ +[#]: subject: "Beginner’s Guide to Installing Arch Linux on VirtualBox" +[#]: via: "https://itsfoss.com/install-arch-linux-virtualbox/" +[#]: author: "Ankush Das https://itsfoss.com/author/ankush/" +[#]: collector: "lujun9972" +[#]: translator: "hanszhao80" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14834-1.html" + +在 VirtualBox 安装 Arch Linux 的新手操作指南 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/16/100738bceesesazv6rsxl4.jpg) + +[Arch Linux 在桌面 Linux 世界中非常流行][1]。受欢迎的原因之一是 [安装 Arch Linux][2] 本身就是一项复杂的任务。 + +我没有夸大其词。安装 [Ubuntu 或 Debian][3] 比 Arch Linux 容易得多,因为官方没给后者提供图形界面的安装程序。 + +这时虚拟机就派上用场了。 + +你可以先在 VirtualBox 中尝试安装 Arch Linux,看看它是否是你想在实际硬件上运行的系统。通过这种方式,你可以在不弄乱当前操作系统的情况下体验 Arch Linux。 + +在本文,我将一步一步指导你完成一个实用的 Arch Linux 虚拟机的安装过程。 + +### 在 VirtualBox 上安装 Arch Linux + +毫无疑问,你需要先 [在 Linux 上安装 VirtualBox][4](或在 Windows 上)。在 Windows 上,只需访问 Oracle 的网站并下载 VirtualBox。 + +> **[下载 VirtualBox][5]** + +如果你使用的是 Windows 10 或更高版本,请确保你的系统已启用虚拟化。 + +完成后,你需要到 [Arch Linux 官方网站][6] 下载 ISO 文件。你应该找到 [使用 torrent 下载][7] 或直接下载文件的选项。 + +![][8] + +你可以保留 ISO 文件以备不时之需,安装成功后也可以将其删除以 [释放系统上的空间][9]。 + +现在,让我们开始在 VirtualBox 上安装 Arch Linux 吧。 + +#### 第一部分 创建虚拟机 + +**第一步**:首先,你需要在 VirtualBox 中设置一下。启动 VirtualBox 并单击 “新建New” 来创建一个虚拟机。 + +![][10] + +注意,你可以使用 “向导模式guided mode” 继续创建虚拟机,但使用 “专家模式expert mode” 可以一目了然地获得更多选项。 + +![][11] + +因此,我推荐使用专家模式来创建虚拟机。 + +不用担心,专家模式同样简单,只是多了一些额外的可选项,无需担心其他任何事情。 + +**第二步**:输入你的虚拟机名称。当你在 “名称Name” 字段中输入 “Arch Linux” 时,它会分别自动检测 “类型Type” 和 “版本Version”。 + +![][12] + +你应该增加内存大小以舒适地使用虚拟机。如果只是用于小型测试,你可以继续使用默认设置。 + +我在这个例子中分配了 **4 GB 左右的内存**。 + +另外,请确保在 “硬盘Hard disk”选项下选择 “现在创建虚拟硬盘create a virtual hard disk”。它应该是默认选项。 + +现在,继续设置虚拟硬盘大小。 + +**第三步**:你可以选择虚拟硬盘的存放位置,并根据你的需求调整大小。最小分配大小(8 GB)对于安装系统应该不是问题,但安全起见,你可能得分配至少 10 到 15 GB。 + +![][13] + +接下来,你需要将硬盘硬盘文件类型选择为 “VDI(VirtualBox Disk Image)” ,将存储选择为 “动态分配Dynamically assigned”,如上图所示。 + +VDI 是虚拟硬盘最常见的硬盘类型。 + +当你为硬盘存储选择 “动态分配Dynamically allocated” 选项时,这意味着存储空间将根据使用情况进行使用。换言之,当创建虚拟机后,并不会立即将这 15 GB 的空间从你的磁盘中锁定。 + +现在,你所要做的就是点击 “创建Create” 来添加虚拟机。 + +#### 第二部分 添加 ISO 文件以开始安装 Arch Linux + +![][14] + +当虚拟机在左侧列表中出现后,你可以查看其配置并在 “存储Storage” 选项下选择 ISO 文件作为磁盘驱动。 + +你也可以单独前往虚拟机设置以探索更多内容并选择 ISO 文件。 + +![][15] + +为此,你需要导航至虚拟机设置的 “存储Storage” 标签页。 + +![][16] + +在这里,你必须单击 “控制器Controller” 下的 “没有盘片Empty”,然后继续选择 Arch Linux ISO 文件作为磁盘文件(如上图所示)。 + +![][17] + +完成选择后,点击 “OK” 以保存设置的变更。 + +将 ISO 设置为要引导的磁盘时,虚拟机设置应如下所示: + +![][18] + +现在,点击 “启动Start” 启动虚拟机并开始安装。 + +#### 第三部分 使用引导式安装程序安装 Arch Linux + +使用 [介绍一个引导式安装程序][19] 的方法使安装 Arch Linux 变得更容易,也就是说,它为你提供了设置成熟的 Arch Linux 系统所需的所有选项。 + +因此,在引导式安装程序的帮助下,你不必单独安装桌面环境和其他基本软件包。你所要做的就是按照屏幕上的说明选择适合你的选项。 + +在本文中,我们将重点介绍引导式安装程序。如果你想自己做,你应该遵循我们的 [Arch 安装指南][2]。 + +继续安装流程,当你启动虚拟机时,将看到以下屏幕: + +![][20] + +第一个选项是理想的处理方式。如果你有特定的要求,可以选择其他选项来启动 Arch Linux。 + +现在,你应该正在查看一个终端窗口。以下是如何开始: + +**第一步**:输入 `archinstall` 以使用引导式安装程序启动安装。 + +![][21] + +**第二步**:根据你的要求选择键盘布局,美式布局应该是最常见的选择。简单地输入一个数字即可进行选择,如下图所示(例如,26): + +![][22] + +**第三步**:接下来,你需要选择一个区域来下载包。 + +![][23] + +选择首选地区而不是 “全球Worldwide”。这至关重要,因为如果你选择 **全球** 作为你的地区,它会下载许多不必要的包。 + +**第四步**:选择区域后,它会要求你选择驱动器进行安装。在这个例子中,我们已经创建了一个大约 15 GB 的虚拟驱动器,显示为 `/dev/sda`。 + +类似的,根据大小检查你创建的驱动器,然后选择该磁盘继续。在这里,我输入 `1` 作为输入;你的可能会有所不同。 + +![][24] + +**第五步**:接下来,你将被询问以下内容: + + - 选择文件系统类型 + - 加密密码(可选的) + - 主机名 + - 创建 root 密码(可选的) + - 创建超级用户 + - 选择一个预编程的配置文件 + +![][25] + +在我的测试中,我选择了 btrfs 作为文件系统,没有设置任何磁盘加密密码。 + +主机名可随心所欲的设置,但我建议保持简短。 + +你可以选择创建一个 root 密码,即使不这么做也应该没什么问题。不过,你需要创建一个具有 sudo 权限的超级用户。 + +我使用 `admin`/`pass` 作为用户名和密码。不过,如果你不想让其他人访问你计算机上的虚拟机,则不应使用易于猜测的密码。 + +然后,你将看到一个选择配置文件的选项。在这种情况下,我们需要一个成熟的 Arch Linux 桌面。因此,我们通过输入 `0` 来选择 “桌面desktop”。 + +**第六步**:接下来,你将被要求选择桌面环境。我决定使用 KDE。你可以选择任何你喜欢的。 + +![][26] + +**第七步**:最后,你将被要求选择显卡驱动程序。由于我们是在 VirtualBox 上安装的 Arch Linux,你可以选择选项 4:VMware/VirtualBox,如下图所示: + +![][27] + +你可能还会被要求输入“是(`y`)或否(`n`)”选择 pipewire 而不是 PulseAudio 作为音频服务。选任何一个都应该都可以。 + +**第八步**:接下来是重要的一步。在这里,如果你需要内核的 LTS 版本,你可以选择使用 “linux-lts”,或者继续使用默认值。 + +![][28] + +安装程序会提示你输入想安装的软件包。在这里,我们没有任何特殊要求,因此我们将其留空并按回车键跳过。 + +**第九步**:你将被要求选择所需的网络适配器以启用互联网访问。你必须选择以下选项: + +“使用网络管理器来控制和管理你的互联网连接Use network manager to control and manage your internet connection” + +![][29] + +**第十步**:下一步需要定义时区。选择适用于你的时区,或继续使用默认选项。 + +**第十一步**:完成后,它将显示你选择的大部分选项以供确认。按回车键继续。 + +![][30] + +**第十二步**:安装完成需要花费几分钟时间,这取决于你的互联网连接速度。 + +安装完成后,它会要求你 “chroot 进入新创建的安装以进行安装后配置”,但我们不需要。因此输入 `N` 以完成安装。 + +**第十三步**:最后,你应该会再次看到终端窗口。输入: + +``` +shutdown now +``` + +这将安全地退出安装并关闭虚拟机。 + +一切就绪!在启动安装了 Arch 的虚拟机之前,你还需要做一件事 —— **移除选择作为光驱的 ISO 磁盘**。与添加启动 ISO 的方式类似,你可以前往虚拟机设置并将其删除,如下所示: + +![][31] + +到此为止你已在 VirtualBox 上安装了 Arch Linux。 + +你所要做的就是启动虚拟机,在我的例子中它是这样的: + +![virtualbox arch][32] + +尽管浏览这些选项需要一些时间,但 Arch Linux 上新的引导式安装程序可以节省大量时间使必填项配置正确。 + +![][33] + +同样的步骤也适用于在你的计算机上安装 Arch Linux。你需要用 Arch Linux ISO 文件 [使用 Etcher 制作单独的可启动 USB 盘][34]。 + +### 总结 + +[Arch Linux 成为一种流行的选择][1] 有多种原因。但是,如果这是你第一次安装,或者你想对其进行测试,那么虚拟机是在不打乱主机的情况下体验它的最佳方式。 + +我希望这可以帮助你在 VirtualBox 上安装 Arch Linux。在下面的评论中让我知道你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-arch-linux-virtualbox/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[hanszhao80](https://github.com/hanszhao80) +校对:[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/why-arch-linux/ +[2]: https://itsfoss.com/install-arch-linux/ +[3]: https://itsfoss.com/debian-vs-ubuntu/ +[4]: https://itsfoss.com/install-virtualbox-ubuntu/ +[5]: https://www.virtualbox.org/wiki/Downloads +[6]: https://archlinux.org/download/ +[7]: https://itsfoss.com/best-torrent-ubuntu/ +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/archlinux-downloads.png?resize=800%2C419&ssl=1 +[9]: https://itsfoss.com/free-up-space-ubuntu-linux/ +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/virtualbox-new.png?resize=800%2C562&ssl=1 +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/10/virtualbox-expert-mode.png?resize=707%2C438&ssl=1 +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/10/virtualbox-create.png?resize=800%2C536&ssl=1 +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/10/virtualbox-disk.png?resize=800%2C528&ssl=1 +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/10/choose-disk-virtualbox-arch.png?resize=800%2C440&ssl=1 +[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/10/virtualbox-settings-option.png?resize=800%2C551&ssl=1 +[16]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/10/virtualbox-choose-iso.png?resize=800%2C314&ssl=1 +[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/10/virtualbox-arch-iso-select.png?resize=800%2C348&ssl=1 +[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/10/virtualbox-set-start.png?resize=800%2C548&ssl=1 +[19]: https://news.itsfoss.com/arch-linux-easy-install/ +[20]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/virtualbox-archlinux-boot.png?resize=800%2C593&ssl=1 +[21]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/10/vb-archinstall-guided.png?resize=800%2C400&ssl=1 +[22]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/10/vb-archinstall-kb-layout.png?resize=800%2C694&ssl=1 +[23]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/archinstall-region.png?resize=800%2C664&ssl=1 +[24]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/archinstall-selectdisk.png?resize=800%2C199&ssl=1 +[25]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/10/archinstall-desktop-configure.png?resize=800%2C497&ssl=1 +[26]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/archinstall-virtualbox-desktop-environment.png?resize=800%2C415&ssl=1 +[27]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/10/virtualbox-environment.png?resize=419%2C173&ssl=1 +[28]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/10/archinstall-linux-kernel.png?resize=800%2C692&ssl=1 +[29]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/10/virtualbox-arch-network-manager.png?resize=800%2C151&ssl=1 +[30]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/10/archinstall-confirmation.png?resize=800%2C697&ssl=1 +[31]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/10/iso-remove-archinstall.png?resize=800%2C286&ssl=1 +[32]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/10/virtualbox-arch.png?resize=800%2C635&ssl=1 +[33]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/10/kde-arch-virtualbox.png?resize=800%2C453&ssl=1 +[34]: https://itsfoss.com/install-etcher-linux/ diff --git a/published/20211203 Should Businesses Opt for Serverless Computing-.md b/published/20211203 Should Businesses Opt for Serverless Computing-.md new file mode 100644 index 0000000000..6fa2d4a1e2 --- /dev/null +++ b/published/20211203 Should Businesses Opt for Serverless Computing-.md @@ -0,0 +1,93 @@ +[#]: subject: "Should Businesses Opt for Serverless Computing?" +[#]: via: "https://www.opensourceforu.com/2021/12/should-businesses-opt-for-serverless-computing/" +[#]: author: "Krishna Mohan Koyya https://www.opensourceforu.com/author/krishna-mohan-koyya/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14781-1.html" + +企业应该选择无服务器计算吗? +====== + +> 无服务器计算将服务器从规划中移除,使企业能够专注于应用功能。那么,企业是不是都应该选择无服务器计算呢?让我们来探究一下吧! + +![](https://img.linux.net.cn/data/attachment/album/202207/01/113921u4sjl5cczwj3tjbu.jpg) + +直至不久之前,几乎每个产品经理都会将他/她的工程资源,分成两个独立的团队 —— 开发团队和运维团队。开发团队通常参与编码、测试和构建应用功能,而运维团队负责应用程序的交付、部署和运行维护。 + +当开发团队构建电商应用时,运维团队会搭建好服务器来托管该应用。搭建服务器涉及到许多方面,其中包括: + +* 选择合适的硬件和操作系统 +* 应用所需的补丁集 +* 搭建所需服务器环境,如 JDK、Python、Tomcat、NodeJS 等 +* 部署、配置和提供实际的应用 +* 打开并固定合适的端口 +* 搭建所需的数据库引擎 + +……这个名单还在继续。 + +除此之外,管理人员还对容量规划感到头疼。毕竟,任何重要应用都应始终保持 100% 可用、可靠且可扩展。这需要对硬件进行最佳投资。众所周知,在一些关键时期,硬件短缺会导致业务损失,而硬件冗余又会损害利润。因此,无论应用是针对本地数据中心,还是针对云基础架构,容量规划都是至关重要的。到目前为止,很明显,企业不仅在功能构建上投入了大量的精力,还在功能交付上也花费了大量的时间。 + +无服务器计算Serverless computing旨在提供一种无缝的方式来交付功能,而无需担心服务器的设置和维护。换句话说,无服务器计算平台提供了一个“即用型ready-to-use”环境,企业可以尽快将应用程序构建和部署为一些较小的功能。这就是为什么这种方法被称为“功能即服务Function as a Service”(FaaS)。 + +请记住,无服务器计算中仍然存在服务器,但它由 AWS、微软和谷歌等 FaaS 供应商负责。 + +例如,AWS 以 “Lambda 函数”的形式提供了一个无服务器计算环境。开发人员可以选择将应用程序构建为一组 Lambda 函数,这些函数可以用 NodeJS、Java、Python 和其他一些语言编写。AWS 提供了一个现成的环境来部署这些函数。它还提供了即用​​型数据库服务器、文件服务器、应用程序网关和身份验证服务器等。 + +同样,微软 Azure 也提供了一个环境,它可以用 C# 等语言构建和部署 Azure 函数。 + +### 为什么选择无服务器? + +有两个主要因素推动了无服务器计算的普及。 + +#### 1、即用型环境 + +显然,这是无服务器计算的最大卖点。企业无需提前采购/预订硬件或实例,也无需操心许可证,以及设置和配置服务器。他们不需要为扩大和缩小规模而烦恼。所有这些都由 FaaS 供应商负责。 + +#### 2、最优成本 + +由于 FaaS 供应商总是根据环境的利用率向客户收费(按使用付费模式),因此企业无需担心前期成本和资源浪费。例如,AWS 根据 Lambda 函数接收的请求数量、在数据表上运行的查询数量等指标来向客户端收费。 + +### 无服务器计算的挑战 + +与任何其他方法一样,无服务器计算也不是每个人都可以盲目遵循的完美方法。它本身也有一系列限制。以下是其中的几个。 + +#### 1、供应商锁定 + +当使用无服务器计算时,第一个也是最重要的问题就是,Lambda 或 Azure 等函数将使用供应商提供的 API 来编写。例如,使用 AWS Lambda API 编写的函数无法部署到 Google Cloud 中,反之亦然。因此,无服务器计算迫使企业在许多年内,只能使用同一家供应商。并且,应用的成功或失败不仅取决于它的功能,还取决于供应商在性能等方面的能力。 + +#### 2、编程语言 + +没有哪家无服务器计算平台支持所有的编程语言。此外,对于它支持的编程语言,它也可能不支持其所有版本。这样一来,应用开发团队只能选择供应商提供的语言。就团队的能力而言,这可能是非常关键的。 + +#### 3、最优成本,真的吗? + +其实也不一定,这一切都取决于资源的使用情况。如果你的应用正在承受巨大的负载,例如每秒数百万个请求,那么你所支付的费用可能会过高。在这样的规模下,在本地或云端拥有自己的服务器可能会更便宜。这并不意味着具有 Web 规模的应用不适合用无服务器计算。归根结底,它还是取决于你的平台的构建方式,以及你与供应商签署的协议。 + +#### 4、生态系统 + +没有哪个应用是为了一个孤立的环境而编写的。它总是需要其他组件,如数据存储、数据库、安全引擎、网关、消息服务器、队列、缓存等。每个平台都提供自己的一组此类工具。例如,AWS 提供了 Dynamo DB 作为其 NoSQL 解决方案之一。显然,其他供应商也提供了自己的 NoSQL 解决方案。因此,团队又会被迫地基于所选平台来构建应用程序。尽管大多数商业 FaaS 供应商都为特定需求提供了多个组件,但并非每个组件都可能是同类型中最佳的。 + +### 为什么不考虑容器呢? + +在过去十年中,我们中的许多人都迁移到了容器化部署模型,因为它们为昂贵的物理机或虚拟机提供了一种轻量级的替代方案。有了 Kubernetes 等编排工具后,我们乐于部署容器化应用,同时也满足了 Web 规模的要求。容器提供了与底层环境一定程度的隔离,这使得部署相对容易。但是,我们仍然需要在硬件(本地或云)、许可证、网络、配置等方面进行投资,这需要具有前瞻性的规划、合适的技术能力和仔细的监控。无服务器计算,尽管它也有自己的优点和缺点,但它让我们把这些责任也摆脱了。 + +### 展望未来 + +我们正处于持续开发、持续集成和持续部署的时代。每个企业都面临着竞争。产品上市时间Time to market(TTM)在吸引客户、留住客户这两个方面,发挥着重要作用。在这种背景下,企业喜欢花更多时间来尽可能快地推出功能,而不是在部署和维护的细节上苦苦挣扎。无服务器计算有可能满足这些需求。大玩家们正在投入巨额资金,以使 FaaS 尽可能地无缝且经济。无服务器计算的未来看起来是一片光明。 + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2021/12/should-businesses-opt-for-serverless-computing/ + +作者:[Krishna Mohan Koyya][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/krishna-mohan-koyya/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2021/10/Severless-Cloud-Computing-Featured-image-OSFY-Oct-2021.jpg diff --git a/sources/tech/20220106 Send desktop notifications and reminders from Linux terminal.md b/published/20220106 Send desktop notifications and reminders from Linux terminal.md similarity index 50% rename from sources/tech/20220106 Send desktop notifications and reminders from Linux terminal.md rename to published/20220106 Send desktop notifications and reminders from Linux terminal.md index 73b3b708cc..35ed30f1e0 100644 --- a/sources/tech/20220106 Send desktop notifications and reminders from Linux terminal.md +++ b/published/20220106 Send desktop notifications and reminders from Linux terminal.md @@ -2,136 +2,107 @@ [#]: via: "https://opensource.com/article/22/1/linux-desktop-notifications" [#]: author: "Tomasz Waraksa https://opensource.com/users/tomasz" [#]: collector: "lujun9972" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " +[#]: translator: "mcfd" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14826-1.html" -Send desktop notifications and reminders from Linux terminal +如何从 Linux 终端发送桌面通知与提醒 ====== -This Linux tutorial demonstrates how to use script commands to send -yourself desktop notifications and reminders. -![Person using a laptop][1] -Sometimes it's useful to get visual feedback from a script. For example, when a script or cron job completes, a long-running build fails, or there is an urgent problem during script execution. Desktop applications can do this with popup notifications, but it can be done from a script too! You can use script commands to send yourself desktop notifications and reminders. +> 这篇教程演示如何使用脚本命令来发送自己的桌面通知与提醒。 + +![](https://img.linux.net.cn/data/attachment/album/202207/14/145103vawkhy6w506thy6h.jpg) + +有时候,来自脚本的视觉回馈是很有用的。例如,当一个脚本或计划任务完成时,一个长期运行的构建任务失败时,或者当脚本执行中出现了紧急问题时。桌面应用程序可以通过弹出通知来做到这一点,但脚本也可以做到这一点!你可以使用脚本命令来给自己发送桌面通知与提醒。 ![Example notification][2] -(Tomasz Waraksa, CC BY-SA 4.0) +下面的代码是在 Linux 上编写和测试的。它也可以在 macOS 上运行,只需花点功夫。请参见最后一节 [提示与技巧][3]。 -The below code has been written and tested on Linux. It can also be done on macOS with a bit of effort. See the last section for some [hints and tips][3]. +### 从 Linux 终端发送通知 -### Sending notifications from the Linux terminal - -To send notifications from the Linux terminal, use the [`notify-send`][4] command. Run `which ``notify-send` to see if it's present on your system. If not, install it with your package manager of choice. - -On Fedora, type: +要从 Linux 终端发送通知,请使用 [notify-send][4] 命令。运行 `which notify-send` 命令来查看它是否在于你的系统中。如果没有,请使用包管理器来安装它。 +在 Fedora 上,输入: ``` -`$ sudo dnf install notify-send` +$ sudo dnf install notify-send ``` -On Debian-based distributions, type: - +在基于 Debian 的发行版上,输入: ``` -`$ sudo apt install notify-send` +$ sudo apt install notify-send ``` -A few examples of simple notifications: - +几个简单的通知示例: ``` - - $ notify-send "Dinner ready!" $ notify-send "Tip of the Day" "How about a nap?" - ``` -You can customize the notification with options such as urgency level, custom icon, etc. Find out more with `man notify-send`. You can use a small set of HTML tags in the notification body to give your messages a nice touch. On top of that, URLs are rendered as clickable. For example: - +你可以用紧急程度、自定义图标等选项来自定义通知。过 `man notify-send` 了解更多。你也可以在通知正文中使用一小组 HTML 标记,以使消息有一个棒的视觉感受。最重要的是,URL 被呈现为可点击的。例如: ``` - - $ notify-send -u critical \ -  "Build failed!" \ -  "There were <b>123</b> errors. Click here to see the results: " - + "Build failed!" \ + "There were 123 errors. Click here to see the results: http://buildserver/latest" ``` ![Build fail notification][5] -(Tomasz Waraksa, CC BY-SA 4.0) +发送的通知会被桌面环境接收,并像其他通知一样显示。它们将具有相同的外观、交互和行为。 -Sent notifications are picked up by the desktop environment and displayed just like any other notification. They will have the same consistent look, feel, and behavior. - -### Combine notify-send with at - -Cron is commonly used to schedule commands at regular intervals. The `at` command schedules the single execution of a command at a specified time. If you run it like this, it starts in interactive mode, where you can enter commands to execute at a given time: +### 将 notify-send 与 at 结合使用 +计划任务通常被用来定期安排命令。`at` 命令安排在一个指定的时间执行一条命令。如果你像这样运行它,它会以交互模式启动,你可以在其中输入要在指定时间执行的命令: ``` -`$ at 12:00` +$ at 12:00 ``` -This isn't useful for scripts. Luckily, `at` accepts parameters from standard input so that we can use it this way: - +这对脚本来说并不有用。幸运的是 `at` 接受来自标准输入的参数,所以我们可以这样使用它: ``` - - $ echo "npm run build" | at now + 1 minute $ echo "backup-db" | at 13:00 - ``` -There are many ways of specifying time. From absolute time, such as `10:00` through relative time, such as `now + 2 hours`, to special times such as `noon` or `midnight`. We can combine it with `notify-send` to show ourselves reminders at some time in the future. For example: - +有许多指定时间的方法。 从绝对时间,如 `10:00`,到相对时间,如 `now + 2 hours` ,再特殊时间,如`noon` 或 `midnight`。我们可以把它和 `notify-send` 结合起来,在未来的某个时间向自己发送提醒。例如: ``` -`$ echo "notify-send 'Stop it and go home now?' 'Enough work for today.' -u critical" | at now` +$ echo "notify-send 'Stop it and go home now?' 'Enough work for today.' -u critical" | at now ``` ![Stop for the day notification][6] -(Tomasz Waraksa, CC BY-SA 4.0) - -### The remind command - -Now, build a custom Bash command for sending yourself reminders. How about something as simple and human-friendly as: +### 提醒的命令 +现在,建立一个自定义的 Bash 命令来给自己发送提醒信息。像这样简单且人性化的命令: ``` - - $ remind "I'm still here" now $ remind "Time to wake up!" in 5 minutes $ remind "Dinner" in 1 hour $ remind "Take a break" at noon $ remind "It's Friday pints time!" at 17:00 - ``` -This is better than Alexa! How to get this goodness? +这比 Alexa 更好!该怎样做? -See the code below. It defines a shell function called **remind**, which supports the above syntax. The actual work is done in the last two lines. The rest is responsible for help, parameter validation, etc., which roughly matches the proportion of useful code vs. necessary white-noise in any large application. - -Save the code somewhere, for example, in the `~/bin/remind` file, and source the function in your `.bashrc` profile so that it's loaded when you log in: +请看下面的代码。它定义了一个名为 `remind` 的函数,它支持上述语法。实际工作是在最后两行完成的。其余的部分负责显示帮助信息、参数校验等,这与任何大型应用程序中有用的代码与必要的白噪声的比例大致相同。 +把代码保存在某个地方,例如,在 `~/bin/remind` 文件中,并在你的 `.bashrc` 配置文件写入该函数,以便在你登录时加载它: ``` -`$ source ~/bin/remind` +$ source ~/bin/remind ``` -Reload the terminal, then type remind to see the syntax. Enjoy! - +重新打开终端,然后输入 `remind` 来查看语法。尽情享受吧! ``` - - #!/usr/bin/env bash function remind () {   local COUNT="$#" @@ -195,13 +166,15 @@ function remind () { ``` -### Easy notifications +### 简单的提醒 -With these few simple open source commands, you can integrate your own scripts, applications, and tasks with your desktop. Try it out! +通过这几个简单的开源命令,你可以将你自己的脚本、应用程序和任务与你的桌面结合起来。试一试吧! * * * -_This article has been adapted with the author's permission from the original article, found [here][7]._ +(文内图片来自 Tomasz Waraksa, CC BY-SA 4.0) + +本文经作者许可改编自 [原文][7]。 -------------------------------------------------------------------------------- @@ -209,8 +182,8 @@ via: https://opensource.com/article/22/1/linux-desktop-notifications 作者:[Tomasz Waraksa][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[mcfd](https://github.com/mcfd) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20220115 Why use a Raspberry Pi to power your business.md b/published/20220115 Why use a Raspberry Pi to power your business.md new file mode 100644 index 0000000000..e14dbdcdfb --- /dev/null +++ b/published/20220115 Why use a Raspberry Pi to power your business.md @@ -0,0 +1,80 @@ +[#]: subject: "Why use a Raspberry Pi to power your business" +[#]: via: "https://opensource.com/article/22/1/raspberry-pi-business" +[#]: author: "Giuseppe Cassibba https://opensource.com/users/peppe8o" +[#]: collector: "lujun9972" +[#]: translator: "void-mori" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14829-1.html" + +为何要使用树莓派为你的业务提供动力 +====== + +> 为何小小的单板机是智能工作以及小型办公室的未来。 + +![](https://img.linux.net.cn/data/attachment/album/202207/15/152016pcjh4heez4q0oof6.jpg) + +随着疫情的大流行,我们的工作方式也正在发生着改变。工作的分散化正在成为所有公司需要面临的一项重要挑战。 + +### 智能办公室 + +即使工厂认为智能办公仅仅是通过虚拟私有网络来对员工的笔记本电脑进行远程控制,再稍微增加一点进化也可以让一些基本的办公服务离人们更近一点,这些都能够极大降低数据中心的负载,并且提高人们的工作体验。这个方案还有一个额外的影响就是从信息和通信技术(ICT)上来说消除了许多单点故障。 + +与其在公司外部有成百上千的工作场地,不如在世界范围内有着成百上千的小型办公室/分支,这就是所谓的“智能办公室”。 + +这种表述可能会让许多 ICT 专家感到恐慌,因为这种文化使得每个办公室都与一台大机器(即服务器)联系在一起,即使分散计算资源的优势非常明显。 + +### 一个不同的角度 + +如果你能用一块 50 美元的小开发板提供一个大服务器的服务会怎么样?如果这个小板子只需要一张 SD 卡和一个普通的 USB 电源支持,那又会怎么样呢?这就是 [树莓派][2] 是最灵活的解决方案的原因所在。 + +树莓派开发板是尺寸非常小的运行 Linux 的计算机。它有一个由树莓派基金会提供和维护的操作系统:树莓派操作系统Raspberry Pi OS。它基于 Debian,并与这个最知名的 Linux 发行版共享许多软件包。此外,许多树莓派的开发板能够完美运行最知名的 Ubuntu 服务器,它涵盖了 ARM 处理器支持,提供了对低功耗处理器的支持。 + +但树莓派开发板对小公司来说也是一个很好的机会,以能够承担得起的代价获得大量的(开源)服务。但这种情况下,你必须考虑数据丢失的风险,因为你把所有的服务运行在一个小的、消费级的硬件上。不过设置正确的备份/恢复程序能够降低这些风险。 + +### 你能从树莓派开发板上提供什么服务? + +大多数服务通常由更昂贵的服务器提供。这里的“大多数”取决于一些限制: + + * **ARM 处理器:** 一些软件包只支持 x86/x64 处理器。这是最难克服的挑战之一。但另一方面,ARM 处理器的市场份额不断增长,使得程序员为他们的软件开发了兼容 ARM 处理器的版本。 + * **内存容量:** 这是一个仅限于在复杂应用以复杂的方式进行复杂的计算的情况下讨论的问题。很多时候,这只不过是关于重新审查代码、拆分步骤,并保持简单高效的问题。此外,如果一个服务虽然只服务少数几个用户,但需要大量的内存/CPU,这大概也意味着此服务没有正常工作。这可能是你消除浪费资源的旧问题的一个机会。最后,最新的树莓派开发板把内存容量升级到了 8GB,这是一个很大的提升。 + * **对服务器没有经验的用户:** 这是另一个问题,你可以在基础镜像所在的树莓派的 micro-SD 卡中存储系统和运行数据。 + +也就是说,你能够用树莓派做很多有趣的事情。在 [我的博客][4] 里,我通过运行各种服务进行了测试 —— 从基本的 LAMP 服务器到复杂的 CRM。从简单到复杂系统,全部都是开源的,例如: + + * 代理服务器(也能够添加广告拦截服务) + * 电子邮件服务器 + * 打印服务器 + * [酒店管理][5] + * 联系关系管理(CRM) + * [私人社交网络][6] + * 私人论坛 + * 私有 Git 门户网站 + * 网络监控服务器 + * [许多其他有用的服务][7] + +对树莓派来说,另一个有趣的用法是在你的远程办公室获得提供高级服务的 Wi-Fi 热点,并且可以从它的以太网端口进行控制。  + +最后,[树莓派也能够运行容器][8],这是一个额外的工具,从这个不可思议的开发板中获得一个可用的服务世界。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/1/raspberry-pi-business + +作者:[Giuseppe Cassibba][a] +选题:[lujun9972][b] +译者:[void-mori](https://github.com/void-mori) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/peppe8o +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BIZ_WorkInPublic_4618517_1110_CS_A.png?itok=RwVrWArk "A chair in a field." +[2]: https://opensource.com/resources/raspberry-pi +[3]: https://enterprisersproject.com/article/2020/11/raspberry-pi-7-enterprise-it-uses +[4]: https://peppe8o.com +[5]: https://opensource.com/article/20/4/qloapps-raspberry-pi +[6]: https://opensource.com/article/20/3/raspberry-pi-open-source-social +[7]: https://peppe8o.com/category/raspberrypi/ +[8]: https://opensource.com/article/20/8/kubernetes-raspberry-pi diff --git a/published/20220214 A guide to Kubernetes architecture.md b/published/20220214 A guide to Kubernetes architecture.md new file mode 100644 index 0000000000..ca87e0e93c --- /dev/null +++ b/published/20220214 A guide to Kubernetes architecture.md @@ -0,0 +1,165 @@ +[#]: subject: "A guide to Kubernetes architecture" +[#]: via: "https://opensource.com/article/22/2/kubernetes-architecture" +[#]: author: "Nived Velayudhan https://opensource.com/users/nivedv" +[#]: collector: "lujun9972" +[#]: translator: "MjSeven" +[#]: reviewer: "turbokernel" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14789-1.html" + +Kubernetes 架构指南 +====== + +> 了解 Kubernetes 架构中不同组件是如何组合在一起的,这样你就可以更好地排查问题、维护一个健康的集群,以及优化工作流。 + +![](https://img.linux.net.cn/data/attachment/album/202207/03/105135ey33hhx022m9y9fr.jpg) + +使用 Kubernetes 来编排容器,这种描述说起来简单,但理解它的实际含义以及如何实现它完全是另外一回事。如果你正在运行或管理 Kubernetes 集群,那么你就会知道 Kubernetes 由一台称为 “控制平面control plane” 的机器和许多其他 工作节点worker node 机器组成。每种类型都有一个复杂但稳定的堆栈,这使编排成为可能,熟悉每个组件有助于理解它是如何工作的。 + +![Kubernetes 架构图][2] + +*(Nived Velayudhan, [CC BY-SA 4.0][3])* + +### 控制平面组件 + +Kubernetes 安装在一个称为“控制平面control plane”的机器上,它会运行 Kubernetes 守护进程,并在启动容器和容器组pod时与之通信。下面介绍控制平面的各个组件。 + +#### etcd + +etcd 是一种快速、分布式一致性键值存储器,用作 Kubernetes 对象数据的持久存储,如容器组、副本控制器、密钥和服务。etcd 是 Kubernetes 存储集群状态和元数据的唯一地方。唯一与 etcd 直连的组件是 Kubernetes API 服务器。其他所有组件都通过 API 服务器间接的从 etcd 读写数据。 + +etcd 还实现了一个监控功能,它提供了一个基于事件的接口,用于异步监控键的更改。一旦你更改了一个键,它的监控者就会收到通知。API 服务器组件严重依赖于此来获得通知,并将 etcd 变更至期望状态。 + +_为什么 etcd 实例的数量应该是奇数?_ + +你通常会运行三个、五个或七个 etcd 实例实现高可用(HA)环境,但这是为什么呢?因为 etcd 是分布式数据存储,可以水平扩展它,但你需要确保每个实例中的数据是一致的。因此,需要为系统当前状态达成共识,etcd 为此使用 [RAFT 共识算法][4]。 + +RAFT 算法需要经过选举(或仲裁)集群才能进入下一个状态。如果你只有两个 etcd 实例并且他们其中一个失败的话,那么 etcd 集群无法转换到新的状态,因为不存在过半这个概念。如果你有三个 etcd 实例,一个实例可能会失败,但仍有 2 个实例可用于进行选举。 + +#### API 服务器 + +API 服务器是 Kubernetes 中唯一直接与 etcd 交互的组件。Kubernetes 中的其他所有组件都必须通过 API 服务器来处理集群状态,包括客户端(kubectl)。API 服务器具有以下功能: + + * 提供在 etcd 中存储对象的一致方式。 + * 执行验证对象,防止客户端存储配置不正确的对象(如果它们直接写入 etcd 数据存储,可能会发生这种情况)。 + * 提供 RESTful API 来创建、更新、修改或删除资源。 + * 提供 [乐观并发锁][5],在发生更新时,其他客户端永远不会有机会重写对象。 + * 对客户端发送的请求进行身份验证和授权。它使用插件提取客户端的用户名、ID、所属组,并确定通过身份验证的用户是否可以对请求的资源执行请求的操作。 + * 如果请求试图创建、修改或删除资源,则负责 [权限控制][6]。例如,AlwaysPullImages、DefaultStorageClass 和 ResourceQuota。 + * 实现了一种监控机制(类似于 etcd),用户客户端监控更改。这允许调度器和控制器管理器等组件以松耦合的方式与 API 服务器交互。 + +#### 控制器管理器 + +在 Kubernetes 中,控制器持续监控集群状态,然后根据需要进行或请求更改。每个控制器都尝试将当前集群状态变更至期望状态。控制器至少跟踪一种 Kubernetes 资源类型,这些对象均有一个字段来表示期望的状态。 + +控制器示例: + + * 副本管理器(管理副本控制器ReplicationController资源的控制器) + * 副本集ReplicaSet守护进程集DaemonSet 和任务控制器 + * 部署控制器 + * 有状态负载控制器 + * 节点控制器 + * 服务控制器 + * 接入点控制器 + * 命名空间控制器 + * 持久卷PersistentVolume控制器 + +控制器通过监控机制来获得变更通知。它们监视 API 服务器对资源的变更,对每次更改执行操作,无论是新建对象还是更新或删除现有对象。大多数时候,这些操作包括创建其他资源或更新监控的资源本身。不过,由于使用监控并不能保证控制器不会错过任何事件,它们还会定期执行一系列操作,确保没有错过任何事件。 + +控制器管理器还执行生命周期功能。例如命名空间创建和生命周期、事件垃圾收集、已终止容器组垃圾收集、[级联删除垃圾收集][7] 和节点垃圾收集。有关更多信息,参考 [云控制器管理器][8]。 + +#### 调度器 + +调度器是一个将容器组分配给节点的控制平面进程。它会监视新创建没有分配节点的容器组。调度器会给每个发现的容器组分配运行它的最佳节点。 + +满足容器组调度要求的节点称为可调度节点。如果没有合适的节点,那么容器组会一直处于未调度状态,直到调度器可以安置它。一旦找到可调度节点,它就会运行一组函数来对节点进行评分,并选择得分最高的节点,然后它会告诉 API 服务器所选节点的信息。这个过程称为绑定。 + +节点的选择分为两步: + + 1. 过滤所有节点的列表,获得可以调度容器组的节点列表(例如,PodFitsResources 过滤器检查候选节点是否有足够的可用资源来满足容器组的特定资源请求)。 + 2. 对第一步得到的节点列表进行评分和排序,选择最佳节点。如果得分最高的有多个节点,循环过程可确保容器组会均匀地部署在所有节点上。 + +调度决策要考虑的因素包括: + + * 容器组是否请求硬件/软件资源?节点是否报告内存或磁盘压力情况? + * 节点是否有与容器组规范中的节点选择器匹配的标签? + * 如果容器组请求绑定到特定地主机端口,该端口是否可用? + * 容器组是否容忍节点的污点? + * 容器组是否指定节点亲和性或反亲和性规则? + +调度器不会指示所选节点运行容器组。调度器所做的就是通过 API 服务器更新容器组定义。然后 API 服务器通过监控机制通知 kubelet 容器组已被调度,然后目标节点上的 kubelet 服务看到容器组被调度到它的节点,它创建并运行容器组。 + +### 工作节点组件 + +工作节点运行 kubelet 代理,这允许控制平面接纳它们来处理负载。与控制平面类似,工作节点使用几个不同的组件来实现这一点。 以下部分描述了工作节点组件。 + +#### Kubelet + +Kubelet 是一个运行在集群中每个节点上的代理,负责在工作节点上运行的所有事情。它确保容器在吊舱中运行。 + +kubelet服务的主要功能有: + + * 通过在 API 服务器中创建节点资源来注册它正在运行的节点。 + * 持续监控 API 服务器上调度到节点的容器组。 + * 使用配置的容器运行时启动容器组的容器。 + * 持续监控正在运行的容器,并将其状态、事件和资源消耗报告给 API 服务器。 + * 运行容器存活探测,在探测失败时重启容器,当 API 服务器中删除容器组时终止(通知服务器容器组终止的消息)。 + +#### 服务代理 + +服务代理(kube-proxy)在每个节点上运行,确保一个容器组可以与另一个容器组通讯,一个节点可以与另一个节点对话,一个容器可以与另一个容器对话。它负责监视 API 服务器对服务和容器组定义的更改,以保持整个网络配置是最新的。当一项服务得到多个容器组的支持时,代理会在这些容器组之间执行负载平衡。 + +kube-proxy 之所以叫代理,是因为它最初实际上是一个代理服务器,用于接受连接并将它们代理到容器组。当前的实现是使用 iptables 规则将数据包重定向到随机选择的后端容器组,而无需通过实际的代理服务器。 + +关于它工作原理的高级视图: + + * 当你创建一个服务时,会立即分配一个虚拟 IP 地址。 + * API 服务器会通知在工作节点上运行的 kube-proxy 代理有一个新服务。 + * 每个 kube-proxy 通过设置 iptables 规则使服务可寻址,确保截获每个服务 IP/端口对,并将目的地址修改为支持服务的一个容器组。 + * 监控 API 服务器对服务或其端点对象的更改。 + +#### 容器运行时 + +容器运行时有两类: + + * **较低级别的容器运行时:** 它们主要关注运行中的容器并为容器设置命名空间和控制组cgroup。 + * **更高级别的容器运行时(容器引擎):** 它们专注于格式、解包、管理、共享镜像以及为开发人员提供 API。 + +容器运行时负责: + + * 如果容器镜像本地不存在,则从镜像仓库中提取。 + * 将镜像解压到写时复制文件系统,所有容器层叠加创建一个合并的文件系统。 + * 准备一个容器挂载点。 + * 设置容器镜像的元数据,如覆盖命令、用户输入的入口命令,并设置 SECCOMP 规则,确保容器按预期运行。 + * 通知内核将进程、网络和文件系统等隔离分配给容器。 + * 通知内核分配一些资源限制,如 CPU 或内存限制。 + * 将系统调用(syscall)传递给内核启动容器。 + * 确保 SElinux/AppArmor 设置正确。 + +### 协同 + +系统级组件协同工作,确保 Kubernetes 集群的每个部分都能实现其目和执行其功能。当你深入编辑 [YAML 文件][10] 时,有时很难理解请求是如何在集群中通信的。现在你已经了解了各个部分是如何组合在一起的,你可以更好地理解 Kubernetes 内部发生了什么,这有助于诊断问题、维护健康的集群并优化你的工作流。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/2/kubernetes-architecture + +作者:[Nived Velayudhan][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[turbokernel](https://github.com/turbokernel) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/nivedv +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/containers_modules_networking_hardware_parts.png?itok=rPpVj92- (Parts, modules, containers for software) +[2]: https://opensource.com/sites/default/files/uploads/kubernetes-architecture-diagram.png (Kubernetes architecture diagram) +[3]: https://creativecommons.org/licenses/by-sa/4.0/ +[4]: https://www.geeksforgeeks.org/raft-consensus-algorithm/ +[5]: https://stackoverflow.com/questions/52910322/kubernetes-resource-versioning#:~:text=Optimistic%20concurrency%20control%20\(sometimes%20referred,updated%2C%20the%20version%20number%20increases. +[6]: https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/ +[7]: https://kubernetes.io/docs/concepts/architecture/garbage-collection/ +[8]: https://kubernetes.io/docs/concepts/architecture/cloud-controller/ +[9]: https://www.redhat.com/architect/how-kubernetes-creates-runs-containers +[10]: https://www.redhat.com/sysadmin/yaml-beginners diff --git a/published/20180523 Creating random, secure passwords in Go.md b/published/202205/20180523 Creating random, secure passwords in Go.md similarity index 100% rename from published/20180523 Creating random, secure passwords in Go.md rename to published/202205/20180523 Creating random, secure passwords in Go.md diff --git a/published/20180529 Build a concurrent TCP server in Go.md b/published/202205/20180529 Build a concurrent TCP server in Go.md similarity index 100% rename from published/20180529 Build a concurrent TCP server in Go.md rename to published/202205/20180529 Build a concurrent TCP server in Go.md diff --git a/translated/tech/20180625 3 ways to copy files in Go.md b/published/202205/20180625 3 ways to copy files in Go.md similarity index 93% rename from translated/tech/20180625 3 ways to copy files in Go.md rename to published/202205/20180625 3 ways to copy files in Go.md index b362d05e2f..7a6d0a1647 100644 --- a/translated/tech/20180625 3 ways to copy files in Go.md +++ b/published/202205/20180625 3 ways to copy files in Go.md @@ -3,17 +3,16 @@ [#]: author: "Mihalis Tsoukalos https://opensource.com/users/mtsouk" [#]: collector: "lkxed" [#]: translator: "lkxed" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14658-1.html" 在 Go 中复制文件的三种方法 ====== -本文是 Go 系列的第三篇文章,我将介绍三种最流行的复制文件的方法。 -![][1] +![](https://img.linux.net.cn/data/attachment/album/202205/31/153413kcrth9v8c93r5u8e.jpg) -图源:Opensource.com +> 本文是 Go 系列的第三篇文章,我将介绍三种最流行的复制文件的方法。 本文将介绍展示如何使用 [Go 编程语言][3] 来复制文件。在 Go 中复制文件的方法有很多,我只介绍三种最常见的:使用 Go 库中的 `io.Copy()` 函数调用、一次读取输入文件并将其写入另一个文件,以及使用缓冲区一块块地复制文件。 @@ -85,7 +84,7 @@ if err != nil { } ``` -上述代码包括了两个 if 代码块(嗯,用 Go 写程序就是这样的),程序的实际功能其实体现在 `ioutil.ReadFile()` 和 `ioutil.WriteFile()` 这两行代码中。 +上述代码包括了两个 `if` 代码块(嗯,用 Go 写程序就是这样的),程序的实际功能其实体现在 `ioutil.ReadFile()` 和 `ioutil.WriteFile()` 这两行代码中。 运行 `cp2.go`,你会得到下面的输出: @@ -204,7 +203,7 @@ via: https://opensource.com/article/18/6/copying-files-go 作者:[Mihalis Tsoukalos][a] 选题:[lkxed][b] 译者:[lkxed](https://github.com/lkxed) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20190404 Why you should choose mindfulness over multitasking.md b/published/202205/20190404 Why you should choose mindfulness over multitasking.md similarity index 100% rename from published/20190404 Why you should choose mindfulness over multitasking.md rename to published/202205/20190404 Why you should choose mindfulness over multitasking.md diff --git a/published/20200303 Watching activity on Linux with watch and tail commands.md b/published/202205/20200303 Watching activity on Linux with watch and tail commands.md similarity index 100% rename from published/20200303 Watching activity on Linux with watch and tail commands.md rename to published/202205/20200303 Watching activity on Linux with watch and tail commands.md diff --git a/published/20200807 A Beginner-s Guide to Open Source.md b/published/202205/20200807 A Beginner-s Guide to Open Source.md similarity index 100% rename from published/20200807 A Beginner-s Guide to Open Source.md rename to published/202205/20200807 A Beginner-s Guide to Open Source.md diff --git a/published/20210102 Explore the night sky with this open source astronomy app.md b/published/202205/20210102 Explore the night sky with this open source astronomy app.md similarity index 100% rename from published/20210102 Explore the night sky with this open source astronomy app.md rename to published/202205/20210102 Explore the night sky with this open source astronomy app.md diff --git a/published/20210111 9 Decentralized, P2P and Open Source Alternatives to Mainstream Social Media Platforms Like Twitter, Facebook, YouTube and Reddit.md b/published/202205/20210111 9 Decentralized, P2P and Open Source Alternatives to Mainstream Social Media Platforms Like Twitter, Facebook, YouTube and Reddit.md similarity index 100% rename from published/20210111 9 Decentralized, P2P and Open Source Alternatives to Mainstream Social Media Platforms Like Twitter, Facebook, YouTube and Reddit.md rename to published/202205/20210111 9 Decentralized, P2P and Open Source Alternatives to Mainstream Social Media Platforms Like Twitter, Facebook, YouTube and Reddit.md diff --git a/published/20210112 8 tips for the Linux command line.md b/published/202205/20210112 8 tips for the Linux command line.md similarity index 100% rename from published/20210112 8 tips for the Linux command line.md rename to published/202205/20210112 8 tips for the Linux command line.md diff --git a/published/20210122 Convert your filesystem to Btrfs.md b/published/202205/20210122 Convert your filesystem to Btrfs.md similarity index 100% rename from published/20210122 Convert your filesystem to Btrfs.md rename to published/202205/20210122 Convert your filesystem to Btrfs.md diff --git a/published/20210211 31 open source text editors you need to try.md b/published/202205/20210211 31 open source text editors you need to try.md similarity index 100% rename from published/20210211 31 open source text editors you need to try.md rename to published/202205/20210211 31 open source text editors you need to try.md diff --git a/published/20210305 Build a printer UI for Raspberry Pi with XML and Java.md b/published/202205/20210305 Build a printer UI for Raspberry Pi with XML and Java.md similarity index 100% rename from published/20210305 Build a printer UI for Raspberry Pi with XML and Java.md rename to published/202205/20210305 Build a printer UI for Raspberry Pi with XML and Java.md diff --git a/published/20210310 Troubleshoot WiFi problems with Go and a Raspberry Pi.md b/published/202205/20210310 Troubleshoot WiFi problems with Go and a Raspberry Pi.md similarity index 100% rename from published/20210310 Troubleshoot WiFi problems with Go and a Raspberry Pi.md rename to published/202205/20210310 Troubleshoot WiFi problems with Go and a Raspberry Pi.md diff --git a/published/20210323 WebAssembly Security, Now and in the Future.md b/published/202205/20210323 WebAssembly Security, Now and in the Future.md similarity index 100% rename from published/20210323 WebAssembly Security, Now and in the Future.md rename to published/202205/20210323 WebAssembly Security, Now and in the Future.md diff --git a/published/20210428 Share files between Linux and Windows computers.md b/published/202205/20210428 Share files between Linux and Windows computers.md similarity index 100% rename from published/20210428 Share files between Linux and Windows computers.md rename to published/202205/20210428 Share files between Linux and Windows computers.md diff --git a/published/20210615 Listen to music on FreeDOS.md b/published/202205/20210615 Listen to music on FreeDOS.md similarity index 100% rename from published/20210615 Listen to music on FreeDOS.md rename to published/202205/20210615 Listen to music on FreeDOS.md diff --git a/published/20210617 Linux package management with dnf.md b/published/202205/20210617 Linux package management with dnf.md similarity index 100% rename from published/20210617 Linux package management with dnf.md rename to published/202205/20210617 Linux package management with dnf.md diff --git a/published/20210624 Linux package management with apt.md b/published/202205/20210624 Linux package management with apt.md similarity index 100% rename from published/20210624 Linux package management with apt.md rename to published/202205/20210624 Linux package management with apt.md diff --git a/published/20210710 A new open source operating system for embedded systems.md b/published/202205/20210710 A new open source operating system for embedded systems.md similarity index 100% rename from published/20210710 A new open source operating system for embedded systems.md rename to published/202205/20210710 A new open source operating system for embedded systems.md diff --git a/published/20211213 How I use open source to design my own card games.md b/published/202205/20211213 How I use open source to design my own card games.md similarity index 100% rename from published/20211213 How I use open source to design my own card games.md rename to published/202205/20211213 How I use open source to design my own card games.md diff --git a/published/20220113 Learn Rust in 2022.md b/published/202205/20220113 Learn Rust in 2022.md similarity index 100% rename from published/20220113 Learn Rust in 2022.md rename to published/202205/20220113 Learn Rust in 2022.md diff --git a/published/20220212 5 levels of transparency for open source communities.md b/published/202205/20220212 5 levels of transparency for open source communities.md similarity index 100% rename from published/20220212 5 levels of transparency for open source communities.md rename to published/202205/20220212 5 levels of transparency for open source communities.md diff --git a/published/20220219 Crop and resize photos on Linux with Gwenview.md b/published/202205/20220219 Crop and resize photos on Linux with Gwenview.md similarity index 100% rename from published/20220219 Crop and resize photos on Linux with Gwenview.md rename to published/202205/20220219 Crop and resize photos on Linux with Gwenview.md diff --git a/published/20220221 3 steps to start running containers today.md b/published/202205/20220221 3 steps to start running containers today.md similarity index 100% rename from published/20220221 3 steps to start running containers today.md rename to published/202205/20220221 3 steps to start running containers today.md diff --git a/published/20220327 Top 10 Linux Distributions for Programmers in 2022 -Featured.md b/published/202205/20220327 Top 10 Linux Distributions for Programmers in 2022 -Featured.md similarity index 100% rename from published/20220327 Top 10 Linux Distributions for Programmers in 2022 -Featured.md rename to published/202205/20220327 Top 10 Linux Distributions for Programmers in 2022 -Featured.md diff --git a/published/20220414 A guide to JVM parameters for Java developers.md b/published/202205/20220414 A guide to JVM parameters for Java developers.md similarity index 100% rename from published/20220414 A guide to JVM parameters for Java developers.md rename to published/202205/20220414 A guide to JVM parameters for Java developers.md diff --git a/published/20220419 Difference Between Ubuntu 22.04 and Ubuntu 20.04 LTS.md b/published/202205/20220419 Difference Between Ubuntu 22.04 and Ubuntu 20.04 LTS.md similarity index 100% rename from published/20220419 Difference Between Ubuntu 22.04 and Ubuntu 20.04 LTS.md rename to published/202205/20220419 Difference Between Ubuntu 22.04 and Ubuntu 20.04 LTS.md diff --git a/published/20220422 Documentation Isn’t Just Another Aspect of Open Source Development.md b/published/202205/20220422 Documentation Isn’t Just Another Aspect of Open Source Development.md similarity index 100% rename from published/20220422 Documentation Isn’t Just Another Aspect of Open Source Development.md rename to published/202205/20220422 Documentation Isn’t Just Another Aspect of Open Source Development.md diff --git a/published/20220423 5 Less Popular Features that Make Ubuntu 22.04 LTS an Epic Release.md b/published/202205/20220423 5 Less Popular Features that Make Ubuntu 22.04 LTS an Epic Release.md similarity index 100% rename from published/20220423 5 Less Popular Features that Make Ubuntu 22.04 LTS an Epic Release.md rename to published/202205/20220423 5 Less Popular Features that Make Ubuntu 22.04 LTS an Epic Release.md diff --git a/published/20220425 Exciting New Features Revealed for KDE Plasma 5.25- Take a Look Here.md b/published/202205/20220425 Exciting New Features Revealed for KDE Plasma 5.25- Take a Look Here.md similarity index 100% rename from published/20220425 Exciting New Features Revealed for KDE Plasma 5.25- Take a Look Here.md rename to published/202205/20220425 Exciting New Features Revealed for KDE Plasma 5.25- Take a Look Here.md diff --git a/published/20220425 Linux Mint Upgrade Tool - Here-s How it Works.md b/published/202205/20220425 Linux Mint Upgrade Tool - Here-s How it Works.md similarity index 100% rename from published/20220425 Linux Mint Upgrade Tool - Here-s How it Works.md rename to published/202205/20220425 Linux Mint Upgrade Tool - Here-s How it Works.md diff --git a/published/20220426 How to Upgrade to Pop OS 22.04 LTS from 21.10 -Step by Step.md b/published/202205/20220426 How to Upgrade to Pop OS 22.04 LTS from 21.10 -Step by Step.md similarity index 100% rename from published/20220426 How to Upgrade to Pop OS 22.04 LTS from 21.10 -Step by Step.md rename to published/202205/20220426 How to Upgrade to Pop OS 22.04 LTS from 21.10 -Step by Step.md diff --git a/published/20220427 10 Reasons to Run Linux in Virtual Machines.md b/published/202205/20220427 10 Reasons to Run Linux in Virtual Machines.md similarity index 100% rename from published/20220427 10 Reasons to Run Linux in Virtual Machines.md rename to published/202205/20220427 10 Reasons to Run Linux in Virtual Machines.md diff --git a/published/20220427 Bloomberg Open Sources Memray, A Python Memory Profiler.md b/published/202205/20220427 Bloomberg Open Sources Memray, A Python Memory Profiler.md similarity index 100% rename from published/20220427 Bloomberg Open Sources Memray, A Python Memory Profiler.md rename to published/202205/20220427 Bloomberg Open Sources Memray, A Python Memory Profiler.md diff --git a/published/20220427 Hands on With GNOME-s New Text Editor for Linux Users.md b/published/202205/20220427 Hands on With GNOME-s New Text Editor for Linux Users.md similarity index 100% rename from published/20220427 Hands on With GNOME-s New Text Editor for Linux Users.md rename to published/202205/20220427 Hands on With GNOME-s New Text Editor for Linux Users.md diff --git a/published/20220427 How I grew my product management career with open source.md b/published/202205/20220427 How I grew my product management career with open source.md similarity index 100% rename from published/20220427 How I grew my product management career with open source.md rename to published/202205/20220427 How I grew my product management career with open source.md diff --git a/published/20220427 Shortwave 3.0 is Here With UI Upgrades, Private Stations, and More Improvements.md b/published/202205/20220427 Shortwave 3.0 is Here With UI Upgrades, Private Stations, and More Improvements.md similarity index 100% rename from published/20220427 Shortwave 3.0 is Here With UI Upgrades, Private Stations, and More Improvements.md rename to published/202205/20220427 Shortwave 3.0 is Here With UI Upgrades, Private Stations, and More Improvements.md diff --git a/published/20220428 Archinstall-s New Menu System Makes it Even Easier to Install Arch Linux.md b/published/202205/20220428 Archinstall-s New Menu System Makes it Even Easier to Install Arch Linux.md similarity index 100% rename from published/20220428 Archinstall-s New Menu System Makes it Even Easier to Install Arch Linux.md rename to published/202205/20220428 Archinstall-s New Menu System Makes it Even Easier to Install Arch Linux.md diff --git a/published/20220428 Elon Musk’s Plan To Open Source The Twitter Algorithm Has Flaws.md b/published/202205/20220428 Elon Musk’s Plan To Open Source The Twitter Algorithm Has Flaws.md similarity index 100% rename from published/20220428 Elon Musk’s Plan To Open Source The Twitter Algorithm Has Flaws.md rename to published/202205/20220428 Elon Musk’s Plan To Open Source The Twitter Algorithm Has Flaws.md diff --git a/published/20220428 How to Remove Snap Packages in Ubuntu Linux.md b/published/202205/20220428 How to Remove Snap Packages in Ubuntu Linux.md similarity index 100% rename from published/20220428 How to Remove Snap Packages in Ubuntu Linux.md rename to published/202205/20220428 How to Remove Snap Packages in Ubuntu Linux.md diff --git a/published/20220428 Why use Apache Druid for your open source analytics database.md b/published/202205/20220428 Why use Apache Druid for your open source analytics database.md similarity index 100% rename from published/20220428 Why use Apache Druid for your open source analytics database.md rename to published/202205/20220428 Why use Apache Druid for your open source analytics database.md diff --git a/published/20220429 Detect a Phishing URL Using Machine Learning in Python.md b/published/202205/20220429 Detect a Phishing URL Using Machine Learning in Python.md similarity index 100% rename from published/20220429 Detect a Phishing URL Using Machine Learning in Python.md rename to published/202205/20220429 Detect a Phishing URL Using Machine Learning in Python.md diff --git a/published/20220430 Hands On With GNOME’s New Terminal for Linux Users.md b/published/202205/20220430 Hands On With GNOME’s New Terminal for Linux Users.md similarity index 100% rename from published/20220430 Hands On With GNOME’s New Terminal for Linux Users.md rename to published/202205/20220430 Hands On With GNOME’s New Terminal for Linux Users.md diff --git a/published/20220430 How to Install h.264 decoder on Ubuntu Linux.md b/published/202205/20220430 How to Install h.264 decoder on Ubuntu Linux.md similarity index 100% rename from published/20220430 How to Install h.264 decoder on Ubuntu Linux.md rename to published/202205/20220430 How to Install h.264 decoder on Ubuntu Linux.md diff --git a/published/20220430 Rust-based Redox OS 0.7.0 Arrives with Enhanced Hardware Support.md b/published/202205/20220430 Rust-based Redox OS 0.7.0 Arrives with Enhanced Hardware Support.md similarity index 100% rename from published/20220430 Rust-based Redox OS 0.7.0 Arrives with Enhanced Hardware Support.md rename to published/202205/20220430 Rust-based Redox OS 0.7.0 Arrives with Enhanced Hardware Support.md diff --git a/published/20220501 How to Install Classic GNOME Flashback in Ubuntu 22.04 LTS.md b/published/202205/20220501 How to Install Classic GNOME Flashback in Ubuntu 22.04 LTS.md similarity index 100% rename from published/20220501 How to Install Classic GNOME Flashback in Ubuntu 22.04 LTS.md rename to published/202205/20220501 How to Install Classic GNOME Flashback in Ubuntu 22.04 LTS.md diff --git a/published/20220502 How to make community recognition more inclusive.md b/published/202205/20220502 How to make community recognition more inclusive.md similarity index 100% rename from published/20220502 How to make community recognition more inclusive.md rename to published/202205/20220502 How to make community recognition more inclusive.md diff --git a/published/20220502 Microsoft Joins The Open 3D Foundation For Open Source 3D Development.md b/published/202205/20220502 Microsoft Joins The Open 3D Foundation For Open Source 3D Development.md similarity index 100% rename from published/20220502 Microsoft Joins The Open 3D Foundation For Open Source 3D Development.md rename to published/202205/20220502 Microsoft Joins The Open 3D Foundation For Open Source 3D Development.md diff --git a/published/20220502 Tools You Can Use for the Security Audit of IoT Devices.md b/published/202205/20220502 Tools You Can Use for the Security Audit of IoT Devices.md similarity index 100% rename from published/20220502 Tools You Can Use for the Security Audit of IoT Devices.md rename to published/202205/20220502 Tools You Can Use for the Security Audit of IoT Devices.md diff --git a/published/20220502 Ubuntu’s Unity Desktop Still Lives- Version 7.6 is Available for Testing After 6 Years.md b/published/202205/20220502 Ubuntu’s Unity Desktop Still Lives- Version 7.6 is Available for Testing After 6 Years.md similarity index 100% rename from published/20220502 Ubuntu’s Unity Desktop Still Lives- Version 7.6 is Available for Testing After 6 Years.md rename to published/202205/20220502 Ubuntu’s Unity Desktop Still Lives- Version 7.6 is Available for Testing After 6 Years.md diff --git a/published/20220503 Nvidia Begins To Set The Foundation For Future Open And Parallel Coding.md b/published/202205/20220503 Nvidia Begins To Set The Foundation For Future Open And Parallel Coding.md similarity index 100% rename from published/20220503 Nvidia Begins To Set The Foundation For Future Open And Parallel Coding.md rename to published/202205/20220503 Nvidia Begins To Set The Foundation For Future Open And Parallel Coding.md diff --git a/published/20220503 Package Analysis Examines Packages In Open Source Repositories In Real Time.md b/published/202205/20220503 Package Analysis Examines Packages In Open Source Repositories In Real Time.md similarity index 100% rename from published/20220503 Package Analysis Examines Packages In Open Source Repositories In Real Time.md rename to published/202205/20220503 Package Analysis Examines Packages In Open Source Repositories In Real Time.md diff --git a/published/20220504 ESI Group Collaborates With ENSAM, Open Sources Its “Inspector” Software.md b/published/202205/20220504 ESI Group Collaborates With ENSAM, Open Sources Its “Inspector” Software.md similarity index 100% rename from published/20220504 ESI Group Collaborates With ENSAM, Open Sources Its “Inspector” Software.md rename to published/202205/20220504 ESI Group Collaborates With ENSAM, Open Sources Its “Inspector” Software.md diff --git a/published/20220504 Firefox 100 Marks 17 Years of Development with Interesting Upgrades.md b/published/202205/20220504 Firefox 100 Marks 17 Years of Development with Interesting Upgrades.md similarity index 100% rename from published/20220504 Firefox 100 Marks 17 Years of Development with Interesting Upgrades.md rename to published/202205/20220504 Firefox 100 Marks 17 Years of Development with Interesting Upgrades.md diff --git a/published/20220504 How I manage my own virtual network with ZeroTier.md b/published/202205/20220504 How I manage my own virtual network with ZeroTier.md similarity index 100% rename from published/20220504 How I manage my own virtual network with ZeroTier.md rename to published/202205/20220504 How I manage my own virtual network with ZeroTier.md diff --git a/published/20220504 Microsoft’s 3D Movie Maker, First Released In 1995, Is Now Open Source.md b/published/202205/20220504 Microsoft’s 3D Movie Maker, First Released In 1995, Is Now Open Source.md similarity index 100% rename from published/20220504 Microsoft’s 3D Movie Maker, First Released In 1995, Is Now Open Source.md rename to published/202205/20220504 Microsoft’s 3D Movie Maker, First Released In 1995, Is Now Open Source.md diff --git a/published/20220504 elementary OS 7 Code Name Revealed. Here are the Details.md b/published/202205/20220504 elementary OS 7 Code Name Revealed. Here are the Details.md similarity index 100% rename from published/20220504 elementary OS 7 Code Name Revealed. Here are the Details.md rename to published/202205/20220504 elementary OS 7 Code Name Revealed. Here are the Details.md diff --git a/published/20220505 Experiment with containers and pods on your own computer.md b/published/202205/20220505 Experiment with containers and pods on your own computer.md similarity index 100% rename from published/20220505 Experiment with containers and pods on your own computer.md rename to published/202205/20220505 Experiment with containers and pods on your own computer.md diff --git a/published/20220505 Open Source Developer Creates First-of-its-Kind Fund To Support Maintainers.md b/published/202205/20220505 Open Source Developer Creates First-of-its-Kind Fund To Support Maintainers.md similarity index 100% rename from published/20220505 Open Source Developer Creates First-of-its-Kind Fund To Support Maintainers.md rename to published/202205/20220505 Open Source Developer Creates First-of-its-Kind Fund To Support Maintainers.md diff --git a/published/20220505 Tails 5.0 Release is Based on Debian 11 With a New -Kleopatra- Tool.md b/published/202205/20220505 Tails 5.0 Release is Based on Debian 11 With a New -Kleopatra- Tool.md similarity index 100% rename from published/20220505 Tails 5.0 Release is Based on Debian 11 With a New -Kleopatra- Tool.md rename to published/202205/20220505 Tails 5.0 Release is Based on Debian 11 With a New -Kleopatra- Tool.md diff --git a/published/20220505 Xebian – A Blend of Debian and Goodness of Xfce [Review].md b/published/202205/20220505 Xebian – A Blend of Debian and Goodness of Xfce [Review].md similarity index 100% rename from published/20220505 Xebian – A Blend of Debian and Goodness of Xfce [Review].md rename to published/202205/20220505 Xebian – A Blend of Debian and Goodness of Xfce [Review].md diff --git a/published/20220506 Announcing Fedora Linux 36.md b/published/202205/20220506 Announcing Fedora Linux 36.md similarity index 100% rename from published/20220506 Announcing Fedora Linux 36.md rename to published/202205/20220506 Announcing Fedora Linux 36.md diff --git a/published/20220506 My favorite open source tool for using crontab.md b/published/202205/20220506 My favorite open source tool for using crontab.md similarity index 100% rename from published/20220506 My favorite open source tool for using crontab.md rename to published/202205/20220506 My favorite open source tool for using crontab.md diff --git a/published/20220506 Ubuntu MATE’s Lead Creates a Nifty Tool to Help Install 3rd Party Deb Packages.md b/published/202205/20220506 Ubuntu MATE’s Lead Creates a Nifty Tool to Help Install 3rd Party Deb Packages.md similarity index 100% rename from published/20220506 Ubuntu MATE’s Lead Creates a Nifty Tool to Help Install 3rd Party Deb Packages.md rename to published/202205/20220506 Ubuntu MATE’s Lead Creates a Nifty Tool to Help Install 3rd Party Deb Packages.md diff --git a/published/20220508 How open source leads the way for sustainable technology.md b/published/202205/20220508 How open source leads the way for sustainable technology.md similarity index 100% rename from published/20220508 How open source leads the way for sustainable technology.md rename to published/202205/20220508 How open source leads the way for sustainable technology.md diff --git a/published/20220509 PyCaret- Machine Learning Model Development Made Easy.md b/published/202205/20220509 PyCaret- Machine Learning Model Development Made Easy.md similarity index 100% rename from published/20220509 PyCaret- Machine Learning Model Development Made Easy.md rename to published/202205/20220509 PyCaret- Machine Learning Model Development Made Easy.md diff --git a/published/20220510 Can’t Run AppImage on Ubuntu 22.04- Here’s How to Fix it.md b/published/202205/20220510 Can’t Run AppImage on Ubuntu 22.04- Here’s How to Fix it.md similarity index 100% rename from published/20220510 Can’t Run AppImage on Ubuntu 22.04- Here’s How to Fix it.md rename to published/202205/20220510 Can’t Run AppImage on Ubuntu 22.04- Here’s How to Fix it.md diff --git a/published/20220510 HydraPaper- A Wallpaper Manager for Linux with Multi-Monitor Support.md b/published/202205/20220510 HydraPaper- A Wallpaper Manager for Linux with Multi-Monitor Support.md similarity index 100% rename from published/20220510 HydraPaper- A Wallpaper Manager for Linux with Multi-Monitor Support.md rename to published/202205/20220510 HydraPaper- A Wallpaper Manager for Linux with Multi-Monitor Support.md diff --git a/published/20220511 Good News! Docker Desktop is Now Here for Linux Users.md b/published/202205/20220511 Good News! Docker Desktop is Now Here for Linux Users.md similarity index 100% rename from published/20220511 Good News! Docker Desktop is Now Here for Linux Users.md rename to published/202205/20220511 Good News! Docker Desktop is Now Here for Linux Users.md diff --git a/published/20220511 How to Install Fedora 36 Workstation Step by Step.md b/published/202205/20220511 How to Install Fedora 36 Workstation Step by Step.md similarity index 100% rename from published/20220511 How to Install Fedora 36 Workstation Step by Step.md rename to published/202205/20220511 How to Install Fedora 36 Workstation Step by Step.md diff --git a/published/20220511 Red Hat Enterprise Linux 9 Announced as the Next-Gen Backbone of Enterprise IT.md b/published/202205/20220511 Red Hat Enterprise Linux 9 Announced as the Next-Gen Backbone of Enterprise IT.md similarity index 100% rename from published/20220511 Red Hat Enterprise Linux 9 Announced as the Next-Gen Backbone of Enterprise IT.md rename to published/202205/20220511 Red Hat Enterprise Linux 9 Announced as the Next-Gen Backbone of Enterprise IT.md diff --git a/published/20220512 5 reasons to use sudo on Linux.md b/published/202205/20220512 5 reasons to use sudo on Linux.md similarity index 100% rename from published/20220512 5 reasons to use sudo on Linux.md rename to published/202205/20220512 5 reasons to use sudo on Linux.md diff --git a/published/20220512 NVIDIA Takes a Big Step to Improve its GPU Experience on Linux.md b/published/202205/20220512 NVIDIA Takes a Big Step to Improve its GPU Experience on Linux.md similarity index 100% rename from published/20220512 NVIDIA Takes a Big Step to Improve its GPU Experience on Linux.md rename to published/202205/20220512 NVIDIA Takes a Big Step to Improve its GPU Experience on Linux.md diff --git a/published/20220514 How To Enable Minimize And Maximize Buttons In Fedora 36 Workstation.md b/published/202205/20220514 How To Enable Minimize And Maximize Buttons In Fedora 36 Workstation.md similarity index 100% rename from published/20220514 How To Enable Minimize And Maximize Buttons In Fedora 36 Workstation.md rename to published/202205/20220514 How To Enable Minimize And Maximize Buttons In Fedora 36 Workstation.md diff --git a/published/20220514 How To Install Multimedia Codecs In Fedora Linux.md b/published/202205/20220514 How To Install Multimedia Codecs In Fedora Linux.md similarity index 100% rename from published/20220514 How To Install Multimedia Codecs In Fedora Linux.md rename to published/202205/20220514 How To Install Multimedia Codecs In Fedora Linux.md diff --git a/published/20220516 Fudgie- The Awesome Budgie Desktop is Coming to Fedora Linux Soon.md b/published/202205/20220516 Fudgie- The Awesome Budgie Desktop is Coming to Fedora Linux Soon.md similarity index 100% rename from published/20220516 Fudgie- The Awesome Budgie Desktop is Coming to Fedora Linux Soon.md rename to published/202205/20220516 Fudgie- The Awesome Budgie Desktop is Coming to Fedora Linux Soon.md diff --git a/published/20220516 How To Reset Root Password In Fedora 36.md b/published/202205/20220516 How To Reset Root Password In Fedora 36.md similarity index 100% rename from published/20220516 How To Reset Root Password In Fedora 36.md rename to published/202205/20220516 How To Reset Root Password In Fedora 36.md diff --git a/published/20220516 Microsoft has another Linux distribution and it is based on Debian.md b/published/202205/20220516 Microsoft has another Linux distribution and it is based on Debian.md similarity index 100% rename from published/20220516 Microsoft has another Linux distribution and it is based on Debian.md rename to published/202205/20220516 Microsoft has another Linux distribution and it is based on Debian.md diff --git a/published/20220516 Structured Data Processing with Spark SQL.md b/published/202205/20220516 Structured Data Processing with Spark SQL.md similarity index 100% rename from published/20220516 Structured Data Processing with Spark SQL.md rename to published/202205/20220516 Structured Data Processing with Spark SQL.md diff --git a/published/20220517 Adobe Illustrator Alternative Inkscape Releases Version 1.2.md b/published/202205/20220517 Adobe Illustrator Alternative Inkscape Releases Version 1.2.md similarity index 100% rename from published/20220517 Adobe Illustrator Alternative Inkscape Releases Version 1.2.md rename to published/202205/20220517 Adobe Illustrator Alternative Inkscape Releases Version 1.2.md diff --git a/published/20220517 Kali Linux 2022.2 Release Adds an Amusing New Feature for the Hackers to Scare People.md b/published/202205/20220517 Kali Linux 2022.2 Release Adds an Amusing New Feature for the Hackers to Scare People.md similarity index 100% rename from published/20220517 Kali Linux 2022.2 Release Adds an Amusing New Feature for the Hackers to Scare People.md rename to published/202205/20220517 Kali Linux 2022.2 Release Adds an Amusing New Feature for the Hackers to Scare People.md diff --git a/translated/tech/20220518 Five common mistakes when using automation.md b/published/202205/20220518 Five common mistakes when using automation.md similarity index 91% rename from translated/tech/20220518 Five common mistakes when using automation.md rename to published/202205/20220518 Five common mistakes when using automation.md index cf8b52b775..c41b5d825b 100644 --- a/translated/tech/20220518 Five common mistakes when using automation.md +++ b/published/202205/20220518 Five common mistakes when using automation.md @@ -3,16 +3,14 @@ [#]: author: "Gary Scarborough https://fedoramagazine.org/author/gscarbor/" [#]: collector: "lujun9972" [#]: translator: "geekpi" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14657-1.html" 使用自动化时的五个常见错误 ====== -![][1] - -背景图片来自 [“Modern Times”(1936)][2],[United Artists][3],公共领域,通过 Wikimedia Commons +![](https://img.linux.net.cn/data/attachment/album/202205/31/151450ukwk98weqgefgowa.jpg) 随着自动化扩展到涵盖 IT 的更多方面,越来越多的管理员正在学习自动化技能并应用它们来减轻他们的工作量。自动化可以减轻重复性任务的负担,并为基础设施增加一定程度的一致性。但是,当 IT 工作人员部署自动化时,会出现可能对大大小小的基础设施造成严重破坏的常见错误。在自动化部署中通常会出现五个常见错误。 @@ -20,7 +18,7 @@ 初学者常犯的错误是自动化脚本没有经过全面测试。由于拼写错误或逻辑错误,简单的 shell 脚本可能会对服务器产生不利影响。将该错误乘以基础架构中的服务器数量,你可能会遇到一大堆问题需要清理。在大规模部署之前始终测试你的自动化脚本。 -### 意外的服务器负载 +### 意外负载 经常发生的第二个错误是没有预测脚本可能对其他资源施加的系统负载。当目标是十几个服务器时,运行从仓库下载文件或安装包的脚本可能没问题。脚本通常在成百上千台服务器上运行。这种负载可以使支持服务停止或完全崩溃。不要忘记考虑端点影响或设置合理的并发率。 @@ -30,11 +28,11 @@ ### 缺乏文档 -管理员的一项固定职责应该是记录他们的工作。由于合同到期、升职或定期员工流动,公司可能会在 IT 部门频繁招聘新员工。公司内的工作组相互隔离也很常见。由于这些原因,重要的是记录哪些自动化已经到位。与用户运行脚本不同,自动化可能会在创建它的人离开组之后继续很长时间。管理员可能会发现自己在其基础设施中面临着来自自动化未经检查的奇怪行为。 +管理员的一项固定职责应该是记录他们的工作。由于合同到期、升职或定期员工流动,公司可能会在 IT 部门频繁招聘新员工。公司内的工作组相互隔离也很常见。由于这些原因,重要的是记录哪些自动化已经到位。与用户运行脚本不同,自动化可能会在创建它的人离开组之后继续很长时间。管理员可能会发现自己在其基础设施中面临着来自未经检查的自动化的奇怪行为。 ### 缺乏经验 -列表中的最后一个错误是管理员对他们正在自动化的系统不够了解。管理员经常被雇用到他们没有接受过足够培训且没有人可以学习的职位上工作。自 COVID 以来,当公司努力填补空缺时,这一点尤其重要。然后管理员被迫处理他们没有设置并且可能不完全理解的基础设施。这可能会导致非常低效的脚本浪费资源或配置错误的服务器。 +列表中的最后一个错误是管理员对他们正在自动化的系统不够了解。管理员经常被雇用到他们没有接受过足够培训且没有人可以求教的职位上工作。自 COVID 以来,当公司努力填补空缺时,这一点尤其重要。然后管理员被迫处理他们没有设置并且可能不完全理解的基础设施。这可能会导致非常低效的脚本浪费资源或配置错误的服务器。 ### 结论 @@ -47,7 +45,7 @@ via: https://fedoramagazine.org/five-common-mistakes-when-using-automation/ 作者:[Gary Scarborough][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20220518 Google To Start Distributing A Collection Of Open Source Software libraries.md b/published/202205/20220518 Google To Start Distributing A Collection Of Open Source Software libraries.md similarity index 100% rename from published/20220518 Google To Start Distributing A Collection Of Open Source Software libraries.md rename to published/202205/20220518 Google To Start Distributing A Collection Of Open Source Software libraries.md diff --git a/published/20220518 How To Reset Sudo Password In Ubuntu 22.04 - 20.04 LTS.md b/published/202205/20220518 How To Reset Sudo Password In Ubuntu 22.04 - 20.04 LTS.md similarity index 100% rename from published/20220518 How To Reset Sudo Password In Ubuntu 22.04 - 20.04 LTS.md rename to published/202205/20220518 How To Reset Sudo Password In Ubuntu 22.04 - 20.04 LTS.md diff --git a/published/20220518 ONLYOFFICE 7.1 Release Adds ARM Compatibility, a New PDF Viewer, and More Features.md b/published/202205/20220518 ONLYOFFICE 7.1 Release Adds ARM Compatibility, a New PDF Viewer, and More Features.md similarity index 100% rename from published/20220518 ONLYOFFICE 7.1 Release Adds ARM Compatibility, a New PDF Viewer, and More Features.md rename to published/202205/20220518 ONLYOFFICE 7.1 Release Adds ARM Compatibility, a New PDF Viewer, and More Features.md diff --git a/published/20220519 How To Enable Activate Linux Watermark Notification In Linux Desktop.md b/published/202205/20220519 How To Enable Activate Linux Watermark Notification In Linux Desktop.md similarity index 100% rename from published/20220519 How To Enable Activate Linux Watermark Notification In Linux Desktop.md rename to published/202205/20220519 How To Enable Activate Linux Watermark Notification In Linux Desktop.md diff --git a/published/20220520 A programmer-s guide to GNU C Compiler.md b/published/202205/20220520 A programmer-s guide to GNU C Compiler.md similarity index 100% rename from published/20220520 A programmer-s guide to GNU C Compiler.md rename to published/202205/20220520 A programmer-s guide to GNU C Compiler.md diff --git a/published/20220520 Customize GNOME 42 with A Polished Look.md b/published/202205/20220520 Customize GNOME 42 with A Polished Look.md similarity index 100% rename from published/20220520 Customize GNOME 42 with A Polished Look.md rename to published/202205/20220520 Customize GNOME 42 with A Polished Look.md diff --git a/published/20220520 How to rename a branch, delete a branch, and find the author of a branch in Git.md b/published/202205/20220520 How to rename a branch, delete a branch, and find the author of a branch in Git.md similarity index 100% rename from published/20220520 How to rename a branch, delete a branch, and find the author of a branch in Git.md rename to published/202205/20220520 How to rename a branch, delete a branch, and find the author of a branch in Git.md diff --git a/published/20220521 FSF Does Not Accept Debian as a Free Distribution. Here-s Why!.md b/published/202205/20220521 FSF Does Not Accept Debian as a Free Distribution. Here-s Why!.md similarity index 100% rename from published/20220521 FSF Does Not Accept Debian as a Free Distribution. Here-s Why!.md rename to published/202205/20220521 FSF Does Not Accept Debian as a Free Distribution. Here-s Why!.md diff --git a/published/20220523 DAML- The Programming Language for Smart Contracts in a Blockchain.md b/published/202205/20220523 DAML- The Programming Language for Smart Contracts in a Blockchain.md similarity index 100% rename from published/20220523 DAML- The Programming Language for Smart Contracts in a Blockchain.md rename to published/202205/20220523 DAML- The Programming Language for Smart Contracts in a Blockchain.md diff --git a/published/20220523 Linux Kernel 5.18 Released with Graphics Driver Changes and New Hardware Support.md b/published/202205/20220523 Linux Kernel 5.18 Released with Graphics Driver Changes and New Hardware Support.md similarity index 100% rename from published/20220523 Linux Kernel 5.18 Released with Graphics Driver Changes and New Hardware Support.md rename to published/202205/20220523 Linux Kernel 5.18 Released with Graphics Driver Changes and New Hardware Support.md diff --git a/published/20220523 System76 Collaborates with HP for a Powerful Linux Laptop for Developers.md b/published/202205/20220523 System76 Collaborates with HP for a Powerful Linux Laptop for Developers.md similarity index 100% rename from published/20220523 System76 Collaborates with HP for a Powerful Linux Laptop for Developers.md rename to published/202205/20220523 System76 Collaborates with HP for a Powerful Linux Laptop for Developers.md diff --git a/published/20220525 ProtonMail is Now Just -Proton- Offering a Privacy Ecosystem.md b/published/202205/20220525 ProtonMail is Now Just -Proton- Offering a Privacy Ecosystem.md similarity index 100% rename from published/20220525 ProtonMail is Now Just -Proton- Offering a Privacy Ecosystem.md rename to published/202205/20220525 ProtonMail is Now Just -Proton- Offering a Privacy Ecosystem.md diff --git a/published/20220526 DeepMind-s Open Source MuJoCo Is Available On GitHub.md b/published/202205/20220526 DeepMind-s Open Source MuJoCo Is Available On GitHub.md similarity index 100% rename from published/20220526 DeepMind-s Open Source MuJoCo Is Available On GitHub.md rename to published/202205/20220526 DeepMind-s Open Source MuJoCo Is Available On GitHub.md diff --git a/translated/news/20220526 Plex Desktop Player is Now Available for Linux.md b/published/202205/20220526 Plex Desktop Player is Now Available for Linux.md similarity index 77% rename from translated/news/20220526 Plex Desktop Player is Now Available for Linux.md rename to published/202205/20220526 Plex Desktop Player is Now Available for Linux.md index 3abeea5a3b..af12ffedbf 100644 --- a/translated/news/20220526 Plex Desktop Player is Now Available for Linux.md +++ b/published/202205/20220526 Plex Desktop Player is Now Available for Linux.md @@ -3,13 +3,14 @@ [#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" [#]: collector: "lkxed" [#]: translator: "lkxed" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14656-1.html" Plex 桌面播放器现已支持 Linux ====== -Plex.tv 终于在 Linux 上增加了它的桌面版本和全新的 HTPC 应用。不过,它目前只提供了 snap 包。 + +> Plex.tv 终于增加了 Linux 桌面版本和全新的 HTPC 应用。不过,它目前只提供了 Snap 包。 ![plex][1] @@ -29,21 +30,23 @@ Plex 是一个流行的流媒体播放器,同时,它能够用作一个媒体 这样一来,借助 Flatpak 和 Snap 软件包,Plex 就可以成为在 Linux 上流式传输和组织个人媒体收藏的绝佳选择。 +除了桌面应用程序,如果你利用你的 Linux 机器连接到一个大屏幕来观看所有的内容,还有一个 Plex HTPC(有计划发布 Flatpak 软件包)。 + ![][6] -如果你感兴趣的话,HTPC 是 PMP TV(全称为 Plex Media Player TV)模式的继承者。 +顺便说一句,HTPC 是 PMP TV(全称为 Plex Media Player TV)模式的继承者。 -官网上发布了这款产品,以及它的 Linux 桌面应用程序 。 +他们在官网上与它的 Linux 桌面应用程序一同发布了这款产品。 -使用 HTPC,这个桌面应用就可以和电视共享,并支持音频直通、刷新率切换、控制器支持和可配置输入映射等高级功能。 +使用 HTPC,这个桌面应用就可以和电视共享,并支持音频直通、刷新率切换、控制器和可配置输入映射等高级功能。 ![][7] 因此,如果你有一个大屏幕,并且想要连接你的系统(不管是什么桌面平台)的话,你现在可以使用 HTPC 应用程序来完成。 -[Plex 桌面版][8] +> **[Plex 桌面版][8]** -[Plex HTPC][9] +> **[Plex HTPC][9]** 在 Linux 系统或联网电视上流式传输内容时,你通常会使用什么呢?你觉得 Plex 能满足你的需求吗?即然它支持 Linux 了,你会想要用它来替代当前使用的软件吗? @@ -56,7 +59,7 @@ via: https://news.itsfoss.com/plex-desktop-linux/ 作者:[Ankush Das][a] 选题:[lkxed][b] 译者:[lkxed](https://github.com/lkxed) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20220527 AlmaLinux Continues the Legacy of CentOS with the Release of Version 9.md b/published/202205/20220527 AlmaLinux Continues the Legacy of CentOS with the Release of Version 9.md similarity index 100% rename from published/20220527 AlmaLinux Continues the Legacy of CentOS with the Release of Version 9.md rename to published/202205/20220527 AlmaLinux Continues the Legacy of CentOS with the Release of Version 9.md diff --git a/published/20220527 Tails Linux Users Warned Against Using the Tor Browser- Here-s why!.md b/published/202205/20220527 Tails Linux Users Warned Against Using the Tor Browser- Here-s why!.md similarity index 93% rename from published/20220527 Tails Linux Users Warned Against Using the Tor Browser- Here-s why!.md rename to published/202205/20220527 Tails Linux Users Warned Against Using the Tor Browser- Here-s why!.md index 4e3c9f8c5e..f30dae7372 100644 --- a/published/20220527 Tails Linux Users Warned Against Using the Tor Browser- Here-s why!.md +++ b/published/202205/20220527 Tails Linux Users Warned Against Using the Tor Browser- Here-s why!.md @@ -22,6 +22,10 @@ Tor 浏览器是 Tails 事实上的(默认)网页浏览器,它有助于在 最近,有人发现了两个令人讨厌的漏洞,它们允许有害网站能够从其他网站窃取用户的信息。 +这些都是在 Firefox 使用的 JavaScript 引擎中发现的。 + +但是,Tor 与此有什么关系?对于那些不知道的人来说,Tor 实际上是 Firefox 的一个复刻,因此包含许多类似的功能,如 JavaScript 引擎。 + 具体来说,在 [Mozilla 发布的公告][2] 中,这些漏洞已被确定为 CVE-2022-1802 和 CVE-2022-1529。 Tails 公告中也对此进行了说明: diff --git a/published/20220519 Top 10 Essential Ubuntu Apps For Everyone in 2022.md b/published/20220519 Top 10 Essential Ubuntu Apps For Everyone in 2022.md new file mode 100644 index 0000000000..4b04331930 --- /dev/null +++ b/published/20220519 Top 10 Essential Ubuntu Apps For Everyone in 2022.md @@ -0,0 +1,195 @@ +[#]: subject: "Top 10 Essential Ubuntu Apps For Everyone in 2022" +[#]: via: "https://www.debugpoint.com/2022/05/essential-ubuntu-apps-2022-part-1/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: "Donkey-Hao" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14794-1.html" + +10 大必备 Ubuntu 应用:基本篇 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/05/132504xx09az5i4ip0pel5.jpg) + +> 本文列出了 2022 年可以用于不同情况的 10 个 Ubuntu 基本应用。 + +不管你是偶尔使用的用户、学生、老师,还是科学家、开发人员和创意工作者,在工作上你需要各种各样的应用程序。Linux 生态系统有数以千计的应用程序,它们分散在各个角落,几乎可以满足各种需求。而包括 Ubuntu 在内的大多数主流 Linux 发行版,默认都只提供了基本的应用程序。 + +在这个五篇系列文章的第一篇中,我们列出了一些每个人都用的上的专门应用。 + +### 1、GNOME 优化工具 + +如果你在使用 Ubuntu GNOME 版,GNOME 优化工具GNOME Tweak Tool是你必备的实用工具。使用这个工具来定制你的桌面,你可以改变字体、缩放比例、主题、光标和许多其他选项。默认的设置窗口现在没有列出所有这些选项。 + +此外,你也能用该应用改变窗口装饰、标题栏、标题栏按钮以及开机启动项。 + +你可以使用应用商店搜索 “Tweaks” 来安装它,或者通过下列终端的命令来安装: + +``` +sudo apt install gnome-tweaks +``` + +![GNOME Tweaks Tool][2] + +### 2、Steam + +由于 Valve 公司和相关社区的贡献,在 Linux 上玩游戏不再困难。[Steam][3] 是 Valve 公司开发的电子游戏服务的前端平台,你可以通过 Steam 在 Ubuntu 上获取最新的游戏版本。此外,Steam 客户端提供反外挂监测、自动更新,和支持带有流媒体功能的社交对话。 + +如果你是一个 Linux 游戏玩家,Steam 是常用的客户端,你可以用下面的命令来安装。此外,你可以在应用商店中搜索 “Steam Installer” 并使用 [Flatpak][4] 或 [Snap][5] 进行安装。 + +``` +sudo apt install steam +``` + +![Steam Client][6] + +### 3、Peek + +在我看来,[Peek][7] 是一款被低估的应用。它是一个 GIF 动画录像机,对各种工作场景都非常有用。这是一款非常强大的应用程序,它适合在 Ubuntu 或任何 Linux 发行版中使用。此外,Peek 带有诸如录制区域选择、倒计时、GIF/MP4/WebM 支持等选项。它的后端使用的是 ffmpeg 。 + +在应用商店中搜索 “peek” 或者在命令行输入以下命令来安装这款优秀的应用。 + +``` +sudo apt install peek +``` + +![Peek][8] + +### 4、新立得 + +[新立得][9]Synaptic 是一款杰出的软件包管理器,可以帮助你以传统方式添加和移除软件包。有经验的 Linux 用户知道它的特性以及灵活性。你可以在各种库中搜索软件包、验证依赖性并进行安装。 + +如果你经常安装和卸载软件包,这是一个完美的应用程序。你可以通过以下命令或在应用商店中搜索 “synaptic” 来安装它。 + +``` +sudo apt install synaptic +``` + +![Synaptic Package Manager][10] + +### 5、GDebi + +正如上面提到的新立得,你也可以试试 [GDebi][11] 软件包安装程序,它带有几种功能。GDebi 软件包安装程序是用于安装外部 deb 文件的命令行实用程序。此外,GDebi 安装 .deb 包速度更快、效率更高,可以快速解决依赖关系并为你下载它们。 + +它是 Ubuntu 上安装 .deb 包最好的终端程序之一,你可以用以下命令安装它。安装后,你可以运行 `gdebi <你的 .deb 软件包路径>` 来安装任何软件包。 + +``` +sudo apt install gdebi +``` + +### 6、Geary + +不管从事什么工作,你需要一个 Ubuntu 桌面的本地 [邮箱客户端][12]。电子邮件对很多人来说仍然是有意义和有价值的。尽管 Ubuntu 默认带有最好的 Thunderbird 电子邮件客户端,但你也可以试试其它的电子邮件客户端应用,或许可以给你带来更好体验。 + +[Geary][13] 拥有友好而简洁的用户界面,能够让你更简单的设置多个邮件账号。此外, Geary 也带来了会话功能、更快的搜索、撰写富文本电子邮件以及其他功能,这使它成为 Linux 桌面的“首选”电子邮件客户端。 + +你可以使用如下命令或者在应用商店中搜索 “Geary” 来安装 Geary 。也可以通过 [Flatpak][14] 获得。 + +``` +sudo apt install geary +``` + +![Geary][15] + +### 7. 谷歌 Chrome 浏览器 + +虽然很多人担心隐私以及跟踪,但谷歌 Chrome 仍然是浏览器市场的领头者。Ubuntu 默认提供了 Firefox 浏览器,但随着近期火狐的 Snap 事件,你可能想换到其它浏览器。 + +如果你与谷歌生态系统密切相关,并希望在流媒体和浏览方面获得更好的网络体验,你可能会考虑使用谷歌 Chrome。但是,如果你担心隐私和跟踪,你可以选择其他一些浏览器,例如 Brave 或 Vivaldi。 + +你可以从下面链接中下载 .deb 包来安装谷歌 Chrome 安装器。安装后,你可以打开应用商店来安装它。 + +> **[下载谷歌 Chrome][16]** + +### 8、Kdenlive + +[Kdenlive][17] 是 Linux 上最好的自由开源的视频编辑器之一。 Kdenlive 设计良好的用户界面易于使用,并且带来了各种功能。使用 Kdenlive,你可以简单的导入视频片段,更改画布分辨率,并在编辑后导出为多种格式。时间线和工具让只需你单击一个按钮即可剪切和添加标题、转场和效果。此外,如果你是视频编辑新手,学习起来也非常容易。 + +Kdenlive 是一个非常活跃的项目,每个主要版本都会带有更多先进的功能。这是 2022 年必不可少的 Ubuntu 应用程序之一,如果你想与其它 [免费视频编辑器][18] 进行比较,你可以看看此列表。 + +使用以下命令安装 Kdenlive 很简单。除此,你可以用 [Flatpak][19] 或 [Snap][20] 版本来安装。 + +``` +sudo apt install kdenlive +``` + +![Kdenlive Video Editor][21] + +### 9. Spectacle + +你可能尝试过很多截屏应用。但在我看来,[Spectacle][22] 或许是最好的、也是被低估了的一款应用。Spectacle 是一款 KDE 应用程序,速度超快,非常适合需要截屏并使用的任何工作需求。你可以在自定义的延时后截取整个桌面、部分桌面或窗口。如果需要,窗口截屏还可以选择截取窗口装饰和光标。Spectacle 还为你提供了一个内置的注释功能,可以涂鸦、书写和标记你的图像。 + +此外,你还可以直接从其主窗口在 GIMP 或任何图像编辑器中打开图像,并将其导出。此外,自动保存、将截屏复制到剪贴板以及共享到社交媒体是 Spectacle 的一些独特功能。 + +在我看来,它是一个带有内置屏幕录像机的完整截图工具。 + +你可以用以下命令或者从 [Snap][23] 中安装 Spectacle。 + +``` +sudo apt install kde-spectacle +``` + +![Spectacle Screenshot tool][24] + +### 10. VLC 媒体播放器 + +Ubuntu Linux 的 GNOME 版默认带有可以播放视频文件的 GNOME 视频应用程序。但由于缺乏解码功能,GNOME 视频无法播放多种视频格式。这就是为什么你应该考虑一下 [VLC 媒体播放器][25] —— 它是 Linux 桌面上的“首选”媒体播放器。 + +VLC 确实可以播放任何格式。它甚至可以帮助你播放数据不完整的损坏视频文件。它是强大的媒体播放器之一,你可以使用下面的命令来安装。 + +此外,如果你偏向于另一种安装方式,你可以通过 [Flatpak][26] 或者 [Snap][27] 安装。 + +``` +sudo apt install vlc +``` + +![VLC Media Player][28] + +### 结语 + +2022 年必备的 Ubuntu 应用程序系列的第 1 部分到此结束。通过以上信息,我希望你可以选择一些应用供你的日常使用。在下面的评论框中告诉我你更喜欢此列表中的哪些应用程序。 + +最后,请继续关注本 Ubuntu 应用程序系列的第 2 部分。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2022/05/essential-ubuntu-apps-2022-part-1/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[Donkey](https://github.com/Donkey-Hao) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://gitlab.gnome.org/GNOME/gnome-tweaks +[2]: https://www.debugpoint.com/wp-content/uploads/2022/05/GNOME-Tweaks-Tool.jpg +[3]: https://store.steampowered.com/ +[4]: https://flathub.org/apps/details/com.valvesoftware.Steam +[5]: https://snapcraft.io/steam +[6]: https://www.debugpoint.com/wp-content/uploads/2022/05/Steam-Client.jpg +[7]: https://github.com/phw/peek +[8]: https://www.debugpoint.com/wp-content/uploads/2022/05/Peek-in-action2.jpg +[9]: https://www.nongnu.org/synaptic/ +[10]: https://www.debugpoint.com/wp-content/uploads/2022/05/Synaptic-Package-Manager.jpg +[11]: https://launchpad.net/gdebi +[12]: https://www.debugpoint.com/2019/06/best-email-client-linux-windows/ +[13]: https://wiki.gnome.org/Apps/Geary +[14]: https://flathub.org/apps/details/org.gnome.Geary +[15]: https://www.debugpoint.com/wp-content/uploads/2019/06/Geary.png +[16]: https://www.google.com/chrome +[17]: https://kdenlive.org/ +[18]: https://www.debugpoint.com/2019/09/best-free-video-editors-linux-ubuntu/ +[19]: https://flathub.org/apps/details/org.kde.kdenlive +[20]: https://snapcraft.io/kdenlive +[21]: https://www.debugpoint.com/wp-content/uploads/2021/01/Kdenlive-Video-Editor.jpg +[22]: https://apps.kde.org/spectacle/ +[23]: https://snapcraft.io/spectacle +[24]: https://www.debugpoint.com/wp-content/uploads/2022/05/Spectacle-Screenshot-tool.jpg +[25]: https://www.videolan.org/vlc +[26]: https://flathub.org/apps/details/org.videolan.VLC +[27]: https://snapcraft.io/vlc +[28]: https://www.debugpoint.com/wp-content/uploads/2022/05/VLC-Media-Player.jpg diff --git a/published/20220527 Plotting Data in R- Graphs.md b/published/20220527 Plotting Data in R- Graphs.md new file mode 100644 index 0000000000..f2877704fc --- /dev/null +++ b/published/20220527 Plotting Data in R- Graphs.md @@ -0,0 +1,322 @@ +[#]: subject: "Plotting Data in R: Graphs" +[#]: via: "https://www.opensourceforu.com/2022/05/plotting-data-in-r-graphs/" +[#]: author: "Shakthi Kannan https://www.opensourceforu.com/author/shakthi-kannan/" +[#]: collector: "lkxed" +[#]: translator: "tanloong" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14830-1.html" + +R 语言绘制数据:图表篇 +====== + +R 语言有非常多的绘图和数据可视化的包,比如 `graphics`、`lattice`、`ggplot2` 等。这是 R 语言系列的第 9 篇文章,我们会介绍 R 中用来绘图的各种函数。 + +![](https://img.linux.net.cn/data/attachment/album/202207/15/155129rsfee22secwyii8w.jpg) + +本文使用的 R 是 4.1.2 版本,运行环境为 Parabola GNU/Linux-libre (x86-64)。 + +``` +$ R --version + +R version 4.1.2 (2021-11-01) -- "Bird Hippie" +Copyright (C) 2021 The R Foundation for Statistical Computing +Platform: x86_64-pc-linux-gnu (64-bit) +``` + +R 是自由软件,没有任何担保责任。只要遵守 GNU 通用公共许可证的版本 2 或者版本 3,你就可以对它进行(修改和)再分发。详情见 [https://www.gnu.org/licenses/](https://www.gnu.org/licenses/)。 + +### 折线图 + +我们以印度全境消费者物价指数(CPI -- 乡村/城市)数据集为研究对象,它可以从 [https://data.gov.in/catalog/all-india-consumer-price-index-ruralurban-0](https://data.gov.in/catalog/all-india-consumer-price-index-ruralurban-0) 下载。选择“截止到 2021 年 11 月” 的版本,用 `read.csv` 函数读取下载好的文件,如下所示: + +``` +> cpi <- read.csv(file="CPI.csv", sep=",") + +> head(cpi) +Sector Year Name Andhra.Pradesh Arunachal.Pradesh Assam Bihar +1 Rural 2011 January 104 NA 104 NA +2 Urban 2011 January 103 NA 103 NA +3 Rural+Urban 2011 January 103 NA 104 NA +4 Rural 2011 February 107 NA 105 NA +5 Urban 2011 February 106 NA 106 NA +6 Rural+Urban 2011 February 105 NA 105 NA +Chattisgarh Delhi Goa Gujarat Haryana Himachal.Pradesh Jharkhand Karnataka +1 105 NA 103 104 104 104 105 104 +2 104 NA 103 104 104 103 104 104 +3 104 NA 103 104 104 103 105 104 +4 107 NA 105 106 106 105 107 106 +5 106 NA 105 107 107 105 107 108 +6 105 NA 104 105 106 104 106 106 +... +``` + +以 Punjab 州为例,对每年各月份的 CPI 值求和,然后用 `plot` 函数画一张折线图: + +``` +> punjab <- aggregate(x=cpi$Punjab, by=list(cpi$Year), FUN=sum) + +> head(punjab) +Group.1 x +1 2011 3881.76 +2 2012 4183.30 +3 2013 4368.40 +4 2014 4455.50 +5 2015 4584.30 +6 2016 4715.80 + +> plot(punjab$Group.1, punjab$x, type="l", main="Punjab Consumer Price Index upto November 2021", xlab="Year", ylab="Consumer Price Index") +``` + +`plot` 函数可以传入如下参数: + +| 参数 | 描述 | +| :- | :- | +| `x` | 向量类型,用于绘制 x 轴的数据 | +| `y` | 向量或列表类型,用于绘制 y 轴的数据 | +| `type` | 设置绘图类型:`p` 画点;`l` 画线;`o` 同时画点和线,且相互重叠;`s` 画阶梯线;`h` 画铅垂线 | +| `xlim` | x 轴范围 | +| `ylim` | y 轴范围 | +| `main` | 标题 | +| `sub` | 副标题 | +| `xlab` | x 轴标题 | +| `ylab` | y 轴标题 | +| `axes` | 逻辑型,是否绘制坐标轴 | + +结果如图 1。 + +![Figure 1: Line chart][2] + +### 自相关图 + +自相关图能在时序分析中展示一个变量是否具有自相关性,可以用 R 中的 `acf` 函数绘制。`acf` 函数可以设置三种自相关类型:`correlation`、`covariance` 或 `partial`。图 2 是 Punjab 州 CPI 值的自相关图,x 表示 CPI。 + +``` +acf(punjab$x,main='x') +``` + +![Figure 2: ACF chart][3] + +`acf` 函数可以传入以下参数: + +| 参数 | 描述 | +| :- | :- | +| `x` | 一个单变量或多变量的时序对象,或者一个数值向量或数值矩阵 | +| `lag.max` | 最大滞后阶数 | +| `type` | 字符型,设置所计算的自相关类型:`correlation`、`covariance` 或 `partial` | +| `plot` | 逻辑性,若 `TRUE` 则绘制图像,若 `FALSE` 则打印传入数据的描述信息 | +| `i` | 一组要保留的时差滞后 | +| `j` | 一组要保留的名称或数字 | + +### 柱状图 + +R 中画柱状图的函数是 `barplot`。下面的代码用来画 Punjab 州 CPI 的柱状图,如图3: + +``` +> barplot(punjab$x, main="Punjab Consumer Price Index", sub="Upto November 2021", xlab="Year", ylab="Consumer Price Index", col="navy") +``` + +![Figure 3: Line chart of Punjab's CPI][4] + +`barplot` 函数的使用方法非常灵活,可以传入以下参数: + +| 参数 | 描述 | +| :- | :- | +| `height` | 数值向量或数值矩阵,包含用于绘图的数据 | +| `width` | 数值向量,用于设置柱宽 | +| `space` | 柱间距 | +| `beside` | 逻辑型,若 `FALSE` 则绘制堆积柱状图,若 `TRUE` 则绘制并列柱状图 | +| `density` | 数值型,设置阴影线的填充密度(条数/英寸),默认为 `NULL`,即不填充阴影线| +| `angle` | 数值型,填充线条的角度,默认为 45 | +| `border` | 柱形边缘的颜色 | +| `main` | 标题 | +| `sub` | 副标题 | +| `xlab` | x 轴标题 | +| `ylab` | y 轴标题 | +| `xlim` | x 轴范围 | +| `ylim` | y 轴范围 | +| `axes` | 逻辑型,是否绘制坐标轴 | + +用 `help` 命令可以查看 `barplot` 函数的详细信息: + +``` +> help(barplot) + +barplot package:graphics R Documentation + +Bar Plots + +Description: + + Creates a bar plot with vertical or horizontal bars. + +Usage: + + barplot(height, ...) + + ## Default S3 method: + barplot(height, width = 1, space = NULL, + names.arg = NULL, legend.text = NULL, beside = FALSE, + horiz = FALSE, density = NULL, angle = 45, + col = NULL, border = par("fg"), + main = NULL, sub = NULL, xlab = NULL, ylab = NULL, + xlim = NULL, ylim = NULL, xpd = TRUE, log = "", + axes = TRUE, axisnames = TRUE, + cex.axis = par("cex.axis"), cex.names = par("cex.axis"), + inside = TRUE, plot = TRUE, axis.lty = 0, offset = 0, + add = FALSE, ann = !add && par("ann"), args.legend = NULL, ...) + + ## S3 method for class 'formula' + barplot(formula, data, subset, na.action, + horiz = FALSE, xlab = NULL, ylab = NULL, ...) +``` + +### 饼图 + +绘制饼图时要多加注意,因为饼图不一定能展示出各扇形间的区别。(LCTT 译注:根据统计学家和一些心理学家的调查结果,这种以比例展示数据的统计图形 [实际上是很糟糕的可视化方式][10],因此,R 关于饼图的帮助文件中清楚地说明了并不推荐使用饼图,而是使用条形图或点图作为替代。) 用 `subset` 函数获得 Gujarat 州在 2021 年 1 月 Rural、Urban、Rurual+Urban 的 CPI 值: + +``` +> jan2021 <- subset(cpi, Name=="January" & Year=="2021") + +> jan2021$Gujarat +[1] 153.9 151.2 149.1 + +> names <- c('Rural', 'Urban', 'Rural+Urban') +``` + +使用 `pie` 函数为 Gujarat 州的 CPI 值生成饼图,如下所示: + +``` +> pie(jan2021$Gujarat, names, main="Gujarat CPI Rural and Urban Pie Chart") +``` + +![Figure 4: Pie chart][5] + +`pie` 函数可以传入以下参数: + +| 参数 | 描述 | +| :- | :- | +| `x | 元素大于 0 的数值向量 | +| `label` | 字符向量,用于设置每个扇形的标签 | +| `radius` | 饼图的半径 | +| `clockwise` | 逻辑型,若 `TRUE` 则顺时针绘图,若 `FALSE` 则逆时针绘图 | +| `density` | 数值型,设置阴影线的填充密度(条数/英寸),默认为 `NULL`,即不填充阴影线| +| `angle` | 数值型,填充线条的角度,默认为 45 | +| `col` | 数值向量,用于设置颜色 | +| `lty` | 每个扇形的线条类型 | +| `main` | 标题 | + +### 箱线图 + +(LCTT 译注:箱线图主要是 [从四分位数的角度出发][11] 描述数据的分布,它通过最大值(Q4)、上四分位数(Q3)、中位数(Q2)、下四分位数(Q1) 和最小值(Q0)五处位置来获取一维数据的分布概况。我们知道,这五处位置之间依次包含了四段数据,每段中数据量均为总数据量的 1/4。通过每一段数据占据的长度,我们可以大致推断出数据的集中或离散趋势。长度越短,说明数据在该区间上越密集,反之则稀疏。) + +箱线图能够用“须线whisker” 展示一个变量的四分位距Interquartile Range(简称 IQR=Q3-Q1)。用上下四分位数分别加/减内四分位距,再乘以一个人为设定的倍数 `range`(见下面的参数列表),得到 `range * c(Q1-IQR, Q3+IQR)`,超过这个范围的数据点就被视作离群点,在图中直接以点的形式表示出来。 + +`boxplot` 函数可以传入以下参数: + +| 参数 | 描述 | +| :- | :- | +| `data` | 数据框或列表,用于参数类型为公式的情况 | +| `x` | 数值向量或者列表,若为列表则对列表中每一个子对象依次作出箱线图 | +| `width` | 设置箱子的宽度 | +| `outline` | 逻辑型,设置是否绘制离群点 | +| `names` | 设置每个箱子的标签 | +| `border` | 设置每个箱子的边缘的颜色 | +| `range` | 延伸倍数,设置箱线图末端(须)延伸到什么位置 | +| `plot` | 逻辑型,设置是否生成图像,若 TRUE 则生成图像,若 FALSE 则打印传入数据的描述信息 | +| `horizontal` | 逻辑型,设置箱线图是否水平放置 | + +用 `boxplot` 函数绘制部分州的箱线图: + +``` +> names <- c ('Andaman and Nicobar', 'Lakshadweep', 'Delhi', 'Goa', 'Gujarat', 'Bihar') +> boxplot(cpi$Andaman.and.Nicobar, cpi$Lakshadweep, cpi$Delhi, cpi$Goa, cpi$Gujarat, cpi$Bihar, names=names) +``` + +![Figure 5: Box plot][6] + +### QQ 图 + +QQ 图Quantile-Quantile plot可以用来对比两个数据集,也可以用来检查数据是否服从某种理论分布。`qqnorm` 函数能绘制正态分布 QQ 图,可以检验数据是否服从正态分布,用下面的代码绘制 Punjab 州 CPI 数据的 QQ 图: + +``` +> qqnorm(punjab$x) +``` + +![Figure 6: Q-Q plot][7] + +`qqline` 函数可以向正态分布 QQ 图上添加理论分布曲线,它可以传入以下参数: + +| 参数 | 描述 | +| :- | :- | +| `x` | 第一个数据样本 | +| `y` | 第二个数据样本 | +| `datax` | 逻辑型,设置是否以 x 轴表示理论曲线的值,默认为 `FALSE` | +| `probs` | 长度为 2 的数值向量,代表概率 | +| `xlab` | x 轴标题 | +| `ylab` | y 轴标题 | +| `qtype` | `[1,9]` 内的整数,设置分位计算类型,详情见 `help(quantile)` 的类型小节 | + +### 等高图 + +等高图可以描述三维数据,在 R 中对应的函数是 `contour`,这个函数也可以用来向已有的图表添加等高线。等高图常与其他图表一起使用。我们用 `contour` 对 R 中的 `volcano` 数据集(奥克兰的火山地形信息)绘制等高图,代码如下: + +``` +> contour(volcano) +``` + +![Figure 7: Volcano][8] + +`contour` 函数的常用参数如下: + +| 参数 | 描述 | +| :- | :- | +| `x,y` | z 中数值对应的点在平面上的位置 | +| `z` | 数值向量 | +| `nlevels` | 设置等高线的条数,调整等高线的疏密 | +| `labels` | 等高线上的标记字符串,默认是高度的数值 | +| `xlim` | 设置 x 轴的范围 | +| `ylim` | 设置 y 轴的范围 | +| `zlim` | 设置 z 轴的范围 | +| `axes` | 设置是否绘制坐标轴 | +| `col` | 设置等高线的颜色 | +| `lty` | 设置线条的类型 | +| `lwd` | 设置线条的粗细 | +| `vfont` | 设置标签字体 | + +等高线之间的区域可以用颜色填充,每种颜色表示一个高度范围,如下所示: + +``` +> filled.contour(volcano, asp = 1) +# asp 为图形纵横比,即 y 轴上的 1 单位长度和 x 轴上 1 单位长度的比率 +``` +填充结果见图 8。 + +![Figure 8: Filled volcano][9] + +掌握上述内容后,你可以尝试 R 语言 `graphics` 包中的其他函数和图表(LCTT 译注:用 `help(package=graphics)` 可以查看 graphics 包提供的函数列表)。 + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/05/plotting-data-in-r-graphs/ + +作者:[Shakthi Kannan][a] +选题:[lkxed][b] +译者:[tanloong](https://github.com/tanloong) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/shakthi-kannan/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/04/business-man-visulising-graphs.jpg +[2]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-1-Line-chart.jpg +[3]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-2-ACF-chart.jpg +[4]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-3-Line-chart-of-Punjabs-CPI.jpg +[5]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-4-Pie-chart.jpg +[6]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-5-ox-plot.jpg +[7]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-6-Q-Q-plot.jpg +[8]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-7-Volcano.jpg +[9]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-8-Filled-volcano.jpg +[10]: https://bookdown.org/xiangyun/msg/gallery.html#sec:pie +[11]: https://bookdown.org/xiangyun/msg/gallery.html#sec:boxplot diff --git a/published/20220531 How dynamic linking for modular libraries works on Linux.md b/published/20220531 How dynamic linking for modular libraries works on Linux.md new file mode 100644 index 0000000000..a3fab8faa0 --- /dev/null +++ b/published/20220531 How dynamic linking for modular libraries works on Linux.md @@ -0,0 +1,223 @@ +[#]: subject: "How dynamic linking for modular libraries works on Linux" +[#]: via: "https://opensource.com/article/22/5/dynamic-linking-modular-libraries-linux" +[#]: author: "Jayashree Huttanagoudar https://opensource.com/users/jayashree-huttanagoudar" +[#]: collector: "lkxed" +[#]: translator: "robsean" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14813-1.html" + +如何在 Linux 上动态链接模块库 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/10/182540caie7ldrefflffah.jpg) + +> 学习如何用动态链接库将多个 C 目标文件结合到一个单个的可执行文件之中。 + +当使用 C 编程语言编写一个应用程序时,你的代码通常有多个源文件代码。 + +最终,这些文件必须被编译到一个单个的可执行文件之中。你可以通过创建静态或动态库(后者也被称为 共享shared 库)来实现这一点。这两种类型的库在创建和链接的方式上有所不同。两者都有缺点和优点,这取决于你的使用情况。 + +动态链接是最常见的方法,尤其是在 Linux 系统上。动态链接会保持库模块化,因此,很多应用程序可以共享一个库。应用程序的模块化也允许单独更新其依赖的共享库。 + +在这篇文章中,我将演示动态链接是如何工作的。在后期的文章中,我将演示静态链接。 + +### 链接器 + +链接器linker是一个命令,它将一个程序的数个部分结合在一起,并为它们重新组织内存分配。 + +链接器的功能包括: + +* 整合一个程序的所有的部分 +* 计算出一个新的内存组织结构,以便所有的部分组合在一起 +* 恢复内存地址,以便程序可以在新的内存组织结构下运行 +* 解析符号引用 + +链接器通过这些功能,创建了一个名为可执行文件executable的可以运行的程序。在你创建一个动态链接的可执行文件前,你需要一些用来链接的库,和一个用来编译的应用程序。准备好你 [最喜欢的文本编辑器][2] 并继续。 + +### 创建目标文件 + +首先,创建带有这些函数签名的头文件 `mymath.h` : + +``` +int add(int a, int b); +int sub(int a, int b); +int mult(int a, int b); +int divi(int a, int b); +``` + +使用这些函数定义来创建 `add.c` 、`sub.c` 、`mult.c` 和 `divi.c` 文件。我将把所有的代码都放置到一个代码块中,请将其分为四个文件,如注释所示: + +``` +// add.c +int add(int a, int b){ +return (a+b); +} + +//sub.c +int sub(int a, int b){ +return (a-b); +} + +//mult.c +int mult(int a, int b){ +return (a*b); +} + +//divi.c +int divi(int a, int b){ +return (a/b); +} +``` + +现在,使用 GCC 来创建目标文件 `add.o`、`sub.o`、`mult.o` 和 `divi.o` : + +(LCTT 校注:关于“目标文件object file”,有时候也被称作“对象文件”,对此,存在一些译法混乱情形,称之为“目标文件”的译法比较流行,本文采用此译法。) + +``` +$ gcc -c add.c sub.c mult.c divi.c +``` + +`-c` 选项跳过链接步骤,并且只创建目标文件。 + +### 创建一个共享的目标文件 + +在最终的可执行文件的执行过程中将链接动态库。在最终的可执行文件中仅放置动态库的名称。实际上的链接过程发生在运行时,在此期间,可执行文件和库都被放置到了主内存中。 + +除了可共享外,动态库的另外一个优点是它减少了最终的可执行文件的大小。在一个应用程序最终的可执行文件生成时,其使用的库只包括该库的名称,而不是该库的一个多余的副本。 + +你可以从你现有的示例代码中创建动态库: + +``` +$ gcc -Wall -fPIC -c add.c sub.c mult.c divi.c +``` + +选项 `-fPIC` 告诉 GCC 来生成位置无关的代码position-independent code(PIC)。`-Wall` 选项不是必需的,并且与代码的编译方式是无关的。不过,它却是一个有价值的选项,因为它会启用编译器警告,这在排除故障时是很有帮助的。 + +使用 GCC ,创建共享库 `libmymath.so` : + +``` +$ gcc -shared -o libmymath.so add.o sub.o mult.o divi.o +``` + +现在,你已经创建了一个简单的示例数学库 `libmymath.so` ,你可以在 C 代码中使用它。当然,也有非常复杂的 C 库,这就是他们这些开发者来生成最终产品的工艺流程,你和我可以安装这些库并在 C 代码中使用。 + +接下来,你可以在一些自定义代码中使用你的新数学库,然后链接它。 + +### 创建一个动态链接的可执行文件 + +假设你已经为数学运算编写了一个命令。创建一个名称为 `mathDemo.c` 的文件,并将这些代码复制粘贴至其中: + +``` +#include +#include +#include + +int main() +{ + int x, y; + printf("Enter two numbers\n"); + scanf("%d%d",&x,&y); + + printf("\n%d + %d = %d", x, y, add(x, y)); + printf("\n%d - %d = %d", x, y, sub(x, y)); + printf("\n%d * %d = %d", x, y, mult(x, y)); + + if(y==0){ + printf("\nDenominator is zero so can't perform division\n"); + exit(0); + }else{ + printf("\n%d / %d = %d\n", x, y, divi(x, y)); + return 0; + } +} +``` + +注意:第一行是一个 `include` 语句,通过名称来引用你自己的 `libmymath` 库。要使用一个共享库,你必须已经安装了它,如果你没有安装你将要使用的库,那么当你的可执行文件在运行并搜索其包含的库时,将找不到该共享库。如果你需要在不安装库到已知目录的情况下编译代码,这里有 [一些方法可以覆盖默认设置][3]。不过,对于一般使用来说,我们希望库存在于已知的位置,因此,这就是我在这里演示的东西。 + +复制文件 `libmymath.so` 到一个标准的系统目录,例如:`/usr/lib64`, 然后运行 `ldconfig` 。`ldconfig` 命令创建所需的链接,并缓存到标准库目录中发现的最新共享库。 + +``` +$ sudo cp libmymath.so /usr/lib64/ +$ sudo ldconfig +``` + +### 编译应用程序 + +从你的应用程序源文件代码(`mathDemo.c`)中创建一个名称为 `mathDemo.o` 的目标文件: + +``` +$ gcc -I . -c mathDemo.c +``` + +`-I` 选项告诉 GCC 来在其后所列出的目录中搜索头文件(在这个示例中是 `mymath.h`)。在这个示例中,你指定的是当前目录,通过一个单点(`.`)来表示。创建一个可执行文件,使用 `-l` 选项来通过名称来引用你的共享数学库: + +``` +$ gcc -o mathDynamic mathDemo.o -lmymath +``` + +GCC 会找到 `libmymath.so` ,因为它存在于一个默认的系统库目录中。使用 `ldd` 来查证所使用的共享库: + +``` +$ ldd mathDemo + linux-vdso.so.1 (0x00007fffe6a30000) + libmymath.so => /usr/lib64/libmymath.so (0x00007fe4d4d33000) + libc.so.6 => /lib64/libc.so.6 (0x00007fe4d4b29000) + /lib64/ld-linux-x86-64.so.2 (0x00007fe4d4d4e000) +``` + +看看 `mathDemo` 可执行文件的大小: + +``` +$ du ./mathDynamic +24 ./mathDynamic +``` + +当然,它是一个小的应用程序,它所占用的磁盘空间量也反映了这一点。相比之下,相同代码的一个静态链接版本(正如你将在我后期的文章所看到的一样)是 932K ! + +``` +$ ./mathDynamic +Enter two numbers +25 +5 + +25 + 5 = 30 +25 - 5 = 20 +25 * 5 = 125 +25 / 5 = 5 +``` + +你可以使用 `file` 命令来查证它是动态链接的: + +``` +$ file ./mathDynamic +./mathDynamic: ELF 64-bit LSB executable, x86-64, +dynamically linked, +interpreter /lib64/ld-linux-x86-64.so.2, +with debug_info, not stripped +``` + +成功! + +### 动态链接 + +因为链接发生在运行时,所以,使用一个共享库会产生一个轻量型的可执行文件。因为它在运行时解析引用,所以它会花费更多的执行时间。不过,因为在日常使用的 Linux 系统上绝大多数的命令是动态链接的,并且在现代硬件上,所能节省的时间是可以忽略不计的。对开发者和用户来说,它的固有模块性是一种强大的功能。 + +在这篇文章中,我描述了如何创建动态库,并将其链接到一个最终可执行文件。在我的下一篇文章中,我将使用相同的源文件代码来创建一个静态链接的可执行文件。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/5/dynamic-linking-modular-libraries-linux + +作者:[Jayashree Huttanagoudar][a] +选题:[lkxed][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jayashree-huttanagoudar +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/links.png +[2]: https://opensource.com/article/21/2/open-source-text-editors +[3]: https://opensource.com/article/22/5/compile-code-ldlibrarypath diff --git a/translated/tech/20180712 An introduction to Go arrays and slices.md b/published/202206/20180712 An introduction to Go arrays and slices.md similarity index 90% rename from translated/tech/20180712 An introduction to Go arrays and slices.md rename to published/202206/20180712 An introduction to Go arrays and slices.md index 40e3f9a3b6..9dcac9545c 100644 --- a/translated/tech/20180712 An introduction to Go arrays and slices.md +++ b/published/202206/20180712 An introduction to Go arrays and slices.md @@ -3,17 +3,16 @@ [#]: author: "Mihalis Tsoukalos https://opensource.com/users/mtsouk" [#]: collector: "lkxed" [#]: translator: "lkxed" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14665-1.html" Go 数组和切片的介绍 ====== -了解使用数组和切片在 Go 中存储数据的优缺点,以及为什么其中一个比另一个更好。 -![][1] +![](https://img.linux.net.cn/data/attachment/album/202206/02/105657zahhco3612vv1bbo.jpg) -图源:carrotmadman6,经 Opensource.com 修改,CC BY-SA 2.0 +> 了解使用数组和切片在 Go 中存储数据的优缺点,以及为什么其中一个更好。 在本系列的第四篇文章中,我将解释 [Go][5] 数组和切片,包括如何使用它们,以及为什么你通常要选择其中一个而不是另一个。 @@ -26,6 +25,7 @@ Go 数组和切片的介绍 ``` anArray := [4]int{-1, 2, 0, -4} ``` + 数组的大小应该在它的类型之前声明,而类型应该在声明元素之前定义。`len()` 函数可以帮助你得到任何数组的长度。上面数组的大小是 4。 如果你熟悉其他编程语言,你可能会尝试使用 `for` 循环来遍历数组。Go 当然也支持 `for` 循环,不过,正如你将在下面看到的,Go 的 `range` 关键字可以让你更优雅地遍历数组或切片。 @@ -39,7 +39,6 @@ twoD := [3][3]int{ {10, 11, 12}} ``` -The `arrays.go` source file explains the use of Go arrays. The most important code in `arrays.go` is: `arrays.go` 源文件中包含了 Go 数组的示例代码。其中最重要的部分是: ``` @@ -101,7 +100,6 @@ Go 切片与 Go 数组类似,但是它没有后者的缺点。 此外,切片是通过引用传递给函数的,这意味着实际传递给函数的是切片变量的内存地址,这样一来,你对函数内部的切片所做的任何修改,都不会在函数退出后丢失。因此,将大切片传递给函数,要比将具有相同数量元素的数组传递给同一函数快得多。这是因为 Go 不必拷贝切片 —— 它只需传递切片变量的内存地址。 -Go slices are illustrated in `slice.go`, which contains the following code: `slice.go` 源文件中有 Go 切片的代码示例,其中包含以下代码: ``` @@ -141,7 +139,7 @@ func main() { } ``` -切片和数组在定义方式上的最大区别就在于:你不需要指定切片的大小。实际上,切片的大小取决于你要放入其中的元素数量。此外,`append()` 函数允许你将元素添加到现有切片 —— 请注意,即使切片的容量允许你将元素添加到该切片,它的长度也不会被修改,除非你调用 `append ()`。上述代码中的 `printSlice()` 函数是一个辅助函数,用于打印切片中的所有元素,而 `negative()` 函数将切片中的每个元素都变为各自的相反数。 +切片和数组在定义方式上的最大区别就在于:你不需要指定切片的大小。实际上,切片的大小取决于你要放入其中的元素数量。此外,`append()` 函数允许你将元素添加到现有切片 —— 请注意,即使切片的容量允许你将元素添加到该切片,它的长度也不会被修改,除非你调用 `append()`。上述代码中的 `printSlice()` 函数是一个辅助函数,用于打印切片中的所有元素,而 `negative()` 函数将切片中的每个元素都变为各自的相反数。 运行 `slice.go` 将得到以下输出: @@ -192,7 +190,7 @@ Array: [1 -2 3 -4 5] 你可以在 [GitHub][6] 上找到 `arrays.go`、`slice.go` 和 `refArray.go` 的源代码。 -如果您有任何问题或反馈,请在下方发表评论或在 [Twitter][7] 上与我联系。 +如果你有任何问题或反馈,请在下方发表评论或在 [Twitter][7] 上与我联系。 -------------------------------------------------------------------------------- @@ -201,7 +199,7 @@ via: https://opensource.com/article/18/7/introduction-go-arrays-and-slices 作者:[Mihalis Tsoukalos][a] 选题:[lkxed][b] 译者:[lkxed](https://github.com/lkxed) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/202206/20190131 OOP Before OOP with Simula.md b/published/202206/20190131 OOP Before OOP with Simula.md new file mode 100644 index 0000000000..c5d9c97a84 --- /dev/null +++ b/published/202206/20190131 OOP Before OOP with Simula.md @@ -0,0 +1,183 @@ +[#]: subject: "OOP Before OOP with Simula" +[#]: via: "https://twobithistory.org/2019/01/31/simula.html" +[#]: author: "Two-Bit History https://twobithistory.org" +[#]: collector: "lujun9972" +[#]: translator: "aREversez" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14682-1.html" + +Simula 诞生之前的面向对象程序设计 +====== + +想象一下,你坐在河边,河岸上如茵绿草,不远处湍急河流;午后的阳光慵懒惬意,使人陷入冥想哲思,不觉开始思考眼前的河流是否真实存在。诚然,几米外确实有河水奔流而下。不过,我们所称为“河流”的存在究竟是什么呢?毕竟,河水奔流不息,一直处于变化之中。似乎,“河流”这个词无法指代任何固定不变的事物。 + +2009 年,Clojure 的创始人 里奇·希基Rich Hickey 发表了 [一场精彩的演讲][1],探讨了为什么上文那样的哲学窘境会给面向对象程序的编程范式带来难题。他认为,人们看待计算机程序中的对象与看待河流的逻辑是一样的:我们想象对象是固定不变的,即使对象的许多或者说全部的属性都无时无刻不处于变化之中。所以,这种逻辑并不正确,我们无法区分在不同状态下同一对象实例的不同之处。程序中没有明确的时间的概念。人们只是单纯地用着同一个名字,以期在引用对象时,对象能够处于预期的状态中。这样,我们也就难免会遇到 故障bug。 + +希基总结道,这一难题的应对办法就是人们应该将世界建模成作用于不可变数据的 进程process 的集合,而不是可变的对象的集合。换句话说,我们应把每个对象看作一条“河流”,因果相连。总结说来,你应该使用 Clojure 等函数式语言。 + +![][2] + +_作者在远足途中思考面向对象程序设计的本体论问题。_ + +自从希基发表演讲之后,人们对函数式编程语言的兴趣不断提升,主流的面向对象编程语言也大多都采用了函数式编程语言。尽管如此,大多数程序员依旧沿用自己的老一套,继续将对象实例化,不断改变其状态。这些人长此以往,很难做到用不同的视角看待编程。 + +我曾经想写一篇关于 Simula 的文章,大概会写到我们今天所熟知的面向对象的理念是何时又是如何应用到程序语言之中的。但是,我觉得写当初的 Simula 与如今的面向对象程序设计的 _迥然不同之处_,会更有趣一些,这我敢打包票。毕竟,我们现在熟知的面向对象程序设计还未完全成型。Simula 有两个主要版本:Simula I 和 Simula 67。Simula 67 为世界带来了 class类的继承class hierarchy 以及 虚拟方法virtual method;但 Simula I 是一个初稿,它实验了如何能够将数据和进程捆绑起来的其他设想。Simula I 的模型不是希基提出的函数式模型,不过这一模型关注的是随时间展开的 _进程_,而非有着隐藏状态的对象之间的相互作用。如果 Simula 67 采用了 Simula I 的理念,那么我们如今所知的面向对象程序设计可能会大有不同——这类偶然性启示我们,不要想着现在的程序设计范式会一直占据主导地位。 + +### 从 Simula 0 到 Simula 67 + +Simula 是由两位挪威人 克里斯汀·尼加德Kristen Nygaard奥利-约翰·达尔Ole-Johan Dahl 创建的。 + +20 世纪 50 年代末,尼加德受雇于 挪威防务科学研究中心Norwegian Defense Research Establishment(NDRE),该研究中心隶属于挪威军方。在那里,他负责设计 蒙特卡洛模拟方法Monte Carlo simulations,用于核反应堆设计与操作研究。最初,那些模拟实验是由人工完成的;后来,实验在 Ferranti Mercury 电脑 [^1] 上编入程序运行。尼加德随后发现,将这些模拟实验输入电脑需要一种更有效的方式。 + +尼加德设计的这种模拟实验就是人们所知的“离散事件模型discrete event model”,这种模拟记录了一系列事件随着时间改变系统状态的进程。但是问题的关键在于模拟可以从一个事件跳跃到另一个事件中,因为事件是离散的,事件之间的系统不存在任何变化。根据尼加德和达尔在 1966 年发表的一篇关于 Simula 的论文,这种模型被迅速应用于“神经网络、通信系统、交通流量、生产系统、管理系统、社会系统等” [^2] 领域的分析。因此,尼加德认为,其他人描述模拟实验时,可能也需要更高层级的模型。于是他开始物色人才,帮助他完成他称之为“模拟语言Simulation Language”或者“蒙特卡洛编译器Monte Carlo Compiler”的项目 [^3]。 + +达尔当时也受雇于挪威防务科学研究中心,专攻语言设计,此时也加入了尼加德的项目,扮演“沃兹尼亚克”的角色(LCTT 译注:指苹果公司联合创始人斯蒂夫·盖瑞·沃兹尼亚克)。在接下来一年左右的时间,尼加德和达尔携手开发了 Simula 0 语言。[^4] 这一语言的早期版本仅仅是在 ALGOL 60 基础上进行的较小拓展,当时也只是打算将其用作预处理程序而已。当时的语言要比后来的编程语言抽象得多,其基本语言结构是“车站stations”与“乘客customers”,这些结构可以用于针对具体某些离散事件网络建立模型。尼加德和达尔给出了一个模拟飞机离港的例子。[^5] 但是尼加德和达尔最后想出了一个更加通用的语言结构,可以同时表示“车站”和“乘客”,也可以为更广泛的模拟建立模型。这是两个主要的概括,它改变了 Simula 作为 ALGOL 专属包的定位,使其转变为通用编程语言。 + +Simula I 没有“车站stations”和“乘客customers”的语言结构,但它可以通过使用“进程process”再现这些结构。(LCTT 译注:此处使用的“进程”,与当前计算机中用来指代一个已执行程序的实体的概念不同,大致上,你可以将本文中所说的“进程”理解为一种“对象”。)一个进程包含大量数据属性,这些属性与作为进程的 _操作规程_ 的单个行为相联系。你可能会把进程当作是只有单个方法的对象,比如 `run()` 之类的。不过,这种类比并不全面,因为每个进程的操作规程都可以随时暂停、随时恢复,因为这种操作规程属于 协程coroutine 的一种。Simula I 程序会将系统建立为一套进程的模型,在概念上这些进程并行运行。实际上,一个时间点上能称为“当前进程”的只有一个进程。但是,一旦某个进程暂停运行,那么下一个进程就会自动接替它的位置。随着模拟的运行,Simula 会保持一个 “事件通知event notices” 的时间线,跟踪记录每个进程恢复的时间。为了恢复暂停运行的进程,Simula 需要记录多个 调用栈call stacks 的情况。这就意味着 Simula 无法再作为 ALGOL 的预处理程序了,因为 ALGOL 只有一个 调用栈call stacks。于是,尼加德和达尔下定决心,开始编写自己的编译器。 + +尼加德和达尔在介绍该系统的论文中,借助图示,通过模拟一个可用机器数量有限的工厂,阐明了其用法。[^6] 在该案例中,进程就好比订单:通过寻找可用的机器,订单得以发出;如果没有可用的机器,订单就会搁置;而一旦有机器空出来,订单就会执行下去。有一个订单进程的定义,用来实例化若干种不同的订单实例,不过这些实例并未调用任何方法。该程序的主体仅仅是创建进程,并使其运行。 + +历史上第一个 Simula I 编译器发布于 1965 年。尼加德和达尔在离开挪威防务科学研究中心之后,就进入了 挪威计算机中心Norwegian Computer Center 工作,Simula I 也是在这里日渐流行起来的。当时,Simula I 在 UNIVAC 公司的计算机和 Burroughs 公司的 B5500 计算机上均可执行。[^7] 尼加德和达尔两人与一家名为 ASEA 的瑞典公司达成了咨询协议,运用 Simula 模拟加工车间。但是,尼加德和达尔随后就意识到 Simula 也可以写一些和模拟完全不搭边的程序。 + +奥斯陆大学University of Oslo教授 斯坦因·克罗达尔Stein Krogdahl 曾写过关于 Simula 的发展史,称“真正能够促使新开发的通用语言快速发展的催化剂”就是 [一篇题为《记录处理》Record Handling的论文][10],作者是英国计算机科学家 查尔斯·安东尼·理查德·霍尔C.A.R. Hoare。[^8] 假如你现在读霍尔的这篇论文,你就不会怀疑这句话。当人们谈及面向对象语言的发展史时,一定会经常提起霍尔的大名。以下内容摘自霍尔的《记录处理》一文: + +> 该方案设想,在程序执行期间,计算机内部存在任意数量的记录,每条记录都代表着程序员在过去、现在或未来所需的某个对象。程序对现有记录的数量保持动态控制,并可以根据当前任务的要求创建新的记录或删除现有记录。 +> +> 计算机中的每条记录都必须属于数量有限但互不重合的记录类型中的一类;程序员可以根据需要声明尽可能多的记录类型,并借助标识符为各个类型命名。记录类型的命名可能是普通词汇,比如“牛”、“桌子”以及“房子”,同时,归属于这些类型的记录分别代表一头“牛”、一张“桌子”以及一座“房子”。 + +霍尔在这片论文中并未提到子类的概念,但是达尔由衷地感谢霍尔,是他引导了两人发现了这一概念。[^9] 尼加德和达尔注意到 Simula I 的进程通常具有相同的元素,所以引入父类来执行共同元素就会非常方便。这也强化了“进程”这一概念本身可以用作父类的可能性,也就是说,并非每种类型都必须用作只有单个操作规程的进程。这就是 Simula 语言迈向通用化的第二次飞跃,此时,Simula 67 真正成为了通用编程语言。正是如此变化让尼加德和达尔短暂地萌生了给 Simula 改名的想法,想让人们意识到 Simula 不仅仅可以用作模拟。[^10] 不过,考虑到 “Simula”这个名字的知名度已经很高了,另取名字恐怕会带来不小的麻烦。 + +1967 年,尼加德和达尔与 控制数据公司Control Data 签署协议,着手开发Simula 的新版本:Simula 67。同年六月份的一场会议中,来自控制数据公司、奥斯陆大学以及挪威计算机中心的代表与尼加德和达尔两人会面,意在为这门新语言制定标准与规范。最终,会议发布了 [《Simula 67 通用基础语言》][14],确定了该语言的发展方向。 + +Simula 67 编译器的开发由若干家供应商负责。Simula 用户协会The Association of Simula Users(ASU)也随后成立,并于每年举办年会。不久,Simula 67 的用户就遍及了 23 个国家。[^11] + +### 21 世纪的 Simula 语言 + +人们至今还记得 Simula,是因为后来那些取代它的编程语言都受到了它的巨大影响。到了今天,你很难找到还在使用 Simula 写程序的人,但是这并不意味着 Simula 已经从这个世界上消失了。得益于 [GNU cim][16],人们在今天依然能够编写和运行 Simula 程序。 + +cim 编译器遵循 1986 年修订后的 Simula 标准,基本上也就是 Simula 67 版本。你可以用它编写类、子类以及虚拟方法,就像是在使用 Simula 67 一样。所以,用 Python 或 Ruby 轻松写出短短几行面向对象的程序,你照样也可以用 cim 写出来: + +``` +! dogs.sim ; +Begin + Class Dog; + ! The cim compiler requires virtual procedures to be fully specified ; + Virtual: Procedure bark Is Procedure bark;; + Begin + Procedure bark; + Begin + OutText("Woof!"); + OutImage; ! Outputs a newline ; + End; + End; + + Dog Class Chihuahua; ! Chihuahua is "prefixed" by Dog ; + Begin + Procedure bark; + Begin + OutText("Yap yap yap yap yap yap"); + OutImage; + End; + End; + + Ref (Dog) d; + d :- new Chihuahua; ! :- is the reference assignment operator ; + d.bark; +End; +``` + +你可以按照下面代码执行程序的编译与运行: + +``` +$ cim dogs.sim +Compiling dogs.sim: +gcc -g -O2 -c dogs.c +gcc -g -O2 -o dogs dogs.o -L/usr/local/lib -lcim +$ ./dogs +Yap yap yap yap yap yap +``` + +(你可能会注意到,cim 先将 Simula 语言编译为 C 语言,然后传递给 C 语言编译器。) + +这就是 1967 年的面向对象程序设计,除了语法方面的不同,和 2019 年的面向对象程序设计并无本质区别。如果你同意我的这一观点,你也就懂得了为什么人们会认为 Simula 在历史上是那么的重要。 + +不过,我更想介绍一下 Simula I 的核心概念——进程模型。Simula 67 保留了进程模型,不过只有在使用 `Process` 类 和 `Simulation` 块的时候才能调用。 + +为了表现出进程是如何运行的,我决定模拟下述场景。想象一下,有这么一座住满了村民的村庄,村庄的旁边有条小河边,小河里有很多的鱼。但是,村里的村民却只有一条鱼竿。村民们胃口很大,每隔一个小时就饿了。他们一饿,就会拿着鱼竿去钓鱼。如果一位村民正在等鱼竿,另一位村民自然也用不了。这样一来,村民们就会为了钓鱼排起长长的队伍。假如村民要等五、六分钟才能钓到一条鱼,那么这样等下去,村民们的身体状况就会变得越来越差。再假如,一位村民已经到了骨瘦如柴的地步,最后他可能就会饿死。 + +这个例子多少有些奇怪,虽然我也不说不出来为什么我脑袋里最先想到的是这样的故事,但是就这样吧。我们把村民们当作 Simula 的各个进程,观察在有着四个村民的村庄里,一天的模拟时间内会发生什么。 + +完整程序可以通过此处 [GitHub Gist][17] 的链接获取。 + +我把输出结果的最后几行放在了下面。我们来看看一天里最后几个小时发生了什么: + +``` +1299.45: 王五饿了,要了鱼竿。 +1299.45: 王五正在钓鱼。 +1311.39: 王五钓到了一条鱼。 +1328.96: 赵六饿了,要了鱼竿。 +1328.96: 赵六正在钓鱼。 +1331.25: 李四饿了,要了鱼竿。 +1340.44: 赵六钓到了一条鱼。 +1340.44: 李四饿着肚子等着鱼竿。 +1340.44: 李四在等鱼竿的时候饿死了。 +1369.21: 王五饿了,要了鱼竿。 +1369.21: 王五正在钓鱼。 +1379.33: 王五钓到了一条鱼。 +1409.59: 赵六饿了,要了鱼竿。 +1409.59: 赵六正在钓鱼。 +1419.98: 赵六钓到了一条鱼。 +1427.53: 王五饿了,要了鱼竿。 +1427.53: 王五正在钓鱼。 +1437.52: 王五钓到了一条鱼。 +``` + +可怜的李四最后饿死了,但是他比张三要长寿,因为张三还没到上午 7 点就饿死了。赵六和王五现在一定过得很好,因为需要鱼竿的就只剩下他们两个了。 + +这里,我要说明,这个程序最重要的部分只是创建了进程(四个村民),并让它们运行下去。各个进程操作对象(鱼竿)的方式与我们今天对对象的操作方式相同。但是程序的主体部分并没有调用任何方法,也没有修改进程的任何属性。进程本身具有内部状态,但是这种内部状态的改变只有进程自身才能做到。 + +在这个程序中,仍然有一些字段发生了变化,这类程序设计无法直接解决纯函数式编程所能解决的问题。但是正如克罗达尔所注意到的那样,“这一机制引导进行模拟的程序员为底层系统建立模型,生成一系列进程,每个进程表示了系统内的自然事件顺序。”[^12] 我们不是主要从名词或行动者(对其他对象做事的对象)的角度来思考正在进行的进程。我们可以将程序的总控制权交予 Simula 的事件通知系统,克罗达尔称其为 “时间管理器time manager”。因此,尽管我们仍然在适当地改变进程,但是没有任何进程可以假设其他进程的状态。每个进程只能间接地与其他进程进行交互。 + +这种模式如何用以编写编译器、HTTP 服务器以及其他内容,尚且无法确定。(另外,如果你在 Unity 游戏引擎上编写过游戏,就会发现两者十分相似。)我也承认,尽管我们有了“时间管理器”,但这可能并不完全是希基的意思,他说我们在程序中需要一个明确的时间概念。(我认为,希基想要的类似于 [阿达·洛芙莱斯Ada Lovelace 用于区分一个变量随时间变化产生的不同数值的上标符号][19]。)尽管如此,我们可以发现,面向对象程序设计前期的设计方式与我们今天所习惯的面向对象程序设计并非完全一致,我觉得这一点很有意思。我们可能会理所当然地认为,面向对象程序设计的方式千篇一律,即程序就是对事件的一长串记录:某个对象以特定顺序对其他对象产生作用。Simula I 的进程系统表明,面向对象程序设计的方式不止一种。仔细想一下,函数式语言或许是更好的设计方式,但是 Simula I 的发展告诉我们,现代面向对象程序设计被取代也很正常。 + +_如果你喜欢这篇文章,欢迎关注推特 [@TwoBitHistory][20],也可通过 [RSS feed][21] 订阅,获取最新文章(每四周更新一篇)。_ + + +[^1]: Jan Rune Holmevik, “The History of Simula,” accessed January 31, 2019, .  +[^2]: Ole-Johan Dahl and Kristen Nygaard, “SIMULA—An ALGOL-Based Simulation Langauge,” Communications of the ACM 9, no. 9 (September 1966): 671, accessed January 31, 2019, [http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.95.384&rep=rep1&type=pdf][24].  +[^3]: Stein Krogdahl, “The Birth of Simula,” 2, accessed January 31, 2019, .  +[^4]: 出处同上。  +[^5]: Ole-Johan Dahl and Kristen Nygaard, “The Development of the Simula Languages,” ACM SIGPLAN Notices 13, no. 8 (August 1978): 248, accessed January 31, 2019, .  +[^6]: Dahl and Nygaard (1966), 676.  +[^7]: Dahl and Nygaard (1978), 257.  +[^8]: Krogdahl, 3.  +[^9]: Ole-Johan Dahl, “The Birth of Object-Orientation: The Simula Languages,” 3, accessed January 31, 2019, .  +[^10]: Dahl and Nygaard (1978), 265.  +[^11]: Holmevik.  +[^12]: Krogdahl, 4.  + +-------------------------------------------------------------------------------- + +via: https://twobithistory.org/2019/01/31/simula.html + +作者:[Two-Bit History][a] +选题:[lujun9972][b] +译者:[aREversez](https://github.com/aREversez) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://twobithistory.org +[b]: https://github.com/lujun9972 +[1]: https://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey +[2]: https://twobithistory.org/images/river.jpg +[10]: https://archive.computerhistory.org/resources/text/algol/ACM_Algol_bulletin/1061032/p39-hoare.pdf +[14]: http://web.eah-jena.de/~kleine/history/languages/Simula-CommonBaseLanguage.pdf +[16]: https://www.gnu.org/software/cim/ +[17]: https://gist.github.com/sinclairtarget/6364cd521010d28ee24dd41ab3d61a96 +[19]: https://twobithistory.org/2018/08/18/ada-lovelace-note-g.html +[20]: https://twitter.com/TwoBitHistory +[21]: https://twobithistory.org/feed.xml +[22]: https://twitter.com/TwoBitHistory/status/1075075139543449600?ref_src=twsrc%5Etfw +[24]: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.95.384&rep=rep1&type=pdf diff --git a/published/202206/20210104 10 ways Ansible is for everyone.md b/published/202206/20210104 10 ways Ansible is for everyone.md new file mode 100644 index 0000000000..a47695f268 --- /dev/null +++ b/published/202206/20210104 10 ways Ansible is for everyone.md @@ -0,0 +1,75 @@ +[#]: collector: (lujun9972) +[#]: translator: (Donkey-Hao) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14739-1.html) +[#]: subject: (10 ways Ansible is for everyone) +[#]: via: (https://opensource.com/article/21/1/ansible) +[#]: author: (James Farrell https://opensource.com/users/jamesf) + +分享 10 篇 Ansible 文章 +====== + +> 通过这些 Ansible 文章扩展你的知识和技能。 + +![](https://img.linux.net.cn/data/attachment/album/202206/21/111840akw4bjd13dh8ayky.jpg) + +我希望能够激发刚刚接触 Ansible 的初学者的兴趣。这里有一系列总结文章,我已将其包括在内,以供你随意后续查阅。 + +### 适合初学者的 Ansible + +这五篇文章对于 Ansible 新手来说是一个非常好的起点。前三篇文章由 Seth Kenlon 撰写。 + + * 如果你不了解 Ansible ,[现在可以做这 7 件事][2] 来入手。这是很好的入门指导,它收集了用于管理硬件、云、容器等的链接。 + * 在 《[编排与自动化有何区别?][3]》 这篇文章中,你会学到一些术语和技术路线,将会激发你对 Ansible 感兴趣。 + * 文章 《[如何用 Ansible 安装软件][4]》 覆盖了一些脚本概念和一些 Ansible 的好惯例,给出了一些本地或远程管理软件包的案例。 + * 在 [我编写 Ansible 剧本时学到的 3 个教训][5] 中,使自己养成 Jeff Geerling 所传授的好习惯,他是一位真正的 Ansible 资深人士。源代码控制、文档、测试、简化和优化是自动化成功的关键。 + * 《[我使用 Ansible 的第一天][6]》 介绍了记者 David Both 在解决重复性开发任务时的思考过程。这篇文章从 Ansible 的基础开始,并说明了一些简单的操作和任务。 + +### 尝试 Ansible 项目 + +一旦你掌握了基础和并拥有良好习惯,就可以开始一些具体主题和实例了。 + + * Ken Fallon 在 《[使用 Ansible 管理你的树莓派机群][7]》 一文中介绍了一个部署和管理树莓派设备机群的示例。它介绍了受限环境中的安全和维护概念。 + * 在 《[将你的日历与 Ansible 融合以避免日程冲突][8]》一文中,Nicolas Leiva 快速介绍了如何使用前置任务和条件在自动日程安排中中强制执行隔离窗口 + * Nicolas 在 《[创建一个整合你的谷歌日历的 Ansible 模块][9]》中完成了他的日历隔离的理念。他的文章深入探讨了在 Go 中编写自定义 Ansible 模块以实现所需的日历连接。 Nicolas 介绍了构建和调用 Go 程序并将所需数据传递给 Ansible 并接收所需输出的不同方法。 + +### 提升你的 Ansible 技巧 + +Kubernetes 是近来的热门话题,以下文章提供了一些很好的示例来学习新技能。 + + * 在 《[适用于 Kubernets 自动编排你的 Ansible 模块][10]》 文章中,Seth Kenlon 介绍了 Ansible Kubernetes 模块, 介绍了用于测试的基本 Minikube 环境,并提供了一些用于Pod 控制的 `k8s` 模块的基本示例。 + * Jeff Geerling 在 《[使用 Ansible 的 Helm 模块构建 Kubernetes Minecraft 服务器][11]》 中解释了 Helm Chart 应用程序、Ansible 集合以及执行一个有趣的项目以在 k8s 集群中设置你自己的 Minecraft 服务器的概念。 + +我希望你的 Ansible 旅程已经开始,并能常从这些文章中充实自己。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/1/ansible + +作者:[James Farrell][a] +选题:[lujun9972][b] +译者:[Donkey](https://github.com/Donkey-Hao) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jamesf +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/innovation_lightbulb_gears_devops_ansible.png?itok=TSbmp3_M (gears and lightbulb to represent innovation) +[2]: https://opensource.com/article/20/9/ansible +[3]: https://opensource.com/article/20/11/orchestration-vs-automation +[4]: https://opensource.com/article/20/9/install-packages-ansible +[5]: https://opensource.com/article/20/1/ansible-playbooks-lessons +[6]: https://opensource.com/article/20/10/first-day-ansible +[7]: https://opensource.com/article/20/9/raspberry-pi-ansible +[8]: https://opensource.com/article/20/10/calendar-ansible +[9]: https://opensource.com/article/20/10/ansible-module-go +[10]: https://opensource.com/article/20/9/ansible-modules-kubernetes +[11]: https://opensource.com/article/20/10/kubernetes-minecraft-ansible +[12]: https://opensource.com/article/20/1/ansible-news-edition-six +[13]: https://opensource.com/article/20/2/ansible-news-edition-seven +[14]: https://opensource.com/article/20/3/ansible-news-edition-eight +[15]: https://opensource.com/article/20/4/ansible-news-edition-nine +[16]: https://opensource.com/article/20/5/ansible-news-edition-ten +[17]: https://opensource.com/how-submit-article diff --git a/published/202206/20210104 Docker Compose- a nice way to set up a dev environment.md b/published/202206/20210104 Docker Compose- a nice way to set up a dev environment.md new file mode 100644 index 0000000000..fd2ddc9846 --- /dev/null +++ b/published/202206/20210104 Docker Compose- a nice way to set up a dev environment.md @@ -0,0 +1,245 @@ +[#]: collector: (lujun9972) +[#]: translator: (lkxed) +[#]: reviewer: (turbokernel) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14747-1.html) +[#]: subject: (Docker Compose: a nice way to set up a dev environment) +[#]: via: (https://jvns.ca/blog/2021/01/04/docker-compose-is-nice/) +[#]: author: (Julia Evans https://jvns.ca/) + +Docker Compose:搭建开发环境的好方式 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/23/180033lpg4v4bz0bbb1719.jpg) + +大家好!我又写了一篇关于 [我最喜欢的电脑工具][1] 的文章。这一篇讲的是 Docker Compose! + +本文主要就是讲一讲我对 Docker Compose 有多么满意啦(不讨论它的缺点)!咳咳,因为它总能够完成它该做的,并且似乎总能有效,更棒的是,它的使用还非常简单。另外,在本文中,我只讨论我是如何用 Docker Compose 来搭建开发环境的,而不涉及它在生产中的使用。 + +最近,我考虑了很多关于这种个人开发环境的搭建方式,原因是,我现在把所有的计算工作都搬到了一个私有云上,大概 20 美元/月的样子。这样一来,我就不用在工作的时候花时间去思考应该如何管理几千台 AWS 服务器了。 + +在此之前,我曾花了两天的时间,尝试使用其他的工具来尝试搭建一个开发环境,搭到后面,我实在是心累了。相比起来,Docker Compose 就简单易用多了,我非常满意。于是,我和妹妹分享了我的 `docker-compose` 使用经历,她略显惊讶:“是吧!你也觉得 Docker Compose 真棒对吧!” 嗯,我觉得我应该写一篇博文把过程记录下来,于是就有了你们看到的这篇文章。 + +### 我们的目标是:搭建一个开发环境 + +目前,我正在编写一个 Ruby on Rails 服务(它是一个计算机“调试”游戏的后端)。在我的生产服务器上,我安装了: + + * 一个 Nginx 服务器 + * 一个 Rails 服务 + * 一个 Go 服务(使用了 [gotty][2] 来代理一些 SSH 连接) + * 一个 Postgres 数据库 + +在本地搭建 Rails 服务非常简单,用不着容器(我只需要安装 Postgres 和 Ruby 就行了,小菜一碟)。但是,我还想要把匹配 `/proxy/*` 的请求的发送到 Go 服务,其他所有请求都发送到 Rails 服务,所以需要借助 Nginx。问题来了,在笔记本电脑上安装 Nginx 对我来说太麻烦了。 + +是时候使用 `docker-compose` 了! + +### docker-compose 允许你运行一组 Docker 容器 + +基本上,Docker Compose 的作用就是允许你运行一组可以互相通信 Docker 容器。 + +你可以在一个叫做 `docker-compose.yml` 的文件中,配置你所有的容器。我在下方将贴上我为这个服务编写的 `docker-compose.yml` 文件(完整内容),因为我觉得它真的很简洁、直接! + +``` +version: "3.3" +services: + db: + image: postgres + volumes: + - ./tmp/db:/var/lib/postgresql/data + environment: + POSTGRES_PASSWORD: password # yes I set the password to 'password' + go_server: + # todo: use a smaller image at some point, we don't need all of ubuntu to run a static go binary + image: ubuntu + command: /app/go_proxy/server + volumes: + - .:/app + rails_server: + build: docker/rails + command: bash -c "rm -f tmp/pids/server.pid && source secrets.sh && bundle exec rails s -p 3000 -b '0.0.0.0'" + volumes: + - .:/app + web: + build: docker/nginx + ports: + - "8777:80" # this exposes port 8777 on my laptop +``` + +这个配置包含了两种容器。对于前面两个容器,我直接使用了现有的镜像(`image: postgres` 和 `image: ubuntu`)。对于后面两个容器,我不得不构建一个自定义容器镜像,其中, `build: docker/rails` 的作用就是告诉 Docker Compose,它应该使用 `docker/rails/Dockerfile` 来构建一个自定义容器。 + +我需要允许我的 Rails 服务访问一些 API 密钥和其他东西,因此,我使用了 `source secrets.sh`,它的作用就是在环境变量中预设一组密钥。 + +### 如何启动所有服务:先 “build” 后 “up” + +我一直都是先运行 `docker-compose build` 来构建容器,然后再运行 `docker-compose up` 把所有服务启动起来。 + +你可以在 yaml 文件中设置 `depends_on`,从而进行更多启动容器的控制。不过,对于我的这些服务而言,启动顺序并不重要,所以我没有设置它。 + +### 网络互通也非常简单 + +容器之间的互通也是一件很重要的事情。Docker Compose 让这件事变得超级简单!假设我有一个 Rails 服务正在名为 `rails_server` 的容器中运行,端口是 3000,那么我就可以通过 `http://rails_server:3000` 来访问该服务。就是这么简单! + +以下代码片段截取自我的 Nginx 配置文件,它是根据我的使用需求配置的(我删除了许多 `proxy_set_headers` 行,让它看起来更清楚): + +``` +location ~ /proxy.* { + proxy_pass http://go_server:8080; +} +location @app { + proxy_pass http://rails_server:3000; +} +``` + +或者,你可以参考如下代码片段,它截取自我的 Rails 项目的数据库配置,我在其中使用了数据库容器的名称(`db`): + +``` +development: + <<: *default + database: myproject_development + host: db # <-------- 它会被“神奇地”解析为数据库容器的 IP 地址 + username: postgres + password: password +``` + +至于 `rails_server` 究竟是如何被解析成一个 IP 地址的,我还真有点儿好奇。貌似是 Docker 在我的计算机上运行了一个 DNS 服务来解析这些名字。下面是一些 DNS 查询记录,我们可以看到,每个容器都有它自己的 IP 地址: + +``` +$ dig +short @127.0.0.11 rails_server +172.18.0.2 +$ dig +short @127.0.0.11 db +172.18.0.3 +$ dig +short @127.0.0.11 web +172.18.0.4 +$ dig +short @127.0.0.11 go_server +172.18.0.5 +``` + +### 是谁在运行这个 DNS 服务? + +我(稍微)研究了一下这个 DNS 服务是怎么搭建起来的。 + +以下所有命令都是在容器外执行的,因为我没有在容器里安装很多网络工具。 + +**第一步:**:使用 `ps aux | grep puma`,获取 Rails 服务的进程 ID。 + +找到了,它是 `1837916`!简单~ + +**第二步:**:找到和 `1837916` 运行在同一个网络命名空间的 UDP 服务。 + +我使用了 `nsenter` 来在 `puma` 进程的网络命令空间内运行 `netstat`(理论上,我猜想你也可以使用 `netstat -tupn` 来只显示 UDP 服务,但此时,我的手指头只习惯于打出 `netstat -tulpn`)。 + +``` +$ sudo nsenter -n -t 1837916 netstat -tulpn +Active Internet connections (only servers) +Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name +tcp 0 0 127.0.0.11:32847 0.0.0.0:* LISTEN 1333/dockerd +tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 1837916/puma 4.3.7 +udp 0 0 127.0.0.11:59426 0.0.0.0:* 1333/dockerd +``` + +我们可以看到,此时有一个运行在 `59426` 端口的 UDP 服务,它是由 `dockerd` 运行的!或许它就是我们要找的 DNS 服务? + +**第三步**:确定它是不是我们要找的 DNS 服务 + +我们可以使用 `dig` 工具来向它发送一个 DNS 查询: + +``` +$ sudo nsenter -n -t 1837916 dig +short @127.0.0.11 59426 rails_server +172.18.0.2 +``` + +奇怪,我们之前运行 `dig` 的时候,DNS 查询怎么没有发送到 `59426` 端口,而是发送到了 `53` 端口呢?这到底是怎么回事呀? + +**第四步**:iptables + +对于类似“这个服务似乎正运行在 X 端口上,但我却在 Y 端口上访问到了它,这是什么回事呢?”的问题,我的第一念头都是“一定是 iptables 在作怪”。 + +于是,我在运行了容器的网络命令空间内执行 `iptables-save`,果不其然,真相大白: + +``` +$ sudo nsenter -n -t 1837916 iptables-save +.... redacted a bunch of output .... +-A DOCKER_POSTROUTING -s 127.0.0.11/32 -p udp -m udp --sport 59426 -j SNAT --to-source :53 +COMMIT +``` + +在输出中有一条 iptables 规则,它将 `53` 端口的流量发送到了 `59426` 上。哈哈,真有意思! + +### 数据库文件储存在一个临时目录中 + +这样做有一个好处:我可以直接挂载 Postgres 容器的数据目录 `./tmp/db`,而无需在我的笔记本电脑上管理 Postgres 环境。 + +我很喜欢这种方式,因为我真的不想在笔记本电脑上独自管理一个 Postgres 环境(我也真的不知道该如何配置 Postgres)。另外,出于习惯,我更喜欢让开发环境的数据库和代码放在同一个目录下。 + +### 仅需一行命令,我就可以访问 Rails 控制台 + +管理 Ruby 的版本总是有点棘手,并且,即使我暂时搞定了它,我也总是有点担心自己会把 Ruby 环境搞坏,然后就要修它个十年(夸张)。 + +(使用 Docker Compose)搭建好这个开发环境后,如果我需要访问 Rails 控制台console(一个交互式环境,加载了所有我的 Rails 代码),我只需要运行一行代码即可: + +``` +$ docker-compose exec rails_server rails console +Running via Spring preloader in process 597 +Loading development environment (Rails 6.0.3.4) +irb(main):001:0> +``` + +好耶! + +### 小问题:Rails 控制台的历史记录丢失了 + +我碰到了一个问题:Rails 控制台的历史记录丢失了,因为我一直在不断地重启它。 + +不过,我也找到了一个相当简单的解决方案(嘿嘿):我往容器中添加了一个 `/root/.irbrc` 文件,它能够把 IRB 历史记录文件的保存位置指向一个不受容器重启影响的地方。只需要一行代码就够啦: + +``` +IRB.conf[:HISTORY_FILE] = "/app/tmp/irb_history" +``` + +### 我还是不知道它在生产环境的表现如何 + +到目前为止,这个项目的生产环境搭建进度,还停留在“我制作了一个 DigitalOcean droplet(LCCT 译注:一种 Linux 虚拟机服务),并手工编辑了很多文件”的阶段。 + +嗯……我相信以后会在生产环境中使用 docker-compose 来运行一下它的。我猜它能够正常工作,因为这个服务很可能最多只有两个用户在使用,并且,如果我愿意,我可以容忍它在部署过程中有 60 秒的不可用时间。不过话又说回来,出错的往往是我想不到的地方。 + +推特网友提供了一些在生产中使用 docker-compose 的注意事项: + + * `docker-compose up` 只会重启那些需要重启的容器,这会让重启速度更快。 + * 有一个 Bash 小脚本 [wait-for-it][3],你可以用它来保持等待一个容器,直到另一个容器的服务可用。 + * 你可以准备两份 `docker-compose.yaml` 文件:用于开发环境的 `docker-compose.yaml` 和用于生产环境的 `docker-compose-prod.yaml`。我想我会在分别为 Nginx 指定不同的端口:开发时使用 `8999`,生产中使用 `80`。 + * 人们似乎一致认为,如果你的项目是一台计算机上运行的小网站,那么 docker-compose 在生产中不会有问题。 + * 有个人建议说,如果愿意在生产环境搭建复杂那么一丢丢,Docker Swarm 就或许会是更好的选择,不过我还没试过(当然,如果要这么说的话,干嘛不用 Kubernetes 呢?Docker Compose 的意义就是它超级简单,而 Kubernetes 肯定不简单 : ))。 + +Docker 似乎还有一个特性,它能够 [把你用 docker-compose 搭建的环境,自动推送到弹性容器服务(ESC)上][4],听上去好酷的样子,但是我还没有试过。 + +### docker-compose 会有不适用的场景吗 + +我听说 docker-compose 在以下场景的表现较差: + + * 当你有很多微服务的时候(还是自己搭建比较好) + * 当你尝试从一个很大的数据库中导入数据时(就像把几百 G 的数据存到每个人的笔记本电脑里一样) + * 当你在 Mac 电脑上运行 Docker 时。我听说 Docker 在 macOS 上比在 Linux 上要慢很多(我猜想是因为它需要做额外的虚拟化)。我没有 Mac 电脑,所以我还没有碰到这个问题。 + +### 以上就是全部内容啦! + +在此之前,我曾花了一整天时间,尝试使用 Puppet 来配置 Vagrant 虚拟机,然后在这个虚拟机里配置开发环境。结果,我发现虚拟机启动起来实在是有点慢啊,还有就是,我也不喜欢编写 Puppet 配置(哈哈,没想到吧)。 + +幸好,我尝试了 Docker Compose,它真好简单,马上就可以开始工作啦! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2021/01/04/docker-compose-is-nice/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[lkxed](https://github.com/lkxed) +校对:[turbokernel](https://github.com/turbokernel) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://jvns.ca/#cool-computer-tools---features---ideas +[2]: https://github.com/yudai/gotty/ +[3]: https://github.com/vishnubob/wait-for-it +[4]: https://docs.docker.com/cloud/ecs-integration/ diff --git a/translated/tech/20210115 Learn awk by coding a -guess the number- game.md b/published/202206/20210115 Learn awk by coding a -guess the number- game.md similarity index 71% rename from translated/tech/20210115 Learn awk by coding a -guess the number- game.md rename to published/202206/20210115 Learn awk by coding a -guess the number- game.md index 30040b9347..24738ff4be 100644 --- a/translated/tech/20210115 Learn awk by coding a -guess the number- game.md +++ b/published/202206/20210115 Learn awk by coding a -guess the number- game.md @@ -1,57 +1,57 @@ [#]: collector: (lujun9972) -[#]: translator: (FYJNEVERFOLLOWS ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (FYJNEVERFOLLOWS) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14668-1.html) [#]: subject: (Learn awk by coding a "guess the number" game) [#]: via: (https://opensource.com/article/21/1/learn-awk) [#]: author: (Chris Hermansen https://opensource.com/users/clhermansen) -编写一个“猜数”游戏的程序来学习 awk +通过编写“猜数字”游戏来学习 Awk ====== -编程语言往往具有许多共同特征。学习一门新语言的好方法是去写一个熟悉的程序。在本文中,我将会使用 awk 编写一个“猜数”程序来展示熟悉的概念。 -![question mark in chalk][1] +> 编程语言往往具有许多共同特征。学习一门新语言的好方法是去写一个熟悉的程序。在本文中,我将会使用 Awk 编写一个“猜数字”程序来展示熟悉的概念。 + +![](https://img.linux.net.cn/data/attachment/album/202206/03/130545jthh1vtoadahwahd.jpg) 当你学习一门新的编程语言时,最好把重点放在大多数编程语言都有的共同点上: + * 变量 —— 存储信息的地方 * 表达式 —— 计算的方法 * 语句 —— 在程序中表示状态变化的方法 - 这些概念是大多是编程语言的基础。 -一旦你理解了这些概念,你就可以开始把其他的弄清楚。例如,大多数语言都有得到其设计支持的“处理方式”,这些方式在不同语言之间可能有很大的不同。这些方法包括模块化(将相关功能分组在一起)、声明性与命令性、面向对象、低级与高级语法特性等等。许多程序员熟悉的一个例子是“仪式”,即,在处理问题之前设置场景所需的工作量。据说 Java 编程语言有一个重要的仪式要求,这源于它的设计,要求所有代码都在一个类中定义。 +一旦你理解了这些概念,你就可以开始把其他的弄清楚。例如,大多数语言都有由其设计所支持的“处理方式”,这些方式在不同语言之间可能有很大的不同。这些方法包括模块化(将相关功能分组在一起)、声明式与命令式、面向对象、低级与高级语法特性等等。许多程序员比较熟悉的是编程“仪式”,即,在处理问题之前设置场景所需花费的工作。据说 Java 编程语言有一个源于其设计的重要仪式要求,就是所有代码都在一个类中定义。 -但是回到最基本的,编程语言通常有相似之处。一旦你掌握了一种编程语言,就从学习另一种语言的基本知识开始,去品味这种新语言的不同之处。 +但从根本上讲,编程语言通常有相似之处。一旦你掌握了一种编程语言,就可以从学习另一种语言的基本知识开始,品味这种新语言的不同之处。 -继续进行的一个好方法是创建一组基本的测试程序。有了这些,就可以从这些相似之处开始学习。 +一个好方法是创建一组基本的测试程序。有了这些,就可以从这些相似之处开始学习。 你可以选择创建的一个测试程序是“猜数字”程序。电脑从 1 到 100 之间选择一个数字,让你猜这个数字。程序一直循环,直到你猜对为止。 “猜数字”程序练习了编程语言中的几个概念: + * 变量 * 输入 * 输出 * 条件判断 * 循环 - 这是学习一门新的编程语言的一个很好的实践实验。 - -**注**:本文改编自 Moshe Zadka 关于在 [Julia][2] 中使用这种方法的文章和Jim Hall关于在 [Bash][3] 中使用这种方法的文章。 +**注**:本文改编自 Moshe Zadka 在 [Julia][2] 中使用这种方法和 Jim Hall在 [Bash][3] 中使用这种方法的文章。 ### 在 awk 程序中猜数 -让我们编写一个实现“猜数字”游戏的 awk 程序。 -Awk 是动态类型的,是一种面向数据转换的脚本语言,并且对交互使用有着令人惊讶的良好支持。Awk 出现于 20 世纪 70 年代,最初是 Unix 操作系统的一部分。如果你不了解 Awk,但是喜欢电子表格,可以看一下这个链接 [去学习 Awk][4]! +让我们编写一个实现“猜数字”游戏的 Awk 程序。 -您可以通过编写一个版本的“猜数字”游戏来开始对 Awk 的探索。 +Awk 是动态类型的,这是一种面向数据转换的脚本语言,并且对交互使用有着令人惊讶的良好支持。Awk 出现于 20 世纪 70 年代,最初是 Unix 操作系统的一部分。如果你不了解 Awk,但是喜欢电子表格,这就是一个你可以 [去学习 Awk][4] 的信号! + +您可以通过编写一个“猜数字”游戏版本来开始对 Awk 的探索。 以下是我的实现(带有行号,以便我们可以查看一些特定功能): - ```      1    BEGIN {      2        srand(42) @@ -71,20 +71,21 @@ Awk 是动态类型的,是一种面向数据转换的脚本语言,并且对     16        }     17    } ``` + 我们可以立即看到 Awk 控制结构与 C 或 Java 的相似之处,但与 Python 不同。 -在像 *if-then-else*、*while* 这样的语句中,*then*、*else* 和 *while* 部分接受一个语句或一组被 **{** 和 **}** 包围的语句。然而,Awk 有一个很大的区别需要从一开始就了解: +在像 `if-then-else`、`while` 这样的语句中,`then`、`else` 和 `while` 部分接受一个语句或一组被 `{` 和 `}` 包围的语句。然而,Awk 有一个很大的区别需要从一开始就了解: 根据设计,Awk 是围绕数据管道构建的。 这是什么意思呢?大多数 Awk 程序都是一些代码片段,它们接收一行输入,对数据做一些处理,然后将其写入输出。认识到这种转换管道的需要,Awk 默认情况下提供了所有的转换管道。让我们通过关于上面程序的一个基本问题来探索:“从控制台读取数据”的结构在哪里? -答案是——“内置的”。特别的,第 7-17 行告诉 Awk 如何处理被读取的每一行。在这种情况下,很容易看到第 1-6 行在读取任何内容之前被执行。 +答案是——“内置的”。特别的,第 7-17 行告诉 Awk 如何处理被读取的每一行。在这种情况下,很容易看到第 1-6 行是在读取任何内容之前被执行的。 -更具体地说,第 1 行上的 **BEGIN** 关键字是一种“模式”,在本例中,它指示 Awk 在读取任何数据之前,应该先执行 { … } 中 **BEGIN** 后面的内容。另一个类似的关键字 **END**,在这个程序中没有被使用,它指示 Awk 在读取完所有内容后要做什么。 +更具体地说,第 1 行上的 `BEGIN` 关键字是一种“模式”,在本例中,它指示 Awk 在读取任何数据之前,应该先执行 `{ ... }` 中 `BEGIN` 后面的内容。另一个类似的关键字 `END`,在这个程序中没有被使用,它指示 Awk 在读取完所有内容后要做什么。 -回到第 7-17 行,我们看到它们创建了一个类似代码块 { … } 的片段,但前面没有关键字。因为在 **{** 之前没有任何东西可以让 Awk 匹配,所以它将把这一行用于接收每一行输入。每一行的输入都将由用户输入作为猜测。 +回到第 7-17 行,我们看到它们创建了一个类似代码块 `{ ... }` 的片段,但前面没有关键字。因为在 `{` 之前没有任何东西可以让 Awk 匹配,所以它将把这一行用于接收每一行输入。每一行的输入都将由用户输入作为猜测。 -让我们看看正在执行的代码。首先,在读取任何输入之前发生的序言。 +让我们看看正在执行的代码。首先,是在读取任何输入之前发生的序言部分。 在第 2 行,我们用数字 42 初始化随机数生成器(如果不提供参数,则使用系统时钟)。为什么要用 42?[当然要选 42!][5] 第 3 行计算 1 到 100 之间的随机数,第 4 行输出该随机数以供调试使用。第 5 行邀请用户猜一个数字。注意这一行使用的是 `printf`,而不是 `print`。和 C 语言一样,`printf` 的第一个参数是一个用于格式化输出的模板。 @@ -94,7 +95,6 @@ Awk 是动态类型的,是一种面向数据转换的脚本语言,并且对 考虑到 Awk 程序不同寻常的结构,代码片段会对特定的输入行配置做出反应,并处理数据,让我们看看另一种结构,看看过滤部分是如何工作的: - ```      1    BEGIN {      2        srand(42) @@ -120,7 +120,6 @@ Awk 是动态类型的,是一种面向数据转换的脚本语言,并且对 为了完整起见,我们可以使用这些模式将普通的计算与只适用于特定环境的计算分离开来。下面是第三个版本: - ```      1    BEGIN {      2        srand(42) @@ -142,20 +141,21 @@ Awk 是动态类型的,是一种面向数据转换的脚本语言,并且对     18        exit     19    } ``` + 认识到这一点,无论输入的是什么值,都需要将其转换为整数,因此我们创建了第 7-9 行来完成这一任务。现在第 10-12、13-15 和 16-19 行这三组代码,都是指已经定义好的变量 guess,而不是每次都对输入行进行转换。 让我们回到我们想要学习的东西列表: + * 变量 —— 是的,Awk 有这些;我们可以推断出,输入数据以字符串形式输入,但在需要时可以转换为数值 * 输入 —— Awk 只是通过它的“数据转换管道”的方式发送输入来读取数据 * 输出 —— 我们已经使用了 Awk 的 `print` 和 `printf` 函数来将内容写入输出 - * 条件判断 —— 我们已经学习了 Awk 的 *if-then-else* 和对应特定输入行配置的输入过滤器 - * 循环 —— 嗯,想象一下!我们在这里不需要循环,这还是多亏了 Awk 采用的“数据转换管道”方法;循环“就这么发生了”。注意,用户可以通过向 Awk 发送一个文件结束信号(当使用 Linux 终端窗口时可通过快捷键 **CTRL-D**)来提前退出管道。 + * 条件判断 —— 我们已经学习了 Awk 的 `if-then-else` 和对应特定输入行配置的输入过滤器 + * 循环 —— 嗯,想象一下!我们在这里不需要循环,这还是多亏了 Awk 采用的“数据转换管道”方法;循环“就这么发生了”。注意,用户可以通过向 Awk 发送一个文件结束信号(当使用 Linux 终端窗口时可通过快捷键 `CTRL-D`)来提前退出管道。 -考虑不需要循环来处理输入的重要性是非常值得的。Awk 能够长期存在的一个原因是 Awk 程序是紧凑的,而它们紧凑的一个原因是不需要从控制台或文件中读取样板文件。 +不需要循环来处理输入的重要性是非常值得的。Awk 能够长期保持存在的一个原因是 Awk 程序是紧凑的,而它们紧凑的一个原因是不需要从控制台或文件中读取的那些格式代码。 让我们运行下面这个程序: - ``` $ awk -f guess.awk random number is 25 @@ -167,14 +167,15 @@ that's right $ ``` -我们没有涉及的一件事是注释。Awk 注释以“#”开头,以行尾结束。 +我们没有涉及的一件事是注释。Awk 注释以 `#` 开头,以行尾结束。 ### 总结 -Awk 非常强大,这种“猜数字”游戏是入门的好方法。但这不应该是你探索 Awk 的终点。你可以 [阅读关于 Awk 和 Gawk (GNU Awk) 的历史][6],Gawk是 Awk 的扩展版本,如果你在电脑上运行Linux,可能会有这个。或者,你可以 [阅读所有关于它最初开发者的原始版本][7]。 +Awk 非常强大,这种“猜数字”游戏是入门的好方法。但这不应该是你探索 Awk 的终点。你可以看看 [Awk 和 Gawk(GNU Awk)的历史][6],Gawk 是 Awk 的扩展版本,如果你在电脑上运行 Linux,可能会有这个。或者,从它的原始开发者那里阅读关于 [最初版本][7] 的各种信息。 你还可以 [下载我们的备忘单][8] 来帮你记录下你所学的一切。 +> **[Awk 备忘单][8]** -------------------------------------------------------------------------------- @@ -183,7 +184,7 @@ via: https://opensource.com/article/21/1/learn-awk 作者:[Chris Hermansen][a] 选题:[lujun9972][b] 译者:[FYJNEVERFOLLOWS](https://github.com/FYJNEVERFOLLOWS) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/202206/20210122 Configure a Linux workspace remotely from the command line.md b/published/202206/20210122 Configure a Linux workspace remotely from the command line.md new file mode 100644 index 0000000000..5c632a9870 --- /dev/null +++ b/published/202206/20210122 Configure a Linux workspace remotely from the command line.md @@ -0,0 +1,134 @@ +[#]: collector: (lujun9972) +[#]: translator: (Donkey-Hao) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14776-1.html) +[#]: subject: (Configure a Linux workspace remotely from the command line) +[#]: via: (https://opensource.com/article/21/1/remote-configuration-xfce4) +[#]: author: (David Both https://opensource.com/users/dboth) + +从命令行远程配置 Xfce4 工作区 +====== + +> 几乎所有的事情都可以从 Linux 命令行完成,包括对 Xfce4 进行远程配置。 + +![](https://img.linux.net.cn/data/attachment/album/202206/30/114747lfub5hh0b5nyquf3.jpg) + +与专有操作系统相比,我很欣赏 Linux 的一个特点是,几乎所有的东西都可以从命令行中进行管理和配置。意味着几乎所有的事情都可以在本地或者通过 SSH 远程登录进行管理。虽然有时候需要花费一点时间在互联网上搜索,但是你能想到的任务,是有可能从命令行完成的。 + +### 问题 + +有时候需要使用命令行对桌面进行远程配置。在这种特殊情况下,我需要响应远程用户的请求将在 [Xfce][2] 控制板上的工作区从四个减少到三个。这种配置只需要在互联网上搜索约 20 分钟就找到了。 + +xfwm4 的默认工作区数量和许多其他设置可以在 `/usr/share/xfwm4/defaults` 这个文件中找到和修改。因此将 `workspace_count=2` 设置为 `workspace_count=4` 就改变了主机上所有用户的默认值。同时,非 root 用户可以执行 `xfconf-query` 命令来查询和设置 xfwm4 窗口管理器的各种属性。它应该由需要改变设置的用户使用,而不是由 root 使用。 + +在下面的例子中,首先我验证了当前工作区数量为 `4` ,然后将数量改为 `2`,最后确认了新设置。 + +``` +[user@test1 ~]# xfconf-query -c xfwm4 -p /general/workspace_count +4 +[user@test1 ~]# xfconf-query -c xfwm4 -p /general/workspace_count -s 2 +[user@test1 ~]# xfconf-query -c xfwm4 -p /general/workspace_count +2 +[user@test1 ~]# +``` + +此更改会立即生效,用户可以马上看到,无需重新启动,甚至无需注销并重新登录。我曾在我的工作站上玩过这个游戏,当我输入设置不同数量的工作空间的命令时,可以观察到工作空间切换器的变化。我在哪儿都能找到乐子。;- ) + +### 更多探索 + +现在我解决了这个问题,我决深入了解一下 `xfconf-query` 命令。不幸的是,该工具没有手册或信息页,`/usr/share` 中也没有任何文档。退而求其次,使用 `-h` 选项获取一些帮助信息。 + +``` +$ xfconf-query -h + Usage: +   xfconf-query [OPTION…] - Xfconf commandline utility + Help Options: +   -h, --help            显示帮助选项 + Application Options: +   -V, --version         版本信息 +   -c, --channel         查询/修改通道 +   -p, --property        查询/修改属性 +   -s, --set             更新权限的值 +   -l, --list            罗列属性(或者通道,如果没有用 -c 指定) +   -v, --verbose         详细输出 +   -n, --create          当新属性不存在,则创建它 +   -t, --type            指定属性值类型 +   -r, --reset           重置属性 +   -R, --recursive       递归(与 -r 一起使用) +   -a, --force-array     即使只有一个元素也强制采用数组 +   -T, --toggle          反转现有的布尔属性 +   -m, --monitor         监视属性更改的通道 +``` + +这没有多大帮助,但我们还是可以从中找出一些有用的东西。首先,_通道_ 是可以修的属性的分组。我对 `general` 通道下的 `workspace_count` 属性进行了更改。让我们看看完整的通道列表: + +``` +$ xfconf-query -l +Channels: +  xfwm4 +  xfce4-keyboard-shortcuts +  xfce4-notifyd +  xsettings +  xfdashboard +  thunar +  parole +  xfce4-panel +  xfce4-appfinder +  xfce4-settings-editor +  xfce4-power-manager +  xfce4-session +  keyboards +  displays +  keyboard-layout +  ristretto +  xfcethemer +  xfce4-desktop +  pointers +  xfce4-settings-manager +  xfce4-mixer +``` + +给定通道的属性也可以用下列的命令来查看。我使用 `less` 分页器,因为结果是一长串数据。我对下面的列表进行了裁剪,但留下了足够多的条目,你可以看到这些条目的类型。 + +``` +$ xfconf-query -c xfwm4 -l | less +/general/activate_action +/general/borderless_maximize +/general/box_move +/general/box_resize +/general/button_layout +/general/button_offset +<裁剪> +/general/workspace_count +/general/workspace_names +/general/wrap_cycle +/general/wrap_layout +/general/wrap_resistance +/general/wrap_windows +/general/wrap_workspaces +/general/zoom_desktop +(END) +``` + +你可以用这种方式探索所有的通道。我发现通道通常对应“设置管理器”中的各种设置。这些属性是你在这些对话框中设置的。请注意,并非你在“设置管理器”对话窗口中找到的所有设置都是 Xfce 桌面的一部分,因此它们没有对应的通道。屏幕保护程序就是一个例子,因为它是通用的 GNU 屏幕保护程序,并不是 Xfce 独有的。“设置管理器” 是 Xfce 定位这些配置工具的一个很好的中心位置。 + +### 文档 + +综上所述,`xconf-query` 命令似乎没有任何手册或信息页,并且我在网上发现了很多不正确的、记录不全的信息。我发现对 Xfce4 来说最好的文档是 [Xfce 网站][2],关于 `xconf-query` 的一些具体信息可以在这里找到。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/1/remote-configuration-xfce4 + +作者:[David Both][a] +选题:[lujun9972][b] +译者:[Donkey-Hao](https://github.com/Donkey-Hao) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dboth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: https://www.xfce.org/ diff --git a/published/202206/20210124 3 stress-free steps to tackling your task list.md b/published/202206/20210124 3 stress-free steps to tackling your task list.md new file mode 100644 index 0000000000..015dc51560 --- /dev/null +++ b/published/202206/20210124 3 stress-free steps to tackling your task list.md @@ -0,0 +1,66 @@ +[#]: collector: (lujun9972) +[#]: translator: (Donkey-Hao) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14773-1.html) +[#]: subject: (3 stress-free steps to tackling your task list) +[#]: via: (https://opensource.com/article/21/1/break-down-tasks) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +轻松解决你的任务清单的三个步骤 +====== + +> 将你的大任务分为小步骤,避免自己不堪重负。 + +![](https://img.linux.net.cn/data/attachment/album/202206/29/145852zcqqw24v2svulswl.jpg) + +本周开始,我先回顾我的日程安排,看看我需要或想要完成的事情。通常,列表上有些较大的项目。无论来自工作上的问题,还是一系列关于生产力的文章,或者改进我家的鸡舍,当作为一项工作时,这个任务真的很艰巨。很有可能我无法坐下来,在一个时间段内,甚至在一天内完成类似(请注意,只是举例)21 篇文章之类的事情。 + +![21 Days of Productivity project screenshot][2] + +*21 天的生产力 (Kevin Sonney, [CC BY-SA 4.0][3])* + +所以当我的清单上有这样的东西时,我做的第一件事就是把它分解成更小的部分。如著名的诺贝尔文学奖得主 [William Faulkner][4] 说的“移山的人,从小石头开始。”(LCTT 译注:感觉与“千里之行,始于足下”是一个意思) 我们要解决大任务(山)并且需要完成各个步骤(小石头)。 + +我使用下面的步骤将大任务分割为小步骤: + + 1. 我通常很清楚完成一项任务需要做什么。如果没有,我会做一些研究来弄清楚这一点。 + 2. 我会顺序的写下完成的步骤。 + 3. 最后,我坐下来拿着我的日历和清单,开始将任务分散到几天(或几周或几个月),以了解我何时可以完成它。 + +现在我不仅有计划,还知道多久能完成。逐步完成,我可以看到这项大任务不仅变得更小,而且更接近完成。 + +军队有句古话,“遇敌无计”。 几乎可以肯定的是,有一两点(或五点)我意识到像“截屏”这样简单的事情需要扩展到更复杂的事情。事实上,在 [Easy!Appointments][5] 的截图中,竟然是: + + 1. 安装和配置 Easy!Appointments + 2. 安装和配置 Easy!Appointments WordPress 插件 + 3. 生成 API 密钥来同步日历 + 4. 截屏 + +即便如此,我也不得不将这些任务分解成更小的部分——下载软件、配置 NGINX、验证安装……你明白了吧。没关系。一个计划或一组任务不是一成不变的,可以根据需要进行更改。 + +![project completion pie chart][6] + +*今年的计划已经完成了 2/3 ! (Kevin Sonney, [CC BY-SA 4.0][3])* + +这是一项后天习得的技能,最初几次需要一些努力。学习如何将大任务分解成更小的步骤可以让您跟踪实现目标或完成大任务的进度,而不会在过程中不知所措。 + +-------------------------------------------------------------------- + +via: https://opensource.com/article/21/1/break-down-tasks + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[Donkey](https://github.com/Donkey-Hao) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ksonney +[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://opensource.com/sites/default/files/day14-image1.png +[3]: https://creativecommons.org/licenses/by-sa/4.0/ +[4]: https://en.wikipedia.org/wiki/William_Faulkner +[5]: https://opensource.com/article/21/1/open-source-scheduler +[6]: https://opensource.com/sites/default/files/day14-image2_1.png diff --git a/published/202206/20210131 How to teach open source beyond business.md b/published/202206/20210131 How to teach open source beyond business.md new file mode 100644 index 0000000000..1e8afecdf6 --- /dev/null +++ b/published/202206/20210131 How to teach open source beyond business.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: (duoluoxiaosheng) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14686-1.html) +[#]: subject: (How to teach open source beyond business) +[#]: via: (https://opensource.com/article/21/1/open-source-beyond-business) +[#]: author: (Irit Goihman https://opensource.com/users/iritgoihman) + +在商业之外,为学生们教授开源知识 +====== + +> Beyond 计划连接起未来科技行业的人才和开源文化。 + +![](https://img.linux.net.cn/data/attachment/album/202206/08/095200eezhuq7ssd4x4d66.jpg) + +那时,我还是一个大学生,我不明白人们为什么那么吹捧开源软件。我也使用 Linux 和开源软件,但是我不明白开源的运作模式,不知道如何参加一个开源项目,也不知道这对我未来的职业有什么好处。我的开发经验主要是家庭作业和学位需要的一个大型期末项目。 + +所以,当我开始踏足科技行业时,我发现我还有很多知识需要学习。我需要了解如何加入一个既定的、可能很大并且分散在不同地方的团队,为一个正在进行中的项目工作。我还要学会正确的沟通以保证我付出的努力不白费。 + +在这方面,我并不特别。我只是众多毕业生中的一员。 + +### 开源让毕业生的起点更高 + +作为一个工程师,一个管理者,从那时起我开始帮助刚入行的工程师。我发现,有开源经验的毕业生比没有开源经验的毕业生能更快的入门。 + +通过将开源方法纳入学术研究,学生们可以获得相关的行业经验,学会利用他们自己的知识,并建立一个陈述观点和分享知识的平台。参与开源项目可以对学生的技术知识和经验产生积极影响。这可以帮助他们更好的规划自己的职业生涯。 + +开源在科技行业的价值是公认的,它塑造了全球软件公司的文化。参与开源项目并采用 [开放组织文化][2] 正在成为行业普遍现象。公司寻求知道如何在开源领域工作并培养其文化的思想新颖、才华横溢的员工。因此,科技行业必须推动学术界将开源文化作为学习科技研究的基本方法之一。 + +### 商业之上是开源文化 + +当我遇到红帽的高级软件工程师 [Liora Milbaum][3] 时,我发现,我们对将开源文化和规则引入学术界有着共同的兴趣。Liora 之前创立了 [DevOps Loft][4], 在其中,她与有兴趣进入这个行业的人们分享了 DevOps 实践,并希望发起一个类似的项目,教授大学生开源。我们决定启动 [Beyond][5] 计划,将科技行业拥抱开源精神的人才与红帽的实践联系起来。 + +我们在 [Tel Aviv-Yafo 技术学院][6] 开始了 Beyond 计划,在那里,我们受到了信息系统学院的热烈欢迎。我们从介绍 DevOps 技术栈的 “DevOps 入门” 开始。我们开始时最大的挑战是怎么讲明白开源是什么。答案似乎很简单:实践出真理。我们不想给学生们讲授什么老套的学院课程,相反,我们想让学生接触到行业标准。 + +我们创建了一个包含常见的开源项目和工具的教学大纲来教授 DevOps 技术栈。该课程由工程师教授的讲座和实践组成。学生们被分成小组,每组都由一名工程师指导和支持。他们练习团队合作,分享知识(在团队内外),并有效的协作。 + +在我们为计算机科学学院的通讯准备的高级课程 “开源开发的基础” 中,我们遇到了另外的困难。当我们的课程开始两周以后,随着新冠疫情在全球的流行,我们完全靠远程沟通。我们通过与学生一起使用我们在红帽日常工作中使用的相同远程协作工具解决了这个问题。我们惊讶于过渡的是如此简单和顺利。 + +![Beyond teaching online][7] + +(Irit Goihman, [CC BY-SA 4.0][8]) + +### 成果展示 + +这两个课程取得了巨大的成功,我们甚至雇佣了我们最优秀的学生之一。我们收到了非常棒的反馈,同学们表示,我们对他们的知识、思维和软技能产生了积极影响。一些学生因为在课程期间的开源贡献而得到了他们第一份技术工作。 + +其他学术机构对这些课程表达出了极大的兴趣,因此我们将这个项目扩展到了另外一所大学。 + +很荣幸,在一群优秀工程师的参与下,与 Liora 一起领导这个成功的项目。我们一起助力开源社区的成长。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/1/open-source-beyond-business + +作者:[Irit Goihman][a] +选题:[lujun9972][b] +译者:[duoluoxiaosheng](https://github.com/duoluoxiaosheng) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/iritgoihman +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-lead-teacher-learner.png?itok=rMJqBN5G (Teacher or learner?) +[2]: https://opensource.com/open-organization/resources/open-org-definition +[3]: https://www.linkedin.com/in/lioramilbaum +[4]: https://www.devopsloft.io/ +[5]: https://research.redhat.com/blog/2020/05/24/open-source-development-course-and-devops-methodology/ +[6]: https://www.int.mta.ac.il/ +[7]: https://opensource.com/sites/default/files/pictures/beyond_mta.png (Beyond teaching online) +[8]: https://creativecommons.org/licenses/by-sa/4.0/ diff --git a/published/202206/20210207 3 ways to play video games on Linux.md b/published/202206/20210207 3 ways to play video games on Linux.md new file mode 100644 index 0000000000..75f0f9992b --- /dev/null +++ b/published/202206/20210207 3 ways to play video games on Linux.md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: (godgithubf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14756-1.html) +[#]: subject: (3 ways to play video games on Linux) +[#]: via: (https://opensource.com/article/21/2/linux-gaming) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +在 Linux 上玩电子游戏的三种方式 +====== + +> 如果你准备放下爆米花,想从各个角度体验游戏的话,那么就在 Linux 下打开游戏吧! + +![](https://img.linux.net.cn/data/attachment/album/202206/25/143306xijsi5aaz5jsj2aj.jpg) + +如今,人们有更多喜欢 Linux 的理由。在这个系列里,我将分享 21 个使用 Linux 的理由。今天,我将从游戏开始。 + +我过去认为“游戏玩家”是一种非常特殊的生物,要由科学家们在数年的研究和测试之后严谨地认定才行。我从来没有把自己归类为游戏玩家,因为我所玩过的游戏要么是桌面游戏(棋盘类游戏和纸笔角色扮演游戏),要么是 NetHack、俄罗斯方块。现在,在移动设备、游戏机、电脑和电视机上都有游戏,我觉得现在的承认有各种形式的游戏玩家们了。如果你想自称为游戏玩家,你就可以是,不需任何资格认定。你不用必须在心里熟记那些“上上下下左右左右BA”的科乐美秘籍(你甚至可以不知道这是什么);你也不用必须买过和玩过 3A 级游戏。如果你时不时地玩游戏,你就完全可以自称为玩家。如果你想成为一名玩家,那么现在使用 Linux 正当其时。 + +### 欢迎来到游戏世界 + +剥除光鲜的广告,在其下面,你肯定会发现一个欣欣向荣的游戏世界。在人们相信不是电子表格也不是练习打字一类的软件能挣钱以前,新兴的游戏市场已经开始发展起来了。独立游戏indie game已经在流行文化上以各种方式打上了自己的烙印(或许你不相信,《我的世界》尽管不是开源的,但一开始就是一款独立游戏),这也证实了,在玩家眼里,可玩性高于产品价值。 + +独立开发者和开源开发者之间有很多交集。没有什么比带着你的 Linux 笔记本电脑,浏览 itch.io 或你的发行版的软件库,寻找鲜为人知但珍贵的开源游戏宝藏更有意义了。 + +有各种各样的开源游戏,包括大量的第一视角射击游戏、Nodulus 之类的益智游戏、运输大亨之类的策略经营游戏、Jethook 之类的竞速游戏、Sauerbraten 之类的竞速逃生游戏,以及很多未提到的(多亏了像 Open Jam 这样伟大的活动,每年都有新增的游戏)。 + +![Jethook game screenshot][10] + +总的来说,探索开源游戏的世界的体验,和购买大型游戏工作室的产品带来的即时满足感有很大的不同。大型游戏工作室生产的游戏提供大量的视听刺激、知名演员、和长达 60 小时以上的游戏时长。而独立和开源游戏不能与之相提并论。但是话又说回来,大型游戏工作室无法提供的是,当你发现一款别人未曾听说过的游戏时的产生的发现感和与个人相关的感受。当你意识到别人都非常想知道你刚玩过的哪个出色游戏时,大型工作室也并不能提供这种紧迫感。(LCTT 校注:此处大概的意思是指大型工作室的作品已被人熟知,没有什么挖掘的新鲜感) + +花点时间找出你最喜欢的游戏,然后浏览下你的发行商的软件仓库、Flathub、开源的游戏仓库,看看你能发现什么,如果发现你很喜欢的游戏,就帮忙推广一下吧。 + +#### Proton 和 WINE + +Linux 上的游戏并没有止步于开源,但是从开源开始的。数年前 Valve 软件公司通过发行 Linux 版的 Steam 客户端把 Linux 重新带入游戏市场时,人们希望这可以推动游戏工作室能编写原生的 Linux 游戏。一些工作室这样做了,但 Valve 公司并没有成功的把 Linux 推为主要的平台,即使是 Valve 品牌的游戏电脑。并且大多数游戏工作室又转回仅在 Windows 平台上开发游戏的旧方式。 + +有趣的是,最终的结果是产生了更多的开源代码。Valve 公司为 Linux 兼容创建了 Proton 工程,一个可以转换 Windows 游戏到 Linux 的兼容层。在 Proton 的内核层面,它使用了WINE(Wine Is Not an Emulator) —— 以开源的方式极好地重新实现了主要的 Windows 库。 + +游戏市场的成果,如今已经变成了开源世界的宝藏。今天,来自大型工作室的大多数游戏都可以在 Linux 上像原生游戏一样运行。 + +当然,如果你是必须要在发行日就玩上最新版游戏的这类玩家,你可能会遇到一些令人不愉快的“惊喜”。尽管那不是惊喜,很少有大型游戏在发行时毫无漏洞,一周后才补上补丁。这些游戏在 Proton 和 WINE 上运行时遇到这些错误可能更糟糕,因此 Linux 玩家通过避免尽早上车而避免这些问题。这种妥协可能是值得的。我玩过一些游戏,它们在 Proton 平台运行完美,后来从愤怒的论坛帖子中发现,它在最新版的 Windows 上运行显然充满了致命的错误。总之,似乎来自大型工作室的游戏并不完美,但你可能在 Linux 上遇到相似但不同的问题,正如你在 Windows 上遇到的。 + +#### Flatpak + +Linux 近来历史上最令人激动的发展就是 Flatpak 了,它是本地容器和打包的结合,它和游戏无关(或者它和游戏息息相关),它使得 Linux 应用基本上能被分发到任意的 Linux 发行版上。这也适用于游戏,因为在游戏中使用了相当多的前沿技术,而对发行版维护者来说,要跟上任何特定游戏所需的所有最新版本可能是相当苛刻的。 + +Flapak 通过为应用程序库抽象出一种通用的 Flatpak 特定的层,而将其从发行版中抽象出来。Flatpak 软件包的发行者知道,如果一个库不在 Flatpak SDK 中,那么它必须要包含在 Flatpak 软件包中,简单而直接。 + +多亏了 Flatpak,Steam 客户端可以运行在像 Fedora 这样的常用发行版上,也可以运行在 RHEL、Slackware 等从传统角度看并不面向游戏市场的操作系统上。 + +#### Lutris + +如果你并不急于在 Steam 上注册账号,那么可以用我比较偏爱的游戏客户端 Lutris 。表面上看,Lutris 是一个简单的游戏启动器,当你想玩游戏但还没决定玩什么的时候,你可以到这这里找找。有了 Lutris,你可以将系统上的所有游戏添加到你的游戏库,然后从 Lutris 界面启动并立即玩起来。更好的是,Lutris 贡献者(像我一样)会定期发布安装脚本,使你可以轻松安装自己的游戏。这并不是必须的,但它可以是一个很好的捷径,可以绕过一些繁琐的配置。 + +Lutris 也可以借助运行器或子系统,来运行那些不能从应用菜单直接启动的游戏。比如你想玩开源的《魔兽塔防Warcraft Tower Defense》这样的游戏机游戏,你必须运行模拟器。如果你已经安装过模拟器的话,Lutris 可以帮你处理这一切。除此以外,如果你有一个 GOG.com 游戏账号,Lutris 可以访问它,并可以把游戏导入你的游戏库中。 + +没有比这更容易的管理你的游戏的方式了。 + +### 去玩游戏吧 + +Linux 游戏是一种充实且给人力量的体验。我过去避免玩电脑游戏,因为我不觉得我有太多的选择。似乎昂贵的游戏总是在不断发布,并且不可避免的获得好或者不好的极端体验,然后很快又转向下一个。另一方面,开源游戏把我引入了游戏的圈子。我见到过其他玩家和开发者。我见到过艺术家和音乐家、粉丝以及推广者。我玩过各种各样的我从来不知道的游戏。其中一些甚至不够我玩一下午,而其他的却让我长久的着迷于游戏、修改、关卡设计和乐趣。 + +如果你准备好放下爆米花,从各个角度体验下游戏的话,那就在 Linux 上开始游戏吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/2/linux-gaming + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[godgithubf](https://github.com/godgithubf) +校对:[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/gaming_grid_penguin.png?itok=7Fv83mHR (Gaming with penguin pawns) +[2]: https://opensource.com/alternatives/minecraft +[3]: https://itch.io/jam/open-jam-2020 +[4]: https://opensource.com/article/20/5/open-source-fps-games +[5]: https://hyperparticle.itch.io/nodulus +[6]: https://www.openttd.org/ +[7]: https://rcorre.itch.io/jethook +[8]: http://sauerbraten.org/ +[9]: https://opensource.com/article/18/9/open-jam-announcement +[10]: https://opensource.com/sites/default/files/game_0.png +[11]: http://flathub.org +[12]: https://github.com/ValveSoftware/Proton +[13]: http://winehq.org +[14]: https://opensource.com/business/16/8/flatpak +[15]: https://www.redhat.com/en/enterprise-linux-8 +[16]: http://lutris.net +[17]: https://opensource.com/article/18/10/lutris-open-gaming-platform +[18]: https://ndswtd.wordpress.com/download diff --git a/published/202206/20210210 Manage your budget on Linux with this open source finance tool.md b/published/202206/20210210 Manage your budget on Linux with this open source finance tool.md new file mode 100644 index 0000000000..7434c9614f --- /dev/null +++ b/published/202206/20210210 Manage your budget on Linux with this open source finance tool.md @@ -0,0 +1,81 @@ +[#]: collector: (lujun9972) +[#]: translator: (hanszhao80) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14679-1.html) +[#]: subject: (Manage your budget on Linux with this open source finance tool) +[#]: via: (https://opensource.com/article/21/2/linux-skrooge) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +使用 Linux 上的开源财务工具 Skrooge 管理你的预算 +====== + +> 使用开源预算工具 Skrooge 让你的财务管理更加轻松。 + +![](https://img.linux.net.cn/data/attachment/album/202206/06/115449f0uy9guxxokj0umo.jpg) + +2021 年,人们喜欢 Linux 的理由比以往任何时候都多。在本系列中,我将分享使用 Linux 的 21 个不同理由。本篇介绍的是个人财务管理。 + +个人财务可能很难管理。当你没有足够的钱在没有经济援助的情况下度日时,这可能是令人沮丧甚至不安的,而当你确实有所需的钱却又不清楚每个月的去向时,这可能会令人惊讶地难以接受。更糟糕的是,我们经常被告知要“制定预算”,好像宣布你每个月的花销就能在某种程度上体现出你需要多少钱。底线是:制定预算是困难的,没有达到你的财务目标是令人沮丧的。但这仍然很重要,Linux 有几个工具可以帮助使任务变得可管理。 + +### 理财 + +就像生活中的其他事情一样,我们都有自己的方法来跟踪我们的财务。我过去常常采取一种简单而直接的方法:我的薪水支票被存入一个账户,然后我会提取一定比例的现金。一旦我钱包里的钱没了,我就得等到下一个发薪日才能花钱。我用了一天没有午餐的时间,就明白了我必须认真对待我的目标,并相应地调整了我的消费行为。对于当时我的简单的生活方式来说,这是一种让我对自己的收入保持诚实的有效手段,但它并不能很好地转化为在线商业交易、长期公用事业合同、投资等等。 + +随着我不断完善我的财务跟踪方式,我了解到个人会计始终是一个不断发展的过程。我们每个人都有独特的财务状况,这告诉我们可以或应该使用什么样的解决方案来跟踪我们的收入和债务。如果你失业了,那么你的预算目标可能是尽可能少花钱。如果你在工作,但在还学生贷款,那么你的目标可能是向银行汇款。如果你在工作,但计划退休,那么你可能会尽可能多地存钱。 + +关于预算,要记住的一点是,它是为了将你的财务现实与你的财务 _目标_ 进行比较。你无法避免一些开支,但在这些之后,你可以设定自己的优先事项。如果你没有达到你的目标,你可以调整自己的行为或改写你的目标,使其更好地反映现实。调整你的财务计划并不意味着你失败了,这只是意味着你最初的预测并不准确。在困难时期,你可能无法达到任何预算目标,但如果你坚持你的预算,你会学到很多关于维持你目前的生活方式(无论它是什么)所需要的财务手段。随着时间的推移,你可以学习调整你可能从未意识到的变化。例如,由于远程工作已成为一种被广泛接受的选择,人们正在搬到农村城镇以降低生活成本。看到这样一种生活方式的转变可以改变你的预算报告,真是令人震惊。 + +重点是,预算编制是一项经常被低估的活动,这在很大程度上是因为它令人生畏。重要的是要认识到,无论你的专业水平或对财务的兴趣如何,你都可以进行预算。无论你 [只使用 LibreOffice 电子表格][2],还是尝试专用的财务应用程序,你都可以设定目标,跟踪自己的行为,并学到许多宝贵的经验教训,这些经验教训最终可能会带来回报。 + +### 开源会计 + +有几个专用于 [Linux 的个人理财应用程序][3],包括 [HomeBank][4]、[Money Manager EX][5]、[GNUCash][6]、[KMyMoney][7] 和 [Skrooge][8]。所有这些应用程序本质上都是账本,你可以在每个月底(或每当你查看帐户时)退回到一个地方,从你的银行导入数据,并审查你的支出如何与你为自己设定的预算保持一致。 + +![显示财务数据的 Skrooge 界面][9] + +我使用 Skrooge 作为我的个人预算跟踪器。即便面对多个银行账户,它也能轻松自如的设置。与大多数开源金融应用程序一样,Skrooge 可以导入多种文件格式,因此我的工作流程大致如下: + + 1. 登录我的银行。 + 2. 将当月的银行对账单导出为 QIF 文件。 + 3. 打开 Skrooge。 + 4. 导入 QIF 文件。每个文件都会自动分配到相应的帐户。 + 5. 对照我为自己设定的预算目标审查我的支出。如果我超支了,那么我就会扣减下个月的目标(这样我就会理性地少花钱来弥补差额)。如果我尚未超出我的目标预算,那么我会把多余的部分移到 12 月的预算中(这样我在年底就会有更多的支出份额)。 + +我只跟踪了 Skrooge 中的家庭预算的一部分。Skrooge 通过一个动态数据库简化了这一过程,该数据库允许我使用自定义标签一次对多个交易进行分类。这使我可以轻松地从一般家庭和公用事业支出中提取我的个人支出,并且我可以在查看 Skrooge 提供的自动生成的报告时利用这些类别。 + +![Skrooge 预算饼图][10] + +最重要的是,流行的 Linux 财务应用程序使我能够以最适合我的方式管理我的预算。例如,我的合作伙伴更喜欢使用 LibreOffice 电子表格,但我只需要付出很少的努力就可以从家庭预算中提取 CSV 文件,将其导入到 Skrooge,并使用一组更新的数据集。不存在供应商锁定和不兼容。该系统灵活敏捷,使我们能够在更多地了解有效预算和生活中的情况时调整我们的预算和跟踪支出的方法。 + +### 开放选择 + +世界各地的货币市场各不相同,我们每个人与之互动的方式也决定了我们可以使用哪些工具。归根结底,你对财务类软件的选择必须基于自己的需求。开源做得特别好的一件事是为用户提供了选择的自由。 + +在设定自己的财务目标时,我很欣赏我可以使用最适合我个人计算风格的任何应用程序。我可以控制我在生活中如何处理数据,即使是我不一定喜欢处理的数据。Linux 及其令人惊叹的应用程序集使它不再是一件苦差事。 + +在 Linux 上尝试一些财务应用程序,看看你是否可以激励自己设定一些目标并节省开支吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/2/linux-skrooge + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[hanszhao80](https://github.com/hanszhao80) +校对:[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/Medical%20Costs%20Transparency_1.jpg?itok=CkZ_J88m (2 cents penny money currency) +[2]: https://opensource.com/article/20/3/libreoffice-templates +[3]: https://opensource.com/life/17/10/personal-finance-tools-linux +[4]: http://homebank.free.fr/en/index.php +[5]: https://www.moneymanagerex.org/download +[6]: https://opensource.com/article/20/2/gnucash +[7]: https://kmymoney.org/download.html +[8]: https://apps.kde.org/en/skrooge +[9]: https://opensource.com/sites/default/files/skrooge.jpg +[10]: https://opensource.com/sites/default/files/skrooge-pie_0.jpg diff --git a/published/202206/20210319 Create a countdown clock with a Raspberry Pi.md b/published/202206/20210319 Create a countdown clock with a Raspberry Pi.md new file mode 100644 index 0000000000..40f4299374 --- /dev/null +++ b/published/202206/20210319 Create a countdown clock with a Raspberry Pi.md @@ -0,0 +1,369 @@ +[#]: subject: (Create a countdown clock with a Raspberry Pi) +[#]: via: (https://opensource.com/article/21/3/raspberry-pi-countdown-clock) +[#]: author: (Chris Collins https://opensource.com/users/clcollins) +[#]: collector: (lujun9972) +[#]: translator: (Donkey-Hao) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14731-1.html) + +使用树莓派做一个倒计时器 +====== + +> 使用树莓派和电子纸显示屏开始倒计时你的下一个假期。 + +![](https://img.linux.net.cn/data/attachment/album/202206/19/145133beh3yp1s3ky6bi5b.jpg) + +[圆周率日][2]Pi Day(3 月 14 日) 来了又走,留下美好的回忆以及 [许多树莓派项目][3] 等待我们去尝试。在任何令人精神振奋、充满欢乐的假期后回到工作中都很难,圆周率日也不例外。当我们回望三月的时候,渴望那些天的快乐。但是不用害怕,亲爱的圆周率日庆祝者们,我们开始下一个节日的漫长倒计时! + +好了,严肃点。我做了一个圆周率日倒计时器,你也可以! + +不久前,我购买了一个 [树莓派 Zero W][4],并且用它来 [解决 WiFi 信号较差的原因][5] 。我也对使用电子纸ePaper来作为它的显示屏十分感兴趣。虽然我不知道该用它来干什么,但是!它看起来真的很有趣!我买了一个十分适合放在树莓派的顶部的 2.13 英寸的 [WaveShare 显示器][6] 。安装很简单:只需要将显示器接到树莓派的 GPIO 上即可。 + +我使用 [树莓派操作系统][7] 来实现该项目,虽然其他的操作系统肯定也能完成。但是下面的 `raspi-config` 命令在树莓派系统上很容易使用。 + +### 设置树莓派和电子纸显示屏 + +设置树莓派和电子纸显示屏一起工作,需要你在树莓派软件中启用串行外设接口(SPI),安装 BCM2835 C 库(来访问树莓派上的博通 BCM 2835 芯片的 GPIO 功能),安装 Python GPIO 库来控制电子纸显示屏。最后,你需要安装 WaveShare 的库来使用 Python 控制这个 2.13 英寸的显示屏。 + +下面是完成这些的步骤。 + +#### 启用 SPI + +树莓派上启用 SPI 最简单的方式是使用 `raspi-config` 命令。SPI 总线允许与设备进行串行数据通信——在本例中,电子纸显示: + +``` +$ sudo raspi-config +``` + +从弹出的菜单中, 选择 “接口选项Interfacing Options -> SPI -> Yes” 来启用 SPI 接口,然后启动。 + +#### 安装 BCM2835 库 + +如上所述,BCM2835 库是用于树莓派博通 BCM2385 芯片的软件,它允许访问 GPIO 引脚来控制设备。 + +在我写这篇文章之时,用于树莓派的最新博通 BCM2385 库版本是 v1.68 。安装此库需要下载软件压缩包然后使用 `make` 来安装: + +``` +# 下载 BCM2853 库并解压 +$ curl -sSL http://www.airspayce.com/mikem/bcm2835/bcm2835-1.68.tar.g> -o - | tar -xzf - + +# 进入解压后的文件夹 +$ pushd bcm2835-1.68/ + +# 配置、检查并安装 BCM2853 库 +$ sudo ./configure +$ sudo make check +$ sudo make install + +# 返回上级目录 +$ popd +``` + +#### 安装需要的 Python 库 + +你用 Python 控制电子纸显示屏需要安装 Python 库 `RPi.GPIO`,还需要使用 `python3-pil` 包来画图。显然,PIL 包已经不行了,但 Pillow 可以作为代替方案。我还没有为该项目测试过 Pillow ,但它可行: + +``` +# 安装需要的 Python 库 +$ sudo apt-get update +$ sudo apt-get install python3-pip python3-pil +$ sudo pip3 install RPi.GPIO +``` + +_注意:这些是 Python3 的指令。你可以在 WaveShare 网站查到 Python2 的指令。_ + +#### 下载 WaveShare 示例和 Python 库 + +Waveshare 维护了一个 Python 和 C 的 Git 库,用于使用其电子纸显示屏和一些展示如何使用它们的示例。对这个倒计时时钟而言,你需要克隆这个库并使用用于 2.13 英寸显示屏的库: + +``` +# 克隆这个 WaveShare e-Paper git 库 +$ git clone https://github.com/waveshare/e-Paper.gi> +``` + +如果你用不同的显示器或者其他公司产品,需要使用适配软件。 + +Waveshare 提供了很多指导: + + * [WaveShare 电子纸设置指导][9] + * [WaveShare 电子纸库安装指导][10] + +#### 获得有趣的字体(选做) + +你可以随心所欲的使用显示器,为什么不搞点花样?找一个炫酷的字体! + +这有大量 [开放字体许可][11] 的字体可供选择。我十分喜爱 Bangers 字体。如果你看过 YouTube 那你见过这种字体了,它十分流行。你可以下载到本地的共享字体目录文件中,并且所有的应用都可以使用,包括这个项目: + +``` +# “Bangers” 字体是 Vernon Adams 使用 Google 字体开放许可授权的字体 +$ mkdir -p ~/.local/share/fonts +$ curl -sSL https://github.com/google/fonts/raw/master/ofl/bangers/Bangers-Regular.ttf -o fonts/Bangers-Regular.ttf +``` + +### 创建一个圆周率日倒计时器 + +现在你已经安装好了软件,可以使用带有炫酷字体的电子纸显示屏了。你可以创建一个有趣的项目:倒计时到下一个圆周率日! + +如果你想,你可以从该项目的 [GitHub 仓库][13] 直接下载 [countdown.py][12] 这个 Python 文件并跳到文章结尾。 + +为了满足大家的好奇心,我将逐步讲解。 + +#### 导入一些库 + +``` +#!/usr/bin/python3 +# -*- coding:utf-8 -*- +import logging +import os +import sys +import time + +from datetime import datetime +from pathlib import Path +from PIL import Image,ImageDraw,ImageFont + +logging.basicConfig(level=logging.INFO) + +basedir = Path(__file__).parent +waveshare_base = basedir.joinpath('e-Paper', 'RaspberryPi_JetsonNano', 'python') +libdir = waveshare_base.joinpath('lib') +``` + +开始先导入一些标准库之后脚本中用。也需要你从 PIL 添加 `Image`、`ImageDraw` 和 `ImageFont`,你会用到这些来画一些简单的图形。最后,为本地 `lib` 目录设置一些变量,该目录包含了用于 2.13 英寸显示屏的 Waveshare Python 库,稍后你可以使用这些变量从本地目录加载库。 + +#### 字体大小辅助函数 + +下一部分是为你选择的 Bangers-Regular.ttf 字体建立一个修改大小的辅助函数。该函数将整型变量作为大小参数,并返回一个图形字体对象来用于显示: + +``` +def set_font_size(font_size): +    logging.info("Loading font...") +    return ImageFont.truetype(f"{basedir.joinpath('Bangers-Regular.ttf').resolve()}", font_size) +``` + +#### 倒计时逻辑 + +接下来是计算这个项目的一个函数:距下次圆周率日还有多久。如果是在一月,那么计算剩余天数将很简单。但是你需要考虑是否今年的圆周率日是否已经过去了(允悲)。如果是的话,那么计算在你可以再次庆祝之前还有多少天: + +``` +def countdown(now): +    piday = datetime(now.year, 3, 14) + +    # 如果错过了就增加一年 +    if piday < now: +        piday = datetime((now.year + 1), 3, 14) + +    days = (piday - now).days + +    logging.info(f"Days till piday: {days}") +    return day +``` + +#### 主函数 + +最后,到了主函数,需要初始化显示屏并向它写数据。这时,你应该写一个欢迎语然后再开始倒计时。但是首先,你需要加载 Waveshare 库: + +``` +def main(): + +    if os.path.exists(libdir): +        sys.path.append(f"{libdir}") +        from waveshare_epd import epd2in13_V2 +    else: +        logging.fatal(f"not found: {libdir}") +        sys.exit(1) +``` + +上面的代码片段检查以确保该库已下载到倒计时脚本旁边的目录中,然后加载`epd2in13_V2` 库。如果你使用不同的显示屏,则需要使用不同的库。如果你愿意,也可以自己编写。我发现阅读 Waveshare 随显示屏提供的 Python 代码很有趣,它比我想象的要简单得多。 + +下一段代码创建一个 EPD(电子纸显示屏)对象以与显示器交互并初始化硬件: + +``` +    logging.info("Starting...") +    try: +        # 创建一个显示对象 +        epd = epd2in13_V2.EPD() + +        # 初始化并清空显示 +        # ePaper 保持它的状态处分更新 +        logging.info("Initialize and clear...") +        epd.init(epd.FULL_UPDATE) +        epd.Clear(0xFF) +``` + +关于电子纸的一个有趣之处:它仅在将像素从白色变为黑色或从黑色变为白色时才耗电。这意味着当设备断电或应用程序因任何原因停止时,屏幕上的任何内容都会保留下来。从功耗的角度来看,这很好,但这也意味着你需要在启动时清除显示,否则你的脚本只会覆盖屏幕上已有的内容。 因此,`epd.Clear(0xFF)` 用于在脚本启动时清除显示。 + +接下来,创建一个“画布”来绘制剩余的显示输出: + +``` +    # 创建一个图形对象 + # 注意:"epd.heigh" 是屏幕的长边 + # 注意:"epd.width" 是屏幕的短边 +    # 真是反直觉… +    logging.info(f"Creating canvas - height: {epd.height}, width: {epd.width}") +    image = Image.new('1', (epd.height, epd.width), 255)  # 255: clear the frame +    draw = ImageDraw.Draw(image) +``` + +这与显示器的宽度和高度相匹配——但它有点反直觉,因为显示器的短边是宽度。我认为长边是宽度,所以这只是需要注意的一点。 请注意,`epd.height` 和 `epd.width` 由 Waveshare 库设置以对应于你使用的设备。 + +#### 欢迎语 + +接下来,你将开始画一些画。这涉及在你之前创建的“画布”对象上设置数据。这还没有将它绘制到电子纸显示屏上——你现在只是在构建你想要的图像。由你为这个项目绘制带有一块馅饼的图像,来创建一个庆祝圆周率日的欢迎信息: + +![画一块馅饼][14] + +很可爱,不是吗? + +``` +    logging.info("Set text text...") +    bangers64 = set_font_size(64) +    draw.text((0, 30), 'PI DAY!', font = bangers64, fill = 0) + +    logging.info("Set BMP...") +    bmp = Image.open(basedir.joinpath("img", "pie.bmp")) +    image.paste(bmp, (150,2)) +``` +最后,_真是是最后了_,你可以展示你画的图画: + +``` +    logging.info("Display text and BMP") +    epd.display(epd.getbuffer(image)) +``` + +上面那段话更新了显示屏,以显示你所画的图像。 + +接下来,准备另一幅图像展示你的倒计时: + +#### 圆周率日倒计时 + +首先,创建一个用来展示倒计时的图像对象。也需要设置数字的字体大小: + +``` +    logging.info("Pi Date countdown; press CTRL-C to exit") +    piday_image = Image.new('1', (epd.height, epd.width), 255) +    piday_draw = ImageDraw.Draw(piday_image) + +    # 设置字体大小 +    bangers36 = set_font_size(36) +    bangers64 = set_font_size(64) +``` + +为了使它显示的时候更像一个倒计时,更新图像的一部分是更加有效的手段,仅更改已经改变的显示数据部分。下面的代码准备以这样方式运行: + +``` +    # 准备更新显示 +    epd.displayPartBaseImage(epd.getbuffer(piday_image)) +    epd.init(epd.PART_UPDATE) +``` + +最后,需要计时,开始一个无限循环来检查据下次圆周率日还有多久,并显示在电子纸上。如果到了圆周率日,你可以输出一些庆祝短语: + +``` +    while (True): +        days = countdown(datetime.now()) +        unit = get_days_unit(days) + +        # 通过绘制一个填充有白色的矩形来清除屏幕的下半部分 +        piday_draw.rectangle((0, 50, 250, 122), fill = 255) + +        # 绘制页眉 +        piday_draw.text((10,10), "Days till Pi-day:", font = bangers36, fill = 0) + +        if days == 0: +            # 绘制庆祝语 +            piday_draw.text((0, 50), f"It's Pi Day!", font = bangers64, fill = 0) +        else: +            # 绘制距下一次 Pi Day 的时间 +            piday_draw.text((70, 50), f"{str(days)} {unit}", font = bangers64, fill = 0) + +        # 渲染屏幕 +        epd.displayPartial(epd.getbuffer(piday_image)) +        time.sleep(5) +``` + +脚本最后做了一些错误处理,包括捕获键盘中断,这样你可以使用 `Ctrl + C` 来结束无限循环,以及一个根据计数来打印 `day` 或 `days` 的函数: + +``` +    except IOError as e: +        logging.info(e) + +    except KeyboardInterrupt: +        logging.info("Exiting...") +        epd.init(epd.FULL_UPDATE) +        epd.Clear(0xFF) +        time.sleep(1) +        epd2in13_V2.epdconfig.module_exit() +        exit() + +def get_days_unit(count): +    if count == 1: +        return "day" + +    return "days" + +if __name__ == "__main__": +    main() +``` + +现在你已经拥有一个倒计时并显示剩余天数的脚本!这是在我的树莓派上的显示(视频经过加速,我没有足够的磁盘空间来保存一整天的视频): + +![Pi Day Countdown Timer In Action][16] + +#### 安装 systemd 服务(选做) + +如果你希望在系统打开时运行倒计时显示,并且无需登录并运行脚本,你可以将可选的 systemd 单元安装为 [systemd 用户服务][17]。 + +将 GitHub 上的 [piday.service][18] 文件复制到 `${HOME}/.config/systemd/user`,如果该目录不存在,请先创建该目录。然后你可以启用该服务并启动它: + +``` +$ mkdir -p ~/.config/systemd/user +$ cp piday.service ~/.config/systemd/user +$ systemctl --user enable piday.service +$ systemctl --user start piday.service + +# Enable lingering, to create a user session at boot +# and allow services to run after logout +$ loginctl enable-linger $USER +``` + +该脚本将输出到 systemd 日志,可以使用 `journalctl` 命令查看输出。 + +### 它开始看起来像是圆周率日了! + +这就是你的作品!一个显示在电子纸显示屏上的树莓派 Zero W 圆周率日倒计时器!并在系统启动时使用 systemd 单元文件启动!现在距离我们可以再次相聚庆祝圆周率日还有好多天的奇妙设备———树莓派。通过我们的小项目,我们可以一目了然地看到确切的天数。 + +但实际上,每个人都可以在每一天在心中庆祝圆周率日,因此请使用自己的树莓派创建一些有趣且具有教育意义的项目吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/3/raspberry-pi-countdown-clock + +作者:[Chris Collins][a] +选题:[lujun9972][b] +译者:[Donkey](https://github.com/Donkey-Hao) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clcollins +[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://en.wikipedia.org/wiki/Pi_Day +[3]: https://opensource.com/tags/raspberry-pi +[4]: https://www.raspberrypi.org/products/raspberry-pi-zero-w/ +[5]: https://opensource.com/article/21/3/troubleshoot-wifi-go-raspberry-pi +[6]: https://www.waveshare.com/product/displays/e-paper.htm +[7]: https://www.raspberrypi.org/software/operating-systems/ +[8]: https://pypi.org/project/Pillow/ +[9]: https://www.waveshare.com/wiki/2.13inch_e-Paper_HAT +[10]: https://www.waveshare.com/wiki/Libraries_Installation_for_RPi +[11]: https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL +[12]: https://github.com/clcollins/epaper-pi-ex/blob/main/countdown.py +[13]: https://github.com/clcollins/epaper-pi-ex/ +[14]: https://opensource.com/sites/default/files/uploads/pie.png (drawing of a piece of pie) +[15]: https://creativecommons.org/licenses/by-sa/4.0/ +[16]: https://opensource.com/sites/default/files/uploads/piday_countdown.gif (Pi Day Countdown Timer In Action) +[17]: https://wiki.archlinux.org/index.php/systemd/User +[18]: https://github.com/clcollins/epaper-pi-ex/blob/main/piday.service diff --git a/published/202206/20210405 How different programming languages do the same thing.md b/published/202206/20210405 How different programming languages do the same thing.md new file mode 100644 index 0000000000..0d8a476397 --- /dev/null +++ b/published/202206/20210405 How different programming languages do the same thing.md @@ -0,0 +1,409 @@ +[#]: subject: "How different programming languages do the same thing" +[#]: via: "https://opensource.com/article/21/4/compare-programming-languages" +[#]: author: "Jim Hall https://opensource.com/users/jim-hall" +[#]: collector: "lujun9972" +[#]: translator: "VeryZZJ" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14687-1.html" + +不同编程语言是如何完成同一件事 +====== + +> 通过一个简单的小游戏比较 13 种编程语言。 + +![](https://img.linux.net.cn/data/attachment/album/202206/08/113845fs81srd5s8rjryt5.jpg) + +当我开始学习一种新的编程语言时,会把重点放在定义变量、书写声明以及计算表达式,一旦对这些概念有一个大致的了解,通常就能够自己弄清剩下的部分。大多数编程语言都具有相似性,所以如果你掌握了一种编程语言,学习下一种语言的重点就是弄清楚独有的概念以及区分不同。 + +我喜欢写一些测试程序来帮助练习新的编程语言。其中我经常写的是一个叫做“猜数字”的小游戏,计算机选出 1 到 100 里的任一数字,然后我来猜。程序循环进行,直到猜出正确数字。通过伪代码可以看出,这是个非常简单的程序: + +* 计算机在 1 到 100 之间选出一个随机数字 +* 循环进行直到猜出该随机数字 + + 计算机读取我的猜测 + + 告诉我我的猜测过高还是过低 + +我们发表了一些文章,用不同的语言写这个程序。这是一个比较不同语言做同样事情的有趣机会。大多数编程语言具有相似性,所以当你在学习下一种新的编程语言时,主要是学习它的独特之处。 + +C 语言由 Dennis Ritchie 于 1972 年在贝尔实验室创建,是一种早期的通用编程语言。C 语言非常受欢迎,并迅速成为 Unix 系统上的标准编程语言。正是因为它的流行,许多其他编程语言也采用了类似的编程语法。这就是为什么如果你已经知道如何使用 C 语言编程,学习 C++、Rust、Java、Groovy、JavaScript、awk 或 Lua 会更容易。 + +接下来我们看看这些不同的编程语言是如何实现 “猜数字” 游戏的主要步骤。我将把重点放在基本元素的相似或不同,跳过一些外围代码,如分配临时变量。 + +### 计算机在 1 到 100 之间选出一个随机数字 + +你可以看到这里有许多相似之处。大多数编程语言使用类似 `rand()` 的函数,你可以设定一个范围来生成随机数。而其他一些语言使用一个特殊的函数来设定范围生成随机数。 + +C: + +``` +// Using the Linux `getrandom` system call +getrandom(&randval, sizeof(int), GRND_NONBLOCK); +number = randval % maxval + 1; + +// Using the standard C library +number = rand() % 100 + 1; +``` + +C++: + +``` +int number = rand() % 100+1; +``` + +Rust: + +``` +let random = rng.gen_range(1..101); +``` + +Java: + +``` +private static final int NUMBER = r.nextInt(100) + 1; +``` + +Groovy: + +``` +int randomNumber = (new Random()).nextInt(100) + 1 +``` + +JavaScript: + +``` +const randomNumber = Math.floor(Math.random() * 100) + 1 +``` + +awk: + +``` +randomNumber = int(rand() * 100) + 1 +``` + +Lua: + +``` +number = math.random(1,100) +``` + +### 循环进行直到我猜出该随机数字 + +循环通常是用控制流程来实现的,如 `while` 或 `do-while`。JavaScript 中的实现没有使用循环,而是 “实时 ”更新 HTML 页面,直到用户猜出正确的数字。Awk 虽然支持循环,但是通过循环读取输入信息是没有意义的,因为 Awk 是基于数据管道的,所以它从文件而不是直接从用户读取输入信息。 + +C: + +``` +do { + … +} while (guess != number); +``` + +C++: + +``` +do { + … +} while ( number != guess ); +``` + +Rust: + +``` +for line in std::io::stdin().lock().lines() { + … + break; +} +``` + +Java: + +``` +while ( guess != NUMBER ) { + … +} +``` + +Groovy: + +``` +while ( … ) { + … + break; +} +``` + +Lua: + +``` +while ( player.guess ~= number ) do + … +end +``` + +### 计算机读取我的猜测 + +不同编程语言对输入的处理方式不同。例如,JavaScript 直接从 HTML 表单中读取数值,而 Awk 则从数据管道中读取数据。 + +C: + +``` +scanf("%d", &guess); +``` + +C++: + +``` +cin >> guess; +``` + +Rust: + +``` +let parsed = line.ok().as_deref().map(str::parse::); +if let Some(Ok(guess)) = parsed { + … +} +``` + +Java: + +``` +guess = player.nextInt(); +``` + +Groovy: + +``` +response = reader.readLine() +int guess = response as Integer +``` + +JavaScript: + +``` +let myGuess = guess.value +``` + +Awk: + +``` +guess = int($0) +``` + +Lua: + +``` +player.answer = io.read() +player.guess = tonumber(player.answer) +``` + +### 告诉我猜测过高还是过低 + +在这些类 C 语言中,通常是通过 `if` 语句进行比较的。每种编程语言打印输出的方式有一些变化,但打印语句在每个样本中都是可识别的。 + +C: + +``` +if (guess < number) { + puts("Too low"); +} +else if (guess > number) { + puts("Too high"); +} +… +puts("That's right!"); +``` + +C++: + +``` +if ( guess > number) { cout << "Too high.\n" << endl; } +else if ( guess < number ) { cout << "Too low.\n" << endl; } +else { + cout << "That's right!\n" << endl; + exit(0); +} +``` + +Rust: + +``` +_ if guess < random => println!("Too low"), +_ if guess > random => println!("Too high"), +_ => { + println!("That's right"); + break; +} +``` + +Java: + +``` +if ( guess > NUMBER ) { + System.out.println("Too high"); +} else if ( guess < NUMBER ) { + System.out.println("Too low"); +} else { + System.out.println("That's right!"); + System.exit(0); +} +``` + +Groovy: + +``` +if (guess < randomNumber) + print 'too low, try again: ' +else if (guess > randomNumber) + print 'too high, try again: ' +else { + println "that's right" + break +} +``` + +JavaScript: + +``` +if (myGuess === randomNumber) { + feedback.textContent = "You got it right!" +} else if (myGuess > randomNumber) { + feedback.textContent = "Your guess was " + myGuess + ". That's too high. Try Again!" +} else if (myGuess < randomNumber) { + feedback.textContent = "Your guess was " + myGuess + ". That's too low. Try Again!" +} +``` + +Awk: + +``` +if (guess < randomNumber) { + printf "too low, try again:" +} else if (guess > randomNumber) { + printf "too high, try again:" +} else { + printf "that's right\n" + exit +} +``` + +Lua: + +``` +if ( player.guess > number ) then + print("Too high") +elseif ( player.guess < number) then + print("Too low") +else + print("That's right!") + os.exit() +end +``` + +### 非类 C 编程语言会怎么样呢? + +非类 C 编程语言会有很大的不同,需要学习特定的语法来完成每一步。Racket 源于 Lisp 和 Scheme,所以它使用 Lisp 的前缀符和大量括号。Python 使用空格而不是括号来表示循环之类的块。Elixir 是一种函数式编程语言,有自己的语法。Bash 是基于 Unix 系统中的 Bourne shell,它本身借鉴了 Algol68,并支持额外的速记符,如 `&&` 作为 `and` 的变体。Fortran 是在使用打孔卡片输入代码的时期创建的,所以它依赖于一些重要列的 80 列布局。 + +我将通过比较 `if` 语句,举例表现这些编程语言的不同。`if` 判断一个值是否小于或大于另一个值,并向用户打印适当信息。 + +Racket: + +``` +(cond [(> number guess) (displayln "Too low") (inquire-user number)] + [(< number guess) (displayln "Too high") (inquire-user number)] + [else (displayln "Correct!")])) +``` + +Python: + +``` +if guess < random: + print("Too low") +elif guess > random: + print("Too high") +else: + print("That's right!") +``` + +Elixir: + +``` +cond do + guess < num -> + IO.puts "Too low!" + guess_loop(num) + guess > num -> + IO.puts "Too high!" + guess_loop(num) + true -> + IO.puts "That's right!" +end +``` + +Bash: + +``` +[ "0$guess" -lt $number ] && echo "Too low" +[ "0$guess" -gt $number ] && echo "Too high" +``` + +Fortran: + +``` +IF (GUESS.LT.NUMBER) THEN + PRINT *, 'TOO LOW' +ELSE IF (GUESS.GT.NUMBER) THEN + PRINT *, 'TOO HIGH' +ENDIF +``` + +### 更多 + +当你在学习一种新的编程语言时 “猜数字” 游戏是一个很友好的入门程序,通过一种简单的方式练习了几个常见的编程概念。通过不同编程语言实现这个简单游戏,你可以理解一些核心概念和每种语言的细节。 + +学习如何用 C 和类 C 语言编写 “猜数字” 游戏: + +* [C][2], Jim Hall +* [C++][3], Seth Kenlon +* [Rust][4], Moshe Zadka +* [Java][5], Seth Kenlon +* [Groovy][6], Chris Hermansen +* [JavaScript][7], Mandy Kendall +* [awk][8], Chris Hermansen +* [Lua][9], Seth Kenlon + +其他语言: + +* [Racket][10], Cristiano L. Fontana +* [Python][11], Moshe Zadka +* [Elixir][12], Moshe Zadka +* [Bash][13], Jim Hall +* [Fortran][14], Jim Hall + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/4/compare-programming-languages + +作者:[Jim Hall][a] +选题:[lujun9972][b] +译者:[VeryZZJ](https://github.com/VeryZZJ) +校对:[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/code_development_programming.png?itok=M_QDcgz5 "Developing code." +[2]: https://opensource.com/article/21/1/learn-c +[3]: https://opensource.com/article/20/12/learn-c-game +[4]: https://opensource.com/article/20/12/learn-rust +[5]: https://opensource.com/article/20/12/learn-java +[6]: https://opensource.com/article/20/12/groovy +[7]: https://opensource.com/article/21/1/learn-javascript +[8]: https://opensource.com/article/21/1/learn-awk +[9]: https://opensource.com/article/20/12/lua-guess-number-game +[10]: https://opensource.com/article/21/1/racket-guess-number +[11]: https://opensource.com/article/20/12/learn-python +[12]: https://opensource.com/article/20/12/elixir +[13]: https://opensource.com/article/20/12/learn-bash +[14]: https://opensource.com/article/21/1/fortran diff --git a/published/202206/20210503 Learn the Lisp programming language in 2021.md b/published/202206/20210503 Learn the Lisp programming language in 2021.md new file mode 100644 index 0000000000..fc5b4e6588 --- /dev/null +++ b/published/202206/20210503 Learn the Lisp programming language in 2021.md @@ -0,0 +1,295 @@ +[#]: subject: "Learn the Lisp programming language in 2021" +[#]: via: "https://opensource.com/article/21/5/learn-lisp" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14751-1.html" + +一起来学习 Lisp 编程语言吧! +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/24/124147v0loy4e3y0hneih8.jpg) + +> 许多大型代码库中都有 Lisp 代码的身影,因此,熟悉一下这门语言是一个明智之举。 + +早在 1958 年,Lisp 就被发明出来了,它是世界上第二古老的计算机编程语言(LCTT 译注:最古老的编程语言是 Fortran,诞生于 1957 年)。它有许多现代的衍生品,包括 Common Lisp、Emacs Lisp(Elisp)、Clojure、Racket、Scheme、Fennel 和 GNU Guile 等。 + +那些喜欢思考编程语言的设计的人,往往都喜欢 Lisp,因为它的语法和数据有着相同的结构:Lisp 代码实际上是一个列表的列表a list of lists,它的名字其实是 “列表处理LISt Processing” 的简写。而那些喜欢思考编程语言的美学的人,往往都讨厌 Lisp,因为它经常使用括号来定义范围;事实上,编程界也有一个广为流传的笑话:Lisp 代表的其实是 “大量烦人的多余括号”Lots of Irritating Superfluous Parentheses。 + +不管你是喜欢还是讨厌 Lisp 的设计哲学,你都不得不承认,它都是一门有趣的语言,过去如此,现在亦然(这得归功于现代方言 Clojure 和 Guile)。你可能会惊讶于在任何特定行业的大代码库中潜伏着多少 Lisp 代码,因此,现在开始学习 Lisp,至少熟悉一下它,不失为一个好主意。 + +### 安装 Lisp + +Lisp 有很多不同的实现。比较流行的开源版本有 [SBCL][2]、[GNU Lisp][3] 和 [GNU Common Lisp][4](GCL)。你可以使用发行版的包管理器安装它们中的任意一个,在本文中,我是用的是 `clisp`(LCTT 译注:也就是 GNU Lisp,一种 ANSI Common Lisp 的实现)。 + +以下是在不同的 Linux 发行版中安装 `clisp` 的步骤。 + +在 Fedora Linux 上,使用 `dnf`: + +``` +$ sudo dnf install clisp +``` + +在 Debian 上,使用 `apt`: + +``` +$ sudo apt install clisp +``` + +在 macOS 上,使用 [MacPorts][5] 或者 [Homebrew][6]: + +``` +# 使用 MacPorts +$ sudo port install clisp + +# 使用 Homebrew +$ brew install clisp +``` + +在 Windows 上,你可以使用 [clisp on Cygwin][7] 或者从 [gnu.org/software/gcl][8] 上下载 GCL 的二进制文件。 + +虽然我使用 `clisp` 命令来运行 Lisp 代码,但是本文中涉及到的大多数语法规则,对任何 Lisp 实现都是适用的。如果你选择使用一个不同的 Lisp 实现,除了用来运行 Lisp 代码的命令会和我不一样外(比如,你可能要用 `gcl` 或 `sbcl` 而不是 `clisp`),其它的所有东西都是相同的。 + +### 列表处理 + +Lisp 源代码的基本单元是 “表达式expression”,它在形式上是一个列表。举个例子,下面就是一个列表,它由一个操作符(`+`)和两个整数(`1` 和 `2`)组成: + +``` +(+ 1 2) +``` + +同时,它也是一个 Lisp 表达式,内容是一个符号(`+`,会被解析成一个加法函数)和它的两个参数(`1` 和 `2`)。你可以在 Common Lisp 的交互式环境(即 REPL)中运行该表达式和其它表达式。如果你熟悉 Python 的 IDLE,那么你应该会对 Lisp 的 REPL 感到亲切。(LCTT 译注:REPL 的全称是 “Read-Eval-Print Loop”,意思是 “‘读取-求值-输出’循环”,这个名字很好地描述了它的工作过程。) + +要进入到 REPL 中,只需运行 Common Lisp 即可: + +``` +$ clisp +[1]> +``` + +在 REPL 提示符中,尝试输入一些表达式: + +``` +[1]> (+ 1 2) +3 +[2]> (- 1 2) +-1 +[3]> (- 2 1) +1 +[4]> (+ 2 3 4) +9 +``` + +### 函数 + +在了解了 Lisp 表达式的基本结构后,你可以使用函数来做更多有用的事。譬如,`print` 函数可以接受任意数量的参数,然后把它们都显示在你的终端上,`pprint` 函数还可以实现格式化打印。还有更多不同的打印函数,不过,`pprint` 在 REPL 中的效果就挺好的: + +``` +[1]> (pprint "hello world") + +"hello world" + +[2]> +``` + +你可以使用 `defun` 函数来创建一个自定义函数。`defun` 函数需要你提供自定义函数的名称,以及它接受的参数列表: + +``` +[1]> (defun myprinter (s) (pprint s)) +MYPRINTER +[2]> (myprinter "hello world") + +"hello world" + +[3]> +``` + +### 变量 + +你可以使用 `setf` 函数来在 Lisp 中创建变量: + +``` +[1]> (setf foo "hello world") +"hello world" +[2]> (pprint foo) + +"hello world" + +[3]> +``` + +你可以在表达式里嵌套表达式(就像使用某种管道一样)。举个例子,你可以先使用 `string-upcase` 函数,把某个字符串的所有字符转换成大写,然后再使用 `pprint` 函数,将它的内容格式化打印到终端上: + +``` +[3]> (pprint (string-upcase foo)) + +"HELLO WORLD" + +[4]> +``` + +Lisp 是动态类型语言,这意味着,你在给变量赋值时不需要声明它的类型。Lisp 默认会把整数当作整数来处理: + +``` +[1]> (setf foo 2) +[2]> (setf bar 3) +[3]> (+ foo bar) +5 +``` + +如果你想让整数被当作字符串来处理,你可以给它加上引号: + +``` +[4]> (setf foo "2") +"2" +[5]> (setf bar "3") +"3" +[6]> (+ foo bar) + +*** - +: "2" is not a number +The following restarts are available: +USE-VALUE      :R1      Input a value to be used instead. +ABORT          :R2      Abort main loop +Break 1 [7]> +``` + +在这个示例 REPL 会话中,变量 `foo` 和 `bar` 都被赋值为加了引号的数字,因此,Lisp 会把它们当作字符串来处理。数学运算符不能够用在字符串上,因此 REPL 进入了调试器模式。想要跳出这个调试器,你需要按下 `Ctrl+D` 才行(LCTT 译注:就 `clisp` 而言,使用 `quit` 关键字也可以退出)。 + +你可以使用 `typep` 函数对一些对象进行类型检查,它可以测试对象是否为某个特定数据类型。返回值 `T` 和 `NIL` 分别代表 `True` 和 `False`。 + +``` +[4]> (typep foo 'string) +NIL +[5]> (typep foo 'integer) +T +``` + +`string` 和 `integer` 前面加上了一个单引号(`'`),这是为了防止 Lisp(错误地)把这两个单词当作是变量来求值: + +``` +[6]> (typep foo string) +*** - SYSTEM::READ-EVAL-PRINT: variable STRING has no value +[...] +``` + +这是一种保护某些术语(LCTT 译注:类似于字符串转义)的简便方法,正常情况下它是用 `quote` 函数来实现的: + +``` +[7]> (typep foo (quote string)) +NIL +[5]> (typep foo (quote integer)) +T +``` + +### 列表 + +不出人意料,你当然也可以在 Lisp 中创建列表: + +``` +[1]> (setf foo (list "hello" "world")) +("hello" "world") +``` + +你可以使用 `nth` 函数来索引列表: + +``` +[2]> (nth 0 foo) +"hello" +[3]> (pprint (string-capitalize (nth 1 foo))) + +"World" +``` + +### 退出 REPL + +要结束一个 REPL 会话,你需要按下键盘上的 `Ctrl+D`,或者是使用 Lisp 的 `quit` 关键字: + +``` +[99]> (quit) +$ +``` + +### 编写脚本 + +Lisp 可以被编译,也可以作为解释型的脚本语言来使用。在你刚开始学习的时候,后者很可能是最容易的方式,特别是当你已经熟悉 Python 或 [Shell 脚本][9] 时。 + +下面是一个用 Common Lisp 编写的简单的“掷骰子”脚本: + +``` +#!/usr/bin/clisp + +(defun roller (num)   +  (pprint (random (parse-integer (nth 0 num)))) +) + +(setf userput *args*) +(setf *random-state* (make-random-state t)) +(roller userput) +``` + +脚本的第一行注释(LCTT 译注:称之为“释伴shebang”)告诉了你的 POSIX 终端,该使用什么可执行文件来运行这个脚本。 + +`roller` 函数使用 `defun` 函数创建,它在内部使用 `random` 函数来打印一个伪随机数,这个伪随机数严格小于 `num` 列表中下标为 0 的元素。在脚本中,这个 `num` 列表还没有被创建,不过没关系,因为只有当脚本被调用时,函数才会执行。 + +接下来的那一行,我们把运行脚本时提供的任意参数,都赋值给一个叫做 `userput` 的变量。这个 `userput` 变量是一个列表,当它被传递给 `roller` 函数后,它就会变成参数 `num`。 + +脚本的倒数第二行产生了一个“随机种子”。这为 Lisp 提供了足够的随机性来生成一个几乎随机的数字。 + +最后一行调用了自定义的 `roller` 函数,并将 `userput` 列表作为唯一的参数传递给它。 + +将这个文件保存为 `dice.lisp`,并赋予它可执行权限: + +``` +$ chmod +x dice.lisp +``` + +最后,运行它,并给它提供一个数字,以作为它选择随机数的最大值: + +``` +$ ./dice.lisp 21 + +13 +$ ./dice.lisp 21 + +7 +$ ./dice.lisp 21 + +20 +``` + +看起来还不错! + +你或许注意到,你的模拟骰子有可能会是 0,并且永远达不到你提供给它的最大值参数。换句话说,对于一个 20 面的骰子,这个脚本永远投不出 20(除非你把 0 当作 20)。有一个简单的解决办法,它只需要用到在本文中介绍的知识,你能够想到吗? + +### 学习 Lisp + +无论你是想将 Lisp 作为个人脚本的实用语言,还是为了助力你的职业生涯,抑或是仅仅作为一个有趣的实验,你都可以去看看一年一度(LCTT 译注:应该是两年一度)的 [Lisp 游戏果酱Game Jam][11],从而收获一些特别有创意的用途(其中的大多数提交都是开源的,因此你可以查看代码以从中学习)。 + +Lisp 是一门有趣而独特的语言,它有着不断增长的开发者用户群、足够悠久的历史和新兴的方言,因此,它有能力让从事各个行业的程序员都满意。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/5/learn-lisp + +作者:[Seth Kenlon][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[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/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/OSDC_women_computing_4.png +[2]: http://sbcl.org +[3]: http://clisp.org +[4]: https://www.gnu.org/software/gcl/ +[5]: https://opensource.com/article/20/11/macports +[6]: https://opensource.com/article/20/6/homebrew-linux +[7]: https://cygwin.fandom.com/wiki/Clisp +[8]: http://mirror.lagoon.nc/gnu/gcl/binaries/stable +[9]: https://opensource.com/article/20/4/bash-programming-guide +[10]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains +[11]: https://itch.io/jam/spring-lisp-game-jam-2021 diff --git a/published/202206/20210531 Get started with Kubernetes using chaos engineering.md b/published/202206/20210531 Get started with Kubernetes using chaos engineering.md new file mode 100644 index 0000000000..2aaaaa83a7 --- /dev/null +++ b/published/202206/20210531 Get started with Kubernetes using chaos engineering.md @@ -0,0 +1,72 @@ +[#]: subject: (Get started with Kubernetes using chaos engineering) +[#]: via: (https://opensource.com/article/21/5/kubernetes-chaos) +[#]: author: (Jessica Cherry https://opensource.com/users/cherrybomb) +[#]: collector: (lujun9972) +[#]: translator: (Donkey-Hao) +[#]: reviewer: (turbokernel, wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14743-1.html) + +在 Kubernetes 中使用混沌工程 +====== + +> 在这篇文章中学习混沌工程的基础知识。 + +![](https://img.linux.net.cn/data/attachment/album/202206/22/110901xbb88ccb8lfcgcrl.jpg) + +混沌工程是由科学、规划以及实验组成的。它是一门在系统上进行实验的学科,用来建立系统在生产中承受混乱条件能力的信心。 + +首先,我会在文章导论部分解释混沌系统如何工作。 + +### 如何开始学习混沌系统呢? + +以我的经验,开始学习混沌系统的最好方式是触发一个此前生产中出现的事故来进行实验。使用过去的数据,制定一个计划,以相同的方式破坏你的系统,然后建立修复策略,并确认结果满足你预期。如果计划失败,你就有了一种新的实验方式,并朝着快速处理问题的新方式前进。 + +最重要的是,你可以随时记录所有内容,这意味着,随着时间的推移,整个系统将被完整记录下来,任何人都可以值守而无需太多加码,每个人都可以在周末好好休息。 + +### 你要在混沌工程中做什么? + +混沌系统实验运行背后有一些科学依据。我记录了其中一些步骤: + +1. **定义一个稳定状态:** 使用监控工具来搜集当系统没有问题或事故时,看起来功能正常的数据。 +2. **提出假设或使用先前的事故:** 现在你已经定义了一个稳定状态,请提出一个关于在事故或中断期间会发生(或发生过)的情况的假设。用这个假设来得出一系列将会发生的事故,以及如何解决问题的理论。然后你可以制定一个故意引发该问题的计划。 +3. **引发问题:** 用这个计划来破坏系统,并开始在真实环境中测试。收集破坏时的指标状态,按计划修复,并追踪提出解决方案所需时长。确保你把所有的东西都记录下来,以备将来发生故障时使用。 +4. **试图推翻你的假设:** 实验中最精彩的部分是尝试推翻你的思考或计划。你要创建一个不同的状态,看看你能走多远,并在系统中生成一个不同的稳定状态。 + +确保在你在另一个系统中生成的破坏因素前,建立一个处于稳定状态的控制系统。这将使你更容易在实验前、期间和之后发现各种稳定状态的差异。 + +### 混沌工程需要什么? + +这有一些初学混沌工程很好的工具: + +* 良好的文档编制方法 +* 一个捕捉你系统是否处于稳定状态的监控系统 + * Grafana + * Prometheus +* 混沌工程工具: + * Chaos mesh + * Litmus + * 之后的文章我会介绍更多 +* 一个假设 +* 一个计划 + +### 去搞破坏吧 + +现在你已经掌握了基础,是时候去安全的摧毁你的系统了。我计划每年制造四次混乱,然后努力实现每月一次的破坏。 + +混沌工程是一种很好的实践,也是推进你的内部文档保持最新的好方法。此外,随着时间的推移,新升级或应用程序部署将更加顺畅,你的日常生活管理将通过 Kubernetes 变得更加轻松。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/5/kubernetes-chaos + +作者:[Jessica Cherry][a] +选题:[lujun9972][b] +译者:[Donkey](https://github.com/Donkey-Hao) +校对:[turbokernel](https://github.com/turbokernel), [wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/cherrybomb +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brett-jordan-chaos-unsplash.jpg?itok=sApp5dVd (Scrabble letters spell out chaos for chaos engineering) diff --git a/published/202206/20210630 9 reasons I love to use the Qt Creator IDE.md b/published/202206/20210630 9 reasons I love to use the Qt Creator IDE.md new file mode 100644 index 0000000000..87e3231afc --- /dev/null +++ b/published/202206/20210630 9 reasons I love to use the Qt Creator IDE.md @@ -0,0 +1,186 @@ +[#]: subject: (9 reasons I love to use the Qt Creator IDE) +[#]: via: (https://opensource.com/article/21/6/qtcreator) +[#]: author: (Stephan Avenwedde https://opensource.com/users/hansic99) +[#]: collector: (lujun9972) +[#]: translator: (hadisi1993) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-14767-1.html) + +我爱用 Qt Creator IDE 的九个原因 +====== + +> Qt Creator 就是丰富的 Qt 库和程序员之间的粘合剂。 + +![](https://img.linux.net.cn/data/attachment/album/202206/27/192023otvmu77tl808lltl.jpg) + +Qt Creator 是 Qt 框架的默认集成开发环境(IDE),同时也是丰富的 Qt 库和用户之前的粘合剂。除了如智能代码补全、调试、项目管理等基础功能外,Qt Creator 还提供了很多让软件开发变得更简单的特性。 + +在这篇文章中,我会重点介绍一些我最喜欢的 [Qt Creator][2] 特性。 + +### 深色模式 + +当我使用一个新的应用时,我的第一个问题是:_它有深色模式吗?_ Qt Creator 的回答是:_你更喜欢哪一种深色模式呢?_ + +你可以在“选项Options”菜单中激活深色模式。在顶部的菜单栏中,点击“工具Tools”,选择“选项Options”,然后转到“环境Environment”部分。下面是你能选择的常用外观: + +![QT Creator 深色模式][3] + +### 定制外观 + +像每一个 Qt 应用一样,借助样式表,Qt Creator 的外观是高度可定制化的。下面,你可以按照我的做法给 Qt Creator一个想要的外观。 + +将下面这些内容写入 `mycustomstylesheet.css` 文件中: + +``` +QMenuBar { background-color: olive } +QMenuBar::item { background-color: olive } +QMenu { background-color : beige; color : black } +QLabel { color: green } +``` + +然后使用命令行开启 Qt Creator,将样式表作为参数传入: + +``` +qtcreator -stylesheet=mycustomstylesheet.css +``` + +IDE 现在看上去应该会变成这样: + +![QT Creator 定制样式表][5] + +在这份 [文档][6] 中可以查阅更多的样式表。 + +### 命令行参数 + +Qt Creator 可接受很多命令行选项。例如,如果想在启动时自动加载当前项目,那么你可以将它的路径传入: + +``` +qtcreator ~/MyProject/MyQtProject.pro +``` + +你甚至可以将默认应该打开的文件和行数作为参数传递。下面这个命令打开 `main.cpp` 20 行处: + +``` +qtcreator ~/MyProject/main.cpp:20 +``` + +在这份 [文档][7] 中可以查阅更多 Qt 特有的命令行选项。 + + +Qt Creator 和一般的 Qt 应用无二,所以,除了自己的命令行参数以外,它也接收 [QApplication][8] 和 [QGuiApplication][9] 的一般参数。 + +### 交叉编译 + +Qt Creator 允许你定义一些被称为“配套Kit”的工具链。 “配套” 定义了构建和运行应用所需要的二进制库和 SDK。 + +![QT Creator kits][10] + +这使得你通过两次点击,就在完全不同的工具链之间切换。 + +![在 Qt Creator 中切换配套][11] + +在这份 [手册][12] 中可以查阅更多关于配套的内容。 + +### 分析工具 + +Qt Creator 集成了一些最流行的性能分析工具,例如: + + * [Linux 性能分析器][13](需要特定的内核) + * [Valgrind][14] 内存分析器 + * [Clang-Tidy 和 Clazy][15],一种检查 C/C++ 的 静态分析器Linter + +![Qt Creator 分析工具][16] + +### 调试器 + +在调试方面,Qt Creator 为 GNU Debugger(GDB)配备了一个很好的界面。我喜欢它检查容器类型和创建条件断点的方式,很简单。 + +![Qt Creator 调试器][17] + +### FakeVim + +如果你喜欢 Vim,你可以在设置中开启 FakeVim,来像 Vim 一样控制 Qt Creator。点击“工具Tools”,选择“选项Options”。在 “FakeVim” 选项中,你可以找到许多开关来定制 FakeVim。除了编辑器的功能外,你可以将自己设置的功能和命令关联起来,定制 Vim 命令。 + +举个例子,你可以将“构建项目Build Project”的功能和 `build` 命令关联到一起: + +![Qt Creator中的FakeVim][18] + +回到编辑器中,当你按下冒号(`:`)并输入 `build`,Qt Creator 利用配置的工具链,开始进行构建: + +![Qt Creator中的FakeVim][19] + +你可以在这份 [文档][20] 中找到 FakeVim 的更多信息。 + +### 类检测器 + +当使用 C++ 开发时,点击 Qt Creator 右下角的按钮可打开右边的窗口。然后在窗口顶部拉下的菜单中选择“大纲Outline”。如果你在左侧窗体中有头文件打开,你可以很好地纵览定义的类和类型。如果你切换到源文件中(`*.cpp`),右侧窗体会列出所有定义的方法,双击其中一个,你可以跳转到这个方法: + +![Qt Creator 中的类列表][21] + +### 项目配置 + +Qt Creator 的项目建立在项目目录里的 `*.pro-file` 之上。你可以为你的项目在 `*.pro-file` 中添加定制的配置。我向 `*.pro-file` 中添加了 `my_special_config`,它向编译器的定义添加 `MY_SPECIAL_CONFIG`。 + +``` +QT -= gui + +CONFIG += c++11 console +CONFIG -= app_bundle + +CONFIG += my_special_config + +my_special_config { +DEFINES += MY_SPECIAL_CONFIG +} +``` + +Qt Creator 自动根据当前配置设置代码高亮: + +![Qt Creator 的特殊配置][22] + +`*.pro-file` 使用 [qmake 语言][23] 进行编写。 + +### 总结 + +这些特性仅仅是 Qt Creators 所提供的特性的冰山一角。初学者们应该不会感到被其众多的功能所淹没,Qt Creator 是一款对初学者很友好的 IDE。它甚至可能是入门 C++ 开发最简单的方式。如果要获得 QT Creator 特性的全面概述,请参考它的 [官方文档][24]。 + +*(插图来自 Stephan Avenwedde, [CC BY-SA 4.0][4])* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/qtcreator + +作者:[Stephan Avenwedde][a] +选题:[lujun9972][b] +译者:[hadisi1993](https://github.com/hadisi1993) +校对:[wxy](https://github.com/wxy) + +本文由 [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/lenovo-thinkpad-laptop-concentration-focus-windows-office.png?itok=-8E2ihcF (Woman using laptop concentrating) +[2]: https://www.qt.io/product/development-tools +[3]: https://opensource.com/sites/default/files/uploads/qt_creator_dark_mode.png ( QT Creator dark mode) +[4]: https://creativecommons.org/licenses/by-sa/4.0/ +[5]: https://opensource.com/sites/default/files/uploads/qt_creator_custom_stylesheet2.png (QT Creator custom stylesheet) +[6]: https://doc.qt.io/qt-5/stylesheet-reference.html +[7]: https://doc.qt.io/qtcreator/creator-cli.html +[8]: https://doc.qt.io/qt-5/qapplication.html#QApplication +[9]: https://doc.qt.io/qt-5/qguiapplication.html#supported-command-line-options +[10]: https://opensource.com/sites/default/files/uploads/qt_creator_cross_compiling.png (QT Creator kits) +[11]: https://opensource.com/sites/default/files/uploads/qt_creator_select_kits.png (Switching between Kits in Qt Creator) +[12]: https://doc.qt.io/qtcreator/creator-targets.html +[13]: https://doc.qt.io/qtcreator/creator-cpu-usage-analyzer.html +[14]: https://doc.qt.io/qtcreator/creator-valgrind-overview.html +[15]: https://doc.qt.io/qtcreator/creator-clang-tools.html +[16]: https://opensource.com/sites/default/files/uploads/qt_creator_analyzer.png (Qt Creator analyzer) +[17]: https://opensource.com/sites/default/files/uploads/qt_creator_debugger2.png (Qt Creator debugger) +[18]: https://opensource.com/sites/default/files/uploads/qt_creator_fakevim_ex_commands.png (FakeVim in Qt Creator) +[19]: https://opensource.com/sites/default/files/uploads/qt_creator_fakevim_build_commands.png (FakeVim in Qt Creator) +[20]: https://doc.qt.io/qtcreator/creator-editor-fakevim.html +[21]: https://opensource.com/sites/default/files/uploads/qtcreator_class_overview.png (List of classes in Qt Creator) +[22]: https://opensource.com/sites/default/files/uploads/qtcreater_special_config.png (Special configuration in Qt Creator) +[23]: https://doc.qt.io/qt-5/qmake-language.html +[24]: https://doc.qt.io/qtcreator/ diff --git a/published/202206/20210722 Write your first JavaScript code.md b/published/202206/20210722 Write your first JavaScript code.md new file mode 100644 index 0000000000..1cbb8f9f06 --- /dev/null +++ b/published/202206/20210722 Write your first JavaScript code.md @@ -0,0 +1,186 @@ +[#]: subject: "Write your first JavaScript code" +[#]: via: "https://opensource.com/article/21/7/javascript-cheat-sheet" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14740-1.html" + +编写你的第一段 JavaScript 代码 +====== + +> JavaScript 是为 Web 而生的,但它可以做的事远不止于此。本文将带领你了解它的基础知识,然后你可以下载我们的备忘清单,以便随时掌握详细信息。 + +![](https://img.linux.net.cn/data/attachment/album/202206/21/114718zzb8f6na6lgb28cn.jpg) + +JavaScript 是一种充满惊喜的编程语言。许多人第一次遇到 JavaScript 时,它通常是作为一种 Web 语言出现的。所有主流浏览器都有一个 JavaScript 引擎;并且,还有一些流行的框架,如 JQuery、Cash 和 Bootstrap 等,它们可以帮助简化网页设计;甚至还有用 JavaScript 编写的编程环境。它似乎在互联网上无处不在,但事实证明,它对于 [Electron][2] 等项目来说也是一种有用的语言。Electron 是一个构建跨平台桌面应用程序的开源工具包,它使用的语言就是 JavaScript。 + +JavaScript 语言的用途多到令人惊讶,它拥有各种各样的库,而不仅仅是用于制作网站。它的基础知识十分容易掌握,因此,它可以作为一个起点,助你跨出构建你想象中的东西的第一步。 + +### 安装 JavaScript + +随着你的 JavaScript 水平不断提高,你可能会发现自己需要高级的 JavaScript 库和运行时环境。不过,刚开始学习的时候,你是根本不需要安装 JavaScript 环境的。因为所有主流的 Web 浏览器都包含一个 JavaScript 引擎来运行代码。你可以使用自己喜欢的文本编辑器编写 JavaScript,将其加载到 Web 浏览器中,接着你就能看到代码的作用。 + +### 上手 JavaScript + +要编写你的第一个 JavaScript 代码,请打开你喜欢的文本编辑器,例如 [Atom][4] 或 [VSCode][5] 等。因为它是为 Web 开发的,所以 JavaScript 可以很好地与 HTML 配合使用。因此,我们先来尝试一些基本的 HTML: + +``` + +  +    JS +  +  +   

Nothing here.

+  + +``` + +保存这个文件,然后在 Web 浏览器中打开它。 + +![浏览器中显示的 HTML][6] + +要将 JavaScript 添加到这个简单的 HTML 页面,你可以创建一个 JavaScript 文件并在页面的 `` 中引用它,或者只需使用 ` + +  + +``` + +在浏览器中重新加载页面。 + +![在浏览器中显示带有 JavaScript 的 HTML][7] + +如你所见,`

` 标签仍然包含字符串 `"Nothing here"`,但是当它被渲染时,JavaScript 会改变它,使其包含 `"Hello world"`。是的,JavaScript 具有重建​​(或只是帮助构建)网页的能力。 + +这个简单脚本中的 JavaScript 做了两件事。首先,它创建一个名为 `myvariable` 的变量,并将字符串 `"Hello world!"` 放置其中。然后,它会在当前文档(浏览器呈现的网页)中搜索 ID 为 `example` 的所有 HTML 元素。当它找到 `example` 时,它使用了 `innerHTML` 函数将 HTML 元素的内容替换为 `myvariable` 的内容。(LCTT 译注:这里作者笔误了,`innerHTML` 是“属性”而非“函数”。) + +当然,我们也可以不用自定义变量。因为,使用动态创建的内容来填充 HTML 元素也是容易的。例如,你可以使用当前时间戳来填充它: + +``` + +  +    JS +  +  +   

Date and time appears here.

+ +    +    +  + +``` + +重新加载页面,你就可以看到在呈现页面时生成的时间戳。再重新加载几次,你可以观察到秒数会不断增加。 + +### JavaScript 语法 + +在编程中,语法syntax 指的是如何编写句子(或“行”)的规则。在 JavaScript 中,每行代码必须以分号(`;`)结尾,以便运行代码的 JavaScript 引擎知道何时停止阅读。(LCTT 译注:从实用角度看,此处的“必须”其实是不正确的,大多数 JS 引擎都支持不加分号。Vue.js 的作者尤雨溪认为“没有应该不应该,只有你自己喜欢不喜欢”,他同时表示,“Vue.js 的代码全部不带分号”。详情可以查看他在知乎上对于此问题的 [回答][10]。) + +单词(或 字符串strings)必须用引号(`"`)括起来,而数字(或 整数integers)则不用。 + +几乎所有其他东西都是 JavaScript 语言的约定,例如变量、数组、条件语句、对象、函数等等。 + +### 在 JavaScript 中创建变量 + +变量是数据的容器。你可以将变量视为一个盒子,你在其中放置数据,以便与程序的其他部分共享它。要在 JavaScript 中创建变量,你可以选用关键字 `let` 和 `var` 中的一个,请根据你打算如何使用变量来选择:`var` 关键字用于创建一个供整个程序使用的变量,而 `let` 只为特定目的创建变量,通常在函数或循环的内部使用。(LCTT 译注:还有 `const` 关键字,它用于创建一个常量。) + +JavaScript 内置的 `typeof` 函数可以帮助你识别变量包含的数据的类型。使用第一个示例,你可以修改显示文本,来显示 `myvariable` 包含的数据的类型: + +``` + +let myvariable = "Hello world!"; +document.getElementById("example").innerHTML = typeof(myvariable); + +``` + +接着,你就会发现 Web 浏览器中显示出 “string” 字样,因为该变量包含的数据是 `"Hello world!"`。在 `myvariable` 中存储不同类型的数据(例如整数),浏览器就会把不同的数据类型打印到示例网页上。尝试将 `myvariable` 的内容更改为你喜欢的数字,然后重新加载页面。 + +### 在 JavaScript 中创建函数 + +编程中的函数是独立的数据处理器。正是它们使编程得以 *模块化*。因为函数的存在,程序员可以编写通用库,例如​​,调整图像大小或统计时间花费的库,以供其他和你一样的程序员在他们的代码中使用。 + +要创建一个函数,你可以为函数提供一个自定义名称,后面跟着用大括号括起来的、任意数量的代码。 + +下面是一个简单的网页,其中包含了一个剪裁过的图像,还有一个分析图像并返回真实图像尺寸的按钮。在这个示例代码中,` +    +    +   
+      +   
+    +    +    +  + +``` + +保存这个文件,并将其加载到 Web 浏览器中以尝试这段代码。 + +![自定义的 get_size 函数返回了图像尺寸][8] + +### 使用 JavaScript 的跨平台应用程序 + +你可以从代码示例中看到,JavaScript 和 HTML 紧密协作,从而创建了有凝聚力的用户体验。这是 JavaScript 的一大优势。当你使用 JavaScript 编写代码时,你继承了现代计算中最常见的用户界面之一,而它与平台无关,那就是 Web 浏览器。你的代码本质上是跨平台的,因此你的应用程序,无论是简单的图像大小分析器还是复杂的图像编辑器、视频游戏,或者你梦想的任何其他东西,都可以被所有人使用,无论是通过 Web 浏览器,还是桌面(如果你同时提供了一个 Electron 应用)。 + +学习 JavaScript 既简单又有趣。网络上有很多网站提供了相关教程,还有超过一百万个 JavaScript 库可帮助你与设备、外围设备、物联网、服务器、文件系统等进行交互。在你学习的过程中,请将我们的 [JavaScript 备忘单][9] 放在身边,以便记住语法和结构的细节。 + +> **[JavaScript 备忘单][9]** + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/javascript-cheat-sheet + +作者:[Seth Kenlon][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[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/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/code2.png +[2]: https://www.electronjs.org/ +[3]: https://opensource.com/article/16/12/notepad-text-editor +[4]: https://opensource.com/article/20/12/atom +[5]: https://opensource.com/article/20/6/open-source-alternatives-vs-code +[6]: https://opensource.com/sites/default/files/pictures/plain-html.jpg +[7]: https://opensource.com/sites/default/files/uploads/html-javascript.jpg +[8]: https://opensource.com/sites/default/files/uploads/get-size.jpg +[9]: https://opensource.com/downloads/javascript-cheat-sheet +[10]: https://www.zhihu.com/question/20298345/answer/49551142 diff --git a/published/202206/20210724 How to Fix yay- error while loading shared libraries- libalpm.so.12.md b/published/202206/20210724 How to Fix yay- error while loading shared libraries- libalpm.so.12.md new file mode 100644 index 0000000000..befb210be1 --- /dev/null +++ b/published/202206/20210724 How to Fix yay- error while loading shared libraries- libalpm.so.12.md @@ -0,0 +1,68 @@ +[#]: subject: "How to Fix yay: error while loading shared libraries: libalpm.so.12" +[#]: via: "https://www.debugpoint.com/2021/07/yay-error-libalpm-so-12/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14683-1.html" + +如何修复 “yay: error while loading shared libraries: libalpm.so.12” +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/07/144052x9tpvo93zhthdh6x.jpg) + +> 这篇快速指南是为了帮助你修复 “yay error: while loading shared libraries: libalpm.so.12” 错误。 + +如果你在系统中运行 [Arch Linux][1] 的时间比较长,那么由于其滚动发布性质以及你的硬件支持,程序可能会损坏。 如果你使用 AUR 助手 Yay,那么有时,由于其他软件包的多次安装升级,Yay 可能会损坏。 + +Yay 助手一般是非常稳定的,但有时它会被搞乱,在修复好之前,你不能使用它安装任何程序。而其中一个令人头疼的错误是这样的: + +``` +yay: error while loading shared libraries: libalpm.so.12: cannot open shared object file: No such file or directory +``` + +这个错误特别是在升级到 pacman 6.0 后出现的,因为共享库不兼容。 + +![error while loading shared libraries - yay][2] + +### 如何解决 “yay: error while loading shared libraries: libalpm.so.12” + +这个错误只能通过完全卸载 `yay` 来解决,包括它的依赖。然后重新安装 `yay`。 + +没有其他方法来解决这个错误。 + +我们已经有一个 [如何安装 Yay][3] 的指南,然而,以下是修复的步骤。 + +从 AUR 克隆 yay 仓库并构建。在终端窗口中依次运行以下命令。 + +``` +cd /tmp +git clone 'https://aur.archlinux.org/yay.git' +cd /tmp/yay +makepkg -si +cd ~ +rm -rf /tmp/yay/ +``` + +安装完成后,你可以尝试运行给你带来这个错误的命令。然后就好了。如果你仍然有这个错误,请在下面的评论区告诉我。 + +很多人都遇到了这个问题,网络上有 [几个讨论][4]。以上是解决这个错误的唯一办法。而且我在任何地方都找不到这个问题的确切根源,除了它是在 pacman 6.0 更新后开始的。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2021/07/yay-error-libalpm-so-12/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://archlinux.org/ +[2]: https://www.debugpoint.com/wp-content/uploads/2021/07/error-while-loading-shared-libraries-yay.jpg +[3]: https://www.debugpoint.com/2021/01/install-yay-arch/ +[4]: https://github.com/Jguer/yay/issues/1519 diff --git a/published/202206/20210725 How to Recover Arch Linux Install via chroot.md b/published/202206/20210725 How to Recover Arch Linux Install via chroot.md new file mode 100644 index 0000000000..fdadf9e7be --- /dev/null +++ b/published/202206/20210725 How to Recover Arch Linux Install via chroot.md @@ -0,0 +1,117 @@ +[#]: subject: "How to Recover Arch Linux Install via chroot" +[#]: via: "https://www.debugpoint.com/2021/07/recover-arch-linux/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14708-1.html" + +如何通过 chroot 恢复 Arch Linux 系统 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/14/111204hm20rzjmmf5ib9nr.jpg) + +> 这个快速指南解释了恢复 Arch Linux 安装的一些方便步骤。 + +作为一个滚动发布的版本,[Arch Linux][1] 中有时会出现一些问题。不是因为你自己的行为,而是数以百计的其他原因,如新内核与你的硬件或软件的兼容性。但是,Arch Linux 仍然很棒,它提供了最新的软件包和应用。 + +但有时,它也会给你带来麻烦,你最终只能看到一个闪烁的光标,其他什么都没有。 + +所以,在这种情况下,与其重新格式化或重新安装,不如在放弃希望之前尝试恢复安装和数据。本指南概述了这个方向的一些步骤。 + +### 恢复 Arch Linux 安装 + +第一步是用 Arch Linux 创建一个可启动的现场Live USB。从 [这个链接][3] 下载 .ISO 并创建一个可启动的 USB。你可以查看这个 [如何使用 Etcher 创建可启动的 USB][2] 的指南。记住这一步需要另一个稳定的工作系统,因为你目前的系统不能使用。 + +你需要知道你的 Arch Linux 安装在哪个分区上。这是一个非常重要的步骤。如果你不知道,你可以用 GParted 来查找。或者在你的 GRUB 菜单中查看,或者你可以运行下面的命令来了解。这将列出你所有的磁盘分区及其大小、标签: + +``` +sudo lsblk -o name,mountpoint,label,size,uuid +``` + +完成后,插入 USB 盘并从它启动。你应该在现场介质中看到 Arch Linux 的提示符。 + +现在,用下面的方法挂载 Arch Linux 分区。记得把 `/dev/sda3` 改成你对应的分区。 + +``` +mount /dev/sda3 /mnt +arch-chroot /mnt +``` + +`arch-chroot` 命令将在终端挂载你的 Arch Linux 分区,所以用你的 Arch 凭证登录。现在,在这个阶段,根据你的需要,你有以下选择。 + +* 你可以通过 `/home` 文件夹来备份你的数据。如果,故障排除方式无效的话。你可以把文件复制到外部 USB 或其他分区。 +* 核查日志文件,特别是 pacman 日志。因为,不稳定的系统可能是由升级某些软件包引起的,如图形驱动或任何其他驱动。根据日志,如果你需要的话,可以降级任何特定的软件包。 + +你可以使用下面的命令来查看 pacman 日志文件的最后 200 行,以找出任何失败的项目或依赖性删除。 + +``` +tail -n 200 /var/log/pacman.log | less +``` + +上面的命令给出了你的 `pacman.log` 文件末尾的 200 行来验证。现在,仔细检查哪些软件包在你成功启动后被更新了。 + +并记下软件包的名称和版本。你可以尝试逐一降级软件包,或者如果你认为某个特定的软件包产生了问题。使用 `pacman -U` 开关来降级。 + +``` +pacman -U +``` + +如果有的话,你可以在降级后运行以下命令来启动你的 Arch 系统。 + +``` +exec /sbin/init +``` + +检查你的显示管理器的状态,是否有任何错误。有时,显示管理器会产生一个问题,无法与 X 服务器通信。例如,如果你正在使用 Lightdm,那么你可以通过以下方式检查它的状态。 + +``` +systemctl status lightdm +``` + +或者,可以通过下面的命令启动它,并检查出现了错误。 + +``` +lightdm --test-mode --debug +``` + +下面是一个 Lightdm 失败的例子,它导致了一个不稳定的 Arch 系统。 + +![lightdm - test mode][4] + +或者通过使用 `startx` 启动 X 服务器来检查。 + +``` +startx +``` + +根据我的经验,如果你在上述命令中看到错误,尝试安装另一个显示管理器并启用它,如 sddm。它可能会消除这个错误。 + +根据你的系统状态,尝试上述步骤,并进行故障排除。对于特定于显示管理器 lightdm 的错误,我们有一个 [指南][5],你可以看看。 + +如果你使用的是 sddm,那么请查看 [这些故障排除步骤][6]。 + +### 总结 + +每个安装环境都是不同的。上述步骤可能对你不起作用。但它值得一试,根据经验,它是有效的。如果它起作用,那么,对你来说是好事。无论哪种方式,请在下面的评论区中告诉我结果如何。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2021/07/recover-arch-linux/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://www.debugpoint.com/tag/arch-linux +[2]: https://www.debugpoint.com/2021/01/etcher-bootable-usb-linux/ +[3]: https://archlinux.org/download/ +[4]: https://www.debugpoint.com/wp-content/uploads/2021/03/lightdm-test-mode.jpg +[5]: https://www.debugpoint.com/2021/03/failed-to-start-lightdm/ +[6]: https://wiki.archlinux.org/title/SDDM#Troubleshooting diff --git a/published/202206/20210809 How to Enable Minimize, Maximize Window Buttons in elementary OS.md b/published/202206/20210809 How to Enable Minimize, Maximize Window Buttons in elementary OS.md new file mode 100644 index 0000000000..64d7a26557 --- /dev/null +++ b/published/202206/20210809 How to Enable Minimize, Maximize Window Buttons in elementary OS.md @@ -0,0 +1,91 @@ +[#]: subject: "How to Enable Minimize, Maximize Window Buttons in elementary OS" +[#]: via: "https://www.debugpoint.com/2021/08/enable-minimize-maximize-elementary/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14778-1.html" + +如何在 elementary OS 中启用最小化、最大化窗口按钮 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/30/141133zfwflwefqwyeffff.jpg) + +> 这是如何在 elementary OS 中启用最小化、最大化窗口按钮的方法。 + +许多人(大多数是 elementary OS 的新用户)在各种论坛上问这些问题: + +1. 我怎样才能在 elementary OS 中启用最小化按钮? +2. 我如何启用还原、最小化、最大化? +3. 有可能恢复最小化和最大化按钮吗? + +这些都是完全正常的问题,而且问问题也是可以的。对吧?这篇指南可以帮助他们在 elementary OS 中获得这些按钮。 + +Elementary OS 所使用的 Pantheon 桌面并没有默认的标准窗口按钮。其主要原因是通过 Dock 和应用菜单处理用户行为和活动的不同理念。可以说,这种设计或实现的行为模仿了macOS。 + +不过,许多用户更喜欢窗口按钮,因为这是一个所谓的“肌肉记忆”,而且有些人是从其他桌面环境(甚至是 Windows)迁移过来的。 + +尽管 Elementary 没有为你提供这个默认设置,你仍然可以启用它。下面是方法。 + +### 启用最小化最大化按钮 - elementary OS + +打开终端,安装添加 PPA 所需的 `software-properties-common` 软件包。默认情况下,这个包在 elementary OS 中没有安装(不要问我为什么,真的)。 + +``` +sudo apt install software-properties-common +``` + +#### elementary OS 6 Odin + +elementary Tweak 工具被重新换了个名字,它现在被称为 [Pantheon Tweaks][1],并正在单独开发中。使用以下命令,你可以安装它: + +``` +sudo add-apt-repository -y ppa:philip.scott/pantheon-tweaks +sudo apt install -y pantheon-tweaks +``` + +#### elementary OS 5 Juno 及更低版本 + +如果你使用的是 elementary OS 5 June 及更低版本,你可以使用相同的 PPA 安装早期的 [elementary-tweaks][2]。在终端按照以下命令进行操作: + +``` +sudo add-apt-repository -y ppa:philip.scott/elementary-tweaks +sudo apt install -y elementary-tweaks +``` + +#### 更改设置 + +* 安装后,点击顶部栏的“应用Application”,打开“系统设置System settings”。在系统设置窗口中,点击“个人Personal”下的 “Tweaks”。 +* 在 Tweaks 窗口中,进入“外观Appearance”。 +* 在窗口控制下,选择布局:“Windows”。 + + ![enable minimize maximize buttons elementary OS][3] + +* 然后在顶部窗口栏的右侧应该有最小化、最大化和关闭按钮了。 + +也有其他组合形式,如 Ubuntu、macOS 等。你可以选择任何你觉得合适的: + +![Other Options of Window buttons in elementary][4] + +这篇指南至此就结束了。系统设置中还有其他选项,你可以尝试使用,但窗口管理器 gala 最近删除了这些选项。因此,它们目前可能无法工作。 + +我希望这个指南能帮助你启用 elementary OS 的最小化最大化按钮。如果你需要任何帮助,请在下面的评论栏告诉我。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2021/08/enable-minimize-maximize-elementary/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://github.com/pantheon-tweaks/pantheon-tweaks +[2]: https://github.com/elementary-tweaks/elementary-tweaks +[3]: https://www.debugpoint.com/wp-content/uploads/2021/08/enable-minimize-maximize-buttons-elementary-OS.png +[4]: https://www.debugpoint.com/wp-content/uploads/2021/08/Other-Options-of-Window-buttons-in-elementary.jpg diff --git a/published/202206/20211102 Apache Kafka- Asynchronous Messaging for Seamless Systems.md b/published/202206/20211102 Apache Kafka- Asynchronous Messaging for Seamless Systems.md new file mode 100644 index 0000000000..3882caa3a3 --- /dev/null +++ b/published/202206/20211102 Apache Kafka- Asynchronous Messaging for Seamless Systems.md @@ -0,0 +1,303 @@ +[#]: subject: "Apache Kafka: Asynchronous Messaging for Seamless Systems" +[#]: via: "https://www.opensourceforu.com/2021/11/apache-kafka-asynchronous-messaging-for-seamless-systems/" +[#]: author: "Krishna Mohan Koyya https://www.opensourceforu.com/author/krishna-mohan-koyya/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14772-1.html" + +Apache Kafka:为“无缝系统”提供异步消息支持 +====== + +> Apache Kafka 是最流行的开源消息代理之一。它已经成为了大数据操作的重要组成部分,你能够在几乎所有的微服务环境中找到它。本文对 Apache Kafka 进行了简要介绍,并提供了一个案例来展示它的使用方式。 + +![](https://img.linux.net.cn/data/attachment/album/202206/29/094326fbo6zzsrxiava661.jpg) + +你有没有想过,电子商务平台是如何在处理巨大的流量时,做到不会卡顿的呢?有没有想过,OTT 平台是如何在同时向数百万用户交付内容时,做到平稳运行的呢?其实,关键就在于它们的分布式架构。 + +采用分布式架构设计的系统由多个功能组件组成。这些功能组件通常分布在多个机器上,它们通过网络,异步地交换消息,从而实现相互协作。正是由于异步消息的存在,组件之间才能实现可伸缩、无阻塞的通信,整个系统才能够平稳运行。 + +### 异步消息 + +异步消息的常见特性有: + +* 消息的生产者producer消费者consumer都不知道彼此的存在。它们在不知道对方的情况下,加入和离开系统。 +* 消息代理broker充当了生产者和消费者之间的中介。 +* 生产者把每条消息,都与一个“主题topic”相关联。主题是一个简单的字符串。 +* 生产者可以在多个主题上发送消息,不同的生产者也可以在同一主题上发送消息。 +* 消费者向代理订阅一个或多个主题的消息。 +* 生产者只将消息发送给代理,而不发送给消费者。 +* 代理会把消息发送给订阅该主题的所有消费者。 +* 代理将消息传递给针对该主题注册的所有消费者。 +* 生产者并不期望得到消费者的任何回应。换句话说,生产者和消费者不会相互阻塞。 + +市场上的消息代理有很多,而 Apache Kafka 是其中最受欢迎的之一。 + +### Apache Kafka + +Apache Kafka 是一个支持流式处理的、开源的分布式消息系统,它由 Apache 软件基金会开发。在架构上,它是多个代理组成的集群,这些代理间通过 Apache ZooKeeper 服务来协调。在接收、持久化和发送消息时,这些代理分担集群上的负载。 + +#### 分区 + +Kafka 将消息写入称为“分区partition”的桶中。一个特定分区只保存一个主题上的消息。例如,Kafka 会把 `heartbeats` 主题上的消息写入名为 `heartbeats-0` 的分区(假设它是个单分区主题),这个过程和生产者无关。 + +![图 1:异步消息][2] + +不过,为了利用 Kafka 集群所提供的并行处理能力,管理员通常会为指定主题创建多个分区。举个例子,假设管理员为 `heartbeats` 主题创建了三个分区,Kafka 会将它们分别命名为 `heartbeats-0`、`heartbeats-1` 和 `heartbeats-2`。Kafka 会以某种方式,把消息分配到这三个分区中,并使它们均匀分布。 + +还有另一种可能的情况,生产者将每条消息与一个消息键key相关联。例如,同样都是在 `heartbeats` 主题上发送消息,有个组件使用 `C1` 作为消息键,另一个则使用 `C2`。在这种情况下,Kafka 会确保,在一个主题中,带有相同消息键的消息,总是会被写入到同一个分区。不过,在一个分区中,消息的消息键却不一定相同。下面的图 2 显示了消息在不同分区中的一种可能分布。 + +![图 2:消息在不同分区中的分布][3] + +#### 领导者和同步副本 + +Kafka 在(由多个代理组成的)集群中维护了多个分区。其中,负责维护分区的那个代理被称为“领导者leader”。只有领导者能够在它的分区上接收和发送消息。 + +可是,万一分区的领导者发生故障了,又该怎么办呢?为了确保业务连续性,每个领导者(代理)都会把它的分区复制到其他代理上。此时,这些其他代理就称为该分区的同步副本in-sync-replicas(ISR)。一旦分区的领导者发生故障,ZooKeeper 就会发起一次选举,把选中的那个同步副本任命为新的领导者。此后,这个新的领导者将承担该分区的消息接受和发送任务。管理员可以指定分区需要维护的同步副本的大小。 + +![图 3:生产者命令行工具][4] + +#### 消息持久化 + +代理会将每个分区都映射到一个指定的磁盘文件,从而实现持久化。默认情况下,消息会在磁盘上保留一个星期。当消息写入分区后,它们的内容和顺序就不能更改了。管理员可以配置一些策略,如消息的保留时长、压缩算法等。 + +![图 4:消费者命令行工具][5] + +#### 消费消息 + +与大多数其他消息系统不同,Kafka 不会主动将消息发送给消费者。相反,消费者应该监听主题,并主动读取消息。一个消费者可以从某个主题的多个分区中读取消息。多个消费者也可以读取来自同一个分区的消息。Kafka 保证了同一条消息不会被同一个消费者重复读取。 + +Kafka 中的每个消费者都有一个组 ID。那些组 ID 相同的消费者们共同组成了一个消费者组。通常,为了从 N 个主题分区读取消息,管理员会创建一个包含 N 个消费者的消费者组。这样一来,组内的每个消费者都可以从它的指定分区中读取消息。如果组内的消费者比可用分区还要多,那么多出来的消费者就会处于闲置状态。 + +在任何情况下,Kafka 都保证:不管组内有多少个消费者,同一条消息只会被该消费者组读取一次。这个架构提供了一致性、高性能、高可扩展性、准实时交付和消息持久性,以及零消息丢失。 + +### 安装、运行 Kafka + +尽管在理论上,Kafka 集群可以由任意数量的代理组成,但在生产环境中,大多数集群通常由三个或五个代理组成。 + +在这里,我们将搭建一个单代理集群,对于生产环境来说,它已经够用了。 + +在浏览器中访问 [https://kafka.apache.org/downloads][5a],下载 Kafka 的最新版本。在 Linux 终端中,我们也可以使用下面的命令来下载它: + +``` +wget https://www.apache.org/dyn/closer.cgi?path=/kafka/2.8.0/kafka_2.12-2.8.0.tgz +``` + +如果需要的话,我们也可以把下载来的档案文件 `kafka_2.12-2.8.0.tgz` 移动到另一个目录下。解压这个档案,你会得到一个名为 `kafka_2.12-2.8.0` 的目录,它就是之后我们要设置的 `KAFKA_HOME`。 + +打开 `KAFKA_HOME/config` 目录下的 `server.properties` 文件,取消注释下面这一行配置: + +``` +listeners=PLAINTEXT://:9092 +``` + +这行配置的作用是让 Kafka 在本机的 `9092` 端口接收普通文本消息。我们也可以配置 Kafka 通过安全通道secure channel接收消息,在生产环境中,我们也推荐这么做。 + +无论集群中有多少个代理,Kafka 都需要 ZooKeeper 来管理和协调它们。即使是单代理集群,也是如此。Kafka 在安装时,会附带安装 ZooKeeper,因此,我们可以在 `KAFKA_HOME` 目录下,在命令行中使用下面的命令来启动它: + +``` +./bin/zookeeper-server-start.sh ./config/zookeeper.properties +``` + +当 ZooKeeper 运行起来后,我们就可以在另一个终端中启动 Kafka 了,命令如下: + +``` +./bin/kafka-server-start.sh ./config/server.properties +``` + +到这里,一个单代理的 Kafka 集群就运行起来了。 + +### 验证 Kafka + +让我们在 `topic-1` 主题上尝试下发送和接收消息吧!我们可以使用下面的命令,在创建主题时为它指定分区的个数: + +``` +./bin/kafka-topics.sh --create --topic topic-1 --zookeeper localhost:2181 --partitions 3 --replication-factor 1 +``` + +上述命令还同时指定了复制因子replication factor,它的值不能大于集群中代理的数量。我们使用的是单代理集群,因此,复制因子只能设置为 1。 + +当主题创建完成后,生产者和消费者就可以在上面交换消息了。Kafka 的发行版内附带了生产者和消费者的命令行工具,供测试时用。 + +打开第三个终端,运行下面的命令,启动生产者: + +``` +./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic topic-1 +``` + +上述命令显示了一个提示符,我们可以在后面输入简单文本消息。由于我们指定的命令选项,生产者会把 `topic-1` 上的消息,发送到运行在本机的 9092 端口的 Kafka 中。 + +打开第四个终端,运行下面的命令,启动消费者: + +``` +./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic topic-1 –-from-beginning +``` + +上述命令启动了一个消费者,并指定它连接到本机 9092 端口的 Kafka。它订阅了 `topic-1` 主题,以读取其中的消息。由于命令行的最后一个选项,这个消费者会从最开头的位置,开始读取该主题的所有消息。 + +我们注意到,生产者和消费者连接的是同一个代理,访问的是同一个主题,因此,消费者在收到消息后会把消息打印到终端上。 + +下面,让我们在实际应用场景中,尝试使用 Kafka 吧! + +### 案例 + +假设有一家叫做 ABC 的公共汽车运输公司,它拥有一支客运车队,往返于全国不同城市之间。由于 ABC 希望实时跟踪每辆客车,以提高其运营质量,因此,它提出了一个基于 Apache Kafka 的解决方案。 + +首先,ABC 公司为所有公交车都配备了位置追踪设备。然后,它使用 Kafka 建立了一个操作中心,以接收来自数百辆客车的位置更新。它还开发了一个仪表盘dashboard,以显示任一时间点所有客车的当前位置。图 5 展示了上述架构: + +![图 5:基于 Kafka 的架构][6] + +在这种架构下,客车上的设备扮演了消息生产者的角色。它们会周期性地把当前位置发送到 Kafka 的 `abc-bus-location` 主题上。ABC 公司选择以客车的行程编号trip code作为消息键,以处理来自不同客车的消息。例如,对于从 Bengaluru 到 Hubballi 的客车,它的行程编号就会是 `BLRHL003`,那么在这段旅程中,对于所有来自该客车的消息,它们的消息键都会是 `BLRHL003`。 + +仪表盘应用扮演了消息消费者的角色。它在代理上注册了同一个主题 `abc-bus-location`。如此,这个主题就成为了生产者(客车)和消费者(仪表盘)之间的虚拟通道。 + +客车上的设备不会期待得到来自仪表盘应用的任何回复。事实上,它们相互之间都不知道对方的存在。得益于这种架构,数百辆客车和操作中心之间实现了非阻塞通信。 + +#### 实现 + +假设 ABC 公司想要创建三个分区来维护位置更新。由于我们的开发环境只有一个代理,因此复制因子应设置为 1。 + +相应地,以下命令创建了符合需求的主题: + +``` +./bin/kafka-topics.sh --create --topic abc-bus-location --zookeeper localhost:2181 --partitions 3 --replication-factor 1 +``` + +生产者和消费者应用可以用多种语言编写,如 Java、Scala、Python 和 JavaScript 等。下面几节中的代码展示了它们在 Java 中的编写方式,好让我们有一个初步了解。 + +##### Java 生产者 + +下面的 `Fleet` 类模拟了在 ABC 公司的 6 辆客车上运行的 Kafka 生产者应用。它会把位置更新发送到指定代理的 `abc-bus-location` 主题上。请注意,简单起见,主题名称、消息键、消息内容和代理地址等,都在代码里硬编码的。 + +``` +public class Fleet { + public static void main(String[] args) throws Exception { + String broker = “localhost:9092”; + Properties props = new Properties(); + props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, broker); + props.setProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, + StringSerializer.class.getName()); + props.setProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, + StringSerializer.class.getName()); + + Producer producer = new KafkaProducer(props); + String topic = “abc-bus-location”; + Map locations = new HashMap<>(); + locations.put(“BLRHBL001”, “13.071362, 77.461906”); + locations.put(“BLRHBL002”, “14.399654, 76.045834”); + locations.put(“BLRHBL003”, “15.183959, 75.137622”); + locations.put(“BLRHBL004”, “13.659576, 76.944675”); + locations.put(“BLRHBL005”, “12.981337, 77.596181”); + locations.put(“BLRHBL006”, “13.024843, 77.546983”); + + IntStream.range(0, 10).forEach(i -> { + for (String trip : locations.keySet()) { + ProducerRecord record + = new ProducerRecord( + topic, trip, locations.get(trip)); + producer.send(record); + } + }); + producer.flush(); + producer.close(); + } +} +``` + +##### Java 消费者 + +下面的 `Dashboard` 类实现了一个 Kafka 消费者应用,运行在 ABC 公司的操作中心。它会监听 `abc-bus-location` 主题,并且它的消费者组 ID 是 `abc-dashboard`。当收到消息后,它会立即显示来自客车的详细位置信息。我们本该配置这些详细位置信息,但简单起见,它们也是在代码里硬编码的: + +``` +public static void main(String[] args) { + String broker = “127.0.0.1:9092”; + String groupId = “abc-dashboard”; + Properties props = new Properties(); + props.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, broker); + props.setProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, + StringDeserializer.class.getName()); + props.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, + StringDeserializer.class.getName()); + props.setProperty(ConsumerConfig.GROUP_ID_CONFIG, groupId); + + @SuppressWarnings(“resource”) + Consumer consumer = new KafkaConsumer(props); + consumer.subscribe(Arrays.asList(“abc-bus-location”)); + while (true) { + ConsumerRecords records + = consumer.poll(Duration.ofMillis(1000)); + + for (ConsumerRecord record : records) { + String topic = record.topic(); + int partition = record.partition(); + String key = record.key(); + String value = record.value(); + System.out.println(String.format( + “Topic=%s, Partition=%d, Key=%s, Value=%s”, + topic, partition, key, value)); + } + } +} +``` + +##### 依赖 + +为了编译和运行这些代码,我们需要 JDK 8 及以上版本。看到下面的 `pom.xml` 文件中的 Maven 依赖了吗?它们会把所需的 Kafka 客户端库下载并添加到类路径中: + +``` + + org.apache.kafka + kafka-clients + 2.8.0 + + + org.slf4j + slf4j-simple + 1.7.25 + +``` + +#### 部署 + +由于 `abc-bus-location` 主题在创建时指定了 3 个分区,我们自然就会想要运行 3 个消费者,来让读取位置更新的过程更快一些。为此,我们需要同时在 3 个不同的终端中运行仪表盘。因为所有这 3 个仪表盘都注册在同一个组 ID 下,它们自然就构成了一个消费者组。Kafka 会为每个仪表盘都分配一个特定的分区(来消费)。 + +当所有仪表盘实例都运行起来后,在另一个终端中启动 `Fleet` 类。图 6、7、8 展示了仪表盘终端中的控制台示例输出。 + +![图 6:仪表盘终端之一][7] + +仔细看看控制台消息,我们会发现第一个、第二个和第三个终端中的消费者,正在分别从 `partition-2`、`partition-1` 和 `partition-0` 中读取消息。另外,我们还能发现,消息键为 `BLRHBL002`、`BLRHBL004` 和 `BLRHBL006` 的消息写入了 `partition-2`,消息键为 `BLRHBL005` 的消息写入了 `partition-1`,剩下的消息写入了 `partition-0`。 + +![图 7:仪表盘终端之二][8] + +使用 Kafka 的好处在于,只要集群设计得当,它就可以水平扩展,从而支持大量客车和数百万条消息。 + +![图 8:仪表盘终端之三][9] + +### 不止是消息 + +根据 Kafka 官网上的数据,在《财富》100 强企业中,超过 80% 都在使用 Kafka。它部署在许多垂直行业,如金融服务、娱乐等。虽然 Kafka 起初只是一种简单的消息服务,但它已凭借行业级的流处理能力,成为了大数据生态系统的一环。对于那些喜欢托管解决方案的企业,Confluent 提供了基于云的 Kafka 服务,只需支付订阅费即可。(LCTT 译注:Confluent 是一个基于 Kafka 的商业公司,它提供的 Confluent Kafka 在 Apache Kafka 的基础上,增加了许多企业级特性,被认为是“更完整的 Kafka”。) + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2021/11/apache-kafka-asynchronous-messaging-for-seamless-systems/ + +作者:[Krishna Mohan Koyya][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/krishna-mohan-koyya/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2021/09/Digital-backgrund-connecting-in-globe.jpg +[2]: https://www.opensourceforu.com/wp-content/uploads/2021/09/Figure-1-Asynchronous-messaging.jpg +[3]: https://www.opensourceforu.com/wp-content/uploads/2021/09/Figure-2-Message-distribution-among-the-partitions.jpg +[4]: https://www.opensourceforu.com/wp-content/uploads/2021/09/Figure-3-Command-line-producer.jpg +[5]: https://www.opensourceforu.com/wp-content/uploads/2021/09/Figure-4-Command-line-consumer.jpg +[5a]: https://kafka.apache.org/downloads +[6]: https://www.opensourceforu.com/wp-content/uploads/2021/09/Figure-5-Kafka-based-architecture.jpg +[7]: https://www.opensourceforu.com/wp-content/uploads/2021/09/Figure-6-Dashboard-Terminal-1.jpg +[8]: https://www.opensourceforu.com/wp-content/uploads/2021/09/Figure-7-Dashboard-Terminal-2.jpg +[9]: https://www.opensourceforu.com/wp-content/uploads/2021/09/Figure-8-Dashboard-Terminal-3.jpg diff --git a/published/202206/20220510 6 easy ways to make your first open source contribution with LibreOffice.md b/published/202206/20220510 6 easy ways to make your first open source contribution with LibreOffice.md new file mode 100644 index 0000000000..de5efae413 --- /dev/null +++ b/published/202206/20220510 6 easy ways to make your first open source contribution with LibreOffice.md @@ -0,0 +1,58 @@ +[#]: subject: "6 easy ways to make your first open source contribution with LibreOffice" +[#]: via: "https://opensource.com/article/22/5/first-open-source-contribution-libreoffice" +[#]: author: "Klaatu https://opensource.com/users/klaatu" +[#]: collector: "lkxed" +[#]: translator: "lkskjjk" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14719-1.html" + +使用 LibreOffice 进行首次开源贡献的 6 种简单方法 +====== + +> 2022 年 5 月是 LibreOffice 月。这里有一些简单的方法来完成你的第一个开源贡献。 + +![](https://img.linux.net.cn/data/attachment/album/202206/16/230450d6u6u9hb1q9wx69c.jpg) + +“参与”开源似乎有点令人困惑。你从哪里开始?如果你不会编程怎么办?你取得谁的同意?别人怎么知道你做出了贡献,会有人关心吗? + +这类问题实际上有答案(你自己选择就行;没关系;不用谁的同意;你告诉他们;是的),但在 2022 年 5 月,有一个简单的答案:LibreOffice。5 月是参与 LibreOffice 及其管理机构 文档基金会The Document Foundation 的月份。他们正在邀请各种各样的贡献者以六种不同的方式提供帮助,其中只有一种与代码有任何关系。无论你的技能如何,你都可以找到一种方法来帮助这个世界上最好的办公套件。 + +### 为 LibreOffice 做出贡献的 6 种方式 + +以下是你可以做的: + +* Handy Helper:在 [Ask LibreOffice][3] 上回答其他 LibreOffice 用户的问题。如果你是 LibreOffice 的狂热用户,并且认为你有可以帮助他人的有用提示和技巧,那么这就是你一直在等待的角色。 +* First Responder:当错误报告得到不止一个用户确认时会更好。如果你擅长安装软件(有时错误报告是针对比你通常使用的版本更旧的版本),那么请访问 [LibreOffice Bugzilla][4] 并查找尚未确认的新错误。当你找到时,试着复制所报告的内容。假设你可以做到这一点,请添加一条评论,例如 “CONFIRMED on Linux (Fedora 35) and LibreOffice 7.3.2”。 +* Drum Beater:开源项目很少有大公司投入营销资金来推广它们。如果所有声称喜欢开源的公司都能提供帮助,那就太好了,但不是所有的公司都这样做,那么为什么不发出你的声音呢?在社交媒体上告诉你的朋友你为什么喜欢 LibreOffice,或者你用它做什么(当然还要加上#libreoffice 标签。) +* Globetrotter:LibreOffice 已经支持多种不同的语言,但并不是所有语言。 LibreOffice 正在积极开发中,因此它的界面翻译需要保持最新。[在这里参与][5]。 +* Docs Doctor:LibreOffice 有在线帮助和用户手册。如果你擅长向其他人解释事情,或者如果你擅长校对其他人的文档,那么你应该联系 [文档团队][6]。 +* Code Cruncher:你可能不会立即深入了解 LibreOffice 的代码库并进行重大更改,但这通常不是项目所需要的。如果你知道如何编码,那么你可以[按照此 wiki 页面上的说明][8]加入[开发人员社区][7]。 + +### 免费贴纸 + +我不想提前提到这一点,因为很明显你参与 LibreOffice 只是因为你喜欢参与一个优秀的开源项目。但是,你最终会发现,所以我不妨告诉你:通过为 LibreOffice 做出贡献,你可以注册然后从文档基金会获得免费贴纸。你肯定一直想 [装饰你的笔记本电脑吧][2]? + +不过,不要被战利品的承诺分心。如果你对参与开源感到困惑但很兴奋,那么这是一个很好的机会。它代表了你参与开源的一般方式:寻找需要做的事情,去做它,然后你和其他人讨论它,这样你就可以获得下一步可以做什么的想法。经常这样做,你就会找到进入社区的方式。最终,你不会再纠结于如何参与开源,因为你已经忙于贡献! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/5/first-open-source-contribution-libreoffice + +作者:[Klaatu][a] +选题:[lkxed][b] +译者:[lkskjjk](https://github.com/lkskjjk) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/klaatu +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/dandelion_zoom.jpg +[2]: https://opensource.com/business/15/11/open-source-stickers +[3]: http://ask.libreoffice.org/ +[4]: https://bugs.documentfoundation.org/buglist.cgi?bug_status=__open__&content=&no_redirect=1&order=changeddate%20DESC%2Cpriority%2Cbug_severity&product=&query_based_on=&query_format=specific +[5]: https://www.libreoffice.org/community/localization/ +[6]: https://www.libreoffice.org/community/docs-team +[7]: https://www.libreoffice.org/community/developers/ +[8]: https://wiki.documentfoundation.org/Development/GetInvolved diff --git a/published/202206/20220514 Hidden Features! 25 Fun Things You Can Do With DuckDuckGo Search Engine.md b/published/202206/20220514 Hidden Features! 25 Fun Things You Can Do With DuckDuckGo Search Engine.md new file mode 100644 index 0000000000..af80f8bfac --- /dev/null +++ b/published/202206/20220514 Hidden Features! 25 Fun Things You Can Do With DuckDuckGo Search Engine.md @@ -0,0 +1,236 @@ +[#]: subject: "Hidden Features! 25 Fun Things You Can Do With DuckDuckGo Search Engine" +[#]: via: "https://itsfoss.com/duckduckgo-easter-eggs/" +[#]: author: "sreenath https://itsfoss.com/author/sreenath/" +[#]: collector: "lkxed" +[#]: translator: "TravinDreek" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14696-1.html" + +隐藏功能!在 DuckDuckGo 搜索引擎中,你可以做这 25 件有趣的事情 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/11/142806ebr5xtzgcwcr5955.jpg) + +比起无处不在的 Google,[有些搜索引擎替代品更加尊重隐私][1],而 DuckDuckGo 就是其中之一。 + +最近,这个搜索引擎有了很大的改进,搜索一般网页十分顺畅。在搜索本地地点方面,则还远不及 Google。 + +不过,DuckDuckGo(简称为 DDG)有一些很酷的功能,大部分用户还没注意到。如果你是一位 DDG 狂热粉,你可能会喜欢用这些小技巧来提升你的搜索体验。 + +### 1、跳转到特定网页 + +在你最喜欢的网站名称前输入 `!` 即可直接进入这个网站。则类似于 Google 的 “运气不错” 功能,但用 DDG 的话来说,这就叫 “叹号搜索”。 + +有一些网站有缩写形式,开始输入时便会提示。 + +![duckduckgo bang feature][2] + +在网站名后面输入搜索词,就可以直接抵达那个网站的搜索结果处。 + +### 2、文本转 ASCII + +Figlet 是一个 [有趣的 Linux 命令][3],可以将任意文本转换为漂亮的 ASCII 画格式。 + +在任意搜索词前输入 `figlet`,就会显示 ASCII 输出。无需打开终端。 + +![Figlet in DDG][4] + +### 3、检查社交媒体的状态 + +在某个人的 Twitter 名前加上 `@`,就会显示 TA 的状态(关注者等)。 + +![Itsfoss Twitter][5] + +### 4、生成强密码 + +输入 `password` 并加上需要的字符数,就可以生成一个独特的强密码。 + +![Generating password in DuckDuckGo][6] + +### 5、生成随机密码短语 + +输入 `random passphrase` 可生成一段密码短语,通常长度为 4 个词。 + +![Random Passphrase][7] + +### 6、获取一份速查表 + +在需要看速查表的搜索词后面,可输入 `cheatsheet`。如果要搜索的东西有速查表,就会立即显示在搜索页面。 + +![Vim Cheatsheet][8] + +### 7、通过色码获取颜色 + +输入 `color` 并加上你想查的颜色的十六进制码,便可显示这个颜色。 + +![Color][9] + +### 8、生成随机数 + +搜索 `random number` 会输出一个 0 到 1 之间的随机数。 + +![Random Number][10] + +你也可以指定需要的范围。 + +![Random Number between 1 and 1000][11] + +### 9、转换为二进制等形式 + +输入一个二进制数并加上 `binary`,可将其从二进制转换为十进制。 + +![Binary to Decimal][12] + +类似地,它也能用于十六进制和八进制,但我不清楚它们的处理逻辑。 + +### 10、寻找韵词 + +输入 `what rhymes with` 并带上要找同韵词的词语。作诗能力变强了,对吧? + +![What rhymes with rain][13] + +### 11、获取拉马努金数、圆周率等常数 + +输入想获取数值的常数名,便可在搜索结果中看到它。 + +![Ramanujan Number][14] + +### 12、查询现在谁在太空中 + +输入 `people in space` 获取当前在太空中的人员名单。同时还会显示他们在太空中居住的时间。 + +![People in Space][15] + +### 13、查询网页是否无法访问 + +如果你想知道某个网站是你无法访问了,还是大家都无法访问了,只需在搜索词中输入 `is xyz.com down`。 + +![Is down?][16] + +### 14、获取特定话题的名言 + +输入一个词并带上 `quotes`,就会显示与这个词相关的名言。 + +![Get quotes in DDG][17] + +### 15、获取占位文本 + +搜索 `lorem ipsum` 就可以获取 5 段占位文本。对 Web 开发者应该会有用。 + +![Lorem ipsum][18] + +### 16、获取任意月份的日历 + +在年、月、日后面输入 `calendar`,就会为你显示该月份的交互式日历。 + +![Calendar][19] + +### 17、生成二维码 + +在文字、链接等后面输入 `qr`,就会生成对应的二维码。 + +![QRCode][20] + +### 18、获取一些 CSS 动画 + +搜索 `css animations` 以获取一些 CSS 动画例子。 + +![CSS Animations][21] + +### 19、展开短链接 + +如果有一个 Bitly 链接或其他短链接,但不确定它指向哪里,不必再跳转到充满垃圾信息的网页了,只需展开短链接,看看真正的网址。 + +在短链接后面输入关键词 `expand`,就会显示真正的目标 URL。 + +![Expand Link][22] + +### 20、获取特殊字符的 HTML 代码 + +搜索 `html chars`,可以获取一份很长的列表,上面有 HTML 实体及其描述,按下后会在结果中显示更多信息。 + +![HTML Chars][23] + +### 21、我用这东西干啥? + +这功能没什么用。如果你输入 `why should I use this?` ,它就会在搜索结果顶部显示 `cause it's awesome`。显然,DuckDuckGo 在说他自己。 + +![Why should I use this?][24] + +### 22、转换大小写 + +大小写都可转换。`lowercase <大写搜索词>` 就会显示小写的结果 + +![Lowercase][25] + +`uppercase <小写搜索词>` 就会显示大写的结果。 + +![Uppercase][26] + +### 23、编码 URL + +搜索 `encode` 并加上 URL,就会给出编码后的结果 + +![URL Encode][27] + +### 24、Motherboard + +搜索 `Motherboard` 就会看见左侧的 DuckDuckGo 的 logo 变了。它会显示选好的几个随机 logo。 + +![Motherboard][28] + +### 25、获取 HTML 色码 + +搜索 `color codes` 便可获得一份颜色表。一样,这个功能多为 Web 开发者和设计师所用。 + +![Color Codes][29] + +### 还有很多别的··· + +我的伙伴 Sreenath 想到本贴的主意。他说 DuckDuckGo 中还有许多 “彩蛋”,我觉得没错。但全部列出来有诸多不便。 + +如果你知道更多这样有趣的 DDG 搜索功能,请在评论中分享。如果你又发现了你喜欢的搜索功能,也提出来吧。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/duckduckgo-easter-eggs/ + +作者:[sreenath][a] +选题:[lkxed][b] +译者:[Peaksol](https://github.com/TravinDreek) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/sreenath/ +[b]: https://github.com/lkxed +[1]: https://itsfoss.com/privacy-search-engines/ +[2]: https://itsfoss.com/wp-content/uploads/2022/05/duckduckgo-bang-feature-800x449.png +[3]: https://itsfoss.com/funny-linux-commands/ +[4]: https://itsfoss.com/wp-content/uploads/2022/05/figlet-800x272.png +[5]: https://itsfoss.com/wp-content/uploads/2022/05/itsfoss-twitter-800x278.jpg +[6]: https://itsfoss.com/wp-content/uploads/2022/05/password-30-800x185.jpg +[7]: https://itsfoss.com/wp-content/uploads/2022/05/random-pqssphrase-800x179.png +[8]: https://itsfoss.com/wp-content/uploads/2022/05/vim-cheatsheet-800x367.png +[9]: https://itsfoss.com/wp-content/uploads/2022/05/color-800x289.jpg +[10]: https://itsfoss.com/wp-content/uploads/2022/05/random-number-800x235.png +[11]: https://itsfoss.com/wp-content/uploads/2022/05/random-number-between-1-and-1000-800x244.png +[12]: https://itsfoss.com/wp-content/uploads/2022/05/binary-800x184.png +[13]: https://itsfoss.com/wp-content/uploads/2022/05/What-rhymes-with-rain-800x257.png +[14]: https://itsfoss.com/wp-content/uploads/2022/05/ramanujan-number-800x238.png +[15]: https://itsfoss.com/wp-content/uploads/2022/05/people-in-space-800x313.jpg +[16]: https://itsfoss.com/wp-content/uploads/2022/05/is-down-800x204.png +[17]: https://itsfoss.com/wp-content/uploads/2022/05/life-quotes-800x303.png +[18]: https://itsfoss.com/wp-content/uploads/2022/05/lorem-ipsum-800x227.png +[19]: https://itsfoss.com/wp-content/uploads/2022/05/calendar-800x331.png +[20]: https://itsfoss.com/wp-content/uploads/2022/05/qrcode-800x255.png +[21]: https://itsfoss.com/wp-content/uploads/2022/05/css-animations-800x385.jpg +[22]: https://itsfoss.com/wp-content/uploads/2022/05/expand-shortened-link-ddg-800x209.png +[23]: https://itsfoss.com/wp-content/uploads/2022/05/html-chars-800x174.png +[24]: https://itsfoss.com/wp-content/uploads/2022/05/why-should-i-use-this-800x160.png +[25]: https://itsfoss.com/wp-content/uploads/2022/05/lowercase-800x179.png +[26]: https://itsfoss.com/wp-content/uploads/2022/05/uppercase-800x185.png +[27]: https://itsfoss.com/wp-content/uploads/2022/05/url-encode-800x177.png +[28]: https://itsfoss.com/wp-content/uploads/2022/05/motherboard.png +[29]: https://itsfoss.com/wp-content/uploads/2022/05/color-codes-800x554.png diff --git a/published/202206/20220516 How to Dual Boot Ubuntu 22.04 LTS and Windows 11.md b/published/202206/20220516 How to Dual Boot Ubuntu 22.04 LTS and Windows 11.md new file mode 100644 index 0000000000..4004bcb938 --- /dev/null +++ b/published/202206/20220516 How to Dual Boot Ubuntu 22.04 LTS and Windows 11.md @@ -0,0 +1,196 @@ +[#]: subject: "How to Dual Boot Ubuntu 22.04 LTS and Windows 11" +[#]: via: "https://www.linuxtechi.com/dual-boot-ubuntu-22-04-and-windows-11/" +[#]: author: "James Kiarie https://www.linuxtechi.com/author/james/" +[#]: collector: "lkxed" +[#]: translator: "robsean" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14699-1.html" + +如何双启动 Ubuntu 22.04 LTS 和 Windows 11 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/12/110546fff10ck07e2p0z2f.jpg) + +嗨,伙计们,在这篇指南中,我们将演示如何在 Windows 11 的之外配置 Ubuntu 22.04 LTS(Jammy Jellyfish)的双启动设置。 + +为使其能工作,你需要在你的计算机上已经安装好了 Windows 11 。接下来,你将需要在你的硬盘驱动器上创建一个单独的分区,你将在此分区上安装 Ubuntu 22.04 。我们将包含这点知识,因此不要担心。 + +**前置条件:** + +在设置双启动前,这些是你所需要的: + +* 一个 Ubuntu 22.04 的可启动 USB 驱动器,你可以转到 [Ubuntu 22.04 下载页面][1] 来下载 Ubuntu 22.04 的 ISO 镜像文件。在 ISO 镜像文件到位后,拿一个 16GB USB 驱动器,并使用 Rufus 应用程序来使其可启动。 +* 快速稳定的互联网连接 + +### 步骤 1、在你的硬盘驱动器上创建一个可用的分区  + +正如介绍中所提到的,我们首先需要在硬盘驱动器上创建一个单独的分区,我们将在其中安装 Ubuntu 22.04 。 + +因此,通过按下 `Windows + R` 组合键来打开磁盘管理器实用程序。 + +在对话框中,输入 `diskmgmt.msc` ,并按下回车键。 + +![][2] + +磁盘管理disk management控制台将显示当前磁盘分区,如你将在下面所看到的一样。我们将通过压缩 “卷 E” 来创建一个用于安装 Ubuntu 的分区。这在你的安装过程中可能有所不同,但是只需要跟着做,你就会理解其中的大体意思。 + +![][3] + +因此,在你想要压缩的磁盘驱动器卷上点击鼠标右键,并在弹出的菜单中选择 压缩卷Shrink 选项。 + +![][4] + +将会出现一个弹出对话框,如下所示。具体指定压缩的控件大小(以 MB 为单位),并单击 压缩卷Shrink 。 + +这是指定给 Ubuntu 22.04 安装所用的空间。 + +![][5] + +在缩小磁盘空间后,它将显示为 未分配Unallocated可用空间Free Space,如图所示。 + +![][6] + +随着有了可用空间,现在将可启动 USB 驱动器插入到你的 PC ,并重新启动你的系统。此外,要确保访问 BIOS 设置,并修改启动优先级,来使 USB 驱动器成为第一优先级。保存 BIOS 更改并继续启动。 + +### 步骤 2、开始安装 + +在第一个屏幕中,你将得到如图所示的 GRUB 菜单。选择第一个选项 尝试或安装 UbuntuTry or Install Ubuntu ,并按下 回车键ENTER 按键。 + +![][7] + +Ubuntu 22.04 将开始加载,如下所示。这最多需要一分钟。 + +![][8] + +此后,安装程序向导将弹出,向你提供两个选项: 尝试 UbuntuTry Ubuntu安装 UbuntuInstall Ubuntu。因为我们的使命是安装 Ubuntu ,所以选择后者。 + +![][9] + +接下来,选择你的首选键盘布局,并单击 继续Continue 按钮。 + +![][10] + +在 更新和其它软件Updates and Other Software 步骤中,选择 正常安装Normal Installation 以便安装 Ubuntu的 GUI 版本,通过勾选其它剩余选项来允许下载更新和安装第三方的针对于图像、WIFI 硬件和其它实用程序的软件包。 + +接下来,单击 继续Continue 按钮。 + +![][11] + +下一步提供两个安装选项。第一个选项 - 清除整个磁盘并安装 UbuntuErase disk and install Ubuntu – 完全地擦除你的驱动器并安装。但是由于这是一个双启动设置,这个选项对于你现有安装的 Windows 系统来说会是灾难性的。 + +因此,选择 其它选项Something else,单击 继续Continue 按钮。 + +![][12] + +分区表将显示所有现有的磁盘分区。到目前为止,我们仅有 NTFS 分区和我们之前压缩出来的可用分区。 + +针对 Ubuntu 22.04 ,我们将创建下面的分区: + +* `/boot`        –        1 GB +* `/home`        –        10 GB +* `/`            –        12 GB +* 交换分区        –         2 GB +* EFI           –       300 MB + +为开始使用这些分区,单击 可用空间Free Space分区下面的 “+” 符号。 + +![][13] + +如图显示填写 `/boot` 分区的详细信息,然后单击 确定OK 按钮。 + +![][14] + +接下来,具体指定 `/home` 分区,并单击 确定OK 按钮。 + +![][15] + +接下来,定义 `/`(根)分区,并单击 确定OK 按钮。 + +![][16] + +为定义交换空间,设置大小,并在 使用为Use as:选项中选择 交换区域Swap area。 + +![][17] + +最后,如果你正在使用 UEFI 启动模式,那么创建一个 EFI 系统分区。我们将分配 300MB 到 EFI 分区。 + +![][18] + +下图是一份我们的分区表的分区摘要: + +![][19] + +为继续安装,单击 现在安装Install Now。在下图显示的弹出窗口中,单击 继续Continue来保存更改到磁盘。 + +![][20] + +接下来,安装程序向导将自动侦测出你的位置,只需要单击 继续Continue 按钮。 + +![][21] + +接下来,通过具体指定姓名、计算机的名称和密码来创建一个登录用户。接下来单击 继续Continue 按钮。 + +![][22] + +此时,安装程序向导将复制所有的 Ubuntu 文件和软件包到手动创建的硬盘驱动器分区,并安装必要的软件包。 + +这个过程将需要很长一段时间,因此,要有耐心。在我们的实例中,它需要大约 30 分钟。 + +![][23] + +在安装过程完成后,单击 立刻重新启动Restart Now 按钮来重新启动系统。 + +![][24] + +在这时,移除你的可启动 USB 驱动器,并按下回车键。 + +![][25] + +在系统重新启动时,你将找到包括 Ubuntu 和 Windows 11 在内的各种选项。 + +选择 “Ubuntu” 来启动到你的新 Ubuntu 22.04 安装。要启动到 Windows 11,请选择标有 Windows 恢复环境Windows Recovery Environment 的条目。 + +![][26] + +就这样。我们演示了如何双启动 Windows 11 和 Ubuntu 22.04。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/dual-boot-ubuntu-22-04-and-windows-11/ + +作者:[James Kiarie][a] +选题:[lkxed][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/james/ +[b]: https://github.com/lkxed +[1]: https://releases.ubuntu.com/22.04/ +[2]: https://www.linuxtechi.com/wp-content/uploads/2022/05/diskmgmt-msc-command-windows11.png +[3]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Disk-Management-Console-Windows11.png +[4]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Shrink-Volume-Windows11.png +[5]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Shrink-Volume-Size-Windows11.png +[6]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Free-Space-Disk-Management-Console-Windows11.png +[7]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Select-Install-Ubuntu-Linux.png +[8]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Ubuntu-22-04-Loading-Screen.png +[9]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Choose-Install-Ubuntu-Linux.png +[10]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Keyboard-Layout-Ubuntu-22-04.png +[11]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Normal-Installation-Option-During-Ubuntu-22-04-Installation.png +[12]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Something-else-ubuntu-installation.png +[13]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Select-Free-Space-for-Ubuntu-22-04-Installation.png +[14]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Boot-Partition-Ubuntu-22-04-LTS.png +[15]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Home-Partition-For-Ubuntu-22-04.png +[16]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Root-Partition-For-Ubuntu-22-04.png +[17]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Swap-Area-Ubuntu-22-04.png +[18]: https://www.linuxtechi.com/wp-content/uploads/2022/05/EFI-System-Partition-Ubuntu-22-04.png +[19]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Install-Now-Ubuntu-22-04.png +[20]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Write-Changes-Disk-Ubuntu-22-04.png +[21]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Location-for-Ubuntu-22-04-Installation.png +[22]: https://www.linuxtechi.com/wp-content/uploads/2022/05/UserName-Hostname-Ubuntu-22-04-lts-Installation.png +[23]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Installation-Progress-Ubuntu-22-04.png +[24]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Restart-After-Ubuntu-22-04-LTS-Installation.png +[25]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Remove-Installation-Media-after-Ubuntu-22-04-Installation.png +[26]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Dual-Boot-Grub-Bootloader-Screen-Ubuntu-22-04.png diff --git a/published/202206/20220518 How To Boot Into Rescue Mode Or Emergency Mode In Ubuntu 22.04 - 20.04 - 18.04.md b/published/202206/20220518 How To Boot Into Rescue Mode Or Emergency Mode In Ubuntu 22.04 - 20.04 - 18.04.md new file mode 100644 index 0000000000..77459650a8 --- /dev/null +++ b/published/202206/20220518 How To Boot Into Rescue Mode Or Emergency Mode In Ubuntu 22.04 - 20.04 - 18.04.md @@ -0,0 +1,276 @@ +[#]: subject: "How To Boot Into Rescue Mode Or Emergency Mode In Ubuntu 22.04 / 20.04 / 18.04" +[#]: via: "https://ostechnix.com/how-to-boot-into-rescue-mode-or-emergency-mode-in-ubuntu-18-04/" +[#]: author: "sk https://ostechnix.com/author/sk/" +[#]: collector: "lkxed" +[#]: translator: "robsean" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14709-1.html" + +详解在 Ubuntu 中引导到救援模式或紧急模式 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/14/153639n33fg3e2gc7xnvv3.jpg) + +这篇教程将介绍如何在 Ubuntu 22.04、20.04 和 18.04 LTS 版本中引导到 救援Rescue 模式或 紧急Emergency 模式。 + +> 你可能已经知道,在 RHEL 7 、RHEL 8 、Ubuntu 16.04 LTS 及其更新的版本的 Linux 发行版中 运行等级Runlevels 已经被 系统目标Systemd target 所替代。更多关于 运行等级Runlevel系统目标Systemd targets 的信息,参考 [这篇指南][1] 。 + +这篇指南是针对 Ubuntu 编写的,但是,下面所给的步骤应该也适用于大多数使用 systemd 作为默认服务管理器的 Linux 发行版。 + +在进入主题前,让我们简单的理解:什么是 救援rescue 模式 和 紧急Emergency 模式,以及这两种模式的目的是什么。 + +### 什么是救援模式? + +在 Linux 发行版中,救援模式等效于使用 SysV 作为默认的服务器管理器的 单用户single user 模式。在救援模式中,将挂载所有的本地文件系统,将仅启动一些重要的服务。但是,不会启动一般的服务(例如,网络服务)。 + +救援模式在不能正常引导系统的情况下是很有用的。此外,我们可以在救援模式下执行一些重要的救援操作,例如,[重新设置 root 密码][2] 。 + +### 什么是紧急模式? + +与救援模式相比,在紧急模式中,不会启动任何的东西。不会启动服务、不会挂载挂载点、不会建立套接字、什么都不会启动。你将所拥有的只是一个 **原始的 shell** 。紧急模式适用于调试目的。 + +首先,我们将看到如何在 Ubuntu 22.04 和 20.04 LTS 发行版中引导到救援模式或紧急模式。在 Ubuntu 22.04 和 20.04 LTS 中的过程是完全相同的! + +### 在 Ubuntu 22.04 / 20.04 LTS 中引导到救援模式 + +我们可以使用两种方法来引导到救援模式。 + +#### 方法 1 + +打开你的 Ubuntu 系统。在 BIOS 徽标出现后,按下 `ESC` 按键来显示 GRUB 菜单。 + +在 GRUB 菜单中,选择第一项,并按下 `e` 按键来编辑它。 + +![GRUB Menu In Ubuntu 22.04 / 20.04 LTS][3] + +按下 `↓` 按键,并找到以单词 `linux` 开头的一行代码,并在其结尾处添加下面的一行代码。为到达其结尾处,只需要按下 `Ctrl + e` 组合键,或使用你键盘上的 `END` 按键或 `←`/`→` 按键。 + +``` +systemd.unit=rescue.target +``` + +![Edit Grub Boot Menu Entries To Enter Into Rescue Mode In Ubuntu 22.04 / 20.04 LTS][4] + +在添加上面的代码行后,按下 `Ctrl + x` 组合键或按下 `F10` 按键来引导到救援模式。 + +数秒后,你将作为 root 用户来登录到救援模式(即单用户模式)。将会提示你按下回车键来进入维护。 + +下图是 Ubuntu 22.04 / 20.04 LTS 系统的救援模式的样子: + +![Boot Into Rescue Mode In Ubuntu 22.04 / 20.04 LTS][5] + +现在,在救援模式中做你想做的任何事。在救援模式中,在你执行任何操作前,你可能需要以 读/写模式来挂载根(`/`)文件系统。 + +``` +mount -n -o remount,rw / +``` + +![Mount Root File System In Read Write Mode In Ubuntu 22.04 / 20.04 LTS][6] + +在完成后,按下 `Ctrl + d` 组合键来引导到正常模式。或者,你可以输入下面的任意一个命令来引导到正常模式。 + +``` +systemctl default +``` + +或者, + +``` +exit +``` + +如果你想重新启动系统,而不是引导到正常的模式,输入: + +``` +systemctl reboot +``` + +#### 方法 2 + +在这种方法中,你不需要编辑 GRUB 启动菜单项目。 + +打开系统电源,并从 GRUB 启动菜单中选择 Ubuntu 高级选项Advanced options for Ubuntu。 + +![Choose Advanced Options For Ubuntu From Grub Boot Menu][7] + +接下来,你将看到一个带有内核版本的可用的 Ubuntu 版本的列表。在 Ubuntu 中的 GRUB 启动菜单中选择 恢复模式Recovery mode 。 + +![Choose Recovery Mode In Grub Boot Menu In Ubuntu 22.04 / 20.04 LTS][8] + +数秒后,你将看到 Ubuntu 的 恢复Recovery 菜单。从恢复菜单中,选择 进入 root 的 shell 提示符Drop to root shell prompt 选项 ,并按下回车键。 + +![Enter Into Root Shell Prompt In Ubuntu 22.04 / 20.04 LTS][9] + +现在,你将进入维护。 + +![Ubuntu Maintenance Mode][10] + +通过输入下面的命令来 以读/写模式的方式 来挂载根(`/`)文件系统: + +``` +mount -n -o remount,rw / +``` + +![Mount Root File System In Read Write Mode In Ubuntu][11] + +在救援模式中做你想做的任何事。 + +在完成后,输入 `exit` 来返回到恢复菜单。 + +``` +exit +``` + +最后,选择 救援正常启动Resume normal boot 选项,并按下回车键。 + +![Boot Into Normal Mode In Ubuntu][12] + +再次按下回车键来退出恢复模式,并继续引导到正常模式。 + +![Exit The Recovery Mode In Ubuntu][13] + +如果你不想引导到正常模式,从救援模式中输入 `reboot` 并按下回车键来重新启动你的系统。 + +### 在 Ubuntu 22.04 / 20.04 LTS 中引导到紧急模式 + +当 GRUB 菜单出现时,按下 `e` 按键来编辑它。 + +![GRUB Menu In Ubuntu 22.04 / 20.04 LTS][14] + +找到以单词 `linux` 开头的一行代码,并在其结尾处添加下面的一行代码: + +``` +systemd.unit=emergency.target +``` + +![Edit Grub Boot Menu Entries To Enter Into Emergency Mode In Ubuntu 22.04 / 20.04 LTS][15] + +在添加上面的代码行后,按下 `Ctrl + x` 组合键,或按下 `F10` 按键来引导到紧急模式。 + +数秒后,你将作为 `root` 用户来进入维护。将会提示你按下回车键来进入紧急模式。 + +下图是 Ubuntu 22.04 / 20.04 LTS 系统的紧急模式的样子: + +![Boot Into Emergency Mode In Ubuntu 22.04 / 20.04 LTS][16] + +现在,在紧急模式中做你想做的任何事。在紧急模式中,在你执行任何操作前,你可能需要以读/写模式来挂载根(`/`)文件系统。 + +``` +mount -n -o remount,rw / +``` + +在完成后,按下 `Ctrl + d` 组合键来引导到正常模式。或者,你可以输入下面的任意一个命令来引导到正常模式。 + +``` +systemctl default +``` + +或者, + +``` +exit +``` + +如果你想重新启动系统,而不是引导到正常模式,输入: + +``` +systemctl reboot +``` + +### 在 Ubuntu 18.04 LTS 中引导到救援模式 + +启动你的 Ubuntu 系统。当 GRUB 菜单出现时,选择第一项并按下按键 `e` 来编辑。(为到达其行尾处,只需要按下 `Ctrl + e` 组合键,或使用你键盘上的 `END` 按键或 `←`/`→` 按键): + +![Grub Menu][17] + +如果你没有看到 GRUB 菜单,只需要在 BIOS 徽标出现后,按下 `ESC` 按键来显示 GRUB 菜单。 + +找到以单词 `linux` 开头的一行代码,并在其结尾处添加下面的一行代码(为到达其行尾处,只需要按下 `Ctrl + e` 组合键,或使用你键盘上的 END` 按键或 `←`/`→` 按键): + +``` +systemd.unit=rescue.target +``` + +![Edit Grub Menu][18] + +在添加上面的代码行后,只需要按下 `Ctrl + x` 组合键,或按下 `F10` 按键来引导到救援模式。数秒后,你将作为 `root` 用户进入维护(即单用户模式)。 + +下图是 Ubuntu 18.04 LTS 服务器系统的救援模式的样子: + +![Ubuntu Rescue Mode][19] + +接下来,输入下面的命令来挂载根(`/`)文件系统为读/写模式。 + +``` +mount -n -o remount,rw / +``` + +### 在 Ubuntu 18.04 LTS 中引导到紧急模式 + +引导你的 Ubuntu 到紧急模式基本与上述方法相同。你所需要做的全部工作是,在编辑 GRUB 菜单时,将 `systemd.unit=rescue.target` 替换为 `systemd.unit=emergency.target` 。 + +![Edit Grub Menu][20] + +在你添加 `systemd.unit=emergency.target` 后,按下 `Ctrl + x` 组合键,或按下 `F10` 按键来引导到紧急模式。 + +![Ubuntu Emergency Mode][21] + +最后,你可以使用下面的命令来以读/写模式的方式来挂载根(`/`)文件系统: + +``` +mount -n -o remount,rw / +``` + +### 在救援模式和紧急模式之间切换 + +如果你正在救援模式中,你不必像我上述提到的那样来编辑 GRUB 的菜单启动项。相反,你只想要输入下面的命令来立刻切换到紧急模式: + +``` +systemctl emergency +``` + +同样,为从紧急模式切换到救援模式,输入: + +``` +systemctl rescue +``` + +### 总结 + +现在,你知道了什么是救援模式和紧急模式,以及如何在 Ubuntu 22.04 、20.04 和 18.04 LTS 系统中启动到这些模式。正如我已经提到的,在这里提供的这些步骤应该也适用于大多数当前使用 systemd 作为默认服务管理器的 Linux 发行版。 + +-------------------------------------------------------------------------------- + +via: https://ostechnix.com/how-to-boot-into-rescue-mode-or-emergency-mode-in-ubuntu-18-04/ + +作者:[sk][a] +选题:[lkxed][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://ostechnix.com/author/sk/ +[b]: https://github.com/lkxed +[1]: https://ostechnix.com/check-runlevel-linux/ +[2]: https://ostechnix.com/how-to-reset-or-recover-root-user-password-in-linux/ +[3]: https://ostechnix.com/wp-content/uploads/2022/05/GRUB-Menu-In-Ubuntu-22.04-LTS.png +[4]: https://ostechnix.com/wp-content/uploads/2022/05/Edit-Grub-Boot-Menu-Entries-To-Enter-Into-Rescue-Mode-In-Ubuntu-22.04-LTS.png +[5]: https://ostechnix.com/wp-content/uploads/2022/05/Boot-Into-Rescue-Mode-In-Ubuntu-22.04.png +[6]: https://ostechnix.com/wp-content/uploads/2022/05/Mount-Root-File-System-In-Read-Write-Mode-In-Ubuntu.png +[7]: https://ostechnix.com/wp-content/uploads/2022/05/Choose-Advanced-Options-For-Ubuntu-From-Grub-Boot-Menu.png +[8]: https://ostechnix.com/wp-content/uploads/2022/05/Choose-Recovery-Mode-In-Grub-Boot-Menu-In-Ubuntu.png +[9]: https://ostechnix.com/wp-content/uploads/2022/05/Enter-Into-Root-Shell-Prompt-In-Ubuntu.png +[10]: https://ostechnix.com/wp-content/uploads/2022/05/Ubuntu-Maintenance-Mode.png +[11]: https://ostechnix.com/wp-content/uploads/2022/05/Mount-Root-File-System-In-Read-Write-Mode-In-Ubuntu-1.png +[12]: https://ostechnix.com/wp-content/uploads/2022/05/Boot-Into-Normal-Mode-In-Ubuntu.png +[13]: https://ostechnix.com/wp-content/uploads/2022/05/Exit-The-Recovery-Mode-In-Ubuntu.png +[14]: https://ostechnix.com/wp-content/uploads/2022/05/GRUB-Menu-In-Ubuntu-22.04-LTS.png +[15]: https://ostechnix.com/wp-content/uploads/2022/05/Edit-Grub-Boot-Menu-Entries-To-Enter-Into-Emergency-Mode-In-Ubuntu.png +[16]: https://ostechnix.com/wp-content/uploads/2018/12/Boot-Into-Emergency-Mode-In-Ubuntu-20.04-LTS.png +[17]: https://ostechnix.com/wp-content/uploads/2018/12/Grub-menu.png +[18]: https://ostechnix.com/wp-content/uploads/2018/12/Edit-grub-menu.png +[19]: https://ostechnix.com/wp-content/uploads/2018/12/Ubuntu-rescue-mode.png +[20]: https://ostechnix.com/wp-content/uploads/2018/12/emergency-mode.png +[21]: https://ostechnix.com/wp-content/uploads/2018/12/emergency-mode-1.png diff --git a/published/202206/20220518 Install Specific Package Version With Apt Command in Ubuntu.md b/published/202206/20220518 Install Specific Package Version With Apt Command in Ubuntu.md new file mode 100644 index 0000000000..3fd0736890 --- /dev/null +++ b/published/202206/20220518 Install Specific Package Version With Apt Command in Ubuntu.md @@ -0,0 +1,193 @@ +[#]: subject: "Install Specific Package Version With Apt Command in Ubuntu" +[#]: via: "https://itsfoss.com/apt-install-specific-version-2/" +[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" +[#]: collector: "lkxed" +[#]: translator: "robsean" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14760-1.html" + +如何在 Ubuntu 中安装具体指定的软件包版本 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/26/145335zcrpducpup4p2ugy.jpg) + +在 Ubuntu 中想安装一个软件包的一个特别指定的版本?你可以通过下面的方式来轻松地完成: + +``` +sudo apt install package_name=package_version +``` + +你如何知道某个软件包有哪些可用的版本?可以使用这个命令: + +``` +apt list --all-versions package_name +``` + +在下面的屏幕截屏中,你可以看到,我有两个可用的 VLC 版本,我使用命令来安装较旧的版本: + +![install specific versions apt ubuntu][1] + +听起来像一个简单的任务,对吧?但是事情并非看起来那么简单。这里有一些不确定是否会出现,但是可能会涉及的东西。 + +这篇教程将涵盖使用 `apt` 或 `apt-get` 命令来安装一个具体指定的程序的版本的所有的重要的方面。 + +### 安装一个具体指定版本的程序需要知道的事 + +在基于 Ubuntu 和 Debian 发行版中,你需要知道一些关于 APT 和存储库是如何工作的知识。 + +#### 同一个软件包源没有较旧的版本 + +Ubuntu 在其存储库中不保留较旧版本的软件包。在特殊的情况下,你可以暂时性地看到多个版本。例如,你运行 APT 更新(但不升级)时,可能会有一个可用的新版本。在 APT 缓存中,你可以看到同一个软件包的两个版本。但是,一旦软件包被升级到了新的版本,较旧版本的软件包将从 **APT 缓存** 和存储库中移除。 + +#### 使用多个软件包源来使用不同的版本 + +为获取同一个的软件包的多个版本,你必须得添加多个软件包源。例如,VLC 是版本 3.x 系列。添加 [VLC 每日构建 PPA][2] 将会提供(不稳定的)版本 4.x 系列。 + +同样,**你可以下载不同版本的 DEB 文件,并安装它**。 + +#### 较高版本编号的版本通常有优先权 + +如果你有来自多个软件包源的相同名称的软件,默认情况下,Ubuntu 将安装可用的最高版本编号的版本。 + +在前面的示例中,如果我安装 VLC ,那么它将会安装 4.x 系列的版本,而不是 3.x 系列的版本。 + +#### 较旧版本将升级到可用的较新版本 + +这是另外一个可能存在的问题。即使你安装较旧版本的软件包,它也会升级到较新的版本(如果存在可用的较新版本)。你必须 [保留该软件包来防止其升级][3] 。 + +#### 依赖关系也需要安装 + +如果软件包有依赖关系,你也需要安装必要的依赖关系软件包。 + +现在,你已经知道一些可能存在的问题,让我们看看如何解决它们。 + +### 安装一个软件包的具体指定版本 + +在这篇教程中,我将以 VLC 为例。在 Ubuntu 的存储库中可获得 VLC 版本。我添加了每日构建 PPA ,它将向我提供 VLC 的 4.0 版本的候选版本。 + +如你所见,在现在的系统中,我有两个可用的 VLC 版本: + +![install specific versions apt ubuntu][4] + +``` +~$ apt list -a vlc +Listing... Done +vlc/jammy 4.0.0~rc1~~git20220516+r92284+296~ubuntu22.04.1 amd64 +vlc/jammy 3.0.16-1build7 amd64 +vlc/jammy 3.0.16-1build7 i386 +``` + +因为较高版本编号版本有优先权,使用 `apt install vlc` 命令将会导致安装 VLC 的 4.0 版本。但是,因为这篇教程的缘由,我想安装较旧的版本 3.0.16 。 + +``` +sudo apt install vlc=3.0.16-1build7 +``` + +但是,这里会有这样的事。VLC 软件包有一些依赖关系,并且这些依赖关系也需要具体指定的版本。因此,在 Ubuntu 为其尝试安装最新的版本时,你将会遇到经典的 [你已保留残缺软件包][5]you have held broken packages 错误。 + +![problem installing specific version apt ubuntu][6] + +为修复这个错误,你需要为其提供它所投诉的所有依赖关系的软件包的具体指定版本。因此,该命令会变成这样: + +``` +sudo apt install vlc=3.0.16-1build7 \ + vlc-bin=3.0.16-1build7 \ + vlc-plugin-base=3.0.16-1build7 \ + vlc-plugin-qt=3.0.16-1build7 \ + vlc-plugin-video-output=3.0.16-1build7 \ + vlc-l10n=3.0.16-1build7 \ + vlc-plugin-access-extra=3.0.16-1build7 \ + vlc-plugin-notify=3.0.16-1build7 \ + vlc-plugin-samba=3.0.16-1build7 \ + vlc-plugin-skins2=3.0.16-1build7 \ + vlc-plugin-video-splitter=3.0.16-1build7 \ + vlc-plugin-visualization=3.0.16-1build7 +``` + +说明一下,每行结尾处的 `\` 只是用来将多行命令来写入同一个命令的一种方式。 + +**它有作用吗?在很多情况下,它是有作用的。** 但是,我选择了一个复杂的 VLC 示例,它有很多依赖关系。甚至这些所涉及的依赖关系也依赖于其它的软件包。所以,它就变得令人难以处理。 + +一种替代的方法是在安装时指定软件包源。 + +#### 替代方式,指定存储库 + +你已经添加多个软件包源,因此,你应该对这些软件包的来源有一些了解。 + +使用下面的命令来搜索存储库: + +``` +apt-cache policy | less +``` + +注意存储库名称后面的行: + +``` +500 http://security.ubuntu.com/ubuntu jammy-security/multiverse i386 Packages + release v=22.04,o=Ubuntu,a=jammy-security,n=jammy,l=Ubuntu,c=multiverse,b=i386 + origin security.ubuntu.com +``` + +你可以具体指定 `o`、`l`、`a` 等参数。 + +在我原来的示例中,我想安装来自 Ubuntu 存储库的 VLC(获取版本 3.16),而不是安装来 PPA 的版本(它将向我提供版本 4)。 + +因此,下面的命令将安装 VLC 版本 3.16 及其所有的依赖关系: + +``` +sudo apt install -t "o=ubuntu" vlc +``` + +![install from repository source][7] + +看起来令人满意?但是,当你必须更新系统时,问题就来了。它接下来会控诉找不到指定的软件包版本。 + +**还能做什么?** + +为安装较旧的软件包版本,从你的系统中移除较新版本的软件包源(如果可能的话)。它将有助于逃脱这些依赖关系地狱。 + +如果不能这么做,检查你是否可以从其它一些软件包的打包格式来获取,像 Snap、Flatpak、AppImage 等等。事实上,Snap 和 Flatpak 也允许你从可用的版本中选择和安装。因为这些应用程序是沙盒模式的,所以它很容易管理不同版本的依赖关系。 + +#### 保留软件包,防止升级 + +如果你完成安装一个指定的程序版本,你可能想避免意外地升级到较新的版本。实现这一点并不太复杂。 + +``` +sudo apt-mark hold package_name +``` + +你可以免除保留软件包,以便它能稍后升级: + +``` +sudo apt-mark unhold package_name +``` + +注意,软件包的依赖关系不会自动地保留。它们需要单独地指明。 + +### 结论 + +如你所见,安装选定软件包版本有一定之规。只有当软件包有依赖关系时,那么事情就会变得复杂,然后,你就会进入依赖关系地狱。 + +我希望你在这篇教程中学到一些新的东西。如果你有问题或建议来改善它,请在评论区告诉我。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/apt-install-specific-version-2/ + +作者:[Abhishek Prakash][a] +选题:[lkxed][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lkxed +[1]: https://itsfoss.com/wp-content/uploads/2022/05/install-specific-versions-apt-ubuntu.png +[2]: https://launchpad.net/~videolan/+archive/ubuntu/master-daily +[3]: https://itsfoss.com/prevent-package-update-ubuntu/ +[4]: https://itsfoss.com/wp-content/uploads/2022/05/install-specific-versions-apt-ubuntu.png +[5]: https://itsfoss.com/held-broken-packages-error/ +[6]: https://itsfoss.com/wp-content/uploads/2022/05/problem-installing-specific-version-apt-ubuntu-800x365.png +[7]: https://itsfoss.com/wp-content/uploads/2022/05/install-from-repository-source-800x578.png diff --git a/translated/tech/20220519 Use this open source screen reader on Windows.md b/published/202206/20220519 Use this open source screen reader on Windows.md similarity index 59% rename from translated/tech/20220519 Use this open source screen reader on Windows.md rename to published/202206/20220519 Use this open source screen reader on Windows.md index 27bcf2fe00..a553667e53 100644 --- a/translated/tech/20220519 Use this open source screen reader on Windows.md +++ b/published/202206/20220519 Use this open source screen reader on Windows.md @@ -3,32 +3,32 @@ [#]: author: "Peter Cheer https://opensource.com/users/petercheer" [#]: collector: "lkxed" [#]: translator: "geekpi" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14664-1.html" -在 Windows 上使用这个开源屏幕阅读器 +在 Windows 上使用开源屏幕阅读器 NVDA ====== -为纪念全球无障碍意识日,了解 NVDA 开源屏幕阅读器,以及你如何参与其中,为所有网络用户提高无障碍性。 -![Working from home at a laptop][1] -图片提供:Opensource.com +![](https://img.linux.net.cn/data/attachment/album/202206/02/101911ds5t1xts1o52vmss.jpg) + +> 为纪念全球无障碍意识日,让我们了解一下 NVDA 开源屏幕阅读器,以及你该如何参与其中,为所有网络用户提高无障碍性。 屏幕阅读器是辅助技术软件的一个专门领域,它可以阅读并说出计算机屏幕上的内容。完全没有视力的人只是视力障碍者的一小部分,屏幕阅读器软件可以帮助所有群体。屏幕阅读器大多特定于操作系统,供有视觉障碍的人和无障碍培训师使用,以及想要测试网站或应用的无障碍访问程度的开发人员和无障碍顾问。 ### 如何使用 NVDA 屏幕阅读器 -[WebAIM 屏幕阅读器用户调查][2]始于 2009 年,一直持续到 2021 年。在第一次调查中,最常用的屏幕阅读器是 JAWS,占 74%。它是 Microsoft Windows 的商业产品,并且是长期的市场领导者。 NVDA 当时是一个相对较新的 Windows 开源屏幕阅读器,仅占 8%。快进到 2021 年,JAWS 占 53.7%,NVDA 占 30.7%。 +[WebAIM 屏幕阅读器用户调查][2] 始于 2009 年,一直持续到 2021 年。在第一次调查中,最常用的屏幕阅读器是 JAWS,占 74%。它是微软 Windows 的商业产品,并且是长期的市场领导者。NVDA 当时是一个相对较新的 Windows 开源屏幕阅读器,仅占 8%。快进到 2021 年,JAWS 占 53.7%,NVDA 占 30.7%。 -你可以从 [NVAccess 网站][3]下载最新版本的 NVDA。为什么我要使用 NVDA 并将它推荐给我使用微软 Windows 的客户?嗯,它是开源的,速度快,功能强大,易于安装,支持多种语言,可以作为便携式应用运行,拥有庞大的用户群,并且有定期发布新版本的周期。 +你可以从 [NVAccess 网站][3] 下载最新版本的 NVDA。为什么我要使用 NVDA 并将它推荐给我使用微软 Windows 的客户?嗯,它是开源的、速度快、功能强大、易于安装、支持多种语言、可以作为便携式应用运行、拥有庞大的用户群,并且有定期发布新版本的周期。 -NVDA 已被翻译成 55 种语言,并在 175 个不同的国家/地区使用。还有一个活跃的开发者社区,拥有自己的[社区插件网站][4]。你选择安装的任何附加组件都将取决于你的需求,并且有很多可供选择,包括常见视频会议平台的扩展。 +NVDA 已被翻译成 55 种语言,并在 175 个不同的国家/地区使用。还有一个活跃的开发者社区,拥有自己的 [社区插件网站][4]。你选择安装的任何附加组件都将取决于你的需求,并且有很多可供选择,包括常见视频会议平台的扩展。 与所有屏幕阅读器一样,NVDA 有很多组合键需要学习。熟练使用任何屏幕阅读器都需要培训和练习。 ![Image of NVDA welcome screen][5] -向熟悉计算机和会使用键盘的人教授 NVDA 并不太难。向一个完全初学者教授基本的计算机技能(没有鼠标、触摸板和键盘技能)和使用 NVDA 是一个更大的挑战。个人的学习方式和偏好不同。此外,如果人们只想浏览网页和使用电子邮件,他们可能不需要学习如何做所有事情。NVDA 教程和资源的一个很好的链接来源是[无障碍中心][6]。 +向熟悉计算机和会使用键盘的人教授 NVDA 并不太难。向一个完全初学者教授基本的计算机技能(没有鼠标、触摸板和键盘技能)和使用 NVDA 是一个更大的挑战。个人的学习方式和偏好不同。此外,如果人们只想浏览网页和使用电子邮件,他们可能不需要学习如何做所有事情。NVDA 教程和资源的一个很好的链接来源是 [无障碍中心][6]。 当你掌握了使用键盘命令操作 NVDA,它就会变得更容易,但是还有一个菜单驱动的系统可以完成许多配置任务。 @@ -36,13 +36,11 @@ NVDA 已被翻译成 55 种语言,并在 175 个不同的国家/地区使用 ### 测试无障碍性 -多年来,屏幕阅读器用户无法访问某些网站一直是个问题,尽管美国残疾人法案(ADA)等残疾人平等立法仍然存在。 NVDA 在有视力的社区中的一个很好的用途是用于网站无障碍性测试。NVDA 可以免费下载,并且通过运行便携式版本,网站开发人员甚至不需要安装它。运行 NVDA,关闭显示器或闭上眼睛,看看你在浏览网站或应用时的表现如何。 +多年来,屏幕阅读器用户无法访问某些网站一直是个问题,尽管美国残疾人法案(ADA)等残疾人平等立法仍然存在。NVDA 在有视力的社区中的一个很好的用途是用于网站无障碍性测试。NVDA 可以免费下载,并且通过运行便携式版本,网站开发人员甚至不需要安装它。运行 NVDA,关闭显示器或闭上眼睛,看看你在浏览网站或应用时的表现如何。 -NVDA 也可用于测试(通常被忽略的)正确[标记 PDF 文档以实现无障碍性][8]任务。 +NVDA 也可用于测试(通常被忽略的)正确 [标记 PDF 文档以实现无障碍性][8] 任务。 -有几个指南专注于使用 NVDA 进行无障碍性测试。我可以推荐[使用 NVDA 测试网页][9]和使用 [NVDA 评估 Web 无障碍性][10]。 - -图片提供:(Peter Cheer,CC BY-SA 4.0) +有几个指南专注于使用 NVDA 进行无障碍性测试。我可以推荐 [使用 NVDA 测试网页][9] 和使用 [NVDA 评估 Web 无障碍性][10]。 -------------------------------------------------------------------------------- @@ -51,7 +49,7 @@ via: https://opensource.com/article/22/5/open-source-screen-reader-windows-nvda 作者:[Peter Cheer][a] 选题:[lkxed][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/202206/20220523 7 pieces of Linux advice for beginners.md b/published/202206/20220523 7 pieces of Linux advice for beginners.md new file mode 100644 index 0000000000..3a2c4d76ad --- /dev/null +++ b/published/202206/20220523 7 pieces of Linux advice for beginners.md @@ -0,0 +1,141 @@ +[#]: subject: "7 pieces of Linux advice for beginners" +[#]: via: "https://opensource.com/article/22/5/linux-advice-beginners" +[#]: author: "Opensource.com https://opensource.com/users/admin" +[#]: collector: "lkxed" +[#]: translator: "lightchaserhy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14712-1.html" + +给 Linux 初学者的 7 条建议 +====== + +> 我们咨询了我们社区作者们,分享了他们的初学经验。 + +![](https://img.linux.net.cn/data/attachment/album/202206/15/143733yhdrxhbnhojbxn2a.jpg) + +对 Linux 的新用户有什么建议?我们请社区的作者们分享了他们初学时的最佳经验。 + +### 1、用好 Linux 资源 + +我哥们儿告诉我,Linux 就像一个“软件积木搭建套装”(这是一个过时的词汇,指的是上世纪五六十年代流行的建筑积木玩具),这个比喻比较恰当。在 2001、2002 年那时,我曾经利用 Windows 3.1 和 Windows NT,尝试搭建一个安全、有用的 K12 学区网站,当时网上可用的资料不多。其中被推荐的《ROOT 用户指南》是一本“大部头”专业教程,信息丰富,但是有一定上手难度。 + +于我而言,Mandrake Linux 的线上课程是最有用的资源。该课程对使用和管理 Linux 桌面或服务器进行了详细的解读。我学习了该课程,并同时利用红帽公司维护的一个邮件列表服务,有问题时就在社区提问寻求帮助。 + +—— [Don Watkins][2] + +### 2、在 Linux 社区寻求帮助 + +我的建议是要多问,你可以从网上搜索信息开始,看看其他人类似的问题(甚至是更好的提问)。问什么和如何问,需要花一定时间熟悉。 + +一旦你对 Linux 更加熟悉了,查看你感兴趣的各种相关论坛,在提问前,先看看是否有人已经提过相同问题,并获得了答案。 + +加入邮件列表也很有用,最后你会发现自己也能专业地答复提问。正如他们说的,通过回答他人的问题也会学到更多知识。 + +同时,你会越来越熟悉这个操作系统内部运行机制,再也不是初学时的一无所知。 + +—— [Greg Pittman][3] + +我的建议是利用 `man`、`info` 等帮助命令获取信息。另外,尽可能花时间熟悉命令行界面,且真正理解 UNIX 的设计理念。事实上,我最喜欢的书之一就是一本 80 年代的 UNIX 书籍,对理解文件、目录、设备、基础命令等非常有帮助。 + +—— [Alan Formy-Duval][4] + +我最好的建议是充分相信社区的答复、手册页的详细信息、介绍不同选项的 HOW-TO 文档。不管怎么说,我是在 2009 年左右开始学习的,当时有很多可用的工具和资源。有一个叫 “Linux from Scratch(LFS)”的项目 —— 从源码开始创建 Linux 系统,在这个项目我学会了很多内部原理知识,以及如何创建一个 LFS 镜像。 + +—— [Sumantro Mukherjee][6] + +我的建议是泛读。利用像 “Ask Fedora”、“Fedora Matrix chat” 等论坛,阅读他人的经验观点,并且尝试实践。我通过阅读他人的网上争论学习到很多东西,然后我会尝试找出问题的原因。 + +—— [Steve Morris][8] + +### 3、安装双操作系统 + +我在 90 年代末就开始安装双操作系统(Windows 和 Linux),虽然我真正想使用的是 Linux 操作系统,但我最终还是启动了 Windows 系统,以便在熟悉的桌面环境中工作。最好的建议之一是改变计算机系统启动顺序,所以每次我都反应不够快,自动进入了 Linux 系统。: ) + +—— [Heike Jurzik][9] + +我的团队里的一个人挑战我,要做一个知识交换。 + +他是我们的 Linux 系统管理员,利用 Joomla 搭建了一个网站(我们的 Web 团队擅长这个,他想学习更多知识),而我则安装了 Linux(以前一直是用 Windows)。我们一开始就用了双启动,因为我还有一堆依赖于操作系统的软件需要用于业务,但这让我对 Linux 的使用有了一个飞跃。 + +在我们各自学习新系统时,对方作为专家来互相帮助有助于共同成长,“一个都不能少!”,坚持不懈是一个很大的挑战。 + +我经历一个相当尴尬的低级错误后,在显示器上贴了一个大便签,上面写着“在使用任何 `rm` 操作前,首先要思考一下”。管理员给我写了一个命令行大全(网上有很多类似的),对于熟悉基础操作非常有用。我开始使用 Ubuntu 的 KDE 桌面环境时,发现对习惯于使用图形界面的初学者很有帮助。 + +从那以后我就开始长期使用 Linux(除了我的工作计算机),而那位管理员仍然在用 Joomla,看起来我俩都得到了成长。 + +—— [Ruth Cheesley][12] + +### 4、为了安全请先备份 + +我的建议是使用一个带有简单且强大的备份软件的发行版。Linux 新用户会创建、编辑、破坏和恢复系统配置。当操作系统无法启动、丢失数据时,会让他们非常沮丧。 + +有了备份软件,他们的数据就有了保障。 + +我们都喜爱 Linux,因为它能让我们自由飞翔,但这是“双刃剑”,使用不当也有可能发生非常严重的错误。 + +—— [Giuseppe Cassibba][13] + +### 5、分享你的 Linux 经验 + +我的建议是分享你的 Linux 使用经验。我曾经认为有一些发行版更适合新用户,所以当他们咨询使用 Linux 时,我总是推荐这些为“新用户准备的”发行版。但是当我坐在他们的计算机前,看起来却像是我从未用过 Linux 一样,因为一些新功能我也不熟悉。现在当有人咨询时,我会推荐自己使用的发行版,虽说这不一定是初学者的“最佳”版本,但毕竟我熟悉,他们遇到的问题我能够快速解决(当然我自己也会在分享中学到新东西)。 + +—— [Seth Kenlon][14] + +以前有句俗话叫“不要随便使用杂志封面上宣传的发行版,使用你朋友都在用的,当你遇到问题时才能更好地需求帮助”。将关键词“杂志封面”替换为“互联网”,这句话依然有效 : -) 。我从未听从过这个建议,因为我是方圆五十公里内唯一使用 Linux 的人,周围的人都在用 FreeBSD、IRIX、Solaris 和 Windows 3.11 等操作系统,最后,我就是那个被人们寻求 Linux 帮助的人。 + +—— [Peter Czanik][15] + +### 6、坚持学习 Linux + +在到 Red Hat 工作前,我是一名分销商合作伙伴,我有几个提供旅行护士的家庭健康代理机构客户,他们使用了一个叫“Carefacts”的软件包,最初用于 DOS,在旅行笔记本电脑和中心数据库同步中总是出错。 + +早期我听到的最好建议是认真研究一下开源运动。开源在 2022 年是主流思想,但在一代人以前,从 Red Hat 的零售商购买 Linux 安装光盘是带有革命性的创新行为。开源打破了常规,我认为要客观看待开源,但确实惊叹到了相当一部分人。 + +我的公司在 20 世纪 90 年代中期搭建了第一个客户防火墙,那是基于 Windows NT 和 Altavista 的一个产品,但是经常发生错误崩溃。我们自己又搭建了一个基于 Linux 的防火墙,再也没有出问题了。因此,我们用 Linux 替换了客户的那套 Altavista 系统,稳定地运行了多年。我们在 1999 年底搭建了另一个客户防火墙,当时我花三周读完了一本关书,介绍了数据包过滤和 ipchains 的正确使用,当我完成时感觉超赞,它解决了所有问题。在接下来的 15 年,我搭建安装了数百个防火墙系统,主要采用 iptables 技术,有些利用桥接或 ARP 代理以及 QOS 保障视频会议传输,有些利用 IPSEC 和 OpenVPN 隧道。我靠管理个人防火墙和一些双机热备系统赚取生活费,非常不错,而以前都是用的 Windows 系统。我甚至还建了一些虚拟防火墙。 + +但是技术在高速发展,2022 年,iptables 已过时,我以前的防火墙技术也成了美好的回忆。 + +目前的经验之谈?永远不要停止探索。 + +—— [Greg Scott][19] + +### 7、享受过程 + +耐心点,Linux 和之前你熟悉的操作系统不太相同,准备拥抱一个充满无限可能的新世界,尽情享受吧。 + +—— [Alex Callejas][20] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/5/linux-advice-beginners + +作者:[Opensource.com][a] +选题:[lkxed][b] +译者:[lightchaserhy](https://github.com/lightchaserhy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/admin +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/yearbook-haff-rx-linux-file-lead_0.png +[2]: https://opensource.com/users/don-watkins +[3]: https://opensource.com/users/greg-p +[4]: https://opensource.com/users/alanfdoss +[5]: https://linuxfromscratch.org/ +[6]: https://opensource.com/users/sumantro +[7]: https://ask.fedoraproject.org +[8]: https://opensource.com/users/smorris12 +[9]: https://opensource.com/users/hej +[10]: https://opensource.com/downloads/linux-common-commands-cheat-sheet +[11]: https://opensource.com/article/22/2/why-i-love-linux-kde +[12]: https://opensource.com/users/rcheesley +[13]: https://opensource.com/users/peppe8o +[14]: https://opensource.com/users/seth +[15]: https://opensource.com/users/czanik +[16]: https://www.redhat.com/sysadmin/run-your-own-vpn-libreswan +[17]: https://opensource.com/article/21/8/openvpn-server-linux +[18]: https://opensource.com/article/19/7/make-linux-stronger-firewalls +[19]: https://opensource.com/users/greg-scott +[20]: https://opensource.com/users/darkaxl diff --git a/translated/tech/20220524 Collision- Linux App to Verify ISO and Other Files.md b/published/202206/20220524 Collision- Linux App to Verify ISO and Other Files.md similarity index 66% rename from translated/tech/20220524 Collision- Linux App to Verify ISO and Other Files.md rename to published/202206/20220524 Collision- Linux App to Verify ISO and Other Files.md index 7d59ad4431..a60f32620a 100644 --- a/translated/tech/20220524 Collision- Linux App to Verify ISO and Other Files.md +++ b/published/202206/20220524 Collision- Linux App to Verify ISO and Other Files.md @@ -3,21 +3,24 @@ [#]: author: "Arindam https://www.debugpoint.com/author/admin1/" [#]: collector: "lkxed" [#]: translator: "geekpi" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14671-1.html" Collision:用于验证 ISO 和其他文件的 Linux 应用 ====== -本教程概述了 Collision 的功能和使用指南。它是一个基于 GUI 且易于使用的程序,可让你使用加密哈希函数验证文件。 + +![](https://img.linux.net.cn/data/attachment/album/202206/04/111427jzkwsocv4oug3vso.jpg) + +> 本教程概述了 Collision 的功能和使用指南。它是一个基于 GUI 且易于使用的程序,可让你使用加密哈希函数验证文件。 ### 为什么需要验证文件? -每个人每天都通过 Internet 下载文件。但许多用户从不费心去验证他们的完整性或真实性。这意味着该文件是否合法且未被任何恶意代码篡改。 +人们每天都通过互联网下载文件。但许多用户从不费心去验证他们的完整性或真实性。这意味着不知道该文件是否合法且未被任何恶意代码篡改。 -以作为标准安装镜像的 [Linux 发行版][1]的 ISO 文件为例。所有流行的发行版制造商还提供哈希文件和 ISO 文件。使用该文件,你可以轻松比较下载文件的哈希值。你可以放心,你的文件是正确的并且没有以任何方式损坏。 +以作为标准安装镜像的 [Linux 发行版][1] 的 ISO 文件为例。所有流行的发行版制造商在 ISO 文件还提供哈希文件。使用该文件,你可以轻松比较下载文件的哈希值。让你可以放心你的文件是正确的并且没有以任何方式损坏。 -此外,如果你通过不稳定的互联网连接下载大文件,该文件可能会损坏。在这些情况下,它也有助于验证。 +此外,如果你通过不稳定的互联网连接下载大文件,该文件可能会损坏。在这些情况下,它也有需要验证。 ### Collision – 功能和使用方法 @@ -27,29 +30,29 @@ Collision:用于验证 ISO 和其他文件的 Linux 应用 ![Collision – First Screen][3] -首先,它有两个主要特点。 a) 上传文件以获取校验和和或哈希值 b) 将校验和与上传的文件进行比较。 +首先,它有两个主要特点。 a、上传文件以获取校验和和或哈希值;b、将校验和与上传的文件进行比较。 -例如,如果你有一个简单的文件,你可以通过“打开文件”按钮或“打开”按钮重新上传另一个文件。 +例如,如果你有一个简单的文件,你可以通过“打开文件Open a File”按钮上传一个文件,或“打开Open”按钮重新上传另一个文件。 -如下图所示,文本文件具有以下各种哈希函数的校验和。现在你可以通过互联网/与任何人共享该文件,以及用于验证的校验和值。 +如下图所示,该文本文件具有以下各种哈希函数的校验和。现在你可以通过互联网/与任何人共享该文件,以及用于验证的校验和值。 ![Hash values of a test file][4] 此外,如果有人篡改文件(即使是单个字节)或文件在分发过程中被破坏,那么哈希值就会完全改变。 -其次,如果要验证已下载文件的完整性,请点击“验证”选项卡。然后上传文件,输入你收到的上传文件的哈希值。 +其次,如果要验证已下载文件的完整性,请点击“验证Verify”选项卡。然后上传文件,输入你收到的上传文件的哈希值。 如果匹配,你应该会看到一个绿色勾号,显示其真实性。 ![Collision verifies a sample file with SHA-256][5] -此外,这是另一个示例,我修改了测试文件并保持值相同。这个场景清楚地表明它对该文件无效。 +此外,这是另一个示例,我修改了测试文件并保持大小相同。这个场景清楚地表明它对该文件无效。 ![Collision showing that a file is not valid][6] #### 重要说明 -这里值得一提的是,哈希方法不会验证文件元属性,如修改时间、修改日期等。如果有人篡改了文件并将其还原为原始内容,哈希方法将其称为有效文件。 +这里值得一提的是,哈希方法不会验证文件元属性,如修改时间、修改日期等。如果有人篡改了文件并将其还原为原始内容,这种哈希方式将其称为有效文件。 现在,让我们看一个验证 ISO 文件的典型示例。 @@ -59,21 +62,21 @@ Collision:用于验证 ISO 和其他文件的 Linux 应用 ![Ubuntu server ISO file and checksums][7] -SHA256SUMS 文件具有以下安装程序的校验和值,如上所示。 +`SHA256SUMS` 文件带有上面的该安装程序的以下校验和值: ![SHA-256 value of Ubuntu server ISO image][8] -下载后,打开 Collision 应用并通过验证选项卡上传 ISO 文件。然后复制 SHA-256 值并将其粘贴到左侧的校验和框中。 +下载后,打开 Collision 应用并通过“验证Verify”选项卡上传 ISO 文件。然后复制 SHA-256 值并将其粘贴到左侧的校验和框中。 -如果你已正确下载并按照步骤操作,你应该会看到该文件是真实的。 +如果你已正确下载并按照步骤操作,你应该会看到该文件是真实有效的。 ![Ubuntu server ISO image verified][9] ### 如何安装 Collision -使用 Flatpak 可以轻松安装 Collision 应用。你需要为你的 Linux 发行版[设置 Flatpak][10],并单击以下链接以安装 Collision。 +使用 Flatpak 可以轻松安装 Collision 应用。你需要为你的 Linux 发行版 [设置 Flatpak][10],并单击以下链接以安装 Collision。 -[通过 Flathub 安装 Collision][11] +> **[通过 Flathub 安装 Collision][11]** 安装后,你应该通过发行版的应用菜单找到它。 @@ -101,7 +104,7 @@ sha256sum <文件名> ### 结束语 -我希望本指南可以帮助你使用 Collision GTK 应用验证你的文件。它使用起来很简单。此外,你可以在终端中使用命令行方法来验证您想要的任何文件。另外,最好的做法是尽可能始终检查文件完整性。 +我希望本指南可以帮助你使用 Collision GTK 应用验证你的文件。它使用起来很简单。此外,你可以在终端中使用命令行方法来验证您想要的任何文件。尽可能始终检查文件完整性总是应该的。 -------------------------------------------------------------------------------- @@ -110,7 +113,7 @@ via: https://www.debugpoint.com/2022/05/collision/ 作者:[Arindam][a] 选题:[lkxed][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/202206/20220524 How to Install KVM on Ubuntu 22.04 -Jammy Jellyfish-.md b/published/202206/20220524 How to Install KVM on Ubuntu 22.04 -Jammy Jellyfish-.md new file mode 100644 index 0000000000..c60fbf2e57 --- /dev/null +++ b/published/202206/20220524 How to Install KVM on Ubuntu 22.04 -Jammy Jellyfish-.md @@ -0,0 +1,264 @@ +[#]: subject: "How to Install KVM on Ubuntu 22.04 (Jammy Jellyfish)" +[#]: via: "https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/" +[#]: author: "James Kiarie https://www.linuxtechi.com/author/james/" +[#]: collector: "lkxed" +[#]: translator: "turbokernel" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14661-1.html" + +Ubuntu 22.04 之 KVM 安装手札 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/01/171619m6dd7bjb8292bbb9.jpg) + +**KVM** 是 基于内核的虚拟机Kernel-based Virtual Machine 的首字母缩写,这是一项集成在内核中的开源虚拟化技术。它是一种类型一(裸机)的管理程序hypervisor,可以使内核能够作为一个裸机管理程序bare-metal hypervisor。 + +在 KVM 之上可以运行 Windows 和 Liunx 虚拟机。每个虚拟机都独立于其它虚拟机和底层操作系统(宿主机系统),并拥有自己的 CPU、内存、网络接口、存储设备等计算资源。 + +本文将介绍在 Ubuntu 22.04 LTS(Jammy Jellyfish)中如何安装 KVM 。在文末,我们也将演示如何在安装 KVM 完成之后创建一台虚拟机。 + +### 1、更新 Ubuntu 22.04 + +在一切开始前,打开终端并通过如下命令更新本地的软件包索引: + +``` +$ sudo apt update +``` + +### 2、检查虚拟化是否开启 + +在进一步行动之前,首先需要检查你的 CPU 是否支持 KVM 虚拟化,确保你系统中有 VT-x( vmx)英特尔处理器或 AMD-V(svm)处理器。 + +你可以通过运行如下命令,如果输出值大于 0,那么虚拟化被启用。否则,虚拟化被禁用,你需要启用它: + +``` +$ egrep -c '(vmx|svm)' /proc/cpuinfo +``` + +![SVM-VMX-Flags-Cpuinfo-linux][1] + +根据上方命令输出,你可以推断出虚拟化功能已经启用,因为输出结果大于 0。如果虚拟化功能没有启用,请确保在系统的 BIOS 设置中启用虚拟化功能。 + +另外,你可以通过如下命令判断 KVM 虚拟化是否已经在运行: + +``` +$ kvm-ok +``` + +运行该命令之前,请确保你已经安装了 `cpu-checker` 软件包,否则将提示未找到该命令的报错。 + +直接就在下面,你会得到如何解决这个问题的指示,那就是安装 `cpu-checker` 包。 + +![KVM-OK-Command-Not-Found-Ubuntu][2] + +随后,通过如下命令安装 `cpu-checker` 软件包: + +``` +$ sudo apt install -y cpu-checker +``` + +接着再运行 `kvm-ok` 命令,如果 KVM 已经启动,你将看到如下输出: + +``` +$ kvm-ok +``` + +![KVM-OK-Command-Output][3] + +### 3、在 Ubuntu 22.04 上安装 KVM + +随后,通过如下命令在 Ubuntu 22.04 中安装 KVM 以及其他相关虚拟化软件包: + +``` +$ sudo apt install -y qemu-kvm virt-manager libvirt-daemon-system virtinst libvirt-clients bridge-utils +``` + +以下为你解释刚刚安装了哪些软件包: + +* `qemu-kvm` – 一个提供硬件仿真的开源仿真器和虚拟化包 +* `virt-manager` – 一款通过 libvirt 守护进程,基于 QT 的图形界面的虚拟机管理工具 +* `libvirt-daemon-system` – 为运行 libvirt 进程提供必要配置文件的工具 +* `virtinst` – 一套为置备和修改虚拟机提供的命令行工具 +* `libvirt-clients` – 一组客户端的库和API,用于从命令行管理和控制虚拟机和管理程序 +* `bridge-utils` – 一套用于创建和管理桥接设备的工具 + +### 4、启用虚拟化守护进程(libvirtd) + +在所有软件包安装完毕之后,通过如下命令启用并启动 libvirt 守护进程: + +``` +$ sudo systemctl enable --now libvirtd +$ sudo systemctl start libvirtd +``` + +你可以通过如下命令验证该虚拟化守护进程是否已经运行: + +``` +$ sudo systemctl status libvirtd +``` + +![Libvirtd-Status-Ubuntu-Linux][4] + +另外,请将当前登录用户加入 `kvm` 和 `libvirt` 用户组,以便能够创建和管理虚拟机。 + +``` +$ sudo usermod -aG kvm $USER +$ sudo usermod -aG libvirt $USER +``` + +`$USER` 环境变量引用的即为当前登录的用户名。你需要重新登录才能使得配置生效。 + +### 5、创建网桥(br0) + +如果你打算从本机(Ubuntu 22.04)之外访问 KVM 虚拟机,你必须将虚拟机的网卡映射至网桥。`virbr0` 网桥是 KVM 安装完成后自动创建的,仅做测试用途。 + +你可以通过如下内容在 `/etc/netplan` 目录下创建文件 `01-netcfg.yaml` 来新建网桥: + +``` +$ sudo vi /etc/netplan/01-netcfg.yaml +network: +  ethernets: +    enp0s3: +      dhcp4: false +      dhcp6: false +  # add configuration for bridge interface +  bridges: +    br0: +      interfaces: [enp0s3] +      dhcp4: false +      addresses: [192.168.1.162/24] +      macaddress: 08:00:27:4b:1d:45 +      routes: +        - to: default +          via: 192.168.1.1 +          metric: 100 +      nameservers: +        addresses: [4.2.2.2] +      parameters: +        stp: false +      dhcp6: false +  version: 2 +``` + +保存并退出文件。 + +注:上述文件的配置是我环境中的,请根据你实际环境替换 IP 地址、网口名称以及 MAC 地址。 + +你可以通过运行 `netplan apply` 命令应用上述变更。 + +``` +$ sudo netplan apply +``` + +你可以通过如下 `ip` 命令,验证网桥 `br0`: + +``` +$ ip add show +``` + +![Network-Bridge-br0-ubuntu-linux][5] + +### 6、启动 KVM 虚拟机管理器 + +当 KVM 安装完成后,你可以使用图形管理工具 `virt-manager` 创建虚拟机。你可以在 GNOME 搜索工具中搜索 `Virtual Machine Manager` 以启动。 + +点击搜索出来的图标即可: + +![Access-Virtual-Machine-Manager-Ubuntu-Linux][6] + +虚拟机管理器界面如下所示: + +![Virtual-Machine-Manager-Interface-Ubuntu-Linux][7] + +你可以点击 “文件File” 并选择 “新建虚拟机New Virtual Machine”。你也可以点击下图所示的图标: + +![New-Virtual-Machine-Icon-Virt-Manager][8] + +在弹出的虚拟机安装向导将看到如下四个选项: + +* 本地安装介质(ISO 镜像或 CDROM) +* 网络安装(HTTP、HTTPS 和 FTP) +* 导入现有磁盘镜像 +* 手动安装 + +本文使用已下载的 ISO 镜像,你可以选择自己的 ISO 镜像,选择第一个选项,并点击 “向前Forward”。 + +![Local-Install-Media-ISO-Virt-Manager][9] + +下一步中,点击 “浏览Browse” 选择 ISO 镜像位置。 + +![Browse-ISO-File-Virt-Manager-Ubuntu-Linux][10] + +在下一个窗口中点击 “浏览本地Browse local” 选取本机中 ISO 镜像。 + +![Browse-Local-ISO-Virt-Manager][11] + +如下所示,我们选择了 Debian 11 ISO 镜像,随后点击 “打开Open”。 + +![Choose-ISO-File-Virt-Manager][12] + +当 ISO 镜像选择后,点击 “向前Forward” 进入下一步。 + +![Forward-after-browsing-iso-file-virt-manager][13] + +接着定义虚拟机所用内存大小以及 CPU 核心数,并点击 “向前Forward” 。 + +![Virtual-Machine-RAM-CPU-Virt-Manager][14] + +下一步中,输入虚拟机磁盘空间,并点击 “向前Forward” 继续。 + +![Storage-for-Virtual-Machine-KVM-Virt-Manager][15] + +如你需要将虚拟机网卡连接至网桥,点击 “选择网络Network selection” 并选择 `br0` 网桥。 + +![Network-Selection-KVM-Virtual-Machine-Virt-Manager][16] + +最后,点击 “完成Finish” 按钮结束设置虚拟机。 + +![Choose-Finish-to-OS-Installation-KVM-VM][17] + +稍等片刻,虚拟机的创建过程将开始。 + +![Creating-Domain-Virtual-Machine-Virt-Manager][18] + +当创建结束时,虚拟机将开机并进入系统安装界面。如下是 Debian 11 的安装选项。在这里你可以根据需要进行系统安装。 + +![Virtual-Machine-Console-Virt-Manager][19] + +### 小结 + +至此,本文向你演示了如何在 Ubuntu 22.04 上 安装 KVM 虚拟化引擎。你的反馈对我们至关重要。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ + +作者:[James Kiarie][a] +选题:[lkxed][b] +译者:[turbokernel](https://github.com/turbokernel) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/james/ +[b]: https://github.com/lkxed +[1]: https://www.linuxtechi.com/wp-content/uploads/2022/05/SVM-VMX-Flags-Cpuinfo-linux.png +[2]: https://www.linuxtechi.com/wp-content/uploads/2022/05/KVM-OK-Command-Not-Found-Ubuntu.png +[3]: https://www.linuxtechi.com/wp-content/uploads/2022/05/KVM-OK-Command-Output.png +[4]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Libvirtd-Status-Ubuntu-Linux.png +[5]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Network-Bridge-br0-ubuntu-linux.png +[6]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Access-Virtual-Machine-Manager-Ubuntu-Linux.png +[7]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Virtual-Machine-Manager-Interface-Ubuntu-Linux.png +[8]: https://www.linuxtechi.com/wp-content/uploads/2022/05/New-Virtual-Machine-Icon-Virt-Manager.png +[9]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Local-Install-Media-ISO-Virt-Manager.png +[10]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Browse-ISO-File-Virt-Manager-Ubuntu-Linux.png +[11]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Browse-Local-ISO-Virt-Manager.png +[12]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Choose-ISO-File-Virt-Manager.png +[13]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Forward-after-browsing-iso-file-virt-manager.png +[14]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Virtual-Machine-RAM-CPU-Virt-Manager.png +[15]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Storage-for-Virtual-Machine-KVM-Virt-Manager.png +[16]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Network-Selection-KVM-Virtual-Machine-Virt-Manager.png +[17]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Choose-Finish-to-OS-Installation-KVM-VM.png +[18]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Creating-Domain-Virtual-Machine-Virt-Manager.png +[19]: https://www.linuxtechi.com/wp-content/uploads/2022/05/Virtual-Machine-Console-Virt-Manager.png diff --git a/published/202206/20220525 Machine Learning- Classification Using Python.md b/published/202206/20220525 Machine Learning- Classification Using Python.md new file mode 100644 index 0000000000..0ae672fac4 --- /dev/null +++ b/published/202206/20220525 Machine Learning- Classification Using Python.md @@ -0,0 +1,108 @@ +[#]: subject: "Machine Learning: Classification Using Python" +[#]: via: "https://www.opensourceforu.com/2022/05/machine-learning-classification-using-python/" +[#]: author: "Gayatri Venugopal https://www.opensourceforu.com/author/gayatri-venugopal/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "turbokernel" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14676-1.html" + +机器学习:使用 Python 进行分类 +====== + +> 机器学习(ML)就是,分析一组数据以预测结果。Python 被认为是 ML 的最佳编程语言选择之一。在本文中,我们将讨论使用 Python 进行分类的机器学习。 + +![machine-learning-classification][1] + +假设你想教孩子区分苹果和橙子。有多种方法可以做到这一点。你可以让孩子触摸这两种水果,让他们熟悉形状和柔软度。你还可以向她展示苹果和橙子的多个例子,以便他们可以直观地发现差异。这个过程的技术等价物被称为机器学习。 + +机器学习教计算机解决特定问题,并通过经验变得更好。这里讨论的示例是一个分类问题,其中机器被赋予各种标记示例,并期望使用它从标记样本中获得的知识来对未标记样本进行标记。机器学习问题也可以采用回归的形式,其中期望根据已知样本及其解决方案来预测给定问题的实值real-valued解决方案。分类Classification回归Regression被广泛称为监督学习supervised learning。机器学习也可以是无监督unsupervised的,机器识别未标记数据中的模式,并形成具有相似模式的样本集群。机器学习的另一种形式是强化学习reinforcement learning,机器通过犯错从环境中学习。 + +### 分类 + +分类是根据从已知点获得的信息来预测一组给定点的标签的过程。与一个数据集相关的类别或标签可以是二元的,也可以是多元的。举例来说,如果我们必须给与一个句子相关的情绪打上标签,我们可以把它标记为正面、负面或中性。另一方面,我们必须预测一个水果是苹果还是橘子的问题将有二元标签。表 1 给出了一个分类问题的样本数据集。 + +在该表中,最后一列的值,即贷款批准,预计将基于其他变量进行预测。在接下来的部分中,我们将学习如何使用 Python 训练和评估分类器。 + +| 年龄 | 信用等级 | 工作 | 拥有房产 | 贷款批准 | +| :- | :- | :- | :- | :- | +| 35 | 好 | 是 | 是 | 是 | +| 32 | 差 | 是 | 不 | 不 | +| 22 | 一般 | 不 | 不 | 不 | +| 42 | 好 | 是 | 不 | 是 | + +*表 1* + +### 训练和评估分类器 + +为了训练分类器classifier,我们需要一个包含标记示例的数据集。尽管本节不涉及清理数据的过程,但建议你在将数据集输入分类器之前阅读各种数据预处理和清理技术。为了在 Python 中处理数据集,我们将导入 `pandas` 包和数据帧DataFrame结构。然后,你可以从多种分类算法中进行选择,例如决策树decision tree支持向量分类器support vector classifier随机森林random forest、XG boost、ADA boost 等。我们将看看随机森林分类器,它是使用多个决策树形成的集成分类器。 + +``` +from sklearn.ensemble import RandomForestClassifier +from sklearn import metrics + +classifier = RandomForestClassifier() + +#creating a train-test split with a proportion of 70:30 +X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33) + +classifier.fit(X_train, y_train) # 在训练集上训练分类器 + +y_pred = classifier.predict(X_test) # 用未知数据评估分类器 + +print("Accuracy: ", metrics.accuracy_score(y_test, y_pred)) # 用测试计划中的实际值比较准确率 +``` + +虽然这个程序使用准确性作为性能指标,但应该使用多种指标的组合,因为当测试集不平衡时,准确性往往会产生非代表性的结果。例如,如果模型对每条记录都给出了相同的预测,而用于测试模型的数据集是不平衡的,即数据集中的大多数记录与模型预测的类别相同,我们就会得到很高的准确率。 + +### 调整分类器 + +调优是指修改模型的超参数hyperparameter值以提高其性能的过程。超参数是可以改变其值以改进算法的学习过程的参数。 + +以下代码描述了随机搜索超参数调整。在此,我们定义了一个搜索空间,算法将从该搜索空间中选择不同的值,并选择产生最佳结果的那个: + +``` +from sklearn.model_selection import RandomizedSearchCV + +#define the search space +min_samples_split = [2, 5, 10] +min_samples_leaf = [1, 2, 4] +grid = {‘min_samples_split’ : min_samples_split, ‘min_samples_leaf’ : min_samples_leaf} + +classifier = RandomizedSearchCV(classifier, grid, n_iter = 100) + +# n_iter 代表从搜索空间提取的样本数 +# result.best_score 和 result.best_params_ 可以用来获得模型的最佳性能,以及参数的最佳值 + +classifier.fit(X_train, y_train) +``` + +### 投票分类器 + +你也可以使用多个分类器和它们的预测来创建一个模型,根据各个预测给出一个预测。这个过程(只考虑为每个预测投票的分类器的数量)被称为硬投票。软投票是一个过程,其中每个分类器产生一个给定记录属于特定类别的概率,而投票分类器产生的预测是获得最大概率的类别。 + +下面给出了一个创建软投票分类器的代码片段: + +``` +soft_voting_clf = VotingClassifier( +estimators=[(‘rf’, rf_clf), (‘ada’, ada_clf), (‘xgb’, xgb_clf), (‘et’, et_clf), (‘gb’, gb_clf)], +voting=’soft’) +soft_voting_clf.fit(X_train, y_train) +``` + +这篇文章总结了分类器的使用,调整分类器和结合多个分类器的结果的过程。请将此作为一个参考点,详细探讨每个领域。 + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/05/machine-learning-classification-using-python/ + +作者:[Gayatri Venugopal][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[turbokernel](https://github.com/turbokernel) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/gayatri-venugopal/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/04/machine-learning-classification.jpg diff --git a/translated/tech/20220525 Package is -set to manually installed-- What does it Mean-.md b/published/202206/20220525 Package is -set to manually installed-- What does it Mean-.md similarity index 61% rename from translated/tech/20220525 Package is -set to manually installed-- What does it Mean-.md rename to published/202206/20220525 Package is -set to manually installed-- What does it Mean-.md index 13f06a1f14..127e111531 100644 --- a/translated/tech/20220525 Package is -set to manually installed-- What does it Mean-.md +++ b/published/202206/20220525 Package is -set to manually installed-- What does it Mean-.md @@ -3,62 +3,67 @@ [#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" [#]: collector: "lkxed" [#]: translator: "geekpi" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14675-1.html" -软件包 “set to manually installed”?这是什么意思? +软件包 “被标记为手动安装”?这是什么意思? ====== -如果你使用 apt 命令在终端中安装软件包,你将看到各种输出。 + +![](https://img.linux.net.cn/data/attachment/album/202206/05/154517uqnqdfi79yqidi79.jpg) + +如果你使用 `apt` 命令在终端中安装软件包,你将看到各种输出。 如果你注意并查看输出,有时你会注意到一条消息: -**package_name set to manually installed** +``` +package_name set to manually installed +``` 你有没有想过这条消息是什么意思,为什么你没有在所有包上看到它?让我在本篇中分享一些细节。 -### 理解 “Package set to manually installed” +### 理解 “软件包被标记为手动安装” -当你尝试安装已安装的库或开发包时,你会看到此消息。此依赖包是与另一个包一起自动安装的。如果删除了主包,则使用 apt autoremove 命令删除依赖包。 +当你尝试安装已安装的库或开发包时,你会看到此消息。此依赖包是与另一个包一起自动安装的。如果删除了主包,则使用 `apt autoremove` 命令删除依赖包。 但是由于你试图显式安装依赖包,你的 Ubuntu 系统认为你需要这个包独立于主包。因此,该软件包被标记为手动安装,因此不会自动删除。 -不是很清楚,对吧?以[在 Ubuntu 上安装 VLC][1] 为例。 +不是很清楚,对吧?以 [在 Ubuntu 上安装 VLC][1] 为例。 -由于主 vlc 包依赖于许多其他包,因此这些包会自动安装。 +由于主 VLC 包依赖于许多其他包,因此这些包会自动安装。 ![installing vlc with apt ubuntu][2] -如果你检查名称中包含 vlc 的[已安装软件包列表][3],你会看到除了 vlc,其余都标记为“自动”。这表明这些软件包是自动安装的(使用 vlc),它们将使用 apt autoremove 命令自动删除(当 vlc 被卸载时)。 +如果你检查名称中包含 `vlc` 的 [已安装软件包列表][3],你会看到除了 VLC,其余都标记为“自动”。这表明这些软件包是(跟着 vlc)自动安装的,当 VLC 被卸载时,它们将使用 `apt autoremove` 命令自动删除。 ![list installed packages vlc ubuntu][4] -现在假设你出于某种原因考虑安装 “vlc-plugin-base”。如果你在其上运行 apt install 命令,系统会告诉你该软件包已安装。同时,它将标记从自动更改为手动,因为系统认为你在尝试手动安装时明确需要此 vlc-plugin-base。 +现在假设你出于某种原因考虑安装 `vlc-plugin-base`。如果你在其上运行 `apt install` 命令,系统会告诉你该软件包已安装。同时,它将标记从自动更改为手动,因为系统认为在尝试手动安装表明你明确需要此 `vlc-plugin-base`。 ![package set manually][5] -可以看到它的状态已经从 [installed,automatic] 变成了 [installed]。 +可以看到它的状态已经从 `[installed,automatic]` 变成了 `[installed]`。 ![listing installed packages with vlc][6] -现在,让我删除 VLC 并运行 autoremove 命令。你可以看到 “vlc-plugin-base” 不在要删除的软件包列表中。 +现在,让我删除 VLC 并运行 `autoremove` 命令。你可以看到 `vlc-plugin-base` 不在要删除的软件包列表中。 ![autoremove vlc ubuntu][7] -再次检查已安装软件包的列表。vlc-plugin-base 仍然安装在系统上。 +再次检查已安装软件包的列表。`vlc-plugin-base` 仍然安装在系统上。 ![listing installed packages after removing vlc][8] -你可以在这里看到另外两个与 vlc 相关的包。这些是 vlc-plugin-base 包的依赖项,这就是为什么它们也存在于系统上但标记为 “automatic” 的原因。 +你可以在这里看到另外两个与 VLC 相关的包。这些是 `vlc-plugin-base` 包的依赖项,这就是为什么它们也存在于系统上但标记为 `automatic` 的原因。 -我相信现在有了这些例子,事情就更清楚了。让我给你一个额外提示。 +我相信现在有了这些例子,事情就更清楚了。让我给你一个额外的技巧。 ### 将包重置为自动 如果包的状态从自动更改为手动,你可以通过以下方式将其设置回自动: ``` -sudo apt-mark auto 包名 +sudo apt-mark auto package_name ``` ![set package to automatic][9] @@ -67,7 +72,7 @@ sudo apt-mark auto 包名 这不是一个重大错误,也不会阻止你在系统中进行工作。但是,了解这些小事会增加你的知识。 -**好奇心可能会害死猫,但它会让企鹅变得更聪明**。这是为这篇原本枯燥的文章增添幽默感的原始引述 :) +**好奇心可能会害死猫,但它会让企鹅变得更聪明**。这是为这篇原本枯燥的文章增添幽默感的原始引述 : ) 如果你想阅读更多这样的文章,这些文章可能看起来微不足道,但可以帮助你更好地了解您的 Linux 系统,请告诉我。 @@ -78,7 +83,7 @@ via: https://itsfoss.com/package-set-manually-installed/ 作者:[Abhishek Prakash][a] 选题:[lkxed][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/202206/20220527 TypeScript Based Headless CMS -Payload- Becomes Open Source.md b/published/202206/20220527 TypeScript Based Headless CMS -Payload- Becomes Open Source.md new file mode 100644 index 0000000000..6e41f831e1 --- /dev/null +++ b/published/202206/20220527 TypeScript Based Headless CMS -Payload- Becomes Open Source.md @@ -0,0 +1,80 @@ +[#]: subject: "TypeScript Based Headless CMS ‘Payload’ Becomes Open Source" +[#]: via: "https://news.itsfoss.com/payload-open-source/" +[#]: author: "Jacob Crume https://news.itsfoss.com/author/jacob/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14660-1.html" + +基于 TypeScript 的无头内容管理系统 “Payload” 现已开源 +====== + +> 开源的无头Headless内容管理系统(CMS)列表中添加了一个新选项。它会是一个更好的无头 WordPress 替代品吗? + +![Payload][1] + +自从一年多前发布首个测试版以来,作为无头内容管理系统(CMS),Payload 已经逐渐在 Web 开发社区中给人们留下了深刻印象。先做一些背景介绍,Payload 是专门为更简单地开发网站、Web 应用或原生native应用而量身定制的内容管理系统。 + +最近,他们决定完全开源,现在,它已跻身 [可用的最佳开源内容管理系统][2] 之一。 + +然而,这也带来了一些问题:他们会采用怎么样的商业模式?Payload 内容管理系统的计划是什么?下面,就让我们简要地看一下吧! + +### Payload 为什么要开源? + +自 2021 年首次发布以来,Payload 已经收到了来自开源社区的许多贡献。正如 Payload 在他们 [最近的公告][3] 中所说,开源是一个重要的决定,它能够使项目能够达到的更高的高度,这是闭门造车做不到的。 + +![][4] + +此外,这种开放性通常会增加开发者社区的信任。这种信任也会延伸到商业,自然而然地转而成为开发者最支持、最信任的平台。 + +因此,Payload 正在切换到 MIT 许可证。这将允许任何人免费且不受限制地修改、分发和使用 Payload。 + +然而,Payload 仍然需要资金流入才能持续运营。那么,这就引出了一个问题,Payload 将如何盈利呢? + +### Payload 将如何盈利? + +与往常一样,Payload 需要一些财务支持才能维持运营。团队拿出了一个由两部分组成的计划,该计划既要为用户提供更多 以便利为中心convenience-focused 的功能,又要为 自托管self-hosted 客户提供难以置信的灵活性。 + +![][5] + +#### 企业许可证 + +此选项与其他开源 CMS 的软件服务极为相似。这些许可证将提供更高级的 SSO 选项,并为开发者保证 Payload 核心团队的响应时间。 + +这些许可证应该对大公司有吸引力,尤其是那些需要最大程度可靠性的公司。 + +#### 云主机 + +这个选项非常有吸引力,因为它结合了多种服务来创造最方便的体验。尽管传统托管仍然相当容易,但只要你为 Node 应用程序添加数据库、持久文件存储和其他基础设施,你就会面对四五个不同的服务,而这些服务都需要无缝协同工作。 + +应该注意的是,这不是必需的,Payload 仍然鼓励用户托管他们的实例。这项服务只是消除了与托管相关的大量费用和挑战而已。 + +截至目前,事情还没有敲定。但是,你可以关注 [GitHub][6] 上的讨论来跟踪事情的进展。 + +### 总结 + +作为一个新兴的 CMS 选项,很高兴看到 Payload 迈出了这一步,成为 WordPress 和其他选项的流行替代品。此外,在我看来,Payload 团队对他们的新业务模式充满信心,或许这预示着一个光明的未来(希望如此)。 + +> **[Payload 内容管理系统][7]** + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/payload-open-source/ + +作者:[Jacob Crume][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/05/payload-opensource.jpg +[2]: https://itsfoss.com/open-source-cms/ +[3]: https://payloadcms.com/blog/open-source +[4]: https://news.itsfoss.com/wp-content/uploads/2022/05/payloadcms-demo.png +[5]: https://news.itsfoss.com/wp-content/uploads/2022/05/payload-free-opensource-1024x576.jpg +[6]: https://github.com/payloadcms/payload +[7]: https://payloadcms.com/ diff --git a/published/202206/20220529 Compile GNOME Shell and Apps From Source [Beginner-s Guide].md b/published/202206/20220529 Compile GNOME Shell and Apps From Source [Beginner-s Guide].md new file mode 100644 index 0000000000..5620f379f6 --- /dev/null +++ b/published/202206/20220529 Compile GNOME Shell and Apps From Source [Beginner-s Guide].md @@ -0,0 +1,161 @@ +[#]: subject: "Compile GNOME Shell and Apps From Source [Beginner’s Guide]" +[#]: via: "https://www.debugpoint.com/2022/05/compile-gnome-source/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14662-1.html" + +如何从源码编译 GNOME Shell 和应用 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/01/180518p98dt89wz7779tyb.jpg) + +> 这是一篇如何从源码编译 GNOME 的快速指南,包括 Shell、mutter 和一些原生应用。 + +在编译之前,你需要确保一些事情,因为以下编译直接来自 Gitlab 的主分支,其中包含一些开发包。 + +通常,你可以选择在任何 Linux 发行版中编译。但是我建议使用 Fedora Rawhide(Fedora 的开发分支,用于将来的发布)。 + +另外,请勿在稳定系统中尝试此操作。因为操作可能出错,所以你可能最终得到损坏的系统。 + +总而言之,你需要以下内容来从源码编译 GNOME。 + +* 测试环境([虚拟机][1] 或测试系统)。 +* Fedora Rawhide 发行版(推荐,[从此处下载][2])。 +* 确保你的发行版是最新的。 +* 你已登录 X.org 会话。 + +我不建议你在 Wayland 会话中进行编译,因为你会遇到问题。 + +### 从源码编译 GNOME + +GNOME 桌面是一个基于其功能的软件包集合。Linux 发行版的桌面组件工作于窗口管理器和 shell 之下。 + +因此,对于 GNOME,我将首先编译 mutter – 它是 GNOME Shell 的窗口管理器。然后进行 GNOME Shell 的编译。最后,我将编译一些原生应用。 + +我将使用 meson 构建系统进行编译。meson 是一个漂亮的构建系统,快速且用户友好。 + +#### 编译 mutter + +打开终端并安装 GNOME Shell 和 mutter 所需的软件包。 + +``` +sudo dnf build-dep mutter gnome-shell +``` + +在主目录(或你想要的任何地方)中创建演示目录。 + +``` +cd ~ +mkdir demo +cd demo +``` + +从 Gitlab 克隆 mutter 的主分支。 + +``` +git clone https://gitlab.gnome.org/GNOME/mutter +``` + +进入克隆目录,然后使用以下 `meson` 命令来准备构建文件。默认情况下,meson 使用 `/usr/local` 用于构建文件。但是,你也可以使用前缀开关将输出重定向到特定文件夹(如下所示)。 + +``` +cd mutter +meson _build --prefix=/usr +``` + +![Compile Mutter for GNOME][3] + +使用以下命令在构建完成时,将 mutter 安装在到系统中。 + +``` +sudo ninja install -C _build +``` + +#### 编译 GNOME Shell + +GNOME Shell 和其他软件包的编译方法类似。首先,从 GitLab 克隆 GNOME Shell 主仓库,然后进行编译和安装。你可以按照下面的命令依次进行。 + +在 GNOME Shell 中,你需要两个依赖项。它们是 [asciidoc][4] 和 [sassc][5] 。请在构建 GNOME Shell 之前安装它们。 + +``` +sudo dnf install asciidoc +sudo dnf install sassc +``` + +安装完这些依赖项后,按照下面的命令来构建和安装 GNOME Shell。在运行这个命令之前,请确保你回到 `demo` 文件夹(我在第一步创建的)。 + +``` +git clone https://gitlab.gnome.org/GNOME/gnome-shellcd gnome-shellmeson _build --prefix=/usrsudo ninja install -C _build +``` + +### 运行 GNOME Shell + +编译完成后,你可以尝试重新启动 GNOME Shell 来查看来自主分支的变化。 + +在重启之前,正如我之前提到的,确保你处于 X.Org 会话中。按 `ALT+F2` 并输入 `r`。然后按回车键。这个命令将重启 GNOME Shell。 + +![Restart GNOME Shell (X11)][6] + +恭喜你! 你已经成功地编译了 GNOME Shell 和 Mutter。 + +现在,是时候编译一些 GNOME 原生应用了。 + +### 编译 GNOME 原生应用 + +这些步骤对于 GNOME 或任何应用的所有源码都是一样的。你需要改变仓库的名字。因此,这里有一些编译必要的 GNOME 原生应用的命令示例。 + +#### Files(Nautilus) + +``` +git clone https://gitlab.gnome.org/GNOME/nautilus/cd gnome-shellmeson _build --prefix=/usrsudo ninja install -C _build +``` + +#### GNOME 软件商店 + +``` +git clone https://gitlab.gnome.org/GNOME/gnome-software/cd gnome-shellmeson _build --prefix=/usrsudo ninja install -C _build +``` + +#### GNOME 控制中心 + +``` +git clone https://gitlab.gnome.org/GNOME/gnome-control-center/cd gnome-shellmeson _build --prefix=/usrsudo ninja install -C _build +``` + +### FAQ + +1. 使用上述步骤,你可以编译任何源码分支。不仅仅是 GNOME。 +2. GitLab 服务器有时很慢,克隆一个仓库可能需要较长的时间。如果 `git clone` 失败,我建议你再试一次。 + +### 结束语 + +我希望这个小小的高级教程能够帮助你在新的 GNOME 功能出现在 GNOME 每日构建系统之前尝试它。既然你编译了,你也可以为测试新的 GNOME 功能做出贡献,并在 GitLab 问题页面上报告任何特定包的 bug 或问题。 + +这篇文章是开源应用编译系列的第一篇文章。请继续关注更多开源应用的编译文章。 + +另外,请让我在下面的评论栏中知道你的评论、建议,或者你在使用这些说明时遇到的任何错误。 + +干杯。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2022/05/compile-gnome-source/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://www.debugpoint.com/tag/virtual-machine +[2]: https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Workstation/x86_64/iso/ +[3]: https://www.debugpoint.com/wp-content/uploads/2022/05/Compile-Mutter-for-GNOME.jpg +[4]: https://asciidoc.org/ +[5]: https://github.com/sass/sassc +[6]: https://www.debugpoint.com/wp-content/uploads/2022/05/Restart-GNOME-Shell-X11.jpg diff --git a/published/202206/20220530 Dynamically linking libraries while compiling code.md b/published/202206/20220530 Dynamically linking libraries while compiling code.md new file mode 100644 index 0000000000..200b9a7fda --- /dev/null +++ b/published/202206/20220530 Dynamically linking libraries while compiling code.md @@ -0,0 +1,136 @@ +[#]: subject: "Dynamically linking libraries while compiling code" +[#]: via: "https://opensource.com/article/22/5/compile-code-ldlibrarypath" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14690-1.html" + +编译代码时动态地链接库 +====== + +![](https://linux.cn/article-14690-1.html) + +> 编译软件在你如何运行你的系统方面给你很大的灵活性。`LD_LIBRARY_PATH` 变量,以及 GCC 的 `-L` 和 `-l` 选项,是这种灵活性的组成部分。 + +编译软件是开发者经常做的事情,在开源世界中,一些用户甚至选择自己动手。Linux 播客 Dann Washko 称源码为“通用包格式”,因为它包含了使一个应用在任何平台上运行所需的所有组件。当然,并不是所有的源码都是为所有的系统编写的,所以它只是在目标系统的子集内是“通用”的,但问题是,源码是非常灵活的。有了开源,你可以决定代码的编译和运行方式。 + +当你在编译代码时,你通常要处理多个源文件。开发人员倾向于将不同的类或模块放在不同的文件中,这样它们可以被单独维护,甚至可能被不同的项目使用。但当你编译这些文件时,许多文件会被编译成一个可执行文件。 + +这通常是通过创建共享库来完成的,然后从可执行文件中动态链接回它们。这样可以通过保持模块化功能的外部性来保持可执行文件的小型化,并确保库可以独立于使用它们的应用而被更新。 + +### 在编译过程中定位一个共享对象 + +当你 [用 GCC 编译][2] 时,你通常需要在你的工作站上安装一个库,以便 GCC 能够定位到它。默认情况下,GCC 假定库在系统库路径中,例如 `/lib64` 和 `/usr/lib64`。然而,如果你要链接到一个你自己的尚未安装的库,或者你需要链接到一个没有安装在标准位置的库,那么你必须帮助 GCC 找到这些文件。 + +有两个选项对于在 GCC 中寻找库很重要: + +* `-L`(大写字母 L)在 GCC 的搜索位置上增加一个额外的库路径。 +* `-l`(小写字母 L)设置你要链接的库的名字。 + +例如,假设你写了一个叫做 `libexample.so` 的库,并且你想在编译你的应用 `demo.c` 时使用它。首先,从 `demo.c` 创建一个对象文件: + +``` +$ gcc -I ./include -c src/demo.c +``` + +`-I` 选项在 GCC 搜索头文件的路径中增加了一个目录。在这个例子中,我假设自定义头文件在一个名为 `include` 的本地目录中。`-c` 选项防止 GCC 运行链接器,因为这个任务只是为了创建一个对象文件。结果如下: + +``` +$ ls +demo.o include/ lib/ src/ +``` + +现在你可以使用 `-L` 选项为你的库设置一个路径,然后进行编译: + +``` +$ gcc -L`pwd`/lib -o myDemo demo.o -lexample +``` + +注意,`-L` 选项在 `-l` 选项*之前*。这很重要,因为如果在你告诉 GCC 查找非默认库之前没有将 `-L` 添加到 GCC 的搜索路径中,GCC 就不知道要在你的自定义位置上搜索。编译成功了,但当你试图运行它时,却出现了问题: + +``` +$ ./myDemo +./myDemo: error while loading shared libraries: +libexample.so: cannot open shared object file: +No such file or directory +``` + +### 用 ldd 排除故障 + +`ldd` 工具可以打印出共享对象的依赖关系,它在排除类似问题时很有用: + +``` +$ ldd ./myDemo + linux-vdso.so.1 (0x00007ffe151df000) + libexample.so => not found + libc.so.6 => /lib64/libc.so.6 (0x00007f514b60a000) + /lib64/ld-linux-x86-64.so.2 (0x00007f514b839000) +``` + +你已经知道定位不到 `libexample`,但 `ldd` 输出至少确认了它对*工作*库的期望位置。例如,`libc.so.6 `已经被定位,`ldd` 显示其完整路径。 + +### LD_LIBRARY_PATH + +`LD_LIBRARY_PATH` [环境变量][3] 定义了库的路径。如果你正在运行一个依赖于没有安装到标准目录的库的应用程,你可以使用 `LD_LIBRARY_PATH` 添加到系统的库搜索路径。 + +有几种设置环境变量的方法,但最灵活的是在运行命令前放置环境变量。看看设置 `LD_LIBRARY_PATH` 对 `ldd` 命令在分析一个“损坏”的可执行文件时的作用: + +``` +$ LD_LIBRARY_PATH=`pwd`/lib ldd ./ + linux-vdso.so.1 (0x00007ffe515bb000) + libexample.so => /tmp/Demo/lib/libexample.so (0x0000... + libc.so.6 => /lib64/libc.so.6 (0x00007eff037ee000) + /lib64/ld-linux-x86-64.so.2 (0x00007eff03a22000) +``` + +这也同样适用于你的自定义命令: + +``` +$ LD_LIBRARY_PATH=`pwd`/lib myDemo +hello world! +``` + +然而,如果你移动库文件或可执行文件,它又会失效: + +``` +$ mv lib/libexample.so ~/.local/lib64 +$ LD_LIBRARY_PATH=`pwd`/lib myDemo +./myDemo: error while loading shared libraries... +``` + +要修复它,你必须调整 `LD_LIBRARY_PATH` 以匹配库的新位置: + +``` +$ LD_LIBRARY_PATH=~/.local/lib64 myDemo +hello world! +``` + +### 何时使用 LD_LIBRARY_PATH + +在大多数情况下,`LD_LIBRARY_PATH` 不是你需要设置的变量。按照设计,库安装到 `/usr/lib64` 中,因此应用自然会在其中搜索所需的库。在两种情况下,你可能需要使用 `LD_LIBRARY_PATH`: + +* 你正在编译的软件需要链接到本身刚刚编译但尚未安装的库。良好设计的构建系统,例如 [Autotools][4] 和 [CMake][5],可以帮助处理这个问题。 +* 你正在使用设计为在单个目录之外运行的软件,它没有安装脚本,或安装脚本将库放置在非标准目录中。一些应用具有 Linux 用户可以下载、复制到 `/opt` 并在“不安装”的情况下运行的版本。`LD_PATH_LIBRARY` 变量是通过封装脚本设置的,因此用户通常甚至不知道它已被设置。 + +编译软件为你在运行系统方面提供了很大的灵活性。`LD_LIBRARY_PATH` 变量以及 `-L` 和 `-l` GCC 选项是这种灵活性的组成部分。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/5/compile-code-ldlibrarypath + +作者:[Seth Kenlon][a] +选题:[lkxed][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/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/collab-team-pair-programming-code-keyboard2.png +[2]: https://opensource.com/article/22/5/what-happens-behind-scenes-during-gcc-compilation-c-programs +[3]: https://opensource.com/article/19/8/what-are-environment-variables +[4]: https://opensource.com/article/19/7/introduction-gnu-autotools +[5]: https://opensource.com/article/21/5/cmake diff --git a/published/202206/20220530 Using a Machine Learning Model to Make Predictions.md b/published/202206/20220530 Using a Machine Learning Model to Make Predictions.md new file mode 100644 index 0000000000..7fb0ad690d --- /dev/null +++ b/published/202206/20220530 Using a Machine Learning Model to Make Predictions.md @@ -0,0 +1,91 @@ +[#]: subject: "Using a Machine Learning Model to Make Predictions" +[#]: via: "https://www.opensourceforu.com/2022/05/using-a-machine-learning-model-to-make-predictions/" +[#]: author: "Jishnu Saurav Mittapalli https://www.opensourceforu.com/author/jishnu-saurav-mittapalli/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14689-1.html" + +机器学习:使用 Python 进行预测 +====== + +> 机器学习基本上是人工智能的一个子集,它使用以前存在的数据对新数据进行预测。 + +当然,现在我们所有人都知道这个道理了!这篇文章展示了如何将 Python 中开发的机器学习模型作为 Java 代码的一部分来进行预测。 + +![Machine-learning][1] + +本文假设你熟悉基本的开发技巧并理解机器学习。我们将从训练我们的模型开始,然后在 Python 中制作一个机器学习模型。 + +我以一个洪水预测模型为例。首先,导入以下库: + +``` +import pandas as pd +import numpy as np +import matplotlib.pyplot as plt +``` + +当我们成功地导入了这些库,我们就需要输入数据集,如下面的代码所示。为了预测洪水,我使用的是河流水位数据集。 + +``` +from google.colab import files +uploaded = files.upload() +for fn in uploaded.keys(): + print('User uploaded file "{name}" with length {length} bytes'.format(name=fn, length=len(uploaded[fn]))) +``` + +如果没有选择文件的话,选择上传的文件。 + +只有在当前浏览器会话中执行了该单元格时,上传部件才可用。请重新运行此单元,上传文件 `Hoppers Crossing-Hourly-River-Level.csv`,大小 2207036 字节。 + +完成后,我们就可以使用 `sklearn` 库来训练我们的模型。为此,我们首先需要导入该库和算法模型,如图 1 所示。 + +![Figure 1: Training the model][2] + +``` +from sklearn.linear_model import LinearRegression +regressor = LinearRegression() +regressor.fit(X_train, y_train) +``` + +完成后,我们就训练好了我们的模型,现在可以进行预测了,如图 2 所示。 + +![Figure 2: Making predictions][3] + +### 在 Java 中使用 ML 模型 + +我们现在需要做的是把 ML 模型转换成一个可以被 Java 程序使用的模型。有一个叫做 `sklearn2pmml` 的库可以帮助我们做到这一点: + +``` +# Install the library +pip install sklearn2pmml +``` + +库安装完毕后,我们就可以转换我们已经训练好的模型,如下图所示: + +``` +sklearn2pmml(pipeline, ‘model.pmml’, with_repr = True) +``` + +这就完成了!我们现在可以在我们的 Java 代码中使用生成的 `model.pmml` 文件来进行预测。请试一试吧! + +(LCTT 译注:Java 中有第三方库 [jpmml/jpmml-evaluator][4],它能帮助你使用生成的 `model.pmml` 进行预测。) + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/05/using-a-machine-learning-model-to-make-predictions/ + +作者:[Jishnu Saurav Mittapalli][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/jishnu-saurav-mittapalli/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/05/Machine-learning.jpg +[2]: https://www.opensourceforu.com/wp-content/uploads/2022/05/Figure-1Training-the-model.jpg +[3]: https://www.opensourceforu.com/wp-content/uploads/2022/05/Figure-2-Making-predictions.jpg +[4]: https://github.com/jpmml/jpmml-evaluator diff --git a/published/202206/20220601 GNOME Shell for Mobile- A Promising Start with Huge Expectations [Opinion].md b/published/202206/20220601 GNOME Shell for Mobile- A Promising Start with Huge Expectations [Opinion].md new file mode 100644 index 0000000000..878c857eba --- /dev/null +++ b/published/202206/20220601 GNOME Shell for Mobile- A Promising Start with Huge Expectations [Opinion].md @@ -0,0 +1,93 @@ +[#]: subject: "GNOME Shell for Mobile: A Promising Start with Huge Expectations [Opinion]" +[#]: via: "https://www.debugpoint.com/2022/06/gnome-shell-mobile-announcement/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14672-1.html" + +移动版 GNOME Shell:希望之始,期望满满 +====== + +![GNOME Shell 在一台 Pinephone 原型机上运行][3] + +> GNOME 开发人员在最近的一篇博文中提出了将 GNOME Shell 完全移植到手机上的想法。下面是我对这个项目的一些看法。 + +### 移动版 GNOME Shell + +作为一个桌面环境,GNOME 在过去的十年中发展成为了 [GNOME 40][1]。GNOME 40 是一个重要的版本,它以一种现代的方式改变了完整的用户界面设计。 + +看着 GNOME 40 的设计方式,你可能会觉得 Shell 和它的底层技术已经为小屏幕做好了准备。手势驱动的工作区、图标网格和停靠区 —— 在某种程度上感觉更接近于像安卓这样的移动操作系统,而不是桌面环境。 + +此外,系统托盘、日历、通知和原生的应用程序,可以有效地在较小尺寸的设备上工作。得益于 GTK4 和 libadwaita,其设计是响应式的,应用程序和控件的外观与移动平台很匹配。 + +在 GNOME 40 之后,GNOME 开发者为较小尺寸的设备(如平板电脑和手机)设计了几个 GNOME Shell 的概念验证。 + +#### 为什么是现在? + +任何项目的开发和研究工作都要花费时间和金钱。虽然有来自主要科技公司对 GNOME 的捐赠,但这次有一个 “原型基金Prototype Fund” 帮助该团队继续进行这项努力。[原型基金][2] 是德国教育部(BMBF)支持公共利益软件的资助项目。 + +#### 包括什么? + +设计一个完整的移动用户界面,并将其与移动操作系统整合是一个非常复杂的项目。它需要一个精心设计的愿景来支持成千上万的移动硬件和用户支持。更不用说,用户在移动设备上的隐私和安全问题了。 + +因此,有了这个基金,团队可以集中精力进行概念验证,以满足 GNOME Shell 中一些基本的用户互动。 + +* 启动器 +* 应用程序网格 +* 轻扫、手势和导航 +* 用手机键盘搜索 +* 检测屏幕大小和支持屏幕旋转 +* 工作空间和多任务 +* 设置 +* 屏幕键盘 + +![GNOME Shell 移动版模拟图][4] + +始终要记住的是,移动体验远不止用户界面这么简单。另外,GNOME 本身并不是一个操作系统。它由底层的稳定的操作系统组成,它提供了非常需要的隐私和安全。另外,“应用商店”的概念也是如此。手机制造商需要与 GNOME 开发者合作,让他们的产品采用这个概念。 + +#### 进展如何? + +在写这篇文章时,团队给我们快速演示了取得的进展。在下面的视频中可以看到: + +![][5] + +复杂的任务是识别触摸屏手机中的各种手势。例如,你可能会使用长触摸、短触摸、双指轻扫和拖动,以及许多只有在小尺寸设备中才可行的可能性。这需要在各自的 GNOME Shell 组件中推倒重构。 + +而完全在现有的 GNOME Shell 基础上开发它们是很有挑战性的工作。 + +此外,该团队使用著名的 Pinephone Pro 进行开发和测试。Pinephone 已经是一个商业产品,装有 “友商” KDE Plasma 手机和其他 Linux 操作系统。 + +![][6] + +### 结语 + +如果一切按计划进行,我们可能在一个完整的开源手机中获得原生的 GNOME 体验。而你可以重新拥有你的隐私! + +另外,我不确定 Phosh(它也是基于 GNOME 的)会发生什么。虽然 Phosh 是由 Purism 开发和管理的,但看看 GNOME Shell 在移动设备上的努力和 PHosh 在未来一段日子的发展方向将是很有趣的。 + +那么,你对这个项目的前景怎么看?请在下面的评论栏里告诉我。 + +*图片和视频来源:GNOME 开发者 [博客][7]* + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2022/06/gnome-shell-mobile-announcement/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://www.debugpoint.com/tag/gnome-40 +[2]: http://www.prototypefund.de +[3]: https://www.debugpoint.com/wp-content/uploads/2022/06/GNOME-Shell-Running-on-a-prototype-Pinephone.jpg +[4]: https://www.debugpoint.com/wp-content/uploads/2022/06/GNOME-Shell-Mobile-mock-up.jpg +[5]: https://www.debugpoint.com/wp-content/uploads/2022/06/phone.webm +[6]: https://www.debugpoint.com/wp-content/uploads/2022/06/tablet.webm +[7]: https://blogs.gnome.org/shell-dev/2022/05/30/towards-gnome-shell-on-mobile/ diff --git a/published/202206/20220601 How to Create Local Yum-DNF Repository on RHEL 9.md b/published/202206/20220601 How to Create Local Yum-DNF Repository on RHEL 9.md new file mode 100644 index 0000000000..328acf878a --- /dev/null +++ b/published/202206/20220601 How to Create Local Yum-DNF Repository on RHEL 9.md @@ -0,0 +1,139 @@ +[#]: subject: "How to Create Local Yum/DNF Repository on RHEL 9" +[#]: via: "https://www.linuxtechi.com/create-local-yum-dnf-repository-rhel/" +[#]: author: "Pradeep Kumar https://www.linuxtechi.com/author/pradeep/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14697-1.html" + +如何在 RHEL 9 上创建本地 Yum/DNF 仓库 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/11/164149y9zzm7kkxwsxgszw.jpg) + +你好,技术兄弟,最近红帽发布了最新的操作系统 RHEL 9,RHEL 9 满足了混合云的所有要求。它可以安装在物理服务器、虚拟机和容器镜像中。 + +当我们没有订阅的时候,想安装软件包来做实验,那么设置本地的 Yum 或 DNF 仓库将是很方便的。 + +在本指南中,我们将介绍如何在 RHEL 9 上使用 DVD 或 ISO 文件一步一步地创建本地 Yum/DNF 资源库。 + +创建本地 Yum/DNF 资源库的先决条件: + +* 最小化安装 RHEL 9 系统 +* 具有管理权限的 sudo 用户 +* RHEL 9 DVD 或 ISO 文件 + +### 1)挂载 RHEL 9 ISO 文件或 DVD + +我们假设 RHEL 9 iso 文件已经被复制到系统中。运行下面的挂载命令,将 ISO 文件挂载到 `/opt/repo` 文件夹。 + +``` +$ sudo mkdir /var/repo +$ sudo mount -o loop rhel-baseos-9.0-x86_64-dvd.iso /var/repo/ +``` + +![Mount-RHEL9-ISO-File-Command][1] + +如果是 DVD 光盘,运行: + +``` +$ sudo mount /dev/sr0 /var/repo/ +``` + +### 2)在 /etc/yum.repos.d/ 目录中创建仓库文件 + +在 `/etc/yum.repos.d/` 目录下创建一个名为 “rhel9-local.repo` 的仓库文件,内容如下: + +``` +$ sudo vi /etc/yum.repos.d/rhel9-local.repo +[Local-BaseOS] +name=Red Hat Enterprise Linux 9 - BaseOS +metadata_expire=-1 +gpgcheck=1 +enabled=1 +baseurl=file:///var/repo//BaseOS/ +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release + +[Local-AppStream] +name=Red Hat Enterprise Linux 9 - AppStream +metadata_expire=-1 +gpgcheck=1 +enabled=1 +baseurl=file:///var/repo//AppStream/ +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +``` + +保存并关闭该文件。 + +![RHEL8-Local-Repo-File][2] + +### 3)刷新 Yum/DNF 和订阅管理器的缓存 + +执行以下命令来清理 Yum 或 DNF 和订阅管理器的缓存。 + +``` +$ sudo dnf clean all +$ sudo subscription-manager clean +``` + +![DNF-Subscription-Manager-Clean][3] + +在上面的输出中,我们得到一个警告信息 `This system is not registered with an entitlement`(系统没有注册权限)。所以,为了抑制这个警告信息,编辑文件 `/etc/yum/pluginconf.d/subscription-manager.conf`,将参数 `enabled=1` 改为 `enabled=0`。 + +``` +$ sudo vi /etc/yum/pluginconf.d/subscription-manager.conf +``` + +![Disable-Subscription-Parameter-RHEL-9][4] + +保存并退出该文件。 + +### 4)使用本地仓库安装软件包 + +现在我们都准备好测试我们的本地仓库了。运行下面的命令来查看配置仓库。 + +``` +$ sudo dnf repolist +``` + +输出: + +![DNF-Repolist-RHEL-9][5] + +现在,试试用 `dnf` 命令通过上面配置的本地仓库安装软件包。 + +``` +$ sudo dnf install nfs-utils +``` + +输出: + +![Install-RPM-Package-via-local-repo-rhel9][6] + +![Package-Installation-Completion-RHEL9-DNF-Command][7] + +完美,上述输出证实了 `nfs-utils` 包及其依赖项已经通过本地配置的 Yum 或 DNF 仓库成功安装。 + +这就是本指南的全部内容。我希望你觉得它有参考价值。请在下面的评论区发表你的疑问和反馈。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/create-local-yum-dnf-repository-rhel/ + +作者:[Pradeep Kumar][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lkxed +[1]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Mount-RHEL9-ISO-File-Command.png +[2]: https://www.linuxtechi.com/wp-content/uploads/2022/06/RHEL8-Local-Repo-File.png +[3]: https://www.linuxtechi.com/wp-content/uploads/2022/06/DNF-Subscription-Manager-Clean.png +[4]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Disable-Subscription-Parameter-RHEL-9.png +[5]: https://www.linuxtechi.com/wp-content/uploads/2022/06/DNF-Repolist-RHEL-9.png +[6]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Install-RPM-Package-via-local-repo-rhel9.png +[7]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Package-Installation-Completion-RHEL9-DNF-Command.png diff --git a/published/202206/20220601 Linux Lite 6.0 Ditches Firefox to Favor Google Chrome as the Default Browser.md b/published/202206/20220601 Linux Lite 6.0 Ditches Firefox to Favor Google Chrome as the Default Browser.md new file mode 100644 index 0000000000..85c9e25716 --- /dev/null +++ b/published/202206/20220601 Linux Lite 6.0 Ditches Firefox to Favor Google Chrome as the Default Browser.md @@ -0,0 +1,134 @@ +[#]: subject: "Linux Lite 6.0 Ditches Firefox to Favor Google Chrome as the Default Browser" +[#]: via: "https://news.itsfoss.com/linux-lite-6-0-release/" +[#]: author: "Jacob Crume https://news.itsfoss.com/author/jacob/" +[#]: collector: "lkxed" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14669-1.html" + +Linux Lite 6.0 发布:弃用 Firefox,默认浏览器使用 Chrome +====== + +> Linux Lite 6.0 是一个有趣的版本,有一个新的默认浏览器,改进了无障碍性、新的主题、新的系统监视器等等改进。 + +![linux lite][1] + +Linux Lite,是 [最好的类 Windows 发行版][2] 之一,刚刚发布了它的最新版本 6.0。 + +Linux Lite 6.0 基于 [Ubuntu 22.04 LTS][3],内置了 [Linux 内核 5.15 LTS][4]。 + +这次升级包含了相当多的令人兴奋的新功能,包括一个新的窗口主题和无障碍技术。 + +让我们深入了解一下新的内容! + +### Linux Lite 6.0 概述 + +Linux Lite 6.0 包括许多变化,包括: + +* 更新了软件 +* 新的窗口主题 +* 新的屏幕键盘 +* 屏幕阅读器 +* 屏幕放大镜 +* Chrome 取代 Firefox 成为默认浏览器 +* 新的 GRUB 菜单 + +#### 无障碍性的改进 + +![Linux Lite 6.0][5] + +Linux Lite 通过这一改变已经步入了大联盟。无障碍性,在历史上一直是 GNOME 特有的优势,它现在有了很大的改进。这主要体现在三个不同的工具上:一个屏幕键盘,一个屏幕阅读器(Orca),和一个屏幕放大镜。 + +屏幕键盘对于许多触摸屏用户和没有键盘的用户来说是相当有用的。另一方面,屏幕阅读器对于视障用户来说将是完美的。 + +![Linux Lite 6.0][6] + +最后一项无障碍改进屏幕放大镜,也是针对与屏幕阅读器相同的受众。然而,它与传统的桌面理念相当吻合,所以众多用户可能更青睐它,而不是屏幕阅读器。 + +这些无障碍性的改进有助于 Linux Lite 6.0 成为一个主流的选择。 + +#### 更新的软件 + +与几乎所有的发行版升级一样,Linux Lite 6.0 包括更新的软件。最值得注意的是最新的 LibreOffice 稳定版 7.2.6。 + +其他更新包括 VLC 3.0.16、Thunderbird 91.7、Chrome 100、GIMP 2.10.30 等等。 + +虽然本身不一定是大规模的升级,但它表明了所包含的 LibreOffice 版本的重大变化。 + +以前,由于提供了更多的稳定性,Linux Lite 停留在更多老版本上。然而,Linux Lite 的开发者现在觉得使用最新的稳定版本也很放心,因为测试新 LibreOffice 版本的人比以往任何时候都多。 + +#### 新的窗口主题 + +![Linux Lite 6.0][7] + +Linux Lite 6.0 引入了一个新的窗口主题,叫做 “Materia”。那些主题社区的人可能会对它相当熟悉,因为它已经被移植到几乎所有的平台。这些平台包括 GTK 2、3 和 4、GNOME Shell、Budgie、Cinnamon、MATE、Unity、Xfce、LightDM、GDM,甚至是 Chrome 浏览器。 + +改用 Materia 应该会让 ChromeOS 用户感觉界面很熟悉,因为它是基于谷歌开发的 Material UI 的。 + +#### 谷歌 Chrome 浏览器成为新的默认浏览器 + +![Linux Lite 6.0][8] + +随着 Ubuntu 将其 Firefox 版本转移到一个 Snap 应用中,Linux Lite 已经完全抛弃了 Firefox,转而使用谷歌 Chrome。虽然我不能说我是这个变化的粉丝,但它确实有意义,特别是对于一个针对 Windows 用户的发行版来说。 + +虽然你可以自由地安装任何你喜欢的东西,但无论如何,Chrome 是大多数用户的流行选择。 + +此外,如果你想在访问文件之前扫描文件,Linux Lite 的开发者在 Chrome 中包含了一个 Virus Total 扫描器扩展(默认是禁用的)。 + +注意,你可以从 Linux Lite 的软件中心安装 Firefox,但它是 Snap 版本的。 + +#### 系统监控中心替代了任务管理器 + +![Linux Lite 6.0][9] + +Linux Lite 6.0 现在打包了 [系统监控中心][10]System Monitoring Center 来替代任务管理器和进程查看器。 + +请注意,Linux Lite 的开发者复刻了这个应用程序,在系统标签中提供了关于发行版的具体信息。 + +它提供了所有关注你的资源的必要功能。 + +### 其他改进 + +除了基本的变化之外,Linux Lite 6.0 还包括对 GRUB 菜单的更新、推送紧急修复包的能力、新的 whisker 菜单,以及更多的调整。 + +![Linux Lite 6.0][11] + +正如你所注意到的,新的 GRUB 菜单还包括关闭和重启,同时删除了内存测试选项。 + +你可以在其 [官方公告帖子][12] 中了解更多的技术细节。 + +### 总结 + +Linux Lite 6.0 看起来是一个可靠的版本,特别是对于那些等待无障碍功能和新的视觉感受的人。 + +如果你想自己尝试一下,ISO 文件可以从官方下载页面获得。 + +> **[下载Linux Lite][13]** + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/linux-lite-6-0-release/ + +作者:[Jacob Crume][a] +选题:[lkxed][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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/linux-lite-6.jpg +[2]: https://itsfoss.com/windows-like-linux-distributions/ +[3]: https://news.itsfoss.com/ubuntu-22-04-release/ +[4]: https://news.itsfoss.com/linux-kernel-5-15-release/ +[5]: https://news.itsfoss.com/wp-content/uploads/2022/05/Screen-Reader-Linux-Lite-6.0.png +[6]: https://news.itsfoss.com/wp-content/uploads/2022/06/linux-lite-accessibility.png +[7]: https://news.itsfoss.com/wp-content/uploads/2022/05/Materia-Linux-Lite-6.0.png +[8]: https://news.itsfoss.com/wp-content/uploads/2022/05/Chrome-Linux-Lite-6.0.png +[9]: https://news.itsfoss.com/wp-content/uploads/2022/05/system-monitoring-center-linux-lite.png +[10]: https://itsfoss.com/system-monitoring-center/ +[11]: https://news.itsfoss.com/wp-content/uploads/2022/06/grub-linux-lite-6.png +[12]: https://www.linuxliteos.com/forums/release-announcements/linux-lite-6-0-final-released/ +[13]: https://www.linuxliteos.com/download.php#current diff --git a/published/202206/20220601 de-Googled -e-OS v1 Released Along with a New Brand -Murena- for Smartphone and Cloud Services.md b/published/202206/20220601 de-Googled -e-OS v1 Released Along with a New Brand -Murena- for Smartphone and Cloud Services.md new file mode 100644 index 0000000000..e1412ef77a --- /dev/null +++ b/published/202206/20220601 de-Googled -e-OS v1 Released Along with a New Brand -Murena- for Smartphone and Cloud Services.md @@ -0,0 +1,89 @@ +[#]: subject: "de-Googled /e/OS v1 Released Along with a New Brand ‘Murena’ for Smartphone and Cloud Services" +[#]: via: "https://news.itsfoss.com/murena-e-os/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14666-1.html" + +去谷歌化操作系统 /e/OS v1 及新品牌 Murena 一同发布 +====== + +> Murena 是一个与 e 基金会有关的新品牌,该品牌专注于提供隐私友好的 /e/OS 及新的智能手机和云服务。 + +![murena][1] + +/e/OS 是一个流行的、注重隐私的移动操作系统,是谷歌安卓的替代品之一。 + +这个复刻自 Lineage OS 的操作系统消除了任何与谷歌有关的依赖性,并鼓励你在使用中不要直接依赖任何谷歌的服务。 + +取而代之的是,它提供一些解决方案作为替代品,为你提供一个隐私友好的生态系统。 + +为了精简其产品,负责该操作系统的 e 基金会宣布了一个新的品牌 “Murena”,其中包括了一些以该操作系统为核心的新功能和一个新的智能手机。 + +### Murena 和 e 基金会 + +e 基金会作为一个致力于 /e/OS 的非营利组织将继续存在。因此,可以说这不是一次品牌重塑。 + +然而,[Murena][2] 作为一个新的创业公司,似乎是一个独立的商业实体,将专注于鼓励主流用户尝试 /e/OS,并促进支持该操作系统的智能手机的使用。 + +对该公司,/e/OS 的创建者提及: + +![][3] + +### /e/OS 1.0 有什么新内容? + +随着该操作系统的最新升级发布,他们的目标是让事情变得更容易理解,在提高使用便利性的同时,仍然考虑到隐私。 + +此外,还随同本次更新推出了新的应用程序商店(App Lounge)和新的隐私工具(Advanced Privacy)。 + +**App Lounge**:这个新的应用程序安装程序可以让你安装许多开源应用程序和 PWA(渐进式网页应用Progress Web App)。在你安装之前,它还会告知你每个应用程序中已有的跟踪器。 + +![][4] + +我相信一个量身定做的应用商店的存在将有助于消除新用户是否应该尝试用 /e/OS 安装 Play Store 或 F-Droid 的困惑。 + +除此之外,Advanced Privacy 工具将有助于限制用户在安装第三方应用程序后暴露的数据。 + +如果你想远离科技巨头,你还会发现 Murena 云服务可以用作私人电子邮件账户服务和云存储。该电子邮件服务提供的功能可以隐藏你的原始电子邮件地址。 + +### Murena One + +![][5] + +首款 Murena 品牌的智能手机将于 6 月下旬推出,并将向美国、加拿大、欧洲、英国和瑞士等地的用户发货。 + +这款智能手机将采用 6.5 英寸显示屏,配备 2500 万像素的前置摄像头,后置摄像头设置有三个传感器,分别是 4800 万像素、800 万像素和 500 万像素。 + +我们不太确定是什么处理器,但它提到了是一个八核芯片,加上 4GB 的内存。所有这些都由 4500 毫安时的电池供电。 + +除了它的第一款智能手机,你还可以从它的官方网站上购买 Fairphone 和 Teracube 的智能手机,这些手机预装了 /e/OS。 + +### 总结 + +你可以在其官方网站上了解更多关于新的 /e/OS 升级、云服务和可用的智能手机的信息。 + +> **[Murena][6]** + +该智能手机的定价还没有在新闻发布会上披露。所以,我们建议你如果有兴趣,可以关注一下。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/murena-e-os/ + +作者:[Ankush Das][a] +选题:[lkxed][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/ankush/ +[b]: https://github.com/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/murena.jpg +[2]: https://murena.com/ +[3]: https://news.itsfoss.com/wp-content/uploads/2022/06/murena-quote.jpeg +[4]: https://news.itsfoss.com/wp-content/uploads/2022/06/eos-app-lounge-1024x1024.jpg +[5]: https://news.itsfoss.com/wp-content/uploads/2022/06/murena-one-1024x576.jpeg +[6]: https://murena.com/ diff --git a/published/202206/20220602 Linux Mint to Maintain Timeshift Backup Tool as an XApp.md b/published/202206/20220602 Linux Mint to Maintain Timeshift Backup Tool as an XApp.md new file mode 100644 index 0000000000..b12e5175e9 --- /dev/null +++ b/published/202206/20220602 Linux Mint to Maintain Timeshift Backup Tool as an XApp.md @@ -0,0 +1,73 @@ +[#]: subject: "Linux Mint to Maintain Timeshift Backup Tool as an XApp" +[#]: via: "https://news.itsfoss.com/linux-mint-timeshift/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "hadisi1993" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14681-1.html" + +Linux Mint 接管 Timeshift 备份工具的开发,并作为一款 XApp 来维护 +====== + +> Linux Mint 接管了 Timeshift 备份/恢复工具的开发。你可以在它新的 GitHub 仓库中找到它。 + +![linux mint][1] + +Timeshift 可以说是 [备份和恢复 Linux 系统的最佳工具][2]。 + +Linux Mint 也利用它帮助用户在系统更新时更方便地创建快照,确保快捷无碍的操作。 + +当然,这不是 [Linux Mint 可能比 Ubuntu 更好的唯一原因][3]。 + +不幸的是,Timeshift 背后的开发者([Tony George][4])计划把注意力集中在其他项目上,将不再继续维护这个项目。 + +Linux Mint 团队联系了这位开发者,并愿意为这个项目提供任何可能的帮助。最终,它们接管了 Timeshift 的开发。 + +所以,现在 Linux Mint 团队会对 Timeshift 的发布和修复,以及任何与之相关的开发工作负责。 + +### 将 Timeshift 调整成 XApp + +![][5] + +Linux Mint 倾向于将某些应用作为“XApp”来维护,以确保它们能在各种不同的桌面环境下工作,不会依赖于某个特殊的桌面。 + +考虑到他们计划将 Timeshift 调整成一个XApp,你可以期待该工具在很长一段时间内维持当前的外观和功能,而不用顾虑你的桌面环境是什么。 + +不像一些 GNOME 应用程序,为了获得最好的体验,它们通常会变成 GNOME 专用的应用程序。 + +Timeshift 是一个必不可少的备份/恢复工具。所以,Linux Mint 接管 Timeshift 的开发并作为一个 XApp 来维护的计划听上去相当完美! + +如果你想知道的话,那不妨告诉你,Timeshift 的迁移已经在 [Launchpad][6] 上完成了。 + +新的 [GitHub仓库][7](由 Linux Mint 复刻的)可以给你提供这个应用的更多细节以及它最近的开发活动。 + +你也可以在 [最近每月发布的博文][8] 中查阅官方对此的声明。 + +### 结语 + +作为 Timeshift 的维护者,Linux Mint 希望在不久的将来带来更多的新特性和改进。 + +你如何看待 Linux Mint 将 Timeshift 接管为一款 XApp?欢迎在下方的评论区内分享你的想法。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/linux-mint-timeshift/ + +作者:[Ankush Das][a] +选题:[lkxed][b] +译者:[hadisi1993](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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/linux-mint-time-shift.jpg +[2]: https://itsfoss.com/backup-restore-linux-timeshift/ +[3]: https://itsfoss.com/linux-mint-vs-ubuntu/ +[4]: https://teejeetech.com/ +[5]: https://news.itsfoss.com/wp-content/uploads/2022/06/timeshiftlinux-mint.png +[6]: https://github.com/linuxmint/timeshift +[7]: https://github.com/linuxmint/timeshift +[8]: https://blog.linuxmint.com/?p=4323 diff --git a/published/202206/20220602 Why Do Enterprises Use and Contribute to Open Source Software.md b/published/202206/20220602 Why Do Enterprises Use and Contribute to Open Source Software.md new file mode 100644 index 0000000000..e0feb992ca --- /dev/null +++ b/published/202206/20220602 Why Do Enterprises Use and Contribute to Open Source Software.md @@ -0,0 +1,121 @@ +[#]: subject: "Why Do Enterprises Use and Contribute to Open Source Software" +[#]: via: "https://www.linux.com/news/why-do-enterprises-use-and-contribute-to-open-source-software/" +[#]: author: "Dan Whiting https://www.linuxfoundation.org/blog/why-do-enterprises-use-and-contribute-to-open-source-software/" +[#]: collector: "lkxed" +[#]: translator: "aREversez" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14725-1.html" + +企业为何使用开源软件,又为何推动开源软件的发展 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/18/160635ejcmee273zmmxh72.jpg) + +每当人们知道我在 Linux 基金会Linux Foundation 工作,他们总是会问我们的工作具体是做什么的。有时候,他们会一直问我是不是开发 Linux 操作系统的。我只能回答说,我们做的是开源软件,并试图在他们失去兴趣之前,在短短的 20 秒钟内介绍它对世界的影响力。如果他们的兴趣还在,想要进一步了解,我就会给他们深入分析一番:企业为何想参与到开源软件项目之中?它们为何会使用开源软件?没错,企业确实会这样做,无论它们有没有意识到这一点。此外,成千上万的企业会将企业内部代码捐给开源项目,为推动开源软件的进一步开发和优化投入大量的时间和资源。 + +### 开源软件的使用范围有多广 + +引用我们最近发表的一项报告《企业开源指南A Guide to Enterprise Open Source》:“开源软件open source software(OSS)改变了世界,是数字经济的支柱,数字世界的基石。从我们日常使用的互联网和移动应用到开拓未来的操作系统和编程语言,开源软件无不发挥着重要的作用,可谓是科技行业的命脉。在今天,开源软件驱动数字经济发展,推进科学技术取得突破,不断改善人们的生活水平。手机、汽车和飞机等设备,家庭、企业和政府等群体都在使用着开源软件。但就在 20 年前,开源软件还仅仅为少数人所知,它的使用也仅限于一小部分专门的爱好者。” + +开源软件(OSS)已经改变了我们的世界,成为我们数字经济的支柱和数字世界的基础。 + +而它实际上: + +* 在各行业的 垂类软件栈vertical software stacks 中,开源软件的占比达到了 20% - 85%。 +* 超过 90% 的网站服务器和联网设备都依靠 Linux 来运行。 +* 安卓手机系统也是基于 Linux 内核。 +* 用于应用程序开发的 AMP、Appium、Dojo、jQuery、Marko、Node.js 等 [主流的库和工具][1] 均属于开源项目。 +* 世界上排名位列前 100 名的超级计算机都在使用 Linux。 +* 大型机客户均在使用 Linux。 +* 亚马逊、谷歌以及微软三大云服务供应商都在使用开源软件运行服务,并在云端托管开源解决方案。 + +### 企业为何想参与到开源软件项目之中 + +企业参与开源软件项目主要通过三种方式: + +* 企业向开源社区捐赠自家开发的软件。 +* 企业向开源软件项目提供直接的资金援助。 +* 企业向开源项目分派软件开发人员以及其他员工。 + +人们经常会问,为什么这些企业愿意放弃自家软件的所有权?为什么它们不让员工专攻自家软件的开发呢? + +从整体上来看,这一问题的答案就是,企业和组织聚集起来,合力解决共同的难题,如此一来,他们就可以各自专注于在这基础上的各类难题。这些企业明白,将资源聚集在一起,能够更好地解决基础问题。有时,这种现象被叫做“竞合coopetition”,大概的意思是企业在一些领域可能互为竞争对手,但是它们在另一些领域则会互相合作。 + +“竞合”现象的一些典型例子: + +* 铁路公司采用统一的铁轨尺寸,统一规划建设。得益于此,火车就可以在同样铁轨上运行,铁路公司之间也可以互相交换设备。 +* 在数码相机诞生之前,不同的公司在电影和摄像机行业各行创新之路,形成了各自的优势,但为了推进电影行业的发展,它们在相机链轮间距这一问题上达成了统一。 +* 娱乐产业在开展竞争的同时,也一致坚持采用家用录像系统和蓝光格式。 + +如今,企业、组织以及个体在合力解决难题的同时,也在不断地改进自身的产品与业务。 + +* [来此加密][2]Let’s Encrypt(LCTT译注:Let’s Encrypt 官网并没有用“来此加密”这样的称呼,但是在一些场合有这样的译名。我们认为此翻译很贴切。) 是一个免费的、开放的自动化证书颁发机构,旨在通过简化安装程序,减低安装费用,快速扩大安全网络协议的应用范围。该机构为超过 2.25 亿个网站提供服务,每天平均发放证书约 150 万张。 +* 好莱坞成立的 [学院软件基金会][3]Academy Software Foundation 通过共同开发软件,推动娱乐、游戏和媒体等产业的增长,为产业发展提供开放标准,在电影行业内 [创造了巨大的价值][4]。 +* 超级账本Hyperledger 基金会管理多个企业级区块链软件项目。众所周知,这些项目 [消耗的能源远比其他解决方案要少][5]。 +* [LF 能源基金会][6]LF Energy 推动 [电网朝着更加模块化、互操作和可拓展的方向发展][7],助力提升可再生能源的利用率。 +* [无人机代码基金会][8]Dronecode 致力于无人机软件的开发,促进企业在无人机领域进一步开拓创新。 +* [开源软件软件安全基金会][9]OpenSSF 聚集了顶尖的科技企业,共同强化开源软件的安全与韧性。 +* [Kubernetes][10] 是 Google 捐赠给 Linux 基金会下属的云原生计算基金会(CNCF)的一个项目,是管理基于云计算软件的首选方案。 + +上述只是企业参与的一小部分开源软件项目,点击 [此处][11],可以在 Linux 基金会官网浏览全部项目列表。 + +### 企业如何有效利用和参与开源软件项目? + +若想要更好地利用开源项目,更有效地参与开源项目,企业可以向 Linux 基金会寻求帮助。我们最新发布的报告 《[企业开源指南][12]》 提供了企业与组织需要了解的大部分信息。这份报告凝聚了来自多家顶级企业、具有几十年丰富经验的开源领袖的知识与智慧,报告主要分为以下六个章节: + +* 使用开源软件 +* 准备参与开源 +* 制定开源策略 +* 部署基础设施 +* 建立人才团队 +* 应对多方挑战 + +此外,Linux 基金会还提供了许多开源 [培训课程][13]、全年 [活动][14]、[LFX 平台][15],发起开源项目,协助企业与组织利用和参与开源项目,比如: + +* [TODO 工作组][16] 为开源项目办公室的建立和运作提供资源,包括其自身 [丰富的指导意见][17]。 +* [Openchain 项目][18] 旨在提供和维护国际开源许可标准,包括各种许可规定的相关信息。依赖于此,企业可以确保自身行为符合法律规定。 +* [FinOps 基金会][19] 目前正在将自身打造为“不断发展的云财务管理和文化实践平台,通过促进工程、财务、技术以及商业团队之间在数据驱动支出决策方面的合作,确保企业能够最大化实现商业价值”。 +* [软件数据包交换标准][20]Software Data Package Exchange(SPDX)是一个用于交流 软件物料清单software bill of materials(SBOM)的开放标准。在该标准下,每个用户都能清楚了解整个软件包中包括哪些软件。 + +同样,上述这些只是 Linux 基金会所有项目中的一小部分。所有这些项目都致力于帮助企业接受和使用开源项目,引导企业为开源项目做出贡献、提供捐赠。 + +总而言之,目前,企业正在迅速投向开源软件项目,借此解决共同的难题,并探索进一步的创新发展,而 Linux 基金会将为它们提供帮助。 + +*该文 [《企业为何使用开源软件,又为何推动开源软件的发展》][21] 首发于 [Linux 基金会][22] 官网。* + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/news/why-do-enterprises-use-and-contribute-to-open-source-software/ + +作者:[Dan Whiting][a] +选题:[lkxed][b] +译者:[aREversez](https://github.com/aREversez) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxfoundation.org/blog/why-do-enterprises-use-and-contribute-to-open-source-software/ +[b]: https://github.com/lkxed +[1]: https://openjsf.org/projects/ +[2]: https://letsencrypt.org/ +[3]: https://www.aswf.io/ +[4]: https://linuxfoundation.org/tools/open-source-in-entertainment/ +[5]: https://linuxfoundation.org/tools/carbon-footprint-of-nfts/ +[6]: https://www.lfenergy.org/ +[7]: https://linuxfoundation.org/tools/paving-the-way-to-battle-climate-change-how-two-utilities-embraced-open-source-to-speed-modernization-of-the-electric-grid/ +[8]: https://www.dronecode.org/projects/ +[9]: https://openssf.org/ +[10]: https://kubernetes.io/ +[11]: https://linuxfoundation.org/projects/ +[12]: https://linuxfoundation.org/tools/guide-to-enterprise-open-source/ +[13]: https://training.linuxfoundation.org/ +[14]: https://events.linuxfoundation.org/ +[15]: https://lfx.linuxfoundation.org/ +[16]: https://todogroup.org/ +[17]: https://linuxfoundation.org/resources/open-source-guides/ +[18]: https://www.openchainproject.org/resources +[19]: https://www.finops.org/introduction/what-is-finops/ +[20]: https://spdx.dev/ +[21]: https://www.linuxfoundation.org/blog/why-do-enterprises-use-and-contribute-to-open-source-software/ +[22]: https://www.linuxfoundation.org/ diff --git a/published/202206/20220603 How to Install FFmpeg in Ubuntu and Other Linux.md b/published/202206/20220603 How to Install FFmpeg in Ubuntu and Other Linux.md new file mode 100644 index 0000000000..9d7a484114 --- /dev/null +++ b/published/202206/20220603 How to Install FFmpeg in Ubuntu and Other Linux.md @@ -0,0 +1,173 @@ +[#]: subject: "How to Install FFmpeg in Ubuntu and Other Linux" +[#]: via: "https://www.debugpoint.com/2022/06/install-ffmpeg-ubuntu/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: "aREversez" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14716-1.html" + +在 Linux 上安装 FFmpeg +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/16/103329av0zoz5m5o9ootz5.jpg) + +> 本教程介绍了在 Ubuntu 及其他 Linux 发行版上安装 FFmpeg 的步骤。 + +FFmpeg 是一套处理多媒体文件的软件库。凭借这些强大的库,FFmpeg 能够转换格式、推流以及处理音频和视频文件。许多 Linux 的前端应用都使用 FFmpeg 作为后端支持,所以这些应用对 FFmpeg 的依赖度非常高。举个例子,录屏软件可能会用到 FFmpeg 将录屏转换为 gif 动图。 + +VLC 多媒体播放器、YouTube、Blender、Kodi、Shotcut 和 Handbrake 等流行的应用与服务都在使用 FFmpeg,这仅仅一小部分。 + +趣事:NASA 火星 2020 计划的探测器“毅力”号在将图像和视频发送到地球之前,会先使用 FFmpeg 对其进行处理。 + +### 关于 FFmpeg + +[FFmpeg][1] 本身是一款非常强大的命令行实用程序,在 Linux 发行版、Windows 以及 macOS 等系统上均可运行,支持多种架构。FFmpeg 是用 C 语言和汇编语言编写的,性能强大,提供跨平台支持。 + +#### 核心 + +FFmpeg 的核心是命令行实用程序,既可在命令行上使用,也可以经由任何程序语言调用。比如,你可以在 Shell 程序或 python 脚本中使用 FFmpeg。 + +* `ffmpeg`:用于转换音视频格式,包括来自视频直播的信号源。 +* `ffplay`:FFmpeg 配套使用的媒体播放器 +* `ffprobe`:显示媒体文件信息的命令行工具,可将信息输出为 csv、xml、json 等格式。 + +### FFmpeg 安装 + +在 Ubuntu 等 Linux 发行版上, FFmpeg 的安装比较简单。打开终端,运行以下命令安装即可。 + +#### Ubuntu 及与其相似的发行版 + +``` +sudo apt install FFmpeg +``` + +#### Fedora + +在 Fedora Linux 上安装 FFmpeg,你需要添加 [RPM Fusion 仓库][2],因为 Fedora 官方仓库没有 FFmpeg 软件包。 + +``` +sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm +``` + +``` +sudo dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree- +``` + +``` +sudo dnf install ffmpeg +``` + +#### Arch Linux + +``` +pacman -S ffmpeg +``` + +安装完成后,可输入以下命令查看安装是否成功。 + +``` +ffmpeg --version +``` + +![FFmpeg installed in Ubuntu Linux][3] + +### 示例:FFmpeg 的基本操作 + +首先,我们先来看看 FFmpeg 语法的一个简单例子。如下,该语法可以将 mp4 文件转换为 mkv 文件。 + +1、视频文件格式转换 + +``` +ffmpeg -i big_buck_bunny.mp4 big_buck_bunny.mkv +``` + +当然,这种写法最为简单易懂,但它并不完整,因为没有输入 比特率bit rate分辨率resolution 以及其他的视频文件属性。 + +2、音频文件格式转换 + +其次,输入与上面相似的命令可以转换音频文件的格式。 + +``` +ffmpeg -i sunny_day.ogg sunny_day.mp3 +``` + +3、使用音视频编解码器执行格式转换 + +最后,在下面的例子中,我们可以使用特定的 编解码器codec 来转换视频格式。参数 `-c` 搭配 `a` 或者 `v`,可以分别定义音频和视频文件。以下转换命令使用 `libvpx` 视频编解码器和 `libvorbis` 音频编解码器。 + +``` +ffmpeg -i big_buck_bunny.mp4 -c:v libvpx -c:a libvorbis big_buck_bunny.webm +``` + +### 如何确定自己系统中有哪些编码器和解码器? + +#### 显示所有编解码器 + +输入以下命令,打印所有编解码器。 + +``` +ffmpeg -codecs +``` + +该命令可以打印出所有可用的编解码器,并显示每个编解码器对应的功能信息,比如是否支持解码或编码。此外,如以下输出结果所示,打印出来的信息还会按照首字母顺序标注出每个编码器和解码器的位置。 + +``` +D..... = 支持解码 +.E.... = 支持编码 +..V... = 视频编解码器 +..A... = 音频编解码器 +..S... = 字幕编解码器 +...I.. = 仅限帧内编解码器 +....L. = 有损压缩 +.....S = 无损压缩 +``` + +![FFmpeg Codec list][4] + +#### 显示所有编码器 + +输入下列命令,打印出所有编码器 + +``` +ffmpeg -encoders +``` + +#### 显示所有解码器 + +同样,输入下列命令,打印出所有解码器。 + +``` +ffmpeg -decoders +``` + +#### 更多信息 + +输入参数 `-h`,获取更多关于编码器或解码器的信息。 + +``` +ffmpeg -h decoder=mp3 +``` + +### 总结 + +我希望这篇文章可以帮助你了解 FFmpeg 的基本知识及基本命令。若要了解更多信息,可前往 FFmpeg 官方网站浏览 [帮助文档][5]。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2022/06/install-ffmpeg-ubuntu/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[aREversez](https://github.com/aREversez) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://ffmpeg.org/ +[2]: https://www.debugpoint.com/2020/07/enable-rpm-fusion-fedora-rhel-centos/ +[3]: https://www.debugpoint.com/wp-content/uploads/2022/06/FFmpeg-installed-in-Ubuntu-Linux.jpg +[4]: https://www.debugpoint.com/wp-content/uploads/2022/06/FFmpeg-Codec-list.jpg +[5]: https://ffmpeg.org/documentation.html diff --git a/published/202206/20220605 Contribute at the Fedora Linux 37 Test Week for Kernel 5.18.md b/published/202206/20220605 Contribute at the Fedora Linux 37 Test Week for Kernel 5.18.md new file mode 100644 index 0000000000..41a873dfc9 --- /dev/null +++ b/published/202206/20220605 Contribute at the Fedora Linux 37 Test Week for Kernel 5.18.md @@ -0,0 +1,45 @@ +[#]: subject: "Contribute at the Fedora Linux 37 Test Week for Kernel 5.18" +[#]: via: "https://fedoramagazine.org/contribute-at-the-fedora-linux-37-test-week-for-kernel-5-18/" +[#]: author: "Sumantro Mukherjee https://fedoramagazine.org/author/sumantrom/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14685-1.html" + +Fedora Linux 37 的内核 5.18 测试周到了,一起来做贡献吧! +====== +![][1] + +Fedora 内核团队正在为 Linux 内核 5.18 进行最终集成。这个版本刚刚发布,很快就会出现在 Fedora 中。因此,Fedora 内核和 QA 团队组织了一个测试周,截止日期为 **2022 年 6 月 12 日,星期日。** 请参阅 [维基页面][2] 来获取你将要参与的测试镜像链接。继续阅读下文,可了解更多细节~ + +### 测试周是如何运作的? + +测试周是一个人人都可以参与的活动。在测试周,任何人都可以为 Fedora 即将发布的版本查漏补缺,确保它最终能够运行良好。Fedora 社区成员会经常参与这个活动,我们同时也欢迎公众参加这些活动。如果你以前从未做过贡献,那么这是一个绝佳的上手机会。 + +要想做出贡献,你只需要能够执行以下操作即可: + +* 下载测试资料,包括一些大文件 +* 阅读并按照说明一步一步地进行操作 + +内核测试日的 [维基页面][2] 提供了很多关于测试内容和测试方法的有用信息。完成一些测试后,你可以在测试日的 [Web 应用][3] 上记录下你的测试结果。如果你在活动的当天或前后有空,请进行一些测试并报告你的结果。不知道该怎么做?没关系,我们有一份文件,其中提供了 [所有步骤][4]。 + +希望能在测试日见到你,预祝测试愉快~ + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/contribute-at-the-fedora-linux-37-test-week-for-kernel-5-18/ + +作者:[Sumantro Mukherjee][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/sumantrom/ +[b]: https://github.com/lkxed +[1]: https://fedoramagazine.org/wp-content/uploads/2022/06/test-days-816x345.jpg +[2]: http://fedoraproject.org/wiki/Test_Day:2022-06-05_Kernel_5.18_Test_Week +[3]: https://testdays.fedoraproject.org/events/136 +[4]: https://docs.fedoraproject.org/en-US/quick-docs/kernel/howto-kernel-testday/ diff --git a/published/202206/20220606 6 Linux word processors you need to try.md b/published/202206/20220606 6 Linux word processors you need to try.md new file mode 100644 index 0000000000..9fd712d06f --- /dev/null +++ b/published/202206/20220606 6 Linux word processors you need to try.md @@ -0,0 +1,82 @@ +[#]: subject: "6 Linux word processors you need to try" +[#]: via: "https://opensource.com/article/22/6/word-processors-linux" +[#]: author: "Don Watkins https://opensource.com/users/don-watkins" +[#]: collector: "lkxed" +[#]: translator: "duoluoxiaosheng" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14693-1.html" + +值得尝试的六款 Linux 文字处理程序 +====== + +> 选择一款最中意的文字处理程序把你的想法打印到纸上。 + +![](https://img.linux.net.cn/data/attachment/album/202206/10/120032h7jlo1ozm37fdyfv.jpg) + +作家们总是在寻找更好的方法将他们的文字和想法以更好的方式呈现给他们的读者。我对文字处理程序最早的印象是在 Apple II 上使用 AppleWorks 和后来的 FrEDWriter,后者是一个创建于 1985 年的免费文字处理程序。这是我的学生们的标配,他们许多人来自没有钱购买专有软件的家庭。 + +### Abiword + +在 20 世纪 90 年代时,我开始使用 Linux,寻找我可以使用的高质量的写作程序,并推荐给跟随我进入开源软件世界的学生们。我首先接触的文字处理程序是 [AbiWord][2]。AbiWord 来自西班牙语 Abierto,意思是“开放”。它最早发布于 1998 年,并且之后一直在升级。它使用 GPLv2 开源协议。它支持列表、缩进,字符格式等基本功能,支持 .doc、.html、.docx、.odt 等多种格式文件的导入和导出。 + +![Image of Abiword][3] + +### Etherpad + +[Etherpad][4] 是一个开源协作编辑项目。它可以让你像 Google Drive 那样实时编辑文档,主要的区别是它是完全开源的。据它的网站上介绍,你可以“与你的朋友、同学或同事一起写文章、新闻稿、待办事项,同时在同一个文件上工作”。其源代码可随时查看。Etherpad 采用 Apache 2.0 开源协议。你可以直接在线使用它,或者把它下载并 [安装][5] 到你的 Linux 电脑上。 + +### Cryptpad + +[CryptPad][6] 是一个端到端加密的写作套件。使用 GPLv3 开源协议,并且源代码公开在 [GitHub][7] 上。它由 [Xwiki][8] 实验室开发。可替代 Google Drive,并且是自主托管的。根据其网站描述,“CryptPad 旨在实现协作办公。实时同步文档的更改。由于所有数据都已加密,因此该服务及其管理员无法查看正在编辑和存储的内容。” Cryptpad 为用户提供了 [丰富的文档][9]。 + +### Focuswriter + +[FocusWriter][10] 是一个简单的免干扰的编辑器。它使用隐藏式界面,鼠标移动到屏幕边界时才显示界面。它使用 GPLv3 开源协议,并为 Linux 提供了 Flatpak 软件包,也为 [Ubuntu][11] 和 [Fedora][12] 提供了 DEB 和 RPM。下图是一个 FocusWriter 桌面的例子。这是一个非常简单直观的界面,菜单自动隐藏,当鼠标指向屏幕顶部或边缘时才会显示。文件默认保存为 .odt 格式,也支持纯文本、.docx 和富文本。 + +![Image of FocusWriter][13] + +### LibreOffice Writer + +[LibreOffice Writer][14] 是我最喜欢的,我已经使用了十多年了。它拥有我需要的所有特性,包括富文本格式化。它还拥有我见过的最多的导入、导出方式。类似于 [APA][15] 这样的问卷和出版模板它拥有十多种。我最喜欢的是它可以将文件导出为 PDF 和 epub。 LibreOffice Writer 是一个自由软件,使用 Mozilla 公开许可证(MPL)2.0 开源协议。其 [源代码][16] 由文档基金会提供。LibreOffice 支持大多数 Linux 发行版。同时它也提供 Flatpak、Snap 和 AppImage 软件包。另外,你也可以把它下载并安装到 MacOS 和 Windows 上。 + +![Image of LibreOffice work space][17] + +### OpenOffice Writer + +Apache [OpenOffice Writer][18] 是一个全功能的文字处理程序。它可以简单地用于备忘录,也可以复杂到足以编写你的第一本书。依据官网的描述,OpenOffice Writer 将文档自动保存为 .odt。它还支持将文档保存为 .doc、.docx、富文本和其他格式。OpenOffice Writer 使用 Apache 许可证 2.0 开源协议。源代码在 [GitHub][19] 上公开。 + +还有许多自由开源软件等着大家去发现。它们非常适合完成你的日常任务,你也可以为它们的发展做出贡献。你最喜欢的 Linux 文字处理器程序是什么呢? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/6/word-processors-linux + +作者:[Don Watkins][a] +选题:[lkxed][b] +译者:[duoluoxiaosheng](https://github.com/duoluoxiaosheng) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/typewriter-hands.jpg +[2]: https://www.abisource.com/ +[3]: https://opensource.com/sites/default/files/2022-05/abiword.png +[4]: https://etherpad.org/# +[5]: https://github.com/ether/etherpad-lite#installation +[6]: https://cryptpad.fr/what-is-cryptpad.html +[7]: https://github.com/xwiki-labs/cryptpad +[8]: https://github.com/xwiki-labs +[9]: https://docs.cryptpad.fr/en/user_guide/index.html +[10]: https://gottcode.org/focuswriter/ +[11]: https://packages.ubuntu.com/jammy/focuswriter +[12]: https://src.fedoraproject.org/rpms/focuswriter +[13]: https://opensource.com/sites/default/files/2022-05/focuswriter.png +[14]: https://www.libreoffice.org/discover/writer/ +[15]: https://extensions.libreoffice.org/en/extensions/show/apa-style-paper-template +[16]: https://www.libreoffice.org/about-us/source-code/ +[17]: https://opensource.com/sites/default/files/2022-05/Libreofficewriter.png +[18]: https://www.openoffice.org/product/writer.html +[19]: https://github.com/apache/openoffice diff --git a/published/202206/20220606 Amberol is a Stunning Looking Music Player for Linux That Just Plays Music and Nothing Else.md b/published/202206/20220606 Amberol is a Stunning Looking Music Player for Linux That Just Plays Music and Nothing Else.md new file mode 100644 index 0000000000..0ccbb7c9bc --- /dev/null +++ b/published/202206/20220606 Amberol is a Stunning Looking Music Player for Linux That Just Plays Music and Nothing Else.md @@ -0,0 +1,113 @@ +[#]: subject: "Amberol is a Stunning Looking Music Player for Linux That Just Plays Music and Nothing Else" +[#]: via: "https://itsfoss.com/amberol-music-player/" +[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14700-1.html" + +Amberol 是一款外观漂亮的 Linux 音乐播放器,只播放音乐,不做其他事情 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/12/155846b0sbsvtt1et70ttf.jpg) + +虽然音乐世界被流媒体服务所主导,但这并没有阻止开发者为桌面电脑创建音乐播放器。 + +最近,我发现了一个外观漂亮的新的 Linux 桌面音乐播放器。它名为 Amberol,我被它的美丽所震撼。 + +![amberol music player interface][1] + +看起来不错,不是吗?让我们仔细看看它。 + +### Amberol,Linux 上的可爱的音乐播放器 + +看起来不错是它所做的两件(或几件)事情中的一件。另一件事是播放音乐。 + +这就是它,[Amberol][2] 没有额外的花哨(和有用)的功能,如生成专辑封面、元数据编辑、歌词显示或播放列表和库管理。 + +这些功能也不像是会在未来的版本中加入。Amberol 只想播放音乐。就是这样。 + +#### 令人惊叹的用户界面 + +Amberol 和大多数新的 GNOME 应用一样,是用 Rust 和 GTK 编写的。 + +它有一个自适应的用户界面,可以根据你正在播放的专辑颜色来改变颜色。渐变效果给了它一个现代、时尚的外观,肯定会成为你的 Linux 美化Ricing截图的一部分。 + +![amberol music player][3] + +由于其 UI 没有传统的手柄和菜单,它给应用一个统一的外观。 + +#### 播放列表 + +它会从你添加的文件夹中的文件自动生成一个播放列表,显示在左手边的侧边栏。 + +![amberol playlist][4] + +你可以在左上角看到整个播放列表将播放多长时间的音乐。点击“勾选”符号,你可以选择歌曲,并从播放列表中删除它们。 + +如果你愿意,可以隐藏播放列表的侧边栏。 + +![amberol without playlist][5] + +#### 音乐播放选项 + +你可以在界面上看到歌曲的进度。该播放器与键盘上的媒体控制按钮整合得很好。你可以用专用的媒体键来播放、暂停和改变曲目(如果你的系统上有)。 + +Amberol 为你提供了一些播放音乐的选项。你可以打开随机播放功能,按随机顺序播放音乐。你也可以单曲循环,直到你厌倦它。 + +![amberol music playing options][6] + +底部的汉堡菜单让你可以选择添加文件或文件夹,并显示可用的键盘快捷方式。 + +![amberol keyboard shortcuts][7] + +你也可以从这里禁用 UI 颜色变化以配合专辑封面。 + +### 在 Linux 上安装 Amberol + +Amberol 是 [以 Flatpak 形式提供的][8]。请确保 [你的系统已启用 Flatpak 支持][9]。 + +要安装 Amberol,请打开终端并使用以下命令: + +``` +flatpak install flathub io.bassi.Amberol +``` + +安装完毕后,在菜单中搜索该应用,并点击启动。 + +第一次运行时,它会要求你添加音乐文件或文件夹。你也可以拖放文件播放。 + +![amberol first run][10] + +### 总结 + +就个人而言,我更喜欢流媒体服务,因为我没有本机音乐珍藏。但我知道有的人有大量的 CD 收藏,现在都保存在硬盘上。 + +Amberol 是一个外观漂亮的应用,对于播放本机音乐来说,它足够好。最吸引人的是它基于专辑封面的自适应用户界面。 + +请你试试它,并在评论区分享你的经验。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/amberol-music-player/ + +作者:[Abhishek Prakash][a] +选题:[lkxed][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/lkxed +[1]: https://itsfoss.com/wp-content/uploads/2022/06/amberol-music-player-interface-800x693.png +[2]: https://apps.gnome.org/app/io.bassi.Amberol/ +[3]: https://itsfoss.com/wp-content/uploads/2022/06/amberol-music-player-800x580.png +[4]: https://itsfoss.com/wp-content/uploads/2022/06/Amberol-playlist-800x548.png +[5]: https://itsfoss.com/wp-content/uploads/2022/06/amberol-without-playlist-800x693.png +[6]: https://itsfoss.com/wp-content/uploads/2022/06/Amberol-music-playing-options-800x548.png +[7]: https://itsfoss.com/wp-content/uploads/2022/06/Amberol-keyboard-shortcuts-800x528.png +[8]: https://flathub.org/apps/details/io.bassi.Amberol +[9]: https://itsfoss.com/flatpak-guide/ +[10]: https://itsfoss.com/wp-content/uploads/2022/06/amberol-first-run-800x693.png diff --git a/published/202206/20220607 How Garbage Collection works inside a Java Virtual Machine.md b/published/202206/20220607 How Garbage Collection works inside a Java Virtual Machine.md new file mode 100644 index 0000000000..cd4ed74084 --- /dev/null +++ b/published/202206/20220607 How Garbage Collection works inside a Java Virtual Machine.md @@ -0,0 +1,156 @@ +[#]: subject: "How Garbage Collection works inside a Java Virtual Machine" +[#]: via: "https://opensource.com/article/22/6/garbage-collection-java-virtual-machine" +[#]: author: "Jayashree Huttanagoudar https://opensource.com/users/jayashree-huttanagoudar" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14742-1.html" + +JVM 垃圾回收的工作原理 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/22/094238qvh45pv2jtpde9td.jpg) + +> 对于程序员来说,掌握 Java 的内存管理机制并不是必须的,但它能够帮助你更好地理解 JVM 是如何处理程序中的变量和类实例的。 + +Java 之所以能够如此流行,自动 垃圾回收Garbage Collection(GC)功不可没,它也是 Java 最重要的几个特性之一。在这篇文章中,我将说明为什么垃圾回收如此重要。本文的主要内容为:自动的分代垃圾回收、JVM 划分内存的依据,以及 JVM 垃圾回收的工作原理。 + +### Java 内存分配 + +Java 程序的内存空间被划分为以下四个区域: + +1. 堆区Heap:对象实例就是在这个区域分配的。不过,当我们声明一个对象时,堆中不会发生任何内存分配,只是在栈中创建了一个对象的引用而已。 +2. 栈区Stack:方法、局部变量和类的实例变量就是在这个区域分配的。 +3. 代码区Code:这个区域存放了程序的字节码。 +4. 静态区Static:这个区域存放了程序的静态数据和静态方法。 + +### 什么是自动垃圾回收? + +自动垃圾回收是这样一个过程:首先,堆中的所有对象会被分类为“被引用的”和“未被引用的”;接着,“未被引用的对象”就会被做上标记,以待之后删除。其中,“被引用的对象”是指程序中的某一部分仍在使用的对象,“未被引用的对象”是指目前没有正在被使用的对象。 + +许多编程语言,例如 C 和 C++,都需要程序员手动管理内存的分配和释放。在 Java 中,这一过程是通过垃圾回收机制来自动完成的(尽管你也可以在代码中调用 `system.gc();` 来手动触发垃圾回收)。 + +垃圾回收的基本步骤如下: + +#### 1、标记已使用和未使用的对象 + +在这一步骤中,已使用和未使用的对象会被分别做上标记。这是一个及其耗时的过程,因为需要扫描内存中的所有对象,才能够确定它们是否正在被使用。 + +![标记已使用和未使用的对象][2] + +#### 2、扫描/删除对象 + +有两种不同的扫描和删除算法: + +**简单删除(标记清除)**:它的过程很简单,我们只需要删除未被引用的对象即可。但是,后续给新对象分配内存就会变得很困难了,因为可用空间被分割成了一块块碎片。 + +![标记清除的过程][3] + +**删除压缩(标记整理)**:除了会删除未被引用的对象,我们还会压缩被引用的对象(未被删除的对象)。这样以来,新对象的内存分配就相对容易了,并且内存分配的效率也有了提升。 + +![标记整理的过程][4] + +### 什么是分代垃圾回收,为什么需要它? + +正如我们在“扫描删除”模型中所看到的,一旦对象不断增长,我们就很难扫描所有未使用的对象以回收内存。不过,有一项实验性研究指出,在程序执行期间创建的大多数对象,它们的存活时间都很短。 + +既然大多数对象的存活时间都很短,那么我们就可以利用这个事实,从而提升垃圾回收的效率。该怎么做呢?首先,JVM 将内存划分为不同的“代”。接着,它将所有的对象都分类到这些内存“代”中,然后对这些“代”分别执行垃圾回收。这就是“分代垃圾回收”。 + +### 堆内存的“代”和分代垃圾回收过程 + +为了提升垃圾回收中的“标记清除”的效率,JVM 将对内存划分成以下三个“代”: + +* 新生代Young Generation +* 老年代Old Generation +* 永久代Permanent Generation + +![Hotspot 堆内存结构][5] + +下面我将介绍每个“代”及其主要特征。 + +#### 新生代 + +所有创建不久的对象都存放在这里。新生代被进一步分为以下两个区域: + +1. 伊甸区Eden:所有新创建的对象都在此处分配内存。 +2. 幸存者区Survivor,分为 S0 和 S1:经历过一次垃圾回收后,仍然存活的对象会被移动到两个幸存者区中的一个。 + +![对象分配][6] + +在新生代发生的分代垃圾回收被称为 “次要回收Minor GC”(LCTT 译注:也称为“新生代回收Young GC”)。Minor GC 过程中的每个阶段都是“停止世界Stop The World”(STW)的,这会导致其他应用程序暂停运行,直到垃圾回收结束。这也是次要回收更快的原因。 + +一句话总结:伊甸区存放了所有新创建的对象,当它的可用空间被耗尽,第一次垃圾回收就会被触发。 + +![填充伊甸区][7] + +次要回收:在该垃圾回收过程中,所有存活和死亡的对象都会被做上标记。其中,存活对象会被移动到 S0 幸存者区。当所有存活对象都被移动到了 S0,未被引用的对象就会被删除。 + +![拷贝被引用的对象][8] + +S0 中的对象年龄为 1,因为它们挺过了一次次要回收。此时,伊甸区和 S1 都是空的。 + +每当完成清理后,伊甸区就会再次接受新的存活对象。随着时间的推移,伊甸区和 S0 中的某些对象被宣判死亡(不再被引用),并且伊甸区的可用空间也再次耗尽(填满了),那么次要回收 又将再次被触发。 + +![对象年龄增长][9] + +这一次,伊甸区和 S0 中的死亡和存活的对象会被做上标记。其中,伊甸区的存活对象会被移动到 S1,并且年龄增加至 1。S0 中的存活对象也会被移动到 S1,并且年龄增加至 2(因为它们挺过了两次次要回收)。此时,伊甸区和 S0 又是空的了。每次次要回收之后,伊甸区和两个幸存者区中的一个都会是空的。 + +新对象总是在伊甸区被创建,周而复始。当下一次垃圾回收发生时,伊甸区和 S1 都会被清理,它们中的存活对象会被移动到 S0 区。每次次要回收之后,这两个幸存者区(S0 和 S1)就会交换一次。 + +![额外年龄增长][10] + +这个过程会一直进行下去,直到某个存活对象的年龄达到了某个阈值,然后它就会被移动到一个叫做“老年代”的地方,这是通过一个叫做“晋升”的过程来完成的。 + +使用 `-Xmn` 选项可以设置新生代的大小。 + +### 老年代 + +这个区域存放着那些挺过了许多次次要回收,并且达到了某个年龄阈值的对象。 + +![晋升][11] + +在上面这个示例图表中,晋升的年龄阈值为 8。在老年代发生的垃圾回收被称为 “主要回收Major GC”。(LCTT 译注:也被称为“全回收Full GC”) + +使用 `-Xms` 和 `-Xmx` 选项可以分别设置堆内存大小的初始值和最大值。(LCTT 译注:结合上面的 `-Xmn` 选项,就可以间接设置老年代的大小了。) + +### 永久代 + +永久代存放着一些元数据,它们与应用程序、Java 标准环境以及 JVM 自用的库类及其方法相关。JVM 会在运行时,用到了什么类和方法,就会填充相应的数据。当 JVM 发现有未使用的类,就会卸载或是回收它们,从而为正在使用的类腾出空间。 + +使用 `-XX:PermGen` 和 `-XX:MaxPerGen` 选项可以分别设置永久代大小的初始值和最大值。 + +#### 元空间 + +Java 8 引入了元空间Metaspace,并用它替换了永久代。这么做的好处是自动调整大小,避免了 内存不足OutOfMemory(OOM)错误。 + +### 总结 + +本文讨论了各种不同的 JVM 内存“代”,以及它们是如何在分代垃圾回收算法中起作用的。对于程序员来说,掌握 Java 的内存管理机制并不是必须的,但它能够帮助你更好地理解 JVM 处理程序中的变量和类实例的方式。这种理解使你能够规划和排除代码故障,并理解特定平台固有的潜在限制。 + +*正文配图来自:Jayashree Huttanagoudar,CC BY-SA 4.0* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/6/garbage-collection-java-virtual-machine + +作者:[Jayashree Huttanagoudar][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jayashree-huttanagoudar +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/java-coffee-beans.jpg +[2]: https://opensource.com/sites/default/files/2022-06/1Marking.png +[3]: https://opensource.com/sites/default/files/2022-06/2NormalDeletion.png +[4]: https://opensource.com/sites/default/files/2022-06/3DeletionwithCompacting.png +[5]: https://opensource.com/sites/default/files/2022-06/4Hotspot.png +[6]: https://opensource.com/sites/default/files/2022-06/5ObjAllocation.png +[7]: https://opensource.com/sites/default/files/2022-06/6FillingEden.png +[8]: https://opensource.com/sites/default/files/2022-06/7CopyingRefdObjs.png +[9]: https://opensource.com/sites/default/files/2022-06/8ObjAging.png +[10]: https://opensource.com/sites/default/files/2022-06/9AddlAging.png +[11]: https://opensource.com/sites/default/files/2022-06/10Promotion.png diff --git a/published/202206/20220607 How to Boot Ubuntu 22.04 into Rescue - Emergency Mode.md b/published/202206/20220607 How to Boot Ubuntu 22.04 into Rescue - Emergency Mode.md new file mode 100644 index 0000000000..c618877834 --- /dev/null +++ b/published/202206/20220607 How to Boot Ubuntu 22.04 into Rescue - Emergency Mode.md @@ -0,0 +1,88 @@ +[#]: subject: "How to Boot Ubuntu 22.04 into Rescue / Emergency Mode" +[#]: via: "https://www.linuxtechi.com/boot-ubuntu-22-04-rescue-emergency-mode/" +[#]: author: "Pradeep Kumar https://www.linuxtechi.com/author/pradeep/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14750-1.html" + +如何启动 Ubuntu 22.04 进入救援/紧急模式 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/24/101647n4nru1ayaw4nrnue.jpg) + +极客们好,将 Ubuntu 22.04(Jammy Jellyfish)启动到救援Rescue紧急Emergency模式可以重置忘记的用户密码、修复文件系统错误,以及在启动过程中禁用或启用 systemd 服务。 + +在这篇文章中,我们将学习如何启动 Ubuntu 22.04 LTS 系统进入救援和应急模式。救援模式类似于单用户模式,所有的故障排除步骤都在这里进行。救援模式加载最小的环境并挂载根文件系统。 + +而在紧急模式下,我们得到的是单用户 Shell,而不启动任何系统服务。因此,当我们无法启动系统进入救援模式时,就需要紧急模式。 + +### 启动 Ubuntu 22.04 进入救援或单用户模式 + +前往你想启动到救援或单用户模式的目标系统。在启动时按下 `SHIFT + ESC` 键,进入 GRUB 引导加载器页面。 + +![Default-Grub-Screen-Ubuntu-22-04][1] + +选择第一个选项 “Ubuntu”,并按 `e` 键进入编辑模式。 + +在以 `linux` 开头的一行末尾,删除字符串 `$vt_handoff` 并添加字符串 `systemd.unit=rescue.target`。 + +![rescue-target-ubuntu-22-04][2] + +做完修改后,按 `Ctrl + X` 或 `F10` 在救援模式下启动。 + +![Troubleshooting-Commands-in-Rescue-Mode][3] + +进入救援模式后,运行所有的故障排除命令,并运行 `systemctl reboot` 命令来重启系统。 + +### 另一种启动系统进入救援模式的方法 + +重新启动系统并按下 `ESC + Shift` 键,进入 GRUB 启动界面。 + +选择第二个选项 “Ubuntu 高级选项Advanced Options for Ubuntu”->选择“恢复模式recovery mode”选项并点击回车->选择 root(进入 root shell 提示符)root (Drop to root shell prompt)。 + +下面是一个例子: + +![Boot-Ubuntu-22-04-Rescue-Mode][4] + +当你有了 root Shell,运行命令来恢复和修复系统问题,最后使用 `systemctl reboot` 来重启系统。 + +### 引导 Ubuntu 22.04 进入紧急模式 + +要启动系统进入紧急模式,首先进入 GRUB 页面。 + +![Default-Grub-Screen-Ubuntu-22-04][5] + +选择第一个选项 “Ubuntu” 并按 `e` 键进行编辑。寻找以 `linux` 开头的一行,移到该行的末尾,删除字符串 `$vt_handoff` 并添加字符串 `systemd.unit=emergency.target`。 + +![Emergency-Mode-Ubuntu-22-04][6] + +按 `Ctrl + X` 或 `F10` 将系统启动到紧急模式。 + +![Command-in-Emergency-Mode-Ubuntu-22-04][7] + +同样,在紧急模式下,你可以在这个模式下执行所有的故障排除,完成后,就用 `systemctl reboot` 命令重启系统。 + +这篇文章的内容就这些。文章内容丰富,不要犹豫,请在你的技术朋友中分享它。请在下面的评论区发表你的疑问和反馈。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/boot-ubuntu-22-04-rescue-emergency-mode/ + +作者:[Pradeep Kumar][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lkxed +[1]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Default-Grub-Screen-Ubuntu-22-04.png +[2]: https://www.linuxtechi.com/wp-content/uploads/2022/06/rescue-target-ubuntu-22-04.png +[3]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Troubleshooting-Commands-in-Rescue-Mode.png +[4]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Boot-Ubuntu-22-04-Rescue-Mode.gif +[5]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Default-Grub-Screen-Ubuntu-22-04.png +[6]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Emergency-Mode-Ubuntu-22-04.png +[7]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Command-in-Emergency-Mode-Ubuntu-22-04.png diff --git a/published/202206/20220607 Integrating Zeek with ELK Stack.md b/published/202206/20220607 Integrating Zeek with ELK Stack.md new file mode 100644 index 0000000000..ab63c0ad30 --- /dev/null +++ b/published/202206/20220607 Integrating Zeek with ELK Stack.md @@ -0,0 +1,143 @@ +[#]: subject: "Integrating Zeek with ELK Stack" +[#]: via: "https://www.opensourceforu.com/2022/06/integrating-zeek-with-elk-stack/" +[#]: author: "Tridev Reddy https://www.opensourceforu.com/author/tridev-reddy/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14770-1.html" + +将 Zeek 与 ELK 栈集成 +====== + +> Zeek 是一个开源的网络安全监控工具。本文讨论了如何将 Zeek 与 ELK 集成。 + +![](https://img.linux.net.cn/data/attachment/album/202206/28/164550v4nuk3g7ux77y77v.jpg) + +在本杂志 2022 年 3 月版发表的题为“用 Zeek 轻松实现网络安全监控”的文章中,我们研究了 Zeek 的功能,并学习了如何开始使用它。现在我们将把我们的学习经验再进一步,看看如何将其与 ELK(即 Elasticsearch、Kibana、Beats 和 Logstash)整合。 + +为此,我们将使用一个叫做 Filebeat 的工具,它可以监控、收集并转发日志到 Elasticsearch。我们将把 Filebeat 和 Zeek 配置在一起,这样后者收集的数据将被转发并集中到我们的 Kibana 仪表盘上。 + +### 安装 Filebeat + +让我们首先将 Filebeat 与 Zeek 安装在一起。使用 `apt` 来安装 Filebeat,使用以下命令: + +``` +sudo apt install filebeat +``` + +接下来,我们需要配置 `.yml` 文件,它位于 `/etc/filebeat/` 文件夹中: + +``` +sudo nano /etc/filebeat/filebeat.yml +``` + +我们只需要在这里配置两件事。在 Filebeat 输入部分,将类型改为 `log`,并取消对 `enabled:false` 的注释,将其改为 `true`。我们还需要指定存储日志的路径,也就是说,我们需要指定 `/opt/zeek/logs/current/*.log`。 + +完成这些后,设置的第一部分应该类似于图 1 所示的内容。 + +![Figure 1: Filebeat config (a)][2] + +第二件要修改的事情是在输出下的 Elasticsearch 输出部分,取消对 `output.elasticsearch` 和 `hosts` 的注释。确保主机的 URL 和端口号与你安装 ELK 时配置的相似。我们把它保持为 `localhost`,端口号为 `9200`。 + +在同一部分中,取消底部的用户名和密码的注释,输入安装后配置 ELK 时生成的 Elasticsearch 用户的用户名和密码。完成这些后,参考图 2,检查设置。 + +![Figure 2: Filebeat config (b)][3] + +现在我们已经完成了安装和配置,我们需要配置 Zeek,使其以 JSON 格式存储日志。为此,确保你的 Zeek 实例已经停止。如果没有,执行下面的命令来停止它: + +``` +cd /opt/zeek/bin +./zeekctl stop +``` + +现在我们需要在 `local.zeek` 中添加一小行,它存在于 `opt/zeek/share/zeek/site/` 目录中。 + +以 root 身份打开该文件,添加以下行: + +``` +@load policy/tuning/json-logs.zeek +``` + +参考图 3,确保设置正确。 + +![Figure 3: local.zeek file][4] + +由于我们改变了 Zeek 的一些配置,我们需要重新部署它,这可以通过执行以下命令来完成: + +``` +cd /opt/zeek/bin +./zeekctl deploy +``` + +现在我们需要在 Filebeat 中启用 Zeek 模块,以便它转发 Zeek 的日志。执行下面的命令: + +``` +sudo filebeat modules enable zeek +``` + +我们几乎要好了。在最后一步,配置 `zeek.yml` 文件要记录什么类型的数据。这可以通过修改 `/etc/filebeat/modules.d/zeek.yml` 文件完成。 + +在这个 .yml 文件中,我们必须提到这些指定的日志存放在哪个目录下。我们知道,这些日志存储在当前文件夹中,其中有几个文件,如 `dns.log`、`conn.log`、`dhcp.log` 等等。我们需要在每个部分提到每个路径。如果而且只有在你不需要该文件/程序的日志时,你可以通过把启用值改为 `false` 来舍弃不需要的文件。 + +例如,对于 `dns`,确保启用值为 `true`,并且路径被配置: + +``` +var.paths: [ “/opt/zeek/logs/current/dns.log”, “/opt/zeek/logs/*.dns.json” ] +``` + +对其余的文件重复这样做。我们对一些我们需要的文件做了这个处理。我们添加了所有主要需要的文件。你也可以这样做。请参考图 4。 + +![Figure 4: zeek.yml configuration][5] + +现在是启动 Filebeat 的时候了。执行以下命令: + +``` +sudo filebeat setup +sudo service filebeat start +``` + +现在一切都完成了,让我们移动到 Kibana 仪表板,检查我们是否通过 Filebeat 接收到来自 Zeek 的数据。 + +![Figure 5: Dashboard of Kibana (Destination Geo)][6] + +进入仪表板。你可以看到它所捕获的数据的清晰统计分析(图 5 和图 6)。 + +![Figure 6: Dashboard of Kibana (Network)][7] + +现在让我们进入发现选项卡,通过使用查询进行过滤来检查结果: + +``` +event.module: "zeek" +``` + +这个查询将过滤它在一定时间内收到的所有数据,只向我们显示名为 Zeek 的模块的数据(图 7)。 + +![Figure 7: Filtered data by event.module query][8] + +### 鸣谢 + +*作者感谢 VIT-AP 计算机科学与工程学院的 Sibi Chakkaravarthy Sethuraman、Sudhakar Ilango、Nandha Kumar R.和Anupama Namburu 的不断指导和支持。特别感谢人工智能和机器人技术卓越中心(AIR)。* + + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/06/integrating-zeek-with-elk-stack/ + +作者:[Tridev Reddy][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/tridev-reddy/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Integrating-Zeek-with-ELK-Stack-Featured-image.jpg +[2]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-1-Filebeat-config-a.jpg +[3]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-2-Filebeat-config-b.jpg +[4]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-3-local.zeek-file-1.jpg +[5]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-4-zeek.yml-configuration.jpg +[6]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-5-Dashboard-of-Kibana-Destination-Geo.jpg +[7]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-6-Dashboard-of-Kibana-Network-1.jpg +[8]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-7-Filtered-data-by-event.jpg diff --git a/published/202206/20220607 Linux Kernel 5.19 RC1 Released, Concluding ARM Generic Kernel Work.md b/published/202206/20220607 Linux Kernel 5.19 RC1 Released, Concluding ARM Generic Kernel Work.md new file mode 100644 index 0000000000..3e2c88b021 --- /dev/null +++ b/published/202206/20220607 Linux Kernel 5.19 RC1 Released, Concluding ARM Generic Kernel Work.md @@ -0,0 +1,100 @@ +[#]: subject: "Linux Kernel 5.19 RC1 Released, Concluding ARM Generic Kernel Work" +[#]: via: "https://www.debugpoint.com/2022/06/linux-kernel-5-19-rc1/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: "Donkey-Hao" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14692-1.html" + +Linux 内核 5.19 RC1 发布,完成了 ARM 通用内核的工作 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/10/100401b0t82bd0ww0o2tgn.jpg) + +> Linus Torvalds 发布了用来测试的 Linux 内核 5.19 RC1,带来了一些重大变化。 + +继上个月 [Linux 内核 5.18][1] 发布之后,Linus Torvalds 宣布了 Linux 内核 5.19 系列第一个候选版本。与此同时,Linux 内核 5.19 官方合并窗口关闭,这意味着除非是关键性的,否则不会再接受任何新功能。 + +简单看一下 Linux 内核 5.19 的新内容,会发现 CPU、GPU、网络、存储和核心模块都有常规的更新。此外,代码清理、淘汰过时硬件和对以后芯片组的持续支持是此版本的亮点。 + +在进一步介绍之前,让我们简单来看一下这些新特性。 + +### Linux 内核 5.19(RC1)的新特性 + +#### CPU + +首先需要提及的是,Linux 内核 5.19 开始 [初步支持][2] 龙芯架构的 CPU 系列。龙芯由中国龙芯中科公司设计开发。龙芯架构的 CPU 是兼容 MIPS 架构的通用微处理器。不过虽然现在提供了支持,但是你仍不能在龙芯 CPU 上启动 Linux,因为一些代码还在审核中。希望在 5.20 版本中能够使用。 + +新的 [英特尔 IFS 驱动][4] 在该版本中落地,这有助于在部署前后发现硬件问题。它能够在早期阶段检测电路层面的 CPU 错误。 + +在前几个针对英特尔 CPU 的内核版本中一直在对电源管理和散热方面进行开发,[这个版本][5] 也不例外。首先,为 Raptor 和 Alder Lake 家族添加了英特尔 运行时平均功率限制Run-Time Average Power Limiting(RAPL)的支持。其次,改进了 P-state 驱动以处理频率变化,并且基于 CPU 的缩放支持被添加到被动 devfreq 中。 + +虽然英特尔 CPU 主要是散热和电源管理方面的工作,但对 AMD CPU 系列来说有更多的性能更新。首先,计划在今年年底完成 ZMD Zen 4 CPU 的 基于指令的采样Instruction-Based Sampling(IBS)模块引入了更多更新。此外,此版本引入了 PerfMonV2,提供了更多性能监视能力。 + +此外,该版本中移除了 a.out 支持。同样,过时的 Renesas H8/300 CPU 也被移除了。 + +#### 主要 ARM 更新 + +终于,主线 Linux 内核能够 [支持 ARM 多平台][7] 了。在 Linus 的 RC1 开场白中可以看到,这是该版本中的巨大改变!从 Linux 3.7 开始,跨越了十多年的工作,这是多么漫长的过程。 + +![Linux 内核 5.19 Rc1 发布公告提到了 ARM 变化][8] + +#### 图形和存储升级 + +存储子系统在各种流行的文件系统中都有性能提升。最主要的变化包括苹果 M1 NVMe 控制器支持和对 XFS 文件系统的更好支持。此外,Btrfs、F2FS 以及 exFAT 文件系统也有增强。 + +在代码行数方面,有一个令人兴奋的指标是仅是图形驱动程序 Linux 内核 5.19 就增加了大约[50 万行代码][9]。它包括 AMD 的 RDNA、CDNA,英特尔的 Raptor Lake、DG2/Alchemist 等图形驱动更新。 + +#### 重要的网络变化 + +鉴于数据传输大幅增长,对 Big TCP 的支持有助于支持数据中心 400 GBit 级别的流量。它还可以在高性能网络环境中降低延迟。 + +继续改进了 多路径 TCPMulti-Path TCP(MPTCP)。此外,高通 ath11k WiFi 驱动程序在此版本中添加了网络唤醒功能。同样增加了对瑞昱的 8852ce 芯片、联发科的 T700 调制解调器以及瑞萨科技的 RZ/V2M 的支持。 + +#### 其他值得注意的功能 + +首先,内核中著名的随机函数生成器(RNG)在此版本中 [继续][10] 改进。 + +其次,著名的新兴的 Framework 模块化笔记本电脑获得了此版本 Chrome OS EC 驱动支持。Framework 笔记本现在可以作为一个非 Chromebook 设备利用 ChromeOS 的嵌入式控制器。 + +此外,Wacom 绘画板以及其他相关设备也有众多更新。[包括][11] 对联想 Thinkpad TrackPoint II、谷歌 Whiskers Touchpad、联想 X12 TrackPoint 等设备支持的提升。 + +### Linux 内核 5.19 下载 + +如果你想要测试并尝试该候选版本,可以在 [这里][12] 下载。 + +预计在 2022 年 7 月左右最终版本发布前,将会有多个版本更迭。 + +参考自:[内核邮件列表][17] + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2022/06/linux-kernel-5-19-rc1/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[Donkey-Hao](https://github.com/Donkey-Hao) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://www.debugpoint.com/2022/05/linux-kernel-5-18/ +[2]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c6f2f3e2c80e975804360665d973211e4d9390cb +[3]: http://www.loongson.cn/ +[4]: https://lore.kernel.org/lkml/13e61c61-0d4b-5f48-6373-f056bf8b603f@redhat.com/ +[5]: https://lore.kernel.org/linux-acpi/CAJZ5v0hKBt3js65w18iKxzWoN5QuEc84_2xcM6paSv-ZHwe3Rw@mail.gmail.com/ +[6]: https://lore.kernel.org/lkml/You6yGPUttvBcg8s@gmail.com/ +[7]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ecf0aa5317b0ad6bb015128a5b763c954fd58708 +[8]: https://www.debugpoint.com/wp-content/uploads/2022/06/Linux-Kernel-5.19-Rc1-release-announcement-mentions-ARM-changes.jpg +[9]: https://lore.kernel.org/lkml/CAPM=9tw62EZfAm0PbiOPmMrpfR98QMFTWGEQcA34G4ap4xxNkA@mail.gmail.com/ +[10]: https://lore.kernel.org/lkml/20220522214457.37108-1-Jason@zx2c4.com/T/#u +[11]: https://lore.kernel.org/lkml/nycvar.YFH.7.76.2205241107530.28985@cbobk.fhfr.pm/ +[12]: https://www.kernel.org/ +[13]: https://git.kernel.org/torvalds/t/linux-5.19-rc1.tar.gz +[14]: https://git.kernel.org/torvalds/p/v5.19-rc1/v5.18 +[15]: https://git.kernel.org/torvalds/ds/v5.19-rc1/v5.18 +[16]: https://git.kernel.org/torvalds/h/v5.19-rc1 +[17]: https://lore.kernel.org/lkml/CAHk-=wgZt-YDSKfdyES2p6A_KJoG8DwQ0mb9CeS8jZYp+0Y2Rw@mail.gmail.com/T/#u diff --git a/published/202206/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md b/published/202206/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md new file mode 100644 index 0000000000..18e0fae1d8 --- /dev/null +++ b/published/202206/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md @@ -0,0 +1,47 @@ +[#]: subject: "OpenInfra Foundation Launches ‘directed funding’ To Support Open Source Projects" +[#]: via: "https://www.opensourceforu.com/2022/06/openinfra-foundation-launches-directed-funding-to-support-open-source-projects/" +[#]: author: "Laveesh Kocher https://www.opensourceforu.com/author/laveesh-kocher/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14707-1.html" + +OpenInfra 基金会启动“定向资助”以支持开源项目 +====== +![OpenInfra][1] + +OpenInfra 基金会的前身为 OpenStack 基金会,几年前它将范围扩展到其旗舰项目之外,于是改了名字。2022 年 6 月 7 日,它宣布了一种有趣的新方式,让企业资助基金会内的开源项目。一般来说,开源基金会的企业成员通过支付会员费来支持该组织,然后基金会按照他们认为合适的方式分发这些费用。OpenInfra 基金会现在推出了一种新的“定向资助”模式,允许成员将他们的资金直接用于项目。 + +此前,基金会并不允许这样做,因为正如 Bryce 指出的那样,它可能会产生混合激励和付费游戏动态,而该组织一直试图避免这种情况。然而,社区对支持特定项目有很大的兴趣,这是有道理的,因为该基金会现在拥有更多种类的项目,但并不是每个成员都对每个项目进行了大量投入。 + +Bryce 表示,基金会的领导层和董事会,花费了大量时间来考虑,如何使基金会的核心原则与这种新模式相协调。因此,该模型试图将过去十年运行良好的 OpenStack/OpenInfra 技术治理模型的优点,与这些新的财务考虑相结合。 + +在这种“定向资助”模式下,每个新项目都将拥有自己的法人实体来持有项目资金。为确保新项目的合法性,OpenInfra 白金会员(目前为 9 家,包括蚂蚁集团、华为、Meta、微软和红帽)必须担任项目的发起人,之后其他组织才能加入项目基金。如果赞助公司还不是 OpenInfra 成员,则必须成为成员。然后,所有这些资助成员组成一个项目基金管理委员会,决定创建预算的费用。与此同时,OpenInfra 基金会将为这些项目提供社区建设服务。 + +这种新模式暂时只适用于加入基金会的新项目。Bryce 和 Collier 指出,组织可能会在一些现有项目中追溯应用这种新模式,但这个考虑目前不在路线图上。 + +自从将范围扩展到 OpenStack 之外后,OpenInfra 基金会增加了一些新项目,例如用于提高容器安全性的 Kata Containers、用于基础设施生命周期管理的 Airship、Startling X 边缘计算堆栈以及 Zuul CI/CD 平台。 + +“我们从每个成功的项目中学到的最重要的一点是,协作是关键,支持生态系统的范围越广越好,” OpenInfra 基金会总经理 Thierry Carrez 说,“事实上,我们发现最成功的开源项目是由多家公司资助的,因为他们能够整合资源以实现更高的回报率。” + +这种新模式显然是 OpenInfra 基金会引入新项目和新成员的一种方式。正如领导团队欣然承认的那样,其在多方生态系统中管理开源项目的模型 —— 无论是通过新的定向资金还是更传统的方法 —— 可能并不适合每个项目。即使 OpenInfra 基金会只收到一小部分项目,随着对这些复杂云基础设施项目需求的增长,开源项目的数量也在增加,同时它们也变得更加复杂。 + +基金会还宣布了其各个项目的几个里程碑版本的发布,包括 Kata Containers 2.0 版、Zuul 5.0 版和 StarlingX 6.0 。 + +Collier 说:“基金会今年庆祝成立 10 周年,在展望下一个十年的开放基础设施之际,我们正在推动我们的模型如此成功的关键,那就是:将希望合作的公司和个人联合起来,为他们提供一个框架和有效协作的工具,并帮助他们投资资金以最好地帮助他们关心的项目。” + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/06/openinfra-foundation-launches-directed-funding-to-support-open-source-projects/ + +作者:[Laveesh Kocher][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/laveesh-kocher/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/06/open-infra-berlin-event.png diff --git a/published/202206/20220608 How I gave my old laptop new life with the Linux Xfce desktop.md b/published/202206/20220608 How I gave my old laptop new life with the Linux Xfce desktop.md new file mode 100644 index 0000000000..428b8d4814 --- /dev/null +++ b/published/202206/20220608 How I gave my old laptop new life with the Linux Xfce desktop.md @@ -0,0 +1,93 @@ +[#]: subject: "How I gave my old laptop new life with the Linux Xfce desktop" +[#]: via: "https://opensource.com/article/22/6/linux-xfce-old-laptop" +[#]: author: "Jim Hall https://opensource.com/users/jim-hall" +[#]: collector: "lkxed" +[#]: translator: "lightchaserhy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14735-1.html" + +我如何利用 Xfce 桌面为旧电脑赋予新生 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/20/143325vfdibhvv22qvddiv.jpg) + +> 当我为了在一场会议上做演示,用笔记本电脑安装 Linux 系统后,发现 Linux 和 Xfce 桌面让我的这台旧电脑健步如飞。 + +几周前,我要在一个会议上简要演示自己在 Linux 下编写的一款小软件。我需要带一台 Linux 笔记本电脑参会,因此我翻出一台旧笔记本电脑,并且安装上 Linux 系统。我使用的是 Fedora 36 Xfce 版,使用还不错。 + +这台我用的笔记本是在 2012 年购买的。1.70 GHZ 的 CPU、4 GB 的 内存、128 GB 的硬盘,也许和我现在的桌面电脑比性能很弱,但是 Linux 和 Xfce 桌面赋予了这台旧电脑新的生命。 + +### Linux 的 Xfce 桌面 + +Xfce 桌面是一个轻量级桌面,它提供一个精美、现代的外观。熟悉的界面,有任务栏或者顶部“面板”可以启动应用程序,在系统托盘可以改变虚拟桌面,或者查看通知信息。屏幕底部的快速访问停靠区让你可以启动经常使用的应用程序,如终端、文件管理器和网络浏览器。 + +![Image of Xfce desktop][6] + +要开始一个新应用程序,点击左上角的应用程序按钮。这将打开一个应用程序启动菜单,顶部有常用的应用程序,比如终端和文件管理。其它的应用程序会分组排列,这样你可以找到所需要的应用。 + +![Image of desktop applications][7] + +### 管理文件 + +Xfce 的文件管理器时叫 Thunar,它能很好地管理我的文件。我喜欢 Thunar 可以连接远程系统,在家里,我用一个开启 SSH 的树莓派作为个人文件服务器。Thunar 可以打开一个 SSH 文件传输窗口,这样我可以在笔记本电脑和树莓派之间拷贝文件。 + +![Image of Thunar remote][9] + +另一个访问文件和文件夹的方式是通过屏幕底部的快速访问停靠区。点击文件夹图标可以打开一个常用操作的菜单,如在终端窗口打开一个文件夹、新建一个文件夹或进入指定文件夹等。 + +![Image of desktop with open folders][10] + +### 其它应用程序 + +我喜欢探索 Xfce 提供的其他应用程序。Mousepad 看起来像一个简单的文本编辑器,但是比起纯文本编辑,它包含更多有用的功能。Mousepad 支持许多文件类型,程序员和其他高级用户也许会非常喜欢。可以在文档菜单中查看一下部分编程语言的列表。 + +![Image of Mousepad file types][11] + +如果你更喜欢一个不同的外观和感觉,可以用视图菜单调整界面选项,如字体、配色方案以及行号。 + +![Image of Mousepad in color scheme solarized][12] + +磁盘工具可以让你管理储存设备。虽然我不需要修改我的系统磁盘,磁盘工具是一个初始化或重新格式化 USB 闪存设备的好方式。我认为这个界面非常简单好用。 + +![Image of disk utility][13] + +Geany 集成开发环境也给我留下了深刻印象,我有点惊讶于一个完整的集成开发软件(IDE)可以在一个旧系统可以如此流畅地运行。Geany 宣称自己是一个“强大、稳定和轻量级的程序员文本编辑器,提供大量有用的功能,而不会拖累你的工作流程”。而这正是 Geany 所提供的。 + +我用一个简单的 “hello world” 程序测试 Geany,当我输入每一个函数名称时,很高兴地看到 IDE 弹出语法帮助,弹出的信息并不特别显眼,且刚好提供了我需要的信息。虽然我能很容易记住 `printf` 函数,但总是忘记诸如 `fputs` 和 `realloc` 之类的函数的选项顺序,这就是我需要弹出语法帮助的地方。 + +![Image of Geany workspace][14] + +深入了解 Xfce 的菜单,寻找其它应用程序,让你的工作更简单,你将找到可以播放音乐、访问终端或浏览网页的应用程序。 + +当我在笔记本电脑上安装了 Linux,在会议上做了一些演示后,我发现 Linux 和 Xfce 桌面让这台旧电脑变得相当敏捷。这个系统运行得如此流畅,以至于当会议结束后,我决定把这台笔记本电脑作为备用机。 + +我确实喜欢在 Xfce 中工作和使用这些应用程序,尽管系统开销不大,使用也很简单,但我并没有感觉到不够用,我可以用 Xfce 和上面的应用程序做任何事情。如果你有一台需要翻新的旧电脑,试试安装 Linux,给旧硬件带来新的生命。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/6/linux-xfce-old-laptop + +作者:[Jim Hall][a] +选题:[lkxed][b] +译者:[lightchaserhy](https://github.com/lightchaserhy) +校对:[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/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/coffee_tea_laptop_computer_work_desk.png +[2]: https://unsplash.com/@jonasleupe?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]: https://unsplash.com/s/photos/tea-cup-computer?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: https://spins.fedoraproject.org/xfce/download/index.html +[5]: https://opensource.com/article/19/12/xfce-linux-desktop +[6]: https://opensource.com/sites/default/files/2022-06/Linuxlaptop1.png +[7]: https://opensource.com/sites/default/files/2022-06/linuxlaptopDesktopApps.png +[8]: https://opensource.com/article/20/3/personal-file-server-ssh +[9]: https://opensource.com/sites/default/files/2022-06/LinuxlaptopThunarremote.png +[10]: https://opensource.com/sites/default/files/2022-06/LinuxlaptopDesk.png +[11]: https://opensource.com/sites/default/files/2022-06/LinuxlaptopMousepadfiletype.png +[12]: https://opensource.com/sites/default/files/2022-06/Linuxlaptopmousepadsolarized.png +[13]: https://opensource.com/sites/default/files/2022-06/linuxlaptopdisks.png +[14]: https://opensource.com/sites/default/files/2022-06/Linuxlaptopgeany.png diff --git a/published/202206/20220609 Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet.md b/published/202206/20220609 Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet.md new file mode 100644 index 0000000000..2fd9490dd6 --- /dev/null +++ b/published/202206/20220609 Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet.md @@ -0,0 +1,87 @@ +[#]: subject: "Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet" +[#]: via: "https://news.itsfoss.com/cloudflare-pat/" +[#]: author: "Jacob Crume https://news.itsfoss.com/author/jacob/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14711-1.html" + +Cloudflare 有了一个新东西,它可以替代互联网上烦人的验证码 +====== + +不想通过正确输入 验证码CAPTCHA 来证明自己是个人类吗?Cloudflare 可能有了一个解决方案。 + +![Cloudflare][1] + +互联网服务巨头 Cloudflare 前两天 [宣布了][2] 私有访问令牌Private Access Tokens 功能。这项功能旨在减少你在网络上看到的验证码数量,同时改善你的隐私。 + +你可能已经发现,验证码在移动设备上是一种可怕的体验。通常,它们会最终会占据整个屏幕,有时甚至无法完成。 + +作为替代方案,网站可以选择收集唯一识别数据,以证明你是人类。当然,从隐私的角度来看,这种做法是很糟糕的。如果这么做,许多重视隐私的公司都几乎无法避免他们受到 僵尸攻击bot attacks。 + +幸运的是,私有访问令牌(PAT)的发布将改变这一点。 + +### 私有访问令牌会产生什么影响? + +简而言之,私有访问令牌能够做到下面这些事: + +* 在支持的设备上减少验证码数量 +* 增强用户隐私 +* 允许网站所有者确保访问者来自真实设备 + +然而,深入观察,我们可以看到私有访问令牌的影响力远不止于此。若使用传统的验证码,就有多个实体可以访问你的数据。 + +首先,你正在访问的网站知道你的 IP 地址和你正在访问的 URL。当然,这些数据是建立连接所需的最低要求。此外,对于更高级的功能,网站还会发送一些用户代理(UA)数据,还好这些数据并不是唯一可识别的。 + +然而,另一方,也就是验证码提供者,却可以收集更多的数据。与你要访问的网站一样,它也知道你的 IP 地址、用户代理数据和你访问的 URL。不幸的是,除此之外,他们还会收集其他数据,例如你的设备信息和交互数据。如果把这些信息,与你之前完成验证码的时间联系起来,你就会惊讶的发现,他们可以建立一个非常详细的属于你的个人资料。 + +幸运的是,有了 Cloudflare 的私有访问令牌,你就可以完全绕过验证码,从而阻止验证码提供者收集此类数据。 + +### 私有访问令牌是如何工作的? + +![][3] + +验证码的理念是集中尽可能多的数据,私人访问令牌则恰恰相反,它将数据去中心化,因此任何一方都无法唯一识别你。在你提到数据共享之前,Cloudflare 就已经特别指出了,数据不会在各方之间共享。 + +当你访问使用 Cloudflare 和私人访问令牌的网站的时候,共有三方将处理你的数据的不同部分。 + +1. 网站。它只会知道你的 IP、URL 和用户代理,这也是建立连接所必需的。 +2. 你的设备制造商。他们只会知道那些用于验证设备是否真实所需的设备数据,而不会知道你正在访问哪个网站,或你的 IP 地址是什么。验证了你的设备后,他们将生成一个令牌,该令牌将发送到 Cloudflare。 +3. Cloudflare。他们将收到这个令牌,令牌中不包含你的任何设备数据,只有制造商对它是正品的“保证”。他们知道的唯一其他数据,就是你正在访问的网站,同样,这是为你提供内容所必需的。 + +通过这种方式,Cloudflare 无需接触你的数据,就可以对“你是一个人”充满信心。 + +### 支持的操作系统:没有 Linux? + +你可能已经意识到,私人访问令牌需要特定的操作系统功能才能工作。目前,它们仅存在于苹果最新的操作系统上,即 iOS 和 iPadOS 16,以及 macOS Ventura。这是因为苹果的操作系统只在有限的硬件上运行,设备验证会更加容易。 + +另一方面,Linux 是一种通用操作系统,旨在在各种硬件上运行。因此,我认为,在可预见的未来,它都不会支持私人访问令牌。 + +回到苹果,我想到私人访问令牌也可能导致消费者维修设备的权利出现一些问题。例如,如果我用第三方的非正品电池更换了老旧的 iPhone 原装电池,私人访问令牌系统会特殊对待这种情况吗? + +如果是 Linux 手机呢?这些制造商,如 Pine64 和 Purism,可能没有支持这样一个系统的基础设施。是否可以在这些上使用私人访问令牌呢? + +Cloudflare 在 [公告][4] 中提到: + +> 我们正在积极努力让其他客户和设备制造商也使用私人访问令牌框架。每当新客户开始使用它时,从该客户进入你网站的流量将自动开始要求令牌,你的访问者将自动看到更少的验证码。 + +因此,我们希望看到它被更多的设备和操作系统采用。你如何看待 Cloudflare 的私人访问令牌呢?在下面的评论中发表你的看法吧! + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/cloudflare-pat/ + +作者:[Jacob Crume][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/cloudflare-private-access-tokens.jpg +[2]: https://blog.cloudflare.com/eliminating-captchas-on-iphones-and-macs-using-new-standard/ +[3]: https://news.itsfoss.com/wp-content/uploads/2022/06/PAT-Data-transfer-chart-1024x650.png +[4]: https://blog.cloudflare.com/eliminating-captchas-on-iphones-and-macs-using-new-standard/ diff --git a/published/202206/20220609 Edit PDFs on Linux with these open source tools.md b/published/202206/20220609 Edit PDFs on Linux with these open source tools.md new file mode 100644 index 0000000000..50d82225cc --- /dev/null +++ b/published/202206/20220609 Edit PDFs on Linux with these open source tools.md @@ -0,0 +1,89 @@ + [#]: subject: "Edit PDFs on Linux with these open source tools" +[#]: via: "https://opensource.com/article/22/6/open-source-pdf-editors-linux" +[#]: author: "Michael Korotaev https://opensource.com/users/michaelk" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14761-1.html" + +用这些开源工具在 Linux 上编辑 PDF 文件 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/26/152728d3kajokj34t3agwm.jpg) + +> Adobe Acrobat 的开源替代品具有创建、编辑和注释 PDF 的所有必要功能。 + +开源的 PDF 阅读和编辑工具通常比 “PDF 编辑器” 搜索结果第一页中的应用更安全和可靠。在那里,你很可能看到带有隐藏的限制和关税的专有应用,缺乏关于数据保护政策和托管的足够信息。你可以有更好的。 + +这里有五个应用,可以安装在你的 Linux 系统上(和其他系统)或托管在服务器上。每一个都是自由而开源的,具有创建、编辑和注释 PDF 文件的所有必要功能。 + +### LibreOffice + +使用 [LibreOffice][2] 套件,你对应用的选择取决于最初的任务。虽然文字处理器 LibreOffice Writer,可以让你创建 PDF 文件,并从 ODF 和其他文本格式导出,但 Draw 更适合于处理现有的 PDF 文件。 + +Draw 是用来创建和编辑图形文件的,如小册子、杂志和海报。因此,其工具集主要用于视觉对象和布局上。然而,对于 PDF 编辑,当文件具有可编辑属性时,LibreOffice Draw 提供了用于修改和添加 PDF 内容的工具。如果没有的话,你仍然可以在现有的内容层上添加新的文本字段,并对文件进行注释或完成。 + +Draw 和 Writer 都被捆绑在 LibreOffice 桌面套件中,可在 Linux 系统、macOS 和 Windows 上安装。 + +### ONLYOFFICE Docs + +ONLYOFFICE 一直在改进 PDF 的处理,并在 [ONLYOFFICE Docs][3] 的 7.1 版本中引入了一个全新的 PDF 和电子书的阅读器。 + +该文档编辑器允许从头开始创建 PDF 文件,使用 DOCX 作为文件的基础,然后可以转换为 PDF 或 PDF/A。通过内置的表单创建功能,ONLYOFFICE Docs 还可以建立可填充的文档模板,并将其导出为可编辑的 PDF,并为不同类型的内容设置可填充的字段:文本、图像、日期等。 + +除了可以识别 PDF 内的文本进行复制和提取外,ONLYOFFICE Docs 还可以将 PDF 转换为 DOCX,这样你就可以继续使用完全可编辑的文本格式的文件。ONLYOFFICE 还可以让你用密码保护文件,添加水印,并使用桌面版中的数字签名。 + +ONLYOFFICE Docs 可以作为一个网络套件(内部或云端)集成到文档管理系统(DMS)或作为一个独立的桌面应用程序使用。你可以将后者作为 DEB 或 RPM 文件、AppImage、Flatpack 和其他几种格式在 Linux 中安装。 + +### PDF Arranger + +[PDF Arranger][4] 是 PikePDF 库的一个前端应用。它不像 LibreOffice 和 ONLYOFFICE 那样用于对 PDF 的内容进行编辑,但它对于重新排序页面、将 PDF 分割成更小的文件、将几个 PDF 合并成一个、旋转或裁剪页面等都很好。它的界面是直观的,易于使用。 + +PDF Arranger 可用于 Linux 和 Windows。 + +### Okular + +[Okular][5] 是一个由 KDE 社区开发的免费开源文档查看器。该应用的功能非常成熟,可以查看 PDF、电子书、图片和漫画。 + +Okular 完全或部分支持大多数流行的 PDF 功能和使用场景,如添加注释和内联笔记或插入文本框、形状和印章。你还可以为文档添加数字加密签名,这样你的读者就可以确定文档的来源。 + +除了在 PDF 中添加文本和图像外,还可以从文档中检索到它们,以复制和粘贴到其他地方。Okular 中的区域选择工具可以识别所选区域内的组件,所以你可以从 PDF 中独立提取它们。 + +你可以使用你的发行版包管理器或以 Flatpak 的形式安装 Okular。 + +### Xournal++ + +[Xournal++][6] 是一款带有 PDF 文件注释工具的手写日记软件。 + +它是一款具有强化手写功能的记事软件,对于处理基于文本的内容和专业布局来说,它可能不是最佳选择。然而,它渲染图形的能力以及对书写和绘图的手写笔输入的支持使它作为一个小众生产力工具脱颖而出。 + +图层管理工具、可定制的笔尖设置以及对手写笔映射的支持,使 PDF 注释和草图绘制变得更加舒适。Xournal++ 还有一个文本工具,用于添加文本框,并能插入图像。 + +Xournal++ 可在 Linux 系统(Ubuntu、Debian、Arch、SUSE)、MacOS 和 Windows(10及以上)中安装。 + +### 总结 + +如果你正在寻找一个免费和安全的专有 PDF 浏览和编辑软件的替代品,不难找到一个开源的选择,无论是桌面还是在线使用。只要记住,目前可用的解决方案在不同的使用情况下有各自的优势,没有一个工具在所有可能的任务中都同样出色。 + +这五个方案因其功能或对小众 PDF 任务的有用性而脱颖而出。对于企业使用和协作,我建议使用 ONLYOFFICE 或 LibreOffice Draw。PDF Arranger 是一个简单的、轻量级的工具,当你不需要改变文本时,可以用它来处理页面。Okular 为多种文件类型提供了很好的查看功能,如果你想在 PDF 中画草图和做笔记,Xournal++ 是最佳选择。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/6/open-source-pdf-editors-linux + +作者:[Michael Korotaev][a] +选题:[lkxed][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/michaelk +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/checklist_hands_team_collaboration.png +[2]: https://opensource.com/article/21/9/libreoffice-tips +[3]: https://opensource.com/article/20/12/onlyoffice-docs +[4]: https://flathub.org/apps/details/com.github.jeromerobert.pdfarranger +[5]: https://opensource.com/article/22/4/linux-kde-eco-certification-okular +[6]: http://xournal.sourceforge.net/ diff --git a/published/202206/20220609 openSUSE Leap 15.4 Release Adds Leap Micro 5.2, Updated Desktop Environments, and More.md b/published/202206/20220609 openSUSE Leap 15.4 Release Adds Leap Micro 5.2, Updated Desktop Environments, and More.md new file mode 100644 index 0000000000..740bfc4082 --- /dev/null +++ b/published/202206/20220609 openSUSE Leap 15.4 Release Adds Leap Micro 5.2, Updated Desktop Environments, and More.md @@ -0,0 +1,100 @@ +[#]: subject: "openSUSE Leap 15.4 Release Adds Leap Micro 5.2, Updated Desktop Environments, and More" +[#]: via: "https://news.itsfoss.com/opensuse-leap-15-4-release/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "robsean" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14695-1.html" + +openSUSE Leap 15.4 发布版本添加了 Leap Micro 5.2、更新桌面环境等等 +====== + +> 为奋起直追 SUSE Linux Enterprise 的 SP 4 ,openSUSE Leap 15.4 到来了,带来了新的升级和极其重要的改善。 + +![opensuse 15.4][1] + +即将到来的 openSUSE 小发布版本终于来了。如果你使用 openSUSE 作为你日常使用的桌面或服务器版本,你现在可能已经测试候选版本好几周了。 + +openSUSE Leap 15.4 的重点是软件包的更新,用以奋起直追 SUSE Linux Enterprise 的 SP 4 。因此,你将注意到一些弃用的软件包,以及可用于替换它们的新的升级。 + +当然,你应该有一些可用的软件包来确保兼容性。但是,大多数较旧的版本已经被移除。 + +### openSUSE Leap 15.4: 有什么新的变化? + +为与最新的 SUSE Linux Enterprise(SLE)相适应,像 Python 2 和 KDE 4 一样的软件包已经被移除。你可以在这次的发布版本中找到较新的桌面环境。 + +此外,在容器和 AI/ML 用例方面,更新了 Podman、Containerd、Tensorflow 和 Grafana。 + +#### Leap Micro 5.2 + +Leap Micro 是针对容器和虚拟化工作负载定制的轻量级操作系统的最新版本。它也是 Leap 版的 [MicroOS][2],是 Tumbleweed 的一种变体,提供了自动管理和修补。 + +#### 桌面环境 + +Xfce 4.16 继续保留,但你可以找到主要功能的一些新补充,包括新图标和调色板。 + +Xfce 4.16 中的设置管理器也获得了视觉上的刷新。类似地,文件管理器(Thunar)也有一些改善,新的状态托盘插件的深色模式支持等等。 + +KDE 4 软件包已经被弃用,Plasma 5.24 LTS 已经作为长期支持版本中包含于其中。 + +要深入了解这些变化,你可以查看我们之前针对 [KDE Plasma 5.24 LTS][3] 的报道。总体来说,新的 KDE Plasma 体验应该会令桌面用户赞叹。 + +说到 GNOME,你可以发现包含在 openSUSE Leap 15.4 中的 GNOME 41 带来了一系列的改善和新的特色功能。了解更多关于 [GNOME 41][4] 的信息,你可以期待它的一些新的特色功能。 + +对于其它的可用的桌面环境来说,Leap 15.4 包括: + +* MATE 桌面环境 1.26 +* Enlightenment 桌面环境0.25.3 +* 深度桌面环境 20.3 + +#### 弃用的软件包 + +移除了一些基础的软件包,包括 Python 2(生命终结)、Digikam、TensorFlow 1.x 和 Qt 4 等软件包。 + +在更新系统后,你可以使用 Qt 5 和 Plasma 5 。 + +#### 更新的软件包 + +很多重要的软件包在 Leap 15.4 中得到了更新,包含一些流行的软件包: + +* TensorFlow 2.6.2 +* Podman 3.4.4 +* GNU Health 4.0 +* sudo 1.9.9 +* systemd 249.10 +* AppArmor 3.04 +* DNF 4.10.0 +* LibreOffice 7.2.5 + +因此,你应该会注意到一些针对服务器用户和桌面用户的各种应用程序的有用更新。很多多媒体应用程序,像 VLC、GNOME MPV 等,都得到了升级。 + +#### 其它改善 + +随着基本软件的更新和清理,你也可以找到一个由 SUSE 维护的较新的 Linux 内核 5.14.21。 + +更新后的内核对硬件的支持应该会有改善。 + +更多信息,你可以参考针对 [openSUSE Leap 15.4][5] 的发布版本说明。 + +> **[下载 openSUSE Leap 15.4][6]** + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/opensuse-leap-15-4-release/ + +作者:[Ankush Das][a] +选题:[lkxed][b] +译者:[robsean](https://github.com/robsean) +校对:[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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/opensuse-leap-15-4.jpg +[2]: https://microos.opensuse.org/ +[3]: https://news.itsfoss.com/kde-plasma-5-24-lts-release/ +[4]: https://news.itsfoss.com/gnome-41-release/ +[5]: https://doc.opensuse.org/release-notes/x86_64/openSUSE/Leap/15.4/#rnotes +[6]: https://get.opensuse.org/leap/15.4/ diff --git a/published/202206/20220610 Manage Flatpak Permission Using Flatseal.md b/published/202206/20220610 Manage Flatpak Permission Using Flatseal.md new file mode 100644 index 0000000000..28207dbe14 --- /dev/null +++ b/published/202206/20220610 Manage Flatpak Permission Using Flatseal.md @@ -0,0 +1,116 @@ +[#]: subject: "Manage Flatpak Permission Using Flatseal" +[#]: via: "https://www.debugpoint.com/2022/06/manage-flatpak-permission-flatseal/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14736-1.html" + +使用 Flatseal 管理 Flatpak 的权限 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/20/151550qkrkpjw4f9dpjo50.jpg) + +> 了解如何使用 Flatseal 应用管理 Flatpak 权限,它为你提供了一个友好的 GUI 和额外的功能。 + +从新用户的角度来看,在 Linux 中安装应用可能是一个挑战。主要原因是有这么多的 [Linux 发行版][1]。而你需要为各种 Linux 发行版提供不同的安装方法或说明。对于一些用户来说,这可能会让他们不知所措。此外,对于开发者来说,为不同的发行版创建独立的软件包和构建也很困难。 + +### Flatpak 解决了这个问题。如何解决? + +它使用了容器技术,使同一个应用的可执行文件在所有的 Linux 平台上都能类似地运行。例如,一个单一的可执行文件可以在 Ubuntu、Fedora、OpenSUSE、Arch Linux 和许多其他平台上运行。 + +此外,开发人员还可以减少为不同平台打包同一应用的努力。他们可以专注于应用的功能,而不是发行或部署。 + +此外,Flatpak 应用还能即时更新,当有了最新版本,你就能得到它。 + +所有这些好处也开启了一个重要的问题。Flatpak 应用需要的权限是什么?你如何轻松地管理它们?例如,一个应用可能只需要网络访问,而不需要磁盘空间。或者另一个可能有截图的权限,但可能根本就不需要。 + +所以,审查一个 Flatpak 应用的权限是非常必要的。这与你的安卓或 iOS 应用的权限类似。 + +最后,即使你是一个新用户,管理和审查权限也不是那么困难,这要感谢图形化的应用 - Flatseal。 + +### 什么是 Flatseal? + +Flatseal 是一个 Flatpak 应用,它为你提供了一个友好的用户界面来查看和改变你系统中所有 Flatpak 应用的权限。 + +它是一个优秀的小程序,每个应用的每个权限部分都有一个易于使用的切换按钮。下面是它的外观(图 1)。 + +![Figure 1 – Flatseal App][2] + +### 你如何使用 Flatseal 来管理 Flatpak 的权限? + +当打开 Flatseal 应用时,它应该在左边的导航栏列出所有的 Flatpak 应用。而当你选择了一个应用,它就会在右边的主窗口中显示可用的权限设置。 + +现在,对于每个 Flatpak 权限控制,当前值显示在切换开关中。如果该权限正在使用中,它应该被启用。否则,它应该是灰色的。 + +首先,要设置权限,你必须进入你的系统的应用。然后,你可以从权限列表中启用或禁用任何各自的控制。 + +其次,如果你想设置一个适用于你系统中所有 Flatpak 的全局控制,你可以在左上方选择“所有应用”并应用全局设置(图 2)。 + +![Figure 2: Manage Flatpak Permission using Flatseal][3] + +这真是超级简单。不是吗? + +### 使用 Flatseal 管理 Flatpak 权限的例子 + +让我们举个例子。 + +在我的系统中,我安装了上述 Flatpak(图 2)。让我们挑选 Telegram 桌面应用。目前,Telegram 桌面没有访问任何主目录或用户文件的权限(图 3)。 + +![Figure 3: Telegram Desktop Flatpak App does not have permission to the home folders][4] + +现在,如果我想允许所有的用户文件和某个特定的文件夹(例如:`/home/Downloads`),你可以通过打开启用开关来给予它。请看下面的图 4。 + +![Figure 4: Permission changed of Telegram Desktop to give access to folders][5] + +同样地,你可以启用或禁用你想要的权限。在内部,Flatseal 执行内部的 Flatpak 命令来实现这一点。 + +例如,上述情况可能转化为以下命令。 + +``` +flatpak override org.telegram.desktop --filesystem=/home/Downloads +``` + +而要删除权限: + +``` +flatpak override org.telegram.desktop --nofilesystem=/home/Downloads +``` + +Flatseal 还有一个很酷的功能,它在用户特定的权限变化旁边显示一个小的警报图标(见图 4)。 + +### 我可以在所有的 Linux 发行版中安装 Flatseal 吗? + +是的,你可以把 [Flatseal][6] 作为 Flatpak 安装在所有 Linux 发行版中。你可以使用 [本指南][7] 设置你的系统,并运行以下命令进行安装。或者,[点击这里][8] 直接启动特定系统的安装程序。 + +``` +flatpak install flathub com.github.tchx84.Flatseal +``` + +### 结束语 + +我希望上面的 Flatpak 权限管理指南足够简单,让你了解并开始使用 Flatpak。它超级容易控制,使用起来也容易得多。另外,你可能想访问我们更多的 [Flatpak 指南][9]。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2022/06/manage-flatpak-permission-flatseal/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://www.debugpoint.com/category/distributions +[2]: https://www.debugpoint.com/wp-content/uploads/2022/06/Flatseal-App.jpg +[3]: https://www.debugpoint.com/wp-content/uploads/2022/06/Manage-Flatpak-Permission-using-Flatseal.jpg +[4]: https://www.debugpoint.com/wp-content/uploads/2022/06/Telegram-Desktop-Flatpak-App-does-not-have-permission-to-the-home-folders.jpg +[5]: https://www.debugpoint.com/wp-content/uploads/2022/06/Permission-changed-of-Telegram-Desktop-to-give-access-to-folders.jpg +[6]: https://flathub.org/apps/details/com.github.tchx84.Flatseal +[7]: https://flatpak.org/setup/ +[8]: https://dl.flathub.org/repo/appstream/com.github.tchx84.Flatseal.flatpakref +[9]: https://www.debugpoint.com/tag/flatpak/ diff --git a/published/202206/20220610 Run Windows Apps And Games Using WineZGUI On Linux.md b/published/202206/20220610 Run Windows Apps And Games Using WineZGUI On Linux.md new file mode 100644 index 0000000000..64081739db --- /dev/null +++ b/published/202206/20220610 Run Windows Apps And Games Using WineZGUI On Linux.md @@ -0,0 +1,178 @@ +[#]: subject: "Run Windows Apps And Games Using WineZGUI On Linux" +[#]: via: "https://ostechnix.com/winezgui-run-windows-apps-and-games-on-linux/" +[#]: author: "sk https://ostechnix.com/author/sk/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14744-1.html" + +在 Linux 上使用 WineZGUI 运行 Windows 应用和游戏 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/22/160322tds2ut05d8jqdlzz.jpg) + +> WineZGUI - 一个使用 Zenity 的 Wine GUI 前台 + +不久前,我们写了关于 [Bottles][1] 的文章,这是一个开源的图形应用,可以在 Linux 操作系统上轻松运行 Windows 软件和游戏。今天,我们将讨论一个类似的有趣项目。向 **WineZGUI** 打个招呼,它是一个 Wine GUI 前台,可以 [在 Linux 上用 Wine 运行 Windows 应用和游戏][2]。 + +### 什么是 WineZGUI? + +WineZGUI 是一个 Bash 脚本的集合,它允许你轻松地管理 Wine 前缀,并在 Linux 上使用 **Zenity** 提供更轻松的 Wine 游戏体验。 + +(LCTT 译注:Wine 前缀是一个特殊文件夹,Wine 在其中放置所有 Wine 特定的文件,安装 Windows 程序、库和注册表代码,以及用户首选项。) + +使用 WineZGUI,我们可以直接从文件管理器中启动 Windows EXE 文件或游戏,而无需安装它们。 + +WineZGUI 为每个应用或游戏创建快捷方式,以便于访问,同时也为每个 EXE 二进制文件创建单独的前缀。 + +当你用 WineZGUI 启动一个 Windows EXE 文件时,它会提示你是否使用默认的 Wine 前缀或创建一个新的前缀。默认的前缀是 `~/.local/share/winezgui/default`。 + +如果你选择为 Windows 二进制文件(EXE)创建一个新的前缀,WineZGUI 将尝试从 EXE 文件中提取产品名称和图标,并创建一个桌面快捷方式。 + +当你以后启动相同的二进制文件(EXE)时,它将建议你用先前的相关前缀来运行它。 + +说得通俗一点,WineZGUI 只是一个用于官方原始 Wine 的简单 GUI。当我们启动一个 EXE 来玩游戏时,Wine 前缀的设置是自动的。 + +你只需打开一个 EXE,它就会创建一个前缀和一个桌面快捷方式,并从该 EXE 中提取名称和图标。 + +它使用 `exiftool` 和 `icotool` 工具来分别提取名称和图标。你可以通过现有的前缀打开一个 EXE 来启动该游戏,或者使用桌面快捷方式。 + +WineZGUI 是一个在 GitHub 上免费托管的 shell 脚本。你可以抓取源代码,改进它,修复错误和增加功能。 + +### Bottles Vs WineZGUI + +你可能想知道 WineZGUI 与 Bottles 相比如何。但这些应用之间有一个微妙的区别。 + +**Bottles 是面向前缀的**和**面向运行器的**。意思是:Bottles 首先创建一个前缀,然后使用不同的 EXE 文件。Bottles 不会记住 EXE 的前缀。Bottles 使用不同的运行器。 + +**WineZGUI 是面向 EXE 的**。它使用 EXE 并只为该 EXE 创建一个前缀。下次我们打开一个 EXE 时,它将询问是否用现有的 EXE 前缀启动。 + +WineZGUI 不提供像 Bottles 或 [lutris][3] 那样的高级功能,如运行程序、在线安装程序等。 + +### 如何在 Linux 中安装 WineZGUI + +确保你已经安装了 WineZGUI 的必要先决条件。 + +Debian/Ubuntu: + +``` +$ sudo dpkg --add-architecture i386 +$ sudo apt install zenity wine winetricks libimage-exiftool-perl icoutils gnome-terminal +``` + +Fedora: + +``` +$ sudo dnf install zenity wine winetricks perl-Image-ExifTool icoutils gnome-terminal +``` + +官方推荐的安装 WineZGUI 的方法是使用 [Flatpak][4]。 + +安装完 Flatpak 后,逐一运行以下命令,在 Linux 中安装 WineZGUI。 + +``` +$ flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo +``` + +``` +$ flatpak --user -y install flathub org.winehq.Wine/x86_64/stable-21.08 +``` + +``` +$ wget https://github.com/fastrizwaan/WineZGUI-Releases/releases/download/WineZGUI-0.4_20220608/io.github.WineZGUI_0_4_20220608.flatpak +``` + +``` +$ flatpak --user -y install io.github.WineZGUI_0_4_20220608.flatpak +``` + +### 在 Linux 中用 WineZGUI 运行 Windows 应用和游戏 + +从 Dash 或菜单中启动 WineZGUI。 + +![Launch WineZGUI][5] + +这就是 WineZGUI 的默认界面的样子。 + +![WineZGUI Interface][6] + +正如你在上面的截图中看到的,WineZGUI 的界面非常简单易懂。从主窗口中,你可以: + +* 打开一个 EXE 文件。 +* 打开 Winetricks GUI 和 CLI。 +* 启动 Wine 配置。 +* 启动资源管理器。 +* 打开 BASH Shell。 +* 关闭所有的应用/游戏,包括 WineZGUI 界面。 +* 删除 Wine 前缀。 +* 查看已安装的 WineZGUI 版本。 + +为了演示,我将打开一个 EXE 文件。 + +在下一个窗口中,选择要运行的 EXE 文件。在我的例子中,它是 WinRAR。 + +![Choose The EXE File To Run][7] + +接下来,你是想用默认的前缀运行 EXE 文件,还是创建一个新的前缀。我选择默认的前缀。 + +![Run WinRAR With Default Prefix][8] + +几秒钟后,会出现 WinRAR 安装向导。点击安装,继续。 + +![Install WinRAR In Linux][9] + +点击 “OK” 来完成 WinRAR 的安装。 + +![Complete WinRAR Installation][10] + +点击 “运行 WinRARRun WinRAR” 来启动它。 + +![Run WinRAR][11] + +下面是 WinRAR 在我的 Fedora 36 桌面上的运行情况! + +![WinRAR Is Running In Fedora Using Wine][12] + +### 总结 + +WineZGUI 是俱乐部的新人。如果你正在寻找一种在 Linux 桌面上使用 Wine 运行 Windows 应用和游戏的更简单方法,WineZGUI 可能是一个不错的选择。 + +在 WineZGUI 的帮助下,用户可以选择在与 EXE 相同的文件夹中创建一个 Wine 前缀,并创建一个相对链接的 `.desktop` 条目来自动执行此操作。 + +原因是使用 Wine 前缀备份和删除游戏更容易,并且让它生成一个 `.desktop` 将使其能够适应移动和转移。 + +一个很酷的场景是使用该应用进行设置,然后将 Wine 前缀分享给你的朋友和其他人,他们只需要一个具有所有依赖性和保存的工作 Wine 前缀。 + +请试一试它,在下面的评论区告诉我们你对这个项目的看法。 + +**资源:** + +* [WineZGUI GitHub 仓库][13] + +-------------------------------------------------------------------------------- + +via: https://ostechnix.com/winezgui-run-windows-apps-and-games-on-linux/ + +作者:[sk][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://ostechnix.com/author/sk/ +[b]: https://github.com/lkxed +[1]: https://ostechnix.com/run-windows-software-on-linux-with-bottles/ +[2]: https://ostechnix.com/run-windows-games-softwares-ubuntu-16-04/ +[3]: https://ostechnix.com/manage-games-using-lutris-linux/ +[4]: https://ostechnix.com/how-to-install-and-use-flatpak-in-linux/ +[5]: https://ostechnix.com/wp-content/uploads/2022/06/Launch-WineZGUI.png +[6]: https://ostechnix.com/wp-content/uploads/2022/06/WineZGUI-Interface.png +[7]: https://ostechnix.com/wp-content/uploads/2022/06/Choose-The-EXE-File-To-Run.png +[8]: https://ostechnix.com/wp-content/uploads/2022/06/Run-WinRAR-With-Default-Prefix.png +[9]: https://ostechnix.com/wp-content/uploads/2022/06/Install-WinRAR-In-Linux.png +[10]: https://ostechnix.com/wp-content/uploads/2022/06/Complete-WinRAR-Installation.png +[11]: https://ostechnix.com/wp-content/uploads/2022/06/Run-WinRAR.png +[12]: https://ostechnix.com/wp-content/uploads/2022/06/WinRAR-Is-Running-In-Fedora-Using-Wine.png +[13]: https://github.com/fastrizwaan/WineZGUI diff --git a/published/202206/20220611 Don-t Be Afraid of Linux Terminal. Embrace it..md b/published/202206/20220611 Don-t Be Afraid of Linux Terminal. Embrace it..md new file mode 100644 index 0000000000..1a8a532e1e --- /dev/null +++ b/published/202206/20220611 Don-t Be Afraid of Linux Terminal. Embrace it..md @@ -0,0 +1,147 @@ +[#]: subject: "Don’t Be Afraid of Linux Terminal. Embrace it." +[#]: via: "https://itsfoss.com/love-thy-terminal/" +[#]: author: "Ankush Das https://itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "duoluoxiaosheng" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14721-1.html" + +Linux 终端,它不可怕,拥抱它 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/17/144213pjobjojcnwbnd4rn.jpg) + +至少,对于熟悉图形界面的新用户来说,我们大多时候都在避免使用 Linux 终端。 + +尽管让事情变得简单和方便是好事,但还是有许多理由说明我们不应该害怕尝试 Linux 终端。 + +在这里,我将重点介绍其中的几个,以鼓励你在终端中尝试一些最终会对你有所帮助的东西。 + +### 1、快速熟悉命令 + +![quick info terminal][1] + +有时,你需要使用某个命令在终端中执行一些操作。当然,你可以在不知道它到底有什么用情况下复制粘贴。 + +但是,如果你想知道这条命令更多的信息,该怎么办呢? + +你只需要输入下面的命令就可以了, + +``` +man +``` + +例如:`man apt`。 + +它会直接在屏幕上给出所有重要的细节,不需要网络连接,不需要在网上搜索它是如何工作的。你节约了时间,增长了知识。 + +而且,这使事情变得简单,使你在使用终端的时候更有信心。 + +这通常被称为 “手册页man page”。 你可以阅读我们的课程《[了解 Linux 上的手册页][2]》。 + +Linux 终端万岁。 + +### 2、解决问题 + +![troubleshoting illustration][3] + +当你在互联网上搜索一个问题的解决方法时,通常,解决方案中会包含几个命令。 + +因此,终端的最佳用例之一,是可以毫不费力地解决几个系统问题。同时,你需要小心,因为如果你不知道你在做什么,你可能最终会破坏你的系统。 + +虽然图形界面可以调整一些东西,但是大部分简单的修复方法都是通过终端完成的。 + +我们在网站上提供了几个 [故障诊断指南][4],例如: + +* [检查网卡制造商][5] +* [修复关机时间过长][6] +* [修复博通网卡没有 WiFi 信号的问题][7] + +### 3、使用远程服务器愉快工作 + +![remote server illustration][8] + +最终,你会通过命令行(或终端)访问一个远程服务器并执行各种操作,包括文件传输。 + +与使用图形界面访问远程服务器相比,使用 Linux 终端可以让你用最小的带宽,快速的执行任何你想要的操作。 + +当然,你也可以通过终端在远程服务器上开启图形界面程序。尽管速度十分缓慢,终端还是可以让你轻松的与远程服务器进行交互。 + +### 4、高效利用资源 + +不管你使用哪一款 [Linux 发行版][9],Linux 终端永远是高效且消耗内存最小的。 + +如果你资源不足或硬件驱动和图形界面程序有冲突,那么 Linux 终端永远值得你的信赖。 + +这将帮你在不占用太多系统资源的情况下完成关键任务。 + +### 5、快速 + +![fast illustration][10] + +你知道吗?不仅局限于内存使用,使用终端你可以比使用图形界面更快的完成任务。 + +你可以尝试安装应用、运行程序、执行复杂的文件操作等等。 + +### 6、稳定可靠的命令行程序 + +相比于图形界面程序,命令行程序更加稳定和可靠,为什么呢? + +在终端中,使程序崩溃的因素很少。 + +由于终端工具大部分是为服务器构建的,很多时候不够直观。也正是由于这个原因,命令行工具通常不会得到不必要的频繁更新,使它们成为比图形界面程序更可靠的选择。 + +### 7、更多的命令行工具 + +没有一个图形界面程序能解决所有问题。但是,对执行各种操作,然而,有几个 [命令行工具][11] 可以执行各种操作,一些有趣和关键的任务也是如此。 + +你需要完成一些工作,来吧,总有一款命令行工具适合你。 + +### 8、尝试各种终端模拟器 + +![variety illustration][12] + +尽管使用 Linux 发行版默认安装的终端模拟器对你来说没有任何困难,你仍然有更多的选择。 + +如果你有特殊的外观和性能需求,或者为某些用途特殊定制,你可以看看这些 [最佳的终端模拟器][13]。 + +如果你觉得使用终端是一件枯燥的事情,你一定要试试这些终端模拟器。 + +### 结束语 + +就我个人来说,当我刚开始接触 Linux 时,我也对终端心存畏惧。但是当我可以熟练的使用它处理一些简单任务的时候,我才开始意识到上面所说的终端的优点。 + +你没必要放弃图形界面而使用终端处理所有的事情。尽管如此,最好还是使用终端处理一些事情,这可以节省你的时间,让你更快的完成工作,并心情愉悦。 + +Abhishek 曾经写过一篇很棒的涉及各种小事的 [指南][14],可以让你熟悉 Linux 终端。 + +*你觉得,相比于图形界面,终端有哪些优点呢?是什么原因让你选择终端呢?快来告诉我们吧。* + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/love-thy-terminal/ + +作者:[Ankush Das][a] +选题:[lkxed][b] +译者:[duoluoxiaosheng](https://github.com/duoluoxiaosheng) +校对:[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/lkxed +[1]: https://itsfoss.com/wp-content/uploads/2022/06/quick-info-terminal.png +[2]: https://itsfoss.com/linux-man-page-guide/ +[3]: https://itsfoss.com/wp-content/uploads/2022/06/troubleshoting-illustration.jpg +[4]: https://itsfoss.com/tag/troubleshoot/ +[5]: https://itsfoss.com/find-network-adapter-ubuntu-linux/ +[6]: https://itsfoss.com/long-shutdown-linux/ +[7]: https://itsfoss.com/fix-no-wireless-network-ubuntu/ +[8]: https://itsfoss.com/wp-content/uploads/2022/06/remote-server-illustration.jpg +[9]: https://itsfoss.com/best-linux-distributions/ +[10]: https://itsfoss.com/wp-content/uploads/2022/06/fast-illustration.jpg +[11]: https://itsfoss.com/tag/cli-tools/ +[12]: https://itsfoss.com/wp-content/uploads/2022/06/variety-illustration.jpg +[13]: https://itsfoss.com/linux-terminal-emulators/ +[14]: https://itsfoss.com/basic-terminal-tips-ubuntu/ diff --git a/published/202206/20220613 Thonny is an Ideal IDE for Teaching Python Programming in Schools.md b/published/202206/20220613 Thonny is an Ideal IDE for Teaching Python Programming in Schools.md new file mode 100644 index 0000000000..2840423b72 --- /dev/null +++ b/published/202206/20220613 Thonny is an Ideal IDE for Teaching Python Programming in Schools.md @@ -0,0 +1,128 @@ +[#]: subject: "Thonny is an Ideal IDE for Teaching Python Programming in Schools" +[#]: via: "https://itsfoss.com/thonny-python-ide/" +[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14717-1.html" + +Thonny:在学校教授 Python 编程的理想 IDE +====== + +在 Linux 中运行一个 Python 程序只需要简单地在终端中执行 Python 文件就行。 + +但这对人们来说不是很方便,也不能帮助你调试你的程序。太原始了。 + +有几个 IDE 和文本编辑器可以用于 Python 开发。Linux 用户可以使用 [PyCharm 社区版][1]。 + +我最近发现了另一个专门为 Python 初学者制作的 IDE。我喜欢这个应用的想法,因此我在这里与你分享。 + +### Thonny 是一个跨平台、开源的 Python IDE,适合初学者使用 + +[Thonny][2] 在用户界面和用户体验方面,感觉就像 Python 版本的 Eclipse。考虑到大多数 C++ 和 Java 的初学者都是从 Eclipse 开始的,而且许多人后来一直使用它,这也不完全是一件坏事。 + +它不是一个新的工具。它已经出现好几年了。我没有用 Python 进行编码,所以直到最近才发现它。 + +Thonny 专注于 Python,提供了帮助 Python 初学者了解其程序行为的功能。让我们来看看这些功能。 + +#### 即装即用 + +Thonny 自带 Python,所以你不需要为安装 Python 做额外的努力。这对 Linux 用户来说不是什么大事,因为大多数发行版都默认安装了 Python。 + +界面很简单。它给你一个编辑器,你可以写你的 Python 程序,然后点击运行按钮或使用 `F5` 键来运行程序。输出显示在底部。 + +![thonny hello world][3] + +#### 查看变量 + +在 “查看View->变量Variables”,你可以看到所有变量的值。不需要将它们全部打印出来。 + +![thonny variable pane][4] + +#### 内置调试器 + +通过使用调试器一步步运行你的程序。你可以从顶部的菜单或使用 `Ctrl + F5` 键访问它。在这里你甚至不需要设置断点。你可以用 `F6` 进入大步骤,或用 `F7` 进入小步骤。 + +![thonny step by step f6][5] + +在小步骤中,你可以看到 Python 是如何看待你的表达式的。这对新的程序员理解他们的程序为什么以某种方式表现非常有帮助。 + +![thonny step by step f7][6] + +不止这样。对于函数调用,它会打开一个新的窗口,里面有独立的局部变量表和代码指针。超级酷! + +#### 语法错误高亮 + +初学者经常会犯一些简单的语法错误,如缺少小括号、引号等。Thonny 会在编辑器中立即指出来。 + +本地变量也可以从视觉上与全局变量区分开来。 + +#### 自动补全 + +你不需要输入所有的东西。Thonny 支持自动补全代码,这有助于加快编码。 + +![thonny auto complete][7] + +#### 访问系统 shell + +在工具中,你可以访问系统 shell。在这里你可以安装新的 Python 包或学习从命令行处理 Python。 + +![thonny shell terminal][8] + +请注意,如果你使用 Flatpak 或 Snap,Thonny 可能无法访问系统 shell。 + +#### 从 GUI 管理 Pip + +进入工具和管理包。它会打开一个窗口,你可以从这个 GUI 中安装 Pip 软件包。 + +![thonny manage packages][9] + +对于学习 Python 来说,功能足够好,对吗?让我们看看如何安装它。 + +### 在 Linux 上安装 Thonny + +Thonny 是一个跨平台的应用。它可用于 Windows、macOS 和 Linux。 + +它是一个流行的应用,你可以在大多数 Linux 发行版的仓库中找到它。只要在你的系统的软件中心寻找它。 + +另外,你也可以随时使用你的 Linux 发行版的包管理器。 + +在 Debian 和基于 Ubuntu 的发行版上,你可以使用 `apt` 命令来安装它。 + +``` +sudo apt install thonny +``` + +它会下载一堆依赖关系和大约 300MB 的软件包。 + +安装后,你可以在菜单中搜索它,并从那里安装它。 + +### 总结 + +Thonny 对于初级 Python 程序员来说是个不错的工具。不是说专家不能使用它,但它更适合在学校和学院使用。学生们会发现它有助于学习 Python 和理解他们的代码是如何以某种方式表现出来的。事实上,它最初是在爱沙尼亚的塔尔图大学开发的。 + +总的来说,对于 Python 学习者来说是一个很好的软件。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/thonny-python-ide/ + +作者:[Abhishek Prakash][a] +选题:[lkxed][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/lkxed +[1]: https://itsfoss.com/install-pycharm-ubuntu/ +[2]: https://thonny.org/ +[3]: https://itsfoss.com/wp-content/uploads/2022/06/thonny-hello-world.png +[4]: https://itsfoss.com/wp-content/uploads/2022/06/thonny-variable-pane.png +[5]: https://itsfoss.com/wp-content/uploads/2022/06/thonny-step-by-step-f6.png +[6]: https://itsfoss.com/wp-content/uploads/2022/06/thonny-step-by-step-f7.png +[7]: https://itsfoss.com/wp-content/uploads/2022/06/thonny-auto-complete.png +[8]: https://itsfoss.com/wp-content/uploads/2022/06/thonny-shell-terminal.png +[9]: https://itsfoss.com/wp-content/uploads/2022/06/thonny-manage-packages.png diff --git a/published/202206/20220614 Adobe Launches Open Source Toolkit To Contain Visual Misinformation.md b/published/202206/20220614 Adobe Launches Open Source Toolkit To Contain Visual Misinformation.md new file mode 100644 index 0000000000..b5142c3643 --- /dev/null +++ b/published/202206/20220614 Adobe Launches Open Source Toolkit To Contain Visual Misinformation.md @@ -0,0 +1,44 @@ +[#]: subject: "Adobe Launches Open Source Toolkit To Contain Visual Misinformation" +[#]: via: "https://www.opensourceforu.com/2022/06/adobe-launches-open-source-toolkit-to-contain-visual-misinformation/" +[#]: author: "Laveesh Kocher https://www.opensourceforu.com/author/laveesh-kocher/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14729-1.html" + +为减少视觉错误信息,Adobe 推出了开源工具包 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/19/105844yauuhdz1u1189ffr.jpg) + +Adobe 设想的是为网络上充斥的照片和视频标注关于它们的来源。该公司的主要目标是减少视觉错误信息的传播,不过,该系统也可以使那些“希望将自己的名字与工作关联起来”的内容创作者受益。 + +Adobe 在 2019 年首次宣布了其 内容真实性计划Content Authenticity Initiative(CAI)项目,此后,它发布了一份关于实现该目标的技术白皮书,将该系统集成了到自己的软件中,并与新闻编辑室和硬件制造商展开了合作,以帮助普及其愿景。 + +现在,该公司发布了一个由三部分组成的开源工具包,从而把该技术交到开发人员手中,并投入使用。Adobe 的新开源工具包括一个用于开发“在浏览器中显示内容凭据”的 JavaScript SDK、一个命令行实用程序,和一个用于开发桌面应用程序、移动应用程序和其他应用的 Rust SDK,以创建、查看和验证嵌入式内容凭据。 + +众所周知,照片的 EXIF 数据中记录了有关光圈和快门速度的信息,这个新标准也采用了这种方式,它还记录有关文件创建的信息,例如文件的创建和编辑方式。如果该公司的共同愿景成真,这些 Adobe 称之为“内容凭证”的元数据,将在社交媒体平台、图像搜索平台、图像编辑器、搜索引擎中广泛可见。 + +C2PA 是 Adob​​e 的 CAI 与 微软、索尼、英特尔、推特以及 BBC 等合作伙伴的合作成果。华尔街日报、尼康和美联社最近也加入了 Adob​​e 的这个计划,即将 内容认证技术content authentication 更加广泛地应用。 + +有了这些新工具,社交媒体平台就可以使用 Adob​​e 的 JavaScript SDK,快速让平台上的所有图像和视频显示内容凭据,这些凭据将会在鼠标悬停时,显示为右上角的一个图标。因此,无需专门的团队和更大的软件构建,该实施可以由几个开发人员在几周内完成。 + +CAI 的主要目标是打击互联网上的视觉错误信息,比如那些扭曲乌克兰战争的旧图片的重新传播,或是臭名昭著的南希·佩洛西的“廉价假货”。不过,数字监管链也可能使“作品被盗或出售”的内容创作者受益,这个问题多年来一直困扰着视觉艺术家,现在也正在 NFT 市场引发问题。 + +根据 Parsons 的说法,CAI 还引起了那些“制作合成图像和视频”的公司的巨大兴趣。公司可以将原始元数据嵌入到我们从 DALL-E 等模型中看到的那种 AI 创作中,从而确保它提供的合成图像不会轻易被误认为是真实的东西。 + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/06/adobe-launches-open-source-toolkit-to-contain-visual-misinformation/ + +作者:[Laveesh Kocher][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/laveesh-kocher/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/06/adobe.jpeg diff --git a/published/202206/20220614 KDE Plasma 5.25 Release is All About Color, Theme, and Other Improvements.md b/published/202206/20220614 KDE Plasma 5.25 Release is All About Color, Theme, and Other Improvements.md new file mode 100644 index 0000000000..4115800575 --- /dev/null +++ b/published/202206/20220614 KDE Plasma 5.25 Release is All About Color, Theme, and Other Improvements.md @@ -0,0 +1,143 @@ +[#]: subject: "KDE Plasma 5.25 Release is All About Color, Theme, and Other Improvements" +[#]: via: "https://news.itsfoss.com/kde-plasma-5-25-release/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14720-1.html" + +KDE Plasma 5.25 发布:颜色、主题和其他改进 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/17/120251jxjpjmmhzcmoq2mx.jpg) + +> KDE Plasma 5.25 终于来了,它带来了许多视觉更新和有用的改进! + +![Plasma 5.25][1] + +KDE Plasma 5.25 一直是最受期待的版本之一,因为它最近的版本都专注于改进视觉效果和工作流程。 + +例如,[KDE Plasma 5.24][2] LTS 版本带来了升级的 Breeze 主题和全新的概览效果,改进了工作流程。 + +如今,KDE Plasma 5.25 带来了更多升级! + +### KDE Plasma 5.25 更新内容 + +虽然,在 Plasma 5.25 的最终发布之前,我们已经知道了一些它的 [关键特性][3]。但是,既然它正式发布了,那就是时候和你简单介绍一下 KDE Plasma 5.25 的全部新功能啦! + +**剧透一下**:大多数更新都涉及视觉改善和可用性改进。 + +#### 新壁纸 + +![][4] + +如果你玩过 “[无人深空][5]No Man's Sky” 或类似的电子游戏,你可能会有似曾相识的感觉。 + +撇开这一点不谈,默认壁纸对旧壁纸进行了更新,具有完全不同的主题颜色。 + +#### 触摸板和触摸屏手势 + +Plasma 5.25 包括了一系列手势,以充分利用新功能。例如:四指捏合、从屏幕边缘滑动以触发概览效果或 桌面网格Desktop Grid 等。 + +你可以使用该版本支持的 1:1 手势,轻松管理虚拟桌面,并在工作区之间切换。 + +你可以前往 工作区行为Workspace Behavior 设置来调整你需要的操作。 + +#### 支持选择性应用全局主题 + +![KDE Plasma 5.25][6] + +当你在系统设置中应用 全局主题Global Theme 时,系统将提示你,是否要应用主题的所有部分,或是只应用它的某些部分。 + +你可以应用它的特定外观选项,也可以用它来替换整个配置。 + +总的来说,当将全局主题应用于使用 KDE 的系统时,这个更新提供了细粒度的自定义控制。 + +#### 根据当前壁纸自动生成强调色 + +以前,我们总觉得能够选择自定义或预设强调色,就已经足够了。 + +现在,有了 KDE Plasma 5.25,你可以根据当前壁纸自动生成强调色。它应该也能够与墙纸幻灯片一起使用。 + +![][7] + +所以,如果你既让桌面匹配你的背景,又不想要自己花力气定制,那么这个选项应该会对你有用。 + +![][7a] + +这是新功能库的一个小而强大的补充。 + +#### 带有强调色的配色方案 + +为了更好地自定义外观/观感,KDE Plasma 5.25 可以让你在选择的强调色上定制配色方案。 + +![KDE Plasma 5.25][8] + +如果你喜欢配色主题的用户体验,你可以启用/禁用它。 + +#### 触控模式改进 + +![][9] + +当你在桌面环境中使用触控模式时(通过支持的设备或手动),KDE Plasma 5.25 将增大 KDE 应用程序的任务管理器、系统托盘和标题栏的大小,使它们更易于访问。 + +#### “发现” 软件中心的改进 + +“发现Discover” 软件中心有一些细微的变化。以前,你需要单独浏览“应用程序”、“附加组件”和 “Plasma 附加组件”等类别;而现在,你在侧边栏中就可以找到所有应用程序类别。 + +![KDE Plasma 5.24][10] + +![KDE Plasma 5.25][11] + +此外,对于 Flatpak 应用程序,你可以看到它所需的权限。还有,应用程序页面也有了一些升级,以显示有关你查看的应用程序的更多信息。 + +#### 其他改进 + +其他重要的改进包括定制功能的升级和工作流程的修改。其中包括: + +* 一个新的混合效果,用于使动画颜色之间的变化具有动画效果,每当你改变主题/颜色或自动改变时,可以平滑过渡。 +* 强大的容纳管理功能,它允许你在监视器之间移动桌面以及文件夹/小部件,即使你已断开它们的连接。 +* Kwin 脚本设置页面已被重写。 +* 键盘导航支持自定义快捷键和系统托盘图标。 +* 新增一个浮动面板,用于在面板周围添加边距。 +* 改进了 KRunner 的性能。 +* 网络小部件添加了 Wi-Fi 网络的频率和 BSSID 的详细信息。 + +如果你想了解更多,可以查看 [公告][12]。 + +### 尝试 KDE Plasma 5.25 + +你可以下载 KDE Neon,以便在最新的 KDE Plasma 5.25 有更新时马上就可以用上。如果你等不及了,测试版也是个不错的选择(如果你愿意实验的话)。 + +> **[KDE Neon][13]** + +对于其他 Linux 发行版,你得等待开发人员推送更新(LTS 版除外)。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/kde-plasma-5-25-release/ + +作者:[Ankush Das][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/plasma-5-25-feat.jpg +[2]: https://news.itsfoss.com/kde-plasma-5-24-lts-release/ +[3]: https://news.itsfoss.com/plasma-5-25-features/ +[4]: https://news.itsfoss.com/wp-content/uploads/2022/06/plasma-5-25-wallpaper-1024x576.jpg +[5]: https://www.nomanssky.com/ +[6]: https://news.itsfoss.com/wp-content/uploads/2022/06/apply_global_theme_advanced.png +[7]: https://news.itsfoss.com/wp-content/uploads/2022/06/blue_accent.jpg +[7a]: https://player.vimeo.com/video/720193948 +[8]: https://news.itsfoss.com/wp-content/uploads/2022/04/tint-color-scheme-1024x751.png +[9]: https://news.itsfoss.com/wp-content/uploads/2022/06/tablet_context_menu.png +[10]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2022/04/kde-discover-plasma-5-25.png?ssl=1 +[11]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2022/04/kde-plasma-5-25-discover.png?ssl=1 +[12]: https://kde.org/announcements/plasma/5/5.25.0/ +[13]: https://neon.kde.org/download diff --git a/published/202206/20220614 Share your Linux terminal with tmate.md b/published/202206/20220614 Share your Linux terminal with tmate.md new file mode 100644 index 0000000000..b296bc9a53 --- /dev/null +++ b/published/202206/20220614 Share your Linux terminal with tmate.md @@ -0,0 +1,104 @@ +[#]: subject: "Share your Linux terminal with tmate" +[#]: via: "https://opensource.com/article/22/6/share-linux-terminal-tmate" +[#]: author: "Sumantro Mukherjee https://opensource.com/users/sumantro" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "turbokernel" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14726-1.html" + +用 tmate 分享你的 Linux 终端 +====== + +> tmate 扩展了你分享 Linux 终端会话的方式。 + +![](https://img.linux.net.cn/data/attachment/album/202206/18/170815hfrcdfd4lltd737z.jpg) + +作为 Fedora Linux QA 团队的一员,我有时想将自己执行的一堆命令广而告之给其他开发者。如果你曾经使用过像 [tmux][5] 或 [GNU Screen][6] 这样的 [终端复用器][4],你可能会认为这是一个挺轻松的任务。不是所有看我的示范的人都是从笔记本电脑或台式机连接到我的终端会话的,有些人可能是随手在他们的手机浏览器中打开的,因为我使用了 [tmate][7],所以他们可以很容易地做到这一点。 + +### 使用 tmate 分享 Linux 终端 + +观看别人在 Linux 终端的工作是非常有教育意义的。你可以学到新的命令、新的工作流程,或者新的调试和自动化的方法。但要抓住你所看到的东西,以便你以后可以自己尝试,这可能很困难。你可能会借助截图或一个共享终端会话的屏幕记录,这样你就可以在以后打出每个命令。剩下的唯一选择是由演示命令的人使用 [Asciinema][8] 或 [script 和 scriptreplay][9] 等工具来记录会话。 + +但是通过 `tmate`,用户可以在只读模式下或通过 SSH 分享终端。SSH 和只读会话都可以通过终端或以 HTML 网页的形式访问。 + +当我为 Fedora QA 团队培训人员时,我使用只读模式,因为我需要运行命令并显示输出,但有了 `tmate`,人们可以通过从他们的浏览器复制和粘贴到文本编辑器来记录笔记。 + +### Linux tmate 上手 + +在 Linux 上,你可以用你的包管理器安装 `tmate`。例如,在 Fedora 上: + +``` +$ sudo dnf install tmate +``` + +在 Debian 和类似的发行版上: + +``` +$ sudo apt install tmate +``` + +在 macOS 上,你可以用 [Homebrew][10] 或 [MacPorts][11] 安装它。如果你需要其他 Linux 发行版的说明,请参考 [安装][12] 指南。 + +![Screenshot of terminal showing the options for tmate sharing: web session (regular and read-only) and ssh session (regular and read-only)][13] + +安装后,启动 `tmate`: + +``` +$ tmate +``` + +当 `tmate` 启动时,会生成链接,通过 HTTP 和 SSH 提供对终端会话的访问。每个协议都有一个只读方式,以及一个反向的 SSH 会话。 + +下面是一个网络会话的样子: + +![Screenshot showing tmate terminal window and 2 versions of sharing sessions demonstrating the same code][14] + +`tmate` 的网络控制台是 HTML5 的,因此,用户可以复制整个屏幕并粘贴到终端来运行相同的命令。 + +### 保持会话 + +你可能想知道如果你不小心关闭了你的终端会发生什么。你也可能想知道如何与不同的控制台应用共享你的终端。毕竟,`tmate` 是一个多路复用器,所以它应该能够保持会话,脱离并重新连接到一个会话,等等。 + +当然,这正是 `tmate` 所能做到的。如果你曾经使用过 `tmux`,这可能是相当熟悉的。 + +``` +$ tmate -F -n web new-session vi console +``` + +这个命令在 `vi` 中打开了 `new-session`,`-F` 选项确保会话在关闭时也能重新产生。 + +![A screenshot of the terminal showing the output after using the new-session and -F options: connection information for either a web session (regular or read-only) or ssh session (regular or read-only)][15] + +### 社交复用 + +`tmate` 给你带来了 `tmux` 或 GNU Screen 的自由度,以及与他人分享会话的能力。这是一个有价值的工具,可以教其他用户如何使用终端、演示一个新命令的功能,或调试意外的行为。它是开源的,所以请试一试! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/6/share-linux-terminal-tmate + +作者:[Sumantro Mukherjee][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[turbokernel](https://github.com/turbokernel) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sumantro +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/terminal_command_linux_desktop_code.jpg +[2]: https://pixabay.com/en/users/iradaturrahmat-3964359/ +[3]: https://pixabay.com/en/ubuntu-computer-program-interface-3145957/ +[4]: https://opensource.com/article/21/5/linux-terminal-multiplexer +[5]: https://opensource.com/downloads/tmux-cheat-sheet +[6]: https://opensource.com/article/17/3/introduction-gnu-screen +[7]: https://tmate.io/ +[8]: https://opensource.com/article/22/1/record-your-terminal-session-asciinema +[9]: https://www.redhat.com/sysadmin/record-terminal-script-scriptreplay +[10]: https://opensource.com/article/20/6/homebrew-mac +[11]: https://opensource.com/article/20/11/macports +[12]: https://tmate.io/ +[13]: https://opensource.com/sites/default/files/2022-06/install%20tmate_0.png +[14]: https://opensource.com/sites/default/files/2022-06/tmate%20web%20session.png +[15]: https://opensource.com/sites/default/files/2022-06/tmate%20keeping%20session%20alive.png diff --git a/published/202206/20220614 Thunderbird, The Open Source Email Client, Is Coming To Android.md b/published/202206/20220614 Thunderbird, The Open Source Email Client, Is Coming To Android.md new file mode 100644 index 0000000000..8d3dfe46e5 --- /dev/null +++ b/published/202206/20220614 Thunderbird, The Open Source Email Client, Is Coming To Android.md @@ -0,0 +1,38 @@ +[#]: subject: "Thunderbird, The Open Source Email Client, Is Coming To Android" +[#]: via: "https://www.opensourceforu.com/2022/06/thunderbird-the-open-source-email-client-is-coming-to-android/" +[#]: author: "Laveesh Kocher https://www.opensourceforu.com/author/laveesh-kocher/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14715-1.html" + +开源电子邮件客户端 Thunderbird 即将登陆 Android +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/16/084004gdzgp4bqgigi9tpe.jpg) + +开源电子邮件客户端 Thunderbird 将通过 K-9 Mail Android 电子邮件应用项目登陆 Android,该项目与 Thunderbird 合并后的产品就是 Thunderbird Android 电子邮件应用。两年前,Thunderbird 被转移到了 Mozilla 基金会的子公司 MZLA Technologies Corporation 下,该公司的所有权结构与基金会子公司 Mozilla 公司旗下的 Firefox 类似。有了 OpenPGP 端到端加密和期待已久的移动应用等新功能,Thunderbird 项目能够开辟出一条自己的道路。 + +根据 Thunderbird 团队的说法,Thunderbird 产品经理 Ryan Lee Sipes 和 K-9 的主要维护者 Christian Ketterer,两人早在 2018 年就开始讨论可能的 Thunderbird 电子邮件应用合作了。到了 2022 年,两人决定不再让 Thunderbird 从头开始​​开发自己的应用程序,而是直接让 K-9 加入 Thunderbird。 + +Thunderbird 团队表示:“许多 Thunderbird 用户都要求在移动设备上获得 Thunderbird 体验,我们打算通过把 K-9 打造成令人惊叹的产品(并将其变成 Android 上的 Thunderbird)来提供这种体验。K-9 将补充提供 Thunderbird 体验,并增强它的使用场景和方式,让用户获得出色的电子邮件体验。我们对桌面 Thunderbird 的承诺没有改变,我们团队中的大多数人都致力于将其打造为一流的电子邮件客户端,并将保持这种状态。” + +虽然 K-9 在 Google Play 上并不是特别受欢迎的电子邮件应用,但它已经获得了 500 万次下载。K-9 Mail 的路线图目前包括:使用 Thunderbird 帐户自动配置的帐户设置、改进的文件夹管理、消息过滤器支持,以及桌面和移动 Thunderbird 之间的同步。虽然 Thunderbird 知道人们对 iOS 版 Thunderbird 应用程序也很感兴趣,但在常见问题解答(FAQ)中,该项目仅声明它正在“评估”这种可能性。 + +Thunderbird 团队还打算将 Firefox Sync 作为一种在 Thunderbird 和 K-9 Mail 之间同步帐户的方法。它应该会在 2023 年夏天正式投入使用。该项目还在研究将哪些 Thunderbird 功能引入 Android 应用程序,例如日历、任务、提要和聊天支持等。 + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/06/thunderbird-the-open-source-email-client-is-coming-to-android/ + +作者:[Laveesh Kocher][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/laveesh-kocher/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/06/android-developer.jpg diff --git a/published/202206/20220615 According to studies, Twitter Drives Open Source Projects Popularity.md b/published/202206/20220615 According to studies, Twitter Drives Open Source Projects Popularity.md new file mode 100644 index 0000000000..f3a693778c --- /dev/null +++ b/published/202206/20220615 According to studies, Twitter Drives Open Source Projects Popularity.md @@ -0,0 +1,42 @@ +[#]: subject: "According to studies, Twitter Drives Open Source Projects Popularity" +[#]: via: "https://www.opensourceforu.com/2022/06/according-to-studies-twitter-drives-open-source-projects-popularity/" +[#]: author: "Laveesh Kocher https://www.opensourceforu.com/author/laveesh-kocher/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14734-1.html" + +有研究表明,推特能够推动开源项目的普及 +====== + +![推特][1] + +由 HongBo Fang 博士领导的研究团队发现,推特是一种吸引更多人关注和贡献 GitHub 开源项目的有效方式。Fang 博士在国际软件工程会议上发表了这项名为“‘这真是太棒了!’估计推文对开源项目受欢迎程度和新贡献者的影响”的研究,并获得了杰出论文奖。这项研究显示,发送和一个项目有关的推文,导致了该项目受欢迎程度增加了 7%(在 GitHub 上至少增加了一个星标),贡献者数量增加了 2%。一个项目收到的推文越多,它收到的星标和贡献者就越多。 + +Fang 说:“我们已经意识到社交媒体在开源社区中变得越来越重要,吸引关注和新的贡献者将带来更高质量和更好的软件。” + +大多数开源软件都是由志愿者创建和维护的。参与项目的人越多,结果就越好。开发者和其他人使用该软件、报告问题并努力解决这些问题。然而,不受欢迎的项目有可能得不到应有的关注。这些劳动力(几乎都是志愿者),维护了数百万人每天依赖的软件。例如,几乎每个 HTTPS 网站都使用开源的 OpenSSL 保护其内容。Heartbleed 是 OpenSSL 中发现的一个安全漏洞,在 2014 年被发现后,企业花费了数百万美元来修复它。另一个开源软件 cURL 允许连接的设备相互发送数据,并安装在大约 10 亿台设备上。开源软件之多,不胜枚举。 + +此次“推特对提高开源项目的受欢迎程度和吸引新贡献者的影响”的研究,其实是 “Vasilescu 数据挖掘与社会技术研究实验室”(STRUDEL)的一个更大项目的其中一部分,该研究着眼于如何建立开源社区并且其工作更具可持续性。毕竟,支撑现代技术的数字基础设施、道路和桥梁都是开源软件。如果维护不当,这些基础设施可能会崩溃。 + +研究人员检查了 44544 条推文,其中包含指向 2370 个开源 GitHub 存储库的链接,以证明这些推文确实吸引了新的星标和项目贡献者。在这项研究中,研究人员使用了一种科学的方法:将推特上提及的 GitHub 项目的星标和贡献者的增加,与推特上未提及的一组项目进行了比较。该研究还描述了高影响力推文的特征、可能被帖子吸引到项目的人的类型,以及这些人与通过其他方式吸引的贡献者有何不同。来自项目支持者而不是开发者的推文最能吸引注意力。请求针对特定任务或项目提供帮助的帖子会收到更高的回复率。推文往往会吸引新的贡献者,**他们是 GitHub 的新手,但不是经验不足的程序员**。还有,**新的关注可能不会带来新的帮助**。 + +提高项目受欢迎程度也存在其缺点,研究人员讨论后认为,它的潜在缺点之一,就是注意力和行动之间的差距。**更多的关注通常会导致更多的功能请求或问题报告,但不一定有更多的开发者来解决它们**。社交媒体受欢迎程度的提高,可能会导致有更多的“巨魔”或“有毒行为”出现在项目周围。 + +(LCTT 译注:我觉得文章中有三句话写得很好,于是把它们加粗了,和大家分享。 —— 六开箱) + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/06/according-to-studies-twitter-drives-open-source-projects-popularity/ + +作者:[Laveesh Kocher][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/laveesh-kocher/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/06/twiiter.jpg diff --git a/published/202206/20220615 How I use LibreOffice keyboard shortcuts.md b/published/202206/20220615 How I use LibreOffice keyboard shortcuts.md new file mode 100644 index 0000000000..eb9db93ab1 --- /dev/null +++ b/published/202206/20220615 How I use LibreOffice keyboard shortcuts.md @@ -0,0 +1,59 @@ +[#]: subject: "How I use LibreOffice keyboard shortcuts" +[#]: via: "https://opensource.com/article/22/6/libreoffice-keyboard-shortcuts" +[#]: author: "Jim Hall https://opensource.com/users/jim-hall" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14765-1.html" + +使用 LibreOffice 键盘快捷键的小技巧 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/27/144807lc4csplt17xm6mee.jpg) + +> 键盘快捷键让我专注于我要传递的内容,而不是它的外观。 + +从我记事起,我就一直在使用文字处理软件。当文字处理器从直接格式化转向利用样式来改变文本在页面上的显示方式时,这对我的写作有很大的推动作用。 + +LibreOffice 提供了多种样式,你可以使用它们来创建各种内容。 LibreOffice 将段落样式应用于文本块,例如正文、列表和代码示例。字符样式类似,只是这些样式适用于段落内的内联词或其他短文本。使用“视图View -> 样式Styles”菜单,或使用 `F11` 键盘快捷键,调出样式选择器。 + +![Image of LibreOffice styles][2] + +使用样式可以更轻松地编写更长的文档。看看这个例子:作为咨询实践的一部分,我写了很多工作簿和培训材料。一个工作簿可能有 40 或 60 页长,具体取决于主题,并且可以包含各种内容,例如正文、表格和列表。我的一些技术培训材料可能还包括源代码示例。 + +我有一个提供给客户的标准培训集,但我也做定制的培训计划。在处理自定义程序时,我可能会先从另一个工作簿导入文本,然后从那里开始工作。根据客户的不同,我可能还会调整字体和其他样式元素以匹配客户的样式偏好。对于其他材料,我可能需要添加源代码示例。 + +要使用直接格式输入示例源代码,我需要设置字体并调整工作簿中每个代码块的边距。如果我后来决定我的工作簿应该对正文文本或源代码示例使用不同的字体,我需要返回并更改所有内容。对于包含多个代码示例的工作簿,这可能需要几个小时来查找每个源代码示例并调整字体和边距以匹配新的首选格式。 + +但是,通过使用样式,我可以更新定义一次,为正文样式使用不同的字体,并且 LibreOffice Writer 会在所有使用正文样式的地方更新我的文档。同样,我可以调整预格式化文本样式的字体和边距,LibreOffice Writer 会将这种新样式应用到每个具有预格式化文本样式的源代码示例中。这对于其他文本块也是如此,包括标题、源代码、列表以及页眉和页脚。 + +我最近有了一个好主意,更新 LibreOffice 键盘快捷键以简化我的写作过程。我重新定义了 `Ctrl + B` 设置加粗强调字符样式,`Ctrl + I` 设置强调字符样式,`Ctrl + 空格` 设置取消字符样式。这使我的写作变得更加容易,因为我不必暂停写作,这样我就可以高亮显示一些文本并选择一种新的风格。相反,我可以使用新的 `Ctrl + I` 键盘快捷键来设置字符样式,它本质上是斜体文本。之后我输入的任何内容都使用强调样式,直到我按 `Ctrl + 空格` 将字符样式重置为默认的无字符样式。 + +![Image of LibreOffice character styles][3] + +如果你想自己设置的,请使用“工具Tools -> 自定义Customize”, 然后单击“键盘Keyboard”选项卡以修改键盘快捷键。 + +![Image of LibreOffice keyboard customizations][4] + +LibreOffice 通过样式使技术写作变得更加容易。通过利用键盘快捷键,我简化了我的写作方式,让我专注于我要交付的内容,而不是它的外观。稍后我可能会更改格式,但样式保持不变。 + +*图片来源:(Jim Hall,CC BY-SA 40)* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/6/libreoffice-keyboard-shortcuts + +作者:[Jim Hall][a] +选题:[lkxed][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/jim-hall +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/programming_keyboard_coding.png +[2]: https://opensource.com/sites/default/files/2022-06/libreofficestyles.png +[3]: https://opensource.com/sites/default/files/2022-06/libreofficecharstyles.png +[4]: https://opensource.com/sites/default/files/2022-06/libreofficekeyboardcustom.png diff --git a/published/202206/20220615 Mozilla Just Made Firefox the Most Secure Web Browser for All Users.md b/published/202206/20220615 Mozilla Just Made Firefox the Most Secure Web Browser for All Users.md new file mode 100644 index 0000000000..9273ad64d6 --- /dev/null +++ b/published/202206/20220615 Mozilla Just Made Firefox the Most Secure Web Browser for All Users.md @@ -0,0 +1,77 @@ +[#]: subject: "Mozilla Just Made Firefox the Most Secure Web Browser for All Users" +[#]: via: "https://news.itsfoss.com/mozilla-firefox-secure/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14723-1.html" + +Mozilla 刚刚使 Firefox 成为所有人的最安全的网页浏览器 +====== + +> Mozilla 终于启用了一项隐私保护功能,这可能使其成为当下最安全的网页浏览器。你怎么看? + +![Mozilla Firefox][1] + +Mozilla Firefox 是市面上最安全的开源网页浏览器之一。 + +毫无疑问,你可以自由定制它来进一步增强安全性,这就是 Tor 浏览器使用 Firefox 作为其核心的原因。 + +并且,这也是 [我继续使用 Firefox 的原因][2] 之一。 + +现在,Mozilla 终于为**所有桌面用户**启用了一项新功能,这使其成为最安全的浏览器(或是他们声称的“最安全”)。 + +本文中,我讨论的不是任何新功能,而是 Firefox 中的现有功能,即 Cookie 全面保护Total Cookie Protection。它是在去年与 [Firefox 86][3] 一起引入的,但默认情况下并未对所有用户启用。 + +### 为所有用户提供的全面的 Cookie 保护 + +“Cookie 全面保护”正在向所有人推出,无论你使用的是 Windows、Mac 还是 Linux,它将成为默认启用的核心功能之一。 + +最初,要使用该功能,你必须启用严格模式(增强跟踪保护Enhanced Tracking Protection)。但现在,你不再需要这样做了。 + +#### 它是什么? + +如果你好奇的话,“Cookie 全面保护”会隔离每个网站和它们的 Cookie。Cookie 是网站向你的浏览器发送的少量数据。 + +因此,Cookie 不会在网站之间共享,从而防止了跨站跟踪cross-site tracking。 + +浏览器将为你访问的每个网站都创建单独的“饼干罐Cookie Jar”。(LCTT 译注:Cookie 原意是小饼干。) + +![][4] + +Mozilla 的博文对此进行了更多解释: + +> 在任何时候,网站或嵌入网站的 [第三方内容][5] 在浏览器中存储的 Cookie,都将仅限于分配给该网站的 “饼干罐”。其他网站无法进入不属于它们的“饼干罐”,以得到你存储在那些 Cookie 中的信息。这可以让你免受侵入性广告的影响,并减少公司收集的关于你的信息量。 + +### 那么,这有什么大不了的吗? + +即使你配备了所有的隐私跟踪保护和内容拦截器,你也不一定知道,其实还有个问题叫做“跨站跟踪”。 + +因此,通过跨站点的 Cookie 交互,你的许多个人活动和习惯,都可以帮助数字跟踪公司建立你的在线个人资料。 + +但是,对于 Mozilla Firefox 来说,它在所有其他隐私措施之上,默认额外启用了该功能,这可确保你获得最私密的体验。 + +并且,所有这些都不需要你调整任何东西,这应该为那些“重视隐私”的用户提供方便。 + +想了解进一步信息,你可以查看 Mozilla 的 [官方公告][6]。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/mozilla-firefox-secure/ + +作者:[Ankush Das][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/mozilla-made-firefox-most-secure-web-browser.jpg +[2]: https://news.itsfoss.com/why-mozilla-firefox/ +[3]: https://news.itsfoss.com/firefox-86-release/ +[4]: https://news.itsfoss.com/wp-content/uploads/2021/02/tcp-firefox.png +[5]: https://support.mozilla.org/en-US/kb/third-party-cookies-firefox-tracking-protection#:~:text=Third%2Dparty%20cookies%20are%20cookies,considered%20a%20third%2Dparty%20cookie. +[6]: https://blog.mozilla.org/en/products/firefox/firefox-rolls-out-total-cookie-protection-by-default-to-all-users-worldwide/ diff --git a/published/202206/20220616 Analyze web pages with Python requests and Beautiful Soup.md b/published/202206/20220616 Analyze web pages with Python requests and Beautiful Soup.md new file mode 100644 index 0000000000..1716386150 --- /dev/null +++ b/published/202206/20220616 Analyze web pages with Python requests and Beautiful Soup.md @@ -0,0 +1,145 @@ +[#]: subject: "Analyze web pages with Python requests and Beautiful Soup" +[#]: via: "https://opensource.com/article/22/6/analyze-web-pages-python-requests-beautiful-soup" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14769-1.html" + +使用 Python 的 requests 和 Beautiful Soup 来分析网页 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/28/132859owwf9az49k2oje2o.jpg) + +> 学习这个 Python 教程,轻松提取网页的有关信息。 + +浏览网页可能占了你一天中的大部分时间。然而,你总是需要手动浏览,这很讨厌,不是吗?你必须打开浏览器,然后访问一个网站,单击按钮,移动鼠标……相当费时费力。如果能够通过代码与互联网交互,岂不是更好吗? + +在 Python 的 `requests` 模块的帮助下,你可以使用 Python 从互联网中获取数据: + +``` +import requests + +DATA = "https://opensource.com/article/22/5/document-source-code-doxygen-linux" +PAGE = requests.get(DATA) + +print(PAGE.text) +``` + +在以上代码示例中,你首先导入了 `requests` 模块。接着,你创建了两个变量:其中一个叫做 `DATA`,它用来保存你要下载的 URL。在之后的代码中,你将能够在每次运行应用程序时提供不同的 URL。不过,就目前而言,最简单的方法是“硬编码”一个测试 URL,以达到演示目的。 + +另一个变量是 `PAGE`。代码读取了存储在 `DATA` 中的 URL,然后把它作为参数传入 `requests.get` 函数,最后用变量 `PAGE` 来接收函数的返回值。`requests` 模块及其 `.get` 函数的功能是:“读取”一个互联网地址(一个 URL)、访问互联网,并下载位于该地址的任何内容。 + +当然,其中涉及到很多步骤。幸运的是,你不必自己弄清楚,这也正是 Python 模块存在的原因。最后,你告诉 Python 打印 `requests.get` 存储在 `PAGE` 变量的 `.text` 字段中的所有内容。 + +### Beautiful Soup + +如果你运行上面的示例代码,你会得到示例 URL 的所有内容,并且,它们会不加选择地输出到你的终端里。这是因为在代码中,你对 `requests` 收集到的数据所做的唯一事情,就是打印它。然而,解析文本才是更加有趣的。 + +Python 可以通过其最基本的功能来“读取”文本,但解析文本允许你搜索模式、特定单词、HTML 标签等。你可以自己解析 `requests` 返回的文本,不过,使用专门的模块会容易得多。针对 HTML 和 XML 文本,我们有 [Beautiful Soup][2] 库。 + +下面这段代码完成了同样的事情,只不过,它使用了 Beautiful Soup 来解析下载的文本。因为 Beautiful Soup 可以识别 HTML 元素,所以你可以使用它的一些内置功能,让输出对人眼更友好。 + +例如,在程序的末尾,你可以使用 Beautiful Soup 的 `.prettify` 函数来处理文本(使其更美观),而不是直接打印原始文本: + +``` +from bs4 import BeautifulSoup +import requests + +PAGE = requests.get("https://opensource.com/article/22/5/document-source-code-doxygen-linux") +SOUP = BeautifulSoup(PAGE.text, 'html.parser') + +# Press the green button in the gutter to run the script. +if __name__ == '__main__': +    # do a thing here +    print(SOUP.prettify()) +``` + +通过以上代码,我们确保了每个打开的 HTML 标签都输出在单独的一行,并带有适当的缩进,以帮助说明标签的继承关系。实际上,Beautiful Soup 能够通过更多方式来理解 HTML 标签,而不仅仅是将它打印出来。 + +你可以选择打印某个特定标签,而不是打印整个页面。例如,尝试将打印的选择器从 `print(SOUP.prettify())` 更改为: + +``` +print(SOUP.p) +``` + +这只会打印一个 `

` 标签。具体来说,它只打印遇到的第一个 `

` 标签。要打印所有的 `

` 标签,你需要使用一个循环。 + +### 循环 + +使用 Beautiful Soup 的 `find_all` 函数,你可以创建一个 `for` 循环,从而遍历 `SOUP` 变量中包含的整个网页。除了 `

` 标签之外,你可能也会对其他标签感兴趣,因此最好将其构建为自定义函数,由 Python 中的 `def` 关键字(意思是 “定义”define)指定。 + +``` +def loopit(): +    for TAG in SOUP.find_all('p'): +        print(TAG) +``` + +你可以随意更改临时变量 `TAG` 的名字,例如 `ITEM` 或 `i` 或任何你喜欢的。每次循环运行时,`TAG` 中都会包含 `find_all` 函数的搜索结果。在此代码中,它搜索的是 `

` 标签。 + +函数不会自动执行,除非你显式地调用它。你可以在代码的末尾调用这个函数: + +``` +# Press the green button in the gutter to run the script. +if __name__ == '__main__': +    # do a thing here +    loopit() +``` + +运行代码以查看所有的 `

` 标签和它们的内容。 + +### 只获取内容 + +你可以通过指定只需要 “字符串string”(它是 “单词words” 的编程术语)来排除打印标签。 + +``` +def loopit(): +    for TAG in SOUP.find_all('p'): +        print(TAG.string) +``` + +当然,一旦你有了网页的文本,你就可以用标准的 Python 字符串库进一步解析它。例如,你可以使用 `len` 和 `split` 函数获得单词个数: + +``` +def loopit(): +    for TAG in SOUP.find_all('p'): +        if TAG.string is not None: +            print(len(TAG.string.split())) +``` + +这将打印每个段落元素中的字符串个数,省略那些没有任何字符串的段落。要获得字符串总数,你需要用到变量和一些基本数学知识: + +``` +def loopit(): +    NUM = 0 +    for TAG in SOUP.find_all('p'): +        if TAG.string is not None: +            NUM = NUM + len(TAG.string.split()) +    print("Grand total is ", NUM) +``` + +### Python 作业 + +你可以使用 Beautiful Soup 和 Python 提取更多信息。以下是有关如何改进你的应用程序的一些想法: + +* [接受输入][3],这样你就可以在启动应用程序时,指定要下载和分析的 URL。 +* 统计页面上图片(`` 标签)的数量。 +* 统计另一个标签中的图片(`` 标签)的数量(例如,仅出现在 `

` div 中的图片,或仅出现在 `

` 标签之后的图片)。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/6/analyze-web-pages-python-requests-beautiful-soup + +作者:[Seth Kenlon][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[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/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/python_programming_question.png +[2]: https://beautiful-soup-4.readthedocs.io/en/latest/ +[3]: https://opensource.com/article/17/3/python-tricks-artists-interactivity-Python-scripts diff --git a/published/202206/20220616 Mattermost Extends workflow platform with 7.0 release.md b/published/202206/20220616 Mattermost Extends workflow platform with 7.0 release.md new file mode 100644 index 0000000000..042d200389 --- /dev/null +++ b/published/202206/20220616 Mattermost Extends workflow platform with 7.0 release.md @@ -0,0 +1,40 @@ +[#]: subject: "Mattermost Extends workflow platform with 7.0 release" +[#]: via: "https://www.opensourceforu.com/2022/06/mattermost-extends-workflow-platform-with-7-0-release/" +[#]: author: "Laveesh Kocher https://www.opensourceforu.com/author/laveesh-kocher/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14738-1.html" + +Mattermost 7.0 发布,扩展了工作流平台 +====== + +![Mattermost][1] + +自 2016 年开源以来,Mattermost 一直在开发一个具有不断增加的用例的消息传递平台。6 月 16 日,Mattermost 7.0 平台发布,其中包括了新的语音呼叫、工作流模板和用于开源技术的应用框架。新版本扩展了 2021 年 10 月发布的 6.0 版本引入的功能。一直以来,Mattermost 都在与包括 Slack、Atlassian 和 Asana 在内的几家大公司,竞争不断增长的协作工具市场。另一方面,Mattermost 侧重于对开发者的支持,尽管该平台也可用于安全和 IT 运营。 + +Mattermost 的软件同时提供有商业版和开源版,目前它们都升级到了 7.0 版。Tien 解释说,Mattermost 的商业平台是建立在开源基础上的。在开放核心模型中,开源版作为软件的基础或核心,专有的企业功能则内置于商业版中。合规性、规模性和高级配置是 Mattermost 的关键企业功能。Tien 声称,开源版本对于中小型团队来说已经足够了。他认为,拥有 500 名或更多用户的团队才需要考虑使用商业版。 + +Tien 认为开源也关乎社区贡献。Mattermost 开源项目有超过 4000 名个人贡献者,他们贡献了超过 30000 行代码。 + +以前,Mattermost 依赖集成第三方呼叫服务(例如 Zoom)来启用语音呼叫功能。在 7.0 版本中,它通过开源 WebRTC 协议引入了呼叫功能的直接集成,所有现代 Web 浏览器都支持该协议。直接集成呼叫功能的目标是为协作提供单一平台,这符合 Tien 对该平台的总体愿景。现在,除了提供集成工具以实现协作之外,该平台还会增加“工作流模板”功能,以帮助(用户)组织构建可重复的流程。 + +工作流概念采用了 剧本playbook,其中包含了为“特定类型的操作”所执行的动作和操作的清单。例如,在发生服务故障或网络安全事件时,公司可以为事件响应创建工作流模板。 + +这个清单可以链接到 Mattermost 操作operation,例如让特定用户发起呼叫,并协助生成报告。Tien 表示,Mattermost 还与常见的开发者工具集成,并且工作流模板的功能将随着时间的推移而扩展,以便使用第三方工具来实现更多自动化。 + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/06/mattermost-extends-workflow-platform-with-7-0-release/ + +作者:[Laveesh Kocher][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/laveesh-kocher/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/06/marttermost-e1655377462300.jpeg diff --git a/published/202206/20220616 The Travis CI Vulnerability Exposes Sensitive Open Source Project Credentials.md b/published/202206/20220616 The Travis CI Vulnerability Exposes Sensitive Open Source Project Credentials.md new file mode 100644 index 0000000000..396d198271 --- /dev/null +++ b/published/202206/20220616 The Travis CI Vulnerability Exposes Sensitive Open Source Project Credentials.md @@ -0,0 +1,38 @@ +[#]: subject: "The Travis CI Vulnerability Exposes Sensitive Open Source Project Credentials" +[#]: via: "https://www.opensourceforu.com/2022/06/the-travis-ci-vulnerability-exposes-sensitive-open-source-project-credentials/" +[#]: author: "Laveesh Kocher https://www.opensourceforu.com/author/laveesh-kocher/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14724-1.html" + +Travis CI 漏洞暴露了敏感的开源项目凭证 +====== + +![Travis CI](https://img.linux.net.cn/data/attachment/album/202206/18/095734heuo8nc7g7n0ibtd.jpg) + +Travis CI 持续集成工具中的一个缺陷暴露了来自数千个在线开源项目的敏感数据。这并不是该软件第一次遇到此类安全问题。 + +Travis CI 是一个持续集成工具,它帮助软件开发者实现自动化地测试新代码,并将新代码集成到开源项目中。Aqua 研究人员发现,通过该软件的一个 API,可以访问来自 Travis CI 免费用户的多达 7.7 亿条“日志”(即使用户的账号已经删除)。 + +攻击者可以从这些明文存储的日志中,提取出用于登录 GitHub、Docker Hub 和 AWS 等云服务的用户身份验证令牌。研究人员在 800 万份日志样本中,发现了 70000 多个敏感令牌和其他机密凭证。Aqua 团队认为“所有 Travis CI 免费用户都有可能暴露”。根据 2019 年的数据,Travis CI 被超过 60 万名独立用户,用于超过 932977 个开源项目。 + +这种对高级用户凭证的访问,会给使用该产品的软件开发者及其客户带来风险。趋势科技英国和爱尔兰安全技术总监 Bharat Mistry 解释道:“如果攻击者获得了这些凭据,就没有什么能阻止他们将恶意代码引入库或构建过程。这个缺陷无疑会导致数字供应链攻击。” + +供应链攻击可能极具破坏性。2020 年的 太阳风Solar Winds 攻击,使国家资助的俄罗斯黑客能够访问数千家企业和政府组织的系统。2021 年的 Kaseya 供应链攻击,使犯罪分子可以同时加密 1500 多家公司的数据,将它们全部扣为人质。 + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/06/the-travis-ci-vulnerability-exposes-sensitive-open-source-project-credentials/ + +作者:[Laveesh Kocher][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/laveesh-kocher/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/06/travis-c.png diff --git a/published/202206/20220616 Ubuntu Core 22 is Here for IoT and Edge Devices.md b/published/202206/20220616 Ubuntu Core 22 is Here for IoT and Edge Devices.md new file mode 100644 index 0000000000..8d55013527 --- /dev/null +++ b/published/202206/20220616 Ubuntu Core 22 is Here for IoT and Edge Devices.md @@ -0,0 +1,77 @@ +[#]: subject: "Ubuntu Core 22 is Here for IoT and Edge Devices" +[#]: via: "https://news.itsfoss.com/ubuntu-core-22-release/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14730-1.html" + +Ubuntu Core 22 来了,适用于物联网和边缘设备 +====== + +> Ubuntu Core 22 基于 Ubuntu 22.04 LTS,为物联网和嵌入式设备带来了最佳的安全性和性能。 + +![Ubuntu][1] + +Ubuntu Core 22 是一个容器化的 Ubuntu 22.04 LTS 变体,针对嵌入式和物联网设备进行了优化。 + +对于希望在边缘设备上运行 Canonical 的最新操作系统的开发者来说,这会是一个很棒的产品。 + +在发布 Ubuntu Core 22 时,Canonical 的 CEO **Mark Shuttleworth** 说: + +> “Canonical 的目标是在从开发环境到云、再到边缘和设备的任何地方提供安全、可靠的开源技术。” + +### Ubuntu Core 22 更新介绍 + +![什么是 Ubuntu Core 22?][2] + +Ubuntu Core 22 版本带来了针对安全性和可靠性的改进。其中包括了以下几个改进。 + +#### 实时计算 + +正如公告中提到的,Ubuntu 22.04 LTS 提供了一个实时内核(测试版可用),它能为那些时间敏感的工业、汽车和机器人用例,提供高性能、超低延迟和工作负载可预测性。 + +此外,如果你有 Ubuntu 认证的硬件,你还能充分利用先进的实时功能。 + +#### Snapcraft 框架 + +整个 Ubuntu 镜像分解为许多个包(Snap),使得内核、操作系统和应用程序隔离在一个沙箱中。 + +这可以让你轻松地安装应用程序,而无需担心来自专用 物联网应用商店IoT App Store 的依赖。对于企业而言,通过软件商店进行的软件管理解决方案,应该能够带来一系列内部部署的机会。 + +该框架还可帮助系统确保 OTA 更新按预期工作,即使由于某种原因失败,也不会破坏任何内容。 + +#### 安全 + +Ubuntu Core 提供了高级安全功能,包括安全启动、全盘加密以及一些更适合任务关键型环境的功能。 + +注意,此版本还提供了 10 年的安全更新承诺。 + +#### 其他关键改进 + +* 支持从 Ubuntu Core 20 轻松迁移并确保向后兼容性。 +* 性能改进。 +* 新的“恢复出厂设置”启动模式,以便在“运行/恢复模式”中恢复出厂设置。 + +如果你想了解更多信息,可以查看 [官方公告][3]。 + +如果你对 Ubuntu Core 感兴趣,可以访问它的 [主​​页][4] 以了解更多关于它的信息。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/ubuntu-core-22-release/ + +作者:[Ankush Das][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/ubuntu-22-core.jpg +[2]: https://youtu.be/6NDWqH1SrGs +[3]: https://ubuntu.com/blog/canonical-ubuntu-core-22-is-now-available-optimised-for-iot-and-embedded-devices +[4]: https://ubuntu.com/core diff --git a/published/202206/20220617 Ubuntu Runs on a Google Nest Hub, Wait, What-.md b/published/202206/20220617 Ubuntu Runs on a Google Nest Hub, Wait, What-.md new file mode 100644 index 0000000000..922e3169ab --- /dev/null +++ b/published/202206/20220617 Ubuntu Runs on a Google Nest Hub, Wait, What-.md @@ -0,0 +1,89 @@ +[#]: subject: "Ubuntu Runs on a Google Nest Hub, Wait, What?" +[#]: via: "https://news.itsfoss.com/ubuntu-google-nest/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14746-1.html" + +Ubuntu 可以运行在谷歌 Nest Hub 上了?! +====== + +> 一名安全专家成功地在谷歌 Nest Hub(第 2 代)上运行了 Ubuntu,嗯,然后呢? + +![Ubuntu Google][1] + +我刚刚看到了一个关于在谷歌 Nest Hub(第 2 代)上运行的 Ubuntu 的消息。 + +嗯,这实在是让人兴奋! + +所以,让我在这里分享更多关于它的信息吧。 + +### 破解谷歌 Nest Hub 以安装 Ubuntu + +是的,破解使得这成为可能。 + +网络安全专家 Frédéric Basse 破解了谷歌 Nest Hub(第 2 代)的安全启动,并成功运行 Ubuntu。 + +当然,谷歌 Nest Hub 并没有正式支持启动一个自定义操作系统。但是,Fred 使用了一个安全漏洞,从而成功运行了 Ubuntu。 + +虽然这很有趣,但对于始终在线的谷歌智能家居显示器来说,这也是一个严重的安全问题。 + +![](https://news.itsfoss.com/wp-content/uploads/2022/06/ubuntu-google-nest-hacked.gif) + +正如这位安全专家在 [博客文章][2] 中所解释的,他使用了树莓派 Pico 微控制器,利用引导加载程序中的 USB 漏洞,从而破坏了安全启动链。 + +这位安全专家得出结论: + +> 因此,攻击者可以通过插入恶意 USB 设备并按下两个按钮,从而在早期启动阶段(内核执行之前)执行任意代码。 + +如果你想进行实验(适合安全研究人员),他还在 [GitHub][3] 上提供了相关代码(关于如何利用这个引导加载程序漏洞)。 + +### 让 Ubuntu 在 Google Nest 上运行 + +![][4] + +该漏洞允许攻击者启动未签名的操作系统。但是,在那之前,攻击者必须对为树莓派(64 位 ARM 版)量身定制的预装 Ubuntu 镜像进行一些修改。 + +这位安全专家还提到了以下内容: + +> 我们构建了一个自定义 U-Boot 引导加载程序,禁用了安全引导,并更改了引导流程以从 USB 闪存驱动器加载环境。我们还为 elaine 构建了一个自定义 Linux 内核,其中包括包括了一些 [额外驱动,例如 USB 鼠标][5] 。重新打包了来自 Ubuntu 的初始 ramdisk(initrd),以集成触摸屏所需的固件二进制文件。引导镜像是基于自定义 Linux 内核和修改的 initrd 创建的。 + +因此,很明显,你不会获得完整的 Ubuntu 体验,但由于该漏洞,我们现在知道,如果你愿意破解 谷歌 Nest 进行测试的话(真心不建议!),Ubuntu 是可以在谷歌 Nest 上作运行的。 + +### 智能家居安全担忧 + Linux + +网络安全专家指出,该漏洞已在上游(两次)修复。 + +但是,研究人员也指出,缺乏分配的 CVE 编号可能会导致修复程序无法向下游传播。 + +毫无疑问,看到有人在不受支持的设备上运行 Linux 真是太棒了。这让我思考,我们是否应该也制造一些 **由 Linux 驱动的商业智能家居设备?** + +*或者说,已经有类似的东西了吗?* + +然而,智能家居设备容易受到简单攻击,也同样令人担忧。 + +你怎么看?在下面的评论中分享你的想法吧。 + +**本文最初发布于** [Liliputing][6] + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/ubuntu-google-nest/ + +作者:[Ankush Das][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/hacker-installs-ubuntu-on-google-nest-hub.jpg +[2]: https://fredericb.info/2022/06/breaking-secure-boot-on-google-nest-hub-2nd-gen-to-run-ubuntu.html +[3]: https://github.com/frederic/chipicopwn +[4]: https://news.itsfoss.com/wp-content/uploads/2022/06/ubuntu-google-nest.jpg +[5]: https://github.com/frederic/elaine-linux/commit/11068237d9178e77d79e3a5d27fc4f8f9b923c51 +[6]: https://liliputing.com/2022/06/hacker-installs-ubuntu-on-a-google-nest-hub-2nd-gen-smart-display.html diff --git a/published/202206/20220620 Compress Images in Linux Easily With Curtail GUI App.md b/published/202206/20220620 Compress Images in Linux Easily With Curtail GUI App.md new file mode 100644 index 0000000000..46b8ad5ca9 --- /dev/null +++ b/published/202206/20220620 Compress Images in Linux Easily With Curtail GUI App.md @@ -0,0 +1,108 @@ +[#]: subject: "Compress Images in Linux Easily With Curtail GUI App" +[#]: via: "https://itsfoss.com/curtail-image-compress/" +[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14748-1.html" + +用 Curtail GUI 应用轻松压缩 Linux 中的图像 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/23/182901s4d060uu98g8qquv.jpg) + +有一大堆文件尺寸巨大的图片占用了太多的磁盘空间?或者你必须将图片上传到有文件大小限制的门户网站? + +你可能有很多原因想要压缩图片。有大量的工具可以帮助你,我在这里说的不是命令行的工具。 + +你可以使用一个成熟的图像编辑器,如 GIMP。你也可以使用像 [Squoosh][1] 这样的网络工具,这是谷歌的一个开源项目。它甚至可以让你比较每个压缩级别的文件。 + +然而,所有这些工具都是针对单个图像工作的。如果你想批量压缩照片怎么办?Curtail 是一个能帮助你的应用。 + +### Curtail: Linux 中用于图像压缩的灵巧工具 + +使用 Python 和 GTK3 构建的 Curtail 是一个简单的 GUI 应用,使用 OptiPNG、[jpegoptim][2] 等开源库来提供图像压缩功能。 + +它有一个 [Flatpak 应用][3]。请确保你的系统已启用 [Flatpak 支持][4]。 + +首先添加 Flathub 仓库: + +``` +flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo +``` + +然后使用下面的命令来安装 Curtail: + +``` +flatpak install flathub com.github.huluti.Curtail +``` + +安装后,在你的 Linux 系统的菜单中寻找它,并从那里启动它。 + +![curtail app][5] + +界面朴素而简单。你可以选择你想要无损压缩还是有损压缩。 + +有损压缩会有质量差的图像,但尺寸较小。无损压缩会有更好的质量,但尺寸可能不会比原来的小很多。 + +![curtail app interface][6] + +你可以浏览图片,或者把它们拖到应用中。 + +是的,你可以用 Curtail 一键压缩多张图片。 + +事实上,你甚至不需要点击。只要你选择图片或拖放它们,它们就会被压缩,你会看到压缩过程的摘要。 + +![curtail image compression summary][7] + +正如你在上面的图片中看到的,我的一张图片的尺寸减少了 35%,另外两张图片的尺寸减少了 3% 和 8%。这是在无损压缩的情况下。 + +这些图片以 `-min` 为后缀(默认),保存在与原始图片相同的目录中。 + +虽然它看起来很简约,但有几个选项可以配置 Curtail。点击菜单,你会看到一些设置选项。 + +![curtail configuration options][8] + +你可以选择是将压缩文件保存为新文件还是替换现有文件。如果你选择新文件(默认行为),你也可以为压缩后的图像提供一个不同的后缀。保留文件属性的选项也在这里。 + +在下一个选项卡中,你可以配置有损压缩的设置。默认情况下,压缩级别为 90%。 + +![curtail compression options][9] + +高级选项卡让你可以选择配置 PNG 和 WebP 文件的无损压缩级别。 + +![curtain advanced options][10] + +### 总结 + +正如我前面所说,这不是一个突破性的工具。你可以用其他工具如 GIMP 做同样的事情。它只是使图像压缩的任务更简单,特别是对于批量图像压缩。 + +我很想看到在压缩时有[转换图像文件格式][11]的选项,就像我们在 Converseen 等工具中所拥有的那样。 + +总的来说,对于图像压缩的具体目的来说,这是一个不错的小工具。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/curtail-image-compress/ + +作者:[Abhishek Prakash][a] +选题:[lkxed][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/lkxed +[1]: https://squoosh.app/ +[2]: https://github.com/tjko/jpegoptim +[3]: https://itsfoss.com/what-is-flatpak/ +[4]: https://itsfoss.com/flatpak-guide/ +[5]: https://itsfoss.com/wp-content/uploads/2022/06/curtail-app.png +[6]: https://itsfoss.com/wp-content/uploads/2022/06/curtail-app-interface.png +[7]: https://itsfoss.com/wp-content/uploads/2022/06/curtail-image-compression-summary.png +[8]: https://itsfoss.com/wp-content/uploads/2022/06/curtail-configuration-options.png +[9]: https://itsfoss.com/wp-content/uploads/2022/06/curtail-compression-options.png +[10]: https://itsfoss.com/wp-content/uploads/2022/06/curtain-advanced-options.png +[11]: https://itsfoss.com/converseen/ diff --git a/published/202206/20220620 Manjaro 21.3.0 -Ruah- Release Adds Latest Calmares 3.2, GNOME 42, and More Upgrades.md b/published/202206/20220620 Manjaro 21.3.0 -Ruah- Release Adds Latest Calmares 3.2, GNOME 42, and More Upgrades.md new file mode 100644 index 0000000000..d5f49184e2 --- /dev/null +++ b/published/202206/20220620 Manjaro 21.3.0 -Ruah- Release Adds Latest Calmares 3.2, GNOME 42, and More Upgrades.md @@ -0,0 +1,92 @@ +[#]: subject: "Manjaro 21.3.0 ‘Ruah’ Release Adds Latest Calmares 3.2, GNOME 42, and More Upgrades" +[#]: via: "https://news.itsfoss.com/manjaro-21-3-0-release/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14754-1.html" + +Manjaro 21.3.0 Ruah 发布:增加了最新的 Calmares 3.2、GNOME 42 和更多升级 +====== + +> Manjaro Linux 21.3.0 发行包包含一些最新和最强大的更新,包括改进的安装程序。 + +![](https://img.linux.net.cn/data/attachment/album/202206/25/093727pqm59kkragcaga4c.jpg) + +Manjaro Linux 是一个滚动发布的发行版。因此,从技术上讲,如果你定期更新系统的话,你一直都会使用最新版本。 + +升级到 Manjaro 21.3.0 应该没什么大不了的,考虑到我已经在正式发布前几天就已经在稳定运行它了,毫无问题。 + +**另外**,你可能想阅读一下我 [从 Ubuntu 切换到 Manjaro][2] 的初步体验(如果你对于升级仍然犹豫不决的话)。 + +那么,Manjaro 21.3.0 带来了什么更新呢? + +### Manjaro 21.3.0 更新内容 + +![][3] + +桌面环境升级到了最新的稳定版本,而内核版本仍然是 [Linux 内核 5.15 LTS][4]。 + +此外,这个版本还包括最终的 Clamares v3.2 版本。让我们来看看它有哪些变化吧。 + +#### Calamares v3.2.59 + +Calamares v3.2.59 安装程序是 3.2 系列的最终版本,它有许多有意义的改进。这次,分区模块包含了对 LUKS 分区的支持和更多改进,以避免那些可能会弄乱 Manjaro 安装的设置。 + +Calamares 3.2 的所有未来版本都将仅是错误修复。 + +#### GNOME 42 + Libadwaita + +最初的版本包含了 GNOME 42,而最新的版本包含了 GNOME 42.2(附带最新的更新)。 + +总体而言,你将获得 [GNOME 42][5] 引入的所有优点,包括系统范围的深色模式、基于 GTK 4 的 GNOME 应用的现代用户界面、升级的应用程序以及其他一些重大变化。 + +![][6] + +#### KDE Plasma 5.24 + +不幸的是,考虑到它差不多是在同一周发布的,因此该版本无法包含 [KDE Plasma 5.25][7]。 + +[KDE Plasma 5.24][8] 是一个不错的升级,具有更新的主题和概览效果。 + +#### XFCE 4.16 + +在 Xfce 4.16 中,窗口管理器得到了许多更新和改进,以支持小数倍数的缩放和更多功能。 + +### 下载 Manjaro 21.3.0 + +到目前为止,我在 Manjaro 21.3.0 GNOME 版本中没有遇到任何问题。一切看起来都不错,升级也很顺利。 + +但是,如果你不想重新安装或丢失重要文件,则应始终进行备份。 + +你可以从 [Manjaro 的下载页面][9] 下载最新版本。你也应该可以通过 pamac 包管理器获得更新。 + +无论哪种情况,你都可以在终端中输入以下命令进行升级: + +``` +sudo pacmane -Syu +``` + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/manjaro-21-3-0-release/ + +作者:[Ankush Das][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/manjaro-21-3-0-ruah-release.jpg +[2]: https://news.itsfoss.com/manjaro-linux-experience/ +[3]: https://news.itsfoss.com/wp-content/uploads/2022/06/manjaro-gnome-42-2-1024x576.jpg +[4]: https://news.itsfoss.com/linux-kernel-5-15-release/ +[5]: https://news.itsfoss.com/gnome-42-release/ +[6]: https://news.itsfoss.com/wp-content/uploads/2022/06/manjaro-21-3-neofetch.png +[7]: https://news.itsfoss.com/kde-plasma-5-25-release/ +[8]: https://news.itsfoss.com/kde-plasma-5-24-lts-release/ +[9]: https://manjaro.org/download/ diff --git a/published/202206/20220620 Microsoft To Charge For Available Open Source Software In Microsoft Store.md b/published/202206/20220620 Microsoft To Charge For Available Open Source Software In Microsoft Store.md new file mode 100644 index 0000000000..81622add51 --- /dev/null +++ b/published/202206/20220620 Microsoft To Charge For Available Open Source Software In Microsoft Store.md @@ -0,0 +1,40 @@ +[#]: subject: "Microsoft To Charge For Available Open Source Software In Microsoft Store" +[#]: via: "https://www.opensourceforu.com/2022/06/microsoft-to-charge-for-available-open-source-software-in-microsoft-store/" +[#]: author: "Laveesh Kocher https://www.opensourceforu.com/author/laveesh-kocher/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14755-1.html" + +微软将对应用商店中开源软件的收费进行限制 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/25/101648dlxnqxkaox00xc3l.jpg) + +2022 年 6 月 16 日,微软更新了其应用商店的策略。其中一项禁止了发布者对开源或免费的软件收取费用,另一项则针对的是商店使用的不合理高价。如果你在过去几年中访问过微软应用商店,你可能已经注意到,它正在成为越来越多的开源和免费产品的所在地。如果原始开发者将应用程序和游戏上传到商店,这将是有益的,但情况并非如此,因为它们是由第三方上传的。 + +更糟糕的是,其中许多程序仅作为付费应用提供,而不是免费下载。换句话说,微软的客户必须付费才能购买应用商店的版本,而它们在其他地方是免费的!在应用商店中,免费版和付费版有时并存。为免费应用付费已经够糟糕的了,但这并不是用户在购买时可能遇到的唯一问题。更新也可能是一个问题,因为山寨应用可能不会像源头应用程序那样频繁或快速地更新。 + +在更新的微软商店政策中,微软在 10.8.7 节下指出: + +> 在您决定产品或应用内购买的定价时,您的数字产品或服务的所有定价(包括销售或折扣)必须: +> +> 遵守所有适用的法律、法规和监管要求,包括联邦贸易委员会的《反欺骗性定价指南》。您不得试图从开源软件或其他可免费获得的软件中获利,您的产品也不应提供一个(与它提供的特性和功能相比)过高的不合理定价。 + +这个新策略在更新部分中得到了确认。如果开源和免费产品普遍免费提供,则它们不得在微软应用商店上出售,发布者也不得对其产品收取不合理的高价。开源和免费应用的开发者可以在微软应用商店上为其产品收费。例如,Paint.net 的开发者就是这样做的。如果微软强制执行这些策略,许多应用将从应用商店中删除。以前,开发者可以向微软报告应用程序,但在新策略下,微软可以直接控制应用的列出和提交。 + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/06/microsoft-to-charge-for-available-open-source-software-in-microsoft-store/ + +作者:[Laveesh Kocher][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/laveesh-kocher/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/06/microsoft-e1655714723942.jpg diff --git a/published/202206/20220621 Mysterious GeckoLinux Creator Reveals a New Debian Remix Distro.md b/published/202206/20220621 Mysterious GeckoLinux Creator Reveals a New Debian Remix Distro.md new file mode 100644 index 0000000000..ac911d1337 --- /dev/null +++ b/published/202206/20220621 Mysterious GeckoLinux Creator Reveals a New Debian Remix Distro.md @@ -0,0 +1,76 @@ +[#]: subject: "Mysterious GeckoLinux Creator Reveals a New Debian Remix Distro" +[#]: via: "https://news.itsfoss.com/debian-remix-spiral-linux/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14758-1.html" + +神秘的 GeckoLinux 创建者推出了一个新的 Debian 合成发行版 +====== + +> GeckoLinux 创建者推出了一个基于 Debian 的新 Linux 发行版,专注于简单性和可用性。 + +![Linux 螺旋][1] + +GeckoLinux 改进了的 openSUSE 体验,它的创建者一直保持匿名。 + +我不会评论这是好事还是坏事,但现在,开发者又带着另一个基于 Debian 的类似项目回来了。 + +**SpiralLinux**,这是一个基于 Debian 的发行版,旨在使 Debian 适合最终用户使用。 + +### SpiralLinux:基于 Debian 构建的发行版 + +![SpiralLinux][2] + +毫不奇怪,大多数用户友好的 Linux 发行版都将 Debian 作为其原始基础。Ubuntu 就是在此基础上进行了大量改进,从而提供了良好的桌面体验,即使对于没有 Linux 经验的用户也是如此。 + +那么,这个发行版有什么不同呢? + +嗯,它的创建者说,这个项目旨在帮助你获得 Debian 的所有核心优势,而无需定制很多东西。 + +如果你想在桌面上使用 Debian,SpiralLinux 是一种接近原版的体验。你还可以根据需要升级到最新的稳定 Debian 版本(或不稳定/测试版),而不会丢失方便易用的自定义设置。 + +换句话说,SpiralLinux 使 Debian 适合桌面使用,而最终用户只需付出最小的努力。 + +为了实现这一点,SpiralLinux 使用了 Debian 官方软件包存储库,并提供了现场安装方式,让你能够定制自己的 Debian 系统。 + +此外,SpiralLinux 还具有以下功能: + +* 开箱即用的 VirtualBox 支持 +* 预装了专有的媒体编解码器和非自由软件包存储库 +* 预装了专有固件 +* 打印机支持 +* 通过 GUI(软件中心)支持 Flatpak +* 默认启用 zRAM 交换 +* 多种桌面环境(Cinnamon、XFCE、Gnome、Plasma、MATE、Budgie、LXQt) + +Debian 始终坚持使用开源和自由软件包,最终用户必须自己搞定编解码器、驱动程序和其他软件包,才能使许多功能正常工作,获得令他们满意的桌面体验。 + +而 SpiralLinux 似乎可以作为 Debian 的一个有用的替代品,就像 GeckoLinux 之于 openSUSE 一样。 + +### 下载 SpiralLinux + +如果你一直想尝试 Debian,但又不想在初始配置上费尽心思,你可以尝试 SpiralLinux。 + +你可以前往其托管在 GitHub 上的官网以了解更多信息,链接如下: + +> **[SpiralLinux][3]** + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/debian-remix-spiral-linux/ + +作者:[Ankush Das][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/spiral-linux-debian-remix-distro.jpg +[2]: https://news.itsfoss.com/wp-content/uploads/2022/06/spirallinux.jpg +[3]: https://spirallinux.github.io/ diff --git a/published/202206/20220621 The Final Version Of 7-Zip 22.00 Is Now Available.md b/published/202206/20220621 The Final Version Of 7-Zip 22.00 Is Now Available.md new file mode 100644 index 0000000000..15e9c3d03e --- /dev/null +++ b/published/202206/20220621 The Final Version Of 7-Zip 22.00 Is Now Available.md @@ -0,0 +1,45 @@ +[#]: subject: "The Final Version Of 7-Zip 22.00 Is Now Available" +[#]: via: "https://www.opensourceforu.com/2022/06/the-final-version-of-7-zip-22-00-is-now-available/" +[#]: author: "Laveesh Kocher https://www.opensourceforu.com/author/laveesh-kocher/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14764-1.html" + +7-Zip 22.00 最终版现已推出 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/27/110310hwrmxuwyqlor1olp.jpg) + +7-Zip 是用于 Windows、Mac 和 Linux 的知名开源文件归档器。它的最新版本 22.00 现已推出。它是 2022 年的第一个稳定版本。上一个版本是 21.07,于 2021 年 12 月发布。7-Zip 的用户可以从官方网站获取该应用的最新版本,下载适用于 Windows 64 位、32 位和 ARM 版本。该应用仍然与过时的 Windows 版本兼容,例如 XP 和 Vista。它还支持所有官方支持的 Windows 版本,包括服务器版本。适用于 Linux 的 7-Zip 22.00 已经可以下载,但 Mac OS 版本还不可用。 + +7-Zip 22.00 包含一些增强了应用功能的新特性。这个归档器现在支持提取苹果文件系统Apple File System(APFS)镜像。几年前,苹果公司在 Mac OS 10.13 和 iOS 中引入了苹果文件系统。该文件系统在设计时就考虑到了闪存(Flash)和固态硬盘(SSD)存储。 + +7-Zip 22.00 包括了对其 TAR 存档支持的多项增强。使用选项 `-ttar -mm=pax` 或 `-ttar -mm=posix`,7-Zip 现在可以创建符合 POSIX 标准的 tar 格式的 TAR 档案。此外,使用选项 `ttar -mm=pax -mtp=3 -mtc -mta`,7-Zip 可以在 tar/pax 存档中存储高精度的文件时间戳。 + +最后,Linux 用户可以在 TAR 归档文件中使用以下两个新选项: + +* `snoi`:将所有者/组 ID 保存在存档中,或将所有者/组 ID 从存档复制到提取的文件中。 +* `snon`:在存档中保留所有者/组的名称。 + +适用于 Windows 的 7-Zip 22.00 添加了对 `-snz` 选项的支持,该选项用于传播区识别符(LCTT 译注:区标识符是微软在 2013 年为 IE 设计的安全功能,它会标记那些用户自网络上所下载的文件,并在用户准备打开时跳出警告)。 + +要提取文件,请使用标识符流。出于安全目的,Windows 使用了该流,它可用于确定文件是在本地创建的还是从互联网下载的。 + +在“添加到存档add to archive”配置对话框中,7-Zip 22.00 包含一个新的选项窗口。它包括用于更改时间戳精度、更改其他与时间相关的配置选项,以及防止更改源文件的最后访问时间等选项。 + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/06/the-final-version-of-7-zip-22-00-is-now-available/ + +作者:[Laveesh Kocher][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/laveesh-kocher/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/06/7-zip-2200-500x312-1.jpg diff --git a/published/202206/20220621 This Open-Source Project Proves Chrome Extensions Can Track You.md b/published/202206/20220621 This Open-Source Project Proves Chrome Extensions Can Track You.md new file mode 100644 index 0000000000..ae5ea206e5 --- /dev/null +++ b/published/202206/20220621 This Open-Source Project Proves Chrome Extensions Can Track You.md @@ -0,0 +1,70 @@ +[#]: subject: "This Open-Source Project Proves Chrome Extensions Can Track You" +[#]: via: "https://news.itsfoss.com/chrome-extension-tracking/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14768-1.html" + +你安装的 Chrome 扩展的组合可以跟踪你 +====== + +> 这会成为放弃基于 Chromium 的浏览器并开始使用 Firefox 的一个理由吗?也许吧,决定权在你。 + +![Chrome 扩展追踪器][1] + +即使你有了所有的隐私扩展和各种保护功能,别人仍然有方法可以识别你或跟踪你。 + +请注意,并非所有浏览器都是如此,本文中,我们主要关注基于 Chromium 的浏览器,并将谷歌 Chrome 作为“主要嫌疑人”。 + +以前,在 Chromium 浏览器上,尽管别人已经能够检测到你已安装的扩展程序,但许多扩展程序都实施了某些保护措施来防止这种检测。 + +然而,一位名为 “**z0ccc**” 的安全研究人员发现了一种检测已安装 Chrome 浏览器扩展程序的新方法,该方法可进一步用于**通过“浏览器指纹识别”来跟踪你**。 + +如果你还不知道的话:浏览器指纹识别Browser Fingerprinting是指收集有关你的设备/浏览器的各种信息,以创建唯一的指纹 ID(哈希),从而在互联网上识别你的一种跟踪方法。“各种信息”包括:浏览器名称、版本、操作系统、已安装的扩展程序、屏幕分辨率和类似的技术数据。 + +这听起来像是一种无害的数据收集技术,但可以使用这种跟踪方法在线跟踪你。 + +### 检测谷歌 Chrome 扩展 + +研究人员发布了一个开源项目 “**Extension Fingerprints**”,你可以使用它来测试你安装的 Chrome 扩展是否能被检测到。 + +新技术涉及一种“时间差”方法,该工具比较了扩展程序获取资源的时间。与浏览器上未安装的其他扩展相比,受保护的扩展需要更多时间来获取资源。因此,这有助于从 1000 多个扩展列表中识别出一些扩展。 + +关键是:即使有了各种新的进步和技术来防止跟踪,Chrome 网上应用店的扩展也可以被检测到。 + +![][2] + +并且,在检测到已安装的扩展程序后,别人可以就使用浏览器指纹识别,对你进行在线跟踪。 + +令人惊讶的是,即使你安装有 uBlocker、AdBlocker、或 Privacy Badger(一些流行的以隐私为重点的扩展程序)之类的扩展程序,使用了这种方法,它们也都可以被检测到。 + +你可以在它的 [GitHub 页面][3] 上查看所有技术细节。如果你想自己测试它,请前往它的 [扩展指纹识别网站][4] 自行检查。 + +### 拯救 Firefox? + +嗯,似乎是的,毕竟我出于各种原因,[不断回到 Firefox][5]。 + +这个新发现的(跟踪)方法应该适用于所有基于 Chromium 的浏览器。我在 Brave 和谷歌 Chrome 上都测试了这个方法。研究人员还提到,该工具不能在使用微软应用商店中的扩展的微软 Edge 上工作。但是,相同的跟踪方法仍然有效。 + +正如研究人员指出,Mozilla Firefox 可以避免这种情况,因为每个浏览器实例的扩展 ID 都是唯一的。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/chrome-extension-tracking/ + +作者:[Ankush Das][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/opensource-project-tracker-chrome-extensions.jpg +[2]: https://news.itsfoss.com/wp-content/uploads/2022/06/extension-fingerprints.jpg +[3]: https://github.com/z0ccc/extension-fingerprints +[4]: https://z0ccc.github.io/extension-fingerprints/ +[5]: https://news.itsfoss.com/why-mozilla-firefox/ diff --git a/published/202206/20220622 Manage your Rust toolchain using rustup.md b/published/202206/20220622 Manage your Rust toolchain using rustup.md new file mode 100644 index 0000000000..b60c13fec5 --- /dev/null +++ b/published/202206/20220622 Manage your Rust toolchain using rustup.md @@ -0,0 +1,142 @@ +[#]: subject: "Manage your Rust toolchain using rustup" +[#]: via: "https://opensource.com/article/22/6/rust-toolchain-rustup" +[#]: author: "Gaurav Kamathe https://opensource.com/users/gkamathe" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "turbokernel" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14779-1.html" + +使用 rustup 管理你的 Rust 工具链 +====== + +![](https://img.linux.net.cn/data/attachment/album/202206/30/145426h9he5z111149ctcj.jpg) + +> rustup 可用于 Rust 安装与更新。它还能够在稳定版、测试版和每日更新版之间无缝切换 Rust 编译器及其工具。 + +[Rust 编程语言][2] 如今变得越来越流行,受到爱好者和公司的一致好评。它受欢迎的原因之一是 Rust 提供的令人惊叹的工具,使其成为开发人员使用的乐趣。[rustup][3] 是管理 Rust 工具的官方工具。它不仅可以安装和更新 Rust ,它还能够在稳定版、测试版和每日更新版之间无缝切换 Rust 编译器及其工具。本文将向你介绍 `rustup` 及其一些常用命令。 + +### 默认 Rust 安装方式 + +如果你想在 Linux 上安装 Rust,你可以使用你的包管理器。在 Fedora 或 CentOS Stream 上,你可以这样: + +``` +$ sudo dnf install rust cargo +``` + +这提供了一个稳定版的 Rust 工具链,如果你是 Rust 的初学者,并想尝试编译和运行简单的程序,它会非常有用。但是,由于 Rust 是一种新的编程语言,它变化很快,并且经常添加许多新功能。这些功能是 Rust 工具链的每日更新版和之后测试版的一部分。要试用这些功能,你需要安装这些较新版本的工具链,而不会影响系统上的稳定版本。不幸的是,你的发行版的包管理器在这里无法做到。 + +### 使用 rustup 安装 Rust 工具链 + +要解决上述问题,你可以下载安装脚本: + +``` +$ curl --proto '=https' --tlsv1.2 \ + -sSf https://sh.rustup.rs > sh.rustup.rs +``` + +检查它,然后运行它。它不需要 root 权限,并根据你的本地用户权限安装 Rust: + +``` +$ file sh.rustup.rs +sh.rustup.rs: POSIX shell script, ASCII text executable +$ less sh.rustup.rs +$ bash sh.rustup.rs +``` + +出现提示时选择选项 `1`: + +``` +1) Proceed with installation (default) +2) Customize installation +3) Cancel installation +> 1 +``` + +安装后,你必须获取环境变量以确保 `rustup` 命令立即可供你运行: + +``` +$ source $HOME/.cargo/env +``` + +验证是否安装了 Rust 编译器(`rustc`)和 Rust 包管理器(`cargo`): + +``` +$ rustc --version +$ cargo --version +``` + +### 查看已安装和可用的工具链 + +你可以使用以下命令查看已安装的不同工具链以及哪个工具链是可用的: + +``` +$ rustup show +``` + +### 在工具链之间切换 + +你可以查看默认工具链并根据需要进行更改。如果你当前使用的是稳定版工具链,并希望尝试每日更新版中提供的新功能,你可以轻松切换到每日更新版工具链: + +``` +$ rustup default +$ rustup default nightly +``` + +要查看 Rust 的编译器和包管理器的完整路径: + +``` +$ rustup which rustc +$ rustup which cargo +``` + +### 检查和更新工具链 + +要检查是否有新的 Rust 工具链可用: + +``` +$ rustup check +``` + +假设一个新版本的 Rust 发布了,其中包含一些有趣的特性,并且你想要获取最新版本的 Rust。你可以使用 `update` 子命令来做到这一点: + +``` +$ rustup update +``` + +### 帮助和文档 + +以上命令对于日常使用来说绰绰有余。尽管如此,`rustup` 有多种命令,你可以参考帮助部分了解更多详细信息: + +``` +$ rustup --help +``` + +`rustup` 在 GitHub 上有完整的 [参考手册][4],你可以用作参考。所有 Rust 文档都安装在你的本地系统上,不需要你连接到互联网。你可以访问包括书籍、标准库等在内的本地文档: + +``` +$ rustup doc +$ rustup doc --book +$ rustup doc --std +$ rustup doc --cargo +``` + +Rust 是一种正在积极开发中的令人兴奋的语言。如果你对编程的发展方向感兴趣,请关注 Rust! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/6/rust-toolchain-rustup + +作者:[Gaurav Kamathe][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[turbokernel](https://github.com/turbokernel) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/gkamathe +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/tools_hardware_purple.png +[2]: https://www.rust-lang.org/ +[3]: https://github.com/rust-lang/rustup +[4]: https://rust-lang.github.io/rustup/ diff --git a/published/202206/20220623 Minetest, an Open Source Minecraft Alternative.md b/published/202206/20220623 Minetest, an Open Source Minecraft Alternative.md new file mode 100644 index 0000000000..5c7b6eef20 --- /dev/null +++ b/published/202206/20220623 Minetest, an Open Source Minecraft Alternative.md @@ -0,0 +1,131 @@ +[#]: subject: "Minetest, an Open Source Minecraft Alternative" +[#]: via: "https://itsfoss.com/minetest/" +[#]: author: "John Paul https://itsfoss.com/author/john/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14774-1.html" + +Minetest:一个开源的 Minecraft 替代品 +====== + +早在 2009 年,Minecraft 就来到了这个世界。从那时起,它已经成为一种文化现象。在这段时间里,一些开发者发布了具有类似想法和机制的开源游戏。今天,我们将看看其中最大的一个:Minetest。 + +### 什么是 Minetest? + +![](https://img.linux.net.cn/data/attachment/album/202206/29/151524eem52oyatm2tz2dr.jpg) + +[Minetest][2],简单地说,是一个基于体素voxel的沙盒游戏,与 Minecraft 非常相似。与 Minecraft 不同的是,Minetest 是用 C++ 编写的,并被设计成可以在大多数系统上原生运行。它也有一个非常大的地图区域。地图大小为 “62,000 × 62,000 × 62,000 块”,“你可以向下开采 31,000 块,或向上建造 31,000 块”。 + +有趣的是,Minetest 最初是以专有许可证发布的,但后来被重新授权为 GPL。此后,它又被重新授权为 LGPL。 + +Minetest 有几种模式。你可以建造并发挥创意,或者你可以尝试在各种元素中生存。你并不局限于这些模式。Minetest 有大量的 [额外内容][3],包括 模组mod、纹理包和在 Minetest 中建立的游戏。这主要是通过 Minetest 的 [模组 API][4] 和 Lua 完成的。 + +![minetest packages][5] + +对于那些玩过 Minecraft 的人来说,你会发现 Minetest 中的体验非常相似。你可以挖掘资源,建造结构,并结合材料来制作工具。我在 Minetest 中没有注意到的一件事是怪物。我认为 Minetest 中没有任何生物,但话说回来,我只在创意模式中玩过。我还没有玩过生存模式。 + +Minetest 也被用于 [教育][6]。例如,瑞士 CERN 的人用 Minetest 创造了一个游戏,以 [展示互联网是如何工作的][7] 以及它是如何被创造出来的。Minetest 还被用于 [教授][8] 编程、地球科学以及微积分和三角学。 + +![minetes map1][9] + +### 如何安装 Minetest? + +Minetest 几乎在每个系统上都可以使用。下面是一个命令列表,你可以用它来在一些最流行的 Linux 发行版中安装 Minetest。 + +#### Ubuntu 或者 Debian + +如果你有一个基于 Ubuntu 或 Debian 的发行版,只要在终端输入这个命令: + +``` +sudo apt install mintest +``` + +#### Arch 或者 Manjaro + +对于基于 Arch 的系统(如 Manjaro),使用: + +``` +sudo pacman -S minetest +``` + +#### Fedora + +你可以从 Fedora 服务器中输入以下命令安装 Mintest: + +``` +sudo dnf install mintest +``` + +#### openSUSE + +openSUSE 用户可以用这个命令安装 Minetest: + +``` +sudo zypper in mintest +``` + +#### FreeBSD + +FreeBSD 用户很幸运。他们可以用这个命令安装 Mintest: + +``` +pkg install minetest minetest_game +``` + +#### Snap + +要安装 Minetest 的 Snap 包,请在终端输入以下命令: + +``` +sudo snap install minetest +``` + +#### Flathub + +要安装,请输入: + +``` +flatpak install flathub net.minetest.Minetest +``` + +你可以在 [这里][11] 下载 Windows 的可移植执行文件。你也可以在 Android 上安装 Minetest,可以通过 [Google Play][12] 或 [下载 APK][13]。 + +### 总结 + +![minetest about][14] + +我已经在 Minetest 中花了几个小时在我的本地系统上进行构建和探索。它非常有趣。我还没来得及尝试任何额外的内容,因为我对我玩过的相对较少的游戏部分非常满意。我遇到的唯一麻烦是,由于某种原因,它在 Fedora 上运行缓慢。我可能存在一些配置上的错误。 + +如果你曾经认为 Minecraft 看起来很有趣,但不想花钱,那就去看看 Minetest。你会很高兴你这么做。 + +如果你玩过 Minetest,在评论中告诉我们你的体验如何。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/minetest/ + +作者:[John Paul][a] +选题:[lkxed][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/john/ +[b]: https://github.com/lkxed +[1]: https://itsfoss.com/wp-content/uploads/2022/03/minetest-start-800x411.jpg +[2]: https://www.minetest.net/ +[3]: https://content.minetest.net/ +[4]: https://dev.minetest.net/Modding_Intro +[5]: https://itsfoss.com/wp-content/uploads/2022/03/minetest-packages-800x411.jpg +[6]: https://www.minetest.net/education/ +[7]: https://forum.minetest.net/viewtopic.php?t=22871 +[8]: https://en.wikipedia.org/wiki/Minetest#Usage_in_education +[9]: https://itsfoss.com/wp-content/uploads/2022/03/minetes-map1-800x411.png +[10]: https://itsfoss.com/wp-content/uploads/2022/03/minetest-map2-800x413.png +[11]: https://www.minetest.net/downloads/ +[12]: https://play.google.com/store/apps/details?id=net.minetest.minetest&utm_source=website&pcampaignid=MKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1 +[13]: https://github.com/minetest/minetest/releases/download/5.5.0/app-armeabi-v7a-release.apk +[14]: https://itsfoss.com/wp-content/uploads/2022/03/minetest-about-800x407.jpg diff --git a/published/202206/20220624 GitHub Copilot is Now Available for All and Not Everyone Likes It.md b/published/202206/20220624 GitHub Copilot is Now Available for All and Not Everyone Likes It.md new file mode 100644 index 0000000000..345b934ec0 --- /dev/null +++ b/published/202206/20220624 GitHub Copilot is Now Available for All and Not Everyone Likes It.md @@ -0,0 +1,91 @@ +[#]: subject: "GitHub Copilot is Now Available for All and Not Everyone Likes It" +[#]: via: "https://news.itsfoss.com/github-copilot/" +[#]: author: "Jacob Crume https://news.itsfoss.com/author/jacob/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14759-1.html" + +GitHub Copilot 现已可供所有人使用,但并非所有人都喜欢它 +====== + +> GitHub Copilot 来了,它能帮助程序员,为他们提供人工智能的编码建议,不过,它是否会让事情变得更糟呢? + +![GitHub][1] + +在 2021 年,我曾花了好几个小时来翻阅 GitHub Copilot 文档,试图弄清楚如何能够加入它的技术预览计划。还好,这一切都得到了回报,我成功加入了预览计划。 + +而现在,它终于可供所有人使用啦! + +如果你还不知道的话,[GitHub Copilot][2] 是一个 AI 助手,可帮助你更快、更高效地编写代码。 + +我能想到的最类似的东西,就是你手机上的(输入法的)自动完成功能。不过,与自动完成功能不同,GitHub Copilot 编写代码,就相当于是在完成整段的句子。 + +### Copilot 现已可供大众使用 + +正如我在前面提到的,Copilot 已经处于技术预览阶段将近一年了。这意味着,GitHub 只允许非常有限数量的开发者免费使用它,以换取同意 GitHub 监控他们的使用情况,从而改进程序的最终版本。 + +看起来 GitHub 终于满意地向公众发布了它。现在,任何拥有 GitHub 帐户的人都应该能够使用它,尽管需要付出一定的代价(我很快就会在下面提到)。 + +[公告][3] 中提到: + +> 直到不久前,人工智能都没有能够帮助改进代码,开发软件的过程几乎完全是手动的。现在,这种情况正在改变。今天,我很高兴地宣布,我们正在向所有个人开发者提供 [GitHub Copilot][4]。你的 AI 配对程序员来啦。 +> +> —— [Thomas Dohmke][5],GitHub CEO + +Copilot 作为免费的编辑器扩展,已经帮助数百万开发者加快了他们的编程速度。然而,它确实是有代价的,无论是直接的还是间接的。 + +### GitHub Copilot 定价 + +与几乎所有令人兴奋的新技术一样,Copilot 对某些人来说可能过于昂贵。它将花费你 10 美元/月或 100 美元/年。 + +如果你是开源项目维护者或经过验证的学生,那么你可以免费使用它。 + +### GitHub Copilot 不道德吗? + +围绕 GitHub Copilot 产品的争议巨大且令人担忧。从技术上讲,这个人工智能是使用大家托管在 GitHub 上的代码来进行训练的。 + +因此,基本上,GitHub 是通过使用你的代码来提供一个新产品(如果你愿意的话,还可以加点料)。而且,关于 Copilot,可别忘了,自由软件基金会(FSF)也 [建议][6] 不要在 GitHub 上托管代码。 + +我们知道,企业总是喜欢利用事物,但有些人认为这应该不会直接损害托管在 GitHub 上的项目/代码。 + +**但是,是这样吗?** + +简而言之,在 Copilot 发布后,许多开发者都分享说,他们发现 GitHub Copilot 生成了受版权保护的代码: + +> 我试了下 GitHub Copilot,这是一项付费服务​​,来看看它是否会使用带有限制性许可证的存储库的代码。我检查了它,看看它是否有我在之前雇主那里编写的代码,该代码有一个许可证,只允许其用于免费游戏,并且需要附加许可证。是的,它确实有。 + +![图源:推特上的 Chris Green][7] + +当然,如果我们查看 GitHub Copilot 的常见问题解答(FAQ),其中提到: + +> GitHub 不拥有 GitHub Copilot 生成的建议。您在 GitHub Copilot 的帮助下编写的代码属于您自己,由您自己负责。 + +所以说,你为一项服务付了费,最终却为你的项目增加了不便和更多的工作? + +在我看来,就简化开发者的任务而言,这听起来一点儿也不令人兴奋。 + +*你对此有什么想法?请在下面的评论区中分享一下吧!* + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/github-copilot/ + +作者:[Jacob Crume][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[校对者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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/github-copilot.jpg +[2]: https://copilot.github.com/ +[3]: https://github.blog/2022-06-21-github-copilot-is-generally-available-to-all-developers/ +[4]: http://copilot.github.com +[5]: https://github.blog/author/ashtom/ +[6]: https://www.fsf.org/blogs/licensing/fsf-funded-call-for-white-papers-on-philosophical-and-legal-questions-around-copilot +[7]: https://pbs.twimg.com/media/FV45qM_VEAALLv6?format=png&name=medium +[8]: https://twitter.com/ChrisGr93091552/status/1539731632931803137?ref_src=twsrc%5Etfw diff --git a/published/202206/20220624 Linus Torvalds Expects to See Rust Support in the Kernel Soon.md b/published/202206/20220624 Linus Torvalds Expects to See Rust Support in the Kernel Soon.md new file mode 100644 index 0000000000..84501ed7fa --- /dev/null +++ b/published/202206/20220624 Linus Torvalds Expects to See Rust Support in the Kernel Soon.md @@ -0,0 +1,64 @@ +[#]: subject: "Linus Torvalds Expects to See Rust Support in the Kernel Soon" +[#]: via: "https://news.itsfoss.com/linux-kernel-rust/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14763-1.html" + +Linus Torvalds 暗示很快就可以在内核中看到对 Rust 的支持 +====== + +> 正如 Linus Torvalds 所暗示,Linux Kernel 5.20 发布时可能会提供对 Rust 的支持。你怎么看? + +![Linus][1] + +市面上已经有许多用 Rust 重写的开源项目。因此,如今 Rust 被认为是 Linux 内核的第二语言,也就不足为奇了。 + +几天前,在 [Linux 基金会开源峰会][2] 上,Linus Torvals 提到他们预计将在下一个内核版本(即 Linux 内核 5.20)中对 Rust 进行试验。 + +或许你不知道,正如 [Phoronix][3] 率先报道的那样,Linux 已经有了 Rust 内核补丁,包含了少量的示例驱动程序,以及基本的基础设施的启用代码。 + +因此,Linus Torvalds 对可能合并 Rust 支持的暗示,也不足为奇。但是,这无疑是令人兴奋的! + +### 用于 Linux 内核的 Rust + +这么做的最终目标是让 Linux 内核变得更好,但它现在仍然处于试运行阶段。 + +凭借其各种优势,Rust 正日益成为一种流行的编程语言。还记得吗,[System76 也在开发一个用 Rust 编写的新桌面环境][4]。 + +然而,并不是所有参与维护 Linux 内核的人都熟悉这种编程语言。 + +那么,这会是一个问题吗? + +Linus Torvalds 并不认为这是一个大问题,因为内核中也有其他语言。他还提到希望看到 Rust 成为新的一份子。 + +[The Register][5] 报道称,Linus Torvalds 表示会信任维护者,除非他们犯了错误。 + +### Linux 5.20:何时发布? + +Linux 内核 5.19 版本将于 7 月底左右发布。因此,5.20 版本的合并窗口应该会在其稳定版发布后开启(假设没有意外延迟的话)。 + +除了 Rust 以外,Linux 内核 5.20 应该也是对包括 RDNA3 在内的下一代硬件支持的重要更新,它同时提供了更多功能。 + +*你如何看待 Rust 将在不久的将来进入 Linux 呢?你感到兴奋吗?欢迎在下方评论区告诉我们~* + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/linux-kernel-rust/ + +作者:[Ankush Das][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/linus-expects-rust-support-in-linux-kernel-soon.jpg +[2]: https://events.linuxfoundation.org/open-source-summit-north-america/ +[3]: https://www.phoronix.com/scan.php?page=news_item&px=Rust-Linux-v7-Plus-New-Uutils +[4]: https://news.itsfoss.com/system76-rust-cosmic-desktop/ +[5]: https://www.theregister.com/2022/06/23/linus_torvalds_rust_linux_kernel/ diff --git a/published/20220603 How static linking works on Linux.md b/published/20220603 How static linking works on Linux.md new file mode 100644 index 0000000000..df4d8a2a21 --- /dev/null +++ b/published/20220603 How static linking works on Linux.md @@ -0,0 +1,218 @@ +[#]: subject: "How static linking works on Linux" +[#]: via: "https://opensource.com/article/22/6/static-linking-linux" +[#]: author: "Jayashree Huttanagoudar https://opensource.com/users/jayashree-huttanagoudar" +[#]: collector: "lkxed" +[#]: translator: "robsean" +[#]: reviewer: "turbokernel" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14819-1.html" + +Linux 上静态链接库工作原理 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/12/120441y0q5a5abfyjyy7ug.jpg) + +> 学习如何用静态链接库将多个 C 目标文件结合到一个单个的可执行文件之中。 + +使用 C 编写的应用程序时,通常有多个源码文件,但最终你需要编译成单个的可执行文件。 + +你可以通过两种方式来完成这项工作:通过创建一个 静态static 库 或 一个 动态dynamic 库(也被称为 共享shared 库)。从创建和链接的方式来看,它们是两种不同类型的库。选择使用哪种方式取决于你的的具体场景。 + +在 [上一篇文章][3] 中,我演示了如何创建一个动态链接的可执行文件,这是一种更通用的方法。在这篇文章中,我将说明如何创建一个静态链接的可执行文件。 + +### 使用静态库链接器 + +链接器linker是一个命令,它将一个程序的多个部分结合在一起,并为它们重新组织内存分配。 + +链接器的功能包括: + +* 整合一个程序的所有的部分 +* 计算出一个新的内存组织结构,以便所有的部分组合在一起 +* 恢复内存地址,以便程序可以在新的内存组织结构下运行 +* 解析符号引用 + +链接器通过这些功能,创建了一个名称为可执行文件的一个可运行程序。 + +静态库是通过复制一个程序中的所有依赖库模块到最终的可执行镜像来创建的。链接器将链接静态库作为编译过程的最后一步。可执行文件是通过解析外部引用、将库例程与程序代码结合在一起来创建的。 + +### 创建目标文件 + +这里是一个静态库的示例以及其链接过程。首先,创建带有这些函数识别标志的头文件 `mymath.h` : + +``` +int add(int a, int b); +int sub(int a, int b); +int mult(int a, int b); +int divi(int a, int b); +``` + +使用这些函数定义来创建 `add.c` 、`sub.c` 、`mult.c` 和 `divi.c` 文件。我将把所有的代码都放置到一个代码块中,请将其分为四个文件,如注释所示: + +``` +// add.c +int add(int a, int b){ +return (a+b); +} + +//sub.c +int sub(int a, int b){ +return (a-b); +} + +//mult.c +int mult(int a, int b){ +return (a*b); +} + +//divi.c +int divi(int a, int b){ +return (a/b); +} +``` + +现在,使用 GCC 来生成目标文件 `add.o` 、`sub.o` 、`mult.o` 和 `divi.o`: + +(LCTT 校注:关于“目标文件object file”,有时候也被称作“对象文件”,对此,存在一些译法混乱情形,称之为“目标文件”的译法比较流行,本文采用此译法。) + +``` +$ gcc -c add.c sub.c mult.c divi.c +``` + +`-c` 选项跳过链接步骤,而只创建目标文件。 + +创建一个名称为 `libmymath.a` 的静态库,接下来,移除目标文件,因为它们不再被需要。(注意,使用一个 `trash` 命令比使用一个 `rm` 命令更安全。) + +``` +$ ar rs libmymath.a add.o sub.o mult.o divi.o +$ trash *.o +$ ls +add.c  divi.c  libmymath.a  mult.c  mymath.h  sub.c +``` + +现在,你已经创建了一个名称为 `libmymath` 的简单数学示例库,你可以在 C 代码中使用它。当然,也有非常复杂的 C 库,这就是他们这些开发者来生成最终产品的工艺流程,你和我可以安装这些库并在 C 代码中使用。 + +接下来,在一些自定义代码中使用你的数学库,然后链接它。 + +### 创建一个静态链接的应用程序 + +假设你已经为数学运算编写了一个命令。创建一个名称为 `mathDemo.c` 的文件,并将这些代码复制粘贴至其中: + +``` +#include +#include +#include + +int main() +{ +  int x, y; +  printf("Enter two numbers\n"); +  scanf("%d%d",&x,&y); +  +  printf("\n%d + %d = %d", x, y, add(x, y)); +  printf("\n%d - %d = %d", x, y, sub(x, y)); +  printf("\n%d * %d = %d", x, y, mult(x, y)); + +  if(y==0){ +    printf("\nDenominator is zero so can't perform division\n"); +      exit(0); +  }else{ +      printf("\n%d / %d = %d\n", x, y, divi(x, y)); +      return 0; +  } +} +``` + +注意:第一行是一个 `include` 语句,通过名称来引用你自己的 `libmymath` 库。 + +针对 `mathDemo.c` 创建一个名称为 `mathDemo.o` 的对象文件: + +``` +$ gcc -I . -c mathDemo.c +``` + +`-I` 选项告诉 GCC 搜索在其后列出的头文件。在这个实例中,你通过单个点(`.`)来指定当前目录。 + +链接 `mathDemo.o` 和 `libmymath.a` 来生成最终的可执行文件。这里有两种方法来向 GCC 告知这一点。 + +你可以指向文件: + +``` +$ gcc -static -o mathDemo mathDemo.o libmymath.a +``` + +或者,你可以具体指定库的路径及名称: + +``` +$ gcc -static -o mathDemo -L . mathDemo.o -lmymath +``` + +在后面的那个示例中,`-lmymath` 选项告诉链接器来链接对象文件 `mathDemo.o` 和对象文件 `libmymath.a` 来生成最终的可执行文件。`-L` 选项指示链接器在下面的参数中查找库(类似于你使用 `-I` 所做的工作)。 + +### 分析结果 + +使用 `file` 命令来验证它是静态链接的: + +``` +$ file mathDemo +mathDemo: ELF 64-bit LSB executable, x86-64... +statically linked, with debug_info, not stripped +``` + +使用 `ldd` 命令,你将会看到该可执行文件不是动态链接的: + +``` +$ ldd ./mathDemo +        not a dynamic executable +``` + +你也可以查看 `mathDemo` 可执行文件的大小: + +``` +$ du -h ./mathDemo +932K    ./mathDemo +``` + +在我 [前一篇文章][3] 的示例中,动态链接的可执行文件只占有 24K 大小。 + +运行该命令来看看它的工作内容: + +``` +$ ./mathDemo +Enter two numbers +10 +5 + +10 + 5 = 15 +10 - 5 = 5 +10 * 5 = 50 +10 / 5 = 2 +``` + +看起来令人满意! + +### 何时使用静态链接 + +动态链接可执行文件通常优于静态链接可执行文件,因为动态链接会保持应用程序的组件模块化。假如一个库接收到一次关键安全更新,那么它可以很容易地修补,因为它存在于应用程序的外部。 + +当你使用静态链接时,库的代码会“隐藏”在你创建的可执行文件之中,意味着在库每次更新时(相信我,你会有更好的东西),仅有的一种修补方法是重新编译和发布一个新的可执行文件。 + +不过,如果一个库的代码,要么存在于它正在使用的具有相同代码的可执行文件中,要么存在于不会接收到任何更新的专用嵌入式设备中,那么静态连接将是一种可接受的选项。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/6/static-linking-linux + +作者:[Jayashree Huttanagoudar][a] +选题:[lkxed][b] +译者:[robsean](https://github.com/robsean) +校对:[turbokernel](https://github.com/turbokernel) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jayashree-huttanagoudar +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/lenovo-thinkpad-laptop-concentration-focus-windows-office.png +[2]: https://creativecommons.org/licenses/by/3.0/us/ +[3]: https://linux.cn/article-14813-1.html +[4]: https://www.redhat.com/sysadmin/recover-file-deletion-linux +[5]: https://opensource.com/article/22/5/dynamic-linking-modular-libraries-linux diff --git a/published/20220606 10 Best Ubuntu Apps for Everyone in 2022 [Part 2].md b/published/20220606 10 Best Ubuntu Apps for Everyone in 2022 [Part 2].md new file mode 100644 index 0000000000..e7fd03308c --- /dev/null +++ b/published/20220606 10 Best Ubuntu Apps for Everyone in 2022 [Part 2].md @@ -0,0 +1,253 @@ +[#]: subject: "10 Best Ubuntu Apps for Everyone in 2022 [Part 2]" +[#]: via: "https://www.debugpoint.com/best-ubuntu-apps-2022-part2/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: "Donkey-Hao" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14816-1.html" + +10 大必备 Ubuntu 应用:优选篇 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/11/180521obse00404niahjof.jpg) + +> 本文列出了 2022 年可以用于不同情况的 10 个 Ubuntu 优选应用。 + +如果你计划永久的转移到 Linux 系统上,你应该会很高兴地知道在 Linux 上有数以千计的能与商业或付费应用媲美的应用。如果你是第一次使用 Linux 的 Windows 用户,你可能都没有听说过这些应用。 + +因此,在这一系列文章中,我们每一篇重点介绍一组 Ubuntu 应用,以增加 Linux 用户们的协作和认识。 + +这是 Ubuntu 应用程序系列的第二篇文章,如果你错过了其他部分,可以在这里阅读: + +* [第一篇][1] + +### 1、OBS Studio + +第一个应用是著名的 [流媒体应用][3] —— OBS Studio 。这是一款自由开源的应用,主要用于互联网上的流媒体应用。此外,你可以使用该应用创建一个复杂的流媒体项目,包括多源、覆盖式横幅等功能。 + +而且,由于它能够支持“实时消息传输协议Real-Time Messaging Protocol”(RTMP),你可以使用它在 Facebook、Youtube、Twitch 以及其他支持的平台上进行流式传输。 + +这个有十年历史的应用程序是 Linux 上最好的应用程序之一。 + +![OBS Studio][4] + +你可以在 [OBS Studio 官网][5] 了解更多的信息并下载,或者通过以下方式安装。 + +通过 PPA 在 Ubuntu 和相关发行版上安装: + +``` +sudo add-apt-repository ppa:obsproject/obs-studio +sudo apt update +sudo apt install obs-studio +``` + +如果你希望通过 Flatpak 安装 ,首先 [为 Flatpak 设置系统][6] 然后 [通过这个页面安装][7] 。 + +在 Arch Linux 或者其他 Linux 版本,访问 [此页面][8] 了解。 + +#### 2、Inkscape + +这里介绍的第二款应用是流行的 Inkscape。 Inkscape 是一个自由开源的矢量图形编辑软件。它主要用于创建可缩放的矢量图形(SVG)。此外,它是一款一流的应用,可以使用基本的矢量形状如矩形、多边形、螺旋形等。你可以使用这些基本图形以及辅助工具(见下文)创作一流的绘图。 + +此外,只要你有足够的技能,就可以使用 Inkscape 创作出 [绝妙的动画][9] 。这是艺术家必备的一款应用。 + +![Sample Image – credit-Inkscape][10] + +![Inkscape][11] + +你可以在 [Inkscape 官网][12] 下载并了解更多相关信息,或者通过以下方式下载。 + +通过 PPA 在 Ubuntu 和相关发行版上安装: + +``` +sudo add-apt-repository ppa:inkscape.dev/stable +sudo apt update +sudo apt install inkscape +``` + +更多下载方式可以查看 [此页面][13] 。 + +#### 3、GIMP + +GIMP 是 “GNU 图像操作程序GNU Image Manipulation Program”的缩写,它是一个光栅图形编辑器,它有时候被视作 Linux 平台上的 [Photoshop 替代品][14](值得商榷)。这款拥有 20 年历史的应用适合于从基础到高级的图像编辑。此外,它支持图层、滤镜、装饰和其它对摄影工作必不可少的高级图像编辑功能。 + +![GIMP Image Editor][15] + +[官方主页][16] 是你了解更多关于 GIMP 的知识的最好的途径,可以在官网下载或者通过以下方式安装。 + +我推荐的方式是通过 Flatpak 下载最新版本 GIMP 。你可以为 Flatpak 设置 [你的系统][17] 然后 [通过该页面安装][18] 。 + +[该页面][19] 提供了更多下载选项。 + +#### 4、Spotify + +Spotify 是一家专业提供音频流媒体和媒体服务的提供商。它是最广泛的音乐流媒体服务之一,有超过 400 万的月活用户。 + +首先,你需要安装客户端才能获取 Spotify 流媒体服务。其次,如果你是移动用户,你可以通过 Google Play 商店或者苹果应用商店获取 Spotify 应用。 + +在 Linux 上安装桌面客户端后你可以收听上百万首歌曲。你可以为不同的 Linux 发行版通过不同的方式安装 Spotify 。 + +![Spotify Client in Ubuntu][20] + +推荐你在 Ubuntu 或者其他 Linux 上使用 Snap 来安装,你可以通过以下命令安装: + +``` +snap install spotify +``` + +如果你偏爱原始的 deb 包,你可以通过以下命令安装: + +``` +curl -sS https://download.spotify.com/debian/pubkey_5E3C45D7B312C643.gpg | sudo apt-key add -echo "deb http://repository.spotify.com stable non-free" | sudo tee /etc/apt/sources.list.d/spotify.list +``` + +你也可以使用非官方 [Flatpak 包][21] 进行安装。 + +#### 5、SimpleScreenRecorder + +SimpleScreenRecorder 可能是最好的开源截屏工具。该应用程序易于使用并提供了各种功能。并且,其独特的 3 步录制屏幕的方法完全不需要学习。此外,你可以选择整个屏幕、窗口或自定义形状来记录屏幕。 + +此外,你还可以指定音频/视频比特率、音频源选项和不同的输出选项。最后,它可以安装在所有 Linux 发行版中。 + +![SimpleScreenRecorder][22] + +[官方页面][23] 囊括了更多的 SimpleScreenRecorder 信息,你也可以使用如下方式下载。 + +在 Ubuntu 或其他相关发行版中使用下面的 PPA 命令安装该应用: + +``` +sudo apt-get updatesudo apt-get install simplescreenrecorder +``` + +访问 [此页][24] 获取更多下载版本。 + +#### 6、Calibre + +Calibre 是一款可以在 Ubuntu、Linux Mint 以及其他 Linux 平台使用的自由开源的电子书库管理应用程序。它拥有书库管理、电子书格式转换、同步你的电子书设备以及其他独特的功能。你可以下载新闻和其他互联网上的文章,并可以使用 Calibre 转换成电子书格式。同时,它支持多种电子书格式进行管理。Calibre 是一款具有这些功能最好的电子书管理应用程序之一。 + +![Calibre][25] + +[Calibre 主页][26] 提供了很多文件以及指导手册,你也可以使用以下方式下载。 + +* [下载 Linux 版本][27] +* [下载其他系统版本][28] + +#### 7、Scribus + +多年来,桌面出版已经发生了变化。现今,仍有一些桌面出版的应用程序和基于网页的服务。Scribus 是早期的一款自由开源的桌面出版应用程序,可以在 Linux 发行版和其他操作系统中使用。此外,它基于 Qt,并带来了吸引人的用户界面,让你可以马上投入学习。此外,初学者和专业人士都可以使用它来创建令人惊叹的 DTP 页面。 + +并且它仍然在积极开发中。 + +![Scribus][29] + +你可以在 Scribus 的 [官方页面][30] 了解更多信息并下载,或者通过以下方式安装。 + +Scribus 位于 Ubuntu 和其他相关发行版的主要存储库中。你可以运行以下命令进行安装: + +``` +sudo apt install scribus +``` + +[该页面][31] 提供了其他下载选项。 + +#### 8、MyPaint + +第八个应用程序是 MyPaint 。MyPaint 是一个自由开源的绘图程序,适用于数字艺术家。MyPaint 支持并可用于压感平板电脑和设备。其独特的无干扰设计可以让你专注于绘图而不是应用程序。此外,它还带来了真实铅笔和画笔的仿真,提供了各种画笔、颜色和图层。 + +![MyPaint 2.0.1][32] + +浏览 MyPaint 的 [官方页面][33] 获取更多信息,可以使用以下方式下载。 + +推荐使用 Flatpak 安装 。你可以为 Flatpak 设置 [系统][34] 然后 [通过该页面安装][35] 。 + +[该页面][36] 提供了其他下载选项。 + +#### 9、LibreOffice + +如果有任何专业的办公套件可以和市场领导者微软 Office 相媲美,那一定是文档基金会的 LibreOffice 了 。它是所有 Linux 发行版的默认办公套件。它带有电子表格程序(Calc)、文字处理器(Writer)、演示文稿(Impress)和用来绘图的 Draw。此外,它还带来了一个数据库系统 (Base)和用来撰写数学公式的 Math。 + +除此之外, LibreOffice 提供两个版本。其一是社区版,用于社区和一般用途,并带有最新的功能和更新。第二是商务版,也称企业版,更稳定,更适合专业工作。 + +LibreOffice 办公套件已默认安装在 Ubuntu 上。 + +![LibreOffice 7.3.x Community Edition in Ubuntu 22.04 LTS Jammy Jellyfish][37] + +[LibreOffice 的官方文档][38] 很庞大,你可以通过各种方式浏览它们,包括在它 [友好的论坛][39] 。你可以 [从此处][40] 下载 LibreOffice。 + +如果你也想升级 LibreOffice ,你可以访问 [这里][41] 。 + +#### 10、Cawbird + +如果你是重度 Twitter 用户,你或许应考虑一款桌面应用。 Cawbird 是一款 Linux 发行版上的 Twitter 桌面程序。它是 Corebird 应用(已停止维护)的复刻,Cawbird 带来了内嵌图片、视频预览、列表支持等。此外,它可以在 Twitter 上进行全文搜索,并支持多个 Twitter 帐户。 + +但是,由于 Twitter API 的限制,它只能每两分钟刷新一次,此外,还有一些其他限制,例如没有关注和取消关注的通知、阻止、静音和其他功能。Twitter 强加了这些限制。 + +![Cawbird][42] + +最后,你可以通过 [该链接][43] 在任何 Linux 发行版上下载 Cawbird 。 + +### 结语 + +这是 2022 年 5 篇系列的必备 Ubuntu 应用程序的第 2 篇。通过以上信息,我希望你可以选择一些应用供你的日常使用。在下面的评论框中告诉我你更喜欢此列表中的哪些应用程序。 + +最后,请继续关注本 Ubuntu 应用程序系列的第 3 部分。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/best-ubuntu-apps-2022-part2/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[Donkey](https://github.com/Donkey-Hao) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://www.debugpoint.com/essential-ubuntu-apps-2022-part-1/ +[2]: https://www.debugpoint.com/necessary-ubuntu-apps-2022/ +[3]: https://www.debugpoint.com/2022/02/live-streaming-applications-linux-2022/ +[4]: https://www.debugpoint.com/wp-content/uploads/2022/06/OBS-Studio.jpg +[5]: https://obsproject.com/ +[6]: https://www.debugpoint.com/2018/07/how-to-install-flatpak-apps-ubuntu-linux/ +[7]: https://flathub.org/apps/details/com.obsproject.Studio +[8]: https://obsproject.com/wiki/unofficial-linux-builds +[9]: https://inkscape.org/gallery/ +[10]: https://www.debugpoint.com/wp-content/uploads/2022/06/Sample-Image-credit-Inkscape.jpg +[11]: https://www.debugpoint.com/wp-content/uploads/2018/09/Inkscape-Running.png +[12]: https://inkscape.org/ +[13]: https://inkscape.org/release/ +[14]: https://www.debugpoint.com/2018/09/3-best-free-photoshop-alternatives-ubuntu-linux/ +[15]: https://www.debugpoint.com/wp-content/uploads/2018/09/GIMP-Running.png +[16]: https://www.gimp.org/ +[17]: https://www.debugpoint.com/2018/07/how-to-install-flatpak-apps-ubuntu-linux/ +[18]: https://flathub.org/repo/appstream/org.gimp.GIMP.flatpakref +[19]: https://www.gimp.org/downloads/ +[20]: https://www.debugpoint.com/wp-content/uploads/2022/06/Spotify-Client-in-Ubuntu.jpg +[21]: https://flathub.org/apps/details/com.spotify.Client +[22]: https://www.debugpoint.com/wp-content/uploads/2022/06/SimpleScreenRecorder.jpg +[23]: https://www.maartenbaert.be/simplescreenrecorder/ +[24]: https://www.maartenbaert.be/simplescreenrecorder/#download +[25]: https://www.debugpoint.com/wp-content/uploads/2019/11/Calibre.png +[26]: https://calibre-ebook.com/ +[27]: https://calibre-ebook.com/download_linux +[28]: https://calibre-ebook.com/download +[29]: https://www.debugpoint.com/wp-content/uploads/2022/06/Scribus.jpg +[30]: https://www.scribus.net/ +[31]: https://www.scribus.net/downloads/stable-branch/ +[32]: https://www.debugpoint.com/wp-content/uploads/2020/05/MyPaint-2.0.1.png +[33]: http://mypaint.org/ +[34]: https://www.debugpoint.com/2018/07/how-to-install-flatpak-apps-ubuntu-linux/ +[35]: https://flathub.org/repo/appstream/org.mypaint.MyPaint.flatpakref +[36]: http://mypaint.org/downloads/ +[37]: https://www.debugpoint.com/wp-content/uploads/2019/09/LibreOffice-7.3.x-Community-Edition-in-Ubuntu-22.04-LTS-Jammy-Jellyfish.jpg +[38]: https://help.libreoffice.org/latest/index.html +[39]: https://ask.libreoffice.org/ +[40]: https://www.libreoffice.org/download/download/ +[41]: https://www.debugpoint.com/2022/06/libreoffice-upgrade-update-latest/ +[42]: https://www.debugpoint.com/wp-content/uploads/2022/06/Cawbird.jpg +[43]: https://software.opensuse.org//download.html?project=home%3AIBBoard%3Acawbird&package=cawbird +[44]: https://www.debugpoint.com/essential-ubuntu-apps-2022-part-1/ +[45]: https://www.debugpoint.com/necessary-ubuntu-apps-2022/ diff --git a/published/20220623 How to Boot into an Older Kernel By Default in Ubuntu and Other Linux.md b/published/20220623 How to Boot into an Older Kernel By Default in Ubuntu and Other Linux.md new file mode 100644 index 0000000000..6e74655d55 --- /dev/null +++ b/published/20220623 How to Boot into an Older Kernel By Default in Ubuntu and Other Linux.md @@ -0,0 +1,132 @@ +[#]: subject: "How to Boot into an Older Kernel By Default in Ubuntu and Other Linux" +[#]: via: "https://itsfoss.com/boot-older-kernel-default/" +[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" +[#]: collector: "lkxed" +[#]: translator: "hanszhao80" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14843-1.html" + +如何默认启动到 Linux 系统的旧内核 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/19/142100e4ympeo7y5w6pwvo.jpg) + +这是一个可能的情景。你的系统收到了内核更新,但不知何故,事情不像以前那样顺利。 + +你意识到,如果你启动到较旧的内核(是的,你可以降级内核),一切都会恢复正常。 + +高兴之余你会觉得有点儿不爽。因为你不得不在每次启动时手动选择较旧的内核。 + +一位年长的读者遇到了这个问题。[Linux Mint][1] 中的新内核更新没有按预期工作。启动到较旧的内核“修复”了问题,但麻烦的是在每次启动时要去手动选择较旧的内核。 + +删除新内核而使用旧内核不是一个好主意,因为新内核将会在下一次系统更新时被安装使用。 + +因此,我建议设置成默认启动到较旧的 Linux 内核。怎么做?这就是我将在本教程中向你展示的内容。 + +### 启动至较旧的 Linux 内核 + +你可能不了解,你的 Linux 发行版会在你的系统上安装多个 Linux 内核。不信?使用以下命令 [列出 Ubuntu 中已安装的内核][2]: + +``` +apt list --installed | grep linux-image +``` + +当你升级系统时会获得一个新版本的内核,这时你的系统会自动选择启动至最新的可用内核。 + +在 [grub][3] 屏幕中,你可以转到高级选项Advanced option(较旧的 Linux 版本): + +![ubuntu grub][4] + +在这里,你可以看到要启动的可用内核。选择较旧的(不带恢复选项recovery option 的条目): + +![grub 高级选项][5] + +你不会注意到任何显示的差异。你的文件和应用程序保持不变。 + +现在你已经启动到旧内核,是时候让你的系统自动启动到它了。 + +### 使旧内核成为默认启动项 + +如果你乐于使用 Linux 终端和命令,你可以修改 `/etc/default/grub` 文件并在其中添加以下行: + +``` +GRUB_DEFAULT=saved +GRUB_SAVEDEFAULT=true +``` + +然后使用如下命令 [更新 GRUB][6]: + +``` +sudo update-grub +``` + +你在这里所做的是告诉你的系统将当前使用的启动项保存为将来运行 GRUB 的默认启动项。 + +然而,并不是每个人都善于使用命令行,因此我将专注于一个名为 [Grub Customizer][7] 的 GUI 工具。 + +#### 安装 Grub Customizer + +使用官方 PPA [在基于 Ubuntu 的发行版中安装 Grub Customizer][8]: + +``` +sudo add-apt-repository ppa:danielrichter2007/grub-customizer +sudo apt update +sudo apt install grub-customizer +``` + +对于其他发行版,请使用你的包管理器来安装此工具。 + +#### 使用 Grub Customizer 更改默认启动项 + +当你运行 Grub Customizer 时,它会显示可用的启动项。 + +![ubuntu 的 grub customizer][9] + +在这里你有两个选择。 + +**选择一:** 选择所需的内核项并使用箭头按钮(显示在顶部菜单上)将其向上移动。 + +![在 Ubuntu grub 将旧内核向上移动][10] + +**选择二:** 将先前的启动项previously booted entry设为默认启动项default entry。 + +![将当前启动项设为默认 Ubuntu 启动项][11] + +我建议使用第二个选择,因为即使有新的内核更新它也可以工作。 + +这样你就可以在 Ubuntu 或其他发行版中降级内核,甚至无需删除新内核版本。 + +请注意,像 Ubuntu 这样的发行版大部分一次只保留两个内核版本。因此,最终你首选的旧内核将在新的内核版本释出时被删除。 + +这个巧妙的技巧曾助我脱困。当时我 [在 Ubuntu 中安装最新的 Linux 内核][12] ,由于某种原因它与我的音频系统有些兼容问题。 + +无论是什么原因,你现在都知道如何自动启动到旧内核。 + +如果有问题或建议,请在评论区留言。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/boot-older-kernel-default/ + +作者:[Abhishek Prakash][a] +选题:[lkxed][b] +译者:[hanszhao80](https://github.com/hanszhao80) +校对:[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/lkxed +[1]: https://linuxmint.com/ +[2]: https://learnubuntu.com/list-installed-kernels/ +[3]: https://itsfoss.com/what-is-grub/ +[4]: https://itsfoss.com/wp-content/uploads/2022/06/ubuntu-grub.jpg +[5]: https://itsfoss.com/wp-content/uploads/2022/06/Grub-Advanced-Options.jpg +[6]: https://itsfoss.com/update-grub/ +[7]: https://itsfoss.com/customize-grub-linux/ +[8]: https://itsfoss.com/install-grub-customizer-ubuntu/ +[9]: https://itsfoss.com/wp-content/uploads/2022/06/grub-customizer-ubuntu.png +[10]: https://itsfoss.com/wp-content/uploads/2022/06/move-older-kernel-up-the-order-ubntu-grub.png +[11]: https://itsfoss.com/wp-content/uploads/2022/06/make-currently-booted-entry-as-default-ubuntu.png +[12]: https://itsfoss.com/upgrade-linux-kernel-ubuntu/ diff --git a/published/20220625 Download YouTube Videos with VLC -Because, Why Not--.md b/published/20220625 Download YouTube Videos with VLC -Because, Why Not--.md new file mode 100644 index 0000000000..d657e3a5f0 --- /dev/null +++ b/published/20220625 Download YouTube Videos with VLC -Because, Why Not--.md @@ -0,0 +1,98 @@ +[#]: subject: "Download YouTube Videos with VLC (Because, Why Not?)" +[#]: via: "https://itsfoss.com/download-youtube-videos-vlc/" +[#]: author: "Community https://itsfoss.com/author/itsfoss/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14788-1.html" + +使用 VLC 下载 YouTube 视频 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/03/100812twzmm942m4o7lmzq.jpg) + +[VLC][1] 是 [Linux 和其他平台上最受欢迎的视频播放器][2]之一。 + +它不仅仅是一个视频播放器。它提供了许多多媒体和网络相关的功能。你会惊讶地 [了解 VLC 的能力][3]。 + +我将演示一个简单的 VLC 功能,即使用它下载 YouTube 视频。 + +是的。你可以在 VLC 中播放 YouTube 视频并下载它们。让我告诉你怎么做。(LCTT 校注:发布此文只探讨技术可行性。) + +### 使用 VLC 媒体播放器下载 YouTube 视频 + +现在,有一些方法可以 [下载 YouTube 视频][4]。使用浏览器扩展或使用专门的网站或工具。 + +但是如果你不想使用任何额外的东西,已经安装的 VLC 播放器可以用于此目的。 + +**重要提示:**在从 YouTube 复制链接之前,请确保从 YouTube 播放器中选择所需的视频质量,因为我们将获得与复制链接时流式传输视频相同的质量。 + +#### 步骤 1:获取所需视频的视频链接 + +你可以使用任何你喜欢的浏览器并从地址栏中复制视频链接。 + +![copy youtube link][5] + +#### 步骤 2:将复制的链接粘贴到网络流 + +“网络流Network Stream”选项位于“媒体Media”菜单下,这是我们顶部菜单栏的第一个选项。你也可以使用快捷方式 `CTRL + N` 打开网络流 。 + +![click on media and select network stream][6] + +现在,你只需粘贴复制的 YouTube 视频链接,然后单击播放按钮。我知道它只是在我们的 VLC 中播放视频,但还有一点额外的步骤可以让我们下载当前的流媒体视频。 + +![paste video link][7] + +#### 步骤 3:从编解码器信息中获取位置链接 + +在“编解码器信息Codec Information”下,我们会得到当前播放视频的位置链接。要打开编解码器信息,你可以使用快捷键 `CTRL + J` 或者你会在“工具Tools”菜单下找到编解码器信息选项。 + +![click on tools and then codec information][8] + +它将带来有关当前流媒体视频的详细信息。但我们需要的是“位置Location”。你只需复制位置链接,我们的任务就完成了 90%。 + +![copy location link][9] + +#### 步骤 4:将位置链接粘贴到新选项卡 + +打开任何你喜欢的浏览器,并将复制的位置链接粘贴到新选项卡,它将开始在浏览器中播放该视频。 + +现在,右键单击播放视频,你将看到“将视频另存为”的选项。 + +![click on save][10] + +它将打开文件管理器并询问你是否要在本地保存此视频。你还可以重命名该文件,默认情况下它将被命名为 “videoplayback.mp4”。 + +![showing file in folder][11] + +### 结论 + +如果你有互联网连接问题,或者如果你想保存一些视频以供将来观看,下载 YouTube 视频是有意义的。 + +当然,我们不鼓励盗版。此方法仅用于合理使用,请确保视频的创建者已允许该视频进行合理使用,并确保在将其用于其他地方之前将其归属于视频的原始所有者。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/download-youtube-videos-vlc/ + +作者:[Community][a] +选题:[lkxed][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/itsfoss/ +[b]: https://github.com/lkxed +[1]: https://www.videolan.org/vlc/ +[2]: https://itsfoss.com/video-players-linux/ +[3]: https://itsfoss.com/vlc-pro-tricks-linux/ +[4]: https://itsfoss.com/download-youtube-videos-ubuntu/ +[5]: https://itsfoss.com/wp-content/uploads/2022/06/copy-Youtube-link-800x190.jpg +[6]: https://itsfoss.com/wp-content/uploads/2022/06/click-on-media-and-select-network-stream.png +[7]: https://itsfoss.com/wp-content/uploads/2022/06/paste-video-link.png +[8]: https://itsfoss.com/wp-content/uploads/2022/06/click-on-tools-and-then-codec-information-800x249.png +[9]: https://itsfoss.com/wp-content/uploads/2022/06/copy-location-link.png +[10]: https://itsfoss.com/wp-content/uploads/2022/06/click-on-save-800x424.jpg +[11]: https://itsfoss.com/wp-content/uploads/2022/06/showing-file-in-folder-800x263.png diff --git a/published/20220627 Kuro- An Unofficial Microsoft To-Do Desktop Client for Linux.md b/published/20220627 Kuro- An Unofficial Microsoft To-Do Desktop Client for Linux.md new file mode 100644 index 0000000000..f4257ab223 --- /dev/null +++ b/published/20220627 Kuro- An Unofficial Microsoft To-Do Desktop Client for Linux.md @@ -0,0 +1,100 @@ +[#]: subject: "Kuro: An Unofficial Microsoft To-Do Desktop Client for Linux" +[#]: via: "https://itsfoss.com/kuro-to-do-app/" +[#]: author: "Ankush Das https://itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14795-1.html" + +Kuro:非官方的微软 To-Do Linux 桌面客户端 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/05/151405wsp6k55rrzdkk6dl.jpg) + +> 微软说他们热爱 Linux 和开源,但我们仍然没有得到对其许多产品的 Linux 原生支持。 + +虽然他们可能在努力增加更多的支持,比如 [可以在 Linux 上安装微软 Edge 浏览器][1],但对于一个价值几万亿美元的公司来说,这并不出色。 + +同样,微软的 To-Do 服务也是一个受欢迎的服务,它取代了 2020 年关闭的 Wunderlist。 + +如果你不知道的话,我们有很多 [可用于 Linux 的待办事项列表应用][2]。因此,如果你想脱离微软 To-Do,你有选择。 + +微软 To-Do 是一个基于云的任务管理应用,让你从手机、桌面和网络组织你的任务。它可以在 Windows、Mac 和 Android 上下载。 + +那么,如果你不愿意使用网页浏览器而使用一个单独的应用,你在 Linux 上能做什么呢? + +Kuro 派上用场了。 + +### Kuro:非官方的开源微软 To-Do 应用 + +![kuro todo][3] + +Kuro 是一个非官方的开源应用,它为你提供了微软 To-Do 在 Linux 上的桌面体验和一些额外的功能。 + +它是 Ao 的一个分叉,Ao 是一个开源项目,逐渐成为它的解决方案。不幸的是,它不再积极维护了。所以,我遇到了一个似乎可以工作的新复刻。 + +![kuro todo options][4] + +Kuro 提供了一些额外的功能,可以让你在应用中切换主题,启用全局快捷方式等。 + +请注意,这个应用是相当新的,但有一个稳定版本可以试用。此外,开发者计划在不久的将来增加更多的主题和功能。 + +### Kuro 的功能 + +![kuro todo 1][5] + +如果你倾向于使用微软的服务(如 Outlook),它的 To-Do 应用应该是组织你的任务的一个完美选择。你甚至可以标记电子邮件以创建任务。 + +使用 Kuro 桌面客户端,你可以得到一些可配置的功能,包括: + +* 能够在启动时启动该程序。 +* 获得一个系统托盘图标,以快速创建一个任务,搜索,或检查当天的可用列表。 +* 启用全局快捷键。 +* 切换可用的主题(深褐色、德古拉、黑色、深色)。 +* 切换自动夜间模式,如果你不想不断改变主题。 +* 隐藏托盘图标,如果你不需要它。 +* 根据需要定制字体大小。 + +![kuro todo settings][6] + +除了一些功能外,你还可以进入某些设置来启用/禁用电子邮件通知、删除前确认等,对待办事项应用体验的进行更多的控制。 + +总的来说,体验并不糟糕,但我在几分钟内注意到用户界面上有一些奇怪的图形问题。我不确定这是否是一个已知的问题。 + +### 在 Linux 中安装 Kuro + +你可以从它的 [GitHub 发布页面][7] 找到基于 Ubuntu 的发行版的 .deb 包。 + +此外,你可以从 [Snap 商店][8] 中在你选择的任何 Linux 发行版上安装它。该软件包也可在 Arch Linux 发行版的 [AUR][9] 中获取。 + +开发者还提到,正在开发一个 Flatpak 软件包。所以,你可以关注它的 [GitHub 页面][10]以了解更多相关信息。 + +> **[Kuro][11]** + +你已经试过它了吗?你知道有什么更好的微软 To-Do 客户端用于 Linux 吗?请在下面的评论中告诉我。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/kuro-to-do-app/ + +作者:[Ankush Das][a] +选题:[lkxed][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/lkxed +[1]: https://itsfoss.com/microsoft-edge-linux/ +[2]: https://itsfoss.com/to-do-list-apps-linux/ +[3]: https://itsfoss.com/wp-content/uploads/2022/06/kuro-todo-800x507.png +[4]: https://itsfoss.com/wp-content/uploads/2022/06/kuro-todo-options-800x444.png +[5]: https://itsfoss.com/wp-content/uploads/2022/06/kuro-todo-1.png +[6]: https://itsfoss.com/wp-content/uploads/2022/06/kuro-todo-settings.png +[7]: https://github.com/davidsmorais/kuro/releases +[8]: https://snapcraft.io/kuro-desktop +[9]: https://itsfoss.com/aur-arch-linux/ +[10]: https://github.com/davidsmorais/kuro +[11]: https://github.com/davidsmorais/kuro diff --git a/published/20220627 Make a temporary file on Linux with Bash.md b/published/20220627 Make a temporary file on Linux with Bash.md new file mode 100644 index 0000000000..630fcc31bc --- /dev/null +++ b/published/20220627 Make a temporary file on Linux with Bash.md @@ -0,0 +1,144 @@ +[#]: subject: "Make a temporary file on Linux with Bash" +[#]: via: "https://opensource.com/article/22/6/make-temporary-file-bash" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14783-1.html" + +在 Linux 上使用 Bash 创建一个临时文件 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/01/145110u1ninn1n3idspp71.jpg) + +> 基于 Fedora 的系统上的 `mktemp` 命令和基于 Debian 的系统上的 `tempfile` 是专门为减轻这种负担而设计的,它使创建、使用和删除独特的文件变得容易。 + +使用 Bash 脚本语言进行编程时,有时需要创建一个临时文件。例如,你可能需要一个可以提交到磁盘的中间文件,以便你可以使用另一个命令对其进行处理。创建诸如 `temp` 之类的文件或任何以 `.tmp` 结尾的文件很容易。但是,这些名称很可能是由其他进程生成的,因此你可能会不小心覆盖现有的临时文件。除此之外,你不应该花费脑力想出看起来独特的名字。基于 Fedora 的系统上的 `mktemp` 命令和基于 Debian 的系统上的 `tempfile` 是专门为减轻这种负担而设计的,它使创建、使用和删除独特的文件变得容易。 + +### 创建一个临时文件 + +`mktemp` 和 `tempfile` 都创建一个临时文件作为它们的默认操作,并打印文件的名称和位置作为输出: + +``` +$ tempfile +/tmp/fileR5dt6r + +$ mktemp +/tmp/tmp.ojEfvMaJEp +``` + +除非你指定不同的路径,否则系统会将临时文件放在 `/tmp` 目录中。 + +对于 `mktemp`,可以使用 `-p` 选项指定路径: + +``` +$ mktemp -p ~/Demo +/home/tux/Demo/tmp.i8NuhzbEJN +``` + +对于 `tempfile`,可以使用 `--directory` 或 `-d` 选项: + +``` +$ tempfile --directory ~/Demo/ +/home/sek/Demo/fileIhg9aX +``` + +### 找到你的临时文件 + +使用自动生成的临时文件的问题是你无法知道它的名字是什么。这就是为什么两个命令都返回生成的文件名作为输出的原因。你可以使用 Konsole、GNOME 终端或 [rxvt][2] 等交互式 shell 来使用终端上显示的文件名与文件进行交互。 + +但是,如果你正在编写脚本,则无法通过读取文件名并在以下命令中使用它来进行干预。 + +`mktemp` 和 `tempfile` 的作者想到了这个问题,并且有一个简单的解决方法。终端将输出发送到名为“标准输出”的流。你可以通过将变量设置为在子 shell 中启动的命令的结果来捕获标准输出: + +``` +$ TMPFILE=$(mktemp -p ~/Demo) + +$ echo $TMPFILE +/home/tux/Demo/tmp.PjP3g6lCq1 +``` + +引用文件时使用 `$TMPFILE`,它与直接与文件本身交互相同。 + +### 使用 mktemp 创建一个临时目录 + +你还可以使用 `mktemp` 命令创建目录而不是文件: + +``` +$ mktemp --directory -p ~/Demo/ +/home/tux/Demo/tmp.68ukbuluqI + +$ file /home/tux/Demo/tmp.68ukbuluqI +/home/tux/Demo/tmp.68ukbuluqI: directory +``` + +### 自定义临时名称 + +有时你甚至可能希望在伪随机生成的文件名中加入可预测性元素。你可以使用这两个命令自定义临时文件的名称。 + +使用 `mktemp`,你可以为文件名添加后缀: + +``` +$ mktemp -p ~/Demo/ --suffix .mine +/home/tux/Demo/tmp.dufLYfwJLO.mine +``` + +使用 `tempfile`,你可以设置前缀和后缀: + +``` +$ tempfile --directory ~/Demo/ --prefix tt_ --suffix .mine +/home/tux/Demo/tt_0dfu5q.mine +``` + +### 把 tempfile 作为 touch 使用 + +你还可以使用 `tempfile` 设置自定义名称: + +``` +$ tempfile --name not_random +not_random +``` + +当你使用 `--name` 选项时,它是绝对的,忽略所有其他形式的自定义。事实上,它甚至忽略了 `--directory` 选项: + +``` +$ tempfile --directory ~/Demo --prefix this_is_ --suffix .all --name not_random_at +not_random_at +``` + +在某种程度上,`tempfile` 可以替代 `touch` 和 `test`,因为它拒绝创建已经存在的文件: + +``` +$ tempfile --name example.txt +open: file exists +``` + +`tempfile` 命令并非默认安装在所有 Linux 发行版上,因此在将其用作脚本中的 `test` 的 hack 之前,你必须确保它存在。 + +### 安装 mktemp 和 tempfile + +[GNU Core Utils][3] 包括 `mktemp` 命令。主要发行版默认包括 Core Utils(它是包含 `chmod`、`cut`、`du` 和其他基本命令的同一个软件包)。 + +Debian Utils 软件包包含 `tempfile` 命令,默认安装在大多数基于 Debian 的发行版和 Slackware Linux 上。 + +### 总结 + +临时文件很方便,因为不会混淆它们是否可以安全删除。它们是临时的,意在根据需要使用并毫不犹豫地丢弃。在需要时使用它们,并在完成后清除它们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/6/make-temporary-file-bash + +作者:[Seth Kenlon][a] +选题:[lkxed][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/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/bash_command_line.png +[2]: https://opensource.com/article/19/10/why-use-rxvt-terminal +[3]: https://www.gnu.org/software/coreutils/ diff --git a/published/20220628 HandBrake- Free Tool for Converting Videos from Any Format.md b/published/20220628 HandBrake- Free Tool for Converting Videos from Any Format.md new file mode 100644 index 0000000000..91509dd7e5 --- /dev/null +++ b/published/20220628 HandBrake- Free Tool for Converting Videos from Any Format.md @@ -0,0 +1,127 @@ +[#]: subject: "HandBrake: Free Tool for Converting Videos from Any Format" +[#]: via: "https://www.debugpoint.com/handbrake/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14801-1.html" + +HandBrake:用于转换任何格式视频的免费工具 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/07/141355dt7b8znyhfmltmsh.jpg) + +> 了解一下 HandBrake,这是一个优秀的工具,可以将任何格式的视频转换为目标类型。 + +本文介绍了它的功能、下载说明和使用指南。 + +### HandBrake + +在这个社交媒体的时代,我们身处各种视频之中,当然还有随之而来的各种格式。因此,如果你是在 Linux 平台,甚至是在 Windows 平台,你可以使用各种软件来为多个平台转换各种视频。但是,如果你需要一个简单但功能丰富的视频转换器来处理来自多个来源的所有视频格式,请尝试 HandBrake。 + +#### 功能 + +HandBrake 有大量的选项,使其成为一个独特的工具。首先,其工作流程是超级简单。事实上,它只是三个步骤: + +* 选择一个视频 +* 选择一个目标格式 +* 转换 + +正如你所看到的,如果你是一个新手用户,使用这个工具是非常容易的,因为目标格式的属性(如比特率、尺寸)是基于默认的预设。 + +其次,如果你想进行高级编辑,如在转换时从字幕文件中添加字幕,也可以使用这个工具。 + +此外,你还可以改变尺寸、翻转视频、改变分辨率、修改长宽比,以及裁剪。此外,通过一套基本的过滤器配置,可以完成诸如去噪和锐化等操作。 + +另外,为你的视频文件添加章节、标签和音轨也很容易。 + +也许 HandBrake 的重要功能是提供预设,以满足现代社会媒体和流媒体的需求。例如,其预设与这些流媒体平台和流媒体设备相一致,如: + +* Discord +* GMail +* Vimeo +* 亚马逊 Fire Stick 电视棒 +* 苹果设备 +* Chromecast +* Playstation +* Roku +* Xbox + +一个相当令人印象深刻的列表,不是吗?不仅如此,如果你是一个专业工作者,它可以帮助你定义和创建转换队列。队列功能允许你在工作流程中批量转换多个视频文件。 + +最后,你可以转换为 MPEG-4(mp4)、Matroska(mkv)和 WebM 格式。 + +![HandBrake with various features][1] + +### 下载和安装 + +下载和安装 HandBrake 对于任何平台(Linux、Mac 和 Windows)都很容易。开发者直接提供了可执行文件,可以免费下载。 + +由于本站的主要目标受众是 Linux 用户,我们将讨论 HandBrake 在 Linux 中的安装。 + +对于 Ubuntu、Linux Mint 和所有其他发行版,最好的方法是 Flatpak。你可以 [设置 Flatpak][2],然后点击下面的按钮来安装 HandBrake: + +> **[通过 Flathub 安装 HandBrake][3]** + +对于 Windows、macOS 的安装程序,请访问 [这个页面][4a]。 + +一个有趣的特点是,你可以通过命令行使用这个应用程序!这意味着你可以使用命令行工具进一步定制你的工作流程,你可以在 [这里][4] 下载。 + +### 如何使用 HandBrake 来转换视频?(示例) + +既然你安装了它,让我们看看你如何只用三个步骤就能转换一个示例视频。 + +1. 打开 HandBrake,点击顶部工具栏上的 “打开源文件Open Source” 按钮,选择你的视频文件。 +2. 现在,从“格式Format”下拉菜单中选择目标文件类型。确保选中目标文件夹(默认为 `Videos`)。 +3. 最后,点击顶部工具栏的“开始Start”按钮,用 HandBrake 转换视频。 + +![HandBrake Video Conversion in three simple steps][5] + +你可以在窗口的底部找到一个漂亮的转换进度显示。 + +![Encoding status][6] + +上面的步骤是最基本的步骤。如果你想进一步控制视频,你可以改变选项,也可以从我前面解释的大量预设列表中选择。 + +### 常见问题 + +**HandBrake 是免费使用么?** + +是的,它是一个自由开源的应用程序,你可以免费下载它。 + +**它可在 Mac 和 Windows 上用么?** + +是的,你可以在 macOS、Windows 10 和 Windows 11 中轻松安装 HandBrake。 + +**如何下载 HandBrake?** + +你只能从官方网站 https://handbrake.fr/ ,不能从其他地方下载 HandBrake。 + +### 结束语 + +Handbrake 是如今可用的专业级免费和开源视频编码器之一。它是一个经过时间考验的应用,每天有数百万用户使用。我希望本指南能帮助你了解这个神奇的工具,让你开始你的视频项目。 + +**演示视频来自 [Pexels - cottonbro][7]**。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/handbrake/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://www.debugpoint.com/wp-content/uploads/2022/06/HandBrake-with-various-features.jpg +[2]: https://www.debugpoint.com/how-to-install-flatpak-apps-ubuntu-linux/ +[3]: https://dl.flathub.org/repo/appstream/fr.handbrake.ghb.flatpakref +[4]: https://handbrake.fr/downloads2.php +[4a]: https://handbrake.fr/downloads.php +[5]: https://www.debugpoint.com/wp-content/uploads/2022/06/HandBrake-Video-Conversion-in-three-simple-steps.jpg +[6]: https://www.debugpoint.com/wp-content/uploads/2022/06/Encoding-status.jpg +[7]: https://www.pexels.com/video/hands-hand-table-colorful-3997786/ diff --git a/published/20220629 Finding Your Router-s IP Address -Default Gateway- in Ubuntu and Other Linux.md b/published/20220629 Finding Your Router-s IP Address -Default Gateway- in Ubuntu and Other Linux.md new file mode 100644 index 0000000000..e33d4eb801 --- /dev/null +++ b/published/20220629 Finding Your Router-s IP Address -Default Gateway- in Ubuntu and Other Linux.md @@ -0,0 +1,112 @@ +[#]: subject: "Finding Your Router’s IP Address (Default Gateway) in Ubuntu and Other Linux" +[#]: via: "https://itsfoss.com/router-ip-address-linux/" +[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14799-1.html" + +在 Linux 中找到你的路由器的 IP 地址(默认网关) +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/06/155222cgjpa9ppa19zr2g1.jpg) + +你可能已经知道如何在 Linux 中获得你的系统的 IP 地址。 + +但是你怎么知道你的路由器的 IP 地址呢? + +我说的不是你可以通过连接到 “[Show My IP][1]” 这样的网站或简单地在 [DuckDuckGo][3] 中 [搜索“what is my ip”][2] 获得的公网 IP。 + +我说的是默认网关 IP,你的 Linux 桌面所连接的地址。 + +你为什么需要它?嗯,如果你需要改变你的 Wi-Fi/网络的 SSID、密码或其他配置,你必须连接到它。简单的方法是在网页浏览器中输入路由器的 IP 地址,然后使用路由器的用户名和密码。 + +虽然我不能帮助你获得路由器的用户名和密码,但我肯定可以告诉你如何获得它的 IP。 + +一如既往,我将展示 GUI 和命令行两种方法。 + +### 方法 1:在 Linux 中使用 GUI 获取路由器的 IP 地址 + +这其实很简单。我在这里使用的是 Ubuntu 的 GNOME 桌面。如果你使用一些 [其他桌面环境][4],截图可能会有所不同。 + +打开“系统设置System Settings”: + +![go to settings][5] + +现在进入 Wi-Fi 或“网络Network”(如果你使用的是有线的以太网连接)。在这里,点击你当前使用的网络旁边的小设置符号。 + +![access network settings ubuntu][6] + +它将打开一个新窗口,里面有关于你的连接的一些细节,如 IP 地址、DNS 和 [Mac 地址][7]。你还可以在“安全security”标签下看到 [保存的 Wi-Fi 密码][8]。 + +你还会看到一个名为“默认路由Default Route”的条目。这就是你要找的东西。你的路由器的 IP 地址。 + +![default gateway ip ubuntu][9] + +你的系统和网络上的所有其他设备都使用这个 IP 地址连接到路由器。这就是大多数家庭的设置。 + +现在我已经展示了 GUI 的方法,让我们去看看终端的路线。 + +### 方法 2:在 Linux 命令行中获取路由器的 IP 地址 + +打开一个终端,使用以下命令: + +``` +ip route +``` + +它将显示几个条目。 + +``` +~$ ip route +default via 192.168.1.1 dev wlp0s20f3 proto dhcp metric 600 +169.254.0.0/16 dev wlp0s20f3 scope link metric 1000 +192.168.1.0/24 dev wlp0s20f3 proto kernel scope link src 192.168.1.34 metric 600 +``` + +第一行,以 `default via` 开头,给出了你网关的 IP。这是你的路由器的 IP 地址。 + +![default route linux terminal][10] + +你可以看到,`192.168.1.1` 是我的路由器的 IP 地址。通常情况下,路由器的 IP 地址是子网的第一个数字。然而,这并不是一个硬性规定。我也见过有 `x.y.z.30` 地址的路由器。 + +### 额外技巧 + +正如 Samir 在评论中所分享的,你也可以(在 Debian 上)使用 `ping` 命令来获得网关 IP: + +``` +ping _gateway +``` + +![ping gateway][11] + +以防你不知道,你必须 [在 Linux 中使用 Ctrl+C 来停止一个正在运行的命令][12]。 + +我希望你在需要的时候能发现这个技巧是有用的。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/router-ip-address-linux/ + +作者:[Abhishek Prakash][a] +选题:[lkxed][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/lkxed +[1]: https://www.showmyip.com/ +[2]: https://duckduckgo.com/?q=what+is+my+ip&t=h_&ia=answer +[3]: https://itsfoss.com/duckduckgo-easter-eggs/ +[4]: https://itsfoss.com/best-linux-desktop-environments/ +[5]: https://itsfoss.com/wp-content/uploads/2022/02/go_to_settings.jpg +[6]: https://itsfoss.com/wp-content/uploads/2022/06/access-network-settings-ubuntu-800x448.png +[7]: https://itsfoss.com/change-mac-address-linux/ +[8]: https://itsfoss.com/how-to-find-saved-wireless-wifi-passwords-ubuntu/ +[9]: https://itsfoss.com/wp-content/uploads/2022/06/defaul-gateway-ip-ubuntu.png +[10]: https://itsfoss.com/wp-content/uploads/2022/06/defaul-route-linux-terminal.png +[11]: https://itsfoss.com/wp-content/uploads/2022/06/ping-gateway.png +[12]: https://itsfoss.com/stop-program-linux-terminal/ diff --git a/published/20220630 6 New Changes Coming to Nautilus File Manager in GNOME 43.md b/published/20220630 6 New Changes Coming to Nautilus File Manager in GNOME 43.md new file mode 100644 index 0000000000..99f5848a1e --- /dev/null +++ b/published/20220630 6 New Changes Coming to Nautilus File Manager in GNOME 43.md @@ -0,0 +1,109 @@ +[#]: subject: "6 New Changes Coming to Nautilus File Manager in GNOME 43" +[#]: via: "https://news.itsfoss.com/gnome-files-43/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14791-1.html" + +GNOME 43 中 Nautilus 文件管理器的 6 个新变化 +====== + +> GNOME 文件即将到来的变化改善了用户体验,让我们来看看其中的一些变化。 + +![gnome files][1] + +我们离 GNOME 43 的发布还有几个月的时间,但是 GNOME 应用程序的开发活动正在如火如荼地进行。 + +例如,[GNOME Web 43 alpha 版本支持了扩展][2]。 + +同样,GNOME 文件管理器(Nautilus)也有一些令人兴奋的变化,特别是对于列表视图。 + +列表视图使用 [GtkColumnView][3] 部件重新实现,丢弃了 GtkTreeView,以便能够添加新功能。 + +一些完善了代码的变化包括: + +### 1、拖动并选择文件 + +就像你在网格视图中通常所做的那样,你终于可以通过简单地拖动你的鼠标在列表视图中选择多个项目,来选择你想要的项目。 + +![gnome files][4] + +如果你没有注意到,每行之间也有一点间隔。虽然选择的动画还不是最流畅的,但它是一个正在进行的工作。 + +我试着用 peek 录制 GIF(在带有 Wayland 的 Fedora 上),但由于某些原因,它没有反应,可能与 alpha 版本有一些冲突。 + +### 2、鼠标悬停时高亮行 + +当你把鼠标悬停在上面的时候,没有行高亮是很不直观的。 + +现在,它做到了。只要把你的光标放在列表视图中的任何一个项目上,它就会被突出显示,如上图所示。 + +### 3、搜索一个文件时,列不会消失 + +![之前][5] + +![之后][6] + +当你用当前的 Nautilus 文件管理器搜索一个文件时,列的处理方式不是很好。你会失去某些细节信息,如文件大小。 + +在新的变化中,你仍然可以看到文件的大小、修改日期,以及给文件加星的能力。 + +通过这一改变,用户体验肯定会更好。 + +### 4、更好的紧凑视图 + +当你缩小文件管理器窗口的大小时,也处理的不是很好。你看不到文件扩展名的细节,而且列对变化没有反应。 + +![][7] + +在 GNOME 文件管理器 43 alpha 版本中,即使你缩小了窗口的大小以获得一个紧凑的视图,你仍然可以看到列,以及如上所示的文件扩展名。 + +### 5、新的文件上下文菜单 + +![][8] + +作为对 2022 年 GSoC(谷歌编程之夏)的贡献的一部分,一位开发者正专注于改善新文档功能的可发现性。 + +当你将某些文件添加到模板Templates目录中时,你可以在执行右键单击时在上下文菜单中找到这个 “新文档New Document” 选项。 + +在即将到来的更新中,这个选项将是开箱即用。即,更加易于使用。 + +另外,开发人员正在想办法改进添加模板的过程。你可以这篇在 [博文][9] 中更多了解他们的工作。 + +### 6、当你给一个文件加星时的动画 + +![][10] + +当你点击列表项右侧的星形图标时,你可以发现它在移动,让你知道你与该选项进行了互动。 + +### 总结 + +当然,我所提到的一切都处于开发阶段(alpha 版本)。在我们等待 beta 版本的时候,我们应该能清楚地了解到文件管理器的更多功能,以及事情是如何改进的。 + +你对 GNOME 43 有什么期待?请在下面的评论中告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/gnome-files-43/ + +作者:[Ankush Das][a] +选题:[lkxed][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/ankush/ +[b]: https://github.com/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/changes-in-nautilus-in-gnome-43.jpg +[2]: https://news.itsfoss.com/gnome-web-extensions-dev/ +[3]: https://gitlab.gnome.org/GNOME/nautilus/-/commit/6708861ed174e2b2423df0500df9987cdaf2adc0 +[4]: https://news.itsfoss.com/wp-content/uploads/2022/06/nautilus-drag-select-alpha.jpg +[5]: https://news.itsfoss.com/wp-content/uploads/2022/06/file-search-before.jpg +[6]: https://news.itsfoss.com/wp-content/uploads/2022/06/file-search-after.jpg +[7]: https://news.itsfoss.com/wp-content/uploads/2022/06/compact-view-files-1024x482.jpg +[8]: https://news.itsfoss.com/wp-content/uploads/2022/06/new-document-file-manager.jpg +[9]: https://ignapk.blogspot.com/2022/06/gsoc-2022-first-update-planning.html +[10]: https://news.itsfoss.com/wp-content/uploads/2022/06/animation0file.webm diff --git a/published/20220630 Hide Files and Folders in Linux Without Renaming Them.md b/published/20220630 Hide Files and Folders in Linux Without Renaming Them.md new file mode 100644 index 0000000000..496b2205d8 --- /dev/null +++ b/published/20220630 Hide Files and Folders in Linux Without Renaming Them.md @@ -0,0 +1,137 @@ +[#]: subject: "Hide Files and Folders in Linux Without Renaming Them" +[#]: via: "https://itsfoss.com/hide-files-folders-linux/" +[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" +[#]: collector: "lkxed" +[#]: translator: "hanszhao80" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14806-1.html" + +在 Linux 中隐藏文件和文件夹的那些事 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/08/142700yijbiw44bqfpfs4j.jpg) + +> 这篇面向初学者的文章探讨了在 Linux 中如何在普通视图中隐藏文件和文件夹。图形用户界面和命令行方法都有所涉猎。 + +有时你需要在 Linux 中隐藏文件。 + +不要误会,我不是指那些你不想让你的家人看到的“特殊文件”。尽管你可以隐藏这些特殊文件,但更好的办法还是用密码锁定它们以提供额外的保护。 + +回到隐藏文件的话题。**名称以 `.` 开头的任何文件或文件夹在 Linux 中是“隐藏的”。** + +Linux 有很多这样的文件和文件夹,在普通视图中它们是隐藏的。这些主要是系统和程序所需的配置文件。 + +用户通常不需要理会它们,因此它们在普通视图中是隐藏的,这样一来你就不会被许多看起来很奇怪的而不是你所创建的文件所淹没。 + +下图展示了我的主目录中隐藏的文件和文件夹。 + +![linux 普通视图][1] + +![linux 显示隐藏文件][2] + +如果你使用的是桌面版 Linux,你可以通过在文件管理器中按 `Ctrl+H` 快捷键来轻松 [查看隐藏文件][3]。在终端中,你可以使用 `ls -a` 命令显示隐藏文件和普通文件。 + +那么,如何在 Linux 中创建隐藏文件呢?你只需用一个在命名的时候加一个 `.` 前缀。就是这样。 + +### 在桌面版 Linux 里创建隐藏文件和文件夹(GUI 方法) + +如果你使用的是文件管理器,在文件或文件夹上右键并选择重命名选项。现在你所要做的就是在文件名的开头添加一个 `.`。 + +当你以这种方式创建隐藏文件时,GNOME 的 Nautilus 文件管理器也会显示一个警告。 + +![ubuntu linux 隐藏文件][4] + +你可以以相同的方式隐藏文件夹及其所有内容。 + +你可以按 `Ctrl+H` 键来显示隐藏文件。哦!我是多么的喜欢 [Ubuntu 中的键盘快捷键][5] 和我使用的任何其他程序或操作系统! + +要使隐藏文件变回普通文件,只需再次重命名这些文件删掉文件名前缀的 `.` 即可。 + +### 在 Linux 终端创建隐藏文件和文件夹(CLI 方法) + +如果你热衷于终端,你可以 [使用 mv 命令][6] 重命名文件。你只需在原始文件名的开头添加一个 `.`。 + +``` +mv filename .filename +``` + +你可以使用以下命令显示隐藏文件: + +``` +ls -la +``` + +你也可以使用 `ls -lA`。这条命令不会显示点文件(`.` 和 `..`)。 + +### 额外提示:用非重命名的方法隐藏文件和文件夹(仅适用于 GUI) + +你刚刚学了在 Linux 中隐藏文件。问题是你必须重命名文件,而这种操作不适用于所有的场合。 + +例如,在 Ubuntu 中,你会在目录中看到一个名为 `snap` 的文件夹。你不会使用它,但如果重命名它,你的 Snap 应用程序将无法按预期工作。类似的情况是,在 Ubuntu 22.04(安装有 Snap 版本的 Firefox)的 `Downloads` 目录下有一个 `firefox.tmp` 文件夹。 + +有一个巧妙的技巧可以在 Linux 桌面中使用。它应该可以在 Nemo、Thunar、Dolphin 等各种文件管理器下工作,但我不能保证。它确实适用于 GNOME 的 Nautilus 文件管理器。 + +因此,你在这里所做的是在你想要隐藏的文件或文件所在的目录中创建一个名为 `.hidden` 的新文件。 + +![在 Linux 中隐藏文件的另一种方法][7] + +按 `Ctrl+H` 显示隐藏文件并 **打开 `.hidden` 文件** 进行编辑。**在单独的行中添加文件或文件夹的名称**。注意不能使用绝对或相对路径。你想要隐藏的 **文件和文件夹应与此特殊 `.hidden` 文件** 位于同一路径下。 + +这是我以不重命名的方式隐藏 `cpufetch` 目录和 `pcloud` 文件的示例: + +``` +pcloud +cpufetch +``` + +按 `Ctrl+H` 以再次隐藏 `.hidden` 文件。 + +现在,**关闭你的文件资源管理器并重新启动它**。你将不会再看到 `.hidden` 文件中提到的文件和目录。 + +如果你想再次查看它们,请按 `Ctrl+H` 键。 + +如果你不想再隐藏文件,请从 `.hidden` 文件中删除其名称或完全删除 `.hidden` 文件。 + +### 额外琐事:隐藏文件“功能”实际上是一个 bug + +你知道吗?在文件名的开头添加一个 `.` 来隐藏文件的“功能” [实际上是一个 bug][8]? + +在早期的 UNIX 时代,当创建文件系统时,添加了 `.`(当前目录)和 `..`(父目录)文件以方便导航。 + +由于这些特殊的 `.` 和 `..` 文件中没有实际数据,因此给 `ls` 命令添加了一个新的“功能”:该功能是检查文件名的第一个字符,如果它是一个点(`.`),则不再使用 `ls` 命令显示它。 + +这对隐藏 `.` 和 `..` 文件有效,但它引入了一个 “bug”:`ls` 命令的输出会隐藏任何文件名以 `.` 开头的文件。 + +这个 bug 变成了一个功能,因为程序员喜欢它来“隐藏”他们的配置文件。`ls` 命令可能是后来修改添加了一个显示隐藏点文件的选项。 + +Linux 遵循相同的约定,因为 Linux 是以 UNIX 为原型开发的。 + +### 结论 + +我讨论了如何从普通视图中创建隐藏文件。如果要创建让其他人无法访问的机密文件或文件夹,则应对其进行加密。我曾经写过 [在 Linux 中使用密码锁定文件夹][9]。这是一篇有点儿旧的文章,但它可能仍然有效。 + +我希望你喜欢这个简单的话题并学到新的东西。发布你的评论让我知道你的想法吧。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/hide-files-folders-linux/ + +作者:[Abhishek Prakash][a] +选题:[lkxed][b] +译者:[hanszhao80](https://github.com/hanszhao80) +校对:[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/lkxed +[1]: https://itsfoss.com/wp-content/uploads/2022/06/linux-normal-view.png +[2]: https://itsfoss.com/wp-content/uploads/2022/06/linux-show-hiiden-files.png +[3]: https://itsfoss.com/hide-folders-and-show-hidden-files-in-ubuntu-beginner-trick/ +[4]: https://itsfoss.com/wp-content/uploads/2022/06/hide-files-ubuntu-linux.png +[5]: https://itsfoss.com/ubuntu-shortcuts/ +[6]: https://linuxhandbook.com/mv-command/ +[7]: https://itsfoss.com/wp-content/uploads/2022/06/alternate-way-of-hiding-files-in-linux.png +[8]: https://linux-audit.com/linux-history-how-dot-files-became-hidden-files/ +[9]: https://itsfoss.com/password-protect-folder-linux/ diff --git a/published/20220630 The Top Trends Changing The Data Center Industry.md b/published/20220630 The Top Trends Changing The Data Center Industry.md new file mode 100644 index 0000000000..8cc699c044 --- /dev/null +++ b/published/20220630 The Top Trends Changing The Data Center Industry.md @@ -0,0 +1,52 @@ +[#]: subject: "The Top Trends Changing The Data Center Industry" +[#]: via: "https://www.opensourceforu.com/2022/06/top-trends-changing-data-center-industry/" +[#]: author: "abhimanyu rathore https://www.opensourceforu.com/author/abhimanyu-rathore/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14805-1.html" + +改变数据中心行业的主要趋势 +====== + +![Data center][1] + +大流行加快了印度全国数字化转型的速度,这需要对数据中心进行更多投资。由于快速的数字化和云采用,印度数据中心市场的容量预计在未来几年将翻一番。据报道,2021 年印度数据中心市场规模为 43.5 亿美元,到 2027 年将达到 100.9 亿美元,2022-2027 年的复合年增长率为 15.07%。 + +现在,出现的一个关键问题是印度数据中心行业的未来是什么?哪些新趋势将塑造其未来?下面提到的是将对印度数据中心行业产生重大影响的主要趋势。 + +### 数据本地化 + +数据本地化就意味着限制数据从一个国家流向另一个国家。印度政府已发布指导方针,强调需要在该国境内存储印度用户的数据。数据本地化使得收集关键消费者数据的公司必须在本地数据中心存储和处理这些数据。这给本地数据中心带来了巨大的增长。此外,印度的成本优势和熟练劳动力的便利性使其成为亚洲数据中心的重要枢纽。 + +### 可持续数据中心 + +众所周知,数据中心消耗大量非可再生资源。为了使数据中心可持续发展,公司重新设计了他们的设施,通过利用人工智能、机器学习和云等新兴技术来大大降低电力和水的消耗。云数据中心使用更少的服务器,从而减少碳排放。它们通常位于更靠近为其供电的设施,以防止在长距离传输电能的过程中出现大量损失。此外,公共云数据中心可用于存储来自多个业务的数据。本地数据中心在存储大量数据时存在容量限制,从而导致资源的非最佳使用。因此,云数据中心通过使企业能够消耗更少的服务器和更少的电力并减少其在此过程中的碳排放,正在彻底改变行业。 + +### 边缘连接 + +边缘数据中心是靠近网络边缘的小型数据中心。它们通常连接到更大的中央数据中心或多个数据中心。通过处理更接近最终用户的数据和服务,边缘计算允许组织减少延迟并改善客户体验。这样的数据中心对于需要实时数据处理的行业非常有利,例如自动驾驶汽车、远程医疗、电信、OTT 平台和智能可穿戴设备。 + +### 超大规模数据中心 + +传统上,数据中心是一个简单的机架网络,带有存储单元和一组管理工具。它具有易于理解的架构。然而,随着数字化转型接管了企业界,组织开始生成大量数据。传统的存储单元和工具不足以处理大量涌入的数据,因此需要更大的容量和复杂的设施。此外,传统数据中心无法扩大或缩小其能力以适应需求波动,从而导致资源浪费。这导致了超大规模作为解决方案的演变。 + +超大规模数据中心是大规模的关键业务设施,旨在通过将大量高速协同工作的服务器聚集在一起,有效地支持强大且可扩展的应用。这种能力使数据中心能够水平和垂直扩展。 + +总之,数据中心行业正在发展,新趋势将不断涌现。借助新时代的颠覆性技术,数据中心行业可以构建环保节能的数据中心。人工智能、边缘计算和物联网等技术可用于最大限度地提高能源效率并最大限度地减少对环境的影响。 + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/06/top-trends-changing-data-center-industry/ + +作者:[abhimanyu rathore][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/abhimanyu-rathore/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2016/03/Data-center.jpg diff --git a/published/20220630 With Extensions, GNOME Web is Slowly Becoming an Attractive Option on Desktop Linux.md b/published/20220630 With Extensions, GNOME Web is Slowly Becoming an Attractive Option on Desktop Linux.md new file mode 100644 index 0000000000..202daca0ba --- /dev/null +++ b/published/20220630 With Extensions, GNOME Web is Slowly Becoming an Attractive Option on Desktop Linux.md @@ -0,0 +1,89 @@ +[#]: subject: "With Extensions, GNOME Web is Slowly Becoming an Attractive Option on Desktop Linux" +[#]: via: "https://news.itsfoss.com/gnome-web-extensions-dev/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14797-1.html" + +有了扩展,GNOME Web 正逐渐成为 Linux 桌面上一个有吸引力的选择 +====== + +> GNOME Web 正在打磨成一个完美的 Linux 浏览器。你认同吗? + +![Gnome Web 浏览器][1] + +GNOME Web(Epiphany)是 [可供 Linux 用户使用的最佳浏览器][2] 之一。 + +它提供了简约且独特的用户体验。 + +不幸的是,这种独特性并没有激励用户把它作为主力网页浏览器。 + +但是,看起来这种情况很快就会改变…… + +根据其中一位开发者(Patrick,网名 TingPing)透露,GNOME Web 终于添加了对 WebExtensions 的支持。 + +它将会是 GNOME 43 新功能的一部分。 + +### 带有 WebExtensions 的 GNOME Web + +![][3] + +一个浏览器,外观简约,还支持扩展,夫复何求啊! + +我不知道你怎么想,但我对于 GNOME Web 不支持扩展这件事,一直耿耿于怀。 + +所以,这个消息真的让我很兴奋! + +目前,这只是对 **Epiphany 43.alpha** 版本的实验性支持。因此,你只能使用 GNOME Web 的 beta/alpha 构建来测试它。 + +开发者提到: + +> Epiphany 43.alpha 支持上述的基本结构。我们目前正在根据 Firefox 的 ManifestV2 API 来建模行为,同时也尽可能与 Chrome 扩展程序保持兼容。未来,我们计划在保留 V2 的同时,支持 ManifestV3。 + +你必须在终端中显式启用扩展支持,然后下载、添加扩展的 **.xpi** 文件,以安装浏览器扩展。 + +你需要访问 [Mozilla 的 Firefox 附加组件门户网站][4] 来获得扩展程序。 + +![][5] + +你可以安装 Epiphany(GNOME Web)的最新开发版本,并使用以下命令启用扩展: + +``` +flatpak remote-add --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo +flatpak install gnome-nightly org.gnome.Epiphany.Devel +flatpak run --command=gsettings org.gnome.Epiphany.Devel set org.gnome.Epiphany.web:/org/gnome/epiphany/web/ enable-webextensions true +``` + +请注意,它仍在活跃开发中,可能无法按预期工作。在第一次尝试时,你可能需要密切关注终端是否有错误,如果有的话,要先解决它才行。 + +如果你想了解更多技术细节,你可以阅读 [TingPing 的博文][6]。 + +### 你的下一个主力浏览器? + +与 Linux 上的基于 Firefox 和 Chrome/Chromium 的浏览器相比,GNOME Web 是一个的完全独特的替代品。(LCTT 译注:GNOME Web 基于 WebKit 引擎。) + +那么,随着即将推出的扩展支持,你愿意尝试将 GNOME Web 作为你的主力浏览器吗? + +*你如何看待 GNOME Web(或 Epiphany)中的改进呢?请在下方评论区中告诉我们吧!* + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/gnome-web-extensions-dev/ + +作者:[Ankush Das][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/gnome-web-adds-extensions-support.jpg +[2]: https://itsfoss.com/best-browsers-ubuntu-linux/ +[3]: https://news.itsfoss.com/wp-content/uploads/2022/06/gnome-web-extensions.png +[4]: https://addons.mozilla.org/en-US/firefox/extensions/ +[5]: https://news.itsfoss.com/wp-content/uploads/2022/06/gnome-web-extensions-1.png +[6]: https://blog.tingping.se/2022/06/29/WebExtensions-Epiphany.html diff --git a/published/20220703 10 Necessary Ubuntu Apps For Everyone [Part 3].md b/published/20220703 10 Necessary Ubuntu Apps For Everyone [Part 3].md new file mode 100644 index 0000000000..bfe1119295 --- /dev/null +++ b/published/20220703 10 Necessary Ubuntu Apps For Everyone [Part 3].md @@ -0,0 +1,311 @@ +[#]: subject: "10 Necessary Ubuntu Apps For Everyone [Part 3]" +[#]: via: "https://www.debugpoint.com/necessary-ubuntu-apps-2022" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: "Donkey-Hao" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14841-1.html" + +10 大必备 Ubuntu 应用:必备篇 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/18/183730r55l353ni64aiiu4.jpg) + +> 本文列出了 2022 年可以用于日常工作的 10 个 Ubuntu 必备应用。 + +我们经常忘记,有成千上万的、可以与同类商业产品相媲美的自由开源应用。此外,若你是 Windows 用户,并考虑完全摆脱 Windows ,你也应该事先了解此类应用程序。 + +因此,在这篇“必备的 Ubuntu 应用”文章中,我们为急需这些信息的 Linux 用户列举了 10 款应用。 + +这是这个系列的第三篇文章,如果你错过了之前的文章,可以通过以下链接阅读: + +* [第一篇][1] +* [第二篇][2] + +### Guake + +你是否想要在处理重要工作时使用快捷键打开一个终端?这款下拉式的终端程序 Guake 能够帮你实现。如果你正忙于写文章、剪辑视频、在你最喜欢的代码编辑器中写代码,并想要快速用终端检查一些东西并返回到工作中,Guake 能够帮助你。只用按 `F12` 终端就会立即出现,再次按 `F12` 它会消失,不用打开或关闭不同的终端。 + +![Guake Running in Ubuntu][3] + +在 Ubuntu 或其他发行版,你可以使用以下命令安装。如需更多下载选项,请访问 [此页面][4]。 + +``` +sudo apt install guake +``` + +浏览以下链接了解 Guake 的更多信息: + +* [主页][5] +* [源码][6] + +### Safe Eyes + +眼睛很宝贵,如果你是长时间使用平板或电脑的用户,你应该保护好眼睛。这里有一款可以帮助你保护眼睛的应用 —— Safe Eyes ,能够帮你减少并预防用眼过度。 + +Safe Eyes 这款应用会在你的工作期间为你提供“顺时针转动眼睛 10 秒”等活动的弹出式指令。 + +我认为它是每个人都应该尝试使用的一款 Ubuntu 应用。 + +![Safe Eyes][7] + +通过 PPA 可以很容易在 Ubuntu 上安装 Safe Eyes 。你可以打开终端并使用以下命令安装这款应用。 + +``` +sudo add-apt-repository ppa:slgobinath/safeeyessudo apt updatesudo apt install safeeyes +``` + +更多下载选项,请访问 [此页面][8]。 + +浏览以下链接了解 Safe Eyes 的更多信息: + +* [主页][9] +* [源码][10] + +### Tusk + +笔记应用有很多。虽然,包括 Ubuntu 在内的所有 Linux 发行版,都带有一个基础文本编辑器,但是想要高级的笔记功能,你需要一个专业应用。 + +Tusk 是适用于 Ubuntu/Linux 的新款印象笔记式桌面应用程序。它带有大量主题,例如浅色、深褐色和深色。它具有以下功能: + +* 本地和全局自定义快捷键 +* 更新通知 +* 基于 Electron 的跨平台应用 +* 可伸缩的界面(放大和缩小) +* 浅色、深褐色和深色主题 +* 聚焦模式和自动夜间模式 +* 将笔记导出为 HTML、PDF 和 Markdown 格式 + +![Tusk][11] + +该应用有用于 Linux 发行版的 AppImage 、Deb 和 RPM 文件等格式。你可以从以下链接下载 deb 文件并运行它以在 Ubuntu 中安装它。有关其他下载选项,请访问 [此页面][12]。 + +> **[下载 Tusk][13]** + +浏览以下链接了解 Tusk 的更多信息: + +* [主页][14] +* [源码][15] + +### Krita + +如果你是一个艺术家并想在 Linux 上学习绘画,那你一定要用 Krita 。Krita 拥有众多绘画工具,包含诸如压感式绘画等高级模式。此外,你也可以在触屏设备上使 Krita 。它包含一些独特的功能: + +* 自定义工具栏和停靠栏 +* 将工作区另存为文件 +* 深浅主题 +* 内置矢量引擎,海量画笔 +* 带稳定功能的画笔引擎 +* 支持 PhotoShop 文件(PSD) +* 支持全色系 +* 支持 Python 脚本扩展 + +![Krita Drawing Program][16] + +在所有的 Linux 发行版的官方仓库都有 Krita ,所以很容易安装。在 Ubuntu 中,你可以在应用商店里搜索并安装。如果你更喜欢使用终端安装,可以运行如下指令: + +``` +sudo apt install krita +``` + +浏览以下链接了解 Krita 的更多信息: + +* [主页][17] +* [学习文件][18] +* [源码][19] + +### Foliate + +当你想到电子书阅读器时,总是会想到 Calibre 。不过还有一款杰出的 GNOME 应用 —— Foliate 。Foliate 是用 GTK 编写的新颖的电子书阅读器,它带来了令人赞叹的功能,例如自定义页面的颜色、亮度、多栏支持等等。此外,它还支持 Epub、Amazon Kindle、FictionBook、CBA 和 Mobipocket 格式,让你完全控制自己的收藏。 + +如果你想要一个漂亮而优美的电子书阅读器,非它莫属。 + +![Foliate][20] + +使用 Linux 发行版的 Flatpak 安装 Foliate 很容易。首先,你需要 [设置 Flatpak][21] 并单击下方链接进行安装。 + +> **[下载 Foliate][22]** + +浏览以下链接了解 Foliate 的更多信息: + +* [主页][23] +* [源码][24] + +### Bitwarden + +平均而言,每个人至少有十几个在线账号和密码。你越是精通技术,那么你管理密码的数量就会越多。使用密码管理器能够更好的保护你的数据以及密码。那么接下来这款应用,Bitwarden,是当今最好的管理密码的应用。 + +Bitwarden 是一款自由开源的密码管理器,能够轻松帮助你生成、存储并保存密码。在 AES-256 加密的支持下,Bitwarden 能够在不同设备,比如手机和平板自动同步密码。 + +![Bitwarden Password Manager desktop client][25] + +你可以从 [此页面][26] 下载可执行安装包文件。此外,如果你打算在你最喜欢的浏览器中使用它,也可以在该页面中获取扩展。 + +浏览以下链接了解 Bitwarden 更多信息: + +* [主页][27] +* [帮助文档][28] + +### Brave Browser + +Brave 是一款基于 Chromium 的以隐私为中心的浏览器。它非常适合希望完全控制其在线活动的用户。Brave 带有内置广告拦截器、隐身浏览、VPN 和 Tor 模式,可实现更多匿名浏览。 + +最近,Brave 还推出了电子邮件服务,你可以直接从浏览器访问邮件。此外,它具备一些 Firefox 、 Chrome 以及 Safari 所没有的优点。 + +![Brave Browser][29] + +在 Ubuntu 终端上安装这款浏览器需要额外的命令。你可以 [在此][30] 找到相信的下载教程。 + +更多详细信息,请浏览官方 [主页][31] 。 + +### Mailspring + +如果你在找一款好用并高效的 Linux 桌面电子邮件客户端,并且想要它支持所有的电子邮件协议,那你应该试试 Mailspring 。 + +Mailspring 支持多个账户、统一邮箱,并且支持触控和手势。它还支持微软 Office 365 ,这是此电子邮件客户端在 Linux 系统中的最大优势之一。此外,它具有快速检索、翻译、取消发送(邮件召回)以及内置的拼写检查等特征,使得它成为最好的邮件客户端之一。 + +它还有一个付费版本,只需要每月付出少量费用,即可得到更多功能,例如创建公司简介、链接跟踪、阅读回执、模板和洞察力功能。专业版中的洞察力功能提供了你在一天中何时收到更多电子邮件的详细信息。 + +![Mailspring Email Client][32] + +这款应用可以通过 Snap 和 Deb 文件在 Ubuntu 或其他相关 Linux 上安装。 + +访问官方 [Snapcraft 页面][33] 获取 Snap 包并安装。 + +点击 [这里][33a] 下载 deb 包。下载后,你可以双击 deb 文件通过 Ubuntu 应用商店程序安装。 + +浏览以下链接了解 Mailspring 更多信息: + +* [主页][34] +* [其他下载选项][35](Fedora Linux、Windows 以及 macOS) + +### Blender + +我肯定你听说过 Blender 。 Blender 是一款自由开源的专业级图形设计软件,几乎可以完成你的图形项目的一切需求。 + +![Blender Video Editor][36] + +你可以创建动画电影、视觉效果、艺术作品、3D 打印模型、动态图形、交互式 3D 应用程序和计算机游戏。 Blender 的功能包括 3D 建模、UV 展开、贴图、光栅图形编辑、套索和蒙皮、流体和烟雾模拟、粒子模拟、柔体模拟、雕刻、动画、匹配移动、渲染、运动图形、视频编辑和合成。 + +它是一个专业级的应用程序,还是自由开源的。 + +想要在 Ubuntu 中轻松安装,打开应用商店,搜索 Blender,然后点击安装。或者,你也可以打开终端窗口并运行以下命令进行安装。 + +``` +sudo apt install blender +``` + +该软件适用于 Windows、macOS 和其他平台。你可以访问 [官方下载页面][37] 了解更多详情。 + +浏览以下链接了解 Blender 更多信息: + +* [主页][38] +* [详细功能亮点][39] +* [文档][40] + +### Ungoogled Chromium + +如果你想要一个没有谷歌的应用和服务的干净浏览器,你应该试试 Ungoogled Chromium 浏览器。它是一个没有谷歌集成服务的,提供了原装 Chromium 体验的替代品。 + +例如,它去除了代码中的所有预编译二进制文件和所有谷歌集成,并且还禁用了需要手动启用的功能,以获得更好控制。 + +或许一个合适的浏览器,才会有最好的 Chromium 体验。 + +![Ungoogled-Chromium][41] + +使用 Flatpak 安装 Ungoogled Chromium 很容易。首先设置 [Flatpak][42] 然后使用下列命令安装该浏览器: + +``` +flatpak install flathub com.github.Eloston.UngoogledChromium +``` + +浏览 [官方 GitHub 页面][43] 获取该浏览器更多信息。 + +### Tilix + +![Tilix Terminal Window][44] + +必备 Ubuntu 应用程序列表中的最后一个应用程序是 Tilix 。Tilix 是一个基于 GTK 的,平铺式的终端仿真器。它带有自定义标题、以及通知支持(用于命令补完)和透明背景图像支持。此外,Tilix 还允许你在终端窗口中添加自定义图像背景。最后,你可以在一个窗口中并排创建多个终端窗口。 + +这是一个用 GTK 编写的高级终端,你可能会发现它很有用。 + +所有 Linux 发行版上都有它的安装包。在 Ubuntu 或相关发行版,运行以下命令进行安装: + +``` +sudo apt install tilix +``` + +更多信息请浏览 Tilix [主页][45] 。 + +### 结语 + +这是 2022 年 5 篇系列的必备 Ubuntu 应用程序的第 3 篇。我希望你能够在 Ubuntu 或者其他 Linux 发行版上安装,并在你的日常工作中使用这些应用程序。同时,欢迎在下方评论,让我知道你最喜欢哪一款应用。 + +最后,请继续关注本 Ubuntu 应用程序系列的第 4 部分。 + +干杯! + +*一些图片来源:令人尊敬的应用开发人员或团队* + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/necessary-ubuntu-apps-2022 + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[Donkey](https://github.com/Donkey-Hao) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://www.debugpoint.com/essential-ubuntu-apps-2022-part-1/ +[2]: https://www.debugpoint.com/best-ubuntu-apps-2022-part2/ +[3]: https://www.debugpoint.com/wp-content/uploads/2018/09/Guake-Running-in-Ubuntu.gif +[4]: https://guake.readthedocs.io/en/latest/user/installing.html#system-wide-installation +[5]: http://guake-project.org/ +[6]: https://github.com/Guake/guake +[7]: https://www.debugpoint.com/wp-content/uploads/2018/09/Safe-Eyes.gif +[8]: https://slgobinath.github.io/SafeEyes/ +[9]: https://slgobinath.github.io/SafeEyes/ +[10]: https://github.com/slgobinath/SafeEyes +[11]: https://www.debugpoint.com/wp-content/uploads/2018/09/Tusk.gif +[12]: https://github.com/klaussinani/tusk/releases/ +[13]: https://github.com/klaussinani/tusk/releases/download/v0.23.0/tusk_0.23.0_amd64.deb +[14]: https://klaussinani.github.io/tusk/ +[15]: https://github.com/klaussinani/tusk +[16]: https://www.debugpoint.com/wp-content/uploads/2022/07/Krita-Drawing-Program.jpg +[17]: https://krita.org/en/ +[18]: https://docs.krita.org/en/ +[19]: https://invent.kde.org/graphics/krita +[20]: https://www.debugpoint.com/wp-content/uploads/2022/07/Foliate.jpg +[21]: https://www.debugpoint.com/how-to-install-flatpak-apps-ubuntu-linux/ +[22]: https://dl.flathub.org/repo/appstream/com.github.johnfactotum.Foliate.flatpakref +[23]: https://johnfactotum.github.io/foliate/ +[24]: https://github.com/johnfactotum/foliate +[25]: https://www.debugpoint.com/wp-content/uploads/2022/07/Bitwarden-Password-Manager-desktop-client.jpg +[26]: https://bitwarden.com/download/ +[27]: https://bitwarden.com/help/ +[28]: https://bitwarden.com/help/ +[29]: https://www.debugpoint.com/wp-content/uploads/2022/07/Brave-Browser.jpg +[30]: https://brave.com/linux/#release-channel-installation +[31]: https://brave.com +[32]: https://www.debugpoint.com/wp-content/uploads/2022/07/Mailspring-Email-Client.jpg +[33]: https://snapcraft.io/mailspring +[33a]: https://updates.getmailspring.com/download?platform=linuxDeb +[34]: https://getmailspring.com/ +[35]: https://getmailspring.com/download +[36]: https://www.debugpoint.com/wp-content/uploads/2019/09/Blender-Video-Editor.jpg +[37]: https://www.blender.org/download/ +[38]: https://www.blender.org/ +[39]: https://www.blender.org/features/ +[40]: https://www.blender.org/get-involved/documenters/ +[41]: https://www.debugpoint.com/wp-content/uploads/2022/07/Ungoogled-Chromium.jpg +[42]: https://www.debugpoint.com/how-to-install-flatpak-apps-ubuntu-linux/ +[43]: https://github.com/ungoogled-software/ungoogled-chromium#feature-overview +[44]: https://www.debugpoint.com/wp-content/uploads/2022/07/Tilix-Terminal-Window.jpg +[45]: https://gnunn1.github.io/tilix-web/ +[46]: https://www.debugpoint.com/essential-ubuntu-apps-2022-part-1/ +[47]: https://www.debugpoint.com/best-ubuntu-apps-2022-part2/ diff --git a/published/20220704 Darktable 4.0.0 is Here with a Revamped UI and Improved Color Saturation.md b/published/20220704 Darktable 4.0.0 is Here with a Revamped UI and Improved Color Saturation.md new file mode 100644 index 0000000000..89eb32ac89 --- /dev/null +++ b/published/20220704 Darktable 4.0.0 is Here with a Revamped UI and Improved Color Saturation.md @@ -0,0 +1,97 @@ +[#]: subject: "Darktable 4.0.0 is Here with a Revamped UI and Improved Color Saturation" +[#]: via: "https://news.itsfoss.com/darktable-4-0-release" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14802-1.html" + +darktable 4.0.0:用户界面改版,改进了色彩饱和度处理 +====== + +> darktable 4.0.0 版本来了,这是一个主要版本,带来了新的功能,简化了用户界面,还有一些其他的改进。 + +![darktable][1] + +最近,作为其 3.8.x 系列的升级版,darktable 开发人员公布了新的稳定版。 + +最新的升级带来了新功能、错误修复和重大变化。 + +### darktable 4.0 有什么新内容? + +在 darktable 4.0 中,增加了很多功能,并对用户界面进行了一些有意义的重新打造。 + +让我在此介绍一下关键的亮点: + +> **注意:** 这是一次重大版本升级,采用了新的库和配置,与旧版本不兼容。因此,你需要在进行升级之前对你的工作进行备份。 + +#### 颜色和曝光映射 + +在曝光和颜色校准模块中,你现在可以定义和保存颜色采集器的目标颜色/曝光度。 + +这应该有助于你匹配图像中的源对象,并确保一个对象在一批照片中的颜色一致性。 + +#### 完善的用户界面 + +![darktable][2] + +用户界面已经进行了改造以改善外观/感觉。首先能看到的是其默认主题改为了 “优雅灰”。 + +总的来说,填充、边距、颜色、对齐方式和图标等等都得到了改造。也添加了新的可折叠的部分(rgb 通道混合器、曝光、颜色校准),使用户界面更干净,更容易访问。 + +你会发现许多细微的变化,布局也更合理。 + +#### 性能变化 + +在简化用户偏好的同时,该版本还增加了一些优化措施。 + +你还可以改变性能配置,而不需要重启 darktable。 + +#### 改进了色彩饱和度处理 + +![darktable][3] + +Filmic v6(一种新的色彩学)的加入有助于获得更多的饱和度,特别是对于蓝天。 + +另外正如公告中提到的,可以以最小的破坏性方式恢复,调色应该更安全。除此之外,还为艺术饱和度的变化设计了一个新的信息色彩空间。 + +总的来说,你应该对这个版本对饱和度控制的改进感到高兴。 + +#### 其他变化 + +其他一些值得注意的变化包括: + +* 一个新的“引导式拉普拉斯”方法已被添加到高光重建模块中。 +* 全局颜色选择器工具的改进 +* 一个新的对比度参数 +* 一个新的集合过滤器模块 +* 增加了对 EXR 16 位(半数)浮点数输出的支持。 + +你可以在其 [官方公告帖子][4] 中查看所有的技术细节。 + +### 下载 darktable 4.0.0 + +你可以使用 [Flathub][5] 上的 Flatpak 包获得最新版本。写这篇文章时,Snap 包还没有更新。 + +此外,你也可以选择使用其 [GitHub 发布区][6] 中的 tar.xz 文件。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/darktable-4-0-release + +作者:[Ankush Das][a] +选题:[lkxed][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/ankush/ +[b]: https://github.com/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/07/darktable-4-0-0-1200x675.jpg +[2]: https://news.itsfoss.com/wp-content/uploads/2022/07/darktable-4.jpg +[3]: https://news.itsfoss.com/wp-content/uploads/2022/07/darktable-4-1.jpg +[4]: https://www.darktable.org/2022/07/darktable-4.0.0-released/ +[5]: https://flathub.org/apps/details/org.darktable.Darktable +[6]: https://github.com/darktable-org/darktable/releases/tag/release-4.0.0 diff --git a/published/20220704 Docker Commands Tutorial - Getting Started With Docker In Linux.md b/published/20220704 Docker Commands Tutorial - Getting Started With Docker In Linux.md new file mode 100644 index 0000000000..189134dae8 --- /dev/null +++ b/published/20220704 Docker Commands Tutorial - Getting Started With Docker In Linux.md @@ -0,0 +1,751 @@ +[#]: subject: "Docker Commands Tutorial | Getting Started With Docker In Linux" +[#]: via: "https://ostechnix.com/getting-started-with-docker/" +[#]: author: "sk https://ostechnix.com/author/sk/" +[#]: collector: "lkxed" +[#]: translator: "Yufei-Yan" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14849-1.html" + +Linux 下的 Docker 入门教程 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/21/101143uuwylyrrglzjfwj7.jpg) + +> 面向初学者的 Docker 基本命令指南。 + +这篇详细的 Docker 教程覆盖了核心的 **Docker 命令**,比如,如何创建新容器、运行容器、删除容器等。另外,这篇教程也解释了如何从已有的容器构建你自己的 Docker 镜像,如何移除容器和镜像。言归正传,现在开始 Docker 的基本用法。 + +### Docker 安装步骤 + +大多数现代 Linux 操作系统都可以安装 Docker。如果还没安装过 Docker,请参考下面的步骤: + +* [在 AlmaLinux、CentOS、Rocky Linux 上安装 Docker Engine 和 Docker Compose][1] +* [如何在 Ubuntu 上安装 Docker 和 Docker Compose][2] + +### 什么是 Docker 镜像和 Docker 容器? + +在开始 Docker 之前,我先说明一下 Docker 镜像和 Docker 容器是什么。 + +Docker 镜像是一个描述容器如何运行的的文件,Docker 容器是 Docker 镜像在运行或被终止时的一个阶段。 + +容器和主机上的其他文件是隔离的。 + +当我们运行一个 Docker 容器的时候,它会使用一个被隔离出来的文件系统,这个文件系统是由一个 Docker 镜像提供的。Docker 镜像包含了运行应用程序所需要的一切东西 - 所有的依赖、配置、脚本、二进制文件等等。 + +镜像也包含容器所需要的其他配置项,比如说环境变量、默认运行的命令,以及其他元数据。 + +### Linux 下的 Docker 入门 + +下面的所有步骤都已在 Ubuntu 22.04、20.04 以及 18.04 LTS 服务器版本中测试通过。后续小节中提供的步骤对于所有 Linux 平台都是通用的。比如,在基于 RHEL 的系统中(比如 AlmaLinux)可以运行相同的命令。 + +#### 1、搜索 Docker 镜像 + +我们可以从叫做 [Docker hub][3] 的 Docker 官方库获得镜像,或者我们也可以制作自己的镜像。 + +有些人可能不清楚,Docker hub 是一个线上的中心化仓库,Docker 用户们在上面构建、测试、然后保存他们的 Docker 镜像。Docker hub 有数以万计的 Docker 镜像,而且这个数字还在每天增长。 + +你可以从命令行通过 ``docker search` 命令搜索任意 Docker 镜像。 + +比如要搜索基于 **Alpine** Linux 的 Docker 镜像,运行: + +``` +$ sudo docker search alpine +``` + +输出结果: + +![Search Docker Images][4] + +搜索基于 **Ubuntu** 的镜像,运行: + +``` +$ sudo docker search ubuntu +``` + +你还可以搜索其他任意的应用,比如 **Nginx**,像下面这样: + +``` +$ sudo docker search nginx +``` + +Docker hub 有各种各样的镜像。你能在 Docker hub 上找到各种已构建好的 Docker 镜像,比如说操作系统、应用,或者多个应用的合体(比如 LAMP 栈)。 + +如果你找的东西不在上面,你还可以构建一个镜像,然后通过 Docker hub 向其他人开放,或者只是自己用。 + +#### 2、下载 Docker 镜像 + +从终端运行下面的命令可以下载 Ubuntu OS 的 Docker 镜像: + +``` +$ sudo docker pull ubuntu +``` + +上面的这个命令会从 Docker hub 下载最新的 Ubuntu 镜像。 + +输出结果: + +``` +Using default tag: latest +latest: Pulling from library/ubuntu +405f018f9d1d: Pull complete +Digest: sha256:b6b83d3c331794420340093eb706a6f152d9c1fa51b262d9bf34594887c2c7ac +Status: Downloaded newer image for ubuntu:latest +docker.io/library/ubuntu:latest +``` + +你也可以用下面的命令下载指定版本的 Ubuntu 镜像: + +``` +$ sudo docker pull ubuntu:20.04 +``` + +Docker 允许我们下载任何镜像,并且在那个镜像上创建容器,这些操作与主机的操作系统无关。 + +比如要下载 Alpine 系统的镜像,运行: + +``` +$ sudo docker pull alpine +``` + +![Download Docker Images][5] + +#### 3、列出 Docker 镜像 + +所有已下载的 Docker 镜像都保存在 `/var/lib/docker` 路径下。 + +要查看所有已下载的 Docker 镜像,运行: + +``` +$ sudo docker images +``` + +输出结果: + +``` +REPOSITORY TAG IMAGE ID CREATED SIZE +ubuntu latest 27941809078c 3 weeks ago 77.8MB +ubuntu 20.04 20fffa419e3a 3 weeks ago 72.8MB +alpine latest e66264b98777 5 weeks ago 5.52MB +``` + +![List Docker Images][6] + +从上面可以看出来,我已经下载了三个 Docker 镜像 - Ubuntu latest、Ubuntu 20.04 和 Alpine Linux。 + +现在,我们看一下接下来如何从下载的镜像启动或者运行容器。 + +#### 4、运行 Docker 容器 + +有两种方法我们可以启动一个容器 - 使用 Docker 镜像的标签TAG 或者 镜像 IDImage ID。 + +标签指的是一个特定的镜像快照,镜像 IDImage ID 是那个镜像对应的唯一识别码。 + +可以查看下面这个截图: + +![Docker Image Tag and ID][7] + +从上面的解脱可以看到,标签是 `latest` 和 `20.04`。 + +* `27941809078c` 是 Ubuntu latest 的 Docker 镜像的镜像 ID, +* `20fffa419e3a` 是 Ubuntu 20.04 的 Docker 镜像的镜像 ID, +* 而 `e66264b98777` 是 Alpine latest 的 Docker 镜像的镜像 ID。 + +##### 4.1、使用标签运行容器 + +下载选择好的 Docker 镜像后,运行下面的命令来启动 Docker 容器,并且通过它的标签进行连接。 + +``` +$ sudo docker run -t -i ubuntu:latest /bin/bash +``` + +或者, + +``` +$ sudo docker run -it ubuntu:latest /bin/bash +``` + +这里, + +* `-t`:在 Ubuntu 容器内分配一个伪终端。 +* `-i`:通过从容器获取一个标准输入(STDIN),允许我们创建一个可交互的连接。 +* `ubuntu:latest`:标签为 `latest` 的 Ubuntu Docker 镜像。 +* `/bin/bash`:新容器的 BASH shell。这个是可选项。如果你不加 shell 的话,会分配默认的 shell 给容器。 + +启动容器后,会自动进入容器的 shell(命令行): + +![Run Containers Using Tag][8] + +基于最新 Ubuntu 镜像的容器现在已经启动了。所有的新容器都会被赋予一个名字和唯一的 ID。从上面的输出可以看到,那个 Ubuntu 容器的 ID 是 `2f2a5b826762`。一会儿我们会看到从哪找到容器的名字。 + +现在就可以在容器里面工作了。当你完成容器内的工作后,你可以回到主机操作系统的终端(在我这个例子中,操作系统是 Ubuntu 22.04 LTS)而不需要关掉容器(客户机)。 + +##### 4.2、从运行中的容器中脱离 + +使用 `CTRL+P` 然后 `CTRL+Q` 就可以从运行中的容器脱离(不需要关闭)。 + +现在,你就回到了你原来的主机的终端窗口。请注意,容器还在后台运行中,我们并没有关掉它。 + +##### 4.3、使用镜像 ID 运行容器 + +另一种启动容器并且连接进去的方式是通过使用镜像 ID,像下面这样: + +``` +$ sudo docker run -it 20fffa419e3a /bin/bash +``` + +这里, + +* `20fffa419e3a` - 镜像 ID + +按 `CTRL+P` 然后 `CTRL+Q` 可以从当前容器中脱离回到主机系统的终端。我们只是从容器中脱离,但是没有让它停止。容器仍然在后台运行中。 + +##### 4.4. 在脱离模式中运行容器 + +在前面的小结中,我们启动了一个容器并且立刻连接了进去。然后当容器中的工作结束后,我们从容器中脱离了出来。 + +你也可以在脱离模式(不需要自动连接进去)中启动容器。 + +在后台运行一个容器,输入命令: + +``` +$ sudo docker run -it -d alpine:latest +``` + +输出结果: + +``` +d74f2ceb5f3ad2dbddb0b26e372adb14efff91e75e7763418dbd12d1d227129d +``` + +上面输出结果的前 12 字符代表的是容器的 ID。 + +通过 `docker ps` 命令,你可以验证容器是否在运行: + +``` +$ sudo docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +d74f2ceb5f3a alpine:latest "/bin/sh" 3 seconds ago Up 2 seconds zen_pascal +``` + +![Run Containers In Background][9] + +从上面个的输出结果中可以看到,我们创建了一个 Alpine 容器,但是还没有连接进去。 + +如果你想连接进去,很简单,运行: + +``` +$ sudo docker attach d74f2ceb5f3a +``` + +#### 5、查看运行中的容器 + +查看运行中的容器,运行下面的命令: + +``` +$ sudo docker ps +``` + +输出结果: + +``` +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +f7e04eed577e 20fffa419e3a "/bin/bash" 6 minutes ago Up 6 minutes brave_mclean +2f2a5b826762 ubuntu:latest "/bin/bash" 18 minutes ago Up 18 minutes hungry_leavitt +``` + +![View Running Containers][10] + +这里, + +* `f7e04eed577e` 是由镜像 `2f2a5b826762` 创建的 Ubuntu 容器的 ID。并且,`brave_mclean` 是这个容器的名字。 +* `2f2a5b826762` 是由镜像 “ubuntu:latest” 创建的 Ubuntu 容器的 ID。并且,`hungry_leavitt` 是这个容器的名字。 + +当一个新容器被创建后,会赋给它一个唯一的 ID 和名字,这样我们就能通过它的 ID 和名字来连接它。 + +**注意:请注意容器 ID 和 Docker 镜像 ID 是不同的**。 + +列出所有可用的(运行或者停止)容器,运行: + +``` +$ sudo docker ps -a +``` + +#### 6、从运行中的容器脱离或连接 + +首先,通过 `docker ps` 命令找到容器的 ID。 + +``` +$ sudo docker ps +``` + +然后,运行 `docker attach` 命令连接到运行中的容器。 + +``` +$ sudo docker attach +``` + +比如像下面这样,我要连接到 ID 为 `f7e04eed577e` 的容器: + +``` +$ sudo docker attach f7e04eed577e +``` + +你也可以通过使用它的名字连接到一个容器。 + +``` +$ sudo docker attach brave_mclean +``` + +现在你就登录到这个容器了。 + +想要从容器脱离,只要按 `CTRL+P` 然后 `CTRL+Q`。 + +#### 7、启动、重启、暂停和终止容器 + +你可以使用容器的名字或 ID 来启动,重启,暂停或者终止一个 Docker 容器。 + +首先,通过 `docker ps -a` 命令找到容器的名字或 ID。 + +![Find Container ID And Name][11] + +现在,通过使用 `docker start` 命令,加上名字或 ID,你可以启动一个容器,像下面这样: + +``` +$ sudo docker start modest_cray +``` + +``` +$ sudo docker start 10615254bb45 +``` + +用空格隔开,就可以**启动多个容器**,像下面这样: + +``` +$ sudo docker start 24b5ee8c3d3a 56faac6d20ad d74f2ceb5f3a +``` + +优雅的重启一个运行中的容器,运行: + +``` +$ sudo docker start 10615254bb45 +``` + +暂停一个运行中的容器: + +``` +$ sudo docker pause 10615254bb45 +``` + +把暂停的容器恢复过来: + +``` +$ sudo docker unpause 10615254bb45 +``` + +直到其它容器都停止前,阻塞一个容器: + +``` +$ sudo docker wait 10615254bb45 +``` + +我们可以很容易地通过使用它的名字或 ID 来终止一个容器。如果你已经在容器的 shell 里了,只需要运行下面的命令就可以非常简单的终止: + +``` +# exit +``` + +你也可以使用下面的命令从 Docker 的主机系统中终止(关闭容器)容器: + +``` +$ sudo docker stop 10615254bb45 +``` + +用空格隔开,你可以退出多个容器,像下面这样。 + +``` +$ sudo docker stop 35b5ee8c3d3a 10615254bb45 +``` + +在退出容器之后,通过列出所有容器的命令来确保它确实被终止了: + +``` +$ sudo docker ps +``` + +#### 8、强行关闭 Docker 容器 + +`docker stop` 命令可以非常优雅的关掉运行中的容器。有时候,你可能卡在一个没有响应的容器,或者你想强制关掉容器。 + +通过给一个运行中的容器发送 `SIGKILL` 来强行关闭容器,运行: + +``` +$ sudo docker kill 10615254bb45 +``` + +#### 9、在关闭容器后自动删除他们 + +也许你想测试一个容器,然后当你完成在容器中的工作就把它删掉。如果是这样,通过使用 `--rm` 标签在关闭后自动删掉容器: + +``` +$ sudo docker run -it --rm debian:latest +``` + +当你从容器中退出,它会自动被删掉。 + +![Automatically Delete Containers][12] + +从上面的结果可以看到,我先创建了一个新的 Debian 容器。当我退出这个容器的时候,它就被自动删掉了。`docker ps -a` 命令的输出结果显示,Debian 容器现在不存在。 + +#### 10、给容器命名 + +如果你再看一下之前命令的输出结果,当你启动一个容器的时候,每个容器都被赋予了一个随机的名字。如果你不命名你的容器,Docker 会自动替你给他们命名。 + +现在看一下下面的例子: + +``` +$ sudo docker run -it -d alpine:latest +2af79e97a825c91bf374b4862b9e7c22fc22acd1598005e8bea3439805ec335d +``` + +``` +$ sudo docker run -it -d alpine:latest +80b53b7e661d33696b65c78267fc3f067b6100799c925910db4721963e3fae0a +``` + +``` +$ sudo docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +80b53b7e661d alpine:latest "/bin/sh" 3 seconds ago Up 2 seconds bold_margulis +2af79e97a825 alpine:latest "/bin/sh" 6 seconds ago Up 5 seconds recursing_taussig +``` + +从上面的结果可以看到,尽管我用同一个 Docker 镜像创建了两个容器,它们获得了不同的 ID 和名字。 + +如果你想给容器赋一个不变的名字,使用 `--name` 标签,像下面这样: + +``` +$ sudo docker run -it -d --name ostechnix_alpine alpine:latest +``` + +上面的命令会在脱离模式中创建一个叫做 `ostechnix_alpine` 的新容器。 + +我们看一下当前运行的容器列表: + +``` +$ sudo docker ps +``` +输出结果: + +``` +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +397111fac537 alpine:latest "/bin/sh" 2 seconds ago Up 2 seconds ostechnix_alpine +80b53b7e661d alpine:latest "/bin/sh" 7 minutes ago Up 7 minutes bold_margulis +2af79e97a825 alpine:latest "/bin/sh" 7 minutes ago Up 7 minutes recursing_taussig +``` + +![Assign Name To Containers][13] + +注意到上面输出结果中的第一个容器的名字了吗?对了,我们给这个容器分配了一个自定义的名字(也就是 `ostechnix_alpine`)。 + +给容器分配自定义的名字可以给我们带来其他好处。只要看一下容器的名字,我们就能很容易的确定那个容器里面安装了什么。 + +#### 11、构建自定义 Docker 镜像 + +Docker 不仅仅是下载和使用已存在的容器。你也可以创建自己的自定义 Docker 镜像。 + +现在我们开始一个 Ubuntu 容器: + +``` +$ sudo docker run -it ubuntu:latest +``` + +现在,你会进入到容器的 shell。 + +然后,在容器中,你可以安装任何的软件或者做你想做的事情。 + +比如,我们在容器中安装 Apache Web 服务器。 + +``` +# apt update +# apt install apache2 +``` + +相似地,在容器中,可以根据自己的需要安装和测试软件。 + +完成以后,从容器脱离(不要退出)回到主机系统的 shell。不要终止或者关闭容器。使用 `CTRL+P` 然后 `CTRL+Q` 从容器中脱离,这样不会关闭容器。 + +在你的 Docker 主机的终端,运行下面的命令来找到容器 ID: + +``` +$ sudo docker ps +``` + +最后,创建一个当前运行中的容器的 Docker 镜像,使用命令: + +``` +$ sudo docker commit 377e6d77ebb5 ostechnix/ubuntu_apache +``` + +输出结果: + +``` +sha256:bc5e5f95ca592a3585fda2c5a40ec30c98e292046ef70390a2c3b7863cc6f7c1 +``` + +这里, + +* `377e6d77ebb5` – Ubuntu 容器的 ID。 +* `ostechnix` – 创建容器的用户的名字。 +* `ubuntu_apache` – 用户 `ostechnix` 创建的 Docker 镜像的名字。 + +现在我们查看一下新的 Docker 镜像是否被创建了,使用下面的命令: + +``` +$ sudo docker images +``` + +输出结果: + +``` +ostechnix/ubuntu_apache +``` + +![Build Custom Docker Images][14] + +从上面给的结果中可以看到,从运行中的容器创建的新 Docker 镜像已经在我们的 Docker 主机系统中了。 + +现在你就可以从这个新的 Docker 镜像创建行容器了,用之前的命令: + +``` +$ sudo docker run -it ostechnix/ubuntu_apache +``` + +#### 12、移除容器 + +当你在 Docker 容器中完成所有开发后,如果你不需要它们了,你可以删掉它们。 + +为此,首先我们需要终止(关闭)运行中的容器。 + +用这个命令来看一下运行中的容器: + +``` +$ sudo docker ps +``` + +输出结果: + +``` +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +377e6d77ebb5 ubuntu:latest "bash" 7 minutes ago Up 7 minutes elegant_beaver +``` + +通过使用它的 ID 来终止运行中的容器: + +``` +$ sudo docker stop 377e6d77ebb5 +``` + +现在,使用这个命令删除容器: + +``` +$ sudo docker rm 377e6d77ebb5 +``` + +同样,如果不再需要所有的容器,关闭并删除它们。 + +一个一个的删除多个容器会是一项繁琐的工作。所以,我们可以把所有停止的容器一次性删掉,运行: + +``` +$ sudo docker container prune +``` + +敲 `Y` 然后回车键,这些容器就被删掉了。 + +``` +WARNING! This will remove all stopped containers. +Are you sure you want to continue? [y/N] y +Deleted Containers: +397111fac5374921b974721ee646b2d5fbae61ca9c6e8b90fbf47952f382a46b +80b53b7e661d33696b65c78267fc3f067b6100799c925910db4721963e3fae0a +[...] +Total reclaimed space: 176B +``` + +![Delete Containers][15] + +这个命令只有在最新版中有效。 + +使用下面的命令来验证是否所有容器都被删除了: + +``` +$ sudo docker ps -a +``` + +如果看不到任何结果,说明所有容器被删掉了。 + +#### 13、删除 Docker 镜像 + +记住,在删除所有镜像之前,首先要删掉所有从那些镜像创建的容器。 + +当你删掉容器后,你可以删掉你不需要的 Docker 镜像。 + +列出所有下载的 Docker 镜像: + +``` +$ sudo docker images +``` + +输出结果: + +``` +REPOSITORY TAG IMAGE ID CREATED SIZE +ostechnix/ubuntu_apache latest bc5e5f95ca59 14 minutes ago 229MB +debian latest d2780094a226 11 days ago 124MB +ubuntu latest 27941809078c 3 weeks ago 77.8MB +ubuntu 20.04 20fffa419e3a 3 weeks ago 72.8MB +alpine latest e66264b98777 5 weeks ago 5.52MB +``` + +从上面可以看到,在我们的主机上有 5 个 Docker 镜像。 + +通过使用镜像 ID 来删掉它们: + +``` +$ sudo docker rmi ce5aa74a48f1 +``` + +输出结果: + +``` +Untagged: ostechnix/ubuntu_apache:latest +Deleted: sha256:bc5e5f95ca592a3585fda2c5a40ec30c98e292046ef70390a2c3b7863cc6f7c1 +Deleted: sha256:a8e4797160a2b2d33d8bd1bd67e008260c022b3a53fbcc198b2b74d9eae5961d +``` + +同样,删除其他所有 Docker 镜像。 + +删掉所有未运行的容器、所有镜像、构建的缓存、所有网络,运行: + +``` +$ sudo docker system prune -a +``` + +使用这个命令的时候要注意,它会删掉所有没有使用的容器、网络、镜像(包括 挂起dangling未使用unreferenced 的) + +![Delete Everything In Docker][16] + +默认情况下,即使当前没有容器在使用磁盘卷volumes,为防止重要数据被删除,磁盘卷也不会被删除。 + +如果你想删掉所有东西,包括分配的卷,使用 `--volumes` 标签。 + +``` +$ sudo docker system prune -a --volumes +``` + +### Docker 问题汇总 + +如果 Docker 镜像正在被运行或停止的容器使用,Docker 不会允许你删除这些镜像。 + +比如,当我尝试从一个以前的 Ubuntu 服务器上删除 ID 为 `b72889fa879c` 的 Docker 镜像。我会得到下面的错误: + +``` +Error response from daemon: conflict: unable to delete b72889fa879c (must be forced) - image is being used by stopped container dde4dd285377 +``` + +这是因为你想删除的 Docker 镜像正在被另一个容器使用。 + +所以,我们先查看一下运行中的容器,使用命令: + +``` +$ sudo docker ps +``` + +输出结果: + +![Show running docker containers][17] + +噢,没有运行中的容器。 + +我们在看一下所有的容器(运行和停止的),用这个命令: + +``` +$ sudo docker ps -a +``` + +输出结果: + +![Show running and stopped docker containers][18] + +可以看到,仍然有停止的容器在使用其中一个 Docker 镜像。所以,我们先把所有容器删掉。 + +比如: + +``` +$ sudo docker rm 12e892156219 +``` + +类似地,向上面那样,用对应容器的 ID 将它们都删除。 + +当把所有容器删掉后,移除掉 Docker 镜像。 + +比如: + +``` +$ sudo docker rmi b72889fa879c +``` + +就这么简单。现在确认是否还有其他 Docker 镜像在主机上,使用命令: + +``` +$ sudo docker images +``` + +你现在应该不再有任何 docker 镜像了。 + +### 总结 + +在这篇全面的 Docker 入门教程中,我们解释了 Docker 的基本操作,比如创建、运行、搜索、删除容器,还有从 Docker 镜像构建你自己的容器。同时,我们也解释了如何在不需要 Docker 容器和镜像的时候删除它们。 + +希望你现在对 **Docker 的使用** 有一个基本的了解。 + +更多细节,请参考这篇教程最下面的官方资源链接,或者在下面的评论区进行评论。 + +### 相关资料 + +* [Docker 官网][19] +* [Docker 文档][20] + +-------------------------------------------------------------------------------- + +via: https://ostechnix.com/getting-started-with-docker/ + +作者:[sk][a] +选题:[lkxed][b] +译者:[MCGA](https://github.com/Yufei-Yan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://ostechnix.com/author/sk/ +[b]: https://github.com/lkxed +[1]: https://ostechnix.com/install-docker-almalinux-centos-rocky-linux/ +[2]: https://ostechnix.com/install-docker-ubuntu/ +[3]: https://hub.docker.com/ +[4]: https://ostechnix.com/wp-content/uploads/2022/07/Search-Docker-Images.png +[5]: https://ostechnix.com/wp-content/uploads/2022/07/Download-Docker-Images.png +[6]: https://ostechnix.com/wp-content/uploads/2022/07/List-Docker-Images.png +[7]: https://ostechnix.com/wp-content/uploads/2022/07/Docker-Image-Tag-and-ID.png +[8]: https://ostechnix.com/wp-content/uploads/2022/07/Run-Containers-Using-Tag-1.png +[9]: https://ostechnix.com/wp-content/uploads/2022/07/Run-Containers-In-Background-1.png +[10]: https://ostechnix.com/wp-content/uploads/2022/07/View-Running-Containers.png +[11]: https://ostechnix.com/wp-content/uploads/2022/07/Find-Container-ID-And-Name.png +[12]: https://ostechnix.com/wp-content/uploads/2022/07/Automatically-Delete-Containers.png +[13]: https://ostechnix.com/wp-content/uploads/2022/07/Assign-Name-To-Containers.png +[14]: https://ostechnix.com/wp-content/uploads/2022/07/Build-Custom-Docker-Images.png +[15]: https://ostechnix.com/wp-content/uploads/2022/07/Delete-Containers.png +[16]: https://ostechnix.com/wp-content/uploads/2022/07/Delete-Everything-In-Docker.png +[17]: https://ostechnix.com/wp-content/uploads/2016/04/sk@sk-_005-1-1.jpg +[18]: https://ostechnix.com/wp-content/uploads/2016/04/sk@sk-_006-1.jpg +[19]: https://www.docker.com/ +[20]: https://docs.docker.com/ diff --git a/published/20220704 Fixing -cannot find signatures with metadata for snap- Error in Ubuntu and other Linux.md b/published/20220704 Fixing -cannot find signatures with metadata for snap- Error in Ubuntu and other Linux.md new file mode 100644 index 0000000000..8ca837d489 --- /dev/null +++ b/published/20220704 Fixing -cannot find signatures with metadata for snap- Error in Ubuntu and other Linux.md @@ -0,0 +1,87 @@ +[#]: subject: "Fixing “cannot find signatures with metadata for snap” Error in Ubuntu and other Linux" +[#]: via: "https://itsfoss.com/snap-metadata-signature-error/" +[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14815-1.html" + +修复 Ubuntu 中的 “cannot find signatures with metadata for snap” 错误 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/11/112312l4y0jf3gag8sam4g.jpg) + +前几天我试图安装 [massCode][1] 应用。对于安装,它提供了一个 Snap 文件以供下载。 + +当我尝试从 Snap 文件安装应用程序时: + +``` +sudo snap install snap_file +``` + +它给了我以下错误: + +``` +error: cannot find signatures with metadata for snap "masscode_2.6.1_amd64.snap" +``` + +![cannot find signature with metadata for snap][2] + +这很奇怪。[在 Ubuntu 中添加外部仓库][3] 时,你必须添加 GPG 密钥。但是这里的开发人员没有提供这样的东西。 + +“修复”简单易行。让我给你解释一下。 + +### 处理 “cannot find signatures with metadata for snap” 错误 + +这里其实不涉及签名。 + +发生的情况是你从第三方下载了 Snap 安装程序。 Ubuntu 中的 Snap 机制希望你从官方 Snap 商店获取 Snap 包。 + +由于它不是来自 Snap 商店,因此你会看到 “cannot find signatures with metadata for snap” 的错误消息。与大多数错误消息一样,这个错误消息不是描述性的。 + +那么,这里的解决方案是什么? + +任何未通过 Snap 商店分发的 Snap 包都必须使用 `--dangerous` 选项进行安装。这就是规则。 + +``` +sudo snap install --dangerous path_to_snap_file +``` + +这样,你告诉 Snap 包管理器显式安装 Snap 包。 + +在这里,我使用了这个选项并且能够成功地从它的 Snap 包中安装 massCode。 + +![installing third party snap packages][4] + +以这种方式安装 Snap 包有多“危险”?几乎和下载并 [安装 deb 格式安装包][5] 相同。 + +在我看来,如果你是从项目开发者的网站上下载 Snap 包,你已经在信任该项目了。在这种情况下,你可以使用 `--dangerous` 选项安装它。 + +当然,你应该首先搜索该软件包是否在 Snap 商店中可用: + +``` +snap find package_name +``` + +我希望这个快速的小技巧可以帮助你修复 Snap 错误。如果你有任何问题或建议,请告诉我。如果你想了解更多信息,请参阅 [这个使用 Snap 命令指南][6]。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/snap-metadata-signature-error/ + +作者:[Abhishek Prakash][a] +选题:[lkxed][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/lkxed +[1]: https://masscode.io/ +[2]: https://itsfoss.com/wp-content/uploads/2022/07/cannot-find-signature-with-metadata-for-snap-800x205.png +[3]: https://itsfoss.com/adding-external-repositories-ubuntu/ +[4]: https://itsfoss.com/wp-content/uploads/2022/07/installing-third-party-snap-packages-800x358.png +[5]: https://itsfoss.com/install-deb-files-ubuntu/ +[6]: https://itsfoss.com/use-snap-packages-ubuntu-16-04/ diff --git a/published/20220704 Manage your files in your Linux terminal with ranger.md b/published/20220704 Manage your files in your Linux terminal with ranger.md new file mode 100644 index 0000000000..585feda04a --- /dev/null +++ b/published/20220704 Manage your files in your Linux terminal with ranger.md @@ -0,0 +1,116 @@ +[#]: subject: "Manage your files in your Linux terminal with ranger" +[#]: via: "https://opensource.com/article/22/7/manage-files-linux-terminal-ranger" +[#]: author: "Sumantro Mukherjee https://opensource.com/users/sumantro" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14835-1.html" + +用 ranger 在 Linux 终端管理你的文件 +====== + +> 试试这个轻量级的开源工具,不用离开终端就可以预览文件。 + +![Filing cabinet for organization][1] + +查看你的文件和文件夹的最基本方法是使用命令 `ls` 和 `ll`。但是有时候,我不仅想看到文件的元数据,还想一目了然地看到文件的内容。为此,我使用 ranger。 + +如果你喜欢在控制台中工作,并使用 [Vim][2] 或 Vi,而且你不想因为任何原因离开你的终端,那么 ranger 就是你最好的新朋友。ranger 是一个精简的文件管理器,它不仅可以让你浏览文件,还可以预览它们。ranger 与 rifle 捆绑在一起,rifle 是一个文件执行器,可以有效地选择与特定文件类型相关的程序。 + +### 在 Linux 上安装 ranger + +ranger 可以在 Fedora 或任何基于 RPM 的发行版中安装,方法是运行: + +``` +$ sudo dnf install ranger +``` + +ranger 也可以用于 [其他发行版和 macOS][3]。 + +### 第一次使用 ranger + +作为一个用户,你可以在你喜欢的终端上简单地输入 `ranger` 来启动 ranger。可以用方向键浏览。这张截图是一个很好的例子,我可以预览存储在 `Kernel-tests` 中的 `config.example` 文件的代码。 + +![Screenshot of terminal showing config.example highlighted and a preview of the file in the terminal to the right][4] + +选中任何文件并按下 `F4` 键,就可以打开你的默认编辑器,让你立即编辑这些文件! + +### 图像和视频怎么办? + +使用 [rifle][5] 和 ranger 可以让你快速找到与某一文件相关的程序。将鼠标悬停在图片上,然后试图打开它是非常简单的,只要点击回车即可。下面是它的样子: + +![Screenshot of a PNG file preview over a terminal window][6] + +在一个图像文件上点击 `i` 会给用户提供所有的 EXIF 数据。点击 `Shift+Enter` 将打开这个 PDF 文件。 + +![A screenshot showing a preview of a PDF file (tickets to a museum) floating over the terminal window][7] + +同样的组合键将在系统默认的支持该编解码器的视频播放器中打开并开始播放视频。下面的例子是一个 mp4 视频,它在 [VLC][8] 上播放得很好。 + +![Screenshot of a Bugcrowd University Cross Site Scripting video in VLC media player, previewed over the terminal][9] + +### 文件操作 + +除非 Vim 用户另有配置,否则下面的键绑定工作良好。 + +- `j`:下移 +- `k`:上移 +- `h`: 移动到父目录 +- `gg`:移到列表的顶部 +- `i`:预览文件 +- `r`:打开文件 +- `zh`:查看隐藏文件 +- `cw`:重命名当前文件 +- `yy`:复制文件 +- `dd`:剪切文件 +- `pp`:粘贴文件 +- `u`:撤销 +- `z`:改变设置 +- `dD`:删除文件 + +### 控制台命令 + +有时我在起草文章时,有一个文件夹包含某个软件的截图。通过点击空格选择或标记文件,然后输入 `:bulkrename`,可以帮助我把所有奇怪的时间戳变成如:lorax1、lorax2 等等。下面是一个例子。 + +![Screenshot of terminal showing timestamped files that can be renamed with the bulkrename command][10] + +其他有用的控制台命令包括: + +- `:openwith`:用你选择的程序打开一个选择的文件 +- `:touch FILENAME`:创建一个文件 +- `:mkdir FILENAME`:创建一个目录 +- `:shell `:在 shell 中运行一个命令 +- `:delete`:删除文件 + +### 在 tty2/3/4 中能工作吗? + +作为一个从事质量保证(QA)工作的人,我发现搜索日志和阅读日志从未如此简单。即使我的 Gnome 显示管理器崩溃了,我也可以切换到我的 tty2,用我的用户名和密码登录,并以超级用户权限启动 ranger,然后我就可以尽情地探索了! + +ranger 是一个很好的工具,可以在不离开终端的情况下处理文件。ranger 是精简的,也是可定制的,所以不妨一试吧! + +*图片来源:(Sumantro Mukherjee,CC BY-SA 4.0)* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/7/manage-files-linux-terminal-ranger + +作者:[Sumantro Mukherjee][a] +选题:[lkxed][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/sumantro +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/files_documents_organize_letter.png +[2]: https://opensource.com/tags/vim +[3]: https://opensource.com/article/20/3/ranger-file-navigator +[4]: https://opensource.com/sites/default/files/2022-06/ranger%201.png +[5]: https://www.systutorials.com/docs/linux/man/1-rifle/ +[6]: https://opensource.com/sites/default/files/2022-06/ranger%202.png +[7]: https://opensource.com/sites/default/files/2022-06/ranger%203.png +[8]: https://opensource.com/article/21/2/linux-media-players +[9]: https://opensource.com/sites/default/files/2022-06/ranger%204.png +[10]: https://opensource.com/sites/default/files/2022-06/ranger%205.png diff --git a/published/20220704 massCode- A Free and Open-Source Code Snippet Manager.md b/published/20220704 massCode- A Free and Open-Source Code Snippet Manager.md new file mode 100644 index 0000000000..4ac978e0aa --- /dev/null +++ b/published/20220704 massCode- A Free and Open-Source Code Snippet Manager.md @@ -0,0 +1,107 @@ +[#]: subject: "massCode: A Free and Open-Source Code Snippet Manager" +[#]: via: "https://itsfoss.com/masscode/" +[#]: author: "Ankush Das https://itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14827-1.html" + +massCode:一个自由开源的代码片段管理器 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/14/151504ti9twf2u5kft2wh2.jpg) + +> massCode 是一个开源的代码片段管理器,使你能够涉足代码,提高生产力,并节省时间。 + +如果一个工具能让事情变得更快、更有效率,那对许多开发者来说就是救命稻草。 + +虽然有各种服务和平台试图使编码体验更快,但你仍然有其他几个选择可以考虑。 + +例如,代码片段管理器。使用代码片段管理器,你的目的是保存你想快速访问的代码片段。它更像是指定快捷方式,在你的程序中添加所需的代码。 + +这不是一个新的概念,但可用于这项工作的工具可能不完全是开源的。 + +幸运的是,我偶然发现了一个不错的项目,它为你提供了一个自由开源的片段管理器,即 massCode。 + +### massCode:跨平台的开源片段管理器 + +![masscode][1] + +massCode 是一个有用的代码片段管理器,具有一些基本功能。 + +它支持广泛的编程语言,还包括对 Markdown 的支持。你可以使用文件夹组织你的代码片段,添加标签等。 + +massCode 可用于 Linux、Windows 或 macOS。让我们来看看一些主要功能。 + +### massCode 的特点 + +![masscode screenshot][2] + +massCode 包括许多有用的功能。其中一些是: + +* 多层次的文件夹结构 +* 每个片段都可以存储在片段(标签)中 +* 集成的编码编辑器 [Ace][3] +* 代码格式化或高亮显示 +* 支持带预览的 Markdown +* 能够搜索片段 +* 给你的代码段添加描述,以了解它的用途 +* 各种深色/浅色主题可用 +* 能够从 [SnippetsLab][4] 迁移 +* 自动保存以帮助你保留你的工作 +* 将其与云同步文件夹整合 +* 支持 VSCode、Raycast 和 Alfred 的扩展 + +除了上述所有功能外,你还可以轻松地复制保存代码片段,只需点击一下。 + +对于自定义,你可以调整字体大小和系列、切换自动换行、高亮显示行、使用单引号或添加尾随命令,这要归功于 [Prettier][5]。 + +此外,一份片段可以有多个分片。因此,它使你有机会将其用于各种用例。 + +如前所述,你也可以通过改变同步文件夹的存储位置将其与你的任何云同步服务整合。 + +![masscode migrate preferences][6] + +总的来说,它工作得很好,有一些局限性,比如缺乏将嵌套文件夹从 SnippetsLab 迁移到 masCode 的能力。 + +### 在 Linux 上安装 massCode + +massCode 有 [Snap 包][7],但不在 Snap 商店中。你可以直接下载该软件包,并使用以下命令来安装它: + +``` +sudo snap install --dangerous ~/Downloads/masscode_2.6.1_amd64.snap +``` + +我们的一份故障排除指南可以帮助你了解 [snap 的 dangerous 选项][8]。 + +你可以通过其 [官方网站][9] 或 [GitHub 发布区][10] 下载 Windows/MacOS 版。 + +> **[massCode][11]** + +你试过 massCode 吗?还有其他可用于 Linux 的代码片段管理器吗?请在下面的评论中告诉我你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/masscode/ + +作者:[Ankush Das][a] +选题:[lkxed][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/lkxed +[1]: https://itsfoss.com/wp-content/uploads/2022/07/masscode-screenshot-1.png +[2]: https://itsfoss.com/wp-content/uploads/2022/07/masscode-screenshot.png +[3]: https://github.com/ajaxorg/ace +[4]: https://apps.apple.com/us/app/snippetslab/id1006087419?mt=12 +[5]: https://prettier.io/ +[6]: https://itsfoss.com/wp-content/uploads/2022/07/masscode-migrate-preferences.jpg +[7]: https://itsfoss.com/install-snap-linux/ +[8]: https://itsfoss.com/snap-metadata-signature-error/ +[9]: https://masscode.io/ +[10]: https://github.com/massCodeIO/massCode/releases/tag/v2.6.1 +[11]: https://masscode.io/ diff --git a/published/20220705 StarFighter- A Linux Laptop with a 4K 10-bit IPS Display is Coming Soon.md b/published/20220705 StarFighter- A Linux Laptop with a 4K 10-bit IPS Display is Coming Soon.md new file mode 100644 index 0000000000..16800310e3 --- /dev/null +++ b/published/20220705 StarFighter- A Linux Laptop with a 4K 10-bit IPS Display is Coming Soon.md @@ -0,0 +1,69 @@ +[#]: subject: "StarFighter: A Linux Laptop with a 4K 10-bit IPS Display is Coming Soon" +[#]: via: "https://news.itsfoss.com/starfighter-laptop-reveal/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14798-1.html" + +星际战机:配备 4K 10 位 IPS 显示屏的 Linux 笔记本电脑即将问世 +====== + +> “星际战机”是星空实验室即将推出的一款 Linux 笔记本电脑。他们正在最后确定生产细节,同时透露了一些关键的亮点。 + +![starfighter][1] + +我们已经有许多来自星空实验室、TUXEDO 等制造商的 Linux 专用笔记本电脑。 + +然而,其中只有少数几家专注于提供一个超棒的显示屏。 + +例如,[TUXEDO 的 Infinitybook Pro 14][2] 带有 3K 显示屏,而且,该笔记本电脑确实不错。 + +现在,看起来 [星空实验室][3] 将为其即将推出的 “星际战机” 笔记本电脑配备 15.6 英寸 4K 显示屏。他们在 [推特][4] 上分享了初步信息,提到他们正在敲定生产细节。 + +### 关于星际战机我们目前所知道的情况 + +这款笔记本电脑将采用 45W 供电的英特尔 / AMD 处理器,它将有英特尔 / AMD 两种变体可用。 + +你还将可以选择高达 64GB 的内存和 2TB 的存储。可以说,对于那些想为自己的 Linux 笔记本电脑提高规格的用户来说,这应该是一个强大的机器。 + +当然,它的关键亮点是显示屏。它将采用 4K 10 位哑光 IPS 显示屏。 + +该公司提到,该显示屏的成本要高于其 StarLite 笔记本电脑。 + +但是,这会是一个有吸引力的产品吗?许多采用高分辨率显示屏或 OLED 面板的笔记本电脑在电池时长方面表现不佳。不仅仅是 Linux 笔记本电脑。 + +那么,“星际战机”会成为该领域的一个有竞争力的竞争者吗? + +星空实验室在一条推文中提到,他们估计电池时长约为 8-14 小时,这取决于配置。当然,这也取决于你的使用情况。 + +该公司还澄清说,这款笔记本电脑可以使用 Coreboot,但它不会是一个完全采用自由软件的项目。其他一些值得注意的地方还有: + +* 该笔记本电脑将具有 [LVFS][5] 支持。 +* 英特尔型号将提供第 4 代固态硬盘。AMD 型号将只限于第 3 代固态硬盘。 + +如图片所示,它可能安装了 elementaryOS 6.1。然而,你也可以预期它提供 Ubuntu 22.04 LTS。 + +那么,你对星空实验室的这架“星际战机”有何看法?当它上市时,这将是你的下一台笔记本电脑吗? + +在下面的评论区分享你的想法。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/starfighter-laptop-reveal/ + +作者:[Ankush Das][a] +选题:[lkxed][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/ankush/ +[b]: https://github.com/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/07/starfighter-linux-powered-laptop.jpg +[2]: https://news.itsfoss.com/infinitybook-pro-14-3k/ +[3]: http://starlabs.systems +[4]: https://twitter.com/starlabsltd/status/1542908391793692672 +[5]: https://fwupd.org/ diff --git a/published/20220705 Why I love Tig for visualizing my Git workflows.md b/published/20220705 Why I love Tig for visualizing my Git workflows.md new file mode 100644 index 0000000000..d6d8b25fe3 --- /dev/null +++ b/published/20220705 Why I love Tig for visualizing my Git workflows.md @@ -0,0 +1,96 @@ +[#]: subject: "Why I love Tig for visualizing my Git workflows" +[#]: via: "https://opensource.com/article/22/7/visualize-git-workflow-tig" +[#]: author: "Sumantro Mukherjee https://opensource.com/users/sumantro" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14809-1.html" + +使用 Tig 来可视化 Git 工作流 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/09/123419u39t3jz9gzc6345t.jpg) + +> Tig 是审查 Git 仓库的绝佳工具,它鼓励你探索日志,而无需构建冗长且有时复杂的查询。 + +如果你发现浏览你的 Git 仓库非常复杂,我已经为你准备好了工具,来了解一下 Tig。 + +Tig 是一个 [基于 ncurses][2] 的 Git 文本模式界面,它允许你浏览 Git 仓库中的更改。它还可以充当各种 Git 命令输出的分页器。使用这个工具可以让我很好地了解在哪个提交中发生了哪些更改,最新的提交合并是什么等等。请跟随这个简短的教程,亲自尝试一下。 + +### 安装 Tig + +在 Linux 上,你可以使用包管理器安装 Tig。例如,在 Fedora 和 Mageia 上: + +``` +$ sudo dnf install tig +``` + +在 Debian、Linux Mint、Elementary、Pop_OS 和其他基于 Debian 的发行版上: + +``` +$ sud apt install tig +``` + +在 macOS 上,使用 [MacPorts][3] 或 [Homebrew][4]。 Tig 的完整安装指南可在 [Tig 手册][5] 中找到。 + +### 使用 Tig + +Tig 提供了常见 Git 输出的交互式视图。例如,使用 Git,你可以使用命令 `git show-ref` 查看所有引用: + +``` +$ git show-ref +98b108... refs/heads/master +6dae95... refs/remotes/origin/1010-internal-share-partition-format-reflexion +84e1f8... refs/remotes/origin/1015-add-libretro-openlara +e62c7c... refs/remotes/origin/1016-add-support-for-retroarch-project-cd +1c29a8... refs/remotes/origin/1066-add-libretro-mess +ffd3f53... refs/remotes/origin/1155-automatically-generate-assets-for-external-installers +ab4d14... refs/remotes/origin/1160-release-on-bare-metal-servers +28baa9... refs/remotes/origin/1180-ipega-pg-9118 +8dff1d... refs/remotes/origin/1181-add-libretro-dosbox-core-s +81a7fe... refs/remotes/origin/1189-allow-manual-build-on-master +[...] +``` + +使用 Tig,你可以在可滚动列表中获取该信息以及更多信息,此外还可以使用键盘快捷键来打开其他视图,其中包含每个引用的详细信息。 + +![][6] + +### 分页模式 + +当输入来自标准输入时,Tig 进入分页模式。当指定 `show` 子命令并给出 `--stdin` 选项时,标准输入被假定为提交 ID 列表,它被转发到 `git-show` : + +``` +$ git rev-list --author=sumantrom HEAD | tig show –stdin +``` + +### 日志和差异视图 + +当你在 Tig 的日志视图中时,你可以按键盘上的 `d` 键来显示差异。这将显示提交中更改的文件以及删除和添加的行。 + +### 交互式 Git 数据 + +Tig 是对 Git 的一个很好的补充。它鼓励你探索日志,而无需构建冗长且有时复杂的查询,从而可以轻松查看你的 Git 仓库。 + +立即将 Tig 添加到你的 Git 工具包中! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/7/visualize-git-workflow-tig + +作者:[Sumantro Mukherjee][a] +选题:[lkxed][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/sumantro +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/images/life/computer_code_programming_laptop_0.jpg +[2]: https://opensource.com/article/21/8/ncurses-linux +[3]: https://opensource.com/article/20/11/macports +[4]: https://opensource.com/article/20/6/homebrew-mac +[5]: https://jonas.github.io/tig/doc/manual.html +[6]: https://opensource.com/sites/default/files/2022-06/tig%201.png diff --git a/published/20220707 Check disk usage in Linux.md b/published/20220707 Check disk usage in Linux.md new file mode 100644 index 0000000000..c4448c158c --- /dev/null +++ b/published/20220707 Check disk usage in Linux.md @@ -0,0 +1,140 @@ +[#]: subject: "Check disk usage in Linux" +[#]: via: "https://opensource.com/article/22/7/check-disk-usage-linux" +[#]: author: "Don Watkins https://opensource.com/users/don-watkins" +[#]: collector: "lkxed" +[#]: translator: "MjSeven" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14823-1.html" + +检查 Linux 磁盘使用情况 +====== + +> du 和 ncdu 两个命令提供了相同信息的两种不同视图,便于我们跟踪存储在计算机上的内容。 + +![](https://img.linux.net.cn/data/attachment/album/202207/13/111729faleyal2gmappykc.jpg) + +无论你有多少存储空间,了解文件占用了多少磁盘空间都是一个重要的考虑事项。我的笔记本有一个相对较小的 250GB NVME 驱动器,大多数时候都没什么问题,但几年前我开始探索 Linux 上的游戏,情况变得有所不同,安装 Steam 和其他游戏使存储管理更加重要。 + +### du 命令 + +检查磁盘驱动器上剩余存储空间最简单的方法是 [du 命令][2]。它会估计文件空间使用情况,像其他所有 Linux 工具一样,`du` 非常强大,但学会如何根据你的特定需求使用它会很有帮助。我总是查阅手册页来掌握实用程序的用法。`du` 有几个选项,可以为你提供文件存储的最佳快照,以及它们在系统上消耗多少空间。 + +`du` 命令有很多选项,以下是一些常见的: + +* `-a` - 包括文件夹和文件在内的存储信息 +* `--apparent-size` - 打印自身大小而不是占用磁盘量 +* `-h` - 人类可读的格式 +* `-b` - 以字节为单位 +* `-c` - 总计 +* `-k` - 以块为单位 +* `-m` - 以兆字节为单位的大小 + +务必查看 `du` 手册页获取完整帮助列表。 + +#### 显示所有文件 + +你可以选择的第一个选项是 `du -a`,它可以显示系统上所有文件及其存储目录的大小。这个命令让我知道了我的主目录中存储了 11555168 个字节。使用 `du -a` 可以快速递归地查看我的存储系统。如果我想要一个更有意义的数字,并且我想深入到目录中查看大文件的位置,该怎么办? + +我认为在 `Downloads` 目录下有一些大文件,所以我输入 `du -a /home/don/Downloads` 来查看。 + +``` +$ du -a ~/Downloads +4923    ./UNIX_Driver_5-0/UNIX Driver 50 +4923    ./UNIX_Driver_5-0 +20     ./epel-release-latest-9.noarch.rpm +12     ./rpmfusion-free-release-9.noarch.rpm +2256    ./PZO9297 000 Cover.pdf +8     ./pc.md +2644    ./geckodriver-v0.31.0-linux64.tar.gz +466468 +``` + +最左边的数字是以字节为单位的文件大小。我想要一些对我更有帮助的东西,所以我将人类可读格式的选项添加到命令中,结果是 456M(兆字节),这对我来说是一种更有用的数字格式。 + +``` +$ du -ah ~/Downloads +4.9M    ./UNIX_Driver_5-0/UNIX Driver 50 +4.9M    ./UNIX_Driver_5-0 +20K    ./epel-release-latest-9.noarch.rpm +12K    ./rpmfusion-free-release-9.noarch.rpm +2.2M    ./PZO9297 000 Cover.pdf +8.0K    ./pc.md +2.6M    ./geckodriver-v0.31.0-linux64.tar.gz +456M    . +``` + +与大多数 Linux 命令一样,你可以组合选项,要以人类可读的格式查看 `Downloads` 目录,使用 `du -ah ~/Downloads` 命令。 + +#### 总和 + +`-c` 选项在最后一行提供了磁盘使用总和。我可以使用 `du -ch /home/don` 来显示主目录中的每个文件和目录。这里有很多信息,我只想知道最后一行的信息,所以我将 `du` 命令通过管道传输给 `tail` 来显示最后几行。命令是 `du -ch /home/don | tail`。(LCTT 校注:可以使用 `tail -1` 来仅显示最后一行汇总行。) + +![将 du 命令输出通过管道传输到 tail][4] + +### ncdu 命令 + +对存储在驱动器上内容感兴趣的 Linux 用户,另一个选择是 [ncdu 命令][5],它代表 “NCurses 磁盘使用情况”。基于你的 Linux 发行版,你可能需要下载并安装它。 + +在 Linux Mint、Elementary、Pop_OS! 或其它基于 Debian 的发行版上: + +``` +$ sudo apt install ncdu +``` + +在 Fedora、Mageia 或 CentOS 上: + +``` +$ sudo dnf install ncdu +``` + +在 Arch、Manjar 或者类似发行版上: + +``` +$ sudo pacman -S ncdu +``` + +安装后,你可以使用 `ncdu` 来分析你的文件系统。以下是在我的主目录中发出 `ncdu` 后的示例输出。`ncdu` 的手册页指出 “ncdu(NCurses Disk Usage)是众所周知的 `du` 基于 curses 的版本,它提供了一种快速查看哪些目录正在使用磁盘空间的方法。” + +![du 命令输出][6] + +我可以使用方向键上下导航,按下回车键进入目录。有趣的是,`du` 报告我的主目录中的总磁盘使用量为 12GB,而 `ncdu` 显示为 11GB。你可以在 `ncdu` 手册页中找到更多信息。 + +你可以将 `ncdu` 指向某个目录来探索特定目录。例如,`ncdu /home/don/Downloads`。 + +![ncdu 命令输出][7] + +按 `?` 键显示帮助菜单。 + +![ncdu 帮助][8] + +### 总结 + +`du` 和 `ncdu` 两个命令提供了相同信息的两种不同视图,便于我们跟踪存储在计算机上的内容。 + +如果你不习惯使用终端,或者想寻找此类信息的另一种查看方式,可以看看 [GNOME 磁盘使用分析器][9]。如果你的系统上还没有它,你可以轻松安装和使用它。检查你的发行版是否有 baobab 开发的这个软件,如果你想试试,那就去安装它吧。 + +(文内图片来自于 Don Watkins, CC BY-SA 4.0) + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/7/check-disk-usage-linux + +作者:[Don Watkins][a] +选题:[lkxed][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/data_stack_blue_disks.png +[2]: https://opensource.com/article/21/7/check-disk-space-linux-du +[3]: https://opensource.com/article/18/7/how-check-free-disk-space-linux +[4]: https://opensource.com/sites/default/files/2022-06/1-du-tail.png +[5]: https://opensource.com/article/21/8/ncdu-check-free-disk-space-linux +[6]: https://opensource.com/sites/default/files/2022-06/2home.png +[7]: https://opensource.com/sites/default/files/2022-06/3downloads.png +[8]: https://opensource.com/sites/default/files/2022-06/4ncdu.png +[9]: https://help.gnome.org/users/baobab/stable/ diff --git a/published/20220707 Google Summer of Code + Zephyr RTOS.md b/published/20220707 Google Summer of Code + Zephyr RTOS.md new file mode 100644 index 0000000000..2484e74048 --- /dev/null +++ b/published/20220707 Google Summer of Code + Zephyr RTOS.md @@ -0,0 +1,140 @@ +[#]: subject: "Google Summer of Code + Zephyr RTOS" +[#]: via: "https://www.linux.com/news/google-summer-of-code-zephyr-rtos/" +[#]: author: "The Linux Foundation https://www.linuxfoundation.org/blog/google-summer-of-code-zephyr-rtos/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14818-1.html" + +谷歌编程之夏与 Zephyr RTOS 项目介绍 +====== + +**谷歌编程之夏**(GSoC)是一个谷歌举办的国际年度项目,每年都在夏季举办。当贡献者们参与并完成一个 [自由开源软件][3] 的编码项目,[谷歌][1] 就会给他们发放 [津贴][2]。谷歌编程之夏于 2005 年推出,于每年 5 月至 8 月举行。项目创意由参与开源软件开发的主办组织提交,但学生也可以提出自己的项目创意。 + +今年,该项目向 18 岁或以上的任何人开放 —— 不仅限于学生和应届毕业生了。参与者通过编写软件获得报酬,其 [津贴][4] 的金额取决于他们所在国家/地区的 [购买力平价][5]。 + +**LCTT 译注:以往,这个活动只允许在校学生参与,今年条件放开,只需年龄 18+ 即可,对参与者的贡献时长要求也降低了,尽可能地让更多人参与进来。不过,今年的报名通道在 4 月 19 日就截止了,大家有兴趣的话明年可以关注一下。** + +这也是 Zephyr 项目第一次作为 Linux 基金会的项目,参与到谷歌编程之夏中。让我们一起欢迎这些贡献者及其项目吧! + +### 项目一:基于 Zephyr 的 Arduino 模块 + +1 个贡献者(350 小时)。 + +[Arduino][6] 是一个流行的框架,它为嵌入式设备编程提供了一个简化的接口。最近,Arduino 采用 mbed OS 作为其一些新设备的基础 RTOS。通过这项工作,他们将 [Arduino Core][7] 作为独立的抽象层,从 [Arduino Core for mbed][8] 中分离出来。这为在其他操作系统上利用 Arduino Core 开辟了可能性。 + +该项目的想法就是创建一个利用 Arduino Core 的 Zephyr 模块,以便开发人员在与 Arduino 兼容的设备上使用 Arduino 框架时,可以使用 Zephyr 作为底层操作系统。对用户的好处包括: + +* 可以访问 Arduino API 以及高级 Zephyr 功能 +* 得益于 Zephyrs 的设备支持,用户可以选择标准 Arduino 生态系统更广泛的设备 +* 能够重复使用 Arduino 工具,如 Arduino IDE 和丰富的库 + +Arduino Core 使用 LGPL 许可证,Zephyr 使用 Apache 2 许可证。这意味着该项目的开发很可能需要脱离主分支,并在单独的仓库中进行,以保持代码和许可证分离。有关这方面的历史讨论,请参阅 [#22247][9],有关 Arduino 核心架构之前的早期尝试,请参阅 [soburi/arduino-on-zephyr][10]。 + +**贡献者的任务是:** + +* 实现一个基于 Arduino Core 的准系统模块,可以为任何目标编译(不具备功能性,可能在 QEMU 中) +* 基于 Zephyr,使用 Arduino API 实现一个通用外围设备,例如 [Serial][11] +* 以一个物理板为目标,例如 Arduino Zero + +**导师:** + +[Jonathan Beri][12] – Golioth 和 Zephyr TSC 的首席执行官 +[Alvaro Viebrantz][13] – Golioth 和 Google GDE 的创始工程师 + +**代码许可证:** LGPL + +**贡献者详细信息:** + +* 姓名:Dhruva Gole +* 项目博客:[https://dhruvag2000.github.io/Blog-GSoC22/][14] +* 项目海报: + +![][15] + +**关于贡献者:** + +![][16] + +Dhruva 是一名电气工程专业的本科生。他的兴趣广泛,从嵌入式软件开发到硬件设计,在 SBC、微控制器和嵌入式 Linux 平台方面拥有丰富的工作经验。 + +### 项目二:Zephyr 的 Apache Thrift 模块 + +一个贡献者(350 小时)。 + +[Apache Thrift][17] 是一个 [IDL][18] 规范、[RPC][19] 框架和代码生成器,它抽象出传输和协议细节,让开发者专注于应用逻辑。它适用于所有主流操作系统,支持超过 27 种编程语言、7 种协议和 6 种底层传输方式。最初,它于 [2007 年在 Facebook 开发][20],随后与 Apache 软件基金会共享。 + +![][21] + +![][22] + +在 Zephyr RTOS 中支持 Thrift 将使社区受益匪浅。它将带来新的软件和硬件技术、新产品以及云集成的其他方式。 Thrift 也可以用于几乎任何传输,因此,它是 Zephyr 支持的许多不同物理通信层的自然选择。该项目的想法是使概念验证 [Thrift for Zephyr 模块][23] 形成以供上游使用。为此,贡献者必须: + +* 对 Thrift 功能(协议、传输)执行额外的集成 +* 使用 [supported board][24] 或 [Qemu][25] 编写其他示例应用程序 +* 使用 [Zephyr 测试框架][26] 编写其他测试并生成覆盖率报告 +* 确保模块遵循适当的 [编码指南][27] 并满足 [模块要求][28] +* 将任何必要的改进贡献回 Apache Thrift 项目 +* 将任何必要的改进贡献回 Zephyr 项目 + +**导师:** + +* [Christopher Friedt][29] – Meta 的 SWE / ASIC FW 和 Zephyr TSC 成员 +* [Stephanos Ioannidis][30] – Zephyr CXX 子系统维护者 + +**代码许可证:** Apache 2.0 + +**贡献者详细信息:** + +* 姓名:Young + +**关于贡献者:** Young 是一名通信工程专业的学生,他将攻读计算机工程硕士学位。他兴趣广泛,从前端开发到硬件设计,在 Web、IoT 和嵌入式平台方面拥有丰富的工作经验。2021 年他设计的一款搭载 RISC-V 64 处理器的低成本单板机被多家极客媒体报道。 + +本文 [Google Summer of Code + Zephyr RTOS][31] 首发于 [Linux 基金会][32]。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/news/google-summer-of-code-zephyr-rtos/ + +作者:[The Linux Foundation][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxfoundation.org/blog/google-summer-of-code-zephyr-rtos/ +[b]: https://github.com/lkxed +[1]: https://en.wikipedia.org/wiki/Google +[2]: https://en.wikipedia.org/wiki/Stipend +[3]: https://en.wikipedia.org/wiki/Free_and_open-source_software +[4]: https://en.wikipedia.org/wiki/Stipend +[5]: https://en.wikipedia.org/wiki/Purchasing_power_parity +[6]: https://www.arduino.cc/ +[7]: https://github.com/arduino/ArduinoCore-API +[8]: https://github.com/arduino/ArduinoCore-mbed +[9]: https://github.com/zephyrproject-rtos/zephyr/issues/22247 +[10]: https://github.com/soburi/arduino-on-zephyr +[11]: https://www.arduino.cc/reference/en/language/functions/communication/serial/ +[12]: https://www.linkedin.com/in/jonathanberi/ +[13]: https://www.linkedin.com/in/alvaro-viebrantz-55119048/ +[14]: https://dhruvag2000.github.io/Blog-GSoC22/ +[15]: https://www.linuxfoundation.org/wp-content/uploads/project-poster.png +[16]: https://www.linuxfoundation.org/wp-content/uploads/dhruva.jpeg +[17]: https://github.com/apache/thrift +[18]: https://en.wikipedia.org/wiki/Interface_description_language +[19]: https://en.wikipedia.org/wiki/Remote_procedure_call +[20]: https://thrift.apache.org/static/files/thrift-20070401.pdf +[21]: https://www.linuxfoundation.org/wp-content/uploads/apache-thrift-layered-architecture.png +[22]: https://www.linuxfoundation.org/wp-content/uploads/SPDX-license.png +[23]: https://github.com/cfriedt/thrift-for-zephyr +[24]: https://docs.zephyrproject.org/latest/boards/index.html +[25]: https://docs.zephyrproject.org/latest/guides/networking/qemu_user_setup.html +[26]: https://docs.zephyrproject.org/latest/guides/test/ztest.html +[27]: https://docs.zephyrproject.org/latest/contribute/coding_guidelines/index.html +[28]: https://docs.zephyrproject.org/latest/guides/modules.html +[29]: https://www.linkedin.com/in/christopher-friedt/ +[30]: https://www.linkedin.com/in/stephanosio/ +[31]: https://www.linuxfoundation.org/blog/google-summer-of-code-zephyr-rtos/ +[32]: https://www.linuxfoundation.org/ diff --git a/published/20220707 More Linux Developers Joining Microsoft, Systemd Creator Adds to the List.md b/published/20220707 More Linux Developers Joining Microsoft, Systemd Creator Adds to the List.md new file mode 100644 index 0000000000..85c5366a8d --- /dev/null +++ b/published/20220707 More Linux Developers Joining Microsoft, Systemd Creator Adds to the List.md @@ -0,0 +1,70 @@ +[#]: subject: "More Linux Developers Joining Microsoft, Systemd Creator Adds to the List" +[#]: via: "https://news.itsfoss.com/systemd-creator-microsoft/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14804-1.html" + +又有 Linux 开发者加入微软,这次是 systemd 的创建者 +====== + +> 看来微软拿了一手好牌,在 Linux 和开源方面取得行业成功。 + +![microsoft][1] + +出于某种原因,微软在开源和 Linux 方面总是受到关注。 + +而且,当我们谈论 Linux 开发者时,它也会成为焦点……为什么会这样? + +微软似乎正在为一系列的项目招聘大量 Linux 开发人员。而且,一个知名人物也加入了这个名单。 + +据 [Phoronix][2] 报道,systemd 和 PulseAudio 的创建者 **Lennart Poettering**,现在已在微软工作,继续专注于 systemd 的开发。 + +或许你不知道,Lennart 曾在红帽工作,领导 PulseAudio 项目和其他一些事情。 + +除了 Lennart 之外,Python 之父 **Guido Van Rossum** 等一些关键的开发人员之前就加入了微软。 + +(LCTT 译注:据 Phoronix 总结,还有更多的开源开发者加入了(或加入过)微软,这包括:GNOME 创建者 Miguel de Icaza 曾在 2016 年微软收购 Xamarin 时受雇,到今年早些时候离开;Nat Friedman 作为 Xamarin 的成员在微软收购后加入,后担任微软旗下的 GitHub 的 CEO;Gentoo Linux 创始人 Daniel Robbins 之前受雇于微软;Steve French 作为 Linux CIFS/SMB2/SMB3 的维护者和 Samba 团队的成员为微软工作;以及大量的上游 Linux 开发者,如 Matteo Croce、Matthew Wilcox、Tyler Hicks、Shyam Prasad N、Michael Kelley、Christian Brauner 等等也曾被微软雇佣。) + +### 微软在为最佳状态做准备 + +毫不奇怪,微软希望提高其对基于开源的项目的关注,并尽可能有效地利用 Linux 为其业务服务。 + +Azure 平台对开源的利用最多,而且,不要忘了 **Windows Subsystem for Linux**(WSL)。 + +因此,微软一直在招聘 Linux 开发人员。如果你想试试,你会在 [微软职业][3] 栏目中找到很多与 Linux 有关的职位。 + +虽然这对微软的产品线来说是一件大事,但它一般不会影响到 Linux 桌面用户。事实上,我认为,Linux 开发者得到的资源越多,由于他们工作角色转换,他们可以帮助 Linux 生态系统更好地增强其愿景。 + +当然,让所有关键的 Linux 开发者都在微软拥有的项目上工作并不是一件喜闻乐见的事情,但是,事实就是如此。 + +### 微软正在做正确的事情 + +这不仅仅是经济上的回报,Linux 开发者加入微软团队的趋势意味着他们在开源和 Linux 上的一些努力是成功的。 + +只要微软努力改善 Linux 生态系统,我认为我们就没有什么可担心的。 + +我不想被提醒“拥抱、扩展和熄灭Embrace, extend, and extinguish”(3E)。毕竟,这对所有公司来说都是生意。当涉及到赚钱的决定时,没有人应该被认为是英雄。 + +因此,我们只能希望微软在不久的将来为 Linux 开发者和用户准备好一些好东西。 + +你对此有何看法?在下面的评论区分享你的想法。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/systemd-creator-microsoft/ + +作者:[Ankush Das][a] +选题:[lkxed][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/ankush/ +[b]: https://github.com/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/07/more-linux-devs-joing-microsoft-systemd-creator-add-list.jpg +[2]: https://www.phoronix.com/scan.php?page=news_item&px=Systemd-Creator-Microsoft +[3]: https://careers.microsoft.com/us/en/search-results?keywords=Linux diff --git a/published/20220707 Raspberry Pi 4 Support is Coming to Fedora Linux.md b/published/20220707 Raspberry Pi 4 Support is Coming to Fedora Linux.md new file mode 100644 index 0000000000..d178afd6dd --- /dev/null +++ b/published/20220707 Raspberry Pi 4 Support is Coming to Fedora Linux.md @@ -0,0 +1,66 @@ +[#]: subject: "Raspberry Pi 4 Support is Coming to Fedora Linux" +[#]: via: "https://news.itsfoss.com/fedora-raspberry-pi-4/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14808-1.html" + +Fedora Linux 37 即将正式支持树莓派 4 +====== + +> 由于上游的一些改进,Fedora Linux 37 将引入对树莓派 4 的正式支持。 + +![Fedora raspberry pi][1] + +Fedora Linux 的工作站版很适合台式机使用。不过,如果你想让它用于服务器或物联网需求,可以使用 Fedora ARM 项目。 + +它也支持树莓派,只是最新的树莓派 4 除外(其实早在 2019 年就发布了)。 + +现在,随着 [Phoronix][2] 发现的一项拟议的变化,看起来 Fedora Linux 37 可能会正式增加对树莓派 4 的支持。 + +### 目前还不是正式的... + +到现在为止,对树莓派 4 的支持只是一个拟议的变化。 + +Fedora Linux 通常会公开其拟议的变化列表,以接受社区反馈并让其他人跟踪其进展。 + +所以,Fedora Linux 37 中的正式支持只有在得到 Fedora 工程指导委员会的批准后才会实施。 + +但是,**支持树莓派 4 的阻碍是什么呢?** + +这是由于缺乏加速图形以及缺失一些功能,所以不方便增加对它的支持。 + +现在,随着新的 Linux 内核和 Mesa 的上游工作为树莓派 4 带来了图形加速功能,可以让他们启用对它的支持。 + +拟议的变化文件中提到: + +> 上游现在支持使用 V3D GPU 的 OpenGL-ES 和 Vulkan 加速图形。对有线网络也有增强,支持 CM4/4B 上的 PTPv2。 + +此外,不仅仅是引入对树莓派 4 的支持,一些拟议的变化还涉及对树莓派 3 系列和 Zero 2 W 的改进。 + +因此,如果如人们所期望的那样发生,这应该是一个有趣的变化。 + +请注意,对树莓派 400 的 Wi-Fi 的支持不是这个过程的一部分,但对音频支持的测试将是这个变化的一部分。 + +你可以在 [拟议文件][3] 中阅读所有的细节。 + +你对 Fedora Linux 37 对树莓派 4 的支持有什么看法?请在下面的评论中分享你的想法。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/fedora-raspberry-pi-4/ + +作者:[Ankush Das][a] +选题:[lkxed][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/ankush/ +[b]: https://github.com/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/07/fedora-coming-to-raspberry-pi.jpg +[2]: https://www.phoronix.com/scan.php?page=news_item&px=Fedora-37-Raspberry-Pi-4 +[3]: https://fedoraproject.org/wiki/Changes/RaspberryPi4 diff --git a/published/20220708 Do You Miss Firefox Send- Internxt Send is Ready as a Replacement.md b/published/20220708 Do You Miss Firefox Send- Internxt Send is Ready as a Replacement.md new file mode 100644 index 0000000000..c1bc131418 --- /dev/null +++ b/published/20220708 Do You Miss Firefox Send- Internxt Send is Ready as a Replacement.md @@ -0,0 +1,68 @@ +[#]: subject: "Do You Miss Firefox Send? Internxt Send is Ready as a Replacement" +[#]: via: "https://news.itsfoss.com/internxt-send/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14822-1.html" + +怀念 Firefox Send 吗?不妨试试 Internxt Send 吧 +====== + +> Internxt 发布了一个新产品,它可以让你快速地将加密文件发送给任何人,同时保持你的隐私。嗯,我们只能希望它不会像 Firefox Send 那样关闭吧…… + +![Internxt][1] + +[Internxt][2] 是一个相当新的开源加密云服务,旨在取代大型科技公司的产品。例如,你可以把它作为谷歌的相册和云端硬盘的替代品。 + +它免费提供 10 GB 的容量。所以,如果感兴趣的话,你可以注册个账号试一试。 + +最近,他们还新增了另一个产品 “Internxt Send”,作为 Firefox Send 的替代品,填补这个空缺。 + +唉,说到这里还挺遗憾的,Firefox Send 已停止服务了,不得不说它是一个很好的工具! + +不过,[Internxt Send][3] 让你可以像 Firefox Send 一样安全地发送/共享图像、视频、文档和其他文件。 + +### Internxt Send:一个安全的文件共享服务 + +![][4] + +我在 GitHub 上找不到 Internxt Send 的存储库,但我已经要求他们澄清了。 + +(LCTT 译注:虽然 Internxt 是在 GitHub 上开源的,但是 GitHub 上没有 Internxt Send 这个产品的存储库,产品的介绍里也没有声称它是开源的。) + +正如你所期望的那样,你无需创建帐户即可将文件上传到 Internxt Send。 + +文件上传限制为 5 GB。而且,你不能以任何方式提高这个限制。 + +你可以选择文件,上传并生成共享链接。或者,你也可以直接向收件人发送电子邮件,那样的话,你需要在邮件里分享你的电子邮件地址。 + +![][5] + +有趣的是,它还允许你在这个电子邮件中添加自定义文本。 + +与 Firefox Send 不同的是,你无法修改文件共享链接的到期时间,或者是让它在多次下载后失效。默认情况下,链接会在 15 天后过期,你无法更改这个时间。嗯,这还挺扫兴的。 + +但是,对于那些正在苦苦等待一个加密的共享文件服务的人来说,这可能是一种替代方案。 + +*我认为有更多的 Firefox Send 替代品是件好事!你对 Internxt Send 有何看法?欢迎在下方评论区里和大家分享。* + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/internxt-send/ + +作者:[Ankush Das][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/07/internxt-send-ft-1.jpg +[2]: https://itsfoss.com/internxt-cloud-service/ +[3]: https://send.internxt.com/ +[4]: https://news.itsfoss.com/wp-content/uploads/2022/07/internxt-send-1024x640.png +[5]: https://news.itsfoss.com/wp-content/uploads/2022/07/internxt-send-screenshot-1024x782.png diff --git a/published/20220708 Meet Free Software Foundation Executive Director Zoë Kooyman.md b/published/20220708 Meet Free Software Foundation Executive Director Zoë Kooyman.md new file mode 100644 index 0000000000..15f63616b7 --- /dev/null +++ b/published/20220708 Meet Free Software Foundation Executive Director Zoë Kooyman.md @@ -0,0 +1,79 @@ +[#]: subject: "Meet Free Software Foundation Executive Director Zoë Kooyman" +[#]: via: "https://opensource.com/article/22/7/meet-fsf-executive-director-zoe-kooyman" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lkxed" +[#]: translator: "TravinDreek" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14844-1.html" + +自由软件基金会执行董事 Zoë Kooyman 专访 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/19/151615wnr8m4l8yotr6hp8.jpg) + +> 了解一下自由软件基金会(FSF)。 + +早在 1985 年,[自由软件基金会][2](FSF)就开始提倡源代码共享的理念,并从此打响了为计算机用户和开发者捍卫权利的斗争。FSF 认为,用“开放Open”和“封闭Closed”这两个词来划分软件,十分具有局限性;于是,在为程序分类时,转而使用了以下词语:*尊重自由*(这个“自由free”或这个“自由Libre”)或*践踏自由*(“非自由non-free”或“专有proprietary”)。不管用语如何,关键之处在于,计算机必须受用户控制,而不是任由开发了计算机软件的公司来摆布。正因如此,GNU 工程、Linux 内核、Freedesktop.org 等众多自由软件项目,才会如此重要。 + +最近,FSF 新上任了一位执行董事,她叫 Zoë Kooyman。我初见 Zoë 时,是在 2019 年的一个 [All Things Open][3] 大会上。当然,那个时候她还不是 FSF 的执行董事,不过已经在管理 FSF 不断增长的重大活动了 —— 包括 [LibrePlant][4]。她之前递给我了一份自由软件作者的名单,名单长得一眼望不尽,而且那些软件都是我*每天*在用的。由此,我也很受她那充沛的精力和诚恳的态度所打动。我只是偶然参加了一次 FSF 的聚会,但最后却和那些人成了朋友。是他们让我的数字生活有了意义,是他们保障了我能够拥有 Zoë 和 FSF 所说的 [四项基本自由][5]: + +* 无论用户出于何种目的,用户必须可以按照自己的意愿,自由地运行该软件(自由之零)。 +* 用户可以自由地学习并修改该软件,使它按照你的意愿进行计算(自由之一)。作为前提,用户必须可以得到该软件的源代码。 +* 用户可以自由地分发该软件的副本,这样就可以帮助别人(自由之二)。 +* 用户可以自由地分发该软件修改后的副本(自由之三)。借此,用户可以把改进后的软件分享给整个社区,令他人也从中受益。作为前提,用户必须可以得到该软件的源代码。 + +听说了 Zoë 受任为执行董事后,我给她发了一封邮件,提出想和她进行一次采访。她十分热心,在百忙之中抽出了一点时间来和我畅谈。 + +**Seth Kenlon:你当上 FSF 的执行董事了!你是怎么走到今天的呢?** + +**Zoë Kooyman:** 在我的工作生涯中,我最开始是一位活动组织者。我环游世界,举办着一些世界上最大的音乐节目。在不断变更的地点、各具特色的文化中工作,是十分有趣的,因为不管是演出、技艺还是别的现场元素,所有各异的制作元素都结合在一起了。让一切事物都在恰当时候安排到位,就像是耍杂技一样。很多时候,我都是在不同的国家生活和工作。多亏了我的工作,我才能学到这么多的组织和交流的技巧。我也对不同形式的媒体有过研究和工作,了解它们的体验,以及它们与社会的关系。 + +大学时期,我第一次了解到了“左版copyleft”(LCTT 译注:与版权copyright相对。是一种分享软件的思想和方法;简而言之,其目的是保障一款软件对其每一位接收者来说都是自由的),它是关于我们如何才能使用现有的结构来造福自己,并推动变革的。也正是在那时,媒体(以及互联网和软件)的格局开始迅速变化,而这种变化却是以自由为代价的。搬到美国后,我的生活变了许多。在美国,我对社会责任问题有了更加强烈的紧迫感,因此我决定为此付诸行动。我很感激 John Sullivan(时任 FSF 执行董事),他根据我对自由软件的了解以及我在活动组织方面的经验聘任了我,由此我也得以把这两方面的能力结合到一起。 + +**Seth:你是如何了解到自由软件的?** + +**Zoë:** 我们常常会觉得,自由软件主要影响的是懂技术的人。但是,自由软件运动的目的是捍卫每一位计算机用户的自由。其实,软件自由影响着边缘化社区(LCTT 译注:因条件受限或受到排斥等,落后于主流社会的发展,而被置于社会边缘的群体)的成员,他们很少有机会使用计算机。而软件也塑造了他们的生活。 + +GNU 工程和左版的概念所取得的成就是十分卓越的。去真正观察社会发展的方向,然后说:“不一定非得那样才行,我们可以把事情掌握在自己手中。”这在早期改变了我的人生观。我开始有了一种想法,把现有的材料用起来,再把它重新引入不同的亚文化之中。在娱乐行业,这已是家常便饭。从他人的作品中得到灵感,并基于此创造新的作品,其结果就是对我们所处时代的反映,同时也是对历史的致敬。没有这般自由,也不会有真正的进步。 + +谈谈我对电影版权的看法吧。我曾经与荷兰电影研究所合作,做了一个由许多“孤立的电影片段”组合而成的混剪。然后,在一次有几千名年轻人参加的大型舞蹈活动中,那个混剪就在一个 170 米的全景屏幕上播放了,而且还有现场 DJ 在配合演奏。他们之后也经常在别的活动中播放它,比如说荷兰的 博物馆之夜Museumnacht。 + +我并不懂技术,于是我通过文化来表达了这些观点。但这些年来,我越来越多地接触到了自由软件的思想。我于是意识到,随着软件不断融入我们的生活(有时还是身体),为自由软件而战的重要性正日益凸显。在当今的世界,专有软件处于称霸地位,我们社会的发展呈现出以利益驱动、为少数人着想的趋势,而这种趋势是以多数人的自由为代价的。如果没有自由软件,生活中的许多方面、社会的许多重要事业,就不可能真正取得成功。 + +**Seth:** 你是什么时候加入 FSF 的? + +**Zoë:** 在 2019 年初,LibrePlanet 最后一期现场版的前一周(LCTT 译注:LibrePlant 之后因为疫情而改成了线上活动)。 + +**Seth:** 是什么吸引了你去担任执行董事这一职位? + +**Zoë:** FSF 只是一个致力于让社会更加公平、更加协作、更加理解软件的组织,但它长期以来一直是这场运动的核心。社会正在迅速变化,而许多人却还没准备好如何应对当今社会的数字产物,例如软件。这是一项十分重要的工作,但是去做这项工作的人还是太少了。能有一个组织来应对未来的各种挑战,这是十分重要的。 + +执行董事这一职位,在某种程度上,不过是辅助工作人员和社区的角色,好让他们为自由软件作出关键的改变。我相信,我们继续传播自由软件的思想,是非常重要的;并且,有了 FSF 的团队协助,我也相信,我能利用好工作在不同文化和人群中的经验,以及组织高挑战性的全球项目的经验,来使我们发挥出最大的潜能。我的这项决定,得到了来自工作人员、管理层和社区和董事会的支持,由此我相信,这个决定是正确的。 + +**Seth:** 你认为当今的软件自由,面临的最大的挑战是什么?FSF 在应对这些挑战的时候,应该承担怎样的使命? + +**Zoë:** 随着软件越来越多地融入了社会的基本结构,软件也更加无形了。如今,软件的存在是如此的广泛,我们却习惯性地忽视它。我们只关注着程序的功能,却无视了实现这种功能的手段,更别说它尊不尊重你作为一位用户的自由了。而与此同时,软件又比以往任何时候都更快的扩散。如果人们无法理解程序是如何构成的,而只是整天地用着这些程序,那我们该怎么向他们解释,他们正遭受着不公呢? + +FSF 的职责就是,让每个人重新谈起用户自由,并提醒人们,我们所使用的工具并没有那么好。因此,教育行业和政府的认可是十分重要的。如果我们让人们关注软件自由在这些领域的问题,那我们必将取得成效。通过教育,我们可以确保后代也有选择自由的权利;而政府采用自由软件,可以保护公民免遭专有软件的不正影响(维护数字主权)。 + +我们可以告诉人们,当今社会给我们灌输了错误的观点:你的自由受到侵犯是正常的,毕竟事情“太复杂,你理解不了”。如果你想要图个便利,想要相互联系,或者就是想要满足你的需求,那你就得相信这些组织,按照他们的意愿来。这是不对的。我们整个社区都相信,我们能构建一个无需抛弃自由也能处在其中的社会。并且我们也有这样的法律框架来支持我们的观点。每天,不同背景、不同能力的人都加入我们的对话,越来越多的人关心自己的自由,并且每个人都是出于真心的。我们每天都在学习如何去保护自己以及他人,并且我也希望,未来能够更加自由。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/7/meet-fsf-executive-director-zoe-kooyman + +作者:[Seth Kenlon][a] +选题:[lkxed][b] +译者:[Peaksol](https://github.com/TravinDreek) +校对:[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/lkxed +[1]: https://opensource.com/sites/default/files/dandelion_zoom.jpg +[2]: https://www.fsf.org/ +[3]: https://www.allthingsopen.org/ +[4]: https://libreplanet.org +[5]: https://www.gnu.org/philosophy/free-sw.en.html diff --git a/published/20220708 Meta-s AI Model That Helps Overcome Language Barrier Is Now Open-Source.md b/published/20220708 Meta-s AI Model That Helps Overcome Language Barrier Is Now Open-Source.md new file mode 100644 index 0000000000..df302ffce7 --- /dev/null +++ b/published/20220708 Meta-s AI Model That Helps Overcome Language Barrier Is Now Open-Source.md @@ -0,0 +1,69 @@ +[#]: subject: "Meta’s AI Model That Helps Overcome Language Barrier Is Now Open-Source" +[#]: via: "https://news.itsfoss.com/meta-open-source-ai-model/" +[#]: author: "Rishabh Moharir https://news.itsfoss.com/author/rishabh/" +[#]: collector: "lkxed" +[#]: translator: "fenglyulin" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14812-1.html" + +Meta 开源了语言翻译 AI 模型 +====== + +> Meta 的 “不落下任何语言No Language Left Behind” 是一个宏大的开源项目,旨在以最高准确度翻译语言。 + +![meta][1] + +Meta(前身是 Facebook)在开源世界做出了不小的贡献。Meta 除了专注于元宇宙Metaverse和其社交媒体平台外,还致力于各种研究和创新工作,比如 React(一个 JaveScript 库)。 + +现在,Meta 的研究人员决定开源一个叫 “不落下任何语言No Language Left Behind” 项目。 + +(LCTT 校注:这个直译项目名称不够好听,我来抛砖引玉,似可称做“无人独语”,读者有什么建议吗?) + +### Meta 试图不落下任何语言 + +![200 languages within a single AI model: A breakthrough in high-quality machine translation][2] + +目前,虽然世界上有大约 7000 个在使用中的语言,但大多数在线的内容都是以少数的流行语言来提供的,比如英语。这让许多不懂这些语言的人处于不利的地位。 + +虽然现存的许多翻译工具,但语法错误会让错误变得难以阅读和理解。另外,如果你想把内容翻译为一个不流行的语言(特别是非洲和亚洲的一些语言),翻译体验不会很好。 + +因此,Meta 正在开发有最高质量的翻译工具,可以帮助解决这一全球性的问题。 + +NLLB-200(不落下任何语言No Language Left Behind) 是一个人工智能翻译模型,其可以翻译 200 多种语言。该模型在每种语言中的翻译结果是通过一个名为 FLORES-200 复杂数据集来确定和评估的。 + +正如 Meta 所说,NLLB 的翻译结果比以前的人工智能研究方法好 40% 。对于一些最不常见的语言,其翻译准确率甚至超过 70%。了不起的工作! + +为了帮助开发项目和提高模型的翻译质量,Meta 向所有感兴趣的研究人员开放了源代码,包括 NLLB-200 模型、FLORES-200 数据库、模型训练和重建训练数据库的代码。 + +你可以在 [GitHub][3] 上找到源代码,并且可以在该项目的 [博客][4] 上了解它的更多信息。 + +### 对社会事业的鼓励 + +Meta 宣布向从事联合国可持续发展目标UN Sustainable Development Goals任何领域工作和翻译非洲语言的非营利组织和研究人员提供高达 20 万美元的捐赠,也鼓励其他学术领域如语言学和机器翻译的研究人员申请。 + +### 项目的影响 + +尽管 Meta 主要打算在其数字平台上,特别是在“元宇宙”上使用 NLLB,但 NLLB 也有可能在其他领域产生巨大影响。 + +许多用户可以用他们的母语轻松地访问和阅读在线资源。项目开源后,社区应该能够帮助实现这个目标。 + +*你对 Meta 的这个项目有什么看法?* + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/meta-open-source-ai-model/ + +作者:[Rishabh Moharir][a] +选题:[lkxed][b] +译者:[fenglyulin](https://github.com/fenglyulin) +校对:[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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/07/meta-makes-ai-language-model-opensource.jpg +[2]: https://youtu.be/uCxSPPiwrNE +[3]: https://github.com/facebookresearch/fairseq/tree/nllb +[4]: https://ai.facebook.com/blog/nllb-200-high-quality-machine-translation/ diff --git a/published/20220709 Monitoring tiny web services.md b/published/20220709 Monitoring tiny web services.md new file mode 100644 index 0000000000..1b57dfc0d3 --- /dev/null +++ b/published/20220709 Monitoring tiny web services.md @@ -0,0 +1,141 @@ +[#]: subject: "Monitoring tiny web services" +[#]: via: "https://jvns.ca/blog/2022/07/09/monitoring-small-web-services/" +[#]: author: "Julia Evans https://jvns.ca/" +[#]: collector: "lujun9972" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14840-1.html" + +如何监测微型的网站服务 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/18/105829gzviausw5wg7wwxb.jpg) + +你好! 我最近又开始运行一些服务器([nginx playground][1]、[mess with dns][2]、[dns lookup][3]),所以我一直在考虑监控问题。 + +最初我并不完全清楚如何监控这些网站,所以我想快速写下我是如何做到的。 + +我根本不打算谈如何监控大型的、严肃的关键任务网站,只谈微型的不重要的网站。 + +### 目标:在操作上几乎不花时间 + +我希望网站大部分时间都能正常工作,但我也希望不用在持续的运营上花费时间。 + +我最初对运行服务器非常警惕,因为在我的上一份工作中,我是 24/7 轮流值班,负责一些关键的服务,在我的印象中,“负责服务器”意味着“在凌晨 2 点被叫起来修理服务器”和“有很多复杂的仪表盘”。 + +所以有一段时间我只做静态网站,这样我就不用考虑服务器的问题。 + +但最终我意识到,我所要写的任何服务器的风险都很低,如果它们偶尔宕机 2 小时也没什么大不了的,我只需设置一些非常简单的监控来帮助它们保持运行。 + +### 没有监控很糟糕 + +起初,我根本没有为我的服务器设置任何监控。这样做的结果是非常可预见的:有时网站坏了,而我却没有发现,直到有人告诉我! + +### 步骤 1:uptime 检查器 + +第一步是建立一个 uptime 检查器。外面有很多这样的东西,我现在使用的是 [updown.io][4] 和 [uptime robot][5]。我更喜欢 updown 的用户界面和 [定价][6] 结构(它是按请求而不是按月收费),但 uptime 机器人有一个更慷慨的免费套餐。 + +它们会: + + 1. 检查网站是否正常 + 2. 如果出现故障,它会给我发电子邮件 + +我发现电子邮件通知对我来说是一个很好的通知级别,如果网站宕机,我会很快发现,但它不会吵醒我或做其它的什么打扰。 + +### 步骤 2:端到端的健康检查 + +接下来,让我们谈谈“检查网站是否正常”到底是什么意思。 + +起初,我只是把我的健康检查端点之一变成一个函数,无论如何都会返回 `200 OK`。 + +这倒是挺有用的 – 它告诉我服务器是启动着的! + +但不出所料,我遇到了问题,因为它没有检查 API 是否真的在 _工作_ – 有时健康检查成功了,尽管服务的其他部分实际上已经进入了一个糟糕的状态。 + +所以我更新了它,让它真正地发出 API 请求,并确保它成功了。 + +我所有的服务都只做了很少的事情(nginx playground 只有一个端点),所以设置一个健康检查是非常容易的,它实际上贯穿了服务应该做的大部分动作。 + +下面是 nginx playground 的端到端健康检查处理程序的样子。它非常基本:它只是发出一个 POST 请求(给自己),并检查该请求是成功还是失败。 + +``` + + func healthHandler(w http.ResponseWriter, r *http.Request) { + // make a request to localhost:8080 with `healthcheckJSON` as the body + // if it works, return 200 + // if it doesn't, return 500 + client := http.Client{} + resp, err := client.Post("http://localhost:8080/", "application/json", strings.NewReader(healthcheckJSON)) + if err != nil { + log.Println(err) + w.WriteHeader(http.StatusInternalServerError) + return + } + if resp.StatusCode != http.StatusOK { + log.Println(resp.StatusCode) + w.WriteHeader(http.StatusInternalServerError) + return + } + w.WriteHeader(http.StatusOK) + } + +``` + +### 健康检查频率:每小时一次 + +现在,我大部分健康检查每小时运行一次,有些每 30 分钟运行一次。 + +我每小时运行一次,因为 updown.io 的定价是按健康检查次数计算的,我正在监控 18 个不同的 URL,而且我想把我的健康检查预算保持在 5 美元/年的最低水平。 + +花一个小时来发现这些网站中的一个出现故障,对我来说是可以的 – 如果有问题,我也不能保证能很快修复它。 + +如果可以更频繁地运行它们,我可能会每 5-10 分钟运行一次。 + +### 步骤 3:第三步:如果健康检查失败,自动重新启动 + +我的一些网站在 fly.io 上,fly 有一个相当标准的功能,我可以为一个服务配置一个 HTTP 健康检查,如果健康检查失败,就重新启动服务。 + +“经常重启”是一个非常有用的策略来弥补我尚未修复的 bug,有一段时间,nginx playground 有一个进程泄漏,`nginx` 进程没有被终止,所以服务器的内存一直在耗尽。 + +通过健康检查,其结果是,每隔一天左右就会发生这样的情况: + + * 服务器的内存用完了 + * 健康检查开始失败 + * 它被重新启动 + * 一切又正常了 + * 几个小时后再次重复整个传奇 + +最终,我开始实际修复进程泄漏,但很高兴有一个解决方法可以在我拖延修复 bug 时保持运行。 + +这些用于决定是否重新启动服务的运行状况检查更频繁地运行:每 5 分钟左右。 + +### 这不是监控大型服务的最佳方式 + +这可能很明显,我在一开始就已经说过了,但是“编写一个 HTTP 健康检查”并不是监控大型复杂服务的最佳方法。 但我不会深入讨论,因为这不是这篇文章的主题。 + +### 到目前为止一直运行良好! + +我最初在 3 个月前的四月写了这篇文章,但我一直等到现在才发布它以确保整个设置正常工作。 + +这带来了很大的不同 – 在我遇到一些非常愚蠢的停机问题之前,现在在过去的几个月里,网站的运行时间达到了 99.95%! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2022/07/09/monitoring-small-web-services/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://nginx-playground.wizardzines.com +[2]: https://messwithdns.net +[3]: https://dns-lookup.jvns.ca +[4]: https://updown.io/ +[5]: https://uptimerobot.com/ +[6]: https://updown.io/#pricing diff --git a/published/20220710 How to Install yay AUR Helper in Arch Linux [Beginner-s Guide].md b/published/20220710 How to Install yay AUR Helper in Arch Linux [Beginner-s Guide].md new file mode 100644 index 0000000000..71da71927e --- /dev/null +++ b/published/20220710 How to Install yay AUR Helper in Arch Linux [Beginner-s Guide].md @@ -0,0 +1,167 @@ +[#]: subject: "How to Install yay AUR Helper in Arch Linux [Beginner’s Guide]" +[#]: via: "https://www.debugpoint.com/install-yay-arch/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14846-1.html" + +初级:如何在 Arch Linux 中安装 Yay AUR 助手 +====== + +![](https://www.debugpoint.com/wp-content/uploads/2021/01/yay2021.jpg) + +> 这个初学者指南解释了在 Arch Linux 中安装 Yay AUR 助手的步骤。 + +Yay 是 “Yet Another Yogurt” 的缩写(LCTT 校注:Yogurt 是另外一个已经停止维护的 AUR 助手)。从技术上讲,它是用 [Go 编程语言][2] 编写的 [pacman][1] 封装器和 AUR 助手。它是当今最流行的 [Arch 用户仓库(AUR)][3] 助手。使用 Yay,你可以利用庞大的 Arch 用户软件包库并轻松编译和安装任何软件。 + +它可以自动执行许多包管理任务,例如搜索、动态解决依赖关系、编译和构建包,当然还有在 AUR 发布包。 + +让我们看看如何在 Arch Linux 或任何基于 Arch 的发行版(如 Manjaro)中安装 Yay。安装 Arch Linux 后,你可以通过 pacman 包管理器从三个主要的 Arch 官方仓库安装包。但是在全新的 Arch Linux 安装后,默认情况下不会安装 Yay。因此,你需要手动安装它以利用 AUR。 + +本指南涵盖以下主题: + +* 在 Arch Linux 中安装 Yay +* 在 Manjaro 中安装 Yay +* 如何在 Arch Linux 和 Manjaro 中使用 Yay 安装包 +* 一些 Yay 的技巧 + +### 在 Arch Linux 中安装 Yay + +#### 先决条件 + +打开终端并运行以下命令。出现提示时提供管理员密码。这些步骤需要 [base-devel][4] 包和 git 包进行编译和安装。 + +``` +sudo pacman -S base-devel +``` + +``` +sudo pacman -S git +``` + +![Install git][5] + +#### 安装 Yay + +`yay` 包在 Arch 仓库中有两个版本,如下所示。 + +- [yay][6] – 稳定版 +- [yay-git][7]– 开发版 + +对于本指南,我使用了稳定版。现在,进入 `/opt` 目录并克隆 git 仓库。 + +``` +cd /opt +sudo git clone https://aur.archlinux.org/yay.git +``` + +![clone the yay repo][8] + +更改源目录的所有者。将 `debugpoint` 替换为你的用户名。 + +``` +sudo chown -R debugpoint:users ./yay +``` + +如果你不知道用户或组,可以使用以下示例查找用户和组。 + +``` +id debugpoint +``` + +进入目录并编译。 + +``` +cd yay +``` + +``` +makepkg -si +``` + +这样就完成了 Arch Linux 中 Yay 的安装。 + +![Install yay in Arch Linux][9] + +### 在 Manjaro 中安装 Yay + +如果你使用 Manjaro Linux,`yay` 包可以在社区仓库中找到。你可以在 Manjaro 中使用以下命令轻松安装。 + +``` +pacman -Syyupacman -S yay +``` + +现在,让我们看看如何使用 Yay 安装任何软件包,以及一些基本的 `yay` 用法。 + +### 如何使用 Yay 安装包 + +首先在 AUR 网站上搜索安装任何应用以获取包名。例如,要安装 [featherpad][10] 文本编辑器,请运行以下命令。 + +``` +yay -S featherpad +``` + +安装后,你可以在应用菜单中找到应用启动器。 + +![Install a sample application (featherpad) using yay][11] + +### 一些 Yay 的技巧 + +你还可以使用 yay 进行许多调整和系统操作。下面是一些示例。 + +**刷新系统包并升级**: + +``` +yay -Syu +``` + +**使用包的开发版本并升级(运行此命令时要小心)**: + +``` +yay -Syu --devel --timeupdate +``` + +**删除任何包(例如,featherpad)**: + +``` +yay -Rns featherpad +``` + +**快速获取系统统计信息**: + +![system stat using yay][12] + +``` +yay -Ps +``` + +我希望这个初学者指南能帮助你在 [Arch Linux][13] 中安装 Yay,然后使用 Yay 安装包,并执行不同的系统操作。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/install-yay-arch/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://wiki.archlinux.org/index.php/pacman +[2]: https://golang.org/ +[3]: https://wiki.archlinux.org/index.php/Arch_User_Repository +[4]: https://aur.archlinux.org/packages/meta-group-base-devel/ +[5]: https://www.debugpoint.com/wp-content/uploads/2021/01/Install-git-1024x291.png +[6]: https://aur.archlinux.org/packages/yay/ +[7]: https://aur.archlinux.org/packages/yay-git/ +[8]: https://www.debugpoint.com/wp-content/uploads/2021/01/clone-the-yay-repo-1024x271.png +[9]: https://www.debugpoint.com/wp-content/uploads/2021/01/Install-yay-in-Arch-Linux-1024x460.png +[10]: https://aur.archlinux.org/packages/featherpad-git/ +[11]: https://www.debugpoint.com/wp-content/uploads/2021/01/Install-a-sample-application-featherpad-using-yay-1024x620.png +[12]: https://www.debugpoint.com/wp-content/uploads/2021/01/system-stat-using-yay.png +[13]: https://www.debugpoint.com/tag/arch-linux/ diff --git a/published/20220711 7 Reasons Why Ubuntu 22.04 LTS is the Most Secure Release Yet.md b/published/20220711 7 Reasons Why Ubuntu 22.04 LTS is the Most Secure Release Yet.md new file mode 100644 index 0000000000..921d3e23c5 --- /dev/null +++ b/published/20220711 7 Reasons Why Ubuntu 22.04 LTS is the Most Secure Release Yet.md @@ -0,0 +1,141 @@ +[#]: subject: "7 Reasons Why Ubuntu 22.04 LTS is the Most Secure Release Yet" +[#]: via: "https://news.itsfoss.com/reasons-ubuntu-22-04-secure/" +[#]: author: "Jacob Crume https://news.itsfoss.com/author/jacob/" +[#]: collector: "lkxed" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14820-1.html" + +Ubuntu 22.04 LTS 是目前最安全的版本的七大原因 +====== + +> Ubuntu 22.04 LTS 是迄今为止最好的 Ubuntu 版本之一。是什么让它如此安全? + +![ubuntu 22.04][1] + +早在今年 4 月就发布了的 [Ubuntu 22.04 LTS][2],是迄今为止最安全的 Ubuntu 版本。 + +其安全更新的延长支持、新的硬件支持和其他林林总总的改进,使它在安全方面远远超过了之前的所有版本。 + +但它是如何做到这一点的呢?还有,是什么让这个版本与以前的版本不同的呢? + +嗯,有几个原因,Canonical 在一篇新的博客文章中为我们重点指出了这些。在这里,让我总结一下,以帮助你了解更多。 + +### 是什么让 Ubuntu 22.04 LTS 变得安全? + +在这个版本中,Ubuntu 团队似乎投入了大量的工作来确保其长期的安全性和可靠性。尽管多年来他们以难以想象的方式做到了这一点,但我将强调其中的几件事: + +* 改进的硬件安全措施支持 +* 更新了安全包 +* 私有家目录 +* OpenSSL 3 +* GCC 11 +* nftables 作为默认的防火墙后端 +* Linux 内核改进 + +#### 1、改进的硬件安全措施支持 + +![][3] + +随着英特尔、AMD 和 ARM 的 CPU/SoC 开始推出更多的安全措施,拥有足够的软件来让这些功能发挥作用就变得越来越重要。 + +截至目前,Ubuntu 22.04 支持三种主要的硬件安全措施。 + +英特尔的 “软件保护扩展Software Guard eXtensions”(SGX)提供了一个安全独立的区域来进行敏感计算。例如,理想情况下,密码处理将在这里进行,因为它确保没有其他应用程序可以访问这些数据。 + +还有 AMD 的“安全加密虚拟化Secure Encrypted Virtualization”(SEV)。这项技术旨在防止主机操作系统干扰正在运行的虚拟机。 + +尽管这与桌面用户的相关性不如其他技术,但要知道,很多数据中心的基础设施都依赖虚拟机来实现应用的容器化。总的来说,此类针对硬件的安全措施应该会加强对桌面和服务器用户的保护。 + +#### 2、Linux 内核安全的改进 + +随着 Ubuntu 的每一次发布,Linux 内核都会得到升级,提供了许多有用的功能和支持。 + +但是,这一次,Canonical 推出了针对不同的平台的优化内核版本。对于 OEM 认证的桌面设备,它提供了 [Linux 内核 5.17][4]。 + +而对于所有的桌面和服务器用户,可以使用 [Linux 内核 5.15 LTS][5]。 + +不仅仅限于这个概念,在 [博文][6] 中提到的一些基本内核安全增强措施包括: + +* 支持 [核心调度][7],它允许进程控制哪些线程可以在 SMT 同级之间调度,以便让它们保护敏感信息,而不泄露给系统中其他不受信任的进程。 +* 内核堆栈随机化提供了一种加固措施,以挫败希望在内核内进行内存破坏攻击的攻击者。 +* BPF 子系统也有一些安全方面的增强,包括默认情况下限制为只有特权进程可以使用,以及对签名的 BPF 程序的初步支持。 +* 新的 Landlock Linux 安全模块的加入为应用程序沙箱提供了另一种机制,可以通过 AppArmor 或 SELinux 与更传统的方式结合使用。 + +总之,所有这些改进使 Ubuntu 22.04 LTS 成为开发者、用户和系统管理员的更安全的选择。 + +#### 3、更新的安全软件包 + +![][8] + +让我们从技术性的安全概念退后一步,回到每个 Ubuntu 用户都应该已经熟悉的概念:软件包。每一个新的 Ubuntu 版本,软件库中的大多数软件包都会更新,以带来更好的安全性和新功能。 + +尽管对于 Ubuntu 22.04 来说,这并不完全是新的东西,但这确实包括了很多安全方面的更新。这方面的例子包括 openSSL 3 和 GCC 11。 + +#### 4、OpenSSL 3 + +OpenSSL 是所有安全通信的支柱。 + +考虑到包括 MD2 和 DES 在内的许多传统算法已经被废弃并默认禁用,OpenSSL 3 作为一个重大的升级特别值得关注。 + +因此,除非用户特别想使用不太安全的算法,否则你将在默认情况下获得最好的安全性。 + +#### 5、GCC 11 + +另一方面,GCC 是许多开发者用来将他们的代码变成可以在你的计算机上运行的程序的编译器。 + +它带来了许多改进,但有一项特别显著地提高了安全性。静态分析得到了极大的加强,使开发人员能够更快地发现软件的漏洞,在第一步就防止有漏洞的代码被发布。 + +这可能不会直接影响到用户,许多开发人员使用 Ubuntu 来开发他们的应用程序。因此,你下载的很多程序,即使在非 Ubuntu 系统上,也应该比以前更安全。 + +#### 6、私有家目录 + +![][9] + +作为一个传统上以桌面为重点的发行版,Ubuntu 经常选择方便而不是安全。然而,随着他们越来越努力地推动云计算的采用,这种情况必须改变。 + +以前,任何有权限进入电脑的人都可以打开并查看任何用户的家目录。然而,你可以想象,这给非桌面用户带来了很多问题。因此,需要改变为私有家目录。 + +对于多用户系统来说,这可能稍显不方便,但这可以相对容易地改变。而且,对于那些不太熟悉技术的人来说,他们不需要做任何事情就可以得到更好的安全保障。 + +#### 7、nftables 作为默认防火墙后端 + +![][10] + +25 年来,防火墙一直是将你的计算机与更广泛的互联网隔离开来的一个关键部分。这些年来,Linux 发行版通常使用两种不同的防火墙解决方案:iptables 和 xtables。 + +然而,近些年来,一种不同的解决方案进入了人们的视野:nftables。它提供了显著的性能和灵活性的改进,使网络管理员能够更好地保护你的设备。 + +### 总结 + +毋庸置疑,Ubuntu 22.04 LTS 做了很多不错的升级。不仅仅是用户体验,它在安全方面也是一个重大的飞跃。 + +当然,还有更多,但上面提到的改进是很好的成就! + +关于更多的技术细节,你可以查看这篇 [Ubuntu 的官方博客文章][11]。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/reasons-ubuntu-22-04-secure/ + +作者:[Jacob Crume][a] +选题:[lkxed][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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/07/ubuntu-22-04-is-most-secure-release.jpg +[2]: https://news.itsfoss.com/ubuntu-22-04-release/ +[3]: https://news.itsfoss.com/wp-content/uploads/2022/07/hardware-security-illustration-1024x576.jpg +[4]: https://news.itsfoss.com/linux-kernel-5-17-release/ +[5]: https://news.itsfoss.com/linux-kernel-5-15-release/ +[6]: https://ubuntu.com/blog/whats-new-in-security-for-ubuntu-22-04-lts +[7]: https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/core-scheduling.html +[8]: https://news.itsfoss.com/wp-content/uploads/2021/07/open-source-security-illustration-1024x576.png +[9]: https://news.itsfoss.com/wp-content/uploads/2021/04/private-home-directory-ubuntu-21.png +[10]: https://news.itsfoss.com/wp-content/uploads/2022/07/firewall-illustration-1024x576.jpg +[11]: https://ubuntu.com/blog/whats-new-in-security-for-ubuntu-22-04-lts diff --git a/published/20220711 Manual Renewal of SSL Certificates- A Simple Guide.md b/published/20220711 Manual Renewal of SSL Certificates- A Simple Guide.md new file mode 100644 index 0000000000..fde96a948b --- /dev/null +++ b/published/20220711 Manual Renewal of SSL Certificates- A Simple Guide.md @@ -0,0 +1,80 @@ +[#]: subject: "Manual Renewal of SSL Certificates: A Simple Guide" +[#]: via: "https://www.opensourceforu.com/2022/07/manual-renewal-of-ssl-certificates-a-simple-guide/" +[#]: author: "Jitendra Bhojwani https://www.opensourceforu.com/author/jitendra-bhojwani/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14838-1.html" + +手动续订 SSL 证书的简单指南 +====== + +![SSL-Certificates-Featured-image][1] + +*在本杂志 2022 年 4 月号中,我们了解了不同类型的 SSL 证书及其应用。本文介绍如何手动更新现有 SSL 证书,以使其保持最新的安全要求。* + +当访问者与你的网站互动并分享信用卡号码等关键细节时,他们相信他们的信息已得到保护,不会被滥用。因此,你有责任尊重这种信任并为你网站上的所有访问者提供全面保护。不这样做不仅会使你失去客户的忠诚度,而且还可能使你陷入法律困境。在许多情况下,无法保护客户数据免遭泄露、盗窃或滥用的网站被迫支付巨额罚款,同时也失去了声誉。 + +#### SSL 证书如何保护客户的数据? + +保护敏感客户信息的最佳方法之一是使用 SSL(安全套接字层)证书保护你的站点。用不涉及技术细节的话来说,SSL 证书对 Web 服务器和访问者浏览器之间的通信进行加密,从而使黑客或威胁参与者在技术上不可能窃取传输中的数据。 SSL 建立了一个安全的握手过程来解密加密的信息,这个过程太复杂了,人类甚至软件都无法破解。(LCTT 校注:此处言过其实,SSL 加密传输的信息并不是绝对不可截获和破解的,比如中间人攻击等。) + +#### 为什么需要更新 SSL 证书? + +虽然 SSL 证书提供了防止数据盗窃或滥用的安全性,但你需要定期更新它以确保最有效的安全性以抵御最新的威胁。本文将列出以正确方式更新 SSL 证书的分步说明。 + +更新 SSL 证书有很多好处: + +* 及时更新验证你的网站的身份。 +* 获得更新的安全性。 +* 一年有效期促进定期更新/升级保护范围的健康实践,从而消除与过时版本相关的风险。 + +> 注意:最佳做法是选择一种自动续订方式,以减轻你记住续订日期或手动执行相关步骤的压力。 + +#### 有点跑题了,构建你自己的 SSL 证书的纯开源方式 + +是的,这绝对是真的!通过一些简化和紧凑的步骤,你实际上可以从头开始构建自己的 SSL 证书!虽然整个过程超出了本文的范围,但这里有一些可用于创建 SSL 证书的关键开源组件和工具。 + +* OpenSSL:这是实现 TLS 和加密库的高度可信的工具。 +* EasyRSA:此命令行工具使你能够构建 PKI CA 并有效地管理它。 +* CFSSL:Cloudflare 终于为 PKI 和 TLS 构建了一个多用途、多功能的工具。 +* Lemur:由 Netflix 开发的还不错的 TLS 生成器。 + +### 如何更新你的 SSL 证书 + +虽然 [SSL][2] 更新的一般过程保持不变,但可能会有一些细微的调整和变化,具体取决于你的特定 SSL 提供商。 + +更新过程遵循三个主要步骤:CSR(证书签名请求)生成、证书激活,最后是证书安装。 + +**生成 CSR:** 对于 cPanel 托管面板,你可以单击“安全Security”选项卡并搜索 *SSL/TLS* 选项。它将显示一个页面,在 CSR 选项下方有一个链接。这里可以帮助你为所需的域名生成新的 CSR。 + +系统将询问你详细的联系信息,以确认你是真正的域所有者。填写表格后,你将获得证书重新激活所需的 CSR 代码。 + +**激活 SSL 证书:** 在你的仪表板中,你可以快速查看拥有的 SSL 证书、域和其他数字基础设施产品。单击该按钮开始 SSL 续订过程。输入之前生成的 CSR,确认信息的准确性。你现在可以验证 SSL 续订过程。 + +**验证 SSL 证书:** 系统将再次提示你确认域所有权 —— 输入与域相关的电子邮件;在需要安装证书的 Web 服务器上上传文件;借助 CNAME 记录验证 SSL 证书等等。虽然有多种选择,但最好和最简单的方法是通过电子邮件进行验证。输入与该域关联的电子邮件后,你将收到一封包含特定链接的电子邮件,然后是另一封邮件,其中包含带有 `.crt` 扩展名的新证书文件。 + +**安装 SSL 证书:** 你的主机托管商将为你提供与支持团队沟通的方式,以安装更新文件,或为你提供有关如何通过 cPanel 手动执行此操作的详细说明。请记住,不同的主机提供不同的续订方式。也就是说,如果你是非技术人员,那么联系支持团队将是你的最佳选择。 + +如需手动更新,请访问 cPanel 的 “SSL/TLS” 页并找到 “管理 SSL 站点Manage SSL sites”选项。它包含了你拥有的整个域列表。对应每个域名,你可以看到证书更新选项。 + +在旁边的页面中,使用“按域自动填写Autofill by Domain”选项输入“私钥Private Key”的详细信息。在 “证书Certificate” 选项下,填写你的 `.crt` 文件的详细信息。离完成就剩一步了。只需单击显示“安装证书Install Certificate”的按钮。 + +除了保存用户的关键数据和敏感信息外,SSL 证书还通过重申你网站上共享的数据是安全的来建立信任。由于谷歌认为 SSL 认证是一种健康的做法,因此它也会对你的 SEO 产生积极影响。但是,要继续享受此证书的最佳安全性,你需要定期更新它。这可以确保你的网站根据最新的安全要求,充分防止数据传输中的攻击。 + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/07/manual-renewal-of-ssl-certificates-a-simple-guide/ + +作者:[Jitendra Bhojwani][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/jitendra-bhojwani/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/05/SSL-Certificates-Featured-image.jpg +[2]: https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwitou7xjv_3AhWLRmwGHVZ2BWwQFnoECB0QAQ&url=https%3A%2F%2Fgithub.com%2Fopenssl%2Fopenssl&usg=AOvVaw0niwMRCpb4nN_PtJFMQwWP diff --git a/published/20220711 Nokia Targets An Amateur Linux Phone Project -NOTKIA- for a Name Change.md b/published/20220711 Nokia Targets An Amateur Linux Phone Project -NOTKIA- for a Name Change.md new file mode 100644 index 0000000000..927aaa8b2f --- /dev/null +++ b/published/20220711 Nokia Targets An Amateur Linux Phone Project -NOTKIA- for a Name Change.md @@ -0,0 +1,87 @@ +[#]: subject: "Nokia Targets An Amateur Linux Phone Project ‘NOTKIA’ for a Name Change" +[#]: via: "https://news.itsfoss.com/nokia-notkia/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14837-1.html" + +诺基亚勒令一个开源 Linux 手机项目 “NOTKIA” 改名字 +====== + +> 有一个想要为你带来一款诺基亚风格的 Linux 手机的开源项目,但诺基亚似乎并不喜欢这个项目的名字。 + +![诺基亚][1] + +近期,一个旨在打造经典诺基亚(小型)的 Linux 手机的开源项目,遭到了诺基亚的抨击。 + +该项目的名称最初是 “**Notkia**”,然而,诺基亚认为该名称与自己相似,可能会影响自己的品牌声誉,并侵犯到自己的权利。 + +虽然这样做可以保护公司的业务,但这些公司向在当前状态下甚至对他们构不成威胁的项目发送侵权通知是怎么回事? + +### Notkia:开发一款袖珍 Linux 手机 + +不过还得 *感谢* 诺基亚的这个侵权通知,我们才能了解到这个有趣的项目:开发一款满足基本使用、注重隐私的小型 Linux 手机。 + +该项目的目标是设计一个完全适合诺基亚经典手机外壳的 PCB。 + +![][2] + +到目前为止,该项目已经支持许多硬件相关的功能,包括蓝牙和 Wi-Fi。 + +该项目不基于安卓,而是基于主线 Linux 内核。 + +你可以在他们的 [官方博文][3] 中,了解有关该项目和计划中的手机规格。 + +目前,该项目正在等待筹款,以便可以单独购买早期原型机。 + +### 灵感来自诺基亚,并受到诺基亚的关注 + +嗯,该项目清楚地表明他们受到诺基亚经典手机的启发,他们并没有试图误导任何贡献者和潜在客户。 + +该项目的创建者在推特上分享了诺基亚的电子邮件,同时他提到,诺基亚在将此类通知发送给以社区利益为主导的项目之前,应该更谨慎一些才对。 + +> 再次阅读 [@Nokia][4] 的邮件后,我开始感到愤怒。这无非是一场精心策划的演出。既然它是一个协作项目,并且得到了世界各地的人们的贡献,因此,我将把完整的电子邮件发布给它的“预期收件人”。 +> +> ![来自推特 @ReimuNotMoe][5] + +**此外,他们确认该项目将更名。** + +当然,作为一个开源项目,它应该和诺基亚是扯不上关系的,除非他们使用诺基亚的品牌名称销售他们的原型/手机。 + +但是,在目前的状态下,这更像是一个激情项目,是开源爱好者社区协作努力的成果。因此,向他们发出侵犯诺基亚权利的通知,听起来实在有些牵强。 + +*对吗?* + +当然,对于一般企业来说,这并不奇怪;但对于诺基亚来说,这未免有点过于谨慎和反竞争了。 + +更何况,我们可以肯定地说,诺基亚的最新的智能手机的表现,并没有达到用户的预期。 + +有趣的是,一位推特用户发现,还有一家名为 “Notkia” 的 [IT 公司][7]。他们是否也收到了诺基亚的通知?呵呵,谁知道呢。 + +*那么,你如何看待这个基于 Linux 的袖珍手机的开源项目呢?在下面的评论中分享你的看法吧!* + +消息来源:[Vice][8] + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/nokia-notkia/ + +作者:[Ankush Das][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[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/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/07/nokia-targets-linux-phone-notkia.jpg +[2]: https://news.itsfoss.com/wp-content/uploads/2022/07/notkia-nokia-1024x766.jpg +[3]: https://hackaday.io/project/185645-notkia-name-change-planned +[4]: https://twitter.com/nokia?ref_src=twsrc%5Etfw +[5]: https://pbs.twimg.com/media/FWftWyjUYAA49ew?format=jpg&name=large +[6]: https://twitter.com/ReimuNotMoe/status/1542466662154108930?ref_src=twsrc%5Etfw +[7]: https://www.linkedin.com/company/notkia-it/ +[8]: https://www.vice.com/en/article/93awjz/nokia-asks-open-source-notkia-phone-project-to-change-its-name diff --git a/published/20220716 Guide- How to Share A Folder Between Ubuntu-Linux and Windows.md b/published/20220716 Guide- How to Share A Folder Between Ubuntu-Linux and Windows.md new file mode 100644 index 0000000000..6e5fa9d287 --- /dev/null +++ b/published/20220716 Guide- How to Share A Folder Between Ubuntu-Linux and Windows.md @@ -0,0 +1,97 @@ +[#]: subject: "Guide: How to Share A Folder Between Ubuntu/Linux and Windows" +[#]: via: "https://www.debugpoint.com/guide-how-share-folder-between-ubuntu-linux-windows/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: "MjSeven" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14850-1.html" + +如何在 Ubuntu/Linux 和 Windows 之间共享文件夹 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/21/104750kh3y9craf6s6nasj.jpg) + +> 本初学者指南解释了如何在 Ubuntu/Linux 中快速共享一个文件夹。 + +在 Ubuntu/Linux 中共享一个文件夹并在其他操作系统(如 Windows)中通过网络访问并不难。默认情况下,Ubuntu 并没有安装所需的软件包。但是,你可以打开安装向导来自动安装所需的软件。 + +本 [指南][1] 适用于所有 Ubuntu 版本(包括 [22.04][2]、20.04、18.04、19.10 以及即将发布的版本 —— 除非此功能的设计发生重大的变化)。 + +### Ubuntu 中共享文件夹的步骤 + +**步骤 1:** 打开文件管理器,右键单击共享的文件夹。点击上下文菜单中的“本地网络共享”选项。 + +![本地网络共享选项][3] + +**步骤 2:** 在文件夹共享对话框中点击共享文件夹复选框。 + +这将在你的系统中安装 [Samba][4] 软件包。Samba 用于在 Windows 和 Unix 系统之间通过网络共享文件和打印机。 + +![文件夹共享选项 - 安装 Samba][5] + +**步骤 3:** 安装 Samba 后,执行以下操作共享文件夹或目录。 + + * 选中共享文件夹复选框。 + * 输入共享名称。这将是你从另一个系统(如 Windows)看到的名称。尽量不要使用任何带有空格的名称。 + * (可选)通过勾选相应选项,你可以控制共享文件夹的写入权限,以及允许访客访问。 + * 如果你允许访客访问,则没有凭据的人可以访问共享文件夹。所以要谨慎。 + * 如果你希望用户输入用户名和密码,打开终端并运行以下命令。 + +``` +sudo smbpasswd -a 用户名 +``` + +`用户名` 应该是对应 Ubuntu 系统的有效用户。 + +现在,你应该已经设置好了共享的文件夹或目录。 + +### 如何访问共享文件夹 + +从 Ubuntu/Linux 系统中访问共享文件夹,你需要系统的 IP 地址或主机名。为此,打开“系统设置System Settings -> Wi-Fi -> 获取 IP 地址Get the IP address”。 + +![IP 地址设置][6] + +如果你运行的是 Linux 发行版不是 Ubuntu,此步骤略有不同。你可能想运行 `ip addr` 来获取 IP 地址,如下所示: + +![在 Linux 中查找 IP 地址][7] + +一旦你获得 IP 地址,就可以在 Ubuntu/Linux 系统中打开文件管理器,然后在地址栏中输入以下内容。注意:你应该修改为你系统的 IP 地址。 + +你现在可以看到共享文件夹上面显示了一个小共享图标,表示网络共享文件夹。 + +![共享文件夹][8] + +要在 **Windows 系统** 访问共享文件夹,打开运行(按下 `Windows + R`)或打开资源管理器,输入以下地址。注意:你应该修改为你系统的 IP 地址和文件夹名称。 + +``` +\\192.168.43.19\Folder +``` + +你应该能够查看共享文件夹的内容,并根据授予的权限修改它。 + +### 总结 + +我已经向你展示了如何从 Ubuntu 共享一个件夹,并通过 IP 地址在 Windows 系统中访问。对于其他 Linux 发行版,你也可以执行相同的步骤。如果本文对你有帮助,在下面的评论框中告诉我。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/guide-how-share-folder-between-ubuntu-linux-windows/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://www.debugpoint.com/category/tutorials/ +[2]: https://www.debugpoint.com/web-stories/ubuntu-22-04-review/ +[3]: https://www.debugpoint.com/wp-content/uploads/2020/01/Local-Network-Share-Option.jpg +[4]: https://en.wikipedia.org/wiki/Samba_(software) +[5]: https://www.debugpoint.com/wp-content/uploads/2020/01/Folder-Sharing-Option-Install-Samba-1024x552.jpg +[6]: https://www.debugpoint.com/wp-content/uploads/2020/01/IP-Address-Settings.jpg +[7]: https://www.debugpoint.com/wp-content/uploads/2020/01/Finding-out-IP-Address-in-Linux.jpg +[8]: https://www.debugpoint.com/wp-content/uploads/2020/01/Share-Folder-1.jpg diff --git a/published/20220718 Monitor your Linux firewall with nftwatch.md b/published/20220718 Monitor your Linux firewall with nftwatch.md new file mode 100644 index 0000000000..468fb0b8c5 --- /dev/null +++ b/published/20220718 Monitor your Linux firewall with nftwatch.md @@ -0,0 +1,85 @@ +[#]: subject: "Monitor your Linux firewall with nftwatch" +[#]: via: "https://opensource.com/article/22/7/nftwatch-linux-firewall" +[#]: author: "Kenneth Aaron https://opensource.com/users/flyingrhino" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14858-1.html" + +用 nftwatch 监控你的 Linux 防火墙 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/24/070724d542rvbbg3af3o9p.jpg) + +> 我创建了 Linux nftwatch 命令来观察防火墙的流量统计。 + +Netfilter 表([nftables][4])是现代 Linux 发行版中的默认防火墙。它在 Fedora 和 RHEL 8、最新的 Debian 和许多其他版本上都有。它取代了早期发行版中捆绑的旧版 iptables。它是一个强大的、值得的 iptables 替代品,作为一个广泛使用它的人,我欣赏它的能力和功能。 + +nftables 的一个特点是能够为许多元素添加计数器,例如规则。这些都是按需启用的。你需要使用 `counter` 参数,在每一行明确地要求它。我为我的防火墙中的特定规则启用了这些计数器,这使我能够看到这些规则。 + +这让我开始思考。我怎样才能实时查看这些计数器?一开始我尝试了 `watch`,它允许诸如刷新率之类的东西,但我不喜欢默认格式,而且它不能滚动。我发现使用 `head` 和 `tail` 以及 `awk` 也不理想,并不存在一个用户友好的解决方案。所以我自己写了一个,我想与开源社区分享。 + +### Linux 上的 nftwatch 介绍 + +我的解决方案,我称之为 `nftwatch`,做了几件事: + +* 它对 nftables 的输出进行重新排序和改写,使其更具有可读性。 +* 它允许向上或向下滚动输出。 +* 可以由用户定义的刷新率(可以实时改变)。 +* 它可以暂停显示。 + +你得到的不是一个表格的转储,而是显示每个规则活动的输出。 + +![Image of nftwatch][5] + +你可以从它的 [Git 仓库][6]下载它。 + +它是 100% 的 Python 代码,100% 的开源,100% 的免费。它满足了所有免费的高质量程序的要求。 + +### 在 Linux 上安装 nftwatch + +以下是手动安装说明: + +1. 克隆或从 git 仓库下载该项目。 +2. 将 `nftwatch.yml` 复制到 `/etc/nftwatch.yml`。 +3. 将 `nftwatch` 复制到 `/usr/local/bin/nftwatch` 并使用 `chmod a+x` 授予其可执行权限。 +4. 使用 `nftwatch`,不带任何参数来运行它。 +5. 参见 `nftwatch -m` 的手册。 + +你也可以在没有 [YAML][7] 配置文件的情况下运行 nftwatch,在这种情况下它使用内置的默认值。 + +### 使用 + +`nftwatch` 命令显示 nftables 规则。大多数控制都是为此目的而设计的。 + +箭头键和等效的 Vim 的按键控制滚动。使用 `F` 或 `S` 键来改变刷新速度。使用 `P` 键来暂停显示。 + +运行 `nftwatch -m` 以获得完整的说明,以及交互式按键控制的列表。 + +### 防火墙的新观点 + +即使你花费了时间去配置防火墙,它也会显得晦涩难懂和模糊不清。除了从日志条目中推断指标外,很难判断你的防火墙实际看到的活动类型。 使用 `nftwatch`,你可以看到你的防火墙在工作,并且可以更好地了解你的网络每天需要处理的流量类型。 + +*(文内图片来自 Kenneth Aaron,CC BY-SA 4.0)* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/7/nftwatch-linux-firewall + +作者:[Kenneth Aaron][a] +选题:[lkxed][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/flyingrhino +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/coffee_tea_laptop_computer_work_desk.png +[2]: https://unsplash.com/@jonasleupe?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]: https://unsplash.com/s/photos/tea-cup-computer?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: https://developers.redhat.com/blog/2016/10/28/what-comes-after-iptables-its-successor-of-course-nftables?extIdCarryOver=true&sc_cid=701f2000001OH79AAG#getting_started +[5]: https://opensource.com/sites/default/files/2022-07/nftwatch-sample.png +[6]: https://github.com/flyingrhinonz/nftwatch +[7]: https://opensource.com/article/21/9/yaml-cheat-sheet diff --git a/published/20220719 How to Install Discord on Manjaro and Other Arch Linux Derivatives.md b/published/20220719 How to Install Discord on Manjaro and Other Arch Linux Derivatives.md new file mode 100644 index 0000000000..23b855c07d --- /dev/null +++ b/published/20220719 How to Install Discord on Manjaro and Other Arch Linux Derivatives.md @@ -0,0 +1,118 @@ +[#]: subject: "How to Install Discord on Manjaro and Other Arch Linux Derivatives" +[#]: via: "https://itsfoss.com/install-discord-arch-manjaro/" +[#]: author: "Anuj Sharma https://itsfoss.com/author/anuj/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14856-1.html" + +如何在 Manjaro 和其他 Arch Linux 衍生品上安装 Discord 客户端 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/23/181625i62zdef7iufup2e6.jpg) + +[Discord][1] 是一个跨平台的应用,可用于语音通话、视频通话、文本消息,以及分享媒体和文件。 + +它在游戏玩家和主播中非常流行。虽然,许多开源项目已经开始使用它来主持他们的社区讨论。你可以找到这类开源社区的 [官方 Discord 服务器][2]。 + +Discord 可以直接从你的网页浏览器访问。安装官方桌面客户端可以让你获得系统通知和集中交流,而不是在多个打开的标签中摸索 Discord 标签。 + +虽然 Discord 为 Ubuntu 提供了 Deb 文件,但在 Arch Linux 上却没有这样的即用型软件包。 + +别担心。在本教程中,我将向你展示两种在 [Arch Linux][3] 及其衍生版本上安装 Discord 的方法。 + +* 通过 [Pacman][4] 安装 Discord(命令行方法,对所有基于 Arch 的发行版有效)。 +* 通过 [Pamac][5] 安装 Discord(GUI 方法,对 Manjaro 和其他一些使用 Pamac 工具的基于 Arch 的发行版有效)。 + +### 方法 1: 通过 pacman 命令安装 Discord + +首先,更新你的系统,因为它是一个滚动发布的版本,[不支持部分升级][6]。 + +在终端输入以下 [pacman 命令][7] 来 [更新你的 Arch Linux 系统][8]。 + +``` +sudo pacman -Syu +``` + +现在你可以通过以下命令安装 Discord 包。 + +``` +sudo pacman -S discord +``` + +安装后,只需从应用菜单中启动应用,然后登录就可以开始使用 Discord。 + +![Discord client in Arch Linux][9] + +**如果你想安装 Discord 的每日构建版本** 来测试即将到来的新功能,请使用以下命令。请注意,它可能并不稳定,所以如果你想要这个版本,请再考虑一下。 + +``` +sudo pacman -S discord-canary +``` + +#### 删除 Discord + +如果你想删除 Discord,使用下面的命令来删除它以及它的依赖关系和配置文件: + +``` +sudo pacman -Rns discord +``` + +如果你选择的是每日构建版本,请使用以下命令将其删除: + +``` +sudo pacman -Rns discord-canary +``` + +这很不错。现在对于不喜欢使用终端的人来说,有一个替代方案。我将在下一节讨论这个问题。 + +### 方法 2:通过 Pamac 安装 Discord + +如果你使用 Arch Linux 的衍生产品,如 [Manjaro Linux][10]、[Garuda Linux][11] 等,你就有一个叫做 Pamac 的图形化软件中心。 + +有了这个图形化的工具,你可以轻松地安装新的应用程序或删除现有的应用,而不必进入终端。 + +从应用程序菜单中启动 Pamac(添加/删除软件)。 + +![pamac menu][12] + +点击“更新Updates”来更新你的系统。 + +![pamac update][13] + +现在点击“浏览Browse”,使用左上方的搜索按钮搜索 “discord”。然后,选择软件包并点击“应用Apply”来安装。 + +![Installing Discord from Pamac][14] + +你可以用 Pamac 来卸载软件包,就像你安装它一样。 + +我希望这个关于在基于 Arch 的 Linux 发行版上安装 Discord 的快速技巧对你有帮助。如果你有任何问题或建议,请告诉我。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-discord-arch-manjaro/ + +作者:[Anuj Sharma][a] +选题:[lkxed][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/anuj/ +[b]: https://github.com/lkxed +[1]: https://discord.com/ +[2]: https://discord.com/open-source +[3]: https://archlinux.org/ +[4]: https://archlinux.org/pacman/ +[5]: https://gitlab.manjaro.org/applications/pamac +[6]: https://wiki.archlinux.org/title/System_maintenance#Partial_upgrades_are_unsupported +[7]: https://itsfoss.com/pacman-command/ +[8]: https://itsfoss.com/update-arch-linux/ +[9]: https://itsfoss.com/wp-content/uploads/2022/06/discord.png +[10]: https://manjaro.org/ +[11]: https://garudalinux.org/ +[12]: https://itsfoss.com/wp-content/uploads/2022/06/pamac-menu.png +[13]: https://itsfoss.com/wp-content/uploads/2022/06/pamac-update.png +[14]: https://itsfoss.com/wp-content/uploads/2022/06/pamac-discord.png diff --git a/published/20220721 Dell XPS 13 Plus -Developer Edition- Gets Certified for Ubuntu 22.04 LTS.md b/published/20220721 Dell XPS 13 Plus -Developer Edition- Gets Certified for Ubuntu 22.04 LTS.md new file mode 100644 index 0000000000..1917a11a33 --- /dev/null +++ b/published/20220721 Dell XPS 13 Plus -Developer Edition- Gets Certified for Ubuntu 22.04 LTS.md @@ -0,0 +1,76 @@ +[#]: subject: "Dell XPS 13 Plus (Developer Edition) Gets Certified for Ubuntu 22.04 LTS" +[#]: via: "https://news.itsfoss.com/dell-xps-13-plus-dev-ubuntu-certified/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14852-1.html" + +戴尔 XPS 13 Plus 开发者版获得 Ubuntu 22.04 LTS 认证 +====== + +> 戴尔的 XPS 13 Plus 开发者版可能是第一款为 Ubuntu 22.04 LTS 认证的笔记本电脑。 + +![xps 13 dev][1] + +戴尔 XPS 是一个适合专业人士和商业用户的高端笔记本电脑系列。 + +而且它也是运行 Linux 的最受欢迎的笔记本电脑之一。如果你一直想得到一台为最新的 Ubuntu 量身定做的戴尔 XPS 笔记本电脑,那么 **戴尔 XPS 13 Plus 开发者版** 就是为你准备的。 + +13 英寸 XPS 笔记本电脑的开发者版现在已经通过认证,可以使用 Ubuntu 22.04 LTS 完美工作。 + +这些经过认证的设备都经过了测试,以获得最佳体验,确保每台笔记本电脑的功能都能按预期工作。 + +换句话说,你可以找到预装 [Ubuntu 22.04 LTS][2] 的优质笔记本电脑,不必担心其开箱即用的体验。而且,如果你已经有一台 XPS 13 Plus 笔记本电脑,你也可以手动安装 Ubuntu 22.04 来获得同样的优化体验。 + +这款笔记本应该是 [TUXEDO Pulse 15][3] 和 [HP Dev One][4] 的绝佳替代品。 + +### 戴尔的高级笔记本电脑拥有顺滑的 Ubuntu 体验 + +虽然我们可以在任何笔记本电脑上安装 Linux 发行版,但可能并不总是一种方便的体验。 + +从 Wi-Fi 兼容性问题到指纹认证,任何事情都可能出错。除非一个设备与一个操作系统正式兼容,否则你只能带着失败的几率去尝试。 + +然而,戴尔在 Ubuntu 领域是非常有名的,它提供的笔记本电脑在 Ubuntu 的最新版本中完全可以正常工作。戴尔的 XPS 13 Plus 开发者版运行的是经 Canonical 认证的最新推出的 Ubuntu 22.04 LTS。 + +你可以查看我们的 [Ubuntu 22.04 LTS 特色][5] 文章,探索你可以从它那里得到什么。 + +戴尔的产品经理就他们与 Canonical 的长期合作分享了一些见解。 + +> “XPS 是戴尔的创新门户 —— 从对尖端技术的应用,到新用户界面和体验式设计的实验。”戴尔技术公司的 Linux 操作系统产品经理 Jaewook Woo 说:“通过将 Ubuntu 22.04 LTS 的增强性能和电源管理功能引入我们最先进的高端笔记本电脑,戴尔和 Canonical 加强了我们的共同承诺,即继续为使用 Ubuntu 的开发者提供最佳的计算体验。” + +![][6] + +戴尔 XPS 13 Plus 开发者版提供了令人兴奋的规格,包括: + +* 四扬声器设计 +* 高达 4K+ 分辨率的 OLED 显示屏 +* M.2 PCIe Gen 4 NVMe SSD +* 高达 32GB、LPDDR5 5200MHz 内存 + +这款笔记本电脑将于 2022 年 8 月在美国、加拿大和部分欧洲国家预装 Ubuntu 22.04 LTS 发售。如果你想买一台,你可能想关注一下 [戴尔的 XPS 13 Plus 产品页面][7]。 + +> **[Dell XPS 13 Plus][8]** + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/dell-xps-13-plus-dev-ubuntu-certified/ + +作者:[Ankush Das][a] +选题:[lkxed][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/ankush/ +[b]: https://github.com/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/07/dell-xps-13-dev-edition-with-ubuntu-22-04.jpg +[2]: https://news.itsfoss.com/ubuntu-22-04-release/ +[3]: https://news.itsfoss.com/tuxedo-pulse-gen-2/ +[4]: https://news.itsfoss.com/hp-dev-one-system76/ +[5]: https://itsfoss.com/ubuntu-22-04-release-features/ +[6]: https://news.itsfoss.com/wp-content/uploads/2022/07/dell-xps-13-plus-dev-1.jpg +[7]: https://www.dell.com/en-us/shop/dell-laptops/xps-13-plus-laptop/spd/xps-13-9320-laptop +[8]: https://www.dell.com/en-us/shop/dell-laptops/xps-13-plus-laptop/spd/xps-13-9320-laptop diff --git a/sources/news/20220527 TypeScript Based Headless CMS -Payload- Becomes Open Source.md b/sources/news/20220527 TypeScript Based Headless CMS -Payload- Becomes Open Source.md deleted file mode 100644 index 0e99f3c1d1..0000000000 --- a/sources/news/20220527 TypeScript Based Headless CMS -Payload- Becomes Open Source.md +++ /dev/null @@ -1,79 +0,0 @@ -[#]: subject: "TypeScript Based Headless CMS ‘Payload’ Becomes Open Source" -[#]: via: "https://news.itsfoss.com/payload-open-source/" -[#]: author: "Jacob Crume https://news.itsfoss.com/author/jacob/" -[#]: collector: "lkxed" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -TypeScript Based Headless CMS ‘Payload’ Becomes Open Source -====== -A new option added to the list of open-source headless CMS. Now, a better headless WordPress alternative? - -![payload][1] - -Since its first beta release a little over a year ago, Payload has slowly built a name for itself within the web development community as a headless Content Management System (CMS). For a bit of background information, Payload is a CMS tailored specifically toward being simpler to develop websites, web apps, or native applications. - -Recently, they decided to go completely open-source, putting it among the likes of some of the [best open-source CMS available][2]. - -However, that raises some questions, like what will their business model look like? And what are the plans for Payload CMS? Let’s take a brief look. - -### Why Has Payload Gone Open-Source? - -Since its initial launch back in 2021, Payload has received many contributions from the open-source community. As Payload said in their [recent announcement][3], the decision to go open-source is massive, and it allows projects to read much greater heights than could ever be possible if kept behind closed doors. - -![][4] - -In addition, this openness often results in much greater levels of trust from the developer community. This trust also extends to businesses, naturally turning to the platform with the greatest developer support and trust. - -Due to all these reasons, Payload is now switching to the MIT license. This allows anyone to modify, distribute, and use Payload for free and without limitations. - -However, Payload still needs money flowing in to operate sustainably. So, that begs the question, how will Payload make money? - -### How Payload Is Going To Make Money? - -As is always the case, Payload requires some financial backing to remain afloat. They have outlined a two-part plan that should both provide users with even more convenience-focused features while still leaving self-hosted customers incredible flexibility. - -![][5] - -#### Enterprise Licenses - -This option is extremely similar to other open-source CMS software services. These licenses would provide more advanced SSO options and give the developers guaranteed response times from the core Payload team. - -These licenses should look appealing to larger corporations, especially those that require the utmost reliability. - -#### Cloud Hosting - -This option is quite attractive, as it combines multiple services to create the most convenient experience possible. Although traditional hosting remains reasonably easy, as soon as you add in a database, permanent file storage, and deliberate infrastructure for Node apps, you are left with four or five different services that all need to work seamlessly together. - -It should be noted that this is not required, and users are still encouraged to host their instances. However, this service simply takes a lot of the expenses and challenges associated with hosting out of the equation. - -As of now, things haven’t been finalized. But, you can keep an eye on the discussions on [GitHub][6] to keep up with it. - -### Wrapping Up - -As an emerging CMS option, it is great to see Payload take this step to become a popular alternative to WordPress and other options. Additionally, it appears to me that the Payload team is confident in their new business model, signifying a (hopefully) bright future for them. - -[Payload CMS][7] - --------------------------------------------------------------------------------- - -via: https://news.itsfoss.com/payload-open-source/ - -作者:[Jacob Crume][a] -选题:[lkxed][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/lkxed -[1]: https://news.itsfoss.com/wp-content/uploads/2022/05/payload-opensource.jpg -[2]: https://itsfoss.com/open-source-cms/ -[3]: https://payloadcms.com/blog/open-source -[4]: https://news.itsfoss.com/wp-content/uploads/2022/05/payloadcms-demo.png -[5]: https://news.itsfoss.com/wp-content/uploads/2022/05/payload-free-opensource-1024x576.jpg -[6]: https://github.com/payloadcms/payload -[7]: https://payloadcms.com/ diff --git a/sources/talk/20190131 OOP Before OOP with Simula.md b/sources/talk/20190131 OOP Before OOP with Simula.md deleted file mode 100644 index 5af32716d9..0000000000 --- a/sources/talk/20190131 OOP Before OOP with Simula.md +++ /dev/null @@ -1,231 +0,0 @@ -[#]: subject: "OOP Before OOP with Simula" -[#]: via: "https://twobithistory.org/2019/01/31/simula.html" -[#]: author: "Two-Bit History https://twobithistory.org" -[#]: collector: "lujun9972" -[#]: translator: "aREversez" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -OOP Before OOP with Simula -====== - -Imagine that you are sitting on the grassy bank of a river. Ahead of you, the water flows past swiftly. The afternoon sun has put you in an idle, philosophical mood, and you begin to wonder whether the river in front of you really exists at all. Sure, large volumes of water are going by only a few feet away. But what is this thing that you are calling a “river”? After all, the water you see is here and then gone, to be replaced only by more and different water. It doesn’t seem like the word “river” refers to any fixed thing in front of you at all. - -In 2009, Rich Hickey, the creator of Clojure, gave [an excellent talk][1] about why this philosophical quandary poses a problem for the object-oriented programming paradigm. He argues that we think of an object in a computer program the same way we think of a river—we imagine that the object has a fixed identity, even though many or all of the object’s properties will change over time. Doing this is a mistake, because we have no way of distinguishing between an object instance in one state and the same object instance in another state. We have no explicit notion of time in our programs. We just breezily use the same name everywhere and hope that the object is in the state we expect it to be in when we reference it. Inevitably, we write bugs. - -The solution, Hickey concludes, is that we ought to model the world not as a collection of mutable objects but a collection of _processes_ acting on immutable data. We should think of each object as a “river” of causally related states. In sum, you should use a functional language like Clojure. - -![][2] _The author, on a hike, pondering the ontological commitments -of object-oriented programming._ - -Since Hickey gave his talk in 2009, interest in functional programming languages has grown, and functional programming idioms have found their way into the most popular object-oriented languages. Even so, most programmers continue to instantiate objects and mutate them in place every day. And they have been doing it for so long that it is hard to imagine that programming could ever look different. - -I wanted to write an article about Simula and imagined that it would mostly be about when and how object-oriented constructs we are familiar with today were added to the language. But I think the more interesting story is about how Simula was originally so _unlike_ modern object-oriented programming languages. This shouldn’t be a surprise, because the object-oriented paradigm we know now did not spring into existence fully formed. There were two major versions of Simula: Simula I and Simula 67. Simula 67 brought the world classes, class hierarchies, and virtual methods. But Simula I was a first draft that experimented with other ideas about how data and procedures could be bundled together. The Simula I model is not a functional model like the one Hickey proposes, but it does focus on _processes_ that unfold over time rather than objects with hidden state that interact with each other. Had Simula 67 stuck with more of Simula I’s ideas, the object-oriented paradigm we know today might have looked very different indeed—and that contingency should teach us to be wary of assuming that the current paradigm will dominate forever. - -### Simula 0 Through 67 - -Simula was created by two Norwegians, Kristen Nygaard and Ole-Johan Dahl. - -In the late 1950s, Nygaard was employed by the Norwegian Defense Research Establishment (NDRE), a research institute affiliated with the Norwegian military. While there, he developed Monte Carlo simulations used for nuclear reactor design and operations research. These simulations were at first done by hand and then eventually programmed and run on a Ferranti Mercury.[1][3] Nygaard soon found that he wanted a higher-level way to describe these simulations to a computer. - -The kind of simulation that Nygaard commonly developed is known as a “discrete event model.” The simulation captures how a sequence of events change the state of a system over time—but the important property here is that the simulation can jump from one event to the next, since the events are discrete and nothing changes in the system between events. This kind of modeling, according to a paper that Nygaard and Dahl presented about Simula in 1966, was increasingly being used to analyze “nerve networks, communication systems, traffic flow, production systems, administrative systems, social systems, etc.”[2][4] So Nygaard thought that other people might want a higher-level way to describe these simulations too. He began looking for someone that could help him implement what he called his “Simulation Language” or “Monte Carlo Compiler.”[3][5] - -Dahl, who had also been employed by NDRE, where he had worked on language design, came aboard at this point to play Wozniak to Nygaard’s Jobs. Over the next year or so, Nygaard and Dahl worked to develop what has been called “Simula 0.”[4][6] This early version of the language was going to be merely a modest extension to ALGOL 60, and the plan was to implement it as a preprocessor. The language was then much less abstract than what came later. The primary language constructs were “stations” and “customers.” These could be used to model certain discrete event networks; Nygaard and Dahl give an example simulating airport departures.[5][7] But Nygaard and Dahl eventually came up with a more general language construct that could represent both “stations” and “customers” and also model a wider range of simulations. This was the first of two major generalizations that took Simula from being an application-specific ALGOL package to a general-purpose programming language. - -In Simula I, there were no “stations” or “customers,” but these could be recreated using “processes.” A process was a bundle of data attributes associated with a single action known as the process’ _operating rule_. You might think of a process as an object with only a single method, called something like `run()`. This analogy is imperfect though, because each process’ operating rule could be suspended or resumed at any time—the operating rules were a kind of coroutine. A Simula I program would model a system as a set of processes that conceptually all ran in parallel. Only one process could actually be “current” at any time, but once a process suspended itself the next queued process would automatically take over. As the simulation ran, behind the scenes, Simula would keep a timeline of “event notices” that tracked when each process should be resumed. In order to resume a suspended process, Simula needed to keep track of multiple call stacks. This meant that Simula could no longer be an ALGOL preprocessor, because ALGOL had only once call stack. Nygaard and Dahl were committed to writing their own compiler. - -In their paper introducing this system, Nygaard and Dahl illustrate its use by implementing a simulation of a factory with a limited number of machines that can serve orders.[6][8] The process here is the order, which starts by looking for an available machine, suspends itself to wait for one if none are available, and then runs to completion once a free machine is found. There is a definition of the order process that is then used to instantiate several different order instances, but no methods are ever called on these instances. The main part of the program just creates the processes and sets them running. - -The first Simula I compiler was finished in 1965. The language grew popular at the Norwegian Computer Center, where Nygaard and Dahl had gone to work after leaving NDRE. Implementations of Simula I were made available to UNIVAC users and to Burroughs B5500 users.[7][9] Nygaard and Dahl did a consulting deal with a Swedish company called ASEA that involved using Simula to run job shop simulations. But Nygaard and Dahl soon realized that Simula could be used to write programs that had nothing to do with simulation at all. - -Stein Krogdahl, a professor at the University of Oslo that has written about the history of Simula, claims that “the spark that really made the development of a new general-purpose language take off” was [a paper called “Record Handling”][10] by the British computer scientist C.A.R. Hoare.[8][11] If you read Hoare’s paper now, this is easy to believe. I’m surprised that you don’t hear Hoare’s name more often when people talk about the history of object-oriented languages. Consider this excerpt from his paper: - -> The proposal envisages the existence inside the computer during the execution of the program, of an arbitrary number of records, each of which represents some object which is of past, present or future interest to the programmer. The program keeps dynamic control of the number of records in existence, and can create new records or destroy existing ones in accordance with the requirements of the task in hand. - -> Each record in the computer must belong to one of a limited number of disjoint record classes; the programmer may declare as many record classes as he requires, and he associates with each class an identifier to name it. A record class name may be thought of as a common generic term like “cow,” “table,” or “house” and the records which belong to these classes represent the individual cows, tables, and houses. - -Hoare does not mention subclasses in this particular paper, but Dahl credits him with introducing Nygaard and himself to the concept.[9][12] Nygaard and Dahl had noticed that processes in Simula I often had common elements. Using a superclass to implement those common elements would be convenient. This also raised the possibility that the “process” idea itself could be implemented as a superclass, meaning that not every class had to be a process with a single operating rule. This then was the second great generalization that would make Simula 67 a truly general-purpose programming language. It was such a shift of focus that Nygaard and Dahl briefly considered changing the name of the language so that people would know it was not just for simulations.[10][13] But “Simula” was too much of an established name for them to risk it. - -In 1967, Nygaard and Dahl signed a contract with Control Data to implement this new version of Simula, to be known as Simula 67. A conference was held in June, where people from Control Data, the University of Oslo, and the Norwegian Computing Center met with Nygaard and Dahl to establish a specification for this new language. This conference eventually led to a document called the [“Simula 67 Common Base Language,”][14] which defined the language going forward. - -Several different vendors would make Simula 67 compilers. The Association of Simula Users (ASU) was founded and began holding annual conferences. Simula 67 soon had users in more than 23 different countries.[11][15] - -### 21st Century Simula - -Simula is remembered now because of its influence on the languages that have supplanted it. You would be hard-pressed to find anyone still using Simula to write application programs. But that doesn’t mean that Simula is an entirely dead language. You can still compile and run Simula programs on your computer today, thanks to [GNU cim][16]. - -The cim compiler implements the Simula standard as it was after a revision in 1986. But this is mostly the Simula 67 version of the language. You can write classes, subclass, and virtual methods just as you would have with Simula 67. So you could create a small object-oriented program that looks a lot like something you could easily write in Python or Ruby: - -``` - - ! dogs.sim ; - Begin - Class Dog; - ! The cim compiler requires virtual procedures to be fully specified ; - Virtual: Procedure bark Is Procedure bark;; - Begin - Procedure bark; - Begin - OutText("Woof!"); - OutImage; ! Outputs a newline ; - End; - End; - - Dog Class Chihuahua; ! Chihuahua is "prefixed" by Dog ; - Begin - Procedure bark; - Begin - OutText("Yap yap yap yap yap yap"); - OutImage; - End; - End; - - Ref (Dog) d; - d :- new Chihuahua; ! :- is the reference assignment operator ; - d.bark; - End; - -``` - -You would compile and run it as follows: - -``` - - $ cim dogs.sim - Compiling dogs.sim: - gcc -g -O2 -c dogs.c - gcc -g -O2 -o dogs dogs.o -L/usr/local/lib -lcim - $ ./dogs - Yap yap yap yap yap yap - -``` - -(You might notice that cim compiles Simula to C, then hands off to a C compiler.) - -This was what object-oriented programming looked like in 1967, and I hope you agree that aside from syntactic differences this is also what object-oriented programming looks like in 2019. So you can see why Simula is considered a historically important language. - -But I’m more interested in showing you the process model that was central to Simula I. That process model is still available in Simula 67, but only when you use the `Process` class and a special `Simulation` block. - -In order to show you how processes work, I’ve decided to simulate the following scenario. Imagine that there is a village full of villagers next to a river. The river has lots of fish, but between them the villagers only have one fishing rod. The villagers, who have voracious appetites, get hungry every 60 minutes or so. When they get hungry, they have to use the fishing rod to catch a fish. If a villager cannot use the fishing rod because another villager is waiting for it, then the villager queues up to use the fishing rod. If a villager has to wait more than five minutes to catch a fish, then the villager loses health. If a villager loses too much health, then that villager has starved to death. - -This is a somewhat strange example and I’m not sure why this is what first came to mind. But there you go. We will represent our villagers as Simula processes and see what happens over a day’s worth of simulated time in a village with four villagers. - -The full program is [available here as a Gist][17]. - -The last lines of my output look like the following. Here we are seeing what happens in the last few hours of the day: - -``` - - 1299.45: John is hungry and requests the fishing rod. - 1299.45: John is now fishing. - 1311.39: John has caught a fish. - 1328.96: Betty is hungry and requests the fishing rod. - 1328.96: Betty is now fishing. - 1331.25: Jane is hungry and requests the fishing rod. - 1340.44: Betty has caught a fish. - 1340.44: Jane went hungry waiting for the rod. - 1340.44: Jane starved to death waiting for the rod. - 1369.21: John is hungry and requests the fishing rod. - 1369.21: John is now fishing. - 1379.33: John has caught a fish. - 1409.59: Betty is hungry and requests the fishing rod. - 1409.59: Betty is now fishing. - 1419.98: Betty has caught a fish. - 1427.53: John is hungry and requests the fishing rod. - 1427.53: John is now fishing. - 1437.52: John has caught a fish. - -``` - -Poor Jane starved to death. But she lasted longer than Sam, who didn’t even make it to 7am. Betty and John sure have it good now that only two of them need the fishing rod. - -What I want you to see here is that the main, top-level part of the program does nothing but create the four villager processes and get them going. The processes manipulate the fishing rod object in the same way that we would manipulate an object today. But the main part of the program does not call any methods or modify and properties on the processes. The processes have internal state, but this internal state only gets modified by the process itself. - -There are still fields that get mutated in place here, so this style of programming does not directly address the problems that pure functional programming would solve. But as Krogdahl observes, “this mechanism invites the programmer of a simulation to model the underlying system as a set of processes, each describing some natural sequence of events in that system.”[12][18] Rather than thinking primarily in terms of nouns or actors—objects that do things to other objects—here we are thinking of ongoing processes. The benefit is that we can hand overall control of our program off to Simula’s event notice system, which Krogdahl calls a “time manager.” So even though we are still mutating processes in place, no process makes any assumptions about the state of another process. Each process interacts with other processes only indirectly. - -It’s not obvious how this pattern could be used to build, say, a compiler or an HTTP server. (On the other hand, if you’ve ever programmed games in the Unity game engine, this should look familiar.) I also admit that even though we have a “time manager” now, this may not have been exactly what Hickey meant when he said that we need an explicit notion of time in our programs. (I think he’d want something like the superscript notation [that Ada Lovelace used][19] to distinguish between the different values a variable assumes through time.) All the same, I think it’s really interesting that right there at the beginning of object-oriented programming we can find a style of programming that is not all like the object-oriented programming we are used to. We might take it for granted that object-oriented programming simply works one way—that a program is just a long list of the things that certain objects do to other objects in the exact order that they do them. Simula I’s process system shows that there are other approaches. Functional languages are probably a better thought-out alternative, but Simula I reminds us that the very notion of alternatives to modern object-oriented programming should come as no surprise. - -_If you enjoyed this post, more like it come out every four weeks! Follow [@TwoBitHistory][20] on Twitter or subscribe to the [RSS feed][21] to make sure you know when a new post is out._ - -_Previously on TwoBitHistory…_ - -> Hey everyone! I sadly haven't had time to do any new writing but I've just put up an updated version of my history of RSS. This version incorporates interviews I've since done with some of the key people behind RSS like Ramanathan Guha and Dan Libby. -> -> — TwoBitHistory (@TwoBitHistory) [December 18, 2018][22] - - 1. Jan Rune Holmevik, “The History of Simula,” accessed January 31, 2019, . [↩︎][23] - - 2. Ole-Johan Dahl and Kristen Nygaard, “SIMULA—An ALGOL-Based Simulation Langauge,” Communications of the ACM 9, no. 9 (September 1966): 671, accessed January 31, 2019, [http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.95.384&rep=rep1&type=pdf][24]. [↩︎][25] - - 3. Stein Krogdahl, “The Birth of Simula,” 2, accessed January 31, 2019, . [↩︎][26] - - 4. ibid. [↩︎][27] - - 5. Ole-Johan Dahl and Kristen Nygaard, “The Development of the Simula Languages,” ACM SIGPLAN Notices 13, no. 8 (August 1978): 248, accessed January 31, 2019, . [↩︎][28] - - 6. Dahl and Nygaard (1966), 676. [↩︎][29] - - 7. Dahl and Nygaard (1978), 257. [↩︎][30] - - 8. Krogdahl, 3. [↩︎][31] - - 9. Ole-Johan Dahl, “The Birth of Object-Orientation: The Simula Languages,” 3, accessed January 31, 2019, . [↩︎][32] - - 10. Dahl and Nygaard (1978), 265. [↩︎][33] - - 11. Holmevik. [↩︎][34] - - 12. Krogdahl, 4. [↩︎][35] - - - - --------------------------------------------------------------------------------- - -via: https://twobithistory.org/2019/01/31/simula.html - -作者:[Two-Bit History][a] -选题:[lujun9972][b] -译者:[aREversez](https://github.com/aREversez) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://twobithistory.org -[b]: https://github.com/lujun9972 -[1]: https://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey -[2]: https://twobithistory.org/images/river.jpg -[3]: tmp.2ZIthXB4S6#fn:1 -[4]: tmp.2ZIthXB4S6#fn:2 -[5]: tmp.2ZIthXB4S6#fn:3 -[6]: tmp.2ZIthXB4S6#fn:4 -[7]: tmp.2ZIthXB4S6#fn:5 -[8]: tmp.2ZIthXB4S6#fn:6 -[9]: tmp.2ZIthXB4S6#fn:7 -[10]: https://archive.computerhistory.org/resources/text/algol/ACM_Algol_bulletin/1061032/p39-hoare.pdf -[11]: tmp.2ZIthXB4S6#fn:8 -[12]: tmp.2ZIthXB4S6#fn:9 -[13]: tmp.2ZIthXB4S6#fn:10 -[14]: http://web.eah-jena.de/~kleine/history/languages/Simula-CommonBaseLanguage.pdf -[15]: tmp.2ZIthXB4S6#fn:11 -[16]: https://www.gnu.org/software/cim/ -[17]: https://gist.github.com/sinclairtarget/6364cd521010d28ee24dd41ab3d61a96 -[18]: tmp.2ZIthXB4S6#fn:12 -[19]: https://twobithistory.org/2018/08/18/ada-lovelace-note-g.html -[20]: https://twitter.com/TwoBitHistory -[21]: https://twobithistory.org/feed.xml -[22]: https://twitter.com/TwoBitHistory/status/1075075139543449600?ref_src=twsrc%5Etfw -[23]: tmp.2ZIthXB4S6#fnref:1 -[24]: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.95.384&rep=rep1&type=pdf -[25]: tmp.2ZIthXB4S6#fnref:2 -[26]: tmp.2ZIthXB4S6#fnref:3 -[27]: tmp.2ZIthXB4S6#fnref:4 -[28]: tmp.2ZIthXB4S6#fnref:5 -[29]: tmp.2ZIthXB4S6#fnref:6 -[30]: tmp.2ZIthXB4S6#fnref:7 -[31]: tmp.2ZIthXB4S6#fnref:8 -[32]: tmp.2ZIthXB4S6#fnref:9 -[33]: tmp.2ZIthXB4S6#fnref:10 -[34]: tmp.2ZIthXB4S6#fnref:11 -[35]: tmp.2ZIthXB4S6#fnref:12 diff --git a/sources/talk/20191106 How Much of a Genius-Level Move Was Using Binary Space Partitioning in Doom.md b/sources/talk/20191106 How Much of a Genius-Level Move Was Using Binary Space Partitioning in Doom.md index 8f71021591..38496565a4 100644 --- a/sources/talk/20191106 How Much of a Genius-Level Move Was Using Binary Space Partitioning in Doom.md +++ b/sources/talk/20191106 How Much of a Genius-Level Move Was Using Binary Space Partitioning in Doom.md @@ -2,7 +2,7 @@ [#]: via: "https://twobithistory.org/2019/11/06/doom-bsp.html" [#]: author: "Two-Bit History https://twobithistory.org" [#]: collector: "lujun9972" -[#]: translator: " " +[#]: translator: "aREversez" [#]: reviewer: " " [#]: publisher: " " [#]: url: " " @@ -141,7 +141,7 @@ via: https://twobithistory.org/2019/11/06/doom-bsp.html 作者:[Two-Bit History][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) +译者:[aREversez](https://github.com/aREversez) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/talk/20220115 Why use a Raspberry Pi to power your business.md b/sources/talk/20220115 Why use a Raspberry Pi to power your business.md deleted file mode 100644 index a01a8f45b3..0000000000 --- a/sources/talk/20220115 Why use a Raspberry Pi to power your business.md +++ /dev/null @@ -1,85 +0,0 @@ -[#]: subject: "Why use a Raspberry Pi to power your business" -[#]: via: "https://opensource.com/article/22/1/raspberry-pi-business" -[#]: author: "Giuseppe Cassibba https://opensource.com/users/peppe8o" -[#]: collector: "lujun9972" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -Why use a Raspberry Pi to power your business -====== -Why small, single-board computers can be the future for smart working -and small offices. -![A chair in a field.][1] - -With the pandemic changing the way we're working, job decentralization is becoming an important challenge for all companies. - -### Smart offices - -Even if every factory approached smart working only as remoting the employee notebook through a VPN, adding evolution brings some basic office services as nearest as possible to people. This could drastically reduce the datacenter's load and improve people's working experience. An additional effect is removing many single-point-of-failures from information and communications technology (ICT) in this scenario. - -Instead of hundreds or thousands of workplaces outside the company, it's like having hundreds or thousands of small offices/branches around the world. It's what one might call **smart offices**. - -This statement may frighten many ICT experts because of the culture, which associates a big machine (server) to each office, even if the advantages of spreading computing resources are clear. - -### A different perspective - -What if you could deliver the services of a big server from a tiny US$ 50 board? What if this tiny board requires only an SD card and an ordinary USB power supply? Here's where the [Raspberry Pi][2] is the most flexible solution. - -Raspberry Pi computer boards are very small form factor computers running Linux. They have an OS delivered and maintained from Raspberry Pi Foundation—the Raspberry Pi OS. Based on Debian, it shares many software packages with the most known Linux distributions. Moreover, many Raspberry Pi boards can flawlessly run the most famous Ubuntu server. They include ARM processors, which grant low energy consumption. - -**[ Read next: [7 ways to use Raspberry Pi in enterprise IT][3] ]** - -But Raspberry Pi computer boards are a great opportunity also for small companies, bringing tons of (open source) services at affordable costs. Here, you have to consider data loss risks, as you have all your services in small consumer-grade hardware. But setting up the right backup/restore procedures can reduce these risks. - -### What services can you provide from a Raspberry Pi board? - -Most services usually get delivered from more expensive servers. The "most" attribute depends on some restrictions: - - * **ARM processor:** Some packages are available only for X86/X64 processors. This is one of the hardest challenges to overcome. On the other hand, the increasing market share for ARM processors keeps programmers having ARM-compatible versions of their software. - * **RAM amount:** This is a problem limited to some complex applications running complex calculations in a sophisticated manner. Many times, it's just a matter of revisiting the code, splitting steps, and keeping it simple and efficient. Moreover, if a service requires a lot of RAM/CPU for a few users, this may also mean that the service is not working correctly, and it could be an opportunity for you to remove old problems that are wasting resources. Finally, the latest Raspberry Pi computer boards upgraded the RAM amount up to 8GB, which is a lot. - * **Users who are inexperienced with servers:** This is another problem you can approach with base images inside the micro-SD cards on which Raspberry Pi stores the OS and running data. - - - -That said, you can do many interesting things with a Raspberry Pi. In [my blog][4], I've tested this by running all kinds of services—from a basic LAMP server to a complex CRM. Passing through some complex systems, all open source, like: - - * Proxy server (also capable to add ad-blocker services) - * Email server - * Printing server - * [Hotel management][5] - * Contact relations management - * [Private social network][6] - * Private forum - * Private Git web portal - * Network monitoring server - * [And many other useful services][7] - - - -Another interesting opportunity for Raspberry Pi in your remote office is to get a WiFi hotspot offering advanced services and control from its Ethernet port.  - -Finally, [Raspberry Pi can also run containers][8], an additional tool to get a world of services available from this incredible board. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/22/1/raspberry-pi-business - -作者:[Giuseppe Cassibba][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/peppe8o -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BIZ_WorkInPublic_4618517_1110_CS_A.png?itok=RwVrWArk (A chair in a field.) -[2]: https://opensource.com/resources/raspberry-pi -[3]: https://enterprisersproject.com/article/2020/11/raspberry-pi-7-enterprise-it-uses -[4]: https://peppe8o.com -[5]: https://opensource.com/article/20/4/qloapps-raspberry-pi -[6]: https://opensource.com/article/20/3/raspberry-pi-open-source-social -[7]: https://peppe8o.com/category/raspberrypi/ -[8]: https://opensource.com/article/20/8/kubernetes-raspberry-pi diff --git a/sources/talk/20220510 6 easy ways to make your first open source contribution with LibreOffice.md b/sources/talk/20220510 6 easy ways to make your first open source contribution with LibreOffice.md deleted file mode 100644 index df7c631f1e..0000000000 --- a/sources/talk/20220510 6 easy ways to make your first open source contribution with LibreOffice.md +++ /dev/null @@ -1,56 +0,0 @@ -[#]: subject: "6 easy ways to make your first open source contribution with LibreOffice" -[#]: via: "https://opensource.com/article/22/5/first-open-source-contribution-libreoffice" -[#]: author: "Klaatu https://opensource.com/users/klaatu" -[#]: collector: "lkxed" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -6 easy ways to make your first open source contribution with LibreOffice -====== -May 2022 is LibreOffice month. Here are some easy ways to make your first open source contribution. - -![Dandelion zoomed in][1] -(Photo by Rob Tiller, CC BY-SA 4.0) - -"Getting involved" with open source can seem a little confusing. Where do you go to get started? What if you don't know how to code? Who do you talk to? How does anybody know that you have contributed, and besides that does anybody care? - -There are actually answers to questions like those (your choice, it's OK, nobody, you tell them, yes) but during the month of May 2022, there's one simple answer: LibreOffice. This month is a month of participation at LibreOffice and its governing body, The Document Foundation. They're inviting contributors of all sorts to help in any of six different ways, and only one of those has anything at all to do with code. No matter what your skill, you can probably find a way to help the world's greatest office suite. - -### 6 ways to contribute to LibreOffice - -Here's what you can do: - -* Handy Helper: Go answer questions from other LibreOffice users on Ask LibreOffice. If you're an avid user of LibreOffice and think you have useful tips and tricks that will help others, this is the role you've been waiting for. -* First Responder: Bug reports are better when they're confirmed by more than just one user. If you're good at installing software (sometimes bug reports are for older versions than what you might be using normally) then go to the LibreOffice Bugzilla and find new bugs that have yet to be confirmed. When you find one, try to replicate what's been reported. Assuming you can do that, add a comment like “CONFIRMED on Linux (Fedora 35) and LibreOffice 7.3.2”. -* Drum Beater: Open source projects rarely have big companies funneling marketing money into promoting them. It would be nice if all the companies claiming to love open source would help out, but not all of them do, so why not lend your voice? Get on social media and tell your friends why you love LibreOffice, or what you’re using it for (and of course add the #libreoffice hashtag.) -* Globetrotter: LibreOffice is already available in many different languages, but not literally all languages. And LibreOffice is actively being developed, so its interface translations need to be kept up-to-date. Get involved here. -* Docs Doctor: LibreOffice has online help as well as user handbooks. If you're great at explaining things to other people, or if you're great at proof-reading other people's documentation, then you should contact the docs team. -* Code Cruncher: You're probably not going to dive into LibreOffice's code base and make major changes right away, but that's not generally what projects need. If you know how to code, then you can join the developer community by following the instructions on this wiki page. - -``` -#libreoffice -``` - -### Free stickers - -I didn't want to mention this up-front because obviously you should get involved with LibreOffice just because you're excited to get involved with a great open source project. However, you're going to find out eventually so I may as well tell you: By contributing to LibreOffice, you can sign up to get free stickers from The Document Foundation. Surely you've been meaning to [decorate your laptop][2]? - -Don't get distracted by the promise of loot, though. If you're confused but excited to get involved with open source, this is a great opportunity to do so. And it is representative of how you get involved with open source in general: You look for something that needs to be done, you do it, and then you talk about it with others so you can get ideas for what you can do next. Do that often enough, and you find your way into a community. Eventually, you stop wondering how to get involved with open source, because you're too busy contributing! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/22/5/first-open-source-contribution-libreoffice - -作者:[Klaatu][a] -选题:[lkxed][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/klaatu -[b]: https://github.com/lkxed -[1]: https://opensource.com/sites/default/files/dandelion_zoom.jpg -[2]: https://opensource.com/business/15/11/open-source-stickers diff --git a/sources/talk/20220523 7 pieces of Linux advice for beginners.md b/sources/talk/20220523 7 pieces of Linux advice for beginners.md deleted file mode 100644 index bc902926eb..0000000000 --- a/sources/talk/20220523 7 pieces of Linux advice for beginners.md +++ /dev/null @@ -1,142 +0,0 @@ -[#]: subject: "7 pieces of Linux advice for beginners" -[#]: via: "https://opensource.com/article/22/5/linux-advice-beginners" -[#]: author: "Opensource.com https://opensource.com/users/admin" -[#]: collector: "lkxed" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -7 pieces of Linux advice for beginners -====== -We asked our community of writers for the best advice they got when they first started using Linux. - -![Why the operating system matters even more in 2017][1] - -Image by: Internet Archive Book Images. Modified by Opensource.com. CC BY-SA 4.0 - -What advice would you give a new Linux user? We asked our community of writers to share their favorite Linux advice. - -### 1. Use Linux resources - -My brother told me that Linux was like a "software erector set" (that's a dated reference to the old Erector sets that could be purchased in the 1950s and 1960s) which was a helpful metaphor. I was using Windows 3.1 and Windows NT at the time and was trying to build a useful and safe K-12 school district website. This was in 2001 and 2002 and there were very few texts or resources on the web that were helpful. One of the resources recommended was the "Root Users Guide," a very large book that had lots of printed information in it but was tough to decipher and know just how to proceed. - -One of the most useful resources for me was an online course that Mandrake Linux maintained. It was a step-by-step explanation of the nuances of using and administering a Linux computer or server. I used that along with a listserv that Red Hat maintained in those days, where you could pose questions and get answers. - -—— [Don Watkins][2] - -### 2. Ask the Linux community for help - -My advice is to ask questions, in all of their settings. You can start out with an Internet search, looking for others who have had the same or similar questions (maybe even better questions.) It takes a while to know what to ask and how to ask it. - -Once you become more familiar with Linux, check through the various forums out there, to find one or more that you like, and again, before you ask something yourself, look to see if someone else has already had the question and had it answered. - -Getting involved in a mail list is also helpful, and eventually, you may find yourself knowledgeable enough to answer some questions yourself. As they say, you learn the most about something by becoming able to answer someone else's questions about it. - -Meanwhile, you also become more familiar with using a system that's not a black box that you never understand how something is done except by paying for it. - -—— [Greg Pittman][3] - -My advice is to get familiar with help utilities such as man and info.  Also, spend as much time as possible at the command line interface and really get used to the fundamental UNIX design. As a matter of fact, one of my favorite books is a UNIX book from the 80s because it really helps in understanding files, directories, devices, basic commands, and more. - -—— [Alan Formy-Duval][4] - -The best advice I got was to trust the community with answers and manual pages for detailed information and "how-to" use different options. However, I started off around 2009-ish, there were a lot of tools and resources available, including a project called [Linux from Scratch (LFS)][5]. This project really taught me a lot about the internals and how to actually build an LFS image. - -—— [Sumantro Mukherjee][6] - -My advice is to read. Using places like [Ask Fedora][7] or the Fedora Matrix chat or other forum type areas. Just read what others are saying, and trying to fix. I learned a lot from just reading what others were struggling with, and then I would try to figure out how the issue was caused. - -—— [Steve Morris][8] - -### 3. Try dual booting - -I started with a dual-boot system in the late 90s (Windows and Linux), and while I wanted to really use Linux, I ended up booting Windows to work in my familiar desktop environment. One of the best pieces of advice was to change the boot order, so every time I wasn't quick enough, I ended up using Linux. ;) - -—— [Heike Jurzik][9] - -I was challenged by one of my team to do a knowledge swap. - -He (our Linux sysadmin) built his website in **Joomla!** (which our web team specialized in, and he wanted to know more about) and I adopted Linux (having been Windows only to that point.) We dual booted to start with, as I still had a bunch of OS-dependent software I needed to use for the business, but it jump-started my adoption of Linux. - -It was really helpful to have each other as an expert to call on while we were each learning our way into the new systems, and quite a challenge to keep going and not give up because he hadn't! - -I did have a big sticky note on my monitor saying "anything with `rm`  in the command, ask first" after a rather embarrassing blunder early on. He wrote a command-line cheat sheet (there are dozens [online now][10]) for me, which really helped me get familiar with the basics. I also started with the [KDE version][11] of Ubuntu, which I found really helpful as a novice used to working with a GUI. - -I've used Linux ever since (aside from my work computer) and he's still on Joomla, so it seemed to work for both of us! - -—— [Ruth Cheesley][12] - -### 4. Back it up for safety - -My advice is to use a distro with an easy and powerful backup app. A new Linux user will touch, edit, destroy and restore configurations. They probably will reach a time when their OS will not boot and losing data is frustrating. - -With a backup app, they're always sure that their data is safe. - -We all love Linux because it allows us to edit everything, but the dark side of this is that making fatal errors is always an option. - -—— [Giuseppe Cassibba][13] - -### 5. Share the Linux you know and use - -My advice is to share the Linux you use. I used to believe the hype that there were distributions that were "better" for new users, so when someone asked me to help them with Linux, I'd show them the distro "for new users." Invariably, this resulted in me sitting in front of their computer looking like I had never seen Linux before myself, because something would be just unfamiliar enough to confuse me.  Now when someone asks about Linux, I show them how to use what I use. It may not be branded as the "best" Linux for beginners, but it's the distro I know best, so when their problems become mine, I'm able to help solve them (and sometimes I learn something new, myself.) - -—— [Seth Kenlon][14] - -There was a saying back in the old days, "Do not just use a random Linux distro from a magazine cover. Use the distro your friend is using, so you can ask for help when you need it." Just replace "from a magazine cover" with "off the Internet" and it's still valid :-) I never followed this advice, as I was the only Linux user in a 50km radius. Everyone else was using FreeBSD, IRIX, Solaris, and Windows 3.11 around me. Later I was the one people were asking for Linux help. - -—— [Peter Czanik][15] - -### 6. Keep learning Linux - -I was a reseller partner prior to working at Red Hat, and I had a few home health agencies with traveling nurses. They used a quirky package named Carefacts, originally built for DOS, that always got itself out of sync between the traveling laptops and the central database. - -The best early advice I heard was to take a hard look at the open source movement. Open source is mainstream in 2022, but it was revolutionary a generation ago when nonconformists bought Red Hat Linux CDs from retailers. Open source turned conventional wisdom on its ear. I learned it was not communism and not cancer, but it scared powerful people. - -My company built its first customer firewall in the mid-1990s, based on Windows NT and a product from Altavista. That thing regularly crashed and often corrupted itself. We built a Linux-based firewall for ourselves and it never gave us a problem. And so, we replaced that customer Altavista system with a Linux-based system, and it ran trouble-free for years. I built another customer firewall in late 1999. It took me three weeks to go through a book on packet filtering and get the `ipchains` commands right. But it was beautiful when I finally finished, and it did everything it was supposed to do. Over the next 15+ years, I built and installed hundreds more, now with `iptables` ; some with bridges or proxy ARP and QOS to support video conferencing, some with [IPSEC][16] and [OpenVPN tunnels][17]. I got pretty good at it and earned a living managing individual firewalls and a few active/standby pairs, all with Windows systems behind them. I even built a few virtual firewalls. - -But progress never stops. By 2022, [iptables is obsolete][18] and my firewall days are a fond memory. - -The ongoing lesson? Never stop exploring. - -—— [Greg Scott][19] - -### 7. Enjoy the process - -Be patient. Linux is a different system than what you are used to, be prepared for a new world of endless possibilities. Enjoy it. - -—— [Alex Callejas][20] - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/22/5/linux-advice-beginners - -作者:[Opensource.com][a] -选题:[lkxed][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/admin -[b]: https://github.com/lkxed -[1]: https://opensource.com/sites/default/files/lead-images/yearbook-haff-rx-linux-file-lead_0.png -[2]: https://opensource.com/users/don-watkins -[3]: https://opensource.com/users/greg-p -[4]: https://opensource.com/users/alanfdoss -[5]: https://linuxfromscratch.org/ -[6]: https://opensource.com/users/sumantro -[7]: https://ask.fedoraproject.org -[8]: https://opensource.com/users/smorris12 -[9]: https://opensource.com/users/hej -[10]: https://opensource.com/downloads/linux-common-commands-cheat-sheet -[11]: https://opensource.com/article/22/2/why-i-love-linux-kde -[12]: https://opensource.com/users/rcheesley -[13]: https://opensource.com/users/peppe8o -[14]: https://opensource.com/users/seth -[15]: https://opensource.com/users/czanik -[16]: https://www.redhat.com/sysadmin/run-your-own-vpn-libreswan -[17]: https://opensource.com/article/21/8/openvpn-server-linux -[18]: https://opensource.com/article/19/7/make-linux-stronger-firewalls -[19]: https://opensource.com/users/greg-scott -[20]: https://opensource.com/users/darkaxl diff --git a/sources/talk/20220604 Attract contributors to your open source project with authenticity.md b/sources/talk/20220604 Attract contributors to your open source project with authenticity.md new file mode 100644 index 0000000000..d97d80f40d --- /dev/null +++ b/sources/talk/20220604 Attract contributors to your open source project with authenticity.md @@ -0,0 +1,141 @@ +[#]: subject: "Attract contributors to your open source project with authenticity" +[#]: via: "https://opensource.com/article/22/6/attract-contributors-open-source-project" +[#]: author: "Rizel Scarlett https://opensource.com/users/blackgirlbytes" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Attract contributors to your open source project with authenticity +====== +Check out these methods that open source maintainers can use to attract contributors in a genuine manner. + +![a big flag flying in a sea of other flags, teamwork][1] + +Image by: Opensource.com + +It's not a secret that maintaining an open source project is often thankless and time-consuming work. However, I've learned that there's one shared joy among open source maintainers: They love building with a group of technologists who passionately believe in their vision. + +### Marketing feels cringey + +Community support and teamwork are major incentives for open source maintainers. However, gaining community support and contributors is a challenge, especially as a new maintainer. The hope is that technologists will find our projects and start contributing by chance. The reality is we have to market our projects. Think about it: Developers create several public repositories daily, but nobody knows those repositories exist. Without adoption, community, or collaboration, we're not truly reaping the benefits of open source. + +Although marketing an open source project is necessary for a project's overall success, developers are hesitant to do it because marketing to other developers often feels inauthentic and cringey. In this article, I explore methods maintainers can use to attract contributors in a genuine manner. + +### Promote your open source project + +If you want people to contribute to your project, you have to tell them your project exists. So what can promotion look like for you? Instead of spamming discord channels or DMs about an open source project, maintainers can promote their projects through many channels, including: + +* Conference talks: People attend conferences to gain inspiration. Don't be afraid; they're not necessarily looking for a PhD-level lecture. Take the stage at an event like [All Things Open][2], [Open Source Series 101][3], [Codeland][4], or [Upstream][5] to talk about what you're building, why you're building it, issues you face, and discoveries you have made. After your talk, people may want to learn more about what you're building and how they can get involved. +* Blogging: Leverage popular developer blogging platforms such as [Aviyel][6], [Dev.to][7], or [Hashnode][8] to talk about your project. Add a link to your project within the blog posts so that the right people can find it. You can also [submit an article][9] to the editors here on Opensource.com to raise awareness about your open source project! +* Twitter: Twitter has a large tech audience, including Developers, UX Designers, Developer Advocates, and InfoSec professionals who want to collaborate and learn from each other. Twitter is the perfect platform to post in an authentic, non-pushy way about your discoveries, new releases, and bug fixes. Folks will learn from you through your tweets and may feel inclined to build with you. +* Podcasts or Twitter Spaces: Like conference talks, use podcasts and Twitter Spaces to build your project's brand. You don't have to talk about it in a marketing way. You can geek out with the host over your vision and the technical hiccups you've faced along the way. +* Twitch Streams: Stream yourself live coding your project to create awareness of its existence and pair the program with your viewers. Eventually, they might tell other people about your product, or they might ask to contribute themselves. +* Hacktoberfest: Hacktoberfest is a month-long event in October that encourages people to make their first contributions to projects. By participating in Hacktoberfest as a maintainer, you may recruit new contributors. +* Sponsorships: Contributions don't always have to include code. Corporations and individuals can contribute by sponsoring you. Learn more about creating an appealing Sponsor profile [here][10]. + +### Gain community support + +The proverb "it takes a village" applies to more than child-rearing. It also takes a village to maintain an open source project. Community is a large part of open source and just general life success. However, community support is a two-way street. To sustain community support, it's a best practice to give back to community members. + +What can community support look like for you? As you promote your project, you will find folks willing to support you. To encourage them to continue supporting and appeal to other potential supporters, you can: + +* Highlight contributors/supporters: Once you start getting contributors, you can motivate more people to contribute to your project by highlighting past, current, or consistent contributors in your README. This acknowledgment shows that you value and support your contributors. Send your contributors swag or a portion of your sponsorship money if you can afford it. Folks will naturally gravitate to your projects if you're known for genuinely supporting your open source community. + +![Acknowledge contributors on a profile page][11] + +* Establish a culture of kindness: Publish a Code of Conduct in your repository to ensure psychological safety for contributors. I strongly suggest you also adhere to those guidelines by responding kindly to people in comments, pull requests, and issues. It's also vital that you enforce your Code of Conduct. If someone in your community is not following the rules, make sure they face the outlined consequences without exception. Don't let a toxic actor ruin your project's environment with unkind language and harassment. +* Provide a space for open discussion: Often, contributors join an open source community to befriend like-minded technologists, or they have a technical question, and you won't always be available to chat. Open source maintainers often use one of the following tools to create a place for contributors to engage with each other and ask questions in the open: + * GitHub Discussions + * Discord + * Matrix.org + * Mattermost + +### Create a "good" open source project + +*Good* is subjective in code or art, but there are a few ways to indicate that your project is well thought out and a good investment. What does creating a good project look like for you? Your project doesn't have to include amazing code or be a life-changing project to indicate quality. Instead, ensure that your project has the following attributes. + +#### Easy to find + +To help other people find and contribute to your project, you can add topics to your repository related to your project's intended purpose, subject area, affinity groups, or other important qualities. When people go to github.com/topics to search for projects, your project has a higher chance of showing up. + +![GitHub Scientist page][12] + +#### Easy to use + +Make your project easy to use with a detailed README. It's the first thing new users and potential contributors see when visiting your project's repository. Your README should serve as a how-to guide for users. I suggest you include the following information in your README: + +* Project title +* Project description +* Installation instructions +* Usage instructions +* Link to your live web app +* Links to related documentation (code of conduct, license, contributing guidelines) +* Contributors highlights + +You can learn more about crafting the perfect README [here][13]. + +#### Easy to contribute to + +Providing guidelines and managing issues help potential contributors understand opportunities to help. + +* Contributing guidelines - Similar to a README, contributors look for a markdown file called Contributing.md for insight on how to contribute to your project. Guidelines are helpful for you and the contributor because they won't have to ask you too many questions. The contributing guidelines should answer frequently asked questions. I suggest including the following information in your Contributing.md file: + * Technologies used + * How to report bugs + * How to propose new features + * How to open a pull request + * How to claim an issue or task + * Environment set up + * Style guide/code conventions + * Link to a discussion forum or how people can ask for help + * Project architecture (nice to have) + * Known issues +* Good first issues - Highlight issues that don't need legacy project knowledge with the label good-first-issue, so new contributors can feel comfortable contributing to your project for the first time. + +![discover issues with GitHub][14] + +### Exercise persistence + +Even if no one contributes to your project, keep it active with your contributions. Folks will be more interested in contributing to an active project. What does exercising persistence look like for your project? Even if no one is contributing, continue to build your project. If you can't think of new features to add and you feel like you fixed all the bugs, set up ways to make your project easy to manage and scale when you finally get a ton of contributors. + +* Scalability: Once you get contributors, it will get harder to balance responding to every issue. While you're waiting for more contributors, automate the tasks that will eventually become time-consuming. You can leverage GitHub Actions to handle the release process, CI/CD, or enable users to self-assign issues. + +### TL;DR + +Attracting contributors to your open source project takes time, so be patient and don't give up on your vision. While you're waiting, promote your project by building in public and sharing your journey through blog posts, tweets, and Twitch streams. Once you start to gain contributors, show them gratitude in the form of acknowledgment, psychological safety, and support. + +### Next steps + +For more information on maintaining an open source project, check out [GitHub's Open Source Guide][15]. + +Image by: (Rizel Scarlett, CC BY-SA 4.0) + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/6/attract-contributors-open-source-project + +作者:[Rizel Scarlett][a] +选题:[lkxed][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/blackgirlbytes +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/leader_flag_people_team_group.png +[2]: https://2021.allthingsopen.org/ +[3]: https://opensource101.com/ +[4]: https://codelandconf.com/ +[5]: https://upstream.live/ +[6]: http://aviyel.com/ +[7]: https://dev.to/ +[8]: https://hashnode.com/ +[9]: https://opensource.com/writers +[10]: https://dev.to/github/how-to-create-the-perfect-sponsors-profile-for-your-open-source-project-3747 +[11]: https://opensource.com/sites/default/files/2022-05/contributors.png +[12]: https://opensource.com/sites/default/files/2022-05/github-scientist.png +[13]: https://dev.to/github/how-to-create-the-perfect-readme-for-your-open-source-project-1k69 +[14]: https://opensource.com/sites/default/files/2022-05/label-issues.png +[15]: https://opensource.guide/ diff --git a/sources/talk/20220609 SSL Certificates- Make the Right Choice.md b/sources/talk/20220609 SSL Certificates- Make the Right Choice.md new file mode 100644 index 0000000000..e2ade3d02d --- /dev/null +++ b/sources/talk/20220609 SSL Certificates- Make the Right Choice.md @@ -0,0 +1,120 @@ +[#]: subject: "SSL Certificates: Make the Right Choice" +[#]: via: "https://www.opensourceforu.com/2022/06/ssl-certificates-make-the-right-choice/" +[#]: author: "Jitendra Bhojwani https://www.opensourceforu.com/author/jitendra-bhojwani/" +[#]: collector: "lkxed" +[#]: translator: "lightchaserhy" +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +SSL Certificates: Make the Right Choice +====== +Increasingly sophisticated techniques are being used to hack into data today. So it has become extremely important to use even better ways to protect your customers’ data. SSL certification is one such way. This article looks at the different types of SSL certificates and how to choose one that suits your organisation. + +![SSL-certificate][1] + +*Increasingly sophisticated techniques are being used to hack into data today. So it has become extremely important to use even better ways to protect your customers’ data. SSL certification is one such way. This article looks at the different types of SSL certificates and how to choose one that suits your organisation.* + +SSL certificates are an apt solution for securing data in transit. They create an automated mechanism to encrypt the transfer of data between the server and browser (or site and visitor). This encryption can only be decrypted by the intended system. So it discourages hackers from stealing data, and offers complete security against transit attacks on it. + +Along with securing communication, SSL certificates also build trust with customers and help you emerge as a credible business by displaying virtual trust icons like a padlock, HTTPS prefix, and a green address bar. So let’s learn about the major types of SSL certificates and how to choose the one that works best for you. + +### SSL certificate options: Similarities and differences + +Let’s first discuss the basic similarity all SSL certificates share. Regardless of their type, price and scope, every SSL certificate encrypts the to-and-fro communication between the site’s server and the Internet browser of your visitor. + +The difference lies in the terms and conditions of the validation process and the number of domains/subdomains it covers, etc. Proceeding to purchase an SSL certificate without first reviewing your present and future needs may result in costly mistakes, and you may end up paying a hefty amount for advanced features that are irrelevant to your business. Or you may get tempted to buy a cheap certificate that isn’t a perfect fit for your business needs. +Due to the crucial role it plays, an SSL certificate is issued by an official certificate authority after a thorough verification procedure to confirm the legitimacy of ownership. So, this certificate not only encrypts the communication between websites and audiences, but also ensures the legal position of a site. It plays a vital role in building trust. + +As you have now understood why we need a SSL certificate, we can discuss the different types of popular SSL certificates, along with their benefits and issuance procedures. + +### Domain validation (DV) SSL certificate + +The most basic of the three types of SSL certificates, the DV or domain validation certificate confirms the ownership of a domain through an automated online process. All you have to do is to complete a few basic steps to prove that you are the legitimate owner of the domain to get this certificate. Though easiest to get, this type of certificate helps in building only a basic level of trust. + +After completing the DV certification procedure, you are allocated trust-building visual elements — a static seal, a padlock icon, and an HTTPS prefix in your URL. + +Cheapest prices and quick, automated processes are the two major benefits of a DV certificate. On the flip side, you get only the basic trust signs that aren’t enough to satisfy the security concerns of more demanding customers or visitors. + +*Important to know:* DV misses the most important trust sign — vetting the real, legal business that owns the domain name. For instance, suppose Mr X buys a domain ‘abc.com’ to lure gullible people into investing money in a business that seems genuine. Being a legitimate domain owner, he can get a DV through an automated process. With HTTPS URLs and other trust signs, it is easy to gain people’s trust too. However, the company (or fraud mechanism) behind this domain isn’t vetted/verified, which makes it easier for Mr X to continue duping investors of their hard-earned money. + +Is DV SSL the right choice for you?: DV is best for a small and general website, which doesn’t demand or require any sensitive information that can be misused like credit card numbers, social security information, or details of a financial portfolio. For websites that post children’s stories, general e-magazines, personal blogs, professional portfolios, and other static websites on general topics, a DV certificate is a perfect and cheap solution. Securing more mission-critical sites that collect sensitive data like credit card numbers and social security details is a different story though. + +### Organisation validation (OV) SSL certificate + +As the name suggests, the OV certificate not only validates the domain ownership but also vets the real identity of the organisation to which the domain officially belongs. It builds an extra layer of trust for visitors who have stronger concerns, by displaying the key information about the business. Interested visitors just need to check the details of the certificate to ascertain the credibility of the company. + +As compared to a DV certificate, an OV certification requires a more detailed process carried out by an authorised certificate authority that demands and vets key documents representing the legal status of the company. Hence, along with domain ownership, this certificate also assures that it is owned by a legitimate organisation. + +Though the issuance process is more expensive and demanding, this type of certificate does empower you to position your company as a legal, real company doing legitimate business. It makes you stand out and even more concerned visitors are able to trust your organisation. + +Is OV the right choice for you?: Sites that ask for sensitive data that can be misused by threat actors should obtain this certificate. E-commerce sites with online payment gateways, digital health practitioners, government websites that demand citizens’ information, defence-related websites, online trading platforms, or professional networking sites are all the right candidates for obtaining an OV certificate. + +### Extended validation (EV) SSL certificate + +In the digital domain, visuals matter a lot. A company seal, security icons, or even assuring colours (like green) can go a long way in leaving a lasting impression, winning you a big deal or helping you forge business relations with dynamic brands. + +The vetting procedure for issuing an EV SSL certificate is quite stringent and involves a manual process as well. It starts by verifying the ownership of the domain. After that, the certification authority asks for your identification number. Next, it gets your legal working contact number from relevant authentic sources. That contact number is manually verified by calling your office and talking with the real person. Only after satisfying all such verification parameters can you get the EV certificate. + +Unlike an OV certificate, you don’t just get a static site seal with a basic look, but get dynamic seals as well. Additionally, the full legal company name is displayed in the address bar along with a green-coloured padlock. Added to this, the entire address bar turns green as soon as your site loads. All these visible signs vouch for the legality of your firm, build a ‘visual comfort zone’ and reaffirm the credibility of your organisation. + +Such certificates satisfy the sophisticated digital security vetting parameters of global brands and corporate conglomerates. If highly expensive items like gold and diamond jewellery are being sold on a website, then such superior trust factors satisfy the higher trust demands of buyers. Though this certificate is the most expensive among all the SSL certificates, it is worth investing in the extra dollars as it has the potential to significantly boost your sales revenue. + +### Scope of different SSL certificates + +Apart from the type of certificate, the other crucial question is: how many digital properties you want your certificate to cover? If you own a single domain property and do not want to expand in the foreseeable future, then a single DV would do for you. But what if you own, say, 20 different domains — most of which deal with e-commerce or collect sensitive client information? It wouldn’t be practical to buy the more expensive EV certificate for each of these domains. Here is some guidance on that. + +### Wildcard SSL certificate + +With a single wildcard SSL certificate you can protect the main domain and practically unlimited sub-domains related to it. For instance, yoursite.com (the main domain) may have three subdomains: + +* mail.yoursite.com +* login.yoursite.com +* ftp.yoursite.com + +This certificate relieves you from the stress and expenses of purchasing a separate certificate for every domain after going through the complete validation process, followed by an installation process for each. It also saves you a lot of time on repetitive processes and almost eliminates potential errors. + +| - | +| :- | +| Note: Both DV and OV offer wildcard certificate options. | + +### Multi-domain (or SAN SSL) certificate + +One level above the wildcard SSL certificate is the multi-domain certificate, which helps to secure primary domains and their related subdomains. It does everything that a wildcard certificate can do, and more. If you own multiple domains and want a uniform and standard SSL security for all, then a multi-domain certificate is the right choice for you. + +### Is SSL certification only about visual trust signs? + +Obviously, when you spend significant money on an SSL certificate you would like to get more than security icons or trust signals. Well, your certification authority does offer a specific amount of warranty or a payback if your customers become victims of a fraud. The amount of this warranty depends upon the type of certificate and how much it costs. + +### How to choose the ideal certificate authority (CA) for SSL + +The next question is: who can judge the judge? It is you. Carefully consider some of the prime factors while finding the right SSL certificate provider/CA for your site. Before buying any certificate, thoroughly vet the reputation, credentials and experience of the certificate authority. + +Also, ask questions. Do they have a credible history? What type of customers do they have in their repertoire? Do they have an impressive portfolio of regular customers? Most importantly, is the company passively following old industry standards, or is it actively investing in research and development on how to prevent the latest cyber frauds? All such questions will help you to make informed decisions and get the best value for your money. + +Also make another very important check: Has any major browser banned the CA? The very objective of the SSL certificate is defeated if the CA has been banned by a major browser. + +### How long does it take for an SSL certificate to be issued? + +The time taken to issue a certificate varies and depends upon the validation procedure and its requirements. A DV certificate, for instance, is issued within minutes as it has the least verification requirements. An OV SSL, with more detailed vetting requirements, can take up to three days for issuance. Since it has the most demanding vetting process, the EV certificate can take up to four days for issuance. + +The validation period of the certificate, along with its credibility and scope, plays an important role in influencing its price. It is always best to use your discretion, and find a fine balance between the price and value of the certificate. + +A few reputed SSL certificates go the extra mile and also offer extra security measures to customers. You can never be secure enough on a digital platform. So it is always best to see if such additional security elements will be helpful. However, your prime focus should be the credibility and portfolio of the company. It isn’t wise to compromise with that just to get some extra security elements. + +SSL certificates encrypt the data and information that customers share with organisations. They help to save customers from data theft and misuse by threat actors. But it’s always advisable to check the credibility and reviews of a certificate authority carefully before buying a SSL certificate from it. + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/06/ssl-certificates-make-the-right-choice/ + +作者:[Jitendra Bhojwani][a] +选题:[lkxed][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/jitendra-bhojwani/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/05/SSL-certificate.jpg diff --git a/sources/talk/20220615 SBOM – SB Doesn-t Stand for Silver Bullet.md b/sources/talk/20220615 SBOM – SB Doesn-t Stand for Silver Bullet.md new file mode 100644 index 0000000000..e43bd0baf5 --- /dev/null +++ b/sources/talk/20220615 SBOM – SB Doesn-t Stand for Silver Bullet.md @@ -0,0 +1,120 @@ +[#]: subject: "SBOM – SB Doesn’t Stand for Silver Bullet" +[#]: via: "https://www.linux.com/news/sbom-sb-doesnt-stand-for-silver-bullet/" +[#]: author: "Dan Whiting https://www.linuxfoundation.org/blog/sbom-sb-doesnt-stand-for-silver-bullet/" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +SBOM – SB Doesn’t Stand for Silver Bullet +====== +Software Bill of Materials (SBOMs) are like ingredient labels on food. They are critical to keep consumers safe and healthy, they are somewhat standardized, but it is a lot more exciting to grow or make the food rather than the label. + +### What is an SBOM? + +What is an SBOM? In short, it is a way to tell another party all of the software that is used in the stack that makes up an application. One benefit of having a SBOM is you know what is in there when a vulnerability comes up. You can easily determine if you are vulnerable and where. + +As modern software is built utilizing a base of software already written (no sense in recreating the wheel), it is important that all of the components don’t get lost in the shuffle. It isn’t readily apparent what a particular piece of software utilizes. So, if a vulnerability for Software A arises, you need to know, do I have that piece of software somewhere in my ecosystem, and, if so, where. Then you can remediate if you need to. + +I can’t take credit for the food label analogy used in my introduction. I heard it from [Allan Friedman][1], a Senior Advisor and Strategist at the [U.S. Cybersecurity and Infrastructure Security Agency][2] (CISA) and a key SBOM advocate, when he presented about SBOMs at the RSA Conference 2022 with [Kate Stewart][3], the VP of Dependable Embedded Systems here at the Linux Foundation. Allan made the point that food labels only provide information. The consumer needs to read and understand them and take appropriate action. For instance, if they are allergic to peanuts, they can look at an ingredient label and determine if they can safely eat the food. + +SBOMs are similar – they tell a person what software is used as an “ingredient” so someone can determine if they need to take action if a vulnerability arises. It isn’t a silver bullet, but it is a vital tool. Without SBOMs no one can track what component “ingredients” are in their software applications. + +### SBOMs and the Software Supply Chain + +Supply chains are impacting our lives more than just restricting availability of consumer goods. Software supply chains are immensely more complicated now as software is built with pre-existing components. This makes software better, more effective, more powerful, etc. But it also introduces risk as more and more parties touch a particular piece of software. Much like our world has become so interdependent, so has our software. + +Understanding what is in the supply chain for our software helps us effectively secure it. When a new risk emerges, we know what we need to do. + +### SBOMs and Software Security + +SBOMs are increasingly being recognized as an important pillar in any comprehensive software security plan. A global [survey conducted in 2021 Q3 by the Linux Foundation][4] found that 78% of organizations responding plan to use SBOMs in 2022. Additionally, the recently published [Open Source Software Security Mobilization Plan][5] recommends SBOMs be universal and the [U.S. Executive Order on Improving the Nation’s Cybersecurity][6] requires SBOMs be provided for software purchased by the U.S. government. And, as Allan points out in his talk, “We buy everything.” The E.O. actually lays out a nice summary of SBOMs and their benefits: + +The term “Software Bill of Materials” or “SBOM” means a formal record containing the details and supply chain relationships of various components used in building software. Software developers and vendors often create products by assembling existing open source and commercial software components. The SBOM enumerates these components in a product. It is analogous to a list of ingredients on food packaging. An SBOM is useful to those who develop or manufacture software, those who select or purchase software, and those who operate software. Developers often use available open source and third-party software components to create a product; an SBOM allows the builder to make sure those components are up to date and to respond quickly to new vulnerabilities. Buyers can use an SBOM to perform vulnerability or license analysis, both of which can be used to evaluate risk in a product. Those who operate software can use SBOMs to quickly and easily determine whether they are at potential risk of a newly discovered vulnerability. A widely used, machine-readable SBOM format allows for greater benefits through automation and tool integration. The SBOMs gain greater value when collectively stored in a repository that can be easily queried by other applications and systems. Understanding the supply chain of software, obtaining an SBOM, and using it to analyze known vulnerabilities are crucial in managing risk. + +Allan and Kate spent time in their talk going into the current state of SBOMs, challenges, benefits, tools available for creating and sharing SBOMs, what is a minimum SBOM, standards being developed, making them fully automated, and more. Look for some future LF Blog posts digging into these. + +But there are things you can do now. + +### What can you and your organization do now? + +Allan and Kate laid out several things you and your organization can do, starting now. Starting within your organization: + +Next week: Understand origins of software your organization is using + +* Commercial: can you ask for an SBOM? +* Open source: do you have an SBOM for the binary or sources you’re importing? + +Three months: Understand what SBOMs your customers will require + +Expectations: which standards, dependency depth, licensing info? + +Six months: Prototype and deploy + +Implement SBOM through using an OSS tool and/or starting a conversation with vendor + +And participate in ongoing discussions to determine best practices for the ecosystem and contribute to open source project any code developed to support SBOMs. + +### But there are also steps you can take as an individual:  + +Next week: Start playing with an open source SBOM tool and apply it to a repo + +Three months: Have an SBOM strategy that explicitly identifies tooling needs + +Six months: + +Begin SBOM implementation through using an OSS tool or starting a conversation with vendor +Participate in a plugfest and try to consume another’s SBOM + +And make sure to share any open source and commercial tools you find helpful and work with the tools to help harden them, test and report bugs, and push them to scale. + +### How can you shape the future of SBOMs? + +First, I want to highlight some upcoming opportunities they shared to help shape the future of SBOMs. CISA is running public Tooling & Implementation work stream discussions in July 2022. They are the same, but occur at different times to help accommodate more time zones: + +* July 13, 2022 – 3:00-4:30 PM ET +* July 21, 2022 – 9:30-11:00 AM ET + +If you want to participate, please email [SBOM@cisa.dhs.gov][7]. + +Additionally, there will be “[plugfests][8]” to be announced soon, and they suggested organizations already adopting SBOMs publish case studies and reference tooling workflows to help others. + +### Conclusion + +SBOMs are here to stay. If you aren’t already, get on the train now. It is pulling out of the station, but you still have an opportunity to help shape where it is going and how well the journey goes. + +Allan’s and Kate’s slides are available [here][9]. If you registered to attend the RSA Conference, you can now watch their full presentation on demand [here][10]. + +### The Software Package Data ExchangeⓇ (SPDXⓇ) + +The Linux Foundation hosts SPDX, which is an open standard for communicating software bill of material information, including components, licenses, copyrights, and security references. SPDX reduces redundant work by providing a common format for companies and communities to share important data, thereby streamlining and improving compliance. The SPDX specification is an international open standard (ISO/IEC 5962:2021). Learn more at [spdx.dev][11]. + +The post [SBOM – SB Doesn’t Stand for Silver Bullet][12] appeared first on [Linux Foundation][13]. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/news/sbom-sb-doesnt-stand-for-silver-bullet/ + +作者:[Dan Whiting][a] +选题:[lkxed][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxfoundation.org/blog/sbom-sb-doesnt-stand-for-silver-bullet/ +[b]: https://github.com/lkxed +[1]: https://www.linkedin.com/in/allanafriedman/ +[2]: https://www.cisa.gov/ +[3]: https://www.linkedin.com/in/katestewartaustin/ +[4]: https://www.linuxfoundation.org/tools/the-state-of-software-bill-of-materials-sbom-and-cybersecurity-readiness/ +[5]: https://openssf.org/oss-security-mobilization-plan/ +[6]: https://openssf.org/blog/2021/05/14/how-lf-communities-enable-security-measures-required-by-the-us-executive-order-on-cybersecurity/ +[7]: https://www.linux.com/mailto:SBOM@cisa.dhs.gov +[8]: https://en.wikipedia.org/wiki/Plugtest +[9]: https://www.linuxfoundation.org/wp-content/uploads/Tooling-up-Getting-SBOMs-to-Scale_slides.pdf +[10]: https://www.rsaconference.com/usa/agenda/session/Tooling%20up%20Getting%20SBOMs%20to%20Scale +[11]: https://spdx.dev/ +[12]: https://www.linuxfoundation.org/blog/sbom-sb-doesnt-stand-for-silver-bullet/ +[13]: https://www.linuxfoundation.org/ diff --git a/sources/talk/20220616 -It-s time to contribute to open source-.md b/sources/talk/20220616 -It-s time to contribute to open source-.md new file mode 100644 index 0000000000..9d4e58d4d6 --- /dev/null +++ b/sources/talk/20220616 -It-s time to contribute to open source-.md @@ -0,0 +1,134 @@ +[#]: subject: "“It’s time to contribute to open source”" +[#]: via: "https://www.opensourceforu.com/2022/06/its-time-to-contributing-to-open-source/" +[#]: author: "Abbinaya Kuzhanthaivel https://www.opensourceforu.com/author/abbinaya-swath/" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +“It’s time to contribute to open source” +====== +Nilesh Vaghela is an AWS community hero and founder, ElectroMech Corporation, a cloud and open source company. According to him, contributing to open source is a rewarding act in itself. However, it needs commitment and there are many steps involved in the process, right from selecting a project to ensuring your contribution is noticed. In a conversation with Abbinaya Kuzhanthaivel of OSFY, he shares a few tips on how developers can help to improve India’s contributions to open source. + +![Nilesh Vaghela, +AWS community hero and +founder, ElectroMech Corporation][1] + +##### Q. Can you tell us a bit about your current role and contributions to open source. + +**A.** I am currently an architect working on automation. I lead multiple teams and also contribute majorly to Invinsense, an open source security service platform. I started open source groups in early 1998 and had around 1500 members even then. A group (https://groups.google.com/g/vglug) I am handling now has been very active since 2014-15. + +##### Q. How did you start working with open source projects? + +**A.** I am a mechanical engineer by qualification, and was dealing with modems and UPS systems at my firm ElectroMech Corporation. I slowly got dragged into handling PCs, networking and Linux. I started experimenting in 1996 after getting inspired by seeing over 150 computer servers running on Linux at a Nuclear Science Centre. That’s when I converted my company entirely, focusing on open source for training and support. + +I can proudly say that I was one of the first and early adopters of open source — helping customers to understand what is open source, what are its benefits, what’s available for free, security or code issues, and so on. We got at least four or five customers in Vadodara supporting us, and we eventually promoted ourselves through advertisements in the Yellow Pages. We partnered with Red Hat and the journey continues till now. + +##### Q. How do you think open source has evolved since then? + +A. I can say that, earlier, open source was a passion that fascinated and attracted people to participate. I was particularly impressed hearing user-friendly stories across the world when some Siberian contributors were working to improve water scarcity. It was more like a corporate social responsibility (CSR) activity. A board would be created by people and experts to govern and take projects forward. People would come in for the love of technology without expectations. + +I did not believe then that open source could get commercial, but it is the driving force for most of the innovation and technology today, and many more enterprises are adopting it. We are looking forward to a great balance in contribution to and use of open source, as we have people, communities and big companies coming into play. This is the real future and power of open source. + +##### Q. Could you share some of your challenges? + +A. Initially, I walked alone but people joined once they knew my intentions were good. I created a lot of communities without any expectation, but did get paid indirectly in terms of reputation or fame; some people understood that I was a technical expert and gave projects in the long term. As it was very early days, people started joining the community and contributing without much effort. The goal wasn’t to get business and hence I can say I didn’t really face any hurdles. + +##### Q. What are your leadership mantras and lessons from being a community leader? + +**A.** First, if you want to start a community, then be neutral and don’t harbour a biased opinion. It may look like you are running a community as a leader, but remember those joining you are contributing equally. And never demotivate anyone. Be polite while making comments and addressing queries. Whatever the question, if you don’t want to give an answer, then choose to be quiet. But don’t stop anyone from asking. Help them build expertise. + +Second, don’t involve the community in business. Do not mix and match the goals of your business and community. Have a clear differentiation. + +Always try to encourage people to participate instead of delivering instructions as an expert. If you find people are interested to lead and take initiatives, then give them the stage. Invite and engage them in the community. That will help you to make more community leaders. Also, keep your community simple and don’t involve sponsors in the initial stages. + +##### Q. Who do you look up to for inspiration? + +**A.** Richard Stallman, the father of the open source movement, is my inspiration and I have always admired his projects. + +Apart from him, I have an interesting incident to share that inspired me to work on open source. At the time when I started working on open source, most of the software for the Nuclear Science Centre was based on the Windows OS. However, many scientists wanted to work with Linux based software. And within two or three months, they actually created Linux drivers. This is what fascinated me – that the user can create these drivers which may not be possible in the case of proprietary software. I really liked the fact that open source empowered the user. + +##### Q. Your thoughts on the open source landscape in India and the scope for improvement. + +**A.** India is the largest consumer of open source and we are focusing on becoming a contributor. With so many developers around, we still do not have software giants in India. What we have mostly are service providers and not innovators. More people should become contributors to open source and develop something with international labels. + +The very thought of contributing to open source should begin from the level of schools and colleges. Fortunately, the Gujarat government has already introduced lessons based on Linux from Class 8 to Class 10. It is important to educate and make youngsters aware of open source models. + +Second, we have to develop good mentors. When people start contributing, it is important to find an open source mentor working in that particular project. The mentor gives a small assignment, tries the code and then commits it. If everything goes fine, the contribution is increased gradually. Unfortunately, we have very few mentors available in India. We need to prepare a lot of mentors or maybe connect to those across the world. + +Third, we need to encourage those who come forward to contribute. Once you are a recognised developer or a person contributing to open source development, you also progress in your career and business. + +India can be a major contributor to open source by following such simple methods. + +##### Q. What do you think about the coding requirements to contribute to open source? + +**A.** From my experience, if you know the internal parts, how to develop the application, what code standard you should maintain, and how to manage the team and other best practices, you may not have to actually worry about coding expertise. + +There are other roles too with respect to designing, security maintenance and integration. See what works for you. Develop and strengthen your skill in what you like to do. If you feel coding still interests you, then take the support of fellow developers to learn it. + +##### Q. How do you shortlist a project you would like to contribute to? + +A. You need to understand your top few interest areas and then do your research on the projects happening around them. You need to figure out the area of requirements or openings for contributors and more volunteers. You can start small to practice and then build expertise. + +Avoid going by the trendy topics; what’s important is your individual interest. For instance, DevOps is in high demand now and you may tend to go for a DevOps project. Do not make this mistake. + +You can find open source projects on Cloud Native Computing Foundation ([CNCF][2]), Apache, Fedora, Red Hat, and so on. This way you can also find mentors who are already working on projects and can get proper guidance. + +##### Q. Projects have their own purpose and target audience. Sometimes they even misalign with open source goals. So, what does one check before contributing? + +A. I agree it becomes challenging when somebody starts an open source project and then commercialises it. But this is always a risk, and should not discourage you. + +First try to check out the group — how popular are the contributors working in the group, how long have they been contributing, and how reputed are they. And once you join, observing everyone and everything is the key. Try to learn at least for three to six months, and understand how everything works. You can always leave the project if you find the intention is wrong. But if you feel it’s all right, then go ahead and contribute. + +![The team at ElectroMech Corporation][3] + +There are certain licence checks that you can do, say, like GPL version 3. You can also look at unmodified licence versions like the Apache open source licence. + +##### Q. Do you think big companies will accept contributions from freshers? + +A. Yes, of course. Companies also like mentoring. They usually don’t allow you to contribute directly, but may give you a small assignment initially. A mentor will first try to understand what skill you have and how good you are at it. Once they recognise you have the kind of skill that is needed, they will continue to guide you or assign you to some other mentor based on your skill. The initial stages are very crucial. Many companies do some sort of screening, and you may be allowed to contribute only after you have proved your ability. + +##### Q. What are the initial challenges that contributors have to overcome when picking up projects? + +A. First, you should be very serious about your contribution. There are no written commitments and contributors may tend to take the work lightly. That’s totally wrong. Try to dedicate 8-10 hours or whatever is feasible each day. If you are skipping this commitment because you feel there are no immediate returns, then you will not be a good contributor. +Always adhere to a mentor’s guidance strictly at the initial stages. This is very crucial for a healthy contribution. Sometimes it may happen that you believe you are good at something, while your mentor may not assign a project based on that skill. Simply approach your mentor in such scenarios and ask him what you should do, what is your role, and how you can contribute. + +##### Q. Many developers do not get replies after submitting the contribution to a project. How does one make a submission noticeable? + +A. Write a small blog on the project you are planning to contribute to, covering aspects like what you like in it, what you don’t like, and what can be improved. Such a positive and promotional approach can greatly help you. + +Be a part of the group and be involved in activities related to that particular project. Instead of contributing, first try to engage with the group, and this will increase the chances for you to get adopted as a contributor. + +Once you have a better understanding of the project, not only will your work be accepted but you will be able to better align yourself with that project. + +##### Q. How do you overcome a situation where your contribution is not accepted? + +A. Just understand that this can happen for many reasons — maybe you are not in the right project or you have not contributed correctly. If the project is country driven, your request may not be accepted. Hence, remember to have a checklist as stated earlier. Don’t worry if your contribution is not accepted because either you are not fit for the project or the project is not fit for you. + +All I would recommend is try to identify four or five projects, and at least one among those projects you work on will probably be accepted. + +##### Q. What is your message for our readers? + +A. Open source is the driving force behind most of the innovation happening today. Instead of just using open source, let us try to contribute according to our capacity and skills. Contributions can be in terms of code, documentation, testing, blogs, money, etc. It’s time to contribute. + +##### Q. Any hiring plans for ElectroMech Corporation — what are the roles and skill expectations? + +We have requirements in cloud DevOps, and are hiring cloud architects, Python developers, Linux architects and security professionals. + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/06/its-time-to-contributing-to-open-source/ + +作者:[Abbinaya Kuzhanthaivel][a] +选题:[lkxed][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/abbinaya-swath/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/05/Nilesh-Vaghela-AWS-community-hero-and-founder-ElectroMech-Corporation.jpg +[2]: https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwib2vvv3dv3AhVa7XMBHfZSCsIQFnoECAgQAQ&url=https%3A%2F%2Fwww.cncf.io%2F&usg=AOvVaw2LnRyH4SZPDHntRLJU_b3q +[3]: https://www.opensourceforu.com/wp-content/uploads/2022/05/The-team-at-ElectroMech-Corporation.jpg diff --git a/sources/talk/20220616 Using habits to practice open organization principles.md b/sources/talk/20220616 Using habits to practice open organization principles.md new file mode 100644 index 0000000000..f8992b3b80 --- /dev/null +++ b/sources/talk/20220616 Using habits to practice open organization principles.md @@ -0,0 +1,142 @@ +[#]: subject: "Using habits to practice open organization principles" +[#]: via: "https://opensource.com/open-organization/22/6/using-habits-practice-open-organization-principles" +[#]: author: "Ron McFarland https://opensource.com/users/ron-mcfarland" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Using habits to practice open organization principles +====== +Follow these steps to implement habits that support open culture and get rid of those that don't. + +![Selfcare, drinking tea on the porch][1] + +Image by: opensource.com + +Habits are a long-term interest of mine. Several years ago, I gave a presentation on habits, both good and bad, and how to expand on good habits and change bad ones. Just recently, I read the habits-focused book Smart Thinking by Art Markman. You might ask what this has to do with [open organization principles.][2] There is a connection, and I'll explain it in this two-part article on managing habits. + +In this first article, I talk about habits, how they work, and—most important—how you can start to change them. In the second article, I review Markman's thoughts as presented in his book. + +### The intersection of principles and habits + +Suppose you learned about open organization principles and although you found them interesting and valuable, you just weren't in the habit of using them. Here's how that might look in practice. + +Community: If you're faced with a significant challenge but think you can't address it alone, you're likely in the habit of just giving up. Wouldn't it be better to have the habit of building a community of like-minded people that collectively can solve the problem? + +Collaboration: Suppose you don't think you're a good collaborator. You like to do things alone. You know that there are cases when collaboration is required, but you don't have a habit of engaging in it. To counteract that, you must build a habit of collaborating more. + +Transparency: Say you like to keep most of what you do and know a secret. However, you know that if you don't share information, you're not likely to get good information from others. Therefore, you must create the habit of being more transparent. + +Inclusivity: Imagine you are uncomfortable working with people you don't know and who are different from you, whether in personality, culture, or language. You know that if you want to be successful, you must work with a wide variety of people. How do you create a habit of being more inclusive? + +Adaptability: Suppose you tend to resist change long after what you're doing is no longer achieving what you had hoped it would. You know you must adapt and redirect your efforts, but how can you create a habit of being adaptive? + +### What is a habit? + +Before I give examples regarding the above principles, I'll explain some of the relevant characteristics of a habit. + +* A habit is a behavior performed repeatedly—so much so that it's now performed without thinking. +* A habit is automatic and feels right at the time. The person is so used to it, that it feels good when doing it, and to do something else would require effort and make them feel uncomfortable. They might have second thoughts afterward though. +* Some habits are good and extremely helpful by saving you a lot of energy. The brain is 2% of the body's weight but consumes 20% of your daily energy. Because thinking and concentration require a lot of energy, your mind is built to save it through developing unconscious habits. +* Some habits are bad for you, so you desire to change them. +* All habits offer some reward, even if it is only temporary. +* Habits are formed around what you are familiar with and what you know, even habits you don’t necessarily like. + +### The three steps of a habit + +1. Cue (trigger): First, a cue or trigger tells the brain to go into automatic mode, using previously learned habitual behavior. Cues can be things like seeing a candy bar or a television commercial, being in a certain place at a certain time of day, or just seeing a particular person. Time pressure can trigger a routine. An overwhelming atmosphere can trigger a routine. Simply put, something reminds you to behave a certain way. +2. Routine: The routine follows the trigger. A routine is a set of physical, mental, and/or emotional behaviors that can be incredibly complex or extremely simple. Some habits, such as those related to emotions, are measured in milliseconds. +3. Reward: The final step is the reward, which helps your brain figure out whether a particular activity is worth remembering for the future. Rewards can range from food or drugs that cause physical sensations to joy, pride, praise, or personal self-esteem. + +### Bad habits in a business environment + +Habits aren't just for individuals. All organizations have good and bad institutional habits. However, some organizations deliberately design their habits, while others just let them evolve without forethought, possibly through rivalries or fear. These are some organizational habit examples: + +* Always being late with reports +* Working alone or working in groups when the opposite is appropriate +* Being triggered by excess pressure from the boss +* Not caring about declining sales +* Not cooperating among a sales team because of excess competition +* Allowing one talkative person to dominate a meeting + +### A step-by-step plan to change a habit + +Habits don't have to last forever. You can change your own behavior. First, remember that many habits can not be changed concurrently. Instead, find a keystone habit and work on it first. This produces small, quick rewards. Remember that one keystone habit can create a chain reaction. + +Here is a four-step framework you can apply to changing any habit, including habits related to open organization principles. + +##### Step one: identify the routine + +Identify the habit loop and the routine in it (for example, when an important challenge comes up that you can't address alone). The routine (the behaviors you do) is the easiest to identify, so start there. For example: "In my organization, no one discusses problems with anyone. They just give up before starting." Determine the routine that you want to modify, change, or just study. For example: "Every time an important challenge comes up, I should discuss it with people and try to develop a community of like-minded people who have the skills to address it." + +##### Step two: experiment with the rewards + +Rewards are powerful because they satisfy cravings. But, we're often not conscious of the cravings that drive our behavior. They are only evident afterward. For example, there may be times in meetings when you want nothing more than to get out of the room and avoid a subject of conversation, even though down deep you know you should figure out how to address the problem. + +To learn what a craving is, you must experiment. That might take a few days, weeks, or longer. You must feel the triggering pressure when it occurs to identify it fully. For example, ask yourself how you feel when you try to escape responsibility. + +Consider yourself a scientist, just doing experiments and gathering data. The steps in your investigation are: + +1. After the first routine, start adjusting the routines that follow to see whether there's a reward change. For example, if you give up every time you see a challenge you can't address by yourself, the reward is the relief of not taking responsibility. A better response might be to discuss the issue with at least one other person who is equally concerned about the issue. The point is to test different hypotheses to determine which craving drives your routine. Are you craving the avoidance of responsibility? +2. After four or five different routines and rewards, write down the first three or four things that come to mind right after each reward is received. Instead of just giving up in the face of a challenge, for instance, you discuss the issue with one person. Then, you decide what can be done. +3. After writing about your feeling or craving, set a timer for 15 minutes. When it rings, ask yourself whether you still have the craving. Before giving in to a craving, rest and think about the issue one or two more times. This forces you to be aware of the moment and helps you later recall what you were thinking about at that moment. +4. Try to remember what you were thinking and feeling at that precise instant, and then 15 minutes after the routine. If the craving is gone, you have identified the reward. + +##### Step three: isolate the cue or trigger + +The cue is often hard to identify because there's usually too much information bombarding you as your behaviors unfold. To identify a cue amid other distractions, you can observe four factors the moment the urge hits you: + +Location: Where did it occur? ("My biggest challenges come out in meetings.") + +Time: When did it occur? ("Meetings in the afternoon, when I'm tired, are the worst time, because I'm not interested in putting forth any effort.") + +Feelings: What was your emotional state? ("I feel overwhelmed and depressed when I hear the problem.") + +People: Who or what type of people were around you at the time, or were you alone? ("In the meetings, most other people don't seem interested in the problem either. Others dominate the discussion.") + +##### Step four: have a plan + +Once you have confirmed the reward driving your behavior, the cues that trigger it, and the behavior itself, you can begin to shift your actions. Follow these three easy steps: + +1. First, plan for the cue. ("In meetings, I'm going to look for and focus my attention on important problems that come up.") +2. Second, choose a behavior that delivers the same reward but without the penalties you suffer now. ("I'm going to explore a plan to address that problem and consider what resources and skills I need to succeed. I'm going to feel great when I create a community that's able to address the problem successfully.") +3. Third, make the behavior a deliberate choice each and every time, until you no longer need to think about it. ("I'm going to consciously pay attention to major issues until I can do it without thinking. I might look at agendas of future meetings, so I know what to expect in advance. Before and during every meeting, I will ask why should I be here, to make sure I'm focused on what is important." + +##### Plan to avoid forgetting something that must be done + +To successfully start doing something you often forget, follow this process: + +1. Plan what you want to do. +2. Determine when you want to complete it. +3. Break the project into small tasks as needed. +4. With a timer or daily planner, set up cues to start each task. +5. Complete each task on schedule. +6. Reward yourself for staying on schedule. + +### Habit change + +Change takes a long time. Sometimes a support group is required to help change a habit. Sometimes, a lot of practice and role play of a new and better routine in a low-stress environment is required. To find an effective reward, you need repeated experimentation. + +Sometimes habits are only symptoms of a more significant, deeper problem. In these cases, professional help may be required. But if you have the desire to change and accept that there will be minor failures along the way, you can gain power over any habit. + +In this article, I've used examples of community development using the cue-routine-reward process. It can equally be applied to the other open organization principles. I hope this article got you thinking about how to manage habits through knowing how habits work, taking steps to change habits, and making plans to avoid forgetting things you want done. Whether it's an open organization principle or anything else, you can now diagnose the cue, the routine, and the reward. That will lead you to a plan to change a habit when the cue presents itself. + +In my next article, I'll look at habits through the lens of Art Markman's thoughts on Smart Thinking. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/22/6/using-habits-practice-open-organization-principles + +作者:[Ron McFarland][a] +选题:[lkxed][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/ron-mcfarland +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/coffee_tea_selfcare_wfh_porch_520.png +[2]: https://theopenorganization.org/definition/open-organization-definition/ diff --git a/sources/talk/20220617 What scrum masters can learn from dancing.md b/sources/talk/20220617 What scrum masters can learn from dancing.md new file mode 100644 index 0000000000..511b99f955 --- /dev/null +++ b/sources/talk/20220617 What scrum masters can learn from dancing.md @@ -0,0 +1,63 @@ +[#]: subject: "What scrum masters can learn from dancing" +[#]: via: "https://opensource.com/article/22/6/scrum-master-dancing" +[#]: author: "Kelsea Zhang https://opensource.com/users/kelsea-zhang" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +What scrum masters can learn from dancing +====== +Like dancing, being a scrum master takes coordination, verbal and nonverbal communication, and cooperation. + +![OpenStack Superuser][1] + +Image by: Opensource.com + +Many scrum masters have an obsession with quickly turning their teams into what they want them to be. Once their expectations are not met within some arbitrary time limit, or someone resists their ideas, then the fight begins. + +But the fight takes energy, time, and resources, and most of the time it doesn't solve the problem. In fact, most of the time it worsens the problem. When this happens, it's time for some reflection about the role of the scrum master. + +### Priorities of the scrum master and the team + +Even when a team agrees that a problem is indeed a problem, the team may not agree on what's most urgent. As the scrum master, if you ask the team to make efforts to what the team perceives as a secondary conflict, the team will likely resist. They may cooperate nominally, but in the best case you're only getting a fraction of their potential. + +### Don't be stubborn + +Some scrum masters want to make their company look a very specific way, usually in accordance with common models or methods in the industry. Sometimes they openly confront managers who don't align with their vision of how things "should" be. + +It might feel like you're "fighting the good fight" when you attempt to do this, but that doesn't mean you're making progress. You have important work to do, and while your entire company might eventually be transformed, you have to start somewhere. The more support you gather from your team, the better chance you have of spreading your agile principles throughout the organization. + +### Dancing together + +A wise scrum master takes harmonious steps with their team, without stepping on each other's feet or tripping anyone up. Certainly, they could never be thought to be fighting each other. I call this "dancing together" because like dancing, it takes coordination, verbal and nonverbal communication, and cooperation. And when done even moderately well, it renders something elegant and enjoyable. + +### Awareness + +As a scrum master, you need to reflect on yourself all the time. How are your ideas and actions being received? If there's a sense of resistance or competition, then something is probably wrong, either in how you've been communicating, or how you've been seeking feedback and participation. + +As a scrum master, you need to be aware of your environment. There are ebbs and flows within an organization, times when great change is appropriate and times when fundamental groundwork must be laid. Look for that in your organization, starting with your team. Wait for the right person to be in the right place at the right time, wait for an opportunity, wait for a certain policy, and then integrate agile methodology to drive changes. + +### Get buy-in from the top + +In most organizations, the scrum master ultimately serves the business goals of upper management. Transparency and communication are important. It's your job to understand your organization's objectives. Ask for advice from your managers, and get a clear picture of the intentions and expectations of the rest of the company. A scrum master can help management achieve their goals with expertise and efficiency, but only if you understand the objective. + +### Tango over Foxtrot + +Most of the actual agile transformation in real enterprises is very slow. It is not a fast and furious battle. The scrum master has to step in rhythm with the pace of the enterprise. You must strike a balance between who leads and who flourishes. You don't want to move too slow, or too fast. You must not pursue perfection in everything. Allow for mistakes and misunderstandings. Don't blame each other, but stay focused on creating something vibrant together. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/6/scrum-master-dancing + +作者:[Kelsea Zhang][a] +选题:[lkxed][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/kelsea-zhang +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/LIFE_dance.png diff --git a/sources/talk/20220621 7 summer book recommendations from open source enthusiasts.md b/sources/talk/20220621 7 summer book recommendations from open source enthusiasts.md new file mode 100644 index 0000000000..5d1352dadb --- /dev/null +++ b/sources/talk/20220621 7 summer book recommendations from open source enthusiasts.md @@ -0,0 +1,184 @@ +[#]: subject: "7 summer book recommendations from open source enthusiasts" +[#]: via: "https://opensource.com/article/22/6/2022-opensourcecom-summer-reading-list" +[#]: author: "Joshua Allen Holm https://opensource.com/users/holmja" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +7 summer book recommendations from open source enthusiasts +====== +Members of the Opensource.com community recommend this mix of books covering everything from a fun cozy mystery to non-fiction works that explore thought-provoking topics. + +![Ceramic mug of tea or coffee with flowers and a book in front of a window][1] + +Image by: Photo by [Carolyn V][2] on [Unsplash][3] + +It is my great pleasure to introduce Opensource.com's 2022 summer reading list. This year's list contains seven wonderful reading recommendations from members of the Opensource.com community. You will find a nice mix of books covering everything from a fun cozy mystery to non-fiction works that explore thought-provoking topics. I hope you find something on this list that interests you. + +Enjoy! + +![Book title 97 Things Every Java Programmer Should Know][4] + +Image by: O'Reilly Press + +**[97 Things Every Java Programmer Should Know: Collective Wisdom from the Experts, edited by Kevlin Henney and Trisha Gee][5]** + +*[Recommendation written by Seth Kenlon][6]* + +Written by 73 different authors working in all aspects of the software industry, the secret to this book's greatness is that it actually applies to much more than just Java programming. Of course, some chapters lean into Java, but there are topics like Be aware of your container surroundings, Deliver better software, faster, and Don't hIDE your tools that apply to development regardless of language. + +Better still, some chapters apply to life in general. Break problems and tasks into small chunks is good advice on how to tackle any problem, Build diverse teams is important for every group of collaborators, and From puzzles to products is a fascinating look at how the mind of a puzzle-solver can apply to many different job roles. + +Each chapter is just a few pages, and with 97 to choose from, it's easy to skip over the ones that don't apply to you. Whether you write Java code all day, just dabble, or if you haven't yet started, this is a great book for geeks interested in code and the process of software development. + +![Book title A City is Not a Computer][7] + +Image by: Princeton University Press + +**[A City is Not a Computer: Other Urban Intelligences, by Shannon Mattern][8]** + +*[Recommendation written by Scott Nesbitt][9]* + +These days, it's become fashionable (if not inevitable) to make everything *smart*: Our phones, our household appliances, our watches, our cars, and, especially, our cities. + +With the latter, that means putting sensors everywhere, collecting data as we go about our business, and pushing information (whether useful or not) to us based on that data. + +This begs the question, does embedding all that technology in a city make it smart? In *A City Is Not a Computer*, Shannon Mattern argues that it doesn't. + +A goal of making cities smart is to provide better engagement with and services to citizens. Mattern points out that smart cities often "aim to merge the ideologies of technocratic managerialism and public service, to reprogram citizens as 'consumers' and 'users'." That, instead of encouraging citizens to be active participants in their cities' wider life and governance. + +Then there's the data that smart systems collect. We don't know what and how much is being gathered. We don't know how it's being used and by whom. There's *so much* data being collected that it overwhelms the municipal workers who deal with it. They can't process it all, so they focus on low-hanging fruit while ignoring deeper and more pressing problems. That definitely wasn't what cities were promised when they were sold smart systems as a balm for their urban woes. + +*A City Is Not a Computer* is a short, dense, well-researched polemic against embracing smart cities because technologists believe we should. The book makes us think about the purpose of a smart city, who really benefits from making a city smart, and makes us question whether we need to or even should do that. + +![Book title git sync murder][10] + +Image by: Tilted Windmill Press + +**[git sync murder, by Michael Warren Lucas][11]** + +*[Recommendation written by Joshua Allen Holm][12]* + +Dale Whitehead would rather stay at home and connect to the world through his computer's terminal, especially after what happened at the last conference he attended. During that conference, Dale found himself in the role of an amateur detective solving a murder. You can read about that case in the first book in this series, *git commit murder*. + +Now, back home and attending another conference, Dale again finds himself in the role of detective. *git sync murder* finds Dale attending a local tech conference/sci-fi convention where a dead body is found. Was it murder or just an accident? Dale, now the "expert" on these matters, finds himself dragged into the situation and takes it upon himself to figure out what happened. To say much more than that would spoil things, so I will just say *git sync murder* is engaging and enjoyable to read. Reading *git commit murder* first is not necessary to enjoy *git sync murder*, but I highly recommend both books in the series. + +Michael Warren Lucas's *git murder* series is perfect for techies who also love cozy mysteries. Lucas has literally written the book on many complex technical topics, and it carries over to his fiction writing. The characters in *git sync murder* talk tech at conference booths and conference social events. If you have not been to a conference recently because of COVID and miss the experience, Lucas will transport you to a tech conference with the added twist of a murder mystery to solve. Dale Whitehead is an interesting, if somewhat unorthodox, cozy mystery protagonist, and I think most Opensource.com readers would enjoy attending a tech conference with him as he finds himself thrust into the role of amateur sleuth. + +![Book title Kick Like a Girl][13] + +Image by: Inner Wings Foundation + +**[Kick Like a Girl, by Melissa Di Donato Roos][14]** + +*[Recommendation written by Joshua Allen Holm][15]* + +Nobody likes to be excluded, but that is what happens to Francesca when she wants to play football at the local park. The boys won't play with her because she's a girl, so she goes home upset. Her mother consoles her by relating stories about various famous women who have made an impact in some significant way. The historical figures detailed in *Kick Like a Girl* include women from throughout history and from many different fields. Readers will learn about Frida Kahlo, Madeleine Albright, Ada Lovelace, Rosa Parks, Amelia Earhart, Marie Curie, Valentina Tereshkova, Florence Nightingale, and Malala Yousafzai. After hearing the stories of these inspiring figures, Francesca goes back to the park and challenges the boys to a football match. + +*Kick Like a Girl* features engaging writing by Melissa Di Donato Roos (SUSE's CEO) and excellent illustrations by Ange Allen. This book is perfect for young readers, who will enjoy the rhyming text and colorful illustrations. Di Donato Roos has also written two other books for children, *How Do Mermaids Poo?* and *The Magic Box*, both of which are also worth checking out. + +![Book title Mine!][16] + +Image by: Doubleday + +**[Mine!: How the Hidden Rules of Ownership Control Our Lives, by Michael Heller and James Salzman][17]** + +*[Recommendation written by Bryan Behrenshausen][18]* + +"A lot of what you know about ownership is wrong," authors Michael Heller and James Salzman write in *Mine!* It's the kind of confrontational invitation people drawn to open source can't help but accept. And this book is certainly one for open source aficionados, whose views on ownership—of code, of ideas, of intellectual property of all kinds—tend to differ from mainstream opinions and received wisdom. In this book, Heller and Salzman lay out the "hidden rules of ownership" that govern who controls access to what. These rules are subtle, powerful, deeply historical conventions that have become so commonplace they just seem incontrovertible. We know this because they've become platitudes: "First come, first served" or "You reap what you sow." Yet we see them play out everywhere: On airplanes in fights over precious legroom, in the streets as neighbors scuffle over freshly shoveled parking spaces, and in courts as juries decide who controls your inheritance and your DNA. Could alternate theories of ownership create space for rethinking some essential rights in the digital age? The authors certainly think so. And if they're correct, we might respond: Can open source software serve as a model for how ownership works—or doesn't—in the future? + +![Book Title Not All Fairy Tales Have Happy Endings][19] + +Image by: Lulu.com + +**[Not All Fairy Tales Have Happy Endings: The Rise and Fall of Sierra On-Line, by Ken Williams][20]** + +*[Recommendation written by Joshua Allen Holm][21]* + +During the 1980s and 1990s, Sierra On-Line was a juggernaut in the computer software industry. From humble beginnings, this company, founded by Ken and Roberta Williams, published many iconic computer games. King's Quest, Space Quest, Quest for Glory, Leisure Suit Larry, and Gabriel Knight are just a few of the company's biggest franchises. + +*Not All Fairy Tales Have Happy Endings* covers everything from the creation of Sierra's first game, [Mystery House][22], to the company's unfortunate and disastrous acquisition by CUC International and the aftermath. The Sierra brand would live on for a while after the acquisition, but the Sierra founded by the Williams was no more. Ken Williams recounts the entire history of Sierra in a way that only he could. His chronological narrative is interspersed with chapters providing advice about management and computer programming. Ken Williams had been out of the industry for many years by the time he wrote this book, but his advice is still extremely relevant. + +Sierra On-Line is no more, but the company made a lasting impact on the computer gaming industry. *Not All Fairy Tales Have Happy Endings* is a worthwhile read for anyone interested in the history of computer software. Sierra On-Line was at the forefront of game development during its heyday, and there are many valuable lessons to learn from the man who led the company during those exciting times. + +![Book title The Soul of a New Machine][23] + +Image by: Back Bay Books + +**[The Soul of a New Machine, by Tracy Kidder][24]** + +*[Recommendation written by Guarav Kamathe][25]* + +I am an avid reader of the history of computing. It's fascinating to know how these intelligent machines that we have become so dependent on (and often take for granted) came into being. I first heard of [The Soul of a New Machine][26] via [Bryan Cantrill][27]'s [blog post][28]. This is a non-fiction book written by [Tracy Kidder][29] and published in 1981 for which he [won a Pulitzer prize][30]. Imagine it's the 1970s, and you are part of the engineering team tasked with designing the [next generation computer][31]. The backdrop of the story begins at Data General Corporation, a then mini-computer vendor who was racing against time to compete with the 32-bit VAX computers from Digital Equipment Corporation (DEC). The book outlines how two competing teams within Data General, both wanting to take a shot at designing the new machine, results in a feud. What follows is a fascinating look at the events that unfold. The book provides insights into the minds of the engineers involved, the management, their work environment, the technical challenges they faced along the way and how they overcame them, how stress affected their personal lives, and much more. Anybody who wants to know what goes into making a computer should read this book. + +There is the 2022 suggested reading list. It provides a variety of great options that I believe will provide Opensource.com readers with many hours of thought-provoking entertainment. Be sure to check out our previous reading lists for even more book recommendations. + +* [2021 Opensource.com summer reading list][32] +* [2020 Opensource.com summer reading list][33] +* [2019 Opensource.com summer reading list][34] +* [2018 Open Organization summer reading list][35] +* [2016 Opensource.com summer reading list][36] +* [2015 Opensource.com summer reading list][37] +* [2014 Opensource.com summer reading list][38] +* [2013 Opensource.com summer reading list][39] +* [2012 Opensource.com summer reading list][40] +* [2011 Opensource.com summer reading list][41] +* [2010 Opensource.com summer reading list][42] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/6/2022-opensourcecom-summer-reading-list + +作者:[Joshua Allen Holm][a] +选题:[lkxed][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/holmja +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/tea-cup-mug-flowers-book-window.jpg +[2]: https://unsplash.com/@sixteenmilesout?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]: https://unsplash.com/s/photos/tea?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: https://opensource.com/sites/default/files/2022-06/97_Things_Every_Java_Programmer_Should_Know_1.jpg +[5]: https://www.oreilly.com/library/view/97-things-every/9781491952689/ +[6]: https://opensource.com/users/seth +[7]: https://opensource.com/sites/default/files/2022-06/A_City_is_Not_a_Computer_0.jpg +[8]: https://press.princeton.edu/books/paperback/9780691208053/a-city-is-not-a-computer +[9]: https://opensource.com/users/scottnesbitt +[10]: https://opensource.com/sites/default/files/2022-06/git_sync_murder_0.jpg +[11]: https://mwl.io/fiction/crime#gsm +[12]: https://opensource.com/users/holmja +[13]: https://opensource.com/sites/default/files/2022-06/Kick_Like_a_Girl.jpg +[14]: https://innerwings.org/books/kick-like-a-girl +[15]: https://opensource.com/users/holmja +[16]: https://opensource.com/sites/default/files/2022-06/Mine.jpg +[17]: https://www.minethebook.com/ +[18]: https://opensource.com/users/bbehrens +[19]: https://opensource.com/sites/default/files/2022-06/Not_All_Fairy_Tales.jpg +[20]: https://kensbook.com/ +[21]: https://opensource.com/users/holmja +[22]: https://en.wikipedia.org/wiki/Mystery_House +[23]: https://opensource.com/sites/default/files/2022-06/The_Soul_of_a_New_Machine.jpg +[24]: https://www.hachettebookgroup.com/titles/tracy-kidder/the-soul-of-a-new-machine/9780316204552/ +[25]: https://opensource.com/users/gkamathe +[26]: https://en.wikipedia.org/wiki/The_Soul_of_a_New_Machine +[27]: https://en.wikipedia.org/wiki/Bryan_Cantrill +[28]: http://dtrace.org/blogs/bmc/2019/02/10/reflecting-on-the-soul-of-a-new-machine/ +[29]: https://en.wikipedia.org/wiki/Tracy_Kidder +[30]: https://www.pulitzer.org/winners/tracy-kidder +[31]: https://en.wikipedia.org/wiki/Data_General_Eclipse_MV/8000 +[32]: https://opensource.com/article/21/6/2021-opensourcecom-summer-reading-list +[33]: https://opensource.com/article/20/6/summer-reading-list +[34]: https://opensource.com/article/19/6/summer-reading-list +[35]: https://opensource.com/open-organization/18/6/summer-reading-2018 +[36]: https://opensource.com/life/16/6/2016-summer-reading-list +[37]: https://opensource.com/life/15/6/2015-summer-reading-list +[38]: https://opensource.com/life/14/6/annual-reading-list-2014 +[39]: https://opensource.com/life/13/6/summer-reading-list-2013 +[40]: https://opensource.com/life/12/7/your-2012-open-source-summer-reading +[41]: https://opensource.com/life/11/7/summer-reading-list +[42]: https://opensource.com/life/10/8/open-books-opensourcecom-summer-reading-list diff --git a/sources/talk/20220623 Applying smart thinking to open organization principles.md b/sources/talk/20220623 Applying smart thinking to open organization principles.md new file mode 100644 index 0000000000..57d446aa19 --- /dev/null +++ b/sources/talk/20220623 Applying smart thinking to open organization principles.md @@ -0,0 +1,136 @@ +[#]: subject: "Applying smart thinking to open organization principles" +[#]: via: "https://opensource.com/open-organization/22/6/applying-smart-thinking-open-organization-principles" +[#]: author: "Ron McFarland https://opensource.com/users/ron-mcfarland" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Applying smart thinking to open organization principles +====== +Use your environment, repetition, and the Role of 3 to enhance your thinking habits. + +![a magnifying glass looking at a brain illustration][1] + +Image by: Opensource.com + +Habits have an unfair reputation of being bad things that need to be stopped. But consider this: Automation and habits have many things in common. First, they're both repetitive. They're done over and over, the exact same way. More importantly, they reduce costs (both cost per piece and cost of energy used). + +[Art Markman's book Smart Thinking][2] stresses the importance of creating habits to take your mind away from unimportant thoughts and redirect your attention toward more interesting and creative ideas. You can apply this concept to the use of [open organization principles][3]. + +This article is the second part of a two-part series on habits. The first part drew from a presentation I gave a few years ago. In this article, I apply new information from Markman. + +### What is smart thinking? + +Smart thinking is about the information you have, how you get valuable information, and how you use what you have successfully. It's also the ability to solve new problems using your current knowledge. Smart thinking is a skill you can use, practice, and improve on. Based on that definition, those benefits would be very helpful in promoting open organization principles. + +### Forming habits + +Markman says habits are formed, unthinkingly automatic, and rarely reviewed for their importance. A process of strategic thinking is required to do this review. If performed correctly, less effort is needed to change these habits. The human mental system is designed to avoid thinking when possible. It's preferable to just effortlessly act on routine tasks so you can direct your attention to more important issues. When you perform tasks repeatedly, you form habits so your mind doesn't have to think through them step by step. + +That's why you can't remember things you did a few seconds ago. Markman gives the example of not remembering whether you locked the door of your apartment or house. Because you did it automatically, if you were thinking of something completely different when you locked the door, you likely don't know whether you locked it. + +The goal of smart thinking is to develop as many good habits as possible, so your mind doesn't have to go through the effort of thinking every time you perform them. Developing checklists is a good way to avoid excessive thinking. This can be applied to open organization principles as well. To save on energy and effort, follow a list of items and act on them. This was my goal when I developed the [Communication technology maturity worksheet][4], which I wrote about in my article "[How to assess your organization's technical maturity][5]." If there's no routine and the activity is new, you must resort to a more stressful and tiring thought process. + +### Importance of environment and repetition + +Markman describes a formula for creating smart habits, considering two key facts: + +* There is interaction between environment and action. +* Only work on repeated actions to create good habits. + +#### Environment + +Markman defines an environment as both the outside world and one's internal mental world (such as goals, feelings, or perspectives). In the outside world, you can develop seemingly meaningless activities to create triggers and reminders. For example, you assign convenient locations for things, so you don't have to think about where they are. You can create triggers (such as lists or empty packages for resupply reminders) to highlight things you need to do, thereby avoiding a lot of thought. + +If you want to read a book but have been putting it off, consider taking it out and putting it in front of your computer or TV. That way, you'll see it, and probably have to move it out of your way, each time you're at your computer or TV, which can be a powerful way to get you reading. + +If you learn something in a particular place (with all its surroundings), you will recall that learning more easily if you are in a similar place or the same place. The environment triggers the information to come to the top of your mind. Because new (wanted) habits must be consciously performed, you must add elements in your environment to remind yourself to do them. Also, you must eliminate triggers that remind you of the old (unwanted) habit and replace them with another activity. + +For the internal mental environment, consider trying to memorize useful facts that are continually required, such as names, locations, the best road routes, and so on. If I meet someone I want to get to know better, I ask for their name and use it as much as possible, then write it down when I have a chance. Later, I add that name to my personal contact information. By repeatedly seeing the name, I eventually memorize it and use it without thinking. + +#### Repetition + +All habits are formed through repeated use, and the first time is the hardest. After many repetitions, minimal thought is required, until the habit becomes automatic. Structure your daily life by forming beneficial habits and practicing them. Regular role playing is equally important. By getting those memories top of mind, they become faster to retrieve. + +If you can make each habit as distinct as possible, it will be easier to remember and retrieve when needed. You know you've created a good habit when you no longer have to think about it. + +### When good habits go bad + +A habit can go from good to bad with a situational change. Getting rid of a bad habit and creating a productive new one takes a lot of thought. When a habit change is required, regularly getting a good night's sleep is essential. Your brain helps process the new experiences and behaviors and makes the activity more effective in the future. + +There are two important characteristics of changing habits: + +1. Your current habit pushes you into action. You must overcome the pressure to act. +2. When there's pressure to act, replace the habit with a more helpful action. New memories of the desired action must be developed and stored. + +You must develop triggers to engage the new behavior. This trigger requires your attention, as you are forcing yourself to stop the strong current habit and develop a new and, initially, weak habit. If you are distracted, the old habit remains strong. Your effort could also be disrupted by stress, fatigue, or the powerful influence of your environment. + +Willpower alone cannot change habits, and it's extremely exhausting to try. You might have some short-term successes, but you will wear out eventually. You need environmental support. Cravings happen when you have an active goal that has been blocked. They are your mind's way of saying you must strengthen your desired goal further. You must not only stop the old habit but study what in your environment is activating it. + +To apply these concepts to open organization principles, consider how you can create an environment that makes it easy to activate a principle while discouraging the current unproductive behavior. You must create an environment that reduces the chance of the bad habit being recalled and create triggers to activate the principles. That's the goal of the open organization leadership assessments. They become triggers. + +### The Role of 3 + +One of Markman's key concepts is the Role of 3, which guides both effective learning and effective presentation of information in a way that will be remembered. Markman is talking about getting someone else to change his behavior. This reminds me of my sales seminar in which I wanted to improve (change) the sales associates' selling activities. There is a difference between education, which is just providing knowledge, and training. Training is developing a skill one can use and improve on. Therefore, I had to cut three-quarters of the content and repeat it four times in different ways in my seminars, including role playing. I think what Markman is saying is that stressing just three actions is ideal initially. In my sales training case, my greatest success was role playing product presentations. Not only did the sales people learn the features of the product, but they could talk about them confidently to customers. Afterward, that led to other skills that could be developed. + +This Role of 3 applies to you too when wanting to act on something. Imagine a critical business meeting with vital information presented. Suppose you were distracted by jokes or anxiety-provoking rumors (about layoffs, demotions, or inadequate performance). The meeting could be a waste of your time unless you manage your attention on specific issues. + +Here is what Markman recommends before, during, and after an important event, to learn three key points: + +1. Prepare: Consider what you want to get out of the event (be it a meeting, presentation, or one-on-one discussion) and what you want to achieve. Consider at most three things. Information connected to your goal is easier to detect and remember. Your mental preparation directs your mind to the information you seek. Psychologists call this advance organizer activity. Consider what will be discussed and review any available materials beforehand. +2. Pay attention: This is hard work, particularly when there are distractions. Avoid multitasking on unrelated work (including emails and instant messaging). Working memory is an important concept: Your attention impacts what you will remember later. +3. Review: After any critical information-gathering event (a class, meeting, reading a book or article), write down three key points. If you can't write it down, review it in your mind, or record it on your phone or digital recorder. Try to attach what you learned to what you know. Where do they match or conflict? + +Suppose you're presenting open organization principles to a group. To make sure they remember those principles and use them, follow these procedures: + +1. Start presentations with an agenda and outline for all to review. +2. During the presentation, stay focused primarily on your three critical points. Present all principles, but continually review and highlight three of them. +3. Help people connect the content to what they are doing now and how the principles will improve their activities. +4. Share additional ways the principles can be applied with example use cases and their benefits. +5. End all presentations with a three-point summary. An action plan can be helpful as well. + +Say you're presenting the five open organization principles of transparency, collaboration, inclusivity, adaptability, and community. First, you present all of them in basic terms, but the Role of 3 tells you the audience will probably only pick up on three of them, so you focus on transparency, collaboration, and inclusivity. + +Here's an example outline, following the Role of 3: + +1. Present three key ideas. + 1. Transparency + 2. Collaboration + 3. Inclusivity +2. Organize the presentation by describing each key idea in one sentence. + 1. Transparency is getting as much useful information to other people as possible. + 2. Collaboration is discussing issues with as many other people as appropriate and avoiding making final decisions on your own. + 3. Inclusivity is getting as many different kinds of people involved in a project as appropriate. +3. Develop key idea relationships. + 1. How is transparency related to what people already know? The more transparent you are, the easier it is to collaborate. + 2. How is collaboration related to what people already know, including transparency? If people are doing well with transparency, mention many times that by collaborating more, their transparency will improve. + 3. How is inclusivity related to what people already know, including transparency and inclusivity? The more inclusive we are, the more diverse the ideas generated, leading to more transparency and collaboration. +4. Provide three questions to help people remember and explain the ideas. + 1. When was the last time you paused before deciding something and decided instead to collaborate with all people concerned? + 2. Who do you think would be an easy person to collaborate with? + 3. Each week, how many people do you collaborate with? Should that number be improved upon? + +### Better for everyone + +Now you know what smart thinking is all about. You've learned the Role of 3, and you understand the importance of environment and repetition. These concepts can help you be more productive and happier in whatever you get involved in, including bringing the open organization principles to your own communities. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/22/6/applying-smart-thinking-open-organization-principles + +作者:[Ron McFarland][a] +选题:[lkxed][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/ron-mcfarland +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/LAW_EvidencedBasedIP_520x292_CS.png +[2]: https://www.amazon.com/Smart-Thinking-Essential-Problems-Innovate/dp/0399537759 +[3]: https://theopenorganization.org/definition/open-organization-definition/ +[4]: https://opensource.com/sites/default/files/images/open-org/communication_tech_worksheet.pdf +[5]: https://opensource.com/open-organization/20/3/communication-technology-worksheet diff --git a/sources/talk/20220624 Create a more diverse and equitable open source project with open standards.md b/sources/talk/20220624 Create a more diverse and equitable open source project with open standards.md new file mode 100644 index 0000000000..4e1b99c3b0 --- /dev/null +++ b/sources/talk/20220624 Create a more diverse and equitable open source project with open standards.md @@ -0,0 +1,130 @@ +[#]: subject: "Create a more diverse and equitable open source project with open standards" +[#]: via: "https://opensource.com/article/22/6/open-source-standards-diversity" +[#]: author: "Paloma Oliveira https://opensource.com/users/discombobulateme" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Create a more diverse and equitable open source project with open standards +====== +Using open standards improves your project's quality and shareability. Most importantly, they can guide technology development by gently enforcing space for diversity and equity. + +![multi-colored dandelions][1] + +Image by: [Monsterkoi][2]. Modified by Opensource.com. [CC BY-SA 4.0][3] + +This article is intended to serve as a reference so that you can understand everything you need to be proud of your repository and make your open source project more open. By using open standards, an open source project improves its quality and shareability, since such standards exist to foster better communication between creators and consumers of the project. Most importantly, open standards can guide technology development by gently enforcing space for diversity and equity. + +### What is open source? + +The term [open source][4] started in the late 80's as a way to guarantee access to technological development by legally guaranteeing the right to copy, modify, and redistribute software. This idea has expanded and today it is about fostering a culture of sharing that supports everything from political actions to a billion dollar technology industry. + +The projects and their communities, which give the projects their value, have become much more complex than just the code. Today, it is impossible to think of a project outside of what I prefer to define as its ecosystem. "Ecosystem" sounds to me like a proper definition, because it acknowledges the complexity of technical things, like code and configuration, and also of people. + +### Lack of diversity is a problem in open source + +Without open source, the technology industry would collapse, or it wouldn't even exist. That's the scope of importance that open source has today. What a powerful feeling it is to know that we are all "standing on the shoulders of giants"? We are all benefiting from the power of the commons, using collective labor and intelligence to make something better for everyone. + +What's rarely spoken of is that such important initiatives, in most cases, depend solely on the volunteer labor of its maintainers. This creates a huge imbalance, both from work and diversity aspects. + +Open source is intrinsically a power to foster diversity within the development industry by valuing the contributions of what is contributed over who is contributing it. The reality is, though, that free time is often a rare commodity for many people. Many people are too busy working to generate income, caring for families and loved ones, looking for work, fighting social injustice, and are unable to dedicate time to contribute to software. + +The very opportunity to contribute to the system depends on you being one of the lucky ones who can be part of this system. This is not a reality for many others because of their gender, skin color, or social status. Historically, women accumulate unpaid work that's invisible, but which requires a substantial proportion of their energy and time. Underprivileged people have little free time because they have to work more hours, often having more than one job. + +This is reflected in the numbers. [Only 4.5%][5] of [open source maintainers][6] are not white males, according to research into the field. So we know that this billion dollar industry, shaping technological development, is composed of a homogeneous environment. But we also know that diversity renders robust innovative results.The question is, how can this be changed? + +### Intentional communication with your open source community + +Communication is key. Build a structure with transparency of communication and governance for your project. Clear, concise and respectful communication makes your project accessible to users and contributors. It helps project maintainers devote their time focusing on what they need to do. It helps interested people feel welcome and start contributing faster and more consistently, and it attracts diversity to your community. + +Sounds great, but how can this be obtained? I grouped the rules of good practice into three categories procedural, daily, and long term. These practices are in part strategic, but if you and your community don't have the capacity to be strategic, it's also possible to substantially change your project by adding a few simple files to your repository. + +But which files are those, and what happens when you already have several projects under your management? A few of them are: + +* Code of conduct +* License +* Readme +* Changelog +* Contributing +* Ownership +* Test directory +* Issues +* Pull request templates +* Security +* Support + +To help you get started, there are many projects that offer templates. By simply cloning them, you create a repository with these documents. + +Another tool, designed to help open source software (OSS) maintainers and open source program offices (OSPO) is [check-my-repo][7]. Created by us at [Sauce Labs' OSPO Community][8], it's an automated tool built on [Repolinter][9] that verifies whether the main necessary parameters to comply with open source best practices (including the files mentioned above and a few other rules), are present in your repositories. The web app also explains why each file needs to exist. + +#### Procedural best practices + +As the name implies, this is about the process: + +* Maintain a single public issue tracker. +* Allow open access to the issues identified by the project. +* Have mechanisms for feedback and to discuss new features. +* Offer public meeting spaces scheduled in advance and have them recorded. + +Here are some files that relate to the procedural logic: + +* README: Make it easier for anyone who lands on your project to get started. +* Code of conduct: Establish expectations and facilitate a healthy and constructive community. +* Ownership: Make sure that someone is put in charge of the project to prevent it from being forgotten. + +#### Daily tasks + +This is about the day-to-day aspects, including: + +* Check the status of the project. +* Explain how to submit issues, propose enhancements, and add new features. +* Show how to contribute to the project. + +Files related to the daily aspects of project management are: + +* Contributing: A step by step guideline on how to contribute. +* Changelog: Notable changes need to be logged. +* Security: Show how to report a security vulnerability. +* Support: How the project is being maintained. + +#### Long term goals + +This has information that guarantees the history and continuation of the project, such as a mission statement, key concepts and goals, a list of features and requirements, and a project roadmap. + +Relevant files are: + +* License: It's essential for users to know their limits, and for you to protect yourself legally. +* Test directory: Use this to avoid regression, breaks, and many other issues. + +### Creating and maintaining your open source project + +Now imagine a project with all of these factors. Will it help you build and keep a community? Will noise in communication be mitigated? Will it save maintainers tons of time so they can onboard people and solve issues? Will people feel welcome? + +Creating and maintaining an open source project is very rewarding. Creating collaboratively is an incredible experience and has the intrinsic potential to take such creation into possibilities that one person alone, or a small group could never achieve. But working openly and collaboratively is also a challenge for the maintainers and a responsibility for the community to ensure that this space is equitable and diverse. + +There's a lot of work ahead. The result of surveys on the health of open source communities often reflect the worst of the technology industry. That's why ensuring that these standards are used is so important. To help mitigate this situation, I am betting on standards. They're a powerful tool to align our intentions and to guide us to an equitable, transparent, and shareable space. Will you join me? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/6/open-source-standards-diversity + +作者:[Paloma Oliveira][a] +选题:[lkxed][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/discombobulateme +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/diversity-inclusion-transformation-change_20180927.png +[2]: https://pixabay.com/en/dandelion-colorful-people-of-color-2817950/ +[3]: https://creativecommons.org/publicdomain/zero/1.0/deed.en +[4]: https://opensource.com/article/18/2/coining-term-open-source-software +[5]: https://www.wired.com/2017/06/diversity-open-source-even-worse-tech-overall/ +[6]: https://www.linuxfoundation.org/blog/addressing-diversity-equity-and-inclusion-in-2021-and-beyond +[7]: https://opensource.saucelabs.com/check-my-repo +[8]: https://opensource.saucelabs.com +[9]: https://todogroup.github.io/repolinter diff --git a/sources/talk/20220627 Accessibility in Fedora Workstation.md b/sources/talk/20220627 Accessibility in Fedora Workstation.md new file mode 100644 index 0000000000..0fe841bdf4 --- /dev/null +++ b/sources/talk/20220627 Accessibility in Fedora Workstation.md @@ -0,0 +1,63 @@ +[#]: subject: "Accessibility in Fedora Workstation" +[#]: via: "https://fedoramagazine.org/accessibility-in-fedora-workstation/" +[#]: author: "Christian Fredrik Schaller https://fedoramagazine.org/author/uraeus/" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Accessibility in Fedora Workstation +====== +![Accessibility in Fedora Workstation Featured Image][1] + +Photo by [Elizabeth Woolner][2] on [Unsplash][3] + +The first concerted effort to support accessibility under Linux was undertaken by Sun Microsystems when they decided to use GNOME for Solaris. Sun put together a team focused on building the pieces to make GNOME 2 fully accessible and worked with hardware makers to make sure things like Braille devices worked well. I even heard claims that GNOME and Linux had the best accessibility of any operating system for a while due to this effort. As Sun started struggling and got acquired by Oracle this accessibility effort eventually trailed off with the community trying to pick up the slack afterwards. Especially engineers from Igalia were quite active for a while trying to keep the accessibility support working well. + +But over the years we definitely lost a bit of focus on this and we know that various parts of GNOME 3 for instance aren’t great in terms of accessibility. So at Red Hat we have had a lot of focus over the last few years trying to ensure we are mindful about diversity and inclusion when hiring, trying to ensure that we don’t accidentally pre-select against underrepresented groups based on for instance gender or ethnicity. But one area we realized we hadn’t given so much focus recently was around technologies that allowed people with various disabilities to make use of our software. Thus I am very happy to announce that Red Hat has just hired Lukas Tyrychtr, who is a blind software engineer, to lead our effort in making sure Red Hat Enterprise Linux and Fedora Workstation has excellent accessibility support! + +Anyone who has ever worked for a large company knows that getting funding for new initiatives is often hard and can take a lot of time, but I want to highlight how I was extremely positively surprised at how quick and easy it was to get support for hiring Lukas to work on accessibility. When Jiri Eischmann and I sent the request to my manager, Stef Walter, he agreed to champion the same day, and when we then sent it up to Mike McGrath who is the Vice President of Linux Engineering he immediately responded that he would bring this to Tim Cramer who is our Senior Vice President of Software Engineering. Within a few days we had the go ahead to hire Lukas. The fact that everyone just instantly agreed that accessibility is important and something we as a company should do made me incredibly proud to be a Red Hatter. + +What we hope to get from this is not only a better experience for our users, but also to allow even more talented engineers like Lukas to work on Linux and open source software at Red Hat. I thought it would be a good idea here to do a quick interview with Lukas Tyrychtr about the state of accessibility under Linux and what his focus will be. + +Christian: Hi Lukas, first of all welcome as a full time engineer to the team! Can you tell us a little about yourself? + +Lukas: Hi, Christian. For sure. I am a completely blind person who can see some light, but that’s basically it. I started to be interested in computers around 2009 or so, around my 15th or 16th birthday. First, because of circumstances, I started tinkering with Windows, but Linux came shortly after, mainly because of some pretty good friends. Then, after four years the university came and the Linux knowledge paid off, because going through all the theoretical and practical Linux courses there was pretty straightforward (yes, there was no GUI involved, so it was pretty okay, including some custom kernel configuration tinkering). During that time, I was contacted by Red Hat associates whether I’d be willing to help with some accessibility related presentation at our faculty, and that’s how the collaboration began. And, yes, the hire is its current end, but that’s actually, I hope, only the beginning of a long and productive journey. + +Christian: So as a blind person you have first hand experience with the state of accessibility support under Linux. What can you tell us about what works and what doesn’t work? + +Lukas: Generally, things are in pretty good shape. Braille support on text-only consoles basically just always works (except for some SELinux related issues which cropped up). Having speech there is somewhat more challenging, the needed kernel module ([Speakup][4] for the curious among the readers) is not included by all distributions, unfortunately it is not included by Fedora, for example, but Arch Linux has it. When we look at the desktop state of affairs, there is basically only a single screen reader (an application which reads the screen content), called [Orca][5], which might not be the best position in terms of competition, but on the other hand, stealing Orca developers would not be good either. Generally, the desktop is usable, at least with GTK, Qt and major web browsers and all recent Electron based applications. Yes, accessibility support receives much less testing than I would like, so for example, a segmentation fault with a running screen reader can still unfortunately slip through a GTK release. But, generally, the foundation works well enough. Having more and naturally sounding voices for speech synthesis might help attract more blind users, but convincing all the players is no easy work. And then there’s the issue of developer awareness. Yes, everything is in some guidelines like the GNOME ones, however I saw much more often than I’d like to for example a button without any accessibility labels, so I’d like to help all the developers to fix their apps so accessibility regressions don’t get to the users, but this will have to improve slowly, I guess. + +Christian: So you mention Orca, are there other applications being widely used providing accessibility? + +Lukas: Honestly, only a few. There’s Speakup – a kernel module which can read text consoles using speech synthesis, e.g. a screen reader for these, however without something like Espeakup (an Espeak to Speakup bridge) the thing is basically useless, as it by default supports hardware synthesizers, however this piece of hardware is basically a think of the past, e.g. I have never seen one myself. Then, there’s [BRLTTY][6]. This piece of software provides braille output for screen consoles and an API for applications which want to output braille, so the drivers can be implemented only once. And that’s basically it, except for some efforts to create an Orca alternative in Rust, but that’s a really long way off. Of course, utilities for other accessibility needs exist as well, but I don’t know much about these. + +Christian: What is your current focus for things you want to work on both yourself and with the larger team to address? + +Lukas: For now, my focus is to go through the applications which were ported to GTK 4 as a part of the GNOME development cycle and ensure that they work well. It includes adding a lot of missing labels, but in some cases, it will involve bigger changes, for example, GNOME Calendar seems to need much more work. During all that, educating developers should not be forgotten either. With these things out of the way, making sure that no regressions slip to the applications should be addressed by extending the quality assurance and automated continuous integration checks, but that’s a more distant goal. + +Christian: Thank you so much for talking with us Lukas, if there are other people interested in helping out with accessibility in Fedora Workstation what is the best place to reach you? + +Actually for now the easiest way to reach me is by email at [ltyrycht@redhat.com][7]. Be happy to talk to anyone wanting to help with making Workstation great for accessibility. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/accessibility-in-fedora-workstation/ + +作者:[Christian Fredrik Schaller][a] +选题:[lkxed][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/uraeus/ +[b]: https://github.com/lkxed +[1]: https://fedoramagazine.org/wp-content/uploads/2022/06/Accessibility-in-Fedora-Workstation-816x345.jpg +[2]: https://unsplash.com/@elizabeth_woolner?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]: https://unsplash.com/s/photos/accessibility?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: http://www.linux-speakup.org/speakup.html +[5]: https://wiki.gnome.org/action/show/Projects/Orca?action=show&redirect=Orca +[6]: https://brltty.app/ +[7]: https://fedoramagazine.org/mailto:ltyrycht@redhat.com diff --git a/sources/talk/20220705 GitHub Copilot Is Only Effective Because It Steals Open Source Code.md b/sources/talk/20220705 GitHub Copilot Is Only Effective Because It Steals Open Source Code.md new file mode 100644 index 0000000000..b321dedb8d --- /dev/null +++ b/sources/talk/20220705 GitHub Copilot Is Only Effective Because It Steals Open Source Code.md @@ -0,0 +1,38 @@ +[#]: subject: "GitHub Copilot Is Only Effective Because It Steals Open Source Code" +[#]: via: "https://www.opensourceforu.com/2022/07/github-copilot-is-only-effective-because-it-steals-open-source-code/" +[#]: author: "Laveesh Kocher https://www.opensourceforu.com/author/laveesh-kocher/" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +GitHub Copilot Is Only Effective Because It Steals Open Source Code +====== +![github-logo-2][1] + +The Software Freedom Conservancy (SFC), a non-profit community of open source advocates, announced its withdrawal from GitHub today in a scathing blog post urging members and supporters to publicly condemn the platform. The SFC’s issue with GitHub stems from allegations that Microsoft and OpenAI trained an AI system called Copilot on data that had been made available under an open source licence. Open source code is not like a donation box where you can take whatever you want and use it however you want. + +It’s closer to photography. Even if a photographer does not charge you to use one of their images, you are still required to give credit where credit is due. According to an SFC [blog post][2], Copilot does not do this when it comes to using other people’s code snippets: + +“This harkens to long-standing problems with GitHub, and the central reason why we must together give up on GitHub. We’ve seen with Copilot, with GitHub’s core hosting service, and in nearly every area of endeavor, GitHub’s behavior is substantially worse than that of their peers. We don’t believe Amazon, Atlassian, GitLab, or any other for-profit hoster are perfect actors. However, a relative comparison of GitHub’s behavior to those of its peers shows that GitHub’s behavior is much worse.” + +GitHub is the world’s de facto repository for open source code. It’s a cross between YouTube, Twitter, and Reddit, but for programmers and the code they create. Sure, there are alternatives. Switching from one code-repository ecosystem to another, however, is not the same as trading Instagram for TikTok. Microsoft paid more than $7 billion to acquire GitHub in 2018. Since then, Microsoft has used its position as OpenAI’s primary benefactor to collaborate on the development of Copilot. And access to Copilot is only available through a special invitation from Microsoft or through a paid subscription. The SFC and other open source advocates are outraged because Microsoft and OpenAI are effectively monetizing other people’s code while removing the ability for those who use that code to properly credit those who use it. + +Copilot must be killed. Alternately, Microsoft and OpenAI could construct a time machine and travel back in time to label every single datapoint in Copilot’s database, allowing them to create a second model that gives proper credit to every output. But it’s always easier to take advantage of people and exploit the Wild West regulatory environment than it is to care about the ethics of the products and services you offer. + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/07/github-copilot-is-only-effective-because-it-steals-open-source-code/ + +作者:[Laveesh Kocher][a] +选题:[lkxed][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/laveesh-kocher/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/07/github-logo-2-e1657018894307.png +[2]: https://sfconservancy.org/blog/2022/jun/30/give-up-github-launch/ diff --git a/sources/talk/20220711 Why Agile coaches need internal cooperation.md b/sources/talk/20220711 Why Agile coaches need internal cooperation.md new file mode 100644 index 0000000000..ed15dbc048 --- /dev/null +++ b/sources/talk/20220711 Why Agile coaches need internal cooperation.md @@ -0,0 +1,89 @@ +[#]: subject: "Why Agile coaches need internal cooperation" +[#]: via: "https://opensource.com/article/22/7/agile-coach-internal-cooperation" +[#]: author: "Kelsea Zhang https://opensource.com/users/kelsea-zhang" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Why Agile coaches need internal cooperation +====== +An Agile coach is only as successful as their Agile partner. Here's how to foster internal cooperation and create an Agile team. + +![Working meetings can be effective meetings][1] + +Image by Mapbox Uncharted ERG, [CC-BY 3.0 US][2] + +If you're an Agile coach, you probably seek to inspire and empower others as an external member of your team or department. However, many Agile coaches overlook the importance of internal cooperation. That's not necessarily a term you are familiar with, so allow me to explain. + +### What is internal cooperation? + +As an Agile coach, you don't work alone. You try to find a partner in the team you're taking care of. This partner is expected to: + +* Undertake all or most of the Agile transformation in the future. +* Find all possible opportunities for systematic improvement and team optimization. +* Be self-motivated. +* Not be managed by you; you delegate your enthusiasm and vision to them. + +Of course, maybe you don't need such a person because, theoretically speaking, everyone in the team is your ideal candidate, and everyone is self-driven. Or maybe your whole team will magically become what you want it to be overnight. + +Reality check: most of the time, you need a partner, an inside agent. Somebody to keep the spirit of Agile alive, whether you're there to encourage it or not. + +### Internal cooperation is required + +Getting buy-in from the team you are coaching isn't a luxury; it's a requirement. If you're the only Agile practitioner on your team, then your team isn't Agile! So how do you cultivate this internal cooperation? + +#### Clarify responsibility + +Being Agile is supposed to be a team effort. The beneficiary is the team itself, but the team must also bear the burden of transformation. An Agile coach is meant to be inspiring and empowering, but the change doesn't happen in just one person. That's why teams must learn to consider and solve problems on their own. A team must have its own *engine* (your Agile partner is such an engine) rather than relying on the external force of the Agile coach. It's the engines that want to solve problems, and with the help of Agile coaches, their abilities and ways of thinking can be enriched and improved. + +It's best to have an engine from the beginning, but that's not always possible. The earlier, the better, so look for allies from the start. + +#### Know the team + +When you find a partner, you gain someone who understands the team's situation better than you do. A good partner knows the team from the inside and communicates with it on a level you cannot. No matter how good you are as an Agile coach, you must recognize that an excellent Agile partner has a unique advantage in "localization." + +The best approach is not *An Agile coach makes a customized implementation plan for the team, and then the team is responsible for execution*. In my opinion, with the support of the Agile coach, the Agile partner should work with the team to make plans that best fit its needs. Next, try to implement those plans with frequent feedback and keep adjusting them as needed. + +You continue to observe progress, whether the team members falter in Agile principles, and give them support at the right moments. Of course, when there's something wrong, you often want to stay silent, let the team hit a wall, and learn from their setbacks. Other times, stepping in to provide guidance is the right thing. + +### Is an Agile coach still necessary? + +In a word: Absolutely! + +Agile is a team effort. Everyone must collaborate to find processes that work. Solutions are often sparked by the collision of ideas between the Agile coach and the partner. Then the partner can accurately get how an Agile theory is applied in the daily work. The partner understands the essence of Agile theories through the solutions. + +As an Agile coach, you must have a solid theoretical foundation and the ability to apply that theory to specific scenarios. On the surface, you take charge of the theory while your Agile partner is responsible for the practice. However, an Agile coach must not be an armchair strategist, and teams aren't supposed to assume that the Agile coach is a theorist. In fact, an Agile coach must consciously let go of the practice part so the Agile partner can take over. + +The significance of accompanying a team is not supposed to be pushing the team to move passively toward the Agile coach's vision. The amount of guidance required from you will fluctuate over time, but it shouldn't and can't last forever. + +### Find an Agile partner + +How do you find your Agile partner? First of all, observe the team you are coaching and notice anyone who is in charge of continuous improvement, whether it's their defined job role or not. That person is your Agile partner. + +If there's nobody like that yet, you must cultivate one. Be sure to choose someone with a good sense of project management. I have observed that team leaders or project managers who perform well in the traditional development model may not be good candidates in the Agile environment. In an Agile management model, you must have an open mind, a sense of continuous pursuit of excellence, a flexible approach, extensive knowledge, and strong self-motivation. + +### Be Agile together + +Don't be shy about bringing on a partner to help you with your work and communication. Instead, find willing partners, and work together to make your organization an Agile one. + +*[This article is translated from Xu Dongwei's Blog and is republished with permission.][4]* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/7/agile-coach-internal-cooperation + +作者:[Kelsea Zhang][a] +选题:[lkxed][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/kelsea-zhang +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/leader-team-laptops-conference-meeting.png +[2]: https://creativecommons.org/licenses/by/3.0/us/ +[3]: https://enterprisersproject.com/article/2022/2/agile-adoption-6-steps-IT-leaders?intcmp=7013a000002qLH8AAM +[4]: https://mp.weixin.qq.com/s/OQUAY6JkpTEgnev_EgZdZA diff --git a/sources/tech/20210101 Djinn- A Code Generator and Templating Language Inspired by Jinja2.md b/sources/tech/20210101 Djinn- A Code Generator and Templating Language Inspired by Jinja2.md deleted file mode 100644 index d903ef5abf..0000000000 --- a/sources/tech/20210101 Djinn- A Code Generator and Templating Language Inspired by Jinja2.md +++ /dev/null @@ -1,261 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Djinn: A Code Generator and Templating Language Inspired by Jinja2) -[#]: via: (https://theartofmachinery.com/2021/01/01/djinn.html) -[#]: author: (Simon Arneaud https://theartofmachinery.com) - -Djinn: A Code Generator and Templating Language Inspired by Jinja2 -====== - -Code generators can be useful tools. I sometimes use the command line version of [Jinja2][1] to generate highly redundant config files and other text files, but it’s feature-limited for transforming data. Obviously the author of Jinja2 thinks differently, but I wanted something like list comprehensions or D’s composable range algorithms. - -I decided to make a tool that’s like Jinja2, but lets me generate complex files by transforming data with range algorithms. The idea was dead simple: a templating language that gets rewritten directly to D code. That way it supports everything D does, simply because it _is_ D. I wanted a standalone code generator, but thanks to [D’s `mixin` feature][2], the same templating language works as an embedded templating language (for HTML in a web app, for example). (For more on that trick, see [this post about translating Brainfuck to D to machine code all at compile time using `mixin`s][3].) - -As usual, [it’s on GitLab][4]. [The examples in this post can be found there, too.][5] - -### Hello world example - -Here’s an example to demonstrate the idea: - -``` -Hello [= retro("dlrow") ]! -[: enum one = 1; :] -1 + 1 = [= one + one ] -``` - -`[= some_expression ]` is like `{{ some_expression }}` in Jinja2, and it renders a value to the output. `[: some_statement; :]` is like `{% some_statement %}` and causes full code statements to be executed. I changed the syntax because D also uses curly braces a lot, and mixing the two made templates hard to read. (There are also special non-D directives, like `include`, that get wrapped in `[<` and `>]`.) - -If you save the above to a file called `hello.txt.dj` and run the `djinn` command line tool against it, you’ll get a file called `hello.txt` containing what you might guess: - -``` -Hello world! -1 + 1 = 2 -``` - -If you’ve used Jinja2, you might be wondering what happened to the second line. Djinn has a special rule that simplifies formatting and whitespace handling: if a source line contains `[:` statements or `[<` directives but doesn’t contain any non-whitespace output, the whole line is ignored for output purposes. Blank lines are still rendered. - -### Generating data - -Okay, now for something a bit more practical: generating CSV data. - -``` -x,f(x) -[: import std.mathspecial; -foreach (x; iota(-1.0, 1.0, 0.1)) :] -[= "%0.1f,%g", x, normalDistribution(x) ] -``` - -A `[=` and `]` pair can contain multiple expressions separated by commas. If the first expression is a double-quoted string, it’s interpreted as a [format string][6]. Here’s the output: - -``` -x,f(x) --1.0,0.158655 --0.9,0.18406 --0.8,0.211855 --0.7,0.241964 --0.6,0.274253 --0.5,0.308538 --0.4,0.344578 --0.3,0.382089 --0.2,0.42074 --0.1,0.460172 -0.0,0.5 -0.1,0.539828 -0.2,0.57926 -0.3,0.617911 -0.4,0.655422 -0.5,0.691462 -0.6,0.725747 -0.7,0.758036 -0.8,0.788145 -0.9,0.81594 -``` - -### Making an image - -This example is just for the heck of it. [The classic netpbm image library defined a bunch of image formats][7], some of which are text-based. For example, here’s an image of a 3x3 cross: - -``` -P2 # identifier for Portable GrayMap -3 3 # width and height -7 # value for pure white (0 is black) -7 0 7 -0 0 0 -7 0 7 -``` - -You can save the above text to a file named something like `cross.pgm` and many image tools will understand it. Here’s some Djinn code that generates a [Mandelbrot set][8] fractal in the same format: - -``` -[: -import std.complex; -enum W = 640; -enum H = 480; -enum kMaxIter = 20; -ubyte mb(uint x, uint y) -{ - const c = complex(3.0 * (x - W / 1.5) / W, 2.0 * (y - H / 2.0) / H); - auto z = complex(0.0); - ubyte ret = kMaxIter; - while (abs(z) <= 2 && --ret) z = z * z + c; - return ret; -} -:] -P2 -[= W ] [= H ] -[= kMaxIter ] -[: foreach (y; 0..H) :] -[= "%(%s %)", iota(W).map!(x => mb(x, y)) ] -``` - -The resulting file is about 800kB, but it compresses nicely as a PNG: - -``` -$ # Converting with GraphicsMagick -$ gm convert mandelbrot.pgm mandelbrot.png -``` - -And here it is: - -![][9] - -### Solving a puzzle - -Here’s a puzzle: - -![][10] - -The 5x5 grid needs to be filled in with numbers from 1 to 5, using each number once in each row, and once in each column. (I.e., to make a 5x5 Latin square.) The numbers in neighbouring cells must also satisfy the inequalities indicated by any `>` greater-than signs. - -[I used linear programming (LP) some months ago.][11] LP problems are systems of continuous variables with linear constraints. This time I’ll use mixed integer linear programming (MILP), which generalises LP by also allowing integer-constrained variables. It turns out that’s enough to be NP complete, and MILP happens to be reasonably good for modelling this puzzle. - -In that previous post, I used the Julia library JuMP to help spec the problem. This time I’ll use the [CPLEX text-based format][12], which is supported by several LP and MILP solvers (and can be easily converted to other formats by off-the-shelf tools if needed). Here’s the LP from the previous post in CPLEX format: - -``` -Minimize - obj: v -Subject To - ptotal: pr + pp + ps = 1 - rock: 4 ps - 5 pp - v <= 0 - paper: 5 pr - 8 ps - v <= 0 - scissors: 8 pp - 4 pr - v <= 0 -Bounds - 0 <= pr <= 1 - 0 <= pp <= 1 - 0 <= ps <= 1 -End -``` - -CPLEX format is nice to read, but non-trivial problems take a lot of variables and constraints to model, making it painful and error-prone to write out manually. There are domain-specific languages like [ZIMPL][13] for speccing MILPs and LPs in a high-level way. They’re pretty cool for many problems, but ultimately they’re not as expressive as a general-purpose language with a good library like JuMP — or as a code generator with D. - -I’ll model the puzzle using two sets of variables: (v_{r,c}) and (i_{r,c,v}). (v_{r,c}) will hold the value (1-5) of the cell at row (r) and column (c). (i_{r,c,v}) will be an indicator binary that’s 1 if the cell at row (r) and column (c) has value (v), and 0 otherwise. These two sets of variables are redundant representations of the grid, but the first representation makes it easier to model the inequality constraints, while the second representation makes it easier to model the uniqueness constraints. I just need to add some extra constraints to force the two representations to be consistent. But first, let’s start with the basic constraint that each cell must have exactly one value. Mathematically, that means all the indicators for a given row and column must be 0, except for one that is 1. That can be enforced by this equation: - -[i_{r,c,1} + i_{r,c,2} + i_{r,c,3} + i_{r,c,4} + i_{r,c,5} = 1] - -The CPLEX constraints for all rows and columns can be generated with this Djinn code: - -``` -\ Cell has one value -[: -foreach (r; iota(N)) -foreach (c; iota(N)) -:] - [= "%-(%s + %)", vs.map!(v => ivar(r, c, v)) ] = 1 -[::] -``` - -`ivar()` is a helper function that gives us the string identifier for an (i) variable, and `vs` stores the numbers 1-5 for convenience. The constraints for uniqueness within rows and columns are exactly the same, but iterating over the other two dimensions of (i). - -To make the (i) vars consistent with the (v) vars, we need constraints like this (remember, only one of the (i) vars is non-zero): - -[i_{r,c,1} + 2i_{r,c,2} + 3i_{r,c,3} + 4i_{r,c,4} + 5i_{r,c,5} = v_{r,c}] - -CPLEX requires all variables to be on the left, so the Djinn code looks like this: - -``` -\ Link i vars with v vars -[: -foreach (r; iota(N)) -foreach (c; iota(N)) -:] - [= "%-(%s + %)", vs.map!(v => text(v, ' ', ivar(r, c, v))) ] - [= vvar(r,c) ] = 0 -[::] -``` - -The constraints for the neighouring cell inequalities and for the bottom left corner being 4 are all trivial to write. All that’s left is to declare the indicator variables to be binary, and set the bounds for the (v) vars. All up, there are 150 variables and 111 constraints, plus bounds for the variables. [You can see the full code in the repo.][14] - -The [GNU Linear Programming Kit][15] has a command line tool that can solve this CPLEX MILP. Unfortunately, its output is a big dump of everything, so I used awk to pull out what’s needed: - -``` -$ time glpsol --lp inequality.lp -o /dev/stdout | awk '/v[0-9][0-9]/ { print $2, $4 }' | sort -v00 1 -v01 3 -v02 2 -v03 5 -v04 4 -v10 2 -v11 5 -v12 4 -v13 1 -v14 3 -v20 3 -v21 1 -v22 5 -v23 4 -v24 2 -v30 5 -v31 4 -v32 3 -v33 2 -v34 1 -v40 4 -v41 2 -v42 1 -v43 3 -v44 5 - -real 0m0.114s -user 0m0.106s -sys 0m0.005s -``` - -Here’s the solution written out in the original grid: - -![][16] - -These examples are just for playing around, but I’m sure you get the idea. The `README.md` for the Djinn repo is itself generated using a Djinn template, by the way. - -As I said, Djinn can also be used as a compile-time templating language embedded inside D code. I primarily wanted a code generator, but that’s a bonus thanks to D’s metaprogramming features. - --------------------------------------------------------------------------------- - -via: https://theartofmachinery.com/2021/01/01/djinn.html - -作者:[Simon Arneaud][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://theartofmachinery.com -[b]: https://github.com/lujun9972 -[1]: https://jinja2docs.readthedocs.io/en/stable/ -[2]: https://dlang.org/articles/mixin.html -[3]: https://theartofmachinery.com/2017/12/31/compile_time_brainfuck.html -[4]: https://gitlab.com/sarneaud/djinn -[5]: https://gitlab.com/sarneaud/djinn/-/tree/v0.1.0/examples -[6]: https://dlang.org/phobos/std_format.html#format-string -[7]: http://netpbm.sourceforge.net/doc/#formats -[8]: https://en.wikipedia.org/wiki/Mandelbrot_set -[9]: https://theartofmachinery.com/images/djinn/mandelbrot.png -[10]: https://theartofmachinery.com/images/djinn/inequality.svg -[11]: https://theartofmachinery.com/2020/05/21/glico_weighted_rock_paper_scissors.html -[12]: http://lpsolve.sourceforge.net/5.0/CPLEX-format.htm -[13]: https://zimpl.zib.de/ -[14]: https://gitlab.com/sarneaud/djinn/-/tree/v0.1.0/examples/inequality.lp.dj -[15]: https://www.gnu.org/software/glpk/ -[16]: https://theartofmachinery.com/images/djinn/inequality_solution.svg diff --git a/sources/tech/20210101 Solve a charity-s problem with the Julia programming language.md b/sources/tech/20210101 Solve a charity-s problem with the Julia programming language.md index 6a29af626b..0362f44efd 100644 --- a/sources/tech/20210101 Solve a charity-s problem with the Julia programming language.md +++ b/sources/tech/20210101 Solve a charity-s problem with the Julia programming language.md @@ -1,18 +1,20 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Solve a charity's problem with the Julia programming language) -[#]: via: (https://opensource.com/article/21/1/solve-problem-julia) -[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen) +[#]: subject: "Solve a charity's problem with the Julia programming language" +[#]: via: "https://opensource.com/article/21/1/solve-problem-julia" +[#]: author: "Chris Hermansen https://opensource.com/users/clhermansen" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " Solve a charity's problem with the Julia programming language ====== -See how Julia differs from Java, Python, and Groovy to solve a food -bank's real-world problem. +See how Julia differs from Java, Python, and Groovy to solve a food bank's real-world problem. + ![Puzzle pieces coming together to form a computer screen][1] +Image by: Opensource.com + I have been writing a series of articles about solving a nice, small, and somewhat unusual problem in different programming languages ([Groovy][2], [Python][3], and [Java][4] so far). Briefly, the problem is how to unpack bulk supplies into their units (for example, dividing a 10 pack of one-pound bags of your favorite coffee) and repackage them into hampers of similar value to distribute to struggling neighbors in the community. @@ -29,10 +31,9 @@ But enough speculation, let's code something! ### The Julia solution -My first decision is how to implement the data model. Julia supports _composite types_, seemingly similar to `struct` in C, and Julia even uses the keyword `struct`. Of note is that a `struct` is immutable (unless declared a `mutable struct`), which is fine for this problem since the data doesn't need to be mutated. - -By following the approach I took in the Java solution, the `Unit struct` can be defined as:  +My first decision is how to implement the data model. Julia supports *composite types*, seemingly similar to `struct` in C, and Julia even uses the keyword `struct`. Of note is that a `struct` is immutable (unless declared a `mutable struct` ), which is fine for this problem since the data doesn't need to be mutated. +By following the approach I took in the Java solution, the `Unit struct` can be defined as: ``` struct Unit @@ -44,13 +45,12 @@ end Similarly, `Pack` is defined as the bulk package of `Unit` instances: - ``` struct Pack       unit::Unit       count::Int       Pack(item, brand, unitCount,p ackPrice) = -            new(Unit(item, brand, [div][6](packPrice,unitCount)), unitCount) +            new(Unit(item, brand, div(packPrice,unitCount)), unitCount) end ``` @@ -58,7 +58,6 @@ There is an interesting thing here: a Julia "inner constructor." In the Java sol Because Julia isn't object-oriented, I can't add methods to `Pack` to give unit price vs. pack price or to unpack it into a list of `Unit` instances. I can declare "getter" functions that accomplish the same tasks. (I probably don't need these, but I'll do it anyway to see how Julia methods work): - ``` item(pack::Pack) = pack.unit.item brand(pack::Pack) = pack.unit.brand @@ -68,17 +67,16 @@ packPrice(pack::Pack) = pack.unit.price * pack.count unpack(pack::Pack) = Iterators.collect(Iterators.repeated(pack.unit,pack.count)) ``` -The `unpack()` method is quite similar to the method of the same name I declared in the Java class `Pack`. The function `Iterators.repeated(thing,N)` creates an iterator that will deliver `N` copies of `thing`. The `Iterators.collect` (`iterator`) function processes the `iterator` to yield an array made up of the elements it delivers. - -Finally, the `Bought struct`: +The `unpack()` method is quite similar to the method of the same name I declared in the Java class `Pack`. The function `Iterators.repeated(thing,N)` creates an iterator that will deliver `N` copies of `thing`. The `Iterators.collect` (`iterator` ) function processes the `iterator` to yield an array made up of the elements it delivers. +Finally, the `Bought struct` : ``` struct Bought       pack::Pack       count::Int end -unpack(bought::Bought) =         +unpack(bought::Bought) =              Iterators.collect(Iterators.flatten(Iterators.repeated(unpack(bought.pack),          bought.count))) ``` @@ -87,7 +85,6 @@ Once again, I'm creating an array of an array of unpacked `Pack` instances (i.e. Now I can construct the list of what I bought: - ``` packs = [         Bought(Pack("Rice","Best Family",10,5650),1), @@ -111,12 +108,11 @@ I'm starting to see a pattern here… this looks surprisingly like the Java solu With the list packs of what I bought, I can now unpack into the units before working on redistributing them: - ``` -`units = Iterators.collect(Iterators.flatten(unpack.(packs)))` +units = Iterators.collect(Iterators.flatten(unpack.(packs))) ``` -What's going on here? Well, a construct like `unpack.(packs)`—that is, the dot between the function name and the argument list—applies the function `unpack()` to each element in the list `packs`. This will generate a list of lists corresponding to the unpacked groups of `Packs` I bought. To turn that into a flat list of units, I apply `Iterators.flatten()`. Because `Iterators.flatten()` is lazy, to make the flatten thing happen, I wrap it in `Iterators.collect()`. This kind of composition of functions adheres to the spirit of functional programming, even though you don't see the functions chained together, as programmers who write functionally in JavaScript, Java, or what-have-you are familiar with. +What's going on here? Well, a construct like `unpack.(packs)` —that is, the dot between the function name and the argument list—applies the function `unpack()` to each element in the list `packs`. This will generate a list of lists corresponding to the unpacked groups of `Packs` I bought. To turn that into a flat list of units, I apply `Iterators.flatten()`. Because `Iterators.flatten()` is lazy, to make the flatten thing happen, I wrap it in `Iterators.collect()`. This kind of composition of functions adheres to the spirit of functional programming, even though you don't see the functions chained together, as programmers who write functionally in JavaScript, Java, or what-have-you are familiar with. One observation is that the list of units created here is actually an array whose starting index is 1, not 0. @@ -124,63 +120,59 @@ With units being the list of units purchased and unpacked, I can now take on rep Here's the code, which is not exceptionally different than the versions in Groovy, Python, and Java: - ```  1      valueIdeal = 5000  2      valueMax = round(valueIdeal * 1.1)  3      hamperNumber = 0         - 4      while length(units) > 0 + 4      while length(units) > 0  5          global hamperNumber += 1  6          hamper = Unit[]  7          value = 0  8          canAdd = true  9          while canAdd -10              u = [rand][7](0:(length(units)-1)) +10              u = rand(0:(length(units)-1)) 11              canAdd = false 12              for o = 0:(length(units)-1) 13                  uo = (u + o) % length(units) + 1 14                  unit = units[uo] -15                  if length(units) < 3 || findfirst(u -> u == unit,hamper) === nothing && (value + unit.price) < valueMax +15                  if length(units) < 3 || findfirst(u -> u == unit,hamper) === nothing && (value + unit.price) < valueMax 16                      push!(hamper,unit) 17                      value += unit.price 18                      deleteat!(units,uo) -19                      canAdd = length(units) > 0 +19                      canAdd = length(units) > 0 20                      break 21                  end 22              end 23          end -24          Printf.@[printf][8]("\nHamper %d value %d:\n",hamperNumber,value) +24          Printf.@printf("\nHamper %d value %d:\n",hamperNumber,value) 25          for unit in hamper -26              Printf.@[printf][8]("%-25s%-25s%7d\n",unit.item,unit.brand,unit.price) +26              Printf.@printf("%-25s%-25s%7d\n",unit.item,unit.brand,unit.price) 27          end -28          Printf.@[printf][8]("Remaining units %d\n",length(units)) +28          Printf.@printf("Remaining units %d\n",length(units)) 29      end ``` Some clarification, by line numbers: - * Lines 1–3: Set up the ideal and maximum values to be loaded into any given hamper and initialize Groovy's random number generator and the hamper number - * Lines 4–29: This `while` loop redistributes units into hampers, as long as there are more available - * Lines 5–7: Increment the (global) hamper number, get a new empty hamper (an array of `Unit` instances), and set its value to 0 - * Line 8 and 9–23: As long as I can add units to the hamper… - * Line 10: Gets a random number between zero and the number of remaining units minus 1 - * Line 11: Assumes I can't find more units to add - * Lines 12–22: This `for` loop, starting at the randomly chosen index, will try to find a unit that can be added to the hamper - * Lines 13–14: Figure out which unit to look at (remember arrays start at index 1) and get it - * Lines 15–21: I can add this unit to the hamper if there are only a few left or if the value of the hamper isn't too high once the unit is added and if that unit isn't already in the hamper - * Lines 16–18: Add the unit to the hamper, increment the hamper value by the unit price, and remove the unit from the available units list - * Lines 19–20: As long as there are units left, I can add more, so break out of this loop to keep looking - * Line 22: On exit from this `for` loop, if I have inspected every remaining unit and could not find one to add to the hamper, the hamper is complete; otherwise, I found one and can continue looking for more - * Line 23: On exit from this `while` loop, the hamper is as full as I can make it, so… - * Lines 24–28: Print out the contents of the hamper and the remaining units info - * Line 29: When I exit this loop, there are no more units left - - +* Lines 1–3: Set up the ideal and maximum values to be loaded into any given hamper and initialize Groovy's random number generator and the hamper number +* Lines 4–29: This `while` loop redistributes units into hampers, as long as there are more available +* Lines 5–7: Increment the (global) hamper number, get a new empty hamper (an array of `Unit` instances), and set its value to 0 +* Line 8 and 9–23: As long as I can add units to the hamper… +* Line 10: Gets a random number between zero and the number of remaining units minus 1 +* Line 11: Assumes I can't find more units to add +* Lines 12–22: This `for` loop, starting at the randomly chosen index, will try to find a unit that can be added to the hamper +* Lines 13–14: Figure out which unit to look at (remember arrays start at index 1) and get it +* Lines 15–21: I can add this unit to the hamper if there are only a few left or if the value of the hamper isn't too high once the unit is added and if that unit isn't already in the hamper +* Lines 16–18: Add the unit to the hamper, increment the hamper value by the unit price, and remove the unit from the available units list +* Lines 19–20: As long as there are units left, I can add more, so break out of this loop to keep looking +* Line 22: On exit from this `for` loop, if I have inspected every remaining unit and could not find one to add to the hamper, the hamper is complete; otherwise, I found one and can continue looking for more +* Line 23: On exit from this `while` loop, the hamper is as full as I can make it, so… +* Lines 24–28: Print out the contents of the hamper and the remaining units info +* Line 29: When I exit this loop, there are no more units left The output of running this code looks quite similar to the output from the other programs: - ``` Hamper 1 value 5020: Tea                      Superior                     544 @@ -238,9 +230,8 @@ Once again, the random-number-driven list manipulation seems to make the "workin Given that the main effort revolves around `for` and `while` loops, in Julia, I don't see any construct similar to: - ``` -`for (boolean canAdd = true; canAdd; ) { … }` +for (boolean canAdd = true; canAdd; ) { … } ``` This means I have to declare the `canAdd` variable outside the `while` loop. Which is too bad—but not a terrible thing. @@ -249,27 +240,24 @@ I do miss not being able to attach behavior directly to my data, but that's just Good things: low ceremony, check; decent list-handling, check; compact and readable code, check. All in all, a pleasant experience, supporting the idea that Julia can be a decent choice to solve "ordinary problems" and as a scripting language. -Next time, I'll do this exercise in [Go][9]. +Next time, I'll do this exercise in [Go][6]. -------------------------------------------------------------------------------- via: https://opensource.com/article/21/1/solve-problem-julia 作者:[Chris Hermansen][a] -选题:[lujun9972][b] +选题:[lkxed][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/clhermansen -[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) +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/puzzle_computer_solve_fix_tool.png [2]: https://opensource.com/article/20/9/groovy [3]: https://opensource.com/article/20/9/solve-problem-python [4]: https://opensource.com/article/20/9/problem-solving-java [5]: https://julialang.org/ -[6]: http://www.opengroup.org/onlinepubs/009695399/functions/div.html -[7]: http://www.opengroup.org/onlinepubs/009695399/functions/rand.html -[8]: http://www.opengroup.org/onlinepubs/009695399/functions/printf.html -[9]: https://golang.org/ +[6]: https://golang.org/ diff --git a/sources/tech/20210104 10 ways Ansible is for everyone.md b/sources/tech/20210104 10 ways Ansible is for everyone.md deleted file mode 100644 index 6b93c69ff3..0000000000 --- a/sources/tech/20210104 10 ways Ansible is for everyone.md +++ /dev/null @@ -1,94 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (10 ways Ansible is for everyone) -[#]: via: (https://opensource.com/article/21/1/ansible) -[#]: author: (James Farrell https://opensource.com/users/jamesf) - -10 ways Ansible is for everyone -====== -Expand your knowledge and skills with the top 10 Ansible articles plus -five news summaries from 2020. -![gears and lightbulb to represent innovation][1] - -Here we are again at the end of another year with a great set of articles about Ansible from Opensource.com. I thought it would be nice to review them in a series of progressively advancing topics. I hope to help stimulate the interest of people just getting started with Ansible. There were also a series of summary articles, which I've included for your casual follow-up. - -### Ansible for beginners - -The first five articles on this year's list are a really good place for Ansible neophytes to start. The first three articles were written by Opensource.com editor Seth Kenlon. - - * If you don't know much about Ansible, [_7 things you can do with Ansible right now_][2] is a great place to start. This is a nice primer that gathers links for managing hardware, cloud, containers, and more. - * In [_What's the difference between orchestration and automation?_][3] you will learn some of the terms and baseline technologies that will help kick off your interest in Ansible. - * [_How to install software with Ansible_][4] covers a few rudimentary concepts and some good Ansible habits, followed by simple examples on managing software packages on local and remote hosts. - * In [_3 lessons I've learned writing Ansible playbooks_][5], set yourself right with good habits handed down by Jeff Geerling, a real Ansible veteran. Source control, documentation, testing, simplification, and optimization are the keys to automation success. - * [_My first day using Ansible_][6] outlines Correspondent David Both's thought process for solving a repetitive development task. The article starts with a baseline of what Ansible needs and illustrates some simple plays and tasks. - - - -### Ansible projects to try - -Once you have the basics and some good habits, it's time to turn to more specific topics with concrete examples. - - * [_Manage your Raspberry Pi fleet with Ansible_][7] by Ken Fallon walks through an example of deploying and managing fleets of RPi units. It presents concepts of security and maintenance in constrained environments. - * In _[Integrate your calendar with Ansible to avoid schedule conflicts][8],_ Nicolas Leiva quickly introduces how to use pre-tasks and conditionals to enforce execution blackout windows in your automation schedule. - * Nicolas completes his calendar blackout concept in [_Create an Ansible module for integrating your Google Calendar_][9]. His article dives into writing a custom Ansible module in Go to achieve the desired calendar connection. Nicolas introduces different ways to structure and invoke Go programs and pass the required data to Ansible and receive the desired output. - - - -### Elevate your Ansible skills - -Kubernetes is a hot topic these days, and the following articles offer some great examples to learn new skills. - - * In [_Automate your container orchestration with Ansible modules for Kubernetes_][10], Seth Kenlon introduces the Ansible Kubernetes module, walks through a basic Minikube installation for testing, and presents some basic examples of the "k8s" module for pod control. - * Jeff Geerling explains the concept of Helm Chart applications, Ansible collections, and executing a fun project to set up your own Minecraft server in a k8s cluster in [_Build a Kubernetes Minecraft server with Ansible's Helm modules_][11]. - - - -### Other Ansible news - -This year, Mark Phillips delivered a series of "Ansible around the web" news articles covering a wide variety of Ansible topics. They are packed with links to interesting Ansible developments, ranging from basic tutorials, module writing, plugins, Kubernetes, video demonstrations, and Ansible community news. Check them all out—there are valuable nuggets to follow for all interests and skill levels! - - * [_Containers, networks, security, and more Ansible news_][12] - * [_Tips for CI/CD pipelines and Windows users, and more Ansible news_][13] - * [_Collections signal major shift in Ansible ecosystem, and more Ansible news_][14] - * [_Ansible 101 videos with Jeff Geerling, and more Ansible news_][15] - * [_Beginner guides, Windows, networking, and more Ansible news_][16] - - - -### Have a happy 2021! - -I hope your personal journey with Ansible is already underway and regularly enriched by content from Opensource.com. Tell us in the comments what you might like to learn about Ansible in the coming year, and if you have information to share, please consider [writing an article][17] for Opensource.com. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/1/ansible - -作者:[James Farrell][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/jamesf -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/innovation_lightbulb_gears_devops_ansible.png?itok=TSbmp3_M (gears and lightbulb to represent innovation) -[2]: https://opensource.com/article/20/9/ansible -[3]: https://opensource.com/article/20/11/orchestration-vs-automation -[4]: https://opensource.com/article/20/9/install-packages-ansible -[5]: https://opensource.com/article/20/1/ansible-playbooks-lessons -[6]: https://opensource.com/article/20/10/first-day-ansible -[7]: https://opensource.com/article/20/9/raspberry-pi-ansible -[8]: https://opensource.com/article/20/10/calendar-ansible -[9]: https://opensource.com/article/20/10/ansible-module-go -[10]: https://opensource.com/article/20/9/ansible-modules-kubernetes -[11]: https://opensource.com/article/20/10/kubernetes-minecraft-ansible -[12]: https://opensource.com/article/20/1/ansible-news-edition-six -[13]: https://opensource.com/article/20/2/ansible-news-edition-seven -[14]: https://opensource.com/article/20/3/ansible-news-edition-eight -[15]: https://opensource.com/article/20/4/ansible-news-edition-nine -[16]: https://opensource.com/article/20/5/ansible-news-edition-ten -[17]: https://opensource.com/how-submit-article diff --git a/sources/tech/20210104 Docker Compose- a nice way to set up a dev environment.md b/sources/tech/20210104 Docker Compose- a nice way to set up a dev environment.md deleted file mode 100644 index b2d719b02a..0000000000 --- a/sources/tech/20210104 Docker Compose- a nice way to set up a dev environment.md +++ /dev/null @@ -1,249 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Docker Compose: a nice way to set up a dev environment) -[#]: via: (https://jvns.ca/blog/2021/01/04/docker-compose-is-nice/) -[#]: author: (Julia Evans https://jvns.ca/) - -Docker Compose: a nice way to set up a dev environment -====== - -Hello! Here is another post about [computer tools that I’ve appreciated][1]. This one is about Docker Compose! - -This post is mostly just about how delighted I was that it does what it’s supposed to do and it seems to work and to be pretty straightforward to use. I’m also only talking about using Docker Compose for a dev environment here, not using it in production. - -I’ve been thinking about this kind of personal dev environment setup more recently because I now do all my computing with a personal cloud budget of like $20/month instead of spending my time at work thinking about how to manage thousands of AWS servers. - -I’m very happy about this because previous to trying Docker Compose I spent two days getting frustrated with trying to set up a dev environment with other tools and Docker Compose was a lot easier and simpler. And then I told my sister about my docker-compose experiences and she was like “I KNOW, DOCKER COMPOSE IS GREAT RIGHT?!?!” So I thought I’d write a blog post about it, and here we are. - -### the problem: setting up a dev environment - -Right now I’m working on a Ruby on Rails service (the backend for a sort of computer debugging game). On my production server, I have: - - * a nginx proxy - * a Rails server - * a Go server (which proxies some SSH connections with [gotty][2]) - * a Postgres database - - - -Setting up the Rails server locally was pretty straightforward without resorting to containers (I just had to install Postgres and Ruby, fine, no big deal), but then I wanted send `/proxy/*` to the Go server and everything else to the Rails server, so I needed nginx too. And installing nginx on my laptop felt too messy to me. - -So enter `docker-compose`! - -### docker-compose lets you run a bunch of Docker containers - -Docker Compose basically lets you run a bunch of Docker containers that can communicate with each other. - -You configure all your containers in one file called `docker-compose.yml`. I’ve pasted my entire `docker-compose.yml` file here for my server because I found it to be really short and straightforward. - -``` -version: "3.3" -services: - db: - image: postgres - volumes: - - ./tmp/db:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: password # yes I set the password to 'password' - go_server: - # todo: use a smaller image at some point, we don't need all of ubuntu to run a static go binary - image: ubuntu - command: /app/go_proxy/server - volumes: - - .:/app - rails_server: - build: docker/rails - command: bash -c "rm -f tmp/pids/server.pid && source secrets.sh && bundle exec rails s -p 3000 -b '0.0.0.0'" - volumes: - - .:/app - web: - build: docker/nginx - ports: - - "8777:80" # this exposes port 8777 on my laptop -``` - -There are two kinds of containers here: for some of them I’m just using an existing image (`image: postgres` and `image: ubuntu`) without modifying it at all. And for some I needed to build a custom container image – `build: docker/rails` says to use `docker/rails/Dockerfile` to build a custom container. - -I needed to give my Rails server access to some API keys and things, so `source secrets.sh` puts a bunch of secrets in environment variables. Maybe there’s a better way to manage secrets but it’s just me so this seemed fine. - -### how to start everything: `docker-compose build` then `docker-compose up` - -I’ve been starting my containers just by running `docker-compose build` to build the containers, then `docker-compose up` to run everything. - -You can set `depends_on` in the yaml file to get a little more control over when things start in, but for my set of services the start order doesn’t matter, so I haven’t. - -### the networking is easy to use - -It’s important here that the containers be able to connect to each other. Docker Compose makes that super simple! If I have a Rails server running in my `rails_server` container on port 3000, then I can access that with `http://rails_server:3000`. So simple! - -Here’s a snippet from my nginx configuration file with how I’m using that in practice (I removed a bunch of `proxy_set_header` lines to make it more clear) - -``` -location ~ /proxy.* { - proxy_pass http://go_server:8080; -} -location @app { - proxy_pass http://rails_server:3000; -} -``` - -Or here’s a snippet from my Rails project’s database configuration, where I use the name of the database container (`db`): - -``` -development: - <<: *default - database: myproject_development - host: db # <-------- this "magically" resolves to the database container's IP address - username: postgres - password: password -``` - -I got a bit curious about how `rails_server` was actually getting resolved to an IP address. It seems like Docker is running a DNS server somewhere on my computer to resolve these names. Here are some DNS queries where we can see that each container has its own IP address: - -``` -$ dig +short @127.0.0.11 rails_server -172.18.0.2 -$ dig +short @127.0.0.11 db -172.18.0.3 -$ dig +short @127.0.0.11 web -172.18.0.4 -$ dig +short @127.0.0.11 go_server -172.18.0.5 -``` - -### who’s running this DNS server? - -I dug into how this DNS server is set up a very tiny bit. - -I ran all these commands outside the container, because I didn’t have a lot of networking tools installed in the container. - -**step 1**: find the PID of my Rails server with `ps aux | grep puma` - -It’s 1837916. Cool. - -**step 2**: find a UDP server running in the same network namespace as PID `1837916` - -I did this by using `nsenter` to run `netstat` in the same network namespace as the `puma` process. (technically I guess you could run `netstat -tupn` to just show UDP servers, but my fingers only know how to type `netstat -tulpn` at this point) - -``` -$ sudo nsenter -n -t 1837916 netstat -tulpn -Active Internet connections (only servers) -Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name -tcp 0 0 127.0.0.11:32847 0.0.0.0:* LISTEN 1333/dockerd -tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 1837916/puma 4.3.7 -udp 0 0 127.0.0.11:59426 0.0.0.0:* 1333/dockerd -``` - -So there’s a UDP server running on port `59426`, run by `dockerd`! Maybe that’s the DNS server? - -**step 3**: check that it’s a DNS server - -We can use `dig` to make a DNS query to it: - -``` -$ sudo nsenter -n -t 1837916 dig +short @127.0.0.11 59426 rails_server -172.18.0.2 -``` - -But – when we ran `dig` earlier, we weren’t making a DNS query to port 59426, we were querying port 53! What’s going on? - -**step 4**: iptables - -My first guess for “this server seems to be running on port X but I’m accessing it on port Y, what’s going on?” was “iptables”. - -So I ran iptables-save in the container’s network namespace, and there we go: - -``` -$ sudo nsenter -n -t 1837916 iptables-save -.... redacted a bunch of output .... --A DOCKER_POSTROUTING -s 127.0.0.11/32 -p udp -m udp --sport 59426 -j SNAT --to-source :53 -COMMIT -``` - -There’s an iptables rule that sends traffic on port 53 to 59426. Fun! - -### it stores the database files in a temp directory - -One nice thing about this is: instead of managing a Postgres installation on my laptop, I can just mount the Postgres container’s data directory at `./tmp/db`. - -I like this because I really do not want to administer a Postgres installation on my laptop (I don’t really know how to configure Postgres), and conceptually I like having my dev database literally be in the same directory as the rest of my code. - -### I can access the Rails console with `docker-compose exec rails_server rails console` - -Managing Ruby versions is always a little tricky and even when I have it working, I always kind of worry I’m going to screw up my Ruby installation and have to spend like ten years fixing it. - -With this setup, if I need access to the Rails console (a REPL with all my Rails code loaded), I can just run: - -``` -$ docker-compose exec rails_server rails console -Running via Spring preloader in process 597 -Loading development environment (Rails 6.0.3.4) -irb(main):001:0> -``` - -Nice! - -### small problem: no history in my Rails console - -I ran into a problem though: I didn’t have any history in my Rails console anymore, because I was restarting the container all the time. - -I figured out a pretty simple solution to this though: I added a `/root/.irbrc` to my container that changed the IRB history file’s location to be something that would persist between container restarts. It’s just one line: - -``` -IRB.conf[:HISTORY_FILE] = "/app/tmp/irb_history" -``` - -### I still don’t know how well it works in production - -Right now my production setup for this project is still “I made a digitalocean droplet and edited a lot of files by hand”. - -I think I’ll try to use docker-compose to run this thing in production. My guess is that it should work fine because this service is probably going to have at most like 2 users at a time and I can easily afford to have 60 seconds of downtime during a deploy if I want, but usually something goes wrong that I haven’t thought of. - -A few notes from folks on Twitter about docker-compose in production: - - * `docker-compose up` will only restart the containers that need restarting, which makes restarts faster - * there’s a small bash script [wait-for-it][3] that you can use to make a container wait for another service to be available - * You can have 2 docker-compose.yaml files: `docker-compose.yaml` for DEV, and `docker-compose-prod.yaml` for prod. I think I’ll use this to expose different nginx ports: 8999 in dev and 80 in prod. - * folks seemed to agree that docker-compose is fine in production if you have a small website running on 1 computer - * one person suggested that Docker Swarm might be better for a slightly more complicated production setup, but I haven’t tried that (or of course Kubernetes, but the whole point of Docker Compose is that it’s super simple and Kubernetes is certainly not simple :) ) - - - -Docker also seems to have a feature to [automatically deploy your docker-compose setup to ECS][4], which sounds cool in theory but I haven’t tried it. - -### when doesn’t docker-compose work well? - -I’ve heard that docker-compose doesn’t work well: - - * when you have a very large number of microservices (a simple setup is best) - * when you’re trying to include data from a very large database (like putting hundreds of gigabytes of data on everyone’s laptop) - * on Mac computers, I’ve heard that Docker can be a lot slower than on Linux (presumably because of the extra VM). I don’t have a Mac so I haven’t run into this. - - - -### that’s all! - -I spent an entire day before this trying to configure a dev environment by using Puppet to provision a Vagrant virtual machine only to realize that VMs are kind of slow to start and that I don’t really like writing Puppet configuration (I know, huge surprise :)). - -So it was nice to try Docker Compose and find that it was straightforward to get to work! - --------------------------------------------------------------------------------- - -via: https://jvns.ca/blog/2021/01/04/docker-compose-is-nice/ - -作者:[Julia Evans][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://jvns.ca/ -[b]: https://github.com/lujun9972 -[1]: https://jvns.ca/#cool-computer-tools---features---ideas -[2]: https://github.com/yudai/gotty/ -[3]: https://github.com/vishnubob/wait-for-it -[4]: https://docs.docker.com/cloud/ecs-integration/ diff --git a/sources/tech/20210105 How to customize your voice assistant with the voice of your choice.md b/sources/tech/20210105 How to customize your voice assistant with the voice of your choice.md index 51f86d0519..85be02276b 100644 --- a/sources/tech/20210105 How to customize your voice assistant with the voice of your choice.md +++ b/sources/tech/20210105 How to customize your voice assistant with the voice of your choice.md @@ -1,21 +1,23 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to customize your voice assistant with the voice of your choice) -[#]: via: (https://opensource.com/article/21/1/customize-voice-assistant) -[#]: author: (Rich Lucente https://opensource.com/users/rlucente) +[#]: subject: "How to customize your voice assistant with the voice of your choice" +[#]: via: "https://opensource.com/article/21/1/customize-voice-assistant" +[#]: author: "Rich Lucente https://opensource.com/users/rlucente" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " How to customize your voice assistant with the voice of your choice ====== -The Nana and Poppy project enables a voice assistant to greet users with -their great-grandchildren's voices instead of a generic AI. +The Nana and Poppy project enables a voice assistant to greet users with their great-grandchildren's voices instead of a generic AI. + ![radio communication signals][1] +Image by: [Internet Archive Book Images][2]. Modified by Opensource.com. [CC BY-SA 4.0][3] + It can be hard to find meaningful gifts for relatives that already have almost everything. My wife and I have given our parents "experiences" to try something novel, such as going to a themed restaurant or seeing a concert, but as our parents get older, it becomes more difficult. This year was no exception—until I thought about a way open source could give them something really special. -What if when they request help from an artificial intelligence (AI) voice assistant such as [Mycroft][2], my in-laws could get a special greeting? I looked at the existing voice assistant APIs to see if something like this was already available. There was something close, but not exactly what I was looking for. My idea was to record their great-grandchildren speaking a short greeting that would play whenever they push the button and before the conversation with the voice assistant begins. The greeting would be something like: +What if when they request help from an artificial intelligence (AI) voice assistant such as [Mycroft][4], my in-laws could get a special greeting? I looked at the existing voice assistant APIs to see if something like this was already available. There was something close, but not exactly what I was looking for. My idea was to record their great-grandchildren speaking a short greeting that would play whenever they push the button and before the conversation with the voice assistant begins. The greeting would be something like: > "Good morning, Nana and Poppy. Today is December 25th. The time is 3:10 pm. The current temperature for Waynesboro is 47 degrees. The current temperature for Ocean City is 50 degrees." @@ -25,168 +27,166 @@ When they press the button, my in-laws would hear their great-grandchildren repo The first problem was figuring out what phrases the voice assistant would need to say. Thinking about all the dates, times, and temperatures that I would need to cover, I arrived at a list of 79 phrases. I sent these instructions to my nieces: -> _Please record the kids saying each line below. Sorry there are so many. It's okay to do this in one setting with prompting them if it makes it easier. I can edit the audio files and deal with most formats, so none of that should be a problem. Just record using your phone in whatever way is easiest._ -> -> _Make sure that the kids say each line clearly and loudly. There should be a slight pause between each line to make editing easier (prompting helps like "Repeat after me …"). That will make it easier for me to chop these up into individual sound files._ -> -> _Whenever the button on the device is pushed, it will respond with a random grandchild saying the correct date/time/temperature, like:_ -> -> _"Good afternoon, Nana and Poppy. Today is January third. The time is one oh four pm. The current temperature for Waynesboro is thirty degrees. The current temperature for Ocean City is thirty four degrees."_ -> -> _PLEASE RECORD EACH CHILD SAYING THE FOLLOWING PHRASES WITH A SHORT PAUSE BETWEEN EACH ONE:_ +> Please record the kids saying each line below. Sorry there are so many. It's okay to do this in one setting with prompting them if it makes it easier. I can edit the audio files and deal with most formats, so none of that should be a problem. Just record using your phone in whatever way is easiest. + +> Make sure that the kids say each line clearly and loudly. There should be a slight pause between each line to make editing easier (prompting helps like "Repeat after me …"). That will make it easier for me to chop these up into individual sound files.* + +> Whenever the button on the device is pushed, it will respond with a random grandchild saying the correct date/time/temperature, like: "Good afternoon, Nana and Poppy. Today is January third. The time is one oh four pm. The current temperature for Waynesboro is thirty degrees. The current temperature for Ocean City is thirty four degrees." + +> PLEASE RECORD EACH CHILD SAYING THE FOLLOWING PHRASES WITH A SHORT PAUSE BETWEEN EACH ONE: Then I provided the following list of words for the children to record: -_Good -morning -afternoon -evening -night_ +(这个表格有问题,待修复) -_Nana and Poppy_ +| - | - | - | +| :- | :- | :- | +| Good + morning + afternoon + evening + night +Nana and Poppy +The time + Today  + The current temperature for + Waynesboro + Ocean City + is + and + degrees + minus +am + pm +January + February + March + April + May | June + July + August + September + October + November + December + first + second + third + fourth + fifth + sixth + seventh + eighth + ninth + tenth + eleventh + twelfth + thirteenth + fourteenth + fifteenth + sixteenth + seventeenth + eighteenth + nineteenth + twentieth + thirtieth + oh | one + two + three + four + five + six + seven + eight + nine + ten + eleven + twelve + thirteen + fourteen + fifteen + sixteen + seventeen + eighteen + nineteen + twenty + thirty + forty + fifty + sixty + seventy + eighty + ninety + hundred | -_The time -Today  -The current temperature for -Waynesboro -Ocean City -is -and -degrees -minus_ +*Nana and Poppy* -_am -pm_ +*The time + Today  + The current temperature for + Waynesboro + Ocean City + is + and + degrees + minus* -_January -February -March -April -May_ +*am + pm* -| _June -July -August -September -October -November -December -first -second -third -fourth -fifth -sixth -seventh -eighth -ninth -tenth -eleventh -twelfth -thirteenth -fourteenth -fifteenth -sixteenth -seventeenth -eighteenth -nineteenth -twentieth -thirtieth -oh_ | _one -two -three -four -five -six -seven -eight -nine -ten -eleven -twelve -thirteen -fourteen -fifteen -sixteen -seventeen -eighteen -nineteen -twenty -thirty -forty -fifty -sixty -seventy -eighty -ninety -hundred_ ----|---|--- +*January + February + March + April + May* My nieces are doubly blessed with children under 10 years old and near-infinite patience. So, after a couple of months of prodding, I received a three-minute audio file for each child. -Now my problem was how to edit them. I needed to normalize the recordings, reduce noise, and chop them into audio clips for individual words and phrases. I also wanted to take advantage of lossless audio, and I decided to convert the tracks to Waveform Audio File Format ([WAV][3]). Audacity was just the open source tool to do all of that. +Now my problem was how to edit them. I needed to normalize the recordings, reduce noise, and chop them into audio clips for individual words and phrases. I also wanted to take advantage of lossless audio, and I decided to convert the tracks to Waveform Audio File Format ([WAV][5]). Audacity was just the open source tool to do all of that. ### Audacity to the rescue! -[Audacity][4] is a feature-rich open source sound-editing tool. The software's features and capabilities can be overwhelming, so I'll describe the workflow I followed to accomplish my goals. I make no claims to being an Audacity expert, but the steps I followed seemed to work pretty well. (Comments are always welcome on how to improve what I've done.) +[Audacity][6] is a feature-rich open source sound-editing tool. The software's features and capabilities can be overwhelming, so I'll describe the workflow I followed to accomplish my goals. I make no claims to being an Audacity expert, but the steps I followed seemed to work pretty well. (Comments are always welcome on how to improve what I've done.) -Audacity has [downloads][5] for Linux, Windows, and macOS. I grabbed the most recent macOS binary and quickly installed it on my laptop. Launching Audacity opens an empty new project. I imported all of the children's audio files using the **Import** feature. +Audacity has [downloads][7] for Linux, Windows, and macOS. I grabbed the most recent macOS binary and quickly installed it on my laptop. Launching Audacity opens an empty new project. I imported all of the children's audio files using the **Import** feature. -![Import audio files in Audacity][6] - -(Rich Lucente, [CC BY-SA 4.0][7]) +![Import audio files in Audacity][8] #### Normalizing audio files Some of the children spoke louder than others, so the various audio files had different volume levels. I needed to normalize the audio tracks so that the greeting's volume would be the same regardless of which child was speaking. To normalize the volumes, I began by selecting all of the audio tracks after they were imported. -![Selecting all the audio tracks][8] - -(Rich Lucente, [CC BY-SA 4.0][7]) +![Selecting all the audio tracks][9] To normalize the children's peaks and valleys, so one child wasn't louder than the other, I used Audacity's **Normalize** effect. -![Normalize effect][9] - -(Rich Lucente, [CC BY-SA 4.0][7]) +![Normalize effect][10] It's important to understand that the Normalize and Amplify effects do very different things. Normalize adjusts the highest peaks and lowest valleys for multiple tracks, so they are all similar, whereas Amplify exaggerates the existing peaks and valleys. If I had used Amplify instead of Normalize, the louder child would have become even louder. I used the default settings to normalize the two audio tracks. -![Normalize defaults][10] - -(Rich Lucente, [CC BY-SA 4.0][7]) +![Normalize defaults][11] #### Remove background noise -Another thing I noticed is that there was noise between the spoken phrases on the tracks. Audacity has tooling to help reduce background noise and result in much cleaner audio. To reduce noise, select a sample of an audio track with background noise. I used the **View->Zoom** menu option to see the track's noise more easily. +Another thing I noticed is that there was noise between the spoken phrases on the tracks. Audacity has tooling to help reduce background noise and result in much cleaner audio. To reduce noise, select a sample of an audio track with background noise. I used the **View->Zoom** menu option to see the track's noise more easily. -![Background noise sample][11] +![Background noise sample][12] -(Rich Lucente, [CC BY-SA 4.0][7]) +To make sure I selected only the background noise, I listened to the selected audio clip using the **Play** button in the toolbar. Next, I selected **Effect->Noise Reduction**. -To make sure I selected only the background noise, I listened to the selected audio clip using the **Play** button in the toolbar. Next, I selected **Effect->Noise Reduction**. - -![Noise Reduction effect][12] - -(Rich Lucente, [CC BY-SA 4.0][7]) +![Noise Reduction effect][13] Then I created a **Noise Profile** using step 1 in the **Noise Reduction** dialog. -![Get a Noise Profile from audio sample][13] - -(Rich Lucente, [CC BY-SA 4.0][7]) +![Get a Noise Profile from audio sample][14] Audacity characterizes the background noise in the audio sample so that it can be removed. To remove the background noise, I selected the entire audio track by pressing the small **Select** button to the left of the track. -![Select whole audio track button][14] - -(Rich Lucente, [CC BY-SA 4.0][7]) +![Select whole audio track button][15] I applied the **Noise Reduction** effect again, but this time I pressed **OK** in step 2 of the dialog. I accepted the default settings. -![Noise Reduction effect step 2][15] - -(Rich Lucente, [CC BY-SA 4.0][7]) +![Noise Reduction effect step 2][16] I repeated these steps for each child's audio track, so I had normalized audio tracks, and the background noise was characterized and removed. @@ -194,110 +194,106 @@ I repeated these steps for each child's audio track, so I had normalized audio t The remaining task was to zoom and scroll through each track and export the specific clips as separate audio files in WAV format. When working with one child's track, I needed to mute the other tracks using either the small **Mute** button to the left of each audio track or, since there were so many tracks, selecting the **Solo** button for the track I wanted to work with. -![Mute and Solo buttons for multiple tracks][16] - -(Rich Lucente, [CC BY-SA 4.0][7]) +![Mute and Solo buttons for multiple tracks][17] Selecting each word and phrase can be tricky, but the ability to zoom into an audio track was my friend. I tried to set each audio clip's start and end to just before and just after the word or phrase being spoken. Before exporting any audio clips, I played the selected clip using the **Play** icon on the toolbar to make sure I got it all. One interesting thing is how waveforms map to spoken words. The waveforms for "six" and "sixth" are incredibly similar, with the latter having a smaller audio waveform to the right for the "th" sound. I carefully tested each clip before exporting it to make sure I had captured the full word or phrase. -After selecting an audio clip for a word or phrase, I exported the selected audio using the **File->Export** menu. +After selecting an audio clip for a word or phrase, I exported the selected audio using the **File->Export** menu. -![Exporting selected audio][17] - -(Rich Lucente, [CC BY-SA 4.0][7]) +![Exporting selected audio][18] I had to make sure to save each clip using the correct file name from the list of words and phrases. This is because the application I used to customize the voice assistant expects the file name to match an entry in the phrase list. The expected file names for the audio clips (without the .wav extension) are listed below. Note the underscores within the phrases. If you're doing this project, adjust the bold file names to match your loved ones' nicknames and location preferences. You'll also have to make the same changes in the application source code. -_good -morning -afternoon -evening -night -**nana_and_poppy** -the_time -today -the_current_temperature_for -**waynesboro -ocean_city** -is -and -degrees -minus -am -pm -january -february -march -april -may -june -july -august -september -october_ | _november -december -first -second -third -fourth -fifth -sixth -seventh -eighth -ninth -tenth -eleventh -twelfth -thirteenth -fourteenth -fifteenth -sixteenth -seventeenth -eighteenth -nineteenth -twentieth -thirtieth -oh -one -two_ | _three -four -five -six -seven -eight -nine -ten -eleven -twelve -thirteen -fourteen -fifteen -sixteen -seventeen -eighteen -nineteen -twenty -thirty -forty -fifty -sixty -seventy -eighty -ninety -hundred_ ----|---|--- +(这个表格有问题,待修正) +| - | - | - | +| :- | :- | :- | +| good + morning + afternoon + evening + night + nana_and_poppy + the_time + today + the_current_temperature_for + waynesboro + ocean_city + is + and + degrees + minus + am + pm + january + february + march + april + may + june + july + august + september + october | november + december + first + second + third + fourth + fifth + sixth + seventh + eighth + ninth + tenth + eleventh + twelfth + thirteenth + fourteenth + fifteenth + sixteenth + seventeenth + eighteenth + nineteenth + twentieth + thirtieth + oh + one + two | three + four + five + six + seven + eight + nine + ten + eleven + twelve + thirteen + fourteen + fifteen + sixteen + seventeen + eighteen + nineteen + twenty + thirty + forty + fifty + sixty + seventy + eighty + ninety + hundred | This project's GitHub repository also includes a Bash script to run as a sanity check for any missing or misnamed files. After choosing each clip's appropriate name, I saved the clip in the child's specific folder (child1, child2, etc.) as a WAV format file. I accepted the default export settings. -![Converting clip to WAV format][18] - -(Rich Lucente, [CC BY-SA 4.0][7]) +![Converting clip to WAV format][19] After exporting all the audio clips, I had a folder for each child that was fully populated with WAV files for the phrases above. This seems like a lot of work, but it took only about 90 minutes for each child, and I got way more efficient with each successive audio clip. @@ -305,22 +301,19 @@ After exporting all the audio clips, I had a folder for each child that was full Now that I had the audio clips for the greeting, I needed to think about the application and how to package it. I also wanted an open source-friendly solution that was open to modification. -About two years ago, a colleague gave me a [Google AIY Voice Kit][19] that he grabbed from the clearance bin for just $10. It's a cleverly folded box containing a speaker, microphone, and custom circuit board. You supply a Raspberry Pi and quickly have a do-it-yourself Google voice assistant. These kits are available for purchase online and in electronics stores. This small box offered an easy way to package the project. +About two years ago, a colleague gave me a [Google AIY Voice Kit][20] that he grabbed from the clearance bin for just $10. It's a cleverly folded box containing a speaker, microphone, and custom circuit board. You supply a Raspberry Pi and quickly have a do-it-yourself Google voice assistant. These kits are available for purchase online and in electronics stores. This small box offered an easy way to package the project. -![Google AIY Voice Kit][20] - -(Rich Lucente, [CC BY-SA 4.0][7]) +![Google AIY Voice Kit][21] ### Customize the voice assistant -The Google kit includes a Python API and several Python modules. I followed the kit's instructions to get the initial configuration working. The [Google Assistant gRPC][21] software is open source under an Apache 2.0 license. +The Google kit includes a Python API and several Python modules. I followed the kit's instructions to get the initial configuration working. The [Google Assistant gRPC][22] software is open source under an Apache 2.0 license. I adapted the Google Assistant gRPC demo to implement my application. The application's operation is fairly simple: First, it waits for the device's button to be pressed. The code then constructs four separate word lists for: 1. the greeting and date, 2. the current time, 3. the current temperature of the first location, and 4. the current temperature of the second location. The children's voices are randomly shuffled, and then each word list is used to play the audio clips corresponding to the child assigned to that list. (This is why it was important to strictly follow the naming convention for the audio clips.) The application then initiates a conversation with the Google Assistant API. At first, I thought the code to gather weather data for the current temperature and convert numbers to words would be challenging. This proved not to be the case at all. In fact, existing open source Python modules made it all simple and intuitive. -There were two cases to be addressed for converting numbers to word lists: I needed to convert ordinal numbers to words (e.g., 1 and 2 to first and second), and I also needed to convert cardinal numbers to words (e.g., 28 to twenty-eight). The open source [inflect.py module][22] has functions that handle both cases quite easily. - +There were two cases to be addressed for converting numbers to word lists: I needed to convert ordinal numbers to words (e.g., 1 and 2 to first and second), and I also needed to convert cardinal numbers to words (e.g., 28 to twenty-eight). The open source [inflect.py module][23] has functions that handle both cases quite easily. ``` import inflect @@ -337,8 +330,7 @@ print(p.number_to_words(p.ordinal(number)).replace('-', ' ').split(' ')) The inflect engine returns string representations of the numbers with embedded hyphens (e.g., twenty-three) so that the code splits the strings into variable-length word lists by converting the hyphens to spaces and splitting the string into a list using a space as the delimiter. -The next problem to solve was getting the current temperature for the two locations. [Open Weather Map][23] offers a free-tier weather service that allows up to 60 calls a minute or 1 million calls a month, which is way more than this project needs. I signed up for the free-tier service and received an API key. It was very easy to access the service by using the open source Python wrapper module [PyOWM][24]. Here is a simplified code snippet: - +The next problem to solve was getting the current temperature for the two locations. [Open Weather Map][24] offers a free-tier weather service that allows up to 60 calls a minute or 1 million calls a month, which is way more than this project needs. I signed up for the free-tier service and received an API key. It was very easy to access the service by using the open source Python wrapper module [PyOWM][25]. Here is a simplified code snippet: ``` import pyowm @@ -359,46 +351,49 @@ temp = round(observation.weather.temperature('fahrenheit')['temp']) ### Wrapping it up with a bow -The full source code for the project is available in my [GitHub repository][25]. The project includes a systemd service unit file adapted from Google's demo to automatically start the application on device boot. The GitHub repository includes instructions to install the Python modules and configure the systemd service. +The full source code for the project is available in my [GitHub repository][26]. The project includes a systemd service unit file adapted from Google's demo to automatically start the application on device boot. The GitHub repository includes instructions to install the Python modules and configure the systemd service. -I created a [short video][26] of the result. Five custom voice assistants were distributed during the holidays: one each for the great grandparents and grandparents of each child. For some, these gifts brought tears of joy. The children's voices are absolutely adorable and these boxes capture a fleeting moment of childhood that can be enjoyed for a very long time. +I created a [short video][27] of the result. Five custom voice assistants were distributed during the holidays: one each for the great grandparents and grandparents of each child. For some, these gifts brought tears of joy. The children's voices are absolutely adorable and these boxes capture a fleeting moment of childhood that can be enjoyed for a very long time. + +Image by: (Rich Lucente, CC BY-SA 4.0) -------------------------------------------------------------------------------- via: https://opensource.com/article/21/1/customize-voice-assistant 作者:[Rich Lucente][a] -选题:[lujun9972][b] +选题:[lkxed][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/rlucente -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/sound-radio-noise-communication.png?itok=KMNn9QrZ (radio communication signals) -[2]: https://opensource.com/article/20/7/mycroft-voice-skill -[3]: https://en.wikipedia.org/wiki/WAV -[4]: https://www.audacityteam.org/ -[5]: https://www.audacityteam.org/download/ -[6]: https://opensource.com/sites/default/files/uploads/audacity1_importaudio.png (Import audio files in Audacity) -[7]: https://creativecommons.org/licenses/by-sa/4.0/ -[8]: https://opensource.com/sites/default/files/uploads/audacity2_selectingtracks.png (Selecting all the audio tracks) -[9]: https://opensource.com/sites/default/files/uploads/audacity3_normalize.png (Normalize effect) -[10]: https://opensource.com/sites/default/files/uploads/audacity4_normalizedefaults.png (Normalize defaults) -[11]: https://opensource.com/sites/default/files/uploads/audacity5_backgroundnoise.png (Background noise sample) -[12]: https://opensource.com/sites/default/files/uploads/audacity6_noisereduction.png (Noise Reduction effect) -[13]: https://opensource.com/sites/default/files/uploads/audacity7_noiseprofile.png (Get a Noise Profile from audio sample) -[14]: https://opensource.com/sites/default/files/uploads/audacity8_selecttrack.png (Select whole audio track button) -[15]: https://opensource.com/sites/default/files/uploads/audacity9_noisereduction2.png (Noise Reduction effect step 2) -[16]: https://opensource.com/sites/default/files/uploads/audacity10_mutesolo.png (Mute and Solo buttons for multiple tracks) -[17]: https://opensource.com/sites/default/files/uploads/audacity11_exportaudio.png (Exporting selected audio) -[18]: https://opensource.com/sites/default/files/uploads/audacity12_convertwav.png (Converting clip to WAV format) -[19]: https://aiyprojects.withgoogle.com/voice/ -[20]: https://opensource.com/sites/default/files/uploads/googleaiy.png (Google AIY Voice Kit) -[21]: https://pypi.org/project/google-assistant-grpc/ -[22]: https://pypi.org/project/inflect -[23]: https://openweathermap.org/ -[24]: https://pypi.org/project/pyowm -[25]: https://github.com/rlucente-se-jboss/nana-poppy-project -[26]: https://youtu.be/Co7rigJRNUM +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/sound-radio-noise-communication.png +[2]: https://www.flickr.com/photos/internetarchivebookimages/14571450820/in/photolist-ocCuEG-otg1AX-hPy8JE-oc9YmN-oeUU2C-8cKWej-hQz72S-rpae2k-ocNYbT-oxbPTB-odGRsQ-ouDBo1-i5GTL8-qscJfA-idDrfk-i5D6oK-6K6iNH-ouxpn7-i8SivQ-oeY1eG-i7HGbT-bqXPhH-hN5on7-i9Q8YD-ouFYDw-fpy7Lo-oeSJo1-otqUu4-hNaVhf-oydqAV-owur2M-owkTSD-oydSWR-ocayce-ovFdYk-ocdaeL-ouE9UP-zmmrhp-qxtozB-ouqnSQ-obYbwS-odrnXt-ousXXw-ocA6Uo-owme9S-ouACY2-ocajY1-oeUJQG-ouryBk-ouxMJb +[3]: https://creativecommons.org/licenses/by-sa/4.0/ +[4]: https://opensource.com/article/20/7/mycroft-voice-skill +[5]: https://en.wikipedia.org/wiki/WAV +[6]: https://www.audacityteam.org/ +[7]: https://www.audacityteam.org/download/ +[8]: https://opensource.com/sites/default/files/uploads/audacity1_importaudio.png +[9]: https://opensource.com/sites/default/files/uploads/audacity2_selectingtracks.png +[10]: https://opensource.com/sites/default/files/uploads/audacity3_normalize.png +[11]: https://opensource.com/sites/default/files/uploads/audacity4_normalizedefaults.png +[12]: https://opensource.com/sites/default/files/uploads/audacity5_backgroundnoise.png +[13]: https://opensource.com/sites/default/files/uploads/audacity6_noisereduction.png +[14]: https://opensource.com/sites/default/files/uploads/audacity7_noiseprofile.png +[15]: https://opensource.com/sites/default/files/uploads/audacity8_selecttrack.png +[16]: https://opensource.com/sites/default/files/uploads/audacity9_noisereduction2.png +[17]: https://opensource.com/sites/default/files/uploads/audacity10_mutesolo.png +[18]: https://opensource.com/sites/default/files/uploads/audacity11_exportaudio.png +[19]: https://opensource.com/sites/default/files/uploads/audacity12_convertwav.png +[20]: https://aiyprojects.withgoogle.com/voice/ +[21]: https://opensource.com/sites/default/files/uploads/googleaiy.png +[22]: https://pypi.org/project/google-assistant-grpc/ +[23]: https://pypi.org/project/inflect +[24]: https://openweathermap.org/ +[25]: https://pypi.org/project/pyowm +[26]: https://github.com/rlucente-se-jboss/nana-poppy-project +[27]: https://youtu.be/Co7rigJRNUM diff --git a/sources/tech/20210107 A hands-on tutorial for using the GNU Project Debugger.md b/sources/tech/20210107 A hands-on tutorial for using the GNU Project Debugger.md deleted file mode 100644 index 422cb3821d..0000000000 --- a/sources/tech/20210107 A hands-on tutorial for using the GNU Project Debugger.md +++ /dev/null @@ -1,655 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (Starryi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (A hands-on tutorial for using the GNU Project Debugger) -[#]: via: (https://opensource.com/article/21/1/gnu-project-debugger) -[#]: author: (Stephan Avenwedde https://opensource.com/users/hansic99) - -A hands-on tutorial for using the GNU Project Debugger -====== -The GNU Project Debugger is a powerful tool for finding bugs in -programs. -![magnifying glass on computer screen, finding a bug in the code][1] - -If you're a programmer and you want to put a certain functionality in your software, you start by thinking of ways to implement it—such as writing a method, defining a class, or creating new data types. Then you write the implementation in a language that the compiler or interpreter can understand. But what if the compiler or interpreter does not understand the instructions as you had them in mind, even though you're sure you did everything right? What if the software works fine most of the time but causes bugs in certain circumstances? In these cases, you have to know how to use a debugger correctly to find the source of your troubles. - -The GNU Project Debugger ([GDB][2]) is a powerful tool for finding bugs in programs. It helps you uncover the reason for an error or crash by tracking what is going on inside the program during execution. - -This article is a hands-on tutorial on basic GDB usage. To follow along with the examples, open the command line and clone this repository: - - -``` -`git clone https://github.com/hANSIc99/core_dump_example.git` -``` - -### Shortcuts - -Every command in GDB can be shortened. For example, `info break`, which shows the set breakpoints, can be shortened to `i break`. You might see those abbreviations elsewhere, but in this article, I will write out the entire command so that it is clear which function is used. - -### Command-line parameters - -You can attach GDB to every executable. Navigate to the repository you cloned, and compile it by running `make`. You should now have an executable called **coredump**. (See my article on [_Creating and debugging Linux dump files_][3] for more information.. - -To attach GDB to the executable, type: `gdb coredump`. - -Your output should look like this: - -![gdb coredump output][4] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -It says no debugging symbols were found. - -Debugging information is part of the object file (the executable) and includes data types, function signatures, and the relationship between the source code and the opcode. At this point, you have two options: - - * Continue debugging the assembly (see "[Debug without symbols][6]" below) - * Compile with debug information using the information in the next section - - - -### Compile with debug information - -To include debug information in the binary file, you have to recompile it. Open the **Makefile** and remove the hashtag (`#`) from line 9: - - -``` -`CFLAGS =-Wall -Werror -std=c++11 -g` -``` - -The `g` option tells the compiler to include the debug information. Run `make clean` followed by `make` and invoke GDB again. You should get this output and can start debugging the code: - -![GDB output with symbols][7] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -The additional debugging information will increase the size of the executable. In this case, it increases the executable by 2.5 times (from 26,088 byte to 65,480 byte). - -Start the program with the `-c1` switch by typing `run -c1`. The program will start and crash when it reaches `State_4`: - -![gdb output crash on c1 switch][8] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -You can retrieve additional information about the program. The command `info source` provides information about the current file: - -![gdb info source output][9] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - - * 101 lines - * Language: C++ - * Compiler (version, tuning, architecture, debug flag, language standard) - * Debugging format: [DWARF 2][10] - * No preprocessor macro information available (when compiled with GCC, macros are available only when [compiled with the `-g3` flag][11]). - - - -The command `info shared` prints a list of dynamic libraries with their addresses in the virtual address space that was loaded on startup so that the program will execute: - -![gdb info shared output][12] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -If you want to learn about library handling in Linux, see my article [_How to handle dynamic and static libraries in Linux_][13]. - -### Debug the program - -You may have noticed that you can start the program inside GDB with the `run` command. The `run` command accepts command-line arguments like you would use to start the program from the console. The `-c1` switch will cause the program to crash on stage 4. To run the program from the beginning, you don't have to quit GDB; simply use the `run` command again. Without the `-c1` switch, the program executes an infinite loop. You would have to stop it with **Ctrl+C**. - -![gdb output stopped by sigint][14] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -You can also execute a program step by step. In C/C++, the entry point is the `main` function. Use the command `list main` to open the part of the source code that shows the `main` function: - -![gdb output list main][15] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -The `main` function is on line 33, so add a breakpoint there by typing `break 33`: - -![gdb output breakpoint added][16] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -Run the program by typing `run`. As expected, the program stops at the `main` function. Type `layout src` to show the source code in parallel: - -![gdb output break at main][17] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -You are now in GDB's text user interface (TUI) mode. Use the Up and Down arrow keys to scroll through the source code. - -GDB highlights the line to be executed. By typing `next` (n), you can execute the commands line by line. GBD executes the last command if you don't specify a new one. To step through the code, just hit the **Enter** key. - -From time to time, you will notice that TUI's output gets a bit corrupted: - -![gdb output corrupted][18] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -If this happens, press **Ctrl+L** to reset the screen. - -Use **Ctrl+X+A** to enter and leave TUI mode at will. You can find [other key bindings][19] in the manual. - -To quit GDB, simply type `quit`. - -### Watchpoints - -The heart of this example program consists of a state machine running in an infinite loop. The variable `n_state` is a simple enum that determines the current state: - - -``` -while(true){ -        switch(n_state){ -        case State_1: -                std::cout << "State_1 reached" << std::flush; -                n_state = State_2; -                break; -        case State_2: -                std::cout << "State_2 reached" << std::flush; -                n_state = State_3; -                break; -        -        (.....) -        -        } -} -``` - -You want to stop the program when `n_state` is set to the value `State_5`. To do so, stop the program at the `main` function and set a watchpoint for `n_state`: - - -``` -`watch n_state == State_5` -``` - -Setting watchpoints with the variable name works only if the desired variable is available in the current context. - -When you continue the program's execution by typing `continue`, you should get output like: - -![gdb output stop on watchpoint_1][20] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -If you continue the execution, GDB will stop when the watchpoint expression evaluates to `false`: - -![gdb output stop on watchpoint_2][21] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -You can specify watchpoints for general value changes, specific values, and read or write access. - -### Altering breakpoints and watchpoints - -Type `info watchpoints` to print a list of previously set watchpoints: - -![gdb output info watchpoints][22] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -#### Delete breakpoints and watchpoints - -As you can see, watchpoints are numbers. To delete a specific watchpoint, type `delete` followed by the number of the watchpoint. For example, my watchpoint has the number 2; to remove this watchpoint, enter `delete 2`. - -_Caution:_ If you use `delete` without specifying a number, _all_ watchpoints and breakpoints will be deleted. - -The same applies to breakpoints. In the screenshot below, I added several breakpoints and printed a list of them by typing `info breakpoint`: - -![gdb output info breakpoints][23] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -To remove a single breakpoint, type `delete` followed by its number. Alternatively, you can remove a breakpoint by specifying its line number. For example, the command `clear 78` will remove breakpoint number 7, which is set on line 78. - -#### Disable or enable breakpoints and watchpoints - -Instead of removing a breakpoint or watchpoint, you can disable it by typing `disable` followed by its number. In the following, breakpoints 3 and 4 are disabled and are marked with a minus sign in the code window: - -![disabled breakpoints][24] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -It is also possible to modify a range of breakpoints or watchpoints by typing something like `disable 2 - 4`. If you want to reactivate the points, type `enable` followed by their numbers. - -### Conditional breakpoints - -First, remove all breakpoints and watchpoints by typing `delete`. You still want the program to stop at the `main` function, but instead of specifying a line number, add a breakpoint by naming the function directly. Type `break main` to add a breakpoint at the `main` function. - -Type `run` to start the execution from the beginning, and the program will stop at the `main` function. - -The `main` function includes the variable `n_state_3_count`, which is incremented when the state machine hits state 3. - -To add a conditional breakpoint based on the value of `n_state_3_count` type: - - -``` -`break 54 if n_state_3_count == 3` -``` - -![Set conditional breakpoint][25] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -Continue the execution. The program will execute the state machine three times before it stops at line 54. To check the value of `n_state_3_count`, type: - - -``` -`print n_state_3_count` -``` - -![print variable][26] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -#### Make breakpoints conditional - -It is also possible to make an existing breakpoint conditional. Remove the recently added breakpoint with `clear 54`, and add a simple breakpoint by typing `break 54`. You can make this breakpoint conditional by typing: - - -``` -`condition 3 n_state_3_count == 9` -``` - -The `3` refers to the breakpoint number. - -![modify breakpoint][27] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -#### Set breakpoints in other source files - -If you have a program that consists of several source files, you can set breakpoints by specifying the file name before the line number, e.g., `break main.cpp:54`. - -#### Catchpoints - -In addition to breakpoints and watchpoints, you can also set catchpoints. Catchpoints apply to program events like performing syscalls, loading shared libraries, or raising exceptions. - -To catch the `write` syscall, which is used to write to STDOUT, enter: - - -``` -`catch syscall write` -``` - -![catch syscall write output][28] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -Each time the program writes to the console output, GDB will interrupt execution. - -In the manual, you can find a whole chapter [covering break-, watch-, and catchpoints][29]. - -### Evaluate and manipulate symbols - -Printing the values of variables is done with the `print` command. The general syntax is `print `. The value of a variable can be modified by typing: - - -``` -`set variable .` -``` - -In the screenshot below, I gave the variable `n_state_3_count` the value _123_. - -![print variable][30] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -The `/x` expression prints the value in hexadecimal; with the `&` operator, you can print the address within the virtual address space. - -If you are not sure of a certain symbol's data type, you can find it with `whatis`: - -![whatis output][31] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -If you want to list all variables that are available in the scope of the `main` function, type `info scope main`: - -![info scope main output][32] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -The `DW_OP_fbreg` values refer to the stack offset based on the current subroutine. - -Alternatively, if you are already inside a function and want to list all variables on the current stack frame, you can use `info locals`: - -![info locals output][33] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -Check the manual to learn more about [examining symbols][34]. - -### Attach to a running process - -The command `gdb attach ` allows you to attach to an already running process by specifying the process ID (PID). Luckily, the `coredump` program prints its current PID to the screen, so you don't have to manually find it with [ps][35] or [top][36]. - -Start an instance of the coredump application: - - -``` -`./coredump` -``` - -![coredump application][37] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -The operating system gives the PID `2849`. Open a separate console window, move to the coredump application's source directory, and attach GDB: - - -``` -`gdb attach 2849` -``` - -![attach GDB to coredump][38] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -GDB immediately stops the execution when you attach it. Type `layout src` and `backtrace` to examine the call stack: - -![layout src and backtrace output][39] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -The output shows the process interrupted while executing the `std::this_thread::sleep_for<...>(...)` function that was called in line 92 of `main.cpp`. - -As soon as you quit GDB, the process will continue running. - -You can find more information about [attaching to a running process][40] in the GDB manual. - -#### Move through the stack - -Return to the program by using `up` two times to move up in the stack to `main.cpp`: - -![moving up the stack to main.cpp][41] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -Usually, the compiler will create a subroutine for each function or method. Each subroutine has its own stack frame, so moving upwards in the stackframe means moving upwards in the callstack. - -You can find out more about [stack evaluation][42] in the manual. - -#### Specify the source files - -When attaching to an already running process, GDB will look for the source files in the current working directory. Alternatively, you can specify the source directories manually with the [`directory` command][43]. - -### Evaluate dump files - -Read [_Creating and debugging Linux dump files_][3] for information about this topic. - -TL;DR: - - 1. I assume you're working with a recent version of Fedora - - 2. Invoke coredump with the c1 switch: `coredump -c1` - -![Crash meme][44] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - - 3. Load the latest dumpfile with GDB: `coredumpctl debug` - - 4. Open TUI mode and enter `layout src` - - - - -![coredump output][45] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -The output of `backtrace` shows that the crash happened five stack frames away from `main.cpp`. Enter to jump directly to the faulty line of code in `main.cpp`: - -![up 5 output][46] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -A look at the source code shows that the program tried to free a pointer that was not returned by a memory management function. This results in undefined behavior and caused the `SIGABRT`. - -### Debug without symbols - -If there are no sources available, things get very hard. I had my first experience with this when trying to solve reverse-engineering challenges. It is also useful to have some knowledge of [assembly language][47]. - -Check out how it works with this example. - -Go to the source directory, open the **Makefile**, and edit line 9 like this: - - -``` -`CFLAGS =-Wall -Werror -std=c++11 #-g` -``` - -To recompile the program, run `make clean` followed by `make` and start GDB. The program no longer has any debugging symbols to lead the way through the source code. - -![no debugging symbols][48] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -The command `info file` reveals the memory areas and entry point of the binary: - -![info file output][49] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -The entry point corresponds with the beginning of the `.text` area, which contains the actual opcode. To add a breakpoint at the entry point, type `break *0x401110` then start execution by typing `run`: - -![breakpoint at the entry point][50] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -To set up a breakpoint at a certain address, specify it with the dereferencing operator `*`. - -#### Choose the disassembler flavor - -Before digging deeper into assembly, you can choose which [assembly flavor][51] to use. GDB's default is AT&T, but I prefer the Intel syntax. Change it with: - - -``` -`set disassembly-flavor intel` -``` - -![changing assembly flavor][52] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -Now open the assembly and register the window by typing `layout asm` and `layout reg`. You should now see output like this: - -![layout asm and layout reg output][53] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -#### Save configuration files - -Although you have already entered many commands, you haven't actually started debugging. If you are heavily debugging an application or trying to solve a reverse-engineering challenge, it can be useful to save your GDB-specific settings in a file. - -The [config file `gdbinit`][54] in this project's GitHub repository contains the recently used commands: - - -``` -set disassembly-flavor intel -set write on -break *0x401110 -run -c2 -layout asm -layout reg -``` - -The `set write on` command enables you to modify the binary during execution. - -Quit GDB and reopen it with the configuration file: `gdb -x gdbinit coredump`. - -#### Read instructions - -With the `c2` switch applied, the program will crash. The program stops at the entry function, so you have to write `continue` to proceed with execution: - -![continuing execution after crash][55] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -The `idiv` instruction performs an integer division with the dividend in the `RAX` register and the divisor specified as an argument. The quotient is loaded into the `RAX` register, and the remainder is loaded into `RDX`. - -From the register overview, you can see the `RAX` contains _5_, so you have to find out which value is stored on the stack at position `RBP-0x4`. - -#### Read memory - -To read raw memory content, you must specify a few more parameters than for reading symbols. When you scroll up a bit in the assembly output, you can see the division of the stack: - -![stack division output][56] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -You're most interested in the value of `rbp-0x4` because this is the position where the argument for `idiv` is stored. From the screenshot, you can see that the next variable is located at `rbp-0x8`, so the variable at `rbp-0x4` is 4 bytes wide. - -In GDB, you can use the `x` command to _examine_ any memory content: - -> `x/` < optional parameter `n` `f` `u` > < memory address `addr` > - -Optional parameters: - - * `n`: Repeat count (default: 1) refers to the unit size - * `f`: Format specifier, like in [printf][57] - * `u`: Unit size - * `b`: bytes - * `h`: half words (2 bytes) - * `w`: word (4 bytes)(default) - * `g`: giant word (8 bytes) - - - -To print out the value at `rbp-0x4`, type `x/u $rbp-4`: - -![print value][58] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -If you keep this pattern in mind, it's straightforward to examine the memory. Check the [examining memory][59] section in the manual. - -#### Manipulate the assembly - -The arithmetic exception happened in the subroutine `zeroDivide()`. When you scroll a bit upward with the Up arrow key, you can find this pattern: - - -``` -0x401211 <_Z10zeroDividev>              push   rbp -0x401212 <_Z10zeroDividev+1>            mov    rbp,rsp   -``` - -This is called the [function prologue][60]: - - 1. The base pointer (`rbp`) of the calling function is stored on the stack - 2. The value of the stack pointer (`rsp`) is loaded to the base pointer (`rbp`) - - - -Skip this subroutine completely. You can check the call stack with `backtrace`. You are only one stack frame ahead of your `main` function, so you can go back to `main` with a single `up`: - -![Callstack assembly][61] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -In your `main` function, you can find this pattern: - - -``` -0x401431 <main+497>     cmp    BYTE PTR [rbp-0x12],0x0 -0x401435 <main+501>     je     0x40145f <main+543> -0x401437 <main+503>     call   0x401211<_Z10zeroDividev> -``` - -The subroutine `zeroDivide()` is entered only when `jump equal (je)` evaluates to `true`. You can easily replace this with a `jump-not-equal (jne)` instruction, which has the opcode `0x75` (provided you are on an x86/64 architecture; the opcodes are different on other architectures). Restart the program by typing `run`. When the program stops at the entry function, manipulate the opcode by typing: - - -``` -`set *(unsigned char*)0x401435 = 0x75` -``` - -Finally, type `continue`. The program will skip the subroutine `zeroDivide()` and won't crash anymore. - -### Conclusion - -You can find GDB working in the background in many integrated development environments (IDEs), including Qt Creator and the [Native Debug][62] extension for VSCodium. - -![GDB in VSCodium][63] - -(Stephan Avenwedde, [CC BY-SA 4.0][5]) - -It's useful to know how to leverage GDB's functionality. Usually, not all of GDB's functions can be used from the IDE, so you benefit from having experience using GDB from the command line. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/1/gnu-project-debugger - -作者:[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/mistake_bug_fix_find_error.png?itok=PZaz3dga (magnifying glass on computer screen, finding a bug in the code) -[2]: https://www.gnu.org/software/gdb/ -[3]: https://opensource.com/article/20/8/linux-dump -[4]: https://opensource.com/sites/default/files/uploads/gdb_output_no_dbg_symbols.png (gdb coredump output) -[5]: https://creativecommons.org/licenses/by-sa/4.0/ -[6]: tmp.2p0XrqmAS5#without_symbols -[7]: https://opensource.com/sites/default/files/uploads/gdb_output_with_symbols.png (GDB output with symbols) -[8]: https://opensource.com/sites/default/files/uploads/gdb_output_crash_on_c1_switch.png (gdb output crash on c1 switch) -[9]: https://opensource.com/sites/default/files/uploads/gdb_output_info_source.png (gdb info source output) -[10]: http://dwarfstd.org/ -[11]: https://sourceware.org/gdb/current/onlinedocs/gdb/Compilation.html#Compilation -[12]: https://opensource.com/sites/default/files/uploads/gdb_output_info_shared.png (gdb info shared output) -[13]: https://opensource.com/article/20/6/linux-libraries -[14]: https://opensource.com/sites/default/files/uploads/gdb_output_stopped_by_sigint.png (gdb output stopped by sigint) -[15]: https://opensource.com/sites/default/files/uploads/gdb_output_list_main.png (gdb output list main) -[16]: https://opensource.com/sites/default/files/uploads/gdb_output_breakpoint_added.png (gdb output breakpoint added) -[17]: https://opensource.com/sites/default/files/uploads/gdb_output_break_at_main.png (gdb output break at main) -[18]: https://opensource.com/sites/default/files/images/gdb_output_screen_corrupted.png (gdb output corrupted) -[19]: https://sourceware.org/gdb/onlinedocs/gdb/TUI-Keys.html#TUI-Keys -[20]: https://opensource.com/sites/default/files/uploads/gdb_output_stop_on_watchpoint_1.png (gdb output stop on watchpoint_1) -[21]: https://opensource.com/sites/default/files/uploads/gdb_output_stop_on_watchpoint_2.png (gdb output stop on watchpoint_2) -[22]: https://opensource.com/sites/default/files/uploads/gdb_output_info_watchpoints.png (gdb output info watchpoints) -[23]: https://opensource.com/sites/default/files/uploads/gdb_output_info_breakpoints.png (gdb output info breakpoints) -[24]: https://opensource.com/sites/default/files/uploads/gdb_output_disabled_breakpoints.png (disabled breakpoints) -[25]: https://opensource.com/sites/default/files/uploads/gdb_output_set_conditional_breakpoint.png (Set conditional breakpoint) -[26]: https://opensource.com/sites/default/files/uploads/gdb_output_print_variable.png (print variable) -[27]: https://opensource.com/sites/default/files/uploads/gdb_output_modify_breakpoint.png (modify breakpoint) -[28]: https://opensource.com/sites/default/files/uploads/gdb_output_syscall_catch.png (catch syscall write output) -[29]: https://sourceware.org/gdb/current/onlinedocs/gdb/Breakpoints.html#Breakpoints -[30]: https://opensource.com/sites/default/files/uploads/gdb_output_print_and_modify.png (print variable) -[31]: https://opensource.com/sites/default/files/uploads/gdb_output_whatis.png (whatis output) -[32]: https://opensource.com/sites/default/files/uploads/gdb_output_info_scope_main.png (info scope main output) -[33]: https://opensource.com/sites/default/files/uploads/gdb_output_info_locals_main.png (info locals output) -[34]: https://sourceware.org/gdb/current/onlinedocs/gdb/Symbols.html -[35]: https://man7.org/linux/man-pages/man1/ps.1.html -[36]: https://man7.org/linux/man-pages/man1/top.1.html -[37]: https://opensource.com/sites/default/files/uploads/coredump_running.png (coredump application) -[38]: https://opensource.com/sites/default/files/uploads/gdb_output_attaching_to_process.png (attach GDB to coredump) -[39]: https://opensource.com/sites/default/files/uploads/gdb_output_backtrace.png (layout src and backtrace output) -[40]: https://sourceware.org/gdb/current/onlinedocs/gdb/Attach.html#Attach -[41]: https://opensource.com/sites/default/files/uploads/gdb_output_stackframe_up.png (moving up the stack to main.cpp) -[42]: https://sourceware.org/gdb/current/onlinedocs/gdb/Stack.html#Stack -[43]: https://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_48.html#SEC49 -[44]: https://opensource.com/sites/default/files/uploads/crash.png (Crash meme) -[45]: https://opensource.com/sites/default/files/uploads/gdb_output_coredump.png (coredump output) -[46]: https://opensource.com/sites/default/files/uploads/gdb_output_up_five.png (up 5 output) -[47]: https://en.wikipedia.org/wiki/Assembly_language -[48]: https://opensource.com/sites/default/files/uploads/gdb_output_no_debugging_symbols.png (no debugging symbols) -[49]: https://opensource.com/sites/default/files/uploads/gdb_output_info_file.png (info file output) -[50]: https://opensource.com/sites/default/files/uploads/gdb_output_break_at_start.png (breakpoint at the entry point) -[51]: https://en.wikipedia.org/wiki/X86_assembly_language#Syntax -[52]: https://opensource.com/sites/default/files/uploads/gdb_output_disassembly_flavor.png (changing assembly flavor) -[53]: https://opensource.com/sites/default/files/uploads/gdb_output_layout_reg_asm.png (layout asm and layout reg output) -[54]: https://github.com/hANSIc99/core_dump_example/blob/master/gdbinit -[55]: https://opensource.com/sites/default/files/uploads/gdb_output_asm_div_zero.png (continuing execution after crash) -[56]: https://opensource.com/sites/default/files/uploads/gdb_output_stack_division.png (stack division output) -[57]: https://en.wikipedia.org/wiki/Printf_format_string#Type_field -[58]: https://opensource.com/sites/default/files/uploads/gdb_output_examine_1.png (print value) -[59]: https://sourceware.org/gdb/current/onlinedocs/gdb/Memory.html -[60]: https://en.wikipedia.org/wiki/Function_prologue -[61]: https://opensource.com/sites/default/files/uploads/gdb_output_callstack_assembly_0.png (Callstack assembly) -[62]: https://github.com/WebFreak001/code-debug -[63]: https://opensource.com/sites/default/files/uploads/vs_codium_native_debug.png (GDB in VSCodium) diff --git a/sources/tech/20210111 an even better video wharf.md b/sources/tech/20210111 an even better video wharf.md new file mode 100644 index 0000000000..d42ace0d0b --- /dev/null +++ b/sources/tech/20210111 an even better video wharf.md @@ -0,0 +1,121 @@ +[#]: subject: "an even better video wharf" +[#]: via: "https://jao.io/blog/2021-01-11-an-even-better-video-wharf.html" +[#]: author: "jao https://jao.io" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +an even better video wharf +====== + +A couple of days ago, [i was writing][1] about [embark][2] and my first experiment defining a new embarking to play remote video streams. Omar Antolín Camarena, embark's author, has been kind enough to not only read it, but comment on a couple of significant improvements that i think well deserve this follow-up. + +First, you'll remember that we were defining a function to detect a video URL: + +``` + + (defun jao-video-finder () + "Check whether we're looking at a video URL. + Return (video-url . ) if so." + (when-let ((url (thing-at-point-url-at-point))) + (when (string-match-p jao-video-url-rx url) + (cons 'video-url url)))) + +``` + +Once we've got a non-null `url` value, even if it's not a video URL, it's still certainly a URL, and embark has a `url` category, so we could save a new parsing by the default URL finder by saying: + +``` + + (when-let ((url (thing-at-point-url-at-point))) + (cons (if (string-match-p jao-video-url-rx url) 'video-url 'url) url)) + +``` + +This has the potential drawback that we're overriding embark's finder, `embark-target-url-at-point`, and we might prefer to keep the latter. + +Turns out that we can do that thanks to embark's _target transformers_. One can add to `embark-transformers-alist` an arbitrary function to be applied to a target of any given category, and embark will apply its actions to the transformed value. Omar calls this process, very aptly, a refinement of the target; here's how we would do it: + +``` + + (defun jao-refine-url-type (url) + "Refine type of URL in case it is a video." + (cons (if (string-match-p jao-video-url-rx url) 'video-url 'url) url)) + + (add-to-list 'embark-transformer-alist '(url . jao-refine-url-type)) + +``` + +With this strategy, we don't need `jao-video-finder` at all, and it also makes lots of sense, conceptually, to have our `video-url` defined as a refinement rather than a new target[1][3]. Omar's second suggestion is also in line with this concept: surely we want all actions available for `url` also for our `video-url`, don't we? Well, that's exactly the reason why the `embark-define-keymap` macro we used to define our actions can inherit all the actions already defined in another keymap, using the `:parent` keyword[2][4]: + +``` + + (embark-define-keymap jao-video-url-map + "Actions on URLs pointing to remote video streams." + :parent embark-url-map + ("p" jao-play-video-url)) + + (add-to-list 'embark-keymap-alist '(video-url . jao-video-url-map)) + +``` + +It is worth noting that this ability to inherit a keymap is not really an embark add-on: vanilla Emacs keymaps already have it, via the standard function `set-keymap-parent`. You could actually define `jao-video-url-map` without using `embark-define-keymap` at all, and it'd work exactly the same. + +So, our code has become shorter and more featureful: thanks, Omar! + +### Footnotes: + +[1][5] + +There's a scenario where keeping jao-video-finder could make sense, namely, if we want to alter the URL detection function. For instance, i use emacs-w3m, and there often a URL is stored as a text property (the actual text being the link text). To retrieve the URL at point there, one needs to call `w3m-anchor`, and `embark-target-url-at-point` will miss it. For that scenario, i ended up writing (and using) `jao-video-finder` defined with: + +``` + + (when-let ((url (or (w3m-anchor) (thing-at-point-url-at-point)))) + (cons (if (string-match-p jao-video-url-rx url) 'video-url 'url) url)) + +``` + +Another way of accomplishing the same thing (with another tip of the hat to Omar) would be to add a specific finder for w3m anchors (and keep using the transformer for video-url): + +``` + + (defun jao-w3m-url-finder () + (when-let ((url (w3m-anchor))) + (cons 'url url))) + + (add-to-list 'embark-target-finders #'jao-w3m-url-finder) + +``` + +This way is more modular and, depending on your taste, more elegant. These functions are small and there's not a big difference between the two approaches, but if one keeps adding finders, things can easily get uglier with the former approach. + +[2][6] + +In my original example, i was adding also `browse-url` and `browse-url-firefox` to the video map. The former is no longer necessary, because it's already present in `embark-url-map`. If we wanted to make `browse-url-firefox` available to _all_ URLs, we could add it to `embark-url-map` (remember, embark's keymaps are just Emacs keymaps). That's yet another simple way of extending embark. + +[Tags][7]: [emacs][8] + +-------------------------------------------------------------------------------- + +via: https://jao.io/blog/2021-01-11-an-even-better-video-wharf.html + +作者:[jao][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://jao.io +[b]: https://github.com/lujun9972 +[1]: https://jao.io/blog/2021-01-09-embarking-videos.html +[2]: https://github.com/oantolin/embark +[3]: tmp.VUqMT3Yft2#fn.1 +[4]: tmp.VUqMT3Yft2#fn.2 +[5]: tmp.VUqMT3Yft2#fnr.1 +[6]: tmp.VUqMT3Yft2#fnr.2 +[7]: https://jao.io/blog/tags.html +[8]: https://jao.io/blog/tag-emacs.html diff --git a/sources/tech/20210113 Analyze Kubernetes files for errors with KubeLinter.md b/sources/tech/20210113 Analyze Kubernetes files for errors with KubeLinter.md index 37b7f2ff53..ed86a16cf2 100644 --- a/sources/tech/20210113 Analyze Kubernetes files for errors with KubeLinter.md +++ b/sources/tech/20210113 Analyze Kubernetes files for errors with KubeLinter.md @@ -1,18 +1,20 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Analyze Kubernetes files for errors with KubeLinter) -[#]: via: (https://opensource.com/article/21/1/kubelinter) -[#]: author: (Jessica Cherry https://opensource.com/users/cherrybomb) +[#]: subject: "Analyze Kubernetes files for errors with KubeLinter" +[#]: via: "https://opensource.com/article/21/1/kubelinter" +[#]: author: "Jessica Cherry https://opensource.com/users/cherrybomb" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " Analyze Kubernetes files for errors with KubeLinter ====== -Find and fix errors in your Helm charts and Kubernetes configuration -files with KubeLinter. +Find and fix errors in your Helm charts and Kubernetes configuration files with KubeLinter. + ![magnifying glass on computer screen, finding a bug in the code][1] +Image by: Opensource.com + [KubeLinter][2] is an open source project released by Stackrox to analyze Kubernetes YAML files for security issues and errant code. The tool covers Helm charts and Kubernetes configuration files, including [Knative][3] files. Using it can improve cloud-native development, reduce development time, and encourage DevOps best practices. ### Download and install @@ -23,23 +25,20 @@ You have several options to install KubeLinter. You can install manually from the Git repository: - ``` -$ git clone [git@github.com][4]:stackrox/kube-linter.git -$ cd kube-linter && make build +$ git clone git@github.com:stackrox/kube-linter.git +$ cd kube-linter && make build $ .gobin/kube-linter version ``` -If you use [Homebrew][5], you can install it with the `brew` command: - +If you use [Homebrew][4], you can install it with the `brew` command: ``` -`$ brew install kube-linter` +$ brew install kube-linter ``` You can also install it with Go (as I did): - ``` $ GO111MODULE=on go get golang.stackrox.io/kube-linter/cmd/kube-linter go: finding golang.stackrox.io/kube-linter latest @@ -48,11 +47,10 @@ go: extracting golang.stackrox.io/kube-linter v0.0.0-20201204022312-475075c74675 [...] ``` -After installing, you must make an alias in your `~/.bashrc`: - +After installing, you must make an alias in your `~/.bashrc` : ``` -$ echo "alias kube-linter=$HOME/go/bin/kube-linter" >> ~/.bashrc +$ echo "alias kube-linter=$HOME/go/bin/kube-linter" >> ~/.bashrc $ source ~/.bashrc ``` @@ -60,7 +58,6 @@ $ source ~/.bashrc Now that the tool is installed, try it out on a Helm chart. First, start Minikube with a clean build and some small configuration changes: - ``` $ minikube config set kubernetes-version v1.19.0 $ minikube config set memory 8000 @@ -68,23 +65,22 @@ $ minikube config set memory 8000 $ minikube config set cpus 12 ❗  These changes will take effect upon a minikube delete and then a minikube start $ minikube delete -🔥  Deleting "minikube" in docker ... -🔥  Deleting container "minikube" ... -🔥  Removing /home/jess/.minikube/machines/minikube ... -💀  Removed all traces of the "minikube" cluster. +?  Deleting "minikube" in docker ... +?  Deleting container "minikube" ... +?  Removing /home/jess/.minikube/machines/minikube ... +?  Removed all traces of the "minikube" cluster. $ minikube start -😄  minikube v1.14.2 on Debian bullseye/sid +?  minikube v1.14.2 on Debian bullseye/sid ✨  Using the docker driver based on user configuration -👍  Starting control plane node minikube in cluster minikube -🎉  minikube 1.15.1 is available! Download it: -💡  To disable this notice, run: 'minikube config set WantUpdateNotification false' +?  Starting control plane node minikube in cluster minikube +?  minikube 1.15.1 is available! Download it: https://github.com/kubernetes/minikube/releases/tag/v1.15.1 +?  To disable this notice, run: 'minikube config set WantUpdateNotification false' -💾  Downloading Kubernetes v1.19.0 preload ... +?  Downloading Kubernetes v1.19.0 preload ... ``` -Once everything is running, create an example Helm chart called `first_test`: - +Once everything is running, create an example Helm chart called `first_test` : ``` $ helm create first_test @@ -95,7 +91,6 @@ first_test Test KubeLinter against the new, unedited chart. Run the `kube-linter` command to see the available commands and flags: - ``` $ kube-linter Usage: @@ -103,8 +98,8 @@ Usage: Available Commands:   checks      View more information on lint checks -  help        Help about any command -  lint        Lint Kubernetes YAML files and Helm charts +  help  Help about any command +  lint  Lint Kubernetes YAML files and Helm charts   templates   View more information on check templates   version     Print version and exit @@ -116,13 +111,12 @@ Use "/home/jess/go/bin/kube-linter [command] --help" for more information about Then test what the basic `lint` command does to your example chart. You'll end up with many errors, so I'll grab a snippet of some issues: - ``` $ kube-linter lint first_test/ -first_test/first_test/templates/deployment.yaml: (object: <no namespace>/test-release-first_test apps/v1, Kind=Deployment) container "first_test" does not have a read-only root file system (check: no-read-only-root-fs, remediation: Set readOnlyRootFilesystem to true in your container's securityContext.) +first_test/first_test/templates/deployment.yaml: (object: /test-release-first_test apps/v1, Kind=Deployment) container "first_test" does not have a read-only root file system (check: no-read-only-root-fs, remediation: Set readOnlyRootFilesystem to true in your container's securityContext.) -first_test/first_test/templates/deployment.yaml: (object: <no namespace>/test-release-first_test apps/v1, Kind=Deployment) container "first_test" is not set to runAsNonRoot (check: run-as-non-root, remediation: Set runAsUser to a non-zero number, and runAsNonRoot to true, in your pod or container securityContext. See for more details.) +first_test/first_test/templates/deployment.yaml: (object: /test-release-first_test apps/v1, Kind=Deployment) container "first_test" is not set to runAsNonRoot (check: run-as-non-root, remediation: Set runAsUser to a non-zero number, and runAsNonRoot to true, in your pod or container securityContext. See https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ for more details.) [...] Error: found 12 lint errors ``` @@ -131,14 +125,12 @@ For the sake of brevity, I picked two security issues that are easy for me to f The `kube-linter` output provides hints about the required fixes. For instance, the first error ends with: - ``` -`remediation: Set readOnlyRootFilesystem to true in your container's securityContext.` +remediation: Set readOnlyRootFilesystem to true in your container's securityContext. ``` The next step is clear: Open the `values.yaml` file in a text editor (I use Vi, but you can use whatever you like) and locate the `securityContext` section: - ``` securityContext: {}   # capabilities: @@ -151,12 +143,11 @@ securityContext: {} Uncomment the section and remove the braces: - ``` -securityContext: +securityContext:    capabilities:      drop: -    - ALL +     - ALL    readOnlyRootFilesystem: true    runAsNonRoot: true    runAsUser: 1000 @@ -164,20 +155,18 @@ securityContext: Save the file and rerun the linter. Those errors no longer show up in the list, and the error count changes. - ``` -`Error: found 10 lint errors` +Error: found 10 lint errors ``` Congratulations! You have resolved security issues! ### Kubernetes with KubeLinter -This example uses an app file from my [previous article on Knative][6] to test against Kubernetes config files. I already have Knative up and running, so you may want to review that article if it's not running on your system. +This example uses an app file from my [previous article on Knative][5] to test against Kubernetes config files. I already have Knative up and running, so you may want to review that article if it's not running on your system. I downloaded the Kourier service YAML file for this example: - ``` $ ls kourier.yaml   first_test @@ -185,13 +174,12 @@ kourier.yaml   first_test Start by running the linter against `kourier.yaml`. Again, there are several issues. I'll focus on resource problems: - ``` -$ kube-linter lint kourier.yaml +$ kube-linter lint kourier.yaml -kourier.yaml: (object: kourier-system/3scale-kourier-gateway apps/v1, Kind=Deployment) container "kourier-gateway" has cpu limit 0 (check: unset-cpu-requirements, remediation: Set your container's CPU requests and limits depending on its requirements. See for more details.) +kourier.yaml: (object: kourier-system/3scale-kourier-gateway apps/v1, Kind=Deployment) container "kourier-gateway" has cpu limit 0 (check: unset-cpu-requirements, remediation: Set your container's CPU requests and limits depending on its requirements. See https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#requests-and-limits for more details.) -kourier.yaml: (object: kourier-system/3scale-kourier-gateway apps/v1, Kind=Deployment) container "kourier-gateway" has memory request 0 (check: unset-memory-requirements, remediation: Set your container's memory requests and limits depending on its requirements. See for more details.) +kourier.yaml: (object: kourier-system/3scale-kourier-gateway apps/v1, Kind=Deployment) container "kourier-gateway" has memory request 0 (check: unset-memory-requirements, remediation: Set your container's memory requests and limits depending on its requirements. See https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#requests-and-limits for more details.) Error: found 12 lint errors ``` @@ -200,7 +188,6 @@ Since this is a single deployment file, you can edit it directly. Open it in a t Start with deployment: - ``` apiVersion: apps/v1 kind: Deployment @@ -214,70 +201,67 @@ metadata: The containers section has some problems: - ``` -   spec: -      containers: -      - args: -       - --base-id 1 -        - -c /tmp/config/envoy-bootstrap.yaml -        - --log-level info -        command: -       - /usr/local/bin/envoy -        image: docker.io/maistra/proxyv2-ubi8:1.1.5 -        imagePullPolicy: Always -        name: kourier-gateway -        ports: -        - name: http2-external -          containerPort: 8080 -          protocol: TCP -        - name: http2-internal -          containerPort: 8081 -          protocol: TCP -        - name: https-external -          containerPort: 8443 -          protocol: TCP +spec: + containers: + - args: +  - --base-id 1 +   - -c /tmp/config/envoy-bootstrap.yaml +   - --log-level info +   command: +  - /usr/local/bin/envoy +   image: docker.io/maistra/proxyv2-ubi8:1.1.5 +   imagePullPolicy: Always +   name: kourier-gateway +   ports: +   - name: http2-external +     containerPort: 8080 +     protocol: TCP +   - name: http2-internal +     containerPort: 8081 +     protocol: TCP +   - name: https-external +     containerPort: 8443 +     protocol: TCP ``` Add some specs to the container configuration: - ``` -   spec: -      containers: -      - args: -       - --base-id 1 -        - -c /tmp/config/envoy-bootstrap.yaml -        - --log-level info -        command: -       - /usr/local/bin/envoy -        image: docker.io/maistra/proxyv2-ubi8:1.1.5 -        imagePullPolicy: Always -        name: kourier-gateway -        ports: -        - name: http2-external -          containerPort: 8080 -          protocol: TCP -        - name: http2-internal -          containerPort: 8081 -          protocol: TCP -        - name: https-external -          containerPort: 8443 -          protocol: TCP +spec: + containers: + - args: +  - --base-id 1 +   - -c /tmp/config/envoy-bootstrap.yaml +   - --log-level info +   command: +  - /usr/local/bin/envoy +   image: docker.io/maistra/proxyv2-ubi8:1.1.5 +   imagePullPolicy: Always +   name: kourier-gateway +   ports: +   - name: http2-external +     containerPort: 8080 +     protocol: TCP +   - name: http2-internal +     containerPort: 8081 +     protocol: TCP +   - name: https-external +     containerPort: 8443 +     protocol: TCP  resources:     limits: -      cpu: 100m -      memory: 128Mi + cpu: 100m + memory: 128Mi     requests: -      cpu: 100m -      memory: 128Mi + cpu: 100m + memory: 128Mi ``` When you rerun the linter, you'll notice these issues no longer show in the output, and the error count changes: - ``` -`Error: found 8 lint errors` +Error: found 8 lint errors ``` Congratulations! You have fixed resource issues in your Kubernetes file! @@ -293,17 +277,16 @@ I think KubeLinter's best part is that each error message includes documentation via: https://opensource.com/article/21/1/kubelinter 作者:[Jessica Cherry][a] -选题:[lujun9972][b] +选题:[lkxed][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/cherrybomb -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/mistake_bug_fix_find_error.png?itok=PZaz3dga (magnifying glass on computer screen, finding a bug in the code) +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/mistake_bug_fix_find_error.png [2]: https://github.com/stackrox/kube-linter [3]: https://knative.dev/ -[4]: mailto:git@github.com -[5]: https://opensource.com/article/20/6/homebrew-linux -[6]: https://opensource.com/article/20/11/knative +[4]: https://opensource.com/article/20/6/homebrew-linux +[5]: https://opensource.com/article/20/11/knative diff --git a/sources/tech/20210120 Highlighted Text Not Visible in gedit in Dark Mode- Here-s What You Can Do.md b/sources/tech/20210120 Highlighted Text Not Visible in gedit in Dark Mode- Here-s What You Can Do.md deleted file mode 100644 index a037e8b060..0000000000 --- a/sources/tech/20210120 Highlighted Text Not Visible in gedit in Dark Mode- Here-s What You Can Do.md +++ /dev/null @@ -1,84 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Highlighted Text Not Visible in gedit in Dark Mode? Here’s What You Can Do) -[#]: via: (https://itsfoss.com/gedit-dark-mode-problem/) -[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) - -Highlighted Text Not Visible in gedit in Dark Mode? Here’s What You Can Do -====== - -I love [using dark mode in Ubuntu][1]. It’s soothing on the eyes and makes the system look aesthetically more pleasing, in my opinion. - -One minor annoyance I noticed is with [gedit][2] text editor and if you use it with the dark mode in your system, you might have encountered it too. - -By default, gedit highlights the line where your cursor is. That’s a useful feature but it becomes a pain if you are using dark mode in your Linux system. Why? Because the highlighted text is not readable anymore. Have a look at it yourself: - -![Text on the highlighted line is hardly visible][3] - -If you select the text, it becomes readable but it’s not really a pleasant reading or editing experience. - -![Selecting the text makes it better but that’s not a convenient thing to do for all lines][4] - -The good thing is that you don’t have to live with it. I’ll show a couple of steps you can take to enjoy dark mode system and gedit together. - -### Making gedit reader-friendly in dark mode - -You basically have two options: - - 1. Disable highlight the current line but then you’ll have to figure out which line you are at. - 2. Change the default color settings but then the colors of the editor will be slightly different, and it won’t switch to light mode automatically if you change the system theme. - - - -It’s a workaround and compromise that you’ll have to make until the gedit or GNOME developers fix the issue. - -#### Option 1: Disable highlighting current line - -When you have gedit opened, click on the hamburger menu and select **Preferences**. - -![Go to Preferences][5] - -In the View tab, you should see the “Highlight current line” option under Highlighting section. Uncheck this. The effects are visible immediately. - -![Disable highlighting current line][6] - -Highlighting current line is a usable feature and if you want to continue using it, opt for the second option. - -#### Option 2: Change the editor color theme - -In the Preferences window, go to Font & Colors tab and change the color scheme to Oblivion, Solarized Dark or Cobalt. - -![Change the color scheme][7] - -As I mentioned earlier, the drawback is that when you switch the system theme to a light theme, the editor theme isn’t switched automatically to the light theme. - -### A bug that should be fixed by devs - -There are [several text editors available for Linux][8] but for quick reading or editing a text file, I prefer using gedit. It’s a minor annoyance but an annoyance nonetheless. The developers should fix it in future version of this awesome text editor so that we don’t have to resort to these worarounds. - -How about you? Do you use dark mode on your system or light mode? Had you noticed this trouble with gedit? Did you take any steps to fix it? Feel free to share your experience. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/gedit-dark-mode-problem/ - -作者:[Abhishek Prakash][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/abhishek/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/dark-mode-ubuntu/ -[2]: https://wiki.gnome.org/Apps/Gedit -[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/01/gedit-dark-mode-problem.png?resize=779%2C367&ssl=1 -[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/01/gedit-dark-mode-issue.png?resize=779%2C367&ssl=1 -[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/01/gedit-preference.jpg?resize=777%2C527&ssl=1 -[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/01/disable-highlight-line-gedit.jpg?resize=781%2C530&ssl=1 -[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/01/change-color-scheme-gedit.jpg?resize=785%2C539&ssl=1 -[8]: https://itsfoss.com/best-modern-open-source-code-editors-for-linux/ diff --git a/sources/tech/20210122 Configure a Linux workspace remotely from the command line.md b/sources/tech/20210122 Configure a Linux workspace remotely from the command line.md deleted file mode 100644 index f7118f5ba8..0000000000 --- a/sources/tech/20210122 Configure a Linux workspace remotely from the command line.md +++ /dev/null @@ -1,137 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Configure a Linux workspace remotely from the command line) -[#]: via: (https://opensource.com/article/21/1/remote-configuration-xfce4) -[#]: author: (David Both https://opensource.com/users/dboth) - -Configure a Linux workspace remotely from the command line -====== -Nearly everything can be done from the Linux command line, including -remote configuration of Xfce4. -![Coding on a computer][1] - -One of the things I appreciate about Linux versus proprietary operating systems is that almost everything can be managed and configured from the command line. That means that nearly everything can be configured locally or even remotely via an SSH login connection. Sometimes it takes a bit of time spent on Internet searches, but if you can think of a task, it can probably be done from the command line. - -### The problem - -Sometimes it is necessary to make remote modifications to a desktop using the command line. In this particular case, I needed to reduce the number of workspaces on the [Xfce][2] panel from four to three at the request of a remote user. This configuration only required about 20 minutes of searching on the Internet. - -The default workspace count and many other settings for **xfwm4** can be found and changed in the **/usr/share/xfwm4/defaults** file. So setting _workspace_count=4_ to _workspace_count=2_ changes the default for all users on the host. Also, the **xfconf-query** command can be run by non-root users to query and set various attributes for the **xfwm4** window manager. It should be used by the user account that requires the change and not by root. - -In the sample below, I have first verified the current setting of _four_ workspaces, then set the number to _two_, and finally confirmed the new setting. - - -``` -[user@test1 ~]# xfconf-query -c xfwm4 -p /general/workspace_count -4 -[user@test1 ~]# xfconf-query -c xfwm4 -p /general/workspace_count -s 2 -[user@test1 ~]# xfconf-query -c xfwm4 -p /general/workspace_count -2 -[user@test1 ~]# -``` - -This change takes place immediately and is visible to the user without a reboot or even logging out and back in. I had a bit of fun with this on my workstation by watching the workspace switcher change as I entered commands to set different numbers of workspaces. I get my amusements where I can these days. ;-) - -### More exploration - -Now that I fixed the problem, I decided to explore the **xfconf-query** command in a bit more detail. Unfortunately, there are no man or info pages for this tool, nor is there any documentation in **/usr/share**. The usual fallback of using the **-h** option resulted in little helpful information. - - -``` -$ xfconf-query -h - Usage: -   xfconf-query [OPTION…] - Xfconf commandline utility - Help Options: -   -h, --help            Show help options - Application Options: -   -V, --version         Version information -   -c, --channel         The channel to query/modify -   -p, --property        The property to query/modify -   -s, --set             The new value to set for the property -   -l, --list            List properties (or channels if -c is not specified) -   -v, --verbose         Verbose output -   -n, --create          Create a new property if it does not already exist -   -t, --type            Specify the property value type -   -r, --reset           Reset property -   -R, --recursive       Recursive (use with -r) -   -a, --force-array     Force array even if only one element -   -T, --toggle          Invert an existing boolean property -   -m, --monitor         Monitor a channel for property changes -``` - -This is not a lot of help, but we can figure out a good bit from it anyway. First, _channels_ are groupings of properties that can be modified. I made the change above to the **general** channel, and the property is **workspace_count**. Let’s look at the complete list of channels. - - -``` -$ xfconf-query -l -Channels: -  xfwm4 -  xfce4-keyboard-shortcuts -  xfce4-notifyd -  xsettings -  xfdashboard -  thunar -  parole -  xfce4-panel -  xfce4-appfinder -  xfce4-settings-editor -  xfce4-power-manager -  xfce4-session -  keyboards -  displays -  keyboard-layout -  ristretto -  xfcethemer -  xfce4-desktop -  pointers -  xfce4-settings-manager -  xfce4-mixer -``` - -The properties for a given channel can also be viewed using the following syntax. I have used the **less** pager because the result is a long stream of data. I have pruned the listing below but left enough to see the type of entries you can expect to find. - - -``` -$ xfconf-query -c xfwm4 -l | less -/general/activate_action -/general/borderless_maximize -/general/box_move -/general/box_resize -/general/button_layout -/general/button_offset -<SNIP> -/general/workspace_count -/general/workspace_names -/general/wrap_cycle -/general/wrap_layout -/general/wrap_resistance -/general/wrap_windows -/general/wrap_workspaces -/general/zoom_desktop -(END) -``` - -You can explore all the channels in this manner. I discovered that the channels generally correspond to the various settings in the **Settings Manager**. The properties are the ones that you would set in those dialogs. Note that not all the icons you will find in the **Settings Manager** dialog window are part of the **Xfce** desktop, so there are no corresponding channels for them. The **Screensaver** is one example because it is a generic GNU screensaver and not unique to **Xfce**. The **Settings Manager** is just a good central place for **Xfce** to locate many of these configuration tools. - -### Documentation - -As mentioned previously, there do not appear to be any man or info pages for the **xconf-query** command, and I found a lot of incorrect and poorly documented information on the Internet. The best documentation I found for **Xfce4** is on the [Xfce website][2], and some specific information on **xconf-query** can be found here. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/1/remote-configuration-xfce4 - -作者:[David Both][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/dboth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) -[2]: https://www.xfce.org/ diff --git a/sources/tech/20210123 How I programmed a virtual gift exchange.md b/sources/tech/20210123 How I programmed a virtual gift exchange.md index 446c1b50c2..a633e69e0c 100644 --- a/sources/tech/20210123 How I programmed a virtual gift exchange.md +++ b/sources/tech/20210123 How I programmed a virtual gift exchange.md @@ -1,40 +1,40 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How I programmed a virtual gift exchange) -[#]: via: (https://opensource.com/article/21/1/open-source-gift-exchange) -[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen) +[#]: subject: "How I programmed a virtual gift exchange" +[#]: via: "https://opensource.com/article/21/1/open-source-gift-exchange" +[#]: author: "Chris Hermansen https://opensource.com/users/clhermansen" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " How I programmed a virtual gift exchange ====== -A book club takes its annual gift exchange online with the help of HTML, -CSS, and JavaScript. +A book club takes its annual gift exchange online with the help of HTML, CSS, and JavaScript. + ![Package wrapped with brown paper and red bow][1] +Image by: Photo by [Jess Bailey][2] on [Unsplash][3] + Every year, my wife's book club has a book exchange during the holidays. Due to the need to maintain physical distance in 2020, I created an online gift exchange for them to use during a book club videoconference. Apparently, the virtual book exchange worked out (at least, I received kind compliments from the book club members), so I decided to share this simple little hack. ### How the book exchange usually works In past years, the exchange has gone something like this: - 1. Each person buys a book and wraps it up. - 2. Everyone arrives at the host's home and puts the wrapped books in a pile. - 3. Each person draws a number out of a hat, which establishes their turn. - 4. The person who drew No. 1 selects a book from the pile and unwraps it. In turn, each subsequent person chooses to either take a wrapped book from the pile or to steal an unwrapped book from someone who has gone before. - 5. When someone's book is stolen, they can either replace it with a wrapped book from the pile or steal another book (but not the one that was stolen from them) from someone else. - 6. And so on… eventually, someone has to take the last unwrapped book to end the exchange. - - +1. Each person buys a book and wraps it up. +2. Everyone arrives at the host's home and puts the wrapped books in a pile. +3. Each person draws a number out of a hat, which establishes their turn. +4. The person who drew No. 1 selects a book from the pile and unwraps it. In turn, each subsequent person chooses to either take a wrapped book from the pile or to steal an unwrapped book from someone who has gone before. +5. When someone's book is stolen, they can either replace it with a wrapped book from the pile or steal another book (but not the one that was stolen from them) from someone else. +6. And so on… eventually, someone has to take the last unwrapped book to end the exchange. ### Designing the virtual book exchange My first decision was which implementation platform to use for the book exchange. Because there would already be a browser open to host the videoconference, I decided to use HTML, CSS, and JavaScript. -Then it was design time. After some thinking, I decided to use rectangles to represent the book club members and the books. The books would be draggable, and when one was dropped on a member's rectangle, the book would unwrap (and stay unwrapped). I needed some "wrapping paper," so I used this source of [free-to-use images][2]. +Then it was design time. After some thinking, I decided to use rectangles to represent the book club members and the books. The books would be draggable, and when one was dropped on a member's rectangle, the book would unwrap (and stay unwrapped). I needed some "wrapping paper," so I used this source of [free-to-use images][4]. -I took screenshots of the patterns I liked and used [GIMP][3] to scale the images to the right width and height. +I took screenshots of the patterns I liked and used [GIMP][5] to scale the images to the right width and height. I needed a way to handle draggable and droppable interactions; given that I've been using jQuery and jQuery UI for several years now, I decided to continue along that path. @@ -42,25 +42,19 @@ For a while, I struggled with what a droppable element should do when something Jumping to the results, here's a screenshot of the user interface at the beginning of the exchange: -![Virtual book exchange][4] - -(Chris Hermansen, [CC BY-SA 4.0][5]) +![Virtual book exchange][6] There are nine book club members: Wanda, Carlos, Bill, and so on. There are also nine fairly ugly wrapped parcels. Let's say Wanda goes first and chooses the flower wrapping paper. The host clicks and drags that parcel to Wanda's name, and the parcel unwraps: -![Virtual book exchange][6] - -(Chris Hermansen, [CC BY-SA 4.0][5]) +![Virtual book exchange][7] Whoops! That title and author are a bit too long to fit on the book's "cover." Oh well, I'll fix that in the next version. Carlos is next. He decides he really wants to read that book, so he steals it. Wanda then chooses the paisley pattern, and the screen looks like this: -![Virtual book exchange][7] - -(Chris Hermansen, [CC BY-SA 4.0][5]) +![Virtual book exchange][8] And so on until the exchange ends. @@ -68,120 +62,117 @@ And so on until the exchange ends. So what about the code? Here it is: - ``` -     1  <!doctype html> -     2  <[html][8] lang="en"> -     3  <[head][9]> -     4    <[meta][10] charset="utf-8"> -     5    <[title][11]>Book Exchange</[title][11]> -     6    <[link][12] rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css"> -     7    <[style][13]> -     8    .draggable { -     9      float: left; -    10      width: 90px; -    11      height: 90px; -    12      background: #ccc; -    13      padding: 5px; -    14      margin: 5px 5px 5px 0; -    15    } -    16    .droppable { -    17      float: left; -    18      width: 100px; -    19      height: 125px; -    20      background: #999; -    21      color: #fff; -    22      padding: 10px; -    23      margin: 10px 10px 10px 0; -    24    } -    25    </[style][13]> -    26    <[script][14] src="[https://code.jquery.com/jquery-1.12.4.js"\>\][15]</[script][14]> -    27    <[script][14] src="[https://code.jquery.com/ui/1.12.1/jquery-ui.js"\>\][16]</[script][14]> -    28  </[head][9]> -    29  <[body][17]> -    30  <[h1][18] style="color:#1a1aff;">Raffles Book Club Remote Gift Exchange</[h1][18]> -    31  <[h2][19] style="color:#aa0a0a;">The players, in random order, and the luxurious gifts, wrapped:</[h2][19]> -    32    -    33  <[div][20]> -    34  <[div][20] id="wanda" class="droppable">Wanda</[div][20]> -    35  <[div][20] id="carlos" class="droppable">Carlos</[div][20]> -    36  <[div][20] id="bill" class="droppable">Bill</[div][20]> -    37  <[div][20] id="arlette" class="droppable">Arlette</[div][20]> -    38  <[div][20] id="joanne" class="droppable">Joanne</[div][20]> -    39  <[div][20] id="aleks" class="droppable">Alekx</[div][20]> -    40  <[div][20] id="ermintrude" class="droppable">Ermintrude</[div][20]> -    41  <[div][20] id="walter" class="droppable">Walter</[div][20]> -    42  <[div][20] id="hilary" class="droppable">Hilary</[div][20]> -    43  </[div][20]> -    44  <[div][20]> -    45  <[div][20] id="bows" class="draggable" style="background-image: url('bows.png');"></[div][20]> -    46  <[div][20] id="boxes" class="draggable" style="background-image: url('boxes.png');"></[div][20]> -    47  <[div][20] id="circles" class="draggable" style="background-image: url('circles.png');"></[div][20]> -    48  <[div][20] id="gerbers" class="draggable" style="background-image: url('gerbers.png');"></[div][20]> -    49  <[div][20] id="hippie" class="draggable" style="background-image: url('hippie.png');"></[div][20]> -    50  <[div][20] id="lattice" class="draggable" style="background-image: url('lattice.png');"></[div][20]> -    51  <[div][20] id="nautical" class="draggable" style="background-image: url('nautical.png');"></[div][20]> -    52  <[div][20] id="splodges" class="draggable" style="background-image: url('splodges.png');"></[div][20]> -    53  <[div][20] id="ugly" class="draggable" style="background-image: url('ugly.png');"></[div][20]> -    54  </[div][20]> -    55    -    56  <[script][14]> -    57  var books = { -    58      'bows': 'Untamed by Glennon Doyle', -    59      'boxes': "The Heart's Invisible Furies by John Boyne", -    60      'circles': 'The Great Halifax Explosion by John Bacon', -    61      'gerbers': 'Homes: A Refugee Story by Abu Bakr al Rabeeah, Winnie Yeung', -    62      'hippie': 'Before We Were Yours by Lisa Wingate', -    63      'lattice': "Hamnet and Judith by Maggie O'Farrell", -    64      'nautical': 'Shuggy Bain by Douglas Stewart', -    65      'splodges': 'Magdalena by Wade Davis', -    66      'ugly': 'Funny Boy by Shyam Selvadurai' -    67  }; -    68  $( ".droppable" ).droppable({ -    69    drop: function(event, ui) { -    70      var element = $(ui.draggable[0]); -    71      var wrapping = element.attr('id'); -    72      /* alert( $(this).text() + " got " + wrapping); */ -    73      $(ui.draggable[0]).css("background-image","url(book_cover.png)"); -    74      $(ui.draggable[0]).text(books[wrapping]); -    75    }, -    76    out: function() { -    77      /* alert( $(this).text() + " lost it" ); */ -    78    } -    79  }); -    80  $( ".draggable" ).draggable(); -    81  </[script][14]> -    82    -    83  </[body][17]> -    84  </[html][8]> +1  +2  +3  +4    +5    Book Exchange +6    +7    +26    +27    +28  +29  +30 

Raffles Book Club Remote Gift Exchange

+31 

The players, in random order, and the luxurious gifts, wrapped:

+32    +33 
+34 
Wanda
+35 
Carlos
+36 
Bill
+37 
Arlette
+38 
Joanne
+39 
Alekx
+40 
Ermintrude
+41 
Walter
+42 
Hilary
+43 
+44 
+45 
+46 
+47 
+48 
+49 
+50 
+51 
+52 
+53 
+54 
+55    +56  +82    +83  +84  ``` ### Breaking it down Let's go over this code bit by bit. - * **Lines 1–6:** Upfront, I have the usual HTML boilerplate, `HTML`, `HEAD`, `META`, `TITLE` elements, followed by a link to the CSS for jQuery UI. - * **Lines 7–25:** I added two new style classes: `draggable` and `droppable`. These define the layout for the books (draggable) and the people (droppable). Note that, aside from defining the size, background color, padding, and margin, I established that these need to float left. This way, the layout adjusts to the browser window width in a reasonably acceptable form. - * **Line 26–27:** With the CSS out of the way, it's time for the JavaScript libraries, first jQuery, then jQuery UI. - * **Lines 29–83:** Now that the `HEAD` element is done, next is the `BODY`: - * **Lines 30–31:** These couple of titles, `H1` and `H2`, let people know what they're doing here. - * **Lines 33–43:** A `DIV` to contain the people: - * **Lines 34–42:** The people are defined as droppable `DIV` elements and given `ID` fields corresponding to their names. - * **Lines 44–54:** A `DIV` to contain the books: - * **Lines 45–53:** The books are defined as draggable `DIV` elements. Each element is declared with a background image corresponding to the wrapping paper with no text between the `
` and `
`. The `ID` fields correspond to the wrapping paper. - * **Lines 56–81:** These contain JavaScript to make it all work. - * **Lines 57–67:** This JavaScript object contains the book definitions. The keys (`'bows'`, `'boxes'`, etc.) correspond to the `ID` fields of the book `DIV` elements. The values (`'Untamed by Glennon Doyle',` `"The Heart's Invisible Furies by John Boyne"`, etc.) are the book titles and authors. - * **Lines 68–79:** This JavaScript jQuery UI function defines the droppable functionality to be attached to HTML elements whose class is `droppable`. - * **Lines 69–75:** When a `draggable` element is dropped onto a `droppable` element, the function `drop` is called. - * **Line 70:** The `element` variable is assigned the draggable object that was dropped (this will be a `
` element. - * **Line 71:** The `wrapping` variable is assigned the value of the `ID` field in the draggable object. - * **Line 72:** This line is commented out, but while I was learning and testing, calls to `alert()` were useful. - * **Line 73:** This reassigns the draggable object's background image to a bland image on which text can be read; part 1 of unwrapping is getting rid of the wrapping paper. - * **Line 74:** This sets the text of the draggable object to the title of the book, looked up in the book's object using the draggable object's ID; part 2 of the unwrapping is showing the book title and author. - * **Lines 76–78:** For a while, I thought I wanted something to happen when a draggable object was removed from a droppable object (e.g., when a club member stole a book), which would require using the `out` function in a droppable object. Eventually, I decided not to do anything. But, this could note that the book was stolen and make it "unstealable" for one turn; or it could show a status line that says something like: _"Wanda's book Blah Blah by Joe Blogs was stolen, and she needs to choose another."_ - * **Line 80:** This JavaScript jQuery UI function defines the draggable functionality to be attached to HTML elements whose class is `draggable`. In my case, the default behavior was all I needed. - - +* Lines 1–6: Upfront, I have the usual `HTML` boilerplate, HTML, `HEAD`, `META`, `TITLE` elements, followed by a link to the CSS for jQuery UI. +* Lines 7–25: I added two new style classes: `draggable` and `droppable`. These define the layout for the books (draggable) and the people (droppable). Note that, aside from defining the size, background color, padding, and margin, I established that these need to float left. This way, the layout adjusts to the browser window width in a reasonably acceptable form. +* Line 26–27: With the CSS out of the way, it's time for the JavaScript libraries, first jQuery, then jQuery UI. +* Lines 29–83: Now that the `HEAD` `element` is done, next is the `BODY`: + * Lines 30–31: These couple of titles, `H1` and `H2`, let people know what they're doing here. +Lines 33–43: A `DIV` to contain the people: +Lines 34–42: The people are defined as `droppable` `DIV` elements and given `ID` fields corresponding to their names. +Lines 44–54: A `DIV` to contain the books: +Lines 45–53: The books are defined as `draggable` `DIV` elements. Each element is declared with a background image corresponding to the `wrapping` paper with no text between the `
` and `
`. The `ID` fields correspond to the wrapping paper. +Lines 56–81: These contain JavaScript to make it all work. + * Lines 57–67: This JavaScript object contains the book definitions. The keys ('bows', `'boxes'`, etc.) correspond to the `ID` fields of the book `DIV` elements. The values ('Untamed by Glennon Doyle', `"The Heart's Invisible Furies by John Boyne"`, etc.) are the book titles and authors. +Lines 68–79: This JavaScript jQuery UI function defines the `droppable` functionality to be attached to HTML elements whose class is `drop`pable. +Lines 69–75: When a `draggable` element is dropped onto a droppable element, the function drop is called. +Line 70: The element variable is assigned the draggable object that was dropped (this will be a `
` element. +Line 71: The wrapping variable is assigned the value of the `ID` field in the draggable object. +Line 72: This line is commented `out`, but while I was learning and testing, calls to `alert()` were useful. + * Line 73: This reassigns the draggable object's background image to a bland image on which text can be read; part 1 of unwrapping is getting rid of the wrapping paper. + * Line 74: This sets the text of the draggable object to the title of the book, looked up in the book's object using the draggable object's ID; part 2 of the unwrapping is showing the book title and author. +Lines 76–78: For a while, I thought I wanted something to happen when a draggable object was removed from a droppable object (e.g., when a club member stole a book), which would require using the out function in a droppable object. Eventually, I decided not to do anything. But, this could note that the book was stolen and make it "unstealable" for one turn; or it could show a status line that says something like: "Wanda's book Blah Blah by Joe Blogs was stolen, and she needs to choose another." +Line 80: This JavaScript jQuery UI function defines the draggable functionality to be attached to HTML elements whose class is draggable. In my case, the default behavior was all I needed. That's it! @@ -189,49 +180,38 @@ That's it! Libraries like jQuery and jQuery UI are incredibly helpful when trying to do something complicated in JavaScript. Look at the `$().draggable()` and `$().droppable()` functions, for example: - ``` -`$( ".draggable" ).draggable();` +$( ".draggable" ).draggable(); ``` The `".draggable"` allows associating the `draggable()` function with any HTML element whose class is "draggable." The `draggable()` function comes with all sorts of useful behavior about picking, dragging, and releasing a draggable HTML element. -If you haven't spent much time with jQuery, I really like the book [_jQuery in Action_][21] by Bear Bibeault, Yehuda Katz, and Aurelio De Rosa. Similarly, [_jQuery UI in Action_][22] by TJ VanToll is a great help with the jQuery UI (where draggable and droppable come from). +If you haven't spent much time with jQuery, I really like the book [jQuery in Action][9] by Bear Bibeault, Yehuda Katz, and Aurelio De Rosa. Similarly, [jQuery UI in Action][10] by TJ VanToll is a great help with the jQuery UI (where draggable and droppable come from). Of course, there are many other JavaScript libraries, frameworks, and what-nots around to do good stuff in the user interface. I haven't really started to explore all that jQuery and jQuery UI offer, and I want to play around with the rest to see what can be done. +Image by: (Chris Hermansen, CC BY-SA 4.0) + -------------------------------------------------------------------------------- via: https://opensource.com/article/21/1/open-source-gift-exchange 作者:[Chris Hermansen][a] -选题:[lujun9972][b] +选题:[lkxed][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/clhermansen -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brown-package-red-bow.jpg?itok=oxZYQzH- (Package wrapped with brown paper and red bow) -[2]: https://all-free-download.com/free-vector/patterns-creative-commons.html#google_vignette -[3]: https://opensource.com/tags/gimp -[4]: https://opensource.com/sites/default/files/uploads/bookexchangestart.png (Virtual book exchange) -[5]: https://creativecommons.org/licenses/by-sa/4.0/ -[6]: https://opensource.com/sites/default/files/uploads/bookexchangeperson1.png (Virtual book exchange) -[7]: https://opensource.com/sites/default/files/uploads/bookexchangeperson2.png (Virtual book exchange) -[8]: http://december.com/html/4/element/html.html -[9]: http://december.com/html/4/element/head.html -[10]: http://december.com/html/4/element/meta.html -[11]: http://december.com/html/4/element/title.html -[12]: http://december.com/html/4/element/link.html -[13]: http://december.com/html/4/element/style.html -[14]: http://december.com/html/4/element/script.html -[15]: https://code.jquery.com/jquery-1.12.4.js"\>\ -[16]: https://code.jquery.com/ui/1.12.1/jquery-ui.js"\>\ -[17]: http://december.com/html/4/element/body.html -[18]: http://december.com/html/4/element/h1.html -[19]: http://december.com/html/4/element/h2.html -[20]: http://december.com/html/4/element/div.html -[21]: https://www.manning.com/books/jquery-in-action-third-edition -[22]: https://www.manning.com/books/jquery-ui-in-action +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/brown-package-red-bow.jpg +[2]: https://unsplash.com/@jessbaileydesigns?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]: https://unsplash.com/s/photos/package?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: https://all-free-download.com/free-vector/patterns-creative-commons.html#google_vignette +[5]: https://opensource.com/tags/gimp +[6]: https://opensource.com/sites/default/files/uploads/bookexchangestart.png +[7]: https://opensource.com/sites/default/files/uploads/bookexchangeperson1.png +[8]: https://opensource.com/sites/default/files/uploads/bookexchangeperson2.png +[9]: https://www.manning.com/books/jquery-in-action-third-edition +[10]: https://www.manning.com/books/jquery-ui-in-action diff --git a/sources/tech/20210124 3 stress-free steps to tackling your task list.md b/sources/tech/20210124 3 stress-free steps to tackling your task list.md deleted file mode 100644 index 04e65e4b06..0000000000 --- a/sources/tech/20210124 3 stress-free steps to tackling your task list.md +++ /dev/null @@ -1,70 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (3 stress-free steps to tackling your task list) -[#]: via: (https://opensource.com/article/21/1/break-down-tasks) -[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) - -3 stress-free steps to tackling your task list -====== -Break your larger tasks into small steps to keep from being overwhelmed. -![Team checklist][1] - -In prior years, this annual series covered individual apps. This year, we are looking at all-in-one solutions in addition to strategies to help in 2021. Welcome to day 14 of 21 Days of Productivity in 2021. - -At the start of the week, I like to review my schedule and look at the things I either need or would like to accomplish. And often, there are some items on that list that are relatively big. Whether it is an issue for work, a series of articles on productivity, or maybe an improvement to the chicken enclosures, the task can seem really daunting when taken as a single job. The odds are good that I will not be able to sit down and finish something like (just as an example, mind you) 21 articles in a single block of time, or even a single day. - -![21 Days of Productivity project screenshot][2] - -21 Days of Productivity (Kevin Sonney, [CC BY-SA 4.0][3]) - -So the first thing I do when I have something like this on my list is to break it down into smaller pieces. As Nobel laureate [William Faulkner][4] famously said, "The man who removes a mountain begins by carrying away small stones." We need to take our big tasks (the mountain) and find the individual steps (the small stones) that need to be done. - -I use the following steps to break down my big tasks into little ones: - - 1. I usually have a fair idea of what needs to be done to complete a task. If not, I do a little research to figure that out. - 2. I write down the steps I think it will take, in order. - 3. Finally, I sit down with my calendar and the list and start to spread the tasks out across several days (or weeks, or months) to get an idea of when I might finish it. - - - -Now I have not only a plan but an idea of how long it is going to take. As I complete each step, I can see that big task get not only a little smaller but closer to completion. - -There is an old military saying that goes, "No plan survives contact with the enemy." It is almost certain that there will be a point or two (or five) where I realize that something as simple as "take a screenshot" needs to be expanded into something _much_ more complex. In fact, taking the screenshots of [Easy!Appointments][5] turned out to be: - - 1. Install and configure Easy!Appointments. - 2. Install and configure the Easy!Appointments WordPress plugin. - 3. Generate the API keys needed to sync the calendar. - 4. Take screenshots. - - - -Even then, I had to break these tasks down into smaller pieces—download the software, configure NGINX, validate the installs…you get the idea. And that's OK. A plan, or set of tasks, is not set in stone and can be changed as needed. - -![project completion pie chart][6] - -About 2/3 done for this year! (Kevin Sonney, [CC BY-SA 4.0][3]) - -This is a learned skill and will take some effort the first few times. Learning how to break big tasks into smaller steps allows you to track progress towards a goal or completion of something big without getting overwhelmed in the process. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/1/break-down-tasks - -作者:[Kevin Sonney][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/ksonney -[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://opensource.com/sites/default/files/day14-image1.png -[3]: https://creativecommons.org/licenses/by-sa/4.0/ -[4]: https://en.wikipedia.org/wiki/William_Faulkner -[5]: https://opensource.com/article/21/1/open-source-scheduler -[6]: https://opensource.com/sites/default/files/day14-image2_1.png diff --git a/sources/tech/20210127 Introduction to Thunderbird mail filters.md b/sources/tech/20210127 Introduction to Thunderbird mail filters.md index 423d48f86d..808a22f084 100644 --- a/sources/tech/20210127 Introduction to Thunderbird mail filters.md +++ b/sources/tech/20210127 Introduction to Thunderbird mail filters.md @@ -1,164 +1,151 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Introduction to Thunderbird mail filters) -[#]: via: (https://fedoramagazine.org/introduction-to-thunderbird-mail-filters/) -[#]: author: (Richard England https://fedoramagazine.org/author/rlengland/) +[#]: subject: "Introduction to Thunderbird mail filters" +[#]: via: "https://fedoramagazine.org/introduction-to-thunderbird-mail-filters/" +[#]: author: "Richard England https://fedoramagazine.org/author/rlengland/" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " Introduction to Thunderbird mail filters ====== - ![][1] Everyone eventually runs into an inbox loaded with messages that they need to sort through. If you are like a lot of people, this is not a fast process. However, use of mail filters can make the task a little less tedious by letting Thunderbird pre-sort the messages into categories that reflect their source, priority, or usefulness. This article is an introduction to the creation of filters in Thunderbird. Filters may be created for each email account you have created in Thunderbird. These are the accounts you see in the main Thunderbird folder pane shown at the left of the “Classic Layout”. -![Classic Layout][2] +![][2] There are two methods that can be used to create mail filters for your accounts. The first is based on the currently selected account and the second on the currently selected message. Both are discussed here. ### Message destination folder -Before filtering messages there has to be a destination for them. Create the destination by selecting a location to create a new folder. In this example the destination will be **Local Folders** shown in the accounts pane. Right click on **Local Folders** and select _New Folder…_ from the menu. +Before filtering messages there has to be a destination for them. Create the destination by selecting a location to create a new folder. In this example the destination will be **Local Folders**shown in the accounts pane. Right click on **Local Folders** and select *New Folder…* from the menu. -![Creating a new folder][3] +![][3] -Enter the name of the new folder in the menu and select _Create Folder._ The mail to filter is coming from the New York Times so that is the name entered. +Enter the name of the new folder in the menu and select *Create Folder.* The mail to filter is coming from the New York Times so that is the name entered. -![Folder creation][4] +![][4] ### Filter creation based on the selected account -Select the _Inbox_ for the account you wish to filter and select the toolbar menu item at _Tools > Message_Filters_. +Select the *Inbox* for the account you wish to filter and select the toolbar menu item at *Tools > Message_Filters*. -![Message_Filters menu location][5] +![][5] -The _Message Filters_ menu appears and is set to your pre-selected account as indicated at the top in the selection menu labelled _Filters for:_. +The *Message Filters* menu appears and is set to your pre-selected account as indicated at the top in the selection menu labelled *Filters for:*. -![Message Filters menu][6] +![][6] -Previously created filters, if any, are listed beneath the account name in the “_Filter Name”_ column. To the right of this list are controls that let you modify the filters selected. These controls are activated when you select a filter. More on this later. +Previously created filters, if any, are listed beneath the account name in the “*Filter Name”*column. To the right of this list are controls that let you modify the filters selected. These controls are activated when you select a filter. More on this later. Start creating your filter as follows: - 1. Verify the correct account has been pre-selected. It may be changed if necessary. - 2. Select _New…_ from the menu list at the right. +1. Verify the correct account has been pre-selected. It may be changed if necessary. +2. Select New… from the menu list at the right. - - -When you select _New_ you will see the _Filter Rules_ menu where you define your filter. Note that when using _New…_ you have the option to copy an existing filter to use as a template or to simply duplicate the settings. +When you select *New* you will see the *Filter Rules*menu where you define your filter. Note that when using *New…* you have the option to copy an existing filter to use as a template or to simply duplicate the settings. Filter rules are made up of three things, the “property” to be tested, the “test”, and the “value” to be tested against. Once the condition is met, the “action” is performed. -![Message Filters menu][7] +![][7] Complete this filter as follows: - 1. Enter an appropriate name in the textbox labelled _Filter name:_ - 2. Select the property _From_ in the left drop down menu, if not set. - 3. Leave the test set to _contains_. - 4. Enter the value, in this case the email address of the sender. +1. Enter an appropriate name in the textbox labelled Filter name: +2. Select the property From in the left drop down menu, if not set. +3. Leave the test set to contains. +4. Enter the value, in this case the email address of the sender. +Under the *Perform these actions:* section at the bottom, create an action rule to move the message and choose the destination. +1. Select Move Messages to from the left end of the action line. +2. Select Choose Folder… and select Local Folders > New York Times. +3. Select OK. -Under the _Perform these actions:_ section at the bottom, create an action rule to move the message and choose the destination. +By default the **Apply filter when:** is set to *Manually Run* and *Getting New Mail:*. This means that when new mail appears in the Inbox for this account the filter will be applied and you may run it manually at any time, if necessary. There are other options available but they are too numerous to be discussed in this introduction. They are, however, for the most part self explanatory. - 1. Select _Move Messages to_ from the left end of the action line. - 2. Select _Choose Folder…_ and select _Local Folders > New York Times_. - 3. Select _OK_. +If more than one rule or action is to be created during the same session, the “+” to the right of each entry provides that option. Additional property, test, and value entries can be added. If more than one rule is created, make certain that the appropriate option for *Match all of the following* and *Match any of the following* is selected. In this example the choice does not matter since we are only setting one filter. +After selecting *OK,*the *Message Filters* menu is displayed again showing your newly created filter. Note that the menu items on the right side of the menu are now active for *Edit…* and *Delete.* +![][8] -By default the **Apply filter when:** is set to _Manually Run_ and _Getting New Mail:_. This means that when new mail appears in the Inbox for this account the filter will be applied and you may run it manually at any time, if necessary. There are other options available but they are too numerous to be discussed in this introduction. They are, however, for the most part self explanatory. +Also notice the message *“Enabled filters are run automatically in the order shown below”*. If there are multiple filters the order is changed by selecting the one to be moved and using the *Move to Top, Move Up, Move Down,*or*Move to Bottom* buttons. The order can change the destination of your messages so consider the tests used in each filter carefully when deciding the order. -If more than one rule or action is to be created during the same session, the “+” to the right of each entry provides that option. Additional property, test, and value entries can be added. If more than one rule is created, make certain that the appropriate option for _Match all of the following_ and _Match any of the following_ is selected. In this example the choice does not matter since we are only setting one filter. - -After selecting _OK,_ the _Message Filters_ menu is displayed again showing your newly created filter. Note that the menu items on the right side of the menu are now active for _Edit…_ and _Delete._ - -![First filter in the Message Filters menu][8] - -Also notice the message _“Enabled filters are run automatically in the order shown below”_. If there are multiple filters the order is changed by selecting the one to be moved and using the _Move to Top, Move Up, Move Down,_ or _Move to Bottom_ buttons. The order can change the destination of your messages so consider the tests used in each filter carefully when deciding the order. - -Since you have just created this filter you may wish to use the _Run Now_ button to run your newly created filter on the Inbox shown to the left of the button. +Since you have just created this filter you may wish to use the *Run Now* button to run your newly created filter on the Inbox shown to the left of the button. ### Filter creation based on a message -An alternative creation technique is to select a message from the message pane and use the _Create Filter From Message…_ option from the menu bar. +An alternative creation technique is to select a message from the message pane and use the *Create Filter From Message…* option from the menu bar. -In this example the filter will use two rules to select the messages: the email address and a text string in the Subject line of the email. Start as follows: +In this example the filter will use two rules to select the messages: the email address and a text string in the Subject line of the email. Start as follows: - 1. Select a message in the message page. - 2. Select the filter options on the toolbar at _Message > Create Filter From Message…_. +1. Select a message in the message page. +2. Select the filter options on the toolbar at Message > Create Filter From Message…. +![][9] - -![Create new filters from Messages][9] - -The pre-selected message, highlighted in grey in the message pane above, determines the account used and _Create Filter From Message…_ takes you directly to the _Filter Rules_ menu. +The pre-selected message, highlighted in grey in the message pane above, determines the account used and *Create Filter From Message…* takes you directly to the *Filter Rules* menu. ![][10] -The property (_From_), test (_is_), and value (email) are pre-set for you as shown in the image above. Complete this filter as follows: +The property (*From*), test (*is*), and value (email) are pre-set for you as shown in the image above. Complete this filter as follows: - 1. Enter an appropriate name in the textbox labelled _Filter name:_. _COVID_ is the name in this case. - 2. Check that the property is _From_. - 3. Verify the test is set to _is_. - 4. Confirm that the value for the email address is from the correct sender. - 5. Select the “+” to the right of the _From_ rule to create a new filter rule. - 6. In the new rule, change the default property entry _From_ to _Subject_ using the pulldown menu. - 7. Set the test to _contains_. - 8. Enter the value text to be matched in the Email “Subject” line. In this case _COVID_. +1. Enter an appropriate name in the textbox labelled Filter name:. COVID is the name in this case. +2. Check that the property is From. +3. Verify the test is set to is. +4. Confirm that the value for the email address is from the correct sender. +5. Select the “+” to the right of the From rule to create a new filter rule. +6. In the new rule, change the default property entry From to Subject using the pulldown menu. +7. Set the test to contains. +8. Enter the value text to be matched in the Email “Subject” line. In this case COVID. +Since we left the *Match all of the following* item checked, each message will be from the address chosen AND will have the text *COVID* in the email subject line. +Now use the action rule to choose the destination for the messages under the *Perform these actions:* section at the bottom: -Since we left the _Match all of the following_ item checked, each message will be from the address chosen AND will have the text _COVID_ in the email subject line. +1. Select Move Messages to from the left menu. +2. Select Choose Folder… and select Local Folders > COVID in Scotland. (This destination was created before this example was started. There was no magic here.) +3. Select OK. -Now use the action rule to choose the destination for the messages under the _Perform these actions:_ section at the bottom: - - 1. Select _Move Messages to_ from the left menu. - 2. Select _Choose Folder…_ and select _Local Folders > COVID in Scotland_. (This destination was created before this example was started. There was no magic here.) - 3. Select _OK_. - - - -_OK_ will cause the _Message Filters_ menu to appear, again, verifying that the new filter has been created. +*OK* will cause the *Message Filters* menu to appear, again, verifying that the new filter has been created. ### The Message Filters menu -All the message filters you create will appear in the _Message Filters_ menu. Recall that the _Message Filters_ is available in the menu bar at _Tools > Message Filters_. +All the message filters you create will appear in the *Message Filters* menu. Recall that the *Message Filters* is available in the menu bar at *Tools > Message Filters*. -Once you have created filters there are several options to manage them. To change a filter, select the filter in question and click on the _Edit_ button. This will take you back to the _Filter Rules_ menu for that filter. As mentioned earlier, you can change the order in which the rules are apply here using the _Move_ buttons. Disable a filter by clicking on the check mark in the _Enabled_ column. +Once you have created filters there are several options to manage them. To change a filter, select the filter in question and click on the *Edit* button. This will take you back to the *Filter Rules* menu for that filter. As mentioned earlier, you can change the order in which the rules are apply here using the *Move* buttons. Disable a filter by clicking on the check mark in the *Enabled* column. ![][11] -The _Run Now_ button will execute the selected filter immediately. You may also run your filter from the menu bar using _Tools > Run Filters on Folder_ or _Tools > Run Filters on Message_. +The *Run Now* button will execute the selected filter immediately. You may also run your filter from the menu bar using *Tools > Run Filters on Folder* or *Tools > Run Filters on Message*. ### Next step -This article hasn’t covered every feature available for message filtering but hopefully it provides enough information for you to get started. Places for further investigation are the “property”, “test”, and “actions” in the _Filter menu_ as well as the settings there for when your filter is to be run, _Archiving, After Sending,_ and _Periodically_. +This article hasn’t covered every feature available for message filtering but hopefully it provides enough information for you to get started. Places for further investigation are the “property”, “test”, and “actions” in the *Filter menu* as well as the settings there for when your filter is to be run, *Archiving, After Sending,* and *Periodically*. ### References -Mozilla: [Organize][12] [Your Messages][12] [by Using Filters][12] +Mozilla: [Organize][12][Your Messages][13][by Using Filters][14] -MozillaZine: [Message][13] [Filters][13] +MozillaZine: [Message][15][Filters][16] -------------------------------------------------------------------------------- via: https://fedoramagazine.org/introduction-to-thunderbird-mail-filters/ 作者:[Richard England][a] -选题:[lujun9972][b] +选题:[lkxed][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/rlengland/ -[b]: https://github.com/lujun9972 +[b]: https://github.com/lkxed [1]: https://fedoramagazine.org/wp-content/uploads/2021/01/Tbird_mail_filters-1-816x345.jpg [2]: https://fedoramagazine.org/wp-content/uploads/2021/01/Image_001-1024x613.png [3]: https://fedoramagazine.org/wp-content/uploads/2021/01/Image_New_Folder.png @@ -171,4 +158,7 @@ via: https://fedoramagazine.org/introduction-to-thunderbird-mail-filters/ [10]: https://fedoramagazine.org/wp-content/uploads/2021/01/Filter_rules_2-1.png [11]: https://fedoramagazine.org/wp-content/uploads/2021/01/Message_Filters_2nd_entry.png [12]: https://support.mozilla.org/en-US/kb/organize-your-messages-using-filters -[13]: http://kb.mozillazine.org/Filters_%28Thunderbird%29 +[13]: https://support.mozilla.org/en-US/kb/organize-your-messages-using-filters +[14]: https://support.mozilla.org/en-US/kb/organize-your-messages-using-filters +[15]: http://kb.mozillazine.org/Filters_%28Thunderbird%29 +[16]: http://kb.mozillazine.org/Filters_%28Thunderbird%29 diff --git a/sources/tech/20210128 Interview with Shuah Khan, Kernel Maintainer - Linux Fellow.md b/sources/tech/20210128 Interview with Shuah Khan, Kernel Maintainer & Linux Fellow.md similarity index 81% rename from sources/tech/20210128 Interview with Shuah Khan, Kernel Maintainer - Linux Fellow.md rename to sources/tech/20210128 Interview with Shuah Khan, Kernel Maintainer & Linux Fellow.md index 1d22b6f0fb..09152cb53a 100644 --- a/sources/tech/20210128 Interview with Shuah Khan, Kernel Maintainer - Linux Fellow.md +++ b/sources/tech/20210128 Interview with Shuah Khan, Kernel Maintainer & Linux Fellow.md @@ -1,46 +1,43 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Interview with Shuah Khan, Kernel Maintainer & Linux Fellow) -[#]: via: (https://www.linux.com/news/interview-with-shuah-khan-kernel-maintainer-linux-fellow/) -[#]: author: (The Linux Foundation https://www.linuxfoundation.org/en/blog/interview-with-shuah-khan-kernel-maintainer-linux-fellow/) +[#]: subject: "Interview with Shuah Khan, Kernel Maintainer & Linux Fellow" +[#]: via: "https://www.linux.com/news/interview-with-shuah-khan-kernel-maintainer-linux-fellow/" +[#]: author: "The Linux Foundation https://www.linuxfoundation.org/en/blog/interview-with-shuah-khan-kernel-maintainer-linux-fellow/" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " Interview with Shuah Khan, Kernel Maintainer & Linux Fellow ====== - -![][1] - -_Jason Perlow, Director of Project Insights and Editorial Content at the Linux Foundation, had an opportunity to speak with Shuah Khan about her experiences as a woman in the technology industry. She discusses how mentorship can improve the overall diversity and makeup of open source projects, why software maintainers are important for the health of open source projects such as the Linux kernel, and how language inclusivity and codes of conduct can improve relationships and communication between software maintainers and individual contributors._ +Jason Perlow, Director of Project Insights and Editorial Content at the Linux Foundation, had an opportunity to speak with Shuah Khan about her experiences as a woman in the technology industry. She discusses how mentorship can improve the overall diversity and makeup of open source projects, why software maintainers are important for the health of open source projects such as the Linux kernel, and how language inclusivity and codes of conduct can improve relationships and communication between software maintainers and individual contributors. **JP:** So, Shuah, I know you wear many different hats at the Linux Foundation. What do you call yourself around here these days? -**SK:** <laughs> Well, I primarily call myself a Kernel Maintainer & Linux Fellow. In addition to that, I focus on two areas that are important to the continued health and sustainability of the open source projects in the Linux ecosystem. The first one is bringing more women into the Kernel community, and additionally, I am leading the mentorship program efforts overall at the Linux Foundation. And in that role, in addition to the Linux Kernel Mentorship, we are looking at how the Linux Foundation mentorship program is working overall, how it is scaling. I make sure the [LFX Mentorship][2] platform scales and serves diverse mentees and mentors’ needs in this role. +**SK:** Well, I primarily call myself a Kernel Maintainer & Linux Fellow. In addition to that, I focus on two areas that are important to the continued health and sustainability of the open source projects in the Linux ecosystem. The first one is bringing more women into the Kernel community, and additionally, I am leading the mentorship program efforts overall at the Linux Foundation. And in that role, in addition to the Linux Kernel Mentorship, we are looking at how the Linux Foundation mentorship program is working overall, how it is scaling. I make sure the [LFX Mentorship][1] platform scales and serves diverse mentees and mentors’ needs in this role. -The LF mentorships program includes several projects in the Linux kernel, LFN, HyperLedger, Open MainFrame, OpenHPC, and other technologies. [The Linux Foundation’s Mentorship Programs][3] are designed to help developers with the necessary skills–many of whom are first-time open source contributors–experiment, learn, and contribute effectively to open source communities. +The LF mentorships program includes several projects in the Linux kernel, LFN, HyperLedger, Open MainFrame, OpenHPC, and other technologies. [The Linux Foundation’s Mentorship Programs][2] are designed to help developers with the necessary skills–many of whom are first-time open source contributors–experiment, learn, and contribute effectively to open source communities. The mentorship program has been successful in its mission to train new developers and make these talented pools of prospective employees trained by experts to employers. Several graduated mentees have found jobs. New developers have improved the quality and security of various open source projects, including the Linux kernel. Several Linux kernel bugs were fixed, a new subsystem mentor was added, and a new driver maintainer is now part of the Linux kernel community. My sincere thanks to all our mentors for volunteering to share their expertise. **JP:** How long have you been working on the Kernel? -**SK:** Since 2010, or 2011, I got involved in the [Android Mainlining project][4]. My [first patch removed the Android pmem driver][5]. +**SK:** Since 2010, or 2011, I got involved in the [Android Mainlining project][3]. My [first patch removed the Android pmem driver][4]. **JP:** Wow! Is there any particular subsystem that you specialize in? -**SK:** I am a self described generalist. I maintain the [kernel self-test][6] subsystem, the [USB over IP driver][7], [usbip tool][8], and the [cpupower][9] tool. I contributed to the media subsystem working on [Media Controller Device Allocator API][10] to resolve shared device resource management problems across device drivers from different subsystems. +**SK:** I am a self described generalist. I maintain the [kernel self-test][5] subsystem, the [USB over IP driver][6], [usbip tool][7], and the [cpupower][8] tool. I contributed to the media subsystem working on [Media Controller Device Allocator API][9] to resolve shared device resource management problems across device drivers from different subsystems. -**JP:** Hey, I’ve [actually used the USB over IP driver][11] when I worked at Microsoft on Azure. And also, when I’ve used AWS and Google Compute. +**JP:** Hey, I’ve [actually used the USB over IP driver][10] when I worked at Microsoft on Azure. And also, when I’ve used AWS and Google Compute. **SK:** It’s a small niche driver used in cloud computing. Docker and other containers use that driver heavily. That’s how they provide remote access to USB devices on the server to export devices to be imported by other systems for use. **JP:** I initially used it for IoT kinds of stuff in the embedded systems space. Were you the original lead developer on it, or was it one of those things you fell into because nobody else was maintaining it? -**SK:** Well, twofold. I was looking at USB over IP because I like that technology. it just so happened the driver was brought from the staging tree into the Mainline kernel, I volunteered at the time to maintain it. Over the last few years, we discovered some security issues with it, because it handles a lot of userspace data, so I had a lot of fun fixing all of those. <laugh>. +**SK:** Well, twofold. I was looking at USB over IP because I like that technology. it just so happened the driver was brought from the staging tree into the Mainline kernel, I volunteered at the time to maintain it. Over the last few years, we discovered some security issues with it, because it handles a lot of userspace data, so I had a lot of fun fixing all of those. . **JP:** What drew you into the Linux operating system, and what drew you into the kernel development community in the first place? -**SK:** Well, I have been doing kernel development for a very long time. I worked on the [LynxOS RTOS][12], a while back, and then HP/UX, when I was working at HP, after which I transitioned into  doing open source development — the [OpenHPI][13] project, to support HP’s rack server hardware, and that allowed me to work much more closely with Linux on the back end. And at some point, I decided I wanted to work with the kernel and become part of the Linux kernel community. I started as an independent contributor. +**SK:** Well, I have been doing kernel development for a very long time. I worked on the [LynxOS RTOS][11], a while back, and then HP/UX, when I was working at HP, after which I transitioned into  doing open source development — the [OpenHPI][12] project, to support HP’s rack server hardware, and that allowed me to work much more closely with Linux on the back end. And at some point, I decided I wanted to work with the kernel and become part of the Linux kernel community. I started as an independent contributor. **JP:** Maybe it just displays my own ignorance, but you are the first female, hardcore Linux kernel developer I have ever met. I mean, I had met female core OS developers before — such as when I was at Microsoft and IBM — but not for Linux. Why do you suppose we lack women and diversity in general when participating in open source and the technology industry overall? @@ -52,9 +49,9 @@ There’s a natural resistance to choosing certain professions that you have to **SK:** Yes. -**JP:** It’s funny; my wife really likes this [Netflix show about matchmaking in India][14]. Are you familiar with it? +**JP:** It’s funny; my wife really likes this [Netflix show about matchmaking in India][13]. Are you familiar with it? -**SK:** <laughs> Yes I enjoyed the series, and [A Suitable Girl][15] documentary film that follows three women as they navigate making decisions about their careers and family obligations. +**SK:** Yes I enjoyed the series, and [A Suitable Girl][14] documentary film that follows three women as they navigate making decisions about their careers and family obligations. **JP:** For many Americans, this is our first introduction to what home life is like for Indian people. But many of the women featured on this show are professionals, such as doctors, lawyers, and engineers. And they are very ambitious, but of course, the family tries to set them up in a marriage to find a husband for them that is compatible. As a result, you get to learn about the traditional values and roles they still want women to play there — while at the same time, many women are coming out of higher learning institutions in that country that are seeking technical careers. @@ -62,11 +59,11 @@ There’s a natural resistance to choosing certain professions that you have to **JP:** Women in technical and STEM professions are becoming much more prominent in other countries, such as China, Japan, and Korea. For some reason, in the US, I tend to see more women enter the medical profession than hard technology — and it might be a level of effort and perceived reward thing. You can spend eight years becoming a medical doctor or eight years becoming a scientist or an engineer, and it can be equally difficult, but the compensation at the end may not be the same. It’s expensive to get an education, and it takes a long time and hard work, regardless of the professional discipline. -**SK:** I have also heard that women also like to enter professions where they can make a difference in the world — a human touch, if you will. So that may translate to them choosing careers where they can make a larger impact on people — and they may view careers in technology as not having those same attributes. Maybe when we think about attracting women to technology fields, we might have to promote technology aspects that make a difference. That may be changing now, such as the [LF Public Health][16] (LFPH) project we kicked off last year. And with [LF AI & Data Foundation][17], we are also making a difference in people’s lives, such as [detecting earthquakes][18] or [analyzing climate change][19]. If we were to promote projects such as these, we might draw more women in. +**SK:** I have also heard that women also like to enter professions where they can make a difference in the world — a human touch, if you will. So that may translate to them choosing careers where they can make a larger impact on people — and they may view careers in technology as not having those same attributes. Maybe when we think about attracting women to technology fields, we might have to promote technology aspects that make a difference. That may be changing now, such as the [LF Public Health][15] (LFPH) project we kicked off last year. And with [LF AI & Data Foundation][16], we are also making a difference in people’s lives, such as [detecting earthquakes][17] or [analyzing climate change][18]. If we were to promote projects such as these, we might draw more women in. -**JP:** So clearly, one of the areas of technology where you can make a difference is in open source, as the LF is hosting some very high-concept and existential types of projects such as [LF Energy][20], for example — I had no idea what was involved in it and what its goals were until I spoke to [Shuli Goodman][21] in-depth about it. With the mentorship program, I assume we need this to attract fresh talent — because as folks like us get older and retire, and they exit the field, we need new people to replace them. So I assume mentorship, for the Linux Foundation, is an investment in our own technologies, correct? +**JP:** So clearly, one of the areas of technology where you can make a difference is in open source, as the LF is hosting some very high-concept and existential types of projects such as [LF Energy][19], for example — I had no idea what was involved in it and what its goals were until I spoke to [Shuli Goodman][20] in-depth about it. With the mentorship program, I assume we need this to attract fresh talent — because as folks like us get older and retire, and they exit the field, we need new people to replace them. So I assume mentorship, for the Linux Foundation, is an investment in our own technologies, correct? -**SK:** Correct. Bringing in new developers into the fold is the primary purpose, of course — and at the same time, I view the LF as taking on mentorship provides that neutral, level playing field across the industry for all open source projects. Secondly, we offer a self-service platform, [LFX Mentorship][22], where anyone can come in and start their project. So when the COVID-19 pandemic began, we [expanded this program to help displaced people][3] — students, et cetera, and less visible projects. Not all projects typically get as much funding or attention as others do — such as a Kubernetes or  Linux kernel — among the COVID mentorship program projects we are funding. I am particularly proud of supporting a climate change-related project, [Using Machine Learning to Predict Deforestation][23]. +**SK:** Correct. Bringing in new developers into the fold is the primary purpose, of course — and at the same time, I view the LF as taking on mentorship provides that neutral, level playing field across the industry for all open source projects. Secondly, we offer a self-service platform, [LFX Mentorship][21], where anyone can come in and start their project. So when the COVID-19 pandemic began, we [expanded this program to help displaced people][22] — students, et cetera, and less visible projects. Not all projects typically get as much funding or attention as others do — such as a Kubernetes or  Linux kernel — among the COVID mentorship program projects we are funding. I am particularly proud of supporting a climate change-related project, [Using Machine Learning to Predict Deforestation][23]. The self-service approach allows us to fund and add new developers to projects where they are needed. The LF mentorships are remote work opportunities that are accessible to developers around the globe. We see people sign up for mentorship projects from places we haven’t seen before, such as Africa, and so on, thus creating a level playing field. @@ -122,43 +119,43 @@ Talking about backpacking reminded me of the two-day, 22-mile backpacking trip d **JP:** Awesome. I enjoyed talking to you today. So happy I finally got to meet you virtually. -The post [Interview with Shuah Khan, Kernel Maintainer & Linux Fellow][33] appeared first on [Linux Foundation][34]. +The post [Interview with Shuah Khan, Kernel Maintainer & Linux Fellow][33] appeared first on [Linux Foundation][34]. -------------------------------------------------------------------------------- via: https://www.linux.com/news/interview-with-shuah-khan-kernel-maintainer-linux-fellow/ 作者:[The Linux Foundation][a] -选题:[lujun9972][b] +选题:[lkxed][b] 译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]: https://www.linuxfoundation.org/en/blog/interview-with-shuah-khan-kernel-maintainer-linux-fellow/ -[b]: https://github.com/lujun9972 -[1]: https://www.linux.com/wp-content/uploads/2021/01/3E9C3E02-5F59-4A99-AD4A-814C7B8737A9_1_105_c.jpeg -[2]: https://lfx.linuxfoundation.org/tools/mentorship/ -[3]: https://linuxfoundation.org/about/diversity-inclusivity/mentorship/ -[4]: https://elinux.org/Android_Mainlining_Project -[5]: https://lkml.org/lkml/2012/1/26/368 -[6]: https://www.kernel.org/doc/html/v4.15/dev-tools/kselftest.html -[7]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/usbip -[8]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/usb/usbip -[9]: https://www.systutorials.com/docs/linux/man/1-cpupower/ -[10]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/media/mc/mc-dev-allocator.c -[11]: https://www.linux-magazine.com/Issues/2018/208/Tutorial-USB-IP -[12]: https://en.wikipedia.org/wiki/LynxOS -[13]: http://www.openhpi.org/Developers -[14]: https://www.netflix.com/title/80244565 -[15]: https://en.wikipedia.org/wiki/A_Suitable_Girl_(film) -[16]: https://www.lfph.io/ -[17]: https://lfaidata.foundation/ -[18]: https://openeew.com/ -[19]: https://www.os-climate.org/ -[20]: https://www.lfenergy.org/ -[21]: mailto:sgoodman@contractor.linuxfoundation.org -[22]: https://mentorship.lfx.linuxfoundation.org/ +[b]: https://github.com/lkxed +[1]: https://lfx.linuxfoundation.org/tools/mentorship/ +[2]: https://linuxfoundation.org/about/diversity-inclusivity/mentorship/ +[3]: https://elinux.org/Android_Mainlining_Project +[4]: https://lkml.org/lkml/2012/1/26/368 +[5]: https://www.kernel.org/doc/html/v4.15/dev-tools/kselftest.html +[6]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/usbip +[7]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/usb/usbip +[8]: https://www.systutorials.com/docs/linux/man/1-cpupower/ +[9]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/media/mc/mc-dev-allocator.c +[10]: https://www.linux-magazine.com/Issues/2018/208/Tutorial-USB-IP +[11]: https://en.wikipedia.org/wiki/LynxOS +[12]: http://www.openhpi.org/Developers +[13]: https://www.netflix.com/title/80244565 +[14]: https://en.wikipedia.org/wiki/A_Suitable_Girl_(film) +[15]: https://www.lfph.io/ +[16]: https://lfaidata.foundation/ +[17]: https://openeew.com/ +[18]: https://www.os-climate.org/ +[19]: https://www.lfenergy.org/ +[20]: https://www.linux.com/mailto:sgoodman@contractor.linuxfoundation.org +[21]: https://mentorship.lfx.linuxfoundation.org/ +[22]: https://linuxfoundation.org/about/diversity-inclusivity/mentorship/ [23]: https://mentorship.lfx.linuxfoundation.org/project/926665ac-9b96-45aa-bb11-5d99096be870 [24]: https://www.linuxfoundation.org/en/blog/preventing-supply-chain-attacks-like-solarwinds/ [25]: https://www.linuxfoundation.org/en/press-release/new-open-source-contributor-report-from-linux-foundation-and-harvard-identifies-motivations-and-opportunities-for-improving-software-security/ diff --git a/sources/tech/20210128 Start programming in Racket by writing a -guess the number- game.md b/sources/tech/20210128 Start programming in Racket by writing a -guess the number- game.md index 4f0bb194a6..7d672783b8 100644 --- a/sources/tech/20210128 Start programming in Racket by writing a -guess the number- game.md +++ b/sources/tech/20210128 Start programming in Racket by writing a -guess the number- game.md @@ -1,21 +1,21 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Start programming in Racket by writing a "guess the number" game) -[#]: via: (https://opensource.com/article/21/1/racket-guess-number) -[#]: author: (Cristiano L. Fontana https://opensource.com/users/cristianofontana) +[#]: subject: "Start programming in Racket by writing a "guess the number" game" +[#]: via: "https://opensource.com/article/21/1/racket-guess-number" +[#]: author: "Cristiano L. Fontana https://opensource.com/users/cristianofontana" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " Start programming in Racket by writing a "guess the number" game ====== -Racket is a great way to learn a language from the Scheme and Lisp -families. +Racket is a great way to learn a language from the Scheme and Lisp families. + ![Person using a laptop][1] I am a big advocate of learning multiple programming languages. That's mostly because I tend to get bored with the languages I use the most. It also teaches me new and interesting ways to approach programming. -Writing the same program in multiple languages is a good way to learn their differences and similarities. Previously, I wrote articles showing the same sample data plotting program written in [C & C++][2], JavaScript with [Node.js][3], and [Python and Octave][4]. +Writing the same program in multiple languages is a good way to learn their differences and similarities. Previously, I wrote articles showing the same sample data plotting program written in [C & C++][2], JavaScript with [Node.js][3], and [Python and Octave][4]. This article is part of another series about writing a "guess the number" game in different programming languages. In this game, the computer picks a number between one and 100 and asks you to guess it. The program loops until you make a correct guess. @@ -31,7 +31,6 @@ When I start learning a new language, I usually look for a tutorial that introdu Starting with Racket makes sense because it is very mature and versatile, and the community is very active. Since Racket is a Lisp-like language, a major characteristic is that it uses the [prefix notation][9] and a [lot of parentheses][10]. Functions and operators are applied to a list of operands by prefixing them: - ``` (function-name operand operand ...) @@ -58,15 +57,14 @@ The major Linux distributions offer packaged versions of Racket, so [installatio Here is a version of the "guess the number" program written in Racket: - ``` #lang racket (define (inquire-user number)   (display "Insert a number: ") -  (define guess (string->number (read-line))) -  (cond [(> number guess) (displayln "Too low") (inquire-user number)] -        [(< number guess) (displayln "Too high") (inquire-user number)] +  (define guess (string->number (read-line))) +  (cond [(> number guess) (displayln "Too low") (inquire-user number)] +        [(< number guess) (displayln "Too high") (inquire-user number)]         [else (displayln "Correct!")])) (displayln "Guess a number between 1 and 100") @@ -75,14 +73,12 @@ Here is a version of the "guess the number" program written in Racket: Save this listing to a file called `guess.rkt` and run it: - ``` -`$ racket guess.rkt` +$ racket guess.rkt ``` Here is some example output: - ``` Guess a number between 1 and 100 Insert a number: 90 @@ -111,9 +107,9 @@ Now for the next line. `(define ...)` is used to declare new variables or functi This function recursively calls itself to repeat the question until the user guesses the right number. Note that I am not using loops; I feel that Racket programmers do not like loops and only use recursive functions. This approach is idiomatic to Racket, but if you prefer, [loops are an option][18]. -The first step of the `inquire-user` function asks the user to insert a number by writing that string to the console. Then it defines a variable called `guess` that contains whatever the user entered. The [`read-line` function][19] returns the user input as a string. The string is then converted to a number with the [`string->number` function][20]. After the variable definition, the [`cond` function][21] accepts a series of conditions. If a condition is satisfied, it executes the code inside that condition. These conditions, `(> number guess)` and `(< number guess)`, are followed by two functions: a `displayln` that gives clues to the user and a `inquire-user` call. The function calls itself again when the user does not guess the right number. The `else` clause executes when the two conditions are not met, i.e., the user enters the correct number. The program's guts are this `inquire-user` function. +The first step of the `inquire-user` function asks the user to insert a number by writing that string to the console. Then it defines a variable called `guess` that contains whatever the user entered. The [read-line function][19] returns the user input as a string. The string is then converted to a number with the [string->number function][20]. After the variable definition, the [cond function][21] accepts a series of conditions. If a condition is satisfied, it executes the code inside that condition. These conditions, `(> number guess)` and `(< number guess)`, are followed by two functions: a `displayln` that gives clues to the user and a `inquire-user` call. The function calls itself again when the user does not guess the right number. The `else` clause executes when the two conditions are not met, i.e., the user enters the correct number. The program's guts are this `inquire-user` function. -However, the function still needs to be called! First, the program asks the user to guess a number between 1 and 100, and then it calls the `inquire-user` function with a random number. The random number is generated with the [`random` function][22]. You need to inform the function that you want to generate a number between 1 and 100, but the `random` function generates integer numbers up to `max-1`, so I used 101. +However, the function still needs to be called! First, the program asks the user to guess a number between 1 and 100, and then it calls the `inquire-user` function with a random number. The random number is generated with the [random function][22]. You need to inform the function that you want to generate a number between 1 and 100, but the `random` function generates integer numbers up to `max-1`, so I used 101. ### Try Racket @@ -124,15 +120,15 @@ Learning new languages is fun! I am a big advocate of programming languages poly via: https://opensource.com/article/21/1/racket-guess-number 作者:[Cristiano L. Fontana][a] -选题:[lujun9972][b] +选题:[lkxed][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/cristianofontana -[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) +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/laptop_screen_desk_work_chat_text.png [2]: https://opensource.com/article/20/2/c-data-science [3]: https://opensource.com/article/20/6/data-science-nodejs [4]: https://opensource.com/article/20/2/python-gnu-octave-data-science diff --git a/sources/tech/20210131 How to teach open source beyond business.md b/sources/tech/20210131 How to teach open source beyond business.md deleted file mode 100644 index f9563e14ff..0000000000 --- a/sources/tech/20210131 How to teach open source beyond business.md +++ /dev/null @@ -1,72 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to teach open source beyond business) -[#]: via: (https://opensource.com/article/21/1/open-source-beyond-business) -[#]: author: (Irit Goihman https://opensource.com/users/iritgoihman) - -How to teach open source beyond business -====== -The Beyond program connects future talents in the tech industry with -open source culture. -![Teacher or learner?][1] - -When I was a university student, I didn't understand the fuss about open source software. I used Linux and open source software but didn't really understand the open source model, how to contribute to projects, or how it could benefit my future career. My development experience consisted mainly of homework assignments and a large final project required for my degree. - -So, when I took my first steps in the tech industry, there was a big learning curve before I felt comfortable. I needed to understand how to join established, sometimes large, and distributed teams working on an ongoing project. I also needed to know how to communicate properly so that my efforts could be recognized. - -I am not special in this regard. This is a common situation among new graduates. - -### Open source gives students a head start - -Since then, as an engineer and later as a manager, I have helped onboard many junior engineers. One of the things I've noticed is that the new graduates who have already contributed to open source projects could onboard quickly and start contributing faster than those without this experience. - -By incorporating open source methodology into academic studies, students can gain experience relevant to the industry, learn to reuse their existing knowledge, and establish a good platform for formulating ideas and sharing knowledge. Practicing open source can make a positive impact on students' technical knowledge and experience. This can help them become more successful in bootstrapping their careers. - -The value of open source methodologies in the tech industry is well-established and shapes the culture of software companies worldwide. Involvement in open source projects and adoption of the [open organization culture][2] has become an industry standard. Companies seek fresh-minded, talented employees who know how to work in open source and cultivate its culture. Therefore, the tech industry must drive the academic world to embrace open source culture as one of the fundamental methodologies to learn in tech studies. - -### Moving open source culture 'Beyond' business - -When I met [Liora Milbaum][3], a senior principal software engineer at Red Hat, I learned we shared an interest in bringing open source culture and principles into academics. Liora had previously founded [DevOps Loft][4], in which she shared DevOps practices with people interested in stepping into this world, and wished to start a similar initiative to teach open source to university students. We decided to launch the [Beyond][5] program to connect future talents in the tech industry with open source culture as Red Hat practices it. - -We started the Beyond program at the [Academic College of Tel Aviv-Yafo][6], where we were warmly welcomed by the information systems faculty. We started by teaching an "Introduction to DevOps'' course to introduce elements of the DevOps tech stack. Our biggest challenge at the start was deciding how to teach what open source is. The answer was simple: by practicing it, of course. We didn't want to deliver yet another old-school academic course; rather, we wanted to expose students to industry standards. - -We created a syllabus that incorporated common open source projects and tools to teach the DevOps stack. The course consisted of lectures and hands-on participation taught by engineers. The students were divided into groups, each one mentored and supported by an engineer. They practiced working in teams, sharing knowledge (both inside and outside of their groups), and collaborating effectively. - -During our second course, "Open source development pillars," for students in the computer science department, we encountered another big obstacle. Two weeks after the course started, we became fully remote as the COVID pandemic hit the globe. We solved this problem by using the same remote collaboration tools with our students that we were using for our daily work at Red Hat. We were amazed at how simple and smooth the transition was. - -![Beyond teaching online][7] - -(Irit Goihman, [CC BY-SA 4.0][8]) - -### Successful early outcomes - -The two courses were a huge success, and we even hired one of the top students we taught. The feedback we received was amazing; the students said we positively impacted their knowledge, thinking, and soft skills. A few students were hired for their first tech job based on their open source contributions during the course. - -Other academic institutions have expressed interest in adopting these courses, so we've expanded the program to another university. - -I am fortunate to co-lead this successful initiative with Liora, accompanied by a team of talented engineers. Together, we are helping increase the open source community a bit more. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/1/open-source-beyond-business - -作者:[Irit Goihman][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/iritgoihman -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-lead-teacher-learner.png?itok=rMJqBN5G (Teacher or learner?) -[2]: https://opensource.com/open-organization/resources/open-org-definition -[3]: https://www.linkedin.com/in/lioramilbaum -[4]: https://www.devopsloft.io/ -[5]: https://research.redhat.com/blog/2020/05/24/open-source-development-course-and-devops-methodology/ -[6]: https://www.int.mta.ac.il/ -[7]: https://opensource.com/sites/default/files/pictures/beyond_mta.png (Beyond teaching online) -[8]: https://creativecommons.org/licenses/by-sa/4.0/ diff --git a/sources/tech/20210203 Defining boundaries and interfaces in software development.md b/sources/tech/20210203 Defining boundaries and interfaces in software development.md index 6f3e540da8..47f72b8d66 100644 --- a/sources/tech/20210203 Defining boundaries and interfaces in software development.md +++ b/sources/tech/20210203 Defining boundaries and interfaces in software development.md @@ -92,7 +92,7 @@ The system is trying to remove an item that does not exist in the basket, and it ``` public int RemoveItem(Hashtable item) { -        if(basket.IndexOf(item) >= 0) { +        if(basket.IndexOf(item) >= 0) {                 basket.RemoveAt(basket.IndexOf(item));         }         return basket.Count; diff --git a/sources/tech/20210204 How to implement business requirements in software development.md b/sources/tech/20210204 How to implement business requirements in software development.md index 1527f6babe..38845d0cb4 100644 --- a/sources/tech/20210204 How to implement business requirements in software development.md +++ b/sources/tech/20210204 How to implement business requirements in software development.md @@ -86,7 +86,7 @@ Implement this processing logic in the `ShippingAPI` class: ``` private double Calculate10PercentDiscount(double total) {         double discount = 0.00; -        if(total > 500.00) { +        if(total > 500.00) {                 discount = (total/100) * 10;         }         return discount; diff --git a/sources/tech/20210205 Astrophotography with Fedora Astronomy Lab- setting up.md b/sources/tech/20210205 Astrophotography with Fedora Astronomy Lab- setting up.md index 7077d9544b..78d855c76b 100644 --- a/sources/tech/20210205 Astrophotography with Fedora Astronomy Lab- setting up.md +++ b/sources/tech/20210205 Astrophotography with Fedora Astronomy Lab- setting up.md @@ -1,11 +1,11 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Astrophotography with Fedora Astronomy Lab: setting up) -[#]: via: (https://fedoramagazine.org/astrophotography-with-fedora-astronomy-lab-setting-up/) -[#]: author: (Geoffrey Marr https://fedoramagazine.org/author/coremodule/) +[#]: subject: "Astrophotography with Fedora Astronomy Lab: setting up" +[#]: via: "https://fedoramagazine.org/astrophotography-with-fedora-astronomy-lab-setting-up/" +[#]: author: "Geoffrey Marr https://fedoramagazine.org/author/coremodule/" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " Astrophotography with Fedora Astronomy Lab: setting up ====== @@ -28,21 +28,15 @@ Download Fedora Astronomy Lab from the [Fedora Labs website][4]. You will need a Before you can go capturing the heavens, you need to do some minor setup in Fedora Astronomy Lab. -First of all, you need to add your user to the _dialout_ group so that you can access certain pieces of astronomical equipment from within the guiding software. Do that by opening the terminal (Konsole) and running this command (replacing _user_ with your username): +First of all, you need to add your user to the *dialout* group so that you can access certain pieces of astronomical equipment from within the guiding software. Do that by opening the terminal (Konsole) and running this command (replacing *user* with your username): -sudo usermod -a -G dialout user - -My personal setup includes a guide camera (QHY5 series, also known as Orion Starshoot) that does not have a driver in the mainline Fedora repositories. To enable it, ypu need to install the [qhyccd SDK][9]. (_Note that this package is not officially supported by Fedora. Use it at your own risk.)_ At the time of writing, I chose to use the latest stable release, 20.08.26. Once you download the Linux 64-bit version of the SDK, to extract it: -``` +My personal setup includes a guide camera (QHY5 series, also known as Orion Starshoot) that does not have a driver in the mainline Fedora repositories. To enable it, ypu need to install the [qhyccd SDK][9]. (*Note that this package is not officially supported by Fedora. Use it at your own risk.)* At the time of writing, I chose to use the latest stable release, 20.08.26. Once you download the Linux 64-bit version of the SDK, to extract it: ``` - tar zxvf sdk_linux64_20.08.26.tgz ``` -``` - -Now change into the directory you just extracted, change the permissions of the _install.sh_ file to give you execute privileges, and run the _install.sh_: +Now change into the directory you just extracted, change the permissions of the *install.sh* file to give you execute privileges, and run the *install.sh*: ``` cd sdk_linux64_20.08.26 @@ -50,49 +44,35 @@ chmod +x install.sh sudo ./install.sh ``` -Now it’s time to install the qhyccd INDI driver. INDI is an open source software library used to control astronomical equipment. Unfortunately, the driver is unavailable in the mainline Fedora repositories, but it is in a Copr repository. (_Note: Copr is not officially supported by Fedora infrastructure. Use packages at your own risk.)_ If you prefer to have the newest (and perhaps unstable!) pieces of astronomy software, you can also enable the “bleeding” repositories at this time by following [this guide][10]. For this tutorial, you are only going to enable one repo: -``` +Now it’s time to install the qhyccd INDI driver. INDI is an open source software library used to control astronomical equipment. Unfortunately, the driver is unavailable in the mainline Fedora repositories, but it is in a Copr repository. (*Note: Copr is not officially supported by Fedora infrastructure. Use packages at your own risk.)* If you prefer to have the newest (and perhaps unstable!) pieces of astronomy software, you can also enable the “bleeding” repositories at this time by following [this guide][10]. For this tutorial, you are only going to enable one repo: ``` - sudo dnf copr enable xsnrg/indi-3rdparty-bleeding ``` -``` - Install the driver by running the following command: -``` ``` - sudo dnf install indi-qhy ``` -``` - Finally, update all of your system packages: -sudo dnf update -y - -To recap what you accomplished in this sectio: you added your user to the _dialout_ group, downloaded and installed the qhyccd driver, enabled the _indi-3rdparty-bleeding_ copr, installed the qhyccd-INDI driver with dnf, and updated your system. +To recap what you accomplished in this sectio: you added your user to the *dialout* group, downloaded and installed the qhyccd driver, enabled the *indi-3rdparty-bleeding* copr, installed the qhyccd-INDI driver with dnf, and updated your system. ### Connecting your equipment This is the time to connect all your equipment to your computer. Most astronomical equipment will connect via USB, and it’s really as easy as plugging each device into your computer’s USB ports. If you have a lot of equipment (mount, imaging camera, guide camera, focuser, filter wheel, etc), you should use an external powered-USB hub to make sure that all connected devices have adequate power. Once you have everything plugged in, run the following command to ensure that the system recognizes your equipment: -``` ``` - lsusb ``` -``` - You should see output similar to (but not the same as) the output here: ![][11] -You see in the output that the system recognizes the telescope mount (a SkyWatcher EQM-35 Pro) as _Prolific Technology, Inc. PL2303 Serial Port_, the imaging camera (a Sony a6000) as _Sony Corp. ILCE-6000_, and the guide camera (an Orion Starshoot, aka QHY5) as _Van Ouijen Technische Informatica_. Now that you have made sure your system recognizes your equipment, it’s time to open your desktop planetarium and telescope controller, KStars! +You see in the output that the system recognizes the telescope mount (a SkyWatcher EQM-35 Pro) as *Prolific Technology, Inc. PL2303 Serial Port*, the imaging camera (a Sony a6000) as *Sony Corp. ILCE-6000*, and the guide camera (an Orion Starshoot, aka QHY5) as *Van Ouijen Technische Informatica*. Now that you have made sure your system recognizes your equipment, it’s time to open your desktop planetarium and telescope controller, KStars! ### Setting up KStars @@ -100,15 +80,15 @@ It’s time to open [KStars][12], which is a desktop planetarium and also includ ![][13] -Follow the prompts to choose your home location (where you will be imaging from) and _Download Extra Data…_ +Follow the prompts to choose your home location (where you will be imaging from) and *Download Extra Data…* -![Setting your location][14] +![][14] -![“Download Extra Data”][15] +![][15] -![Choosing which catalogs to download][16] +![][16] -This will allow you to install additional star, nebula, and galaxy catalogs. You don’t need them, but they don’t take up too much space and add to the experience of using KStars. Once you’ve completed this, hit _Done_ in the bottom right corner to continue. +This will allow you to install additional star, nebula, and galaxy catalogs. You don’t need them, but they don’t take up too much space and add to the experience of using KStars. Once you’ve completed this, hit *Done* in the bottom right corner to continue. ### Getting familiar with KStars @@ -116,49 +96,49 @@ Now is a good time to play around with the KStars interface. You are greeted wit ![][17] -This is the desktop planetarium which allows you to view the placement of objects in the night sky. Double-clicking an object selects it, and right clicking on an object gives you options like _Center & Track_ which will follow the object in the planetarium, compensating for [sidereal time][18]. _Show DSS Image_ shows a real [digitized sky survey][19] image of the selected object. +This is the desktop planetarium which allows you to view the placement of objects in the night sky. Double-clicking an object selects it, and right clicking on an object gives you options like *Center & Track* which will follow the object in the planetarium, compensating for [sidereal time][18]. *Show DSS Image* shows a real [digitized sky survey][19] image of the selected object. ![][20] -Another essential feature is the _Set Time_ option in the toolbar. Clicking this will allow you to input a future (or past) time and then simulate the night sky as if that were the current date. +Another essential feature is the *Set Time* option in the toolbar. Clicking this will allow you to input a future (or past) time and then simulate the night sky as if that were the current date. -![The Set Time button][21] +![][21] ### Configuring capture equipment with Ekos -You’re familiar with the KStars layout and some basic functions, so it’s time to move on configuring your equipment using the [Ekos][22] observatory controller and automation tool. To open Ekos, click the observatory button in the toolbar or go to _Tools_ > _Ekos_. +You’re familiar with the KStars layout and some basic functions, so it’s time to move on configuring your equipment using the [Ekos][22] observatory controller and automation tool. To open Ekos, click the observatory button in the toolbar or go to *Tools* > *Ekos*. -![The Ekos button on the toolbar][23] +![][23] -You will see another setup wizard: the _Ekos Profile Wizard_. Click _Next_ to start the wizard. +You will see another setup wizard: the *Ekos Profile Wizard*. Click *Next* to start the wizard. ![][24] -In this tutorial, you have all of our equipment connected directly to your computer. A future article we will cover using an INDI server installed on a remote computer to control our equipment, allowing you to connect over a network and not have to be in the same physical space as your gear. For now though, select _Equipment is attached to this device_. +In this tutorial, you have all of our equipment connected directly to your computer. A future article we will cover using an INDI server installed on a remote computer to control our equipment, allowing you to connect over a network and not have to be in the same physical space as your gear. For now though, select *Equipment is attached to this device*. ![][25] -You are now asked to name your equipment profile. I usually name mine something like “Local Gear” to differentiate between profiles that are for remote gear, but name your profile what you wish. We will leave the button marked _Internal Guide_ checked and won’t select any additional services. Now click the _Create Profile & Select Devices_ button. +You are now asked to name your equipment profile. I usually name mine something like “Local Gear” to differentiate between profiles that are for remote gear, but name your profile what you wish. We will leave the button marked *Internal Guide* checked and won’t select any additional services. Now click the *Create Profile & Select Devices* button. ![][26] This next screen is where we can select your particular driver to use for each individual piece of equipment. This part will be specific to your setup depending on what gear you use. For this tutorial, I will select the drivers for my setup. -My mount, a [SkyWatcher EQM-35 Pro][27], uses the _EQMod Mount_ under _SkyWatcher_ in the menu (this driver is also compatible with all SkyWatcher equatorial mounts, including the [EQ6-R Pro][28] and the [EQ8-R Pro][29]). For my Sony a6000 imaging camera, I choose the _Sony DSLR_ under _DSLRs_ under the CCD category. Under _Guider_, I choose the _QHY CCD_ under _QHY_ for my Orion Starshoot (and any QHY5 series camera). That last driver we want to select will be under the Aux 1 category. We want to select _Astrometry_ from the drop-down window. This will enable the Astrometry plate-solver from within Ekos that will allow our telescope to automatically figure out where in the night sky it is pointed, saving us the time and hassle of doing a one, two, or three star calibration after setting up our mount. +My mount, a [SkyWatcher EQM-35 Pro][27], uses the *EQMod Mount* under *SkyWatcher* in the menu (this driver is also compatible with all SkyWatcher equatorial mounts, including the [EQ6-R Pro][28] and the [EQ8-R Pro][29]). For my Sony a6000 imaging camera, I choose the *Sony DSLR* under *DSLRs* under the CCD category. Under *Guider*, I choose the *QHY CCD* under *QHY* for my Orion Starshoot (and any QHY5 series camera). That last driver we want to select will be under the Aux 1 category. We want to select *Astrometry* from the drop-down window. This will enable the Astrometry plate-solver from within Ekos that will allow our telescope to automatically figure out where in the night sky it is pointed, saving us the time and hassle of doing a one, two, or three star calibration after setting up our mount. -You selected your drivers. Now it’s time to configure your telescope. Add new telescope profiles by clicking on the + button in the lower right. This is essential for computing field-of-view measurements so you can tell what your images will look like when you open the shutter. Once you click the + button, you will be presented with a form where you can enter the specifications of your telescope and guide scope. For my imaging telescope, I will enter Celestron into the _Vendor_ field, SS-80 into the _Model_ field, I will leave the _Driver_ field as None, _Type_ field as Refractor, _Aperture_ as 80mm, and _Focal Length_ as 400mm. +You selected your drivers. Now it’s time to configure your telescope. Add new telescope profiles by clicking on the + button in the lower right. This is essential for computing field-of-view measurements so you can tell what your images will look like when you open the shutter. Once you click the + button, you will be presented with a form where you can enter the specifications of your telescope and guide scope. For my imaging telescope, I will enter Celestron into the *Vendor* field, SS-80 into the *Model* field, I will leave the *Driver* field as None, *Type* field as Refractor, *Aperture* as 80mm, and *Focal Length* as 400mm. ![][30] -After you enter the data, hit the _Save_ button. You will see the data you just entered appear in the left window with an index number of 1 next to it. Now you can go about entering the specs for your guide scope following the steps above. Once you hit save here, the guide scope will also appear in the left window with an index number of 2. Once all of your scopes are entered, close this window. Now select your _Primary_ and _Guide_ telescopes from the drop-down window. +After you enter the data, hit the *Save* button. You will see the data you just entered appear in the left window with an index number of 1 next to it. Now you can go about entering the specs for your guide scope following the steps above. Once you hit save here, the guide scope will also appear in the left window with an index number of 2. Once all of your scopes are entered, close this window. Now select your *Primary* and *Guide* telescopes from the drop-down window. ![][31] -After all that work, everything should be correctly configured! Click the _Close_ button and complete the final bit of setup. +After all that work, everything should be correctly configured! Click the *Close* button and complete the final bit of setup. ### Starting your capture equipment -This last step before you can start taking images should be easy enough. Click the _Play_ button under Start & Stop Ekos to connect to your equipment. +This last step before you can start taking images should be easy enough. Click the *Play* button under Start & Stop Ekos to connect to your equipment. ![][32] @@ -166,26 +146,23 @@ You will be greeted with a screen that looks similar to this: ![][33] -When you click on the tabs at the top of the screen, they should all show a green dot next to _Connection_, indicating that they are connected to your system. On my setup, the baud rate for my mount (the EQMod Mount tab) is set incorrectly, and so the mount is not connected. +When you click on the tabs at the top of the screen, they should all show a green dot next to *Connection*, indicating that they are connected to your system. On my setup, the baud rate for my mount (the EQMod Mount tab) is set incorrectly, and so the mount is not connected. ![][34] -This is an easy fix; click on the _EQMod Mount_ tab, then the _Connection_ sub-tab, and then change the baud rate from 9600 to 115200. Now is a good time to ensure the serial port under _Ports_ is the correct serial port for your mount. You can check which port the system has mounted your device on by running the command: -``` +This is an easy fix; click on the *EQMod Mount* tab, then the *Connection* sub-tab, and then change the baud rate from 9600 to 115200. Now is a good time to ensure the serial port under *Ports* is the correct serial port for your mount. You can check which port the system has mounted your device on by running the command: ``` - ls /dev -``` | grep USB ``` -You should see _ttyUSB0_. If there is more than one USB-serial device plugged in at a time, you will see more than one ttyUSB port, with an incrementing following number. To figure out which port is correct. unplug your mount and run the command again. +You should see *ttyUSB0*. If there is more than one USB-serial device plugged in at a time, you will see more than one ttyUSB port, with an incrementing following number. To figure out which port is correct. unplug your mount and run the command again. -Now click on the _Main Control_ sub-tab, click _Connect_ again, and wait for the mount to connect. It might take a few seconds, be patient and it should connect. +Now click on the *Main Control* sub-tab, click *Connect* again, and wait for the mount to connect. It might take a few seconds, be patient and it should connect. -The last thing to do is set the sensor and pixel size parameters for my camera. Under the _Sony DSLR Alpha-A6000 (Control)_ tab, select the _Image Info_ sub-tab. This is where you can enter your sensor specifications; if you don’t know them, a quick search on the internet will bring you your sensor’s maximum resolution as well as pixel pitch. Enter this data into the right-side boxes, then press the _Set_ button to load them into the left boxes and save them into memory. Hit the _Close_ button when you are done. +The last thing to do is set the sensor and pixel size parameters for my camera. Under the *Sony DSLR Alpha-A6000 (Control)* tab, select the *Image Info* sub-tab. This is where you can enter your sensor specifications; if you don’t know them, a quick search on the internet will bring you your sensor’s maximum resolution as well as pixel pitch. Enter this data into the right-side boxes, then press the *Set* button to load them into the left boxes and save them into memory. Hit the *Close* button when you are done. ![][35] @@ -198,14 +175,14 @@ Your equipment is ready to use. In the next article, you will learn how to captu via: https://fedoramagazine.org/astrophotography-with-fedora-astronomy-lab-setting-up/ 作者:[Geoffrey Marr][a] -选题:[lujun9972][b] +选题:[lkxed][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/coremodule/ -[b]: https://github.com/lujun9972 +[b]: https://github.com/lkxed [1]: https://fedoramagazine.org/wp-content/uploads/2021/02/astrophotography-setup-2-816x345.jpg [2]: https://fedoramagazine.org/wp-content/uploads/2020/11/IMG_4151-768x1024.jpg [3]: https://labs.fedoraproject.org/en/astronomy/ diff --git a/sources/tech/20210207 3 ways to play video games on Linux.md b/sources/tech/20210207 3 ways to play video games on Linux.md deleted file mode 100644 index e01c4b2e77..0000000000 --- a/sources/tech/20210207 3 ways to play video games on Linux.md +++ /dev/null @@ -1,98 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (godgithubf) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (3 ways to play video games on Linux) -[#]: via: (https://opensource.com/article/21/2/linux-gaming) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) - -3 ways to play video games on Linux -====== -If you're ready to put down the popcorn and experience games from all -angles, start gaming on Linux. -![Gaming with penguin pawns][1] - -In 2021, there are more reasons why people love Linux than ever before. In this series, I'll share 21 different reasons to use Linux. Today, I'll start with gaming. - -I used to think a "gamer" was a very specific kind of creature, carefully cataloged and classified by scientists after years of study and testing. I never classified myself as a gamer because most of the games I played were either on a tabletop (board games and pen-and-paper roleplaying games), NetHack, or Tetris. Now that games are available on everything from mobile devices, consoles, computers, and televisions, it feels like it's a good time to acknowledge that "gamers" come in all different shapes and sizes. If you want to call yourself a gamer, you can! There's no qualification exam. You don't have to know the Konami Code by heart (or even what that reference means); you don't have to buy and play "triple-A" games. If you enjoy a game from time to time, you can rightfully call yourself a gamer. And if you want to be a gamer, there's never been a better time to use Linux. - -### Welcome to the underground - -Peel back the glossy billboard ads, and underneath, you're sure to find a thriving gaming underground. It's a movement that began with the nascent gaming market before anyone believed money could be made off software that wasn't either a spreadsheet or typing tutor. Indie games have carved out a place in pop culture (believe it or not, [Minecraft, while not open source][2], started out as an indie game) in several ways, proving that in the eyes of players, gameplay comes before production value. - -There's a lot of cross-over in the indie and open source developer space. There's nothing quite like kicking back with your Linux laptop and browsing [itch.io][3] or your distribution's software repository for a little-known but precious gem of an open source game. - -There are all kinds of open source games available, including plenty of [first person shooters][4], puzzle games like [Nodulus][5], systems management games like [OpenTTD][6], racing games like [Jethook][7], tense escape campaigns like [Sauerbraten][8], and too many more to mention (with more arriving each year, thanks to great initiatives like [Open Jam][9]). - -![Jethook game screenshot][10] - -Jethook - -Overall, the experience of delving into the world of open source games is different than the immediate satisfaction of buying whatever a major game studio releases next. Games by the big studios provide plenty of visual and sonic stimuli, big-name actors, and upwards of 60 hours of gameplay. Independent and open source games aren't likely to match that, but then again, major studios can't match the sense of discovery and personal connection you get when you find a game that you just know nobody else _has ever heard of_. And they can't hope to match the sense of urgency you get when you realize that everybody in the world really, really needs to hear about the great game you've just played. - -Take some time to identify the kinds of games you enjoy the most, and then have a browse through your distribution's software repository, [Flathub][11], and open game jams. See what you can uncover and, if you like the game enough, help to promote it! - -### Proton and WINE - -Gaming on Linux doesn't stop with open source, but it is enabled by it. When Valve Software famously brought Linux back into the gaming market a few years ago by releasing their Steam client for Linux, the hope was that it would compel game studios to write code native to Linux systems. Some did, but Valve failed to push Linux as the primary platform even on their own Valve-branded gaming computers, and it seems that most studios have reverted to their old ways of Windows-only games. - -Interestingly, though, the end result has produced more open source code than probably intended. Valve's solution for Linux compatibility has been to create the [Proton][12] project, a compatibility layer to translate Windows games to Linux. At its core, Proton uses [WINE (Wine Is Not an Emulator)][13], the too-good-to-be-true reimplementation of major Windows libraries as open source. - -The game market's spoils have turned out to be a treasure trove for the open source world, and today, most games from major studios can be run on Linux as if they were native. - -Of course, if you're the type of gamer who has to have the latest title on the day of release, you can certainly expect unpleasant surprises. That's not surprising, though, because few major games are released without bugs requiring large patches a week later. Those bugs can be even worse when a game runs on Proton and WINE, so Linux gamers often benefit by refraining from early adoption. The trade-off may be worth it, though. I've played a few games that run perfectly on Proton, only to discover later from angry forum posts that it's apparently riddled with fatal errors when played on the latest version of Windows. In short, it seems that games from major studios aren't perfect, and so you can expect similar-but-different problems when playing them on Linux as you would on Windows. - -### Flatpak - -One of the most exciting developments of recent Linux history is [Flatpak][14], a cross between local containers and packaging. It's got nothing to do with gaming (or doesn't it?), but it enables Linux applications to essentially be distributed universally to any Linux distribution. This applies to gaming because there are often lots of fringe technologies used in games, and it can be pretty demanding on distribution maintainers to keep up with all the latest versions required by any given game. - -Flatpak abstracts that away from the distribution by establishing a common Flatpak-specific layer for application libraries. Distributors of flatpaks know that if a library isn't in a Flatpak SDK, then it must be included in the flatpak. It's simple and straightforward. - -Thanks to Flatpak, the Steam client runs on something obvious like Fedora and on distributions not traditionally geared toward the gaming market, like [RHEL][15] and Slackware! - -### Lutris - -If you're not eager to sign up on Steam, though, there's my preferred gaming client, [Lutris][16]. On the surface, Lutris is a simple game launcher for your system, a place you can go when you know you want to play a game but just can't decide what to launch yet. With Lutris, you can add [all the games you have on your system][17] to create your own gaming library, and then launch and play them right from the Lutris interface. Better still, Lutris contributors (like me!) regularly publish installer scripts to make it easy for you to install games you own. It's not always necessary, but it can be a nice shortcut to bypass some tedious configuration. - -Lutris can also enlist the help of _runners_, or subsystems that run games that wouldn't normally launch straight from your application menu. For instance, if you want to play console games like the open source [Warcraft Tower Defense][18], you must run an emulator, and Lutris can handle that for you (provided you have the emulator installed). Additionally, should you have a GOG.com (Good Old Games) account, Lutris can access it and import games from your library. - -There's no easier way to manage your games. - -### Play games - -Linux gaming is a fulfilling and empowering experience. I used to avoid computer gaming because I didn't feel I had much of a choice. It seemed that there were always expensive games being released, which inevitably got extreme reactions from happy and unhappy gamers alike, and then the focus shifted quickly to the next big thing. On the other hand, open source gaming has introduced me to the _people_ of the gaming world. I've met other players and developers, I've met artists and musicians, fans and promoters, and I've played an assortment of games that I never even realized existed. Some of them were barely long enough to distract me for just one afternoon, while others have provided me hours and hours of obsessive gameplay, modding, level design, and fun. - -If you're ready to put down the popcorn and experience games from all angles, start gaming on Linux. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/2/linux-gaming - -作者:[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/gaming_grid_penguin.png?itok=7Fv83mHR (Gaming with penguin pawns) -[2]: https://opensource.com/alternatives/minecraft -[3]: https://itch.io/jam/open-jam-2020 -[4]: https://opensource.com/article/20/5/open-source-fps-games -[5]: https://hyperparticle.itch.io/nodulus -[6]: https://www.openttd.org/ -[7]: https://rcorre.itch.io/jethook -[8]: http://sauerbraten.org/ -[9]: https://opensource.com/article/18/9/open-jam-announcement -[10]: https://opensource.com/sites/default/files/game_0.png -[11]: http://flathub.org -[12]: https://github.com/ValveSoftware/Proton -[13]: http://winehq.org -[14]: https://opensource.com/business/16/8/flatpak -[15]: https://www.redhat.com/en/enterprise-linux-8 -[16]: http://lutris.net -[17]: https://opensource.com/article/18/10/lutris-open-gaming-platform -[18]: https://ndswtd.wordpress.com/download diff --git a/sources/tech/20210208 Fedora Aarch64 on the SolidRun HoneyComb LX2K.md b/sources/tech/20210208 Fedora Aarch64 on the SolidRun HoneyComb LX2K.md index e060ca66fa..ef95349df3 100644 --- a/sources/tech/20210208 Fedora Aarch64 on the SolidRun HoneyComb LX2K.md +++ b/sources/tech/20210208 Fedora Aarch64 on the SolidRun HoneyComb LX2K.md @@ -42,7 +42,7 @@ nvme_core.default_ps_max_latency_us=0 In the end I upgraded my main workstation so I could repurpose its existing Samsung EVO 960 for the HoneyComb which worked much better. -After some fidgeting I was able to install Fedora but it became apparent that the integrated network ports still don’t work with the mainline kernel. The NXP tech is great but requires a custom kernel build and tooling. Some earlier blogs got around this with a USB->RJ45 Ethernet adapter which works fine. Hopefully network support will be mainlined soon, but for now I snagged a kernel SRPM from the helpful engineers on Discord. With the custom kernel the 1Gbe NIC worked fine, but it turns out the SFP+ ports need more configuration. They won’t be recognized as interfaces until you use NXP’s _restool_ utility to map ports to their usage. In this case just a runtime mapping of _dmap -> dni_ was required. This is NXP’s way of mapping a MAC to a network interface via IOCTL commands. The restool binary isn’t provided either and must be built from source. It then layers on management scripts which use cheeky $arg0 references for redirection to call the restool binary with complex arguments. +After some fidgeting I was able to install Fedora but it became apparent that the integrated network ports still don’t work with the mainline kernel. The NXP tech is great but requires a custom kernel build and tooling. Some earlier blogs got around this with a USB->RJ45 Ethernet adapter which works fine. Hopefully network support will be mainlined soon, but for now I snagged a kernel SRPM from the helpful engineers on Discord. With the custom kernel the 1Gbe NIC worked fine, but it turns out the SFP+ ports need more configuration. They won’t be recognized as interfaces until you use NXP’s _restool_ utility to map ports to their usage. In this case just a runtime mapping of _dmap -> dni_ was required. This is NXP’s way of mapping a MAC to a network interface via IOCTL commands. The restool binary isn’t provided either and must be built from source. It then layers on management scripts which use cheeky $arg0 references for redirection to call the restool binary with complex arguments. Since I was starting to accumulate quite a few custom packages it was apparent that a COPR repo was needed to simplify this for Fedora. If you’re not familiar with COPR I think it’s one of Fedora’s finest resources. This repo contains the uefi build (currently failing build), 5.10.5 kernel built with network support, and the restool binary with supporting scripts. I also added a oneshot systemd unit to enable the SFP+ ports on boot: ``` diff --git a/sources/tech/20210210 Configure multi-tenancy with Kubernetes namespaces.md b/sources/tech/20210210 Configure multi-tenancy with Kubernetes namespaces.md index 5ced955007..5804c35922 100644 --- a/sources/tech/20210210 Configure multi-tenancy with Kubernetes namespaces.md +++ b/sources/tech/20210210 Configure multi-tenancy with Kubernetes namespaces.md @@ -85,8 +85,8 @@ Describe the newly created namespace: ``` [root@master ~]# kubectl describe namespace test Name:         test -Labels:       <none> -Annotations:  <none> +Labels:       +Annotations:   Status:       Active No resource quota. No LimitRange resource. @@ -233,8 +233,8 @@ Verify the Roles: ``` $ kubectl describe roles -n test   Name:         list-deployments -  Labels:       <none> -  Annotations:  <none> +  Labels:       +  Annotations:     PolicyRule:     Resources         Non-Resource URLs  Resource Names  Verbs     ---------         -----------------  --------------  ----- diff --git a/sources/tech/20210210 Draw Mandelbrot fractals with GIMP scripting.md b/sources/tech/20210210 Draw Mandelbrot fractals with GIMP scripting.md index d38f3fb54d..3ff3460421 100644 --- a/sources/tech/20210210 Draw Mandelbrot fractals with GIMP scripting.md +++ b/sources/tech/20210210 Draw Mandelbrot fractals with GIMP scripting.md @@ -1,57 +1,51 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Draw Mandelbrot fractals with GIMP scripting) -[#]: via: (https://opensource.com/article/21/2/gimp-mandelbrot) -[#]: author: (Cristiano L. Fontana https://opensource.com/users/cristianofontana) +[#]: subject: "Draw Mandelbrot fractals with GIMP scripting" +[#]: via: "https://opensource.com/article/21/2/gimp-mandelbrot" +[#]: author: "Cristiano L. Fontana https://opensource.com/users/cristianofontana" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " Draw Mandelbrot fractals with GIMP scripting ====== Create complex mathematical images with GIMP's Script-Fu language. + ![Painting art on a computer screen][1] +Image by: Opensource.com + The GNU Image Manipulation Program ([GIMP][2]) is my go-to solution for image editing. Its toolset is very powerful and convenient, except for doing [fractals][3], which is one thing you cannot draw by hand easily. These are fascinating mathematical constructs that have the characteristic of being [self-similar][4]. In other words, if they are magnified in some areas, they will look remarkably similar to the unmagnified picture. Besides being interesting, they also make very pretty pictures! -![Portion of a Mandelbrot fractal using GIMPs Coldfire palette][5] +![Rotated and magnified portion of the Mandelbrot set using Firecode][5] -Portion of a Mandelbrot fractal using GIMP's Coldfire palette (Cristiano Fontana, [CC BY-SA 4.0][6]) +GIMP can be automated with [Script-Fu][6] to do [batch processing of images][7] or create complicated procedures that are not practical to do by hand; drawing fractals falls in the latter category. This tutorial will show how to draw a representation of the [Mandelbrot fractal][8] using GIMP and Script-Fu. -GIMP can be automated with [Script-Fu][7] to do [batch processing of images][8] or create complicated procedures that are not practical to do by hand; drawing fractals falls in the latter category. This tutorial will show how to draw a representation of the [Mandelbrot fractal][9] using GIMP and Script-Fu. +![Mandelbrot set drawn using GIMP's Firecode palette][9] -![Mandelbrot set drawn using GIMP's Firecode palette][10] - -Portion of a Mandelbrot fractal using GIMP's Firecode palette. (Cristiano Fontana, [CC BY-SA 4.0][6]) - -![Rotated and magnified portion of the Mandelbrot set using Firecode.][11] - -Rotated and magnified portion of the Mandelbrot set using the Firecode palette. (Cristiano Fontana, [CC BY-SA 4.0][6]) +![Rotated and magnified portion of the Mandelbrot set using Firecode.][10] In this tutorial, you will write a script that creates a layer in an image and draws a representation of the Mandelbrot set with a colored environment around it. ### What is the Mandelbrot set? -Do not panic! I will not go into too much detail here. For the more math-savvy, the Mandelbrot set is defined as the set of [complex numbers][12] _a_ for which the succession +Do not panic! I will not go into too much detail here. For the more math-savvy, the Mandelbrot set is defined as the set of [complex numbers][11] *a* for which the succession -_zn+1 = zn2 + a_ +zn+1 = zn2 + a -does not diverge when starting from _z₀ = 0_. +does not diverge when starting from *z₀ = 0*. In reality, the Mandelbrot set is the fancy-looking black blob in the pictures; the nice-looking colors are outside the set. They represent how many iterations are required for the magnitude of the succession of numbers to pass a threshold value. In other words, the color scale shows how many steps are required for the succession to pass an upper-limit value. ### GIMP's Script-Fu -[Script-Fu][7] is the scripting language built into GIMP. It is an implementation of the [Scheme programming language][13]. +[Script-Fu][12] is the scripting language built into GIMP. It is an implementation of the [Scheme programming language][13]. -If you want to get more acquainted with Scheme, GIMP's documentation offers an [in-depth tutorial][14]. I also wrote an article about [batch processing images][8] using Script-Fu. Finally, the Help menu offers a Procedure Browser with very extensive documentation with all of Script-Fu's functions described in detail. +If you want to get more acquainted with Scheme, GIMP's documentation offers an [in-depth tutorial][14]. I also wrote an article about [batch processing images][15] using Script-Fu. Finally, the Help menu offers a Procedure Browser with very extensive documentation with all of Script-Fu's functions described in detail. -![GIMP Procedure Browser][15] - -(Cristiano Fontana, [CC BY-SA 4.0][6]) - -Scheme is a Lisp-like language, so a major characteristic is that it uses a [prefix notation][16] and a [lot of parentheses][17]. Functions and operators are applied to a list of operands by prefixing them: +![GIMP Procedure Browser][16] +Scheme is a Lisp-like language, so a major characteristic is that it uses a [prefix notation][17] and a [lot of parentheses][18]. Functions and operators are applied to a list of operands by prefixing them: ``` (function-name operand operand ...) @@ -67,7 +61,6 @@ Scheme is a Lisp-like language, so a major characteristic is that it uses a [pre You can write your first script and save it to the **Scripts** folder found in the preferences window under **Folders → Scripts**. Mine is at `$HOME/.config/GIMP/2.10/scripts`. Write a file called `mandelbrot.scm` with: - ``` ; Complex numbers implementation (define (make-rectangular x y) (cons x y)) @@ -111,17 +104,17 @@ You can write your first script and save it to the **Scripts** folder found in t   (define bytes-per-pixel (car (gimp-drawable-bpp drawable)))   ; Fractal drawing section. -  ; Code from: +  ; Code from: https://rosettacode.org/wiki/Mandelbrot_set#Racket   (define (iterations a z i)     (let ((z′ (add-c (mul-c z z) a))) -       (if (or (= i num-colors) (> (magnitude z′) threshold)) +       (if (or (= i num-colors) (> (magnitude z′) threshold))           i           (iterations a z′ (+ i 1))))) -  (define (iter->color i) -    (if (>= i num-colors) -        (list->vector '(0 0 0)) -        (list->vector (vector-ref colors i)))) +  (define (iter->color i) +    (if (>= i num-colors) +        (list->vector '(0 0 0)) +        (list->vector (vector-ref colors i))))   (define z0 (make-rectangular 0 0)) @@ -130,10 +123,10 @@ You can write your first script and save it to the **Scripts** folder found in t            (real-y (- (* domain-height (/ y height)) offset-y))            (a (make-rectangular real-x real-y))            (i (iterations a z0 0)) -           (color (iter->color i))) -      (cond ((and (< x end-x) (< y end-y)) (gimp-drawable-set-pixel drawable x y bytes-per-pixel color) +           (color (iter->color i))) +      (cond ((and (< x end-x) (< y end-y)) (gimp-drawable-set-pixel drawable x y bytes-per-pixel color)                                            (loop (+ x 1) end-x y end-y)) -            ((and (>= x end-x) (< y end-y)) (gimp-progress-update (/ y end-y)) +            ((and (>= x end-x) (< y end-y)) (gimp-progress-update (/ y end-y))                                             (loop 0 end-x (+ y 1) end-y)))))   (loop 0 width 0 height) @@ -161,15 +154,14 @@ You can write your first script and save it to the **Scripts** folder found in t   SF-ADJUSTMENT "X offset"           '(2.25 -20 20 0.1 1 4 0)   SF-ADJUSTMENT "Y offset"           '(1.50 -20 20 0.1 1 4 0) ) -(script-fu-menu-register "script-fu-mandelbrot" "<Image>/Layer/") +(script-fu-menu-register "script-fu-mandelbrot" "/Layer/") ``` I will go through the script to show you what it does. ### Get ready to draw the fractal -Since this image is all about complex numbers, I wrote a quick and dirty implementation of complex numbers in Script-Fu. I defined the complex numbers as [pairs][18] of real numbers. Then I added the few functions needed for the script. I used [Racket's documentation][19] as inspiration for function names and roles: - +Since this image is all about complex numbers, I wrote a quick and dirty implementation of complex numbers in Script-Fu. I defined the complex numbers as [pairs][19] of real numbers. Then I added the few functions needed for the script. I used [Racket's documentation][20] as inspiration for function names and roles: ``` (define (make-rectangular x y) (cons x y)) @@ -198,7 +190,6 @@ Since this image is all about complex numbers, I wrote a quick and dirty impleme The new function is called `script-fu-mandelbrot`. The best practice for writing a new function is to call it `script-fu-something` so that it can be identified in the Procedure Browser easily. The function requires a few parameters: an `image` to which it will add a layer with the fractal, the `palette-name` identifying the color palette to be used, the `threshold` value to stop the iteration, the `domain-width` and `domain-height` that identify the image boundaries, and the `offset-x` and `offset-y` to center the image to the desired feature. The script also needs some other parameters that it can deduce from the GIMP interface: - ``` (define (script-fu-mandelbrot image palette-name threshold domain-width domain-height offset-x offset-y)   (define num-colors (car (gimp-palette-get-info palette-name))) @@ -212,7 +203,6 @@ The new function is called `script-fu-mandelbrot`. The best practice for writing Then it creates a new layer and identifies it as the script's `drawable`. A "drawable" is the element you want to draw on: - ``` (define new-layer (car (gimp-layer-new image                                        width height @@ -226,27 +216,25 @@ Then it creates a new layer and identifies it as the script's `drawable`. A "dra (define bytes-per-pixel (car (gimp-drawable-bpp drawable))) ``` -For the code determining the pixels' color, I used the [Racket][20] example on the [Rosetta Code][21] website. It is not the most optimized algorithm, but it is simple to understand. Even a non-mathematician like me can understand it. The `iterations` function determines how many steps the succession requires to pass the threshold value. To cap the iterations, I am using the number of colors in the palette. In other words, if the threshold is too high or the succession does not grow, the calculation stops at the `num-colors` value. The `iter->color` function transforms the number of iterations into a color using the provided palette. If the iteration number is equal to `num-colors`, it uses black because this means that the succession is probably bound and that pixel is in the Mandelbrot set: - +For the code determining the pixels' color, I used the [Racket][21] example on the [Rosetta Code][22] website. It is not the most optimized algorithm, but it is simple to understand. Even a non-mathematician like me can understand it. The `iterations` function determines how many steps the succession requires to pass the threshold value. To cap the iterations, I am using the number of colors in the palette. In other words, if the threshold is too high or the succession does not grow, the calculation stops at the `num-colors` value. The `iter->color` function transforms the number of iterations into a color using the provided palette. If the iteration number is equal to `num-colors`, it uses black because this means that the succession is probably bound and that pixel is in the Mandelbrot set: ``` ; Fractal drawing section. -; Code from: +; Code from: https://rosettacode.org/wiki/Mandelbrot_set#Racket (define (iterations a z i)   (let ((z′ (add-c (mul-c z z) a))) -     (if (or (= i num-colors) (> (magnitude z′) threshold)) +     (if (or (= i num-colors) (> (magnitude z′) threshold))         i         (iterations a z′ (+ i 1))))) -(define (iter->color i) -  (if (>= i num-colors) -      (list->vector '(0 0 0)) -      (list->vector (vector-ref colors i)))) +(define (iter->color i) +  (if (>= i num-colors) +      (list->vector '(0 0 0)) +      (list->vector (vector-ref colors i)))) ``` Because I have the feeling that Scheme users do not like to use loops, I implemented the function looping over the pixels as a recursive function. The `loop` function reads the starting coordinates and their upper boundaries. At each pixel, it defines some temporary variables with the `let*` function: `real-x` and `real-y` are the real coordinates of the pixel in the complex plane, according to the parameters; the `a` variable is the starting point for the succession; the `i` is the number of iterations; and finally `color` is the pixel color. Each pixel is colored with the `gimp-drawable-set-pixel` function that is an internal GIMP procedure. The peculiarity is that it is not undoable, and it does not trigger the image to refresh. Therefore, the image will not be updated during the operation. To play nice with the user, at the end of each row of pixels, it calls the `gimp-progress-update` function, which updates a progress bar in the user interface: - ``` (define z0 (make-rectangular 0 0)) @@ -255,17 +243,16 @@ Because I have the feeling that Scheme users do not like to use loops, I impleme          (real-y (- (* domain-height (/ y height)) offset-y))          (a (make-rectangular real-x real-y))          (i (iterations a z0 0)) -         (color (iter->color i))) -    (cond ((and (< x end-x) (< y end-y)) (gimp-drawable-set-pixel drawable x y bytes-per-pixel color) +         (color (iter->color i))) +    (cond ((and (< x end-x) (< y end-y)) (gimp-drawable-set-pixel drawable x y bytes-per-pixel color)                                          (loop (+ x 1) end-x y end-y)) -          ((and (>= x end-x) (< y end-y)) (gimp-progress-update (/ y end-y)) +          ((and (>= x end-x) (< y end-y)) (gimp-progress-update (/ y end-y))                                           (loop 0 end-x (+ y 1) end-y))))) (loop 0 width 0 height) ``` At the calculation's end, the function needs to inform GIMP that it modified the `drawable`, and it should refresh the interface because the image is not "automagically" updated during the script's execution: - ``` (gimp-drawable-update drawable 0 0 width height) (gimp-displays-flush) @@ -275,7 +262,6 @@ At the calculation's end, the function needs to inform GIMP that it modified the To use the `script-fu-mandelbrot` function in the graphical user interface (GUI), the script needs to inform GIMP. The `script-fu-register` function informs GIMP about the parameters required by the script and provides some documentation: - ``` (script-fu-register   "script-fu-mandelbrot"          ; Function name @@ -300,71 +286,69 @@ To use the `script-fu-mandelbrot` function in the graphical user interface (GUI) Then the script tells GIMP to put the new function in the Layer menu with the label "Create a Mandelbrot layer": - ``` -`(script-fu-menu-register "script-fu-mandelbrot" "/Layer/")` +(script-fu-menu-register "script-fu-mandelbrot" "/Layer/") ``` Having registered the function, you can visualize it in the Procedure Browser. -![script-fu-mandelbrot function][22] - -(Cristiano Fontana, [CC BY-SA 4.0][6]) +![script-fu-mandelbrot function][23] ### Run the script Now that the function is ready and registered, you can draw the Mandelbrot fractal! First, create a square image and run the script from the Layers menu. -![script running][23] - -(Cristiano Fontana, [CC BY-SA 4.0][6]) +![script running][24] The default values are a good starting set to obtain the following image. The first time you run the script, create a very small image (e.g., 60x60 pixels) because this implementation is slow! It took several hours for my computer to create the following image in full 1920x1920 pixels. As I mentioned earlier, this is not the most optimized algorithm; rather, it was the easiest for me to understand. -![Mandelbrot set drawn using GIMP's Firecode palette][10] - -Portion of a Mandelbrot fractal using GIMP's Firecode palette. (Cristiano Fontana, [CC BY-SA 4.0][6]) +![Mandelbrot set drawn using GIMP's Firecode palette][25] ### Learn more This tutorial showed how to use GIMP's built-in scripting features to draw an image created with an algorithm. These images show GIMP's powerful set of tools that can be used for artistic applications and mathematical images. -If you want to move forward, I suggest you look at the official documentation and its [tutorial][14]. As an exercise, try modifying this script to draw a [Julia set][24], and please share the resulting image in the comments. +If you want to move forward, I suggest you look at the official documentation and its [tutorial][26]. As an exercise, try modifying this script to draw a [Julia set][27], and please share the resulting image in the comments. + +Image by: Rotated and magnified portion of the Mandelbrot set using Firecode. (Cristiano Fontana, CC BY-SA 4.0) -------------------------------------------------------------------------------- via: https://opensource.com/article/21/2/gimp-mandelbrot 作者:[Cristiano L. Fontana][a] -选题:[lujun9972][b] +选题:[lkxed][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/cristianofontana -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/painting_computer_screen_art_design_creative.png?itok=LVAeQx3_ (Painting art on a computer screen) +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/painting_computer_screen_art_design_creative.png [2]: https://www.gimp.org/ [3]: https://en.wikipedia.org/wiki/Fractal [4]: https://en.wikipedia.org/wiki/Self-similarity -[5]: https://opensource.com/sites/default/files/uploads/mandelbrot_portion.png (Portion of a Mandelbrot fractal using GIMPs Coldfire palette) -[6]: https://creativecommons.org/licenses/by-sa/4.0/ -[7]: https://docs.gimp.org/en/gimp-concepts-script-fu.html -[8]: https://opensource.com/article/21/1/gimp-scripting -[9]: https://en.wikipedia.org/wiki/Mandelbrot_set -[10]: https://opensource.com/sites/default/files/uploads/mandelbrot.png (Mandelbrot set drawn using GIMP's Firecode palette) -[11]: https://opensource.com/sites/default/files/uploads/mandelbrot_portion2.png (Rotated and magnified portion of the Mandelbrot set using Firecode.) -[12]: https://en.wikipedia.org/wiki/Complex_number +[5]: https://opensource.com/sites/default/files/uploads/mandelbrot_portion.png +[6]: https://docs.gimp.org/en/gimp-concepts-script-fu.html +[7]: https://opensource.com/article/21/1/gimp-scripting +[8]: https://en.wikipedia.org/wiki/Mandelbrot_set +[9]: https://opensource.com/sites/default/files/uploads/mandelbrot.png +[10]: https://opensource.com/sites/default/files/uploads/mandelbrot_portion2.png +[11]: https://en.wikipedia.org/wiki/Complex_number +[12]: https://docs.gimp.org/en/gimp-concepts-script-fu.html [13]: https://en.wikipedia.org/wiki/Scheme_(programming_language) [14]: https://docs.gimp.org/en/gimp-using-script-fu-tutorial.html -[15]: https://opensource.com/sites/default/files/uploads/procedure_browser_0.png (GIMP Procedure Browser) -[16]: https://en.wikipedia.org/wiki/Polish_notation -[17]: https://xkcd.com/297/ -[18]: https://www.gnu.org/software/guile/manual/html_node/Pairs.html -[19]: https://docs.racket-lang.org/reference/generic-numbers.html?q=make-rectangular#%28part._.Complex_.Numbers%29 -[20]: https://racket-lang.org/ -[21]: https://rosettacode.org/wiki/Mandelbrot_set#Racket -[22]: https://opensource.com/sites/default/files/uploads/mandelbrot_documentation.png (script-fu-mandelbrot function) -[23]: https://opensource.com/sites/default/files/uploads/script_working.png (script running) -[24]: https://en.wikipedia.org/wiki/Julia_set +[15]: https://opensource.com/article/21/1/gimp-scripting +[16]: https://opensource.com/sites/default/files/uploads/procedure_browser_0.png +[17]: https://en.wikipedia.org/wiki/Polish_notation +[18]: https://xkcd.com/297/ +[19]: https://www.gnu.org/software/guile/manual/html_node/Pairs.html +[20]: https://docs.racket-lang.org/reference/generic-numbers.html?q=make-rectangular#%28part._.Complex_.Numbers%29 +[21]: https://racket-lang.org/ +[22]: https://rosettacode.org/wiki/Mandelbrot_set#Racket +[23]: https://opensource.com/sites/default/files/uploads/mandelbrot_documentation.png +[24]: https://opensource.com/sites/default/files/uploads/script_working.png +[25]: https://opensource.com/sites/default/files/uploads/mandelbrot.png +[26]: https://docs.gimp.org/en/gimp-using-script-fu-tutorial.html +[27]: https://en.wikipedia.org/wiki/Julia_set diff --git a/sources/tech/20210210 Manage your budget on Linux with this open source finance tool.md b/sources/tech/20210210 Manage your budget on Linux with this open source finance tool.md deleted file mode 100644 index 6e11979896..0000000000 --- a/sources/tech/20210210 Manage your budget on Linux with this open source finance tool.md +++ /dev/null @@ -1,86 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (hanszhao80) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Manage your budget on Linux with this open source finance tool) -[#]: via: (https://opensource.com/article/21/2/linux-skrooge) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) - -Manage your budget on Linux with this open source finance tool -====== -Make managing your finances easier with Skrooge, an open source -budgeting tool. -![2 cents penny money currency][1] - -In 2021, there are more reasons why people love Linux than ever before. In this series, I'll share 21 different reasons to use Linux. This article is about personal financial management. - -Personal finances can be difficult to manage. It can be frustrating and even scary when you don't have enough money to get by without financial assistance, and it can be surprisingly overwhelming when you do have the money you need but no clear notion of where it all goes each month. To make matters worse, we're often told to "make a budget" as if declaring the amount of money you can spend each month will somehow manifest the money you need. The bottom line is that making a budget is hard, and not meeting your financial goals is discouraging. But it's still important, and Linux has several tools that can help make the task manageable. - -### Money management - -As with anything else in life, we all have our own ways of keeping track of our money. I used to take a simple and direct approach: My paycheck was deposited into an account, and I'd withdraw some percentage in cash. Once the cash was gone from my wallet, I had to wait until the next payday to spend anything. It only took one day of missing out on lunch to learn that I had to take my goals seriously, and I adjusted my spending behavior accordingly. For the simple lifestyle I had at the time, it was an effective means of keeping myself honest with my income, but it didn't translate well to online business transactions, long-term utility contracts, investments, and so on. - -As I continue to refine the way I track my finances, I've learned that personal accounting is always an evolving process. We each have unique financial circumstances, which inform what kind of solution we can or should use to track our income and debt. If you're out of work, then your budgeting goal is likely to spend as little as possible. If you're working but paying off a student loan, then your goal probably favors sending money to the bank. And if you're working but planning for retirement, then you're probably trying to save as much as you can. - -The thing to remember about a budget is that it's meant to compare your financial reality with your financial _goals_. You can't avoid some expenses, but after those, you get to set your own priorities. If you don't hit your goals, you can adjust your own behavior or rewrite your goals so that they better reflect reality. Adapting your financial plan doesn't mean you've failed. It just means that your initial projection wasn't accurate. During hard times, you may not be able to hit any budget goals, but if you keep up with your budget, you'll learn a lot about what it takes financially to maintain your current lifestyle (whatever it may be). Over time, you can learn to adjust settings you may never have realized were available to you. For instance, people are moving to rural towns for the lower cost of living now that remote work is a widely accepted option. It's pretty stunning to see how such a lifestyle shift can alter your budget reports. - -The point is that budgeting is an often undervalued activity, and in no small part because it's daunting. It's important to realize that you can budget, no matter your level of expertise or interest in finances. Whether you [just use a LibreOffice spreadsheet][2], or try a dedicated financial application, you can set goals, track your own behavior, and learn a lot of valuable lessons that could eventually pay dividends. - -### Open source accounting - -There are several dedicated [personal finance applications for Linux][3], including [HomeBank][4], [Money Manager EX][5], [GNUCash][6], [KMyMoney][7], and [Skrooge][8]. All of these applications are essentially ledgers, a place you can retreat to at the end of each month (or whenever you look at your accounts), import data from your bank, and review how your expenditures align with whatever budget you've set for yourself. - -![Skrooge interface with financial data displayed][9] - -Skrooge - -I use Skrooge as my personal budget tracker. It's an easy application to set up, even with multiple bank accounts. Skrooge, as with most open source finance apps, can import multiple file formats, so my workflow goes something like this: - - 1. Log in to my banks. - 2. Export the month's bank statement as QIF files. - 3. Open Skrooge. - 4. Import the QIF files. Each gets assigned to their appropriate accounts automatically. - 5. Review my expenditures compared to the budget goals I've set for myself. If I've gone over, then I dock next month's goals (so that I'll ideally spend less to make up the difference). If I've come in under my goal, then I move the excess to December's budget (so I'll have more to spend at the end of the year). - - - -I only track a subset of the household budget in Skrooge. Skrooge makes that process easy through a dynamic database that allows me to categorize multiple transactions at once with custom tags. This makes it easy for me to extract my personal expenditures from general household and utility expenses, and I can leverage these categories when reviewing the autogenerated reports Skrooge provides. - -![Skrooge budget pie chart][10] - -Skrooge budget pie chart - -Most importantly, the popular Linux financial apps allow me to manage my budget the way that works best for me. For instance, my partner prefers to use a LibreOffice spreadsheet, but with very little effort, I can extract a CSV file from the household budget, import it into Skrooge, and use an updated set of data. There's no lock-in, no incompatibility. The system is flexible and agile, allowing us to adapt our budget and our method of tracking expenses as we learn more about effective budgeting and about what life has in store. - -### Open choice - -Money markets worldwide differ, and the way we each interact with them also defines what tools we can use. Ultimately, your choice of what to use for your finances is a decision you must make based on your own requirements. And one thing open source does particularly well is provide its users the freedom of choice. - -When setting my own financial goals, I appreciate that I can use whatever application fits in best with my style of personal computing. I get to retain control of how I process the data in my life, even when it's data I don't necessarily enjoy having to process. Linux and its amazing set of applications make it just a little less of a chore. - -Try some financial apps on Linux and see if you can inspire yourself to set some goals and save money! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/2/linux-skrooge - -作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[hanszhao80](https://github.com/hanszhao80) -校对:[校对者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/Medical%20Costs%20Transparency_1.jpg?itok=CkZ_J88m (2 cents penny money currency) -[2]: https://opensource.com/article/20/3/libreoffice-templates -[3]: https://opensource.com/life/17/10/personal-finance-tools-linux -[4]: http://homebank.free.fr/en/index.php -[5]: https://www.moneymanagerex.org/download -[6]: https://opensource.com/article/20/2/gnucash -[7]: https://kmymoney.org/download.html -[8]: https://apps.kde.org/en/skrooge -[9]: https://opensource.com/sites/default/files/skrooge.jpg -[10]: https://opensource.com/sites/default/files/skrooge-pie_0.jpg diff --git a/sources/tech/20210222 A step-by-step guide to Knative eventing.md b/sources/tech/20210222 A step-by-step guide to Knative eventing.md index 9b297879bb..82f90f55c8 100644 --- a/sources/tech/20210222 A step-by-step guide to Knative eventing.md +++ b/sources/tech/20210222 A step-by-step guide to Knative eventing.md @@ -1,18 +1,20 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (A step-by-step guide to Knative eventing) -[#]: via: (https://opensource.com/article/21/2/knative-eventing) -[#]: author: (Jessica Cherry https://opensource.com/users/cherrybomb) +[#]: subject: "A step-by-step guide to Knative eventing" +[#]: via: "https://opensource.com/article/21/2/knative-eventing" +[#]: author: "Jessica Cherry https://opensource.com/users/cherrybomb" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " A step-by-step guide to Knative eventing ====== -Knative eventing is a way to create, send, and verify events in your -cloud-native environment. +Knative eventing is a way to create, send, and verify events in your cloud-native environment. + ![Computer laptop in space][1] +Image by: Opensource.com + In a previous article, I covered [how to create a small app with Knative][2], which is an open source project that adds components to [Kubernetes][3] for deploying, running, and managing [serverless, cloud-native][4] applications. In this article, I'll explain Knative eventing, a way to create, send, and verify events in your cloud-native environment. Events can be generated from many sources in your environment, and they can be confusing to manage or define. Since Knative follows the [CloudEvents][5] specification, it allows you to have one common abstraction point for your environment, where the events are defined to one specification. @@ -25,7 +27,6 @@ This walkthrough uses [Minikube][7] with Kubernetes 1.19.0. It also makes some c **Minikube pre-configuration commands:** - ``` $ minikube config set kubernetes-version v1.19.0 $ minikube config set memory 4000 @@ -34,7 +35,6 @@ $ minikube config set cpus 4 Before starting Minikube, run the following commands to make sure your configuration stays and start Minikube: - ``` $ minikube delete $ minikube start @@ -44,9 +44,8 @@ $ minikube start Install the Knative eventing custom resource definitions (CRDs) using kubectl. The following shows the command and a snippet of the output: - ``` -$ kubectl apply --filename +$ kubectl apply --filename https://github.com/knative/eventing/releases/download/v0.20.0/eventing-crds.yaml customresourcedefinition.apiextensions.k8s.io/apiserversources.sources.knative.dev created customresourcedefinition.apiextensions.k8s.io/brokers.eventing.knative.dev created @@ -56,9 +55,8 @@ customresourcedefinition.apiextensions.k8s.io/triggers.eventing.knative.dev crea Next, install the core components using kubectl: - ``` -$ kubectl apply --filename +$ kubectl apply --filename https://github.com/knative/eventing/releases/download/v0.20.0/eventing-core.yaml namespace/knative-eventing created serviceaccount/eventing-controller created clusterrolebinding.rbac.authorization.k8s.io/eventing-controller created @@ -66,23 +64,20 @@ clusterrolebinding.rbac.authorization.k8s.io/eventing-controller created Since you're running a standalone version of the Knative eventing service, you must install the in-memory channel to pass events. Using kubectl, run: - ``` -`$ kubectl apply --filename https://github.com/knative/eventing/releases/download/v0.20.0/in-memory-channel.yaml` +$ kubectl apply --filename https://github.com/knative/eventing/releases/download/v0.20.0/in-memory-channel.yaml ``` Install the broker, which utilizes the channels and runs the event routing: - ``` -$ kubectl apply --filename +$ kubectl apply --filename https://github.com/knative/eventing/releases/download/v0.20.0/mt-channel-broker.yaml clusterrole.rbac.authorization.k8s.io/knative-eventing-mt-channel-broker-controller created clusterrole.rbac.authorization.k8s.io/knative-eventing-mt-broker-filter created ``` Next, create a namespace and add a small broker to it; this broker routes events to triggers. Create your namespace using kubectl: - ``` $ kubectl create namespace eventing-test namespace/eventing-test created @@ -90,7 +85,6 @@ namespace/eventing-test created Now create a small broker named `default` in your namespace. The following is the YAML from my **broker.yaml** file (which can be found in my GitHub repository): - ``` apiVersion: eventing.knative.dev/v1 kind: broker @@ -101,7 +95,6 @@ metadata: Then apply your broker file using kubectl: - ``` $ kubectl create -f broker.yaml    broker.eventing.knative.dev/default created @@ -109,11 +102,10 @@ $ kubectl create -f broker.yaml Verify that everything is up and running (you should see the confirmation output) after you run the command: - ``` $ kubectl -n eventing-test get broker default                                                               NAME      URL                                                                              AGE    READY   REASON -default     3m6s   True +default   http://broker-ingress.knative-eventing.svc.cluster.local/eventing-test/default   3m6s   True ``` You'll need this URL from the broker output later for sending events, so save it. @@ -126,7 +118,6 @@ First, you need to create event consumers. You'll create two consumers in this w **The hello-display YAML code:** - ``` apiVersion: apps/v1 kind: Deployment @@ -135,7 +126,7 @@ metadata: spec:   replicas: 1   selector: -    matchLabels: &labels +    matchLabels: &labels       app: hello-display   template:     metadata: @@ -145,7 +136,7 @@ spec:         - name: event-display           image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display -\--- +--- kind: Service apiVersion: v1 @@ -162,7 +153,6 @@ spec: **The goodbye-display YAML code:** - ``` apiVersion: apps/v1 kind: Deployment @@ -171,7 +161,7 @@ metadata: spec:   replicas: 1   selector: -    matchLabels: &labels +    matchLabels: &labels       app: goodbye-display   template:     metadata: @@ -179,10 +169,10 @@ spec:     spec:       containers:         - name: event-display -          # Source code: +          # Source code: https://github.com/knative/eventing-contrib/tree/master/cmd/event_display           image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display -\--- +--- kind: Service apiVersion: v1 @@ -199,7 +189,6 @@ spec: The differences in the YAML between the two consumers are in the `app` and `metadata name` sections. While both consumers are on the same ports, you can target one when generating an event. Create the consumers using kubectl: - ``` $ kubectl -n eventing-test apply -f hello-display.yaml deployment.apps/hello-display created @@ -212,7 +201,6 @@ service/goodbye-display created Check to make sure the deployments are running after you've applied the YAML files: - ``` $ kubectl -n eventing-test get deployments hello-display goodbye-display NAME              READY   UP-TO-DATE   AVAILABLE   AGE @@ -226,7 +214,6 @@ Now, you need to create the triggers, which define the events the consumer recei **The greeting-trigger.yaml code:** - ``` apiVersion: eventing.knative.dev/v1 kind: Trigger @@ -246,7 +233,6 @@ spec: To create the first trigger, apply your YAML file: - ``` $ kubectl -n eventing-test apply -f greeting-trigger.yaml trigger.eventing.knative.dev/hello-display created @@ -256,7 +242,6 @@ Next, make the second trigger using **sendoff-trigger.yaml**. This sends anythin **The sendoff-trigger.yaml code:** - ``` apiVersion: eventing.knative.dev/v1 kind: Trigger @@ -276,7 +261,6 @@ spec: Next, apply your second trigger definition to the cluster: - ``` $ kubectl -n eventing-test apply -f sendoff-trigger.yaml trigger.eventing.knative.dev/goodbye-display created @@ -284,19 +268,17 @@ trigger.eventing.knative.dev/goodbye-display created Confirm everything is correctly in place by getting your triggers from the cluster using kubectl: - ``` $ kubectl -n eventing-test get triggers -NAME              BROKER    SUBSCRIBER_URI                                            AGE   READY   -goodbye-display   default     24s   True     -hello-display     default       46s   True +NAME              BROKER    SUBSCRIBER_URI                                            AGE   READY   +goodbye-display   default   http://goodbye-display.eventing-test.svc.cluster.local/   24s   True     +hello-display     default   http://hello-display.eventing-test.svc.cluster.local/     46s   True ``` ### Create an event producer Create a pod you can use to send events. This is a simple pod deployment with curl and SSH access for you to [send events using curl][8]. Because the broker can be accessed only from inside the cluster where Knative eventing is installed, the pod needs to be in the cluster; this is the only way to send events into the cluster. Use the **event-producer.yaml** file with this code: - ``` apiVersion: v1 kind: Pod @@ -318,7 +300,6 @@ spec: Next, deploy the pod by using kubectl: - ``` $ kubectl -n eventing-test apply -f event-producer.yaml pod/curl created @@ -326,7 +307,6 @@ pod/curl created To verify, get the deployment and make sure the pod is up and running: - ``` $ kubectl get pods -n eventing-test NAME                               READY   STATUS    RESTARTS   AGE @@ -339,14 +319,12 @@ Since this article has been so configuration-heavy, I imagine you'll be happy to Begin by logging into the pod: - ``` -`$ kubectl -n eventing-test attach curl -it` +$ kubectl -n eventing-test attach curl -it ``` Once logged in, you'll see output similar to: - ``` Defaulting container name to curl. Use 'kubectl describe pod/curl -n eventing-test' to see all of the containers in this pod. @@ -356,9 +334,8 @@ If you don't see a command prompt, try pressing enter. Now, generate an event using curl. This needs some extra definitions and requires the broker URL generated during the installation. This example sends a greeting to the broker: - ``` -curl -v "" \ +curl -v "http://broker-ingress.knative-eventing.svc.cluster.local/eventing-test/default" \   -X POST \   -H "Ce-Id: say-hello" \   -H "Ce-Specversion: 1.0" \ @@ -372,31 +349,29 @@ curl -v " POST /eventing-test/default HTTP/1.1 +> User-Agent: curl/7.35.0 +> Host: broker-ingress.knative-eventing.svc.cluster.local +> Accept: */* +> Ce-Id: say-hello +> Ce-Specversion: 1.0 +> Ce-Type: greeting +> Ce-Source: not-sendoff +> Content-Type: application/json +> Content-Length: 24 +> +< HTTP/1.1 202 Accepted +< Date: Sun, 24 Jan 2021 22:25:25 GMT +< Content-Length: 0 ``` The 202 means the trigger sent it to the **hello-display** consumer (because of the definition.) Next, send a second definition to the **goodbye-display** consumer with this new curl command: - ``` -curl -v "" \ +curl -v "http://broker-ingress.knative-eventing.svc.cluster.local/eventing-test/default" \   -X POST \   -H "Ce-Id: say-goodbye" \   -H "Ce-Specversion: 1.0" \ @@ -410,22 +385,21 @@ This time, it is a `sendoff` and not a greeting based on the previous setup sect Your output should look like this, with another 202 returned: - ``` -> POST /eventing-test/default HTTP/1.1 -> User-Agent: curl/7.35.0 -> Host: broker-ingress.knative-eventing.svc.cluster.local -> Accept: */* -> Ce-Id: say-goodbye -> Ce-Specversion: 1.0 -> Ce-Type: not-greeting -> Ce-Source: sendoff -> Content-Type: application/json -> Content-Length: 26 -> -< HTTP/1.1 202 Accepted -< Date: Sun, 24 Jan 2021 22:33:00 GMT -< Content-Length: 0 +> POST /eventing-test/default HTTP/1.1 +> User-Agent: curl/7.35.0 +> Host: broker-ingress.knative-eventing.svc.cluster.local +> Accept: */* +> Ce-Id: say-goodbye +> Ce-Specversion: 1.0 +> Ce-Type: not-greeting +> Ce-Source: sendoff +> Content-Type: application/json +> Content-Length: 26 +> +< HTTP/1.1 202 Accepted +< Date: Sun, 24 Jan 2021 22:33:00 GMT +< Content-Length: 0 ``` Congratulations, you sent two events! @@ -438,14 +412,12 @@ Now that the events have been sent, how do you know that the correct consumers r Start with the **hello-display** consumer:: - ``` -`$ kubectl -n eventing-test logs -l app=hello-display --tail=100` +$ kubectl -n eventing-test logs -l app=hello-display --tail=100 ``` There isn't much running in this example cluster, so you should see only one event: - ``` ☁️  cloudevents.Event Validation: valid @@ -467,7 +439,6 @@ You've confirmed the **hello-display** consumer received the event! Now check th Start by running the same command but with **goodbye-display**: - ``` $ kubectl -n eventing-test logs -l app=goodbye-display --tail=100 ☁️  cloudevents.Event @@ -494,9 +465,8 @@ So you sent events to each consumer using curl, but what if you want to send an Here is a curl example of a definition for sending an event to both consumers: - ``` -curl -v "" \ +curl -v "http://broker-ingress.knative-eventing.svc.cluster.local/eventing-test/default" \   -X POST \   -H "Ce-Id: say-hello-goodbye" \   -H "Ce-Specversion: 1.0" \ @@ -512,27 +482,25 @@ Here is sample output of what the events look like after they are sent. **Output of the event being sent:** - ``` -> POST /eventing-test/default HTTP/1.1 -> User-Agent: curl/7.35.0 -> Host: broker-ingress.knative-eventing.svc.cluster.local -> Accept: */* -> Ce-Id: say-hello-goodbye -> Ce-Specversion: 1.0 -> Ce-Type: greeting -> Ce-Source: sendoff -> Content-Type: application/json -> Content-Length: 41 -> -< HTTP/1.1 202 Accepted -< Date: Sun, 24 Jan 2021 23:04:15 GMT -< Content-Length: 0 +> POST /eventing-test/default HTTP/1.1 +> User-Agent: curl/7.35.0 +> Host: broker-ingress.knative-eventing.svc.cluster.local +> Accept: */* +> Ce-Id: say-hello-goodbye +> Ce-Specversion: 1.0 +> Ce-Type: greeting +> Ce-Source: sendoff +> Content-Type: application/json +> Content-Length: 41 +> +< HTTP/1.1 202 Accepted +< Date: Sun, 24 Jan 2021 23:04:15 GMT +< Content-Length: 0 ``` **Output of hello-display (showing two events):** - ``` $ kubectl -n eventing-test logs -l app=hello-display --tail=100 ☁️  cloudevents.Event @@ -567,7 +535,6 @@ Data, **Output of goodbye-display (also with two events):** - ``` $ kubectl -n eventing-test logs -l app=goodbye-display --tail=100 ☁️  cloudevents.Event @@ -611,15 +578,15 @@ Internal eventing in cloud events is pretty easy to track if it's going to a pre via: https://opensource.com/article/21/2/knative-eventing 作者:[Jessica Cherry][a] -选题:[lujun9972][b] +选题:[lkxed][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/cherrybomb -[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) +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/computer_space_graphic_cosmic.png [2]: https://opensource.com/article/20/11/knative [3]: https://opensource.com/resources/what-is-kubernetes [4]: https://en.wikipedia.org/wiki/Cloud_native_computing diff --git a/sources/tech/20210226 Navigate your FreeDOS system.md b/sources/tech/20210226 Navigate your FreeDOS system.md index 9397e73e2b..c80a601bbb 100644 --- a/sources/tech/20210226 Navigate your FreeDOS system.md +++ b/sources/tech/20210226 Navigate your FreeDOS system.md @@ -1,15 +1,16 @@ -[#]: subject: (Navigate your FreeDOS system) -[#]: via: (https://opensource.com/article/21/2/freedos-dir) -[#]: author: (Kevin O'Brien https://opensource.com/users/ahuka) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: subject: "Navigate your FreeDOS system" +[#]: via: "https://opensource.com/article/21/2/freedos-dir" +[#]: author: "Kevin O'Brien https://opensource.com/users/ahuka" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " Navigate your FreeDOS system ====== Master the DIR command to navigate your way around FreeDOS. + ![A map with a route highlighted][1] [FreeDOS][2] is an open source implementation of DOS. It's not a remix of Linux, and it is compatible with the operating system that introduced many people to personal computing. This makes it an important resource for running legacy applications, playing retro games, updating firmware on motherboards, and experiencing a little bit of living computer history. In this article, I'll look at some of the essential commands used to navigate a FreeDOS system. @@ -22,7 +23,6 @@ There are many reasons not to work exclusively in your root directory. First of The FreeDOS `CD` command changes your current working subdirectory to another subdirectory. Imagine a computer with the following directory structure: - ``` C:\   \LETTERS\   @@ -34,48 +34,43 @@ C:\   \SCHOOL\ ``` -You start in the `C:\` directory, so to navigate to your love letter directory, you can use `CD`: - +You start in the `C:\` directory, so to navigate to your love letter directory, you can use `CD` : ``` -`C:\>CD \LETTERS\LOVE\` +C:\>CD \LETTERS\LOVE\ ``` -To navigate to your `\LETTERS\BUSINESS` directory, you must specify the path to your business letters from a common fixed point on your filesystem. The most reliable starting location is `C:\`, because it's where _everything_ on your computer is stored. - +To navigate to your `\LETTERS\BUSINESS` directory, you must specify the path to your business letters from a common fixed point on your filesystem. The most reliable starting location is `C:\`, because it's where *everything* on your computer is stored. ``` -`C:\LETTERS\LOVE\>CD C:\LETTERS\BUSINESS` +C:\LETTERS\LOVE\>CD C:\LETTERS\BUSINESS ``` #### Navigating with dots -There's a useful shortcut for navigating your FreeDOS system, which takes the form of dots. Two dots (`..`) tell FreeDOS you want to move "back" or "down" in your directory tree. For instance, the `LETTERS` directory in this example system contains one subdirectory called `LOVE` and another called `BUSINESS`. If you're in `LOVE` currently, and you want to step back and change over to `BUSINESS`, you can just use two dots to represent that move: - +There's a useful shortcut for navigating your FreeDOS system, which takes the form of dots. Two dots (`..` ) tell FreeDOS you want to move "back" or "down" in your directory tree. For instance, the `LETTERS` directory in this example system contains one subdirectory called `LOVE` and another called `BUSINESS`. If you're in `LOVE` currently, and you want to step back and change over to `BUSINESS`, you can just use two dots to represent that move: ``` -C:\LETTERS\LOVE\>CD ..\BUSINESS -C:\LETTERS\BUSINESS\> +C:\LETTERS\LOVE\>CD ..\BUSINESS +C:\LETTERS\BUSINESS\> ``` To get all the way back to your root directory, just use the right number of dots: - ``` -C:\LETTERS\BUSINESS\: CD ..\\.. -C:\> +C:\LETTERS\BUSINESS\: CD ..\.. +C:\> ``` #### Navigational shortcuts -There are some shortcuts for navigating directories, too.  +There are some shortcuts for navigating directories, too. To get back to the root directory from wherever you are: - ``` -C:\LETTERS\BUSINESS\>CD \ -C:\> +C:\LETTERS\BUSINESS\>CD \ +C:\> ``` ### List directory contents with DIR @@ -84,9 +79,8 @@ The `DIR` command displays the contents of a subdirectory, but it can also funct `DIR` displays the contents of the current working subdirectory, and with an optional path argument, it displays the contents of some other subdirectory: - ``` -C:\LETTERS\BUSINESS\>DIR +C:\LETTERS\BUSINESS\>DIR MTG_CARD    TXT  1344 12-29-2020  3:06p NON         TXT   381 12-31-2020  8:12p SOMUCHFO    TXT   889 12-31-2020  9:36p @@ -97,49 +91,49 @@ TEST        BAT    32 01-03-2021 10:34a With a special attribute argument, you can use `DIR` to find and filter out certain kinds of files. There are 10 attributes you can specify: -`H` | Hidden ----|--- -`-H` | Not hidden -`S` | System -`-S` | Not system -`A` | Archivable files -`-A` | Already archived files -`R` | Read-only files -`-R` | Not read-only (i.e., editable and deletable) files -`D` | Directories only, no files -`-D` | Files only, no directories +| - | - | +| :- | :- | +| H | Hidden | +| -H | Not hidden | +| S | System | +| -S | Not system | +| A | Archivable files | +| -A | Already archived files | +| R | Read-only files | +| -R | Not read-only (i.e., editable and deletable) files | +| D | Directories only, no files | +| -D | Files only, no directories | These special designators are denoted with `/A:` followed by the attribute letter. You can enter as many attributes as you like, in order, without leaving a space between them. For instance, to view only hidden directories: - ``` -C:\MEMOS\>DIR /A:HD -.OBSCURE    <DIR>  01-08-2021 10:10p +C:\MEMOS\>DIR /A:HD +.OBSCURE      01-08-2021 10:10p ``` #### Listing in order You can also display the results of your `DIR` command in a specific order. The syntax for this is very similar to using attributes. You leave a space after the `DIR` command or after any other switches, and enter `/O:` followed by a selection. There are 12 possible selections: -`N` | Alphabetical order by file name ----|--- -`-N` | Reverse alphabetical order by file name -`E` | Alphabetical order by file extension -`-E` | Reverse alphabetical order by file extension -`D` | Order by date and time, earliest first -`-D` | Order by date and time, latest first -`S` | By size, increasing -`-S` | By size, decreasing -`C` | By [DoubleSpace][3] compression ratio, lowest to highest (version 6.0 only) -`-C` | By DoubleSpace compression ratio, highest to lowest (version 6.0 only) -`G` | Group directories before other files -`-G` | Group directories after other files +| - | - | +| :- | :- | +| N | Alphabetical order by file name | +| -N | Reverse alphabetical order by file name | +| E | Alphabetical order by file extension | +| -E | Reverse alphabetical order by file extension | +| D | Order by date and time, earliest first | +| -D | Order by date and time, latest first | +| S | By size, increasing | +| -S | By size, decreasing | +| C | By DoubleSpace compression ratio, lowest to highest (version 6.0 only) | +| -C | By DoubleSpace compression ratio, highest to lowest (version 6.0 only) | +| G | Group directories before other files | +| -G | Group directories after other files | To see your directory listing grouped by file extension: - ``` -C:\>DIR /O:E +C:\>DIR /O:E TEST        BAT 01-10-2021 7:11a TIMER       EXE 01-11-2021 6:06a AAA         TXT 01-09-2021 4:27p @@ -149,9 +143,8 @@ This returns a list of files in alphabetical order of file extension. If you're looking for a file you were working on yesterday, you can order by modification time: - ``` -C:\>DIR /O:-D +C:\>DIR /O:-D AAA         TXT 01-09-2021 4:27p TEST        BAT 01-10-2021 7:11a TIMER       EXE 01-11-2021 6:06a @@ -163,12 +156,11 @@ If you need to clean up your hard drive because you're running out of space, you You can use multiple arguments in a `DIR` command to achieve fairly complex results. Remember that each argument has to be separated from its neighbors by a blank space on each side: - ``` -`C:\>DIR /A:A /O:D /P` +C:\>DIR /A:A /O:D /P ``` -This command selects only those files that have not yet been backed up (`/A:A`), orders them by date, beginning with the oldest (`/O:D`), and displays the results on your monitor one page at a time (`/P`). So you can really do some slick stuff with the `DIR` command once you've mastered these arguments and switches. +This command selects only those files that have not yet been backed up (`/A:A` ), orders them by date, beginning with the oldest (`/O:D` ), and displays the results on your monitor one page at a time (`/P` ). So you can really do some slick stuff with the `DIR` command once you've mastered these arguments and switches. ### Terminology @@ -180,24 +172,21 @@ If it has a slash in front, it is a switch. So all switches are also arguments, FreeDOS can be very different from what you're used to if you're used to Windows or macOS, and it can be just different enough if you're used to Linux. A little practice goes a long way, though, so try some of these on your own. You can always get a help message with the `/?` switch. The best way to get comfortable with these commands is to practice using them. -* * * - -_Some of the information in this article was previously published in [DOS lesson 12: Expert DIR use][4] (CC BY-SA 4.0)._ +*Some of the information in this article was previously published in [DOS lesson 12: Expert DIR use][3] (CC BY-SA 4.0).* -------------------------------------------------------------------------------- via: https://opensource.com/article/21/2/freedos-dir 作者:[Kevin O'Brien][a] -选题:[lujun9972][b] +选题:[lkxed][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/ahuka -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/map_route_location_gps_path.png?itok=RwtS4DsU (A map with a route highlighted) +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/map_route_location_gps_path.png [2]: https://www.freedos.org/ -[3]: https://en.wikipedia.org/wiki/DriveSpace -[4]: https://www.ahuka.com/dos-lessons-for-self-study-purposes/dos-lesson-12-expert-dir-use/ +[3]: https://www.ahuka.com/dos-lessons-for-self-study-purposes/dos-lesson-12-expert-dir-use/ diff --git a/sources/tech/20210301 5 tips for choosing an Ansible collection that-s right for you.md b/sources/tech/20210301 5 tips for choosing an Ansible collection that-s right for you.md index 5d7b220c05..1b9bd5eea2 100644 --- a/sources/tech/20210301 5 tips for choosing an Ansible collection that-s right for you.md +++ b/sources/tech/20210301 5 tips for choosing an Ansible collection that-s right for you.md @@ -1,17 +1,19 @@ -[#]: subject: (5 tips for choosing an Ansible collection that's right for you) -[#]: via: (https://opensource.com/article/21/3/ansible-collections) -[#]: author: (Tadej Borovšak https://opensource.com/users/tadeboro) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: subject: "5 tips for choosing an Ansible collection that's right for you" +[#]: via: "https://opensource.com/article/21/3/ansible-collections" +[#]: author: "Tadej Borovšak https://opensource.com/users/tadeboro" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " 5 tips for choosing an Ansible collection that's right for you ====== -Try these strategies to find and vet collections of Ansible plugins and -modules before you install them. -![Woman sitting in front of her computer][1] +Try these strategies to find and vet collections of Ansible plugins and modules before you install them. + +![Women in computing and open source][1] + +Image by: Ray Smith In August 2020, Ansible issued its first release since the developers split the core functionality from the vast majority of its modules and plugins. A few [basic Ansible modules][2] remain part of core Ansible—modules for templating configuration files, managing services, and installing packages. All the other modules and plugins found their homes in dedicated [Ansible collections][3]. @@ -25,7 +27,6 @@ With the introduction of Ansible collections, [Ansible Galaxy][7] became the cen Ansible comes bundled with the `ansible-galaxy` tool for installing collections. Once you know what Ansible collection you want to install, things are relatively straightforward: Run the installation command listed on the Ansible Galaxy page. Ansible takes care of downloading and installing it. For example: - ``` $ ansible-galaxy collection install sensu.sensu_go Process install dependency map @@ -44,7 +45,7 @@ The ability to install Ansible collections offered a lot more control over the c Now users are solely responsible for the quality of content they use to build Ansible playbooks. But how can you separate high-quality content from the rest? Here are five things to check when evaluating an Ansible collection. -#### 1\. Documentation +#### 1. Documentation Once you find a potential candidate on Ansible Galaxy, check its documentation first. In an ideal world, each Ansible collection would have a dedicated documentation site. For example, the [Sensu Go][8] and [F5 Networks][9] Ansible collections have them. Most other Ansible collections come only with a README file, but this will change for the better once the documentation tools mature. @@ -52,10 +53,9 @@ The Ansible collection's documentation should contain at least a quickstart tuto Another essential part of the documentation is a detailed module, plugin, and role reference guide. Collection authors do not always publish those guides on the internet, but they should always be accessible with the `ansible-doc` tool. - ``` $ ansible-doc community.sops.sops_encrypt -> SOPS_ENCRYPT    (/home/tadej/.ansible/collections/ansible> +> SOPS_ENCRYPT    (/home/tadej/.ansible/collections/ansible>         Allows to encrypt binary data (Base64 encoded), text         data, JSON or YAML data with sops. @@ -63,7 +63,7 @@ $ ansible-doc community.sops.sops_encrypt   * This module is maintained by The Ansible Community OPTIONS (= is mandatory): -\- attributes +- attributes         The attributes the resulting file or directory should         have.         To get supported flags look at the man page for @@ -78,18 +78,17 @@ OPTIONS (= is mandatory): ... ``` -#### 2\. Playbook readability +#### 2. Playbook readability An Ansible playbook should serve as a human-readable description of the desired state. To achieve that, modules from the Ansible collection under evaluation should have a consistent user interface and descriptive parameter names. For example, if Ansible modules interact with a web service, authentication parameters should be separated from the rest. And all modules should use the same authentication parameters if possible. - ``` -\- name: Create a check that runs every 30 seconds +- name: Create a check that runs every 30 seconds   sensu.sensu_go.check: -    auth: &auth -      url: +    auth: &auth +      url: https://my.sensu.host:8080       user: demo       password: demo-pass     name: check @@ -97,36 +96,34 @@ For example, if Ansible modules interact with a web service, authentication para     interval: 30     publish: true -\- name: Create a filter +- name: Create a filter   sensu.sensu_go.filter: -    # Reuse the authentication data from before +     # Reuse the authentication data from before     auth: *auth     name: filter     action: deny     expressions: -      - event.check.interval == 10 +       - event.check.interval == 10       - event.check.occurrences == 1 ``` -#### 3\. Basic functionality +#### 3. Basic functionality Before you start using third-party Ansible content in production, always check each Ansible module's basic functionality. Probably the most critical property to look for is the result. Ansible modules and roles that enforce a state are much easier to use than their action-executing counterparts. This is because you can update your Ansible playbook and rerun it without risking a significant breakage. - ``` -\- name: Command module executes an action -> fails on re-run +- name: Command module executes an action -> fails on re-run   ansible.builtin.command: useradd demo -\- name: User module enforces a state -> safe to re-run +- name: User module enforces a state -> safe to re-run   ansible.builtin.user:     name: demo ``` You should also expect support for [check mode][12], which simulates the change without making it. If you combine check mode with state enforcement, you get a configuration drift detector for free. - ``` $ ansible-playbook --check playbook.yaml @@ -142,11 +139,11 @@ host        : ok=5    changed=2    unreachable=0    failed=0                       skipped=3        rescued=0   ignored=0 ``` -#### 4\. Implementation robustness +#### 4. Implementation robustness A robustness check is a bit harder to perform if you've never developed an Ansible module or role before. Checking the continuous integration/continuous delivery (CI/CD) configuration files should give you a general idea of what is tested. Finding `ansible-test` and `molecule` commands in the test suite is an excellent sign. -#### 5\. Maintenance +#### 5. Maintenance During your evaluation, you should also take a look at the issue tracker and development activity. Finding old issues with no response from maintainers is one sign of a poorly maintained Ansible collection. @@ -163,15 +160,15 @@ If you are thinking about creating your own Ansible Collection, you can download via: https://opensource.com/article/21/3/ansible-collections 作者:[Tadej Borovšak][a] -选题:[lujun9972][b] +选题:[lkxed][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/tadeboro -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_3.png?itok=qw2A18BM (Woman sitting in front of her computer) +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/OSDC_women_computing_3.png [2]: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/ [3]: https://docs.ansible.com/ansible/latest/collections/index.html#list-of-collections [4]: https://galaxy.ansible.com/sensu/sensu_go diff --git a/sources/tech/20210301 Build a home thermostat with a Raspberry Pi.md b/sources/tech/20210301 Build a home thermostat with a Raspberry Pi.md index 434e6a5796..35ec8b7951 100644 --- a/sources/tech/20210301 Build a home thermostat with a Raspberry Pi.md +++ b/sources/tech/20210301 Build a home thermostat with a Raspberry Pi.md @@ -1,36 +1,34 @@ -[#]: subject: (Build a home thermostat with a Raspberry Pi) -[#]: via: (https://opensource.com/article/21/3/thermostat-raspberry-pi) -[#]: author: (Joe Truncale https://opensource.com/users/jtruncale) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: subject: "Build a home thermostat with a Raspberry Pi" +[#]: via: "https://opensource.com/article/21/3/thermostat-raspberry-pi" +[#]: author: "Joe Truncale https://opensource.com/users/jtruncale" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " Build a home thermostat with a Raspberry Pi ====== -The ThermOS project is an answer to the many downsides of off-the-shelf -smart thermostats. +The ThermOS project is an answer to the many downsides of off-the-shelf smart thermostats. + ![Orange home vintage thermostat][1] -My wife and I moved into a new home in October 2020. As soon as it started getting cold, we realized some shortcomings of the home's older heating system (including one heating zone that was _always_ on). We had Nest thermostats in our previous home, and the current setup was not nearly as convenient. There are multiple thermostats in our house, and some had programmed heating schedules, others had different schedules, some had none at all. +Image by: Photo by [Moja Msanii][2] on [Unsplash][3] -![Old thermostats][2] +My wife and I moved into a new home in October 2020. As soon as it started getting cold, we realized some shortcomings of the home's older heating system (including one heating zone that was *always* on). We had Nest thermostats in our previous home, and the current setup was not nearly as convenient. There are multiple thermostats in our house, and some had programmed heating schedules, others had different schedules, some had none at all. -The home's previous owner left notes explaining how some of the thermostats worked. (Joseph Truncale, [CC BY-SA 4.0][3]) +![Old thermostats][4] + +The home's previous owner left notes explaining how some of the thermostats worked. (Joseph Truncale, CC BY-SA 4.0) It was time for a change, but the house has some constraints: - * It was built in the late 1960s with a renovation during the '90s. - * The heat is hydronic (hot water baseboard). - * It has six thermostats for the six heating zones. - * There are only two wires that go to each thermostat for heat (red and white). +* It was built in the late 1960s with a renovation during the '90s. +* The heat is hydronic (hot water baseboard). +* It has six thermostats for the six heating zones. +* There are only two wires that go to each thermostat for heat (red and white). - - -![Furnace valves][4] - -Taco (pronounced TAY-KO) zone valves at the furnace. (Joseph Truncale, [CC BY-SA 4.0][3]) +![Furnace valves][5] ### To buy or to build? @@ -38,36 +36,29 @@ I wanted "smart" thermostat control for all of the heat zones (schedules, automa **Option 1: A Nest or Ecobee** - * It's expensive: No smart thermostat can handle multiple zones, so I would need one for each zone (~$200*6 = $1,200). - * It's difficult: I would have to rerun the thermostat wire to get the infamous [C wire][5], which enables continuous power to the thermostat. The wires are 20 to 100 feet each, in-wall, and _might_ be stapled to the studs. +* It's expensive: No smart thermostat can handle multiple zones, so I would need one for each zone (~$200*6 = $1,200). +* It's difficult: I would have to rerun the thermostat wire to get the infamous [C wire][6], which enables continuous power to the thermostat. The wires are 20 to 100 feet each, in-wall, and might be stapled to the studs. +**Option 2: A battery-powered thermostat** such as the [Sensi WiFi thermostat][7] +* The batteries last only a month or two. +* It's not HomeKit-compatible in battery-only mode. -**Option 2: A battery-powered thermostat** such as the [Sensi WiFi thermostat][6] +**Option 3: A commercial-off-the-shelf thermostat**, but only one exists (kind of): [Honeywell's TrueZONE][8] - * The batteries last only a month or two. - * It's not HomeKit-compatible in battery-only mode. +* It's old and poorly supported (it was released in 2008). +* It's expensive—more than $300 for just the controller, and you need a [RedLINK gateway][9] for a shoddy app to work. - - -**Option 3: A commercial-off-the-shelf thermostat**, but only one exists (kind of): [Honeywell's TrueZONE][7]  - - * It's old and poorly supported (it was released in 2008). - * It's expensive—more than $300 for just the controller, and you need a [RedLINK gateway][8] for a shoddy app to work. - - - -And the winner is…  +And the winner is… **Option 4: Build my own!** -I decided to build my own multizone smart thermostat, which I named [ThermOS][9]. - - * It's centralized at the furnace (you need one device, not six). - * It uses the existing in-wall thermostat wires. - * It's HomeKit compatible, complete with automation, scheduling, home/away, etc. - * Anddddd it's… fun? Yeah, fun… I think. +I decided to build my own multizone smart thermostat, which I named [ThermOS][10]. +* It's centralized at the furnace (you need one device, not six). +* It uses the existing in-wall thermostat wires. +* It's HomeKit compatible, complete with automation, scheduling, home/away, etc. +* Anddddd it's… fun? Yeah, fun… I think. ### The ThermOS hardware @@ -75,79 +66,62 @@ I knew that I wanted to use a Raspberry Pi. Since they've gotten so inexpensive, Here's a full list of the parts I used: -Name | Quantity | Price ----|---|--- -Raspberry Pi 4 Model B 2GB | 1 | $29.99 -Raspberry Pi 4 official 15W power supply | 1 | $6.99 -Inland 400 tie-point breadboard | 1 | $2.99 -Inland 8 channel 5V relay module for Arduino | 1 | $8.99 -Inland DuPont jumper wire 20cm (3 pack) | 1 | $4.99 -DS18B20 temperature sensor (genuine) from Mouser.com | 6 | $6.00 -3-pin screw terminal blocks (40 pack) | 1 | $7.99 -RPi GPIO terminal block breakout board module for Raspberry Pi | 1 | $17.99 -Alligator clip test leads (10 pack) | 1 | $5.89 -Southwire 18/2 thermostat wire (50ft) | 1 | $10.89 -Shrinkwrap | 1 | $4.99 -Solderable breadboard (5 pack) | 1 | $11.99 -PCB mounting brackets (50 pack) | 1 | $7.99 -Plastic housing/enclosure | 1 | $27.92 +| Name | Quantity | Price | +| :- | :- | :- | +| Raspberry Pi 4 Model B 2GB | 1 | $29.99 | +| Raspberry Pi 4 official 15W power supply | 1 | $6.99 | +| Inland 400 tie-point breadboard | 1 | $2.99 | +| Inland 8 channel 5V relay module for Arduino | 1 | $8.99 | +| Inland DuPont jumper wire 20cm (3 pack) | 1 | $4.99 | +| DS18B20 temperature sensor (genuine) from Mouser.com | 6 | $6.00 | +| 3-pin screw terminal blocks (40 pack) | 1 | $7.99 | +| RPi GPIO terminal block breakout board module for Raspberry Pi | 1 | $17.99 | +| Alligator clip test leads (10 pack) | 1 | $5.89 | +| Southwire 18/2 thermostat wire (50ft) | 1 | $10.89 | +| Shrinkwrap | 1 | $4.99 | +| Solderable breadboard (5 pack) | 1 | $11.99 | +| PCB mounting brackets (50 pack) | 1 | $7.99 | +| Plastic housing/enclosure | 1 | $27.92 | -I began drawing out the hardware diagram on [draw.io][10] and realized I lacked some crucial knowledge about the furnace. I opened the side panel and found the step-down transformer that takes the 120V electrical line and makes it 24V for the heating system. If your heating system is anything like mine, you'll see a lot of jumper wires between the Taco zone valves. Terminal 3 on the Taco is jumped across all of my zone valves. This is because it doesn't matter how many valves are on/open—it just controls the circulator pump. If any combination of one to five valves is open, it should be on; if no valves are open, it should be off… simple! +I began drawing out the hardware diagram on [draw.io][11] and realized I lacked some crucial knowledge about the furnace. I opened the side panel and found the step-down transformer that takes the 120V electrical line and makes it 24V for the heating system. If your heating system is anything like mine, you'll see a lot of jumper wires between the Taco zone valves. Terminal 3 on the Taco is jumped across all of my zone valves. This is because it doesn't matter how many valves are on/open—it just controls the circulator pump. If any combination of one to five valves is open, it should be on; if no valves are open, it should be off… simple! -![Furnace wiring architecture][11] - -ThermOS architecture using one zone. (Joseph Truncale, [CC BY-SA 4.0][3]) +![Furnace wiring architecture][12] At its core, a thermostat is just a type of switch. Once the thermistor (temp sensor) inside the thermostat detects a lower temperature, the switch closes and completes the 24V circuit. Instead of having a thermostat in every room, this project keeps all of them right next to the furnace so that all six-zone valves can be controlled by a relay module using six of the eight relays. The Raspberry Pi acts as the brains of the thermostat and controls each relay independently. -![Manually setting relays using Raspberry Pi and Python][12] - -Manually setting the relays using the Raspberry Pi and Python. (Joseph Truncale, [CC BY-SA 4.0][3]) +![Manually setting relays using Raspberry Pi and Python][13] The next problem was how to get temperature readings from each room. I could have a wireless temperature sensor in each room running on an Arduino or Raspberry Pi, but that can get expensive and complicated. Instead, I wanted to reuse the existing thermostat wire in the walls but purely for temperature sensors. -The "1-wire" [DS18B20][13] temperature sensor appeared to fit the bill: +The "1-wire" [DS18B20][14] temperature sensor appeared to fit the bill: - * It has an accuracy of +/- 0.5°C or 0.9°F. - * It uses the "1-wire" protocol for data. - * Most importantly, the DS18B20 can use "[parasitic power][14]" mode where it needs just two wires for power and data. Just a heads up… almost all of the DS18B20s out there are [counterfeit][15]. I purchased a few (hoping they were genuine), but they wouldn't work when I tried to use parasitic power. I then bought real ones from [Mouser.com][16], and they worked like a charm! +* It has an accuracy of +/- 0.5°C or 0.9°F. +* It uses the "1-wire" protocol for data. +* Most importantly, the DS18B20 can use "[parasitic power][15]" mode where it needs just two wires for power and data. Just a heads up… almost all of the DS18B20s out there are [counterfeit][16]. I purchased a few (hoping they were genuine), but they wouldn't work when I tried to use parasitic power. I then bought real ones from [Mouser.com][17], and they worked like a charm! +![Temperature sensors][18] +Starting with a breadboard and all the components locally, I started writing code to interact with all of it. Once I proved out the concept, I added the existing in-wall thermostat wire into the mix. I got consistent readings with that setup, so I set out to make them a bit more polished. With help from my [dad][19], the self-proclaimed "just good enough" solderer, we soldered leads to the three-pin screw terminals (to avoid overheating the sensor) and then attached the sensor into the terminals. Now the sensors can be attached with wire nuts to the existing in-wall wiring. -![Temperature sensors][17] - -Three DS18B20s connected using parasitic power on the same GPIO bus. (Joseph Truncale, [CC BY-SA 4.0][3]) - -Starting with a breadboard and all the components locally, I started writing code to interact with all of it. Once I proved out the concept, I added the existing in-wall thermostat wire into the mix. I got consistent readings with that setup, so I set out to make them a bit more polished. With help from my [dad][18], the self-proclaimed "just good enough" solderer, we soldered leads to the three-pin screw terminals (to avoid overheating the sensor) and then attached the sensor into the terminals. Now the sensors can be attached with wire nuts to the existing in-wall wiring. - -![Attaching temperature sensors][19] - -The DS18B20s are attached to the old thermostat location using the existing wires. (Joseph Truncale, [CC BY-SA 4.0][3]) +![Attaching temperature sensors][20] I'm still in the process of "prettifying" my temperature sensor wall mounts, but I've gone through a few 3D printing revisions, and I think I'm almost there. -![Wall mounts][20] - -I started with a Nest-style mount and made my way to a flush-mount style. (Joseph Truncale, [CC BY-SA 4.0][3]) +![Wall mounts][21] ### The ThermOS software -As usual, writing the logic wasn't the hard part. However, deciding on the application architecture and framework was a confusing, multi-day process. I started out evaluating open source projects like [PiHome][21], but it relied on specific hardware _and_ was written in PHP. I'm a Python fan and decided to start from scratch and write my own REST API. +As usual, writing the logic wasn't the hard part. However, deciding on the application architecture and framework was a confusing, multi-day process. I started out evaluating open source projects like [PiHome][22], but it relied on specific hardware *and* was written in PHP. I'm a Python fan and decided to start from scratch and write my own REST API. -Since HomeKit integration was so important, I figured I would eventually write a [HomeBridge][22] plugin to integrate it. I didn't realize that there was an entire Python HomeKit framework called [HAP-Python][23] that implements the accessory protocol. It helped me get a proof of concept running and controlled through my iPhone's Home app within 30 minutes. +Since HomeKit integration was so important, I figured I would eventually write a [HomeBridge][23] plugin to integrate it. I didn't realize that there was an entire Python HomeKit framework called [HAP-Python][24] that implements the accessory protocol. It helped me get a proof of concept running and controlled through my iPhone's Home app within 30 minutes. -![ThermOS HomeKit integration][24] +![ThermOS HomeKit integration][25] -Initial version of Apple HomeKit integration, with help from the HAP-Python framework. (Joseph Truncale, [CC BY-SA 4.0][3]) - -![ThermOS software architecture][25] - -ThermOS software architecture (Joseph Truncale, [CC BY-SA 4.0][3]) +![ThermOS software architecture][26] The rest of the "temp" logic is relatively straightforward, but I do want to highlight a piece that I initially missed. My code was running for a few days, and I was working on the hardware, when I noticed that my relays were turning on and off every few seconds. This "short-cycling" isn't necessarily harmful, but it certainly isn't efficient. To avoid that, I added some thresholding to make sure the heat toggles only when it's +/- 0.5C°. -Here is the threshold logic (you can see the [rubber-duck debugging][26] in the comments): - +Here is the threshold logic (you can see the [rubber-duck debugging][27] in the comments): ``` # check that we want heat @@ -155,7 +129,7 @@ if self.target_state.value == 1:     # if heat relay is already on, check if above threshold     # if above, turn off .. if still below keep on     if GPIO.input(self.relay_pin): -        if self.current_temp.value - self.target_temp.value >= 0.5: +        if self.current_temp.value - self.target_temp.value >= 0.5:             status = 'HEAT ON - TEMP IS ABOVE TOP THRESHOLD, TURNING OFF'             GPIO.output(self.relay_pin, GPIO.LOW)         else: @@ -163,96 +137,87 @@ if self.target_state.value == 1:             GPIO.output(self.relay_pin, GPIO.HIGH)     # if heat relay is not already on, check if below threshold     elif not GPIO.input(self.relay_pin): -        if self.current_temp.value - self.target_temp.value <= -0.5: +        if self.current_temp.value - self.target_temp.value <= -0.5:             status = 'HEAT OFF - TEMP IS BELOW BOTTOM THRESHOLD, TURNING ON'             GPIO.output(self.relay_pin, GPIO.HIGH)         else:           status = 'HEAT OFF - KEEPING OFF' ``` -![Thresholding][27] - -Thresholding allows longer stretches of time where the heat is off. (Joseph Truncale, [CC BY-SA 4.0][3]) +![Thresholding][28] And I achieved my ultimate goal—to be able to control all of it from my phone. -![ThermOS as a HomeKit Hub][28] - -ThermOS as a HomeKit Hub (Joseph Truncale, [CC BY-SA 4.0][3]) +![ThermOS as a HomeKit Hub][29] ### Putting my ThermOS in a lunchbox My proof of concept was pretty messy. -![Initial ThermOS setup][29] +![Initial ThermOS setup][30] -ThermOS controlling a single zone (before packaging it) (Joseph Truncale, [CC BY-SA 4.0][3]) - -With the software and general hardware design in place, I started figuring out how to package all of the components in a more permanent and polished form. One of my main concerns for a permanent installation was to use a breadboard with DuPont jumper wires. I ordered some [solderable breadboards][30] and a [screw terminal breakout board][31] (thanks [@arduima][32] for the Raspberry Pi GPIO pins). +With the software and general hardware design in place, I started figuring out how to package all of the components in a more permanent and polished form. One of my main concerns for a permanent installation was to use a breadboard with DuPont jumper wires. I ordered some [solderable breadboards][31] and a [screw terminal breakout board][32] (thanks [@arduima][33] for the Raspberry Pi GPIO pins). Here's what the solderable breadboard with mounts and enclosure looked like in progress. -![ThermOS hardware being packaged][33] - -Putting the ThermOS in a lunchbox. (Joseph Truncale, [CC BY-SA 4.0][3]) +![ThermOS hardware][34] And here it is, mounted in the boiler room. -![ThermOS mounted][34] - -ThermOS mounted (Joseph Truncale, [CC BY-SA 4.0][3]) +![ThermOS mounted][35] Now I just need to organize and label the wires, and then I can start swapping the remainder of the thermostats over to ThermOS. And I'll be on to my next project: ThermOS for my central air conditioning. -* * * +Image by: (Joseph Truncale, CC BY-SA 4.0) -_This originally appeared on [Medium][35] and is republished with permission._ +*This originally appeared on [Medium][36] and is republished with permission.* -------------------------------------------------------------------------------- via: https://opensource.com/article/21/3/thermostat-raspberry-pi 作者:[Joe Truncale][a] -选题:[lujun9972][b] +选题:[lkxed][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/jtruncale -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/home-thermostat.jpg?itok=wuV1XL7t (Orange home vintage thermostat) -[2]: https://opensource.com/sites/default/files/uploads/oldthermostats.jpeg (Old thermostats) -[3]: https://creativecommons.org/licenses/by-sa/4.0/ -[4]: https://opensource.com/sites/default/files/uploads/furnacevalves.jpeg (Furnace valves) -[5]: https://smartthermostatguide.com/thermostat-c-wire-explained/ -[6]: https://www.amazon.com/Emerson-Thermostat-Version-Energy-Certified/dp/B01NB1OB0I -[7]: https://www.honeywellhome.com/us/en/products/air/forced-air-zone-panels/truezone-hz432-panel-hz432-u/ -[8]: https://www.amazon.com/Honeywell-Redlink-Enabled-Internet-THM6000R7001/dp/B0783HK9ZZ -[9]: https://github.com/truncj/thermos -[10]: http://draw.io/ -[11]: https://opensource.com/sites/default/files/uploads/furnacewiring.png (Furnace wiring architecture) -[12]: https://opensource.com/sites/default/files/uploads/settingrelays.gif (Manually setting relays using Raspberry Pi and Python) -[13]: https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf -[14]: https://learn.openenergymonitor.org/electricity-monitoring/temperature/DS18B20-temperature-sensing -[15]: https://github.com/cpetrich/counterfeit_DS18B20 -[16]: https://www.mouser.com/ -[17]: https://opensource.com/sites/default/files/uploads/tempsensors.png (Temperature sensors) -[18]: https://twitter.com/jofredrick -[19]: https://opensource.com/sites/default/files/uploads/attachingsensors.jpeg (Attaching temperature sensors) -[20]: https://opensource.com/sites/default/files/uploads/wallmount.jpeg (Wall mounts) -[21]: https://github.com/pihome-shc/pihome -[22]: https://github.com/homebridge/homebridge -[23]: https://github.com/ikalchev/HAP-python -[24]: https://opensource.com/sites/default/files/uploads/iphoneintegration.gif (ThermOS HomeKit integration) -[25]: https://opensource.com/sites/default/files/uploads/thermosarchitecture.png (ThermOS software architecture) -[26]: https://en.wikipedia.org/wiki/Rubber_duck_debugging -[27]: https://opensource.com/sites/default/files/uploads/thresholding.png (Thresholding) -[28]: https://opensource.com/sites/default/files/uploads/thermoshomekit.png (ThermOS as a HomeKit Hub) -[29]: https://opensource.com/sites/default/files/uploads/unpackaged.jpeg (Initial ThermOS setup) -[30]: https://www.amazon.com/gp/product/B07ZV8FWM4/r -[31]: https://www.amazon.com/gp/product/B084C69VSQ/ -[32]: https://twitter.com/dimitri_koshkin -[33]: https://opensource.com/sites/default/files/uploads/breadboard.png (ThermOS hardware being packaged) -[34]: https://opensource.com/sites/default/files/uploads/mounted.png (ThermOS mounted) -[35]: https://joetruncale.medium.com/thermos-d089e1c4974b +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/home-thermostat.jpg +[2]: https://unsplash.com/@mojamsanii?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]: https://unsplash.com/s/photos/thermostat?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: https://opensource.com/sites/default/files/uploads/oldthermostats.jpeg +[5]: https://opensource.com/sites/default/files/uploads/furnacevalves.jpeg +[6]: https://smartthermostatguide.com/thermostat-c-wire-explained/ +[7]: https://www.amazon.com/Emerson-Thermostat-Version-Energy-Certified/dp/B01NB1OB0I +[8]: https://www.honeywellhome.com/us/en/products/air/forced-air-zone-panels/truezone-hz432-panel-hz432-u/ +[9]: https://www.amazon.com/Honeywell-Redlink-Enabled-Internet-THM6000R7001/dp/B0783HK9ZZ +[10]: https://github.com/truncj/thermos +[11]: http://draw.io/ +[12]: https://opensource.com/sites/default/files/uploads/furnacewiring.png +[13]: https://opensource.com/sites/default/files/uploads/settingrelays.gif +[14]: https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf +[15]: https://learn.openenergymonitor.org/electricity-monitoring/temperature/DS18B20-temperature-sensing +[16]: https://github.com/cpetrich/counterfeit_DS18B20 +[17]: https://www.mouser.com/ +[18]: https://opensource.com/sites/default/files/uploads/tempsensors.png +[19]: https://twitter.com/jofredrick +[20]: https://opensource.com/sites/default/files/uploads/attachingsensors.jpeg +[21]: https://opensource.com/sites/default/files/uploads/wallmount.jpeg +[22]: https://github.com/pihome-shc/pihome +[23]: https://github.com/homebridge/homebridge +[24]: https://github.com/ikalchev/HAP-python +[25]: https://opensource.com/sites/default/files/uploads/iphoneintegration.gif +[26]: https://opensource.com/sites/default/files/uploads/thermosarchitecture.png +[27]: https://en.wikipedia.org/wiki/Rubber_duck_debugging +[28]: https://opensource.com/sites/default/files/uploads/thresholding.png +[29]: https://opensource.com/sites/default/files/uploads/thermoshomekit.png +[30]: https://opensource.com/sites/default/files/uploads/unpackaged.jpeg +[31]: https://www.amazon.com/gp/product/B07ZV8FWM4/r +[32]: https://www.amazon.com/gp/product/B084C69VSQ/ +[33]: https://twitter.com/dimitri_koshkin +[34]: https://opensource.com/sites/default/files/uploads/breadboard.png +[35]: https://opensource.com/sites/default/files/uploads/mounted.png +[36]: https://joetruncale.medium.com/thermos-d089e1c4974b diff --git a/sources/tech/20210302 Learn Java with object orientation by building a classic Breakout game.md b/sources/tech/20210302 Learn Java by building a classic arcade game.md similarity index 58% rename from sources/tech/20210302 Learn Java with object orientation by building a classic Breakout game.md rename to sources/tech/20210302 Learn Java by building a classic arcade game.md index 121fe21b62..f5f43c98f4 100644 --- a/sources/tech/20210302 Learn Java with object orientation by building a classic Breakout game.md +++ b/sources/tech/20210302 Learn Java by building a classic arcade game.md @@ -1,37 +1,35 @@ -[#]: subject: (Learn Java with object orientation by building a classic Breakout game) -[#]: via: (https://opensource.com/article/21/3/java-object-orientation) -[#]: author: (Vaneska Sousa https://opensource.com/users/vaneska) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: subject: "Learn Java by building a classic arcade game" +[#]: via: "https://opensource.com/article/21/3/java-object-orientation" +[#]: author: "Vaneska Sousa https://opensource.com/users/vaneska" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " -Learn Java with object orientation by building a classic Breakout game +Learn Java by building a classic arcade game ====== -Practice how to structure a project and write Java code while having fun -building a fun game. +Practice how to structure a project and write Java code while having fun building a fun game. + ![Learning and studying technology is the key to success][1] -As a second-semester student in systems and digital media at the Federal University of Ceará in Brazil, I was given the assignment to remake the classic Atari 2600 [Breakout game][2] from 1978. I am still in my infancy in learning software development, and this was a challenging experience. It was also a gainful one because I learned a lot, especially about applying object-oriented concepts. +Image by: [WOCinTech Chat][2], [CC BY 2.0][3] -![Breakout game][3] +As a second-semester student in systems and digital media at the Federal University of Ceará in Brazil, I was given the assignment to remake the classic Atari 2600 [Breakout game][4] from 1978. I am still in my infancy in learning software development, and this was a challenging experience. It was also a gainful one because I learned a lot, especially about applying object-oriented concepts. -(Vaneska Karen, [CC BY-SA 4.0][4]) +![Breakout game][5] I'll explain how I accomplished this challenge, and if you follow the step-by-step instructions, at the end of this article, you will have the first pieces of your own classic Breakout game. ### Choosing Java and TotalCross -Several of my courses use [Processing][5], a software engine that uses [Java][6]. Java is a great language for learning programming concepts, in part because it's a strongly typed language. +Several of my courses use [Processing][6], a software engine that uses [Java][7]. Java is a great language for learning programming concepts, in part because it's a strongly typed language. Despite being free to choose any language or framework for my Breakout project, I chose to continue in Java to apply what I've learned in my coursework. I also wanted to use a framework so that I did not need to do everything from scratch. I considered using Godot, but that would mean I would hardly need to program at all. -Instead, I chose [TotalCross][7]. It is an open source software development kit (SDK) and framework with a simple game engine that generates code for [Linux Arm][8] devices (like the Raspberry Pi) and smartphones. Also, because I work for TotalCross, I have access to developers with much more experience than I have and know the platform very well. It seemed to be the safest way and, despite some strife, I don't regret it one bit. It was very cool to develop the whole project and see it running on the phone and the [Raspberry Pi][9]. +Instead, I chose [TotalCross][8]. It is an open source software development kit (SDK) and framework with a simple game engine that generates code for [Linux Arm][9] devices (like the Raspberry Pi) and smartphones. Also, because I work for TotalCross, I have access to developers with much more experience than I have and know the platform very well. It seemed to be the safest way and, despite some strife, I don't regret it one bit. It was very cool to develop the whole project and see it running on the phone and the [Raspberry Pi][10]. -![Breakout remake][10] - -Breakout remake built with Java and TotalCross running on Raspberry Pi 3 Model B. (Vaneska Karen, [CC BY-SA 4.0][4]) +![Breakout remake][11] ### Define the project mechanics and structure @@ -39,63 +37,52 @@ When starting to develop any application, and especially a game, you need to con #### Game mechanics - 1. The platform moves left or right, according to the user's command. When it reaches an end, it hits the "wall" (edge). - 2. When the ball hits the platform, it returns in the opposite direction it came from. - 3. Each time the ball hits a "brick" (blue, green, yellow, orange, or red), the brick disappears. - 4. When all the bricks in level 01 have been destroyed, new ones appear (in the same position as the previous one), and the ball's speed increases. - 5. When all the bricks in level 02 have been destroyed, the game continues without obstacles on the screen. - 6. The game ends when the ball falls. - - +1. The platform moves left or right, according to the user's command. When it reaches an end, it hits the "wall" (edge). +2. When the ball hits the platform, it returns in the opposite direction it came from. +3. Each time the ball hits a "brick" (blue, green, yellow, orange, or red), the brick disappears. +4. When all the bricks in level 01 have been destroyed, new ones appear (in the same position as the previous one), and the ball's speed increases. +5. When all the bricks in level 02 have been destroyed, the game continues without obstacles on the screen. +6. The game ends when the ball falls. #### Project structure - * `RunBreakoutApplication.java` is the class responsible for calling the class that inherits the `GameEngine` and runs the simulator. - * `Breakout.java` is the main class, which inherits from the `GameEngine` class and "assembles" the game, where it will call objects, define positions, etc. - * The `sprites` package is where all the classes responsible for the sprites (e.g., the image and behavior of the blocks, platform, and ball) go. - * The `util` packages contain classes used to facilitate project maintenance, such as constants, image initialization, and colors. - - +* RunBreakoutApplication.java is the class responsible for calling the class that inherits the `GameEngine` and runs the simulator. +* Breakout.java is the main class, which inherits from the `GameEngine` class and "assembles" the game, where it will call objects, define positions, etc. +* The `sprites` package is where all the classes responsible for the sprites (e.g., the image and behavior of the blocks, platform, and ball) go. +* The `util` packages contain classes used to facilitate project maintenance, such as constants, image initialization, and colors. ### Get hands-on with code -First, install the [TotalCross plugin from VSCode][11]. If you are using another [integrated development environment][12] (IDE), check TotalCross's documentation for installation instructions.  - -If you're using the plugin, just press `Ctrl`+`P`, type `totalcross`, and click `Create new project`. Fill in the requested information: - - * `Folder name:` gameTC - * `ArtifactId:` com.totalcross - * `Project name:` Breakout - * `TotalCross version:` 6.1.1 (or the most recent one) - * `Build platforms:` -Android and -Linux_arm (select the platforms you want) +First, install the [TotalCross plugin from VSCode][12]. If you are using another [integrated development environment][13] (IDE), check TotalCross's documentation for installation instructions. +If you're using the plugin, just press `Ctrl` +`P`, type `totalcross`, and click `Create new project`. Fill in the requested information: +* Folder name: gameTC +* ArtifactId: com.totalcross +* Project name: Breakout +* TotalCross version: 6.1.1 (or the most recent one) +* Build platforms: -Android and -Linux_arm (select the platforms you want) When filling in the fields above and generating the project, if you are in the `RunBreakoutApplication.java` class, right-clicking on it and clicking "run" will open the simulator, and "Hello World!" will appear on your screen if you have created your Java project with TotalCross properly. -![HelloWorld project structure][13] +![HelloWorld project structure][14] -(Vaneska Karen, [CC BY-SA 4.0][4]) +If you have a problem, check the [documentation][15] or ask the [TotalCross community][16] on Telegram for help. -If you have a problem, check the [documentation][14] or ask the [TotalCross community][15] on Telegram for help. - -After the project is configured, the next step is to add the project's images in `Resources` > `Sprites`. Create two packages named `util` and `sprites` to work on later. +After the project is configured, the next step is to add the project's images in `Resources` > `Sprites`. Create two packages named `util` and `sprites` to work on later. The structure of your project will be: -![Project structure][16] - -(Vaneska Karen, [CC BY-SA 4.0][4]) +![Project structure][17] ### Go behind the scenes -To make it easier to maintain the code and change the images to the colors you want to use, it's a good practice to [centralize everything by creating classes][17]. Place all of the classes for this function inside the `util` package. +To make it easier to maintain the code and change the images to the colors you want to use, it's a good practice to [centralize everything by creating classes][18]. Place all of the classes for this function inside the `util` package. #### Constants.java First, create the `constants.java` class, which is where placement patterns (such as the edge between the screen and where the platform starts), speed, number of blocks, etc., reside. This is good for playing, changing numbers, and understanding where things change and why. It is a great exercise for those just starting with Java. - ``` package com.totacross.util; @@ -105,15 +92,15 @@ import totalcross.util.UnitsConverter; public class Constants {     //Position -    public static final int BOTTOM_EDGE = UnitsConverter.toPixels(430 + [Control][18].DP); -    public static final int DP_23 = UnitsConverter.toPixels(23 + [Control][18].DP); -    public static final int DP_50 = UnitsConverter.toPixels(50 + [Control][18].DP); -    public static final int DP_100 = UnitsConverter.toPixels(100 + [Control][18].DP); +    public static final int BOTTOM_EDGE = UnitsConverter.toPixels(430 + Control.DP); +    public static final int DP_23 = UnitsConverter.toPixels(23 + Control.DP); +    public static final int DP_50 = UnitsConverter.toPixels(50 + Control.DP); +    public static final int DP_100 = UnitsConverter.toPixels(100 + Control.DP);     //Sprites -    public static final int EDGE_RACKET = UnitsConverter.toPixels(20 + [Control][18].DP); -    public static final int WIDTH_BALL =  UnitsConverter.toPixels(15 + [Control][18].DP); -    public static final int HEIGHT_BALL =  UnitsConverter.toPixels(15 + [Control][18].DP); +    public static final int EDGE_RACKET = UnitsConverter.toPixels(20 + Control.DP); +    public static final int WIDTH_BALL =  UnitsConverter.toPixels(15 + Control.DP); +    public static final int HEIGHT_BALL =  UnitsConverter.toPixels(15 + Control.DP);     //Bricks     public static final int NUM_BRICKS = 10; @@ -136,7 +123,6 @@ If you want to know more about the pixel density (DP) unit, I recommend reading As the name suggests, this class is where you define the colors used in the game. I recommend naming things according to the color's purpose, such as background, font color, etc. This will make it easier to update your project's color palette in a single class. - ``` package com.totacross.util; @@ -152,7 +138,6 @@ public class Colors { The `images.java` class is undoubtedly the most frequently used. - ``` package com.totacross.util; @@ -160,26 +145,27 @@ import static com.totacross.util.Constants.*; import totalcross.ui.dialog.MessageBox; import totalcross.ui.image.Image; + public class Images { -    public static [Image][20] paddle, ball; -    public static [Image][20] red, orange, dark_orange, yellow, green, blue; +    public static Image paddle, ball; +    public static Image red, orange, dark_orange, yellow, green, blue;     public static void loadImages() {         try {             // general -            paddle = new [Image][20]("sprites/paddle.png"); -            ball = new [Image][20]("sprites/ball.png").getScaledInstance(WIDTH_BALL, HEIGHT_BALL); +            paddle = new Image("sprites/paddle.png"); +            ball = new Image("sprites/ball.png").getScaledInstance(WIDTH_BALL, HEIGHT_BALL);             // Bricks -            red = new [Image][20]("sprites/red_brick.png").getScaledInstance(WIDTH_BRICKS, HEIGHT_BRICKS); -            orange = new [Image][20]("sprites/orange_brick.png").getScaledInstance(WIDTH_BRICKS, HEIGHT_BRICKS); -            dark_orange = new [Image][20]("sprites/orange2_brick.png").getScaledInstance(WIDTH_BRICKS, HEIGHT_BRICKS); -            yellow = new [Image][20]("sprites/yellow_brick.png").getScaledInstance(WIDTH_BRICKS, HEIGHT_BRICKS); -            green = new [Image][20]("sprites/green_brick.png").getScaledInstance(WIDTH_BRICKS, HEIGHT_BRICKS); -            blue = new [Image][20]("sprites/blue_brick.png").getScaledInstance(WIDTH_BRICKS, HEIGHT_BRICKS); +            red = new Image("sprites/red_brick.png").getScaledInstance(WIDTH_BRICKS, HEIGHT_BRICKS); +            orange = new Image("sprites/orange_brick.png").getScaledInstance(WIDTH_BRICKS, HEIGHT_BRICKS); +            dark_orange = new Image("sprites/orange2_brick.png").getScaledInstance(WIDTH_BRICKS, HEIGHT_BRICKS); +            yellow = new Image("sprites/yellow_brick.png").getScaledInstance(WIDTH_BRICKS, HEIGHT_BRICKS); +            green = new Image("sprites/green_brick.png").getScaledInstance(WIDTH_BRICKS, HEIGHT_BRICKS); +            blue = new Image("sprites/blue_brick.png").getScaledInstance(WIDTH_BRICKS, HEIGHT_BRICKS); -        } catch ([Exception][21] e) { +        } catch (Exception e) {             MessageBox.showException(e, true);         }     } @@ -192,9 +178,7 @@ The `getScaledInstance()` method will manipulate the image to match the values p At this point, your project should look like this: -![Project structure][22] - -(Vaneska Karen, [CC BY-SA 4.0][4]) +![Project structure][20] ### Create your first sprite @@ -202,11 +186,10 @@ Now that the project is structured properly, you're ready to create your first c #### Paddle.java -The `paddle.java` class must inherit from `sprite`, which is the class responsible for objects in games. This is a fundamental concept in game engine development, so when inheriting from sprites, the TotalCross framework will already be concerned with delimiting movement within the screen, detecting collisions between sprites, and other important functions. You can check all the details in [Javadoc][23]. +The `paddle.java` class must inherit from `sprite`, which is the class responsible for objects in games. This is a fundamental concept in game engine development, so when inheriting from sprites, the TotalCross framework will already be concerned with delimiting movement within the screen, detecting collisions between sprites, and other important functions. You can check all the details in [Javadoc][21]. In Breakout, the paddle moves on the X-axis at a speed determined by the user's command (by touch screen or mouse movement). The `paddle.java` class is responsible for defining this movement and the sprite's image (the "face"): - ``` package com.totacross.sprites; @@ -218,7 +201,7 @@ import totalcross.ui.image.ImageException; public class Paddle extends Sprite {   private static final int SPEED = 4; -  public Paddle() throws [IllegalArgumentException][24], [IllegalStateException][25], ImageException { +  public Paddle() throws IllegalArgumentException, IllegalStateException, ImageException {     super(Images.paddle, -1, true, null);   } @@ -235,7 +218,7 @@ public class Paddle extends Sprite { } ``` -You indicate the image (`Images.paddle`) within the constructor, and the `move` method (a TotalCross feature) receives the speed defined at the beginning of the class. Experiment with other values and observe what happens with the movement. +You indicate the image (`Images.paddle` ) within the constructor, and the `move` method (a TotalCross feature) receives the speed defined at the beginning of the class. Experiment with other values and observe what happens with the movement. When the paddle is moving to the left, the center of the paddle at any moment is defined as itself minus the speed, and when it's moving to the right, it's itself plus the speed. Ultimately, you define the position of the sprite on the screen. @@ -247,17 +230,14 @@ When building your game engine, you need to focus on some standard points. For t Basically, you will delete the automatically generated `initUI()` method and, instead of inheriting from `MainWindow`, you will inherit it from `GameEngine`. A "red" will appear in the name of your class, so just click on the lamp or the suggestion symbol for your IDE and click `Add unimplemented methods`. This will automatically generate the `onGameInit()` method, which is responsible for the moment when the game starts, i.e., the moment the `breakout` class is called. -Inside the constructor, you must add the style type (`MaterialUI`) and the refresh time on the screen (`70`), and signal that the game has an interface (`gameHasUI = true;`). +Inside the constructor, you must add the style type (`MaterialUI` ) and the refresh time on the screen (`70` ), and signal that the game has an interface (`gameHasUI = true;` ). Last but not least, you have to start the game through `this.start()` on `onGameInit()` and focus on some other methods: - * `onGameInit()` is the first method called. In it, you must initialize the sprites and images (`Images.loadImages`), and tell the game that it can start. - * `onGameStart()`is called when the game starts. It sets the platform's initial position (in the center of the screen on the X-axis and below the center with a border on the Y-axis). - * `onPaint()` is where you say what will be drawn for each frame. First, it paints the background black (to not leave traces of the sprites), then it displays the sprites with `.show()`. - * The `onPenDrag` and `onPenDown` methods identify when the user moves the paddle (by dragging a finger on a touch screen or moving the mouse while pressing the left button). These methods change the paddle movement through the `setPos()` method, which triggers the `move` method in the `Paddle.java` class. Note that the last parameter of the `racket.setPos` method is `true` to precisely limit the paddle's movement within the screen so that it never disappears from the user's field of view. - - - +* onGameInit() is the first method called. In it, you must initialize the sprites and images (Images.loadImages), and tell the game that it can start. +* onGameStart()is called when the game starts. It sets the platform's initial position (in the center of the screen on the X-axis and below the center with a border on the Y-axis). +* onPaint() is where you say what will be drawn for each frame. First, it paints the background black (to not leave traces of the sprites), then it displays the sprites with `.show()`. +* The `onPenDrag` and `onPenDown` methods identify when the user `move`s the paddle (by dragging a finger on a touch screen or moving the mouse while pressing the left button). These methods change the paddle movement through the `setPos()` method, which triggers the move method in the `Paddle.java` class. Note that the last parameter of the `racket.setPos` method is `true` to precisely limit the paddle's movement within the screen so that it never disappears from the user's field of view. ``` package com.totacross; @@ -295,7 +275,7 @@ public class Breakout extends GameEngine {         try {             racket = new Paddle(); -        } catch ([Exception][21] e) { +        } catch (Exception e) {             MessageBox.showException(e, true);             MainWindow.exit(0);         } @@ -307,7 +287,7 @@ public class Breakout extends GameEngine {      //to draw the interface      @Override -     public void onPaint([Graphics][26] g) { +     public void onPaint(Graphics g) {          super.onPaint(g);          if (gameIsRunning) {              g.backColor = Colors.PRIMARY; @@ -339,71 +319,64 @@ public class Breakout extends GameEngine { To run the game, just click `RunBreakoutApplication.java` with the right mouse button, then click `run` to see how it looks. -![Breakout game remake on phone][27] - -(Vaneska Karen, [CC BY-SA 4.0][4]) +![Breakout game remake][22] If you want to run it on a Raspberry Pi, change the parameters in the `RunBreakoutApplication.java` class to: - ``` -`        TotalCrossApplication.run(Breakout.class, "/scr", "848x480");` +TotalCrossApplication.run(Breakout.class, "/scr", "848x480"); ``` This sets the screen size to match the Raspberry Pi. -![Breakout on Raspberry Pi][28] - -(Vaneska Karen, [CC BY-SA 4.0][4]) +![Breakout on Raspberry Pi][23] The first sprite and game mechanics are ready! ### Next steps -In the next article, I'll show how to add the ball sprite and make collisions. If you need help, call me in the [community group][15] on Telegram or post in the TotalCross [forum][29], where I'm available to help. +In the next article, I'll show how to add the ball sprite and make collisions. If you need help, call me in the [community group][24] on Telegram or post in the TotalCross [forum][25], where I'm available to help. -If you put this article into practice, share your experience in the comments. All feedback is important! If you wish, favorite [TotalCross on GitHub][30], as it improves the project's relevance on the platform. +If you put this article into practice, share your experience in the comments. All feedback is important! If you wish, favorite [TotalCross on GitHub][26], as it improves the project's relevance on the platform. + +Image by: (Vaneska Karen, CC BY-SA 4.0) -------------------------------------------------------------------------------- via: https://opensource.com/article/21/3/java-object-orientation 作者:[Vaneska Sousa][a] -选题:[lujun9972][b] +选题:[lkxed][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/vaneska -[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://www.youtube.com/watch?v=Cr6z3AyhRr8 -[3]: https://opensource.com/sites/default/files/uploads/originalbreakout.gif (Breakout game) -[4]: https://creativecommons.org/licenses/by-sa/4.0/ -[5]: https://processing.org/ -[6]: https://opensource.com/resources/java -[7]: https://opensource.com/article/20/7/totalcross-cross-platform-development -[8]: https://www.arm.linux.org.uk/docs/whatis.php -[9]: https://opensource.com/resources/raspberry-pi -[10]: https://opensource.com/sites/default/files/uploads/breakoutremake.gif (Breakout remake) -[11]: https://marketplace.visualstudio.com/items?itemName=totalcross.vscode-totalcross -[12]: https://www.redhat.com/en/topics/middleware/what-is-ide -[13]: https://opensource.com/sites/default/files/uploads/helloworld.png (HelloWorld project structure) -[14]: https://learn.totalcross.com/ -[15]: https://t.me/guiforembedded -[16]: https://opensource.com/sites/default/files/uploads/projectstructure.png (Project structure) -[17]: https://learn.totalcross.com/documentation/guides/app-architecture/colors-fonts-and-images -[18]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+control +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/studying-books-java-couch-education.png +[2]: https://www.wocintechchat.com/ +[3]: https://creativecommons.org/licenses/by/2.0/ +[4]: https://www.youtube.com/watch?v=Cr6z3AyhRr8 +[5]: https://opensource.com/sites/default/files/uploads/originalbreakout.gif +[6]: https://processing.org/ +[7]: https://opensource.com/resources/java +[8]: https://opensource.com/article/20/7/totalcross-cross-platform-development +[9]: https://www.arm.linux.org.uk/docs/whatis.php +[10]: https://opensource.com/resources/raspberry-pi +[11]: https://opensource.com/sites/default/files/uploads/breakoutremake.gif +[12]: https://marketplace.visualstudio.com/items?itemName=totalcross.vscode-totalcross +[13]: https://www.redhat.com/en/topics/middleware/what-is-ide +[14]: https://opensource.com/sites/default/files/uploads/helloworld.png +[15]: https://learn.totalcross.com/ +[16]: https://t.me/guiforembedded +[17]: https://opensource.com/sites/default/files/uploads/projectstructure.png +[18]: https://learn.totalcross.com/documentation/guides/app-architecture/colors-fonts-and-images [19]: https://material.io/design/layout/pixel-density.html -[20]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+image -[21]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+exception -[22]: https://opensource.com/sites/default/files/uploads/projectstructure2.png (Project structure) -[23]: https://en.wikipedia.org/wiki/Javadoc -[24]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+illegalargumentexception -[25]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+illegalstateexception -[26]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+graphics -[27]: https://opensource.com/sites/default/files/uploads/runbreakout.gif (Breakout game remake on phone) -[28]: https://opensource.com/sites/default/files/uploads/runbreakout2.gif (Breakout on Raspberry Pi) -[29]: http://forum.totalcross.com -[30]: https://github.com/totalcross/totalcross +[20]: https://opensource.com/sites/default/files/uploads/projectstructure2.png +[21]: https://en.wikipedia.org/wiki/Javadoc +[22]: https://opensource.com/sites/default/files/uploads/runbreakout.gif +[23]: https://opensource.com/sites/default/files/uploads/runbreakout2.gif +[24]: https://t.me/guiforembedded +[25]: http://forum.totalcross.com +[26]: https://github.com/totalcross/totalcross diff --git a/sources/tech/20210303 Host your website with dynamic content and a database on a Raspberry Pi.md b/sources/tech/20210303 Host your website with dynamic content and a database on a Raspberry Pi.md index 805f04dafa..dbd7837991 100644 --- a/sources/tech/20210303 Host your website with dynamic content and a database on a Raspberry Pi.md +++ b/sources/tech/20210303 Host your website with dynamic content and a database on a Raspberry Pi.md @@ -1,50 +1,44 @@ -[#]: subject: (Host your website with dynamic content and a database on a Raspberry Pi) -[#]: via: (https://opensource.com/article/21/3/web-hosting-raspberry-pi) -[#]: author: (Marty Kalin https://opensource.com/users/mkalindepauledu) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: subject: "Host your website with dynamic content and a database on a Raspberry Pi" +[#]: via: "https://opensource.com/article/21/3/web-hosting-raspberry-pi" +[#]: author: "Marty Kalin https://opensource.com/users/mkalindepauledu" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " Host your website with dynamic content and a database on a Raspberry Pi ====== -You can use free software to support a web application on a very -lightweight computer. +You can use free software to support a web application on a very lightweight computer. + ![Digital creative of a browser on the internet][1] Raspberry Pi's single-board machines have set the mark for cheap, real-world computing. With its model 4, the Raspberry Pi can host web applications with a production-grade web server, a transactional database system, and dynamic content through scripting. This article explains the installation and configuration details with a full code example. Welcome to web applications hosted on a very lightweight computer. ### The snowfall application -Imagine a downhill ski area large enough to have microclimates, which can mean dramatically different snowfalls across the area. The area is divided into regions, each of which has devices that record snowfall in centimeters; the recorded information then guides decisions on snowmaking, grooming, and other maintenance operations. The devices communicate, say, every 20 minutes with a server that updates a database that supports reports. Nowadays, the server-side software for such an application can be free _and_ production-grade. +Imagine a downhill ski area large enough to have microclimates, which can mean dramatically different snowfalls across the area. The area is divided into regions, each of which has devices that record snowfall in centimeters; the recorded information then guides decisions on snowmaking, grooming, and other maintenance operations. The devices communicate, say, every 20 minutes with a server that updates a database that supports reports. Nowadays, the server-side software for such an application can be free *and* production-grade. This snowfall application uses the following technologies: - * A [Raspberry Pi 4][2] running Debian - * Nginx web server: The free version hosts over 400 million websites. This web server is easy to install, configure, and use. - * [SQLite relational database system][3], which is file-based: A database, which can hold many tables, is a file on the local system. SQLite is lightweight but also [ACID-compliant][4]; it is suited for low to moderate volume. SQLite is likely the most widely used database system in the world, and the source code for SQLite is in the public domain. The current version is 3. A more powerful (but still free) option is PostgreSQL. - * Python: The Python programming language can interact with databases such as SQLite and web servers such as Nginx. Python (version 3) comes with Linux and macOS systems. - - +* A [Raspberry Pi 4][2] running Debian +* Nginx web server: The free version hosts over 400 million websites. This web server is easy to install, configure, and use. +* [SQLite relational database system][3], which is file-based: A database, which can hold many tables, is a file on the local system. SQLite is lightweight but also [ACID-compliant][4]; it is suited for low to moderate volume. SQLite is likely the most widely used database system in the world, and the source code for SQLite is in the public domain. The current version is 3. A more powerful (but still free) option is PostgreSQL. +* Python: The Python programming language can interact with databases such as SQLite and web servers such as Nginx. Python (version 3) comes with Linux and macOS systems. Python includes a software driver for communicating with SQLite. There are options for connecting Python scripts with Nginx and other web servers. One option is [uWSGI][5] (Web Server Gateway Interface), which updates the ancient CGI (Common Gateway Interface) from the 1990s. Several factors speak for uWSGI: - * uWSGI is flexible. It can be used as either a lightweight concurrent web server or the backend application server connected to a web server such as Nginx. - * Its setup is minimal. - * The snowfall application involves a low to moderate volume of hits on the web server and database system. In general, CGI technologies are not fast by modern standards, but CGI performs well enough for department-level web applications such as this one. - - +* uWSGI is flexible. It can be used as either a lightweight concurrent web server or the backend application server connected to a web server such as Nginx. +* Its setup is minimal. +* The snowfall application involves a low to moderate volume of hits on the web server and database system. In general, CGI technologies are not fast by modern standards, but CGI performs well enough for department-level web applications such as this one. Various acronyms describe the uWSGI option. Here's a sketch of the three principal ones: - * **WSGI** is a Python specification for an interface between a web server on one side, and an application or an application framework (e.g., Django) on the other side. This specification defines an API whose implementation is left open. - * **uWSGI** implements the WSGI interface by providing an application server, which connects applications to a web server. A uWSGI application server's main job is to translate HTTP requests into a format that a web application can consume and, afterward, to format the application's response into an HTTP message. - * **uwsgi** is a binary protocol implemented by a uWSGI application server to communicate with a full-featured web server such as Nginx; it also includes utilities such as a lightweight web server. The Nginx web server "speaks" uwsgi out of the box. - - +* WSGI is a Python specification for an interface between a web server on one side, and an application or an application framework (e.g., Django) on the other side. This specification defines an API whose implementation is left open. +* uWSGI implements the WSGI interface by providing an application server, which connects applications to a web server. A uWSGI application server's main job is to translate HTTP requests into a format that a web application can consume and, afterward, to format the application's response into an HTTP message. +* uwsgi is a binary protocol implemented by a uWSGI application server to communicate with a full-featured web server such as Nginx; it also includes utilities such as a lightweight web server. The Nginx web server "speaks" uwsgi out of the box. For convenience, I will use "uwsgi" as shorthand for the binary protocol, the application server, and the very lightweight web server. @@ -52,33 +46,29 @@ For convenience, I will use "uwsgi" as shorthand for the binary protocol, the ap On a Debian-based system, you can install SQLite the usual way (with `%` representing the command-line prompt): - ``` -`% sudo apt-get install sqlite3` +% sudo apt-get install sqlite3 ``` This database system is a collection of C libraries and utilities, all of which come to about 500KB in size. There is no database server to start, stop, or otherwise maintain. Once SQLite is installed, create a database at the command-line prompt: - ``` -`% sqlite3 snowfall.db` +% sqlite3 snowfall.db ``` If this succeeds, the command creates the file `snowfall.db` in the current working directory. The database name is arbitrary (e.g., no extension is required), and the command opens the SQLite client utility with `>sqlite` as the prompt: - ``` Enter ".help" for usage hints. -sqlite> +sqlite> ``` Create the snowfall table in the snowfall database with the following command. The table name, like the database name, is arbitrary: - ``` -sqlite> CREATE TABLE snowfall (id INTEGER PRIMARY KEY AUTOINCREMENT, +sqlite> CREATE TABLE snowfall (id INTEGER PRIMARY KEY AUTOINCREMENT,                                region TEXT NOT NULL,                                device TEXT NOT NULL,                                amount DECIMAL NOT NULL, @@ -87,9 +77,8 @@ sqlite> CREATE TABLE snowfall (id INTEGER PRIMARY KEY AUTOINCREMENT, SQLite commands are case-insensitive, but it is traditional to use uppercase for SQL terms and lowercase for user terms. Check that the table was created: - ``` -`sqlite> .schema` +sqlite> .schema ``` The command echoes the `CREATE TABLE` statement. @@ -100,10 +89,9 @@ The database is now ready for business, although the single-table snowfall is em Recall that uwsgi can be used in two ways: either as a lightweight web server or as an application server connected to a production-grade web server such as Nginx. The second use is the goal, but the first is suited for developing and testing the programmer's request-handling code. Here's the architecture with Nginx in play as the web server: - ``` -       HTTP       uwsgi -client<\---->Nginx<\----->appServer<\--->request-handling code<\--->SQLite +HTTP       uwsgi +client<---->Nginx<----->appServer<--->request-handling code<--->SQLite ``` The client could be a browser, a utility such as [curl][6], or a hand-crafted program fluent in HTTP. Communications between the client and Nginx occur through HTTP, but then uwsgi takes over as a binary-transport protocol between Nginx and the application server, which interacts with request-handling code such as `requestHandler.py` (described below). This architecture delivers a clean division of labor. Nginx alone manages the client, and only the request-handling code interacts with the database. In turn, the application server separates the web server from the programmer-written code, which has a high-level API to read and write HTTP messages delivered over uwsgi. @@ -116,7 +104,6 @@ Below is the source code file `requestHandler.py` for the snowfall application. #### The request-handling program - ``` import sqlite3 import cgi @@ -127,7 +114,7 @@ PATH_2_DB = '/home/marty/wsgi/snowfall.db' def application(env, start_line):     if env['REQUEST_METHOD'] == 'POST':   ## add new DB record         return handle_post(env, start_line) -    elif env['REQUEST_METHOD'] == 'GET':  ## create HTML-fragment report +    elif env['REQUEST_METHOD'] == 'GET':  ## create HTML-fragment report         return handle_get(start_line)     else:                                 ## no other option for now         start_line('405 METHOD NOT ALLOWED', [('Content-Type', 'text/plain')]) @@ -136,7 +123,7 @@ def application(env, start_line): def handle_post(env, start_line):         form = get_field_storage(env)  ## body of an HTTP POST request -    +        ## Extract fields from POST form.     region = form.getvalue('region')     device = form.getvalue('device') @@ -162,19 +149,19 @@ def handle_get(start_line):     cursor = conn.cursor()                   ## get a cursor     cursor.execute("select * from snowfall") -    response_body = "<h3>Snowfall report</h3><ul>" +    response_body = "

Snowfall report

    "     rows = cursor.fetchall()     for row in rows: -        response_body += "<li>" + str(row[0]) + '|'  ## primary key +        response_body += "
  • " + str(row[0]) + '|'  ## primary key         response_body += row[1] + '|'                ## region         response_body += row[2] + '|'                ## device         response_body += str(row[3]) + '|'           ## amount -        response_body += str(row[4]) + "</li>"       ## timestamp -    response_body += "</ul>" +        response_body += str(row[4]) + "
  • "       ## timestamp +    response_body += "
"     conn.commit()  ## commit     conn.close()   ## cleanup -    +        start_line('200 OK', [('Content-Type', 'text/html')])     return [response_body.encode()] @@ -184,7 +171,7 @@ def add_record(reg, dev, amt, tstamp):     cursor = conn.cursor()                 ## get a cursor     sql = "INSERT INTO snowfall(region,device,amount,tstamp) values (?,?,?,?)" -    cursor.execute(sql, (reg, dev, amt, tstamp)) ## execute INSERT +    cursor.execute(sql, (reg, dev, amt, tstamp)) ## execute INSERT     conn.commit()  ## commit     conn.close()   ## cleanup @@ -203,16 +190,14 @@ def get_field_storage(env): A constant at the start of the source file defines the path to the database file: - ``` -`PATH_2_DB = '/home/marty/wsgi/snowfall.db'` +PATH_2_DB = '/home/marty/wsgi/snowfall.db' ``` Make sure to update the path for your Raspberry Pi. As noted earlier, uwsgi includes a lightweight web server that can host this request-handling application. To begin, install uwsgi with these two commands (`##` introduces my comments): - ``` % sudo apt-get install build-essential python-dev ## C header files, etc. % pip install uwsgi                               ## pip = Python package manager @@ -220,19 +205,17 @@ As noted earlier, uwsgi includes a lightweight web server that can host this req Next, launch a bare-bones snowfall application using uwsgi as the web server: - ``` -`% uwsgi --http 127.0.0.1:9999 --wsgi-file requestHandler.py  ` +% uwsgi --http 127.0.0.1:9999 --wsgi-file requestHandler.py ``` The flag `--http` runs uwsgi in web-server mode, with 9999 as the web server's listening port on localhost (127.0.0.1). By default, uwsgi dispatches HTTP requests to a programmer-defined function named `application`. For review, here's the full function from the top of the `requestHandler.py` code: - ``` def application(env, start_line):     if env['REQUEST_METHOD'] == 'POST':   ## add new DB record         return handle_post(env, start_line) -    elif env['REQUEST_METHOD'] == 'GET':  ## create HTML-fragment report +    elif env['REQUEST_METHOD'] == 'GET':  ## create HTML-fragment report         return handle_get(start_line)     else:                                 ## no other option for now         start_line('405 METHOD NOT ALLOWED', [('Content-Type', 'text/plain')]) @@ -242,25 +225,21 @@ def application(env, start_line): The snowfall application accepts only two request types: - * A POST request, if up to snuff, creates a new entry in the snowfall table. The request should include the ski area region, the device in the region, the snowfall amount in centimeters, and a Unix-style timestamp. A POST request is dispatched to the `handle_post` function (which I'll clarify shortly). - * A GET request returns an HTML fragment (an unordered list) with the records currently in the snowfall table. - - +* A POST request, if up to snuff, creates a new entry in the snowfall table. The request should include the ski area region, the device in the region, the snowfall amount in centimeters, and a Unix-style timestamp. A POST request is dispatched to the `handle_post` function (which I'll clarify shortly). +* A GET request returns an HTML fragment (an unordered list) with the records currently in the snowfall table. Requests with an HTTP verb other than POST and GET will generate an error message. You can use a utility such as curl to generate HTTP requests for testing. Here are three sample POST requests to start populating the database: - ``` -% curl -X POST -d "region=R1&device=D9&amount=1.42&tstamp=1604722088.0158753" localhost:9999/ -% curl -X POST -d "region=R7&device=D4&amount=2.11&tstamp=1604722296.8862638" localhost:9999/ -% curl -X POST -d "region=R5&device=D1&amount=1.12&tstamp=1604942236.1013834" localhost:9999/ +% curl -X POST -d "region=R1&device=D9&amount=1.42&tstamp=1604722088.0158753" localhost:9999/ +% curl -X POST -d "region=R7&device=D4&amount=2.11&tstamp=1604722296.8862638" localhost:9999/ +% curl -X POST -d "region=R5&device=D1&amount=1.12&tstamp=1604942236.1013834" localhost:9999/ ``` These commands add three records to the snowfall table. A subsequent GET request from curl or a browser displays an HTML fragment that lists the rows in the snowfall table. Here's the equivalent as non-HTML text: - ``` Snowfall report @@ -273,20 +252,18 @@ A professional report would convert the numeric timestamps into human-readable o The uwsgi utility accepts various flags, which can be given either through a configuration file or in the launch command. For example, here's a richer launch of uwsgi as a web server: - ``` -`% uwsgi --master --processes 2 --http 127.0.0.1:9999 --wsgi-file requestHandler.py` +% uwsgi --master --processes 2 --http 127.0.0.1:9999 --wsgi-file requestHandler.py ``` This version creates a master (supervisory) process and two worker processes, which can handle the HTTP requests concurrently. In the snowfall application, the functions `handle_post` and `handle_get` process POST and GET requests, respectively. Here's the `handle_post` function in full: - ``` def handle_post(env, start_line):         form = get_field_storage(env)  ## body of an HTTP POST request -    +        ## Extract fields from POST form.     region = form.getvalue('region')     device = form.getvalue('device') @@ -308,18 +285,17 @@ def handle_post(env, start_line):         return [response_body.encode()] ``` -The two arguments to the `handle_post` function (`env` and `start_line`) represent the system environment and a communications channel, respectively. The `start_line` channel sends the HTTP start line (in this case, either `400 Bad Request` or `201 OK`) and any HTTP headers (in this case, just `Content-Type: text/plain`) of an HTTP response. +The two arguments to the `handle_post` function (`env` and `start_line` ) represent the system environment and a communications channel, respectively. The `start_line` channel sends the HTTP start line (in this case, either `400 Bad Request` or `201 OK` ) and any HTTP headers (in this case, just `Content-Type: text/plain` ) of an HTTP response. The `handle_post` function tries to extract the relevant data from the HTTP POST request and, if it's successful, calls the function `add_record` to add another row to the snowfall table: - ``` def add_record(reg, dev, amt, tstamp):     conn = sqlite3.connect(PATH_2_DB)      ## connect to DB     cursor = conn.cursor()                 ## get a cursor     sql = "INSERT INTO snowfall(region,device,amount,tstamp) VALUES (?,?,?,?)" -    cursor.execute(sql, (reg, dev, amt, tstamp)) ## execute INSERT +    cursor.execute(sql, (reg, dev, amt, tstamp)) ## execute INSERT     conn.commit()  ## commit     conn.close()   ## cleanup @@ -329,26 +305,25 @@ SQLite automatically wraps single SQL statements (such as `INSERT` above) in a t The `handle_get` function also touches the database, but only to read the records in the snowfall table: - ``` def handle_get(start_line):     conn = sqlite3.connect(PATH_2_DB)        ## connect to DB     cursor = conn.cursor()                   ## get a cursor     cursor.execute("SELECT * FROM snowfall") -    response_body = "<h3>Snowfall report</h3><ul>" +    response_body = "

Snowfall report

    "     rows = cursor.fetchall()     for row in rows: -        response_body += "<li>" + str(row[0]) + '|'  ## primary key +        response_body += "
  • " + str(row[0]) + '|'  ## primary key         response_body += row[1] + '|'                ## region         response_body += row[2] + '|'                ## device         response_body += str(row[3]) + '|'           ## amount -        response_body += str(row[4]) + "</li>"       ## timestamp -    response_body += "</ul>" +        response_body += str(row[4]) + "
  • "       ## timestamp +    response_body += "
"     conn.commit()  ## commit     conn.close()   ## cleanup -    +        start_line('200 OK', [('Content-Type', 'text/html')])     return [response_body.encode()] ``` @@ -359,28 +334,25 @@ A user-friendly version of the snowfall application would support additional (an The Nginx web server can be installed on a Debian-based system with one command: - ``` -`% sudo apt-get install nginx` +% sudo apt-get install nginx ``` As a web server, Nginx provides the expected services, such as wire-level security, HTTPS, user authentication, load balancing, media streaming, response compression, file uploading, etc. The Nginx engine is high-performance and stable, and this server can support dynamic content through a variety of programming languages. Using uwsgi as a very lightweight web server is an attractive option but switching to Nginx is a move up to industrial-strength web hosting with high-volume capability. Nginx and uwsgi are both implemented in C. With Nginx in play, uwsgi takes on a communication protocol's restricted roles and an application server; it no longer acts as an HTTP web server. Here's the revised architecture: - ``` -          HTTP       uwsgi                   -requester<\---->Nginx<\----->app server<\--->requestHandler.py +HTTP       uwsgi                   +requester<---->Nginx<----->app server<--->requestHandler.py ``` As noted earlier, Nginx includes uwsgi support and now acts as a reverse-proxy server that forwards designated HTTP requests to the uwsgi application server, which in turn interacts with the Python script `requestHandler.py`. Responses from the Python script move in the reverse direction so that Nginx sends the HTTP response back to the requesting client. Two changes bring this new architecture to life. The first launches uwsgi as an application server: - ``` -`% uwsgi --socket 127.0.0.1:8001 --wsgi-file requestHandler.py` +% uwsgi --socket 127.0.0.1:8001 --wsgi-file requestHandler.py ``` Socket 8001 is the Nginx default for uwsgi communications. For robustness, you could use the full path to the Python script so that the command above does not have to be executed in the directory that houses the Python script. In a production environment, uwsgi would start and stop automatically; for now, however, the emphasis remains on how the architectural pieces fit together. @@ -389,7 +361,6 @@ The second change involves Nginx configuration, which can be tricky on Debian-ba However the configuration is distributed, the key section for having Nginx talk to the uwsgi application server begins with `http` and has one or more `server` subsections, which in turn have `location` subsections. Here's an example from the Nginx documentation: - ``` ... http { @@ -397,7 +368,7 @@ http {     ...     server { # simple reverse-proxy        listen       80; -       server_name  domain2.com [www.domain2.com][8]; +       server_name  domain2.com www.domain2.com;        access_log   logs/domain2.access.log  main;        # serve static files @@ -408,7 +379,7 @@ http {        # pass requests for dynamic content to rails/turbogears/zope, et al        location / { -         proxy_pass      ; +         proxy_pass      http://127.0.0.1:8080;        }      }      ... @@ -417,7 +388,6 @@ http { The `location` subsections are the ones of interest. For the snowfall application, here's the added `location` entry with its two configuration lines: - ``` ... server { @@ -441,9 +411,8 @@ server { To keep things simple for now, make `/snowfall` the only `location` in the configuration. With this configuration in place, Nginx listens on port 80 and dispatches HTTP requests ending with the `/snowfall` path to the uwsgi application server: - ``` -% curl -X POST -d "..." localhost/snowfall ## new POST +% curl -X POST -d "..." localhost/snowfall ## new POST % curl -X GET localhost/snowfall           ## new GET ``` @@ -453,16 +422,14 @@ If the configured location were simply `/` instead of `/snowfall`, then any HTTP Once you've changed the Nginx configuration with the added `location` subsection, you can start the web server: - ``` -`% sudo systemctl start nginx` +% sudo systemctl start nginx ``` There are other commands similar to `stop` and `restart` Nginx. In a production environment, you could automate these actions so that Nginx starts on a system boot and stops on a system shutdown. With uwsgi and Nginx both running, you can use a browser to test whether the architectural components cooperate as expected. For example, if you enter the URL `localhost/` in the browser's input window, then the Nginx welcome page should appear with (HTML) content similar to this: - ``` Welcome to nginx! ... @@ -471,7 +438,6 @@ Thank you for using nginx. By contrast, the URL `localhost/snowfall` should display the rows currently in the snowfall table: - ``` Snowfall report @@ -491,19 +457,18 @@ The software components in the web application work well together and require ve via: https://opensource.com/article/21/3/web-hosting-raspberry-pi 作者:[Marty Kalin][a] -选题:[lujun9972][b] +选题:[lkxed][b] 译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]: https://opensource.com/users/mkalindepauledu -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet) +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/browser_web_internet_website.png [2]: https://www.raspberrypi.org/products/raspberry-pi-4-model-b/ [3]: https://opensource.com/article/21/2/sqlite3-cheat-sheet [4]: https://en.wikipedia.org/wiki/ACID [5]: https://uwsgi-docs.readthedocs.io/en/latest/ [6]: https://opensource.com/article/20/5/curl-cheat-sheet [7]: https://condor.depaul.edu/mkalin -[8]: http://www.domain2.com diff --git a/sources/tech/20210306 Manage containers on Raspberry Pi with this open source tool.md b/sources/tech/20210306 Use FreeBSD jails on Raspberry Pi.md similarity index 88% rename from sources/tech/20210306 Manage containers on Raspberry Pi with this open source tool.md rename to sources/tech/20210306 Use FreeBSD jails on Raspberry Pi.md index 8b31abd533..1b7ebb7bfe 100644 --- a/sources/tech/20210306 Manage containers on Raspberry Pi with this open source tool.md +++ b/sources/tech/20210306 Use FreeBSD jails on Raspberry Pi.md @@ -1,18 +1,20 @@ -[#]: subject: (Manage containers on Raspberry Pi with this open source tool) -[#]: via: (https://opensource.com/article/21/3/bastille-raspberry-pi) -[#]: author: (Peter Czanik https://opensource.com/users/czanik) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: subject: "Use FreeBSD jails on Raspberry Pi" +[#]: via: "https://opensource.com/article/21/3/bastille-raspberry-pi" +[#]: author: "Peter Czanik https://opensource.com/users/czanik" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " -Manage containers on Raspberry Pi with this open source tool +Use FreeBSD jails on Raspberry Pi ====== -Create and maintain your containers (aka jails) at scale on FreeBSD with -Bastille. +Create and maintain your containers (aka jails) at scale on FreeBSD with Bastille. + ![Parts, modules, containers for software][1] +Image by: Opensource.com + Containers became widely popular because of Docker on Linux, but there are [much earlier implementations][2], including the [jail][3] system on FreeBSD. A container is called a "jail" in FreeBSD terminology. The jail system was first released in FreeBSD 4.0 way back in 2000, and it has continuously improved since. While 20 years ago it was used mostly on large servers, now you can run it on your Raspberry Pi. ### Jails vs. containers on Linux @@ -31,19 +33,17 @@ Docker brought popularity, accessibility, and ease of use to containers. There a Installing [BSD on Raspberry Pi][8] is pretty similar to installing Linux. You download a compressed image from the FreeBSD website and `dd` it to an SD card. You can also use a dedicated image writer tool; there are many available for all operating systems (OS). Download and write an image from the command line with: - ``` -wget +wget https://download.freebsd.org/ftp/releases/arm64/aarch64/ISO-IMAGES/13.0/FreeBSD-13.0-BETA1-arm64-aarch64-RPI.img.xz xzcat FreeBSD-13.0-BETA1-arm64-aarch64-RPI.img.xz | dd of=/dev/XXX ``` -That writes the latest beta image available for 64-bit Raspberry Pi boards; check the [download page][9] if you use another Raspberry Pi board or want to use another build. Replace `XXX` with your SD card's device name, which depends on your OS and how the card connects to your machine. I purposefully did not use a device name so that you won't overwrite anything if you just copy and paste the instructions mindlessly. I did that and was lucky to have a recent backup of my laptop, but it was _not_ a pleasant experience. +That writes the latest beta image available for 64-bit Raspberry Pi boards; check the [download page][9] if you use another Raspberry Pi board or want to use another build. Replace `XXX` with your SD card's device name, which depends on your OS and how the card connects to your machine. I purposefully did not use a device name so that you won't overwrite anything if you just copy and paste the instructions mindlessly. I did that and was lucky to have a recent backup of my laptop, but it was *not* a pleasant experience. Once you've written the SD card, put it in your Raspberry Pi and boot it. The first boot takes a bit longer than usual; I suspect the partition sizes are being adjusted to the SD card's size. After a while, you will receive the familiar login prompt on a good old text-based screen. The username is **root**, and the password is the same as the user name. The SSH server is enabled by default, but don't worry; the root user cannot log in. It is still a good idea to change the password to something else. The network is automatically configured by DHCP for the Ethernet connection (I did not test WiFi). The easiest way to configure Bastille on the system is to SSH into Raspberry Pi and copy and paste the commands and configuration in this article. You have a couple of options, depending on how much you care about industry best practices or are willing to treat it as a test system. You can either enable root login in the SSHD configuration (scary, but this is what I did at first) or create a regular user that can log in remotely. In the latter case, make sure that the user is part of the "wheel" group so that it can use `su -` to become root and use Bastille: - ``` root@generic:~ # adduser Username: czanik @@ -79,9 +79,8 @@ Goodbye! The fifth line adds the user to the wheel group. Note that you might have a different list of shells on your system, and Bash is not part of the base system. Install Bash before adding the user: - ``` -`pkg install bash` +pkg install bash ``` PKG needs to bootstrap itself on the first run, so invoking the command takes a bit longer this time. @@ -90,34 +89,30 @@ PKG needs to bootstrap itself on the first run, so invoking the command takes a Managing jails with the tools in the FreeBSD base system is possible—but not really convenient. Using a tool like Bastille can simplify it considerably. It is not part of the base system, so install it: - ``` -`pkg install bastille` +pkg install bastille ``` As you can see from the command's output, Bastille has no external dependencies. It is a shell script that relies on commands in the FreeBSD base system (with an exception I'll note later when explaining templates). If you want to start your containers on boot, enable Bastille: - ``` -`sysrc bastille_enable="YES"` +sysrc bastille_enable="YES" ``` Start with a simple use case. Many people use containers to install different development tools in different containers to avoid conflicts or simplify their environments. For example, no sane person wants to install Python 2 on a brand-new system—but you might need to run an ancient script every once in a while. So, create a jail for Python 2. Before creating your first jail, you need to bootstrap a FreeBSD release and configure networking. Just make sure that you bootstrap the same or an older release than the host is running. For example: - ``` -`bastille bootstrap 12.2-RELEASE` +bastille bootstrap 12.2-RELEASE ``` It downloads and extracts this release under the `/usr/local/bastille` directory structure. Networking can be configured in many different ways using Bastille. One option that works everywhere—on your local machine and in the cloud—is using cloned interfaces. This allows jails to use an internal network that does not interfere with the external network. Configure and start this internal network: - ``` sysrc cloned_interfaces+=lo1 sysrc ifconfig_lo1_name="bastille0" @@ -126,7 +121,6 @@ service netif cloneup With this network setup, services in your jails are not accessible from the outside network, nor can they reach outside. You need forward ports from your host's external interface to the jails and to enable network access translation (NAT). Bastille integrates with BSD's [PF firewall][10] for this task. The following `pf.conf` configures the PF firewall such that Bastille can add port forwarding rules to the firewall dynamically: - ``` ext_if="ue0" @@ -134,8 +128,8 @@ set block-policy return scrub in on $ext_if all fragment reassemble set skip on lo -table <jails> persist -nat on $ext_if from <jails> to any -> ($ext_if) +table persist +nat on $ext_if from to any -> ($ext_if) rdr-anchor "rdr/*" @@ -147,7 +141,6 @@ pass in inet proto tcp from any to any port ssh flags S/SA modulate state You also need to enable and start PF for these rules to take effect. Note that if you work through an SSH connection, starting PF will terminate your connection, and you will need to log in again: - ``` sysrc pf_enable="YES" service pf restart @@ -157,14 +150,12 @@ service pf restart To create a jail, Bastille needs a few parameters. First, it needs a name for the jail you're creating. It is an important parameter, as you will always refer to a jail by its name. I chose the name of the most famous Hungarian jail for the most elite criminals, but in real life, jail names often refer to the jail's function, like `syslogserver`. You also need to set the FreeBSD release you're using and an internet protocol (IP) address. I used a random `10.0.0.0/8` IP address range, but if your internal network already uses addresses from that, then using the `192.168.0.0/16` is probably a better idea: - ``` -`bastille create csillag 12.2-RELEASE 10.17.89.51` +bastille create csillag 12.2-RELEASE 10.17.89.51 ``` Your new jail should be up and running within a few seconds. It is a complete FreeBSD base system without any extra packages. So install some packages, like my favorite text editor, inside the jail: - ``` root@generic:~ # bastille pkg csillag install joe [csillag]: @@ -190,22 +181,20 @@ Checking integrity... done (0 conflicting) You can install multiple packages at the same time. Install Python 2, Bash, and Git: - ``` -`bastille pkg csillag install bash python2 git` +bastille pkg csillag install bash python2 git ``` Now you can start working in your new, freshly created jail. There are no network services installed in it, but you can reach it through its console: - ``` root@generic:~ # bastille console csillag [csillag]: root@csillag:~ # python2 Python 2.7.18 (default, Feb  2 2021, 01:53:44) -[GCC FreeBSD Clang 10.0.1 ([git@github.com][11]:llvm/llvm-project.git llvmorg-10.0.1- on freebsd12 +[GCC FreeBSD Clang 10.0.1 (git@github.com:llvm/llvm-project.git llvmorg-10.0.1- on freebsd12 Type "help", "copyright", "credits" or "license" for more information. ->>> +>>> root@csillag:~ # logout root@generic:~ # @@ -217,21 +206,18 @@ The previous example manually installed some packages inside a jail. Setting up To use templates, you need to install Git on the host: - ``` -`pkg install git` +pkg install git ``` For example, to bootstrap the `syslog-ng` template, use: - ``` -`bastille bootstrap https://gitlab.com/BastilleBSD-Templates/syslog-ng` +bastille bootstrap https://gitlab.com/BastilleBSD-Templates/syslog-ng ``` Create a new jail, apply the template, and redirect an external port to it: - ``` bastille create alcatraz 12.2-RELEASE 10.17.89.50 bastille template alcatraz BastilleBSD-Templates/syslog-ng @@ -240,7 +226,6 @@ bastille rdr alcatraz tcp 514 514 To test the new service within the jail, use telnet to connect port 514 of your host and enter some random text. Use the `tail` command within your jail to see what you just entered: - ``` root@generic:~ # tail /usr/local/bastille/jails/alcatraz/root/var/log/messages Feb  6 03:57:27 alcatraz sendmail[3594]: gethostbyaddr(10.17.89.50) failed: 1 @@ -249,26 +234,26 @@ Feb  6 04:07:18 192.168.1.126 this is a test Feb  6 04:07:20 alcatraz syslog-ng[1186]: Syslog connection closed; fd='23', client='AF_INET(192.168.1.126:50104)', local='AF_INET(0.0.0.0:514)' ``` -Since I'm a [syslog-ng][12] evangelist, I used the syslog-ng template in my example, but there are many more available. Check the full list of [Bastille templates][13] to learn about them. +Since I'm a [syslog-ng][11] evangelist, I used the syslog-ng template in my example, but there are many more available. Check the full list of [Bastille templates][12] to learn about them. ### What's next? -I hope that this article inspires you to try FreeBSD and Bastille on your Raspberry Pi. It was just enough information to get you started; to learn about all of Bastille's cool features—like auditing your jails for vulnerabilities and updating software within them—in the [documentation][14]. +I hope that this article inspires you to try FreeBSD and Bastille on your Raspberry Pi. It was just enough information to get you started; to learn about all of Bastille's cool features—like auditing your jails for vulnerabilities and updating software within them—in the [documentation][13]. -------------------------------------------------------------------------------- via: https://opensource.com/article/21/3/bastille-raspberry-pi 作者:[Peter Czanik][a] -选题:[lujun9972][b] +选题:[lkxed][b] 译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]: https://opensource.com/users/czanik -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/containers_modules_networking_hardware_parts.png?itok=rPpVj92- (Parts, modules, containers for software) +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/containers_modules_networking_hardware_parts.png [2]: https://opensource.com/article/18/1/history-low-level-container-runtimes [3]: https://docs.freebsd.org/en/books/handbook/jails/ [4]: https://opensource.com/article/18/11/behind-scenes-linux-containers @@ -278,7 +263,6 @@ via: https://opensource.com/article/21/3/bastille-raspberry-pi [8]: https://opensource.com/article/19/3/netbsd-raspberry-pi [9]: https://www.freebsd.org/where/ [10]: https://en.wikipedia.org/wiki/PF_(firewall) -[11]: mailto:git@github.com -[12]: https://www.syslog-ng.com/ -[13]: https://gitlab.com/BastilleBSD-Templates/ -[14]: https://bastille.readthedocs.io/en/latest/ +[11]: https://www.syslog-ng.com/ +[12]: https://gitlab.com/BastilleBSD-Templates/ +[13]: https://bastille.readthedocs.io/en/latest/ diff --git a/sources/tech/20210316 Get started with edge computing by programming embedded systems.md b/sources/tech/20210316 Get started with edge computing by programming embedded systems.md index 5899e54827..a51532e521 100644 --- a/sources/tech/20210316 Get started with edge computing by programming embedded systems.md +++ b/sources/tech/20210316 Get started with edge computing by programming embedded systems.md @@ -1,18 +1,20 @@ -[#]: subject: (Get started with edge computing by programming embedded systems) -[#]: via: (https://opensource.com/article/21/3/rtos-embedded-development) -[#]: author: (Alan Smithee https://opensource.com/users/alansmithee) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: subject: "Get started with edge computing by programming embedded systems" +[#]: via: "https://opensource.com/article/21/3/rtos-embedded-development" +[#]: author: "Alan Smithee https://opensource.com/users/alansmithee" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " Get started with edge computing by programming embedded systems ====== -The AT device package for controlling wireless modems is one of RTOS's -most popular extensions. +The AT device package for controlling wireless modems is one of RTOS's most popular extensions. + ![Looking at a map][1] +Image by: opensource.com + RTOS is an open source [operating system for embedded devices][2] developed by RT-Thread. It provides a standardized, friendly foundation for developers to program a variety of devices and includes a large number of useful libraries and toolkits to make the process easier. Like Linux, RTOS uses a modular approach, which makes it easy to extend. Packages enable developers to use RTOS for any device they want to target. One of RTOS's most popular extensions is the AT device package, which includes porting files and sample code for different AT devices (i.e., modems). @@ -37,77 +39,71 @@ The at_device package is distributed under an LGPLv2.1 license, and it's easy to To use AT devices with RTOS, you must enable the AT component library and AT socket functionality. This requires: - * RT_Thread 4.0.2+ - * RT_Thread AT component 1.3.0+ - * RT_Thread SAL component - * RT-Thread netdev component - - +* RT_Thread 4.0.2+ +* RT_Thread AT component 1.3.0+ +* RT_Thread SAL component +* RT-Thread netdev component The AT device package has been updated for multiple versions. Different versions require different configuration options, so they must fit into the corresponding system versions. Most of the currently available AT device package versions are: - * V1.2.0: For RT-Thread versions less than V3.1.3, AT component version equals V1.0.0 - * V1.3.0: For RT-Thread versions less than V3.1.3, AT component version equals V1.1.0 - * V1.4.0: For RT-Thread versions less than V3.1.3 or equal to V4.0.0, AT component version equals V1.2.0 - * V1.5.0: For RT-Thread versions less than V3.1.3 or equal to V4.0.0, AT component version equals V1.2.0 - * V1.6.0: For RT-Thread versions equal to V3.1.3 or V4.0.1, AT component version equals V1.2.0 - * V2.0.0/V2.0.1: For RT-Thread versions higher than V4.0.1 or higher than 3.1.3, AT component version equals V1.3.0 - * Latest version: For RT-Thread versions higher than V4.0.1 or higher than 3.1.3, AT component version equals V1.3.0 - - +* V1.2.0: For RT-Thread versions less than V3.1.3, AT component version equals V1.0.0 +* V1.3.0: For RT-Thread versions less than V3.1.3, AT component version equals V1.1.0 +* V1.4.0: For RT-Thread versions less than V3.1.3 or equal to V4.0.0, AT component version equals V1.2.0 +* V1.5.0: For RT-Thread versions less than V3.1.3 or equal to V4.0.0, AT component version equals V1.2.0 +* V1.6.0: For RT-Thread versions equal to V3.1.3 or V4.0.1, AT component version equals V1.2.0 +* V2.0.0/V2.0.1: For RT-Thread versions higher than V4.0.1 or higher than 3.1.3, AT component version equals V1.3.0 +* Latest version: For RT-Thread versions higher than V4.0.1 or higher than 3.1.3, AT component version equals V1.3.0 Getting the right version is mostly an automatic process done in menuconfig. It provides the best version of the at_device package based on your current system environment. As mentioned, different versions require different configuration options. For instance, version 1.x supports enabling one AT device at a time: - ``` -RT-Thread online packages  ---> -     IoT - internet of things  ---> +RT-Thread online packages  ---> +     IoT - internet of things  --->         -*- AT DEVICE: RT-Thread AT component porting or samples for different device           [ ]   Enable at device init by thread -              AT socket device modules (Not selected, please select)  --->     -              Version (V1.6.0)  ---> +              AT socket device modules (Not selected, please select)  --->     +              Version (V1.6.0)  ---> ``` The option to enable the AT device init by thread dictates whether the configuration creates a separate thread to initialize the device network. Version 2.x supports enabling multiple AT devices at the same time: - ``` -RT-Thread online packages  ---> -     IoT - internet of things  ---> +RT-Thread online packages  ---> +     IoT - internet of things  --->         -*- AT DEVICE: RT-Thread AT component porting or samples for different device -        [*]   Quectel M26/MC20  ---> +        [*]   Quectel M26/MC20  --->           [*]   Enable initialize by thread           [*]   Enable sample           (-1)    Power pin           (-1)    Power status pin           (uart3) AT client device name           (512)   The maximum length of receive line buffer -        [ ]   Quectel EC20  ---> -        [ ]   Espressif ESP32  ---> -        [*]   Espressif ESP8266  ---> +        [ ]   Quectel EC20  ---> +        [ ]   Espressif ESP32  ---> +        [*]   Espressif ESP8266  --->           [*]   Enable initialize by thread           [*]   Enable sample           (realthread) WIFI ssid           (12345678) WIFI password           (uart2) AT client device name           (512)   The maximum length of receive line buffer -        [ ]   Realthread RW007  ---> -        [ ]   SIMCom SIM800C  ---> -        [ ]   SIMCom SIM76XX  ---> -        [ ]   Notion MW31  ---> -        [ ]   WinnerMicro W60X  ---> -        [ ]   AiThink A9/A9G  ---> -        [ ]   Quectel BC26  ---> -        [ ]   Luat air720  ---> -        [ ]   GOSUNCN ME3616  ---> -        [ ]   ChinaMobile M6315  ---> -        [ ]   Quectel BC28  ---> -        [ ]   Quectel ec200x  ---> -        Version (latest)  ---> +        [ ]   Realthread RW007  ---> +        [ ]   SIMCom SIM800C  ---> +        [ ]   SIMCom SIM76XX  ---> +        [ ]   Notion MW31  ---> +        [ ]   WinnerMicro W60X  ---> +        [ ]   AiThink A9/A9G  ---> +        [ ]   Quectel BC26  ---> +        [ ]   Luat air720  ---> +        [ ]   GOSUNCN ME3616  ---> +        [ ]   ChinaMobile M6315  ---> +        [ ]   Quectel BC28  ---> +        [ ]   Quectel ec200x  ---> +        Version (latest)  ---> ``` This version includes many other options, including one to enable sample code, which might be particularly useful to new developers or any developer using an unfamiliar device. @@ -116,24 +112,21 @@ You can also control options to choose which pin you want to use to supply power In short, there is no shortage of control options. - * V2.X.X version supports enabling multiple AT devices simultaneously, and the enabled device information can be viewed with the `ifocnfig` command in [finsh shell][6]. - * V2.X.X version requires the device to register before it's used; the registration can be done in the samples directory file or customized in the application layer. - * Pin options such as **Power pin** and **Power status pin** are configured according to the device's hardware connection. They can be configured as `-1` if the hardware power-on function is not used. - * One AT device should correspond to one serial name, and the **AT client device name** for each device should be different. - - +* V2.X.X version supports enabling multiple AT devices simultaneously, and the enabled device information can be viewed with the `ifocnfig` command in [finsh shell][6]. +* V2.X.X version requires the device to register before it's used; the registration can be done in the samples directory file or customized in the application layer. +* Pin options such as Power pin and Power status pin are configured according to the device's hardware connection. They can be configured as `-1` if the hardware power-on function is not used. +* One AT device should correspond to one serial name, and the AT client device name for each device should be different. ### AT components configuration options When the AT device package is selected and device support is enabled, client functionality for the AT component is selected by default. That means more options—this time for the AT component: - ``` -RT-Thread Components  ---> -    Network  ---> -        AT commands  ---> +RT-Thread Components  ---> +    Network  ---> +        AT commands  --->     [ ]   Enable debug log output -    [ ]   Enable AT commands server +    [ ]   Enable AT commands server     -*-   Enable AT commands client     (1)     The maximum number of supported clients     -*-     Enable BSD Socket API support by AT commnads @@ -144,11 +137,9 @@ RT-Thread Components  ---> The configuration options related to the AT device package are: - * **The maximum number of supported clients**: Selecting multiple devices in the AT device package requires this option to be configured as the corresponding value. - * **Enable BSD Socket API support by AT commands**: This option will be selected by default when selecting the AT device package. - * **The maximum length of AT Commands buffe:** The maximum length of the data the AT commands can send. - - +* The maximum number of supported clients: Selecting multiple devices in the AT device package requires this option to be configured as the corresponding value. +* Enable BSD Socket API support by AT commands: This option will be selected by default when selecting the AT device package. +* The maximum length of AT Commands buffe: The maximum length of the data the AT commands can send. ### Anything is possible @@ -159,15 +150,15 @@ When you start programming embedded systems, you quickly realize that you can cr via: https://opensource.com/article/21/3/rtos-embedded-development 作者:[Alan Smithee][a] -选题:[lujun9972][b] +选题:[lkxed][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/alansmithee -[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) +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/tips_map_guide_ebook_help_troubleshooting_lightbulb_520.png [2]: https://opensource.com/article/20/6/open-source-rtos [3]: https://en.wikipedia.org/wiki/Berkeley_sockets [4]: https://github.com/RT-Thread/rtthread-manual-doc/blob/master/at/at.md diff --git a/sources/tech/20210318 Get started with an open source customer data platform.md b/sources/tech/20210318 Get started with an open source customer data platform.md index 9cdbc1d34d..ec2f2c9afa 100644 --- a/sources/tech/20210318 Get started with an open source customer data platform.md +++ b/sources/tech/20210318 Get started with an open source customer data platform.md @@ -1,19 +1,20 @@ -[#]: subject: (Get started with an open source customer data platform) -[#]: via: (https://opensource.com/article/21/3/rudderstack-customer-data-platform) -[#]: author: (Amey Varangaonkar https://opensource.com/users/ameypv) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: subject: "Get started with an open source customer data platform" +[#]: via: "https://opensource.com/article/21/3/rudderstack-customer-data-platform" +[#]: author: "Amey Varangaonkar https://opensource.com/users/ameypv" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " Get started with an open source customer data platform ====== -As an open source alternative to Segment, RudderStack collects and -routes event stream (or clickstream) data and automatically builds your -customer data lake on your data warehouse. +As an open source alternative to Segment, RudderStack collects and routes event stream (or clickstream) data and automatically builds your customer data lake on your data warehouse. + ![Person standing in front of a giant computer screen with numbers, data][1] +Image by: Opensource.com + [RudderStack][2] is an open source, warehouse-first customer data pipeline. It collects and routes event stream (or clickstream) data and automatically builds your customer data lake on your data warehouse. RudderStack is commonly known as the open source alternative to the customer data platform (CDP), [Segment][3]. It provides a more secure, flexible, and cost-effective solution in comparison. You get all the CDP functionality with added security and full ownership of your customer data. @@ -24,60 +25,51 @@ Warehouse-first tools like RudderStack are architected to build functional data Before you get started, you will need the RudderStack workspace token from your RudderStack dashboard. To get it: - 1. Go to the [RudderStack dashboard][4]. - - 2. Log in using your credentials (or sign up for an account, if you don't already have one). - -![RudderStack login screen][5] - -(RudderStack, [CC BY-SA 4.0][6]) - - 3. Once you've logged in, you should see the workspace token on your RudderStack dashboard. - -![RudderStack workspace token][7] - -(RudderStack, [CC BY-SA 4.0][6]) +1. Go to the [RudderStack dashboard][4]. +2. Log in using your credentials (or sign up for an account, if you don't already have one). + ![RudderStack login screen][7] +3. Once you've logged in, you should see the workspace token on your RudderStack dashboard. + ![RudderStack workspace token][8] ### Installing RudderStack Setting up a RudderStack open source instance is straightforward. You have two installation options: - 1. On your Kubernetes cluster, using RudderStack's Helm charts - 2. On your Docker container, using the `docker-compose` command +1. On your Kubernetes cluster, using RudderStack's Helm charts +2. On your Docker container, using the `docker-compose` command - - -This tutorial explains how to use both options but assumes that you already have [Git installed on your system][8]. +This tutorial explains how to use both options but assumes that you already have [Git installed on your system][9]. #### Deploying with Kubernetes -You can deploy RudderStack on your Kubernetes cluster using the [Helm][9] package manager. +You can deploy RudderStack on your Kubernetes cluster using the [Helm][10] package manager. -_If you plan to use RudderStack in production, we strongly recommend using this method._ This is because the Docker images are updated with bug fixes more frequently than the GitHub repository (which follows a monthly release cycle). +*If you plan to use RudderStack in production, we strongly recommend using this method.* This is because the Docker images are updated with bug fixes more frequently than the GitHub repository (which follows a monthly release cycle). Before you can deploy RudderStack on Kubernetes, make sure you have the following prerequisites in place: - * [Install and connect kubectl][10] to your Kubernetes cluster. - * [Install Helm][11] on your system, either through the Helm installer scripts or its package manager. - * Finally, get the workspace token from the RudderStack dashboard by following the steps in the [Getting the RudderStack workspace token][12] section. - - +* [Install and connect kubectl][11] to your Kubernetes cluster. +* [Install Helm][12] on your system, either through the Helm installer scripts or its package manager. +* Finally, get the workspace token from the RudderStack dashboard by following the steps in the Getting the RudderStack workspace token section. Once you've completed all the prerequisites, deploy RudderStack on your default Kubernetes cluster: - 1. Find the Helm chart required to deploy RudderStack in this [repo][13]. - 2. Install the Helm chart with a release name of your choice (`my-release`, in this example) from the root directory of the repo in the previous step: [code] $ helm install \ -my-release ./ --set \ -rudderWorkspaceToken="<your workspace token from RudderStack dashboard>" -``` +1. Find the Helm chart required to deploy RudderStack in this [repo][13]. +2. Install the Helm chart with a release name of your choice (my-release, in this example) from the root directory of the repo in the previous step: + ``` + $ helm install \ + my-release ./ --set \ + rudderWorkspaceToken="" + ``` + This deploys RudderStack on your default Kubernetes cluster configured with kubectl using the workspace token you obtained from the RudderStack dashboard. For more details on the configurable parameters in the RudderStack Helm chart or updating the versions of the images used, consult the [documentation][14]. -### Deploying with Docker +#### Deploying with Docker Docker is the easiest and fastest way to set up your open source RudderStack instance. @@ -85,12 +77,12 @@ First, get the workspace token from the RudderStack dashboard by following the s Once you have the RudderStack workspace token: - 1. Download the [**rudder-docker.yml**][15] docker-compose file required for the installation. - 2. Replace `` in this file with your RudderStack workspace token. - 3. Set up RudderStack on your Docker container by running: [code]`docker-compose -f rudder-docker.yml up` -``` - - +1. Download the [rudder-docker.yml][15] docker-compose file required for the installation. +2. Replace `` in this file with your RudderStack workspace token. +3. Set up RudderStack on your Docker container by running: + ``` + docker-compose -f rudder-docker.yml up + ``` Now RudderStack should be up and running on your Docker instance. @@ -98,128 +90,115 @@ Now RudderStack should be up and running on your Docker instance. You can verify your RudderStack installation by sending test events using the bundled shell script: - 1. Clone the GitHub repository: [code]`git clone https://github.com/rudderlabs/rudder-server.git` -``` - 2. In this tutorial, you will verify RudderStack by sending test events to Google Analytics. Make sure you have a Google Analytics account and keep the tracking ID handy. Also, note that the Google Analytics account needs to have a `Web` property. +1. Clone the GitHub repository: + ``` + git clone https://github.com/rudderlabs/rudder-server.git + ``` +2. In this tutorial, you will verify RudderStack by sending test events to Google Analytics. Make sure you have a Google Analytics account and keep the tracking ID handy. Also, note that the Google Analytics account needs to have a `Web` property. +3. In the [RudderStack hosted control plane][16]: + * Add a source on the RudderStack dashboard by following the [Adding a source and destination in RudderStack][17] guide. You can use either of RudderStack's event stream software development kits (SDKs) for sending events from your app. This example sets up the [JavaScript SDK][18] as a source on the dashboard. Note: You aren't actually installing the RudderStack JavaScript SDK on your site in this step; you are just creating the source in RudderStack. + * Configure a Google Analytics destination on the RudderStack dashboard using the instructions in the guide mentioned previously. Use the Google Analytics tracking ID you kept from step 2 of this section: - 3. In the [RudderStack hosted control plane][4]: - - * Add a source on the RudderStack dashboard by following the [Adding a source and destination in RudderStack][16] guide. You can use either of RudderStack's event stream software development kits (SDKs) for sending events from your app. This example sets up the [JavaScript SDK][17] as a source on the dashboard. **Note:** You aren't actually installing the RudderStack JavaScript SDK on your site in this step; you are just creating the source in RudderStack. - - * Configure a Google Analytics destination on the RudderStack dashboard using the instructions in the guide mentioned previously. Use the Google Analytics tracking ID you kept from step 2 of this section: - -![Google Analytics tracking ID][18] - -(RudderStack, [CC BY-SA 4.0][6]) - - 4. As mentioned before, RudderStack bundles a shell script that generates test events. Get the **Source write key** from the RudderStack dashboard: - -![RudderStack source write key][19] - -(RudderStack, [CC BY-SA 4.0][6]) - - 5. Next, run: [code]`./scripts/generate-event https://hosted.rudderlabs.com/v1/batch` -``` - - 6. Finally, log into your Google Analytics account and verify that the events were delivered. In your Google Analytics account, navigate to **RealTime** -> **Events**. The RealTime view is important because some dashboards can take one to two days to refresh. + ![Google Analytics tracking ID][27] +4. As mentioned before, RudderStack bundles a shell script that generates test events. Get the **Source write key** from the RudderStack dashboard: + ![RudderStack source write key][28] +5. Next, run: + ``` + ./scripts/generate-event https://hosted.rudderlabs.com/v1/batch + ``` +6. Finally, log into your Google Analytics account and verify that the events were delivered. In your Google Analytics account, navigate to *RealTime** -> **Events**. The RealTime view is important because some dashboards can take one to two days to refresh. ### Optional: Setting up the open source control plane -RudderStack's core architecture contains two major components: the data plane and the control plane. The data plane, [rudder-server][20], delivers your event data, and the RudderStack hosted control plane manages the configuration of your sources and destinations. +RudderStack's core architecture contains two major components: the data plane and the control plane. The data plane, [rudder-server][29], delivers your event data, and the RudderStack hosted control plane manages the configuration of your sources and destinations. -However, if you want to manage the source and destination configurations locally, you can set an open source control plane in your environment using the RudderStack Config Generator. (You must have [Node.js][21] installed on your system to use it.) +However, if you want to manage the source and destination configurations locally, you can set an open source control plane in your environment using the RudderStack Config Generator. (You must have [Node.js][30] installed on your system to use it.) Here are the steps to set up the control plane: - 1. Install and set up RudderStack on the platform of your choice by following the instructions above. - 2. Run the following commands in this order: - * `cd utils/config-gen` - * `npm install` - * `npm start` - - +1. Install and set up RudderStack on the platform of your choice by following the instructions above. +2. Run the following commands in this order: + ``` + cd utils/config-gen + npm install + npm start + ``` You should now be able to access the open source control plane at `http://localhost:3000` by default. If your setup is successful, you will see the user interface. -![RudderStack open source control plane][22] +![RudderStack open source control plane][31] -(RudderStack, [CC BY-SA 4.0][6]) - -To export the existing workspace configuration from the RudderStack-hosted control plane and have RudderStack use it, consult the [docs][23]. +To export the existing workspace configuration from the RudderStack-hosted control plane and have RudderStack use it, consult the [docs][32]. ### RudderStack and open source -The core of RudderStack is in the [rudder-server][20] repository. It is open source, licensed under [AGPL-3.0][24]. A majority of the destination integrations live in the [rudder-transformer][25] repository. They are open source as well, licensed under the [MIT License][26]. The SDKs and instrumentation repositories, several tool and utility repositories, and even some [dbt][27] model repositories for use-cases like customer journey analysis and sessionization for the data residing in your data warehouse are open source, licensed under the MIT License, and available in the [GitHub repository][28]. +The core of RudderStack is in the [rudder-server][33] repository. It is open source, licensed under [AGPL-3.0][34]. A majority of the destination integrations live in the [rudder-transformer][35] repository. They are open source as well, licensed under the [MIT License][36]. The SDKs and instrumentation repositories, several tool and utility repositories, and even some [dbt][37] model repositories for use-cases like customer journey analysis and sessionization for the data residing in your data warehouse are open source, licensed under the MIT License, and available in the [GitHub repository][38]. -You can use RudderStack's open source offering, rudder-server, on your platform of choice. There are setup guides for [Docker][29], [Kubernetes][30], [native installation][31], and [developer machines][32]. +You can use RudderStack's open source offering, rudder-server, on your platform of choice. There are setup guides for [Docker][39], [Kubernetes][40], [native installation][41], and [developer machines][42]. RudderStack open source offers: - 1. RudderStack event stream - 2. 15+ SDKs and source integrations to ingest event data - 3. 80+ destination and warehouse integrations - 4. Slack community support - - +1. RudderStack event stream +2. 15+ SDKs and source integrations to ingest event data +3. 80+ destination and warehouse integrations +4. Slack community support #### RudderStack Cloud -RudderStack also offers a managed option, [RudderStack Cloud][33]. It is fast, reliable, and highly scalable with a multi-node architecture and sophisticated error-handling mechanism. You can hit peak event volume without worrying about downtime, loss of events, or latency. +RudderStack also offers a managed option, [RudderStack Cloud][43]. It is fast, reliable, and highly scalable with a multi-node architecture and sophisticated error-handling mechanism. You can hit peak event volume without worrying about downtime, loss of events, or latency. -Explore our open source repos on [GitHub][28], subscribe to [our blog][34], and follow us on social media: [Twitter][35], [LinkedIn][36], [dev.to][37], [Medium][38], and [YouTube][39]! +Image By: (RudderStack, CC BY-SA 4.0) -------------------------------------------------------------------------------- via: https://opensource.com/article/21/3/rudderstack-customer-data-platform 作者:[Amey Varangaonkar][a] -选题:[lujun9972][b] +选题:[lkxed][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/ameypv -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/data_metrics_analytics_desktop_laptop.png [2]: https://rudderstack.com/ [3]: https://segment.com/ [4]: https://app.rudderstack.com/ -[5]: https://opensource.com/sites/default/files/uploads/rudderstack_login.png (RudderStack login screen) -[6]: https://creativecommons.org/licenses/by-sa/4.0/ -[7]: https://opensource.com/sites/default/files/uploads/rudderstack_workspace-token.png (RudderStack workspace token) -[8]: https://opensource.com/life/16/7/stumbling-git -[9]: https://helm.sh/ -[10]: https://kubernetes.io/docs/tasks/tools/install-kubectl/ -[11]: https://helm.sh/docs/intro/install/ -[12]: tmp.AhGpFIyrbZ#token +[7]: https://opensource.com/sites/default/files/uploads/rudderstack_login.png +[8]: https://opensource.com/sites/default/files/uploads/rudderstack_workspace-token.png +[9]: https://opensource.com/life/16/7/stumbling-git +[10]: https://helm.sh/ +[11]: https://kubernetes.io/docs/tasks/tools/install-kubectl/ +[12]: https://helm.sh/docs/intro/install/ [13]: https://github.com/rudderlabs/rudderstack-helm [14]: https://docs.rudderstack.com/installing-and-setting-up-rudderstack/kubernetes [15]: https://raw.githubusercontent.com/rudderlabs/rudder-server/master/rudder-docker.yml -[16]: https://docs.rudderstack.com/get-started/adding-source-and-destination-rudderstack -[17]: https://docs.rudderstack.com/rudderstack-sdk-integration-guides/rudderstack-javascript-sdk -[18]: https://opensource.com/sites/default/files/uploads/googleanalyticstrackingid.png (Google Analytics tracking ID) -[19]: https://opensource.com/sites/default/files/uploads/rudderstack_sourcewritekey.png (RudderStack source write key) -[20]: https://github.com/rudderlabs/rudder-server -[21]: https://nodejs.org/en/download/ -[22]: https://opensource.com/sites/default/files/uploads/rudderstack_controlplane.png (RudderStack open source control plane) -[23]: https://docs.rudderstack.com/how-to-guides/rudderstack-config-generator -[24]: https://www.gnu.org/licenses/agpl-3.0-standalone.html -[25]: https://github.com/rudderlabs/rudder-transformer -[26]: https://opensource.org/licenses/MIT -[27]: https://www.getdbt.com/ -[28]: https://github.com/rudderlabs -[29]: https://docs.rudderstack.com/get-started/installing-and-setting-up-rudderstack/docker -[30]: https://docs.rudderstack.com/get-started/installing-and-setting-up-rudderstack/kubernetes -[31]: https://docs.rudderstack.com/get-started/installing-and-setting-up-rudderstack/native-installation -[32]: https://docs.rudderstack.com/get-started/installing-and-setting-up-rudderstack/developer-machine-setup -[33]: https://resources.rudderstack.com/rudderstack-cloud -[34]: https://rudderstack.com/blog/ -[35]: https://twitter.com/RudderStack -[36]: https://www.linkedin.com/company/rudderlabs/ -[37]: https://dev.to/rudderstack -[38]: https://rudderstack.medium.com/ -[39]: https://www.youtube.com/channel/UCgV-B77bV_-LOmKYHw8jvBw +[16]: https://app.rudderstack.com/ +[17]: https://docs.rudderstack.com/get-started/adding-source-and-destination-rudderstack +[18]: https://docs.rudderstack.com/rudderstack-sdk-integration-guides/rudderstack-javascript-sdk +[20]: https://docs.rudderstack.com/get-started/adding-source-and-destination-rudderstack +[21]: https://docs.rudderstack.com/rudderstack-sdk-integration-guides/rudderstack-javascript-sdk +[24]: https://docs.rudderstack.com/get-started/adding-source-and-destination-rudderstack +[25]: https://docs.rudderstack.com/rudderstack-sdk-integration-guides/rudderstack-javascript-sdk +[27]: https://opensource.com/sites/default/files/uploads/googleanalyticstrackingid.png +[28]: https://opensource.com/sites/default/files/uploads/rudderstack_sourcewritekey.png +[29]: https://github.com/rudderlabs/rudder-server +[30]: https://nodejs.org/en/download/ +[31]: https://opensource.com/sites/default/files/uploads/rudderstack_controlplane.png +[32]: https://docs.rudderstack.com/how-to-guides/rudderstack-config-generator +[33]: https://github.com/rudderlabs/rudder-server +[34]: https://www.gnu.org/licenses/agpl-3.0-standalone.html +[35]: https://github.com/rudderlabs/rudder-transformer +[36]: https://opensource.org/licenses/MIT +[37]: https://www.getdbt.com/ +[38]: https://github.com/rudderlabs +[39]: https://docs.rudderstack.com/get-started/installing-and-setting-up-rudderstack/docker +[40]: https://docs.rudderstack.com/get-started/installing-and-setting-up-rudderstack/kubernetes +[41]: https://docs.rudderstack.com/get-started/installing-and-setting-up-rudderstack/native-installation +[42]: https://docs.rudderstack.com/get-started/installing-and-setting-up-rudderstack/developer-machine-setup +[43]: https://resources.rudderstack.com/rudderstack-cloud diff --git a/sources/tech/20210319 Create a countdown clock with a Raspberry Pi.md b/sources/tech/20210319 Create a countdown clock with a Raspberry Pi.md deleted file mode 100644 index bc376bd374..0000000000 --- a/sources/tech/20210319 Create a countdown clock with a Raspberry Pi.md +++ /dev/null @@ -1,393 +0,0 @@ -[#]: subject: (Create a countdown clock with a Raspberry Pi) -[#]: via: (https://opensource.com/article/21/3/raspberry-pi-countdown-clock) -[#]: author: (Chris Collins https://opensource.com/users/clcollins) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Create a countdown clock with a Raspberry Pi -====== -Start counting down the days to your next holiday with a Raspberry Pi -and an ePaper display. -![Alarm clocks with different time][1] - -For 2021, [Pi Day][2] has come and gone, leaving fond memories and [plenty of Raspberry Pi projects][3] to try out. The days after any holiday can be hard when returning to work after high spirits and plenty of fun, and Pi Day is no exception. As we look into the face of the Ides of March, we can long for the joys of the previous, well, day. But fear no more, dear Pi Day celebrant! For today, we begin the long countdown to the next Pi Day! - -OK, but seriously. I made a Pi Day countdown timer, and you can too! - -A while back, I purchased a [Raspberry Pi Zero W][4] and recently used it to [figure out why my WiFi was so bad][5]. I was also intrigued by the idea of getting an ePaper display for the little Zero W. I didn't have a good use for one, but, dang it, it looked like fun! I purchased a little 2.13" [Waveshare display][6], which fit perfectly on top of the Raspberry Pi Zero W. It's easy to install: Just slip the display down onto the Raspberry Pi's GIPO headers and you're good to go. - -I used [Raspberry Pi OS][7] for this project, and while it surely can be done with other operating systems, the `raspi-config` command, used below, is most easily available on Raspberry Pi OS. - -### Set up the Raspberry Pi and the ePaper display - -Setting up the Raspberry Pi to work with the ePaper display requires you to enable the Serial Peripheral Interface (SPI) in the Raspberry Pi software, install the BCM2835 C libraries (to access the GPIO functions for the Broadcom BCM 2835 chip on the Raspberry Pi), and install Python GPIO libraries to control the ePaper display. Finally, you need to install the Waveshare libraries for working with the 2.13" display using Python. - -Here's a step-by-step walkthrough of how to do these tasks. - -#### Enable SPI - -The easiest way to enable SPI is with the Raspberry Pi `raspi-config` command. The SPI bus allows serial data communication to be used with devices—in this case, the ePaper display: - - -``` -`$ sudo raspi-config` -``` - -From the menu that pops up, select **Interfacing Options** -> **SPI** -> **Yes** to enable the SPI interface, then reboot. - -#### Install BCM2835 libraries - -As mentioned above, the BCM2835 libraries are software for the Broadcom BCM2385 chip on the Raspberry Pi, which allows access to the GPIO pins and the ability to use them to control devices. - -As I'm writing this, the latest version of the Broadcom BCM 2835 libraries for the Raspberry Pi is v1.68. To install the libraries, you need to download the software tarball and build and install the software with `make`: - - -``` -# Download the BCM2853 libraries and extract them -$ curl -sSL -o - | tar -xzf - - -# Change directories into the extracted code -$ pushd bcm2835-1.68/ - -# Configure, build, check and install the BCM2853 libraries -$ sudo ./configure -$ sudo make check -$ sudo make install - -# Return to the original directory -$ popd -``` - -#### Install required Python libraries - -You also need some Python libraries to use Python to control the ePaper display, the `RPi.GPIO` pip package. You also need the `python3-pil` package for drawing shapes. Apparently, the PIL package is all but dead, but there is an alternative, [Pillow][8]. I have not tested Pillow for this project, but it may work: - - -``` -# Install the required Python libraries -$ sudo apt-get update -$ sudo apt-get install python3-pip python3-pil -$ sudo pip3 install RPi.GPIO -``` - -_Note: These instructions are for Python 3. You can find Python 2 instructions on Waveshare's website_ - -#### Download Waveshare examples and Python libraries - -Waveshare maintains a Git repository with Python and C libraries for working with its ePaper displays and some examples that show how to use them. For this countdown clock project, you will clone this repository and use the libraries for the 2.13" display: - - -``` -# Clone the WaveShare e-Paper git repository -$ git clone -``` - -If you're using a different display or a product from another company, you'll need to use the appropriate software for your display. - -Waveshare provides instructions for most of the above on its website: - - * [WaveShare ePaper setup instructions][9] - * [WaveShare ePaper libraries install instructions][10] - - - -#### Get a fun font (optional) - -You can display your timer however you want, but why not do it with a little style? Find a cool font to work with! - -There's a ton of [Open Font License][11] fonts available out there. I am particularly fond of Bangers. You've seen this if you've ever watched YouTube—it's used _all over_. It can be downloaded and dropped into your user's local shared fonts directory to make it available for any application, including this project: - - -``` -# The "Bangers" font is a Open Fonts License licensed font by Vernon Adams () from Google Fonts -$ mkdir -p ~/.local/share/fonts -$ curl -sSL -o fonts/Bangers-Regular.ttf -``` - -### Create a Pi Day countdown timer - -Now that you have installed the software to work with the ePaper display and a fun font to use, you can build something cool with it: a timer to count down to the next Pi Day! - -If you want, you can just grab the [countdown.py][12] Python file from this project's [GitHub repo][13] and skip to the end of this article. - -For the curious, I'll break down that file, section by section. - -#### Import some libraries - - -``` -#!/usr/bin/python3 -# -*- coding:utf-8 -*- -import logging -import os -import sys -import time - -from datetime import datetime -from pathlib import Path -from PIL import Image,ImageDraw,ImageFont - -logging.basicConfig(level=logging.INFO) - -basedir = Path(__file__).parent -waveshare_base = basedir.joinpath('e-Paper', 'RaspberryPi_JetsonNano', 'python') -libdir = waveshare_base.joinpath('lib') -``` - -At the start, the Python script imports some standard libraries used later in the script. You also need to add `Image`, `ImageDraw`, and `ImageFont` from the PIL package, which you'll use to draw some simple geometric shapes. Finally, set some variables for the local `lib` directory that contains the Waveshare Python libraries for working with the 2.13" display, and which you can use later to load the library from the local directory. - -#### Font size helper function - -The next part of the script has a helper function for setting the font size for your chosen font: Bangers-Regular.ttf. It takes an integer for the font size and returns an ImageFont object you can use with the display: - - -``` -def set_font_size(font_size): -    logging.info("Loading font...") -    return ImageFont.truetype(f"{basedir.joinpath('Bangers-Regular.ttf').resolve()}", font_size) -``` - -#### Countdown logic - -Next is a small function that calculates the meat of this project: how long it is until the next Pi Day. If it were, say, January, it would be relatively straightforward to count how many days are left, but you also need to consider whether Pi Day has already passed for the year (sadface), and if so, count how very, very many days are ahead until you can celebrate again: - - -``` -def countdown(now): -    piday = datetime(now.year, 3, 14) - -    # Add a year if we're past PiDay -    if piday < now: -        piday = datetime((now.year + 1), 3, 14) - -    days = (piday - now).days - -    logging.info(f"Days till piday: {days}") -    return day -``` - -#### The main function - -Finally, you get to the main function, which initializes the display and begins writing data to it. In this case, you'll write a welcome message and then begin the countdown to the next Pi Day. But first, you need to load the Waveshare library: - - -``` -def main(): - -    if os.path.exists(libdir): -        sys.path.append(f"{libdir}") -        from waveshare_epd import epd2in13_V2 -    else: -        logging.fatal(f"not found: {libdir}") -        sys.exit(1) -``` - -The snippet above checks to make sure the library has been downloaded to a directory alongside the countdown script, and then it loads the `epd2in13_V2` library. If you're using a different display, you will need to use a different library. You can also write your own if you are so inclined. I found it kind of interesting to read the Python code that Waveshare provides with the display. It's considerably less complicated than I would have imagined it to be, if somewhat tedious. - -The next bit of code creates an EPD (ePaper Display) object to interact with the display and initializes the hardware: - - -``` -    logging.info("Starting...") -    try: -        # Create an a display object -        epd = epd2in13_V2.EPD() - -        # Initialize the displace, and make sure it's clear -        # ePaper keeps it's state unless updated! -        logging.info("Initialize and clear...") -        epd.init(epd.FULL_UPDATE) -        epd.Clear(0xFF) -``` - -An interesting aside about ePaper: It uses power only when it changes a pixel from white to black or vice-versa. This means when the power is removed from the device or the application stops for whatever reason, whatever was on the screen remains. That's great from a power-consumption perspective, but it also means you need to clear the display when starting up, or your script will just write over whatever is already on the screen. Hence, `epd.Clear(0xFF)` is used to clear the display when the script starts. - -Next, create a "canvas" where you will draw the rest of your display output: - - -``` -    # Create an image object -    # NOTE: The "epd.heigh" is the LONG side of the screen -    # NOTE: The "epd.width" is the SHORT side of the screen -    # Counter-intuitive... -    logging.info(f"Creating canvas - height: {epd.height}, width: {epd.width}") -    image = Image.new('1', (epd.height, epd.width), 255)  # 255: clear the frame -    draw = ImageDraw.Draw(image) -``` - -This matches the width and height of the display—but it is somewhat counterintuitive, in that the short side of the display is the width. I think of the long side as the width, so this is just something to note. Note that the `epd.height` and `epd.width` are set by the Waveshare library to correspond to the device you're using. - -#### Welcome message - -Next, you'll start to draw something. This involves setting data on the "canvas" object you created above. This doesn't draw it to the ePaper display yet—you're just building the image you want right now. Create a little welcome message celebrating Pi Day, with an image of a piece of pie, drawn by yours truly just for this project: - -![drawing of a piece of pie][14] - -(Chris Collins, [CC BY-SA 4.0][15]) - -Cute, huh? - - -``` -    logging.info("Set text text...") -    bangers64 = set_font_size(64) -    draw.text((0, 30), 'PI DAY!', font = bangers64, fill = 0) - -    logging.info("Set BMP...") -    bmp = Image.open(basedir.joinpath("img", "pie.bmp")) -    image.paste(bmp, (150,2)) -``` - -Finally, _finally_, you get to display the canvas you drew, and it's a little bit anti-climactic: - - -``` -    logging.info("Display text and BMP") -    epd.display(epd.getbuffer(image)) -``` - -That bit above updates the display to show the image you drew. - -Next, prepare another image to display your countdown timer. - -#### Pi Day countdown timer - -First, create a new image object that you can use to draw the display. Also, set some new font sizes to use for the image: - - -``` -    logging.info("Pi Date countdown; press CTRL-C to exit") -    piday_image = Image.new('1', (epd.height, epd.width), 255) -    piday_draw = ImageDraw.Draw(piday_image) - -    # Set some more fonts -    bangers36 = set_font_size(36) -    bangers64 = set_font_size(64) -``` - -To display a ticker like a countdown, it's more efficient to update part of the image, changing the display for only what has changed in the data you want to draw. The next bit of code prepares the display to function this way: - - -``` -    # Prep for updating display -    epd.displayPartBaseImage(epd.getbuffer(piday_image)) -    epd.init(epd.PART_UPDATE) -``` - -Finally, you get to the timer bit, starting an infinite loop that checks how long it is until the next Pi Day and displays the countdown on the ePaper display. If it actually _is_ Pi Day, you can handle that with a little celebration message: - - -``` -    while (True): -        days = countdown(datetime.now()) -        unit = get_days_unit(days) - -        # Clear the bottom half of the screen by drawing a rectangle filld with white -        piday_draw.rectangle((0, 50, 250, 122), fill = 255) - -        # Draw the Header -        piday_draw.text((10,10), "Days till Pi-day:", font = bangers36, fill = 0) - -        if days == 0: -            # Draw the Pi Day celebration text! -            piday_draw.text((0, 50), f"It's Pi Day!", font = bangers64, fill = 0) -        else: -            # Draw how many days until Pi Day -            piday_draw.text((70, 50), f"{str(days)} {unit}", font = bangers64, fill = 0) - -        # Render the screen -        epd.displayPartial(epd.getbuffer(piday_image)) -        time.sleep(5) -``` - -The last bit of the script does some error handling, including some code to catch keyboard interrupts so that you can stop the infinite loop with **Ctrl**+**C** and a small function to print "day" or "days" depending on whether or not the output should be singular (for that one, single day each year when it's appropriate): - - -``` -    except IOError as e: -        logging.info(e) - -    except KeyboardInterrupt: -        logging.info("Exiting...") -        epd.init(epd.FULL_UPDATE) -        epd.Clear(0xFF) -        time.sleep(1) -        epd2in13_V2.epdconfig.module_exit() -        exit() - -def get_days_unit(count): -    if count == 1: -        return "day" - -    return "days" - -if __name__ == "__main__": -    main() -``` - -And there you have it! A script to count down and display how many days are left until Pi Day! Here's an action shot on my Raspberry Pi (sped up by 86,400; I don't have nearly enough disk space to save a day-long video): - -![Pi Day Countdown Timer In Action][16] - -(Chris Collins, [CC BY-SA 4.0][15]) - -#### Install the systemd service (optional) - -If you'd like the countdown display to run whenever the system is turned on and without you having to be logged in and run the script, you can install the optional systemd unit as a [systemd user service][17]). - -Copy the [piday.service][18] file on GitHub to `${HOME}/.config/systemd/user`, first creating the directory if it doesn't exist. Then you can enable the service and start it: - - -``` -$ mkdir -p ~/.config/systemd/user -$ cp piday.service ~/.config/systemd/user -$ systemctl --user enable piday.service -$ systemctl --user start piday.service - -# Enable lingering, to create a user session at boot -# and allow services to run after logout -$ loginctl enable-linger $USER -``` - -The script will output to the systemd journal, and the output can be viewed with the `journalctl` command. - -### It's beginning to look a lot like Pi Day! - -And _there_ you have it! A Pi Day countdown timer, displayed on an ePaper display using a Raspberry Pi Zero W, and starting on system boot with a systemd unit file! Now there are just 350-something days until we can once again come together and celebrate the fantastic device that is the Raspberry Pi. And we can see exactly how many days at a glance with our tiny project. - -But in truth, anyone can hold Pi Day in their hearts year-round, so enjoy creating some fun and educational projects with your own Raspberry Pi! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/3/raspberry-pi-countdown-clock - -作者:[Chris Collins][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/clcollins -[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://en.wikipedia.org/wiki/Pi_Day -[3]: https://opensource.com/tags/raspberry-pi -[4]: https://www.raspberrypi.org/products/raspberry-pi-zero-w/ -[5]: https://opensource.com/article/21/3/troubleshoot-wifi-go-raspberry-pi -[6]: https://www.waveshare.com/product/displays/e-paper.htm -[7]: https://www.raspberrypi.org/software/operating-systems/ -[8]: https://pypi.org/project/Pillow/ -[9]: https://www.waveshare.com/wiki/2.13inch_e-Paper_HAT -[10]: https://www.waveshare.com/wiki/Libraries_Installation_for_RPi -[11]: https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL -[12]: https://github.com/clcollins/epaper-pi-ex/blob/main/countdown.py -[13]: https://github.com/clcollins/epaper-pi-ex/ -[14]: https://opensource.com/sites/default/files/uploads/pie.png (drawing of a piece of pie) -[15]: https://creativecommons.org/licenses/by-sa/4.0/ -[16]: https://opensource.com/sites/default/files/uploads/piday_countdown.gif (Pi Day Countdown Timer In Action) -[17]: https://wiki.archlinux.org/index.php/systemd/User -[18]: https://github.com/clcollins/epaper-pi-ex/blob/main/piday.service diff --git a/sources/tech/20210405 How different programming languages do the same thing.md b/sources/tech/20210405 How different programming languages do the same thing.md deleted file mode 100644 index 01085f7526..0000000000 --- a/sources/tech/20210405 How different programming languages do the same thing.md +++ /dev/null @@ -1,372 +0,0 @@ -[#]: subject: (How different programming languages do the same thing) -[#]: via: (https://opensource.com/article/21/4/compare-programming-languages) -[#]: author: (Jim Hall https://opensource.com/users/jim-hall) -[#]: collector: (lujun9972) -[#]: translator: (VeryZZJ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -How different programming languages do the same thing -====== -Compare 13 different programming languages by writing a simple game. -![Developing code.][1] - -Whenever I start learning a new programming language, I focus on defining variables, writing a statement, and evaluating expressions. Once I have a general understanding of those concepts, I can usually figure out the rest on my own. Most programming languages have some similarities, so once you know one programming language, learning the next one is a matter of figuring out the unique details and recognizing the differences. - -To help me practice a new programming language, I like to write a few test programs. One sample program I often write is a simple "guess the number" game, where the computer picks a number between one and 100 and asks me to guess it. The program loops until I guess correctly. This is a very simple program, as you can see using pseudocode like this: - -* The computer picks a random number between 1 and 100 -* Loop until I guess the random number - + The computer reads my guess - + It tells me if my guess is too low or too high - -Recently, Opensource.com ran an article series that wrote this program in different languages. This was an interesting opportunity to compare how to do the same thing in each language. I also found that most programming languages do things similarly, so learning the next programming language is mostly about learning its differences. - -C is an early general-purpose programming language, created in 1972 at Bell Labs by Dennis Ritchie. C proved popular and quickly became a standard programming language on Unix systems. Because of its popularity, many other programming languages adopted a similar programming syntax. That's why learning C++, Rust, Java, Groovy, JavaScript, awk, or Lua is easier if you already know how to program in C. - -For example, look at how these different programming languages implement the major steps in the "guess the number" game. I'll skip some of the surrounding code, such as assigning temporary variables, to focus on how the basics are similar or different. - -### The computer picks a random number between one and 100 - -You can see a lot of similarities here. Most of the programming languages generate a random number with a function like `rand()` that you can put into a range on your own. Other languages use a special function where you can specify the range for the random value. - -C -```c -// Using the Linux `getrandom` system call -getrandom(&randval, sizeof(int), GRND_NONBLOCK); -number = randval % maxval + 1; - -// Using the standard C library -number = rand() % 100 + 1; -``` - -C++ -```cpp -int number = rand() % 100+1; -``` - -Rust -```rust -let random = rng.gen_range(1..101); -``` - -Java -```java -private static final int NUMBER = r.nextInt(100) + 1; -``` - -Groovy -```groovy -int randomNumber = (new Random()).nextInt(100) + 1 -``` - -JavaScript -```javascript -const randomNumber = Math.floor(Math.random() * 100) + 1 -``` - -awk -```awk -randomNumber = int(rand() * 100) + 1 -``` - -Lua -```lua -number = math.random(1,100) -``` - -### Loop until I guess the random number - -Loops are usually done with a flow-control block such as `while` or `do-while`. The JavaScript implementation doesn't use a loop and instead updates the HTML page "live" until the user guesses the correct number. Awk supports loops, but it doesn't make sense to loop to read input because awk is based around data pipelines, so it reads input from a file instead of directly from the user.  - -C -```c -do { - … -} while (guess != number); -``` - -C++ -```cpp -do { - … -} while ( number != guess ); -``` - -Rust -```rust -for line in std::io::stdin().lock().lines() { - … - break; -} -``` - -Java -```java -while ( guess != NUMBER ) { - … -} -``` - -Groovy -```groovy -while ( … ) { - … - break; -} -``` - -Lua -```lua -while ( player.guess ~= number ) do - … -end -``` - -### The computer reads my guess - -Different programming languages handle input differently. So there's some variation here. For example, JavaScript reads values directly from an HTML form, and awk reads data from its data pipeline. - -C -```c -scanf("%d", &guess); -``` - -C++ -```cpp -cin >> guess; -``` - -Rust -```rust -let parsed = line.ok().as_deref().map(str::parse::); -if let Some(Ok(guess)) = parsed { - … -} -``` - -Java -```java -guess = player.nextInt(); -``` - -Groovy -```groovy -response = reader.readLine() -int guess = response as Integer -``` - -JavaScript -```javascript -let myGuess = guess.value -``` - -awk -```awk -guess = int($0) -``` - -Lua -```lua -player.answer = io.read() -player.guess = tonumber(player.answer) -``` - -### Tell me if my guess is too low or too high - -Comparisons are fairly consistent across these C-like programming languages, usually through an `if` statement. There's some variation in how each programming language prints output, but the print statement remains recognizable across each sample. - -C -```c -if (guess < number) { - puts("Too low"); -} -else if (guess > number) { - puts("Too high"); -} -… -puts("That's right!"); -``` - -C++ -```cpp -if ( guess > number) { cout << "Too high.\n" << endl; } -else if ( guess < number ) { cout << "Too low.\n" << endl; } -else { - cout << "That's right!\n" << endl; - exit(0); -} -``` - -Rust -```rust -_ if guess < random => println!("Too low"), -_ if guess > random => println!("Too high"), -_ => { - println!("That's right"); - break; -} -``` - -Java -```java -if ( guess > NUMBER ) { - System.out.println("Too high"); -} else if ( guess < NUMBER ) { - System.out.println("Too low"); -} else { - System.out.println("That's right!"); - System.exit(0); -} -``` - -Groovy -```groovy -if (guess < randomNumber) - print 'too low, try again: ' -else if (guess > randomNumber) - print 'too high, try again: ' -else { - println "that's right" - break -} -``` - -JavaScript -```javascript -if (myGuess === randomNumber) { - feedback.textContent = "You got it right!" -} else if (myGuess > randomNumber) { - feedback.textContent = "Your guess was " + myGuess + ". That's too high. Try Again!" -} else if (myGuess < randomNumber) { - feedback.textContent = "Your guess was " + myGuess + ". That's too low. Try Again!" -} -``` - -awk -```awk -if (guess < randomNumber) { - printf "too low, try again:" -} else if (guess > randomNumber) { - printf "too high, try again:" -} else { - printf "that's right\n" - exit -} -``` - -Lua -```lua -if ( player.guess > number ) then - print("Too high") -elseif ( player.guess < number) then - print("Too low") -else - print("That's right!") - os.exit() -end -``` - -### What about non-C-based languages? - -Programming languages that are not based on C can be quite different and require learning specific syntax to do each step. Racket derives from Lisp and Scheme, so it uses Lisp's prefix notation and lots of parentheses. Python uses whitespace rather than brackets to indicate blocks like loops. Elixir is a functional programming language with its own syntax. Bash is based on the Bourne shell from Unix systems, which itself borrows from Algol68—and supports additional shorthand notation such as `&&` as a variation of "and." Fortran was created when code was entered using punched cards, so it relies on an 80-column layout where some columns are significant. - -As an example of how these other programming languages can differ, I'll compare just the "if" statement that sees if one value is less than or greater than another and prints an appropriate message to the user. - -Racket -```racket -(cond [(> number guess) (displayln "Too low") (inquire-user number)] - [(< number guess) (displayln "Too high") (inquire-user number)] - [else (displayln "Correct!")])) -``` - -Python -```python -if guess < random: - print("Too low") -elif guess > random: - print("Too high") -else: - print("That's right!") -``` - -Elixir -```elixir -cond do - guess < num -> - IO.puts "Too low!" - guess_loop(num) - guess > num -> - IO.puts "Too high!" - guess_loop(num) - true -> - IO.puts "That's right!" -end -``` - -Bash -```bash -[ "0$guess" -lt $number ] && echo "Too low" -[ "0$guess" -gt $number ] && echo "Too high" -``` - -Fortran -```fortran -IF (GUESS.LT.NUMBER) THEN - PRINT *, 'TOO LOW' -ELSE IF (GUESS.GT.NUMBER) THEN - PRINT *, 'TOO HIGH' -ENDIF -``` - -### Read more - -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. - -Learn how to write the "guess the number" game in C and C-like languages: - -* [C][2], by Jim Hall -* [C++][3], by Seth Kenlon -* [Rust][4], by Moshe Zadka -* [Java][5], by Seth Kenlon -* [Groovy][6], by Chris Hermansen -* [JavaScript][7], by Mandy Kendall -* [awk][8], by Chris Hermansen -* [Lua][9], by Seth Kenlon - -And in non-C-based languages: - -* [Racket][10], by Cristiano L. Fontana -* [Python][11], by Moshe Zadka -* [Elixir][12], by Moshe Zadka -* [Bash][13], by Jim Hall -* [Fortran][14], by Jim Hall - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/4/compare-programming-languages - -作者:[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/code_development_programming.png?itok=M_QDcgz5 (Developing code.) -[2]: https://opensource.com/article/21/1/learn-c -[3]: https://opensource.com/article/20/12/learn-c-game -[4]: https://opensource.com/article/20/12/learn-rust -[5]: https://opensource.com/article/20/12/learn-java -[6]: https://opensource.com/article/20/12/groovy -[7]: https://opensource.com/article/21/1/learn-javascript -[8]: https://opensource.com/article/21/1/learn-awk -[9]: https://opensource.com/article/20/12/lua-guess-number-game -[10]: https://opensource.com/article/21/1/racket-guess-number -[11]: https://opensource.com/article/20/12/learn-python -[12]: https://opensource.com/article/20/12/elixir -[13]: https://opensource.com/article/20/12/learn-bash -[14]: https://opensource.com/article/21/1/fortran diff --git a/sources/tech/20210503 Learn the Lisp programming language in 2021.md b/sources/tech/20210503 Learn the Lisp programming language in 2021.md deleted file mode 100644 index a1de95ead8..0000000000 --- a/sources/tech/20210503 Learn the Lisp programming language in 2021.md +++ /dev/null @@ -1,305 +0,0 @@ -[#]: subject: (Learn the Lisp programming language in 2021) -[#]: via: (https://opensource.com/article/21/5/learn-lisp) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Learn the Lisp programming language in 2021 -====== -A lot of Lisp code lurks inside big codebases, so it's smart to get -familiar with the language. -![Woman sitting in front of her laptop][1] - -Lisp was invented in 1958, which makes it the second-oldest computer programming language. It has spawned several modern derivatives, including Common Lisp, Emacs Lisp (Elisp), Clojure, Racket, Scheme, Fennel, and GNU Guile. - -People who love thinking about the design of programming languages often love Lisp because of how its syntax and data share the same structure: Lisp code is essentially a list of lists, and its name is an acronym for _LISt Processing_. People who love thinking about the aesthetics of programming languages often hate Lisp because of its frequent use of parentheses for scoping; in fact, it's a common joke that Lisp stands for _Lots of Irritating Superfluous Parentheses_. - -Whether you love or hate its design philosophies, Lisp is an interesting glimpse at the past and, thanks to Clojure and Guile, into the future. You might be surprised how much Lisp code there is lurking within big codebases in any given industry, so it's a good idea to have at least a passing familiarity with the language. - -### Install Lisp - -There are many implementations of Lisp. Popular open source versions include [SBCL][2] and [GNU Common Lisp][3] (GCL). You can install either of these with your distribution's package manager. - -On Fedora Linux: - - -``` -`$ sudo dnf install gcl` -``` - -On Debian: - - -``` -`$ sudo apt install gcl` -``` - -For macOS, you can use [MacPorts][4] or [Homebrew][5]: - - -``` -`$ sudo port install gcl` -``` - -For Windows, download a binary from [gnu.org/software/gcl][6]. - -For this article, I'm using GCL and its `clisp` command, but most of the principles apply to any Lisp. - -### List processing - -The basic unit of Lisp source code is an _expression_, which is written as a list. For instance, this is a list of an operator (`+`) and two integers (`1` and `2`): - - -``` -`(+ 1 2)` -``` - -It's also a Lisp expression, using a symbol (`+`) that evaluates to a function (addition) and two arguments (`1` and `2`). You can run this expression and others in an interactive Common Lisp environment called REPL (read-eval-print loop). If you're familiar with Python's IDLE, Lisp's REPL should feel somewhat familiar to you. - -To launch a REPL, launch Common Lisp: - - -``` -$ clisp -[1]> -``` - -At the REPL prompt, type a few expressions: - - -``` -[1]> (+ 1 2) -3 -[2]> (- 1 2) --1 -[3]> (- 2 1) -1 -[4]> (+ 2 3 4) -9 -``` - -### Functions - -Now that you know the basic structure of a Lisp expression, you can utilize Lisp functions in useful ways. The `print` function takes any argument you provide and displays it on your terminal, while the `pprint` function "pretty" prints it. There are other variations on the print function, but `pprint` is nice in REPL: - - -``` -[1]> (pprint "hello world") - -"hello world" - -[2]> -``` - -You can create your own functions with `defun`. The `defun` function requires a name for your function and any parameters you want your function to accept: - - -``` -[1]> (defun myprinter (s) (pprint s)) -MYPRINTER -[2]> (myprinter "hello world") - -"hello world" - -[3]> -``` - -### Variables - -You can create variables in Lisp with `setf`: - - -``` -[1]> (setf foo "hello world") -"hello world" -[2]> (pprint foo) - -"hello world" - -[3]> -``` - -You can nest expressions within expressions in a kind of pipeline. For instance, you can pretty print the contents of your variable after invoking the `string-upcase` function to convert its characters to uppercase: - - -``` -[3]> (pprint (string-upcase foo)) - -"HELLO WORLD" - -[4]> -``` - -Lisp is dynamically typed in the sense that you don't have to declare variable types when setting them. Lisp treats integers as integers by default: - - -``` -[1]> (setf foo 2) -[2]> (setf bar 3) -[3]> (+ foo bar) -5 -``` - -If you intend for an integer to be interpreted as a string, you can quote it: - - -``` -[4]> (setf foo "2")                                                                                                                       -"2"                                                                                                                                       -[5]> (setf bar "3")                                                                                                                       -"3" -[6]> (+ foo bar) - -*** - +: "2" is not a number -The following restarts are available: -USE-VALUE      :R1      Input a value to be used instead. -ABORT          :R2      Abort main loop -Break 1 [7]> -``` - -In this sample REPL session, both `foo` and `bar` are set to quoted numbers, so Lisp interprets them as strings. Math operators can't be used on strings, so REPL drops into a debugger mode. To get out of the debugger, press **Ctrl+D** on your keyboard. - -You can do some introspection on objects using the `typep` function, which tests for a specific data type. The tokens `T` and `NIL` represent _True_ and _False_, respectively. - - -``` -[4]> (typep foo 'string) -NIL -[5]> (typep foo 'integer) -T -``` - -The single quote (`'`) before `string` and `integer` prevents Lisp from (incorrectly) evaluating those keywords as variables: - - -``` -[6]> (typep foo string) -*** - SYSTEM::READ-EVAL-PRINT: variable STRING has no value -[...] -``` - -It's a shorthand way to protect the terms, normally done with the `quote` function: - - -``` -[7]> (typep foo (quote string)) -NIL -[5]> (typep foo (quote integer)) -T -``` - -### Lists - -Unsurprisingly, you can also create lists in Lisp: - - -``` -[1]> (setf foo (list "hello" "world")) -("hello" "world") -``` - -Lists can be indexed with the `nth` function: - - -``` -[2]> (nth 0 foo) -"hello" -[3]> (pprint (string-capitalize (nth 1 foo))) - -"World" -``` - -### Exiting REPL - -To end a REPL session, press **Ctrl+D** on your keyboard, or use the `quit` keyword in Lisp: - - -``` -[99]> (quit) -$ -``` - -### Scripting - -Lisp can be compiled or used as an interpreted scripting language. The latter is probably the easiest option when you're starting, especially if you're already familiar with Python or [shell scripting][7]. - -Here's a simple dice roller script written in GNU Common Lisp: - - -``` -#!/usr/bin/clisp - -(defun roller (num)   -  (pprint (random (parse-integer (nth 0 num)))) -) - -(setf userput *args*) -(setf *random-state* (make-random-state t)) -(roller userput) -``` - -The first line tells your [POSIX][8] terminal what executable to use to run the script. - -The `roller` function, created with `defun`, uses the `random` function to print a pseudo-random number up to, and not including, the zeroth item of the `num` list. The `num` list hasn't been created yet in the script, but the function doesn't get executed until it's called. - -The next line assigns any argument provided to the script at launch time to a variable called `userput`. The `userput` variable is a list, and it's what becomes `num` once it's passed to the `roller` function. - -The penultimate line of the script starts a _random seed_. This provides Lisp with enough entropy to generate a mostly random number. - -The final line invokes the custom `roller` function, providing the `userput` list as its sole argument. - -Save the file as `dice.lisp` and mark it executable: - - -``` -`$ chmod +x dice.lisp` -``` - -Finally, try running it, providing it with a maximum number from which to choose its random number: - - -``` -$ ./dice.lisp 21 - -13 -$ ./dice.lisp 21 - -7 -$ ./dice.lisp 21 - -20 -``` - -Not bad! - -### Learn Lisp - -Whether you can imagine using Lisp as a utilitarian language for personal scripts, to advance your career, or just as a fun experiment, you can see some particularly inventive uses at the annual [Lisp Game Jam][9] (most submissions are open source, so you can view the code to learn from what you play). - -Lisp is a fun and unique language with an ever-growing developer base and enough historic and emerging dialects to keep programmers from all disciplines happy. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/5/learn-lisp - -作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/seth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_4.png?itok=VGZO8CxT (Woman sitting in front of her laptop) -[2]: http://sbcl.org -[3]: https://www.gnu.org/software/gcl/ -[4]: https://opensource.com/article/20/11/macports -[5]: https://opensource.com/article/20/6/homebrew-linux -[6]: http://mirror.lagoon.nc/gnu/gcl/binaries/stable -[7]: https://opensource.com/article/20/4/bash-programming-guide -[8]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains -[9]: https://itch.io/jam/spring-lisp-game-jam-2021 diff --git a/sources/tech/20210511 Use the Alpine email client in your Linux terminal.md b/sources/tech/20210511 Use the Alpine email client in your Linux terminal.md index 83930d59c3..7f4e8155e6 100644 --- a/sources/tech/20210511 Use the Alpine email client in your Linux terminal.md +++ b/sources/tech/20210511 Use the Alpine email client in your Linux terminal.md @@ -1,15 +1,16 @@ -[#]: subject: (Use the Alpine email client in your Linux terminal) -[#]: via: (https://opensource.com/article/21/5/alpine-linux-email) -[#]: author: (David Both https://opensource.com/users/dboth) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: subject: "Use the Alpine email client in your Linux terminal" +[#]: via: "https://opensource.com/article/21/5/alpine-linux-email" +[#]: author: "David Both https://opensource.com/users/dboth" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " Use the Alpine email client in your Linux terminal ====== Configure Alpine to handle your email the way you like it. + ![Chat via email][1] Email is an important communications medium and will remain so for the foreseeable future. I have used many different email clients over the last 30 years, and [Thunderbird][2] is what I have used the most in recent years. It is an excellent and functional desktop application that provides all the features that most people need—including me. @@ -22,7 +23,7 @@ This desire to go retro with my email client started back in 2017 when I wrote a I recently decided to exclusively use Alpine for email. The main attraction is the ease of use offered by keeping my hands on the keyboard (and reducing the number of times I need to reach for the mouse). It is also about scratching my sysadmin itch to do something different and use an excellent text mode interface in the process. -## Getting started +### Getting started I already had Alpine set up from my previous use, so it was just a matter of starting to use it again. @@ -32,18 +33,17 @@ I previously set up Alpine on my mail server—I used secure shell (SSH) to log But now I want to run Alpine on my workstation or laptop. It's relatively simple to configure Alpine on the same host as the email server. Using it on a remote computer requires a good bit more. -## Install Alpine +### Install Alpine Installing Alpine on Fedora is simple because it is available from the Fedora repository. Just use DNF as root: - ``` -`# dnf -y install alpine` +# dnf -y install alpine ``` This command installs Alpine and any prerequisite packages that are not already installed. Alpine's primary dependencies are Sendmail, Hunspell, OpenLDAP, OpenSSL, krb5-libs, ncurses, and a couple of others. In my case, Alpine was the only package installed. -## Launch Alpine +### Launch Alpine To launch Alpine, open a terminal session, type **alpine** on the command line, and press **Enter**. @@ -51,7 +51,6 @@ The first time you start Alpine, it displays a message that it is creating the u For now, just press lowercase **e** to exit from the greeting message. You should now see Alpine's Main menu (I deleted several blank lines of the output to save space): - ``` +----------------------------------------------------+ | ALPINE 2.24 MAIN MENU Folder: INBOX No Messages    | @@ -77,25 +76,24 @@ For now, just press lowercase **e** to exit from the greeting message. You shoul | For Copyright information press "?"                | |                                                    | | ? Help P PrevCmd R RelNotes                        | -| O OTHER CMDS > [ListFldrs] N NextCmd K KBLock      | +| O OTHER CMDS > [ListFldrs] N NextCmd K KBLock      | +----------------------------------------------------+ ``` -_Figure 1: Alpine's Main menu_ +*Figure 1: Alpine's Main menu* Alpine creates the `~mail` directory localhost during initial use. When you configure the IMAP server, Alpine creates the default `~/mail`, `~/mail/sent-mail`, and `saved-messages` folders in your home directory on the IMAP server. You can change the defaults, but I recommend against it. When using IMAP, emails are not stored locally unless you copy them to local folders. All emails are stored in the Inbox on the SMTP server until they are saved to a folder on the IMAP server. The SMTP and IMAP servers might use the same or different hosts. Alpine also assumes that the Inbox is located at `/var/spool/mail/user_name` on the email SMTP server. This article explains how to configure both IMAP and SMTP servers. The email administrator for your organization—that might be you—will add your account to the IMAP server and provide you with the initial password. -## The Alpine interface +### The Alpine interface The Alpine user interface (UI) is a text-mode, menu-driven UI, also known as a TUI. This type of interface is also sometimes called captive user interface (CUI), which does not provide a command-line interface that can be used in scripts, for example. You must exit from the program to perform other tasks. By contrast, the [mailx][5] program is an email program that can be used with either a TUI, from the command line, or in scripts. For example, you can use the following command to send the results of the free command directly to the sysadmin's email account: - ``` -`$ free | mailx -s "Free memory" sysadmin@example.com` +$ free | mailx -s "Free memory" sysadmin@example.com ``` But enough of that little side trip; there is work to do. Let's start with an explanation. @@ -106,20 +104,19 @@ On the Main menu, you can use the **Up** and **Down** arrow keys to highlight a Use the **Page Down** and **Page Up** keys to scroll through the commands if you can't see them all. The secondary menu at the bottom of the page usually lists all the commands available on the current menu; you will also see a message similar to this: - ``` -`[START of Information About Setup Command]` +[START of Information About Setup Command] ``` Should you find yourself at a place you don't want to be, such as creating a new email, responding to one, or making changes to settings, and decide you don't want to do that, **Ctrl+C** allows you to cancel the current task. In most cases, you will be asked to confirm that you want to cancel by pressing the **C** key. Note that **^C** in the secondary menu represents **Ctrl+C**. Many commands use the **Ctrl** key, so you will see **^** quite frequently on some menus. Finally, to quit Alpine, you can press **Q**; when it asks, "Really quit Alpine?" respond with **Y** to exit. Like many commands, **Q** is not available from all menus. -## Help +### Help Help is available from all of the menus I have tried. You can access detailed help for each menu item by highlighting the item you need information for and pressing the **?** key to obtain context-sensitive help. -## Configuration +### Configuration When I started using Alpine regularly, I made the minimum changes to the configuration needed to send and receive emails. As I gained more experience with Alpine, I changed other configuration items to make things work easier or more to my liking. @@ -127,100 +124,97 @@ First, I will explain the basic configurations required to make Alpine work, the If you have been exploring a bit on your own—which is a good thing—return to the Main menu. To get to Alpine's Configuration menu from the Main menu, type **S** for Setup. You will see a menu like this: - ``` -ALPINE 2.24 SETUP Folder: INBOX No Messages +ALPINE 2.24 SETUP Folder: INBOX No Messages -This is the Setup screen for Alpine. Choose from the following commands: +This is the Setup screen for Alpine. Choose from the following commands: -(E) Exit Setup: -This puts you back at the Main Menu. +(E) Exit Setup: +This puts you back at the Main Menu. -(P) Printer: -Allows you to set a default printer and to define custom -print commands. +(P) Printer: +Allows you to set a default printer and to define custom +print commands. -(N) Newpassword: -Change your password. +(N) Newpassword: +Change your password. -(C) Config: -Allows you to set or unset many features of Alpine. -You may also set the values of many options with this command. +(C) Config: +Allows you to set or unset many features of Alpine. +You may also set the values of many options with this command. -(S) Signature: -Enter or edit a custom signature which will -be included with each new message you send. +(S) Signature: +Enter or edit a custom signature which will +be included with each new message you send.   -(A) AddressBooks: -Define a non-default address book. +(A) AddressBooks: +Define a non-default address book.   -(L) collectionLists: -You may define groups of folders to help you better organize your mail. +(L) collectionLists: +You may define groups of folders to help you better organize your mail.   -(R) Rules: -This has up to six sub-categories: Roles, Index Colors, Filters, - [START of Information About Setup Command ] +(R) Rules: +This has up to six sub-categories: Roles, Index Colors, Filters, + [START of Information About Setup Command ] ? Help E Exit Setup N Newpassword S Signature L collectionList D Directory   O OTHER CMDS P Printer C Config A AddressBooks R Rules K Kolor ``` -_Figure 2: Alpine Setup menu_ +*Figure 2: Alpine Setup menu* The Setup menu groups the very large number of setup items into related categories to, hopefully, make the ones you want easier to locate. Use **Page Down** and **Page Up** to scroll through the commands if you can't see them all. I'll start with the settings necessary to get email—Alpine's entire purpose—up and running. -## Config +### Config The Config section contains 15 pages (on my large screen) of option- and feature-configuration items. These settings can be used to set up your SMTP and IMAP connections to the email server and define the way many aspects of Alpine work. In these examples, I'll use the `example.com` domain name (which is the virtual network I use for testing and experimenting). Alpine's configuration is stored in the `~/.pinerc` file, created the first time you start Alpine. The first page of the Setup Configuration menu contains most of the settings required to configure Alpine to send and receive email: - ``` ALPINE 2.24 SETUP CONFIGURATION Folder: INBOX No Messages -Personal Name = <No Value Set: using "Test User"> -User Domain = <No Value Set> -SMTP Server (for sending) = <No Value Set> -NNTP Server (for news) = <No Value Set> -Inbox Path = <No Value Set: using "inbox"> -Incoming Archive Folders = <No Value Set> -Pruned Folders = <No Value Set> -Default Fcc (File carbon copy) = <No Value Set: using "sent-mail"> -Default Saved Message Folder = <No Value Set: using "saved-messages"> -Postponed Folder = <No Value Set: using "postponed-msgs"> -Read Message Folder = <No Value Set> -Form Letter Folder = <No Value Set> -Trash Folder = <No Value Set: using "Trash"> -Literal Signature = <No Value Set> -Signature File = <No Value Set: using ".signature"> +Personal Name = +User Domain = +SMTP Server (for sending) = +NNTP Server (for news) = +Inbox Path = +Incoming Archive Folders = +Pruned Folders = +Default Fcc (File carbon copy) = +Default Saved Message Folder = +Postponed Folder = +Read Message Folder = +Form Letter Folder = +Trash Folder = +Literal Signature = +Signature File = Feature List = Set Feature Name -\--- ---------------------- +--- ---------------------- [ Composer Preferences ] [X] Allow Changing From (default) -[ ] Alternate Compose Menu -[ ] Alternate Role (#) Menu -[ ] Compose Cancel Confirm Uses Yes -[ ] Compose Rejects Unqualified Addresses -[ ] Compose Send Offers First Filter -[ ] Ctrl-K Cuts From Cursor -[ ] Delete Key Maps to Ctrl-D -[ ] Do Not Save to Deadletter on Cancel +[ ] Alternate Compose Menu +[ ] Alternate Role (#) Menu +[ ] Compose Cancel Confirm Uses Yes +[ ] Compose Rejects Unqualified Addresses +[ ] Compose Send Offers First Filter +[ ] Ctrl-K Cuts From Cursor +[ ] Delete Key Maps to Ctrl-D +[ ] Do Not Save to Deadletter on Cancel [Already at start of screen] -? Help E Exit Setup P Prev - PrevPage A Add Value % Print +? Help E Exit Setup P Prev - PrevPage A Add Value % Print O OTHER CMDS C [Change Val] N Next Spc NextPage D Delete Val W WhereIs ``` -_Figure 3: First page of Alpine's Setup Configuration menu_ +*Figure 3: First page of Alpine's Setup Configuration menu* This is where you define the parameters required to communicate with the email server. To change a setting, use the **Arrow** keys to move the selection bar to the desired configuration item and press **Enter**. You can see in Figure 3 that none of the basic configuration items have any values set. The **Personal Name** item uses the [Gecos field][6] of the Unix `/etc/passwd` entry for the logged-in user to obtain the default name. This is just a name Alpine uses for display and has no role in receiving or sending email. I usually call this the "pretty name." In this case, the default name is fine, so I will leave it as it is. -There are some configuration items that you must set. Start with the **User Domain**, which is the current computer's domain name. Mine is a virtual machine I use for testing and examples in my books. Use the command line to get the fully qualified domain name (FQDN) and the hostname. In Figure 4, you can see that the domain name is `example.com`: - +There are some configuration items that you must set. Start with the **User Domain**, which is the current computer's domain name. Mine is a virtual machine I use for testing and examples in my books. Use the command line to get the fully qualified domain name (FQDN) and the hostname. In Figure 4, you can see that the domain name is `example.com` : ``` $ hostnamectl @@ -236,117 +230,161 @@ Kernel: Linux 5.10.23-200.fc33.x86_64 Architecture: x86-64 ``` -_Figure 4: Obtaining the hostname and domain name_ - -Once you have the FQDN, select the **User Domain** entry and press **Enter** to see the entry field at the bottom of the Alpine screen (as shown in Figure 5). Type your domain name and press **Enter** (using _your_ network's domain and server names): +*Figure 4: Obtaining the hostname and domain name* +Once you have the FQDN, select the **User Domain** entry and press **Enter** to see the entry field at the bottom of the Alpine screen (as shown in Figure 5). Type your domain name and press **Enter** (using *your* network's domain and server names): ``` ALPINE 2.24 SETUP CONFIGURATION Folder: INBOX No Messages -Personal Name = <No Value Set: using "Test User"> -User Domain = <No Value Set> -SMTP Server (for sending) = <No Value Set> -NNTP Server (for news) = <No Value Set> -Inbox Path = <No Value Set: using "inbox"> -Incoming Archive Folders = <No Value Set> -Pruned Folders = <No Value Set> -Default Fcc (File carbon copy) = <No Value Set: using "sent-mail"> -Default Saved Message Folder = <No Value Set: using "saved-messages"> -Postponed Folder = <No Value Set: using "postponed-msgs"> -Read Message Folder = <No Value Set> -Form Letter Folder = <No Value Set> -Trash Folder = <No Value Set: using "Trash"> -Literal Signature = <No Value Set> -Signature File = <No Value Set: using ".signature"> +Personal Name = +User Domain = +SMTP Server (for sending) = +NNTP Server (for news) = +Inbox Path = +Incoming Archive Folders = +Pruned Folders = +Default Fcc (File carbon copy) = +Default Saved Message Folder = +Postponed Folder = +Read Message Folder = +Form Letter Folder = +Trash Folder = +Literal Signature = +Signature File = Feature List = Set Feature Name -\--- ---------------------- +--- ---------------------- [ Composer Preferences ] [X] Allow Changing From (default) -[ ] Alternate Compose Menu -[ ] Alternate Role (#) Menu -[ ] Compose Cancel Confirm Uses Yes -[ ] Compose Rejects Unqualified Addresses -[ ] Compose Send Offers First Filter -[ ] Ctrl-K Cuts From Cursor -[ ] Delete Key Maps to Ctrl-D -[ ] Do Not Save to Deadletter on Cancel -Enter the text to be added : example.com -^G Help +[ ] Alternate Compose Menu +[ ] Alternate Role (#) Menu +[ ] Compose Cancel Confirm Uses Yes +[ ] Compose Rejects Unqualified Addresses +[ ] Compose Send Offers First Filter +[ ] Ctrl-K Cuts From Cursor +[ ] Delete Key Maps to Ctrl-D +[ ] Do Not Save to Deadletter on Cancel +Enter the text to be added : example.com +^G Help ^C Cancel Ret Accept ``` -_Figure 5: Type the domain name into the text entry field._ +*Figure 5: Type the domain name into the text entry field.* -### Required config +#### Required config These are the basic configuration items you need to send and receive email: - * **Personal Name** - * Your name - * This is the pretty name Alpine uses for the From and Return fields in emails. - * **User Domain** - * `example.com:25/user=SMTP_Authentication_UserName` - * This is the email domain for your email client. This might be different from the User Domain name. This line also contains the SMTP port number and the user name for SMTP authentication. - * **SMTP server** - * SMTP - * This is the name of the outbound SMTP email server. It combines with the User Domain name to create the FQDN for the email server. - * **Inbox Path** - * `{IMAP_server)}Inbox` - * This is the name of the IMAP server enclosed in curly braces (`{}`) and the name of the Inbox. Note that this directory location is different from the inbound IMAP email. The usual location for the inbox on the server is `/var/spool/mail/user_name`. - * **Default Fcc** (file carbon copy) - * `{IMAP_server)}mail/sent` - * This is the mailbox (folder) where sent mail is stored. The default mail directory on the server is usually `~/mail`, but `mail/` must be specified in this and the next two entries, or the folders will be placed in the home directory instead. - * **Default Saved Message Folder** - * `{IMAP_server)}mail/saved-messages` - * This is the default folder when saving a message to a folder if you don't use `^t` to specify a different one. - * **Trash Folder** - * `{IMAP_server)}mail/Trash` - * **Literal Signature** - * A signature string - * I don't use this, but it's an easy place to specify a simple signature. - * **Signature File** - * `~/MySignature.sig` - * This points to the file that contains your signature file. +* Personal Name + * Your name + * This is the pretty name Alpine uses for the From and Return fields in emails. +* User Domain + * example.com:25/user=SMTP_Authentication_UserName + * This is the email domain for your email client. This might be different from the User Domain name. This line also contains the SMTP port number and the user name for SMTP authentication. +* * SMTP server +SMTP + * This is the name of the outbound SMTP email server. It combines with the User Domain name to create the FQDN for the email server. +* Inbox Path + * {IMAP_server)}Inbox + * This is the name of the IMAP server enclosed in curly braces ({}) and the name of the Inbox. Note that this directory location is different from the inbound IMAP email. The usual location for the inbox on the server is `/var/spool/mail/user_name`. +* Default Fcc (file carbon copy) + * {IMAP_server)}mail/sent + * This is the mailbox (folder) where sent mail is stored. The default mail directory on the server is usually `~/mail`, but `mail/` must be specified in this and the next two entries, or the folders will be placed in the home directory instead. +* Default Saved Message Folder + * {IMAP_server)}mail/saved-messages + * This is the default folder when saving a message to a folder if you don't use `^t` to specify a different one. +* Trash Folder + * {IMAP_server)}mail/Trash +* Literal Signature + * A signature string + * I don't use this, but it's an easy place to specify a simple signature. +* Signature File + * ~/MySignature.sig + * This points to the file that contains your signature file. - - -### Optional config +#### Optional config Here are the features I changed to make Alpine work more to my liking. They are not about getting Alpine to send and receive email, but about making Alpine work the way you want it to. Unless otherwise noted, I turned all of these features on. Features that are turned on by default have the string `(default)` next to them in the Alpine display. Because they are already turned on, I will not describe them. - * **Alternate Role (`#`) Menu:** This allows multiple identities using different email addresses on the same client and server. The server must be configured to allow multiple addresses to be delivered to your primary email account. - * **Compose Rejects Unqualified Addresses:** Alpine will not accept an address that is not fully qualified. That is, it must be in the form ``. - * **Enable Sigdashes:** This enables Alpine to automatically add dashes (`--`) in the row just above the signature. This is a common way of delineating the start of the signature. - * **Prevent User Lookup in Password File:** This prevents the lookup of the full user name from the Gecos field of the passwd file. - * **Spell Check Before Sending:** Although you can invoke the spell checker at any time while composing an email, this forces a spell check when you use the `^X` keystroke to send an email. - * **Include Header in Reply:** This includes a message's headers when you reply. - * **Include Text in Reply:** This includes the text of the original message in your reply. - * **Signature at Bottom:** Many people prefer to have their signature at the very bottom of the email. This setting changes the default, which puts the signature at the end of the reply and before the message being replied to. - * **Preserve Original Fields:** This preserves the original addresses in the **To:** and **CC:** fields when you reply to a message. If this feature is disabled when you reply to a message, the original sender is added to the **To:** field, all other recipients are added to the **CC:** field, and your address is added to the **From:** field. - * **Enable Background Sending:** This speeds the Alpine user interface response when sending an email. - * **Enable Verbose SMTP Posting:** This produces more verbose information during SMTP conversations with the server. It is a problem-determination aid for the sysadmin. - * **Warn if Blank Subject:** This prevents sending emails with no subject. - * **Combined Folder Display:** This combines all folder collections into a single main display. Otherwise, collections will be in separate views. - * **Combined Subdirectory Display:** This combines all subdirectories' collections into a single main display. Otherwise, subdirectories will be in separate views. This is useful when searching for a subdirectory to attach or save files. - * **Enable Incoming Folders Collection:** This lists all incoming folders in the same collection as the Inbox. Incoming folders can be used with a tool like procmail to presort email into folders other than the Inbox and makes it easier to see the folders where new emails are sorted. - * **Enable Incoming Folders Checking:** This enables Alpine to check for new emails in the incoming folders collection. - * **Incoming Checking Includes Total:** This displays the number of old and new emails in the incoming folders. - * **Expanded View of Folders:** This displays all folders in each collection when you view the **Folder List** screen. Otherwise, only the collections are shown, and the folders are not shown until selected. - * **Separate Folder and Directory Entries:** If your mail directory has email folders and regular directories that use the same name, this causes Alpine to list them separately. - * **Use Vertical Folder List:** This sorts mail folders vertically first and then horizontally. The default is horizontal, then vertical. - * **Convert Dates To Localtime:** By default, all dates and times are displayed in their originating time zones. This converts the dates to display in local time. - * **Show Sort in Titlebar:** Alpine can sort emails in a mail folder using multiple criteria. This causes the sort criteria to be displayed in the title bar. - * **Enable Message View Address Links:** This highlights email addresses in the body of the email. - * **Enable Message View Attachment Links:** This highlights URL links in the body of the email. - * **Prefer Plain Text:** Many emails contain two versions, plain text and HTML. When this feature is turned on, Alpine always displays the plain text version. You can use the **A** key to toggle to the "preferred" version, usually the HTML one. I usually find the plain text easier to visualize the structure of and read the email. This can depend upon the sending client, so I use the **A** key when needed. - * **Enable Print Via Y Command:** This prints a message using the previous default, **Y**. Because **Y** is also used to confirm many commands, the keystroke can inadvertently cause you to print a message. The new default is **%** to prevent accidental printing. I like the ease of using **Y**, but it has caused some extra print jobs, so I am thinking about turning this feature off. - * **Print Formfeed Between Messages:** This prints each message on a new sheet of paper. - * **Customized Headers:** Customized headers enables overriding the default **From:** and **Reply-To:** headers. I set mine to: [code] -   From: "David Both" <[[david@example.com][7]](mailto:[david@both.org][8])> -\-   Reply-To: "David Both" -    <[[david@example.com][7]](mailto:[david@both.org][8])> +* Alternate Role (#) Menu: This allows multiple identities using different email addresses on the same client and server. The server must be configured to allow multiple addresses to be delivered to your primary email account. +* Compose Rejects Unqualified Addresses: Alpine will not accept an address that is not fully qualified. That is, it must be in the form ``. +* Enable Sigdashes: This enables Alpine to automatically add dashes (--) in the row just above the signature. This is a common way of delineating the start of the signature. +* Prevent User Lookup in Password File: This prevents the lookup of the full user name from the Gecos field of the passwd file. +* Spell Check Before Sending: Although you can invoke the spell checker at any time while composing an email, this forces a spell check when you use the `^X` keystroke to send an email. +* Include Header in Reply: This includes a message's headers when you reply. +* Include Text in Reply: This includes the text of the original message in your reply. +* Signature at Bottom: Many people prefer to have their signature at the very bottom of the email. This setting changes the default, which puts the signature at the end of the reply and before the message being replied to. +* Preserve Original Fields: This preserves the original addresses in the To: and CC: fields when you reply to a message. If this feature is disabled when you reply to a message, the original sender is added to the To: field, all other recipients are added to the CC: field, and your address is added to the From: field. +* Enable Background Sending: This speeds the Alpine user interface response when sending an email. +* Enable Verbose SMTP Posting: This produces more verbose information during SMTP conversations with the server. It is a problem-determination aid for the sysadmin. +* Warn if Blank Subject: This prevents sending emails with no subject. +* Combined Folder Display: This combines all folder collections into a single main display. Otherwise, collections will be in separate views. +* Combined Subdirectory Display: This combines all subdirectories' collections into a single main display. Otherwise, subdirectories will be in separate views. This is useful when searching for a subdirectory to attach or save files. +* Enable Incoming Folders Collection: This lists all incoming folders in the same collection as the Inbox. Incoming folders can be used with a tool like procmail to presort email into folders other than the Inbox and makes it easier to see the folders where new emails are sorted. +* Enable Incoming Folders Checking: This enables Alpine to check for new emails in the incoming folders collection. +* Incoming Checking Includes Total: This displays the number of old and new emails in the incoming folders. +* Expanded View of Folders: This displays all folders in each collection when you view the Folder List screen. Otherwise, only the collections are shown, and the folders are not shown until selected. +* Separate Folder and Directory Entries: If your mail directory has email folders and regular directories that use the same name, this causes Alpine to list them separately. +* Use Vertical Folder List: This sorts mail folders vertically first and then horizontally. The default is horizontal, then vertical. +* Convert Dates To Localtime: By default, all dates and times are displayed in their originating time zones. This converts the dates to display in local time. +* Show Sort in Titlebar: Alpine can sort emails in a mail folder using multiple criteria. This causes the sort criteria to be displayed in the title bar. +* Enable Message View Address Links: This highlights email addresses in the body of the email. +* Enable Message View Attachment Links: This highlights URL links in the body of the email. +* Prefer Plain Text: Many emails contain two versions, plain text and HTML. When this feature is turned on, Alpine always displays the plain text version. You can use the A key to toggle to the "preferred" version, usually the HTML one. I usually find the plain text easier to visualize the structure of and read the email. This can depend upon the sending client, so I use the A key when needed. +* Enable Print Via Y Command: This prints a message using the previous default, Y. Because Y is also used to confirm many commands, the keystroke can inadvertently cause you to print a message. The new default is % to prevent accidental printing. I like the ease of using Y, but it has caused some extra print jobs, so I am thinking about turning this feature off. +* Print Formfeed Between Messages: This prints each message on a new sheet of paper. +* Customized Headers: Customized headers enables overriding the default From: and Reply-To: headers. I set mine to: +-   From: "David Both" <[david@example.com](mailto:david@both.org)> +-   Reply-To: "David Both" +    <[david@example.com](mailto:david@both.org)> +* Sort key: By default, Alpine sorts messages in a folder by arrival time. I found this to be a bit confusing, so I changed it to Date, which can be significantly different from arrival time. Many spammers use dates and times in the past or future, so this setting can sort the future ones to the top of the list (or bottom, depending on your preferences for forward or reverse sorts). +* Image Viewer: This feature allows you to specify the image viewer to use when displaying graphics attached to or embedded in an email. This only works when using Alpine in a terminal window on the graphical desktop. It will not work in a text-only virtual console. I always set this to `=okular` because [Okular][7] is my preferred viewer. +* URL-Viewer: This tells Alpine what web browser you want to use. I set this for `= /bin/firefox` but you could use Chrome or another browser. Be sure to verify the location of the Firefox executable. + +#### Printing + +It is easy to set up Alpine for printing. Select the **Printer** menu from the **Setup** page. This allows you to set a default printer and define custom print commands. The default is probably `attached-to-ansi`. Move the cursor down to the **Standard UNIX print command** section and highlight the printer list. + ``` - * **Sort key:** By default, Alpine sorts messages in a folder by arrival time. I found this to be a bit confusing, so I changed it to **Date**, which can be significantly different from arrival time. Many spammers use dates and times in the past or future, so this setting can sort the future ones to the top of the list (or bottom, depending on your preferences for forward or reverse sorts). - * **Image Viewer:** This feature allows you to specify the image viewer to use when displaying graphics attached to or embedded in an email. This only works when using Alpine in a terminal window on the graphical desktop. It will not work in a text-only virtual console. I always set this to `=okular` because [Okular][9] is my preferred viewer. - * **URL-Viewer:** This tells Alpine what web browser you \ No newline at end of file +Standard UNIX print command + +Using this option may require setting your "PRINTER" or "LPDEST" + +environment variable using the standard UNIX utilities. + +Printer List: "" lpr +``` + +Then press the **Enter** key to set the standard Unix **lpr** command as the default. + +### Final thoughts + +This is not a step-by-step guide to Alpine configuration and use. Rather, I tried to cover the basics to get it up and running to send and receive email. I also shared some configuration changes that have made my Alpine experience much more usable. These are the configuration items that I've found most important to my experience; you may find that others are more important to you. + +I have been using Alpine for several months now and am very happy with the experience. The text interface helps me concentrate on the message and not the distracting graphics and animations. I can view those if I choose, but 99% of the time, I choose not to. + +Alpine is easy to use and has a huge number of features that can be configured to give the best email client experience possible. + +Use the **Help** feature to get more information about the fields I explored above and those that I did not cover. You will undoubtedly find ways to configure Alpine that work better for you than the defaults or what I changed. I hope this will at least give you a start to set up Alpine the way you want. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/5/alpine-linux-email + +作者:[David Both][a] +选题:[lkxed][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dboth +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/email_chat_communication_message.png +[2]: https://www.thunderbird.net/en-US/ +[3]: https://alpine.x10host.com/ +[4]: https://opensource.com/article/17/10/alpine-email-client +[5]: https://linux.die.net/man/1/mailx +[6]: https://en.wikipedia.org/wiki/Gecos_field +[7]: https://okular.kde.org/ diff --git a/sources/tech/20210511 What is fog computing.md b/sources/tech/20210511 What is fog computing.md deleted file mode 100644 index 7d1f54ee22..0000000000 --- a/sources/tech/20210511 What is fog computing.md +++ /dev/null @@ -1,70 +0,0 @@ -[#]: subject: (What is fog computing?) -[#]: via: (https://opensource.com/article/21/5/fog-computing) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -What is fog computing? -====== -Learn about the network comprised of all the connected devices in our -lives. -![Man at laptop on a mountain][1] - -In the early days, computers were big and expensive. There were few users in the world, and they had to reserve time on a computer (and show up in person) to have their punchcards processed. Systems called [mainframes][2] made many innovations and enabled time-shared tasks on terminals (like desktop computers, but without their own CPU). - -Skip forward to today, when powerful computation is [as cheap as US$35 and no larger than a credit card][3]. That doesn't even begin to cover all the little devices in modern life that gather and process data. Take a high-level view of this collection of computers, and you can imagine all of these devices outnumbering grains of sands or particles in a cloud. - -It so happens that the term "cloud computing" is already occupied, so there needs to be a unique name for the network comprised of the Internet of Things (IoT) and other strategically situated servers. And besides, if there's already a cloud representing nodes of a data center, then there's surely something unique about the nodes intermingling with us folk outside that cloud. - -### Welcome to fog computing - -The cloud delivers computing services over the internet. But the data centers that make up the cloud are big and relatively few compared to their number of potential clients. This suggests potential bottlenecks when data is sent back and forth between the cloud and its many users. - -Fog computing, by contrast, can outnumber its potential clients without risking a bottleneck because the devices perform much of the data collection or computation. It's the outer "edge" of the cloud, the part of a cloud that touches down to the ground. - -### Fog and edge computing - -Fog computing and [edge computing][4] are essentially synonymous. Both have strong associations with both the cloud and IoT and make the same architectural assumptions: - - * The closer you are to the CPU doing the work, the faster the data transfer. - * Like [Linux][5], there's a strong advantage to having small, purpose-built computers that can "do one thing and do it well." (Of course, our devices actually do more than just one thing, but from a high-level view, a smartwatch you bought to monitor your health is essentially doing "one" thing.) - * Going offline is inevitable, but a good device can function just as effectively in the interim and then sync up when reconnected. - * Local devices can be simpler and cheaper than large data centers. - - - -### Networking on the edge - -It's tempting to view fog computing as a completely separate entity from the cloud, but they're just two parts of the whole. The cloud needs the infrastructure of the digital enterprise, including public cloud providers, telecommunication companies, and even specialized corporations running their own services. Localized services are also important to provide waystations between the cloud core and its millions and millions of clients. - -**[Read next: [An Architect's guide to edge computing essentials][6]]** - -Fog computing, located at the edge of the cloud, intermingles with clients wherever they are located. Sometimes, this is a consumer setting, such as your own home or car, while other times, it's a business interest, such as price-monitoring devices in a retail store or vital safety sensors on a factory floor. - -### Fog computing is all around you - -Fog computing is built up of all the connected devices in our lives: drones, phones, watches, fitness monitors, security monitors, home automation, portable gaming devices, gardening automation, weather sensors, air-quality monitors, and much, much more. Ideally, the data it provides helps to build a better and more informed future. There are lots of great open source projects out there that are working toward improving health and wellness—or even just making life a little more entertaining—and it's all happening thanks to fog and cloud computing. _Our_ job, however, is to make sure it [stays open][7]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/5/fog-computing - -作者:[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_laptop_code_programming_mountain_view.jpg?itok=yx5buqkr (Man at laptop on a mountain) -[2]: https://opensource.com/article/19/9/linux-mainframes-part-1 -[3]: https://opensource.com/resources/raspberry-pi -[4]: https://www.redhat.com/en/topics/edge-computing/what-is-edge-computing -[5]: https://opensource.com/resources/linux -[6]: https://www.redhat.com/architect/edge-computing-essentials -[7]: https://opensource.com/article/20/10/keep-cloud-open diff --git a/sources/tech/20210511 What is the OSI model.md b/sources/tech/20210511 What is the OSI model.md deleted file mode 100644 index 1d43a0e9bc..0000000000 --- a/sources/tech/20210511 What is the OSI model.md +++ /dev/null @@ -1,95 +0,0 @@ -[#]: subject: (What is the OSI model?) -[#]: via: (https://jvns.ca/blog/2021/05/11/what-s-the-osi-model-/) -[#]: author: (Julia Evans https://jvns.ca/) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -What is the OSI model? -====== - -Today I tweeted something about how the OSI model doesn’t correspond well to the reality of how TCP/IP works and it made me think – what is the OSI model, exactly? From reading some of the replies on Twitter, it seems like there are at least 3 different ways to think about it: - - 1. A literal description of how TCP/IP works - 2. An abstract model that you can use to describe and compare a lot of different networking protocols - 3. A literal description of some computer networking protocols from the 1980s that are mostly no longer used today - - - -In this post I’m not going to try to argue that any one of these is “really” what the OSI model is – it seems like different people think about the OSI model in all of these ways, and that’s okay. - -### the OSI model has 7 layers - -Before we talk about what the OSI model means, let’s very briefly discuss what it is: it’s an abstract model for how networking works with 7 numbered layers: - - * Layer 1: physical layer - * Layer 2: data link - * Layer 3: network - * Layer 4: transport - * Layer 5: session - * Layer 6: presentation - * Layer 7: application - - - -I won’t say more about what each of those is supposed to mean, there are a thousand explanations of it online. - -### the OSI model as a literal description of how TCP/IP works - -First, I want to talk about one common way people use the OSI model in practice: as a literal description of how TCP/IP works. Some layers of the OSI model are really easy to map to TCP/IP: - - * Layer 2 corresponds to Ethernet - * Layer 3 corresponds to IP - * Layer 4 corresponds to TCP or UDP (or ICMP etc) - * Layer 7 corresponds to whatever is inside the TCP or UDP packet (for example a DNS query) - - - -This mapping makes a lot of sense for layers 2, 3, and 4 – TCP packets have 3 headers corresponding to these 3 layers (the Ethernet header, the IP header, and the TCP header). - -Having numbers to describe the different headers in a TCP packet is pretty useful – if you say “layer 2”, it’s clear that that lives “underneath” layer 3, because 2 is a smaller number than 3. - -The weird thing about “OSI model as literal description” is that layers 5 and 6 don’t really correspond to anything in TCP/IP – I’ve heard a lot of different interpretations of what layers 5 or 6 could be (you could say layer 5 is TLS or something!) but they don’t have a clear correspondence like “every layer has a corresponding header in the TCP packet” the way layers 2, 3, and 4 do. - -Also, some parts of TCP/IP don’t fit well into the OSI model even around layers 2-4 – for example, what layer is an ARP packet? ARP packets send some data with an Ethernet header, so does that mean they’re layer 3? Layer 2? The Wikipedia article listing different OSI layers categorizes it under “layer 2.5” which is pretty unsatisfying. - -This is only really a problem because the OSI model is sometimes used to teach TCP/IP, and it’s confusing if it’s not made clear which parts of the model map well to TCP/IP and which don’t. - -### the OSI model as an abstraction for comparing networking protocols - -Another way of thinking of OSI that I’ve heard is that it’s an abstraction you can use to draw analogies between lots of different networking protocols. For example, if you want to understand how Bluetooth works, maybe you can use the OSI model to help you – here’s an diagram I found on [this page][1] showing how Bluetooth fits into the OSI model. - -![][2] - -As another example of this, [this Wikipedia article][3] has a list of OSI layers and which specific networking protocols correspond to those OSI layers. - -### the OSI model as a literal description of some obsolete protocols - -Some very brief research on Wikipedia says that in addition to an abstract description of 7 layers, the OSI model also contained a [bunch of specific protocols implementing those layers][4]. Apparently this happened during the [Protocol Wars][5] in the 70s and 80s, where the OSI model lost and TCP/IP won. - -This explains why the OSI model doesn’t really correspond that well to TCP/IP, since if the OSI protocols had “won” then the OSI model _would_ correspond exactly to how internet networking actually works. - -### that’s all! - -I’m writing this because when I originally learned about the OSI model I found it super confusing (what are all these layers? are they real? is this actually how networking works? what’s happening?) and I wish someone had told me that (as someone who does not work with any networking protocols other than TCP/IP) I could just learn how layers 2, 3, 4, and 7 relate to TCP/IP and then ignore everything else about it. So hopefully this will help clear things up for somebody! - --------------------------------------------------------------------------------- - -via: https://jvns.ca/blog/2021/05/11/what-s-the-osi-model-/ - -作者:[Julia Evans][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://jvns.ca/ -[b]: https://github.com/lujun9972 -[1]: https://flylib.com/books/en/4.215.1.116/1/ -[2]: https://jvns.ca/images/bluetooth.gif -[3]: https://en.wikipedia.org/wiki/List_of_network_protocols_(OSI_model) -[4]: https://en.wikipedia.org/wiki/OSI_protocols -[5]: https://en.wikipedia.org/wiki/Protocol_Wars diff --git a/sources/tech/20210517 reading and searching gmane with gnus, fast.md b/sources/tech/20210517 reading and searching gmane with gnus, fast.md new file mode 100644 index 0000000000..51816eac6c --- /dev/null +++ b/sources/tech/20210517 reading and searching gmane with gnus, fast.md @@ -0,0 +1,91 @@ +[#]: subject: "reading and searching gmane with gnus, fast" +[#]: via: "https://jao.io/blog/2021-05-17-reading-and-searching-gmane-with-gnus-fast.html" +[#]: author: "jao https://jao.io" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +reading and searching gmane with gnus, fast +====== + +Reading mailing lists via Gnus by pointing it to the usenet service news.gmane.io is a well-known trick among emacsers. It has a couple of drawbacks, though: network latency and no search. The two problems have, as almost always with almost any problem in Emacs land, a cure. The names of the game are, in this case, leafnode and notmuch. + +I've been using [leafnode][1] since i was young to avoid network latency issues when Gnus fetches news from remote usenet servers. [Leafnode][1] is a store & forward NNTP proxy that can be used to give a regular newsreader off-line functionality. It works by fetching in the background news articles from a number of configured remote servers (gmane.io in our case), storing them locally and offering a local NNTP server to Gnus (or any other newsreader, for that matter). That way, one configures Gnus to fetch news from localhost, which is fast and will never block, even when one is disconnected from the interwebs. Leafnode's server implements the full protocol, so one can also post to the remote servers. + +For our case, leafnode's configuration file is very simple: + +``` + + ## Unread articles will be deleted after this many days + expire = 365 + + ## This is the NNTP server leafnode fetches its news from. + ## You need read and post access to it. Mandatory. + server = news.gmane.io + + ## Fetch only a few articles when we subscribe a new newsgroup. The + ## default is to fetch all articles. + initialfetch = 100 + +``` + +With leafnode in place, i've rarely needed to subscribe to a mailing list[1][2], and all their messages are available with the Gnus interface that we all know and love. + +With one caveat: one can search over e-mails, using either IMAP (i like dovecot's lucene indexes) or (even better) notmuch. Can we do the same with those messages we access through leafnode? Well, it turns out that, using notmuch, you can! + +First of all, leafnode stores its articles in a format recognised by notmuch's indexer. In my debian installation, the live in the directory `/var/spool/news/gmane`. On the other hand, my notmuch configuration points to `~/var/mail` as the parent directory where my mailboxes are to be found. I just created a symlink in the latter to the former and voila, notmuch is indexing all the messages retrieved by leafnode and i can search over them![2][3] + +With the version of Gnus in current emacs master, it's even better. I can tell Gnus that the search engine for the news server is notmuch: + +``` + + (setq gnus-select-method + '(nntp "localhost" + (gnus-search-engine gnus-search-notmuch + (remove-prefix "/home/jao/var/mail/")))) + +``` + +and perform searches directly in Gnus using the notmuch indexes. Or, if you prefer, you can use directly notmuch.el to find and read those usenet articles: they look just like good old email[3][4] :) + +### Footnotes: + +[1][5] + +Actually, gmane also includes _gwene_ groups that mirror RSS feeds as usenet messages, so you could extend the trick to feeds too. I however use [rss2email][6] to read RSS feeds as email, for a variety of reasons best left to a separate post. + +[2][7] + +With the `expire` parameter in leafnode's configuration set to 365, i keep locally an indexed archive of the mailing list posts less than a year old: in this age of cheap storage, one can make that much longer. One can also play with `initialfetch`. + +[3][8] + +I am not a mu4e user, but i am pretty sure one can play the same trick if that's your email indexer and reader. + +[Tags][9]: [emacs][10] + +-------------------------------------------------------------------------------- + +via: https://jao.io/blog/2021-05-17-reading-and-searching-gmane-with-gnus-fast.html + +作者:[jao][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://jao.io +[b]: https://github.com/lujun9972 +[1]: https://leafnode.sourceforge.io/ +[2]: tmp.gr7aQUOwRH#fn.1 +[3]: tmp.gr7aQUOwRH#fn.2 +[4]: tmp.gr7aQUOwRH#fn.3 +[5]: tmp.gr7aQUOwRH#fnr.1 +[6]: https://wiki.archlinux.org/title/Rss2email +[7]: tmp.gr7aQUOwRH#fnr.2 +[8]: tmp.gr7aQUOwRH#fnr.3 +[9]: https://jao.io/blog/tags.html +[10]: https://jao.io/blog/tag-emacs.html diff --git a/sources/tech/20210524 4 steps to set up global modals in React.md b/sources/tech/20210524 4 steps to set up global modals in React.md index 1a6a762096..f0debb9c82 100644 --- a/sources/tech/20210524 4 steps to set up global modals in React.md +++ b/sources/tech/20210524 4 steps to set up global modals in React.md @@ -1,15 +1,16 @@ -[#]: subject: (4 steps to set up global modals in React) -[#]: via: (https://opensource.com/article/21/5/global-modals-react) -[#]: author: (Ajay Pratap https://opensource.com/users/ajaypratap) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: subject: "4 steps to set up global modals in React" +[#]: via: "https://opensource.com/article/21/5/global-modals-react" +[#]: author: "Ajay Pratap https://opensource.com/users/ajaypratap" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " 4 steps to set up global modals in React ====== Learn how to create interactive pop-up windows in a React web app. + ![Digital creative of a browser on the internet][1] A modal dialog is a window that appears on top of a web page and requires a user's interaction before it disappears. [React][2] has a couple of ways to help you generate and manage modals with minimal coding. @@ -24,11 +25,10 @@ In my opinion, the best way to manage modal dialogs in your React application is Here are the steps (and code) to set up global modals in React. I'm using [Patternfly][3] as my foundation, but the principles apply to any project. -#### 1\. Create a global modal component +#### 1. Create a global modal component In a file called **GlobalModal.tsx**, create your modal definition: - ``` import React, { useState, createContext, useContext } from 'react'; import { CreateModal, DeleteModal,UpdateModal } from './components'; @@ -46,25 +46,25 @@ const MODAL_COMPONENTS: any = { }; type GlobalModalContext = { - showModal: (modalType: string, modalProps?: any) => void; - hideModal: () => void; + showModal: (modalType: string, modalProps?: any) => void; + hideModal: () => void;  store: any; }; const initalState: GlobalModalContext = { - showModal: () => {}, - hideModal: () => {}, + showModal: () => {}, + hideModal: () => {},  store: {}, }; const GlobalModalContext = createContext(initalState); -export const useGlobalModalContext = () => useContext(GlobalModalContext); +export const useGlobalModalContext = () => useContext(GlobalModalContext); -export const GlobalModal: React.FC<{}> = ({ children }) => { +export const GlobalModal: React.FC<{}> = ({ children }) => {  const [store, setStore] = useState();  const { modalType, modalProps } = store || {}; - const showModal = (modalType: string, modalProps: any = {}) => { + const showModal = (modalType: string, modalProps: any = {}) => {    setStore({      ...store,      modalType, @@ -72,7 +72,7 @@ export const GlobalModal: React.FC<{}> = ({ children }) => {    });  }; - const hideModal = () => { + const hideModal = () => {    setStore({      ...store,      modalType: null, @@ -80,19 +80,19 @@ export const GlobalModal: React.FC<{}> = ({ children }) => {    });  }; - const renderComponent = () => { + const renderComponent = () => {    const ModalComponent = MODAL_COMPONENTS[modalType];    if (!modalType || !ModalComponent) {      return null;    } -   return <ModalComponent id="global-modal" {...modalProps} />; +   return ;  };  return ( -   <GlobalModalContext.Provider value={{ store, showModal, hideModal }}> +         {renderComponent()}      {children} -   </GlobalModalContext.Provider> +     ); }; ``` @@ -103,40 +103,39 @@ The `showModal` function takes two parameters: `modalType` and `modalProps`. The The `hideModal` function doesn't have any parameters; calling it causes the current open modal to close. -#### 2\. Create modal dialog components +#### 2. Create modal dialog components In a file called **CreateModal.tsx**, create a modal: - ``` import React from "react"; import { Modal, ModalVariant, Button } from "@patternfly/react-core"; import { useGlobalModalContext } from "../GlobalModal"; -export const CreateModal = () => { +export const CreateModal = () => {  const { hideModal, store } = useGlobalModalContext();  const { modalProps } = store || {};  const { title, confirmBtn } = modalProps || {}; - const handleModalToggle = () => { + const handleModalToggle = () => {    hideModal();  };  return ( -   <Modal +             {confirmBtn || "Confirm button"} -       </Button>, -       <Button key="cancel" variant="link" onClick={handleModalToggle}> +       , +             ]} -   > +   >      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod      tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim      veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea @@ -144,7 +143,7 @@ export const CreateModal = () => {      velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat      cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id      est laborum. -   </Modal> +     ); }; ``` @@ -153,34 +152,33 @@ This has a custom hook, `useGlobalModalContext`, that provides store object from To delete a modal, create a file called **DeleteModal.tsx**: - ``` import React from "react"; import { Modal, ModalVariant, Button } from "@patternfly/react-core"; import { useGlobalModalContext } from "../GlobalModal"; -export const DeleteModal = () => { +export const DeleteModal = () => {  const { hideModal } = useGlobalModalContext(); - const handleModalToggle = () => { + const handleModalToggle = () => {    hideModal();  };  return ( -   <Modal +             Confirm -       </Button>, -       <Button key="cancel" variant="link" onClick={handleModalToggle}> +       , +             ]} -   > +   >      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod      tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim      veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea @@ -188,41 +186,40 @@ export const DeleteModal = () => {      velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat      cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id      est laborum. -   </Modal> +     ); }; ``` To update a modal, create a file called **UpdateModal.tsx** and add this code: - ``` import React from "react"; import { Modal, ModalVariant, Button } from "@patternfly/react-core"; import { useGlobalModalContext } from "../GlobalModal"; -export const UpdateModal = () => { +export const UpdateModal = () => {  const { hideModal } = useGlobalModalContext(); - const handleModalToggle = () => { + const handleModalToggle = () => {    hideModal();  };  return ( -   <Modal +             Confirm -       </Button>, -       <Button key="cancel" variant="link" onClick={handleModalToggle}> +       , +             ]} -   > +   >      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod      tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim      veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea @@ -230,15 +227,14 @@ export const UpdateModal = () => {      velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat      cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id      est laborum. -   </Modal> +     ); }; ``` -#### 3\. Integrate GlobalModal into the top-level component in your application - -To integrate the new modal structure you've created into your app, you just import the global modal class you've created. Here's my sample **App.tsx** file: +#### 3. Integrate GlobalModal into the top-level component in your application +To integrate the new modal structure you've created into your app, you just import the global modal class you've created. Here's my sample **App.tsx**file: ``` import "@patternfly/react-core/dist/styles/base.css"; @@ -248,9 +244,9 @@ import { AppLayout } from "./AppLayout"; export default function App() {  return ( -   <GlobalModal> -     <AppLayout /> -   </GlobalModal> +    +      +     ); } ``` @@ -259,55 +255,54 @@ App.tsx is the top-level component in your app, but you can add another componen `GlobalModal` is the root-level component where all your modal components are imported and mapped with their specific `modalType`. -#### 4\. Select the modal's button from the AppLayout component +#### 4. Select the modal's button from the AppLayout component Adding a button to your modal with **AppLayout.js**: - ``` import React from "react"; import { Button, ButtonVariant } from "@patternfly/react-core"; import { useGlobalModalContext, MODAL_TYPES } from "./components/GlobalModal"; -export const AppLayout = () => { +export const AppLayout = () => {  const { showModal } = useGlobalModalContext(); - const createModal = () => { + const createModal = () => {    showModal(MODAL_TYPES.CREATE_MODAL, {      title: "Create instance form",      confirmBtn: "Save"    });  }; - const deleteModal = () => { + const deleteModal = () => {    showModal(MODAL_TYPES.DELETE_MODAL);  }; - const updateModal = () => { + const updateModal = () => {    showModal(MODAL_TYPES.UPDATE_MODAL);  };  return ( -   <> -     <Button variant={ButtonVariant.primary} onClick={createModal}> +   <> +      +     
+     
+      +     
+     
+      +     ); }; ``` -There are three buttons in the AppLayout component: create modal, delete modal, and update modal. Each modal is mapped with the corresponding `modalType`: `CREATE_MODAL`, `DELETE_MODAL`, or `UPDATE_MODAL`. +There are three buttons in the AppLayout component: create modal, delete modal, and update modal. Each modal is mapped with the corresponding `modalType` : `CREATE_MODAL`, `DELETE_MODAL`, or `UPDATE_MODAL`. ### Use global dialogs @@ -315,22 +310,20 @@ Global modals are a clean and efficient way to handle dialogs in React. They are If you'd like to see the code in action, I've included the [complete application][4] I created for this article in a sandbox. -Leslie Hinson sits down with Andrés Galante, an expert HTML and CSS coder who travels the world... - -------------------------------------------------------------------------------- via: https://opensource.com/article/21/5/global-modals-react 作者:[Ajay Pratap][a] -选题:[lujun9972][b] +选题:[lkxed][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/ajaypratap -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet) +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/browser_web_internet_website.png [2]: https://reactjs.org/ [3]: https://www.patternfly.org/v4/ [4]: https://codesandbox.io/s/affectionate-pine-gib74 diff --git a/sources/tech/20210531 Get started with Kubernetes using chaos engineering.md b/sources/tech/20210531 Get started with Kubernetes using chaos engineering.md deleted file mode 100644 index 344f7c1e9e..0000000000 --- a/sources/tech/20210531 Get started with Kubernetes using chaos engineering.md +++ /dev/null @@ -1,75 +0,0 @@ -[#]: subject: (Get started with Kubernetes using chaos engineering) -[#]: via: (https://opensource.com/article/21/5/kubernetes-chaos) -[#]: author: (Jessica Cherry https://opensource.com/users/cherrybomb) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Get started with Kubernetes using chaos engineering -====== -Learn the basics of chaos engineering in this first article in a series -celebrating Kubernetes' 11th birthday. -![Scrabble letters spell out chaos for chaos engineering][1] - -Kubernetes is turning 11, so I'll be celebrating its birthday by giving you some open source tools that will help you cause chaos. Chaos engineering is part science, part planning, and part experiments. It's the discipline of experimenting on a system to build confidence in the system's capability to withstand turbulent conditions in production. - -Before I start passing out the gifts, in this introductory article, I will explain the basics of how chaos engineering works. - -### How do I get started with chaos engineering? - -In my experience, the best way to start chaos engineering is by taking an incident that has happened before in production and using it as an experiment. Use your past data, make a plan to break your system in a similar way, create a repair strategy, and confirm the outcome turns out exactly how you want. If your plan fails, you have a new way to experiment and move forward toward a new way to handle issues quickly. - -Best of all, you can document everything as you go, which means, over time, your entire system will be fully documented so that anyone can be on call without too many escalations and everyone can have a nice break on weekends. - -### What do you do in chaos engineering? - -Chaos engineering has some science behind how these experiments work. I've documented some of the steps: - - 1. **Define a steady state**: Use a monitoring tool to gather data about what your system looks like functionally when there are no problems or incidents. - 2. **Come up with a hypothesis or use a previous incident:** Now that you have defined a steady state, come up with a hypothesis about what would happen (or has happened) during an incident or outage. Use this hypothesis to generate a series of theories about what could happen and how to resolve the problems. Then you can start a plan to purposely cause the issue. - 3. **Introduce the problem:** Use that plan to break your system and begin real-world testing. Gather your broken metrics' states, use your planned fix, and keep track of how long it takes before you reach a resolution. Make sure you document everything for future outages. - 4. **Try to disprove your own hypothesis:** The best part of experimenting is trying to disprove what you think or plan. You want to create a different state, see how far you can take it, and generate a different steady state in the system. - - - -Make sure to create a control system in a steady state before you generate the broken variables in another system. This will make it easier to spot the differences in various steady states before, during, and after your experiment. - -### What do I need for chaos engineering? - -The best tools for beginning chaos engineering are: - - * Good documentation practices - * A monitoring system to capture your system in a steady state and a non-steady state - * Grafana - * Prometheus - * Chaos engineering tools - * Chaos mesh - * Litmus - * And more that I will cover in future articles - * A hypothesis - * A plan - - - -### Go forth and destroy - -Now that you have the basics in hand, it's time to go forth and destroy your system safely. I would plan to start causing chaos four times a year and work toward monthly destructions. - -Chaos engineering is good practice and a great way to keep your internal documentation up to date. Also, new upgrades or application deployments will be smoother over time, and your daily life will be easier with Kubernetes administration. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/5/kubernetes-chaos - -作者:[Jessica Cherry][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/cherrybomb -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brett-jordan-chaos-unsplash.jpg?itok=sApp5dVd (Scrabble letters spell out chaos for chaos engineering) diff --git a/sources/tech/20210601 Get started with Java serverless functions.md b/sources/tech/20210601 Get started with Java serverless functions.md index e8c9184cef..94fe5a6f72 100644 --- a/sources/tech/20210601 Get started with Java serverless functions.md +++ b/sources/tech/20210601 Get started with Java serverless functions.md @@ -1,18 +1,20 @@ -[#]: subject: (Get started with Java serverless functions) -[#]: via: (https://opensource.com/article/21/6/java-serverless-functions) -[#]: author: (Daniel Oh https://opensource.com/users/daniel-oh) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: subject: "Get started with Java serverless functions" +[#]: via: "https://opensource.com/article/21/6/java-serverless-functions" +[#]: author: "Daniel Oh https://opensource.com/users/daniel-oh" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " Get started with Java serverless functions ====== -Quarkus allows you to develop serverless workloads with familiar Java -technology. +Quarkus allows you to develop serverless workloads with familiar Java technology. + ![Tips and gears turning][1] +Image by: opensource.com + The [serverless Java][2] journey started out with functions—small snippets of code running on demand. This phase didn't last long. Although functions based on virtual machine architecture in the 1.0 phase made this paradigm very popular, as the graphic below shows, there were limits around execution time, protocols, and poor local-development experience. Developers then realized that they could apply the same serverless traits and benefits to microservices and Linux containers. This launched the 1.5 phase, where some serverless containers completely abstracted [Kubernetes][3], delivering the serverless experience through [Knative][4] or another abstraction layer that sits on top of it. @@ -21,24 +23,21 @@ In the 2.0 phase, serverless starts to handle more complex orchestration and int ![The serverless Java journey][5] -(Daniel Oh, [CC BY-SA 4.0][6]) - Before Java developers can start developing new serverless functions, their first task is to choose a new cloud-native Java framework that allows them to run Java functions quicker with a smaller memory footprint than traditional monolithic applications. This can be applied to various infrastructure environments, from physical servers to virtual machines to containers in multi- and hybrid-cloud environments. -Developers might consider an opinionated Spring framework that uses the `java.util.function` package in [Spring Cloud Function][7] to support the development of imperative and reactive functions. Spring also enables developers to deploy Java functions to installable serverless platforms such as [Kubeless][8], [Apache OpenWhisk][9], [Fission][10], and [Project Riff][11]. However, there are concerns about slow startup and response times and heavy memory-consuming processes with Spring. This problem can be worse when running Java functions on scalable container environments such as Kubernetes. +Developers might consider an opinionated Spring framework that uses the `java.util.function` package in [Spring Cloud Function][6] to support the development of imperative and reactive functions. Spring also enables developers to deploy Java functions to installable serverless platforms such as [Kubeless][7], [Apache OpenWhisk][8], [Fission][9], and [Project Riff][10]. However, there are concerns about slow startup and response times and heavy memory-consuming processes with Spring. This problem can be worse when running Java functions on scalable container environments such as Kubernetes. -[Quarkus][12] is a new open source cloud-native Java framework that can help solve these problems. It aims to design serverless applications and write cloud-native microservices for running on cloud infrastructures (e.g., Kubernetes). +[Quarkus][11] is a new open source cloud-native Java framework that can help solve these problems. It aims to design serverless applications and write cloud-native microservices for running on cloud infrastructures (e.g., Kubernetes). Quarkus rethinks Java, using a closed-world approach to building and running it. It has turned Java into a runtime that's comparable to Go. Quarkus also includes more than 100 extensions that integrate enterprise capabilities, including database access, serverless integration, messaging, security, observability, and business automation. Here is a quick example of how developers can scaffold a Java serverless function project with Quarkus. -### 1\. Create a Quarkus serverless Maven project +### 1. Create a Quarkus serverless Maven project -Developers have multiple options to install a local Kubernetes cluster, including [Minikube][13] and [OKD][14] (OpenShift Kubernetes Distribution). This tutorial uses an OKD cluster for a developer's local environment because of the easy setup of serverless functionality on Knative and DevOps toolings. These guides for [OKD installation][15] and [Knative operator installation][16] offer more information about setting them up. - -The following command generates a Quarkus project (e.g., `quarkus-serverless-restapi`) to expose a simple REST API and download a `quarkus-openshift` extension for Knative service deployment: +Developers have multiple options to install a local Kubernetes cluster, including [Minikube][12] and [OKD][13] (OpenShift Kubernetes Distribution). This tutorial uses an OKD cluster for a developer's local environment because of the easy setup of serverless functionality on Knative and DevOps toolings. These guides for [OKD installation][14] and [Knative operator installation][15] offer more information about setting them up. +The following command generates a Quarkus project (e.g., `quarkus-serverless-restapi` ) to expose a simple REST API and download a `quarkus-openshift` extension for Knative service deployment: ``` $ mvn io.quarkus:quarkus-maven-plugin:1.13.4.Final:create \ @@ -48,50 +47,45 @@ $ mvn io.quarkus:quarkus-maven-plugin:1.13.4.Final:create \        -DclassName="org.acme.getting.started.GreetingResource" ``` -### 2\. Run serverless functions locally +### 2. Run serverless functions locally Run the application using Quarkus development mode to check if the REST API works, then tweak the code a bit: - ``` -`$ ./mvnw quarkus:dev` +$ ./mvnw quarkus:dev ``` The output will look like this: - ``` -__  ____  __  _____   ___  __ ____  ______ - --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ - -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   -\--\\___\\_\\____/_/ |_/_/|_/_/|_|\\____/___/   -INFO  [io.quarkus] (Quarkus Main Thread) quarkus-serverless-restapi 1.0.0-SNAPSHOT on JVM (powered by Quarkus xx.xx.xx.) started in 2.386s. Listening on: +__  ____  __  _____   ___  __ ____  ______ + --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ + -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   +--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   +INFO  [io.quarkus] (Quarkus Main Thread) quarkus-serverless-restapi 1.0.0-SNAPSHOT on JVM (powered by Quarkus xx.xx.xx.) started in 2.386s. Listening on: http://localhost:8080 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated. INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, kubernetes, resteasy] ``` > **Note**: Keep your Quarkus application running to use Live Coding. This allows you to avoid having to rebuild, redeploy the application, and restart the runtime whenever the code changes. -Now you can hit the REST API with a quick `curl` command. The output should be `Hello RESTEasy`: - +Now you can hit the REST API with a quick `curl` command. The output should be `Hello RESTEasy` : ``` $ curl localhost:8080/hello Hello RESTEasy ``` -Tweak the return text in `GreetingResource.java`: - +Tweak the return text in `GreetingResource.java` : ``` -    public [String][17] hello() { +public String hello() {         return "Quarkus Function on Kubernetes";     } ``` You will see new output when you reinvoke the REST API: - ``` $ curl localhost:8080/hello Quarkus Function on Kubernetes @@ -99,87 +93,77 @@ Quarkus Function on Kubernetes There's not been a big difference between normal microservices and serverless functions. A benefit of Quarkus is that it enables developers to use any microservice to deploy Kubernetes as a serverless function. -### 3\. Deploy the functions to a Knative service +### 3. Deploy the functions to a Knative service -If you haven't already, [create a namespace][18] (e.g., `quarkus-serverless-restapi`) on your OKD (Kubernetes) cluster to deploy this Java serverless function. - -Quarkus enables developers to generate Knative and Kubernetes resources by adding the following variables in `src/main/resources/application.properties`: +If you haven't already, [create a namespace][16] (e.g., `quarkus-serverless-restapi` ) on your OKD (Kubernetes) cluster to deploy this Java serverless function. +Quarkus enables developers to generate Knative and Kubernetes resources by adding the following variables in `src/main/resources/application.properties` : ``` -quarkus.container-image.group=quarkus-serverless-restapi <1> -quarkus.container-image.registry=image-registry.openshift-image-registry.svc:5000 <2> -quarkus.kubernetes-client.trust-certs=true <3> -quarkus.kubernetes.deployment-target=knative <4> -quarkus.kubernetes.deploy=true <5> -quarkus.openshift.build-strategy=docker <6> +quarkus.container-image.group=quarkus-serverless-restapi <1> +quarkus.container-image.registry=image-registry.openshift-image-registry.svc:5000 <2> +quarkus.kubernetes-client.trust-certs=true <3> +quarkus.kubernetes.deployment-target=knative <4> +quarkus.kubernetes.deploy=true <5> +quarkus.openshift.build-strategy=docker <6> ``` > Legend: -> -> <1> Define a project name where you deploy a serverless application -> <2> The container registry to use -> <3> Use self-signed certs in this simple example to trust them -> <4> Enable the generation of Knative resources -> <5> Instruct the extension to deploy to OpenShift after the container image is built -> <6> Set the Docker build strategy + +> <1> Define a project name where you deploy a serverless application +<2> The container registry to use +<3> Use self-signed certs in this simple example to trust them +<4> Enable the generation of Knative resources +<5> Instruct the extension to deploy to OpenShift after the container image is built +<6> Set the Docker build strategy This command builds the application then deploys it directly to the OKD cluster: - ``` -`$ ./mvnw clean package -DskipTests` +$ ./mvnw clean package -DskipTests ``` -> **Note:** Make sure to log in to the right project (e.g., `quarkus-serverless-restapi`) by using the `oc login` command ahead of time. +> **Note:** Make sure to log in to the right project (e.g., `quarkus-serverless-restapi` ) by using the `oc login` command ahead of time. The output should end with `BUILD SUCCESS`. Add a Quarkus label to the Knative service with this `oc` command: - ``` -$ oc label rev/quarkus-serverless-restapi-00001 +$ oc label rev/quarkus-serverless-restapi-00001 app.openshift.io/runtime=quarkus --overwrite ``` -Then access the OKD web console to go to the [Topology view in the Developer perspective][19]. You might see that your pod (serverless function) is already scaled down to zero (white-line circle). +Then access the OKD web console to go to the [Topology view in the Developer perspective][17]. You might see that your pod (serverless function) is already scaled down to zero (white-line circle). -![Topology view][20] +![Topology view][18] -(Daniel Oh, [CC BY-SA 4.0][6]) - -### 4\. Test the functions on Kubernetes +### 4. Test the functions on Kubernetes Retrieve a route `URL` of the serverless function by running the following `oc` command: - ``` $ oc get rt/quarkus-serverless-restapi [...] NAME                      URL                             READY   REASON -quarkus-serverless[...]     True +quarkus-serverless[...]   http://quarkus[...].SUBDOMAIN   True ``` Access the route `URL` with a `curl` command: - ``` -`$ curl http://quarkus-serverless-restapi-quarkus-serverless-restapi.SUBDOMAIN/hello` +$ curl http://quarkus-serverless-restapi-quarkus-serverless-restapi.SUBDOMAIN/hello ``` In a few seconds, you will get the same result as you got locally: - ``` -`Quarkus Function on Kubernetes` +Quarkus Function on Kubernetes ``` When you return to the Topology view in the OKD cluster, the Knative service scales up automatically. -![Scaling the Knative Function][21] - -(Daniel Oh, [CC BY-SA 4.0][6]) +![Scaling the Knative Function][19] This Knative service pod will go down to zero again in 30 seconds because of Knative serving's default setting. @@ -189,37 +173,37 @@ The serverless journey has evolved, starting with functions on virtual machines The next article in this series will guide you on optimizing Java serverless functions in Kubernetes for faster startup time and small memory footprints at scale. +Image by: (Daniel Oh, CC BY-SA 4.0) + -------------------------------------------------------------------------------- via: https://opensource.com/article/21/6/java-serverless-functions 作者:[Daniel Oh][a] -选题:[lujun9972][b] +选题:[lkxed][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/daniel-oh -[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) +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/gears_devops_learn_troubleshooting_lightbulb_tips_520.png [2]: https://opensource.com/article/21/5/what-serverless-java [3]: https://opensource.com/article/19/6/reasons-kubernetes [4]: https://cloud.google.com/knative/ -[5]: https://opensource.com/sites/default/files/uploads/serverless-journey.png (The serverless Java journey) -[6]: https://creativecommons.org/licenses/by-sa/4.0/ -[7]: https://spring.io/serverless -[8]: https://kubeless.io/ -[9]: https://openwhisk.apache.org/ -[10]: https://fission.io/ -[11]: https://projectriff.io/ -[12]: https://quarkus.io/ -[13]: https://minikube.sigs.k8s.io/docs/start/ -[14]: https://docs.okd.io/latest/welcome/index.html -[15]: https://docs.okd.io/latest/installing/index.html -[16]: https://knative.dev/docs/install/knative-with-operators/ -[17]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string -[18]: https://docs.okd.io/latest/applications/projects/configuring-project-creation.html -[19]: https://docs.okd.io/latest/applications/application_life_cycle_management/odc-viewing-application-composition-using-topology-view.html -[20]: https://opensource.com/sites/default/files/uploads/topologyview.png (Topology view) -[21]: https://opensource.com/sites/default/files/uploads/scale-up-knative-function.png (Scaling the Knative Function) +[5]: https://opensource.com/sites/default/files/uploads/serverless-journey.png +[6]: https://spring.io/serverless +[7]: https://kubeless.io/ +[8]: https://openwhisk.apache.org/ +[9]: https://fission.io/ +[10]: https://projectriff.io/ +[11]: https://quarkus.io/ +[12]: https://minikube.sigs.k8s.io/docs/start/ +[13]: https://docs.okd.io/latest/welcome/index.html +[14]: https://docs.okd.io/latest/installing/index.html +[15]: https://knative.dev/docs/install/knative-with-operators/ +[16]: https://docs.okd.io/latest/applications/projects/configuring-project-creation.html +[17]: https://docs.okd.io/latest/applications/application_life_cycle_management/odc-viewing-application-composition-using-topology-view.html +[18]: https://opensource.com/sites/default/files/uploads/topologyview.png +[19]: https://opensource.com/sites/default/files/uploads/scale-up-knative-function.png diff --git a/sources/tech/20210602 Establish an SSH connection between Windows and Linux.md b/sources/tech/20210602 Establish an SSH connection between Windows and Linux.md deleted file mode 100644 index 2d76592dc7..0000000000 --- a/sources/tech/20210602 Establish an SSH connection between Windows and Linux.md +++ /dev/null @@ -1,230 +0,0 @@ -[#]: subject: (Establish an SSH connection between Windows and Linux) -[#]: via: (https://opensource.com/article/21/6/ssh-windows) -[#]: author: (Stephan Avenwedde https://opensource.com/users/hansic99) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Establish an SSH connection between Windows and Linux -====== -Use the open source tool, PuTTY to establish an SSH connection from a -Windows machine to a Linux system. -![clouds in windows][1] - -The secure shell protocol (SSH) is the most common method for controlling remote machines over the command line in the Linux world. SSH is a true Linux original, and it is also gaining popularity in the Windows world. There is even official [Windows documentation for SSH][2], which covers controlling Windows machines using [OpenSSH][3]. - -This article describes how to establish an SSH connection from a Windows machine to a Fedora 33 Linux system using the popular open source tool [PuTTY][4]. - -### Ways to use SSH - -SSH uses a client-server architecture, where an SSH client establishes a connection to an SSH server. The SSH server is usually running as a system daemon, so it is often called SSHD. You can hardly find a Linux distribution that does not come with the SSH daemon. In Fedora 33, the SSH daemon is installed but not activated. - -You can use SSH to control almost any Linux machine, whether it's running as a virtual machine or as a physical device on your network. A common use case is the headless configuration of embedded devices, including the Raspberry Pi. SSH can also be used to tunnel other network services. Because SSH traffic is encrypted, you can use SSH as a transport layer for any protocol that does not provide encryption by default. - -In this article, I'll explain four ways to use SSH: 1. how to configure the SSH daemon on the Linux side, 2. how to set up a remote console connection, 3. how to copy files over the network, and 4. how to tunnel a certain protocol over SSH. - -### 1\. Configure SSHD - -The Linux system (Fedora 33 in my case) acts as the SSH server that allows the PuTTY SSH client to connect. First, check the daemon's SSH configuration. The configuration file is located at `/etc/ssh/sshd_config` and contains a lot of switches that can be activated by commenting out related lines: - - -``` -#       $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $ - -# This is the sshd server system-wide configuration file.  See -# sshd_config(5) for more information. - -# This sshd was compiled with PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin - -# The strategy used for options in the default sshd_config shipped with -# OpenSSH is to specify options with their default value where -# possible, but leave them commented.  Uncommented options override the -# default value. - -Include /etc/ssh/sshd_config.d/*.conf - -#Port 22 -#AddressFamily any -#ListenAddress 0.0.0.0 -#ListenAddress :: -``` - -The default configuration, where no line is uncommented, should work for this example. Check whether the SSH daemon is already running by typing `systemctl status sshd`: - - -``` -$ systemctl status sshd -● sshd.service - OpenSSH server daemon -   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) -   Active: active (running) since Fri 2018-06-22 11:12:05 UTC; 2 years 11 months ago -     Docs: man:sshd(8) -           man:sshd_config(5) - Main PID: 577 (sshd) -    Tasks: 1 (limit: 26213) -   CGroup: /system.slice/sshd.service -           └─577 /usr/sbin/sshd -D -oCiphers=[aes256-gcm@openssh.com][5],chacha20-[...] -``` - -If it's inactive, start it with the `systemctl start sshd` command. - -### 2\. Set up a remote console - -On Windows, [download the PuTTY installer][6], then install and open it. You should see a window like this: - -![PuTTY configuration screen][7] - -(Stephan Avenwedde, [CC BY-SA 4.0][8]) - -In the **Host Name (or IP address)** input field, enter the connection information for your Linux system. In this example, I set up a Fedora 33 virtual machine with a bridged network adapter that I can use to contact the system at the IP address `192.168.1.60`. Click **Open**, and a window like this should open: - -![PutTTY security alert][9] - -(Stephan Avenwedde, [CC BY-SA 4.0][8]) - -This is an SSH security mechanism to prevent a [man-in-the-middle attack][10]. The fingerprint in the message should match the key on the Linux system at `/etc/ssh/ssh_host_ed25519_key.pub.`. PuTTY prints the key as an [MD5 hash][11]. To check its authenticity, switch to the Linux system, open a command shell, and enter: - - -``` -`ssh-keygen -l -E md5 -f /etc/ssh/ssh_host_ed25519_key.pub` -``` - -The output should match the fingerprint shown by PuTTY: - - -``` -$ ssh-keygen -l -E md5 -f /etc/ssh/ssh_host_ed25519_key.pub -256 MD5:E4:5F:01:05:D0:F7:DC:A6:32 no comment (ED25519) -``` - -Confirm the PuTTY Security Alert by clicking **Yes**. The host system's fingerprint is now in PuTTYs trust list, which is located in the Windows registry under: - - -``` -`HKEY_CURRENT_USER\SOFTWARE\SimonTatham\PuTTY\SshHostKeys` -``` - -Enter your correct login credentials, and you should be on the console in your home directory: - -![Logged in to SSH][12] - -(Stephan Avenwedde, [CC BY-SA 4.0][8]) - -### 3\. Copy files over the network - -In addition to the remote console, you can use PuTTY to transfer files via SSH. Look in the installation folder under `C:\\Program Files (x86)\\PuTTY` and find `pscp.exe`. You can use this to copy files to and from a Linux system. - -Open a command prompt with **Windows + R** and enter **cmd**. Copy the file `MyFile.txt` from your Linux user home directory to your Windows home directory by entering: - - -``` -`C:\"Program Files (x86)"\PuTTY\pscp.exe stephan@192.168.1.60:/home/stephan/MyFile.txt .` -``` - -To copy a file from the Windows home directory to the Linux user home directory, enter: - - -``` -`C:\"Program Files (x86)"\PuTTY\pscp.exe MyFile.txt stephan@192.168.1.60:/home/stephan/` -``` - -As you may have already figured out, the copy command's general structure is: - - -``` -`pscp.exe ` -``` - -### 4\. Tunnel a protocol - -Imagine you have a Linux machine that is running an HTTP-based service for some arbitrary application. You want to access this HTTP service from your Windows machine over the internet. Of course, you cannot expose the related TCP port to the public because: - - 1. The server is running HTTP, not HTTPS - 2. There is no user management nor login at all - - - -At first glance, it looks like an impossible task to set up this architecture without producing a horrible security flaw. But SSH makes it relatively easy to set up a safe solution for this scenario. - -I will demonstrate this procedure with my software project [Pythonic][13]. Running as a container, Pythonic exposes two TCP ports: TCP port 7000 (main editor) and TCP port 8000 (the [code-server][14] source-code editor). - -To install Pythonic on a Linux machine, run: - - -``` -podman pull pythonicautomation/pythonic -podman run -d -p 7000:7000 -p 8000:8000 pythonic -``` - -Switch to your Windows machine, open PuTTY, and navigate to **Connection -> SSH -> Tunnels**. Add the two TCP ports you want to forward: - - * Source: `7000` / Destination: `localhost:7000` - * Source: `8000` / Destination: `localhost:8000` - - - -![Port forwarding in PuTTY][15] - -(Stephan Avenwedde, [CC BY-SA 4.0][8]) - -Then go back to the **Session** section, and establish an SSH connection as you did before. Open a browser and navigate to `http://localhost:7000`; you should see a screen like this: - -![Pythonic][16] - -(Stephan Avenwedde, [CC BY-SA 4.0][8]) - -You have successfully configured port forwarding! - -**Warning**: If you expose TCP Port 22 to the public, don't use easy-to-guess login credentials. You will receive login attempts from all over the world trying to access your Linux machine with common, standard credentials. Instead, permit only known clients to log in. This login restriction can be achieved using [public-key cryptography][17], which uses a key pair in which the public key is stored on the SSH host machine, and the private key remains at the client. - -### Debugging - -If you are struggling to connect to your Linux machine, you can follow the processes in your SSH daemon with: - - -``` -`journalctl -f -u sshd` -``` - -This is how an ordinary log-in process looks like with LogLevel DEBUG : - -![LogLevel DEBUG output][18] - -(Stephan Avenwedde, [CC BY-SA 4.0][8]) - -### Learn more - -This article barely scratched the surface about ways to use SSH. If you are looking for information about a specific use case, you can probably find it among the tons of SSH tutorials on the internet. I use PuTTY heavily at work because its easy configuration and good interoperability between operating systems make it a Swiss Army knife tool for connectivity solutions. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/6/ssh-windows - -作者:[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/cloud-windows-building-containers.png?itok=0XvZLZ8k (clouds in windows) -[2]: https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_overview -[3]: https://www.openssh.com/ -[4]: https://www.putty.org/ -[5]: mailto:aes256-gcm@openssh.com -[6]: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html -[7]: https://opensource.com/sites/default/files/uploads/putty_connection_settings.png (PuTTY configuration screen) -[8]: https://creativecommons.org/licenses/by-sa/4.0/ -[9]: https://opensource.com/sites/default/files/uploads/putty_host_key.png (PutTTY security alert) -[10]: https://en.wikipedia.org/wiki/Man-in-the-middle_attack -[11]: https://en.wikipedia.org/wiki/MD5 -[12]: https://opensource.com/sites/default/files/uploads/ssh_successfull_login.png (Logged in to SSH) -[13]: https://github.com/hANSIc99/Pythonic -[14]: https://github.com/cdr/code-server -[15]: https://opensource.com/sites/default/files/uploads/ssh_port_forwarding.png (Port forwarding in PuTTY) -[16]: https://opensource.com/sites/default/files/uploads/pythonic_screen.png (Pythonic) -[17]: https://opensource.com/article/21/4/encryption-decryption-openssl -[18]: https://opensource.com/sites/default/files/uploads/sshd_debug_log.png (LogLevel DEBUG output) diff --git a/sources/tech/20210611 How to use the FreeDOS text editor.md b/sources/tech/20210611 How to use the FreeDOS text editor.md deleted file mode 100644 index 4afe36aa36..0000000000 --- a/sources/tech/20210611 How to use the FreeDOS text editor.md +++ /dev/null @@ -1,96 +0,0 @@ -[#]: subject: (How to use the FreeDOS text editor) -[#]: via: (https://opensource.com/article/21/6/freedos-text-editor) -[#]: author: (Jim Hall https://opensource.com/users/jim-hall) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -How to use the FreeDOS text editor -====== -FreeDOS provides a user-friendly text editor called FreeDOS Edit. -![Person using a laptop][1] - -Editing files is a staple on any operating system. Whether you want to make a note about something, write a letter to a friend, or update a system configuration file—you need an editor. And FreeDOS provides a user-friendly text editor called (perhaps unimaginatively) "FreeDOS Edit." - -### Editing files - -The simplest invocation of FreeDOS Edit is just `EDIT`. This brings up an empty editor window. The patterned background suggests an empty "desktop"—a reminder that you aren't editing any files. - -![FreeDOS Edit][2] - -FreeDOS Edit without any files loaded -Jim Hall, CC-BY SA 4.0 - -Like most DOS applications, you can access the menus in Edit by tapping the Alt key once on your keyboard. This activates the menu. After hitting Alt, Edit will switch to "menu" access and will highlight the "File" menu. If you want to access a different menu on the menu bar, use the left and right arrow keys. Press the down arrow or hit the Enter key to go "into" the menu. - -![FreeDOS Edit menu][3] - -Highlighting the menu -Jim Hall, CC-BY SA 4.0 - -Do you notice that the first letter for each menu title is a different color? This highlight indicates a shortcut. For example, the "F" in the "File" menu is highlighted in red. So you could instead press Alt+F (Alt and F at the same time) and Edit will bring up the "File" menu. - -![File menu][4] - -The File menu -Jim Hall, CC-BY SA 4.0 - -You can use the "File" menu to either start a new (empty) file, or open an existing file. Let's start a new file by using the arrow keys to move down to "New" and pressing the Enter key. You can also start a new file by pressing Ctrl+N (Ctrl and N at the same time): - -![new file][5] - -Editing a new file -Jim Hall, CC-BY SA 4.0 - -Editing files should be pretty straightforward after that. Most of the familiar keyboard shortcuts exist in FreeDOS Edit: Ctrl+C to copy text, Ctrl+X to cut text, and Ctrl+V to paste copied or cut text into a new location. If you need to find specific text in a long document, press Ctrl+F. To save your work, use Ctrl+S to commit changes back to the disk. - -### Programming in Edit - -If you're a programmer, you may find the extended ASCII table a useful addition. DOS systems supported an "extended" ASCII character set commonly referred to as "code page 437." The standard characters between 0 and 127 include the letters A through Z (uppercase and lowercase), numbers, and special symbols like punctuation. However, the DOS extended characters from code 128 to code 255 included foreign language characters and "line drawing" elements. DOS programmers often made use of these extended ASCII characters, so FreeDOS Edit makes it easy to view a table of all the ASCII codes and their associated characters. - -To view the ASCII table, use the "Utilities" menu and select the "ASCII Table" entry. This brings up a window containing a table. - -![utilities menu - ascii table][6] - -Find the ASCII Table in the Utilities menu -Jim Hall, CC-BY SA 4.0 - -Along the left, the table shows the hexadecimal values "00" through "F0," and the top shows the single values "0" through "F." These provide a quick reference to the hexadecimal code for each character. For example, the item in the first row (00) and the first column (0) has the hexadecimal value 00 + 0, or 0x00 (the "NULL" value). And the character in the fifth row (40) and the second column (1) has the value 40 + 1, or 0x41 (the letter "A"). - -![utilities menu - ascii table][7] - -The ASCII Table provides a handy reference for extended characters -Jim Hall, CC-BY SA 4.0 - -As you move the cursor through the table to highlight different characters, you'll see the values at the bottom of the table change to show the character's code in decimal, hexadecimal, and octal. For example, moving the cursor to highlight the "line intersection" character at row C0 and column 5 shows this extended character code as 197 (dec), 0xc5 (hex), and 305 (oct). In a program, you might reference this extended character by typing the hex value `0xc5`, or the octal "escape code" `\305`. - -![ASCII 0xc5][8] - -The "line intersection" character is 197 (dec), 0xc5 (hex), and 305 (oct) -Jim Hall, CC-BY SA 4.0 - -Feel free to explore the menus in Edit to discover other neat features. For example, the "Options" menu allows you to change the behavior and appearance of Edit. If you prefer to use a more dense display, you can use the "Display" menu (under "Options") to set Edit to 25, 43, or 50 lines. You can also force Edit to display in monochrome (white on black) or reversed mode (black on white). - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/6/freedos-text-editor - -作者:[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/laptop_screen_desk_work_chat_text.png?itok=UXqIDRDD (Person using a laptop) -[2]: https://opensource.com/sites/default/files/uploads/edit.png (FreeDOS Edit without any files loaded) -[3]: https://opensource.com/sites/default/files/uploads/edit-menu.png (Highlighting the menu) -[4]: https://opensource.com/sites/default/files/uploads/edit-file.png (The File menu) -[5]: https://opensource.com/sites/default/files/uploads/edit-new.png (Editing a new file) -[6]: https://opensource.com/sites/default/files/uploads/utilities-ascii.png (Find the ASCII Table in the Utilities menu) -[7]: https://opensource.com/sites/default/files/uploads/ascii-table-0x00.png (The ASCII Table provides a handy reference for extended characters) -[8]: https://opensource.com/sites/default/files/uploads/ascii-0xc5.png (The "line intersection" character is 197 (dec), 0xc5 (hex), and 305 (oct)) diff --git a/sources/tech/20210627 How to Convert File Formats With Pandoc in Linux -Quick Guide.md b/sources/tech/20210627 How to Convert File Formats With Pandoc in Linux -Quick Guide.md deleted file mode 100644 index e6abce3857..0000000000 --- a/sources/tech/20210627 How to Convert File Formats With Pandoc in Linux -Quick Guide.md +++ /dev/null @@ -1,137 +0,0 @@ -[#]: subject: (How to Convert File Formats With Pandoc in Linux [Quick Guide]) -[#]: via: (https://itsfoss.com/pandoc-convert-file/) -[#]: author: (Bill Dyer https://itsfoss.com/author/bill/) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -How to Convert File Formats With Pandoc in Linux [Quick Guide] -====== - -In an earlier article, I covered the [procedure to batch convert a handful of Markdown files to HTML][1] using pandoc. In that article, multiple HTML files were created, but pandoc can do much more. It has been called “the Swiss army knife” of document conversion – and with good reason. There isn’t a lot that it can’t do. - -[Pandoc][2] can covert .docx, .odt, .html, .epub, LaTeX, DocBook, etc. to these and other formats, such as JATS, TEI Simple, AsciiDoc, and more. - -Yes, this means that pandoc can convert .docx files to .pdf and .html, but you may be thinking: “Word can export files to .pdf and .html too. Why would I need pandoc?” - -You would have a good point there, but since pandoc can convert so many formats, it could well become your go-to tool for all of your conversion tasks. For example, many of us know that [Markdown editors][3] can export its Markdown files to .html. With pandoc, Markdown files can be converted to numerous other formats as well. - -I rarely have Markdown export to HTML; I normally let pandoc do it. - -### Converting File Formats with Pandoc - -![][4] - -Here, I will convert Markdown files into a few different formats. I do almost all of my writing using Markdown syntax, but I often have to convert to another format: .docx files are usually required for school work, .html for web pages that I create – and for .epub work, .pdf for flyers and handouts, and even an occasional TEI Simple file for a university digital humanities project. Pandoc can handle all of these, and more, easily. - -First, you need to [install pandoc][5]. Also, to create .pdf files, LaTeX will be needed as well. The package I prefer is [TeX Live][6]. - -**Note**: If you would like to try out pandoc before installing it, there is an online try-out page at: - -#### Installing pandoc and texlive - -Users of Ubuntu and other Debian distros can type the following commands in the terminal: - -``` -sudo apt-get update -sudo apt-get install pandoc texlive -``` - -Notice on the second line, you are installing pandoc and texlive in one shot. [apt-get command][7] will have no problem with this, but go get some coffee; this may take a few minutes. - -#### Getting to Conversion - -Once pandoc and texlive are installed, you can burn through some work! - -The sample document for this project will be an article that was first published in the _North American Review_ in December of 1894, and is titled: “How To Repel Train Robbers”. The Markdown file that I will be using was created some time ago as part of a restoration project. - -The file: `how_to_repel_train_robbers.md` is located in my Documents directory, in a sub-directory named samples. Here is what it looks like in Ghostwriter. - -![Markdown file in Ghostwriter][8] - -I want to create .docx, .pdf, and .html versions of this file. - -#### The First Conversion - -I’ll start with making a .pdf copy first, since I went through the trouble of installing a LaTeX package. - -While in the ~/Documents/samples/ directory, I type the following to create a .pdf file: - -``` -pandoc -o htrtr.pdf how_to_repel_train_robbers.md -``` - -The above command will create a file called htrtr.pdf from the how_to_repel_train_robbers.md file. The reason I used htrtr as a name was that it is shorter than how_to_repel_train_robbers – htrtr is the first letter of each word in the long title. - -Here is a snapshot of the .pdf file once it is made: - -![Converted PDF file viewed in Ocular][9] - -#### The Second Conversion - -Next, I want to create a .docx file. The command is almost identical to the one I used to create the .pdf and it is: - -``` -pandoc -o htrtr.docx how_to_repel_train_robbers.md -``` - -In no time, a .docx file is created. Here is what it looks like in Libre Writer: - -![Converted DOCX file viewed in Libre Writer][10] - -#### The Third Conversion - -I may want to post this on the web, so a web page would be nice. I will create a .html file with this command: - -``` -pandoc -o htrtr.html how_to_repel_train_robbers.md -``` - -Again, the command to create it is very much like the last two conversions. Here is what the .html file looks like in a browser: - -![Converted HTML file viewed in Firefox][11] - -#### Noticed Anything Yet? - -Let’s look at the past commands again. They were: - -``` -pandoc -o htrtr.pdf how_to_repel_train_robbers.md -pandoc -o htrtr.docx how_to_repel_train_robbers.md -pandoc -o htrtr.html how_to_repel_train_robbers.md -``` - -The only thing different about these three commands is the extension next to htrtr. This gives you a hint that pandoc relies on the extension of the output filename you provide. - -### Conclusion - -Pandoc can do far more than the three little conversions done here. If you write with a preferred format, but need to convert the file to another format, chances are great that pandoc will be able to do it for you. - -What would you do with this? Would you automate this? What if you had a web site that had articles for your readers to download? You could modify these little commands to work as a script and your readers could decide which format they would like. You could offer .docx, .pdf, .odt, .epub, or more. Your readers choose, the proper conversion script runs, and your readers download their file. It can be done. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/pandoc-convert-file/ - -作者:[Bill Dyer][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/bill/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/convert-markdown-files/ -[2]: https://pandoc.org/ -[3]: https://itsfoss.com/best-markdown-editors-linux/ -[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/pandoc-quick-guide.png?resize=800%2C450&ssl=1 -[5]: https://pandoc.org/installing.html -[6]: https://www.tug.org/texlive/ -[7]: https://itsfoss.com/apt-get-linux-guide/ -[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/convert_with_pandoc_ghostwriter.png?resize=800%2C516&ssl=1 -[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/convert_with_pandoc_ocular.png?resize=800%2C509&ssl=1 -[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/convert_with_pandoc_libre_writer.png?resize=800%2C545&ssl=1 -[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/convert_with_pandoc_firefox.png?resize=800%2C511&ssl=1 diff --git a/sources/tech/20210630 9 reasons I love to use the Qt Creator IDE.md b/sources/tech/20210630 9 reasons I love to use the Qt Creator IDE.md deleted file mode 100644 index 44a5b4ad73..0000000000 --- a/sources/tech/20210630 9 reasons I love to use the Qt Creator IDE.md +++ /dev/null @@ -1,209 +0,0 @@ -[#]: subject: (9 reasons I love to use the Qt Creator IDE) -[#]: via: (https://opensource.com/article/21/6/qtcreator) -[#]: author: (Stephan Avenwedde https://opensource.com/users/hansic99) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -9 reasons I love to use the Qt Creator IDE -====== -Qt Creator is the glue between Qt's rich set of libraries and the -programmer. -![Business woman on laptop sitting in front of window][1] - -Qt Creator is the Qt framework's default integrated development environment (IDE) and hence the glue between Qt's rich set of libraries and the user. In addition to its basic features such as intelligent code completion, debugging, and project administration, Qt Creator offers a lot of nice features that make software development easier. - -In this article, I will highlight some of my favorite [Qt Creator][2] features. - -### Dark mode - -My first question when working with a new application is: _Is there a dark mode?_ Qt Creator answers with: _Which dark mode do you prefer?_ - -You can activate dark mode in the Options menu. On the top menu bar, go to **Tools**, select **Options**, and go to the **Environment** section. Here is where you can select the general appearance: - -![ QT Creator dark mode][3] - -(Stephan Avenwedde, [CC BY-SA 4.0][4]) - -### Custom appearance - -Like every Qt application, Qt Creator's appearance is highly customizable with style sheets. Below, you can follow along with my approach to give Qt Creator a fancy look. - -Create the file `mycustomstylesheet.css` with the following content: - - -``` -QMenuBar { background-color: olive } -QMenuBar::item { background-color: olive } -QMenu { background-color : beige; color : black } -QLabel { color: green } -``` - -Then start Qt Creator from the command line and pass the style sheet as a parameter with: - - -``` -`qtcreator -stylesheet=mycustomstylesheet.css` -``` - -It should look like this: - -![QT Creator custom stylesheet][5] - -(Stephan Avenwedde, [CC BY-SA 4.0][4]) - -Read more about style sheets in the [documentation][6]. - -### Command-line parameters - -Qt Creator accepts many command-line options. For example, if you want to automatically load your current project at startup, pass the path to the `*.pro-file`: - - -``` -`qtcreator ~/MyProject/MyQtProject.pro` -``` - -You can even pass the file and the line number that should be opened by default. This command opens the file `main.cpp` at line 20: - - -``` -`qtcreator ~/MyProject/main.cpp:20` -``` - -Read more about the Qt Creator-specific command-line options in the [documentation][7]. - -Qt Creator is an ordinary Qt application, so, in addition to its own command-line arguments, it also accepts the generic arguments for [QApplication][8] and [QGuiApplication][9]. - -### Cross-compiling - -Qt Creator allows you to define several toolchains, called **Kits**. A kit defines the binaries and SDK for building and running an application: - -![QT Creator kits][10] - -(Stephan Avenwedde, [CC BY-SA 4.0][4]) - -This allows you to switch between completely different toolchains with just two clicks: - -![Switching between Kits in Qt Creator][11] - -(Stephan Avenwedde, [CC BY-SA 4.0][4]) - -Read more about kits in the [manual][12]. - -### Analyzer - -Qt Creator integrates several of the most popular analyzers, such as: - - * [Linux Performance Analyzer][13] (requires a special kernel)  - * [Valgrind][14] memory profiler - * [Clang-Tidy and Clazy][15], a linter for C/C++ - - - -![Qt Creator analyzer][16] - -(Stephan Avenwedde, [CC BY-SA 4.0][4]) - -### Debugger - -When it comes to debugging, Qt Creator has a nice interface for GNU Debugger (GDB). I like its easy way of inspecting container types and creating conditional breakpoints: - -![Qt Creator debugger][17] - -(Stephan Avenwedde, [CC BY-SA 4.0][4]) - -### FakeVim - -If you like Vim, enable FakeVim in the settings to control Qt Creator like Vim. Go to **Tools** and select **Options**. In the **FakeVim** section, you can find many switches to customize FakeVim's behavior. In addition to the editor functions, you can also map your own functions to custom Vim commands. - -For example, you can map the function **Build Project** to the `build` command: - -![FakeVim in Qt Creator][18] - -(Stephan Avenwedde, [CC BY-SA 4.0][4]) - -Back in the editor, when you press the colon button and enter `build`, Qt Creator starts a build process with the configured toolchain: - -![FakeVim in Qt Creator][19] - -(Stephan Avenwedde, [CC BY-SA 4.0][4]) - -You can find more information about FakeVim [in the docs][20]. - -### Class inspector - -When developing in C++, open the right window by clicking on the button in the bottom-right corner of Qt Creator. Then choose **Outline** from the dropdown menu on the top border. If you have a header file open on the left pane, you get a nice overview of the defined classes or types. If you switch to a source file (`*.cpp`), the right pane will list all defined methods, and you can jump to one by double-clicking on it: - -![List of classes in Qt Creator][21] - -(Stephan Avenwedde, [CC BY-SA 4.0][4]) - -### Project configuration - -Qt Creator projects are built around the `*.pro-file` in the project's directory. You can add your own custom configuration to the project's `*.pro-file` of your project. I added `my_special_config` to the `*.pro-file`, which adds `MY_SPECIAL_CONFIG` to the compiler defined: - - -``` -QT -= gui - -CONFIG += c++11 console -CONFIG -= app_bundle - -CONFIG += my_special_config - -my_special_config { -DEFINES += MY_SPECIAL_CONFIG -} -``` - -Qt Creator automatically highlights the code according to the active configuration: - -![Special configuration in Qt Creator][22] - -(Stephan Avenwedde, [CC BY-SA 4.0][4]) - -The `*.pro-file` is written in the [qmake language][23]. - -### Summary - -These features are only the tip of the iceberg of what Qt Creator provides. Beginners shouldn't feel overwhelmed by the many features, as Qt Creator is absolutely beginner-friendly. It may even be the easiest way to start developing in C++. To get a complete overview of its features, refer to the [official Qt Creator documentation][24]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/6/qtcreator - -作者:[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/lenovo-thinkpad-laptop-concentration-focus-windows-office.png?itok=-8E2ihcF (Woman using laptop concentrating) -[2]: https://www.qt.io/product/development-tools -[3]: https://opensource.com/sites/default/files/uploads/qt_creator_dark_mode.png ( QT Creator dark mode) -[4]: https://creativecommons.org/licenses/by-sa/4.0/ -[5]: https://opensource.com/sites/default/files/uploads/qt_creator_custom_stylesheet2.png (QT Creator custom stylesheet) -[6]: https://doc.qt.io/qt-5/stylesheet-reference.html -[7]: https://doc.qt.io/qtcreator/creator-cli.html -[8]: https://doc.qt.io/qt-5/qapplication.html#QApplication -[9]: https://doc.qt.io/qt-5/qguiapplication.html#supported-command-line-options -[10]: https://opensource.com/sites/default/files/uploads/qt_creator_cross_compiling.png (QT Creator kits) -[11]: https://opensource.com/sites/default/files/uploads/qt_creator_select_kits.png (Switching between Kits in Qt Creator) -[12]: https://doc.qt.io/qtcreator/creator-targets.html -[13]: https://doc.qt.io/qtcreator/creator-cpu-usage-analyzer.html -[14]: https://doc.qt.io/qtcreator/creator-valgrind-overview.html -[15]: https://doc.qt.io/qtcreator/creator-clang-tools.html -[16]: https://opensource.com/sites/default/files/uploads/qt_creator_analyzer.png (Qt Creator analyzer) -[17]: https://opensource.com/sites/default/files/uploads/qt_creator_debugger2.png (Qt Creator debugger) -[18]: https://opensource.com/sites/default/files/uploads/qt_creator_fakevim_ex_commands.png (FakeVim in Qt Creator) -[19]: https://opensource.com/sites/default/files/uploads/qt_creator_fakevim_build_commands.png (FakeVim in Qt Creator) -[20]: https://doc.qt.io/qtcreator/creator-editor-fakevim.html -[21]: https://opensource.com/sites/default/files/uploads/qtcreator_class_overview.png (List of classes in Qt Creator) -[22]: https://opensource.com/sites/default/files/uploads/qtcreater_special_config.png (Special configuration in Qt Creator) -[23]: https://doc.qt.io/qt-5/qmake-language.html -[24]: https://doc.qt.io/qtcreator/ diff --git a/sources/tech/20210722 Write your first JavaScript code.md b/sources/tech/20210722 Write your first JavaScript code.md deleted file mode 100644 index d02ca214cd..0000000000 --- a/sources/tech/20210722 Write your first JavaScript code.md +++ /dev/null @@ -1,204 +0,0 @@ -[#]: subject: (Write your first JavaScript code) -[#]: via: (https://opensource.com/article/21/7/javascript-cheat-sheet) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Write your first JavaScript code -====== -JavaScript was created for the web, but it can do so much more. Learn -the basics, then download our cheat sheet so you always have the details -at hand. -![Code with javascript on white background][1] - -JavaScript is a programming language full of pleasant surprises. Many people first encounter JavaScript as a language for the web. There's a JavaScript engine in all the major browsers, there are popular frameworks such as JQuery, Cash, and Bootstrap to help make web design easier, and there are even programming environments written in JavaScript. It seems to be everywhere on the internet, but it turns out that it's also a useful language for projects like [Electron][2], an open source toolkit for building cross-platform desktop apps with JavaScript. - -JavaScript is a surprisingly multipurpose language with a wide assortment of libraries for much more than just making websites. Learning the basics of the language is easy, and it's a gateway to building whatever you imagine. - -### Install JavaScript - -As you progress with JavaScript, you may find yourself wanting advanced JavaScript libraries and runtimes. When you're just starting, though, you don't have to install JavaScript at all. All major web browsers include a JavaScript engine to run the code. You can write JavaScript using your favorite text editor, load it into your web browser, and see what your code does. - -### Get started with JavaScript - -To write your first JavaScript code, open your favorite text editor, such as [Notepad++][3], [Atom][4], or [VSCode][5]. Because it was developed for the web, JavaScript works well with HTML, so first, just try some basic HTML: - - -``` -<[html][6]> -  <[head][7]> -    <[title][8]>JS</[title][8]> -  </[head][7]> -  <[body][9]> -    <[p][10] id="example">Nothing here.</[p][10]> -  </[body][9]> -</[html][6]> -``` - -Save the file, and then open it in a web browser. - -![HTML displayed in browser][11] - -(Seth Kenlon, [CC BY-SA 4.0][12]) - -To add JavaScript to this simple HTML page, you can either create a JavaScript file and refer to it in the page's `head` or just embed your JavaScript code in the HTML using the `