diff --git a/published/20200204 Managing your attached hardware on Linux with systemd-udevd.md b/published/20200204 Managing your attached hardware on Linux with systemd-udevd.md new file mode 100644 index 0000000000..b9fc40090a --- /dev/null +++ b/published/20200204 Managing your attached hardware on Linux with systemd-udevd.md @@ -0,0 +1,146 @@ +[#]: collector: (lujun9972) +[#]: translator: (YungeG) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13691-1.html) +[#]: subject: (Managing your attached hardware on Linux with systemd-udevd) +[#]: via: (https://opensource.com/article/20/2/linux-systemd-udevd) +[#]: author: (David Clinton https://opensource.com/users/dbclinton) + +在 Linux 使用 systemd-udevd 管理你的接入硬件 +====== + +> 使用 udev 管理你的 Linux 系统处理物理设备的方式。 + +![](https://img.linux.net.cn/data/attachment/album/202108/17/104654z1evcdx41xfc4zpq.jpg) + +Linux 能够出色地自动识别、加载、并公开接入的无数厂商的硬件设备。事实上,很多年以前,正是这个特性说服我,坚持让我的雇主将整个基础设施转换到 Linux。痛点在于 Redmond 的某家公司(LCTT 译注:指微软)不能在我们的 Compaq 台式机上加载集成网卡的驱动,而 Linux 可以轻松实现这一点。 + +从那以后的岁月里,Linux 的识别设备库随着该过程的复杂化而与日俱增,而 [udev][2] 就是解决这个问题的希望之星。udev 负责监听 Linux 内核发出的改变设备状态的事件。它可能是一个新 USB 设备被插入或拔出,也可能是一个无线鼠标因浸入洒出的咖啡中而脱机。 + +udev 负责处理所有的状态变更,比如指定访问设备使用的名称和权限。这些更改的记录可以通过 [dmesg][3] 获取。由于 dmesg 的输出通常有几千行,对结果进行过滤通常是聪明的选择。下面的例子说明了 Linux 如何识别我的 WiFi 接口。这个例子展示了我的无线设备使用的芯片组(`ath9k`)、启动过程早期阶段分配的原始名称(`wlan0`)、以及正在使用的又臭又长的永久名称(`wlxec086b1ef0b3`): + +``` +$ dmesg | grep wlan +[    5.396874] ath9k_htc 1-3:1.0 wlxec086b1ef0b3: renamed from wlan0 +``` + +在这篇文章中,我会讨论为何有人想要使用这样的名称。在这个过程中,我会探索剖析 udev 的配置文件,然后展示如何更改 udev 的设置,包括编辑系统命名设备的方式。这篇文件基于我的新课程中《[Linux 系统优化][4]》的一个模块。 + +### 理解 udev 配置系统 + +使用 systemd 的机器上,udev 操作由 `systemd-udevd` 守护进程管理,你可以通过常规的 systemd 方式使用 `systemctl status systemd-udevd` 检查 udev 守护进程的状态。 + +严格来说,udev 的工作方式是试图将它收到的每个系统事件与 `/lib/udev/rules.d/` 和 `/etc/udev/rules.d/` 目录下找到的规则集进行匹配。规则文件包括匹配键和分配键,可用的匹配键包括 `action`、`name` 和 `subsystem`。这意味着如果探测到一个属于某个子系统的、带有特定名称的设备,就会给设备指定一个预设的配置。 + +接着,“分配”键值对被拿来应用想要的配置。例如,你可以给设备分配一个新名称、将其关联到文件系统中的一个符号链接、或者限制为只能由特定的所有者或组访问。这是从我的工作站摘出的一条规则: + +``` +$ cat /lib/udev/rules.d/73-usb-net-by-mac.rules +# Use MAC based names for network interfaces which are directly or indirectly +# on USB and have an universally administered (stable) MAC address (second bit +# is 0). Don't do this when ifnames is disabled via kernel command line or +# customizing/disabling 99-default.link (or previously 80-net-setup-link.rules). + +IMPORT{cmdline}="net.ifnames" +ENV{net.ifnames}=="0", GOTO="usb_net_by_mac_end" + +ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb", NAME=="", \ +    ATTR{address}=="?[014589cd]:*", \ +    TEST!="/etc/udev/rules.d/80-net-setup-link.rules", \ +    TEST!="/etc/systemd/network/99-default.link", \ +    IMPORT{builtin}="net_id", NAME="$env{ID_NET_NAME_MAC}" +``` + +`add` 动作告诉 udev,只要新插入的设备属于网络子系统,*并且*是一个 USB 设备,就执行操作。此外,如果我理解正确的话,只有设备的 MAC 地址由特定范围内的字符组成,并且 `80-net-setup-link.rules` 和 `99-default.link` 文件*不*存在时,规则才会生效。 + +假定所有的条件都满足,接口 ID 会改变以匹配设备的 MAC 地址。还记得之前的 dmesg 信息显示我的接口名称从 `wlan0` 改成了讨厌的 `wlxec086b1ef0b3` 吗?那都是这条规则的功劳。我怎么知道?因为 `ec:08:6b:1e:f0:b3` 是设备的 MAC 地址(不包括冒号)。 + +``` +$ ifconfig -a +wlxec086b1ef0b3: flags=4163  mtu 1500 +        inet 192.168.0.103  netmask 255.255.255.0  broadcast 192.168.0.255 +        inet6 fe80::7484:3120:c6a3:e3d1  prefixlen 64  scopeid 0x20 +        ether ec:08:6b:1e:f0:b3  txqueuelen 1000  (Ethernet) +        RX packets 682098  bytes 714517869 (714.5 MB) +        RX errors 0  dropped 0  overruns 0  frame 0 +        TX packets 472448  bytes 201773965 (201.7 MB) +        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 +``` + +Linux 默认包含这条 udev 规则,我不需要自己写。但是为什么费力进行这样的命名呢——尤其是看到这样的接口命名这么难使用后?仔细看一下包含在规则中的注释: + +> 对直接或间接插入在 USB 上的网络接口使用基于 MAC 的名称,并且用一个普遍提供的(稳定的)MAC 地址(第二位是 0)。当 ifnames 通过内核命令行或 `customizing/disabling 99-default.link`(或之前的 `80-net-setup-link.rules`)被禁用时,不要这样做。 + +注意,这个规则专为基于 USB 的网络接口设计的。和 PCI 网络接口卡(NIC)不同,USB 设备很可能时不时地被移除或者替换,这意味着无法保证它们的 ID 不变。某一天 ID 可能是 `wlan0`,第二天却变成了 `wlan3`。为了避免迷惑应用程序,指定绝对 ID 给设备——就像分配给我的 USB 接口的 ID。 + +### 操作 udev 的设置 + +下一个示例中,我将从 [VirtualBox][5] 虚拟机里抓取以太网接口的 MAC 地址和当前接口 ID,然后用这些信息创建一个改变接口 ID 的 udev 新规则。为什么这么做?也许我打算从命令行操作设备,需要输入那么长的名称让人十分烦恼。下面是工作原理。 + +改变接口 ID 之前,我需要关闭 [Netplan][6] 当前的网络配置,促使 Linux 使用新的配置。下面是 `/etc/netplan/` 目录下我的当前网络接口配置文件: + +``` +$ less /etc/netplan/50-cloud-init.yaml +# This file is generated from information provided by +# the datasource.  Changes to it will not persist across an instance. +# To disable cloud-init's network configuration capabilities, write a file +# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: +# network: {config: disabled} +network: +    ethernets: +        enp0s3: +            addresses: [] +            dhcp4: true +    version: 2 +``` + +`50-cloud-init.yaml` 文件包含一个非常基本的接口定义,但是注释中也包含一些禁用配置的重要信息。为此,我将移动到 `/etc/cloud/cloud.cfg.d` 目录,创建一个名为 `/etc/cloud/cloud.cfg.d` 的新文件,插入 `network: {config: disabled}` 字符串。 + +尽管我只在 Ubuntu 发行版上测试了这个方法,但它应该在任何一个带有 systemd 的 Linux(几乎所有的 Linux 发行版都有 systemd)上都可以工作。不管你使用哪个,都可以很好地了解编写 udev 配置文件并对其进行测试。 + +接下来,我需要收集一些系统信息。执行 `ip` 命令,显示我的以太网接口名为 `enp0s3`,MAC 地址是 `08:00:27:1d:28:10`。 + +``` +$ ip a +2: enp0s3: mtu 1500 qdisc fq_codel state UP group default qlen 1000 +    link/ether 08:00:27:1d:28:10 brd ff:ff:ff:ff:ff:ff +    inet 192.168.0.115/24 brd 192.168.0.255 scope global dynamic enp0s3 +``` + +现在,我要在 `/etc/udev/rules.d` 目录创建一个名为 `peristent-net.rules` 的新文件。我将给文件一个以较小的数字开头的名称,比如 10: + +``` +$ cat /etc/udev/rules.d/10-persistent-network.rules +ACTION=="add", SUBSYSTEM=="net",ATTR{address}=="08:00:27:1d:28:10",NAME="eth3" +``` + +数字越小,Linux 越早执行文件,我想要这个文件早点执行。文件被添加时,包含其中的代码就会分配名称 `eth3` 给网络设备——只要设备的地址能够匹配 `08:00:27:1d:28:10`,即我的接口的 MAC 地址 。 + +保存文件并重启计算机后,我的新接口名应该就会生效。我可能需要直接登录虚拟机,使用 `dhclient` 手动让 Linux 为这个新命名的网络请求一个 IP 地址。在执行下列命令前,可能无法打开 SSH 会话: + +``` +$ sudo dhclient eth3 +``` + +大功告成。现在你能够促使 udev 控制计算机按照你想要的方式指向一个网卡,但更重要的是,你已经有了一些工具,可以弄清楚如何管理任何不听话的设备。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/linux-systemd-udevd + +作者:[David Clinton][a] +选题:[lujun9972][b] +译者:[YungeG](https://github.com/YungeG) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dbclinton +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_BUS_Apple_520.png?itok=ZJu-hBV1 (collection of hardware on blue backround) +[2]: https://en.wikipedia.org/wiki/Udev +[3]: https://en.wikipedia.org/wiki/Dmesg +[4]: https://pluralsight.pxf.io/RqrJb +[5]: https://www.virtualbox.org/ +[6]: https://netplan.io/ diff --git a/published/20210308 How the ARPANET Protocols Worked.md b/published/20210308 How the ARPANET Protocols Worked.md new file mode 100644 index 0000000000..7794a808f4 --- /dev/null +++ b/published/20210308 How the ARPANET Protocols Worked.md @@ -0,0 +1,125 @@ +[#]: subject: (How the ARPANET Protocols Worked) +[#]: via: (https://twobithistory.org/2021/03/08/arpanet-protocols.html) +[#]: author: (Two-Bit History https://twobithistory.org) +[#]: collector: (lujun9972) +[#]: translator: (Lin-vy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13643-1.html) + +ARPANET 协议是如何工作的 +====== + +![](https://img.linux.net.cn/data/attachment/album/202108/03/130239ybmxjmixx3xbx7ix.jpg) + +ARPANET 通过证明可以使用标准化协议连接完全不同的制造商的计算机,永远改变了计算。在我的 [关于 ARPANET 的历史意义的文章][1] 中,我提到了其中的一些协议,但没有详细描述它们。所以我想仔细看看它们。也想看看那些早期协议的设计有多少保留到了我们今天使用的协议中。 + +ARPANET 协议像我们现代的互联网协议,是通过分层形式来组织的。[^1] 较高层协议运行在较低层协议之上。如今的 TCP/IP 套件有 5 层(物理层、链路层、网络层、传输层以及应用层),但是这个 ARPANET 仅有 3 层,也可能是 4 层,这取决于你怎样计算它们。 + +我将会解释每一层是如何工作的,但首先,你需要知道是谁在 ARPANET 中构建了些什么,你需要知道这一点才能理解为什么这些层是这样划分的。 + +### 一些简短的历史背景 + +ARPANET 由美国联邦政府资助,确切的说是位于美国国防部的高级研究计划局Advanced Research Projects Agency(因此被命名为 “ARPANET” )。美国政府并没有直接建设这个网络;而是,把这项工作外包给了位于波士顿的一家名为 “Bolt, Beranek, and Newman” 的咨询公司,通常更多时候被称为 BBN。 + +而 BBN 则承担了实现这个网络的大部分任务,但不是全部。BBN 所做的是设计和维护一种称为接口消息处理机Interface Message Processor(简称为 IMP) 的机器。这个 IMP 是一种定制的霍尼韦尔Honeywell小型机minicomputer,它们被分配给那些想要接入这个 ARPANET 的遍及全国各地的各个站点。它们充当通往 ARPANET 的网关,为每个站点提供多达四台主机的连接支持。它基本上是一台路由器。BBN 控制在 IMP 上运行的软件,把数据包从一个 IMP 转发到另一个 IMP ,但是该公司无法直接控制那些将要连接到 IMP 上并且成为 ARPANET 网络中实际主机的机器。 + +那些主机由网络中作为终端用户的计算机科学家们所控制。这些计算机科学家在全国各地的主机站负责编写软件,使主机之间能够相互通讯。而 IMP 赋予主机之间互相发送消息的能力,但是那并没有多大用处,除非主机之间能商定一种用于消息的格式。为了解决这个问题,一群杂七杂八的人员组成了网络工作组,其中有大部分是来自各个站点的研究生们,该组力求规定主机计算机使用的协议。 + +因此,如果你设想通过 ARPANET 进行一次成功的网络互动,(例如发送一封电子邮件),使这些互动成功的一些工程由一组人负责(BBN),然而其他的一些工程则由另一组人负责(网络工作组和在每个站点的工程师们)。这种组织和后勤方面的偶然性或许对推动采用分层的方法来管理 ARPANET 网络中的协议起到很大的作用,这反过来又影响了 TCP/IP 的分层方式。 + +### 好的,回到协议上来 + +![ARPANET Network Stack][3] + +*ARPANET 协议层次结构* + +这些协议层被组织成一个层次结构,在最底部是 “Level 0”。[^2] 这在某种意义上是不算数的,因为在 ARPANET 中这层完全由 BBN 控制,所以不需要标准协议。Level 0 的作用是管理数据在 IMP 之间如何传输。在 BBN 内部,有管理 IMP 如何做到这一点的规则;在 BBN 之外,IMP 子网是一个黑匣子,它只会传送你提供的任意数据。因此,Level 0 是一个没有真正协议的层,就公开已知和商定的规则集而言,它的存在可以被运行在 ARPANET 的主机上的软件忽略。粗略地说,它处理相当于当今使用的 TCP/IP 套件的物理层、链路层和网络层下的所有内容,甚至还包括相当多的传输层,这是我将在这篇文章的末尾回来讨论的内容。 + +“Level 1” 层在 ARPANET 的主机和它们所连接的 IMP 之间建立了接口。如果你愿意,可以认为它是为 BBN 构建的 “Level 0” 层的黑匣子使用的一个应用程序接口(API)。当时它也被称为 IMP-Host 协议。必须编写该协议并公布出来,因为在首次建立 ARPANET 网络时,每个主机站点都必须编写自己的软件来与 IMP 连接。除非 BBN 给他们一些指导,否则他们不会知道如何做到这一点。 + +BBN 在一份名为 [BBN Report 1822][5] 的冗长文件中规定了 IMP-Host 协议。随着 ARPANET 的发展,该文件多次被修订;我将在这里大致描述 IMP-Host 协议最初设计时的工作方式。根据 BBN 的规则,主机可以将长度不超过 8095 位的消息传递给它们的 IMP,并且每条消息都有一个包含目标主机号和链路识别号的头部字段。[^3] IMP 将检查指定的主机号,然后尽职尽责地将消息转发到网络中。当从远端主机接收到消息时,接收的 IMP 在将消息传递给本地主机之前会把目标主机号替换为源主机号。实际上在 IMP 之间传递的内容并不是消息 —— IMP 将消息分解成更小的数据包以便通过网络传输 —— 但该细节对主机来说是不可见的。 + +![1969 Host-IMP Leader][7] + +*Host-IMP 消息头部格式,截至 1969。 图表来自 [BBN Report 1763][8]* + +链路号的取值范围为 0 到 255 ,它有两个作用。一是更高级别的协议可以利用它在网络上的任何两台主机之间建立多个通信信道,因为可以想象得到,在任何时刻都有可能存在多个本地用户与同一个目标主机进行通信的场景(换句话说,链路号允许在主机之间进行多路通信)。二是它也被用在 “Level 1” 层去控制主机之间发送的大量流量,以防止高性能计算机压制低性能计算机的情况出现。按照最初的设计,这个 IMP-Host 协议限制每台主机在某一时刻通过某条链路仅发送一条消息。一旦某台主机沿着某条链路发送了一条消息给远端主机后,在它沿着该链路发送下一条消息之前,必须等待接收一条来自远端的 IMP 的特别类型的消息,叫做 RFNM(请求下一条消息Request for Next Message)。后来为了提高性能,对该系统进行了修订,允许一台主机在给定的时刻传送多达 8 条消息给另一台主机。[^4] + +“Level 2” 层才是事情真正开始变得有趣的地方,因为这一层和在它上面的那一层由 BBN 和国防部全部留给学者们和网络工作组自己去研发。“Level 2” 层包括了 Host-Host 协议,这个协议最初在 RFC9 中草拟,并且在 RFC54 中首次正式规定。在 [ARPANET 协议手册][10] 中有更易读的 Host-Host 协议的解释。 + +“Host-Host 协议” 管理主机之间如何创建和管理连接。“连接”是某个主机上的写套接字和另一个主机上的读套接字之间的一个单向的数据管道。“套接字socket” 的概念是在 “Level-1” 层的有限的链路设施(记住,链路号只能是那 256 个值中的一个)之上被引入的,是为了给程序提供寻址运行在远端主机上的特定进程的一种方式。“读套接字” 是用偶数表示的,而“写套接字”是用奇数表示的;套接字是 “读” 还是 “写” 被称为套接字的 “性别”。并没有类似于 TCP 协议那样的 “端口号” 机制,连接的打开、维持以及关闭操作是通过主机之间使用 “链路 0” 发送指定格式的 Host-Host 控制消息来实现的,这也是 “链路 0” 被保留的目的。一旦在 “链路 0” 上交换控制消息来建立起一个连接后,就可以使用接收端挑选的另一个链路号来发送进一步的数据消息。 + +Host-Host 控制消息一般通过 3 个字母的助记符来表示。当两个主机交换一条 STR(发送端到接收端sender-to-receiver)消息和一条配对的 RTS(接收端到发送端receiver-to-sender)消息后,就建立起了一条连接 —— 这些控制消息都被称为请求链接消息。链接能够被 CLS(关闭close)控制消息关闭。还有更多的控制信息能够改变从发送端到接收端发送消息的速率。从而再次需要确保较快的主机不会压制较慢的主机。在 “Level 1” 层上的协议提供了流量控制的功能,但对 “Level 2” 层来说显然是不够的;我怀疑这是因为从远端 IMP 接收到的 RFNM 只能保证远端 IMP 已经传送该消息到目标主机,而不能保证目标主机已经全部处理了该消息。还有 INR(接收端中断interrupt-by-receiver)、INS(发送端中断interrupt-by-sender)控制消息,主要供更高级别的协议使用。 + +更高级别的协议都位于 “Level 3”,这层是 ARPANET 的应用层。Telnet 协议,它提供到另一台主机的一个虚拟电传链接,其可能是这些协议中最重要的。但在这层中也有许多其他协议,例如用于传输文件的 FTP 协议和各种用于发送 Email 的协议实验。 + +在这一层中有一个不同于其他的协议:初始链接协议Initial Connection Protocol(ICP)。ICP 被认为是一个 “Level-3” 层协议,但实际上它是一种 “Level-2.5” 层协议,因为其他 “Level-3” 层协议都依赖它。之所以需要 ICP,是因为 “Level 2” 层的 Host-Host 协议提供的链接只是单向的,但大多数的应用需要一个双向(例如:全双工)的连接来做任何有趣的事情。要使得运行在某个主机上的客户端能够连接到另一个主机上的长期运行的服务进程,ICP 定义了两个步骤。第一步是建立一个从服务端到客户端的单向连接,通过使用服务端进程的众所周知的套接字号来实现。第二步服务端通过建立的这个连接发送一个新的套接字套接字号给客户端。到那时,那个存在的连接就会被丢弃,然后会打开另外两个新的连接,它们是基于传输的套接字号建立的“读”连接和基于传输的套接字号加 1 的“写”连接。这个小插曲是大多数事务的一个前提——比如它是建立 Telnet 链接的第一步。 + +以上是我们逐层攀登了 ARPANET 协议层次结构。你们可能一直期待我在某个时候提一下 “网络控制协议Network Control Protocol”(NCP) 。在我坐下来为这篇文章和上一篇文章做研究之前,我肯定认为 ARPANET 运行在一个叫 “NCP” 的协议之上。这个缩写有时用来指代整个 ARPANET 协议,这可能就是我为什么有这个想法的原因。举个例子,[RFC801][11] 讨论了将 ARPANET 从 “NCP” 过渡到 “TCP” 的方式,这使 NCP 听起来像是一个相当于 TCP 的 ARPANET 协议。但是对于 ARPANET 来说,从来都没有一个叫 “网络控制协议” 的东西(即使 [大英百科全书是这样认为的][12]),我怀疑人们错误地将 “NCP” 解释为 “网络控制协议Network Control Protocol” ,而实际上它代表的是 “网络控制程序Network Control Program” 。网络控制程序是一个运行在各个主机上的内核级别的程序,主要负责处理网络通信,等同于现如今操作系统中的 TCP/IP 协议栈。用在 RFC 801 的 “NCP” 是一种转喻,而不是协议。 + +### 与 TCP/IP 的比较 + +ARPANET 协议以后都会被 TCP/IP 协议替换(但 Telnet 和 FTP 协议除外,因为它们很容易就能在 TCP 上适配运行)。然而 ARPANET 协议都基于这么一个假设:就是网络是由一个单一实体(BBN)来构建和管理的。而 TCP/IP 协议套件是为网间网设计的,这是一个网络的网络,在那里一切都是不稳定的和不可靠的。这就导致了我们的现代协议套件和 ARPANET 协议有明显的不同,比如我们现在怎样区分网络层和传输层。在 ARPANET 中部分由 IMP 实现的类似传输层的功能现在完全由在网络边界的主机负责。 + +我发现 ARPANET 协议最有趣的事情是,现在在 TCP 中的许多传输层的功能是如何在 ARPANET 上经历了一个糟糕的青春期。我不是网络专家,因此我拿出大学时的网络课本(让我们跟着 Kurose 和 Ross 学习一下),他们对传输层通常负责什么给出了一个非常好的概述。总结一下他们的解释,一个传输层协议必须至少做到以下几点。这里的 “segment” 基本等同于 ARPANET 上的术语 “消息message”: + + * 提供进程之间的传送服务,而不仅仅是主机之间的(传输层多路复用和多路分解) + * 在每个段的基础上提供完整性检查(即确保传输过程中没有数据损坏) + +像 TCP 那样,传输层也能够提供可靠的数据传输,这意味着: + + * “段” 是按顺序被传送的 + * 不会丢失任何 “段” + * “段” 的传送速度不会太快以至于被接收端丢弃(流量控制) + +似乎在 ARPANET 上关于如何进行多路复用和多路分解以便进程可以通信存在一些混淆 —— BBN 在 IMP-Host 层引入了链路号来做到这一点,但结果证明在 Host-Host 层上无论如何套接字号都是必要的。然后链路号只是用于 IMP-Host 级别的流量控制,但 BBN 似乎后来放弃了它,转而支持在唯一的主机对之间进行流量控制,这意味着链路号一开始是一个超载的东西,后来基本上变成了虚设。TCP 现在使用端口号代替,分别对每一个 TCP 连接单独进行流量控制。进程间的多路复用和多路分解完全在 TCP 内部进行,不会像 ARPANET 一样泄露到较低层去。 + +同样有趣的是,鉴于 Kurose 和 Ross 如何开发 TCP 背后的想法,ARPANET 一开始就采用了 Kurose 和 Ross 所说的一个严谨的 “停止并等待stop-and-wait” 方法,来实现 IMP-Host 层上的可靠的数据传输。这个 “停止并等待” 方法发送一个 “段” 然后就拒绝再去发送更多 “段” ,直到收到一个最近发送的 “段” 的确认为止。这是一种简单的方法,但这意味着只有一个 “段” 在整个网络中运行,从而导致协议非常缓慢 —— 这就是为什么 Kurose 和 Ross 将 “停止并等待” 仅仅作为在通往功能齐全的传输层协议的路上的垫脚石的原因。曾有一段时间 “停止并等待” 是 ARPANET 上的工作方式,因为在 IMP–Host 层,必须接收到请求下一条消息Request for Next Message(RFNM)以响应每条发出的消息,然后才能发送任何进一步的消息。客观的说 ,BBN 起初认为这对于提供主机之间的流量控制是必要的,因此减速是故意的。正如我已经提到的,为了更好的性能,RFNM 的要求后来放宽松了,而且 IMP 也开始向消息中添加序列号和保持对传输中的消息的 “窗口” 的跟踪,这或多或少与如今 TCP 的实现如出一辙。[^5] + +因此,ARPANET 表明,如果你能让每个人都遵守一些基本规则,异构计算系统之间的通信是可能的。正如我先前所说的,这是 ARPANET 的最重要的遗产。但是,我希望对这些基线规则的仔细研究揭示了 ARPANET 协议对我们今天使用的协议有多大影响。在主机和 IMP 之间分担传输层职责的方式上肯定有很多笨拙之处,有时候是冗余的。现在回想起来真的很可笑,主机之间一开始只能通过给出的任意链路在某刻只发送一条消息。但是 ARPANET 实验是一个独特的机会,可以通过实际构建和操作网络来学习这些经验,当到了是时候升级到我们今天所知的互联网时,似乎这些经验变得很有用。 + +_如果你喜欢这篇贴子,更喜欢每四周发布一次的方式!那么在 Twitter 上关注 [@TwoBitHistory][14] 或者订阅 [RSS 提要][15],以确保你知道新帖子的发布时间。_ + +[^1]: 协议分层是网络工作组发明的。这个论点是在 [RFC 871][17] 中提出的。分层也是 BBN 如何在主机和 IMP 之间划分职责的自然延伸,因此 BBN 也值得称赞。 +[^2]: “level” 是被网络工作组使用的术语。 详见 [RFC 100][19] +[^3]: 在 IMP-Host 协议的后续版本中,扩展了头部字段,并且将链路号升级为消息 ID。但是 Host-Host 协议仅仅继续使用消息 ID 字段的高位 8 位,并将其视为链路号。请参阅 [ARPANET 协议手册][10] 的 “Host-Host” 协议部分。 +[^4]: John M. McQuillan 和 David C. Walden。 “ARPA 网络设计决策”,第 284页,。 2021 年 3 月 8 日查看。 +[^5]: 同上。 + +-------------------------------------------------------------------------------- + +via: https://twobithistory.org/2021/03/08/arpanet-protocols.html + +作者:[Two-Bit History][a] +选题:[lujun9972][b] +译者:[Lin-vy](https://github.com/Lin-vy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://twobithistory.org +[b]: https://github.com/lujun9972 +[1]: https://twobithistory.org/2021/02/07/arpanet.html +[2]: tmp.szauPoOKtk#fn:1 +[3]: https://twobithistory.org/images/arpanet-stack.png +[4]: tmp.szauPoOKtk#fn:2 +[5]: https://walden-family.com/impcode/BBN1822_Jan1976.pdf +[6]: tmp.szauPoOKtk#fn:3 +[7]: https://twobithistory.org/images/host-imp-1969.png +[8]: https://walden-family.com/impcode/1969-initial-IMP-design.pdf +[9]: tmp.szauPoOKtk#fn:4 +[10]: http://mercury.lcs.mit.edu/~jnc/tech/arpaprot.html +[11]: https://tools.ietf.org/html/rfc801 +[12]: https://www.britannica.com/topic/ARPANET +[13]: tmp.szauPoOKtk#fn:5 +[14]: https://twitter.com/TwoBitHistory +[15]: https://twobithistory.org/feed.xml +[16]: https://twitter.com/TwoBitHistory/status/1358487195905064960?ref_src=twsrc%5Etfw +[17]: https://tools.ietf.org/html/rfc871 +[18]: tmp.szauPoOKtk#fnref:1 +[19]: https://www.rfc-editor.org/info/rfc100 +[20]: tmp.szauPoOKtk#fnref:2 +[21]: tmp.szauPoOKtk#fnref:3 +[22]: tmp.szauPoOKtk#fnref:4 +[23]: tmp.szauPoOKtk#fnref:5 diff --git a/published/20210414 3 essential Linux cheat sheets for productivity.md b/published/20210414 3 essential Linux cheat sheets for productivity.md new file mode 100644 index 0000000000..410855472e --- /dev/null +++ b/published/20210414 3 essential Linux cheat sheets for productivity.md @@ -0,0 +1,120 @@ +[#]: subject: "3 essential Linux cheat sheets for productivity" +[#]: via: "https://opensource.com/article/21/4/linux-cheat-sheets" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lujun9972" +[#]: translator: "YungeG" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13662-1.html" + +3 个提高生产力的必备 Linux 速查表 +====== + +> 下载 `sed`、`grep` 和 `parted` 的速查表来整合新的流程到你的工作中。 + +![](https://img.linux.net.cn/data/attachment/album/202108/09/121350vvha4adg77b77j7c.jpg) + +Linux 因其命令闻名,部分原因是 Linux 执行的几乎所有操作都可以从终端调用;另一部分原因是 Linux 是一个高度模块化的操作系统,它的工具被设计用于产生十分确定的结果,在非常了解一些命令后,你可以将这些命令进行奇妙的组合,产生有用的输出。Linux 的学习过程一半是学习命令,另一半是学习如何将这些命令连成有意思的组合。 + +然而有这么多 Linux 命令需要学习,迈出第一步似乎令人望而生畏。应该先学习哪一个命令?有那些命令需要熟练掌握,又有哪些命令只需要浅尝辄止?认真考虑过这些问题后,我个人不相信有一个通用的答案。对所有人来说,“基本”命令很可能是相同的: + + * `ls` + * `cd` + * `mv` + +有这些命令你就可以浏览自己的 Linux 文件系统。 + +但是,除了基本命令,不同行业的“默认”命令有所不同。系统管理员需要 [系统自我检查和监测][2] 的工具;艺术家需要 [媒体转换][3] 和 [图形处理][4] 工具;家庭用户可能想要 [PDF 处理][5]、[日历][6]、[文档转换][7] 工具。这份列表无穷无尽。 + +然而一些 Linux 命令由于极其重要能够脱颖而出 —— 或者因为这些命令是每个人不时需要的常用的底层工具,或者因为这些命令是每个人在大多数时间都会觉得有用的万能工具。 + +这里有三个需要添加到你的列表中的命令。 + +### Sed + +**用途:** `sed` 是一个任何 Linux 用户都可以从学习中获益的优良通用工具。从表面上看,它只是一个基于终端的“查找和替换”,能够简单快速地纠正多个文档。`sed` 命令为我节省了打开单个文件、寻找和替换一个单词、保存文件、关闭文件所需要的数个小时(也可能是数天)时间,仅此一条命令就证明了我在学习 Linux 终端的投入是合理的。一旦充分了解 `sed`,你很有可能发现一个使生活更加轻松的潜在编辑技巧世界。 + +**长处:** 命令的长处在于重复。如果你只有一个要编辑的文件,很容易在传统的 [文本编辑器][8]打开并进行“查找和替换”。然而,如果要替换 5 或 50 个文件,恰当地使用 `sed` 命令(可能结合 [GNU Parallel][9] 进行加速)可以帮你节省数个小时。 + +**不足:** 你需要权衡直接更改期望所花的时间和构建正确的 `sed` 命令可能需要的时间。使用常见的 `sed 's/foo/bar/g'` 语法所做的简单编辑通常值得上输入这些命令所花的时间;但是利用保持空间和任何 `ed` 形式子命令的复杂 `sed` 命令可能需要高度集中的注意力和多次的试错。事实证明,使用 `sed` 进行编辑通常是更好的方式。 + +**秘技:** 下载我们的 [sed 速查表][10] 获取命令的单字母子命令和语法概述的快速参考。 + +### Grep + +**用途:** `grep` 一词来源于其公认的笨拙描述:全局正则表达式打印。换言之,在文件中(或者其他形式的输入中)找到的任何匹配模式,`grep` 都会打印到终端。这使得 `grep` 成为一个强大的搜索工具,尤其擅长处理大量的文本。 + +你可以使用 `grep` 查找 URL: + +``` +$ grep --only-matching \ + http\:\/\/.* example.txt +``` + +你可以使用 `grep` 查找一个特定的配置项: + +``` +$ grep --line-number \ + foo= example.ini +2:foo=true +``` + +当然,你还可以将 `grep` 和其他命令组合: + +``` +$ grep foo= example.ini | cut -d= -f2 +true +``` + +**长处:** `grep` 是一个简单的搜索命令,如果你阅读了上面的例子,就已经基本有所了解。为了增强灵活性,你可以使用命令的扩展正则表达式语法。 + +**不足:** `grep` 的问题也是它的长处:它只有搜索功能。一旦你找到想要的内容,可能会面临一个更大的问题 —— 如何处理找到的内容。有时进行的处理可能简单如重定向输出到一个文件,作为过滤后的结果列表。但是,更复杂的使用场景可能需要对结果做进一步处理,或者使用许多类似 [awk][11]、[curl][12](凑巧的是,我们也有 [curl 速查表][13])的命令,或者使用现代计算机上你所拥有的数千个其他选项中的任何一个命令。 + +**秘技:** 下载我们的 [grep 速查表][14] 获取更多命令选项和正则表达式语法的快速参考。 + +### Parted + +**用途:** GNU `parted` 不是一个常用命令,但它是最强大的硬盘操作工具之一。关于硬盘驱动器的沮丧事实是 —— 数年来你一直忽略它们,直到需要设置一个新的硬盘时,才会想起自己对于格式化驱动器的最好方式一无所知,而此时熟悉 `parted` 会十分有用。GNU `parted` 能够创建磁盘卷标,新建、备份、恢复分区。此外,你可以通过命令获取驱动器及其布局的许多信息,并为文件系统初始化驱动器。 + +**长处:** 我偏爱 `parted` 而不是 `fdisk` 等类似工具的原因在于它组合了简单的交互模式和完全的非交互选项。不管你如何使用 `parted`,它的命令符合相同的语法,其编写良好的帮助菜单包含了丰富的信息。更棒的是,命令本身是 _智能_ 的 —— 给一个驱动器分区时,你可以用扇区和百分比指明分区的大小,`parted` 会尽可能计算出更精细的位置存放分区表。 + +**不足:** 在很长一段时间内我不清楚驱动器的工作原理,因此切换到 Linux 后,我花费了很长时间学习 GNU `parted`。GNU `parted` 和大多数终端磁盘工具假定你已经知晓什么是一个分区、驱动器由扇区组成、初始时驱动器缺少文件系统,需要磁盘卷标和分区表等等知识。硬盘驱动器的基础而不是命令本身的学习曲线十分陡峭,而 GNU `parted` 并没有做太多的努力来弥补潜在的认知差距。可以说,带你完成磁盘驱动器的基础知识学习不是命令的职责,因为有类似的 [图形应用][15],但是一个聚焦于工作流程的选项对于 GNU `parted` 可能是一个有用的附加功能。 + +**秘技:** 下载我们的 [parted 速查表][16] 获取大量子命令和选项的快速参考。 + +### 了解更多 + +这是一些我最喜欢的命令列表,但是其中的命令自然取决于我如何使用自己的计算机。我编写很多命令解释器脚本,因此频繁地使用 `grep` 查找配置选项,通过 `sed` 编辑文本。我还会用到 `parted`,因为处理多媒体项目时,通常涉及很多硬盘驱动器。你可能已经开发了,或者很快就要使用最喜欢的(至少是 _频繁使用的_)命令开发自己的工作流程。 + +整合新的流程到日常工作时,我会创建或者下载一个速查表(就像上面的链接),然后进行练习。我们都有自己的学习方式,找出最适合你的方式,学习一个新的必需命令。你对最常使用的命令了解越多,你就越能充分地使用它们。 + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/4/linux-cheat-sheets + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[YungeG](https://github.com/YungeG) +校对:[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/yearbook-haff-rx-linux-file-lead_0.png?itok=-i0NNfDC "Hand putting a Linux file folder into a drawer" +[2]: https://opensource.com/life/16/2/open-source-tools-system-monitoring +[3]: https://opensource.com/article/17/6/ffmpeg-convert-media-file-formats +[4]: https://opensource.com/article/17/8/imagemagick +[5]: https://opensource.com/article/20/8/reduce-pdf +[6]: https://opensource.com/article/19/4/calendar-git +[7]: https://opensource.com/article/20/5/pandoc-cheat-sheet +[8]: https://opensource.com/article/21/2/open-source-text-editors +[9]: https://opensource.com/article/18/5/gnu-parallel +[10]: https://opensource.com/downloads/sed-cheat-sheet +[11]: https://opensource.com/article/20/9/awk-ebook +[12]: https://www.redhat.com/sysadmin/social-media-curl +[13]: https://opensource.com/article/20/5/curl-cheat-sheet +[14]: https://opensource.com/downloads/grep-cheat-sheet +[15]: https://opensource.com/article/18/11/partition-format-drive-linux#gui +[16]: https://opensource.com/downloads/parted-cheat-sheet diff --git a/published/20210525 Pen testing with Linux security tools.md b/published/20210525 Pen testing with Linux security tools.md new file mode 100644 index 0000000000..4f1ece54a8 --- /dev/null +++ b/published/20210525 Pen testing with Linux security tools.md @@ -0,0 +1,283 @@ +[#]: subject: "Pen testing with Linux security tools" +[#]: via: "https://opensource.com/article/21/5/linux-security-tools" +[#]: author: "Peter Gervase https://opensource.com/users/pgervase" +[#]: collector: "lujun9972" +[#]: translator: "MjSeven" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13650-1.html" + +使用 Linux 安全工具进行渗透测试 +====== + +> 使用 Kali Linux 和其他开源工具来发现系统中的安全漏洞和弱点。 + +![](https://img.linux.net.cn/data/attachment/album/202108/05/111124w66lpuzsc467nlv1.jpg) + +众多被广泛报道的大型消费企业入侵事件凸显了系统安全管理的重要性。幸运的是,有许多不同的应用程序可以帮助保护计算机系统。其中一个是 [Kali][2],一个为安全和渗透测试而开发的 Linux 发行版。本文演示了如何使用 Kali Linux 来审视你的系统以发现弱点。 + +Kali 安装了很多工具,它们都是开源的,默认情况下安装了它们会让事情变得更容易。 + +(LCTT 译注:Kali 及其携带工具只应该用于对自己拥有合法审查权利的系统和设备,任何未经授权的扫描、渗透和攻击均是违法的。本文作者、译者均不承担任何非授权使用的结果。) + +![Kali's tools][3] + +本文使用的系统是: + + 1. `kali.usersts.redhat.com`:这是我将用来启动扫描和攻击的系统。它拥有 30GB 内存和 6 个虚拟 CPU(vCPU)。 + 2. `vulnerable.usersys.redhat.com`: 这是一个 Red Hat 企业版 Linux 8 系统,它会成为目标。它拥有 16GB 内存和 6 个 vCPU。它是一个相对较新的系统,但有些软件包可能已经过时。 + 3. 这个系统包括 `httpd-2.4.37-30.module+el8.3.0+7001+0766b9e7.x86_64`、 `mariadb-server-10.3.27-3.module+el8.3.0+8972+5e3224e9.x86_64`、 `tigervnc-server-1.9.0-15.el8_1.x86_64`、 `vsftpd-3.0.3-32.el8.x86_64` 和一个 5.6.1 版本的 WordPress。 + +我在上面列出了硬件规格,因为一些任务要求很高,尤其是在运行 WordPress 安全扫描程序([WPScan][5])时对目标系统 CPU 的要求。 + +### 探测你的系统 + +首先,我会在目标系统上进行基本的 Nmap 扫描(你可以阅读 [使用 Nmap 结果帮助加固 Linux 系统][6] 一文来更深入地了解 Nmap)。Nmap 扫描是一种快速的方法,可以大致了解被测系统中哪些端口和服务是暴露的。 + +![Nmap scan][7] + +默认扫描显示有几个你可能感兴趣的开放端口。实际上,任何开放端口都可能成为攻击者破坏你网络的一种方式。在本例中,端口 21、22、80 和 443 是不错的扫描对象,因为它们是常用服务的端口。在这个早期阶段,我只是在做侦察工作,尽可能多地获取有关目标系统的信息。 + +我想用 Nmap 侦察 80 端口,所以我使用 `-p 80` 参数来查看端口 80,`-A` 参数来获取操作系统和应用程序版本等信息。 + +![Nmap scan of port 80][8] + +关键信息有: + +``` +PORT   STATE SERVICE VERSION +80/tcp open  http       Apache httpd 2.4.37 ((Red Hat Enterprise Linux)) +|_http-generator: WordPress 5.6.1 +``` + +现在我知道了这是一个 WordPress 服务器,我可以使用 WPScan 来获取有关潜在威胁的信息。一个很好的侦察方法是尝试找到一些用户名,使用 `--enumerate u` 告诉 WPScan 在 WordPress 实例中查找用户名。例如: + +``` +┌──(root💀kali)-[~] +└─# wpscan --url vulnerable.usersys.redhat.com --enumerate u +_______________________________________________________________ + __ _______ _____ + \ \ / / __ \ / ____| + \ \ /\ / /| |__) | (___ ___ __ _ _ __ ® + \ \/ \/ / | ___/ \___ \ / __|/ _` | '_ \ + \ /\ / | | ____) | (__| (_| | | | | + \/ \/ |_| |_____/ \___|\__,_|_| |_| + + WordPress Security Scanner by the WPScan Team + Version 3.8.10 + Sponsored by Automattic - https://automattic.com/ + @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart +_______________________________________________________________ + +[+] URL: http://vulnerable.usersys.redhat.com/ [10.19.47.242] +[+] Started: Tue Feb 16 21:38:49 2021 + +Interesting Finding(s): +... +[i] User(s) Identified: + +[+] admin + | Found By: Author Posts - Display Name (Passive Detection) + | Confirmed By: + | Author Id Brute Forcing - Author Pattern (Aggressive Detection) + | Login Error Messages (Aggressive Detection) + +[+] pgervase + | Found By: Author Posts - Display Name (Passive Detection) + | Confirmed By: + | Author Id Brute Forcing - Author Pattern (Aggressive Detection) + | Login Error Messages (Aggressive Detection) +``` + +这显示有两个用户:`admin` 和 `pgervase`。我将尝试使用密码字典来猜测 `admin` 的密码。密码字典是一个包含很多密码的文本文件。我使用的字典大小有 37G,有 3,543,076,137 行。 + +就像你可以选择不同的文本编辑器、Web 浏览器和其他应用程序 一样,也有很多工具可以启动密码攻击。下面是两个使用 Nmap 和 WPScan 的示例命令: + +``` +# nmap -sV --script http-wordpress-brute --script-args userdb=users.txt,passdb=/path/to/passworddb,threads=6 vulnerable.usersys.redhat.com +``` + +``` +# wpscan --url vulnerable.usersys.redhat.com --passwords /path/to/passworddb --usernames admin --max-threads 50 | tee nmap.txt +``` + +这个 Nmap 脚本是我使用的许多脚本之一,使用 WPScan 扫描 URL 只是这个工具可以完成的许多任务之一。你可以用你喜欢的那一个。 + +WPScan 示例在文件末尾显示了密码: + +``` +┌──(root💀kali)-[~] +└─# wpscan --url vulnerable.usersys.redhat.com --passwords passwords.txt --usernames admin +_______________________________________________________________ + __ _______ _____ + \ \ / / __ \ / ____| + \ \ /\ / /| |__) | (___ ___ __ _ _ __ ® + \ \/ \/ / | ___/ \___ \ / __|/ _` | '_ \ + \ /\ / | | ____) | (__| (_| | | | | + \/ \/ |_| |_____/ \___|\__,_|_| |_| + + WordPress Security Scanner by the WPScan Team + Version 3.8.10 + Sponsored by Automattic - https://automattic.com/ + @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart +_______________________________________________________________ + +[+] URL: http://vulnerable.usersys.redhat.com/ [10.19.47.242] +[+] Started: Thu Feb 18 20:32:13 2021 + +Interesting Finding(s): + +...... + +[+] Performing password attack on Wp Login against 1 user/s +Trying admin / redhat Time: 00:01:57 <==================================================================================================================> (3231 / 3231) 100.00% Time: 00:01:57 +Trying admin / redhat Time: 00:01:57 <========================================================= > (3231 / 6462) 50.00% ETA: ??:??:?? +[SUCCESS] - admin / redhat + +[!] Valid Combinations Found: + | Username: admin, Password: redhat + +[!] No WPVulnDB API Token given, as a result vulnerability data has not been output. +[!] You can get a free API token with 50 daily requests by registering at https://wpscan.com/register + +[+] Finished: Thu Feb 18 20:34:15 2021 +[+] Requests Done: 3255 +[+] Cached Requests: 34 +[+] Data Sent: 1.066 MB +[+] Data Received: 24.513 MB +[+] Memory used: 264.023 MB +[+] Elapsed time: 00:02:02 +``` + +在末尾的“找到有效组合”部分包含了管理员用户名和密码,3231 行只用了两分钟。 + +我还有另一个字典文件,其中包含 3,238,659,984 行,使用它花费的时间更长并且会留下更多的证据。 + +使用 Nmap 可以更快地产生结果: + +``` +┌──(root💀kali)-[~] +└─# nmap -sV --script http-wordpress-brute --script-args userdb=users.txt,passdb=password.txt,threads=6 vulnerable.usersys.redhat.com +Starting Nmap 7.91 ( https://nmap.org ) at 2021-02-18 20:48 EST +Nmap scan report for vulnerable.usersys.redhat.com (10.19.47.242) +Host is up (0.00015s latency). +Not shown: 995 closed ports +PORT STATE SERVICE VERSION +21/tcp open ftp vsftpd 3.0.3 +22/tcp open ssh OpenSSH 8.0 (protocol 2.0) +80/tcp open http Apache httpd 2.4.37 ((Red Hat Enterprise Linux)) +|_http-server-header: Apache/2.4.37 (Red Hat Enterprise Linux) +| http-wordpress-brute: +| Accounts: +| admin:redhat - Valid credentials <<<<<<< +| pgervase:redhat - Valid credentials <<<<<<< +|_ Statistics: Performed 6 guesses in 1 seconds, average tps: 6.0 +111/tcp open rpcbind 2-4 (RPC #100000) +| rpcinfo: +| program version port/proto service +| 100000 2,3,4 111/tcp rpcbind +| 100000 2,3,4 111/udp rpcbind +| 100000 3,4 111/tcp6 rpcbind +|_ 100000 3,4 111/udp6 rpcbind +3306/tcp open mysql MySQL 5.5.5-10.3.27-MariaDB +MAC Address: 52:54:00:8C:A1:C0 (QEMU virtual NIC) +Service Info: OS: Unix + +Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . +Nmap done: 1 IP address (1 host up) scanned in 7.68 seconds +``` + +然而,运行这样的扫描可能会在目标系统上留下大量的 HTTPD 日志消息: + +``` +10.19.47.170 - - [18/Feb/2021:20:14:01 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "http://vulnerable.usersys.redhat.com/" "WPScan v3.8.10 (https://wpscan.org/)" +10.19.47.170 - - [18/Feb/2021:20:14:00 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "http://vulnerable.usersys.redhat.com/" "WPScan v3.8.10 (https://wpscan.org/)" +10.19.47.170 - - [18/Feb/2021:20:14:00 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "http://vulnerable.usersys.redhat.com/" "WPScan v3.8.10 (https://wpscan.org/)" +10.19.47.170 - - [18/Feb/2021:20:14:00 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "http://vulnerable.usersys.redhat.com/" "WPScan v3.8.10 (https://wpscan.org/)" +10.19.47.170 - - [18/Feb/2021:20:14:00 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "http://vulnerable.usersys.redhat.com/" "WPScan v3.8.10 (https://wpscan.org/)" +10.19.47.170 - - [18/Feb/2021:20:14:00 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "http://vulnerable.usersys.redhat.com/" "WPScan v3.8.10 (https://wpscan.org/)" +10.19.47.170 - - [18/Feb/2021:20:14:02 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "http://vulnerable.usersys.redhat.com/" "WPScan v3.8.10 (https://wpscan.org/)" +10.19.47.170 - - [18/Feb/2021:20:14:02 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "http://vulnerable.usersys.redhat.com/" "WPScan v3.8.10 (https://wpscan.org/)" +10.19.47.170 - - [18/Feb/2021:20:14:02 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "http://vulnerable.usersys.redhat.com/" "WPScan v3.8.10 (https://wpscan.org/)" + +``` + +为了获得关于在最初的 Nmap 扫描中发现的 HTTPS 服务器的信息,我使用了 `sslscan` 命令: + +``` +┌──(root💀kali)-[~] +└─# sslscan vulnerable.usersys.redhat.com +Version: 2.0.6-static +OpenSSL 1.1.1i-dev xx XXX xxxx + +Connected to 10.19.47.242 + +Testing SSL server vulnerable.usersys.redhat.com on port 443 using SNI name vulnerable.usersys.redhat.com + + SSL/TLS Protocols: +SSLv2 disabled +SSLv3 disabled +TLSv1.0 disabled +TLSv1.1 disabled +TLSv1.2 enabled +TLSv1.3 enabled + +``` + +它显示了有关启用的 SSL 协议的信息,在最下方,是关于 Heartbleed 漏洞的信息: + +``` +  Heartbleed: +TLSv1.3 not vulnerable to heartbleed +TLSv1.2 not vulnerable to heartbleed +``` + +### 防御或减轻攻击的技巧 + +有很多方法可以保护你的系统免受大量攻击。几个关键点是: + + * **了解你的系统:**包括了解哪些端口是开放的,哪些端口应该开放,谁应该能够看到这些开放的端口,以及使用这些端口服务的预期流量是多少。Nmap 是了解网络系统的一个绝佳工具。 + * **使用当前的最佳实践:** 现在的最佳实践可能不是未来的最佳实践。作为管理员,了解信息安全领域的最新趋势非常重要。 + * **知道如何使用你的产品:** 例如,与其让攻击者不断攻击你的 WordPress 系统,不如阻止他们的 IP 地址并限制尝试登录的次数。在现实世界中,阻止 IP 地址可能没有那么有用,因为攻击者可能会使用受感染的系统来发起攻击。但是,这是一个很容易启用的设置,可以阻止一些攻击。 + * **维护和验证良好的备份:** 如果攻击者攻击了一个或多个系统,能从已知的良好和干净的备份中重新构建可以节省大量时间和金钱。 + * **检查日志:** 如上所示,扫描和渗透命令可能会留下大量日志,这表明攻击者正在攻击系统。如果你注意到它们,可以采取先发制人的行动来降低风险。 + * **更新系统、应用程序和任何额外的模块:** 正如 [NIST Special Publication 800-40r3][9] 所解释的那样,“补丁通常是减轻软件缺陷漏洞最有效的方法,而且通常是唯一完全有效的解决方案。” + * **使用供应商提供的工具:** 供应商有不同的工具来帮助你维护他们的系统,因此一定要充分利用它们。例如,红帽企业 Linux 订阅中包含的 [Red Hat Insights][10] 可以帮助你优化系统并提醒你注意潜在的安全威胁。 + +### 了解更多 + +本文对安全工具及其使用方法的介绍只是冰山一角。深入了解的话,你可能需要查看以下资源: + + * [Armitage][11],一个开源的攻击管理工具 + * [Red Hat 产品安全中心][12] + * [Red Hat 安全频道][13] + * [NIST 网络安全页面][14] + * [使用 Nmap 结果来帮助加固 Linux 系统][6] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/5/linux-security-tools + +作者:[Peter Gervase][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/pgervase +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0 "Magnifying glass on code" +[2]: https://www.kali.org/ +[3]: https://opensource.com/sites/default/files/uploads/kali-tools.png "Kali's tools" +[4]: https://creativecommons.org/licenses/by-sa/4.0/ +[5]: https://wpscan.com/wordpress-security-scanner +[6]: https://www.redhat.com/sysadmin/using-nmap-harden-systems +[7]: https://opensource.com/sites/default/files/uploads/nmap-scan.png "Nmap scan" +[8]: https://opensource.com/sites/default/files/uploads/nmap-port80.png "Nmap scan of port 80" +[9]: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-40r3.pdf +[10]: https://www.redhat.com/sysadmin/how-red-hat-insights +[11]: https://en.wikipedia.org/wiki/Armitage_(computing) +[12]: https://access.redhat.com/security +[13]: https://www.redhat.com/en/blog/channel/security +[14]: https://www.nist.gov/cybersecurity \ No newline at end of file diff --git a/translated/tech/20200108 6 requirements of cloud-native software.md b/published/202106/20200108 6 requirements of cloud-native software.md similarity index 63% rename from translated/tech/20200108 6 requirements of cloud-native software.md rename to published/202106/20200108 6 requirements of cloud-native software.md index 3e31a7d0dd..e2848eb214 100644 --- a/translated/tech/20200108 6 requirements of cloud-native software.md +++ b/published/202106/20200108 6 requirements of cloud-native software.md @@ -1,28 +1,29 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13497-1.html) [#]: subject: (6 requirements of cloud-native software) [#]: via: (https://opensource.com/article/20/1/cloud-native-software) [#]: author: (Daniel Oh https://opensource.com/users/daniel-oh) 云原生软件的 6 个要求 ====== -开发和实施云原生(容器优先)软件的检查清单。 -![Team checklist][1] -许多年来,单体应用是实现业务需求的标准企业架构。但是,当云基础设施开始以规模和速度为业务加速,这种情况就发生了重大变化。应用架构也发生了转变,以适应云原生应用和[微服务][2]、[无服务器][3]以及事件驱动的服务,这些服务在跨混合云和多云平台的不可变的基础设施上运行。 +> 开发和实施云原生(容器优先)软件的检查清单。 + +![](https://img.linux.net.cn/data/attachment/album/202106/18/101348dcjg3u7wugo5uouw.jpg) + +许多年来,单体应用是实现业务需求的标准企业架构。但是,当云基础设施开始以规模和速度为业务加速,这种情况就发生了重大变化。应用架构也发生了转变,以适应云原生应用和 [微服务][2]、[无服务器][3] 以及事件驱动的服务,这些服务运行在跨混合云和多云平台的不可变的基础设施上。 ### 云原生与 Kubernetes 的联系 -根据[云原生计算基金会][4] (CNCF) 的说法: +根据 [云原生计算基金会][4] (CNCF) 的说法: > “云原生技术使企业能够在现代动态环境中建立和运行可扩展的应用,如公共云、私有云和混合云。容器、服务网格、微服务、不可变的基础设施和声明式 API 就是这种方法的典范。” > > “这些技术使松散耦合的系统具有弹性、可管理和可观察性。与强大的自动化相结合,它们使工程师能够以最小的工作量频繁地、可预测地进行重要的改变。” - 像 [Kubernetes][5] 这样的容器编排平台允许 DevOps 团队建立不可变的基础设施,以开发、部署和管理应用服务。现在,快速迭代的速度与业务需求相一致。构建容器以在 Kubernetes 中运行的开发人员需要一个有效的地方来完成。 ### 云原生软件的要求 @@ -31,14 +32,12 @@ 虽然构建和架构云原生应用的方法有很多,但以下是一些需要考虑的部分: - * **运行时:**它们更可能以容器优先或/和 Kubernetes 原生语言编写,这意味着运行时会如 Java、Node.js、Go、Python 和 Ruby。 - * **安全:**在多云或混合云应用环境中部署和维护应用时,安全是最重要的,应该是环境的一部分。 - * **可观察性:**使用 Prometheus、Grafana 和 Kiali 等工具,这些工具可以通过提供实时指标和有关应用在云中的使用和行为的更多信息来增强可观察性。 - * **效率:**专注于极小的内存占用、小的构件大小和快速启动时间,使应用可跨混合/多云平台移植。 - * **互操作性:**将云原生应用与能够满足上述要求的开源技术相结合,包括 Infinispan、MicroProfile、Hibernate、Kafka、Jaeger、Prometheus 等,以构建标准运行时架构。 - * **DevOps/DevSecOps:**这些方法论是为持续部署到生产而设计的,与最小可行产品 (MVP) 一致,并将安全作为工具的一部分。 - - + * **运行时:** 它们更多是以容器优先或/和 Kubernetes 原生语言编写的,这意味着运行时会如 Java、Node.js、Go、Python 和 Ruby。 + * **安全:** 在多云或混合云应用环境中部署和维护应用时,安全是最重要的,应该是环境的一部分。 + * **可观察性:** 使用 Prometheus、Grafana 和 Kiali 等工具,这些工具可以通过提供实时指标和有关应用在云中的使用和行为的更多信息来增强可观察性。 + * **效率:** 专注于极小的内存占用、更小的构件大小和快速启动时间,使应用可跨混合/多云平台移植。 + * **互操作性:** 将云原生应用与能够满足上述要求的开源技术相结合,包括 Infinispan、MicroProfile、Hibernate、Kafka、Jaeger、Prometheus 等,以构建标准运行时架构。 + * **DevOps/DevSecOps:** 这些方法论是为持续部署到生产而设计的,与最小可行产品 (MVP) 一致,并将安全作为工具的一部分。 ### 让云原生具体化 @@ -53,7 +52,7 @@ via: https://opensource.com/article/20/1/cloud-native-software 作者:[Daniel Oh][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/202106/20200206 How key Python projects are maintained.md b/published/202106/20200206 How key Python projects are maintained.md new file mode 100644 index 0000000000..6fd2a1952c --- /dev/null +++ b/published/202106/20200206 How key Python projects are maintained.md @@ -0,0 +1,92 @@ +[#]: collector: (lujun9972) +[#]: translator: (stevenzdg988) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13526-1.html) +[#]: subject: (How key Python projects are maintained) +[#]: via: (https://opensource.com/article/20/2/python-maintained) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +如何维护关键的 Python 项目 +====== + +> 一窥开源 Python 项目保持平稳运行的社区幕后。 + +![](https://img.linux.net.cn/data/attachment/album/202106/27/130401uu3l1nkq1padn1gn.jpg) + +Jannis Leidel 是 [Jazzband][2] 社区的一部分。Jazzband 是一个协作社区,共同承担维护基于 [Python][3] 的项目。 + +Jazzband 的诞生源于长期独自维护一个开源项目的压力。Jannis 是“roadie”,这意味着他负责管理任务并确保团队中的人可以在他们想要的时候参与。 + +Jazzband 并不是他的第一个开源志愿者工作——他是前 [Django][4] 核心开发人员,[Django 软件基金会][5] 董事会成员,编写了许多 Django 应用程序和 Python 项目,曾是 [pip][6] 和 [virtualenv][7] 核心开发人员和发布经理,共同创立了 [Python 打包机构][8]Python Packaging Authority,还担任过 [PyPI][9] 管理员。在社区方面,他共同创立了德国 Django 协会,担任 [DjangoCon Europe][10] 2010 联合主席,在多个会议上发言,并在去年担任了 [Python 软件基金会][11] 董事和联席主席。 + +### Moshe Zadka: 你是如何开始编程的? + +Jannis Leidel:我开始接触编程是在高中的常规德国计算机科学课程中,在那里我涉猎了 Turbo Pascal 和 Prolog。我很快就进入了 Web 开发的世界,并使用 PHP3、[Perl5][12] 和 [MySQL][13] 编写了一些小型网站。后来在大学里,我在从事媒体艺术项目时再次学习了编程,发现 [Ruby][14]、Perl 和 Python 特别有用。我最终坚持使用 Python,因为它的多功能性和易用性。从那时起,我很高兴能够在我的职业生涯中使用 Python 和开放 Web 技术(HTML/JS/CSS)。 + +### Zadka: 你是如何开始接触开源的? + +Leidel:作为大学艺术项目的一部分,我需要一种与各种 Web 服务对话并与一些电子设备交互的方法,但发现我之前的 PHP 技能无法胜任这项任务。因此,我参加了有关使用 Python 编程的课程,相比库,我对学习更多有关框架如何工作更感兴趣,因为它们进一步体现了我想了解的最佳实践。特别是,新生的 Django Web 框架对我很有吸引力,因为它倾向于一种务实的方法,并为如何开发 Web 应用程序提供了大量指导。 2007 年,我作为学生参与了 Google Summer of Code for Django,后来为 Django 及其可重用组件生态系统做出了更多贡献,不久我也成为了 Django 核心开发人员。在完成学位期间,我能够利用这些技能成为一名自由职业者,并花时间在 Django 社区的许多不同部分工作。在那时,横向移动到更广泛的 Python 社区不过是很自然的。 + +### Zadka: 你的日常工作是什么? + +Leidel:我是 Mozilla 的一名软件工程师,致力于为 Firefox 数据管道开发数据工具。实际上,这意味着我在更广泛的 Firefox 工程团队中工作,从事各种内部和面向公众的基于 Web 的项目,这些项目帮助 Mozilla 员工和社区成员理解 Firefox Web 浏览器发送的遥测数据。我目前的部分重点是维护我们的数据分析和可视化平台,该平台基于开源项目 [Redash][15],并对其做出贡献。我参与的其他项目是我们的下一代遥测系统 [Glean][16] 和一个允许你在浏览器(包括 Scientific Python 堆栈)中进行数据科学的工具 [Iodide][17]。 + +### Zadka: 你是如何参与 Jazzband 的? + +Leidel:早在 2015 年,我就对单独维护很多人所依赖的项目感到沮丧,并看到我的许多社区同行都在为类似的问题苦苦挣扎。我不知道有什么好方法可以让社区中更多的人对长期维护感兴趣。在某些情况下,我觉得新的“社会编码”范式的社会性的不足,而且常常是孤立的,有时甚至对新老贡献者来说都是创伤。我相信在我们的社区中,我现在觉得无法容忍的不平等现象在当时更加猖獗,这使得为贡献者提供一个安全的环境变得困难——我们现在知道这对于稳定的项目维护至关重要。我想知道我们是否缺少一种更具协作性和包容性的软件开发方法。 + +Jazzband 项目的启动是为了降低进入维护的门槛,并简化其中一些较无聊的方面(例如,围绕 [CI][18] 的最佳实践)。 + +### Zadka: 你最喜欢 Jazzband 的哪一点? + +Leidel:我最喜欢 Jazzband 的一点是,我们确保了许多人所依赖的许多项目的维护,同时还确保任何经验水平的新贡献者都可以加入。 + +### Zadka: Jazzband 的“roadie”的工作是什么? + +Leidel:“roadie”是指处理 Jazzband 幕后所有事务的人。这意味着,例如,处理新项目的进入、维护 Jazzband 网站以处理用户管理和项目发布、充当安全或行为准则事件的第一响应者等等。“roadie”这个词是从音乐和演出行业借来的,指的是支持人员,他们负责在巡回演出中几乎所有需要做的事情,除了实际的艺术表演。在 Jazzband,他们的存在是为了确保成员可以在项目中工作。这也意味着,在有意义的情况下,某些任务是部分或完全自动化的,并且最佳实践被应用于大多数 Jazzband 项目,如打包设置、文档托管或持续集成。 + +### Zadka: 作为 Jazzband 的“roadie”,你工作中最具挑战性的方面是什么? + +Leidel:目前,我作为“roadie”的工作中最具挑战性的方面是实施社区成员提出的 Jazzband 改进,而不影响他们所依赖的工作流程。换句话说,Jazzband 越大,在概念级别上扩展项目变得越困难。具有讽刺意味的是,我是目前唯一的“roadie”,独自处理一些任务,而 Jazzband 却试图阻止其项目发生这种情况。这是 Jazzband 未来的一大担忧。 + +### Zadka: 对于有兴趣想知道能否加入 Jazzband 的人,你有什么想说的? + +Leidel:如果你有兴趣加入一群相信协作工作比单独工作更好的人,或者如果你一直在为自己的维护负担而苦苦挣扎,并且不知道如何继续,请考虑加入 Jazzband。它简化了新贡献者的进入流程,提供了一个争议解决框架,并自动发布到 [PyPI][19]。有许多最佳实践可以很好地降低项目无人维护的风险。 + +### Zadka: 你还有什么想告诉我们的读者的吗? + +Leidel:我鼓励每个从事开源项目的人都考虑屏幕另一边的人。要有同理心,记住你自己的经历可能不是你同龄人的经历。要明白你是全球多元化社区的成员,这要求我们始终尊重我们之间的差异。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/python-maintained + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[stevenzdg988](https://github.com/stevenzdg988) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/migration_innovation_computer_software.png?itok=VCFLtd0q (and old computer and a new computer, representing migration to new software or hardware) +[2]: https://jazzband.co/ +[3]: https://opensource.com/resources/python +[4]: https://opensource.com/article/18/8/django-framework +[5]: https://www.djangoproject.com/foundation/ +[6]: https://opensource.com/article/19/11/python-pip-cheat-sheet +[7]: https://virtualenv.pypa.io/en/latest/ +[8]: https://www.pypa.io/en/latest/ +[9]: https://pypi.org/ +[10]: https://djangocon.eu/ +[11]: https://www.python.org/psf/ +[12]: http://opensource.com/article/18/1/why-i-love-perl-5 +[13]: https://opensource.com/life/16/10/all-things-open-interview-dave-stokes +[14]: http://opensource.com/business/16/4/save-development-time-and-effort-ruby +[15]: https://redash.io/ +[16]: https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/start/report-gecko-telemetry-in-glean.html +[17]: https://alpha.iodide.io/ +[18]: https://opensource.com/article/19/12/cicd-resources +[19]: https://opensource.com/downloads/7-essential-pypi-libraries diff --git a/published/202106/20200228 4 technologists on careers in tech for minorities.md b/published/202106/20200228 4 technologists on careers in tech for minorities.md new file mode 100644 index 0000000000..34ffe23bcd --- /dev/null +++ b/published/202106/20200228 4 technologists on careers in tech for minorities.md @@ -0,0 +1,125 @@ +[#]: collector: (lujun9972) +[#]: translator: (M4Xrun) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13480-1.html) +[#]: subject: (4 technologists on careers in tech for minorities) +[#]: via: (https://opensource.com/article/20/2/careers-tech-minorities) +[#]: author: (Shilla Saebi https://opensource.com/users/shillasaebi) + +4 位技术专家谈少数族群的技术职业 +====== + +> 了解 BHM 对他们意味着什么,什么影响了他们的职业生涯,为想要进入科技领域的少数族群提供资源,等等。 + +![Team meeting][1] + +为了纪念 BHM,我收集了一些我最喜欢的技术专家和开源贡献者的意见。这四位正在为下一代铺路,同时也在为他们在科技行业所做的工作铺路。了解 BHM 对他们意味着什么,是什么影响了他们的职业生涯,为想要进入科技领域的少数族群提供资源,等等。 + +**[Tameika Reed][2],Women In Linux 创始人** + +自 Women In Linux 发起以来,Tameika 一直致力于探索基础设施、网络安全、DevOps 和物联网领域的职业生涯,并致力于领导力和持续技能的培养。作为一个自学成才的系统管理员,Tameika 相信学习技术的最好方法就是深入其中。为了给女性一个全面的角度来看技术,Tameika 每周都会举办一次线上会议来探讨 Hyperledger、Kubernetes、微服务和高性能计算等 Linux 常规之外的技术。Tameika 的职业生涯包括与 OSCon、LISA 2018、Seagl、HashiCorp EU 2019 不同的会议以及各种当地活动进行会议发言。 + +**[Michael Scott Winslow][3],Comcast 公司核心应用与平台总监** + +“我是一个父亲、丈夫、兄弟、儿子。我出生在一个小家庭,所以我很乐于把朋友们变成一个大家庭。当我把我的名字附在某件事上时,我就非常希望它能成功,所以我很在意我参与的事情。噢,在我的职业生涯中我已经做了数十年的软件开发。我解决问题,和别人合作一起帮助解决大问题,我带领、引导和指导年轻的软件工程师的同时观察我想要学习的人。” + +**[Bryan Liles][4],VMware 资深工程师** + +“我正在和我们的团队一起重新思考开发人员如何与 Kubernetes 进行交互。当我不工作的时候,我就制造机器人和在社区里努力激励下一代的软件工程师。” + +**[Mutale Nkonde][5],AI For the People(AFP)首席执行官** + +AFP 是一家非营利性的创意机构。在创办非营利组织之前,Nkonde 从事人工智能治理工作。在此期间,她是向美国众议院提出《算法和深度伪造算法法案》以及《无生物识别障碍住房法案》的团队成员之一。Nkonde 的职业生涯中最开始是做广播记者,曾在英国广播公司(BBC)、美国有线电视新闻网(CNN)和美国广播公司(ABC)工作。她还广泛从事种族和科技方面的写作,并在哈佛大学和斯坦福大学获得奖学金。 + +### 是什么影响了你选择技术领域的职业? + +当我回到大学的时候,我害怕电脑。我害怕电脑是因为我从大学辍学了。之后我又回去了,我就把尽我所能学习作为自己的任务。这是我至今的座右铭,学习永不停止。— Tameika Reed + +我不会拐弯抹角,我小时候是个极客!在我 10 岁的时候,我就从印刷杂志上读到的代码开始每天写 GW-BASIC。在我上高中的时候,我给了自己一点喘息的时间来享受生活,但是当到了为大学选择专业的时候,这是一个很容易做出的选择。我留在了科技行业,这得感谢我一路走来遇到的了不起的导师和同事。— Michael Scott Winslow + +我从中学就开始写软件了。我喜欢告诉电脑去做事情并看到结果。长大后,我很快就意识到,拥有一份让我满意、收入高的工作才是正确的选择。— Bryan Liles + +我想知道为什么科技公司雇佣的黑人女性这么少。 — Mutale Nkonde + +### 在开源技术领域有没有某个特别的人给了你启发? + +我从很多其他人和项目中得到启发。比如我喜欢看到其他人来到 [Women In Linux][6],并确定他们想去哪里。我试着让人们从更全面的角度来看科技,这样他们就可以决定自己喜欢什么。说自己想在科技行业工作很容易,但要入手并坚持下去很难。你不必仅仅是一个程序员,你也可以成为一个云计算架构师。— Tameika Reed + +[Kelsey Hightower][7]、[Bryan Liles][4] 和 Kim Scott 激励了我。他们是如此真实!他们说的都是我每天的感受和经历。做好你的工作!别抱怨了!承认你的行为,并明白你是如何促成你的处境的![Gene Kim][8] 也给了我很大的启发。作为 DevOps 运动的领导者,我看到自己在追随和模仿他做的很多事情。 — Michael Scott Winslow + +不,我没有看到我想要的灵感,所以我努力成为 20 年前那个给我启发的人。 — Bryan Liles + +太多了!我最喜欢的一个是:[Dorothy Vaughan][9],她是美国第一个为 IBM 沃森电脑编程的人。她的故事被记录在电影《Hidden Figures》中。 — Mutale Nkonde + +### 你有什么特别的资源可以推荐给那些想要加入科技行业的少数人吗? + +有,我建议你在 Twitter 上交一些朋友,然后提问。以下是我在科技界关注和欣赏的一些人: — Tameika Reed + + * [@techgirl1908][10] + * [@bryanl][4] + * [@kelseyhightower][7] + * [@kstewart][11] + * [@tiffani][12] + * [@EricaJoy][13] + * [@womeninlinux][6] + * [@ArlanWasHere][14] + * [@blkintechnology][15] + * [@digundiv][16] + +受重视的新人训练营确实缩短了人们加入科技行业的时间。我遇到过几位经过培训的专业人士,他们都比 4 年制学校的同行更出色。我认为我们可以真正开始尊重人们创造的成果,而不是技术的熟练。 — Michael Scott Winslow + +我不确定我能推荐什么具体的东西。科技是一个很大的整体,所以没有一个简单的答案。我的建议是选择你认为会感兴趣的东西,并努力成为这个方面的专家。从问为什么开始,而不是怎么做,并且开始理解事物是如何一起运作的。 — Bryan Liles + +这取决于他们想做什么工作。对于那些在科技和社会公正的交汇处工作的人,我推荐 Safiya Noble 的《[Algorithms of Oppression][17]》一书。 —Mutale Nkonde + +### 你对有色人种将科技作为他们的职业有什么建议? + +我建议你学习自己的技能。你将是一个永远的学习者。总会有人或事挡在你的路上,你的反应和行动将取决于你自己。永远不要拒绝第一个提议,要知道自己的价值。我看技术就像看艺术一样。发展需要时间,所以要对自己有耐心,拔掉插头说不也没关系。 — Tameika Reed + +作为一个有点像行业保护者一样的人,我不想要不适合技术的人。所以要真正判断自己是否适合科技。你是一个能解决问题的人吗?你是否理性多于感性?你是否经常发现自己在创造过程?如果是这样,无论你的背景如何,我认为你都可以在科技行业找到一个家。— Michael Scott Winslow + +事情不会那么简单。你的进步会因为你的族群而减慢。你必须更努力工作。把逆境当作动力。你要比周围的人准备的更充分,这样当机会出现时你就能够应对它。找一个与你相似的人的网络,私下发泄不满,公开展示实力。你属于这里,你就能成功。 — Bryan Liles + +除了为一家公司工作,也在发展公共利益技术领域,我们的工作中心是技术如何影响真实的人。许多领导这项工作的人是有色人种妇女,黑人妇女正在取得巨大的进步。— Mutale Nkonde + +### BHM 对你来说意味着什么? + +意味着永不停止,为你永远不会忘记。 —Tameika Reed + +BHM 对我来说意味着关注塔斯克基飞行队而不是奴隶制。强调我们如何为历史做出贡献,而不是如何成为历史的受害者。我希望人们理解我们的骄傲来自哪里,而不是我们的愤怒。在我们的人民身上发生了很多非常糟糕的事情,但我们还站在这里。坚强!— Michael Scott Winslow + +BHM 是一个反思被遗忘的美国黑人历史的日子。我把它当作是感谢我的祖先所做的牺牲的时刻。— Bryan Liles + +这是一个集中体现全球黑人所作贡献的时刻。我喜欢它,这是我一年中最喜欢的时间之一。 — Mutale Nkonde + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/careers-tech-minorities + +作者:[Shilla Saebi][a] +选题:[lujun9972][b] +译者:[M4Xrun](https://github.com/M4Xrun) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/shillasaebi +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/meeting-team-listen-communicate.png?itok=KEBP6vZ_ (Team meeting) +[2]: https://www.linkedin.com/in/tameika-reed-1a7290128/ +[3]: https://twitter.com/michaelswinslow +[4]: https://twitter.com/bryanl +[5]: https://twitter.com/mutalenkonde +[6]: https://twitter.com/WomenInLinux +[7]: https://twitter.com/kelseyhightower +[8]: https://twitter.com/RealGeneKim +[9]: https://en.wikipedia.org/wiki/Dorothy_Vaughan +[10]: https://twitter.com/techgirl1908 +[11]: https://twitter.com/kstewart +[12]: https://twitter.com/tiffani +[13]: https://twitter.com/EricaJoy +[14]: https://twitter.com/ArlanWasHere +[15]: https://twitter.com/blkintechnology +[16]: https://twitter.com/digundiv +[17]: http://algorithmsofoppression.com/ diff --git a/published/20200511 Start using systemd as a troubleshooting tool.md b/published/202106/20200511 Start using systemd as a troubleshooting tool.md similarity index 100% rename from published/20200511 Start using systemd as a troubleshooting tool.md rename to published/202106/20200511 Start using systemd as a troubleshooting tool.md diff --git a/published/202106/20200731 Why we open sourced our Python platform.md b/published/202106/20200731 Why we open sourced our Python platform.md new file mode 100644 index 0000000000..75e6c2cb59 --- /dev/null +++ b/published/202106/20200731 Why we open sourced our Python platform.md @@ -0,0 +1,102 @@ +[#]: collector: "lujun9972" +[#]: translator: "zepoch" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13533-1.html" +[#]: subject: "Why we open sourced our Python platform" +[#]: via: "https://opensource.com/article/20/7/why-open-source" +[#]: author: "Meredydd Luff https://opensource.com/users/meredydd-luff" + +为什么我们要开源我们的 Python 平台 +====== + +> 开源开发的理念使得 Anvil 的整个解决方案更加有用且值得信赖。 + +![](https://img.linux.net.cn/data/attachment/album/202106/29/041151fpvlz4a75ihlr0lv.jpg) + +Anvil 团队最近开源了 [Anvil App Server][2], 一个用于托管完全用 Python 构建的 Web 程序的运行时引擎。 + +社区的反应十分积极,我们 Anvil 团队已经将许多反馈纳入了我们的 [下一个版本][3]。但是我们不断被问到的问题是,“为什么你们选择开源这个产品的核心呢?” + +### 我们为何创造 Anvil + +[Anvil][4] 是一个可以使得构建 Web 应用更加简单的工具。我们让你们有能力仅使用一种语言—— Python —— 就可以来构建你的整个应用。 + +在 Anvil 之前,如果你想要构建一个 Web app,你需要写很多代码,用很多的技术,比如 HTML、Javascript、CSS、Python、SQL、React、Redux、Bootstrap、Sass、Webpack 等。这需要花费很长时间来学习。对于一个简单的应用便是这样子;相信我,一般的应用其实 [更加复杂][5]。 + +![A complex framework of development tools needed for a simple web app][6] + +*是的。对于一个简单的 web 应用便是需要如此多的技术。* + +但即使如此,你还没有完成!你需要了解有关 Git 和云托管提供商的所有信息、如何保护(很有可能是)Linux 操作系统、如何调整数据库,然后随时待命以保持其运行。一直如此。 + +因此,我们开发出了 Anvil,这是一个在线 IDE,你可以在用 [拖放编辑器][7] 来设计你的 UI 界面,用 Python 编写你的 [逻辑][8],然后 Anvil 会负责其余的工作。我们将所有的繁杂的技术栈进行了替换,只用 Python 就行啦! + +### 简单的 Web 托管很重要,但还不够 + +Anvil 还可以为你托管你的应用程序。为什么不呢?部署 Web 应用程序非常复杂,因此运行我们自己的云托管服务是提供我们所需的简单性的唯一方法。在 Anvil 编辑器中构建一个应用程序,[单击按钮][9],它就在网上发布了。 + +但我们不断听到有人说,“那太好了,但是……” + + * “我需要在没有可靠互联网接入的海外平台上运行这个应用。” + * “我想要将我的应用程序嵌入到我售出的 IoT 设备中” + * "如果我把我的宝都压到你的 Anvil 上,我怎么能确定十年后我的应用仍然能够运行呢?” + +这些都是很好的观点!云服务并不是适合所有人的解决方案。如果我们想为这些用户提供服务,就必须有一些方法让他们把自己的应用从 Anvil 中取出来,在本地运行,由他们自己完全控制。 + +### 开源是一个逃生舱,而不是弹射座椅 + +在会议上,我们有时会被问到,“我可以将它导出为 Flask+JS 的应用程序吗?” 当然,我们可以将 Anvil 项目分别导出为 Python 和 JavaScript —— 我们可以生成一个服务器包,将客户端中的 Python 编译为 Javascript,然后生成一个经典的 Web 应用程序。但它会有严重的缺点,因为:**代码生成是一个弹射座椅。** + +![Code generation is an ejector seat from a structured platform][10] + +生成的代码聊胜于无;至少你可以编辑它!但是在你编辑该代码的那一刻,你就失去了生成它的系统的所有好处。如果你使用 Anvil 是因为它的 [拖放编辑器][12] 和 [运行在浏览器中的 Python][13],那么你为什么必须使用 vim 和 Javascript 才能在本地托管你的应用程序? + +我们相信 [逃生舱,而不是弹射座椅][14]。所以我们选择了一个正确的方式——我们 [开源了 Anvil 的运行引擎][2],这与在我们的托管服务中为你的应用程序提供服务的代码相同。这是一个独立的应用程序;你可以使用文本编辑器编辑代码并在本地运行。但是你也可以将它直接用 `git` 推回到我们的在线 IDE。这不是弹射座椅;没有爆炸性的转变。这是一个逃生舱;你可以爬出来,做你需要做的事情,然后再爬回来。 + +### 如果它开源了,它还可靠吗 + +开源中的一个看似矛盾的是,它的免费可用性是它的优势,但有时也会产生不稳定的感觉。毕竟,如果你不收费,你如何保持这个平台的长期健康运行? + +我们正在做我们一直在做的事情 —— 提供一个开发工具,使构建 Web 应用程序变得非常简单,尽管你使用 Anvil 构建的应用程序 100% 是你的。我们为 Anvil 应用程序提供托管,并为 [企业客户][15] 提供整个现场开发和托管平台。这使我们能够提供免费计划,以便每个人都可以将 Anvil 用于业余爱好或教育目的,或者开始构建某些东西并查看它的发展。 + +### 得到的多,失去的少 + +开源我们的运行引擎并没有减少我们的业务 —— 它使我们的在线 IDE 在今天和未来变得更有用、更值得信赖。我们为需要它的人开放了 Anvil App Server 的源代码,并提供最终的安全保障。对于我们的用户来说,这是正确的举措 —— 现在他们可以放心地进行构建,因为他们知道开源代码 [就在那里][3],如果他们需要的话。 + +如果我们的开发理念与你产生共鸣,何不亲自尝试 Anvil? + +----- + +这篇文章改编自 [Why We Open Sourced the Anvil App Server][16],经许可重复使用。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/7/why-open-source + +作者:[Meredydd Luff][a] +选题:[lujun9972][b] +译者:[zepoch](https://github.com/zepoch) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/meredydd-luff +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUS_OSwhy_520x292_ma.png?itok=lqfhAs8L "neon sign with head outline and open source why spelled out" +[2]: https://anvil.works/blog/open-source +[3]: https://github.com/anvil-works/anvil-runtime +[4]: https://anvil.works/ +[5]: https://github.com/kamranahmedse/developer-roadmap#introduction +[6]: https://opensource.com/sites/default/files/uploads/frameworks.png "A complex framework of development tools needed for a simple web app" +[7]: https://anvil.works/docs/client/ui +[8]: https://anvil.works/docs/client/python +[9]: https://anvil.works/docs/deployment +[10]: https://opensource.com/sites/default/files/uploads/ejector-seat-opensourcecom.jpg "Code generation is an ejector seat from a structured platform" +[11]: https://commons.wikimedia.org/wiki/File:Crash.arp.600pix.jpg +[12]: https://anvil.works/docs/editor +[13]: https://anvil.works/docs/client +[14]: https://anvil.works/blog/escape-hatches-and-ejector-seats +[15]: https://anvil.works/docs/overview/enterprise +[16]: https://anvil.works/blog/why-open-source + diff --git a/published/202106/20200930 FCC auctions should be a long-term boost for 5G availability.md b/published/202106/20200930 FCC auctions should be a long-term boost for 5G availability.md new file mode 100644 index 0000000000..c51a38e7d9 --- /dev/null +++ b/published/202106/20200930 FCC auctions should be a long-term boost for 5G availability.md @@ -0,0 +1,75 @@ +[#]: collector: (lujun9972) +[#]: translator: (littlebirdnest) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13525-1.html) +[#]: subject: (FCC auctions should be a long-term boost for 5G availability) +[#]: via: (https://www.networkworld.com/article/3584072/fcc-auctions-should-be-a-long-term-boost-for-5g-availability.html) +[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) + +FCC 的频谱拍卖是对 5G 普及的长期助推 +====== + +> FCC 制定新政策是为了让更多的频谱能够被用于通信以此来创造新的服务。 + +![FCC][1] + +随着 5G 的发展,为了完全实现它的服务,显然需要更多的频谱来,FCC 显然对此当成重中之重。 + +FCC 近日完成了有关公民宽带无线电服务Citizen’s Broadband Radio Service(CBRS)的 5G 频谱的[拍卖][8],这些频谱是位于 3.5GHz 频段中的 70MHz 新带宽。它拍卖了 45.8 个亿,是近几年为无线传输释放更多频道的拍卖会之一。FCC 在 2011、2014 和 2015 年在中低频段(大致在 1.7GHz 至 2.2GHz)和 700MHz 上拍卖了 65MHz。 + +当前频谱可操作的范围是低于 6GHz 频段或是中频段的频谱,与 [CBRS][9] 拍卖中出售的频谱处于同一区域。据专家称,即将举行的 C 频段拍卖将会是重要一环,将会有高达 280 MHz 频谱被拍卖。 + +IDC 的研究主管 Jasom leigh 说,“C 频段的拍卖将带来大笔资金。……美国的中频段频谱是稀缺的,这就是为什么你会看到这种巨大的紧迫性。” + +虽然几大主要移动运营商仍有望抢到这次拍卖中的大部分可用的许可证,但频谱的一些最具创新性的用途将由企业实施,所以将会与运营商竞争一系列可用的频段。 + +[物联网][11]、资产追踪以及其他私人网络应用的专用网络早已可以通过私人 LTE 实现,但由于 5G 技术先进的频谱共享、低延迟和多连接的特性,它的成熟大大拓宽了它们的范围。广义上讲,能替代更多当前需要连线的应用,如工业自动化、设备管理等等。 + +### 重新分配频谱就意味着谈判 + +对于想要改变美国的频谱优先事项上的问题并不是小事,FCC 前主席 Tom Wheeler 对此绝对深有体会,过去 10 年里,美国政府一直在推动重新分配频段,而持有频段者的大多是政府机构或者是卫星网络运营商。 + +Wheeler 说,这些利益相关者必须被分配到不同频段,通常以纳税人出资补偿,而让各个相关方参与分享和进行分享经常是一个复杂的过程。 + + +他指出,“FCC 现在面临的挑战之一是,频谱的分配是根据假定使用模拟信号做出的,而这些假定由于数字技术而被改写”。就像电视从模拟电视转变成数字电视。当模拟电视占用了 6MHz 频段,并需要两侧的保护带以避免干扰时,数字信号却能够在一个频段里容纳四到五个信号。 + +事实证明,这些假定是很难面对的。反对者公开反对 FCC 在中频段的动作,认为这样做没有足够的预防措施来避免对他们原有的设备和服务的干扰,而改变频率也意味着必须购买新的设备。 + +“我们和[美国国防部]还有卫星公司讨论过,事实上其中一个较大的原因是监管的挑战,没人想放弃现有体系下基于模拟信号假定下的安全地位。”Wheeler 说到,“我认为你也必须考虑周全,但我发现那些所谓宣声信号冲突的人,其实是将眼下当作避难所,根本没有竞争和威胁方面的意识。” + +### 未来:更多的服务 + +Leigh 表示,无论开放频谱的确切方式如何,但广泛的观点认为将中频频段开放给运营商和企业,对美国商业会有潜在的优势。而当美国坚持以拍卖形式分配无线频谱时,其他国家,像德国,就已经专门预留了供企业使用的中频段频谱。 + +对于试图推出自己的私有 5G 网络的公司而言,可能会推高频谱拍卖价格。但是,只要最终有足够可用的频谱,就有服务足够可用,无论它们是内部提供的,还是由移动运营商或供应商销售的。 + +他说:“企业在 5G 方面做的事情,将推动真正的未来。” + +------ + +via: https://www.networkworld.com/article/3584072/fcc-auctions-should-be-a-long-term-boost-for-5g-availability.html + +作者:[Jon Gold][a] +选题:[lujun9972][b] +译者:[littlebirdnest](https://github.com/littlebirdnest) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Jon-Gold/ +[b]: https://github.com/lujun9972 +[1]: https://images.techhive.com/images/article/2017/01/fcc-100704762-large.jpg +[2]: https://www.networkworld.com/article/3203489/what-is-5g-fast-wireless-technology-for-enterprises-and-phones.html +[3]: https://www.networkworld.com/article/3568253/how-5g-frequency-affects-range-and-speed.html +[4]: https://www.networkworld.com/article/3568614/private-5g-can-solve-some-enterprise-problems-that-wi-fi-can-t.html +[5]: https://www.networkworld.com/article/3488799/private-5g-keeps-whirlpool-driverless-vehicles-rolling.html +[6]: https://www.networkworld.com/article/3570724/5g-can-make-for-cost-effective-private-backhaul.html +[7]: https://www.networkworld.com/article/3529291/cbrs-wireless-can-bring-private-5g-to-enterprises.html +[8]: https://www.networkworld.com/article/3572564/cbrs-wireless-yields-45b-for-licenses-to-support-5g.html +[9]: https://www.networkworld.com/article/3180615/faq-what-in-the-wireless-world-is-cbrs.html +[10]: https://www.networkworld.com/newsletters/signup.html +[11]: https://www.networkworld.com/article/3207535/what-is-iot-the-internet-of-things-explained.html +[12]: https://www.facebook.com/NetworkWorld/ +[13]: https://www.linkedin.com/company/network-world diff --git a/published/202106/20201026 7 Git tricks that changed my life.md b/published/202106/20201026 7 Git tricks that changed my life.md new file mode 100644 index 0000000000..d7b1c17f59 --- /dev/null +++ b/published/202106/20201026 7 Git tricks that changed my life.md @@ -0,0 +1,189 @@ +[#]: collector: "lujun9972" +[#]: translator: "BoosterY" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13529-1.html" +[#]: subject: "7 Git tricks that changed my life" +[#]: via: "https://opensource.com/article/20/10/advanced-git-tips" +[#]: author: "Rajeev Bera https://opensource.com/users/acompiler" + +七个改变我生活的 Git 小技巧 +====== + +> 这些有用的小技巧将改变你在当前最流行的版本控制系统下的工作方式。 + +![](https://img.linux.net.cn/data/attachment/album/202106/28/110029d64pblurlh5a4a50.jpg) + +Git 是当前最流行最普遍的版本控制系统之一,它被应用于私有系统和公开网站上各种各样的开发工作。不论我变得对 Git 有多熟悉,似乎总有些功能等待着被发掘。下面分享下和 Git 相关的改变我工作方式的一些小技巧。 + +### 1、Git 中的自动纠错 + +我们每个人都不时在输入时犯拼写错误,但是如果你使能了 Git 的自动纠错功能,你就能让 Git 自动纠正一些输入错误的子命令。 + +假如你想用命令 `git status` 来检查状态,但是你恰巧错误地输入了 `git stats`。通常情况下,Git 会告诉你 ‘stats’ 不是个有效的命令: + +``` +$ git stats +git: ‘stats’ is not a git command. See ‘git --help’. + +The most similar command is +status +``` + +为了避免类似情形,只需要在你的 Git 配置中使能自动纠错功能。 + +``` +$ git config --global help.autocorrect 1 +``` + +如果你只想对当前的仓库生效,就省略掉选项 `--global`。 + +这个命令会使能自动纠错功能。在相应的 [Git 官方文档][2] 中可以看到这个命令的详细说明,但是试着敲一下上面的错误命令会使你对这个设置干了什么有个直观的了解: + +``` +$ git stats +git: ‘stats’ is not a git command. See ‘git --help’. +On branch master +Your branch is up to date with ‘origin/master’. + +nothing to commit, working tree clean +``` + +在上面的例子中,Git 直接运行了它建议命令的第一个,也就是 `git status`,而不是给你展示它所建议的子命令。 + +### 2、对提交进行计数 + +需要对提交进行计数的原因有很多。例如,一些开发人员利用提交计数来判断什么时候递增工程构建序号,也有一些开发人员用提交计数来对项目进展取得一个整体上的感观。 + +对提交进行计数相当简单而且直接,下面就是相应的 Git 命令: + +``` +$ git rev-list --count branch-name +``` + +在上述命令中,参数 `branch-name` 必须是一个你当前仓库里的有效分支名。 + +``` +$ git rev-list –count master +32 +$ git rev-list –count dev +34 +``` + +### 3、仓库优化 + +你的代码仓库不仅对你来说很宝贵,对你所在的组织也一样。通过少数几个惯例你就能使自己的仓库整洁并且保持最新。[使用 .gitignore 文件][3] 就是这些最好的惯例之一。通过使用这个文件你可以告诉 Git 不要保存一些不需要记录的文件,如二进制文件、临时文件等等。 + +当然,你还可以使用 Git 的垃圾回收来进一步优化你的仓库。 + +``` +$ git gc --prune=now --aggressive +``` + +这个命令在你和你的团队经常使用 `pull` 或者 `push` 操作的时候很有帮助。 + +它是一个内部工具,能清理掉你的仓库里没法访问或者说“空悬”的 Git 对象。 + +### 4、给未追踪的文件来个备份 + +大多数时候,删除所有未追踪的文件是安全的。但很多时候也有这么一种场景,你想删掉这些未追踪的文件同时也想做个备份防止以后需要用到。 + +Git 组合一些 Bash 命令和管道操作,可以让你可以很容易地给那些未追踪的文件创建 zip 压缩包。 + +``` +$ git ls-files --others --exclude-standard -z |\ + xargs -0 tar rvf ~/backup-untracked.zip +``` + +上面的命令就生成了一个名字为 `backup-untracked.zip` 的压缩包文件(当然,在 `.gitignore` 里面忽略了的文件不会包含在内)。 + +### 5、了解你的 .git 文件夹 + +每个仓库都有一个 `.git` 文件夹,它是一个特殊的隐藏文件夹。 + +``` +$ ls -a +. … .git +``` + +Git 主要通过两个东西来工作: + +1. 当前工作树(你当前检出的文件状态) +2. 你的 Git 仓库的文件夹(准确地说,包含版本信息的 `.git` 文件夹的位置) + +这个文件夹存储了所有参考信息和一些其他的如配置、仓库数据、HEAD 状态、日志等更多诸如此类的重要细节。 + +一旦你删除了这个文件夹,尽管你的源码没被删,但是类似你的工程历史记录等远程信息就没有了。删除这个文件夹意味着你的工程(至少本地的复制)不再在版本控制的范畴之内了。这也就意味着你没法追踪你的修改;你没法从远程仓拉取或推送到远程仓了。 + +通常而言,你需要或者应当对你的 `.git` 文件夹的操作并不多。它是被 Git 管理的,而且大多数时候是一个禁区。然而,在这个文件夹内还是有一些有趣的工件,比如说当前的 HEAD 状态在内的就在其中。 + +``` +$ cat .git/HEAD +ref: refs/heads/master +``` + +它也隐含着对你仓库地描述: + +``` +$ cat .git/description +``` + +这是一个未命名的仓库;通过编辑文件 ‘description’ 可以给这个仓库命名。 + +Git 钩子文件夹连同一些钩子文件例子也在这里。参考这些例子你就能知道 Git 钩子能干什么了。当然,你也可以 [参考这个 Seth Kenlon 写的 Git 钩子介绍][4]。 + +### 6、浏览另一个分支的文件 + +有时,你会想要浏览另一个分支下某个文件的内容。这其实用一个简单的 Git 命令就可以实现,甚至都不用切换分支。 + +设想你有一个命名为 [README.md][5] 的文件,并且它在 `main` 分支上。当前你正工作在一个名为 `dev` 的分支。 + +用下面的 Git 命令,在终端上就行。 + +``` +$ git show main:README.md +``` + +一旦你执行这个命令,你就能在你的终端上看到 `main` 分支上该文件的内容。 + +### 7、Git 中的搜索 + +用一个简单的命令你就能在 Git 中像专业人士一样搜索了。更有甚者,尽管你不确定你的修改在哪次提交或者哪个分支上,你依然能搜索。 + +``` +$ git rev-list --all | xargs git grep -F '' +``` + +例如,假设你想在你的仓库中搜索字符串 `“font-size: 52 px;"` : + +``` +$ git rev-list –all | xargs git grep -F ‘font-size: 52 px;’ +F3022…9e12:HtmlTemplate/style.css: font-size: 52 px; +E9211…8244:RR.Web/Content/style/style.css: font-size: 52 px; +``` + +### 试试这些小技巧 + +我希望这些小技巧对你是有用的,或者增加你的生产力或者节省你的大量时间。 + +你也有一些喜欢的 [Git 技巧][6] 吗?在评论区分享吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/10/advanced-git-tips + +作者:[Rajeev Bera][a] +选题:[lujun9972][b] +译者:[BoosterY](https://github.com/BoosterY) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/acompiler +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_screen_windows_files.png?itok=kLTeQUbY (Computer screen with files or windows open) +[2]: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_code_help_autocorrect_code +[3]: https://opensource.com/article/20/8/dont-ignore-gitignore +[4]: https://opensource.com/life/16/8/how-construct-your-own-git-server-part-6 +[5]: http://README.md +[6]: https://acompiler.com/git-tips/ diff --git a/sources/tech/20210222 A friendly guide to the syntax of C-- method pointers.md b/published/202106/20210222 A friendly guide to the syntax of C-- method pointers.md similarity index 65% rename from sources/tech/20210222 A friendly guide to the syntax of C-- method pointers.md rename to published/202106/20210222 A friendly guide to the syntax of C-- method pointers.md index 19125cb1bc..a80a7bffc1 100644 --- a/sources/tech/20210222 A friendly guide to the syntax of C-- method pointers.md +++ b/published/202106/20210222 A friendly guide to the syntax of C-- method pointers.md @@ -1,35 +1,36 @@ [#]: collector: (lujun9972) [#]: translator: (mengxinayan) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13498-1.html) [#]: subject: (A friendly guide to the syntax of C++ method pointers) [#]: via: (https://opensource.com/article/21/2/ccc-method-pointers) [#]: author: (Stephan Avenwedde https://opensource.com/users/hansic99) C++ 类成员函数指针语法的友好指南 ====== -一旦您理解了一般原则,C++ 类成员函数指针不再那么令人生畏。 -![Person drinking a hot drink at the computer][1] +> 一旦你理解了一般原则,C++ 类成员函数指针不再那么令人生畏。 -如果您正在寻找性能、复杂性或许多可能的解决方法来解决问题,那么 [C++][2] 总是一个很好的选择。当然,功能通常伴随着复杂性,但是一些 C++ 的特性几乎难以分辨。根据我的观点,C++ 的 [类成员函数指针](3) 也许是我接触过的最复杂的表达式,但是我会先从一些较简单的开始。 +![](https://img.linux.net.cn/data/attachment/album/202106/18/104200rm48h22eghehg2p3.jpg) + +如果你正在寻找性能、复杂性或许多可能的解决方法来解决问题,那么在涉及到极端的情况下,[C++][2] 总是一个很好的选择。当然,功能通常伴随着复杂性,但是一些 C++ 的特性几乎难以分辨。根据我的观点,C++ 的 [类成员函数指针][3] 也许是我接触过的最复杂的表达式,但是我会先从一些较简单的开始。 文章中的例子可以在我的 [Github 仓库][4] 里找到。 ### C 语言:函数指针 -让我们先从一些基础开始:假设您有一个函数接收两个整数作为参数返回一个整数: +让我们先从一些基础开始:假设你有一个函数接收两个整数作为参数返回一个整数: -```c +``` int sum(int a, int b) { return a+b; } ``` -在纯 C 语言中,您可以创建一个指向这个函数的指针,将其分配给您的 `sum(...)` 函数,通过解引用来调用它。函数的签名(参数、返回类型)必须符合指针的签名。除此之外,一个函数指针表现和普通的指针相同: +在纯 C 语言中,你可以创建一个指向这个函数的指针,将其分配给你的 `sum(...)` 函数,通过解引用来调用它。函数的签名(参数、返回类型)必须符合指针的签名。除此之外,一个函数指针表现和普通的指针相同: -```c +``` int (*funcPtrOne)(int, int); funcPtrOne = ∑ @@ -37,9 +38,9 @@ funcPtrOne = ∑ int resultOne = funcPtrOne(2, 5); ``` -如果您使用指针作为参数并返回一个指针,这会显得很丑陋: +如果你使用指针作为参数并返回一个指针,这会显得很丑陋: -```c +``` int *next(int *arrayOfInt){ return ++arrayOfInt; } @@ -55,9 +56,9 @@ C 语言中的函数指针存储着子程序的地址。 ### 指向类成员函数的指针 -让我们来进入 C++:好消息是您也许不需要使用类成员函数指针,除非在一个特别罕见的情况下,像接下来的例子。首先,您已经知道定义一个类和其中一个成员函数: +让我们来进入 C++:好消息是你也许不需要使用类成员函数指针,除非在一个特别罕见的情况下,比如说接下来的例子。首先,你已经知道定义一个类和其中一个成员函数: -```cpp +``` class MyClass { public: @@ -69,42 +70,42 @@ public: }; ``` -#### 1\. 定义一个指针指向某一个类中一个成员函数 +#### 1、定义一个指针指向某一个类中一个成员函数 -声明一个指针指向 `MyClass` 类成员函数。在此时,您并不知道想调用的具体函数。您仅仅声明了一个指向 `MyClass` 类中任意成员函数的指针。当然,签名(参数、返回值类型)需要匹配您接下想要调用的 `sum(...)` 函数: +声明一个指针指向 `MyClass` 类成员函数。在此时,你并不知道想调用的具体函数。你仅仅声明了一个指向 `MyClass` 类中任意成员函数的指针。当然,签名(参数、返回值类型)需要匹配你接下想要调用的 `sum(...)` 函数: -```cpp +``` int (MyClass::*methodPtrOne)(int, int); ``` -#### 2\. 赋值给一个具体的函数 +#### 2、赋值给一个具体的函数 为了和 C 语言(或者 [静态成员函数][5])对比,类成员函数指针不需要指向绝对地址。在 C++ 中,每一个类中都有一个虚拟函数表(vtable)用来储存每个成员函数的地址偏移量。一个类成员函数指针指向 vtable 中的某个条目,因此它也只存储偏移值。这样的原则使得 [多态][6] 变得可行。 -因为 `sum(...)` 函数的签名和您的指针声明匹配,您可以赋值签名给它: +因为 `sum(...)` 函数的签名和你的指针声明匹配,你可以赋值签名给它: -```cpp +``` methodPtrOne = &MyClass::sum; ``` -#### 3\. 调用成员函数 +#### 3、调用成员函数 -如果您想使用指针调用一个类成员函,您必须提供一个类的实例: +如果你想使用指针调用一个类成员函,你必须提供一个类的实例: -```cpp +``` MyClass clsInstance; int result = (clsInstance.*methodPtrOne)(2,3); ``` -您可以使用 `.` 操作符来访问,使用 `*` 对指针解引用,通过提供两个整数作为调用函数时的参数。这是丑陋的,对吧?但是您可以进一步应用。 +你可以使用 `.` 操作符来访问,使用 `*` 对指针解引用,通过提供两个整数作为调用函数时的参数。这是丑陋的,对吧?但是你可以进一步应用。 ### 在类内使用类成员函数指针 -假设您正在创建一个带有后端和前端的 [客户端/服务器][7] 原理架构的应用程序。您现在并不需要关心后端,相反的,您将基于 C++ 类的前端。前端依赖于后端提供的数据完成初始化,所以您需要一个额外的初始化机制。同时,您希望通用地实现此机制,以便将来可以使用其他初始化函数(可能是动态的)来拓展您的前端。 +假设你正在创建一个带有后端和前端的 [客户端/服务器][7] 原理架构的应用程序。你现在并不需要关心后端,相反的,你将基于 C++ 类的前端。前端依赖于后端提供的数据完成初始化,所以你需要一个额外的初始化机制。同时,你希望通用地实现此机制,以便将来可以使用其他初始化函数(可能是动态的)来拓展你的前端。 首先定义一个数据类型用来存储初始化函数(`init`)的指针,同时描述何时应调用此函数的信息(`ticks`): -```cpp +``` template struct DynamicInitCommand { void (T::*init)(); // 指向额外的初始化函数 @@ -114,7 +115,7 @@ struct DynamicInitCommand { 下面一个 `Frontend` 类示例代码: -```cpp +``` class Frontend { public: @@ -131,8 +132,6 @@ public: m_dynamicInit.push_back(init3); } - - void tick(){ std::cout << "tick: " << ++m_ticks << std::endl; @@ -174,9 +173,9 @@ private: }; ``` -在 `Frontend` 完成实例化后,`tick()` 函数会被后端以固定的时间时间调用。例如,您可以每 200 毫秒调用一次: +在 `Frontend` 完成实例化后,`tick()` 函数会被后端以固定的时间时间调用。例如,你可以每 200 毫秒调用一次: -```cpp +``` int main(int argc, char* argv[]){ Frontend frontendInstance; @@ -187,7 +186,7 @@ int main(int argc, char* argv[]){ } ``` -`Fronted` 有三个额外的初始化函数,它们必须根据 `m_ticks` 的值来选择调用哪个。在 tick 等于何值调用哪个初始化函数的信息存储在数组 `m_dynamicInit` 中。在构造函数(`Frontend()`)中,将此信息附加到数组中,以便在 5、10 和 15 个 tick 后调用其他初始化函数。当后端调用 `tick()` 函数时,`m_ticks` 值会递增,同时遍历数组 `m_dynamicInit` 以检查是否必须调用初始化函数。 +`Fronted` 有三个额外的初始化函数,它们必须根据 `m_ticks` 的值来选择调用哪个。在 ticks 等于何值调用哪个初始化函数的信息存储在数组 `m_dynamicInit` 中。在构造函数(`Frontend()`)中,将此信息附加到数组中,以便在 5、10 和 15 个 tick 后调用其他初始化函数。当后端调用 `tick()` 函数时,`m_ticks` 值会递增,同时遍历数组 `m_dynamicInit` 以检查是否必须调用初始化函数。 如果是这种情况,则必须通过引用 `this` 指针来取消引用成员函数指针: @@ -197,9 +196,9 @@ int main(int argc, char* argv[]){ ### 总结 -如果您并不熟悉类成员函数指针,它们可能会显得有些复杂。我做了很多尝试和经历了很多错误,花了一些时间来找到正确的语法。然而,一旦你理解了一般原理后,方法指针就变得不那么可怕了。 +如果你并不熟悉类成员函数指针,它们可能会显得有些复杂。我做了很多尝试和经历了很多错误,花了一些时间来找到正确的语法。然而,一旦你理解了一般原理后,方法指针就变得不那么可怕了。 -这是迄今为止我在 C++ 中发现的最复杂的语法。 您还知道更糟糕的吗? 在评论中发布您的观点! +这是迄今为止我在 C++ 中发现的最复杂的语法。 你还知道更糟糕的吗? 在评论中发布你的观点! -------------------------------------------------------------------------------- @@ -208,7 +207,7 @@ via: https://opensource.com/article/21/2/ccc-method-pointers 作者:[Stephan Avenwedde][a] 选题:[lujun9972][b] 译者:[萌新阿岩](https://github.com/mengxinayan) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20210325 Identify Linux performance bottlenecks using open source tools.md b/published/202106/20210325 Identify Linux performance bottlenecks using open source tools.md similarity index 100% rename from published/20210325 Identify Linux performance bottlenecks using open source tools.md rename to published/202106/20210325 Identify Linux performance bottlenecks using open source tools.md diff --git a/translated/tech/20210427 Upgrade your Linux PC hardware-using open source tools.md b/published/202106/20210427 Upgrade your Linux PC hardware-using open source tools.md similarity index 87% rename from translated/tech/20210427 Upgrade your Linux PC hardware-using open source tools.md rename to published/202106/20210427 Upgrade your Linux PC hardware-using open source tools.md index 76de1b87ae..7ddd890346 100644 --- a/translated/tech/20210427 Upgrade your Linux PC hardware-using open source tools.md +++ b/published/202106/20210427 Upgrade your Linux PC hardware-using open source tools.md @@ -4,15 +4,15 @@ [#]: collector: (lujun9972) [#]: translator: (wxy) [#]: reviewer: (wxy) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13472-1.html) 使用开源工具升级你的 Linux PC 硬件 ====== > 升级你的电脑硬件来提升性能,以获得最大的回报。 -![笔记本电脑上的商务女性坐在窗前][1] +![](https://img.linux.net.cn/data/attachment/album/202106/09/204443k8dz09dddhd7xu65.jpg) 在我的文章《[使用开源工具识别 Linux 性能瓶颈][2]》中,我解释了一些使用开源的图形用户界面(GUI)工具监测 Linux 性能的简单方法。我的重点是识别 _性能瓶颈_,即硬件资源达到极限并阻碍你的 PC 性能的情况。 @@ -22,33 +22,33 @@ 开源工具是关键。GUI 工具可以帮助你监控你的系统,预测哪些硬件改进会有效。否则,你可能买了硬件后发现它并没有提高性能。在升级之后,这些工具也有助于验证升级是否产生了你预期的好处。 -这篇文章概述了一种简单的 PC 硬件升级的方法。其“秘诀”是开源的 GUI 工具。 +这篇文章概述了一种简单的 PC 硬件升级的方法,其“秘诀”是开源的 GUI 工具。 ### 如何升级内存 几年前,升级内存是不用多想的。增加内存几乎总是能提高性能。 -今天,情况不再是这样了。个人电脑配备了更多的内存,而且 Linux 能非常有效地使用它。如果你买了系统用不完的内存,你就浪费了钱。 +今天,情况不再是这样了。个人电脑配备了更多的内存,而且 Linux 能非常有效地使用它。如果你购买了系统用不完的内存,就浪费了钱。 因此,你要花一些时间来监测你的电脑,看看内存升级是否会有助于提升它的性能。例如,在你进行典型的一天工作时观察内存的使用情况。而且一定要检查在内存密集型工作负载中发生了什么。 -各种各样的开源工具可以帮助你进行这种监测,不过我用的是 [GNOME系统监视器][3]。它在大多数 Linux 软件库中都有。 +各种各样的开源工具可以帮助你进行这种监测,不过我用的是 [GNOME 系统监视器][3]。它在大多数 Linux 软件库中都有。 -当你启动系统监视器时,它的**资源**面板会显示这样的输出: +当你启动系统监视器时,它的“资源”面板会显示这样的输出: ![用 GNOME 系统监控器监控内存][4] *图 1. 用 GNOME 系统监视器监控内存 (Howard Fosdick, [CC BY-SA 4.0][5])* -屏幕中间显示内存的使用情况。[交换空间][6] 是 Linux 在内存不足时使用的磁盘空间。Linux 通过使用交换空间作为内存的一个较慢的扩展来有效地增加内存。 +屏幕中间显示了内存的使用情况。[交换空间][6] 是 Linux 在内存不足时使用的磁盘空间。Linux 通过使用交换空间作为内存的一个较慢的扩展来有效地增加内存。 由于交换空间比内存慢,如果内存交换活动变得显著,增加内存将改善你的计算机的性能。你会得到多大的改善取决于交换活动的数量和交换空间所在的设备的速度。 -如果使用了大量的交换空间,你通过增加内存得到的性能改善会比只使用了少量交换空间的情况大。 +如果使用了大量的交换空间,你通过增加内存会得到比只使用了少量交换空间更多的性能改善。 -如果交换空间位于慢速的机械硬盘上,你会发现增加内存比交换空间位于最快的固态硬盘上有更大的改善。 +如果交换空间位于慢速的机械硬盘上,你会发现增加内存比将交换空间放在最快的固态硬盘上改善更多。 -下面是一个关于何时增加内存的例子。这台电脑在内存利用率达到 80% 后显示出交换活动在增加。当内存利用率超过 90% 时,它就变得没有反应了。 +下面是一个关于何时增加内存的例子。这台电脑在内存利用率达到 80% 后显示交换活动在增加。当内存利用率超过 90% 时,它就变得失去反应了。 ![系统监控 - 内存不足的情况][7] @@ -70,15 +70,15 @@ 升级后,启动系统监视器。运行之前使你的内存超载的相同程序。 -系统监控器应该显示出你扩展的内存,而且你应该看到更好的性能。 +系统监控器应该显示出你扩充的内存,而且你应该发现性能更好了。 ### 如何升级存储 -我们正处在一个存储快速改进的时代。即使是只有几年历史的计算机也可以从磁盘升级中受益。但首先,你要确保升级对你的计算机和工作负载是有意义的。 +我们正处在一个存储快速改进的时代。即使是只用了几年的计算机也可以从磁盘升级中受益。但首先,你要确保升级对你的计算机和工作负载是有意义的。 首先,要找出你有什么磁盘。许多开源工具会告诉你。[Hardinfo][8] 或 [GNOME 磁盘][9] 是不错的选择,因为它们都是广泛可用的,而且它们的输出很容易理解。这些应用程序会告诉你磁盘的品牌、型号和其他细节。 -接下来,通过基准测试来确定你的磁盘性能。GNOME 磁盘让这一切变得简单。只要启动该工具并点击它的**磁盘基准测试**选项。这会给出你磁盘的读写率和平均磁盘访问时间。 +接下来,通过基准测试来确定你的磁盘性能。GNOME 磁盘让这一切变得简单。只要启动该工具并点击它的“磁盘基准测试”选项。这会给出你磁盘的读写率和平均磁盘访问时间。 ![GNOME 磁盘基准测试][10] @@ -104,7 +104,7 @@ 很明显,你可以用一个更快的磁盘来提高性能。 -你也会想知道是哪个程序使用了磁盘。只要启动系统监视器并点击其**进程**标签。 +你也会想知道是哪个程序使用了磁盘。只要启动系统监视器并点击其“进程”标签。 现在你知道了你的磁盘有多忙,以及哪些程序在使用它,所以你可以做出一个有根据的判断,是否值得花钱买一个更快的磁盘。 @@ -126,7 +126,7 @@ * **绿色柱形图:** 固态硬盘比机械硬盘快。但如果固态硬盘使用 SATA 接口,就会限制其性能。这是因为 SATA 接口是十多年前为机械硬盘设计的。 * **蓝色柱形图:** 最快的内置磁盘技术是新的 [PCIe 接口的 NVMe 固态盘][19]。这些可以比 SATA 连接的固态硬盘大约快 5 倍,比机械硬盘快 20 倍。 -对于外置 SSD,你会发现 [最新的雷电和 USB 接口][20] 是最快的。 +对于外置 SSD,你会发现 [最新的雷电接口和 USB 接口][20] 是最快的。 #### 如何安装一个内置磁盘 @@ -152,7 +152,7 @@ *图 7. USB 速度差别很大(Howard Fosdick,[CC BY-SA 4.0][5],基于 [Tripplite][23] 和 [维基][24] 的数据* -要查看你得到的实际 USB 速度,请启动 GNOME 磁盘。GNOME 磁盘可以对 USB 连接的设备进行基准测试,就像对内部磁盘一样。选择其**基准磁盘**选项。 +要查看你得到的实际 USB 速度,请启动 GNOME 磁盘。GNOME 磁盘可以对 USB 连接的设备进行基准测试,就像对内部磁盘一样。选择其“磁盘基准测试”选项。 你插入的设备和 USB 端口共同决定了你将得到的速度。如果端口和设备不匹配,你将体验到两者中较慢的速度。 @@ -170,7 +170,7 @@ USB 3.0 卡的价格只有 25 美元左右。较新、较贵的卡提供 USB 3.1 升级你的互联网带宽很容易。只要给你的 ISP 写一张支票即可。 -问题是:应该升级吗? +问题是,应该升级吗? 系统监控器显示了你的带宽使用情况(见图 1)。如果你经常遇到你从 ISP 购买的带宽限额,你会从购买更高的限额中受益。 @@ -192,13 +192,13 @@ USB 3.0 卡的价格只有 25 美元左右。较新、较贵的卡提供 USB 3.1 大多数台式机主板支持一系列的 CPU,并且是可以升级的 —— 假设你还没有使用该系列中最顶级的处理器。 -使用系统监视器观察你的 CPU,并确定升级是否有帮助。它的**资源**面板将显示你的 CPU 负载。如果你的所有逻辑处理器始终保持在 80% 或 90% 以上,你可以从更多的 CPU 功率中受益。 +使用系统监视器观察你的 CPU,并确定升级是否有帮助。它的“资源”面板将显示你的 CPU 负载。如果你的所有逻辑处理器始终保持在 80% 或 90% 以上,你可以从更多的 CPU 功率中受益。 这是一个升级 CPU 的有趣项目。只要小心谨慎,任何人都可以做到这一点。 不幸的是,这几乎没有成本效益。大多数卖家对单个 CPU 芯片收取溢价,比他们卖给你的新系统要高。因此,对许多人来说,升级 CPU 并不具有经济意义。 -如果你将显示器直接插入台式机的主板,你可能会通过升级图形处理而受益。只需添加一块显卡。 +如果你将显示器直接插入台式机的主板,你可能会通过升级图形处理器而受益。只需添加一块显卡。 诀窍是在新显卡和你的 CPU 之间实现平衡的工作负荷。这个 [在线工具][27] 能准确识别哪些显卡能与你的 CPU 最好地配合。[这篇文章][28] 详细解释了如何去升级你的图形处理。 @@ -222,7 +222,7 @@ via: https://opensource.com/article/21/4/upgrade-linux-hardware [a]: https://opensource.com/users/howtech [b]: https://github.com/lujun9972 [1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-concentration-focus-windows-office.png?itok=-8E2ihcF (Woman using laptop concentrating) -[2]: https://opensource.com/article/21/3/linux-performance-bottlenecks +[2]: https://linux.cn/article-13462-1.html [3]: https://vitux.com/how-to-install-and-use-task-manager-system-monitor-in-ubuntu/ [4]: https://opensource.com/sites/default/files/uploads/system_monitor_-_resources_panel_0.jpg (Monitoring memory with GNOME System Monitor) [5]: https://creativecommons.org/licenses/by-sa/4.0/ diff --git a/published/20210517 Convenient matrices and other improvements Python 3.5 brought us.md b/published/202106/20210517 Convenient matrices and other improvements Python 3.5 brought us.md similarity index 100% rename from published/20210517 Convenient matrices and other improvements Python 3.5 brought us.md rename to published/202106/20210517 Convenient matrices and other improvements Python 3.5 brought us.md diff --git a/published/202106/20210517 Use open source tools to set up a private VPN.md b/published/202106/20210517 Use open source tools to set up a private VPN.md new file mode 100644 index 0000000000..416c8d5aef --- /dev/null +++ b/published/202106/20210517 Use open source tools to set up a private VPN.md @@ -0,0 +1,199 @@ +[#]: subject: (Use open source tools to set up a private VPN) +[#]: via: (https://opensource.com/article/21/5/open-source-private-vpn) +[#]: author: (Lukas Janėnas https://opensource.com/users/lukasjan) +[#]: collector: (lujun9972) +[#]: translator: (stevenzdg988) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13539-1.html) + +使用开源工具创建私有的虚拟专用网络 +====== + +> 使用 OpenWRT 和 Wireguard 在路由器上创建自己的虚拟专用网络。 + +![](https://img.linux.net.cn/data/attachment/album/202107/01/101629ym69mwpmcmetdp99.jpg) + +通过计算机网络从一个地方到另一个地方可能是一件棘手的事情。除了知道正确的地址和打开正确的端口之外,还有安全问题。 对于 Linux,SSH 是一种流行的默认方式,虽然你可以使用 SSH 做很多事情,但它仍然“只是”一个安全外壳(实际上,这就是 SSH 的含义)。用于加密流量的更广泛的协议是“虚拟专用网络”,它创建了一个独特的两点之间的虚拟的专用网络。有了它,你可以登录到另一个网络上的计算机并使用它的所有服务(文件共享、打印机等等),就像你坐在同一个房间里一样,并且全部的数据都是从点到点加密的。 + +通常,为了使虚拟专用网络连接成为可能,进入每个网络的网关必须接受虚拟专用网络流量,并且必须侦听目标网络上的某些计算机的虚拟专用网络流量。然而,你可以运行自己的带有虚拟专用网络服务器的路由器固件,使你能够连接到目标网络,而无需担心转发端口或考虑内部拓扑。我最喜欢的固件是 OpenWrt,在本文中我将演示如何设置它,以及如何启用虚拟专用网络。 + +### 什么是 OpenWrt? + +[OpenWrt][2] 是一个使用 Linux 面向嵌入式设备的开源项目。它已经存在超过 15 年,拥有庞大而活跃的社区。 + +使用 OpenWrt 的方法有很多种,但它的主要用途是在路由器中。它提供了一个具有包管理功能的完全可写的文件系统,并且由于它是开源的,你可以查看和修改代码并为生态系统做出贡献。如果你想对路由器进行更多控制,这就是你想要使用的系统。 + +OpenWrt 支持很多路由器,包括 [思科][3]、[华硕][4]、[MikroTik][5]、[Teltonika Networks][6]、[D-Link][7]、[TP-link][8]、[Buffalo][9]、[Ubiquiti][10] 等知名品牌和 [许多其他品牌][11]。 + +### Wireguard 是什么? + +[Wireguard][12] 是开源的虚拟专用网络软件,它比 OpenVPN 等其他选项更快、更简单且更安全。它使用最先进的密码学:用于对称加密的 ChaCha20;用于密钥协商的 Curve 25519(使用椭圆曲线),和用于散列的 BLAKE2。这些算法的设计方式在嵌入式系统上是高效的。Wireguard 也可用于各种操作系统 [平台][13]。 + +### 先决条件 + +对于这个项目,你需要: + + * [Teltonika RUT955][14] 或支持 OpenWrt 的其他路由器 + * 一个公网 IP 地址,用于从外部网络连接到虚拟专用网络 + * 一部安卓手机 + +### 安装 OpenWrt + +首先,下载路由器的 OpenWrt 镜像。使用 [固件选择器][15] 检查 OpenWrt 是否支持你的路由器并下载固件。输入你的路由器型号,将显示选项: + +![OpenWRT 固件选择器][16] + +使用搜索框右侧的下拉输入选择要下载的固件版本。 + +下载出厂镜像。 + +![下载出厂镜像][18] + +许多路由器允许你从 Web 界面刷入未经授权的固件,但 Teltonika Networks 不允许。要将 OpenWrt 固件刷入这样的路由器,你需要使用引导加载器。为此,请按照下列步骤操作: + + 1. 拔掉路由器的电源线。 + 2. 按住重置按钮。 + 3. 插入路由器的电源线。 + 4. 插入电源线后,继续按住重置按钮 5 到 8 秒。 + 5. 将计算机的 IP 地址设置为 `192.168.1.15`,将网络掩码设置为 `255.255.255.0`。 + 6. 使用以太网电缆通过 LAN 端口连接路由器和计算机。 + 7. 打开网页浏览器并输入 `192.168.1.1:/index.html`。 + 8. 上传并刷写固件。 + +刷机过程可能占用三分钟。之后,你应该可以通过在浏览器中输入 `192.168.1.1` 来访问路由器的 Web 界面。 默认情况下没有设置密码 + +![OpenWrt 授权][19] + +### 配置网络连接 + +网络连接是必要条件。如果你的 Internet 服务提供商(ISP) 使用 DHCP 自动分配你的 IP 地址,你只需将以太网电缆插入路由器的 WAN 端口。 + +如果你需要手动分配 IP 地址,导航至 “Network → Interfaces”。选择 “Edit” 编辑你的 WAN 接口。从 “Protocol” 字段中,选择 “Static address”,然后选择 “Switch protocol”。 + +![手动分配 IP 地址][20] + +在 “IPv4 address” 字段中,输入你的路由器地址。设置 “IPv4 netmask” 以匹配你的网络子网;输入你将用于连接到网络的 “IPv4 gateway” 地址; 并在 “Use custom DNS servers” 字段中输入 DNS 服务器的地址。保存配置。 + +就是这样!你已成功配置 WAN 接口以获得网络连接。 + +### 安装必要的包 + +默认情况下,该固件不包含很多包,但 OpenWrt 有一个包管理器和可选安装的软件包。导航到 “System → Software” 并通过选择 “Update list...” 更新你的包管理器。 + +![OpenWrt 包管理器][21] + +在“Filter”输入中,键入 “Wireguard”,等待系统找到所有包含该关键字的包。找到并安装名为 “luci-app-wireguard” 的包。 + +![luci-app-wireguard 包][22] + +该软件包包括一个用于配置 Wireguard 的 Web 界面,并安装 Wireguard 所必需的所有依赖项。 + +如果你在安装 Wireguard 软件包之前收到一个软件包丢失的警告并且在存储库中找不到,请忽略它并继续。 + +接下来,找到并安装名为 “luci-app-ttyd” 的包。这将用于稍后访问终端。 + +安装这些软件包后,重新启动路由器以使更改生效。 + +### 配置 Wireguard 接口 + +接下来,创建 Wireguard 接口。导航到 “Network → Interfaces” 并选择左下角的 “Add new interface...”。在弹出窗口中,输入你想要的接口名称,从下拉列表中选择 “WireguardVPN”,然后选择右下角的 “Create interface”。 + +![创建 Wireguard 接口][23] + +在新弹出的窗口中,选择 “Generate Key” 为 Wireguard 接口生成私钥。在 “Listen Port” 字段中,输入所需的端口。我将使用默认的 Wireguard 端口,“51820”。在 “IP Addresses” 字段中,分配将用于 Wireguard 接口的 IP 地址。在这个例子中,我使用了 `10.0.0.1/24`。数字 “24” 表明我的子网的大小。 + +![创建 Wireguard 接口][24] + +保存配置并重启接口。 + +导航到 “Services → Terminal”,登录到 shell,然后输入命令 `wg show`。你将看到有关 Wiregaurd 接口的一些信息,包括其公钥。复制公钥——稍后你将需要它来创建对等点。 + +![Wireguard 公钥][25] + +### 配置防火墙 + +导航到 “Network → Firewall” 并选择 “Traffic Rules” 选项卡。在页面底部,选择 “Add”。在弹出窗口的 “Name” 字段中,为你的规则命名,例如 “Allow-wg”。接下来,将 “Destination zone” 从 “Lan” 更改为 “Device”,并将 “Destination port” 设置为 “51820”。 + +![Wireguard 防火墙设置][26] + +保存配置。 + +### 手机上配置 Wireguard + +从 Google Play 在你的手机上安装 [Wireguard 应用程序][27]。安装后,打开应用程序并从头开始创建一个新接口。在 “Name” 字段中,输入要用于接口的名称。在 “Private key” 字段中,按右侧的双向箭头图标生成密钥对。你将需要上面的公钥来在你的手机和路由器之间创建一个对等点。在 “Addresses” 字段中,分配你将用于通过虚拟专用网络访问电话的 IP 地址。我将使用 `10.0.0.2/24`。在 “Listen port” 中,输入端口;我将再次使用默认端口。 + +![在 Android 上设置虚拟专用网络接口][28] + +保存配置。 + +要向配置中添加对等点,请选择 “Add peer”。在 “Public key” 字段中,输入路由器的 Wireguard 公钥。在 “Endpoint” 字段中,输入路由器的公共 IP 地址和端口,以冒号分隔,例如 `12.34.56.78:51820`。在 “Allowed IP” 字段中,输入要通过 Wireguard 接口访问的 IP 地址。 (你可以输入路由器的虚拟专用网络接口 IP 地址和 LAN 接口地址。)IP 地址必须用逗号分隔。你还可以定义子网的大小。 + +![在 Android 上添加虚拟专用网络对等点][29] + +保存配置。 + +配置中还剩下最后一步:在路由器上添加一个对等点。 + +### 在路由器上添加一个对等点 + +导航到 “Network → Interfaces” 并选择你的 Wireguard 接口。转到 “Peers” 选项卡并选择 “Add peer”。在 “Description” 字段中,输入对等方的名称。在 “Public Key” 字段中输入手机的 Wireguard 接口公钥,在 “Allowed IPs” 字段中输入手机的 Wireguard 接口 IP 地址。选中 “Route Allowed IPs” 复选框。 + +![在路由器上添加一个对等点][30] + +保存配置并重启接口。 + +### 测试配置 + +在手机上打开 Web 浏览器。在 URL 栏中,输入 IP 地址 `10.0.0.1` 或 `192.168.1.1`。你应该能够访问路由器的网站。 + +![从 Android 登录 虚拟专用网络][31] + +### 你自己的虚拟专用网络 + +这些天有很多虚拟专用网络服务商在做广告,但是拥有和控制自己的基础设施还有很多话要说,尤其是当该基础设施仅用于提高安全性时。无需依赖其他人为你提供安全的数据连接。使用 OpenWrt 和 Wireguard,你可以拥有自己的开源虚拟专用网络解决方案。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/5/open-source-private-vpn + +作者:[Lukas Janėnas][a] +选题:[lujun9972][b] +译者:[stevenzdg988](https://github.com/stevenzdg988) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lukasjan +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/vpn_scrabble_networking.jpg?itok=pdsUHw5N (scrabble letters used to spell "V") +[2]: https://openwrt.org/ +[3]: https://www.cisco.com/c/en/us/products/routers/index.html +[4]: https://www.asus.com/Networking-IoT-Servers/WiFi-Routers/All-series/ +[5]: https://mikrotik.com/ +[6]: https://teltonika-networks.com/ +[7]: https://www.dlink.com/en/consumer +[8]: https://www.tp-link.com/us/ +[9]: https://www.buffalotech.com/products/category/wireless-networking +[10]: https://www.ui.com/ +[11]: https://openwrt.org/toh/views/toh_fwdownload +[12]: https://www.wireguard.com/ +[13]: https://www.wireguard.com/install/ +[14]: https://teltonika-networks.com/product/rut955/ +[15]: https://firmware-selector.openwrt.org/ +[16]: https://opensource.com/sites/default/files/uploads/openwrt_firmware-selector.png (OpenWRT firmware selector) +[17]: https://creativecommons.org/licenses/by-sa/4.0/ +[18]: https://opensource.com/sites/default/files/uploads/downloadfactoryimage.png (Downloading the Factory Image) +[19]: https://opensource.com/sites/default/files/uploads/openwrt_authorization.png (OpenWrt authorization) +[20]: https://opensource.com/sites/default/files/uploads/openwrt_staticaddress.png (Assigning IP address manually) +[21]: https://opensource.com/sites/default/files/uploads/openwrt_update-lists.png (OpenWrt package manager) +[22]: https://opensource.com/sites/default/files/uploads/wireguard-package.png (luci-app-wireguard package) +[23]: https://opensource.com/sites/default/files/uploads/wireguard_createinterface.png (Creating Wireguard interface) +[24]: https://opensource.com/sites/default/files/uploads/wireguard_createinterface2.png (Creating Wireguard interface) +[25]: https://opensource.com/sites/default/files/uploads/wireguard_publickey.png (Wireguard public key) +[26]: https://opensource.com/sites/default/files/uploads/wireguard-firewallsetup.png (Wireguard firewall setup) +[27]: https://play.google.com/store/apps/details?id=com.wireguard.android&hl=lt&gl=US +[28]: https://opensource.com/sites/default/files/uploads/vpn_inferfacesetup.png (Setting up V interface on Android) +[29]: https://opensource.com/sites/default/files/uploads/addpeeronphone.png (Adding a V peer on an Android) +[30]: https://opensource.com/sites/default/files/uploads/addpeeronrouter.png (Adding a peer on the router) +[31]: https://opensource.com/sites/default/files/uploads/android-vpn-login.png (Logging into the V from Android) diff --git a/published/202106/20210518 4 essential characteristics of successful APIs.md b/published/202106/20210518 4 essential characteristics of successful APIs.md new file mode 100644 index 0000000000..63d514f348 --- /dev/null +++ b/published/202106/20210518 4 essential characteristics of successful APIs.md @@ -0,0 +1,206 @@ +[#]: subject: (4 essential characteristics of successful APIs) +[#]: via: (https://opensource.com/article/21/5/successful-apis) +[#]: author: (Tom Wilson https://opensource.com/users/tomwillson4014) +[#]: collector: (lujun9972) +[#]: translator: (ywxgod) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13483-1.html) + +完善的 API 的 4 个基本特征 +====== + +> 创建一个 API(应用程序接口),我们所要做的远远不止是让它能“正常工作”。 + +![](https://img.linux.net.cn/data/attachment/album/202106/14/155547zs3mffismifqqi59.jpg) + +如果你正在构建基于 C/S 模型的应用程序,那么你需要一个应用程序接口(API)。API 就是一种非常清晰而又明确的定义,它是一个进程process与另一个进程之间明确定义的边界。Web 应用中我们常见的边界定义就是 REST/JSON API。 + +虽然很多开发者可能主要关注在如何让 API 正常工作(或功能正常),但却还有一些“非功能性”的要求也是需要他们注意的。所有的 API *必须具备* 的 4 个非功能性的要求是: + + * 安全 + * 文档 + * 验证 + * 测试 + +### 安全 + +在软件开发中,安全是最基本的要求。对于 API 开发者来说,API 的安全性主要包含以下 4 个方面: + + 1. HTTPS/SSL 证书 + 2. 跨域资源共享 + 3. 身份认证与 JSON Web 令牌 + 4. 授权与作用域 + +#### 1、HTTPS/SSL 证书 + +Web 应用的黄金标准是使用 SSL 证书的 HTTPS 协议。[Let's Encrypt][2] 可以帮你达到这一目的。Let's Encrypt 来自于非营利性的互联网安全研究小组(ISRG),它是一个免费的、自动化的、开放的证书颁发机构。 + +Let's Encrypt 的软件会为你的域(LCTT 译注:包含域名、IP 等信息)生成中央授权证书。而正是这些证书确保了从你的 API 到客户端的数据载荷是点对点加密的。 + +Let's Encrypt 支持证书管理的多种部署方案。我们可以通过查看 [文档][3] 来找出最适合自己需要的方案。 + +#### 2、跨域资源共享 + +跨域资源共享Cross-origin resource sharing(CORS)是一个针对浏览器的安全策略预检。如果你的 API 服务器与发出请求的客户端不在同一个域中,那么你就要处理 CORS。例如,如果你的服务器运行在 `api.domain-a.com` 并且接到一个来自 `domain-b.com` 的客户端的请求,那么 CORS 就会(让浏览器)发送一个 HTTP 预检请求,以便查看你的 API 服务是否会接受来自此客户域的客户端请求。 + +[来自 MDN 的定义][4]: + +> “跨域资源共享(CORS)是一种基于 HTTP 头的机制,这种机制允许服务器标记除自身源外的其他任何来源(域、方案或端口)。而对于这些被服务器标识的源,浏览器应该允许我们从它们加载资源。” + +![CORS 原理][5] + +*([MDN文档][4], [CC-BY-SA 2.5][6])* + +另外,有很多用于 [Node.js][7] 的辅助库来 [帮助 API 开发者处理 CORS][8]。 + +#### 3、身份认证与 JSON Web 令牌 + +有多种方法可以验证你的 API 中的认证用户,但最好的方法之一是使用 JSON Web 令牌(JWT),而这些令牌使用各种知名的加密库进行签名。 + +当客户端登录时,身份管理服务会向客户端提供一个 JWT。然后,客户端可以使用这个令牌向 API 发出请求,API 收到请求后,从服务器读取公钥或私密信息来验证这个令牌。 + +有一些现有的库,可以帮助我们对令牌进行验证,包括 [jsonwebtoken][9]。关于 JWT 的更多信息,以及各种语言中对其的支持库,请查看 [JWT.io][10]。  + +``` +import jwt from 'jsonwebtoken' + +export default function (req, res, next) { + // req.headers.authorization Bearer token + const token = extractToken(req) + jwt.verify(token, SECRET, { algorithms: ['HS256'] }, (err, decoded) => { + if (err) { next(err) } + req.session = decoded + next() + }) +} +``` + +#### 4、授权与作用域 + +认证(或身份验证)很重要,但授权同样很重要。也就是说,经过验证的客户端是否有权限让服务器执行某个请求呢?这就是作用域的价值所在。当身份管理服务器对客户端进行身份认证,且创建 JWT 令牌时,身份管理服务会给当前客户提供一个作用域,这个作用域将会决定当前经过验证的客户的 API 请求能否被服务器执行。这样也就免去了服务器对访问控制列表的一些不必要的查询。 + +作用域是一个文本块(通常以空格分隔),用于描述一个 API 端点的访问能力。一般来说,作用域被分为资源与动作。这种模式对 REST/JSON API 很有效,因为它们有相似的 `RESOURCE:ACTION` 结构。(例如,`ARTICLE:WRITE` 或 `ARTICLE:READ`,其中 `ARTICLE` 是资源,`READ` 和 `WRITE` 是动作)。 + +作用域的划分让我们的 API 能够专注于功能的实现,而不是去考虑各种角色和用户。身份访问管理服务可以将不同的角色和用户分配不同的权限范围,然后再将这些不同的作用域提供给不同的 JWT 验证中的客户。 + +#### 总结 + +当我们开发和部署 API 时,安全应该一直是最重要的要求之一。虽然安全性是一个比较宽泛的话题,但如果能解决上面四个方面的问题,这对于你的 API 来说,在生产环境中将会表现得更好。 + +### 文档 + +_有什么能比没有文档更糟糕?过期的文档。_ + +开发者对文档真的是又爱又恨。尽管如此,文档仍然是 API 定义是否完善的一个关键部分。开发者需要从文档中知道如何使用这些 API,且你创建的文档对于开发者如何更好地使用 API 也有着非常巨大的作用。 + +创建 API 文档,我们需要关注下面三个方面: + + 1. 开发者入门文档(自述文件/基本介绍) + 2. 技术参考(规范/说明书) + 3. 使用方法(入门和其他指南) + +#### 1、入门文档 + +在构建 API 服务的时候,你需要明确一些事情,比如:这个 API 是做什么的?如何建立开发者环境?如何测试该服务?如何提交问题?如何部署它? + +通常我们可以通过自述(`README`)文件来回答上面的这些问题,自述文件一般放在你的代码库中,用于为开发者提供使用你项目的最基本的起点和说明。 + +自述文件应该包含: + + * API 的描述 + * 技术参考与指南的链接 + * 如何以开发者的身份设置你的项目 + * 如何测试这个项目 + * 如何部署这个项目 + * 依赖管理 + * 代码贡献指南 + * 行为准则 + * 许可证 + * 致谢 + +你的自述文件应该简明扼要;你不必解释每一个方面,但要提供足够的信息,以便开发者在熟悉你的项目后可以进一步深入研究。 + +#### 2、技术参考 + +在 REST/JSON API 中, 每一个具体的端点endpoint都对应一个特定的功能,都需要一个具体的说明文档,这非常重要。文档中会定义 API 的描述,输入和可能的输出,并为各种客户端提供使用示例。 + +[OpenAPI][13] 是一个创建 REST/JSON 文档的标准, 它可以指导你完成编写 API 文档所需的各种细节。OpenAPI 还可以为你的 API 生成演示文档。 + +#### 3、使用方法 + +对于 API 的用户来说,仅仅只有技术说明是不够的。他们还需要知道如何在一些特定的情况和场景下来使用这些 API,而大多数的潜在用户可能希望通过你的 API 来解决他们所遇到的问题。 + +向用户介绍 API 的一个好的方法是利用一个“开始”页面。“开始”页面可以通过一个简单的用例引导用户,让他们迅速了解你的 API 能给他们能带来的益处。 + +#### 总结 + +对于任何完善的 API,文档都是一个很关键的组成部分。当你在创建文档时,你需要关注 API 文档中的如何入门、技术参考以及如何快速开始等三个方面,这样你的 API 才算是一个完善的 API。 + +### 验证 + +API 开发过程中经常被忽视的一个点就是验证。它是一个验证来自外部来源的输入的过程。这些来源可以是客户端发送过来的 JSON 数据,或者是你请求别人的服务收到的响应数据。我们不仅仅要检查这些数据的类型,还要确保这些数据确实是我们要的数据,这样可以消除很多潜在的问题。了解你的边界以及你能控制的和不能控制的东西,对于 API 的数据验证来说是一个很重要的方面。 + +最好的策略是在进入数据逻辑处理之前,在你能控制的边界的边缘处进行数据的验证。当客户端向你的 API 发送数据时,你需要对该数据做出任何处理之前应用你的验证,比如:确保 Email 是真实的邮件地址、日期数据有正确的格式、字符串符合长度要求。 + +这种简单的检查可以为你的应用增加安全性和一致性。还有,当你从某个服务接收数据时,比如数据库或缓存,你需要重新验证这些数据,以确保返回的结果符合你的数据检查。 + +你可以自己手写这些校验逻辑,当然也可以用像 [Lodash][14] 或 [Ramda][15] 这样的函数库,它们对于一些小的数据对象非常有用。像 [Joi][16]、[Yup][17] 或 [Zod][18] 这样的验证库效果会更好,因为它们包含了一些常见的验证方法,可以节省你的时间和精力。除此,它们还能创建一个可读性强的模式。如果你需要看看与语言无关的东西,请看 [JSON Schema][19]。 + +#### 总结 + +数据验证虽然并不显眼和突出(LCTT 译注:跟 API 的功能实现以及其他几个方面比),但它可以帮你节省大量的时间。如果不做验证,这些时间将可能被用于故障排除和编写数据迁移脚本。真的不要相信你的客户端会发送干净的数据给你,也不要让验证不通过的数据渗入到你的业务逻辑或持久数据存储中去。花点时间验证你的 API 收到的数据和请求到的响应数据,虽然在前期你可能会感到一些挫折和不适,但这总比你在后期花大量时间去做各种数据收紧管制、故障排除等要容易得多。 + +### 测试 + +测试是软件开发中的最佳实践,它应该是最主要的非功能性的要求。对于包括 API 在内的任何项目,确定测试策略都是一个挑战,因为你自始至终都要掌握各种约束,以便相应的来制定你的测试策略。 + +集成测试Integration testing是测试 API 的最有效的方法之一。在集成测试模式中,开发团队会创建一个测试集用来覆盖应用流程中的某些部分,从一个点到另一个点。一个好的集成测试流程包括测试 API 的入口点以及模拟请求到服务端的响应。搞定这两点,你就覆盖了整个逻辑,包括从 API 请求的开始到模拟服务器的响应,并返回数据给 API。 + +虽然使用的是模拟,但这种方法让能我们专注于代码逻辑层,而不需要去依赖后端服务和展示逻辑来进行测试。没有依赖的测试会更加可靠、更容易实现自动化,且更容易被接入持续集成管道流。 + +集成测试的实施中,我会用 [Tape][20]、[Test-server][21] 和 [Fetch-mock][22]。这些库让我们能够从 API 的请求到数据的响应进行隔离测试,使用 Fetch-mock 还可以将出站请求捕获到持久层。 + +#### 总结 + +虽然其他的各种测试和类型检查对 API 也都有很好的益处,但集成测试在流程效率、构建和管理时间方面却有着更大的优势。使用 Fetch-mock 这样的工具,可以在服务边界提供一个干净的模拟场景。 + +### 专注于基础 + +不管是设计和构建应用程序还是 API,都要确保包含上面的四个基本要素。它们并不是我们唯一需要考虑的非功能性需求,其他的还包括应用监控、日志和 API 管理等。即便如此,安全、文档、验证和测试这四个基本点,对于构建任何使用场景下的完善 API 都是至关重要的关注点。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/5/successful-apis + +作者:[Tom Wilson][a] +选题:[lujun9972][b] +译者:[ywxgod](https://github.com/ywxgod) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/tomwillson4014 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tips_map_guide_ebook_help_troubleshooting_lightbulb_520.png?itok=L0BQHgjr (Looking at a map) +[2]: https://letsencrypt.org/ +[3]: https://letsencrypt.org/docs/ +[4]: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS +[5]: https://opensource.com/sites/default/files/uploads/cors_principle_1.png (CORS principles) +[6]: https://creativecommons.org/licenses/by-sa/2.5/ +[7]: https://nodejs.org +[8]: https://www.npmjs.com/search?q=CORS +[9]: https://github.com/auth0/node-jsonwebtoken +[10]: https://jwt.io +[11]: https://opensource.com/sites/default/files/uploads/jwt-verify-example.png (JWT verification example) +[12]: https://blog.hyper63.com/content/images/2021/03/jwt-verify-example.png +[13]: https://spec.openapis.org/oas/v3.1.0 +[14]: https://lodash.com +[15]: https://ramdajs.com/ +[16]: https://joi.dev/ +[17]: https://github.com/jquense/yup +[18]: https://github.com/colinhacks/zod/tree/v3 +[19]: https://json-schema.org/ +[20]: https://github.com/substack/tape +[21]: https://github.com/twilson63/test-server +[22]: http://www.wheresrhys.co.uk/fetch-mock/ diff --git a/published/20210518 Are you using this magic method for filesystems from Python 3.6.md b/published/202106/20210518 Are you using this magic method for filesystems from Python 3.6.md similarity index 100% rename from published/20210518 Are you using this magic method for filesystems from Python 3.6.md rename to published/202106/20210518 Are you using this magic method for filesystems from Python 3.6.md diff --git a/published/202106/20210518 Manage your Raspberry Pi with Cockpit.md b/published/202106/20210518 Manage your Raspberry Pi with Cockpit.md new file mode 100644 index 0000000000..d64b731d9a --- /dev/null +++ b/published/202106/20210518 Manage your Raspberry Pi with Cockpit.md @@ -0,0 +1,152 @@ +[#]: subject: (Manage your Raspberry Pi with Cockpit) +[#]: via: (https://opensource.com/article/21/5/raspberry-pi-cockpit) +[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss) +[#]: collector: (lujun9972) +[#]: translator: (ShuyRoy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13487-1.html) + +使用 Cockpit 管理你的树莓派 +====== + +> 用 Cockpit 建立你的树莓派的控制中心。 + +![](https://img.linux.net.cn/data/attachment/album/202106/15/144053hmswm01w6qus011n.jpg) + +去年,我写了关于使用 [Cockpit 管理我的 Linux 服务器的文章][2]。它是一个基于 Web 的工具,为管理多个服务器及其相关的服务和应用提供了一个简洁、强大的界面。它还简化了日常的管理任务。 + +在这篇文章中,我将会介绍如何在树莓派基金会提供的标准操作系统树莓派 OS 上安装用于 Linux 服务器的 Cockpit Web 控制台。我还会简要介绍它的特性。 + +### 在树莓派 OS 上安装 Cockpit + +在 `sudo` 权限下使用一个账户通过 SSH 登录你的树莓派系统。如果你还没有建立一个账户: + +``` +$ ssh pibox +alan@pibox's password: +Linux pibox.someplace.org 5.10.17-v7+ #1403 SMP Mon Feb 22 11:29:51 GMT 2021 armv7l + +The programs included with the Debian GNU/Linux system are free software; +the exact distribution terms for each program are described in the +individual files in /usr/share/doc/*/copyright. + +Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent +permitted by applicable law. +Last login: Tue May  4 09:55:57 2021 from 172.1.4.5 +alan@pibox:~ $ +``` + +在树莓派 OS 上安装 Cockpit Web 控制台和在 Linux 服务器上一样简单: + +``` +$ sudo apt install cockpit +``` + +Cockpit 只需要 60.4 KB 的磁盘空间。加上它的几个包依赖项,总使用量是 115MB。 + +安装过程将负责设置和启动服务。你可以使用 `systemctl` 命令来验证状态: + +``` +$ systemctl status cockpit.socket +● cockpit.socket - Cockpit Web Service Socket +   Loaded: loaded (/lib/systemd/system/cockpit.socket; enabled; vendor preset: enabled) +   Active: active (listening) since Tue 2021-05-04 10:24:43 EDT; 35s ago +     Docs: man:cockpit-ws(8) +   Listen: 0.0.0.0:9090 (Stream) +  Process: 6563 ExecStartPost=/usr/share/cockpit/motd/update-motd  localhost (code=exited, status=0/SUCCESS) +  Process: 6570 ExecStartPost=/bin/ln -snf active.motd /run/cockpit/motd (code=exited, status=0/SUCCESS) +    Tasks: 0 (limit: 2181) +   CGroup: /system.slice/cockpit.socket +``` + +### 使用 Cockpit + +#### 连接 + +默认的监听端口号是 9090。打开你最喜欢的 Web 浏览器并输入地址,例如: `https://pibox:9090`。 + +![Cockpit home page][3] + +你现在可以使用你的普通账户登录。同样,这个账户上需要有使用 `sudo` 的权限 —— 很可能就是你用来 SSH 和运行 Apt 的那个账户。一定要勾选“为特权任务重用我的密码”。 + +#### 管理你的树莓派 + +Cockpit 的初始屏幕以 “System” 页开始,提供当前 CPU 和内存使用的详细信息和图表。 + +![Initial Cockpit screen][5] + +你可以从这个屏幕看到硬件细节。 + +![Cockpit hardware details][6] + +通过点击每一项来展开左边的列(例如,日志、存储、服务等)。这些是标准的 Cockpit 部分,不言自明。让我快速描述一下每个部分。 + +#### 日志 + +这部分展示了日志。它们可以根据日期和严重程度来过滤。 + +#### 存储 + +存储部分展示了已经安装的物理驱动器和 RAID 设备。例如大小、序列号等细节都被展示了出来。还展示了读/写活动和实际空间使用的图表。存储的具体日志显示在底部。 + +#### 网络 + +这部分展示了发送和接收活动、IP 地址以及网络特定的日志。你还可以使用相应的按钮添加更多的网络设备,如绑定、网桥和 VLAN。 + +#### 账户 + +这里展示了已有的账户。点击每个账户来管理,或使用创建新账户按钮来添加用户。账户也可以被删除。 + +#### 服务 + +这部分可以让管理员查看系统所有服务的状态。点击任何服务都会转到一个包含启动、重启和禁用的标准任务的屏幕。 + +#### 应用程序 + +通常,这个屏幕提供了各种用于管理功能的应用程序,例如 389 目录服务器或创建 Podman 容器。但在我的树莓派 OS 上,这个屏幕只显示“没有安装或可用的应用程序”。在写这篇文章的时候,这个或许还没有实现。虽然,你可能会怀疑这类型的程序对于树莓派硬件来说是否太过沉重。 + +#### 软件更新 + +对任何系统管理员来说,保持软件最新是最重要的任务之一。Cockpit 的软件更新部分可以检查并进行更新。 + +![Software updates in Cockpit][7] + +#### 终端 + +Cockpit 最方便的特点之一是终端。你可以使用它,而不是打开一个单独的终端模拟器并使用 SSH。我使用终端来安装 [ScreenFetch][8]: + +``` +$ sudo apt install screenfetch +``` + +使用 ScreenFetch 生成了这张截图: + +![Terminal in Cockpit][9] + +### 使用 Cockpit 的中心控制 + +Cockpit 在树莓派上的表现就像它在其他 Linux 系统上一样。你可以将它添加到仪表盘上进行集中控制。它允许企业在 Cockpit 作为管理仪表盘解决方案的任何地方,将基于树莓派的服务和系统整合到他们的整体 Linux 基础设施中。因为树莓派经常在高密度机架数据中心以无外接控制headless方式运行,而这些数据中心通常会缺乏 KVM 访问方式,这是非常方便的。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/5/raspberry-pi-cockpit + +作者:[Alan Formy-Duval][a] +选题:[lujun9972][b] +译者:[RiaXu](https://github.com/ShuyRoy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alanfdoss +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberrypi_kuberenetes_cluster_lead2_0.jpeg?itok=kx0Zc0NK (Neon colorized Raspberry Pi cluster with LEGOs) +[2]: https://opensource.com/article/20/11/cockpit-server-management +[3]: https://opensource.com/sites/default/files/uploads/cockpit_homepage.png (Cockpit home page) +[4]: https://creativecommons.org/licenses/by-sa/4.0/ +[5]: https://opensource.com/sites/default/files/uploads/cockpit_initialscreen.png (Initial Cockpit screen) +[6]: https://opensource.com/sites/default/files/uploads/hardware_details.png (Cockpit hardware details) +[7]: https://opensource.com/sites/default/files/uploads/software_updates.png (Software updates in Cockpit) +[8]: https://opensource.com/article/20/1/screenfetch-neofetch +[9]: https://opensource.com/sites/default/files/uploads/pi_cockpit_terminal.png (Terminal in Cockpit) diff --git a/published/20210519 Slice infinite generators with this Python 3.7 feature.md b/published/202106/20210519 Slice infinite generators with this Python 3.7 feature.md similarity index 100% rename from published/20210519 Slice infinite generators with this Python 3.7 feature.md rename to published/202106/20210519 Slice infinite generators with this Python 3.7 feature.md diff --git a/published/20210520 Make your API better with this positional trick from Python 3.8.md b/published/202106/20210520 Make your API better with this positional trick from Python 3.8.md similarity index 100% rename from published/20210520 Make your API better with this positional trick from Python 3.8.md rename to published/202106/20210520 Make your API better with this positional trick from Python 3.8.md diff --git a/translated/tech/20210521 How Python 3.9 fixed decorators and improved dictionaries.md b/published/202106/20210521 How Python 3.9 fixed decorators and improved dictionaries.md similarity index 68% rename from translated/tech/20210521 How Python 3.9 fixed decorators and improved dictionaries.md rename to published/202106/20210521 How Python 3.9 fixed decorators and improved dictionaries.md index 1b0a407c4f..6f4a929d87 100644 --- a/translated/tech/20210521 How Python 3.9 fixed decorators and improved dictionaries.md +++ b/published/202106/20210521 How Python 3.9 fixed decorators and improved dictionaries.md @@ -3,40 +3,40 @@ [#]: author: (Moshe Zadka https://opensource.com/users/moshez) [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13477-1.html) Python 3.9 如何修复装饰器并改进字典 ====== -探索最近版本的 Python 的一些有用的特性。 -![Python in a coffee cup.][1] -这是关于首次出现在 Python 3.x 版本中的特性的系列文章中的第十篇,其中一些版本已经发布了一段时间。Python 3.9 在 2020 年首次发布,具有很酷的新特性,但仍未被充分利用。下面是其中的三个。 +> 探索最近版本的 Python 的一些有用的特性。 + +![](https://img.linux.net.cn/data/attachment/album/202106/12/115315xrnd4evse8uzpi8i.jpg) + +这是 Python 3.x 首发特性系列文章中的第十篇,其中一些版本已经发布了一段时间。Python 3.9 在 2020 年首次发布,具有很酷的新特性,但仍未被充分利用。下面是其中的三个。 ### 添加字典 -假设你有一个 “defaults” 字典,而你想更新它的参数。在 Python 3.9 之前,最好的办法是复制 defaults 字典,然后使用 `.update()` 方法。 +假设你有一个 `defaults` 字典,而你想更新它的参数。在 Python 3.9 之前,最好的办法是复制 `defaults` 字典,然后使用 `.update()` 方法。 Python 3.9 为字典引入了联合运算符: - ``` defaults = dict(who="someone", where="somewhere") params = dict(where="our town", when="today") defaults | params - -``` -``` -` {'who': 'someone', 'where': 'our town', 'when': 'today'}` ``` -注意,顺序很重要。在这种情况下,来自 `params` 的 `where ` 值覆盖了默认值,因为它应该如此。 +``` + {'who': 'someone', 'where': 'our town', 'when': 'today'} +``` + +注意,顺序很重要。在这种情况下,正如预期,来自 `params` 的 `where` 值覆盖了默认值。 ### 删除前缀 -如果你用 Python 做了临时的文本解析或清理,你会写出这样的代码: - +如果你用 Python 做临时的文本解析或清理,你会写出这样的代码: ``` def process_pricing_line(line): @@ -44,25 +44,27 @@ def process_pricing_line(line): return line[len("pricing:"):] return line process_pricing_line("pricing:20") +``` ``` -``` -` '20'` + '20' ``` 这样的代码很容易出错。例如,如果字符串被错误地复制到下一行,价格就会变成 `0` 而不是 `20`,而且会悄悄地发生。 从 Python 3.9 开始,字符串有了一个 `.lstrip()` 方法: +``` +"pricing:20".lstrip("pricing:") +``` ``` -`"pricing:20".lstrip("pricing:")`[/code] [code]` '20'` + '20' ``` ### 任意的装饰器表达式 -以前,关于装饰器中允许哪些表达式的规则没有得到充分的记录,而且很难理解。例如:虽然 - +以前,关于装饰器中允许哪些表达式的规则没有得到充分的说明,而且很难理解。例如:虽然 ``` @item.thing @@ -72,7 +74,6 @@ def foo(): 是有效的,而且: - ``` @item.thing() def foo(): @@ -81,7 +82,6 @@ def foo(): 是有效的,相似地: - ``` @item().thing def foo(): @@ -92,7 +92,6 @@ def foo(): 从 Python 3.9 开始,任何表达式作为装饰器都是有效的: - ``` from unittest import mock @@ -102,10 +101,10 @@ item = mock.MagicMock() def foo(): pass print(item.return_value.thing.call_args[0][0]) +``` ``` -``` -` ` + ``` 虽然在装饰器中保持简单的表达式仍然是一个好主意,但现在是人类的决定,而不是 Python 分析器的选择。 @@ -121,7 +120,7 @@ via: https://opensource.com/article/21/5/python-39-features 作者:[Moshe Zadka][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/202106/20210523 3 reasons to learn Java in 2021.md b/published/202106/20210523 3 reasons to learn Java in 2021.md new file mode 100644 index 0000000000..fbbf2c5e53 --- /dev/null +++ b/published/202106/20210523 3 reasons to learn Java in 2021.md @@ -0,0 +1,89 @@ +[#]: subject: (3 reasons to learn Java in 2021) +[#]: via: (https://opensource.com/article/21/5/java) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: (PearFL) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13491-1.html) + +2021 年学习 Java 的三个理由 +====== + +> Java 具有功能强大、多样化、可拓展、有趣的特点。这就是 Java 为什么被我们广泛使用,也是我们如何正确使用它的方式。 + +![](https://img.linux.net.cn/data/attachment/album/202106/16/122019wdrbtby3dlf9uu49.jpg) + +Java 是在 1995 年发布的,当我写这篇文章的时候,它已经 26 岁了。起初它是专有的,但在 2007 年,Java 基于 GPL 协议被开源发布了。如果想要理解是什么使得 Java 变得非常重要,你就必须理解它声称要解决的是什么样的问题,从而你就能理解它让开发者和用户受益的原因和方式。 + +理解 Java 解决了什么问题的最好方式就是进行软件开发,当然啦,如果不做开发,仅仅只是使用软件也会是一个很好的开始。作为一名开发人员,当你将在自己的本地计算机上运行良好的软件部署到其他计算机上运行时,一些稀奇古怪的麻烦可能就出现了,从而导致软件可能无妨正常运行。软件本应正常工作,但每个程序员都明白,一些问题总是会被忽视。当你在另一个操作系统上尝试运行该软件时,情况就变得更加复杂了。这也是为什么在每一个软件的获取页面上都会有针对不同的操作系统有对应下载按钮的原因:Windows 的、macOS 的、Linux 的、移动端的、甚至许多其他操作系统环境的下载选项。 + +作为一名用户,一个典型的场景是你想下载一些优秀的软件,但它却不适用于你的平台。遗憾的是这样的情况仍然发生在当下非常先进的计算机上,它们可以在计算机中运行虚拟机,通过仿真使老式视频游戏保持活力,甚至可以放在你的口袋里,但软件交付实际上相当困难。 + +有没有更好的办法?可能会有吧。 + +### 1、一次编码,任意环境都能跑通 + +令人惊讶甚至是失望的是,代码是特定于操作系统和环境的。代码需要从对人友好的高级程序设计语言编译成机器语言,即被设计可以用于让 CPU 响应的一系列二进制指令。在先进的计算机世界中,我们很难理解为什么不能仅仅只要编写代码,就能将它发送给任何一个想要运行它的平台,无需担忧它们正处在什么样的平台中。 + +Java 可以解决这种不协调的问题。它的代码是可以跨平台进行工作的,在任何运行它的系统上都执行相同的工作。Java 实现这一壮举的方法起初是有悖常理的。在某种程度上,Java 只与一台计算机兼容。奇怪的是,这台电脑实际上并不存在。Java 代码的目标计算机是Java 虚拟机(JVM)。这是一个由 Java 的创建者编写的程序,可用于你能想到的任何计算机设备。只要你安装了它,你运行的任何 Java 代码都会由你计算机中的这台“虚拟”计算机进行处理。Java 代码会由 JVM 执行,JVM 向你的计算机发送适当的特定于平台的指令,因此所有工作在每个操作系统和架构上都是一样的。 + +当然,Java 使用的方法并不是这里的真正的卖点。大多数用户和许多开发人员并不关心软件兼容性是如何实现的,只关心它是否具备兼容性。许多语言都承诺提供跨平台的功能,通常情况下,这个承诺最终都是真的,但是这个过程并不总是容易实现的。编程语言必须针对其目标平台进行编译,脚本语言需要特定于平台的解释器,而且两者都很难确保对底层系统资源的一致访问。跨平台支持变得越来越好,库可以帮助转换路径、环境变量和设置,并且一些框架(特别是 [Qt][2])在弥补外设访问的差距方面做了很多工作。但是,Java 始终可靠地提供它的兼容性。 + +### 2、明智的代码 + +Java 的语法即使是在最好的方面也很无聊。如果你把所有流行的编程语言都放在一个摇滚杯中,那么你会得到 Java。通过观察 Java 编写的源代码,你或多或少会均匀地看到所有特定的编程表达方式。括号表示函数和流程控制的范围、变量在使用前被明确地声明和实例化,并且表达式具有清晰一致的结构。 + +我发现 Java 学习过程中通常会鼓励自学成才的程序员使用结构化程度较少的语言编写更精炼的代码。从网上学习的源代码中收集到的技术中,有许多“基本”编程经验是你无法学到的,比如以 Java 公开字段的风格进行全局变量声明、正确地预测和处理异常、使用类和函数、和许多其他的技术。从 Java 借鉴的一点小改动可以产生很大的不同。 + +### 3、脚手架和支持 + +流行的编程语言都有很好的支持系统,这也是使得其变成流行语言的原因。它们都有很多文档资料,有针对它们的集成开发环境或 IDE 扩展、示例代码、免费和付费培训和开发者社区。在另一方面,当你在尝试做某事遇到困难时,似乎没有任何编程语言有足够的支持。 + +我不能说 Java 可以摆脱这两个普遍但又相互矛盾的事实。尽管如此,我发现当我需要一个 Java 库时,我必然能为给定的任务找到多个选项。通常我不想使用一个库的原因是我不喜欢它的开发人员如何实现我需要的功能,它的许可证与我喜欢的有所不同,或者有其他琐碎的争议点。当一门语言得到大量支持时,我就会很多的选择性。我可以从许多合适的解决方案中选择一个最能满足我需求的,不论我的需求多么微不足道都能被最好得满足。 + +更好的是,围绕 Java 有一个健康的基础设施。像 [Apache Ant][3]、[Gradle][4] 和 [Maven][5] 等工具可以帮助管理构建和交付的过程。像 [Sonatype Nexus][6] 等服务帮助实现监控的安全性。[Spring][7] 和 [Grails][8] 使 Web 开发变得更加容易,而 [Quarkus][9] 和 [Eclipse Che][10] 有助于云上的开发。 + +在接触 Java 语言本身时,你甚至可以选择使用什么样的版本。[OpenJDK][11] 提供经典的、官方的 Java,而 [Groovy][12] 是一种类似于脚本语言的简化方法(你可以把它比作 Python),而 [Quarkus][13] 提供了一个容器优先开发的框架。 + +还有很多,但现在已经足以说明 Java 是一个完整的生态了,无论你想在其中寻找什么。 + +### 此外,简单易学 + +事实证明,Java 对我和各行各业的许多开发人员来说是一个明智的解决方案。以下是我喜欢使用 Java 的一些原因。 + +你可能听说过或推断出 Java 是一种“专业”语言,只适用于笨重的政府网站,专供“真正的”开发人员使用。千万不要被 Java 25 年以来的各种名声所迷惑!它的可怕程度只有它名声的一半,这意思是,并不比其他任何语言更可怕。 + +编程很困难的这件事是无法回避的,它要求你基于逻辑进行思考,学习一种比母语表达方式更少的新语言,要你弄清楚如何解决困难的问题,使它们可以使用你的程序完成自动化的执行,没有语言可以避免这些问题。 + +然而,编程语言的学习曲线的差异令人惊讶。有些一开始很容易,但当你开始探索细节时就会变得复杂。换句话说,打印“hello world”可能只需要一行代码,但当你学习到了类和函数, 你相当于开始重新学习这门语言(或者至少是它的数据模型)。Java 从一开始就是 Java,一旦你学会了它,就可以使用它的许多技巧和便利。 + +简而言之: 去学习 Java 吧!它具有功能强大、多样化、可拓展、有趣的特点。为了给你提供帮助, [下载我们的 Java 备忘单][14], 它包含你在开发前十个项目时需要的所有基本语法。在那之后,你就不再需要它了,因为 Java 具有完美的一致性和可预测性。来享受它吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/5/java + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[PearFL](https://github.com/PearFL) +校对:[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/studying-books-java-couch-education.png?itok=C9gasCXr (Learning and studying technology is the key to success) +[2]: http://qt.io +[3]: https://ant.apache.org/ +[4]: https://gradle.org +[5]: https://spring.io/guides/gs/maven +[6]: https://www.sonatype.com/products/repository-pro +[7]: http://spring.io +[8]: https://grails.org +[9]: https://opensource.com/article/21/4/quarkus-tutorial +[10]: https://opensource.com/article/19/10/cloud-ide-che +[11]: http://adoptopenjdk.net +[12]: https://opensource.com/article/20/12/groovy +[13]: https://developers.redhat.com/products/quarkus/getting-started +[14]: https://opensource.com/downloads/java-cheat-sheet diff --git a/published/20210524 How to Install and Use XRDP on Ubuntu for Remote Desktop Connection.md b/published/202106/20210524 How to Install and Use XRDP on Ubuntu for Remote Desktop Connection.md similarity index 100% rename from published/20210524 How to Install and Use XRDP on Ubuntu for Remote Desktop Connection.md rename to published/202106/20210524 How to Install and Use XRDP on Ubuntu for Remote Desktop Connection.md diff --git a/published/202106/20210526 How I monitor my greenhouse with CircuitPython and open source tools.md b/published/202106/20210526 How I monitor my greenhouse with CircuitPython and open source tools.md new file mode 100644 index 0000000000..1248ca1e70 --- /dev/null +++ b/published/202106/20210526 How I monitor my greenhouse with CircuitPython and open source tools.md @@ -0,0 +1,276 @@ +[#]: subject: (How I monitor my greenhouse with CircuitPython and open source tools) +[#]: via: (https://opensource.com/article/21/5/monitor-greenhouse-open-source) +[#]: author: (Darin London https://opensource.com/users/dmlond) +[#]: collector: (lujun9972) +[#]: translator: (alim0x) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13504-1.html) + +我如何用 CircuitPython 和开源工具监控温室 +====== + +> 使用微控制器、传感器、Python 以及 MQTT 持续追踪温室的温度、湿度以及环境光。 + +![种有西红柿的温室花园][1] + +CircuitPython 提供了一种和微控制器板进行交互的革命性方式。这篇文章介绍了如何使用 CircuitPython 来监测温室的温度、湿度以及环境光,并且使用 CircuitPython MQTT 客户端将结果发布到一个 [MQTT][2] 中介broker。你可以在若干个程序中订阅 MQTT 队列并进一步处理信息。 + +这个项目使用一个简单的 Python 程序来运行 Web 服务器,它发布一个 Prometheus 格式的采集端点,拉取监控指标到 [Prometheus][3] 进行不间断的监控。 + +### 关于 CircuitPython + +[CircuitPython][4] 是一个由 [Adafruit][5] 创建的开源 Python 发行版,用于运行在低成本微控制器开发板上。CircuitPython 为与 [兼容的开发板][6] 的交互提供了简单的开发体验。你可以在连接你的开发板时挂载的 `CIRCUITPYTHON` 根驱动器上创建一个 `code.py` 文件来启动你的程序。CircuitPython 还为开发板提供了一个串行连接,包含一个交互式解释器(REPL)会话,你可以使用 Python 代码实时和开发板进行交互。 + +Adafruit 的网站提供了大量的文档,可以帮助你开始使用 CircuitPython。首先,参考下《[欢迎来到 CircuitPython][7]》指南。这份指南能够帮助你开始使用 CircuitPython 在开发板上运行代码以及和 REPL 交互。它还记录了如何安装 Adafruit 的 CircuitPython 库合集和范例,可以用在它出售的许多开发板和传感器上。接下来,阅读《[CircuitPython 基础][8]》指南来学习更多关于其功能的信息,里面还有链接指向在特定及兼容的开发板上使用 CircuitPython 的相关信息。最后,就如所有开源软件一样,你可以深入 [CircuitPython 的源码][9],发布议题,以及做出贡献。 + +### 微控制器设置 + +微控制器系统非常简单。要完成这个示例项目,你会需要: + + * **树莓派 4**:你需要一台电脑来给微控制器系统编程,我用的是树莓派 4。 + * **CircuitPython 兼容的微控制器**:我用的是 [Adafruit Feather S2][10],带有内置 WiFi,环境光传感器,Qwiic 线缆输入。 + * **微控制器 WiFi**:Feather S2 内置了 WiFi。如果你的微控制器没有,你需要给开发板找个 WiFi 扩展板。 + * **传感器**:Feather S2 有个内置的环境光传感器,所以我还需要一个温湿度传感器。有很多不同厂商的产品可以选择,包括 Adafruit、SparkFun、亚马逊。我用的是一个 [Adafruit 传感器][11],带有 Feather S2 输入兼容的 Qwiic 线缆。尽管多数 SparkFun 传感器可以在 Adafruit 库下工作,但如果你不是从 Adafruit 购买的传感器,你可能还是需要自己去找到它兼容 CircuitPython 的 Python 库。 + * **跳线和线缆**:为了避免使用面包板或焊接,我使用 [Adafruit Qwiic 线缆][12]。SparkFun 销售的包含不同长度的[线缆套装][13]中也有它。 + +在将微控制器连接到你的电脑之前,将传感器连接到微控制器上。 + +![将传感器连接到微控制器上][14] + +现在你可以将微控制器用 USB 数据线连接到你的电脑。 + +### MQTT 中介 + +你可以使用 [这份说明][16] 来在树莓派的系统上安装 [Mosquitto MQTT 中介][17] 和 Mosquitto 客户端。如果你想把树莓派做为长期服务器使用,在你的网络上给树莓派 4 设置一个静态 IP 地址。Mosquitto 中介运行起来之后,创建一份 [用户名/密码文件][18],设置客户端向中介发布和订阅消息时用的认证信息。 + +你可以用树莓派上的 Mosquitto 客户端来测试 MQTT 中介。打开两个终端(如果你是无界面运行的话打开两个 SSH 会话): + +在终端一输入: + +``` +mosquitto_sub -h localhost -u $user -P $pass -t "mqtt/test" +``` + +这条命令会启动一个持续运行的进程,监听发布到 `mqtt/test` 队列的消息。 + +在终端二输入: + +``` +mosquitto_pub -h localhost -u $user -P $pass -t "mqtt/test" -m hello` +``` + +这条命令会向 `mqtt/test` 队列发布一条消息,它应该会显示在终端一的输出里。 + +现在你可以中止终端一运行的 `sub` 命令了。 + +Mosquitto 中介允许客户端发布消息到任何队列,甚至没有任何订阅的队列也可以。这些消息会永久丢失,但这不会阻止客户端继续发布消息。 + +打开第三个终端,订阅下列队列(你的控制器会发布消息到这些队列上): + + * greenhouse/temperature + * greenhouse/light + * greenhouse/humidity + +### 给微控制器编码 + +现在你已经准备好给微控制器编码,发布它的监测指标到树莓派 4 上运行的 MQTT 中介上了。 + +Adafruit 有 [出色的文档][19],指导你使用 [CircuitPython 库合集][20] 的库来将你的微控制器连接到 WiFi 路由器,并发布监测指标到 MQTT 中介上。 + +安装下列库到 `CIRCUITPYTHON/lib` 目录,温室监控会用到它们。这些库在 Adafruit 的 CircuitPython 库合集中都有提供: + + * `adafruit_bus_device`:一个带有多个 .mpy 文件的 Python 包文件夹(.mpy 是经过压缩的 Python 文件,用以节省空间) + * `adafruit_requests`:单个 .mpy 文件 + * `adafruit_register`:一个包文件夹 + * `adafruit_minimqtt`:一个包文件夹 + * `adafruit_si7021`:单个 .mpy 文件,用来支持温湿度传感器 + +库装好了之后,将以下代码写入 `CIRCUITPYTHON` 文件夹的 `code.py` 文件中: + +``` +import time +import ssl +import socketpool +import wifi +import adafruit_minimqtt.adafruit_minimqtt as MQTT +import board +from digitalio import DigitalInOut, Direction, Pull +from analogio import AnalogIn +import adafruit_si7021 +  +# Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and +# "password" keys with your WiFi credentials. DO NOT share that file or commit it into Git or other +# source control. +# pylint: disable=no-name-in-module,wrong-import-order +try: +        from secrets import secrets +except ImportError: +        print("WiFi secrets are kept in secrets.py, please add them there!") +        raise +  +print("Connecting to %s" % secrets["ssid"]) +wifi.radio.connect(secrets["ssid"], secrets["password"]) +print("Connected to %s!" % secrets["ssid"]) +### Feeds ### +light_feed = "greenhouse/light" +temp_feed = "greenhouse/temperature" +humidity_feed = "greenhouse/humidity" +  +# Define callback methods which are called when events occur +# pylint: disable=unused-argument, redefined-outer-name +def connected(client, userdata, flags, rc): +        # This function will be called when the client is connected +        # successfully to the broker. +        print("Connected to MQTT!") +  +def disconnected(client, userdata, rc): +        # This method is called when the client is disconnected +        print("Disconnected from MQTT!") +  +  +def get_voltage(pin): +        return (pin.value * 3.3) / 65536 +  +# Create a socket pool +pool = socketpool.SocketPool(wifi.radio) +  +# Set up a MiniMQTT Client +mqtt_client = MQTT.MQTT( +        broker=secrets["broker"], +        port=secrets["port"], +        username=secrets["aio_username"], +        password=secrets["aio_key"], +        socket_pool=pool, +        ssl_context=ssl.create_default_context(), +) +  +# Setup the callback methods above +mqtt_client.on_connect = connected +mqtt_client.on_disconnect = disconnected +  +# Connect the client to the MQTT broker. +print("Connecting to MQTT...") +mqtt_client.connect() +  +# Create library object using our Bus I2C port +sensor = adafruit_si7021.SI7021(board.I2C()) +light_pin = AnalogIn(board.IO4) +  +while True: +        # Poll the message queue +        mqtt_client.loop() +  +        # get the current temperature +        light_val = get_voltage(light_pin) +        temp_val = ((sensor.temperature * 9)/5) + 32 +        humidity_val = sensor.relative_humidity +  +        # Send a new messages +        mqtt_client.publish(light_feed, light_val) +        mqtt_client.publish(temp_feed, temp_val) +        mqtt_client.publish(humidity_feed, humidity_val) +        time.sleep(0.5) +``` + +保存你的代码。然后连接到串行监视器,看程序连接到你的 MQTT 中介。你还可以将树莓派 4 上的终端切换到订阅了它的发布队列的终端来查看输出。 + +### 处理监测指标 + +像 MQTT 这样的发布/订阅工作流给微控制器系统提供了诸多好处。你可以有多个微控制器 + 传感器来回报同一个系统的不同指标或并行回报相同指标的若干读数。你还可以有多个不同进程订阅各个队列,并行地对这些消息进行回应。甚至还可以有多个进程订阅相同的队列,对消息做出不同的动作,比如数值过高时发送通知邮件或将消息发送到另一个 MQTT 队列上去。 + +另一个选项是让一个微控制器订阅一个外部队列,可以发送信号告诉微控制器做出动作,比如关闭或开始一个新会话。最后,发布/订阅工作流对低功耗微控制器系统更佳(比如那些使用电池或太阳能的系统),因为这些设备可以在更长的延迟周期后批量发布监测指标,并在回报的间隔期间关闭大量消耗电量的 WiFi 广播。 + +要处理这些监测指标,我创建了一个 Python 客户端,使用 [Paho Python MQTT 客户端][21] 订阅监测指标队列。我还使用官方的 [Prometheus Python 客户端][22] 创建了一个 Web 服务器,它产生一个符合 Prometheus 标准的采集端点,使用这些监测指标作为面板信息。[Prometheus 服务器][23]和 Mosquitto MQTT 中介我都是运行在同一个树莓派 4 上的。 + +``` +from prometheus_client import start_http_server, Gauge +import random +import time +import paho.mqtt.client as mqtt + +gauge = { +  "greenhouse/light": Gauge('light','light in lumens'), +  "greenhouse/temperature": Gauge('temperature', 'temperature in fahrenheit'), +  "greenhouse/humidity": Gauge('humidity','relative % humidity') +} + +try: +        from mqtt_secrets import mqtt_secrets +except ImportError: +        print("WiFi secrets are kept in secrets.py, please add them there!") +        raise + +def on_connect(client, userdata, flags, rc): +        print("Connected with result code "+str(rc)) +        # Subscribing in on_connect() means that if we lose the connection and +        # reconnect then subscriptions will be renewed. +        client.subscribe("greenhouse/light") +        client.subscribe('greenhouse/temperature') +        client.subscribe('greenhouse/humidity') + +def on_message(client, userdata, msg): +        topic = msg.topic +        payload = msg.payload +        gauge[topic].set(payload) + +client = mqtt.Client() +client.username_pw_set(mqtt_secrets["mqtt_user"],mqtt_secrets['mqtt_password']) +client.on_connect = on_connect +client.on_message = on_message +client.connect('localhost',1883,60) + +if __name__ == '__main__': +        # Start up the server to expose the metrics. + +        client = mqtt.Client() +        client.username_pw_set('london','abc123') +        client.on_connect = on_connect +        client.on_message = on_message +        client.connect('localhost',1883,60) + +        start_http_server(8000) +        client.loop_forever() +``` + +然后我配置 Prometheus 服务器采集端点数据到 `localhost:8000`。 + +你可以在 Github 上访问 [温室 MQTT 微控制器][24] 这个项目的代码,项目采用 MIT 许可证授权。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/5/monitor-greenhouse-open-source + +作者:[Darin London][a] +选题:[lujun9972][b] +译者:[alim0x](https://github.com/alim0x) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dmlond +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/zanda-photography-unsplash-greenhouse.jpg?itok=ZMnZyNMM (Greenhouse garden with tomatoes) +[2]: https://mqtt.org/ +[3]: https://prometheus.io/ +[4]: https://circuitpython.io/ +[5]: https://adafruit.com +[6]: https://circuitpython.org/downloads +[7]: https://learn.adafruit.com/welcome-to-circuitpython +[8]: https://learn.adafruit.com/circuitpython-essentials/circuitpython-essentials +[9]: https://github.com/adafruit/circuitpython +[10]: https://www.adafruit.com/product/4769 +[11]: https://www.adafruit.com/product/3251 +[12]: https://www.adafruit.com/product/4399 +[13]: https://www.sparkfun.com/products/15081 +[14]: https://opensource.com/sites/default/files/uploads/connectsensors-microcontroller.jpg (Connecting sensors to microcontroller) +[15]: https://creativecommons.org/licenses/by-sa/4.0/ +[16]: https://pimylifeup.com/raspberry-pi-mosquitto-mqtt-server/ +[17]: https://mosquitto.org/ +[18]: https://mosquitto.org/documentation/authentication-methods/ +[19]: https://learn.adafruit.com/mqtt-in-circuitpython +[20]: https://circuitpython.org/libraries +[21]: https://pypi.org/project/paho-mqtt/ +[22]: https://pypi.org/project/prometheus-client +[23]: https://opensource.com/article/21/3/iot-measure-raspberry-pi +[24]: https://github.com/dmlond/greenhouse_mqtt_microcontroller diff --git a/published/20210526 Make Command Not Found- Here-s How to Fix it.md b/published/202106/20210526 Make Command Not Found- Here-s How to Fix it.md similarity index 100% rename from published/20210526 Make Command Not Found- Here-s How to Fix it.md rename to published/202106/20210526 Make Command Not Found- Here-s How to Fix it.md diff --git a/published/20210528 What you need to know about Quarkus in 2021.md b/published/202106/20210528 What you need to know about Quarkus in 2021.md similarity index 100% rename from published/20210528 What you need to know about Quarkus in 2021.md rename to published/202106/20210528 What you need to know about Quarkus in 2021.md diff --git a/published/202106/20210601 Get started with FreeDOS.md b/published/202106/20210601 Get started with FreeDOS.md new file mode 100644 index 0000000000..9706804d74 --- /dev/null +++ b/published/202106/20210601 Get started with FreeDOS.md @@ -0,0 +1,104 @@ +[#]: subject: (Get started with FreeDOS) +[#]: via: (https://opensource.com/article/21/6/get-started-freedos) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13492-1.html) + +FreeDOS 入门 +====== + +> 它看起来像复古计算,但它是一个现代的操作系统,你可以用它来完成任务。 + +![](https://img.linux.net.cn/data/attachment/album/202106/16/123557an8ybzgnqg833vz4.jpg) + +在整个 1980 年代和 1990 年代,我主要是一个 DOS 用户。我喜欢 DOS 提供的命令行环境,它随着每一个连续的版本变得更加强大。我甚至学会了如何用 C 语言编写自己的 DOS 程序,这样我就可以扩展 DOS 命令行,并为标准的 DOS 命令编写更强大的替代程序。我曾经试验过微软的 Windows,但如果你记得当时的 Windows 3,你就会知道它很慢,而且容易崩溃。但无论如何我更喜欢命令行,所以我坚持使用 DOS。 + +这一切在 1994 年发生了变化。流行的技术杂志谈到了即将到来的 Windows 版本,它将完全废除 DOS。我不想被迫使用 Windows。在我访问的 Usenet 讨论区中,其他人也有同样的感觉。所以在 [1994 年 6 月 29 日][2],我认为如果我们想保留 DOS,我们需要自己编写。所以在 6 月 29 日,我宣布了一个小项目,这个项目后来成为 [FreeDOS 项目][3]。 + +从那时起,我们已经发布了几个完整的 FreeDOS 发行版。我们从 1994 年到 1997 年的 alpha 系列开始,再到 1998 年到 2005 年的 beta 系列,最后在 2006 年发布了 FreeDOS 1.0 版本。从那时起,进展是缓慢但稳定的。在 1.0 之后,我们并没有真正急于发布每个新版本,因为 DOS 在 1995 年不再是一个变动的目标。 + +从 1.0 开始的每一个 FreeDOS 发行版都是对现代 DOS 的不断重新想象。我们已经包括了很多编译器和汇编器,供开发人员编写软件。我们还提供了许多“强大工具”,以便你可以做真正的工作。我们还提供了各种编辑器,因为每个人都有自己的最爱。 + +我们最近发布了 FreeDOS 1.3 RC4 发行版。从技术上讲,这是我们即将推出的 FreeDOS 1.3 发行版的候选版本,但它是一个全功能的发行版。我对 FreeDOS 1.3 RC4 的所有功能感到非常兴奋。 + +### 无需安装 FreeDOS 即可运行 FreeDOS + +在我们以前所有的 FreeDOS 发行版中,我们把重点放在 _安装_ FreeDOS 到电脑上。但我们认识到,大多数用户实际上已经不在实际硬件上运行 FreeDOS 了。他们在 [像 QEMU 或 VirtualBox 这样的虚拟机][4] 中运行 FreeDOS。所以在 FreeDOS 1.3 RC4 中,我们改进了 “LiveCD” 环境。 + +通过 FreeDOS 1.3 RC4,你可以在你喜欢的虚拟机中启动 LiveCD 镜像,并立即开始使用 FreeDOS。这就是我现在运行 FreeDOS 的方式。我有一个小的虚拟硬盘镜像,我把所有的文件都放在那里,但我从 LiveCD 启动并运行 FreeDOS。 + +![Booting the FreeDOS 1.3 RC4 LiveCD on QEMU][5] + +*启动 FreeDOS 1.3 RC4 LiveCD (Jim Hall, [CC-BY SA 4.0][6])* + +### 安装真的很简单 + +如果你不想从 LiveCD 上运行 FreeDOS,你也可以在你的硬盘上安装它。我们更新了 FreeDOS 的安装程序,所以它本身并不是一个真正的“程序”,而是一个非常聪明的 DOS “批处理”文件,它可以检测到各种情况并采取适当的行动,例如在没有 FreeDOS 分区的情况下为其创建一个新的磁盘分区。 + +旧的 FreeDOS 发行版会提示你各种问题,甚至选择个别程序来安装。新的安装程序非常精简。它只问你几个问题就开始了,然后就自己做其他事情。在一个空的虚拟机上安装 FreeDOS 只需要几分钟时间。 + +![Installing FreeDOS 1.3 RC4][7] + +*安装FreeDOS 1.3 RC4 (Jim Hall, [CC-BY SA 4.0][6])* + +### 你可以从软盘安装它 + +不是每个人都喜欢在虚拟机中运行 FreeDOS。现在有一个复古计算社区,他们收集并精心修复经典的 PC 硬件,如 Pentium 或 486 系统。你甚至可以在那里找到一些 XT(8088)或 AT(80286)系统,它由一个专门的用户社区运营。 + +虽然我们认为 FreeDOS 是一个现代的 DOS,但如果我们不在旧的 PC 硬件上运行,我们就不是 “DOS” 了。因此,在 FreeDOS 1.3 中,我们包含了一个纯软盘版!这个版本可以运行在任何硬件上。这个版本应该可以在任何可以运行 FreeDOS 的硬件上运行,并且有 EGA 或更好的图形。 + +你在运行 286 或其他没有 CD-ROM 驱动器的经典系统吗?从这些软盘安装 FreeDOS。你是否只有一个硬盘而没有 CD 或软盘驱动器?只要把软盘的内容复制到一个临时目录,然后从那里运行安装程序。想执行“无交互外设方式”安装到不同的 DOS 目录吗?用命令行选项就可以了。 + +纯软盘版使用一个完全不同的安装程序,并包含一套有限的 FreeDOS 程序,它们在经典的 PC 硬件上更有用。 + +![Installing the FreeDOS Floppy-Only Edition][8] + +*安装FreeDOS纯软盘版 (Jim Hall, [CC-BY SA 4.0][6])* + +### 充满了开源应用和游戏 + +如果 FreeDOS 是一个闭源的 DOS,它就不是一个 _自由_ 的 DOS。我们希望每个人都能使用和研究 FreeDOS,包括其源代码。当我们计划 FreeDOS 1.3 发行版时,我们仔细检查了每个软件包中的每一个许可证,并专注于只包括 _开源_ 程序。(在以前的 FreeDOS 发行版中,有几个程序并不完全“开源”,还有一两个程序没有包括源码,但是可以“自由使用和发布”。在这个版本中,所有的东西都是开源的,以“开源定义”作为我们的模型。) + +而且,这是一个多么棒的开源应用和游戏的集合。游戏是 FreeDOS 1.3 RC4 中我最喜欢的内容。许多人使用 FreeDOS 来玩经典的 DOS 游戏,但我们想提供我们自己的开源游戏给人们玩。 + +你可以发现 LiveCD 中已经安装了两个游戏:Simple Senet(可以追溯到古埃及的棋盘游戏)和 Floppy Bird(Flappy Bird 游戏的一个版本)。如果你安装了 FreeDOS,你还会发现很多其他游戏可以尝试,包括 Sudoku86(一个数独游戏)、Wing(一个太空射击游戏)和 Bolitaire(单人纸牌游戏)。 + +![Playing the Floppy Bird game][9] + +*玩 Floppy Bird 游戏 (Jim Hall, [CC-BY SA 4.0][6])* + +![The ancient game of Senet][10] + +*古老的 Senet 游戏 (Jim Hall, [CC-BY SA 4.0][6])* + +### 现在就试试 FreeDOS 1.3 RC4 + +你可以在 FreeDOS 的 [下载][11] 页面上找到新的 FreeDOS 1.3 RC4。要安装 FreeDOS,你需要至少 20MB 的可用磁盘空间:20MB 用来安装一个普通的 FreeDOS 系统,或者 250MB 用来安装所有,包括应用和游戏。要安装源码,你将需要高达 450MB 的可用空间。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/get-started-freedos + +作者:[Jim Hall][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jim-hall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/retro_old_unix_computer.png?itok=SYAb2xoW (Old UNIX computer) +[2]: https://groups.google.com/g/comp.os.msdos.apps/c/oQmT4ETcSzU/m/O1HR8PE2u-EJ +[3]: https://www.freedos.org/ +[4]: https://opensource.com/article/20/8/virt-tools +[5]: https://opensource.com/sites/default/files/freedos-livecd.png (Booting the FreeDOS 1.3 RC4 LiveCD) +[6]: https://creativecommons.org/licenses/by-sa/4.0/ +[7]: https://opensource.com/sites/default/files/install6.png (Installing FreeDOS 1.3 RC4) +[8]: https://opensource.com/sites/default/files/freedos-floppy.png (Installing the FreeDOS Floppy-Only Edition) +[9]: https://opensource.com/sites/default/files/floppy-bird.png (Playing the Floppy Bird game) +[10]: https://opensource.com/sites/default/files/simple-senet.png (The ancient game of Senet) +[11]: https://www.freedos.org/download/ diff --git a/published/20210601 Nyxt Browser is a Keyboard-oriented Web Browser Inspired by Emacs and Vim.md b/published/202106/20210601 Nyxt Browser is a Keyboard-oriented Web Browser Inspired by Emacs and Vim.md similarity index 100% rename from published/20210601 Nyxt Browser is a Keyboard-oriented Web Browser Inspired by Emacs and Vim.md rename to published/202106/20210601 Nyxt Browser is a Keyboard-oriented Web Browser Inspired by Emacs and Vim.md diff --git a/published/20210602 Convert Images to ASCII Art in Linux Terminal With This Nifty Little Tool.md b/published/202106/20210602 Convert Images to ASCII Art in Linux Terminal With This Nifty Little Tool.md similarity index 100% rename from published/20210602 Convert Images to ASCII Art in Linux Terminal With This Nifty Little Tool.md rename to published/202106/20210602 Convert Images to ASCII Art in Linux Terminal With This Nifty Little Tool.md diff --git a/published/20210602 openSUSE Leap 15.3 Release Finally Closes the Gap With SUSE Linux Enterprise.md b/published/202106/20210602 openSUSE Leap 15.3 Release Finally Closes the Gap With SUSE Linux Enterprise.md similarity index 100% rename from published/20210602 openSUSE Leap 15.3 Release Finally Closes the Gap With SUSE Linux Enterprise.md rename to published/202106/20210602 openSUSE Leap 15.3 Release Finally Closes the Gap With SUSE Linux Enterprise.md diff --git a/published/202106/20210603 Explore the Kubernetes ecosystem in 2021.md b/published/202106/20210603 Explore the Kubernetes ecosystem in 2021.md new file mode 100644 index 0000000000..d7c2ba19d1 --- /dev/null +++ b/published/202106/20210603 Explore the Kubernetes ecosystem in 2021.md @@ -0,0 +1,72 @@ +[#]: subject: (Explore the Kubernetes ecosystem in 2021) +[#]: via: (https://opensource.com/article/21/6/kubernetes-ebook) +[#]: author: (Chris Collins https://opensource.com/users/clcollins) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13506-1.html) + +探索 Kubernetes 生态系统(2021 版) +====== + +> 这份可下载的指南充满了有用的教程,让 SRE 和系统管理员使用 Kubernetes 获得便利。 + +![](https://img.linux.net.cn/data/attachment/album/202106/21/162617ikidrw6q8i6nif2n.jpg) + +Kubernetes 是容器编排的事实标准,在基础设施管理和应用开发方面已经迅速发展成为容器环境的主导。作为一个拥有庞大的爱好者和专业人士社区的开源平台,以及作为云原生计算基金会的一部分,Kubernetes 不仅成为一个强大而令人印象深刻的编排系统本身,而且它还促进了一个庞大的相关工具和服务的生态系统,使其更容易使用,并通过更强大和复杂的组件扩展其功能。 + +在这本新的电子书《[给 SRE 和系统管理员的 Kubernetes 指导][2]》中,[Jess Cherry][3](Ben Finkel 也有贡献)涵盖了一系列用于管理和整合 Kubernetes 的工具和服务。Cherry 和 Finkel 提供了一些有用的 _入门_ 指南,包括 Kubernetes 和一些工具。他们甚至还分享了面试问题,以帮助读者为在这个快速增长的大规模生态系统中工作做好准备。 + +### 了解 Kubernetes + +如果你刚开始接触 Kubernetes 和容器,Ben Finkel 的 《[Kubernetes 入门][4]》文如其题,也是一篇对你需要了解的相关概念的出色介绍。它也是一本轻量级的快速入门指南,用于设置和使用单节点集群进行测试。没有什么比亲身体验技术并直接进入学习更好的方法了。什么是吊舱Pod? 如何在集群上部署一个应用程序? Ben 一一为你做了介绍。 + +与集群交互的主要方式是 [kubectl][5] 命令,这是一种 CLI 工具,它提供了一种与管理集群本身的 API 服务器交互的适合方式。例如,你可以使用 `kubectl get` 来列出上述的吊舱和部署,但正如你对 Kubernetes 这样复杂的东西所期望的那样,它的 CLI 界面有很强的功能和灵活性。Jess Cherry 的《[9 个系统管理员需要知道的 kubectl 命令][6]》速查表是一个很好的介绍,是使用 `kubectl` 的入门好方法。 + +同样,Cherry 的《[给初学者的 Kubernetes 命令空间][7]》也很好地解释了什么是命名空间以及它们在 Kubernetes 中的使用方式。 + +### 简化 Kubernetes 的工作 + +在一个复杂的系统中工作是很困难的,尤其是使用像 `kubectl` 这样强大而极简的 CLI 工具。幸运的是,在围绕 Kubernetes 的生态系统中,有许多工具可用于简化事情,使扩展服务和集群管理更容易。 + +可用于在 Kubernetes 上部署和维护应用和服务的 `kubectl` 命令主要使用的是 YAML 和 JSON。然而,一旦你开始管理更多应用,用 YAML 的大型仓库这样做会变得既重复又乏味。一个好的解决方案是采用一个模板化的系统来处理你的部署。[Helm][8] 就是这样一个工具,被称为 “Kubernetes 的包管理器”,Helm 提供了一种方便的方式来打包和共享应用。Cherry 写了很多关于 Helm 的有用文章:创建有效的 《[Helm 海图][9]》和有用的《[Helm 命令][10]》。 + +`kubectl` 也为你提供了很多关于集群本身的信息:上面运行的是什么,以及正在发生的事件。这些信息可以通过 `kubectl` 来查看和交互,但有时有一个更直观的 GUI 来进行交互是有帮助的。[K9s][11] 符合这两个世界的要求。虽然它仍然是一个终端应用,但它提供了视觉反馈和一种与集群交互的方式,而不需要长长的 `kubectl` 命令。Cherry 也写了一份很好的《[k9s 使用入门][12]》的指南。 + +### 建立在 Kubernetes 的强大和灵活性之上的扩展 + +幸运的是,尽管 Kubernetes 是复杂而强大的,但它惊人的灵活并且开源。它专注于其核心优势:容器编排,并允许围绕它的爱好者和专业人士的社区扩展其能力,以承担不同类型的工作负载。其中一个例子是 [Knative][13],在 Kubernetes 之上提供组件,它为无服务器和事件驱动的服务提供工具,并利用 Kubernetes 的编排能力在容器中运行最小化的微服务。事实证明,这样做非常高效,既能提供在容器中开发小型、易于测试和维护的应用的好处,又能提供仅在需要时运行这些应用的成本优势,可以在特定事件中被触发,但在其他时候处于休眠。 + +在这本电子书中,Cherry 介绍了 Knative 和它的事件系统,以及为什么值得自己研究使用 Knative。 + +### 有一个完整的世界可以探索 + +通过 Jess Cherry 和 Ben Finkel 的这本新的[电子书][2],可以开始了解 Kubernetes 和围绕它的生态系统。除了上述主题外,还有一些关于有用的 Kubernetes 扩展和第三方工具的文章。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/kubernetes-ebook + +作者:[Chris Collins][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clcollins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/ship_wheel_gear_devops_kubernetes.png?itok=xm4a74Kv (A ship wheel with someone steering) +[2]: https://opensource.com/downloads/kubernetes-sysadmin +[3]: https://opensource.com/users/cherrybomb +[4]: https://opensource.com/article/17/11/getting-started-kubernetes +[5]: https://kubernetes.io/docs/reference/kubectl/kubectl/ +[6]: https://opensource.com/article/20/5/kubectl-cheat-sheet +[7]: https://opensource.com/article/19/12/kubernetes-namespaces +[8]: https://helm.sh/ +[9]: https://opensource.com/article/20/5/helm-charts +[10]: https://opensource.com/article/20/2/kubectl-helm-commands +[11]: https://k9scli.io/ +[12]: https://opensource.com/article/20/5/kubernetes-administration +[13]: https://cloud.google.com/knative/ diff --git a/translated/tech/20210603 How to Install Code Blocks IDE on Ubuntu Linux.md b/published/202106/20210603 How to Install Code Blocks IDE on Ubuntu Linux.md similarity index 64% rename from translated/tech/20210603 How to Install Code Blocks IDE on Ubuntu Linux.md rename to published/202106/20210603 How to Install Code Blocks IDE on Ubuntu Linux.md index f12b90fbb2..443aaf018c 100644 --- a/translated/tech/20210603 How to Install Code Blocks IDE on Ubuntu Linux.md +++ b/published/202106/20210603 How to Install Code Blocks IDE on Ubuntu Linux.md @@ -3,24 +3,26 @@ [#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13484-1.html) 如何在 Ubuntu Linux 上安装 Code Blocks IDE ====== +![](https://img.linux.net.cn/data/attachment/album/202106/14/164807ov99wdi2m7pmgz2j.jpg) + Code Blocks 是一个用 C++ 编写的开源 IDE,非常适合 C、C++ 和 Fortran 开发。它是跨平台的,可以在 Linux、macOS 和 Windows 上运行。 Code Blocks 是轻量级和快速的。它支持工作区、多目标项目、工作区内的项目间依赖关系。 -你可以得到语法高亮,代码折叠,标签式界面,类浏览器,智能缩进等。你还可以通过插件扩展 IDE 的功能。 +你可以得到语法高亮、代码折叠、标签式界面、类浏览器、智能缩进等功能。你还可以通过插件扩展 IDE 的功能。 在本教程中,你将学习如何在基于 Ubuntu 的 Linux 发行版上安装 Code Blocks。 -注意 - -Code Blocks 也可以在 Ubuntu 软件中心找到。然而,从 Ubuntu 21.04 开始,从 Ubuntu 软件中心以图形方式安装 Code Blocks 会安装一个 codeblocks-common 软件包,而不是图形化 IDE。因而你看不到安装在你系统上的 Code Blocks 的运行。由于这个原因,我建议采取终端的方式在 Ubuntu 上安装 Code Blocks。 +> 注意 +> +> Code Blocks 也可以在 Ubuntu 软件中心找到。然而,从 Ubuntu 21.04 开始,从 Ubuntu 软件中心以图形方式安装 Code Blocks 会安装一个 codeblocks-common 软件包,而不是图形化 IDE。因而你不能看到安装在你系统上的 Code Blocks 以运行。由于这个原因,我建议采取终端的方式在 Ubuntu 上安装 Code Blocks。 ### 在基于 Ubuntu 的 Linux 发行版上安装 Code Blocks @@ -36,7 +38,7 @@ sudo add-apt-repository universe sudo apt update ``` -最后,你可以使用 apt install 命令在基于 Ubuntu 的发行版上安装 Code Blocks: +最后,你可以使用 `apt install` 命令在基于 Ubuntu 的发行版上安装 Code Blocks: ``` sudo apt install codeblocks @@ -44,7 +46,7 @@ sudo apt install codeblocks ![][3] -建议你也安装额外的插件,以便从 Code Blocks IDE 中获得更多。你可以使用 codeblocks-contrib 包来安装它们: +建议你也安装额外的插件,以便从 Code Blocks IDE 中获得更多。你可以使用 `codeblocks-contrib` 包来安装它们: ``` sudo apt install codeblocks-contrib @@ -52,21 +54,21 @@ sudo apt install codeblocks-contrib ### 如何使用 Code Blocks -在系统菜单中搜索 Code Blocks。这是在 Ubuntu 默认的 GNOME 版本中的样子: +在系统菜单中搜索 “Code Blocks”。这是在 Ubuntu 默认的 GNOME 版本中的样子: ![][4] 当你第一次启动 Code Blocks 时,它会寻找你系统中所有可用的编译器,并将其添加到路径中,这样你就不用自己去配置它了。 -在我的例子中,我的 Ubuntu 系统上已经安装了 gcc,Code Blocks很 好地识别了它。 +在我的例子中,我的 Ubuntu 系统上已经安装了 gcc,Code Blocks 很好地识别了它。 ![][5] -Code Blocks 的用户界面绝对不现代,但请记住,这个 IDE 是轻量级的,它几乎消耗不到 50MB 的内存。 +Code Blocks 的用户界面绝对不够现代,但请记住,这个 IDE 是轻量级的,它几乎消耗不到 50MB 的内存。 如果你曾经使用过像 Eclipse 这样的其他 IDE,你就不会觉得使用 Code Block 有什么困难。你可以写你的代码并把它们组织在项目中。 -构建、运行并构建和运行按钮一起在顶部。 +构建、运行并构建和运行按钮一起放在顶部。 ![][6] @@ -74,9 +76,9 @@ Code Blocks 的用户界面绝对不现代,但请记住,这个 IDE 是轻量 ![][7] -这就是你需要的关于 Code Blocks 的最少信息。我把它留给你,让你通过浏览它的 [wiki][8] 和[用户手册][9]来进一步探索它。 +这就是你需要的关于 Code Blocks 的最少信息。剩下的留给你,你可以通过浏览它的 [维基][8] 和[用户手册][9] 来进一步探索它。 -拥有一个 IDE 可以使[在 Linux 上运行 C 或 C++ 程序][10]更容易。Eclipse 是一个很好的 IDE,但它比 Code Blocks 要消耗更多的系统资源。当然,最后,重要的是你的选择。 +拥有一个 IDE 可以使 [在 Linux 上运行 C 或 C++ 程序][10] 更容易。Eclipse 是一个很好的 IDE,但它比 Code Blocks 要消耗更多的系统资源。当然,最后,重要的是你的选择。 -------------------------------------------------------------------------------- @@ -85,7 +87,7 @@ via: https://itsfoss.com/install-code-blocks-ubuntu/ 作者:[Abhishek Prakash][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/202106/20210605 15 Useful Visual Studio Code Keyboard Shortcuts to Increase Productivity.md b/published/202106/20210605 15 Useful Visual Studio Code Keyboard Shortcuts to Increase Productivity.md new file mode 100644 index 0000000000..f2d1c5cdf8 --- /dev/null +++ b/published/202106/20210605 15 Useful Visual Studio Code Keyboard Shortcuts to Increase Productivity.md @@ -0,0 +1,240 @@ +[#]: subject: (15 Useful Visual Studio Code Keyboard Shortcuts to Increase Productivity) +[#]: via: (https://itsfoss.com/vs-code-shortcuts/) +[#]: author: (Sarvottam Kumar https://itsfoss.com/author/sarvottam/) +[#]: collector: (lujun9972) +[#]: translator: (ywxgod) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13481-1.html) + +15 个提高工作效率的 VS Code 键盘快捷键 +====== + +![](https://img.linux.net.cn/data/attachment/album/202106/13/123502pqfi45mgpf8847yf.jpg) + +毫无疑问,微软的 [VS Code是最好的开源代码编辑器之一][1]。它与传说中的 Vim 不同,VS Code 不需要你是一个快捷键大师(LCTT 译注:以下都指键盘快捷键),开发者们对它大部分的功能都及其熟悉,且推崇备至。 + +但这并不意味着你不能成为快捷键大师,或者说你在 VS Code 中不应该使用快捷键。 + +在敲代码的时候,你可能需要用鼠标去执行其他的动作,比如在 VS Code 编辑器中切换终端,而此时你的代码流程会被打断,这是不是很讨厌?如果是的,那么你应该立即熟记下面这些 VS Code 有用的快捷键。 + +它不仅能帮助你摆脱鼠标,还能使你的生产力和工作效率得到提高。 + +那么,让我们来了解一下如何通过使用快捷键快速进行代码导航来进行快速编码。 + +### 有用的 VS Code 快捷键 + +免责声明。下面的这些快捷键是我在 VS Code 的使用中发现的较为有用的,你可以根据你的需要来发现更多有用的快捷键。 + +下面我还给出了 MacOS 用户的键盘快捷键。 + +#### 1、显示所有命令 + +Windows/Linux | macOS +---|--- +`CTRL + SHIFT + P` 或 `F1` | `SHIFT + ⌘ + P` 或 `F1` + +我们从最有用的快捷键开始,这个快捷键能打开命令面板(列表),它提供了对 VS Code 所有功能的访问。 + +![命令面板][2] + +这是一个非常重要的 VS Code 快捷键,因为即使你忘记了或不想记起其他任何快捷键,但你记得这个,那么你仍然可以使用命令面板进行各种操作,如创建新文件、打开设置、改变主题,还可以查看所有快捷键。 + +#### 2、垂直和水平拆分 VS Code 编辑器 + +Windows/Linux | macOS +---|--- +`CTRL + \` | `⌘ + \` + +为了提高效率,但你又没有安装多个显示器,那么你可以通过水平或垂直分割 VS Code 的编辑器来一次查看多个文件的代码。 + +![分割 VS Code 编辑区][3] + +要在多个编辑区间切换焦点,你可以使用数字键或箭头键。 + +Windows/Linux | macOS +---|--- +`CTRL + 1`/`2`/`3` | `⌘ + 1`/`2`/`3` +`CTRL + K` `CTRL + ←`/`→` | `⌘ + K` `⌘ + ←`/`→` + +#### 3、切换集成终端 + +Windows/Linux | macOS +---|--- +CTRL + \` | ⌘ + \` + +VS Code 中的集成终端是一个非常方便的功能,它可以让你在不切换窗口的情况下快速执行任务。要在编辑器中显示/隐藏终端,下面的快捷键会非常方便。 + +![集成终端][4] + +但是,如果你跟我一样觉得 CTRL + \` 在键盘的角落位置而比较难按到,你可以打开命令面板执行`View: Toggle Terminal` 命令来切换终端。 + +![使用命令面板切换终端][5] + +#### 4、转到文件 + +Windows/Linux | macOS +---|--- +`CTRL + P` | `⌘ + P` + +随着项目的壮大,查找文件可能会变得困难。因此,我建议,即使你使用鼠标,这个命令也能为你节省很多搜索和导航到版本库中的文件的时间。 + +![转到文件][6] + +#### 5、转到行 + +Windows/Linux | macOS +---|--- +`CTRL + G` | `^ + G` + +当你找到文件,你可能需要去到文件中指定的行增加或编辑代码,而如果这个文件包含了数千行代码,那么滚动代码将会浪费你大量的时间。而 `CTRL + G` 或 `^ + G` 快捷键能让你快速的去掉指定的行。 + +![转到行][7] + +另外,你也可以使用上面的转到文件的快捷键,在输入框中输入冒号 `:` 加行号,结果就跟转到行是一样的。 + +#### 6、在整个项目中搜索 + +Windows/Linux | macOS +---|--- +`CTRL + SHIFT + F` | `⌘ + SHIFT + F` + +很可能你需要在整个项目中搜索一个文本、变量或函数,在这种情况下,上面的命令就非常方便,它会在侧边栏显示一个搜索输入框。 + +![在项目中搜索][8] + +我们还可以在搜索的时候添加一些过滤器,比如使用 `ALT+C` 来启用大写匹配,`ALT+W` 用于匹配整个单词,`ALT+R` 用于启用正则表达式。 + +#### 7、禅模式 + +Windows/Linux | macOS +---|--- +`CTRL + K Z` | `⌘ + K Z` + +想要在不受干扰的环境中工作以保持更专注? 你可以试试禅模式(先按下 `CTRL + K`,再按下 `Z`),它会隐藏所有 UI(状态栏、活动栏、面板和侧边栏)并仅在全屏上显示编辑器。 + +![禅模式][9] + +要启用禅模式,你可以使用上面的快捷键或者打开命令面板执行 `View: Toggle Zen Mode`,要退出禅模式,你可以按两次 `Esc` 键。 + +#### 8、将选择添加到下一次匹配中 + +Windows/Linux | macOS +---|--- +`CTRL + D` | `⌘ + D` + +这条命令能让你选择所选文本的下一个出现的地方,从而进行编辑。如果下一个匹配出现的位置与第一个相离较远,那这将会很方便处理。 + +![查找下一个匹配][10] + +#### 9、切换行注释 + +Windows/Linux | macOS +---|--- +`CTRL + /` | `⌘ + /` + +将光标移到行的开头,然后添加双斜杠进行注释,这种麻烦的操作我们可以用上面的快捷键来代替了。 + +![注释代码][11] + +甚至,如果你想注释多行代码,你可以先通过 `SHIFT+UP`/`Down` 快捷键来选中多行,然后按 `CTRL+/` 快捷键进行注释。 + +#### 10、转到文件的开头或结尾 + +Windows/Linux | macOS +---|--- +`CTRL + HOME`/`END` | `⌘ + ↑`/`↓` + +如果你迷失在文件的中间位置,该命令可以让你快速达到文件的起点或终点。 + +#### 11、代码折叠或打开 + +Windows/Linux | macOS +---|--- +`CTRL + SHIFT + [`/`]` | `⌥ + ⌘ + [`/`]` + +这也是最有用的快捷键之一,它可以帮助你折叠/取消折叠一个区域的代码。通过这种方式,你可以隐藏不必要的代码,每次只查看所需的部分代码,以便更加专注和快速编码。 + +![折叠一块代码][12] + +#### 12、窥视执行 + +Windows/Linux | macOS +---|--- +`CTRL + SHIFT + F12` | `⌘ + SHIFT + F12` + +这个快捷键最有可能的作用是帮助你进行代码分析,或修复 bug 时了解函数和变量的运行情况。 + +![窥视执行][13] + +#### 13、删除当前行 + +Windows/Linux | macOS +---|--- +`CTRL + SHIFT + K` | `SHIFT + ⌘ + K` + +这是一条可以快速执行,选中当前行并按删除/退格键,这两个任务的简单命令。 + +#### 14、查找与替换 + +Windows/Linux | macOS +---|--- +`CTRL + F` | `⌘ + F` +`CTRL + H` | `⌥ + ⌘ + F` + +用一个新的文本替换文件中所有出现的该文本的最好方法是什么?如果你手动一个一个的通过滚动代码来处理,且如果需要替换的地方又很多,那么你可能会花费大量的时间。 + +![查找与替换][14] + +而使用查找和替换功能我们能在几秒内完成相同的任务。你可以用两个快捷键来打开它,其中一个实际上是打开用于查找文本的输入框,另一个用于输入新的文本。 + +#### 15、VS Code 的全部键盘快捷键 + +Windows/Linux | macOS +---|--- +`CTRL + K CTRL + S` | `⌘ + K ⌘ + S` + +最后,如果你还在为记住上述所有的快捷键而苦恼,你大可不必。因为你可以使用上面的快捷键查看编辑器所有可用的命令。 + +![快捷键][15] + +你还可以根据自己的喜好编辑命令的绑定键。 + +### 想要为 VS Code 添加更多快捷键? + +如果你想对 VS Code 的快捷键有完整的了解,你可以查看 VS Code 的 [文档][16]。 + +或者,如果你想在纸上将所有快捷键打印出来慢慢看,下面这些是各个系统对应的快捷键速查表: [Linux][17]、[macOS][18] 和 [Windows][19]。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/vs-code-shortcuts/ + +作者:[Sarvottam Kumar][a] +选题:[lujun9972][b] +译者:[ywxgod](https://github.com/ywxgod) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/sarvottam/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/best-modern-open-source-code-editors-for-linux/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/Command-Palette.jpg?resize=800%2C418&ssl=1 +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/Split-VS-Code.png?resize=800%2C405&ssl=1 +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/Integrated-Terminal.png?resize=800%2C221&ssl=1 +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/Toggle-Terminal-Using-Command-Palette.png?resize=686%2C118&ssl=1 +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/Go-to-file.jpg?resize=800%2C388&ssl=1 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/Go-to-line.jpg?resize=800%2C99&ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/05/Search-project.jpg?resize=381%2C450&ssl=1 +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/05/Zen-Mode.png?resize=800%2C450&ssl=1 +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/Next-find-match.jpg?resize=800%2C313&ssl=1 +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/Comment-out-code.jpg?resize=800%2C313&ssl=1 +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/05/Collapse-a-region-of-code.jpg?resize=800%2C287&ssl=1 +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/Peek-Implementation.png?resize=800%2C339&ssl=1 +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/Find-and-replace.png?resize=800%2C223&ssl=1 +[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/05/Keyboard-Shortcuts.png?resize=800%2C406&ssl=1 +[16]: https://code.visualstudio.com/docs/getstarted/keybindings +[17]: https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf +[18]: https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf +[19]: https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf diff --git a/published/202106/20210608 How FreeDOS boots.md b/published/202106/20210608 How FreeDOS boots.md new file mode 100644 index 0000000000..bbad79b7e3 --- /dev/null +++ b/published/202106/20210608 How FreeDOS boots.md @@ -0,0 +1,71 @@ +[#]: subject: (How FreeDOS boots) +[#]: via: (https://opensource.com/article/21/6/freedos-boots) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13503-1.html) + +FreeDOS 如何启动 +====== + +> 概述你的计算机如何引导和启动一个像 FreeDOS 这样的简单操作系统。 + +![](https://img.linux.net.cn/data/attachment/album/202106/20/140809fpkrcnow8npnow8p.jpg) + +在使用 DOS 计算机的过程中,我很欣赏的一点是,引导过程相对容易理解。在 DOS 中没有太多的变动组件。而今天,我想和大家分享一下电脑是如何引导和启动像 FreeDOS 这样的简单操作系统的概况。 + +### 初始引导 + +当你打开计算机的电源时,系统会进行一些自我检查,如验证内存和其他组件。这被称为开机自检Power On Self Test(POST)。POST 之后,计算机使用一个硬编码指令,告诉它在哪里找到加载操作系统的指令。这就是“引导加载程序boot loader”,通常它将试图找到硬盘上的主引导记录Master Boot Record(MBR)。然后,MBR 加载主操作系统,在这里就是 FreeDOS。 + +这个定位一个信息以便计算机能够加载操作系统的下一个部分的过程被称为“引导bootstrapping”,来自于“通过你自己的努力振作起来picking yourself up by your bootstraps”的古老说法。正是从这个用法中,我们采用了“引导boot”一词来表示启动你的计算机。 + +### 内核 + +当计算机加载 FreeDOS 内核时,内核所做的第一件事就是识别用户所表示要使用的任何参数。它被保存在一个叫做 `FDCONFIG.SYS` 的文件中,与内核保存在同一个根目录下。如果 `FDCONFIG.SYS` 不存在,那么 FreeDOS 的内核就会寻找一个叫做 `CONFIG.SYS` 的替代文件。 + +如果你在 20 世纪 80 年代或 90 年代使用过 DOS,你可能对 `CONFIG.SYS` 文件很熟悉。从 1999 年起,FreeDOS 首先寻找 `FDCONFIG.SYS`,以防你的 DOS 系统与其他 DOS(如 MS-DOS)做了 _双启动_。请注意,MS-DOS 只使用 `CONFIG.SYS` 文件。因此,如果你用同一个硬盘同时启动 FreeDOS 和 MS-DOS,MS-DOS 使用 `CONFIG.SYS` 来配置自己,而 FreeDOS 则使用 `FDCONFIG.SYS`。这样一来,双方都可以使用自己的配置。 + +`FDCONFIG.SYS` 可以包含一些配置设置,其中之一是 `SHELL=` 或 `SHELLHIGH=`。任何一个都会指示内核加载这个程序作为用户的交互式 shell。 + +如果 `FDCONFIG.SYS` 和 `CONFIG.SYS` 都不存在,那么内核就会假定几个默认值,包括在哪里找到 shell。如果你在启动 FreeDOS 系统时看到 “Bad or missing Command Interpreter” 的信息,这意味着 `SHELL=` 或 `SHELLHIGH=` 指向了一个在你系统中不存在的 shell 程序。 + +![Bad or missing Command Interpreter][2] + +你可以通过查看 `SHELL=` 或 `SHELLHIGH=` 行来调试这个问题。如果做不到这一点,请确保你在 FreeDOS 系统的根目录下有一个名为 `COMMAND.COM` 的程序。它就是 _shell_,我接下来会讲到它。 + +### shell + +在 DOS 系统中,“shell” 一词通常是指一个命令行解释器:一个交互式程序,它从用户那里读取指令,然后执行它们。在这里,FreeDOS 的 shell 与 Linux 的 Bash shell 相似。 + +除非你用 `SHELL=` 或 `SHELLHIGH=` 要求内核加载一个不同的 shell,否则 DOS 上的标准命令行 shell 被称为 `COMMAND.COM`。当 `COMMAND.COM` 启动时,它也寻找一个文件来配置自己。默认情况下,`COMMAND.COM` 会在根目录下寻找一个名为 `AUTOEXEC.BAT` 的文件。`AUTOEXEC.BAT` 是一个“批处理文件”,它包含一组启动时运行的指令,大致类似于 Linux 上 Bash 启动时读取的 `~/.bashrc` “资源文件”。 + +你可以在 `FDCONFIG.SYS` 文件中用 `SHELL=` 或 `SHELLHIGH=` 改变 shell 以及 shell 的启动文件。FreeDOS 1.3 RC4 安装程序将系统设置为读取 `FDAUTO.BAT` 而不是 `AUTOEXEC.BAT`。这与内核读取另一个配置文件的原因相同;你可以在硬盘上用另一个 DOS 双启动 FreeDOS。FreeDOS 将使用 `FDAUTO.BAT` 而 MS-DOS 将使用 `AUTOEXEC.BAT`。 + +如果没有像 `AUTOEXEC.BAT` 这样的启动文件,shell 将简单地提示用户输入日期和时间。 + +![Without AUTOEXEC.BAT, the shell will prompt for date and time][3] + +就是这些了。当 FreeDOS 加载了内核,而内核也加载了 shell,FreeDOS 就准备好让用户输入命令了。 + +![FreeDOS is ready for you to enter your first command][4] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/freedos-boots + +作者:[Jim Hall][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jim-hall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_development_programming.png?itok=4OM29-82 (Code going into a computer.) +[2]: https://opensource.com/sites/default/files/uploads/bad-missing-command.png (Bad or missing Command Interpreter) +[3]: https://opensource.com/sites/default/files/uploads/no-autoexec.png (Without AUTOEXEC.BAT, the shell will prompt for date and time) +[4]: https://opensource.com/sites/default/files/uploads/freedos-boot.png (FreeDOS is ready for you to enter your first command) diff --git a/published/202106/20210608 Subtitld- A Cross-Platform Open-Source Subtitle Editor.md b/published/202106/20210608 Subtitld- A Cross-Platform Open-Source Subtitle Editor.md new file mode 100644 index 0000000000..69832b7d35 --- /dev/null +++ b/published/202106/20210608 Subtitld- A Cross-Platform Open-Source Subtitle Editor.md @@ -0,0 +1,101 @@ +[#]: subject: (Subtitld: A Cross-Platform Open-Source Subtitle Editor) +[#]: via: (https://itsfoss.com/subtitld/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13510-1.html) + +Subtitld: 一个跨平台的开源字幕编辑器 +====== + +![](https://img.linux.net.cn/data/attachment/album/202106/22/145800rejjtp9exvd7zvpn.jpg) + +字幕可以使观看视频的体验更加完美。你不需要一定理解视频的语言,字幕可以帮助你用你喜欢的文字来弄清楚正在发生什么。 + +你在流媒体平台上找到的大部分内容都有字幕,你可能需要为一些你在本地收藏的视频添加字幕。 + +虽然你可以通过简单地下载 SRT 文件并使用视频播放器加载它来做到这一点,但你如何编辑它,删除它,或转录一个视频?Subtitld 是一个开源的字幕编辑器,它可以帮助你。 + +### Subtitld: 创建、删除、切分和转录字幕 + +Subtitld 是一个自由开源的项目,可以让你充分利用你的字幕。 + +![][1] + +如果你没有字幕,就创建一个,如果你需要编辑它,就用这个吧。有了这个开源工具,你会有许多选项来处理字幕。 + +换句话说,它是字幕编辑器之一,也是一个成熟的字幕编辑器(就我所遇到的而言)。 + +在你决定试用它之前,让我强调一些关键功能。 + +### Subtitld 的功能 + +![][2] + +它提供了大量的功能,虽然不是每个人都需要所有的功能,但如果你是一个经常需要创建、编辑和处理字幕的人,它应该会很方便。 + +下面是它的功能列表: + +* 创建字幕 +* 编辑字幕 +* 使用时间轴移动字幕,手动同步 +* 放大/缩小功能,帮助处理拥挤的时间线 +* 支持保存为 SRT 文件格式 +* 支持各种其他格式的导入和导出(SSA、TTML、SBV、DFXP、VTT、XML、SCC 和 SAMI) +* 易于调整字幕大小或从时间轴上调整字幕的持续时间 +* 与其他字幕合并,或从项目中切分字幕 +* 能够启用网格,按帧、场景或秒进行可视化 +* 在编辑器中回放以检查字幕情况 +* 在时间轴上捕捉字幕以避免重叠 +* 在字幕中添加/删除 +* 启用安全边界,以确保字幕不会看起来不妥当 +* 调整播放速度 +* 键盘快捷键 +* 自动转录 +* 输出加入了字幕的视频 +* 无限次撤消 + +除了这些功能外,音频波形的视觉提示也有一定的帮助。 + +![][3] + +总的来说,如果你是一个转录视频的人,想一次性地编辑视频,你可以用它做很多事情,也可以专业地使用它。 + +### 在 Linux 中安装 Subtitld + +虽然它也适用于 Windows,但你可以在 Linux 上使用 [snap 包][6] 轻松地安装它。你不会找到二进制包或 Flatpak,但你应该能够在任何 Linux 发行版上 [使用 snap][7] 安装它。 + +- [Subtitld][8] + +如果你想深入探索,你可以在 [GitLab][9] 上找到源代码。 + +### 总结 + +它有视频同步或添加字幕的精细设置,我只是测试了一些导入、导出、添加或删除字幕的基本功能。 + +自动转录功能仍处于测试阶段(截至发布时),但用户界面可以再做一些改进。例如,当我把鼠标悬停在编辑器内的按钮上时,它没有告诉我它是做什么的。 + +总的来说,它是一个在 Linux 上的有用工具。你对它有什么看法?请不要犹豫,在下面的评论中让我知道你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/subtitld/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/subtitld-editor.png?resize=800%2C546&ssl=1 +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/subtitld-export.png?resize=800%2C469&ssl=1 +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/subtitld-screenshot-1.png?resize=800%2C588&ssl=1 +[6]: https://snapcraft.io/subtitld +[7]: https://itsfoss.com/use-snap-packages-ubuntu-16-04/ +[8]: https://subtitld.jonata.org +[9]: https://gitlab.com/jonata/subtitld \ No newline at end of file diff --git a/published/202106/20210609 Helix- A Terminal Based Text Editor for Power Linux Users.md b/published/202106/20210609 Helix- A Terminal Based Text Editor for Power Linux Users.md new file mode 100644 index 0000000000..6e71cd3c0e --- /dev/null +++ b/published/202106/20210609 Helix- A Terminal Based Text Editor for Power Linux Users.md @@ -0,0 +1,102 @@ +[#]: subject: (Helix: A Terminal Based Text Editor for Power Linux Users) +[#]: via: (https://itsfoss.com/helix-editor/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13495-1.html) + +Helix:高级 Linux 用户的终端文本编辑器 +====== + +说到 [基于终端的文本编辑器][1],通常 Vim、Emacs 和 Nano 受到了关注。 + +这并不意味着没有其他这样的文本编辑器。Vim 的现代增强版 [Neovim][2],是许多这样的例子之一。 + +按照同样的思路,我想介绍另一个基于终端的文本编辑器,叫做 Helix Editor。 + +### Helix,一个用 Rust 编写的现代文本编辑器 + +![][3] + +[Helix][4] 是用 Rust 编写的,使用 Tree-sitter 进行语法高亮。开发者声称,它比正则表达式高亮更快,因为 Tree-sitter 像编译器一样将代码解析成语法树,从而给出更多的代码结构信息。 + +你可以跟踪局部变量,计算缩进和操作选择来选择语法节点。它足够强大,即使有语法错误也能产生结果。 + +Helix 的主要亮点是“多重选择”,这是基于 [Kakoune][5] 的。 + +内置的语言服务器支持提供上下文感知补全、诊断和代码操作。 + +### 在 Linux 上安装 Helix + +对于 Arch 和 Manjaro 用户来说,Helix 在 AUR 中有两个包: + + * [helix-bin][6]: 包含来自 GitHub 发布的预构建二进制文件 + * [helix-git][7]: 构建该仓库的主分支 + +作为一个 Arch 用户,我相信你可能已经知道 [如何使用 AUR 安装应用][8]。 + +对于其他 Linux 发行版,你必须使用 Cargo。Cargo 是 Rust 软件包管理器。有了它,你可以安装 Rust 包。可以认为它相当于 Python 的 PIP。 + +你应该能够使用你的发行版的包管理器来安装 Cargo。在基于 Ubuntu 的发行版上,可以这样安装 Cargo: + +``` +sudo apt install cargo +``` + +接下来,你要克隆 Helix 仓库: + +``` +git clone --recurse-submodules --shallow-submodules -j8 https://github.com/helix-editor/helix +``` + +进入克隆的目录中: + +``` +cd helix +``` + +现在用 `cargo` 来安装 Helix: + +``` +cargo install --path helix-term --features "embed_runtime" +``` + +最后一步是将 `hx` 二进制文件添加到 `PATH` 变量中,这样你就可以从任何地方运行它。这应该被添加到你的 `bashrc` 或 bash 配置文件中。 + +``` +export PATH=”$HOME/.cargo/bin:$PATH” +``` + +现在都设置好了,你应该可以通过在终端输入 `hx` 来使用编辑器。 + +你可以在 Helix 的[文档页][9]上找到使用 Helix 的键盘快捷键: + +- [Helix 键盘快捷键][10] + +它与 Vim 或 Neovim 相比如何?我无法说。我可以用 Vim 进行基本的编辑,但我不是 Vim 忍者。如果你是一个信奉 Vim(或 Emacs)的人,请你试试 Helix 并自己判断。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/helix-editor/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/command-line-text-editors-linux/ +[2]: https://neovim.io/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/helix-editor-screenshot.png?resize=800%2C515&ssl=1 +[4]: https://helix-editor.com/ +[5]: http://kakoune.org/ +[6]: https://aur.archlinux.org/packages/helix-bin/ +[7]: https://aur.archlinux.org/packages/helix-git/ +[8]: https://itsfoss.com/aur-arch-linux/ +[9]: https://docs.helix-editor.com/ +[10]: https://docs.helix-editor.com/keymap.html diff --git a/published/202106/20210610 Use cpulimit to free up your CPU.md b/published/202106/20210610 Use cpulimit to free up your CPU.md new file mode 100644 index 0000000000..9276c0dd58 --- /dev/null +++ b/published/202106/20210610 Use cpulimit to free up your CPU.md @@ -0,0 +1,91 @@ +[#]: subject: (Use cpulimit to free up your CPU) +[#]: via: (https://fedoramagazine.org/use-cpulimit-to-free-up-your-cpu/) +[#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13501-1.html) + +使用 cpulimit 来释放你的 CPU +====== + +![](https://img.linux.net.cn/data/attachment/album/202106/19/084002xuwuuqfww8xvfem7.jpg) + +在 Linux 系统上管理系统资源的推荐工具是 [cgroups][4]。虽然在可以调整的限制方面(CPU、内存、磁盘 I/O、网络等)非常强大,但配置 cgroups 并不简单。[nice][5] 命令从 1973 年起就可以使用了。但它只是调整在一个处理器上竞争时间的进程之间的调度优先级。`nice` 命令不会限制一个进程在单位时间内所能消耗的 CPU 周期的百分比。[cpulimit][6] 命令提供了两个世界的最佳方案。它限制了一个进程在每单位时间内可以分配的 CPU 周期的百分比,而且相对容易调用。 + +`cpulimit` 命令主要对长期运行的和 CPU 密集型的进程有用。编译软件和转换视频是长期运行的进程的常见例子,它们可以使计算机的 CPU 使用率达到最大。限制这类进程的 CPU 使用率将释放出处理器时间,供计算机上可能运行的其他任务使用。限制 CPU 密集型进程也将减少功耗及热输出,并可能减少系统的风扇噪音。限制一个进程的 CPU 使用率的代价是,它需要更多的时间来完成运行。 + +### 安装 cpulimit + +`cpulimit` 命令在默认的 Fedora Linux 仓库中可用。运行下面的命令,在 Fedora Linux 系统上安装 `cpulimit`: + +``` +$ sudo dnf install cpulimit +``` + +### 查看 cpulimit 的文档 + +`cpulimit` 软件包并没有附带的手册页。使用下面的命令来查看 `cpulimit` 的内置文档。输出结果在下面提供。但你可能需要在你自己的系统上运行该命令,以防止自本文编写以来选项发生变化。 + +``` +$ cpulimit --help +Usage: cpulimit [OPTIONS…] TARGET + OPTIONS + -l, --limit=N percentage of cpu allowed from 0 to 800 (required) + -v, --verbose show control statistics + -z, --lazy exit if there is no target process, or if it dies + -i, --include-children limit also the children processes + -h, --help display this help and exit + TARGET must be exactly one of these: + -p, --pid=N pid of the process (implies -z) + -e, --exe=FILE name of the executable program file or path name + COMMAND [ARGS] run this command and limit it (implies -z) +``` + +### 演示 + +为了演示 `cpulimit` 命令的使用方式,下面提供了一个精心设计的、计算量很大的 Python 脚本。该脚本首先在没有限制的情况下运行,然后在限制为 50% 的情况下运行。它计算的是第 42 个 [斐波那契数][7] 的值。该脚本在这两种情况下都作为 `time` 命令的子进程运行,以显示计算答案所需的总时间。 + +``` +$ /bin/time -f '(computed in %e seconds)' /bin/python -c 'f = lambda n: n if n<2 else f(n-1)+f(n-2); print(f(42), end=" ")' +267914296 (computed in 51.80 seconds) +$ /bin/cpulimit -i -l 50 /bin/time -f '(computed in %e seconds)' /bin/python -c 'f = lambda n: n if n<2 else f(n-1)+f(n-2); print(f(42), end=" ")' +267914296 (computed in 127.38 seconds) +``` + +当运行第一个版本的命令时,你可能会听到电脑上的 CPU 风扇转动起来。但在运行第二个版本时,你应该不会。第一个版本的命令不受 CPU 的限制,但它不应该导致你的电脑陷入瘫痪。它是以这样一种方式编写的:它最多只能使用一个 CPU 核心。大多数现代 PC 都有多个 CPU 核心,当其中一个 CPU 100% 繁忙时,可以毫无困难地同时运行其他任务。为了验证第一条命令是否使你的一个处理器达到最大,在一个单独的终端窗口中运行 `top` 命令并按下 `1` 键。要退出 `top` 命令可以按 `Q` 键。 + +设置高于 100% 的限制只对能够进行 [任务并行化][8] 的程序有意义。对于这样的程序,高于 100% 的增量代表一个 CPU 的全部利用率(200%=2 个CPU,300%=3 个CPU,等等)。 + +注意,在上面的例子中,`-i` 选项已经传递给 `cpulimit` 命令。这是必要的,因为要限制的命令不是 `cpulimit` 命令的直接子进程。相反,它是 `time` 命令的一个子进程,而后者又是 `cpulimit` 命令的一个子进程。如果没有 `-i` 选项,`cpulimit` 将只限制 `time` 命令。 + +### 最后说明 + +如果你想限制一个从桌面图标启动的图形程序,请将该程序的 `.desktop` 文件(通常位于 `/usr/share/applications` 目录下)复制到你的 `~/.local/share/applications` 目录下,并相应修改 `Exec` 行。然后运行下面的命令来应用这些变化: + +``` +$ update-desktop-database ~/.local/share/applications +``` + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/use-cpulimit-to-free-up-your-cpu/ + +作者:[Gregory Bartholomew][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/glb/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2021/06/cpulimit-816x345.jpg +[2]: https://unsplash.com/@henning?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]: https://unsplash.com/s/photos/speed-limit?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: https://en.wikipedia.org/wiki/Cgroups +[5]: https://en.wikipedia.org/wiki/Nice_(Unix) +[6]: https://github.com/opsengine/cpulimit +[7]: https://en.wikipedia.org/wiki/Fibonacci_number +[8]: https://en.wikipedia.org/wiki/Task_parallelism diff --git a/published/202106/20210610 Why choose open source for your home automation project.md b/published/202106/20210610 Why choose open source for your home automation project.md new file mode 100644 index 0000000000..ef10c47064 --- /dev/null +++ b/published/202106/20210610 Why choose open source for your home automation project.md @@ -0,0 +1,45 @@ +[#]: subject: "Why choose open source for your home automation project" +[#]: via: "https://opensource.com/article/21/6/home-automation-ebook" +[#]: author: "Alan Smithee https://opensource.com/users/alansmithee" +[#]: collector: "lujun9972" +[#]: translator: "zepoch" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13535-1.html" + +为什么要为你的家庭自动化项目选择开源 +====== + +> 家庭自动化是一个令人兴奋的技术分支。现在开始用开源工具为你的家庭自动化设计一套解决方案吧。 + +![](https://img.linux.net.cn/data/attachment/album/202106/29/215353tk85i7m1myggvu8g.jpg) + +行动起来吧。科技的关键是让生活更加美好。 + +当然,“更好”的标准因人而异,取决于他们在特定时刻的需求。尽管如此,技术具有影响许多不同阶段生活的独特能力。对一些人来说,科技提供了一个轻松的下午娱乐,而对另一些人来说,它提供导航帮助、改善医疗保健或更精确的科学研究。 + +有趣的是,为一个目的开发的技术很少与用于另一个目的的技术完全无关。例如,运动相机的进步使得一个人可以记录她们在滑雪场上的滑雪过程,也可以使得人体摄像头来帮助防止警察侵犯人权。3D 打印的进步可以让一个人可以制作超级英雄的动作手办,也使得志愿者可以为体弱者制造氧气呼吸机成为可能。技术很重要,它影响着我们所有人。 + +开源的工作之一是确保每个人都能获得技术进步,无论种族、性别、国籍、身体能力、宗教信仰或财富如何。可悲的是,有些公司将技术视为一种工具来获取有关其客户(即你和我!)的数据,即使这些客户为该技术的研究和开发提供资金。不过,这不是开源的目标,开源项目保护其用户。 + +是的,家庭自动化是一种现代便利,它正在变得一天比一天好。但这是你的家。开源家庭自动化可以让生活变得更轻松,更像是所有科幻书籍和电影中承诺的未来。但它也可以改善那些身体能力与电器制造商计划不同的人的生活。一个简单的 Python 脚本对一个用户来说可能只是带来了一些便利,而对其他人来说却可能会改变生活。 + +家庭自动化是一个令人兴奋和有趣的技术分支。 借助这本 **[电子书][2]**,立即开始设计你的家庭自动化解决方案,然后与他人分享你的创新,让每个人都能受益。 + +这就是开源的真正意义所在:可以帮助世界上的所有人。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/home-automation-ebook + +作者:[Alan Smithee][a] +选题:[lujun9972][b] +译者:[zepoch](https://github.com/zepoch) +校对:[wxy](https://github.com/wxy) + +本文由 [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/wfh_work_home_laptop_work.png?itok=VFwToeMy "Working from home at a laptop" +[2]: https://opensource.com/downloads/home-automation-ebook diff --git a/published/202106/20210611 RTFM- How to Read (and Understand) the Fantastic Man Pages in Linux.md b/published/202106/20210611 RTFM- How to Read (and Understand) the Fantastic Man Pages in Linux.md new file mode 100644 index 0000000000..aa785206b5 --- /dev/null +++ b/published/202106/20210611 RTFM- How to Read (and Understand) the Fantastic Man Pages in Linux.md @@ -0,0 +1,349 @@ +[#]: subject: (RTFM! How to Read \(and Understand\) the Fantastic Man Pages in Linux) +[#]: via: (https://itsfoss.com/linux-man-page-guide/) +[#]: author: (Bill Dyer https://itsfoss.com/author/bill/) +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13478-1.html) + +RTFM!如何阅读(和理解)Linux 中神奇的手册页 +====== + +![](https://img.linux.net.cn/data/attachment/album/202106/12/161749re6iiuhzn9ni2in4.jpg) + +手册页man pages,即参考手册页reference manual pages的简称,是你进入 Linux 的钥匙。你想知道的一切都在那里,包罗万象。这套文档永远不会赢得普利策奖,但这套文档是相当准确和完整的。手册页是主要信源,其权威性是众所周知的。 + +虽然它们是源头,但阅读起来并不是最令人愉快的。有一次,在很久以前的哲学课上,有人告诉我,阅读 [亚里士多德][1] 是最无聊的阅读。我不同意:说到枯燥的阅读,亚里士多德远远地排在第二位,仅次于手册页。 + +乍一看,这些页面可能看起来并不完整,但是,不管你信不信,手册页并不是为了隐藏信息 —— 只是因为信息量太大,这些页面必须要有结构,而且信息是以尽可能简短的形式给出的。这些解释相当简略,需要一些时间来适应,但一旦你掌握了使用它们的技巧,你就会发现它们实际上是多么有用。 + +### Linux 中的手册页入门 + +这些页面是通过一个叫做 `man` 的工具查看的,使用它的命令相当简单。在最简单的情况下,要使用 `man`,你要在命令行上输入 `man`,后面加一个空格和你想查询的命令,比如 `ls` 或 `cp`,像这样: + +``` +man ls +``` + +`man` 会打开 `ls` 命令的手册页。 + +![][2] + +你可以用方向键上下移动,按 `q` 退出查看手册页。通常情况下,手册页是用 `less` 打开的,所以 `less` 命令的键盘快捷键在 `man` 中也可以使用。 + +例如,你可以用 `/search_term` 来搜索一个特定的文本,等等。 + +有一个关于手册页的介绍,这是一篇值得阅读介绍。它非常详细地说明了手册页是如何布局和组织的。 + +要看这个页面,请打开一个终端,然后输入: + +``` +man man +``` + +![man page of man][3] + +### 节 + +在你开始更深入地研究手册页之前,知道手册页有一个固定的页面布局和一个归档方案会有帮助。这可能会让新手感到困惑,因为我可以说:“看手册页中关于 `ls` 的 NAME section”,我也可以说:“看第 5 section中的 `passwd` 的手册页。” + +我把 “section” 这个词用斜体字表示,是为了显示混淆的来源。这个词,“节” 被用于两种不同的方式,但并不总是向新人解释其中的区别。 + +我不确定为什么会出现这种混淆,但我在培训新用户和初级系统管理员时看到过几次这种混淆。我认为这可能是隧道视野,专注于一件事会使一个人忘记另一件事。一叶障目,不见泰山。 + +对于那些已经知道其中的区别的人,你可以跳过这一小节。这一部分是针对那些刚接触到手册页的人。 + +这就是区别: + +#### 对于手册页 + +单独的手册页是用来显示信息块的。例如,每个手册页都有一个“NAME”节,显示命令的名称和简短的描述。还会有另一个信息块,称为“SYNOPSIS”,显示该命令是如何使用的,以此类推。 + +![][4] + +每个手册页都会有这些,以及其他的标题。这些在各个手册页上的节,或者说标题,有助于保持事情的一致性和信息的分工。 + +#### 对于手册 + +使用“节”,如 “查看第 5 节中的 `passwd` 的手册页”,是指整个手册的内容。当我们只看一页时,很容易忽略这一点,但是 `passwd` 手册页是同一本手册的一部分,该手册还有 `ls`、`rm`、`date`、`cal` 等的手册页。 + +整个 Linux 手册是巨大的;它有成千上万的手册页。其中一些手册页有专门的信息。有些手册页有程序员需要的信息,有些手册页有网络方面的独特信息,还有一些是系统管理员会感兴趣的。 + +这些手册页根据其独特的目的被分组。想想看,把整个手册分成几个章节 —— 每章有一个特定的主题。有 9 个左右的章节(非常大的章节)。碰巧的是,这些章节被称为“节”。 + +总结一下: + + * 手册中单页(我们称之为“手册页”)的节是由标题定义的信息块。 + * 这个大的手册(所有页面的集合)中的章节,刚好被称为“节”。 + +现在你知道区别了,希望本文的其余部分会更容易理解。 + +### 手册页的节 + +你将会看到不同的手册页,所以让我们先研究一下各个页面的布局。 + +手册页被分成几个标题,它们可能因提供者不同而不同,但会有相似之处。一般的分类如下: + + * `NAME`(名称) + * `SYNOPSIS`(概要) + * `DESCRIPTION`(描述) + * `EXAMPLES`(例子) + * `DIAGNOSTICS`(诊断) + * `FILES`(文件) + * `LIMITS`(限制) + * `PORTABILITY`(可移植性) + * `SEE ALSO`(另见) + * `HISTORY`(历史) + *  WARNING`(警告)或 `BUGS`(错误) + * `NOTES`(注意事项) + +`NAME` - 在这个标题下是命令的名称和命令的简要描述。 + +`SYNOPSIS` - 显示该命令的使用方法。例如,这里是 `cal` 命令的概要: + +``` +cal [Month] [Year] +``` + +概要以命令的名称开始,后面是选项列表。概要采用命令行的一般形式;它显示了你可以输入的内容和参数的顺序。方括号中的参数(`[]`)是可选的;你可以不输入这些参数,命令仍然可以正常工作。不在括号内的项目必须使用。 + +请注意,方括号只是为了便于阅读。当你输入命令时,不应该输入它们。 + +`DESCRIPTION` - 描述该命令或工具的作用以及如何使用它。这一节通常以对概要的解释开始,并说明如果你省略任何一个可选参数会发生什么。对于长的或复杂的命令,这一节可能会被细分。 + +`EXAMPLES ` - 一些手册页提供了如何使用命令或工具的例子。如果有这一节,手册页会尝试给出一些简单的使用例子,以及更复杂的例子来说明如何完成复杂的任务。 + +`DIAGNOSTICS` - 本节列出了由命令或工具返回的状态或错误信息。通常不显示不言自明的错误和状态信息。通常会列出可能难以理解的信息。 + +`FILES` - 本节包含了 UNIX 用来运行这个特定命令的补充文件的列表。这里,“补充文件”是指没有在命令行中指定的文件。例如,如果你在看 `passwd` 命令的手册,你可能会发现 `/etc/passwd` 列在这一节中,因为 UNIX 是在这里存储密码信息。 + +`LIMITS` - 本节描述了一个工具的限制。操作系统和硬件的限制通常不会被列出,因为它们不在工具的控制范围内。 + +`PORTABILITY` - 列出其他可以使用该工具的系统,以及该工具的其他版本可能有什么不同。 + +`SEE ALSO` - 列出包含相关信息的相关手册页。 + +`HISTORY` - 提供命令的简要历史,如它第一次出现的时间。 + +`WARNING` - 如果有这个部分,它包含了对用户的重要建议。 + +`NOTES` - 不像警告那样严重,但也是重要的信息。 + +同样,并不是所有的手册都使用上面列出的确切标题,但它们足够接近,可以遵循。 + +### 手册的节 + +整个 Linux 手册集合的手册页传统上被划分为有编号的节: + + **第 1 节**:Shell 命令和应用程序 + **第 2 节**:基本内核服务 - 系统调用和错误代码 + **第 3 节**:为程序员提供的库信息 + **第 4 节**:网络服务 - 如果安装了 TCP/IP 或 NFS 设备驱动和网络协议 + **第 5 节**:文件格式 - 例如:显示 `tar` 存档的样子 + **第 6 节**:游戏 + **第 7 节**:杂项文件和文档 + **第 8 节**:系统管理和维护命令 + **第 9 节**:不知名的内核规格和接口 + +将手册页分成这些组,可以使搜索更有效率。在我工作的地方,我有时会做一些编程工作,所以我花了一点时间看第 3 节的手册页。我也做一些网络方面的工作,所以我也知道要涉足网络部分。作为几个实验性机器的系统管理员,我在第 8 节花了很多时间。 + +将手册网归入特定的节(章节),使搜索信息更加容易 —— 无论是对需要搜索的人,还是对进行搜索的机器。 + +你可以通过名称旁边的数字来判断哪个手册页属于哪个部分。例如,如果你正在看 `ls` 的手册页,而页面的最上面写着。 `LS(1)`,那么你正在浏览第 1 节中的 `ls` 页面,该节包含关于 shell 命令和应用程序的页面。 + +下面是另一个例子。如果你在看 `passwd` 的手册页,页面的顶部显示: `PASSWD(1)`,说明你正在阅读第 1 节中描述 `passwd` 命令如何更改用户账户密码的手册页。如果你看到 `PASSWD(5)`,那么你正在阅读关于密码文件和它是如何组成的的手册页。 + +![][5] + +`passwd` 恰好是两个不同的东西:一个是命令的名称,一个是文件的名称。同样,第 1 节描述了命令,而第 5 节涉及文件格式。 + +括号中的数字是重要的线索 —— 这个数字告诉你正在阅读的页面来自哪一节。 + +### 搜索一个特定的节 + +基本命令: + +``` +man -a name +``` + +将在每一节中搜索由 `name` 标识的手册页,按数字顺序逐一显示。要把搜索限制在一个特定的部分,请在 `man` 命令中使用一个参数,像这样: + +``` +man 1 name +``` + +这个命令将只在手册页的第 1 节中搜索 `name`。使用我们前面的 `passwd` 例子,这意味着我们可以保持搜索的针对性。如果我想阅读 `passwd` 命令的手册页,我可以在终端输入以下内容: + +``` +man 1 passwd +``` + +`man` 工具将只在第 1 节中搜索 `passwd` 并显示它。它不会在任何其他节中寻找 `passwd`。 + +这个命令的另一种方法是输入: `man passwd.1`。 + +### 使用 man -k 来搜索包含某个关键词的所有手册页 + +如果你想获得包含某个关键词的手册页的列表,`man` 命令中的 `-k` 选项(通常称为标志或开关)可以派上用场。例如,如果你想看一个关于 `ftp` 的手册列表,你可以通过输入以下内容得到这个列表: + +``` +man -k ftp +``` + +在接下来的列表中,你可以选择一个特定的手册页来阅读: + +![man k example][6] + +在某些系统上,在 `man -k` 工作之前,系统管理员需要运行一个叫做 `catman` 的工具。 + +### 使用 whatis 和 whereis 命令来了解手册的各个节 + +有两个有趣的工具可以帮助你搜索信息:`whatis`和 `whereis`。 + +#### whatis + +有的时候,我们完全可以得到我们需要的信息。我们需要的信息有很大的机会是可以找到的 —— 找到它可能是一个小问题。 + +例如,如果我想看关于 `passwd` 文件的手册页,我在终端上输入: + +``` +man passwd +``` + +我就会看到关于 `passwd` 命令所有信息的手册页,但没有关于 `passwd` 文件的内容。我知道 `passwd` 是一个命令,也有一个 `passwd` 文件,但有时,我可能会忘记这一点。这时我才意识到,文件结构在手册页中的不同节,所以我输入了: + +``` +man 4 passwd +``` + +我得到这样的答复: + +``` +No manual entry for passwd in section 4 +See 'man 7 undocumented' for help when manual pages are not available. +``` + +又是一次健忘的失误。文件结构在 System V UNIX 页面的第 4 节中。几年前,当我建立文件时,我经常使用 `man 4 ...`;这仍然是我的一个习惯。那么它在 Linux 手册中的什么地方呢? + +现在是时候调用 `whatis` 来纠正我了。为了做到这一点,我在我的终端中输入以下内容: + +``` +whatis passwd +``` + +然后我看到以下内容: + +``` +passwd (1) - change user password +passwd (1ssl) - compute password hashes +passwd (5) - the password file +``` + +啊!`passwd` 文件的页面在第 5 节。现在没问题了,可以访问我想要的信息了: + +``` +man 5 passwd +``` + +然后我被带到了有我需要的信息的手册页。 + +`whatis` 是一个方便的工具,可以用简短的一句话告诉你一个命令的作用。想象一下,你想知道 `cal` 是做什么的,而不想查看手册页。只要在命令提示符下键入以下内容。 + +``` +whatis cal +``` + +你会看到这样的回应: + +``` +cal (1) - displays a calendar and the date of Easter +``` + +现在你知道了 `whatis` 命令,我可以告诉你一个秘密 —— 有一个 `man` 命令的等价物。为了得到这个,我们使用 `-f` 开关:`man -f ...`。 + +试试吧。在终端提示下输入 `whatis cal`。执行后就输入:`man -f cal`。两个命令的输出将是相同的: + +![whatis cal and man f cal outputs are the same][7] + +#### whereis + +`whereis` 命令的名字就说明了这一点 —— 它告诉你一个程序在文件系统中的位置。它也会告诉你手册页的存放位置。再以 `cal` 为例,我在提示符下输入以下内容: + +``` +whereis cal +``` + +我将看到这个: + +![whereis cal output][8] + +仔细看一下这个回答。答案只在一行里,但它告诉我两件事: + +- `/usr/bin/cal` 是 `cal` 程序所在的地方,以及 +- `/usr/share/man/man1/cal.1.gz` 是手册页所在的地方(我也知道手册页是被压缩的,但不用担心 —— `man` 命令知道如何即时解压)。 + +`whereis` 依赖于 `PATH` 环境变量;它只能告诉你文件在哪里,如果它们在你的 `PATH` 环境变量中。 + +你可能想知道是否有一个与 `whereis` 相当的 `man` 命令。没有一个命令可以告诉你可执行文件的位置,但有一个开关可以告诉你手册页的位置。在这个例子中使用 `date` 命令,如果我们输入: + +``` +whereis date +``` + +在终端提示符下,我们会看到: + +![whereis date output][9] + +我们看到 `date` 程序在 `/usr/bin/` 目录下,其手册页的名称和位置是:`/usr/share/man/man1/date.1.gz`。 + +我们可以让 `man` 像 `whereis` 一样行事,最接近的方法是使用 `-w` 开关。我们不会得到程序的位置,但我们至少可以得到手册页的位置,像这样: + +``` +man -w date +``` + +我们将看到这样的返回: + +![][10] + +你知道了 `whatis` 和 `whereis`,以及让 `man` 命令做同样(或接近)事情的方法。我展示了这两种方法,有几个不同的原因。 + +多年来,我使用 `whatis` 和 `whereis`,因为它们在我的培训手册中。直到最近我才了解到 `man -f ...` 和 `man -w ...`。我确信我看了几百次 `man` 的手册页,但我从未注意到 `-f` 和 `-w` 开关。我总是在看手册页的其他东西(例如:`man -k ...`)。我只专注于我需要找到的东西,而忽略了其他的东西。一旦我找到了我需要的信息,我就会离开这个页面,去完成工作,而不去注意这个命令所提供的其他一些宝贝。 + +这没关系,因为这部分就是手册页的作用:帮助你完成工作。 + +直到最近我向别人展示如何使用手册页时,我才花时间去阅读 —— “看看还有什么可能” —— 我们才真正注意到关于 `man` 命令的 `-f` 和 `-w` 标记可以做什么的信息。 + +不管你使用 Linux 多久了,或者多么有经验,总有一些新东西需要学习。 + +手册页会告诉你在完成某项任务时可能需要知道的东西 —— 但它们也有很多内容 —— 足以让你看起来像个魔术师,但前提是你要花时间去读。 + +### 结论 + +如果你花一些时间和精力在手册页上,你将会取得胜利。你对手册页的熟练程度,将在你掌握 Linux 的过程中发挥巨大作用。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/linux-man-page-guide/ + +作者:[Bill Dyer][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/bill/ +[b]: https://github.com/lujun9972 +[1]: https://www.britannica.com/biography/Aristotle +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/man-page-example-800x527.png?resize=800%2C527&ssl=1 +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/man_man.png?resize=800%2C455&ssl=1 +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/man-page-example-1.png?resize=800%2C527&ssl=1 +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/man-page-passwd-command.png?resize=1026%2C676&ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/man-k_example.png?resize=800%2C200&ssl=1 +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/05/whatis_cal_man-f_cal.png?resize=800%2C135&ssl=1 +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/whereis_cal.png?resize=800%2C100&ssl=1 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/whereis_date.png?resize=800%2C100&ssl=1 +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/man-w_date-1.png?resize=800%2C100&ssl=1 diff --git a/published/202106/20210613 How Free - Open Source Software Can Save Online Privacy.md b/published/202106/20210613 How Free - Open Source Software Can Save Online Privacy.md new file mode 100644 index 0000000000..b1334ad866 --- /dev/null +++ b/published/202106/20210613 How Free - Open Source Software Can Save Online Privacy.md @@ -0,0 +1,147 @@ +[#]: subject: (How Free & Open Source Software Can Save Online Privacy) +[#]: via: (https://news.itsfoss.com/save-privacy-with-foss/) +[#]: author: (Team It's FOSS https://news.itsfoss.com/author/team/) +[#]: collector: (lujun9972) +[#]: translator: (zz-air) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13512-1.html) + +自由/开源软件如何保护在线隐私 +====== + +![](https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/online-privacy.png?w=1200&ssl=1) + +_多年来,我一直使用科技巨头提供的服务。大部分都是免费的,但是是以牺牲我的隐私为代价的。但那些日子已经过去了,现在我浏览、聊天、工作,没有任何人能跟踪、变现和审查我的数据。多亏了自由/开源软件。_ + +### 我开始担心大型科技公司了 + +![][1] + +我一直觉得机器应该按照我的意愿行事,而不是反过来。这就是为什么谷歌的 Android 操作系统在 2008 年首次上市时就立刻吸引了我。在当时,谷歌的开源方式确实令人耳目一新。我花了几个小时定制了我的 HTC Hero 手机。我对它是不是比我朋友的 iPhone 或塞班设备更丑并不在意。我的新玩意具有无限的通用性。 + +一跃十年,谷歌已经成为了科技巨头,使 iOS 相形见绌并且淘汰了塞班操作系统。如今,这个公司占据了 90% 以上的搜索流量,并主导着浏览器市场。这种惊人的增长是有代价的,谷歌删除了“不作恶”条款就说明了这一点。这家搜索巨头目前正陷入官司之中,比如关于 [数据收集和追踪不当行为][2] 的案件。研究人员还在谷歌的联系人追踪应用程序中发现了 [隐私缺陷][3]。更重要的是,这家科技巨头宣布了一个颇具争议的 [可以追踪用户浏览行为][4] 的新算法,从而更好地提供广告服务。 + +现在,我不想把责任推给谷歌。亚马逊刚刚建立了美国历史上最大的民用 [监控网络][5] 。它让警方可以在未经许可的情况下使用数百万个家庭监控摄像头。于此同时,欧洲对亚马逊遵守 [隐私规定][6] 的情况进行了调查。微软也是如此。它也为顺带着促进 [工作场所监控][7] 功能而道歉。 + +有人可能认为,人们至少可以指望苹果来保护他们的隐私。这家科技巨头最近让他们选择知道应用程序是否会追踪他们的行为。事实证明,[只有 5%][8] 的美国用户选择接受这种新的应用追踪透明度。与此同时,该公司从谷歌这样的数据经纪商的业务中获得了 [巨大的利益][9]。更别提《堡垒之夜》开发商 Epic Games 和苹果之间的 [反垄断审判][10] ,后者声称要保护其应用商店的隐私。当然,还有 Facebook。该公司的隐私不当行为在参议院就 [剑桥分析公司][11] 丑闻举行的听证会上达到了高潮,失去了用户仅存的信任。 + +尽管如此 —— 或者因为 —— 这些有问题的做法,这些公司的总价值在 2021 年 3 月超过了 [7.5 万亿美元][12]。“科技巨头”们 现在超过了德国和英国国内生产总值的总和! + +### 为什么隐私很重要 + +![][13] + +我们都在使用大科技公司的服务。我们是 [监控资本主义][14]Surveillance Capitalism 的一部分,这是哈佛大学教授 Shoshana Zuboff 创造的一个术语,在 Cory Doctorow 的 [新书][15]《监控资本主义》里也讨论了它。这是一个以技术垄断为中心的经济体系,通过收集个人数据来获取利润最大化。这一制度威胁到民主的核心,因为它导致了大规模监视,扰乱了选举程序,推动了思想的一致性和审查制度。 + +监视资本主义的基础是对我们生活的侵犯,令人深感不安。我们往往忘记隐私是一项基本权利。它被联合国人权理事会UN Human Rights Council、《公民权利与政治权利国际公约International Covenant on Civil and Political Rights》和一些条约所规定。我认为我们都能体会到:在我们的生活中有很多方面我们想要保持隐私,即使没有错误的行为。无论是为了自由地表达自己,探索自己的个性,而不被他人评判。还是为了保护我们不受监视、审查和操纵。这就是窗帘被发明的原因。还有银行保密、律师-客户特权,通信保密,投票保密,告解室保密或医疗保密。 + +解决网络隐私问题是一个广泛问题,它需要对我们的法律体系和社会习俗的全面改变。对技术垄断的监管是这个十年的主要挑战之一。最近科技巨头和政府之间的对峙就说明了这一点:[澳大利亚 vs. Facebook][16]、 [中国 vs. 腾讯][17]、 [印度 vs. WhatsApp][18]、[欧盟 vs. Facebook][19] 或者是 [美国 vs. 科技巨头][20]。多年来,数字权利组织和软件基金会一直在倡导更好的隐私法律、用户权利和创新自由,如:电子前沿基金会Electronic Frontier Foundation自由软件基金会Free Software Foundation新闻自由基金会Freedom of the Press Foundation隐私国际Privacy International开放权利组织Open Rights Group欧洲数字权利European Digital Rights。 + +### 这和自由/开源软件有什么关系? + +![][21] + +自 1983 年成立以来,[自由软件运动][22]Free Software movement 已经成为一个相当多样化的社区。自由和开源软件通常被称为 FOSS、FLOSS、Libre Software 或 Free Software。 它包括一系列许可证,授权给用户 [使用、学习、分享并提高][23] 这个软件的权力。以及 [维修][24] 的权利。 自由软件Free Software的“自由Free”是指 “[言论自由][25]”的“自由”,有时也指 “免费啤酒”的“免费”。因此,自由/开源软件(FOSS)不仅仅是技术。它是关于社会、政治和经济解放的。 + +几年前,一场隐私争议震动了自由软件社区。Ubuntu 12.10(各种不同的 GHU/Linux 风格之一)开始在人们的电脑上建立互联网连接进行本地搜索。它为亚马逊提供广告服务,并与 Facebook 或 Twitter 共享私人数据。遭到了 [剧烈反弹][26]。几年后, Canonical(Ubuntu 背后的公司)最终取消了在线搜索和亚马逊 Web 应用。最近 [Audacity 闹剧][27] 是自由/开源软件如何保护隐私的另一个例子。新的项目管理层决定将谷歌的 Analytics 和 Yandex 添加到音频软件中,但由于公众的强烈抗议,最终放弃了这一计划。 + +尽管自由软件有很多优点,但它也不能免于批评。一种说法是自由/开源软件项目经常被放弃。然而最近在 [实证软件工程和测量会议][28] 上提出的一项研究表明,情况并非如此:在 1932 个流行的开源项目中,有 7%(128 个项目)在被忽视后由新的开发人员接管,使烂尾率降低到不到 10%(187 个项目)。 + +另一个常见的批评是自由/开源软件通过公布代码暴露了潜在的安全漏洞。另一方面,将源代码保密 [不一定会提高安全性][29]。认为封闭源代码要比自由/开源软件安全得多的观点,却忽略了一个事实,即专有堆栈越来越多地构建在 [开放源代码之上][30]。自由软件也倾向于去中心化,这有助于增强抵御监视、单点故障或大规模数据泄露。所以可以肯定的是,自由/开源软件并不能避免安全漏洞。但专有的解决方案也是如此,正如来自 Facebook、Linkedin 和 Clubhouse 的最新 [10 亿人的数据泄露][31] 或者对 SolarWind 和 Colonial 管道公司的大规模 [安全攻击][32] 所说明的那样。 + +总之,自由软件在促进网上隐私方面发挥了重要作用。近四十年来,自由/开源软件一直鼓励开发人员审计代码、修复问题并确保幕后没有任何可疑的事情发生。 + +### 使用自由/开源软件实现在线隐私的七个步骤 + +![][33] + +在等待更好的隐私法律出台的同时,还有很多事情可以让你的设备更隐私。以下是用尊重隐私、自由/开源软件取代大型科技公司的七个步骤。 根据你的 [威胁模型][34],你可能想首先考虑步骤 1 到步骤 4,因为它们已经提供了一个合理的隐私水平。如果你有一些技术技能,想要更进一步,看看步骤 5 到步骤 7。 + + 1. **[参与到隐私保护中来][35]**。关于在线隐私、数据利用、过滤泡沫、监控和审查,还有很多值得我们讨论和学习的地方。参与进来,传播信息。 + 2. **[选择一个安全和隐私的浏览器][36]**。切换到 Firefox。阻止追踪器、cookie 和广告。使用尊重隐私的搜索引擎。可能要用 Tor 或 VPN 加密你的通信。 + 3. **[保持交流的私密性][37]**。使用端到端加密保护你的电子邮件、消息和电话。抛弃传统的社交媒体,探索 fediversity ,这是一个由各种在线服务组成的联合家庭。 + 4. **[保护你的数据][38]**。使用长且独特的密码。为你的每个账户和设备选择一个不同的密码。将它们安全地保存在加密的密码管理器中。考虑使用双因素身份验证。创建一个常规备份例程。并对敏感数据进行加密。 + 5. **[解绑你的电脑][39]**。切换到 GNU/Linux ,并首选自由和开源的应用程序。根据你的需要,选择一个对初学者友好的发行版,如 Linux Mint 或 Ubuntu;对于更有经验的用户,选择 Debian、Manjaro、openSUSE、Fedora 或 Gentoo Linux。对于隐私爱好者,可以看看 Qubes OS、Whonix 或 Tails。 + 6. **[解绑你的手机][40]**。切换到一个定制的移动操作系统,如 LineageOS、CalyxOS、GrapheneOS 或 /e/。首选社区维护的应用商店提供的自由及开源应用。 + 7. **[解绑你的云][41]**。选择尊重隐私的云服务商。或设置你自己的安全服务器和自托管服务,例如云存储、图库、任务和联系人管理,或媒体流。 + +### 结束 + +![][42] + +面对在线隐私没有一键式解决方案。用自由及开源软件取代大型科技公司是一个过程。有些改动很简单,比如安装 Firefox 或 Signal。其他方法需要更多的时间和技能。但它们绝对值得。你并不孤单,你可以依靠一个很棒的社区的支持。所以,请允许我引用《华盛顿邮报》在线专栏的 [Geoffrey A. Fowler][43] 的话作为总结: “_隐私没有消亡,但你必须足够愤怒才能要求它_”。 + +* * * + +### 关于作者 + +![][48] + +_Georg Jerska 是一个对保护公民隐私特别感兴趣的开源爱好者。他和他的小团队运营着 [GoFOSS][44],这是一个关于如何用尊重隐私的自由和开源软件取代大型科技公司的全面指南。_ + +_[开源][46] 插图 [Katerina Limpitsouni][47]。_ + +_所表达的观点只是作者的观点,并不一定反应我们的官方政策或立场。_ + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/save-privacy-with-foss/ + +作者:[Team It's FOSS][a] +选题:[lujun9972][b] +译者:[zz-air](https://github.com/zz-air) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/team/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/big_tech.png?resize=706%2C636&ssl=1 +[2]: https://www.gizmodo.com.au/2021/05/google-location-services-lawsuit +[3]: https://blog.appcensus.io/2021/04/27/why-google-should-stop-logging-contact-tracing-data +[4]: https://news.itsfoss.com/google-floc +[5]: https://www.theguardian.com/commentisfree/2021/may/18/amazon-ring-largest-civilian-surveillance-network-us +[6]: https://edps.europa.eu/press-publications/press-news/press-releases/2021/edps-opens-two-investigations-following-schrems_en +[7]: https://www.theguardian.com/technology/2020/dec/02/microsoft-apologises-productivity-score-critics-derided-workplace-surveillance +[8]: https://www.flurry.com/blog/ios-14-5-opt-in-rate-att-restricted-app-tracking-transparency-worldwide-us-daily-latest-update +[9]: https://www.nytimes.com/2020/10/25/technology/apple-google-search-antitrust.html +[10]: https://www.nytimes.com/2021/05/25/business/dealbook/apple-epic-case.html +[11]: https://en.wikipedia.org/wiki/Cambridge_Analytica +[12]: https://en.wikipedia.org/wiki/List_of_public_corporations_by_market_capitalization#2021 +[13]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/privacy.png?resize=706%2C584&ssl=1 +[14]: https://en.wikipedia.org/wiki/Surveillance_capitalism +[15]: https://www.goodreads.com/book/show/55134785-how-to-destroy-surveillance-capitalism +[16]: https://www.bbc.com/news/world-australia-56163550 +[17]: https://www.nytimes.com/2021/06/02/technology/china-tencent-monopoly.html +[18]: https://www.theguardian.com/world/2021/may/26/whatsapp-sues-indian-government-over-mass-surveillance-internet-laws +[19]: https://nypost.com/2021/05/26/eu-reportedly-set-to-open-formal-antitrust-probe-into-facebook +[20]: https://www.nytimes.com/interactive/2020/10/06/technology/house-antitrust-report-big-tech.html +[21]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/foss.png?resize=706%2C631&ssl=1 +[22]: https://itsfoss.com/what-is-foss +[23]: https://fsfe.org/freesoftware/freesoftware.en.html +[24]: https://framatube.org/videos/watch/99069c5c-5a00-489e-97cb-fd5cc76de77c +[25]: https://www.eff.org/deeplinks/2015/04/remembering-case-established-code-speech +[26]: https://itsfoss.com/canonical-targets-website-crictical-ubuntu-privacy +[27]: https://github.com/audacity/audacity/pull/835 +[28]: https://arxiv.org/abs/1906.08058 +[29]: https://www.schneier.com/crypto-gram/archives/2002/0515.html#1 +[30]: https://www.bcg.com/publications/2021/open-source-software-strategy-benefits +[31]: https://www.politico.eu/article/how-to-leak-data-and-get-away-with-it +[32]: https://theconversation.com/the-colonial-pipeline-ransomware-attack-and-the-solarwinds-hack-were-all-but-inevitable-why-national-cyber-defense-is-a-wicked-problem-160661 +[33]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/steps.png?w=1054&ssl=1 +[34]: https://www.eff.org/files/2015/11/24/3mod_threat-modeling-ssd_9-3-15.pdf +[35]: https://www.gofoss.today/nothing-to-hide +[36]: https://www.gofoss.today/intro-browse-freely +[37]: https://www.gofoss.today/intro-speak-freely +[38]: https://www.gofoss.today/intro-store-safely +[39]: https://www.gofoss.today/intro-free-your-computer +[40]: https://www.gofoss.today/intro-free-your-phone +[41]: https://www.gofoss.today/intro-free-your-cloud +[42]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/gofoss.png?resize=300%2C300&ssl=1 +[43]: https://www.washingtonpost.com/technology/2019/12/31/how-we-survive-surveillance-apocalypse +[44]: https://gofoss.today/ +[45]: https://gofoss.today +[46]: https://undraw.co/license +[47]: https://undraw.co +[48]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/georg.png?resize=300%2C300&ssl=1 \ No newline at end of file diff --git a/published/202106/20210615 Build a static website with Eleventy.md b/published/202106/20210615 Build a static website with Eleventy.md new file mode 100644 index 0000000000..2a78a7b3cb --- /dev/null +++ b/published/202106/20210615 Build a static website with Eleventy.md @@ -0,0 +1,135 @@ +[#]: subject: (Build a static website with Eleventy) +[#]: via: (https://opensource.com/article/21/6/static-site-builder) +[#]: author: (Nwokocha Wisdom https://opensource.com/users/wise4rmgod) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13513-1.html) + +用 Eleventy 建立一个静态网站 +====== + +> Eleventy 是一个基于 JavaScript 的 Jekyll 和 Hugo 的替代品,用于构建静态网站。 + +![](https://img.linux.net.cn/data/attachment/album/202106/23/160000epjn313s1t5ja8wj.jpg) + +静态网站生成器是一种基于原始数据和一组模板生成完整的静态 HTML 网站的工具。它可以自动完成单个 HTML 页面的编码任务,并让这些页面准备好为用户服务。由于 HTML 页面是预先建立的,它们在用户的浏览器中加载得非常快。 + +静态网站对文档也很友好,因为静态网站很容易扩展,而且它们是生成、维护和部署项目文档的一种简单方法。由于这些原因,企业经常使用它们来记录应用编程接口 (API)、数据库模式和其他信息。文档是软件开发、设计和其他方面技术的一个重要组成部分。所有的代码库都需要某种形式的文档,选择范围从简单的 README 到完整的文档。 + +### Eleventy: 一个静态网站生成器 + +[Eleventy][2](11ty)是一个简单的静态网站生成器,是 [Jekyll][3] 和 [Hugo][4] 的替代品。它是用 JavaScript 编写的,它将一个(不同类型的)模板目录转化为 HTML。它也是开源的,在 MIT 许可下发布。 + +Eleventy 可以与 HTML、Markdown、Liquid、Nunjucks、Handlebars、Mustache、EJS、Haml、Pug 和 JavaScript Template Literals 协同工作。 + +它的特点包括: + + * 易于设置 + * 支持多种模板语言(如 Nunjucks、HTML、JavaScript、Markdown、Liquid) + * 可定制 + * 基于 JavaScript,这是许多网络开发者所熟悉的,新用户也容易学习 + +### 安装 Eleventy + +Eleventy 需要 Node.js。在 Linux 上,你可以使用你的包管理器安装 Node.js: + +``` +$ sudo dnf install nodejs +``` + +如果你的包管理器没有 Node.js,或者你不在 Linux 上,你可以从 Node.js 网站[安装它][5]。 + +Node.js 安装完毕后,就用它来安装 Eleventy: + +``` +$ npm install -g @11ty/eleventy +``` + +这就完成了! + +### 为你的文档建立一个静态网站 + +现在你可以开始使用 Eleventy 来建立你的静态文档网站。以下是需要遵循的步骤。 + +#### 1、创建一个 package.json 文件 + +要将 Eleventy 安装到你的项目中,你需要一个 `package.json` 文件: + +``` +$ npm init -y +``` + +#### 2、将 Eleventy 安装到 package.json 中 + +安装 Eleventy 并保存到你的项目的 `package.json` 中。运行: + +``` +$ npm install-save-dev @11ty/eleventy +``` + +#### 3、运行 Eleventy + +使用 `npx` 命令来运行你本地项目的 Eleventy 版本。在你确认安装完成后,尝试运行 Eleventy: + +``` +$ npx @11ty/eleventy +``` + +#### 4、创建一些模板 + +现在运行两个命令来创建两个新的模板文件(一个 HTML 和一个 Markdown 文件): + +``` +$ cat << EOF >> index.html + + +Page title + +

Hello world

+ +EOF +$ echo '# Page header' > index.md +``` + +这就把当前目录或子目录中的任何内容模板编译到输出文件夹中(默认为 `_site`)。 + +运行 `eleventy --serve` 来启动一个开发网络服务器。 + +``` +$ npx @11ty/eleventy-serve +``` + +在你的网络浏览器中打开 `http://localhost:8080/README/`,看你的 Eleventy 输出。 + +然后把 `_site` 中的文件上传到你的 Web 服务器,发布你的网站给世界看。 + +### 尝试 Eleventy + +Eleventy 是一个静态网站生成器,它易于使用,有模板和主题。如果你已经在你的开发流程中使用 Node.js,Eleventy 可能比 Jekyll 或 Hugo 更自然。它能快速提供很好的结果,并使你免于复杂的网站设计和维护。要了解更多关于使用 Eleventy 的信息,请仔细阅读它的[文档][6]。 + +* * * + +_本文基于 [为开源项目建立技术文档静态网站][7],首次发布在 Nwokocha Wisdom Maduabuchi 的 Medium 上,经授权转载。_ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/static-site-builder + +作者:[Nwokocha Wisdom][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/wise4rmgod +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_desk_home_laptop_browser.png?itok=Y3UVpY0l (Digital images of a computer desktop) +[2]: https://www.11ty.dev/ +[3]: https://opensource.com/article/17/4/getting-started-jekyll +[4]: https://opensource.com/article/18/3/start-blog-30-minutes-hugo +[5]: https://nodejs.org/en/ +[6]: https://www.11ty.dev/docs/getting-started/ +[7]: https://wise4rmgodadmob.medium.com/building-a-technical-documentation-static-site-for-open-source-projects-7af4e73d77f0 diff --git a/published/202106/20210615 Try this new open source tool for data analytics.md b/published/202106/20210615 Try this new open source tool for data analytics.md new file mode 100644 index 0000000000..dbc5fc37b3 --- /dev/null +++ b/published/202106/20210615 Try this new open source tool for data analytics.md @@ -0,0 +1,77 @@ +[#]: subject: (Try this new open source tool for data analytics) +[#]: via: (https://opensource.com/article/21/6/cubejs) +[#]: author: (Ray Paik https://opensource.com/users/rpaik) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13517-1.html) + +Cube.js:试试这个新的数据分析开源工具 +====== + +> Cube.js 是一个开源的分析平台,可以作为数据源和应用之间的中间层。 + +![](https://img.linux.net.cn/data/attachment/album/202106/24/114907z53fpzv6szv936vj.jpg) + +数据分析是一个时髦的领域,有许多解决方案可供选择。其中之一是 [Cube.js][2],这是一个开源的分析平台。你可以把 Cube.js 看作是你的数据源和应用之间的一个中间层。 + +如下图所示,Cube.js 支持无服务器数据仓库和大多数现代关系型数据库管理系统 (RDBMS)。你可以使用任何用于数据可视化的 JavaScript 前端库,而 Cube.js 将负责其他工作,包括访问控制、性能、并发性等。 + +![Cube.js architecture][3] + +### 主要优点 + +当我向我们的社区成员询问 Cube.js 的主要优点时,他们经常提到: + + * **它的抽象层**:配置 Cube.js 后,人们说他们不再需要担心性能优化、资源管理、SQL 专业知识等问题。许多人把 Cube.js 称为 “黑盒”,因为它的抽象层帮助他们专注于理解数据,而不是实施细节。 + * **易于定制**:由于 Cube.js 是可视化的,它很容易与前端框架集成,建立看起来像用户自己平台的解决方案。大多数商业平台(如 Looker、Tableau 等)需要更多的定制工作来与他们的基础设施整合。许多用户说,定制的便利性与抽象层相结合,使他们能够减少数据分析平台的开发时间。 + * **社区支持**:在开始使用 Cube.js 时,人们通常会从社区成员那里得到帮助(特别是在我们的 [Slack][4]),许多人提到社区支持是一个关键的入门资源。 + +访问 [用户故事页面][5],阅读更多关于人们使用 Cube.js 的经验以及他们如何使用它。 + +### 开始使用 + +如果你想了解 Cube.js: + + * 进入我们的 [文档页面][6],点击**开始**,并按照指示在你的笔记本电脑或工作站上启动和运行 Cube.js。 + * 当你进入 [Developer Playground][7],你将能够生成数据模式,执行查询,并建立仪表盘,以看到 Cube.js 的运行。 + +在你启动和运行 Cube.js 之后,这里有一些有用的资源: + + * [文档][6]:我们把大量的精力放在我们的文档上,因为它是开源社区的重要资源。我们还在我们的文档页面和 YouTube 频道的 [入门播放列表][8] 中添加了视频剪辑。 + * [Discourse][9]:Cube.js 论坛是最近增加的,社区成员可以在这里分享他们的使用案例、技巧和窍门等,这样我们就可以建立一个社区知识库。 + * [GitHub][10]: 你可以在这里找到 Cube.js 的代码,社区成员可以通过 [问题页面][11] 提交错误或功能请求。我们还在 GitHub 上发布了我们的 [季度路线图][12],以便每个人都能看到我们正在进行的工作。 + * [每月社区电话会议][13]:我们在每个月的第二个星期三举行电话会议,讨论社区更新,展示功能演示,并邀请社区成员分享他们的使用案例。你可以在 [社区电话会议页面][13] 上找到电话会议的日程,你也可以在我们 YouTube 频道的 [社区电话会议播放列表][14] 上找到过去的电话会议录音。 + +就像任何好的开源项目一样,Cube.js 有许多软件贡献者。如果你想查看社区的拉取请求(PR),请搜索带有 `pr:community` 标签的 PR。如果你想寻找你可以回答的问题,请搜索带有 `good first issue` 或者 `help wanted` 标签的问题。 + +我希望你试试 Cube.js。如果你有任何问题,请随时在下面留言或在 [Cube.js Slack][4] 上找我! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/cubejs + +作者:[Ray Paik][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/rpaik +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_data_dashboard_system_computer_analytics.png?itok=oxAeIEI- (metrics and data shown on a computer screen) +[2]: https://cube.dev/ +[3]: https://opensource.com/sites/default/files/uploads/cubejs-architecture.png (Cube.js architecture) +[4]: https://slack.cube.dev/ +[5]: https://cube.dev/blog/category/user-stories/ +[6]: https://cube.dev/docs/ +[7]: https://cube.dev/docs/dev-tools/dev-playground +[8]: https://www.youtube.com/playlist?list=PLtdXl_QTQjpaXhVEefh7JCIdtYURoyWo9 +[9]: https://forum.cube.dev/ +[10]: https://github.com/cube-js/cube.js +[11]: https://github.com/cube-js/cube.js/issues +[12]: https://github.com/cube-js/cube.js/projects +[13]: https://cube.dev/community-call/ +[14]: https://www.youtube.com/playlist?list=PLtdXl_QTQjpb1dHZCM09qKTsgvgqjSvc9 diff --git a/published/202106/20210615 With Deskreen, You Can Mirror or Stream Your Linux Computer Screen to Any Device.md b/published/202106/20210615 With Deskreen, You Can Mirror or Stream Your Linux Computer Screen to Any Device.md new file mode 100644 index 0000000000..27c26b9203 --- /dev/null +++ b/published/202106/20210615 With Deskreen, You Can Mirror or Stream Your Linux Computer Screen to Any Device.md @@ -0,0 +1,119 @@ +[#]: subject: (With Deskreen, You Can Mirror or Stream Your Linux Computer Screen to Any Device) +[#]: via: (https://itsfoss.com/deskreen/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13507-1.html) + +用 Deskreen 将你的 Linux 屏幕镜像或串流到任何设备上 +====== + +其它平台上的屏幕共享或屏幕镜像应用并不那么好。尽管大多数选项仅适用于 Windows/Mac,而你可能很难找到一个适用于 Linux 的开源解决方案。 + +有了这个应用,你可以与连接到网络的任何设备共享你的屏幕。 + +如果你有多显示器设置,你会意识到拥有多个屏幕的好处。而且,有了 Deskreen,你可以把任何设备变成你的副屏,多么令人激动啊! + +### Deskreen:将任何设备变成你的 Linux 系统的副屏 + +![我把我的 Linux Mint 桌面镜像到我的 Android 手机上][1] + +[Deskreen][2] 是一个自由开源的应用,可以让你使用任何带有 Web 浏览器的设备来作为电脑的副屏。 + +如果你愿意,它还支持多个设备连接。 + +Deskreen 很容易使用,当你的所有设备都连接到同一个 Wi-Fi 网络时,它可以正常工作。 + +让我们来看看它的功能和工作原理。 + +### Deskreen 的功能 + +Deskreen 的功能包括以下要点: + + * 分享整个屏幕的能力 + * 选择一个特定的应用窗口进行串流 + * 翻转模式,将你的屏幕作为提词器使用 + * 支持多种设备 + * 高级视频质量设置 + * 提供端对端加密 + * 最小的系统要求 + * 黑暗模式 + +没有一个冗长的功能列表,但对大多数用户来说应该是足够的。 + +### 如何使用 Deskreen 应用? + +Deskreen 使用分为三个简单的步骤,让我为你强调一下,以便你开始使用: + +首先,当你启动该应用时,它会显示一个二维码和一个 IP 地址,以帮助你用 Web 浏览器连接其他设备,以串流你的屏幕。 + +![][4] + +你可以按你喜欢的方式,在你的辅助设备上的 Web 浏览器的帮助下建立连接。 + +当你扫描二维码或在浏览器的地址栏中输入 IP 地址,你会在 Deskreen 应用上得到一个提示,允许或拒绝连接。除非是你不认识它,否则就允许吧。 + +![][5] + +接下来,你将被要求选择你想要串流的内容(你的整个屏幕或特定的应用窗口): + +![][6] + +你可以选择串流整个屏幕或选择你想串流的窗口。然而,并不是每个应用窗口都能被检测到。 + +在我的快速测试中,我没有检测到 Rocket.Chat 应用窗口,但它似乎能检测到 Slack 窗口、Deskscreen 窗口和终端。 + +![][7] + +你只需要选择源并确认,就可以了。你应该注意到它在你的副屏(手机/桌面)上开始串流。 + +![][8] + +这是它完成后的样子: + +![][9] + +Deskreen 还为你提供了管理连接设备的能力。因此,如果你需要断开任何会话或所有会话的连接,你可以从设置中进行操作。 + +### 在 Linux 中安装 Deskreen + +你会找到一个用于 Linux 机器的 DEB 包和 AppImage 文件。如果你不知道,可以通过我们的 [安装 DEB 包][10] 和 [使用 AppImage 文件][11] 指南来安装它。 + +你可以从 [官方网站][2] 下载它,或者从它的 [GitHub 页面][12]探索更多的信息。 + +- [Deskreen][2] + +### 结束语 + +考虑到它使用 Wi-Fi 网络工作,在串流方面绝对没有问题。这是一种奇妙的方式,可以与别人分享你的屏幕,或者出于任何目的将其串流到第二个设备上。 + +当然,它不能取代你的电脑的第二个显示器的优势,但在一些使用情况下,你可能不需要第二个屏幕。 + +现在,我想问你,你能想到哪些实际应用可以用到 Deskreen? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/deskreen/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/deskreen-app.jpg?resize=800%2C450&ssl=1 +[2]: https://deskreen.com/lang-en +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/deskreen-connect.png?resize=800%2C559&ssl=1 +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/deskscreen-connect.png?resize=800%2C553&ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/deskreen-select.png?resize=800%2C549&ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/deskreen-app-window.png?resize=800%2C551&ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/deskreen-confirm-1.png?resize=800%2C554&ssl=1 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/deskscreen-done.png?resize=873%2C599&ssl=1 +[10]: https://itsfoss.com/install-deb-files-ubuntu/ +[11]: https://itsfoss.com/use-appimage-linux/ +[12]: https://github.com/pavlobu/deskreen diff --git a/published/202106/20210616 Migrate virtual machines to Kubernetes with this new tool.md b/published/202106/20210616 Migrate virtual machines to Kubernetes with this new tool.md new file mode 100644 index 0000000000..97814b89e0 --- /dev/null +++ b/published/202106/20210616 Migrate virtual machines to Kubernetes with this new tool.md @@ -0,0 +1,95 @@ +[#]: subject: (Migrate virtual machines to Kubernetes with this new tool) +[#]: via: (https://opensource.com/article/21/6/migrate-vms-kubernetes-forklift) +[#]: author: (Miguel Perez Colino https://opensource.com/users/mperezco) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13520-1.html) + +用 Forklift 将虚拟机迁移到 Kubernetes 上 +====== + +> 用 Forklift 将你的虚拟化工作负载过渡到 Kubernetes。 + +![](https://img.linux.net.cn/data/attachment/album/202106/25/113010mxhtznxjhxf1glz7.jpg) + +2017 年,[KubeVirt][2] 团队 [发起][3] 了一个在 [Kubernetes][4] 中管理容器及相关的虚拟机(VM)的项目。这个开源项目的意图是让虚拟机成为这个环境中的一等公民。 + +自从在 [2018 年开源峰会][5] 上推出以来,KubeVirt 一直在不断成熟和发展。它在 GitHub 上已经达到了 200 多颗星,甚至在 2021 年 2 月推出了自己的活动:[KubeVirt 峰会][6]。 + +![KubeVirt architecture][7] + +*KubeVirt 架构(© 2020,[Red Hat OpenShift][8])* + +KubeVirt 是 [OpenShift 虚拟化][9] 的基础,它帮助开发者将虚拟机带入容器化工作流程。 + +### 在 Kubernetes 中使用虚拟机 + +KubeVirt 使你能够在虚拟机上原生使用 Kubernetes。这意味着它们可以连接到使用标准 Kubernetes 方法(如服务、路由、管道等)访问的吊舱Pod网络。应用于虚拟机吊舱的网络策略与应用于应用吊舱的方式相同,它提供一个一致的模型来管理虚拟机到吊舱(或反之)的通信。 + +这方面的一个真实例子是一家航空公司利用旧的模拟器软件的方式。它注入了人工智能和机器学习 (AI/ML) 的模型,然后在基于虚拟机的模拟器上自动部署和测试它们。这使得它能够使用 Kubernetes 和 [Kubeflow][10] 完全自动化地获得测试结果和新的遥测训练数据。 + +![VM-creation workflow][11] + +*(Konveyor, [CC BY-SA 4.0][12])* + +[Konveyor.io][13] 是一个开源项目,帮助现有工作负载(开发、测试和生产)过渡到 Kubernetes。其工具包括将容器从一个 Kubernetes 平台转移到另一个平台的 [Crane][14];将工作负载从 Cloud Foundry 带到 Kubernetes的 [Move2Kube][15];以及分析 Java 应用,使其对 Kubernetes 等容器化平台中的运行时更加标准和可移植,从而使其现代化的 [Tackle][16]。 + +这些工具在转化模式中很有用,但许多项目希望在早期阶段利用 Kubernetes,以变得更加敏捷和富有成效。在基础设施方面,这些好处可能包括蓝/绿负载均衡、路由管理、声明式部署,或(取决于你的部署方式)由于不可变的基础设施而更容易升级。在开发方面,它们可能包括将持续集成/持续开发 (CI/CD) 管道与平台整合,使应用更快地投入生产,自我提供资源,或整合健康检查和监控。 + +KubeVirt 可以通过在 Kubernetes 环境中以虚拟机来运行工作负载帮助你。它能让你的工作负载迅速使用 Kubernetes,享受它的好处,并随着时间的推移稳步实现工作负载的现代化。但是,仍然有一个问题,就是把你的虚拟机从传统的虚拟化平台带到现代的 Kubernetes 平台。这就是 Konveyor 的 [Forklift][17] 项目的意义所在。 + +### 关于 Forklift + +Forklift 使用 KubeVirt 将不同来源的虚拟化工作负载迁移到 Kubernetes。它的设计目标是使任务变得简单,以便你可以从一两台机器到数百台机器迁移任何东西。 + +迁移是一个简单的、三阶段的过程: + + 1. 连接到一个现有的虚拟化平台(称为“源提供者”)和一个 Kubernetes 环境(“目标提供者”)。 + 2. 将网络和存储资源从源提供者映射到目标提供者,在两者中寻找等价的资源。 + 3. 选择要迁移的虚拟机,分配网络和存储映射,制定迁移计划。然后运行它。 + +### 如何开始 + +要开始使用 Forklift,首先,你需要一个兼容的源提供商。你还需要一个带有 KubeVirt 0.40 或更新版本的 Kubernetes 环境和裸机节点(尽管为了测试,你可以使用嵌套虚拟化)。用读-写-执行 (RWX) 功能配置你的存储类,并使用 [Multus][18] 配置你的网络,以匹配你的虚拟机在源提供者中使用的网络。(如果你不能这样做,也不用担心。你也可以选择重新分配 IP 地址。) + +最后,使用提供的操作器在你的 Kubernetes 上[安装 Forklift][19],并进入用户界面,开始运行你的第一次测试迁移。 + +Forklift 是 Red Hat 的 [虚拟化迁移工具套件][20] 的上游版本。因此,如果你想在生产环境中使用它,你可以考虑使用该工具的支持版本。 + +迁移愉快! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/migrate-vms-kubernetes-forklift + +作者:[Miguel Perez Colino][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mperezco +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/containers_2015-1-osdc-lead.png?itok=VEB4zwza (Containers on a ship on the ocean) +[2]: http://kubevirt.io/ +[3]: https://kubevirt.io/2017/This-Week-in-Kube-Virt-1.html +[4]: https://opensource.com/resources/what-is-kubernetes +[5]: https://ossna18.sched.com/event/FAOR/kubevirt-cats-and-dogs-living-together-stephen-gordon-red-hat +[6]: https://kubevirt.io/summit/ +[7]: https://opensource.com/sites/default/files/uploads/image1_1.png (KubeVirt architecture) +[8]: https://www.openshift.com/learn/topics/virtualization/ +[9]: https://openshift.com/virtualization/ +[10]: https://www.kubeflow.org/ +[11]: https://opensource.com/sites/default/files/uploads/image2_0_6.png (VM-creation workflow) +[12]: https://creativecommons.org/licenses/by-sa/4.0/ +[13]: https://www.konveyor.io/ +[14]: https://www.konveyor.io/crane +[15]: https://move2kube.konveyor.io/ +[16]: https://www.konveyor.io/tackle +[17]: https://www.konveyor.io/forklift +[18]: https://github.com/k8snetworkplumbingwg/multus-cni +[19]: https://www.youtube.com/watch?v=RnoIP3QjHww&t=1693s +[20]: https://access.redhat.com/documentation/en-us/migration_toolkit_for_virtualization/2.0/ diff --git a/published/202106/20210618 How to Set Up Razer Devices on Linux for Lighting Effects and Other Configurations.md b/published/202106/20210618 How to Set Up Razer Devices on Linux for Lighting Effects and Other Configurations.md new file mode 100644 index 0000000000..bdad8451e8 --- /dev/null +++ b/published/202106/20210618 How to Set Up Razer Devices on Linux for Lighting Effects and Other Configurations.md @@ -0,0 +1,129 @@ +[#]: subject: (How to Set Up Razer Devices on Linux for Lighting Effects and Other Configurations) +[#]: via: (https://itsfoss.com/set-up-razer-devices-linux/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13538-1.html) + +如何在 Linux 上设置雷蛇设备的灯光效果和其他配置 +====== + +你有了一个闪亮的新雷蛇硬件,但你找不到 Linux 的 Razer Synapse 软件。而你最终没有正确 RGB 同步,也没有办法定制它。你会怎么做呢? + +好吧,对于某些功能,比如给你的鼠标添加宏,你仍然需要(在 Windows 或 MacOS 上)访问 Razer Synapse。 + +但是,要调整其他一些选项,如键盘的宏,改变鼠标的 DPI,或灯光效果,你可以在 Linux 上轻松设置你的雷蛇外设。 + +![My Razer Basilisk V2 with lighting effect][1] + +这里有一些鼠标和鼠标垫的照片。这是同样的设置,但有不同的照明方案。点击图片可以看到更大的图片。 + +![][2] + +![][3] + +![][4] + +雷蛇 Basilisk 是一款不错的游戏鼠标。如果你想,你可以从亚马逊订购或从当地商店获得。 + +如果你已经拥有一个雷蛇设备,让我展示一下配置它的步骤,就像我在这里做的那样。 + +### 步骤 1:安装 OpenRazer + +**OpenRazer** 是一个开源的驱动程序,使雷蛇硬件在 Linux 上工作。它支持几种功能来定制和控制你的设备,包括 RGB 鼠标垫。 + +虽然这不是官方 Linux 驱动,但它在各种设备上工作良好。 + +它为各种 Linux 发行版提供支持,包括 Solus、openSUSE、Fedora、Debian、Arch Linux、Ubuntu 和其他一些发行版。 + +在这里,我将重点介绍在任何基于 Ubuntu 的发行版上安装它的步骤,对于其他发行版,你可能想参考 [官方说明][8]。 + +你需要在 Ubuntu 上 [使用 PPA][9] 安装 OpenRazer,下面是如何做的: + +``` +sudo apt install software-properties-gtk +sudo add-apt-repository ppa:openrazer/stable +sudo apt update +sudo apt install openrazer-meta +``` + +它也提供了一个 [守护进程][10],你可以选择让它工作,你要把你的用户加入到 `plugdev` 组,它给了设备的特权访问: + +``` +sudo gpasswd -a $USER plugdev +``` + +我不需要用上述命令中配置/添加一个守护程序,但我仍然可以很好地使用这些设备。守护进程主要是确保驱动保持活跃。 + +- [下载 OpenRazer][11] + +### 步骤 2:安装一个 GUI 来管理和调整选项 + +现在驱动已经安装完毕,你所需要的是一个图形用户界面 (GUI) 来帮助你定制你的雷蛇硬件。 + +你可以找到一些可用的选择,但我将推荐安装 [Polychromatic][12],它提供了一个有吸引力的用户界面,而且运行良好。 + +![][13] + +Polychromatic 是我能推荐的最接近 Razer Synapse 的应用,而且效果不错。 + +对于基于 Ubuntu 的发行版,你需要做的就是使用 PPA 安装它: + +``` +sudo add-apt-repository ppa:polychromatic/stable +sudo apt update +sudo apt install polychromatic +``` + +对于 Arch Linux 用户,你可以在 [AUR][14] 中找到它。关于更多的安装说明,你可以参考[官方下载页面][15]。 + +- [下载 Polychromatic][16] + +你会得到不同设备的不同选项。在这里,我试着改变 DPI,自定义颜色周期,以及我的雷蛇 Basilisk v2 鼠标的轮询率,它完全正常。 + +![Customization options for a mouse][17] + +如果你知道你想做什么,它还为你提供了轻松重启或停止 [守护进程][10]、改变小程序图标和执行高级配置选项的能力。 + +另外,你可以试试 [RazerGenie][18]、[Snake][19] 或 [OpenRGB][20] (用于改变颜色)来调整鼠标的颜色或任何其他设置。 + +### 总结 + +现在你可以轻松地定制你的雷蛇硬件了,希望你能玩得开心! + +虽然你可能会找到一些其他的选择来配置你的雷蛇设备,但我没有找到任何其他效果这么好的选择。 + +如果你遇到了一些有用的东西,值得在这里为所有的雷蛇用户提一下,请在下面的评论中告诉我。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/set-up-razer-devices-linux/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/Razer-Basilisk-V2.jpg?resize=800%2C600&ssl=1 +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/razer-mouse-pad-lighting-effect-3-com.jpg?resize=800%2C600&ssl=1 +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/razer-mouse-pad-lighting-effect-2-com.jpg?resize=800%2C600&ssl=1 +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/razer-mouse-pad-lighting-effect-1-com.jpg?resize=800%2C600&ssl=1 +[8]: https://openrazer.github.io/#download +[9]: https://itsfoss.com/ppa-guide/ +[10]: https://itsfoss.com/linux-daemons/ +[11]: https://openrazer.github.io/ +[12]: https://polychromatic.app +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/polychromatic-app-1.png?resize=800%2C500&ssl=1 +[14]: https://itsfoss.com/aur-arch-linux/ +[15]: https://polychromatic.app/download/ +[16]: https://polychromatic.app/ +[17]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/razer-basilisk-polychromatic.png?resize=800%2C505&ssl=1 +[18]: https://github.com/z3ntu/RazerGenie +[19]: https://github.com/bithatch/snake +[20]: https://itsfoss.com/openrgb/ diff --git a/published/202106/20210618 Systemd Timers for Scheduling Tasks.md b/published/202106/20210618 Systemd Timers for Scheduling Tasks.md new file mode 100644 index 0000000000..6ce42556f9 --- /dev/null +++ b/published/202106/20210618 Systemd Timers for Scheduling Tasks.md @@ -0,0 +1,220 @@ +[#]: subject: (Systemd Timers for Scheduling Tasks) +[#]: via: (https://fedoramagazine.org/systemd-timers-for-scheduling-tasks/) +[#]: author: (Richard England https://fedoramagazine.org/author/rlengland/) +[#]: collector: (lujun9972) +[#]: translator: (dcoliversun) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13522-1.html) + +用于调度任务的 systemd 定时器 +====== + +![](https://img.linux.net.cn/data/attachment/album/202106/25/175650j4wrdw0z884iod80.jpg ) + +systemd 提供定时器有一段时间了,定时器替代了 cron 功能,这一特性值得看看。本文将向你介绍在系统启动后如何使用 systemd 中的定时器来运行任务,并在此后重复运行。这不是对 systemd 的全面讨论,只是对此特性的一个介绍。 + +### 快速回顾:cron、anacron 与 systemd + +cron 可以以几分钟到几个月或更长时间的粒度调度运行一个任务。设置起来相对简单,它只需要一个配置文件。虽然配置过程有些深奥,但一般用户也可以使用。 + +然而,如果你的系统在需要执行的时间没有运行,那么 cron 会失败。 + +anacron 克服了“系统没有运行”的问题。它确保任务将在你的系统再次启动时执行。虽然它旨在给管理员使用,但有些系统允许普通用户访问 anacron。 + +但是,anacron 的执行频率不能低于每天一次。 + +cron 和 anacron 都存在执行上下文一致性的问题。必须注意任务运行时有效的环境与测试时使用的环境完全相同。必须提供相同的 shell、环境变量和路径。这意味着测试和调试有时会很困难。 + +systemd 定时器提供了 cron 和 anacron 二者的优点,允许调度到分钟粒度。确保在系统再次运行时执行任务,即使在预期的执行时间内系统处于关闭状态。它对所有用户都可用。你可以在它将要运行的环境中测试和调试执行。 + +但是,它的配置更加复杂,至少需要两个配置文件。 + +如果你的 cron 和 anacron 配置可以很好地为你服务,那么可能没有理由改变。但是 systemd 至少值得研究,因为它可以简化任何当前的 cron/anacron 工作方式。 + +### 配置 + +systemd 定时器执行功能至少需要两个文件。这两个是“定时器单元timer unit”和“服务单元service unit”。(其执行的)“动作”不仅仅是简单的命令,你还需要一个“作业”文件或脚本来执行必要的功能。 + +定时器单元文件定义调度表,而服务单元文件定义执行的任务。有关的更多详细信息请参考 `man systemd.timer` 中提供的 .timer 单元。服务单元的详细信息可在 `man systemd.service` 中找到。 + +单元文件存放在几个位置(在手册页中有列出)。然而,对于普通用户来说,最容易找到的位置可能是 `~/.config/systemd/user`。请注意,这里的 `user` 是字符串 `user`。 + +### 示例 + +此示例是一个创建用户调度作业而不是(以 root 用户身份运行的)系统调度作业的简单示例。它将消息、日期和时间打印到文件中。 + +1、首先创建一个执行任务的 shell 脚本。在你的本地 `bin` 目录中创建它,例如在 `~/bin/schedule-test.sh` 中。 + +创建文件: + +``` +touch ~/bin/schedule-test.sh +``` + +然后将以下内容添加到你刚刚创建的文件中: + +``` +#!/bin/sh +echo "This is only a test: $(date)" >> "$HOME/schedule-test-output.txt" +``` + +记住赋予你的 shell 脚本执行权限。 + +2、创建 .service 单元调用上面的脚本。在以下位置创建目录与文件:`~/.config/systemd/user/schedule-test.service`: + +``` +[Unit] +Description=A job to test the systemd scheduler + +[Service] +Type=simple +ExecStart=/home//bin/schedule-test.sh + +[Install] +WantedBy=default.target +``` + +请注意 `` 应该是你的家目录地址,但是单元文件路径名中的 `user` 实际上是字符串 `user`。 + +`ExecStart` 应该提供一个没有变量的绝对地址。例外情况是,对于用户单元文件,你可以用 `%h` 替换 `$HOME`。换句话说,你可以使用: + +``` +ExecStart=%h/bin/schedule-test.sh +``` + +这仅用于用户单元文件,而不适用于系统服务,因为在系统环境中运行时 `%h` 总是返回 `/root`。其他特殊符号可在 `man systemd.unit` 的 `SPECIFIERS` 中找到。因为它超出了本文的范围,所以这就是我们目前需要了解的关于特殊符号的全部内容。 + +3、创建一个 .timer 单元文件,该文件实际上调度你创建的 .service 单元文件。在 .service 单元文件相同位置创建它:`~/.config/systemd/user/schedule-test.timer`。请注意,文件名仅在扩展名上有所不同,例如一个是 `.service`,一个是 `.timer`。 + +``` +[Unit] +Description=Schedule a message every 1 minute +RefuseManualStart=no # Allow manual starts +RefuseManualStop=no # Allow manual stops + +[Timer] +#Execute job if it missed a run due to machine being off +Persistent=true +#Run 120 seconds after boot for the first time +OnBootSec=120 +#Run every 1 minute thereafter +OnUnitActiveSec=60 +#File describing job to execute +Unit=schedule-test.service + +[Install] +WantedBy=timers.target +``` + +请注意,这个 .timer 单元文件使用了 `OnUnitActiveSec` 来指定调度表。`OnCalendar` 选项更加灵活。例如: + +``` +# run on the minute of every minute every hour of every day + OnCalendar=*-*-* *:*:00 +# run on the hour of every hour of every day + OnCalendar=*-*-* *:00:00 +# run every day + OnCalendar=*-*-* 00:00:00 +# run 11:12:13 of the first or fifth day of any month of the year +# 2012, but only if that day is a Thursday or Friday + OnCalendar=Thu,Fri 2012-*-1,5 11:12:13 +``` + +有关 `OnCalendar` 的更多信息参见 [这里][2]。 + +4、所有的部件都已就位,但你应该进行测试,以确保一切正常。首先,启用该用户服务: + +``` +$ systemctl --user enable schedule-test.service +``` + +这将导致类似如下的输出: + +``` +Created symlink /home//.config/systemd/user/default.target.wants/schedule-test.service → /home//.config/systemd/user/schedule-test.service. +``` + +现在执行测试工作: + +``` +$ systemctl --user start schedule-test.service +``` + +检查你的输出文件(`$HOME/schedule-test-output.txt`),确保你的脚本运行正常。应该只有一个条目,因为我们还没有启动定时器。必要时进行调试。如果你需要更改 .service 单元文件,而不是更改它调用的 shell 脚本,请不要忘记再次启用该服务。 + +5、一旦作业正常运行,通过为服务启用、启动用户定时器来实时调度作业: + +``` +$ systemctl --user enable schedule-test.timer +$ systemctl --user start schedule-test.timer +``` + +请注意,你已经在上面的步骤 4 中启动、启用了服务,因此只需要为它启用、启动定时器。 + +`enable` 命令会产生如下输出: + +``` +Created symlink /home//.config/systemd/user/timers.target.wants/schedule-test.timer → /home//.config/systemd/user/schedule-test.timer. +``` + +`start` 命令将只是返回命令行界面提示符。 + +### 其他操作 + +你可以检查和监控服务。如果你从系统服务收到错误,下面的第一个命令特别有用: + +``` +$ systemctl --user status schedule-test +$ systemctl --user list-unit-files +``` + +手动停止服务: + +``` +$ systemctl --user stop schedule-test.service +``` + +永久停止并禁用定时器和服务,重新加载守护程序配置并重置任何失败通知: + +``` +$ systemctl --user stop schedule-test.timer +$ systemctl --user disable schedule-test.timer +$ systemctl --user stop schedule-test.service +$ systemctl --user disable schedule-test.service +$ systemctl --user daemon-reload +$ systemctl --user reset-failed +``` + +### 总结 + +本文以 systemd 定时器为出发点,但是 systemd 的内容远不止于此。这篇文章应该为你提供一个基础。你可以从 [Fedora Magazine systemd 系列][3] 开始探索更多。 + +### 参考 + +更多阅读: + + * `man systemd.timer` + * `man systemd.service` + * [Use systemd timers instead of cronjobs][4] + * [Understanding and administering systemd][5] + * 内有 systemd 速查表 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/systemd-timers-for-scheduling-tasks/ + +作者:[Richard England][a] +选题:[lujun9972][b] +译者:[dcoliversun](https://github.com/dcoliversun) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/rlengland/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2021/06/schedule_withsystemdtimer-816x345.jpg +[2]: https://www.freedesktop.org/software/systemd/man/systemd.time.html#Calendar%20Events +[3]: https://fedoramagazine.org/what-is-an-init-system/ +[4]: https://opensource.com/article/20/7/systemd-timers +[5]: https://docs.fedoraproject.org/en-US/quick-docs/understanding-and-administering-systemd/ diff --git a/published/202106/20210619 Here-s Why Switching to Linux Makes Sense in 2021.md b/published/202106/20210619 Here-s Why Switching to Linux Makes Sense in 2021.md new file mode 100644 index 0000000000..f018eca6e7 --- /dev/null +++ b/published/202106/20210619 Here-s Why Switching to Linux Makes Sense in 2021.md @@ -0,0 +1,128 @@ +[#]: subject: "Here’s Why Switching to Linux Makes Sense in 2021" +[#]: via: "https://news.itsfoss.com/switch-to-linux-in-2021/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lujun9972" +[#]: translator: "zepoch" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13519-1.html" + +为什么在 2021 年我仍然推荐你使用 Linux +====== + +![](https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/05/linux-2021.png?w=1200&ssl=1) + +在某些领域,Linux 确实要比 Windows 和 macOS 更加优秀。人们正在意识到这一点,而且 Linux 也在桌面操作系统市场上变得愈发流行。 + +当然,目前大多数桌面操作系统用户仍然对 Windows 或者 macOS 推崇备至,但是也有着越来越多的用户开始尝试新的 Linux 发行版,看看他们是否可以从原来的系统切换到 Linux 系统。 + +他们可能已经听过 [用 Linux 作为桌面操作系统](https://news.itsfoss.com/linux-foundation-linux-desktop/) 的一些优秀案例,又或者是仅仅想要去尝试一些与原先不同的事物,谁知道呢? + +在这里,我将为你解释为什么在 2021 年我仍然推荐你使用 Linux。 + +### Linux 真棒,但是究竟是什么让其在 2021 年值得推荐呢? + +如果已经知道了 [使用 Linux 的优点](https://itsfoss.com/reasons-switch-linux-windows-xp/),你可能就知道接下来我会说些什么。 + +#### 1、你不需要购买许可证 + +![][3] + +你必须付费才能获得 Windows 10 许可证。 + +虽然有更便宜的选择,如获得 OEM 密钥。但是,如果你不愿意通过一些地下网站,而是从官方网站获得许可证,那么仅授权使用 1 台 PC 的**家庭版**就至少需要花费 **140 美元**。 + +当然,macOS 是一个完全不同的模式(你需要购买先进的硬件才能使用 macOS)——所以我们才会一直使用微软的 Windows。 + +关键是,在失业的浪潮中,配置一台新电脑是一个挑战。此外,你还需要花钱购买操作系统的许可证,但是你却可以在多台计算机上免费使用 Linux。 + +是的,你不需要为 Linux 获取许可证密钥。你可以轻松下载 [Linux 发行版][4],并根据需要将其安装在尽可能多的设备上。 + +不要担心,如果你不了解 Linux 发行版,你可以看看我们的 [最好的 Linux 发行版](https://itsfoss.com/best-linux-distributions/) 列表。 + +#### 2、重新唤醒你的 PC 并节省资金 + +[全球芯片短缺](https://www.cnbc.com/2021/05/12/the-global-chip-shortage-could-last-until-2023-.html) 已经严重影响了电脑组件的价格,特别是**显卡**。并不是简单的价格上升,而是你不得不支付 **2 到 5 倍**的零售价来购得显卡。 + +当然,如果你没有电脑,现在配置一个新的电脑可能是难以置信的挑战,但如果你有一个旧电脑的话,选择在上面运行 Windows 10 将会是十分卡顿的。 + +如果你不想要 Windows 系统,那 macOS 呢?入门级 Mac 系统将会花费至少 **1100** 美金,甚至更多,这取决于你住在哪里。对许多人来说,这会是一笔昂贵的开销。 + +你肯定需要升级你的系统 —— 但是如果我说 Linux 可以让你的旧电脑重新派上用场,能为你省钱呢? + +你将能够在你认为无法运行最新版本的微软 Windows 的电脑上运行 Linux。是的,就是这样的。 + +Linux 是一个资源高效型的操作系统,可在各种较旧的系统配置上运行。 + +所有你需要做的只是参考我们的列表 [轻量级 Linux 发行版][7],并选择一个你喜欢的。 + +#### 3、通过再次利用系统来减少电子浪费 + +![][8] + +考虑到电子废物正在全球不断产生,尤其是由加密矿工产生的,我们可以尽量减少浪费。除非你真正需要新的硬件,否则最好将现有硬件设备重新用于新任务。 + +而且,多亏了 Linux,你可以将旧电脑或单片机转变成媒体服务器或个人 [Nextcloud][9] 服务器。 + +你可以在现有硬件上使用 Linux 做更多工作。 + +因此,这将显著降低对新硬件的需求,并让你高效地重复使用现有的设备。 + +#### 4、远离病毒和恶意软件 + +![][10] + +在远程工作无处不在的时代,病毒和恶意软件显著增加。因此,即使你想平静地工作,你最终也可能受到恶意软件的影响。 + +Windows 和 macOS 比以往任何时候都更容易受到恶意软件的影响。但是,对于 Linux?这是不太可能的。 + +Linux 发行版会定期修补,以确保最佳安全性。 + +此外,正因为用户群体小,攻击者就不会花太多时间制作欺骗 Linux 用户的病毒或软件。因此,在使用 Linux 时遇到某种形式的恶意软件的机会较小。 + +#### 5、没有强制更新 + +![][11] + +在一个人们压力倍增的时代,强制更新然后发现计算机无法启动可能是一大烦恼。 + +至少,Windows 用户的情况就是这样。 + +但是,使用 Linux,你可以继续使用你的系统,而无需在后台强制下载任何更新。 + +你的操作系统只有你能决定。 + +当你想要更新你的 Linux 发行版本时,你可以选择更新,也可以不更新,它可以一直保持不更新的状态并且不会打扰你,除非你有很长一段时间没有更新。 + +### 总结 + +这些只是我能想到的几个原因之一,Linux 作为操作系统的选择在 2021 年比以往任何时候都更值得被推荐。 + +当然,这也取决于你的要求,这些好处可能不会体现在在你的用例中。但是,如果你确实不了解 Linux,至少,现在你可以评估你的需求,重新作出选择。 + +除了上述几点之外,你还能想到什么?请在下面的评论中告诉我。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/switch-to-linux-in-2021/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[zepoch](https://github.com/zepoch) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://news.itsfoss.com/linux-foundation-linux-desktop/ +[2]: https://itsfoss.com/reasons-switch-linux-windows-xp/ +[3]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/license-agreement.jpg?w=1000&ssl=1 +[4]: https://itsfoss.com/what-is-linux-distribution/ +[5]: https://itsfoss.com/best-linux-distributions/ +[6]: https://www.cnbc.com/2021/05/12/the-global-chip-shortage-could-last-until-2023-.html +[7]: https://itsfoss.com/lightweight-linux-beginners/ +[8]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/05/e-waste-illustration.jpg?w=800&ssl=1 +[9]: https://itsfoss.com/nextcloud/ +[10]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/05/system-malware.jpg?w=800&ssl=1 +[11]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/05/linux-system-update.jpg?w=800&ssl=1 \ No newline at end of file diff --git a/published/202106/20210622 KTorrent- An Incredibly Useful BitTorrent Application by KDE.md b/published/202106/20210622 KTorrent- An Incredibly Useful BitTorrent Application by KDE.md new file mode 100644 index 0000000000..fba3c69a7e --- /dev/null +++ b/published/202106/20210622 KTorrent- An Incredibly Useful BitTorrent Application by KDE.md @@ -0,0 +1,110 @@ +[#]: subject: (KTorrent: An Incredibly Useful BitTorrent Application by KDE) +[#]: via: (https://itsfoss.com/ktorrent/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13530-1.html) + +KTorrent:KDE 上的一个非常有用的 BitTorrent 应用 +====== + +![](https://img.linux.net.cn/data/attachment/album/202106/28/120031cml79jimcs99ybpy.jpg) + +Linux 中有各种各样的 BitTorrent 应用。但是,找到一个好的、提供许多功能的应用将可以为你节省一些时间。 + +KDE 的 KTorrent 就是这样一个为 Linux 打造的 BitTorrent 应用。 + +虽然 [Linux 有好几个 torrent 客户端][1],但我最近发现 KTorrent 对我而言很合适。 + +### KTorrent: 适用于 Linux 的开源 BitTorrent 客户端 + +![][2] + +KTorrent 是一个成熟的 torrent 客户端,主要为 KDE 桌面定制。无论你使用什么桌面环境,它都能很好地工作。 + +当然,使用 KDE 桌面,你可以得到一个无缝的用户体验。 + +让我们来看看它的所有功能。 + +### KTorrent 的功能 + +![][3] + +对于普通的 torrent 用户来说,拥有一套全面的功能使事情变得简单。而 KTorrent 也不例外。在这里,我将列出 KTorrent 的主要亮点: + + * 在一个队列中添加 torrent 下载 + * 能够控制每次下载(或整体)的速度限制 + * 视频和音频文件预览选项 + * 支持导入下载的文件(部分/全部) + * 在下载多个文件时,能够对 torrent 下载进行优先排序 + * 为多文件 torrent 选择要下载的特定文件 + * IP 过滤器,可选择踢走/禁止对端。 + * 支持 UDP 跟踪器 + * 支持 µTorrent 对端 + * 支持协议加密 + * 能够创建无跟踪器的 torrent + * 脚本支持 + * 系统托盘集成 + * 通过代理连接 + * 增加了插件支持 + * 支持 IPv6 + +KTorrent 看起来可以作为一个日常使用的 torrent 客户端,在一个地方管理所有的 torrent 下载。 + +![][4] + +除了上面提到的功能外,它还对客户端的行为提供了很大的控制。例如,调整下载/暂停/跟踪器的指示颜色。 + +如果你想禁用完成 torrent 下载时的声音或得到活动通知,你还可以设置通知。 + +![][5] + +虽然像协议加密支持这样的功能可能无法取代一些 [最好的私有专用网络][6] 服务,但它对桌面客户端来说是一个重要的补充。 + +### 在 Linux 中安装 KTorrent + +KTorrent 应该可以通过包管理器(如 [Synaptic][7])或默认的仓库获得。你也可以在你的软件中心找到它并轻松安装。 + +除此之外,它还在 [Flathub][9] 上提供了一个适用于任何 Linux 发行版的 [Flatpak][8] 官方包。如果你需要帮助,我们有一个 [Flatpak 指南][10] 供参考。 + +如果你喜欢的话,你也可以尝试可用的 [snap包][11]。 + +要探索更多关于它和源码的信息,请前往它的 [官方 KDE 应用页面][12]。 + +- [KTorrent][12] + +### 结束语 + +KTorrent 是 Linux 中一个出色的 torrent 客户端。我在我的 Linux Mint 系统的 Cinnamon 桌面上试用了它,它运行得很好。 + +我喜欢它的简单和可配置性。尽管我不是每天都在使用 torrent 客户端,但在我短暂的测试中,我没有发现 KTorrent 有什么奇怪的地方。 + +你认为 KTorrent 作为 Linux 的 torrent 客户端怎么样?你喜欢用什么呢? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ktorrent/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/best-torrent-ubuntu/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/ktorrent-download.png?resize=850%2C582&ssl=1 +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/ktorrent-configure.png?resize=850%2C656&ssl=1 +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/ktorrent-speed-limit.png?resize=850%2C585&ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/ktorrent-plugins.png?resize=850%2C643&ssl=1 +[6]: https://itsfoss.com/best-vpn-linux/ +[7]: https://itsfoss.com/synaptic-package-manager/ +[8]: https://itsfoss.com/what-is-flatpak/ +[9]: https://flathub.org/apps/details/org.kde.ktorrent +[10]: https://itsfoss.com/flatpak-guide/ +[11]: https://snapcraft.io/ktorrent +[12]: https://apps.kde.org/ktorrent/ diff --git a/published/202106/20210622 Replace du with dust on Linux.md b/published/202106/20210622 Replace du with dust on Linux.md new file mode 100644 index 0000000000..ba59483df1 --- /dev/null +++ b/published/202106/20210622 Replace du with dust on Linux.md @@ -0,0 +1,145 @@ +[#]: subject: (Replace du with dust on Linux) +[#]: via: (https://opensource.com/article/21/6/dust-linux) +[#]: author: (Sudeshna Sur https://opensource.com/users/sudeshna-sur) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13532-1.html) + +在 Linux 上用 dust 代替 du +====== + +> dust 命令是用 Rust 编写的对 du 命令的一个更直观实现。 + +![](https://img.linux.net.cn/data/attachment/album/202106/29/033403l8x83x7a4tt4fq84.jpg) + +如果你在 Linux 命令行上工作,你会熟悉 `du` 命令。了解像 `du` 这样的命令,可以快速返回磁盘使用情况,是命令行使程序员更有效率的方法之一。然而,如果你正在寻找一种方法来节省更多的时间,使你的生活更加容易,看看 [dust][2],它是用 Rust 重写的 `du`,具有更多的直观性。 + +简而言之,`dust` 是一个提供文件类型和元数据的工具。如果你在一个目录中运行了 `dust`,它将以几种方式报告该目录的磁盘利用率。它提供了一个信息量很大的图表,告诉你哪个文件夹使用的磁盘空间最大。如果有嵌套的文件夹,你可以看到每个文件夹使用的空间百分比。 + +### 安装 dust + +你可以使用 Rust 的 Cargo 包管理器安装 `dust`: + +``` +$ cargo install du-dust +``` + +另外,你可以在 Linux 上的软件库中找到它,在 macOS 上,可以使用 [MacPorts][3] 或 [Homebrew][4]。 + +### 探索 dust + +在一个目录中执行 `dust` 命令,会返回一个图表,以树状格式显示其内容和每个项目所占的百分比。 + + +``` +$ dust + 5.7M ┌── exa │ ██ │ 2% + 5.9M ├── tokei │ ██ │ 2% + 6.1M ├── dust │ ██ │ 2% + 6.2M ├── tldr │ ██ │ 2% + 9.4M ├── fd │ ██ │ 4% + 2.9M │ ┌── exa │ ░░░█ │ 1% + 15M │ ├── rustdoc │ ░███ │ 6% + 18M ├─┴ bin │ ████ │ 7% + 27M ├── rg │ ██████ │ 11% + 1.3M │ ┌── libz-sys-1.1.3.crate │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │ 0% + 1.4M │ ├── libgit2-sys-0.12.19+1.1.0.crate │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │ 1% + 4.5M │ ┌─┴ github.com-1ecc6299db9ec823 │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │ 2% + 4.5M │ ┌─┴ cache │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │ 2% + 1.0M │ │ ┌── git2-0.13.18 │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 0% + 1.4M │ │ ├── exa-0.10.1 │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 1% + 1.5M │ │ │ ┌── src │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 1% + 2.2M │ │ ├─┴ idna-0.2.3 │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 1% + 1.2M │ │ │ ┌── linux │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 0% + 1.6M │ │ │ ┌─┴ linux_like │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 1% + 2.6M │ │ │ ┌─┴ unix │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 1% + 3.1M │ │ │ ┌─┴ src │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 1% + 3.1M │ │ ├─┴ libc-0.2.94 │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 1% + 1.2M │ │ │ ┌── test │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 0% + 2.6M │ │ │ ┌─┴ zlib-ng │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 1% + 904K │ │ │ │ ┌── vstudio │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 0% + 2.0M │ │ │ │ ┌─┴ contrib │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 1% + 3.4M │ │ │ ├─┴ zlib │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 1% + 6.1M │ │ │ ┌─┴ src │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓██ │ 2% + 6.1M │ │ ├─┴ libz-sys-1.1.3 │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓██ │ 2% + 1.6M │ │ │ ┌── pcre │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 1% + 2.5M │ │ │ ┌─┴ deps │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 1% + 3.8M │ │ │ ├── src │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓█ │ 1% + 7.4M │ │ │ ┌─┴ libgit2 │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓██ │ 3% + 7.6M │ │ ├─┴ libgit2-sys-0.12.19+1.1.0 │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓██ │ 3% + 26M │ │ ┌─┴ github.com-1ecc6299db9ec823 │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████ │ 10% + 26M │ ├─┴ src │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████ │ 10% + 932K │ │ ┌── .cache │ ░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█ │ 0% + 11M │ │ │ ┌── pack-c3e3a51a17096a3078196f3f014e02e5da6285aa.idx │ ░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓███ │ 4% + 135M │ │ │ ├── pack-c3e3a51a17096a3078196f3f014e02e5da6285aa.pack│ ░░░░░░▓▓███████████████████████████ │ 53% + 147M │ │ │ ┌─┴ pack │ ░░░░░░█████████████████████████████ │ 57% + 147M │ │ │ ┌─┴ objects │ ░░░░░░█████████████████████████████ │ 57% + 147M │ │ ├─┴ .git │ ░░░░░░█████████████████████████████ │ 57% + 147M │ │ ┌─┴ github.com-1ecc6299db9ec823 │ ░░░░░░█████████████████████████████ │ 57% + 147M │ ├─┴ index │ ░░░░░░█████████████████████████████ │ 57% + 178M ├─┴ registry │ ███████████████████████████████████ │ 69% + 257M ┌─┴ . │██████████████████████████████████████████████████ │ 100% +$ +``` + +将 `dust` 应用于一个特定的目录: + +``` +$ dust ~/Work/ +``` + +![Dust output from a specific directory][5] + +`-r` 选项以相反的顺序显示输出,“根”在底部: + +``` +$ dust -r ~/Work/ +``` + +使用 `dust -d 3` 会返回三层的子目录和它们的磁盘利用率: + +``` +$ dust -d 3 ~/Work/wildfly/jaxrs/target/classes + 4.0K ┌── jaxrs.xml │ █ │ 1% + 4.0K ┌─┴ subsystem-templates │ █ │ 1% + 4.0K │ ┌── org.jboss.as.controller.transform.ExtensionTransformerRegistration│ █ │ 1% + 4.0K │ ├── org.jboss.as.controller.Extension │ █ │ 1% + 8.0K │ ┌─┴ services │ █ │ 2% + 8.0K ├─┴ META-INF │ █ │ 2% + 4.0K │ ┌── jboss-as-jaxrs_1_0.xsd │ ░█ │ 1% + 8.0K │ ├── jboss-as-jaxrs_2_0.xsd │ ░█ │ 2% + 12K ├─┴ schema │ ██ │ 3% + 408K │ ┌── as │ ████████████████████████████████████████ │ 94% + 408K │ ┌─┴ jboss │ ████████████████████████████████████████ │ 94% + 408K ├─┴ org │ ████████████████████████████████████████ │ 94% + 432K ┌─┴ classes │██████████████████████████████████████████ │ 100% +$ +``` + +### 总结 + +`dust` 的魅力在于它是一个小而简单的、易于理解的命令。它使用颜色方案来表示最大的子目录,使你的目录易于可视化。这是一个受欢迎的项目,欢迎大家来贡献。 + +你是否使用或考虑使用 `dust`?如果是,请在下面的评论中告诉我们你的想法。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/dust-linux + +作者:[Sudeshna Sur][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sudeshna-sur +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/sand_dunes_desert_hills_landscape_nature.jpg?itok=wUByylBb +[2]: https://github.com/bootandy/dust +[3]: https://opensource.com/article/20/11/macports +[4]: https://opensource.com/article/20/6/homebrew-mac +[5]: https://opensource.com/sites/default/files/uploads/dust-work.png (Dust output from a specific directory) +[6]: https://creativecommons.org/licenses/by-sa/4.0/ diff --git a/published/202106/20210623 Python 3.10 beta in Fedora Linux.md b/published/202106/20210623 Python 3.10 beta in Fedora Linux.md new file mode 100644 index 0000000000..8d900cd460 --- /dev/null +++ b/published/202106/20210623 Python 3.10 beta in Fedora Linux.md @@ -0,0 +1,115 @@ +[#]: subject: (Python 3.10 beta in Fedora Linux) +[#]: via: (https://fedoramagazine.org/python-3-10-beta-in-fedora-linux/) +[#]: author: (Miro Hrončok https://fedoramagazine.org/author/churchyard/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13536-1.html) + +Fedora Linux 中的 Python 3.10 测试版 +====== + +![][1] + +Python 开发者已经发布了 Python 3.10.0 的三个测试版本。现在,你可以在 Fedora Linux 中试用最新的版本尽早用 3.10 测试你的 Python 代码,为 10 月份的 3.10.0 最终版本做好准备。 + +### 在 Fedora Linux 上安装 Python 3.10 + +如果你运行 Fedora Linux,你可以用 `dnf` 从官方仓库安装 Python 3.10: + +``` +$ sudo dnf install python3.10 +``` + +你可能需要启用 `updates-testing` 仓库来获得最新的预发布版本: + +``` +$ sudo dnf install --enablerepo=updates-testing python3.10 +``` + +随着更多的测试版和候选版 [发布][2],Fedora 包将得到更新。不需要编译你自己的 Python 开发版本,只要安装它就可以获得最新。从第一个测试版开始,Python 开发者不会再增加新的功能了。你已经可以享受所有的新东西了。 + +### 用 Python 3.10 测试你的项目 + +运行 `python3.10` 命令来使用 Python 3.10,或者用 [内置的 venv 模块 tox][3] 或用 [pipenv][4] 和 [poetry][5] 创建虚拟环境。下面是一个使用 `tox` 的例子: + +``` +$ git clone https://github.com/benjaminp/six.git +Cloning into 'six'... +$ cd six/ +$ tox -e py310 +py310 run-test: commands[0] | python -m pytest -rfsxX +================== test session starts =================== +platform linux -- Python 3.10.0b3, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 +collected 200 items + +test_six.py ...................................... [ 19%] +.................................................. [ 44%] +.................................................. [ 69%] +.................................................. [ 94%] +............ [100%] + +================== 200 passed in 0.43s =================== +________________________ summary _________________________ + py310: commands succeeded + congratulations :) +``` + +如果你在 Fedora Linux 上发现了 Python 3.10 的问题,请 [在 Fedora 的 bugzilla 上提交 bug 报告][6] 或在 [Python 的问题追踪][7] 上提交。如果你不确定这是否是 Python 的问题,你可以 [通过电子邮件或 IRC 直接联系 Fedora 的 Python 维护者][8] 。 + +### Python 3.10 中的新内容 + +参见 [Python 3.10 的全部新闻列表][9]。例如,你可以尝试一下 [结构模式匹配][10]: + +``` +$ python3.10 +Python 3.10.0b3 (default, Jun 17 2021, 00:00:00) +[GCC 10.3.1 20210422 (Red Hat 10.3.1-1)] on linux +Type "help", "copyright", "credits" or "license" for more information. +>>> point = (3, 10) +>>> match point: +... case (0, 0): +... print("Origin") +... case (0, y): +... print(f"Y={y}") +... case (x, 0): +... print(f"X={x}") +... case (x, y): +... print(f"X={x}, Y={y}") +... case _: +... raise ValueError("Not a point") +... +X=3, Y=10 +>>> x +3 +>>> y +10 +``` + +敬请期待 [Fedora Linux 35 中的 python3 —— Python 3.10][11]! + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/python-3-10-beta-in-fedora-linux/ + +作者:[Miro Hrončok][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/churchyard/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2021/06/python310-beta-816x345.jpg +[2]: https://www.python.org/dev/peps/pep-0619/ +[3]: https://developer.fedoraproject.org/tech/languages/python/multiple-pythons.html +[4]: https://fedoramagazine.org/install-pipenv-fedora/ +[5]: https://python-poetry.org/ +[6]: https://bugzilla.redhat.com/buglist.cgi?component=python3.10&product=Fedora +[7]: https://bugs.python.org/ +[8]: https://fedoraproject.org/wiki/SIGs/Python#Communicate +[9]: https://docs.python.org/3.10/whatsnew/3.10.html +[10]: https://www.python.org/dev/peps/pep-0634/ +[11]: https://fedoraproject.org/wiki/Changes/Python3.10 diff --git a/published/202106/20210623 Replace find with fd on Linux.md b/published/202106/20210623 Replace find with fd on Linux.md new file mode 100644 index 0000000000..c20a9713ad --- /dev/null +++ b/published/202106/20210623 Replace find with fd on Linux.md @@ -0,0 +1,137 @@ +[#]: subject: (Replace find with fd on Linux) +[#]: via: (https://opensource.com/article/21/6/fd-linux) +[#]: author: (Sudeshna Sur https://opensource.com/users/sudeshna-sur) +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13516-1.html) + +在 Linux 上用 fd 代替 find +====== + +> fd 命令是一个流行的、用户友好的 find 命令的替代品。 + +![](https://img.linux.net.cn/data/attachment/album/202106/24/110546npqmttwobtqpo4qk.jpg) + +许多 Linux 程序员在其工作中每天都在使用 `find` 命令。但是 `find` 给出的文件系统条目是有限的,如果你要进行大量的 `find` 操作,它甚至不是很快速。因此,我更喜欢使用 Rust 编写的 `fd` 命令,因为它提供了合理的默认值,适用于大多数使用情况。 + +正如它的 [README][2] 所说,“`fd` 是一个在文件系统中寻找条目的程序。它是一个简单、快速和用户友好的 `find` 的替代品。”它的特点是目录的并行遍历,可以一次搜索多个目录。它支持正则表达式(regex)和基于通配符的模式。 + +### 安装 fd + +在 Linux 上,你可以从你的软件库中安装 `fd`(可用的软件包列表可以在 [Repology 上的 fd 页面][3] 找到)。 例如,在 Fedora 上: + +``` +$ sudo dnf install fd-find +``` + +在 macOS 上,可以使用 [MacPorts][4] 或 [Homebrew][5]。 + +另外,你也可以使用 Rust 的 Cargo 软件包管理器: + +``` +$ cargo install fd-find +``` + +### 使用 fd + +要做一个简单的搜索,运行 `fd` 并在后面跟上要搜索的名字,例如: + +``` +$ fd sh +registry/src/github.com-1ecc6299db9ec823/cc-1.0.67/src/bin/gcc-shim.rs +registry/src/github.com-1ecc6299db9ec823/exa-0.10.1/completions/completions.bash +registry/src/github.com-1ecc6299db9ec823/exa-0.10.1/completions/completions.fish +registry/src/github.com-1ecc6299db9ec823/exa-0.10.1/completions/completions.zsh +registry/src/github.com-1ecc6299db9ec823/exa-0.10.1/xtests/run.sh +registry/src/github.com-1ecc6299db9ec823/git2-0.13.18/src/stash.rs +registry/src/github.com-1ecc6299db9ec823/libc-0.2.94/src/unix/solarish +registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/cmake/SelectHashes.cmake +registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/include/git2/stash.h +registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/include/git2/sys/hashsig.h +registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/script/backport.sh +registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/script/leaks.sh +registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/script/valgrind.sh +registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/src/config_snapshot.c +[...] +``` + +如果你想搜索一个特定的目录,可以将目录路径作为 `fd` 的第二个参数,例如: + +``` +$ fd passwd /etc +/etc/pam.d/passwd +/etc/passwd +/etc/passwd- +/etc/security/opasswd +``` + +要搜索一个特定的文件扩展名,使用 `-e` 作为选项。例如: + +``` +$ fd . '/home/ssur/exa' -e md +/home/ssur/exa/README.md +/home/ssur/exa/devtools/README.md +/home/ssur/exa/man/exa.1.md +/home/ssur/exa/man/exa_colors.5.md +/home/ssur/exa/xtests/README.md +$ +``` + +你也可以通过提供 `-x` 或 `-X` 来执行一个命令。 + + * `-x`/`--exec`:选项为每个搜索结果(并行)运行一个外部命令。 + * `-X`/`--exec-batch`:选项将所有搜索结果作为参数启动一次外部命令。 + +例如,要递归地找到所有的 ZIP 档案并解压: + +``` +$ fd -e zip -x unzip +``` + +或者,要列出某个特定目录下在过去 _n_ 天内改变的所有文件,使用`--changed-within` 选项: + +``` +$ fd . '/home/ssur/Work/' --changed-within 10d +/home/ssur/Work/wildfly/connector/src/main/java/org/jboss/as/connector/subsystems/data_sources/JdbcDriverAdd.java +/home/ssur/Work/wildfly/connector/src/main/java/org/jboss/as/connector/subsystems/data_sources/JdbcExample.java +[...] +``` + +而要搜索所有在特定天数之前被修改的文件,请使用 `--changed-before` _n_ 选项: + +``` +$ fd . '/home/ssur/Work/' --changed-before 365d +``` + +这里,`.` 作为一个(正则)通配符,指示 `fd` 返回所有文件。 + +要了解更多关于 `fd` 的功能,请查阅 GitHub 上的 [文档][2]。 + +### 总结 + +我特别喜欢 `fd` 的一点是,搜索模式默认是不区分大小写的,这使得它更容易找到东西,即使你对你要找的东西没有精确的认识。更好的是,如果模式包含一个大写的字符,它就会*自动*切换到大小写敏感。 + +另一个好处是,它使用颜色编码来突出不同的文件类型。 + +如果你已经在使用这个神奇的 Rust 工具,请在评论中告诉我们你的想法。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/fd-linux + +作者:[Sudeshna Sur][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sudeshna-sur +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0 (Magnifying glass on code) +[2]: https://github.com/sharkdp/fd +[3]: https://repology.org/project/fd-find/versions +[4]: https://opensource.com/article/20/11/macports +[5]: https://opensource.com/article/20/6/homebrew-mac diff --git a/published/20210608 Tune your MySQL queries like a pro.md b/published/20210608 Tune your MySQL queries like a pro.md new file mode 100644 index 0000000000..7ec70af50c --- /dev/null +++ b/published/20210608 Tune your MySQL queries like a pro.md @@ -0,0 +1,107 @@ +[#]: subject: (Tune your MySQL queries like a pro) +[#]: via: (https://opensource.com/article/21/5/mysql-query-tuning) +[#]: author: (Dave Stokes https://opensource.com/users/davidmstokes) +[#]: collector: (lujun9972) +[#]: translator: (unigeorge) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13684-1.html) + +如老手一般玩转 MySQL 查询 +====== + +> 优化查询语句不过是一项简单的工程,而非什么高深的黑魔法。 + +![](https://img.linux.net.cn/data/attachment/album/202108/15/104728m3e3wefi3bq3qn34.jpg) + +许多人将数据库查询语句的调优视作哈利波特小说中某种神秘的“黑魔法”;使用错误的咒语,数据就会从宝贵的资源变成一堆糊状物。 + +实际上,对关系数据库系统的查询调优是一项简单的工程,其遵循的规则或启发式方法很容易理解。查询优化器会翻译你发送给 [MySQL][2] 实例的查询指令,然后将这些启发式方法和优化器已知的数据信息结合使用,确定获取所请求数据的最佳方式。再读一下后面这半句:_“优化器已知的数据信息_。”查询优化器需要对数据所在位置的猜测越少(即已知信息越多),它就可以越好地制定交付数据的计划。 + +为了让优化器更好地了解数据,你可以考虑使用索引和直方图。正确使用索引和直方图可以大大提高数据库查询的速度。这就像如果你按照食谱做菜,就可以得到你喜欢吃的东西;但是假如你随意在该食谱中添加材料,最终得到的东西可能就不那么尽如人意了。 + +### 基于成本的优化器 + +大多数现代关系型数据库使用基于成本的优化器cost-based optimizer来确定如何从数据库中检索数据。该成本方案是基于尽可能减少非常耗费资源的磁盘读取过程。数据库服务器内的查询优化器代码会在得到数据时对这些数据的获取进行统计,并构建一个获取数据的历史模型。 + +但历史数据是可能会过时的。这就好像你去商店买你最喜欢的零食,然后突然发现零食涨价或者商店关门了。服务器的优化进程可能会根据旧信息做出错误的假设,进而制定出低效的查询计划。 + +查询的复杂性可能会影响优化。优化器希望提供可用的最低成本查询方式。连接五个不同的表就意味着有 5 的阶乘(即 120)种可能的连接组合。代码中内置了启发式方法,以尝试对所有可能的选项进行快捷评估。MySQL 每次看到查询时都希望生成一个新的查询计划,而其他数据库(例如 Oracle)则可以锁定查询计划。这就是向优化器提供有关数据的详细信息至关重要的原因。要想获得稳定的性能,在制定查询计划时为查询优化器提供最新信息确实很有效。 + +此外,优化器中内置的规则可能与数据的实际情况并不相符。没有更多有效信息的情况下,查询优化器会假设列中的所有数据均匀分布在所有行中。没有其他选择依据时,它会默认选择两个可能索引中较小的一个。虽然基于成本的优化器模型可以制定出很多好的决策,但最终查询计划并不是最佳方案的情况也是有可能的。 + +### 查询计划是什么? + +查询计划query plan是指优化器基于查询语句产生的,提供给服务器执行的计划内容。查看查询计划的方法是在查询语句前加上 `EXPLAIN` 关键字。例如,以下查询要从城市表(`city`)和相应的国家表(`country`)中获得城市名称(和所属国家名称),城市表和国家表通过国家唯一代码连接。本例中仅查询了英国的字母顺序前五名的城市: + +``` +SELECT city.name AS 'City', +               country.name AS 'Country' +FROM city +JOIN country ON (city.countrycode = country.code) +WHERE country.code = 'GBR' +LIMIT 5; +``` + +在查询语句前加上 `EXPLAIN` 可以看到优化器生成的查询计划。跳过除输出末尾之外的所有内容,可以看到优化后的查询: + +``` +SELECT `world`.`city`.`Name` AS `City`, +                'United Kingdom' AS `Country` +FROM `world`.`city` +JOIN `world`.`country` +WHERE (`world`.`city`.`CountryCode` = 'GBR') +LIMIT 5; +``` + +看下比较大的几个变化, `country.name as 'Country'` 改成了 `'United Kingdom' AS 'Country'`,`WHERE` 子句从在国家表中查找变成了在城市表中查找。优化器认为这两个改动会提供比原始查询更快的结果。 + +### 索引 + +在 MySQL 世界中,你会听到索引或键的概念。不过,索引是由键组成的,键是一种识别记录的方式,并且大概率是唯一的。如果将列设计为键,优化器可以搜索这些键的列表以找到所需的记录,而无需读取整个表。如果没有索引,服务器必须从第一列的第一行开始读取每一行数据。如果该列是作为唯一索引创建的,则服务器可以直接读取该行数据并忽略其余数据。索引的值(也称为基数)唯一性越强越好。请记住,我们在寻找更快获取数据的方法。 + +MySQL 默认的 InnoDB 存储引擎希望你的表有一个主键,并按照该键将你的数据存储在 B+ 树中。“不可见列”是 MySQL 最近添加的功能,除非在查询中明确指明该不可见列,否则不会返回该列数据。例如,`SELECT * FROM foo;` 就不会返回任何不可见列。这个功能提供了一种向旧表添加主键的方法,且无需为了包含该新列而重写所有查询语句。 + +更复杂的是,有多种类型的索引,例如函数索引、空间索引和复合索引。甚至在某些情况下,你还可以创建这样一个索引:该索引可以为查询提供所有请求的信息,从而无需再去访问数据表。 + +本文不会详细讲解各种索引类型,你只需将索引看作指向要查询的数据记录的快捷方式。你可以在一个或多个列或这些列的一部分上创建索引。我的医师系统就可以通过我姓氏的前三个字母和出生日期来查找我的记录。使用多列时要注意首选唯一性最强的字段,然后是第二强的字段,依此类推。“年-月-日”的索引可用于“年-月-日”、“年-月”和“年”搜索,但不适用于“日”、“月-日”或“年-日”搜索。考虑这些因素有助于你围绕如何使用数据这一出发点来设计索引。 + +### 直方图 + +直方图就是数据的分布形式。如果你将人名按其姓氏的字母顺序排序,就可以对姓氏以字母 A 到 F 开头的人放到一个“逻辑桶”中,然后将 G 到 J 开头的放到另一个中,依此类推。优化器会假定数据在列内均匀分布,但实际使用时多数情况并不是均匀的。 + +MySQL 提供两种类型的直方图:所有数据在桶中平均分配的等高型,以及单个值在单个桶中的等宽型。最多可以设置 1,024 个存储桶。数据存储桶数量的选择取决于许多因素,包括去重后的数值量、数据倾斜度以及需要的结果准确度。如果桶的数量超过某个阈值,桶机制带来的收益就会开始递减。 + +以下命令将在表 `t` 的列 `c1` 上创建 10 个桶的直方图: + +``` +ANALYZE TABLE t UPDATE HISTOGRAM ON c1 WITH 10 BUCKETS; +``` + +想象一下你在售卖小号、中号和大号袜子,每种尺寸的袜子都放在单独的储物箱中。如果你想找某个尺寸的袜子,就可以直接去对应尺寸的箱子里找。MySQL 自从三年前发布 MySQL 8.0 以来就有了直方图功能,但该功能却并没有像索引那样广为人知。与索引不同,使用直方图插入、更新或删除记录都不会产生额外开销。而如果更新索引,就必须更新 `ANALYZE TABLE` 命令。当数据变动不大并且频繁更改数据会降低效率时,直方图是一种很好的方法。 + +### 选择索引还是直方图? + +对需要直接访问的且具备唯一性的数据项目使用索引。虽然修改、删除和插入操作会产生额外开销,但如果数据架构正确,索引就可以方便你快速访问。对不经常更新的数据则建议使用直方图,例如过去十几年的季度结果。 + +### 结语 + +本文源于最近在 [Open Source 101 会议][3] 上的一次报告。报告的演示文稿源自 [PHP UK Conferenc][4] 的研讨会。查询调优是一个复杂的话题,每次我就索引和直方图作报告时,我都会找到新的可改进点。但是每次报告反馈也表明很多软件界中的人并不精通索引,并且时常使用错误。我想直方图大概由于出现时间较短,还没有出现像索引这种使用错误的情况。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/5/mysql-query-tuning + +作者:[Dave Stokes][a] +选题:[lujun9972][b] +译者:[unigeorge](https://github.com/unigeorge) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/davidmstokes +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-window-focus.png?itok=g0xPm2kD (young woman working on a laptop) +[2]: https://www.mysql.com/ +[3]: https://opensource101.com/ +[4]: https://www.phpconference.co.uk/ diff --git a/published/20210625 Windows 11 Makes Your Hardware Obsolete, Use Linux Instead.md b/published/20210625 Windows 11 Makes Your Hardware Obsolete, Use Linux Instead.md new file mode 100644 index 0000000000..3f28da1fd2 --- /dev/null +++ b/published/20210625 Windows 11 Makes Your Hardware Obsolete, Use Linux Instead.md @@ -0,0 +1,111 @@ +[#]: subject: (Windows 11 Makes Your Hardware Obsolete, Use Linux Instead!) +[#]: via: (https://news.itsfoss.com/windows-11-linux/) +[#]: author: (Ankush Das https://news.itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: (zd200572) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13640-1.html) + +Windows 11 让你的硬件过时,使用 Linux 代替吧! +====== + +> 微软希望你为 Windows 11 买新的硬件。你是否应该为 Windows 11 升级你的电脑,或者只是,用 Linux 代替!? + +![](https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/windows-to-linux.png?w=1200&ssl=1) + +Windows 11 终于来了,我们并不完全对此感到兴奋,它给许多电脑用户带来了困扰。 + +我甚至不是在讨论隐私方面或者它的设计选择,而是 Windows 11 要求更新的硬件才能工作,这在某种程度上让你的旧电脑变得过时,并迫使你毫无理由地升级新的硬件。 + +随着 Windows 11 的到来还有什么问题呢,它有什么不好的? + +### 只有符合条件的设备才能获得 Windows 11 升级 + +首先,有意思的是,Windows 11 添加了一个最低系统需求,这表面上看起来还行: + + * 1GHz 双核 64 位处理器 + * 4GB 内存 + * 64GB 存储空间 + * 支持 UEFI 安全启动 + * 受信任平台模块(TPM)版本 2.0 + * DirectX 12 兼容显卡 + * 720P 分辨率显示器 + +![][1] + +你可以在 [微软官方网站][2] 下载“电脑健康状况检查”应用检查你的系统是否符合条件。 + +过去十年内的大多数电脑能达到这些标准 —— 但有一个陷阱。 + +硬件需要有一个 TPM 芯片,一些电脑和笔记本可能没有。幸运的是,你可能只需要从 BIOS 设置中启用它(包括安全引导支持),就可以使你的电脑符合条件。这里有一个 [PCGamer][3] 的向导可以帮你。 + +从技术上说,根据微软官方文档,Windows 11 不支持比 **Intel 第 8 代和 Ryzen 3000 系列**更老的处理器([AMD][4] | [Intel][5])。 + +可是,有相当数量的电脑不支持,你该怎么做? + +很简单,在 Windows 10 不再收到更新之前,[都 2021 年了,换成 Linux 吧][6]。今年,在你的个人电脑上尝试 Linux 变得比任何时候更有意义! + +### Windows 11 安装需要网络连接 + +![][7] + +虽然我们不太清楚,但根据其系统要求规范,Windows 11 安装过程中将要求用户有可连通的互联网连接。 + +但是,Linux 不需要这样。 + +这只是其中一个 [使用 Linux 而不是 Windows][8] 的好处 —— 这是你可以完全掌控的操作系统。 + +### 没有 32 位支持 + +![][12] + +Windows 10 确实是支持 32 位系统的,但是 Windows 11 终结了相关支持。 + +这又是 Linux 的优势了。 + +尽管对 32 位支持都在逐渐减少,我们依然有一系列 [支持 32 位系统的 Linux 发行版][9]。或许你的 32 位电脑还能与 Linux 一起工作 10 年。 + +### Windows 10 将在 2025 年结束支持 + +好吧,鉴于微软最初计划在 Windows 10 之后永远不会有升级,而是在可预见的未来一直支持它,这是个意外。 + +现在,Windows 10 将会在 2025 年被干掉…… + +那么,到时候你该怎么做呢?升级你的硬件,只因为它不支持 Windows 11? + +除非有这个必要,否则 Linux 是你永远的朋友。 + +你可以尝试几个 [轻量级 Linux 发行版][10],它们将使你的任何一台被微软认为过时的电脑重新焕发生机。 + +### 结语 + +尽管 Windows 11 计划在未来几年内强迫用户升级他们的硬件,但 Linux 可以让你长时间继续使用你的硬件,并有一些额外的好处。 + +因此,如果你对 Windows 11 的发布不满意,你可能想开始使用 Linux 代替。不要烦恼,你可以参考我们的指南,来学习开始使用 Linux 的一切知识。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/windows-11-linux/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[zd200572](https://github.com/zd200572) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/windows-11-requirements-new.png?w=1026&ssl=1 +[2]: https://www.microsoft.com/en-us/windows/windows-11 +[3]: https://www.pcgamer.com/Windows-11-PC-Health-Check/ +[4]: https://docs.microsoft.com/en-us/windows-hardware/design/minimum/supported/windows-11-supported-amd-processors +[5]: https://docs.microsoft.com/en-us/windows-hardware/design/minimum/supported/windows-11-supported-intel-processors +[6]: https://news.itsfoss.com/switch-to-linux-in-2021/ +[7]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/internet-connectivity-illustration.png?w=1200&ssl=1 +[8]: https://itsfoss.com/linux-better-than-windows/ +[9]: https://itsfoss.com/32-bit-linux-distributions/ +[10]: https://itsfoss.com/lightweight-linux-beginners/ +[11]: https://itsfoss.com +[12]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/32-bit-support-illustration.png?w=1200&ssl=1 \ No newline at end of file diff --git a/published/20210626 Windows 11 Look Inspired by KDE Plasma and GNOME.md b/published/20210626 Windows 11 Look Inspired by KDE Plasma and GNOME.md new file mode 100644 index 0000000000..6bf2303b94 --- /dev/null +++ b/published/20210626 Windows 11 Look Inspired by KDE Plasma and GNOME.md @@ -0,0 +1,107 @@ +[#]: subject: (Windows 11 Look Inspired by KDE Plasma and GNOME?) +[#]: via: (https://www.debugpoint.com/2021/06/windows-11-inspiration-linux-kde-plasma/) +[#]: author: (Arindam https://www.debugpoint.com/author/admin1/) +[#]: collector: (lujun9972) +[#]: translator: (imgradeone) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13653-1.html) + +Windows 11 的外观受到了 KDE Plasma 和 GNOME 的启发吗? +====== + +> 截图显示,微软即将发布的 Windows 11 操作系统与我们所心爱的 KDE Plasma 和 GNOME 有许多相似之处。它们到底有多相似呢?我们试着比较了一下。 + +![](https://img.linux.net.cn/data/attachment/album/202108/06/103308cfoo3xoz2c002hx2.jpg) + +我曾记得一句俗话 —— “优秀者模仿,伟大者剽窃Good artists copy. Great artists steal”。我不认识 Windows 11 背后的设计团队,但他们似乎很大程度上受到了 Linux 桌面的影响。如果你回顾近几年来的 Windows 系统外观 —— 从 Windows XP 到 7,再到 10 —— 整体视觉上都没有什么太大的变化,直到今天为止。 + +Windows 操作系统的新版本通常有 5 到 7 年的生命周期。如果你试着回想 Windows 提供给你的个性化选项,你会发现这些选项近几年来基本都是一致的,甚至包括开始菜单位置、宽度、颜色在内的桌面整体的体验,一切都没变过。 + +但随着 Windows 11 的全新外观,这一点终于改变了。让我带你看一些我之前所见过的截图,并且分析一下,它们到底和流行的 Linux [桌面环境][1](如 KDE Plasma 和 GNOME)有多相似。 + +### Windows 11 的外观受到了 KDE Plasma 和 GNOME 的启发? + +#### 开始菜单和任务栏 + +传统的开始菜单和任务栏主题在 Windows 11 上有所变化。开始菜单和任务栏图标位于任务栏中央(默认视图)。Windows 也在设置中提供了将任务栏图标和开始菜单移回左侧的选项。 + +![Windows 11 – 浅色模式下的开始菜单][2] + +整体的布局方式和默认图标的色彩让我想起了 KDE Plasma 的任务栏和启动器。这些图标很精致,并且居中,给你带来一种类似 GNOME 上 Adwaita 图标的观感,而任务栏就更像是 KDE Plasma 的任务栏。 + +当你打开开始菜单后,它为你提供不同的图标和选项的排列方式。此外,当你开始打字时,顶部的搜索选项就会弹出。 + +现在,来看看全新设计的 KDE Plasma 启动器。我知道间距、图标大小和清晰度并不完全一致,但你可以看到,两者看起来有多么惊人的相似。 + +![KDE Plasma 5.22 亮色模式下的启动器][3] + +如果你正在使用 GNOME 或 Xfce 桌面,借助 [Arc Menu][4] 和一些小修改,你可以让两者看上去完全一致。 + +![修改过的 Arc Menu][5] + +#### 窗口装饰 + +按照传统,GNOME 总是用圆角作为标准的窗口装饰。作为对照,Windows 则一直采用直角作为窗口装饰 —— 似乎一直都这样,直到现在为止。嗯,在 Windows 11 中,所有窗口装饰都是圆角,看起来很好。圆角的概念不是什么版权专利或者新想法,这就有一个问题了,为什么现在全都在用圆角?是有什么隐藏的目的吗? + +![Windows 资源管理器和 Nautilus 的圆角][6] + +哦,还记得 GNOME 的应用程序菜单的小指示器吗?这些小点提示着这里到底有多少页的应用程序。Windows 11 似乎也使用了这种这种思路。 + +![标记页面数量的小点][7] + +#### 调色盘 + +Windows 多年来始终有基于“蓝色”或其他蓝色变体的主题。虽然用户可以自行更改任务栏、开始菜单背景、窗口标题栏颜色,但借助这个选项,调色板与亮暗模式结合,展示出巨大变化,给 Windows 桌面带来了更圆滑、迷人的外观。也许这个灵感源自 Ubuntu、KDE 或者其它风格的调色板。 + +#### 暗黑模式 + +Windows 11 首次官方支持了暗黑模式,或者说是暗色主题。那么,我就直接在下面放两张截图,由大家自己评判。左侧是 Windows 11 暗黑模式下的开始菜单,右侧是使用了 Breeze Dark 主题的 KDE Plasma。 + +![Windows 11 开始菜单与 KDE Plasma 的比较][9] + +#### 全新桌面小组件 + +灵感的启发从来不会停止。还记得 KDE Plasma 的小组件吗?其实,这也不是什么新概念,然而小组件已经出现在 Windows 11。这是全新小组件面板的截图。你可以添加、移除或者重新排序这些小组件。 + +![小组件菜单][10] + +这些只是吸引我眼球的冰山一角。也许 Windows 11 还有许多“灵感”来“启发”它的外观。 + +但问题来了 —— 为什么现在是一次推出这些功能和外观的最佳时机? + +### 结束语 + +实话实说,当我第一次看到 Windows 11 的新外观时,我脑袋里就浮现出 Breeze Dark 主题的 KDE Plasma。借助很少量的修改,你可以让 KDE Plasma 看上去像 Windows 11。这本身就说明了它们两者是有多么地相似。 + +如果你看向整个桌面操作系统的市场,竞争者只有 Windows、Linux 桌面和 macOS。至今为止,它们的外观都有明显的标志性特征,例如 macOS 有自己独一无二的外观。直到现在,Windows 也有一样的蓝色主题的常规开始菜单,等等。但借助这些新变化,Windows 为用户提供了更丰富的定制选项,让它看上去更像 Linux 桌面。 + +在我个人看来,Windows 团队需要一种不同的标志性特征,而不是一直从我们心爱的 Linux 桌面获得“启发”。 + +我不知道未来会发生什么,但现在看来,“E-E-E” 还在竭尽全力运作。(LCTT 译注:“E-E-E”是微软臭名昭著的拥抱、扩展再消灭Embrace, extend, and extinguish策略。) + +再会。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2021/06/windows-11-inspiration-linux-kde-plasma/ + +作者:[Arindam][a] +选题:[lujun9972][b] +译者:[imgradeone](https://github.com/imgradeone) +校对:[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/lujun9972 +[1]: https://www.debugpoint.com/category/desktop-environment +[2]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/Windows-11-Start-menu-in-light-mode.jpg +[3]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/KDE-Plasma-5.22-Launcher-in-Light-mode.jpg +[4]: https://gitlab.com/LinxGem33/Arc-Menu +[5]: https://www.debugpoint.com/blog/wp-content/uploads/2020/12/gnomecustomize2020-2-1024x576.jpg +[6]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/Rounded-Corners-in-Windows-Explorer-and-Nautilus-1024x716.jpg +[7]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/Dots-in-paging-1024x468.jpg +[8]: https://www.debugpoint.com/2021/06/windows-11-system-requirement/ +[9]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/Comparison-of-Windows-11-Start-Menu-and-KDE-Plasma-1024x505.jpg +[10]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/Widgets-menu-1024x833.jpg diff --git a/published/202107/20180416 Cgo and Python.md b/published/202107/20180416 Cgo and Python.md new file mode 100644 index 0000000000..dea1e2c230 --- /dev/null +++ b/published/202107/20180416 Cgo and Python.md @@ -0,0 +1,334 @@ +如何在 Go 中嵌入 Python +================== + +![](https://datadog-prod.imgix.net/img/blog/engineering/cgo-and-python/cgo_python_hero.png?auto=format&w=1900&dpr=1) + +如果你看一下 [新的 Datadog Agent][8],你可能会注意到大部分代码库是用 Go 编写的,尽管我们用来收集指标的检查仍然是用 Python 编写的。这大概是因为 Datadog Agent 是一个 [嵌入了][9] CPython 解释器的普通 Go 二进制文件,可以在任何时候按需执行 Python 代码。这个过程通过抽象层来透明化,使得你可以编写惯用的 Go 代码而底层运行的是 Python。 + +[视频](https://youtu.be/yrEi5ezq2-c) + +在 Go 应用程序中嵌入 Python 的原因有很多: + +* 它在过渡期间很有用;可以逐步将现有 Python 项目的部分迁移到新语言,而不会在此过程中丢失任何功能。 +* 你可以复用现有的 Python 软件或库,而无需用新语言重新实现。 +* 你可以通过加载去执行常规 Python 脚本来动态扩展你软件,甚至在运行时也可以。 + +理由还可以列很多,但对于 Datadog Agent 来说,最后一点至关重要:我们希望做到无需重新编译 Agent,或者说编译任何内容就能够执行自定义检查或更改现有检查。 + +嵌入 CPython 非常简单,而且文档齐全。解释器本身是用 C 编写的,并且提供了一个 C API 以编程方式来执行底层操作,例如创建对象、导入模块和调用函数。 + +在本文中,我们将展示一些代码示例,我们将会在与 Python 交互的同时继续保持 Go 代码的惯用语,但在我们继续之前,我们需要解决一个间隙:嵌入 API 是 C 语言,但我们的主要应用程序是 Go,这怎么可能工作? + +![](https://datadog-prod.imgix.net/img/blog/engineering/cgo-and-python/cgo_python_divider_1.png?auto=format&fit=max&w=847) + +### 介绍 cgo + +有 [很多好的理由][10] 说服你为什么不要在堆栈中引入 cgo,但嵌入 CPython 是你必须这样做的原因。[cgo][11] 不是语言,也不是编译器。它是 [外部函数接口][12]Foreign Function Interface(FFI),一种让我们可以在 Go 中使用来调用不同语言(特别是 C)编写的函数和服务的机制。 + +当我们提起 “cgo” 时,我们实际上指的是 Go 工具链在底层使用的一组工具、库、函数和类型,因此我们可以通过执行 `go build` 来获取我们的 Go 二进制文件。下面是使用 cgo 的示例程序: + +``` +package main + +// #include +import "C" +import "fmt" + +func main() { + fmt.Println("Max float value of float is", C.FLT_MAX) +} + +``` + +在这种包含头文件情况下,`import "C"` 指令上方的注释块称为“序言preamble”,可以包含实际的 C 代码。导入后,我们可以通过“C”伪包来“跳转”到外部代码,访问常量 `FLT_MAX`。你可以通过调用 `go build` 来构建,它就像普通的 Go 一样。 + +如果你想查看 cgo 在这背后到底做了什么,可以运行 `go build -x`。你将看到 “cgo” 工具将被调用以生成一些 C 和 Go 模块,然后将调用 C 和 Go 编译器来构建目标模块,最后链接器将所有内容放在一起。 + +你可以在 [Go 博客][13] 上阅读更多有关 cgo 的信息,该文章包含更多的例子以及一些有用的链接来做进一步了解细节。 + +现在我们已经了解了 cgo 可以为我们做什么,让我们看看如何使用这种机制运行一些 Python 代码。 + +![](https://datadog-prod.imgix.net/img/blog/engineering/cgo-and-python/cgo_python_divider_2.png?auto=format&fit=max&w=847) + +### 嵌入 CPython:一个入门指南 + +从技术上讲,嵌入 CPython 的 Go 程序并没有你想象的那么复杂。事实上,我们只需在运行 Python 代码之前初始化解释器,并在完成后关闭它。请注意,我们在所有示例中使用 Python 2.x,但我们只需做很少的调整就可以应用于 Python 3.x。让我们看一个例子: + +``` +package main + +// #cgo pkg-config: python-2.7 +// #include +import "C" +import "fmt" + +func main() { + C.Py_Initialize() + fmt.Println(C.GoString(C.Py_GetVersion())) + C.Py_Finalize() +} + +``` + +上面的例子做的正是下面 Python 代码要做的事: + +``` +import sys +print(sys.version) +``` + +你可以看到我们在序言加入了一个 `#cgo` 指令;这些指令被会被传递到工具链,让你改变构建工作流程。在这种情况下,我们告诉 cgo 调用 `pkg-config` 来收集构建和链接名为 `python-2.7` 的库所需的标志,并将这些标志传递给 C 编译器。如果你的系统中安装了 CPython 开发库和 pkg-config,你只需要运行 `go build` 来编译上面的示例。 + +回到代码,我们使用 `Py_Initialize()` 和 `Py_Finalize()` 来初始化和关闭解释器,并使用 `Py_GetVersion` C 函数来获取嵌入式解释器版本信息的字符串。 + +如果你想知道,所有我们需要放在一起调用 C 语言 Python API的 cgo 代码都是模板代码。这就是为什么 Datadog Agent 依赖 [go-python][14] 来完成所有的嵌入操作;该库为 C API 提供了一个 Go 友好的轻量级包,并隐藏了 cgo 细节。这是另一个基本的嵌入式示例,这次使用 go-python: + +``` +package main + +import ( + python "github.com/sbinet/go-python" +) + +func main() { + python.Initialize() + python.PyRun_SimpleString("print 'hello, world!'") + python.Finalize() +} + +``` + +这看起来更接近普通 Go 代码,不再暴露 cgo,我们可以在访问 Python API 时来回使用 Go 字符串。嵌入式看起来功能强大且对开发人员友好,是时候充分利用解释器了:让我们尝试从磁盘加载 Python 模块。 + +在 Python 方面我们不需要任何复杂的东西,无处不在的“hello world” 就可以达到目的: + +``` +# foo.py +def hello(): + """ + Print hello world for fun and profit. + """ + print "hello, world!" +``` + +Go 代码稍微复杂一些,但仍然可读: + +``` +// main.go +package main + +import "github.com/sbinet/go-python" + +func main() { + python.Initialize() + defer python.Finalize() + + fooModule := python.PyImport_ImportModule("foo") + if fooModule == nil { + panic("Error importing module") + } + + helloFunc := fooModule.GetAttrString("hello") + if helloFunc == nil { + panic("Error importing function") + } + + // The Python function takes no params but when using the C api + // we're required to send (empty) *args and **kwargs anyways. + helloFunc.Call(python.PyTuple_New(0), python.PyDict_New()) +} + +``` + +构建时,我们需要将 `PYTHONPATH` 环境变量设置为当前工作目录,以便导入语句能够找到 `foo.py` 模块。在 shell 中,该命令如下所示: + +``` +$ go build main.go && PYTHONPATH=. ./main +hello, world! +``` + +![](https://datadog-prod.imgix.net/img/blog/engineering/cgo-and-python/cgo_python_divider_3.png?auto=format&fit=max&w=847) + +### 可怕的全局解释器锁 + +为了嵌入 Python 必须引入 cgo ,这是一种权衡:构建速度会变慢,垃圾收集器不会帮助我们管理外部系统使用的内存,交叉编译也很难。对于一个特定的项目来说,这些问题是否是可以争论的,但我认为有一些不容商量的问题:Go 并发模型。如果我们不能从 goroutine 中运行 Python,那么使用 Go 就没有意义了。 + +在处理并发、Python 和 cgo 之前,我们还需要知道一些事情:它就是全局解释器锁Global Interpreter Lock,即 GIL。GIL 是语言解释器(CPython 就是其中之一)中广泛采用的一种机制,可防止多个线程同时运行。这意味着 CPython 执行的任何 Python 程序都无法在同一进程中并行运行。并发仍然是可能的,锁是速度、安全性和实现简易性之间的一个很好的权衡,那么,当涉及到嵌入时,为什么这会造成问题呢? + +当一个常规的、非嵌入式的 Python 程序启动时,不涉及 GIL 以避免锁定操作中的无用开销;在某些 Python 代码首次请求生成线程时 GIL 就启动了。对于每个线程,解释器创建一个数据结构来存储当前的相关状态信息并锁定 GIL。当线程完成时,状态被恢复,GIL 被解锁,准备被其他线程使用。 + +当我们从 Go 程序运行 Python 时,上述情况都不会自动发生。如果没有 GIL,我们的 Go 程序可以创建多个 Python 线程,这可能会导致竞争条件,从而导致致命的运行时错误,并且很可能出现分段错误导致整个 Go 应用程序崩溃。 + +解决方案是在我们从 Go 运行多线程代码时显式调用 GIL;代码并不复杂,因为 C API 提供了我们需要的所有工具。为了更好地暴露这个问题,我们需要写一些受 CPU 限制的 Python 代码。让我们将这些函数添加到前面示例中的 `foo.py` 模块中: + +``` +# foo.py +import sys + +def print_odds(limit=10): + """ + Print odds numbers < limit + """ + for i in range(limit): + if i%2: + sys.stderr.write("{}\n".format(i)) + +def print_even(limit=10): + """ + Print even numbers < limit + """ + for i in range(limit): + if i%2 == 0: + sys.stderr.write("{}\n".format(i)) + +``` + +我们将尝试从 Go 并发打印奇数和偶数,使用两个不同的 goroutine(因此涉及线程): + +``` +package main + +import ( + "sync" + + "github.com/sbinet/go-python" +) + +func main() { + // The following will also create the GIL explicitly + // by calling PyEval_InitThreads(), without waiting + // for the interpreter to do that + python.Initialize() + + var wg sync.WaitGroup + wg.Add(2) + + fooModule := python.PyImport_ImportModule("foo") + odds := fooModule.GetAttrString("print_odds") + even := fooModule.GetAttrString("print_even") + + // Initialize() has locked the the GIL but at this point we don't need it + // anymore. We save the current state and release the lock + // so that goroutines can acquire it + state := python.PyEval_SaveThread() + + go func() { + _gstate := python.PyGILState_Ensure() + odds.Call(python.PyTuple_New(0), python.PyDict_New()) + python.PyGILState_Release(_gstate) + + wg.Done() + }() + + go func() { + _gstate := python.PyGILState_Ensure() + even.Call(python.PyTuple_New(0), python.PyDict_New()) + python.PyGILState_Release(_gstate) + + wg.Done() + }() + + wg.Wait() + + // At this point we know we won't need Python anymore in this + // program, we can restore the state and lock the GIL to perform + // the final operations before exiting. + python.PyEval_RestoreThread(state) + python.Finalize() +} + +``` + +在阅读示例时,你可能会注意到一个模式,该模式将成为我们运行嵌入式 Python 代码的习惯写法: + +1. 保存状态并锁定 GIL。 +2. 执行 Python。 +3. 恢复状态并解锁 GIL。 + +代码应该很简单,但我们想指出一个微妙的细节:请注意,尽管借用了 GIL 执行,有时我们通过调用 `PyEval_SaveThread()` 和 `PyEval_RestoreThread()` 来操作 GIL,有时(查看 goroutines 里面)我们对 `PyGILState_Ensure()` 和 `PyGILState_Release()` 来做同样的事情。 + +我们说过当从 Python 操作多线程时,解释器负责创建存储当前状态所需的数据结构,但是当同样的事情发生在 C API 时,我们来负责处理。 + +当我们用 go-python 初始化解释器时,我们是在 Python 上下文中操作的。因此,当调用 `PyEval_InitThreads()` 时,它会初始化数据结构并锁定 GIL。我们可以使用 `PyEval_SaveThread()` 和 `PyEval_RestoreThread()` 对已经存在的状态进行操作。 + +在 goroutines 中,我们从 Go 上下文操作,我们需要显式创建状态并在完成后将其删除,这就是 `PyGILState_Ensure()` 和 `PyGILState_Release()` 为我们所做的。 + +![](https://datadog-prod.imgix.net/img/blog/engineering/cgo-and-python/cgo_python_divider_4.png?auto=format&fit=max&w=847) + +### 释放 Gopher + +在这一点上,我们知道如何处理在嵌入式解释器中执行 Python 的多线程 Go 代码,但在 GIL 之后,另一个挑战即将来临:Go 调度程序。 + +当一个 goroutine 启动时,它被安排在可用的 `GOMAXPROCS` 线程之一上执行,[参见此处][15] 可了解有关该主题的更多详细信息。如果一个 goroutine 碰巧执行了系统调用或调用 C 代码,当前线程会将线程队列中等待运行的其他 goroutine 移交给另一个线程,以便它们有更好的机会运行; 当前 goroutine 被暂停,等待系统调用或 C 函数返回。当这种情况发生时,线程会尝试恢复暂停的 goroutine,但如果这不可能,它会要求 Go 运行时找到另一个线程来完成 goroutine 并进入睡眠状态。 goroutine 最后被安排给另一个线程,它就完成了。 + +考虑到这一点,让我们看看当一个 goroutine 被移动到一个新线程时,运行一些 Python 代码的 goroutine 会发生什么: + +1. 我们的 goroutine 启动,执行 C 调用并暂停。GIL 被锁定。 +2. 当 C 调用返回时,当前线程尝试恢复 goroutine,但失败了。 +3. 当前线程告诉 Go 运行时寻找另一个线程来恢复我们的 goroutine。 +4. Go 调度器找到一个可用线程并恢复 goroutine。 +5. goroutine 快完成了,并在返回之前尝试解锁 GIL。 +6. 当前状态中存储的线程 ID 来自原线程,与当前线程的 ID 不同。 +7. 崩溃! + +所幸,我们可以通过从 goroutine 中调用运行时包中的 `LockOSThread` 函数来强制 Go runtime 始终保持我们的 goroutine 在同一线程上运行: + +``` +go func() { + runtime.LockOSThread() + + _gstate := python.PyGILState_Ensure() + odds.Call(python.PyTuple_New(0), python.PyDict_New()) + python.PyGILState_Release(_gstate) + wg.Done() +}() +``` + +这会干扰调度器并可能引入一些开销,但这是我们愿意付出的代价。 + +### 结论 + +为了嵌入 Python,Datadog Agent 必须接受一些权衡: + +* cgo 引入的开销。 +* 手动处理 GIL 的任务。 +* 在执行期间将 goroutine 绑定到同一线程的限制。 + +为了能方便在 Go 中运行 Python 检查,我们很乐意接受其中的每一项。但通过意识到这些权衡,我们能够最大限度地减少它们的影响,除了为支持 Python 而引入的其他限制,我们没有对策来控制潜在问题: + +* 构建是自动化和可配置的,因此开发人员仍然需要拥有与 `go build` 非常相似的东西。 +* Agent 的轻量级版本,可以使用 Go 构建标签,完全剥离 Python 支持。 +* 这样的版本仅依赖于在 Agent 本身硬编码的核心检查(主要是系统和网络检查),但没有 cgo 并且可以交叉编译。 + +我们将在未来重新评估我们的选择,并决定是否仍然值得保留 cgo;我们甚至可以重新考虑整个 Python 是否仍然值得,等待 [Go 插件包][16] 成熟到足以支持我们的用例。但就目前而言,嵌入式 Python 运行良好,从旧代理过渡到新代理再简单不过了。 + +你是一个喜欢混合不同编程语言的多语言者吗?你喜欢了解语言的内部工作原理以提高你的代码性能吗? + +-------------------------------------------------------------------------------- + +via: https://www.datadoghq.com/blog/engineering/cgo-and-python/ + +作者:[Massimiliano Pippi][a] +译者:[Zioyi](https://github.com/Zioyi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://github.com/masci +[1]:http://twitter.com/share?url=https://www.datadoghq.com/blog/engineering/cgo-and-python/ +[2]:http://www.reddit.com/submit?url=https://www.datadoghq.com/blog/engineering/cgo-and-python/ +[3]:https://www.linkedin.com/shareArticle?mini=true&url=https://www.datadoghq.com/blog/engineering/cgo-and-python/ +[4]:https://www.datadoghq.com/blog/category/under-the-hood +[5]:https://www.datadoghq.com/blog/tag/agent +[6]:https://www.datadoghq.com/blog/tag/golang +[7]:https://www.datadoghq.com/blog/tag/python +[8]:https://github.com/DataDog/datadog-agent/ +[9]:https://docs.python.org/2/extending/embedding.html +[10]:https://dave.cheney.net/2016/01/18/cgo-is-not-go +[11]:https://golang.org/cmd/cgo/ +[12]:https://en.wikipedia.org/wiki/Foreign_function_interface +[13]:https://blog.golang.org/c-go-cgo +[14]:https://github.com/sbinet/go-python +[15]:https://morsmachine.dk/go-scheduler +[16]:https://golang.org/pkg/plugin/ +[17]:https://www.datadoghq.com/careers/ diff --git a/published/202107/20180713 What-s the difference between a fork and a distribution.md b/published/202107/20180713 What-s the difference between a fork and a distribution.md new file mode 100644 index 0000000000..3cb7d0bd95 --- /dev/null +++ b/published/202107/20180713 What-s the difference between a fork and a distribution.md @@ -0,0 +1,77 @@ +分支与发行版有什么不同? +====== + +> 开源软件的发行版和分支是不一样的。了解其中的区别和潜在的风险。 + +![](https://img.linux.net.cn/data/attachment/album/202107/22/205518spblrgcpxrlnbibe.jpg) + +如果你们对开源软件有过一段时间的了解,一定曾在许多相关方面中听说过分支fork发行版distribution两个词。许多人对这两个词的区别不太清楚,因此我将试着通过这篇文章为大家解答这一疑惑。 + +(LCTT 译注:fork 一词,按我们之前的倡议,在版本控制工作流中,为了避免和同一个仓库的 branch 一词混淆,我们建议翻译为“复刻”。但是在项目和发行版这个语境下,没有这个混淆,惯例上还是称之为“分支”。) + +### 首先,一些定义 + +在解释分支与发行版两者的细微区别与相似之处之前,让我们先给一些相关的重要概念下定义。 + +**[开源软件][1]** 是指具有以下特点的软件: + + * 在特定的 [许可证][2] 限制下,软件供所有人免费分发 + * 在特定的许可证限制下,软件源代码可以供所有人查看与修改 + +开源软件可以按以下方式 **使用**: + + * 以二进制或者源代码的方式下载,通常是免费的。(例如,[Eclipse 开发者环境][3]) + * 作为一个商业公司的产品,有时向用户提供一些服务并以此收费。(例如,[红帽产品][4]) + * 嵌入在专有的软件解决方案中。(例如一些智能手机和浏览器用于显示字体的 [Freetype 软件][5]) + +自由开源软件free and open source software(FOSS)不一定是“零成本”的“免费free”。自由开源软件仅仅意味着这个软件在遵守软件许可证的前提下可以自由地分发、修改、研究和使用。软件分发者也可能为该软件定价。例如,Linux 可以是 Fedora、Centos、Gentoo 等免费发行版,也可以是付费的发行版,如红帽企业版 Linux(RHEL)、SUSE Linux 企业版(SLES)等。 + +社区community指的是在一个开源项目上协作的团体或个人。任何人或者团体都可以在遵守协议的前提下,通过编写或审查代码/文档/测试套件、管理会议、更新网站等方式为开源项目作出贡献。例如,在 [Openhub.net][6] 网站上,我们可以看见政府、非营利性机构、商业公司和教育团队等组织都在 [为一些开源项目作出贡献][7]。 + +一个开源项目project是集协作开发、文档和测试的结果。大多数项目都搭建了一个中央仓库用来存储代码、文档、测试文件和目前正在开发的文件。 + +发行版distribution是指开源项目的一份的二进制或源代码的副本。例如,CentOS、Fedora、红帽企业版 Linux(RHEL)、SUSE Linux、Ubuntu 等都是 Linux 项目的发行版。Tectonic、谷歌的 Kubernetes 引擎(GKE)、亚马逊的容器服务和红帽的 OpenShift 都是 Kubernetes 项目的发行版。 + +开源项目的商业发行版经常被称作产品products,因此,红帽 OpenStack 平台是红帽 OpenStack 的产品,它是 OpenStack 上游项目的一个发行版,并且是百分百开源的。 + +主干trunk是开发开源项目的社区的主要工作流。 + +开源分支fork是开源项目主干的一个版本,它是分离自主干的独立工作流。 + +因此,**发行版并不等同于分支**。发行版是上游项目的一种包装,由厂商提供,经常作为产品进行销售。然而,发行版的核心代码和文档与上游项目的版本保持一致。分支,以及任何基于分支的的发行版,导致代码和文档的版本与上游项目不同。对上游项目进行了分支的用户必须自己来维护分支项目,这意味着他们失去了上游社区协同工作带来的好处。 + +为了进一步解释软件分支,让我来用动物迁徙作比喻。鲸鱼和海狮从北极迁徙到加利福尼亚和墨西哥;帝王斑蝶从阿拉斯加迁徙到墨西哥;并且北半球的燕子和许多其他鸟类飞翔南方去过冬。成功迁徙的关键因素在于,团队中的所有动物团结一致,紧跟领导者,找到食物和庇护所,并且不会迷路。 + +### 独立前行带来的风险 + +一只鸟、帝王蝶或者鲸鱼一旦掉队就失去了许多优势,例如团队带来的保护,以及知道哪儿有食物、庇护所和目的地。 + +相似地,从上游版本获取分支并且独立维护的用户和组织也存在以下风险: + + 1. **由于代码不同,分支用户不能够基于上游版本更新代码。** 这就是大家熟知的技术债,对分支的代码修改的越多,将这一分支重新归入上游项目需要花费的时间和金钱成本就越高。 + 2. **分支用户有可能运行不太安全的代码。** 由于代码不同的原因,当开源代码的漏洞被找到,并且被上游社区修复时,分支版本的代码可能无法从这次修复中受益。 + 3. **分支用户可能不会从新特性中获益。** 拥有众多组织和个人支持的上游版本,将会创建许多符合所有上游项目用户利益的新特性。如果一个组织从上游分支,由于代码不同,它们可能无法纳入新的功能。 + 4. **它们可能无法和其他软件包整合在一起。** 开源项目很少是作为单一实体开发的;相反地,它们经常被与其他项目打包在一起构成一套解决方案。分支代码可能无法与其他项目整合,因为分支代码的开发者没有与上游的其他参与者们合作。 + 5. **它们可能不会得到硬件平台认证。** 软件包通常被搭载在硬件平台上进行认证,如果有问题发生,硬件与软件工作人员可以合作找出并解决问题发生的根源。 + +总之,开源发行版只是一个来自上游的、多组织协同开发的、由供应商销售与支持的打包集合。分支是一个开源项目的独立开发工作流,有可能无法从上游社区协同工作的结果中受益。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/7/forks-vs-distributions + +作者:[Jonathan Gershater][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[Wlzzzz-del](https://github.com/Wlzzzz-del) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/jgershat +[1]:https://opensource.com/resources/what-open-source +[2]:https://opensource.com/tags/licensing +[3]:https://www.eclipse.org/che/getting-started/download/ +[4]:https://access.redhat.com/downloads +[5]:https://www.freetype.org/ +[6]:http://openhub.net +[7]:https://www.openhub.net/explore/orgs diff --git a/published/202107/20190807 Trace code in Fedora with bpftrace.md b/published/202107/20190807 Trace code in Fedora with bpftrace.md new file mode 100644 index 0000000000..8a1c67ba8b --- /dev/null +++ b/published/202107/20190807 Trace code in Fedora with bpftrace.md @@ -0,0 +1,200 @@ +[#]: collector: (lujun9972) +[#]: translator: (YungeG) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13632-1.html) +[#]: subject: (Trace code in Fedora with bpftrace) +[#]: via: (https://fedoramagazine.org/trace-code-in-fedora-with-bpftrace/) +[#]: author: (Augusto Caringi https://fedoramagazine.org/author/acaringi/) + +在 Fedora 中用 bpftrace 追踪代码 +====== + +![](https://img.linux.net.cn/data/attachment/album/202107/29/222633wjln78my68exj7x9.jpg) + +bpftrace 是一个 [基于 eBPF 的新型追踪工具][2],在 Fedora 28 第一次引入。Brendan Gregg、Alastair Robertson 和 Matheus Marchini 在网上的一个松散的黑客团队的帮助下开发了 bpftrace。它是一个允许你分析系统在幕后正在执行的操作的追踪工具,可以告诉你代码中正在被调用的函数、传递给函数的参数、函数的调用次数等。 + +这篇文章的内容涉及了 bpftrace 的一些基础,以及它是如何工作的,请继续阅读获取更多的信息和一些有用的实例。 + +### eBPF(扩展的伯克利数据包过滤器extended Berkeley Packet Filter) + +[eBPF][3] 是一个微型虚拟机,更确切的说是一个位于 Linux 内核中的虚拟 CPU。eBPF 可以在内核空间以一种安全可控的方式加载和运行小型程序,使得 eBPF 的使用更加安全,即使在生产环境系统中。eBPF 虚拟机有自己的指令集架构([ISA][4]),类似于现代处理器架构的一个子集。通过这个 ISA,可以很容易将 eBPF 程序转化为真实硬件上的代码。内核即时将程序转化为主流处理器架构上的本地代码,从而提升性能。 + +eBPF 虚拟机允许通过编程扩展内核,目前已经有一些内核子系统使用这一新型强大的 Linux 内核功能,比如网络、安全计算、追踪等。这些子系统的主要思想是添加 eBPF 程序到特定的代码点,从而扩展原生的内核行为。 + +虽然 eBPF 机器语言功能强大,由于是一种底层语言,直接用于编写代码很费力,bpftrace 就是为了解决这个问题而生的。eBPF 提供了一种编写 eBPF 追踪脚本的高级语言,然后在 clang / LLVM 库的帮助下将这些脚本转化为 eBPF,最终添加到特定的代码点。 + +### 安装和快速入门 + +在终端 [使用][5] [sudo][5] 执行下面的命令安装 bpftrace: + +``` +$ sudo dnf install bpftrace +``` + +使用“hello world”进行实验: + +``` +$ sudo bpftrace -e 'BEGIN { printf("hello world\n"); }' +``` + +注意,出于特权级的需要,你必须使用 root 运行 `bpftrace`,使用 `-e` 选项指明一个程序,构建一个所谓的“单行程序”。这个例子只会打印 “hello world”,接着等待你按下 `Ctrl+C`。 + +`BEGIN` 是一个特殊的探针名,只在执行一开始生效一次;每次探针命中时,大括号 `{}` 内的操作(这个例子中只是一个 `printf`)都会执行。 + +现在让我们转向一个更有用的例子: + +``` +$ sudo bpftrace -e 't:syscalls:sys_enter_execve { printf("%s called %s\n", comm, str(args->filename)); }' +``` + +这个例子打印了父进程的名字(`comm`)和系统中正在创建的每个新进程的名称。`t:syscalls:sys_enter_execve` 是一个内核追踪点,是 `tracepoint:syscalls:sys_enter_execve` 的简写,两种形式都可以使用。下一部分会向你展示如何列出所有可用的追踪点。 + +`comm` 是一个 bpftrace 内建指令,代表进程名;`filename` 是 `t:syscalls:sys_enter_execve` 追踪点的一个字段,这些字段可以通过 `args` 内建指令访问。 + +追踪点的所有可用字段可以通过这个命令列出: + +``` +bpftrace -lv "t:syscalls:sys_enter_execve" +``` + +### 示例用法 + +#### 列出探针 + +`bpftrace` 的一个核心概念是探针点probe point,即 eBPF 程序可以连接到的(内核或用户空间的)代码中的测量点,可以分成以下几大类: + + * `kprobe`——内核函数的开始处 + * `kretprobe`——内核函数的返回处 + * `uprobe`——用户级函数的开始处 + * `uretprobe`——用户级函数的返回处 + * `tracepoint`——内核静态追踪点 + * `usdt`——用户级静态追踪点 + * `profile`——基于时间的采样 + * `interval`——基于时间的输出 + * `software`——内核软件事件 + * `hardware`——处理器级事件 + +所有可用的 `kprobe` / `kretprobe`、`tracepoints`、`software` 和 `hardware` 探针可以通过这个命令列出: + +``` +$ sudo bpftrace -l +``` + +`uprobe` / `uretprobe` 和 `usdt` 是用户空间探针,专用于某个可执行文件。要使用这些探针,通过下文中的特殊语法。 + +`profile` 和 `interval` 探针以固定的时间间隔触发;固定的时间间隔不在本文的范畴内。 + +#### 统计系统调用数 + +**映射** 是保存计数、统计数据和柱状图的特殊 BPF 数据类型,你可以使用映射统计每个系统调用正在被调用的次数: + +``` +$ sudo bpftrace -e 't:syscalls:sys_enter_* { @[probe] = count(); }' +``` + +一些探针类型允许使用通配符匹配多个探针,你也可以使用一个逗号隔开的列表为一个操作块指明多个连接点。上面的例子中,操作块连接到了所有名称以 `t:syscalls:sysenter_` 开头的追踪点,即所有可用的系统调用。 + +`bpftrace` 的内建函数 `count()` 统计系统调用被调用的次数;`@[]` 代表一个映射(一个关联数组)。该映射的键 `probe` 是另一个内建指令,代表完整的探针名。 + +这个例子中,相同的操作块连接到了每个系统调用,之后每次有系统调用被调用时,映射就会被更新,映射中和系统调用对应的项就会增加。程序终止时,自动打印出所有声明的映射。 + +下面的例子统计所有的系统调用,然后通过 `bpftrace` 过滤语法使用 PID 过滤出某个特定进程调用的系统调用: + +``` +$ sudo bpftrace -e 't:syscalls:sys_enter_* / pid == 1234 / { @[probe] = count(); }' +``` + +#### 进程写的字节数 + +让我们使用上面的概念分析每个进程正在写的字节数: + +``` +$ sudo bpftrace -e 't:syscalls:sys_exit_write /args->ret > 0/ { @[comm] = sum(args->ret); }' +``` + +`bpftrace` 连接操作块到写系统调用的返回探针(`t:syscalls:sys_exit_write`),然后使用过滤器丢掉代表错误代码的负值(`/arg->ret > 0/`)。 + +映射的键 `comm` 代表调用系统调用的进程名;内建函数 `sum()` 累计每个映射项或进程写的字节数;`args` 是一个 `bpftrace` 内建指令,用于访问追踪点的参数和返回值。如果执行成功,`write` 系统调用返回写的字节数,`arg->ret` 用于访问这个字节数。 + +#### 进程的读取大小分布(柱状图): + +`bpftrace` 支持创建柱状图。让我们分析一个创建进程的 `read` 大小分布的柱状图的例子: + +``` +$ sudo bpftrace -e 't:syscalls:sys_exit_read { @[comm] = hist(args->ret); }' +``` + +柱状图是 BPF 映射,因此必须保存为一个映射(`@`),这个例子中映射键是 `comm`。 + +这个例子使 `bpftrace` 给每个调用 `read` 系统调用的进程生成一个柱状图。要生成一个全局柱状图,直接保存 `hist()` 函数到 `@`(不使用任何键)。 + +程序终止时,`bpftrace` 自动打印出声明的柱状图。创建柱状图的基准值是通过 _args->ret_ 获取到的读取的字节数。 + +#### 追踪用户空间程序 + +你也可以通过 `uprobes` / `uretprobes` 和 USDT(用户级静态定义的追踪)追踪用户空间程序。下一个例子使用探测用户级函数结尾处的 `uretprobe` ,获取系统中运行的每个 `bash` 发出的命令行: + +``` +$ sudo bpftrace -e 'uretprobe:/bin/bash:readline { printf("readline: \"%s\"\n", str(retval)); }' +``` + +要列出可执行文件 `bash` 的所有可用 `uprobes` / `uretprobes`, 执行这个命令: + +``` +$ sudo bpftrace -l "uprobe:/bin/bash" +``` + +`uprobe` 指向用户级函数执行的开始,`uretprobe` 指向执行的结束(返回处);`readline()` 是 `/bin/bash` 的一个函数,返回键入的命令行;`retval` 是被探测的指令的返回值,只能在 `uretprobe` 访问。 + +使用 `uprobes` 时,你可以用 `arg0..argN` 访问参数。需要调用 `str()` 将 `char *` 指针转化成一个字符串。 + +### 自带脚本 + +`bpftrace` 软件包附带了许多有用的脚本,可以在 `/usr/share/bpftrace/tools/` 目录找到。 + +这些脚本中,你可以找到: + + * `killsnoop.bt`——追踪 `kill()` 系统调用发出的信号 + * `tcpconnect.bt`——追踪所有的 TCP 网络连接 + * `pidpersec.bt`——统计每秒钟(通过 `fork`)创建的新进程 + * `opensnoop.bt`——追踪 `open()` 系统调用 + * `bfsstat.bt`——追踪一些 VFS 调用,按秒统计 + +你可以直接使用这些脚本,比如: + +``` +$ sudo /usr/share/bpftrace/tools/killsnoop.bt +``` + +你也可以在创建新的工具时参考这些脚本。 + +### 链接 + + * bpftrace 参考指南—— + * Linux 2018 `bpftrace`(DTrace 2.0)—— + * BPF:通用的内核虚拟机—— + * Linux Extended BPF(eBPF)Tracing Tools—— + * 深入 BPF:一个阅读材料列表—— [https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf][6] + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/trace-code-in-fedora-with-bpftrace/ + +作者:[Augusto Caringi][a] +选题:[lujun9972][b] +译者:[YungeG](https://github.com/YungeG) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/acaringi/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/08/bpftrace-816x345.jpg +[2]: https://github.com/iovisor/bpftrace +[3]: https://lwn.net/Articles/740157/ +[4]: https://github.com/iovisor/bpf-docs/blob/master/eBPF.md +[5]: https://fedoramagazine.org/howto-use-sudo/ +[6]: https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/ +[7]: https://unsplash.com/@wehavemegapixels?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[8]: https://unsplash.com/search/photos/trace?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/published/202107/20200210 Music composition with Python and Linux.md b/published/202107/20200210 Music composition with Python and Linux.md new file mode 100644 index 0000000000..ca457a139a --- /dev/null +++ b/published/202107/20200210 Music composition with Python and Linux.md @@ -0,0 +1,107 @@ +[#]: collector: (lujun9972) +[#]: translator: (stevenzdg988) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13547-1.html) +[#]: subject: (Music composition with Python and Linux) +[#]: via: (https://opensource.com/article/20/2/linux-open-source-music) +[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss) + +“MAGFest 先生”专访:用 Python 和 Linux 进行音乐创作 +====== + +> 与 “MAGFest 先生” Brendan Becker 的对话。 + +![](https://img.linux.net.cn/data/attachment/album/202107/04/174833k7uvo4l5vov7umv4.jpg) + +1999 年,我在一家计算机商店工作时遇到了 Brendan Becker。我们都喜欢构建定制计算机并在其上安装 Linux。Brendan 一直在同时参与着从游戏编程到音乐创作的多个技术项目。从那之后快进几年,他继续编写 [pyDance][2],这是一个多舞种游戏的开源实现,然后成为了音乐和游戏项目 [MAGFest][3] 的 CEO。他有时被称为 “MAGFest 先生”,因为他是该项目的负责人,Brendan 现在使用的音乐笔名是 “[Inverse Phase][4]”,是一位电子合音chiptune(主要在 8 位计算机和游戏机上创作的音乐)作曲家。 + +我认为采访并询问他在整个职业生涯中如何从 Linux 和开源软件中受益的一些细节会很有趣。 + +![Inverse Phase 表演照片][5] + +### 你是如何开始接触计算机和软件的? + +Brendan Becker:从我记事起,我家就有一台电脑。我父亲热衷于技术;在康柏便携式电脑刚刚上市时,他就带了一台回家,当他不在上面工作时,我就可以使用它。由于我两岁时就开始阅读,使用电脑就成了我的第二天性——只要阅读磁盘上的内容,按照说明进行操作,我就可以玩游戏了!有时我会玩一些学习和教育软件,我们有几张装满游戏的磁盘,我可以在其他时间玩。我记得有一张磁盘,里面有一些流行游戏的免费副本。后来,我父亲向我展示了我们可以呼叫其他计算机(我 5 岁时就上了 BBS!),我看到了一些游戏来自那儿。我喜欢玩的一款游戏是用 BASIC 编写的,当我意识到我可以简单地修改游戏,只需阅读一些内容并重新输入它们游戏就会更轻松,玩游戏就没意思了。 + +### 这是上世纪 80 年代? + +Becker:康柏便携式电脑于 1983 年推出,这可以给你一些参考。我爸爸有一个那个型号的初代产品。 + +### 你是如何进入 Linux 和开源软件的? + +Becker:在上世纪 90 年代初,我酷爱 MOD 和演示场景demoscene之类的东西,我注意到 Walnut Creek(即 [cdrom.com][6];现已解散)在 FreeBSD 上开设了商店。总的来说,我对 Unix 和其他操作系统非常好奇,但没有太多的第一手资料,我认为是时候尝试一些东西了。当时 DOOM 刚刚发布,有人告诉我,我可以试着在计算机上运行它。在这与能够运行很酷的互联网服务器之间,我开始陷入两难取舍。有人看到我在阅读有关 FreeBSD 的文章,并建议我了解一下 Linux,这是一个为 x86 重新编写的新操作系统,与 BSD 不同,(他们说)后者存在一些兼容性问题。因此,我加入了 undernet IRC 上的 #linuxhelp 频道,询问如何开始使用 Linux,并表明我已经做了一些研究(我已经能问出 “Red Hat 和 Slackware 之间有什么区别?”这样的问题),想知道什么是最容易使用的。频道里唯一说话的人说他已经 13 岁了,他都能弄明白 Slackware,所以我应该不会有问题。学校的一个数学老师给了我一个硬盘,我下载了 “A” 盘组和一个启动盘,写入到软盘,安装了它,回头看也并没有花太多时间。 + +### 你是如何被称为 “MAGFest 先生”的? + +Becker:嗯,这个很简单。在第一个活动后,我几乎立即成为了 MAGFest 的代理负责人。前任主席都各奔东西,我向负责人要求不要取消活动。解决方案就是自己运营它,当我慢慢地将项目塑造成我自己的时,这个昵称就成了我的。 + +### 我记得我在早期参加过,MAGFest 最终变得有多大? + +Becker:第一届 MAGFest 是 265 人。现在它超大,有两万多名不同的参与者。 + +### 太棒了!你能简要描述一下 MAGFest 大会吗? + +Becker:我的一个朋友 Hex 描述得非常好。他说:“就像是和你所有的朋友一起举办这个以电子游戏为主题的生日派对,那里恰好有几千人,如果你愿意,他们都可以成为你的朋友,然后还有摇滚音乐会。” 这很快被采用并缩短为 “这是一个为期四天的电子游戏派对,有多场电子游戏摇滚音乐会”。通常 “音乐和游戏节” 这句话就能让人们明白这个意思。 + +### 你是如何利用开源软件来运行 MAGFest 的? + +Becker:当我成为 MAGFest 的负责人时,我已经用 Python 编写了一个游戏,所以我觉得用 Python 编写我们的注册系统最舒服。这是一个非常轻松的决定,因为不涉及任何费用,而且我已经有了经验。后来,我们的在线注册系统和拼车界面都是用 PHP/MySQL 编写的,我们的论坛使用了 Kboard。最终,这发展到我们用 Python 从头开始编写了自己的注册系统,我们也在活动中使用它,并在主网站上运行 Drupal。有一次,我还用 Python 编写了一个系统来管理视频室和邀请比赛站。哦,我们有一些游戏音乐收听站,你可以翻阅标志性的游戏 OST(原始音轨)的曲目和简介,和演奏 MAGFest 的乐队。 + +### 我知道几年前你减少了你在 MAGFest 的职责,去追求新的项目。你接下来的努力是什么? + +Becker:我一直非常投入游戏音乐领域,并试图将尽可能多的音乐带到 MAGFest 中。随着我越来越多地成为这些社区的一部分,我想参与其中。我使用以前用过的自由开源版本的 DOS 和 Windows 演示场景工具编写了一些视频游戏曲调的混合曲、封面和编曲,我以前使用过的这种工具也是免费的,但不一定是开源的。我在运行 MAGFest 的最初几年发布了一些曲目,然后在 Jake Kaufman(也被称为 `virt`;在他的简历之外也叫 Shovel Knight 和 Shantae)的一些严厉的关爱和建议之后,我改变主题到我更擅长的电子和音。尽管我小时候就用我的康柏便携式电脑编写了 PC 扬声器发出的哔哔啵啵声,并在 90 年代的演示场景中写过 MOD 文件,但我在 2006 年发布了第一首 NES 规格的曲目,我真的能很自豪地称之为我自己的作品。随后还有几张流行音乐的作品和专辑。 + +2010 年,有很多人找我做游戏配乐工作。尽管配乐工作对它没有太大影响,但我开始更认真地缩减我在 MAGFest 的一些职责,并且在 2011 年,我决定更多地进入幕后。我会留在董事会担任顾问,帮助人们了解他们需要什么来管理他们的部门,但我不再掌舵了。与此同时,我的兼职工作,即给我支付账单的工作,解雇了他们所有的工人,我突然发现自己有了很多空闲时间。我开始写《 Pretty Eight Machine》,这是一首向《Nine Inch Nails》致敬的作品,我在这个事情和游戏配乐工作之间花了一年多,我向自己证明了我可以用音乐来(即便只是勉强)维持生计,这就是我接下来想做的。 + +![Inverse Phase CTM Tracker][7] + +*版权所有 Inverse Phase,经许可使用。* + +### 就硬件和软件而言,你的工作空间是什么样的? + +Becker:在我的 DOS/Windows 时代,我主要使用 FastTracker 2。在 Linux 中,我将其替换为 SoundTracker(不是 Karsten Obarski 的原始版本,而是 GTK 重写版本;参见 [soundtracker.org][8])。近来,SoundTracker 处于不断变化的状态——虽然我仍然需要尝试新的 GTK3 版本——但是当我无法使用 SoundTracker 时,[MilkyTracker][9] 是一个很好的替代品。如果我真的需要原版 FastTracker 2,虽然老旧但它也可以在 DOSBox 中运行起来。然而,那是我开始使用 Linux 的时候,所以这是我在 20-25 年前发现的东西。 + +在过去的十年里,我已经从基于采样的音乐转向了电子和音,这是由来自 8 位和 16 位游戏系统和计算机的旧声音芯片合成的音乐。有一个非常好的跨平台工具叫 [Deflemask][10],可以为许多这些系统编写音乐。不过,我想为其创作音乐的一些系统不受支持,而且 Deflemask 是闭源的,因此我已经开始使用 Python 和 [Pygame][11] 从头开始构建自己的音乐创作环境。我使用 Git 维护我的代码树,并将使用开源的 [KiCad][12] 控制硬件合成器板。 + +### 你目前专注于哪些项目? + +Becker:我断断续续地从事于游戏配乐和音乐委托工作。在此期间,我还一直致力于创办一个名为 [Bloop][13] 的电子娱乐博物馆。我们在档案和库存方面做了很多很酷的事情,但也许最令人兴奋的是我们一直在用树莓派构建展览。它们的用途非常广泛,而且我觉得很奇怪,如果我在十年前尝试这样做,我就不会有可以驱动我的展品的小型单板计算机;我可能会用把一个平板固定在笔记本电脑的背面! + +### 现在有更多游戏平台进入 Linux,例如 Steam、Lutris 和 Play-on-Linux。你认为这种趋势会持续下去吗?这些会一直存在吗? + +Becker:作为一个在 Linux 上玩了 25 年游戏的人——事实上,我 _是因为_ 游戏才接触 Linux 的——我想我认为这个问题比大多数人认为的更艰难。我已经玩了 Linux 原生游戏几十年了,我甚至不得不对收回我当年说的“要么存在 Linux 解决方案,要么编写出来”这样的话,但最终,我做到了,我编写了一个 Linux 游戏。 + +说实话:Android 问世于 2008 年。如果你在 Android 上玩过游戏,那么你就在 Linux 上玩过游戏。Steam 在 Linux 已经八年了。Steambox/SteamOS 发布在 Steam 发布一年后。我没有听到太多 Lutris 或 Play-on-Linux 的消息,但我知道它们并希望它们成功。我确实看到 GOG 的追随者非常多,我认为这非常好。我看到很多来自 Ryan Gordon(icculus)和 Ethan Lee(flibitijibibo)等人的高质量游戏移植,甚至有些公司在内部移植。Unity 和 Unreal 等游戏引擎已经支持 Linux。Valve 已经将 Proton 纳入 Linux 版本的 Steam 已有两年左右的时间了,所以现在 Linux 用户甚至不必搜索他们游戏的 Linux 原生版本。 + +我可以说,我认为大多数游戏玩家期待并将继续期待他们已经从零售游戏市场获得的支持水平。就我个人而言,我希望这个水平是增长而不是下降! + +_详细了解 Brendan 的 [Inverse Phase][14] 工作。_ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/linux-open-source-music + +作者:[Alan Formy-Duval][a] +选题:[lujun9972][b] +译者:[stevenzdg988](https://github.com/stevenzdg988) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alanfdoss +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_other21x_cc.png?itok=JJJ5z6aB (Wires plugged into a network switch) +[2]: http://icculus.org/pyddr/ +[3]: http://magfest.org/ +[4]: http://www.inversephase.com/ +[5]: https://opensource.com/sites/default/files/uploads/inverse_phase_performance_bw.png (Inverse Phase performance photo) +[6]: https://en.wikipedia.org/wiki/Walnut_Creek_CDROM +[7]: https://opensource.com/sites/default/files/uploads/inversephase_ctm_tracker_screenshot.png (Inverse Phase CTM Tracker) +[8]: http://soundtracker.org +[9]: http://www.milkytracker.org +[10]: http://www.deflemask.com +[11]: http://www.pygame.org +[12]: http://www.kicad-pcb.org +[13]: http://bloopmuseum.com +[14]: https://www.inversephase.com diff --git a/published/202107/20200428 Learn Bash with this book of puzzles.md b/published/202107/20200428 Learn Bash with this book of puzzles.md new file mode 100644 index 0000000000..532a58dc4a --- /dev/null +++ b/published/202107/20200428 Learn Bash with this book of puzzles.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: (baddate) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13544-1.html) +[#]: subject: (Learn Bash with this book of puzzles) +[#]: via: (https://opensource.com/article/20/4/bash-it-out-book) +[#]: author: (Carlos Aguayo https://opensource.com/users/hwmaster1) + +《Bash it out》书评:用这本谜题书学习 Bash +====== + +> 《Bash it out》使用 16 个谜题,涵盖了基本、中级和高级 Bash 脚本。 + +![](https://img.linux.net.cn/data/attachment/album/202107/03/154134jgm2m82o76mrm2o7.jpg) + +计算机既是我的爱好,也是我的职业。我的公寓里散布着大约 10 台计算机,它们都运行 Linux(包括我的 Mac)。由于我喜欢升级我的电脑和提升我的电脑技能,当我遇到 Sylvain Leroux 的《[Bash it out][2]》时,我抓住了购买它的机会。我在 Debian Linux 上经常使用命令行,这似乎是扩展我的 Bash 知识的好机会。当作者在前言中解释他使用 Debian Linux 时,我笑了,这是我最喜欢的两个发行版之一。 + +Bash 可让你自动执行任务,因此它是一种省力、有趣且有用的工具。在阅读本书之前,我已经有相当多的 Unix 和 Linux 上的 Bash 经验。我不是专家,部分原因是脚本语言非常广泛和强大。当我在基于 Arch 的 Linux 发行版 [EndeavourOS][3] 的欢迎屏幕上看到 Bash 时,我第一次对 Bash 产生了兴趣。 + +以下屏幕截图显示了 EndeavourOS 的一些选项。你可能不相信,这些面板只指向 Bash 脚本,每个脚本都完成一些相对复杂的任务。而且因为它都是开源的,所以我可以根据需要修改这些脚本中的任何一个。 + +![EndeavourOS after install][4] + +![EndeavourOS install apps][5] + +### 总有东西要学 + +我对这本书的印象非常好。虽然不长,但经过了深思熟虑。作者对 Bash 有非常广泛的了解,并且具有解释如何使用它的不可思议的能力。这本书使用 16 个谜题涵盖了基本、中级和高级 Bash 脚本,他称之为“挑战”。这教会了我将 Bash 脚本视为需要解决的编程难题,这让我玩起来更有趣。 + +Bash 的一个令人兴奋的方面是它与 Linux 系统深度集成。虽然它的部分能力在于它的语法,但它也很强大,因为它可以访问很多系统资源。你可以编写重复性任务或简单但厌倦了手动执行的任务的脚本。不管是大事还是小事,《Bash it out》可以帮助你了解可以做什么以及如何实现它。 + +如果我不提及 David Both 的发布在 Opensource.com 的免费资源《[A sysadmin's guide to Bash scripting_][6]》,这篇书评就不会完整。这个 17 页的 PDF 指南与《Bash it out》不同,但它们共同构成了任何想要了解它的人的成功组合。 + +我不是计算机程序员,但《Bash it out》增加了我进入更高级 Bash 脚本水平的欲望——虽然没有这个打算,但我可能最终无意中成为一名计算机程序员。 + +我喜欢 Linux 的原因之一是因为它的操作系统功能强大且用途广泛。无论我对 Linux 了解多少,总有一些新东西需要学习,这让我更加欣赏 Linux。 + +在竞争激烈且不断变化的就业市场中,我们所有人都应该不断更新我们的技能。这本书帮助我以非常实际的方式学习了 Bash。几乎感觉作者和我在同一个房间里,耐心地指导我学习。 + +作者 Leroux 具有不可思议的能力去吸引读者。这是一份难得的天赋,我认为比他的技术专长更有价值。事实上,我写这篇书评是为了感谢作者预见了我自己的学习需求;虽然我们从未见过面,但我从他的天赋中受益匪浅。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/bash-it-out-book + +作者:[Carlos Aguayo][a] +选题:[lujun9972][b] +译者:[baddates](https://github.com/baddates) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/hwmaster1 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/puzzle_computer_solve_fix_tool.png?itok=U0pH1uwj (Puzzle pieces coming together to form a computer screen) +[2]: https://www.amazon.com/Bash-Out-Strengthen-challenges-difficulties/dp/1521773262/ +[3]: https://endeavouros.com/ +[4]: https://opensource.com/sites/default/files/uploads/endeavouros-welcome.png (EndeavourOS after install) +[5]: https://opensource.com/sites/default/files/uploads/endeavouros-install-apps.png (EndeavourOS install apps) +[6]: https://opensource.com/downloads/bash-scripting-ebook diff --git a/published/202107/20200528 9 open source JavaScript frameworks for front-end web development.md b/published/202107/20200528 9 open source JavaScript frameworks for front-end web development.md new file mode 100644 index 0000000000..8b2dab76c6 --- /dev/null +++ b/published/202107/20200528 9 open source JavaScript frameworks for front-end web development.md @@ -0,0 +1,275 @@ +[#]: collector: (lujun9972) +[#]: translator: (stevending1st) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13594-1.html) +[#]: subject: (9 open source JavaScript frameworks for front-end web development) +[#]: via: (https://opensource.com/article/20/5/open-source-javascript-frameworks) +[#]: author: (Bryant Son https://opensource.com/users/brson) + +用于 Web 前端开发的 9 个 JavaScript 开源框架 +====== + +> 根据 JavaScript 框架的优点和主要特点对许多 JavaScript 框架进行细分。 + +![](https://img.linux.net.cn/data/attachment/album/202107/18/205233kz0sqwdwwvrwp2ss.jpg) + +大约十年前,JavaScript 社区开始见证一场 JavaScript 框架的激战。在本文中,我将介绍其中最著名的一些框架。值得注意的是,这些都是开源的 JavaScript 项目,这意味着你可以在 [开源许可证][2] 下自由地使用它们,甚至为它们的源代码和社区做出贡献。 + +不过,在开始之前,了解一些 JavaScript 开发者谈论框架时常用的术语,将对后续的内容大有裨益。 + +术语 | 释义 +---|--- +[文档对象模型(DOM)][3] | 网站的树形结构表示,每一个节点都是代表网页一部分的对象。万维网联盟(W3C),是万维网的国际标准组织,维护着 DOM 的定义。 +[虚拟 DOM][4] | 用户界面(UI)以“虚拟”或“理想”的方式保存在内存中,并通过 [ReactDOM][5] 等一些库与“真实” DOM 同步。要进一步探索,请阅读 ReactJS 的虚拟 DOM 和内部文档。 +[数据绑定][6] | 一个编程概念,为访问网站上的数据提供一致的接口。Web 元素与 DOM 维护的元素的属性property特性attribute 相关联(LCTT 译注:根据 MDN 的解释,Javascript 的属性property是对象的特征,通常描述与数据结构相关的特征;特性attribute 是指元素所有属性节点的一个实时集合)。例如,当需要在网页表单中填写密码时,数据绑定机制可以用密码验证逻辑检验,确保密码格式有效。 + +我们已经清楚了常用的术语,下面我们来探索一下开源的 JavaScript 框架有哪些。 + +框架 | 简介 | 许可证 | 发布日期 +---|---|---|--- +[ReactJS][7] | 目前最流行的 JavaScript 框架,由 Facebook 创建 | MIT 许可证 | 2013-5-24 +[Angular][8] | Google 创建的流行的 JavaScript 框架 | MIT 许可证 | 2010-1-5 +[VueJS][9] | 快速增长的 JavaScript 框架 | MIT 许可证 | 2013-7-28 +[MeteorJS][10] | 超乎于 JavaScript 框架的强大框架 | MIT 许可证 | 2012-1-18 +[KnockoutJS][11] | 开源的 MVVM(模型-视图-视图模型Model-View-ViewModel) 框架 | MIT 许可证 | 2010-7-5 +[EmberJS][12] | 另一个开源的 MVVM 框架 | MIT 许可证 | 2011-12-8 +[BackboneJS][13] | 带有 RESTful JSON 和模型-视图-主持人Model-View-Presenter模式的 JavaScript 框架 | MIT 许可证 | 2010-9-30 +[Svelte][14] | 不使用虚拟 DOM 的 JavaScript 开源框架 | MIT 许可证 | 2016-11-20 +[AureliaJS][15] | 现代 JavaScript 模块的集合 | MIT 许可证 | 2018-2-14 + +为了说明情况,下面是每个框架的 NPM 包下载量的公开数据,感谢 [npm trends][16]。 + +![Framework downloads graph][17] + +### ReactJS + +![React page][18] + +[ReactJS][19] 是由 Facebook 研发的,它虽然在 Angular 之后发布,但明显是当今 JavaScript 框架的领导者。React 引入了一个虚拟 DOM 的概念,这是一个抽象副本,开发者能在框架内仅使用他们想要的 ReactJS 功能,而无需重写整个项目。此外,React 项目活跃的开源社区无疑成为增长背后的主力军。下面是一些 React 的主要优势: + + * 合理的学习曲线 —— React 开发者可以轻松地创建 React 组件,而不需要重写整个 JavaScript 的代码。在 ReactJS 的 [首页][20] 查看它的优点以及它如何使编程更容易。 + * 高度优化的性能 —— React 的虚拟 DOM 的实现和其他功能提升了应用程序的渲染性能。请查看 ReactJS 的关于如何对其性能进行基准测试,并对应用性能进行衡量的相关 [描述][21]。 + * 优秀的支持工具 —— [Redux][22]、[Thunk][23] 和 [Reselect][24] 是构建良好、可调式代码的最佳工具。 + * 单向数据绑定 —— 模型使用 Reach 流,只从所有者流向子模块,这使得在代码中追踪因果关系更加简单。请在 ReactJS 的 [数据绑定页][25] 阅读更多相关资料。 + +谁在使用 ReactJS?Facebook 自从发明它,就大量使用 React 构建公司首页,据说 [Instagram][26] 完全基于 ReactJS 库。你可能会惊讶地发现,其他知名公司如 [纽约时报][27]、[Netflix][28] 和 [可汗学院][29] 也在他们的技术栈中使用了 ReactJS。 + +更令人惊讶的是 ReactJS 开发者的工作机会,正如在下面 Stackoverflow 所做的研究中看到的,嘿,你可以从事开源项目并获得报酬。这很酷! + +![React jobs page][30] + +*Stackoverflow 的研究显示了对 ReactJS 开发者的巨大需求——[来源:2017 年开发者招聘趋势——Stackoverflow 博客][31]* + +[ReactJS 的 GitHub][7] 目前显示超过 13,000 次提交和 1,377 位贡献者。它是一个在 MIT 许可证下的开源项目。 + +![React GitHub page][32] + +### Angular + +![Angular homepage][33] + +就开发者数量来说,也许 React 是现在最领先的 JavaScript 框架,但是 [Angular][34] 紧随其后。事实上,开源开发者和初创公司更乐于选择 React,而较大的公司往往更喜欢 Angular(下面列出了一些例子)。主要原因是,虽然 Angular 可能更复杂,但它的统一性和一致性适用于大型项目。例如,在我整个职业生涯中一直研究 Angular 和 React,我观察到大公司通常认为 Angular 严格的结构是一种优势。下面是 Angular 的另外一些关键优势: + + * 精心设计的命令行工具 —— Angular 有一个优秀的命令行工具(CLI),可以轻松起步和使用 Angular 进行开发。ReactJS 提供命令行工具和其他工具,同时 Angular 有广泛的支持和出色的文档,你可以参见 [这个页面][35]。 + * 单向数据绑定 —— 和 React 类似,单向数据绑定模型使框架受更少的不必要的副作用的影响。 + * 更好的 TypeScript 支持 —— Angular 与 [TypeScript][36] 有很好的一致性,它其实是 JavaScript 强制类型的拓展。它还可以转译为 JavaScript,强制类型是减少错误代码的绝佳选择。 + +像 YouTube、[Netflix][37]、[IBM][38] 和 [Walmart][39] 等知名网站,都已在其应用程序中采用了 Angular。我通过自学使用 Angular 来开始学习前端 JavaScript 开发。我参与了许多涉及 Angular 的个人和专业项目,但那是当时被称为 AngularJS 的 Angular 1.x。当 Google 决定将版本升级到 2.0 时,他们对框架进行了彻底的改造,然后变成了 Angular。新的 Angular 是对之前的 AngularJS 的彻底改造,这一举动带来了一部分新开发者也驱逐了一部分原有的开发者。 + +截止到撰写本文,[Angular 的 GitHub][8] 页面显示 17,781 次提交和 1,133 位贡献者。它也是一个遵循 MIT 许可证的开源项目,因此你可以自由地在你的项目或贡献中使用。 + +![Angular GitHub page][40] + +### VueJS + +![Vue JS page][41] + +[VueJS][42] 是一个非常有趣的框架。它是 JavaScript 框架领域的新来者,但是在过去几年里它的受欢迎程度显著增加。VueJS 由 [尤雨溪][43] 创建,他是曾参与过 Angular 项目的谷歌工程师。该框架现在变得如此受欢迎,以至于许多前端工程师更喜欢 VueJS 而不是其他 JavaScript 框架。下图描述了该框架随着时间的推移获得关注的速度。 + +![Vue JS popularity graph][44] + +这里有一些 VueJS 的主要优点: + + * 更容易地学习曲线 —— 与 Angular 或 React 相比,许多前端开发者都认为 VueJS 有更平滑的学习曲线。 + * 小体积 —— 与 Angular 或 React 相比,VueJS 相对轻巧。在 [官方文档][45] 中,它的大小据说只有约 30 KB;而 Angular 生成的项目超过 65 KB。 + * 简明的文档 —— VueJS 有全面清晰的文档。请自行查看它的 [官方文档][46]。 + +[VueJS 的 GitHub][9] 显示该项目有 3,099 次提交和 239 位贡献者。 + +![Vue JS GitHub page][47] + +### MeteorJS + +![Meteor page][48] + +[MeteorJS][49] 是一个自由开源的 [同构框架][50],这意味着它和 NodeJS 一样,同时运行客户端和服务器的 JavaScript。Meteor 能够和任何其他流行的前端框架一起使用,如 Angular、React、Vue、Svelte 等。 + +Meteor 被高通、马自达和宜家等多家公司以及如 Dispatch 和 Rocket.Chat 等多个应用程序使用。[您可以其在官方网站上查看更多案例][51]。 + +![Meteor case study][52] + +Meteor 的一些主要功能包括: + + * 在线数据 —— 服务器发送数据而不是 HTML,并由客户端渲染。在线数据主要是指 Meteor 在页面加载时通过一个 WebSocket 连接服务器,然后通过该链接传输所需要的数据。 + * 用 JavaScript 开发一切 —— 客户端、应用服务、网页和移动界面都可以用 JavaScript 设计。 + * 支持大多数主流框架 —— Angular、React 和 Vue 都可以与 Meteor 结合。因此,你仍然可以使用最喜欢的框架如 React 或 Angular,这并不防碍 Meteor 为你提供一些优秀的功能。 + +截止到目前,[Meteor 的 GitHub][10] 显示 22,804 次提交和 428 位贡献者。这对于开源项目来说相当多了。 + +![Meteor GitHub page][53] + +### EmberJS + +![EmberJS page][54] + +[EmberJS][55] 是一个基于 [模型-视图-视图模型(MVVM)][56] 模式的开源 JavaScript 框架。如果你从来没有听说过 EmberJS,你肯定会惊讶于有多少公司在使用它。Apple Music、Square、Discourse、Groupon、LinkedIn、Twitch、Nordstorm 和 Chipotle 都将 EmberJS 作为公司的技术栈之一。你可以通过查询 [EmberJS 的官方页面][57] 来发掘所有使用 EmberJS 的应用和客户。 + +Ember 虽然和我们讨论过的其他框架有类似的好处,但这里有些独特的区别: + + * 约定优于配置 —— Ember 将命名约定标准化并自动生成结果代码。这种方法学习曲线有些陡峭,但可以确保程序员遵循最佳实践。 + * 成熟的模板机制 —— Ember 依赖于直接文本操作,直接构建 HTML 文档,而并不关心 DOM。 + +正如所期待的那样,作为一个被许多应用程序使用的框架,[Ember 的 GitHub][58] 页面显示该项目拥有 19,808 次提交和 785 位贡献者。这是一个巨大的数字! + +![EmberJS GitHub page][59] + +### KnockoutJS + +![KnockoutJS page][60] + +[KnockoutJS][61] 是一个独立开源的 JavaScript 框架,采用 [模板-视图-视图模型(MVVM)][56] 模式与模板。尽管与 Angular、React 或 Vue 相比,听说过这个框架的人可能比较少,这个项目在开发者社区仍然相当活跃,并且有以下功能: + + * 声明式绑定 —— Knockout 的声明式绑定系统提供了一种简洁而强大的方式来将数据链接到 UI。绑定简单的数据属性或使用单向绑定很简单。请在 [KnockoutJS 的官方文档页面][62] 阅读更多相关信息。 + * 自动 UI 刷新。 + * 依赖跟踪模板。 + +[Knockout 的 GitHub][11] 页面显示约有 1,766 次提交和 81 位贡献者。与其他框架相比,这些数据并不重要,但是该项目仍然在积极维护中。 + +![Knockout GitHub page][63] + +### BackboneJS + +![BackboneJS page][64] + +[BackboneJS][65] 是一个具有 RESTful JSON 接口,基于模型-视图-主持人Model-View-Presenter(MVP)设计范式的轻量级 JavaScript 框架。 + +这个框架据说已经被 [Airbnb][66]、Hulu、SoundCloud 和 Trello 使用。你可以在 [Backbone 的页面][67] 找到上面所有这些案例来研究。 + +[BackboneJS 的 GitHub][13] 页面显示有 3,386 次提交和 289 位贡献者。 + +![BackboneJS GitHub page][68] + +### Svelte + +![Svelte page][69] + +[Svelte][70] 是一个开源的 JavaScript 框架,它生成操作 DOM 的代码,而不是包含框架引用。在构建时而非运行时将应用程序转换为 JavaScript 的过程,在某些情况下可能会带来轻微的性能提升。 + +[Svelte 的 GitHub][14] 页面显示,截止到本文撰写为止,该项目有 5,729 次提交和 296 位贡献者。 + +![Svelte GitHub page][71] + +### AureliaJS + +![Aurelia page][72] + +最后我们介绍一下 [Aurelia][73]。Aurelia 是一个前端 JavaScript 框架,是一个现代 JavaScript 模块的集合。Aurelia 有以下有趣的功能: + + * 快速渲染 —— Aurelia 宣称比当今其他任何框架的渲染速度都快。 + * 单向数据流 —— Aurelia 使用一个基于观察的绑定系统,将数据从模型推送到视图。 + * 使用原生 JavaScript 架构 —— 可以用原生 JavaScript 构建网站的所有组件。 + +[Aurelia 的 GitHub][15] 页面显示,截止到撰写本文为止该项目有 788 次提交和 96 位贡献者。 + +![Aurelia GitHub page][74] + +这就是我在查看 JavaScript 框架世界时发现的新内容。我错过了其他有趣的框架吗?欢迎在评论区分享你的想法。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/open-source-javascript-frameworks + +作者:[Bryant Son][a] +选题:[lujun9972][b] +译者:[stevending1st](https://github.com/stevending1st) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/brson +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_screen_windows_files.png?itok=kLTeQUbY (Computer screen with files or windows open) +[2]: https://opensource.com/article/17/9/open-source-licensing +[3]: https://www.w3schools.com/js/js_htmldom.asp +[4]: https://reactjs.org/docs/faq-internals.html +[5]: https://reactjs.org/docs/react-dom.html +[6]: https://en.wikipedia.org/wiki/Data_binding +[7]: https://github.com/facebook/react +[8]: https://github.com/angular/angular +[9]: https://github.com/vuejs/vue +[10]: https://github.com/meteor/meteor +[11]: https://github.com/knockout/knockout +[12]: https://github.com/emberjs/ember.js +[13]: https://github.com/jashkenas/backbone +[14]: https://github.com/sveltejs/svelte +[15]: https://github.com/aurelia/framework +[16]: https://www.npmtrends.com/angular-vs-react-vs-vue-vs-meteor-vs-backbone +[17]: https://opensource.com/sites/default/files/uploads/open-source-javascript-framework-downloads-opensourcedotcom_0.png (Framework downloads graph) +[18]: https://opensource.com/sites/default/files/uploads/3_react.jpg (React page) +[19]: https://reactjs.org +[20]: https://reactjs.org/ +[21]: https://reactjs.org/docs/perf.html +[22]: https://redux.js.org/ +[23]: https://github.com/reduxjs/redux-thunk +[24]: https://github.com/reduxjs/reselect +[25]: https://reactjs.org/docs/two-way-binding-helpers.html +[26]: https://instagram-engineering.com/react-native-at-instagram-dd828a9a90c7 +[27]: https://open.nytimes.com/introducing-react-tracking-declarative-tracking-for-react-apps-2c76706bb79a +[28]: https://medium.com/dev-channel/a-netflix-web-performance-case-study-c0bcde26a9d9 +[29]: https://khan.github.io/react-components/ +[30]: https://opensource.com/sites/default/files/uploads/4_reactjobs_0.jpg (React jobs page) +[31]: https://stackoverflow.blog/2017/03/09/developer-hiring-trends-2017 +[32]: https://opensource.com/sites/default/files/uploads/5_reactgithub.jpg (React GitHub page) +[33]: https://opensource.com/sites/default/files/uploads/6_angular.jpg (Angular homepage) +[34]: https://angular.io +[35]: https://cli.angular.io/ +[36]: https://www.typescriptlang.org/ +[37]: https://netflixtechblog.com/netflix-likes-react-509675426db +[38]: https://developer.ibm.com/technologies/javascript/tutorials/wa-react-intro/ +[39]: https://medium.com/walmartlabs/tagged/react +[40]: https://opensource.com/sites/default/files/uploads/7_angulargithub.jpg (Angular GitHub page) +[41]: https://opensource.com/sites/default/files/uploads/8_vuejs.jpg (Vue JS page) +[42]: https://vuejs.org +[43]: https://www.freecodecamp.org/news/between-the-wires-an-interview-with-vue-js-creator-evan-you-e383cbf57cc4/ +[44]: https://opensource.com/sites/default/files/uploads/9_vuejspopularity.jpg (Vue JS popularity graph) +[45]: https://vuejs.org/v2/guide/comparison.html#Size +[46]: https://vuejs.org/v2/guide/ +[47]: https://opensource.com/sites/default/files/uploads/10_vuejsgithub.jpg (Vue JS GitHub page) +[48]: https://opensource.com/sites/default/files/uploads/11_meteor_0.jpg (Meteor Page) +[49]: https://www.meteor.com +[50]: https://en.wikipedia.org/wiki/Isomorphic_JavaScript +[51]: https://www.meteor.com/showcase +[52]: https://opensource.com/sites/default/files/uploads/casestudy1_meteor.jpg (Meteor case study) +[53]: https://opensource.com/sites/default/files/uploads/12_meteorgithub.jpg (Meteor GitHub page) +[54]: https://opensource.com/sites/default/files/uploads/13_emberjs.jpg (EmberJS page) +[55]: https://emberjs.com +[56]: https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel +[57]: https://emberjs.com/ember-users +[58]: https://github.com/emberjs +[59]: https://opensource.com/sites/default/files/uploads/14_embergithub.jpg (EmberJS GitHub page) +[60]: https://opensource.com/sites/default/files/uploads/15_knockoutjs.jpg (KnockoutJS page) +[61]: https://knockoutjs.com +[62]: https://knockoutjs.com/documentation/binding-syntax.html +[63]: https://opensource.com/sites/default/files/uploads/16_knockoutgithub.jpg (Knockout GitHub page) +[64]: https://opensource.com/sites/default/files/uploads/17_backbonejs.jpg (BackboneJS page) +[65]: https://backbonejs.org +[66]: https://medium.com/airbnb-engineering/our-first-node-js-app-backbone-on-the-client-and-server-c659abb0e2b4 +[67]: https://sites.google.com/site/backbonejsja/examples +[68]: https://opensource.com/sites/default/files/uploads/18_backbonejsgithub.jpg (BackboneJS GitHub page) +[69]: https://opensource.com/sites/default/files/uploads/19_svelte.jpg (Svelte page) +[70]: https://svelte.dev +[71]: https://opensource.com/sites/default/files/uploads/20_svletegithub.jpg (Svelte GitHub page) +[72]: https://opensource.com/sites/default/files/uploads/21_aurelia.jpg (Aurelia page) +[73]: https://aurelia.io +[74]: https://opensource.com/sites/default/files/uploads/22_aureliagithub.jpg (Aurelia GitHub page) diff --git a/published/202107/20200807 An advanced guide to NLP analysis with Python and NLTK.md b/published/202107/20200807 An advanced guide to NLP analysis with Python and NLTK.md new file mode 100644 index 0000000000..65fc9c9f76 --- /dev/null +++ b/published/202107/20200807 An advanced guide to NLP analysis with Python and NLTK.md @@ -0,0 +1,517 @@ +[#]: collector: (lujun9972) +[#]: translator: (tanloong) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13602-1.html) +[#]: subject: (An advanced guide to NLP analysis with Python and NLTK) +[#]: via: (https://opensource.com/article/20/8/nlp-python-nltk) +[#]: author: (Girish Managoli https://opensource.com/users/gammay) + +进阶教程:用 Python 和 NLTK 进行 NLP 分析 +====== + +> 进一步学习自然语言处理的基本概念 + +![](https://img.linux.net.cn/data/attachment/album/202107/21/115633k8l9nkqowqkowpwm.jpg) + +在 [之前的文章][2] 里,我介绍了自然语言处理natural language processing(NLP)和宾夕法尼亚大学研发的自然语言处理工具包Natural Language Toolkit ([NLTK][3])。我演示了用 Python 解析文本和定义停顿词stopword的方法,并介绍了语料库corpus的概念。语料库是由文本构成的数据集,通过提供现成的文本数据来辅助文本处理。在这篇文章里,我将继续用各种语料库对文本进行对比和分析。 + +这篇文章主要包括以下部分: + + * 词网WordNet同义词集synset + * 相似度比较Similarity comparison + * Tree树库treebank + * 命名实体识别Named entity recognition + +### 词网和同义词集 + +[词网][4]WordNet 是 NLTK 里的一个大型词汇数据库语料库。词网包含各单词的诸多认知同义词cognitive synonyms(认知同义词常被称作“同义词集synset”)。在词网里,名词、动词、形容词和副词,各自被组织成一个同义词的网络。 + +词网是一个很有用的文本分析工具。它有面向多种语言的版本(汉语、英语、日语、俄语和西班牙语等),也使用多种许可证(从开源许可证到商业许可证都有)。初代版本的词网由普林斯顿大学研发,面向英语,使用类 MIT 许可证MIT-like license。 + +因为一个词可能有多个意义或多个词性,所以可能与多个同义词集相关联。每个同义词集通常提供下列属性: + +|**属性** | **定义** | **例子**| +|---|---|---| +|名称Name| 此同义词集的名称 | 单词 `code` 有 5 个同义词集,名称分别是 `code.n.01`、 `code.n.02`、 `code.n.03`、`code.v.01` 和 `code.v.02`| +|词性POS| 此同义词集的词性 | 单词 `code` 有 3 个名词词性的同义词集和 2 个动词词性的同义词集| +|定义Definition| 该词作对应词性时的定义 | 动词 `code` 的一个定义是:(计算机科学)数据或计算机程序指令的象征性排列symbolic arrangement| +|例子Example| 使用该词的例子 | `code` 一词的例子:We should encode the message for security reasons| +|词元Lemma| 与该词相关联的其他同义词集(包括那些不一定严格地是该词的同义词,但可以大体看作同义词的);词元直接与其他词元相关联,而不是直接与单词word相关联|`code.v.02` 的词元是 `code.v.02.encipher`、`code.v.02.cipher`、`code.v.02.cypher`、`code.v.02.encrypt`、`code.v.02.inscribe` 和 `code.v.02.write_in_code`| +|反义词Antonym| 意思相反的词 | 词元 `encode.v.01.encode` 的反义词是 `decode.v.01.decode`| +|上义词Hypernym|该词所属的一个范畴更大的词 | `code.v.01` 的一个上义词是 `tag.v.01`| +|分项词Meronym| 属于该词组成部分的词 | `computer` 的一个分项词是 `chip` | +|总项词Holonym| 该词作为组成部分所属的词 | `window` 的一个总项词是 `computer screen`| + +同义词集还有一些其他属性,在 `<你的 Python 安装路径>/Lib/site-packages` 下的 `nltk/corpus/reader/wordnet.py`,你可以找到它们。 + +下面的代码或许可以帮助理解。 + +这个函数: + +``` +from nltk.corpus import wordnet + +def synset_info(synset): + print("Name", synset.name()) + print("POS:", synset.pos()) + print("Definition:", synset.definition()) + print("Examples:", synset.examples()) + print("Lemmas:", synset.lemmas()) + print("Antonyms:", [lemma.antonyms() for lemma in synset.lemmas() if len(lemma.antonyms()) > 0]) + print("Hypernyms:", synset.hypernyms()) + print("Instance Hypernyms:", synset.instance_hypernyms()) + print("Part Holonyms:", synset.part_holonyms()) + print("Part Meronyms:", synset.part_meronyms()) + print() + + +synsets = wordnet.synsets('code') +print(len(synsets), "synsets:") +for synset in synsets: + synset_info(synset) +``` + +将会显示: + +``` +5 synsets: +Name code.n.01 +POS: n +Definition: a set of rules or principles or laws (especially written ones) +Examples: [] +Lemmas: [Lemma('code.n.01.code'), Lemma('code.n.01.codification')] +Antonyms: [] +Hypernyms: [Synset('written_communication.n.01')] +Instance Hpernyms: [] +Part Holonyms: [] +Part Meronyms: [] + +... + +Name code.n.03 +POS: n +Definition: (computer science) the symbolic arrangement of data or instructions in a computer program or the set of such instructions +Examples: [] +Lemmas: [Lemma('code.n.03.code'), Lemma('code.n.03.computer_code')] +Antonyms: [] +Hypernyms: [Synset('coding_system.n.01')] +Instance Hpernyms: [] +Part Holonyms: [] +Part Meronyms: [] + +... + +Name code.v.02 +POS: v +Definition: convert ordinary language into code +Examples: ['We should encode the message for security reasons'] +Lemmas: [Lemma('code.v.02.code'), Lemma('code.v.02.encipher'), Lemma('code.v.02.cipher'), Lemma('code.v.02.cypher'), Lemma('code.v.02.encrypt'), Lemma('code.v.02.inscribe'), Lemma('code.v.02.write_in_code')] +Antonyms: [] +Hypernyms: [Synset('encode.v.01')] +Instance Hpernyms: [] +Part Holonyms: [] +Part Meronyms: [] +``` + +同义词集synset词元lemma在词网里是按照树状结构组织起来的,下面的代码会给出直观的展现: + +``` +def hypernyms(synset): +    return synset.hypernyms() + +synsets = wordnet.synsets('soccer') +for synset in synsets: +    print(synset.name() + " tree:") +    pprint(synset.tree(rel=hypernyms)) +    print() +``` + +``` +code.n.01 tree: +[Synset('code.n.01'), + [Synset('written_communication.n.01'), +   ... + +code.n.02 tree: +[Synset('code.n.02'), + [Synset('coding_system.n.01'), +   ... + +code.n.03 tree: +[Synset('code.n.03'), +   ... + +code.v.01 tree: +[Synset('code.v.01'), + [Synset('tag.v.01'), +   ... + +code.v.02 tree: +[Synset('code.v.02'), + [Synset('encode.v.01'), +   ... +``` + +词网并没有涵盖所有的单词和其信息(现今英语有约 17,0000 个单词,最新版的 词网 涵盖了约 15,5000 个),但它开了个好头。掌握了“词网”的各个概念后,如果你觉得它词汇少,不能满足你的需要,可以转而使用其他工具。或者,你也可以打造自己的“词网”! + +#### 自主尝试 + +使用 Python 库,下载维基百科的 “[open source][5]” 页面,并列出该页面所有单词的同义词集synset词元lemma。 + +### 相似度比较 + +相似度比较的目的是识别出两篇文本的相似度,在搜索引擎、聊天机器人等方面有很多应用。 + +比如,相似度比较可以识别 `football` 和 `soccer` 是否有相似性。 + +``` +syn1 = wordnet.synsets('football') +syn2 = wordnet.synsets('soccer') + +# 一个单词可能有多个 同义词集,需要把 word1 的每个同义词集和 word2 的每个同义词集分别比较 +for s1 in syn1: +    for s2 in syn2: +        print("Path similarity of: ") +        print(s1, '(', s1.pos(), ')', '[', s1.definition(), ']') +        print(s2, '(', s2.pos(), ')', '[', s2.definition(), ']') +        print("   is", s1.path_similarity(s2)) +        print() +``` + +``` +Path similarity of: +Synset('football.n.01') ( n ) [ any of various games played with a ball (round or oval) in which two teams try to kick or carry or propel the ball into each other's goal ] +Synset('soccer.n.01') ( n ) [ a football game in which two teams of 11 players try to kick or head a ball into the opponents' goal ] +   is 0.5 + +Path similarity of: +Synset('football.n.02') ( n ) [ the inflated oblong ball used in playing American football ] +Synset('soccer.n.01') ( n ) [ a football game in which two teams of 11 players try to kick or head a ball into the opponents' goal ] +   is 0.05 +``` + +两个词各个同义词集之间路径相似度path similarity最大的是 0.5,表明它们关联性很大([路径相似度path similarity][6]指两个词的意义在上下义关系的词汇分类结构hypernym/hypnoym taxonomy中的最短距离)。 + +那么 `code` 和 `bug` 呢?这两个计算机领域的词的相似度是: + +``` +Path similarity of: +Synset('code.n.01') ( n ) [ a set of rules or principles or laws (especially written ones) ] +Synset('bug.n.02') ( n ) [ a fault or defect in a computer program, system, or machine ] +   is 0.1111111111111111 +... +Path similarity of: +Synset('code.n.02') ( n ) [ a coding system used for transmitting messages requiring brevity or secrecy ] +Synset('bug.n.02') ( n ) [ a fault or defect in a computer program, system, or machine ] +   is 0.09090909090909091 +... +Path similarity of: +Synset('code.n.03') ( n ) [ (computer science) the symbolic arrangement of data or instructions in a computer program or the set of such instructions ] +Synset('bug.n.02') ( n ) [ a fault or defect in a computer program, system, or machine ] +   is 0.09090909090909091 +``` + +这些是这两个词各同义词集之间路径相似度path similarity的最大值,这些值表明两个词是有关联性的。 + +NLTK 提供多种相似度计分器similarity scorers,比如: + + * path_similarity + * lch_similarity + * wup_similarity + * res_similarity + * jcn_similarity + * lin_similarity + +要进一步了解这些相似度计分器similarity scorers,请查看 [WordNet Interface][6] 的 Similarity 部分。 + +#### 自主尝试 + +使用 Python 库,从维基百科的 [Category: Lists of computer terms][7] 生成一个术语列表,然后计算各术语之间的相似度。 + +### 树和树库 + +使用 NLTK,你可以把文本表示成树状结构以便进行分析。 + +这里有一个例子: + +这是一份简短的文本,对其做预处理和词性标注: + +``` +import nltk + +text = "I love open source" +# Tokenize to words +words = nltk.tokenize.word_tokenize(text) +# POS tag the words +words_tagged = nltk.pos_tag(words) +``` + +要把文本转换成树状结构,你必须定义一个语法grammar。这个例子里用的是一个基于 [Penn Treebank tags][8] 的简单语法。 + +``` +# A simple grammar to create tree +grammar = "NP: {<JJ><NN>}" +``` + +然后用这个语法grammar创建一颗tree: + +``` +# Create tree +parser = nltk.RegexpParser(grammar) +tree = parser.parse(words_tagged) +pprint(tree) +``` + +运行上面的代码,将得到: + +``` +Tree('S', [('I', 'PRP'), ('love', 'VBP'), Tree('NP', [('open', 'JJ'), ('source', 'NN')])]) +``` + +你也可以图形化地显示结果。 + +``` +tree.draw() +``` + +![NLTK Tree][9] + +这个树状结构有助于准确解读文本的意思。比如,用它可以找到文本的 [主语][11]: + +``` +subject_tags = ["NN", "NNS", "NP", "NNP", "NNPS", "PRP", "PRP$"] +def subject(sentence_tree): +    for tagged_word in sentence_tree: +        # A crude logic for this case -  first word with these tags is considered subject +        if tagged_word[1] in subject_tags: +            return tagged_word[0] + +print("Subject:", subject(tree)) +``` + +结果显示主语是 `I`: + +``` +Subject: I +``` + +这是一个比较基础的文本分析步骤,可以用到更广泛的应用场景中。 比如,在聊天机器人方面,如果用户告诉机器人:“给我妈妈 Jane 预订一张机票,1 月 1 号伦敦飞纽约的”,机器人可以用这种分析方法解读这个指令: + +**动作**: 预订 +**动作的对象**: 机票 +**乘客**: Jane +**出发地**: 伦敦 +**目的地**: 纽约 +**日期**: (明年)1 月 1 号 + +树库treebank指由许多预先标注好的tree构成的语料库。现在已经有面向多种语言的树库,既有开源的,也有限定条件下才能免费使用的,以及商用的。其中使用最广泛的是面向英语的宾州树库。宾州树库取材于华尔街日报Wall Street Journal。NLTK 也包含了宾州树库作为一个子语料库。下面是一些使用树库treebank的方法: + +``` +words = nltk.corpus.treebank.words() +print(len(words), "words:") +print(words) + +tagged_sents = nltk.corpus.treebank.tagged_sents() +print(len(tagged_sents), "sentences:") +print(tagged_sents) + +``` + +``` +100676 words: +['Pierre', 'Vinken', ',', '61', 'years', 'old', ',', ...] +3914 sentences: +[[('Pierre', 'NNP'), ('Vinken', 'NNP'), (',', ','), ('61', 'CD'), ('years', 'NNS'), ('old', 'JJ'), (',', ','), ('will', 'MD'), ('join', 'VB'), ('the', 'DT'), ('board', 'NN'), ('as', 'IN'), ('a', 'DT'), ('nonexecutive', 'JJ'), ('director', 'NN'), ...] +``` + +查看一个句子里的各个标签tags: + +``` +sent0 = tagged_sents[0] +pprint(sent0) +``` + +``` +[('Pierre', 'NNP'), + ('Vinken', 'NNP'), + (',', ','), + ('61', 'CD'), + ('years', 'NNS'), +... +``` + +定义一个语法grammar来把这个句子转换成树状结构: + +``` +grammar = ''' + Subject: {} + SubjectInfo: {} + Action: {} + Object: {
} + Stopwords: {
} + ObjectInfo: {} + When: {} +''' +parser = nltk.RegexpParser(grammar) +tree = parser.parse(sent0) +print(tree) +``` + +``` +(S +  (Subject Pierre/NNP Vinken/NNP) +  ,/, +  (SubjectInfo 61/CD years/NNS old/JJ) +  ,/, +  (Action will/MD join/VB) +  (Object the/DT board/NN) +  as/IN +  a/DT +  (ObjectInfo nonexecutive/JJ director/NN) +  (Subject Nov./NNP) +  29/CD +  ./.) +``` + +图形化地显示: + +``` +tree.draw() +``` + +![NLP Treebank image][12] + +trees树库treebanks的概念是文本分析的一个强大的组成部分。 + +#### 自主尝试 + +使用 Python 库,下载维基百科的 “[open source][5]” 页面,将得到的文本以图形化的树状结构展现出来。 + +### 命名实体识别 + +无论口语还是书面语都包含着重要数据。文本处理的主要目标之一,就是提取出关键数据。几乎所有应用场景所需要提取关键数据,比如航空公司的订票机器人或者问答机器人。 NLTK 为此提供了一个命名实体识别named entity recognition的功能。 + +这里有一个代码示例: + +``` +sentence = 'Peterson first suggested the name "open source" at Palo Alto, California' +``` + +验证这个句子里的人名name地名place有没有被识别出来。照例先预处理: + +``` +import nltk + +words = nltk.word_tokenize(sentence) +pos_tagged = nltk.pos_tag(words) +``` + +运行命名实体标注器named-entity tagger: + +``` +ne_tagged = nltk.ne_chunk(pos_tagged) +print("NE tagged text:") +print(ne_tagged) +print() +``` + +``` +NE tagged text: +(S +  (PERSON Peterson/NNP) +  first/RB +  suggested/VBD +  the/DT +  name/NN +  ``/`` +  open/JJ +  source/NN +  ''/'' +  at/IN +  (FACILITY Palo/NNP Alto/NNP) +  ,/, +  (GPE California/NNP)) +``` + +上面的结果里,命名实体被识别出来并做了标注;只提取这个tree里的命名实体: + +``` +print("Recognized named entities:") +for ne in ne_tagged: +    if hasattr(ne, "label"): +        print(ne.label(), ne[0:]) +``` + +``` +Recognized named entities: +PERSON [('Peterson', 'NNP')] +FACILITY [('Palo', 'NNP'), ('Alto', 'NNP')] +GPE [('California', 'NNP')] +``` + +图形化地显示: + +``` +ne_tagged.draw() +``` + +![NLTK Treebank tree][13] + +NLTK 内置的命名实体标注器named-entity tagger,使用的是宾州法尼亚大学的 [Automatic Content Extraction][14](ACE)程序。该标注器能够识别组织机构ORGANIZATION、人名PERSON、地名LOCATION、设施FACILITY地缘政治实体geopolitical entity等常见实体entites。 + +NLTK 也可以使用其他标注器tagger,比如 [Stanford Named Entity Recognizer][15]. 这个经过训练的标注器用 Java 写成,但 NLTK 提供了一个使用它的接口(详情请查看 [nltk.parse.stanford][16] 或 [nltk.tag.stanford][17])。 + +#### 自主尝试 + +使用 Python 库,下载维基百科的 “[open source][5]” 页面,并识别出对开源open source有影响力的人的名字,以及他们为开源open source做贡献的时间和地点。 + +### 高级实践 + +如果你准备好了,尝试用这篇文章以及此前的文章介绍的知识构建一个超级结构superstructure。 + +使用 Python 库,下载维基百科的 “[Category: Computer science page][18]”,然后: + + * 找出其中频率最高的单词unigrams、二元搭配bigrams三元搭配trigrams,将它们作为一个关键词列表或者技术列表。相关领域的学生或者工程师需要了解这样一份列表里的内容。 + * 图形化地显示这个领域里重要的人名、技术、日期和地点。这会是一份很棒的信息图。 + * 构建一个搜索引擎。你的搜索引擎性能能够超过维基百科吗? + +### 下一步? + +自然语言处理是应用构建application building的典型支柱。NLTK 是经典、丰富且强大的工具集,提供了为现实世界构建有吸引力、目标明确的应用的工作坊。 + +在这个系列的文章里,我用 NLTK 作为例子,展示了自然语言处理可以做什么。自然语言处理和 NLTK 还有太多东西值得探索,这个系列的文章只是帮助你探索它们的切入点。 + +如果你的需求增长到 NLTK 已经满足不了了,你可以训练新的模型或者向 NLTK 添加新的功能。基于 NLTK 构建的新的自然语言处理库正在不断涌现,机器学习也正被深度用于自然语言处理。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/8/nlp-python-nltk + +作者:[Girish Managoli][a] +选题:[lujun9972][b] +译者:[tanloong](https://github.com/tanloong) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/gammay +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brain_computer_solve_fix_tool.png?itok=okq8joti (Brain on a computer screen) +[2]: https://opensource.com/article/20/8/intro-python-nltk +[3]: http://www.nltk.org/ +[4]: https://en.wikipedia.org/wiki/WordNet +[5]: https://en.wikipedia.org/wiki/Open_source +[6]: https://www.nltk.org/howto/wordnet.html +[7]: https://en.wikipedia.org/wiki/Category:Lists_of_computer_terms +[8]: https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html +[9]: https://opensource.com/sites/default/files/uploads/nltk-tree.jpg (NLTK Tree) +[10]: https://creativecommons.org/licenses/by-sa/4.0/ +[11]: https://en.wikipedia.org/wiki/Subject_(grammar) +[12]: https://opensource.com/sites/default/files/uploads/nltk-treebank.jpg (NLP Treebank image) +[13]: https://opensource.com/sites/default/files/uploads/nltk-treebank-2a.jpg (NLTK Treebank tree) +[14]: https://www.ldc.upenn.edu/collaborations/past-projects/ace +[15]: https://nlp.stanford.edu/software/CRF-NER.html +[16]: https://www.nltk.org/_modules/nltk/parse/stanford.html +[17]: https://www.nltk.org/_modules/nltk/tag/stanford.html +[18]: https://en.wikipedia.org/wiki/Category:Computer_science diff --git a/published/202107/20200914 Use Python to solve a charity-s business problem.md b/published/202107/20200914 Use Python to solve a charity-s business problem.md new file mode 100644 index 0000000000..b2a6f4379c --- /dev/null +++ b/published/202107/20200914 Use Python to solve a charity-s business problem.md @@ -0,0 +1,190 @@ +[#]: collector: "lujun9972" +[#]: translator: "zepoch" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13542-1.html" +[#]: subject: "Use Python to solve a charity's business problem" +[#]: via: "https://opensource.com/article/20/9/solve-problem-python" +[#]: author: "Chris Hermansen https://opensource.com/users/clhermansen" + +使用 Python 来解决慈善机构的业务问题 +====== + +> 比较不同的编程语言如何解决同一个问题是一个很有趣的事情,也很有指导意义。接下来,我们就来讲一讲如何用 Python 来解决。 + +![](https://img.linux.net.cn/data/attachment/album/202107/02/124241fzuzo7kflrf7g77v.jpg) + +在我这一系列的 [第一篇文章][2] 里,我描述了这样子的一个问题,如何将一大批的救助物资分为具有相同价值的物品,并将其分发给社区中的困难住户。我也曾写过用不同的编程语言写一些小程序来解决这样子的小问题以及比较这些程序时如何工作的。 + +在第一篇文章中,我是使用了 [Groovy][3] 语言来解决问题的。Groovy 在很多方面都与 [Python][4] 很相似,但是在语法上她更像 C 语言和 Java。因此,使用 Python 来创造一个相同的解决方案应该会很有趣且更有意义。 + +### 使用 Python 的解决方案 + +使用 Java 时,我会声明一个工具类来保存元组数据(新的记录功能将会很好地用于这个需求)。使用 Groovy 时,我就是用了该语言的映射功能,我也将在 Python 使用相同的机制。 + +使用一个字典列表来保存从批发商处批发来的货物: + +``` +packs = [ + {'item':'Rice','brand':'Best Family','units':10,'price':5650,'quantity':1}, + {'item':'Spaghetti','brand':'Best Family','units':1,'price':327,'quantity':10}, + {'item':'Sardines','brand':'Fresh Caught','units':3,'price':2727,'quantity':3}, + {'item':'Chickpeas','brand':'Southern Style','units':2,'price':2600,'quantity':5}, + {'item':'Lentils','brand':'Southern Style','units':2,'price':2378,'quantity':5}, + {'item':'Vegetable oil','brand':'Crafco','units':12,'price':10020,'quantity':1}, + {'item':'UHT milk','brand':'Atlantic','units':6,'price':4560,'quantity':2}, + {'item':'Flour','brand':'Neighbor Mills','units':10,'price':5200,'quantity':1}, + {'item':'Tomato sauce','brand':'Best Family','units':1,'price':190,'quantity':10}, + {'item':'Sugar','brand':'Good Price','units':1,'price':565,'quantity':10}, + {'item':'Tea','brand':'Superior','units':5,'price':2720,'quantity':2}, + {'item':'Coffee','brand':'Colombia Select','units':2,'price':4180,'quantity':5}, + {'item':'Tofu','brand':'Gourmet Choice','units':1,'price':1580,'quantity':10}, + {'item':'Bleach','brand':'Blanchite','units':5,'price':3550,'quantity':2}, + {'item':'Soap','brand':'Sunny Day','units':6,'price':1794,'quantity':2}] +``` + +大米有一包,每包中有 10 袋大米,意大利面条有十包,每包中有一袋意大利面条。上述代码中,变量 `packs` 被设置为 Python 字典列表。这与 Groovy 的方法非常相似。关于 Groovy 和 Python 之间的区别,有几点需要注意: + + 1. 在 Python 中,无需关键字来定义变量 `packs`,Python 变量初始化时需要设置一个值。 + 2. Python 字典中的词键(例如,`item`、`brand`、`units`、`price`、 `quantity`)需要引号来表明它们是字符串;Groovy 假定这些是字符串,但也接受引号。 + 3. 在 Python 中,符号 `{ ... }` 表明一个字典声明; Groovy 使用与列表相同的方括号,但两种情况下的结构都必须具有键值对。 + +当然,表中的价格不是以美元计算的。 + +接下来,打开散装包。例如,打开大米的单个散装包装,将产出 10 单元大米; 也就是说,产出的单元总数是 `units * quantity`。 Groovy 脚本使用一个名为 `collectMany` 的方便的函数,该函数可用于展平列表列表。 据我所知,Python 没有类似的东西,所以使用两个列表推导式来产生相同的结果: + +``` +units = [[{'item':pack['item'],'brand':pack['brand'], + 'price':(pack['price'] / pack['units'])}] * + (pack['units'] * pack['quantity']) for pack in packs] +units = [x for sublist in units for x in sublist] +``` + +第一个列表可理解为(分配给单元)构建字典列表列表。 第二个将其“扁平化”为字典列表。 请注意,Python 和 Groovy 都提供了一个 `*` 运算符,它接受左侧的列表和右侧的数字 `N`,并复制列表 `N` 次。 + +最后一步是将这些单元的大米之类的重新包装到篮子(`hamper`)中以进行分发。 就像在 Groovy 版本中一样,你需要更具体地了解理想的篮子数,当你只剩下几个单元时,你最好不要过度限制,即可以做一些随机分配: + +``` +valueIdeal = 5000 +valueMax = valueIdeal * 1.1 +``` + +很好! 重新打包篮子。 + +``` +import random +hamperNumber = 0 # 导入 Python 的随机数生成器工具并初始化篮子数 +while len(units) > 0: # 只要有更多可用的单元,这个 `while` 循环就会将单元重新分配到篮子中: + hamperNumber += 1 + hamper = [] + value = 0 + canAdd = True # 增加篮子编号,得到一个新的空篮子(单元的列表),并将其值设为 0; 开始假设你可以向篮子中添加更多物品。 + while canAdd: # 这个 `while` 循环将尽可能多地向篮子添加单元(Groovy 代码使用了 `for` 循环,但 Python 的 `for` 循环期望迭代某些东西,而 Groovy 则是为更传统的 C 形式的 `for` 循环形式): + u = random.randint(0,len(units)-1) # 获取一个介于 0 和剩余单元数减 1 之间的随机数。 + canAdd = False # 假设你找不到更多要添加的单元。 + o = 0 # 创建一个变量,用于从你正在寻找要放入篮子中的物品的起点的偏移量。 + while o < len(units): # 从随机选择的索引开始,这个 `while` 循环将尝试找到一个可以添加到篮子的单元(再次注意,Python `for` 循环可能不适合这里,因为列表的长度将在迭代中中发生变化)。 + uo = (u + o) % len(units) + unit = units[uo] + unitPrice = unit['price'] # 找出要查看的单元(随机起点+偏移量)并获得其价格。 + if len(units) < 3 or not (unit in hamper) and (value + unitPrice) < valueMax: + # 如果只剩下几个,或者添加单元后篮子的价值不太高,你可以将此单元添加到篮子中。 + hamper.append(unit) + value += unitPrice + units.pop(u) # 将单元添加到篮子中,按单价增加 篮子数,从可用单元列表中删除该单元。 + canAdd = len(units) > 0 + break # 只要还有剩余单元,你就可以添加更多单元,因此可以跳出此循环继续寻找。 + o += 1 # 增加偏移量。 + # 在退出这个 `while` 循环时,如果你检查了所有剩余的单元并且找不到单元可以添加到篮子中,那么篮子就完成了搜索; 否则,你找到了一个,可以继续寻找更多。 + print('') + print('Hamper',hamperNumber,'value',value) + for item in hamper: + print('%-25s%-25s%7.2f' % (item['item'],item['brand'],item['price'])) # 打印出篮子的内容。 + print('Remaining units',len(units)) # 打印出剩余的单元信息。 +``` + +一些澄清如上面的注释。 + +运行此代码时,输出看起来与 Groovy 程序的输出非常相似: + +``` +Hamper 1 value 5304.0 +UHT milk Atlantic 760.00 +Tomato sauce Best Family 190.00 +Rice Best Family 565.00 +Coffee Colombia Select 2090.00 +Sugar Good Price 565.00 +Vegetable oil Crafco 835.00 +Soap Sunny Day 299.00 +Remaining units 148 + +Hamper 2 value 5428.0 +Tea Superior 544.00 +Lentils Southern Style 1189.00 +Flour Neighbor Mills 520.00 +Tofu Gourmet Choice 1580.00 +Vegetable oil Crafco 835.00 +UHT milk Atlantic 760.00 +Remaining units 142 + +Hamper 3 value 5424.0 +Soap Sunny Day 299.00 +Chickpeas Southern Style 1300.00 +Sardines Fresh Caught 909.00 +Rice Best Family 565.00 +Vegetable oil Crafco 835.00 +Spaghetti Best Family 327.00 +Lentils Southern Style 1189.00 +Remaining units 135 + +... + +Hamper 21 value 5145.0 +Tomato sauce Best Family 190.00 +Tea Superior 544.00 +Chickpeas Southern Style 1300.00 +Spaghetti Best Family 327.00 +UHT milk Atlantic 760.00 +Vegetable oil Crafco 835.00 +Lentils Southern Style 1189.00 +Remaining units 4 + +Hamper 22 value 2874.0 +Sardines Fresh Caught 909.00 +Vegetable oil Crafco 835.00 +Rice Best Family 565.00 +Rice Best Family 565.00 +Remaining units 0 +``` + +最后一个篮子在内容和价值上有所简化。 + +### 结论 + +乍一看,这个程序的 Python 和 Groovy 版本之间没有太大区别。 两者都有一组相似的结构,这使得处理列表和字典非常简单。 两者都不需要很多“样板代码”或其他“繁杂”操作。 + +此外,使用 Groovy 时,向篮子中添加单元还是一件比较繁琐的事情。 你需要在单元列表中随机选择一个位置,然后从该位置开始,遍历列表,直到找到一个价格允许的且包含它的单元,或者直到你用完列表为止。 当只剩下几件物品时,你需要将它们扔到最后一个篮子里。 + +另一个值得一提的问题是:这不是一种特别有效的方法。 从列表中删除元素、极其多的重复表达式还有一些其它的问题使得这不太适合解决这种大数据重新分配问题。 尽管如此,它仍然在我的老机器上运行。 + +如果你觉得我在这段代码中使用 `while` 循环并改变其中的数据感到不舒服,你可能希望我让它更有用一些。 我想不出一种方法不使用 Python 中的 map 和 reduce 函数,并结合随机选择的单元进行重新打包。 你可以吗? + +在下一篇文章中,我将使用 Java 重新执行此操作,以了解 Groovy 和 Python 的工作量减少了多少,未来的文章将介绍 Julia 和 Go。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/9/solve-problem-python + +作者:[Chris Hermansen][a] +选题:[lujun9972][b] +译者:[zepoch](https://github.com/zepoch) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clhermansen +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python_programming_question.png?itok=cOeJW-8r "Python programming language logo with question marks" +[2]: https://opensource.com/article/20/8/solving-problem-groovy +[3]: https://groovy-lang.org/ +[4]: https://www.python.org/ diff --git a/published/202107/20201012 My top 7 keywords in Rust.md b/published/202107/20201012 My top 7 keywords in Rust.md new file mode 100644 index 0000000000..2f770e9532 --- /dev/null +++ b/published/202107/20201012 My top 7 keywords in Rust.md @@ -0,0 +1,55 @@ +[#]: collector: "lujun9972" +[#]: translator: "mcfd" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13589-1.html" +[#]: subject: "My top 7 keywords in Rust" +[#]: via: "https://opensource.com/article/20/10/keywords-rust" +[#]: author: "Mike Bursell https://opensource.com/users/mikecamel" + +我的 7 大 Rust 关键字 +====== + +> 从 Rust 标准库学习一些有用的关键字。 + +![Rustacean t-shirt][1] + +我使用 [Rust][2] 已经有几个月了,写的东西比我预期的要多——尽管随着我的学习,我改进了所写的代码,并完成了一些超出我最初意图的更复杂的任务,相当多的东西已经被扔掉了。 + +我仍然喜欢它,并认为谈论一些在 Rust 中反复出现的重要关键字可能会有好处。我会提供我个人对它们的作用的总结:为什么你需要考虑如何使用它们,以及任何其他有用的东西,特别是对于刚接触 Rust 的新手或来自另一种语言的人(如 Java;请阅读我的文章 [为什么作为一个 Java 程序员的我喜欢学习 Rust][3])。 + +事不宜迟,让我们开始吧。获取更多信息的好地方总是 Rust 官方文档 —— 你可能想从 [std 标准库][4]开始。 + + 1. `const` – 你可以用 `const` 来声明常量,而且你应该这样做。虽然这不是造火箭,但请一定要用 `const` ,如果你要在不同的模块中使用常量,那请创建一个 `lib.rs` 文件(Rust 默认的),你可以把所有的常量放在一个命名良好的模块中。我曾经在不同模块的不同文件中发生过 `const` 变量名(和值)的冲突,仅仅是因为我太懒了,除了在不同文件中剪切和粘贴之外,我本可以通过创建一个共享模块来节省大量的工作。 + 2. `let` – 你并不 _总是_ 需要用 `let` 语句声明一个变量,但当你这样做时你的代码会更加清晰。此外,如果可以,请一定要添加变量类型。Rust 会尽最大努力猜测它应该是什么类型的变量,但它不一定总能在运行时做到这一点(在这种情况下,编译器 [Cargo][5] 会提示你),它甚至可能做不到你期望的那样。在后一种情况下,对于 Cargo 来说,抱怨你所赋值的函数(例如)与声明不一致,总比 Rust 试图帮助你做错事,而你却不得不在其他地方花费大量时间来进行调试要简单。 + 3. `match` – `match` 对我来说是新鲜事物,我喜欢使用它。它与其他编程语言中的 `switch` 没有什么不同,但在 Rust 中被广泛使用。它使代码更清晰易读,如果你做了一些愚蠢的事情(例如错过一些可能的情况),Cargo 会很好地提示你。我一般的经验法则是,在管理不同的选项或进行分支时,如果可以使用 `match`,那就请一定要使用它。 + 4. `mut` – 在声明一个变量时,如果它的值在声明后会发生变化,那么你需要声明它是可变的(LCTT 译注:Rust 中变量默认是不可变的)。常见的错误是在某个变量 _没有_ 变化的情况下声明它是可变的,这时编译器会警告你。如果你收到了 Cargo 的警告,说一个可变的变量没有被改变,而你认为它被 _改变_ 了,那么你可能要检查该变量的范围,并确保你使用的是正确的那个。 + 5. `return` – 实际上我很少使用 `return`,它用于从函数中返回一个值,但是如果你只是在函数的最后一行提供值(或提供返回值的函数),通常会变得更简单,能更清晰地阅读。警告:在很多情况下,你 _会_ 忘记省略这一行末尾的分号(`;`),如果你这样做,编译器会不高兴的。 + 6. `unsafe` – 如其意:如果你想做一些不能保证 Rust 内存安全的事情,那么你就需要使用这个关键字。我绝对无意在现在或将来的任何时候宣布我的任何 Rust 代码不安全;Rust 如此友好的原因之一是它阻止了这种黑客行为。如果你真的需要这样做,再想想,再想想,然后重新设计代码。除非你是一个非常低级的系统程序员,否则要 _避免_ 使用 `unsafe`。 + 7. `use` – 当你想使用另一个 crate 中的东西时,例如结构体、变量、函数等,那么你需要在你要使用它的代码的代码块的开头声明它。另一个常见的错误是,你这样做了,但没有在 `Cargo.toml` 文件中添加该 crate (最好有一个最小版本号)。 + +我知道,这不是我写过的最复杂的文章,但这是我在开始学习 Rust 时会欣赏的那种文章。我计划在关键函数和其他 Rust 必知知识方面编写类似的文章:如果你有任何要求,请告诉我! + +* * * + +_本文最初发表于 [Alice, Eve, and Bob][6] 经作者许可转载。_ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/10/keywords-rust + +作者:[Mike Bursell][a] +选题:[lujun9972][b] +译者:[mcfd](https://github.com/mcfd) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mikecamel +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rustacean-tshirt.jpg?itok=u7LBmyaj "Rustacean t-shirt" +[2]: https://www.rust-lang.org/ +[3]: https://opensource.com/article/20/5/rust-java +[4]: https://doc.rust-lang.org/std/ +[5]: https://doc.rust-lang.org/cargo/ +[6]: https://aliceevebob.com/2020/09/01/rust-my-top-7-keywords/ diff --git a/published/202107/20201105 6 evening rituals for working in tech.md b/published/202107/20201105 6 evening rituals for working in tech.md new file mode 100644 index 0000000000..76726f4d1e --- /dev/null +++ b/published/202107/20201105 6 evening rituals for working in tech.md @@ -0,0 +1,50 @@ +[#]: collector: "lujun9972" +[#]: translator: "Arzelan" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13610-1.html" +[#]: subject: "6 evening rituals for working in tech" +[#]: via: "https://opensource.com/article/20/11/evening-rituals-working-tech" +[#]: author: "Jen Wike Huger https://opensource.com/users/jen-wike" + +IT 人的 6 个晚上放松方式 +====== + +> 在结束了一天的远程会议、邮件往来、写代码和其他协作工作后,你在晚上如何放松自己呢? + +![](https://img.linux.net.cn/data/attachment/album/202107/24/100720afeq20kf2wfp4qwi.jpg) + +这个奇怪的时代一方面给我们放慢脚步的机会,但另一方面来说,却比以前更忙了,尤其是当你除了照顾自己还要照顾家人的时候。俗话说,空杯子倒不出酒。所以,让我们看看在关上电脑或者完成最后一件工作之后,能为自己做些什么? + +1、走出家门,做几次深呼吸,不要在乎是不是下雪天,让新鲜的空气从肺部充满全身。如果可以的话,在院子里走走,或者去街上逛逛。 + +2、如果有时间的话,给自己沏杯茶,红茶含有咖啡因,最好不要晚上喝,可以喝绿茶或者花果茶,然后在你穿上鞋(或许还有外套)时让它稍微凉一下。把茶倒在保温杯里,在小区周围散散步。不用设置目标或者目的地,就随便走走。如果你时间不充裕的话,可以定一个 15 分钟的闹钟。 + +3、放一首突然想到的歌,或者听之前想听但是一直没机会听的歌。 + +4、如果你有时间的话,别在椅子上继续坐着,可以站起来跳一段舞活动活动,或者到床上平躺着,躺着的时候什么也不要想,放空自己,让大脑休息休息。研究表明,给大脑一段空白时间后可以更好的思考。 + +5、打开你的 [电子书应用][2] 或者拿起一本纸质书,看纸质书相对来说对眼睛好点。享受轻松的阅读,如果不能长时间阅读的话,起码给自己留出能阅读一个章节的时间。 + +6、制做一些美食。享受把从杂货店买到的基本的食材按照菜谱做成一份美味佳肴的成就感和兴奋感。 + +你也可以在晚上把其中一些综合起来做,好好放松。如果你是 IT 人,那么无论是在 [早上][3]、中午、晚上用这些方式放松都很有效,因为现在我们都是在家工作,远程办公,没有和同事面对面交流时的闲暇。 + +那么,你的晚上放松方式是什么? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/11/evening-rituals-working-tech + +作者:[Jen Wike Huger][a] +选题:[lujun9972][b] +译者:[Arzelan](https://github.com/Arzelan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jen-wike +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDUCATION_jadud_farm-road.png?itok=of8IuSM5 "A farm road" +[2]: https://opensource.com/article/20/2/linux-ebook-readers +[3]: https://opensource.com/article/20/10/tech-morning-rituals \ No newline at end of file diff --git a/published/202107/20210129 Machine learning made easy with Python.md b/published/202107/20210129 Machine learning made easy with Python.md new file mode 100644 index 0000000000..ac7e31389f --- /dev/null +++ b/published/202107/20210129 Machine learning made easy with Python.md @@ -0,0 +1,216 @@ +[#]: collector: (lujun9972) +[#]: translator: (tanloong) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13628-1.html) +[#]: subject: (Machine learning made easy with Python) +[#]: via: (https://opensource.com/article/21/1/machine-learning-python) +[#]: author: (Girish Managoli https://opensource.com/users/gammay) + +用 Python 轻松实现机器学习 +====== + +> 用朴素贝叶斯分类器解决现实世界里的机器学习问题。 + +![](https://img.linux.net.cn/data/attachment/album/202107/29/105035ocxdhdob78wmmtzd.jpg) + +朴素贝叶斯Naïve Bayes是一种分类技术,它是许多分类器建模算法的基础。基于朴素贝叶斯的分类器是简单、快速和易用的机器学习技术之一,而且在现实世界的应用中很有效。 + +朴素贝叶斯是从 [贝叶斯定理][2]Bayes' theorem 发展来的。贝叶斯定理由 18 世纪的统计学家 [托马斯·贝叶斯][3] 提出,它根据与一个事件相关联的其他条件来计算该事件发生的概率。比如,[帕金森氏病][4] 患者通常嗓音会发生变化,因此嗓音变化就是与预测帕金森氏病相关联的症状。贝叶斯定理提供了计算目标事件发生概率的方法,而朴素贝叶斯是对该方法的推广和简化。 + +### 解决一个现实世界里的问题 + +这篇文章展示了朴素贝叶斯分类器解决现实世界问题(相对于完整的商业级应用)的能力。我会假设你对机器学习有基本的了解,所以文章里会跳过一些与机器学习预测不大相关的步骤,比如 数据打乱date shuffling数据切片data splitting。如果你是机器学习方面的新手或者需要一个进修课程,请查看 《[An introduction to machine learning today][5]》 和 《[Getting started with open source machine learning][6]》。 + +朴素贝叶斯分类器是 [有监督的][7]supervised、属于 [生成模型][8]generative 的、非线性的、属于 [参数模型][9]parametric 的和 [基于概率的][10]probabilistic。 + +在这篇文章里,我会演示如何用朴素贝叶斯预测帕金森氏病。需要用到的数据集来自 [UCI 机器学习库][11]。这个数据集包含许多语音信号的指标,用于计算患帕金森氏病的可能性;在这个例子里我们将使用这些指标中的前 8 个: + + * **MDVP:Fo(Hz)**:平均声带基频 + * **MDVP:Fhi(Hz)**:最高声带基频 + * **MDVP:Flo(Hz)**:最低声带基频 + * **MDVP:Jitter(%)**、**MDVP:Jitter(Abs)**、**MDVP:RAP**、**MDVP:PPQ** 和 **Jitter:DDP**:5 个衡量声带基频变化的指标 + +这个例子里用到的数据集,可以在我的 [GitHub 仓库][12] 里找到。数据集已经事先做了打乱和切片。 + +### 用 Python 实现机器学习 + +接下来我会用 Python 来解决这个问题。我用的软件是: + + * Python 3.8.2 + * Pandas 1.1.1 + * scikit-learn 0.22.2.post1 + +Python 有多个朴素贝叶斯分类器的实现,都是开源的,包括: + + * **NLTK Naïve Bayes**:基于标准的朴素贝叶斯算法,用于文本分类 + * **NLTK Positive Naïve Bayes**:NLTK Naïve Bayes 的变体,用于对只标注了一部分的训练集进行二分类 + * **Scikit-learn Gaussian Naïve Bayes**:提供了部分拟合方法来支持数据流或很大的数据集(LCTT 译注:它们可能无法一次性导入内存,用部分拟合可以动态地增加数据) + * **Scikit-learn Multinomial Naïve Bayes**:针对离散型特征、实例计数、频率等作了优化 + * **Scikit-learn Bernoulli Naïve Bayes**:用于各个特征都是二元变量/布尔特征的情况 + +在这个例子里我将使用 [sklearn Gaussian Naive Bayes][13]。 + +我的 Python 实现在 `naive_bayes_parkinsons.py` 里,如下所示: + +``` +import pandas as pd + +# x_rows 是我们所使用的 8 个特征的列名 +x_rows=['MDVP:Fo(Hz)','MDVP:Fhi(Hz)','MDVP:Flo(Hz)', + 'MDVP:Jitter(%)','MDVP:Jitter(Abs)','MDVP:RAP','MDVP:PPQ','Jitter:DDP'] +y_rows=['status'] # y_rows 是类别的列名,若患病,值为 1,若不患病,值为 0 + +# 训练 + +# 读取训练数据 +train_data = pd.read_csv('parkinsons/Data_Parkinsons_TRAIN.csv') +train_x = train_data[x_rows] +train_y = train_data[y_rows] +print("train_x:\n", train_x) +print("train_y:\n", train_y) + +# 导入 sklearn Gaussian Naive Bayes,然后进行对训练数据进行拟合 +from sklearn.naive_bayes import GaussianNB + +gnb = GaussianNB() +gnb.fit(train_x, train_y) + +# 对训练数据进行预测 +predict_train = gnb.predict(train_x) +print('Prediction on train data:', predict_train) + +# 在训练数据上的准确率 +from sklearn.metrics import accuracy_score +accuracy_train = accuracy_score(train_y, predict_train) +print('Accuray score on train data:', accuracy_train) + +# 测试 + +# 读取测试数据 +test_data = pd.read_csv('parkinsons/Data_Parkinsons_TEST.csv') +test_x = test_data[x_rows] +test_y = test_data[y_rows] + +# 对测试数据进行预测 +predict_test = gnb.predict(test_x) +print('Prediction on test data:', predict_test) + +# 在测试数据上的准确率 +accuracy_test = accuracy_score(test_y, predict_test) +print('Accuray score on test data:', accuracy_train) +``` + +运行这个 Python 脚本: + +``` +$ python naive_bayes_parkinsons.py + +train_x: +      MDVP:Fo(Hz)  MDVP:Fhi(Hz) ...  MDVP:RAP  MDVP:PPQ  Jitter:DDP +0        152.125       161.469  ...   0.00191   0.00226     0.00574 +1        120.080       139.710  ...   0.00180   0.00220     0.00540 +2        122.400       148.650  ...   0.00465   0.00696     0.01394 +3        237.323       243.709  ...   0.00173   0.00159     0.00519 +..           ...           ...           ...  ...       ...       ...         +155      138.190       203.522  ...   0.00406   0.00398     0.01218 + +[156 rows x 8 columns] + +train_y: +      status +0         1 +1         1 +2         1 +3         0 +..      ... +155       1 + +[156 rows x 1 columns] + +Prediction on train data: [1 1 1 0 ... 1] +Accuracy score on train data: 0.6666666666666666 + +Prediction on test data: [1 1 1 1 ... 1 + 1 1] +Accuracy score on test data: 0.6666666666666666 +``` + +在训练集和测试集上的准确率都是 67%。它的性能还可以进一步优化。你想尝试一下吗?你可以在下面的评论区给出你的方法。 + +### 背后原理 + +朴素贝叶斯分类器从贝叶斯定理发展来的。贝叶斯定理用于计算条件概率,或者说贝叶斯定理用于计算当与一个事件相关联的其他事件发生时,该事件发生的概率。简而言之,它解决了这个问题:_如果我们已经知道事件 x 发生在事件 y 之前的概率,那么当事件 x 再次发生时,事件 y 发生的概率是多少?_ 贝叶斯定理用一个先验的预测值来逐渐逼近一个最终的 [后验概率][14]。贝叶斯定理有一个基本假设,就是所有的参数重要性相同(LCTT 译注:即相互独立)。 + +贝叶斯计算主要包括以下步骤: + + 1. 计算总的先验概率: + $P(患病)$ 和 $P(不患病)$ + 2. 计算 8 种指标各自是某个值时的后验概率 (value1,...,value8 分别是 MDVP:Fo(Hz),...,Jitter:DDP 的取值): + $P(value1,\ldots,value8\ |\ 患病)$ + $P(value1,\ldots,value8\ |\ 不患病)$ + 3. 将第 1 步和第 2 步的结果相乘,最终得到患病和不患病的后验概率: + $P(患病\ |\ value1,\ldots,value8) \propto P(患病) \times P(value1,\ldots,value8\ |\ 患病)$ + $P(不患病\ |\ value1,\ldots,value8) \propto P(不患病) \times P(value1,\ldots,value8\ |\ 不患病)$ + +上面第 2 步的计算非常复杂,朴素贝叶斯将它作了简化: + + 1. 计算总的先验概率: + $P(患病)$ 和 $P(不患病)$ + 2. 对 8 种指标里的每个指标,计算其取某个值时的后验概率: + $P(value1\ |\ 患病),\ldots,P(value8\ |\ 患病)$ + $P(value1\ |\ 不患病),\ldots,P(value8\ |\ 不患病)$ + 3. 将第 1 步和第 2 步的结果相乘,最终得到患病和不患病的后验概率: + $P(患病\ |\ value1,\ldots,value8) \propto P(患病) \times P(value1\ |\ 患病) \times \ldots \times P(value8\ |\ 患病)$ + $P(不患病\ |\ value1,\ldots,value8) \propto P(不患病) \times P(value1\ |\ 不患病) \times \ldots \times P(value8\ |\ 不患病)$ + +这只是一个很初步的解释,还有很多其他因素需要考虑,比如数据类型的差异,稀疏数据,数据可能有缺失值等。 + +### 超参数 + +朴素贝叶斯作为一个简单直接的算法,不需要超参数。然而,有的版本的朴素贝叶斯实现可能提供一些高级特性(比如超参数)。比如,[GaussianNB][13] 就有 2 个超参数: + + * **priors**:先验概率,可以事先指定,这样就不必让算法从数据中计算才能得出。 + * **var_smoothing**:考虑数据的分布情况,当数据不满足标准的高斯分布时,这个超参数会发挥作用。 + +### 损失函数 + +为了坚持简单的原则,朴素贝叶斯使用 [0-1 损失函数][15]。如果预测结果与期望的输出相匹配,损失值为 0,否则为 1。 + +### 优缺点 + +**优点**:朴素贝叶斯是最简单、最快速的算法之一。 +**优点**:在数据量较少时,用朴素贝叶斯仍可作出可靠的预测。 +**缺点**:朴素贝叶斯的预测只是估计值,并不准确。它胜在速度而不是准确度。 +**缺点**:朴素贝叶斯有一个基本假设,就是所有特征相互独立,但现实情况并不总是如此。 + +从本质上说,朴素贝叶斯是贝叶斯定理的推广。它是最简单最快速的机器学习算法之一,用来进行简单和快速的训练和预测。朴素贝叶斯提供了足够好、比较准确的预测。朴素贝叶斯假设预测特征之间是相互独立的。已经有许多朴素贝叶斯的开源的实现,它们的特性甚至超过了贝叶斯算法的实现。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/1/machine-learning-python + +作者:[Girish Managoli][a] +选题:[lujun9972][b] +译者:[tanloong](https://github.com/tanloong) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/gammay +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fail_progress_cycle_momentum_arrow.png?itok=q-ZFa_Eh (arrows cycle symbol for failing faster) +[2]: https://en.wikipedia.org/wiki/Bayes%27_theorem +[3]: https://en.wikipedia.org/wiki/Thomas_Bayes +[4]: https://en.wikipedia.org/wiki/Parkinson%27s_disease +[5]: https://opensource.com/article/17/9/introduction-machine-learning +[6]: https://opensource.com/business/15/9/getting-started-open-source-machine-learning +[7]: https://en.wikipedia.org/wiki/Supervised_learning +[8]: https://en.wikipedia.org/wiki/Generative_model +[9]: https://en.wikipedia.org/wiki/Parametric_model +[10]: https://en.wikipedia.org/wiki/Probabilistic_classification +[11]: https://archive.ics.uci.edu/ml/datasets/parkinsons +[12]: https://github.com/gammay/Machine-learning-made-easy-Naive-Bayes/tree/main/parkinsons +[13]: https://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.GaussianNB.html +[14]: https://en.wikipedia.org/wiki/Posterior_probability +[15]: https://en.wikipedia.org/wiki/Loss_function#0-1_loss_function diff --git a/published/202107/20210317 Programming 101- Input and output with Java.md b/published/202107/20210317 Programming 101- Input and output with Java.md new file mode 100644 index 0000000000..f512ef9a8b --- /dev/null +++ b/published/202107/20210317 Programming 101- Input and output with Java.md @@ -0,0 +1,159 @@ +[#]: subject: (Programming 101: Input and output with Java) +[#]: via: (https://opensource.com/article/21/3/io-java) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: (piaoshi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13622-1.html) + +编程基础:Java 中的输入和输出 +====== + +> 学习 Java 如何外理数据的读与写。 + +![](https://img.linux.net.cn/data/attachment/album/202107/27/101854by7yizpokqyo77kk.jpg) + +当你写一个程序时,你的应用程序可能需要读取和写入存储在用户计算机上的文件。这在你想加载或存储配置选项,你需要创建日志文件,或你的用户想要保存工作以待后用的情况下是很常见的。每种语言处理这项任务的方式都有所不同。本文演示了如何用 Java 处理数据文件。 + +### 安装 Java + +不管你的计算机是什么平台,你都可以从 [AdoptOpenJDK][2] 安装 Java。这个网站提供安全和开源的 Java 构建。在 Linux 上,你的软件库中也可能找到 AdoptOpenJDK 的构建。 + +我建议你使用最新的长期支持(LTS)版本。最新的非 LTS 版本对希望尝试最新 Java 功能的开发者来说是最好的,但它很可能超过大多数用户所安装的版本 —— 要么是系统上默认安装的,要么是以前为其他 Java 应用安装的。使用 LTS 版本可以确保你与大多数用户所安装的版本保持一致。 + +一旦你安装好了 Java,就可以打开你最喜欢的文本编辑器并准备开始写代码了。你可能还想要研究一下 [Java 集成开发环境][3]。BlueJ 是新程序员的理想选择,而 Eclipse 和 Netbeans 对中级和有经验的编码者更友好。 + +### 利用 Java 读取文件 + +Java 使用 `File` 类来加载文件。 + +这个例子创建了一个叫 `Ingest` 的类来读取文件中数据。当你要在 Java 中打开一个文件时,你创建了一个 `Scanner` 对象,它可以逐行扫描你提供的文件。事实上,`Scanner` 与文本编辑器中的光标是相同的概念,这样你可以用 `Scanner` 的一些方法(如 `nextLine`)来控制这个“光标”以进行读写。 + +``` +import java.io.File; +import java.util.Scanner; +import java.io.FileNotFoundException; + +public class Ingest { + public static void main(String[] args) { + + try { + File myFile = new File("example.txt"); + Scanner myScanner = new Scanner(myFile); + while (myScanner.hasNextLine()) { + String line = myScanner.nextLine(); + System.out.println(line); + } + myScanner.close(); + } catch (FileNotFoundException ex) { + ex.printStackTrace(); + } //try + } //main +} //class +``` + +这段代码首先在假设存在一个名为 `example.txt` 的文件的情况下创建了变量 `myfile`。如果该文件不存在,Java 就会“抛出一个异常”(如它所说的,这意味着它在你试图做的事情中发现了一个错误),这个异常是被非常特定的 `FileNotFoundException` 类所“捕获”。事实上,有一个专门的类来处理这个明确的错误,这说明这个错误是多么常见。 + +接下来,它创建了一个 `Scanner` 并将文件加载到其中。我把它叫做 `myScanner`,以区别于它的通用类模板。接着,一个 `while` 循环将 `myScanner` 逐行送入文件中,只要 _存在_ 下一行。这就是 `hasNextLine` 方法的作用:它检测“光标”之后是否还有数据。你可以通过在文本编辑器中打开一个文件来模拟这个过程:你的光标从文件的第一行开始,你可以用键盘控制光标来向下扫描文件,直到你走完了所有的行。 + +`while` 循环创建了一个变量 `line`,并将文件当前行的数据分配给它。然后将 `line` 的内容打印出来以提供反馈。一个更有用的程序可能会解析每一行的内容,从而提取它所包含的任何重要数据。 + +在这个过程结束时,关闭 `myScanner` 对象。 + +### 运行代码 + +将你的代码保存到 `Ingest.java` 文件(这是一个 Java 惯例,将类名的首字母大写,并以类名来命名相应的文件)。如果你试图运行这个简单的应用程序,你可能会接收到一个错误信息,这是因为还没有 `example.txt` 文件供应用程序加载: + +``` +$ java ./Ingest.java +java.io.FileNotFoundException: +example.txt (No such file or directory) +``` + +正好可以编写一个将数据写入文件的 Java 应用程序,多么完美的时机! + +### 利用 Java 将数据写入文件 + +无论你是存储用户使用你的应用程序创建的数据,还是仅仅存储关于用户在应用程序中做了什么的元数据(例如,游戏保存或最近播放的歌曲),有很多很好的理由来存储数据供以后使用。在 Java 中,这是通过 `FileWriter` 类实现的,这次先打开一个文件,向其中写入数据,然后关闭该文件。 + +``` +import java.io.FileWriter; +import java.io.IOException; + +public class Exgest { + public static void main(String[] args) { + try { + FileWriter myFileWriter = new FileWriter("example.txt", true); + myFileWriter.write("Hello world\n"); + myFileWriter.close(); + } catch (IOException ex) { + System.out.println(ex); + } // try + } // main +} +``` + +这个类的逻辑和流程与读取文件类似。但它不是一个 `Scanner`,而是以一个文件的名字为参数创建的一个 `FileWriter` 对象。`FileWriter` 语句末尾的 `true` 标志告诉 `FileWriter` 将文本 _追加_ 到文件的末尾。要覆盖一个文件的内容,请移除 `true` 标志。 + +``` +`FileWriter myFileWriter = new FileWriter("example.txt", true);` +``` + +因为我在向文件中写入纯文本,所以我在写入文件的数据(`Hello world`)的结尾处手动添加了换行符(`\n`)。 + +### 试试代码 + +将这段代码保存到 `Exgest.java` 文件,遵循 Java 的惯例,使文件名为与类名相匹配。 + +既然你已经掌握了用 Java 创建和读取数据的方法,你可以按相反的顺序尝试运行你的新应用程序。 + +``` +$ java ./Exgest.java +$ java ./Ingest.java +Hello world +$ +``` + +因为程序是把数据追加到文件末尾,所以你可以重复执行你的应用程序以多次写入数据,只要你想把更多的数据添加到你的文件中。 + +``` +$ java ./Exgest.java +$ java ./Exgest.java +$ java ./Exgest.java +$ java ./Ingest.java +Hello world +Hello world +Hello world +$ +``` + +### Java 和数据 + +你不会经常向文件中写入原始文本;事实上,你可能会使用一个其它的类库以写入特定的格式。例如,你可能使用 XML 类库来写复杂的数据,使用 INI 或 YAML 类库来写配置文件,或者使用各种专门类库来写二进制格式,如图像或音频。 + +更完整的信息,请参阅 [OpenJDK 文档][10]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/3/io-java + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[piaoshi](https://github.com/piaoshi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/java-coffee-mug.jpg?itok=Bj6rQo8r (Coffee beans and a cup of coffee) +[2]: https://adoptopenjdk.net +[3]: https://opensource.com/article/20/7/ide-java +[4]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string +[5]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+file +[6]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system +[7]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+filenotfoundexception +[8]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+filewriter +[9]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+ioexception +[10]: https://access.redhat.com/documentation/en-us/openjdk/11/ diff --git a/published/202107/20210418 F(r)iction- Or How I Learnt to Stop Worrying and Start Loving Vim.md b/published/202107/20210418 F(r)iction- Or How I Learnt to Stop Worrying and Start Loving Vim.md new file mode 100644 index 0000000000..f90216e9ea --- /dev/null +++ b/published/202107/20210418 F(r)iction- Or How I Learnt to Stop Worrying and Start Loving Vim.md @@ -0,0 +1,157 @@ +[#]: subject: (F\(r\)iction: Or How I Learnt to Stop Worrying and Start Loving Vim) +[#]: via: (https://news.itsfoss.com/how-i-started-loving-vim/) +[#]: author: (Theena https://news.itsfoss.com/author/theena/) +[#]: collector: (lujun9972) +[#]: translator: (piaoshi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13634-1.html) + +小说还是折磨:我如何学会克服焦虑并开始爱上 Vim +====== + +> 非技术人员也可以使用 Linux 和开源软件进行非技术工作。这是我的故事。 + +![](https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/04/vim-writer.png?w=1200&ssl=1) + +(LCTT 译注:本文原文标题用 “F(r)iction” 一语双关的表示了小说fiction写作过程中的摩擦friction苦恼。) + +时间:2009 年 12 月。我准备辞去工作。 + +我希望专心写我的第一本书;我的工作职责和技术环境都没办法让我完成这本书的写作。 + +写作是件苦差事。 + +在现代世界中,很少有工作像写作这样奇特或者说艰巨的追求 —— 面对一张白纸,坐下来,迫使你的大脑吐出文字,向读者传达一个想法。当然,我并不是说写作不能与他人合作完成,而只是想说明,对于作家来说,自己着手写一部新作品是多么令人生畏。小说还是非小说写作都是如此。但由于我是一名小说家,我在这篇文章中主要想关注是小说的写作。 + +![][1] + +还记得 2009 年是什么样子吗? + +智能手机已经诞生 3 年了 —— 而我还在使用功能机。笔记本电脑又大又笨重。同时,基于云的生产力 Web 应用还处于起步阶段,并不那么好用。从技术上讲,像我这样的作家们正在以 Gmail 账户(和一个非常年轻的基于云的存储服务 Dropbox)作为一个始终可用的选项来处理自己的草稿,即使我的个人电脑不在身边。虽然这与作家们必须要使用打字机(或,上帝保佑,使用笔和纸)工作时相比已经是一个很好的变化了,但并没有好多少。 + +首先,对手稿的版本控制是一场噩梦。此外,我为简化工作流程而在工具包中添加的工具越多,我转换写作环境(无论是用户界面还是用户体验)的次数就越多。 + +我是在 Windows 记事本上开始写草稿的,然后把它保存在家里电脑上的 MS Word 文档中,用电子邮件发给自己一份副本,同时在 Dropbox 上保留另一份副本(因为在上班时无法访问 Dropbox),在公司时对该文件的副本进行处理,在一天结束时用电子邮件发给自己,在家里的电脑上下载它,用一个新的名字和相应的日期保存它,这样我就能认出该文件是在公司(而不是家里)进行修改的……好吧,你知道这是怎样一个画面。如果你能感受到这种涉及 Windows 记事本、MS Word、Gmail 和 Dropbox 的工作流程有多么疯狂,那么现在你就知道我为什么辞职了。 + +让我更清醒的是,我仍然知道一些作家,其中竟然有些还是好作家,依然在使用我 2009 年遵循的工作流程的各种变体。 + +在接下来的三年里,我一直在写手稿,在 2012 年完成了初稿。在这三年里,技术环境发生了很大变化。智能手机确实相当给力,我在 2009 年遇到的一些复杂情况已经消失了。我仍然可以用手机处理我在家里外理的文件(不一定是新的写作,但由于手机上的 Dropbox,编辑变得相当容易)。我的主要写作工具仍然是微软的 Windows 记事本和 Word,我就是这样完成初稿的。 + +小说 [《第一声》][2] 于 2016 年出版,获得了评论界和商业界的好评。 + +结束了。 + +或许我是这么想的。 + +我一完成手稿发给了编辑,就已经开始着手第二部小说的写作。我不再为写作而辞职,而是采取了一种更务实的方法:我会在每年年底请两个星期的假,这样我就可以到山上的一个小木屋里去写作。 + +花了半天时间我才意识到,那些让我讨厌的 [写作工具][3] 和工作流程并没有消失,而是演变成了一个更复杂的野兽。作为一个作家,我并不像我想像的那样高产或高效。 + +### 新冠期间的 Linux + +![][4] + +时间:2020 年。世界正处于集体疯狂的边缘。 + +起初在中国分离出的一种新型病毒正在演变成 1911 年以来的第一次全球大流行疾病。3 月 20 日,斯里兰卡,跟随世界上大多数国家的脚步,封城了。 + +四月是斯里兰卡旱季的高峰。在像科伦坡这样的混凝土丛林中,温度可以达到三十多度,湿度高达九十多度。在最好的情况下,它也可以使大多数人精神错乱,更别说在全球大流行病正在进行的时候,被困在没有一直开着空调的家里?真是一个让人疯狂的好温床。 + +让我的疯狂是 Linux,或者说是“发行版跳跃”,像我们在开源社区中所说的。 + +我越在各种 *nix 发行版间蹿来蹿,我就对控制的想法越迷恋。当任何事情似乎都不在我们的控制之中时 —— 即使是与另一个人握手这样的简单行为 —— 我们自然会倾向于做那些我们感觉更有控制力的事。 + +在我的生活中,还有什么比计算机更容易被控制的呢?自然,这也延伸到我的写作工具和工作流程。 + +### 通往 Vim 之路 + +有一个关于 [Vim][5] 的笑话完美地描述了我对它的第一次体验:人们对 Vim 难以割舍是因为他们不知道怎么关掉它。 + +我试图编辑一个配置文件,而 [新安装的 Ubuntu 服务器][6] 只预装了 Vim 文本编辑器。第一次是恐慌 —— 以至于我重新启动了机器,以为操作系统没有识别出我的键盘。然而当它再次发生时,不可避免地,我谷歌搜索:“[我该如何关闭 Vim?][7]” + +_哦。这真有趣_,我想。 + +_但为什么呢?_ + +要理解我为什么会对一个复杂到无法关闭的文本编辑器有点兴趣,你必须了解我是多么崇拜 Windows 记事本。 + +作为一个作家,我喜欢在它的没有废话、没有按钮、白纸一样的画布上写作。它没有拼写检查。它没有格式。但这些我并不关心。 + +对于我这个作家来说,记事本是有史以来最好的草稿写作板。不幸的是,它并不强大 —— 所以即使我会先用记事本写草稿,一旦超过 1000 字,我就会把它移到 MS Word 上 —— 记事本不是为散文而生的,当超过这个字数限制时,这些局限就会凸显出来。 + +因此,当我把我所有的计算机工作从 Windows 上迁移走时,我第一个要安装的就是一个好的文本编辑器。 + +[Kate][8] 是第一个让我感到比用 Windows 记事本更舒服的替代品 —— 它更强大(它有拼写检查功能!),而且,我可以在同一个环境中搞一些业余爱好式的编程。 + +当时它是我的爱。 + +但后来 Vim 出现了。 + +我对 Vim 了解得越多,看开发者在 Vim 上现场进行编码的次数越多,我就越发现自己在编辑文本时更想打开 Vim。我使用 Unix 传统意义上“文本编辑”这一短语:编辑配置文件中的文本块,或者有时编写基本的 Bash 脚本。 + +我仍然没有用 Vim 来满足我的散文写作需求。 + +在这方面我有 Libre Office。 + +算是吧。 + +虽然它是一个适当的 [MS Office 替代品][9],但我发现自己没有被它打动。它的用户界面可能比 MS Word 更让人分心,而且每个发行版都有不同的 Libre Office 软件包,我发现自己使用的是一个非常零散的工具包和工作流程,更不用说用户界面在不同的发行版和桌面环境中差异是多么大。 + +事情变得更加复杂了,因为我也开始读我的硕士学位了。这时,我要在 Kate 上做笔记,把它们转移到 Libre Office 上,然后保存到我的 Dropbox 上。 + +我每天都面临着情境转换。 + +生产力下降,因为我不得不打开和关闭一些不相关的应用程序。我需要一个写作工具来满足我所有的需求,无论是作为一个小说家,还是一个学生、亦或是一个业余的程序员。 + +这时我意识到,解决我场景切换噩梦的方法也同样摆在我的面前。 + +这时,我已经经常使用 Vim —— 甚至在我的安卓手机上利用 Termux 使用它。这使我对要把所有东西都搬到 Vim 上的想法感到相当舒服。由于它支持 Markdown 语法,记笔记也会变得更加容易。 + +这仅仅是大约两个月前的事。 + +现在怎么样了? + +时间:2021 年 4 月。 + +坐在出租车上,我通过 Termux(借助蓝牙键盘)[用 Vim][10] 在手机上开始写这个草稿。我把文件推送到 GitHub 上我的用于写作使用的私人仓库,我从那里把文件拉到我的电脑上,又写了几行,然后再次出门。我把新版本的文件从 GitHub 拉到我的手机上,修改、推送,如此往复,直到我把最后的草稿用电子邮件发给编辑。 + +现在,场景切换的情景已经不复存在。 + +在文字处理器中写作所带来的分心问题也没有了。 + +编辑工作变得无比简单,而且更快了。 + +我的手腕不再疼痛,因为我不再需要鼠标了。 + +现在是 2021 年 4 月。 + +我是一名小说家。 + +而我在 Vim 上写作。 + +怎么做的?我将在本专栏系列的第二部分讨论这个工作流程的具体内容,即非技术人员如何使用免费和开源技术。敬请关注。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/how-i-started-loving-vim/ + +作者:[Theena][a] +选题:[lujun9972][b] +译者:[piaoshi](https://github.com/piaoshi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/theena/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/04/Cellphones-different-generations-set.png?w=800&ssl=1 +[2]: https://www.goodreads.com/book/show/29616237-first-utterance +[3]: https://itsfoss.com/open-source-tools-writers/ +[4]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/04/quarantine.jpg?w=800&ssl=1 +[5]: https://www.vim.org/ +[6]: https://itsfoss.com/install-ubuntu-server-raspberry-pi/ +[7]: https://itsfoss.com/how-to-exit-vim/ +[8]: https://kate-editor.org/ +[9]: https://itsfoss.com/best-free-open-source-alternatives-microsoft-office/ +[10]: https://linuxhandbook.com/basic-vim-commands/ diff --git a/published/202107/20210508 My weird jobs before tech.md b/published/202107/20210508 My weird jobs before tech.md new file mode 100644 index 0000000000..33c1d30cb9 --- /dev/null +++ b/published/202107/20210508 My weird jobs before tech.md @@ -0,0 +1,49 @@ +[#]: subject: (My weird jobs before tech) +[#]: via: (https://opensource.com/article/21/5/weird-jobs-tech) +[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen) +[#]: collector: (lujun9972) +[#]: translator: (MM-BCY) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13553-1.html) + +我在进入技术行业之前的奇怪工作 +====== + +> 你永远不会知道从你的第一份工作会走到哪里! + +![Yellow plane flying in the air, Beechcraft D17S][1] + +在我从事技术工作之前,我做过一些奇怪的工作。 + +我是一家飞机修理厂的初级助理,这意味着我的工作要在溶剂中清洗肮脏的金属零件(哇,70 年代的事情可和现在不一样)。我在那里最有趣的工作是熨烫涤纶飞机的布料,放到一架正在修理中的漂亮的老式比奇交错式双翼机Beechcraft Staggerwing的木制副翼和水平稳定器上。 + +在大学期间的一个夏天,我在同一个机场的一个团队工作,混合阻燃剂,然后把它注入灭火飞机(“[水轰炸机][2]water bomber”)。那可能是我做过的最脏的工作了,但是给飞机装载还是挺酷的。有一个离地面约两米的小挡板,你可以在把填充软管连接到接头后把手指伸进去。然后泵上的人启动泵。当你觉得你的手指湿了,就挥手让管理泵的人停止泵。与此同时,在你前方几米处运行的右侧径向引擎噪音极大,螺旋桨吹掉了你身上因混合阻燃剂而积聚的红色粉尘。如果你搞砸了,让飞机装得太满,他们就得滑到一块地方,把货卸在那里,否则他们会太重而无法起飞。 + +另外两个夏天,我在当地的百事可乐、七喜、Orange Crush 经销商那里工作,给商店和餐馆送一箱箱的软饮料。这绝对是我做过的最重的体力活了。想想看,在一辆手推车上堆放着五层高的木箱,每个木箱里装着一打 750 毫升的软饮料玻璃瓶。想想把它搬到二楼的餐厅,想想那家餐厅每周要运 120 箱……爬 24 次楼,然后又带着所有的空瓶子下来。一辆小卡车上通常会有 300 箱左右的软饮料。我们的工资是按载重计算的,而不是按小时计算的,所以我们的目标是早点完工,然后去海滩。 + +### 我的技术工作 + +送苏打水是我大学期间最后一份暑期工作。第二年我毕业了,获得了数学学位,还修了很多计算机课程,尤其是数值分析。我在技术领域的第一份工作,是为一家小型电脑服务咨询公司工作。我用 SPSS 对一些运动钓鱼调查做了一些分析,写了几百行 PL/1,在我们按时间租来的服务部门的 IBM 3800 激光打印机上打印演唱会门票,并开始研究一些程序来分析森林统计数据。我最终为需要林业统计的客户工作,在 20 世纪 80 年代中期成为合伙人。那时我们已经不仅仅是测量树木,也不再使用分时服务部门timesharing bureau来进行计算了。我们买了一台 UNIX 小型计算机,我们在 80 年代后期升级到 SUN 工作站网络。 + +我在一个大型开发项目上工作了一段时间,它的总部设在马来西亚吉隆坡。然后我们买了第一个地理信息系统,在 80 年代末和 90 年代,我的大部分时间都在和我们的客户一起工作,他们需要定制软件来满足他们的业务需求。到了 21 世纪初,我的三个老合伙人都准备退休了,我试图弄明白,我是如何融入我们这个不再是小公司的,大约 200 名员工的长期图景。我们新的员工老板也不明白这一点,2002 年,我来到智利,想看看智利-加拿大自由贸易协定,是否提供了一个合理的机会,把我们的部分业务转移到拉丁美洲。 + +该业务在 2004 年正式成立。与此同时,加拿大的母公司由于一些投资组合受到严重影响,在 2007-2009 年的经济衰退的情况下,这些投资似乎不再那么明智,它在 2011 年被迫倒闭。然而,那时候,智利子公司还在经营,所以我们原来的雇员和我成了合伙人,通过资产出售买下了它。直到今天,它仍在运行,在社会环境领域做了很多很酷的事情,我经常参与其中,特别是当我可靠的数学和计算背景有用的时候。 + +作为一个副业,我为一个在印度以买卖赛马为业的人开发和支持一个赛马信息系统。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/5/weird-jobs-tech + +作者:[Chris Hermansen][a] +选题:[lujun9972][b] +译者:[MM-BCY](https://github.com/MM-BCY) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clhermansen +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/yellow_plane_fly_air.jpg?itok=pEcrCVJT (Yellow plane flying in the air, Beechcraft D17S) +[2]: https://worldairphotography.wordpress.com/2016/08/22/air-tanker-history-in-canada-part-one/amp/ diff --git a/published/202107/20210517 How to look at the stack with gdb.md b/published/202107/20210517 How to look at the stack with gdb.md new file mode 100644 index 0000000000..5c2f5ced83 --- /dev/null +++ b/published/202107/20210517 How to look at the stack with gdb.md @@ -0,0 +1,385 @@ +[#]: subject: "How to look at the stack with gdb" +[#]: via: "https://jvns.ca/blog/2021/05/17/how-to-look-at-the-stack-in-gdb/" +[#]: author: "Julia Evans https://jvns.ca/" +[#]: collector: "lujun9972" +[#]: translator: "amwps290" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13550-1.html" + +使用 GDB 查看程序的栈空间 +====== + +![](https://img.linux.net.cn/data/attachment/album/202107/05/103738f00boylephggpeyh.jpg) + +昨天我和一些人在闲聊的时候,他们说他们并不真正了解栈是如何工作的,而且也不知道如何去查看栈空间。 + +这是一个快速教程,介绍如何使用 GDB 查看 C 程序的栈空间。我认为这对于 Rust 程序来说也是相似的。但我这里仍然使用 C 语言,因为我发现用它更简单,而且用 C 语言也更容易写出错误的程序。 + +### 我们的测试程序 + +这里是一个简单的 C 程序,声明了一些变量,从标准输入读取两个字符串。一个字符串在堆上,另一个字符串在栈上。 + +``` +#include +#include + +int main() { + char stack_string[10] = "stack"; + int x = 10; + char *heap_string; + + heap_string = malloc(50); + + printf("Enter a string for the stack: "); + gets(stack_string); + printf("Enter a string for the heap: "); + gets(heap_string); + printf("Stack string is: %s\n", stack_string); + printf("Heap string is: %s\n", heap_string); + printf("x is: %d\n", x); +} +``` + +这个程序使用了一个你可能从来不会使用的极为不安全的函数 `gets` 。但我是故意这样写的。当出现错误的时候,你就知道是为什么了。 + +### 第 0 步:编译这个程序 + +我们使用 `gcc -g -O0 test.c -o test` 命令来编译这个程序。 + +`-g` 选项会在编译程序中将调式信息也编译进去。这将会使我们查看我们的变量更加容易。 + +`-O0` 选项告诉 gcc 不要进行优化,我要确保我们的 `x` 变量不会被优化掉。 + +### 第一步:启动 GDB + +像这样启动 GDB: + +``` +$ gdb ./test +``` + +它打印出一些 GPL 信息,然后给出一个提示符。让我们在 `main` 函数这里设置一个断点: + +``` +(gdb) b main +``` + +然后我们就可以运行程序: + +``` +(gdb) b main +Starting program: /home/bork/work/homepage/test +Breakpoint 1, 0x000055555555516d in main () + +(gdb) run +Starting program: /home/bork/work/homepage/test + +Breakpoint 1, main () at test.c:4 +4 int main() { +``` + +好了,现在程序已经运行起来了。我们就可以开始查看栈空间了。 + +### 第二步:查看我们变量的地址 + +让我们从了解我们的变量开始。它们每个都在内存中有一个地址,我们可以像这样打印出来: + +``` +(gdb) p &x +$3 = (int *) 0x7fffffffe27c +(gdb) p &heap_string +$2 = (char **) 0x7fffffffe280 +(gdb) p &stack_string +$4 = (char (*)[10]) 0x7fffffffe28e +``` + +因此,如果我们查看那些地址的堆栈,那我们应该能够看到所有的这些变量! + +### 概念:栈指针 + +我们将需要使用栈指针,因此我将尽力对其进行快速解释。 + +有一个名为 ESP 的 x86 寄存器,称为“栈指针stack pointer”。 基本上,它是当前函数的栈起始地址。 在 GDB 中,你可以使用 `$sp` 来访问它。 当你调用新函数或从函数返回时,栈指针的值会更改。 + +### 第三步:在 `main` 函数开始的时候,我们查看一下在栈上的变量 + +首先,让我们看一下 main 函数开始时的栈。 现在是我们的堆栈指针的值: + +``` +(gdb) p $sp +$7 = (void *) 0x7fffffffe270 +``` + +因此,我们当前函数的栈起始地址是 `0x7fffffffe270`,酷极了。 + +现在,让我们使用 GDB 打印出当前函数堆栈开始后的前 40 个字(即 160 个字节)。 某些内存可能不是栈的一部分,因为我不太确定这里的堆栈有多大。 但是至少开始的地方是栈的一部分。 + +``` +(gdb) x/40x $sp +0x7fffffffe270: 0x00000000 0x00000000 0x55555250 0x00005555 +0x7fffffffe280: 0x00000000 0x00000000 0x55555070 0x00005555 +0x7fffffffe290: 0xffffe390 0x00007fff 0x00000000 0x00000000 +0x7fffffffe2a0: 0x00000000 0x00000000 0xf7df4b25 0x00007fff +0x7fffffffe2b0: 0xffffe398 0x00007fff 0xf7fca000 0x00000001 +0x7fffffffe2c0: 0x55555169 0x00005555 0xffffe6f9 0x00007fff +0x7fffffffe2d0: 0x55555250 0x00005555 0x3cae816d 0x8acc2837 +0x7fffffffe2e0: 0x55555070 0x00005555 0x00000000 0x00000000 +0x7fffffffe2f0: 0x00000000 0x00000000 0x00000000 0x00000000 +0x7fffffffe300: 0xf9ce816d 0x7533d7c8 0xa91a816d 0x7533c789 +``` + +我已粗体显示了 `stack_string`,`heap_string` 和 `x` 变量的位置,并改变了颜色: + + * `x` 是红色字体,并且起始地址是 `0x7fffffffe27c` + * `heap_string` 是蓝色字体,起始地址是 `0x7fffffffe280` + * `stack_string` 是紫色字体,起始地址是 `0x7fffffffe28e` + +你可能会在这里注意到的一件奇怪的事情是 `x` 的值是 0x5555,但是我们将 `x` 设置为 `10`! 那是因为直到我们的 `main` 函数运行之后才真正设置 `x` ,而我们现在才到了 `main` 最开始的地方。 + +### 第三步:运行到第十行代码后,再次查看一下我们的堆栈 + +让我们跳过几行,等待变量实际设置为其初始化值。 到第 10 行时,`x` 应该设置为 `10`。 + +首先我们需要设置另一个断点: + +``` +(gdb) b test.c:10 +Breakpoint 2 at 0x5555555551a9: file test.c, line 11. +``` + +然后继续执行程序: + +``` +(gdb) continue +Continuing. + +Breakpoint 2, main () at test.c:11 +11 printf("Enter a string for the stack: "); +``` + +好的! 让我们再来看看堆栈里的内容! `gdb` 在这里格式化字节的方式略有不同,实际上我也不太关心这些(LCTT 译注:可以查看 GDB 手册中 `x` 命令,可以指定 `c` 来控制输出的格式)。 这里提醒一下你,我们的变量在栈上的位置: + + + * `x` 是红色字体,并且起始地址是 `0x7fffffffe27c` + * `heap_string` 是蓝色字体,起始地址是 `0x7fffffffe280` + * `stack_string` 是紫色字体,起始地址是 `0x7fffffffe28e` + +``` +(gdb) x/80x $sp +0x7fffffffe270: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 +0x7fffffffe278: 0x50 0x52 0x55 0x55 0x0a 0x00 0x00 0x00 +0x7fffffffe280: 0xa0 0x92 0x55 0x55 0x55 0x55 0x00 0x00 +0x7fffffffe288: 0x70 0x50 0x55 0x55 0x55 0x55 0x73 0x74 +0x7fffffffe290: 0x61 0x63 0x6b 0x00 0x00 0x00 0x00 0x00 +0x7fffffffe298: 0x00 0x80 0xf7 0x8a 0x8a 0xbb 0x58 0xb6 +0x7fffffffe2a0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 +0x7fffffffe2a8: 0x25 0x4b 0xdf 0xf7 0xff 0x7f 0x00 0x00 +0x7fffffffe2b0: 0x98 0xe3 0xff 0xff 0xff 0x7f 0x00 0x00 +0x7fffffffe2b8: 0x00 0xa0 0xfc 0xf7 0x01 0x00 0x00 0x00 +``` + +在继续往下看之前,这里有一些有趣的事情要讨论。 + +### `stack_string` 在内存中是如何表示的 + +现在(第 10 行),`stack_string` 被设置为字符串`stack`。 让我们看看它在内存中的表示方式。 + +我们可以像这样打印出字符串中的字节(LCTT 译注:可以通过 `c` 选项直接显示为字符): + +``` +(gdb) x/10x stack_string +0x7fffffffe28e: 0x73 0x74 0x61 0x63 0x6b 0x00 0x00 0x00 +0x7fffffffe296: 0x00 0x00 +``` + +`stack` 是一个长度为 5 的字符串,相对应 5 个 ASCII 码- `0x73`、`0x74`、`0x61`、`0x63` 和 `0x6b`。`0x73` 是字符 `s` 的 ASCII 码。 `0x74` 是 `t` 的 ASCII 码。等等... + +同时我们也使用 `x/1s` 可以让 GDB 以字符串的方式显示: + +``` +(gdb) x/1s stack_string +0x7fffffffe28e: "stack" +``` + +### `heap_string` 与 `stack_string` 有何不同 + +你已经注意到了 `stack_string` 和 `heap_string` 在栈上的表示非常不同: + +* `stack_string` 是一段字符串内容(`stack`) +* `heap_string` 是一个指针,指向内存中的某个位置 + +这里是 `heap_string` 变量在内存中的内容: + +``` +0xa0 0x92 0x55 0x55 0x55 0x55 0x00 0x00 +``` + +这些字节实际上应该是从右向左读:因为 x86 是小端模式,因此,`heap_string` 中所存放的内存地址 `0x5555555592a0` + +另一种方式查看 `heap_string` 中存放的内存地址就是使用 `p` 命令直接打印 : + +``` +(gdb) p heap_string +$6 = 0x5555555592a0 "" +``` + +### 整数 x 的字节表示 + +`x` 是一个 32 位的整数,可由 `0x0a 0x00 0x00 0x00` 来表示。 + +我们还是需要反向来读取这些字节(和我们读取 `heap_string` 需要反过来读是一样的),因此这个数表示的是 `0x000000000a` 或者是 `0x0a`,它是一个数字 `10`; + +这就让我把把 `x` 设置成了 `10`。 + +### 第四步:从标准输入读取 + +好了,现在我们已经初始化我们的变量,我们来看一下当这段程序运行的时候,栈空间会如何变化: + +``` +printf("Enter a string for the stack: "); +gets(stack_string); +printf("Enter a string for the heap: "); +gets(heap_string); +``` + +我们需要设置另外一个断点: + +``` +(gdb) b test.c:16 +Breakpoint 3 at 0x555555555205: file test.c, line 16. +``` + +然后继续执行程序: + +``` +(gdb) continue +Continuing. +``` + +我们输入两个字符串,为栈上存储的变量输入 `123456789012` 并且为在堆上存储的变量输入 `bananas`; + +### 让我们先来看一下 `stack_string`(这里有一个缓存区溢出) + +``` +(gdb) x/1s stack_string +0x7fffffffe28e: "123456789012" +``` + +这看起来相当正常,对吗?我们输入了 `12345679012`,然后现在它也被设置成了 `12345679012`(LCTT 译注:实测 gcc 8.3 环境下,会直接段错误)。 + +但是现在有一些很奇怪的事。这是我们程序的栈空间的内容。有一些紫色高亮的内容。 + +``` +0x7fffffffe270: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 +0x7fffffffe278: 0x50 0x52 0x55 0x55 0x0a 0x00 0x00 0x00 +0x7fffffffe280: 0xa0 0x92 0x55 0x55 0x55 0x55 0x00 0x00 +0x7fffffffe288: 0x70 0x50 0x55 0x55 0x55 0x55 0x31 0x32 +0x7fffffffe290: 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 +0x7fffffffe298: 0x31 0x32 0x00 0x8a 0x8a 0xbb 0x58 0xb6 +0x7fffffffe2a0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 +0x7fffffffe2a8: 0x25 0x4b 0xdf 0xf7 0xff 0x7f 0x00 0x00 +0x7fffffffe2b0: 0x98 0xe3 0xff 0xff 0xff 0x7f 0x00 0x00 +0x7fffffffe2b8: 0x00 0xa0 0xfc 0xf7 0x01 0x00 0x00 0x00 +``` + +令人奇怪的是 **`stack_string` 只支持 10 个字节**。但是现在当我们输入了 13 个字符以后,发生了什么? + +这是一个典型的缓冲区溢出,`stack_string` 将自己的数据写在了程序中的其他地方。在我们的案例中,这还没有造成问题,但它会使你的程序崩溃,或者更糟糕的是,使你面临非常糟糕的安全问题。 + +例如,假设 `stack_string` 在内存里的位置刚好在 `heap_string` 之前。那我们就可能覆盖 `heap_string` 所指向的地址。我并不确定 `stack_string` 之后的内存里有一些什么。但我们也许可以用它来做一些诡异的事情。 + +### 确实检测到了有缓存区溢出 + +当我故意写很多字符的时候: + +``` + ./test +Enter a string for the stack: 01234567891324143 +Enter a string for the heap: adsf +Stack string is: 01234567891324143 +Heap string is: adsf +x is: 10 +*** stack smashing detected ***: terminated +fish: Job 1, './test' terminated by signal SIGABRT (Abort) +``` + +这里我猜是 `stack_string` 已经到达了这个函数栈的底部,因此额外的字符将会被写在另一块内存中。 + +当你故意去使用这个安全漏洞时,它被称为“堆栈粉碎”,而且不知何故有东西在检测这种情况的发生。 + +我也觉得这很有趣,虽然程序被杀死了,但是当缓冲区溢出发生时它不会立即被杀死——在缓冲区溢出之后再运行几行代码,程序才会被杀死。 好奇怪! + +这些就是关于缓存区溢出的所有内容。 + +### 现在我们来看一下 `heap_string` + +我们仍然将 `bananas` 输入到 `heap_string` 变量中。让我们来看一下内存中的样子。 + +这是在我们读取了字符串以后,`heap_string` 在栈空间上的样子: + +``` +(gdb) x/40x $sp +0x7fffffffe270: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 +0x7fffffffe278: 0x50 0x52 0x55 0x55 0x0a 0x00 0x00 0x00 +0x7fffffffe280: 0xa0 0x92 0x55 0x55 0x55 0x55 0x00 0x00 +0x7fffffffe288: 0x70 0x50 0x55 0x55 0x55 0x55 0x31 0x32 +0x7fffffffe290: 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 +``` + +需要注意的是,这里的值是一个地址。并且这个地址并没有改变,但是我们来看一下指向的内存上的内容。 + +``` +(gdb) x/10x 0x5555555592a0 +0x5555555592a0: 0x62 0x61 0x6e 0x61 0x6e 0x61 0x73 0x00 +0x5555555592a8: 0x00 0x00 +``` + +看到了吗,这就是字符串 `bananas` 的字节表示。这些字节并不在栈空间上。他们存在于内存中的堆上。 + +### 堆和栈到底在哪里? + +我们已经讨论过栈和堆是不同的内存区域,但是你怎么知道它们在内存中的位置呢? + +每个进程都有一个名为 `/proc/$PID/maps` 的文件,它显示了每个进程的内存映射。 在这里你可以看到其中的栈和堆。 + +``` +$ cat /proc/24963/maps +... lots of stuff omitted ... +555555559000-55555557a000 rw-p 00000000 00:00 0 [heap] +... lots of stuff omitted ... +7ffffffde000-7ffffffff000 rw-p 00000000 00:00 0 [stack] +``` + +需要注意的一件事是,这里堆地址以 `0x5555` 开头,栈地址以 `0x7fffff` 开头。 所以很容易区分栈上的地址和堆上的地址之间的区别。 + +### 像这样使用 gdb 真的很有帮助 + +这有点像旋风之旅,虽然我没有解释所有内容,但希望看到数据在内存中的实际情况可以使你更清楚地了解堆栈的实际情况。 + +我真的建议像这样来把玩一下 gdb —— 即使你不理解你在内存中看到的每一件事,我发现实际上像这样看到我程序内存中的数据会使抽象的概念,比如“栈”和“堆”和“指针”更容易理解。 + +### 更多练习 + +一些关于思考栈的后续练习的想法(没有特定的顺序): + + * 尝试将另一个函数添加到 `test.c` 并在该函数的开头创建一个断点,看看是否可以从 `main` 中找到堆栈! 他们说当你调用一个函数时“堆栈会变小”,你能在 gdb 中看到这种情况吗? + * 从函数返回一个指向栈上字符串的指针,看看哪里出了问题。 为什么返回指向栈上字符串的指针是不好的? + * 尝试在 C 中引起堆栈溢出,并尝试通过在 gdb 中查看堆栈溢出来准确理解会发生什么! + * 查看 Rust 程序中的堆栈并尝试找到变量! + * 在 [噩梦课程][1] 中尝试一些缓冲区溢出挑战。每个问题的答案写在 README 文件中,因此如果你不想被宠坏,请避免先去看答案。 所有这些挑战的想法是给你一个二进制文件,你需要弄清楚如何导致缓冲区溢出以使其打印出 `flag` 字符串。 + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2021/05/17/how-to-look-at-the-stack-in-gdb/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[amwps290](https://github.com/amwps290) +校对:[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://github.com/guyinatuxedo/nightmare diff --git a/published/202107/20210529 Configuring Vim as a Writing Tool.md b/published/202107/20210529 Configuring Vim as a Writing Tool.md new file mode 100644 index 0000000000..b56464d14d --- /dev/null +++ b/published/202107/20210529 Configuring Vim as a Writing Tool.md @@ -0,0 +1,197 @@ +[#]: subject: (Configuring Vim as a Writing Tool) +[#]: via: (https://news.itsfoss.com/configuring-vim-writing/) +[#]: author: (Theena https://news.itsfoss.com/author/theena/) +[#]: collector: (lujun9972) +[#]: translator: (piaoshi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13607-1.html) + +将 Vim 配置成一个写作工具 +====== + +> 我使用 Vim 来写小说。我是这样配置它的。 + +![](https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/05/Setting-Up-Vim-for-Writing.jpg?w=1200&ssl=1) + +在我的第一个专栏中,我谈到了我为什么把 [我的写作工作迁移到了 Vim 上][1] —— 远离了现代写作者们的标准工具,如文字处理器(MS Word 及它的开源替代方案)、文本编辑器(记事本,因为直到去年我一直是 Windows 用户)和云存储技术。如果你是一个写作者,在继续下面的内容前,我建议你先阅读一下 [那篇文章的第一部分][1] 。 + +基本上可以说,你使用的设备越多,你需要的写作工具就越多,最终你的工作流程就越复杂。这一点对我来说是很贴切的,因为我有四台设备,包括一部安卓手机,一台日常用的运行 Linux 的主力笔记本电脑,还有两台旧的笔记本电脑,其中一台是 Mac,我去户外拍摄时会带着它。 + +Vim 对于我和我的工作方式来说是一个完美的解决方案;虽然我不会说我的新的工作流程是现代写作者工作的最佳方式,但我可以说的是,对于写作者来说,拥有一个能在我们所有设备上工作的工具非常重要的,并且这个工具要足够强大以满足我们写作者每天从事的不同类型的写作需求。 + +从这个角度来看,Vim 的主要优势是它是跨平台的 —— 无论在什么设备上,Vim 都能工作。在苹果生态系统中使用 Vim 的情况我就不细说了,但粗略地看一下 [这个应用程序][2] 的评论,我就会知道,总会有人在各种地方使用 Vim,不管他们使用的是什么设备。 + +现在我们假设你是一个想开始使用 Vim 的写作者。当你安装了它,你该从哪里开始呢? + +我在这一部分给你的并不算是教程,而是一系列的建议,包含对一个用于诗歌写作的 `.vimrc` 配置文件的解读。只要有可能,我就会链接到我学习相应内容时用到的 YouTube 上的教程。 + +对于 Linux 用户来说,系统已经预装了 Vim —— 通过你喜欢的终端模拟器就可以启动它。对于 Windows 和 Mac 用户,你可以从 [Vim 官方网站][3] 下载它。 + +### 建议 + +**安装/启用 Vim 后** + + * 通过终端打开 Vim Tutor。(Mac 用户可以用这种方式启动,而 Windows 用户也可以用这种方法启动。[LCTT 译注:原文这里本应该有链接,可能作者忘记添加了。无论如何,在终端中, Linux 中的命令是 `vimtutor`,Windows 在安装目录下找到 `vimtutor.bat` 命令并运行;Mac?应该与 Linux 一样?我没 Mac 呀!])在这个阶段,你不会使用 Vim 进行任何写作 —— 相反,你要每天花 15 分钟做 Vim 教程。不要多花一分钟或少花一分钟;看看在规定的 15 分钟内,你能在教程中取得多大的进展。你会发现,每天你都会在教程中取得更大的进步。在一个月内,你应该能够利用这些 15 分钟完成整个教程。 + * 成为一个更好的打字员对 Vim 的使用来说有极大的好处。这不是必须的,但我正在重新学习打字,它的副作用是使 Vim 变得更加有用了。我每次都以花 15 分钟练习打字开始,作为进入 Vim 教程前的热身。 + +在每一天的开始,我分配了 30 分钟的时间做这两项练习进行热身,而每天晚上睡觉前再分配 30 分钟进行练习以让我安定下来。这样的做法帮我快速从旧的工具包过渡到了 Vim,但你的安排可能有所不同。 + +我再次强调,**除了 Vim Tutor 之外**,上述步骤都是可选的;这完全取决于你个人的动机水平。 + +现在我们来到了这篇文章的重点:如何配置 Vim ,使它对写作者友好? + +### 如何配置用于写作的 .vimrc + +在开始之前,我想在这里提醒各位读者,我不是一个技术人员 —— 我是一个小说家 —— 你在下面看到的任何错误都是我自己的;我希望有经验的 Vim 用户能提供反馈,告诉我如何进一步完善我的配置文件。 + +下面是我的 `.vimrc` 文件。你可以从我的 [GitHub][4] 上下载,并进一步完善它: + +``` +syntax on + +set noerrorbells " 取消 Vim 的错误警告铃声,关闭它以免打扰到我们 +set textwidth=100 " 确保每一行不超过 100 字符 +set tabstop=4 softtabstop=4 +set shiftwidth=4 +set expandtab +set smartindent +set linebreak +set number +set showmatch +set showbreak=+++ +set smartcase +set noswapfile +set undodir=~/.vim/undodir +set undofile +set incsearch +set spell +set showmatch +set confirm +set ruler +set autochdir +set autowriteall +set undolevels=1000 +set backspace=indent,eol,start + +" 下面的设置确保按写作者而不是程序员喜欢的方式折行 + +set wrap +nnoremap :set linebreak +nnoremap :set nolinebreak + + +call plug#begin('~/.vim/plugged') + +" 这是颜色风格插件 + +Plug 'colepeters/spacemacs-theme.vim' +Plug 'sainnhe/gruvbox-material' +Plug 'phanviet/vim-monokai-pro' +Plug 'flazz/vim-colorschemes' +Plug 'chriskempson/base16-vim' +Plug 'gruvbox-community/gruvbox' + +" 这是为了更容易的诗歌写作选择的一些插件 + +Plug 'dpelle/vim-LanguageTool' +Plug 'ron89/thesaurus_query.vim' +Plug 'junegunn/goyo.vim' +Plug 'junegunn/limelight.vim' +Plug 'reedes/vim-pencil' +Plug 'reedes/vim-wordy' + + +" 这一部分是为了更容易地与机器集成,用了 vim-airline 这类插件 + +Plug 'vim-airline/vim-airline' + +" 这一部分外理工作区和会话管理 + +Plug 'thaerkh/vim-workspace' + +" 与上面插件相关, 下面的代码将你的所有的会话文件保存到一个你工作区之外的目录 + +let g:workspace_session_directory = $HOME . '/.vim/sessions/' + + +" 与上面插件相关,这是一个 Vim 活动的跟踪器 + +Plug 'wakatime/vim-wakatime' + +" 一个干扰因素:我在这里使用了一些 Emacs 的功能,特别是 org-mode + +Plug 'jceb/vim-orgmode' + + +" 这是文件格式相关插件 + +Plug 'plasticboy/vim-markdown' + + +call plug#end() + +colorscheme pacific +set background=dark + +if executable('rg') + let g:rg_derive_root='true' +endif +``` + +学习如何安装 Vim 插件时,这个[教程](https://www.youtube.com/watch?v=n9k9scbTuvQ)帮助了我。我使用 Vim Plugged 插件管理器是因为在我看来它是最简单、最优雅的。 + +![][5] + +#### 对于写作者的 .vimrc 选项的整理 + + * `syntax on`:这可以确保 Vim 知道我在使用什么语法。做笔记、写这种文章时我主要使用 Markdown;而在写小说的时候,纯文本是我的首选格式。 + * `set noerrorbells`:为了你的精神状态,我强烈建议打开这个选项。 + * `set textwidth=100`:为了便于阅读,没有人愿意横向滚动一个文本文件。 + * `set spell`:如果有拼写错误的话提醒你。 + * `set wrap`:确保文本以写作者而不是程序员的方式进行折行。 + +你会注意到,我没有花更多时间讨论其他一些基本配置选项,因为我并不觉得那些对写作者来说有多重要。因为我做一些业余的编码工作,所以我的 `.vimrc` 配置反映了这一点。如果你只想在 Vim 上写作,那么上述配置就应该能让你顺利开始。 + +从这点上来说,你的 `.vimrc` 是一个活的文档,它能生动地反映你想用 Vim 做什么,以及你希望 Vim 如何为你做这些事情。 + +#### 关于插件的说明 + +第 43-98 行之间是我对插件的配置。如果你已经学习了关于如何安装 Vim 插件的教程,我强烈推荐你从以下专为写作开发的 Vim 插件开始: + + * `vim-LanguageTool` + * `thesaurus_query.vim` + * `vim-pencil` + * `vim-wordy` + * `vim-goyo` + * `vim-markdown` + +#### 总结 + +在这篇文章中,我们简单地[介绍](https://youtu.be/Pq3JMp3stxQ)了写作者可以怎样开始使用 Vim,以及一个在写作工作中需要的 `.vimrc` 入门配置。除了我的 `.vimrc` 之外,我还将在这里链接到我在 GitHub 上发现的其他写作者的 `.vimrc`,它们是我自己配置时的灵感来源。 + +![][6] + +请劳记,这只是一个写作者的 `.vimrc` 的入门配置。你会发现,随着你的需求的发展,Vim 也可以随之发展。因此,投入一些时间学习配置你的 `.vimrc` 是值得的。 + +在下一篇文章中,我将会检视我在写作时的工作流程的具体细节,这个工作流程中我使用了 Vim 和 Git 及 GitHub。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/configuring-vim-writing/ + +作者:[Theena][a] +选题:[lujun9972][b] +译者:[piaoshi](https://github.com/piaoshi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/theena/ +[b]: https://github.com/lujun9972 +[1]: https://news.itsfoss.com/how-i-started-loving-vim/ +[2]: https://apps.apple.com/us/app/ivim/id1266544660 +[3]: https://www.vim.org/ +[4]: https://github.com/MiragianCycle/dotfiles +[5]: https://i1.wp.com/i.ytimg.com/vi/n9k9scbTuvQ/hqdefault.jpg?w=780&ssl=1 +[6]: https://i2.wp.com/i.ytimg.com/vi/Pq3JMp3stxQ/hqdefault.jpg?w=780&ssl=1 diff --git a/published/202107/20210529 My family-s Linux story.md b/published/202107/20210529 My family-s Linux story.md new file mode 100644 index 0000000000..fb5ef4b277 --- /dev/null +++ b/published/202107/20210529 My family-s Linux story.md @@ -0,0 +1,40 @@ +[#]: subject: (My family's Linux story) +[#]: via: (https://opensource.com/article/21/5/my-linux-story) +[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen) +[#]: collector: (lujun9972) +[#]: translator: (shiboi77) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13614-1.html) + +我家的 Linux 故事 +====== + +> 我们在 Linux 的第一次尝试只是一个 apt-get 的距离。 + +![](https://img.linux.net.cn/data/attachment/album/202107/25/065040z2zt9lb9fc99kcho.jpg) + +我在 Linux 的第一次尝试是那种“或许我应该试一试”的情况。 + +那是 1990 年代,我在一些软盘上找到了用某种打包方式打包的红帽发行版,我为家里的笔记本电脑买了第二个硬盘,然后开始安装它。这是一件有趣的实验,但是我记得当时家人还没有准备好在电脑上使用 Linux。转眼到了 2005 年,我最终放弃了这种做法,买了一台可爱的东芝笔记本电脑,来运行 Windows XP。在工作中,我有一台有点年头的 SUN SPARCStation 5,并且我不太喜欢当时整个 Solaris 的发展方向(基于 Motif 的桌面)。我真的想要用 GIMP 来完成一些这样或那样的项目,但是在 Solaris 上安装 GNOME 1.x(也许是 1.4?)的曲折旅程是很有挑战性的。所以,我实际上是在考虑跳槽到 Windows XP。但是在我的家用机上用了几个月之后,我发现我更不喜欢在 Solaris 上运行 GNOME,所以我安装了 Ubuntu Hoary Hedgehog 5.04,随后在我的笔记本电脑上安装了 Breezy Badger 5.10。这太棒了,那台拥有 3.2GHz 奔腾处理器、2GB 内存和 100GB 的硬盘的机器就在我的 SPARCStation 5 旁边运行。 + +突然之间,我不再用拼凑起来的 Solaris 安装包来试图去让东西运行起来,而只是用 apt-get 就可以了。并且这个时机也很好。我家庭和我从 2006 年 8 月到 2007 年 7 月居住在法国格勒诺布尔,当时我的妻子在休假。因为有了运行 Linux 的东芝笔记本,我可以带着我的工作一起走。那个时候我在几个大的项目上做了大量的 GIS 数据处理,我发现我可以在 PostGIS / PostgreSQL 上做同样的事情,比我们在加拿大家中使用的昂贵得多的商业 GIS 软件要快得多。大家都很开心,尤其是我。 + +这一路上发生的有趣的事情是,我们把另外两台电脑带到了法国 —— 我妻子的类似的东芝电脑(运行 XP,对她来说很好用)和我们孩子最近新买的东芝牌笔记本电脑,也运行 XP。也就在圣诞节过后,他们有一些朋友过来,无意中在他们的电脑上安装了一个讨厌的、无法清除的病毒。经过几个小时甚至几天后,我的一个孩子问我:“爸爸,我们就不能安装和你电脑上一样的东西吗?”然后,三个新的 Linux 用户就这样产生了。我的儿子,29 岁了,依然是一个快乐的 Linux 用户,我猜他有第四或第五台 Linux 笔记本电脑了,最后几台都是由 System 76 提供的。我的一个女儿三年前开始读法学院时被迫转换为 Windows,因为她所在的学校有一个强制性的测试框架,只能在 Windows 上运行,而且据称会检测虚拟机之类的东西(请不要让我开始骂人)。而我的另一个女儿被她的公司为她买的 Macbook Air 诱惑了。 + +哦,好吧,不可能全都赢了吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/5/my-linux-story + +作者:[Chris Hermansen][a] +选题:[lujun9972][b] +译者:[shiboi77](https://github.com/shiboi77) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clhermansen +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/terminal_command_linux_desktop_code.jpg?itok=p5sQ6ODE (Terminal command prompt on orange background) diff --git a/published/202107/20210606 How Real-World Apps Lose Data.md b/published/202107/20210606 How Real-World Apps Lose Data.md new file mode 100644 index 0000000000..9f8406d810 --- /dev/null +++ b/published/202107/20210606 How Real-World Apps Lose Data.md @@ -0,0 +1,59 @@ +[#]: subject: (How Real-World Apps Lose Data) +[#]: via: (https://theartofmachinery.com/2021/06/06/how_apps_lose_data.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) +[#]: collector: (lujun9972) +[#]: translator: (PearFL) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13598-1.html) + +现实中的应用程序是如何丢失数据? +====== + +![](https://img.linux.net.cn/data/attachment/album/202107/20/062734awvesw2nqnzrsw5i.jpg) + +现代应用程序开发的一大优点是,像硬件故障或如何设置 RAID 这类问题是由云提供商操心的。优秀的云供应商不太可能丢失你的应用数据,所以有时我会被询问现在为什么还要备份?下面是一些现实世界的故事。 + +### 故事之一 + +第一个故事来自一个数据科学项目:它基本上是一个从正在进行的研究中来收集数据的庞大而复杂的管道,然后用各种不同的方式处理以满足一些尖端模型的需要。这个面向用户的应用程序还没有推出,但是一个由数据科学家和开发人员组成的团队已经为建立这个模型和它的数据集工作了好几个月。 + +在项目中工作的人有他们自己的实验工作的开发环境。他们会在终端中做一些类似 `export ENVIRONMENT=simonsdev` 的事情,然后所有在终端上运行的软件都会在那个环境下运行,而不是在生产环境下。 + +该团队迫切需要推出一个面向用户的应用程序,以便那些花钱的人能够从他们几个月的投资中真正看到一些回报。在一个星期六,一位工程师试图赶工一些工作。他在晚上很晚的时候做完了一个实验,决定收拾东西回家。他启动了一个清理脚本来删除他的开发环境中的所有内容,但奇怪的是,这比平时花费了更长的时间。这时他意识到,他已经忘记了哪个终端被配置为指向哪个环境。(LCTT 译注:意即删除了生产环境。) + +### 故事之二 + +第二个故事来自于一个商业的网页和手机应用。后端有一个由一组工程师负责的微服务体系结构。这意味着部署需要协调,但是使用正式的发布过程和自动化简化了一些。新代码在准备好后会被审查并合并到主干中,并且高层开发人员通常会为每个微服务标记版本,然后自动部署到临时环境。临时环境中的版本会被定期收集到一个元版本中,在自动部署到生产环境之前,该版本会得到各个人的签署(这是一个合规环境)。 + +有一天,一位开发人员正在开发一个复杂的功能,而其他开发该微服务的开发人员都同意将他们正在开发的代码提交到主干,也都知道它还不能被实际发布。长话短说,并不是团队中的每个人都收到了消息,而代码就进入了发布管道。更糟糕的是,那些实验性代码需要一种新的方式来表示用户配置文件数据,因此它有一个临时数据迁移,它在推出到生产环境时运行,损坏了所有的用户配置文件。 + +### 故事之三 + +第三个故事来自另一款网页应用。这个有一个更简单的架构:大部分代码在一个应用程序中,数据在数据库中。然而,这个应用程序也是在很大的截止日期压力下编写的。事实证明,在开发初期,当彻底更改的数据库架构很常见时,添加一项功能来检测此类更改并清理旧数据,这实际上对发布前的早期开发很有用,并且始终只是作为开发环境的临时功能。不幸的是,在匆忙构建应用的其余部分并推出时,我们忘记了这些代码。当然,直到有一天它在生产环境中被触发了。 + +### 事后分析 + +对于任何故障的事后分析,很容易忽视大局,最终将一切归咎于一些小细节。一个特例是发现某人犯了一些错误,然后责怪那个人。这些故事中的所有工程师实际上都是优秀的工程师(雇佣 SRE 顾问的公司不是那些在长期雇佣中偷工减料的公司),所以解雇他们,换掉他们并不能解决任何问题。即使你拥有 100 倍的开发人员,它仍然是有限的,所以在足够的复杂性和压力下,错误也会发生。最重要的解决方案是备份,无论你如何丢失数据(包括来自恶意软件,这是最近新闻中的一个热门话题),它都能帮助你。如果你无法容忍没有副本,就不要只有一个副本。 + +故事之一的结局很糟糕:没有备份。该项目的六个月的数据收集白干了。顺便说一句,有些地方只保留一个每日快照作为备份,这个故事也是一个很好的例子,说明了这也会出错:如果数据丢失发生在星期六,并且你准备在星期一尝试恢复,那么一日备份就只能得到星期日的一个空数据备份。 + +故事之二并不算好,但结果要好得多。备份是可用的,但数据迁移也是可逆的。不好的部分是发布是在推出前完成的,并且修复工作必须在生产站点关闭时进行编码。我讲这个故事的主要原因是为了提醒大家,备份并不仅仅是灾难性的数据丢失。部分数据损坏也会发生,而且可能会更加混乱。 + +故事之三还好。尽管少量数据永久丢失,但大部分数据可以从备份中恢复。团队中的每个人都对没有标记极其明显的危险代码感到非常难过。我没有参与早期的开发,但我感觉很糟糕,因为恢复数据所需的时间比正常情况要长得多。如果有一个经过良好测试的恢复过程,我认为该站点应该在总共不到 15 分钟的时间内重新上线。但是第一次恢复没有成功,我不得不调试它为什么不能成功,然后重试。当一个生产站点宕机了,需要你重新启动它,每过 10 秒钟都感觉过了一个世纪。值得庆幸的是,老板们比某些人更能理解我们。他们实际上松了一口气,因为这一场可能使公司沉没的一次性灾难只导致了几分钟的数据丢失和不到一个小时的停机时间。 + +在实践中,备份“成功”但恢复失败的情况极为普遍。很多时候,小型数据集上进行恢复测试是可以正常工作的,但在生产规模的大数据集上就会失败。当每个人都压力过大时,灾难最有可能发生,而生产站点的故障只会增加压力。在时间合适的时候测试和记录完整的恢复过程是一个非常好的主意。 + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2021/06/06/how_apps_lose_data.html + +作者:[Simon Arneaud][a] +选题:[lujun9972][b] +译者:[PearFL](https://github.com/PearFL) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://theartofmachinery.com +[b]: https://github.com/lujun9972 diff --git a/published/202107/20210612 How to get KDE Plasma 5.22 in Kubuntu 21.04 Hirsute Hippo.md b/published/202107/20210612 How to get KDE Plasma 5.22 in Kubuntu 21.04 Hirsute Hippo.md new file mode 100644 index 0000000000..9a49de936f --- /dev/null +++ b/published/202107/20210612 How to get KDE Plasma 5.22 in Kubuntu 21.04 Hirsute Hippo.md @@ -0,0 +1,112 @@ +[#]: subject: (How to get KDE Plasma 5.22 in Kubuntu 21.04 Hirsute Hippo) +[#]: via: (https://www.debugpoint.com/2021/06/plasma-5-22-kubuntu-21-04/) +[#]: author: (Arindam https://www.debugpoint.com/author/admin1/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13621-1.html) + +如何在 Kubuntu 21.04 中安装和升级 KDE Plasma 5.22 +====== + +> KDE 团队启用了向后移植 PPA,你可以使用它在 Kubuntu 21.04 Hirsute Hippo 中安装和升级到 KDE Plasma 5.22。 + +![Kubnutu 21.04 running with KDE Plasma 5.22][1] + +KDE 团队最近发布了 KDE Plasma 5.22,其中有相当多的增强功能、错误修复以及更新的 KDE 框架和应用版本。这个版本带来了一些改进,如面板的自适应透明度,文件操作弹出时的用户友好通知,“发现”中的软件包类型显示,各种 Wayland 的变化等。在 [这里][2] 查看更多关于功能细节。 + +如果你正在运行 Kubuntu 21.04 Hirsute Hippo,或者在 [Ubuntu 21.04 Hirsute Hippo][3] 中安装了自定义的 KDE Plasma,你可以通过以下步骤升级到最新版本。目前的 Hirsute Hippo 系列提供了先前版本 KDE Plasma 5.21.04 与 KDE Framework 5.80。 + +### 在 Kubuntu 21.04 Hirsute Hippo 中安装 KDE Plasma 5.22 的步骤 + +按照下面的步骤进行。 + +如果你想使用图形方法,那么在“发现”中将 `ppa:kubuntu-ppa/backports` 添加到软件源,然后点击“更新”。 + +或者,使用下面的终端方法,以加快安装速度。 + + * **步骤 1**:打开一个终端,添加下面的 KDE Backports PPA。 + + ``` + sudo add-apt-repository ppa:kubuntu-ppa/backports + ``` + + * **步骤 2**:然后运行以下程序来启动系统升级。这将在你的 Hirsute Hippo 系统中安装最新的 KDE Plasma 5.22。 + + ``` + sudo apt update + sudo apt full-upgrade + ``` + + ![Upgrade to Plasma 5.22][8] + + * **步骤 3**:更新后重新启动,你应该会看到一个更新的 KDE Plasma 5.22 桌面。 + +考虑到这是整个桌面环境的完整版本升级,安装可能需要一些时间。 + +### 在 Ubuntu 21.04 中安装 KDE Plasma 5.22 + +如果你正在运行基于 GNOME 的默认 Ubuntu 21.04 Hirsute Hippo 桌面,你可以使用这个 PPA 来安装最新的 KDE Plasma。下面是方法。 + +打开终端,添加 PPA(像上面的步骤那样)。 + +``` +sudo add-apt-repository ppa:kubuntu-ppa/backports +``` + +然后,刷新软件包。 + +``` +sudo apt update +``` + +然后运行下面的程序来安装 Kubuntu 桌面。 + +``` +sudo apt install kubuntu-desktop +``` + +这将在 Ubuntu 21.04 中与 GNOME 一起安装 KDE Plasma 桌面。 + +### Ubuntu 20.04 LTS 中的 KDE Plasma 5.22 + +Ubuntu 20.04 LTS 版拥有早期的 KDE Plasma 5.18、KDE Framework 5.68、KDE Applications 19.12.3。所以,在它的整个生命周期中,它不会收到最新的 KDE 更新。所以,从技术上讲,你可以添加上述 PPA 并安装 KDE Plasma 5.22。但我不建议这样做,因为不兼容的软件包、框架可能会导致系统不稳定。 + +所以,建议你使用 Kubuntu 21.04 和上面的向后移植 PPA 或者使用 KDE neon 来体验最新的 Plasma 桌面。 + +### 卸载 KDE Plasma 5.22 + +如果你改变主意,想回到 KDE Plasma 的原始版本,那么安装 `ppa-purge` 并清除 PPA。这将使软件包降级,并启用仓库版本。 + +``` +sudo apt install ppa-purge +sudo ppa-purge ppa:kubuntu-ppa/backports +sudo apt update +``` + +### 结束语 + +我希望这个快速指南能帮助你在 Kubuntu 21.04 Hirsute Hippo 中安装最新的 KDE Plasma 5.22。这可以让你体验到最新的 KDE 技术以及 KDE 框架和应用。然而,你应该知道,并不是所有的功能都应该在向后移植 PPA 中提供,它只有选定的功能和错误修复,这才能通过回归测试并安全使用。也就是说,你总是可以把 KDE Neon 安装成一个全新的系统来享受 KDE 的最新技术。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2021/06/plasma-5-22-kubuntu-21-04/ + +作者:[Arindam][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lujun9972 +[1]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/Kubutu-21.04-running-with-KDE-Plasma-5.22-1024x531.jpg +[2]: https://www.debugpoint.com/2021/06/kde-plasma-5-22-release/ +[3]: https://www.debugpoint.com/2021/04/ubuntu-21-04-hirsute-hippo-release/ +[4]: tmp.wazjcS11If#plasma-kubuntu-2104 +[5]: tmp.wazjcS11If#plasma-ubuntu-2104 +[6]: tmp.wazjcS11If#plasma-ubuntu-2004 +[7]: tmp.wazjcS11If#uninstall-stock-version +[8]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/Upgrade-to-Plasma-5.22.jpg \ No newline at end of file diff --git a/published/202107/20210614 What is a CI-CD pipeline.md b/published/202107/20210614 What is a CI-CD pipeline.md new file mode 100644 index 0000000000..e6bd3657fa --- /dev/null +++ b/published/202107/20210614 What is a CI-CD pipeline.md @@ -0,0 +1,82 @@ +[#]: subject: (What is a CI/CD pipeline?) +[#]: via: (https://opensource.com/article/21/6/what-cicd-pipeline) +[#]: author: (Will Kelly https://opensource.com/users/willkelly) +[#]: collector: (lujun9972) +[#]: translator: (baddate) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13541-1.html) + +CI/CD 管道是什么? +====== + +> 你如何定义持续集成/持续部署管道取决于你组织的要求。 + +![Plumbing tubes in many directions][1] + +持续集成continuous integration/持续部署continuous deployment(CI/CD)管道是每个 DevOps 计划的基础。 CI/CD 管道打破了传统的开发孤岛,使开发和运营团队能够在整个软件开发生命周期中进行协作。 + +更好的是,转向 DevOps 和 CI/CD 管道可以帮助你的组织以更高的速度更安全地 [交付软件][2]。 + +### 拆解 CI/CD 管道 + +CI/CD 管道有很多定义,所以我总是建议组织定义自己的 CI/CD 管道版本和其他 DevOps 概念,而不是使用其他人的。开源 CI/CD 工具为你提供构建满足组织要求的 CI/CD 管道的自由和选择。 + +形成 CI/CD 管道的阶段是将不同的任务子集分组为 _管道阶段_。典型的管道阶段包括: + + * **构建**:开发人员编译应用程序代码。 + * **测试**:质量保证(QA)团队使用自动化测试工具和策略测试应用程序代码。 + * **发布**:开发团队将应用程序代码交付到代码库。 + * **部署**:DevOps 团队将应用程序代码分阶段投入生产。 + * **安全性和合规性**:QA 团队根据项目要求验证构建。这是组织部署容器扫描工具的阶段,这些工具根据常见漏洞和暴露Common Vulnerabilities and Exposures(CVE)检查容器镜像的质量。 + +这些是 CI/CD 管道的标准阶段,但一些组织调整 CI/CD 管道模型以满足他们的要求。例如,为医疗保健市场构建应用程序的组织,具有严格的合规性标准,可以在整个工具链中分发测试、验证和合规性门槛。 + +其他示例可能是依赖于具有开源软件(OSS)的复杂软件供应链的组织。商业组件可能会设立一个门槛,开发团队成员可以在其中为 OSS 包生成 [软件物料清单][3]software bill of materials(SBOM),或者外部商业软件供应商必须将 SBOM 作为其合同可交付成果的一部分进行交付。 + +### CI/CD 管道的障碍 + +实施 CI/CD 管道会改变团队的流程和文化。尽管许多开发人员愿意接受某些任务和测试的自动化,但人员可能成为采用 CI/CD 的障碍。 + +从瀑布式流程转向 CI/CD 可能会动摇某些组织中基本的和隐含的权力结构。由于 CI/CD 管道提高了软件交付速度,旧手动流程的“守门人”可能会受到这种变化的威胁。 + +### 整合机会 + +随着你在文化、流程和工具中达到更高的 DevOps 成熟度水平,包含 CI/CD 工具链的工具的开源根源为一些激动人心的集成创造了机会。 + +分析公司 Forrester 在 2020 年预测,即时学习just-in-time learning将加入 CI/CD 管道。如果你考虑一下,会发现这是有道理的。在当前远程工作的时代,甚至对于新员工的远程入职,这更有意义。例如,组织可以将文档 wiki 与内部流程文档集成到其管道中。 + +更雄心勃勃的组织可以将学习管理系统(LMS)(例如 [Moodle][4])集成到其 CI/CD 管道中。它可以使用 LMS 发布有关新 DevOps 工具链功能的简短视频,开发人员在加入时或在整个管道中更新工具时需要学习这些功能。 + +一些组织正在将群聊和其他协作工具直接集成到他们的 CI/CD 管道中。聊天平台提供警报并支持团队之间的协作和沟通。将 Mattermost、Rocket.Chat 或其他 [企业聊天][5] 平台集成到你的 CI/CD 管道中需要预先规划和分析,以确保管道用户不会被警报淹没。 + +另一个需要探索的集成机会是将分析和高级报告构建到你的 CI/CD 管道中。这有助于你利用通过管道传输的数据。 + +### 总结 + +CI/CD 管道是 DevOps 的基础。开源使其能够适应并灵活地满足你在 DevOps 之旅中实施的运营变更所产生的新需求。 + +我希望看到对统一 DevOps 平台趋势的开源响应,在这种趋势中,组织寻求端到端的 CI/CD 解决方案。这种解决方案的要素就在那里。毕竟,GitLab 和 GitHub 将他们的平台追溯到开源根源。 + +最后,不要忘记每一个成功的 CI/CD 工具链背后的教育和外展。记录你的工具链和相关流程将改善开发人员入职和持续的 DevOps 团队培训。 + +你和你的组织如何定义你的 CI/CD 工具链?请在评论中分享你的反馈。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/what-cicd-pipeline + +作者:[Will Kelly][a] +选题:[lujun9972][b] +译者:[baddate](https://github.com/baddate) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/willkelly +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/plumbing_pipes_tutorial_how_behind_scenes.png?itok=F2Z8OJV1 (Plumbing tubes in many directions) +[2]: https://techbeacon.com/devops/5-reasons-why-cicd-vital-your-organizations-value-stream +[3]: https://www.ntia.gov/SBOM +[4]: https://moodle.org/ +[5]: https://opensource.com/alternatives/slack \ No newline at end of file diff --git a/published/202107/20210616 Hash Linux- Arch Linux Preconfigured With Xmonad, Awesome, i3, and Bspwm Window Manager.md b/published/202107/20210616 Hash Linux- Arch Linux Preconfigured With Xmonad, Awesome, i3, and Bspwm Window Manager.md new file mode 100644 index 0000000000..61b12247ce --- /dev/null +++ b/published/202107/20210616 Hash Linux- Arch Linux Preconfigured With Xmonad, Awesome, i3, and Bspwm Window Manager.md @@ -0,0 +1,137 @@ +[#]: subject: "Hash Linux: Arch Linux Preconfigured With Xmonad, Awesome, i3, and Bspwm Window Manager" +[#]: via: "https://itsfoss.com/hash-linux-review/" +[#]: author: "Sarvottam Kumar https://itsfoss.com/author/sarvottam/" +[#]: collector: "lujun9972" +[#]: translator: "mcfd" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13608-1.html" + +Hash Linux:预配置了四种平铺窗口管理器的 Arch Linux 衍生版 +====== + +![](https://img.linux.net.cn/data/attachment/album/202107/23/112405tt57nu7neuddkk7k.jpg) + +通过一些努力,[你能安装上 Arch Linux][1],也可以在你的 Arch 系统上安装一个你选择的桌面环境或窗口管理器。 + +这需要一些时间和精力,但肯定是可以实现的。但是,有一些项目可以减轻你的痛苦,为你提供一个预先配置好的桌面环境或窗口管理器的系统。[ArcoLinux][2] 就是这样一个例子。 + +最近,我发现了另一个项目,它只专注于在出色的 Arch 发行版上提供完善的窗口管理器的选择。 + +[Hash 项目][3] 提供了四种预配置有平铺式窗口管理器的 Arch 变体:Awesome、[Xmonad][4]、 i3 和 Bspwm。 + +如果你是一个刚刚接触窗口管理器的人,Hash 项目绝对是你应该马上尝试的。不用先投入时间去配置它,你就可以深入探索窗口管理器,并习惯由键盘驱动的系统。 + +在本文中,我将讨论我在使用 **Hash Linux Xmonad 版本** 时的部分体验,该版本采用 Linux 5.12 的内核。 + +### 安装 Hash Linux + +Hash Linux 四个版本的 ISO 镜像均可 [下载][5] ,适用于 x86_64 系统架构。 + +为了避免在实体机上安装时出现的各种意外错误,我在 GNOME Boxes 中创建了一个 Hash Linux Xmonad 版本的虚拟机。 + +当我启动到 Hash Linux 时,我注意到两件事。首先是一个面板,提供用于管理窗口和命令的快捷方式。我将在安装后讨论它。其次,是一个漂亮且易于使用的 GUI 安装程序。 + +![Hash Linux GUI Installer][6] + +像其他衍生版一样,图形化的安装程序使安装过程非常顺畅。在几个步骤的配置中,Hash Linux 已安装完毕,并准备重新启动。 + +![Installer Welcome Page][7] + +### 第一印象 + +![Hash Linux][8] + +如果你曾经在你的 Linux 系统上安装过 Xmonad 窗口管理器,那么你重启后首先看到的是什么?空白的屏幕吧。 + +如果你是一个初学者,或者你不知道默认的按键绑定,你会被卡在一个屏幕上。因此,在使用任何窗口管理器之前,你必须先阅读其键盘快捷键。 + +如果你想把所有重要的快捷键提示都放在窗口上呢?一个备忘单可以为你节省很多时间。 + +因此,为了简化和方便初学者,Hash Linux 将重要的快捷键都钉在了桌面上。 + +所以,让我们先尝试其中的一些。从最重要的一个开始 `Super+Enter`,它可以打开默认的 termite 终端模拟器与 Z shell(ZSH)。 + +如果你多次按下它,你会发现默认情况下 Xmonad 遵循一个缩减布局,它首先将一个窗口固定在右边,然后以同样的方式将其余的全部安排在左边。 + +![Xmonad default layout][9] + +按下 `Super+Space`,你也可以将当前的布局改为标签式布局。甚至你可以按下 `Super+leftclick` 将窗口拖动。 + +![Moved to float][10] + +要退出当前的窗口,你可以按下 `Super+Q`。 + +### Hash Linux 中的应用 + +默认情况下,Hash Linux 包含几个有用的命令行工具,如:NeoFetch、Htop、Vim、Pacman、Git 和 Speedtest-cli。 + +![Htop][11] + +它还拥有大量的图形应用程序,如:Firefox 89、Gparted、Nitrogen、Conky、Flameshot、Geany 和 CPU-X。 + +`Super+D` 是 Hash Linux 中打开应用程序搜索菜单的默认快捷键。 + +![Application search menu][12] + +### 主题美化 + +Hash Cyan 是 Hash Linux 的默认主题。除了它之外,Hash Linux 还提供了另外四个主题:Light Orange、Sweet Purple、Night Red 和 Arch Dark。 + +Hash Theme Selector 是一个自制的 Hash Linux 应用程序,你可以用它来配置窗口管理器的主题。 + +![Hash Theme Selector][13] + +### 升级 Hash Linux + +作为一个滚动发行版,你不需要下载一个新的 Hash Linux 的 ISO 来更新现有系统。你唯一需要的是在终端运行 ` upgrade` 命令来升级你的系统。 + +![upgrading hash linux][14] + +### 结束语 + +如果你想使用一个窗口管理器来代替桌面环境,但又不想花很多时间来配置它,Hash 项目可以节省你的时间。 + +首先,它可以节省你大量的配置时间和精力,其次,它可以很轻松地让你适应使用键盘控制的系统。以后,你肯定可以学会根据自己的需要进行配置。 + +由于 Hash Linux 已经提供了 4 个带有不同的窗口管理器的 ISO,你可以开始使用任何一个版本,并找到你最喜欢的一个版本。总的来说,它是一个 [很好的 Arch Linux 衍生版][15]。 + +最后我还要提一下,目前 Hash Linux 的官方 [网站][3] 并没有包含很多关于它的信息。 + +![][16] + +在发布信息中也提到了一个早期的 [网站][17](我现在无法访问),在我上次访问时,其中包含了许多关于它的信息,包括配置细节等。 + +不想入 Arch 的教,只想用平铺式窗口管理器?可以试试 [Regolith Linux][18] 。它是预先配置了 i3wm 的 Ubuntu。棒极了,对吧? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/hash-linux-review/ + +作者:[Sarvottam Kumar][a] +选题:[lujun9972][b] +译者:[mcfd](https://github.com/mcfd) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/sarvottam/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/install-arch-linux/ +[2]: https://arcolinux.com/ +[3]: https://hashproject.ga/ +[4]: https://xmonad.org/ +[5]: https://hashproject.ga/index.html#downloads +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/Hash-Linux-GUI-Installer.jpg?resize=800%2C451&ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/Installer-Welcome-Page.png?resize=800%2C452&ssl=1 +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/Hash-Linux.jpg?resize=800%2C451&ssl=1 +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/Xmonad-default-layout.png?resize=800%2C452&ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/Moved-to-float.png?resize=800%2C452&ssl=1 +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/Htop.jpg?resize=800%2C451&ssl=1 +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/Application-search-menu.jpg?resize=800%2C451&ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/Hash-Theme-Selector.png?resize=800%2C452&ssl=1 +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/Upgrading-hash-linux.png?resize=800%2C452&ssl=1 +[15]: https://itsfoss.com/arch-based-linux-distros/ +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/Hash-Linux-Site-URL.png?resize=575%2C193&ssl=1 +[17]: https://hashproject.org/ +[18]: https://itsfoss.com/regolith-linux-desktop/ diff --git a/published/202107/20210621 Jim Hall- How Do You Fedora.md b/published/202107/20210621 Jim Hall- How Do You Fedora.md new file mode 100644 index 0000000000..75a941404f --- /dev/null +++ b/published/202107/20210621 Jim Hall- How Do You Fedora.md @@ -0,0 +1,79 @@ +[#]: subject: (Jim Hall: How Do You Fedora?) +[#]: via: (https://fedoramagazine.org/jim-hall-how-do-you-fedora/) +[#]: author: (Karimi Hari Priya https://fedoramagazine.org/author/haripriya21/) +[#]: collector: (lujun9972) +[#]: translator: (zz-air) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13558-1.html) + +Jim Hall,你觉得 Fedora 怎么样? +====== + +![][1] + +我们最近采访了 Jim Hall,了解他是如何使用 Fedora 的。这个 Fedora 杂志 [系列][2] 中的一篇。该系列介绍了 Fedora 用户以及他们如何使用 Fedora 来完成任务。如果你对本系列的后继采访感兴趣,请通过 [反馈表][3] 与我们联系。 + +### Jim Hall 是谁? + +Jim Hall 曾担任高等教育和政府部门的首席信息官超过 8 年,最近创办了咨询公司 [Hallmentum][4]。他的大部分工作包括培训、研讨会和指导,帮助新的 IT 领导者发展领导技能,也帮助当前的 IT 领导者更好地发挥领导力。除了咨询,Jim 还担任大学的兼职教师,目前教授管理信息系统(MIS)和技术与专业写作课程。 + +Jim 是如何成长的? Jim 童年时代的英雄来自电视和电影,包括蝙蝠侠和汉索罗。Jim 长期以来最喜欢看的电影是《星球大战:新希望》。Jim 说:“我是一个星球大战迷。”Jim 最喜欢吃意大利菜,“我喜欢意大利菜!我最喜欢的意大利菜可能是炖鸡”。Jim 的观点是,诚实、创造力、想象力、好奇心和开放性是一个人所能拥有的五个好品质。 + +他喜欢写作,非常好的是他的日常工作主要是写作。他花了很多时间为像 OpenSource.com、 CloudSavvy IT 和 Linux Magazine 等网站撰写“如何”类文章。现在他正在写一本关于 C 编程的书。除了写作,他还玩电子游戏来放松。他有一台 PlayStation 4 游戏机,大多数周六下午他都会坐在电视机前玩游戏。 + +### Fedora 社区 + +Jim 从 1993 年开始使用 Linux。他的第一个 Linux 发行版是 Softlanding Linux System(SLS)1.03,运行 Linux 内核 0.99,补丁级别 11。“从那以后,我一直是家里的全职 Linux 用户”。Jim 在很久以前参加了 Fedora Core 时代的一个 Linux 会议之后,开始更多参与到 Fedora 中。Jim 在这遇见了 Tom “Spot” Callaway,他们开始谈论 Fedora。“Spot 鼓励我用另一种方式来做贡献:找到 bug 并报告它们。这就是我参与测试所有 Beta 版本的原因”。 + +Jim 想在 Fedora 改变什么? 他想在 getfedora.com 上看到一个倒计时,告诉大家新的 Beta 版本或新的完整版本是什么时候发布的,这是 Fedora 项目的一个改变。并且 Jim 想让人们都知道,使用 Fedora 是多么容易。“对开源做出贡献最具挑战性的事情是,弄清楚如何做出他们的第一个贡献。”Jim 补充道,“我不知道我和其他开发人员一样是‘Fedora 项目成员’。我只是个用户。但是作为一个从 1993、1994 年就开始参与开发开源软件的人,我努力成为社区中一个有用的成员。因此,我利用一切机会尝试新的 Fedora 版本,甚至是 Beta 版,如果我发现问题,就会告诉大家。” + +### 你用什么硬件? + +Jim 目前正在运行一台 ThinkCentre M720 Tiny。它配置了第 8 代酷睿 i3-8100T(3.10GHz,6MB 缓存)、32GB(16GB + 16GB)DDR4 2666MHz、英特尔显卡、256GB 固态硬盘 PCIe-NVME Opal M.2、英特尔 8265 802.11AC 和 蓝牙 4.2。他的显示器是华硕 VE248H。 Jim 说:“这一切在Fedora上都很好用!”。 + +他使用 Perixx Periboard-512 人体工程学经典分体式键盘,它从 1998 年开始取代了他最初的微软 Natural Keyboard Elitee PS/2 键盘。Jim 说: “我有时候会把我的 Perixx 键盘换成 Unicomp 的 IBM Model M USB 克隆键盘。我很喜欢这种带有扣动式弹簧动作的点击式键盘。我的是‘灰白色’,所以它有种经典的外观和感觉” + +### 你用什么软件? + +Jim 目前运行的是 Fedora 33,之前是 Fedora 33 Beta 和 Fedora 32。Jim 说:“我使用 GNOME 3 作为我的桌面。我发现默认设置适合我的大多数需求,所以我没有加载任何 GNOME 扩展,但我确实使用‘设置’和 ‘GNOME Tweaks’ 调整了一些东西。所以我没有做什么大的改变。例如,我将默认用户界面字体改为使用 Droid Sans Regular 字体。并且我用‘设置’来改变键盘快捷键,用 `Alt-Tab` 键来切换窗口,而不是切换应用程序。我是在 `Alt-Tab` 工作流程中长大的,所以我已经习惯了。”他使用火狐和谷歌浏览器来作为他的 Web 浏览器。 + +为了经营他的咨询业务,Jim 依赖于一套应用程序: + + * 使用 [LibreOffice][5] 去写他的书。例如,他去年出版了 《[Coaching Buttons][6]》,他完全使用 LibreOffice 来写这本书。最近他写了一本关于 [用 C 语言编写 FreeDOS 程序的书][7] 也用了 LibreOffice 。 + ![Libre Office Writer][15] + * [INKSCAPE][8] 为他创建了矢量格式的公司标志。他的标志可以完美地放大缩小,从文件上的小角落图像到大幅面的海报或横幅。并且 INKSCAPE 允许他导出各种通用格式。Jim 说他的广告合作伙伴很欣赏 INKSCAPE 可以输出到EPS(Encapsulated Postscript),这使得在产品上打印他的标志变得很容易。 + * [GIMP][9] 用于其他图形,例如闪屏图片。“我的闪屏图片是我们公司的标志被放在了背景照片上,在我需要额外装饰的地方,比如印刷材料,我用它来替代普通标志。我也在我的网站上使用了闪屏图片的一个版本”。 + * [QEMU][10] 用来运行虚拟机,在他那里可以启动 [FreeDOS][11]。“我喜欢使用 QEMU,因为我可以在命令行中设置所有需要的选项,这使我在配置虚拟机时有了很大的灵活性。为了更方便,我将所有选项放入到一个脚本中,用它来运行QEMU,每次都是相同的选项”。 + ![QEMU – running as easy as in FreeDOS][14] + * [Scribus][12] 是用来打印产品的。Scribus 很容易用来创建具有“全出血”的印刷品,这意味着任何颜色的背景都会与纸张的边缘重叠。全出血需要一个特殊的打印准备文件,与打印区域重叠。它甚至还提供了切割标记,以便打印机准确地知道要修剪的位置。 + ![Scribus – Postcard][13] + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/jim-hall-how-do-you-fedora/ + +作者:[Karimi Hari Priya][a] +选题:[lujun9972][b] +译者:[zz-air](https://github.com/zz-air) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/haripriya21/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/12/PXL_20200929_205044670.PORTRAIT-01.COVER_-816x345.jpg +[2]: https://fedoramagazine.org/tag/how-do-you-fedora +[3]: https://fedoramagazine.org/submit-an-idea-or-tip +[4]: https://hallmentum.com/ +[5]: https://www.libreoffice.org/ +[6]: https://www.amazon.com/Coaching-Buttons-Jim-Hall/dp/0359834930 +[7]: https://www.freedos.org/books/ +[8]: https://inkscape.org/ +[9]: https://www.gimp.org/ +[10]: https://www.qemu.org/ +[11]: https://www.freedos.org/ +[12]: https://www.scribus.net/ +[13]: https://fedoramagazine.org/wp-content/uploads/2021/03/Scribus-postcard-1024x576.png +[14]: https://fedoramagazine.org/wp-content/uploads/2021/03/QEMU-running-AsEasyAs-in-FreeDOS.png +[15]: https://fedoramagazine.org/wp-content/uploads/2021/03/LibreOffice-Writer-book-1-1024x576.png diff --git a/published/202107/20210621 Replace man pages with Tealdeer on Linux.md b/published/202107/20210621 Replace man pages with Tealdeer on Linux.md new file mode 100644 index 0000000000..38fdafe103 --- /dev/null +++ b/published/202107/20210621 Replace man pages with Tealdeer on Linux.md @@ -0,0 +1,131 @@ +[#]: subject: (Replace man pages with Tealdeer on Linux) +[#]: via: (https://opensource.com/article/21/6/tealdeer-linux) +[#]: author: (Sudeshna Sur https://opensource.com/users/sudeshna-sur) +[#]: collector: (lujun9972) +[#]: translator: (ddl-hust) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13570-1.html) + +在 Linux 上使用 Tealdeer 替代手册页 +====== + +> Tealder 是 Rust 版本的 tldr,对常用的命令提供了易于理解的说明信息。 + +![](https://img.linux.net.cn/data/attachment/album/202107/11/204638catii1ro21jmjzmi.jpg) + +手册页是我开始探索 Linux 时最常用的资源。当然,对于初学者熟悉命令行指令而言,`man` 是最频繁使用的指令。但是手册页中有大量的选项和参数列表,很难被解读,这使得你很难理解你想知道的东西。如果你想要一个更简单的解决方案,有基于例子的输出,我认为 [tldr][2] (太长不读too long dnot's read)是最好的选择。 + +### Tealdeer 是什么? + +[Tealdeer][3] 是 tldr 的一个基于 Rust 的实现。它是一个社区驱动的手册页,给出了非常简单的命令工作原理的例子。Tealdeer 最棒的地方在于它几乎包含了所有你通常会用到的命令。 + +### 安装 Tealdeer + +在 Linux 系统,你可以从软件仓库安装 Tealdeer,比如在 [Fedora][4] 上: + +``` +$ sudo dnf install tealdeer +``` + +在 macOS 可以使用 [MacPorts][5] 或者 [Homebrew][6]。 +同样,你可以使用 Rust 的 Cargo 包管理器来编译和安装此工具: + +``` +$ cargo install tealdeer +``` + +### 使用 Tealdeer + +输入 `tldr-list` 返回 tldr 所支持的手册页,比如 `touch`、`tar`、`dnf`、`docker`、`zcat`、`zgrep` 等: + +``` +$ tldr --list +2to3 +7z +7za +7zr +[ +a2disconf +a2dismod +a2dissite +a2enconf +a2enmod +a2ensite +a2query +[...] +``` + +使用 `tldr` 跟上具体的命令(比如 `tar` )能够显示基于示例的手册页,描述了你可以用该命令做的所有选项。 + +``` +$ tldr tar + + Archiving utility. + Often combined with a compression method, such as gzip or bzip2. + More information: . + + [c]reate an archive and write it to a [f]ile: + + tar cf target.tar file1 file2 file3 + + [c]reate a g[z]ipped archive and write it to a [f]ile: + + tar czf target.tar.gz file1 file2 file3 + + [c]reate a g[z]ipped archive from a directory using relative paths: + + tar czf target.tar.gz --directory=path/to/directory . + + E[x]tract a (compressed) archive [f]ile into the current directory [v]erbosely: + + tar xvf source.tar[.gz|.bz2|.xz] + + E[x]tract a (compressed) archive [f]ile into the target directory: + + tar xf source.tar[.gz|.bz2|.xz] --directory=directory + + [c]reate a compressed archive and write it to a [f]ile, using [a]rchive suffix to determine the compression program: + + tar caf target.tar.xz file1 file2 file3 +``` + +如需控制缓存: + +``` +$ tldr --update +$ tldr --clear-cache +``` + +你能够控制 Tealdeer 输出的颜色选项,有三种模式选择:一直、自动、从不。默认选项是自动,但我喜欢颜色提供的额外信息,所以我在我的 `~/.bashrc `文件中增加了这个别名: + +``` +alias tldr='tldr --color always' +``` +### 结论 + +Tealdeer 的美妙之处在于不需要网络连接就可以使用,只有更新缓存的时候才需要联网。因此,即使你处于离线状态,依然能够查找和学习你新学到的命令。更多信息,请查看该工具的 [说明文档][8]。 + +你会使用 Tealdeer 么?或者你已经在使用了?欢迎留言让我们知道。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/tealdeer-linux + +作者:[Sudeshna Sur][a] +选题:[lujun9972][b] +译者:[ddl-hust](https://github.com/ddl-hust) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sudeshna-sur +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/features_solutions_command_data.png?itok=4_VQN3RK (computer screen ) +[2]: https://github.com/tldr-pages/tldr +[3]: https://github.com/dbrgn/tealdeer +[4]: https://src.fedoraproject.org/rpms/rust-tealdeer +[5]: https://opensource.com/article/20/11/macports +[6]: https://opensource.com/article/20/6/homebrew-mac +[7]: https://www.gnu.org/software/tar\> +[8]: https://dbrgn.github.io/tealdeer/intro.html diff --git a/published/202107/20210624 Copy files between Linux and FreeDOS.md b/published/202107/20210624 Copy files between Linux and FreeDOS.md new file mode 100644 index 0000000000..55fe83b30b --- /dev/null +++ b/published/202107/20210624 Copy files between Linux and FreeDOS.md @@ -0,0 +1,122 @@ +[#]: subject: (Copy files between Linux and FreeDOS) +[#]: via: (https://opensource.com/article/21/6/copy-files-linux-freedos) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13548-1.html) + +在 Linux 和 FreeDOS 之间复制文件 +====== + +> 下面是我如何在我的 FreeDOS 虚拟机和 Linux 桌面系统之间传输文件。 + +![](https://img.linux.net.cn/data/attachment/album/202107/04/181327bfvv3mmzby9z2dpr.jpg) + +我运行 Linux 作为我的主要操作系统,我在一个虚拟机中启动 FreeDOS。大多数时候,我使用 QEMU 作为我的 PC 模拟器,但有时我会用 GNOME Boxes(它使用 QEMU 作为后端虚拟机)或用 VirtualBox 运行其他实验。 + +我喜欢玩经典的 DOS 游戏,有时我也会调出一个最喜欢的 DOS 应用。我在管理信息系统(MIS)课上讲计算机的历史,有时我会用 FreeDOS 和一个传统的 DOS 应用录制一个演示,比如 As-Easy-As(我最喜欢的 DOS 电子表格,曾经作为“共享软件”发布,但现在可以 [从 TRIUS 公司免费获得][2])。 + +但是以这种方式使用 FreeDOS 意味着我需要在我的 FreeDOS 虚拟机和我的 Linux桌 面系统之间传输文件。让我来展示是如何做到这一点的。 + +### 用 guestmount 访问镜像 + +我曾经通过计算第一个 DOS 分区的偏移量来访问我的虚拟磁盘镜像,然后用正确的选项组合来调用 Linux 的 `mount` 命令来匹配这个偏移量。这总是很容易出错,而且不是很灵活。幸运的是,有一个更简单的方法可以做到这一点。来自 [libguestfs-tools][3] 包的 `guestmount` 程序可以让你从 Linux 中访问或 _挂载_ 虚拟磁盘镜像。你可以在 Fedora 上用这个命令安装 `libguestfs-tools`: + +``` +$ yum install libguestfs-tools libguestfs +``` + +使用 `guestmount` 并不像从 GNOME 文件管理器中双击文件那么简单,但命令行的使用并不难。`guestmount` 的基本用法是: + +``` +$ guestmount -a image -m device mountpoint +``` + +在这个用法中,`image` 是要使用的虚拟磁盘镜像。在我的系统中,我用 `qemu-img` 命令创建了 QEMU 虚拟磁盘镜像。`guestmount` 程序可以读取这种磁盘镜像格式,以及 GNOME Boxes 使用的 QCOW2 镜像格式,或者 VirtualBox 使用的 VDI 镜像格式。 + +`device` 选项表示虚拟磁盘上的分区。想象一下,把这个虚拟磁盘当作一个真正的硬盘使用。你可以用 `/dev/sda1` 访问第一个分区,用 `/dev/sda2` 访问第二个分区,以此类推。这就是 `guestmount` 的语法。默认情况下,FreeDOS 1.3 RC4 在一个空的驱动器上创建了一个分区,所以访问这个分区的时候要用 `/dev/sda1`。 + +而 `mountpoint` 是在你的本地 Linux 系统上“挂载” DOS 文件系统的位置。我通常会创建一个临时目录来工作。你只在访问虚拟磁盘时需要挂载点。 + +综上所述,我使用这组命令从 Linux 访问我的 FreeDOS 虚拟磁盘镜像: + +``` +$ mkdir /tmp/freedos +$ guestmount -a freedos.img -m /dev/sda1 /tmp/freedos +``` + +之后,我可以通过 `/tmp/freedos` 目录访问我的 FreeDOS 文件,使用 Linux 上的普通工具。我可以在命令行中使用 `ls /tmp/freedos`,或者使用桌面文件管理器打开 `/tmp/freedos` 挂载点。 + +``` +$ ls -l /tmp/freedos +total 216 +drwxr-xr-x. 5 root root 8192 May 10 15:53 APPS +-rwxr-xr-x. 1 root root 85048 Apr 30 07:54 COMMAND.COM +-rwxr-xr-x. 1 root root 103 May 13 15:48 CONFIG.SYS +drwxr-xr-x. 5 root root 8192 May 15 16:52 DEVEL +drwxr-xr-x. 2 root root 8192 May 15 13:36 EDLIN +-rwxr-xr-x. 1 root root 1821 May 10 15:57 FDAUTO.BAT +-rwxr-xr-x. 1 root root 740 May 13 15:47 FDCONFIG.SYS +drwxr-xr-x. 10 root root 8192 May 10 15:49 FDOS +-rwxr-xr-x. 1 root root 46685 Apr 30 07:54 KERNEL.SYS +drwxr-xr-x. 2 root root 8192 May 10 15:57 SRC +-rwxr-xr-x. 1 root root 3190 May 16 08:34 SRC.ZIP +drwxr-xr-x. 3 root root 8192 May 11 18:33 TEMP +``` + +![GNOME file manager][4] + +*使用 GNOME 文件管理器来访问虚拟磁盘* + +例如,要从我的 Linux `projects` 目录中复制几个 C 源文件到虚拟磁盘镜像上的 `C:\SRC`,以便我以后能在 FreeDOS 下使用这些文件,我可以使用 Linux `cp` 命令: + +``` +$ cp /home/jhall/projects/*.c /tmp/freedos/SRC +``` + +虚拟驱动器上的文件和目录在技术上是不分大小写的,所以你可以用大写或小写字母来引用它们。然而,我发现使用所有大写字母来输入 DOS 文件和目录更为自然。 + +``` +$ ls /tmp/freedos +APPS CONFIG.SYS EDLIN FDCONFIG.SYS KERNEL.SYS SRC.ZIP +COMMAND.COM DEVEL FDAUTO.BAT FDOS SRC TEMP + +$ ls /tmp/freedos/EDLIN +EDLIN.EXE MAKEFILE.OW + +$ ls /tmp/freedos/edlin +EDLIN.EXE MAKEFILE.OW +``` + +### 用 guestmount 卸载 + +在你再次在虚拟机中使用虚拟磁盘镜像之前,你应该总是先 _卸载_。如果你在运行 QEMU 或 VirtualBox 时让镜像挂载,你有可能弄乱你的文件。 + +与 `guestmount` 配套的命令是 `guestunmount`,用来卸载磁盘镜像。只要给出你想卸载的挂载点就可以了: + +``` +$ guestunmount /tmp/freedos +``` + +请注意命令拼写与 Linux 的 `umount` 稍有不同。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/copy-files-linux-freedos + +作者:[Jim Hall][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jim-hall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/files_documents_paper_folder.png?itok=eIJWac15 (Files in a folder) +[2]: http://www.triusinc.com/forums/viewtopic.php?t=10 +[3]: https://libguestfs.org/ +[4]: https://opensource.com/sites/default/files/uploads/gnome-file-manager.png (Using GNOME file manager to access the virtual disk) +[5]: https://creativecommons.org/licenses/by-sa/4.0/ diff --git a/published/202107/20210624 View statistics about your code with Tokei.md b/published/202107/20210624 View statistics about your code with Tokei.md new file mode 100644 index 0000000000..290dddf1b4 --- /dev/null +++ b/published/202107/20210624 View statistics about your code with Tokei.md @@ -0,0 +1,195 @@ +[#]: subject: "View statistics about your code with Tokei" +[#]: via: "https://opensource.com/article/21/6/tokei" +[#]: author: "Sudeshna Sur https://opensource.com/users/sudeshna-sur" +[#]: collector: "lujun9972" +[#]: translator: "zepoch" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13554-1.html" + +使用 Tokei 查看有关代码的统计信息 +====== + +> 了解有关项目编程语言的详细信息。 + +![](https://img.linux.net.cn/data/attachment/album/202107/06/114306ar6zjnrr92rn2vnz.jpg) + +近来,GitHub 添加了一个小指标来展示项目的细节,包括项目使用的编程语言。在这之前,对一个新的贡献者来说,了解他们感兴趣的项目的信息是较为困难的。 + +这个补充很有帮助,但是如果您想知道有关本地存储库中项目的相同信息该怎么办呢? 这正是 [Tokei][2] 派上用场的地方。这是一个当你想和精通不同语言的人想要构建一个项目时可以告诉你项目的代码数据的特别有用的工具。 + +### 探索 Tokei + +据其 [README][3],“Tokei 是一个可以展示你的代码数据的程序。Tokei 将会展示文件的数量,和这些文件中不同语言的代码、注释、空白的行数。”它的 v.12.1.0 版本 [elaborates][4] 是这样子介绍的,“Tokei 是一个快速准确的代码分析 CLI 工具和库,可以使你轻松快速地在你的代码库中看到有多少空白、评论和代码行”。它能够识别超过 150 种编程语言。 + +``` +$ ./tokei ~/exa/src ~/Work/wildfly/jaxrs +================== +Language Files Lines Code Comments Blank +Java 46 6135 4324 945 632 +XML 23 5211 4839 473 224 +--------------------------------- +Rust +Markdown +----------------------------------- +Total +``` + +### 安装 Tokei + +在 Fedora 上安装 Tokei: + +``` +$ sudo dnf install tokei +``` + +用 Rust's Cargo 包管理器安装: + +``` +$ cargo install tokei +``` + +### 使用 Tokei + +要列出当前目录中的代码统计: + +``` +$ tokei +=============================================================================== + Language Files Lines Code Comments Blanks +=============================================================================== + Ada 10 2840 1681 560 599 + Assembly 4 2508 1509 458 541 + GNU Style Assembly 4 2751 1528 748 475 + Autoconf 16 2294 1153 756 385 + Automake 1 45 34 0 11 + BASH 4 1895 1602 133 160 + Batch 2 4 4 0 0 + C 330 206433 150241 23402 32790 + C Header 342 60941 24682 29143 7116 + CMake 48 4572 3459 548 565 + C# 9 1615 879 506 230 + C++ 5 907 599 136 172 + Dockerfile 2 16 10 0 6 + Fish 1 87 77 5 5 + HTML 1 545 544 1 0 + JSON 5 8995 8995 0 0 + Makefile 10 504 293 72 139 + Module-Definition 12 1183 1046 65 72 + MSBuild 1 141 140 0 1 + Pascal 4 1443 1016 216 211 + Perl 2 189 137 16 36 + Python 4 1257 949 112 196 + Ruby 1 23 18 1 4 + Shell 15 1860 1411 222 227 + Plain Text 35 29425 0 26369 3056 + TOML 64 3180 2302 453 425 + Visual Studio Pro| 30 14597 14597 0 0 + Visual Studio Sol| 6 655 650 0 5 + XML 1 116 95 17 4 + YAML 2 81 56 12 13 + Zsh 1 59 48 8 3 +------------------------------------------------------------------------------- + Markdown 55 4677 0 3214 1463 + |- C 1 2 2 0 0 + |- Rust 19 336 268 20 48 + |- TOML 23 61 60 0 1 + (Total) 5076 330 3234 1512 +------------------------------------------------------------------------------- + Rust 496 210966 188958 5348 16660 + |- Markdown 249 17676 1551 12502 3623 + (Total) 228642 190509 17850 20283 +=============================================================================== + Total 1523 566804 408713 92521 65570 +=============================================================================== +$ +``` + +下面的命令打印出了支持的语言和拓展: + +``` +$ tokei -l +ABNF +ABAP +ActionScript +Ada +Agda +Alex +Alloy +Arduino C++ +AsciiDoc +ASN.1 +ASP +ASP.NET +Assembly +GNU Style Assembly +``` + +如果你在两个文件夹上运行 `tokei` 并指定其位置作为参数,它将以先入先出的规则打印单个文件的统计数据: + +![Running Tokei on two files][5] + +默认情况下,`tokei` 仅仅输出有关语言的数据,但是使用 `--files` 标记可提供单个文件统计信息: + +``` +$ tokei ~/exa/src --files +=========================================================================================== + Language Files Lines Code Comments Blanks +=========================================================================================== + Rust 54 9339 7070 400 1869 + |- Markdown 33 1306 0 1165 141 + (Total) 10645 7070 1565 2010 +------------------------------------------------------------------------------------------- + /home/ssur/exa/src/theme/default_theme.rs 130 107 0 23 + /home/ssur/exa/src/output/render/times.rs 30 24 0 6 + /home/ssur/exa/src/output/render/users.rs 98 76 0 22 + /home/ssur/exa/src/output/render/size.rs 182 141 3 38 + /home/ssur/exa/src/output/render/octal.rs 116 88 0 28 + /home/ssur/exa/src/output/render/mod.rs 33 20 3 10 + /home/ssur/exa/src/output/render/inode.rs 28 20 0 8 + /home/ssur/exa/src/output/render/links.rs 87 65 0 22 + /home/ssur/exa/src/output/render/groups.rs 123 93 0 30 + |ome/ssur/exa/src/output/render/filetype.rs 31 26 0 5 + /home/ssur/exa/src/output/render/blocks.rs 57 40 0 17 + /home/ssur/exa/src/output/render/git.rs 108 87 0 21 + |/ssur/exa/src/output/render/permissions.rs 204 160 3 41 + /home/ssur/exa/src/output/grid.rs 67 51 3 13 + /home/ssur/exa/src/output/escape.rs 26 18 4 4 + /home/ssur/exa/src/theme/lsc.rs 235 158 39 38 + /home/ssur/exa/src/options/theme.rs 159 124 6 29 + /home/ssur/exa/src/options/file_name.rs 46 39 0 7 + /home/ssur/exa/src/options/flags.rs 84 63 6 15 + /home/ssur/exa/src/fs/mod.rs 10 8 0 2 + /home/ssur/exa/src/fs/feature/mod.rs 33 25 0 8 +-- /home/ssur/exa/src/output/time.rs --------------------------------------------------------------- + |- Rust 215 170 5 40 + |- Markdown 28 0 25 3 +``` + +### 总结 + +我发现使用 `tokei` 来了解我的代码统计数据十分容易。另一个使用 `tokei` 的好处就是它可以用作为一个很容易集成到其他项目的库。访问 Tokei 的 [Crate.io page][7] 和 [Docs.rs][8] 网站来了解其更多用法。如果你想参与其中,你也可以通过它的 [GitHub 仓库][2] 来为 Tokei 作贡献。 + +你是否觉得 Tokei 很有用呢?可以在下方的评论区告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/tokei + +作者:[Sudeshna Sur][a] +选题:[lujun9972][b] +译者:[zepoch](https://github.com/zepoch) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sudeshna-sur +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_development_programming_screen.png?itok=BgcSm5Pl "A screen of code." +[2]: https://github.com/XAMPPRocky/tokei +[3]: https://github.com/XAMPPRocky/tokei/blob/master/README.md +[4]: https://github.com/XAMPPRocky/tokei/releases/tag/v12.1.0 +[5]: https://opensource.com/sites/default/files/uploads/tokei-two-files_0.png "Running Tokei on two files" +[6]: https://creativecommons.org/licenses/by-sa/4.0/ +[7]: https://crates.io/crates/tokei +[8]: https://docs.rs/tokei/12.1.2/tokei/ diff --git a/published/202107/20210625 How to Setup Internet in CentOS, RHEL, Rocky Linux Minimal Install.md b/published/202107/20210625 How to Setup Internet in CentOS, RHEL, Rocky Linux Minimal Install.md new file mode 100644 index 0000000000..7beff5677d --- /dev/null +++ b/published/202107/20210625 How to Setup Internet in CentOS, RHEL, Rocky Linux Minimal Install.md @@ -0,0 +1,121 @@ +[#]: subject: (How to Setup Internet in CentOS, RHEL, Rocky Linux Minimal Install) +[#]: via: (https://www.debugpoint.com/2021/06/setup-internet-minimal-install-server/) +[#]: author: (Arindam https://www.debugpoint.com/author/admin1/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (turbokernel) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13585-1.html) + +如何在 CentOS、RHEL、Rocky Linux 最小化安装中设置互联网 +====== + +![](https://img.linux.net.cn/data/attachment/album/202107/16/104745wne0x111onmafxj9.jpg) + +在最小化服务器安装中,设置互联网或网络是非常容易的。在本指南中,我们将解释如何在 CentOS、RHEL、Rocky Linux 最小安装中设置互联网或网络。 + +当你刚刚完成任何服务器发行版的最小化安装时,你没有任何图形界面或桌面环境可以用于设置你的网络或互联网。因此,当你只能使用终端时,了解如何设置联网是很重要的。NetworkManager 以及 systemd 服务为完成这项工作提供了必要的工具。以下是具体使用方法。 + +### 在 CentOS、RHEL、Rocky Linux 最小化安装中设置互联网 + +完成安装后,启动服务器终端。理想情况下,你应该会看到提示符。使用 root 或 admin 账户登录。 + +然后,首先尝试使用 `nmcli` 检查网络接口的状态和细节。`nmcli` 是一个控制 NetworkManager 服务的命令行工具。使用以下命令进行检查。 + +``` +nmcli device status +``` + +这将显示设备名称、状态等。 + +![nmcli device status][1] + +运行工具 `nmtui` 来配置网络接口。[nmtui][2] 是 NetworkManager 工具的一部分,它为你提供了一个漂亮的用户界面来配置网络。这是 NetworkManager-tui 包的一部分,当你完成最小服务器的安装时它应该默认安装。 + +``` +nmtui +``` + +在 `nmtui` 窗口中点击编辑一个连接。 + +![nmtui – Select options][3] + +选择网口名称: + +![Select Interface to Edit][4] + +在编辑连接窗口,为 IPv4 和 IPv6 选择自动。并选择自动连接。完成后按 “OK”。 + +![nmtui – Edit Connection][5] + +通过使用如下 [systemd systemctl][6] 命令,重新启动 NetworkManager 服务。 + +``` +systemctl restart NetworkManager +``` + +如果一切顺利,在 CentOS、RHEL、Rocky Linux 服务器的最小化安装中你应该可以连接到网络和互联网了,前提是你的网络有互联网连接。你可以用 `ping` 来验证它是否正常。 + +![setup internet minimal server – CentOS Rocky Linux RHEL][7] + +### 额外技巧:在最小化服务器中设置静态 IP + +当你把网络配置设置为自动,当你连接到互联网时,网口会动态地分配 IP。在某些情况下,当你建立一个局域网 (LAN) 时,你可能想给你的网口分配静态 IP。这超级简单。 + +打开你的网络的网络配置脚本。根据你的设备修改高亮部分: + +``` +vi /etc/sysconfig/network-scripts/ifcfg-ens3 +``` + +在上面的文件中,用 `IPADDR` 属性添加你想要的 IP 地址。保存该文件。 + +``` +IPADDR=192.168.0.55 +``` + +在 `/etc/sysconfig/network` 中为你的网络添加网关: + +``` +NETWORKING=yes +HOSTNAME=debugpoint +GATEWAY=10.1.1.1 +``` + +在 `/etc/resolv.conf` 的 `resolv.conf` 中添加任意公共 DNS 服务器: + +``` +nameserver 8.8.8.8 +nameserver 8.8.4.4 +``` + +并重新启动网络服务: + +``` +systemctl restart NetworkManager +``` + +这样就完成了静态 IP 的设置。你也可以使用 `ip addr` 命令检查详细的 IP 信息。 + +我希望这个指南能帮助你在你的最小化服务器中设置网络、互联网和静态 IP。如果你有任何问题,请在评论区告诉我。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2021/06/setup-internet-minimal-install-server/ + +作者:[Arindam][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[turbokernel](https://github.com/turbokernel) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lujun9972 +[1]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/nmcli-device-status.jpg +[2]: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-configuring_ip_networking_with_nmtui +[3]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/nmtui-Select-options.jpg +[4]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/Select-Interface-to-Edit.jpg +[5]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/nmtui-Edit-Connection.jpg +[6]: https://www.debugpoint.com/2020/12/systemd-systemctl-service/ +[7]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/setup-internet-minimal-server-CentOS-Rocky-Linux-RHEL.jpg diff --git a/published/202107/20210625 Use Python to parse configuration files.md b/published/202107/20210625 Use Python to parse configuration files.md new file mode 100644 index 0000000000..b021b100af --- /dev/null +++ b/published/202107/20210625 Use Python to parse configuration files.md @@ -0,0 +1,198 @@ +[#]: subject: "Use Python to parse configuration files" +[#]: via: "https://opensource.com/article/21/6/parse-configuration-files-python" +[#]: author: "Moshe Zadka https://opensource.com/users/moshez" +[#]: collector: "lujun9972" +[#]: translator: "zepoch" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13551-1.html" + +使用 Python 解析配置文件 +====== + +> 第一步是选择配置文件的格式:INI、JSON、YAML 或 TOML。 + +![](https://img.linux.net.cn/data/attachment/album/202107/05/113551tm0d0yp0px0xzp0n.jpg) + +有时,程序需要足够的参数,将它们全部作为命令行参数或环境变量既不让人愉快也不可行。 在这些情况下,你将需要使用配置文件。 + +有几种流行的配置文件格式。其中包括古老的(虽然有时定义不明确)INI 格式,虽然流行但有时难以手写的 JSON 格式,使用广泛但有时在细节方面令人意外的 YAML 格式,以及很多人还没有听说过的最新出现的 TOML。 + +你的首要任务是选择一种格式,然后记录该选择。解决了这个简单的部分之后就是时候解析配置了。 + +有时,在配置中拥有一个与“抽象“数据相对应的类是一个不错的想法。因为这段代码不会对配置做任何事情,所以这是展示解析逻辑最简单的方式。 + +想象一下文件处理器的配置:它包括一个输入目录、一个输出目录和要提取的文件。 + +配置类的抽象定义可能类似于: + +``` +from __future__ import annotations +``` + +``` +import attr + +@attr.frozen +class Configuration: + @attr.frozen + class Files: + input_dir: str + output_dir: str + files: Files + @attr.frozen + class Parameters: + patterns: List[str] + parameters: Parameters +``` + +为了使特定于格式的代码更简单,你还需要编写一个函数来从字典中解析此类。请注意,这假设配置将使用破折号,而不是下划线。 这种差异并不少见。 + +``` +def configuration_from_dict(details): + files = Configuration.Files( + input_dir=details["files"]["input-dir"], + output_dir=details["files"]["output-dir"], + ) + parameters = Configuration.Paraneters( + patterns=details["parameters"]["patterns"] + ) + return Configuration( + files=files, + parameters=parameters, + ) +``` + +### JSON + +JSON(JavaScript Object Notation)是一种类似于 JavaScript 的格式。 + +以下是 JSON 格式的示例配置: + +``` +json_config = """ +{ + "files": { + "input-dir": "inputs", + "output-dir": "outputs" + }, + "parameters": { + "patterns": [ + "*.txt", + "*.md" + ] + } +} +""" +``` + +解析逻辑使用 `json` 模块将 JSON 解析为 Python 的内置数据结构(字典、列表、字符串),然后从字典中创建类: + +``` +import json +def configuration_from_json(data): + parsed = json.loads(data) + return configuration_from_dict(parsed) +``` + +### INI + +INI 格式,最初只在 Windows 上流行,之后成为配置标准格式。 + +这是与 INI 相同的配置: + +``` +ini_config=""" +[files] +input-dir = inputs +output-dir = outputs + +[parameters] +patterns = ['*.txt', '*.md'] +""" +``` + +Python 可以使用内置的 `configparser` 模块解析它。解析器充当类似 `dict` 的对象,因此可以直接传递给 `configuration_from_dict`: + +``` +import configparser + +def configuration_from_ini(data): + parser = configparser.ConfigParser() + parser.read_string(data) + return configuration_from_dict(parser) +``` + +### YAML + +YAML(Yet Another Markup Language)是 JSON 的扩展,旨在更易于手动编写。为了实现了这一点,部分原因是有一个很长的规范。 + +以下是 YAML 中的相同配置: + +``` +yaml_config = """ +files: + input-dir: inputs + output-dir: outputs +parameters: + patterns: + - '*.txt' + - '*.md' +""" +``` + +要让 Python 解析它,你需要安装第三方模块。最受欢迎的是`PyYAML`(`pip install pyyaml`)。 YAML 解析器还返回可以传递给 `configuration_from_dict` 的内置 Python 数据类型。但是,YAML 解析器需要一个字节流,因此你需要将字符串转换为字节流。 + +``` +import io +import yaml +def configuration_from_yaml(data): + fp = io.StringIO(data) + parsed = yaml.safe_load(fp) + return configuration_from_dict(parsed) +``` + +### TOML + +TOML(Tom's Own Markup Language)旨在成为 YAML 的轻量级替代品。其规范比较短,已经在一些地方流行了(比如 Rust 的包管理器 Cargo 就用它来进行包配置)。 + +这是与 TOML 相同的配置: + +``` +toml_config = """ +[files] +input-dir = "inputs" +output-dir = "outputs" + +[parameters] +patterns = [ "*.txt", "*.md",] +""" +``` + +为了解析 TOML,你需要安装第三方包。最流行的一种被简单地称为 `toml`。 与 YAML 和 JSON 一样,它返回基本的 Python 数据类型。 + +``` +import toml +def configuration_from_toml(data): + parsed = toml.loads(data) + return configuration_from_dict(parsed) +``` + +### 总结 + +选择配置格式是一种微妙的权衡。但是,一旦你做出决定,Python 就可以使用少量代码来解析大多数流行的格式。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/parse-configuration-files-python + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[zepoch](https://github.com/zepoch) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python_programming_question.png?itok=cOeJW-8r "Python programming language logo with question marks" diff --git a/published/202107/20210627 Using Git Version Control as a Writer.md b/published/202107/20210627 Using Git Version Control as a Writer.md new file mode 100644 index 0000000000..9c62e93ebd --- /dev/null +++ b/published/202107/20210627 Using Git Version Control as a Writer.md @@ -0,0 +1,109 @@ +[#]: subject: (Using Git Version Control as a Writer) +[#]: via: (https://news.itsfoss.com/version-control-writers/) +[#]: author: (Theena https://news.itsfoss.com/author/theena/) +[#]: collector: (lujun9972) +[#]: translator: (piaoshi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13604-1.html) + +作为一个写作者如何使用 Git 版本控制 +====== + +> 我使用 Vim 和 Git 来写小说。是的,你也可以用 Git 来完成非编码任务。 + +![](https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/Using-Git-for-Writing.jpg?w=1200&ssl=1) + +我相信当代的写作者们应该开始思考他们的工作流程了。 + +在一个注意力高度分散的世界里,作为写作者,我们必须对每天执行的任务链拥有控制权。传统上,作家们会把他们的写作放在分散注意力的事较少、注意力高度集中的时间段。不幸的是,海明威、阿特伍德们的这些建议不再真正适用于我们了。我们所生活的世界联系得更紧密了,因此对作家来说就有了更多的陷阱。这首先要求我们要有足够的自制力,不要让社交媒体或小狗和小猫的可爱视频在我们写作的时候分散我们的注意力。 + +但是,如果你的写作需要快速地检查事实、拼写不常见和技术性的词汇等,断开与互联网连接并不是一个现实的选项 —— 这正是我写作时的场景。另一个问题是你用于写作的应用程序本身的干扰;作为一个长期使用 MS Word 的人,我发现它越来越漂亮,但速度越来越慢,也越来越让人分心。作为当初我 [迁移到 Vim 的主要原因][1] 之一,我曾详细地谈到了这一点,所以我不打算再在这个问题上大谈特谈。重点是,在现代世界中,在现代设备上进行写作,可能远非理想状态。 + +因为我已经详细介绍过了 [我为什么转向 Vim][2] 和开源版本控制,在这篇文章中,我更想谈谈该 **怎么做**,特别是如何使用开源的版本控制技术,比如 Git(和 GitHub)。 + +### 什么是版本控制?再来一次? + +![Source: https://git-scm.com/][3] + +上图是我们如何进行传统版本控制的一个说明。这个图中假设你有一台设备,而且你只在那台设备上写作。但对我而言,我在许多机器上写作,包括我的安卓手机和一些不同年代的笔记本电脑,我会在特定的任务、特定的位置使用到它们。我在所有这些设备上进行的一个共同任务就是写作 —— 因此,我的设备必须以合理的方式捕捉变化并控制文件的版本。不要再让我将 `file1V1_device1_date.doc` 作为文件名了。 + +上图也没有考虑到我们用来写作的工具。像 LibreOffice Write 这样的文字处理器可以在 Linux、Mac 和 Windows 系统上使用,但在手机上使用文字处理器将会是一段不愉快的经历。我们中的一些写作者还使用其他文本工具(包括 Gmail 或我们的电子邮件客户端)来为我们的写作打草稿。但按逻辑顺序跟踪所有这些文件和电子邮件是相当折磨人的,我就用这样的流程写过一本书,相信我:我花在弄清文件名、版本变化、评论、给自己的注释以及带有附加注释的电子邮件上的时间,足以让我精神错乱。 + +读到这里,你们中的一些人可能会正确地指出,有云备份技术呀。虽然云存储的好处是巨大的,而且我也在继续使用它们,但其版本控制几乎不存在,或者说并不强大。 + +### 一个更好的工作流程 + +就像地球上的其它地方一样,大流行病的开始引发了一些焦虑和一些反思。我利用这段时间在 [The Odin Project][4](强烈推荐给那些想学习 html、CSS、JavaScript/Ruby 的人)上自学了网络开发。 + +在课程的第一个模块中,有一个关于 Git 的介绍:什么是版本控制,以及它试图解决什么问题。读了这一章后,我豁然开朗。我立即意识到,这个 _Git_ 正是我作为一个写作者所要寻找的东西。 + +是的,更好的方法不是本地化的版本控制,而是 _分布式_ 的版本控制。“分布式”描述的是设备的分布,而我在这些设备上访问文件,以及之后进行编辑修改。下图是分布式版本控制的一个直观说明。 + +![Source: https://git-scm.com/][5] + +### 我的方法 + +我为写作建立一个版本控制系统的目标如下: + + * 使我的稿件库可以从任何地方、任何设备上访问 + * 易于使用 + * 减少或消除因在写作、学习和编码各工作流程之间的场景切换而产生的摩擦 —— 尽可能使用同一工具(即 Vim)。 + * 可扩展性 + * 易于维护 + +基于以上需求,下图是我进行写作的分布式版本控制系统。 + +![][6] + +如你所见,我的版本控制系统是分布式版本控制的一个简单的适配。在我的例子中,通过将 Git 版本控制应用到云存储([pCloud][7])的一个文件夹上,我可以同时利用这两种技术的优点。因此,我的工作流程可以用下图描述: + +![][8] + +#### 优势 + + 1. 我用一个写作(和编码)工具 + 2. 我可以对我的手稿进行版本控制,无论我是从什么设备上访问文件的 + 3. [超级简单,几乎没有任何不便之处][9] + 4. 易于维护 + +#### 缺点 + +你们中的写作者一定想知道这个系统存在什么缺点。以下是我在持续使用和完善这一工作流程时预计到的几个问题。 + + * 对草稿的评论:文字处理器的一个更有用的功能是具有评论的功能。当我希望以后再回到文本的某一部分时,我经常在这部分为自己留下一个评论。我仍然没有想出一个解决这个问题的办法。 + * 协作:文字处理程序允许写作者之间进行协作。在我以前做广告相关工作的时候,我会用 Google Docs 来写文案,然后分享链接给我的设计师,从而他可以为广告和网站对文案进行摘录。现在,我的解决方法是用 Markdown 写文案,并通过 Pandoc 将 Markdown 文件导出为 .doc 文件。更关键的是,当我的手稿完成后,我仍然需要将文件以 .doc 格式发送给我的编辑。一旦我的编辑做了一些修改并把它发回来,我再尝试用 Vim 打开它就没有意义了。在这一点上,该系统的局限性变得更加明显。 + +我并不是说这是最好的方法,但在我职业生涯的这个阶段,这是对我来说最好的方法。我想,随着我对我的新的 [用于写作的开源工具][10] 和版本控制越来越熟悉和适应,我将进一步完善这个方法。 + +我希望这篇文章能为那些想使用 Git 进行文档版本控制的写作者提供一个很好的介绍。这肯定不是一篇详尽的文章,但我将分享一些有用的链接,使你的旅程更容易。 + + 1. [The Odin Project 介绍的 Git 基础知识][11] + 2. [开始使用 Git][12] + 3. GitHub 的 Git 基础知识教程 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/version-control-writers/ + +作者:[Theena][a] +选题:[lujun9972][b] +译者:[piaoshi](https://github.com/piaoshi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/theena/ +[b]: https://github.com/lujun9972 +[1]: https://news.itsfoss.com/how-i-started-loving-vim/ +[2]: https://news.itsfoss.com/configuring-vim-writing/ +[3]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/local.png?w=800&ssl=1 +[4]: https://www.theodinproject.com/ +[5]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/distributed.png?w=668&ssl=1 +[6]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/Version_Control.png?w=617&ssl=1 +[7]: https://itsfoss.com/recommends/pcloud/ +[8]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/Version_Control_2.png?w=886&ssl=1 +[9]: https://www.youtube.com/watch?v=NtH-HhaLw-Q +[10]: https://itsfoss.com/open-source-tools-writers/ +[11]: https://www.theodinproject.com/paths/foundations/courses/foundations/lessons/introduction-to-git +[12]: https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control diff --git a/published/202107/20210628 Forgot Linux Password on WSL- Here-s How to Reset it Easily.md b/published/202107/20210628 Forgot Linux Password on WSL- Here-s How to Reset it Easily.md new file mode 100644 index 0000000000..b92b147787 --- /dev/null +++ b/published/202107/20210628 Forgot Linux Password on WSL- Here-s How to Reset it Easily.md @@ -0,0 +1,137 @@ +[#]: subject: (Forgot Linux Password on WSL? Here’s How to Reset it Easily) +[#]: via: (https://itsfoss.com/reset-linux-password-wsl/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13545-1.html) + +在 WSL 上忘记了 Linux 密码?下面是如何轻松重设的方法 +====== + +对于那些想从舒适的 Windows 中享受 Linux 命令行的人来说,WSL(Windows Subsystem for Linux) 是一个方便的工具。 + +当你 [在 Windows 上使用 WSL 安装 Linux][1] 时,会要求你创建一个用户名和密码。当你在 WSL 上启动 Linux 时,这个用户会自动登录。 + +现在的问题是,如果你有一段时间没有使用它,你可能会忘记 WSL 的账户密码。而如果你要使用 `sudo` 的命令,这将成为一个问题,因为这里你需要输入密码。 + +![][2] + +不要担心。你可以很容易地重置它。 + +### 在 Ubuntu 或任何其他 Linux 发行版上重置遗忘的 WSL 密码 + +要在 WSL 中重设 Linux 密码,你需要: + + * 将默认用户切换为 `root` + * 重置普通用户的密码 + * 将默认用户切换回普通用户 + +让我向你展示详细的步骤和截图。 + +#### 步骤 1:将默认用户切换为 root + +记下你的普通/常规用户名将是明智之举。如你所见,我的普通帐户的用户名是 `abhishek`。 + +![Note down the account username][3] + +WSL 中的 `root` 用户是无锁的,没有设置密码。这意味着你可以切换到 `root` 用户,然后利用 `root` 的能力来重置密码。 + +由于你不记得帐户密码,切换到 `root` 用户是通过改变你的 Linux WSL 应用的配置,使其默认使用 `root` 用户来完成。 + +这是通过 Windows 命令提示符完成的,你需要知道你的 Linux 发行版需要运行哪个命令。 + +这个信息通常在 [Windows 商店][4] 中的发行版应用的描述中提供。这是你首次下载发行版的地方。 + +![Know the command to run for your distribution app][5] + +从 Windows 菜单中,启动命令提示符: + +![Start Command Prompt][6] + +在这里,以这种方式使用你的发行版的命令。如果你使用的是 Windows 商店中的 Ubuntu 应用,那么该命令将是: + +``` +ubuntu config --default-user root +``` + +截图中,我正在使用 Windows 商店中的 Ubuntu 20.04 应用。所以,我使用了 ubuntu2004 命令。 + +![Set root as default user in Linux app’s configuration][7] + +为了减少你的麻烦,我在这个表格中列出了一些发行版和它们各自的命令: + +发行版应用 | Windows 命令 +---|--- +Ubuntu | `ubuntu config –default-user root` +Ubuntu 20.04 | `ubuntu2004 config –default-user root` +Ubuntu 18.04 | `ubuntu1804 config –default-user root` +Debian | `debian config –default-user root` +Kali Linux | `kali config –default-user root` + +#### 步骤 2:重设帐户密码 + +现在,如果你启动 Linux 发行程序,你应该以 `root` 身份登录。你可以重新设置普通用户帐户的密码。 + +你还记得 WSL 中的用户名吗?(LCTT 译注:请使用你的“用户名”替换下列命令中的 `username`)如果没有,你可以随时检查 `/home` 目录的内容。当你有了用户名后,使用这个命令: + +``` +passwd username +``` + +它将要求你输入一个新的密码。**当你输入时,屏幕上将不会显示任何内容。这很正常。只要输入新的密码,然后点击回车就可以了。**你必须重新输入新的密码来确认,当你输入密码时,屏幕上也不会显示任何东西。 + +![Reset the password for the regular user][8] + +恭喜你。用户账户的密码已经被重置。但你还没有完成。默认用户仍然是 `root`。你应该把它改回你的普通用户帐户,否则它将一直以 `root` 用户的身份登录。 + +#### 步骤 3:再次将普通用户设置为默认用户 + +你需要你在上一步中用 [passwd 命令][9] 使用的普通帐户用户名。 + +再次启动 Windows 命令提示符。**使用你的发行版命令**,方式与第 1 步中类似。然而,这一次,用普通用户代替 `root`。 + +``` +ubuntu config --default-user username +``` + +![Set regular user as default user][10] + +现在,当你在 WSL 中启动你的 Linux 发行版时,你将以普通用户的身份登录。你已经重新设置了密码,可以用它来运行 `sudo` 命令。 + +如果你将来再次忘记了密码,你知道重置密码的步骤。 + +### 如果重设 WSL 密码如此简单,这难道不是一种安全风险吗? + +并非如此。你需要有对计算机的物理访问权以及对 Windows 帐户的访问权。如果有人已经有这么多的访问权,他/她可以做很多事情,而不仅仅是改变 WSL 中的 Linux 密码。 + +### 你是否能够重新设置 WSL 密码? + +我给了你命令并解释了步骤。我希望这对你有帮助,并能够在 WSL 中重置你的 Linux 发行版的密码。 + +如果你仍然遇到问题,或者你对这个话题有疑问,请随时在评论区提问。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/reset-linux-password-wsl/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/install-bash-on-windows/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/reset-wsl-password.png?resize=800%2C450&ssl=1 +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/username-wsl.png?resize=800%2C296&ssl=1 +[4]: https://www.microsoft.com/en-us/store/apps/windows +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/wsl-distro-command.png?resize=800%2C602&ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/start-cmd-windows.jpg?resize=800%2C500&ssl=1 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/wsl-set-root-as-default.png?resize=800%2C288&ssl=1 +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/resetting-wsl-password.png?resize=800%2C366&ssl=1 +[9]: https://linuxhandbook.com/passwd-command/ +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/set-regular-user-as-default-wsl.png?resize=800%2C288&ssl=1 diff --git a/published/202107/20210628 How to archive files on FreeDOS.md b/published/202107/20210628 How to archive files on FreeDOS.md new file mode 100644 index 0000000000..b2acc5fec0 --- /dev/null +++ b/published/202107/20210628 How to archive files on FreeDOS.md @@ -0,0 +1,87 @@ +[#]: subject: (How to archive files on FreeDOS) +[#]: via: (https://opensource.com/article/21/6/archive-files-freedos) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13567-1.html) + +如何在 FreeDOS 上归档文件 +====== + +> 虽然有一个 FreeDOS 版的 tar,但 DOS 上事实上的标准归档工具是 Zip 和 Unzip。 + +![](https://img.linux.net.cn/data/attachment/album/202107/10/063340wp088ozz1fo9f1e1.jpg) + +在 Linux 上,你可能熟悉标准的 Unix 归档命令:`tar`。FreeDOS 上也有 `tar` 的版本(还有其他一些流行的归档程序),但 DOS 上事实上的标准归档程序是 Zip 和 Unzip。Zip 和 Unzip 都默认安装在 FreeDOS 1.3 RC4 中。 + +Zip 文件格式最初是由 PKWARE 的 Phil Katz 在 1989 年为 PKZIP 和 PKUNZIP 这对 DOS 归档工具构思的。Katz 将 Zip 文件的规范作为一个开放标准发布,因此任何人都可以创建 Zip 档案。作为开放规范的结果,Zip 成为 DOS 上的一个标准归档格式。[Info-ZIP][2] 项目实现了一套开源的 `ZIP` 和 `UNZIP` 程序。 + +### 对文件和目录进行压缩 + +你可以在 DOS 命令行中使用 `ZIP` 来创建文件和目录的归档。这是一个方便的方法,可以为你的工作做一个备份,或者发布一个“包”,在未来的 FreeDOS 发布中使用。例如,假设我想为我的项目源码做一个备份,其中包含这些源文件: + +![dir][3] + +*我想把这些文件归档* + +`ZIP` 有大量的命令行选项来做不同的事情,但我最常使用的命令行选项是 `-r` 来处理目录和子目录 _递归_,以及使用 `-9` 来提供可能的最大压缩。`ZIP` 和 `UNZIP` 使用类似 Unix 的命令行,所以你可以在破折号后面组合选项:`-9r` 将提供最大压缩并在 Zip 文件中包括子目录。 + +![zip][5] + +*压缩一个目录树* + +在我的例子中,`ZIP` 能够将我的源文件从大约 33KB 压缩到大约 22KB,为我节省了 11KB 的宝贵磁盘空间。你可能会得到不同的压缩率,这取决于你给 `ZIP` 的选项,或者你想在 Zip 文件中存储什么文件(以及有多少)。一般来说,非常长的文本文件(如源码)会产生良好的压缩效果,而非常小的文本文件(如只有几行的 DOS “批处理”文件)通常太短,无法很好地压缩。 + +### 解压文件和目录 + +将文件保存到 Zip 文件中是很好的,但你最终会需要将这些文件解压到某个地方。让我们首先检查一下我们刚刚创建的 Zip 文件里有什么。为此,使用 `UNZIP `命令。你可以在 `UNZIP`中使用一堆不同的选项,但我发现我只使用几个常用的选项。 + +要列出一个 Zip 文件的内容,使用 `-l` (“list”) 选项。 + +![unzip -l][6] + +*用 unzip 列出归档文件的内容* + +该输出允让我看到 Zip 文件中的 14 个条目:13 个文件加上 `SRC` 目录。 + +如果我想提取整个 Zip 文件,我可以直接使用 `UNZIP` 命令并提供 Zip 文件作为命令行选项。这样就可以从我当前的工作目录开始提取 Zip 文件了。除非我正在恢复某个东西的先前版本,否则我通常不想覆盖我当前的文件。在这种情况下,我希望将 Zip 文件解压到一个新的目录。你可以用 `-d` (“destination”) 命令行选项指定目标路径。 + +![unzip -d temp][7] + +*你可以用 -d 来解压到目标路径* + +有时我想从一个 Zip 文件中提取一个文件。在这个例子中,假设我想提取一个 DOS 可执行程序 `TEST.EXE`。要提取单个文件,你要指定你想提取的 Zip 文件的完整路径。默认情况下,`UNZIP` 将使用 Zip 文件中提供的路径解压该文件。要省略路径信息,你可以添加 `-j`(“junk the path”) 选项。 + +你也可以组合选项。让我们从 Zip 文件中提取 `SRC\TEST.EXE` 程序,但省略完整路径并将其保存在 `TEMP` 目录下: + +![unzip -j][8] + +*unzip 组合选项* + +因为 Zip 文件是一个开放的标准,所以我们会今天继续看到 Zip 文件。每个 Linux 发行版都可以通过 Info-ZIP 程序支持 Zip 文件。你的 Linux 文件管理器可能也支持 Zip 文件。在 GNOME 文件管理器中,你应该可以右击一个文件夹并从下拉菜单中选择“压缩”。你可以选择创建一个包括 Zip 文件在内的新的归档文件。 + +创建和管理 Zip 文件是任何 DOS 用户的一项关键技能。你可以在 Info-ZIP 网站上了解更多关于 `ZIP` 和 `UNZIP` 的信息,或者在命令行上使用 `h`(“帮助”)选项来打印选项列表。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/archive-files-freedos + +作者:[Jim Hall][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jim-hall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/files_documents_organize_letter.png?itok=GTtiiabr (Filing cabinet for organization) +[2]: http://infozip.sourceforge.net/ +[3]: https://opensource.com/sites/default/files/uploads/dir.png (I'd like to archive these files) +[4]: https://creativecommons.org/licenses/by-sa/4.0/ +[5]: https://opensource.com/sites/default/files/uploads/zip-9r.png (Zipping a directory tree) +[6]: https://opensource.com/sites/default/files/uploads/unzip-l.png (Listing the archive file contents with unzip) +[7]: https://opensource.com/sites/default/files/uploads/unzip-d.png (You can unzip into a destination path with -d) +[8]: https://opensource.com/sites/default/files/uploads/unzip-j.png (Combining options with unzip) diff --git a/published/202107/20210628 How to parse Bash program configuration files.md b/published/202107/20210628 How to parse Bash program configuration files.md new file mode 100644 index 0000000000..64e4569d0f --- /dev/null +++ b/published/202107/20210628 How to parse Bash program configuration files.md @@ -0,0 +1,148 @@ +[#]: subject: (How to parse Bash program configuration files) +[#]: via: (https://opensource.com/article/21/6/bash-config) +[#]: author: (David Both https://opensource.com/users/dboth) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13561-1.html) + +如何解析 Bash 程序的配置文件 +====== + +> 将配置文件与代码分离,使任何人都可以改变他们的配置,而不需要任何特殊的编程技巧。 + +![](https://img.linux.net.cn/data/attachment/album/202107/08/163606y3287i6c7dqq0223.jpg) + +将程序配置与代码分离是很重要的。它使非程序员能够改变配置而不需要修改程序的代码。如果是编译好的二进制可执行文件,这对非程序员来说是不可能的,因为它不仅需要访问源文件(我们在开源程序中会这样),而且还需要程序员的技能组合。很少有人有这种能力,而且大多数人都不想学习它。 + +对于像 Bash 这样的 shell 语言,由于 shell 脚本没有被编译成二进制格式,所以从定义上讲,源码是可以访问的。尽管有这种开放性,但对于非程序员来说,在 shell 脚本中钻研和修改它们并不是一个特别好的主意。即使是经验丰富的开发人员和系统管理员,也会意外地做出一些导致错误或更糟的改变。 + +因此,将配置项放在容易维护的文本文件中,提供了分离,并允许非程序员编辑配置,而不会有对代码进行意外修改的危险。许多开发者对用编译语言编写的程序都是这样做的,因为他们并不期望用户是开发者。由于许多相同的原因,对解释型 shell 语言这样做也是有意义的。 + +### 通常的方式 + +和其他许多语言一样, 你可以为 Bash 程序编写代码,来读取并解析 ASCII 文本的配置文件、读取变量名称并在程序代码执行时设置值。例如,一个配置文件可能看起来像这样: + +``` +var1=LinuxGeek46 +var2=Opensource.com +``` + +程序将读取文件,解析每一行,并将值设置到每个变量中。 + +### 源引 + +Bash 使用一种更简单的方法来解析和设置变量, 叫做源引sourcing。从一个可执行的 shell 程序中获取一个外部文件是一种简单的方法,可以将该文件的内容完整地引入 shell 程序中。在某种意义上,这很像编译语言的 `include` 语句,在运行时包括库文件。这样的文件可以包括任何类型的 Bash 代码,包括变量赋值。 + +(LCTT 译注:对于使用 `source` 或 `.` 命令引入另外一个文件的行为,我们首倡翻译为“源引”。) + +像往常一样,演示比解释更容易。 + +首先,创建一个 `~/bin` 目录(如果它还不存在的话),并将其作为当前工作目录(PWD)。[Linux 文件系统分层标准][2] 将 `~/bin` 定义为用户存储可执行文件的适当位置。 + +在这个目录下创建一个新文件。将其命名为 `main`,并使其可执行: + +``` +[dboth@david bin]$ touch main +[dboth@david bin]$ chmod +x main +[dboth@david bin]$ +``` + +在这个可执行文件中添加以下内容: + +``` +#!/bin/bash +Name="LinuxGeek" +echo $Name +``` + +并执行这个 Bash 程序: + +``` +[dboth@david bin]$ ./main +LinuxGeek +[dboth@david bin]$ +``` + +创建一个新的文件并命名为 `~/bin/data`。这个文件不需要是可执行的。在其中添加以下信息: + +``` +# Sourced code and variables +echo "This is the sourced code from the data file." +FirstName="David" +LastName="Both" +``` + +在 `main` 程序中增加三行,看起来像这样: + +``` +#!/bin/bash +Name="LinuxGeek" +echo $Name +source ~/bin/data +echo "First name: $FirstName" +echo "LastName: $LastName" +``` + +重新运行该程序: + +``` +[dboth@david bin]$ ./main +LinuxGeek +This is the sourced code from the data file. +First name: David +LastName: Both +[dboth@david bin]$ +``` + +关于源引还有一件非常酷的事情要知道。你可以使用一个单点(`.`)作为 `source` 命令的快捷方式。改变 `main` 文件,用 `.` 代替 `source`。 + +``` +#!/bin/bash +Name="LinuxGeek" +echo $Name +. ~/bin/data +echo "First name: $FirstName" +echo "LastName: $LastName" +``` + +并再次运行该程序。其结果应该与之前的运行完全相同。 + +### 运行 Bash + +每一台使用 Bash 的 Linux 主机(几乎所有主机都是,因为 Bash 是所有发行版的默认 shell),都包括一些优秀的、内置的源引示例。 + +每当 Bash shell 运行时,它的环境必须被配置成可以使用的样子。有五个主要文件和一个目录用于配置 Bash 环境。它们和它们的主要功能如下: + + * `/etc/profile`: 系统级的环境和启动程序 + * `/etc/bashrc`: 系统级的函数和别名 + * `/etc/profile.d/`: 包含系统级的脚本的目录,用于配置各种命令行工具,如 `vim` 和 `mc` 以及系统管理员创建的任何自定义配置脚本 + * `~/.bash_profile`: 用户特定的环境和启动程序 + * `~/.bashrc`: 用户特定的别名和函数 + * `~/.bash_logout`: 用户特定的命令,在用户注销时执行 + +试着通过这些文件追踪执行顺序,确定它在非登录 Bash 初始化和登录 Bash 初始化中使用的顺序。我在我的 Linux 培训系列《[使用和管理 Linux:从零到系统管理员][3]》的第一卷第 17 章中这样做过。 + +给你一个提示。这一切都从 `~/.bashrc` 脚本开始。 + +### 总结 + +这篇文章探讨了在 Bash 程序中引用代码和变量的方法。这种从配置文件中解析变量的方法是快速、简单和灵活的。它提供了一种将 Bash 代码与变量赋值分开的方法,以使非程序员能够设置这些变量的值。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/bash-config + +作者:[David Both][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dboth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bash_command_line.png?itok=k4z94W2U (bash logo on green background) +[2]: http://refspecs.linuxfoundation.org/fhs.shtml +[3]: http://www.both.org/?page_id=1183 diff --git a/published/202107/20210628 Query your Linux operating system like a database.md b/published/202107/20210628 Query your Linux operating system like a database.md new file mode 100644 index 0000000000..d587e4f86c --- /dev/null +++ b/published/202107/20210628 Query your Linux operating system like a database.md @@ -0,0 +1,321 @@ +[#]: subject: (Query your Linux operating system like a database) +[#]: via: (https://opensource.com/article/21/6/osquery-linux) +[#]: author: (Gaurav Kamathe https://opensource.com/users/gkamathe) +[#]: collector: (lujun9972) +[#]: translator: (YungeG) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13578-1.html) + +像查询数据库一样查询你的 Linux 操作系统信息 +====== + +> 使用数据库查询操作轻松获取系统信息。 + +![](https://img.linux.net.cn/data/attachment/album/202107/14/095820zywm2m2tzz5otfh5.jpg) + +Linux 提供了很多帮助用户收集主机操作系统信息的命令:列出文件或者目录的属性信息;查询安装的软件包、正在执行的命令、开机时启动的服务;或者了解系统的硬件。 + +每个命令使用自己的输出格式列出系统的信息。你需要使用 `grep`、`sed`、`awk` 这样的工具过滤命令输出的结果,以便找到特定的信息。此外,很多这样的信息会频繁变动,导致系统状态的改变。 + +将所有的信息格式化为一个数据库的 SQL 查询的输出进行查看将会十分有益。想象一下,你能够像查询具有类似名称的 SQL 数据库表一样查询 `ps` 和 `rpm` 命令的输出。 + +幸运的是,有一个工具刚好实现了这个功能,而且功能更多:[Osquery][2] 是一个 [开源的][3] “由 SQL 驱动的操作系统仪表、监控和分析框架”。 + +许多处理安全、DevOps、合规性的应用,以及仓储管理管理(仅举几例)在内部依赖 Osquery 提供的核心功能。 + +### 安装 Osquery + +Osquery 适用于 Linux、macOS、Windows、FreeBSD。请按照 [指南][4] 为你的操作系统安装最新版本。(我会在下面的例子中使用 4.7.0 版本。) + +安装完成后,确保 Osquery 可以工作: + +``` +$ rpm -qa | grep osquery +osquery-4.7.0-1.linux.x86_64 +$ +$ osqueryi --version +osqueryi version 4.7.0 +$ +``` + +### Osquery 组件 + +Osquery 有两个主要组件: + +* `osqueri` 是一个交互式的 SQL 查询控制台,可以独立运行,不需要超级用户权限(除非要查询的表格需要访问权限)。 +* `osqueryd` 像一个安装在主机的监控守护进程,可以定期调度查询操作执行,从底层架构收集信息。 + +可以在不运行 `osqueryd` 的情况下执行 `osqueri`。另一个工具,`osqueryctl`,控制守护进程的启动、停止,并检查其状态。 + +``` +$ rpm -ql osquery-4.8.0-1.linux.x86_64 | grep bin +/usr/bin/osqueryctl +/usr/bin/osqueryd +/usr/bin/osqueryi +$ +``` + +### 使用 osqueryi 交互式命令提示符 + +你和 Osquery 的交互与使用 SQL 数据库十分相似。事实上,`osqueryi` 是 SQList shell 的一个修改版。执行 `osqueryi` 命令进入交互式命令提示符 ,就可以执行 Osquery 的命令,通常以 `.` 开始: + +``` +$ osqueryi +Using a virtual database. Need help, type '.help' +osquery> +``` + +要退出交互式命令提示符,执行 `.quit` 命令回到操作系统的命令提示符: + +``` +osquery> +osquery> .quit +$ +``` + +### 找出可用的表 + +如前所述,Osquery 像 SQL 查询一样输出数据,数据库中的信息通常保存在表中。但是如何在不知道表名的情况下查询这些表呢?你可以运行 `.tables` 命令列出所有可以查询的表。如果你是一个 Linux 长期用户或者一个系统管理员 ,就会对表名十分熟悉,因为你一直在使用操作系统命令获取同样的信息: + +``` +osquery> .tables + => acpi_tables + => apparmor_events + => apparmor_profiles + => apt_sources + +<<裁剪>> + + => arp_cache + => user_ssh_keys + => users + => yara + => yara_events + => ycloud_instance_metadata + => yum_sources +osquery> +``` + +### 检查各个表的模式 + +知道表名后,可以查看每个表提供的信息。既然 `ps` 命令经常用于获取进程信息,就以 `processes` 为例。执行 `.schema` 命令加上表名查看表中保存的信息。如果要验证命令返回的结果,可以快速执行 `ps -ef` 或 `ps aux`,对比命令的输出和表中的内容: + +``` +osquery> .schema processes +CREATE TABLE processes(`pid` BIGINT, `name` TEXT, `path` TEXT, `cmdline` TEXT, `state` TEXT, `cwd` TEXT, `root` TEXT, `uid` BIGINT, `gid` BIGINT, `euid` BIGINT, `egid` BIGINT, `suid` BIGINT, `sgid` BIGINT, `on_disk` INTEGER, `wired_size` BIGINT, `resident_size` BIGINT, `total_size` BIGINT, `user_time` BIGINT, `system_time` BIGINT, `disk_bytes_read` BIGINT, `disk_bytes_written` BIGINT, `start_time` BIGINT, `parent` BIGINT, `pgroup` BIGINT, `threads` INTEGER, `nice` INTEGER, `is_elevated_token` INTEGER HIDDEN, `elapsed_time` BIGINT HIDDEN, `handle_count` BIGINT HIDDEN, `percent_processor_time` BIGINT HIDDEN, `upid` BIGINT HIDDEN, `uppid` BIGINT HIDDEN, `cpu_type` INTEGER HIDDEN, `cpu_subtype` INTEGER HIDDEN, `phys_footprint` BIGINT HIDDEN, PRIMARY KEY (`pid`)) WITHOUT ROWID; +osquery> +``` + +要进一步确认,可以使用下面的命令查看 RPM 包的结构信息,然后与操作系统命令 `rpm -qa` 和 `rpm -qi` 的输出比较: + +``` +osquery> +osquery> .schema rpm_packages +CREATE TABLE rpm_packages(`name` TEXT, `version` TEXT, `release` TEXT, `source` TEXT, `size` BIGINT, `sha1` TEXT, `arch` TEXT, `epoch` INTEGER, `install_time` INTEGER, `vendor` TEXT, `package_group` TEXT, `pid_with_namespace` INTEGER HIDDEN, `mount_namespace_id` TEXT HIDDEN, PRIMARY KEY (`name`, `version`, `release`, `arch`, `epoch`, `pid_with_namespace`)) WITHOUT ROWID; +osquery> +``` + +从 Osquery 的 [表格文档][5] 获取更多信息。 + +### 使用 PRAGMA 命令 + +或许模式信息对你来说太难看懂,还有另一种途径能够以详细的表格格式打印表中的信息:`PRAGMA` 命令。例如,我想通过 `PRAGMA` 用一种易于理解的格式查看 `rpm_packages` 表的信息: + +``` +osquery> PRAGMA table_info(rpm_packages); +``` + +这种表格式信息的一个好处是你可以关注想要查询的字段,查看命令提供的类型信息: + +``` +osquery> PRAGMA table_info(users); ++-----+-------------+--------+---------+------------+----+ +| cid | name | type | notnull | dflt_value | pk | ++-----+-------------+--------+---------+------------+----+ +| 0 | uid | BIGINT | 1 | | 1 | +| 1 | gid | BIGINT | 0 | | 0 | +| 2 | uid_signed | BIGINT | 0 | | 0 | +| 3 | gid_signed | BIGINT | 0 | | 0 | +| 4 | username | TEXT | 1 | | 2 | +| 5 | description | TEXT | 0 | | 0 | +| 6 | directory | TEXT | 0 | | 0 | +| 7 | shell | TEXT | 0 | | 0 | +| 8 | uuid | TEXT | 1 | | 3 | ++-----+-------------+--------+---------+------------+----+ +osquery> +``` + +### 进行你的第一次查询 + +在你从表、模式、条目中获取到所有进行查询所需要的信息后,进行你的第一次 SQL 查询查看其中的信息。下面的查询返回系统中的用户和每个用户的用户 ID、组 ID、主目录和默认的命令行解释器。Linux 用户通过查看 `/etc/passwd` 文件的内容并执行 `grep`、`sed`、`awk` 命令获取同样的信息。 + +``` +osquery> +osquery> select uid,gid,directory,shell,uuid FROM users LIMIT 7; ++-----+-----+----------------+----------------+------+ +| uid | gid | directory | shell | uuid | ++-----+-----+----------------+----------------+------+ +| 0 | 0 | /root | /bin/bash | | +| 1 | 1 | /bin | /sbin/nologin | | +| 2 | 2 | /sbin | /sbin/nologin | | +| 3 | 4 | /var/adm | /sbin/nologin | | +| 4 | 7 | /var/spool/lpd | /sbin/nologin | | +| 5 | 0 | /sbin | /bin/sync | | +| 6 | 0 | /sbin | /sbin/shutdown | | ++-----+-----+----------------+----------------+------+ +osquery> +``` + +### 不进入交互模式的查询 + +如果你想要在不进入 `osqueri` 交互模式的情况下进行查询,该怎么办?要用查询操作写命令行解释器脚本,这种方式可能十分有用。这种情况下,可以直接从 Bash 解释器 `echo` SQL 查询,通过管道输出到 `osqueri` : + +``` +$ echo "select uid,gid,directory,shell,uuid FROM users LIMIT 7;" | osqueryi ++-----+-----+----------------+----------------+------+ +| uid | gid | directory | shell | uuid | ++-----+-----+----------------+----------------+------+ +| 0 | 0 | /root | /bin/bash | | +| 1 | 1 | /bin | /sbin/nologin | | +| 2 | 2 | /sbin | /sbin/nologin | | +| 3 | 4 | /var/adm | /sbin/nologin | | +| 4 | 7 | /var/spool/lpd | /sbin/nologin | | +| 5 | 0 | /sbin | /bin/sync | | +| 6 | 0 | /sbin | /sbin/shutdown | | ++-----+-----+----------------+----------------+------+ +$ +``` + +### 获悉系统启动时开始的服务 + +Osquery 还可以列出系统启动时开始的所有服务。例如,可以查询 `startup_items` 表获取启动时开始的前五项服务的名称、状态和路径: + +``` +osquery> SELECT name,type,status,path FROM startup_items LIMIT 5; + name = README + type = Startup Item +status = enabled + path = /etc/rc.d/init.d/README + + name = anamon + type = Startup Item +status = enabled + path = /etc/rc.d/init.d/anamon + + name = functions + type = Startup Item +status = enabled + path = /etc/rc.d/init.d/functions + + name = osqueryd + type = Startup Item +status = enabled + path = /etc/rc.d/init.d/osqueryd + + name = AT-SPI D-Bus Bus + type = Startup Item +status = enabled + path = /usr/libexec/at-spi-bus-launcher --launch-immediately +osquery> +``` + +### 查阅二进制文件的 ELF 信息 + +假如你想要弄清 `ls` 二进制文件的更多细节,通常会通过 `readelf -h` 命令,加上 `ls` 命令的路径。查询 Osquery 的 `elf_info` 表你可以得到同样的信息: + +``` +osquery> SELECT * FROM elf_info WHERE path="/bin/ls"; + class = 64 + abi = sysv +abi_version = 0 + type = dyn + machine = 62 + version = 1 + entry = 24064 + flags = 0 + path = /bin/ls +osquery> +``` + +现在你应该初步了解如何使用 `osqueri` 查询自己想要的信息。然而,这些信息保存在数量巨大的表中;我查询过的一个系统中,有 156 个不同的表,这个数字可能是十分惊人的: + +``` +$ echo ".tables" | osqueryi | wc -l +156 +$ +``` + +要让事情变得更容易,可以从这些表开始获取你的 Linux 系统的信息: + +**系统信息表:** + +``` +osquery> select * from system_info; +``` + +**系统限制信息:** + +``` +osquery> select * from ulimit_info; +``` + +**由各种进程打开的文件:** + +``` +osquery> select * from process_open_files; +``` + +**系统上开放的端口:** + +``` +osquery> select * from listening_ports; +``` + +**运行中的进程信息:** + +``` +osquery> select * from processes; +``` + +**已安装的包信息:** + +``` +osquery> select * from rpm_packages; +``` + +**用户登录信息:** + +``` +osquery> select * from last; +``` + +**系统日志信息:** + +``` +osquery> select * from syslog_events; +``` + +### 了解更多 + +Osquery 是一个强大的工具,提供了许多可以用于解决各种使用案例的主机信息。你可以阅读 [文档][6] 了解更多 Osquery 的信息。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/osquery-linux + +作者:[Gaurav Kamathe][a] +选题:[lujun9972][b] +译者:[YungeG](https://github.com/YungeG) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/gkamathe +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0 (Magnifying glass on code) +[2]: https://osquery.io/ +[3]: https://github.com/osquery/osquery +[4]: https://osquery.io/downloads/official +[5]: https://osquery.io/schema/4.8.0/ +[6]: https://osquery.readthedocs.io/en/latest/ diff --git a/published/202107/20210629 A brief history of FreeDOS.md b/published/202107/20210629 A brief history of FreeDOS.md new file mode 100644 index 0000000000..5601e5c66c --- /dev/null +++ b/published/202107/20210629 A brief history of FreeDOS.md @@ -0,0 +1,108 @@ +[#]: subject: (A brief history of FreeDOS) +[#]: via: (https://opensource.com/article/21/6/history-freedos) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: (zxy-wyx) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13601-1.html) + +FreeDOS 简史 +====== + +> 经历了近 30 年的发展, FreeDOS 已经成为了世界先进的 DOS。 + +![](https://img.linux.net.cn/data/attachment/album/202107/21/104903zzxiyc4i4gkpxiph.jpg) + +> 一个大师正在给他的一个弟子讲 [编程之道][2]。 “编程之道包含在所有的软件中 —— 不管它多么微不足道,” 大师说道。 +> +> “编程之道在手持计算器里面吗?” 弟子问道。 +> +> “是的,” 大师回答道。 +> +> “编程之道在电子游戏里面吗?” 弟子继续问道。 +> +> “即便是电子游戏中,” 大师说。 +> +> “那编程之道在个人电脑的 DOS 里面吗?” +> +> 大师咳嗽了一下,稍稍改变了一下姿势,说道,“今天的课就到这里吧。” +> +> ——《编程之道》,Geoffrey James,InfoBooks,1987 + +过去,计算仅限于昂贵的大型机和“大铁疙瘩”计算机系统,如 PDP 11。但是微处理器的出现在 20 世纪 70 年代带来了一场计算革命。你终于可以在家里有一台电脑了——“个人电脑”时代已经到了! + +我记得看到的最早的个人电脑包括 Commodore、TRS-80 和 Apple。个人电脑成了一个热门话题,所以 IBM 决定进入这个市场。在经历了一个快速开发周期之后,IBM 于 1981 年 8 月发布了 IBM 5150 个人电脑(最初的“IBM PC”)。 + +从零开始创建一台计算机并非易事,因此 IBM 以用“现成”的硬件来构建 PC 而闻名,并从外部开发商那里获得了其他组件的授权。其中之一是微软授权的操作系统。反过来,微软从西雅图计算机产品公司获得了 86-DOS ,进行了各种更新,并将新版本作为 IBM PC-DOS 与 IBM PC 一起首次亮相。 + +### 早期的 DOS + +运行在最多只有 640 千字节内存中的 DOS,除了管理硬件和允许用户启动应用程序之外,真的做不了什么。因此,PC-DOS 1.0 命令行非常贫乏,只包含了一些设置日期和时间、管理文件、控制终端和格式化软盘的命令。DOS 还包括一个 BASIC 语言解释器,这是那个时代所有个人计算机的一个标准功能。 + +直到 PC-DOS 2.0,DOS 才变得更加有趣,为命令行添加了新的命令,并包含了其他有用的工具。但对我来说,直到 1991 年的 MS-DOS 5.0 才有了“现代感”。微软在这个版本中对 DOS 进行了大修,更新了许多命令,并用一个新的全屏编辑器取代了老旧的 Edlin 编辑器,使之更方便用户使用。DOS 5 还包括我喜欢的其他特性,比如基于微软 QuickBASIC 编译器的新 BASIC 解释器,简称 QBASIC. 如果你曾经在 DOS 上玩过 Gorillas 游戏,那可能就是在 MS-DOS 5.0 中运行的。 + +尽管进行了这些升级,但我对 DOS 命令行并不完全满意。DOS 从来没有偏离原来的设计,有其局限性。DOS 为用户提供了一些工具,可以从命令行执行一些事情 —— 否则,你就得使用 DOS 命令行来启动应用程序。微软认为用户大部分时间都会花在几个关键的应用程序上,比如文字处理器或电子表格。 + +但是开发人员想要一个功能更强的 DOS,此时一个细分行业正在萌芽,以提供小巧优雅的工具和程序。有些是全屏应用程序,但也有许多是增强 DOS 命令环境的命令行实用程序。当我学会一点 C 语言编程时,我开始编写自己的实用程序,扩展或替换 DOS 命令行。尽管 MS-DOS 的基础相当有限,但我发现第三方实用程序加上我自己的工具创建了一个功能强大的 DOS 命令行。 + +### FreeDOS + +1994 年初,我开始在科技杂志上看到很多对微软高管的采访,他们说下一个版本的 Windows 将完全取代 DOS。我以前使用过 Windows,但如果你还记得那个时代,你就知道 Windows 3.1 并不是一个很好的平台。Windows 3.1 很笨重,有很多毛病,如果一个应用程序崩溃,它可能会使整个 Windows 系统瘫痪。我也不喜欢 Windows 的图形用户界面。我更喜欢在命令行做我的工作,而不是用鼠标。 + +我考虑过 Windows,并决定,“如果 Windows 3.2 或 Windows 4.0 会像 Windows 3.1 一样,我就不会去使用它。” 但我有什么选择?此时,我已经尝试过 Linux,并认为 [Linux 很棒][3],但是 Linux 没有任何应用程序。我的文字处理器、电子表格和其他程序都在 DOS 上。我需要 DOS。 + +然后我有了个主意!我想,“如果开发人员能够在互联网上共同编写一个完整的 Unix 操作系统,那么我们当然可以对 DOS 做同样的事情。”毕竟,与 Unix 相比,DOS 是一个相当简单的操作系统。DOS 一次运行一个任务(单任务),并且有一个更简单的内存模型。编写我们自己的 DOS 应该不难。 + +因此,在 1994 年 6 月 29 日,我在一个名为 Usenet 的留言板网络上向 “comp.os.msdos.apps” [发布了一个公告][4]: + +> PD-DOS 项目公告: +> +> 几个月前,我发表了关于启动公共领域版本的 DOS 的文章。 当时大家对此的普遍支持,许多人都同意这样的说法:“开始编写吧!”所以,我就…… +> +> 宣布首次生产 PD-DOS 的努力。我已经写了一个“清单”,描述了这样一个项目的目标和工作大纲,以及一个“任务列表”,它准确地显示了需要编写什么。我会把这些贴在这里,供大家讨论。 + +\* 关于这个名字的说明 —— 我希望这个新的 DOS 成为每个人都可以使用的东西,我天真地认为,当每个人都可以使用它时,它就是“公共领域”。我很快就意识到了这种差别,所以我们把 “PD-DOS” 改名为 “Free-DOS”,然后去掉连字符变成 “FreeDOS”。 + +一些开发人员联系我,提供他们为替换或增强 DOS 命令行而创建的实用程序,类似于我自己的努力。就在项目宣布几个月后,我们汇集了我们的实用程序,并创建了一个实用的系统,我们在 1994 年 9 月发布了一个 “Alpha 1” 版本。在那些日子里,发展是相当迅速的,我们在 1994 年 12 月发布了 “Alpha 2”,1995 年 1 月发布了 “Alpha 3”,1995 年 6 月发布了“Alpha 4”。 + +### 一个现代的 DOS + +从那以后,我们一直致力于使 FreeDOS 成为 “现代” DOS。而这种现代化大部分都集中在创建一个丰富的命令行环境上。是的,DOS 仍然需要支持应用程序,但是我们相信 FreeDOS 也需要一个强大的命令行环境。这就是为什么 FreeDOS 包含了许多有用的工具,包括浏览目录、管理文件、播放音乐、连接网络的命令,……以及类似 Unix 的实用程序集合,如 `less`、`du`、`head`、`tail`、`sed` 和 `tr`。 + +虽然 FreeDOS 的开发已经放缓,但它并没有停止。开发人员继续为 FreeDOS 编写新程序,并向 FreeDOS 添加新功能。我对 FreeDOS 1.3 RC4 的几个重要补充感到特别兴奋,FreeDOS 1.3 RC4 是即将发布的 FreeDOS 1.3 的最新候选版本。最近的一些更新如下: + + * Mateusz Viste 创建了一个新的电子书阅读器,名为 Ancient Machine Book(AMB),我们利用它作为 FreeDOS 1.3 RC4 中的新帮助系统。 + * Rask Ingemann Lambertsen、Andrew Jenner、TK Chia 和其他人正在更新 GCC 的 IA-16 版本,包括一个新的libi86 库,它提供了与 Borland TurboC++ 编译器的 C 库的某种程度的兼容性。 + * Jason Hood 更新了一个可卸载的 CD-ROM 重定向器,以替代微软的 MSCDEX,最多支持 10 个驱动器。 + * SuperIlu 创建了 DOjS,这是一个 Javascript 开发画布,具有集成的编辑器、图形和声音输出,以及鼠标、键盘和操纵杆输入。 + * Japheth 创建了一个 DOS32PAE 扩展程序,它能够通过 PAE 分页使用大量的内存。 + +尽管 FreeDOS 有了新的发展,我们仍然忠于我们的 DOS 根基。在我们继续朝着 FreeDOS 1.3 “最终”版本努力时,我们带着几个核心假设,包括: + + * **兼容性是关键** —— 如果 FreeDOS 不能运行经典 DOS 应用程序,它就不是真正的 “DOS”。虽然我们提供了许多优秀的开源工具、应用程序和游戏,但你也可以运行你的传统的 DOS 应用程序。 + * **继续在旧 PC 上运行(XT、286、386 等)** —— FreeDOS 1.3 将保持 16 位英特尔架构,但在可能的情况下将支持扩展驱动程序支持的新硬件。为此,我们继续专注于单用户命令行环境。 + * **FreeDOS 是开源软件** —— 我一直说,如果人们不能访问、学习和修改源代码,FreeDOS 就不是“自由的 DOS”。FreeDOS 1.3 将包括尽可能多地包括使用公认的开源许可证的软件。但 DOS 实际上早于 GNU 通用公共许可证(1989)和开放源码定义(1998),因此一些 DOS 软件可能会使用它自己的“免费源代码”许可证,而不是标准的“开源”许可。当我们考虑将软件包纳入 FreeDOS 时,我们将继续评估任何许可证,以确保它们是合适的“开放源码”,即使它们没有得到正式承认。 + +我们欢迎你的帮助,使 FreeDOS 强大!请加入我们的电子邮件列表,我们欢迎所有新来者和贡献者。我们通过电子邮件列表进行交流,不过这个列表的信件量非常小,所以不太可能撑爆你的收件箱。 + +访问 FreeDOS 网站 [www.freedos.org][5]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/history-freedos + +作者:[Jim Hall][a] +选题:[lujun9972][b] +译者:[zxy-wyx](https://github.com/zxy-wyx) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jim-hall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/1980s-computer-yearbook.png?itok=eGOYEKK- (Person typing on a 1980's computer) +[2]: https://www.mit.edu/~xela/tao.html +[3]: https://opensource.com/article/17/5/how-i-got-started-linux-jim-hall-freedos +[4]: https://groups.google.com/g/comp.os.msdos.apps/c/oQmT4ETcSzU/m/O1HR8PE2u-EJ +[5]: https://www.freedos.org/ diff --git a/published/202107/20210629 Fotoxx- An Open Source App for Managing and Editing Large Photo Collection.md b/published/202107/20210629 Fotoxx- An Open Source App for Managing and Editing Large Photo Collection.md new file mode 100644 index 0000000000..c9cc852a72 --- /dev/null +++ b/published/202107/20210629 Fotoxx- An Open Source App for Managing and Editing Large Photo Collection.md @@ -0,0 +1,84 @@ +[#]: subject: (Fotoxx: An Open Source App for Managing and Editing Large Photo Collection) +[#]: via: (https://itsfoss.com/fotoxx/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13559-1.html) + +Fotoxx:用于管理和编辑大型照片集合的开源应用 +====== + +![](https://img.linux.net.cn/data/attachment/album/202107/07/131024ej2kzv824zqb4zz8.jpg) + +说到 [Linux 中的照片管理软件][1],Shotwell 可能是其中最有名的。难怪它在许多发行版中都预装了。 + +但是,如果你正在寻找一个类似 Shotwell 而速度更快的应用,Fotoxx 可能是一个不错的选择。 + +它可能没有一个现代的用户界面,但它在处理大量照片集合时速度很快。这一点很重要,因为索引和显示成千上万张照片的缩略图可能需要相当多的时间和计算资源。 + +### 用 Fotoxx 在 Linux 中管理照片并编辑它们 + +![Fotoxx interface][2] + +正如你在上面的截图中看到的,它没有漂亮的界面。看起来更像是一个 2010 年左右的应用。它在视觉上的不足,在功能和性能上得到了弥补。 + +你可以导入大量的照片,包括 RAW 图像。这些图片保持原样。它们不会被复制或移动。它们只是在应用中被索引。 + +你可以编辑图像元数据,如标签、地理标签、日期、评级、标题等。你可以根据这些元数据来搜索图片。 + +它还有一个地图功能,可以分组并显示属于某个地点的图片(基于图片上的地理标签数据)。 + +![Map view][3] + +由于它专注于管理大型照片集合,有几个批处理功能,可以重命名、调整大小、复制/移动、转换图像格式和编辑元数据。 + +你可以选择图片来创建相册和幻灯片,所有这些都是在去重图片的情况下进行的。照片可以组合成 360 度的全景图。 + +Fotoxx 还有几个编辑功能,可以用来修饰图片,添加效果(如素描、绘画)、修剪、旋转等。 + +还有一些选项可以去除旧的、扫描照片打印件上的红眼和尘斑。 + +我可以继续列举功能清单,但这太长了。它的网站描述了它的[全部功能][4],你应该去看看。 + +### 在 Linux 上安装 Fotoxx + +请记住,**Fotoxx 的开发者建议使用一台强大的计算机**,有 4 个以上的 CPU 核心,16GB 以上的内存,以便正常运行。较小的计算机可能会很慢,或可能无法编辑大型图像。 + +Fotoxx 在大多数 Linux 发行版中都有,如 Debian、Ubuntu、Fedora 和 Arch Linux。只需使用你的发行版的包管理器或软件中心来搜索 Fotoxx 并安装它。 + +在基于 Ubuntu 和 Debian 的发行版上,你可以使用 apt 命令来安装它,像这样: + +``` +sudo apt install fotoxx +``` + +当你第一次运行它时,它会要求搜索主目录中的图像。你可以继续使用它,或者将搜索位置限制在选定的文件夹。 + +![][6] + +我注意到,尽管在一分钟左右的时间内索引了 4700 多张,但它并没有立即开始显示图片。我不得不**点击 Gallery->All Folders,然后选择文件夹,然后它就显示了图片**。所以,这一点要记住。 + +Fotoxx 是一个功能广泛的工具,你需要一些时间来适应它并探索它的[所有功能][4]。它的网站列出了几个例子,你应该看看。 + +正如我前面所说,它不是最漂亮的应用,但它大量的功能列表可以完成任务。如果你是一个摄影师或有大量的图片收藏,你可以试试 Fotoxx,看看它是否符合你的需要。当你试过后,请在评论区分享你的经验。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/fotoxx/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/linux-photo-management-software/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/fotoxx-interface.jpg?resize=800%2C561&ssl=1 +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/fotoxx-geotag-map-view.jpg?resize=800%2C466&ssl=1 +[4]: https://kornelix.net/fotoxx/fotoxx.html +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/fotoxx-indexing.png?resize=800%2C617&ssl=1 diff --git a/published/202107/20210630 Parse JSON configuration files with Groovy.md b/published/202107/20210630 Parse JSON configuration files with Groovy.md new file mode 100644 index 0000000000..8ba9dc0556 --- /dev/null +++ b/published/202107/20210630 Parse JSON configuration files with Groovy.md @@ -0,0 +1,292 @@ +[#]: subject: (Parse JSON configuration files with Groovy) +[#]: via: (https://opensource.com/article/21/6/groovy-parse-json) +[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13576-1.html) + +用 Groovy 解析 JSON 配置文件 +====== + +> 抛开关于是否使用 JSON 作为配置格式的争论,只需学习如何用 Groovy 来解析它。 + +![](https://img.linux.net.cn/data/attachment/album/202107/12/232406vpp4qrv6ee5a3erz.jpg) + +应用程序通常包括某种类型的默认或“开箱即用”的状态或配置,以及某种让用户根据自己的需要定制配置的方式。 + +例如,[LibreOffice Writer][2] 通过其菜单栏上的**工具 > 选项**,可以访问诸如用户数据、字体、语言设置等(以及更多的)设置。一些应用程序(如 LibreOffice)提供了一个点选式的用户界面来管理这些设置。有些,像 [Tracker][3](GNOME 的“任务”,用于索引文件)使用 XML 文件。还有一些,特别是基于 JavaScript 的应用,使用 JSON,尽管它有许多人抗议(例如,[这位作者][4] 和 [这位其他作者][5])。 + +在这篇文章中,我将回避关于是否使用 JSON 作为配置文件格式的争论,并解释如何使用 [Groovy 编程语言][6] 来解析这类信息。Groovy 以 Java 为基础,但有一套不同的设计重点,使 Groovy 感觉更像 Python。 + +### 安装 Groovy + +由于 Groovy 是基于 Java 的,它也需要安装 Java。你可能会在你的 Linux 发行版的软件库中找到最近的、合适的 Java 和 Groovy 版本。或者,你可以按照其网站上的 [说明][7] 安装 Groovy。 Linux 用户的一个不错的选择是 [SDKMan][8],你可以使用它来获取 Java、Groovy 和许多其他相关工具的多个版本。 对于本文,我将使用我的发行版的 OpenJDK11 和 SDKMan 的 Groovy 3.0.7。 + +### 演示的 JSON 配置文件 + +在这个演示中,我从 [Drupal][9] 中截取了这个 JSON 文件,它是 Drupal CMS 使用的主要配置文件,并将其保存在文件 `config.json` 中: + +``` +{ + "vm": { + "ip": "192.168.44.44", + "memory": "1024", + "synced_folders": [ + { + "host_path": "data/", + "guest_path": "/var/www", + "type": "default" + } + ], + "forwarded_ports": [] + }, + "vdd": { + "sites": { + "drupal8": { + "account_name": "root", + "account_pass": "root", + "account_mail": "box@example.com", + "site_name": "Drupal 8", + "site_mail": "box@example.com", + "vhost": { + "document_root": "drupal8", + "url": "drupal8.dev", + "alias": ["www.drupal8.dev"] + } + }, + "drupal7": { + "account_name": "root", + "account_pass": "root", + "account_mail": "box@example.com", + "site_name": "Drupal 7", + "site_mail": "box@example.com", + "vhost": { + "document_root": "drupal7", + "url": "drupal7.dev", + "alias": ["www.drupal7.dev"] + } + } + } + } +} +``` + +这是一个漂亮的、复杂的 JSON 文件,有几层结构,如: + +``` +<>.vdd.sites.drupal8.account_name +``` + +和一些列表,如: + +``` +<>.vm.synced_folders +``` + +这里,`<>` 代表未命名的顶层。让我们看看 Groovy 是如何处理的。 + +### 用 Groovy 解析 JSON + +Groovy 自带的 `groovy.json` 包,里面有各种很酷的东西。其中最好的部分是 `JsonSlurper` 类,它包括几个 `parse()` 方法,可以将 JSON 转换为 Groovy 的 `Map`,一种根据键值存储的数据结构。 + +下面是一个简短的 Groovy 程序,名为 `config1.groovy`,它创建了一个 `JsonSlurper` 实例,然后调用其中的 `parse()` 方法来解析文件中的 JSON,并将其转换名为 `config` 的 `Map` 实例,最后将该 map 输出: + + +``` +import groovy.json.JsonSlurper + +def jsonSlurper = new JsonSlurper() + +def config = jsonSlurper.parse(new File('config.json')) + +println "config = $config" +``` + +在终端的命令行上运行这个程序: + +``` +$ groovy config1.groovy +config = [vm:[ip:192.168.44.44, memory:1024, synced_folders:[[host_path:data/, guest_path:/var/www, type:default]], forwarded_ports:[]], vdd:[sites:[drupal8:[account_name:root, account_pass:root, account_mail:box@example.com, site_name:Drupal 8, site_mail:box@example.com, vhost:[document_root:drupal8, url:drupal8.dev, alias:[www.drupal8.dev]]], drupal7:[account_name:root, account_pass:root, account_mail:box@example.com, site_name:Drupal 7, site_mail:box@example.com, vhost:[document_root:drupal7, url:drupal7.dev, alias:[www.drupal7.dev]]]]]] +$ +``` + +输出显示了一个有两个键的顶层映射:`vm` 和 `vdd`。每个键都引用了它自己的值的映射。注意 `forwarded_ports` 键所引用的空列表。 + +这很容易,但它所做的只是把东西打印出来。你是如何获得各种组件的呢?下面是另一个程序,显示如何访问存储在 `config.vm.ip` 的值: + +``` +import groovy.json.JsonSlurper + +def jsonSlurper = new JsonSlurper() + +def config = jsonSlurper.parse(new File('config.json')) + +println "config.vm.ip = ${config.vm.ip}" +``` + +运行它: + +``` +$ groovy config2.groovy +config.vm.ip = 192.168.44.44 +$ +``` + +是的,这也很容易。 这利用了 Groovy 速记,这意味着: + +``` +config.vm.ip +``` + +在 Groovy 中等同于: + +``` +config['vm']['ip'] +``` + +当 `config` 和 `config.vm` 都是 `Map` 的实例,并且都等同于在 Java 中的: + +``` +config.get("vm").get("ip") +``` + +仅仅是处理 JSON 就这么多了。如果你想有一个标准的配置并让用户覆盖它呢?在这种情况下,你可能想在程序中硬编码一个 JSON 配置,然后读取用户配置并覆盖任何标准配置的设置。 + +假设上面的配置是标准的,而用户只想覆盖其中的一点,只想覆盖 `vm` 结构中的 `ip` 和 `memory` 值,并把它放在 `userConfig.json` 文件中: + +``` +{ + "vm": { + "ip": "201.201.201.201", + "memory": "4096", + } +} +``` + +你可以用这个程序来做: + +``` +import groovy.json.JsonSlurper + +def jsonSlurper = new JsonSlurper() + +// 使用 parseText() 来解析一个字符串,而不是从文件中读取。 +// 这给了我们一个“标准配置” +def standardConfig = jsonSlurper.parseText(""" +{ + "vm": { + "ip": "192.168.44.44", + "memory": "1024", + "synced_folders": [ + { + "host_path": "data/", + "guest_path": "/var/www", + "type": "default" + } + ], + "forwarded_ports": [] + }, + "vdd": { + "sites": { + "drupal8": { + "account_name": "root", + "account_pass": "root", + "account_mail": "box@example.com", + "site_name": "Drupal 8", + "site_mail": "box@example.com", + "vhost": { + "document_root": "drupal8", + "url": "drupal8.dev", + "alias": ["www.drupal8.dev"] + } + }, + "drupal7": { + "account_name": "root", + "account_pass": "root", + "account_mail": "box@example.com", + "site_name": "Drupal 7", + "site_mail": "box@example.com", + "vhost": { + "document_root": "drupal7", + "url": "drupal7.dev", + "alias": ["www.drupal7.dev"] + } + } + } + } +} +""") + +// 打印标准配置 +println "standardConfig = $standardConfig" + +//读入并解析用户配置信息 +def userConfig = jsonSlurper.parse(new File('userConfig.json')) + +// 打印出用户配置信息 +println "userConfig = $userConfig" + +// 一个将用户配置与标准配置合并的函数 +def mergeMaps(Map input, Map merge) { + merge.each { k, v -> + if (v instanceof Map) + mergeMaps(input[k], v) + else + input[k] = v + } +} + +// 合并配置并打印出修改后的标准配置 +mergeMaps(standardConfig, userConfig) + +println "modified standardConfig $standardConfig" +``` + +以下列方式运行: + +``` +$ groovy config3.groovy +standardConfig = [vm:[ip:192.168.44.44, memory:1024, synced_folders:[[host_path:data/, guest_path:/var/www, type:default]], forwarded_ports:[]], vdd:[sites:[drupal8:[account_name:root, account_pass:root, account_mail:box@example.com, site_name:Drupal 8, site_mail:box@example.com, vhost:[document_root:drupal8, url:drupal8.dev, alias:[www.drupal8.dev]]], drupal7:[account_name:root, account_pass:root, account_mail:box@example.com, site_name:Drupal 7, site_mail:box@example.com, vhost:[document_root:drupal7, url:drupal7.dev, alias:[www.drupal7.dev]]]]]] +userConfig = [vm:[ip:201.201.201.201, memory:4096]] +modified standardConfig [vm:[ip:201.201.201.201, memory:4096, synced_folders:[[host_path:data/, guest_path:/var/www, type:default]], forwarded_ports:[]], vdd:[sites:[drupal8:[account_name:root, account_pass:root, account_mail:box@example.com, site_name:Drupal 8, site_mail:box@example.com, vhost:[document_root:drupal8, url:drupal8.dev, alias:[www.drupal8.dev]]], drupal7:[account_name:root, account_pass:root, account_mail:box@example.com, site_name:Drupal 7, site_mail:box@example.com, vhost:[document_root:drupal7, url:drupal7.dev, alias:[www.drupal7.dev]]]]]] +$ +``` + +以 `modified standardConfig` 开头的一行显示,`vm.ip` and `vm.memory` 的值被覆盖了。 + +眼尖的读者会注意到,我没有检查畸形的 JSON,也没有仔细确保用户的配置是有意义的(不创建新字段,提供合理的值,等等)。所以用这个递归方法来合并两个映射在现实中可能并不那么实用。 + +好吧,我必须为家庭作业留下 _一些_ 东西,不是吗? + +### Groovy 资源 + +Apache Groovy 网站有很多很棒的 [文档][11]。另一个很棒的 Groovy 资源是 [Mr. Haki][12]。学习 Groovy 的一个非常好的理由是继续学习 [Grails][13],它是一个非常高效的全栈 Web 框架,建立在 Hibernate、Spring Boot 和 Micronaut 等优秀组件之上。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/groovy-parse-json + +作者:[Chris Hermansen][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clhermansen +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/look-binoculars-sight-see-review.png?itok=NOw2cm39 (Looking back with binoculars) +[2]: https://www.libreoffice.org/discover/writer/ +[3]: https://gitlab.gnome.org/GNOME/tracker +[4]: https://www.lucidchart.com/techblog/2018/07/16/why-json-isnt-a-good-configuration-language/ +[5]: https://medium.com/trabe/stop-using-json-config-files-ab9bc55d82fa +[6]: https://groovy-lang.org/ +[7]: https://groovy.apache.org/download.html +[8]: https://sdkman.io/ +[9]: https://www.drupal.org/node/2008800 +[10]: mailto:box@example.com +[11]: http://groovy-lang.org/documentation.html +[12]: https://blog.mrhaki.com/ +[13]: https://grails.org/ diff --git a/published/202107/20210703 Can Windows 11 Influence Linux Distributions.md b/published/202107/20210703 Can Windows 11 Influence Linux Distributions.md new file mode 100644 index 0000000000..23c32ec7a1 --- /dev/null +++ b/published/202107/20210703 Can Windows 11 Influence Linux Distributions.md @@ -0,0 +1,115 @@ +[#]: subject: (Can Windows 11 Influence Linux Distributions?) +[#]: via: (https://news.itsfoss.com/can-windows-11-influence-linux/) +[#]: author: (Ankush Das https://news.itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: (zz-air) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13588-1.html) + +Windows 11 能影响 Linux 发行版吗? +====== + +> Windows 11 正在为全球的桌面用户制造新闻。它会影响 Linux 发行版走向桌面用户吗? + +![](https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/windows-linux-desktop-influence.png?w=1200&ssl=1) + +微软的 Windows11 终于发布了。有些人将其与 macOS 进行比较,另一些人则比较其细枝末节发现与 GNOME 和 KDE 的相似之处(这没有多大意义)。 + +但是,在所有的热议当中,我对另一件事很好奇—— **微软的 Windows 11 能影响桌面 Linux 发行版未来的决策吗?** + +在这里,我将提到一些我的想法,即如果它以前发生过,为什么会发生?以及 Linux 发行版未来会怎样。 + +### 一些 Linux 发行版已经关注类似 Windows 的体验:但是,为什么呢? + +微软的 Windows 是最受欢迎的桌面操作系统,因其易操作、软件支持和硬件兼容占据了 88% 的市场分额。 + +相反, Linux 占有 **大约 2% 的市场分额,** [即使 Linux 比 Windows 有更多的优势][1]。 + +那么 Linux 能做什么来说服更多的用户将 Linux 作为他们的桌面操作系统呢? + +每个桌面操作系统的主要关注点应该是用户体验。当微软和苹果设法为大众提供舒适的用户体验时,Linux 发行版并没有设法在这方面取得巨大的胜利。 + +然而,你将会发现有几个 [Linux 发行版打算取代 Windows 10][2]。这些 Linux 发行版试图提供一个熟悉的用户界面,鼓励 Windows 用户考虑切换到 Linux 。 + +而且,由于这些发行版的存在,[在 2021 年切换到 Linux][3] 比以往任何时候都更有意义。 + +因此,为了让更多的用户跳转到 Linux ,微软 Window 多年来已经影响了许多发行版。 + +### Windows 11 在某些方面比 Linux 好? + +用户界面随着 Windows 的发展而不断的发展。即使这是主观的,它似乎是大多数桌面用户的选择。 + +所以我要说 Windows 11 在这方面做了一些有吸引力的改进。 + +![][4] + +不仅仅局限于 UI/UX ,比如在任务栏中集成微软团队的聊天功能,可以方便用户与任何人即时联系。 + +**虽然 Linux 发行版没有自己成熟的服务,但是像这样定制的更多开箱即用的集成,应该会使新用户更容易上手。** + +并且这让我想起了 Windows 11 的另一个方面——个性化的新闻和信息提要。 + +当然,微软会为此收集数据,你可能需要使用微软账号登录。但这也减少了用户寻找独立应用程序来跟踪天气、新闻和其他日常信息的摩擦。 + +Linux 不会强迫用户做出这些选择,但是像这样的特性/集成可以作为额外的选项添加,可以以选择的形式呈现给用户。 + +**换句话说,在与操作系统集成的同时,使事物更容易访问,应该可以摆脱陡峭的学习曲线。** + +而且,可怕的微软商店也在 Windows 11 上进行了重大升级。 + +![][5] + +不幸的是,对于 Linux 发行版,我没有看到对应用中心进行多少有意义的升级,来使其在视觉上更吸引人,更有趣。 + +elementaryOS 可能正努力专注于 UX/UI ,并不断发展应用中心的体验,但对于大多数其他发行版,没有重大的升级。 + +![Linux Mint 20.1 中的软件管理器][6] + +虽然我很欣赏深度 Linux 在这方面所做的,但它并不是许多用户第一次尝试 Linux 时的热门选择。 + +### Windows 11 引入了更多的竞争:Linux 必须跟上 + +随着 Windows 11 的推出,作为桌面选择的 Linux 将面临更多的竞争。 + +虽然在 Linux 世界中,我们确实有一些 Windows 10 经验的替代品,但还没有针对 Windows 11 的。 + +但这让我们看到了来自 Linux 社区的明显反击—— **一个针对 Windows 11 的 Linux 发行版**。 + +不管是讨厌还是喜欢微软最新的 Windows 11 设计方案,在接下来的几年里,大众将会接受它。 + +并且,为了使 Linux 成为一个引人注目的桌面替代品,Linux 发行版的设计语言也必须发展。 + +不仅仅是桌面市场,还有笔记本专用的设计选择也需要对 Linux 发行版进行重大改进。 + +像 [Pop!_OS_System 76][7] 这些选择一直试图为 Linux 提供这种体验,这是一个良好的开端。 + +我认为 Zorin OS 可以作为一个引入 “**Windows 11**” 布局的发行版,作为让更多用户尝试 Linux 的一个选择。 + +别忘了,在 Windows 11 将 Android 应用程序支持作为一项功能推向市场之后,[深度 Linux 就引入了 Android 应用程序支持。][8] + +所以,你看,当微软的 Windows 采取行动时,对 Linux 也会产生连锁反应。而深度 Linux 的 Android 应用支持只是一个开始……让我们看看接下来还会出现什么。 + +_你对 Windows 11 影响 Linux 桌面的未来有什么看法?我们也需要进化吗?或者我们应该继续与众不同,不受大众选择的影响?_ + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/can-windows-11-influence-linux/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[zz-air](https://github.com/zz-air) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/linux-better-than-windows/ +[2]: https://itsfoss.com/windows-like-linux-distributions/ +[3]: https://news.itsfoss.com/switch-to-linux-in-2021/ +[4]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/windows-11-home.png?w=1024&ssl=1 +[5]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/windows-10-app-store.png?w=1024&ssl=1 +[6]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/software-manager-linux-mint.png?w=862&ssl=1 +[7]: https://pop.system76.com +[8]: https://news.itsfoss.com/deepin-linux-20-2-2-release/ diff --git a/published/202107/20210703 Identify flowers and trees with this open source mobile app.md b/published/202107/20210703 Identify flowers and trees with this open source mobile app.md new file mode 100644 index 0000000000..6dd54f9769 --- /dev/null +++ b/published/202107/20210703 Identify flowers and trees with this open source mobile app.md @@ -0,0 +1,90 @@ +[#]: subject: (Identify flowers and trees with this open source mobile app) +[#]: via: (https://opensource.com/article/21/7/open-source-plantnet) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13568-1.html) + +用开源移动应用 PlantNet 来识别花草和树木 +====== + +> PlantNet 将开源技术与众包知识结合起来,帮助你成为业余植物学家。 + +![Fire pink flower in Maggie Valley, NC][1] + +在我居住的地方很多小路和道路两旁都有花草树木。我所在的社区因其每年的枫树节而闻名,枫树对我来说很容易识别。然而,还有许多其他的树我无法识别名字。花也是如此:蒲公英很容易发现,但我不知道在我的步行道上的野花的名字。 + +最近,我的妻子告诉我了 PlantNet,一个可以识别这些花草和树木的移动应用。它可以在 iOS 和 Android 上使用,而且是免费的,所以我决定试试。 + +### 以开源的方式识别植物 + +我在手机上下载了这个应用程序,开始用它来识别我在村子周围散步时的一些花草和树木。随着我对这个应用的熟悉,我注意到我拍摄的图片(以及其他用户拍摄的图片)是以知识共享署名-相同方式共享(CC-BY-SA)的许可方式共享的。进一步的调查显示,PlantNet 是 [开源][2] 的。如果你喜欢,你可以匿名使用该应用,或者成为社区的注册成员。 + +根据 [Cos4Cloud][3] 公民科学项目,“PlantNet 是一个参与性的公民科学平台,用于收集、分享和审查基于自动识别的植物观察结果。它的目标是监测植物的生物多样性,促进公众对植物知识的获取”。它使用图像识别技术来清点生物多样性。 + +该项目的开发始于 2009 年,由法国的植物学家和计算机科学家进行。它最初是一个 [Web 应用][4],而智能手机应用程序于 2013 年推出。该项目是 [Floris'Tic][5] 倡议的一部分,这是法国的另一个项目,旨在促进植物科学的科学、技术和工业文化。 + +PlantNet 允许用户利用智能手机的摄像头来收集视觉标本,并由软件和社区进行识别。然后,这些照片将与全世界数百万加入 PlantNet 网络的人分享。 + +该项目说:“PlantNet 系统的工作原理是,比较用户通过他们寻求鉴定的植物器官(花、果实、叶……)的照片传送的视觉模式。这些图像被分析,并与每天协作制作和充实的图像库进行比较。然后,该系统提供一个可能的物种清单及其插图”。 + +### 使用 PlantNet + +该应用很容易使用。从你的智能手机上的应用图标启动它。 + +![PlantNet smartphone icon][6] + +当应用打开时,你会看到你已经在资料库中收集的标本。显示屏底部的相机图标允许你使用你的相机将图片添加到你的照片库。 + +![Pl@ntnet homescreen][8] + +选择“相机”选项,将手机的摄像头对准你想识别的树木或花草。拍完照后,点击与你想识别的标本相匹配的选项(叶、花、树皮、果实等)。 + +![Selecting plant type to identify][9] + +例如,如果你想通过叶子的特征来识别一个标本,请选择**叶子**。PlantNet 对其识别的确定程度进行了分配,从高到低的百分比不等。你还可以使用你的智能手机的 GPS 功能,将位置信息自动添加到你的数据收集中,你还可以添加注释。 + +![Identified plant][10] + +你可以在你的智能手机上或通过你的用户 ID(如果你创建了一个账户)登录网站,访问你上传的所有观测数据,并跟踪社区是否批准了它们。从网站界面上,你也可以下载 CSV 或电子表格格式的观察记录。 + +![Pl@ntnet provides user stats][11] + +### 很好的户外活动 + +我特别喜欢 PlantNet 与维基百科的链接,这样我就可以阅读更多关于我收集的植物数据的信息。 + +目前全球大约有 1200 万 PlantNet 用户,所以数据集一直在增长。该应用是免费使用的,每天最多可以有 500 个请求。它还有一个 API,以 JSON 格式提供数据,所以你甚至可以把 Pl antNet 的视觉识别引擎作为一个 Web 服务使用。 + +PlantNet 的一个非常好的地方是,它结合了众包知识和开源技术,将用户相互联系起来,并与很好的户外活动联系起来。没有比这更好的理由来支持开源软件了。 + +关于该应用及其开发者的完整描述可在 [YouTube][12] 上找到(有法语、英文字幕)。你也可以在 [PlantNet][13] 的网站上了解更多该项目。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/open-source-plantnet + +作者:[Don Watkins][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fire-pink-flower-maggie-valley.jpg?itok=q6Ev7TSr (Fire pink flower in Maggie Valley, NC) +[2]: https://github.com/plantnet +[3]: https://cos4cloud-eosc.eu/citizen-science-innovation/cos4cloud-citizen-observatories/plntnet/ +[4]: https://identify.plantnet.org/ +[5]: http://floristic.org/ +[6]: https://opensource.com/sites/default/files/uploads/plantnet-icon.jpg (PlantNet smartphone icon) +[7]: https://creativecommons.org/licenses/by-sa/4.0/ +[8]: https://opensource.com/sites/default/files/uploads/plantnet_camera.jpg (Pl@ntnet homescreen) +[9]: https://opensource.com/sites/default/files/uploads/plantnet_plant-type.jpg (Selecting plant type to identify) +[10]: https://opensource.com/sites/default/files/uploads/plantnet-identification.jpg (Identified plant) +[11]: https://opensource.com/sites/default/files/uploads/plantnet_user-stats.jpg (Pl@ntnet provides user stats) +[12]: https://www.youtube.com/watch?v=W_cBqaPfRFE +[13]: https://plantnet.org/ diff --git a/published/202107/20210704 7 guides about open source to keep your brain busy this summer.md b/published/202107/20210704 7 guides about open source to keep your brain busy this summer.md new file mode 100644 index 0000000000..16cf08fc77 --- /dev/null +++ b/published/202107/20210704 7 guides about open source to keep your brain busy this summer.md @@ -0,0 +1,111 @@ +[#]: subject: "7 guides about open source to keep your brain busy this summer" +[#]: via: "https://opensource.com/article/21/7/open-source-guides" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lujun9972" +[#]: translator: "zepoch" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13575-1.html" + +让你的大脑在这个夏天保持忙碌的 7 本开源指南 +====== + +> 下载我们的免费指南之一:开发一个基于 Python 的电子游戏;使用开源工具来让你的生活井井有条;完成家庭自动化项目;或尝试你的树莓派家用实验室。 + +![](https://img.linux.net.cn/data/attachment/album/202107/12/225953hynu3qud32s1jn1z.jpg) + +(LCTT 译注:opensource.com 的免费电子书需要免费注册一个用户才能下载。) + +### 开启一个新的树莓派项目 + +近十年来,树莓派一直俘获着开源爱好者的心和手。你可以用树莓派做无数的项目,无论是 [监控你的花园][2]、[设置家长监控][3](尤其是在那些漫长的夏天),甚至从你自己的后院 [跟踪飞机][4]。如果这些很酷的项目激起了你的兴趣,但你的树莓派仍在吃灰,那么你需要下载我们的指南来促使你开始行动。在你知道它之前,你需要学习 [如何管理它们][5],因为你将与很多树莓派一起工作! + +**下载:《[如何开始使用你的树莓派][6]》** + +### 设计你的开源智能家庭 + +一个聪明且有用的方式去使用树莓派的方式是去设计你的智能家庭。使用家庭助手或其他的开源工具,你的家可以按你自己的设置进行自动化而无需借助第三方平台。作者 [Steve Ovens][7] 用这本家庭自动化集锦的手写电子书来指导你的每一步工作。 + +**下载:《[使用开源工具实现家庭自动化的实用指南][7]》** + +### 将事情梳理地井井有条 + +可能你并没做好准备使得你的家庭完全自动化,但是你可能会对梳理你的思维有兴趣。为什么不从你的 to-do 列表开始呢?在贡献者 [Kevin Sonney][8] 的生产力指导下,你将会熟悉六个开源工具的使用,从而帮你把事情安排得井井有条。一旦你完成了他的教程,你就会感到事情井井有条,在这个夏天终于有时间放松了。 + +**下载:《[六个可以将事情梳理地井井有条的开源工具][9]》** + +### 学习如何写代码 + +电脑无处不在。能吐槽一下很多编程语言对初学者不是很友好吗? + +有许多为初学者设计的编程语言。Bash 是 Linux 和 macOS 终端中使用的相同的脚本语言,如果你新开始写代码,Bash 将会是一个伟大的开始。你可以以 [互动的方式学习它][10],之后下载我们的电子书以了解更多。 + +**下载:《[Bash 编程指南][11]》** + +### 用 Python 写一个游戏 + +另一个初学者喜欢的编程语言是 Python。它不仅受到仅仅学习编码的中小学生的欢迎,还被专业程序员用来做 [网站开发][12]、[视频编辑][13] 以及 [云端自动化][14]。无论你最终的目标是什么,开始学习 Python 的一个有趣的方式是编写一个自己的游戏。 + +**下载:《[Python 游戏开发指南][15]》** + +### 发现使用 Jpuyter 的巧妙方法 + +为了让 Python 具有交互性且易于分享,Jupyter 项目提供了基于 Web 的发展环境。你可以在“笔记本”文件中写代码,然后将其发送给其他用户,以便他们轻松复制和可视化你所做的。它是代码、文档和演示文稿的完美组合,而且非常灵活。下载 Moshe Zadka 的多方面指南了解更多关于 Jupyter。 + +**下载:《[使用 Jupyer 的六种惊艳方式][16]》** + +### 在你的家庭实验室里尝试 Kubernetes + +现在,你已经在你的树莓派上安装了 Linux,已经登录,已设置新用户并 [配置了 sudo][17] 使得能够进入管理员模式,你正在 [运行所有你需要的服务][18] 。之后呢? + +如果你对 Linux 和服务器管理感到满意,你的下一步可能是云服务。可以读一下 Chris Collins 的电子书,从你的家庭实验室的舒适中了解所有关于容器,吊舱和集群的信息。 + +**下载: 《[在你的树莓派家庭实验室上运行 Kubernetes][19]》** + +### 福利:书籍列表 + +只工作不休息是不健康的。夏天(或任何季节,它是在你的世界的一部分)假期是为了休息,没有什么比坐在门廊或海滩上读一本好书更休闲人心的。下面是一些最近列出的书,以激发一些想法: + + * [8 本供开源技术专家读的书(2021)][20] + * [十几本适合所有年龄段的书][21] + * [8 本提升领导力的书籍][22] + * [6 本必读的云架构书籍][23] + * 我们的第一份 [2010 年的书籍列表][24] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/open-source-guides + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[zepoch](https://github.com/zepoch) +校对:[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/chen-mizrach-unsplash.jpg?itok=S_wIO5e8 "One chair on a sandy beach" +[2]: https://opensource.com/article/21/5/monitor-greenhouse-open-source +[3]: https://opensource.com/article/21/3/raspberry-pi-parental-control +[4]: https://opensource.com/article/21/3/tracking-flights-raspberry-pi +[5]: https://opensource.com/article/21/5/raspberry-pi-cockpit +[6]: https://opensource.com/downloads/raspberry-pi-guide +[7]: https://opensource.com/downloads/home-automation-ebook +[8]: https://opensource.com/users/ksonney +[9]: https://opensource.com/downloads/organization-tools +[10]: https://opensource.com/article/19/10/learn-bash-command-line-games#bashcrawl +[11]: https://opensource.com/downloads/bash-programming-guide +[12]: https://opensource.com/article/18/4/flask +[13]: https://opensource.com/article/21/2/linux-python-video +[14]: https://opensource.com/article/19/2/quickstart-guide-ansible +[15]: https://opensource.com/downloads/python-gaming-ebook +[16]: https://opensource.com/downloads/jupyter-guide +[17]: https://opensource.com/article/19/10/know-about-sudo +[18]: https://opensource.com/article/20/5/systemd-units +[19]: https://opensource.com/downloads/kubernetes-raspberry-pi +[20]: https://opensource.com/article/21/6/2021-opensourcecom-summer-reading-list +[21]: https://opensource.com/article/20/6/summer-reading-list +[22]: https://enterprisersproject.com/article/2021/5/8-leadership-books-self-improvement +[23]: https://www.redhat.com/architect/books-cloud-architects +[24]: https://opensource.com/life/10/8/open-books-opensourcecom-summer-reading-list diff --git a/published/202107/20210705 Enter invisible passwords using this Python module.md b/published/202107/20210705 Enter invisible passwords using this Python module.md new file mode 100644 index 0000000000..530a0ac62f --- /dev/null +++ b/published/202107/20210705 Enter invisible passwords using this Python module.md @@ -0,0 +1,150 @@ +[#]: subject: (Enter invisible passwords using this Python module) +[#]: via: (https://opensource.com/article/21/7/invisible-passwords-python) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13579-1.html) + +使用这个 Python 模块输入不可见的密码 +====== + +> 用 GPG 和 Python 的 getpass 模块给你的密码多一层安全保障。 + +![](https://img.linux.net.cn/data/attachment/album/202107/14/101543fy6up6imco65mi68.jpg) + +密码对程序员来说尤其重要。你不应该在不加密的情况下存储它们,而且你也不应该在用户输入密码的时候显示出输入的内容。当我决定要提高我的笔记本电脑的安全性时,这对我来说变得特别重要。我对我的家目录进行了加密,但当我登录后,任何以纯文本形式存储在配置文件中的密码都有可能暴露在偷窥者面前。 + +具体来说,我使用一个名为 [Mutt][2] 的应用作为我的电子邮件客户端。它可以让我在我的 Linux 终端中阅读和撰写电子邮件,但通常它希望在其配置文件中有一个密码。我限制了我的 Mutt 配置文件的权限,以便只有我可以看到它,我是我的笔记本电脑的唯一用户,所以我并不真的担心经过认证的用户会无意中看到我的配置文件。相反,我想保护自己,无论是为了吹嘘还是为了版本控制,不至于心不在焉地把我的配置发布到网上,把我的密码暴露了。此外,虽然我不希望我的系统上有不受欢迎的客人,但我确实想确保入侵者不能通过对我的配置上运行 `cat` 就获得我的密码。 + +### Python GnuPG + +Python 模块 `python-gnupg` 是 `gpg` 应用的一个 Python 封装。该模块的名字是 `python-gnupg`,你不要把它和一个叫做 `gnupg` 的模块混淆。 + +[GnuPG][3](GPG) 是 Linux 的默认加密系统,我从 2009 年左右开始使用它。我对它很熟悉,对它的安全性有很高的信任。 + +我决定将我的密码输入 Mutt 的最好方法是将我的密码存储在一个加密的 GPG 文件中,创建一个提示我的 GPG 密码来解锁这个加密文件,然后将密码交给 Mutt(实际上是交给 `offlineimap` 命令,我用它来同步我的笔记本和电子邮件服务器)。 + +[用 Python 获取用户输入][4] 是非常容易的。对 `input` 进行调用,无论用户输入什么,都会被存储为一个变量: + +``` +print("Enter password: ") +myinput = input() + +print("You entered: ", myinput) +``` + +我的问题是,当我根据密码提示在终端上输入密码时,我所输入的所有内容对任何从我肩膀上看过去或滚动我的终端历史的人来说都是可见的: + +``` +$ ./test.py +Enter password: my-Complex-Passphrase +``` + +### 用 getpass 输入不可见密码 + +正如通常的情况一样,有一个 Python 模块已经解决了我的问题。这个模块是 `getpass4`,从用户的角度来看,它的行为和 `input` 完全一样,只是不显示用户输入的内容。 + +你可以用 [pip][5] 安装这两个模块: + +``` +$ python -m pip install --user python-gnupg getpass4 +``` + +下面是我的 Python 脚本,用于创建密码提示: + +``` +#!/usr/bin/env python +# by Seth Kenlon +# GPLv3 + +# install deps: +# python3 -m pip install --user python-gnupg getpass4 + +import gnupg +import getpass +from pathlib import Path + +def get_api_pass(): + homedir = str(Path.home()) + gpg = gnupg.GPG(gnupghome=os.path.join(homedir,".gnupg"), use_agent=True) + passwd = getpass.getpass(prompt="Enter your GnuPG password: ", stream=None) + + with open(os.path.join(homedir,'.mutt','pass.gpg'), 'rb') as f: + apipass = (gpg.decrypt_file(f, passphrase=passwd)) + + f.close() + + return str(apipass) + +if __name__ == "__main__": + apipass = get_api_pass() + print(apipass) +``` + +如果你想试试,把文件保存为 `password_prompt.py`。如果你使用 `offlineimap` 并想在你自己的密码输入中使用这个方案,那么把它保存到某个你可以在 `.offlineimaprc` 文件中指向 `offlineimap` 的位置(我使用 `~/.mutt/password_prompt.py`)。 + +### 测试密码提示 + +要查看脚本的运行情况,你首先必须创建一个加密文件(我假设你已经设置了 GPG): + +``` +$ echo "hello world" > pass +$ gpg --encrypt pass +$ mv pass.gpg ~/.mutt/pass.gpg +$ rm pass +``` + +现在运行 Python 脚本: + +``` +$ python ~/.mutt/password_prompt.py +Enter your GPG password: +hello world +``` + +当你输入时没有任何显示,但只要你正确输入 GPG 口令,你就会看到该测试信息。 + +### 将密码提示符与 offlineimap 整合起来 + +我需要将我的新提示与 `offlineimap` 命令结合起来。我为这个脚本选择了 Python,因为我知道 `offlineimap` 可以对 Python 程序进行调用。如果你是一个 `offlineimap` 用户,你会明白唯一需要的“整合”是在你的 `.offlineimaprc` 文件中改变两行。 + +首先,添加一行引用 Python 文件的内容: + +``` +pythonfile = ~/.mutt/password_prompt.py +``` + +然后将 `.offlineimaprc`中的 `remotepasseval` 行改为调用 `password_prompt.py`中的 `get_api_pass()` 函数: + +``` +remotepasseval = get_api_pass() +``` + +配置文件中不再有密码! + +### 安全问题 + +在你的个人电脑上考虑安全问题有时会让人觉得很偏执。你的 SSH 配置是否真的需要限制为 600?隐藏在名为 `.mutt` 的无关紧要的电子邮件密码真的重要吗?也许不重要。 + +然而,知道我没有把敏感数据悄悄地藏在我的配置文件里,使我更容易把文件提交到公共 Git 仓库,把片段复制和粘贴到支持论坛,并以真实好用的配置文件的形式分享我的知识。仅就这一点而言,安全性的提高使我的生活更加轻松。而且有这么多好的 Python 模块可以提供帮助,这很容易实现。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/invisible-passwords-python + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/password.jpg?itok=ec6z6YgZ (Password lock) +[2]: http://www.mutt.org/ +[3]: https://gnupg.org/ +[4]: https://opensource.com/article/20/12/learn-python +[5]: https://opensource.com/article/19/11/python-pip-cheat-sheet diff --git a/published/202107/20210706 Edit PDFs on the Linux command line.md b/published/202107/20210706 Edit PDFs on the Linux command line.md new file mode 100644 index 0000000000..d0b985bf79 --- /dev/null +++ b/published/202107/20210706 Edit PDFs on the Linux command line.md @@ -0,0 +1,96 @@ +[#]: subject: (Edit PDFs on the Linux command line) +[#]: via: (https://opensource.com/article/21/7/qpdf-command-line) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13581-1.html) + +在 Linux 命令行上编辑 PDF +====== + +> 使用 qpdf 和 poppler-utils 来分割、修改和合并 PDF 文件。 + +![](https://img.linux.net.cn/data/attachment/album/202107/15/093249xh6dmg846py8bgbc.jpg) + +你收到的许多文件都是 PDF 格式的。有时这些 PDF 需要进行处理。例如,可能需要删除或添加页面,或者你可能需要签署或修改一个特定的页面。 + +不管是好是坏,这就是我们所处的现实。 + +有一些花哨的图形用户界面工具可以让你编辑 PDF,但我一直对命令行感到最舒服。在这个任务的许多命令行工具中,当我想修改一个 PDF 时,我使用的是 `qpdf` 和 `poppler-utils`。 + +### 安装 + +在 Linux 上,你可以用你的包管理器(如 `apt` 或 `dnf`)来安装 `qpdf` 和 `poppler-utils`。比如在 Fedora 上: + +``` +$ sudo dnf install qpdf poppler-utils +``` + +在 macOS 上,使用 [MacPorts][2] 或 [Homebrew][3]。在 Windows 上,使用 [Chocolatey][4]。 + +### qpdf + +`qpdf` 命令可以做很多事情,但我主要用它来: + + 1. 将一个 PDF 分割成不同的页面 + 2. 将多个 PDF 文件合并成一个文件 + +要将一个 PDF 分割成不同的页面: + +``` +qpdf --split-pages original.pdf split.pdf +``` + +这就会生成像 `split-01.pdf`、`split-02.pdf` 这样的文件。每个文件都是一个单页的 PDF 文件。 + +合并文件比较微妙: + +``` +qpdf --empty concatenated.pdf --pages split-*.pdf -- +``` + +这就是 `qpdf` 默认的做法。`--empty` 选项告诉 qpdf 从一个空文件开始。结尾处的两个破折号(`--`)表示没有更多的文件需要处理。这是一个参数反映内部模型的例子,而不是人们使用它的目的,但至少它能运行并产生有效的 PDF! + +### poppler-utils + +这个软件包包含几个工具,但我用得最多的是 [pdftoppm][5],它把 PDF 文件转换为可移植的像素图(`ppm`)文件。我通常在用 `qpdf` 分割页面后使用它,并需要将特定页面转换为我可以修改的图像。`ppm` 格式并不为人所知,但重要的是大多数图像处理方法,包括 [ImageMagick][6]、[Pillow][7] 等,都可以使用它。这些工具中的大多数也可以将文件保存为 PDF。 + +### 工作流程 + +我通常的工作流程是: + + * 使用 `qpdf` 将 PDF 分割成若干页。 + * 使用 `poppler-utils` 将需要修改的页面转换为图像。 + * 根据需要修改图像,并将其保存为 PDF。 + * 使用 `qpdf` 将各页合并成一个 PDF。 + +### 其他工具 + +有许多很好的开源命令来处理 PDF,无论你是 [缩小它们][8]、[从文本文件创建它们][9]、[转换文档][10],还是尽量 [完全避免它们][11]。你最喜欢的开源 PDF 工具是什么?请在评论中分享它们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/qpdf-command-line + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_blue_text_editor_web.png?itok=lcf-m6N7 (Text editor on a browser, in blue) +[2]: https://opensource.com/article/20/11/macports +[3]: https://opensource.com/article/20/6/homebrew-mac +[4]: https://opensource.com/article/20/3/chocolatey +[5]: https://www.xpdfreader.com/pdftoppm-man.html +[6]: https://opensource.com/article/17/8/imagemagick +[7]: https://opensource.com/article/20/8/edit-images-python +[8]: https://opensource.com/article/20/8/reduce-pdf +[9]: https://opensource.com/article/20/5/pandoc-cheat-sheet +[10]: https://opensource.com/article/21/3/libreoffice-command-line +[11]: https://opensource.com/article/19/3/comic-book-archive-djvu diff --git a/published/202107/20210706 Send and receive Gmail from the Linux command line.md b/published/202107/20210706 Send and receive Gmail from the Linux command line.md new file mode 100644 index 0000000000..13d2d546eb --- /dev/null +++ b/published/202107/20210706 Send and receive Gmail from the Linux command line.md @@ -0,0 +1,258 @@ +[#]: subject: (Send and receive Gmail from the Linux command line) +[#]: via: (https://opensource.com/article/21/7/gmail-linux-terminal) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13573-1.html) + +在 Linux 命令行中收发 Gmail 邮件 +====== + +> 即使你用的是诸如 Gmail 的托管邮件服务,你也可以通过 Mutt 在终端里收发电子邮件。 + +![](https://img.linux.net.cn/data/attachment/album/202107/12/104952frwgx4oz4xrinbxl.jpg) + +我喜欢在 Linux 终端上读写电子邮件的便捷,因此我是 [Mutt][2] 这个轻量简洁的电子邮件客户端的忠实用户。对于电子邮件服务来说,不同的系统配置和网络接入并不会造成什么影响。这个客户端通常隐藏在我 Linux 终端的 [某个标签页或者某个终端复用器的面板][3] 上,需要用的时候随时可以调出来,不需要使用的时候放到后台,就不需要在桌面上一直放置一个电子邮件客户端的应用程序。 + +当今我们大多数人使用的都是托管电子邮件账号,在这种使用场景中并不会与电子邮件协议发生过多的直接交互。而 Mutt(以及更早的 ELM)是在更简单的时代创建的,那时候检查邮件只是对 `uucp` 的调用,以及对 `/var/mail` 的读取。当然 Mutt 也很与时俱进,随着各种流行的协议(如 POP、IMAP、LDAP)出现,它都实现了良好的支持。因此,即使我们使用的是 Gmail 这种邮件服务,也可以与 Mutt 无缝衔接。 + +如今在大多数情况下,用户都不会拥有自己的电子邮件服务器,大部分用户都会选择 Gmail,因此下文会以 Mutt + Gmail 为例作介绍。如果你比较注重电子邮件隐私,不妨考虑 [ProtonMail][4] 或者 [Tutanota][5],它们都提供完全加密的电子邮件服务。其中 Tutanota 包含很多 [开源组件][6],而 ProtonMail 则为付费用户提供 [IMAP 桥接][7],简化了在非浏览器环境下的邮件访问。不过,很多公司、学校和组织都没有自己的电子邮件服务,而是使用 Gmail 提供的邮件服务,这样一来,大部分用户都会有一个 Gmail 邮箱。 + +当然,如果你自己就 [拥有电子邮件服务器][8],那么使用 Mutt 就更简单了。下面我们开始介绍。 + +### 安装 Mutt + +在 Linux 系统上,一般可以直接从发行版提供的软件库中安装 Mutt,另外需要在家目录中创建一个 `.mutt` 目录以存放配置文件: + +``` +$ sudo dnf install mutt +$ mkdir ~/.mutt +``` + +在 MacOS 上,可以通过 [MacPorts][9] 或者 [Homebrew][10] 安装;在 Windows 上则可以使用 [Chocolatey][11] 安装。 + +Mutt 是一个邮件用户代理Mail User Agent(MUA),因此它的作用是读取、编写以及向外部邮件池发送邮件。向邮件服务器实际传输邮件是其它应用或邮件服务的工作,尽管它们可以和 Mutt 进行协作,让我们看起来是 Mutt 完成了所有功能,但实际上并非如此。在弄懂了两者之间的区别之后,我们会对 Mutt 的配置更加清楚。 + +这也是为什么除了 Mutt 之外,我们还需要视乎进行通信的服务种类选择一些辅助应用程序。在本文中我使用的是 IMAP 服务,这可以让我本地的电子邮件副本与电子邮件服务提供商的远程邮件副本保持同步。如果你选择 POP 服务,配置的难度就更下一个台阶了,也无需依赖其它外部工具。我们需要 OfflineIMAP 这个 Python 应用程序来实现 IMAP 的集成,这个应用程序可以在 [它的 GitHub 存储库][12] 获取。 + +OfflineIMAP 目前仍然在从 Python 2 移植到 Python 3,目前需要手动安装,但以后你也可以通过 `python3 -m pip` 命令进行安装。 + +OfflineIMAP 依赖于 `imaplib2` 库,这个库也在努力开发当中,所以我更喜欢手动安装。同样地,也是通过 Git 将代码库克隆到本地,进入目录后使用 `pip` 安装。 + +首先安装 `rfc6555` 依赖: + +``` +$ python3 -m pip install --user rfc6555 +``` + +然后从源码安装 `imaplib2`: + +``` +$ git clone git@github.com:jazzband/imaplib2.git +$ pushd imaplib2.git +$ python3 -m pip install --upgrade --user . +$ popd +``` + +最后从源码安装 OfflineIMAP: + +``` +$ git clone git@github.com:OfflineIMAP/offlineimap3.git +$ pushd offlineimap3.git +$ python3 -m pip install --upgrade --user . +$ popd +``` + +如果你使用的是 Windows 上的 Cygwin,那么你还需要安装 [Portlocker][14]。 + +### 配置 OfflineIMAP + +OfflineIMAP 默认使用 `~/.offlineimaprc` 这个配置文件,在它的代码库中会有一个名为 `offlineimap.conf` 的配置模板,可以直接将其移动到家目录下: + +``` +$ mv offlineimap3.git/offlineimap.conf ~/.offlineimaprc` +``` + +你可以使用任何文本编辑器打开浏览这个配置文件,它的注释很完善,便于了解各个可用的配置项。 + +以下是我的 `.offlineimaprc` 配置文件,为了清晰起见,我把其中的注释去掉了。对于你来说其中有些配置项的值可能会略有不同,但或许会为你的配置带来一些启发: + +``` +[general] +ui = ttyui +accounts = %your-gmail-username% +pythonfile = ~/.mutt/password_prompt.py +fsync = False + +[Account %your-gmail-username%] +localrepository = %your-gmail-username%-Local +remoterepository = %your-gmail-username%-Remote +status_backend = sqlite +postsynchook = notmuch new + +[Repository %your-gmail-username%-Local] +type = Maildir +localfolders = ~/.mail/%your-gmail-username%-gmail.com +nametrans = lambda folder: {'drafts': '[Gmail]/Drafts', + 'sent': '[Gmail]/Sent Mail', + 'flagged': '[Gmail]/Starred', + 'trash': '[Gmail]/Trash', + 'archive': '[Gmail]/All Mail', + }.get(folder, folder) + +[Repository %your-gmail-username%-Remote] +maxconnections = 1 +type = Gmail +remoteuser = %your-gmail-username%@gmail.com +remotepasseval = '%your-gmail-API-password%' +## remotepasseval = get_api_pass() +sslcacertfile = /etc/ssl/certs/ca-bundle.crt +realdelete = no +nametrans = lambda folder: {'[Gmail]/Drafts': 'drafts', + '[Gmail]/Sent Mail': 'sent', + '[Gmail]/Starred': 'flagged', + '[Gmail]/Trash': 'trash', + '[Gmail]/All Mail': 'archive', + }.get(folder, folder) +folderfilter = lambda folder: folder not in ['[Gmail]/Trash', + '[Gmail]/Important', + '[Gmail]/Spam', + ] +``` + +配置文件里有两个可以替换的值,分别是 `%your-gmail-username%` 和 `%your-gmail-API-password%`。其中第一个值需要替换为 Gmail 用户名,也就是邮件地址中 `@gmail.com` 左边的部分。而第二个值则需要通过双因素身份验证(2FA)后从 Google 获取(即使你在查收邮件时不需要使用 2FA)。 + +### 为 Gmail 设置双因素身份验证(2FA) + +Google 希望用户通过 Gmail 网站收发电子邮件,因此当你在 Gmail 网站以外操作电子邮件时,实际上是被 Google 作为“开发者”看待(尽管你没有进行任何开发工作)。也就是说,Google 会认为你正在创建一个应用程序。要获得开发者层面的应用程序密码,就必须设置双因素身份验证。完成了这个过程以后,就可以获得一个应用程序密码,Mutt 可以通过这个密码在浏览器以外的环境登录到你的电子邮箱中。 + +为了安全起见,你还可以在 Google 的 [账号安全][15] 页面中添加一个用于找回的电子邮件地址。 + +在账号安全页面中,点击“两步验证2-step Verification”开始设置 2FA,设置过程中需要用到一部手机。 + +激活 2FA 之后,账号安全页面中会出现“应用程序密码App Passwords”选项,点击就可以为 Mutt 创建一个新的应用程序密码。在 Google 生成密码之后,将其替换 `.offlineimaprc` 配置文件中的 `%your-gmail-API-password%` 值。 + +直接将应用程序密码记录在 `.offlineimaprc` 文件中,这种以纯文本形式存储的做法有一定的风险。长期以来我都是这样做的,而且感觉良好,因为我的家目录是加密的。但出于安全考虑,我现在已经改为使用 GnuPG 加密应用程序密码,这部分内容不在本文的讨论范围,关于如何设置 GPG 密码集成,可以参考我的 [另一篇文章][16]。 + +### 在 Gmail 启用 IMAP + +在你永远告别 Gmail 网页界面之前,还有最后一件事:你必须启用 Gmail 账户的 IMAP 访问。 + +在 Gmail 网站页面中,点击右上角的“cog”图标,选择“查看所有设置See all settings”。在 Gmail 设置页面中,点击“POP/IMAP”标签页,并选中“启用 IMAPenable IMAP”,然后保存设置。 + +现在就可以在浏览器以外访问你的 Gmail 电子邮件了。 + +### 配置 Mutt + +Mutt 的配置过程相对简单。和 [.bashrc][17]、[.zshrc][18]、`.emacs` 这些配置文件一样,网络上有很多优秀的 .muttrc 配置文件可供参照。我自己的 `.muttrc` 配置文件则借鉴了 [Kyle Rankin][19]、[Paul Frields][20] 等人的配置项和想法。下面列出我的配置文件的一些要点: + +``` +set ssl_starttls=yes +set ssl_force_tls=yes + +set from='tux@example.com' +set realname='Tux Example' + +set folder = imaps://imap.gmail.com/ +set spoolfile = imaps://imap.gmail.com/INBOX +set postponed="imaps://imap.gmail.com/[Gmail]/Drafts" +set smtp_url="smtp://smtp.gmail.com:25" +set move = no +set imap_keepalive = 900 +set record="imaps://imap.gmail.com/[Gmail]/Sent Mail" + +# Paths +set folder = ~/.mail +set alias_file = ~/.mutt/alias +set header_cache = "~/.mutt/cache/headers" +set message_cachedir = "~/.mutt/cache/bodies" +set certificate_file = ~/.mutt/certificates +set mailcap_path = ~/.mutt/mailcap +set tmpdir = ~/.mutt/temp +set signature = ~/.mutt/sig +set sig_on_top = yes + +# Basic Options +set wait_key = no +set mbox_type = Maildir +unset move # gmail does that + +# Sidebar Patch +set sidebar_visible = yes +set sidebar_width = 16 +color sidebar_new color221 color233 + +## Account Settings +# Default inbox +set spoolfile = "+example.com/INBOX" + +# Mailboxes to show in the sidebar. +mailboxes +INBOX \ + +sent \ + +drafts + +# Other special folder +set postponed = "+example.com/drafts" + +# navigation +macro index gi "=example.com/INBOX" "Go to inbox" +macro index gt "=example.com/sent" "View sent" +``` + +整个配置文件基本是开箱即用的,只需要将其中的 `Tux Example`和 `example.com` 替换为你的实际值,并将其保存为 `~/.mutt/muttrc` 就可以使用了。 + +### 启动 Mutt + +在启动 Mutt 之前,需要先启动 `offlineimap` 将远程邮件服务器上的邮件同步到本地。在首次启动的时候耗时可能会比较长,只需要让它整晚运行直到同步完成就可以了。 + +在同步完成后,启动 Mutt: + +``` +$ mutt +``` + +Mutt 会提示你打开用于管理电子邮件的目录权限,并展示收件箱的视图。 + +![Mutt email client][22] + +### 学习使用 Mutt + +在学习使用 Mutt 的过程中,你可以找到最符合你使用习惯的 `.muttrc` 配置。例如我的 `.muttrc` 配置文件集成了使用 Emacs 编写邮件、使用 LDAP 搜索联系人、使用 GnuPG 对邮件进行加解密、链接获取、HTML 视图等等一系列功能。你可以让 Mutt 做到任何你想让它做到的事情,你越探索,就能发现越多。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/gmail-linux-terminal + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[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/lenovo-thinkpad-laptop-window-focus.png?itok=g0xPm2kD (young woman working on a laptop) +[2]: http://www.mutt.org/ +[3]: https://opensource.com/article/21/5/linux-terminal-multiplexer +[4]: https://protonmail.com +[5]: https://tutanota.com +[6]: https://github.com/tutao/tutanota +[7]: https://protonmail.com/bridge/ +[8]: https://www.redhat.com/sysadmin/configuring-email-server +[9]: https://opensource.com/article/20/11/macports +[10]: https://opensource.com/article/20/6/homebrew-mac +[11]: https://opensource.com/article/20/3/chocolatey +[12]: https://github.com/OfflineIMAP/offlineimap3 +[13]: mailto:git@github.com +[14]: https://pypi.org/project/portalocker +[15]: https://myaccount.google.com/security +[16]: https://opensource.com/article/21/6/enter-invisible-passwords-using-python-module +[17]: https://opensource.com/article/18/9/handy-bash-aliases +[18]: https://opensource.com/article/19/9/adding-plugins-zsh +[19]: https://twitter.com/kylerankin +[20]: https://twitter.com/stickster +[21]: mailto:tux@example.com +[22]: https://opensource.com/sites/default/files/mutt.png (Mutt email client) diff --git a/published/202107/20210707 Generate passwords on the Linux command line.md b/published/202107/20210707 Generate passwords on the Linux command line.md new file mode 100644 index 0000000000..492c39b954 --- /dev/null +++ b/published/202107/20210707 Generate passwords on the Linux command line.md @@ -0,0 +1,114 @@ +[#]: subject: (Generate passwords on the Linux command line) +[#]: via: (https://opensource.com/article/21/7/generate-passwords-pwgen) +[#]: author: (Sumantro Mukherjee https://opensource.com/users/sumantro) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (turbokernel) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13582-1.html) + +在 Linux 命令行中生成密码 +====== + +> 在命令行上创建符合特定规范的密码。 + +![](https://img.linux.net.cn/data/attachment/album/202107/15/094657l4l494c0080u2ca4.jpg) + +大多数网站或应用都要求用户创建带有安全密码的账户,以便他们能够迎合用户体验。虽然这有利于网站开发者,但肯定不会让用户的生活更轻松。 + +有时,创建密码的规则是如此严格,以至于难以生成一个强壮且合规的组合。如果有一个工具可以生成符合网站或应用程序要求的任何规则的安全密码,那就容易多了。 + +这就是 `pwgen` 的用武之地。根据它的 [手册页][2]:“pwgen 生成的密码是为了让人容易记住,同时又尽可能的安全。” 它返回符合你所提供的规则的多个密码选项,这样你就可以选择一个你喜欢的(而且可能更容易记住)。 + +### 安装 pwgen + +在 Linux 上,你可以通过包管理器安装 `pwgen`。例如,在 Fedora 上: + +``` +$ sudo dnf install pwgen +``` + +在 macOS 上,可以使用 [MacPorts][3] 或 [Homebrew][4]。在 Windows 上,可以使用 [Chocolatey][5]。 + +### 使用 pwgen 生成密码 + +有几种方式可以通过向 `pwgen` 传递参数来生成密码,这取决于你所需的参数。这里有一些例子。更多的参数选项请查阅手册页。 + +如果你需要一个安全的、难以记忆的特定长度的密码,请运行 `pwgen --secure`(或简写 `-s`),后面跟上你所需的密码长度: + +``` +$ pwgen -s 25 +pnFBg9jB8AlKL3feOuS2ZwMGb xlmDRoaLssduXTdGV6jkQhUGY O3IUB3CH7ry2kD4ZrSoODzWez +dENuvhkF3mmeb4FfXd4VPU2dE EMCi1sHFKHUVmbVajXWleFBzD 4UXJIu3JztVzYz6qJktBB3KCv +AF9WM7hmG89cpTlg8PksI7jsL LSSaT7DD4IT8DUgRAgY8Zt06m Nths10uT0bIMGsPuE0XEHDxsj +6YjLRbg3VnGnrzkoQCmrneLmm Tam1Mftac5RxrZPoXJtXx1Qdy BPqePJW4LdTtFnuZOepKEj0o0 +Ss8veqqf95zusqYPsfE7mLb93 4KuZdReO5lhKff7Xv1en1Hefs is7hjLnDrVCUJ7Hh6zYUzfppn +UXOfENPRJYWiroIWEt5IgAwdJ t8i4hM4cDuL8pN1rpFKHnx7yw Wr7gyuyU2br7aCbiH5M5ogvc6 +evk90lUmK2rOUWGgnqmznn0a9 Lflyc9svJfaBRRMin24j0P9ec hIzyJIwCpklDjgOb5PrMkyPCI +bhYcaV7GXfUiCMZ1kvMnlmKLx v4EJew54u6s4ZCirOTAWjfPQ2 IdemhbOHOm4Qo70WGibaNTOpO +j6XkmdB3LBfqZf5mbL3GndliG PpZbeXfWOFCpNARyXt1FWPAb8 OLQS2HFuqkiSg56sdxNsg5vaJ +1g666HxJPQ6l2L0RlaDEMoi50 1t6au7VuTN9HVPpiVmd1Gurli 46OAWypvwtZZUdBEfaHSunjpw +0LiRj9dbtMuI4cbDES8O4gYRq 2HPiaq5AANvVT32fWqNIruu3R 3lT5B107WoUbHsELkKUjnEEih +gLmYUTp0XZJWvIVbA5rFvBT54 LEm6QVeTMinc056DC9c4V55cV ipV45Ewj704365byKhY8zn766 +``` + +运行 `pwgen -symbols`(或简写 `-y`),再加上所需的密码长度,生成包含特殊字符的密码: + +``` +$ pwgen -y 25 +Osh0chahxe0won9aech4ese?v pemoh2ohm9aim;iu4Eiy"ah0y Taiqu;o2aeSh+o4aedoagait3 +Vei;phoh5owai5jui+t|ei3ot teu!w7mahxoh0Po7ohph8Iez6 quie#phooCeu2lohm5shaPaer +eTh5AechaexieToh9ez5eeZ;e nuloh1ico0Nool:eGaig@ae9No OVahh2OhNgahtu8iethaR@i7o ouFai8ahP@eil4Ieh5le5ipu5 +eeT4tahW0ieng9fe?i5auM3ie seet0ohc4aiJei]koiGha2zu% iuh@oh4eix0Vuphi?o,hei9me +loh0Aeph=eix(ohghe6chee3z ahgh2eifiew8dahG_aeph8woo oe!B4iasaeHo`ungie3taekoh +cei!c age 是一个简单的、易于使用的工具,允许你用一个密码来加密和解密文件。 + +![](https://img.linux.net.cn/data/attachment/album/202107/18/102604m808ppq4ddd8w910.jpg) + +文件的保护和敏感文档的安全加密是用户长期以来关心的问题。即使越来越多的数据被存放在网站和云服务上,并由具有越来越安全和高强度密码的用户账户来保护,但我们能够在自己的文件系统中存储敏感数据仍有很大的价值,特别是我们能够快速和容易地加密这些数据时。 + +[age][2] 能帮你这样做。它是一个小型且易于使用的工具,允许你用一个密码加密一个文件,并根据需要解密。 + +### 安装 age + +`age` 可以从众多 Linux 软件库中 [安装][3]。 + +在 Fedora 上安装它: + +``` +$ sudo dnf install age -y +``` + +在 macOS 上,使用 [MacPorts][4] 或 [Homebrew][5] 来安装。在 Windows 上,使用 [Chocolatey][6] 来安装。 + +### 用 age 加密和解密文件 + +`age` 可以用公钥或用户自定义密码来加密和解密文件。 + +#### 在 age 中使用公钥 + +首先,生成一个公钥并写入 `key.txt` 文件: + +``` +$ age-keygen -o key.txt +Public key: age16frc22wz6z206hslrjzuv2tnsuw32rk80pnrku07fh7hrmxhudawase896m9 +``` + +### 使用公钥加密 + +要用你的公钥加密一个文件: + +``` +$ touch mypasswds.txt | age -r \ + ageage16frc22wz6z206hslrjzuv2tnsuw32rk80pnrku07fh7hrmxhudawase896m9 \ + > mypass.tar.gz.age +``` + +在这个例子中,我使用生成的公钥加密文件 `mypasswds.txt`,保存在名为 `mypass.tar.gz.age` 的加密文件中。 + +### 用公钥解密 + +如需解密加密文件,使用 `age` 命令和 `--decrypt` 选项: + +``` +$ age --decrypt -i key.txt -o mypass.tar.gz mypass.tar.gz.age +``` + +在这个例子中,`age` 使用存储在 `key.text` 中的密钥,并解密了我在上一步创建的加密文件。 + +### 使用密码加密 + +不使用公钥的情况下对文件进行加密被称为对称加密。它允许用户设置密码来加密和解密一个文件。要做到这一点: + +``` +$ age --passphrase --output mypasswd-encrypted.txt mypasswd.txt +Enter passphrase (leave empty to autogenerate a secure one): +Confirm passphrase: +``` + +在这个例子中,`age` 提示你输入一个密码,它将通过这个密码对输入文件 `mypasswd.txt` 进行加密,并生成加密文件 `mypasswd-encrypted.txt`。 + +### 使用密码解密 + +如需将用密码加密的文件解密,可以使用 `age` 命令和 `--decrypt` 选项: + +``` +$ age --decrypt --output passwd-decrypt.txt mypasswd-encrypted.txt +``` + +在这个例子中,`age` 提示你输入密码,只要你提供的密码与加密时设置的密码一致,`age` 随后将 `mypasswd-encrypted.txt` 加密文件的内容解密为 `passwd-decrypt.txt`。 + +### 不要丢失你的密钥 + +无论你是使用密码加密还是公钥加密,你都_不能_丢失加密数据的凭证。根据设计,如果没有用于加密的密钥,通过 `age` 加密的文件是不能被解密的。所以,请备份你的公钥,并记住这些密码! + +### 轻松实现加密 + +`age` 是一个真正强大的工具。我喜欢把我的敏感文件,特别是税务记录和其他档案数据,加密到 `.tz` 文件中,以便以后访问。`age` 是用户友好的,使其非常容易随时加密。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/linux-age + +作者:[Sumantro Mukherjee][a] +选题:[lujun9972][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/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/document_free_access_cut_security.png?itok=ocvCv8G2 (Scissors cutting open access to files) +[2]: https://github.com/FiloSottile/age +[3]: https://github.com/FiloSottile/age#installation +[4]: https://opensource.com/article/20/11/macports +[5]: https://opensource.com/article/20/6/homebrew-mac +[6]: https://opensource.com/article/20/3/chocolatey diff --git a/published/202107/20210708 Linux Mint 20.2 is Now Available With New Features and Tools.md b/published/202107/20210708 Linux Mint 20.2 is Now Available With New Features and Tools.md new file mode 100644 index 0000000000..2c4933f98f --- /dev/null +++ b/published/202107/20210708 Linux Mint 20.2 is Now Available With New Features and Tools.md @@ -0,0 +1,95 @@ +[#]: subject: (Linux Mint 20.2 is Now Available With New Features and Tools) +[#]: via: (https://news.itsfoss.com/linux-mint-20-2-release/) +[#]: author: (Ankush Das https://news.itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: (lcf33) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13584-1.html) + +包含新功能和工具的 Linux Mint 20.2 已经发布 +====== + +>Linux Mint 20.2 是一次令人兴奋的升级,它有新的应用程序、更新提醒和桌面环境的升级。是时候升级了? + +![](https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/linux-mint-20-2.jpg?w=1200&ssl=1) + +几周前,Linux Mint 20.2 beta 版 [发布][1]了。现在,Linux Mint 20.2 最终稳定版也发布了。 + +这个版本是基于 Ubuntu 20.04 的 LTS(长期支持版本),支持 2025 年截止。 + +来看下这个版本有什么新特性,以及如何获取它。 + +### Linux Mint 20.2: 有什么新特性? + +这个版本主要两点是增加了更新通知。该功能鼓励用户更新系统,以确保安全性。 + +该功能不像 [Windows 系统那样强制更新][2],但它会留意你多久没有更新系统,检查系统运行时间,然后提醒你更新。 +![][3] + +更棒的是,你可以配置更新通知。 + +其他主要升级还有:桌面环境 **Cinnamon 5**,新的**批量改名工具** Bulky,**用 Sticky Notes 取代 GNote** 作为默认笔记应用。 + +![][4] + +批量文件改名工具可以在所有桌面版本中使用,但不包括 Xfce。因为 Xfce 默认的文件管理器(Thunar)已经有该功能。 + +Cinnamon 5 不是很让人激动,不过有一些内在性能改进,并增加了限制内存使用的选项。 + +![][5] + +Sticky Notes 是用 GTK 3 开发的,支持 HiDPI,并提供了更多的功能。同时,与系统托盘整合得更好。 + +![][6] + +### 其他改进 + +在网络上共享文件的 [Warpinator 应用程序][7] 得到了一些升级,变得更有用。 + +其他桌面环境的升级包括 Xfce 4.16 和 MATE 1.24。除此之外,你还会发现一些细微的 UI 改进和错误修复。 + +特别是解决了 NVIDIA 显卡**对混合图形的支持**的问题,这对笔记本电脑用户来说是个好消息。 + +要了解更多变更详情,你可以参考任一桌面版本的 [官方公告][8]。 + +### 下载或升级至 Linux Mint 20.2 + +你可以直接在官方网站 [下载页面][9] 找到稳定版本。 + +- [下载 Linux Mint 20.2][9] + +如果已经安装了 Linux Mint 20 或者 20.1。你可以先检查所有可用更新,然后更新管理器会收到更新。 + +接下来,确保你做了备份(如果你想的话,可以使用 timeshift 工具),然后从**编辑**菜单种静茹更新管理器的系统升级选项,如下所示。 + +![][10] + +当你单击后,屏幕上会出现升级的提示。你也可以通过 [官方升级说明][11] 获得进一步帮助。 + +_你完成升级了吗?你对最新版本有什么看法?欢迎在下面的评论中分享你的想法。_ + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/linux-mint-20-2-release/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[lcf33](https://github.com/lcf33) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://news.itsfoss.com/linux-mint-20-2-beta-release/ +[2]: https://news.itsfoss.com/linux-mint-updates-notice/ +[3]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/linux-mint-update-reminder.png?w=494&ssl=1 +[4]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/bulky-mint.png?w=570&ssl=1 +[5]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/cinnamon-memory.png?w=800&ssl=1 +[6]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/mint-sticky-notes-ui.png?resize=1568%2C937&ssl=1 +[7]: https://news.itsfoss.com/warpinator-android-app/ +[8]: https://blog.linuxmint.com/?p=4102 +[9]: https://linuxmint.com/download.php +[10]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/mint-upgrade.png?w=533&ssl=1 +[11]: https://blog.linuxmint.com/?p=4111 diff --git a/published/202107/20210708 Write good examples by starting with real code.md b/published/202107/20210708 Write good examples by starting with real code.md new file mode 100644 index 0000000000..0815d4e4d4 --- /dev/null +++ b/published/202107/20210708 Write good examples by starting with real code.md @@ -0,0 +1,93 @@ +[#]: subject: "Write good examples by starting with real code" +[#]: via: "https://jvns.ca/blog/2021/07/08/writing-great-examples/" +[#]: author: "Julia Evans https://jvns.ca/" +[#]: collector: "lujun9972" +[#]: translator: "zepoch" +[#]: reviewer: "turbokernel" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13595-1.html" + +从实际代码开始编写好的示例 +====== + +![](https://img.linux.net.cn/data/attachment/album/202107/18/231616z1hhcerhrk3wzwkr.jpg) + +当编写程序时,我花费了大量时间在编写好的示例上。我从未见过有人写过关于如何写出好的示例,所以我就写了一下如何写出一份好的示例。 + +基础思路就是从你写的真实代码开始,然后删除不相关的细节,使其成为一个独立的例子,而不是无中生有地想出一些例子。 + +我将会谈论两种示例:基于真实案例的示例和奇怪的示例 + +### 好的示例是真实的 + +为了说明为什么好的案例应该是真实的,我们就先讨论一个不真实的案例。假设我们在试图解释 Python 的 lambda 函数(这只是我想到的第一个概念)。你可以举一个例子,使用 `map` 和 lambda 来让一组数字变为原先的两倍。 + +``` +numbers = [1, 2, 3, 4] +squares = map(lambda x: x * x, numbers) +``` + +我觉得这个示例不是真实的,有如下两方面的原因: + + * 将一组数字作平方运算不是在真实的程序中完成的事,除非是欧拉项目或某种东西(更多的可能是针对列表的操作) + * `map` 在 Python 中并不常用,即便是做这个我也更愿意写 `[x*x for x in numbers]` + +一个更加真实的 Python lambdas 的示例是使用 `sort` 函数,就像这样: + +``` +children = [{"name": "ashwin", "age": 12}, {"name": "radhika", "age": 3}] +sorted_children = sorted(children, key=lambda x: x['age']) +``` + +但是这个示例是被精心设计的(为什么我们需要对这些孩子按照年龄进行排序呢?)。所以我们如何来做一个真实的示例呢? + +### 如何让你的示例真实起来:看你所写实际代码 + +我认为最简单的来生成一个例子的方法就是,不是凭空出现一个例子(就像我用那个`儿童`的例子),而只是从真正的代码开始! + +举一个例子吧,如果我要用 `sort.+key` 来编写一串 Python 代码,我会发现很多我按某个标准对列表进行排序的真实例子,例如: + + * `tasks.sort(key=lambda task: task['completed_time'])` + * `emails = reversed(sorted(emails, key=lambda x:x['receivedAt']))` + * `sorted_keysizes = sorted(scores.keys(), key=scores.get)` + * `shows = sorted(dates[date], key=lambda x: x['time']['performanceTime'])` + +在这里很容易看到一个规律——这些基本是按时间排序的!因此,你可以明白如何将按时间排序的某些对象(电子邮件、事件等)的简单实例轻松地放在一起。 + +### 现实的例子有助于“布道”你试图解释的概念 + +当我试图去解释一个想法(就好比 Python Lambdas)的时候,我通常也会试图说服读者,说这是值得学习的想法。Python lambdas 是如此的有用!当我去试图说服某个人 lambdas 是很好用的时候,让他想象一下 lambdas 如何帮助他们完成一项他们将要去做的任务或是以及一项他们以前做过的任务,对说服他会很有帮助。 + +### 从真实代码中提炼出示例可能需要很长时间 + +我给出如何使用 `lambda` 和 `sort` 函数的解释例子是十分简单的,它并不需要花费我很长时间来想出来,但是将真实的代码提炼出为一个独立的示例则是会需要花费很长的时间! + +举个例子,我想在这篇文章中融入一些奇怪的 CSS 行为的例子来说明创造一个奇怪的案例是十分有趣的。我花费了两个小时来解决我这周遇到的一个实际的问题,确保我理解 CSS 的实际情况,并将其变成一个小示例。 + +最后,它“仅仅”用了 [五行 HTML 和一点点的 CSS][1] 来说明了这个问题,看起来并不想是我花费了好多小时写出来的。但是最初它却是几百行的 JS/CSS/JavaScript,它需要花费很长时间来将所有的代码化为核心的很少的代码。 + +但我认为花点时间把示例讲得非常简单明了是值得的——如果有成百上千的人在读你的示例,你就节省了他们这么多时间! + +### 就这么多了! + +我觉得还有更多关于示例可以去讲的——几种不同类型的有用示例,例如: + + * 可以更多的改变人的思维而不是直接提供使用的惊喜读者的示例代码 + * 易于复制粘贴以用作初始化的示例 + +也许有一天我还会再写一些呢? :) + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2021/07/08/writing-great-examples/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[zepoch](https://github.com/zepoch) +校对:[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://codepen.io/wizardzines/pen/0eda7725a46c919dcfdd3fa80aff3d41 diff --git a/published/202107/20210709 How to Install Zlib on Ubuntu Linux.md b/published/202107/20210709 How to Install Zlib on Ubuntu Linux.md new file mode 100644 index 0000000000..504121d831 --- /dev/null +++ b/published/202107/20210709 How to Install Zlib on Ubuntu Linux.md @@ -0,0 +1,70 @@ +[#]: subject: "How to Install Zlib on Ubuntu Linux" +[#]: via: "https://itsfoss.com/install-zlib-ubuntu/" +[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" +[#]: collector: "lujun9972" +[#]: translator: "MjSeven" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13572-1.html" + +如何在 Ubuntu Linux 上安装 Zlib +====== + +![](https://img.linux.net.cn/data/attachment/album/202107/12/095552ndjee050i099j0j6.jpg) + +[Zlib][1] 是一个用于数据压缩的开源库。 + +作为使用者,你可能会遇到需要安装 zlib(或 zlib-devel 包)作为另一个应用程序的依赖项的情况。 + +但问题来了,如果你尝试在 Ubuntu 上安装 zlib,它会抛出 “unable to locate package zlib” 错误。 + +``` +sudo apt install zlib +Reading package lists... Done +Building dependency tree +Reading state information... Done +E: Unable to locate package zlib +``` + +为什么会看到这个 [Ubable to locate package 错误][2]呢?因为没有名为 zlib 的包。 + +如果你 [使用 apt search 命令][3],你会发现有几个包可以让你安装:zlib 1g 和 zlib 1g-dev。当你知道这些后,只需一个 `apt` 命令就可以安装它们。 + +### 在基于 Ubuntu 的 Linux 发行版上安装 Zlib + +打开终端,使用以下命令: + +``` +sudo apt install zlib1g +``` + +请记住 `g` 前面的字母是数字 `1`,而不是小写的字母 `L`。很多人在输入命令时都会犯这个错误。 + +另一个包,zlib 1g-dev 是开发包。只有在你需要时才安装它,否则你应该使用 zlib 1g 包。 + +``` +sudo apt install zlib1g-dev +``` + +你也可以 [Zlib 网站][1] 下载源代码并安装它。但是,除非你有充分的理由,否则我不推荐使用源代码方式来安装 zlib。例如,如果你需要最新或特定版本的 zlib,但该版本在发行版的仓库中不可用。 + +有趣的是,像安装 zlib 这样看似很小的东西可能会变得很麻烦,有两个原因:一个是不同的包名;另一个是包含“隐藏”数字 1,它与小写 L 混淆了。 + +我希望这个快速提示能帮助到你。随意在评论部分留下你的问题、建议或简单的一句 “thank you”。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-zlib-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://zlib.net/ +[2]: https://itsfoss.com/unable-to-locate-package-error-ubuntu/ +[3]: https://itsfoss.com/apt-search-command/ \ No newline at end of file diff --git a/published/202107/20210712 Box64 Emulator Released for Arm64 Linux.md b/published/202107/20210712 Box64 Emulator Released for Arm64 Linux.md new file mode 100644 index 0000000000..6e7ba13f93 --- /dev/null +++ b/published/202107/20210712 Box64 Emulator Released for Arm64 Linux.md @@ -0,0 +1,64 @@ +[#]: subject: (Box64 Emulator Released for Arm64 Linux) +[#]: via: (https://news.itsfoss.com/box64-emulator-released/) +[#]: author: (Jacob Crume https://news.itsfoss.com/author/jacob/) +[#]: collector: (lujun9972) +[#]: translator: (zd200572) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13591-1.html) + +Box64 模拟器发布 Arm64 Linux 版本 +====== + +> 在 Box64 模拟器的帮助下,在 ARM 设备上运行 x64 Linux 程序。想试试吗? + +![](https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/box64-arm.jpg?w=1200&ssl=1) + +[Box86][1] 是一个流行的 X86 模拟器,刚进行了一次巨大的升级。发布了 [Box64][2],也就是对应的 ARM64 版本。 + +可能你还不了解这个模拟器,Box64_86 允许你在 ARM 系统上运行 32 或 64 位的 X86/64 Linux 程序。换句话说,它能让你在树莓派或者 [树莓派替代品][3] 上运行 Linux 桌面程序。 + +幸运的是,现在我们有 Box86 和 Box64 的支持,无论你的 ARM 系统是什么类型。 + +### Box64 是什么? + +![][4] + +你可能听说过苹果的 Rosetta 2,它是一个翻译层,允许为老款 Mac(Intel X86 处理器)设计的应用程序在新的 M1(ARM 处理器)驱动的 Mac 上运行。Box64 与之类似,允许为 X86 设计的应用程序运行在 ARM Linux 设备上。 + +由于它的 Dynarec 模块,它能够做到这一点,同时又是 100% 开源的、免费的,而且速度惊人。它通过重新编译 ARM 程序来提升速度,这意味着和其他 ARM 原生应用一样快。 + +但是,即使 Box64 无法重新编译应用,它仍然可以使用即时模拟,也有令人印象深刻的结果。 + +许多树莓派用户很熟悉 Box86,这是一个大约一年前发布的类似程序。二者最大的区别是 Box86 只兼容 Arm32,而 Box64 只兼容 Arm64。 + +这就是 Box64,一个非常棒的兼容层,允许你在 ARM 电脑上运行 x86_64 应用。 + +### 总结 + +如果你问我认为 Box64 怎么样,我会说这是一个绝对的游戏规则改变者。在难以置信的性能和巨大的潜力之间,这个兼容层肯定会在未来的 ARM 电脑中扮演一个重要角色。 + +如果你想知道它的工作原理,以及如何开始使用它,请查看其 [GitHub 页面][5]。 + +就这样吧,现在你自己去潜入其中并测试吧。 + +你觉得 Box64 怎样?写下你的评论让我知道。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/box64-emulator-released/ + +作者:[Jacob Crume][a] +选题:[lujun9972][b] +译者:[zde200572](https://github.com/zd200572) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/jacob/ +[b]: https://github.com/lujun9972 +[1]: http://github.com/ptitseb/box86 +[2]: http://github.com/ptitseb/box64 +[3]: https://itsfoss.com/raspberry-pi-alternatives/ +[4]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/Box64Logo-1024x287-1.png?w=1024&ssl=1 +[5]: https://github.com/ptitseb/box64 diff --git a/published/202107/20210712 Converseen for Batch Processing Images on Linux.md b/published/202107/20210712 Converseen for Batch Processing Images on Linux.md new file mode 100644 index 0000000000..e06a5318db --- /dev/null +++ b/published/202107/20210712 Converseen for Batch Processing Images on Linux.md @@ -0,0 +1,101 @@ +[#]: subject: (Converseen for Batch Processing Images on Linux) +[#]: via: (https://itsfoss.com/converseen/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13617-1.html) + +在 Linux 上批量处理图像的 Converseen +====== + +![](https://img.linux.net.cn/data/attachment/album/202107/25/215958jd5jl9q2jlzqvvg6.jpg) + +Converseen 是一个用于批量图像转换的自由开源软件。有了这个工具,你可以一次将多张图片转换成另一种格式、调整大小、改变它们的长宽比、旋转或翻转它们。 + +对于像我这样的人来说,这是一个很方便的工具,我必须处理多个不同大小的截图,但在上传到网站之前必须调整它们的大小。 + +批量转换工具在这种情况下有很大的帮助。这可以在 Linux 命令行中用不错的 [ImageMagick][1] 来完成,但在这里使用 GUI 工具要容易得多。实际上,Converseen 在基于 Qt 的图形用户界面下使用 ImageMagick。 + +### 用 Converseen 批量处理图像 + +你可以用 [Converseen][2] 通过鼠标点击来转换、调整大小、旋转和翻转多个图像。 + +你有很多支持批量转换的选项。你可以在你的选择中添加更多的图片,或者删除其中的一些。你可以选择只转换你选择的几张图片。 + +在调整图像大小时,你可以选择保持长宽比。请记住,在宽度和高度中,你最后改变/输入的那个是控制长宽比的那个。所以,如果你想在保持长宽比的情况下调整大小,但要根据宽度来调整,不要修改高度栏。 + +![][3] + +你也可以选择将转换后的图像以不同的名称保存在同一目录或其他位置,也可以覆盖现有的图像。 + +你不能添加文件夹,但你可以一次选择并添加多个图像。 + +你可以将图像转换为多种格式,如 JPEG、JPG、TIFF、SVG 等。 + +在改变格式的同时,还有一个选项可以给透明背景以某种颜色。你还可以设置压缩级别的质量。 + +![][4] + +Converseen 还可以导入 PDF 文件,并将整个 PDF 或其中的一部分转换为图像。然而,在 Ubuntu 21.04 中,每次我试图转换一个 PDF 文件时,它就会崩溃。 + +### 在 Linux 上安装 Converseen + +Converseen 是一个流行的应用。它在大多数 Linux 发行版仓库中都有。 + +你可以在你的发行版的软件中心搜索到它: + +![][5] + +当然,你也可以使用你的发行版的包管理器通过命令行来安装它。 + +在基于 Debian 和 Ubuntu 的发行版上,使用: + +``` +sudo apt install converseen +``` + +在 Fedora 上,使用: + +``` +sudo dnf install converseen +``` + +在 Arch 和 Manjaro 上,使用: + +``` +sudo pacman -Sy converseen +``` + +Converseen 也可在 Windows 和 FreeBSD 下使用。你可以在项目网站的下载页面获得相关说明。 + +- [下载 Converseen][6] + +它的源码可在 GitHub 仓库 [获取][7]。 + +如果你正在寻找一个更简单的方法来调整一张图片的大小,你可以使用这个巧妙的技巧,[在 Nautilus 文件管理器中用右键菜单调整图片大小和旋转图片][8]。 + +总的来说,Converseen 是一个有用的用于批量图像转换的 GUI 工具。它并不完美,但在大多数情况下是有用的。你曾经使用过 Converseen 或者你使用类似的工具吗?你对它的体验如何? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/converseen/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://imagemagick.org/index.php +[2]: https://converseen.fasterland.net/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/converseen-interface.png?resize=800%2C400&ssl=1 +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/converseen-features-overview_copy.png?resize=800%2C497&ssl=1 +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/install-converseen-linux.jpeg?resize=800%2C527&ssl=1 +[6]: https://converseen.fasterland.net/download/ +[7]: https://github.com/Faster3ck/Converseen +[8]: https://itsfoss.com/resize-images-with-right-click/ diff --git a/published/202107/20210712 What is XML.md b/published/202107/20210712 What is XML.md new file mode 100644 index 0000000000..1841c743ea --- /dev/null +++ b/published/202107/20210712 What is XML.md @@ -0,0 +1,132 @@ +[#]: subject: "What is XML?" +[#]: via: "https://opensource.com/article/21/7/what-xml" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lujun9972" +[#]: translator: "amwps290" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13624-1.html" + +什么是 XML? +====== + +> 了解一下 XML 吧,它是一种严格但灵活的标记语言,无论是在文档还是图像方面应用都十分广泛。 + +![](https://img.linux.net.cn/data/attachment/album/202107/28/082605rhju4ckqez0zvcwc.jpg) + +XML 是一种分层的标记语言。它使用打开和关闭标签来定义数据,它常用来存储和交换数据,而且由于它极大的灵活性,不论是在 [文档][2] 还是 [图像][3] 中都用的非常多。 + +这里是一个 XML 文档的例子: + +``` + +    +    +      Fedora +      8 +      Werewolf +    + +    +      Slackware +      12.1 +      +        Tux +        Bob Dobbs +      +    +        + +``` + +阅读这个示例 XML,你可能会发现这个 XML 的格式具有直观的特性。 无论你是否熟悉这个文档的主题,你都可能理解本文档中的数据。 这部分原因是因为 XML 被认为是冗长的。 它使用了很多标签,标签可以有很长的描述性名称,并且数据以分层的方式排序,这有助于解释数据之间的关系。 你可能从这个示例中了解到 Fedora 发行版和 Slackware 发行版是两个不同且不相关的 Linux 发行版,因为每个实例都“包含”在自己独立的 `` 标签中。 + +XML 也非常灵活。 与 HTML 不同,它没有预定义的标签列表。 你可以自由创建你需要表示任何数据结构的标签。 + +### XML 的组成 + +数据的存在为了读取,当计算机“读取”数据时,该过程称为 _解析_。 再次使用示例 XML 数据,以下是大多数 XML 解析器认为重要的术语。 + + * **文档**:`` 标签标记文档的开始, `` 标签标记文档的结束。 + * **节点**:``、``、`` 这些都是节点,在解析术语中,节点是包含其他标签的标签。 + * **元素**:像 `Fedora` 和 `Tux` 这些都是元素。从第一个`<`开始,到最后一个 `>` 结束是一个元素。 + * **内容**:在两个元素标签之间的数据被称之为内容,在第一个 `` 标签中,`Fedora` 字符串就是一个内容。 + +### XML 模式 + +XML 文档中的标签和标签继承性称为 _模式_。 + +一些模式是随意组成的(例如,本文中的示例 XML 代码纯粹是即兴创作的),而其他模式则由标准组织严格定义。 例如,可缩放矢量图形(SVG)模式 [由 W3C 定义][4],而 [DocBook 模式][5] 由 Norman Walsh 定义。 + +模式强制执行一致性。 最基本的模式通常也是最严格的。 在我的示例 XML 代码中,将发行版名称放在 `` 节点中是没有意义的,因为文档的隐含模式清楚地表明 `mascot` 必须是发行版的“子”元素。 + +### 数据对象模型(DOM) + +如果你必须不断地描述标签和位置(例如,“系统部分中的 Linux 部分中第二个发行版标签的名称标签”),那么谈论 XML 会让人感到困惑,因此解析器使用文档对象模型(DOM)的概念来表示 XML 数据。 DOM 将 XML 数据放入一种“家谱”结构中,从根元素(在我的示例 XML 中,即 `os` 标记)开始并包括路径上的每个标记。 + +![Document Object Model][6] + +这种相同的 XML 数据结构可以表示为路径,就像 Linux 系统中的文件或互联网上网页的位置一样。 例如,`` 标签的路径可以表示为 `//os/linux/distribution/slackware/mascot`。 + +两个 `` 标签可以被表示为 `//os/linux/distribution` ,因为这里有两个发行版的节点,因此一个解析器可以直接将两个节点的内容载入到一个数组中,可以进行查询。 + +### 严格的 XML + +XML 也以严格而著称。 这意味着大多数应用程序被设计为在遇到 XML 错误时就会故意失败。 这听起来可能有问题,但这是开发人员最欣赏 XML 的事情之一,因为当应用程序试图猜测如何解决错误时,可能会发生不可预测的事情。 例如,在 HTML 定义明确之前,大多数 Web 浏览器都包含“怪癖模式”,因此当人们试图查看糟糕的 HTML 代码时,Web 浏览器却可以加载作者可能想要的内容。 结果非常难以预测,尤其是当一个浏览器的猜测与另一个浏览器不同时。 + +XML 通过在出现故意错误时失败而不允许这样做。 这让作者可以修复错误,直到它们生成有效的 XML。 因为 XML 是良好定义的,所以有许多应用程序的验证器插件以及像 `xmllint` 和 `xmlstarlet` 这样的独立命令来帮助你及早定位错误。 + +### 转换 XML + +因为 XML 通常用作数据交换,所以将 XML 转换为其他数据格式或其他 XML 模式是很常见的。 经典示例包括 XSLTProc、xmlto 和 [pandoc][8],但从技术上讲,还有许多其他应用程序或者至少程序的一部分就是在转换 XML。 + +事实上,LibreOffice 使用 XML 来布局其文字处理器和电子表格文档,因此无论何时你导出或 [从 LibreOffice 转换文件][9],你都在转换 XML。 + +[开源 EPUB 格式的电子书][10] 使用 XML,因此无论何时你 [将文档转换为 EPUB][11] 或从 EPUB 转换,你都在转换 XML。 + +Inkscape 是基于矢量的插图应用程序,它将其文件保存在 SVG 中,这是一种专为图形设计的 XML 模式。 任何时候你将 Inkscape 中的图像导出为 PNG 文件时,你都在转换 XML。 + +名单还可以一直继续下去。 XML 是一种数据存储格式,旨在确保你的数据,无论是画布上的点和线、图表上的节点,还是文档中的文字,都可以轻松准确地提取、更新和转换。 + +### 学习 XML + +编写 XML 很像编写 HTML。 感谢 Jay Nick 的辛勤工作,[在线提供免费且有趣的 XML 课程][3] 可以教你如何使用 XML 创建图形。 + +通常,探索 XML 所需的特殊工具很少。 由于 HTML 和 XML 之间的密切关系,你可以 [使用 Web 浏览器查看 XML][12]。 此外,[QXmlEdit][13]、[NetBeans][14] 和 [Kate][15] 等开源文本编辑器通过有用的提示、自动完成、语法验证等,使键入和阅读 XML 变得容易。 + +### 选择 XML + +XML 起初可能看起来有很多数据,但它与 HTML 并没有太大的不同(实际上,HTML 已经 [以 XHTML 的形式重新实现为 XML][16])。 XML 有一个独特的好处,即构成其结构的标签也恰好是元数据,提供有关其存储内容的信息。 精心设计的 XML 模式包含并描述你的数据,使用户能够一目了然并快速解析它,并使开发人员能够使用一些库 [快速解析][17]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/what-xml + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[amwps290](https://github.com/amwps290) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_screen_windows_files.png?itok=kLTeQUbY "Computer screen with files or windows open" +[2]: https://opensource.com/article/17/9/docbook +[3]: https://opensource.com/article/17/5/coding-scalable-vector-graphics-make-steam +[4]: https://www.w3.org/TR/SVG11/ +[5]: http://docbook.org +[6]: https://opensource.com/sites/default/files/uploads/dom.jpg "Document Object Model" +[7]: https://creativecommons.org/licenses/by-sa/4.0/ +[8]: https://opensource.com/article/20/5/pandoc-cheat-sheet +[9]: https://opensource.com/article/21/3/libreoffice-command-line +[10]: https://opensource.com/education/15/11/ebook-open-formats +[11]: https://opensource.com/life/13/8/how-create-ebook-open-source-way +[12]: https://opensource.com/article/18/12/xml-browser +[13]: https://opensource.com/article/17/7/7-ways-handle-xml-qxmledit +[14]: https://opensource.com/article/20/12/netbeans +[15]: https://opensource.com/article/20/12/kate-text-editor +[16]: https://www.w3.org/TR/xhtml1/ +[17]: https://opensource.com/article/21/6/parsing-config-files-java diff --git a/published/202107/20210713 Use XMLStarlet to parse XML in your the Linux terminal.md b/published/202107/20210713 Use XMLStarlet to parse XML in your the Linux terminal.md new file mode 100644 index 0000000000..57c03d985a --- /dev/null +++ b/published/202107/20210713 Use XMLStarlet to parse XML in your the Linux terminal.md @@ -0,0 +1,232 @@ +[#]: subject: "Use XMLStarlet to parse XML in your the Linux terminal" +[#]: via: "https://opensource.com/article/21/7/parse-xml-linux" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lujun9972" +[#]: translator: "zepoch" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13627-1.html" + +在命令行中使用 XMLStarlet 来解析 XML +====== + +> 借助终端上的 XML 工具包 XMLStarlet,你就是 XML 之星。 + +![](https://img.linux.net.cn/data/attachment/album/202107/29/091327pgssat1oglrzs73z.jpg) + +学习解析 XML 通常被认为是一件复杂的事情,但它不一定是这样。[XML 是高度严格结构化的][2],所以也是相对来说可预测的。也有许多其他工具可以帮助你使这项工作易于管理。 + +我最喜欢的 XML 实用程序之一是 [XMLStarlet][3],这是一个用于终端的 XML 工具包,借助这个 XML 工具包,你可以验证、解析、编辑、格式化和转换 XML 数据。XMLStarLet 是个相对较小的命令,但浏览 XML 却充满潜力,因此本文演示了如何使用它来查询 XML 数据。 + +### 安装 + +XMLStarLet 默认安装在 CentOS、Fedora,和许多其他现代 Linux 发行版上,所以你可以打开终端,输入 `xmlstarlet` 来访问它。如果 XMLStarLet 还没有被安装,你的操作系统则会为你安装它。 + +或者,你可以用包管理器安装 `xmlstarlet`: + +``` +$ sudo dnf install xmlstarlet +``` + +在 macOS 上,可以使用 [MacPorts][4] 或 [Homebrew][5]。在 Windows 上,可以使用 [Chocolatey][6]。 + +如果都失败了,你可以从 [Sourceforge 上的源代码][7] 手动安装它。 + +### 用 XMLStarlet 解析 XML + +有许多工具可以帮助解析和转换 XML 数据,包括允许你 [编写自己的解析器][8] 的软件库,和复杂的命令,如 `fop` 和 `xsltproc`。不过有时你不需要处理 XML 数据;你只需要一个方便的方法从 XML 数据中来提取、更新或验证重要数据。对于随手的 XML 交互,我使用 `xmlstarlet`,这是常见的处理 XML任务的一个典型的“瑞士军刀”式应用。通过运行 `--help` 命令,你可以看到它提供哪些选项: + +``` +$ xmlstarlet --help +Usage: xmlstarlet [] [] +where is one of: + ed (or edit) - Edit/Update XML document(s) + sel (or select) - Select data or query XML document(s) (XPATH, etc) + tr (or transform) - Transform XML document(s) using XSLT + val (or validate) - Validate XML document(s) (well-formed/DTD/XSD/RelaxNG) + fo (or format) - Format XML document(s) + el (or elements) - Display element structure of XML document + c14n (or canonic) - XML canonicalization + ls (or list) - List directory as XML +[...] +``` + +你可以通过在这些子命令的末尾附加 `-help` 来获得进一步的帮助: + + +``` +$ xmlstarlet sel --help + -Q or --quiet - do not write anything to standard output. + -C or --comp - display generated XSLT + -R or --root - print root element <xsl-select> + -T or --text - output is text (default is XML) + -I or --indent - indent output +[...] +``` + +#### 用 sel 命令选择数据 + +可以使用 `xmlstarlet select`(简称 `sel`)命令查看 XML 格式的数据。下面是一个简单的 XML 文档: + +``` + + + + + + Fedora + 7 + Moonshine + + Live + Fedora + Everything + + + + + Fedora Core + 6 + Zod + + + + + +``` + +在 XML 文件中查找数据时,你的第一个任务是关注要探索的节点。如果知道节点的路径,请使用 `-value of` 选项指定完整路径。你越早浏览 [文档对象模型][9](DOM)树,就可以看到更多信息: + +``` +$ xmlstarlet select --template \ + --value-of /xml/os/linux/distribution \ + --nl myfile.xml + Fedora + 7 + Moonshine + + Live + Fedora + Everything + + Fedora Core + 6 + Zod +``` + +`--nl` 代表“新的一行”,它插入大量的空白,以确保在输入结果后,终端在新的一行显示。我已经删除了样本输出中的一些多余空间。 + +通过进一步深入 DOM 树来凝聚关注点: + +``` +$ xmlstarlet select --template \ + --value-of /xml/os/linux/distribution/name \ + --nl myfile.xml +Fedora +Fedora Core +``` + +#### 条件选择 + +用于导航和解析 XML 的最强大工具之一被称为 XPath。它规范了 XML 搜索中使用的语法,并从 XML 库调用函数。XMLStarlet 能够解析 XPath 表达式,因此可以使用 XPath 函数来有条件的进行选择。XPath 具有丰富的函数,[由 W3C 提供了详细文档][10],但我觉得 [Mozilla 的 XPath 文档][11] 更简洁。 + +可以使用方括号作为测试函数,将元素的内容与某个值进行比较。下面是对 `` 元素的值的测试,它仅返回与特定匹配相关联的版本号。 + +想象一下,示例 XML 文件包含以 1 开头的所有 Fedora 版本。要查看与旧名称 “Fedora Core” 关联的所有版本号(该项目从版本 7 开始删除了名称中的 “Core”),请执行以下操作: + +``` +$ xmlstarlet sel --template \ + --value-of '/xml/os/linux/distribution[name = "Fedora Core"]/release' \ + --nl myfile.xml +6 +5 +4 +3 +2 +1 +``` + +通过将路径的 `--value-of` 更改为 `/xml/os/linux/distribution[name=“Fedora Core”]/codename`,你便可以查看这些版本的所有代号。 + +### 匹配路径和获取目标值 + +将 XML 标记视为节点的一个好处是,一旦找到节点,就可以将其视为当前的数据的“目录”。它不是一个真正的目录,至少不是文件系统意义上的目录,但它是一个可以查询的数据集合。为了帮助你将目标和“里面”的数据分开,XMLStarlet 把你试图用 `--match` 选项匹配的内容和用 `--value-of` 选项匹配的数据值进行了区分。 + +假设你知道 `` 节点包含几个元素。这就是你的目标节点。一旦到了这里,就可以使用 `--value-of` 指定想要哪个元素的值。要查看所有元素,可以使用点(`.`)来代表当前位置: + +``` +$ xmlstarlet sel --template \ + --match '/xml/os/linux/distribution/spin' \ + --value-of '.' --nl myfile.xml \ +Live +Fedora +Everything +``` + +与浏览 DOM 一样,可以使用 XPath 表达式来限制返回数据的范围。在本例中,我使用 `last()` 函数来检索 `spin` 节点中的最后一个元素: + +``` +$ xmlstarlet select --template \ + --match '/xml/os/linux/distribution/spin' \ + --value-of '*[last()]' --nl myfile.xml +Everything +``` + +在本例中,我使用 `position()` 函数选择 `spin` 节点中的特定元素: + +``` +$ xmlstarlet select --template \ + --match '/xml/os/linux/distribution/spin' \ + --value-of '*[position() = 2]' --nl myfile.xml +Fedora +``` + +`--match` 和 `--value` 选项可以重叠,因此如何将它们一起使用取决于你自己。对于示例 XML,这两个表达式执行的是相同的操作: + +``` +$ xmlstarlet select --template \ + --match '/xml/os/linux/distribution/spin' \ + --value-of '.' \ + --nl myfile.xml +Live +Fedora +Everything + +$ xmlstarlet select --template \ + --match '/xml/os/linux/distribution' \ + --value-of 'spin' \ + --nl myfile.xml +Live +Fedora +Everything +``` + +### 熟悉 XML + +XML 有时看起来过于冗长和笨拙,但为与之交互和构建的工具却总是让我吃惊。如果你想要好好使用 XML,那么 XMLStarlet 可能是一个很好的切入点。下次要打开 XML 文件查看其结构化数据时,请尝试使用 XMLStarlet,看看是否可以查询这些数据。当你对 XML 越熟悉时,它就越能作为一种健壮灵活的数据格式而为你服务。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/parse-xml-linux + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[zepoch](https://github.com/zepoch) +校对:[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/linux_penguin_green.png?itok=ENdVzW22 "Penguin with green background" +[2]: https://opensource.com/article/21/6/what-xml +[3]: https://en.wikipedia.org/wiki/XMLStarlet +[4]: https://opensource.com/article/20/11/macports +[5]: https://opensource.com/article/20/6/homebrew-mac +[6]: https://opensource.com/article/20/3/chocolatey +[7]: http://xmlstar.sourceforge.net +[8]: https://opensource.com/article/21/6/parsing-config-files-java +[9]: https://opensource.com/article/21/6/what-xml#dom +[10]: https://www.w3.org/TR/1999/REC-xpath-19991116 +[11]: https://developer.mozilla.org/en-US/docs/Web/XPath/Functions + diff --git a/published/202107/20210714 Getting Started with Podman on Fedora.md b/published/202107/20210714 Getting Started with Podman on Fedora.md new file mode 100644 index 0000000000..cef3a1fcb2 --- /dev/null +++ b/published/202107/20210714 Getting Started with Podman on Fedora.md @@ -0,0 +1,158 @@ +[#]: subject: (Getting Started with Podman on Fedora) +[#]: via: (https://fedoramagazine.org/getting-started-with-podman-in-fedora/) +[#]: author: (Yazan Monshed https://fedoramagazine.org/author/yazanalmonshed/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13615-1.html) + +如何在 Fedora 上使用 Podman +====== + +![][1] + +[Podman][2] 是一个无守护程序的容器引擎,用于在你的 Linux 系统上开发、管理和运行 OCI 容器。在这篇文章中,我们将介绍 Podman 以及如何用 nodejs 构建一个小型应用来使用它。该应用将是非常简单和干净的。 + +### 安装 Podman + +Podman 的命令就与 [docker][3] 相同,如果你已经安装了 Docker,只需在终端输入 `alias docker=podman`。 + +在 Fedora 中,Podman 是默认安装的。但是如果你因为任何原因没有安装,你可以用下面的命令安装它: + +``` +sudo dnf install podman +``` + +对于 Fedora [silverblue][4] 用户,Podman 已经安装在你的操作系统中了。 + +安装后,运行 “hello world” 镜像,以确保一切正常: + +``` +podman pull hello-world +podman run hello-world +``` + +如果一切运行良好,你将在终端看到以下输出: + +``` +Hello from Docker! +This message shows that your installation appears to be working correctly. + To generate this message, Docker took the following steps: + 1.The Docker client contacted the Docker daemon. + 2.The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) + 3.The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. + 4.The Docker daemon streamed that output to the Docker client, which sent it to your terminal. + To try something more ambitious, you can run an Ubuntu container with: + $ docker run -it ubuntu bash + Share images, automate workflows, and more with a free Docker ID: + https://hub.docker.com/ + For more examples and ideas, visit: + https://docs.docker.com/get-started/ +``` + +### 简单的 Nodejs 应用 + +首先,我们将创建一个文件夹 `webapp`,在终端输入以下命令: + +``` +mkdir webapp && cd webapp +``` + +现在创建文件 `package.json`,该文件包括项目运行所需的所有依赖项。在文件 `package.json` 中复制以下代码: + +``` +{ + "dependencies": { + "express": "*" + }, + "scripts": { + "start": "node index.js" + } +} +``` + +创建文件 `index.js`,并在其中添加以下代码: + +``` +const express = require('express') + +const app = express(); + +app.get('/', (req, res)=> { + res.send("Hello World!") +}); +app.listen(8081, () => { + console.log("Listing on port 8080"); +}); +``` + +你可以从 [这里][5] 下载源代码。 + +### 创建 Dockerfile + +首先,创建一个名为 `Dockerfile` 的文件,并确保第一个字符是大写,而不是小写,然后在那里添加以下代码: + +``` +FROM node:alpine +WORKDIR usr/app +COPY ./ ./ +RUN npm install +CMD ["npm", "start"] +``` + +确保你在 `webapp` 文件夹内,然后显示镜像,然后输入以下命令: + +``` +podman build . +``` + +确保加了 `.`。镜像将在你的机器上创建,你可以用以下命令显示它: + +``` +podman images +``` + +最后一步是输入以下命令在容器中运行该镜像: + +``` +podman run -p 8080:8080 +``` + +现在在你的浏览器中打开 `localhost:8080`,你会看到你的应用已经工作。 + +### 停止和删除容器 + +使用 `CTRL-C` 退出容器,你可以使用容器 ID 来删除容器。获取 ID 并使用这些命令停止容器: + +``` +podman ps -a +podman stop +``` + +你可以使用以下命令从你的机器上删除镜像: + +``` +podman rmi +``` + +在 [官方网站][2] 上阅读更多关于 Podman 和它如何工作的信息。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/getting-started-with-podman-in-fedora/ + +作者:[Yazan Monshed][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/yazanalmonshed/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/06/Get_Started_w_Podman_on_Fedora-816x345.jpg +[2]: https://podman.io/ +[3]: https://www.docker.com/ +[4]: https://silverblue.fedoraproject.org/ +[5]: https://github.com/YazanALMonshed/webapp diff --git a/published/202107/20210714 How different programming languages read and write data.md b/published/202107/20210714 How different programming languages read and write data.md new file mode 100644 index 0000000000..544a76741a --- /dev/null +++ b/published/202107/20210714 How different programming languages read and write data.md @@ -0,0 +1,269 @@ +[#]: subject: "How different programming languages read and write data" +[#]: via: "https://opensource.com/article/21/7/programming-read-write" +[#]: author: "Alan Smithee https://opensource.com/users/alansmithee" +[#]: collector: "lujun9972" +[#]: translator: "MjSeven" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13599-1.html" + +不同的编程语言是如何读写数据的 +====== + +> 每种编程语言都有其独特的完成任务的方式,这也说明了为什么有这么多语言可供选择。 + +![](https://img.linux.net.cn/data/attachment/album/202107/20/065355dfr3f1zmf7fpzmw7.jpg) + +在 Jim Hall 的《[不同的编程语言如何完成相同的事情][2]》文章中,他演示了 13 种不同的语言如何使用不同的语法来完成同一个任务。经验是,编程语言往往有很多相似之处。一旦你了解了一种编程语言,你就可以通过理解它的语法和结构来学习另一种。 + +本着同样的精神,Jim 的文章比较了不同编程语言如何读写数据。无论数据来自配置文件还是用户创建的文件,在存储设备上处理数据都是程序员的常见任务。以这种方式涵盖所有编程语言是不切实际的,但最近的 Opensource.com 系列文章提供了对这些编程语言采用的不同方法的深入了解: + + * [C][3] + * [C++][4] + * [Java][5] + * [Groovy][6] + * [Lua][7] + * [Bash][8] + * [Python][9] + +### 读写数据 + +用计算机读写数据的过程和你在现实生活中读写数据的过程类似。要访问书中的数据,你首先要打开它,然后阅读单词或将生词写入书中,然后合上书。 + +当程序需要从文件中读取数据时,你向程序传入一个文件位置,然后计算机将该数据读入内存中并解析它。同样,当程序需要将数据写入文件时,计算机会将新数据放入系统的内存写入缓冲区,然后将其同步到存储设备上的文件中。 + +下面是这些操作的一些伪代码: + + 1. 在内存中加载文件。 + 2. 读取文件内容,或将数据写入文件。 + 3. 关闭文件。 + +### 从文件中读取数据 + +从 Opensource.com 系列文章的语言中,你可以看到读取文件的三种趋势。 + +#### C + +在 C 语言中,打开文件可能涉及检索单个字符(直到 `EOF` 指示符,表示文件结束)或一个数据块,具体取决于你的需求和方法。根据你的目标,它可能感觉像一个主要是手工的过程,但这正是其他语言所模仿的。 + +``` +FILE *infile; +int ch; + +infile = fopen(argv[1], "r"); + +do { + ch = fgetc(infile); + if (ch != EOF) { + printf("%c", ch); + } + } while (ch != EOF); + +fclose(infile); +``` + +你还可以选择将文件的某些部分加载到系统缓冲区中,然后在缓冲区外工作。 + + +``` +FILE *infile; +char buffer[300]; + +infile = fopen(argv[1], "r"); + +while (!feof(infile)) { + size_t buffer_length; + buffer_length = fread(buffer, sizeof(char), 300, infile); +} + +printf("%s", buffer); +fclose(infile); +``` + +#### C++ + +C++ 简化了一些步骤,允许你将数据解析为字符串。 + +``` +std::string sFilename = "example.txt"; + +std::ifstream fileSource(sFilename); +std::string buffer; + +while (fileSource >> buffer) { + std::cout << buffer << std::endl; +} +``` + +#### Java + +Java 和 Groovy 类似于 C++。它们使用名为 `Scanner` 的类来设置数据流或对象,这样就会包含你选择的文件内容。你可以通过标记(字节、行、整数等)扫描文件。 + +``` +File myFile = new File("example.txt"); + +Scanner myScanner = new Scanner(myFile); + while (myScanner.hasNextLine()) { + String line = myScanner.nextLine(); + System.out.println(line); + } + +myScanner.close(); +``` + +#### Groovy + + +``` +def myFile = new File('example.txt') + +def myScanner = new Scanner(myFile) + while (myScanner.hasNextLine()) { + def line = myScanner.nextLine() + println(line) + } + +myScanner.close() +``` + +#### Lua + +Lua 和 Python 进一步抽象了整个过程。你不必有意识地创建数据流,你只需给一个变量赋值为 `open` 函数的返回值,然后解析该变量的内容。这种方式快速,最简且容易。 + +``` +myFile = io.open('example.txt', 'r') + +lines = myFile:read("*all") +print(lines) + +myFile:close() +``` + +#### Python + + +``` +f = open('example.tmp', 'r') + +for line in f: + print(line) + +f.close() +``` + +### 向文件中写入数据 + +就写代码来说,写入是读取的逆过程。因此,将数据写入文件的过程与从文件中读取数据基本相同,只是使用了不同的函数。 + +#### C + +在 C 语言中,你可以使用 `fputc` 函数将字符写入文件: + +``` +fputc(ch, outfile); +``` + +或者,你可以使用 `fwrite` 将数据写入缓冲区。 + +```c +fwrite(buffer, sizeof(char), buffer_length, outfile); +``` + +#### C++ + +因为 C++ 使用 `ifstream` 库为数据打开缓冲区,所以你可以像 C 语言那样将数据写入缓冲区(C++ 库除外)。 + +``` +std::cout << buffer << std::endl; +``` + +#### Java + +在 Java 中,你可以使用 `FileWriter` 类来创建一个可以写入数据的对象。它的工作方式与 `Scanner` 类非常相似,只是方向相反。 + +``` +FileWriter myFileWriter = new FileWriter("example.txt", true); +myFileWriter.write("Hello world\n"); +myFileWriter.close(); +``` + +#### Groovy + +类似地,Groovy 使用 `FileWriter`,但使用了稍微 “groovy” 的语法。 + +``` +new FileWriter("example.txt", true).with { + write("Hello world\n") + flush() +} +``` + +#### Lua + +Lua 和 Python 很相似,都使用名为 `open` 的函数来加载文件,`writer` 函数来写入数据,`close` 函数用于关闭文件。 + + +``` +myFile = io.open('example.txt', 'a') +io.output(myFile) +io.write("hello world\n") +io.close(myFile) +``` + +#### Python + +``` +myFile = open('example.txt', 'w') +myFile.write('hello world') +myFile.close() +``` + +### File 模式 + +许多语言在打开文件时会指定一个“模式”。模式有很多,但这是常见的定义: + + * **w** 表示写入 + * **r** 表示读取 + * **r+** 表示可读可写 + * **a** 表示追加 + +某些语言,例如 Java 和 Groovy,允许你根据用于加载文件的类来确定模式。 + +无论编程语言以何种方式来确定文件模式,你都需要确保你是在 _追加_ 数据,除非你打算用新数据覆盖文件。编程语言不像文件选择器那样,没有内置的提示来警告你防止数据丢失。 + +### 新语言和旧把戏 + +每种编程语言都有其独特完成任务的方式,这就是为什么有这么多语言可供选择。你可以而且应该选择最合适你的语言。但是,你一旦了解了编程的基本结构,你可以随意尝试其他语言,而不必担心不知道如何完成基本任务。通常情况下,实现目标的途径是相似的,所以只要你牢记基本概念,它们就很容易学习。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/programming-read-write + +作者:[Alan Smithee][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alansmithee +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_development_programming.png?itok=4OM29-82 "Code going into a computer." +[2]: https://opensource.com/article/21/4/compare-programming-languages +[3]: https://opensource.com/article/21/3/file-io-c +[4]: https://opensource.com/article/21/3/ccc-input-output +[5]: https://opensource.com/article/21/3/io-java +[6]: https://opensource.com/article/21/4/groovy-io +[7]: https://opensource.com/article/21/3/lua-files +[8]: https://opensource.com/article/21/3/input-output-bash +[9]: https://opensource.com/article/21/6/reading-and-writing-files-python +[10]: http://www.opengroup.org/onlinepubs/009695399/functions/fopen.html +[11]: http://www.opengroup.org/onlinepubs/009695399/functions/fgetc.html +[12]: http://www.opengroup.org/onlinepubs/009695399/functions/printf.html +[13]: http://www.opengroup.org/onlinepubs/009695399/functions/fclose.html +[14]: http://www.opengroup.org/onlinepubs/009695399/functions/feof.html +[15]: http://www.opengroup.org/onlinepubs/009695399/functions/fread.html +[16]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+file +[17]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string +[18]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system +[19]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+filewriter \ No newline at end of file diff --git a/published/202107/20210716 Apps for daily needs part 1- web browsers.md b/published/202107/20210716 Apps for daily needs part 1- web browsers.md new file mode 100644 index 0000000000..6e1f9c7adf --- /dev/null +++ b/published/202107/20210716 Apps for daily needs part 1- web browsers.md @@ -0,0 +1,102 @@ +[#]: subject: (Apps for daily needs part 1: web browsers) +[#]: via: (https://fedoramagazine.org/apps-for-daily-needs-part-1-web-browsers/) +[#]: author: (Arman Arisman https://fedoramagazine.org/author/armanwu/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13625-1.html) + +满足日常需求的应用(一):Web 浏览器 +====== + +![][1] + +满足日常需求的重要应用之一是 Web 浏览器。这是因为上网是大多数人在电脑前进行的一项活动。本文将介绍一些你可以在 Fedora Linux 上使用的开源 Web 浏览器。你需要安装上述软件。本文提到的所有浏览器都已经在官方的 Fedora 软件库中提供。如果你不熟悉如何在 Fedora Linux 中添加软件包,请参阅我之前的文章 [安装 Fedora 34 工作站后要做的事情][4]。 + +### Firefox + +火狐Firefox是一个快速且注重隐私的浏览器,可以在许多设备上使用。它是由 [Mozilla][5] 创建的,是一个具有完整功能的浏览器,提供许多扩展。你可以为你的火狐浏览器添加许多强大的功能和有用的特性。它只使用适量的内存来创造一个流畅的体验,使你的电脑保持对其他任务的响应。你可以创建一个账户,让你在多个设备上共享配置,所以你不需要在每个设备上设置火狐浏览器。 + +![][6] + +火狐浏览器提供以下功能: + + * 隐私浏览模式 + * 阻止广告跟踪器 + * 密码管理器 + * 设备之间的同步 + * 画中画 + +关于火狐浏览器的更多信息可在此链接中找到:[https://www.mozilla.org/en-US/firefox][7] + +### GNOME Web + +GNOME Web 是 GNOME 桌面(Fedora 工作站的默认桌面环境)的一个浏览器。如果你使用 GNOME 作为默认桌面环境的 Fedora 工作站,它可能非常适合作为你的主浏览器。这个浏览器有一个简单、干净、漂亮的外观。GNOME Web 的功能比 Firefox 少,但对于普通用途来说已经足够了。 + +![][8] + +GNOME Web 提供了以下功能: + + * 隐身模式 + * GNOME 桌面集成 + * 内置广告拦截器 + * 智能跟踪预防 + +关于 GNOME Web 的更多信息可以在这个链接中找到: + +### Chromium + +Chromium 是一个来自 Chromium 项目的开源 Web 浏览器,它有一个极简的用户界面。它的外观与 Chrome 相似,因为它实际上是作为 Chrome 和其他几个浏览器的基础。许多人使用 Chromium 是因为他们已经习惯了 Chrome。 + +![][9] + +Chromium 提供以下功能: + + * 隐身模式 + * 扩展程序 + * 密码的自动填写 + +关于 Chromium 浏览器的更多信息可在此链接中找到: + +### qutebrowser + +这个浏览与上面提到的稍有不同,qutebrowser 是一个以键盘为中心的浏览器,具有精简的 GUI。因此,你不会发现通常在其他浏览器中的按钮,如返回、主页、重新加载等。相反,你可以用键盘输入命令来运行 qutebrowser 中的功能。它使用 Vim 风格的键绑定,所以它适合 Vim 用户。如果你有兴趣在上网时获得不同的体验,你应该试试这个浏览器。 + +![][10] + +qutebrowser 提供以下功能: + + * 广告屏蔽 + * 隐私浏览模式 + * 快速书签 + +关于 qutebrowser 浏览器的更多信息可在此链接中找到: + +### 总结 + +每个人在使用互联网时都有不同的需求,特别是在浏览方面。本文中提到的每个浏览器都有不同的功能。因此,请选择适合你日常需求和喜好的浏览器。如果你使用的是本文中提到的浏览器,请在评论中分享你的故事。如果你使用的是其他的浏览器,请说一下。希望这篇文章能帮助你选择在 Fedora 上满足你日常需求的浏览器。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/apps-for-daily-needs-part-1-web-browsers/ + +作者:[Arman Arisman][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/armanwu/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2021/07/FedoraMagz-Apps-1-Browsers-2-816x345.jpg +[2]: https://unsplash.com/@brookecagle?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]: https://unsplash.com/s/photos/meeting-on-cafe-computer?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: https://fedoramagazine.org/things-to-do-after-installing-fedora-34-workstation/ +[5]: https://www.mozilla.org/en-US/ +[6]: https://fedoramagazine.org/wp-content/uploads/2021/07/Browsers-Firefox-1-1024x707.png +[7]: https://www.mozilla.org/en-US/firefox/ +[8]: https://fedoramagazine.org/wp-content/uploads/2021/07/Browsers-Web-1024x658.png +[9]: https://fedoramagazine.org/wp-content/uploads/2021/07/Browsers-Chromium-1-1024x690.png +[10]: https://fedoramagazine.org/wp-content/uploads/2021/07/Browsers-qb-1024x687.png diff --git a/published/202107/20210719 Linux package managers- dnf vs apt.md b/published/202107/20210719 Linux package managers- dnf vs apt.md new file mode 100644 index 0000000000..30cee09b9e --- /dev/null +++ b/published/202107/20210719 Linux package managers- dnf vs apt.md @@ -0,0 +1,216 @@ +[#]: subject: (Linux package managers: dnf vs apt) +[#]: via: (https://opensource.com/article/21/7/dnf-vs-apt) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: (perfiffer) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13620-1.html) + +Linux 包管理器比较:dnf 和 apt +====== + +> 包管理器提供大致相同的功能:安装、管理和移除应用,但是它们还是有一些不一样的地方。 + +![](https://img.linux.net.cn/data/attachment/album/202107/27/083002sd5zzxu37yhiz6yc.jpg) + +[在 Linux 系统上获取一个应用][2] 有多种方式。例如,有新的 Flatpak 和容器方式,也有 DEB 和 RPM 这样一直以来经过考验的方式。 + +并没有一种通用的可以用于所有的操作系统的应用安装程序。如今,因为有无数的开发者发布软件,这导致了大部分的操作系统使用了应用商店(包括第一方和第三方)、拖放式安装,还有安装向导。不同的开发者对于他们发布的代码有不同的需求,这直接导致了他们所选择的安装方式的不同。 + +Linux 开创了一种通过命令行安装、管理、移除应用的包管理器的概念。`apt` 和 `dnf` 就是两种较为常见的包管理器。`apt` 命令是用来管理 DEB 格式的包,`dnf` 命令是用来管理 RPM 格式的包。这两种包管理器在理论上并不是完全互斥的,尽管在实际的实践中,Linux 发行版通常只会使用到其中的一种。理论上,这两种命令可以运行在同一个系统上,但是会造成安装包的重叠,版本控制也会更加困难,命令也会是冗余的。然而,如果你是在一个混合的 Linux 环境下工作,比如你的工作站运行的是一个发行版,同时需要与运行另外一种发行版的服务器进行交互,那么你最好同时掌握这两种包管理器。 + +### 搜索应用 + +当你通过包管理器安装一个应用时,你需要先知道包的名称。通常,应用的名称和包的名称是一样的。`dnf` 和 `apt` 验证要安装的包名的过程是完全相同的。 + +``` +$ sudo dnf search zsh +====== Name Exactly Matched: zsh ====== +zsh.x86_64 : Powerful interactive shell +[...] +``` + +使用 `apt`: + +``` +$ sudo apt search zsh +Sorting... Done +Full Text Search... Done +csh/stable 20110502-4+deb10u1 amd64 + Shell with C-like syntax + +ddgr/stable 1.6-1 all + DuckDuckGo from the terminal + +direnv/stable 2.18.2-2 amd64 + Utility to set directory specific environment variables + +draai/stable 20180521-1 all + Command-line music player for MPD +[...] +``` + +如果想通过 `apt` 更快的获取相关的搜索结果,你可以使用 [正则表达式][3]: + +``` +apt search ^zsh +Sorting... Done +Full Text Search... Done +zsh/stable 5.7.1-1 amd64 + shell with lots of features +[...] +``` + +### 查找应用程序包 + +有一些命令是与其它命令捆绑在一起的,都在一个包中。在这种情况下,你可以通过包管理器去了解哪个包提供了你需要的命令。`dnf` 和 `apt` 命令在如何搜索这类元数据上是有区别的。 + +使用 `dnf`: + +``` +$ sudo dnf provides pgrep +procps-ng-3.3.15-6.el8.x86_64 : System and process monitoring utilities +Repo : baseos +Matched from: +Filename : /usr/bin/pgrep +``` + +`apt` 命令使用子命令 `apt-file`。要使用 `apt-file`,你必须先安装它,然后提示它更新缓存: + +``` +$ sudo apt install apt-file +Reading package lists... Done +Building dependency tree +Reading state information... Done +The following additional packages will be installed: + libapt-pkg-perl libexporter-tiny-perl liblist-moreutils-perl libregexp-assemble-perl +The following NEW packages will be installed: + apt-file libapt-pkg-perl libexporter-tiny-perl liblist-moreutils-perl libregexp-assemble-perl +0 upgraded, 5 newly installed, 0 to remove and 14 not upgraded. +Need to get 297 kB of archives. +After this operation, 825 kB of additional disk space will be used. +Do you want to continue? [Y/n] y + +$ sudo apt-file update +[...] +``` + +你可以通过 `apt-file` 搜索命令。你可以使用此命令进行广泛的全局搜索,但假如你知道命令的执行路径,它会更准确: + +``` +$ sudo apt-file search /usr/bin/pgrep +pgreplay: /usr/bin/pgreplay               +procps: /usr/bin/pgrep +``` + +### 安装应用程序 + +使用`apt` 和 `dnf` 安装应用程序基本上是相同的: + +``` +$ sudo apt install zsh +``` + +使用 `dnf`,你可以使用同样的方式来安装一个包: + +``` +$ sudo dnf install zsh +``` + +许多基于 RPM 的发行版都具有组包安装的特性,它会将有时表面相关的应用程序收集到一个易于安装的目标中。例如,Fedora 中的 [Design Suite][4] 组包就包含流行的创意应用程序。那些想要某一个创意应用程序的艺术家可能也想要类似的应用程序,选择安装一整个组包一个简单而快速的方法,可以合理地开始建立一个数字工作室。你可以通过 `group list` 来查看可用的组包(使用 `-v` 来查看不带空格的组名): + +``` +$ sudo dnf group list -v +[...] +Available Groups: + Container Management (container-management) + RPM Development Tools (rpm-development-tools) + Design Suite (design-suite) + Development Tools (development) +[...] +``` + +使用 `group install` 子命令安装 RPM 组包: + +``` +$ sudo dnf group install design-suite +``` + +你可以使用 `@` 符号来减少输入: + +``` +$ sudo dnf install @design-suite +``` + +### 更新应用程序 + +使用包管理器的一个优点是,它知道所有已经安装的应用。这样你不必去寻找应用程序的更新版本。相反,你可以通过包管理器去获取更新的版本。 + +`dnf` 和 `apt` 使用的子命令略有不同。因为 `apt` 保存了一个需要定期更新的缓存信息,它使用 `upgrade` 子命令来更新应用程序: + +``` +$ sudo apt upgrade +``` + +相比之下,`dnf` 命令在你每次使用时都会更新元信息,所以 `update` 和 `upgrade` 子命令是可以互换的: + +``` +$ sudo dnf upgrade +``` + +这等同于: + +``` +$ sudo dnf update +``` + +### 移除应用程序 + +如果你曾经尝试在任何一个平台上手动删除一个应用程序,你就会知道,应用程序删除后,在硬盘上会残留各种文件,比如首选项文件、数据或图标。所以包管理器的另一个优点是,包管理器管理着包中安装的每一个文件,可以很方便的删除: + +``` +$ sudo dnf remove zsh +``` + +`remove` 子命令也适用于 `apt`: + +``` +$ sudo apt remove zsh +``` + +使用 `apt` 命令删除一个包并不会删除已修改的用户配置文件,以防你意外删除了包。如果你想通过 `apt` 命令删除一个应用及其配置文件,请在你之前删除过的应用程序上使用 `purge` 子命令: + +``` +$ sudo apt purge zsh +``` + +`apt` 和 `dnf` 都不会删除家目录中的数据和配置文件(即使使用 `purge` 子命令)。如果想要从家目录中删除数据,你必须手动操作(通常你可以在 `~/.config` 和 `~/.local` 文件中找到)。 + +### 了解包管理 + +无论你选择的发行版支持的是 `apt` 还是 `dnf`,这些命令的用途大致相同。它们可以帮助你安装、更新和移除包。这两种包管理器是目前最通用的包管理器。它们的语法元素在很大程度上是相同的,所以在两者之间切换非常容易。 + +`apt` 和 `dnf` 还有一些高级功能,例如仓库管理,但这些功能并不像你使用 `search` 和 `install` 那样频繁。 + +无论你更经常使用哪种包管理器,你都可以下载我们的 [apt 备忘单][5] 和 [dnf 备忘单][6],以便你在最需要的时候可以查询使用语法。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/dnf-vs-apt + +作者:[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/OSDC_gift_giveaway_box_520x292.png?itok=w1YQhNH1 (Gift box opens with colors coming out) +[2]: https://opensource.com/article/18/1/how-install-apps-linux +[3]: https://opensource.com/article/18/5/getting-started-regular-expressions +[4]: https://labs.fedoraproject.org/en/design-suite/ +[5]: https://opensource.com/downloads/apt-cheat-sheet +[6]: https://opensource.com/downloads/dnf-cheat-sheet diff --git a/published/202107/20210719 Run Python applications in virtual environments.md b/published/202107/20210719 Run Python applications in virtual environments.md new file mode 100644 index 0000000000..fba26ff824 --- /dev/null +++ b/published/202107/20210719 Run Python applications in virtual environments.md @@ -0,0 +1,152 @@ +[#]: subject: (Run Python applications in virtual environments) +[#]: via: (https://opensource.com/article/21/7/python-pipx) +[#]: author: (Sumantro Mukherjee https://opensource.com/users/sumantro) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13631-1.html) + +pipx:在虚拟环境中运行 Python 应用 +====== + +> 通过使用 pipx 隔离运行 Python 应用来避免版本冲突并提高安全性。 + +![](https://img.linux.net.cn/data/attachment/album/202107/29/205146cpwgxnnpgu44gxz0.jpg) + +如果你使用 Python,你可能会安装很多 Python 应用。有些是你只想尝试的工具。还有一些是你每天都在使用的久经考验的应用,所以你把它们安装在你使用的每一台计算机上。这两种情况下,在虚拟环境中运行你的 Python 应用是非常有用的,这可以使它们以及它们的依赖关系相互分离,以避免版本冲突,并使它们与你系统的其它部分隔离,以提高安全性。 + +这就是 [pipx][2] 出场的地方。 + +大多数 Python 应用可以使用 [pip][3] 进行安装,它只安装 Python 包。然而,`pipx` 为你的 Python 应用创建并管理一个虚拟环境,并帮助你运行它们。 + +### 安装 pipx + +`pipx` 主要是一个 RPM 包,你可以在任何 Fedora、RHEL 或 CentOS 机器上安装它: + +``` +$ sudo dnf install pipx +``` + +### 使用 pipx + +我将通过 Cowsay 以及 [Concentration][4] 工具演示如何使用 `pipx`。 + +#### 安装软件包 + +安装完 `pipx` 后,你可以用以下方法安装 Python 包: + +``` +$ pipx install +``` + +要安装 Cowsay 包: + +``` +$ pipx install cowsay ✔ │ 20:13:41 + installed package cowsay 4.0, Python 3.9.5 + These apps are now globally available + - cowsay +done! ✨ 🌟 ✨ +``` + +现在你可以在系统的任何地方运行 Cowsay,通过终端与你对话! + + +``` +$ cowsay "I <3 OSDC" + _________ +| I <3 OSDC | + ========= + \ + \ + ^__^ + (oo)\_______ + (__)\ )\/\ + ||----w | + || || +``` + +![Cowsay][5] + +#### 以特殊权限进行安装 + +不是所有的应用都像 Cowsay 一样简单。例如,Concentration 会与你系统中的许多其他组件交互,所以它需要特殊的权限。用以下方式安装它: + +``` +$ pipx install concentration ✔ │ 10s │ │ 20:26:12 + installed package concentration 1.1.5, Python 3.9.5 + These apps are now globally available + - concentration +done! ✨ 🌟 ✨ +``` + +Concentration 通过阻止 `distractors` 文件中列出的特定网站来帮助你集中注意力。要做到这点,它需要以 `sudo` 或 root 权限运行。你可以用 [OpenDoas][7] 来做到这点,这是 `doas` 命令的一个版本,可以用特定的用户权限运行任何命令。要使用 `doas` 以 `sudo` 权限来运行 Concentration: + +``` +$ doas concentration improve ✔ │ │ 20:26:54 +doas (sumantrom) password: +Concentration is now improved :D! +``` + +如你所见,这个独立的应用能够改变系统中的一些东西。 + +#### 列出已安装的应用 + +`pipx list` 命令显示所有用 `pipx` 安装的应用和它们的可执行路径: + +``` +$ pipx list +venvs are in /home/sumantrom/.local/pipx/venvs +apps are exposed on your $PATH at /home/sumantrom/.local/bin + package concentration 1.1.5, Python 3.9.5 + - concentration + package cowsay 4.0, Python 3.9.5 + - cowsay +``` + +#### 卸载应用 + +当你使用完毕后,知道如何卸载它们是很重要的。`pipx` 有一个非常简单的卸载命令: + +``` +$ pipx uninstall +``` + +或者你可以删除每个软件包: + +``` +$ pipx uninstall-all + +pipx uninstall-all 2 ✘ │ 20:13:35 +uninstalled cowsay! ✨ 🌟 ✨ +uninstalled concentration! ✨ 🌟 ✨ +``` + +### 尝试 pipx + +`pipx` 是一个流行的 Python 应用的包管理器。它可以访问 [PyPi][8] 上的所有东西,但它也可以从包含有效 Python 包的本地目录、Python wheel 或网络位置安装应用。 + +如果你安装了大量的 Python 应用,可以试试 `pipx`。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/python-pipx + +作者:[Sumantro Mukherjee][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sumantro +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet) +[2]: https://pypi.org/project/pipx/ +[3]: https://pypi.org/project/pip/ +[4]: https://opensource.com/article/20/8/python-concentration +[5]: https://opensource.com/sites/default/files/uploads/cowsay.png (Cowsay) +[6]: https://creativecommons.org/licenses/by-sa/4.0/ +[7]: https://github.com/Duncaen/OpenDoas +[8]: https://pypi.org/ diff --git a/published/202107/20210720 Meet Clapper- A Sleek Looking Linux Video Player for Minimalists.md b/published/202107/20210720 Meet Clapper- A Sleek Looking Linux Video Player for Minimalists.md new file mode 100644 index 0000000000..2c05cb36a8 --- /dev/null +++ b/published/202107/20210720 Meet Clapper- A Sleek Looking Linux Video Player for Minimalists.md @@ -0,0 +1,91 @@ +[#]: subject: (Meet Clapper: A Sleek Looking Linux Video Player for Minimalists) +[#]: via: (https://itsfoss.com/clapper-video-player/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (turbokernel) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13638-1.html) + +认识 Clapper:一款外观时尚的 Linux 视频播放器,极简主义者适用 +====== + +喜欢极简主义吗?你会喜欢 Clapper 的。 + +Clapper 是一个全新 [Linux 视频播放器][1]。实际上,它更多的是基于 GNOME 而不是 Linux。 + +它基于 GNOME 的 JavaScript 库和 GTK4 工具包构建,自然地融合在 GNOME 的桌面环境中。它使用 [GStreamer][2] 作为媒体后端,使用 [OpenGL][3] 进行渲染。 + +我喜欢极简主义的应用。虽然 VLC 是媒体播放器中的瑞士军刀,但我更喜欢 [MPV 播放器][4],因为它的界面时尚、简约。现在我想要坚持使用 Clapper 一段时间了。 + +### Clapper 视频播放器 + +![A screenshot of Clapper video player][5] + +[Clapper 默认开启硬件加速][6]。它支持英特尔和 AMD 的 GPU,在 Xorg 和 Wayland 上都能工作。 + +[Clapper][7] 不使用传统的上部窗口栏。为你提供自动隐藏的偏好菜单、模式切换器和窗口控制按钮供等功能。这给了它一个时尚、简约的外观。 + +它有三种模式: + + * 窗口模式:默认模式显示进度条和窗口控制。 + * 浮动模式:隐藏进度条,播放器浮于其他应用程序的顶部,就像“[总是在顶部][8]”或“画中画”模式。 + * 全屏模式:播放器进入全屏,进度条变大,但它们都会自动隐藏起来 + +![Interface of Clapper video player with preference control and window modes][9] + +Clapper 也有一个自适应的用户界面,可基于 Linux 的智能手机和平板电脑上使用。因此,如果你有自己的 Pine Phone 或 Librem5,你可以在它上面使用 Clapper。 + +它支持字幕,并可选择改变字体。然而,在我的测试中,字幕并不可用。也没有可以明确地在播放的视频中添加字幕的选项。这一点必须改进。 + +和 VLC 一样,如果你再次打开同一个视频文件,Clapper 也可以让你选择从最后一个时间点恢复播放。这是我喜欢的 VLC 中的一个 [方便的功能][10]。 + +如果你有 URL,Clapper 也支持从互联网上播放视频。 + +这里的截图中,我正在 Clapper 中播放一个 YouTube 视频。这是一首由一位美丽的歌手和演员唱的优美歌曲。你能猜到这是哪首歌或哪部电影吗? + +![Clapper playing a video from YouTube][11] + +### 在 Linux 上安装 Clapper + +对 Arch 和 Manjaro 用户而言,Clapper 可在 AUR 中找到。这很稀疏平常,因为 AUR 包罗万象。 + +对于其他发行版,Clapper 官方提供了 [Flatpak 包][12]。所以,请 [为你的发行版启用 Flatpak 支持][13],然后使用下面的命令来安装它: + +``` +flatpak install flathub com.github.rafostar.Clapper +``` + +安装后,只需在应用菜单中搜索它,或右击视频文件,选择用 Clapper 打开它。 + +Clapper 仍不是一个完美的视频播放器。然而,它有可能成为一个流行的 Linux 应用。 + +如果你使用它,请分享你的经验。如果你发现问题,请[通知开发者][14]。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/clapper-video-player/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[turbokernel](https://github.com/turbokernel) + +本文由 [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/video-players-linux/ +[2]: https://gstreamer.freedesktop.org/ +[3]: https://www.opengl.org/ +[4]: https://itsfoss.com/mpv-video-player/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/clapper-screenshot.png?resize=800%2C498&ssl=1 +[6]: https://github.com/Rafostar/clapper/wiki/Hardware-acceleration +[7]: https://github.com/Rafostar/clapper +[8]: https://itsfoss.com/always-on-top/ +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/clapper-video-player-interface.jpg?resize=800%2C480&ssl=1 +[10]: https://itsfoss.com/simple-vlc-tips/ +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/07/clapper-youtube-video.jpg?resize=800%2C501&ssl=1 +[12]: https://flathub.org/apps/details/com.github.rafostar.Clapper +[13]: https://itsfoss.com/flatpak-guide/ +[14]: https://github.com/Rafostar/clapper/issues diff --git a/published/202107/20210720 Run a Linux virtual machine in Podman.md b/published/202107/20210720 Run a Linux virtual machine in Podman.md new file mode 100644 index 0000000000..5f4d366a05 --- /dev/null +++ b/published/202107/20210720 Run a Linux virtual machine in Podman.md @@ -0,0 +1,114 @@ +[#]: subject: (Run a Linux virtual machine in Podman) +[#]: via: (https://opensource.com/article/21/7/linux-podman) +[#]: author: (Sumantro Mukherjee https://opensource.com/users/sumantro) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13635-1.html) + +在 Podman 中运行一个 Linux 虚拟机 +====== + +> 使用 Podman Machine 创建一个基本的 Fedora CoreOS 虚拟机来使用容器和容器化工作负载。 + +![](https://img.linux.net.cn/data/attachment/album/202107/31/114043y4d0kstx90zpx6o3.jpg) + +Fedora CoreOS 是一个自动更新、最小化的基于 [rpm-ostree][2] 的操作系统,用于安全地、大规模地运行容器化工作负载。 + +[Podman][3] “是一个用于管理容器和镜像、挂载到这些容器中的卷,以及由这些容器组组成的吊舱的工具。Podman 基于 libpod,它是一个容器生命周期管理库”。 + +当你使用 [Podman Machine][4] 时,神奇的事情发生了,它可以帮助你创建一个基本的 Fedora CoreOS 虚拟机(VM)来使用容器和容器化工作负载。 + +### 开始使用 Podman Machine + +第一步是安装 Podman。如果你已经安装了最新版本的 Podman,你可以跳过这个步骤。在我的 Fedora 34 机器上,我用以下方式安装 Podman: + +``` +$ sudo dnf install podman +``` + +我使用的是 podman-3.2.2-1.fc34.x86_64。 + +### 初始化 Fedora CoreOS + +Podman 安装完成后,用以下方法初始化它: + +``` +❯ podman machine init vm2 +Downloading VM image: fedora-coreos-34.20210626.1.0-qemu.x86_64.qcow2.xz: done +Extracting compressed file +``` + +这个命令创建了 `vm2`,并下载了 .xz 格式的 Fedora CoreOS 的 qcow2 文件并将其解压。 + +### 列出你的虚拟机 + +了解你的虚拟机和它们的状态是很重要的,`list` 命令可以帮助你做到这一点。下面的例子显示了我所有的虚拟机的名称,它们被创建的日期,以及它们最后一次启动的时间: + +``` +❯ podman machine list +NAME VM TYPE CREATED LAST UP +podman-machine-default* qemu 6 days ago Currently running +vm2 qemu 11 minutes ago 11 minutes ago +``` + +### 启动一个虚拟机 + +要启动一个虚拟机,请运行: + +``` +❯ podman machine start +Waiting for VM ... +``` + +### SSH 到虚拟机 + +你可以使用 SSH 来访问你的虚拟机,并使用它来运行工作负载,而没有任何麻烦的设置: + +``` +❯ podman machine ssh +Connecting to vm podman-machine-default. To close connection, use `~.` or `exit` +Fedora CoreOS 34.20210611.1.0 +Tracker: https://github.com/coreos/fedora-coreos-tracker +Discuss: https://discussion.fedoraproject.org/c/server/coreos/ + +Last login: Wed Jun 23 13:23:36 2021 from 10.0.2.2 +[core@localhost ~]$ uname -a +Linux localhost 5.12.9-300.fc34.x86_64 #1 SMP Thu Jun 3 13:51:40 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux +[core@localhost ~]$ +``` + +目前,Podman 只支持一次运行一个虚拟机。 + +### 停止你的虚拟机 + +要停止运行中的虚拟机,请使用 `stop` 命令: + +``` +❯ podman machine stop + +[core@localhost ~]$ Connection to localhost closed by remote host. +Connection to localhost closed. +Error: exit status 255 +``` + +我希望这能帮助你开始使用 Podman Machine。请试一试,并在评论中告诉我们你的想法。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/linux-podman + +作者:[Sumantro Mukherjee][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sumantro +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-window-focus.png?itok=g0xPm2kD (young woman working on a laptop) +[2]: http://coreos.github.io/rpm-ostree/ +[3]: https://github.com/containers/podman +[4]: http://docs.podman.io/en/latest/markdown/podman-machine.1.html \ No newline at end of file diff --git a/published/202107/20210722 Top Android Emulators to Run and Test Android Apps on Linux.md b/published/202107/20210722 Top Android Emulators to Run and Test Android Apps on Linux.md new file mode 100644 index 0000000000..2a4b7ab2d0 --- /dev/null +++ b/published/202107/20210722 Top Android Emulators to Run and Test Android Apps on Linux.md @@ -0,0 +1,139 @@ +[#]: subject: (Top Android Emulators to Run and Test Android Apps on Linux) +[#]: via: (https://itsfoss.com/android-emulators-linux/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13629-1.html) + +Linux 上的顶级安卓模拟器 +====== + +![](https://img.linux.net.cn/data/attachment/album/202107/29/111502vg5knofnpjc2jp5c.jpg) + +安卓系统是建立在高度定制的 Linux 内核之上的。因此,使用安卓模拟器在 Linux 上运行移动应用是有意义的。 + +虽然这不是在 Linux 机器上你可以做的新鲜事,但在 Windows 于 2021 年推出运行安卓应用的能力后,它是一个更需要的功能。 + +不仅仅限于使用应用,一些安卓模拟器也可以在开发和测试中派上用场。 + +因此,我总结了一份最好的模拟器清单,你可以用它来测试或在 Linux 上运行安卓应用/游戏。 + +### 1、Anbox + +![视频](https://youtu.be/MbmiHnasGWg) + +Anbox 是一个相当流行的模拟器,可以让 Linux 用户运行 Android 应用。可能深度 Linux 正是利用它使得开箱即可运行安卓应用。 + +它使用一个容器将安卓操作系统与主机隔离,这也让它们可以使用最新的安卓版本。 + +运行的安卓应用不能直接访问你的硬件,这是一个很好的安全决定。 + +与这里的其他一些选择不同,Anbox 在技术上不需要仿真层来使安卓系统工作。换句话说,它在你的 Linux 系统上最接近于原生的安卓体验。 + +由于这个原因,它可能不是最简单的选择。你不能只使用谷歌应用商店来安装应用,你需要使用安卓调试桥(ADB)。你只需要一个应用的 APK 文件就可以安装和使用它。 + +- [Anbox][1] + +### 2、Genymotion + +![][2] + +Genymotion 是一个为测试和开发量身定做的令人印象深刻的解决方案。 + +它不是一个自由开源的选择。它们通过云端或独立于 Android Studio 的桌面客户端,提供虚拟的安卓体验作为服务。 + +你可以模拟各种硬件配置和安卓版本,创建一个虚拟设备进行测试。它还让你有能力扩大规模,并有多个安卓虚拟设备运行,进行广泛的测试。 + +它可以帮助你测试文件上传在你的应用中如何工作,电池影响、性能、内存等等。 + +虽然它是一个主要针对专业人士的高级解决方案,但它确实支持最新的 Linux 发行版,包括 Ubuntu 20.04 LTS。 + +- [Genymotion][3] + +### 3、Android-x86 + +![][4] + +Android x86 是一个开源项目,使得安卓可以在 PC 上运行,并支持 32 位。 + +你可以选择在你的 Linux 系统上使用虚拟机管理器来安装它,或者直接在你的 PC 上试用它。 + +如果你需要安装,可以查看官方的 [安装说明][5]。 + +与其他一些选择不同,它是一个简单的试图在 PC 上工作的模拟器,没有花哨的功能。 + +- [Android x86][6] + +### 4、Android Studio (虚拟设备) + +![][7] + +Android Studio 是一个用于开发和测试的完整工具。幸运的是,由于对 Linux 的支持,如果你需要的话,你可以用它来模拟安卓的体验进行实验。 + +你只需要创建一个安卓虚拟设备(AVD),你可以对其进行配置,然后作为模拟器进行模拟。 + +也有很大的机会能找到对一些最新的智能手机、电视和智能手表的支持。 + +它需要一定的学习曲线才能上手,但它是免费的,而且是完全开源的。 + +- [Android Studio][8] + +### 5、ARChon + +![][9] + +一个有趣的解决方案,这是一个你可以在 Linux 和任何其他平台上使用的安卓模拟器。 + +它有助于在 Chrome OS 上运行安卓应用,或者在任何操作系统上使用 Chrome 浏览器。与其他一些不同的是,你可能不会得到完整的安卓体验,而只是能够运行安卓应用。 + +你只需解压运行时,并将其加载到 Chrome 扩展中。接下来,下载 APK 文件到上面来添加你想使用的应用。 + +- [ARChon][10] + +### 6、Bliss OS + +![][11] + +Bliss OS 是另一个开源项目,与 Android x86 类似,旨在使安卓在 PC 上运行。 + +与 Android x86 不同的是,它通过支持 32 位和 64 位架构提供了更多的兼容性选择。此外,你可以根据你的处理器下载兼容文件。 + +它有积极的维护,支持市场上最新的安卓版本。 + +- [Bliss OS][12] + +### 总结 + +虽然你会能找到几个可用于 Linux 的安卓模拟器,但它们可能无法取代全面的智能手机体验。 + +每个模拟器都有一系列的功能和特定目的。请选择你需要的那个! + +你试过安卓模拟器么?你在 Linux 中使用的最喜欢的模拟器是什么?欢迎在下面的评论中让我知道。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/android-emulators-linux/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://anbox.io +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/genymotion-android-emulator.png?resize=800%2C508&ssl=1 +[3]: https://www.genymotion.com +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/android-x86-emulator.jpg?resize=1920%2C1080&ssl=1 +[5]: https://www.android-x86.org/installhowto.html +[6]: https://www.android-x86.org +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/android-virtual-devices-studio.png?resize=800%2C296&ssl=1 +[8]: https://developer.android.com/studio +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/07/arcrhon.jpg?resize=800%2C426&ssl=1 +[10]: https://archon-runtime.github.io +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/07/bliss-os-android.png?resize=800%2C576&ssl=1 +[12]: https://blissos.org diff --git a/published/202107/20210722 Ubuntu 20.10 Reached End of Life, Time to Upgrade.md b/published/202107/20210722 Ubuntu 20.10 Reached End of Life, Time to Upgrade.md new file mode 100644 index 0000000000..128b6d38e5 --- /dev/null +++ b/published/202107/20210722 Ubuntu 20.10 Reached End of Life, Time to Upgrade.md @@ -0,0 +1,69 @@ +[#]: subject: (Ubuntu 20.10 Reached End of Life, Time to Upgrade!) +[#]: via: (https://news.itsfoss.com/ubuntu-20-10-end-of-life/) +[#]: author: (Ankush Das https://news.itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: (zd200572) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13611-1.html) + +Ubuntu 20.10 到达生命终点,该升级啦! +====== + +> 哦!Ubuntu 20.10 将不再收到任何更新。如果你还在使用它,你的系统将面临风险,请考虑升级到 Ubuntu 21.04! + +![](https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/ubuntu-20-10-eof.png?w=1200&ssl=1) + +Ubuntu 20.10(Groovy Gorilla)2021 年 7 月 22 日停止支持啦。它是一个非长期支持发行版本,[带来了一些令人兴奋的新特性][1]。 + +通常,非长期支持发行版维护 9 个月,所以生命周期结束意味着Ubuntu 20.10 用户将没有安全和维护更新。 + +你也会错过已安装应用的更新,[使用 apt 命令][2] 安装新软件也会面临问题。如果不手动修改 `sources.list`(不推荐),使用软件中心也将是个问题。 + +支持周期的结束会影响所有的其他 Ubuntu 特色版本,像 Kubuntu、Lubuntu、MATE 等。 + +但是像 Linux Mint 和 elementary OS 这样的发行版不依赖于非长期支持发行版,你不必有任何担心。 + +使用下面的命令在终端 [检查下你安装的 Ubuntu 版本][3]是个好主意: + +``` +lsb_release -a +``` + +### 升级到 Ubuntu 21.04(Hirsute Hippo):正是时候! + +毫无疑问,你需要升级到 Ubuntu 21.04 才能获得最新的更新和安全改进。 + +[Ubuntu 21.10 版本][4] 将在几个月后发布,所以你也可以尝试到时升级到这个版本。 + +现在,你可以按照我们的 [Ubuntu 升级][5]教程来开始升级。 + +我推荐你备份一下,以防升级过程中出现问题。 + +如果你想重新安装,也可以。 + +### 还在用 Ubuntu 20.10? + +从技术上来说,你可以继续使用不受支持的版本,如果你不想安全问题蔓延,建议还是升级到最新的版本,比如 Ubuntu 21.04。 + +Ubuntu 21.04 将会提供支持到 2022 年 1 月,升级前你可能想看下 [Ubuntu 21.04 的特性][6]。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/ubuntu-20-10-end-of-life/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[zd200572](https://github.com/zd200572) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/ubuntu-20-10-features/ +[2]: https://itsfoss.com/apt-command-guide/ +[3]: https://itsfoss.com/how-to-know-ubuntu-unity-version/ +[4]: https://news.itsfoss.com/ubuntu-21-10-release-schedule/ +[5]: https://itsfoss.com/upgrade-ubuntu-version/ +[6]: https://news.itsfoss.com/ubuntu-21-04-features/ diff --git a/published/202107/20210725 How to Install VLC on Fedora Linux.md b/published/202107/20210725 How to Install VLC on Fedora Linux.md new file mode 100644 index 0000000000..6c9e40d684 --- /dev/null +++ b/published/202107/20210725 How to Install VLC on Fedora Linux.md @@ -0,0 +1,79 @@ +[#]: subject: (How to Install VLC on Fedora Linux) +[#]: via: (https://itsfoss.com/install-vlc-fedora/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13637-1.html) + +如何在 Fedora Linux 上安装 VLC +====== + +![](https://img.linux.net.cn/data/attachment/album/202107/31/215634thkmiihq1limel4i.jpg) + +如果你刚刚安装了 Fedora,现在想在上面安装你最喜欢的视频播放器 VLC,你可能不会在软件中心找到它。至少不会立即找到。 + +出于只有它的开发者知道的原因,Fedora 既没有安装 [VLC][1],也不包括在 Fedora 官方仓库中。 + +那么,你如何在 Fedora 上安装 VLC 呢?很简单。RPM Fusion 是你的朋友。让我告诉你详细的步骤。 + +### 在 Fedora Linux 上安装 VLC + +在这里使用命令行会更容易。你也可以使用图形化的方法。我将在后面讨论它。 + +打开终端,使用下面的命令来添加和启用包含 VLC 包的 RPM Fusion 仓库: + +``` +sudo dnf install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm +``` + +当被要求确认添加新仓库时按 `Y`。接下来,使用 DNF 命令安装 VLC: + +``` +sudo dnf install vlc +``` + +它将在 Fedora 中从 RPM Fusion 仓库中安装 VLC,并从不同的仓库中安装一些额外的依赖项。 + +![Installing VLC in Fedora with DNF command][2] + +安装后,你可以在应用程序菜单中搜索 VLC,或者在“活动区”中搜索它。 + +![Search for VLC][3] + +点击、启动并享受它。 + +#### 替代方法:从软件中心安装 VLC + +当你已经启用了 RPM Fusion 仓库,你可以在软件中心显示这个仓库的应用。要做到这一点,在终端使用以下命令: + +``` +sudo dnf groupupdate core +``` + +之后,打开软件中心,搜索 VLC 并从那里安装。 + +![VLC in Fedora software center][4] + +如果你有添加 FlatHub 仓库,请避免安装 Flatpak 版本的 VLC,因为它的大小大约是 1GB。RPM 版本的大小要小得多。 + +我希望你觉得这个快速教程对在 Fedora 上安装 VLC 有帮助。享受吧。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-vlc-fedora/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.videolan.org/ +[2]: https://itsfoss.com/wp-content/uploads/2021/07/installing-vlc-fedora-800x422.webp +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/07/vlc-fedora.png?resize=799%2C223&ssl=1 +[4]: https://itsfoss.com/wp-content/uploads/2021/07/vlc-in-fedora-software-center-800x486.webp \ No newline at end of file diff --git a/published/20210712 Reading and writing files with Python.md b/published/20210712 Reading and writing files with Python.md new file mode 100644 index 0000000000..e399f2d528 --- /dev/null +++ b/published/20210712 Reading and writing files with Python.md @@ -0,0 +1,129 @@ +[#]: subject: "Reading and writing files with Python" +[#]: via: "https://opensource.com/article/21/7/read-write-files-python" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lujun9972" +[#]: translator: "MjSeven" +[#]: reviewer: "turbokernel" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13649-1.html" + +使用 Python 读写文件 +====== + +> 每种编程语言处理文件数据的方式不尽相同,Python 是这么干的。 + +![](https://img.linux.net.cn/data/attachment/album/202108/05/094700u9kj42rn4jh5h4hr.jpg) + +有些数据是临时的,它们在应用程序运行时存储在内存中,然后丢弃。但是有些数据是持久的。它们存储在硬盘驱动器上供以后使用,而且它们通常是用户最关心的东西。对于程序员来说,编写代码读写文件是很常见的,但每种语言处理该任务的方式都不同。本文演示了如何使用 Python 处理文件数据。 + +### 安装 Python + +在 Linux 上,你可能已经安装了 Python。如果没有,你可以通过发行版软件仓库安装它。例如,在 CentOS 或 RHEL 上: + +``` +$ sudo dnf install python3 +``` + +在 macOS 上,你可以使用 [MacPorts][2] 或 [Homebrew][3] 安装。在 Windows 上,你可以使用 [Chocolatey][4] 安装。 + +一旦安装了 Python,打开你最喜欢的文本编辑器,准备好写代码吧。 + +### 使用 Python 向文件中写入数据 + +如果你需要向一个文件中写入数据,记住有三个步骤: + + 1. 打开 + 2. 写入 + 3. 关闭 + +这与你在计算机上编码、编辑照片或执行其他操作时使用的步骤完全相同。首先,打开要编辑的文档,然后进行编辑,最后关闭文档。 + +在 Python 中,过程是这样的: + +``` +f = open('example.txt', 'w') +f.write('hello world') +f.close() +``` + +这个例子中,第一行以**写**模式打开了一个文件,然后用变量 `f` 表示,我使用了 `f` 是因为它在 Python 代码中很常见,使用其他任意有效变量名也能正常工作。 + +在打开文件时,有不同的模式: + + * `w` 代表写入 + * `r+` 代表可读可写 + * `a` 表示追加 + +第二行表示向文件中写入数据,本例写入的是纯文本,但你可以写入任意类型的数据。 + +最后一行关闭了文件。 + +#### 使用 `with` 语法写入数据 + +对于快速的文件交互,常用有一种简短的方法可以写入数据。它不会使文件保持打开状态,所以你不必记得调用 `close()` 函数。相反,它使用 `with` 语法: + +``` +with open('example.txt', 'a') as f: +    f.write('hello open source') +``` + +### 使用 Python 读取数据 + +如果你或你的用户需要通过应用程序需要向文件中写入一些数据,然后你需要使用它们,那么你就需要读取文件了。与写入类似,逻辑一样: + + 1. 打开 + 2. 读取 + 3. 关闭 + +同样的,这个逻辑反映了你一开始使用计算机就已知的内容。阅读文档,你可以打开、阅读,然后关闭。在计算机术语中,“打开”文件意味着将其加载到内存中。 + +实际上,一个文本文件内容肯定不止一行。例如,你需要读取一个配置文件、游戏存档或乐队下一首歌曲的歌词,正如你打开一本实体书时,你不可能立刻读完整本书,代码也只能解析已经加载到内存中的文件。因此,你可能需要遍历文件的内容。 + +``` +f = open('example.tmp', 'r') + +for line in f: +    print(line) + +f.close() +``` + +示例的第一行指明使用 **读** 模式打开一个文件,然后文件交由变量 `f` 表示,但就像你写数据一样,变量名是任意的。`f` 并没有什么特殊的,它只是单词 “file” 的最简表示,所以 Python 程序员会经常使用它。 + +在第二行,我们使用了 `line`,另一个任意变量名,用来表示 `f` 的每一行。这告诉 Python 逐行迭代文件的内容,并将每一行的内容打印到输出中(在本例中为终端或 [IDLE][5])。 + +#### 使用 `with` 语法读取数据 + +就像写入一样,使用 `with` 语法是一种更简短的方法读取数据。即不需要调用 `close()` 方法,方便地快速交互。 + +``` +with open('example.txt', 'r') as f: +    for line in f: +        print(line) +``` + +### 文件和 Python + +使用 Python 有很多方法向文件写入数据,包括用 [JSON、YAML、TOML][6] 等不同的格式写入。还有一个非常好的内置方法用于创建和维护 [SQLite][7] 数据库,以及许多库来处理不同的文件格式,包括 [图像][8]、音频和视频等。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/read-write-files-python + +作者:[Seth Kenlon][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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd "Hands on a keyboard with a Python book " +[2]: https://opensource.com/article/20/11/macports +[3]: https://opensource.com/article/20/6/homebrew-mac +[4]: https://opensource.com/article/20/3/chocolatey +[5]: https://opensource.com/article/17/10/python-101#idle +[6]: https://opensource.com/article/21/6/parse-configuration-files-python +[7]: https://opensource.com/article/21/2/sqlite3-cheat-sheet +[8]: https://opensource.com/article/19/3/python-image-manipulation-tools diff --git a/published/20210720 How to Upgrade to Debian 11 from Debian 10.md b/published/20210720 How to Upgrade to Debian 11 from Debian 10.md new file mode 100644 index 0000000000..d68dbbbf5d --- /dev/null +++ b/published/20210720 How to Upgrade to Debian 11 from Debian 10.md @@ -0,0 +1,136 @@ +[#]: subject: (How to Upgrade to Debian 11 from Debian 10) +[#]: via: (https://www.debugpoint.com/2021/07/upgrade-debian-11-from-debian-10/) +[#]: author: (Arindam https://www.debugpoint.com/author/admin1/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13647-1.html) + +提前尝鲜,从 Debian 10 升级到 Debian 11 +====== + +> 本指南解释了从 Debian 10 升级到 Debian 11 的步骤。 + +![](https://img.linux.net.cn/data/attachment/album/202108/04/114428rewb8x8m8tckevt9.jpg) + +[Debian][1] 的大版本发布是很罕见的,因为它往往需要社区的多年努力。这就是为什么 Debian 是真正的通用操作系统,并且在稳定性方面坚如磐石。 + +代号 Bullseye 的 [Debian 11][2] 即将正式发布。2021 年 7 月 15 日,Debian 11 进入完全冻结状态,这意味着发行在即。虽然官方发布日期还没有最终确定,但你现在就可以从 Debian 10 安装或升级到 Debian 11。 + +以下是方法。 + +### 前提条件 + + * 升级的过程非常简单明了。然而,采取某些预防措施是一个好的做法。特别是如果你正在升级一台服务器。 + * 对你的系统进行备份,包括所有重要的数据和文件。 + * 尝试禁用/删除你可能在一段时间内添加的任何外部仓库(PPA)。你可以在升级后逐一启用它们。 + * 关闭所有正在运行的应用。 + * 停止任何你可能已经启用的运行中的服务。升级完成后,你可以通过 [systemctl][3] 启动它们。这包括 Web 服务器、SSH 服务器、FTP 服务器或任何其他服务器。 + * 确保你有稳定的互联网连接。 + * 并为你的系统留出足够的停机时间。因为根据你的系统配置,Debian 版本升级需要时间大约在 1.5 小时到 2 小时之间。 + +### 将 Debian 10 Buster 升级到 11 Bullseye + +确保你的系统是最新的,而且你的软件包列表是最新的。 + +``` +sudo apt update && sudo apt upgrade +``` + +使用下面的命令安装 `gcc-8-base` 包。这是必须的,因为在历史上曾出现过升级失败的情况,这是因为下面的软件包中包含了某些依赖。 + +``` +sudo apt install gcc-8-base +``` + +![upgrade debian – system check][4] + +打开 `/etc/apt/sources.list`,通过注释 Debian 10 buster 包,而使用 bullseye 仓库进行更新。 + +注释所有的 buster 仓库,在行的开头加上 `#`。 + +![Comment the Debian 10 lines][5] + +在文件的末尾添加以下几行。 + +``` +deb http://deb.debian.org/debian bullseye main contrib non-free +deb http://deb.debian.org/debian bullseye-updates main contrib non-free +deb http://security.debian.org/debian-security bullseye-security main +deb http://ftp.debian.org/debian bullseye-backports main contrib non-free +``` + +![Add Debian 11 lines][6] + +按 `Ctrl + O` 保存文件,按 `Ctrl + X` 退出 `nano`。 + +更新一次系统仓库列表,以验证仓库的添加情况。 + +``` +sudo apt update +``` + +如果上面的命令没有出现任何错误,那么你已经成功地添加了 bullseye 仓库。 + +现在,通过运行下面的命令开始升级过程。基本安装的下载大小约为 1.2GB。这可能会根据你的系统配置而有所不同。 + +``` +sudo apt full-upgrade +``` + +![Debian upgrade start][7] + +这个命令需要时间。但不要让系统无人看管。因为升级过程中需要各种输入。 + +![lib6 config][8] + +![sudoers file][9] + +完成后,你可以用以下命令重启系统。 + +``` +systemctl reboot +``` + +重启后,运行以下命令,以确保你的系统是最新的,并且清理了所有不再需要的不必要的软件包。 + +``` +sudo apt --purge autoremove +``` + +如果一切顺利,你应该看到了 Debian 11 bullseye。你可以用下面的命令来验证版本: + +``` +cat /etc/os-release +``` + +![Debian 11 after upgrade][10] + +### 结束语 + +我希望这个指南能帮助你将你的系统升级到 Debian 11 bullseye。如果你遇到任何问题,请在下面的评论栏告诉我。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2021/07/upgrade-debian-11-from-debian-10/ + +作者:[Arindam][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lujun9972 +[1]: https://www.debian.org/ +[2]: https://www.debugpoint.com/2021/05/debian-11-features/ +[3]: https://www.debugpoint.com/2020/12/systemd-systemctl-service/ +[4]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/upgrade-debian-system-check-1024x503.jpeg +[5]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/Cpmment-the-Debian-10-lines-1024x636.jpeg +[6]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/Add-Debian-11-lines-1024x635.jpeg +[7]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/Debian-upgrade-start-1024x226.jpeg +[8]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/lib6-config-1024x195.jpeg +[9]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/sudoers-file.jpeg +[10]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/Debian-11-after-upgrade.jpeg \ No newline at end of file diff --git a/published/20210720 Install Shutter in Fedora 34 and Above.md b/published/20210720 Install Shutter in Fedora 34 and Above.md new file mode 100644 index 0000000000..74feecbeaf --- /dev/null +++ b/published/20210720 Install Shutter in Fedora 34 and Above.md @@ -0,0 +1,86 @@ +[#]: subject: (Install Shutter in Fedora 34 and Above) +[#]: via: (https://www.debugpoint.com/2021/07/install-shutter-fedora/) +[#]: author: (Arindam https://www.debugpoint.com/author/admin1/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13641-1.html) + +在 Fedora 34 及以上版本中安装 Shutter +====== + +![](https://img.linux.net.cn/data/attachment/album/202108/01/211059fzo531621ydrr27k.jpg) + +> 这个快速指南解释了在 Fedora 34 及以上版本中安装 Shutter 所需的步骤。 + +截图工具有很多替代和选择。但在我个人看来,没有一个能接近 Shutter 的灵活性。不幸的是,由于各种依赖性问题,特别是它的设计方式,多年来,Linux 发行版,如 Ubuntu、Fedora,都面临着将这个应用打包到官方仓库的问题。 + +主要问题是它仍然基于 GTK2 和 Perl。当大多数应用转移到 GTK3 时,它仍然是 GTK2。这就造成了一个依赖性问题,因为 Debian/Ubuntu、Fedora 删除了某些包的依赖的 GTK2 版本。 + +在 Fedora 34 及以上版本中安装 [Shutter][1] 截图工具需要采用另一种方法。 + +现在,你只能通过个人包存档(PPA)来安装这个工具。下面是如何在 Fedora 34 及以上版本中安装它。 + +![Shutter in Fedora][2] + +### 在 Fedora 34 及以上版本中安装 Shutter + +在你的 Fedora 中打开一个终端,启用以下 [Shutter 的 copr 仓库][3]。这个包存档为 Fedora 的 Shutter 提供了一个单独的构建,其中包含了所有未满足的依赖项。 + +``` +sudo dnf copr enable geraldosimiao/shutter +``` + +完成后,你就可以通过 `dnf` 在 Fedora 34 及以上版本中简单地安装 Shutter。 + +``` +sudo dnf install shutter +``` + +尽管目前最新的版本是 v0.97。遗憾的是,该仓库目前包含旧的 v0.94.x。我希望版本库的所有者尽快包括最新的版本。 + +安装后,你可以通过应用菜单启动它。 + +#### 卸载 Shutter + +如果你愿意,你可以通过命令轻松地删除这个第三方仓库: + +``` +sudo dnf copr remove geraldosimiao/shutter +``` + +然后按照下面的方法,完全删除 Shutter,包括依赖关系。 + +``` +sudo dnf autoremove shutter +``` + +#### 在其他 Linux 发行版中安装 Shutter + +如果你想在 Debian、Ubuntu 或相关发行版中安装它,请 [查看此指南][4]。 + +### Shutter 的开发 + +最近,这个项目 [转移到了 GitHub][6],以便更好地协作,并且正在进行 GTK3 移植。而且它相当活跃,最近还发布了一个版本。我们希望它能尽快被移植到 GTK3 上,并在各发行版的原生仓库中可用。 + +如果你在安装 Shutter 时遇到任何错误,请在评论栏告诉我。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2021/07/install-shutter-fedora/ + +作者:[Arindam][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lujun9972 +[1]: https://www.debugpoint.com/tag/shutter +[2]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/Shutter-in-Fedora.jpeg +[3]: https://copr.fedorainfracloud.org/coprs/geraldosimiao/shutter/ +[4]: https://www.debugpoint.com/2020/04/shutter-install-ubuntu/ +[6]: https://github.com/shutter-project/shutter diff --git a/published/20210723 5 useful ways to manage Kubernetes with kubectl.md b/published/20210723 5 useful ways to manage Kubernetes with kubectl.md new file mode 100644 index 0000000000..0053ec6a0f --- /dev/null +++ b/published/20210723 5 useful ways to manage Kubernetes with kubectl.md @@ -0,0 +1,92 @@ +[#]: subject: (5 useful ways to manage Kubernetes with kubectl) +[#]: via: (https://opensource.com/article/21/7/kubectl) +[#]: author: (Alan Smithee https://opensource.com/users/alansmithee) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (turbokernel) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13676-1.html) + +用 kubectl 管理 Kubernetes 的 5 种有用方法 +====== + +> 学习 kubectl,提升你与 Kubernetes 的互动方式。 + +![Ship captain sailing the Kubernetes seas][1] + +Kubernetes 可以帮你编排运行有大量容器的软件。Kubernetes 不仅提供工具来管理(或者说 [编排][2])运行的容器,还帮助这些容器根据需要进行扩展。有了 Kubernetes 作为你的中央控制面板control panel(或称 控制平面control plane),你需要一种方式来管理 Kubernetes,而这项工作的工具就是 kubectl。`kubectl` 命令让你控制、维护、分析和排查 Kubernetes 集群的故障。与许多使用 `ctl`(“控制”的缩写)后缀的工具一样,如 `systemctl` 和 `sysctl`,`kubectl` 拥有大量的功能和任务权限,所以如果你正在运行 Kubernetes,你肯定会经常使用它。它是一个拥有众多选项的命令,所以下面是 `kubectl` 中简单易用的五个常见任务。 + +### 1、列出并描述资源 + +按照设计,容器往往会成倍增加。在某些条件下,它们可以快速增加。如果你只能通过 `podman ps`或 `docker ps` 来查看正在运行的容器,这可能会让你不知所措。通过 `kubectl get` 和 `kubectl describe`,你可以列出正在运行的吊舱pod以及它们正在处理的容器信息。更重要的是,你可以通过使用 `--namespace` 或 `name` 或 `--selector`等选项,只列出所需信息。 + +`get` 子命令不仅仅对吊舱和容器有用。它也有关于节点、命名空间、发布、服务和副本的信息。 + +### 2、创建资源 + +如果你只通过类似 OpenShift、OKD 或 Kubernetes 提供的 Web 用户界面(UI)创建过发布,但你想从 Linux 终端控制你的集群,那么可以使用 `kubectl create`。`kubectl create` 命令并不只是实例化一个新的应用发布。Kubernetes 中还有很多其他组件可以创建,比如服务、配额和 [计划任务][3]。 + +Kubernetes 中的计划任务可以创建一个临时的吊舱,用来在你选择的时间表上执行一些任务。它们并不难设置。下面是一个计划任务,让一个 BusyBox 镜像每分钟打印 “hello world”。 + +``` +$ kubectl create cronjob \ + hello-world \ + --image=busybox \ + --schedule="*/1 * * * *" -- echo "hello world" +``` + +### 3、编辑文件 + +Kubernetes 中的对象都有相应的配置文件,但在文件系统中查找相应的文件较为麻烦。有了 `kubectl edit`,你可以把注意力放在对象上,而不是定义文件上。你可以通过 `kubectl` 找到并打开文件(通过 `KUBE_EDITOR` 环境变量,你可以设置成你喜欢的编辑器)。 + +``` +$ KUBE_EDITOR=emacs \ + kubectl edit cronjob/hello-world +``` + +### 4、容器之间的传输文件 + +初次接触容器的人往往对无法直接访问的共享系统的概念感到困惑。他们可能会在容器引擎或 `kubectl` 中了解到 `exec` 选项,但当他们不能从容器中提取文件或将文件放入容器中时,容器仍然会显得不透明。使用 `kubectl cp` 命令,你可以把容器当做远程服务器,使主机和容器之间文件传输如 SSH 命令一样简单: + +``` +$ kubectl cp foo my-pod:/tmp +``` + +### 5、应用变更 + +对 Kubernetes 对象进行修改,可以通过 `kubectl apply` 命令完成。你所要做的就是将该命令指向一个配置文件: + +``` +$ kubectl apply -f ./mypod.json +``` + +类似于运行 Ansible 剧本或 Bash 脚本,`apply` 使得快速“导入”设置到运行中的 Kubernetes 实例很容易。例如,GitOps 工具 [ArgoCD][4] 由于 `apply` 子命令,安装起来出奇地简单: + +``` +$ kubectl create namespace argocd +$ kubectl apply -n argocd \ + -f https://raw.githubusercontent.com/argoproj/argo-cd/vx.y.z/manifests/install.yaml +``` + +### 使用 kubectl + +Kubectl 是一个强大的工具,由于它是一个终端命令,它可以写成脚本,并能实现用众多 Web UI 无法实现的功能。学习 `kubectl` 是进一步了解 Kubernetes、容器、吊舱以及围绕这些重要的云计算创新技术的一个好方法。[下载我们的 kubectl 速查表][5],以获得快速参考,其中包括命令示例,以帮助你学习,并在为你提供注意细节。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/kubectl + +作者:[Alan Smithee][a] +选题:[lujun9972][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/alansmithee +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/ship_captain_devops_kubernetes_steer.png?itok=LAHfIpek (Ship captain sailing the Kubernetes seas) +[2]: https://opensource.com/article/20/11/orchestration-vs-automation +[3]: https://opensource.com/article/20/11/kubernetes-jobs-cronjobs +[4]: https://argoproj.github.io/argo-cd/ +[5]: https://opensource.com/downloads/kubectl-cheat-sheet diff --git a/published/20210725 Top 7 Linux Laptops You Can Buy in 2021.md b/published/20210725 Top 7 Linux Laptops You Can Buy in 2021.md new file mode 100644 index 0000000000..80cecb9d70 --- /dev/null +++ b/published/20210725 Top 7 Linux Laptops You Can Buy in 2021.md @@ -0,0 +1,231 @@ +[#]: subject: (Top 7 Linux Laptops You Can Buy in 2021) +[#]: via: (https://news.itsfoss.com/best-linux-laptops-2021/) +[#]: author: (Ankush Das https://news.itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13672-1.html) + +2021 年可以购买的 10 大 Linux 笔记本电脑 +====== + +> 想挑选一台安装有 Linux 的新笔记本电脑?这里有几个选项可以考虑。 + +![](https://news.itsfoss.com/wp-content/uploads/2021/07/linux-laptop.webp) + +Linux 笔记本电脑是 MacOS 和 Windows 笔记本电脑的完美替代品。 + +从技术上讲,你可以通过安装任何你能找到的 Linux 发行版,将你选择的任何笔记本电脑变成一台 Linux 机器。 + +但是,在这里,我们的重点将放在提供 Linux 开箱即用体验的笔记本电脑上,确保无论你有什么样的预算,都能获得最佳的兼容性和支持。 + +### 大众品牌的 Linux 笔记本电脑 + +对于消费者来说,选择由大众品牌制造商生产的 Linux 笔记本电脑往往是最好的选择。 + +你不必担心售后、延长保修期和服务维修等问题。 + +戴尔和联想是通常提供预装了 Linux 的笔记本电脑的厂商之一。 + +请注意,这会因国家/地区的情况而定。 + +*本文中提到的价格已转换为美元,以方便比较,不包括运费和其他额外费用。* + +#### 1、联想 Thinkpad X1 Carbon (第 8 代/第 9 代) + +![][1] + +**价格**:起价为 **$1535** + +联想的整个 Thinkpad 系列是 Linux 用户的一个热门选择。它经久耐用,提供了良好的兼容性。 + +然而,它的价格一直偏高。 + +你有三种选择,这取决于你的需求。如果你定制一台第 9 代 Thinkpad 笔记本电脑,你可以选择安装 Ubuntu 20.04 和 Fedora 33。 + +对于第 8 代机型,似乎 Fedora 33 不在考虑之列,而是提供了 Fedora 32 和 Ubuntu 20.04。 + +所有的配置都采用英特尔芯片组,第 8 代采用的是 10 代芯片组,第 9 代采用 11 代芯片组。 + +其他的大部分规格都相似,有 14 英寸显示屏(FHD、WQHD 和 UHD 可供选择)、高达 32GB 的内存、1TB 固态硬盘、指纹识别器和 Wi-Fi 6 支持。 + +- [Thinkpad X1 Carbon (第 9 代)][2] +- [Thinkpad X1 Carbon (第 8 代)][3] + +#### 2、戴尔 XPS 13 开发者版 + +![][4] + +**价格**:起价为 **$1059** + +戴尔 XPS 系列是一个令人印象深刻的、可以考虑运行 Linux 的笔记本电脑系列。 + +它是为开发者运行 Linux(Ubuntu 20.04)而定制的。 + +你可以得到一个 13.4 英寸的显示屏(有 FHD 和 UHD 可选)、第 11 代 i5/i7 处理器、高达 32GB 的内存、2TB 固态硬盘、指纹识别器,以及 Wi-Fi 6 支持。 + +- [戴尔 XPS 13 开发者版][5] + +### 纯 Linux 制造商的笔记本电脑 + +如果你不想要主流的选择,而是想要一些独特的选择,那你可以选择支持纯 Linux 制造商,有几个是你可以考虑的。 + +#### 1、System76 Gazelle + +![][6] + +**价格**:起价为 **$1499** + +System76 的笔记本电脑将内置他们的 Pop!_OS 操作系统,该系统基于 Ubuntu,但提供了**无忧的开箱即用体验**。 + +可以把 System76 视作 Linux 笔记本电脑中的苹果电脑,他们尽力为其提供的硬件优化了 Pop!_OS。 + +他们可以完全控制这些软件和硬件,所以这对终端消费者来说应该是令人兴奋的产品整合。 + +除了 144Hz 的 16.5 英寸显示屏、第 11 代 i7 处理器、高达 8TB 的 NVMe 固态硬盘支持等令人印象深刻的基本配置外,你还会有一个 RTX 3050 GPU,应该可以让你在笔记本电脑上处理各种苛刻的任务。 + +虽然 System76 还有一些其他型号的笔记本电脑,但在写这篇文章时,还没有上市。因此,请随时查看官方商店页面,订购定制的配置。 + +- [System76 Gazelle][7] + +#### 2、Purism 笔记本电脑 + +![][8] + +**价格**:起价为 **$1599** + +如果你是一个有安全意识的用户,Purism 的笔记本电脑可以作为一个选择。 + +Librem 14 是他们最新的笔记本电脑之一,带有 [PureOS][9](也是由他们制造的)。 + +虽然它可能没有提供最新一代的处理器,但你应该对机上的第 10 代 i7 芯片感到满意吧。 + +它支持高达 64GB 的内存,并具有硬件封禁开关,可以禁用网络摄像头、耳机插孔、蓝牙或无线音频。 + +- [Librem 14][10] + +#### 3、TUXEDO Aura 15 + +![][11] + +**价格**:起价为 **$899** + +如果你想要一台 AMD 的笔记本电脑(采用上一代处理器 Ryzen 7 4700U),TUXEDO 计算机公司的 Aura 15 是一个不错的选择。 + +主要规格包括全高清显示屏、高达 64GB 的内存、支持 Wi-Fi 6,以及一个 LTE 模块。 + +它配备了 Ubuntu 或 TUXEDO 操作系统(基于 Ubuntu Budgie),可根据你的定制要求。 + +- [TUXEDO Aura 15][12] + +#### 4、TUXEDO Stellaris 15 + +![][13] + +**价格**:起价为 **$2160** + +如果你正在寻找最新和最强大的笔记本电脑,并希望用上 RTX 3080 显卡,这应该是一个非常好的选择。 + +它提供了最新的英特尔/AMD Ryzen 处理器的配置选择,并具有 165Hz 刷新率的 3K 分辨率显示屏。 + +它绝不是你会觉得在旅行时带着方便的东西,但如果你需要计算能力,你可以选择它。 + +- [TUXEDO Stellaris 15][21] + +#### 5、Slimbook Pro X + +![][14] + +**价格**:起价为 **$1105** + +Slimbook 专注于旅行方便携带的轻薄笔记本电脑型号。 + +你可以选择各种发行版,包括 Ubuntu(GNOME、KDE、MATE)、KDE Neon、Manjaro 和 Fedora。 + +你可以得到大部分的基本规格,包括支持高达 2TB 的固态硬盘、64GB 的内存、全高清 IPS 显示屏等等。 + +虽然你可以选择英特尔和 AMD Ryzen(最新一代处理器),并分别与 Nvidia 和 Vega 图形处理器相结合,但在写这篇文章时只有 Ryzen 型号有库存。 + +- [Slimbook Pro X][22] + +#### 6、Slimbook Essential + +![][23] + +**价格**:起价为 **$646** + +一个令人印象深刻的预算友好型 Linux 笔记本电脑的选择。 + +它提供了 AMD Ryzen 和英特尔的变体(最后一代)供你选择。你得到硬件规格还可以,包括高达 64GB 的内存、2TB 的 SSD 支持,但是要少一个大的屏幕和板载专用显卡。 + +- [Slimbook Essential][15] + +#### 7、Jupiter 14 Pro + +![][16] + +**价格**:起价为 **$1199** + +Juno 计算机公司的 Jupiter 14 采用了第 11 代英特尔处理器,并配备了 NVIDIA GTX 1650,价格诱人。 + +它内置了 Ubuntu 20.04 系统,没有其他系统可供选择。 + +基本配置包括 16GB 内存,与其他一些产品相比,这可能更物超所值一些。 + +你会发现在他们的网站上可以选择你的地区(英国/欧洲或美国/加拿大),请确保利用这一点。 + +- [Jupiter Pro 14][17] + +#### 荣誉奖:PineBook Pro + +![][18] + +PineBook Pro 是一款基于 ARM 的笔记本电脑(采用 Manjaro ARM 版),预算低廉,对于 Linux 上的很多基本任务来说,应该可以正常工作。 + +在写这篇文章的时候,它已经没有库存了(直到进一步通知)。然而,当你看到这篇文章时,可以自己去看看一下。 + +- [Pinebook Pro][19] + +### 总结 + +如果你不喜欢这里的选择,你可以去看看 [其他可以购买 Linux 笔记本电脑的地方][20]。根据你的预算,选择你觉得最适合你的东西。 + +毕竟,所有的东西都有 Linux 的影子。有些可以让你能够从多个发行版中选择,但大多数人都坚持使用预装的 Ubuntu。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/best-linux-laptops-2021/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/thinkpad-x1-carbon.jpg?w=1060&ssl=1 +[2]: https://www.lenovo.com/us/en/laptops/thinkpad/thinkpad-x1/X1-Carbon-G9/p/22TP2X1X1C9 +[3]: https://www.lenovo.com/us/en/laptops/thinkpad/thinkpad-x1/X1-Carbon-Gen-8-/p/22TP2X1X1C8 +[4]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/dell-xps-13.jpg?w=1200&ssl=1 +[5]: https://www.dell.com/en-us/work/shop/dell-laptops-and-notebooks/new-xps-13-developer-edition/spd/xps-13-9310-laptop/ctox139w10p2c3000u +[6]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/system76-gazelle.jpg?w=1200&ssl=1 +[7]: https://system76.com/laptops/gazelle +[8]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/librem14.png?resize=780%2C780&ssl=1 +[9]: https://www.pureos.net +[10]: https://puri.sm/products/librem-14/ +[11]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/tuxedo-aura-15.jpg?resize=780%2C780&ssl=1 +[12]: https://www.tuxedocomputers.com/en/Linux-Hardware/Linux-Notebooks/15-16-inch/TUXEDO-Aura-15-Gen1.tuxedo +[13]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/tuxedo-stellaris.jpg?resize=780%2C780&ssl=1 +[14]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/slimbook-pro.jpg?resize=1568%2C849&ssl=1 +[15]: https://slimbook.es/en/essential-en +[16]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/jupiter-pro.png?w=1314&ssl=1 +[17]: https://junocomputers.com/us/product/jupiter-14-pro/ +[18]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/pinebook-pro.png?w=869&ssl=1 +[19]: https://www.pine64.org/pinebook-pro/ +[20]: https://itsfoss.com/get-linux-laptops/ +[21]: https://www.tuxedocomputers.com/en/Linux-Hardware/Linux-Notebooks/15-16-inch/TUXEDO-Stellaris-15-Gen3.tuxedo +[22]: https://slimbook.es/en/store/slimbook-pro-x +[23]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/slimbook-essential.jpg?resize=1568%2C882&ssl=1 \ No newline at end of file diff --git a/published/20210726 Command line quick tips- wc, sort, sed and tr.md b/published/20210726 Command line quick tips- wc, sort, sed and tr.md new file mode 100644 index 0000000000..27a875e2a2 --- /dev/null +++ b/published/20210726 Command line quick tips- wc, sort, sed and tr.md @@ -0,0 +1,376 @@ +[#]: subject: (Command line quick tips: wc, sort, sed and tr) +[#]: via: (https://fedoramagazine.org/command-line-quick-tips-wc-sort-sed-and-tr/) +[#]: author: (mahesh1b https://fedoramagazine.org/author/mahesh1b/) +[#]: collector: (lujun9972) +[#]: translator: (perfiffer) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13664-1.html) + +一些命令行小技巧:wc、sort、sed 和 tr +====== + +![](https://img.linux.net.cn/data/attachment/album/202108/10/085720hyd795y1wrmd5rx9.jpg) + +Linux 发行版十分好用,而且它们有一些用户可能不知道的技巧。让我们来看看一些命令行实用工具,当你热衷于终端而不是 GUI 时,它们可能更顺手。 + +我们都知道在一个系统上使用终端会更高效。当你编辑和排版一个文本文件时,终端会让你确切的感受到,生活如此简单。 + +本文将向你介绍 `wc`、`sort`、`tr` 和 `sed` 命令。 + +### wc + +`wc` 是一个实用工具,全称是 “word count”。顾名思义,它可以用来统计任何文件的行数、单词数和字节数。 + +让我们来看看它是如何工作的: + +``` +$ wc filename +lines words characters filename +``` + +输出的是文件的行数、单词数、字符数和文件名。 + +想获得特定的输出,我们必须使用选项: + + * `-c` 打印字节总数 + * `-l` 打印行数 + * `-w` 打印单词总数 + * `-m` 打印字符总数 + +#### wc 示例 + +让我们来看看它的运行结果。 + +让我们从一个文本文件 `lormipsm.txt` 开始。首先,我们通过 `cat` 查看文件内容,然后使用 `wc`: + +``` +$ cat loremipsm.txt +Linux is the best-known and most-used open source operating system. +As an operating system, Linux is software that sits underneath all of the other software on a computer, +receiving requests from those programs and replaying these requests to the computer's hardware. + +$ wc loremipsm.txt +3 41 268 loremipsm.txt +``` + +假设我只想查看文件的字节数: + +``` +$ wc -c loremipsm.txt +268 loremipsm.txt +``` + +查看文件的行数: + +``` +$ wc -l loremipsm.txt +3 loremipsm.txt +``` + +查看文件的单词数: + +``` +$ wc -w loremipsm.txt +41 loremipsm.txt +``` + +现在只查看文件的字符数: + +``` +$ wc -m loremipsm.txt +268 loremipsm.txt +``` + +### sort + +`sort` 命令是最有用的工具之一。它会对文件的数据进行排序。可以根据字符或数字进行升序或降序排列。它也可以用来对文件中的行进行排序和随机化。 + +使用 `sort` 非常简单。我们需要做的仅仅是提供一个文件名: + +``` +$ sort filename +``` + +默认的是按照字母顺序对数据进行排序。需要注意的是 `sort` 命令仅仅是对数据进行排序展示。它并不会改写文件。 + +使用 `sort` 命令的一些有用的选项: + + * `-r` 将文件中的行按倒序进行排序 + * `-R` 将文件中的行打乱为随机顺序 + * `-o` 将输出保存到另一个文件中 + * `-k` 按照特定列进行排序 + * `-t` 使用指定的分隔符,而不使用空格 + * `-n` 根据数值对数据进行排序 + +#### sort 示例 + +让我们看看 `sort` 的几个简单示例。 + +我们有一个 `list.txt` 的文件,包含逗号分隔的名称和数值。 + +首先让我们打印出文件内容并简单排序: + +``` +$ cat list.txt +Cieran Wilks, 9 +Adelina Rowland, 4 +Hayden Mcfarlnd, 1 +Ananya Lamb, 5 +Shyam Head, 2 +Lauryn Fuents, 8 +Kristian Felix, 10 +Ruden Dyer, 3 +Greyson Meyers, 6 +Luther Cooke, 7 + +$ sort list.txt +Adelina Rowland, 4 +Ananya Lamb, 5 +Cieran Wilks, 9 +Greyson Meyers, 6 +Hayden Mcfarlnd, 1 +Kristian Felix, 10 +Lauryn Fuents, 8 +Luther Cooke, 7 +Ruden Dyer, 3 +Shyam Head, 2 +``` + +现在对数据进行倒序排序: + +``` +$ sort -r list.txt +Shyam Head, 2 +Ruden Dyer, 3 +Luther Cooke, 7 +Lauryn Fuents, 8 +Kristian Felix, 10 +Hayden Mcfarlnd, 1 +Greyson Meyers, 6 +Cieran Wilks, 9 +Ananya Lamb, 5 +Adelina Rowland, 4 +``` + +让我们打乱数据: + +``` +$ sort -R list.txt +Cieran Wilks, 9 +Greyson Meyers, 6 +Adelina Rowland, 4 +Kristian Felix, 10 +Luther Cooke, 7 +Ruden Dyer, 3 +Lauryn Fuents, 8 +Hayden Mcfarlnd, 1 +Ananya Lamb, 5 +Shyam Head, 2 +``` + +来看一点更复杂的。这次我们根据第二个字段,也就是数值对数据进行排序,并使用 `-o` 选项将输出保存到另一个文件中: + +``` +$ sort -n -k2 -t ',' -o sorted_list.txt list.txt +$ ls + sorted_list.txt list.txt +$ cat sorted_list.txt +Hayden Mcfarlnd, 1 +Shyam Head, 2 +Ruden Dyer, 3 +Adelina Rowland, 4 +Ananya Lamb, 5 +Greyson Meyers, 6 +Luther Cooke, 7 +Lauryn Fuents, 8 +Cieran Wilks, 9 +Kristian Felix, 10 +``` + +这里我们使用 `-n` 选项按数字顺序进行排序,`-k` 选项用来指定要排序的字段(在本例中为第 2 个字段),`-t` 选项指定分隔符或字段分隔符(逗号),`-o` 选项将输出保存到 `sorted_list.txt` 文件中。 + +### sed + +`sed` 是一个流编辑器,用于过滤和转换输出中的文本。这意味着我们不需要对原文件进行修改,只需要对输出进行修改。如果需要,我们可以将更改保存到一个新的文件中。`sed` 提供了很多有用的选项用于过滤和编辑数据。 + +`sed` 的语法格式如下: + +``` +$ sed [OPTION] ‘PATTERN’ filename +``` + +sed 常用的一些选项: + + * `-n` 取消默认输出 + * `p` 打印指定的数据  + * `d` 删除指定行 + * `q` 退出 `sed` 脚本 + +#### sed 示例 + +我们来看看 `sed` 是如何运作的。我们从 `data` 文件开始,其中的字段表示编号、名称、年龄和操作系统。 + +如果行出现在特定的行范围内,该行将打印 2 次: + +``` +$ cat data +1 Vicky Grant 20 linux +2 Nora Burton 19 Mac +3 Willis Castillo 21 Windows +4 Gilberto Mack 30 Windows +5 Aubrey Hayes 17 windows +6 Allan Snyder 21 mac +7 Freddie Dean 25 linux +8 Ralph Martin 19 linux +9 Mindy Howard 20 Mac + +$ sed '3,7 p' data +1 Vicky Grant 20 linux +2 Nora Burton 19 Mac +3 Willis Castillo 21 Windows +3 Willis Castillo 21 Windows +4 Gilberto Mack 30 Windows +4 Gilberto Mack 30 Windows +5 Aubrey Hayes 17 windows +5 Aubrey Hayes 17 windows +6 Allan Snyder 21 mac +6 Allan Snyder 21 mac +7 Freddie Dean 25 linux +7 Freddie Dean 25 linux +8 Ralph Martin 19 linux +9 Mindy Howard 20 Mac +``` + +这里的操作用单引号括起来,表示第 3 行和第 7 行,并且使用了 `p` 打印出符合匹配规则的数据。sed 的默认行为是在解析后打印每一行。这意味着由于使用了 `p` ,第 3 行到第 7 行打印了两次。 + +如何打印文件中特定的行?使用 `-n` 选项来消除在输出中不匹配的行: + +``` +$ sed -n '3,7 p' data +3 Willis Castillo 21 Windows +4 Gilberto Mack 30 Windows +5 Aubrey Hayes 17 windows +6 Allan Snyder 21 mac +7 Freddie Dean 25 linux +``` + +使用 ‘-n’ 仅仅只有第 3 行到第 7 行会被打印。 + +省略文件中的特定行。使用 `d` 从输出中删除行: + +``` +$ sed '3 d' data +1 Vicky Grant 20 linux +2 Nora Burton 19 Mac +4 Gilberto Mack 30 Windows +5 Aubrey Hayes 17 windows +6 Allan Snyder 21 mac +7 Freddie Dean 25 linux +8 Ralph Martin 19 linux +9 Mindy Howard 20 Mac + +$ sed '5,9 d' data +1 Vicky Grant 20 linux +2 Nora Burton 19 Mac +3 Willis Castillo 21 Windows +4 Gilberto Mack 30 Windows +``` + +从文件中搜索特定的关键字: + +``` +$ sed -n '/linux/ p' data +7 Freddie Dean 25 linux +8 Ralph Martin 19 linux + +$ sed -n '/linux/I p' data +1 Vicky Grant 20 Linux +7 Freddie Dean 25 linux +8 Ralph Martin 19 linux +``` + +在这些例子中,我们在 `/ /` 中使用了一个正则表达式。如果文件中有类似的单词,但大小写不一致,可以使用 `I` 使得搜索不区分大小写。回想一下,`-n` 删除了输出中不匹配的行。 + +替换文件中的单词: + +``` +$ sed 's/linux/linus/' data +1 Vicky Grant 20 Linux +2 Nora Burton 19 Mac +3 Willis Castillo 21 Windows +4 Gilberto Mack 30 Windows +5 Aubrey Hayes 17 windows +6 Allan Snyder 21 mac +7 Freddie Dean 25 linus +8 Ralph Martin 19 linus +9 Mindy Howard 20 Mac +``` + +这里 `s/ / /` 表示它是一个正则表达式。在两个 `/` 之间的就是定位的单词和需要替换的新单词。 + +### tr + +`tr` 命令可以用来转换或删除字符。它可以将小写字母转换为大写字母,也可以将大写字母转换为小写字母,可以消除重复字符,也可以删除特定字符。 + +`tr` 的奇怪之处在于,它不同于 `wc`、`sort`、`sed` 那样接受文件作为输入。我们使用 `|` (管道符)为 `tr` 命令提供输入。 + +``` +$ cat filename | tr [OPTION] +``` + +`tr` 命令使用的一些选项: + + * `-d` 删除给定输入第一个集合中的指定字符,不做转换 + * `-s` 将重复出现的字符替换为单个 + +#### tr 示例 + +现在让我们使用 `tr` 命令将 `letter` 文件中的所有小写字符转换为大写字符: + +``` +$ cat letter +Linux is too easy to learn, +And you should try it too. + +$ cat letter | tr 'a-z' 'A-Z' +LINUX IS TOO EASY TO LEARN, +AND YOU SHOULD TRY IT TOO. +``` + +这里的 `a-z`、`A-Z` 表示我们想要将 `a` 到 `z` 范围内的小写字符转换为大写字符。 + +删除文件中的 `o` 字符: + +``` +$ cat letter | tr -d 'o' +Linux is t easy t learn, +And yu shuld try it t. +``` + +从文件中压缩字符 `o` 意味着如果 `o` 在文件中重复出现,那么它将会被删除并且只打印一次: + +``` +$ cat letter | tr -s 'o' +Linux is to easy to learn, +And you should try it to. +``` + +### 总结 + +这是使用 `wc`、`sort`、`sed`、`tr` 命令的快速演示。这些命令可以方便快捷的操作终端上的文本文件。你可以使用 `man` 命令来了解这些命令的更多信息。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/command-line-quick-tips-wc-sort-sed-and-tr/ + +作者:[mahesh1b][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://fedoramagazine.org/author/mahesh1b/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2018/10/commandlinequicktips-816x345.jpg diff --git a/published/20210726 How to Install elementary Tweaks Tool.md b/published/20210726 How to Install elementary Tweaks Tool.md new file mode 100644 index 0000000000..31bb5406a1 --- /dev/null +++ b/published/20210726 How to Install elementary Tweaks Tool.md @@ -0,0 +1,80 @@ +[#]: subject: (How to Install elementary Tweaks Tool) +[#]: via: (https://www.debugpoint.com/2021/07/elementary-tweaks-install/) +[#]: author: (Arindam https://www.debugpoint.com/author/admin1/) +[#]: collector: (lujun9972) +[#]: translator: (imgradeone) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13665-1.html) + +如何安装 elementary 优化工具 +====== + +> 这篇快速教程演示了如何安装 elementary / Pantheon 优化工具。 + +![](https://img.linux.net.cn/data/attachment/album/202108/10/092914jj9gzejjglclu160.jpg) + +elementary 优化工具elementary Tweaks Tool是专为 [elementary OS][1] 设计的实用工具。它提供了一些用于修改 elementary 设置的选项。虽然 elementary 已经提供了绝大多数选项,但还有一小部分的 Pantheon 桌面优化是不能直接通过普通设置修改的,因此这个工具才得以诞生。这个工具与 GNOME 中的 [GNOME Tweaks][2] 有些相似。 + +也就是说,安装这个工具其实十分简单,只是 [elementary OS 6 Odin][3] 与早期版本(例如 elementary OS 5 Juno)存在一些区别。从 elementary OS 6 Odin 开始,这个工具已经重命名为 Pantheon 优化工具Pantheon Tweaks Tool。下面是安装步骤。 + +### 安装 elementary 优化工具 + +elementary OS 并没有内置用于添加 PPA 的 `software-properties-common` 软件包。如果你还没有安装此软件包,请使用如下命令安装: + +``` +sudo apt install software-properties-common +``` + +#### elementary OS 6 Odin + +该版本的优化工具已经改名,并且独立于原版开发。它的名称是 [Pantheon Tweaks][4]。你可以使用如下命令安装它。 + +``` +sudo add-apt-repository -y ppa:philip.scott/pantheon-tweaks +sudo apt install -y pantheon-tweaks +``` + +#### elementary OS 5 Juno 及更旧版本 + +如果你正在使用 elementary OS 5 Juno 或者更旧的版本,你可以使用同一 PPA 安装早期版本的 [elementary-tweaks][5]。在终端输入以下命令即可安装。 + +``` +sudo add-apt-repository -y ppa:philip.scott/elementary-tweaks +sudo apt install -y elementary-tweaks +``` + +### 使用方法 + +安装完成后,你可以在 “应用程序菜单 > 系统设置 > 优化” 中使用此工具。 + +![设置中的 Tweaks(优化)选项][6] + +在“优化”窗口,你可以修改一些选项,配置你的 elementary 桌面。 + +![安装完成后的 elementary 优化工具 —— 选项][7] + +顺便提示一下,这款工具仅仅是 elementary 桌面设置的前端。如果你知道准确的名称或属性,你可以直接在终端中修改配置。你在这款优化工具中获得的选项也可以在 `dconf` 编辑器中查找 `io.elementary` 路径以修改。 + +如果你在安装或使用优化工具时遇到了一些问题,你可以在评论区留言。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2021/07/elementary-tweaks-install/ + +作者:[Arindam][a] +选题:[lujun9972][b] +译者:[imgradeone](https://github.com/imgradeone) +校对:[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/lujun9972 +[1]: https://www.debugpoint.com/tag/elementary +[2]: https://www.debugpoint.com/2018/05/customize-your-ubuntu-desktop-using-gnome-tweak/ +[3]: https://www.debugpoint.com/2020/09/elementary-os-6-odin-new-features-release-date/ +[4]: https://github.com/pantheon-tweaks/pantheon-tweaks +[5]: https://github.com/elementary-tweaks/elementary-tweaks +[6]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/tweak-in-settings.png +[7]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/elementary-tweaks-after-install-options.png diff --git a/published/20210726 How to use cron on Linux.md b/published/20210726 How to use cron on Linux.md new file mode 100644 index 0000000000..1f1d9ffedb --- /dev/null +++ b/published/20210726 How to use cron on Linux.md @@ -0,0 +1,99 @@ +[#]: subject: (How to use cron on Linux) +[#]: via: (https://opensource.com/article/21/7/cron-linux) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: (perfiffer) +[#]: reviewer: (turbokernel) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13644-1.html) + +如何在 Linux 上使用 cron 定时器 +====== + +> cron 定时器是一个可以按照计划自动运行命令的工具。 + +![](https://img.linux.net.cn/data/attachment/album/202108/03/132733qhmt6mavtbh66m5j.jpg) + +cron 定时器是一个可以按照计划自动运行命令的工具。定时器作业称为 cronjob,创建于 `crontab` 文件中。这是用户自动操作电脑的最简单也是最古老的方法。 + +### 创建一个 cronjob + +要创建一个 cronjob,你可以使用 `crontab` 命令,并添加 `-e` 选项: + +``` +$ crontab -e +``` + +这将使用默认的文本编辑器打开 `crontab`。如需指定文本编辑器,请使用 `EDITOR` [环境变量][1]: + +``` +$ EDITOR=nano crontab -e +``` + +### Cron 语法 + +如需调度一个 cronjob,你需要提供给计算机你想要执行的命令,然后提供一个 cron 表达式。cron 表达式在命令调度时运行: + + * 分钟(0 到 59) + * 小时(0 到 23, 0 代表午夜执行) + * 日期(1 到 31) + * 月份(1 到 12) + * 星期(0 到 6, 星期天是 0) + +星号 (`*`) 代表的是“每一个”。例如,下面的表达式在每月每日每小时的 0 分钟运行备份脚本: + +``` +/opt/backup.sh 0 * * * * +``` + +下面的表达式在周日的凌晨 3:30 运行备份脚本: + +``` +/opt/backup.sh 30 3 * * 0 +``` + +### 简写语法 + +现代的 cron 支持简化的宏,而不是 cron 表达式: + + * `@hourly` 在每天的每小时的 0 分运行 + * `@daily` 在每天的 0 时 0 分运行 + * `@weekly` 在周日的 0 时 0 分运行 + * `@monthly` 在每月的第一天的 0 时 0 分运行 + +例如,下面的 `crontab` 命令在每天的 0 时运行备份脚本: + +``` +/opt/backup.sh @daily +``` + +### 如何停止一个 cronjob + +一旦你开始了一个 cronjob,它就会永远按照计划运行。想要在启动后停止 cronjob,你必须编辑 `crontab`,删除触发该作业的命令行,然后保存文件。 + +``` +$ EDITOR=nano crontab -e +``` + +如需停止一个正在运行的作业,可以 [使用标准的 Linux 进程命令][3] 来停止一个正在运行的进程。 + +### 它是自动的 + +一旦你编写完 `crontab`,保存了文件并且退出了编辑器。你的 cronjob 就已经被调度了,剩下的工作都交给 cron 完成。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/cron-linux + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[perfiffer](https://github.com/perfiffer) +校对:[turbokernel](https://github.com/turbokernel) + +本文由 [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/cron-splash.png?itok=AoBigzts (Cron expression) +[2]: https://opensource.com/article/19/8/what-are-environment-variables +[3]: https://opensource.com/article/18/5/how-kill-process-stop-program-linux diff --git a/published/20210727 Check used disk space on Linux with du.md b/published/20210727 Check used disk space on Linux with du.md new file mode 100644 index 0000000000..878fafc648 --- /dev/null +++ b/published/20210727 Check used disk space on Linux with du.md @@ -0,0 +1,105 @@ +[#]: subject: (Check used disk space on Linux with du) +[#]: via: (https://opensource.com/article/21/7/check-disk-space-linux-du) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (turbokernel) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13656-1.html) + +使用 du 检查 Linux 上已用的磁盘空间 +====== + +> 用 Linux 的 du 命令了解你正在使用多少磁盘空间。 + +![](https://img.linux.net.cn/data/attachment/album/202108/06/200731j561cwxyxyekaic5.jpg) + +无论你有多少存储空间,它总有可能被填满。在大多数个人设备上,磁盘被照片、视频和音乐填满,但在服务器上,由于用户账户和日志文件数据,空间减少是很正常的。无论你是负责管理一个多用户系统,还是只负责自己的笔记本电脑,你都可以用 `du` 命令检查磁盘的使用情况。 + +默认情况下,`du` 列出了当前目录中使用的磁盘空间,以及每个子目录的大小。 + +``` +$ du +12 ./.backups +60 . +``` + +在这个例子中,当前目录总共占用了 60KB,其中 12KB 被子目录 `.backups` 占用。 + +如果你觉得这很混乱,并希望分别看到所有的大小,你可以使用 `--separate-dirs`(或简写 `-S`)选项: + +``` +$ du --separate-dirs +12 ./.backups +48 . +``` + +显示相同的信息(48KB 加 12KB 是 60KB),但每个目录被独立处理。 + +如需看到更多的细节,可以使用 `--all`(简写 `-a`)选项,它显示每个目录中以及每个文件: + +``` +$ du --separate-dirs --all +4 ./example.adoc +28 ./graphic.png +4 ./.backups/example.adoc~ +12 ./.backups +4 ./index.html +4 ./index.adoc +48 . +``` + +### 查看文件的修改时间 + +当查看文件以找出占用空间的内容时,查看文件最后一次被修改的时间是很有用的。一年内没有使用过的文件可以考虑归档,特别是当你的空间快用完时。 + +通过 `du` 查看文件的修改时间,使用 `--time` 选项: + +``` +$ du --separate-dirs --all --time +28 2021-07-21 11:12 ./graphic.png +4 2021-07-03 10:43 ./example.adoc +4 2021-07-13 13:03 ./index.html +4 2021-07-23 14:18 ./index.adoc +48 2021-07-23 14:19 . +``` + +### 为文件大小设置一个阈值 + +当为了磁盘空间而查看文件时,你可能只关心较大的文件。你可以通过 `--threshold`(简写 `-t`)选项为文件大小设置一个阈值。例如,只查看大于 1GB 的文件: + +``` +$ \du --separate-dirs --all --time --threshold=1G ~/Footage/ +1839008 2021-07-14 13:55 /home/tux/Footage/snowfall.mp4 +1577980 2020-04-11 13:10 /home/tux/Footage/waterfall.mp4 +8588936 2021-07-14 13:55 /home/tux/Footage/ +``` + +当文件较大时,它们可能难以阅读。使用 `--human-readable`(简写 `-h`)选项可以使文件大小更容易阅读: + +``` +$ du --separate-dirs --all --time --threshold=1G --human-readable ~/Footage/ +1.8G 2021-07-14 13:55 /home/tux/Footage/snowfall.mp4 +1.6G 2020-04-11 13:10 /home/tux/Footage/waterfall.mp4 +8.5G 2021-07-14 13:55 /home/tux/Footage/ +``` + +### 查看可用磁盘空间 + +如需获得一个驱动器上可用磁盘空间的摘要,请阅读我们关于 [df 命令][2]的文章。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/check-disk-space-linux-du + +作者:[Seth Kenlon][a] +选题:[lujun9972][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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/du-splash.png?itok=nRLlI-5A (Check disk usage) +[2]: https://opensource.com/article/21/7/use-df-check-free-disk-space-linux diff --git a/published/20210727 How to Change Lock and Login Screen Wallpaper in elementary OS.md b/published/20210727 How to Change Lock and Login Screen Wallpaper in elementary OS.md new file mode 100644 index 0000000000..095675b20f --- /dev/null +++ b/published/20210727 How to Change Lock and Login Screen Wallpaper in elementary OS.md @@ -0,0 +1,119 @@ +[#]: subject: (How to Change Lock and Login Screen Wallpaper in elementary OS) +[#]: via: (https://www.debugpoint.com/2021/07/change-lock-login-screen-background-elementary-os/) +[#]: author: (Arindam https://www.debugpoint.com/author/admin1/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13655-1.html) + +如何在 elementary OS 中改变锁定和登录屏幕的壁纸 +====== + +> 本教程解释了在 elementary OS 中改变锁定和登录屏幕背景的步骤。这将取代默认的灰色背景。 + +在 elementary OS 中改变锁屏或登录屏背景的灰色默认壁纸是有点困难的。典型的用图像文件的路径改变 `greeter` 的配置是行不通的。 + +不幸的是,这不是一个更简单的解决方案,因为灰色背景是一个图像文件,它的数据是硬编码在 `greeter` 中的,需要用新的图像重新编译才能使其发挥作用。 + +下面是方法: + +![Lock / Login screen background elementary OS \(Odin\)][1] + +### 改变 elementary OS 锁定和登录屏幕背景 + +在 elementary OS 中打开一个终端。 + +为 [greeter 包][2]安装 git 和以下依赖项: + +``` +sudo apt install git +``` + +``` +sudo apt install -y gnome-settings-daemon libaccountsservice-dev libgdk-pixbuf2.0-dev libgranite-dev libgtk-3-dev libhandy-1-dev liblightdm-gobject-1-dev libmutter-6-dev libwingpanel-dev libx11-dev meson valac +``` + +进入临时的 `/tmp` 目录,从 GitHub 克隆最新的 greeter 主分支: + +``` +cd /tmp +git clone https://github.com/elementary/greeter.git +``` + +克隆完成后,在文件管理器中打开路径 `/tmp/greeter/data`。 + +elementary OS 使用一个 100×100px 的 PNG 文件作为登录屏幕/锁屏的默认背景。该图像是平铺的,给人一种灰色背景的感觉。 + +用 `texture.png` 重命名你想要的墙纸图像,并在路径中覆盖以下文件: + +![gray background is created using this file][3] + +``` +/tmp/greeter/data/texture.png +``` + +在文本编辑器中打开文件 `/tmp/greeter/compositor/SystemBackground.vala`,并替换下面一行: + +![change the path of image][4] + +``` +resource:///io/elementary/desktop/gala/texture.png +``` + +为: + +``` +resource:///io/elementary/greeter/texture.png +``` + +保存该文件。 + + +再次打开终端,使用以下命令构建 `greeter`。 + +``` +cd /tmp/greeter +meson _build --prefix=/usr +sudo ninja install -C _build +``` + +![building greeter][5] + +如果你遇到任何构建错误,请在下面的评论中告诉我。你应该不会看到任何错误,因为我已经测试过了。 + +上面的命令完成后,你可以在测试模式下运行 `lightdm` 来测试登录屏: + +``` +lightdm --test-mode --debug +``` + +如果看起来不错,重新启动系统。而你应该在 elementary OS 的登录屏上看到你的墙纸。 + +这个指南应该可在 [elementary OS 6 Odin][7]、elementary OS 5 Juno 及以下版本中可用。 + +### 结束语 + +我希望本指南能帮助你在 elementary OS 中改变锁屏或登录屏的背景。老实说,在 2021 年改变登录屏的背景图像需要编译代码,这让我很吃惊。 + +如果你遇到错误,请在下面的评论栏里告诉我。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2021/07/change-lock-login-screen-background-elementary-os/ + +作者:[Arindam][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lujun9972 +[1]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/elementary-OS-Login-Screen-in-Odin-1024x768.jpg +[2]: https://github.com/elementary/greeter +[3]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/gray-background-is-created-using-this-file.jpg +[4]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/change-the-path-of-image-1024x450.jpg +[5]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/building-greeter.png +[7]: https://www.debugpoint.com/tag/elementary-os-6 diff --git a/published/20210729 Use df to check free disk space on Linux.md b/published/20210729 Use df to check free disk space on Linux.md new file mode 100644 index 0000000000..c6e86fc125 --- /dev/null +++ b/published/20210729 Use df to check free disk space on Linux.md @@ -0,0 +1,84 @@ +[#]: subject: (Use df to check free disk space on Linux) +[#]: via: (https://opensource.com/article/21/7/check-disk-space-linux-df) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: (piaoshi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13646-1.html) + +使用 df 命令查看 Linux 上的可用磁盘空间 +====== + +> 利用 df 命令查看 Linux 磁盘还剩多少空间。 + +![](https://img.linux.net.cn/data/attachment/album/202108/04/110742netskjccb5vzvujk.jpg) + +磁盘空间已经不像计算机早期那样珍贵,但无论你有多少磁盘空间,总有耗尽的可能。计算机需要一些磁盘空间才能启动运行,所以为了确保你没有在无意间用尽了所有的硬盘空间,偶尔检查一下是非常必要的。在 Linux 终端,你可以用 `df` 命令来做这件事。 + +`df` 命令可以显示文件系统中可用的磁盘空间。 + +要想使输出结果易于阅读,你可以加上 `--human-readable`(或其简写 `-h`)选项: + +``` +$ df --human-readable +Filesystem      Size  Used Avail Use% Mounted on +/dev/sda1       1.0T  525G  500G  52% / +``` + +在这个例子中,计算机的磁盘已经用了 52%,还有 500 GB 可用空间。 + +由于 Linux 从整体上看待所有挂载设备的文件系统,`df` 命令会展示出连接到计算机上的每个存储设备的详细信息。如果你有很多磁盘,那么输出结果将会反映出来: + +``` +$ df --human-readable +Filesystem      Size  Used Avail Use% Mounted on +/dev/root       110G   45G   61G  43% / +devtmpfs         12G     0   12G   0% /dev +tmpfs            12G  848K   12G   1% /run +/dev/sda1       1.6T  1.3T  191G  87% /home +/dev/sdb1       917G  184G  687G  22% /penguin +/dev/sdc1        57G   50G  4.5G  92% /sneaker +/dev/sdd1       3.7T  2.4T  1.3T  65% /tux +``` + +在这个例子中,计算机的 `/home` 目录已经用了 87%,剩下 191 GB 的可用空间。 + +### 查看总的可用磁盘空间 + +如果你的文件系统确实很复杂,而你希望看到所有磁盘的总空间,可以使用 `--total` 选项: + +``` +$ df --human-readable --total +Filesystem      Size  Used Avail Use% Mounted on +/dev/root       110G   45G   61G  43% / +devtmpfs         12G     0   12G   0% /dev +tmpfs            12G  848K   12G   1% /run +/dev/sda1       1.6T  1.3T  191G  87% /home +/dev/sdb1       917G  184G  687G  22% /penguin +/dev/sdc1        57G   50G  4.5G  92% /sneaker +/dev/sdd1       3.7T  2.4T  1.3T  65% /tux +total           6.6T  4.0T  2.5T  62% - +``` + +输出的最后一行展示了文件系统的总空间、已用总空间、可用总空间。 + +### 查看磁盘空间使用情况 + +如果你想大概了解哪些文件占用了磁盘空间,请阅读我们关于 [du 命令][2] 的文章。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/check-disk-space-linux-df + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[piaoshi](https://github.com/piaoshi) +校对:[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/df-splash.png?itok=AGXQm737 (Free disk space) +[2]: https://opensource.com/article/21/7/check-used-disk-space-linux-du diff --git a/published/20210730 4 cool new projects to try in Copr from July 2021.md b/published/20210730 4 cool new projects to try in Copr from July 2021.md new file mode 100644 index 0000000000..914cf2f52c --- /dev/null +++ b/published/20210730 4 cool new projects to try in Copr from July 2021.md @@ -0,0 +1,155 @@ +[#]: subject: (4 cool new projects to try in Copr from July 2021) +[#]: via: (https://fedoramagazine.org/4-cool-new-projects-to-try-in-copr-for-july-2021/) +[#]: author: (Jakub Kadlčík https://fedoramagazine.org/author/frostyx/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13673-1.html) + +COPR 仓库中 4 个很酷的新项目(2021.07) +====== + +![][1] + +COPR 是个人软件仓库 [集合][2],它不在 Fedora 中。这是因为某些软件不符合轻松打包的标准;或者它可能不符合其他 Fedora 标准,尽管它是自由而开源的。COPR 可以在 Fedora 套件之外提供这些项目。COPR 中的软件不受 Fedora 基础设施的支持,或者是由项目自己背书的。但是,这是一种尝试新的或实验性的软件的一种巧妙的方式。 + +本文介绍了 COPR 中一些有趣的新项目。如果你第一次使用 COPR,请参阅 [COPR 用户文档][3]。 + +### Wike + +[Wike][5] 是一个用于 GNOME 桌面的维基百科阅读器,在 GNOME Shell 中集成了搜索功能。它提供了对 [在线百科全书][6] 的无干扰访问。它的界面很简约,但它支持在多种语言之间切换文章、书签、文章目录、黑暗模式等。 + +![][7] + +#### 安装说明 + +该 [仓库][9] 目前为 Fedora 33、34 和 Fedora Rawhide 提供了 Wike。要安装它,请使用这些命令: + +``` +sudo dnf copr enable xfgusta/wike +sudo dnf install wike +``` + +### DroidCam + +我们正生活在一个混乱的时代,被隔离在家中,我们与朋友和同事的大部分互动都发生在一些视频会议平台上。如果你已经有一部手机,就不要把钱浪费在价格过高的网络摄像头上。[DroidCam][11] 让你将手机与电脑配对,并将其作为专用网络摄像头使用。通过 USB 线或通过 WiFi 进行连接。DroidCam 提供对摄像头的远程控制,并允许缩放、使用自动对焦、切换 LED 灯和其他便利功能。 + +![][12] + +#### 安装说明 + +该 [仓库][14] 目前为 Fedora 33 和 34 提供了 DroidCam。在安装之前,请更新你的系统并重新启动,或者确保你运行的是最新的内核版本,并安装了适当版本的 `kernel-headers`。 + +``` +sudo dnf update +sudo reboot +``` + +Droidcam 依赖 `v4l2loopback`,必须从 [RPM Fusion 自由软件仓库][15] 手动安装。 + +``` +sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm +sudo dnf install v4l2loopback +sudo modprobe v4l2loopback +``` + +现在安装 `droidcam` 软件包: + +``` +sudo dnf copr enable meeuw/droidcam +sudo dnf install droidcam +``` + +### Nyxt + +[Nyxt][17] 是一个面向键盘、可无限扩展的 Web 浏览器,专为高级用户设计。它在很大程度上受到 Emacs 的启发,因此用 Common Lisp 实现和配置,提供熟悉的按键绑定([Emacs][18]、[vi][19]、[CUA][20])。 + +其他不能错过的杀手锏是一个内置的 REPL、[树形历史][21]、[缓冲区代替标签][22],还有[更多][17]。 + +Nyxt 与网络引擎无关,所以不用担心页面会以意外的方式呈现。 + +![][23] + +#### 安装说明 + +该 [仓库][25] 目前为 Fedora 33、34 和 Fedora Rawhide 提供了 Nyxt。要安装它,请使用这些命令: + +``` +sudo dnf copr enable teervo/nyxt +sudo dnf install nyxt +``` + +### Bottom + +[Bottom][27] 是一个具有可定制界面和多种功能的系统监控器,它从 [gtop][28]、[gotop][29] 和 [htop][30] 获得了灵感。因此,它支持 [进程][31] 监控、[CPU][32]、[RAM][33] 和 [网络][34] 使用监控。除了这些,它还提供了更多奇特的小部件,如 [磁盘容量][35] 使用情况,[温度传感器][36],和 [电池][37] 使用情况。 + +由于小部件的可自定义布局以及 [可以只关注一个小部件并最大化它][38],Bottom 可以非常有效地利用屏幕空间。 + +![][39] + +#### 安装说明 + +该 [仓库][41] 为 Fedora 33、34 和 Fedora Rawhide 提供了 Bottom。它也可用于 EPEL 7 和 8。要安装它,请使用这些命令: + +``` +sudo dnf copr enable opuk/bottom +sudo dnf install bottom +``` + +使用 `btm` 命令来运行该程序。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/4-cool-new-projects-to-try-in-copr-for-july-2021/ + +作者:[Jakub Kadlčík][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/frostyx/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2017/08/4-copr-945x400.jpg +[2]: https://copr.fedorainfracloud.org/ +[3]: https://docs.pagure.org/copr.copr/user_documentation.html +[4]: https://github.com/FrostyX/fedora-magazine/blob/main/2021-july.md#wike +[5]: https://github.com/hugolabe/Wike +[6]: https://en.wikipedia.org/wiki/Main_Page +[7]: https://fedoramagazine.org/wp-content/uploads/2021/07/wike.png +[8]: https://github.com/FrostyX/fedora-magazine/blob/main/2021-july.md#installation-instructions +[9]: https://copr.fedorainfracloud.org/coprs/xfgusta/wike/ +[10]: https://github.com/FrostyX/fedora-magazine/blob/main/2021-july.md#droidcam +[11]: https://www.dev47apps.com/ +[12]: https://fedoramagazine.org/wp-content/uploads/2021/07/droidcam.png +[13]: https://github.com/FrostyX/fedora-magazine/blob/main/2021-july.md#installation-instructions-1 +[14]: https://copr.fedorainfracloud.org/coprs/meeuw/droidcam +[15]: https://docs.fedoraproject.org/en-US/quick-docs/setup_rpmfusion/#proc_enabling-the-rpmfusion-repositories-using-command-line-utilities_enabling-the-rpmfusion-repositories +[16]: https://github.com/FrostyX/fedora-magazine/blob/main/2021-july.md#nyxt +[17]: https://nyxt.atlas.engineer/ +[18]: https://en.wikipedia.org/wiki/Emacs +[19]: https://en.wikipedia.org/wiki/Vim_(text_editor) +[20]: https://en.wikipedia.org/wiki/IBM_Common_User_Access +[21]: https://nyxt.atlas.engineer/#tree +[22]: https://nyxt.atlas.engineer/#fuzzy +[23]: https://fedoramagazine.org/wp-content/uploads/2021/07/nyxt.png +[24]: https://github.com/FrostyX/fedora-magazine/blob/main/2021-july.md#installation-instructions-2 +[25]: https://copr.fedorainfracloud.org/coprs/teervo/nyxt/ +[26]: https://github.com/FrostyX/fedora-magazine/blob/main/2021-july.md#bottom +[27]: https://github.com/ClementTsang/bottom +[28]: https://github.com/aksakalli/gtop +[29]: https://github.com/xxxserxxx/gotop +[30]: https://github.com/htop-dev/htop/ +[31]: https://clementtsang.github.io/bottom/nightly/usage/widgets/process/ +[32]: https://clementtsang.github.io/bottom/nightly/usage/widgets/cpu/ +[33]: https://clementtsang.github.io/bottom/nightly/usage/widgets/memory/ +[34]: https://clementtsang.github.io/bottom/nightly/usage/widgets/network/ +[35]: https://clementtsang.github.io/bottom/nightly/usage/widgets/disk/ +[36]: https://clementtsang.github.io/bottom/nightly/usage/widgets/temperature/ +[37]: https://clementtsang.github.io/bottom/nightly/usage/widgets/battery/ +[38]: https://clementtsang.github.io/bottom/nightly/usage/general-usage/#expansion +[39]: https://fedoramagazine.org/wp-content/uploads/2021/07/bottom.png +[40]: https://github.com/FrostyX/fedora-magazine/blob/main/2021-july.md#installation-instructions-3 +[41]: https://copr.fedorainfracloud.org/coprs/opuk/bottom/ diff --git a/published/20210801 Use the Linux terminal to see what files are on your computer.md b/published/20210801 Use the Linux terminal to see what files are on your computer.md new file mode 100644 index 0000000000..a9dbcf3625 --- /dev/null +++ b/published/20210801 Use the Linux terminal to see what files are on your computer.md @@ -0,0 +1,78 @@ +[#]: subject: (Use the Linux terminal to see what files are on your computer) +[#]: via: (https://opensource.com/article/21/8/linux-list-files) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: (piaoshi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13669-1.html) + +使用 Linux 终端查看你的电脑上有哪些文件 +====== + +> 通过这个 Linux 教程学习如何使用 ls 命令在终端中列出文件。 + +![](https://img.linux.net.cn/data/attachment/album/202108/11/142450etebpqtp7bl4kupt.jpg) + +要在有图形界面的计算机上列出文件,你通常可以打开一个文件管理器(Linux 上的 “文件”,MacOS 上的 “访达”,Windows 上的 “文件资源管理器”)来查看文件。 + +要在终端中列出文件,你可以使用 `ls` 命令来列出当前目录中的所有文件。而 `pwd` 命令可以告诉你当前所在的目录: + +``` +$ pwd +/home/tux +$ ls +example.txt +Documents +Downloads +Music +Pictures +Templates +Videos +``` + +你可以通过 `--all`(简写为 `-a`) 选项看到隐藏文件: + +``` +$ pwd +/home/tux +$ ls --all +.               Downloads +..              .local +.bashrc         Music +.config         Pictures +example.txt     Templates +Documents       Videos +``` + +如你所见,列出的前两项是点。单个点(`.`)实际上是一个元位置,代表 _你当前所在的文件夹_ 。两个点(`..`)表示你可以从当前位置返回的上级目录。也就是说,当前目录在另一个文件夹中。当你在计算机目录间移动时,你就可以利用这些元位置为自己创建快捷方式,或者增加你的路径的独特性。 + +### 文件和文件夹以及如何区分它们 + +你可能会注意到,文件和文件夹是很难区分的。一些 Linux 发行版有一些漂亮的颜色设置,比如所有的文件夹都是蓝色的,文件是白色的,二进制文件是粉色或绿色的,等等。如果你没有看到这些颜色,你可以试试 `ls --color`。如果你有色盲症或者使用的不是彩色显示器,你可以使用 `--classify` 选项替代: + +``` +$ pwd +/home/tux/Downloads +$ ls --classify +android-info.txt +cheat/ +test-script.sh* +``` + +你会发现,文件夹末尾加了一个斜杠(`/`),以表示它们是文件系统中的某一级目录。而二进制文件,如压缩文件和可执行程序,用星号(`*`)标记。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/8/linux-list-files + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[piaoshi](https://github.com/piaoshi) +校对:[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/ch01.svg__0.png?itok=98wPcbAc (List files on your computer) diff --git a/published/20210803 GNOME Web Canary is Now Available to Test Bleeding Edge Features.md b/published/20210803 GNOME Web Canary is Now Available to Test Bleeding Edge Features.md new file mode 100644 index 0000000000..497171d122 --- /dev/null +++ b/published/20210803 GNOME Web Canary is Now Available to Test Bleeding Edge Features.md @@ -0,0 +1,76 @@ +[#]: subject: (GNOME Web Canary is Now Available to Test Bleeding Edge Features) +[#]: via: (https://news.itsfoss.com/gnome-web-canary/) +[#]: author: (Ankush Das https://news.itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: (zd200572) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13683-1.html) + +使用 GNOME Web 的 Canary 版本测试前沿功能 +====== + +> 如果你想测试高度不稳定的 GNOME Web 浏览器的前沿功能,Canary 版本就是为了这个。 + +![](https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/08/gnome-web-canary.png?w=1200&ssl=1) + +Epiphany(或称 [GNOME Web][1])是一个 Linux 发行版上精简而功能强大的浏览器,你会发现它也是 elementary OS 的默认浏览器。 + +随同 GNOME 40 发布的 Epiphany 浏览器有一些 [改进和新增功能][2]。 + +而在幕后,经常有许多令人兴奋的提升和新增特性。因此,你可以选择为早期测试人员量身定制的 GNOME Web 技术预览版。 + +现在,它发布了一个新的 Canary 版本,你可以使用它来测试甚至在技术预览版中都没有的特性。 + +### GNOME Web Canary 版本 + +![][3] + +GNOME Web 的 Canary 版本允许你测试甚至没有出现在最新 [WebKitGTK][4] 版本中的特性。 + +注意 Canary 版本应该是极其不稳定的,甚至稳定性比开发者技术预览版更差。 + +可是,使用 Canary 版本,终端用户可以在开发过程中的早期进行测试,帮助开发者发现灾难性 bug。 + +不只是终端用户的早期测试,Canary 版本还让 GNOME Web 的开发者的工作更轻松。 + +他们不再需要为了实现和测试一个新特性,来单独构建 WebKitGTK。 + +尽管开发者有一个 Flatpak SDK 可以简化开发人员的流程,但是这仍然是一项耗时的任务。 + +现在,没有了这个阻碍,开发速度也有可能提升。 + +### 怎样获得 Canary 版本? + +首先,你需要使用以下命令添加 WebKit SDK Flatpak 远端仓库: + +``` +flatpak --user remote-add --if-not-exists webkit https://software.igalia.com/flatpak-refs/webkit-sdk.flatpakrepo +flatpak --user install https://nightly.gnome.org/repo/appstream/org.gnome.Epiphany.Canary.flatpakref +``` + +完成后,你就可以使用提供的 [Flatpakref 文件][5] 安装啦! + +测试 Canary 版本可以让更多的用户能够在此过程中帮助 GNOME Web 的开发人员。所以,这绝对是改进 GNOME Web 浏览器开发的急需补充。 + +更多技术细节,你可能需要看这位开发者发布的 [公告][6]。 + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/gnome-web-canary/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[zd200572](https://github.com/zd200572) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://wiki.gnome.org/Apps/Web/ +[2]: https://news.itsfoss.com/gnome-web-new-tab/ +[3]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/08/Epiphany-Canary.png?w=940&ssl=1 +[4]: https://webkitgtk.org +[5]: https://nightly.gnome.org/repo/appstream/org.gnome.Epiphany.Canary.flatpakref +[6]: https://base-art.net/Articles/introducing-the-gnome-web-canary-flavor/ diff --git a/published/20210803 How to Install Google Chrome on Linux Mint -Beginners Tip.md b/published/20210803 How to Install Google Chrome on Linux Mint -Beginners Tip.md new file mode 100644 index 0000000000..29ab48f613 --- /dev/null +++ b/published/20210803 How to Install Google Chrome on Linux Mint -Beginners Tip.md @@ -0,0 +1,129 @@ +[#]: subject: (How to Install Google Chrome on Linux Mint [Beginners Tip]) +[#]: via: (https://itsfoss.com/install-chrome-linux-mint/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13659-1.html) + +初级:如何在 Linux Mint 上安装 Google Chrome +====== + +![](https://img.linux.net.cn/data/attachment/album/202108/08/133301ni5k5i8rziezwe5i.jpg) + +这应该是一个非常简单的话题,但我写这个是因为我看到很多网站推荐在 Linux Mint 上安装 Google Chrome 的奇怪命令行步骤。那是可行的,但那是不必要的复杂,特别是对于不熟悉命令行的初学者。 + +实际上,你根本不需要走终端方式。你所要做的就是去谷歌浏览器的网站,下载 Ubuntu 的安装文件并安装。 + +让我详细介绍一下步骤,供你了解。 + +### 在 Linux Mint 上安装 Google Chrome + +进入 Google Chrome 的网站。 + +[Google Chrome Website][1] + +你会看到一个 “Download Chrome” 的按钮。点击它。 + +![Download Chrome for Linux][2] + +它将向你显示在 Linux 上下载 Chrome 的两个选项。选择 Debian/Ubuntu 选项并点击 “Accept and Install” 按钮。 + +![Select Debian/Ubuntu option for Chrome package on Mint][3] + +在开始下载之前,Firefox 会询问你是否要用 Gdebi 打开下载的文件或保存它。你可以选择任何一个选项,因为最终你会 [使用 Gdebi 来安装 deb 文件][4]。然而,我更喜欢先保存文件。 + +![Save the deb file][5] + +等待下载完成。 + +![Wait for Google Chrome download to finish][6] + +下载完成后,在文件管理器中进入下载文件夹。要 [安装 deb 文件][7],可以双击它或者右击它并选择 “Open With GDebi Package Installer”。 + +![Double click on the downloaded deb file to install it][8] + +等待几秒钟,它应该给你一个安装的选项。 + +![Hit the Install Package option in Gdebi][9] + +它将要求你提供 Linux Mint 的账户密码。在 Linux 中,你需要提供你的密码来安装任何应用。 + +![Enter your password for installing an application][10] + +你就要完成了。它将显示哪些额外的软件包将与之一起安装(如果有的话)。点击继续按钮即可。 + +![Details on the packages to be installed][11] + +安装完成应该只需要几秒钟或最多一分钟。 + +![Installing Chrome in progress][12] + +安装完成后,你应该看到这样的屏幕。 + +![Chrome successfully installed on Linux Mint][13] + +安装完成后,你可以在应用菜单中寻找 Google Chrome 来运行它。 + +![Run Google Chrome in Linux Mint][14] + +然后在 Linux Mint 上享受 Google Chrome。 + +![Google Chrome running in Linux Mint][15] + +### 如何在 Linux Mint 上更新 Google Chrome + +这个方法的好处是,谷歌浏览器会随着系统的更新而更新。当你安装 deb 文件的时候,它也会在你的系统中添加一个来自谷歌的仓库。 + +![Chrome adds a repository to the system for providing updates][16] + +由于这个添加的仓库,Chrome 浏览器上的更新将被添加到系统更新中。因此,当你更新 Linux Mint 时,它也会被更新(如果有可用的更新)。 + +### 如何从 Linux Mint 中删除 Google Chrome + +不喜欢 Chrome?不用担心。你可以从 Linux Mint 中卸载谷歌浏览器。同样这次你也不需要使用终端。 + +点击菜单,搜索 Chrome。在 Chrome 图标上点击右键,你会看到一个 “Uninstall” 选项。选择它。 + +![Removing Google Chrome from Linux Mint][17] + +当然,你必须输入你的密码。它将显示要删除的软件包。在这里点击 OK。 + +![Uninstalling Google Chrome from Linux mint][18] + +你可以留下 Google Chrome 的仓库,也可以删除它。这是你的选择。 + +我希望你觉得这个教程对在 Linux Mint 上使用 Google Chrome 有帮助。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-chrome-linux-mint/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.google.com/chrome/index.html +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/08/download-chrome-linux-mint.png?resize=800%2C320&ssl=1 +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/08/downloading-chrome-linux-mint.png?resize=800%2C679&ssl=1 +[4]: https://itsfoss.com/gdebi-default-ubuntu-software-center/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/08/saving-downloaded-chrome-linux-mint.png?resize=798%2C400&ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/08/finishing-chrome-download-linux-mint.png?resize=799%2C315&ssl=1 +[7]: https://itsfoss.com/install-deb-files-ubuntu/ +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/08/installing-google-chrome-deb-file-mint.png?resize=799%2C529&ssl=1 +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/08/installing-google-chrome-gdebi-mint.png?resize=801%2C548&ssl=1 +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/08/enter-password-for-installing-chrome-mint.png?resize=800%2C399&ssl=1 +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/08/installing-chrome-mint.png?resize=799%2C483&ssl=1 +[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/08/installing-chrome-mint-progress.png?resize=799%2C489&ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/08/chrome-installed-mint.png?resize=798%2C483&ssl=1 +[14]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/08/run-google-chrome-linux-mint.png?resize=798%2C580&ssl=1 +[15]: https://itsfoss.com/wp-content/uploads/2021/08/google-chrome-in-linux-mint-800x450.webp +[16]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/08/google-chrome-repo-added-mint.png?resize=799%2C272&ssl=1 +[17]: https://itsfoss.com/wp-content/uploads/2021/08/removing-google-chrome-from-mint.webp +[18]: https://itsfoss.com/wp-content/uploads/2021/08/uninstalling-google-chrome-from-linux-mint.webp diff --git a/published/20210803 Mount Microsoft OneDrive in Linux With OneDriver GUI Tool.md b/published/20210803 Mount Microsoft OneDrive in Linux With OneDriver GUI Tool.md new file mode 100644 index 0000000000..cae17b0138 --- /dev/null +++ b/published/20210803 Mount Microsoft OneDrive in Linux With OneDriver GUI Tool.md @@ -0,0 +1,113 @@ +[#]: subject: (Mount Microsoft OneDrive in Linux With OneDriver GUI Tool) +[#]: via: (https://itsfoss.com/onedriver/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13681-1.html) + +用 OneDriver GUI 工具在 Linux 中挂载微软 OneDrive +====== + +在 Windows 上,微软提供了一个 [免费云存储服务][1] OneDrive。它与 Windows 集成,你可以通过你的微软账户获得 5GB 的免费存储空间。 + +这在 Windows 上很好用,但和谷歌一样,微软也没有在 Linux 桌面上提供 OneDrive 的本地客户端。 + +当然,你可以通过浏览器访问你的 OneDrive 数据。除此以外,还有一些其他的方法可以在 Linux 上访问 OneDrive。 + +你可以使用像 [Insync][2] 这样的高级服务,或者选择用 [rclone 在 Linux 上使用 OneDrive][3] 这种稍微复杂的命令行方式。 + +最近,我发现了另一个工具,它稍有不同,使用起来也更简单。不出所料,它叫 OneDriver。 + +### OneDriver:在你的 Linux 系统上挂载 OneDrive + +![OneDrive Linux illustration][4] + +[OneDriver][5] 是一个自由而开源的工具,允许你在 Linux 系统上挂载 OneDrive 文件。 + +请记住,它不会像 OneDrive 在 Windows 系统上那样同步文件。它将 OneDrive 文件挂载在本地的挂载点上。你通过网络访问这些文件。 + +然而,它确实提供了一种混合方法。你在挂载的 OneDrive 中打开的文件也被下载到系统中。这意味着,你也可以离线访问打开的文件。如果你没有连接到互联网,这些文件将成为只读。 + +如果你在本地对文件做任何修改,并且连接到互联网,它就会反映到 OneDrive 上。 + +我注意到,在 GNOME 上的 Nautilus 文件管理器中,它会自动下载当前文件夹中的图像。在我的印象中,它们只有在我打开它们时才会被下载。 + +另一件事是,Nautilus 一开始会建立缩略图缓存。OneDriver 在开始的时候可能会觉得有点慢,有点耗费资源,但最终会好起来。 + +哦!你也可以挂载多个 OneDrive 账户。 + +### 安装和使用 OneDriver + +要在 Ubuntu 20.04(和 Linux Mint 20 系列)上安装 OneDriver,你可以使用 OneDriver 开发者的这个 PPA: + +``` +sudo add-apt-repository ppa:jstaf/onedriver +sudo apt update +sudo apt install onedriver +``` + +对于 Ubuntu 21.04,你可以下载 [其 PPA 中的 DEB 文件][6] 来使用它。 + +在 Fedora 上,你可以添加这个 COPR: + +``` +sudo dnf copr enable jstaf/onedriver +sudo dnf install onedriver +``` + +Arch 用户可以在 AUR 中找到它。 + +安装后,在菜单中搜索 OneDriver,然后从这里启动它。 + +![Search for OneDriver][7] + +首次运行时,它会给出一个奇怪的空界面。点击 “+” 号,选择一个文件夹或创建一个新的文件夹,OneDrive 会挂载在那里。在我的例子中,我在我的家目录下创建了一个名为 `One_drive` 的新文件夹。 + +![Click on + sign to add a mount point for OneDrive][8] + +当你选择了挂载点后,你会被要求输入你的微软凭证。 + +![one drive login][9] + +![one drive permission][10] + +登录后,你可以在挂载的目录中看到 OneDrive 的文件。 + +![OneDrive mounted in Linux][11] + +完成这些后,你可以在应用界面上看到你的 OneDrive 账户。点击旁边的勾按钮,以在重启后自动挂载 OneDrive。 + +![Autostart OneDriver mounting][12] + +总的来说,OneDriver 是一个可以在 Linux 上访问 OneDrive 的不错的免费工具。它可能无法像 [高级 Insync 服务][13] 那样提供完整的同步设施,但对于有限的需求来说,它做得不错。 + +如果你使用这个漂亮的工具,请分享你的使用经验。如果你喜欢这个项目,也许可以给它一个 [GitHub 上的星标][5]。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/onedriver/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/cloud-services-linux/ +[2]: https://itsfoss.com/use-onedrive-on-linux/ +[3]: https://itsfoss.com/use-onedrive-linux-rclone/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/08/one-drive-linux.png?resize=800%2C450&ssl=1 +[5]: https://github.com/jstaf/onedriver +[6]: https://launchpad.net/~jstaf/+archive/ubuntu/onedriver/+packages +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/08/search-for-onedriver.png?resize=798%2C214&ssl=1 +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/08/onedriver-interface.png?resize=745%2C456&ssl=1 +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/08/one-drive-login.png?resize=470%2C660&ssl=1 +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/08/one-drive-permission.png?resize=470%2C660&ssl=1 +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/08/one-drive-mounted-in-linux.png?resize=800%2C491&ssl=1 +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/08/auto-start-onedriver.png?resize=602%2C499&ssl=1 +[13]: https://itsfoss.com/recommends/insync/ diff --git a/published/20210803 Set up a VPN server on your Linux PC.md b/published/20210803 Set up a VPN server on your Linux PC.md new file mode 100644 index 0000000000..d310844edb --- /dev/null +++ b/published/20210803 Set up a VPN server on your Linux PC.md @@ -0,0 +1,130 @@ +[#]: subject: (Set up a VPN server on your Linux PC) +[#]: via: (https://opensource.com/article/21/8/openvpn-server-linux) +[#]: author: (D. Greg Scott https://opensource.com/users/greg-scott) +[#]: collector: (lujun9972) +[#]: translator: (perfiffer) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13680-1.html) + +如何在免费 WiFi 中保护隐私(一) +====== + +> 第一步是安装一个“虚拟专用网络”服务器。 + +![](https://img.linux.net.cn/data/attachment/album/202108/13/213142rclc5htyfahotfas.jpg) + +你是否连接到了不受信任的网络,例如酒店或咖啡馆的 WiFi,而又需要通过智能手机和笔记本电脑安全浏览互联网?通过使用虚拟专用网络,你可以匿名访问不受信任的网络,就像你在专用网络上一样安全。 + +“虚拟专用网络” 是保护私人数据的绝佳工具。通过使用 “虚拟专用网络”,你可以在保持匿名的同时连接到互联网上的专用网络。 + +可选的 “虚拟专用网络” 服务有很多,[0penVPN][2] 依然是很多人在使用不受信任的网络时保护私人数据的第一选择。 + +0penVPN 在两点之间创建一个加密通道,防止第三方访问你的网络流量数据。通过设置你的 “虚拟专用网络” 服务,你可以成为你自己的 “虚拟专用网络” 服务商。许多流行的 “虚拟专用网络” 服务都使用 0penVPN,所以当你可以掌控自己的网络时,为什么还要将你的网络连接绑定到特定的提供商呢? + +### 搭建 Linux 服务器 + +首先,在备用 PC 上安装一份 Linux。本例使用 Fedora,但是不论你使用的是什么 Linux 发行版,步骤基本是相同的。 + +从 [Fedora 项目][3] 网站下载最新的 Fedora ISO 副本。制作一个 USB 启动盘,将其插入到你的 PC 并启动,然后安装操作系统。如果你从未制作过可引导的 USB 启动盘,可以了解一下 [Fedora Media Writer][4]。如果你从未安装过 Linux,请阅读 [三步安装 Linux][5]。 + +### 设置网络 + +安装完成 Fedora 操作系统后,登录到控制台或者 SSH 会话。 + +更新到最新并重新启动: + +``` +$ sudo dnf update -y && reboot +``` + +重新登录并关闭防火墙: + +``` +systemctl disable firewalld.service +systemctl stop firewalld.service +``` + +你可能希望在此系统上为你的内部网络添加适当的防火墙规则。如果是这样,请在关闭所有防火墙规则后完成 0penVPN 的设置和调试,然后添加本地防火墙规则。想要了解更多,请参照 [在 Linux 上设置防火墙][6]。 + +### 设置 IP 地址 + +你需要在你的本地网络设置一个静态 IP 地址。下面的命令假设在一个名为 `ens3` 的设备上有一个名为 `ens3` 的网络管理器Network Manager连接。你的设备和连接名称可能不同,你可以通过打开 SSH 会话或从控制台输入以下命令: + +``` +$ sudo nmcli connection show +NAME  UUID                                  TYPE      DEVICE +ens3  39ad55bd-adde-384a-bb09-7f8e83380875  ethernet  ens3 +``` + +你需要确保远程用户能够找到你的 “虚拟专用网络” 服务器。有两种方法可以做到这一点。你可以手动设置它的 IP 地址,或者将大部分工作交给你的路由器去完成。 + +#### 手动配置一个 IP 地址 + +通过以下命令来设置静态 IP 地址、前缀、网关和 DNS 解析器,用来替换掉原有的 IP 地址: + +``` +$ sudo nmcli connection modify ens3 ipv4.addresses 10.10.10.97/24 +$ sudo nmcli connection modify ens3 ipv4.gateway 10.10.10.1 +$ sudo nmcli connection modify ens3 ipv4.dns 10.10.10.10 +$ sudo nmcli connection modify ens3 ipv4.method manual +$ sudo nmcli connection modify ens3 connection.autoconnect yes +``` + +设置主机名: + +``` +$ sudo hostnamectl set-hostname OVPNserver2020 +``` + +如果你运行了一个本地的 DNS 服务,你需要设置一个 DNS 条目,将主机名指向 “虚拟专用网络” 服务器的 IP 地址。 + +重启并确保系统的网络运行正常。 + +#### 在路由器中配置 IP 地址 + +在你的网络当中应该有一台路由器。你可能已经购买了它,或者从互联网服务提供商(ISP)那里获得了一台。无论哪种方式,你的路由器可能都有一个内置的 DHCP 服务,可以为连接到网络上的每台设备分配一个 IP 地址。你的新 “虚拟专用网络” 服务器也是属于网络的一台设备,因此你可能已经注意到它会自动分配一个 IP 地址。 + +这里的潜在问题是你的路由器不能保证每台设备都能在重新连接后获取到相同的 IP 地址。路由器确实尝试保持 IP 地址一致,但这会根据当时连接的设备数量而发生变化。 + +但是,几乎所有的路由器都会有一个界面,允许你为特定设备调停和保留 IP 地址。 + +![Router IP address settings][7] + +路由器没有统一的界面,因此请在你的路由器接口中搜索 “DHCP” 或 “Static IP address” 选项。为你的服务器分配自己的预留 IP 地址,使其在网络中保持 IP 不变。 + +### 连接到服务器 + +默认情况下,你的路由器可能内置了防火墙。这通常很好,因为你不希望网络之外的人能够强行进入你的任何计算机。但是,你必须允许发往 “虚拟专用网络” 服务器的流量通过防火墙,否则你的 “虚拟专用网络” 将无法访问,这种情况下你的 “虚拟专用网络” 服务器将形同虚设。 + +你至少需要一个来自互联网服务提供商的公共静态 IP 地址。使用其静态 IP 地址设置路由器的公共端,然后将你的 0penVPN 服务器放在专用端,在你的网络中使用专用静态 IP 地址。 0penVPN 默认使用 UDP 1194 端口。配置你的路由器,将你的公网 “虚拟专用网络” IP 地址的 UDP 1194 端口转发到 0penVPN 服务器上的 UDP 1194 端口。如果你决定使用不同的 UDP 端口,请相应地调整端口号。 + +### 准备好,我们开始下一步 + +在本文中,你在服务器上安装并配置了一个操作系统,这已经成功了一半。在下一篇文章中,你将解决安装和配置 0penVPN 本身的问题。同时,请熟悉你的路由器并确保你可以从外部访问你的服务器。但是请务必在测试后关闭端口转发,直到你的 “虚拟专用网络” 服务启动并运行。 + +本文的部分内容改编自 D. Greg Scott 的博客,并经许可重新发布。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/8/openvpn-server-linux + +作者:[D. Greg Scott][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/greg-scott +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_tea_laptop_computer_work_desk.png?itok=D5yMx_Dr (Person drinking a hot drink at the computer) +[2]: https://openvpn.net/ +[3]: http://getfedora.org +[4]: https://opensource.com/article/20/10/fedora-media-writer +[5]: https://opensource.com/article/21/2/linux-installation +[6]: https://www.redhat.com/sysadmin/secure-linux-network-firewall-cmd +[7]: https://opensource.com/sites/default/files/uploads/reserved-ip.jpg (Router IP address settings) +[8]: https://creativecommons.org/licenses/by-sa/4.0/ +[9]: https://opensource.com/article/20/9/firewall +[10]: https://www.dgregscott.com/how-to-build-a-vpn-in-four-easy-steps-without-spending-one-penny/ diff --git a/published/20210803 Use the Linux terminal to navigate throughout your computer.md b/published/20210803 Use the Linux terminal to navigate throughout your computer.md new file mode 100644 index 0000000000..303722ad27 --- /dev/null +++ b/published/20210803 Use the Linux terminal to navigate throughout your computer.md @@ -0,0 +1,55 @@ +[#]: subject: (Use the Linux terminal to navigate throughout your computer) +[#]: via: (https://opensource.com/article/21/8/navigate-linux-directories) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: (piaoshi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13674-1.html) + +使用 Linux 终端浏览你的计算机 +====== + +> 学习在 Linux 终端中从一个目录切换到另一个目录。 + +![](https://img.linux.net.cn/data/attachment/album/202108/12/113605d3hp448xm8m18wzw.jpg) + +要在图形界面中浏览你的计算机上的文件夹,你可能习惯于打开一个窗口来“进入”你的计算机,然后双击一个文件夹,再双击一个子文件夹,如此反复。你也可以使用箭头按钮或按键来回溯。 + +而要在终端中浏览你的计算机,你可以利用 `cd` 命令。你可以使用 `cd ..` 回到 _上一级_ 目录,或者使用 `cd ./另一个/文件夹的/路径` 来跳过许多文件夹进入一个特定的位置。 + +你在互联网上已经使用的 URL 的概念,实际上直接来自 [POSIX][2]。当你浏览某个网站的一个特定页面时,比如 `http://www.example.com/tutorials/lesson2.html`,你实际上做的是进入 `/var/www/imaginarysite/tutorials/` 目录,并打开一个叫 `classic2.html` 的文件。当然,你是在 Web 浏览器中打开它的,浏览器会将所有那些看起来奇怪的 HTML 代码解释成漂亮的文本和图片。但这两者的思路是完全一样的。 + +如果你把你的计算机看成是互联网(或者把互联网看成是计算机会更合适),那么你就能理解如何在你的文件夹和文件中遨游了。如果从你的用户文件夹(你的家目录,或简记为 `~`)开始,那么你想切换到的文件夹都是相对于这个文件夹而言的: + +``` +$ cd ~/Documents +$ pwd +/home/tux/Documents + +$ cd .. +$ pwd +/home/tux +``` + +这需要一些练习,但一段时间后,它会变得比你打开和关闭窗口、点击返回按钮和文件夹图标快得多。 + +### 用 Tab 键自动补全 + +键盘上的 `Tab` 键可以自动补全你开始输入的文件夹和文件的名字。如果你要 `cd` 到 `~/Documents` 文件夹,那么你只需要输入 `cd ~/Doc`,然后按 `Tab` 键即可。你的 Shell 会自动补全 `uments`。这不仅仅是一个令人愉快的便利工具,它也是一种防止错误的方法。如果你按下 `Tab` 键而没有任何东西自动补全,那么可能你 _认为_ 存在于某个位置的文件或文件件实际上并不存在。即使有经验的 Linux 用户也会试图切换到一个当前目录下不存在的文件夹,所以你可以经常使用 `pwd` 和 `ls` 命令来确认你确实在你认为你在的目录、以及你的当前目录确实包含了你认为它包含的文件。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/8/navigate-linux-directories + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[piaoshi](https://github.com/piaoshi) +校对:[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/ch01s04.svg_.png?itok=bC8Bcapk (Move around your computer) +[2]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains diff --git a/published/20210804 Firefox Lost Almost 50 million Users- Here-s Why It is Concerning.md b/published/20210804 Firefox Lost Almost 50 million Users- Here-s Why It is Concerning.md new file mode 100644 index 0000000000..2c4802782c --- /dev/null +++ b/published/20210804 Firefox Lost Almost 50 million Users- Here-s Why It is Concerning.md @@ -0,0 +1,112 @@ +[#]: subject: "Firefox Lost Almost 50 million Users: Here’s Why It is Concerning" +[#]: via: "https://news.itsfoss.com/firefox-decline/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lujun9972" +[#]: translator: "imgradeone" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13658-1.html" + +Firefox 失去了近 5000 万用户:令人担忧的原因 +====== + +> 2018 年以来,Mozilla 的火狐浏览器正在大面积流失用户,为什么用户正在远离它?这是否值得担心? + +![](https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/08/firefox-decline.jpg?w=1200&ssl=1) + +Mozilla 的 Firefox 是基于 Chromium 内核的浏览器的唯一流行替代品。 + +它一直是 Linux 用户,以及每个平台上注重隐私的用户的默认选择。 + +然而,即便凭借着大量优势成为最好的 Web 浏览器之一,Firefox 近几年逐渐流失了它的影响力。 + +实话实说,我们都不需要借助统计数据来论证这一点,因为我们当中的许多人就已经转向其它 Chromium 内核的浏览器,或者 Chromium 本身,而不是 Firefox 和 Google Chrome。 + +不过,我在 Reddit 上偶然发现了由 [u/nixcraft][1] 写的一篇帖子,这篇帖子强调了 Firefox 的用户数从 2018 年来不断下降的原因。 + +而令人惊讶的是,这篇帖子的原始信息来源就是 [Firefox 的公开数据报表][2]。 + +![][3] + +根据官方数据统计,在 2018 年底,其报告的(月度)活跃人数达到了 **2.44 亿**。 + +但,到了 **2021 年第二季度**,这个数字降到了 **1.98 亿**。 + +由此可以得出,Firefox 的用户基数下降了高达 **4600 万**。 + +### Firefox 的衰落确实令人担忧,但也很明显 + +鉴于在 2021 年以隐私为重点的工具在其用户群体中大量出现,Mozilla 的 Firefox 用户基数正面临着不断下降。 + +尤其是在 Firefox 设法引入一些业界首创的隐私功能之后。呵,是不是很讽刺? + +如果你从来没有使用过 Firefox,或者已经迁移至其他浏览器许久,这篇 [关于 Brave 和 Firefox 浏览器的比较][4] 表明,到目前为止,Firefox 其实还是一个可靠的浏览器。 + +所以,为什么许多用户迁移到了 Chromium 内核的浏览器,尤其是 Chrome 呢? + +我这里马上就想到了这几点: + + * Google Chrome 是 Android 设备上的默认浏览器 + * Microsoft Edge 是 Windows 设备上的默认浏览器(因此自然就有巨大的市场份额) + * Google.com(最大的搜索引擎)建议用户安装 Google Chrome(实际上是一种潜在的反竞争手段) + * 一些 Web 服务只兼容基于 Chromium 的浏览器 + +除此之外,Firefox 可能也做错了这几件事: + + * 不断以大修的方式来破坏用户体验 + * 近年来缺乏显著的性能改进 + +当然,没有哪个浏览器是完美的,但这是什么值得担心的事吗?嗯,我觉得是的。 + +### 为什么你应该担忧 + +Mozilla 的 Firefox 是基于 Chromium 的浏览器的唯一可行的竞争品。如果 Firefox 消失了,用户就会失去其它浏览器内核的选择。 + +我相信你会同意,纵容垄断是有害的,因此我们需要一些 Google Chromium 引擎的替代品。 + +实际上,相当多的网站会根据基于 Chromium 的浏览器来优化用户体验。 + +因此,如果用户量下降的趋势一直持续下去,**我们这样的用户可能就会被迫适应新的工作流程而改用其他浏览器**。 + +即使忽略掉 Google 的 Chromium 引擎在互联网的主导地位,或者认为 Chrome 之类的浏览器在技术上更好,Firefox 仍旧十分珍贵。因为它至少提供了更多的个性化功能,也不断改进隐私体验,与其他的都不一样。 + +换句话说,我们可能会(被迫)失去许多好的东西,而这一切仅仅是因为其他竞争对手都选择基于 Chromium 内核,或者从事反竞争活动。 + +也许,你现在对 Firefox 很失望而想转向其他浏览器。当然,这是你自己的选择。 + +**但是,待到 Firefox 因为各种使其衰落的因素而彻底消失后,你又该何去何从呢?** + +![][5] + +因此,为了让一切保持平衡,我认为我们应该不断反抗科技巨头的反竞争行为,并且开始使用 Mozilla Firefox(不论是什么身份,甚至是作为备用浏览器)。 + +当然,Mozilla 也需要面对这种情况做出什么措施了。 + +当他们忙于添加隐私网络服务、邮件中继和其他服务集成时,Mozilla 在用户体验改善方面做的并不成功。 + +至少,我是这么认为的。多年来,我一直使用 Firefox 作为主力浏览器,但我最终还是会偶尔转向其他浏览器,尤其是每次 Firefox 界面进行大幅度更改后。 + +### 你怎么看? + +我很想知道你对此有何想法,以及你认为究竟是什么因素导致了 Firefox 用户数的下降。 + +你更喜欢将哪款浏览器作为你的主力浏览器?在评论区中告诉我吧! + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/firefox-decline/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[imgradeone](https://github.com/imgradeone) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://www.reddit.com/user/nixcraft/ +[2]: https://data.firefox.com/dashboard/user-activity +[3]: https://news.itsfoss.com/wp-content/uploads/2021/08/firefox-userbase-decline.png +[4]: https://itsfoss.com/brave-vs-firefox/ +[5]: https://news.itsfoss.com/wp-content/uploads/2021/08/firefox-survive.jpg \ No newline at end of file diff --git a/published/20210804 How to Find and Remove Duplicate Photos in Linux.md b/published/20210804 How to Find and Remove Duplicate Photos in Linux.md new file mode 100644 index 0000000000..96d52f1258 --- /dev/null +++ b/published/20210804 How to Find and Remove Duplicate Photos in Linux.md @@ -0,0 +1,108 @@ +[#]: subject: (How to Find and Remove Duplicate Photos in Linux) +[#]: via: (https://itsfoss.com/find-remove-duplicate-photos-linux/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) +[#]: collector: (lujun9972) +[#]: translator: (zpl1025) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13661-1.html) + +如何在 Linux 系统里查找并删除重复相片 +====== + +![](https://img.linux.net.cn/data/attachment/album/202108/09/101511dq8uo51o8go5s9n9.jpg) + +点击打开了很多相似的相片?同样的相片保存在不同文件夹里?我理解这种感受。 + +在相机里点击相片,通过 WhatsApp 发送。然后又备份相片,于是在 WhatsApp 和系统相册里就会存下同样的拷贝。这个很烦人,很乱而且额外占用不必要的存储空间。 + +我是在翻看我岳父的相片收藏时遇到这个问题的。下面是我如何找出重复相片并删除的做法。 + +### 使用 digiKam 来找出和删除重复相片 + +[digiKam][1] 是一个 [用来管理和收集相片的自由开源应用][2]。它主要是方便摄影师,但并不是说一定要专业玩相机的人才能用。 + +我可以演示如何使用这个工具来查找重复相片,然后根据需要删除重复内容。 + +#### 第一步 + +首先是安装 digiKam。它是一个很流行的应用程序,应该可以在软件中心里直接安装,或者通过你的发行版的包管理器安装。 + +![通过软件中心安装 digikam][3] + +#### 第二步 + +在第一次运行 digiKam 时,它会要求你选择相片保存的位置。然后会创建一个 SQLite 数据库并开始导入图片。 + +![][4] + +![][5] + +![][6] + +#### 第三步 + +在相片导入完成以后,在文件菜单里选择**工具->查找重复图片**。 + +![在文件菜单里,选择工具->查找重复图片][7] + +#### 第四步 + +根据你所收集的图片数量,会需要一些时间。之后,你应该可以在左侧边栏里看到有重复的所有相片。在选中图片后,重复的相片会在右侧边栏里显示出来。 + +![digiKam 找到的重复图片][8] + +在上面的截图里,我在左侧选中的图片有四张一样的。其中有一张图片标记了“参考图片Reference image”,不过还是由你来确定哪张是原始的,哪张是复制的。 + +重复的相片默认会按保存位置(比如文件夹)来分组。可以在文件菜单里选择**视图->分类显示**选择其他方式。 + +**要删除重复相片的话**,选中有侧边栏里的相片并按下删除键。 + +可以重复这个操作,选择左侧边栏里的图片,一个个删除重复图片。会花太长时间?有个方法可以一次删除多个重复内容。 + +#### 在 digiKam 里删除多个重复图片 + +如果想一次把所有重复相片全删掉的话,可以在左侧边栏里选中所有相片。 + +然后,打开**文件菜单->视图->排序**,然后选择按相似程度。 + +![删除多个重复相片][9] + +之后会在底部显示所有参考图片。然后可以在右侧边栏里选中所有没有标记重复的相片,并按下删除按钮。 + +#### 额外提示:可以在垃圾桶里恢复已删除的相片 + +意外总是有的。人们经常会不小心误删了相片。这也是为什么 digiKam 不会立刻彻底删除图片。而是选择在保存相片的文件夹下创建隐藏的 `.dtrash` 文件夹,然后将“已删除”的相片移动到里面。 + +在应用程序界面上,你也可以看到这个垃圾桶文件夹。在里面可以找到你“删除”的相片,然后根据需要可以选择恢复。 + +![digiKam 的垃圾桶文件夹][10] + +希望你能喜欢这个关于在 Linux 上查找和删除重复图片的简短教程。类似的,你可能会想了解 [使用 GUI 工具在 Linux 系统里搜索重复文件][11]。 + +有任何问题和建议,请在下方留评。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/find-remove-duplicate-photos-linux/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[zpl1025](https://github.com/zpl1025) +校对:[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://www.digikam.org/ +[2]: https://itsfoss.com/linux-photo-management-software/ +[3]: https://itsfoss.com/wp-content/uploads/2021/08/digikam-software-center-800x452.webp +[4]: https://itsfoss.com/wp-content/uploads/2021/08/digikam-initial-setup-1.webp +[5]: https://itsfoss.com/wp-content/uploads/2021/08/digikam-initial-setup-2.webp +[6]: https://itsfoss.com/wp-content/uploads/2021/08/digikam-initial-setup-3-800x607.webp +[7]: https://itsfoss.com/wp-content/uploads/2021/08/find-duplicates-digikam-800x462.webp +[8]: https://itsfoss.com/wp-content/uploads/2021/08/duplicate-images-found-with-digikam-800x530.webp +[9]: https://itsfoss.com/wp-content/uploads/2021/08/remove-multiple-duplicate-photos-800x528.webp +[10]: https://itsfoss.com/wp-content/uploads/2021/08/trash-option-digiKam-800x545.webp +[11]: https://itsfoss.com/find-duplicate-files-linux/ diff --git a/published/20210804 Move files in the Linux terminal.md b/published/20210804 Move files in the Linux terminal.md new file mode 100644 index 0000000000..c198ff28ea --- /dev/null +++ b/published/20210804 Move files in the Linux terminal.md @@ -0,0 +1,52 @@ +[#]: subject: (Move files in the Linux terminal) +[#]: via: (https://opensource.com/article/21/8/move-files-linux) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-13677-1.html) + +基础:在 Linux 终端中移动文件 +====== + +> 使用 mv 命令将一个文件从一个位置移动到另一个位置。 + +![](https://img.linux.net.cn/data/attachment/album/202108/13/112248lnal8a0qz50zqzld.jpg) + +要在有图形界面的计算机上移动一个文件,你要打开该文件当前所在的文件夹,然后打开另一个窗口导航到你想把文件移到的文件夹。最后,你把文件从一个窗口拖到另一个窗口。 + +要在终端中移动文件,你可以使用 `mv` 命令将文件从一个位置移动到另一个位置。 + +``` +$ mv example.txt ~/Documents + +$ ls ~/Documents +example.txt +``` + +在这个例子中,你已经把 `example.txt` 从当前文件夹移到了主目录下的 `Documents` 文件夹中。 + +只要你知道一个文件在 _哪里_,又想把它移到 _哪里_ 去,你就可以把文件从任何地方移动到任何地方,而不管你在哪里。与在一系列窗口中浏览你电脑上的所有文件夹以找到一个文件,然后打开一个新窗口到你想让该文件去的地方,再拖动该文件相比,这可以大大节省时间。 + +默认情况下,`mv` 命令完全按照它被告知的那样做:它将一个文件从一个位置移动到另一个位置。如果在目标位置已经存在一个同名的文件,它将被覆盖。为了防止文件在没有警告的情况下被覆盖,请使用 `--interactive`(或简写 `-i`)选项。 + +``` +$ mv -i example.txt ~/Documents +mv: overwrite '/home/tux/Documents/example.txt'? +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/8/move-files-linux + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/ch01s05.svg_.png?itok=PgKQEDZ7 (Moving files) diff --git a/published/20210807 How to Install Java on Fedora Linux.md b/published/20210807 How to Install Java on Fedora Linux.md new file mode 100644 index 0000000000..4a158e5714 --- /dev/null +++ b/published/20210807 How to Install Java on Fedora Linux.md @@ -0,0 +1,102 @@ +[#]: subject: "How to Install Java on Fedora Linux" +[#]: via: "https://itsfoss.com/install-java-fedora/" +[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" +[#]: collector: "lujun9972" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13694-1.html" + +如何在 Fedora Linux 上安装 Java +====== + +![](https://img.linux.net.cn/data/attachment/album/202108/18/102444nfsktbup4b7bfp88.jpg) + +不管是爱它还是恨它,都很难避开 Java。 + +Java 仍然是一种非常流行的编程语言,在学校里教,在企业里用。 + +如果你想使用基于 Java 的工具或用 Java 编程,你就需要在你的系统上安装 Java。 + +这就变得很混乱,因为围绕着 Java 有很多技术术语。 + + * Java 开发工具包Java Development Kit(JDK)用于创建 Java 程序 + * Java 运行环境Java Runtime Environment(JRE)或 Java 虚拟机(JVM),用于运行 Java 程序。 + +除此之外,你还会遇到 [OpenJDK][1] 和 [Oracle Java SE][2]。推荐使用 OpenJDK ,因为它是开源的。如果你有专门的需求,那么你应该选择 Oracle Java SE。 + +还有一件事。即使是 OpenJDK 也有几个版本可供选择。在写这篇文章的时候,Fedora 34 有 OpenJDK 1.8、OpenJDK 11 和 OpenJDK 16 可用。 + +你可以自行决定想要哪个Java版本。 + +### 在 Fedora Linux 上安装 Java + +首先,检查是否已经安装了 Java,以及它是哪个版本。我不是在开玩笑。Fedora 通常预装了 Java。 + +要检查它,请使用以下命令: + +``` +java -version +``` + +正如你在下面的截图中看到的,我的 Fedora 系统上安装了 Java 11(OpenJDK 11)。 + +![Check Java version][3] + +假设你想安装另一个版本的 Java。你可以用下面的命令检查可用的选项: + +``` +sudo dnf search openjdk +``` + +这里的 `sudo` 不是必须的,但它会刷新 `sudo` 用户的元数据,这在你安装另一个版本的 Java 时会有帮助。 + +上面的命令将显示很多输出,其中有很多看起来相似的软件包。你必须专注于最初的几个词来理解不同的版本。 + +![Available Java versions in Fedora][4] + +例如,要安装 Java 8(OpenJDK 1.8),包的名字应该是 `java-1.8.0-openjdk.x86_64` 或者 `java-1.8.0-openjdk`。用它来安装: + +``` +sudo dnf install java-1.8.0-openjdk.x86_64 +``` + +![Install Java Fedora][5] + +这就好了。现在你的系统上同时安装了 Java 11 和 Java 8。但你将如何使用其中一个呢? + +#### 在 Fedora 上切换 Java 版本 + +你正在使用的 Java 版本保持不变,除非你明确改变它。使用这个命令来列出系统上安装的 Java 版本: + +``` +sudo alternatives --config java +``` + +你会注意到在 Java 版本前有一个数字。Java 版本前的 `+` 号表示当前正在使用的 Java 版本。 + +你可以指定这个数字来切换 Java 版本。因此,在下面的例子中,如果我输入 2,它将把系统中的 Java 版本从 Java 11 改为 Java 8。 + +![Switching between installed Java versions][6] + +这就是你在 Fedora 上安装 Java 所需要做的一切。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-java-fedora/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://openjdk.java.net/ +[2]: https://www.oracle.com/java/technologies/javase-downloads.html +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/08/check-java-version-fedora.png?resize=800%2C271&ssl=1 +[4]: https://itsfoss.com/wp-content/uploads/2021/08/available-java-versions-fedora-800x366.webp +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/08/install-java-fedora.png?resize=800%2C366&ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/08/switch-java-versions-fedora.png?resize=800%2C513&ssl=1 diff --git a/published/20210807 It-s Time for Ubuntu to Opt for a Hybrid Rolling Release Model.md b/published/20210807 It-s Time for Ubuntu to Opt for a Hybrid Rolling Release Model.md new file mode 100644 index 0000000000..041a45180f --- /dev/null +++ b/published/20210807 It-s Time for Ubuntu to Opt for a Hybrid Rolling Release Model.md @@ -0,0 +1,73 @@ +[#]: subject: "It’s Time for Ubuntu to Opt for a Hybrid Rolling Release Model" +[#]: via: "https://news.itsfoss.com/ubuntu-hybrid-release-model/" +[#]: author: "Abhishek https://news.itsfoss.com/author/root/" +[#]: collector: "lujun9972" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13666-1.html" + +是时候让 Ubuntu 选择混合滚动发布模式了 +====== + +> 在两个 LTS 版本之间有三个短期版本。Ubuntu 应该用滚动发布模式来取代它们。 + +![](https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/08/Ubuntu-hybrid-release-model.jpg?w=1200&ssl=1) + +即使你不是 Ubuntu 的用户,你可能也知道它的发布模式。 + +有一个 [长期支持(LTS)版本][1],每两年发布一次,并有五年的支持。在这两个 LTS 版本之间,我们可以看到三个非 LTS 版本,它们的发布时间间隔为 6 个月。 + +LTS 版本会保持内核不会变化(除非你选择 [HWE 内核][2]),它还维持了各种软件组件不变以提供稳定的生产环境。 + +介于两者之间的非 LTS 版 Ubuntu 具有 Ubuntu 的新功能、更新一些的内核、新的桌面环境以及 Ubuntu 软件库中的各种软件的新版本。 + +这些非 LTS 版本作为“试验场”,为最终在 LTS 版本中出现的功能提供测试,这已不是什么秘密。 + +这就是为什么我建议摆脱这些中间版本,在 LTS 版本之间选择 [滚动发布][3] 模式。个中原因,请听我说。 + +### 在 LTS 发布之间进行滚动开发 + +六个月一次的发布计划给 Ubuntu 开发者制定了一个紧凑的工作时间表。这是一个好的方法,它可以使他们的目标集中在一个适当的路线图上。 + +但是,这也为在每个版本中提供“更多”新功能带来了额外的压力。如果时间很短,这不可能总是做到。还记得 [Ubuntu 不得不从 21.04 版本中删除 GNOME 40][4] 吗?因为开发者没有足够的时间来完成它。 + +另外,最终用户(比如你和我)想选择留在非 LTS 版本中也是不可行的。其支持在九个月后结束,这意味着即使你没有立即升级到下一个非 LTS 的 Ubuntu 版本,最终你也不得不这样做。如果你在 6 个月内没升级,那你可能就得在 9 个月内升级。 + +我知道你会说,升级 Ubuntu 版本很简单。点击几下,良好的网速和一个潜在的备份就可以让你在新的 Ubuntu 版本上没有什么麻烦。 + +我的问题是,为什么要这么麻烦。滚动发布会更简单。让升级在 LTS 版本之间进行。 + +开发人员在新功能准备好的时候发布。用户随着系统更新不断得到升级,而不是每 6 个月或 9 个月做一次“重大升级”。 + +你看,那些选择非 LTS 版本的人是那些想要新功能的人,让他们通过滚动发布获得新功能。LTS 的发布时间表保持不变,每两年来一次。 + +### Bug 测试?像其他滚动发布的版本一样做个测试分支好了 + +当我说滚动发布时,我并不是指像 Arch Linux 那样的滚动。它应该是像 Manjaro 那样的滚动。换句话说,在测试后推出升级版,而不是直接在野外发布。 + +目前,新的 Ubuntu 版本有测试版,以便早期采用者可以测试它并向开发者提供反馈。这可以通过保留测试和稳定分支来实现,就像许多其他滚动发布的版本一样。 + +### 你对滚动发布怎么看? + +我知道 Ubuntu 的铁杆用户期待着每一次的发布。代号、吉祥物、艺术品和墙纸,这些都是 Ubuntu 的传统的一部分。我们应该打破这种传统吗? + +这只是我的看法,我很想听听你的看法。Ubuntu 应该选择这种混合滚动模式还是坚持目前的模式?你怎么看呢? + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/ubuntu-hybrid-release-model/ + +作者:[Abhishek][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/root/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/long-term-support-lts/ +[2]: https://itsfoss.com/ubuntu-hwe-kernel/ +[3]: https://itsfoss.com/rolling-release/ +[4]: https://news.itsfoss.com/no-gnome-40-in-ubuntu-21-04/ diff --git a/published/20210807 Remove files and folders in the Linux terminal.md b/published/20210807 Remove files and folders in the Linux terminal.md new file mode 100644 index 0000000000..006cc5e784 --- /dev/null +++ b/published/20210807 Remove files and folders in the Linux terminal.md @@ -0,0 +1,84 @@ +[#]: subject: "Remove files and folders in the Linux terminal" +[#]: via: "https://opensource.com/article/21/8/remove-files-linux-terminal" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lujun9972" +[#]: translator: "unigeorge" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13687-1.html" + +基础:在 Linux 终端中删除文件和文件夹 +====== + +> 本教程讲述了如何在 Linux 终端中安全地删除文件和文件夹。 + +![](https://img.linux.net.cn/data/attachment/album/202108/16/110943z9boolgobdlyoiyo.jpg) + +要想使用图形化界面删除计算机上的文件,你可能会直接将文件或文件夹拖拽到 “垃圾箱” 或 “回收站”。或者你也可以选择要删除的文件或文件夹,右键单击并选择 **删除**。 + +而在终端中删除文件或文件夹时并没有垃圾箱一说(至少默认情况下没有)。在图形化桌面上,`Trash`(即垃圾箱文件夹)是一个受保护的目录,保护机制可以防止用户不小心将该目录删除,或将其从默认位置移动从而导致找不到它。Trash 本质不过是一个被高度管理的文件夹,因此你可以创建自己的 Trash 文件夹以在终端中使用。 + +### 为终端设置一个垃圾箱 + +在家目录中创建一个名为 `Trash` 的目录: + +``` +$ mkdir ~/Trash +``` + +### 删除文件 + +要删除文件或文件夹时,使用 `mv` 命令将文件或文件夹移至 `Trash` 中: + +``` +$ mv example.txt ~/Trash +``` + +### 永久删除文件或文件夹 + +当你准备从系统中永久删除某个文件或文件夹时,可以使用 `rm` 命令清除垃圾箱文件夹中的所有数据。通过将 `rm` 命令指向星号(`*`),可以删除 `Trash` 文件夹内的所有文件和文件夹,而不会删除 `Trash` 文件夹本身。因为用户可以方便且自由地创建目录,所以即使不小心删除了 `Trash` 文件夹,你也可以再次新建一个。 + +``` +$ rm --recursive ~/Trash/* +``` + +### 删除空目录 + +删除空目录有一个专门的命令 `rmdir`,它只能用来删除空目录,从而保护你免受递归删除错误的影响。 + +``` +$ mkdir full +$ touch full/file.txt +$ rmdir full +rmdir: failed to remove 'full/': Directory not empty + +$ mkdir empty +$ rmdir empty +``` + +### 更好的删除方式 + +此外还有一些并没有默认安装在终端上的 [删除文件命令][2],你可以从软件库安装它们。这些命令管理和使用的 `Trash` 文件夹与你在桌面模式使用的是同一个(而非你自己单独创建的),从而使删除文件变得更加方便。 + +``` +$ trash ~/example.txt +$ trash --list +example.txt +$ trash --empty +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/8/remove-files-linux-terminal + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[unigeorge](https://github.com/unigeorge) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/ch01s10.svg_.png?itok=p07au80e (Removing files) +[2]: https://www.redhat.com/sysadmin/recover-file-deletion-linux diff --git a/published/20210811 The Wait is Over- elementary OS 6 ‘Odin- is Finally Here With Exciting Changes.md b/published/20210811 The Wait is Over- elementary OS 6 ‘Odin- is Finally Here With Exciting Changes.md new file mode 100644 index 0000000000..2df9ddac80 --- /dev/null +++ b/published/20210811 The Wait is Over- elementary OS 6 ‘Odin- is Finally Here With Exciting Changes.md @@ -0,0 +1,104 @@ +[#]: subject: "The Wait is Over! elementary OS 6 ‘Odin’ is Finally Here With Exciting Changes" +[#]: via: "https://news.itsfoss.com/elementary-os-6-release/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lujun9972" +[#]: translator: "imgradeone" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13670-1.html" + +久等了!elementary OS 6 “Odin” 正式发布,带来令人激动的新变化 +====== + +> 基于 Ubuntu 20.04 LTS,备受期待的 elementary OS 6 终于可以下载了。 + +![](https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/08/elementary-os-6-release.jpg?w=1200&ssl=1) + +[2021 年最值得期待的 Linux 发行版][1] 之一,终于来了。 + +elementary OS 6 基于 Ubuntu 20.04 LTS,它大幅改进了用户体验和安全性。 + +虽然我们已经列出了 [elementary OS 6 的新功能列表][2],但咱们还是来看看本次更新的主要亮点吧。 + +### 正式引入暗黑模式 + +![][3] + +elementary OS 6 加入这个功能可能为时太晚,但至少他们做了极大的努力,让整个系统拥有一致的暗黑模式体验。 + +你也会注意到,预装应用和应用中心里部分适配过的应用都支持暗黑模式。 + +暗黑模式在安装 elementary OS 6 后也可以直接在欢迎页设置。 + +### 通知优化 + +![][4] + +通知现在支持操作按钮和图标徽章,视觉更舒适,也更加易用。 + +### Flatpak 优先原则 + +![][5] + +为了加强隐私保护和安全性,elementary OS 6 提供了开箱即用的 Flatpak 应用支持。 + +现在,不仅仅是系统应用,在应用中心,所有应用都已经打包为 Flatpak 格式。 + +### 多点触控手势 + +![][6] + +对于触控板和触摸屏用户,elementary OS 6 带来了不错的手势交互,你完全可以借助手势来穿梭于系统中。 + +你甚至可以通过手势来忽略通知。 + +### 新应用,新更新 + +本次更新中,待办事项和固件更新正式加入预装应用。 + +同时,大部分系统应用(如邮件)也重构了 UI,以及获得了一些新功能。 + +### 其他重要改进 + +![][7] + +如果你想了解更多关于本次更新的内容,我强烈建议你试用 elementary OS 6 来自行探索。 + +当然,如果你现在就想速览其他重要的新功能,那么我列出几个: + + * 在安装应用中心之外的第三方应用时会有警告。 + * 在向终端粘贴需要 root 权限的命令时会有警告。 + * 更便于区分多任务视图中活动窗口的细节变化。 + * 系统设置内置了在线账户集成。 + * 辅助功能优化。 + * 全新壁纸。 + * 改进的安装器。 + +### 下载 elementary OS 6 + +你现在可以从 elementary OS 的官网获取 elementary OS 的最新版本。如需了解详情,你也可以查阅 [官方公告][8]。 + +- [下载 elementary OS 6][9] + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/elementary-os-6-release/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[imgradeone](https://github.com/imgradeone) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://news.itsfoss.com/linux-distros-for-2021/ +[2]: https://news.itsfoss.com/elementary-os-6-features/ +[3]: https://news.itsfoss.com/wp-content/uploads/2021/08/onboarding-dark.png +[4]: https://news.itsfoss.com/wp-content/uploads/2021/06/notification-badge-elementary-os-6.png +[5]: https://news.itsfoss.com/wp-content/uploads/2021/08/appcenter.png +[6]: https://news.itsfoss.com/wp-content/uploads/2021/08/multitouch-multitasking.png +[7]: https://news.itsfoss.com/wp-content/uploads/2021/08/elementary-os-6-terminal-paste-protection.png +[8]: https://blog.elementary.io/elementary-os-6-odin-released/ +[9]: https://elementary.io diff --git a/published/20210811 Top 11 New Features in elementary OS 6 Linux Release.md b/published/20210811 Top 11 New Features in elementary OS 6 Linux Release.md new file mode 100644 index 0000000000..e43ef67969 --- /dev/null +++ b/published/20210811 Top 11 New Features in elementary OS 6 Linux Release.md @@ -0,0 +1,174 @@ +[#]: subject: "Top 11 New Features in elementary OS 6 Linux Release" +[#]: via: "https://news.itsfoss.com/elementary-os-6-features/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lujun9972" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13678-1.html" + +elementary OS 6 Linux 中的 11 个亮点 +====== + +> elementary OS 6 终于来了。让我们看一下这个主要版本中的重要亮点。 + +![](https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/08/elementary-os-6-features.png?w=1200&ssl=1) + +elementary OS 6 是其 5.x 系列经过几年更新后的一次重大升级。 + +虽然 5.x 系列也有许多功能更新和改进,但 [elementary OS 6][1] 的努力成果看起来令人兴奋。 + +在这里,让我们来看看 elementary OS 6 引入的所有新功能和变化。 + +### 1、暗黑风格及强调色 + +![][2] + +[elementary OS][3] 暗黑风格的主题与现在主流的工作方式类似,是一种选择的偏好。你可以在安装 elementary OS 6 之后,在欢迎屏幕上选择它。 + +虽然增加暗黑模式听起来像是小事一桩,但他们似乎投入了大量的精力来提供一个整体一致的暗黑模式体验。 + +所有的第一方应用程序都无缝地支持暗黑风格和浅色主题。 + +elementary OS 还让应用开发者在 elementary OS 6 中遵照用户的偏好。因此,如果用户喜欢暗黑模式或浅色模式,应用程序就可以适应这种模式。 + +伴随着新的强调色的出现,还有一个自动的强调色偏好,可以从你当前的壁纸中挑选出强调的颜色。 + +### 2、改进的通知及重新设计的通知中心 + +通知现在支持图标徽章和行动按钮,这应该能提供更好的体验。 + +![][4] + +这可以让你快速打开链接、标记一条消息已读,以及其他几种可能的操作。 + +紧急通知有了新的外观和独特的声音,以帮助你识别它们。 + +除了通知方面的改进,通知中心也进行了改造,使其看起来更好,并可以对多个通知进行清理。 + +### 3、在线账户 + +终于,在 elementary OS 6 中,你能够从系统设置中添加在线账户了。 + +一旦登录,你的数据将在支持的系统应用程序(如日历、任务)中同步。 + +它也会显示在系统托盘通知中。 + +### 4、第一方 Flatpak 应用及权限查看 + +为了提高整个平台的隐私和安全,elementary OS 6 采用了优先选择 Flatpak 的方式。 + +Elementary OS 现在有自己的应用中心 Flatpak 资源库。一些默认的应用程序以 Flatpak 包的形式出现,应用中心列出的所有应用程序也都有 Flatpak。 + +总的来说,这意味着更好的沙盒体验,你的所有应用程序将保持相互隔离,不会访问你的敏感数据。 + +![][5] + +而且,最重要的是,elementary OS 6 增加了“门户”功能,应用程序会请求权限,以访问你的文件或启动另一个应用程序。 + +你还可以从系统设置中控制所有的权限。 + +### 5、多点触控手势 + +![][6] + +对于笔记本电脑和触摸板用户来说,新的多点触控手势将变得非常方便。 + +从访问多任务视图到浏览工作区,你都可以用多点触摸手势来完成。 + +不仅仅局限于桌面上的某些功能,你还可以与通知互动、滑过应用程序,并可以通过新的多点触控手势获得全系统的顺滑体验。 + +你可以自定义手势或从系统设置下的手势部分了解更多信息。 + +### 6、屏幕盾牌 + +在 elementary OS 5 中,有些人注意到当你想运行一个耗时的任务或简单地观看视频时,会出现自动锁定屏幕的问题。 + +然而,这种情况在 elementary OS 6 中得到了改变,它不仅解决了这个问题,还以 “屏幕盾牌” 功能的形式带来了新的实现方式。 + +因此,在观看视频或执行耗时的任务时,你可以轻松地保持系统的清醒,而不会突然中断。 + +它利用了 GNOME 的守护程序设置,与第三方应用程序有更好的兼容性。 + +### 7、新的任务应用 + +![][7] + +elementary OS 6 中添加了一个新的任务应用,在那里你可以管理任务、收到提醒,并在你的系统上组织任务,或与在线账户同步。 + +我可能还不会用它来取代 Planner,但它是一个很好的补充,因为它打造的很好。 + +### 8、固件更新应用程序 + +![][14] + +你可以为支持的设备获得最新的固件更新,而无需摆弄任何其他设置。 + +只要从菜单中寻找“固件”应用程序就可以开始了。 + +### 9、更新的应用程序 + +一些应用程序已经被更新,同时引入了新的功能。 + +例如,Epiphany 浏览器被重新命名为 “Web”,现在有 Flatpak 包可用,以方便快速更新。 + +它还包括内置的跟踪保护和广告拦截。 + +其他一些值得注意的变化包括: + + * 相机应用获得了一个新的用户界面,可以切换相机、镜像图像等等。 + * 应用中心现在不仅列出了 Flatpak 应用程序,而且还在应用程序完成安装后通知你,让你快速打开它。 + * 文件应用程序也得到了改进,其形式是一个新的侧边栏和列表视图。另外,现在需要双击才能打开一个文件,而单次点击可以在文件夹中导航。 + +其他应用程序如邮件、日历也得到了改进,以便更好地进行在线整合。 + +### 10、改进的桌面工作流程及屏幕截图工具 + +![][8] + +多任务视图现在可以帮助你明确区分多个活动窗口。而热角视图可以让你将窗口移动到新的工作区,也可以将窗口最大化。 + +![][9] + +屏幕截图工具可以在窗口中移动,而不仅仅是停留在窗口的中心。你还可以从预览中拖放图片,而不需要保存。 + +### 11、改进的安装程序 + +![][10] + +你会注意到一些新的微妙的动画,而且还做了一些努力,以便在不重新调整窗口大小的情况下提供一个一致的安装程序布局。 + +这不是一次大修,但他们提到新的安装程序带有改进的磁盘检测和错误处理功能,这应该能使安装顺滑进行。 + +### 总结 + +[elementary OS 6][3] 是一个激动人心的版本,有多项改进。尽管外观和感觉并没有完全改变,但它已被全面精心雕琢。 + +我喜欢他们为提供一致和漂亮的用户体验所做的工作。另外,像全系统的 Flatpak 这样的变化应该使用户更容易和更安全。 + +你对这个版本有什么看法?你试过了吗? + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/elementary-os-6-features/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://news.itsfoss.com/elementary-os-6-release/ +[2]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/07/dark-style-elementary.jpg?w=1200&ssl=1 +[3]: https://elementary.io +[4]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/notification-badge-elementary-os-6.png?w=724&ssl=1 +[5]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/08/elementary-os-6-permissions.png?resize=1568%2C1158&ssl=1 +[6]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/08/multitouch-multitasking.png?resize=1568%2C883&ssl=1 +[7]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/08/tasks.png?resize=1568%2C1188&ssl=1 +[8]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/08/window-context-dark.png?w=808&ssl=1 +[9]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/08/screenshot.png?w=660&ssl=1 +[10]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/08/installer-progress.png?resize=1568%2C1140&ssl=1 +[14]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/08/firmware.png?resize=1568%2C1158&ssl=1 \ No newline at end of file diff --git a/published/20210812 A Java developer-s guide to Quarkus.md b/published/20210812 A Java developer-s guide to Quarkus.md new file mode 100644 index 0000000000..cee601ce54 --- /dev/null +++ b/published/20210812 A Java developer-s guide to Quarkus.md @@ -0,0 +1,52 @@ +[#]: subject: "A Java developer's guide to Quarkus" +[#]: via: "https://opensource.com/article/21/8/java-quarkus-ebook" +[#]: author: "Daniel Oh https://opensource.com/users/daniel-oh" +[#]: collector: "lujun9972" +[#]: translator: "geekpi" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13690-1.html" + +下载《Quarkus 的 Java 开发者指南》电子书 +====== + +> 一本新的展示了开发者如何继续使用 Java 框架来构建新的无服务器功能的电子书。 + +![](https://img.linux.net.cn/data/attachment/album/202108/17/100432yslvlw6s2d462w41.jpg) + +[无服务器][2] 架构已经成为一种高效的解决方案,无论是物理服务器、虚拟机还是云环境,都可以根据实际工作负载调整超额配置和不足配置资源(如 CPU、内存、磁盘、网络)。然而,在选择新的编程语言来开发无服务器应用时,Java 开发者有一个担忧。对于云上的无服务器部署,尤其是 [Kubernetes][3],Java 框架似乎过于沉重和缓慢。 + +作为 Java 开发者,如果可以继续使用 Java 框架来构建传统的云原生微服务以及同时构建新的无服务器功能呢?这种方法应该是令人兴奋的,因为你不必担心新的无服务器应用框架的学习曲线会很陡峭。 + +此外,如果 Java 框架不仅可以为开发者提供熟悉技术的乐趣,还可以在启动时以毫秒为单位优化 Kubernetes 中的 Java 无服务器功能,并提供微小的内存足迹,又会怎样? + +### 什么是 Quarkus? + +[Quarkus][4] 是一个新的 Java 框架,可以为 Java 开发者、企业架构师和 DevOps 工程师提供这些功能和好处。它旨在设计无服务器应用,并编写云原生微服务,以便在云基础设施(例如 Kubernetes)上运行。 + +Quarkus 还支持一个名为 [Funqy][5] 的可移植 Java API 扩展,供开发者编写和部署无服务器功能到异构无服务器运行时。 + +Quarkus Funqy 使开发者能够将 [CloudEvents][6] 与 Knative 环境中的无服务器函数绑定,以处理反应式流。这有利于开发者建立一个通用的消息传递格式来描述事件,提高多云和混合云平台之间的互操作性。 + +在我的新电子书 《[Java 无服务器功能指南][7]》的帮助下,开始你的 Quarkus 之旅。与他人分享你的 Quarkus 经验,让大家都能享受到用 Java 和 Quarkus 进行的无服务器开发。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/8/java-quarkus-ebook + +作者:[Daniel Oh][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/daniel-oh +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/java-coffee-mug.jpg?itok=Bj6rQo8r (Coffee beans and a cup of coffee) +[2]: https://opensource.com/article/21/1/devapps-strategies +[3]: https://opensource.com/article/19/6/reasons-kubernetes +[4]: https://quarkus.io/ +[5]: https://quarkus.io/guides/funqy +[6]: https://cloudevents.io/ +[7]: https://opensource.com/downloads/java-serverless-ebook diff --git a/published/20210814 What is SteamOS- Everything Important You Need to Know About This -Gaming Distribution.md b/published/20210814 What is SteamOS- Everything Important You Need to Know About This -Gaming Distribution.md new file mode 100644 index 0000000000..223f78ff39 --- /dev/null +++ b/published/20210814 What is SteamOS- Everything Important You Need to Know About This -Gaming Distribution.md @@ -0,0 +1,140 @@ +[#]: subject: "What is SteamOS? Everything Important You Need to Know About This “Gaming Distribution”" +[#]: via: "https://itsfoss.com/steamos/" +[#]: author: "Ankush Das https://itsfoss.com/author/ankush/" +[#]: collector: "lujun9972" +[#]: translator: "imgradeone" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-13688-1.html" + +SteamOS 是什么?关于这款“游戏发行版”你所要知道的事 +====== + +![](https://img.linux.net.cn/data/attachment/album/202108/16/113402ass3smho7sbmo75b.jpg) + +SteamOS 是一款基于 Linux 的操作系统,旨在提供来自 Steam 自己的游戏商店顺滑的游戏体验。 + +虽然它已经存在了许久,但有几件事你应该知道。 + +在这篇文章中,我们将回答许多 SteamOS 相关的常见问题。 + +### SteamOS 是什么? + +SteamOS 是由游戏分发平台 Steam 开发的 Linux 发行版。它并是一款像 Debian、Linux Mint 或者 Ubuntu 那样的泛用型桌面操作系统,即便你确实可以使用桌面功能。默认情况下,SteamOS 的界面类似于游戏机,因为 SteamOS 旨在成为专为 Steam 游戏设备定制的操作系统,如 Steam Machine(已停产)和 Steam Deck。 + +![SteamOS 界面][1] + +你确实也可以在任何 Linux 发行版和其他平台安装 Steam 客户端,但 SteamOS 更是为了提供类似游戏机的体验,方便你玩 Steam 上的游戏。 + +### SteamOS 基于哪个 Linux 发行版? + +作为基于 Linux 的系统,SteamOS 最初基于 Debian 8 开发。随着 Valve 的全新 [Steam Deck][2] 掌机发布,SteamOS 的最新版本(SteamOS 3.0)将基于 Arch Linux 开发,因为 Arch 支持滚动更新。 + +SteamOS 的开发团队也相信,SteamOS 基于 Arch Linux 更有利于快速推送更新和优化 Steam Deck。 + +![][3] + +### SteamOS 的系统要求 + +理想情况下,符合以下最低要求的设备都应该可以正常运行 SteamOS: + + * Intel / AMD 的 64 位 CPU + * 4GB 或更高的运行内存(RAM) + * 250GB 或更大的磁盘 + * NVIDIA / Intel / AMD 的显卡 + * 用于安装介质的 USB 或者 DVD + +(LCTT 译注:本段内容仅针对 SteamOS 2.0。) + +### SteamOS 能否在你的电脑上正常运作? + +SteamOS(2.0 版本)内置了支持特定硬件的驱动程序。 + +理论上 SteamOS 可以在任何电脑上运行,但目前官方并没有支持最新的硬件。 + +### SteamOS 只是又一款 Linux 发行版吗? + +SteamOS 严格来说已经是现有的 [适合游戏的 Linux 发行版][4] 之一。但与其他发行版不同的是,SteamOS 并不是为了泛用型桌面而设计的。你确实可以安装 Linux 程序,但 SteamOS 支持的软件包极为有限。 + +总之,它并不适合替代普通 Linux 桌面系统。 + +### SteamOS 现在还在积极维护中吗? + +**是**,但又**不是**。 + +SteamOS 基于 Debian 8 许久,目前没有任何更新。 + +如果你正期望将 SteamOS 安装到你的个人设备上,那么目前公开发布的版本(SteamOS 2.0)已经处于不再维护的状态。 + +不过,Valve 目前正在为 Steam Deck 维护 SteamOS 3.0。因此,可能不久 SteamOS 就可以用于你的桌面了。 + +### 你是否推荐使用 SteamOS 来玩电脑游戏吗? + +**不推荐**。 在 Windows 和其它 Linux 发行版面前,SteamOS 并不是你应该选择的替代品。 + +虽然 SteamOS 主要是为游戏定制的,但在拿它玩游戏之前,你还需要了解许多注意事项。 + +### 所有游戏都可以在 SteamOS 上玩吗? + +**不**。 SteamOS 需要依赖 Proton 兼容层才能让 Windows 平台的游戏正常运行。 + +当然,如今借助同样的底层技术,[在 Linux 里玩游戏][5] 已经成为了可能,但至少在我写这篇文章时,你并不能让 Steam 上架的所有游戏都可以在 Linux 中运行。 + +虽然大部分游戏都可以运行,但这并不意味着你游戏库里的所有游戏都能正常游玩。 + +如果你想玩 Steam 支持的游戏,以及仅限于 Linux 平台的游戏,那还是值得一试的。 + +### SteamOS 是否开源? + +**是的**(SteamOS 2.0)。 + +SteamOS 操作系统是开源的,你可以在 [官方仓库][6] 中找到源码。 + +不过,你用来玩游戏的 Steam 客户端是专有的。 + +值得注意的是,SteamOS 3.0 目前仍处于开发阶段,因此你无法获得它的源代码和任何公开进展。 + +### SteamOS 是否免费使用? + +目前你暂时无法找到可供公众使用的最新版 SteamOS,但它基本上是免费的。基于 Debian 的旧版 SteamOS 可在其 [官方网站][7] 上获取。 + +### 我能找到内置 SteamOS 的游戏主机吗? + +![Steam Machine 游戏机,已经停产][8] + +SteamOS 最初是为 Steam Machine 这款 Steam 自家的 PlayStation/Xbox 风格的游戏机定制的操作系统。2015 年 Steam Machine 发布后并没有在市场上获得成功,最终停产。 + +目前,唯一一款预装 SteamOS 的设备是备受瞩目的 Steam Deck。 + +待到 SteamOS 开放针对其它设备的下载后,你就可以看到有硬件厂商销售预装 SteamOS 的游戏设备了。 + +但,至少目前来看,你不应该相信任何不知名的制造商提供开箱即用的 SteamOS。 + +### 下一代 SteamOS 能否使 Linux 成为游戏的可行选择? + +是的,绝对是的。 + +Linux 可能不是外界所推荐的游戏选择,但如果你乐意的话,你也可以查看 [我们所推荐的 Linux 游戏发行版][9]。最后,如果 SteamOS 下了狠心,让每款游戏都能在 Steam Deck 上运行,那么桌面 Linux 用户也将终于可以体验到所有曾经不支持的 Steam 游戏了。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/steamos/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[imgradeone](https://github.com/imgradeone) +校对:[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/wp-content/uploads/2021/08/steamos.jpg +[2]: https://www.steamdeck.com/en/ +[3]: https://itsfoss.com/wp-content/uploads/2021/08/steam-deck.jpg +[4]: https://itsfoss.com/linux-gaming-distributions/ +[5]: https://itsfoss.com/linux-gaming-guide/ +[6]: https://repo.steampowered.com/steamos/ +[7]: https://store.steampowered.com/steamos/ +[8]: https://itsfoss.com/wp-content/uploads/2021/08/valves-steam-machine.jpg +[9]: https://news.itsfoss.com/linux-for-gaming-opinion/ diff --git a/sources/news/20210601 Firefox 89 is Here with a Revamped Design and Improved Features.md b/sources/news/20210601 Firefox 89 is Here with a Revamped Design and Improved Features.md deleted file mode 100644 index ce4020a1cf..0000000000 --- a/sources/news/20210601 Firefox 89 is Here with a Revamped Design and Improved Features.md +++ /dev/null @@ -1,112 +0,0 @@ -[#]: subject: (Firefox 89 is Here with a Revamped Design and Improved Features) -[#]: via: (https://news.itsfoss.com/firefox-89-release/) -[#]: author: (Jacob Crume https://news.itsfoss.com/author/jacob/) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Firefox 89 is Here with a Revamped Design and Improved Features -====== - -Firefox has long been the default web browser for many popular distributions such as Ubuntu and Manjaro. It is well known for its privacy features, as well as being completely open source. - -It has had many notable UI redesigns over the years, of which the latest was the Photon design. Although this design did improve the UI, Google Chrome has remained the browser king. - -In this release, Mozilla seems to be targeting Chrome with their new UI and new privacy features. - -### What’s New? - -Although the feature list is not particularly long, it will make a significant impact on the future of Firefox, I believe. The main new features are as follows: - - * Brand-new Proton UI - * Streamlined menu - * Calmer visuals - * Total Cookie Protection in private browsing mode - - - -In this article, we will be diving into what these are, and what impact they will have on Firefox’s future. - -#### New Proton UI - -![][1] - -By far the biggest change, this UI redesign is a huge step in the right direction. - -We already have a separate article dedicated to [the new Proton user interface][2], if you are curious to know what exactly are the changes involved in the redesign. - -![][3] - -As key highlights, the redesign involves: - - * A redesigned toolbar - * A new hamburger menu - * A redesigned address bar - * New animations while moving tabs - - - -The result is a much more modern-looking browsing experience. While some people may not like the larger UI elements and rounded corners, my experience with the beta has been incredibly positive. - -![][3] - -Overall, the interface is clean, with calmer visuals, and aims to provide you fewer distractions. - -This is the key highlight of Firefox 89 release – so you should give it a spin before you start to love it or hate it! - -#### Privacy Improvements - -First introduced in Firefox 86, Total Cookie Protection is Firefox’s way of dealing with the many security concerns associated with cookies. - -It works by putting each website’s cookies into a separate virtual cookie jar. These cookie jars are only able to be opened by the website that created them, making cross-website tracking much harder. - -Previously, this awesome feature was only available in Firefox’s ETP Strict mode. With Firefox 89, this awesome feature becomes more prominent, now becoming part of Firefox’s private browsing mode. - -This, along with the presence of [SmartBlock feature][4] (introduced in Firefox 87) should be an exciting combination. - -For more information on Total Cookie Protection, have a look at the initial release in our [coverage of Firefox 86][5]. - -### Other Improvements - -The release also includes some bug fixes and security updates. You can explore more about what has changed for other platforms like macOS in their [official release note][6]. - -### Wrapping Up - -It is praiseworthy to see Mozilla’s continued support for Firefox to protect user privacy, and this really shines through with this release. - -Between the hugely improved UI, and the new privacy features, Firefox 89 is a great release. As a privacy-oriented individual, I am really excited about Total Cookie Prevention by default in private browsing mode. - -[Download Mozilla Firefox 89][7] - -On the other hand, I also think Mozilla should stop making constant design overhauls and make refinements to a particular design over the time. While it is important to improve user experience, UI overhauls often break the workflow, which is not a good thing. - -I hope this is the last re-design Firefox implements and shifts its focus on performance, convenience, and gaining back the lost market share to Google Chrome and other chrome-based web browsers. - -#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! - -If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. - -I'm not interested - --------------------------------------------------------------------------------- - -via: https://news.itsfoss.com/firefox-89-release/ - -作者:[Jacob Crume][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://news.itsfoss.com/author/jacob/ -[b]: https://github.com/lujun9972 -[1]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQ5NyIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= -[2]: https://news.itsfoss.com/firefox-proton-redesign/ -[3]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQzOSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= -[4]: https://blog.mozilla.org/security/2021/03/23/introducing-smartblock/ -[5]: https://news.itsfoss.com/firefox-86-release/ -[6]: https://www.mozilla.org/en-US/firefox/89.0/releasenotes/ -[7]: https://www.mozilla.org/firefox/download/ diff --git a/sources/news/20210602 OBS Studio 27 Adds Wayland Support, Undo-Redo, and Browser Docks.md b/sources/news/20210602 OBS Studio 27 Adds Wayland Support, Undo-Redo, and Browser Docks.md deleted file mode 100644 index b42e71cb8b..0000000000 --- a/sources/news/20210602 OBS Studio 27 Adds Wayland Support, Undo-Redo, and Browser Docks.md +++ /dev/null @@ -1,99 +0,0 @@ -[#]: subject: (OBS Studio 27 Adds Wayland Support, Undo/Redo, and Browser Docks) -[#]: via: (https://news.itsfoss.com/obs-studio-27-release/) -[#]: author: (Ankush Das https://news.itsfoss.com/author/ankush/) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -OBS Studio 27 Adds Wayland Support, Undo/Redo, and Browser Docks -====== - -Open Broadcaster Software is a free and open-source streaming/recording solution available for multiple platforms. - -Not long ago, we [spotted native Wayland support coming to OBS Studio][1]. - -Now, with the release of OBS Studio 27, it is finally a reality. Not just limited to wayland support, but there are some significant feature additions. - -Here, I shall highlight the key changes introduced with OBS Studio 27. - -### OBS Studio 27: What’s New? - -![][2] - -The key new feature addition with this release is **Undo/Redo**. - -While it sounds like a basic feature that should have existed from the start — but they needed to have a proper implementation, for which they waited. - -The [release announcement][3] mentions a note about it back in 2018: - -> _This is on the agenda. Fortunately, it’s not a “difficult” feature to write, it’s actually pretty simple, but the implementation is what’s delicate, and requires a fair amount of experience to get right._ - -Now that it is here, you can work stress-free without needing to constantly tweak when you accidentally modify something. - -Of course, there’s a limit to what the Undo function can do, and it looks like it should be able to revert **5000 actions** in a particular session. It is worth noting that if you restart the app, you can no longer undo the last actions. - -![][4] - -More about it in the announcement post: - -> Undo is built to track actions that affect the preview. This means every potential modification to scenes, sources, groups, filters, stingers, and scripts. These have the potential to affect the feed in real-time, without a chance to “Apply” changes, and can sometimes result in complex changes that are harder to quickly revert or recreate. The Undo stack is capable of tracking the last 5,000 actions of the session, and is cleared when switching scene collections or restarting the app. - -The next important addition is the **browser dock**, which was already present for Windows users but introduced for macOS and Linux with this release. - -The dock will let you quickly access other sites or services while using the OBS app such as chats, Twitch account linking, and more. - -### Other Improvements - -The release also addresses the display capture support on Laptops with different GPUs, which should provide a good experience for Laptop users. - -There’s also a new missing files dialogue which will clearly list what’s missing to spot the sources that you need to add. - -For more information on the changes, you may refer to the [official announcement post][3]. - -### Download OBS Studio 27 - -You can directly install OBS Studio using the Ubuntu PPA but the Wayland support is available only for Ubuntu 21.04 and above through this method. - -In case you want to do that, here’s what you need to type in the terminal (ensure you have [ffmpeg][5] installed): - -``` -sudo add-apt-repository ppa:obsproject/obs-studio -sudo apt install obs-studio -``` - -So, it is best to use the [Flatpak package][6] to get started. You can also take the help of our [Flatpak guide][7] if you’re using it for the first time. - -You can find other download options in the official download page or its [GitHub page][8]. - -[Download OBS Studio 27][9] - -#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! - -If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. - -I'm not interested - --------------------------------------------------------------------------------- - -via: https://news.itsfoss.com/obs-studio-27-release/ - -作者:[Ankush Das][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://news.itsfoss.com/author/ankush/ -[b]: https://github.com/lujun9972 -[1]: https://news.itsfoss.com/obs-studio-wayland/ -[2]: https://i0.wp.com/i.ytimg.com/vi/LUkMxYNIyj0/hqdefault.jpg?w=780&ssl=1 -[3]: https://obsproject.com/blog/obs-studio-27-released -[4]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQyMyIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= -[5]: https://itsfoss.com/ffmpeg/ -[6]: https://flathub.org/apps/details/com.obsproject.Studio -[7]: https://itsfoss.com/flatpak-guide/ -[8]: https://github.com/obsproject/obs-studio -[9]: https://obsproject.com/download diff --git a/sources/news/20210603 You Can Now Try the New COSMIC Desktop Environment with Pop-_OS 21.04 Beta.md b/sources/news/20210603 You Can Now Try the New COSMIC Desktop Environment with Pop-_OS 21.04 Beta.md deleted file mode 100644 index 6a08460085..0000000000 --- a/sources/news/20210603 You Can Now Try the New COSMIC Desktop Environment with Pop-_OS 21.04 Beta.md +++ /dev/null @@ -1,94 +0,0 @@ -[#]: subject: (You Can Now Try the New COSMIC Desktop Environment with Pop!_OS 21.04 Beta) -[#]: via: (https://news.itsfoss.com/pop-os-21-04-beta-release/) -[#]: author: (Ankush Das https://news.itsfoss.com/author/ankush/) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -You Can Now Try the New COSMIC Desktop Environment with Pop!_OS 21.04 Beta -====== - -Pop!_OS 21.04 is one of the [most anticipated distros][1] of this year and the public beta has finally arrived. - -While we do not have an official list of changes that follows with this release, but it comes packed with its brand new COSMIC Desktop Environment. - -Let me highlight a few things about the desktop, how you can download it, and my initial thoughts on it. - -### COSMIC Desktop Environment on Pop!_OS 21.04 - -![][2] - -With Pop!_OS 21.04 beta, we have more information on it than we had when [System76 first revealed the COSMIC Desktop Environment][3]. - -The horizontal dock sure looks pretty. By default, the dock extends to the edges of the screen, but you can change that as well. Here’s how it looks without the dock extending (macOS-like layout?) - -![][4] - -The icons look colorful and attractive. You will find options to tweak the dock as well (to hide it, change the position, etc.) - -There are some options like adding a launcher icon or workspace icon in the dock itself that are in the to-do list and should be added with the updates to beta version. In addition to that, you can also expect the hot corner feature to arrive soon enough. - -![][5] - -### Other Improvements - -The overall color theme looks to be the same — so there are subtle visual changes, no big makeovers. - -Coming from Pop!_OS 20.04, it will surely feel quite unfamiliar, and you will need to take some time to adjust the workflow. - -However, thanks to the extension manager, you can get back the old workspace layout by disabling the Pop COSMIC extension. Also, you get a nice multi-monitor add-on that offers many options for users with multi-monitors. - -![][6] - -The desktop environment seems to be using GNOME 3.38 based applications. So, it is safe to assume that the COSMIC Desktop Environment is based on the same as well. - -It is important to note that the LTS release (i.e. Pop!_OS 20.04) will not be getting an update to include COMIC Desktop Environment. - -So, you will have to opt for Pop!_OS 21.04 stable version when it releases or just wait for the next LTS release that follows. - -### Pop!_OS 21.04 Without GNOME 40 Is Exciting - -As I expected, even without the direct implementation of GNOME 40, Pop!_OS 21.04 is an exciting release to look out for. - -The COSMIC Desktop Environment may not be a unique or breathtaking experience – but it manages to add essential options out of the box for a great desktop experience. - -Also, considering that multi-monitor users do not usually get an outstanding set of options on other Linux distributions by default, including an add-on for that with COSMIC desktop is a good idea. - -### Try Pop!_OS 21.04 Beta - -You can download the Pop!_OS 21.04 beta ISO from their [GitHub page][7]. You can find both the images for NVIDIA, and AMD/Intel as per your system configuration. - -Do note that this is a beta release and should be only installed for testing purposes. It is prone to bugs, and you may have to re-install it. - -The stable release should come out later this month, I will make sure to review it and also possibly make a video, if that helps. - -[Download Pop!_OS 21.04 Beta][7] - -#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! - -If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. - -I'm not interested - --------------------------------------------------------------------------------- - -via: https://news.itsfoss.com/pop-os-21-04-beta-release/ - -作者:[Ankush Das][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://news.itsfoss.com/author/ankush/ -[b]: https://github.com/lujun9972 -[1]: https://news.itsfoss.com/linux-distros-for-2021/ -[2]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQzOCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= -[3]: https://news.itsfoss.com/cosmic-desktop-pop-os/ -[4]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQ0MCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= -[5]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjUwMyIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= -[6]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjMzNCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= -[7]: https://github.com/pop-os/beta diff --git a/sources/news/20210615 PDF Mix Tool 1.0.1 Now Lets You Edit Metadata with an Improved UI - Qt 6 Support.md b/sources/news/20210615 PDF Mix Tool 1.0.1 Now Lets You Edit Metadata with an Improved UI - Qt 6 Support.md new file mode 100644 index 0000000000..4898095a65 --- /dev/null +++ b/sources/news/20210615 PDF Mix Tool 1.0.1 Now Lets You Edit Metadata with an Improved UI - Qt 6 Support.md @@ -0,0 +1,94 @@ +[#]: subject: (PDF Mix Tool 1.0.1 Now Lets You Edit Metadata with an Improved UI & Qt 6 Support) +[#]: via: (https://news.itsfoss.com/pdf-mix-tool-1-0-1-release/) +[#]: author: (Omar Maarof https://news.itsfoss.com/author/omar/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +PDF Mix Tool 1.0.1 Now Lets You Edit Metadata with an Improved UI & Qt 6 Support +====== + +[PDF Mix Tool][1] is one of the [best PDF editors for Linux][2] and an alternative to [PDF Arranger][3]. +It is a neat and simple GUI tool for manipulating pdf files and allows you to modify your files (rotating, splitting, extracting from files), not their content, however. + +Although this application does not come with a lot of tools, it provides a concise toolset so you can manipulate your documents. + +After a year of no new releases, the developer is back with another release (1.0.1) with some significant improvements. + +Let us discover what features this release has to offer. + +### Improved User Interface (UI) + +There is now a left sidebar containing icons for all the operations you might need to perform. Each one of the icons has a respective function and its name below it. + +![][4] + +This is not a big makeover but helps enhancing the user experience, which should be the focus for a useful tool like PDF Mix Tool. + +### PDF Metadata Editing + +![][5] + +You can now modify your document’s title, author, subject, keywords, creator, producer, and creation and modification dates. Thus, you can edit your document’s metadata easily. + +### Support for Qt 6.0 + +PDF Mix Tool is written in C++, and it relies on **qpdf** and the **Qt** library to make its magic work. It supports [Qt 6.0][6] now, which will affect the UX positively. + +### Other Improvements + + * PDF Mix Tool now adds right-to-left support in page composition. + * Links, annotations, and outlines are preserved as much as possible in all operations. + * This version fixed some bugs. + + + +You can check out the [official changelog][7] in their GitLab page. + +### Summing Up + +Despite its reputation for being a lightweight, PDF Mix Tool is a handy application that delivers essential capabilities to the user. + +You can get it from [Flathub][8] or [Snap store][9]. For Arch Linux users, you may not find the latest release in the repositories or the [AUR][10]. In either case, you can build it from source that can be found on [GitLab][11]. + +You may want to go through our [Flatpak guide][12] or the tutorial for [using Snaps in Linux][13] to get help with installation. + +[Download PDFMixTool][14] + +_What do you think about this release? I’m also curious to know what PDF editor do you happen to use?_ + +#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! + +If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. + +I'm not interested + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/pdf-mix-tool-1-0-1-release/ + +作者:[Omar Maarof][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/omar/ +[b]: https://github.com/lujun9972 +[1]: https://scarpetta.eu/pdfmixtool/ +[2]: https://itsfoss.com/pdf-editors-linux/ +[3]: https://news.itsfoss.com/pdf-arranger-1-7-release/ +[4]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjUyMyIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[5]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjU3MiIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[6]: https://news.itsfoss.com/qt-6-released/ +[7]: https://gitlab.com/scarpetta/pdfmixtool/-/blob/master/CHANGELOG.md +[8]: https://flathub.org/apps/details/eu.scarpetta.PDFMixTool +[9]: https://snapcraft.io/pdfmixtool +[10]: https://itsfoss.com/aur-arch-linux/ +[11]: https://gitlab.com/scarpetta/pdfmixtool +[12]: https://itsfoss.com/flatpak-guide/ +[13]: https://itsfoss.com/use-snap-packages-ubuntu-16-04/ +[14]: https://scarpetta.eu/pdfmixtool/#download diff --git a/sources/news/20210719 Edward Snowden Thinks GIMP Needs a Major UI Overhaul.md b/sources/news/20210719 Edward Snowden Thinks GIMP Needs a Major UI Overhaul.md new file mode 100644 index 0000000000..2f3eaf1c2a --- /dev/null +++ b/sources/news/20210719 Edward Snowden Thinks GIMP Needs a Major UI Overhaul.md @@ -0,0 +1,88 @@ +[#]: subject: (Edward Snowden Thinks GIMP Needs a Major UI Overhaul) +[#]: via: (https://news.itsfoss.com/gimp-ui-edward-snowden/) +[#]: author: (Ankush Das https://news.itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Edward Snowden Thinks GIMP Needs a Major UI Overhaul +====== + +Edward Snowden’s recent tweet praised what free and open-source software can achieve. + +In the tweet, he highlights that every time he uses Blender (an open-source 3D software suite), it reminds him of the advantages of FOSS and the growth of the ecosystem. + +He did not just limit to that, in a follow-up reply to the same thread, he also tagged **GIMP** and added, “**I’m really hoping for a major UI overhaul. You guys could be eating Adobe’s lunch.**“ + +> P.S. [@GIMP_Official][1], I'm really hoping for a major UI overhaul. You guys could be eating Adobe's lunch. +> +> — Edward Snowden (@Snowden) [July 18, 2021][2] + +### Does GIMP Require a Major UI Overhaul? + +![][3] + +[GIMP][4] is one of the most effective free and open-source image manipulation tools available. + +It is actively used by professionals and all kinds of individuals to get a variety of things done. + +You can even [make a GIF in GIMP][5]. Hence, it is tailored for simple and advanced tasks. + +While it offers a learning curve to get used to its UI, it is good enough functionality-wise. + +Does it require a UI overhaul? + +Yes, as per the trends, all kinds of designing/editing tools are working to improve the user-friendliness factor, GIMP may have missed out on this front. + +Of course, a sudden UI change may affect the workflow for a lot of veteran users. But, it does require a UI overhaul to beat its competitors like Adobe’s tools. + +Also, with an easy-to-use interface, it will attract more users, potentially helping it grow and monetize the project even further. + +And, it is also clear that Snowden thinks the same way, which is why he is hoping for a major UI overhaul while expecting GIMP to challenge Adobe tools in a big way. + +### Why is GIMP Not Working on a Major User Experience Overhaul Yet? + +Unfortunately, GIMP does not have regular UX contributors or developers to work on a major overhaul. + +They mentioned it as a reply to one of the tweets in Snowden’s tweet thread: + +> “We worked with a UX architect between 2005 and 2012. Good things came out of it. We make small UX improvements in almost every update now that point releases (e.g. 2.10.24) are allowed to have new stuff. But we don’t have a regular UX contributor or devs for a huge overhaul” + +Well, this is definitely a sad thing for such a popular project that gets immense love from thousands of users. + +And, I hope, after Snowden’s tweet, the GIMP project gets more traction and we see regular contributors to help evolve GIMP with the love it deserves. + +If you want to help, you can explore [GIMP’s contribution page][6] to learn more about helping the project. + +_Feel free to let me know your thoughts on GIMP and if you find it useful. Do you think that it needs a major UI overhaul, comments section is all yours!_ + +**Image Credits (Snowden’s image)**: [TheGuardian][7] + +#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! + +If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. + +I'm not interested + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/gimp-ui-edward-snowden/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://twitter.com/GIMP_Official?ref_src=twsrc%5Etfw +[2]: https://twitter.com/Snowden/status/1416778909358731266?ref_src=twsrc%5Etfw +[3]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQzMCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[4]: https://www.gimp.org +[5]: https://itsfoss.com/make-gif-in-gimp/ +[6]: https://www.gimp.org/develop/ +[7]: https://www.theguardian.com/books/2019/aug/01/edward-snowden-memoir-to-reveal-whistleblowers-secrets-permanent-record diff --git a/sources/news/20210720 You Can Now Use KDE Connect in Windows as Well.md b/sources/news/20210720 You Can Now Use KDE Connect in Windows as Well.md new file mode 100644 index 0000000000..12967b2eef --- /dev/null +++ b/sources/news/20210720 You Can Now Use KDE Connect in Windows as Well.md @@ -0,0 +1,91 @@ +[#]: subject: (You Can Now Use KDE Connect in Windows as Well) +[#]: via: (https://news.itsfoss.com/kde-connect-windows/) +[#]: author: (Ankush Das https://news.itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: (imgradeone) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +You Can Now Use KDE Connect in Windows as Well +====== + +KDE Connect is a popular open-source tool that lets you share a connection between a phone and your computer. + +While it was always limited to the Linux platform, it looks like that it is coming to Windows after all. + +And, cross-platform availability of software is always a good thing. + +### What is KDE Connect? + +In case you are coming across it for the first time—KDE connect lets you share files, links, sync notifications, gives you the ability to reply to messages, and more. + +You can also choose to control your desktop and perform some custom commands remotely. And, you can also use your phone to control the volume/skip the music playing on your computer. + +### KDE Connect Available as Beta in Microsoft Store + +![][1] + +As per a Reddit thread posted a few weeks back, a KDE contributor mentions that the beta version is available from the [Microsoft Store][2]. + +However, it is only accessible through the private link and cannot be found when you search for it in the Microsoft Store. + +This also marks official support for Windows. + +![][3] + +### KDE Connect for Windows: Here’s How it Looks + +![][4] + +You just need to make sure that both of your devices are connected to the same network. + +Next, all you have to do is pair them and then start sharing files/links, browse your phone, and also get notifications. + +You can choose to tweak some of the options that include storage paths for shared images or change the sound to play when you try to ring the device. + +![][5] + +As you can notice here, you have a variety of options to make use of. + +I tried connecting my Android device for a while, and it worked just fine. You may want to explore more to learn what else you can do with it. + +### Why is it Good News for Windows Users? + +Undoubtedly Windows users already had plenty of options to achieve the same functions without KDE Connect. But with KDE connect onboard, it will finally provide the opportunity to use an open-source and privacy-friendly tool that they can pair their devices with. + +After all, you would not want your notifications, and links/files that you share to be spied upon by a shoddy third-party application. + +In that case, KDE Connect is your friend. + +Even though it is in beta right now. You can try it out by visiting the link and installing it from the Microsoft store. + +[KDE Connect on Microsoft Store][2] + +**Via**: [Omg!Ubuntu!][6] + +#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! + +If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. + +I'm not interested + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/kde-connect-windows/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjIyOCIgd2lkdGg9Ijc2MyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[2]: https://www.microsoft.com/en-gb/p/kde-connect/9n93mrmsxbf0?&activetab=pivot:overviewtab +[3]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjI4NyIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[4]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQ2NiIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[5]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQ2MyIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[6]: https://www.omgubuntu.co.uk/2021/07/kde-connect-windows-app diff --git a/sources/news/20210818 Top 9 Features in the Newly Released Zorin OS 16 Linux Distribution.md b/sources/news/20210818 Top 9 Features in the Newly Released Zorin OS 16 Linux Distribution.md new file mode 100644 index 0000000000..c5d5dade29 --- /dev/null +++ b/sources/news/20210818 Top 9 Features in the Newly Released Zorin OS 16 Linux Distribution.md @@ -0,0 +1,126 @@ +[#]: subject: "Top 9 Features in the Newly Released Zorin OS 16 Linux Distribution" +[#]: via: "https://news.itsfoss.com/zorin-os-16-features/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Top 9 Features in the Newly Released Zorin OS 16 Linux Distribution +====== + +Zorin OS 16 is a gorgeous Linux distribution. With the latest release, there are several helpful feature additions to the distribution. + +While we have [highlighted the key updates in our release coverage][1], I shall focus on some of the best features you can find in Zorin OS 16. + +### 1\. Jelly Mode + +![][2] + +Jelly Mode adds an engaging animation when you minimize or move the window on your screen. + +It is more like a wobble effect when you move the windows and a fluid effect when you minimize or launch an app. + +Unlike other animation improvements, this is quite a pleasing effect to enhance the user experience. + +### 2\. Windows 11-like Layout + +![][3] + +Considering that Windows 11 made a lot of buzz for its launch, it only makes sense for Zorin OS to offers a familiar layout. + +After all, it is one of the best Windows-like Linux distributions out there. + +The Windows 11-like layout is only available in the Zorin Appearance settings for Pro users. So, get the Pro edition if you want to support the development and get access to some extra layouts. + +### 3\. Touchpad Gestures + +If you want to get a seamless touch experience with your laptop/touchpad, Zorin OS 16 is here to the rescue. + +A simple three-finger pinch would help you navigate to the activity overview and dabble between active windows. + +And a four-finger swipe up/down will let you switch between workspaces. + +### 4\. Windows Software Detection + +![][4] + +Zorin OS 16 utilizes a database of popular Windows software to detect if you download a .exe file and want to install it. + +This is incredibly useful for beginners considering that it also informs the alternative or the correct way to install the software on Linux. + +Even if it does not have exact instructions for the Windows software you downloaded, it prompts you to install “**Windows App Support**” when trying to access the .exe file. + +![][5] + +### 5\. New Photos App + +![][6] + +The default photos or image viewer is often untouched when a distribution is updated. But, with Zorin OS 16, you get a more straightforward and clean photo management app. + +You get essential options like cropping, adding filters, enhancing the image, and screencasting to the devices connected to your network. + +### 6\. Flathub Apps + +![][7] + +You no longer need to install Flatpak applications from the terminal separately. Flathub is now included with the Software center. + +So, you can effortlessly search for Flatpak applications right from the Software app. + +### 7\. Taskbar and Dash Customization + +With Zorin OS 16, you get a variety of customization options to tweak the appearance of the taskbar, panel, and dock. + +![][8] + +Starting from the transparency to its position, behavior, size, and more. These options should let you tweak your user experience. + +### 8\. Taskbar Unread Icons and Progress bar + +The taskbar is usually static for most of the Linux distributions. Here, you finally get an unread badge counter in the taskbar, and it also supports a new progress bar for tasks like file transfer. + +The progress bar is a helpful addition, given that you do not have to open the app repeatedly to watch the progress. + +### 9\. New Sound Recorder App + +![][9] + +You do not have to opt for a third-party application to record basic voice-overs, podcasts, or voice notes. + +The built-in sound record app offers a clean and easy-to-use interface. So, it should be a breeze to use it. + +### Wrapping Up + +Have you tried Zorin OS 16 yet? What feature did you find the most useful? Let me know your thoughts in the comments down below. + +#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! + +If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. + +I'm not interested + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/zorin-os-16-features/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://news.itsfoss.com/zorin-os-16-release/ +[2]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjM0MyIgd2lkdGg9Ijc1MiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[3]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQzOSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[4]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjM2MSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[5]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQyMiIgd2lkdGg9IjYxNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[6]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjUyMSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[7]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjIzMCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[8]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQ4NSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[9]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQ4MCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= diff --git a/sources/news/20210818 Zorin OS 16 is a Visual Spectacle- You Can Download This New Linux Release Right Now.md b/sources/news/20210818 Zorin OS 16 is a Visual Spectacle- You Can Download This New Linux Release Right Now.md new file mode 100644 index 0000000000..327bd1e4ae --- /dev/null +++ b/sources/news/20210818 Zorin OS 16 is a Visual Spectacle- You Can Download This New Linux Release Right Now.md @@ -0,0 +1,144 @@ +[#]: subject: "Zorin OS 16 is a Visual Spectacle! You Can Download This New Linux Release Right Now" +[#]: via: "https://news.itsfoss.com/zorin-os-16-release/" +[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Zorin OS 16 is a Visual Spectacle! You Can Download This New Linux Release Right Now +====== + +Zorin OS 16, one of the most anticipated Linux distros, based on Ubuntu 20.04.3 LTS, has arrived. + +With the latest release, they now offer a new “Pro” edition replacing the “Ultimate” edition that comes loaded with a few applications pre-installed and a couple of extra layouts. + +Moreover, you get technical support for installation if you get the Zorin OS 16 Pro to support the developers. + +The base edition is Zorin OS 16 “Core,” is free, which includes all the essentials. + +In this article, I shall highlight the key new additions along with my initial impressions of Zorin OS 16. + +### Zorin OS 16: What’s New? + +Zorin OS 16 may not be as big of an upgrade compared to [elementary OS 6][1], but there are significant improvements across the board. Let us take a look at them. + +### Refined User Interface + +![][2] + +The user interface remains familiar, but they have revamped the default theme and worked on the animations to present a polished look. + +Subtle differences to the default transparency setting, theme, icons, and animations impact the overall user experience. + +While you can notice the differences with Zorin OS 16 Core, the Pro edition takes it up a notch with the stunning new wallpapers and premium layouts available out-of-the-box. + +### Flatpak Enabled + +![][3] + +Previously, Zorin OS supported snap right out of the box with its Software center. Now, with Zorin OS 16, Flathub has been enabled by default. + +So, you can find plenty of applications available, including Flatpak packages in the Software manager. + +You can even select a different package (if it is available) from the dropdown menu available in the top-right corner (as shown in the screenshot above). + +### Improved Tour Screen + +![][4] + +They have also revamped their welcome screen to help you set up all the important things right from the start. + +You get to configure online accounts, connect your smartphone with Zorin Connect, and get a head start on the available layouts to choose from. + +### Windows 11-like Layout + +![][2] + +In my previous [Zorin OS 16 beta][5] coverage, I mentioned a potential Windows 10X-like layout was in the works. + +Considering that Windows 10X no longer exists, the new layout is an alternative to Windows 11 experience. + +Do note that you need to purchase the Zorin OS 16 Pro if you want to access Windows 11-like layout on your system. + +### New Touchpad Gestures + +For laptop or touchpad users, you can now swipe up/down with four fingers to move between workspaces and pinch using three fingers to open the activities overview. + +### New Sound Recorder App + +![][6] + +A clean sound recording app to help you quickly record voice notes or podcasts without worrying about 3rd party applications. + +### Performance Improvements + +Even though I don’t have a figure, I observed some noticeable performance improvements compared to my experience with Zorin OS 15. + +For instance, switching between different layouts is an entirely seamless experience. + +As a side note, I tested Zorin OS 16 Pro on my desktop with **i5-7400, 16 GB RAM,** and **a GTX 1050ti** graphics card. + +I always have my doubts when it comes to Nvidia driver compatibility. But it worked like a charm. + +The boot menu when installing Zorin OS 16 offered a different option for modern NVIDIA drivers, which is what I chose to install. + +So, yes, **Zorin OS 16’s ISO comes with Nvidia driver support out-of-the-box.** + +### Other Improvements + +![][7] + +There are several other additions to the animation, customization settings, and more with Zorin OS 16. Some of them are: + + * Jelly mode to enable a macOS-like animation when minimizing or opening applications. + * Improved taskbar + * Introduction of fractional scaling + * Active directory domain option in the installer + * New photos app + * Disabled telemetry and tracking in Firefox browser for better privacy + + + +To explore more, you can check out [our Zorin OS 16 features list][8] or go through the [official announcement][9]. + +### Get Zorin OS 16 + +You can download Zorin OS 16 Core for free. If you opt for the Pro edition at **$39**, you also get access to a Pro-lite edition, which will be available to install for old computers. + +The free lite edition and the pro lite version is not yet available and should be coming soon. + +[Zorin OS 16 Download][10] + +What do you think about Zorin OS 16? Share your thoughts in the comments down below. + +#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! + +If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. + +I'm not interested + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/zorin-os-16-release/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://news.itsfoss.com/elementary-os-6-release/ +[2]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQzOSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[3]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjIzMCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[4]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjUzNiIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[5]: https://news.itsfoss.com/zorin-os-16-beta/ +[6]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQ4MCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[7]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQxNSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[8]: https://news.itsfoss.com/zorin-os-16-features/ +[9]: https://blog.zorin.com/2021/08/17/2021-08-17-zorin-os-16-is-released/ +[10]: https://zorin.com/os/download/ diff --git a/sources/talk/20170928 The Lineage of Man.md b/sources/talk/20170928 The Lineage of Man.md index b51d67f4f9..de2cc7515e 100644 --- a/sources/talk/20170928 The Lineage of Man.md +++ b/sources/talk/20170928 The Lineage of Man.md @@ -92,7 +92,7 @@ via: https://twobithistory.org/2017/09/28/the-lineage-of-man.html 作者:[Two-Bit History][a] 选题:[lujun9972][b] -译者:[bestony](https://github.com/bestony) +译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/talk/20180713 What-s the difference between a fork and a distribution.md b/sources/talk/20180713 What-s the difference between a fork and a distribution.md deleted file mode 100644 index f7f50e014b..0000000000 --- a/sources/talk/20180713 What-s the difference between a fork and a distribution.md +++ /dev/null @@ -1,81 +0,0 @@ -What's the difference between a fork and a distribution? -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/spoons_forks_520x292_jh.png?itok=DzEzZBuG) - -If you've been around open source software for any length of time, you'll hear the terms fork and distribution thrown around casually in conversation. For many people, the distinction between the two isn't clear, so here I'll try to clear up the confusion. - -### First, some definitions - -Before explaining the nuances of a fork vs. a distribution and the pitfalls thereof, let's define key concepts. - -**[Open source software][1]** is software that: - - * Is freely available to distribute under certain [license][2] restraints - * Permits its source code to be viewable and modified under certain license restraints - - - -Open source software can be **consumed** in the following ways: - - * Downloaded in binary or source code format, often at no charge (e.g., the [Eclipse developer environment][3]) - * As a distribution (product) by a vendor, sometimes at a cost to the user (e.g., [Red Hat products][4]) - * Embedded into proprietary software solutions (e.g., some smartphones and browsers display fonts using the open source [freetype software][5]) - - - -**Free and open source (FOSS)** is not necessarily "free" as in "zero cost." Free and open source simply means the software is free to distribute, modify, study, and use, subject to the software's licensing. The software distributor may attach a purchase price to it. For example, Linux is available at no cost as Fedora, CentOS, Gentoo, etc. or as a paid distribution as Red Hat Enterprise Linux, SUSE, etc. - -**Community** refers to the organizations and individuals that collaboratively work on an open source project. Any individual or organization can contribute to the project by writing or reviewing code, documentation, test suites, managing meetings, updating websites, etc., provided they abide by the license. For example, at [Openhub.net][6], we see government, nonprofit, commercial, and education organizations [contributing to some open source projects][7]. - -**project** is the result of this collaborative development, documentation, and testing. Most projects have a central repository where code, documentation, testing, and so forth are developed. - -An open sourceis the result of this collaborative development, documentation, and testing. Most projects have a central repository where code, documentation, testing, and so forth are developed. - -A **distribution** is a copy, in binary or source code format, of an open source project. For example, CentOS, Fedora, Red Hat Enterprise Linux, SUSE, Ubuntu, and others are distributions of the Linux project. Tectonic, Google Kubernetes Engine, Amazon Container Service, and Red Hat OpenShift are distributions of the Kubernetes project. - -Vendor distributions of open source projects are often called **products** , thus Red Hat OpenStack Platform is the Red Hat OpenStack product that is a distribution of the OpenStack upstream project—and it is still 100% open source. - -The **trunk** is the main workstream in the community where the open source project is developed. - -An open source **fork** is a version of the open source project that is developed along a separate workstream from the main trunk. - -Thus, **a distribution is not the same as a fork**. A distribution is a packaging of the upstream project that is made available by vendors, often as products. However, the core code and documentation in the distribution adhere to the version in the upstream project. A fork—and any distribution based on the fork—results in a version of the code and documentation that are different from the upstream project. Users who have forked upstream open source code have to maintain it on their own, meaning they lose the benefit of the collaboration that takes place in the upstream community. - -To further explain a software fork, let's use the analogy of migrating animals. Whales and sea lions migrate from the Arctic to California and Mexico; Monarch butterflies migrate from Alaska to Mexico; and (in the Northern Hemisphere) swallows and many other birds fly south for the winter. The key to a successful migration is that all animals in the group stick together, follow the leaders, find food and shelter, and don't get lost. - -### Risks of going it on your own - -A bird, butterfly, or whale that strays from the group loses the benefit of remaining with the group and knowing where to find food, shelter, and the desired destination. - -Similarly, users or organizations that fork and modify an upstream project and maintain it on their own run the following risks: - - 1. **They cannot update their code based on the upstream because their code differs.** This is known as technical debt; the more changes made to forked code, the more it costs in time and money to rebase the fork to the upstream project. - 2. **They potentially run less secure code.** If a vulnerability is found in open source code and fixed by the community in the upstream, a forked version of the code may not benefit from this fix because it is different from the upstream. - 3. **They might not benefit from new features.** The upstream community, using input from many organizations and individuals, creates new features for the benefit of all users of the upstream project. If an organization forks the upstream, they potentially cannot incorporate the new features because their code differs. - 4. **They might not integrate with other software packages.** Open source projects are rarely developed as single entities; rather they often are packaged together with other projects to create a solution. Forked code may not be able to be integrated with other projects because the developers of the forked code are not collaborating in the upstream with other participants. - 5. **They might not certify on hardware platforms.** Software packages are often certified to run on hardware platforms so, if problems arise, the hardware and software vendors can collaborate to find the root cause or problem. - - - -In summary, an open source distribution is simply a packaging of an upstream, multi-organizational, collaborative open source project sold and supported by a vendor. A fork is a separate development workstream of an open source project and risks not being able to benefit from the collaborative efforts of the upstream community. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/7/forks-vs-distributions - -作者:[Jonathan Gershater][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/jgershat -[1]:https://opensource.com/resources/what-open-source -[2]:https://opensource.com/tags/licensing -[3]:https://www.eclipse.org/che/getting-started/download/ -[4]:https://access.redhat.com/downloads -[5]:https://www.freetype.org/ -[6]:http://openhub.net -[7]:https://www.openhub.net/explore/orgs diff --git a/sources/talk/20191029 5 reasons why I love Python.md b/sources/talk/20191029 5 reasons why I love Python.md index a82429dd9a..5df5be960e 100644 --- a/sources/talk/20191029 5 reasons why I love Python.md +++ b/sources/talk/20191029 5 reasons why I love Python.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: (osu-zxf) +[#]: translator: ( ) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/talk/20200124 Gartner- Data-center spending will inch up this year.md b/sources/talk/20200124 Gartner- Data-center spending will inch up this year.md index 03fbef5355..a58dc86acd 100644 --- a/sources/talk/20200124 Gartner- Data-center spending will inch up this year.md +++ b/sources/talk/20200124 Gartner- Data-center spending will inch up this year.md @@ -42,7 +42,7 @@ via: https://www.networkworld.com/article/3515314/data-center-spending-will-inch 作者:[Andy Patrizio][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) +译者:[zxy-wyx](https://github.com/zxy-wy) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/talk/20200731 Why we open sourced our Python platform.md b/sources/talk/20200731 Why we open sourced our Python platform.md deleted file mode 100644 index fe76ac8487..0000000000 --- a/sources/talk/20200731 Why we open sourced our Python platform.md +++ /dev/null @@ -1,105 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Why we open sourced our Python platform) -[#]: via: (https://opensource.com/article/20/7/why-open-source) -[#]: author: (Meredydd Luff https://opensource.com/users/meredydd-luff) - -Why we open sourced our Python platform -====== -Open source development philosophy makes Anvil's entire solution more -useful and trustworthy. -![neon sign with head outline and open source why spelled out][1] - -The team at Anvil recently open sourced the [Anvil App Server][2], a runtime engine for hosting web apps built entirely in Python. - -The community reaction has been overwhelmingly positive, and we, at Anvil, have already incorporated lots of that feedback into our [next release][3]. But one of the questions we keep getting asked is, "Why did you choose to open source such a core part of your product?" - -### Why we created Anvil - -[Anvil][4] is a tool that makes it as simple as possible to build a web app. We do that by enabling you to build the whole application in one language—Python. - -Before Anvil, if you wanted to build a web app, you'd have to write code using a bunch of technologies like HTML, Javascript, CSS, Python, SQL, React, Redux, Bootstrap, Sass, Webpack, etc. That's a lot to learn. And that's just for a simple app; trust me, it can get [way more complicated][5]. - -![A complex framework of development tools needed for a simple web app][6] - -Yes, really. All of these, for a simple web app. - -But even then, you're not done! You need to know all about Git and cloud hosting providers, how to secure the (most-likely) Linux operating system, how to tune the database, and then you're on call to keep it running. Forever. - -So, instead, we built Anvil, an online IDE where you can build your UI with a [drag-and-drop designer][7] and write all your [logic in Python][8], then Anvil takes care of the rest. We replace that whole teetering stack with "just write Python." - -### Simple web hosting is important, but not enough - -Anvil can also host your apps for you. And why not? There is so much complexity in deploying a web app, so running our own cloud hosting service was the only way to provide the simplicity we need. Build an app in the Anvil editor, [click a button][9], and it's live on the Internet. - -But we kept hearing from people who said, "That's great, but…" - - * "I need to run this on an offshore platform without reliable internet access." - * "I want to package my app into an IoT device I sell." - * "If I'm putting my eggs in this basket, how can I be sure I can still run my app in ten years?" - - - -These are all good points! A cloud service isn't the right solution for everyone. If we want to serve these users, there's got to be some way for them to get their apps out of Anvil and run them locally, under their own complete control. - -### Open source is an escape hatch, not an ejector seat - -At conferences, we sometimes get asked, "Can I export this as a Flask+JS app?" Sure, it would be possible to export an Anvil project into its respective Python and JavaScript—we could generate a server package, compile the client-side Python to Javascript, and spit out a classic web app. But it would have serious drawbacks, because: **code generation is an ejector seat.** - -![Code generation is an ejector seat from a structured platform][10] - -([Image][11] licensed as public domain) - -Generated code is better than nothing; at least you can edit it! But the moment you've edited that code, you've lost all the benefits of the system that generated it. If you're using Anvil because of its [drag-and-drop editor][12] and [Python in the browser][13], why should you have to use vim and Javascript in order to host your app locally? - -We believe in [escape hatches, not ejector seats][14]. So we did it the right way—we [open-sourced Anvil's runtime engine][2], which is the same code that serves your app in our hosted service. It's a standalone app; you can edit your code with a text editor and run it locally. But you can also `git push` it right back into our online IDE. It's not an ejector seat; there's no explosive transition. It's an escape hatch; you can climb out, do what you need to do, and climb right back in. - -### If it's open, is it reliable? - -A seeming contradiction in open source is that its free availability is its strength, but also sometimes creates a perception of instability. After all, if you're not charging for it, how are you keeping this platform up and healthy for the long term? - -We're doing what we always have—providing a development tool that makes it drastically simpler to build web applications, though the apps you build using Anvil are 100% yours. We provide hosting for Anvil apps and we offer the entire development and hosting platform onsite for [enterprise customers][15]. This enables us to offer a free plan so that everyone can use Anvil for hobby or educational purposes, or to start building something and see where it goes. - -### More to gain, little to lose - -Open sourcing our runtime engine isn't a detractor from our business—it makes our online IDE more useful and more trustworthy, today and in the future. We've open-sourced the Anvil App Server for the people who need it, and to provide the ultimate insurance policy. It's the right move for our users—now they can build with confidence, knowing that the open source code is [right there][3] if they need it. - -If our development philosophy resonates with you, why not try Anvil yourself? -  - -\----- - -_This post is an adaptation of [Why We Open Sourced the Anvil App Server][16] and is reused with permission._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/7/why-open-source - -作者:[Meredydd Luff][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/meredydd-luff -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUS_OSwhy_520x292_ma.png?itok=lqfhAs8L (neon sign with head outline and open source why spelled out) -[2]: https://anvil.works/blog/open-source -[3]: https://github.com/anvil-works/anvil-runtime -[4]: https://anvil.works/ -[5]: https://github.com/kamranahmedse/developer-roadmap#introduction -[6]: https://opensource.com/sites/default/files/uploads/frameworks.png (A complex framework of development tools needed for a simple web app) -[7]: https://anvil.works/docs/client/ui -[8]: https://anvil.works/docs/client/python -[9]: https://anvil.works/docs/deployment -[10]: https://opensource.com/sites/default/files/uploads/ejector-seat-opensourcecom.jpg (Code generation is an ejector seat from a structured platform) -[11]: https://commons.wikimedia.org/wiki/File:Crash.arp.600pix.jpg -[12]: https://anvil.works/docs/editor -[13]: https://anvil.works/docs/client -[14]: https://anvil.works/blog/escape-hatches-and-ejector-seats -[15]: https://anvil.works/docs/overview/enterprise -[16]: https://anvil.works/blog/why-open-source diff --git a/sources/talk/20200825 Why we open sourced our security project.md b/sources/talk/20200825 Why we open sourced our security project.md index bc11945595..c161728197 100644 --- a/sources/talk/20200825 Why we open sourced our security project.md +++ b/sources/talk/20200825 Why we open sourced our security project.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: (Starryi) +[#]: translator: ( ) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/talk/20200930 FCC auctions should be a long-term boost for 5G availability.md b/sources/talk/20200930 FCC auctions should be a long-term boost for 5G availability.md deleted file mode 100644 index 151561c2e4..0000000000 --- a/sources/talk/20200930 FCC auctions should be a long-term boost for 5G availability.md +++ /dev/null @@ -1,87 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (FCC auctions should be a long-term boost for 5G availability) -[#]: via: (https://www.networkworld.com/article/3584072/fcc-auctions-should-be-a-long-term-boost-for-5g-availability.html) -[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) - -FCC auctions should be a long-term boost for 5G availability -====== -Federal Communications Commission policymaking targets creation of new services by making more spectrum available -[FCC][1] - -As the march towards 5G progresses, it’s apparent that more spectrum will be needed to fully enable it as a service, and the Federal Communications Commission has clearly taken the message to heart. - -### 5G resources - - * [What is 5G? Fast wireless technology for enterprises and phones][2] - * [How 5G frequency affects range and speed][3] - * [Private 5G can solve some problems that Wi-Fi can’t][4] - * [Private 5G keeps Whirlpool driverless vehicles rolling][5] - * [5G can make for cost-effective private backhaul][6] - * [CBRS can bring private 5G to enterprises][7] - - - -The FCC recently finished [auctioning off priority-access licenses for Citizen’s Broadband Radio Service (CBRS)][8] spectrum for 5G, representing 70MHz swath of new bandwidth within the 3.5GHz band. It took in $4.58 billion and is one of several such auctions in recent  years aimed at freeing up more channels for wireless data. In 2011, 2014 and 2015 the FCC auctioned off 65MHz in the low- to mid-band, between roughly 1.7GHz and 2.2GHz, for example, and the 700MHz band. - -But the operative part of the spectrum now is the sub-6GHz or mid-band spectrum, in the same area as that sold off in the [CBRS][9] auction. A forthcoming C-Band auction will be the big one, according to experts, with a whopping 280MHz of spectrum on the table. - -“The big money’s coming with the C-band auction,” said Jason Leigh, a research manager with IDC. “Mid-band spectrum in the U.S. is scarce— that’s why you’re seeing this great urgency.” - -[[Get regularly scheduled insights by signing up for Network World newsletters.]][10] - -While the major mobile-data providers are still expected to snap up the lion’s share of the available licenses in that auction, some of the most innovative uses of the spectrum will be implemented by the enterprise, which will compete against the carriers for some of the available frequencies. - -Specialist networks for [IoT][11], asset tracking and other private networking applications are already possible via private LTE, but the maturation of 5G substantially broadens their scope, thanks to that technology’s advanced spectrum sharing, low-latency and multi-connectivity features. That, broadly, means a lot of new wire-replacement applications, including industrial automation, facilities management and more. - -## Reallocating spectrum means negotiation - -It hasn’t been a simple matter to shift America’s spectrum priorities around, and few would know that better than former FCC chair Tom Wheeler. Much of the spectrum that the government has been pushing to reallocate to mobile broadband over the past decade was already licensed out to various stakeholders, frequently government agencies and satellite network operators. - -Those stakeholders have to be moved to different parts of the spectrum, often compensated at taxpayer expense, and getting the various players to share and share alike has frequently been a complicated process, Wheeler said. - -“One of the challenges the FCC faces is that the allocation of spectrum was first made from analog assumptions that have been rewritten as a result of digital technology,” he pointed out, citing the transition from analog to digital TV as an example. Where an analog TV signal took up 6MHz of spectrum and required guard bands on either side to avoid interference, four or five digital signals can be fit into that one channel. - -Those assumptions have proved challenging to confront. Incumbents have publicly protested the FCC’s moves in the mid-band, arguing that insufficient precautions have been taken to avoid interference with existing services, and that changing frequency assignments often means they have to buy new equipment. - -“I went through it with the [Department of Defense], with the satellite companies, and the fact of the matter is that one of the big regulatory challenges is that nobody wants to give up the nice secure position that they have based on analog assumptions,” said Wheeler. “I think you also have to pay serious consideration, but I found that claims of interference were the first refuge of people who didn’t like the threat of competition or anything else.” - -## The future: more services - -The broader point of the opening of the mid-band to carrier and enterprise use will be potentially major advantages for U.S. businesses, regardless of the exact manner in which that spectrum is opened, according to Leigh. While the U.S. is sticking to the auction format for allocating wireless spectrum, other countries, like Germany, have set aside mid-band spectrum specifically for enterprise use. - -For a given company trying to roll its own private 5G network, that could push spectrum auction prices higher. But, ultimately, the services are going to be available, whether they’re provisioned in-house or sold by a mobile carrier or vendor, as long as there’s enough spectrum available to them. - -“The things you can do on the enterprise side for 5G are what’s going to drive the really futuristic stuff,” he said. - -Join the Network World communities on [Facebook][12] and [LinkedIn][13] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3584072/fcc-auctions-should-be-a-long-term-boost-for-5g-availability.html - -作者:[Jon Gold][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Jon-Gold/ -[b]: https://github.com/lujun9972 -[1]: https://www.flickr.com/photos/fccdotgov/4808818548/ -[2]: https://www.networkworld.com/article/3203489/what-is-5g-fast-wireless-technology-for-enterprises-and-phones.html -[3]: https://www.networkworld.com/article/3568253/how-5g-frequency-affects-range-and-speed.html -[4]: https://www.networkworld.com/article/3568614/private-5g-can-solve-some-enterprise-problems-that-wi-fi-can-t.html -[5]: https://www.networkworld.com/article/3488799/private-5g-keeps-whirlpool-driverless-vehicles-rolling.html -[6]: https://www.networkworld.com/article/3570724/5g-can-make-for-cost-effective-private-backhaul.html -[7]: https://www.networkworld.com/article/3529291/cbrs-wireless-can-bring-private-5g-to-enterprises.html -[8]: https://www.networkworld.com/article/3572564/cbrs-wireless-yields-45b-for-licenses-to-support-5g.html -[9]: https://www.networkworld.com/article/3180615/faq-what-in-the-wireless-world-is-cbrs.html -[10]: https://www.networkworld.com/newsletters/signup.html -[11]: https://www.networkworld.com/article/3207535/what-is-iot-the-internet-of-things-explained.html -[12]: https://www.facebook.com/NetworkWorld/ -[13]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20210308 How the ARPANET Protocols Worked.md b/sources/talk/20210308 How the ARPANET Protocols Worked.md deleted file mode 100644 index 50c5d37f56..0000000000 --- a/sources/talk/20210308 How the ARPANET Protocols Worked.md +++ /dev/null @@ -1,138 +0,0 @@ -[#]: subject: (How the ARPANET Protocols Worked) -[#]: via: (https://twobithistory.org/2021/03/08/arpanet-protocols.html) -[#]: author: (Two-Bit History https://twobithistory.org) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -How the ARPANET Protocols Worked -====== - -The ARPANET changed computing forever by proving that computers of wildly different manufacture could be connected using standardized protocols. In my [post on the historical significance of the ARPANET][1], I mentioned a few of those protocols, but didn’t describe them in any detail. So I wanted to take a closer look at them. I also wanted to see how much of the design of those early protocols survives in the protocols we use today. - -The ARPANET protocols were, like our modern internet protocols, organized into layers.[1][2] The protocols in the higher layers ran on top of the protocols in the lower layers. Today the TCP/IP suite has five layers (the Physical, Link, Network, Transport, and Application layers), but the ARPANET had only three layers—or possibly four, depending on how you count them. - -I’m going to explain how each of these layers worked, but first an aside about who built what in the ARPANET, which you need to know to understand why the layers were divided up as they were. - -### Some Quick Historical Context - -The ARPANET was funded by the US federal government, specifically the Advanced Research Projects Agency within the Department of Defense (hence the name “ARPANET”). The US government did not directly build the network; instead, it contracted the work out to a Boston-based consulting firm called Bolt, Beranek, and Newman, more commonly known as BBN. - -BBN, in turn, handled many of the responsibilities for implementing the network but not all of them. What BBN did was design and maintain a machine known as the Interface Message Processor, or IMP. The IMP was a customized Honeywell minicomputer, one of which was delivered to each site across the country that was to be connected to the ARPANET. The IMP served as a gateway to the ARPANET for up to four hosts at each host site. It was basically a router. BBN controlled the software running on the IMPs that forwarded packets from IMP to IMP, but the firm had no direct control over the machines that would connect to the IMPs and become the actual hosts on the ARPANET. - -The host machines were controlled by the computer scientists that were the end users of the network. These computer scientists, at host sites across the country, were responsible for writing the software that would allow the hosts to talk to each other. The IMPs gave hosts the ability to send messages to each other, but that was not much use unless the hosts agreed on a format to use for the messages. To solve that problem, a motley crew consisting in large part of graduate students from the various host sites formed themselves into the Network Working Group, which sought to specify protocols for the host computers to use. - -So if you imagine a single successful network interaction over the ARPANET, (sending an email, say), some bits of engineering that made the interaction successful were the responsibility of one set of people (BBN), while other bits of engineering were the responsibility of another set of people (the Network Working Group and the engineers at each host site). That organizational and logistical happenstance probably played a big role in motivating the layered approach used for protocols on the ARPANET, which in turn influenced the layered approach used for TCP/IP. - -### Okay, Back to the Protocols - -![ARPANET Network Stack][3] _The ARPANET protocol hierarchy._ - -The protocol layers were organized into a hierarchy. At the very bottom was “level 0.”[2][4] This is the layer that in some sense doesn’t count, because on the ARPANET this layer was controlled entirely by BBN, so there was no need for a standard protocol. Level 0 governed how data passed between the IMPs. Inside of BBN, there were rules governing how IMPs did this; outside of BBN, the IMP sub-network was a black box that just passed on any data that you gave it. So level 0 was a layer without a real protocol, in the sense of a publicly known and agreed-upon set of rules, and its existence could be ignored by software running on the ARPANET hosts. Loosely speaking, it handled everything that falls under the Physical, Link, and Internet layers of the TCP/IP suite today, and even quite a lot of the Transport layer, which is something I’ll come back to at the end of this post. - -The “level 1” layer established the interface between the ARPANET hosts and the IMPs they were connected to. It was an API, if you like, for the black box level 0 that BBN had built. It was also referred to at the time as the IMP-Host Protocol. This protocol had to be written and published because, when the ARPANET was first being set up, each host site had to write its own software to interface with the IMP. They wouldn’t have known how to do that unless BBN gave them some guidance. - -The IMP-Host Protocol was specified by BBN in a lengthy document called [BBN Report 1822][5]. The document was revised many times as the ARPANET evolved; what I’m going to describe here is roughly the way the IMP-Host protocol worked as it was initially designed. According to BBN’s rules, hosts could pass _messages_ to their IMPs no longer than 8095 bits, and each message had a _leader_ that included the destination host number and something called a _link number_.[3][6] The IMP would examine the designation host number and then dutifully forward the message into the network. When messages were received from a remote host, the receiving IMP would replace the destination host number with the source host number before passing it on to the local host. Messages were not actually what passed between the IMPs themselves—the IMPs broke the messages down into smaller _packets_ for transfer over the network—but that detail was hidden from the hosts. - -![1969 Host-IMP Leader][7] _The Host-IMP message leader format, as of 1969. Diagram from [BBN Report 1763][8]._ - -The link number, which could be any number from 0 to 255, served two purposes. It was used by higher level protocols to establish more than one channel of communication between any two hosts on the network, since it was conceivable that there might be more than one local user talking to the same destination host at any given time. (In other words, the link numbers allowed communication to be multiplexed between hosts.) But it was also used at the level 1 layer to control the amount of traffic that could be sent between hosts, which was necessary to prevent faster computers from overwhelming slower ones. As initially designed, the IMP-Host Protocol limited each host to sending just one message at a time over each link. Once a given host had sent a message along a link to a remote host, it would have to wait to receive a special kind of message called an RFNM (Request for Next Message) from the remote IMP before sending the next message along the same link. Later revisions to this system, made to improve performance, allowed a host to have up to eight messages in transit to another host at a given time.[4][9] - -The “level 2” layer is where things really start to get interesting, because it was this layer and the one above it that BBN and the Department of Defense left entirely to the academics and the Network Working Group to invent for themselves. The level 2 layer comprised the Host-Host Protocol, which was first sketched in RFC 9 and first officially specified by RFC 54. A more readable explanation of the Host-Host Protocol is given in the [ARPANET Protocol Handbook][10]. - -The Host-Host Protocol governed how hosts created and managed _connections_ with each other. A connection was a one-way data pipeline between a _write socket_ on one host and a _read socket_ on another host. The “socket” concept was introduced on top of the limited level-1 link facility (remember that the link number can only be one of 256 values) to give programs a way of addressing a particular process running on a remote host. Read sockets were even-numbered while write sockets were odd-numbered; whether a socket was a read socket or a write socket was referred to as the socket’s gender. There were no “port numbers” like in TCP. Connections could be opened, manipulated, and closed by specially formatted Host-Host control messages sent between hosts using link 0, which was reserved for that purpose. Once control messages were exchanged over link 0 to establish a connection, further data messages could then be sent using another link number picked by the receiver. - -Host-Host control messages were identified by a three-letter mnemonic. A connection was established when two hosts exchanged a STR (sender-to-receiver) message and a matching RTS (receiver-to-sender) message—these control messages were both known as Request for Connection messages. Connections could be closed by the CLS (close) control message. There were further control messages that changed the rate at which data messages were sent from sender to receiver, which were needed to ensure again that faster hosts did not overwhelm slower hosts. The flow control already provided by the level 1 protocol was apparently not sufficient at level 2; I suspect this was because receiving an RFNM from a remote IMP was only a guarantee that the remote IMP had passed the message on to the destination host, not that the host had fully processed the message. There was also an INR (interrupt-by-receiver) control message and an INS (interrupt-by-sender) control message that were primarily for use by higher-level protocols. - -The higher-level protocols all lived in “level 3”, which was the Application layer of the ARPANET. The Telnet protocol, which provided a virtual teletype connection to another host, was perhaps the most important of these protocols, but there were many others in this level too, such as FTP for transferring files and various experiments with protocols for sending email. - -One protocol in this level was not like the others: the Initial Connection Protocol (ICP). ICP was considered to be a level-3 protocol, but really it was a kind of level-2.5 protocol, since other level-3 protocols depended on it. ICP was needed because the connections provided by the Host-Host Protocol at level 2 were only one-way, but most applications required a two-way (i.e. full-duplex) connection to do anything interesting. ICP specified a two-step process whereby a client running on one host could connect to a long-running server process on another host. The first step involved establishing a one-way connection from the server to the client using the server process’ well-known socket number. The server would then send a new socket number to the client over the established connection. At that point, the existing connection would be discarded and two new connections would be opened, a read connection based on the transmitted socket number and a write connection based on the transmitted socket number plus one. This little dance was a necessary prelude to most things—it was the first step in establishing a Telnet connection, for example. - -That finishes our ascent of the ARPANET protocol hierarchy. You may have been expecting me to mention a “Network Control Protocol” at some point. Before I sat down to do research for this post and my last one, I definitely thought that the ARPANET ran on a protocol called NCP. The acronym is occasionally used to refer to the ARPANET protocols as a whole, which might be why I had that idea. [RFC 801][11], for example, talks about transitioning the ARPANET from “NCP” to “TCP” in a way that makes it sound like NCP is an ARPANET protocol equivalent to TCP. But there has never been a “Network Control Protocol” for the ARPANET (even if [Encyclopedia Britannica thinks so][12]), and I suspect people have mistakenly unpacked “NCP” as “Network Control Protocol” when really it stands for “Network Control Program.” The Network Control Program was the kernel-level program running in each host responsible for handling network communication, equivalent to the TCP/IP stack in an operating system today. “NCP”, as it’s used in RFC 801, is a metonym, not a protocol. - -### A Comparison with TCP/IP - -The ARPANET protocols were all later supplanted by the TCP/IP protocols (with the exception of Telnet and FTP, which were easily adapted to run on top of TCP). Whereas the ARPANET protocols were all based on the assumption that the network was built and administered by a single entity (BBN), the TCP/IP protocol suite was designed for an _inter_-net, a network of networks where everything would be more fluid and unreliable. That led to some of the more immediately obvious differences between our modern protocol suite and the ARPANET protocols, such as how we now distinguish between a Network layer and a Transport layer. The Transport layer-like functionality that in the ARPANET was partly implemented by the IMPs is now the sole responsibility of the hosts at the network edge. - -What I find most interesting about the ARPANET protocols though is how so much of the transport-layer functionality now in TCP went through a janky adolescence on the ARPANET. I’m not a networking expert, so I pulled out my college networks textbook (Kurose and Ross, let’s go), and they give a pretty great outline of what a transport layer is responsible for in general. To summarize their explanation, a transport layer protocol must minimally do the following things. Here _segment_ is basically equivalent to _message_ as the term was used on the ARPANET: - - * Provide a delivery service between _processes_ and not just host machines (transport layer multiplexing and demultiplexing) - * Provide integrity checking on a per-segment basis (i.e. make sure there is no data corruption in transit) - - - -A transport layer could also, like TCP does, provide _reliable data transfer_, which means: - - * Segments are delivered in order - * No segments go missing - * Segments aren’t delivered so fast that they get dropped by the receiver (flow control) - - - -It seems like there was some confusion on the ARPANET about how to do multiplexing and demultiplexing so that processes could communicate—BBN introduced the link number to do that at the IMP-Host level, but it turned out that socket numbers were necessary at the Host-Host level on top of that anyway. Then the link number was just used for flow control at the IMP-Host level, but BBN seems to have later abandoned that in favor of doing flow control between unique pairs of hosts, meaning that the link number started out as this overloaded thing only to basically became vestigial. TCP now uses port numbers instead, doing flow control over each TCP connection separately. The process-process multiplexing and demultiplexing lives entirely inside TCP and does not leak into a lower layer like on the ARPANET. - -It’s also interesting to see, in light of how Kurose and Ross develop the ideas behind TCP, that the ARPANET started out with what Kurose and Ross would call a strict “stop-and-wait” approach to reliable data transfer at the IMP-Host level. The “stop-and-wait” approach is to transmit a segment and then refuse to transmit any more segments until an acknowledgment for the most recently transmitted segment has been received. It’s a simple approach, but it means that only one segment is ever in flight across the network, making for a very slow protocol—which is why Kurose and Ross present “stop-and-wait” as merely a stepping stone on the way to a fully featured transport layer protocol. On the ARPANET, “stop-and-wait” was how things worked for a while, since, at the IMP-Host level, a Request for Next Message had to be received in response to every outgoing message before any further messages could be sent. To be fair to BBN, they at first thought this would be necessary to provide flow control between hosts, so the slowdown was intentional. As I’ve already mentioned, the RFNM requirement was later relaxed for the sake of better performance, and the IMPs started attaching sequence numbers to messages and keeping track of a “window” of messages in flight in the more or less the same way that TCP implementations do today.[5][13] - -So the ARPANET showed that communication between heterogeneous computing systems is possible if you get everyone to agree on some baseline rules. That is, as I’ve previously argued, the ARPANET’s most important legacy. But what I hope this closer look at those baseline rules has revealed is just how much the ARPANET protocols also influenced the protocols we use today. There was certainly a lot of awkwardness in the way that transport-layer responsibilities were shared between the hosts and the IMPs, sometimes redundantly. And it’s really almost funny in retrospect that hosts could at first only send each other a single message at a time over any given link. But the ARPANET experiment was a unique opportunity to learn those lessons by actually building and operating a network, and it seems those lessons were put to good use when it came time to upgrade to the internet as we know it today. - -_If you enjoyed this post, more like it come out every four weeks! Follow [@TwoBitHistory][14] on Twitter or subscribe to the [RSS feed][15] to make sure you know when a new post is out._ - -_Previously on TwoBitHistory…_ - -> Trying to get back on this horse! -> -> My latest post is my take (surprising and clever, of course) on why the ARPANET was such an important breakthrough, with a fun focus on the conference where the ARPANET was shown off for the first time: -> -> — TwoBitHistory (@TwoBitHistory) [February 7, 2021][16] - - 1. The protocol layering thing was invented by the Network Working Group. This argument is made in [RFC 871][17]. The layering thing was also a natural extension of how BBN divided responsibilities between hosts and IMPs, so BBN deserves some credit too. [↩︎][18] - - 2. The “level” terminology was used by the Network Working Group. See e.g. [RFC 100][19]. [↩︎][20] - - 3. In later revisions of the IMP-Host protocol, the leader was expanded and the link number was upgraded to a _message ID_. But the Host-Host protocol continued to make use of only the high-order eight bits of the message ID field, treating it as a link number. See the “Host-to-Host” protocol section of the [ARPANET Protocol Handbook][10]. [↩︎][21] - - 4. John M. McQuillan and David C. Walden. “The ARPA Network Design Decisions,” p. 284, . Accessed 8 March 2021. [↩︎][22] - - 5. Ibid. [↩︎][23] - - - - --------------------------------------------------------------------------------- - -via: https://twobithistory.org/2021/03/08/arpanet-protocols.html - -作者:[Two-Bit History][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://twobithistory.org -[b]: https://github.com/lujun9972 -[1]: https://twobithistory.org/2021/02/07/arpanet.html -[2]: tmp.szauPoOKtk#fn:1 -[3]: https://twobithistory.org/images/arpanet-stack.png -[4]: tmp.szauPoOKtk#fn:2 -[5]: https://walden-family.com/impcode/BBN1822_Jan1976.pdf -[6]: tmp.szauPoOKtk#fn:3 -[7]: https://twobithistory.org/images/host-imp-1969.png -[8]: https://walden-family.com/impcode/1969-initial-IMP-design.pdf -[9]: tmp.szauPoOKtk#fn:4 -[10]: http://mercury.lcs.mit.edu/~jnc/tech/arpaprot.html -[11]: https://tools.ietf.org/html/rfc801 -[12]: https://www.britannica.com/topic/ARPANET -[13]: tmp.szauPoOKtk#fn:5 -[14]: https://twitter.com/TwoBitHistory -[15]: https://twobithistory.org/feed.xml -[16]: https://twitter.com/TwoBitHistory/status/1358487195905064960?ref_src=twsrc%5Etfw -[17]: https://tools.ietf.org/html/rfc871 -[18]: tmp.szauPoOKtk#fnref:1 -[19]: https://www.rfc-editor.org/info/rfc100 -[20]: tmp.szauPoOKtk#fnref:2 -[21]: tmp.szauPoOKtk#fnref:3 -[22]: tmp.szauPoOKtk#fnref:4 -[23]: tmp.szauPoOKtk#fnref:5 diff --git a/sources/talk/20210418 F(r)iction- Or How I Learnt to Stop Worrying and Start Loving Vim.md b/sources/talk/20210418 F(r)iction- Or How I Learnt to Stop Worrying and Start Loving Vim.md deleted file mode 100644 index 7743b5f167..0000000000 --- a/sources/talk/20210418 F(r)iction- Or How I Learnt to Stop Worrying and Start Loving Vim.md +++ /dev/null @@ -1,179 +0,0 @@ -[#]: subject: (F(r)iction: Or How I Learnt to Stop Worrying and Start Loving Vim) -[#]: via: (https://news.itsfoss.com/how-i-started-loving-vim/) -[#]: author: (Theena https://news.itsfoss.com/author/theena/) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -F(r)iction: Or How I Learnt to Stop Worrying and Start Loving Vim -====== - -It is Dec 2009, and I am ready to quit my job. - -I wanted to focus on writing my first book; neither my commitments at work nor the state of technology was helping. - -Writing is hard work. - -Few tasks in the modern world can be as singular – or as daunting – a pursuit as sitting down in front of a blank piece of paper, and asking your brain to vomit out words that communicate an idea to readers. I am not suggesting that writing can’t be collaborative of course, but merely illustrating how daunting it can be for writers to set off on a new piece by themselves. This is true for fiction -and non-fiction writing, but since I am a novelist I’d like to focus primarily on fiction in this article. - -![][1] - -Remember what 2009 was like? - -Smart phones were 3 years old – I still hadn’t gone away from feature phones. Laptops were big and bulky. Meanwhile, cloud-based web applications for productivity was in their infancy, and just not good. Technologically speaking, writers like me were using their Gmail accounts (and a very young cloud-based storage called Dropbox) as an always-available option to work on their drafts, even while away from my personal computer. While this was a nice change from what writers had to go through when working with typewriters (or god forbid, pen and paper), it wasn’t much. - -For one thing, version control of manuscripts was a nightmare. Further, the more tools I added to my tool kit to simplify the workflow, the more I had to switch context – both from a UI and a UX sense. - -I would start writing drafts on Windows Notepad, save it on a MS Word Document on my PC at home, email myself a copy, keep another copy on Dropbox (since Dropbox wasn’t accessible at work), work on the copy of that file at work, email it back to myself at the end of the day, download it on the home computer, saving it under a new name and the respective date so that I would recognize the changes in the file were made at work (as opposed to home)…well you get the picture. If you think this workflow involving Windows Notepad, MS Word, Gmail, and Dropbox is insane, well now you know why I quit my job. - -More soberingly, I still know writers, damn good writers too, who use variations of the workflow that I followed in 2009. - -Over the next three years, I worked on the manuscript, completing the first draft in 2012. During the three years much had changed with the state of technology. Smart phones were actually pretty great, and some of the complications I had in 2009 had disappeared. I could still work on the same file that I had been working from at home, on my phone (not necessarily fresh writing, but editing had become considerably easier thanks to Dropbox on the phone.) My main writing tool remained Microsoft’s Windows Notepad and Word, which is how I completed the first draft. - -The novel [**First Utterance**][2] was released in 2016 to critical and commercial acclaim. - -The end. - -Or so I thought. - -As soon as I completed the manuscript and sent it to my editor, I had begun working on the second novel. I was no longer quitting my job to work on writing, but I had taken a more pragmatic approach: I’d take two weeks off at the end of ever year so that I could go to a little cabin in the mountains to write. - -It took me half a day to realize that the things that annoyed me about my [writing tools][3] and workflow had not disappeared, but morphed into a more complex beast. As a writer, I wasn’t being productive or as efficient as I wanted. - -### Linux in the time of Corona - -![][4] - -It is 2020 and the world is on the verge of mass hysteria. - -What had started out as an isolated novel virus in China was morphing into the first global pandemic since 1911. On March 20th, Sri Lanka followed most of the rest of the world and shutdown. - -April in Sri Lanka is the height of the dry season. Temperatures in concrete jungles like Colombo can reach the mid 30s, with humidity in the high 90s. It can drive most people to distraction at the best of times, but stuck at home with no always-on air conditioning while a global pandemic is underway? That is a good recipe for madness. - -My madness was Linux or, as we in the open source community call it, ‘distro-hopping’. - -The more I played around with *nix distros, the more enamoured I came to be with the idea of control. When nothing seems to be within our control – not even the simple act of shaking hands with another person – then it is only natural we lean towards things where we feel more in control. - -Where better to get more control in my life than with my computing? Naturally, this extended to my writing tools and workflow too. - -### The path to Vim - -There’s a joke about [Vim][5] that describes perfectly my first experience with it. People are obsessive about Vim because they don’t know how to close it. - -I was attempting to edit a configuration file, and the [fresh install of Ubuntu Server][6] had only Vim pre-installed. First there was panic – so much so I restarted the machine thinking the OS wasn’t picking up my keyboard. Then when it happened again, the inevitable Google search: ‘[How do I close vim?][7]‘ - -_Oh. That’s interesting_, I thought. - -_But why?_ - -To understand why I was even remotely interested in a text editor that was too complex to close, you have to understand how much I adore Windows Notepad. - -As a writer, I loved writing on its no-nonsense, no buttons, white-abyss like canvas. It had no spell check. It had no formatting. But I didn’t care. - -For the writer in me, Notepad was the best writing scratch pad ever devised. Unfortunately, it isn’t powerful – so even if I start writing my drafts in Notepad, I would move it to MS Word once I had passed a 1000 words – Notepad wasn’t built for prose, and those limitations would be glaringly obvious when I passed that word limit. - -So the first thing I installed I moved all my computing away from Windows, was a good text editor. - -[Kate][8] was the first replacement where I felt more comfortable than I did on Windows Notepad – it was more powerful (it had spell-checker!), and hey, I could mess around with some hobbyist-type coding in the same environment. - -It was love. - -But then Vim happened. - -The more I learnt about Vim, the more I watched developers live coding on Vim, the more I found myself opening Vim for my text editing needs. I use the phrase ‘text editing’ in the traditional Unix sense: editing blocks of text in configuration files, or sometimes writing basic Bash scripts. - -I still hadn’t used Vim remotely for my prose writing needs. - -For that I had LibreOffice. - -Sort of. - -While it is an adequate [replacement for MS Office][9], I found myself underwhelmed. The UI is perhaps even more distracting than MS Word, and with each distro having different packages of LibreOffice, I found myself using a hellishly fragmented tool kit and workflow, to say nothing about how different the UI can look in various distros and desktop environments. - -Things had become even more complicated because I had also started my Masters. In this scenario, I was taking notes down on Kate, transferring them to LibreOffice, and then saving it on to my Dropbox. - -Context switching was staring at me in the face every day. - -Productivity dropped as I had to open and close a number of unrelated applications. I needed one writing tool to meet all my needs – as a novelist, as a student, and as a hobbyist coder. - -And that’s when I realized that the solution to my context switching nightmare was also staring at me in the face at the same time. - -By this point, I had used Vim often enough – even used it with Termux on my Android phone – to be pretty comfortable with the idea of moving everything to Vim. Since it supported markdown syntax, note-taking would also become even easier. - -This was just about two months ago. - -How am I doing? - -It is April 2021. - -I started this draft on my phone, [using Vim][10] via Termux (with the aid of a Bluetooth keyboard), while in a taxi. I pushed the file to a GitHub private repo for my writing, from which I pulled the file to my PC, wrote a few more lines, before heading out again. I pulled the new version of the file from GitHub to my phone, made changes, pushed it, repeat, until I emailed the final draft to the editor. - -The context switching is now no more. - -The distractions that come from writing in word processors is no more. - -Editing is infinitely easier, and faster. - -My wrists are no longer in pain because I hid my mouse from sight. - -It is April 2021. - -I am a novelist. - -And I write on Vim. - -How? I’ll discuss the specific of this workflow in the second part of this column series on how non-tech people are using free and open source technology. Stay tuned. - -![][11] - -I'm not interested - -#### _Related_ - - * [Going Against Google Analytics With Plausible's Co-Founder [Interview]][12] - * ![][13] ![Interview with Plausible founder Marco Saric][14] - - - * [The Progress Linux has Made in Terms of Gaming is Simply Incredible: Lutris Creator][15] - * ![][13] ![][16] - - - * [Multi Monitor and HiDPI Setup is Looking Better on Ubuntu 21.04 [My Experience So Far]][17] - * ![][13] ![Multimonitor setup with Ubuntu 21.04][18] - - - --------------------------------------------------------------------------------- - -via: https://news.itsfoss.com/how-i-started-loving-vim/ - -作者:[Theena][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://news.itsfoss.com/author/theena/ -[b]: https://github.com/lujun9972 -[1]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9JzM5MCcgd2lkdGg9Jzc4MCcgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJyB2ZXJzaW9uPScxLjEnLz4= -[2]: https://www.goodreads.com/book/show/29616237-first-utterance -[3]: https://itsfoss.com/open-source-tools-writers/ -[4]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9JzM5NScgd2lkdGg9Jzc4MCcgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJyB2ZXJzaW9uPScxLjEnLz4= -[5]: https://www.vim.org/ -[6]: https://itsfoss.com/install-ubuntu-server-raspberry-pi/ -[7]: https://itsfoss.com/how-to-exit-vim/ -[8]: https://kate-editor.org/ -[9]: https://itsfoss.com/best-free-open-source-alternatives-microsoft-office/ -[10]: https://linuxhandbook.com/basic-vim-commands/ -[11]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9JzI1MCcgd2lkdGg9Jzc1MCcgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJyB2ZXJzaW9uPScxLjEnLz4= -[12]: https://news.itsfoss.com/marko-saric-plausible/ -[13]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9JzIwMCcgd2lkdGg9JzM1MCcgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJyB2ZXJzaW9uPScxLjEnLz4= -[14]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/04/Interview-plausible.jpg?fit=1200%2C675&ssl=1&resize=350%2C200 -[15]: https://news.itsfoss.com/lutris-creator-interview/ -[16]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/03/lutris-interview-ft.png?fit=1200%2C675&ssl=1&resize=350%2C200 -[17]: https://news.itsfoss.com/ubuntu-21-04-multi-monitor-support/ -[18]: https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/03/multi-monitor-ubuntu-21-itsfoss.jpg?fit=1200%2C675&ssl=1&resize=350%2C200 diff --git a/sources/talk/20210508 My weird jobs before tech.md b/sources/talk/20210508 My weird jobs before tech.md deleted file mode 100644 index f275af1766..0000000000 --- a/sources/talk/20210508 My weird jobs before tech.md +++ /dev/null @@ -1,47 +0,0 @@ -[#]: subject: (My weird jobs before tech) -[#]: via: (https://opensource.com/article/21/5/weird-jobs-tech) -[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -My weird jobs before tech -====== -You never know where you will travel from your first job. -![Yellow plane flying in the air, Beechcraft D17S][1] - -I had a few weird jobs before I hit tech. - -I was a junior assistant in an aircraft repair shop, which meant tasks like cleaning dirty metal parts in solvent (wow, things were different back in the '70s). My most fun task there was ironing Dacron aircraft fabric onto the wooden ailerons and horizontal stabilizer on a beautiful old Beechcraft Staggerwing that was in the shop for a rebuild. - -One summer during university, I worked at the same airport on the team that mixed the fire retardant and pumped it into the fire suppression aircraft ("[water bombers][2]"). That was probably the dirtiest job I ever had, but loading the aircraft was pretty cool. There was a small flap about two meters off the ground that you would stick your finger into after attaching the filling hose to the coupling. Then the person on the pump would start the pump. When you felt your finger get wet, you waved for the pump master to stop the pump. Meanwhile, the incredibly noisy right-side radial engine was running a few meters in front of you, with the propellers doing a great job of blowing off all the red dust that accumulated on you from mixing the retardant in the first place. If you screwed up and let the airplane get too full, they would have to taxi over to a patch of ground and dump the load right there, since they would be too heavy to take off otherwise. - -Two other summers, I worked for the local Pepsi, 7-Up, and Orange Crush distributor delivering crates of soft drinks to stores and restaurants. That was definitely the most physically demanding job I ever had. Think of a five-high stack of wooden crates with each containing a dozen 750ml glass bottles of soft drinks on a hand truck. Think of pulling that up to a second-floor restaurant. Think of that restaurant getting 120 crates per week... 24 trips up those stairs and back down again with all the empties. A small truck would typically have 300 or so crates of soft drinks on board. We were paid by the load, not by the hour, so the goal was to get done early and hit the beach. - -### My tech jobs - -Delivering sodas was my last summer job during university. I graduated the next year with a degree in mathematics and a lot of computer courses, especially numerical analysis, under my belt. My first job in tech was working for a small computer services consultant. I used SPSS to do a bunch of analysis on some sport fishing surveys, wrote a few hundred lines of PL/1 to print concert tickets on the IBM 3800 laser printer in the service bureau where we rented time, and started working on some programs to analyze forest statistics. I eventually went to work for the client needing forestry statistics, becoming a partner in the mid-1980s. By then we were doing a lot more than measuring trees and no longer using a timesharing bureau to do our computations. We bought a Unix minicomputer, which we upgraded in the late 1980s to a network of Sun workstations. - -I spent some time working on a big development project headquartered in Kuala Lumpur, Malaysia. Then we bought our first geographic information system, and I spent most of my time in the late 1980s and 1990s working with our customers who needed to customize that software to meet their business needs. By the early 2000s, my three older partners were getting ready to retire, and I was trying to understand how I fit into the long-term picture of our no-longer-small company of 200 or so employees. Our new employee-owners couldn't really figure that one out either, and in 2002, I found myself in Chile, looking to see if the Chile-Canada Free Trade Agreement provided a reasonable opportunity to move some of our business to Latin America. - -That business started off formally in 2004. The Canadian parent, meanwhile, was badly sideswiped by a combination of some investments that, in the light of the 2007–2009 economic meltdown, no longer seemed so wise, and it was forced to close its doors in 2011. However, by that time, the Chilean subsidiary was a going concern, so our original employee and I became partners and purchased it from the asset sale. It's still going today, doing a lot of cool stuff in the social-environmental space, and I'm often a part of that, especially when my trusty mathematics and computational background are useful. - -As a side hustle, I develop and support a horse racing information system for a wonderful man who has made a career out of buying and selling racehorses in India. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/5/weird-jobs-tech - -作者:[Chris Hermansen][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/clhermansen -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/yellow_plane_fly_air.jpg?itok=pEcrCVJT (Yellow plane flying in the air, Beechcraft D17S) -[2]: https://worldairphotography.wordpress.com/2016/08/22/air-tanker-history-in-canada-part-one/amp/ diff --git a/sources/talk/20210529 My family-s Linux story.md b/sources/talk/20210529 My family-s Linux story.md deleted file mode 100644 index 33bfdbffde..0000000000 --- a/sources/talk/20210529 My family-s Linux story.md +++ /dev/null @@ -1,38 +0,0 @@ -[#]: subject: (My family's Linux story) -[#]: via: (https://opensource.com/article/21/5/my-linux-story) -[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -My family's Linux story -====== -Our first attempt at Linux was just an apt-get away. -![Terminal command prompt on orange background][1] - -My first attempt at Linux was one of those "maybe I should give this a try" kinds of situations. - -Back in the late 1990s, I found some kind of packaged Red Hat distro on quite a few floppies, bought a second hard drive for the family laptop, and set about installing it. It was an interesting experiment, but as I recall the family wasn't quite ready to share the computer to that extent. Fast forward to 2005, I finally broke down and bought a lovely Toshiba laptop that ran Window XP. At work, I had an aging Sun SPARCStation 5, and I didn't really like the direction the whole Solaris thing was going at that point (Motif-based desktop). I really wanted GIMP for some project or the other, but the convoluted journey to installing GNOME 1.x (was it 1.4? maybe) on Solaris was challenging. So, I was actually contemplating jumping ship to Windows XP. But after living with it on my home machine for a few months, I found myself liking that even less than trying to run GNOME on Solaris, so I installed Ubuntu Hoary Hedgehog 5.04 and then Breezy Badger 5.10 on my laptop. It was wonderful. That machine with its 3.2GHz Pentium, 2GB of memory, and 100GB hard drive ran rings around my SPARCStation 5. - -All of a sudden, instead of fooling around with cobbled-together Solaris packages to try to get stuff running, things were just an apt-get away. The timing was good, too. My family and I lived in Grenoble, France from August 2006 to July 2007, while my wife was on sabbatical. Because of the Linux Toshiba, I was able to take my work with me. At the time I was doing a lot of GIS data processing on a couple of big projects; I found I could do the same thing in PostGIS / PostgreSQL much more rapidly than with the incredibly expensive commercial GIS software we used back home in Canada. Everyone was happy, especially me.  - -The funny thing that happened along the way was that we took two other computers to France - my wife's similar Toshiba (running XP, which worked fine for her) and our kids' recently acquired new Toshiba laptop, also running XP. Just after Christmas, they had some friends over who inadvertently installed a nasty and impossible to remove virus on their computer. After several hours over a few days, one of my kids asked "Dad, can't we just install the same thing as on your computer"?  And poof, three new Linux users were created. My son, at 29 years old, is still a happy Linux user, and I'm guessing on his fourth or fifth Linux laptop, the last few all supplied by System76. One of my daughters was forced to convert to Windows when she started law school three years ago as her school had a mandatory testing framework that only would run on Windows and would allegedly detect things like VMs and whatnot (please don't get me started). And, my other daughter was seduced by a Macbook Air that her company bought for her. - -Oh well, can't win them all! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/5/my-linux-story - -作者:[Chris Hermansen][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/clhermansen -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/terminal_command_linux_desktop_code.jpg?itok=p5sQ6ODE (Terminal command prompt on orange background) diff --git a/sources/talk/20210606 How Real-World Apps Lose Data.md b/sources/talk/20210606 How Real-World Apps Lose Data.md deleted file mode 100644 index 6750837e98..0000000000 --- a/sources/talk/20210606 How Real-World Apps Lose Data.md +++ /dev/null @@ -1,56 +0,0 @@ -[#]: subject: (How Real-World Apps Lose Data) -[#]: via: (https://theartofmachinery.com/2021/06/06/how_apps_lose_data.html) -[#]: author: (Simon Arneaud https://theartofmachinery.com) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -How Real-World Apps Lose Data -====== - -A great thing about modern app development is that there are cloud providers to worry about things like hardware failures or how to set up RAID. Decent cloud providers are extremely unlikely to lose your app’s data, so sometimes I get asked what backups are really for these days. Here are some real-world stories that show exactly what. - -### Story #1 - -This first story is from a data science project: it was basically a big, complex pipeline that took data collected from ongoing research and crunched it in various ways to feed some cutting-edge model. The user-facing application hadn’t been launched yet, but a team of data scientists and developers had been working on building the model and its dataset for several months. - -The people working on the project had their own development environments for experimental work. They’d do something like `export ENVIRONMENT=simonsdev` in a terminal, and then all the software running in that terminal would run against that environment instead of the production environment. - -The team was under a lot of pressure to get a user-facing app launched so that stakeholders could actually see some results from their several months of investment. One Saturday, an engineer tried to catch up with some work. He finished an experiment he was doing late in the evening, and decided to tidy up and go home. He fired off a cleanup script to delete everything from his development environment, but strangely it took a lot longer than usual. That’s when he realised he’d lost track of which terminal was configured to point to which environment. - -### Story #2 - -Story #2 is from a commercial web and mobile app. The backend had a microservice architecture worked on by a team of engineers. That meant deployments required co-ordination, but things were simplified a bit using a formal release process and automation. New code would get reviewed and merged into master when ready, and every so often a senior developer would tag a release for each microservice, which would then automatically deploy to the staging environment. The releases in the staging environment would periodically get collected together into a meta-release that got signoff from various people (it was a compliance environment) before being automatically deployed to production. - -One day a developer was working on a complex feature, and the other developers working on that microservice agreed that the work-in-progress code should be committed to master with the understanding that it shouldn’t be actually released yet. To cut a long story short, not everyone in the team got the message, and the code got into the release pipeline. Worse, the experimental code required a new way to represent user profile data, so it had an ad-hoc data migration that ran on launch into production and corrupted all user profiles. - -### Story #3 - -Story #3 is from another web app. This one had a much simpler architecture: most of the code was in one app, and the data was in a database. However, this app had also been written under a lot of deadline pressure. It turned out that early on in development, when radical database schema changes were common, a feature was added to detect such changes and clean up old data. This was actually useful for early development before launch, and was always meant to be a temporary feature for development environments only. Unfortunately, the code was forgotten about in the rush to build the rest of the app and get to launch. Until, of course, one day it got triggered in the production environment. - -### Postmortem - -With any outage postmortem, it’s easy to lose sight of the big picture and end up blaming everything on some little detail. A special case of that is finding some mistake someone made and then blaming that person. All of the engineers in these stories were actually good engineers (companies that hire SRE consultants aren’t the ones to cut corners with their permanent hires), so firing them and replacing them wouldn’t have solved any problem. Even if you have 100x developers, that 100x is still finite, so mistakes will happen with enough complexity and pressure. The big-picture solution is back ups, which help you however you lose the data (including from malware, which is a hot topic in the news lately). If you’re not okay with having zero copies of it, don’t have one copy. - -Story #1 had a bad end: there were no backups. The project was set back by nearly six months of data collection. By the way, some places only keep a single daily snapshot as a backup, and this story is a good example of how that can go wrong, too: if the data loss happened on Saturday and recovery was attempted on Monday, the one-day backup would only have an empty database from the Sunday. - -Story #2 wasn’t fun, but worked out much better. Backups were available, but the data migration was reversible, too. The unfun part was that the release was done just before lunch and the fix had to be coded up while the production site was down. The main reason I’m telling this story is as a reminder that backups aren’t just about catastrophic data loss. Partial data corruption happens, too, and can be extra messy. - -Story #3 was so-so. A small amount of data was lost permanently, but most was recovered from the backup. Everyone on the team felt pretty bad about not flagging the now-extremely-obviously-dangerous code. I wasn’t involved in the early development, but I felt bad because the recovery took a lot longer than it should have. With a well-tested recovery process, I think the site should have been back online in under 15mins total. But the recovery didn’t work first time, and I had to debug why not and retry. When a production site is down and it’s on you to get it up again, every 10s feels like an eternity. Thankfully, the stakeholders were much more understanding than some. They were actually relieved that a one-off disaster that could have sunk the company only resulted in minutes of lost data and under an hour of downtime. - -It’s extremely common in practice for the backup to “work” but the recovery to fail. Often the recovery works when tested on small datasets, but fails on production-sized datasets. Disaster is most likely to strike when everyone is stressed out, and having the production site down only increases the pressure. It’s a really good idea to test and document the full recovery process while times are good. --------------------------------------------------------------------------------- - -via: https://theartofmachinery.com/2021/06/06/how_apps_lose_data.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 diff --git a/sources/talk/20210621 Why transparency is critical to your open source project-s security.md b/sources/talk/20210621 Why transparency is critical to your open source project-s security.md new file mode 100644 index 0000000000..1a0f806da7 --- /dev/null +++ b/sources/talk/20210621 Why transparency is critical to your open source project-s security.md @@ -0,0 +1,82 @@ +[#]: subject: (Why transparency is critical to your open source project's security) +[#]: via: (https://opensource.com/article/21/6/security-transparency) +[#]: author: (Ana Jimenez Santamaria https://opensource.com/users/anajs) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Why transparency is critical to your open source project's security +====== +A community's health and transparency are good measures of a project's +security. +![Lock][1] + +The Biden Administration's recent [executive order on cybersecurity][2] aims to improve [security assurance][3] and the use of best practices. Transparency and project health are two factors that help to support security across the entire software industry—especially now. + +### Software security is now open source software security + +Because [92% of modern applications][4] contain open source components, improving software security generally means improving open source software security. + +According to the Biden executive order: + +> "The trust we place in our digital infrastructure should be proportional to how trustworthy and transparent that infrastructure is." + +Transparency is a cornerstone of security assurance because it helps establish trust and confidence in the technology. Indeed, without transparency, trust and security evaporate. Therefore, one of the ways we can help improve security is by enhancing the transparency of our projects. + +Transparency through open source can provide information about a project that allows users to assess its health in at least two ways: + + * **Cross-community environments:** Cross-team and community collaboration are keys to meeting constantly evolving security, privacy, and safety standards. Security is a complex process involving multiple teams across a single organization and multiple organizations (i.e., cross-community), given its open source nature. + * **Public disclosure:** Transparency also enables organizations to quickly build and issue public security reports to identify potential threats and vulnerabilities. + + + +### How to measure transparency to achieve security assurance + +Open source should be in the DNA of every modern organization that wants to achieve a high level of transparency. However, transparency involves more than simply allowing access to code, products, designs, services, or APIs. Transparency is a **commitment to total clarity**. + +Open source has evolved into a complex ecosystem of projects and organizations with different kinds of relationships. [Open source program offices][5] (OSPOs) enable companies, public institutions, governments, and other organizations to keep tabs on the size and health of their open source ecosystems. They take care of not only the projects the organization is using but also the ones it's releasing or contributing to. + +One of the ways to measure transparency across open source ecosystems is by assessing the answers to the following questions about a community's health: + + * **How many maintainers are needed to keep the project sustainable?** The [Bus Factor][6] is a way to determine how many contributors a project can lose before it stalls. The metric (which hypothesizes what would happen if certain contributors got run over by a bus) calculates the smallest number of people who make 50% of contributions and visualizes the answer. + * **Who are the core developers?** The [Onion Model][7] is an approach to identifying the most committed developers and the ones the project relies upon most. + * **What organizations are involved in the software development process?** In addition to analyzing the number of companies whose employees make commits, issues, or code contributions, the [Elephant Factor][8] determines the minimum number of companies doing half of the work. + * **Does the software have security certifications?** Possessing well-known security certifications, such as the [Core Infrastructure Initiative Best Practices Badge][9], indicates that open source projects follow best practices and meet required certification criteria. + * **How active is the community?** There are various ways to assess whether a community is active. One way is to look at the community's reaction speed, including how fast issues are resolved vs. how many are ignored. + + + +Most of these questions are part of the [CHAOSS metrics][10] definition. Community Health Analytics Open Source Software (CHAOSS) is a Linux Foundation project focused on creating a standard set of metrics and software to help define open source community health. Its GrimoireLab tool makes it [easier][11] for projects to analyze and report their community health metrics. + +### Closing thoughts + +Open source software [took over the world][12] a long time ago. The Biden administration's new executive order is another reason to take the open source ecosystem seriously, as both public entities and private companies rely upon it. But open source innovation has a unique methodology that doesn't follow traditional business processes. Using open source involves [investing in OSPOs][13] and measuring transparency by looking at a project's health based on its activity to achieve the required security assurance. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/security-transparency + +作者:[Ana Jimenez Santamaria][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/anajs +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security-lock-password.jpg?itok=KJMdkKum (Lock) +[2]: https://www.whitehouse.gov/briefing-room/presidential-actions/2021/05/12/executive-order-on-improving-the-nations-cybersecurity/ +[3]: https://www.igi-global.com/dictionary/quantitative-security-assurance/70165 +[4]: https://blog.tidelift.com/open-source-is-everywhere-survey-results-part-1 +[5]: https://opensource.com/article/20/5/open-source-program-office +[6]: https://chaoss.community/metric-bus-factor/ +[7]: https://chaoss.github.io/grimoirelab-sigils/common/onion_analysis/ +[8]: https://chaoss.community/metric-elephant-factor/ +[9]: https://chaoss.community/metric-cii-best-practices-badge/ +[10]: https://chaoss.community/metrics/ +[11]: https://opensource.com/article/21/6/health-metrics-cauldron +[12]: https://techcrunch.com/2019/01/12/how-open-source-software-took-over-the-world/ +[13]: https://todogroup.org/guides/create-program/ diff --git a/sources/talk/20210625 How the Apache Software Foundation selects open source projects.md b/sources/talk/20210625 How the Apache Software Foundation selects open source projects.md new file mode 100644 index 0000000000..e8471bf7a3 --- /dev/null +++ b/sources/talk/20210625 How the Apache Software Foundation selects open source projects.md @@ -0,0 +1,65 @@ +[#]: subject: (How the Apache Software Foundation selects open source projects) +[#]: via: (https://opensource.com/article/21/6/apache-software-foundation) +[#]: author: (Justin Mclean https://opensource.com/users/justin-mclean) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +How the Apache Software Foundation selects open source projects +====== +The Apache Software Foundation (ASF) is built around a unique set of +processes and values to ensure openness. +![Wide open sky and trees][1] + +As a longtime volunteer and mentor (and current board member) at the [Apache Software Foundation][2] (ASF) and vice president of the Apache Incubator, I'm proud to offer my insights into the unique processes and values with which the ASF operates. + +Centered upon the permissive and pragmatic open source [Apache License][3], the ASF conducts itself differently from many other foundations simply because it is a charitable organization constructed for the public good. For example, the ASF board is elected by members. No one can buy a seat on the board, and the ASF's affiliations are with individuals, not companies. Generally, the corporate affiliation of any individual involved with ASF goes unstated, and it doesn't matter. As an outcome, the ASF has fostered a vendor-neutral environment where companies can comfortably collaborate on building valuable projects. + +Let's take a look at how the ASF selects its projects, the state of open source licensing today, and what you can expect from the ASF heading into the future. + +### The Apache Incubator process and 'The Apache Way' + +Potential Apache projects begin in the [Apache Incubator][4], where they receive assistance and mentoring toward their hopeful graduation as top-level Apache projects. Anyone is welcome to put together a project proposal for the Incubator (they simply need to find someone inside the ASF who's willing to help champion it). When vetting a potential project, the ASF prefers to see a diversity of people and entities involved—and certainly not just a singular corporate body. We've found this greater diversity results in projects that are more widely used and longer lasting. + +The central purpose of the Incubator is to help projects learn and operate in alignment with what we call [The Apache Way][5]. It is a set of values that inform best practices for community-led development. The most important aspects of The Apache Way include strict vendor-neutral independence and prioritization of a strong community, even over the strength of a project's code. Open and transparent communication is crucial as well: The ASF requires that all project communication is publicly accessible and permanently archived to enable asynchronous collaboration. In addition, the open source Apache License is attached to all accepted projects, ensuring that all source code is publicly available as well. + +At the Incubator, we initially look at whether a project is a good fit in terms of how it aligns with these Apache values. It isn't necessary to have 100% alignment, but the project needs to be willing to adapt. There will also be a discussion around ensuring that the project is fully compatible with Apache from a licensing perspective—in some scenarios, dependencies will be removed or replaced as needed. The Apache Way prepares projects to build communities that are self-sustaining. That said, it can be difficult for some projects to build a community, and some don't make it through the incubator. + +Another key element of The Apache Way—one essential to thriving communities—is making decisions based on consensus. In our experience, open discussions and avoiding a single individual project leader are mission-critical to that process. We have had a couple of incubating projects that included a strong personality trying to retain control, and well, those projects didn't succeed for that reason. + +### Open source and the Apache License + +Open source projects come in many varieties. At the same time, using an open source license doesn't automatically make a project open source. It's a project's community that unlocks open source benefits and whose contributions precipitate greater openness and transparency. + +Recently, some companies have made high-profile moves away from the Apache License to less-permissive licensing. If your company changes from an open source to a non-open source license, I have to question why you had that open source license in the first place. It probably meant that the business model didn't fit open source. I believe that by changing away from open source licenses, companies are doing a huge disservice to their communities and their users. + +As I said, the ASF is a non-profit, charitable organization that creates software for the public good. That's the purpose of the permissive Apache License. Making money off that software is fine, but that's not what the Apache License is about. As a rule, ASF disallows any field-of-use restrictions. _Anyone_ can use Apache projects for any reason. The idea behind true open source is that some people who use a project will give back to it, but contributions absolutely cannot be required. The companies that seem so hung up on that point need to understand that isn't how open source works, and that isn't how it should work. + +### The future of open source and the ASF + +Open source has certainly seen outsized adoption in the last five to 10 years and particular acceleration among enterprises. I think it's safe to say that there's hardly any software on the planet that doesn't include or rely upon open source projects in some way. That adoption is only going to grow. + +Unlike some foundations, the ASF is fairly hands-off in terms of project recruitment. Expect the ASF to continue as it has, stating the values of The Apache Way and working with those projects that see value in the ASF's approach. With ASF projects leading at the forefront of major industry shifts—initially with web servers and more recently with big data through projects like Apache Hadoop and Spark, Cassandra, and Kafka—the hands-off stance has shown to be successful and sustainable. + +When it comes to what's next, the ASF has several large and buzzed-about artificial intelligence and machine learning projects. In addition, several Internet of Things (IoT) projects have also been passing through the Apache Incubator, some of which will likely become quite influential. Looking forward, expect the ASF to continue as it has, introducing some hugely successful open source projects used by major industry players, with other smaller projects providing vital—if more niche—appeal. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/apache-software-foundation + +作者:[Justin Mclean][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/justin-mclean +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/nature_open_sky_tree.png?itok=2J79Futp (Wide open sky and trees) +[2]: https://www.apache.org/ +[3]: https://www.apache.org/licenses/LICENSE-2.0 +[4]: https://incubator.apache.org/ +[5]: https://apache.org/theapacheway/ diff --git a/sources/talk/20210630 How a college student founded a free and open source operating system.md b/sources/talk/20210630 How a college student founded a free and open source operating system.md new file mode 100644 index 0000000000..67d33c7b4a --- /dev/null +++ b/sources/talk/20210630 How a college student founded a free and open source operating system.md @@ -0,0 +1,150 @@ +[#]: subject: (How a college student founded a free and open source operating system) +[#]: via: (https://opensource.com/article/21/6/freedos-founder) +[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +How a college student founded a free and open source operating system +====== +An interview with FreeDOS founder Jim Hall. +![Puzzle pieces coming together to form a computer screen][1] + +[Jim Hall][2] is best known as the computer programmer who founded the FreeDOS project. Jim began the project in 1994 as a replacement for MS-DOS while he was still a student at the University of Wisconsin–River Falls. Jim created FreeDOS in response to Microsoft ending support for MS-DOS in 1994. Recently Jim agreed to an email interview. Correspondent Joshua Allen Holm joined me in posing the following questions to Jim. + +**Don Watkins: What kind of skill set invites you to write your own operating system?** + +I think even a beginner can get started writing an operating system like FreeDOS, although it would take a more advanced programmer to write the kernel. + +[I am a self-taught programmer][3]. I learned about programming from an early age by tinkering on our Apple II computer at home. Much later, I learned C programming—my brother was a computer science student when I was a physics student, and he introduced me to C. I picked up the rest by reading books and writing my own programs. + +I wrote a lot of small utilities that enhanced my command line on MS-DOS or even replaced certain DOS commands. And you can write a lot of those programs even with a basic level of programming experience. You can write file utilities like FIND, FC, CHOICE, TYPE, MORE, or COPY—or user commands like ECHO or CLS—with only an introduction to C programming. With a bit of practice, you can write system-level programs like ATTRIB, or the COMMAND shell. + +**DW: Were you inspired by Linus Torvalds when you decided to write your own version of DOS and how did that contribute to your licensing decision?** + +In a way, yes. I really liked DOS and had been using it since the early 1980s. I ran MS-DOS on my personal computer at university. But in 1993, I discovered Linux. + +I really liked the Unix systems in our campus computer lab, where I spent much of my time as an undergraduate university student. When I heard about Linux, a free version of Unix that I could run on my ’386 computer at home, I immediately wanted to try it out. [My first Linux distribution][4] was Softlanding Linux System (SLS) 1.03, with Linux kernel 0.99 alpha patch level 11. That required a whopping 2MB of RAM, or 4MB if you wanted to compile programs, and 8MB to run X windows. + +I dual-booted Linux with MS-DOS. I booted into Linux most of the time, but I still booted back into MS-DOS to write papers in a word processor, to use a spreadsheet program to analyze data for my lab classes or to play my favorite DOS games. + +In 1994, I heard that Microsoft planned to “do away” with MS-DOS. The next version of Windows would eliminate DOS. I didn’t like that, and I still wanted to run DOS. I decided that if folks could come together over the Internet to write something like Linux, surely, we could do the same with DOS. After all, DOS was fairly simple compared to Linux. + +On June 29, 1994, [I announced the “PD-DOS” project][5] to write our own DOS. I called it “PD” because I thought it would be in the public domain. But I quickly learned about the GNU General Public License that the Linux kernel used, and decided that was a much better license. No one could take our source code and create a proprietary version of DOS. We changed the name to “Free-DOS” after another week or so. We later dropped the hyphen to become “FreeDOS.” + +**Joshua Allen Holm: What are the advantages of using FreeDOS over alternative ways of running DOS applications (e.g., DOSBox)?** + +Using DOSBox to run DOS applications in Linux is a great way to run certain DOS applications. But DOSBox is really intended to launch a single DOS program, like a game. The DOS command line is pretty limited in DOSBox. + +In contrast, FreeDOS provides a full DOS command line. We include all of the commands you remember from classic DOS, and added other commands and utilities to do new things. FreeDOS also includes compilers and assemblers so developers can write new programs, utilities, and tools to make your DOS experience more useful, Internet programs to help you get on a network, and even open source games. + +**JAH: Looking back over the years you have worked on FreeDOS, is there anything you would have done differently?** + +There’s only one event that I wish I could take back. I occasionally reach out to companies that sold DOS applications in the 1980s and 1990s and ask them if they will release the source code to their old DOS programs under an open source software license. That’s a great way to contribute to the open source community. + +One popular DOS program was a replacement for the MS-DOS COMMAND shell. 4DOS, by JP Software, was an extremely powerful DOS shell and included many modern features. For example, 4DOS supported built-in aliases, color-coded directory listings, and a “swapping” mechanism that freed up more conventional memory to run programs. + +I contacted JP Software to ask if they would release the source code to 4DOS under an open source software license. JP Software had stopped supporting DOS, and instead focused on a similar replacement for the CMD shell in Windows NT, called 4NT. They were interested in releasing the source code to 4DOS but were concerned that someone might take the 4DOS source code and release a version for Windows. In effect, that would put JP Software in competition with their older product. + +I still didn’t understand the fine points of open source software licenses, and I gave them bad advice. I suggested they might start with an existing open source license and add a term that said you could only run it on DOS. They then released the 4DOS source code under a modified version of the MIT license. + +Unfortunately, limiting where you can run the software violates one of the tenets of open source software and free software. Users should be able to run open source software anywhere, and for any use. An open source license isn’t “open source” if you are limited to running it only on one operating system. + +So despite best intentions, I gave JP Software really bad advice there, and 4DOS isn’t actually open source software. We used to include 4DOS in FreeDOS—but as we are preparing the FreeDOS 1.3 release, we want to be careful to only include open source software. So FreeDOS 1.3 RC4 (“release candidate 4”) does not include 4DOS.  + +**JAH: What are some interesting ways people are using FreeDOS?** + +Over the years, I’ve seen people use FreeDOS to do a lot of really interesting things! + +One of the earliest cool examples was someone who built pinball machines like you used to see in arcades. He embedded a version of FreeDOS to track the score and update the video screen on the back of the machine. I don’t know exactly how he did this, but my guess is every target or bumper on the pinball board probably generated a keyboard event. You can write a DOS application to read the “keyboard” and update the score based on that. + +A few years ago, a user found a video of a train control system in Russia [that ran on a FreeDOS PC][6]. They rebooted the computer, and if you freeze the video at the right point, you can briefly see the FreeDOS kernel starting up. It disappears quickly, but you can see it at 0:07 in the video. + +More recently, I saw someone had managed to boot an original IBM PC 5150 with FreeDOS [from a vinyl record][7], using the 5150’s rarely used cassette tape storage port. It’s really cool to see FreeDOS being used this way. It’s a method that I would never have thought to try, but sometimes you have to do something just for the fun of it. + +**JAH: Why work on DOS in 2021?** + +We still work on DOS in 2021 for a few reasons. I guess the first reason is that DOS is still interesting. We’ve added a lot to FreeDOS over the years. Where the original MS-DOS had a limited set of commands, FreeDOS includes dozens of useful utilities and tools, including editors, compilers, assemblers, games, and other neat programs. + +But it has to be more than just a cool hobby. I find that working on FreeDOS makes for a very interesting programming challenge. In modern systems like Linux, you can take advantage of a lot of memory at once, and you can address it all in one big block. As a result, many programmers will load a lot of libraries and other code to create their projects. This is a very easy way to build a complicated project. You can build a very complex system in a very short time this way. And for many systems, time to market is the most important factor. + +Loading a bunch of libraries and other code blocks is very inefficient, however. You may have the same basic functionality implemented half a dozen ways across the different libraries because each library implements something their own way. So your code grows and requires more memory. + +Maybe that’s not a problem on a desktop PC. I run Linux, and my modern desktop PC has 32GB of memory. Loading a bunch of stuff into memory isn’t a big deal. But on a shared server, where you might have multiple instances of that project running, you’ll quickly run into memory limitations. How many instances can you run at the same time on a server? That 32GB of memory starts to look pretty slim. + +You can’t load all of that into memory on a DOS machine. To remain compatible with the original DOS, FreeDOS has all the limitations of DOS. When MS-DOS was popular, a powerful PC might have had 4MB, 8MB, or even 16MB of extended memory. But the computer only had 640kb of “main” memory, due to how DOS addressed memory. And that’s megabytes and kilobytes, not gigabytes. A kilobyte is a thousand bytes (the basic unit of memory). A megabyte is a thousand kilobytes. And a gigabyte is a thousand megabytes. So today’s computers have memory that is about 1,000,000 more than a DOS computer. + +By programming on a limited system like FreeDOS, you constantly have to think about the tradeoffs. How much memory does my program really need to do its job? Is it faster to read a file into memory to work on it, or process the file one bit at a time? And you’re always keeping in mind what libraries and other code you use in your program. A DOS program can only be so big, so you need to be careful about how you write a DOS program. + +When you write DOS programs all the time, you get really good at optimizing a program. You think about programming in a different way, because you’re always considering how to do something more efficiently. That’s a challenge, but an interesting one. + +**DW: How big is the FreeDOS community?** + +FreeDOS was a very popular project throughout the 1990s and into the early 2000s, but the community isn’t as big these days. But it’s great that we are still an engaged and active group. If you look at the news items on our website, you’ll see we post updates on a fairly regular basis. + +It’s hard to estimate the size of the community. I’d say we have a few dozen members who are very active. And we have a few dozen others who reappear occasionally to post new versions of their programs. I think to maintain an active community that’s still working on an open source DOS from 1994 is a great sign. + +Some members have been with us from the very beginning, and I’m really thankful to count them as friends. We do [video hangouts on a semi-regular basis][8]. It’s great to finally “meet” the folks I’ve only exchanged emails with over the years. + +It's meetings like this when I remember open source is more than just writing code; it's about a community. And while I've always done well with our virtual community that communicates via email, I really appreciated getting to talk to people without the asynchronous delay or artificial filter of email—making that real-time connection means a lot to me. + +**DW: How does someone get involved in the community?** + +I think our community is very welcoming, so anyone is free to join. We communicate via an email list, which you can find on the [FreeDOS website][9]. Join the freedos-user email list if you want to talk about FreeDOS or ask for help. Developers should join the freedos-devel email list; that’s where most of the FreeDOS developers hang out. Our email list volume is pretty low, so you aren’t likely to fill up your inbox by subscribing to either email list. + +A great way to get started is by writing or updating documentation, or by fixing bugs. I think that’s true of pretty much every open source project out there. We always need folks to work on the documentation and fix bugs. But for a project like FreeDOS, I think reading through the documentation is important if you’re new to DOS. A common mistake for newcomers is thinking of FreeDOS as a stripped-down version of Linux, when in fact DOS uses a different memory and execution model. You can learn about that by reading the documentation, which is why I recommend new contributors start there. + +For the more adventurous, we maintain a list of priority projects on our website. If you’d like to contribute to FreeDOS, but aren’t sure what needs work, you might consider tackling one or more of these projects: + + * If you’ve got some programming experience: + * Port FreeDOS utilities to OpenWatcom C and NASM—our preferred C compiler and Assembler for FreeDOS. (Some older FreeDOS programs were probably written for Borland C or Turbo C or Microsoft C, or Microsoft ASM or Turbo ASM) + + * Port GNU utilities to FreeDOS, such as using IA-16 GCC (while IA-16 GCC requires a ’386 or better to compile, programs compiled with IA-16 GCC run on all CPUs) + + * Create a new alternative shell, similar to COMMAND.COM but with expanded BAT programming + + * Add international language support to a FreeDOS program that currently only supports one language. + + * If you’re a highly-skilled DOS developer: + * Write a guest tool like VMSMOUNT for VirtualBox + + * Write a driver for modern sound cards + + * Add some kind of UEFI bootstrap BIOS emulator, perhaps implemented as a CSM + + + + +We like to make it easy for new contributors to get started in FreeDOS, and we welcome everyone who wants to work on FreeDOS. If you still don’t know how to contribute, feel free to ask on the email list. + +You can find FreeDOS at [www.freedos.org][10] +Join FreeDOS on Facebook at [facebook.com/groups/freedos/][11]  +Follow FreeDOS on Twitter at [twitter.com/freedos_project][12] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/freedos-founder + +作者:[Joshua Allen Holm][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/holmja +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/puzzle_computer_solve_fix_tool.png?itok=U0pH1uwj (Puzzle pieces coming together to form a computer screen) +[2]: https://opensource.com/users/jim-hall +[3]: https://opensource.com/article/20/8/learn-open-source +[4]: https://opensource.com/article/17/8/linux-anniversary +[5]: https://groups.google.com/g/comp.os.msdos.apps/c/oQmT4ETcSzU/m/O1HR8PE2u-EJ?pli=1 +[6]: https://www.youtube.com/watch?v=eAate0v8hDE +[7]: https://www.youtube.com/watch?v=bqz65_YfcJg +[8]: https://opensource.com/article/20/8/meet-open-source-collaborators +[9]: https://www.freedos.org/ +[10]: http://www.freedos.org/ +[11]: https://www.facebook.com/groups/freedos/ +[12]: http://twitter.com/freedos_project diff --git a/sources/talk/20210704 Pricing Yourself as a Contractor 101.md b/sources/talk/20210704 Pricing Yourself as a Contractor 101.md new file mode 100644 index 0000000000..31c258f304 --- /dev/null +++ b/sources/talk/20210704 Pricing Yourself as a Contractor 101.md @@ -0,0 +1,78 @@ +[#]: subject: (Pricing Yourself as a Contractor 101) +[#]: via: (https://theartofmachinery.com/2021/07/04/pricing_as_contractor_101.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Pricing Yourself as a Contractor 101 +====== + +I’ve been self-employed for most of my career. Sometimes I talk to other people who are interested in leaving a full-time job to do some kind of contracting or service business. By far, the most common newbie mistake that we all seem to make is in pricing ourselves. + +Take [this useful blog post that breaks down employee income vs freelancer income in the US][1]. It estimates that you need $140k revenue as a freelancer in the US to have the equivalent of $100k employee compensation. I remember finding calculations like that really useful when I first started a business. However, some people will look at the result and think, “Gee, I have to make 1.4x as much if I’m self employed. Can I really do that?” + +No, no, no. That thinking is backwards. + +### How to price yourself + +Let’s make up an example. Suppose you’re a full-time-employed software engineer grossing that $100k p.a., and you’re thinking of switching to contracting. + +When you’re self-employed, you have to think like a business because that’s literally how you’re making your living. So you have to add up all your costs and figure out how you’re going to recover them. Spreadsheets get a bad rap (for some good reasons), but they’re actually really useful for this stuff (and a lot of other calculations you’ll do as a business owner). + +The first cost to add to the tally is that $100k. If that sounds weird, it’s what’s called “opportunity cost”. You could have made $100k by staying employed; not making that is effectively a cost you have to justify when planning your business. Mark that cost down, along with any other employment benefits you actually use. If your employer offers on-site lunches, add what it costs you to get lunch each workday of the year. If your employer offers employee discounts on its fitness software, but you don’t use that software anyway, don’t add that benefit as an opportunity cost. + +Other costs depend on what you’re doing and where you live. Employee-provided health insurance isn’t as big a thing in Australia as in the US. On the other hand, compulsory superannuation payments (similar to the US 401(k)) are a big deal. I have my own company, and my major non-salary costs are insurance, accounting/filing, legal (for contract reviews, etc.), debt collection and various online service costs. If you’re counting something durable (like a desk) divide the cost by the estimated number of years you expect to use the thing. + +Anyway, so far this is basically what was in Caleb’s blog post, so to keep things simple, I’ll assume the same $100k nominal salary and $140k equivalent business cost. (Scale everything to match your own circumstances, of course.) Now you need to figure out how to recover that cost. There are about 255 Australian working days in a year, so if you could contract them all out, you’d charge $550 a day (plus sales tax). In reality, you won’t be able to bill the entire year. I’ve taken a higher-risk approach and averaged about 60-70% in the past 6 years of my current stint of self employment. [Accenture’s annual financial reports][2] say they get about 90% “utilization” from their contractors, which I assume means they bill 90% of the total workdays. Let’s assume you’re moderate and bill 75% of work days. That means you recover $140k of costs in 75% of 255 days (or 191 days) by billing about $730 a day (plus sales tax). + +### The mistake + +People new to contracting often react to numbers like that and think, “WTF?! That’s huge!” That’s just one example calculation, but it’s normal for service prices to be around double or more what you might naïvely guess from equivalent full-time employee rates. However, that day rate came from a simple calculation of how much you need to charge to get the equivalent of a $100k salary. It’s the same thing. Thinking otherwise is the critical mistake. + +New contractors are often still unsure. Won’t they sound _greedy_ asking for that much? If your clients have any clue, they’re doing pretty much the same calculation. “I could pay Gentle Blog Reader $730 a day for just as long as I want, or I could pay ~$140k for a full-timer who I won’t even really need every day.” A $100k salary isn’t actually $100k from the employer’s point of view, either. Basing prices on nominal base salaries just doesn’t make sense. Even if you’re selling B2C, your cluey competitors won’t be charging less, at least not sustainably. + +### Why it matters + +That specific example was for contracting, but it’s a basic rule of business economics: unless you’re trying some super-risky growth hacking (and we know how [Pets.com][3] turned out), you need to figure out your costs and set your price high enough to cover them. + +Some people still feel uncomfortable with the price they need to set, and they rationalise dropping the price. Perhaps they think something like, “I’m a really nice person, and if I charge only $400 a day my clients will be even happier.” The problem is that you won’t get the same clients. Cluey clients who would pay $100k a year base salary for an employee won’t pay $400 a day for a contractor to do the same job. Instead, in practice, you might get a few good clients who just didn’t have the budget for $730 a day, but you _will_ get a whole bunch of really bad clients. Think about it. If a stranger offered you a fancy-looking diamond ring for $50, would you pay? Or would you rather buy another ring for a normal price? + +Let me stress that I’m just taking the numbers from Caleb’s post and that everything is relative. Use your own numbers instead. In most parts of the world, $400 a day might be a fantastic rate. However, if you’re a senior fintech developer in Silicon Valley, charging $400 a day will just make you a magnet for terrible clients. Most of the good ones will know something isn’t adding up, and they’ll be scared away. + +What do I mean by bad clients? Browse through [the Clients from Hell blog][4] for a bit. It ranges from a lot of basic annoyance like clients who are never satisfied, or who make unreasonable demands, or who waste your time, all the way to clients who are outright abusive, or who get you to do work to spec before arguing they shouldn’t have to pay because “I don’t want it”. Some clients simply don’t pay at all. + +If _you_ don’t value your own product enough, don’t be shocked if you have customers who don’t value it enough, either. + +It gets worse, though. Good clients tend to work with other good clients. If you’re always available when you say you will be, would you work with people who waste your time? If you treat others with respect, would you work with people who are unreasonable and abusive? On average, your good clients will tend to refer you to other good clients. The reverse is true of bad clients, if they’re even grateful enough to refer you to anyone at all. Therefore, if you charge a good price, your business will tend to grow as you build a reputation. If you undercharge, you’ll find yourself in a downward spiral where you’re not only losing money, but finding it harder and harder to get proper pay at all. + +All of this is just a matter of averages, and if you’re lucky you’ll still get good clients even if you undercharge, and if you’re unlucky you’ll still get bad clients even if you charge the right price. However, if your revenue is already weak, each bad client will really hurt. Hoping to beat the averages isn’t a good plan. + +### “But no one pays that much!” + +Suppose you’re an experienced full-time engineer and you decide to try going independent. You’ll probably find that your calculated rate seems high compared to what you see on a freelancing website. That’s because it’s hard to build up a reputation on freelancing websites. Freelancing websites are most useful for casual buyers who primarily want a low price. + +I think a lot of smart engineers assume career networking is hard and requires super high levels of extroversion, so they have to rely on freelancing websites for work. The bad news is that you need to build up a good reputation to get good pay. The good news is that most people can do it as long as they have skills that are in demand. Networking isn’t about going to so-called “networking events” (they’re actually mostly terrible for networking). Networking tips would make a whole new blog post, but the key is to find good clients in their natural habitats, and to do the things that make them keep coming back and maybe even refer you to other good clients. + +In any case, don’t let freelancing websites or anything else set your price below the equivalent of what you could get from a full-time salary. In fact, [you might even get better than your current salary][5], which is why this is “Pricing 101”. Undercharging, however, will kill your self-employment career. + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2021/07/04/pricing_as_contractor_101.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://calebporzio.com/making-100k-as-an-employee-versus-being-self-employed +[2]: https://www.accenture.com/au-en/about/company/annual-report +[3]: https://en.wikipedia.org/wiki/Pets.com +[4]: https://clientsfromhell.net/ +[5]: https://theartofmachinery.com/2018/10/07/payrise_by_switching_jobs.html diff --git a/sources/talk/20210709 Apply lean startup principles to your open source project.md b/sources/talk/20210709 Apply lean startup principles to your open source project.md new file mode 100644 index 0000000000..3294521866 --- /dev/null +++ b/sources/talk/20210709 Apply lean startup principles to your open source project.md @@ -0,0 +1,224 @@ +[#]: subject: (Apply lean startup principles to your open source project) +[#]: via: (https://opensource.com/article/21/7/lean-startup-open-source) +[#]: author: (Ip Sam https://opensource.com/users/ipkeisam) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Apply lean startup principles to your open source project +====== +Lean startup principles help you manage your open source project with +efficiency and success. +![Mobile devices are a big part of our daily lives][1] + +There are a lot of benefits to starting an open source project. In general, open source projects benefit from collaboration, adoption, transparency, lower ownership costs, development best practices, more contributors and reviewers, and better quality. + +When you contribute to open source projects, you can build your technical and leadership skills, get good experience for your resume, learn new development tools, understand industry trends, work with top engineers around the world, gain mentorship opportunities, meet people with similar interests, improve your people skills, and more. + +When you develop your own open source project, you are much like the CEO of a startup company, and many startups use lean principles. This article demonstrates how you can apply lean startup principles to develop and advance your open source projects. + +### Come up with a good open source idea + +When brainstorming a good open source idea, consider three domains: industry, inventory, and customers. You want to come up with an idea at the intersection of these domains. For example, I am working on an open source project for the hybrid cloud. Cloud computing is my industry. Inventory could be the set of Ansible playbooks available for the cloud computing industry. The customers could be my OpenShift clients interested in using Ansible playbooks to set up their hybrid cloud infrastructure. These get me to the intersection of the three domains, and this could be a great open source idea. + +![A good open source idea][2] + +(Ip Sam, [CC BY-SA 4.0][3]) + +Once you identify your open source idea, start developing a proof of concept (PoC) prototype project, put it into a Git repository, and create the project's backlog: + + 1. Start a simple PoC prototype. + 2. Push the PoC into a public GitHub repository. + 3. Create your README, LICENSE, CONTRIBUTING, and CODE_OF_CONDUCT files. + 4. Set up high-level epics and stories in Jira. + + + +Next, start working on positioning your open source idea for long-term success. Consider your competitors' offerings, customers' needs, and company capabilities. For example, if I know customers want to do cloud automation in an OpenShift cluster, I understand the customers' needs. My team's capabilities are producing Ansible automation to automate OpenShift cluster installation and upgrades. And I need to make sure no competitors are doing similar work. In my open source project, I use Ansible for automation. Other companies may be using shell scripts or PowerShell scripts. Even though they are developing automation technologies, their offerings do not directly interfere with what my open source project is doing. Therefore, I can get into the sweet spot below. + +![Position your open source idea][4] + +(Ip Sam, [CC BY-SA 4.0][3]) + +### Use lean startup principles + +Managing risks is important for an open source project. At any time, a project can lose funding, people, and resources. Business requirements and scope can change. Release schedules can be delayed or canceled. Timelines can change with a lot of uncertainty. As the CEO of your open source project, you can use lean startup principles to minimize risks and maximize profits for your project. + +The lean startup principles focus on developing the minimal viable project (MVP) that gives you value from production as soon as possible. It also pushes for smaller release cycles and fast iteration. Using validated learning through feedback loops from production, you can validate your open source project and make modifications as product data becomes available. + +In the lean startup cycle, first, you come up with your open source idea. Then you convert your idea into code by doing a simple MVP. In between, you set up the build phase (where you build unit tests to ensure the quality of your code), continuous integration/continuous development (CI/CD) pipelines for automated deployments, the cloud computing infrastructure, the developer sandbox, and other development best practices. These are part of your build phase to enable your developers to code faster. + +You need to measure everything from coding to production data. For example, measure the MVP's usability to make sure end users can use it properly. Use monitoring and alerts so that you know when production issues occur. Static code analysis helps you catch code issues and security vulnerabilities. Finally, use feedback data from product users and stakeholders; it helps you measure faster. + +All of this data enables you to learn about your project. You can learn faster by doing more customer interviews or working with customers during development cycles. You can also learn faster by setting up cross-functional teams with other business departments. As you go through the lean startup cycles again in the second iteration, you should be able to code faster, measure faster, and learn faster than in the first iteration. + +![The lean startup cycle diagram][5] + +(Ip Sam, [CC BY-SA 4.0][3]) + +Lean startup methodologies help you create an idea, formulate hypotheses from your idea, create an MVP, and test the MVP to validate your hypotheses. Then you go through what you learned to fine-tune your hypotheses and start your second iteration. + +![Lean startup methodologies][6] + +(Ip Sam, [CC BY-SA 4.0][3]) + +Lean startup is a combination of customer development and agile development. It supports faster iterative development cycles and incremental product development. + +### Leverage design thinking, lean startup, and agile + +![Lean startup and agile][7] + +(Ip Sam, [CC BY-SA 4.0][3]) + +The figure below shows the three cycles of design thinking, lean startup, and agile. The first part is always design thinking (the green cycle), where you gather requirements to define your idea. Often, these come from product managers. Then you move to the lean startup (blue) cycle, where you come up with prototypes, do some experiments, and go through the learning period. Based on your learning, you can enter the agile (yellow) cycle. These often involve the typical two-week sprints, coming up with stories in your product backlogs, bringing stories from the backlog to sprint planning, doing sprint execution, moving stories to completion, and shipping incremental products to production by doing a deployment. At the end, you have the sprint review, sprint demo, and sprint retrospective. After completing the agile cycle, you go back to the blue cycle to begin the build process, measurement, and the next iteration. + +![Design thinking, lean startup, and agile cycles together][8] + +(Ip Sam, [CC BY-SA 4.0][3]) + +Often, you have multiple MVPs before you get to the final product. Use customer feedback and product data to shape the next MVP version. + +![Lean startup MVPs][9] + +(Ip Sam, [CC BY-SA 4.0][3]) + +The project management triangle helps you maintain product quality. Scope, cost, and time are the corners of the triangle. The shape of the triangle represents product quality. If you reduce your scope and costs, the triangle's shape will change, meaning your quality will decrease. + +![Lean project management][10] + +(Ip Sam, [CC BY-SA 4.0][3]) + +Lean startup principles can help you manage scope, cost, and time. By doing each release with the lean startup principles, you can get to incremental changes, small release cycles, small release feature sets, and feedback loops. For each idea, measure if it works, is making money, and generating business value. If your answer to each is yes, begin the reinvestment process to generate more new ideas. + +![Lean releases][11] + +(Ip Sam, [CC BY-SA 4.0][3]) + +### Recruit contributors and build a team + +Project marketing is an important starting point for recruiting contributors and investors into your open source project. Learn how to sell your project, present it at major conferences and events, and demo your PoC or MVP at local developer meetups. If you work for a large organization, you may be able to turn it into an internal project. + +Different people with different backgrounds, working styles, and cultures will come into your project, and your goal is to develop them into a high-performing team. The team will go through learning curves as it finds how to work together. For example, when you get new team members, your team's current working style may not fit them well, and you might get resistance. When individuals do not want to get out of their comfort zone to learn new skills, you might also get resistance. This might create a chaos situation, where team members disagree about how to do things. The team may split into different camps with different ideas. This brings team performance to the lowest point of the team maturity curve. When you reach the lowest point, listen to team members and work to understand their ideas and why people push back, then transform the different ideas into action items. You can leverage voting systems or use product data to validate the ideas. As conflicts are resolved, the team members will start to work better together and integrate their different ways of working into the overall team culture. This is where your team will reach a new status quo and team maturity. + +![Team maturity graph][12] + +(Ip Sam, [CC BY-SA 4.0][3]) + +The lean team management method can help you achieve team maturity. It leverages four levers of control: believe, boundary, measurement, and interactive. + + * **Believe:** This is your team's set of core values. For example, my team believes in quality as a requirement for each product. Therefore, quality is the team's core value. + * **Boundaries:** These relate to setting rules based on core values. For example, my team believes in quality, and we set rules to require unit and integration tests for each code change before committing it into the Git repository. This becomes a boundary for the team. If somebody checks in code without a test, that person is not following the rule, and it's time for you to educate the team members. + * **Measurement:** This includes key performance indicators (KPIs), targets, and budget. For example, my team's KPIs include measuring story cycle time in the sprint, story release time, defect rates, test coverage rate, and product issues. + * **Interactive:** The interactive process is where you revise the product based on your last cycle. Then you start the next iteration for the next set of core values. + + + +![Lean team management][13] + +(Ip Sam, [CC BY-SA 4.0][3]) + +### Minimize waste + +Eight types of waste—defects, overproduction, waiting, non-utilized talent, transportation, inventory, motion, and extra processing—in your development lifecycle harm team productivity. + + * **Defects:** It is cheaper to fix a defect early in the development lifecycle, so many teams use [test-driven development][14] (TDD) to reduce defects. + * **Overproduction:** If you are doing more than what you are asked to do, you are over-producing. This is tied to scope in stories; the scope should be small so that you do not risk overproduction. + * **Waiting:** Waiting is not efficient and wastes your team's resources. During sprint daily standups, identify stories that are blocked or waiting on external dependencies. As a scrum master, it is your job to help escalate these blocking issues to reduce waiting time. + * **Non-used talent:** Unused talent is always a waste, so ensure everyone on the team has enough work to do. + * **Transportation:** If you are moving projects from one team to another, you introduce more learning curves and ramp-up time. Try to reduce how much projects are transported. + * **Inventory:** Too much inventory that can't be sold is a waste. The inventory takes up space in your storage and consumes management time. + * **Motion:** Excessive unnecessary movements, such as going to meetings in different locations or even commuting, are a waste. Many organizations have a work-from-home policy to reduce motion waste. + * **Extra processing:** If you are doing the same validation test repeatedly on the same product, this extra processing might be a waste. Come up with a process flow in your development cycle so that you avoid extra processing. + + + +![Lean waste management][15] + +(Ip Sam, [CC BY-SA 4.0][3]) + +As the CEO of your open source project, your time is very valuable. If it's your job, you only have eight hours a day. If it's your side hustle, your time is even more limited. Lean time management involves a very simple matrix, as shown below. If you have a task that's important to the vision and must be done by you, go ahead and do it. If the task is important to the vision but can be done by a team member, delegate it. If the task is not important to the vision and must be done by you, minimize the time you spend on it. Finally, if the task is not vision-important and can be done by others, it is a waste of resources. + +![Lean time management][16] + +(Ip Sam, [CC BY-SA 4.0][3]) + +### Develop a lean strategy + +Lean strategy is a good way to analyze your open source product to come up with a long-term strategy. Ask yourself these questions: If your open source product did not exist, would your customers suffer any real loss? If so, what type of loss would it be? Is it difficult for your customers to replace your products to meet their needs? For example, if I am doing Ansible playbooks for cluster automation, can my customers replace my Ansible playbooks using a set of shell scripts? What would be the impact on the operational costs and learning curve? + +![Lean strategy questions][17] + +(Ip Sam, [CC BY-SA 4.0][3]) + +The lean strategy hierarchy is (from bottom to top) mission, values, vision, strategy, and balanced scorecard. At the base is your mission: Why do your open source project and team exist? What is your mission statement? Next are the values your team believes in. Vision is how you expect your product to evolve in the next two years. Strategy requires strategic planning. At the very top is the balanced scorecard, where you implement and monitor the plan for your open source project. + +![Lean strategy hierarchy][18] + +(Ip Sam, [CC BY-SA 4.0][3]) + +Your lean strategy statement includes your objective, scope, and competitive advantage. The objective defines what your strategy is designed to do and achieve in a specific time frame. The scope identifies the strategy requirements for your open source product to be successful. Your competitive advantage is the core of your strategy. How will you compete with competitors using this product and your strategy to achieve your objective? + +![Lean strategy statement][19] + +(Ip Sam, [CC BY-SA 4.0][3]) + +Pricing and differentiation are two important factors for achieving profit. You want to offer low price and high differentiation. Ask yourself: How is your product different from your competitors'? What are some features that are unique to your product? If you can maximize differentiation and minimize pricing, you will get to the profit frontier line. + +![Lean Profit Management][20] + +(Ip Sam, [CC BY-SA 4.0][3]) + +### Look to the future + +After running your open source project for a while and tracking everything, it's time to consider where you want to focus next on your journey as the CEO of your open source project. + +Begin by assessing perspective, capability, and profit potential. + + * Perspective involves how your product fulfills customers' needs. For example, can my Ansible playbook reduce manual operations in the OpenShift cluster to save 20% of the customer's operation costs? + * Capability is what your product can do and what new features it can offer. For example, can my Ansible playbooks operate in a way that supports OpenShift 3 and OpenShift 4 clusters? On-premises clusters versus AWS clusters? + * Profit potential includes how much revenue your product is generating for you in a time frame. Does your product fall into the profit frontier margin in the image above? + + + +![What's next?][21] + +(Ip Sam, [CC BY-SA 4.0][3]) + +Open source is the future. There is a lot going on in the open source community, and many companies are moving to open source models. Open source is a great way to get people involved in your project, and lean startup principles help you manage your open source project with efficiency. It will help you and your open source project go a long way. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/lean-startup-open-source + +作者:[Ip Sam][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/ipkeisam +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/mobile-demo-device-phone.png?itok=y9cHLI_F (Mobile devices are a big part of our daily lives) +[2]: https://opensource.com/sites/default/files/uploads/1_opensourceidea.jpg (A good open source idea) +[3]: https://creativecommons.org/licenses/by-sa/4.0/ +[4]: https://opensource.com/sites/default/files/uploads/2_positioning.jpg (Position your open source idea) +[5]: https://opensource.com/sites/default/files/uploads/3_leanstartupcycles.jpg (The lean startup cycle diagram) +[6]: https://opensource.com/sites/default/files/uploads/4_leanstartupmethodologies.jpg (Lean startup methodologies) +[7]: https://opensource.com/sites/default/files/uploads/5_leanstartupagile.jpg (Lean startup and agile) +[8]: https://opensource.com/sites/default/files/uploads/6_designthinkingleanstartupagile.jpg (Design thinking, lean startup, and agile cycles together) +[9]: https://opensource.com/sites/default/files/uploads/7_mvps.jpg (Lean startup MVPs) +[10]: https://opensource.com/sites/default/files/uploads/8_projectmanagementtriangle.jpg (Lean project management) +[11]: https://opensource.com/sites/default/files/uploads/9_leanreleases.jpg (Lean releases) +[12]: https://opensource.com/sites/default/files/uploads/10_teammaturity.jpg (Team maturity graph) +[13]: https://opensource.com/sites/default/files/uploads/11_leanteammanagement.jpg (Lean team management) +[14]: https://opensource.com/article/19/10/test-driven-development-best-practices +[15]: https://opensource.com/sites/default/files/uploads/12_leanwastemanagement.jpg (Lean waste management) +[16]: https://opensource.com/sites/default/files/uploads/13_leantimemanagement_0.jpg (Lean time management) +[17]: https://opensource.com/sites/default/files/uploads/14_leanstrategy.jpg (Lean strategy questions) +[18]: https://opensource.com/sites/default/files/uploads/15_leanstrategyhierarchy.jpg (Lean strategy hierarchy) +[19]: https://opensource.com/sites/default/files/uploads/16_leanstrategystatement.jpg (Lean strategy statement) +[20]: https://opensource.com/sites/default/files/uploads/17_profitfrontier.jpg (Lean Profit Management) +[21]: https://opensource.com/sites/default/files/uploads/18_whatsnext.jpg (What's next?) diff --git a/sources/talk/20210716 Dear Mozilla, Please Remove This Annoying ‘Feature- from Firefox.md b/sources/talk/20210716 Dear Mozilla, Please Remove This Annoying ‘Feature- from Firefox.md new file mode 100644 index 0000000000..cd4031ab75 --- /dev/null +++ b/sources/talk/20210716 Dear Mozilla, Please Remove This Annoying ‘Feature- from Firefox.md @@ -0,0 +1,66 @@ +[#]: subject: (Dear Mozilla, Please Remove This Annoying ‘Feature’ from Firefox) +[#]: via: (https://news.itsfoss.com/mozilla-annoying-new-tab/) +[#]: author: (Abhishek https://news.itsfoss.com/author/root/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Dear Mozilla, Please Remove This Annoying ‘Feature’ from Firefox +====== + +Despite its receding user base, Mozilla Firefox has remained my primary browser. Mozilla has revamped Firefox in the last couple of years and have added several features to it specially focused on protecting user privacy. I respect that. + +However, there is one ‘feature’ that annoys the hell out of me. This so-called feature relates to the auto-update of Firefox in the background. + +Auto-upgrade immediately remind of Windows updates. I mean, Windows is infamous for the forced restarts and updates, right? + +![Image Credit: Digital Trend][1] + +But why am I talking about this in reference to Firefox? Because Firefox, too, has a ‘Windows-que’ feature. + +It updates Firefox in the background. No problem there. That’s not entirely a bad thing. + +But then if you try to open a website in the new tab, it won’t let you do that unless you restart the browser. + +![][2] + +And that small thing stops the users from keep going with their work. What the hell, Mozilla! + +You may argue that it’s not that much of a pain. A quick restart won’t bring your world down, Abhishek. + +Right but imagine you are busy at work. You have more than 20 tabs opened. That’s normal if you are trying to troubleshoot as a developer, sysadmin, student or just trying to learn something in your field of interest. + +You cannot open a new webpage anymore. You have to restart the browser and when you restart, you have to click on each tab manually because Firefox does not load the previously opened webpages on its own. Sure you can see the tabs but the web pages are not actually loaded. + +This should be considered a bug, not a feature. Users should be given a choice to between rebooting right away or doing it later. + +I don’t remember any other browser infringing like this on its users, not even Google Chrome. But somehow Mozilla eggheads thought that this is a good “feature” to add to their open source browser. + +No, Mozilla! This is not a feature. This is a bug and should be fixed. You just cannot annoy your users like this otherwise they will be forced to use [alternate browsers like Brave][3] or Vivaldi and of course, Chrome. + +I end my rant and leave the field open for you. What do you think of these forced restarts by Mozilla Firefox? + +### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! + +If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. + +I'm not interested + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/mozilla-annoying-new-tab/ + +作者:[Abhishek][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/root/ +[b]: https://github.com/lujun9972 +[1]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQyNyIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[2]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjMwOCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[3]: https://news.itsfoss.com/chrome-like-browsers-2021/ diff --git a/sources/talk/20210718 17 open source technologists share their work-from-home uniforms.md b/sources/talk/20210718 17 open source technologists share their work-from-home uniforms.md new file mode 100644 index 0000000000..b8dd681da9 --- /dev/null +++ b/sources/talk/20210718 17 open source technologists share their work-from-home uniforms.md @@ -0,0 +1,117 @@ +[#]: subject: (17 open source technologists share their work-from-home uniforms) +[#]: via: (https://opensource.com/article/21/7/work-home-uniforms) +[#]: author: (Jen Wike Huger https://opensource.com/users/jen-wike) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +17 open source technologists share their work-from-home uniforms +====== +Nerdwear of the technically employed. What's your style? +![Taking a walk outside][1] + +As the world turns and some folks begin returning to the office, I feel it's a good time to ask our community of open source techies: _What's your work-from-home (WFH) uniform?_ + +Do you dress like you would if you were going into the office? Or are you more comfortable in workout clothes or even your PJs? Do you have a template you stick to most days? + +I have a format that helps me feel both productive and comfortable, and if I need to run an errand in public, I don't have to change first: A clean, nice-fitting shirt (T-shirts are OK) on top of comfortable pants (yoga is OK but not pajama). I've leaned into my stash of T-shirts from fun conferences I've attended with people I miss seeing and locales in my home state that make me proud. + +Some Opensource.com friends and contributors weigh in on their work-from-home uniforms below. What's yours? + +* * * + +Over the last eight years, I've learned that if I try to work in my PJs, I will get nothing done. In warm weather, I'm in shorts (cargo, of course) and a T-shirt. In cooler weather, it's jeans and a T-shirt with a sweater or hoodie. Never shoes, but I'll wear socks once my feet start getting cold. —[Ben Cotton][2] + +Last winter, I un-ironically told two friends: "I miss my clothes." Most of my wardrobe went untouched for a year, not because I had outgrown or no longer liked my outfits, but because I had nowhere to wear them. Working from home means I'm exercising at least once before, during, or after work. Between walking a (very brisk-paced) dog and taking a class at the gym on my lunch break, I often work in sneakers complete with bike shorts and a tank top. But when the situation calls, I can pop a cardigan on to look more professional. —[Lauren Maffeo][3] + +Before the pandemic, I tried dressing like I was going to do something that day. WFH was a privilege, and I really appreciated it, as it afforded me the ability to take care of my needs and work at the same time. Once the pandemic hit though, it became tiring to put on a front that I was going somewhere because, well, no one was. Most of the time, I'm wearing a Red Hat or Kubernetes/Cloud Native T-shirt and workout shorts. I live in Michigan, though, so those shorts get swapped out for joggers when it's cold. But that's pretty rare given my office is pretty warm thanks to all the computers. Oh, and slippers, like right now because my feet are cold for some reason. —[Chris Short][4] + +My WFW (work from work) uniform was always conference T's, jeans/cargo pants, and sandals or sneakers. So, my wardrobe hasn't changed... Well, that's not exactly true: Having not replenished my supply of conference T's, some of them have become a bit ratty, but I'm not on camera. And my hair is a bit messier. Sidenote: The New York Times had a recent [article][5] on a slide in hygiene and grooming during COVID, and, according to the article, many are saying they're going to remain a bit sloppier post-COVID. —[Kevin Cole][6] + +I used to wear suits and professional woman's wear for the office. Now I get to go back to the tech WFH uniform: nerd shirt, pants/skirt. Often I add a scarf to jazz it up for video. I wear shoes because my feet get cold. My colleagues mock me, but I do my hair and makeup every day. How I missed all my nerdware and hoodies due to "serious non-tech office jobs." —[Heather Leson][7] + +I try to stay dressed at home like there could be a strong reason to go out at short notice with my shoes and go-bag near the door. Too many years living in earthquake country, I guess. —[Stefano Maffulli][8] + +I wear pajamas most of the time, but I keep a "video shirt" ready in case I need to go on video for some reason. For a template, my day is driven by the calls and meetings on my calendar. During my breaks there, I'll run up and down the stairs a few times just to stretch my legs. —[Peter Gervase][9] + +No video meetings for me, but shorts and T-shirts are the regular. Jeans when it's colder. —[Bob Murphy][10] + +I love playing around with color, so I wear five different colored tops (mostly not ironed) for five days, paired with comfortable cotton pants. I love my earrings, so I match my tops and earrings. Every now and then, I do wear my jeans and other formal outfits to make sure that I fit into them. —[Nimisha Mukherjee][11] + +I start my day in gym clothes because I squeeze in a morning workout before I hit the keyboard. My current WFH uniform is a T-shirt or polo and shorts. I try to wear shorts as much as I can when I WFH. In fall and winter, I stick to chamois shirts, fleeces, and jeans. I end my day back in gym clothes because I hit the gym four out of five nights during the week. —[Will Kelly][12] + +My WFH outfit is the same as my office outfit: knit shirts and jeans. Unlike some of my colleagues, I have not grown a beard and let my hair get long and shaggy. A bike racer I knew once said, "You dress like a bum, you ride like a bum," and I feel the same is true for me: "You dress like a bum, you work like a bum." —[Gary Smith][13] + +I learned long ago when I started full-time remote work, that I needed to do the whole "get up, get ready, get dressed like you were going into the office" thing, providing some structure to my day and to get my head in "the right place" for work. Jeans, T-shirt, socks, boots (or shoes, but mostly boots1), and my ever-present head wrap. I don't know about everyone else, but I have a space that is dedicated for work, and I have my EDC2 bag that I take to and from my home office with my personal belongings, the same as I would any other job. When it is time to stop working, I pick up my bag and take it with me as a signal to myself that I'm done for the day. —[Kevin Sonney][14] +1 You keep livestock, you wear boots. I'm sure you can guess why. +2 "Every-day carry" + +I get up every morning at about the same time, around 7:30am, and get dressed in comfortable, casual clothes. I've been doing this for the last eight years since I retired. I have a light breakfast, and in the summer, I walk between four and five miles. Then I return home and begin my morning routine of juice or tea and toast, then checking email, attending meetings (more on Zoom or other virtual platforms this year). Keeping a routine is important to me, and dressing comfortably is, too. —[Don Watkins][15] + +At one point in my life, I was a chef. So, I have a bunch of chef pants, which are really comfortable but not stylish. I've been wearing them over the winter combined with some of my "ugliest" conference T-shirts. A couple of years ago, a coworker visited Russia and was staying with a family that had a grandmother who loved knitting wool socks. So, he brought wool socks back for everyone. So, ugly chef pants, ugly conference T-shirt, and wool socks hand-knitted by a Russian grandma. —[Craig Sebenik][16] + +My WFH uniform is not much different from my regular outfit. I like to be comfortable, no matter if I'm at home or talking in front of a thousand people at a conference. That means that I'm in T-shirts all around the year, no matter if it's WFH or a large IT event. It's one of the perks of being an engineer, not in sales or management. The only difference is that I wear jeans in public and something more comfortable, like sports pants, at home. —[Peter Czanik][17] + +It has been at least 30 years since I wore suits, then (for a while) "business casual." Most days now, I start early in my jammies. Wednesdays, I start with my yoga pants and top because my online yoga class starts at 9:30. Other days I change into jeans or cargo shorts and a solid black, conference, or other geeky T-shirt after breakfast. I always shave because that is one thing that makes me feel civilized. I am "retired," so I don't feel any need at all to have a different video presence other than my "normal" mode of dress. Besides, the only video meetings I attend are the Opensource.com and Enable Sysadmin weekly writer calls. —[David Both][18] + +The only rule is there are no rules! I wear whatever I want, mostly a Red Hat T-shirt and shorts or jogging pants. If I have an important meeting, I try to be more presentable. —[Kedar Vijay Kulkarni][19] + +Before walking the dogs, I am in sleepwear and a dressing gown while eating toast and having that first coffee. After the dog walk, I'm in shorts/polo/T-shirt if it's warm enough, or jeans/cargo pants if it's colder. I tend towards classic Shadowman shirts if I'm not on customer calls or major internal briefings, and the newer Red Hat logo-based shirts if I need official branding. Sadly, we're heading into winter here in New Zealand, so hoodies and jeans are starting to become a bit more normal. For my 3am calls with the United States, I've got a snug dressing gown and a warm drink. —[Steven Ellis][20] + +Thanks to the Opensource.com Correspondent program, here's my Spring, Summer, Fall, and Winter uniform. —[Chris Hermansen][21] + +![Opensource.com swag, a spring outfit][22] + +  + +![Opensource.com swag, a winter outfit][23] + +  + +![Opensource.com swag, a summer outfit][24] + +Summer + +* * * + +What's your WFH uniform? Are you in a T-shirt and pajama pants, or do you dress as if you're going into the office? Please share your remote work attire in the comments below. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/work-home-uniforms + +作者:[Jen Wike Huger][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jen-wike +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/walking_selfcare_wfh_outside_520.png?itok=64WmWspJ (Taking a walk outside) +[2]: https://opensource.com/users/bcotton +[3]: https://opensource.com/users/lmaffeo +[4]: https://opensource.com/users/chrisshort +[5]: https://www.nytimes.com/2021/05/06/health/shower-bathing-pandemic.html +[6]: https://opensource.com/users/kjcole +[7]: https://opensource.com/users/hleson +[8]: https://opensource.com/users/reed +[9]: https://opensource.com/users/pgervase +[10]: https://opensource.com/users/murph +[11]: https://opensource.com/users/nimisha +[12]: https://opensource.com/users/willkelly +[13]: https://opensource.com/users/greptile +[14]: https://opensource.com/users/ksonney +[15]: https://opensource.com/users/don-watkins +[16]: https://opensource.com/users/craig5 +[17]: https://opensource.com/users/czanik +[18]: https://opensource.com/users/dboth +[19]: https://opensource.com/users/kkulkarn +[20]: https://opensource.com/users/steven-ellis +[21]: https://opensource.com/users/clhermansen +[22]: https://opensource.com/sites/default/files/uploads/spring_2.jpg (Opensource.com swag, a spring outfit) +[23]: https://opensource.com/sites/default/files/uploads/winter.jpg (Opensource.com swag, a winter outfit) +[24]: https://opensource.com/sites/default/files/uploads/summer.jpg (Opensource.com swag, a summer outfit) diff --git a/sources/talk/20210718 Is Open-Source Software Secure.md b/sources/talk/20210718 Is Open-Source Software Secure.md new file mode 100644 index 0000000000..d6d249b54b --- /dev/null +++ b/sources/talk/20210718 Is Open-Source Software Secure.md @@ -0,0 +1,163 @@ +[#]: subject: (Is Open-Source Software Secure?) +[#]: via: (https://news.itsfoss.com/open-source-software-security/) +[#]: author: (Ankush Das https://news.itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Is Open-Source Software Secure? +====== + +Being someone who prefers [Linux for desktop][1] and encourages using open-source software, you may expect the answer to the question raised in the headline with a big “**Yes**“. + +But I am not going to limit discussing the benefits of open-source software. Let us explore more! + +Here, I plan to share my thoughts on if open-source software is secure and what are the things involved in it that make secure or insecure. + +### Why Should You Care if Open-Source Software is Secure? + +No matter whether you use [Linux][2] or any other operating system, you will be surrounded with open-source software in some way (directly/indirectly). + +To give you an example, most of the proprietary software tools depend on some form of open-source libraries to make things work. + +Furthermore, there is a reason why companies of various scale (including Google, Microsoft, and Facebook) rely on open-source software or contribute their resources to the open-source community in one way or the other. + +Hence, the security of open-source software is something essential to know about. + +### Myths About Open-Source Software Security + +![][3] + +While there are several arguments to pitch the cons of open-source software in terms of security, some of them just do not make any sense. + +#### Anyone Can See & Exploit the Code + +The code is accessible to everyone, yes. But just because you can see the code—does that mean anyone can exploit it? + +**Not really.** + +Even though anyone can create a fork (or copy) of the software, the original software cannot be manipulated easily. + +Usually, the project maintainer (or a group of them) manage the code repository and accept the commits from contributors. The code is reviewed before approval. And no one can hijack the code just like that. + +**It takes effort for an attacker to exploit a vulnerability or add malicious code in a software, no matter if it is open-source or closed source.** + +#### Without Dedicated Resources, Security Breaks down + +Many believe that without dedicated employees or a team for an open-source software, it is difficult to maintain security. + +In contrast, with several types of contributors joining and leaving, the software gets more attention from a wide range of developers. + +And they may be able to spot security issues better than a few employees assigned for a proprietary software. + +Some projects from the likes of Mozilla have a dedicated team to effectively iron out security issues. Similarly, most of the successful open source projects have plenty of resources to dedicate for security. + +Hence, the open-source software ecosystem is a mixed bag for security. Even without dedicated resources, the projects get help from various contributors, and some are profitable to a great extent which helps them dedicate more resources. + +### Open Source Software is Secure: Here’s How + +![][3] + +Now that we have tackled the myths, let me highlight how open-source software deals with security issues. + +In other words, the benefits in security with open-source software. + +Not to forget, the perks of open-source software translate to some of the reasons why [Linux is better than Windows][4]. + +#### More Eyes Looking at the Code + +Unlike a proprietary software, access to code is not limited to a few developers. + +Some projects may even have thousands of developers watching the code, reviewing them, and flagging or fixing security issues. + +And this gives an edge over closed-source software by having **the ability to identify issues quickly and addressing them as soon as possible.** + +Not just limited to more developers, often enterprises get involved with open-source projects that they utilize. And when they do, they will also go through the code and review it. + +This gives another source of external audit that may help improve the security of the software. + +In contrast, with a closed-source software, a limited number of developers may not be able to find all kinds of security issues. And it may take them longer to fix all the issues one by one. + +#### Community Decision Making to Prioritize Security Issues + +The developers of a closed-source software may have certain restrictions and priorities as what to work on and when to resolve an issue. + +However, in case of an open-source project, the community of contributors can prioritize and assign themselves what they want to work on and when to fix an issue. You do not need to depend on a vendor or follow their instructions to address a security issue. + +The decision making that goes into addressing and fixing the security issues is more transparent and flexible in case of an open-source software. Hence, it can prove to be more effective leaving you with three specific benefits: + + * **Transparency** + * **No dependency on the vendor** + * **Faster security updates** + + + +### Open Source Software is not Bulletproof: Here’s Why + +![][3] + +While there are cases where open-source software may get an edge for security, there could be instances or factors that affects it. + +It is important to acknowledge that these problems exist, accordingly, an enterprise or an individual can make better decision about the state of security for an open-source software. + +#### Not enough Eyes to Review Code and Uncertainty + +Even if the code is accessible the world of developers, there are chances that a **project does not have enough contributors/developers to thoroughly review the code**. + +In that case, we cannot have great confidence of an open-source software being peer-reviewed, because it lacks exactly that. + +The open-source software may “claim” to have the best security just because its open-source, which is misleading when there are not enough developers working on it. + +Also, we do not know how many developers are looking/reviewing the code and how exactly the code walkthrough is going on. + +For instance, the Heartbleed bug was spotted after 2 years of its introduction in a project that was already popular i.e **OpenSSL**. + +#### Software Responsibility or Accountability + +This may not be important for individuals, but an **open-source software often comes with no warranties**. + +So, if a business uses it, they must take the responsibility of any losses or damages caused by the use of that software. + +This is something that tells you that nothing can be 100% secure and bug-free. No matter how many eyes you have on a code, or how skilled the contributors are, there will be risks in some form, be it security or data loss. + +And this brings us to the fact that open-source software is not bulletproof. + +### Open Source May Have its Edge for Better Security But… + +Nothing is superior when it comes to security. No matter if it is closed-source or open-source, the same set of principles apply when it comes to security. + +There are various external factors that can affect the security of a software, and **many of those are not source dependent**. + +The code must be monitored in the same way to keep things secure. + +Yes, the **open-source approach introduces benefits that closed-source software will never have**, but that does not mean that it is bulletproof. + +_What do you think about the state of security when it comes to open-source software?_ _Do you think it is superior to proprietary solutions?_ + +I would appreciate your valuable thoughts in the comments down below. + +#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! + +If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. + +I'm not interested + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/open-source-software-security/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://news.itsfoss.com/linux-foundation-linux-desktop/ +[2]: https://itsfoss.com/what-is-linux-distribution/ +[3]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQzOSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[4]: https://itsfoss.com/linux-better-than-windows/ diff --git a/sources/talk/20210727 Avoid this common open source scanning error.md b/sources/talk/20210727 Avoid this common open source scanning error.md new file mode 100644 index 0000000000..a30000b983 --- /dev/null +++ b/sources/talk/20210727 Avoid this common open source scanning error.md @@ -0,0 +1,90 @@ +[#]: subject: (Avoid this common open source scanning error) +[#]: via: (https://opensource.com/article/21/7/open-source-scanning-error) +[#]: author: (Jeffrey Robert Kaufman https://opensource.com/users/jkaufman) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Avoid this common open source scanning error +====== +Why do source-code scanners sometimes report incorrect license +information? +![Target practice][1] + +[Pete Townshend][2], legendary guitar player for British rock band The Who, is well-known for playing suspended chords. Suspended chords add musical tension to a song. For those piano players reading this who (like me) love to play in the key of C, simply play a C major chord (the notes C, E, and G) and replace the E note with either an F or a D. You are now on your way to becoming a British rock star![1][3] + +Music is often filled with combinations of chords, like suspended chords, that provide tension, then release. Although adding tension to a musical composition is desirable, adding tension to scanning software with open source tools is certainly unwelcome. + +An issue at Red Hat involving scanning software led me to write this article. + +Recently, an important customer raised a concern after scanning some of our software's source code. As you may know, Red Hat provides the source code of its software. The customer's scanning tool reported that a certain software file was licensed under the GPLv3, which was not expected. In fact, the software file was explicitly and solely marked as being licensed under the Apache 2.0 license. The customer requested that we look into this issue, and we were happy to do so. + +After our in-depth research, we concluded that their scanning software is clearly incorrect. We developed a hypothesis that explains the anomaly, which I will now explain. + +A popular type of open source software scanning tool compares the software being scanned to vast repositories of preexisting open source software and reports any matches. For example, assume there is an open source file named MIT.c that returns an integer one higher than the integer passed to it. In other words, it is a simple adder. It could look like this: + + +``` +Copyright 2021 Jeffrey R. Kaufman + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +int foo(int x) { +        x+=1; +        return x; +} +``` + +For this hypothetical example, assume that MIT.c was placed in a GitHub repository named The Simple Maths Project as an open source community-based project for solving simple arithmetic problems. This project contains many other similar C language files, all under the same MIT License. + +Since this hypothetical example function is so useful (of course it isn't, but stay with me here), it was included to provide simple arithmetic utility in many other open source projects on GitHub. Also, assume that one of these other projects, named The Sustained Chord Calculator, uses this MIT.c source file from The Simple Maths Project to help calculate the musical formulation for suspended chords. + +The hypothetical Suspended Chord Calculator project, in addition to using MIT.c, also includes several source files licensed under GPLv2. When The Suspended Chord Calculator project is compiled, you can assume the resulting executable will contain both GPLv2-licensed software and the MIT-licensed MIT.c as one combined work in such a way that MIT.c cannot be reasonably considered independent and a separate work in itself. That resulting executable would rightly be considered licensed under the GPLv2, and the obligations of the GPLv2 must be complied with. Compliance means providing (or offering to provide for three years) all of the sources used to create the binary or executable, including all the software files licensed under GPLv2 and MIT.c. + +Moving back to our problem… + +Suppose one of your software products uses MIT.c, in addition to your own authored software. Since MIT.c is solely under the MIT License, this would obligate you to comply with only the MIT License terms, which is easy to do. Typically, people comply by providing a copy of the MIT License along with the copyright notice with their software distribution. Or, if you are a company like Red Hat, providing the source code that contains the license text is also a method of compliance—and my recommended approach. (See [_An economically efficient model for open source software license compliance_][4].) + +If you decide to scan the source code of your software product using a source-code scanner of the type that references repositories of open source projects, your scanner may likely report that MIT.c is licensed under the GPLv2! Why? Because it will see MIT.c, in source-code form, associated with The Suspended Chord Calculator project licensed under the GPLv2 and assume, naively, that MIT.c also must be subject to GPLv2 terms. This is notwithstanding that the MIT.c source file is clearly marked with an MIT License, and you copied it only from the original MIT-licensed The Simple Maths Project. + +This is an unfortunate consequence of using these types of scanning systems. In this example, such systems will erroneously report generally every single open source project in its repository that uses MIT.c. There could be tens, hundreds, or even thousands of programs that use MIT.c, all under different licenses, and you will be provided with a giant stack of projects to review indicating that MIT.c could be MIT licensed, BSD licensed, GPLv2 licensed, or, frankly, carry any other open source license under the sun from a project that just happens to use MIT.c. And in the end, you will discover that the file was solely under MIT.c. In my experience, there are very few situations where this type of scanning is warranted and, even when it is justifiable, that the file license results are something other than you expected. It happens, but it is rare. + +There is another type of software scanning system that reports on licensing by looking only for matches to known license texts in the source files of the project. This type of scanner would detect the MIT License text in the source code and correctly report that the software is subject to the terms of the MIT License, notwithstanding the fact that MIT.c may be used in many other open source projects under varying license terms. Although this type of source-code scanner can also have false positives, in my experience, source-code scanners of the type that reference repositories of open source projects have significantly higher rates of misreporting for the reasons discussed previously. + +Frankly, source-code scanners that reference repositories of open source software to ascertain license data can be useful in certain situations, such as when you may be hyper concerned that an engineer has inadvertently copied and pasted source code from an unacceptable license without also copying over the applicable license text. In that situation, a source-code scanner of the type that looks only for matches to license texts would not detect that inclusion. However, as I stated before, this situation is exceptionally rare, making repository-matching source-code scanners prone to errors and a waste of resources for tracking down the truth. This is time and resources that could be devoted to more issues of substance. You can also address this situation by training your developers to never copy software from another source without also copying over any applicable license. + +A scanner that reports the incorrect license is doing a tremendous disservice to your organization by requiring you to resolve a false positive. Countless hours of wasted resources are devoted to these wild-goose chases…as our customer experienced. + +We won't be fooled again! + +* * * + +_I want to thank my colleague Richard Fontana for suggesting the title of this article. Read some of his great articles on Opensource.com under the [Law section][5]._ + +1\. If you want to learn more about music theory and suspended chords, check out Rick Beato's analysis of another great track from The Who at [What Makes This Song Great?™ Ep. 96 The Who][6]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/open-source-scanning-error + +作者:[Jeffrey Robert Kaufman][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/jkaufman +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/target-security.png?itok=Ca5-F6GW (Target practice) +[2]: https://en.wikipedia.org/wiki/Pete_Townshend +[3]: tmp.K7c2OyIB7H#1 +[4]: https://opensource.com/article/17/9/economically-efficient-model +[5]: https://opensource.com/tags/law +[6]: https://www.bing.com/videos/search?q=rick+biato+what+makes+this+song+great+who&view=detail&mid=BBF5E938C3E5AD6D73BCBBF5E938C3E5AD6D73BC&FORM=VIRE diff --git a/sources/talk/20210730 What do we call post-modern system administrators.md b/sources/talk/20210730 What do we call post-modern system administrators.md new file mode 100644 index 0000000000..3ae582f9cc --- /dev/null +++ b/sources/talk/20210730 What do we call post-modern system administrators.md @@ -0,0 +1,76 @@ +[#]: subject: (What do we call post-modern system administrators?) +[#]: via: (https://opensource.com/article/21/7/system-administrators) +[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +What do we call post-modern system administrators? +====== +Our community discusses the responsibilities, possible titles, and +potential skills of today's sysadmins. +![Multi-colored and directional network computer cables][1] + +For today's sysadmin, many companies expect you to have cross-platform knowledge, network knowledge, _and_ application knowledge. Add to that a dash of programming ability, a pinch of sysadmin experience, a heaping portion of social skills, and a fanatical commitment to reliability and automation. + +What do we call this new, post-modern sysadmin? Do we use the same term and simply stretch the responsibilities? Or do we give this evolved role a new name? + +We chatted with friends at [Enable Sysadmin][2] and in the Opensource.com Correspondent program to get their thoughts. Here's what we heard: + +### Possible titles + + * How about Enterprise Architect or Solutions Architect?  + * Or are we talking more of a DevOps Engineer or Site Reliability Engineer? + * What level of experience and expertise are we looking at? Maybe an Applications Specialist or IT Helpdesk Administrator? + * Overheard: Platform Engineer or System Engineer + + + +### Potential skills + + * setting up a new user account in Google Workplace or similar + * configuring and ordering laptop, cell phone, service contracts + * software training (teaching a new user how to use kanban boards, shared storage solutions, or similar) + * preparing “procedures” manuals + * monitoring and checking security settings and storage usage + * keeping an eye on pooled storage + * deactivating a user leaving us + * arranging for pickup of equipment + * working with a user and provider having personal equipment difficulties + * keeping an eye on internet connection services, telephone services + + + +### Lingering questions + +Does today's sysadmin need to understand clustering, containers, FS sharding, unicast/multicast coms, and other similar topics? + +Is there a dividing line between infrastructure and systems? + +Could the title of systems administrator remain the same while the role changes? + +Does the image of a sysadmin crawling under the desk to fix broken cupholders still apply? + +Are most of today's sysadmins already using a PaaS approach in tandem with doing the basic administrative tasks of managing users, accounts, applications, and licenses? + +Are they also a helpful resource for colleagues, acting as an interpersonal bridge between other departments and IT? + +**Share your thoughts and experiences in the comments.** + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/system-administrators + +作者:[Joshua Allen Holm][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/holmja +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/connections_wires_sysadmin_cable.png?itok=d5WqHmnJ (Multi-colored and directional network computer cables) +[2]: https://www.redhat.com/sysadmin/ diff --git a/sources/talk/20210731 Dealing with burnout in open source.md b/sources/talk/20210731 Dealing with burnout in open source.md new file mode 100644 index 0000000000..6d45dcf71c --- /dev/null +++ b/sources/talk/20210731 Dealing with burnout in open source.md @@ -0,0 +1,105 @@ +[#]: subject: (Dealing with burnout in open source) +[#]: via: (https://opensource.com/article/21/7/burnout-open-source) +[#]: author: (Kiran Oliver https://opensource.com/users/kiranoliver-0) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Dealing with burnout in open source +====== +What it is, why you should care, and how you can help prevent burnout. +![Red heart with text "you are not alone"][1] + +Burnout is something you don't expect to happen to you—until it does. The technology industry is one of the worst offenders; over [60% of industry professionals][2] report they've experienced burnout. Sixty percent! Chances are, you or someone you know has dealt with it. How can we tackle such a staggering burnout rate if those who make decisions about mental health barely know what burnout is, never mind how to prevent it? + +The answer is to start simple. Ask the question "what is burnout?" and go from there. + +![Definition of burnout][3] + +(Kiran Oliver, [CC BY-SA 4.0][4]) + +### Autistic burnout, neurodivergence, and mental health + +At [Upstream 2021][5], the Tidelift event that kicked off Maintainer Week celebrating open source maintainers, I gave [a talk about burnout in open source][6]. The individuals who attended my presentation shared their experiences with burnout and mental health as a whole, which are undeniably linked. + +Burnout manifests in cognitive, emotional, and physical symptoms. It can take on different forms that are unique to the individual experiencing it. + +Also, people who are [neurodivergent][7] (e.g., have autism, ADD/ADHD, dyslexia, dyspraxia, etc.) may have standard burnout symptoms, but it can also manifest as [autistic burnout][8], which is often harder to pin down. Crucially, burnout in neurodivergent employees can look like someone is slacking off, not doing their job, or missing important details, when none of these things are correct. + +### How to help people experiencing burnout + +When addressing burnout on a team, managers can do a few things to ensure the team has a psychologically safe environment: + + 1. Ask your human resources department if your insurance company offers mental health services. + 2. Make sure employees know about your company insurance plan's mental health benefits. + 3. Offer flexible time off. + 4. Be flexible with deadlines, if possible. + 5. Use asynchronous meetings. + 6. Embody best practices by taking time off and encouraging your team to do so. + 7. Learn to recognize the signs of burnout in yourself and others. + + + +As an individual contributor, you might be wondering how you can help your teammates. Here are some things that you can do: + + 1. Assign someone to triage issues, or implement an auto-labeling process on your team's kanban and ticketing systems. + 2. Make use of integrations and [productivity tools][9].  + 3. [Automate your business processes][10] wherever possible. + 4. Have a clearly defined process for code reviews. + 5. Encourage maintainers and contributors to take breaks. + 6. Understand and recognize the signs of burnout in yourself and others. + + + +### Burnout in open source communities + +In open source communities, burnout can lead to not responding to pull requests or leaving issues open for an extended period of time. It can look like missing meetings, roadmap deadlines, or general forgetfulness. It can also produce emotional fatigue, [anxiety][11], and stress, so someone might be more tired than usual or speak in a tone of voice different from their usual. They may also feel drained and lack the motivation to contribute to open source while struggling with burnout. For open source project maintainers, burnout can be a real challenge that the entire industry must continue to address. + +![What's under the surface of burnout][12] + +(Kiran Oliver, [CC BY-SA 4.0][4]) + +Recognizing burnout requires vulnerability on behalf of the person experiencing it as well as understanding and compassion from any person told about a team member feeling this way. If someone tells you they are burned out, respect and keep this information private. Do not broadcast it publicly, nor share it with anyone who does not need to know for official medical or legal reasons.  + +### Key takeaways + +Burnout is a genuine issue that impacts many open source practitioners. Here are some tips for how to address it in open source organizations and communities: + + * Be more accepting of neurodivergence in the workplace. + * Create supportive policies and procedures for employees in your organization or open source community that may be experiencing burnout. + * If you are a contributor to a large open source project, make sure you use automation and tools that allow people to step away and take a break with ease. + * Lean on your community for support. + * Learn to recognize the signs of burnout—not only in yourself but also in others. + * Support your community, and remember that it's okay to admit to feeling burned out. + + + +Do you have any other tips for dealing with burnout, either personally or with your open source colleagues? Please share them in the comments. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/burnout-open-source + +作者:[Kiran Oliver][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/kiranoliver-0 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/red-love-heart-alone-stone-path.jpg?itok=O3q1nEVz (Red heart with text "you are not alone") +[2]: https://usblog.teamblind.com/wp-content/uploads/2020/03/TheStateof-Burnout2020.pdf +[3]: https://opensource.com/sites/default/files/uploads/burnoutdefinition.png (Definition of burnout) +[4]: https://creativecommons.org/licenses/by-sa/4.0/ +[5]: https://upstream.live/ +[6]: https://www.youtube.com/watch?v=WlQmwAJc5n4&list=PLDlsR_qA-s0gbycSxXNQIF_LhsMThD3Zi&index=9 +[7]: https://neurocosmopolitanism.com/neurodiversity-some-basic-terms-definitions/ +[8]: https://www.autism.org.uk/advice-and-guidance/topics/mental-health/autistic-fatigue/autistic-adults +[9]: https://opensource.com/article/21/1/open-source-productivity-apps +[10]: https://camunda.com/solutions/human-workflow/ +[11]: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6424886/ +[12]: https://opensource.com/sites/default/files/uploads/burnouticeburg.png (What's under the surface of burnout) diff --git a/sources/talk/20210805 Your one-on-one meeting doesn-t have to be this way.md b/sources/talk/20210805 Your one-on-one meeting doesn-t have to be this way.md new file mode 100644 index 0000000000..d0ba255c60 --- /dev/null +++ b/sources/talk/20210805 Your one-on-one meeting doesn-t have to be this way.md @@ -0,0 +1,86 @@ +[#]: subject: "Your one-on-one meeting doesn't have to be this way" +[#]: via: "https://opensource.com/open-organization/21/8/one-on-one-meeting-tips" +[#]: author: "Catherine Louis https://opensource.com/users/catherinelouis" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Your one-on-one meeting doesn't have to be this way +====== +One-one-one meetings are opportunities for growth. But that's only +possible if you're transparent and collaborative about them. +![A hand reaching out.][1] + +Whenever I'm speaking with colleagues and clients near the end of a quarter, I often hear from managers rushing to squeeze their one-on-one meetings with employees into tight deadlines. Every time I ask an employee if they've enjoyed their one-on-one with a manager, the answer is unanimously "no." And every time I ask a manager if they've enjoyed their one-on-one with an employee, the answer is unanimously "no, but I have to do it." + +So what we have is a constantly recurring event that no one seems to prioritize, no one seems to enjoy, and no one seems to benefit from. And we choose to end every fiscal quarter like this. + +But it doesn't have to be this way. By thinking and acting openly, we can reframe and reinvent our one-on-one meetings to be productive, beneficial, and even _enjoyable_. + +Managers and other organizational leaders [bear their own set of responsibilities and can apply their own tactics for opening up one-on-one meetings][2]. In this article, I'll discuss what employees can do to ensure more open, honest, compelling, and fulfilling one-on-one meetings with their managers—and offer some examples of ways they can initiate the conversation. + +### Be transparent about your goals + +Be clear with your manager about the goals of your one-on-ones. This might sound strange; however, without structure and clear intent, these meetings can quickly go astray. Before the meeting, really think about what you want to accomplish and how your manager could help you achieve this. Which of your manager's more admirable skills and abilities could you benefit from learning more about? Are you in this role as a stepping stone for another position? Do you have a difficult time negotiating with certain stakeholders, and could your manager help with this? To decide what to prioritize in your one-on-ones, try this: Write today's date one year from now, then imagine the place where you want to be in your career. Using this vision as a starting point, work backward and craft goals you believe your manager can help you achieve on the road to getting where you'd like to be. + +**What this sounds like:** "I'd really like for our one-on-ones to be a dedicated time with you for open-ended conversation, for coaching, mentoring for me to achieve my next goal of {X} to get to know one another better, to provide each other context, or even for venting." + +And at the end of your _current_ one-on-one meeting, establish the goals of your _next_ one-on-one meeting and record them (see below) so you're both clear on what you'll need to prepare to discuss. + +**What this sounds like:** "Given that you've provided me with a path forward, I think the focus of our meeting should be my increased network opportunities with this new contact that you will have provided me." Or, if you're stuck and don't sense an immediate opportunity for forward movement (sometimes the case with sticky problems) end your meeting with a question to establish clear goals: "What can we both do between now and our next meeting to make progress on this situation?" + +So what we have is a constantly recurring event that no one seems to prioritize, no one seems to enjoy, and no one seems to benefit from. And we choose to end every fiscal quarter like this. + +### Accelerate your meeting cadence + +Change is easier when opportunities for feedback are more frequent. Ask your manager to let _you_ schedule one-on-one meetings with her, letting her know they'll happen more frequently than every quarter. Find your meeting cadence based on what is really happening in your work context. Always conclude your current one-on-one meeting by scheduling your next one. Soon you'll get into a nice rhythm. And try not to skip one-on-ones; instead of cancelling, reschedule them. + +**What this sounds like:** "I'd love help with my career here at {company X}, and to do this I'd like to be able to access your calendar for guidance at the time I'll have the need." + +To accelerate your feedback cadence even further, consider asking your manager to provide direct feedback in context rather than waiting to receive this feedback in a one-on-one at some later date. If you wait until the end of the quarter to hear feedback, there's very little you can learn, as you'll probably not remember what even happened to prompt the feedback you actually needed three months earlier. + +**What this sounds like:** "Would you mind giving me direct feedback at the time you notice something? I like to learn immediately, in context, and if it's praise or criticism, please provide this feedback with me privately." + +### Close your feedback loops + +One-on-one meetings should be rich opportunities for mutual feedback. Before you've finished, don't forget to remind your managers what you need from _them_, too. And most importantly, make sure they follow through. Even when people are acting with the best intentions, they're still busy and important conversational threads that begin in meetings can get lost when everyone gets back to work. You know how it goes: You've had a fantastic one-on-one with your manager. You've discussed a sticky situation, and your manager says, "I have a great solution for this. I have a colleague working in a different department who I believe knows a great deal about this, and I promise to get back to you with more guidance before our next meeting next month." And then the next meeting happens and you've both forgotten all about it. + +Keep an open, accessible, _shared record_ of what you've discussed at your one-on-one meetings and update this to include specific actions both you and your manager will take before you meet again. Reinforce your needs verbally; stress how important they are, and be clear that the focus of your next one-on-one will be the items you've already told your manager you need to do your best work. + +**What this sounds like:** "Wow that would be great. It's really important to me. Let's write this down so we don't forget." + +One-on-one meetings should be rich opportunities for mutual feedback. Before you've finished, don't forget to remind your managers what you need from them, too. + +### Skip status updates + +Don't let your one-on-one become another status meeting. Why? + + * If the discussion concerns a product you're working on, others on your team would likely benefit from being part of it; if you're being updated now, you're a bottleneck for this information. + * If you go down this path, you'll have no time to discuss the things you've already said you need to discuss (see above).  + * It's easy for your manager to listen, but it's also a way to avoid difficult conversations; attending a Scrum of Scrums meeting, for example, would be the place to hear updates. + + + +**What this sounds like:** "Every team member updates their status daily just prior to the Daily Scrum and the status of the three teams can be heard in the Scrum of Scrums. I'd rather use this hour with you to get your coaching on my career, problems with negotiating with stakeholder Y, and feedback on my personal development progress. If we don't have time to do this now, can we reschedule?" + +### Working for you? + +One-on-one meetings should be productive and energizing. If they aren't, you might need to open them up a bit. Hopefully the ideas I've shared here can help you do just that. And perhaps you have your own tips for making your one-on-one meetings spectacular. I hope you'll share them if you do. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/21/8/one-on-one-meeting-tips + +作者:[Catherine Louis][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/catherinelouis +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareer_job_rh1x_1.png?itok=b1dy5tlv (A hand reaching out.) +[2]: https://opensource.com/open-organization/18/5/open-one-on-one-meetings-guide diff --git a/sources/talk/20210811 My first programming language and early adventures.md b/sources/talk/20210811 My first programming language and early adventures.md new file mode 100644 index 0000000000..529b8ef4f9 --- /dev/null +++ b/sources/talk/20210811 My first programming language and early adventures.md @@ -0,0 +1,116 @@ +[#]: subject: "My first programming language and early adventures" +[#]: via: "https://opensource.com/article/21/8/my-first-programming-language" +[#]: author: "Tomasz Waraksa https://opensource.com/users/tomasz" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +My first programming language and early adventures +====== +A student in 1988 in Poland is invited to a computer lab. +![Old UNIX computer][1] + +A few days ago, contributors to Opensource.com were asked to share our personal stories about how we got into programming. Many entertaining and fascinating responses were submitted. It would be interesting to quantify these data in time. Intriguing patterns emerged. The 70s generation was nostalgic about Fortran, punch cards, and dial-up access to shared mainframes. 80s kids (amongst which I qualify) shared stories of C, BASIC, or Pascal and their beloved Atari and Commodore computers. Surprisingly few stories from the 90s arrived. Almost like there's a generation gap. Maybe teenagers were running away in horror from C++, MFC, and the dreaded Hungarian notation, which was the order of the day. Then there's strange silence from the youngest generation. Maybe our young Raspberry Pi enthusiasts are [too busy making things][2]. + +Here's more about my road to programming. + +### My first programming language + +My first programming language was Microsoft BASIC. I learned it on the mighty MSX SpectraVideo 738 home PC. The MSX standard was a home computer architecture based on the Z80 CPU. Developed in the 80s by Microsoft, it was produced by Sony, Philips, Pioneer, Sharp, Yamaha, and many other vendors. My home country is Poland, and we were still under communist rule, and cut off from modern IT technology due to economic sanctions against us. But the winds of change came during the late 80s, and the MSX Spectravideo made it to my school. + +![MSX Specravideo 738][3] + +Image CC BY-SA [Hans Otten][4] + +I was a student at the time, so I wasn't paid. I got so fascinated with programming that I would be willing to pay myself for the pleasure. Thankfully, all schools and universities were free at that time. Imagine you would start your IT career with zero debt! I started during my early high school years, in 1988 in Poland. I had been growing long hair, playing guitar, listening to Black Sabbath, and hoping to have a rock band one day—all the while missing out on computers. And I had a friend, who I'll call Mr. Briefcase. He was another student, and also a computer nerd with a reputation. He entered the room one day and asked _how are you?_ He had to listen to me for a while, because the Polish _will_ tell you how they are, if you ask. Then he said: _"Hey, I'm going to the computer lab. You can join me. There's no one there today except me."_ I jumped excitedly: _"The entire evening?"_ He answered: _"Sure thing. I'll be busy, but you can play games and stuff."_ + +When we first entered the lab, it felt like a Star Destroyer command center from [Star Wars][5]. The following hardware was available: + + * One beautiful IBM PC clone, Spectravideo SVI-838 xPress-16 with an excellent clickety keyboard—no modern mechanical keyboard has yet been able to replicate that experience. Unfortunately, it was off-limits for newcomers like me. + * ZX Spectrums—I was not too fond of these, since they looked like toys with their rubbery keyboards. + * Futuristic MSX SVI-738 computers with color screens and Seikosha dot-matrix printers. + + + +The choice was made. I played for a while but got bored very quickly. I asked Mr. Briefcase: + +**Me**: _So what is it that you’re doing?_  + +**Briefcase**: _Programming._  + +**Me**: _How do you do that?_  + +**Briefcase**: _Here._ + +And he threw a manual at me. + +### Hello world + +I ran through the "hello world!" examples, and then stumbled onto a chapter about computer graphics. It turned out that our MSX had impressive graphic capabilities. After an hour of struggling with English, which was still foreign to me, there it was—my first working computer program, written in BASIC. I was thrilled, flabbergasted, and completely hooked. I could command this computing device to _do things_. Beautiful things. Utterly stupid things. Boring things. And it would do them all, without hesitation, line after line, only sometimes responding with `Syntax error!` + +It was pure magic! The very next day, I signed up for the computer lab. + +### Computer graphics + +In the following months, I had a lot of fun with computer graphics. Those machines were amazingly efficient in educating young people in computing. Programming a language interpreter was the only way to interact with it. It booted, and you had to enter commands to do anything useful. If you were curious enough, you would inevitably ask—are there more commands? In the end, you got sucked into programming without even knowing it. The entry threshold was so low. + +![Code][6] + +Image CC0 Alan Smithee + +For example, to draw a circle on the screen, all I had to do was: + + * Boot the computer and wait a few seconds. Yes, it only took seconds to boot! + * Write `10 CIRCLE 100`,`100`,`50` and press **ENTER**. Yes, we had to number the lines ourselves. + * Write `run` and press **ENTER**. + + + +There was a simplicity to programming in those days. Today, you have choices to make before you write a single line of code. You have to choose your development platform (web, desktop, both), your programming language, your framework, and more. + +Of course there are always choices to make, but it feels simpler when all you need are a few resources, and when your computer has only **64kB** of memory—the usual on 8-bit machines. To give you a sense of scale—a single high-resolution desktop icon on my Pop_OS Linux box can be bigger than that. Yet within this tiny memory, it could run an operating system and an academic-grade compiler. It could run graphic programs with flawless sprite animation and collision detection. It would play percussion tracks through a programmable noise generator. I have to admit, [I know it's possible][7] but I hardly know where to begin with these kinds of activities today. + +### Pascal and beyond + +My MSX had a 3.5" floppy drive—an amazing thing these days. One day we received floppies with the CPM 2.2 operating system and a [Turbo Pascal 3.0 compiler][8]. This is how I tasted my first actual programming language, while avoiding further exposure to BASIC. Turbo Pascal was beautiful: expressive, concise, safe, and structured. There's an anecdotal theory about why programmers from Central and Eastern Europe have such highly valued skills. In western countries, C and C++ were the order of the day, full of fun quirks and idiosyncrasies. Over here though, we started with Pascal. It was a programming language of choice in schools and universities. The differences between these two are substantial, and the theory is that they wired our young minds in a substantially different way. + +![Turbo Pascal][9] + +Image [Public Domain][10] + +Pascal was much more disciplined than C, and it was as "close to the metal" as it gets. Pascal had pointers, direct memory operations, and even `asm ... end` block for assembly code injection. Yet pointers weren't thrown in everywhere like they are in C, and buffer overflow attacks through null-terminated strings were non-existent. Strings in Pascal is just an array of characters, and only the first entry contains the explicit string length. Simple! It also had a proper module system, precompiled libraries, strict type control, and a blazing fast compiler on top of that. + +Turbo Pascal had an enormous impact on the way I think while programming. Eventually it implemented object-oriented programming, and smoothly prepared me for complex software architectures and programming on Windows with Borland Delphi. I touched C and C++ only when I had no other choice. + +Decades later, I've realized that all my career, I have unconsciously followed in the footsteps of [Anders Hejlsberg][11]. He and his team were creators of a highly successful line of Turbo compilers at Borland. Then they created Delphi, which was a relief for Windows programmers struggling with Visual Basic, WFC, MFC, Charles Petzold books, and Hungarian notation. After Borland, he continued at Microsoft and created [.NET][12], which I happily jumped into. Finally, he created TypeScript, which became the backbone of modern enterprise web development. + +Nowadays, I'm busy architecting and developing large web applications for enterprises. JavaScript and TypeScript is the order of the day, with back-ends running on NodeJS, .NET, or Python and writing little utilities and scripts with Python and Bash, and struggling with complexities of cloud computing and [YAML][13]. After all these years, I still enjoy the thrill. I can't imagine a more satisfying job that keeps challenging me and never gets dull and boring. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/8/my-first-programming-language + +作者:[Tomasz Waraksa][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/tomasz +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/retro_old_unix_computer.png?itok=SYAb2xoW (Old UNIX computer) +[2]: https://opensource.com/articles/21/3/raspberry-pi-projects +[3]: https://opensource.com/sites/default/files/svi738.jpg (MSX Specravideo 738) +[4]: http://msx.hansotten.com/special-msx-hardware/svi-738-xpress/ +[5]: https://opensource.com/article/21/5/open-source-star-wars +[6]: https://opensource.com/sites/default/files/basic.jpg (Code) +[7]: https://opensource.com/article/17/10/python-101 +[8]: https://en.wikipedia.org/wiki/Turbo_Pascal +[9]: https://opensource.com/sites/default/files/uploads/turbo-pascal.png (Turbo Pascal) +[10]: https://commons.wikimedia.org/wiki/File:Turbopascal_6.png +[11]: https://en.wikipedia.org/wiki/Anders_Hejlsberg +[12]: https://opensource.com/article/19/9/getting-started-net +[13]: https://www.redhat.com/sysadmin/yaml-beginners diff --git a/sources/talk/20210816 What was your first programming language.md b/sources/talk/20210816 What was your first programming language.md new file mode 100644 index 0000000000..7e13d19ddb --- /dev/null +++ b/sources/talk/20210816 What was your first programming language.md @@ -0,0 +1,300 @@ +[#]: subject: "What was your first programming language?" +[#]: via: "https://opensource.com/article/21/8/first-programming-language" +[#]: author: "Jen Wike Huger https://opensource.com/users/jen-wike" +[#]: collector: "lujun9972" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +What was your first programming language? +====== +These 24 open source technologists share their programming origin +stories. +![Computer laptop in space][1] + +We asked our contributors _What was your first programming language?_ but the question goes much deeper than that. There are stories to tell about who suggested it or what prompted you to learn it. If you were paid to do so, and what happened next. Then there's a lot it says about your age and what was going on in the world. + +Let's hear a little bit about these 24 technologists' stories. + +* * * + +*What was your first programming language? *BASIC + +*Were you paid to learn it? *Nope. + +*Did you choose it? *Not really. + +*Why? *It was Christmas of 1979, my parents (a school maintenance worker and a public health nurse) scrimped and saved the staggering US$1000 to buy a Tandy/Radio Shack TRS-80. It came with a ring binder that covered the complete BASIC programming language, and my Dad figured getting me to learn to write computer software would be a good way to keep me out of trouble. + +*What happened next? *Mom and Dad would buy me and my younger brother books or subscriptions to popular magazines about "home computing," which included printed source code for a variety of games. We spent hours every weekend painstakingly typing and then debugging line by line with the accompanying checksums to find our typos. When the games got boring, we'd modify them... trivially at first just tweaking strings here and there to turn, say, a roman battle strategy game into a space battle strategy game; but later increasing the complexity of our changes and eventually starting to write terrible games of our own. Soon after that, we were sharing disks by mail and then over BBSes at 110bps. + +Four decades later, I can collaborate on creations with the entire world and home connectivity has increased 7+ orders of magnitude, but part of me still misses those Saturday afternoons hunched over the keyboard, getting thoroughly trounced by my little brother at something truly terrible we created together. —[Jeremy Stanley][2] + +* * * + +*What was your first programming language? *My first language was BASIC, which I learned in 7th grade. + +*Were you paid to learn it? *Not unless you count being allowed to play Wolfenstein 3D, Minecraft, and Sim City in the computer lab at lunch as a perk for being interested enough in computer science to learn BASIC for fun. + +*Did you choose it? *I don't think I was aware enough at the time to realize there might have been alternatives. This was what was available in the computer lab, and some older students knew enough about it to get me into it. I don't remember it even being part of the computer science class curriculum. + +*Why? *At the time, it was just for fun. I used it exclusively to create text-based "Choose Your Own Adventure"-style games. Something about creating something artistic and fun from code and having the computer run it appealed to me.  I'd used computers before, but this was the first time I made it do something for me. + +*What happened next? *Perhaps not-so-coincidentally, I've used "Choose Your Own Adventure"-style games to teach myself every one of the programming languages I've learned the rest of my life. + +This experience and the first exploration of computer games (both commercial and self-written) started me down a path toward getting involved in computers more deeply, always at school until my family bought our first computer when I was in 11th grade.  Three years later, I translated this exploration into my first computer job as an intern for a research company that eventually hired me for my first "real" job out of college—working in their IT Support group. + +I credit BASIC (and Sim City) with starting me down the path toward where I am now as an SRE, writing code and running clusters daily, some 30 years later. —[Chris Collins][3] + +* * * + +*What was your first programming language? *I played with BASIC, but my first formal introduction was PL/I—learned it in my first programming course in college. —[Heidi Ellis][4] + +* * * + +*What was your first programming language? *My first programming language was BASIC. This was in 1981. I learned it because I bought a home computer that booted into a BASIC editor, a TRS-80 Color Computer. It had a whopping 4K of RAM (not a typo) and could store programs on a cassette tape. I wanted to make the computer do things, so I learned how to instruct it using language it understood. Once you tap, for the first time, into that feeling of joy when your program runs successfully, the elation takes over, and you find yourself wanting to experience it again. Next thing you know, 40 years have passed. —[Matthew Helmke][5] + +* * * + +*What was your first programming language? *My first programming language was BASIC. It was part of a computer science class I took in my first semester of college in 1977, so I was not paid to learn it nor did I choose it. But I always thought it was a great first step since it taught me how to think like a computer (and I had a good teacher). It didn't lead to anything right away as I went to graduate school in Economics, but years later I was an IT Project Manager. So I never was a coder, but I managed a few. —[Kevin O'Brien][6] + +* * * + +*What was your first programming language? *BASIC + +*Were you paid to learn it? *No. + +*Did you choose it? *It was built into the Apple ][ computer my Mom brought home for the summer, and my choices were limited. + +*Why? *It was either BASIC or 6502 Assembly, and BASIC seemed more attainable to sixth-grade-me. + +*What happened next? *I went to the public library and found all the back issues of "Byte" magazine with source listings for Apple ][ programs. I spent a lot of time typing in programs that I could barely follow and learning the joys of debugging someone else's code (ok, I'm pretty sure I introduced most of the bugs). I was hooked. Several years later, senior-in-high-school me was very surprised and excited to learn that you could major in something called "computer science." The rest was history. —[Erik O'Shaughnessy][7] + +* * * + +*What was your first programming language? *Fortran IV—tells you something about how long ago this was. + +*Were you paid to learn it? *No, this was part of my first computer science course in college, so I guess that means I paid to learn it. This was on a mainframe, so after writing your program on paper, you bought your blank IBM punchcards, sat down at a keypunch to punch them out, then had to submit your collection of punchcards as a "job." Then the next day, you got your cards back with a printout from a line printer. If your program didn't run, you got nothing, or you might get pages and pages if you managed to create some sort of never-ending loop. + +*What happened next? *At the tail end of college, they began using _Watfor_, a Fortran implementation from the University of Waterloo in Canada. Its advantage was that you could use it on a terminal, saving your programs on the central system, rather than the punchcards we loved so well. So you could run your program yourself and create your never-ending loops right away. Whoopee! + +After Fortran, the next language that caught my eye was BASIC, which was a lot like Fortran, but handled strings much better. Fortran was awful with strings. This was mostly on an Amiga. + +After switching to Linux, my next language was Perl, which oddly enough seemed like a fairly easy transition from BASIC. After Perl, came Python, a language less stiff with syntax. —[Gregory Pittman][8] + +* * * + +*What was your first programming language? *Waterloo Fortran IV in 1974-5, my first computer science course—taken in the second year—back when I was sorta sure I wanted to major in computer science. We also learned a bit about IBM 360/370 assembler later in the year. Back in those days, the lower-year courses at UBC used keypunches, and there was a "student terminal" where you would cue up with your deck of cards and exchange a "blue ticket" for a run of your deck, then walk around behind the IBM line printer to pick up your output. If you were careless or distracted you might put your deck on top of the printer—even though there was a sign saying "don't put your card deck on top of the printer, in case it opens"—and of course if you did, the printer would that very moment run out of paper or have a jam and obligingly raise its lid, which caused your card deck to spill to the floor and become an unorganized mess. + +In my third year, still in computer science, I took a bunch of courses—the mainstream third-year course featuring PL/I, a one-semester 360/370 Assembler course, the two honors courses on computational theory, a numerical analysis course, "the twelve languages of MTS," and a bunch of math courses. + +In my fourth year, I was hired by the applied math institute as a research assistant. At that point, I was getting paid for writing Fortran programs for a small group of mathematicians mostly interested in solving differential equations. Also, by then, I realized that computer science wasn't for me, and I had switched to math. I did continue to take some computer science courses—optimization, more numerical analysis. Looking back, those were my first steps down the data science pathway. + +My first post-university job was programming, mostly in Fortran and in PL/I and SPSS, a statistics language. As well, I learned how to use MPSX, an IBM linear programming utility. —[Chris Hermansen][9] + +* * * + +*What was your first programming language? *In high school, a teacher who had zero experience with computers was asked to teach computer programming as part of an experiment: My school had not tried this before. Xerox Corp. provided the school with a Model-33 teletype and a 110-baud acoustic coupled modem, which gave us access to their XDS Sigma 7 mainframe running the CP-5 time-sharing system. BASIC was the order of the day. + +_Were you paid to learn it?_ Do grades count? + +*What happened next? *A few of us started "poking a stick" at the machine to see what would happen if we didn't type "BASIC" at the prompt... which lead us to discover that there were _other_ languages! And other stuff too! If I recall, there were (at least) three separate Fortran compilers—Fortran, FLAG (Fortran Load And Go—which compiled lightning-quick, or what passed for "quick" in the day), and at the opposite end EFFORT—or possibly EFORT, but pronounced "effort." S-L-O-W to compile, but it did what appeared to be, to our young eyes, amazing optimization of the code. Also, a brief foray with a "weird" keyboard with all sorts of symbols, and APL, where backspace was not used to erase anything but to overstrike operators to make other operators. —[Kevin Cole][10] + +* * * + +*What was your first programming language? *Atari PILOT and Atari BASIC. My family bought an Atari 1200XL when I was a kid, and while I started out just using it for games and some art programs, there were two cartridges that my Dad said were "for adults" and "I wouldn't like them because they're not for kids."  So obviously, I was incredibly curious. One day I decided to check them out. I was totally confused at first but then found the book that he had about them, and I typed in the sample code and thought it was really cool that I could make things happen. I never was able to write anything entirely on my own, but I took the sample code and just changed parts until I either got it to do something else or broke it and had to undo those changes. I've been meaning to try it out again and see how much I remember, but I just haven't had the time. —[JT Pennington][11] + +* * * + +*What was your first programming language? *ELAN. It was a superb language for the time. It is important to note it was tightly coupled with the OS EUMEL so we could do parallel computing. + +_Were you paid to learn it?_ It was an after-school activity. + +*Did you choose it? *No. + +*Why? *I wanted to learn piano, and my parents said I would get one if I take a typewriter course. Next door was the after-school computer club. I thought that was more interesting. Unfortunately, I still don't know how to play the piano as computers kept me busy till today. + +*What happened next? *When I started at the university, they still had punch cards and Fortran. I was lucky as the high school teacher allowed me to use the parallel computer at the high school for programming. In between, I also tried BASIC, but that was just inferior and boring. I then looked at Pascal, which was not any better than ELAN. After C, Modula-2, and Ada, I finally found Occam and did lots of stuff in Occam on transputers. That was exciting as we could do more parallel computing. Having access to 64 of them was pretty cool. Also, plugging in various network configurations was exciting. This was decades ago. I see a difference between yesteryear's high school students and today's. While we initially had few resources (I could not afford a computer till I was in my fourth year at university), today's computers are commodities. Furthermore, the combination of computers and robotics such as FLL (FIRST Lego League) makes it possible to lower the entry barrier. However, today also students are distracted by accessibility to video games and access to very cool graphics. Ready-made products  (videogames, cell phones, tablets) may limit the available "time" today's students have to learn computer science in their free time. I have to admit that if I would have been offered today's video games when I grew up, I may have had a very different outlook on computer science and may not have been labeled by my high schoolmates "nerd,"  but the video gamer. + +Unfortunately, I have no time to do video games as my RTX3090 plays AI algorithms … The toy I really want for me is an A100 and a DGX which I use now remotely. I would argue that due to Google colab and accessibility via Jupyter, access to AI can be lowered to the high school level. However, this all depends on the high school teacher that introduces you to it. If you just have one that teaches you block-programming instead of, for example, Python on the lego robots or one that uses scratch instead of Google colab, then we do not leverage the potential that these students have in their early years and can leverage this superb infrastructure. —[Gregor von Laszewski][12] + +* * * + +*What was your first programming language? *I got into Logo on an Apple, a computer language developed at MIT by Seymour Papert and others in 1967. It was a language designed for education. It's a subset of Lisp. + +I learned it as part of a graduate education program I was involved with at the time. As part of that program, I taught geometry to a fifth-grade student using the Logo programming language. While teaching this student the computer language and the curriculum, I discovered that my own trouble and learned helplessness with mathematics came from an inability to visualize the material. After completing the graduate course, I used the Logo language to teach other students geometry and mathematics using the same curriculum and programming language. The students and I learned math and developed some beautiful graphics in the process, and we actually programmed a 'turtle' robot that drew our images on large pieces of paper on the classroom floor. My experience with programming led me to look for other ways to bring mathematics to life for students, which led me to Python and the "turtle' module. Lately, I've been teaching students how to write Python programs that feature an 'on-screen' turtle robot that can create beautiful graphics while at the same time introducing those students to the Python language and logical thinking skills. —[Donald Watkins][13] + +* * * + +*What was your first programming language? *ZX81 BASIC.  + +I was still at school, probably aged 10 or 11, when a friend got a ZX81—so I taught myself BASIC and wrote a couple of simple programs I could try out on his machine. Christmas 1982, I got my own ZX81 and pretty soon outgrew the hardware and moved onto a ZX Spectrum in late 1993, by which time I was also programming a little in Z80 assembly. + +A couple of years later, I also picked up an early CASIO handheld that ran BASIC. It was one of the PB series, possibly the PB-200, but I can't remember the exact model version. I managed to convince my teachers to let me use it for my O-Level math exam at the age of 16 in the UK. I did take a look at some other languages but didn't really learn any until I started on Ada at university. —[Steven Ellis][14] + +* * * + +*What was your first programming language? *My first ever programming language was BASIC in the early eighties. + +One of my relatives bought a C64 for their kids to get started with learning computers. They only used it for gaming, and I was also invited. But they also had a book about BASIC, and I was curious and gave it a try. I wrote some shortcode, I did not even know how to save it, but it was exciting to see that the computer does what I say to it. This means that I was not paid to learn it, and it was not my choice. It was the language available to me. Obviously, when I got my first computer a few years later, an XT compatible box, I first wrote some code in GW-BASIC, the dialect of BASIC available with DOS. + +*What happened next? *The first time I really choose a programming language was Pascal. I asked around, checked some books, and it seemed to be a good compromise between features and difficulty. First, it was Turbo Pascal, and I coded all kinds of simple games and graphics in it. I loved Pascal, so in my university years, I even used it (well, FreePascal and Lazarus) for measurement automation and modeling how pollution spreads in groundwater. —[Peter Czanik][15] + +* * * + +*What was your first programming language? *The language of the Casio fx-7200G ([a variant of][16]). I don't think it has its own name. + +*Were you paid to learn it? *No. + +*Did you choose it? *No. + +*Why? *I got this programmable calculator (the box said "computer"...) for my 13th birthday. + +*What happened next? *A year later, first high-school year, I studied their Pascal, even though we didn't have books for it—the main Pascal book our teacher recommended was university-level, considered by him to be a bit too hard for us—and the main text we used for theory and exercises was actually using BASIC, so I also learned some BASIC (unintentionally, at least from the teacher's POV). + +I considered myself a latecomer—some kids in my class had computers with BASIC (commodore 64, Spectrum Sinclair, Amstrad) at home, and I already knew a bit of BASIC before high school, and along the first years, there was a semi-tension between us—me, and those who knew BASIC and didn't appreciate the advantages of Pascal. + +Later on, I went to university (math and computer science), where students could use DOS PCs or a few Macintoshes, or terminals (text ones, X Terminals if you were lucky and one was available), mainly to connect to shared SunOS 4 machines. In my second year (in 1993), someone told me about Linux, which I could run at home. I already bought myself a newer PC (an AMD 386SX-compatible. Only after I "decommissioned" it, ~ 8 years later, I realized it was AMD and not an Intel 386, which is what I thought I was buying) before knowing about Linux, learning my 8088 PC isn't suitable for running more modern OSes, and so I tried Linux, which it took me several months to get installed with only 2MB RAM—soon after that, I upgraded to 4MB and then seldom rebooted to DOS (which I kept as a dual-boot option for several years). I still remember my astonishment and excitement at being able to run a UNIX-like OS, even with X windows (after upgrading to 4MB RAM), all at home. + +In terms of languages, in the university, we studied/used Pascal (first intro course), C (intro to systems programming course), and then some course-specific ones—Eiffel (in the OOP course), MatLab (for a workshop), etc. + +My first real job was in a project written on Unix (we used mainly DECstation machines with Ultrix), mainly in Lisp (Lucid Common Lisp) and C, where I studied Lisp, and from which I still have very good memories, even though I never used it later. I managed to make the project semi-work on a PC with Linux, as a personal side project, using a copy of LCL for SCO Unix, which I managed to make work on Linux with the `ibcs2` module and recompiling GNU `libc` with a cross-compiler toolchain (`GCC/as/ld` on Linux to generate COFF binaries for SCO). I was quite proud to demonstrate the application to my manager—something which normally needed a workstation costing ~ $30K, running on a $5K PC. But this never went to production. —[Yedidyah Bar David][17] + +* * * + +*What was your first programming language? *TI-BASIC + +*Were you paid to learn it? *No, but then, I was 10. + +*Did you choose it? *No. + +*Why? *It was the only language available on the TI-99/4A! Well, there was the "Extended Basic," too, but that was just an extended instruction set. You could actually write decent games in 16Kb of RAM. + +*What happened next? *The next step was to type in programs that were shipped in print magazines and record them on audio cassette tapes. But with my brother, we took that one step further—we went live on radio to broadcast the resulting sound for others to record! With a clear recording and enough error correction, you could distribute and download programs wirelessly back in 1985. —[Thierry Carrez][18] + +* * * + +*What was your first programming language? *GW-BASIC + +*Did you choose it? *No. + +_Why?_ It was standard education for beginners. + +*What happened next? *I started in a company for computer hardware specialist. —[Hüseyin GÜÇ][19] + +* * * + +*What was your first programming language? *BASIC, on the VIC-20. + +*Were you paid to learn it? *Nope. + +*Did you choose it? *Only insofar as I chose the computer. + +*Why? *I figured that the VIC would be at least mostly compatible with the PET I had seen in school. Also, it had a decent keyboard. + +*What happened next? *Those were the days of programming because there was no other way to do anything with it—learned a lot. —[Bob Murphy][20] + +* * * + +*What was your first programming language? *It was the year 2004-05 if I recall. I was in school, maybe a fifth-grader, I was introduced to BASIC. Before that, I had learned a little bit of something called "Window Logo." + +*Were you paid to learn it? *My parents paid for my school. + +*Did you choose it? *Not at all. + +*Why? *Part of the curriculum my school decided on. + +*What happened next? *It definitely piqued my interest in programming, and I went on to learn C/C++ through extra-curricular courses outside of my school. My parents encouraged it and managed to pay extra fees somehow. I often ended up as the only "kid" in the entire computer institute. I was the only one learning a programming language while others mostly learned MS Office or PhotoShop etc. LOL. Well, the rest is history. —[Kedar Vijay Kulkarni][21] + +* * * + +*What was your first programming language? *Fortran, because I'm old. + +*Were you paid to learn it? *No, I paid to learn it by taking a computer science class. + +*Did you choose it? *No, it was the only choice. I was lucky that we had terminals to work on instead of the punchcards that my poor husband used when he learned how to program in Fortran. + +*Why? *I was a humanities major (English and Anthropology double major), and I was getting close to graduation and actually having to find a JOB. I figured a computer class might make that possible. As it has turned out, that particular programming class was one of the more valuable ones that I took in terms of marketable skills. It provided a good foundation for learning Python, understanding Git, and editing and writing documentation for Red Hat. + +*What happened next? *I went home and taught myself BASIC on the TI-99 that my parents had bought (I'm not sure why they bought it, though—maybe for my little brother?). That early foundation in Fortran (of all things) made it easier to use the early PCs before Windows existed because I could figure out DOS. A humble beginning for sure. —[Ingrid Towey][22] + +* * * + +*What was your first programming language? *In 2001, I learned Java SE 1.2 by reading the book _Goto Java_ from Addison-Wesley. + +*Were you paid to learn it? *No, I was still in school. + +*Did you choose it? *Yes. + +*Why? *I wanted to create interactive websites with Java Applets. + +*What happened next? *I went to college and got in touch with FOSS and learned ANSI C. —[Joël Krähemann][23] + +* * * + +*What was your first programming language? * + +I was going to write an article for this, but I already wrote that one: [You don't need a computer science degree to work with open source software (6 Aug 2020)][24]. + +Highlights from that article: + +Our parents bought an Apple II+ clone called the Franklin ACE 1000. My brother and I taught ourselves how to program in AppleSoft BASIC. Our parents bought us books, and we devoured them. I learned every corner of BASIC by reading about something in the book, then writing a practice program. My favorite pastime was writing simulations and games. + +I stayed with BASIC for a long time. But I began to learn other programming languages when I entered university. I was a physics student, and as part of our numerical analysis prerequisite, we had to learn Fortran. Having already learned BASIC, I thought Fortran was pretty easy to pick up. Fortran and BASIC were very similar, although Fortran was more limited in my experience. + +My brother was a computer science major at a different university, and he introduced me to the C programming language. I immediately loved working in C! It was a straightforward programming language that gave me a ton of flexibility for writing useful programs. But I didn't have room in my degree program to take a class that didn't apply to my physics major. So, instead, I taught myself C by reading books and combing through the library reference guide. Each time I wanted to learn a new topic, I looked it up in the reference guide and wrote a practice program to exercise my new knowledge. + +Over time, I leveraged what I'd learned to pick up other programming languages. I wrote a ton of Unix Korn shell scripts, Linux Bash scripts, and AWK scripts. I wrote small utilities in Perl, and later wrote Perl CGI and PHP pages for websites. I learned enough LISP to tweak my copy of GNU Emacs, and enough Scheme to work on a project that used GNU Guile. —[Jim Hall][25] + +* * * + +*What was your first programming language? *My first programming language was BASIC, Atari BASIC to be exact. + +My family had an Atari 400 home computer in the early 1980s. I played games on it, but it also came with a cartridge for the BASIC language. It included a cassette recorder (Atari 1010). In those days, programs could be stored on standard audio cassette tapes. The Atari 400 didn't have internal storage, so I learned how to save my programs to cassette and later reload them. In addition to the usual "Hello World" programs, I wrote some that allowed for controlling sound and graphics using a joystick. I still remember the PEEK and POKE commands needed for setting and retrieving certain settings, such as a color or a sound setting. + +_Were you paid to learn it?_ No. + +_Did you choose it?_ Yes, it was the one language included with the Atari, so I decided to give it a try—and I did enjoy programming it. + +*What happened next? *After a while, I guess I lost interest in Atari and computer gaming altogether. It wasn't until the mid-nineties that I became interested in computers and programming again when I attended computer science classes to earn a minor in CS. Those courses taught me languages such as C and Assembly and many general computer and networking skills. I later learned Java as part of my Master's degree. I have only done a small amount of formal coding during my career, mostly a little Java in a ColdFusion environment in the mid-2000s. In terms of coding, shell scripting has been my mainstay, mostly BASH and Windows, but I have coded for specific purposes whenever needed. I've used Job Control Language (JCL) for automating file transfers between mainframe systems. I've also used Python to feed REST API query results back to an enterprise monitoring dashboard. I still think that early experience with BASIC was valuable because I gained a respect for software and programming. —[Alan Formy-Duval][26] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/8/first-programming-language + +作者:[Jen Wike Huger][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jen-wike +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_space_graphic_cosmic.png?itok=wu493YbB (Computer laptop in space) +[2]: https://opensource.com/users/fungi +[3]: https://opensource.com/users/clcollins +[4]: https://opensource.com/users/heidi-jc-ellis +[5]: https://opensource.com/users/matthew-helmke +[6]: https://opensource.com/users/ahuka +[7]: https://opensource.com/users/jnyjny +[8]: https://opensource.com/users/greg-p +[9]: https://opensource.com/users/clhermansen +[10]: https://opensource.com/users/kjcole +[11]: https://opensource.com/users/jtpennington +[12]: https://opensource.com/users/laszewski +[13]: https://opensource.com/users/don-watkins +[14]: https://opensource.com/users/steven-ellis +[15]: https://opensource.com/users/czanik +[16]: https://en.wikipedia.org/wiki/Casio_fx-7000G +[17]: https://opensource.com/users/didib +[18]: https://opensource.com/users/thierry-carrez +[19]: https://opensource.com/users/hguc +[20]: https://opensource.com/users/murph +[21]: https://opensource.com/users/kkulkarn +[22]: https://opensource.com/users/i-towey +[23]: https://opensource.com/users/joel2001k +[24]: https://opensource.com/article/20/8/learn-open-source +[25]: https://opensource.com/users/jim-hall +[26]: https://opensource.com/users/alanfdoss diff --git a/sources/tech/20180416 Cgo and Python.md b/sources/tech/20180416 Cgo and Python.md deleted file mode 100644 index e5688d43c8..0000000000 --- a/sources/tech/20180416 Cgo and Python.md +++ /dev/null @@ -1,351 +0,0 @@ -Cgo and Python -============================================================ - -![](https://datadog-prod.imgix.net/img/blog/engineering/cgo-and-python/cgo_python_hero.png?auto=format&w=1900&dpr=1) - - - -If you look at the [new Datadog Agent][8], you might notice most of the codebase is written in Go, although the checks we use to gather metrics are still written in Python. This is possible because the Datadog Agent, a regular Go binary, [embeds][9] a CPython interpreter that can be called whenever it needs to execute Python code. This process can be made transparent using an abstraction layer so that you can still write idiomatic Go code even when there’s Python running under the hood. - -[video](https://youtu.be/yrEi5ezq2-c) - -There are a number of reasons why you might want to embed Python in a Go application: - -* It is useful during a port; gradually moving portions of an existing Python project to the new language without losing any functionality during the process. - -* You can reuse existing Python software or libraries without re-implementing them in the new language. - -* You can dynamically extend your software by loading and executing regular Python scripts, even at runtime. - -The list could go on, but for the Datadog Agent the last point is crucial: we want you to be able to execute custom checks or change existing ones without forcing you to recompile the Agent, or in general, to compile anything. - -Embedding CPython is quite easy and well documented. The interpreter itself is written in C and a C API is provided to programmatically perform operations at a very low level, like creating objects, importing modules, and calling functions. - -In this article we’ll show some code examples, and we’ll focus on keeping the Go code idiomatic while interacting with Python at the same time, but before we proceed we need to address a small gap: the embedding API is C but our main application is Go, how can this possibly work? - -![](https://datadog-prod.imgix.net/img/blog/engineering/cgo-and-python/cgo_python_divider_1.png?auto=format&fit=max&w=847) - -### Introducing cgo - -There are [a number of good reasons][10] why you might not want to introduce cgo in your stack, but embedding CPython is one of those cases where you must. [Cgo][11] is not a language nor a compiler. It’s a [Foreign Function Interface][12] (FFI), a mechanism we can use in Go to invoke functions and services written in a different language, specifically C. - -When we say “cgo” we’re actually referring to a set of tools, libraries, functions, and types that are used by the go toolchain under the hood so we can keep doing `go build` to get our Go binaries. An absolutely minimal example of a program using cgo looks like this: - -``` -package main - -// #include -import "C" -import "fmt" - -func main() { - fmt.Println("Max float value of float is", C.FLT_MAX) -} - -``` - -The comment block right above the `import "C"` instruction is called a “preamble” and can contain actual C code, in this case an header inclusion. Once imported, the “C” pseudo-package lets us “jump” to the foreign code, accessing the `FLT_MAX` constant. You can build the example by invoking `go build`, the same as if it was plain Go. - -If you want to have a look at all the work cgo does under the hood, run `go build -x`. You’ll see the “cgo” tool will be invoked to generate some C and Go modules, then the C and Go compilers will be invoked to build the object modules and finally the linker will put everything together. - -You can read more about cgo on the [Go blog][13]. The article contains more examples and few useful links to get further into details. - -Now that we have an idea of what cgo can do for us, let’s see how we can run some Python code using this mechanism. -![](https://datadog-prod.imgix.net/img/blog/engineering/cgo-and-python/cgo_python_divider_2.png?auto=format&fit=max&w=847) - -### Embedding CPython: a primer - -A Go program that, technically speaking, embeds CPython is not as complicated as you might expect. In fact, at the bare minimum, all we have to do is initialize the interpreter before running any Python code and finalize it when we’re done. Please note that we’re going to use Python 2.x throughout all the examples but everything we’ll see can be applied to Python 3.x as well with very little adaptation. Let’s look at an example: - -``` -package main - -// #cgo pkg-config: python-2.7 -// #include -import "C" -import "fmt" - -func main() { - C.Py_Initialize() - fmt.Println(C.GoString(C.Py_GetVersion())) - C.Py_Finalize() -} - -``` - -The example above does exactly what the following Python code would do: - -``` -import sys -print(sys.version) - -``` - -You can see we put a `#cgo` directive in the preamble; those directives are passed to the toolchain to let you change the build workflow. In this case, we tell cgo to invoke “pkg-config” to gather the flags needed to build and link against a library called “python-2.7” and pass those flags to the C compiler. If you have the CPython development libraries installed in your system along with pkg-config, this would let you keep using a plain `go build` to compile the example above. - -Back to the code, we use `Py_Initialize()` and `Py_Finalize()` to set up and shut down the interpreter and the `Py_GetVersion` C function to retrieve the string containing the version information for the embedded interpreter. - -If you’re wondering, all the cgo bits we need to put together to invoke the C Python API are boilerplate code. This is why the Datadog Agent relies on [go-python][14] for all the embedding operations; the library provides a Go friendly thin wrapper around the C API and hides the cgo details. This is another basic embedding example, this time using go-python: - -``` -package main - -import ( - python "github.com/sbinet/go-python" -) - -func main() { - python.Initialize() - python.PyRun_SimpleString("print 'hello, world!'") - python.Finalize() -} - -``` - -This looks closer to regular Go code, no more cgo exposed and we can use Go strings back and forth while accessing the Python API. Embedding looks powerful and developer friendly. Time to put the interpreter to good use: let’s try to load a Python module from disk. - -We don’t need anything complex on the Python side, the ubiquitous “hello world” will serve the purpose: - -``` -# foo.py -def hello(): - """ - Print hello world for fun and profit. - """ - print "hello, world!" - -``` - -The Go code is slightly more complex but still readable: - -``` -// main.go -package main - -import "github.com/sbinet/go-python" - -func main() { - python.Initialize() - defer python.Finalize() - - fooModule := python.PyImport_ImportModule("foo") - if fooModule == nil { - panic("Error importing module") - } - - helloFunc := fooModule.GetAttrString("hello") - if helloFunc == nil { - panic("Error importing function") - } - - // The Python function takes no params but when using the C api - // we're required to send (empty) *args and **kwargs anyways. - helloFunc.Call(python.PyTuple_New(0), python.PyDict_New()) -} - -``` - -Once built, we need to set the `PYTHONPATH` environment variable to the current working dir so that the import statement will be able to find the `foo.py`module. From a shell, the command would look like this: - -``` -$ go build main.go && PYTHONPATH=. ./main -hello, world! - -``` -![](https://datadog-prod.imgix.net/img/blog/engineering/cgo-and-python/cgo_python_divider_3.png?auto=format&fit=max&w=847) - -### The dreadful Global Interpreter Lock - -Having to bring in cgo in order to embed Python is a tradeoff: builds will be slower, the Garbage Collector won’t help us managing memory used by the foreign system, and cross compilation will be non-trivial. Whether or not these are concerns for a specific project can be debated, but there’s something I deem not negotiable: the Go concurrency model. If we couldn’t run Python from a goroutine, using Go altogether would make very little sense. - -Before playing with concurrency, Python, and cgo, there’s something we need to know: it’s the Global Interpreter Lock, also known as the GIL. The GIL is a mechanism widely adopted in language interpreters (CPython is one of those) preventing more than one thread from running at the same time. This means that no Python program executed by CPython will be ever able to run in parallel within the same process. Concurrency is still possible and in the end, the lock is a good tradeoff between speed, security, and implementation simplicity. So why should this pose a problem when it comes to embedding? - -When a regular, non-embedded Python program starts, there’s no GIL involved to avoid useless overhead in locking operations; the GIL starts the first time some Python code requests to spawn a thread. For each thread, the interpreter creates a data structure to store information about the current state and locks the GIL. When the thread has finished, the state is restored and the GIL unlocked, ready to be used by other threads. - -When we run Python from a Go program, none of the above happens automatically. Without the GIL, multiple Python threads could be created by our Go program. This could cause a race condition leading to fatal runtime errors, and most likely a segmentation fault bringing down the whole Go application. - -The solution to this problem is to explicitly invoke the GIL whenever we run multithreaded code from Go; the code is not complex because the C API provides all the tools we need. To better expose the problem, we need to do something CPU bounded from Python. Let’s add these functions to our foo.py module from the previous example: - -``` -# foo.py -import sys - -def print_odds(limit=10): - """ - Print odds numbers < limit - """ - for i in range(limit): - if i%2: - sys.stderr.write("{}\n".format(i)) - -def print_even(limit=10): - """ - Print even numbers < limit - """ - for i in range(limit): - if i%2 == 0: - sys.stderr.write("{}\n".format(i)) - -``` - -We’ll try to print odd and even numbers concurrently from Go, using two different goroutines (thus involving threads): - -``` -package main - -import ( - "sync" - - "github.com/sbinet/go-python" -) - -func main() { - // The following will also create the GIL explicitly - // by calling PyEval_InitThreads(), without waiting - // for the interpreter to do that - python.Initialize() - - var wg sync.WaitGroup - wg.Add(2) - - fooModule := python.PyImport_ImportModule("foo") - odds := fooModule.GetAttrString("print_odds") - even := fooModule.GetAttrString("print_even") - - // Initialize() has locked the the GIL but at this point we don't need it - // anymore. We save the current state and release the lock - // so that goroutines can acquire it - state := python.PyEval_SaveThread() - - go func() { - _gstate := python.PyGILState_Ensure() - odds.Call(python.PyTuple_New(0), python.PyDict_New()) - python.PyGILState_Release(_gstate) - - wg.Done() - }() - - go func() { - _gstate := python.PyGILState_Ensure() - even.Call(python.PyTuple_New(0), python.PyDict_New()) - python.PyGILState_Release(_gstate) - - wg.Done() - }() - - wg.Wait() - - // At this point we know we won't need Python anymore in this - // program, we can restore the state and lock the GIL to perform - // the final operations before exiting. - python.PyEval_RestoreThread(state) - python.Finalize() -} - -``` - -While reading the example you might note a pattern, the pattern that will become our mantra to run embedded Python code: - -1. Save the state and lock the GIL. - -2. Do Python. - -3. Restore the state and unlock the GIL. - -The code should be straightforward but there’s a subtle detail we want to point out: notice that despite seconding the GIL mantra, in one case we operate the GIL by calling `PyEval_SaveThread()` and `PyEval_RestoreThread()`, in another (look inside the goroutines) we do the same with `PyGILState_Ensure()`and `PyGILState_Release()`. - -We said when multithreading is operated from Python, the interpreter takes care of creating the data structure needed to store the current state, but when the same happens from the C API, we’re responsible for that. - -When we initialize the interpreter with go-python, we’re operating in a Python context. So when `PyEval_InitThreads()` is called it initializes the data structure and locks the GIL. We can use `PyEval_SaveThread()` and `PyEval_RestoreThread()` to operate on already existing state. - -Inside the goroutines, we’re operating from a Go context and we need to explicitly create the state and remove it when done, which is what `PyGILState_Ensure()` and `PyGILState_Release()` do for us. -![](https://datadog-prod.imgix.net/img/blog/engineering/cgo-and-python/cgo_python_divider_4.png?auto=format&fit=max&w=847) - -### Unleash the Gopher - -At this point we know how to deal with multithreading Go code executing Python in an embedded interpreter but after the GIL, another challenge is right around the corner: the Go scheduler. - -When a goroutine starts, it’s scheduled for execution on one of the `GOMAXPROCS`threads available—[see here][15] for more details on the topic. If a goroutine happens to perform a syscall or call C code, the current thread hands over the other goroutines waiting to run in the thread queue to another thread so they can have better chances to run; the current goroutine is paused, waiting for the syscall or the C function to return. When this happens, the thread tries to resume the paused goroutine, but if this is not possible, it asks the Go runtime to find another thread to complete the goroutine and goes to sleep. The goroutine is finally scheduled to another thread and it finishes. - -With this in mind, let’s see what can happen to a goroutine running some Python code when a goroutine is moved to a new thread:: - -1. Our goroutine starts, performs a C call, and pauses. The GIL is locked. - -2. When the C call returns, the current thread tries to resume the goroutine, but it fails. - -3. The current thread tells the Go runtime to find another thread to resume our goroutine. - -4. The Go scheduler finds an available thread and the goroutine is resumed. - -5. The goroutine is almost done and tries to unlock the GIL before returning. - -6. The thread ID stored in the current state is from the original thread and is different from the ID of the current thread. - -7. Panic! - -Luckily for us, we can force the Go runtime to always keep our goroutine running on the same thread by calling the LockOSThread function from the runtime package from within a goroutine: - -``` -go func() { - runtime.LockOSThread() - - _gstate := python.PyGILState_Ensure() - odds.Call(python.PyTuple_New(0), python.PyDict_New()) - python.PyGILState_Release(_gstate) - wg.Done() -}() - -``` - -This will interfere with the scheduler and might introduce some overhead, but it’s a price that we’re willing to pay to avoid random panics. - -### Conclusions - -In order to embed Python, the Datadog Agent has to accept a few tradeoffs: - -* The overhead introduced by cgo. - -* The task of manually handling the GIL. - -* The limitation of binding goroutines to the same thread during execution. - -We’re happy to accept each of these for the convenience of running Python checks in Go. But by being conscious of the tradeoffs, we’re able to minimize their effect. Regarding other limitations introduced to support Python, we have few countermeasures to contain potential issues: - -* The build is automated and configurable so that devs have still something very similar to `go build`. - -* A lightweight version of the agent can be built stripping out Python support entirely simply using Go build tags. - -* Such a version only relies on core checks hardcoded in the agent itself (system and network checks mostly) but is cgo free and can be cross compiled. - -We’ll re-evaluate our options in the future and decide whether keeping around cgo is still worth it; we could even reconsider whether Python as a whole is still worth it, waiting for the [Go plugin package][16] to be mature enough to support our use case. But for now the embedded Python is working well and transitioning from the old Agent to the new one couldn’t be easier. - -Are you a polyglot who loves mixing different programming languages? Do you love learning about the inner workings of languages to make your code more performant? [Join us at Datadog!][17] - --------------------------------------------------------------------------------- - -via: https://www.datadoghq.com/blog/engineering/cgo-and-python/ - -作者:[ Massimiliano Pippi][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://github.com/masci -[1]:http://twitter.com/share?url=https://www.datadoghq.com/blog/engineering/cgo-and-python/ -[2]:http://www.reddit.com/submit?url=https://www.datadoghq.com/blog/engineering/cgo-and-python/ -[3]:https://www.linkedin.com/shareArticle?mini=true&url=https://www.datadoghq.com/blog/engineering/cgo-and-python/ -[4]:https://www.datadoghq.com/blog/category/under-the-hood -[5]:https://www.datadoghq.com/blog/tag/agent -[6]:https://www.datadoghq.com/blog/tag/golang -[7]:https://www.datadoghq.com/blog/tag/python -[8]:https://github.com/DataDog/datadog-agent/ -[9]:https://docs.python.org/2/extending/embedding.html -[10]:https://dave.cheney.net/2016/01/18/cgo-is-not-go -[11]:https://golang.org/cmd/cgo/ -[12]:https://en.wikipedia.org/wiki/Foreign_function_interface -[13]:https://blog.golang.org/c-go-cgo -[14]:https://github.com/sbinet/go-python -[15]:https://morsmachine.dk/go-scheduler -[16]:https://golang.org/pkg/plugin/ -[17]:https://www.datadoghq.com/careers/ diff --git a/sources/tech/20180619 Systemd Services- Monitoring Files and Directories.md b/sources/tech/20180619 Systemd Services- Monitoring Files and Directories.md index 601132a33f..81e9aa5958 100644 --- a/sources/tech/20180619 Systemd Services- Monitoring Files and Directories.md +++ b/sources/tech/20180619 Systemd Services- Monitoring Files and Directories.md @@ -137,7 +137,7 @@ via: https://www.linux.com/blog/learn/intro-to-linux/2018/6/systemd-services-mon 作者:[Paul Brown][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) +译者:[silentdawn-zz](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/tech/20190807 Trace code in Fedora with bpftrace.md b/sources/tech/20190807 Trace code in Fedora with bpftrace.md deleted file mode 100644 index bead04655e..0000000000 --- a/sources/tech/20190807 Trace code in Fedora with bpftrace.md +++ /dev/null @@ -1,210 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Trace code in Fedora with bpftrace) -[#]: via: (https://fedoramagazine.org/trace-code-in-fedora-with-bpftrace/) -[#]: author: (Augusto Caringi https://fedoramagazine.org/author/acaringi/) - -Trace code in Fedora with bpftrace -====== - -![][1] - -bpftrace is [a new eBPF-based tracing tool][2] that was first included in Fedora 28. It was developed by Brendan Gregg, Alastair Robertson and Matheus Marchini with the help of a loosely-knit team of hackers across the Net. A tracing tool lets you analyze what a system is doing behind the curtain. It tells you which functions in code are being called, with which arguments, how many times, and so on. - -This article covers some basics about bpftrace, and how it works. Read on for more information and some useful examples. - -### eBPF (extended Berkeley Packet Filter) - -[eBPF][3] is a tiny virtual machine, or a virtual CPU to be more precise, in the Linux Kernel. The eBPF can load and run small programs in a safe and controlled way in kernel space. This makes it safer to use, even in production systems. This virtual machine has its own instruction set architecture ([ISA][4]) resembling a subset of modern processor architectures. The ISA makes it easy to translate those programs to the real hardware. The kernel performs just-in-time translation to native code for main architectures to improve the performance. - -The eBPF virtual machine allows the kernel to be extended programmatically. Nowadays several kernel subsystems take advantage of this new powerful Linux Kernel capability. Examples include networking, seccomp, tracing, and more. The main idea is to attach eBPF programs into specific code points, and thereby extend the original kernel behavior. - -eBPF machine language is very powerful. But writing code directly in it is extremely painful, because it’s a low level language. This is where bpftrace comes in. It provides a high-level language to write eBPF tracing scripts. The tool then translates these scripts to eBPF with the help of clang/LLVM libraries, and then attached to the specified code points. - -## Installation and quick start - -To install bpftrace, run the following command in a terminal [using][5] _[sudo][5]_: - -``` -$ sudo dnf install bpftrace -``` - -Try it out with a “hello world” example: - -``` -$ sudo bpftrace -e 'BEGIN { printf("hello world\n"); }' -``` - -Note that you must run _bpftrace_ as _root_ due to the privileges required. Use the _-e_ option to specify a program, and to construct the so-called “one-liners.” This example only prints _hello world_, and then waits for you to press **Ctrl+C**. - -_BEGIN_ is a special probe name that fires only once at the beginning of execution. Every action inside the curly braces _{ }_ fires whenever the probe is hit — in this case, it’s just a _printf_. - -Let’s jump now to a more useful example: - -``` -$ sudo bpftrace -e 't:syscalls:sys_enter_execve { printf("%s called %s\n", comm, str(args->filename)); }' -``` - -This example prints the parent process name _(comm)_ and the name of every new process being created in the system. _t:syscalls:sys_enter_execve_ is a kernel tracepoint. It’s a shorthand for _tracepoint:syscalls:sys_enter_execve_, but both forms can be used. The next section shows you how to list all available tracepoints. - -_comm_ is a bpftrace builtin that represents the process name. _filename_ is a field of the _t:syscalls:sys_enter_execve_ tracepoint. You can access these fields through the _args_ builtin. - -All available fields of the tracepoint can be listed with this command: - -``` -bpftrace -lv "t:syscalls:sys_enter_execve" -``` - -## Example usage - -### Listing probes - -A central concept for _bpftrace_ are **probe points**. Probe points are instrumentation points in code (kernel or userspace) where eBPF programs can be attached. They fit into the following categories: - - * _kprobe_ – kernel function start - * _kretprobe_ – kernel function return - * _uprobe_ – user-level function start - * _uretprobe_ – user-level function return - * _tracepoint_ – kernel static tracepoints - * _usdt_ – user-level static tracepoints - * _profile_ – timed sampling - * _interval_ – timed output - * _software_ – kernel software events - * _hardware_ – processor-level events - - - -All available _kprobe/kretprobe_, _tracepoints_, _software_ and _hardware_ probes can be listed with this command: - -``` -$ sudo bpftrace -l -``` - -The _uprobe/uretprobe_ and _usdt_ probes are userspace probes specific to a given executable. To use them, use the special syntax shown later in this article. - -The _profile_ and _interval_ probes fire at fixed time intervals. Fixed time intervals are not covered in this article. - -### Counting system calls - -**Maps** are special BPF data types that store counts, statistics, and histograms. You can use maps to summarize how many times each syscall is being called: - -``` -$ sudo bpftrace -e 't:syscalls:sys_enter_* { @[probe] = count(); }' -``` - -Some probe types allow wildcards to match multiple probes. You can also specify multiple attach points for an action block using a comma separated list. In this example, the action block attaches to all tracepoints whose name starts with _t:syscalls:sys_enter__, which means all available syscalls. - -The bpftrace builtin function _count()_ counts the number of times this function is called. _@[]_ represents a map (an associative array). The key of this map is _probe_, which is another bpftrace builtin that represents the full probe name. - -Here, the same action block is attached to every syscall. Then, each time a syscall is called the map will be updated, and the entry is incremented in the map relative to this same syscall. When the program terminates, it automatically prints out all declared maps. - -This example counts the syscalls called globally, it’s also possible to filter for a specific process by _PID_ using the bpftrace filter syntax: - -``` -$ sudo bpftrace -e 't:syscalls:sys_enter_* / pid == 1234 / { @[probe] = count(); }' -``` - -### Write bytes by process - -Using these concepts, let’s analyze how many bytes each process is writing: - -``` -$ sudo bpftrace -e 't:syscalls:sys_exit_write /args->ret > 0/ { @[comm] = sum(args->ret); }' -``` - -_bpftrace_ attaches the action block to the write syscall return probe (_t:syscalls:sys_exit_write_). Then, it uses a filter to discard the negative values, which are error codes _(/args->ret > 0/)_. - -The map key _comm_ represents the process name that called the syscall. The _sum()_ builtin function accumulates the number of bytes written for each map entry or process. _args_ is a bpftrace builtin to access tracepoint’s arguments and return values. Finally, if successful, the _write_ syscall returns the number of written bytes. _args->ret_ provides access to the bytes. - -### Read size distribution by process (histogram): - -_bpftrace_ supports the creation of histograms. Let’s analyze one example that creates a histogram of the _read_ size distribution by process: - -``` -$ sudo bpftrace -e 't:syscalls:sys_exit_read { @[comm] = hist(args->ret); }' -``` - -Histograms are BPF maps, so they must always be attributed to a map (_@_). In this example, the map key is _comm_. - -The example makes _bpftrace_ generate one histogram for every process that calls the _read_ syscall. To generate just one global histogram, attribute the _hist()_ function just to _‘@’_ (without any key). - -bpftrace automatically prints out declared histograms when the program terminates. The value used as base for the histogram creation is the number of read bytes, found through _args->ret_. - -### Tracing userspace programs - -You can also trace userspace programs with _uprobes/uretprobes_ and _USDT_ (User-level Statically Defined Tracing). The next example uses a _uretprobe_, which probes to the end of a user-level function. It gets the command lines issued in every _bash_ running in the system: - -``` -$ sudo bpftrace -e 'uretprobe:/bin/bash:readline { printf("readline: \"%s\"\n", str(retval)); }' -``` - -To list all available _uprobes/uretprobes_ of the _bash_ executable, run this command: - -``` -$ sudo bpftrace -l "uprobe:/bin/bash" -``` - -_uprobe_ instruments the beginning of a user-level function’s execution, and _uretprobe_ instruments the end (its return). _readline()_ is a function of _/bin/bash_, and it returns the typed command line. _retval_ is the return value for the instrumented function, and can only be accessed on _uretprobe_. - -When using _uprobes_, you can access arguments with _arg0..argN_. A _str()_ call is necessary to turn the _char *_ pointer to a _string_. - -## Shipped Scripts - -There are many useful scripts shipped with bpftrace package. You can find them in the _/usr/share/bpftrace/tools/_ directory. - -Among them, you can find: - - * _killsnoop.bt_ – Trace signals issued by the kill() syscall. - * _tcpconnect.bt_ – Trace all TCP network connections. - * _pidpersec.bt_ – Count new procesess (via fork) per second. - * _opensnoop.bt_ – Trace open() syscalls. - * _vfsstat.bt_ – Count some VFS calls, with per-second summaries. - - - -You can directly use the scripts. For example: - -``` -$ sudo /usr/share/bpftrace/tools/killsnoop.bt -``` - -You can also study these scripts as you create new tools. - -## Links - - * bpftrace reference guide – - * bpftrace (DTrace 2.0) for Linux 2018 – - * BPF: the universal in-kernel virtual machine – - * Linux Extended BPF (eBPF) Tracing Tools – - * Dive into BPF: a list of reading material – [https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf][6] - - - -* * * - -_Photo by _[_Roman Romashov_][7]_ on _[_Unsplash_][8]_._ - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/trace-code-in-fedora-with-bpftrace/ - -作者:[Augusto Caringi][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/acaringi/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2019/08/bpftrace-816x345.jpg -[2]: https://github.com/iovisor/bpftrace -[3]: https://lwn.net/Articles/740157/ -[4]: https://github.com/iovisor/bpf-docs/blob/master/eBPF.md -[5]: https://fedoramagazine.org/howto-use-sudo/ -[6]: https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/ -[7]: https://unsplash.com/@wehavemegapixels?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText -[8]: https://unsplash.com/search/photos/trace?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/sources/tech/20200107 5 ways to improve your Bash scripts.md b/sources/tech/20200107 5 ways to improve your Bash scripts.md index a2fc7d9175..ae4dd4fcf7 100644 --- a/sources/tech/20200107 5 ways to improve your Bash scripts.md +++ b/sources/tech/20200107 5 ways to improve your Bash scripts.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: (iamcopper) +[#]: translator: ( ) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20200121 13 of the best React JavaScript frameworks.md b/sources/tech/20200121 13 of the best React JavaScript frameworks.md index e82ef14a8a..83b00bdd35 100644 --- a/sources/tech/20200121 13 of the best React JavaScript frameworks.md +++ b/sources/tech/20200121 13 of the best React JavaScript frameworks.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (zpl1025) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20200204 Managing your attached hardware on Linux with systemd-udevd.md b/sources/tech/20200204 Managing your attached hardware on Linux with systemd-udevd.md deleted file mode 100644 index e55f76de73..0000000000 --- a/sources/tech/20200204 Managing your attached hardware on Linux with systemd-udevd.md +++ /dev/null @@ -1,157 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Managing your attached hardware on Linux with systemd-udevd) -[#]: via: (https://opensource.com/article/20/2/linux-systemd-udevd) -[#]: author: (David Clinton https://opensource.com/users/dbclinton) - -Managing your attached hardware on Linux with systemd-udevd -====== -Manipulate how your Linux system handles physical devices with udev. -![collection of hardware on blue backround][1] - -Linux does a great job automatically recognizing, loading, and exposing attached hardware devices from countless vendors. In fact, it was this feature that, many years ago, convinced me to insist that my employer convert its entire infrastructure to Linux. The pain point was the way a certain company in Redmond couldn't load drivers for the integrated network card on our Compaq desktops while Linux did it effortlessly. - -In the years since then, Linux's library of recognized devices has grown enormously along with the sophistication of the process. And the star of that show is [udev][2]. Udev's job is to listen for events from the Linux kernel involving changes to the state of a device. It could be a new USB device that's plugged in or pulled out, or it might be a wireless mouse going offline as it's drowned in spilled coffee. - -Udev's job is to handle all changes of state by, for instance, assigning the names or permissions through which devices are accessed. A record of those changes can be accessed through [dmesg][3]. Since dmesg typically spits out thousands of entries, it's smart to filter the results. The example below shows how Linux identifies my WiFi interface. It shows the chipset my wireless device uses (**ath9k**), the original name it was assigned early in the process (**wlan0**), and the big, ugly permanent name it's currently using (**wlxec086b1ef0b3**): - - -``` -$ dmesg | grep wlan -[    5.396874] ath9k_htc 1-3:1.0 wlxec086b1ef0b3: renamed from wlan0 -``` - -In this article, I'll discuss why anyone might want to use a name like that. Along the way, I'll explore the anatomy of udev configuration files and then show how to make changes to udev settings, including how to edit the way the system names devices. This article is based on a module from my new course, [Linux System Optimization][4]. - -### Understanding the udev configuration system - -On systemd machines, udev operations are managed by the **systemd-udevd** daemon. You can check the status of the udev daemon the regular systemd way using **systemctl status systemd-udevd**. - -Technically, udev works by trying to match each system event it receives against sets of rules found in either the **/lib/udev/rules.d/** or **/etc/udev/rules.d/** directories. Rules files include match keys and assignment keys. The set of available match keys includes **action**, **name**, and **subsystem**. This means that if a device with a specified name that's part of a specified subsystem is detected, then it will be assigned a preset configuration. - -Then, the "assignment" key/value pairs are used to apply the desired configuration. You could, for instance, assign a new name to the device, associate it with a filesystem symlink, or restrict access to a particular owner or group. Here's an excerpt from such a rule from my workstation: - - -``` -$ cat /lib/udev/rules.d/73-usb-net-by-mac.rules -# Use MAC based names for network interfaces which are directly or indirectly -# on USB and have an universally administered (stable) MAC address (second bit -# is 0). Don't do this when ifnames is disabled via kernel command line or -# customizing/disabling 99-default.link (or previously 80-net-setup-link.rules). - -IMPORT{cmdline}="net.ifnames" -ENV{net.ifnames}=="0", GOTO="usb_net_by_mac_end" - -ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb", NAME=="", \ -    ATTR{address}=="?[014589cd]:*", \ -    TEST!="/etc/udev/rules.d/80-net-setup-link.rules", \ -    TEST!="/etc/systemd/network/99-default.link", \ -    IMPORT{builtin}="net_id", NAME="$env{ID_NET_NAME_MAC}" -``` - -The **add** action tells udev to fire up whenever a new device is plugged in that is part of the networking subsystem _and_ is a USB device. In addition, if I understand it correctly, the rule will apply only when the device has a MAC address consisting of characters within a certain range and, in addition, only if the **80-net-setup-link.rules** and **99-default.link** files do _not_ exist. - -Assuming all these conditions are met, the interface ID will be changed to match the device's MAC address. Remember the previous dmesg entry showing how my interface name was changed from **wlan0** to that nasty **wlxec086b1ef0b3** name? That was a result of this rule's execution. How do I know? Because **ec:08:6b:1e:f0:b3** is the device's MAC address (minus the colons): - - -``` -$ ifconfig -a -wlxec086b1ef0b3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500 -        inet 192.168.0.103  netmask 255.255.255.0  broadcast 192.168.0.255 -        inet6 fe80::7484:3120:c6a3:e3d1  prefixlen 64  scopeid 0x20<link> -        ether ec:08:6b:1e:f0:b3  txqueuelen 1000  (Ethernet) -        RX packets 682098  bytes 714517869 (714.5 MB) -        RX errors 0  dropped 0  overruns 0  frame 0 -        TX packets 472448  bytes 201773965 (201.7 MB) -        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 -``` - -This udev rule exists by default within Linux. I didn't have to write it myself. But why bother—especially seeing how difficult it is to work with such an interface designation? Take a second look at the comments included with the rule: - - -``` -# Use MAC based names for network interfaces which are directly or indirectly -# on USB and have an universally administered (stable) MAC address (second bit -# is 0). Don't do this when ifnames is disabled via kernel command line or -# customizing/disabling 99-default.link (or previously 80-net-setup-link.rules). -``` - -Note how this rule is designed specifically for USB-based network interfaces. Unlike PCI network interface cards (NICs), USB devices are likely to be removed and replaced from time to time. This means that there's no guarantee that their ID won't change. They could be **wlan0** one day and **wlan3** the next. To avoid confusing the applications, assign devices absolute IDs—like the one given to my USB interface. - -### Manipulating udev settings - -For my next trick, I'm going to grab the MAC address and current ID for the Ethernet network interface on a [VirtualBox][5] virtual machine and then use that information to create a new udev rule that will change the interface ID. Why? Well, perhaps I'm planning to work with the device from the command line, and having to type that long name can be annoying. Here's how that will work. - -Before I can change my ID, I'll need to disable [Netplan][6]'s current network configuration. That'll force Linux to pay attention to the new configuration. Here's my current network interface configuration file in the **/etc/netplan/** directory: - - -``` -$ less /etc/netplan/50-cloud-init.yaml -# This file is generated from information provided by -# the datasource.  Changes to it will not persist across an instance. -# To disable cloud-init's network configuration capabilities, write a file -# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: -# network: {config: disabled} -network: -    ethernets: -        enp0s3: -            addresses: [] -            dhcp4: true -    version: 2 -``` - -The **50-cloud-init.yaml** file contains a very basic interface definition. But it also includes some important information about disabling the configuration in the comments. To do so, I'll move to the **/etc/cloud/cloud.cfg.d** directory and create a new file called **99-disable-network-config.cfg** and add the **network: {config: disabled}** string. - -While I haven't tested this method on distros other than Ubuntu, it should work on any flavor of Linux with systemd (which is nearly all of them). Whatever you're using, you'll get a good look at writing udev config files and testing them. - -Next, I need to gather some system information. Running the **ip** command reports that my Ethernet interface is called **enp0s3** and its MAC address is **08:00:27:1d:28:10**: - - -``` -$ ip a -2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 -    link/ether 08:00:27:1d:28:10 brd ff:ff:ff:ff:ff:ff -    inet 192.168.0.115/24 brd 192.168.0.255 scope global dynamic enp0s3 -``` - -Now, I'll create a new file called **peristent-net.rules** in the **/etc/udev/rules.d** directory. I'm going to give the file a name that starts with a low number, 10: - - -``` -$ cat /etc/udev/rules.d/10-persistent-network.rules -ACTION=="add", SUBSYSTEM=="net",ATTR{address}=="08:00:27:1d:28:10",NAME="eth3" -``` - -The lower the number, the earlier Linux will execute the file, and I want this one to go early. The file contains code that will give the name **eth3** to a network device when it's added—as long as its address matches **08:00:27:1d:28:10**, which is my interface's MAC address.  - -Once I save the file and reboot the machine, my new interface name should be in play. I may need to log in directly to my virtual machine and use **dhclient** to manually get Linux to request an IP address on this newly named network. Opening SSH sessions might be impossible without doing that first: - - -``` -`$ sudo dhclient eth3` -``` - -Done. So you're now able to force udev to make your computer refer to a NIC the way you want. But more importantly, you've got the tools to figure out how to manage _any_ misbehaving device. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/2/linux-systemd-udevd - -作者:[David Clinton][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/dbclinton -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_BUS_Apple_520.png?itok=ZJu-hBV1 (collection of hardware on blue backround) -[2]: https://en.wikipedia.org/wiki/Udev -[3]: https://en.wikipedia.org/wiki/Dmesg -[4]: https://pluralsight.pxf.io/RqrJb -[5]: https://www.virtualbox.org/ -[6]: https://netplan.io/ diff --git a/sources/tech/20200206 How key Python projects are maintained.md b/sources/tech/20200206 How key Python projects are maintained.md deleted file mode 100644 index bb51029cd4..0000000000 --- a/sources/tech/20200206 How key Python projects are maintained.md +++ /dev/null @@ -1,91 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (HuengchI) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How key Python projects are maintained) -[#]: via: (https://opensource.com/article/20/2/python-maintained) -[#]: author: (Moshe Zadka https://opensource.com/users/moshez) - -How key Python projects are maintained -====== -A peek behind the scenes of the community that keeps open source Python -projects running smoothly. -![and old computer and a new computer, representing migration to new software or hardware][1] - -Jannis Leidel is part of the [Jazzband][2] community. Jazzband is a collaborative community that shares the responsibility of maintaining [Python][3]-based projects. - -Jazzband was born out of the stress of maintaining an open source project alone for a longer time. Jannis is a roadie, which means he does administrative tasks and makes sure the people in the band can play when they want. - -Jazzband is not his first open source volunteer work—he is a former [Django][4] core developer, [Django Software Foundation][5] board member, has written many Django apps and Python projects, has been a [pip][6] and [virtualenv][7] core developer and release manager, co-founded the [Python Packaging Authority][8], and been a [PyPI][9] admin. On the community front, he co-founded the German Django Association, served as [DjangoCon Europe][10] 2010 co-chairperson, has spoken at several conferences, and for the last year has served as a director and co-communication chair of the [Python Software Foundation][11]. - -### Moshe Zadka: How did you get started with programming? - -Jannis Leidel: I got started with programming as part of the regular German computer science lessons in high school, where I dabbled with Turbo Pascal and Prolog. I quickly got drawn into the world of web development and wrote small websites with PHP3, [Perl5][12], and [MySQL][13]. Later at university, I picked up programming again while working on media arts projects and found [Ruby][14], Perl, and Python to be particularly helpful. I eventually stuck with Python for its versatility and ease of use. I'm very happy to have been able to use Python and open web technologies (HTML/JS/CSS) in my career since then. - -### Zadka: How did you get started with open source? - -Leidel: As part of an art project at university, I needed a way to talk to various web services and interact with some electronics and found my prior PHP skills not up to the task. So I took a class about programming with Python and got interested in learning more about how frameworks work—compared to libraries—as they further enshrine best practices that I wanted to know about. In particular, the nascent Django Web Framework really appealed to me since it favored a pragmatic approach and provided lots of guidance for how to develop web applications. In 2007 I participated as a student in the Google Summer of Code for Django and later contributed more to Django and its ecosystem of reusable components—after a while as a Django core developer as well. While finishing my degree, I was able to use those skills to work as a freelancer and also spend time on many different parts of the Django community. Moving laterally to the broader Python community was only natural at that point. - -### Zadka: What do you for your day job? - -Leidel: I'm a Staff Software Engineer at Mozilla, working on data tools for the Firefox data pipeline. In practice, that means I'm working in the broader Firefox Engineering team on various internal and public-facing web-based projects that help Mozilla employees and community members to make sense of the telemetry data that the Firefox web browser sends. Part of my current focus is maintaining our data analysis and visualization platform, which is based on the open source project [Redash][15], and also contributing back to it. Other projects that I contribute to are our next-gen telemetry system [Glean][16] and a tool that allows you to do data science in the browser (including the Scientific Python stack) called [Iodide][17]. - -### Zadka: How did you get involved with Jazzband? - -Leidel: Back in 2015, I was frustrated with maintaining projects alone that a lot of people depended on and saw many of my community peers struggle with similar issues. I didn't know a good way to reach more people in the community who may also have an interest in long-term maintenance. On some occasions, I felt that the new "social coding" paradigm was rarely social and often rather isolating and sometimes even traumatic for old and new contributors. I believe the inequality in our community that I find intolerable nowadays was even more rampant at the time, which made providing a safe environment for contributors difficult—something which we now know is essential for stable project maintenance. I wondered if we were missing a more collaborative and inclusive approach to software development. - -The Jazzband project was launched in an attempt to lower the barriers to entry for maintenance and simplify some of the more boring aspects of it (e.g., best practices around [CI][18]). - -### Zadka: What is your favorite thing about Jazzband? - -Leidel: My favorite thing about Jazzband is the fact that we've secured the maintenance of many projects that a lot of people depend on while also making sure that new contributors of any level of experience can join. - -### Zadka: What is the job of a "roadie" in Jazzband? - -Leidel: A "roadie" is a go-to person when it comes to all things behind the scenes for Jazzband. That means, for example, dealing with onboarding new projects, maintaining the Jazzband website that handles user management and project releases, acting as a first responder to security or Code of Conduct incidents, and much more. The term "roadies" is borrowed from the music and event industry for support personnel that takes care of almost everything that needs to be done while traveling on tour, except for the actual artistic performance. In Jazzband, they are there to make sure the members can work on the projects. That also means that some tasks are partially or fully automated, where it makes sense, and that best practices are applied to the majority of the Jazzband projects like packaging setup, documentation hosting or continuous integration. - -### Zadka: What is the most challenging aspect of your job as a roadie for Jazzband? - -Leidel: At the moment, the most challenging aspect of my job as a roadie is to implement improvements for Jazzband that community members have proposed without risking the workflow that they have come to rely on. In other words, scaling the project on a conceptual level has become more difficult the bigger Jazzband gets. There is a certain irony in the fact that I'm the only roadie at the moment and handle some of the tasks alone while Jazzband tries to prevent that from happening for its projects. This is a big concern for the future of Jazzband. - -### Zadka: What would you say to someone who is wondering whether they should join Jazzband? - -Leidel: If you're interested in joining a group of people who believe that working collaboratively is better than working alone, or if you have struggled with maintenance burden on your own and don't know how to proceed, consider joining Jazzband. It simplifies onboarding new contributors, provides a framework for disputes, and automates releases to [PyPI][19]. There are many best practices that work well for reducing the risk of projects becoming unmaintained. - -### Zadka: Is there anything else you want to tell our readers? - -Leidel: I encourage everyone working on open source projects to consider the people on the other side of the screen. Be empathetic and remember that your own experience may not be the experience of your peers. Understand that you are members of a global and diverse community, which requires us always to take leaps of respect for the differences between us. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/2/python-maintained - -作者:[Moshe Zadka][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/moshez -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/migration_innovation_computer_software.png?itok=VCFLtd0q (and old computer and a new computer, representing migration to new software or hardware) -[2]: https://jazzband.co/ -[3]: https://opensource.com/resources/python -[4]: https://opensource.com/article/18/8/django-framework -[5]: https://www.djangoproject.com/foundation/ -[6]: https://opensource.com/article/19/11/python-pip-cheat-sheet -[7]: https://virtualenv.pypa.io/en/latest/ -[8]: https://www.pypa.io/en/latest/ -[9]: https://pypi.org/ -[10]: https://djangocon.eu/ -[11]: https://www.python.org/psf/ -[12]: http://opensource.com/article/18/1/why-i-love-perl-5 -[13]: https://opensource.com/life/16/10/all-things-open-interview-dave-stokes -[14]: http://opensource.com/business/16/4/save-development-time-and-effort-ruby -[15]: https://redash.io/ -[16]: https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/start/report-gecko-telemetry-in-glean.html -[17]: https://alpha.iodide.io/ -[18]: https://opensource.com/article/19/12/cicd-resources -[19]: https://opensource.com/downloads/7-essential-pypi-libraries diff --git a/sources/tech/20200210 Music composition with Python and Linux.md b/sources/tech/20200210 Music composition with Python and Linux.md deleted file mode 100644 index cb569520ec..0000000000 --- a/sources/tech/20200210 Music composition with Python and Linux.md +++ /dev/null @@ -1,109 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Music composition with Python and Linux) -[#]: via: (https://opensource.com/article/20/2/linux-open-source-music) -[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss) - -Music composition with Python and Linux -====== -A chat with Mr. MAGFest—Brendan Becker. -![Wires plugged into a network switch][1] - -I met Brendan Becker working in a computer store in 1999. We both enjoyed building custom computers and installing Linux on them. Brendan was always involved in several technology projects at once, ranging from game coding to music composition. Fast-forwarding a few years from the days of computer stores, he went on to write [pyDance][2], an open source implementation of multiple dancing games, and then became the CEO of music and gaming event [MAGFest][3]. Sometimes referred to as "Mr. MAGFest" because he was at the helm of the event, Brendan now uses the music pseudonym "[Inverse Phase][4]" as a composer of chiptunes—music predominantly made on 8-bit computers and game consoles. - -I thought it would be interesting to interview him and ask some specifics about how he has benefited from Linux and open source software throughout his career. - -![Inverse Phase performance photo][5] - -Copyright Nickeledge, CC BY-SA 2.0. - -### Alan Formy-Duval: How did you get started in computers and software? - -Brendan Becker: There's been a computer in my household almost as far back as I can remember. My dad has fervently followed technology; he brought home a Compaq Portable when they first hit the market, and when he wasn't doing work on it, I would have access to it. Since I began reading at age two, using a computer became second nature to me—just read what it said on the disk, follow the instructions, and I could play games! Some of the time I would be playing with learning and education software, and we had a few disks full of games that I could play other times. I remember a single disk with a handful of free clones of popular titles. Eventually, my dad showed me that we could call other computers (BBS'ing at age 5!), and I saw where some of the games came from. One of the games I liked to play was written in BASIC, and all bets were off when I realized that I could simply modify the game by just reading a few things and re-typing them to make my game easier. - -### Formy-Duval: This was the 1980s? - -Becker: The Compaq Portable dropped in 1983 to give you a frame of reference. My dad had one of the first of that model. - -### Formy-Duval: How did you get into Linux and open source software? - -Becker: I was heavy into MODs and demoscene stuff in the early 90s, and I noticed that Walnut Creek ([cdrom.com][6]; now defunct) ran shop on FreeBSD. I was super curious about Unix and other operating systems in general, but didn't have much firsthand exposure, and thought it might be time to finally try something. DOOM had just released, and someone told me I might even be able to get it to run. Between that and being able to run cool internet servers, I started going down the rabbit hole. Someone saw me reading about FreeBSD and suggested I check out Linux, this new OS that was written from the ground up for x86, unlike BSD, which (they said) had some issues with compatibility. So, I joined #linuxhelp on undernet IRC and asked how to get started with Linux, pointing out that I had done a modicum of research (asking "what's the difference between Red Hat and Slackware?") and probing mainly about what would be easiest to use. The only person talking in the channel said that he was 13 years old and he could figure out Slackware, so I should not have an issue. A math teacher in my school gave me a hard disk, I downloaded the "A" disk sets and a boot disk, wrote it out, installed it, and didn't spend much time looking back. - -### Formy-Duval: How'd you become known as Mr. MAGFest? - -Becker: Well, this one is pretty easy. I became the acting head of MAGFest almost immediately after the first event. The former chairpeople were all going their separate ways, and I demanded the event not be canceled to the guy in charge. The solution was to run it myself, and that nickname became mine as I slowly molded the event into my own. - -### Formy-Duval: I remember attending in those early days. How large did MAGFest eventually become? - -Becker: The first MAGFest was 265 people. It is now a scary huge 20,000+ unique attendees. - -### Formy-Duval: That is huge! Can you briefly describe the MAGFest convention? - -Becker: One of my buddies, Hex, described it really well. He said, "It's like this video-game themed birthday party with all of your friends, but there happen to be a few thousand people there, and all of them can be your friends if you want, and then there are rock concerts." This was quickly adopted and shortened to "It's a four-day video game party with multiple video game rock concerts." Often the phrase "music and gaming festival" is all people need to get the idea. - -### Formy-Duval: How did you make use of open source software in running MAGFest? - -Becker: At the time I became the head of MAGFest, I had already written a game in Python, so I felt most comfortable also writing our registration system in Python. It was a pretty easy decision since there were no costs involved, and I already had the experience. Later on, our online registration system and rideshare interfaces were written in PHP/MySQL, and we used Kboard for our forums. Eventually, this evolved to us rolling our own registration system from scratch in Python, which we also use at the event, and running Drupal on the main website. At one point, I also wrote a system to manage the video room and challenge stations in Python. Oh, and we had a few game music listening stations that you could flip through tracks and liner notes of iconic game OSTs (Original Sound Tracks) and bands who played MAGFest. - -### Formy-Duval: I understand that a few years ago you reduced your responsibilities at MAGFest to pursue new projects. What was your next endeavor? - -Becker: I was always rather heavily into the game music scene and tried to bring as much of it to MAGFest as possible. As I became a part of those communities more and more, I wanted to participate. I wrote some medleys, covers, and arrangements of video game tunes using free, open source versions of the DOS and Windows demoscene tools that I had used before, which were also free but not necessarily open source. I released a few tracks in the first few years of running MAGFest, and then after some tough love and counseling from Jake Kaufman (also known as virt; Shovel Knight and Shantae are on his resume, among others), I switched gears to something I was much better at—chiptunes. Even though I had written PC speaker beeps and boops as a kid with my Compaq Portable and MOD files in the demoscene throughout the 90s, I released the first NES-spec track that I was truly proud to call my own in 2006. Several pop tributes and albums followed. - -In 2010, I was approached by multiple individuals for game soundtrack work. Even though the soundtrack work didn't affect it much, I began to scale back some of my responsibilities with MAGFest more seriously, and in 2011, I decided to take a much larger step into the background. I would stay on the board as a consultant and help people learn what they needed to run their departments, but I was no longer at the helm. At the same time, my part-time job, which was paying the bills, laid off all of their workers, and I suddenly found myself with a lot of spare time. I began writing Pretty Eight Machine, a Nine Inch Nails tribute, which I spent over a year on, and between that and the game soundtrack work, I proved to myself that I could put food on the table (if only barely) with music, and this is what I wanted to do next. - -### - -![Inverse Phase CTM Tracker][7] - -Copyright Inverse Phase, Used with permission. - -### Formy-Duval: What is your workspace like in terms of hardware and software? - -Becker: In my DOS/Windows days, I used mostly FastTracker 2. In Linux, I replaced that with SoundTracker (not Karsten Obarski's original, but a GTK rewrite; see [soundtracker.org][8]). These days, SoundTracker is in a state of flux—although I still need to try the new GTK3 version—but [MilkyTracker][9] is a good replacement when I can't use SoundTracker. Good old FastTracker 2 also runs in DOSBox, if I really need the original. This was when I started using Linux, however, so this is stuff I figured out 20-25 years ago. - -Within the last ten years, I've gravitated away from sample-based music and towards chiptunes—music synthesized by old sound chips from 8- and 16-bit game systems and computers. There is a very good cross-platform tool called [Deflemask][10] to write music for a lot of these systems. A few of the systems I want to write music for aren't supported, though, and Deflemask is closed source, so I've begun building my own music composition environment from scratch with Python and [Pygame][11]. I maintain my code tree using Git and will control hardware synthesizer boards using open source [KiCad][12]. - -### Formy-Duval: What projects are you currently focused on? - -Becker: I work on game soundtracks and music commissions off and on. While that's going on, I've also been working on starting an electronic entertainment museum called [Bloop][13]. We're doing a lot of cool things with archival and inventory, but perhaps the most exciting thing is that we've been building exhibits with Raspberry Pis. They're so versatile, and it's weird to think that, if I had tried to do this even ten years ago, I wouldn't have had small single-board computers to drive my exhibits; I probably would have bolted a laptop to the back of a flat-panel! - -### Formy-Duval: There are a lot more game platforms coming to Linux now, such as Steam, Lutris, and Play-on-Linux. Do you think this trend will continue, and these are here to stay? - -Becker: As someone who's been gaming on Linux for 25 years—in fact, I was brought to Linux _because_ of games—I think I find this question harder than most people would. I've been running Linux-native games for decades, and I've even had to eat my "either a Linux solution exists or can be written" words back in the day, but eventually, I did, and wrote a Linux game. - -Real talk: Android's been out since 2008. If you've played a game on Android, you've played a game on Linux. Steam's been available for Linux for eight years. The Steambox/SteamOS was announced only a year after Steam. I don't hear a whole lot about Lutris or Play-on-Linux, but I know they exist and hope they succeed. I do see a pretty big following for GOG, and I think that's pretty neat. I see a lot of quality game ports coming out of people like Ryan Gordon (icculus) and Ethan Lee (flibitijibibo), and some companies even port in-house. Game engines like Unity and Unreal already support Linux. Valve has incorporated Proton into the Linux version of Steam for something like two years now, so now Linux users don't even have to search for Linux-native versions of their games. - -I can say that I think most gamers expect and will continue to expect the level of support they're already receiving from the retail game market. Personally, I hope that level goes up and not down! - -_Learn more about Brendan's work as [Inverse Phase][14]._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/2/linux-open-source-music - -作者:[Alan Formy-Duval][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/alanfdoss -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_other21x_cc.png?itok=JJJ5z6aB (Wires plugged into a network switch) -[2]: http://icculus.org/pyddr/ -[3]: http://magfest.org/ -[4]: http://www.inversephase.com/ -[5]: https://opensource.com/sites/default/files/uploads/inverse_phase_performance_bw.png (Inverse Phase performance photo) -[6]: https://en.wikipedia.org/wiki/Walnut_Creek_CDROM -[7]: https://opensource.com/sites/default/files/uploads/inversephase_ctm_tracker_screenshot.png (Inverse Phase CTM Tracker) -[8]: http://soundtracker.org -[9]: http://www.milkytracker.org -[10]: http://www.deflemask.com -[11]: http://www.pygame.org -[12]: http://www.kicad-pcb.org -[13]: http://bloopmuseum.com -[14]: https://www.inversephase.com diff --git a/sources/tech/20200228 4 technologists on careers in tech for minorities.md b/sources/tech/20200228 4 technologists on careers in tech for minorities.md deleted file mode 100644 index 806300d5db..0000000000 --- a/sources/tech/20200228 4 technologists on careers in tech for minorities.md +++ /dev/null @@ -1,126 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (4 technologists on careers in tech for minorities) -[#]: via: (https://opensource.com/article/20/2/careers-tech-minorities) -[#]: author: (Shilla Saebi https://opensource.com/users/shillasaebi) - -4 technologists on careers in tech for minorities -====== -Learn what Black History Month means to them, what influences their -career, resources for minorities wanting to break into tech, and more. -![Team meeting][1] - -In honor of Black History Month, I've garnered the opinions of a few of my favorite technology professionals and open source contributors. These four individuals are paving the way for the next generation alongside the work they're doing in the technology industry. Learn what Black History Month means to them, what influences their career, resources for minorities wanting to break into tech, and more. - -**[Tameika Reed][2], founder of Women In Linux** - -Since its launch, Tameika leads initiatives with a focus on exploring careers in infrastructure, cybersecurity, DevOps and IoT, pivoting into leadership and continuous skill-building. As a self-taught system administrator, Tameika believes the best way to learn tech is by just diving in. In efforts to give women a 360° view of tech, Tameika hosts a weekly virtual meetup to explore outside the norm of just Linux but introducing hyperledger, Kubernetes, microservices, and high-performance computing. Tameika’s career includes different conference talks from OSCon, LISA 2018, Seagl, HashiCorp EU 2019, and various local events. - -**[Michael Scott Winslow][3], Director, Core Applications and Platforms, Comcast** - -"I'm a father, husband, brother, and son. I come from a small family so I have fun turning friends into an extended family. When I attach my name to something, I obsess over its success, so I am very careful what I agree to be a part of. Oh, so as far as my career I have been involved with software development for decades. I solve problems. I work with others to help solve large problems. I lead, guide and mentor newer software engineers while observing others that I want to learn from." - -**[Bryan Liles][4], senior staff engineer, VMware** - -"I’m working with our team to rethink how developers interact with Kubernetes. When not working, I’m out in the community trying to inspire the next generation of software engineers and building robots." - -**[Mutale Nkonde][5], founding CEO of AI For the People (AFP)** - -AFP is a nonprofit creative agency. Prior to starting a nonprofit she worked in AI Governance. During that time she was part of the team that introduced the Algorithmic and Deep Fakes Algorithmic Acts, as well as the No Biometric Barriers to Housing Act to the US House of Representatives. Nkonde started her career as a broadcast journalist and worked at the BBC, CNN & ABC. She also writes widely on race and tech, as well as holding fellowships at Harvard and Stanford. - -### What influenced you to pursue a career in technology? - -My fear of the computer when I went back to college. I was afraid of the computer because I dropped out of college. After and going back, I made it my mission to learn all I can. This is still my motto to this day, learning never stops. —Tameika Reed - -I won’t mince words, I was a child geek! At 10 years old I started writing GW-BASIC from code that I read in printed magazines. Every single day. I gave it a bit of a break to have a life while I went to high school, but when it came time to pick a major for college, it was an easy choice. I stayed in technology thanks to the amazing mentors and colleagues I’ve had along the way. —Michael Scott Winslow - -I’ve been writing software since I was in middle school. I like being able to tell computers to do things and seeing the results. As an adult, I quickly realized that having a job that gave me satisfaction and paid well was the way to go. —Bryan Liles - -I wanted to explore the questions around why so few black women were being hired by tech companies. —Mutale Nkonde - -### Is there a particular person or people in open source and the tech world who have inspired you? - -I get inspired by a lot of other people and projects. For example, I love seeing others come to [Women In Linux][6] and are sure where they want to go. I try to give people a 360-view of tech so they can make a decision on what they like. Its easy to say I want to be in tech but it’s hard to get started and stay. You don’t have to be just a coder/programmer but you can be a cloud architect. —Tameika Reed - -[Kelsey Hightower][7], [Bryan Liles][4], and Kim Scott inspire me very much. They are so REAL! They say things that I feel and experience every day. Get your job done! Stop complaining! Own your actions and understand how you contribute to your situation! [Gene Kim][8] is a big inspiration as well. As a leader in the DevOps movement, I see myself following and emulating a lot of things he does. —Michael Scott Winslow - -No. I didn’t see the inspiration I wanted, so I’ve worked hard to be the inspiration I needed 20 years ago. —Bryan Liles - -There are so many! One of my favorites is [Dorothy Vaughan][9]: She was the first person in the US to program an IBM Watson computer. Her story is captured in the movie Hidden Figures. —Mutale Nkonde - -### Are there particular resources you would recommend for minorities wanting to break into tech? - -Yes, I recommend finding folks on Twitter and just ask questions. Here is a list of people I follow and admire in tech: —Tameika Reed - - * [@techgirl1908][10] - * [@bryanl][4] - * [@kelseyhightower][7] - * [@kstewart][11] - * [@tiffani][12] - * [@EricaJoy][13] - * [@womeninlinux][6] - * [@ArlanWasHere][14] - * [@blkintechnology][15] - * [@digundiv][16] - - - -Respected bootcamps are really cutting down the time it takes to break into the tech industry. I’ve met several professionals who went through bootcamps who have outshined their 4-year institution counterparts. I think we can really start respecting everything that people bring to the table, rather than technical fluency. —Michael Scott Winslow - -I’m not sure I can recommend anything specific. Tech is a big thing and there isn’t an easy answer. My advice is to pick something you think will be interested in and work to become an expert on the topic. Start asking why instead of how, and also start understanding how things work together. — Bryan Liles - -It really depends on the type of work they want to do. For people working at the intersection of tech and social justice, I would recommend the book [Algorithms of Oppression][17] by Safiya Noble. —Mutale Nkonde - -### What advice would you give to a person of color considering technology as their career? - -I suggest you study your craft. You will be a forever learner. There will always be someone or something in your way how you respond and move will be on you. Never take the first offer push back and know your worth. I look at tech like I look at art. It takes time to develop so be patient with yourself. It's okay to unplug and say no. —Tameika Reed - -As someone who is a bit of a protector of the industry, I don’t want people who are not suited for technology. So really decide if you have the personality for tech. Are you a problem solver? Are you more logical than emotional? Do you constantly find yourself creating processes? If so, no matter your background, I think you can find a home in tech. —Michael Scott Winslow - -It is not going to be simple. Your progress will be slowed because of your race. You will have to work harder. Use this adversity as a strength. You will be better prepared than those around you and when the opportunity arises, you will be able to tackle it. Find a network of those who look like you. Air grievances in private and show strength in public. You belong and you can succeed. —Bryan Liles - -To think beyond working for a company, the field of public interest tech is growing, our work centers on how technology impacts real people. Many of the people leading this work are women of color and Black women are making huge strides. Mutale Nkonde - -### What does Black History Month mean to you? - -It means never stop because you can never forget. —Tameika Reed - -Black History Month to me means focusing on the Tuskegee Airmen and not slavery. Highlighting how we contributed to history and not how were victims of it. I want people to understand where our pride comes from and not our anger. There are a lot of really bad things that happened to our people and we are still right here. Strong! —Michael Scott Winslow - -Black History Month is a time to reflect on the forgotten history of black people in the United States. I take it as a time to be thankful for the sacrifices my ancestors made. —Bryan Liles - -It is a time to center the contributions black people have made across the globe. I love it, it is one of my favorite times of year. —Mutale Nkonde - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/2/careers-tech-minorities - -作者:[Shilla Saebi][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/shillasaebi -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/meeting-team-listen-communicate.png?itok=KEBP6vZ_ (Team meeting) -[2]: https://www.linkedin.com/in/tameika-reed-1a7290128/ -[3]: https://twitter.com/michaelswinslow -[4]: https://twitter.com/bryanl -[5]: https://twitter.com/mutalenkonde -[6]: https://twitter.com/WomenInLinux -[7]: https://twitter.com/kelseyhightower -[8]: https://twitter.com/RealGeneKim -[9]: https://en.wikipedia.org/wiki/Dorothy_Vaughan -[10]: https://twitter.com/techgirl1908 -[11]: https://twitter.com/kstewart -[12]: https://twitter.com/tiffani -[13]: https://twitter.com/EricaJoy -[14]: https://twitter.com/ArlanWasHere -[15]: https://twitter.com/blkintechnology -[16]: https://twitter.com/digundiv -[17]: http://algorithmsofoppression.com/ diff --git a/sources/tech/20200320 Run a command on binary files with this script.md b/sources/tech/20200320 Run a command on binary files with this script.md index 2d6f0b6f26..a01e3e2ef0 100644 --- a/sources/tech/20200320 Run a command on binary files with this script.md +++ b/sources/tech/20200320 Run a command on binary files with this script.md @@ -761,7 +761,7 @@ via: https://opensource.com/article/20/3/run-binaries-script 作者:[Nick Clifton][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) +译者:[rakino](https://github.com/rakino) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/tech/20200428 Learn Bash with this book of puzzles.md b/sources/tech/20200428 Learn Bash with this book of puzzles.md deleted file mode 100644 index 08a07b93c5..0000000000 --- a/sources/tech/20200428 Learn Bash with this book of puzzles.md +++ /dev/null @@ -1,60 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Learn Bash with this book of puzzles) -[#]: via: (https://opensource.com/article/20/4/bash-it-out-book) -[#]: author: (Carlos Aguayo https://opensource.com/users/hwmaster1) - -Learn Bash with this book of puzzles -====== -'Bash it out' covers basic, medium, and advanced Bash scripting using 16 -puzzles. -![Puzzle pieces coming together to form a computer screen][1] - -Computers are both my hobby and my profession. I have about 10 of them scattered around my apartment, all running Linux (including my Macs). Since I enjoy upgrading my computers and my computer skills, when I came across [_Bash it out_][2] by Sylvain Leroux, I jumped on the chance to buy it. I use the command line a lot on Debian Linux, and it seemed like a great opportunity to expand my Bash knowledge. I smiled when the author explained in the preface that he uses Debian Linux, which is one of my two favorite distributions. - -Bash lets you automate tasks, so it's a labor-saving, interesting, and useful tool. Before reading the book, I already had a fair amount of experience with Bash on Unix and Linux. I'm not an expert, in part because the scripting language is so extensive and powerful. I first became intrigued with Bash when I saw it on the welcome screen of [EndeavourOS][3], an Arch-based Linux distribution. - -The following screenshots show some options from EndeavourOS. Beleieve it or not, these panels just point to Bash scripts, each of which accomplish some relatively complex tasks. And because it's all open source, I can modify any of these scripts if I want. - -![EndeavourOS after install][4] - -![EndeavourOS install apps][5] - -### Always something to learn - -My impressions of this book are very favorable. It's not long, but it is well-thought-out. The author has very extensive knowledge of Bash and an uncanny ability to explain how to use it. The book covers basic, medium, and advanced Bash scripting using 16 puzzles, which he calls "challenges." This taught me to see Bash scripting as a programming puzzle to solve, which makes it more interesting to play with. - -An exciting aspect of Bash is that it's deeply integrated with the Linux system. While part of its power lies in its syntax, it's also powerful because it has access to so much. You can script repetitive tasks, or tasks that are easy but you're just tired of performing manually. Nothing is too great or too small, and _Bash it out_ helps you understand both what you can do, and how to achieve it. - -This review would not be complete if I didn't mention David Both's free resource [_A sysadmin's guide to Bash scripting_][6] on Opensource.com. This 17-page PDF guide is different from _Bash it out_, but together they make a winning combination for anyone who wants to learn about it. - -I am not a computer programmer, but _Bash it out_ has increased my desire to get into more advanced levels of Bash scripting—I might inadvertently end up as a computer programmer without planning to. - -One reason I love Linux is because of how powerful and versatile the operating system is. However much I know about Linux, there is always something new to learn that makes me appreciate Linux even more. - -In a competitive and ever-changing job market, it behooves all of us to continuously update our skills. This book helped me learn Bash in a very hands-on way. It almost felt as if the author was in the same room with me, patiently guiding me in my learning. - -The author, Leroux, has an uncanny ability to engage readers. This is a rare gift that I think is even more valuable than his technical expertise. In fact, I am writing this book review to thank the author for anticipating my own learning needs; although we have never met, I have benefited in real ways from his gifts. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/4/bash-it-out-book - -作者:[Carlos Aguayo][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/hwmaster1 -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/puzzle_computer_solve_fix_tool.png?itok=U0pH1uwj (Puzzle pieces coming together to form a computer screen) -[2]: https://www.amazon.com/Bash-Out-Strengthen-challenges-difficulties/dp/1521773262/ -[3]: https://endeavouros.com/ -[4]: https://opensource.com/sites/default/files/uploads/endeavouros-welcome.png (EndeavourOS after install) -[5]: https://opensource.com/sites/default/files/uploads/endeavouros-install-apps.png (EndeavourOS install apps) -[6]: https://opensource.com/downloads/bash-scripting-ebook diff --git a/sources/tech/20200504 Understanding systemd at startup on Linux.md b/sources/tech/20200504 Understanding systemd at startup on Linux.md index 2d0a5ef7b6..7a2c6ec9ad 100644 --- a/sources/tech/20200504 Understanding systemd at startup on Linux.md +++ b/sources/tech/20200504 Understanding systemd at startup on Linux.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (YungeG) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20200528 9 open source JavaScript frameworks for front-end web development.md b/sources/tech/20200528 9 open source JavaScript frameworks for front-end web development.md deleted file mode 100644 index 7a029d71fd..0000000000 --- a/sources/tech/20200528 9 open source JavaScript frameworks for front-end web development.md +++ /dev/null @@ -1,294 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (9 open source JavaScript frameworks for front-end web development) -[#]: via: (https://opensource.com/article/20/5/open-source-javascript-frameworks) -[#]: author: (Bryant Son https://opensource.com/users/brson) - -9 open source JavaScript frameworks for front-end web development -====== -A breakdown of many JavaScript options for frameworks—their strengths -and key features. -![Computer screen with files or windows open][1] - -About a decade ago, the JavaScript developer community began to witness fierce battles emerging among JavaScript frameworks. In this article, I will introduce some of the most well-known of these frameworks. And it's important to note that these are all open source JavaScript projects, meaning that you can freely utilize them under an [open source license][2] and even contribute to the source code and communities. - -If you prefer to follow along as I explore these frameworks, you can watch my video. - -Before getting started, though, it will be useful to learn some of the terminology JavaScript developers commonly use when discussing frameworks. - -Term | What It Is ----|--- -[Document Object Model (DOM)][3] | A tree-structure representation of a website where each node is an object representing part of the webpage. The World Wide Web Consortium (W3C), the international standards organization for the World Wide Web, maintains the definition of the DOM. -[Virtual DOM][4] | A "virtual" or "ideal" representation of a user interface (UI) is kept in memory and synced with the "real" DOM by a library such as [ReactDOM][5]. To explore further, please read ReactJS's virtual DOM and internals documentation. -[Data Binding][6] | A programming concept to provide a consistent interface for accessing data on websites. Web elements are associated with a property or attribute of an element maintained by the DOM. For example, when you need to fill out a password in a webpage form, the data binding mechanism can check with the password validation logic to ensure that the password is in a valid format. - -Now that we are clear about common terms, let's explore what open source JavaScript frameworks are out there. - -Framework | About | License | Release Date ----|---|---|--- -[ReactJS][7] | Created by Facebook, currently the most popular JavaScript framework | MIT License | May 24, 2013 -[Angular][8] | Popular JavaScript framework created by Google | MIT License | Jan 5, 2010 -[VueJS][9] | Rapidly growing JavaScript framework | MIT License | Jul 28, 2013 -[MeteorJS][10] | Powerful framework that is more than a JavaScript framework | MIT License | Jan 18, 2012 -[KnockoutJS][11] | Open source Model-View-ViewModel (MVVM) framework | MIT License | Jul 5, 2010 -[EmberJS][12] | Another open source Model-View-ViewModel framework | MIT License | Dec 8, 2011 -[BackboneJS][13] | JavaScript framework with RESTful JSON and Model-View-Presenter pattern | MIT License | Sep 30, 2010 -[Svelte][14] | Open source JavaScript framework not using virtual DOM | MIT License | Nov 20, 2016 -[AureliaJS][15] | A collection of Modern JavaScript modules | MIT License | Feb 14, 2018 - -For context, here is the publicly available data on popularity based on NPM package downloads per framework, thanks to [npm trends][16]. - -![Framework downloads graph][17] - -### ReactJS - -![React page][18] - -[ReactJS][19] was invented by Facebook, and it is the clear leader among JavaScript frameworks today, though it was invented well after Angular. React introduces a concept called a virtual DOM, an abstract copy where developers can utilize only the ReactJS features that they want, without having to rewrite the entire project to work within the framework. In addition, the active open source community with the React project has definitely been the workhorse behind the growth. Here are some of React's key strengths: - - * Reasonable learning curve—React developers can easily create the React components without rewriting the entire code in JavaScript. See the benefits of ReactJS and how it makes it the programming easier on ReactJS's [front page][20]. - * Highly optimized for performance—React's virtual DOM implementation and other features boost app rendering performance. See ReactJS's [description][21] of how its performance can be benchmarked and measured in terms of how the app performs. - * Excellent supporting tools—[Redux][22], [Thunk][23], and [Reselect][24] are some of the best tools for building well-structured, debuggable code. - * One way data binding—The model used in Reach flows from owner to child only making it simpler to trace cause and effect in code. Read more about it on ReactJS's [page on data binding][25]. - - - -Who is using ReactJS? Since Facebook invented it, the company itself heavily uses React for its frontpage, and [Instagram][26] is said to be completely based on the ReactJS library. You might be surprised to know that other well-known companies like [New York Times][27], [Netflix][28], and [Khan Academy][29] also implement ReactJS in their technology stacks. - -What may be even more surprising is the availability of jobs for ReactJS developers, as you can see below from research done by Stackoverflow. Hey, you can work on an open source project and get paid to do it. That is pretty cool! - -![React jobs page][30] - -Stackoverflow shows the huge demand for ReactJS developers—[Source: Developer Hiring Trends in 2017—Stackoverflow Blog][31] - -  - -[ReactJS's GitHub][7] currently shows over 13K commits and 1,377 contributors to the open source project. And it is an open source project under MIT License. - -![React GitHub page][32] - -### Angular - -![Angular homepage][33] - -React may now be the leading JavaScript framework in terms of the number of developers, but [Angular][34] is close behind. In fact, while React is the more popular choice among open source developers and startup companies, larger corporations tend to prefer Angular (a few are listed below). The main reason is that, while Angular might be more complicated, its uniformity and consistency works well for larger projects. For example, I have worked on both Angular and React throughout my career, and I observed that the larger companies generally consider Angular's strict structure a strength. Here are some other key strengths of Angular: - - * Well-designed Command Line Interface: Angular has an excellent Command Line Interface (CLI) tool to easily bootstrap and to develop with Angular. ReactJS also offers the Command Line Interface as well as other tools, but Angular has extensive support and excellent documentation, as you can see on [this page][35]. - * One way data binding—Similarly to React, the one-way data binding model makes the framework less susceptible to unwanted side effects. - * Great support for TypeScript—Angular has excellent alignment with [TypeScript][36], which is effectively JavaScript more type enforcement. It also transcompiling to JavaScript, making it a great option to enforce types for less buggy code. - - - -Well-known websites like YouTube, [Netflix][37], [IBM][38], and [Walmart][39] all have implemented Angular into their applications. I personally started front-end JavaScript development with Angular by educating myself on the subject. I have worked on quite a few personal and professional projects involving Angular, but that was Angular 1.x, which was called by AngularJS at the time. When Google decided to upgrade the version to 2.0, they completely revamped the framework, and then it became Angular. The new Angular was a complete transformation of the previous AngularJS, which drove off some existing developers while bringing new developers. - -[Angular's][8] [GitHub][8] page shows 17,781 commits and 1,133 contributors at the time of this writing. It is also an open source project with an MIT License, so you can feel free to use it for your project or to contribute. - -  - -![Angular GitHub page][40] - -### VueJS - -![Vue JS page][41] - -[VueJS][42] is a very interesting framework. It is a newcomer to the JavaScript framework scene, but its popularity has increased significantly over the course of a few years. VueJS was created by [Evan Yu][43], a former Google engineer who had worked on the Angular project. The framework got so popular that many front-end engineers now prefer VueJS over other JavaScript frameworks. The chart below depicts how fast the framework gained traction over time. - -![Vue JS popularity graph][44] - -Here are some of the key strengths of VueJS: - - * Easier learning curve—Even compared to Angular or React, many front-end developers feel that VueJS has the lowest learning curve. - * Small size—VueJS is relatively lightweight compared to Angular or React. In its [official documentation][45], its size is stated to be only about 30 KB, while the project generated by Angular, for example, is over 65 KB. - * Concise documentation—Vue has thorough but concise and clear documentation. See [its official documentation][46] for yourself. - - - -[VueJS's GitHub][9] shows 3,099 commits and 239 contributors. - -![Vue JS GitHub page][47] - -### MeteorJS - -![Meteor page][48] - -[MeteorJS][49] is a free and open source [isomorphic framework][50], which means, just like NodeJS, it runs both client and server-side JavaScript. Meteor can be used in conjunction with any other popular front-end framework like Angular, React, Vue, Svelte, etc. - -Meteor is used by several corporations such as Qualcomm, Mazda, and Ikea, and many applications like Dispatch and Rocket.Chat. [See the case studies on its official website.][51] - -![Meteor case study][52] - -Some of the key features of Meteor include: - - * Data on the wire—The server sends the data, not HTML, and the client renders it. Data on the wire refers mostly to the way that Meteor forms a WebSocket connection to the server on page load, and then transfers the data needed over that connection. - * Develop everything in JavaScript—Client-side, application server, webpage, and mobile interface can be all designed with JavaScript. - * Supports most major frameworks—Angular, React, and Vue can be all combined and used in conjunction with Meteor. Thus, you can still use your favorite framework, like React or Angular, but still leverage some of the great features that Meteor offers. - - - -As of now, [Meteor's][10] [GitHub][10] shows 22,804 commits and 428 contributors. That is quite a lot for open source activities! - -![Meteor GitHub page][53] - -### EmberJS - -![EmberJS page][54] - -[EmberJS][55] is an open source JavaScript framework based on the [Model-view-viewModel(MVVM)][56] pattern. If you've never heard about EmberJS, you'll definitely be surprised how many companies are using it. Apple Music, Square, Discourse, Groupon, LinkedIn, Twitch, Nordstorm, and Chipotle all leverage EmberJS as one of their technology stacks. Check [EmberJS's official page][57] to discover all applications and customers that use EmberJS. - -Although Ember has similar benefits to the other frameworks we've discussed, here are some of its unique differentiators: - - * Convention over configuration—Ember standardizes naming conventions and automatically generates the result code. This approach has a little more of a learning curve but ensures that programmers follow best-recommended practices. - * Fully-fledged templating mechanism—Ember relies on straight text manipulation, building the HTML document dynamically while knowing nothing about DOM. - - - -As one might expect from a framework used by many applications, [Ember's GitHub][58] page shows 19,808 commits and 785 contributors. That is huge! - -![EmberJS GitHub page][59] - -### KnockoutJS - -![KnockoutJS page][60] - -[KnockoutJS][61] is a standalone open source JavaScript framework adopting a [Model-View-ViewModel (MVVM)][56] pattern with templates. Although fewer people may have heard about this framework compared to Angular, React, or Vue, the project is still quite active among the development community and leverages features such as: - - * Declarative binding—Knockout's declarative binding system provides a concise and powerful way to link data to the UI. It's generally easy to bind to simple data properties or to use a single binding. Read more about it [here at KnockoutJS's official documentation page][62]. - * Automatic UI refresh - * Dependency tracking templating - - - -[Knockout's GitHub][11] page shows about 1,766 commits and 81 contributors. Those numbers are not as significant compared to the other frameworks, but the project is still actively maintained. - -![Knockout GitHub page][63] - -### BackboneJS - -![BackboneJS page][64] - -[BackboneJS][65] is a lightweight JavaScript framework with a RESTful JSON interface and is based on Model-View-Presenter (MVP) design paradigm. - -The framework is said to be used by [Airbnb][66], Hulu, SoundCloud, and Trello. You can find all of these case studies on [Backbone's page][67]. - -The [BackboneJS GitHub][13] page shows 3,386 commits and 289 contributors. - -![BackboneJS GitHub page][68] - -### Svelte - -![Svelte page][69] - -[Svelte][70] is an open source JavaScript framework that generates the code to manipulate DOM instead of including framework references. This process of converting an app into JavaScript at build time rather than run time might offer a slight boost in performance in some scenarios. - -[Svelte's][14] [GitHub][14] page shows 5,729 commits and 296 contributors as of this writing. - -![Svelte GitHub page][71] - -### AureliaJS - -![Aurelia page][72] - -Last on the list is [Aurelia][73]. Aurelia is a front-end JavaScript framework that is a collection of modern JavaScript modules. Aurelia has the following interesting features: - - * Fast rendering—Aurelia claims that its framework can render faster than any other framework today. - * Uni-directional data flow—Aurelia uses an observable-based binding system that pushes the data from the model to the view. - * Build with vanilla JavaScript—You can build all of the website's components with plain JavaScript. - - - -[Aurelia's][15] [GitHub][15] page shows 788 commits and 96 contributors as of this writing. - -![Aurelia GitHub page][74] - -So that is what I found when looking at what is new in the JavaScript framework world. Did I miss any interesting frameworks? Feel free to share your ideas in the comment section! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/5/open-source-javascript-frameworks - -作者:[Bryant Son][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/brson -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_screen_windows_files.png?itok=kLTeQUbY (Computer screen with files or windows open) -[2]: https://opensource.com/article/17/9/open-source-licensing -[3]: https://www.w3schools.com/js/js_htmldom.asp -[4]: https://reactjs.org/docs/faq-internals.html -[5]: https://reactjs.org/docs/react-dom.html -[6]: https://en.wikipedia.org/wiki/Data_binding -[7]: https://github.com/facebook/react -[8]: https://github.com/angular/angular -[9]: https://github.com/vuejs/vue -[10]: https://github.com/meteor/meteor -[11]: https://github.com/knockout/knockout -[12]: https://github.com/emberjs/ember.js -[13]: https://github.com/jashkenas/backbone -[14]: https://github.com/sveltejs/svelte -[15]: https://github.com/aurelia/framework -[16]: https://www.npmtrends.com/angular-vs-react-vs-vue-vs-meteor-vs-backbone -[17]: https://opensource.com/sites/default/files/uploads/open-source-javascript-framework-downloads-opensourcedotcom_0.png (Framework downloads graph) -[18]: https://opensource.com/sites/default/files/uploads/3_react.jpg (React page) -[19]: https://reactjs.org -[20]: https://reactjs.org/ -[21]: https://reactjs.org/docs/perf.html -[22]: https://redux.js.org/ -[23]: https://github.com/reduxjs/redux-thunk -[24]: https://github.com/reduxjs/reselect -[25]: https://reactjs.org/docs/two-way-binding-helpers.html -[26]: https://instagram-engineering.com/react-native-at-instagram-dd828a9a90c7 -[27]: https://open.nytimes.com/introducing-react-tracking-declarative-tracking-for-react-apps-2c76706bb79a -[28]: https://medium.com/dev-channel/a-netflix-web-performance-case-study-c0bcde26a9d9 -[29]: https://khan.github.io/react-components/ -[30]: https://opensource.com/sites/default/files/uploads/4_reactjobs_0.jpg (React jobs page) -[31]: https://stackoverflow.blog/2017/03/09/developer-hiring-trends-2017 -[32]: https://opensource.com/sites/default/files/uploads/5_reactgithub.jpg (React GitHub page) -[33]: https://opensource.com/sites/default/files/uploads/6_angular.jpg (Angular homepage) -[34]: https://angular.io -[35]: https://cli.angular.io/ -[36]: https://www.typescriptlang.org/ -[37]: https://netflixtechblog.com/netflix-likes-react-509675426db -[38]: https://developer.ibm.com/technologies/javascript/tutorials/wa-react-intro/ -[39]: https://medium.com/walmartlabs/tagged/react -[40]: https://opensource.com/sites/default/files/uploads/7_angulargithub.jpg (Angular GitHub page) -[41]: https://opensource.com/sites/default/files/uploads/8_vuejs.jpg (Vue JS page) -[42]: https://vuejs.org -[43]: https://www.freecodecamp.org/news/between-the-wires-an-interview-with-vue-js-creator-evan-you-e383cbf57cc4/ -[44]: https://opensource.com/sites/default/files/uploads/9_vuejspopularity.jpg (Vue JS popularity graph) -[45]: https://vuejs.org/v2/guide/comparison.html#Size -[46]: https://vuejs.org/v2/guide/ -[47]: https://opensource.com/sites/default/files/uploads/10_vuejsgithub.jpg (Vue JS GitHub page) -[48]: https://opensource.com/sites/default/files/uploads/11_meteor_0.jpg (Meteor Page) -[49]: https://www.meteor.com -[50]: https://en.wikipedia.org/wiki/Isomorphic_JavaScript -[51]: https://www.meteor.com/showcase -[52]: https://opensource.com/sites/default/files/uploads/casestudy1_meteor.jpg (Meteor case study) -[53]: https://opensource.com/sites/default/files/uploads/12_meteorgithub.jpg (Meteor GitHub page) -[54]: https://opensource.com/sites/default/files/uploads/13_emberjs.jpg (EmberJS page) -[55]: https://emberjs.com -[56]: https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel -[57]: https://emberjs.com/ember-users -[58]: https://github.com/emberjs -[59]: https://opensource.com/sites/default/files/uploads/14_embergithub.jpg (EmberJS GitHub page) -[60]: https://opensource.com/sites/default/files/uploads/15_knockoutjs.jpg (KnockoutJS page) -[61]: https://knockoutjs.com -[62]: https://knockoutjs.com/documentation/binding-syntax.html -[63]: https://opensource.com/sites/default/files/uploads/16_knockoutgithub.jpg (Knockout GitHub page) -[64]: https://opensource.com/sites/default/files/uploads/17_backbonejs.jpg (BackboneJS page) -[65]: https://backbonejs.org -[66]: https://medium.com/airbnb-engineering/our-first-node-js-app-backbone-on-the-client-and-server-c659abb0e2b4 -[67]: https://sites.google.com/site/backbonejsja/examples -[68]: https://opensource.com/sites/default/files/uploads/18_backbonejsgithub.jpg (BackboneJS GitHub page) -[69]: https://opensource.com/sites/default/files/uploads/19_svelte.jpg (Svelte page) -[70]: https://svelte.dev -[71]: https://opensource.com/sites/default/files/uploads/20_svletegithub.jpg (Svelte GitHub page) -[72]: https://opensource.com/sites/default/files/uploads/21_aurelia.jpg (Aurelia page) -[73]: https://aurelia.io -[74]: https://opensource.com/sites/default/files/uploads/22_aureliagithub.jpg (Aurelia GitHub page) diff --git a/sources/tech/20200629 Scaling a GraphQL Website.md b/sources/tech/20200629 Scaling a GraphQL Website.md index 5434cc1032..5389594701 100644 --- a/sources/tech/20200629 Scaling a GraphQL Website.md +++ b/sources/tech/20200629 Scaling a GraphQL Website.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: (MjSeven) +[#]: translator: ( ) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20200807 An advanced guide to NLP analysis with Python and NLTK.md b/sources/tech/20200807 An advanced guide to NLP analysis with Python and NLTK.md deleted file mode 100644 index 2f6c16a085..0000000000 --- a/sources/tech/20200807 An advanced guide to NLP analysis with Python and NLTK.md +++ /dev/null @@ -1,542 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (An advanced guide to NLP analysis with Python and NLTK) -[#]: via: (https://opensource.com/article/20/8/nlp-python-nltk) -[#]: author: (Girish Managoli https://opensource.com/users/gammay) - -An advanced guide to NLP analysis with Python and NLTK -====== -Get deeper into the foundational concepts behind natural language -processing. -![Brain on a computer screen][1] - -In my [previous article][2], I introduced natural language processing (NLP) and the Natural Language Toolkit ([NLTK][3]), the NLP toolkit created at the University of Pennsylvania. I demonstrated how to parse text and define stopwords in Python and introduced the concept of a corpus, a dataset of text that aids in text processing with out-of-the-box data. In this article, I'll continue utilizing datasets to compare and analyze natural language. - -The fundamental building blocks covered in this article are: - - * WordNet and synsets - * Similarity comparison - * Tree and treebank - * Named entity recognition - - - -### WordNet and synsets - -[WordNet][4] is a large lexical database corpus in NLTK. WordNet maintains cognitive synonyms (commonly called synsets) of words correlated by nouns, verbs, adjectives, adverbs, synonyms, antonyms, and more. - -WordNet is a very useful tool for text analysis. It is available for many languages (Chinese, English, Japanese, Russian, Spanish, and more), under many licenses (ranging from open source to commercial). The first WordNet was created by Princeton University for English under an MIT-like license. - -A word is typically associated with multiple synsets based on its meanings and parts of speech. Each synset usually provides these attributes: - -**Attribute** | **Definition** | **Example** ----|---|--- -Name | Name of the synset | Example: The word "code" has five synsets with names `code.n.01`, `code.n.02`, `code.n.03`, `code.v.01`, `code.v.02` -POS | Part of speech of the word for this synset | The word "code" has three synsets in noun form and two in verb form -Definition | Definition of the word (in POS) | One of the definitions of "code" in verb form is: "(computer science) the symbolic arrangement of data or instructions in a computer program" -Examples | Examples of word's use | One of the examples of "code": "We should encode the message for security reasons" -Lemmas | Other word synsets this word+POC is related to (not strictly synonyms, but can be considered so); lemmas are related to other lemmas, not to words directly | Lemmas of `code.v.02` (as in "convert ordinary language into code") are `code.v.02.encipher`, `code.v.02.cipher`, `code.v.02.cypher`, `code.v.02.encrypt`, `code.v.02.inscribe`, `code.v.02.write_in_code` -Antonyms | Opposites | Antonym of lemma `encode.v.01.encode` is `decode.v.01.decode` -Hypernym | A broad category that other words fall under | A hypernym of `code.v.01` (as in "Code the pieces with numbers so that you can identify them later") is `tag.v.01` -Meronym | A word that is part of (or subordinate to) a broad category | A meronym of "computer" is "chip" -Holonym | The relationship between a parent word and its subordinate parts | A hyponym of "window" is "computer screen" - -There are several other attributes, which you can find in the `nltk/corpus/reader/wordnet.py` source file in `/Lib/site-packages`. - -Some code may help this make more sense. - -This helper function: - - -``` -def synset_info(synset): -    print("Name", synset.name()) -    print("POS:", synset.pos()) -    print("Definition:", synset.definition()) -    print("Examples:", synset.examples()) -    print("Lemmas:", synset.lemmas()) -    print("Antonyms:", [lemma.antonyms() for lemma in synset.lemmas() if len(lemma.antonyms()) > 0]) -    print("Hypernyms:", synset.hypernyms()) -    print("Instance Hypernyms:", synset.instance_hypernyms()) -    print("Part Holonyms:", synset.part_holonyms()) -    print("Part Meronyms:", synset.part_meronyms()) -    print() - -[/code] [code]`synsets = wordnet.synsets('code')` -``` - -shows this: - - -``` -5 synsets: -Name code.n.01 -POS: n -Definition: a set of rules or principles or laws (especially written ones) -Examples: [] -Lemmas: [Lemma('code.n.01.code'), Lemma('code.n.01.codification')] -Antonyms: [] -Hypernyms: [Synset('written_communication.n.01')] -Instance Hpernyms: [] -Part Holonyms: [] -Part Meronyms: [] - -... - -Name code.n.03 -POS: n -Definition: (computer science) the symbolic arrangement of data or instructions in a computer program or the set of such instructions -Examples: [] -Lemmas: [Lemma('code.n.03.code'), Lemma('code.n.03.computer_code')] -Antonyms: [] -Hypernyms: [Synset('coding_system.n.01')] -Instance Hpernyms: [] -Part Holonyms: [] -Part Meronyms: [] - -... - -Name code.v.02 -POS: v -Definition: convert ordinary language into code -Examples: ['We should encode the message for security reasons'] -Lemmas: [Lemma('code.v.02.code'), Lemma('code.v.02.encipher'), Lemma('code.v.02.cipher'), Lemma('code.v.02.cypher'), Lemma('code.v.02.encrypt'), Lemma('code.v.02.inscribe'), Lemma('code.v.02.write_in_code')] -Antonyms: [] -Hypernyms: [Synset('encode.v.01')] -Instance Hpernyms: [] -Part Holonyms: [] -Part Meronyms: [] -``` - -Synsets and lemmas follow a tree structure you can visualize: - - -``` -def hypernyms(synset): -    return synset.hypernyms() - -synsets = wordnet.synsets('soccer') -for synset in synsets: -    print(synset.name() + " tree:") -    pprint(synset.tree(rel=hypernyms)) -    print() - -[/code] [code] - -code.n.01 tree: -[Synset('code.n.01'), - [Synset('written_communication.n.01'), -   ... - -code.n.02 tree: -[Synset('code.n.02'), - [Synset('coding_system.n.01'), -   ... - -code.n.03 tree: -[Synset('code.n.03'), -   ... - -code.v.01 tree: -[Synset('code.v.01'), - [Synset('tag.v.01'), -   ... - -code.v.02 tree: -[Synset('code.v.02'), - [Synset('encode.v.01'), -   ... -``` - -WordNet does not cover all words and their information (there are about 170,000 words in English today and about 155,000 in the latest version of WordNet), but it's a good starting point. After you learn the concepts of this building block, if you find it inadequate for your needs, you can migrate to another. Or, you can build your own WordNet! - -#### Try it yourself - -Using the Python libraries, download Wikipedia's page on [open source][5] and list the synsets and lemmas of all the words. - -### Similarity comparison - -Similarity comparison is a building block that identifies similarities between two pieces of text. It has many applications in search engines, chatbots, and more. - -For example, are the words "football" and "soccer" related? - - -``` -syn1 = wordnet.synsets('football') -syn2 = wordnet.synsets('soccer') - -# A word may have multiple synsets, so need to compare each synset of word1 with synset of word2 -for s1 in syn1: -    for s2 in syn2: -        print("Path similarity of: ") -        print(s1, '(', s1.pos(), ')', '[', s1.definition(), ']') -        print(s2, '(', s2.pos(), ')', '[', s2.definition(), ']') -        print("   is", s1.path_similarity(s2)) -        print() - -[/code] [code] - -Path similarity of: -Synset('football.n.01') ( n ) [ any of various games played with a ball (round or oval) in which two teams try to kick or carry or propel the ball into each other's goal ] -Synset('soccer.n.01') ( n ) [ a football game in which two teams of 11 players try to kick or head a ball into the opponents' goal ] -   is 0.5 - -Path similarity of: -Synset('football.n.02') ( n ) [ the inflated oblong ball used in playing American football ] -Synset('soccer.n.01') ( n ) [ a football game in which two teams of 11 players try to kick or head a ball into the opponents' goal ] -   is 0.05 -``` - -The highest path similarity score of the words is 0.5, indicating they are closely related. - -What about "code" and "bug"? Similarity scores for these words used in computer science are: - - -``` -Path similarity of: -Synset('code.n.01') ( n ) [ a set of rules or principles or laws (especially written ones) ] -Synset('bug.n.02') ( n ) [ a fault or defect in a computer program, system, or machine ] -   is 0.1111111111111111 -... -Path similarity of: -Synset('code.n.02') ( n ) [ a coding system used for transmitting messages requiring brevity or secrecy ] -Synset('bug.n.02') ( n ) [ a fault or defect in a computer program, system, or machine ] -   is 0.09090909090909091 -... -Path similarity of: -Synset('code.n.03') ( n ) [ (computer science) the symbolic arrangement of data or instructions in a computer program or the set of such instructions ] -Synset('bug.n.02') ( n ) [ a fault or defect in a computer program, system, or machine ] -   is 0.09090909090909091 -``` - -These are the highest similarity scores, which indicates they are related. - -NLTK provides several similarity scorers, such as: - - * path_similarity - * lch_similarity - * wup_similarity - * res_similarity - * jcn_similarity - * lin_similarity - - - -See the Similarity section of the [WordNet Interface][6] page to determine the appropriate one for your application. - -#### Try it yourself - -Using Python libraries, start from the Wikipedia [Category: Lists of computer terms][7] page and prepare a list of terminologies, then see how the words correlate. - -### Tree and treebank - -With NLTK, you can represent a text's structure in tree form to help with text analysis. - -Here is an example: - -A simple text pre-processed and part-of-speech (POS)-tagged: - - -``` -import nltk - -text = "I love open source" -# Tokenize to words -words = nltk.tokenize.word_tokenize(text) -# POS tag the words -words_tagged = nltk.pos_tag(words) -``` - -You must define a grammar to convert the text to a tree structure. This example uses a simple grammar based on the [Penn Treebank tags][8]. - - -``` -# A simple grammar to create tree -grammar = "NP: {<JJ><NN>}" -``` - -Next, use the grammar to create a tree: - - -``` -# Create tree -parser = nltk.RegexpParser(grammar) -tree = parser.parse(words_tagged) -pprint(tree) -``` - -This produces: - - -``` -`Tree('S', [('I', 'PRP'), ('love', 'VBP'), Tree('NP', [('open', 'JJ'), ('source', 'NN')])])` -``` - -You can see it better graphically. - - -``` -`tree.draw()` -``` - -![NLTK Tree][9] - -(Girish Managoli, [CC BY-SA 4.0][10]) - -This structure helps explain the text's meaning correctly. As an example, identify the [subject][11] in this text: - - -``` -subject_tags = ["NN", "NNS", "NP", "NNP", "NNPS", "PRP", "PRP$"] -def subject(sentence_tree): -    for tagged_word in sentence_tree: -        # A crude logic for this case -  first word with these tags is considered subject -        if tagged_word[1] in subject_tags: -            return tagged_word[0] - -print("Subject:", subject(tree)) -``` - -It shows "I" is the subject: - - -``` -`Subject: I` -``` - -This is a basic text analysis building block that is applicable to larger applications. For example, when a user says, "Book a flight for my mom, Jane, to NY from London on January 1st," a chatbot using this block can interpret the request as: - -**Action**: Book -**What**: Flight -**Traveler**: Jane -**From**: London -**To**: New York -**Date**: 1 Jan (of the next year) - -A treebank refers to a corpus with pre-tagged trees. Open source, conditional free-for-use, and commercial treebanks are available for many languages. The most commonly used one for English is Penn Treebank, extracted from the _Wall Street Journal_, a subset of which is included in NLTK. Some ways of using a treebank: - - -``` -words = nltk.corpus.treebank.words() -print(len(words), "words:") -print(words) - -tagged_sents = nltk.corpus.treebank.tagged_sents() -print(len(tagged_sents), "sentences:") -print(tagged_sents) - -[/code] [code] - -100676 words: -['Pierre', 'Vinken', ',', '61', 'years', 'old', ',', ...] -3914 sentences: -[[('Pierre', 'NNP'), ('Vinken', 'NNP'), (',', ','), ('61', 'CD'), ('years', 'NNS'), ('old', 'JJ'), (',', ','), ('will', 'MD'), ('join', 'VB'), ('the', 'DT'), ('board', 'NN'), ('as', 'IN'), ('a', 'DT'), ('nonexecutive', 'JJ'), ('director', 'NN'), ...] -``` - -See tags in a sentence: - - -``` -sent0 = tagged_sents[0] -pprint(sent0) - -[/code] [code] - -[('Pierre', 'NNP'), - ('Vinken', 'NNP'), - (',', ','), - ('61', 'CD'), - ('years', 'NNS'), -... -``` - -Create a grammar to convert this to a tree: - - -``` -grammar = ''' -    Subject: {<NNP><NNP>} -    SubjectInfo: {<CD><NNS><JJ>} -    Action: {<MD><VB>} -    Object: {<DT><NN>} -    Stopwords: {<IN><DT>} -    ObjectInfo: {<JJ><NN>} -    When: {<NNP><CD>} -''' -parser = nltk.RegexpParser(grammar) -tree = parser.parse(sent0) -print(tree) - -[/code] [code] - -(S -  (Subject Pierre/NNP Vinken/NNP) -  ,/, -  (SubjectInfo 61/CD years/NNS old/JJ) -  ,/, -  (Action will/MD join/VB) -  (Object the/DT board/NN) -  as/IN -  a/DT -  (ObjectInfo nonexecutive/JJ director/NN) -  (Subject Nov./NNP) -  29/CD -  ./.) -``` - -See it graphically: - - -``` -`tree.draw()` -``` - -![NLP Treebank image][12] - -(Girish Managoli, [CC BY-SA 4.0][10]) - -The concept of trees and treebanks is a powerful building block for text analysis. - -#### Try it yourself - -Using the Python libraries, download Wikipedia's page on [open source][5] and represent the text in a presentable view. - -### Named entity recognition - -Text, whether spoken or written, contains important data. One of text processing's primary goals is extracting this key data. This is needed in almost all applications, such as an airline chatbot that books tickets or a question-answering bot. NLTK provides a named entity recognition feature for this. - -Here's a code example: - - -``` -`sentence = 'Peterson first suggested the name "open source" at Palo Alto, California'` -``` - -See if name and place are recognized in this sentence. Pre-process as usual: - - -``` -import nltk - -words = nltk.word_tokenize(sentence) -pos_tagged = nltk.pos_tag(words) -``` - -Run the named-entity tagger: - - -``` -ne_tagged = nltk.ne_chunk(pos_tagged) -print("NE tagged text:") -print(ne_tagged) -print() - -[/code] [code] - -NE tagged text: -(S -  (PERSON Peterson/NNP) -  first/RB -  suggested/VBD -  the/DT -  name/NN -  ``/`` -  open/JJ -  source/NN -  ''/'' -  at/IN -  (FACILITY Palo/NNP Alto/NNP) -  ,/, -  (GPE California/NNP)) -``` - -Name tags were added; extract only the named entities from this tree: - - -``` -print("Recognized named entities:") -for ne in ne_tagged: -    if hasattr(ne, "label"): -        print(ne.label(), ne[0:]) - -[/code] [code] - -Recognized named entities: -PERSON [('Peterson', 'NNP')] -FACILITY [('Palo', 'NNP'), ('Alto', 'NNP')] -GPE [('California', 'NNP')] -``` - -See it graphically: - - -``` -`ne_tagged.draw()` -``` - -![NLTK Treebank tree][13] - -(Girish Managoli, [CC BY-SA 4.0][10]) - -NLTK's built-in named-entity tagger, using PENN's [Automatic Content Extraction][14] (ACE) program, detects common entities such as ORGANIZATION, PERSON, LOCATION, FACILITY, and GPE (geopolitical entity). - -NLTK can use other taggers, such as the [Stanford Named Entity Recognizer][15]. This trained tagger is built in Java, but NLTK provides an interface to work with it (See [nltk.parse.stanford][16] or [nltk.tag.stanford][17]). - -#### Try it yourself - -Using the Python libraries, download Wikipedia's page on [open source][5] and identify people who had an influence on open source and where and when they contributed. - -### Advanced exercise - -If you're ready for it, try building this superstructure using the building blocks discussed in these articles. - -Using Python libraries, download Wikipedia's [Category: Computer science page][18] and: - - * Identify the most-occurring unigrams, bigrams, and trigrams and publish it as a list of keywords or technologies that students and engineers need to be aware of in this domain. - * Show the names, technologies, dates, and places that matter in this field graphically. This can be a nice infographic. - * Create a search engine. Does your search engine perform better than Wikipedia's search? - - - -### What's next? - -NLP is a quintessential pillar in application building. NLTK is a classic, rich, and powerful kit that provides the bricks and mortar to build practically appealing, purposeful applications for the real world. - -In this series of articles, I explained what NLP makes possible using NLTK as an example. NLP and NLTK have a lot more to offer. This series is an inception point to help get you started. - -If your needs grow beyond NLTK's capabilities, you could train new models or add capabilities to it. New NLP libraries that build on NLTK are coming up, and machine learning is being used extensively in language processing. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/8/nlp-python-nltk - -作者:[Girish Managoli][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/gammay -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brain_computer_solve_fix_tool.png?itok=okq8joti (Brain on a computer screen) -[2]: https://opensource.com/article/20/8/intro-python-nltk -[3]: http://www.nltk.org/ -[4]: https://en.wikipedia.org/wiki/WordNet -[5]: https://en.wikipedia.org/wiki/Open_source -[6]: https://www.nltk.org/howto/wordnet.html -[7]: https://en.wikipedia.org/wiki/Category:Lists_of_computer_terms -[8]: https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html -[9]: https://opensource.com/sites/default/files/uploads/nltk-tree.jpg (NLTK Tree) -[10]: https://creativecommons.org/licenses/by-sa/4.0/ -[11]: https://en.wikipedia.org/wiki/Subject_(grammar) -[12]: https://opensource.com/sites/default/files/uploads/nltk-treebank.jpg (NLP Treebank image) -[13]: https://opensource.com/sites/default/files/uploads/nltk-treebank-2a.jpg (NLTK Treebank tree) -[14]: https://www.ldc.upenn.edu/collaborations/past-projects/ace -[15]: https://nlp.stanford.edu/software/CRF-NER.html -[16]: https://www.nltk.org/_modules/nltk/parse/stanford.html -[17]: https://www.nltk.org/_modules/nltk/tag/stanford.html -[18]: https://en.wikipedia.org/wiki/Category:Computer_science diff --git a/sources/tech/20200908 Deploy a deep learning model on Kubernetes.md b/sources/tech/20200908 Deploy a deep learning model on Kubernetes.md index ca6d98438a..2fb0199735 100644 --- a/sources/tech/20200908 Deploy a deep learning model on Kubernetes.md +++ b/sources/tech/20200908 Deploy a deep learning model on Kubernetes.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (chunibyo-wly) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20200914 Use Python to solve a charity-s business problem.md b/sources/tech/20200914 Use Python to solve a charity-s business problem.md deleted file mode 100644 index febc102037..0000000000 --- a/sources/tech/20200914 Use Python to solve a charity-s business problem.md +++ /dev/null @@ -1,215 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Use Python to solve a charity's business problem) -[#]: via: (https://opensource.com/article/20/9/solve-problem-python) -[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen) - -Use Python to solve a charity's business problem -====== -Comparing how different programming languages solve the same problem is -fun and instructive. Next up, Python. -![Python programming language logo with question marks][1] - -In my [first article][2] in this series, I described a problem of dividing bulk supplies into hampers of similar value to distribute to struggling neighbors in your community. I also wrote about how I enjoy solving small problems like this with small programs in various languages and comparing how they do it. - -In the first article, I solved this problem with the [Groovy][3] programming language. Groovy is like [Python][4] in many ways, but syntactically it's more like C and Java. Therefore, it should be interesting and instructive to create the same solution in Python. - -### The Python solution - -In Java, I declare utility classes to hold tuples of data (the new record feature is going to be great for that). In Groovy, I use the language support for maps, and I follow the same approach in Python. - -Use a list of dictionaries to hold the bulk items picked up from the wholesaler: - - -``` -packs = [ -        {'item':'Rice','brand':'Best Family','units':10,'price':5650,'quantity':1}, -        {'item':'Spaghetti','brand':'Best Family','units':1,'price':327,'quantity':10}, -        {'item':'Sardines','brand':'Fresh Caught','units':3,'price':2727,'quantity':3}, -        {'item':'Chickpeas','brand':'Southern Style','units':2,'price':2600,'quantity':5}, -        {'item':'Lentils','brand':'Southern Style','units':2,'price':2378,'quantity':5}, -        {'item':'Vegetable oil','brand':'Crafco','units':12,'price':10020,'quantity':1}, -        {'item':'UHT milk','brand':'Atlantic','units':6,'price':4560,'quantity':2}, -        {'item':'Flour','brand':'Neighbor Mills','units':10,'price':5200,'quantity':1}, -        {'item':'Tomato sauce','brand':'Best Family','units':1,'price':190,'quantity':10}, -        {'item':'Sugar','brand':'Good Price','units':1,'price':565,'quantity':10}, -        {'item':'Tea','brand':'Superior','units':5,'price':2720,'quantity':2}, -        {'item':'Coffee','brand':'Colombia Select','units':2,'price':4180,'quantity':5}, -        {'item':'Tofu','brand':'Gourmet Choice','units':1,'price':1580,'quantity':10}, -        {'item':'Bleach','brand':'Blanchite','units':5,'price':3550,'quantity':2}, -        {'item':'Soap','brand':'Sunny Day','units':6,'price':1794,'quantity':2}] -``` - -There is one bulk pack of 10 bags of rice and 10 bulk packs with one bag each of spaghetti. In the above, the variable `packs` is set to a Python list of dictionaries. This turns out to be very similar to the Groovy approach. A few points worth noting about the difference between Groovy and Python: - - 1. In Python, there is no keyword used to define the variable `packs`; Python expects the first use to set a value. - 2. Python dictionary keys (e.g., `item`, `brand`, `units`, `price`, `quantity`) require quotes to indicate they are strings; Groovy assumes these are strings, but accepts quotes as well. - 3. In Python, the notation `{ … }` indicates a dictionary declaration; Groovy uses the same square brackets as a list, but the structure in both cases must have key-value pairs. - - - -And, yes, those prices aren't in US dollars. - -Next, unpack the bulk packages. Unpacking the single bulk package of rice, for example, will yield 10 units of rice; that is, the total number of units yielded is `units * quantity`. The Groovy script uses a handy function called `collectMany` that can be used to flatten out lists of lists. As far as I know, Python doesn't have anything similar, so use two list comprehensions to produce the same result: - - -``` -units = [[{'item':pack['item'],'brand':pack['brand'], -        'price':(pack['price'] / pack['units'])}] * -        (pack['units'] * pack['quantity']) for pack in packs] -units = [x for sublist in units for x in sublist] -``` - -The first list comprehension (assignment to units) builds the list of lists of dictionaries. The second "flattens" that into just a list of dictionaries. Note that both Python and Groovy provide an `*` operator that takes a list on the left and a number `N` on the right and replicates the list `N` times. - -The final step is to repack the units into the hampers for distribution. As in the Groovy version, you need to get a bit more specific about the ideal hamper value, and you might as well not be overly restrictive when you get down to just a few units left: - - -``` -valueIdeal = 5000 -valueMax = valueIdeal * 1.1 -``` - -OK! Repack the hampers: - - -``` -import random -hamperNumber = 0           # [1] -while len(units) > 0:      # [2] -    hamperNumber += 1 -    hamper = [] -    value = 0 -    canAdd = True              # [2.1] -    while canAdd:              # [2.2] -        u = random.randint(0,len(units)-1)  # [2.2.1] -        canAdd = False                      # [2.2.2] -        o = 0                               # [2.2.3] -        while o < len(units):               # [2.2.4] -            uo = (u + o) % len(units) -            unit = units[uo] -            unitPrice = unit['price']          # [2.2.4.1] -            if len(units) < 3 or not (unit in hamper) and (value + unitPrice) < valueMax: -                                               # [2.2.4.2] -                hamper.append(unit) -                value += unitPrice -                units.pop(u)                   # [2.2.4.3] -                canAdd = len(units) > 0 -                break                          # [2.2.4.4] -            o += 1                             # [2.2.4.5] -                                            # [2.2.5] -    print('') -    print('Hamper',hamperNumber,'value',value) -    for item in hamper: -        print('%-25s%-25s%7.2f' % (item['item'],item['brand'],item['price'])) # [2.3] -    print('Remaining units',len(units))                                       # [2.4] -``` - -Some clarification, with numbers in brackets in the comments above (e.g., _[1]_) corresponding to the clarifications below: - - * 1\. Import Python's random number generator facilities and initialize the hamper number. - * 2\. This `while` loop will redistribute units into hampers as long as there are more available: - * 2.1 Increment the hamper number, get a new empty hamper (a list of units), and set its value to 0; start off assuming you can add more items to the hamper. - * 2.2 This `while` loop will add as many units to the hamper as possible (the Groovy code used a `for` loop, but Python's `for` loops expect to iterate over something, while Groovy has the more traditional C form of `for` loop): - * 2.2.1 Get a random number between zero and the number of remaining units minus 1. - * 2.2.2 Assume you can't find more units to add. - * 2.2.3 Create a variable to be used for the offset from the starting point where you're looking for items to put in the hamper. - * 2.2.4 Starting at the randomly chosen index, this `while` loop will try to find a unit that can be added to the hamper (once again, note that the Python `for` loop probably isn't suitable here since the length of the list will change during processing). - * 2.2.4.1. Figure out which unit to look at (random starting point + offset) and get its price. - * 2.2.4.2 You 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. - * 2.2.4.3 Add the unit to the hamper, increment the hamper value by the unit price, remove the unit from the available units list. - * 2.2.4.4 As long as there are units left, you can add more, so break out of this loop to keep looking. - * 2.2.4.5 Increment the offset. - * 2.2.5 On exit from this `while` loop, if you inspected every remaining unit and could not find one to add to the hamper, the hamper is complete; otherwise, you found one and can continue looking for more. - * 2.3 Print out the contents of the hamper. - * 2.4 Print out the remaining units info. - - - -When you run this code, the output looks quite similar to the output from the Groovy program: - - -``` -Hamper 1 value 5304.0 -UHT milk                 Atlantic                  760.00 -Tomato sauce             Best Family               190.00 -Rice                     Best Family               565.00 -Coffee                   Colombia Select          2090.00 -Sugar                    Good Price                565.00 -Vegetable oil            Crafco                    835.00 -Soap                     Sunny Day                 299.00 -Remaining units 148 - -Hamper 2 value 5428.0 -Tea                      Superior                  544.00 -Lentils                  Southern Style           1189.00 -Flour                    Neighbor Mills            520.00 -Tofu                     Gourmet Choice           1580.00 -Vegetable oil            Crafco                    835.00 -UHT milk                 Atlantic                  760.00 -Remaining units 142 - -Hamper 3 value 5424.0 -Soap                     Sunny Day                 299.00 -Chickpeas                Southern Style           1300.00 -Sardines                 Fresh Caught              909.00 -Rice                     Best Family               565.00 -Vegetable oil            Crafco                    835.00 -Spaghetti                Best Family               327.00 -Lentils                  Southern Style           1189.00 -Remaining units 135 - -… - -Hamper 21 value 5145.0 -Tomato sauce             Best Family               190.00 -Tea                      Superior                  544.00 -Chickpeas                Southern Style           1300.00 -Spaghetti                Best Family               327.00 -UHT milk                 Atlantic                  760.00 -Vegetable oil            Crafco                    835.00 -Lentils                  Southern Style           1189.00 -Remaining units 4 - -Hamper 22 value 2874.0 -Sardines                 Fresh Caught              909.00 -Vegetable oil            Crafco                    835.00 -Rice                     Best Family               565.00 -Rice                     Best Family               565.00 -Remaining units 0 -``` - -The last hamper is abbreviated in contents and value. - -### Closing thoughts - -At a glance, there isn't a whole lot of difference between the Python and Groovy versions of this program. Both have a similar set of constructs that make handling lists and dictionaries very straightforward. Neither requires a lot of "boilerplate code" or other "ceremonial" actions. - -Also, as in the Groovy example, there is some fiddly business about being able to add units to the hamper. Basically, you pick a random position in the list of units and, starting at that position, iterate through the list until you either find a unit whose price allows it to be included or until you exhaust the list. Also, when there are only a few items left, you just toss them into the last hamper. - -Another issue worth mentioning: This isn't a particularly efficient approach. Removing elements from lists, being careless about repeated expressions, and a few other things make this less suitable for a huge redistribution problem. Still, it runs in a blink on my old machine. - -If you are shuddering at my use of `while` loops and mutating the data in this code, you probably wish I made it more functional. I couldn't think of a way to use map and reduce features in Python in conjunction with a random selection of units for repackaging. Can you? - -In the next article, I'll re-do this in Java just to see how much less effort Groovy and Python are, and future articles will cover Julia and Go. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/9/solve-problem-python - -作者:[Chris Hermansen][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/clhermansen -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python_programming_question.png?itok=cOeJW-8r (Python programming language logo with question marks) -[2]: https://opensource.com/article/20/8/solving-problem-groovy -[3]: https://groovy-lang.org/ -[4]: https://www.python.org/ diff --git a/sources/tech/20201012 My top 7 keywords in Rust.md b/sources/tech/20201012 My top 7 keywords in Rust.md deleted file mode 100644 index cca2eeefc1..0000000000 --- a/sources/tech/20201012 My top 7 keywords in Rust.md +++ /dev/null @@ -1,55 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (My top 7 keywords in Rust) -[#]: via: (https://opensource.com/article/20/10/keywords-rust) -[#]: author: (Mike Bursell https://opensource.com/users/mikecamel) - -My top 7 keywords in Rust -====== -Learn a handful of useful keywords from the Rust standard library. -![Rustacean t-shirt][1] - -I've been using [Rust][2] for a few months now, writing rather more of it than I expected—though quite a lot of that has been thrown away as I've learned, improved what I'm writing, and taken some more complex tasks beyond what I originally intended. - -I still love it and thought it might be good to talk about some of the important keywords that come up again and again in Rust. I'll provide my personal summary of what they do, why you need to think about how you use them, and anything else that's useful, particularly for people who are new to Rust or coming from another language (such as Java; see my article [_Why I'm enjoying learning Rust as a Java programmer_][3]). - -Without further ado, let's get going. A good place for further information is always the official Rust documentation—you'll probably want to start with the [std library][4]. - - 1. **const** – You get to declare constants with const, and you should. This isn't rocket science, but do declare with const, and if you're going to use constants across different modules, then do the right thing and create a `lib.rs` file (the Rust default) into which you can put all of them with a nicely named module. I've had clashes of const variable names (and values!) across different files in different modules simply because I was too lazy to do anything other than cut and paste across files when I could have saved myself lots of work simply by creating a shared module. - 2. **let** – You don't _always_ need to declare a variable with a let statement, but your code will be clearer when you do. What's more, always add the type if you can. Rust will do its very best to guess what it should be, but it may not always be able to do so at runtime (in which case [Cargo][5], the compiler, will tell you), or it may even not do what you expect. In the latter case, it's always simpler for Cargo to complain that the function you're assigning from (for instance) doesn't match the declaration than for Rust to try to help you do the wrong thing, only for you to have to spend ages debugging elsewhere. - 3. **match** – match was new to me, and I love it. It's not dissimilar to "switch" in other languages but is used extensively in Rust. It makes for legible code, and Cargo will have a good go at warning you if you do something foolish (such as miss possible cases). My general rule of thumb, where I'm managing different options or doing branching, is to ask whether I can use match. If I can, I will. - 4. **mut** – When declaring a variable, if it's going to change after its initialisation, then you need to declare it mutable. A common mistake is to declare something mutable when it _isn't_ changed—but the compiler will warn you about that. If you get a warning from Cargo that a mutable variable isn't changed when you think it _is_, then you may wish to check the scope of the variable and make sure that you're using the right version. - 5. **return** – I actually very rarely use return, which is for returning a value from a function, because it's usually simpler and clearer to read if you just provide the value (or the function providing the return value) at the end of the function as the last line. Warning: you _will_ forget to omit the semicolon at the end of this line on many occasions; if you do, the compiler won't be happy. - 6. **unsafe** – This does what it says on the tin: If you want to do things where Rust can't guarantee memory safety, then you're going to need to use this keyword. I have absolutely no intention of declaring any of my Rust code unsafe now or at any point in the future; one of the reasons Rust is so friendly is because it stops this sort of hackery. If you really need to do this, think again, think yet again, and then redesign. Unless you're a seriously low-level systems programmer, _avoid_ unsafe. - 7. **use** – When you want to use an item, e.g., struct, variable, function, etc. from another crate, then you need to declare it at the beginning of the block where you'll be using it. Another common mistake is to do this but fail to add the crate (preferably with a minimum version number) to the `Cargo.toml` file. - - - -This isn't the most complicated article I've ever written, I know, but it's the sort of article I would have appreciated when I was starting to learn Rust. I plan to create similar articles on key functions and other Rust must-knows: let me know if you have any requests! - -* * * - -_This article was originally published on [Alice, Eve, and Bob][6] and is reprinted with the author's permission._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/10/keywords-rust - -作者:[Mike Bursell][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/mikecamel -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rustacean-tshirt.jpg?itok=u7LBmyaj (Rustacean t-shirt) -[2]: https://www.rust-lang.org/ -[3]: https://opensource.com/article/20/5/rust-java -[4]: https://doc.rust-lang.org/std/ -[5]: https://doc.rust-lang.org/cargo/ -[6]: https://aliceevebob.com/2020/09/01/rust-my-top-7-keywords/ diff --git a/sources/tech/20201026 7 Git tricks that changed my life.md b/sources/tech/20201026 7 Git tricks that changed my life.md deleted file mode 100644 index e2b14241d4..0000000000 --- a/sources/tech/20201026 7 Git tricks that changed my life.md +++ /dev/null @@ -1,203 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (7 Git tricks that changed my life) -[#]: via: (https://opensource.com/article/20/10/advanced-git-tips) -[#]: author: (Rajeev Bera https://opensource.com/users/acompiler) - -7 Git tricks that changed my life -====== -These helpful tips will change the way you work with the popular version -control system. -![Computer screen with files or windows open][1] - -Git is one of the most common version control systems available, and it's used on private systems and publicly hosted websites for all kinds of development work. Regardless of how proficient with Git I become, it seems there are always features left to discover. Here are seven tricks that have changed the way I work with Git. - -### 1\. Autocorrection in Git - -We all make typos sometimes, but if you have Git's auto-correct feature enabled, you can let Git automatically fix a mistyped subcommand. - -Suppose you want to check the status with `git status` but you type `git stats` by accident. Under normal circumstances, Git tells you that 'stats' is not a valid command: - - -``` -$ git stats -git: ‘stats’ is not a git command. See ‘git --help’. - -The most similar command is -status -``` - -To avoid similar scenarios, enable Git autocorrection in your Git configuration: - - -``` -`$ git config --global help.autocorrect 1` -``` - -If you want this to apply only to your current repository, omit the `--global` option. - -This command enables the autocorrection feature. An in-depth tutorial is available at [Git Docs][2], but trying the same errant command as above gives you a good idea of what this configuration does: - - -``` -$ git stats -git: ‘stats’ is not a git command. See ‘git --help’. -On branch master -Your branch is up to date with ‘origin/master’. - -nothing to commit, working tree clean -``` - -Instead of suggesting an alternative subcommand, Git now just runs the top suggestion, which in this case was **git status**. - -### 2\. Count your commits - -There are many reasons you might need to count your commits. Many developers count the number of commits to judge when to increment the build number, for instance, or just to get a feel for how the project is progressing. - -To count your commits is really easy and straightforward; here is the Git command: - - -``` -`$ git rev-list --count` -``` - -In the above command, the **branch-name** should be a valid branch name in your current repository. - - -``` -$ git rev-list –count master -32 -$ git rev-list –count dev -34 -``` - -### 3\. Optimize your repo - -Your code repository is valuable not only for you but also for your organization. You can keep your repository clean and up to date with a few simple practices. One of the best practices is to [use the .gitignore file][3]. By using this file, you are telling Git not to store many unwanted files like binaries, temporary files, and so on. - -To optimize your repository further, you can use Git garbage collection. - - -``` -`$ git gc --prune=now --aggressive` -``` - -This command helps when you or your team heavily uses **pull** or **push** commands. - -This command is an internal utility that cleans up unreachable or "orphaned" Git objects in your repository. - -### 4\. Take a backup of untracked files - -Most of the time, it's safe to delete all the untracked files. But many times, there is a situation wherein you want to delete, but also to create a backup of your untracked files just in case you need them later. - -Git, along with some Bash command piping, makes it easy to create a zip archive for your untracked files. - - -``` -$ git ls-files --others --exclude-standard -z |\ -xargs -0 tar rvf ~/backup-untracked.zip -``` - -The above command makes an archive (and excludes files listed in .gitignore) with the name backup-untracked.zip - -### 5\. Know your .git folder - -Every repository has a .git folder. It is a special hidden folder. - - -``` -$ ls -a -. … .git -``` - -Git mainly works with two things: - - 1. The working tree (the state of files in your current checkout) - 2. The path of your Git repository (specifically, the location of the .git folder, which contains the versioning information) - - - -This folder stores all references and other important details like configurations, repository data, the state of HEAD, logs, and much more. - -If you delete this folder, the current state of your source code is not deleted, but your remote information, such as your project history, is. Deleting this folder means your project (at least, the local copy) isn't under version control anymore. It means you cannot track your changes; you cannot pull or push from a remote. - -Generally, there's not much you need to do, or should do, in your .git folder. It's managed by Git and is considered mostly off-limits. However, there are some interesting artifacts in this directory, including the current state of HEAD: - - -``` -$ cat .git/HEAD -ref: refs/heads/master -``` - -It also contains, potentially, a description of your repository: - - -``` -`$ cat .git/description` -``` - -This is an unnamed repository; edit this file 'description' to name the repository. - -The Git hooks folder is also here, complete with example hook files. You can read these samples to get an idea of what's possible through Git hooks, and you can also [read this Git hook introduction by Seth Kenlon][4]. - -### 6\. View a file of another branch - -Sometimes you want to view the content of the file from another branch. It's possible with a simple Git command, and without actually switching your branch. - -Suppose you have a file called [README.md][5], and it's in the **main** branch. You're working on a branch called **dev**. - -With the following Git command, you can do it from the terminal. - - -``` -`$ git show main:README.md` -``` - -Once you execute this command, you can view the content of the file in your terminal. - -### 7\. Search in Git - -You can search in Git like a pro with one simple command. Better still, you can search in Git even if you aren't sure which commit—or even branch—you made your changes. - - -``` -`$ git rev-list --all | xargs git grep -F ‘’` -``` - -For example, suppose you want to search for the string "font-size: 52 px;" in your repository: - - -``` -$ git rev-list –all | xargs git grep -F ‘font-size: 52 px;’ -F3022…9e12:HtmlTemplate/style.css: font-size: 52 px; -E9211…8244:RR.Web/Content/style/style.css: font-size: 52 px; -``` - -### Try these tips - -I hope these advanced tips are useful and boost your productivity, saving you lots of time. - -Do you have [Git tips][6] you love? Share them in the comments. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/10/advanced-git-tips - -作者:[Rajeev Bera][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/acompiler -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_screen_windows_files.png?itok=kLTeQUbY (Computer screen with files or windows open) -[2]: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_code_help_autocorrect_code -[3]: https://opensource.com/article/20/8/dont-ignore-gitignore -[4]: https://opensource.com/life/16/8/how-construct-your-own-git-server-part-6 -[5]: http://README.md -[6]: https://acompiler.com/git-tips/ diff --git a/sources/tech/20201105 6 evening rituals for working in tech.md b/sources/tech/20201105 6 evening rituals for working in tech.md deleted file mode 100644 index 6b999b090e..0000000000 --- a/sources/tech/20201105 6 evening rituals for working in tech.md +++ /dev/null @@ -1,49 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (6 evening rituals for working in tech) -[#]: via: (https://opensource.com/article/20/11/evening-rituals-working-tech) -[#]: author: (Jen Wike Huger https://opensource.com/users/jen-wike) - -6 evening rituals for working in tech -====== -After a busy day of virtual meetings, emails, coding, and collaborating, -how do you wind down for the night? -![A farm road][1] - -This strange time has given us, on one hand, the chance to slow down, yet on the other, it's busier than ever. Especially if you have others in your life to care for in addition to yourself. But you can't give from an empty cup, so, this list of evening rituals is focused on what you can do for yourself right after you turn the computer off, shut the laptop, or say goodbye to the last virtual meeting of the day. - -1\. Head to the nearest door and take a big, deep belly breath in... and out. I don't care if it's snowing. Fill your lungs with fresh air. Stay for a while if you can -- take a lap around the yard, or walk down the street and back. - -2\. If you have some time, make a cup of tea -- black (is caffeinated, so beware), green, or herbal -- and, let it cool down while you get your shoes (and maybe a jacket) on. Pop it in a favorite thermos, and take a stroll around your neighborhood. You don't have to have a plan or a place you're walking to. Set a timer for 15 minutes if you only have a short window. - -3\. Turn on a song that pops into your head or the one you didn't get a chance to jam/relax to earlier today. - -4\. If you have some time, stand up and dance it out or lay all the way down with your feet up. No more sitting. Don't think, just listen. Research shows giving your brain blank space helps you think and deal better later. - -5\. Open your [reader app][2] or pick up a book (the latter is easier on your eyes), and fully indulge, letting the day slip away, or give yourself enough time to read at least one chapter. - -6\. Make food that feels good. Maybe that means a few basic ingredients and simple instructions. Maybe that means putting together that new, complex meal you've been excited about since you picked up the items at the grocery store. - -Can you combine some of these to get even more out of your evening ritual time? If you're working in tech, creating rituals like this—whether they're [in the morning][3], middle of your day, or evening—is critical as we live out a new normal working from home, taking meetings virtually, and missing the energy of in-person connections with colleagues.  - -What is your evening ritual? - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/11/evening-rituals-working-tech - -作者:[Jen Wike Huger][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/jen-wike -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDUCATION_jadud_farm-road.png?itok=of8IuSM5 (A farm road) -[2]: https://opensource.com/article/20/2/linux-ebook-readers -[3]: https://opensource.com/article/20/10/tech-morning-rituals diff --git a/sources/tech/20210129 Machine learning made easy with Python.md b/sources/tech/20210129 Machine learning made easy with Python.md deleted file mode 100644 index da6e7f078f..0000000000 --- a/sources/tech/20210129 Machine learning made easy with Python.md +++ /dev/null @@ -1,218 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Machine learning made easy with Python) -[#]: via: (https://opensource.com/article/21/1/machine-learning-python) -[#]: author: (Girish Managoli https://opensource.com/users/gammay) - -Machine learning made easy with Python -====== -Solve real-world machine learning problems with Naïve Bayes classifiers. -![arrows cycle symbol for failing faster][1] - -Naïve Bayes is a classification technique that serves as the basis for implementing several classifier modeling algorithms. Naïve Bayes-based classifiers are considered some of the simplest, fastest, and easiest-to-use machine learning techniques, yet are still effective for real-world applications. - -Naïve Bayes is based on [Bayes' theorem][2], formulated by 18th-century statistician [Thomas Bayes][3]. This theorem assesses the probability that an event will occur based on conditions related to the event. For example, an individual with [Parkinson's disease][4] typically has voice variations; hence such symptoms are considered related to the prediction of a Parkinson's diagnosis. The original Bayes' theorem provides a method to determine the probability of a target event, and the Naïve variant extends and simplifies this method. - -### Solving a real-world problem - -This article demonstrates a Naïve Bayes classifier's capabilities to solve a real-world problem (as opposed to a complete business-grade application). I'll assume you have basic familiarity with machine learning (ML), so some of the steps that are not primarily related to ML prediction, such as data shuffling and splitting, are not covered here. If you are an ML beginner or need a refresher, see _[An introduction to machine learning today][5]_ and _[Getting started with open source machine learning][6]_. - -The Naïve Bayes classifier is [supervised][7], [generative][8], non-linear, [parametric][9], and [probabilistic][10]. - -In this article, I'll demonstrate using Naïve Bayes with the example of predicting a Parkinson's diagnosis. The dataset for this example comes from this [UCI Machine Learning Repository][11]. This data includes several speech signal variations to assess the likelihood of the medical condition; this example will use the first eight of them: - - * **MDVP:Fo(Hz):** Average vocal fundamental frequency - * **MDVP:Fhi(Hz):** Maximum vocal fundamental frequency - * **MDVP:Flo(Hz):** Minimum vocal fundamental frequency - * **MDVP:Jitter(%)**, **MDVP:Jitter(Abs)**, **MDVP:RAP**, **MDVP:PPQ**, and **Jitter:DDP:** Five measures of variation in fundamental frequency - - - -The dataset used in this example, shuffled and split for use, is available in my [GitHub repository][12]. - -### ML with Python - -I'll use Python to implement the solution. The software I used for this application is: - - * Python 3.8.2 - * Pandas 1.1.1 - * scikit-learn 0.22.2.post1 - - - -There are several open source Naïve Bayes classifier implementations available in Python, including: - - * **NLTK Naïve Bayes:** Based on the standard Naïve Bayes algorithm for text classification - * **NLTK Positive Naïve Bayes:** A variant of NLTK Naïve Bayes that performs binary classification with partially labeled training sets - * **Scikit-learn Gaussian Naïve Bayes:** Provides partial fit to support a data stream or very large dataset - * **Scikit-learn Multinomial Naïve Bayes:** Optimized for discrete data features, example counts, or frequency - * **Scikit-learn Bernoulli Naïve Bayes:** Designed for binary/Boolean features - - - -I will use [sklearn Gaussian Naive Bayes][13] for this example. - -Here is my Python implementation of `naive_bayes_parkinsons.py`: - - -``` -import pandas as pd - -# Feature columns we use -x_rows=['MDVP:Fo(Hz)','MDVP:Fhi(Hz)','MDVP:Flo(Hz)', -        'MDVP:Jitter(%)','MDVP:Jitter(Abs)','MDVP:RAP','MDVP:PPQ','Jitter:DDP'] -y_rows=['status'] - -# Train - -# Read train data -train_data = pd.read_csv('parkinsons/Data_Parkinsons_TRAIN.csv') -train_x = train_data[x_rows] -train_y = train_data[y_rows] -print("train_x:\n", train_x) -print("train_y:\n", train_y) - -# Load sklearn Gaussian Naive Bayes and fit -from sklearn.naive_bayes import GaussianNB - -gnb = GaussianNB() -gnb.fit(train_x, train_y) - -# Prediction on train data -predict_train = gnb.predict(train_x) -print('Prediction on train data:', predict_train) - -# Accuray score on train data -from sklearn.metrics import accuracy_score -accuracy_train = accuracy_score(train_y, predict_train) -print('Accuray score on train data:', accuracy_train) - -# Test - -# Read test data -test_data = pd.read_csv('parkinsons/Data_Parkinsons_TEST.csv') -test_x = test_data[x_rows] -test_y = test_data[y_rows] - -# Prediction on test data -predict_test = gnb.predict(test_x) -print('Prediction on test data:', predict_test) - -# Accuracy Score on test data -accuracy_test = accuracy_score(test_y, predict_test) -print('Accuray score on test data:', accuracy_train) -``` - -Run the Python application: - - -``` -$ python naive_bayes_parkinsons.py - -train_x: -      MDVP:Fo(Hz)  MDVP:Fhi(Hz) ...  MDVP:RAP  MDVP:PPQ  Jitter:DDP -0        152.125       161.469  ...   0.00191   0.00226     0.00574 -1        120.080       139.710  ...   0.00180   0.00220     0.00540 -2        122.400       148.650  ...   0.00465   0.00696     0.01394 -3        237.323       243.709  ...   0.00173   0.00159     0.00519 -..           ...           ...           ...  ...       ...       ...         -155      138.190       203.522  ...   0.00406   0.00398     0.01218 - -[156 rows x 8 columns] - -train_y: -      status -0         1 -1         1 -2         1 -3         0 -..      ... -155       1 - -[156 rows x 1 columns] - -Prediction on train data: [1 1 1 0 ... 1] -Accuracy score on train data: 0.6666666666666666 - -Prediction on test data: [1 1 1 1 ... 1 - 1 1] -Accuracy score on test data: 0.6666666666666666 -``` - -The accuracy scores on the train and test sets are 67% in this example; its performance can be optimized. Do you want to give it a try? If so, share your approach in the comments below. - -### Under the hood - -The Naïve Bayes classifier is based on Bayes' rule or theorem, which computes conditional probability, or the likelihood for an event to occur when another related event has occurred. Stated in simple terms, it answers the question: _If we know the probability that event x occurred before event y, then what is the probability that y will occur when x occurs again?_ The rule uses a prior-prediction value that is refined gradually to arrive at a final [posterior][14] value. A fundamental assumption of Bayes is that all parameters are of equal importance. - -At a high level, the steps involved in Bayes' computation are: - - 1. Compute overall posterior probabilities ("Has Parkinson's" and "Doesn't have Parkinson's") - 2. Compute probabilities of posteriors across all values and each possible value of the event - 3. Compute final posterior probability by multiplying the results of #1 and #2 for desired events - - - -Step 2 can be computationally quite arduous. Naïve Bayes simplifies it: - - 1. Compute overall posterior probabilities ("Has Parkinson's" and "Doesn't have Parkinson's") - 2. Compute probabilities of posteriors for desired event values - 3. Compute final posterior probability by multiplying the results of #1 and #2 for desired events - - - -This is a very basic explanation, and several other factors must be considered, such as data types, sparse data, missing data, and more. - -### Hyperparameters - -Naïve Bayes, being a simple and direct algorithm, does not need hyperparameters. However, specific implementations may provide advanced features. For example, [GaussianNB][13] has two: - - * **priors:** Prior probabilities can be specified instead of the algorithm taking the priors from data. - * **var_smoothing:** This provides the ability to consider data-curve variations, which is helpful when the data does not follow a typical Gaussian distribution. - - - -### Loss functions - -Maintaining its philosophy of simplicity, Naïve Bayes uses a [0-1 loss function][15]. If the prediction correctly matches the expected outcome, the loss is 0, and it's 1 otherwise. - -### Pros and cons - -**Pro:** Naïve Bayes is one of the easiest and fastest algorithms. -**Pro:** Naïve Bayes gives reasonable predictions even with less data. -**Con:** Naïve Bayes predictions are estimates, not precise. It favors speed over accuracy. -**Con:** A fundamental Naïve Bayes assumption is the independence of all features, but this may not always be true. - -In essence, Naïve Bayes is an extension of Bayes' theorem. It is one of the simplest and fastest machine learning algorithms, intended for easy and quick training and prediction. Naïve Bayes provides good-enough, reasonably accurate predictions. One of its fundamental assumptions is the independence of prediction features. Several open source implementations are available with traits over and above what are available in the Bayes algorithm. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/1/machine-learning-python - -作者:[Girish Managoli][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/gammay -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fail_progress_cycle_momentum_arrow.png?itok=q-ZFa_Eh (arrows cycle symbol for failing faster) -[2]: https://en.wikipedia.org/wiki/Bayes%27_theorem -[3]: https://en.wikipedia.org/wiki/Thomas_Bayes -[4]: https://en.wikipedia.org/wiki/Parkinson%27s_disease -[5]: https://opensource.com/article/17/9/introduction-machine-learning -[6]: https://opensource.com/business/15/9/getting-started-open-source-machine-learning -[7]: https://en.wikipedia.org/wiki/Supervised_learning -[8]: https://en.wikipedia.org/wiki/Generative_model -[9]: https://en.wikipedia.org/wiki/Parametric_model -[10]: https://en.wikipedia.org/wiki/Probabilistic_classification -[11]: https://archive.ics.uci.edu/ml/datasets/parkinsons -[12]: https://github.com/gammay/Machine-learning-made-easy-Naive-Bayes/tree/main/parkinsons -[13]: https://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.GaussianNB.html -[14]: https://en.wikipedia.org/wiki/Posterior_probability -[15]: https://en.wikipedia.org/wiki/Loss_function#0-1_loss_function diff --git a/sources/tech/20210317 Programming 101- Input and output with Java.md b/sources/tech/20210317 Programming 101- Input and output with Java.md deleted file mode 100644 index 5cd5d1a644..0000000000 --- a/sources/tech/20210317 Programming 101- Input and output with Java.md +++ /dev/null @@ -1,163 +0,0 @@ -[#]: subject: (Programming 101: Input and output with Java) -[#]: via: (https://opensource.com/article/21/3/io-java) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Programming 101: Input and output with Java -====== -Learn how Java handles reading and writing data. -![Coffee beans and a cup of coffee][1] - -When you write a program, your application may need to read from and write to files stored on the user's computer. This is common in situations when you want to load or store configuration options, you need to create log files, or your user wants to save work for later. Every language handles this task a little differently. This article demonstrates how to handle data files with Java. - -### Installing Java - -Regardless of your computer's platform, you can install Java from [AdoptOpenJDK][2]. This site offers safe and open source builds of Java. On Linux, you may also find AdoptOpenJDK builds in your software repository. - -I recommend using the latest long-term support (LTS) release. The latest non-LTS release is best for developers looking to try the latest Java features, but it likely outpaces what most users have installed—either by default on their system or installed previously for some other Java application. Using the LTS release ensures you're up-to-date with what most users have installed. - -Once you have Java installed, open your favorite text editor and get ready to code. You might also want to investigate an [integrated development environment for Java][3]. BlueJ is ideal for new programmers, while Eclipse and Netbeans are nice for intermediate and experienced coders. - -### Reading a file with Java - -Java uses the `File` library to load files. - -This example creates a class called `Ingest` to read data from a file. When you open a file in Java, you create a `Scanner` object, which scans the file you provide, line by line. In fact, a `Scanner` is the same concept as a cursor in a text editor, and you can control that "cursor" for reading and writing with `Scanner` methods like `nextLine`: - - -``` -import java.io.File; -import java.util.Scanner; -import java.io.FileNotFoundException; - -public class Ingest { -  public static void main([String][4][] args) { -    -      try { -          [File][5] myFile = new [File][5]("example.txt"); -          Scanner myScanner = new Scanner(myFile); -          while (myScanner.hasNextLine()) { -              [String][4] line = myScanner.nextLine(); -              [System][6].out.println(line); -          } -          myScanner.close(); -      } catch ([FileNotFoundException][7] ex) { -          ex.printStackTrace();   -      } //try -    } //main -} //class -``` - -This code creates the variable `myfile` under the assumption that a file named `example.txt` exists. If that file does not exist, Java "throws an exception" (this means it found an error in what you attempted to do and says so), which is "caught" by the very specific `FileNotFoundException` library. The fact that there's a library specific to this exact error betrays how common this error is. - -Next, it creates a `Scanner` and loads the file into it. I call it `myScanner` to differentiate it from its generic class template. A `while` loop sends `myScanner` over the file, line by line, for as long as there _is_ a next line. That's what the `hasNextLine` method does: it detects whether there's any data after the "cursor." You can simulate this by opening a file in a text editor: Your cursor starts at the very beginning of the file, and you can use the keyboard to scan through the file with the cursor until you run out of lines. - -The `while` loop creates a variable `line` and assigns it the data of the current line. Then it prints the contents of `line` just to provide feedback. A more useful program would probably parse each line to extract whatever important data it contains. - -At the end of the process, the `myScanner` object closes. - -### Running the code - -Save your code as `Ingest.java` (it's a Java convention to give classes an initial capital letter and name the file to match). If you try to run this simple application, you will probably receive an error because there is no `example.txt` for the application to load yet: - - -``` -$ java ./Ingest.java -java.io.[FileNotFoundException][7]: -example.txt (No such file or directory) -``` - -What a perfect opportunity to write a Java application that writes data to a file! - -### Writing data to a file with Java - -Whether you're storing data that your user creates with your application or just metadata about what a user did in an application (for instance, game saves or recent songs played), there are lots of good reasons to store data for later use. In Java, this is achieved through the `FileWriter` library, this time by opening a file, writing data into it, and then closing the file: - - -``` -import java.io.FileWriter; -import java.io.IOException; - -public class Exgest { -  public static void main([String][4][] args) { -    try { -        [FileWriter][8] myFileWriter = new [FileWriter][8]("example.txt", true); -        myFileWriter.write("Hello world\n"); -        myFileWriter.close(); -    } catch ([IOException][9] ex) { -        [System][6].out.println(ex); -    } // try -  } // main -} -``` - -The logic and flow of this class are similar to reading a file. Instead of a `Scanner`, it creates a `FileWriter` object with the name of a file. The `true` flag at the end of the `FileWriter` statement tells `FileWriter` to _append_ text to the end of the file. To overwrite a file's contents, remove the `true`: - - -``` -`FileWriter myFileWriter = new FileWriter("example.txt", true);` -``` - -Because I'm writing plain text into a file, I added my own newline character (`\n`) at the end of the data (`Hello world`) written into the file. - -### Trying the code - -Save this code as `Exgest.java`, following the Java convention of naming the file to match the class name. - -Now that you have the means to create and read data with Java, you can try your new applications, in reverse order: - - -``` -$ java ./Exgest.java -$ java ./Ingest.java -Hello world -$ -``` - -Because it appends data to the end, you can repeat your application to write data as many times as you want to add more data to your file: - - -``` -$ java ./Exgest.java -$ java ./Exgest.java -$ java ./Exgest.java -$ java ./Ingest.java -Hello world -Hello world -Hello world -$ -``` - -### Java and data - -You're don't write raw text into a file very often; in the real world, you probably use an additional library to write a specific format instead. For instance, you might use an XML library to write complex data, an INI or YAML library to write configuration files, or any number of specialized libraries to write binary formats like images or audio. - -For full information, refer to the [OpenJDK documentation][10]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/3/io-java - -作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/seth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/java-coffee-mug.jpg?itok=Bj6rQo8r (Coffee beans and a cup of coffee) -[2]: https://adoptopenjdk.net -[3]: https://opensource.com/article/20/7/ide-java -[4]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string -[5]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+file -[6]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system -[7]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+filenotfoundexception -[8]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+filewriter -[9]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+ioexception -[10]: https://access.redhat.com/documentation/en-us/openjdk/11/ diff --git a/sources/tech/20210414 3 essential Linux cheat sheets for productivity.md b/sources/tech/20210414 3 essential Linux cheat sheets for productivity.md deleted file mode 100644 index 0456fb5d85..0000000000 --- a/sources/tech/20210414 3 essential Linux cheat sheets for productivity.md +++ /dev/null @@ -1,123 +0,0 @@ -[#]: subject: (3 essential Linux cheat sheets for productivity) -[#]: via: (https://opensource.com/article/21/4/linux-cheat-sheets) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -3 essential Linux cheat sheets for productivity -====== -Download cheat sheets for sed, grep, and parted to integrate new -processes into your work. -![Hand putting a Linux file folder into a drawer][1] - -Linux is famous for its commands. This is partially because nearly everything that Linux does can also be invoked from a terminal, but it's also that Linux as an operating system is highly modular. Its tools are designed to produce fairly specific results, and when you know a lot about a few commands, you can combine them in interesting ways for useful output. Learning Linux is equal parts learning commands and learning how to string those commands together in interesting combinations. - -With so many Linux commands to learn, though, taking the first step can seem daunting. What command should you learn first? Which commands should you learn well, and which commands require only a passing familiarity? I've thought about these questions a lot, and I'm not convinced there's a universal answer. The "basic" commands are probably the same for anyone: - - * `ls` - * `cd` - * `mv` - - - -These amount to being able to navigate your Linux file system. - -Beyond the basics, though, the "default" commands vary from industry to industry. Sysadmins need tools for [system introspection and monitoring][2]. Artists need tools for [media conversion][3] and [graphic processing][4]. Home users might want tools for [PDF processing][5], or [calendaring][6], or [document conversion][7]. The list goes on and on. - -However, some Linux commands stand out as being particularly important—either because they're common low-level tools that everyone needs on occasion or they're all-purpose tools that anyone might find useful most of the time. - -Here are three to add to your list. - -### Sed - -**Purpose:** The `sed` command is a good, all-purpose tool that any Linux user can benefit from knowing. On the surface, it's just a terminal-based "find and replace." That makes it great for quick and easy corrections across multiple documents. The `sed` command has saved me hours (or possibly cumulative days) of opening individual files, searching and replacing a word, saving the file, and closing the file. It alone justifies my investment in learning the Linux terminal. Once you get to know `sed` well, you're likely to discover a whole world of potential editing tricks that make your life easier. - -**Strength:** The command's strength is in repetition. If you have just one file to edit, it's easy to open it and do a "find and replace" in a traditional [text editor][8]. However, when you're faced with five or 50 files, a good `sed` command (maybe combined with [GNU Parallel][9] for extra speed) can reclaim hours of your day. - -**Weakness:** You have to balance the time you expect to spend making a change with how long it may take you to construct the right `sed` command. Simple edits with the common `sed 's/foo/bar/g` syntax are almost always worth the trivial amount of time it takes to type the command, but complex `sed` commands that utilize a hold space and any of the `ed` style subcommands can take serious concentration combined with several rounds of trial and error. It can be, as it turns out, better to do some edits the new-fashioned way. - -**Cheat:** Download our [sed cheat sheet][10] for quick reference to its single-letter subcommands and an overview of its syntax. - -### Grep - -**Purpose:** The `grep` command comes from its admittedly clunky description: global regular expression print. In other words, `grep` prints to the terminal any matching pattern it finds in files (or other forms of input). That makes it a great search tool, especially adept at scrubbing through vast amounts of text. - -You might use it to find URLs: - - -``` -$ grep --only-matching \ -http\:\/\/.* example.txt -``` - -You could use it to find a specific config option: - - -``` -$ grep --line-number \ -foo= example.ini -2:foo=true -``` - -And of course, you can combine it with other commands: - - -``` -$ grep foo= example.ini | cut -d= -f2 -true -``` - -**Strength:** The `grep` command is a straightforward search command. If you've read the few examples above, then you've essentially learned the command. For even more flexibility, you can use its extended regular expression syntax. - -**Weakness:** The problem with `grep` is also one of its strengths: It's just a search function. Once you've found what you're looking for, you might be faced with the larger question of what to do with it. Sometimes the answer is as easy as redirecting the output to a file, which becomes your filtered list of results. However, more complex use cases mean further processing with any number of commands like [awk][11], [curl][12] (incidentally, [we have a cheat sheet for curl][13], too), or any of the thousands of other options you have on a modern computer. - -**Cheat:** Download our [grep cheat sheet][14] for a quick reference to its many options and regex syntax. - -### Parted - -**Purpose:** GNU `parted` isn't a daily-use command for most people, but it is one of the most powerful tools for hard-drive manipulation. The frustrating thing about hard drives is that you spend years ignoring them until you get a new one and have to set it up for your computer. It's only then that you remember that you have no idea how to best format your drive. That's when familiarity with `parted` can be useful. GNU `parted` can create disk labels and create, back up, and rescue partitions. In addition, it can provide you with lots of information about a drive and its layout and generally prepare a drive for a filesystem. - -**Strength:** The reason I love `parted` over `fdisk` and similar tools is for its combination of an easy interactive mode and its fully noninteractive option. Regardless of how you choose to use `parted`, its commands follow a consistent syntax, and its help menus are well-written and informative. Better still, the command itself is _smart_. When partitioning a drive, you can specify sizes in anything from sectors to percentages, and `parted` does its best to figure out the finer points of partition table placement. - -**Weakness:** It took me a long while to learn GNU `parted` after switching to Linux because, for a very long time, I didn't have a good understanding of how drives actually work. GNU `parted` and most terminal-based drive utilities assume you know what a partition is, that drives have sectors and need disk labels and partition tables that initially lack filesystems, and so on. There's a steep learning curve—not to the command so much as to the foundations of hard-drive technology, and GNU `parted` doesn't do much to bridge the potential gap. It's arguably not the command's job to step you through the process because there are [graphical applications][15] for that, but a workflow-focused option for GNU `parted` could be an interesting addition to the utility. - -**Cheat:** Download our [parted cheat sheet][16] for a quick reference to its many subcommands and options. - -### Learn more - -These are some of my favorite commands, but the list is naturally biased to how I use my computer. I do a lot of shell scripting, so I make heavy use of `grep` to find configuration options, I use `sed` for text editing, and I use `parted` because when I'm working on multimedia projects, there are usually a lot of hard drives involved. You either already have, or you'll soon develop, your own workflows with your own favorite (or at least _frequent_) commands. - -When I'm integrating new processes into my daily work, I create or download a cheat sheet (like the ones linked above), and then I practice. We all learn in our own way, though, so find what works best for you, and learn a new essential command. The more you learn about your most frequent commands, the more you can make them work harder for you. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/4/linux-cheat-sheets - -作者:[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/yearbook-haff-rx-linux-file-lead_0.png?itok=-i0NNfDC (Hand putting a Linux file folder into a drawer) -[2]: https://opensource.com/life/16/2/open-source-tools-system-monitoring -[3]: https://opensource.com/article/17/6/ffmpeg-convert-media-file-formats -[4]: https://opensource.com/article/17/8/imagemagick -[5]: https://opensource.com/article/20/8/reduce-pdf -[6]: https://opensource.com/article/19/4/calendar-git -[7]: https://opensource.com/article/20/5/pandoc-cheat-sheet -[8]: https://opensource.com/article/21/2/open-source-text-editors -[9]: https://opensource.com/article/18/5/gnu-parallel -[10]: https://opensource.com/downloads/sed-cheat-sheet -[11]: https://opensource.com/article/20/9/awk-ebook -[12]: https://www.redhat.com/sysadmin/social-media-curl -[13]: https://opensource.com/article/20/5/curl-cheat-sheet -[14]: https://opensource.com/downloads/grep-cheat-sheet -[15]: https://opensource.com/article/18/11/partition-format-drive-linux#gui -[16]: https://opensource.com/downloads/parted-cheat-sheet diff --git a/sources/tech/20210428 Share files between Linux and Windows computers.md b/sources/tech/20210428 Share files between Linux and Windows computers.md index 1a0de1a9fa..8ba6282397 100644 --- a/sources/tech/20210428 Share files between Linux and Windows computers.md +++ b/sources/tech/20210428 Share files between Linux and Windows computers.md @@ -2,7 +2,7 @@ [#]: via: (https://opensource.com/article/21/4/share-files-linux-windows) [#]: author: (Stephan Avenwedde https://opensource.com/users/hansic99) [#]: collector: (lujun9972) -[#]: translator: (wyxplus) +[#]: translator: ( ) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20210511 What is fog computing.md b/sources/tech/20210511 What is fog computing.md index 17f5772340..7d1f54ee22 100644 --- a/sources/tech/20210511 What is fog computing.md +++ b/sources/tech/20210511 What is fog computing.md @@ -2,7 +2,7 @@ [#]: via: (https://opensource.com/article/21/5/fog-computing) [#]: author: (Seth Kenlon https://opensource.com/users/seth) [#]: collector: (lujun9972) -[#]: translator: (Gordon-Deng) +[#]: translator: ( ) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20210517 How to look at the stack with gdb.md b/sources/tech/20210517 How to look at the stack with gdb.md deleted file mode 100644 index 90d3f8a8ea..0000000000 --- a/sources/tech/20210517 How to look at the stack with gdb.md +++ /dev/null @@ -1,392 +0,0 @@ -[#]: subject: (How to look at the stack with gdb) -[#]: via: (https://jvns.ca/blog/2021/05/17/how-to-look-at-the-stack-in-gdb/) -[#]: author: (Julia Evans https://jvns.ca/) -[#]: collector: (lujun9972) -[#]: translator: (amwps290) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -How to look at the stack with gdb -====== - -I was chatting with someone yesterday and they mentioned that they don’t really understand exactly how the stack works or how to look at it. - -So here’s a quick walkthrough of how you can use gdb to look at the stack of a C program. I think this would be similar for a Rust program, but I’m going to use C because I find it a little simpler for a toy example and also you can do Terrible Things in C more easily. - -### our test program - -Here’s a simple C program that declares a few variables and reads two strings from standard input. One of the strings is on the heap, and one is on the stack. - -``` -#include -#include - -int main() { - char stack_string[10] = "stack"; - int x = 10; - char *heap_string; - - heap_string = malloc(50); - - printf("Enter a string for the stack: "); - gets(stack_string); - printf("Enter a string for the heap: "); - gets(heap_string); - printf("Stack string is: %s\n", stack_string); - printf("Heap string is: %s\n", heap_string); - printf("x is: %d\n", x); -} -``` - -This program uses the extremely unsafe function `gets` which you should never use, but that’s on purpose – we learn more when things go wrong. - -### step 0: compile the program. - -We can compile it with `gcc -g -O0 test.c -o test`. - -The `-g` flag compiles the program with debugging symbols, which is going to make it a lot easier to look at our variables. - -`-O0` tells gcc to turn off optimizations which I did just to make sure our `x` variable didn’t get optimized out. - -### step 1: start gdb - -We can start gdb like this: - -``` -$ gdb ./test -``` - -It prints out some stuff about the GPL and then gives a prompt. Let’s create a breakpoint on the `main` function. - -``` -(gdb) b main -``` - -Then we can run the program: - -``` -(gdb) b main -Starting program: /home/bork/work/homepage/test -Breakpoint 1, 0x000055555555516d in main () - -(gdb) run -Starting program: /home/bork/work/homepage/test - -Breakpoint 1, main () at test.c:4 -4 int main() { -``` - -Okay, great! The program is running and we can start looking at the stack - -### step 2: look at our variables’ addresses - -Let’s start out by learning about our variables. Each of them has an address in memory, which we can print out like this: - -``` -(gdb) p &x -$3 = (int *) 0x7fffffffe27c -(gdb) p &heap_string -$2 = (char **) 0x7fffffffe280 -(gdb) p &stack_string -$4 = (char (*)[10]) 0x7fffffffe28e -``` - -So if we look at the stack at those addresses, we should be able to see all of these variables! - -### concept: the stack pointer - -We’re going to need to use the stack pointer so I’ll try to explain it really quickly. - -There’s an x86 register called ESP called the “stack pointer”. Basically it’s the address of the start of the stack for the current function. In gdb you can access it with `$sp`. When you call a new function or return from a function, the value of the stack pointer changes. - -### step 3: look at our variables on the stack at the beginning of `main` - -First, let’s look at the stack at the start of the `main` function. Here’s the value of our stack pointer right now: - -``` -(gdb) p $sp -$7 = (void *) 0x7fffffffe270 -``` - -So the stack for our current function starts at `0x7fffffffe270`. Cool. - -Now let’s use gdb to print out the first 40 words (aka 160 bytes) of memory after the start of the current function’s stack. It’s possible that some of this memory isn’t part of the stack because I’m not totally sure how big the stack is here. But at least the beginning of this is part of the stack. - -``` -(gdb) x/40x $sp -0x7fffffffe270: 0x00000000 0x00000000 0x55555250 0x00005555 -0x7fffffffe280: 0x00000000 0x00000000 0x55555070 0x00005555 -0x7fffffffe290: 0xffffe390 0x00007fff 0x00000000 0x00000000 -0x7fffffffe2a0: 0x00000000 0x00000000 0xf7df4b25 0x00007fff -0x7fffffffe2b0: 0xffffe398 0x00007fff 0xf7fca000 0x00000001 -0x7fffffffe2c0: 0x55555169 0x00005555 0xffffe6f9 0x00007fff -0x7fffffffe2d0: 0x55555250 0x00005555 0x3cae816d 0x8acc2837 -0x7fffffffe2e0: 0x55555070 0x00005555 0x00000000 0x00000000 -0x7fffffffe2f0: 0x00000000 0x00000000 0x00000000 0x00000000 -0x7fffffffe300: 0xf9ce816d 0x7533d7c8 0xa91a816d 0x7533c789 -``` - -I’ve bolded approximately where the `stack_string`, `heap_string`, and `x` variables are and colour coded them: - - * `x` is red and starts at `0x7fffffffe27c` - * `heap_string` is blue and starts at `0x7fffffffe280` - * `stack_string` is purple and starts at `0x7fffffffe28e` - - - -I think I might have bolded the location of some of those variables a bit wrong here but that’s approximately where they are. - -One weird thing you might notice here is that `x` is the number `0x5555`, but we set `x` to 10! That because `x` doesn’t actually get set until after our `main` function starts, and we’re at the very beginning of `main`. - -### step 3: look at the stack again on line 10 - -Let’s skip a few lines and wait for our variables to actually get set to the values we initialized them to. By the time we get to line 10, `x` should be set to 10. - -First, we need to set another breakpoint: - -``` -(gdb) b test.c:10 -Breakpoint 2 at 0x5555555551a9: file test.c, line 11. -``` - -and continue the program running: - -``` -(gdb) continue -Continuing. - -Breakpoint 2, main () at test.c:11 -11 printf("Enter a string for the stack: "); -``` - -Okay! Let’s look at all the same things again! `gdb` is formatting the bytes in a slightly different way here and I don’t actually know why. Here’s a reminder of where to find our variables on the stack: - - * `x` is red and starts at `0x7fffffffe27c` - * `heap_string` is blue and starts at `0x7fffffffe280` - * `stack_string` is purple and starts at `0x7fffffffe28e` - - - -``` -(gdb) x/80x $sp -0x7fffffffe270: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 -0x7fffffffe278: 0x50 0x52 0x55 0x55 0x0a 0x00 0x00 0x00 -0x7fffffffe280: 0xa0 0x92 0x55 0x55 0x55 0x55 0x00 0x00 -0x7fffffffe288: 0x70 0x50 0x55 0x55 0x55 0x55 0x73 0x74 -0x7fffffffe290: 0x61 0x63 0x6b 0x00 0x00 0x00 0x00 0x00 -0x7fffffffe298: 0x00 0x80 0xf7 0x8a 0x8a 0xbb 0x58 0xb6 -0x7fffffffe2a0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 -0x7fffffffe2a8: 0x25 0x4b 0xdf 0xf7 0xff 0x7f 0x00 0x00 -0x7fffffffe2b0: 0x98 0xe3 0xff 0xff 0xff 0x7f 0x00 0x00 -0x7fffffffe2b8: 0x00 0xa0 0xfc 0xf7 0x01 0x00 0x00 0x00 -``` - -There are a couple of interesting things to discuss here before we go further in the program. - -### how `stack_string` is represented in memory - -Right now (on line 10) `stack_string` is set to “stack”. Let’s take a look at how that’s represented in memory. - -We can print out the bytes in the string like this: - -``` -(gdb) x/10x stack_string -0x7fffffffe28e: 0x73 0x74 0x61 0x63 0x6b 0x00 0x00 0x00 -0x7fffffffe296: 0x00 0x00 -``` - -The string “stack” is 5 characters which corresponds to 5 ASCII bytes – `0x73`, `0x74`, `0x61`, `0x63`, and `0x6b`. `0x73` is `s` in ASCII, `0x74` is `t`, etc. - -We can also get gdb to show us the string with `x/1s`: - -``` -(gdb) x/1s stack_string -0x7fffffffe28e: "stack" -``` - -### how `heap_string` and `stack_string` are different - -You’ll notice that `stack_string` and `heap_string` are represented in very different ways on the stack: - - * `stack_string` has the contents of the string (“stack”) - * `heap_string` is a pointer to an address somewhere else in memory - - - -Here are the bytes on the stack for the `heap_string` variable: - -``` -0xa0 0x92 0x55 0x55 0x55 0x55 0x00 0x00 -``` - -These bytes actually get read backwards because x86 is little-endian, so the memory address of `heap_string` is `0x5555555592a0` - -Another way to see the address of `heap_string` in gdb is just to print it out with `p`: - -``` -(gdb) p heap_string -$6 = 0x5555555592a0 "" -``` - -### the bytes that represent the integer `x` - -`x` is a 32-bit integer, and the bytes that represent it are `0x0a 0x00 0x00 0x00`. - -We need to read these bytes backwards again (the same way reason we read the bytes for `heap_string` address backwards), so this corresponds to the number `0x000000000a`, or `0xa`, which is 10. - -That makes sense! We set `int x = 10;`! - -### step 4: read input from standard input - -Okay, we’ve initialized the variables, now let’s see how the stack changes when this part of the C program runs: - -``` -printf("Enter a string for the stack: "); -gets(stack_string); -printf("Enter a string for the heap: "); -gets(heap_string); -``` - -We need to set another breakpoint: - -``` -(gdb) b test.c:16 -Breakpoint 3 at 0x555555555205: file test.c, line 16. -``` - -and continue running the program - -``` -(gdb) continue -Continuing. -``` - -We’re prompted for 2 strings, and I entered `123456789012` for the stack string and `bananas` for the heap. - -### let’s look at `stack_string` first (there’s a buffer overflow!) - -``` -(gdb) x/1s stack_string -0x7fffffffe28e: "123456789012" -``` - -That seems pretty normal, right? We entered `123456789012` and now it’s set to `123456789012`. - -But there’s something weird about this. Here’s what those bytes look like on the stack. They’re highlighted in purple again. - -``` -0x7fffffffe270: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 -0x7fffffffe278: 0x50 0x52 0x55 0x55 0x0a 0x00 0x00 0x00 -0x7fffffffe280: 0xa0 0x92 0x55 0x55 0x55 0x55 0x00 0x00 -0x7fffffffe288: 0x70 0x50 0x55 0x55 0x55 0x55 0x31 0x32 -0x7fffffffe290: 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 -0x7fffffffe298: 0x31 0x32 0x00 0x8a 0x8a 0xbb 0x58 0xb6 -0x7fffffffe2a0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 -0x7fffffffe2a8: 0x25 0x4b 0xdf 0xf7 0xff 0x7f 0x00 0x00 -0x7fffffffe2b0: 0x98 0xe3 0xff 0xff 0xff 0x7f 0x00 0x00 -0x7fffffffe2b8: 0x00 0xa0 0xfc 0xf7 0x01 0x00 0x00 0x00 -``` - -The weird thing about this is that **stack_string was only supposed to be 10 bytes**. But now suddenly we’ve put 13 bytes in it? What’s happening? - -This is a classic buffer overflow, and what’s happening is that `stack_string` wrote over other data from the program. This hasn’t caused a problem yet in our case, but it can crash your program or, worse, open you up to Very Bad Security Problems. - -For example, if `stack_string` were before `heap_string` in memory, then we could overwrite the address that `heap_string` points to. I’m not sure exactly what’s in memory after `stack_string` here but we could probably use this to do some kind of shenanigans. - -### something actually detects the buffer overflow - -When I cause this buffer overflow problem, here’s - -``` - ./test -Enter a string for the stack: 01234567891324143 -Enter a string for the heap: adsf -Stack string is: 01234567891324143 -Heap string is: adsf -x is: 10 -*** stack smashing detected ***: terminated -fish: Job 1, './test' terminated by signal SIGABRT (Abort) -``` - -My guess about what’s happening here is that the `stack_string` variable is actually at the end of this function’s stack, and so the extra bytes are going into a different region of memory. - -When you do this intentionally as a security exploit it’s called “stack smashing”, and somehow something is detecting that this is happening. I’m not totally sure how this is being detected. - -I also thing this is interesting because the program gets killed, but it doesn’t get killed immediately when the buffer overflow happens – a few more lines of code run after the buffer overflow and the program gets killed later. Weird! - -That’s all I have to say about buffer overflows. - -### now let’s look at `heap_string` - -We also read a value (`bananas`) into the `heap_string` variable. Let’s see what that looks like in memory. - -Here’s what `heap_string` looks on the stack after we read the variable in. - -``` -(gdb) x/40x $sp -0x7fffffffe270: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 -0x7fffffffe278: 0x50 0x52 0x55 0x55 0x0a 0x00 0x00 0x00 -0x7fffffffe280: 0xa0 0x92 0x55 0x55 0x55 0x55 0x00 0x00 -0x7fffffffe288: 0x70 0x50 0x55 0x55 0x55 0x55 0x31 0x32 -0x7fffffffe290: 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 -``` - -The thing to notice here is that it looks exactly the same! It’s an address, and the address hasn’t changed. But let’s look at what’s at that address. - -``` -(gdb) x/10x 0x5555555592a0 -0x5555555592a0: 0x62 0x61 0x6e 0x61 0x6e 0x61 0x73 0x00 -0x5555555592a8: 0x00 0x00 -``` - -Those are the bytes for `bananas`! Those bytes aren’t in the stack at all, they’re somewhere else in memory (on the heap) - -### where are the stack and the heap? - -We’ve talked about how the stack and the heap are different regions of memory, but how can you tell where they are in memory? - -There’s a file for each process called `/proc/$PID/maps` that shows you the memory maps for each process. Here’s where you can see the stack and the heap in there. - -``` -$ cat /proc/24963/maps -... lots of stuff omitted ... -555555559000-55555557a000 rw-p 00000000 00:00 0 [heap] -... lots of stuff omitted ... -7ffffffde000-7ffffffff000 rw-p 00000000 00:00 0 [stack] -``` - -One thing to notice is that here the heap addresses start with `0x5555` and the stack addresses start with `0x7fffff`. So it’s pretty easy to tell the difference between an address on the stack and an address on the heap. - -### playing about with gdb like this is really helpful - -This was kind of a whirlwind tour and I didn’t explain everything, but hopefully seeing what the data actually looks like in memory makes it a little more clear what the stack actually is. - -I really recommend playing around with gdb like this – even if you don’t understand every single thing that you see in memory, I find that actually seeing the data in my program’s memory like this makes these abstract concepts like “the stack” and “the heap” and “pointers” a lot easier to understand. - -### ideas for more exercises - -A few ideas (in no particular order) for followup exercises to think about the stack: - - * try adding another function to `test.c` and make a breakpoint at the beginning of that function and see if you can find the stack from `main`! They say that “the stack grows down” when you call a function, can you see that happening in gdb? - * return a pointer from a function to a string on the stack and see what goes wrong. Why is it bad to return a pointer to a string on the stack? - * try causing a stack overflow in C and try to understand exactly what happens when the stack overflows by looking at it in gdb! - * look at the stack in a Rust program and try to find the variables! - * try some of the buffer overflow challenges in the [nightmare course][1]. The README for each challenge is the solution so avoid reading it if you don’t want to be spoiled. The idea with all of those challenges is that you’re given a binary and you need to figure out how to cause a buffer overflow to get it to print out the “flag” string. - - - --------------------------------------------------------------------------------- - -via: https://jvns.ca/blog/2021/05/17/how-to-look-at-the-stack-in-gdb/ - -作者:[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://github.com/guyinatuxedo/nightmare diff --git a/sources/tech/20210517 Use open source tools to set up a private VPN.md b/sources/tech/20210517 Use open source tools to set up a private VPN.md deleted file mode 100644 index dcf18a65bc..0000000000 --- a/sources/tech/20210517 Use open source tools to set up a private VPN.md +++ /dev/null @@ -1,230 +0,0 @@ -[#]: subject: (Use open source tools to set up a private VPN) -[#]: via: (https://opensource.com/article/21/5/open-source-private-vpn) -[#]: author: (Lukas Janėnas https://opensource.com/users/lukasjan) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Use open source tools to set up a private VPN -====== -Use OpenWRT and Wireguard to create your own virtual private network on -your router. -![scrabble letters used to spell "VPN"][1] - -Getting from one place to another over a computer network can be a tricky thing. Aside from knowing the right address and opening the right ports, there's the question of security. For Linux, SSH is a popular default, and while there's a lot you can do with SSH it's still "just" a secure shell (that's what SSH stands for, in fact.) A broader protocol for encrypted traffic is VPN, which creates a unique, virtual private network between two points. With it, you can log in to a computer on another network and use all of its services (file shares, printers, and so on) just as if you were physically sitting in the same room, and every bit of data is encrypted from point to point. - -Normally, in order to make a VPN connection possible, the gateways into each network must accept VPN traffic, and some computer on your target network must be listening for VPN traffic. However, it's possible to run your own router firmware that runs a VPN server, enabling you to connect to your target network without having to worry about forwarding ports or thinking at all about internal topography. My favorite firmware is OpenWrt, and in this article I demonstrate how to set it up, and how to enable VPN on it. - -### What is OpenWrt? - -[OpenWrt][2] is an open source project that uses Linux to target embedded devices. It's been around for more than 15 years and has a large and active community. - -There are many ways to use OpenWrt, but its main purpose is in routers. It provides a fully writable filesystem with package management, and because it is open source, you can see and modify the code and contribute to the ecosystem. If you would like to have more control over your router, this is the system you want to use. - -OpenWrt supports many routers, including famous brands such as [Cisco][3], [ASUS][4], [MikroTik][5], [Teltonika Networks][6], [D-Link][7], [TP-link][8], [Buffalo][9], [Ubiquiti][10], and [many others][11]. - -### What is Wireguard? - -[Wireguard][12] is open source virtual private network (VPN) software that is much faster, simpler, and more secure than other options such as OpenVPN. It uses state-of-the-art cryptography: ChaCha20 for symmetric cryptography; Curve 25519 (which uses elliptic curves) for key agreement; and BLAKE2 for hashing. These algorithms are designed in a way that is efficient on embedded systems. WIreguard is also available on a wide variety of operating system [platforms][13]. - -### Prerequisites - -For this project, you will need: - - * [Teltonika RUT955][14] or another router supported by OpenWrt - * A public IP address to connect to your VPN from outside your network - * An Android phone - - - -### Install OpenWrt - -To get started, download the OpenWrt image for your router. Use the [firmware selector][15] to check if OpenWrt supports your router and download the firmware. Enter your router's model, and it will show your options: - -![OpenWRT firmware selector][16] - -(Lukas Janenas, [CC BY-SA 4.0][17]) - -Select the firmware version you want to download by using the drop-down input on the right side of the search box. - -Download the factory image. - -![Downloading the Factory Image][18] - -(Lukas Janenas, [CC BY-SA 4.0][17]) - -Many routers allow you to flash unauthorized firmware from the web interface, but Teltonika Networks does not. To flash the OpenWrt firmware to a router like this, you need to use the bootloader. To do so, follow these steps: - - 1. Unplug the router's power cable. - 2. Press and hold the Reset button. - 3. Plug in the router's power cable. - 4. Continue holding the reset button for 5 to 8 seconds after you plug the power cable in. - 5. Set computer's IP address to `192.168.1.15` and the netmask to `255.255.255.0`. - 6. Connect the router and your computer with an Ethernet cable over a LAN port. - 7. Open a web browser and enter `192.168.1.1:/index.html`. - 8. Upload and flash the firmware. - - - -The flashing process can take up to three minutes. Afterward, you should be able to reach the router's web interface by entering `192.168.1.1` in a browser. There is no password set by default. - -![OpenWrt authorization][19] - -(Lukas Janenas, [CC BY-SA 4.0][17]) - -### Configure network connectivity - -Network connectivity is a requirement. If your Internet service provider (ISP) assigns your IP address automatically using DHCP, you just need to plug your Ethernet cable into the WAN port of your router. - -If you need to assign the IP address manually, navigate to **Network → Interfaces**. Select **Edit** to edit your WAN interface. From the **Protocol** field, select **Static address**, and select **Switch protocol**. - -![Assigning IP address manually][20] - -(Lukas Janenas, [CC BY-SA 4.0][17]) - -In the **IPv4 address** field, enter your router's address. Set **IPv4 netmask** to match your network subnet; enter the **IPv4 gateway** address you will use to connect to the network; and enter the DNS server's address in the **Use custom DNS servers** field. Save the configuration. - -That's it! You have successfully configured your WAN interface to get network connectivity. - -### Install the necessary packages - -The firmware doesn't include many packages by default, but OpenWrt has a package manager with a selection of packages you can install. Navigate to **System → Software** and update your package manager by selecting **Update lists…** - -![OpenWrt package manager][21] - -(Lukas Janenas, [CC BY-SA 4.0][17]) - -In the Filter input, type **Wireguard**, and wait until the system finds all the packages that include this keyword. Find and install the package named **luci-app-wireguard**. - -![luci-app-wireguard package][22] - -(Lukas Janenas, [CC BY-SA 4.0][17]) - -This package includes a web interface to configure Wireguard and installs all the dependencies necessary for Wireguard to work. - -If you get a warning that a package is missing and can't be found in the repositories before installing the Wireguard package, just ignore it and proceed. - -Next, find and install the package named **luci-app-ttyd**. This will be used to access the terminal later. - -After these packages are installed, reboot your router for the changes to take effect. - -### Configure the Wireguard interface - -Next, create the Wireguard interface. Navigate to **Network → Interfaces** and select **Add new interface…** on the bottom-left. In the pop-up window, enter your desired name for the interface, choose **Wireguard VPN** from the drop-down list, and select **Create interface** on the lower-right. - -![Creating Wireguard interface][23] - -(Lukas Janenas, [CC BY-SA 4.0][17]) - -In the new pop-up window, select **Generate Key** to generate a private key for the Wireguard interface. In the **Listen Port** field, enter your desired port. I will use the default Wireguard port, **51820**. In the **IP Addresses** field, assign the IP address which will be used for the Wireguard interface. In this example, I use `10.0.0.1/24`. The number **24** indicates the size of my subnet. - -![Creating Wireguard interface][24] - -(Lukas Janenas, [CC BY-SA 4.0][17]) - -Save the configuration and restart the interface. - -Navigate to **Services → Terminal**, log into the shell, and enter the command `wg show`. You will see some information about your Wiregaurd interface, including its public key. Copy down the public key—you will need it to create peers later. - -![Wireguard public key][25] - -(Lukas Janenas, [CC BY-SA 4.0][17]) - -### Configure the firewall - -Navigate to **Network → Firewall** and select the **Traffic Rules** tab. On the bottom of the page, select **Add**. In the **Name** field of the pop-up window, give your rule a name, e.g., **Allow-wg**. Next, change the **Destination zone** from **Lan** to **Device**, and set the **Destination port** to 51820. - -![Wireguard firewall setup][26] - -(Lukas Janenas, [CC BY-SA 4.0][17]) - -Save the configuration. - -### Configure Wireguard on an Android phone - -Install the [Wireguard app][27] on your phone from Google Play. Once it's installed, open the app and create a new interface from scratch. In the **Name** field, enter the name you want to use for your interface. In the **Private key** field, press the double-arrow icon on the right to generate a key pair. You will need the public key from above to create a peer between your phone and router. In the **Addresses** field, assign the IP address you will use to reach the phone over VPN. I will use `10.0.0.2/24`. In **Listen port**, enter a port; I will again use the default port. - -![Setting up VPN interface on Android][28] - -(Lukas Janenas, [CC BY-SA 4.0][17]) - -Save the configuration. - -To add a peer to the configuration, select **Add peer**. In the **Public key** field, enter your router's Wireguard public key. In the **Endpoint** field, enter your router's public IP address and port separated by a colon, e.g., `12.34.56.78:51820`. In the **Allowed IP**s field, enter the IP addresses you want to reach through the Wireguard interface. (You can enter your router's VPN interface IP address and LAN interface address.) The IP addresses must be separated by commas. You can also define the size of the subnet. - -![Adding a VPN peer on an Android][29] - -(Lukas Janenas, [CC BY-SA 4.0][17]) - -Save the configuration. - -There's one last step left in the configuration: adding a peer on the router. - -### Add a peer on the router - -Navigate to **Network → Interfaces** and select your Wireguard interface. Go to the **Peers** tab and select **Add peer**. In the **Description** field, enter the peer's name. In the **Public Key** field, enter your phone's Wireguard interface public key, and in the **Allowed IPs** field, enter your phone's Wireguard interface IP address. Check the **Route Allowed IPs** checkbox. - -![Adding a peer on the router][30] - -(Lukas Janenas, [CC BY-SA 4.0][17]) - -Save the configuration and restart the interface. - -### Test the configuration - -Open a web browser on your phone. In the URL bar, enter the IP address `10.0.0.1` or `192.168.1.1`. You should be able to reach your router's website. - -![Logging into the VPN from Android][31] - -(Lukas Janenas, [CC BY-SA 4.0][17]) - -### Your very own VPN - -There are lots of VPN services being advertised these days, but there's a lot to be said for owning and controlling your own infrastructure, especially when that infrastructure only exists to boost security. There's no need to rely on somebody else to provide you with a secure connection to your data. Using OpenWrt and Wireguard, you can have your own open source VPN solution. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/5/open-source-private-vpn - -作者:[Lukas Janėnas][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/lukasjan -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/vpn_scrabble_networking.jpg?itok=pdsUHw5N (scrabble letters used to spell "VPN") -[2]: https://openwrt.org/ -[3]: https://www.cisco.com/c/en/us/products/routers/index.html -[4]: https://www.asus.com/Networking-IoT-Servers/WiFi-Routers/All-series/ -[5]: https://mikrotik.com/ -[6]: https://teltonika-networks.com/ -[7]: https://www.dlink.com/en/consumer -[8]: https://www.tp-link.com/us/ -[9]: https://www.buffalotech.com/products/category/wireless-networking -[10]: https://www.ui.com/ -[11]: https://openwrt.org/toh/views/toh_fwdownload -[12]: https://www.wireguard.com/ -[13]: https://www.wireguard.com/install/ -[14]: https://teltonika-networks.com/product/rut955/ -[15]: https://firmware-selector.openwrt.org/ -[16]: https://opensource.com/sites/default/files/uploads/openwrt_firmware-selector.png (OpenWRT firmware selector) -[17]: https://creativecommons.org/licenses/by-sa/4.0/ -[18]: https://opensource.com/sites/default/files/uploads/downloadfactoryimage.png (Downloading the Factory Image) -[19]: https://opensource.com/sites/default/files/uploads/openwrt_authorization.png (OpenWrt authorization) -[20]: https://opensource.com/sites/default/files/uploads/openwrt_staticaddress.png (Assigning IP address manually) -[21]: https://opensource.com/sites/default/files/uploads/openwrt_update-lists.png (OpenWrt package manager) -[22]: https://opensource.com/sites/default/files/uploads/wireguard-package.png (luci-app-wireguard package) -[23]: https://opensource.com/sites/default/files/uploads/wireguard_createinterface.png (Creating Wireguard interface) -[24]: https://opensource.com/sites/default/files/uploads/wireguard_createinterface2.png (Creating Wireguard interface) -[25]: https://opensource.com/sites/default/files/uploads/wireguard_publickey.png (Wireguard public key) -[26]: https://opensource.com/sites/default/files/uploads/wireguard-firewallsetup.png (Wireguard firewall setup) -[27]: https://play.google.com/store/apps/details?id=com.wireguard.android&hl=lt&gl=US -[28]: https://opensource.com/sites/default/files/uploads/vpn_inferfacesetup.png (Setting up VPN interface on Android) -[29]: https://opensource.com/sites/default/files/uploads/addpeeronphone.png (Adding a VPN peer on an Android) -[30]: https://opensource.com/sites/default/files/uploads/addpeeronrouter.png (Adding a peer on the router) -[31]: https://opensource.com/sites/default/files/uploads/android-vpn-login.png (Logging into the VPN from Android) diff --git a/sources/tech/20210518 Manage your Raspberry Pi with Cockpit.md b/sources/tech/20210518 Manage your Raspberry Pi with Cockpit.md deleted file mode 100644 index cfcdf7fee9..0000000000 --- a/sources/tech/20210518 Manage your Raspberry Pi with Cockpit.md +++ /dev/null @@ -1,164 +0,0 @@ -[#]: subject: (Manage your Raspberry Pi with Cockpit) -[#]: via: (https://opensource.com/article/21/5/raspberry-pi-cockpit) -[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss) -[#]: collector: (lujun9972) -[#]: translator: (ShuyRoy) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Manage your Raspberry Pi with Cockpit -====== -Establish central control over your Raspberry Pis with Cockpit. -![Neon colorized Raspberry Pi cluster with LEGOs][1] - -Last year, I wrote about using [Cockpit to manage my Linux servers][2]. It is a web-based tool that gives you a clean, powerful interface for managing multiple servers and their associated services and applications. It also eases regular day-to-day administrative tasks. - -In this article, I'll describe how to install the Cockpit web console for Linux servers on the Raspberry Pi operating system (OS), the standard OS provided by the Raspberry Pi Foundation. I'll also provide brief descriptions of its features. - -### Installing Cockpit on Raspberry Pi OS - -Log into your Raspberry Pi system using secure shell (SSH) using an account with sudo privileges. Set up an account if you haven't already done so: - - -``` -$ ssh pibox -alan@pibox's password: -Linux pibox.someplace.org 5.10.17-v7+ #1403 SMP Mon Feb 22 11:29:51 GMT 2021 armv7l - -The programs included with the Debian GNU/Linux system are free software; -the exact distribution terms for each program are described in the -individual files in /usr/share/doc/*/copyright. - -Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent -permitted by applicable law. -Last login: Tue May  4 09:55:57 2021 from 172.1.4.5 -alan@pibox:~ $ -``` - -The command to install the Cockpit web console is as simple on Raspberry Pi OS as it is on Linux servers: - - -``` -`$ sudo apt install cockpit` -``` - -Cockpit only requires 60.4 kB of disk space. Together with its several package dependencies, total usage is 115MB. - -The installation process will take care of setting up and starting the services. You can verify the status by using the `systemctl` command: - - -``` -$ systemctl status cockpit.socket -● cockpit.socket - Cockpit Web Service Socket -   Loaded: loaded (/lib/systemd/system/cockpit.socket; enabled; vendor preset: enabled) -   Active: active (listening) since Tue 2021-05-04 10:24:43 EDT; 35s ago -     Docs: man:cockpit-ws(8) -   Listen: 0.0.0.0:9090 (Stream) -  Process: 6563 ExecStartPost=/usr/share/cockpit/motd/update-motd  localhost (code=exited, status=0/SUCCESS) -  Process: 6570 ExecStartPost=/bin/ln -snf active.motd /run/cockpit/motd (code=exited, status=0/SUCCESS) -    Tasks: 0 (limit: 2181) -   CGroup: /system.slice/cockpit.socket -``` - -### Using Cockpit - -#### Connecting - -The default listening port is 9090. Open your favorite web browser and enter the address, e.g., `https://pibox:9090`. - -![Cockpit home page][3] - -(Alan Formy-Duval, [CC BY-SA 4.0][4]) - -You can now log in with your regular user account. Again, it is helpful to have sudo privileges on this account—most likely the same one you use to SSH and run Apt. Be sure to check the box for "Reuse my password for privileged tasks". - -#### Managing your Pi - -Cockpit's initial screen starts with **System** and will provide details and graphs of current CPU and memory usage. - -![Initial Cockpit screen][5] - -(Alan Formy-Duval, [CC BY-SA 4.0][4]) - -You can view hardware details from this screen. - -![Cockpit hardware details][6] - -(Alan Formy-Duval, [CC BY-SA 4.0][4]) - -Explore the column on the left by clicking each item (e.g., Logs, Storage, Services, etc.). These are the standard Cockpit sections and are fairly self explanatory. Let me quickly describe each. - -#### Logs - -This section shows the logs. They can be filtered by date and severity. - -#### Storage - -The storage section shows the physical drives and RAID devices that are installed. Details such as size and serial number are shown. Graphs for read/write activity and actual space usage are displayed. Storage specific logs are presented at the bottom. - -#### Networking - -This section displays send and recieve activity, IP addresses, and network specific logs. You can also add more networking devices; such as bonds, bridges, and VLANs using the respective buttons. - -#### Accounts - -Existing accounts are shown here. Click each to manage or use the _Create New Account_ button to add users. Accounts can be deleted here also. - -#### Services - -This section allows the administrator to view the status of all of the system services. Clicking any service takes you to a screen with the standard tasks of start, restart, and disable. - -#### Applications - -Normally, this screen provides various applications for managing functions such as the 389 Directory Server or creation of Podman containers. On my Raspberry OS though, this screen only displayed the message, "No applications installed or available". At the time of writing, perhaps this has not yet been implemented. Although, you do have to wonder whether these types of processes would be too heavy for the Raspberry PI hardware. - -#### Software Updates - -Keeping software up to date is one of the most important tasks for any system administrator. Cockpit's Software Updates section checks and applies updates. - -![Software updates in Cockpit][7] - -(Alan Formy-Duval, [CC BY-SA 4.0][4]) - -#### Terminal - -One of Cockpit's neatest features is the terminal. You can use it instead of opening a separate terminal emulator and using SSH. I used the terminal to install [ScreenFetch][8]: - - -``` -`$ sudo apt install screenfetch` -``` - -And I used ScreenFetch to produce this screenshot: - -![Terminal in Cockpit][9] - -(Alan Formy-Duval, [CC BY-SA 4.0][4]) - -### Centralized control with Cockpit - -Cockpit behaves on Raspberry Pi just like it does on any other Linux system. You can add it to a dashboard for centralized control. It allows organizations to integrate Raspberry Pi-based services and systems into their overall Linux infrastructure anywhere Cockpit is used as a management dashboard solution. This is highly convenient, given that Pis are often run headless in high-density racked data centers that generally lack KVM access. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/5/raspberry-pi-cockpit - -作者:[Alan Formy-Duval][a] -选题:[lujun9972][b] -译者:[RiaXu](https://github.com/ShuyRoy) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/alanfdoss -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberrypi_kuberenetes_cluster_lead2_0.jpeg?itok=kx0Zc0NK (Neon colorized Raspberry Pi cluster with LEGOs) -[2]: https://opensource.com/article/20/11/cockpit-server-management -[3]: https://opensource.com/sites/default/files/uploads/cockpit_homepage.png (Cockpit home page) -[4]: https://creativecommons.org/licenses/by-sa/4.0/ -[5]: https://opensource.com/sites/default/files/uploads/cockpit_initialscreen.png (Initial Cockpit screen) -[6]: https://opensource.com/sites/default/files/uploads/hardware_details.png (Cockpit hardware details) -[7]: https://opensource.com/sites/default/files/uploads/software_updates.png (Software updates in Cockpit) -[8]: https://opensource.com/article/20/1/screenfetch-neofetch -[9]: https://opensource.com/sites/default/files/uploads/pi_cockpit_terminal.png (Terminal in Cockpit) diff --git a/sources/tech/20210522 Run your favorite Windows applications on Linux.md b/sources/tech/20210522 Run your favorite Windows applications on Linux.md index 7005f98805..b2bdeb221a 100644 --- a/sources/tech/20210522 Run your favorite Windows applications on Linux.md +++ b/sources/tech/20210522 Run your favorite Windows applications on Linux.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: (hongsofwing) +[#]: translator: ( ) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20210523 3 reasons to learn Java in 2021.md b/sources/tech/20210523 3 reasons to learn Java in 2021.md deleted file mode 100644 index a2b7e388cb..0000000000 --- a/sources/tech/20210523 3 reasons to learn Java in 2021.md +++ /dev/null @@ -1,88 +0,0 @@ -[#]: subject: (3 reasons to learn Java in 2021) -[#]: via: (https://opensource.com/article/21/5/java) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) -[#]: collector: (lujun9972) -[#]: translator: (PearFL) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -3 reasons to learn Java in 2021 -====== -Java is powerful, diverse, scalable, and fun. Here's why—and how—you -should be using it. -![Learning and studying technology is the key to success][1] - -Java was released in 1995, making it 26 years old as I'm writing this. It was proprietary at first, but in 2007, Java was released as open source under the GPL. To understand what makes Java important, you have to understand the problem it claims to solve. Then you can understand why and how it benefits developers and users. - -The best way to understand what Java solves is to develop software, but just using software is a good start, too. As a developer, your troubles are likely to begin when you send software that works perfectly on your own computer to some other computer; it probably won't work. It _should_ work, but as any programmer knows, something always gets overlooked. This is compounded when you try the software on another operating system (OS). It's why there are so many download buttons on any given software site: a button for Windows, for macOS, for Linux, for mobiles, and sometimes even more. - -As a user, a typical scenario is you want to download some great software but find it's not available for your platform. It seems a pity that such a thing still happens on computers so advanced that they can run virtualized computers within computers, keep old video games alive through emulation, and even fit in your pocket, but software delivery is actually pretty difficult. - -Is there a better way? Probably. - -### 1\. Write once, run everywhere - -Code is surprisingly, maybe even disappointingly, specific to OS and architecture. Code has to be _compiled_ from a human-friendly programming language into machine language, a series of binary instructions derived from what a CPU is designed to respond to. It feels arcane in the world of advanced computers that we can't just write code and send it to anyone who wants to run it without worrying about what platform they're on. - -Java is the solution to this incongruity. It's the realization of cross-platform code that works the same across any system you run it on. Java's approach to achieving this feat is counterintuitive at first. In a way, Java isn't compatible with anything but one computer. Stranger still, this computer doesn't actually exist. The computer that Java code targets is the Java Virtual Machine (JVM). This is a program written by Java's creators and distributed for practically any computing device you can think of. As long as you have it installed, any Java code you run is handled by this "imaginary" computer living inside your computer. Java code is executed by the JVM, which sends appropriate platform-specific instructions to your computer, so everything works the same on every OS and architecture. - -Of course, the method used by Java isn't really the selling point here. Most users and many developers don't care how software compatibility is achieved, only that it happens. Many languages promise cross-platform functionality, and usually, that promise is ultimately true, but the journey isn't always easy. Programming languages must be compiled for their target platforms, scripting languages require platform-specific interpreters, and it's rare that either can ensure consistent access to low-level system resources. Cross-platform support is getting better and better, with libraries to help with translating paths and environment variables and settings, and some frameworks (notably [Qt][2]) do much to bridge the gap for peripheral access. But Java has it and delivers it consistently and reliably. - -### 2\. Sensible code - -Java's syntax is boring in the best of ways. If you took all the popular programming languages and put them in a rock tumbler, Java is what you'd get. Looking at source code written in Java, you more or less see the average of all the unique expressions of programming. Brackets indicate the scope of functions and flow control, variables are clearly declared and instantiated before being used, and there's a clear and consistent structure to expressions. - -I've found that learning Java often encourages self-taught programmers using less structured languages to write smarter code. There are lots of "basic" programming lessons you can't learn by gleaning techniques from source code you study online, such as keeping global variable declarations together in the style of Java's public fields, properly anticipating and handling exceptions, using classes and functions, and more. Little touches borrowed from Java can make a big difference. - -### 3\. Scaffolding and support - -All the popular programming languages have great support systems in place. It's what makes popular languages popular. They all have lots of libraries; there are integrated development environments (IDEs) or IDE extensions for them, example code, free and paid training, and communities of developers. On the other hand, no programming language seems to have quite enough support when you get stuck trying to make something work. - -I can't claim that Java can differentiate itself from these two universal but contradictory truths. Still, I have found that when I need a library for Java, I inevitably find not just one but several options for a given task. Often I don't want to use a library because I don't like how its developer chose to implement the functions I need, its license is a little different from what I prefer, or any other trivial point of contention. When there's bountiful support for a language, I have the luxury of being very selective. I get to choose one—among many perfectly suitable solutions—that will best achieve any requirement, however trivial. - -Better yet, there's a healthy infrastructure around Java. Tools like [Apache Ant][3], [Gradle][4], and [Maven][5] help you manage your build and delivery process. Services like [Sonatype Nexus][6] help you monitor security. [Spring][7] and [Grails][8] make it easy to develop for the web, while [Quarkus][9] and [Eclipse Che][10] help with cloud development. - -You can even choose what to use when approaching the Java language itself. [OpenJDK][11] provides classic, official Java, while [Groovy][12] is a simplified approach that resembles a scripting language (you might compare it to Python), and [Quarkus][13] provides a framework for container-first development. - -There's a lot more, but suffice it to say that Java is a complete package regardless of what you're looking for. - -### Bonus: Easy to learn - -Java has proven to be a sensible solution for me and many developers in various industries. Here are some of the reasons I love to use Java. - -You may have heard or inferred that Java is a "professional" language for clunky government sites and reserved for "real" developers. Don't be fooled by the many different reputations Java has garnered over its 25+ years! It's only half as terrifying as its reputation, meaning no more than any other language. - -Programming is hard; there's no getting away from that. It requires you to think logically, it forces you to learn a new language with fewer expressive options than your native tongue, and it demands that you figure out how to solve problems that are difficult enough that they've driven you to programmatic automation. No language alleviates these issues. - -However, learning curves for programming languages can differ in surprising ways. Some are easy to start but get complex when you start exploring the fine details. In other words, it might take just one line of code to print "hello world," but once you learn about classes or functions, you get to learn the language (or at least its data model) all over again. Java is Java from the beginning, but once you learn it, you have access to all of its many tricks and conveniences. - -In short: Go learn Java! It's powerful, diverse, scalable, and fun. To help you on your way, [download our Java cheat sheet][14], which contains all the basic syntax you'll need as you work on your first dozen projects. After that, you won't need it anymore because Java is wonderfully consistent and predictable. Enjoy! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/5/java - -作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/seth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/studying-books-java-couch-education.png?itok=C9gasCXr (Learning and studying technology is the key to success) -[2]: http://qt.io -[3]: https://ant.apache.org/ -[4]: https://gradle.org -[5]: https://spring.io/guides/gs/maven -[6]: https://www.sonatype.com/products/repository-pro -[7]: http://spring.io -[8]: https://grails.org -[9]: https://opensource.com/article/21/4/quarkus-tutorial -[10]: https://opensource.com/article/19/10/cloud-ide-che -[11]: http://adoptopenjdk.net -[12]: https://opensource.com/article/20/12/groovy -[13]: https://developers.redhat.com/products/quarkus/getting-started -[14]: https://opensource.com/downloads/java-cheat-sheet diff --git a/sources/tech/20210525 Pen testing with Linux security tools.md b/sources/tech/20210525 Pen testing with Linux security tools.md deleted file mode 100644 index 22780bd71b..0000000000 --- a/sources/tech/20210525 Pen testing with Linux security tools.md +++ /dev/null @@ -1,295 +0,0 @@ -[#]: subject: (Pen testing with Linux security tools) -[#]: via: (https://opensource.com/article/21/5/linux-security-tools) -[#]: author: (Peter Gervase https://opensource.com/users/pgervase) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Pen testing with Linux security tools -====== -Use Kali Linux and other open source tools to uncover security gaps and -weaknesses in your systems. -![Magnifying glass on code][1] - -The multitude of well-publicized breaches of large consumer corporations underscores the critical importance of system security management. Fortunately, there are many different applications that help secure computer systems. One is [Kali][2], a Linux distribution developed for security and penetration testing. This article demonstrates how to use Kali Linux to investigate your system to find weaknesses. - -Kali installs a lot of tools, all of which are open source, and having them installed by default makes things easier. - -![Kali's tools][3] - -(Peter Gervase, [CC BY-SA 4.0][4]) - -The systems that I'll use in this tutorial are: - - 1. `kali.usersys.redhat.com`: This is the system where I'll launch the scans and attacks. It has 30GB of memory and six virtualized CPUs (vCPUs). - 2. `vulnerable.usersys.redhat.com`: This is a Red Hat Enterprise Linux 8 system that will be the target. It has 16GB of memory and six vCPUs. This is a relatively up-to-date system, but some packages might be out of date. - 3. This system also includes `httpd-2.4.37-30.module+el8.3.0+7001+0766b9e7.x86_64`, `mariadb-server-10.3.27-3.module+el8.3.0+8972+5e3224e9.x86_64`, `tigervnc-server-1.9.0-15.el8_1.x86_64`, `vsftpd-3.0.3-32.el8.x86_64`, and WordPress version 5.6.1. - - - -I included the hardware specifications above because some of these tasks are pretty demanding, especially for the target system's CPU when running the WordPress Security Scanner ([WPScan][5]). - -### Investigate your system - -I started my investigation with a basic Nmap scan on my target system. (You can dive deeper into Nmap by reading [Using Nmap results to help harden Linux systems][6].) An Nmap scan is a quick way to get an overview of which ports and services are visible from the system initiating the Nmap scan. - -![Nmap scan][7] - -(Peter Gervase, [CC BY-SA 4.0][4]) - -This default scan shows that there are several possibly interesting open ports. In reality, any open port is possibly interesting because it could be a way for an attacker to breach your network. In this example, ports 21, 22, 80, and 443 are nice to scan because they are commonly used services. At this early stage, I'm simply doing reconnaissance work and trying to get as much information about the target system as I can. - -I want to investigate port 80 with Nmap, so I use the `-p 80` argument to look at port 80 and `-A` to get information such as the operating system and application version. - -![Nmap scan of port 80][8] - -(Peter Gervase, [CC BY-SA 4.0][4]) - -Some of the key lines in this output are: - - -``` -PORT   STATE SERVICE VERSION -80/tcp open  http       Apache httpd 2.4.37 ((Red Hat Enterprise Linux)) -|_http-generator: WordPress 5.6.1 -``` - -Since I now know this is a WordPress server, I can use WPScan to get information about potential weaknesses. A good investigation to run is to try to find some usernames. Using `--enumerate u` tells WPScan to look for users in the WordPress instance. For example: - - -``` -┌──(root💀kali)-[~] -└─# wpscan --url vulnerable.usersys.redhat.com --enumerate u -_______________________________________________________________ -        __              _______   _____ -        \ \     / /  __ \ / ____| -        \ \  /\  / /| |__) | (___   ___  __ _ _ __ ® -        \ \/  \/ / |  ___/ \\___ \ / __|/ _` | '_ \ -                \  /\  /  | |   ____) | (__| (_| | | | | -                \/  \/   |_|    |_____/ \\___|\\__,_|_| |_| - -        WordPress Security Scanner by the WPScan Team -                        Version 3.8.10 -        Sponsored by Automattic - -        @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart -_______________________________________________________________ - -[+] URL: [10.19.47.242] -[+] Started: Tue Feb 16 21:38:49 2021 - -Interesting Finding(s): -... -[i] User(s) Identified: - -[+] admin - | Found By: Author Posts - Display Name (Passive Detection) - | Confirmed By: - |  Author Id Brute Forcing - Author Pattern (Aggressive Detection) - |  Login Error Messages (Aggressive Detection) - -[+] pgervase - | Found By: Author Posts - Display Name (Passive Detection) - | Confirmed By: - |  Author Id Brute Forcing - Author Pattern (Aggressive Detection) - |  Login Error Messages (Aggressive Detection) -``` - -This shows there are two users: `admin` and `pgervase`. I'll try to guess the password for `admin` by using a password dictionary, which is a text file with lots of possible passwords. The dictionary I used was 37G and had 3,543,076,137 lines. - -Like there are multiple text editors, web browsers, and other applications you can choose from, there are multiple tools available to launch password attacks. Here are two example commands using Nmap and WPScan: - - -``` -`# nmap -sV --script http-wordpress-brute --script-args userdb=users.txt,passdb=/path/to/passworddb,threads=6 vulnerable.usersys.redhat.com`[/code] [code]`# wpscan --url vulnerable.usersys.redhat.com --passwords /path/to/passworddb --usernames admin --max-threads 50 | tee nmap.txt` -``` - -This Nmap script is one of many possible scripts I could have used, and scanning the URL with WPScan is just one of many possible tasks this tool can do. You can decide which you would prefer to use - -This WPScan example shows the password at the end of the file: - - -``` -┌──(root💀kali)-[~] -└─# wpscan --url vulnerable.usersys.redhat.com --passwords passwords.txt --usernames admin -_______________________________________________________________ -        __              _______   _____ -        \ \     / /  __ \ / ____| -        \ \  /\  / /| |__) | (___   ___  __ _ _ __ ® -        \ \/  \/ / |  ___/ \\___ \ / __|/ _` | '_ \ -                \  /\  /  | |   ____) | (__| (_| | | | | -                \/  \/   |_|    |_____/ \\___|\\__,_|_| |_| - -        WordPress Security Scanner by the WPScan Team -                        Version 3.8.10 -        Sponsored by Automattic - -        @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart -_______________________________________________________________ - -[+] URL: [10.19.47.242] -[+] Started: Thu Feb 18 20:32:13 2021 - -Interesting Finding(s): - -….. - -[+] Performing password attack on Wp Login against 1 user/s -Trying admin / redhat Time: 00:01:57 <==================================================================================================================> (3231 / 3231) 100.00% Time: 00:01:57 -Trying admin / redhat Time: 00:01:57 <=========================================================                                                         > (3231 / 6462) 50.00%  ETA: ??:??:?? -[SUCCESS] - admin / redhat                                                                                                                                                                       - -[!] Valid Combinations Found: - | Username: admin, Password: redhat - -[!] No WPVulnDB API Token given, as a result vulnerability data has not been output. -[!] You can get a free API token with 50 daily requests by registering at - -[+] Finished: Thu Feb 18 20:34:15 2021 -[+] Requests Done: 3255 -[+] Cached Requests: 34 -[+] Data Sent: 1.066 MB -[+] Data Received: 24.513 MB -[+] Memory used: 264.023 MB -[+] Elapsed time: 00:02:02 -``` - -The Valid Combinations Found section near the end contains the admin username and password. It took only two minutes to go through 3,231 lines. - -I have another dictionary file with 3,238,659,984 unique entries, which would take much longer and leave a lot more evidence. - -Using Nmap produces a result much faster: - - -``` -┌──(root💀kali)-[~] -└─# nmap -sV --script http-wordpress-brute --script-args userdb=users.txt,passdb=password.txt,threads=6 vulnerable.usersys.redhat.com -Starting Nmap 7.91 ( ) at 2021-02-18 20:48 EST -Nmap scan report for vulnerable.usersys.redhat.com (10.19.47.242) -Host is up (0.00015s latency). -Not shown: 995 closed ports -PORT    STATE SERVICE VERSION -21/tcp   open  ftp      vsftpd 3.0.3 -22/tcp   open  ssh      OpenSSH 8.0 (protocol 2.0) -80/tcp   open  http     Apache httpd 2.4.37 ((Red Hat Enterprise Linux)) -|_http-server-header: Apache/2.4.37 (Red Hat Enterprise Linux) -| http-wordpress-brute: -|   Accounts: -|       admin:redhat - Valid credentials              <<<<<<< -|       pgervase:redhat - Valid credentials         <<<<<<< -|_  Statistics: Performed 6 guesses in 1 seconds, average tps: 6.0 -111/tcp  open  rpcbind 2-4 (RPC #100000) -| rpcinfo: -|   program version     port/proto  service -|   100000  2,3,4       111/tcp   rpcbind -|   100000  2,3,4       111/udp   rpcbind -|   100000  3,4         111/tcp6  rpcbind -|_  100000  3,4         111/udp6  rpcbind -3306/tcp open  mysql   MySQL 5.5.5-10.3.27-MariaDB -MAC Address: 52:54:00:8C:A1:C0 (QEMU virtual NIC) -Service Info: OS: Unix - -Service detection performed. Please report any incorrect results at . -Nmap done: 1 IP address (1 host up) scanned in 7.68 seconds -``` - -However, running a scan like this can leave a flood of HTTPD logging messages on the target system: - - -``` -10.19.47.170 - - [18/Feb/2021:20:14:01 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "" "WPScan v3.8.10 ()" -10.19.47.170 - - [18/Feb/2021:20:14:00 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "" "WPScan v3.8.10 ()" -10.19.47.170 - - [18/Feb/2021:20:14:00 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "" "WPScan v3.8.10 ()" -10.19.47.170 - - [18/Feb/2021:20:14:00 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "" "WPScan v3.8.10 ()" -10.19.47.170 - - [18/Feb/2021:20:14:00 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "" "WPScan v3.8.10 ()" -10.19.47.170 - - [18/Feb/2021:20:14:00 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "" "WPScan v3.8.10 ()" -10.19.47.170 - - [18/Feb/2021:20:14:02 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "" "WPScan v3.8.10 ()" -10.19.47.170 - - [18/Feb/2021:20:14:02 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "" "WPScan v3.8.10 ()" -10.19.47.170 - - [18/Feb/2021:20:14:02 -0500] "POST /wp-login.php HTTP/1.1" 200 7575 "" "WPScan v3.8.10 ()" -``` - -To get information about the HTTPS server found in my initial Nmap scan, I used the `sslscan` command: - - -``` -┌──(root💀kali)-[~] -└─# sslscan vulnerable.usersys.redhat.com -Version: 2.0.6-static -OpenSSL 1.1.1i-dev  xx XXX xxxx - -Connected to 10.19.47.242 - -Testing SSL server vulnerable.usersys.redhat.com on port 443 using SNI name vulnerable.usersys.redhat.com - -  SSL/TLS Protocols: -SSLv2   disabled -SSLv3   disabled -TLSv1.0   disabled -TLSv1.1   disabled -TLSv1.2   enabled -TLSv1.3   enabled -<snip> -``` - -This shows information about the enabled SSL protocols and, further down in the output, information about the Heartbleed vulnerability: - - -``` -  Heartbleed: -TLSv1.3 not vulnerable to heartbleed -TLSv1.2 not vulnerable to heartbleed -``` - -### Tips for preventing or mitigating attackers - -There are many ways to defend your systems against the multitude of attackers out there. A few key points are: - - * **Know your systems:** This includes knowing which ports are open, what ports should be open, who should be able to see those open ports, and what is the expected traffic on those services. Nmap is a great tool to learn about systems on the network. - * **Use current best practices:** What is considered a best practice today might not be a best practice down the road. As an admin, it's important to stay up to date on trends in the infosec realm. - * **Know how to use your products:** For example, rather than letting an attacker continually hammer away at your WordPress system, block their IP address and limit the number of times they can try to log in before getting blocked. Blocking the IP address might not be as helpful in the real world because attackers are likely to use compromised systems to launch attacks. However, it's an easy setting to enable and could block some attacks. - * **Maintain and verify good backups:** If an attacker comprises one or more of your systems, being able to rebuild from known good and clean backups could save lots of time and money. - * **Check your logs:** As the examples above show, scanning and penetration commands may leave lots of logs indicating that an attacker is targeting the system. If you notice them, you can take preemptive action to mitigate the risk. - * **Update your systems, their applications, and any extra modules:** As [NIST Special Publication 800-40r3][9] explains, "patches are usually the most effective way to mitigate software flaw vulnerabilities, and are often the only fully effective solution." - * **Use the tools your vendors provide:** Vendors have different tools to help you maintain their systems, so make sure you take advantage of them. For example, [Red Hat Insights][10], included with Red Hat Enterprise Linux subscriptions, can help tune your systems and alert you to potential security threats. - - - -### Learn more - -This introduction to security tools and how to use them is just the tip of the iceberg. To dive deeper, you might want to look into the following resources: - - * [Armitage][11], an open source attack management tool - * [Red Hat Product Security Center][12] - * [Red Hat Security Channel][13] - * [NIST's Cybersecurity page][14] - * [Using Nmap results to help harden Linux systems][6] - - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/5/linux-security-tools - -作者:[Peter Gervase][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/pgervase -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0 (Magnifying glass on code) -[2]: https://www.kali.org/ -[3]: https://opensource.com/sites/default/files/uploads/kali-tools.png (Kali's tools) -[4]: https://creativecommons.org/licenses/by-sa/4.0/ -[5]: https://wpscan.com/wordpress-security-scanner -[6]: https://www.redhat.com/sysadmin/using-nmap-harden-systems -[7]: https://opensource.com/sites/default/files/uploads/nmap-scan.png (Nmap scan) -[8]: https://opensource.com/sites/default/files/uploads/nmap-port80.png (Nmap scan of port 80) -[9]: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-40r3.pdf%5D(https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-40r3.pdf -[10]: https://www.redhat.com/sysadmin/how-red-hat-insights -[11]: https://en.wikipedia.org/wiki/Armitage_(computing) -[12]: https://access.redhat.com/security -[13]: https://www.redhat.com/en/blog/channel/security -[14]: https://www.nist.gov/cybersecurity diff --git a/sources/tech/20210526 How I monitor my greenhouse with CircuitPython and open source tools.md b/sources/tech/20210526 How I monitor my greenhouse with CircuitPython and open source tools.md deleted file mode 100644 index b493c6a2cf..0000000000 --- a/sources/tech/20210526 How I monitor my greenhouse with CircuitPython and open source tools.md +++ /dev/null @@ -1,287 +0,0 @@ -[#]: subject: (How I monitor my greenhouse with CircuitPython and open source tools) -[#]: via: (https://opensource.com/article/21/5/monitor-greenhouse-open-source) -[#]: author: (Darin London https://opensource.com/users/dmlond) -[#]: collector: (lujun9972) -[#]: translator: (alim0x) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -How I monitor my greenhouse with CircuitPython and open source tools -====== -Keep track of your greenhouse's temperature, humidity, and ambient light -using a microcontroller, sensors, Python, and MQTT. -![Greenhouse garden with tomatoes][1] - -CircuitPython provides a revolutionary way to interact with microcontroller boards. This article explains how to use CircuitPython to measure a greenhouse's temperature, humidity, and ambient light and publish the results to an [MQTT][2] broker using a CircuitPython MQTT client. You can subscribe any number of programs to the MQTT queues to process the information further. - -This project uses a simple Python program that runs a web server that publishes a Prometheus-formatted scrape endpoint and pulls these metrics into [Prometheus][3] for ongoing monitoring. - -### About CircuitPython - -[CircuitPython][4] is an open source Python distribution created by [Adafruit][5] to run on low-cost microcontroller boards. CircuitPython provides a simple development experience for interacting with [compatible boards][6]. You can start a program on the board by creating a `code.py` file in the `CIRCUITPYTHON` root drive that mounts when you connect your board. CircuitPython also provides a serial connection from your board that includes an interactive read-evaluate-print loop (REPL) session that you can use to interact with your board in real time using Python code. - -Adafruit's website offers extensive documentation to help you get started with CircuitPython. First, consult the [Welcome to CircuitPython][7] guide. This will get you started running code on your microcontroller with CircuitPython and interacting with the REPL. It also documents how to install Adafruit's bundle of CircuitPython libraries and examples for many of the boards and sensors it sells. Next, read the [CircuitPython Essentials][8] guide to learn more about its capabilities and link to information about using CircuitPython with specific, compatible boards. Finally, as with all open source software, you can dig into [CircuitPython's code][9], post issues, and contribute. - -### Microcontroller setup - -The microcontroller system is very simple. To follow along with this demo, you will need: - - * **Raspberry Pi 4:** You need a computer to program the microcontroller system, and this is what I used.  - * **A CircuitPython-compatible microcontroller:** I used the [Adafruit FeatherS2][10] with built-in WiFi, ambient light sensor, and Qwiic cable input. - * **Microcontroller WiFi:** The FeatherS2 has a built-in WiFi radio. If your microcontroller does not, you will need to find a WiFi expansion board for it. - * **Sensors:** The Feather S2 has a built-in ambient light sensor, so I needed to get a temperature and humidity sensor. A variety is available from vendors, including Adafruit, SparkFun, and Amazon. I used an [Adafruit sensor][11] with a Qwiic cable connection compatible with the Feather S2 input. You may have to find CircuitPython-compatible Python libraries for sensors not purchased from Adafruit, although many SparkFun sensors work with Adafruit libraries. - * **Jumpers and cables:** To avoid using a breadboard or soldering, I used an [Adafruit Qwiic cable][12]. SparkFun also sells them in a [bundle of cables][13] of different lengths. - - - -Before plugging the microcontroller into your computer, connect the sensors to the microcontroller. - -![Connecting sensors to microcontroller][14] - -(Darin London, [CC BY-SA 4.0][15]) - -Now you can plug the microcontroller into your computer using a USB data cable. - -### The MQTT Broker - -You can use [these instructions][16] to install the [Mosquitto MQTT broker][17] and Mosquitto clients on a Raspberry Pi 4 running Raspberry Pi OS. If you want to use the Raspberry Pi as a long-term server, set a static IP address for the Raspberry Pi 4 on your network. Once the Mosquitto broker is running, create a [user/password file][18] that sets the authentication parameters for clients to use when publishing and subscribing to the broker. - -You can test the MQTT broker using the Mosquitto clients on the Raspberry Pi. Open two terminals (or SSH sessions if you are running headless): - -On Terminal 1, enter: - - -``` -`mosquitto_sub -h localhost -u $user -P $pass -t "mqtt/test"` -``` - -This will start a long-running process that listens for messages published to the `mqtt/test` queue. - -On Terminal 2, enter: - - -``` -`mosquitto_pub -h localhost -u $user -P $pass -t "mqtt/test" -m hello` -``` - -This will publish a message to the `mqtt/test` queue, which should show up in Terminal 1's output. - -You can then kill the `sub` command running on Terminal 1. - -The Mosquitto broker allows clients to publish messages to any queue, even if it has no subscribers. These messages will be lost forever, but they will not stop the client from publishing. - -Start a third terminal and subscribe to the following queues (the queues your microcontroller will publish messages to): - - * greenhouse/temperature - * greenhouse/light - * greenhouse/humidity - - - -### Code the microcontroller - -You are now ready to code your microcontroller to publish its metrics to the MQTT broker running on your Raspberry Pi 4. - -Adafruit has [excellent documentation][19] on using the [CircuitPython Library Bundle][20]'s libraries to connect your microcontroller to your WiFi router and get it publishing metrics to your MQTT broker. - -Install the following libraries, which the greenhouse monitor will use, into the `CIRCUITPYTHON/lib` directory. These are all available in the Adafruit CircuitPython Library Bundle: - - * **adafruit_bus_device:** A Python package directory with multiple .mpy files (.mpy is a compressed Python file that saves space on your microcontroller) - * **adafruit_requests:** A single .mpy file - * **adafruit_register:** Another package directory - * **adafruit_minimqtt:** Another package directory - * **adafruit_si7021:** A single .mpy file that works with the temperature and humidity sensors - - - -Once these libraries are installed, write the following into `code.py` in the `CIRCUITPYTHON` directory: - - -``` -import time -import ssl -import socketpool -import wifi -import adafruit_minimqtt.adafruit_minimqtt as MQTT -import board -from digitalio import DigitalInOut, Direction, Pull -from analogio import AnalogIn -import adafruit_si7021 -  -# Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and -# "password" keys with your WiFi credentials. DO NOT share that file or commit it into Git or other -# source control. -# pylint: disable=no-name-in-module,wrong-import-order -try: -        from secrets import secrets -except ImportError: -        print("WiFi secrets are kept in secrets.py, please add them there!") -        raise -  -print("Connecting to %s" % secrets["ssid"]) -wifi.radio.connect(secrets["ssid"], secrets["password"]) -print("Connected to %s!" % secrets["ssid"]) -### Feeds ### -light_feed = "greenhouse/light" -temp_feed = "greenhouse/temperature" -humidity_feed = "greenhouse/humidity" -  -# Define callback methods which are called when events occur -# pylint: disable=unused-argument, redefined-outer-name -def connected(client, userdata, flags, rc): -        # This function will be called when the client is connected -        # successfully to the broker. -        print("Connected to MQTT!") -  -def disconnected(client, userdata, rc): -        # This method is called when the client is disconnected -        print("Disconnected from MQTT!") -  -  -def get_voltage(pin): -        return (pin.value * 3.3) / 65536 -  -# Create a socket pool -pool = socketpool.SocketPool(wifi.radio) -  -# Set up a MiniMQTT Client -mqtt_client = MQTT.MQTT( -        broker=secrets["broker"], -        port=secrets["port"], -        username=secrets["aio_username"], -        password=secrets["aio_key"], -        socket_pool=pool, -        ssl_context=ssl.create_default_context(), -) -  -# Setup the callback methods above -mqtt_client.on_connect = connected -mqtt_client.on_disconnect = disconnected -  -# Connect the client to the MQTT broker. -print("Connecting to MQTT...") -mqtt_client.connect() -  -# Create library object using our Bus I2C port -sensor = adafruit_si7021.SI7021(board.I2C()) -light_pin = AnalogIn(board.IO4) -  -while True: -        # Poll the message queue -        mqtt_client.loop() -  -        # get the current temperature -        light_val = get_voltage(light_pin) -        temp_val = ((sensor.temperature * 9)/5) + 32 -        humidity_val = sensor.relative_humidity -  -        # Send a new messages -        mqtt_client.publish(light_feed, light_val) -        mqtt_client.publish(temp_feed, temp_val) -        mqtt_client.publish(humidity_feed, humidity_val) -        time.sleep(0.5) -``` - -Save your code. Then attach to the serial monitor and watch it connect to your MQTT broker. You can also see the output by switching to the terminals on your Raspberry Pi 4 subscribed to the queues where this publishes. - -### Process the metrics - -Publish/subscribe workflows like MQTT offer many advantages for microcontroller systems. You can have multiple microcontroller + sensor installations reporting different metrics about the same system or reporting many readings of the same metric in parallel. You can also have many different processes that subscribe to each queue to respond to these messages in parallel. It is even possible to have multiple different processes subscribed to the same queue for different actions, such as sending an email when a value gets too high or publishing a message to another MQTT queue. - -Another option is to have a microcontroller subscribe to an external queue that sends signals to tell the microcontroller to perform an action, such as turning off or starting a new session. Finally, pub/sub workflows can be better for low-power microcontroller installations (such as those using battery or solar power) because these devices can send metrics in batches separated by long delays and turn off the power-hungry WiFi radio during the intervals between reports. - -To process these metrics, I created a Python client that uses the [Paho Python MQTT client][21] to subscribe to the metrics queues. I also use the official [Prometheus Python client][22] to create a web server that produces a Prometheus-compliant scrape endpoint with these metrics as gauges. I run this, a [Prometheus server][23], and the Mosquitto MQTT broker on the same Raspberry Pi 4. - - -``` -from prometheus_client import start_http_server, Gauge -import random -import time -import paho.mqtt.client as mqtt - -gauge = { -  "greenhouse/light": Gauge('light','light in lumens'), -  "greenhouse/temperature": Gauge('temperature', 'temperature in fahrenheit'), -  "greenhouse/humidity": Gauge('humidity','relative % humidity') -} - -try: -        from mqtt_secrets import mqtt_secrets -except ImportError: -        print("WiFi secrets are kept in secrets.py, please add them there!") -        raise - -def on_connect(client, userdata, flags, rc): -        print("Connected with result code "+str(rc)) -        # Subscribing in on_connect() means that if we lose the connection and -        # reconnect then subscriptions will be renewed. -        client.subscribe("greenhouse/light") -        client.subscribe('greenhouse/temperature') -        client.subscribe('greenhouse/humidity') - -def on_message(client, userdata, msg): -        topic = msg.topic -        payload = msg.payload -        gauge[topic].set(payload) - -client = mqtt.Client() -client.username_pw_set(mqtt_secrets["mqtt_user"],mqtt_secrets['mqtt_password']) -client.on_connect = on_connect -client.on_message = on_message -client.connect('localhost',1883,60) - -if __name__ == '__main__': -        # Start up the server to expose the metrics. - -        client = mqtt.Client() -        client.username_pw_set('london','abc123') -        client.on_connect = on_connect -        client.on_message = on_message -        client.connect('localhost',1883,60) - -        start_http_server(8000) -        client.loop_forever() -``` - -Then I configure the Prometheus server to scrape that endpoint on localhost:8000. - -You can access all the code for this project in my MIT-licensed [Greenhouse MQTT Microcontroller][24] repository on GitHub. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/5/monitor-greenhouse-open-source - -作者:[Darin London][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/dmlond -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/zanda-photography-unsplash-greenhouse.jpg?itok=ZMnZyNMM (Greenhouse garden with tomatoes) -[2]: https://mqtt.org/ -[3]: https://prometheus.io/ -[4]: https://circuitpython.io/ -[5]: https://adafruit.com -[6]: https://circuitpython.org/downloads -[7]: https://learn.adafruit.com/welcome-to-circuitpython -[8]: https://learn.adafruit.com/circuitpython-essentials/circuitpython-essentials -[9]: https://github.com/adafruit/circuitpython -[10]: https://www.adafruit.com/product/4769 -[11]: https://www.adafruit.com/product/3251 -[12]: https://www.adafruit.com/product/4399 -[13]: https://www.sparkfun.com/products/15081 -[14]: https://opensource.com/sites/default/files/uploads/connectsensors-microcontroller.jpg (Connecting sensors to microcontroller) -[15]: https://creativecommons.org/licenses/by-sa/4.0/ -[16]: https://pimylifeup.com/raspberry-pi-mosquitto-mqtt-server/ -[17]: https://mosquitto.org/ -[18]: https://mosquitto.org/documentation/authentication-methods/ -[19]: https://learn.adafruit.com/mqtt-in-circuitpython -[20]: https://circuitpython.org/libraries -[21]: https://pypi.org/project/paho-mqtt/ -[22]: https://pypi.org/project/prometheus-client -[23]: https://opensource.com/article/21/3/iot-measure-raspberry-pi -[24]: https://github.com/dmlond/greenhouse_mqtt_microcontroller diff --git a/sources/tech/20210529 Configuring Vim as a Writing Tool.md b/sources/tech/20210529 Configuring Vim as a Writing Tool.md deleted file mode 100644 index ca6a93e8f7..0000000000 --- a/sources/tech/20210529 Configuring Vim as a Writing Tool.md +++ /dev/null @@ -1,206 +0,0 @@ -[#]: subject: (Configuring Vim as a Writing Tool) -[#]: via: (https://news.itsfoss.com/configuring-vim-writing/) -[#]: author: (Theena https://news.itsfoss.com/author/theena/) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Configuring Vim as a Writing Tool -====== - -In my first column I spoke about why I moved [my writing to Vim][1] – away from the standard tools of modern writers such as word processors (MS Word and their open source equivalents), text editors (Notepad since I’ve been a Windows user until last year), and cloud based storage technology. If you are a writer, I urge you to [read that part 1][1] before continuing here. - -Essentially, I argued that the more devices you use, the more writing tools you’ll need, the more complex the workflow eventually becomes. This is pertinent because I have four devices, including an Android phone, a main daily driver laptop running Linux, and a couple of older laptops, including a Mac, I take when I go outdoors for shoots. - -Vim was the perfect solution for me, and how I work; while I won’t argue that my new workflow is the best way for writers to work in the modern world, I will argue that it is important for writers to have a tool that works across all our devices, and is powerful enough to meet the needs for the different kinds of writing that we writers engage in everyday. - -Vim’s main benefit from this perspective, therefore, is that it is cross-platform – no matter what device you are on, Vim will work. I won’t speak extensively about using Vim in the Apple ecosystem, but a cursory glance at the reviews for [this app][2] tells me that somewhere someone needs Vim no matter what device they are using. - -Now let’s say you are a writer who wants to start using Vim. Where do you start once you’ve installed it? - -This part of the article isn’t necessarily a tutorial but a series of recommendations, including an examination of a .vimrc configuration file for prose writing. Wherever possible I will link to the respective YouTube tutorial that I learnt from. - -Linux users already have Vim pre-installed – launch it via the terminal emulator of choice. For Windows and Mac users, you can download it from the [official site][3]. - -### Recommendations - -**Post Vim Installation/Launch** - - * Open Vim Tutor via terminal. (Mac users can launch it this way, while Windows users can launch it using this method. You will not be using Vim to do any writing during this phase – instead you will spend 15 minutes everyday doing the Vim Tutorial. Don’t spend a minute longer or shorter; see how much progress you can make inside the tutorial within the allotted 15 minutes. You will find that every day, you progress that much deeper into the tutorial. Inside a month, you should be able to complete the entire tutorial within those 15 minutes. - * Becoming a better typist has immense benefits for Vim usage. This is optional, but I am relearning to type from scratch and it is having the side effect of making Vim even more useful. I began spending 15 minutes everyday on this site as a warm up before I went into the Vim Tutorial. - - - -I allocated 30 minutes at the start of every day for both these exercises to warm up, and 30 minutes every evening to cool down before I went to bed. This may have contributed to my quick transition from my old tool kit to Vim, but your mileage may vary. - -Once again, let me stress that the above steps _**other than Vim Tutor**_ is optional; it all depends on your individual motivation levels. - -We now come to the meat of this article: How do you configure Vim to be writer-friendly? - -### How to configure .vimrc for writing - -_Before I begin, I’d like to remind readers here that I am not a tech person – I am a novelist – and that any errors you see in the below are my own; I would love for feedback from experienced Vim users on how to refine my configuration file even further._ - -Below is my .vimrc file. You can clone mine from my [GitHub][4] and refine it further. - -``` -syntax on - -set noerrorbells "This removes vim's default error bell, turning it off so that it doesn't annoy us -set textwidth=100 "Ensures that each line is not longer than 100 columns -set tabstop=4 softtabstop=4 -set shiftwidth=4 -set expandtab -set smartindent -set linebreak -set number -set showmatch -set showbreak=+++ -set smartcase -set noswapfile -set undodir=~/.vim/undodir -set undofile -set incsearch -set spell -set showmatch -set confirm -set ruler -set autochdir -set autowriteall -set undolevels=1000 -set backspace=indent,eol,start - -" The next two settings ensure that line breaks and wrap work how writers, not -" coders, prefer it - -set wrap -nnoremap :set linebreak -nnoremap :set nolinebreak - - -call plug#begin('~/.vim/plugged') - -" This is for color themes - -Plug 'colepeters/spacemacs-theme.vim' -Plug 'sainnhe/gruvbox-material' -Plug 'phanviet/vim-monokai-pro' -Plug 'flazz/vim-colorschemes' -Plug 'chriskempson/base16-vim' -Plug 'gruvbox-community/gruvbox' - -" This is a selection of plugins to make prose writing easier. - -Plug 'dpelle/vim-LanguageTool' -Plug 'ron89/thesaurus_query.vim' -Plug 'junegunn/goyo.vim' -Plug 'junegunn/limelight.vim' -Plug 'reedes/vim-pencil' -Plug 'reedes/vim-wordy' - - -" This section are nice-to-haves for easier integration with machine, using vim-airline and such. - -Plug 'vim-airline/vim-airline' - -"This section deals with workspace and session management - -Plug 'thaerkh/vim-workspace' - -"Related to above, the following code saves all session files in a single directory outside your -"workspace - -let g:workspace_session_directory = $HOME . '/.vim/sessions/' - - -"Related to above, this is a activity tracker for vim - -Plug 'wakatime/vim-wakatime' - -" A disturbance in the force: we are using some emacs functionality here, org-mode specifically - -Plug 'jceb/vim-orgmode' - - - -" This is for language-specific plugins - -Plug 'plasticboy/vim-markdown' - - - call plug#end() - -colorscheme pacific -set background=dark - -if executable('rg') - let g:rg_derive_root='true' -endif -``` - -Learn how to install Vim Plugin. This tutorial helped me. I use Vim Plugged because it was the simplest and most elegant in my view. - -![][5] - -#### .vimrc housekeeping for writers - - * `syntax on` : this ensures that vim acknowledges what syntax I am using. I primarily use markdown for most note-taking and writing articles such as this one; while plain-text is my preferred method when working on my fiction. - * `set noerrorbells` : for the sake of your sanity, I highly recommend turning this on - * `set textwidth=100` : For ease of reading because no one wants to be horizontal scrolling a text document - * `set spell“ - * `set wrap` : ensures text wraps like how writers, not coders, would want it. You will notice that I haven’t spent much time discussing some of the other basic configuration, but I don’t feel those are salient for writers. I do some hobbyist coding so my .vimrc is a reflection of that. If all you want to do is to write on Vim, then the above configuration ought to get you started. - - - -From that point, your .vimrc is a living document of what you want to do with Vim, and how you want Vim to do that for you. - -#### A note on plug-ins - -Plug-ins are specified between lines 43-98. Assuming you’ve followed the tutorial on how to install vim plug-ins, I highly recommend the following vim writing-specific plug-ins to get started: - - * `vim-LanguageTool` - * `thesaurus_query.vim` - * `vim-pencil` - * `vim-wordy` - * `vim-goyo` - * `vim-markdown` - - - -#### Conclusion - -In this article, we gently introduced how writers can get started on vim, including a basic primer on configuring .vimrc for writing. In addition to mine, I am going to link here to the .vimrc of other writers that I found on GitHub, and have used as inspiration for my own. - -![][6] - -Remember that this is just a starter kit of a .vimrc for writers. As your needs evolve, you will find that Vim can evolve with it. Therefore, learning to configure your .vimrc is worth investing some time in. - -In the next article, I will be examining specifics of my writing workflow, using Vim and Git and GitHub. - -#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! - -If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. - -I'm not interested - --------------------------------------------------------------------------------- - -via: https://news.itsfoss.com/configuring-vim-writing/ - -作者:[Theena][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://news.itsfoss.com/author/theena/ -[b]: https://github.com/lujun9972 -[1]: https://news.itsfoss.com/how-i-started-loving-vim/ -[2]: https://apps.apple.com/us/app/ivim/id1266544660 -[3]: https://www.vim.org/ -[4]: https://github.com/MiragianCycle/dotfiles -[5]: https://i1.wp.com/i.ytimg.com/vi/n9k9scbTuvQ/hqdefault.jpg?w=780&ssl=1 -[6]: https://i2.wp.com/i.ytimg.com/vi/Pq3JMp3stxQ/hqdefault.jpg?w=780&ssl=1 diff --git a/sources/tech/20210601 Get started with FreeDOS.md b/sources/tech/20210601 Get started with FreeDOS.md deleted file mode 100644 index 8e366ac791..0000000000 --- a/sources/tech/20210601 Get started with FreeDOS.md +++ /dev/null @@ -1,103 +0,0 @@ -[#]: subject: (Get started with FreeDOS) -[#]: via: (https://opensource.com/article/21/6/get-started-freedos) -[#]: author: (Jim Hall https://opensource.com/users/jim-hall) -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Get started with FreeDOS -====== -It looks like retro computing, but it's a modern OS you can use to get -stuff done. -![Old UNIX computer][1] - -Throughout the 1980s and into the 1990s, I was primarily a DOS user. I loved the command line environment offered in DOS, which became more powerful with each successive release. I even learned how to write my own DOS programs in the C programming language so I could extend the DOS command line, and write more powerful replacements for the standard DOS commands. I'd experimented with Microsoft's Windows—but if you remember Windows 3 from that time, you know it was slow and tended to crash. But I preferred the command line anyway, so I stuck to DOS. - -That all changed in 1994. Popular tech magazines talked about an upcoming version of Windows that would completely do away with DOS. I didn't want to be forced to Windows. On the discussion boards I visited on Usenet, others felt the same. So [on 29 June 1994][2], I decided that if we wanted to keep DOS, we needed to write our own. So on June 29, I announced a small project that would become [The FreeDOS Project][3]. - -Since then, we've released several full distributions of FreeDOS. We started with the alpha series from 1994 to 1997, the beta series from 1998 to 2005, before finally releasing the FreeDOS 1.0 distribution in 2006. Progress has been slow but steady since then. We haven't really been rushed to release each new version after 1.0, because DOS stopped being a moving target in 1995. - -Each FreeDOS distribution since 1.0 has been a continual re-imagining of what a modern DOS might look like. We've included lots of compilers, assemblers for developers to write software. We also provide lots of "power tools" so you can do real work. And we offer a variety of editors because everyone has their favorite. - -We recently released the FreeDOS 1.3 RC4 distribution. This is technically a release candidate towards our upcoming FreeDOS 1.3 distribution, but it's a full-featured distribution. I'm very excited about all the great features in FreeDOS 1.3 RC4. - -### Run FreeDOS without installing FreeDOS - -In all our previous FreeDOS distributions, we focused on _installing_ FreeDOS to a computer. But we recognize that most users don't actually run FreeDOS on actual hardware anymore—they run FreeDOS in [a virtual machine like QEMU or VirtualBox][4]. So in FreeDOS 1.3 RC4, we improved the "LiveCD" environment. - -With FreeDOS 1.3 RC4, you can just boot the LiveCD image in your favorite virtual machine, and start using FreeDOS right away. That's how I run FreeDOS now; I have a small virtual hard drive image where I store all my files, but I boot and run FreeDOS from the LiveCD. - -![Booting the FreeDOS 1.3 RC4 LiveCD on QEMU][5] - -Booting the FreeDOS 1.3 RC4 LiveCD (Jim Hall, [CC-BY SA 4.0][6]) - -### Installing is really easy - -If you don't want to run FreeDOS from the LiveCD, you can also install it on your hard drive. We updated the installer in FreeDOS so it's not really a "program" per se, but instead is a very smart DOS "batch" file that detects all sorts of things and takes the appropriate action, like creating a new disk partition for FreeDOS if none exist already. - -Older FreeDOS distributions used to prompt you for everything, even selecting individual programs to install. The new installer is very streamlined. It asks you a few questions to get started, then does everything else on its own. Installing FreeDOS on an empty virtual machine takes only a few minutes. - -![Installing FreeDOS 1.3 RC4][7] - -Installing FreeDOS 1.3 RC4 (Jim Hall, [CC-BY SA 4.0][6]) - -### You can install it from floppy - -Not everyone prefers to run FreeDOS in a virtual machine. There's a retrocomputing community out there that collects and lovingly restores classic PC hardware like Pentium or '486 systems. You can even find some XT (8088) or AT (80286) systems out there, kept running by a dedicated user community. - -And while we consider FreeDOS a _modern_ DOS, we wouldn't be "DOS" if we didn't also run on the older PC hardware too. So with FreeDOS 1.3, we include a Floppy-Only Edition! This edition should run on any hardware that can run FreeDOS and has EGA or better graphics. - -Are you running a '286 or another classic system without a CD-ROM drive? Install from these floppies to install FreeDOS. Do you have just one hard drive and no CD or floppy drive? Just copy the contents of the floppies to a temporary directory and run the installer from there. Want to perform a "headless" install to a different DOS directory? It's easy with the command-line options. - -The Floppy-Only Edition uses a completely different installer and contains a limited FreeDOS set of programs that are more useful on classic PC hardware. - -![Installing the FreeDOS Floppy-Only Edition][8] - -Installing the FreeDOS Floppy-Only Edition (Jim Hall, [CC-BY SA 4.0][6]) - -### Filled with open source apps and games - -FreeDOS isn't a _free_ DOS if it's a closed source DOS. We want everyone to be able to use and study FreeDOS, including its source code. As we planned the FreeDOS 1.3 distribution, we took a close look at every license in every package and focused on including only _open source_ programs. (A few programs in previous FreeDOS distributions were not quite "open source," and one or two programs didn't include source code but were otherwise "free to use and distribute." In this release, everything is open source, using the Open Source Definition as our model.) - -And what a great collection of open source apps and games. The games are my favorite addition to FreeDOS 1.3 RC4. Many people use FreeDOS to play classic DOS games, but we wanted to provide our own open source games for people to play. - -You can find two games already installed in the LiveCD: Simple Senet (a board game dating to ancient Egypt) and Floppy Bird (a version of the Flappy Bird game). If you install FreeDOS, you'll also find lots of other games to try, including Sudoku86 (a sudoku game), Wing (a space shooter), and Bolitaire (solitaire card game). - -![Playing the Floppy Bird game][9] - -Playing the Floppy Bird game (Jim Hall, [CC-BY SA 4.0][6]) - -![The ancient game of Senet][10] - -The ancient game of Senet (Jim Hall, [CC-BY SA 4.0][6]) - -### Try FreeDOS 1.3 RC4 now - -You can find the new FreeDOS 1.3 RC4 from the FreeDOS website, on our [Downloads][11] page. To install FreeDOS, you'll need at least 20MB of free disk space: 20MB to install a plain FreeDOS system, or 250MB to install everything, including applications and games. To install the source code too, you'll need up to 450MB of free space. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/6/get-started-freedos - -作者:[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/retro_old_unix_computer.png?itok=SYAb2xoW (Old UNIX computer) -[2]: https://groups.google.com/g/comp.os.msdos.apps/c/oQmT4ETcSzU/m/O1HR8PE2u-EJ -[3]: https://www.freedos.org/ -[4]: https://opensource.com/article/20/8/virt-tools -[5]: https://opensource.com/sites/default/files/freedos-livecd.png (Booting the FreeDOS 1.3 RC4 LiveCD) -[6]: https://creativecommons.org/licenses/by-sa/4.0/ -[7]: https://opensource.com/sites/default/files/install6.png (Installing FreeDOS 1.3 RC4) -[8]: https://opensource.com/sites/default/files/freedos-floppy.png (Installing the FreeDOS Floppy-Only Edition) -[9]: https://opensource.com/sites/default/files/floppy-bird.png (Playing the Floppy Bird game) -[10]: https://opensource.com/sites/default/files/simple-senet.png (The ancient game of Senet) -[11]: https://www.freedos.org/download/ diff --git a/sources/tech/20210603 FreeDOS commands for Linux fans.md b/sources/tech/20210603 FreeDOS commands for Linux fans.md index cdabb2a9a2..522ca199eb 100644 --- a/sources/tech/20210603 FreeDOS commands for Linux fans.md +++ b/sources/tech/20210603 FreeDOS commands for Linux fans.md @@ -2,7 +2,7 @@ [#]: via: (https://opensource.com/article/21/6/freedos-linux-users) [#]: author: (Jim Hall https://opensource.com/users/jim-hall) [#]: collector: (lujun9972) -[#]: translator: ( shipsw ) +[#]: translator: ( ) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20210605 15 Useful Visual Studio Code Keyboard Shortcuts to Increase Productivity.md b/sources/tech/20210605 15 Useful Visual Studio Code Keyboard Shortcuts to Increase Productivity.md deleted file mode 100644 index 99d2b4f246..0000000000 --- a/sources/tech/20210605 15 Useful Visual Studio Code Keyboard Shortcuts to Increase Productivity.md +++ /dev/null @@ -1,240 +0,0 @@ -[#]: subject: (15 Useful Visual Studio Code Keyboard Shortcuts to Increase Productivity) -[#]: via: (https://itsfoss.com/vs-code-shortcuts/) -[#]: author: (Sarvottam Kumar https://itsfoss.com/author/sarvottam/) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -15 Useful Visual Studio Code Keyboard Shortcuts to Increase Productivity -====== - -There is no doubt that Microsoft’s [VS Code is one of the best open source code editor][1] out there. Unlike the legendary Vim, VS Code doesn’t need you to be a keyboard ninja and has tons of features that developers swear by. - -But this doesn’t mean you cannot, or you should not use keyboard shortcuts in Visual Studio Code. - -Do you hate breaking your coding flow and move your hand to a mouse for performing an action like toggling terminal in your Visual Studio Code (VS Code) editor? If yes, then you should immediately get yourself familiar and memorize these useful keyboard shortcuts for VS Code. - -It will not just help you to get rid of a mouse, but also make you highly productive and efficient. - -So, let’s get to know how you can code fast by quickly navigating through the code editor using keyboard shortcuts. - -### Useful VS Code Keyboard Shortcuts - -Just a disclaimer. These keyboard shortcuts are what I find most useful when working in VS Code. You may explore more of them based on your needs. - -I have also mentioned keyboard shortcuts for macOS users. - -#### 1\. Show All Commands - -Windows/Linux | macOS ----|--- -CTRL + SHIFT + P or F1 | SHIFT + ⌘ + P or F1 - -Starting with the most helpful shortcut, it opens Command Palette that provides access to all of the functionality of VS Code. - -![Command Palette][2] - -It is a very important VS Code Shortcut because even if you forget or don’t want to remember any shortcut except this one, you can still perform various operations using Command Palette like create a new file, open settings, change theme, and view all keyboard shortcuts as well. - -#### 2\. Split VS Code Editor Vertically Or Horizontally - -Windows/Linux | macOS ----|--- -CTRL + \ -| ⌘ + \ - -If you don’t have a multi-monitor setup for high productivity, you can still view codes of multiple files at once by splitting the editor either horizontally or vertically. - -![Split VS Code][3] - -To change focus into editor group, you can either use number or arrow keys. - -Windows/Linux | macOS ----|--- -CTRL + 1/2/3 | ⌘ + 1/2/3 -CTRL + K CTRL + ←/→ | ⌘ + K ⌘ + ←/→ - -#### 3\. Toggle Integrated Terminal - -Windows/Linux | macOS ----|--- -CTRL + ` | ⌘ + ` - -Integrated terminal in VS Code is a very convenient feature that lets you execute the task quickly without switching windows. To hide/unhide the terminal in the editor, this keyboard shortcut comes in very handy. - -![Integrated Terminal][4] - -However, like me, if you find pressing “CTRL+`” difficult to use due to its weird corner location, you can still open Command Palette and execute `View: Toggle Terminal` command. - -![Toggle Terminal Using Command Palette][5] - -#### 4\. Go To File - -Windows/Linux | macOS ----|--- -CTRL + P | ⌘ + P - -As the project grows, looking for a file might become a very difficult task. Hence, I would suggest even you use a mouse, this command can save you a lot of time in searching and navigating to a file in a repository. - -![Go to file][6] - -#### 5\. Go To Line - -Windows/Linux | macOS ----|--- -CTRL + G | ^ + G - -Once you search a file, you may now want to jump to a specific line for adding or editing code. If a file contains thousands of lines of code, scrolling can definitely eat up your time. Hence, CTRL+G or ^+G VS Code Keyboard Shortcut can quickly take you to a line you want. - -![Go to line][7] - -Alternatively, you can also use the fourth shortcut for ‘Go To File,’ where appending `:` colon with line number in the input box works as ‘Go To Line.’ - -#### 6\. Search Complete Project - -Windows/Linux | macOS ----|--- -CTRL + SHIFT + F | ⌘ + SHIFT + F - -Most probably you may also want to search for a text, variable, or function in your whole project. In such a case, this command is very convenient that shows search input in the sidebar. - -![Search project][8] - -You can also add filters to your search using ALT+C to match case, ALT+W to match the whole word, and ALT+R to use regular expression. - -#### 7\. Zen Mode - -Windows/Linux | macOS ----|--- -CTRL + K Z | ⌘ + K Z - -Want to work in a distraction-free environment to stay more focused? Zen mode is a feature in a VS Code that hides all UI (Status Bar, Activity Bar, Panel, and Sidebar) and displays only the editor on a full screen. - -![Zen Mode][9] - -To enable Zen Mode, you can either use the above shortcut or open Command Palette and execute “View: Toggle Zen Mode.” To exit Zen mode, you need to press `Esc` button twice. - -#### 8\. Add Selection To Next Find Match - -Windows/Linux | macOS ----|--- -CTRL + D | ⌘ + D - -This command enables you to select the next occurrences of a selected text for editing. It comes very handy if the next match is located far away from the first match. - -![Next find match][10] - -#### 9\. Toggle Line Comment - -Windows/Linux | macOS ----|--- -CTRL + / | ⌘ + / - -The struggle to reach the start of a line and then add a double forward slash to the comment line can be replaced with this quick keyboard shortcut. - -![Comment out code][11] - -Even if you want to comment out multiple lines, you can select all lines using `SHIFT+UP/Down` and then press `CTRL+/`. - -#### 10\. Jump To The Beginning Or End Of File - -Windows/Linux | macOS ----|--- -CTRL + HOME/END | ⌘ + ↑/↓ - -If you get lost in the middle of your codes, the command can help to quickly reach either start or end of the file. - -#### 11\. Code Folding Or Unfolding - -Windows/Linux | macOS ----|--- -CTRL + SHIFT + [ or ] | ⌥ + ⌘ + [ or ] - -It is one of the most useful shortcuts that can help you collapse/uncollapse a region of code. In this way, you can hide unnecessary code and view only the required section of code at a time to focus more and code fast. - -![Collapse a region of code][12] - -#### 12\. Peek Implementation - -Windows/Linux | macOS ----|--- -CTRL + SHIFT + F12 | ⌘ + SHIFT + F12 - -The shortcut is most likely to help you in your code analysis or bug fixing where you want to understand the working of functions and variables. - -![Peek Implementation][13] - -#### 13\. Delete Current Line - -Windows/Linux | macOS ----|--- -CTRL + SHIFT + K | SHIFT + ⌘ + K - -A single quick command can sum up two tasks of selecting a current line and pressing the delete/backspace button. - -#### 14\. Find And Replace - -Windows/Linux | macOS ----|--- -CTRL + F -CTRL + H | ⌘ + F -⌥ + ⌘ + F - -What could be the best way to replace all occurrences of a text in a file with a new one? If you go for one by one manually by scrolling down the code, no wonder how much time it will take if text occurrence is large. - -![Find and replace][14] - -While using Find and Replace do the same task within seconds. You can open it using two shortcuts where one actually opens the input box for finding text and the other for replacing text. - -#### 15\. VS Code Keyboard Shortcuts - -Windows/Linux | macOS ----|--- -CTRL + K CTRL + S | ⌘ + K ⌘ + S - -At last, if you still struggle with remembering all the above keyboard shortcuts, you still don’t have to worry. This is because you can view all available commands for your editor using the above shortcut. - -![Keyboard Shortcuts][15] - -Here you can also edit keybinding for the command as per your comfort. - -### Want More Keyboard Shortcuts For VS Code? - -If you want to have complete knowledge of VS Code keyboard shortcuts, you can check out the [documentation][16] of Visual Studio Code. - -Or, if you want all available shortcuts in a single piece of paper, get the cheatsheet for [Linux][17], [macOS][18], and [Windows][19]. You can have a quick look whenever you forget. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/vs-code-shortcuts/ - -作者:[Sarvottam Kumar][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/sarvottam/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/best-modern-open-source-code-editors-for-linux/ -[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/Command-Palette.jpg?resize=800%2C418&ssl=1 -[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/Split-VS-Code.png?resize=800%2C405&ssl=1 -[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/Integrated-Terminal.png?resize=800%2C221&ssl=1 -[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/Toggle-Terminal-Using-Command-Palette.png?resize=686%2C118&ssl=1 -[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/Go-to-file.jpg?resize=800%2C388&ssl=1 -[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/Go-to-line.jpg?resize=800%2C99&ssl=1 -[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/05/Search-project.jpg?resize=381%2C450&ssl=1 -[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/05/Zen-Mode.png?resize=800%2C450&ssl=1 -[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/Next-find-match.jpg?resize=800%2C313&ssl=1 -[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/Comment-out-code.jpg?resize=800%2C313&ssl=1 -[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/05/Collapse-a-region-of-code.jpg?resize=800%2C287&ssl=1 -[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/Peek-Implementation.png?resize=800%2C339&ssl=1 -[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/Find-and-replace.png?resize=800%2C223&ssl=1 -[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/05/Keyboard-Shortcuts.png?resize=800%2C406&ssl=1 -[16]: https://code.visualstudio.com/docs/getstarted/keybindings -[17]: https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf -[18]: https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf -[19]: https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf diff --git a/sources/tech/20210608 Analyze community health metrics with this open source tool.md b/sources/tech/20210608 Analyze community health metrics with this open source tool.md new file mode 100644 index 0000000000..6c2aa41b70 --- /dev/null +++ b/sources/tech/20210608 Analyze community health metrics with this open source tool.md @@ -0,0 +1,83 @@ +[#]: subject: (Analyze community health metrics with this open source tool) +[#]: via: (https://opensource.com/article/21/6/health-metrics-cauldron) +[#]: author: (Georg Link https://opensource.com/users/georglink) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Analyze community health metrics with this open source tool +====== +Cauldron makes it easier for anyone to use GrimoireLab to learn more +about open source communities. +![Open source doctor.][1] + +Community managers, maintainers, and foundations seek metrics and insights about open source communities. Because each open source project works differently, its data needs to be analyzed differently. Yet, all projects share common challenges with getting data and creating visualizations. This presents an ideal use case for an open source project to solve this problem generically with the capability to customize it to users' needs. + +The open source GrimoireLab project has been working on ways to [measure the health of open source communities][2]. In addition to powering large-scale open source metrics solutions, it also serves as the backbone of the new [Cauldron][3] platform. + +GrimoireLab solves some hard problems related to retrieving and curating data. It was designed to be a flexible metrics solution for analyzing open source communities. [LibreOffice][4] and [Mautic][5] are among the communities using GrimoireLab's open source tools to generate community health metrics. + +![LibreOffice's GrimoireLab dashboard][6] + +LibreOffice's GrimoireLab dashboard (Georg Link, [CC BY-SA 4.0][7]) + +GrimoireLab satisfies the need for metrics, but two challenges have prevented wider adoption. First, it is difficult to deploy and secure. Its setup is more difficult than many expect, especially those who just want to have metrics without manually editing configuration files. Second, it does not scale well if you have many users trying to analyze different projects; every user must deploy their own GrimoireLab instance. + +Two platforms have solved these challenges to offer community metrics as a service, with GrimoireLab working under the hood. First, the Linux Foundation leveraged GrimoireLab to bootstrap its [LFX Insights platform][8]. It gives the foundation's open source projects a great deal of insight into their communities, some of which goes beyond GrimoireLab's core features. LFX Insights is not available as open source and only available from the Linux Foundation. + +![LFX Insights dashboard][9] + +LFX Insights dashboard showing metrics about the Kubernetes project (Georg Link, [CC BY-SA 4.0][7]) + +The other choice is [Cauldron][10], which is open source. It's designed to abstract the difficulty of using GrimoireLab's metrics and create a smooth user experience. Anyone can use Cauldron for their open source communities for free at [Cauldron.io][3]. Cauldron provides metrics without having to deploy software, which resolves the challenge of deploying and securing GrimoireLab. + +![Cauldron dashboard][11] + +Cauldron dashboard showing metrics about the Kubernetes project (Georg Link, [CC BY-SA 4.0][7]) + +Cauldron solves the scalability challenge by collecting data about an open source community centrally and making it available to all platform users. This reduces the time needed for new reports if the data was previously collected. It also minimizes the issue of API rate limits that could restrict collecting data at scale. + +To mitigate privacy concerns, Cauldron anonymizes all data by default. Should you want to know who your contributors (or companies in your communities) are, you will need a private Cauldron instance, either by deploying it yourself or using [Cauldron Cloud service][12]. + +These design choices enable a new way of working with this data. Instead of limiting analysis to individual projects, anyone can define reports and include anything from a single project's repository to hundreds of repositories from a group of projects. This makes it possible to analyze trends, like the rise in blockchain projects, by looking at data across many projects. + +Many people want to be able to compare data about multiple open source projects. In Cauldron, a user can create a report for each project then use the Comparison feature to show the data for each project side-by-side with graphs. + +![A Cauldron dashboard comparing Ansible, Ethereum, and Kubernetes][13] + +Cauldron dashboard comparing Ansible, Ethereum, and Kubernetes (Georg Link, [CC BY-SA 4.0][7]) + +The high demand for open source within the enterprise and increasing interest in community health and metrics are leading solution providers to improve usability. GrimoireLab continues to focus on retrieving data about open source communities. Downstream projects like LFX Insights and Cauldron leverage GrimoireLab to provide easy-to-use metrics. + +On a related note, the CHAOSS Project offers a Community Health Report. The report is created using the two CHAOSS projects, Augur and GrimoireLab. You can [request your Community Health Report][14] on the CHAOSS website or see the same metrics and visualizations under the [CHAOSS tab][15] in Cauldron. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/health-metrics-cauldron + +作者:[Georg Link][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/georglink +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_520x292_opensourcedoctor.png?itok=fk79NwpC (Open source doctor.) +[2]: https://opensource.com/article/20/3/grimoirelab +[3]: https://cauldron.io/ +[4]: https://dashboard.documentfoundation.org/ +[5]: https://dashboard.mautic.org/ +[6]: https://opensource.com/sites/default/files/uploads/libreoffice_grimoirelab-dashboard.png (LibreOffice's GrimoireLab dashboard) +[7]: https://creativecommons.org/licenses/by-sa/4.0/ +[8]: https://lfx.linuxfoundation.org/tools/insights +[9]: https://opensource.com/sites/default/files/uploads/lfx-insights.png (LFX Insights dashboard) +[10]: https://gitlab.com/cauldronio/cauldron/ +[11]: https://opensource.com/sites/default/files/uploads/cauldron-dashboard.png (Cauldron dashboard) +[12]: http://cloud.cauldron.io/ +[13]: https://opensource.com/sites/default/files/uploads/compare-projects.png (A Cauldron dashboard comparing Ansible, Ethereum, and Kubernetes) +[14]: https://chaoss.community/community-reports/ +[15]: https://cauldron.io/project/372?tab=chaoss diff --git a/sources/tech/20210608 Play Doom on Kubernetes.md b/sources/tech/20210608 Play Doom on Kubernetes.md new file mode 100644 index 0000000000..38f85bc387 --- /dev/null +++ b/sources/tech/20210608 Play Doom on Kubernetes.md @@ -0,0 +1,232 @@ +[#]: subject: (Play Doom on Kubernetes) +[#]: via: (https://opensource.com/article/21/6/kube-doom) +[#]: author: (Jessica Cherry https://opensource.com/users/cherrybomb) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Play Doom on Kubernetes +====== +Terminate pods while having fun by playing Kube DOOM. +![A cat under a keyboard.][1] + +Do you ever feel nostalgic for Doom and other blocky video games, the ones that didn't require much more than a mouse and the hope that you could survive on a LAN with your friends? You know what I'm talking about; the days when your weekends were consumed with figuring out how you could travel with your desktop and how many Mountain Dews you could fit in your cargo pants pockets? If this memory puts a warm feeling in your heart, well, this article is for you. + +Get ready to play Doom again, only this time you'll be playing for a legitimate work reason: doing chaos engineering. I'll be using my [fork of Kube DOOM][2] (with a new Helm chart because that's how I sometimes spend my weekends). I also have a pull request with the [original Kube DOOM][3] creator that I'm waiting to hear about. + +The first article in this series explained [what chaos engineering is][4], and the second demonstrated how to get your [system's steady state][5] so that you can compare it against a chaos state. In the next few articles, I introduced some chaos engineering tools you can use: [Litmus for testing][6] arbitrary failures and experiments in your Kubernetes cluster; [Chaos Mesh][7], an open source chaos orchestrator with a web user interface; and [Kube-monkey][8] for stress-testing your systems by scheduling random termination pods in your cluster. + +In this sixth article, I'll use Pop!_OS 20.04, Helm 3, Minikube 1.14.2, a VNC viewer, and Kubernetes 1.19. + +### Configure Minikube + +If you haven't already, [install Minikube][9] in whatever way that makes sense for your environment. If you have enough resources, I recommend giving your virtual machine a bit more than the default memory and CPU power: + + +``` +$ minikube config set memory 8192 +❗  These changes will take effect upon a minikube delete and then a minikube start +$ minikube config set cpus 6 +❗  These changes will take effect upon a minikube delete and then a minikube start +``` + +Then start and check the status of your system: + + +``` +$ minikube start +😄  minikube v1.14.2 on Debian bullseye/sid +🎉  minikube 1.19.0 is available! Download it: +💡  To disable this notice, run: 'minikube config set WantUpdateNotification false' + +✨  Using the docker driver based on user configuration +👍  Starting control plane node minikube in cluster minikube +🔥  Creating docker container (CPUs=6, Memory=8192MB) ... +🐳  Preparing Kubernetes v1.19.0 on Docker 19.03.8 ... +🔎  Verifying Kubernetes components... +🌟  Enabled addons: storage-provisioner, default-storageclass +🏄  Done! kubectl is now configured to use "minikube" by default +$ minikube status +minikube +type: Control Plane +host: Running +kubelet: Running +apiserver: Running +kubeconfig: Configured +``` + +### Preinstall pods with Helm + +Before moving forward, you'll need to deploy some pods into your cluster. To do this, I generated a simple Helm chart and changed the replicas in my values file from 1 to 8. + +If you need to generate a Helm chart, you can read my article on [creating a Helm chart][10] for guidance. I created a Helm chart named `nginx` and created a namespace to install my chart into using the commands below. + +Create a namespace: + + +``` +`$ kubectl create ns nginx` +``` + +Install the chart in your new namespace with a name: + + +``` +$ helm install chaos-pods nginx -n nginx + +NAME: chaos-pods +LAST DEPLOYED: Sun May 23 10:15:52 2021 +NAMESPACE: nginx +STATUS: deployed +REVISION: 1 +NOTES: +1\. Get the application URL by running these commands: +  export POD_NAME=$(kubectl get pods --namespace nginx -l "app.kubernetes.io/name=nginx,app.kubernetes.io/instance=chaos-pods" -o jsonpath="{.items[0].metadata.name}") +  export CONTAINER_PORT=$(kubectl get pod --namespace nginx $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") +  echo "Visit to use your application" +  kubectl --namespace nginx port-forward $POD_NAME 8080:$CONTAINER_PORT +``` + +### Install Kube DOOM + +You can use any [Virtual Network Computer][11] (VNC) viewer you want; I installed [TigerVNC][12] on my Linux box. There are several ways you can set up Kube DOOM. Before I generated my Helm chart, you could set it up with [kind][13] or use it locally with Docker, and the [README][14] contains instructions for those uses. + +Get started with a `git clone`: + + +``` +$ git clone [git@github.com][15]:Alynder/kubedoom.git +Cloning into 'kubedoom'... +``` + +Then change directory into the `kubedoom/helm` folder: + + +``` +`$ cd kubedoom/helm/` +``` + +Since the base values file is already set up correctly, you just need to run a single install command: + + +``` +$ helm install kubedoom kubedoom/ -n kubedoom +NAME: kubedoom +LAST DEPLOYED: Mon May 31 11:16:58 2021 +NAMESPACE: kubedoom +STATUS: deployed +REVISION: 1 +NOTES: +1\. Get the application URL by running these commands: +  export NODE_PORT=$(kubectl get --namespace kubedoom -o jsonpath="{.spec.ports[0].nodePort}" services kubedoom-kubedoom-chart) +  export NODE_IP=$(kubectl get nodes --namespace kubedoom -o jsonpath="{.items[0].status.addresses[0].address}") +  echo http://$NODE_IP:$NODE_PORT +``` + +Everything should be installed, set up, and ready to go. + +### Play with Kube DOOM + +Now you just need to get in there, run a few commands, and start playing your new chaos video game. The first command is a port forward, followed by the VNC viewer connection command. The VNC viewer connection needs a password, which is `idbehold`. + +Find your pod for the port forward: + + +``` +$ kubectl get pods -n kubedoom +NAME                                       READY   STATUS    RESTARTS   AGE +kubedoom-kubedoom-chart-676bcc5c9c-xkwpp   1/1     Running   0          68m +``` + +Run the `port-forward` command using your pod name: + + +``` +$  kubectl port-forward  kubedoom-kubedoom-chart-676bcc5c9c-xkwpp 5900:5900 -n kubedoom +Forwarding from 127.0.0.1:5900 -> 5900 +Forwarding from [::1]:5900 -> 5900 +``` + +Everything is ready to play, so you just need to run the VNC viewer command (shown below with output): + + +``` +$  vncviewer viewer localhost:5900 + +TigerVNC Viewer 64-bit v1.10.1 +Built on: 2020-04-09 06:49 +Copyright (C) 1999-2019 TigerVNC Team and many others (see README.rst) +See for information on TigerVNC. + +Mon May 31 11:33:23 2021 + DecodeManager: Detected 64 CPU core(s) + DecodeManager: Creating 4 decoder thread(s) + CConn:       Connected to host localhost port 5900 +``` + +Next, you'll see the password request, so enter it (`idbehold`, as given above). + +![VNC authentication][16] + +(Jess Cherry, [CC BY-SA 4.0][17]) + +Once you are logged in, you should be able to walk around and see your enemies with pod names. + +![Kube Doom pods][18] + +(Jess Cherry, [CC BY-SA 4.0][17]) + +I'm terrible at this game, so I use some cheats to have a little more fun: + + * Type `idspispopd` to walk straight through a wall to get to your army of pods. + * Can't handle the gun? That's cool; I'm bad at it, too. If you type `idkfa` and press the number **5**, you'll get a better weapon. + + + +This is what it looks like when you kill something (I used [k9s][19] for this view). + +![Killing pods in Kube DOOM][20] + +(Jess Cherry, [CC BY-SA 4.0][17]) + +### Final notes + +Because this application requires a cluster-admin role, you have to really pay attention to the names of the pods—you might run into a kube-system pod, and you'd better run away. If you kill one of those pods, you will kill an important part of the system. + +I love this application because it's the quickest gamified way to do chaos engineering. It did remind me of how bad I was at this video game, but it was hilarious to try it. Happy hunting! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/kube-doom + +作者:[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/osdc-lead_cat-keyboard.png?itok=fuNmiGV- (A cat under a keyboard.) +[2]: https://github.com/Alynder/kubedoom +[3]: https://github.com/storax/kubedoom +[4]: https://opensource.com/article/21/5/11-years-kubernetes-and-chaos +[5]: https://opensource.com/article/21/5/get-your-steady-state-chaos-grafana-and-prometheus +[6]: https://opensource.com/article/21/5/total-chaos-litmus +[7]: https://opensource.com/article/21/5/get-meshy-chaos-mesh +[8]: https://opensource.com/article/21/6/chaos-kubernetes-kube-monkey +[9]: https://minikube.sigs.k8s.io/docs/start/ +[10]: https://opensource.com/article/20/5/helm-charts +[11]: https://en.wikipedia.org/wiki/Virtual_Network_Computing +[12]: https://tigervnc.org/ +[13]: https://kind.sigs.k8s.io/ +[14]: https://github.com/Alynder/kubedoom/blob/master/README.md +[15]: mailto:git@github.com +[16]: https://opensource.com/sites/default/files/uploads/vnc-password.png (VNC authentication) +[17]: https://creativecommons.org/licenses/by-sa/4.0/ +[18]: https://opensource.com/sites/default/files/uploads/doom-pods.png (Kube Doom pods) +[19]: https://opensource.com/article/20/5/kubernetes-administration +[20]: https://opensource.com/sites/default/files/uploads/doom-pods_kill.png (Killing pods in Kube DOOM) diff --git a/sources/tech/20210608 Subtitld- A Cross-Platform Open-Source Subtitle Editor.md b/sources/tech/20210608 Subtitld- A Cross-Platform Open-Source Subtitle Editor.md deleted file mode 100644 index 88b16f4f71..0000000000 --- a/sources/tech/20210608 Subtitld- A Cross-Platform Open-Source Subtitle Editor.md +++ /dev/null @@ -1,111 +0,0 @@ -[#]: subject: (Subtitld: A Cross-Platform Open-Source Subtitle Editor) -[#]: via: (https://itsfoss.com/subtitld/) -[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Subtitld: A Cross-Platform Open-Source Subtitle Editor -====== - -Subtitles make the experience of watching a video seamless. You do not need to necessarily understand the language of the video, the subtitle helps you figure out what’s happening with a text version of the audio in your preferred language. - -You get subtitles for most of the content in streaming platforms you might have to add subtitles for some videos that you have in your local collection. - -While you can do that by simply downloading SRT files and loading it up using the video player, how do you edit it, remove it, or transcribe a video? Subtitld is an open-source subtitle editor that comes to the rescue. - -### Subtitld: Create, Remove, Slice, and Transcribe Subtitles - -Subtitld is a free and open-source project that lets you make the most out of your subtitles. - -![][1] - -If you do not have a subtitle, create one, if you need to edit it, go ahead. With this open-source tool, you get many options to work with the subtitles. - -In other words, it is a full-fledged subtitle editor and one of its kind (as far as I’ve come across). - -Let me highlight some key features before you decide to try it. - -### Features of Subtitld - -![][2] - -It offers a great deal of functions, while not everyone needs all of them, but if you are someone who regularly creates, edits, and works with subtitles, it should come in pretty handy. - -Here’s a list of them: - - * Create subtitles - * Edit subtitles - * Move subtitles using a timeline to sync manually - * Zoom in/out function to help with a crowded timeline - * Supports saving to SRT file format - * Supports various other formats to import and export (SSA, TTML, SBV, DFXP, VTT, XML, SCC and SAMI) - * Easy to resize or adjust the duration of a subtitle from the timeline - * Merge with other subtitles or just slice a subtitle in a project - * Ability to enable grids to visualize by frames, scenes, or seconds - * Playback in the editor to check how the subtitles work - * Snap the subtitles in the timeline to avoid overlapping - * Add/remove among the subtitles - * Enable safety margins to ensure that the subtitles do not look improper - * Adjust the playback speed - * Keyboard shortcuts available - * Auto-transcribe - * Export videos with subtitles burned in - * Unlimited undo - - - -In addition to these features, the visual clues for the audio waveform also help in a way. - -![][3] - -Overall, you can do many things and use it professionally as well, if you are someone who transcribes videos and want to edit the video in one go. - -**Recommended Read:** - -![][4] - -#### [App Highlight: Penguin Subtitle Player for Adding Subtitles to Online Videos][5] - -With the free and open source application, Penguin subtitle player, you can add subtitles to any online videos. Learn more about this nifty app. - -### Installing Subtitld in Linux - -While it is also available for Windows, you can easily install it on Linux using the [snap package][6]. You will not find any binary packages or Flatpak available, but you should be able to install it on any Linux distribution [using snap on Linux][7]. - -[Subtitld][8] - -You can find the source code on [GitLab][9] if you want to explore. - -### Closing Thoughts - -With fine-grained settings available to sync or add subtitles for a video, I just tested a few basic functions to import, export, add or remove subtitles. - -The auto-transcribe feature is still something in beta (as of publishing this), but the user interface could use some improvements. For instance, when I hover over the buttons inside the editor, it does not tell me what it does. - -Overall, it is a useful tool to have available on Linux. What do you think about it? Please don’t hesitate to let me know your thoughts in the comments down below. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/subtitld/ - -作者:[Ankush Das][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/ankush/ -[b]: https://github.com/lujun9972 -[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/subtitld-editor.png?resize=800%2C546&ssl=1 -[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/subtitld-export.png?resize=800%2C469&ssl=1 -[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/subtitld-screenshot-1.png?resize=800%2C588&ssl=1 -[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/Add_subtitle_online_videos.png?fit=800%2C450&ssl=1 -[5]: https://itsfoss.com/penguin-subtitle-player/ -[6]: https://snapcraft.io/subtitld -[7]: https://itsfoss.com/use-snap-packages-ubuntu-16-04/ -[8]: https://subtitld.jonata.org -[9]: https://gitlab.com/jonata/subtitld diff --git a/sources/tech/20210609 Configure FreeDOS in plain text.md b/sources/tech/20210609 Configure FreeDOS in plain text.md new file mode 100644 index 0000000000..b54016ae8a --- /dev/null +++ b/sources/tech/20210609 Configure FreeDOS in plain text.md @@ -0,0 +1,213 @@ +[#]: subject: (Configure FreeDOS in plain text) +[#]: via: (https://opensource.com/article/21/6/freedos-fdconfigsys) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Configure FreeDOS in plain text +====== +Learn how to configure FreeDOS with FDCONFIG.SYS. +![Person using a laptop][1] + +The main configuration file for FreeDOS is a file in the root directory called `FDCONFIG.SYS`. This file contains a series of lines, each setting a value such as `LASTDRIVE=Z` or `FILES=40`. For example, the default `FDCONFIG.SYS` in FreeDOS 1.3 RC4 looks like this: + + +``` +SET DOSDIR=C:\FDOS + +!COUNTRY=001,858,C:\FDOS\BIN\COUNTRY.SYS +!LASTDRIVE=Z +!BUFFERS=20 +!FILES=40 +!MENUCOLOR=7,0 + +MENUDEFAULT=1,5 +MENU 1 - Load FreeDOS with JEMMEX, no EMS (most UMBs), max RAM free +MENU 2 - Load FreeDOS with JEMM386 (Expanded Memory) +MENU 3 - Load FreeDOS low with some drivers (Safe Mode) +MENU 4 - Load FreeDOS without drivers (Emergency Mode) + +12?DOS=HIGH +12?DOS=UMB +12?DOSDATA=UMB +1?DEVICE=C:\FDOS\BIN\JEMMEX.EXE NOEMS X=TEST I=TEST NOVME NOINVLPG +234?DEVICE=C:\FDOS\BIN\HIMEMX.EXE +2?DEVICE=C:\FDOS\BIN\JEMM386.EXE X=TEST I=TEST I=B000-B7FF NOVME NOINVLPG +34?SHELL=C:\FDOS\BIN\COMMAND.COM C:\FDOS\BIN /E:1024 /P=C:\FDAUTO.BAT +12?SHELLHIGH=C:\FDOS\BIN\COMMAND.COM C:\FDOS\BIN /E:1024 /P=C:\FDAUTO.BAT +``` + +But what do all those lines mean? Why do some have a question mark (`?`) or an exclamation point (`!`), while other lines do not? + +### A simple configuration + +Let's start with a simple configuration, so we can see what does what. Assume this very brief `FDCONFIG.SYS` file: + + +``` +LASTDRIVE=Z +BUFFERS=20 +FILES=40 +DEVICE=C:\FDOS\BIN\HIMEMX.EXE +SHELL=C:\FDOS\BIN\COMMAND.COM C:\FDOS\BIN /E:1024 /P=C:\FDAUTO.BAT +``` + +This configuration file contains only a few instructions: + + 1. `LASTDRIVE=Z` + 2. `BUFFERS=20` + 3. `FILES=40` + 4. `DEVICE=C:\FDOS\BIN\HIMEMX.EXE` + 5. `SHELL=C:\FDOS\BIN\COMMAND.COM C:\FDOS\BIN /E:1024 /P=C:\FDAUTO.BAT` + + + +The first instruction tells FreeDOS how many drive letters to reserve in memory. (DOS uses letters to represent each drive attached to the system, and `LASTDRIVE=Z` says to reserve drive letters from "A" to "Z."). `LASTDRIVE` affects the number of _logical drives_ that your system can recognize. You probably don't have any logical drives; the FreeDOS installer doesn't set these up by default. In any case, it is safe to set `LASTDRIVE=Z` on any FreeDOS system. + +The `BUFFERS` line reserves memory for file buffers. A _buffer_ helps to speed up certain processes that require storage, such as copying files. If you set a larger value for `BUFFERS`, FreeDOS will reserve more memory—and vice versa for smaller values. Most users will set this to `BUFFERS=20` or `BUFFERS=40`, depending on how often they need to read and write files on the system. + +The `FILES` setting determines how many files DOS allows you to open at one time. If you run an application that needs to open many files at once, such as a Genealogy database, you may need to set `FILES` to a larger value. For most users, `FILES=40` is a reasonable value. + +`DEVICE` is a special instruction that loads a _device driver_. DOS requires device drivers for certain hardware or configurations. The line `DEVICE=C:\FDOS\BIN\HIMEMX.EXE` loads the _HimemX_ device driver, so DOS can take advantage of expanded memory beyond the first 640 kilobytes. + +The last line tells the FreeDOS kernel where to find the command-line shell. By default, the kernel will look for the shell as `COMMAND.COM`, but you can change it with the `SHELL` instruction. In this example, `SHELL=C:\FDOS\BIN\COMMAND.COM` says the shell is the `COMMAND.COM` program, located in the `\FDOS\BIN` directory on the `C` drive. + +The other text at the end of the `SHELL` indicate the options to the `COMMAND.COM` shell. The FreeDOS `COMMAND.COM` supports several startup options to modify its behavior, including: + + * **`C:\FDOS\BIN`** \- The full path to the `COMMAND.COM` program + * `/E:1024 -` The environment (E) size, in bytes. `/E:1024` tells `COMMAND.COM` to reserve 1024 bytes, or 1 kilobyte, to store its environment variables. + * **`/P=C:\FDAUTO.BAT`** \- The `/P` option indicates that the shell is a permanent (P) shell, so the user cannot quit the shell by typing `EXIT` (the extra text `=C:\FDAUTO.BAT` tells `COMMAND.COM` to execute the `C:\FDAUTO.BAT` file at startup, instead of the default `AUTOEXEC.BAT` file) + + + +With that simple configuration, you should be able to interpret some of the `FDCONFIG.SYS` file that's installed by FreeDOS 1.3 RC4. + +### Boot menu + +FreeDOS supports a neat feature—multiple configurations on one system, using a "boot menu" to select the configuration you want. The `FDCONFIG.SYS` file contains several lines that define the menu: + + +``` +!MENUCOLOR=7,0 + +MENUDEFAULT=1,5 +MENU 1 - Load FreeDOS with JEMMEX, no EMS (most UMBs), max RAM free +MENU 2 - Load FreeDOS with JEMM386 (Expanded Memory) +MENU 3 - Load FreeDOS low with some drivers (Safe Mode) +MENU 4 - Load FreeDOS without drivers (Emergency Mode) +``` + +The `MENUCOLOR` instruction defines the text color and background color of the boot menu. These values are typically in the range 0 to 7, and represent these colors: + + * 0 Black + * 1 Blue + * 2 Green + * 3 Cyan + * 4 Red + * 5 Magenta + * 6 Brown + * 7 White + + + +So the `MENUCOLOR=7,0` definition means to display the menu with white (7) text on a black (0) background. If you instead wanted to use white text on a blue background, you could define this as `MENUCOLOR=7,1`. + +The exclamation point (`!`) at the start of the line means that this instruction will always be executed, no matter what menu option you choose. + +The `MENUDEFAULT=1,5` line tells the kernel how long to wait for the user to select a boot menu entry, or what default menu entry to use if the user did not select one. `MENUDEFAULT=1,5` indicates the system will wait for 5 seconds; if the user did not attempt to select a menu item within that time, the kernel will assume boot menu "1" instead. + +![boot menu][2] + +Jim Hall, CC-BY SA 4.0 + +The `MENU` lines after that are labels for the different boot menu configurations. These are presented in order, so menu item "1" is first, then "2," and so on. + +![menu select 4][3] + +Jim Hall, CC-BY SA 4.0 + +In the lines that follow in `FDCONFIG.SYS`, you will see numbers before a question mark (`?`). These indicate "for this boot menu entry, use this line." For example, this line with `234?` will only load the HimemX device driver if the user selects boot menu entries "2," "3," or "4." + + +``` +`234?DEVICE=C:\FDOS\BIN\HIMEMX.EXE` +``` + +There are lots of ways to use `FDCONFIG.SYS` to configure your FreeDOS system. We've only covered the basics here, the most common ways to define your FreeDOS kernel settings. For more information, explore the FreeDOS Help system (type `HELP` at the command line) to learn how to use all of the FreeDOS `FDCONFIG.SYS` options: + + * **SWITCHES** + * Boot time processing behavior + * **REM** and **;** + * Comments (ignored in FDCONFIG.SYS) + * **MENUCOLOR** + * Boot menu text color and background color + * **MENUDEFAULT** + * Boot menu default value + * **MENU** + * Boot menu entry + * **ECHO** and **EECHO** + * Display messages + * **BREAK** + * Sets extended **Ctrl+C** checking on or off + * **BUFFERS** or **BUFFERSHIGH** + * How many disk buffers to allocate + * **COUNTRY** + * Sets international behavior + * **DOS** + * Tell the FreeDOS kernel how to load itself into memory + * **DOSDATA** + * Tell FreeDOS to load kernel data into upper memory + * **FCBS** + * Set the number of file control blocks (FCBs) + * **KEYBUF** + * Reassign the keyboard buffer in memory + * **FILES** or **FILESHIGH** + * How many files to have open at once + * **LASTDRIVE** or **LASTDRIVEHIGH** + * Set the last drive letter that can be used + * **NUMLOCK** + * Set the keyboard number pad lock on or off + * **SHELL**, **SHELLHIGH**, or **COMMAND** + * Set the command line shell + * **STACKS** or **STACKSHIGH** + * Add stacks to handle hardware interrupts + * **SWITCHAR** + * Redefines the command line option switch character + * **SCREEN** + * Set the number of lines on the screen + * **VERSION** + * Set what DOS version to report to programs + * **IDLEHALT** + * Activates energy saving features, useful on certain systems + * **DEVICE** and **DEVICEHIGH** + * Load a driver into memory + * **INSTALL** and **INSTALLHIGH** + * Load a "terminate and stay resident" (TSR) program + * **SET** + * Set a DOS environment variable + + + +### Configuring in plain text + +Like Linux and BSD, FreeDOS configuration happens in plain text. No special tools for editing are required, so dive in and see what options suit you best. It's easy but powerful! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/freedos-fdconfigsys + +作者:[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/boot-menu.png (The boot menu waits for 5 seconds before assuming menu item 1) +[3]: https://opensource.com/sites/default/files/uploads/menu-select4.png (Use the arrow keys to select a boot menu configuration) diff --git a/sources/tech/20210609 Making portable functions across serverless platforms.md b/sources/tech/20210609 Making portable functions across serverless platforms.md new file mode 100644 index 0000000000..ff96b42b67 --- /dev/null +++ b/sources/tech/20210609 Making portable functions across serverless platforms.md @@ -0,0 +1,218 @@ +[#]: subject: (Making portable functions across serverless platforms) +[#]: via: (https://opensource.com/article/21/6/quarkus-funqy) +[#]: author: (Daniel Oh https://opensource.com/users/daniel-oh) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Making portable functions across serverless platforms +====== +Quarkus Funqy brings portability to serverless functions. +![Parts, modules, containers for software][1] + +The rising popularity of serverless development alongside the increased adoption of multi- and hybrid-cloud architectures has created a lot of competition among platforms. This gives developers many choices about where they can run functions on serverless platforms—from public managed services to on-premises [Kubernetes][2]. + +If you've read my previous articles about [Java serverless][3], you learned how to get started [developing Java serverless functions][4] with Quarkus and how those serverless functions can be [optimized][5] to run on Kubernetes. So what should you do next to make your serverless functions fit better with the many choices available to you? + +As a clue, think about why the Linux container (Docker, [LXC][6], cri-o) has become so popular: Portability. It's what made containers the de facto packaging technology for moving things from a developer's local machine to Kubernetes environments at scale. It means developers and operators don't need to worry about incompatibility and inconsistency between development and production environments. + +For adopting multi- and hybrid cloud architectures, these container portability benefits should also be considered for serverless function development. Without portability, developers would likely have to learn and use different APIs, command-line interface (CLI) tools, and software development kits (SDKs) for each serverless platform when developing and deploying the same serverless functions across multiple serverless runtimes. Developers, who have limited resources (e.g., time, effort, cost, and human resources), would be so overwhelmed by the options that they would find it difficult to choose the best one. + +![Many serverless runtime options][7] + +(Daniel Oh, [CC BY-SA 4.0][8]) + +### Get Funqy the next time you hit a serverless dance floor + +The [Quarkus Funqy][9] extension supports a portable Java API for developers to write serverless functions and deploy them to heterogeneous serverless runtimes, including AWS Lambda, Azure Functions, Google Cloud, and Knative. It is also usable as a standalone service. Funqy helps developers dance on the serverless floor without making code changes. + +Here is a quick example of how to build a portable serverless function with Quarkus Funqy. + +### 1\. Create a Quarkus Funqy Maven project + +Generate a Quarkus project (`quarkus-serverless-func`) to create a simple function with Funqy extensions: + + +``` +$ mvn io.quarkus:quarkus-maven-plugin:1.13.6.Final:create \ +       -DprojectGroupId=org.acme \ +       -DprojectArtifactId=quarkus-serverless-func \ +       -Dextensions="funqy-http" \ +       -DclassName="org.acme.getting.started.GreetingResource" +``` + +### 2\. Run the serverless function locally + +Open the `Funqy.java` file in the `src/main/java/org/acme/getting/started` directory: + + +``` +public class Funqy { + +    private static final [String][10] CHARM_QUARK_SYMBOL = "c"; + +    @Funq (1) +    public [String][10] charm(Answer answer) { (2) +        return CHARM_QUARK_SYMBOL.equalsIgnoreCase(answer.value) ? "You Quark!" : "👻 Wrong answer"; +    } + +    public static class Answer { +        public [String][10] value; (3) +    } +} +``` + +In the code above: + +(1) Annotation makes the method an exposable function based on the Funqy API. The function name is equivalent to the method name (`charm`) by default. +(2) Indicates a Java class (`Answer`) as an input parameter and `String` type for the output. +(3) `value` should be parameterized when the function is invoked. + +**Note**: Funqy does type introspection at build time to speed boot time, so the Funqy marshaling layer won't notice any derived types at runtime. + +Run the function via Quarkus Dev Mode: + + +``` +`$ ./mvnw quarkus:dev` +``` + +The output should look like: + + +``` +__  ____  __  _____   ___  __ ____  ______ + --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ + -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   +\--\\___\\_\\____/_/ |_/_/|_/_/|_|\\____/___/   +INFO  [io.quarkus] (Quarkus Main Thread) quarkus-serverless-func 1.0.0-SNAPSHOT on JVM (powered by Quarkus x.x.x.) started in 2.908s. Listening on: +INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated. +INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, funqy-http, kubernetes] +``` + +Now the function is running in your local development environment. Access the function with a RESTful API: + + +``` +`$ http://localhost:8080/charm?value=s` +``` + +The output should be: + + +``` +`👻 Wrong answer` +``` + +If you pass `value=c` down as a parameter, you will see: + + +``` +`You Quark!` +``` + +### 3\. Choose a serverless platform to deploy the Funqy function + +Now you can deploy the portable function to your preferred serverless platform when you add one of the Quarkus Funqy extensions in the figure below. The advantage is that you will not need to change the code; you should need only to adjust a few configurations, such as function export and target serverless platform. + +![Quarkus Funqy Extensions][11] + +(Daniel Oh, [CC BY-SA 4.0][8]) + +Try to deploy the function using [Knative Serving][12] (if you have installed it in your Kubernetes cluster). Add the following extensions to the Quarkus Funqy project: + + +``` +`$ ./mvnw quarkus:add-extension -Dextensions="kubernetes,container-image-docker"` +``` + +Open the `application.properties` file in the `src/main/resources/` directory. Then add the following variables to configure Knative and Kubernetes resources—make sure to replace `changeit` with your container registry's group name (username in DockerHub): + + +``` +quarkus.container-image.build=true +quarkus.container-image.group=changeit +quarkus.container-image.push=true +quarkus.container-image.builder=docker +quarkus.kubernetes.deployment-target=knative +``` + +Containerize the function, then push it to the external container registry: + + +``` +`$ ./mvnw clean package` +``` + +The output should end with `BUILD SUCCESS`. Then a `knative.yml` file will be generated in the `target/kubernetes` directory. Now you should be ready to create a Knative service with the function using the following command (be sure to log into the Kubernetes cluster and change the namespace where you want to create the Knative service): + + +``` +`$ kubectl create -f target/kubernetes/knative.yml` +``` + +The output should be like this: + + +``` +`service.serving.knative.dev/quarkus-serverless-func created` +``` + +### 4\. Test the Funqy function in Kubernetes + +Get the function's REST API and note its output: + + +``` +$ kubectl get rt +NAME URL READY REASON +quarkus-serverless-func     True +``` + +Access the function quickly using a `curl` command: + + +``` +`$ http://http://quarkus-serverless-func-YOUR_HOST_DOMAIN/charm?value=c` +``` + +You see the same output as you saw locally: + + +``` +`You Quark!` +``` + +**Note**: The function will scale down to zero in 30 seconds because of Knative Serving's default behavior. In this case, the pod will scale up automatically when the REST API is invoked. + +### What's next? + +You've learned how developers can make portable Java serverless functions with Quarkus and deploy them across serverless platforms (e.g., Knative with Kubernetes). Quarkus enables developers to avoid redundancy when creating the same function and deploying it to multiple serverless platforms. My next article in this series will explain how to enable CloudEvents Bind with Java and Knative. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/quarkus-funqy + +作者:[Daniel Oh][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/daniel-oh +[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/article/19/6/reasons-kubernetes +[3]: https://opensource.com/article/21/5/what-serverless-java +[4]: https://opensource.com/article/21/6/java-serverless-functions +[5]: https://opensource.com/article/21/6/java-serverless-functions-kubernetes +[6]: https://www.redhat.com/sysadmin/exploring-containers-lxc +[7]: https://opensource.com/sites/default/files/uploads/choices.png (Many serverless runtime options) +[8]: https://creativecommons.org/licenses/by-sa/4.0/ +[9]: https://quarkus.io/guides/funqy +[10]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string +[11]: https://opensource.com/sites/default/files/uploads/funqyextensions.png (Quarkus Funqy Extensions) +[12]: https://knative.dev/docs/serving/ diff --git a/sources/tech/20210609 What happens when you terminate Kubernetes containers on purpose.md b/sources/tech/20210609 What happens when you terminate Kubernetes containers on purpose.md new file mode 100644 index 0000000000..08199ae5a0 --- /dev/null +++ b/sources/tech/20210609 What happens when you terminate Kubernetes containers on purpose.md @@ -0,0 +1,289 @@ +[#]: subject: (What happens when you terminate Kubernetes containers on purpose?) +[#]: via: (https://opensource.com/article/21/6/terminate-kubernetes-containers) +[#]: author: (Jessica Cherry https://opensource.com/users/cherrybomb) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +What happens when you terminate Kubernetes containers on purpose? +====== +In the final article in this series about chaos engineering, do some +experiments to learn how changes affect your infrastructure's state. +![x sign ][1] + +In this series celebrating Kubernetes' 11th birthday, I've introduced some great tools for chaos engineering. In the first article, I explained [what chaos engineering is][2], and in the second, I demonstrated how to get your [system's steady state][3] so that you can compare it against a chaos state. In the next four articles, I introduced some chaos engineering tools: [Litmus for testing][4] arbitrary failures and experiments in your Kubernetes cluster; [Chaos Mesh][5], an open source chaos orchestrator with a web user interface; [Kube-monkey][6] for stress-testing your systems by scheduling random termination pods in your cluster; and [Kube DOOM][7] for killing pods while having fun. + +Now I'll wrap up this birthday present by putting it all together. Along with Grafana and Prometheus for monitoring for a steady state on your local cluster, I'll use Chaos Mesh and a small deployment and two experiments to see the difference between steady and not steady, as well as Pop!_OS 20.04, Helm 3, Minikube 1.14.2, and Kubernetes 1.19. + +### Configure Minikube + +If you haven't already, [install Minikube][8] in whatever way that makes sense for your environment. If you have enough resources, I recommend giving your virtual machine a bit more than the default memory and CPU power: + + +``` +$ minikube config set memory 8192 +❗  These changes will take effect upon a minikube delete and then a minikube start +$ minikube config set cpus 6 +❗  These changes will take effect upon a minikube delete and then a minikube start +``` + +Then start and check the status of your system: + + +``` +$ minikube start +😄  minikube v1.14.2 on Debian bullseye/sid +🎉  minikube 1.19.0 is available! Download it: +💡  To disable this notice, run: 'minikube config set WantUpdateNotification false' + +✨  Using the docker driver based on user configuration +👍  Starting control plane node minikube in cluster minikube +🔥  Creating docker container (CPUs=6, Memory=8192MB) ... +🐳  Preparing Kubernetes v1.19.0 on Docker 19.03.8 ... +🔎  Verifying Kubernetes components... +🌟  Enabled addons: storage-provisioner, default-storageclass +🏄  Done! kubectl is now configured to use "minikube" by default +$ minikube status +minikube +type: Control Plane +host: Running +kubelet: Running +apiserver: Running +kubeconfig: Configured +``` + +### Preinstall pods with Helm + +Before moving forward, you'll need to deploy some pods into your cluster. To do this, I generated a simple Helm chart and changed the replicas in my values file from 1 to 8. + +If you need to generate a Helm chart, you can read my article on [creating a Helm chart][9] for guidance. I created a Helm chart named `nginx` and created a namespace to install my chart into using the commands below. + +Create a namespace: + + +``` +`$ kubectl create ns nginx` +``` + +Install the chart in your new namespace with a name: + + +``` +$ helm install chaos-pods nginx -n nginx + +NAME: chaos-pods +LAST DEPLOYED: Sun May 23 10:15:52 2021 +NAMESPACE: nginx +STATUS: deployed +REVISION: 1 +NOTES: +1\. Get the application URL by running these commands: +  export POD_NAME=$(kubectl get pods --namespace nginx -l "app.kubernetes.io/name=nginx,app.kubernetes.io/instance=chaos-pods" -o jsonpath="{.items[0].metadata.name}") +  export CONTAINER_PORT=$(kubectl get pod --namespace nginx $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") +  echo "Visit to use your application" +  kubectl --namespace nginx port-forward $POD_NAME 8080:$CONTAINER_PORT +``` + +### Monitoring and marinating + +Next, install and set up Prometheus and Grafana [following the steps][10] in the second article in this series. However, you'll need to make make the following changes in the installation: + + +``` +$ kubectl create ns monitoring + +$ helm install prometheus prometheus-community/prometheus -n monitoring + +$ helm install grafana bitnami/grafana -n monitoring +``` + +Now that everything is installed in separate namespaces, set up your dashboards and let Grafana marinate for a couple of hours to catch a nice steady state. If you're in a staging or dev cluster at work, it would be even better to let everything sit for a week or so. + +For this walkthrough, I will use the [K8 Cluster Detail Dashboard][11] (dashboard 10856), which provides various drop-downs with details about your cluster. + +![K8 Cluster Detail Dashboard][12] + +(Jess Cherry, [CC BY-SA 4.0][13]) + +### Test #1: Container killing with Grafana and Chaos Mesh + +Install and configure Chaos Mesh using the [steps][5] in my previous article. Once that is set up, you can add some new experiments to test and observe with Grafana. + +Start by setting up an experiment to kill containers. First, look at your steady state. + +![K8 Cluster Detail Dashboard][14] + +(Jess Cherry, [CC BY-SA 4.0][13]) + +Next, make a kill-container experiment pointed at your Nginx containers. I created an `experiments` directory and then the `container-kill.yaml` file: + + +``` +$ mkdir experiments +$ cd experiments/ +$ touch container-kill.yaml +``` + +The file will look like this: + + +``` +apiVersion: chaos-mesh.org/v1alpha1 +kind: PodChaos +metadata: +  name: container-kill-example +  namespace: nginx +spec: +  action: container-kill +  mode: one +  containerName: 'nginx' +  selector: +    labelSelectors: +      'app.kubernetes.io/instance': 'nginx' +  scheduler: +    cron: '@every 60s' +``` + +Once it starts, this experiment will kill an `nginx` container every minute. + +Apply your file: + + +``` +$ kubectl apply -f container-kill.yaml +podchaos.chaos-mesh.org/container-kill-example created +``` + +Now that the experiment is in place, watch it running in Chaos Mesh. + +![Chaos Mesh Dashboard][15] + +(Jess Cherry, [CC BY-SA 4.0][13]) + +You can also look into Grafana and see a notable change in the state of the pods and containers. + +![Grafana][16] + +(Jess Cherry, [CC BY-SA 4.0][13]) + +If you change the kill time and reapply the experiment, you will see even more going on in Grafana. For example, change `@every 60s` to `@every 30s` and reapply the file: + + +``` +$ kubectl apply -f container-kill.yaml +podchaos.chaos-mesh.org/container-kill-example configured +$ +``` + +You can see the disruption in Grafana with two containers sitting in waiting status. + +![Grafana][17] + +(Jess Cherry, [CC BY-SA 4.0][13]) + +Now that you know how the containers reacted, go into the Chaos Mesh user interface and pause the experiment. + +### Test #2: Networking with Grafana and Chaos Mesh + +The next test will work with network delays to see what happens if there are issues between pods. First, grab your steady state from Grafana. + +![Grafana][18] + +(Jess Cherry, [CC BY-SA 4.0][13]) + +Create a `networkdelay.yaml` file for your experiment: + + +``` +`$ touch networkdelay.yaml` +``` + +Then add some network delay details. This example runs a delay in the `nginx` namespace against your namespace instances. The packet-sending delay will be 90ms, the jitter will be 90ms, and the jitter correlation will be 25%: + + +``` +apiVersion: chaos-mesh.org/v1alpha1 +kind: NetworkChaos +metadata: +  name: network-delay-example +  namespace: nginx +spec: +  action: delay +  mode: one +  selector: +    labelSelectors: +      'app.kubernetes.io/instance': 'nginx' +  delay: +    latency: "90ms" +    correlation: "25" +    jitter: "90ms" +  duration: "45s" +  scheduler: +    cron: "@every 1s" +``` + +Save and apply the file: + + +``` +$ kubectl apply -f  networkdelay.yaml +networkchaos.chaos-mesh.org/network-delay-example created +``` + +It should show up in Chaos Mesh as an experiment. + +![Chaos Mesh Dashboard][19] + +(Jess Cherry, [CC BY-SA 4.0][13]) + +Now that it is running pretty extensively using your configuration, you should see an interesting, noticeable change in Grafana. + +![Grafana][20] + +(Jess Cherry, [CC BY-SA 4.0][13]) + +In the graphs, you can see the pods are experiencing a delay. + +Congratulations! You have a more detailed way to keep track of and test networking issues. + +### Chaos engineering final thoughts + +My gift to celebrate Kubernetes' birthday is sharing a handful of chaos engineering tools. Chaos engineering has a lot of evolving yet to do, but the more people involved, the better the testing and tools will get. Chaos engineering can be fun and easy to set up, which means everyone—from your dev team to your administration—can do it. This will make your infrastructure and the apps it hosts more dependable. + +Happy birthday, Kubernetes! I hope this series was a good gift for 11 years of being a cool project. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/terminate-kubernetes-containers + +作者:[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/x_stop_terminate_program_kill.jpg?itok=9rM8i9x8 (x sign ) +[2]: https://opensource.com/article/21/5/11-years-kubernetes-and-chaos +[3]: https://opensource.com/article/21/5/get-your-steady-state-chaos-grafana-and-prometheus +[4]: https://opensource.com/article/21/5/total-chaos-litmus +[5]: https://opensource.com/article/21/5/get-meshy-chaos-mesh +[6]: https://opensource.com/article/21/6/chaos-kubernetes-kube-monkey +[7]: https://opensource.com/article/21/6/chaos-engineering-kubedoom +[8]: https://minikube.sigs.k8s.io/docs/start/ +[9]: https://opensource.com/article/20/5/helm-charts +[10]: https://opensource.com/article/21/6/chaos-grafana-prometheus +[11]: https://grafana.com/grafana/dashboards/10856 +[12]: https://opensource.com/sites/default/files/uploads/k8-cluster-detail-dashboard.png (K8 Cluster Detail Dashboard) +[13]: https://creativecommons.org/licenses/by-sa/4.0/ +[14]: https://opensource.com/sites/default/files/uploads/dashboard-steadystate.png (K8 Cluster Detail Dashboard) +[15]: https://opensource.com/sites/default/files/uploads/chaosmesh-experiment.png (Chaos Mesh Dashboard) +[16]: https://opensource.com/sites/default/files/uploads/grafana-state.png (Grafana) +[17]: https://opensource.com/sites/default/files/uploads/waitingcontainers.png (Grafana) +[18]: https://opensource.com/sites/default/files/uploads/grafana-state2.png (Grafana) +[19]: https://opensource.com/sites/default/files/uploads/chaosmesh-experiment2.png (Chaos Mesh Dashboard) +[20]: https://opensource.com/sites/default/files/uploads/grafana-change.png (Grafana) diff --git a/sources/tech/20210610 Install and remove software packages on FreeDOS.md b/sources/tech/20210610 Install and remove software packages on FreeDOS.md new file mode 100644 index 0000000000..075308fb72 --- /dev/null +++ b/sources/tech/20210610 Install and remove software packages on FreeDOS.md @@ -0,0 +1,113 @@ +[#]: subject: (Install and remove software packages on FreeDOS) +[#]: via: (https://opensource.com/article/21/6/freedos-package-manager) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Install and remove software packages on FreeDOS +====== +Get familiar with FDIMPLES, the FreeDOS package manager. +![Package wrapped with brown paper and red bow][1] + +On Linux, you may have used a _package manager_ to install or remove packages. For example, the default package manager on Debian Linux is the `deb` command, and the default package manager on Fedora Linux is the `dnf` command. But did you know that FreeDOS has a package manager, too? + +### Installing packages + +The FreeDOS 1.3 RC4 distribution includes lots of great programs and applications you can use. However, we don't install all of them by default—we don't want to fill your hard drive space unnecessarily, especially on older systems that may have hard drive capacities of only a few hundred megabytes. And if you selected the "Plain DOS system" option when you installed FreeDOS, you will find your FreeDOS system is quite small (about 20 megabytes). + +However, it's easy to install new packages. From the command line, run the `FDIMPLES` program. Because DOS is _case insensitive_, you can type this command using uppercase or lowercase letters: `fdimples` is the same as `FDIMPLES` or `FDImples`. + +![fdimples][2] + +The FDIMPLES package manager on FreeDOS 1.3 RC4 (running in QEMU) +(Jim Hall, [CC-BY SA 4.0][3]) + +FDIMPLES is an acronym for "**F**ree**D**OS **I**nstaller - **M**y **P**ackage **L**ist **E**ditor **S**oftware," and is an interactive package manager. FDIMPLES reads the installation media to identify packages that it can install or remove. If you see a different menu that says "Installed" but does not let you install other software, check that the FreeDOS install CD-ROM is loaded on your system. On a physical machine, you'll need to insert the CD-ROM into the CD-ROM drive; on a virtual machine like QEMU or VirtualBox, you'll need to associate the install CD-ROM image with the virtal machine. + +![fdimples installed][4] + +If you only see an "Installed" message, check that the CD-ROM is loaded +(Jim Hall, [CC-BY SA 4.0][3]) + +Let's say you wanted to install software that lets you play music and other sound files. Use the Up and Down arrow keys to navigate to the **Sound Tools** entry in the menu. This is called a _package group_ for the sound and music programs. + +![fdimples sound][5] + +Highlighting the Sound package group in FDIMPLES +(Jim Hall, [CC-BY SA 4.0][3]) + +To select all of the packages in this group, press the spacebar on your keyboard. Should you decide to install individual packages in this group, press the Tab key to move into the _package list_ pane, then select each package with the spacebar. + +![fdimples sound select][6] + +Select all the packages in a group by pressing the spacebar +(Jim Hall, [CC-BY SA 4.0][3]) + +You can continue to select other packages or package groups that you want to install. When you have selected everything, use the Tab key to highlight the **OK** button, and press the spacebar. + +![fdimples sound select ok][7] + +Highlight the "Ok" button when you're ready to install +(Jim Hall, [CC-BY SA 4.0][3]) + +FDIMPLES then installs all of the packages you selected. This may only take a few moments if you selected only a couple of small packages, or it could take minutes if you asked to install many larger packages. As it installs each package, FDIMPLES prints the status. Afterward, FDIMPLES exits to the command line, so you can get back to work. + +![fdimples sound install done][8] + +FDIMPLES shows the progress as its installs packages, and automatically exits when done +(Jim Hall, [CC-BY SA 4.0][3]) + +### Removing packages + +What if you install a package, only to discover afterward that you don't want it? Removing packages is just as easy in FDIMPLES. + +Just as when installing packages, start FDIMPLES, and use the arrow keys to navigate to the group that contains the packages you want to remove. For example, if I wanted to uninstall a few of the music-player packages I installed earlier, I would navigate to the **Sound Tools** package group. + +![fdimples sound select][9] + +Navigate to the group with the packages you want to remove +(Jim Hall, [CC-BY SA 4.0][3]) + +To remove the entire package group at once, you can press the spacebar on the group you want to remove to unselect it. But let's say I only wanted to remove a few packages that I didn't need, like the **CDP** audio CD player. (I don't have any physical music CDs.) To remove CDP, hit the Tab key to move into the package list pane, then use the spacebar to unselect the CDP package. This removes the **X** on that package. + +![fdimples unselect cdp][10] + +Unselect a package to remove it +(Jim Hall, [CC-BY SA 4.0][3]) + +You can continue to unselect other packages or package groups that you want to remove. When you have selected everything, use the Tab key to highlight the **OK** button, and press the spacebar. FDIMPLES will remove the packages you unselected, then automatically returns you to the command line. + +![fdimples cdp removed][11] + +FDIMPLES removes the package, then returns to the command line +(Jim Hall, [CC-BY SA 4.0][3]) + +We include many packages in FreeDOS, across a variety of package groups. Use FDIMPLES to install the software you need. Feel free to experiment! If you decide you don't want to keep a package, you can remove it and free up your disk space for other things. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/freedos-package-manager + +作者:[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/brown-package-red-bow.jpg?itok=oxZYQzH- (Package wrapped with brown paper and red bow) +[2]: https://opensource.com/sites/default/files/uploads/fdimples.png (The FDIMPLES package manager on FreeDOS 1.3 RC4 (running in QEMU)) +[3]: https://creativecommons.org/licenses/by-sa/4.0/ +[4]: https://opensource.com/sites/default/files/uploads/fdimples-installed.png (If you only see an "Installed" message, check that the CD-ROM is loaded) +[5]: https://opensource.com/sites/default/files/uploads/fdimples-sound.png (Highlighting the Sound package group in FDIMPLES) +[6]: https://opensource.com/sites/default/files/uploads/fdimples-sound-select.png (Select all the packages in a group by pressing the spacebar) +[7]: https://opensource.com/sites/default/files/uploads/fdimples-sound-select-ok.png (Highlight the "Ok" button when you're ready to install) +[8]: https://opensource.com/sites/default/files/uploads/fdimples-sound-select-ok-install4.png (FDIMPLES shows the progress as its installs packages, and automatically exits when done) +[9]: https://opensource.com/sites/default/files/uploads/fdimples-sound-select_0.png (Navigate to the group with the packages you want to remove) +[10]: https://opensource.com/sites/default/files/uploads/fdimples-unselect-cdp.png (Unselect a package to remove it) +[11]: https://opensource.com/sites/default/files/uploads/fdimples-unselect-cdp-removed.png (FDIMPLES removes the package, then returns to the command line) diff --git a/sources/tech/20210611 How hypertext can establish application state in REST.md b/sources/tech/20210611 How hypertext can establish application state in REST.md new file mode 100644 index 0000000000..2dc4c4627b --- /dev/null +++ b/sources/tech/20210611 How hypertext can establish application state in REST.md @@ -0,0 +1,109 @@ +[#]: subject: (How hypertext can establish application state in REST) +[#]: via: (https://opensource.com/article/21/6/hateoas) +[#]: author: (Alex Bunardzic https://opensource.com/users/alex-bunardzic) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +How hypertext can establish application state in REST +====== +The Hypertext As The Engine Of Application State architectural style +supports non-brittle, resilient systems that enable risk-free changes. +![diagram of planning a cloud][1] + +HATEOAS is a difficult-to-pronounce acronym that stands for "[Hypertext As The Engine Of Application State][2]." Invented by [Roy Fielding][3] in the year 2000, HATEOAS was proposed as an architectural style for network-based software systems. + +The central concept of this architectural style is [hypertext][4]. With hypertext, we have encoded content that may also imply action. Each action, in turn, implies a change of state. HATEOAS represents the mechanism that can be used to control the transition from one application state to another application state. Its name contains the word Engine, based on the assumption that hypertext could drive the transitions from state to state. + +### Why HATEOAS? + +There are several reasons why HATEOAS may be a desirable architectural style. Two main reasons are: + + 1. Late binding + 2. Uniform interface + + + +#### 1\. Late binding + +Brittle systems are invariably a sign of shoddy engineering. When we discover a brittle system, usually we learn that its constituent components and subsystems are tightly coupled (almost welded together). That tight coupling creates a lot of friction that produces a lot of "heat." No wonder such brittle systems are notorious for defective behavior, which is often perceived as malfunctioning. And those defects are typically very hard to troubleshoot and fix. + +But what causes tight coupling? In most cases, it is early binding. We sometimes refer to early binding as premature optimization (which, as the saying goes, is the root of all evil). So, to avoid designing and building brittle systems, we ought to avoid tight coupling, which in practical terms means we should avoid early binding or premature optimization. + +HATEOAS is a prime example of the extreme late-binding design style. Systems built with HATEOAS style are completely decoupled and not prematurely optimized, which gives them the flexibility to be changed safely at a drop of a hat. + +#### 2\. Uniform interface + +Interfaces between the client and the server act as a unifying agent that obfuscates the need for a client to assume or understand the resource structure. A uniform interface relieves clients from having to understand anything about the servers. + +Also, a uniform interface fully separates identification from interaction. In a uniform interface, a resource that is implemented on the backend is identified by a unique resource identifier (URI). A client interested in the services rendered by the back-end resource only needs to know the starting endpoint (the home URI). A client need not know any details about how to interact with the resource. + +As is also the case with late binding, a uniform interface provides resilient, non-brittle solutions. A system built with HATEOAS style retains the freedom to radically revamp its structure without disturbing its clients in the least. + +### In-band and out-of-band information + +Another important concept related to HATEOAS is in-band vs. out-of-band access to information. If a caller (e.g., a client) needs to manipulate a resource (e.g., a server), the client's intention must somehow be translated into the implementation. If the client knows WHAT they want to do or accomplish, their next concern becomes: HOW to do it. + +There are two ways that this knowledge of how to do something could be implemented: + + * Client needs to go out of their way to obtain the how-to information (out-of-band) + * Client is given the how-to information by the resource (in-band) following the just-in-time communications model + + + +Because HATEOAS is a late-bound, uniform-interface style of design, it serves the how-to information in-band. This means a calling client need not learn any details of how to interact with the resource before initiating the interaction. + +In contrast, a traditional remote procedure call (RPC) design hinges on the out-of-band arrangement—a calling client must obtain details needed to interact with the server before initiating the interaction. In other words, it is not sufficient for the calling client to know how to begin the interaction with the server; the client is also expected to know all the necessary details before making precise calls needed for obtaining desired services. + +This upfront knowledge that the calling client must possess before making any calls to the server renders the system extremely brittle. Clients and the server are tightly coupled; the server is not at liberty to modify its API at will and must go the extra mile to maintain backward compatibility. + +Part of the in-band design philosophy of HATEOAS is self-descriptive messages. Clients do not have to know anything about the server state; a self-descriptive message represents the important points that the client needs to continue interacting with the server. + +That arrangement further loosens any possible coupling between the client (the caller) and the server. + +### How does HATEOAS work? + +There is no difference between how the HTML works and how HATEOAS works. When we browse the web, we start from an entry point—a URL. The first step in web browsing consists of instructing the web browser to send the HTTP GET request to the specified URL. + +Upon receiving that HTTP GET request, the back-end resource (the server) replies with an HTTP response. That HTTP response contains both the data and possibly (and most likely) the network operations that can be enacted on that data. These network operations are encoded as hypertext links. If we then click on one of those links, we enact a network operation: the browser sends, on our behalf, another HTTP request (it could be a GET request, or a POST request, etc.). + +The salient point in this description of the mundane web-browsing experience is that we, the clients, don't have to know anything in advance about the structure implemented on the server. All we know is the hypertext links that the server sends to us in the form of a resource representation (the HTML document). + +Replace a web browser with a computer program, and you get the picture of how HATEOAS works. A client (e.g., a computer program) obtains the entry point of the resource (the endpoint of the API). The client then programmatically sends the HTTP GET request to the resource and receives the HTTP response. In the response, the client will find one or more hypertext links. It is those hypertext links that enable the calling program to make the change in the application state. The client makes that change by sending another HTTP request using the in-band details found in the resource representation—the HTML document. + +Step-by-step, the interaction between the client and the server continues in this fashion. + +### What are the advantages of HATEOAS? + +In addition to the above advantages (a non-brittle, resilient system that invites risk-free changes), HATEOAS enables building systems that are: + + * Performant + * Scalable + * Reliable + * Simple to understand + * Transparent + * Portable + + + +These advantages are made possible by the stateless nature of the systems built using the HATEOAS style. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/hateoas + +作者:[Alex Bunardzic][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/alex-bunardzic +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BIZ_darwincloud_520x292_0311LL.png?itok=74DLgd8Q (diagram of planning a cloud) +[2]: https://en.wikipedia.org/wiki/HATEOAS +[3]: https://en.wikipedia.org/wiki/Roy_Fielding +[4]: https://en.wikipedia.org/wiki/Hypertext 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 new file mode 100644 index 0000000000..4afe36aa36 --- /dev/null +++ b/sources/tech/20210611 How to use the FreeDOS text editor.md @@ -0,0 +1,96 @@ +[#]: 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/20210612 How I teach Python on the Raspberry Pi 400 at the public library.md b/sources/tech/20210612 How I teach Python on the Raspberry Pi 400 at the public library.md new file mode 100644 index 0000000000..1480f69fe7 --- /dev/null +++ b/sources/tech/20210612 How I teach Python on the Raspberry Pi 400 at the public library.md @@ -0,0 +1,92 @@ +[#]: subject: (How I teach Python on the Raspberry Pi 400 at the public library) +[#]: via: (https://opensource.com/article/21/6/teach-python-raspberry-pi) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +How I teach Python on the Raspberry Pi 400 at the public library +====== +After a long year of putting plans on hold, declining COVID case numbers +are bringing back community-based programming courses. +![Women programming][1] + +After a long and tough year, I've been looking forward to once again sharing my love of Python and open source software with other people, especially middle and high school students. Before the pandemic, I co-wrote a grant to teach Python programming to middle school students using Raspberry Pi computers. Like many other plans, COVID-19 put mine on hold for over a year. Fortunately, vaccines and the improved health in my state, New York, have changed the dynamic. + +A couple of months ago, once I became fully vaccinated, I offered to self-fund a Raspberry Pi and Python programming course in our local public library system. The [Chautauqua-Cattaraugus Library system][2] accepted my proposal, and the co-central library in Olean, N.Y., offered to fund my program. The library purchased five [Raspberry Pi 400][3] units, Micro-HDMI-to-VGA adapters, and inline power adapters, and the library system's IT department loaned us five VGA monitors. + +With all our equipment needs met, we invited middle school students to enroll for four afternoons of learning and programming fun. + +All the students were socially distanced, each with a new Pi 400 and VGA monitor at their desk. Our class was small, made up of a fourth-grade student and two sixth-grade students. None had a programming background, and their keyboarding skills were rough. However, their innate curiosity and enthusiasm carried the day. + +### Learning and iterating + +We spent the first afternoon assembling the Pi 400s, connecting them to the library's wireless network, and installing the [Mu Python editor][4], which we used for the class. + +![Raspberry Pi 400 equipment][5] + +(Don Watkins, [CC BY-SA 4.0][6]) + +I followed this with a brief introduction to Raspberry Pi OS and how it differs from Windows and macOS computers and offered a brief tutorial on using the Mu editor. + +Since we were meeting in a public library, I emphasized that the library has books covering the concepts and Python programming code used in the class, especially [_Teach Your Kids to Code_][7] by Dr. Bryson Payne and [_Python for Kids_][8] by Jason Briggs. I created daily handouts for the students to refer to alongside the instruction. I also used my own Raspberry PI 400 connected to a 32" LCD monitor to illustrate the code and programming results. + +![Raspberry Pi 400 setup][9] + +(Don Watkins, [CC BY-SA 4.0][6]) + +I like to use the [turtle module to introduce Python][10] programming. It's always been well received, and the students love the graphics they can create while learning Python basics like variables, [`for` loops][11], lists, and the importance of syntax. + +I learn something new every time I teach, and this was no exception. I especially enjoy watching students iterate on my code examples—some are from books, and others are my own creations. The fourth-grader in our class took this example code and added two more colors and corresponding code to create a six-color spiral. + + +``` +# multicolor spiral +import turtle as t +colors = ["red", "yellow", "blue", "green"] +for x in range(100): +    t.pencolor(colors[x%4]) +    t.circle(x) +    t.left(91) +``` + +![Spiral graphic created in Python][12] + +(Don Watkins, [CC BY-SA 4.0][6]) + +At the end of the four-day course, each student received a Raspberry Pi 400 and a book explaining how to program their computer. They also got a list of free and open source software resources, a reading list of recommended books available in the library, and some open educational resources available on the web. + +### Open learning + +Mark Van Doren said, "the art of teaching is the art of assisting discovery." I saw that play out in this classroom using open source tools. More students need opportunities like this to help them gain a quality education. The Raspberry Pi 400 is a great form factor for teaching and learning. + +The [Olean Library][13] plans to offer another similar course later this year. I encourage you to share your love of free and open source software with your own communities. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/teach-python-raspberry-pi + +作者:[Don Watkins][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/collab-team-pair-programming-code-keyboard2.png?itok=WnKfsl-G (Women programming) +[2]: https://www.cclsny.org/ +[3]: https://opensource.com/article/21/3/raspberry-pi-400-review +[4]: https://opensource.com/article/18/8/getting-started-mu-python-editor-beginners +[5]: https://opensource.com/sites/default/files/uploads/pi400_library.jpg (Raspberry Pi 400 equipment) +[6]: https://creativecommons.org/licenses/by-sa/4.0/ +[7]: https://opensource.com/education/15/9/review-bryson-payne-teach-your-kids-code +[8]: https://nostarch.com/pythonforkids +[9]: https://opensource.com/sites/default/files/uploads/pi400_library-teacher.jpg (Raspberry Pi 400 setup) +[10]: https://opensource.com/article/17/10/python-101#turtle +[11]: https://opensource.com/article/18/3/loop-better-deeper-look-iteration-python +[12]: https://opensource.com/sites/default/files/uploads/pi400-spiral.jpg (Spiral graphic created in Python) +[13]: https://www.oleanlibrary.org/ diff --git a/sources/tech/20210614 13 open source tools for developers.md b/sources/tech/20210614 13 open source tools for developers.md new file mode 100644 index 0000000000..7546d5fd32 --- /dev/null +++ b/sources/tech/20210614 13 open source tools for developers.md @@ -0,0 +1,159 @@ +[#]: subject: (13 open source tools for developers) +[#]: via: (https://opensource.com/article/21/6/open-source-developer-tools) +[#]: author: (Nimisha Mukherjee https://opensource.com/users/nimisha) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +13 open source tools for developers +====== +Choose tools that provide maximum flexibility in software integration +and delivery. +![Tools in a cloud][1] + +Modern developers are highly technical, opinionated, passionate, community-focused, driven, polyglot, and most importantly, empowered decision-makers. Today, developers have a say in the products being built and the tools and technologies used to build them. Most importantly, time is precious, and developers and project managers can always benefit from great efficiency. To attain great efficiency, though, you must understand the software lifecycle, and how it can be organized and manipulated. + +The industry is still working on perfecting how a developer's time is spent. We can divide a developer's major tasks into two different "loops": + + * **Inner loop:** These are the most common tasks developers do, the ones that fully utilize their skillsets: code, run, validate, and debug. This is the classical developer loop. + + + +![Inner loop developer tasks][2] + +(Nimisha Mukherjee, [CC BY-SA 4.0][3]) + + * **Outer loop:** This is where a developer's code goes through continuous integration and continuous delivery (CI/CD) and gets deployed to production. On Gitlab and similar platforms, a developer's pull request (PR) gets merged to the main branch, CI/CD kicks in and creates the build, runs the necessary tests, and deploys to the specified environments. This is a DevOps loop. + + + +![Outer loop developer tasks][4] + +(Nimisha Mukherjee, [CC BY-SA 4.0][3]) + +Developers should spend most of their effort on inner-loop tasks, driving innovation, and minimal time on the outer loop. + +Understanding the differences between the inner and outer loops can help identify the developer tools that work best for each part of the software lifecycle. + +### Open source inner-loop tools + +Here are some of my favorite open source tools for the _code, run, validate, and debug_ cycle. + +#### Code + + * [Eclipse Che][5] makes Kubernetes development accessible for developer teams. Che provides an in-browser integrated development environment (IDE), allowing developers to code, build, test, and run applications from any machine exactly as they run in production. + * [Visual Studio Code][6] (VS Code) and [VSCodium][7] are open source code editors with support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git. + + + +#### Run + + * [OpenShift Do][8] (odo) is a command-line interface for developers that supports fast, iterative development, allowing them to focus on what's most important to them: code. + * [Minishift][9] helps developers run [OKD][10] (the community distribution of Kubernetes) locally by launching a single-node OKD cluster inside a virtual machine. Minishift allows trying out OKD or developing with it, day-to-day, on a local machine. + * Eclipse Che + + + +#### Validate + + * Eclipse Che + * Odo + * [VS Code Dependency Analytics][11] is an open source vulnerability database. + + + +#### Deploy + + * Eclipse Che + * Odo + + + +### Learn more + +There are many workflows to implement a good coding cycle. To get an idea of how developers are using these tools, read Daniel Oh's article about how he uses [Quark for serverless application development][12] and Bryan Son's article about [how his team uses Eclipse Che][13]. + +### Open source outer-loop tools + +There are great open source tools that make it easier to send code through CI/CD and deploy it to production. + +#### CI/CD + + * [Tekton][14] is an open source framework for creating CI/CD systems, allowing developers to build, test, and deploy. + * [Jenkins][15] is a free and open source automation server. It helps automate the parts of software development related to building, testing, and deploying to facilitate CI/CD. + + + +#### Build + + * [Shipwright][16] is an extensible framework for building container images on Kubernetes. + * [Eclipse JKube][17] is a collection of plugins and libraries used to build container images using Docker, Jib, or OpenShift Source-to-Image (S2I) build strategies. + + + +#### Run + + * [CodeReady Containers][18] (CRC) manages a local OpenShift 4.x cluster optimized for testing and development purposes. + + + +#### Monitor + + * [Prometheus][19] provides event monitoring and alerting. + + + +#### Deploy + + * Tekton + * Jenkins + * [Helm][20] is a package manager for Kubernetes. + * [Argo CD][21] is a declarative, GitOps continuous delivery tool for Kubernetes. It makes application deployment and lifecycle management automated, auditable, and easy to understand. + + + +### Learn DevOps + +If you're keen to implement a DevOps strategy, you can get started with Jess Cherry's article on how to [use Minishift and Jenkiins to setup your first pipeline][22]. + +### Make it easy + +Today, developers choose the tools and technologies used in software integration and delivery. If you're a developer, then choose open source tools for maximum flexibility. If you're a project manager or architect, choose open source tools to help your developers succeed by working less and getting more done. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/open-source-developer-tools + +作者:[Nimisha Mukherjee][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/nimisha +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cloud_tools_hardware.png?itok=PGjJenqT (Tools in a cloud) +[2]: https://opensource.com/sites/default/files/uploads/innerloop.png (Inner loop developer tasks) +[3]: https://creativecommons.org/licenses/by-sa/4.0/ +[4]: https://opensource.com/sites/default/files/uploads/outerloop.png (Outer loop developer tasks) +[5]: https://www.eclipse.org/che/ +[6]: https://code.visualstudio.com/ +[7]: https://opensource.com/article/20/6/open-source-alternatives-vs-code#vscodium +[8]: https://docs.openshift.com/container-platform/4.4/cli_reference/developer_cli_odo/understanding-odo.html +[9]: https://www.okd.io/minishift/ +[10]: https://www.okd.io/ +[11]: https://marketplace.visualstudio.com/items?itemName=redhat.fabric8-analytics +[12]: https://opensource.com/article/21/5/edge-quarkus-linux +[13]: https://opensource.com/article/19/10/cloud-ide-che +[14]: https://tekton.dev/ +[15]: https://www.jenkins.io/ +[16]: https://shipwright.io/ +[17]: https://projects.eclipse.org/projects/ecd.jkube +[18]: https://github.com/code-ready/crc +[19]: https://prometheus.io/ +[20]: https://helm.sh/ +[21]: https://argoproj.github.io/argo-cd/ +[22]: https://opensource.com/article/20/11/minishift-linux diff --git a/sources/tech/20210614 Fedora Classroom- RPM Packaging 101.md b/sources/tech/20210614 Fedora Classroom- RPM Packaging 101.md new file mode 100644 index 0000000000..c643c165af --- /dev/null +++ b/sources/tech/20210614 Fedora Classroom- RPM Packaging 101.md @@ -0,0 +1,103 @@ +[#]: subject: (Fedora Classroom: RPM Packaging 101) +[#]: via: (https://fedoramagazine.org/fedora-classroom-rpm-packaging-101/) +[#]: author: (Ankur Sinha "FranciscoD" https://fedoramagazine.org/author/ankursinha/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Fedora Classroom: RPM Packaging 101 +====== + +![Fedora classroom on RPM packaging][1] + +Fedora Classroom sessions return with a session on RPM packaging targeted at beginners. + +### About the session + +RPMs are the smallest building blocks of the Fedora Linux system. This session will walk through the basics of building an RPM from source code. You will learn how to set up your Fedora system to build RPMs, how to write a spec file that adheres to the [Fedora Packaging Guidelines][2], and how to use it to generate RPMs for distribution. The session will also provide a brief overview of the complete Fedora packaging pipeline. + +While no prior knowledge of building RPMs or building software from its source code is required, some software development experience will be useful. The hope is to help users learn the skills required to build and maintain RPM packages, and to encourage them to contribute to Fedora by joining the package collection maintainers. + +### When and where + +The classroom session will be organised on the BlueJeans video platform at 1200 UTC on June 17, 2021 and is expected to last an hour: + + * BlueJeans event URL: + * [Fedora calendar entry][3] (Click to see the event in your local time zone and add it to your calendar application). + + + +### Topics covered in the session + + * The basics of a spec file. + * Source and binary RPMs and how they are built from the spec using rpmbuild. + * A brief introduction to mock and fedpkg. + * The life cycle of a Fedora package. + * How you can join the Fedora package collection maintainers. + + + +### Prerequisites + + * A Fedora installation (Workstation or any lab/spin) + * The following software should be installed and configured: + * **git** + +``` +sudo dnf install git +``` + + * **fedora-packager +** + +``` +sudo dnf install fedora-packager +``` + + * **mock** (configured as per [these instructions][4]) + + + + +### Useful reading + + * [RPM packages explained][5] + * [How RPM packages are made: the spec file][6] + * [How RPM packages are made: the source RPM][7] + + + +### About the instructor + +[Ankur Sinha][8] has been maintaining packages in Fedora for more than a decade and is currently both a sponsor to the package maintainers group, and a [proven packager][9]. Ankur primarily focuses on maintaining neuroscience related software for the [NeuroFedora Special Interest Group][10] and contributes to other parts of the community wherever possible. + +Fedora Classroom is a project aimed at spreading knowledge on Fedora related topics. If you would like to propose a session, feel free to open a ticket [here][11] with the tag _classroom_. If you are interested in taking a proposed session, please let us know and once you take it, you will be awarded the [Sensei][12] Badge too as a token of appreciation. Recordings from the previous sessions can be found [here][13]. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/fedora-classroom-rpm-packaging-101/ + +作者:[Ankur Sinha "FranciscoD"][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/ankursinha/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2021/06/fedora-magazing-rpm-classroom-816x345.png +[2]: https://docs.fedoraproject.org/en-US/packaging-guidelines/ +[3]: https://calendar.fedoraproject.org/meeting/10002/ +[4]: https://fedoraproject.org/wiki/Using_Mock_to_test_package_builds#How_do_I_use_Mock.3F +[5]: https://fedoramagazine.org/rpm-packages-explained/ +[6]: https://fedoramagazine.org/how-rpm-packages-are-made-the-spec-file/ +[7]: https://fedoramagazine.org/how-rpm-packages-are-made-the-source-rpm/ +[8]: https://fedoraproject.org/wiki/User:Ankursinha +[9]: https://docs.fedoraproject.org/en-US/fesco/Provenpackager_policy/ +[10]: https://neuro.fedoraproject.org +[11]: https://pagure.io/fedora-join/Fedora-Join/issues +[12]: https://badges.fedoraproject.org/badge/sensei/ +[13]: https://www.youtube.com/playlist?list=PL0x39xti0_64FBQ7mcFt7uBXpG8EA7OF1 diff --git a/sources/tech/20210614 Install FreeDOS without the installer.md b/sources/tech/20210614 Install FreeDOS without the installer.md new file mode 100644 index 0000000000..79a27899a9 --- /dev/null +++ b/sources/tech/20210614 Install FreeDOS without the installer.md @@ -0,0 +1,158 @@ +[#]: subject: (Install FreeDOS without the installer) +[#]: via: (https://opensource.com/article/21/6/install-freedos-without-installer) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Install FreeDOS without the installer +====== +Here's how to set up your FreeDOS system manually without using the +installer. +![FreeDOS fish logo and command prompt on computer][1] + +Most people should be able to install FreeDOS 1.3 RC4 very easily using the installer. The FreeDOS installer asks a few questions, then takes care of the rest—including making space for FreeDOS and making the system bootable. + +But what if the installer doesn't work for you? Or what if you prefer to set up your FreeDOS system _manually_, without using the installer? With FreeDOS, you can do that too! Let's walk through the steps to install FreeDOS without using the installer. I'll do all of these steps using the QEMU virtual machine, using a blank hard drive image. I created a one hundred megabyte ("100M") hard drive image with this Linux command: + + +``` +`$ qemu-img create freedos.img 100M` +``` + +I downloaded the FreeDOS 1.3 RC4 installation LiveCD as FD13LIVE.iso, which provides a "live" environment where I can run FreeDOS, including all the standard tools. Most users also use the LiveCD to install FreeDOS with the regular installer, but here I'll only use the LiveCD to install FreeDOS using individual commands from the command line. + +I started the virtual machine with this rather long QEMU command, and selected the "Use FreeDOS 1.3 in Live Environment mode" boot menu entry: + + +``` +`$ qemu-system-x86_64 -name FreeDOS -machine pc-i440fx-4.2,accel=kvm,usb=off,dump-guest-core=off -enable-kvm -cpu host -m 8 -overcommit mem-lock=off -no-user-config -nodefaults -rtc base=utc,driftfix=slew -no-hpet -boot menu=on,strict=on -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny -msg timestamp=on -hda freedos.img -cdrom FD13LIVE.iso -device sb16 -device adlib -soundhw pcspk -vga cirrus -display sdl -usbdevice mouse` +``` + +![manual install][2] + +Select "Use FreeDOS 1.3 in Live Environment mode" to boot the LiveCD +(Jim Hall, [CC-BY SA 4.0][3]) + +That QEMU command line includes a bunch of options that may seem confusing at first. You configure QEMU entirely with command-line options, so there is a lot to examine here. But I'll briefly highlight a few important options: + + * `-m 8:` Set the system memory ("RAM") to 8 megabytes + * **`-boot menu=on,strict=on:`** Use a boot menu, so I can select if I want to boot from the CD-ROM image or the hard drive image + * **`-hda freedos.img`:** Use **freedos.img** as the hard drive image + * `-cdrom FD13LIVE.iso:`Use **FD13LIVE.iso** as the CD-ROM image + * **`-device sb16 -device adlib -soundhw pcspk`:** Define the machine with a SoundBlaster16 sound card, AdLib digitial music card, and PC speaker emulation (these are useful if you want to play DOS games) + * **`-usbdevice mouse`:** Recognize the user's mouse as a USB mouse (click in the QEMU window to use the mouse) + + + +### Partition the hard drive + +You can use FreeDOS 1.3 RC4 from the LiveCD, but if you want to install FreeDOS to your computer, you'll first need to make space on the hard drive. This requires creating a _partition_ with the FDISK program. + +From the DOS command line, type `FDISK` to run the _fixed disk_ setup program. FDISK is a full-screen interactive program, and you only need to type a number to select a menu item. From the main FDISK menu, enter "1" to create a DOS partition on the drive, then enter "1" on the next screen to create a _primary_ DOS partition. + +![using fdisk][4] + +Select "1" to create a partition +(Jim Hall, [CC-BY SA 4.0][3]) + +![using fdisk][5] + +Select "1" on the next menu to make a primary partition +(Jim Hall, [CC-BY SA 4.0][3]) + +FDISK asks you if you wish to use the full size of the hard disk to create the partition. Unless you need to share space on this hard drive with another operating system, such as Linux, you should answer "Y" to this prompt. + +After FDISK creates the new partition, you'll need to reboot before DOS can recognize the new partition information. Like all DOS operating systems, FreeDOS identifies the hard drive information only when it boots up. So if you create or delete any disk partitions, you'll need to reboot so FreeDOS recognizes the changed partition information. FDISK reminds you to reboot, so you don't forget. + +![using fdisk][6] + +You need to reboot to recognize the new partition +(Jim Hall, [CC-BY SA 4.0][3]) + +You can reboot by stopping and restarting the QEMU virtual machine, but I prefer to reboot FreeDOS from the FreeDOS command line, using the FreeDOS Advanced Power Management (FDADPM) tool. To reboot, type the command `FDADPM /WARMBOOT` and FreeDOS reboots itself. + +### Formatting the hard drive + +After FreeDOS restarts, you can continue setting up the hard drive. Creating the disk partition was "step 1" in this process; now you need to make a DOS _filesystem_ on the partition so FreeDOS can use it. + +DOS systems identify "drives" using the letters `A` through `Z`. FreeDOS recognizes the first partition on the first hard drive as the `C` drive, and so on. You often indicate the drive with the letter and a colon (`:`) so the new partition we created above is actually the `C:` drive. + +You can create a DOS filesystem on the new partition with the FORMAT command. This command takes a few options, but we'll only use the `/S` option to tell FORMAT to make the new filesystem bootable—the "S" means to install the FreeDOS "System" files. Type `FORMAT /S C:` to make a new DOS filesystem on the `C:` drive. + +![formatting the disk][7] + +Format the partition to create the DOS filesystem +(Jim Hall, [CC-BY SA 4.0][3]) + +With the `/S` option, FORMAT will run the SYS program to transfer the system files. You'll see this as part of the output from FORMAT: + +![formatting the disk][8] + +FORMAT /S will use SYS to make the disk bootable +(Jim Hall, [CC-BY SA 4.0][3]) + +### Installing software + +Having created a new partition with FDISK and a new filesystem with FORMAT, the new `C:` drive is basically empty. At this point, the `C:` drive only contains a copy of the kernel and the `COMMAND.COM` command-line shell. To do anything useful with the new disk, we need to install software on it. This is the last step for the manual install process. + +The FreeDOS 1.3 RC4 LiveCD contains all of the software you might want to install on the new system. Each FreeDOS program is available as a separate "package," which is really just a Zip archive file. The packages that set up the standard DOS environment are stored in the `BASE` directory, under the `PACKAGES` directory on the LiveCD. + +You could install the packages by "unzipping" each of them to the hard drive, one at a time. With 62 individual packages in the "Base" group, installing each package individually would take a very long time. However, you can run a one-line `FOR` "loop" command to "unzip" each program. Then FreeDOS can "unzip" all of the packages for you. + +The basic usage of the `FOR` loop indicates a single-letter variable (let's use `%F`) that FreeDOS uses to "fill in" the filename later. The `FOR` also requires a list of files in brackets and the command that it should run against each of the files. The syntax to unzip a list of Zip files looks like this: + + +``` +`FOR %F IN (*.ZIP) DO UNZIP %F` +``` + +This extracts all of the Zip files into the current directory. To extract or "unzip" the files into a different location, use the `-d` ("destination") option at the end of the `UNZIP` command line. For most FreeDOS systems, you will want to install the software packages to the `C:\FDOS` directory: + +![installing the software][9] + +Unzip all of the Base packages to finish installing FreeDOS +(Jim Hall, [CC-BY SA 4.0][3]) + +FreeDOS takes care of the rest, installing all 62 packages to your system. This may take several minutes because DOS can be slow when working with lots of individual files—and this command needs to extract 62 Zip files. The installation process would run a lot faster if we used a single `BASE.ZIP` archive file, but using packages provides more flexibility in what software you might want to install versus what you choose to leave out. + +![installing the software][10] + +After installing all the Base packages +(Jim Hall, [CC-BY SA 4.0][3]) + +After you've installed everything, reboot your system with `FDADPM /WARMBOOT`. Installing manually means your new FreeDOS system won't have the usual `FDCONFIG.SYS` configuration file, so FreeDOS will assume a few typical default values when it starts up. Without the `AUTOXEC.BAT` file, FreeDOS also prompts you for the time and date. + +![rebooting FreeDOS][11] + +Rebooting FreeDOS after a manual install +(Jim Hall, [CC-BY SA 4.0][3]) + +Most users should be able to use the more user-friendly process to install FreeDOS on a new computer. But if you want to install it yourself the "old school" way, you can also run the installation steps manually. This can provide some additional flexibility and control because you install everything yourself. And now you know how to do it. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/install-freedos-without-installer + +作者:[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/freedos-fish-laptop-color.png?itok=vfv_Lpph (FreeDOS fish logo and command prompt on computer) +[2]: https://opensource.com/sites/default/files/uploads/manual-install3.png (Select "Use FreeDOS 1.3 in Live Environment mode" to boot the LiveCD) +[3]: https://creativecommons.org/licenses/by-sa/4.0/ +[4]: https://opensource.com/sites/default/files/uploads/manual-install6.png (Select "1" to create a partition) +[5]: https://opensource.com/sites/default/files/uploads/manual-install7.png (Select "1" on the next menu to make a primary partition) +[6]: https://opensource.com/sites/default/files/uploads/manual-install10.png (You need to reboot to recognize the new partition) +[7]: https://opensource.com/sites/default/files/uploads/manual-install13.png (Format the partition to create the DOS filesystem) +[8]: https://opensource.com/sites/default/files/uploads/manual-install14.png (FORMAT /S will use SYS to make the disk bootable) +[9]: https://opensource.com/sites/default/files/uploads/manual-install18.png (Unzip all of the Base packages to finish installing FreeDOS) +[10]: https://opensource.com/sites/default/files/uploads/manual-install24.png (After installing all the Base packages) +[11]: https://opensource.com/sites/default/files/uploads/manual-install28.png (Rebooting FreeDOS after a manual install) diff --git a/sources/tech/20210615 Keep track of your IRC chats with ZNC.md b/sources/tech/20210615 Keep track of your IRC chats with ZNC.md new file mode 100644 index 0000000000..73d4fd5f0c --- /dev/null +++ b/sources/tech/20210615 Keep track of your IRC chats with ZNC.md @@ -0,0 +1,132 @@ +[#]: subject: (Keep track of your IRC chats with ZNC) +[#]: via: (https://opensource.com/article/21/6/irc-matrix-bridge-znc) +[#]: author: (John 'Warthog9' Hawley https://opensource.com/users/warthog9) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Keep track of your IRC chats with ZNC +====== +Create a bridge between IRC and Matrix. +![Chat bubbles][1] + +For a bit more than a year, I've been wondering if it is possible to bolt the open source [Matrix][2] communications network to Internet Relay Chat (IRC) in such a way that I can still use my [ZNC][3] IRC bouncer without an extra proliferation of nicknames. The answer, is amusingly, yes. But first, some background. + +### What's IRC? + +IRC has been around since August 1988, and it's been a staple of real-time communications ever since. It's also one of the early open source projects, as the code for the original IRC server was eventually shared. Over the years, it's been quite useful for meeting many developers' real-time communication needs, although not without its own share of drama. However, it has been resilient and is still widely used despite newer options. + +### Enter the bouncer + +ZNC solves a specific problem on IRC: IRC is intentionally a very ephemeral system, so no state is saved. When you log into an IRC server, you get nothing except what is happening right then—nothing before, and once you leave, nothing after. This contrasts with more modern systems that give historical context, scrollback, searchability, etc. + +Some of this can be handled by clients that are left on continuously, but that's not ideal. Enter the IRC bouncer. A bouncer acts as a middleman to the IRC connection. It connects to IRC and can log in on the user's behalf. It can then relay chats back out to the client (or, in many cases, clients). This can make it seem like a user is always on, which gives some context. + +Many folks who use IRC use either a bouncer or a client that runs long-term to keep that context going. ZNC is a relatively popular and well-understood bouncer for IRC. Other services like [IRCCloud][4] can provide this and other features bolted around IRC to make the experience more pleasant and usable. + +### Building bridges + +Matrix is a newer standard that isn't really a program or a codebase. It's actually a protocol definition that lends itself particularly well to bridging other protocols and provides a framework for real-time encrypted chat. One of its reference implementations is called Synapse, and it happens to be a pretty solid base from which to build. It has a rich set of prebuilt [bridges][5], including Slack, Gitter, XMPP, and email. While not all features translate everywhere, the fact that so many good bridges exist speaks to a great community and a robust protocol. + +### The crux of the matter + +I've been on IRC for 26 or 27 years; my clients are set up the way I like, and I'm used to interacting with it in certain ways on certain systems. This is great until I want to start interfacing with IRC when I have Matrix, [Mattermost][6], [Rocket.Chat][7], or other systems running. Traditionally, this meant I ended up with an extra nickname every time I logged into IRC. After a while, username[m], username[m]1, username[m]2, and so forth start looking old. Imagine everyone trying to do this, and you understand that this eventually gets untenable. + +I've been running a Matrix server with bridges. So why can't I bridge ZNC into Matrix and get the best of all worlds? + +It's doable with some prerequisites and prep work (which I won't cover in detail, but there's documentation out there should you wish to set this up for yourself). + + * You need a Matrix server, I'm using [Synapse][8], and it's what I'm going to assume going forward. You will also need admin privileges and access to the low-level system. + * You need a [ZNC server][3] up and running or a bouncer that acts like ZNC (although your mileage will vary if you aren't using ZNC). You just need a ZNC account; you don't need admin privileges. + * You need a copy of Heisenbridge, an IRC bridge for Matrix that works differently from a normal IRC bridge. It's possible to run both simultaneously; I am, and the [Heisenbridge README][9] will help you do the same. You'll likely want to run Heisenbridge on the same system you're running Synapse, although it's not required. + + + +I'll assume you have Synapse and a working IRC bouncer set up and working. Now comes the fun part: bolting Heisenbridge into place. Follow the Heisenbridge install guide, except before you restart Synapse and start Heisenbridge, you'll want to make a couple of small changes to the configuration file generated during setup. That config file will look something like this: + + +``` +id: heisenbridge +url: +as_token: alongstringtoken +hs_token: anotherlongstringtoken +rate_limited: false +sender_localpart: heisenbridge +namespaces: + users: + - regex: '@irc_.*' +   exclusive: true + aliases: [] + rooms: [] +``` + + * Change the port it will use because `9898` is also preferred by other bridges. I chose `9897`. As long as it is the same in Synapse and the bridge, it doesn't matter what you use. + * In the `namespaces` section, take note of the regex for the users. The `matrix-appservice-irc` system uses the same regex, and having both of them run in the same namespace causes issues. I changed mine from `@irc_` to `@hirc`. + * You need to add `@heisenbridge:your.homeserver.tld` to the admin list on your server. The easiest way to do this is to start up Heisenbridge once, turn it off, and then edit the database to give the user admin privileges (i.e., set `admin=1` on that user). Then restart Heisenbridge. + + + +My updated config file looks like this: + + +``` +id: heisenbridge +url: +as_token: alongstringtoken +hs_token: anotherlongstringtoken +rate_limited: false +sender_localpart: heisenbridge +namespaces: + users: + - regex: '@hirc_.*' +   exclusive: true + aliases: [] + rooms: [] +``` + +Then, restart Synapse, start Heisenbridge, and go from there. I started mine using: + + +``` +`python3 -m heisenbridge -c /path/to/heisenbridge.yaml -p 9897` +``` + +Next, talk to the Heisenbridge user on your home server and set up a network and a server for your bouncer. + +If you want to add a server, there are some options that aren't documented. If you want to add a server name and host, issue: + + +``` +`addserver networkname hostname portnumber --tls` +``` + +Open the network as your user. You'll be invited to a room where you can set the password for the network login (this is likely needed for ZNC), and then you can connect. + +> **Security warning:** The password will be stored in clear text, so don't use passwords you don't mind being stored this way, and don't do this on machines you don't trust. + +After you hit **Connect**, you should get a flurry of activity as your IRC bouncer pushes its state into Matrix. That should do it! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/irc-matrix-bridge-znc + +作者:[John 'Warthog9' Hawley][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/warthog9 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/talk_chat_communication_team.png?itok=CYfZ_gE7 (Chat bubbles) +[2]: https://matrix.org/ +[3]: https://wiki.znc.in/ZNC +[4]: https://www.irccloud.com/ +[5]: https://matrix.org/bridges/ +[6]: https://mattermost.com/ +[7]: http://rocket.chat/ +[8]: https://matrix.org/docs/projects/server/synapse +[9]: https://github.com/hifi/heisenbridge diff --git a/sources/tech/20210615 Listen to music on FreeDOS.md b/sources/tech/20210615 Listen to music on FreeDOS.md new file mode 100644 index 0000000000..35431d0388 --- /dev/null +++ b/sources/tech/20210615 Listen to music on FreeDOS.md @@ -0,0 +1,99 @@ +[#]: subject: (Listen to music on FreeDOS) +[#]: via: (https://opensource.com/article/21/6/listen-music-freedos) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Listen to music on FreeDOS +====== +Mplayer is an open source media player that's usually found on Linux, +Windows, Mac, and DOS. +![Woman programming][1] + +Music is a great way to relax. On Linux, I listen to music using Rhythmbox. But did you know you can listen to music on FreeDOS, as well? Let's take a look at two popular programs to listen to music: + +### Listen to music with Mplayer + +[Mplayer][2] is an open source media player that's usually found on Linux, Windows, and Mac—but there's a DOS version available, too. And that's the version we include in FreeDOS. While the DOS port is based on an older version (version 1.0rc2-3-3-2 from 2007) it is perfectly serviceable for playing media on DOS. + +I use Mplayer to listen to music files on FreeDOS. For this example, I've copied one of my favorite audiobooks, Doctor Who: Flashpoint by [Big Finish Productions][3], and saved it as `C:\MUSIC\FLASHPNT.MP3` on my FreeDOS computer. To listen to Flashpoint on FreeDOS, I launch Mplayer from the FreeDOS command line and specify the MP3 filename to play. The basic usage of Mplayer is `mplayer [options] filename` so if the default settings work well for you, then you can just launch Mplayer with the filename. In this case, I ran these commands to change my working directory to `\MUSIC` and then run Mplayer with my MP3 audiobook file: + + +``` +CD \MUSIC +MPLAYER FLASHPNT.MP3 +``` + +FreeDOS is _case insensitive_, so it will accept uppercase or lowercase letters for DOS commands and any files or directories. You could also type `cd \music` or `Cd \Music` to move into the Music directory, and that would work the same. + +![mplayer on FreeDOS][4] + +You can use Mplayer to listen to MP3 files +(Jim Hall, [CC-BY SA 4.0][5]) + +Using Mplayer is a "no frills" way to listen to music files on FreeDOS. But at the same time, it's not distracting, so I can leave FreeDOS to play the MP3 file on my DOS computer while I use my other computer to do something else. However, FreeDOS runs tasks one at a time (in other words, DOS is a "single-tasking" operating system) so I cannot run Mplayer in the "background" on FreeDOS while I work on something else _on the same FreeDOS computer_. + +Note that Mplayer is a big program that requires a lot of memory to run. While DOS itself doesn't require much RAM to operate, I recommend at least 16 megabytes of memory to run Mplayer. + +### Listen to audio files with Open Cubic Player + +FreeDOS offers more than just Mplayer for playing media. We also include the [Open Cubic Player][6], which supports a variety of file formats including Midi and WAV files. + +In 1999, I recorded a short audio file of me saying, "Hello, this is Jim Hall, and I pronounce 'FreeDOS' as _FreeDOS_." This was meant as a joke, riffing off of a [similar audio file][7] (`english.au`, included in the Linux source code tree in 1994) recorded by Linus Torvalds to demonstrate how he pronounces "Linux." We don't distribute the _FreeDOS_ audio clip in FreeDOS itself, but you are welcome to download it from our [Silly Sounds][8] directory, found in the FreeDOS files archive at [Ibiblio][9]. + +You can listen to the _FreeDOS_ audio clip using the Open Cubic Player. To run Open Cubic Player, you normally would run `CP` from the `\APPS\OPENCP` directory. However, Open Cubic Player is a 32-bit application that requires a 32-bit DOS extender. A common DOS extender is DOS/4GW. While free to use, DOS/4GW is not an open source program, so we do not distribute it as a FreeDOS package. + +Instead, FreeDOS provides another open source 32-bit extender called DOS/32A. If you did not install everything when you installed FreeDOS, you may need to install it using [FDIMPLES][10]. I used these two commands to move into the `\APPS\OPENCP` directory, and to run Open Cubic Player using the DOS/32A extender: + + +``` +CD \APPS\OPENCP +DOS32A CP +``` + +Open Cubic Player doesn't sport a fancy user interface, but you can use the arrow keys to navigate the _File Selector_ to the directory that contains the media file you want to play. + +![Open Cubic Player][11] + +Open Cubic Player opens with a file selector +(Jim Hall, [CC-BY SA 4.0][5]) + +The text appears smaller than in other DOS applications because Open Cubic Player automatically changes the display to use 50 lines of text, instead of the usual 25 lines. Open Cubic Player will reset the display back to 25 lines when you exit the program. + +When you have selected your media file, Open Cubic Player will play it in a loop. (Press the Esc key on your keyboard to quit.) As the file plays over the speakers, Open Cubic Player displays a spectrum analyzer so you can see the audio for the left and right channels. The _FreeDOS_ audio clip is recorded in mono, so the left and right channels are the same. + +![Open Cubic Player][12] + +Open Cubic Player playing the "FreeDOS" audio clip +(Jim Hall, [CC-BY SA 4.0][5]) + +DOS may be from an older era, but that doesn't mean you can't use FreeDOS to run modern tasks or play current media. If you like to listen to digital music, try using Open Cubic Player or Mplayer on FreeDOS. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/listen-music-freedos + +作者:[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/programming-code-keyboard-laptop-music-headphones.png?itok=EQZ2WKzy (Woman programming) +[2]: https://en.wikipedia.org/wiki/MPlayer +[3]: https://bigfinish.com/ +[4]: https://opensource.com/sites/default/files/uploads/mplayer.png (You can use Mplayer to listen to MP3 files) +[5]: https://creativecommons.org/licenses/by-sa/4.0/ +[6]: https://www.cubic.org/player/ +[7]: https://commons.wikimedia.org/wiki/File:Linus-linux.ogg +[8]: https://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/util/sillysounds/ +[9]: https://www.ibiblio.org/ +[10]: https://opensource.com/article/21/6/freedos-package-manager +[11]: https://opensource.com/sites/default/files/uploads/opencp1.png (Open Cubic Player opens with a file selector) +[12]: https://opensource.com/sites/default/files/uploads/opencp2.png (Open Cubic Player playing the "FreeDOS" audio clip) diff --git a/sources/tech/20210616 How to use FreeDOS as an embedded system.md b/sources/tech/20210616 How to use FreeDOS as an embedded system.md new file mode 100644 index 0000000000..7f32a2c807 --- /dev/null +++ b/sources/tech/20210616 How to use FreeDOS as an embedded system.md @@ -0,0 +1,155 @@ +[#]: subject: (How to use FreeDOS as an embedded system) +[#]: via: (https://opensource.com/article/21/6/freedos-embedded-system) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +How to use FreeDOS as an embedded system +====== +Many embedded systems today run on Linux. But once upon a time, embedded +systems either ran on a custom, proprietary platform or ran on DOS. +![Computer laptop in space][1] + +The [FreeDOS website][2] says that most people use FreeDOS for three main tasks: + + 1. Playing classic DOS games + 2. Running legacy DOS software + 3. Running an embedded system + + + +But what does it mean to run an "embedded" system? + +An embedded system is basically a very minimal system that is dedicated to run a specific task. You might think of embedded systems today as part of the _Internet of Things_ (IoT) including sensors, thermostats, and doorbell cameras. Many embedded systems today run on Linux. + +But once upon a time, embedded systems either ran on a custom, proprietary platform or ran on DOS. Some of these DOS-based embedded systems still run today, such as cash registers or phone private branch exchange (PBX) systems. In one example as recently as 2017, trainspotters discovered a Russian electric train control system (Russian: _САВПЭ_) running FreeDOS with special software to control and monitor the route of suburban trains and to make passenger announcements. + +Setting up an embedded system on DOS requires defining a minimal DOS environment that runs a single application. Fortunately, setting up a minimal FreeDOS environment is pretty easy. Technically, all you need to boot FreeDOS and run DOS applications is the kernel and a `FDCONFIG.SYS` configuration file. + +### Installing a minimal system + +We can simulate a dedicated, minimal FreeDOS system by using the QEMU emulator with very small allocations. To reflect an embedded system more accurately, I'll define a virtual machine with only 8 megabytes of memory and a mere 2 megabytes for a virtual hard drive. + +To create the tiny virtual hard drive, I'll use this `qemu-img` command to define a 2-megabyte file: + + +``` +$ qemu-img create tiny.img 2M +Formatting 'tiny.img', fmt=raw size=2097152 +``` + +This command line defines a 32-bit "i386" CPU with 8 megabytes of memory, using the 2-megabyte `tiny.img` file as the hard drive image and the FreeDOS 1.3 RC4 LiveCD as the CD-ROM media. We'll also set the machine to boot from the CD-ROM drive (`-boot order=d`) although we only need that to install. We'll boot the completed embedded system from the hard disk after we've set everything up: + + +``` +qemu-system-i386 -m 8 -hda tiny.img -cdrom FD13LIVE.iso -boot order=d +``` + +Boot the system using the "Live Environment mode"—this provides us with a running FreeDOS system that we can use to transfer a minimal FreeDOS to the hard disk. + +![embedded setup][3] + +Boot into the LiveCD environment +(Jim Hall, [CC-BY SA 4.0][4]) + +We'll need to create a partition on the virtual hard drive for our programs. To do that, run the FDISK program from the command line. FDISK is the standard _fixed disk_ utility on FreeDOS. Use FDISK to create a single hard drive partition that spans the entire (2-megabyte) hard drive. + +![embedded setup][5] + +FDISK, after creating the 2 megabyte partition +(Jim Hall, [CC-BY SA 4.0][4]) + +But FreeDOS won't see the new hard drive partition until you reboot—FreeDOS only reads the hard disk details at startup. Exit FDISK and reboot, and you'll be ready for the next step. + +After rebooting, you need to create a DOS filesystem on the new hard drive. Since there's just the one virtual hard disk, FreeDOS will identify it as the `C:` drive. You can create a DOS filesystem on `C:` with the FORMAT command. The `/S` option transfers the operating system files (the kernel, plus a copy of the `COMMAND.COM` shell) to the new drive. + +![embedded setup][6] + +Format the new drive to create a DOS filesystem +(Jim Hall, [CC-BY SA 4.0][4]) +  + +Now that you've created the drive and formatted it, you can install the application that will run on the embedded system. + +### Installing the dedicated application + +An embedded system is really just a single-purpose application running on a dedicated system. Such applications are usually custom-built for the system it will control, such as a cash register, display terminal, or control environment. For this demonstration, let's use a program from the FreeDOS 1.3 RC4 installation CD-ROM. It needs to be small enough to fit in the tiny 2-megabyte hard drive we've created for it. This can be anything—so just for fun, let's make it a game. + +FreeDOS 1.3 RC4 includes several fun games. One game that I like is a board game called Simple Senet. It's based on Senet, an ancient Egyptian board game. The details of the game aren't important for this demonstration, except that we'll install it and set it up as the dedicated application for the embedded system. + +To install the application, go into the `\PACKAGES\GAMES` directory on the FreeDOS 1.3 RC4 LiveCD. You'll see a long list of packages there, and the one we want is `SENET.ZIP`. + +![embedded setup][7] + +A list of game packages from FreeDOS 1.3 RC4 +(Jim Hall, [CC-BY SA 4.0][4]) + +To unzip the Simple Senet package onto the virtual hard drive, use the `UNZIP` command. All FreeDOS packages are Zip files, so you can use any Zip-compatible archive utility to manage them. FreeDOS 1.3 RC4 includes `ZIP` to create Zip archives, and `UNZIP` to extract Zip archives. Both are from the [Info-Zip Project][8]. + + +``` +`UNZIP SENET.ZIP -d C:\FDOS` +``` + +Normally, using `UNZIP` will extract a Zip file in the current directory. The `-d C:\FDOS` option at the end of the command line tells `UNZIP` to extract the Zip file to the `C:\FDOS` directory. (`-d` means "destination.") + +![embedded setup][9] + +Unzipping the Simple Senet game +(Jim Hall, [CC-BY SA 4.0][4]) + +To run the Simple Senet game whenever the embedded system boots, we need to tell FreeDOS to use Senet as the system "shell." The default FreeDOS shell is the `COMMAND.COM` program, but you can define a different shell program using the `SHELL=` directive in the `FDCONFIG.SYS` kernel configuration file. We can use FreeDOS Edit to create the new `C:\FDCONFIG.SYS` file. + +![Embedded edit senet][10] + +(Jim Hall, [CC-BY SA 4.0][4]) + +If you need to define other parameters to support the embedded system, you can add those to the `FDCONFIG.SYS` file. For example, you might need to set environment variables using the `SET` action, or tune the FreeDOS kernel with `FILES=` or `BUFFERS=` statements. + +### Run the embedded system + +With the embedded system fully defined, we can now reboot the machine to run the embedded application. Running an embedded system usually requires only limited resources, so for this demonstration, we'll tweak the QEMU command line to only boot from the hard drive (`-boot order=c`) and not define a CD-ROM drive: + + +``` +qemu-system-i386 -m 8 -hda tiny.img -boot order=c +``` + +When the FreeDOS kernel starts up, it reads the `FDCONFIG.SYS` file for its startup parameters. Then it runs the shell using the `SHELL=` line. That runs the Simple Senet game automatically. + +![embedded setup][11] + +Running Simple Senet as an embedded system +(Jim Hall, [CC-BY SA 4.0][4]) + +We've used Simple Senet to demonstrate how to set up an embedded system on FreeDOS. Depending on your needs, you can use whatever standalone application you like. Define it as the DOS shell using the `SHELL=` line in `FDCONFIG.SYS` and FreeDOS will automatically launch the application at boot-time. + +However, there's one limitation here. Embedded systems do not usually need to exit back to a command prompt, so these dedicated applications don't usually allow the user to quit to DOS. If you manage to exit the embedded application, you'll likely see a "Bad or missing Command Interpreter" prompt, where you'll need to enter the full path to a new shell. For a user-focused desktop system, this would be a problem. But on an embedded system that's dedicated to doing only one job, you should never need to exit anyway. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/freedos-embedded-system + +作者:[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/computer_space_graphic_cosmic.png?itok=wu493YbB (Computer laptop in space) +[2]: https://www.freedos.org/ +[3]: https://opensource.com/sites/default/files/uploads/embedded-setup02.png (Boot into the LiveCD environment) +[4]: https://creativecommons.org/licenses/by-sa/4.0/ +[5]: https://opensource.com/sites/default/files/uploads/embedded-setup09.png (FDISK, after creating the 2 megabyte partition) +[6]: https://opensource.com/sites/default/files/uploads/embedded-setup19.png (Format the new drive to create a DOS filesystem) +[7]: https://opensource.com/sites/default/files/uploads/games-dir.png (A list of game packages from FreeDOS 1.3 RC4) +[8]: http://infozip.sourceforge.net/ +[9]: https://opensource.com/sites/default/files/uploads/senet-unzip.png (Unzipping the Simple Senet game) +[10]: https://opensource.com/sites/default/files/pictures/embedded-edit-senet.png (Embedded edit senet) +[11]: https://opensource.com/sites/default/files/uploads/senet.png (Running Simple Senet as an embedded system) diff --git a/sources/tech/20210616 Set up a service mesh on Istio.md b/sources/tech/20210616 Set up a service mesh on Istio.md new file mode 100644 index 0000000000..637687bb8e --- /dev/null +++ b/sources/tech/20210616 Set up a service mesh on Istio.md @@ -0,0 +1,139 @@ +[#]: subject: (Set up a service mesh on Istio) +[#]: via: (https://opensource.com/article/21/6/service-mesh-serverless) +[#]: author: (Daniel Oh https://opensource.com/users/daniel-oh) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Set up a service mesh on Istio +====== +A quick example of going serverless on Knative. +![Net catching 1s and 0s or data in the clouds][1] + +Service mesh and serverless deployment models represent the next phase in the evolution of microservice architectures. Service mesh enables developers to focus on business feature development rather than managing non-functional microservices capabilities such as monitoring, tracing, fault tolerance, and service discovery. + +[Open source service mesh][2] projects, including [Istio][3], [LinkerD][4], and [Kuma][5], use a sidecar, a dedicated infrastructure layer built right into an app, to implement service mesh functionalities. So, for example, developers can improve monitoring and tracing of cloud-native microservices on a distributed networking system using [Jaeger to build an Istio service mesh][6]. + +![CNCF Service Mesh Landscape][7] + +CNCF Service Mesh Landscape (Source: [CNCF][2]) + +In this next phase of implementing service mesh in microservices, developers can advance their serverless development using an event-driven execution pattern. It's not just a brand-new method; it also tries to modernize business processes from 24x7x365 uptime to on-demand scaling. Developers can leverage the traits and benefits of serverless deployment by using one of the [open source serverless projects][8] shown below. For example, [Knative][9] is a faster, easier way to develop serverless applications on Kubernetes platforms. + +![CNCF Serverless Landscape][10] + +CNCF Serverless Landscape (Source: [CNCF][8]) + +Imagine combining service mesh and serverless for more advanced cloud-native microservices development and deployment. This combined architecture allows you to configure additional networking settings, such as custom domains, mutual Transport Layer Security (mTLS) certificates, and JSON Web Token authentication. + +Here is a quick example of setting up service mesh on Istio with serverless on Knative Serving. + +### 1\. Add Istio with sidecar injection + +When you install the Istio service mesh, you need to set the `autoInject: enabled` configuration for automatic sidecar injection: + + +``` +    global: +      proxy: +        autoInject: enabled +``` + +If you'd like to learn more, consult Knative's documentation about [installing Istio without and with sidecar injection][11]. + +### 2\. Enable a sidecar for mTLS networking + +To use mTLS network communication between a `knative-serving` namespace and another namespace where you want the application pod to be running, enable a sidecar injection: + + +``` +`$ kubectl label namespace knative-serving istio-injection=enabled` +``` + +You also need to configure `PeerAuthentication` in the `knative-serving namespace`: + + +``` +cat <<EOF | kubectl apply -f - +apiVersion: "security.istio.io/v1beta1" +kind: "PeerAuthentication" +metadata: +  name: "default" +  namespace: "knative-serving" +spec: +  mtls: +    mode: PERMISSIVE +EOF +``` + +If you've installed a local gateway for Istio service mesh and Knative, the default cluster gateway name will be `knative-local-gateway` for the Knative service and application deployment. + +### 3\. Deploy an application for a Knative service + +Create a Knative service resource YAML file (e.g., `myservice.yml`) to enable sidecar injection for a Knative service. + +Add the `sidecar.istio.io/inject="true"` annotation to the service resource: + + +``` +apiVersion: serving.knative.dev/v1 +kind: Service +metadata: +  name: hello-example-1 +spec: +  template: +    metadata: +      annotations: +        sidecar.istio.io/inject: "true" (1) +        sidecar.istio.io/rewriteAppHTTPProbers: "true" (2) +    spec: +      containers: +      - image: docker.io/sample_application (3) +        name: container +``` + +In the code above: + +(1) Adds the sidecar injection annotation. +(2) Enables JSON Web Token (JWT) authentication. +(3) Replace the application image with yours in an external container registry (e.g., DockerHub, Quay.io). + +Apply the Knative service resource above: + + +``` +`$ kubectl apply -f myservice.yml` +``` + +Note: Be sure to log into the right namespace in the Kubernetes cluster to deploy the sample application. + +### Conclusion + +This article explained the benefits of service mesh and serverless deployment for the advanced cloud-native microservices architecture. You can evolve existing microservices to service mesh or serverless step-by-step, or you can combine them to handle more advanced application implementation with complex networking settings on Kubernetes. However, this combined architecture is still in an early stage due to the architecture's complexity and lack of use cases. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/service-mesh-serverless + +作者:[Daniel Oh][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/daniel-oh +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_analytics_cloud.png?itok=eE4uIoaB (Net catching 1s and 0s or data in the clouds) +[2]: https://landscape.cncf.io/card-mode?category=service-mesh&grouping=category +[3]: https://istio.io/docs/concepts/what-is-istio/ +[4]: https://linkerd.io/ +[5]: https://kuma.io/ +[6]: https://opensource.com/article/19/3/getting-started-jaeger +[7]: https://opensource.com/sites/default/files/uploads/cncf-service-mesh-landscape.png (CNCF Service Mesh Landscape) +[8]: https://landscape.cncf.io/serverless?category=service-mesh&grouping=category&zoom=200 +[9]: https://opensource.com/article/19/4/enabling-serverless-kubernetes +[10]: https://opensource.com/sites/default/files/uploads/cncf-serverless-landscape2.png (CNCF Serverless Landscape) +[11]: https://knative.dev/docs/install/installing-istio/#installing-istio-without-sidecar-injection diff --git a/sources/tech/20210616 Top 5 Chrome-like Browsers That Are Better Than Google Chrome in 2021.md b/sources/tech/20210616 Top 5 Chrome-like Browsers That Are Better Than Google Chrome in 2021.md new file mode 100644 index 0000000000..d0de8fbccf --- /dev/null +++ b/sources/tech/20210616 Top 5 Chrome-like Browsers That Are Better Than Google Chrome in 2021.md @@ -0,0 +1,200 @@ +[#]: subject: (Top 5 Chrome-like Browsers That Are Better Than Google Chrome in 2021) +[#]: via: (https://news.itsfoss.com/chrome-like-browsers-2021/) +[#]: author: (Jacob Crume https://news.itsfoss.com/author/jacob/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Top 5 Chrome-like Browsers That Are Better Than Google Chrome in 2021 +====== + +Want to switch away from Google? But, looking for something potentially better than Google Chrome (and similar) for your Linux system? + +Fortunately, there are multiple Google Chrome alternatives that you can try. + +Each of them brings something interesting to the table, while also keeping the fantastic compatibility Chrome is known for. Read on to find out more about these browsers. + +### Options That Are Better Than Google Chrome + +**Note:** _While [free and open-source software plays a crucial role in replacing big tech][1], any choice available on Linux other than Google Chrome should be a good start. Hence, you will find some non-FOSS options as well._ + +In my opinion, the best alternatives to Chrome are Chromium-based, meaning that they share the same DNA with Chrome. The advantage of this is that they already have feature parity with Chrome, while having more time to add their own. + +Also, if you want, you can explore [opensource alternatives to Chrome][2] that are not based on Chromium. + +In any case, even if the alternatives to Google Chrome do not seem superior to you, it is worth a try to move away from Big Tech. + +The result of this is a collection of browsers that are equal or better than Chrome in various aspects. Without further ado, here are my top five picks for Chrome-like browsers that are better than Chrome itself: + + * **UnGoogled Chromium** + * **Brave** + * **Microsoft Edge** + * **Vivaldi** + * **Opera** + + + +This list is in no order of ranking. + +### 1\. UnGoogled Chromium + +![][3] + +**Features:** + + * Removal of functionality specific to Google domains. + * Blocking of internal requests to Google at runtime. + * Stripping Google binaries from the source code. + * Many new command-line switches and `chrome://flags` entries. + * Forces all pop-ups into tabs. + + + +For the privacy fans out there, this browser will be a godsend. While it may look identical to Chrome, it has many privacy tweaks under-the-hood. + +As the name suggests, the biggest setback for Chrome users will be the absence of Google’s service integrations. This also means no more internal requests to Google, Google URL tracking, and much more. + +It does not boast anything extraordinary to protect your privacy, but it should be better than Google Chrome. + +You can choose to explore and toggle privacy settings at will through the Chrome flags settings as well. + +All-in-all, UnGoogled Chromium provides a familiar browsing experience, with a suite of privacy features added in as well. It is reliable and is also compatible with the large ecosystem of Chrome extensions. + +[UnGoogled Chromium][4] + +### 2\. Brave + +![][3] + +**Features:** + + * Built-in ad blocker. + * Faster page loading times. + * Brave rewards program. + * Ability to synchronise between devices. + * Chrome web store support. + + + +When Brave first marched onto the stage in 2016, people around the world were gawking at its privacy and performance features. At launch, these included a built-in ad-blocker and a new UI. + +Since then, the browser has gained many more features, including a rewards program and [Tor][5] integration. This has led it to become one of the fastest-growing browsers. + +[Brave][6] + +### 3\. Microsoft Edge + +![][3] + +**Features:** + + * Chrome Web Store support + * Child browsing mode (additional protection and simpler UI) + * Good PDF editing tools + * Built-in coupon finder + * Reader Mode + * Built-in password generator + + + +When Microsoft Edge first released alongside Windows 10 in 2015, it was widely criticized for being slow and buggy. However, in early 2020 it was completely remade using the Chromium web engine. + +This is the same engine Chrome is based on. The result of this is a modern and fast browsing experience. One perk of this transition is the web browser’s ability to run on many different platforms, from Windows 7 and macOS to Ubuntu and other Linux-based distros. + +I know, if you hate Microsoft for some reason, this may not entice you – but Microsoft Edge for Linux is a serious alternative to Google Chrome. + +[Microsoft Edge (Beta)][7] + +### 4\. Vivaldi + +![][3] + +**Features:** + + * Built-in translator + * Vivaldi Email (Beta) + * Feed Reader (Beta) + * Vivaldi Calendar (Beta) + * Highly customizable UI + * Built-in Ad Blocker + * Chrome Web Store support + * Tab grouping + * Split-screen tabs + + + +First released in 2016, Vivaldi has quickly risen the ranks in browser wars. Originally designed for Opera users disgruntled by its transition from the [Presto][8] [layout engine][9], it has managed to re-implement many of the features lost during Opera’s transition to Chromium. + +Amazingly, it has managed to do this all while being based on Chromium (the very reason Opera dropped these features). + +The latest [Vivaldi 4.0 release][10] also turned the tables with several features for power users. + +While it isn’t 100% FOSS, 93% of its source code is available, with only the UI being proprietary. Considering Vivaldi’s development team actively focus on Linux users for improvement, this could be a worthy tradeoff due to the sheer number of features Vivaldi offers. + +[Vivaldi][11] + +### 5\. Opera + +![][3] + +**Features:** + + * Built-in VPN + * Easy access to social media + * Built-in cryptocurrency wallet + * Fraud and malware protection + * Highly visible website security badge + + + +While it has never been the king of web browsers, Opera has always been present in the debate over which browser to use. Originally based on its in-house Presto Layout Engine, it switched over to Chromium in 2013. + +Unfortunately, this switch meant that the Opera team was forced to drop some of its most well-known features, paving the way for alternatives such as Vivaldi and Firefox to fill the space Opera had left. + +That isn’t to say that Opera is without features. It contains many, some of which are listed below. + +[Opera][12] + +### Wrapping Up + +Here we have listed a wide variety of browsers tailored to all kinds of users on any desktop platform. + +No matter whether you want more features, a better user interface, or something that helps you get away from Google, there is an option for you. + +Since all these browsers are based on Chromium, they all offer a good compatibility and user experience like Chrome. So, switch to one of these Chrome-like browsers and enjoy the freedom that each of them grants! + +_What’s your favorite alternative to Google Chrome on Linux in 2021? Let me know in the comments down below._ + +#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You! + +If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software. + +I'm not interested + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/chrome-like-browsers-2021/ + +作者:[Jacob Crume][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/jacob/ +[b]: https://github.com/lujun9972 +[1]: https://news.itsfoss.com/save-privacy-with-foss/ +[2]: https://itsfoss.com/open-source-browsers-linux/ +[3]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQxNiIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4= +[4]: https://github.com/Eloston/ungoogled-chromium +[5]: https://itsfoss.com/tor-guide/ +[6]: https://brave.com +[7]: https://www.microsoftedgeinsider.com/en-us/download +[8]: https://en.wikipedia.org/wiki/Presto_(browser_engine) +[9]: https://en.wikipedia.org/wiki/Browser_engine +[10]: https://news.itsfoss.com/vivaldi-4-0-release/ +[11]: https://vivaldi.com +[12]: https://www.opera.com diff --git a/sources/tech/20210617 Linux package management with dnf.md b/sources/tech/20210617 Linux package management with dnf.md new file mode 100644 index 0000000000..5aa3c827b4 --- /dev/null +++ b/sources/tech/20210617 Linux package management with dnf.md @@ -0,0 +1,182 @@ +[#]: subject: (Linux package management with dnf) +[#]: via: (https://opensource.com/article/21/6/dnf-linux) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Linux package management with dnf +====== +Learn how to install packages on Linux with the dnf command, then +download our cheat sheet to keep the right command at your fingertips. +![Package wrapped with brown paper and red bow][1] + +Installing an application on a computer system is pretty simple. You copy files from an archive (like a .zip file) onto the target computer in a place the operating system expects there to be applications. Because many of us are accustomed to having fancy installer "wizards" to help us get software on our computers, the process seems like it should be technically more complex than it is. + +What _is_ complex, though, is the issue of what makes up an application. What users think of as a single application actually contains code borrowing from software libraries (i.e., `.so` files on Linux, `.dll` files on Windows, and `.dylib` on macOS) scattered throughout an operating system. + +So that users don't have to worry about that veritable matrix of interdependent code, Linux uses a **package management system** to track what application needs what library, and which library or application has security or feature updates, and what extra data files were installed with each software title. A package manager is, essentially, an installer wizard. They're easy to use, they provide both graphical interfaces and terminal-based interfaces, and they make your life easier. The better you know your distribution's package manager, the easier your life gets. + +### Installing applications on Linux + +If you're a casual desktop user who wants to install an application on Linux, then you may be looking for [GNOME Software][2], a desktop application browser. + +![Image of the GNOME Software application][3] + +It works as you'd expect: You click through its interface until you find an application that seems like it would be useful, and then you click the **Install** button. + +Alternately, you can open `.rpm` or `.flatpakref` packages downloaded from the web in GNOME Software for it to install them for you. + +If you're inclined toward controlling your computer with typed commands, read on! + +### Finding software with dnf + +Before you can install an application, you may need to confirm that it exists on your distribution's servers. Usually, searching for the common name of an application with `dnf` suffices. For instance, say you recently read [an article about Cockpit][4] and decide you want to try it. You could search for `cockpit` to verify that your distribution includes it: + + +``` +$ dnf search cockpit + Last metadata expiration check: 0:01:46 ago on Tue 18 May 2021 19:18:15 NZST. + ==== Name Exactly Matched: cockpit ==== + cockpit.x86_64 : Web Console for Linux servers + +==== Name & Summary Matched: cockpit == + cockpit-bridge.x86_64 : Cockpit bridge server-side component + cockpit-composer.noarch : Composer GUI for use with Cockpit + [...] +``` + +There's an exact match. The package listed as a match is called `cockpit.x86_64`, but the `.x86_64` part of the name only denotes the CPU architecture it's compatible with. By default, your system installs packages with matching CPU architectures, so you can ignore that extension. Therefore, you've confirmed that the package you're looking for is indeed called simply `cockpit`. + +Now you can confidently install it with `dnf install`. This step requires administrative privileges: + + +``` +`$ sudo dnf install cockpit` +``` + +More often than not, that's the typical `dnf` workflow: search and install. + +Sometimes, however, the results of `dnf search` aren't clear to you, or you want more information about a package than just its common name. There are a few relevant `dnf` subcommands, depending on what information you're after. + +### Package metadata + +If you feel like your search got you _close_ to the package you want, but you're just not sure yet, it's often helpful to take a look at the package's metadata, such as the project's URL and description. To get this info, use the pleasantly intuitive `dnf info` command: + + +``` +$ dnf info terminator +Available Packages +Name         : terminator +Version      : 1.92 +Release      : 2.el8 +Architecture : noarch +Size         : 526 k +Source       : terminator-1.92-2.el8.src.rpm +Repository   : epel +Summary      : Store and run multiple GNOME terminals in one window +URL          : +License      : GPLv2 +Description  : Multiple GNOME terminals in one window.  This is a project to produce +             : an efficient way of filling a large area of screen space with +             : terminals. This is done by splitting the window into a resizeable +             : grid of terminals. As such, you can  produce a very flexible +             : arrangements of terminals for different tasks. +``` + +This info dump tells you the version of the available package, which repository registered with your system provides it, the project's website, and a long description of what it does. + +### What package provides a file? + +Package names don't always match what you're looking for. For instance, suppose you're reading documentation telling you that you must install something called `qmake-qt5`: + + +``` +$ dnf search qmake-qt5 +No matches found. +``` + +The `dnf` database is extensive, so you don't have to restrict yourself to searches for exact matches. You can use the `dnf provides` command to learn whether anything provides what you're looking for as part of some larger package: + + +``` +$ dnf provides qmake-qt5 +qt5-qtbase-devel-5.12.5-8.el8.i686 : Development files for qt5-qtbase +Repo        : appstream +Matched from: +Filename    : /usr/bin/qmake-qt5 + +qt5-qtbase-devel-5.15.2-3.el8.x86_64 : Development files for qt5-qtbase +Repo        : appstream +Matched from: +Filename    : /usr/bin/qmake-qt5 +``` + +This confirms that the application `qmake-qt5` is a part of a package named `qt5-qtbase-devel`. It also tells you that the application gets installed to `/usr/bin`, so you know exactly where to find it once it's installed. + +### What files are included in a package? + +There are times when I find myself approaching `dnf` from a different angle entirely. Sometimes, I've already confirmed that an application is installed on my system; I just can't figure out how I got it. Other times, I know I have a specific package installed, but I'm not clear on exactly what that package put on my system. + +If you ever need to "reverse engineer" a package's payload, you can use the `dnf repoquery` command along with the `--list` option. This looks at the repository's metadata about a package and returns a list of all files provided by that package: + + +``` +$ dnf repoquery --list qt5-qtbase-devel +/usr/bin/fixqt4headers.pl +/usr/bin/moc-qt5 +/usr/bin/qdbuscpp2xml-qt5 +/usr/bin/qdbusxml2cpp-qt5 +/usr/bin/qlalr +/usr/bin/qmake-qt5 +/usr/bin/qvkgen +/usr/bin/rcc-qt5 +[...] +``` + +These lists can get long, so it helps to pipe the command through `less` or your favorite pager. + +### Removing an application + +Should you decide you no longer need an application installed on your system, you can use `dnf remove` to uninstall it, all of the files that were installed as part of its package, and any dependencies that are no longer necessary: + + +``` +`$ dnf remove bigapp` +``` + +Sometimes, dependencies get installed with one app and are later found useful by some other application you install. In the event that two packages require the same dependency, `dnf remove` does _not_ remove the dependency. It's not unheard of to end up with a stray package here and there after installing and uninstalling lots of applications. About once a year, I perform a `dnf autoremove` to clear out any unused packages: + + +``` +`$ dnf autoremove` +``` + +This isn't necessary, but it's a housecleaning step that makes me feel better about my computer. + +### Getting to know dnf + +The more you know about how your package manager works, the easier it is for you to install and query applications when necessary. Even if you're not a regular `dnf` user, it can be useful to know it when you find yourself interfacing with an RPM-based distro. + +Having graduated from `yum`, one of my favorite package managers is the `dnf` command. While I don't love all its subcommands, I find it to be one of the more robust package management systems out there. [**Download our `dnf` cheat sheet**][5] to get used to the command, and don't be afraid to try some new tricks with it. Once you get familiar with it, you might find it hard to use anything else. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/dnf-linux + +作者:[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/brown-package-red-bow.jpg?itok=oxZYQzH- (Package wrapped with brown paper and red bow) +[2]: https://wiki.gnome.org/Apps/Software +[3]: https://opensource.com/sites/default/files/gnome-software.png (The GNOME Software app) +[4]: https://opensource.com/article/20/11/cockpit-server-management +[5]: https://opensource.com/downloads/dnf-cheat-sheet diff --git a/sources/tech/20210617 Refactor your applications to Kubernetes.md b/sources/tech/20210617 Refactor your applications to Kubernetes.md new file mode 100644 index 0000000000..4e41b3bb01 --- /dev/null +++ b/sources/tech/20210617 Refactor your applications to Kubernetes.md @@ -0,0 +1,190 @@ +[#]: subject: (Refactor your applications to Kubernetes) +[#]: via: (https://opensource.com/article/21/6/tackle-diva-kubernetes) +[#]: author: (Yasu Katsuno https://opensource.com/users/yasu-katsuno) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Refactor your applications to Kubernetes +====== +Tackle-DiVA helps developers understand database operations and +transaction processes inside applications. +![Tips and gears turning][1] + +Application modernization developers must be able to understand database operations and transaction processes inside applications precisely. [Tackle-DiVA][2] (Data-intensive Validity Analyzer) is an open source data-centric Java application analysis tool in the [Konveyor Tackle project][3] that aims at refactoring applications to Kubernetes. + +This article gives an overview of Tackle-DiVA and presents example instructions and analysis results. + +### What is Tackle-DiVA? + +Tackle-DiVA is built using Java and Python and operated using a command-line interface. It imports target Java application source files and provides analysis results as files. + +![Tackle-DiVA operation][4] + +(Yasuharu Katsuno, [CC BY-SA 4.0][5]) + +Breaking down this diagram: + + * **Service entry inventory** analysis extracts a list of Java classes for implementing public APIs. + * **Database inventory** analysis exports a list of database tables operated by an application. + * **Transaction inventory** extracts a set of transaction processes. + * **Code-to-database dependency** analyzes which Java class operates which database table. + * The **database-to-database** and **transaction-to-transaction dependency** analyses find clues for transforming parallel executions. + * Finally, **transaction refactoring recommendation** analysis shows parallel executable transactions from original sequential executions. + + + +### Try it out! + +It is easy to get started with Tackle-DiVA. It makes full use of [Docker][6] containers, and the only prerequisite is a Docker-runnable environment, such as RedHat Enterprise Linux, Ubuntu, or macOS. + +Once you have Docker available on your machine, run: + + +``` +$ cd /tmp +$ git clone && tackle-diva +$ docker build . -t diva +``` + +This builds Tackle-DiVA and packs it as a Docker image. Tackle-DiVA is now ready to use on your machine. + +The next step is to prepare source codes of your target Java applications. I'll use the [DayTrader][7] application as an example: + + +``` +$ cd /tmp +$ git clone +``` + +The final step is to execute the `diva_docker` command by attaching the full directory path: + + +``` +$ cd /tmp/tackle-diva/distrib/bin/ +$ ./diva_docker /tmp/sample.daytrader7/ +``` + +This creates the `tackle-diva/distrib/output` directory and stores the analysis result files: + + +``` +$ ls /tmp/tackle-diva/distrib/output +contexts.yml            transaction.json        transaction_summary.dot +database.json           transaction.yml         transaction_summary.pdf +``` + +### Explore the analysis results + +Take a look at some analysis results for the DayTrader application. + +The **service entry inventory** result is stored in the `contexts.yml` file. It finds that the `TradeAppServlet.init class/method` plays a key role in service entries for the `login` and `register` actions: + + +``` +\- entry: +   methods: +  - "com.ibm.websphere.samples.daytrader.web.TradeAppServlet.init" + http-param: +   action: +  - "login" +\- entry: +   methods: +  - "com.ibm.websphere.samples.daytrader.web.TradeAppServlet.init" + http-param: +   action: +  - "register" +``` + +The **database inventory** analysis exports six database tables in the `database.json` file. These tables are used in the DayTrader application: + + +``` +{ + "/app": [ +   "orderejb", +   "holdingejb", +   "quoteejb", +   "accountejb", +   "keygenejb", +   "accountprofileejb" + ] +} +``` + +The **transaction inventory** analysis result is dumped into the `transaction.json` and `.yml` files, but it's better to check the `transaction_summary.pdf` file when looking through transactions. The following transaction consists of six SQL operations to two database tables: `holdingejb` and `orderejb`: + +![Tackle-DiVA transaction inventory][8] + +(Yasuharu Katsuno, [CC BY-SA 4.0][5]) + +The `transaction.json` and `.yml` files also contain **code-to-database dependency** analysis results. The following shows how the TradeDirect class invokes query operations to two database tables, `accountprofileejb` and `accountejb`: + + +``` +"stacktrace" : [ +  ... +  { +  "method" : "<src-method: < Source, +              Lcom/ibm/websphere/samples/daytrader/direct/TradeDirect, +              getStatement(Ljava/sql/Connection;Ljava/lang/String;) +              Ljava/sql/PreparedStatement; >>", +  "file" : "/app/daytrader-ee7-ejb/src/ +            main/java/com/ibm/websphere/ +            samples/daytrader/direct/TradeDirect.java", +  "position" : "TradeDirect.java [1935:15] -> [1935:41]" +  } +], +"sql" : "select * from accountprofileejb ap where ap.userid = ( +            select profile_userid from accountejb a where a.profile_userid=?)" +``` + +The **database-to-database dependency** analysis result is located in the `transaction_summary.dot `and `.pdf` files. The `accoutprofileejb` and `accoutejb` database tables have a mutual-query relationship: + +![Tackle-DiVA database-to-database dependency][9] + +(Yasuharu Katsuno, [CC BY-SA 4.0][5]) + +The **transaction-to-transaction dependency** analysis results are found in the `transaction_summary.dot` and `.pdf` files. Two transactions have a dependency on the `orderejb` database table. The upper transaction updates the table, and the lower transaction queries it: + +![Tackle-DiVA transaction-to-transaction dependency][10] + +(Yasuharu Katsuno, [CC BY-SA 4.0][5]) + +Finally, parallel executable transactions are shown in the `transaction_summary.dot` and `.pdf` files, resulting from the **transaction refactoring recommendation** analysis. In this example, two transactions in the lower part can be executed in parallel after the upper transaction processing completes, which helps keep data consistency due to no transaction dependencies: + +![Tackle-DiVA transaction refactoring recommendation][11] + +(Yasuharu Katsuno, [CC BY-SA 4.0][5]) + +### Learn more + +To learn more about application refactoring, check out the [Konveyor Tackle site][12], join the community, and access the source code on [GitHub][2]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/tackle-diva-kubernetes + +作者:[Yasu Katsuno][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/yasu-katsuno +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/gears_devops_learn_troubleshooting_lightbulb_tips_520.png?itok=HcN38NOk (Tips and gears turning) +[2]: https://github.com/konveyor/tackle-diva +[3]: https://www.konveyor.io/tackle +[4]: https://opensource.com/sites/default/files/uploads/tackle-diva_operation.png (Tackle-DiVA operation) +[5]: https://creativecommons.org/licenses/by-sa/4.0/ +[6]: https://opensource.com/resources/what-docker +[7]: https://github.com/WASdev/sample.daytrader7 +[8]: https://opensource.com/sites/default/files/uploads/tackle-diva_transaction-inventory.png (Tackle-DiVA transaction inventory) +[9]: https://opensource.com/sites/default/files/uploads/tackle-diva_dbtodb.png (Tackle-DiVA database-to-database dependency) +[10]: https://opensource.com/sites/default/files/uploads/tackle-diva_ttot.png (Tackle-DiVA transaction-to-transaction dependency) +[11]: https://opensource.com/sites/default/files/uploads/tackle-diva_transaction-refactoring.png (Tackle-DiVA transaction refactoring recommendation) +[12]: https://github.com/konveyor/tackle diff --git a/sources/tech/20210617 Why FreeDOS has 16 colors.md b/sources/tech/20210617 Why FreeDOS has 16 colors.md new file mode 100644 index 0000000000..60e6790e11 --- /dev/null +++ b/sources/tech/20210617 Why FreeDOS has 16 colors.md @@ -0,0 +1,128 @@ +[#]: subject: (Why FreeDOS has 16 colors) +[#]: via: (https://opensource.com/article/21/6/freedos-sixteen-colors) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Why FreeDOS has 16 colors +====== +Why does text only come in this limited palette, and why does FreeDOS +use those colors and shades, instead of some other colors? The answer, +like many things in technology, is because of history. +![Person typing on a 1980's computer][1] + +If you've looked carefully at FreeDOS, you've probably noticed that text only comes in a limited range of colors—sixteen text colors, and eight background colors. This is similar to how Linux displays text color—you might be able to change _what text colors are used_ in a Linux terminal, but you're still stuck with just sixteen text colors and eight background colors. + +![terminal colors][2] + +DOS text comes in 16 colors and 8 background colors +(Jim Hall, [CC-BY SA 4.0][3]) + +Why does text only come in this limited palette, and why does FreeDOS use _those_ colors and shades, instead of some other colors? The answer, like many things in technology, is because of _history_. + +### The origins of PC color + +To explain why text only comes in sixteen colors, let me tell you a story about the first IBM Personal Computer. Parts of this story may be somewhat apocryphal, but the basics are close enough. + +IBM released the Personal Computer 5150 (the "IBM PC") in 1981. The PC used a simple monitor screen that displayed text in green. Because this display only worked with one color, it was dubbed _monochrome_ (the "IBM 5151 monochrome display," with the IBM Monochrome Display Adapter card, or "MDA"). + +That same year, IBM released an updated version of the PC that sported an amazing technical achievement—color! The new IBM 5153 color display relied on a new IBM Color Graphics Adapter, or "CGA." And it is because of this original CGA that all DOS text inherited their colors. + +But before we go there, we first need to understand something about color. When we talk about colors on a computer screen, we're talking about mixing different values of the three _primary_ light colors—red, green, and blue. You can mix together different levels (or "brightnesses") of red, green, and blue light to create almost any color. Mix just red and blue light, and you get magenta. Mix blue and green, and you get cyan or aqua. Mix all colors equally, and you get white. Without any light colors, you see black (an absence of color). + +![light colors][4] + +Mix red, green, and blue light to get different colors +(Jim Hall, [CC-BY SA 4.0][3]) + +The IBM 5153 color display presented color to the user by lighting up tiny red, green, and blue phosphor dots on a cathode ray tube (a "CRT"). These tiny dots were arranged very close together and in a pattern where a triad of red, green, and blue dots would form a "pixel." By controlling which phosphor dots were lit at one time, the IBM 5153 color display could show different colored pixels. + +![CRT pixels][5] + +Each red, green, and blue triad is a single pixel +(Jim Hall, [CC-BY SA 4.0][3]) + +By the way, even modern displays use this combination of red, green, and blue dots to represent colors. The difference in modern computers is that instead of tiny phosphor dots, each pixel uses a triad of red, green, and blue LED lights—usually arranged side by side. The computer can turn each LED light on or off to mix the red, green, and blue colors in each pixel. + +![LCD pixels][6] + +Each red, green, and blue triad is a single pixel +(Jim Hall, [CC-BY SA 4.0][3]) + +### Defining CGA colors + +The IBM engineers realized they could display several colors by mixing each red, green, and blue pixels. In the simplest case, you could assume each red, green, and blue dot in a single-pixel was either "on" or "off." And as any computer programmer will tell you, you can represent "on" and "off" as binary—ones (1=on) and zeroes (0=off). + +Representing red, green, and blue with ones or zeroes means you can combine up to eight colors, from 000 (red, green, and blue are all off) to 111 (red, green, and blue are all on). Note that the bit pattern goes like "RGB," so RGB=001 is blue (only blue is on) and RGB=011 is cyan (both green and blue are on): + +| | | | | ----------- | | | 000 Black | | | 001 Blue | | | 010 Green | | | 011 Cyan | | | 100 Red | | | 101 Magenta | | | 110 Yellow | | | 111 White | + +But that's just the simplest case. A particularly clever IBM engineer realized you could double the number of colors from eight to sixteen simply by adding another bit. So instead of a bit pattern like RGB, we can use a bit pattern like iRGB. We'll call this extra "i" bit the "intensity" bit because if we set the "intensity" bit to 1 (on), then we'll light up the red, green, and blue phosphor dots at full brightness; if the "intensity" bit is 0 (off) we can use some mid-level brightness. + +And with that simple fix, now CGA could display sixteen colors! For the sake of simplicity, the IBM engineers referred to the high-intensity colors as the "bright" versions of the regular color names. So "red" pairs with "bright red," and "magenta" pairs with "bright magenta." + +| | | | | | | ------------ | | ------------------- | | | 0000 Black | | 1000 Bright Black | | | 0001 Blue | | 1001 Bright Blue | | | 0010 Green | | 1010 Bright Green | | | 0011 Cyan | | 1011 Bright Cyan | | | 0100 Red | | 1100 Bright Red | | | 0101 Magenta | | 1101 Bright Magenta | | | 0110 Yellow | | 1110 Bright Yellow | | | 0111 White | | 1111 Bright White | + +Oh no! But wait! This isn't actually sixteen colors. If you notice iRGB=0000 (black) and iRGB=1000 (bright black), they are both the same _black_. There's no color to make "bright," so they are just both regular black. This means we only have fifteen colors, not the sixteen we were hoping for. + +But IBM has clever engineers working for them, and they realized how to fix this to get sixteen colors. Rather than implement a straight RGB to iRGB, IBM actually implemented a _modified_ iRGB scheme. With this change, IBM set four levels of brightness for each phosphor dot: completely off, one-third brightness, two-thirds brightness, and full brightness. If the "intensity" bit was turned off, then each red, green, and blue phosphor dot would light up at two-thirds brightness. If you set the "intensity" bit on, any zeroes in the RGB colors would be lit at one-third brightness, and any ones in the RGB colors would be lit at full brightness. + +Let me describe this to you another way, using web color code representation. If you are familiar with the HTML colorspace, you probably know that you can represent colors using #RGB, where RGB represents a combination of red, green, and blue values, each between the hexadecimal values 0 through F. So using IBM's modified iRGB definition, iRGB=0001 is #00a (blue) and iRGB=1001 is #55f (bright blue) because with high-intensity colors, all zeroes in RGB=001 are lit at one-third brightness (around "5" on the 0 to F scale) and all ones in RGB=001 are lit at two-third brightness (about "A" on the 0 to F scale). + +| | | | | | | ------------ | | ------------------- | | | 0000 Black | | 1000 Bright Black | | | 0001 Blue | | 1001 Bright Blue | | | 0010 Green | | 1010 Bright Green | | | 0011 Cyan | | 1011 Bright Cyan | | | 0100 Red | | 1100 Bright Red | | | 0101 Magenta | | 1101 Bright Magenta | | | 0110 Yellow | | 1110 Bright Yellow | | | 0111 White | | 1111 Bright White | + +And with those colors, we are finally done! We have a full spectrum of colors from iRGB=0000 (black) to iRGB=1111 (bright white) and every color in between. Like a rainbow of colors, this is beautiful. + +Except, no. Wait. Something's wrong here. We can't actually replicate all of the colors of the rainbow yet. The handy mnemonic we learned in grade school was ROYGBIV, to help us remember that a rainbow has colors from red, orange, yellow, green, blue, indigo, and violet. Our modified iRGB color scheme includes red, yellow, green, and blue—and we can "fake" it for indigo and "violet." But we're missing orange. Oh no! + +![rainbow][7] + +A beautiful rainbow - which unfortunately contains orange  +([Paweł Fijałkowski][8], public domain) + +To fix this, the smart IBM engineers made one final fix for RGB=110. The high-intensity color (iRGB=1110) lit up the red and green phosphor dots at full brightness to make yellow. But at the low-intensity color (iRGB=0110), they lit the red at two-thirds brightness and the green at one-third brightness. This turned iRGB=0110 into an orange color—although it was later dubbed "brown" because IBM had to mess up the standard names somewhere. + +| | | | | | | ------------ | | ------------------- | | | 0000 Black | | 1000 Bright Black | | | 0001 Blue | | 1001 Bright Blue | | | 0010 Green | | 1010 Bright Green | | | 0011 Cyan | | 1011 Bright Cyan | | | 0100 Red | | 1100 Bright Red | | | 0101 Magenta | | 1101 Bright Magenta | | | 0110 Brown | | 1110 Yellow | | | 0111 White | | 1111 Bright White | + +And that's how CGA—and by extension, DOS—got the sixteen colors! And in case you're curious, that's also why there's a "bright black" color, even though it's just a shade of gray. + +### Representing colors (bits and bytes) + +But you may wonder: why can DOS only display eight background colors if it can display sixteen text colors? For that, we need to take a quick diversion into how computers passed color information to the CGA card. + +In brief, the CGA card expected each character's text color and background color to be encoded in a single byte packet. That's eight bits. So where do the eight bits come from? + +We just learned how iRGB (four bits) generates the sixteen colors. Text color uses iRGB, or four bits. The background color is limited to the eight low-intensity colors (RGB, or three bits). Together, that makes only seven bits. Where is the missing eighth bit? + +The final bit was reserved for perhaps the DOS era's most important user interface element—blinking text. While the blinking text might be annoying today, throughout the early 1980s, blinking text was the friendly way to represent critical information such as error messages. + +Adding this "blink" bit to the three background color bits (RGB) and the four text color bits (iRGB) makes eight bits or a byte! Computers like to count in full bytes, making this a convenient way to package color (and blink) information to the computer. + +Thus, the full byte to represent color (and blink) was `Bbbbffff`, where `ffff` is the iRGB bit pattern for the text color (from 0 to 15), `bbb` is the RGB bit pattern for the low-intensity background color (from 0 to 7), and `B` is the "blink" bit. + +The limit of sixteen text colors and eight background colors continues to this day. Certainly, DOS is stuck with this color palette, but even Linux terminal emulators like GNOME Terminal remain constrained to sixteen text colors and eight background colors. Sure, a Linux terminal might let you change the specific colors used, but you're still limited to sixteen text colors and eight background colors. And for that, you can thank DOS and the original IBM PC. You're welcome! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/freedos-sixteen-colors + +作者:[Jim Hall][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jim-hall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/1980s-computer-yearbook.png?itok=eGOYEKK- (Person typing on a 1980's computer) +[2]: https://opensource.com/sites/default/files/uploads/16colors.png (DOS text comes in 16 colors and 8 background colors) +[3]: https://creativecommons.org/licenses/by-sa/4.0/ +[4]: https://opensource.com/sites/default/files/uploads/rgb.svg_.png (Mix red, green, and blue light to get different colors) +[5]: https://opensource.com/sites/default/files/uploads/crt.svg_.png (Each red, green, and blue triad is a single pixel) +[6]: https://opensource.com/sites/default/files/uploads/lcd.svg_.png (Each red, green, and blue triad is a single pixel) +[7]: https://opensource.com/sites/default/files/uploads/rainbow.jpg (A beautiful rainbow - which unfortunately contains orange ) +[8]: https://www.pexels.com/photo/landscape-photography-of-field-with-wind-mill-with-rainbow-1253748/ diff --git a/sources/tech/20210618 5 more reasons to run Kubernetes in your Linux homelab.md b/sources/tech/20210618 5 more reasons to run Kubernetes in your Linux homelab.md new file mode 100644 index 0000000000..dd5ec7ed2c --- /dev/null +++ b/sources/tech/20210618 5 more reasons to run Kubernetes in your Linux homelab.md @@ -0,0 +1,100 @@ +[#]: subject: (5 more reasons to run Kubernetes in your Linux homelab) +[#]: via: (https://opensource.com/article/21/6/kubernetes-linux-homelab) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +5 more reasons to run Kubernetes in your Linux homelab +====== +Kubernetes' advantages aren't just what it can do, they're also what +knowing it can do for you. +![Working from home at a laptop][1] + +In [5 reasons to run Kubernetes on your Raspberry Pi homelab][2], I explain why you might want to use Kubernetes at home. Those reasons are relatively arbitrary, and they mostly focus on outcomes. Aside from what Kubernetes can do, there are several other good reasons to look at Kubernetes as an important next step in your personal computing experience. + +### 1\. It's built on the foundation of Linux + +![T-shirt reading "Containers are Linux"][3] + +(Seth Kenlon, [CC BY-SA 4.0][4]) + +Kubernetes has a certain reputation. More accurately, it has several reputations. For some people, it's a mysterious technology with an unpronounceable name. To other people, it's a sheepdog helping them herd an over-abundance of containers. For others, it's a kind of operating system for the cloud, a useful interface to effective cloud development. And for most people, probably, it's back-end software they've never even heard of. As you might expect, it's all of these things and more. + +Not everyone interacts with Kubernetes the same way, but if you have an inclination toward systems administration, you'll find that Kubernetes is _just another Linux command_. + +I have a t-shirt that reads "Containers are Linux," which states what is, upon reflection, obvious. Container technology uses cgroups to run images of a minimal Linux operating system containing an application or set of applications. From start to finish, when you choose to run a container, you're choosing to run Linux. While Kubernetes commands run on many platforms, it's managing Linux containers, and when you interact with Kubernetes through a terminal, it's Linux business as usual: command, options, args, syntax. Running `kubeadm` or (on OKD or OpenShift) `oc` commands feels familiar because they work like any other Linux command you're used to running. What starts out seeming foreign feels natural in no time, and any Linux user interested in spending time in the terminal can find plenty of fun things to explore in Kubernetes. + +### 2\. Flexible + +Kubernetes used to be a little rigid. It supported, essentially, one container runtime—so stringently, in fact, that there's a hardcoded shim to this day to get around that legacy. Luckily, today Kubernetes has become flexible enough to allow for admins' many diverse needs. There's [Podman][5] and [CRI-O][6] available as container engines, both of which can integrate with [systemd][7]. (I meant what I said when I told you it was all Linux underneath.) You have choices of filesystems, cluster size and construction, monitoring tools, images, programming languages, and much more. Frankly, some people say there's _too much_ choice, which is usually when I suspect that after a few more years, it'll have just enough choice for me. + +### 3\. Personal development + +Containers are a fruitful business, and they have the habit of multiplying rapidly. That's by design. Containers are meant to scale, and they scale by spawning clones. Stick the containers into groups (call them _pods_), and automate how pod lifecycles are managed. That's all Kubernetes really is, and it's changing how servers can run. + +You might not need an infinitely scaleable collection of containers, and you may not need anything to help you manage the one or two containers you do run. However, if you're looking to profit from your ability to wrangle pods, then Kubernetes is exactly the tool you want. As more and more companies and organizations go global and embrace [digital transformation][8], Kubernetes is becoming a required skill in IT. If that's the path you're on, it's a good investment to learn it now and get familiar with common problems and their solutions. + +### 4\. Make containers make sense + +You may remember several years ago when open source projects started distributing their code as container images. For many, it was puzzling at the time. Not many admins really [understood what a container was][9], or where the boundaries of the imaginary container were, or how to get into the container, or why data couldn't live inside the container. + +Now, the IT world—including developers—is comfortable with the concept of containers. Delivery to containers just makes sense for a modern [CI/CD workflow][10]. For the sysadmin, though, the advantages of containers are twofold: installation is (theoretically) easier than waiting for a distro to update its packages, and containers scale. Yet it's very likely that neither of these benefits really manifests for you until you've used Kubernetes. Once you start managing containers with Kubernetes and related tools, the benefits of continuous delivery and the ability to scale are probably merely ideas you've read about. Integrate containers into how you manage your servers, and you suddenly understand what the excitement is all about. + +![Apache JMeter][11] + +(Seth Kenlon, [CC BY-SA 4.0][4]) + +The most basic of tests makes it pretty clear. Just spin up your favorite web server in a container, create a pod, then hit your server with traffic from [Apache JMeter][12], and watch containers respond. + +### 5\. Cloud-native + +If you do more development than systems administration, Kubernetes provides an excellent platform for what has easily become the biggest target of all: web apps. We all use web apps now, even though most people just think of them as "websites." The web has a hugely significant user base (to say the least), so it makes sense to provide open source applications through the browser. There are some great open source applications that run over a network, and many of those are delivered as containers to provide easy installation and a consistent user experience. + +### Bonus: It's fun + +Remember when you were still new to Linux? For some people, that might have been decades ago, and for others, it's still around the corner. For all of us, though, learning something new can be a fun challenge. If you've reached the point that Linux installs are more a bother than a challenge, you might want to try building a Kubernetes cluster in your broom closet. It will reintroduce you to all kinds of concepts you'd forgotten about. Hacking on plain-text ([YAML][13] specifically) configuration files, configuring network interfaces and networks, routing traffic, poring over the advantages and disadvantages of one backend over another, running `--dry-run` after `--dry-run` tests, tentatively pressing Return to find out whether you got everything right. Honestly, Kubernetes is just fun. + +If you want to build your own infrastructure, there's nothing quite like building your own Kubernetes cluster. A whole new world will open to you. You quickly become a cloud architect, perfecting your open cloud, installing amazing open source web applications in containers, and maybe even offering access to your family and friends. + +You become the solution. It's so very satisfying. + +### Explore Kubernetes + +Kubernetes might seem out of reach at first. It's new, a little scary, and worst yet, it apparently requires a cloud. However, there are a few ways to get started. + +First, install either [Minikube][14] or [Minishift][14]. Both of these allow you to run a local instance of Kubernetes on your personal computer. It's not quite as satisfying as building a cluster and opening it up to your friends, but it's a great, safe way to get familiar with the landscape, commands, and toolkit. + +Once you're ready for the real thing, read Chris Collins' article [Build a Kubernetes cluster with the Raspberry Pi][15]. After that, download our free ebook [Running Kubernetes on your Raspberry Pi homelab][16]. Before you know it, you'll find yourself wearing Kubernetes t-shirts, too. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/kubernetes-linux-homelab + +作者:[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/wfh_work_home_laptop_work.png?itok=VFwToeMy (Working from home at a laptop) +[2]: https://opensource.com/article/20/8/kubernetes-raspberry-pi +[3]: https://opensource.com/sites/default/files/uploads/containers-are-linux.jpg (T-shirt reading "Containers are Linux") +[4]: https://creativecommons.org/licenses/by-sa/4.0/ +[5]: http://podman.io +[6]: http://cri-o.io +[7]: https://opensource.com/article/21/5/systemd +[8]: https://enterprisersproject.com/what-is-digital-transformation +[9]: https://opensource.com/article/18/11/behind-scenes-linux-containers +[10]: https://opensource.com/article/18/8/what-cicd +[11]: https://opensource.com/sites/default/files/uploads/jmeter.png (Apache JMeter) +[12]: https://jmeter.apache.org +[13]: https://www.redhat.com/sysadmin/yaml-beginners +[14]: https://opensource.com/article/18/10/getting-started-minikube +[15]: https://opensource.com/article/20/6/kubernetes-raspberry-pi +[16]: https://opensource.com/downloads/kubernetes-raspberry-pi diff --git a/sources/tech/20210618 DevSecOps- An open source story.md b/sources/tech/20210618 DevSecOps- An open source story.md new file mode 100644 index 0000000000..f8429bd53e --- /dev/null +++ b/sources/tech/20210618 DevSecOps- An open source story.md @@ -0,0 +1,106 @@ +[#]: subject: (DevSecOps: An open source story) +[#]: via: (https://opensource.com/article/21/6/open-sourcing-devsecops) +[#]: author: (Will Kelly https://opensource.com/users/willkelly) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +DevSecOps: An open source story +====== +DevSecOps brings culture changes, frameworks, and tools into open source +software. To understand DevSecOps, you must understand its relationship +with open source. +![A lock on the side of a building][1] + +Recent supply chain breaches, plus President Biden's new [Cybersecurity executive order][2], are bringing renewed attention to DevSecOps' value for the enterprise. DevSecOps brings culture changes, frameworks, and tools into open source software (OSS). To understand DevSecOps, you must understand its relationship with OSS. + +### What is DevSecOps? + +In its purest form, DevOps (which is an amalgamation of development and operations) is a methodology for breaking down the traditional silos between programmers and system administrators during the software delivery lifecycle. Corporations and government agencies adopt DevOps for various reasons, including improving software delivery velocity to serve customers better. + +DevSecOps adds security into DevOps, further refining the concept to address code quality, security, and reliability assurance through automation, enabling continuous security and compliance. Organizations seeking to comply with Sarbanes Oxley (SOX), Payment Card Industry Data Security Standard (PCI DSS), FedRAMP, and similar programs are candidates for implementing DevSecOps. + +For example, a federal government agency seeking [FedRAMP compliance][3] should use DevSecOps, because it enables them to bake security automation into each stage of their software development process. Likewise, a healthcare institution entrusted with sensitive personal healthcare information (PHI) needs DevSecOps to ensure its cloud applications meet HIPAA compliance requirements. + +The more you move security mitigation to the left to tackle these issues in development, the more money you save. You also avoid potential negative headlines because your teams don't have to respond to issues in production, where remediation costs can soar way higher than if you caught them in your development environment. + +You can treat the move from DevOps to DevSecOps as another step in the DevOps journey. But it's more like a transformation for your development organization and your entire business. Here's a typical framework: + + 1. **Analyze, communicate, and educate:** This includes analyzing your development process maturity; defining DevSecOps for your organization; and fostering a DevSecOps culture with continuous feedback and interaction, team autonomy, and automation and architecture. + 2. **Integrate security into your DevOps lifecycle:** Ensure your DevOps and security teams work together. + 3. **Introduce automation into your DevOps lifecycle:** Start on small dev projects and gradually expand your automation strategy. + 4. **Collaborate on security changes to your DevOps toolchains:** Get your development and security teams working jointly on projects to harden your DevOps toolchain. + 5. **Execute on DevSecOps:** Get your teams fully engaged with your DevSecOps toolchains and new processes. + 6. **Encourage continuous learning and iteration:** Offer your developers and sysadmins training and feedback mechanisms to support developer performance and the health of your toolchains. + + + +We're at a unique point in the history of software development, where the need to increase security and speed software development velocity is at a crossroads. While DevOps has done a lot to increase velocity, there was always more to do. + +### Growth of DevSecOps + +The growth of DevSecOps has been visible in compliance and security-conscious arenas. For example, it has a growing following inside the security-conscious US Department of Defense. Projects such as [Platform One][4] are setting an example of how DevSecOps practices can protect open source and cloud technologies in the most security-conscious government missions. + +DevSecOps has a 20% to 50% penetration within industry, according to [Gartner's Hype Cycle for Agile and DevOps, 2020][5]. The pandemic has acted as a catalyst for DevSecOps as organizations have moved application development to the cloud. + +### Challenges of DevSecOps + +Even if you treat DevSecOps as another step in your DevOps journey, you can expect changes to your toolchain, roles on your DevOps and security teams, and how your groups interact. Over 60% of the respondents to [GitLab's 2021 Global DevSecOps Survey][6] report new roles and responsibilities because of DevOps, so prepare your people upfront and keep surprises to a minimum. + +There is a variety of open source DevSecOps tools you can adopt to build out your DevOps pipeline, including: + + * [Alerta][7] consolidates and deduplicates alerts from multiple sources to provide quick visualizations. It integrates with Prometheus, Riemann, Nagios, and other monitoring tools and services for developers. You can use Alerta to customize alerts to meet your requirements. + * [StackStorm][8] offers event-driven automation providing scripted remediations and responses. Some users affectionately call it the "[IFTTT][9] for ops." + * [Grafana][10] allows you to create custom dashboards that aggregate all relevant data to visualize and query security data. + * [OWASP Threat Dragon][11] is a web-based tool that offers system diagramming and a rules engine for modeling and mitigating threats automatically. Threat Dragon touts an easy-to-use interface and seamless integration with other software development tools. + + + +DevSecOps brings a culture, much in the same way that DevOps does. Fostering a DevSecOps culture is about putting security first and making it everybody's job. DevSecOps organizations need to go beyond the mandatory corporate-wide online security training with canned dialogue and bring security into development and business processes. + +### DevSecOps and open source risk mitigation + +Businesses and even government agencies use as much as [90% open source code][12]. That sometimes accounts for hundreds of discrete libraries in a single application. There's no doubt that OSS saves DevOps teams time and money, but it may take a DevSecOps security model to mitigate OSS risk and licensing complexities. + +Forty-six percent of respondents to Synopsys' [DevSecOps Practices and Open Source Management in 2020][13] survey said that media coverage of open source issues affects how they implement controls in their OSS projects. Continuing coverage of the recent supply chain breaches are amping up tech leaders' concerns about the stringency of their controls. + +OSS risk mitigation strategies and DevSecOps go together in many ways, such as: + + * Begin generating a software bill of materials (SBOM) as a quality gate before OSS enters your software supply chain. + * Give [OSS procurement][14] the same attention as you do the vetting, purchase, and intake of enterprise software by bringing in talent from your development, security, and corporate back-office teams. You can adapt your DevSecOps lifecycle to factor in your OSS procurement strategy. + + + +### Final thoughts + +DevSecOps is a noisy topic right now. Plenty of marketers are trying to put their spin on defining it to sell more products to commercial and public-sector enterprises. Even so, the relationship between OSS and DevSecOps remains clean because DevSecOps tools and strategies offer a security gate to bring OSS into the software supply chain and your DevSecOps pipeline while maintaining security and compliance from the first step in the process. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/open-sourcing-devsecops + +作者:[Will Kelly][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/willkelly +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_3reasons.png?itok=k6F3-BqA (A lock on the side of a building) +[2]: https://www.whitehouse.gov/briefing-room/presidential-actions/2021/05/12/executive-order-on-improving-the-nations-cybersecurity/ +[3]: https://www.fedramp.gov/faqs/ +[4]: https://software.af.mil/team/platformone/ +[5]: https://www.gartner.com/en/documents/3987588/hype-cycle-for-agile-and-devops-2020 +[6]: https://about.gitlab.com/developer-survey/ +[7]: https://alerta.io/ +[8]: https://stackstorm.com/ +[9]: https://ifttt.com/ +[10]: https://grafana.com/ +[11]: https://www.owasp.org/index.php/OWASP_Threat_Dragon +[12]: https://www.contrastsecurity.com/security-influencers/how-to-identify-remediate-oss-library-risks +[13]: https://www.synopsys.com/software-integrity/resources/analyst-reports/devsecops-practices-open-source-management.html +[14]: https://thenewstack.io/how-to-standardize-open-source-procurement-and-lower-risk-without-slowing-your-developers/ diff --git a/sources/tech/20210618 Use this nostalgic text editor on FreeDOS.md b/sources/tech/20210618 Use this nostalgic text editor on FreeDOS.md new file mode 100644 index 0000000000..384e6f9a9b --- /dev/null +++ b/sources/tech/20210618 Use this nostalgic text editor on FreeDOS.md @@ -0,0 +1,191 @@ +[#]: subject: (Use this nostalgic text editor on FreeDOS) +[#]: via: (https://opensource.com/article/21/6/edlin-freedos) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Use this nostalgic text editor on FreeDOS +====== +Edlin is a joy to use when I want to edit text the "old school" way. +![Old UNIX computer][1] + +In the very early days of DOS, the standard editor was a no-frills _line editor_ called Edlin. Tim Paterson wrote the original Edlin for the first version of DOS, then called 86-DOS and later branded PC-DOS and MS-DOS. Paterson has commented that he meant to replace Edlin eventually, but it wasn't until ten years later that MS-DOS 5 (1991) replaced Edlin with Edit, a full-screen editor. + +You may know that FreeDOS is an open source DOS-compatible operating system that you can use to play classic DOS games, run legacy business software, or develop embedded systems. FreeDOS has very good compatibility with MS-DOS, and the "Base" package group includes those utilities and programs that replicate the behavior of MS-DOS. One of those classic programs is an open source implementation of the venerable Edlin editor; Edlin is distributed under the GNU General Public License version 2. + +Written by Gregory Pietsch, Edlin is a well-designed, portable editor. You can even compile Edlin on Linux. As Gregory described Edlin in the free ebook 23 Years of FreeDOS, “The top tier parses the input and calls the middle tier, a library called `edlib`, which calls the string and array-handling code to do the dirty work.” But aside from its technical merits, I find Edlin is a joy to use when I want to edit text the "old school" way. + +FreeDOS 1.3 RC4 includes Edlin 2.18. That's actually one revision out of date, but you can download [Edlin 2.19][2] from the FreeDOS files archive on [Ibiblio][3]. You'll find two files there—_edlin-2.19.zip_ contains the source code, and _edlin-219exe.zip_ is just the DOS executable. Download the _edlin-219exe.zip_ file, and extract it to your FreeDOS system. I've unzipped my copy in `C:\EDLIN`. + +Edlin takes a little practice to "get into" it, so let's edit a new file to show a few common actions in Edlin. + +### A walkthrough + +Start editing a file by typing `EDLIN` and then the name of the file to edit. For example, to edit a C programming source file called `HELLO.C`, you might type: + + +``` +`C:\EDLIN> edlin hello.c` +``` + +I've typed the FreeDOS commands in all lowercase here. FreeDOS is actually _case insensitive_, so you can type commands and files in uppercase or lowercase. Typing `edlin` or `EDLIN` or `Edlin` would each run the Edlin editor. Similarly, you can identify the source file as `hello.c` or `HELLO.C` or `Hello.C`. + + +``` +C:\EDLIN> edlin hello.c +edlin 2.19, copyright (c) 2003 Gregory Pietsch +This program comes with ABSOLUTELY NO WARRANTY. +It is free software, and you are welcome to redistribute it +under the terms of the GNU General Public License -- either +version 2 of the license, or, at your option, any later +version. + +hello.c: 0 lines read +* +``` + +Once inside Edlin, you'll be greeted by a friendly `*` prompt. The interface is pretty minimal; no shiny "menu" or mouse support here. Just type a command at the `*` prompt to start editing, revise lines, search and replace, save your work, or exit the editor. + +Since this is a new file, we'll need to add new lines. We'll do this with the _insert_ command, by typing `i` at the `*` prompt. The Edlin prompt changes to `:` where you'll enter your new text. When you are done adding new text, type a period (`.`) on a line by itself. + + +``` +*i + : #include <stdio.h> + : + : int + : main() + : { + :   puts("Hello world"); + : } + : . +* +``` + +To view the text you've entered so far, use the _list_ command by entering `l` at the `*` prompt. Edlin will display lines one screenful at a time, assuming 25 rows on the display. But for this short "Hello world" program, the source code fits on one screen: + + +``` +*l +1: #include <stdio.h> +2: +3: int +4: main() +5: { +6:   puts("Hello world"); +7:*} +* +``` + +Did you notice the `*` on line 7, the last line in the file? That's a special mark indicating your place in the file. If you inserted new text in the file, Edlin would add it at this location. + +Let's update the C source file to return a code to the operating system. To do that, we'll need to add a line _above_ line 7. Since that's where Edlin has the mark, we can use `i` to insert next text before this line. Don't forget to enter `.` on a line by itself to stop entering the new text. + +By listing the file contents afterwards, you can see that we inserted the new text in the correct place, before the closing "curly brace" in the program. + + +``` +*i + :   return 0; + : . +*l +1: #include <stdio.h> +2: +3: int +4: main() +5: { +6:   puts("Hello world"); +7:   return 0; +8:*} +* +``` + +But what if you need to edit a single line in the file? At the `*` prompt,simply type the line number that you want to edit. Edlin works one line at a time, so you'll need to re-enter the full line. In this case, let's update the `main()` function definition to use a slightly different programming syntax. That's on line 4, so type `4` at the prompt, and re-type the line in full. + +Listing the file contents afterwards shows the updated line 4. + + +``` +*4 +4:*main() +4: main(void) +*l +1: #include <stdio.h> +2: +3: int +4:*main(void) +5: { +6:   puts("Hello world"); +7:   return 0; +8: } +* +``` + +When you've made all the changes you need to make, don't forget to save the updated file. Enter `w` at the prompt to _write_ the file back to disk, then use `q` to _quit_ Edlin and return to DOS. + + +``` +*w +hello.c: 8 lines written +*q +C:\EDLIN> +``` + +### Quick reference guide + +That walkthrough shows the basics of using Edlin to edit files. But Edlin does more than just "insert, edit, and save." Here's a handy cheat sheet showing all the Edlin functions, where _text_ indicates a text string, _filename_ is the path and name of a file, and _num_ is a number (use `.` for the current line number, `$` for the last line number). + +`?` | Show help +---|--- +_num_ | Edit a single line +`a` | Append a line below the mark +[_num_]`i` | Insert new lines before the mark +[_num_][`,`_num_]`l` | List the file (starting 11 lines above the mark) +[_num_][`,`_num_]`p` | Page (same as List, but starting at the mark) +[_num_]`,`[_num_]`,`_num_`,`[_num_]`c` | Copy lines +[_num_]`,`[_num_]`,`_num_`m` | Move lines +[_num_][`,`_num_][`?`]`s`_text_ | Search for text +[_num_][`,`_num_][`?`]`r`_text_`,`_text_ | Replace text +[_num_][`,`_num_]`d` | Delete lines +[_num_]`t`_filename_ | Transfer (insert the contents of a new file at the mark) +[_num_]`w`[_filename_] | Write the file to disk +`q` | Quit Edlin +`e`[_filename_] | End (write and quit) + +Programmers will be interested to know they can enter special characters in Edlin, using these special codes: + +`\a` | alert +---|--- +`\b` | backspace +`\e` | escape +`\f` | formfeed +`\t` | horizontal tab +`\v` | vertical tab +`\"` | double quote +`\'` | single quote +`\.` | period +`\\` | backslash +`\x`_XX_ | hexadecimal number +`\d`_NNN_ | decimal number +`\`_OOO_ | octal number +`\^`_C_ | control character + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/edlin-freedos + +作者:[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/retro_old_unix_computer.png?itok=SYAb2xoW (Old UNIX computer) +[2]: https://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/dos/edlin/2.19/ +[3]: https://www.ibiblio.org/ diff --git a/sources/tech/20210619 Try quantum computing with this open source software development kit.md b/sources/tech/20210619 Try quantum computing with this open source software development kit.md new file mode 100644 index 0000000000..a36b70ca20 --- /dev/null +++ b/sources/tech/20210619 Try quantum computing with this open source software development kit.md @@ -0,0 +1,119 @@ +[#]: subject: (Try quantum computing with this open source software development kit) +[#]: via: (https://opensource.com/article/21/6/qiskit) +[#]: author: (Gordon Haff https://opensource.com/users/ghaff) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Try quantum computing with this open source software development kit +====== +Qiskit is an open source software development kit for accessing quantum +simulators and hardware for free. +![Tips and gears turning][1] + +Classical computing is based on bits. Zeros and ones. This isn't because there's some inherent advantage to a binary logic system over logic systems with more states—or even over analog computers. But on-off switches are easy to make and, with modern semiconductor technology, we can make them very small and very cheap. + +But they're not without limits. Some problems just can't be efficiently solved by a classical computer. These tend to be problems where the cost, in time or memory, increases exponentially with the scale (`n`) of the problem. We say such problems are `O(2n)` in [Big O notation][2]. + +Much of modern cryptography even depends on this characteristic. Multiplying two, even large, prime numbers together is fairly cheap computationally (`O(n2)`). But reversing the operation takes exponential time. Use large enough numbers, and decryption that depends on such a factoring attack is infeasible. + +### Enter quantum + +A detailed primer on the mathematical and quantum mechanical underpinnings of quantum computing is beyond the scope of this article. However, here are some basics. + +A quantum computer replaces bits with [qubits][3]—controllable units of computing that display quantum properties. Qubits are typically made out of either an engineered superconducting component or a naturally occurring quantum object such as an electron. Qubits can be placed into a "superposition" state that is a complex combination of the 0 and 1 states. You sometimes hear that qubits are _both_ 0 and 1, but that's not really accurate. What is true is that, when a measurement is made, the qubit state will collapse into a 0 or 1. Mathematically, the (unmeasured) quantum state of the qubit is a point on a geometric representation called the [Bloch sphere][4]. + +While superposition is a novel property for anyone used to classical computing, one qubit by itself isn't very interesting. The next unique quantum computational property is "interference." Real quantum computers are essentially statistical in nature. Quantum algorithms encode an interference pattern that increases the probability of measuring a state encoding the solution. + +While novel, superposition and interference do have some analogs in the physical world. The quantum mechanical property "entanglement" doesn't, and it's the real key to exponential quantum speedups. With entanglement, measurements on one particle can affect the outcome of subsequent measurements on any entangled particles—even ones not physically connected. + +### What can quantum do? + +Today's quantum computers are quite small in terms of the number of qubits they contain—tens to hundreds. Thus, while algorithms are actively being developed, the hardware needed to run them faster than their classical equivalents doesn't exist. + +But there's considerable interest in quantum computing in many fields. For example, quantum computers may offer a good way to simulate natural quantum systems, like molecules, whose complexity rapidly exceeds the ability of classical computers to model them accurately. Quantum computing is also tied mathematically to linear algebra, which underpins machine learning and many other modern optimization problems. Therefore, it's reasonable to think quantum computing could be a good fit there as well. + +One commonly cited example of an existing quantum algorithm likely to outperform classical algorithms is [Shor's algorithm][5], which can do the factoring mentioned earlier. Invented by MIT mathematician Peter Shor in 1994, quantum computers can't yet run the algorithm on larger than trivially sized problems. But it's been demonstrated to work in polynomial `O(n3)` time rather than the exponential time required by classical algorithms. + +### Getting started with Qiskit + +At this point, you may be thinking: "But I don't have a quantum computer, and I really like to get hands-on. Is there any hope?" + +Enter an open source (Apache 2.0 licensed) project called [Qiskit][6]. It's a software development kit (SDK) for accessing both the quantum computing simulators and the actual quantum hardware (for free) in the IBM Quantum Experience. You just need to sign up for an API key. + +Certainly, a deep dive into Qiskit, to say nothing of the related linear algebra, is far beyond what I can get into here. If you seek such a dive, there are [many free resources online][7], including a complete textbook. However, dipping a toe in the water is straightforward, requiring only some surface-level knowledge of Python and Jupyter Notebooks. + +To give you a taste, let's do a "Hello, World!" program entirely within the [Qiskit textbook][8]. + +Begin by installing some tools and widgets specific to the textbook: + + +``` +`pip install git+https://github.com/qiskit-community/qiskit-textbook.git#subdirectory=qiskit-textbook-src` +``` + +Next, do the imports: + + +``` +from qiskit import QuantumCircuit, assemble, Aer +from math import pi, sqrt +from qiskit.visualization import plot_bloch_multivector, plot_histogram +``` + +Aer is the local simulator. Qiskit consists of four components: **Aer**, the **Terra** foundation, **Ignis** for dealing with noise and errors on real quantum systems, and **Aqua** for algorithm development. + + +``` +# Let's do an X-gate on a |0> qubit +qc = QuantumCircuit(1) +qc.x(0) +qc.draw() +``` + +An **X-gate** in quantum computing is similar to a **Not gate** in classical computing, although the underlying math actually involves matrix multiplication. (It is, in fact, often called a **NOT-gate**.) + +Now, run it and do a measurement. The result is as you would expect because the qubit was initialized in a `|0>` state, then inverted, and measured. (Use `|0>` and `|1>` to distinguish from classic bits.) + + +``` +# Let's see the result +svsim = Aer.get_backend('statevector_simulator') +qobj = assemble(qc) +state = svsim.run(qobj).result().get_statevector() +plot_bloch_multivector(state) +``` + +![Bloch sphere showing the expected result][9] + +Bloch sphere showing the expected result. (Gordon Haff, [CC-BY-SA 4.0][10]) + +### Conclusion + +In some respects, you can think of quantum computing as a sort of exotic co-processor for classical computers in the same manner as graphics processing units (GPUs) and field-programmable gate arrays (FPGAs). One difference is that quantum computers will be accessed almost entirely as network resources for the foreseeable future. Another is that they work fundamentally differently, which makes them unlike most other accelerators you might be familiar with. That's why there's so much interest in algorithm development and significant resources going in to determine where and when quantum fits best. It wouldn't hurt to see what all the fuss is about. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/qiskit + +作者:[Gordon Haff][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ghaff +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/gears_devops_learn_troubleshooting_lightbulb_tips_520.png?itok=HcN38NOk (Tips and gears turning) +[2]: https://en.wikipedia.org/wiki/Big_O_notation +[3]: https://en.wikipedia.org/wiki/Qubit +[4]: https://en.wikipedia.org/wiki/Bloch_sphere +[5]: https://en.wikipedia.org/wiki/Shor%27s_algorithm +[6]: https://qiskit.org/ +[7]: https://qiskit.org/learn +[8]: https://qiskit.org/textbook/preface.html +[9]: https://opensource.com/sites/default/files/uploads/bloch-sphere.png (Bloch sphere showing the expected result) +[10]: https://creativecommons.org/licenses/by-sa/4.0/ diff --git a/sources/tech/20210620 8 books open source technologists should read this summer.md b/sources/tech/20210620 8 books open source technologists should read this summer.md new file mode 100644 index 0000000000..b8fc177bee --- /dev/null +++ b/sources/tech/20210620 8 books open source technologists should read this summer.md @@ -0,0 +1,243 @@ +[#]: subject: (8 books open source technologists should read this summer) +[#]: via: (https://opensource.com/article/21/6/2021-opensourcecom-summer-reading-list) +[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +8 books open source technologists should read this summer +====== +The 2021 Opensource.com summer reading list features eight recommended +books for you to kick back, relax, and learn by reading. +![Reading a book, selfcare][1] + +Welcome to the 2021 Opensource.com summer reading list. This year's list contains eight wonderful book recommendations from members of the Opensource.com community. From classics like Frank Herbert's _Dune_ and a new translation of _Beowulf_ to non-fiction books about the history of tech industry culture, this list has books for readers with different tastes and interests. + +Each recommendation provides valuable insight into why the person who recommended the book thinks it is worth reading. As always, the book selections and reviews shared by my peers are insightful and inspiring. I always learn so much from what they share, and I always enjoy seeing what new and interesting books I will invariably add to my "to read" list. I hope that you will also find something to add to your "to read" pile. + +Enjoy! + +* * * + +## [Beowulf: A New Translation][2] + +[![Beowulf book cover][3]][2] + +**by Maria Dahvana Headley** (recommendation written by [Kevin Sonney][4]) + +From the first line, you know this isn't the same "Beowulf" you slogged through in grade school. + +> Bro! Tell me we still know how to speak of kings! + +Before I fell into the IT field, I was an English major with a deep, abiding love of _Beowulf_. It can be difficult to read, and (at least here in the United States) it is required reading in high school, but many people remember it as a boring read where the language and structure get in the way of the story. In this translation, Headley puts the story first while maintaining a modern translation that is accurate in structure and meaning with the original text. From the opening "Bro!" to the occasional (and appropriate!) vulgarity, to the description of the "Hashtag: Blessed" Queen, readers will find themselves hanging on every line to find out what happens next. Headley's translation, more than any other, is also a joy to read out loud, just as it was for the bards who told it in the mead halls and longhouses of long ago. + +This is a well-researched, well-written, and most importantly, engaging translation of one of the most important historical works of English literature. Headley makes _Beowulf_ FUN to read, and the reader gets immersed in the story, just like the listeners did over their drinks and meals long ago. + +## [Competing on Internet Time: Lessons From Netscape and Its Battle With Microsoft][5] + +[![Competing on Internet Time book cover][6]][5] + +**by Michael A. Cusumano and David B. Yoffie** (recommendation written by [Gaurav Kamathe][7]) + +If you are reading this right now, chances are you are using a web browser. In fact, if you use a computer today in any form, can you imagine computing without a web browser? We spend the majority of time in it today—doing work, connecting with friends, surfing the web, watching movies, playing music, finding directions, ordering food, etc. Sure, apps have replaced some of these functions on mobile devices; however, the browser has in many ways become the operating system when it comes to the internet and the web. + +There was a time when the web was taking root, and browsers were not mainstream. Few people could have imagined the potential of the web and the impact it would have on humankind. The browser is what made the web truly accessible to everybody, beyond just the technically savvy. If you are curious about what went into developing this exciting technology, the company that created it, and the battles it had to fight along the way against a mighty adversary, well, then keep reading. + +_Competing on Internet Time_ traces events between the years 1994 and 1998. It mostly revolves around two companies: Netscape (today known as Mozilla), then a new, up and coming startup with a radical new product (the web browser) that came out of nowhere and grew rapidly to capture 90% of the browser market, and Microsoft, a well-known giant (even then) known for its dominance in the operating system market. The authors interviewed many key figures at both companies and provided their analysis of the events that transpired. This book is an interesting read from both a technology and a business standpoint. It goes in-depth on business strategy, decision-making, the benefits of speed, technology choice, and, more importantly, the culture of these two diverse organizations. + +One key takeaway from the book is how Netscape truly embraced and utilized the internet as a competitive advantage at a time when other companies, including Microsoft, had ignored it for too long. Another takeaway is that Netscape, being the smaller of the two, had the advantage of flexibility, allowing it to introduce new products rapidly. A third lesson is how Microsoft fully utilized its operating system-market monopoly to beat Netscape at its browser game. Netscape tried to counter this by becoming a champion of cross-platform technology and introducing and pushing open standards to keep Microsoft on its back foot. In the face of stiff competition, Netscape turned its business strategy and went from being just a browser company and made forays into intranet, extranet, and enterprise software markets, ultimately losing this battle. All of this and more happened in a span of just four (internet) years. + +## [Dune][8] + +* * * + +* * * + +* * * + +**[![Dune book cover][9]][8]** + +* * * + +**by Frank Herbert** (recommendation written by [Matthew Broberg][10]) + +My first review of _Dune_ was that it was an inventive, solid read. That was [not received well][11] by friends on Twitter. On reflection, I don't think that assessment does it justice. _Dune_ is an exceptionally influential piece of art from the mid-1960s that interweaves futuristic cultures, empires, and religions. It also plays with timelines. Every chapter weaves the future in as the present unfolds. The layers of foreshadowing while the world of Arrakis comes into focus are a joy to read. + +I have since finished the second book in the series and plan to go on to the third. This world is massive, thoughtful, and feels as modern as it is timeless. + +## [Hacking Diversity: The Politics of Inclusion in Open Technology Cultures][12] + +* * * + +* * * + +* * * + +**[![Hacking Diversity book cover][13]][12]** + +* * * + +**by Christina Dunbar-Hester** (recommendation written by [Bryan Behrenshausen][14]) + +What motivates this critical anthropology of open source technology communities isn't the question: _Why aren't open source communities more diverse?_ or even _How do we involve more underrepresented minorities in open source?_ Instead, Dunbar-Hester seeks answers to a more complex question: _How do the ways open source communities discuss diversity and inclusion inadvertently constrain their ability to make these communities more inclusive and diverse?_ + +By embedding herself inside various open technology communities—visiting their makerspaces, attending their meetups, listening at their conferences—Dunbar-Hester offers numerous insights that help readers understand how well-meaning and good-faith diversity, equity, and inclusion initiatives might produce results antithetical to their own aspirations. If you're at all interested in making open source communities more welcoming and inclusive, you'll want to read this book. + +## [Letters to a New Developer: What I Wish I Had Known When Starting My Development Career][15] + +* * * + +* * * + +* * * + +**[![Letters to a New Developer book cover][16]][15]** + +* * * + +**by Dan Moore** (recommendation written by [Joshua Allen Holm][17]) + +If you found yourself entering (or re-entering) the job market during the last year, you found that much of the traditional mentoring structure for starting a new job was seriously disrupted. It is harder to get solid career advice when meetups and meetings are virtual, so, as an alternative, I suggest reading _Letters to a New Developer: What I Wish I Had Known When Starting My Development Career._ + +The book is divided into 10 chapters, covering Your First Month, Questions, Writing, Tools to Learn, Practices, Understanding the Business, Learning, Mistakes, Your Career, and Community. Each chapter begins with a brief introduction followed by a series of letters addressed to the reader about the chapter's subject. The letters are all interesting and engaging to read. + +Having almost the entire book in epistolary format makes this book feel more personal than other career guidance books. After a year of being disconnected because of COVID-19, the human touch of the letter-based approach makes this book a pleasure to read. No book, not even one as excellent as _Letters to a New Developer,_ can replace a few good human mentors who can adjust their advice to specific circumstances, but this is a solid alternative to having ready access to a mentor in the next cubicle. + +I highly recommend picking up a copy, even if you do not think you need career advice. There are many insightful things in _Letters to a New Developer_ that would benefit even someone well-established in their career. + +## [The All-Consuming World][18] + +* * * + +* * * + +* * * + +**[![The All-Consuming World book cover][19]][18]** + +* * * + +**by Cassandra Khaw** (recommendation written by [Kevin Sonney][4]) +Release date: September 7, 2021; review based on an advance review copy + +Khaw, author of the Lovecraftian _Hammers on Bone_ and the hilarious and visceral _Rupert Wong: Canibal Chef_ series, brings her distinctive style to a far-future space cyberpunk thriller. In _The All-Consuming World_, a band of criminals comes out of retirement to return to the mythical planet that once almost destroyed them. Khaw excels at writing realistic, messy characters whose flaws are their greatest strengths. At times visceral and profane, Khaw builds a complex universe with complex people, where those people can be artificial intelligences, rogue hackers, cyborgs, clones, heavily modified humans, and more. + +_The All-Consuming World_ is a fast, violent, and complex ride from the opening heist onward. Khaw adds her voice to the amazing array of recent modern cyberpunk authors with her unique combination of style, wit, and mayhem. This book may not be for everyone, but I enjoyed the heck out of it. + +## [The Language Lover's Puzzle Book: Lexical Perplexities and Cracking Conundrums From Across the Globe][20] + +* * * + +* * * + +* * * + +**[![The Language Lover's Puzzle Book cover][21]][20]** + +* * * + +**by Alex Bellos** (recommendation written by [Joshua Allen Holm][17]) + +Are you a word nerd? Do you love puzzles? If the answer to both those questions is "yes," then _The Language Lover's Puzzle Book_ is the book for you. This book explores interesting facts about language through a series of puzzles and anecdotes. + +Each of the book's 10 chapters covers different aspects of language like numbers and familial relations. You will find puzzles about ancient languages, like Babylonian and Egyptian, modern languages, and even constructed languages like [Dothraki][22]. Each puzzle is a brain teaser that makes you think about how languages work. The puzzles vary in difficulty, but each presents an interesting challenge for the reader to solve. + +A book full of complex puzzles about languages certainly has a niche audience; still, the anecdotes contained within are interesting enough to make _The Language Lover's Puzzle Book_ something enjoyable even to a reader not interested in solving the puzzles for themselves. Solving the puzzles is very much the point of the book, but the information in the book is still fascinating and informative, even to readers who do not want to challenge themselves with puzzle solving. + +You can watch Alex Bellos' [talk at the Royal Institution][23] for a preview of the puzzles and anecdotes contained in _The Language Lover's Puzzle Book_. + +This review was based on the UK edition of _The Language Lover's Puzzle Book_. A [US edition][24] with the title _The Language Lover's Puzzle Book: Perple_ing Le_ical Patterns to Unmi_ and Ve_ing Synta_ to Outfo__ is due out in November and available now for preorder. + +## [Understanding the Digital World: What You Need to Know about Computers, the Internet, Privacy, and Security, Second Edition][25] + +* * * + +* * * + +* * * + +**[![Understanding the Digital World book cover][26]][25]** + +* * * + +**by Brian W. Kernighan** (recommendation written by [Jim Hall][27]) + +I loved reading _Understanding the Digital World_. While it's listed as a textbook on Amazon, I didn't find it an "academic" text. It's almost a casual introduction to technology, from basic ideas such as "what is a computer" and "analog versus digital" to more advanced topics including mobile devices, internet communication, artificial intelligence, and cryptography. + +Kernighan introduces each topic in a conversational way, so you don't feel like you're stepping up to a more advanced topic. Rather, it's a natural progression or flow from one topic to the next. + +I especially appreciated his demonstration of the Toy Computer, a hypothetical computer model you can experiment with in a web browser. With the Toy, Kernighan explains the fundamentals of Assembly programming without getting lost in the details of macro assembly and specific registers. I found this an approachable way to discuss the topic. + +I also appreciated Kernighan's discussion about operating systems further into the book. Kernighan explains this technical concept in clear terms, breaking down the components into easily understood sections. + +_Understanding the Digital World_ would make a great gift for anyone interested in technology at almost any age level. + +* * * + +Not seeing something that piques your interest? Check out our previous lists for more suggestions: + + * [2020 Opensource.com summer reading list][28] + * [2019 Opensource.com summer reading list][29] + * [2018 Open Organization summer reading list][30] + * [2016 Opensource.com summer reading list][31] + * [2015 Opensource.com summer reading list][32] + * [2014 Opensource.com summer reading list][33] + * [2013 Opensource.com summer reading list][34] + * [2012 Opensource.com summer reading list][35] + * [2011 Opensource.com summer reading list][36] + * [2010 Opensource.com summer reading list][37] + + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/2021-opensourcecom-summer-reading-list + +作者:[Joshua Allen Holm][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/holmja +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/reading_book_selfcare_wfh_learning_education_520.png?itok=H6satV2u (Reading a book, selfcare) +[2]: https://us.macmillan.com/books/9780374110031 +[3]: https://opensource.com/sites/default/files/uploads/beowulf.jpg (Beowulf book cover) +[4]: https://opensource.com/users/ksonney +[5]: https://www.simonandschuster.com/books/Competing-On-Internet-Time/David-B-Yoffie/9780684831121 +[6]: https://opensource.com/sites/default/files/uploads/competing_on_internet_time.jpg (Competing on Internet Time book cover) +[7]: https://opensource.com/users/gkamathe +[8]: https://dunenovels.com/dune/ +[9]: https://opensource.com/sites/default/files/uploads/dune.jpg (Dune book cover) +[10]: https://opensource.com/users/mbbroberg +[11]: https://twitter.com/mbbroberg/status/1372323276802961408 +[12]: https://press.princeton.edu/books/hardcover/9780691182070/hacking-diversity +[13]: https://opensource.com/sites/default/files/uploads/hacking_diversity.jpg (Hacking Diversity book cover) +[14]: https://opensource.com/users/bbehrens +[15]: https://letterstoanewdeveloper.com/the-book/ +[16]: https://opensource.com/sites/default/files/uploads/letters_to_a_new_developer_150.jpg (Letters to a New Developer book cover) +[17]: https://opensource.com/users/holmja +[18]: https://www.erewhonbooks.com/books/the-all-consuming-world-cassandra-khaw +[19]: https://opensource.com/sites/default/files/uploads/the_all-consuming_world.jpg (The All-Consuming World book cover) +[20]: https://www.alexbellos.com/language +[21]: https://opensource.com/sites/default/files/uploads/the_language_lover_s_puzzle_book.jpg (The Language Lover's Puzzle Book cover) +[22]: https://en.wikipedia.org/wiki/Dothraki_language +[23]: https://www.youtube.com/watch?v=2NLquktkdqk +[24]: https://www.amazon.com/dp/B08WK5X45V/ +[25]: https://press.princeton.edu/books/hardcover/9780691219097/understanding-the-digital-world +[26]: https://opensource.com/sites/default/files/uploads/understanding_the_digital_world.jpg (Understanding the Digital World book cover) +[27]: https://opensource.com/users/jim-hall +[28]: https://opensource.com/article/20/6/summer-reading-list +[29]: https://opensource.com/article/19/6/summer-reading-list +[30]: https://opensource.com/open-organization/18/6/summer-reading-2018 +[31]: https://opensource.com/life/16/6/2016-summer-reading-list +[32]: https://opensource.com/life/15/6/2015-summer-reading-list +[33]: https://opensource.com/life/14/6/annual-reading-list-2014 +[34]: https://opensource.com/life/13/6/summer-reading-list-2013 +[35]: https://opensource.com/life/12/7/your-2012-open-source-summer-reading +[36]: https://opensource.com/life/11/7/summer-reading-list +[37]: https://opensource.com/life/10/8/open-books-opensourcecom-summer-reading-list diff --git a/sources/tech/20210621 Why I love programming on FreeDOS with GW-BASIC.md b/sources/tech/20210621 Why I love programming on FreeDOS with GW-BASIC.md new file mode 100644 index 0000000000..d36b04e6db --- /dev/null +++ b/sources/tech/20210621 Why I love programming on FreeDOS with GW-BASIC.md @@ -0,0 +1,141 @@ +[#]: subject: (Why I love programming on FreeDOS with GW-BASIC) +[#]: via: (https://opensource.com/article/21/6/freedos-gw-basic) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Why I love programming on FreeDOS with GW-BASIC +====== +BASIC was my entry into computer programming. I haven't written BASIC +code in years, but I'll always have a fondness for BASIC and GW-BASIC. +![Old UNIX computer][1] + +When I was growing up, it seemed every "personal computer" from the TRS-80 to the Commodore to the Apple let you write your own programs in the Beginners' All-purpose Symbolic Instruction Code ([BASIC][2]) programming language. Our family had a clone of the Apple II called the Franklin ACE 1000, which—as a clone—also ran AppleSoft BASIC. I took to AppleSoft BASIC right away and read books and magazines to teach myself about BASIC programming. + +Later, our family upgraded to an IBM PC running DOS. Just like every personal computer before it, the IBM PC also ran its own version of DOS, called BASICA. Later versions of DOS replaced BASIC with an updated interpreter called GW-BASIC. + +BASIC was my entry into computer programming. As I grew up, I learned other programming languages. I haven't written BASIC code in years, but I'll always have a fondness for BASIC and GW-BASIC. + +### Microsoft open-sources GW-BASIC + +In May 2020, Microsoft surprised everyone (including me) by releasing the source code to GW-BASIC. Rich Turner (Microsoft) wrote in the [announcement][3] on the Microsoft Developer Blog: + +“Since re-open-sourcing MS-DOS 1.25 & 2.0 on GitHub last year, we’ve received numerous requests to also open-source Microsoft BASIC. Well, here we are! As clearly stated in the repo's readme, these sources are the 8088 assembly language sources from 10th Feb 1983 and are being open-sourced for historical reference and educational purposes. This means we will not be accepting PRs (Pull Requests) that modify the source in any way.” + +You can find the GW-BASIC source code release at the [GW-BASIC GitHub][4]. And yes, Microsoft used the [MIT License][5], which makes this open source software. + +Unfortunately, the GW-BASIC code was entirely in Assembly, which wouldn't build with modern tools. But open source developers got to work on that and adjusted the code to assemble with updated DOS assemblers. One project is [TK Chia's GitHub][6] project to update GW-BASIC to assemble with JWASM or other assemblers. You can find several [source and binary releases][7] on TK Chia's project. The notes from the latest version (October 2020) mention that this is “a 'pre-release' binary of GW-BASIC as rebuilt in 2020” and that “support for serial port I/O is missing. Light pen input, joystick input, and printer (parallel port) output need more testing.”  But if you don't need those extra features in GW-BASIC, you should be able to use this latest release to get back into BASIC programming with an open-sourced GW-BASIC. + +FreeDOS 1.3 RC4 doesn't include GW-BASIC, but installing it is pretty easy. Just download the `gwbas-20201025.zip` archive file from TK Chia's October 2020 GW-BASIC release, and extract it (unzip it) on your FreeDOS system. The binary archive uses a default path of `\DEVEL\GWBASIC`. + +### Getting started with GW-BASIC + +To start GW-BASIC, run the `GWBASIC.EXE` program from the DOS command line. Note that DOS is _case insensitive_ so you don't actually need to type that in all uppercase letters. Also, DOS will run any `EXE` or `COM` or `BAT` programs automatically, so you don't need to provide the extension, either. Go into the `\DEVEL\GWBASIC` and type `GWBASIC` to run BASIC. + +![GW-BASIC][8] + +The GW-BASIC interpreter +(Jim Hall, [CC-BY SA 4.0][9]) + +GW-BASIC is an _interpreted_ programming language. The GW-BASIC environment is a "shell" that parses each line in your BASIC program _as it runs the code_. This is a little slower than _compiled_ languages like C but makes for an easier coding-debugging cycle. You can test your code as you go, just by entering it into the interpreter. + +Each line in a GW-BASIC program needs to start with a line number. GW-BASIC uses the line numbers to make sure it executes your program statements in the correct order. With these line numbers, you can later "insert" new program statements between two other statements by giving it a line number that's somewhere in between the other line numbers. For this reason, most BASIC programmers wrote line numbers that went up by tens so that line numbers would go like 10, 20, 30, and so on. + +New to GW-BASIC? You can learn about the programming language by reading an online GW-BASIC reference. Microsoft didn't release a programming guide with the GW-BASIC source code, but you can search for one. [Here's one reference][10] that seems to be a copy of the original Microsoft GW-BASIC User's Guide. + +Let's start with a simple program to print out a list of random numbers. The `FOR` statement creates a loop over a range of numbers, and `RND(1)` prints a random value between 0 and 1. + +![GW-BASIC][11] + +Entering our first program +(Jim Hall, [CC-BY SA 4.0][9]) + +Do you see those highlighted words at the bottom of the screen? Those are keyboard shortcuts that you can access using the "F" keys (or _function_ keys) on your keyboard. For example, F1 will insert the word `LIST` into the GW-BASIC interpreter. The "left arrow" indicates that the shortcut will hit Enter for you, so F2 will enter the `RUN` command and immediately execute it. Let's run the program a few times to see what happens. + +![GW-BASIC][12] + +The two lists of random numbers are the same +(Jim Hall, [CC-BY SA 4.0][9]) + +Interestingly, the list of random numbers is the same every time we run the BASIC program. That's because the GW-BASIC random number generator resets every time you execute a BASIC program. + +To generate new random numbers every time, we need to "seed" the random number generator with a value. One way to do this is by prompting the user to enter their own seed, then use that value with the `RANDOMIZE` instruction. We can insert those two statements at the top of the program using line numbers 1 and 2. GW-BASIC will automatically add those statements before line 10. + +![GW-BASIC][13] + +Updating the program +(Jim Hall, [CC-BY SA 4.0][9]) + +With the random number generator using a new seed, we get a different list of random numbers every time we run our program. + +![GW-BASIC][14] + +Now the lists of random numbers are different +(Jim Hall, [CC-BY SA 4.0][9]) + +### "Guess the number" game in GW-BASIC + +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. + +Let's write a version of this "guess the number" game in GW-BASIC. To start, enter the `NEW` instruction to tell GW-BASIC to forget the previous program and start a new one. + +My "guess the number" program first prompts the user to enter a random number seed, then generates a random number between 1 and 100. The `RND(1)` function actually generates a random value between 0 and 1 (actually 0.9999…) so I first multiply `RND(1)` by 100 to get a value between 0 and 99.9999…, then I turn that into an integer (remove everything after the decimal point). Adding 1 gives a number that's between 1 and 100. + +The program then enters a simple loop where it prompts the user for a guess. If the guess is too low or too high, the program lets the user know to adjust their guess. The loop continues as long as the user's guess is _not_ the same as the random number picked earlier. + +![GW-BASIC][15] + +Entering a "guess the number" program +(Jim Hall, [CC-BY SA 4.0][9]) + +We can run the program by tapping the F2 key. Using a random seed of 1234 generates a completely new random number. It took me six guesses to figure out the secret number was 49. + +![GW-BASIC][16] + +Guessing the secret number +(Jim Hall, [CC-BY SA 4.0][9]) + +And that's your first introduction to GW-BASIC programming! Thanks to Microsoft for releasing this great piece of history as open source software, and thanks also to the many open source developers who assembled GW-BASIC so we can run it. + +One more thing before I go—It's not obvious how to exit GW-BASIC. The interpreter had a special instruction for that—to quit, enter `SYSTEM` and GW-BASIC will exit back to DOS. + +![GW-BASIC][17] + +Enter SYSTEM to quit GW-BASIC +(Jim Hall, [CC-BY SA 4.0][9]) + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/freedos-gw-basic + +作者:[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/retro_old_unix_computer.png?itok=SYAb2xoW (Old UNIX computer) +[2]: https://en.wikipedia.org/wiki/BASIC#:~:text=BASIC%20(Beginners'%20All%2Dpurpose,at%20Dartmouth%20College%20in%201964. +[3]: https://devblogs.microsoft.com/commandline/microsoft-open-sources-gw-basic/ +[4]: https://github.com/microsoft/GW-BASIC +[5]: https://github.com/microsoft/GW-BASIC/blob/master/LICENSE +[6]: https://github.com/tkchia/GW-BASIC +[7]: https://github.com/tkchia/GW-BASIC/releases +[8]: https://opensource.com/sites/default/files/uploads/gwbasic1.png (The GW-BASIC interpreter) +[9]: https://creativecommons.org/licenses/by-sa/4.0/ +[10]: http://www.antonis.de/qbebooks/gwbasman/index.html +[11]: https://opensource.com/sites/default/files/uploads/gwbasic2.png (Entering our first program) +[12]: https://opensource.com/sites/default/files/uploads/gwbasic3.png (The two lists of random numbers are the same) +[13]: https://opensource.com/sites/default/files/uploads/gwbasic4.png (Updating the program) +[14]: https://opensource.com/sites/default/files/uploads/gwbasic5.png (Now the lists of random numbers are different) +[15]: https://opensource.com/sites/default/files/uploads/guessnum1.png (Entering a "guess the number" program) +[16]: https://opensource.com/sites/default/files/uploads/guessnum2.png (Guessing the secret number) +[17]: https://opensource.com/sites/default/files/uploads/guessnum3.png (Enter SYSTEM to quit GW-BASIC) diff --git a/sources/tech/20210622 Edit text like Emacs in FreeDOS.md b/sources/tech/20210622 Edit text like Emacs in FreeDOS.md new file mode 100644 index 0000000000..53f5ce1356 --- /dev/null +++ b/sources/tech/20210622 Edit text like Emacs in FreeDOS.md @@ -0,0 +1,108 @@ +[#]: subject: (Edit text like Emacs in FreeDOS) +[#]: via: (https://opensource.com/article/21/6/freemacs) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Edit text like Emacs in FreeDOS +====== +If you're already familiar with GNU Emacs, you should feel right at home +in Freemacs. +![Typewriter in the grass][1] + +On Linux, I often use the GNU Emacs editor to write the source code for new programs. I learned GNU Emacs long ago when I was an undergraduate student, and I still have the "finger memory" for all the keyboard shortcuts. + +When I started work on FreeDOS in 1994, I wanted to include an Emacs-like text editor. You can find many editors similar to Emacs, such as MicroEmacs, but these all take some shortcuts to fit into the 16-bit address space on DOS. However, I was very pleased to find Freemacs, by Russell "Russ" Nelson. + +You can find Freemacs in FreeDOS 1.3 RC4, on the Bonus CD. You can use FDIMPLES to install the package, which will install to `\APPS\EMACS`. + +![installing Freemacs][2] + +Installing Freemacs from the FreeDOS 1.3 RC4 Bonus CD +(Jim Hall, [CC-BY SA 4.0][3]) + +### Initial setup + +The first time you run Freemacs, the editor will need to "compile" all of the setup files into a form that Freemacs can quickly process. This will take a few minutes to run, depending on your system's speed and memory, but fortunately, you only need to do it once. + +![Running Freemacs for the first time][4] + +Press Y to build the Freemacs MINT files +(Jim Hall, [CC-BY SA 4.0][3]) + +Freemacs actually processes the editor files in two passes. When Freemacs has successfully completed the first pass, it prompts you to restart the editor so it can finish processing. So don't be surprised that the process seems to start up again—it's just "part 2" of the compilation process. + +### Using Freemacs + +To edit a file with Freemacs, start the program with the text file as an argument on the command line. For example, `emacs readme.doc` will open the Readme file for editing in Freemacs. Typing `emacs` at the command line, without any options, will open an empty "scratch" buffer in Freemacs. + +![Freemacs][5] + +Starting Freemacs without any files opens a "scratch" buffer +(Jim Hall, [CC-BY SA 4.0][3]) + +Or, you can start Freemacs without any command-line options, and use the Emacs shortcuts C-x C-f (or M-x `find-file`). Freemacs then prompts you for a new file to load into the editor. The shortcut prefix C- means you should press the Ctrl key and some other key, so C-x is Ctrl and the x key together. And M-x is shorthand for "press the 'Meta' key (usually Esc) then hit x." + +![Freemacs][6] + +Opening a new file with C-x C-f +(Jim Hall, [CC-BY SA 4.0][3]) + +Freemacs automatically detects the file type and attempts to load the correct support. For example, opening a C source file will also set Freemacs to "C-mode." + +![Freemacs][7] + +Editing a C source file in Freemacs +(Jim Hall, [CC-BY SA 4.0][3]) + +If you also use GNU Emacs (like me), then you are probably curious to get Freemacs to match the C indentation that GNU Emacs uses (2 spaces.) Here is how to set Freemacs to use 2 spaces in C-mode: + + 1. Open a C source file in Freemacs. + 2. Enter M-x `edit-options` to edit Freemacs settings. + 3. Use the settings to change both "C-brace-offset" and "C-indent-level" to 2. + 4. Save and exit Freemacs; you'll be prompted to save settings. + + + +### A few limitations + +Much of the rest of Freemacs operates like GNU Emacs. If you're already familiar with GNU Emacs, you should feel right at home in Freemacs. However, Freemacs does have a few limitations that you might need to know: + +**The extension language is not LISP.** The biggest difference between GNU Emacs on Linux and Freemacs on FreeDOS is that Freemacs uses a different extension language. Where GNU Emacs implements a LISP-like interpreter, Freemacs implements a different extension language called MINT—based on the string processing language, TRAC. The name "MINT" is an acronym, meaning "MINT Is Not TRAC." + +You shouldn't expect to evaluate LISP code in Freemacs. The MINT language is completely different from LISP. For more information on MINT, see the reference manual. We provide the full documentation via the FreeDOS files archive on Ibiblio, at [/freedos/files/edit/emacs/docs][8]. In particular, the MINT language is defined in [mint.txt][9] and [mint2.txt][10]. + +**Freemacs cannot open files larger than 64 kilobytes.** This is a common limitation in many programs. 64kb is the maximum size of the data space for programs that do not leverage extended memory. + +**There is no "Undo" feature.** Be careful in editing. If you make a mistake, you will have to re-edit your file to get it back to the old version. Also, save early and often. For very large mistakes, your best path might be to abandon the version you're editing in Freemacs, and load the last saved version. + +The rest is up to you! You can find more information about Freemacs on Ibiblio, at [/freedos/files/edit/emacs/docs][8]. For a quick-start guide to Freemacs, read [quickie.txt][11]. The full manual is in [tutorial.txt][12]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/freemacs + +作者:[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/doc-dish-lead.png?itok=h3fCkVmU (Typewriter in the grass) +[2]: https://opensource.com/sites/default/files/uploads/install1.png (Installing Freemacs from the FreeDOS 1.3 RC4 Bonus CD) +[3]: https://creativecommons.org/licenses/by-sa/4.0/ +[4]: https://opensource.com/sites/default/files/uploads/first-run1_0.png (Press Y to build the Freemacs MINT files) +[5]: https://opensource.com/sites/default/files/uploads/freemacs1.png (Starting Freemacs without any files opens a "scratch" buffer) +[6]: https://opensource.com/sites/default/files/uploads/freemacs2.png (Opening a new file with C-x C-f) +[7]: https://opensource.com/sites/default/files/uploads/freemacs3.png (Editing a C source file in Freemacs) +[8]: https://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/edit/emacs/docs/ +[9]: https://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/edit/emacs/docs/mint.txt +[10]: https://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/edit/emacs/docs/mint2.txt +[11]: https://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/edit/emacs/docs/quickie.txt +[12]: https://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/edit/emacs/docs/tutorial.txt diff --git a/sources/tech/20210622 How to Make LibreOffice Look Like Microsoft Office.md b/sources/tech/20210622 How to Make LibreOffice Look Like Microsoft Office.md new file mode 100644 index 0000000000..63931dca94 --- /dev/null +++ b/sources/tech/20210622 How to Make LibreOffice Look Like Microsoft Office.md @@ -0,0 +1,134 @@ +[#]: subject: (How to Make LibreOffice Look Like Microsoft Office) +[#]: via: (https://www.debugpoint.com/2021/06/libreoffice-like-microsoft-office/) +[#]: author: (Arindam https://www.debugpoint.com/author/admin1/) +[#]: collector: (lujun9972) +[#]: translator: (piaoshi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +How to Make LibreOffice Look Like Microsoft Office +====== +We made an attempt to make the LibreOffice suite look like Microsoft +Office. Is it possible? Let’s find out. +[LibreOffice][1] is a free and open-source office productivity suite that provides you a complete collection of applications. It consists of a Word processor (Writer), a spreadsheet program (Calc), Presentation (Impress), and a drawing program (Draw). It also gives you a stand-alone database system LibreOffice Base while LibreOffice Math is a program that helps students, researchers to write formulas and equations. + +While, the widely used [Microsoft Office][2] is a paid office productivity suite that gives you excellent programs to perform almost all tasks related to study, office, and enterprise usage. + +Both of the programs are different but their objective is the same in terms of functionality. Due to its popularity, Microsoft office is used widely and well known to the users. However, there are many users who prefer the free LibreOffice for their work and activities. Adopting LibreOffice sometimes difficult compared to Microsoft Office – although most of the menu items, tools are the same. + +That said, if you can make LibreOffice look like Microsoft Office, then it is much easier for first-time users to adopt – mostly coming from Microsoft Office background. The look and feel play a big part in users’ minds including their muscle memory and familiarity of colors, menu items. + +Of course, you can not make it exactly like Microsoft Office because of different icons, fonts, etc. However, you can make it look up to a certain amount. + +### Make LibreOffice Look Like Microsoft Office + +_This guide is prepared in LibreOffice 7.2 (dev) version._ + +#### 1\. User Interface changes + +LibreOffice has a “Ribbon” style toolbar called Tabbed Bar. Although it comes with many options of the toolbar (see below). For this guide, I have used the Tabbed bar option. + + * Open LibreOffice and go to `Menu > View > User Interface`. + * Select `Tabbed` from the UI Section. + + + +![tabbed bar option][3] + + * Click on Apply to All. LibreOffice also provides an option to apply the toolbar type-specific to Writer or Calc. If you want a different toolbar type, you can choose that way. But I would recommend using the Apply to All to make it consistent. + + + * Now you should have the Microsoft Office-style Ribbon. Although they are not exactly the same, you get the feel of it. + + + +#### 2\. Microsoft Office Icons for LibreOffice + +The Icons in the toolbar play a big part in your workflow. LibreOffice provides some nice icons for your toolbar. The best ones are the – + + * Karasa Jaga + * Colibre + * Elementary + + + +For this guide, we will use [Office 2013 icon set][4] which is developed by an author. It is available in Devian Art. + + * Go to the below link and download the LibreOffice extension file (*.oxt). For the newer versions of LibreOffice, you need to use extension files to install icon sets. + + + +[download office 2013 icon sets for libreoffice][5] + + * After download, double click the .oxt file to open. Or, press CTRL+ALT+E to open the Extension Manager and select the downloaded .oxt file using the Add button. Close the window once done. + + + +![Import icon sets in Extension Manager][6] + + * Now go to `Tools > Options > View`. From the Icon style choose Office 2013. + + + * Change the icon size via `Icon Size > Notebookbar > Large`. If you feel the icons are small, you can change them. However, I feel to make it more Office-like, the large settings work better. + + + +![Change icons in Options][7] + +And, that’s it. Your LibreOffice installation should look like this. + +[][8] + +SEE ALSO:   LibreOffice 7.2 - New Features and Release Details + +![Making LibreOffice look like Microsoft Office in KDE Plasma][9] + +![Making LibreOffice look like Microsoft Office in Windows 10][10] + +![Making LibreOffice look like Microsoft Office in GNOME][11] + +Remember, if you are using Ubuntu, KDE Plasma, or any Linux distribution, the looks may be different. But in my opinion, it looks closer to Microsoft Office in KDE Plasma than GNOME. LibreOffice doesn’t look good in GTK based systems at the moment. + +In Windows, however, it looks better because it uses system font, color palette. + +These are some settings that you can use, however, you can play around with more customizations, icons, and themes as you wish. If you fancy dark mode in LibreOffice, you may want to read our tutorial – [how to enable dark mode in LibreOffice][12]. + +### Closing Notes + +Microsoft Office is undoubtedly the market leader in the Office productivity space. There is a reason for it, it comes with decades of development, and it’s not a free product. In fact, the latest Office 365 Home usage price is around ~7 USD per month for 3 to 4 devices. Which is a bit pricy if you ask me. + +Whereas LibreOffice is free and community developed headed by The Document Foundation. Hence, the development is slower and features arrive late. It is not trying to be Microsoft Office but gives millions of users, schools, non-profits, colleges, students an opportunity to work and learn using a free office suite. + +Hence, it is beneficial if it can mimic the basic look and feel to make it like Microsoft Office to increase LibreOffice adoption. And I hope this guide serves a little purpose in that direction. + +[_Link: Official Feature comparison between LibreOffice and Microsoft Office._][13] + +* * * + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2021/06/libreoffice-like-microsoft-office/ + +作者:[Arindam][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lujun9972 +[1]: http://libreoffice.com +[2]: http://office.com +[3]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/tabbed-bar-option.jpg +[4]: https://www.deviantart.com/charliecnr/art/Office-2013-theme-for-LibreOffice-512127527 +[5]: https://www.deviantart.com/users/outgoing?https://1drv.ms/u/s!ArgKmgFcmBYHhSQkPfyMZRnXX5LJ +[6]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/Import-icon-sets-in-Extension-Manager.jpg +[7]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/Change-icons-in-Options-1024x574.jpg +[8]: https://www.debugpoint.com/2021/05/libreoffice-7-2/ +[9]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/Making-LibreOffice-look-like-Microsoft-Office-in-KDE-Plasma-1024x441.jpg +[10]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/Making-LibreOffice-look-like-Microsoft-Office-in-Windows-10-1024x554.jpg +[11]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/Making-LibreOffice-look-like-Microsoft-Office-in-GNOME-1024x498.jpg +[12]: https://www.debugpoint.com/2020/01/how-to-enable-dark-mode-libreoffice/ +[13]: https://wiki.documentfoundation.org/Feature_Comparison:_LibreOffice_-_Microsoft_Office diff --git a/sources/tech/20210622 What is a config file.md b/sources/tech/20210622 What is a config file.md new file mode 100644 index 0000000000..cadb9d3e7a --- /dev/null +++ b/sources/tech/20210622 What is a config file.md @@ -0,0 +1,184 @@ +[#]: subject: (What is a config file?) +[#]: via: (https://opensource.com/article/21/6/what-config-files) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +What is a config file? +====== +There are several popular formats for configuration files, each with its +own strengths. Find what works best for you. +![Computer screen with files or windows open][1] + +There are thousands of configuration files on your computer. You may never directly interact with the bulk of them, but they're scattered throughout your `/etc` folder and in `~/.config` and `~/.local` and `/usr`. There are probably some in `/var` and possibly even in `/opt`. If you've ever opened one by accident or to make a change, you may have wondered why some configuration files look one way while others look completely different. + +Storing configurations is a flexible task because as long as developers know how their code puts data into a file, they can easily write code to extract that data as needed. However, the tech industry graciously favors well-documented standardization, so several well-known formats have evolved over the years to make configuration easy. + +### Why we need configuration + +Configuration files ("config files" for short) are important to modern computing. They allow you to customize how you interact with an application or how an application interacts with the rest of your system. It's thanks to config files that any time you launch an application, it has "memories" of how you like to use it. + +Configuration files can be, and often are, very simple in structure. For instance, if you were to write an application, and the only thing it ever needed to know was its user's preferred name, then its one and only config file could contain exactly one word: the name of the user. For example: + + +``` +`Tux` +``` + +Usually, though, an application needs to keep track of more than just one piece of information, so configuration often uses a key and a value: + + +``` +NAME='Tux' +SPECIES='Penguin' +``` + +Even without programming experience, you can imagine how code parses that data. Here are two simple examples, one using the [`awk` command][2] and the other using the [grep command][3], focusing on just the line containing the "key" of `NAME`, and returning the "value" appearing after the equal sign (`=`): + + +``` +$ awk -F'=' '/NAME/ { print $2; }' myconfig.ini +'Tux' +$ grep NAME fake.txt | cut -d'=' -f2 +'Tux' +``` + +The same principle applies to any programming language and any configuration file. As long as you have a consistent data structure, you can write simple code to extract and parse it when necessary. + +### Choose a format + +To be broadly effective, the most important thing about configuration files is that they are consistent and predictable. The last thing you want to do is dump information into a file under the auspices of saving user preferences and then spend days writing code to reverse-engineer the random bits of information that have ended up in the file. + +There are several popular formats for configuration files, each with its own strengths. + +#### INI + +INI files take the format of key and value pairs: + + +``` +[example] +name=Tux +style=widgety,fidgety +enabled=1 +``` + +This simple style of configuration can be intuitive, with the only point of confusion being poor key names (for example, cryptic names like `unampref` instead of `name`). They're easy to parse and easy to edit. + +The INI format features sections in addition to keys and values. In this sample code, `[example]` and `[demo]` are configuration sections: + + +``` +[example] +name=Tux +style=widgety,fidgety +enabled=1 + +[demo] +name=Beastie +fullscreen=1 +``` + +This is a little more complex to parse because there are _two_ `name` keys. You can imagine a careless programmer querying this config file for `name` and always getting back `Beastie` because that's the last name defined by the file. When parsing such a file, a developer must be careful to search within sections for keys, which can be tricky depending on the language used to parse the file. However, it's a popular enough format that most languages have an existing library to help programmers parse INI files. + +#### YAML + +[YAML files][4] are structured lists that can contain values or key and value pairs: + + +``` +\--- +Example: +  Name: 'Tux' +  Style: +   - 'widgety' +    - 'fidgety' +  Enabled: 1 +``` + +YAML is popular partly because it looks clean. It doesn't have much of a syntax aside from where you place the data in relation to previous data. What's a feature for some, though, is a bug for others, and many developers avoid YAML because of the significance it places on what is essentially _not there_. If you get indentation wrong in YAML, YAML parsers may see your file as invalid, and even if it's tolerated, it may return incorrect data. + +Most languages have YAML parsers, and there are good open source YAML linters (applications to validate syntax) to help you ensure the integrity of a YAML file. + +#### JSON + +JSON files are technically subsets of YAML, so its data structure is the same, although its syntax is completely different: + + +``` +{ +  "Example": { +    "Name": [ +      "Tux" +    ], +    "Style": [ +      "widgety", +      "fidgety" +    ], +    "Enabled": 1 +  } +} +``` + +JSON is popular among JavaScript programmers, which isn't surprising, given that JSON stands for JavaScript Object Notation. As a result of being strongly associated with web development, JSON is a common output format for web APIs. Most programming languages have libraries to parse JSON. + +#### XML + +XML uses tags as keys that surround a configuration value: + + +``` +<example> +  <name>Tux</name> +  <style priority="user">widgety</style> +  <style priority="fallback">fidgety</style> +  <enabled>1</enabled> +</example> +``` + +XML is often used by Java programmers, and Java has a rich set of XML parsers. While it has a reputation of being quite strict, XML is simultaneously very flexible. Unlike HTML, which has a set of tags you're allowed to use, you can arbitrarily invent your own XML tags. As long as you structure it consistently and have a good library to parse it, you can extract your data with precision and ease. + +There are some good open source linters to help you validate XML files, and most programming languages have a library to parse XML. + +#### Binary formats + +Linux prides itself on plain-text configuration. The advantage is that you can see configuration data using basic tools like [cat][5], and you can even edit a configuration with your [favorite text editor][6]. + +Some applications use binary formats, though, which means the data is encoded in some format that is not a natural language. These files usually require a special application (usually the application they're meant to configure) to interpret their data. +You can't view these files, at least not in a way that makes any sense, and you can't edit them outside of their host application. Some reasons for resorting to binary formats are: + + * **Speed:** A programmer can register specific bits of information at certain points within a binary's config file using custom notation. When the data is extracted, there's no searching involved because everything is already indexed. + * **Size:** Text files can get big, and should you choose to compress a text file, you're functionally turning it into a binary format. Binary files can be made smaller through tricks of encoding (the same is true of text files, but at some point, your optimizations make your data so obscure that it may as well be binary). + * **Obfuscation:** Some programmers don't want people even looking at their configuration files, so they encode them as binary data. This usually succeeds only in frustrating users. This is not a good reason to use binary formats. + + + +If you must use a binary format for configuration, use one that already exists as an open standard, such as [NetCDF][7]. + +### Find what works + +Configuration formats help developers store the data their applications need and help users store preferences for how they want applications to act. There's probably no wrong answer to the question of what format you should use, as long as you feel well supported by the language you're using. When developing your application, look at the formats available, model some sample data, review and evaluate the libraries and utilities your programming language provides, and choose the one you feel the most confident about. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/what-config-files + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_screen_windows_files.png?itok=kLTeQUbY (Computer screen with files or windows open) +[2]: https://opensource.com/article/20/9/awk-ebook +[3]: https://opensource.com/downloads/grep-cheat-sheet +[4]: https://www.redhat.com/sysadmin/yaml-beginners +[5]: https://opensource.com/article/19/2/getting-started-cat-command +[6]: https://opensource.com/article/21/2/open-source-text-editors +[7]: https://www.unidata.ucar.edu/software/netcdf/ diff --git a/sources/tech/20210623 Parsing config files with Lua.md b/sources/tech/20210623 Parsing config files with Lua.md new file mode 100644 index 0000000000..50b47fa003 --- /dev/null +++ b/sources/tech/20210623 Parsing config files with Lua.md @@ -0,0 +1,231 @@ +[#]: subject: (Parsing config files with Lua) +[#]: via: (https://opensource.com/article/21/6/parsing-config-files-lua) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Parsing config files with Lua +====== +Configure persistent application settings with the Lua programming +language. +![Woman sitting in front of her computer][1] + +Not all applications need configuration files; many applications benefit from starting fresh each time they are launched. Simple utilities, for instance, rarely require preferences or settings that persist across uses. However, when you write a complex application, it's nice for users to be able to configure how they interact with it and how it interacts with their system. That's what configuration files are for, and this article discusses some of the ways you can implement persistent settings with the Lua programming language. + +### Choose a format + +The important thing about configuration files is that they are consistent and predictable. You do not want to dump information into a file under the auspices of saving user preferences and then spend days writing code to reverse-engineer the random bits of information that have ended up in the file. + +There are several popular [formats for configuration files][2]. Lua has libraries for most of the common configuration formats; in this article, I'll use the INI format. + +### Installing the library + +The central hub for Lua libraries is [Luarocks.org][3]. You can search for libraries on the website, or you can install and use the `luarocks` terminal command. + +On Linux, you can install it from your distribution's software repository. For example: + + +``` +`$ sudo dnf install luarocks` +``` + +On macOS, use [MacPorts][4] or [Homebrew][5]. On Windows, use [Chocolatey][6]. + +Once `luarocks` is installed, you can use the `search` subcommand to search for an appropriate library. If you don't know the name of a library, you can search for a keyword, like `ini` or `xml` or `json`, depending on what's relevant to what you're trying to do. In this case, you can just search for `inifile`, which is the library I use to parse text files in the INI format: + + +``` +$ luarocks search inifile +Search results: +inifile + 1.0-2 (rockspec) - + 1.0-2 (src) - + 1.0-1 (rockspec) - + [...] +``` + +A common trap programmers fall into is installing a library on their system and forgetting to bundle it with their application. This can create problems for users who don't have the library installed. To avoid this, use the `--tree` option to install the library to a local folder within your project directory. If you don't have a project directory, create one first, and then install: + + +``` +$ mkdir demo +$ cd demo +$ luarocks install --tree=local inifile +``` + +The `--tree` option tells `luarocks` to create a new directory, called `local` in this case, and install your library into it. With this simple trick, you can install all the dependency code your project uses directly into the project directory. + +### Code setup + +First, create some INI data in a file called `myconfig.ini`: + + +``` +[example] +name=Tux +species=penguin +enabled=false + +[demo] +name=Beastie +species=demon +enabled=false +``` + +Save the file as `myconfig.ini` into your home directory, _not_ into your project directory. You usually want configuration files to exist outside your application so that even when a user uninstalls your application, the data they generate while using the application remains on their system. Users might remove unnecessary config files manually, but many don't. As a result, if they reinstall an application, it will retain all of their preferences. + +Config file locations are technically unimportant, but each operating system (OS) has a specification or a tradition of where they ought to be placed. On Linux, this is defined by the [Freedesktop specification][7]. It dictates that configuration files are to be saved in a hidden folder named `~/.config`. For clarity during this exercise, just save the file in your home directory so that it's easy to find and use. + +Create a second file named `main.lua` and open it in your favorite text editor. + +First, you must tell Lua where you've placed the additional library you want it to use. The `package.path` variable determines where Lua looks for libraries. You can view Lua's default package path in a terminal: + + +``` +$ Lua +> print(package.path) +./?.lua;/usr/share/lua/5.3/?.lua;/usr/share/lua/5.3/?/init.lua;/usr/lib64/lua/5.3/?.lua;/usr/lib64/lua/5.3/?/init.lua +``` + +In your Lua code, append your local library location to `package.path`: + + +``` +`package.path = package.path .. ';local/share/lua/5.3/?.lua` +``` + +### Parsing INI files with Lua + +With the package location established, the next thing to do is to require the `inifile` library and then handle some OS logistics. Even though this is a simple example application, the code needs to get the user's home directory location from the OS and establish how to communicate filesystem paths back to the OS when necessary: + + +``` +package.path = package.path .. ';local/share/lua/5.3/?.lua +inifile = require('inifile') + +\-- find home directory +home = os.getenv('HOME') + +\-- detect path separator +\-- returns '/' for Linux and Mac +\-- and '\' for Windows +d = package.config:sub(1,1) +``` + +Now you can use `inifile` to parse data from the config file into a Lua table. Once the data has been placed into a table, you can query the table as you would any other Lua table: + + +``` +\-- parse the INI file and +\-- put values into a table called conf +conf = inifile.parse(home .. d .. 'myconfig.ini') + +\-- print the data for review +print(conf['example']['name']) +print(conf['example']['species']) +print(conf['example']['enabled']) +``` + +Run the code in a terminal to see the results: + + +``` +$ lua ./main.lua +Tux +penguin +false +``` + +That looks correct. Try doing the same for the `demo` block. + +### Saving data in the INI format + +Not all parser libraries read and write data (often called _encoding_ and _decoding_), but the `inifile` library does. That means you can use it to make changes to a configuration file. + +To change a value in a configuration file, you set the variable representing the value in the parsed table, and then you write the table back to the configuration file: + + +``` +\-- set enabled to true +conf['example']['enabled'] = true +conf['demo']['enabled'] = true + +\-- save the change +inifile.save(home .. d .. 'myconfig.ini', conf) +``` + +Take a look at the configuration file now: + + +``` +$ cat ~/myconfig.ini +[example] +name=Tux +species=penguin +enabled=true + +[demo] +name=Beastie +species=demon +enabled=true +``` + +### Config files + +The ability to save data about how a user wants to use an application is an important part of programming. Fortunately, it's a common task for programmers, so much of the work has probably already been done. Find a good library for encoding and decoding into an open format, and you can provide a persistent and consistent user experience. + +Here's the entire demo code for reference: + + +``` +package.path = package.path .. ';local/share/lua/5.3/?.lua' +inifile = require('inifile') + +\-- find home directory +home = os.[getenv][8]('HOME') + +\-- detect path separator +\-- returns '/' for Linux and Mac +\-- and '\' for Windows +d = package.config:sub(1,1) + +\-- parse the INI file and +\-- put values into a table called conf +conf = inifile.parse(home .. d .. 'myconfig.ini') + +\-- print the data for review +print(conf['example']['name']) +print(conf['example']['species']) +print(conf['example']['enabled']) + +\-- enable Tux +conf['example']['enabled'] = true + +\-- save the change +inifile.save(home .. d .. 'myconfig.ini', conf) +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/parsing-config-files-lua + +作者:[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_2.png?itok=JPlR5aCA (Woman sitting in front of her computer) +[2]: https://opensource.com/article/21/6/config-files-and-their-formats +[3]: https://opensource.com/article/19/11/getting-started-luarocks +[4]: https://opensource.com/article/20/11/macports +[5]: https://opensource.com/article/20/6/homebrew-mac +[6]: https://opensource.com/article/20/3/chocolatey +[7]: https://www.freedesktop.org/wiki/Specifications +[8]: http://www.opengroup.org/onlinepubs/009695399/functions/getenv.html diff --git a/sources/tech/20210623 Program on FreeDOS with Bywater BASIC.md b/sources/tech/20210623 Program on FreeDOS with Bywater BASIC.md new file mode 100644 index 0000000000..4959c38af1 --- /dev/null +++ b/sources/tech/20210623 Program on FreeDOS with Bywater BASIC.md @@ -0,0 +1,83 @@ +[#]: subject: (Program on FreeDOS with Bywater BASIC) +[#]: via: (https://opensource.com/article/21/6/freedos-bywater-basic) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Program on FreeDOS with Bywater BASIC +====== +Install Bywater BASIC on your FreeDOS system and start experimenting +with BASIC programming. +![woman on laptop sitting at the window][1] + +In the early days of personal computing—from the late 1970s and through the 1980s—many people got their start with BASIC programming. BASIC was a universal programming language that came built into most personal computers, from Apple to IBM PCs. + +When we started the FreeDOS Project in June 1994, it seemed natural that we should include an open source BASIC environment. I was excited to discover one already existed in Bywater BASIC. + +The [Bywater BASIC website][2] reminds us that “Bywater BASIC implements a large superset of the ANSI Standard for Minimal BASIC (X3.60-1978) and a significant subset of the ANSI Standard for Full BASIC (X3.113-1987).” It's also distributed under the GNU General Public License version 2, which means it's open source software. We only want to include open source programs in FreeDOS, so Bywater BASIC was a great addition to FreeDOS in our early days. + +We've included Bywater BASIC since at least FreeDOS Alpha 5, in 1997. You can find Bywater BASIC in FreeDOS 1.3 RC4 in the "Development" package group on the Bonus CD. Load this: + +![Bywater BASIC][3] + +Installing Bywater BASIC on FreeDOS 1.3 RC4 +(Jim Hall, [CC-BY SA 4.0][4]) + +FreeDOS installs the Bywater BASIC package in the `\DEVEL\BWBASIC` directory. Change to this directory with `CD \DEVEL\BWBASIC` and type `BWBASIC` to run the Bywater BASIC interpreter. + +![Bywater BASIC][5] + +The Bywater BASIC intepreter +(Jim Hall, [CC-BY SA 4.0][4]) + +### Writing a sample program + +Let me demonstrate Bywater BASIC by writing a test program. We'll keep this simple—print five random numbers. This requires only a few constructs—a loop to iterate over five values and a random number generator. BASIC uses the `RND(1)` statement to generate a random value between 0 and 1. We can use `PRINT` to display the random number. + +One feature I like in Bywater BASIC is the integrated "help" system. There's nothing more frustrating than forgetting the syntax for a BASIC statement. For example, I always forget how to create BASIC loops. Do I use `FOR I IN 1 TO 10` or `FOR I = 1 TO 10`? Just type `help FOR` at the Bywater BASIC prompt and the interpreter displays the usage and a brief description. + +![Bywater BASIC][6] + +Use the "help" system as a quick-reference guide +(Jim Hall, [CC-BY SA 4.0][4]) + +Another neat feature in Bywater BASIC is how it reformats your BASIC instructions, so they are easier to read. After typing my brief program, I can type `list` to see the full source listing. Bywater BASIC automatically adds the `CALL` keyword to my `RANDOMIZE` statement on line 10 and indents the `PRINT` statement inside my loop. These small changes help me to see loops and other features in my program, which can aid in debugging. + +![Bywater BASIC][7] + +Bywater BASIC automatically reformats your code +(Jim Hall, [CC-BY SA 4.0][4]) + +If everything looks okay, then type `RUN` to execute the program. Because I used the `RANDOMIZE` statement at the start of my BASIC program, Bywater _seeds_ the random number generator with a random starting point. This ensures that my numbers are actually random values and don't repeat when I re-run my program. + +![Bywater BASIC][8] + +Generating lists of random numbers +(Jim Hall, [CC-BY SA 4.0][4]) + +Install Bywater BASIC on your FreeDOS system and start experimenting with BASIC programming. BASIC can be a great first programming language, especially if you are interested in getting back to the "roots" of personal computing. You can find more information about Bywater BASIC in the manual, installed in the `\DEVEL\BWBASIC` directory as `BWBASIC.DOC`. You can also explore the online "help" system by typing `HELP` at the Bywater BASIC prompt. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/freedos-bywater-basic + +作者:[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/lenovo-thinkpad-laptop-window-focus.png?itok=g0xPm2kD (young woman working on a laptop) +[2]: https://sourceforge.net/projects/bwbasic/ +[3]: https://opensource.com/sites/default/files/uploads/bwbasic1.png (Installing Bywater BASIC on FreeDOS 1.3 RC4) +[4]: https://creativecommons.org/licenses/by-sa/4.0/ +[5]: https://opensource.com/sites/default/files/uploads/bwbasic3.png (The Bywater BASIC intepreter) +[6]: https://opensource.com/sites/default/files/uploads/randnum1.png (Use the "help" system as a quick-reference guide) +[7]: https://opensource.com/sites/default/files/uploads/randnum2.png (Bywater BASIC automatically reformats your code) +[8]: https://opensource.com/sites/default/files/uploads/randnum3.png (Generating lists of random numbers) diff --git a/sources/tech/20210624 Linux package management with apt.md b/sources/tech/20210624 Linux package management with apt.md new file mode 100644 index 0000000000..3e826c7dc1 --- /dev/null +++ b/sources/tech/20210624 Linux package management with apt.md @@ -0,0 +1,192 @@ +[#]: subject: (Linux package management with apt) +[#]: via: (https://opensource.com/article/21/6/apt-linux) +[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Linux package management with apt +====== +Learn how to install packages on Debian-based Linux distros with the apt +command, then download our cheat sheet to keep the right command at your +fingertips. +![bash logo on green background][1] + +On Linux, [package managers][2] help you handle updates, uninstalls, troubleshooting, and more for the software on your computer. Seth Kenlon [wrote about `dnf`][3], the command-line package management tool for installing software in RHEL, CentOS, Fedora, Mageia, OpenMandriva, and other Linux distros. + +Debian and Debian-based distros such as MX Linux, Deepin, Ubuntu—and distros based on Ubuntu, such as Linux Mint and Pop!_OS—have `apt`, a "similar but different" tool. In this article, I'll follow Seth's examples—but with `apt`—to show you how to use it. + +Before I start, I want to mention four `apt`-related tools for installing software: + + * [Synaptic][4] is a GTK+ based graphical user interface (GUI) front end for `apt`. + * [Aptitude][5] is an Ncurses-based full-screen command-line front end for `apt`. + * There are `apt-get`, `apt-cache`, and other predecessors of `apt`. + * [Dpkg][6] is the "behind the scenes" package manager `apt` uses to do the heavy lifting. + + + +There are other packaging systems, such as [Flatpak][7] and [Snap][8], that you might run into on Debian and Debian-based systems, but I'm not going to discuss them here. There are also application "stores," such as [GNOME Software][9], that overlap with `apt` and other packaging technologies; again, I'm not going to discuss them here. Finally, there are other Linux distros such as [Arch][10] and [Gentoo][11] that use neither `dnf` nor `apt`, and I'm not going to discuss those here either! + +With all the things I'm not going to discuss here, you may be wondering what tiny subset of software `apt` handles. Well, on my Ubuntu 20.04, `apt` gives me access to 69,371 packages, from the `0ad` real-time strategy game of ancient warfare to the `zzuf` transparent application fuzzer. Not bad at all. + +### Finding software with apt + +The first step in using a package manager such as `apt` is finding a software package of interest. Seth's `dnf` article used the [Cockpit][12] server management application as an example, so I will, too: + + +``` +$ apt search cockpit +Sorting... Done +Full Text Search... Done +389-ds/hirsute,hirsute 1.4.4.11-1 all +  389 Directory Server suite - metapackage + +cockpit/hirsute,hirsute 238-1 all +  Web Console for Linux servers + +... +$ +``` + +The second package above is the one you're after (it's the line beginning with `cockpit/hirsute`). If you decide you want to install it, enter: + + +``` +`$ sudo apt install cockpit` +``` + +`apt` will take care of installing Cockpit and all the bits and pieces, or _dependencies_, needed to make it work. Sometimes that's all that's needed; sometimes it's not. It's possible that having a bit more information could be useful in deciding whether you really want to install this application. + +### Package metadata + +To find out more about a package, use the `apt show` command: + + +``` +$ apt show cockpit +Package: cockpit +Version: 238-1 +Priority: optional +Section: universe/admin +Origin: Ubuntu +Maintainer: Ubuntu Developers <[ubuntu-devel-discuss@lists.ubuntu.com][13]> +Original-Maintainer: Utopia Maintenance Team <[pkg-utopia-maintainers@lists.alioth.debian.org][14]> +Bugs: +Installed-Size: 88.1 kB +Depends: cockpit-bridge (>= 238-1), cockpit-ws (>= 238-1), cockpit-system (>= 238-1) +Recommends: cockpit-storaged (>= 238-1), cockpit-networkmanager (>= 238-1), cockpit-packagekit (>= 238-1) +Suggests: cockpit-doc (>= 238-1), cockpit-pcp (>= 238-1), cockpit-machines (>= 238-1), xdg-utils +Homepage: +Download-Size: 21.3 kB +APT-Sources: hirsute/universe amd64 Packages +Description: Web Console for Linux servers + The Cockpit Web Console enables users to administer GNU/Linux servers using a + web browser. + . + It offers network configuration, log inspection, diagnostic reports, SELinux + troubleshooting, interactive command-line sessions, and more. + +$ +``` + +In particular, notice the `Description` field, which tells you more about the application. The `Depends` field says what else must be installed, and `Recommends` shows what other—if any—cooperating components are suggested alongside it. The `Homepage` field offers a URL in case you need more info. + +### What package provides a file? + +Sometimes you don't know the package name, but you know a file that must be in a package. Seth offers as an example the `qmake-qt5` utility. Using `apt search` doesn't find it: + + +``` +$ apt search qmake-qt5 +Sorting... Done +Full Text Search... Done +$ +``` + +However, a related command, `apt-file` will explore inside packages: + + +``` +$ apt-file search qmake-qt5 +qt5-qmake-bin: /usr/share/man/man1/qmake-qt5.1.gz +$ +``` + +This turns up a man page for `qmake-qt5` that is part of a package called `qt5-qmake-bin`. Note that this package name reverses the `qmake` and `qt5` parts. + +### What files are included in a package? + +That handy `apt-file` command also tells which files are included in a given package. For example: + + +``` +$ apt-file list cockpit +cockpit: /usr/share/doc/cockpit/TODO.Debian +cockpit: /usr/share/doc/cockpit/changelog.Debian.gz +cockpit: /usr/share/doc/cockpit/copyright +cockpit: /usr/share/man/man1/cockpit.1.gz +cockpit: /usr/share/metainfo/cockpit.appdata.xml +cockpit: /usr/share/pixmaps/cockpit.png +$ +``` + +Note that this is distinct from the info provided by the `apt show` command, which lists the package's dependencies (other packages that must be installed). + +### Removing an application + +You can also remove packages with `apt`. For example, to remove the `apt-file` application: + + +``` +`$ sudo apt purge apt-file` +``` + +Note that a superuser must run `apt` to install or remove applications. + +Removing a package doesn't automatically remove all the dependencies that `apt` installs along the way. However, it's easy to carry out that little bit of tidying: + + +``` +`$ sudo apt autoremove` +``` + +### Getting to know apt + +As Seth wrote, "the more you know about how your package manager works, the easier it is for you to install and query applications when necessary." + +Even if you're not a regular `apt` user, knowing it can be useful when you need to work at the command line while installing or removing packages (for example, on a remote server or when following a how-to published by some helpful soul). You may also need to know a bit about Dkpg (mentioned above); for example, some software creators provide a bare `.pkg` file. + +I find the Synaptic package manager to be a really useful tool on my desktop, but I also use `apt` on a handful of servers that I maintain for various purposes. + +**[Download our `apt` cheat sheet][15]** to get used to the command and try some new tricks with it. Once you do, you might find it hard to use anything else. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/apt-linux + +作者:[Chris Hermansen][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/clhermansen +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bash_command_line.png?itok=k4z94W2U (bash logo on green background) +[2]: https://opensource.com/article/21/2/linux-package-management +[3]: https://opensource.com/article/21/5/dnf +[4]: https://www.nongnu.org/synaptic/ +[5]: https://wiki.debian.org/Aptitude +[6]: https://wiki.debian.org/Teams/Dpkg +[7]: https://flatpak.org/ +[8]: https://snapcraft.io/ +[9]: https://wiki.gnome.org/Apps/Software +[10]: https://archlinux.org/ +[11]: https://www.gentoo.org/ +[12]: https://opensource.com/article/20/11/cockpit-server-management +[13]: mailto:ubuntu-devel-discuss@lists.ubuntu.com +[14]: mailto:pkg-utopia-maintainers@lists.alioth.debian.org +[15]: https://opensource.com/downloads/apt-cheat-sheet diff --git a/sources/tech/20210625 9 Features in Brave Search That Make it a Great Google Search Alternative.md b/sources/tech/20210625 9 Features in Brave Search That Make it a Great Google Search Alternative.md new file mode 100644 index 0000000000..e1814e4871 --- /dev/null +++ b/sources/tech/20210625 9 Features in Brave Search That Make it a Great Google Search Alternative.md @@ -0,0 +1,161 @@ +[#]: subject: (9 Features in Brave Search That Make it a Great Google Search Alternative) +[#]: via: (https://itsfoss.com/brave-search-features/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +9 Features in Brave Search That Make it a Great Google Search Alternative +====== + +Brave Search is an ambitious initiative by Brave Software based on the open-source project [Tailcat][1], which tries to take on the big tech by introducing the ability to search anonymously. Brave Search itself is [not open source at the moment][2]. + +Of course, there are various other [private search engines][3] available out there trying to offer a privacy-focused experience. Even though not every service proves to be better than Google (regarding features), Brave Search seems to be a compelling choice when considering Brave Browser as a successful open-source replacement to Google Chrome. + +Here, let me highlight a few features in Brave Search that makes it an interesting alternative to Google Search. + +### Top 9 Brave Search Features + +Brave Search does a few things better than Google and those are worth highlighting as unique feature offerings that sets it apart. + +Brave Search is in beta at the time of writing this article. If you notice something different with your experience, there are chances that they may have made an improvement/change. Let me know in the comments below if that’s the case. + +#### 1\. Anonymous Search + +![][4] + +Google tracks your search queries, keeps a log of your history (unless you manually delete it or disable recording your activity). Not just the basics, but your IP address and the website you visit from the search result is also recorded in the process. + +In contrast, Brave Search does not track the IP, or the search queries made using their search portal. + +You stay completely anonymous, along with your search history being private only to yourself. + +This could eliminate the need of using a [secure VPN service][5] to keep your Internet search activity private. + +#### 2\. Ad-Free Version (Coming Soon) + +![][6] + +All the private search engines include advertisements to make money (which is fair). The advertisements used by Google Search include trackers when you click on it, which is not the case with privacy-focused search engines. + +But Brave Search tries to go a little further by offering a choice to the users. + +It is a feature that has been planned for addition, but it is worth mentioning. If you want to get rid of the ads, you can opt for the paid version of the search engine where you can explore the web ad-free. + +I think that’s a win-win for both Brave and you as a user. They do not lose on making revenue and you get to experience a truly ad-free search engine. + +#### 3\. Community Curated Search Rankings (Coming Soon) + +Users can help spot the quality of a web resource better than an algorithm often. + +So, Brave Search aims to work on a community-curated search ranking system, which will be open to all when it is available. + +This should improve the collaborative approach of exploring the web, which should be an impressive feature of Brave Search. + +#### 4\. Independent Index with No Search Algorithm + +![][7] + +With most of the other search engines, there’s an algorithm in place to make sure that only the high-quality web pages rank above the rest. Brave Search does not have any special algorithm controlling the search rankings. + +And yes, that is a feature in a world where everything depends on algorithms. + +Sometimes that algorithm ends up being biased by ranking plagiarism content first, low-quality web pages, along with a few other issues. + +Without any special search algorithm, Brave search uses its own Index to fetch results as per your queries. + +#### 5\. Private Local and Global Search Results + +![][8] + +No matter what region you choose for the search results, you get an additional option to filter your results based on your locality (IP address). + +Brave explains that the IP address is stored locally on your device and is used to serve you the local feed of results – which sounds useful. + +![][9] + +#### 6\. Transparency in Search Results + +![][10] + +The web is a vast network. Therefore, to keep the search result quality resourceful, Brave Search fetches some search results anonymously from Google and Bing (which is often less than 10% in my tests). + +For the rest of the results, Brave Search relies on its independent index. Brave Search also displays the percent of its independent search index used for your search. + +The more users start using Brave Search, the more independent the search results will become. So that’s a good thing. + +Considering not all search engines reveal a lot about their search results, Transparency, as a principle, can be a feature to compare with when choosing a search engine. + +![][11] + +#### [Brave: Open Source Web Browser That Blocks Ads and Tracking By Default][12] + +An open source web browser that blocks ads and tracking. A good choice if you are looking for a privacy focused web browser. Here’s how to install Brave on Linux. + +#### 7\. A Refreshing User Interface + +While every other Google search alternative tries to offer a familiar experience, Brave Search is actually refreshing to look at (in my opinion). + +![][13] + +The user interface looks well-thought and offers a modern, clean experience. Don’t you think? + +I like how DuckDuckGo simplifies things, but Brave certainly makes it up for a better user experience that looks unique and clean. + +#### 8\. No Anti-Competitive Nature + +Unlike some other search engines (especially, Google) do not suggest anything else explicitly, except their own products and services in their search results. + +That’s fair but potentially also anti-competitive, being the most popular search engine. They do have their reasons which we don’t have to talk about here, but giving a shout-out to your competitors is something new businesses/services are adopting. + +![][14] + +And Brave Search does an excellent jobat that. While you scroll through the search results, you will find a choice to use other search engines for your search query. + +#### 9\. Dark Mode & Tweaks + +Yes, the dark mode is an important feature (sigh). + +![][15] + +And from the settings available in Brave Search, you can **turn on the dark mode**, **set links to open in a new tab,** and **control the language** (soon). + +![][16] + +### Wrapping Up + +Brave Search is an interesting private search engine that aims to tackle the Big Tech by offering something new. It should be seamless user experience when [using Brave Browser][12] along with it, but you can use it on any browser without any limitations. + +I like what I see here, what do you think? Let me know your thoughts in the comments below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/brave-search-features/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://www.tailcat.com +[2]: https://www.reddit.com/r/brave_browser/comments/o5qknc/announcement_brave_search_beta_now_available_in/h2p3q22?utm_source=share&utm_medium=web2x&context=3 +[3]: https://itsfoss.com/privacy-search-engines/ +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-search-anonymous.png?resize=800%2C530&ssl=1 +[5]: https://itsfoss.com/best-vpn-linux/ +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/paid-no-ads-brave.png?resize=800%2C450&ssl=1 +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-search-sample.png?resize=800%2C586&ssl=1 +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-local-global-search.png?resize=800%2C228&ssl=1 +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-anonymous-local-results.png?resize=800%2C589&ssl=1 +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-search-transparency.png?resize=800%2C654&ssl=1 +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/09/brave-browser-1-e1573731875389.jpeg?resize=150%2C150&ssl=1 +[12]: https://itsfoss.com/brave-web-browser/ +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-search-ui.png?resize=800%2C590&ssl=1 +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-search-competitors.png?resize=800%2C502&ssl=1 +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-search-dark-mode.png?resize=800%2C573&ssl=1 +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-search-settings.png?resize=483%2C389&ssl=1 diff --git a/sources/tech/20210625 How to program in C on FreeDOS.md b/sources/tech/20210625 How to program in C on FreeDOS.md new file mode 100644 index 0000000000..0a3f6ddeb1 --- /dev/null +++ b/sources/tech/20210625 How to program in C on FreeDOS.md @@ -0,0 +1,137 @@ +[#]: subject: (How to program in C on FreeDOS) +[#]: via: (https://opensource.com/article/21/6/program-c-freedos) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +How to program in C on FreeDOS +====== +Programming in C on FreeDOS is very similar to C programming on Linux. +![Woman sitting in front of her computer][1] + +When I first started using DOS, I enjoyed writing games and other interesting programs using BASIC, which DOS included. Much later, I learned the C programming language. + +I immediately loved working in C! It was a straightforward programming language that gave me a ton of flexibility for writing useful programs. In fact, much of the FreeDOS core utilities are written in C and Assembly. + +So it's probably not surprising that FreeDOS 1.3 RC4 includes a C compiler—along with other programming languages. The FreeDOS 1.3 RC4 LiveCD includes two C compilers—Bruce's C compiler (a simple C compiler) and the OpenWatcom C compiler. On the Bonus CD, you can also find DJGPP (a 32-bit C compiler based on GNU GCC) and the IA-16 port of GCC (requires a '386 or better CPU to compile, but the generated programs can run on low-end systems). + +Programming in C on FreeDOS is basically the same as C programming on Linux, with two exceptions: + + 1. **You need to remain aware of how much memory you use.** Linux allows programs to use lots of memory, but FreeDOS is more limited. Thus, DOS programs used one of four [memory models][2] (large, medium, compact, and small) depending on how much memory they needed. + 2. **You can directly access the console.** On Linux, you can create _text-mode_ mode programs that draw to the terminal screen using a library like _ncurses_. But DOS allows programs to access the console and video hardware. This provides a great deal of flexibility in writing more interesting programs. + + + +I like to write my C programs in the IA-16 port of GCC, or OpenWatcom, depending on what program I am working on. The OpenWatcom C compiler is easier to install since it's only a single package. That's why we provide OpenWatcom on the FreeDOS LiveCD, so you can install it automatically if you choose to do a "Full installation including applications and games" when you install FreeDOS 1.3 RC4. If you opted to install a "Plain DOS system," then you'll need to install the OpenWatcom C compiler afterward, using the FDIMPLES package manager. + +![installing OpenWatcom][3] + +Installing OpenWatcom on FreeDOS 1.3 RC4 +(Jim Hall, [CC-BY SA 4.0][4]) + +### DOS C programming + +You can find documentation and library guides on the [OpenWatcom project website][5] to learn all about the unique DOS C programming libraries provided by the OpenWatcom C compiler. To briefly describe a few of the most useful functions: + +From `conio.h`: + + * `int getch(void)—`Get a single keystroke from the keyboard + * `int getche(void)—`Get a single keystroke from the keyboard, and echo it + + + +From `graph.h`: + + * `_settextcolor(short color)—`Sets the color when printing text + * `_setbkcolor(short color)—`Sets the background color when printing text + * `_settextposition(short y, short x)—`Move the cursor to row `y` and column `x` + * `_outtext(char _FAR *string)—`Print a string directly to the screen, starting at the current cursor location + + + +DOS only supports [sixteen text colors][6] and eight background colors. You can use the values 0 (Black) to 15 (Bright White) to specify the text colors, and 0 (Black) to 7 (White) for the background colors: + + * **0**—Black + * **1**—Blue + * **2**—Green + * **3**—Cyan + * **4**—Red + * **5**—Magenta + * **6**—Brown + * **7**—White + * **8**—Bright Black + * **9**—Bright Blue + * **10**—Bright Green + * **11**—Bright Cyan + * **12**—Bright Red + * **13**—Bright Magenta + * **14**—Yellow + * **15**—Bright White + + + +### A fancy "Hello world" program + +The first program many new developers learn to write is a program that just prints "Hello world" to the user. We can use the DOS "conio" and "graphics" libraries to make this a more interesting program and print "Hello world" in a rainbow of colors. + +In this case, we'll iterate through each of the text colors, from 0 (Black) to 15 (Bright White). As we print each line, we'll indent the next line by one space. When we're done, we'll wait for the user to press any key, then we'll reset the screen and exit. + +You can use any text editor to write your C source code. I like using a few different editors, including [FreeDOS Edit][7]** **and [Freemacs][8], but more recently I've been using the [FED editor][9] because it provides _syntax highlighting_, making it easier to see keywords, strings, and variables in my program source code. + +![writing a simple C program][10] + +Writing a simple test program in C +(Jim Hall, [CC-BY SA 4.0][4]) + +Before you can compile using OpenWatcom, you'll need to set up the DOS [environment variables][11]** **so OpenWatcom can find its support files. The OpenWatcom C compiler package includes a setup [batch file][12] that does this for you, as `\DEVEL\OW\OWSETENV.BAT`. Run this batch file to automatically set up your environment for OpenWatcom. + +Once your environment is ready, you can use the OpenWatcom compiler to compile this "Hello world" program. I've saved my C source file as `TEST.C`, so I can type `WCL TEST.C` to compile and link the program into a DOS executable, called `TEST.EXE`. In the output messages from OpenWatcom, you can see that `WCL` actually calls the OpenWatcom C Compiler (`WCC`) to compile, and the OpenWatcom Linker (`WLINK`) to perform the object linking stage: + +![compiling with OpenWatcom][13] + +Compiling the test program with OpenWatcom +(Jim Hall, [CC-BY SA 4.0][4]) + +OpenWatcom prints some extraneous output that may make it difficult to spot errors or warnings. To tell the compiler to suppress most of these extra messages, use the `/Q` ("Quiet") option when compiling: + +![compiling with OpenWatcom][14] + +If you don't see any error messages when compiling the C source file, you can now run your DOS program. This "Hello world" example is `TEST.EXE`. Enter `TEST` on the DOS command line to run the new program, and you should see this very pretty output: + +![running the test program][15] + +C is a very efficient programming language that works well for writing programs on limited-resource systems like DOS. There's lots more that you can do by programming in C on DOS. If you're new to the C language, you can learn C yourself by following along in our [Writing FreeDOS Programs in C][16] self-paced ebook on the FreeDOS website, and the accompanying "how-to" video series on the [FreeDOS YouTube channel][17]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/program-c-freedos + +作者:[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/OSDC_women_computing_2.png?itok=JPlR5aCA (Woman sitting in front of her computer) +[2]: https://devblogs.microsoft.com/oldnewthing/20200728-00/?p=104012 +[3]: https://opensource.com/sites/default/files/uploads/install-ow.png (Installing OpenWatcom on FreeDOS 1.3 RC4) +[4]: https://creativecommons.org/licenses/by-sa/4.0/ +[5]: http://openwatcom.org/ +[6]: https://opensource.com/article/21/6/freedos-sixteen-colors +[7]: https://opensource.com/article/21/6/freedos-text-editor +[8]: https://opensource.com/article/21/6/freemacs +[9]: https://opensource.com/article/21/1/fed-editor +[10]: https://opensource.com/sites/default/files/uploads/fed-test.png (Writing a simple test program in C) +[11]: https://opensource.com/article/21/6/freedos-environment-variables +[12]: https://opensource.com/article/21/6/automate-tasks-bat-files-freedos +[13]: https://opensource.com/sites/default/files/uploads/wcl-test.png (Compiling the test program with OpenWatcom) +[14]: https://opensource.com/sites/default/files/uploads/wcl-q-test.png (Use the /Q ("Quiet") option to make OpenWatcom print less output) +[15]: https://opensource.com/sites/default/files/uploads/test.png (You can create beautiful programs in C) +[16]: https://www.freedos.org/books/cprogramming/ +[17]: https://www.youtube.com/freedosproject diff --git a/sources/tech/20210625 Mount cue-bin image files with CDemu.md b/sources/tech/20210625 Mount cue-bin image files with CDemu.md new file mode 100644 index 0000000000..21ed6d68d7 --- /dev/null +++ b/sources/tech/20210625 Mount cue-bin image files with CDemu.md @@ -0,0 +1,87 @@ +[#]: subject: (Mount cue/bin image files with CDemu) +[#]: via: (https://fedoramagazine.org/mount-cue-bin-image-files-with-cdemu/) +[#]: author: (Luca Rastelli https://fedoramagazine.org/author/luca247/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Mount cue/bin image files with CDemu +====== + +![][1] + +Photo by [Cameron Bunney][2] on [Unsplash][3] + +The other day I needed to burn a disc. Yeah, I know, some of you might be wondering, “A disc? What’s that?” Others might ask, “Are you really using that archaic media?” + +Well, yes I am. I feel there is still something charming about physical things that digital media cannot replace. + +I needed to burn a very old game that was comprised of a [cue file][4], some audio tracks in [cda format][5], and a [bin file][6] which stored all the binary content that was indexed by the cue file. + +First I tried to use [Brasero][7]. Yeah I know, it’s old but it does the job generally and it fits with the rest of the system, so it’s my choice generally. Unfortunately, this time it was not up to the task. It stated that it had some problems reading the cue file. Then I tried [Xfburn][8] and [K3b][9]. But neither of those worked either. They both detected the bin file but not the cda files. + +Next, I searched on the web and I found lots of posts explaining how to burn image files using command line applications. Or how to create [iso images][10] and then write those out to discs. These methods seemed excessively complex for what I wanted to do. Why all that difficulty for a task that should be easy as clicking on a button? Fedora Linux should be about freedom, not about difficulties! Although it can be used by experts, an easy way of doing things is always appreciated. + +I had almost surrendered. Then, in a forum post buried under all the suggestions mentioned previously, I found the answer I was looking for – [CDemu][11]. + +Those familiar with [Daemon Tools][12] may find CDemu to be similar. I find CDemu to be even easier and far less bloated. With CDemu, you can mount cue images with the classic double-click. Sounds easy? Well that’s because it actually is. + +CDemu is not present in Fedora Linux’s default repositories. So if you want to try it out, you will have to use the [rok/cdemu][13] Copr repository that is compatible with your version of Fedora Linux. + +**Note**: _Copr is not officially supported by Fedora infrastructure. Use packages at your own risk._ + +Open a terminal and enable the Copr repo by entering the following command. + +``` +$ sudo dnf copr enable rok/cdemu +``` + +Then install the daemon and the clients by entering the following commands. + +``` +$ sudo dnf install cdemu-daemon +$ sudo dnf install cdemu-client +$ sudo dnf install gcdemu +``` + +Next, enter the following commands to ensure the right kernel module is available and loaded. + +``` +$ sudo akmods +$ sudo systemctl restart systemd-modules-load.service +``` + +Now CDemu is installed. To associate it with your CD images, you just need to right-click on a file type that you want to mount with CDemu, select _properties_, and the select _Open with CDemu_. Now, double-clicking on those image types should mount them in Nautilus like a physical drive. + +If you need to burn the image (like I did), open Brasero and select _copy disc_. + +CDemu can also be run from the command line. But this guide was all about getting easy, right? + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/mount-cue-bin-image-files-with-cdemu/ + +作者:[Luca Rastelli][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/luca247/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2021/06/cdemu-816x345.jpg +[2]: https://unsplash.com/@bdbillustrations?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]: https://unsplash.com/s/photos/dvd?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: https://en.wikipedia.org/wiki/Cue_sheet_(computing) +[5]: https://en.wikipedia.org/wiki/.cda_file +[6]: https://en.wikipedia.org/wiki/Binary_file +[7]: https://en.wikipedia.org/wiki/Brasero_(software) +[8]: https://en.wikipedia.org/wiki/Xfce#Xfburn +[9]: https://en.wikipedia.org/wiki/K3b +[10]: https://en.wikipedia.org/wiki/Optical_disc_image +[11]: https://en.wikipedia.org/wiki/CDemu +[12]: https://en.wikipedia.org/wiki/Daemon_Tools +[13]: https://copr.fedorainfracloud.org/coprs/rok/cdemu/ diff --git a/sources/tech/20210626 How I helped my mom switch from Windows to Linux.md b/sources/tech/20210626 How I helped my mom switch from Windows to Linux.md new file mode 100644 index 0000000000..7e0a4ae5fa --- /dev/null +++ b/sources/tech/20210626 How I helped my mom switch from Windows to Linux.md @@ -0,0 +1,161 @@ +[#]: subject: (How I helped my mom switch from Windows to Linux) +[#]: via: (https://opensource.com/article/21/6/mom-switch-linux) +[#]: author: (Tomasz https://opensource.com/users/tomaszwaraksa) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +How I helped my mom switch from Windows to Linux +====== +With Linux, novice users will gain a smooth, polished desktop experience +with a multitude of familiar applications. +![Red Lego Heart][1] + +The Large Hadron Collider is [powered by Linux][2]. Laptops on the International Space Station [run on Linux][3]. So do [Instagram][4] and [Nest thermostats][5]. Recently, we watched Ingenuity fly over Mars, an amazing robo-copter driven by… [Linux][6]! It's yet more proof of how flexible and versatile this operating system can be. + +But now, the really big news. It's official. Linux can handle Mom and Dad just as well! + +### The story + +About a year ago, I decided to migrate my mom to Linux. A year has passed, so it's time for retrospection and conclusions. + +Like most of us, I'm officially _Mom's Computer Admin_. Mom is a lovely lady in her late 60s—a real sweetheart. Mom's computer skills are basic. Mom's computer needs are basic, too. Read the internets, send email, type text, browse and edit photos, play videos and music, call family and friends on Skype or Signal. + +Until last year, she was using a Windows laptop, old but not too bad. Then one day, through deceit, threats, and obnoxious popups, Microsoft finally made her click that dreaded "UPGRADE TO WINDOWS 10" button. + +My life as Mom's Computer Admin quickly turned into hell with her desperate calls for help. Why does everything look so different? Where is my app menu? What, this pile of tiles is now my app menu? Why is the computer so slow? Why does it restart daily for updates, just when I need to use it?! Why is something (she meant the hard drive) making noise all the time? What is it actually doing all the time? + +And how would I know that without any ability to look into the source code? + +I considered rolling back the upgrade. But with Windows 7 reaching end-of-life soon, I feared the worst: Without security updates, Mom's computer would soon become a member of countless bot networks, mining cryptocurrencies, mailing spam, and launching vicious DDOS attacks on the vital infrastructure of entire countries. And I'd be the one to clean this mess—every weekend. + +### Linux to the rescue + +With nothing to lose, I decided to migrate her to Linux. I made "the move" five years ago and have never been happier. It surely wouldn't do harm to try it with her. + +Mom was happy when I declared to fix her problems once and for all. What she didn't know is that she would become the crucial part of a year-long scientific experiment named: "Can Mom survive Linux?" + +![Cowsay "Can Mom Survive Linux?"][7] + +(Tomasz Waraksa, [CC BY-SA 4.0][8]) + +And so, one day in February 2020, I arrived from faraway Dublin with a seven-year-old Lenovo Yoga 13, which had similar specs but a much nicer screen and half the weight. After some deliberations and testing various Linux distributions on VirtualBox, I decided on the [Zorin OS][9] distribution, proudly made in Ireland. My choice was driven by the following factors: + + * It's based on Ubuntu Linux, with which I'm most familiar. + * It closely resembles Windows 7, being carefully designed with Windows refugees in mind. + * It feels lightweight, simple, and sufficiently conservative for Mom. No shiny macOS Big Sur glitz anywhere around! + + + +![Zorin OS desktop][10] + +(Tomasz Waraksa, [CC BY-SA 4.0][8]) + +### System installation + +I installed the operating system my usual way, with the `/home` folder on a dedicated partition to keep Mom's Stuff safe in the unlikely case of system reinstallation. It's my old trick that makes late-night distro-hopping much easier. + +During installation, I chose Polish as the user interface (UI) language. Just like me, Mom is Polish to the bone. No worries, Linux seems to support every possible language, including [Klingon][11]. + +Then, I installed the following applications to cover Mom's needs: + + * Skype + * [Signal for Desktop][12] + * Google Chrome browser + * [Geary][13] email client + * [gThumb][14] for photo viewing and editing + * [VLC][15] for playing video and music + * Softmaker Office for text editing and spreadsheets + + + +Notice how there's no antivirus on the list. Yay! + +An hour later, her Zorin OS box was ready and loaded with applications. + +![Zorin OS home folder][16] + +(Tomasz Waraksa, [CC BY-SA 4.0][8]) + +### System configuration + +I made myself Mom's Computer Admin by doing the following: + + * Created an admin account for myself + * Turned Mom's account into non-admin + * Installed the `ssh` daemon for remote unattended access + * Added the machine to my Hamachi VPN: This way, I can securely connect via `ssh` without opening port 22 on the router. Hamachi is a VPN service by LogMeIn. An old-school VPN, I mean. Intended not for running Netflix from another country but for connecting computers into a secure network over the internet. + * Enabled Uncomplicated Firewall ( `ufw`) and allowed ssh traffic + * Installed AnyDesk for logging in to the desktop + + + +With this, I have secure ssh access to Mom's laptop. I can perform periodic maintenance via shell without Mom even noticing anything. That's because Linux normally _does not_ require a reboot after completed updates; what a miracle, how's that even possible? + +![Updating software remotely][17] + +(Tomasz Waraksa, [CC BY-SA 4.0][8]) + +### Can Mom survive Linux? + +Without the slightest doubt! + +When I showed Mom her new PC, she did ask why this new Windows looked different _again_. I had to reveal that this is not Windows at all, but Linux, and explain why we all love Linux. But she picked it up quickly. The classic Zorin OS desktop is very much like her old Windows 7. I watched her find her way through the system and launch her familiar applications with ease. + +She immediately noticed how much faster the computer starts and how much better it performs. + +She's been asking me when I will do the usual computer cleanup so that it doesn't become slow again. I've explained that, with her average use, it won't be needed. Linux simply doesn't rot on its own as Windows does. So far, this has been true. Her PC runs as smooth and fast as on day one. + +Every now and then, I ask how she feels about her new computer. She invariably answers that she's happy with it. Everything works smoothly. The computer doesn't get busy for no reason. No more interrupting her with Very Important Updates. And the menu is where it should always be. She's comfortable with her usual applications in this entirely new environment. + +Over the year, I've logged in remotely a few times to run routine package upgrades. I've logged in with AnyDesk twice. Once, when Mom asked whether photos from an inserted SD card could be imported automatically into the `~/Pictures` folder, and preferably into folders named by dates. Yes, `gThumb` can easily be made to do that with a bit of Bash. Another time, I logged in to add frequently used websites as desktop icons. + +And this has been all of my effort as Mom's Linux Admin so far! At this pace, I could be Mom's Computer Admin to 50 other moms! + +### Summary + +I hope that my story will inspire you to think about migrating to Linux. In the past, we considered Linux to be too difficult for casual users. But today I believe that the opposite is true. The less proficient computer users are, the more reasons they have to migrate to Linux! + +With Linux, novice users will gain a smooth, polished desktop experience with a multitude of familiar applications. They will be much safer than on any other popular computing platform. And helping them with remote access has never been easier and more secure! + +_Disclaimer: This article is not promoting any of the described products, services, or vendors. I don't have any commercial interest nor associations with them. I'm not trying to suggest that these products or services are best for you, nor promising that your experience will be the same._ + +* * * + +_This article originally appeared on [Let's Debug It][18] and is reused with permission._ + +Sandstorm's Jade Wang shares some of her favorite open source web apps that are self-hosted... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/mom-switch-linux + +作者:[Tomasz][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/tomaszwaraksa +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/heart_lego_ccby20.jpg?itok=VRpHf4iU (Red Lego Heart) +[2]: https://www.redhat.com/en/about/press-releases/red-hat-provides-cern-platform-mission-critical-applications +[3]: https://www.extremetech.com/extreme/155392-international-space-station-switches-from-windows-to-linux-for-improved-reliability +[4]: https://instagram-engineering.com/what-powers-instagram-hundreds-of-instances-dozens-of-technologies-adf2e22da2ad +[5]: https://www.theverge.com/2011/11/14/2559567/tony-fadell-nest-learning-thermostat +[6]: https://www.zdnet.com/article/to-infinity-and-beyond-linux-and-open-source-goes-to-mars/ +[7]: https://opensource.com/sites/default/files/uploads/intro.png (Cowsay "Can Mom Survive Linux?") +[8]: https://creativecommons.org/licenses/by-sa/4.0/ +[9]: https://zorinos.com/ +[10]: https://opensource.com/sites/default/files/uploads/zorin-os-desktop.png (Zorin OS desktop) +[11]: https://blogs.gnome.org/muelli/2010/04/klingon-language-support/ +[12]: https://github.com/signalapp +[13]: https://wiki.gnome.org/Apps/Geary +[14]: https://wiki.gnome.org/Apps/Gthumb +[15]: https://www.videolan.org/vlc/ +[16]: https://opensource.com/sites/default/files/uploads/zorin-os-home-folder.png (Zorin OS home folder) +[17]: https://opensource.com/sites/default/files/uploads/upgrading-software.png (Updating software remotely) +[18]: https://letsdebug.it/post/16-linux-for-mars-copters-moms-and-pops/ diff --git a/sources/tech/20210626 Windows 11 System Requirement is Turning Heads. Time to migrate to Linux.md b/sources/tech/20210626 Windows 11 System Requirement is Turning Heads. Time to migrate to Linux.md new file mode 100644 index 0000000000..dab9dde3ec --- /dev/null +++ b/sources/tech/20210626 Windows 11 System Requirement is Turning Heads. Time to migrate to Linux.md @@ -0,0 +1,101 @@ +[#]: subject: (Windows 11 System Requirement is Turning Heads. Time to migrate to Linux?) +[#]: via: (https://www.debugpoint.com/2021/06/windows-11-system-requirement/) +[#]: author: (Arindam https://www.debugpoint.com/author/admin1/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Windows 11 System Requirement is Turning Heads. Time to migrate to Linux? +====== +Microsoft announced Windows 11 at the official online event. Here’s in +this post we brief the Windows 11 system requirement and give you +thinking points on whether you should permanently migrate to Linux. +There are many debates and discussions going around after the announcement of Windows 11 from Microsoft. Many are “blown away” by the look and feel of the customization option that it brings, little they know that it might be “[inspired][1]” by other operating systems. + +![Windows 11 Desktop][2] + +Here’s a quick recap of visible features – + + * New Start Menu, Taskbar, and Search Bar + * New Animations are added while moving and dragging the windows. Even Opening a new window, closing, and minimize tap have different animation than earlier versions of Windows. + * Featured add to perform multitask with windows like split-screen, creating groups of various task windows, etc. + * Touch controls are improved significantly. + * New sounds are added in this version. After the release of Windows 10 in 2015, no significant changes were made in the sounds. But in Windows 11, you will see various new sound options. + * You will have access to dark mode also. + * Rounded Corners: Pointy corners will not be available in Windows 11. Corners of various bars will be made round. + * New icons are added which will make it more attractive than the earlier versions. + * Various new Widgets are added in this version. + * You can run Android apps via Windows 11 store + + + +### Windows 11 System Requirement + + * Processor – 1 gigahertz (GHz) or faster with 2 or more cores on a compatible 64-bit processor or System on a Chip (SoC) + * Memory – 4 GB RAM + * Storage – 64 GB or larger storage device + * System firmware – UEFI, Secure Boot capable + * TPM Trusted Platform Module (TPM) version 2.0 + * Graphics card DirectX 12 compatible graphics / WDDM 2.x +Display >9” with HD Resolution (720p) + * Internet connection Microsoft account and internet connectivity required for setup for Windows 11 Home + + + +Looking at the specification, you might have noticed a couple of interesting items. Windows 11 recommends your system should have TPM a.k.a Trusted Platform Module (TPM) version 2.0. Trusted Platform Module (TPM) technology is designed to provide hardware-based, security-related functions. A TPM chip is a secure crypto-processor that is designed to carry out cryptographic operations. The chip includes multiple physical security mechanisms to make it tamper-resistant, and malicious software is unable to tamper with the security functions of the TPM. + +And this is why Microsoft boasts about Windows 11 being more secure. + +Not all the hardware that is available today has a TPM chip. And worse is, many may force to buy new hardware as well. As a thumb rule, if you have bought any Laptop, Desktop 2017 onwards, you should be fine. + +[][1] + +SEE ALSO:   Windows 11 Look Inspired by KDE Plasma and GNOME? + +### Internet Required for set up? + +From an end-user perspective, this is not a good idea at all. This forces everyone to create a Microsoft account for the initial setup. Think about millions of users who probably buy Laptops for basic usage, and now they required to create an account, with OneDrive and other online “BS”. And you end up consuming more data, give away your data, and so on. + +This move is completely unnecessary from the Microsoft side. Internet connectivity should be optional and not mandatory for setting up your computer which you bought with a price. + +### Should you be moving to Linux? + +Yes, of course. Linux can run super-fast in all newer and older hardware. There are plenty of versions of the Linux operating system with a nice-looking desktop out there that you can easily install and use. You do not need to shell out additional money just to experience fancy Windows 11. + +Linux has many variants which cater to different people with a variety of tastes. You do not need to settle for only one look and feel and functionality. You have the freedom to choose. + +You do not need to buy expensive Antivirus which is recommended for Windows operating system. Linux doesn’t get a virus that easily as it is designed in a different way, and not that popular. So, you are protected on that front and save more money. + +Linux updates are much faster due to stability and the small size of updates. Hence you save money on your data plan as well. + +And, you save thousands of hours by not looking at this: + +![The Never ending wait which becomes part of your life][3] + +### Closing Notes + +Benchmarking a certain set of hardware as “old” is completely subjective in terms of software. You can easily run Debian, or Lubuntu in ten-year-old or more hardware for basic tasks. If someone tells you that your hardware is old, doesn’t make it so. Windows 11 may compel some users to think about their personal hardware strategy in the longer term. It is a market leader in the Desktop operating system and it is a business model for them and OEMs. Fair enough. But if you are a Windows user and reading this, I would recommend you to start experimenting with simple and friendly Linux distributions such as [Linux Mint][4], right now. So that you have options to choose from and have control over your spending in the longer run. + +Cheers. + +* * * + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2021/06/windows-11-system-requirement/ + +作者:[Arindam][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lujun9972 +[1]: https://www.debugpoint.com/2021/06/windows-11-inspiration-linux-kde-plasma/ +[2]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/Windows-11-Desktop-1024x575.jpg +[3]: https://www.debugpoint.com/blog/wp-content/uploads/2021/06/The-Never-ending-wait-which-becomes-part-of-your-life.jpg +[4]: https://www.debugpoint.com/2021/02/cinnamon-arch-linux-install/ 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 new file mode 100644 index 0000000000..e6abce3857 --- /dev/null +++ b/sources/tech/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: ( ) +[#]: 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/20210627 Try Chatwoot, an open source customer relationship platform.md b/sources/tech/20210627 Try Chatwoot, an open source customer relationship platform.md new file mode 100644 index 0000000000..30ee81bab9 --- /dev/null +++ b/sources/tech/20210627 Try Chatwoot, an open source customer relationship platform.md @@ -0,0 +1,154 @@ +[#]: subject: (Try Chatwoot, an open source customer relationship platform) +[#]: via: (https://opensource.com/article/21/6/chatwoot) +[#]: author: (Nitish Tiwari https://opensource.com/users/tiwarinitish86) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Try Chatwoot, an open source customer relationship platform +====== +Chatwoot is an open source alternative to Intercom, Zendesk, Salesforce +Service Cloud, and other proprietary communications platforms. +![Digital images of a computer desktop][1] + +Chatwoot is an open source customer relationship platform built with Ruby and Vue.js. It was written from scratch to allow customer-relations teams to build end-to-end platforms for ticket management and support. + +This article looks at Chatwoot's architecture, installation, and key features. + +### Chatwoot's architecture + +Chatwoot requires the following components to function properly: + + * Chatwoot web servers + * Chatwoot workers + * PostgreSQL database + * Redis + * Email service (e.g., SMTP, SendGrid, Mailgun) + * Object storage (e.g., AWS S3, Azure, Google Cloud Storage, MinIO) + + + +The Chatwoot server and workers are the core components that integrate with everything else. PostgreSQL and Redis are specific, required components. + +![Chatwoot architecture][2] + +(Nitish Tiwari, [CC BY-SA 4.0][3]) + +The other components, like the email server and object storage, are loosely coupled, so you can use any compatible system. Therefore, you could choose any SMTP server, self-hosted or SaaS, as your email service. Similarly, for object storage, you can use public cloud platforms like AWS S3, Azure Blob Store, GCS, or private cloud platforms like MinIO. + +### Install Chatwoot + +Chatwoot is available on common platforms, including Linux virtual machines, Docker, and as a single-click install application on [Heroku][4] and [CapRover][5]. This how-to looks at the Docker installation process; for other platforms, refer to Chatwoot's [documentation][6]. + +To begin, ensure Docker Compose is installed on your machine. Then, download the `env` and `docker-compose` files from [Chatwoot's GitHub repo][7]: + + +``` +# Download the env file template +wget -O .env +# Download the Docker compose template +wget -O docker-compose.yml +``` + +Open the `env` file and fill in the env variables `REDIS_PASSWORD` and `POSTGRES_PASSWORD`; these will be the passwords for Redis and PostgreSQL, respectively. Then update the same PostgreSQL password in the `docker-compose.yaml` file.  + +Now, prepare PostgreSQL: + + +``` +`docker-compose run --rm rails bundle exec rails db:chatwoot_prepare` +``` + +Deploy Chatwoot: + + +``` +`docker-compose up -d` +``` + +You should now be able to access Chatwoot at `http://localhost:3000`. + +![Chatwoot welcome screen][8] + +(Nitish Tiwari, [CC BY-SA 4.0][3]) + +### Chatwoot features + +Fill in the details on the welcome page to create the admin user. After that, you should land on the Conversations page. + +![Chatwoot conversations screen][9] + +(Nitish Tiwari, [CC BY-SA 4.0][3]) + +The following are Chatwoot's key features: + +#### Channels + +Chatwoot supports a wide range of platforms as messaging Channels (including website widgets, Facebook, Twitter, WhatsApp, email, and others). To create an integration, click on the **Inboxes** button on the left-hand sidebar. Then select the platform you want to integrate with. + +![Chatwoot channels screen][10] + +(Nitish Tiwari, [CC BY-SA 4.0][3]) + +Each platform has its own set of human agents, teams, labels, and canned responses. This way, Chatwoot allows a unified interface for talking to customers, but each channel is as customizable as it can be in the background. + +#### Reporting + +Organizations take customer response service-level agreements (SLAs) very seriously—and rightly so. Chatwoot has an integrated dashboard that gives a birds-eye view of the most important metrics, like total messages, response times, resolution times, etc. Administrators can also download reports for specific agents. + +![Chatwoot reports screen][11] + +(Nitish Tiwari, [CC BY-SA 4.0][3]) + +#### Contacts + +Chatwoot also captures contact details from each incoming message and neatly arranges this information on a separate page called Contacts. This ensures all contact details are available for further follow-up or even syncing with an external, full-fledged customer relationship management (CRM) platform. + +![Chatwoot Contacts][12] + +(Nitish Tiwari, [CC BY-SA 4.0][3]) + +#### Integrations + +Channels enable integrations with external messaging systems so that Chatwoot can communicate using these systems. However, what if you want a team to be notified on Slack if there is a new chat message on Chatwoot? + +This is where Integration Webhooks come into the picture. This feature allows you to integrate Chatwoot into external systems so that it can send out relevant information. + +![Chatwoot Integrations][13] + +(Nitish Tiwari, [CC BY-SA 4.0][3]) + +### Learn more + +Chatwoot provides many of the key communications features customer relations teams want. To learn more about Chatwoot, take a look at its [GitHub repository][14] and [documentation][15]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/chatwoot + +作者:[Nitish Tiwari][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/tiwarinitish86 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_desk_home_laptop_browser.png?itok=Y3UVpY0l (Digital images of a computer desktop) +[2]: https://opensource.com/sites/default/files/uploads/chatwoot_servicecalls.png (Chatwoot architecture) +[3]: https://creativecommons.org/licenses/by-sa/4.0/ +[4]: https://www.heroku.com/ +[5]: https://caprover.com/docs/get-started.html +[6]: https://www.chatwoot.com/docs/self-hosted/deployment/architecture#available-deployment-options +[7]: https://github.com/chatwoot/chatwoot +[8]: https://opensource.com/sites/default/files/uploads/chatwoot_welcome.png (Chatwoot welcome screen) +[9]: https://opensource.com/sites/default/files/uploads/chatwoot_conversations.png (Chatwoot conversations screen) +[10]: https://opensource.com/sites/default/files/uploads/chatwoot_channels.png (Chatwoot channels screen) +[11]: https://opensource.com/sites/default/files/uploads/chatwoot_reports.png (Chatwoot reports screen) +[12]: https://opensource.com/sites/default/files/uploads/chatwoot_contacts.png (Chatwoot Contacts) +[13]: https://opensource.com/sites/default/files/uploads/chatwoot_integrations.png (Chatwoot Integrations) +[14]: http://github.com/chatwoot/chatwoot +[15]: https://www.chatwoot.com/help-center diff --git a/sources/tech/20210628 Introduction to image builder.md b/sources/tech/20210628 Introduction to image builder.md new file mode 100644 index 0000000000..d484b866f3 --- /dev/null +++ b/sources/tech/20210628 Introduction to image builder.md @@ -0,0 +1,304 @@ +[#]: subject: (Introduction to image builder) +[#]: via: (https://fedoramagazine.org/introduction-to-image-builder/) +[#]: author: (Andy Mott https://fedoramagazine.org/author/amott/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Introduction to image builder +====== + +![][1] + +Photo by [Marcel Strauß][2] on [Unsplash][3] + +Image Builder is a tool that allows you to create custom OS images (based on the upstream project Weldr), and it’s included in the base repos so you can build images right from the start. + +You can use the command line or a Cockpit plugin, and it’s a fairly simple and straightforward process which allows you to create images for most of the major platforms – Libvirt/KVM (RHV or general Linux virtualisation), VMware, Openstack, AWS and Azure. You can also deploy these images from Satellite. + +### Installing Image Builder + +To install Image Builder, run this command: + +``` +sudo dnf install -y osbuild-composer composer-cli cockpit-composer +``` + +If you’re not using Cockpit then omit that last package and you’ll just have the cli tool. + +If you are using Cockpit, then make sure you add the service to firewalld to allow access like this: + +``` +sudo firewall-cmd --add-service=cockpit && sudo firewall-cmd --runtime-to-permanent +``` + +You need to enable the osbuild-composer socket (and cockpit if you installed it and haven’t yet enabled it): + +``` +sudo systemctl enable --now osbuild-composer.socket +sudo systemctl enable --now cockpit.socket +``` + +Image Builder is now running and ready to use so let’s create an image using the cli first, then move on to using Cockpit. + +### Image Builder CLI + +The main cli command is _composer-cli,_ which you use to create, list, examine and delete blueprints. It is also used to build, list, delete and download images for upload to their intended platform. + +#### Available commands + +The following is a list of the Image Builder commands and their functions: + +**Blueprint manipulation** | +---|--- +List all available blueprints | sudo composer-cli blueprints list +Show a blueprint contents in the toml format | sudo composer-cli blueprints show _blueprint-name_ +Save (export) blueprint contents in the toml format into a file _blueprint-name.toml_ | sudo composer-cli blueprints save _blueprint-name_ +Remove a blueprint | sudo composer-cli blueprints delete _blueprint-name_ +Push (import) a blueprint file in the toml format into Image Builder | sudo composer-cli blueprints push _blueprint-name_ +**Composing images from blueprints** | +Start a compose | sudo composer-cli compose start _blueprint-name_ _image-type_ +List all composes | sudo composer-cli compose list +List all composes and their status | sudo composer-cli compose status +Cancel a running compose | sudo composer-cli compose cancel _compose-uuid_ +Delete a finished compose | sudo composer-cli compose delete _compose-uuid_ +Show detailed information about a compose | sudo composer-cli compose info _compose-uuid_ +Download image file of a compose | sudo composer-cli compose image _compose-uuid_ +**Additional resources** | +The composer-cli man page provides a full list of the available subcommands and options | man composer-cli +The composer-cli command provides help on the subcommands and options | sudo composer-cli help + +#### Creating an image blueprint + +The first step in using Image Builder is to use your favorite editor to create the blueprint of the image itself. The blueprint includes everything the image needs to run. Let’s create a really simple one to begin with, then take it from there. + +##### **Create the blueprint file** + +Blueprint files are .toml files, created in your favorite editor, and the minimal required information is shown here: + +``` +name = "image-name" +description = "my image blueprint" +version = "0.0.1" +modules = [] +groups = [] +``` + +The file above can be used to create a minimal image with just the essential software required to run. Typically, images need a few more things, so let’s add in some additional packages. Add in the following below the groups item to add in extra packages: + +``` +[[packages]] +name = "bash-completion" +version = "*" +``` + +You will need to repeat this block for every package you wish to install. The version can be a specific version or the asterisk to denote the latest. + +Going into a bit more detail, the groups declaration is used to add any groups you might need in the image. If you’re not adding any you can use the format above, but if you need to create a group remove the line shown above: + +``` +groups = [] +``` + +and add this: + +``` +[[groups]] +name = "mygroup" +``` + +Again, you need to repeat this block for every group you want to add. + +It is recommended that you create at least a “root” user using something similar to this: + +``` +[[customizations.user]] + name = "root" + description = "root" + password = "$6$ZkdAX1t8QwEAc/GH$Oi3NY3fyTH/87ALiPfCzZTwpCoKv7P3bCVnoD9JnI8f5gV9I3A0bq5mZrKrw6isuYatmRQ.SVq3Vq27v3X2yu." + home = "/home/root/" + shell = "/usr/bin/bash" + groups = ["root"] +``` + +An example blueprint is available at and it contains an explanation for creating the password hash. It doesn’t cover everything, but has the majority of the options shown. + +##### **Push the blueprint to Image Builder** + +Once you have your blueprint ready, you need to push it to Image Builder. This command pushes file _blueprint-name.toml_ to Image Builder: + +``` +sudo composer-cli blueprints push blueprint-name.toml +``` + +Check that it has been pushed with the _blueprints list_ command: + +``` +sudo composer-cli blueprints list +``` + +##### Generate the image + +Now you have your blueprint uploaded and can use it to generate images. Use the _compose-cli start_ command for this, giving the blueprint name and the output format you want (qcow, ami, vmdk, etc): + +``` +sudo composer-cli compose start blueprint-name qcow2 +``` + +You can obtain a list of image types with: +``` + +``` + +sudo composer-cli compose types +``` + +``` + +The _compose_ step creates a minimally-sized image – if you want more space on your OS disk then add _–size_ and a size, in Gb, to the command. + +The image compose will take a short time, and you can see the status of any images with the + +compose status + +command: + +``` +sudo composer-cli compose status +``` + +##### Using the image + +When the image build is complete the status will show “FINISHED” and you can download it and use it to build your VM: + +``` +sudo composer-cli compose image image-uuid +``` + +The image UUID is displayed when you start the compose. It can also be found at the beginning of the compose status command output. + +The downloaded image file is named with the UUID of the image plus the appropriate extension for the image type. You can copy this file to an image repository and rename as appropriate before creating a VM with it. + +A simple qemu/kvm machine is started like this: + +``` +sudo qemu-kvm --name test-image -m 1024 -hda ./UUID-disk.qcow2 +``` + +Alternatively, you can copy this image to a new file and use that file as the OS disk for a new VM. + +### Image Builder in Cockpit + +If you want to use Image Builder in Cockpit, you need to install the cockpit-composer package as described in the installation section above. + +After installation, log into your Cockpit URL (localhost:9090) and select _Image Builder_ in the _Tools>Applications_ section. This will take you to the initial Image Builder page, where you can create new blueprints: + +![][4] + +#### Create a blueprint + +Selecting the _Create blueprint_ button will display a dialogue box where you need to enter a name for your blueprint plus an optional description: + +![][5] + +After you enter a name and select _Create_, you move to the add packages page. Create a minimal image here by simply selecting the _Create Image_ button, or add extra packages by entering the name in the search box under _Available Components_ and then selecting the + button to add it to your image. Any dependencies required by the package will also be added to the image. Add as many packages as you require. + +![][6] + +After adding your packages, select the _Commit_ button to save your blueprint. You will be shown the changes your actions will make with the option to continue with your commit or discard the changes next. + +When the commit has been made, you will be returned to the same screen where you can add more packages. If you’re done with that, select the name of your blueprint in the breadcrumbs at the top left of the screen to go to the main screen for that blueprint. From here you can add customizations (users, groups etc), more packages, or create the image: + +![][7] + +If your image requires any specific users, or if you want to edit the root user (I’d recommend this, either to set a password or add an ssh key so you can log in without having to further edit or customize the image), then you can do this here. You can also create a hostname, which is useful for a single-use image but less so if the image will be used as the base for multiple deployments. + +To add a user, select the _Create user_ _account_ button. If you name this user root you can update the root account as you need. Enter a user name, description, any password and/or ssh public key, and if this user will be an administrative user (like root) then tick the box to signify this: + +![][8] + +Select the _Create_ button at the bottom to create the user and return to the main blueprint page. Here you will see the new user, and can create more as necessary. Once you’ve created all your users and added all your packages you can create am image from the blueprint by selecting the _Create image_ button at the upper right. + +![][9] + +#### Create an image + +In the Create image dialogue select an image type from the dropdown list, then select a size. This will effectively be the size of the disk available in the OS, just like you’d specify the virtual disk size when creating a VM manually. This will be thin-provisioned, so the actual image file won’t be this size! Select _Creat_e, when finished, to add your image to a build queue. + +![][10] + +Building images takes a little time, and you can check progress or view completed images in the Images page: + +![][11] + +You can create multiple image types from the same blueprint, so you can deploy the exact same image on multiple platforms, increasing your security and making maintenance and administration easier. + +#### Download the image + +To use your image, you need to download it, then upload to your chosen platform. To download the image, select the 3-dot menu next to the image and choose _Download_: + +![][12] + +That’s it – your image is ready to deploy. For a simple QEMU/KVM example use the same command from the CLI section above. + +``` +sudo qemu-kvm --name test-image -m 1024 -hda ./UUID-disk.qcow2 +``` + +#### Final thoughts + + * You can always edit your blueprints at a later date. The Cockpit UI will automatically increment the version number, but you will need to do this yourself in the toml file if using the CLI. Once you’ve edited the blueprint you will also need to create a new image. + * You may verify the TOML format using this web site Note that this verifies only the file formatting, not correctness of the content. + * You can create images with different sizes if your environment has such requirements. + * Create a different blueprint for each specific image you need – don’t update the same one with different packages and version numbers then create images from those. + * Image Builder does not allow disks to be partitioned. The output types that have a partitioned disk will have a single partition and additionally any platform-specific partitions that are required to boot the system image. For example, qcow2 image type has a single root partition, and possibly a platform specific boot partition – like PReP for PPC64 system – that the image requires to boot. + * Images types that may be created are listed in the following table: + +**Description** | **CLI name** | **File Extension** +---|---|--- +QEMU QCOW2 Image | qcow2 | .qcow2 +Ext4 File System Image | 80 | .qcow2 +Raw Partitioned Disk Image | partitiond-disk | .img +Live Bootable ISO | live-iso | .iso +TAR Archive | tar | .tar +Amazon Machine Image Disk | ami | .ami +VMware Virtual Machine Disk | vmdk | .vmdk +Openstack | openstack | .qcow2 + +Image Builder is a fantastic tool for anyone who needs to have repeatable based images for their environment. It’s definitely still a work in progress, but new features are coming all the time, with plans to allow uploading directly into various hypervisors and cloud platforms and other cool stuff. + +#### Image Builder documentation + +Official Weldr documentation: + +RHEL 8: + +RHEL 7: + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/introduction-to-image-builder/ + +作者:[Andy Mott][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/amott/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2021/05/image_builder-816x345.jpg +[2]: https://unsplash.com/@martzzl?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]: https://unsplash.com/s/photos/builder?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: https://fedoramagazine.org/wp-content/uploads/2021/05/image-builder-start-page-1024x198.png +[5]: https://fedoramagazine.org/wp-content/uploads/2021/05/Screenshot-from-2021-05-25-10-20-34.png +[6]: https://fedoramagazine.org/wp-content/uploads/2021/05/image-builder-add-components-1024x456.png +[7]: https://fedoramagazine.org/wp-content/uploads/2021/05/image-builder-main-blueprint-page-1024x226.png +[8]: https://fedoramagazine.org/wp-content/uploads/2021/05/image-builder-add-user.png +[9]: https://fedoramagazine.org/wp-content/uploads/2021/05/image-builder-main-page-2-1024x303.png +[10]: https://fedoramagazine.org/wp-content/uploads/2021/05/image-builder-create-image-2-1024x701.png +[11]: https://fedoramagazine.org/wp-content/uploads/2021/05/image-builder-images-page-1024x252.png +[12]: https://fedoramagazine.org/wp-content/uploads/2021/05/image-builder-download-image-1024x255.png diff --git a/sources/tech/20210629 Try Linux on any operating system with VirtualBox.md b/sources/tech/20210629 Try Linux on any operating system with VirtualBox.md new file mode 100644 index 0000000000..ccf231735e --- /dev/null +++ b/sources/tech/20210629 Try Linux on any operating system with VirtualBox.md @@ -0,0 +1,325 @@ +[#]: subject: (Try Linux on any operating system with VirtualBox) +[#]: via: (https://opensource.com/article/21/6/try-linux-virtualbox) +[#]: author: (Stephan Avenwedde https://opensource.com/users/hansic99) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Try Linux on any operating system with VirtualBox +====== +VirtualBox helps anyone—even a command line novice—set up a virtual +machine. +![Person programming on a laptop on a building][1] + +VirtualBox makes it easy for anyone to try Linux. You don't even need experience with the command line to set up a simple virtual machine to tinker with Linux. I'm kind of a power user when it comes to virtual machines, but this article will show even novices how to virtualize a Linux system. In addition, it provides an overview of how to run and install a Linux system for testing purposes with the open source hypervisor [VirtualBox][2]. + +### Terms + +Before starting, you should understand the difference between the two operating systems (OSes) in this setup: + + * **Host system:** This is your actual OS on which you install VirtualBox. + * **Guest system:** This is the system you want to run virtualized on top of your host system. + + + +Both systems, host and guest, must interact with each other when it comes to input/output, networking, file access, clipboard, audio, and video. + +In this tutorial, I'll use Windows 10 as the _host system_ and [Fedora 33][3] as the _guest system_. + +### Prerequisites + +When we talk about virtualization, we actually mean [hardware-assisted virtualization][4]. Hardware-assisted virtualization requires a compatible CPU. Almost every ordinary x86 CPU from the last decade comes which this feature. AMD calls it **AMD-V,** and Intel calls it **VT-x**. The virtualization feature adds some additional CPU instructions, and it can be enabled or disabled in the BIOS. + +To start with virtualization: + + * Make sure that AMD-V or VT-x is enabled in the BIOS. + * Download and install [VirtualBox][5]. + + + +### Prepare the virtual machine + +Download the image of the Linux distribution you want to try out. It does not matter if it's a 32-bit or 64-bit OS image. You can even start a 64-bit OS image on a 32-bit host system (with limitations in memory usage, of course) and vice versa. + +> **Considerations:** If possible, choose a Linux distribution that comes with the [Logical Volume Manager][6] (LVM). LVM decouples the filesystem from the physical hard drives. This allows you to increase the size of your guest system's hard drive if you are running out of space. + +Now, open VirtualBox and click on the yellow **New** button: + +![VirtualBox New VM][7] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +Next, configure how much memory the guest OS is allowed to use: + +![Set VM memory size][9] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +My recommendation: **Don't skimp on memory!** When memory is low, the guest system will start paging memory from RAM to the hard drive, worsening the system's performance and responsiveness extremely. If the underlying host system starts paging, you might not notice. For a Linux workstation system with a graphical desktop environment, I recommend at least 4GB of memory. + +Next, create the hard disk: + +![Create virtual hard disk][10] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +Choose the default option, **VDI**: + +![Selecting hard disk file type][11] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +In this window, I recommend choosing **dynamically allocated**, as this allows you to increase the size later. If you choose **fixed size**, the disk will be probably faster, but you won't be able to modify it: + +![Dynamically allocating hard disk][12] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +With a Linux distribution that uses LVM, you can start with a small hard disk. If you are running out of space, you can increase it on demand. + +> **Note**: Fedora's website says [it requires][13] a minimum of 20GB free disk space. I highly recommend you stick to that specification. I chose 8GB here so that I can demonstrate how to increase it later. If you are new to Linux or inexperienced with the command line, choose 20GB. + +![Setting hard disk size][14] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +After creating the hard drive, select the newly created virtual machine from the list in VirtualBox's main window and click on **Settings**. In the Settings menu, go to **System** and select the **Processor** tab. By default, VirtualBox assigns only one CPU core to the guest system. On a modern multicore CPU, it should not be any problem to assign at least two cores, which will speed up the guest system significantly: + +![Assigning cores to guest system][15] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +#### Network adapter setup + +The next thing to take care of is the network setup. By default, VirtualBox creates one NAT connection, which should be OK for most use cases: + +![Network settings][16] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +You can create more than one network adapter. Here are the most common types: + + * **NAT:** The NAT adapter performs a [network address translation][17]. From the outside, it looks like the host and the guest system use the same IP address. You are not able to access the guest system from within the host system over the network. (Although you could define [port forwarding][18] to access certain services.) When your host system has access to the internet, the guest system will have access, too. NAT requires no further configuration. + * _Choose **NAT** if you only need internet access for the guest system._ + * **Bridged adapter:** Here, the guest and the host system share the same physical Ethernet device. Both systems will have independent IP addresses. From the outside, it looks like there are two separate systems in the network, both sharing the same physical Ethernet adapter. This setup is more flexible but requires more configuration. + * _Choose **Bridged adapter** if you want to share the guest system's network services._ + * **Host-only adapter:** In this configuration, the guest system can only talk to the host or other guest systems running on the same host. The host system can also connect to the guest system. There is no internet nor physical network access for the guest. + * _Choose **Host-only adapter** for advanced security._ + + + +#### Assign the OS image + +Navigate to **Storage** and select the virtual optical drive. Click on the **CD icon** on the right, and select **Choose a disk file…**. Then assign the downloaded Linux distribution image you want to install: + +![Assigning OS image][19] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +### Install Linux + +The virtual machine is now configured. Leave the **Settings** menu and go back to the main window. Click on the **Green arrow** (i.e., the start button). The virtual machine will start up and boot from the virtual optical drive, and you will find yourself in your Linux distribution's installer: + +![VirtualBox Fedora installer][20] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +#### Partitioning + +The installer will ask you for partitioning information during the installation process. Choose **Custom**: + +![Selecting Custom partition configuration][21] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +> **Note:** I'm assuming you're creating this virtual machine just for testing purposes. Also you don't need to care about hibernation for your guest system, as this function is implicitly provided by VirtualBox. Therefore, you can omit the swap partition to save disk space on your host system. Keep in mind that you can add a swap partition later if needed. In [_An introduction to swap space on Linux systems_][22], David Both explains how to add a swap partition and choose the correct size. + +Fedora 33 and later offer a [zram][23] partition, a compressed part of the memory used for paging and swap. The zram partition is resized on demand, and it is much faster than a hard disk swap partition. + +To keep it simple, just add these two mount points: + +![Adding mount points][24] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +Apply the changes and proceed with the installation. + +### Install VirtualBox Guest Additions + +After you finish the installation, boot from the hard drive and log in. Now you can install VirtualBox Guest Additions, which include special device drivers and system applications that provide: + + * Shared clipboard + * Shared folders + * Better performance + * Freely scalable window size + + + +To install them, click on the top menu in **Devices** and select **Insert Guest Additions CD image…**: + +![Selecting Guest Additions CD image][25] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +On most Linux distributions, the CD image with the Guest Additions is mounted automatically, and they are available in the file browser. Fedora will ask you if you want to run the installation script. Click **Run** and enter your credentials to grant the process root rights: + +![Enabling Guest Additions autorun][26] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +When the installation is finished, reboot the system. + +### LVM: Enlarge disk space + +Creating an 8GB hard disk was a dumb decision, as Fedora quickly starts signaling that it is running out of space: + +![Fedora hard disk running out of space][27] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +As I mentioned, a disk space of 20GB is recommended, and 8GB is the _absolute_ minimum for a Fedora 33 installation to boot up. A fresh installation with no additional software (except the VirtualBox Guest Additions) takes nearly the whole 8GB of available space. Don't open the GNOME Software center or anything else that might download files from the internet in this condition. + +Luckily, I chose to use LVM, so I can easily fix this mishap. + +To increase the filesystem's space within the virtual machine, you must first increase the virtual hard drive on your host system. + +Shut down the virtual machine. If your host system is running Windows, open a command prompt and navigate to `C:\Program Files\Oracle\VirtualBox`. Resize the disk to 12,000MB with the following command: + + +``` +`VBoxManage.exe modifyhd "C:\Users\StephanA\VirtualBox VMs\Fedora_33\Fedora_33.vdi" --resize 12000` +``` + +Boot the virtual machine and open the **Disks** utility. You should see the newly created unassigned free space. Select **Free Space** and click the **+** button: + +![Free space before adding][28] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +Now, create a new partition. Select the amount of free space you want to use: + +![Creating a new partition and setting size][29] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +You don't want to create a filesystem or anything else on your new partition, so select **Other**: + +![Selecting "other" for partition volume type][30] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +Select **No Filesystem**: + +![Setting "No filesystem" on new partition][31] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +The overview should now look like this: + +![VirtualBox after adding new partition][32] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +There is a new partition device, **/dev/sda3**. Check your LVM volume group by typing `vgscan`: + +![Checking LVM volume group by typing vgscan:][33] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +Now you have everything you need. Extend the volume group in the new partition: + + +``` +`vgextend fedora_localhost-live /dev/sda3` +``` + +![vgextend command output][34] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +Because the volume group is larger, you can increase the size of the logical volume. The command `vgdisplay` shows that it has 951 free extends available: + +![vgdisplay command output][35] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +Increase the logical volume by 951 extends: + + +``` +`lvextend -l+951 /dev/mapper/fedora_localhost--live-root` +``` + +![lvextend command output][36] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +After you increase the logical volume, the last thing to do is to resize the filesystem: + + +``` +`resize2fs /dev/mapper/fedora_localhost--live-root` +``` + +![resize2fs command output][37] + +(Stephan Avenwedde, [CC BY-SA 4.0][8]) + +Done! Check the **Disk Usage Analyzer**, and you should see that the extended space is available for the filesystem. + +### Summary + +With a virtual machine, you can check how a piece of software behaves with a specific operating system or a specific version of an operating system. Besides that, you can also try out any Linux distribution you want to test without worrying about breaking your system. For advanced users, VirtualBox offers a wide range of possibilities when it comes to testing, networking, and simulation. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/6/try-linux-virtualbox + +作者:[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/computer_code_programming_laptop.jpg?itok=ormv35tV (Person programming on a laptop on a building) +[2]: https://www.virtualbox.org/ +[3]: https://getfedora.org/ +[4]: https://en.wikipedia.org/wiki/Hardware-assisted_virtualization +[5]: https://www.virtualbox.org/wiki/Downloads +[6]: https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux) +[7]: https://opensource.com/sites/default/files/uploads/virtualbox_new_vm.png (VirtualBox New VM) +[8]: https://creativecommons.org/licenses/by-sa/4.0/ +[9]: https://opensource.com/sites/default/files/uploads/virtualbox_memory_size_1.png (Set VM memory size) +[10]: https://opensource.com/sites/default/files/uploads/virtualbox_create_hd_1.png (Create virtual hard disk) +[11]: https://opensource.com/sites/default/files/uploads/virtualbox_create_hd_2.png (Selecting hard disk file type) +[12]: https://opensource.com/sites/default/files/uploads/virtualbox_create_hd_3.png (Dynamically allocating hard disk) +[13]: https://getfedora.org/en/workstation/download/ +[14]: https://opensource.com/sites/default/files/uploads/virtualbox_create_hd_4.png (Setting hard disk size) +[15]: https://opensource.com/sites/default/files/uploads/virtualbox_cpu_settings.png (Assigning cores to guest system) +[16]: https://opensource.com/sites/default/files/uploads/virtualbox_network_settings2.png (Network settings) +[17]: https://en.wikipedia.org/wiki/Network_address_translation +[18]: https://www.virtualbox.org/manual/ch06.html#natforward +[19]: https://opensource.com/sites/default/files/uploads/virtualbox_choose_image3.png (Assigning OS image) +[20]: https://opensource.com/sites/default/files/uploads/virtualbox_running.png (VirtualBox Fedora installer) +[21]: https://opensource.com/sites/default/files/uploads/virtualbox_partitioning_1.png (Selecting Custom partition configuration) +[22]: https://opensource.com/article/18/9/swap-space-linux-systems +[23]: https://fedoraproject.org/wiki/Changes/SwapOnZRAM +[24]: https://opensource.com/sites/default/files/uploads/virtualbox_partitioning_2.png (Adding mount points) +[25]: https://opensource.com/sites/default/files/uploads/virtualbox_guest_additions_2.png (Selecting Guest Additions CD image) +[26]: https://opensource.com/sites/default/files/uploads/virtualbox_guest_additions_autorun.png (Enabling Guest Additions autorun) +[27]: https://opensource.com/sites/default/files/uploads/virtualbox_disk_usage_1.png (Fedora hard disk running out of space) +[28]: https://opensource.com/sites/default/files/uploads/virtualbox_disks_before.png (Free space before adding) +[29]: https://opensource.com/sites/default/files/uploads/virtualbox_new_partition_1.png (Creating a new partition and setting size) +[30]: https://opensource.com/sites/default/files/uploads/virtualbox_new_partition_2.png (Selecting "other" for partition volume type) +[31]: https://opensource.com/sites/default/files/uploads/virtualbox_no_partition_3.png (Setting "No filesystem" on new partition) +[32]: https://opensource.com/sites/default/files/uploads/virtualbox_disk_after.png (VirtualBox after adding new partition) +[33]: https://opensource.com/sites/default/files/uploads/virtualbox_vgscan.png (Checking LVM volume group by typing vgscan:) +[34]: https://opensource.com/sites/default/files/uploads/virtualbox_vgextend_2.png (vgextend command output) +[35]: https://opensource.com/sites/default/files/uploads/virtualbox_vgdisplay.png (vgdisplay command output) +[36]: https://opensource.com/sites/default/files/uploads/virtualbox_lvextend.png (lvextend command output) +[37]: https://opensource.com/sites/default/files/uploads/virtualbox_resizefs.png (resize2fs command output) 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 new file mode 100644 index 0000000000..44a5b4ad73 --- /dev/null +++ b/sources/tech/20210630 9 reasons I love to use the Qt Creator IDE.md @@ -0,0 +1,209 @@ +[#]: 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/20210630 Is remmina useful for your daily work.md b/sources/tech/20210630 Is remmina useful for your daily work.md new file mode 100644 index 0000000000..a800764706 --- /dev/null +++ b/sources/tech/20210630 Is remmina useful for your daily work.md @@ -0,0 +1,139 @@ +[#]: subject: (Is remmina useful for your daily work?) +[#]: via: (https://fedoramagazine.org/is-remmina-useful-for-your-daily-work/) +[#]: author: (zexcon https://fedoramagazine.org/author/zexcon/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Is remmina useful for your daily work? +====== + +![][1] + +Photo by [Oğuzhan Akdoğan][2] on [Unsplash][3] + +[Remmina][4] is a Remote Desktop Client that supports numerous protocols allowing you to connect to many remote systems. This full featured client program allows you to set up a shared folder, select the screen size and type of connection being used. There are many more options that give you the ability to customize your connection to fit your individual needs. In this article we will utilize Remote Desktop Protocol (RDP) to demonstrate its capabilities. RDP is commonly used for logging into Microsoft Windows machines remotely and that will be used as an example. + +### How I came to use remmina + +Using _remmina_ has become a staple of my work and personal life. At one point I’m sitting at my desk looking at a 13″ monitor trying to perform work on an inadequate laptop. To my left is a 34″ ultra-wide connected to my personal box running Fedora Linux. Then it dawned on me, I should see if I can remote in and use my 34″ monitor to make my life better and offload resource intensive processes. The answer is yes, maybe? Lets try it out and see if it works for you. + +### Installing remmina + +The _remmina_ software is available in the Fedora Linux repository by default. Install it by running the following. +``` + +``` + +sudo dnf install remmina +``` + +``` + +### Collecting Windows Information + +On the the Windows computer you are going to remote into you will need to get the IP address, domain name and username. Type the _Windows Key + r_ and this will display the run box. Type _cmd_ and select OK. + +![][5] + +The terminal (command line) displayed allows us to obtain the IP address. At the prompt type _ipconfig_. +``` + +``` + +ipconfig +``` + +``` + +You will see options labeled “IPv6 Address” or “IPv4 Address” or both. Keep this address handy for the next section. In the terminal enter _set user_ to obtain the Server, Domain and Username. +``` + +``` + +set user +``` + +``` + +This displays the USERDOMAIN and USERNAME. Make note of this along with the IP address you captured in the last step. You will have the following three items. + + * Server = IPv4 or IPv6 + * USERDOMAIN = Domain + * USERNAME = Username + + + +With these three pieces of information you are ready to move to creating the connection. + +### Running remmina + +Execute the following command to start _remmina:_ +``` + +``` + +remmina +``` + +``` + +![Remnina startup screen][6] + +### Creating the connection + +Lets look at creating a connection. Select the icon to the left of the magnifying class at the top to create a connection profile (middle icon of the three). + +![][7] + +In the Remote Connection Profile you provide all the options to create the connection. Provide a meaningful title under the Name field. You can also add your connection to a Group if you are going to manage several connections with _remmina_. For the Protocol select “RDP – Remote Desktop Protocol”. + +Under the Basic options you will need to provide your IPv4 or IPv6 address for the host computer, your login name for the Username and the corresponding password. Use of the Domain will be specific to your situation and may not be needed. + +At this point, you are ready to connect to your remote desktop and can click “Save and Connect” at the bottom or you can continue reading and learn about some of the additional options. + +### The fun stuff “options” + +Here is where all the fun begins. Under Basic you can select Enable multi monitor, Span screen over multiple monitors and List monitor IDs. This allows you to use one or more monitors in many different configurations. You can even set the resolution or select a Color depth. + +One of my favorite options available is the Share folder that allows you to setup a folder on your local machine and it will automatically mount on the remote computer. This affords you the opportunity to move files back and forth easily and no more emailing yourself! + +![][8] + +We will only cover two items under the Advanced section one is Quality and allows you to select performance over visual appeal or vise versa. The second option is the security protocol negotiation that I recommend leaving set to Automatic negotiation. + +![][9] + +### Alternative + +In all fairness I didn’t start with _remmina_. It took using others, notably [FreeRDP,][10] for me to see that the learning curve could be substantial and I didn’t want it to effect my availability and productivity at work. With a little bit of time and research you can dig in and learn the many features of FreeRDP and see if it might be the better choice for you. + +### Conclusion + +A basic setup for an RDP connection to a Windows system was described. Some options were discussed, such as setting the Resolution, Share folder, and Quality. We only touched on a minimal set available among an abundance of options. If you find that _remmina_ is right for you, I highly recommend you go through the remaining options. Many of the options can help tweak the desktop to fit your personal preferences and create a better experience. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/is-remmina-useful-for-your-daily-work/ + +作者:[zexcon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/zexcon/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2021/06/remote_display-816x345.jpg +[2]: https://unsplash.com/@jeffgry?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]: https://unsplash.com/s/photos/remote-display?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: https://remmina.org/ +[5]: https://fedoramagazine.org/wp-content/uploads/2021/06/Remmina05.jpg +[6]: https://fedoramagazine.org/wp-content/uploads/2021/06/Remmina01.jpg +[7]: https://fedoramagazine.org/wp-content/uploads/2021/06/Remmina02.jpg +[8]: https://fedoramagazine.org/wp-content/uploads/2021/06/Rammina03.jpg +[9]: https://fedoramagazine.org/wp-content/uploads/2021/06/Remmina04.jpg +[10]: https://www.freerdp.com/ diff --git a/sources/tech/20210701 How I build my personal website using containers with a Makefile.md b/sources/tech/20210701 How I build my personal website using containers with a Makefile.md new file mode 100644 index 0000000000..12233855c7 --- /dev/null +++ b/sources/tech/20210701 How I build my personal website using containers with a Makefile.md @@ -0,0 +1,212 @@ +[#]: subject: (How I build my personal website using containers with a Makefile) +[#]: via: (https://opensource.com/article/21/7/manage-containers-makefile) +[#]: author: (Chris Collins https://opensource.com/users/clcollins) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +How I build my personal website using containers with a Makefile +====== +Simplify container management by combining the commands to build, test, +and deploy a project in a Makefile. +![Parts, modules, containers for software][1] + +The `make` utility and its related [Makefile][2] have been used to build software for a long time. The Makefile defines a set of commands to run, and the `make` utility runs them. It is similar to a Dockerfile or Containerfile—a set of commands used to build container images. + +Together, a Makefile and Containerfile are an excellent way to manage a container-based project. The Containerfile describes the contents of the container image, and the Makefile describes how to manage the project itself: kicking the image build, testing, and deployment, among other helpful commands. + +### Make targets + +The Makefile consists of "targets": one or more commands grouped under a single command. You can run each target by running the `make` command followed by the target you want to run: + + +``` +# Runs the "build_image" make target from the Makefile +$ make build_image +``` + +This is the beauty of the Makefile. You can build a collection of targets for each task that needs to be performed manually. In the context of a container-based project, this includes building the image, pushing it to a registry, testing the image, and even deploying the image and updating the service running it. I use a Makefile for my personal website to do all these tasks in an easy, automated way. + +### Build, test, deploy + +I build my website using [Hugo][3], a static website generator that builds static HTML from YAML files. I use Hugo to build the HTML files for me, then build a container image with those files and [Caddy][4], a fast and simple web server, and run that image as a container. (Both Hugo and Caddy are open source, Apache-licensed projects.) I use a Makefile to make building and deploying that image to production much easier. + +The first target in the Makefile is appropriately the `image_build` command: + + +``` +image_build: +  podman build --format docker -f Containerfile -t $(IMAGE_REF):$(HASH) . +``` + +This target invokes [Podman][5] to build an image from the Containerfile included in the project. There are some variables in the command above—what are they? Variables can be specified in the Makefile, similarly to Bash or a programming language. I use them for a variety of things within the Makefile, but the most useful is building the image reference to be pushed to remote container image registries: + + +``` +# Image values +REGISTRY := "us.gcr.io" +PROJECT := "my-project-name" +IMAGE := "some-image-name" +IMAGE_REF := $(REGISTRY)/$(PROJECT)/$(IMAGE) + +# Git commit hash +HASH := $(shell git rev-parse --short HEAD) +``` + +Using these variables, the `image_build` target builds an image reference like `us.gcr.io/my-project-name/my-image-name:abc1234` using the short Git revision hash as the image tag so that it can be tied to the code that built it easily. + +The Makefile then tags that image as `:latest`. I don't generally use `:latest` for anything in production, but further down in this Makefile, it will come in useful for cleanup: + + +``` +image_tag: +  podman tag $(IMAGE_REF):$(HASH) $(IMAGE_REF):latest +``` + +So, now the image has been built and needs to be validated to make sure it meets some minimum requirements. For my personal website, this is honestly just, "does the webserver start and return something?" This could be accomplished with shell commands in the Makefile, but it was easier for me to write a Python script that starts a container with Podman, issues an HTTP request to the container, verifies it receives a reply, and then cleans up the container. Python's "try, except, finally" exception handling is perfect for this and considerably easier than replicating the same logic from shell commands in a Makefile: + + +``` +#!/usr/bin/env python3 + +import time +import argparse +from subprocess import check_call, CalledProcessError +from urllib.request import urlopen, Request + +parser = argparse.ArgumentParser() +parser.add_argument('-i', '--image', action='store', required=True, help='image name') +args = parser.parse_args() + +print(args.image) + +try: +    check_call("podman rm smk".split()) +except CalledProcessError as err: +    pass + +check_call( +    "podman run --rm --name=smk -p 8080:8080 -d {}".format(args.image).split() +) + +time.sleep(5) + +r = Request("", headers={'Host': 'chris.collins.is'}) +try: +    print(str(urlopen(r).read())) +finally: +    check_call("podman kill smk".split()) +``` + +This could be a more thorough test. For example, during the build process, the Git revision hash could be built into the response, and the test could check that the response included the expected hash. This would have the benefit of verifying that at least some of the expected content is there. + +If all goes well with the tests, then the image is ready to be deployed. I use Google's Cloud Run service to host my website, and like any of the major cloud services, there is an excellent command-line interface (CLI) tool that I can use to interact with the service. Since Cloud Run is a container service, deployment consists of pushing the images built locally to a remote container registry, and then kicking off a rollout of the service using the `gcloud` CLI tool. + +You can do the push using Podman or Skopeo (or Docker, if you're using it). My push target pushes the `$(IMAGE_REF):$(HASH)` image and also the `:latest` tag: + + +``` +push: +  podman push --remove-signatures $(IMAGE_REF):$(HASH) +  podman push --remove-signatures $(IMAGE_REF):latest +``` + +After the image has been pushed, use the `gcloud run deploy` command to roll out the newest image to the project and make the new image live. Once again, the Makefile comes in handy here. I can specify the `--platform` and `--region` arguments as variables in the Makefile so that I don't have to remember them each time. Let's be honest: I write so infrequently for my personal blog, there is zero chance I would remember these variables if I had to type them from memory each time I deployed a new image: + + +``` +rollout: +  gcloud run deploy $(PROJECT) --image $(IMAGE_REF):$(HASH) --platform $(PLATFORM) --region $(REGION) +``` + +### More targets + +There are additional helpful `make` targets. When writing new stuff or testing CSS or code changes, I like to see what I'm working on locally without deploying it to a remote server. For this, my Makefile has a `run_local` command, which spins up a container with the contents of my current commit and opens my browser to the URL of the page hosted by the locally running webserver: + + +``` +.PHONY: run_local +run_local: +  podman stop mansmk ; podman rm mansmk ; podman run --name=mansmk --rm -p $(HOST_ADDR):$(HOST_PORT):$(TARGET_PORT) -d $(IMAGE_REF):$(HASH) && $(BROWSER) $(HOST_URL):$(HOST_PORT) +``` + +I also use a variable for the browser name, so I can test with several if I want to. By default, it will open in Firefox when I run `make run_local`. If I want to test the same thing in Google, I run `make run_local BROWSER="google-chrome"`. + +When working with containers and container images, cleaning up old containers and images is an annoying chore, especially when you iterate frequently. I include targets in my Makefile for handling these tasks, too. When cleaning up a container, if the container doesn't exist, Podman or Docker will return with an exit code of 125. Unfortunately, `make` expects each command to return 0 or it will stop processing, so I use a wrapper script to handle that case: + + +``` +#!/usr/bin/env bash + +ID="${@}" + +podman stop ${ID} 2>/dev/null + +if [[ $?  == 125 ]] +then +  # No such container +  exit 0 +elif [[ $? == 0 ]] +then +  podman rm ${ID} 2>/dev/null +else +  exit $? +fi +``` + +Cleaning images requires a bit more logic, but it can all be done within the Makefile. To do this easily, I add a label (via the Containerfile) to the image when it's being built. This makes it easy to find all the images with these labels. The most recent of these images can be identified by looking for the `:latest` tag. Finally, all of the images, except those pointing to the image tagged with `:latest`, can be deleted: + + +``` +clean_images: +  $(eval LATEST_IMAGES := $(shell podman images --filter "label=my-project.purpose=app-image" --no-trunc | awk '/latest/ {print $$3}')) +  podman images --filter "label=my-project.purpose=app-image" --no-trunc --quiet | grep -v $(LATEST_IMAGES) | xargs --no-run-if-empty --max-lines=1 podman image rm +``` + +This is the point where using a Makefile for managing container projects really comes together into something cool. To this point, the Makefile includes commands for building and tagging images, testing, pushing images, rolling out a new version, cleaning up a container, cleaning up images, and running a local version. Running each of these with `make image_build && make image_tag && make test`… etc. is considerably easier than running each of the original commands, but it can be simplified even further. + +A Makefile can group commands into a target, allowing multiple targets to run with a single command. For example, my Makefile groups the `image_build` and `image_tag` targets under the `build` target, so I can run both by simply using `make build`. Even better, these targets can be further grouped into the default `make` target, `all`, allowing me to run all of them in order by executing `make all` or more simply, `make`. + +For my project, I want the default `make` action to include everything from building the image to testing, deploying, and cleaning up, so I include the following targets: + + +``` +.PHONY: all +all: build test deploy clean + +.PHONY: build image_build image_tag +build: image_build image_tag + +.PHONY: deploy push rollout +deploy: push rollout + +.PHONY: clean clean_containers clean_images +clean: clean_containers clean_images +``` + +This does everything I've talked about in this article, except the `make run_local` target, in a single command: `make`. + +### Conclusion + +A Makefile is an excellent way to manage a container-based project. By combining all the commands necessary to build, test, and deploy a project into `make` targets within the Makefile, all the "meta" work—everything aside from writing the code—can be simplified and automated. The Makefile can even be used for code-related tasks: running unit tests, maintaining modules, compiling binaries and checksums. While it can't yet write code for you, using a Makefile combined with the benefits of a containerized, cloud-based service can `make` (wink, wink) managing many aspects of a project much easier. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/manage-containers-makefile + +作者:[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/containers_modules_networking_hardware_parts.png?itok=rPpVj92- (Parts, modules, containers for software) +[2]: https://opensource.com/article/18/8/what-how-makefile +[3]: https://gohugo.io/ +[4]: https://caddyserver.com/ +[5]: https://podman.io diff --git a/sources/tech/20210701 Try Dolibarr, an open source customer relationship management platform.md b/sources/tech/20210701 Try Dolibarr, an open source customer relationship management platform.md new file mode 100644 index 0000000000..7549782409 --- /dev/null +++ b/sources/tech/20210701 Try Dolibarr, an open source customer relationship management platform.md @@ -0,0 +1,98 @@ +[#]: subject: (Try Dolibarr, an open source customer relationship management platform) +[#]: via: (https://opensource.com/article/21/7/open-source-dolibarr) +[#]: author: (Pradeep Vijayakumar https://opensource.com/users/deepschennai) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Try Dolibarr, an open source customer relationship management platform +====== +Maintain a customer database and send promotions and offers with +Dolibarr's CRM features. +![a handshake ][1] + +No matter what industry you work in, a key aspect of sustaining your business is keeping your customers. In the customer-relations domain, we call this _customer retention_. + +Whether you run a retail store, restaurant, pub, supermarket, gym, or any other business, you need a reliable way to keep in touch with your customers. After all, they're customers because they like what you do, and, if they've shared their contact information with you, they want to hear more about what you have to offer. Sending them discount coupons, promotions, and special offers benefits your customers and helps ensure they remember your brand and come back to do business with you again. + +So, how can you achieve this? + +I work with [many other people][2] on the [Dolibarr][3] project. It's an open source enterprise resource planning (ERP) and customer relationship management (CRM) software. Dolibarr provides a whole range of ERP features, including point-of-sale (POS), invoicing, stock and inventory management, sales orders, purchase orders, and human resources management. This article focuses on Dolibarr's CRM features, which help you maintain a database of your customers and connect with them to send promotions and offers. + +Even if you've never used a CRM system before, Dolibarr makes it easy to manage your customers and, as long as you put in the effort, enhance customer loyalty. + +### Install Dolibarr CRM + +Dolibarr is open source, so you can [download][4] it and run it locally. If your store's staff includes more than a few people, you probably need a few networked Dolibarr instances. Your systems administrator can set that up for you or, if you're on your own, many hosting service providers offer one-click installers, such as Installatron and Softaculous. + +In the interim, you can try Dolibarr's [online demo][5]. + +### Add customer data + +The first step to getting to know your customers is getting your customers' information into your CRM system. You may not have this data yet, so you'll be starting fresh, or you might have a database or spreadsheet from a system that hasn't been working out for you. Dolibarr imports a wide variety of formats, so it's relatively painless to migrate. + +For the sake of simplicity, I'll assume you're entering new customers. To enter a new customer into your Dolibarr system, navigate to the **Third-parties** menu, and click on the **New Customer** menu item. + +![add a new customer to Dolibarr][6] + +(Pradeep Vijayakumar, [CC BY-SA 4.0][7]) + +All the fields are configurable, and you can add and remove fields if you want. Define a marketing strategy on how you want to connect with your customers. It could be email, SMS, Facebook, Twitter, or another way your customers prefer. Once you have defined the communication channel, you know what information you need to capture for each customer. + +For example, if you've chosen email as your communication method, you know to ask your customers for an email address so that you can put it into the system, along with their name, location, and any other information that may be important to you. + +### Set up an email campaign + +Imagine you're running a weekend promotion with a 20% discount on selected products. Here's how to run an email campaign to announce this offer to all your customers in just a few clicks. + +First, click on the **Tools** tab and the **New Emailing** link. You can use the editor's WYSIWYG capabilities to design attractive emails. + +![Drafting a marketing email with Dolibarr's WYSIWYG Editor][8] + +(Pradeep Vijayakumar, [CC BY-SA 4.0][7]) + +You can use substitution variables to individualize your customers' name, location, gender, etc., as long as you have captured this information in the system (use the **?** tool tip to get the list of substitution variables). Because this email will go out to all the people in your database, you must use the substitution variables to represent any customer-specific data, such as your customers' names. + +Once you've drafted your email, the next step is choosing your customer list. Navigate to the **Recipients** tab and choose **Third parties (by categories)**. + +![Add customers to an email campaign list][9] + +(Pradeep Vijayakumar, [CC BY-SA 4.0][7]) + +All your customers should be included in this email list; you can confirm this by looking at the count displayed next to the list and under **Number of distinct recipients**. + +You can now click on **Validate** and then **Send** to send your email to all of your customers. Dolibarr automatically substitutes the substitution variables with actual customer data. You can also view the delivery reports for the emails that were sent out. + +### Integrations + +Because the marketplace is ever-changing, CRM software needs to keep pace with what customers use for communication. Dolibarr is designed for integration. You can, for instance, manage SMS marketing the same way you manage email marketing. The same is true for WhatsApp and many other targets. + +### Learn more + +All things considered, I think Dolibarr is an indispensable tool for implementing a customer relationship and customer retention strategy for your business. You can learn more about Dolibarr's CRM features by watching [this video on YouTube][10]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/open-source-dolibarr + +作者:[Pradeep Vijayakumar][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/deepschennai +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/handshake_business_contract_partner.png?itok=NrAWzIDM (a handshake ) +[2]: https://www.dolibarr.org/who-works-on-the-dolibarr-project-.php +[3]: http://dolibarr.org/ +[4]: https://www.dolibarr.org/downloads.php +[5]: https://www.dolibarr.org/onlinedemo.php +[6]: https://opensource.com/sites/default/files/uploads/dolibarr_add-customer.png (add a new customer to Dolibarr) +[7]: https://creativecommons.org/licenses/by-sa/4.0/ +[8]: https://opensource.com/sites/default/files/uploads/dolibarr_create-email.png (Drafting a marketing email with Dolibarr's WYSIWYG Editor) +[9]: https://opensource.com/sites/default/files/uploads/dolibarr_select-recipients.png (Add customers to an email campaign list) +[10]: https://youtu.be/9ETxdpVsgU0 diff --git a/sources/tech/20210702 Bind a cloud event to Knative.md b/sources/tech/20210702 Bind a cloud event to Knative.md new file mode 100644 index 0000000000..46f218a2e5 --- /dev/null +++ b/sources/tech/20210702 Bind a cloud event to Knative.md @@ -0,0 +1,333 @@ +[#]: subject: (Bind a cloud event to Knative) +[#]: via: (https://opensource.com/article/21/7/cloudevents-bind-java-knative) +[#]: author: (Daniel Oh https://opensource.com/users/daniel-oh) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Bind a cloud event to Knative +====== +CloudEvents provides a common format to describe events and increase +interoperability. +![woman on laptop sitting at the window][1] + +Events have become an essential piece of modern reactive systems. Indeed, events can be used to communicate from one service to another, trigger out-of-band processing, or send a payload to a service like Kafka. The problem is that event publishers may express event messages in any number of different ways, regardless of content. For example, some messages are payloads in JSON format to serialize and deserialize messages by application. Other applications use binary formats such as [Avro][2] and [Protobuf][3] to transport payloads with metadata. This is an issue when building an event-driven architecture that aims to easily integrate external systems and reduce the complexity of message transmission. + +[CloudEvents][4] is an open specification providing a common format to describe events and increase interoperability. Many cloud providers and middleware stacks, including [Knative][5], [Kogito][6], [Debezium][7], and [Quarkus][8] have adopted this format after the release of CloudEvents 1.0. Furthermore, developers need to decouple relationships between event producers and consumers in serverless architectures. [Knative Eventing][9] is consistent with the CloudEvents specification, providing common formats for creating, parsing, sending, and receiving events in any programming language. Knative Eventing also enables developers to late-bind event sources and event consumers. For example, a cloud event using JSON might look like this: + + +``` +{ +    "specversion" : "1.0", (1) +    "id" : "11111", (2) +    "source" : "", (3) +    "type" : "knative-events-binding", (4) +    "subject" : "cloudevents", (5) +    "time" : "2021-06-04T16:00:00Z", (6) +    "datacontenttype" : "application/json", (7) +    "data" : "{\"message\": \"Knative Events\"}", (8) +} +``` + +In the above code: +(1) Which version of the CloudEvents specification to use +(2) The ID field for a specific event; combining the `id` and the `source` provides a unique identifier +(3) The Uniform Resource Identifier (URI) identifies the event source in terms of the context where it happened or the application that emitted it +(4) The type of event with any random words +(5) Additional details about the event (optional) +(6) The event creation time (optional) +(7) The content type of the data attribute (optional) +(8) The business data for the specific event + +Here is a quick example of how developers can enable a CloudEvents bind with Knative and the [Quarkus Funqy extension][10]. + +### 1\. Create a Quarkus Knative event Maven project + +Generate a Quarkus project (e.g., `quarkus-serverless-cloudevent`) to create a simple function with Funqy Knative events binding extensions: + + +``` +$ mvn io.quarkus:quarkus-maven-plugin:2.0.0.CR3:create \ +       -DprojectGroupId=org.acme \ +       -DprojectArtifactId=quarkus-serverless-cloudevent \ +       -Dextensions="funqy-knative-events" \ +       -DclassName="org.acme.getting.started.GreetingResource" +``` + +### 2\. Run the serverless event function locally + +Open the `CloudEventGreeting.java` file in the `src/main/java/org/acme/getting/started/funqy/cloudevent` directory. The `@funq` annotation enables the `myCloudEventGreeting` method to map the input data to the cloud event message automatically: + + +``` +private static final Logger log = Logger.getLogger(CloudEventGreeting.class); + +    @Funq +    public void myCloudEventGreeting(Person input) { +        log.info("Hello " + input.getName()); +    } +} +``` + +Run the function via Quarkus Dev Mode: + + +``` +`$ ./mvnw quarkus:dev` +``` + +The output should look like this: + + +``` +__  ____  __  _____   ___  __ ____  ______ + --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ + -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   +\--\\___\\_\\____/_/ |_/_/|_/_/|_|\\____/___/   +INFO  [io.quarkus] (Quarkus Main Thread) quarkus-serverless-cloudevent 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.0.0.CR3) started in 1.546s. Listening on: +INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated. +INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, funqy-knative-events, smallrye-context-propagation] + +\-- +Tests paused, press [r] to resume +``` + +**Note**: Quarkus 2.x provides a continuous testing feature so that you can keep testing your code when you add or update code by pressing `r` in the terminal. + +Now the CloudEvents function is running in your local development environment. So, send a cloud event to the function over the HTTP protocol: + + +``` +curl -v \ +  -H "Content-Type:application/json" \ +  -H "Ce-Id:1" \ +  -H "Ce-Source:cloud-event-example" \ +  -H "Ce-Type:myCloudEventGreeting" \ +  -H "Ce-Specversion:1.0" \ +  -d "{\"name\": \"Daniel\"}" +``` + +The output should end with: + + +``` +`HTTP/1.1 204 No Content` +``` + +Go back to the terminal, and the log should look like this: + + +``` +`INFO [org.acm.get.sta.fun.clo.CloudEventGreeting] (executor-thread-0) Hello Daniel` +``` + +### 3\. Deploy the serverless event function to Knative + +Add a `container-image-docker` extension to the Quarkus Funqy project. The extension enables you to build a container image based on the serverless event function and then push it to an external container registry (e.g., [Docker Hub][11], [Quay.io][12]): + + +``` +`$ ./mvnw quarkus:add-extension -Dextensions="container-image-docker"` +``` + +Open the `application.properties` file in the `src/main/resources/` directory. Then add the following variables to configure Knative and Kubernetes resources (make sure to replace `yourAccountName` with your container registry's account name, e.g., your username in Docker Hub): + + +``` +quarkus.container-image.build=true +quarkus.container-image.push=true +quarkus.container-image.builder=docker +quarkus.container-image.image=docker.io/yourAccountName/funqy-knative-events-codestart +``` + +Run the following command to containerize the function and then push it to the Docker Hub container registry automatically: + + +``` +`$ ./mvnw clean package` +``` + +The output should end with `BUILD SUCCESS`. + +Open the `funqy-service.yaml` file in the `src/main/k8s` directory. Then replace `yourAccountName` with your account information in the Docker Hub registry: + + +``` +apiVersion: serving.knative.dev/v1 +kind: Service +metadata: +  name: funqy-knative-events-codestart +spec: +  template: +    metadata: +      name: funqy-knative-events-codestart-v1 +      annotations: +        autoscaling.knative.dev/target: "1" +    spec: +      containers: +        - image: docker.io/yourAccountName/funqy-knative-events-codestart +``` + +Assuming the container image pushed successfully, create the Knative service based on the event function using the following `kubectl` command-line tool (be sure to log into the Kubernetes cluster and change the namespace where you want to create the Knative service): + + +``` +`$ kubectl create -f src/main/k8s/funqy-service.yaml` +``` + +The output should look like this: + + +``` +`service.serving.knative.dev/funqy-knative-events-codestart created` +``` + +Create a default broker to subscribe to the event function. Use the [kn][13] Knative Serving command-line tool: + + +``` +`$ kn broker create default` +``` + +Open the `funqy-trigger.yaml` file in the `src/main/k8s` directory and replace it with: + + +``` +apiVersion: eventing.knative.dev/v1 +kind: Trigger +metadata: +  name: my-cloudevent-greeting +spec: +  broker: default +  subscriber: +    ref: +      apiVersion: serving.knative.dev/v1 +      kind: Service +      name: funqy-knative-events-codestart +``` + +Create a trigger using the `kubectl` command-line tool: + + +``` +`$ kubectl create -f src/main/k8s/funqy-trigger.yaml` +``` + +The output should look like this: + + +``` +`trigger.eventing.knative.dev/my-cloudevent-greeting created` +``` + +### 4\. Send a cloud event to the serverless event function in Kubernetes + +Find out the function's route URL and check that the output looks like this: + + +``` +$ kubectl get rt +NAME URL READY REASON +funqy-knative-events-codestart     True +``` + +Send a cloud event to the function over the HTTP protocol: + + +``` +curl -v \ +  -H "Content-Type:application/json" \ +  -H "Ce-Id:1" \ +  -H "Ce-Source:cloud-event-example" \ +  -H "Ce-Type:myCloudEventGreeting" \ +  -H "Ce-Specversion:1.0" \ +  -d "{\"name\": \"Daniel\"}" +``` + +The output should end with: + + +``` +`HTTP/1.1 204 No Content` +``` + +Once the function pod scales up, take a look at the pod logs. Use the following `kubectl` command to retrieve the pod's name: + + +``` +`$ kubectl get pod` +``` + +The output will look like this: + + +``` +NAME                                                           READY   STATUS    RESTARTS   AGE +funqy-knative-events-codestart-v1-deployment-6569f6dfc-zxsqs   2/2     Running   0          11s +``` + +Run the following `kubectl` command to verify that the pod's logs match the local testing's result:  + + +``` +`$ kubectl logs funqy-knative-events-codestart-v1-deployment-6569f6dfc-zxsqs -c user-container | grep CloudEventGreeting` +``` + +The output looks like this: + + +``` +`INFO  [org.acm.get.sta.fun.clo.CloudEventGreeting] (executor-thread-0) Hello Daniel` +``` + +If you deploy the event function to an [OpenShift Kubernetes Distribution][14] (OKD) cluster, you will find the deployment status in the topology view: + +![Deployment status][15] + +(Daniel Oh, [CC BY-SA 4.0][16]) + +You can also find the pod's logs in the **Pod details** tab: + +![Pod details][17] + +(Daniel Oh, [CC BY-SA 4.0][16]) + +### What's next? + +Developers can bind a cloud event to Knative using Quarkus functions. Quarkus also scaffolds Kubernetes manifests, such as Knative services and triggers, to process cloud events over a channel or HTTP request. + +Learn more serverless and Quarkus topics through OpenShift's [interactive self-service learning portal][18]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/cloudevents-bind-java-knative + +作者:[Daniel Oh][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/daniel-oh +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-window-focus.png?itok=g0xPm2kD (young woman working on a laptop) +[2]: https://avro.apache.org/ +[3]: https://developers.google.com/protocol-buffers +[4]: https://cloudevents.io/ +[5]: https://knative.dev/ +[6]: https://kogito.kie.org/ +[7]: https://debezium.io/ +[8]: https://quarkus.io/ +[9]: https://knative.dev/docs/eventing/ +[10]: https://opensource.com/article/21/6/quarkus-funqy +[11]: https://hub.docker.com/ +[12]: https://quay.io/ +[13]: https://knative.dev/docs/client/install-kn/ +[14]: https://www.okd.io/ +[15]: https://opensource.com/sites/default/files/uploads/5_deployment-status.png (Deployment status) +[16]: https://creativecommons.org/licenses/by-sa/4.0/ +[17]: https://opensource.com/sites/default/files/uploads/5_pod-details.png (Pod details) +[18]: https://learn.openshift.com/serverless/ diff --git a/sources/tech/20210702 Creating a PKGBUILD to Make Packages for Arch Linux.md b/sources/tech/20210702 Creating a PKGBUILD to Make Packages for Arch Linux.md new file mode 100644 index 0000000000..c3078135ca --- /dev/null +++ b/sources/tech/20210702 Creating a PKGBUILD to Make Packages for Arch Linux.md @@ -0,0 +1,271 @@ +[#]: subject: (Creating a PKGBUILD to Make Packages for Arch Linux) +[#]: via: (https://itsfoss.com/create-pkgbuild/) +[#]: author: (Hunter Wittenborn https://itsfoss.com/author/hunter/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Creating a PKGBUILD to Make Packages for Arch Linux +====== + +PKGBUILD files are how packages are built and created for Arch Linux and its derivatives such as Manjaro. + +You may have even come across them a bit yourself if you’ve ever used the [AUR][1], Arch Linux’s user-curated repository of PKGBUILDs. + +But how exactly do you go from a PKGBUILD to an installable package? What exactly is going on between the two, and how can you make them for your own packages? You’ll learn them in this article. + +### PKGBUILD basics + +For those who are familiar with Bash or other shells, you’ll be delighted to know, if you didn’t already, that a PKGBUILD is pretty much just a shell script with some variables. + +PKGBUILD files consist of variables and functions, all of which are used to define the package itself, and how to build it. + +To create a package from a PKGBUILD, the makepkg command line utility is used. After obtaining a PKGBUILD, you simply run `makepkg` inside the directory containing the PKGBUILD, and voila, you have an installable package! + +![][2] + +In this tutorial, you’ll be going over the package I just made, which prints “Hello World!” when run: + +![][3] + +### Getting set up + +To follow along with this tutorial, you need to create a couple of files. + +First, you need to make a file called **PKGBUILD**. If it wasn’t already made clear, this will serve as the “recipe” for building your package. + +The other file you’ll need to make is a file called **hello-world.sh**. I’ll explain its purpose a bit later. + +You can create both of these files with a single command as well. + +``` +touch PKGBUILD hello-world.sh +``` + +You can check that the files were created with the ls command: + +![][4] + +And you’re ready to go! + +### Setting up your PKGBUILD file + +**Instead of having you copy paste the whole file, I’ll be going over entering every line with you, so you can better understand the purpose of everything that’s happening. If you don’t prefer to learn this way, I’d highly recommend the** [Arch Wiki article][5] _**on creating packages for Arch Linux.**_ + +_**This article also doesn’t go over every single option you can set in a PKGBUILD, but rather some commonly used ones so you can get going as quickly as possible.**_ + +With that out of the way, open up your text editor, and let’s get straight into it! + +#### pkgname + +First things first, the pkgname variable. This is what defines the name of your package when installing, and how [Arch Linux’s package manager pacman][6] keeps track of the package. + +The format of this variable (and some others) takes the form of variable=value, with the variable name on the left, the value of the variable on the right, separated by an equals sign. + +To set the package name, enter the following into the PKGBUILD: + +``` +pkgname="hello-world" +``` + + * To set a different package name, replace `hello-world` with the name of the package. + * This doesn’t set the command used to run the program. That’s handled a bit below in the `package()` section. + + + +#### pkgver + +As is stated in the variable name itself, this sets the version of your package (i.e. 1.0.0). This is useful when a user updates their system, as setting a higher version will result in the user being prompted for an upgrade. + +To set, enter the following into the PKGBUILD (after the previous line): + +``` +pkgver="1.0.0" +``` + +#### pkgrel + +This is related to the pkgver variable, and isn’t normally important to know about. Like the pkgver variable though, it will notify users for upgrades if it’s moved to a higher number. + +It serves for any changes that require the pkgver to remain the same, such as any changes to the PKGBUILD itself. This would be useful if you’ve created a PKGBUILD for a program you use (and want to keep the version the same as the package’s), and you need to fix a bug in the PKGBUILD itself. + +To set the variable, enter the following in the PKGBUILD: + +``` +pkgver="1" +``` + +This variable should **always** start at 1, and then move up one at a time. When the **pkgver** itself moves up, this can (and should) be reset to 1, as the pkgver itself will notify users that upgrades are available. + +#### pkgdesc + +This will set the description of the package, which is used to help better identify the package. + +To set it, just put the description inside of quotation marks: + +``` +pkgdesc="Hello world in your terminal!" +``` + +#### arch + +This variable sets the [architecture][7] the package is compatible with. It’s fine if you don’t understand what an architecture is, as it’s pretty much useless in most cases. + +Regardless, makepkg still needs it to be set so it knows the package is compatible with our system. + +This variable supports setting multiple values, so makepkg requires a different syntax as shown below. + +To set it, enter the following in the PKGBUILD: + +``` +arch=("x86_64") +``` + +If you were to set multiple values for this, you would separate each value with a space and quotation marks like so: **arch=(“x86_x64” “arm”)** + +#### depends + +This lists all of the packages that our package needs to function. Like **arch**, it can also contain multiple values, and thus must use the parenthesis syntax. + +Since our package won’t have any dependencies, we don’t have to enter this field in the PKGBUILD. If our package did have dependencies however, we’d just use the same syntax as **arch**. + +#### optdepends + +This lists packages that aren’t required to function, but that are needed for extra functionality. + +This follows the same syntax as **depends**. + +#### conflicts + +This tells pacman what packages would cause our package to act up or behave in a way we wouldn’t want. + +Any package listed here would be uninstalled before ours is installed. + +This follows the same syntax as **depends** as well. + +#### license + +This defines the [software license][8] that your program is licensed under. The [Arch Wiki][9] has some info if you need help choosing a license. Setting this to `custom` will work if you don’t know what to set this to. + +This takes the same syntax as **arch** and **depends**: + +``` +license=("custom") +``` + +#### source + +This is how makepkg knows what files to use to build our package. This can contain a variety of different kinds of sources, including local files and URLs. + +When adding local files, enter the file’s name relative to the PKGBUILD i.e. consider the following directory layout: + +``` +PKGBUILD +file.txt +src/file.sh +``` + +If you wanted to include **file.sh** in our PKGBUILD, you would enter **src/file.sh** as its name. + +When entering URLs, you simply enter the full URL, i.e. . + +Your package only needs the hello-world.sh file, and since it’s in the same directory as the PKGBUILD, you just type its name as the value for **source**. + +This variable also uses the same syntax as **arch** and **depends**: + +``` +source=("hello-world.sh") +``` + +#### sha512sums + +This is used to verify that the files in **source** haven’t been modified or downloaded incorrectly. Information on obtaining the values for this can be found in the [Arch Wiki article on PKGBUILDs][10]. + +If you’d rather just not set this (or you just don’t need to, i.e. for local files), you can just enter SKIP for every file in the **source** variable: + +``` +sha512sums=("SKIP") +``` + +#### package() + +This is the last, and most important part to actually making our package. It’s important to know two variables when working with this: + + * **${srcdir}**: This is where makepkg puts the files in the **source** variable. This is the directory where you can interact with the files, and do any other needed modification to the files. + + + * ${pkgdir}: This is where we place the files that will be installed on our system. +The folder structure for ${pkgdir} is set up as if it was on an actual system (i.e. ${pkgdir}/usr/bin/hello-world would create the file /usr/bin/hello-world when installing with pacman. + + + +package() contains a list of commands used create a package. + +So, if (hypothetically) you needed to have a file that reads Linux is superior to Windows at /usr/share/motto.txt, you would run something like this: + +``` +package() { + mkdir -p "${pkgdir}/usr/share" + echo "Linux is superior to Windows" | tee "${pkgdir}/usr/share/motto.txt" +} +``` + +A few notes on the above command: + + * ${pkgdir} contains **no** directories inside it at first. If you skipped the [mkdir command][11], tee would output an error saying the directory doesn’t exist. + + + * When specifying directories, **always** prepend them with the **${pkgdir}** or **${srcdir}** variable. Entering something like /usr/share/motto.txt without such would point to the literal directory /usr/share/motto.txt on your currently running system. + + + +For your PKGBUILD, you’re going to place the file hello-world.sh at /usr/bin/hello-world on your target system. You’ll also be making the file say “Hello to you!” when ran. + +To do so, enter the following into your PKGBUILD: + +``` +package() { + echo 'Hello to you!' > "${srcdir}/hello-world.sh" + mkdir -p "${pkgdir}/usr/bin" + cp "${srcdir}/hello-world.sh" "${pkgdir}/usr/bin/hello-world" + chmod +x "${pkgdir}/usr/bin/hello-world" +} +``` + +And you’re done! **Build and install the package with makepkg -si**, and then run hello-world in your terminal to see its output. + +![][12] + +### Wrapping Up + +And just like that, you have made your first PKGBUILD! You’re on your way to making actual packages for yourself, and maybe even the AUR. + +Got any questions, or something just not working right? Feel free to post it in the comment section below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/create-pkgbuild/ + +作者:[Hunter Wittenborn][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/hunter/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/aur-arch-linux/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/05/image.png?resize=748%2C689&ssl=1 +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/05/image-2.png?resize=682%2C260&ssl=1 +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/05/image-3.png?resize=682%2C265&ssl=1 +[5]: https://wiki.archlinux.org/title/Creating_packages +[6]: https://itsfoss.com/pacman-command/ +[7]: https://www.quora.com/What-is-CPU-architecture +[8]: https://en.wikipedia.org/wiki/Software_license +[9]: https://wiki.archlinux.org/title/PKGBUILD#license +[10]: https://wiki.archlinux.org/title/PKGBUILD#Integrity +[11]: https://linuxhandbook.com/mkdir-command/ +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/image-1.png?resize=561%2C281&ssl=1 diff --git a/sources/tech/20210702 Run Prometheus at home in a container.md b/sources/tech/20210702 Run Prometheus at home in a container.md new file mode 100644 index 0000000000..13b19b7d5e --- /dev/null +++ b/sources/tech/20210702 Run Prometheus at home in a container.md @@ -0,0 +1,330 @@ +[#]: subject: (Run Prometheus at home in a container) +[#]: via: (https://opensource.com/article/21/7/run-prometheus-home-container) +[#]: author: (Chris Collins https://opensource.com/users/clcollins) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Run Prometheus at home in a container +====== +Keep tabs on your home network by setting up a Prometheus container +image. +![A graph of a wave.][1] + +[Prometheus][2] is an open source monitoring and alerting system that provides insight into the state and history of a computer, application, or cluster by storing defined metrics in a time-series database. It provides a powerful query language, PromQL, to help you explore and understand the data it stores. Prometheus also includes an Alertmanager that makes it easy to trigger notifications when the metrics you collect cross certain thresholds. Most importantly, Prometheus is flexible and easy to set up to monitor all kinds of metrics from whatever system you need to track. + +As site reliability engineers (SREs) on Red Hat's OpenShift Dedicated team, we use Prometheus as a central component of our monitoring and alerting for clusters and other aspects of our infrastructure. Using Prometheus, we can predict when problems may occur by following trends in the data we collect from nodes in the cluster and services we run. We can trigger alerts when certain thresholds are crossed or events occur. As a data source for [Grafana][3], Prometheus enables us to produce graphs of data over time to see how a cluster or service is behaving. + +Prometheus is a strategic piece of infrastructure for us at work, but it is also useful to me at home. Luckily, it's not only powerful and useful but also easy to set up in a home environment, with or without Kubernetes, OpenShift, containers, etc. This article shows you how to build a Prometheus container image and set up the Prometheus Node Exporter to collect data from home computers. It also explains some basic PromQL, the query language Prometheus uses to return data and create graphs. + +### Build a Prometheus container image + +The Prometheus project publishes its own container image, `quay.io/prometheus/prometheus`. However, I enjoy building my own for home projects and prefer to use the [Red Hat Universal Base Image][4] family for my projects. These images are freely available for anyone to use. I prefer the [Universal Base Image 8 Minimal][5] (ubi8-minimal) image based on Red Hat Enterprise Linux 8. The ubi8-minimal image is a smaller version of the normal ubi8 images. It is larger than the official Prometheus container image's ultra-sparse Busybox image, but since I use the Universal Base Image for other projects, that layer is a wash in terms of disk space for me. (If two images use the same layer, that layer is shared between them and doesn't use any additional disk space after the first image.) + +My Containerfile for this project is split into a [multi-stage build][6]. The first, `builder`, installs a few tools via DNF packages to make it easier to download and extract a Prometheus release from GitHub, then downloads a specific release for whatever architecture I need (either ARM64 for my [Raspberry Pi Kubernetes cluster][7] or AMD64 for running locally on my laptop), and extracts it: + + +``` +# The first stage build, downloading Prometheus from Github and extracting it + +FROM registry.access.redhat.com/ubi8/ubi-minimal as builder +LABEL maintainer "Chris Collins <[collins.christopher@gmail.com][8]>" + +# Install packages needed to download and extract the Prometheus release +RUN microdnf install -y gzip jq tar + +# Replace the ARCH for different architecture versions, eg: "linux-arm64.tar.tz" +ENV PROMETHEUS_ARCH="linux-amd64.tar.gz" + +# Replace "tag/<tag_name>" with "latest" to build whatever the latest tag is at the time +ENV PROMETHEUS_VERSION="tags/v2.27.0" +ENV PROMETHEUS="" + +# The checksum file for the Prometheus project is "sha256sums.txt" +ENV SUMFILE="sha256sums.txt" + +RUN mkdir /prometheus +WORKDIR /prometheus + +# Download the checksum +RUN /bin/sh -c "curl -sSLf $(curl -sSLf ${PROMETHEUS} -o - | jq -r '.assets[] | select(.name|test(env.SUMFILE)) | .browser_download_url') -o ${SUMFILE}" + +# Download the binary tarball +RUN /bin/sh -c "curl -sSLf -O $(curl -sSLf ${PROMETHEUS} -o - | jq -r '.assets[] | select(.name|test(env.PROMETHEUS_ARCH)) |.browser_download_url')" + +# Check the binary and checksum match +RUN sha256sum --check --ignore-missing ${SUMFILE} + +# Extract the tarball +RUN tar --extract --gunzip --no-same-owner --strip-components=1 --directory /prometheus --file *.tar.gz +``` + +The second stage of the multi-stage build copies the extracted Prometheus files to a pristine ubi8-minimal image (there's no need for the extra tools from the first image to take up space in the final image) and links the binaries into the `$PATH`: + + +``` +# The second build stage, creating the final image +FROM registry.access.redhat.com/ubi8/ubi-minimal +LABEL maintainer "Chris Collins <[collins.christopher@gmail.com][8]>" + +# Get the binary from the builder image +COPY --from=builder /prometheus /prometheus + +WORKDIR /prometheus + +# Link the binary files into the $PATH +RUN ln prometheus /bin/ +RUN ln promtool /bin/ + +# Validate prometheus binary +RUN prometheus --version + +# Add dynamic target (file_sd_config) support to the prometheus config +# +RUN echo -e "\n\ +  - job_name: 'dynamic'\n\ +    file_sd_configs:\n\ +    - files:\n\ +      - data/sd_config*.yaml\n\ +      - data/sd_config*.json\n\ +      refresh_interval: 30s\ +" >> prometheus.yml + +EXPOSE 9090 +VOLUME ["/prometheus/data"] + +ENTRYPOINT ["prometheus"] +CMD ["--config.file=prometheus.yml"] +``` + +Build the image: + + +``` +# Build the Prometheus image from the Containerfile +podman build --format docker -f Containerfile -t prometheus +``` + +I'm using [Podman][9] as my container engine at home, but you can use Docker if you prefer. Just replace the `podman` command with `docker` above. + +After building this image, you're ready to run Prometheus locally and start collecting some metrics. + +### Running Prometheus + + +``` +# This only needs to be done once +# This directory will store the metrics Prometheus collects so they persist between container restarts +mkdir data + +# Run Prometheus locally, using the ./data directory for persistent data storage +# Note that the image name, prometheus:latest, will be whatever image you are using +podman run --mount=type=bind,src=$(pwd)/data,dst=/prometheus/data,relabel=shared --publish=127.0.0.1:9090:9090 --detach prometheus:latest +``` + +The Podman command above runs Prometheus in a container, mounting the Data directory into the container and allowing you to access the Prometheus web interface with a browser only from the machine running the container. If you want to access Prometheus from other hosts, replace `--publish=127.0.0.1:9090:9090` in the command with `--publish=9090:9090`. + +Once the container is running, you should be able to access Prometheus at `http://127.0.0.1:9000/graph`. There is not much to look at yet, though. By default, Prometheus knows only to check itself (the Prometheus service) for metrics related to itself. For example, navigating to the link above and entering a query for `prometheus_http_requests_total` will show how many HTTP requests Prometheus has received (most likely, just those you have made so far). + +![number of HTTP requests Prometheus received][10] + +(Chris Collins, [CC BY-SA 4.0][11]) + +This query can also be referenced as a URL: + + +``` +`http://127.0.0.1:9090/graph?g0.expr=prometheus_http_requests_total&g0.tab=1&g0.stacked=0&g0.range_input=1h` +``` + +Clicking it should take you to the same results. By default, Prometheus scrapes for metrics every 15 seconds, so these metrics will update over time (assuming they have changed since the last scrape). + +You can also graph the data over time by entering a query (as above) and clicking the **Graph** tab. + +![Graphing data over time][12] + +(Chris Collins, [CC BY-SA 4.0][11]) + +Graphs can also be referenced as a URL: + + +``` +`http://127.0.0.1:9090/graph?g0.expr=prometheus_http_requests_total&g0.tab=0&g0.stacked=0&g0.range_input=1h` +``` + +This internal data is not helpful by itself, though. So let's add some useful metrics. + +### Add some data + +Prometheus—the project—publishes a program called [Node Exporter][13] for exporting useful metrics about the computer or node it is running on. You can use Node Exporter to quickly create a metrics target for your local machine, exporting data such as memory utilization and CPU consumption for Prometheus to track. + +In the interest of brevity, just run the `quay.io/prometheus/node-exporter:latest` container image published by the Projetheus project to get started. + +Run the following with Podman or your container engine of choice: + + +``` +`podman run --net="host" --pid="host" --mount=type=bind,src=/,dst=/host,ro=true,bind-propagation=rslave --detach quay.io/prometheus/node-exporter:latest --path.rootfs=/host` +``` + +This will start a Node Exporter on your local machine and begin publishing metrics on port 9100. You can see which metrics are being generated by opening `http://127.0.0.1:9100/metrics` in your browser. It will look similar to this: + + +``` +# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles. +# TYPE go_gc_duration_seconds summary +go_gc_duration_seconds{quantile="0"} 0.000176569 +go_gc_duration_seconds{quantile="0.25"} 0.000176569 +go_gc_duration_seconds{quantile="0.5"} 0.000220407 +go_gc_duration_seconds{quantile="0.75"} 0.000220407 +go_gc_duration_seconds{quantile="1"} 0.000220407 +go_gc_duration_seconds_sum 0.000396976 +go_gc_duration_seconds_count 2 +``` + +Now you just need to tell Prometheus that the data is there. Prometheus uses a set of rules called [scrape_configs][14] that are defined in its configuration file, `prometheus.yml`, to decide what hosts to check for metrics and how often to check them. The scrape_configs can be set statically in the Prometheus config file, but that doesn't make Prometheus very flexible. Every time you add a new target, you would have to update the config file, stop Prometheus manually, and restart it. Prometheus has a better way, called [file-based service discovery][15]. + +In the Containerfile above, there's a stanza adding a dynamic file-based service discovery configuration to the Prometheus config file: + + +``` +RUN echo -e "\n\ +  - job_name: 'dynamic'\n\ +    file_sd_configs:\n\ +    - files:\n\ +      - data/sd_config*.yaml\n\ +      - data/sd_config*.json\n\ +      refresh_interval: 30s\ +" >> prometheus.ym +``` + +This tells Prometheus to look for files named `sd_config*.yaml` or `sd_config*.json` in the Data directory that are mounted into the running container and to check every 30 seconds to see if there are more config files or if they have changed at all. Using files with that naming convention, you can tell Prometheus to start looking for other targets, such as the Node Exporter you started earlier. + +Create a file named `sd_config_01.json` in the Data directory with the following contents, replacing `your_hosts_ip_address` with the IP address of the host running the Node Exporter: + + +``` +`[{"labels": {"job": "node"}, "targets": ["your_hosts_ip_address:9100"]}` +``` + +Check `http://127.0.0.1:9090/targets` in Prometheus; you should see Prometheus monitoring itself (inside the container) and the target you added for the host with the Node Exporter. Click on the link for this new target to see the raw data Prometheus has scraped. It should look familiar: + + +``` +# NOTE: Truncated for brevity +# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles. +# TYPE go_gc_duration_seconds summary +go_gc_duration_seconds{quantile="0"} 3.6547e-05 +go_gc_duration_seconds{quantile="0.25"} 0.000107517 +go_gc_duration_seconds{quantile="0.5"} 0.00017582 +go_gc_duration_seconds{quantile="0.75"} 0.000503352 +go_gc_duration_seconds{quantile="1"} 0.008072206 +go_gc_duration_seconds_sum 0.029700021 +go_gc_duration_seconds_count 55 +``` + +This is the same data the Node Exporter is exporting: + + +``` +`http://127.0.0.1:9090/graph?g0.expr=rate(node_network_receive_bytes_total%7B%7D%5B5m%5D)&g0.tab=0&g0.stacked=0&g0.range_input=15m` +``` + +With this information, you can create your own rules and instrument your own applications to provide metrics for Prometheus to consume. + +### A light introduction to PromQL + +PromQL is Prometheus' query language and a powerful way to aggregate the time-series data stored in Prometheus. Prometheus shows you the output of a query as the raw result, or it can be displayed as a graph showing the trend of the data over time, like the `node_network_receive_bytes_total` example above. PromQL can be daunting to get into, and this article will not dive into a full tutorial on how to use it, but I will cover some basics. + +To get started, pull up the query interface for Prometheus: + + +``` +`http://127.0.0.1:9090/graph` +``` + +Look at the `node_network_receive_bytes_total` metrics in this example. Enter that string into the query field, and press Enter to display all the collected network metrics from the computer on which the Node Exporter is running. (Note that Prometheus provides an autocomplete feature, making it easy to explore the metrics it collects.) You may see several results, each with labels that have been applied to the data sent by the Node Exporter: + +![Network data received][16] + +(Chris Collins, [CC BY-SA 4.0][11]) + +Looking at the image above, you can see eight interfaces, each labeled by the device name (e.g., `{device="ensp12s0u1"}`), the instance they were collected from (in this case, all the same node), and the job node that was assigned in the `sd_config_01.json`. To the right of these is the latest raw metric data for this device. In the case of the `ensp12s0u1` device, it's received `4007938272` bytes of data over the interface since Prometheus started tracking the data. + +Note: The "job" label is useful in defining what kind of data is being collected. For example, "node" for metrics sent by the Node Exporter, or "cluster" for Kubernetes cluster data, or perhaps an application name for a specific service you may be monitoring. + +Click on the **Graph** tab, and you can see the metrics for these devices graphed over time (one hour by default). The time period can be adjusted using the `- +` toggle on the left. Historical data is displayed and graphed along with the current value. This provides valuable insight into how the data changes over time: + +![Graph of data changing over time][17] + +(Chris Collins, [CC BY-SA 4.0][11]) + +You can further refine the displayed data using the labels. This graph displays all the interfaces reported by the Node Exporter, but what if you are interested just in the wireless device? By changing the query to include the label `node_network_receive_bytes_total{device="wlp2s0"}`, you can evaluate just the data matching that label. Prometheus automatically adjusts the scale to a more human-readable one after the other devices' data is removed: + +![Graph of network data for one label][18] + +(Chris Collins, [CC BY-SA 4.0][11]) + +This data is helpful in itself, but Prometheus' PromQL also has several query functions that can be applied to the data to provide more information. For example, look again at the `rate()` function. The `rate()` function "calculates the per-second average rate of increase of the time series in the range vector." That's a fancy way of saying "shows how quickly the data grew." + +Looking at the graph for the wireless device above, you can see a slight curve—a slightly more vertical increase—in the line graph right around 19:00 hours. It doesn't look like much on its own but, using the `rate()` function, it is possible to calculate just how much larger the growth spike was around that timeframe. Using the query `rate(node_network_receive_bytes_total{device="wlp2s0"}[15m])` shows the rate that the received bytes increased for the wireless device, averaged per second over a 15-minute period: + +![Graph showing rate data increased][19] + +(Chris Collins, [CC BY-SA 4.0][11]) + +It is much more evident that around 19:00 hours, the wireless device received almost three times as much traffic for a brief period. + +PromQL can do much more than this. Using the `predict_linear()` function, Prometheus can make an educated guess about when a certain threshold will be crossed. Using the same wireless `network_receive_bytes` data, you can predict where the value will be over the next four hours based on the data from the previous four hours (or any combination you might be interested in). Try querying `predict_linear(node_network_receive_bytes_total{device="wlp2s0"}[4h], 4 * 3600)`. + +The important bit of the `predict_linear()` function above is `[4h], 4 * 3600`. The `[4h]` tells Prometheus to use the past four hours as a dataset and then to predict where the value will be over the next four hours (or `4 * 3600` since there are 3,600 seconds in an hour). Using the example above, Prometheus predicts that the wireless device will have received almost 95MB of data about an hour from now (your data will vary): + +![Graph showing predicted data that will be received][20] + +(Chris Collins, [CC BY-SA 4.0][11]) + +You can start to see how this might be useful, especially in an operations capacity. Kubernetes exports node disk usage metrics and includes a built-in alert using `predict_linear()` to estimate when a disk might run out of space. You can use all of these queries in conjunction with Prometheus' Alertmanager to notify you when various conditions are met—from network utilization being too high to disk space _probably_ running out in the next four hours and more. Alertmanager is another useful topic that I'll cover in a future article. + +### Conclusion + +Prometheus consumes metrics by scraping endpoints for specially formatted data. Data is tracked and can be queried for point-in-time info or graphed to show changes over time. Even better, Prometheus supports, out of the box, alerting rules that can hook in with your infrastructure in a variety of ways. Prometheus can also be used as a data source for other projects, like Grafana, to provide more sophisticated graphing information. + +In the real world at work, we use Prometheus to track metrics and provide alert thresholds that page us when clusters are unhealthy, and we use Grafana to make dashboards of data we need to view regularly. We export node data to track our nodes and instrument our operators to track their performance and health. Prometheus is the backbone of all of it. + +If you have been interested in Prometheus, keep your eyes peeled for follow-up articles. You'll learn about alerting when certain conditions are met, using Prometheus' built-in Alertmanager and integrations with it, more complicated PromQL, and how to instrument your own application and integrate it with Prometheus. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/run-prometheus-home-container + +作者:[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/LIFE_wavegraph.png?itok=z4pXCf_c (A graph of a wave.) +[2]: https://prometheus.io/ +[3]: https://grafana.com/ +[4]: https://www.redhat.com/en/blog/introducing-red-hat-universal-base-image +[5]: https://catalog.redhat.com/software/containers/ubi8/ubi-minimal/5c359a62bed8bd75a2c3fba8 +[6]: https://docs.docker.com/develop/develop-images/multistage-build/ +[7]: https://opensource.com/article/20/6/kubernetes-raspberry-pi +[8]: mailto:collins.christopher@gmail.com +[9]: https://docs.podman.io/en/latest/Introduction.html +[10]: https://opensource.com/sites/default/files/uploads/prometheus_http_requests_total_query.png (number of HTTP requests Prometheus received) +[11]: https://creativecommons.org/licenses/by-sa/4.0/ +[12]: https://opensource.com/sites/default/files/uploads/prometheus_http_requests_total.png (Graphing data over time) +[13]: https://prometheus.io/docs/guides/node-exporter/ +[14]: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config +[15]: https://prometheus.io/docs/guides/file-sd/ +[16]: https://opensource.com/sites/default/files/uploads/node_network_receive_bytes_total.png (Network data received) +[17]: https://opensource.com/sites/default/files/uploads/node_network_receive_bytes_total_graph_1.png (Graph of data changing over time) +[18]: https://opensource.com/sites/default/files/uploads/node_network_receive_bytes_total_wireless_graph.png (Graph of network data for one label) +[19]: https://opensource.com/sites/default/files/uploads/rate_network_receive_bytes_total_wireless_graph.png (Graph showing rate data increased) +[20]: https://opensource.com/sites/default/files/uploads/predict_linear_node_network_receive_bytes_total_wireless_graph.png (Graph showing predicted data that will be received) diff --git a/sources/tech/20210705 How I avoid breaking functionality when modifying legacy code.md b/sources/tech/20210705 How I avoid breaking functionality when modifying legacy code.md new file mode 100644 index 0000000000..a84b4e751d --- /dev/null +++ b/sources/tech/20210705 How I avoid breaking functionality when modifying legacy code.md @@ -0,0 +1,116 @@ +[#]: subject: (How I avoid breaking functionality when modifying legacy code) +[#]: via: (https://opensource.com/article/21/7/legacy-code) +[#]: author: (Alex Bunardzic https://opensource.com/users/alex-bunardzic) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +How I avoid breaking functionality when modifying legacy code +====== +Extract methods give the biggest bang for the buck when it comes to +modifying legacy code while avoiding the risk of breaking the +functionality. +![Coding on a computer][1] + +Allow me a bit of introspection. I've been working in the software engineering field for 31 years. During those 31 years, I've modified a lot of legacy software. + +Over time, I've formed certain habits when working with legacy code. Because on most projects I get paid to deliver working software that is easy to maintain, I cannot afford the luxury of taking my sweet time trying to fully understand the legacy code I am about to modify. So, I tend to skim. Skimming the code helps me quickly identify relevant portions in the repo. It is a race against time, and I don't have cycles at my disposal to dwell on less-relevant minutia. I'm always going for the most relevant area in the code. Once I find it, I slow down and start analyzing it. + +I rely heavily on my power tools—integrated development environments (IDEs). It doesn't matter which power tool; these days, they're all pretty much capable of doing the same thing. What's important to me is having the ability to quickly find where functions are called and where variables are used. + +Sooner or later, after I'm done skimming the code and analyzing the code segment I intend to change, I identify a place where I want to insert some code. Now that I understand the meaning of the classes, components, and objects involved in performing the function, I write a test first. + +After that, I write code to make the test pass. I type the name of the object I intend to use and then press the dot key (**.**) and the IDE responds by giving me a full list of methods defined for that object. All those methods are callable from the location where my cursor is. + +I then pick the method that makes sense to me. I fill in the blanks (that is, I supply values for the expected arguments/parameters), save the change, and run the test. If the test passes, I'm done with that micro change. + +I typically repeat this activity many times per hour. Throughout the workday, it is not unusual to see it repeated dozens, even hundreds of times. + +I believe the way I modify software is not unique to my work habits. I think it describes a typical flow that many (I'd even say most) software engineers adhere to. + +### A few observations + +The first thing apparent in this way of modifying legacy software is the absence of any work on documentation. Experience shows that software developers very rarely spend time reaching out for documentation. Time spent preparing the documentation and generating it to produce HTML-style online documents is often wasted. + +Instead, most developers rely solely upon power tools. And rightly so—IDEs never lie, as they always offer the real-time picture of the system they are modifying, and documentation is usually stale. + +Another thing is that developers don't read the source code the way it was written. When writing code from scratch (first pass), many developers tend to write long functions. Source code tends to bunch up. Bunching code up makes it easier to read and reason about on the first pass and debug. But after the first pass, people rarely, if ever, consume the code the way it was written. If we catch ourselves reading a whole function from beginning to end, it is most likely because we have exhausted all other options and have no choice but to slow down and read the code in a pedestrian way. However, in my experience, that slow and orderly reading of the code seldom happens. + +### Problems caused by bunched-up code + +If you were to leave the code as it was written during the first pass (i.e., long functions, a lot of bunched-up code for easy initial understanding and debugging), it would render IDEs powerless. If you cram all capabilities an object can offer into a single, giant function, later, when you're trying to utilize that object, IDEs will be of no help. IDEs will show the existence of one method (which will probably contain a large list of parameters providing values that enforce the branching logic inside that method). So, you won't know how to really use that object unless you open its source code and read its processing logic very carefully. And even then, your head will probably hurt. + +Another problem with hastily cobbled-up, "bunched-up" code is that its processing logic is not testable. While you can still write an end-to-end test for that code (input values and the expected output values), you have no way of knowing if the bunched-up code is doing any other potentially risky processing. Also, you have no way of testing for edge cases, unusual scenarios, difficult-to-reproduce scenarios, etc. That renders your code untestable, which is a very bad thing to live with. + +### Break up bunched-up code by extracting methods + +Long functions or methods are always a sign of muddled thinking. When a block of code contains numerous statements, it usually means it is doing way too much processing. Cramming a lot of processing in one place typically means the developer hasn't carefully thought things through. + +You don't need to look further than into how companies are typically organized. Instead of having hundreds of employees working in a single department, companies tend to break up into numerous smaller departments. That way, it is much clearer where responsibilities lie. + +Software code is no different. An application exists to automate a lot of intricate processing. Processing gets broken into multiple smaller steps, so each step must be mapped onto a separate, isolated block of code. You create such separate, isolated, and autonomous blocks of code by extracting methods. You take a long, bulky block of code and break it up by extracting responsibilities into separate blocks of code. + +### Extracted methods enable better naming + +Developers write software code, but it is much more often consumed (i.e., read) by developers than written. + +When consuming software code, it helps if the code is expressive. Expressiveness boils down to proper structure and proper naming. Consider the following statement: + + +``` +`if((x && !y) && !b) || (b && y) && !(z >= 65))` +``` + +It would be literally impossible to understand the meaning and the intention of this statement without running the code and stepping through it with a debugger. Such activity is called GAK (Geek at Keyboard). It is 100% unproductive and quite wasteful. + +Here is where the extract method and proper naming practices come to the rescue. Take the complex statement contained within the `if` statement, extract it into its own method, and give that method a meaningful name. For example: + + +``` +public bool IsEligible(bool b, bool x, bool y, int z) { +  return ((x && !y) && !b) || (b && y) && !(z >= 65); +} +``` + +Now replace the ugly `if` statement with a more readable statement: + + +``` +`if(IsEligible(b, x, y, z))` +``` + +Of course, you should also replace dumb one-character variable names with more meaningful names to improve readability. + +### Reusing legacy code + +Experience shows that any functionality that is not extracted and properly named and moved to the most reasonable class will never be reused. The extract method fosters frequent reuse, which goes a long way toward improving code quality. + +### Testing legacy code + +Writing tests for existing code is hard and feels less rewarding than doing [test-driven development][2] (TDD). Even after you determine that there should be several tests to ensure production code works as expected, when you realize production code must be changed to enable testing, you often decide to skip writing tests. In such situations, achieving your goal to deliver testable code, slowly but surely, keeps diminishing. + +Writing tests for legacy code is tedious because it often requires a lot of time and code to set up the preconditions. That's the opposite of how you write tests when doing TDD, where time spent writing preconditions is minimal. + +The best way to make legacy code testable is to practice the extract method approach. Locating a block of code nested in loops and conditionals and extracting it enables you to write small, precise tests. Such tests on extracted functions improve not only the testability of the code but also the understandability. If legacy code becomes more understandable thanks to extracting methods and writing legible tests, the chance of introducing defects is drastically reduced. + +### Conclusion + +Most of the discussion about extracting methods would not be necessary with TDD. Writing one test first, then making the test pass, then scanning that code for more insights into how the code should be structured and improved, making improvements, and finally making changes to part of the code base guarantees there will be no need to worry about extracting methods. Since legacy code usually means code that was not crafted with TDD methodology, you are forced to adopt a different approach. In my experience, extract methods give the biggest bang for the buck when it comes to modifying legacy code while avoiding the risk of breaking the functionality. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/legacy-code + +作者:[Alex Bunardzic][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/alex-bunardzic +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: https://opensource.com/article/20/1/test-driven-development diff --git a/sources/tech/20210705 Things to do after installing Fedora 34 Workstation.md b/sources/tech/20210705 Things to do after installing Fedora 34 Workstation.md new file mode 100644 index 0000000000..26240956dc --- /dev/null +++ b/sources/tech/20210705 Things to do after installing Fedora 34 Workstation.md @@ -0,0 +1,168 @@ +[#]: subject: (Things to do after installing Fedora 34 Workstation) +[#]: via: (https://fedoramagazine.org/things-to-do-after-installing-fedora-34-workstation/) +[#]: author: (Arman Arisman https://fedoramagazine.org/author/armanwu/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Things to do after installing Fedora 34 Workstation +====== + +![][1] + +Using a new operating system can be a lot of fun. But it often becomes confusing when we first use it, especially for new users who are not very familiar with computer systems. For those of you who are using Fedora for the first time and have successfully installed Fedora 34 Workstation, this article can be an initial guide. I’m sure that you want to feel more at home with your new fresh Fedora. These are several things to do after installing your Fedora 34 Workstation. + +### System update + +Maybe you think that you have installed the most recent version of Fedora 34 Workstation, so your Fedora should be up to date. But you still have to make sure that your Fedora Linux has all the updated packages. Because in every new release of an operating system, usually there are still many things that continue to be improved. You can use the terminal or GNOME software to run the update. + +If you want to update via the terminal, then you just have to open a terminal and type the following command. + +``` +$ sudo dnf update +``` + +But if you want to do it with GNOME _Software_, open the application by selecting _Activities_ then locating and selecting the _Software_ item in the taskbar at the bottom of the screen. When it opens select the _Update_s tab at the top. After that you just click the _Download_ button. An update may require a restart afterwards and _Update_ will tell you that. + +![GNOME Software location in the taskbar at the bottom of the screen][2] + +_note: another way to select Activities is to press the super key on the keyboard. Super key is the button that has the Windows logo on most keyboards._ + +![Gnome Software showing Updates][3] + +### System settings + +You can view and configure your device’s system through _System Settings_. These include items like network, keyboard, mouse, sound, displays, etc. You can run it by pressing the _super_ key on your keyboard, clicking _Show Applications_ in the task bar at the bottom of the window, then selecting _Settings_. Configure it according to your needs. + +![Settings menu showing Network selected][4] + +### Additional repositories + +Maybe some packages you need are not available to be installed from the official Fedora Repository. You can add software repositories with the _dnf config-manager_ command. Please be careful if you want to add other repositories besides the official Fedora repository. + +The first thing you should do is define a new repository by adding a new file ending in _.repo_ to the _/etc/yum.repos.d/_ directory. Run the following command in the terminal. + +``` +$ sudo dnf config-manager --add-repo /etc/yum.repos.d/file_name.repo +``` + +_note: replace file_name with the repository file name._ + +Or you can use GNOME _Software_. Open it as described in the System Update section above. Now select the “hamburger” icon (three horizontal lines) on the top right and select _Software Repositories_. You can add the repository from there using the _Install_ option. + +![GNOME Software showing location of Software Repositories menu][5] + +Most people will enable RPM Fusion. It’s a third party repository. You can read about third party repositories in [Fedora Docs][6]. + +### Fastest mirror and Delta RPM + +There are several things you can do to speed up your download times when using DNF to update your system. You can enable Fastest Mirror and Delta RPM. Edit _/etc/dnf/dnf.conf_ using a text editor, such as gedit or nano. Here’s the example to open _dnf.conf_ file with _nano_ in _terminal_. + +``` +$ sudo nano /etc/dnf/dnf.conf +``` + +Append the following line onto your _dnf.conf_ file. + +``` +fastestmirror=true +deltarpm=true +``` + +Press _ctrl+o_ to save the file then _ctrl+x_ to quit from _nano_. + +### Multimedia plugins for audio and video + +You may need some plugins for your multimedia needs. You can install multimedia plugins by running this command in a terminal. + +``` +$ sudo dnf group upgrade --with-optional Multimedia +``` + +Please pay attention to the regulations and standards in your country regarding multimedia codecs. You can read about this in [Fedora Docs][7]. + +### Tweaks and Extentions + +Fedora 34 Workstation comes with GNOME as the default Desktop Environment. We can do various configurations of GNOME by using Tweaks and Extensions, like changing themes, changing buttons in the window dialog, and many more. + +Open your terminal and run this command to install GNOME Tweaks. + +``` +$ sudo dnf install gnome-tweaks +``` + +And run this command to install GNOME Extensions. + +``` +$ sudo dnf install gnome-extensions-app +``` + +Do the same way as above when you search for _GNOME Software_. Select _Activities_ or press the _super_ key then select _Show Applications_ to see a list of installed applications. You can find both applications in the list. You can do the same thing every time you want to search for installed applications. Then do the configuration with your preferences with _Tweaks_ and _Extensions_. + +![GNOME Tweaks][8] + +![GNOME Extensions][9] + +### Install applications + +When you first install Fedora, you will find several installed apps. You can add other applications according to your needs with GNOME Software. Do the same way to open GNOME Software as described earlier. Then find the application you want, select the application, and then press the Install button. + +![GNOME Software][10] + +Or you can do it with terminal. Here are the commands to find and install the application. + +Command to search for available applications: + +``` +$ sudo dnf search application_name +``` + +The command to install the application: + +``` +$ sudo dnf install application_name +``` + +Commands to remove installed applications: + +``` +$ sudo dnf remove application_name +``` + +_note: replace application_name with the name of the application._ + +You can search for installed applications by viewing them in _Show Applications_. Select _Activities_ or press the _super_ key and select _Show Applications_. Then you can select the application you want to run from the list. + +![Installed application list][11] + +### Conclusion + +Fedora Workstation is an easy-to-use and customizable operating system. There are many things you can do after installing Fedora 34 Workstation according to your needs. This article is just a basic guide for your first steps before you have more fun with your Fedora Linux system. You can read [Fedora Docs][12] for more detailed information. I hope you enjoy using Fedora Linux. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/things-to-do-after-installing-fedora-34-workstation/ + +作者:[Arman Arisman][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/armanwu/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2021/07/FedoraMagz-Cover_ThingsToDo.png +[2]: https://fedoramagazine.org/wp-content/uploads/2021/07/GNOME_Software_location-1024x576.png +[3]: https://fedoramagazine.org/wp-content/uploads/2021/07/Software_Updates-1024x735.png +[4]: https://fedoramagazine.org/wp-content/uploads/2021/07/Settings-1024x764.png +[5]: https://fedoramagazine.org/wp-content/uploads/2021/07/Software_Hamburger_-1-1024x685.png +[6]: https://docs.fedoraproject.org/en-US/quick-docs/setup_rpmfusion/ +[7]: https://docs.fedoraproject.org/en-US/quick-docs/assembly_installing-plugins-for-playing-movies-and-music/ +[8]: https://fedoramagazine.org/wp-content/uploads/2021/07/Tweaks-1024x733.png +[9]: https://fedoramagazine.org/wp-content/uploads/2021/07/GNOME_Extensions.png +[10]: https://fedoramagazine.org/wp-content/uploads/2021/07/GNOME_Software-1-1024x687.png +[11]: https://fedoramagazine.org/wp-content/uploads/2021/07/Show_Application-1024x576.png +[12]: https://docs.fedoraproject.org/en-US/fedora/f34/ diff --git a/sources/tech/20210706 Element- A Cross-Platform Decentralized Open-Source Messaging App.md b/sources/tech/20210706 Element- A Cross-Platform Decentralized Open-Source Messaging App.md new file mode 100644 index 0000000000..31709b65dd --- /dev/null +++ b/sources/tech/20210706 Element- A Cross-Platform Decentralized Open-Source Messaging App.md @@ -0,0 +1,158 @@ +[#]: subject: (Element: A Cross-Platform Decentralized Open-Source Messaging App) +[#]: via: (https://itsfoss.com/element/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Element: A Cross-Platform Decentralized Open-Source Messaging App +====== + +There are many open-source messaging applications available, especially if you are looking for [WhatsApp replacements][1] on both desktop and mobile. + +Element is one of them, which is a decentralized alternative for private messaging that you can use to interact with individuals, communities, or businesses. + +### Element: Privacy-Friendly Open-Source Messenger Built on Matrix Network + +![][2] + +Matrix is an open standard for secure and decentralized communication. And Element is the messaging client that uses that. + +Element is also a part of the Matrix.org Foundation — so you will find most of the same team responsible for this. + +Originally, it was known as [Riot][3], which we covered back then. But, after the [rebranding][4], it is now known as “Element”, which comes with an improved user experience and constantly focusing on making decentralized communication common for instant messaging. + +![][5] + +Element is not just another open-source messenger, it gives you the ability to do a lot of things. + +Here, let me highlight some of the key features along with some details about it that follows as you read on. + +### Features of Element + +![][6] + +Element is more of an all-in-one messenger than a replacement of something. You could choose it as an [open-source alternative to Slack][7] or a private alternative to any instant messenger like Telegram. + +Some of the options that you get with it are: + + * End-to-End encryption chat room + * Public communities (may not be encrypted) + * Direct voice call + * Conference call in the community + * Meet Jitsi integration (one of the [open-source alternatives to Zoom][8]) + * File sharing + * Emoji and Sticker support + * Moderation tools for managing communities + * Extensive anti-spam options + * Ability to bridge other services like Slack, Discord, IRC, and more + * Offers paid managed hosting to have control over your data + * Cross-signed device verification for message privacy/security + * Fine grained notification settings + * Email notifications + * Ability to restore using encryption keys + * Make yourself discoverable to the entire Matrix network using your email or number + + + +The features offered by Element may sound to be overwhelming for a user who just wants private messaging. + +But fortunately, all those features do not get in the way unless you explicitly access/configure them. So that’s a good thing. + +First, let me address the installation instructions for Linux and I’ll give you some insights on how my experience with Element was (on both Linux desktop and Android). + +### Installing Element in Linux + +Element officially supports Debian/Ubuntu for installation. You can just add the package repository and install element. + +The commands used for this is: + +``` +sudo apt install -y wget apt-transport-https + +sudo wget -O /usr/share/keyrings/riot-im-archive-keyring.gpg https://packages.riot.im/debian/riot-im-archive-keyring.gpg + +echo "deb [signed-by=/usr/share/keyrings/riot-im-archive-keyring.gpg] https://packages.riot.im/debian/ default main" | sudo tee /etc/apt/sources.list.d/riot-im.list + +sudo apt update + +sudo apt install element-desktop +``` + +Do note that they are still using Riot.im domain to host packages even after rebranding — so not to be confused with the older Riot messaging app. + +You can also find it in AUR for Arch-based distros — but I’m not quite sure about how well it works. + +Unfortunately, there’s no [Flatpak][9] or [Snap][10] package available. So, if you are using a distribution that isn’t officially supported by Element, the best place to explore solutions/raise issues will be their [GitHub page][11]. + +Now, before you get started using it, let me give you some heads up with my thoughts on it. + +### Element on Linux and Android: Here’s What You Need to Know + +To start with — the user experience is fantastic on both Android and desktop. I tried it on Linux Mint, and it worked flawlessly. + +You do not need a mobile number to sign up. Just create a username and add an email account to it, and you’re done. + +![][12] + +One can opt for a paid homeserver (your own matrix network) or just join the free Matrix homeserver offered. + +**Keep in mind,** if you are signing up for free, you may not get to experience all the features — like the ability to see who’s online. You can only do that with your own server, the free Matrix server restricts certain functionalities like that to be able to accommodate an unlimited number of free users. + +When signing in to a mobile device, you will have to verify the session by scanning a QR code prompted on Element’s desktop app. + +Once done, you can explore and join public communities available or create your own. + +Most of the existing public communities do not have end-to-end encryption enabled. So make sure you know what you are doing before messaging in any of the public communities. + +While Element supports bridging IRC, Slack, and others or adding bots to a community — it is just not supported for an encrypted community. So, you need to have an unencrypted community to be able to use bots and bridges. + +![][13] + +A **word of caution**: + +Element is getting popular, and scammers/spammers are attracted to the platform because it does not need any valuable personal information to get started. + +So **make sure that you do not trust anyone and keep your identity safe** by not using your real profile picture or work email, especially if you are joining the public communities. + +Element is constantly improving and offers plenty of features for several use-cases. I don’t see a problem with it being an open-source Discord replacement as well (in some way). + +I was impressed with the level of notification controls that it gives and an added email notification option (which is enabled by default). You can choose to have notifications based on the keywords that you find interesting, what an exciting feature to have! + +![][14] + +Overall, Element may not be the perfect replacement for everything you use right now but it is shaping up to be an all-in-one alternative to many proprietary options. + +I’ve had a good experience with Element so far and I’m confident about its future. What do you think? Willing to try Element on Linux? + +Feel free to let me know your thoughts on this. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/element/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/private-whatsapp-alternatives/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/element-io.png?resize=800%2C531&ssl=1 +[3]: https://itsfoss.com/riot-desktop/ +[4]: https://itsfoss.com/riot-to-element/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/element-ui.png?resize=800%2C602&ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/element-settings.png?resize=800%2C673&ssl=1 +[7]: https://itsfoss.com/open-source-slack-alternative/ +[8]: https://itsfoss.com/open-source-video-conferencing-tools/ +[9]: https://itsfoss.com/what-is-flatpak/ +[10]: https://itsfoss.com/install-snap-linux/ +[11]: https://github.com/vector-im +[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/element-sign-in.png?resize=800%2C581&ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/element-bridge-bots.png?resize=800%2C517&ssl=1 +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/element-notifications.png?resize=800%2C547&ssl=1 diff --git a/sources/tech/20210706 How to Install Fedora 34 Workstation -Step by Step.md b/sources/tech/20210706 How to Install Fedora 34 Workstation -Step by Step.md new file mode 100644 index 0000000000..5ea4a8a2d4 --- /dev/null +++ b/sources/tech/20210706 How to Install Fedora 34 Workstation -Step by Step.md @@ -0,0 +1,151 @@ +[#]: subject: (How to Install Fedora 34 Workstation [Step by Step]) +[#]: via: (https://www.debugpoint.com/2021/07/install-fedora-34-workstation/) +[#]: author: (Arindam https://www.debugpoint.com/author/admin1/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +How to Install Fedora 34 Workstation [Step by Step] +====== +In this absolute beginner’s guide, we explain the steps required to +install Fedora 34 workstation edition (GNOME desktop environment). +This page covers the following topics + + * [Fedora 34 Minimum system requirements][1] + * [Pre-Steps before installation][2] + * [Download and create LIVE USB][3] + * [Install Fedora 34][4] + + + +[Fedora][5] is a Linux based distribution which offers desktop and server flavors. It is a free and open-source Linux distribution sponsored by Red Hat and developed and contributed by the community. It works as an upstream distribution for Red Hat Enterprise Linux. Hence, with Fedora you get the latest Linux Kernel, packages with cutting edge features and applications. + +Fedora desktop edition offers almost all popular desktop environments. A quick list of desktop environment is below which has official Fedora flavor. + + * KDE Plasma + * GNOME + * Xfce + * LXDE + * LXQt + * i3 WM + * MATE + * Cinnamon (via repo) + + + +This is why it is very popular, and many users choose Fedora to Ubuntu because you get a perfect system with many packages pre-installed. Mostly experienced users prefer Fedora, but it is absolutely useful for beginner’s as well. If you are an Ubuntu user and want to jump the ship to Fedora, well, you may want to check out our [Ubuntu to Fedora migration guide][6]. + +The Fedora 34 which we are going to install in this post brings some interesting changes. Fedora 34 brings Linux Kernel 5.11, Zstd compression when btrfs is used, default sound daemon Pipewire, GNOME 40 desktop, KDE Plasma 5.21 and many Wayland related updates. For a detailed coverage, visit our [Fedora 34 topics][7] to learn more. + +### Fedora 34 workstation – System requirement + +This is the minimum system requirement for installing Fedora in general. + + * 2 GHz dual-core processor + * 4 GiB RAM (system memory) + * 20 GB of hard-drive space + * VGA capable of 1024×768 screen resolution + * Either a CD/DVD drive or a USB port for the installer media + * Internet access is not mandatory for installation + + + +### Pre-Step Before Installation + +Before you start the installation, make sure of the followings. + + * If you are installing in a physical system, make sure to decide which partition you want to install. + * If you are planning to dual boot with Windows or any other Linux Systems, then make sure you decide which partition to install. + * Take a backup of your personal data. + * Keep a LIVE USB with [Boot Repair][8] handy, in case something goes wrong. + + + +[][9] + +SEE ALSO:   How to Upgrade to Fedora 34 from Fedora 33 Workstation (GUI and CLI Method) + +### Download and prepare LIVE USB + +Download the Workstation edition from the below link. It contains the torrent of the .ISO file and also includes all other [Fedora 34 Spins][10] as well. + +[fedora torrents][11] + +After the download is complete, create a LIVE USB using any utility such as [Etcher][12]. Plug in the USB in your system, change BIOS settings to boot from it. + +### Install Fedora 34 – Steps + +1\. The LIVE Fedora installation system boot up to a LIVE desktop, that gives you options to install to a Physical medium. + +![Install to Hard Driver Option in LIVE Media][13] + +2\. In the next screen, select language and continue. Then click on the Installation destination to select which partition you would like to install. + +![Select Language][14] + +![Installation Destination Select][15] + +3\. In the installation destination screen, select the disk and choose Storage Configuration: Custom. And click Done at the top. + +![Select Disk][16] + +4\. In the partitioning screen, choose your partition sizes for root, and boot partitions. For example, keep /boot at around 1GB and rest you can assign to /root partition. + +5\. For Fedora 34, it is better to use btrfs for root partition for better performance. Do not forget to set the mount point as / in root partition. + +![root partition][17] + +![boot partition][18] + +6\. When you are satisfied with your new file system, click on Done. In the next screen, make sure to verify carefully the summary of changes that is going to happen to your disk. Because this will make changes to your system and can not be reverted. Click Accept changes once you are ready. + +![Summary of Changes][19] + +7\. Wait for the installation to complete. Once it is finished, click on Finish Installation and reboot the LIVE system. + +![Installation complete][20] + +So, that’s about it. If all goes well, after reboot, you should be greeted with Fedora 34 workstation edition desktop with GNOME 40. + +![Fedora 34 Desktop][21] + +I hope this basic guide to install Fedora 34 helps beginner’s or advanced users for their work. If you run into a problem, such as with dual boot, or any other installation error, let me know in the comment box below. + +* * * + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2021/07/install-fedora-34-workstation/ + +作者:[Arindam][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lujun9972 +[1]: tmp.cwqzC2PPCj#min-requirement +[2]: tmp.cwqzC2PPCj#pre-steps +[3]: tmp.cwqzC2PPCj#download-create-USB +[4]: tmp.cwqzC2PPCj#install-fedora-34 +[5]: https://getfedora.org/ +[6]: https://www.debugpoint.com/2021/04/migrate-to-fedora-from-ubuntu/ +[7]: https://www.debugpoint.com/tag/fedora-34 +[8]: https://sourceforge.net/p/boot-repair/home/Home/ +[9]: https://www.debugpoint.com/2021/04/upgrade-fedora-34-from-fedora-33/ +[10]: https://www.debugpoint.com/2021/04/fedora-34-desktop-spins/ +[11]: https://torrent.fedoraproject.org/ +[12]: https://www.debugpoint.com/2021/01/etcher-bootable-usb-linux/ +[13]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/Install-to-Hard-Driver-Option-in-LIVE-Media.jpeg +[14]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/Select-Language.jpeg +[15]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/Installation-Destination-Select.jpeg +[16]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/Select-Disk.jpeg +[17]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/root-partition-1024x532.jpeg +[18]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/boot-partition.jpeg +[19]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/Summary-of-Changes.jpeg +[20]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/Installation-complete-1024x526.jpeg +[21]: https://www.debugpoint.com/blog/wp-content/uploads/2021/04/Fedora-34-Desktop--1024x529.jpg diff --git a/sources/tech/20210706 Why you need to use Kubernetes schema validation tools.md b/sources/tech/20210706 Why you need to use Kubernetes schema validation tools.md new file mode 100644 index 0000000000..be587490fe --- /dev/null +++ b/sources/tech/20210706 Why you need to use Kubernetes schema validation tools.md @@ -0,0 +1,216 @@ +[#]: subject: (Why you need to use Kubernetes schema validation tools) +[#]: via: (https://opensource.com/article/21/7/kubernetes-schema-validation) +[#]: author: (Eyar Zilberman https://opensource.com/users/eyarz) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Why you need to use Kubernetes schema validation tools +====== +Compare schema validation tools that help you avoid misconfigurations in +your Kubernetes clusters. +![Net catching 1s and 0s or data in the clouds][1] + +How do you ensure the stability of your Kubernetes (K8s) clusters? How do you know that your manifests are syntactically valid? Are you sure you don't have any invalid data types? Are any mandatory fields missing? + +Most often, we become aware of these misconfigurations only at the worst time: when we're trying to deploy the new manifests. + +Specialized tools and a "shift-left" approach make it possible to verify a Kubernetes schema before it's applied to a cluster. This article addresses how you can avoid misconfigurations and which tools are the best to use. + +> ## TL;DR +> +> Running schema validation tests is important, and the sooner the better. If all machines (e.g., local developer environments, continuous integration [CI], etc.) have access to your Kubernetes cluster, run `kubectl --dry-run` in server mode on every code change. If this isn't possible and you want to perform schema validation tests offline, use kubeconform together with a policy-enforcement tool to have optimal validation coverage. + +### Schema-validation tools + +Verifying the state of Kubernetes manifests may seem like a trivial task because the Kubernetes command-line interface (CLI), kubectl, can verify resources before they're applied to a cluster. You can verify the schema by using the [dry-run][2] flag (`--dry-run=client/server`) when specifying the `kubectl create` or `kubectl apply` commands; these will perform the validation without applying Kubernetes resources to the cluster. + +But I can assure you that it's actually more complex. A running Kubernetes cluster must obtain the schema for the set of resources being validated. So, when incorporating manifest verification into a CI process, you must also manage connectivity and credentials to perform the validation. This becomes even more challenging when dealing with multiple microservices in several environments (e.g., prod, dev, etc.). + +[Kubeval][3] and [kubeconform][4] are CLI tools developed to validate Kubernetes manifests without requiring a running Kubernetes environment. Because kubeconform was inspired by kubeval, they operate similarly; verification is performed against pre-generated JSON schemas created from the OpenAPI specifications ([swagger.json][5]) for each Kubernetes version. All that remains [to run][6] the schema validation tests is to point the tool executable to a single manifest, directory or pattern. + +![Kubeval and kubeconform ][7] + +(Eyar Zilberman, [CC BY-SA 4.0][8]) + +### Comparing the tools + +Now that you're aware of the tools available for Kubernetes schema validation, let's compare some core abilities—misconfiguration coverage, speed tests, support for different versions, Custom Resource Definitions support, and docs—in: + + * kubeval + * kubeconform + * kubectl dry-run in client mode + * kubectl dry-run in server mode + + + +#### Misconfiguration coverage + +I donned my QA hat and generated some (basic) Kubernetes manifest files with some [intentional misconfigurations][9] and then ran them against all four tools. + +Misconfig/Tool | + +kubeval / +kubeconform + +| + +kubectl dry-run +in client mode + +| + +kubectl dry-run +in server mode + +---|---|---|--- +[API deprecation][10] | ✅ Caught | ✅ Caught | ✅ Caught +[Invalid kind value][11] | ✅ Caught | ❌ Didn't catch | ✅ Caught +[Invalid label value][12] | ❌ Didn't catch | ❌ Didn't catch | ✅ Caught +[Invalid protocol type][13] | ✅ Caught | ❌ Didn't catch | ✅ Caught +[Invalid spec key][14] | ✅ Caught | ✅ Caught | ✅ Caught +[Missing image][15] | ❌ Didn't catch | ❌ Didn't catch | ✅ Caught +[Wrong K8s indentation][16] | ✅ Caught | ✅ Caught | ✅ Caught + +In summary: all misconfiguration was caught by `kubectl` dry-run in server mode. + +Some misconfigurations were caught by everything: + + * Invalid spec key: Caught successfully by everything! + * API deprecation: Caught successfully by everything! + * Wrong k8s indentation: Caught successfully by everything! + + + +However, some had mixed results: + + * Invalid kind value: Caught by Kubeval / Kubeconform but missed by Kubectl client. + * Invalid protocol type: Caught by Kubeval / Kubeconform but missed by Kubectl client. + * Invalid label value: Missed by both Kubeval / Kubeconform and Kubectl client. + * Missing image: Missed by both Kubeval / Kubeconform and Kubectl client. + + + +Conclusion: Running kubectl dry-run in server mode caught all misconfigurations, while kubeval/kubeconform missed two of them. It's also interesting to see that running kubectl dry-run in client mode is almost useless because it's missing some obvious misconfigurations and also requires a connection to a running Kubernetes environment. + + * All the schemas validation tests were performed against Kubernetes version 1.18.0. + * Because kubeconform is based on kubeval, they provide the same result when run against the files with the misconfigurations. + * kubectl is one tool, but each mode (client or server) produces a different result (as you can see from the table). + + + +#### Benchmark speed test + +I used [hyperfine][17] to benchmark the execution time of each tool. First, I ran it against all the [files with misconfigurations][18] (seven files in total). Then I ran it against [100 Kubernetes files][19] (all the files contain the same config). + +Results for running the tools against seven files with different Kubernetes schema misconfigurations: + +Tool | Mean | Min | Max +---|---|---|--- +kubeconform | 0.2 ms ± 0.3 ms | 0.0 ms | 2.3 ms +kubeval | 1.443 s ± 1.551 s | 0.741 s | 5.842 s +kubectl --dry-run=client | 1.92 s ± 0.035 s | 1.872 s | 2.009 s +kubectl --dry-run=server | 2.288 s ± 0.027 s | 2.241 s | 2.323 s + +Results for running the tools against 100 files with valid Kubernetes schemas: + +Tool | Mean | Min | Max +---|---|---|--- +kubeconform | 0.3 ms ± 0.3 ms | 0.0 ms | 1.9 ms +kubeval | 1.152 s ± 0.197 s | 0.989 s | 1.669 s +kubectl --dry-run=client | 1.274 s ± 0.028 s | 1.234 s | 1.313 s +kubectl --dry-run=server | 60.675 s ± 0.546 s | 60.489 s | 62.228 s + +Conclusion: While kubeconform (#1), kubeval (#2), and kubectl `--dry-run=client` (#3) provide fast results on both tests, kubectl `--dry-run=server` (#4) is slower, especially when it evaluates 100 files. Yet 60 seconds for generating a result is still a good outcome in my opinion. + +#### Kubernetes versions support + +Both kubeval and kubeconform accept the Kubernetes schema version as a flag. Although both tools are similar (as mentioned, kubeconform is based on kubeval), one of the key differences is that each tool relies on its own set of pre-generated JSON schemas: + + * **Kubeval:** [instrumenta/kubernetes-json-schema][20] (last commit: [133f848][21] on April 29, 2020) + * **Kubeconform:** [yannh/kubernetes-json-schema][22] (last commit: [a660f03][23] on May 15, 2021) + + + +As of May 2021, kubeval supports Kubernetes schema versions only up to 1.18.1, while kubeconform supports the latest Kubernetes schema available, 1.21.0. With kubectl, it's a little bit trickier. I don't know which version of kubectl introduced the dry run, but I tried it with Kubernetes version 1.16.0 and it still worked, so I know it's available in Kubernetes versions 1.16.0–1.18.0. + +The variety of supported Kubernetes schemas is especially important if you want to migrate to a new Kubernetes version. With kubeval and kubeconform, you can set the version and start evaluating which configurations must be changed to support the cluster upgrade. + +Conclusion: The fact that kubeconform has all the schemas for all the different Kubernetes versions available—and also doesn't require Minikube setup (as kubectl does)—makes it a superior tool when comparing these capabilities to its alternatives. + +### Other things to consider + +#### Custom Resource Definition (CRD) support + +Both kubectl dry-run and kubeconform support the [CRD][24] resource type, while kubeval does not. According to kubeval's docs, you can pass a flag to kubeval to tell it to ignore missing schemas so that it will not fail when testing a bunch of manifests where only some are resource type CRD. + +#### Documentation + +Kubeval is a more popular project than kubeconform; therefore, its community and [documentation][25] are more extensive. Kubeconform doesn't have official docs, but it does have a [well-written README][26] file that explains its capabilities pretty well. The interesting part is that although Kubernetes-native tools such as kubectl are usually well-documented, it was really hard to find the information needed to understand how the `dry-run` flag works and its limitations. + +Conclusion: Although it's not as famous as kubeval, the CRD support and good-enough documentation make kubeconform the winner, in my opinion. + +### Strategies for validating Kubernetes schema using these tools + +Now that you know the pros and cons of each tool, here are some best practices for leveraging them within your Kubernetes production-scale development flow: + + * ⬅️ Shift-left: When possible, the best setup is to run `kubectl --dry-run=server` on every code change. You probably can't do that because you can't allow every developer or CI machine in your organization to have a connection to your cluster. So, the second-best effort is to run kubeconform. + * 🚔 Because kubeconform doesn't cover all common misconfigurations, it's recommended to run it with a policy enforcement tool on every code change to fill the coverage gap. + * 💸 Buy vs. build: If you enjoy the [engineering overhead][27], then kubeconform + [conftest][28] is a great combination of tools to get good coverage. Alternatively, there are tools that can provide you with an out-of-the-box experience to help you save time and resources, such as [Datree][29] (whose schema validation is powered by kubeconform). + * 🚀 During the CD step, it shouldn't be a problem to connect with your cluster, so you should always run `kubectl --dry-run=server` before deploying your new code changes. + * 👯 Another option for using kubectl dry-run in server mode, without having a connection to your Kubernetes environment, is to run Minikube + `kubectl --dry-run=server`. The downside of this hack is that you must also set up the Minikube cluster like prod (i.e., same volumes, namespace, etc.), or you'll encounter errors when trying to validate your Kubernetes manifests. + + + +_Thank you to_ [_Yann Hamon_][30] _for creating kubeconform—it's awesome! This article wouldn't be possible without you. Thank you for all of your guidance._ + +* * * + +_This article originally appeared on [Datree.io][31] and is reprinted with permission._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/kubernetes-schema-validation + +作者:[Eyar Zilberman][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/eyarz +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_analytics_cloud.png?itok=eE4uIoaB (Net catching 1s and 0s or data in the clouds) +[2]: https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/576-dry-run/README.md +[3]: https://github.com/instrumenta/kubeval/tree/master/kubeval +[4]: https://github.com/yannh/kubeconform +[5]: https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json +[6]: https://github.com/datreeio/kubernetes-schema-validation#running-schema-validation-tests +[7]: https://opensource.com/sites/default/files/uploads/kubeval-and-kubeconform.png (Kubeval and kubeconform ) +[8]: https://creativecommons.org/licenses/by-sa/4.0/ +[9]: https://github.com/datreeio/kubernetes-schema-validation#misconfigs +[10]: https://github.com/datreeio/kubernetes-schema-validation#api-deprecationyaml +[11]: https://github.com/datreeio/kubernetes-schema-validation#invalid-kind-valueyaml +[12]: https://github.com/datreeio/kubernetes-schema-validation#invalid-label-valueyaml +[13]: https://github.com/datreeio/kubernetes-schema-validation#invalid-protocol-typeyaml +[14]: https://github.com/datreeio/kubernetes-schema-validation#invalid-spec-keyyaml +[15]: https://github.com/datreeio/kubernetes-schema-validation#missing-imageyaml +[16]: https://github.com/datreeio/kubernetes-schema-validation#wrong-k8s-indentationyaml +[17]: https://github.com/sharkdp/hyperfine +[18]: https://github.com/datreeio/kubernetes-schema-validation/tree/main/misconfigs +[19]: https://github.com/datreeio/kubernetes-schema-validation/tree/main/benchmark +[20]: https://github.com/instrumenta/kubernetes-json-schema +[21]: https://github.com/instrumenta/kubernetes-json-schema/commit/133f84871ccf6a7a7d422cc40e308ae1c044c2ab +[22]: https://github.com/yannh/kubernetes-json-schema +[23]: https://github.com/yannh/kubernetes-json-schema/commit/a660f03314fad36fb4cbfb4fa2f9a76b7766cf51 +[24]: https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/ +[25]: https://kubeval.instrumenta.dev/ +[26]: https://github.com/yannh/kubeconform/blob/master/Readme.md +[27]: https://jrott.com/posts/why-buy/ +[28]: https://www.conftest.dev/ +[29]: https://hub.datree.io/schema-validation/?utm_source=our_blog&utm_medium=schema-validation +[30]: https://github.com/yannh +[31]: https://www.datree.io/resources/kubernetes-schema-validation diff --git a/sources/tech/20210707 How to Know if Your System Uses MBR or GPT Partitioning -on Windows and Linux.md b/sources/tech/20210707 How to Know if Your System Uses MBR or GPT Partitioning -on Windows and Linux.md new file mode 100644 index 0000000000..5532fd9485 --- /dev/null +++ b/sources/tech/20210707 How to Know if Your System Uses MBR or GPT Partitioning -on Windows and Linux.md @@ -0,0 +1,114 @@ +[#]: subject: (How to Know if Your System Uses MBR or GPT Partitioning [on Windows and Linux]) +[#]: via: (https://itsfoss.com/check-mbr-or-gpt/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +How to Know if Your System Uses MBR or GPT Partitioning [on Windows and Linux] +====== + +Knowing the correct partitioning scheme of your disk could be crucial when you are installing Linux or any other operating system. + +There are two popular partitioning schemes; the older MBR and the newer GPT. Most computers use GPT these days. + +While creating the live or bootable USB, some tools (like [Rufus][1]) ask you the type of disk partitioning in use. If you choose GPT with an MBR disk, the bootable USB might not work. + +In this tutorial, I’ll show various methods to check the disk partitioning scheme on Windows and Linux systems. + +### Check whether your system uses MBR or GPT on Windows systems + +While there are several ways to check the disk partitioning scheme in Windows including command line ones, I’ll stick with the GUI methods. + +Press the Windows button and search for ‘disk’ and then click on “**Create and format disk partitions**“. + +![][2] + +In here, **right-click on the disk** for which you want to check the partitioning scheme. In the right-click context menu, **select Properties**. + +![Right click on the disk and select properties][3] + +In the Properties, go to **Volumes** tab and look for **Partition style**. + +![In Volumes tab, look for Partition style][4] + +As you can see in the screenshot above, the disk is using GPT partitioning scheme. For some other systems, it could show MBR or MSDOS partitioning scheme. + +Now you know how to check disk partitioning scheme in Windows. In the next section, you’ll learn to do the same in Linux. + +### Check whether your system uses MBR or GPT on Linux + +There are several ways to check whether a disk uses MBR or GPT partitioning scheme in Linux as well. This includes commands and GUI tools. + +Let me first show the command line method and then I’ll show a couple of GUI methods. + +#### Check disk partitioning scheme in Linux command line + +The command line method should work on all Linux distributions. + +Open a terminal and use the following command with sudo: + +``` +sudo parted -l +``` + +The above command is actually a CLI-based [partitioning manager in Linux][5]. With the option -l, it lists the disks on your system along with the details about those disks. It includes partitioning scheme information. + +In the output, look for the line starting with **Partition Table**: + +![][6] + +In the above screenshot, the disk has GPT partitioning scheme. For **MBR**, it would show **msdos**. + +You learned the command line way. But if you are not comfortable with the terminal, you can use graphical tools as well. + +#### Checking disk information with GNOME Disks tool + +Ubuntu and many other GNOME-based distributions have a built-in graphical tool called Disks that lets you handle the disks in your system. + +You can use the same tool for getting the partition type of the disk as well. + +![][7] + +#### Checking disk information with Gparted graphical tool + +If you don’t have the option to use GNOME Disks tool, no worries. There are other tools available. + +One such popular tool is Gparted. You should find it in the repositories of most Linux distributions. If not installed already, [install Gparted][8] using your distribution’s software center or [package manager][9]. + +In Gparted, select the disk and from the menu select **View->Device** Information. It will start showing the disk information in the bottom-left area and this information includes the partitioning scheme. + +![][10] + +See, not too complicated, was it? Now you know multiple ways of figuring our whether the disks in your system use GPT or MBR partitioning scheme. + +On the same note, I would also like to mention that sometimes disks also have a [hybrid partitioning scheme][11]. This is not common and most of the time it is either MBR or GPT. + +Questions? Suggestions? Please leave a comment below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/check-mbr-or-gpt/ + +作者:[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://rufus.ie/en_US/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/03/disc-management-windows.png?resize=800%2C561&ssl=1 +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/gpt-check-windows-1.png?resize=800%2C603&ssl=1 +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/gpt-check-windows-2-1.png?resize=800%2C600&ssl=1 +[5]: https://itsfoss.com/partition-managers-linux/ +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/07/check-if-mbr-or-gpt-in-Linux.png?resize=800%2C446&ssl=1 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/07/check-if-mbr-or-gpt-in-Linux-gui.png?resize=800%2C548&ssl=1 +[8]: https://itsfoss.com/gparted/ +[9]: https://itsfoss.com/package-manager/ +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/check-disk-partitioning-scheme-linux-gparted.jpg?resize=800%2C555&ssl=1 +[11]: https://www.rodsbooks.com/gdisk/hybrid.html diff --git a/sources/tech/20210707 Open source tools and tips for improving your Linux PC-s performance.md b/sources/tech/20210707 Open source tools and tips for improving your Linux PC-s performance.md new file mode 100644 index 0000000000..e31bfd908c --- /dev/null +++ b/sources/tech/20210707 Open source tools and tips for improving your Linux PC-s performance.md @@ -0,0 +1,192 @@ +[#]: subject: (Open source tools and tips for improving your Linux PC's performance) +[#]: via: (https://opensource.com/article/21/7/improve-linux-pc-performance) +[#]: author: (Howard Fosdick https://opensource.com/users/howtech) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Open source tools and tips for improving your Linux PC's performance +====== +Make changes to your software (and how you use it) to improve your Linux +computer's performance. +![Business woman on laptop sitting in front of window][1] + +This is the third in a series of articles that explain how to improve your Linux personal computer's performance. My first article described how to unleash performance by [identifying and resolving bottlenecks][2]. My second article showed how to improve performance by [upgrading your PC's hardware][3]. + +This article completes the series by presenting software performance tips. It also explores ways to improve performance by changing how you use your computer. Some of these behavioral changes may be obvious to many Opensource.com readers, but they might not be to the end users you support. + +The goal is a simple approach to improving Linux PC performance. As in my previous articles, I use all open source tools. There's no need for anything else. + +### How to measure improvements + +Before you make any change to your computer, assess performance to ensure that the change would be beneficial. After making the update, you might want to inspect the system a second time to verify that the modification succeeded. + +Several open source graphical tools make performance monitoring easy. They include the [GNOME System Monitor][4], [KDE System Guard][5], [GKrellM][6], [Stacer][7], [Conky][8], and [Glances][9]. (In my first article in this series, I showed how to monitor performance using the GNOME System Monitor.) + +Whichever tool you pick, look very closely at your processor and memory use. You might also want to monitor other hardware resources, such as disk and USB storage, the graphics processor, and the internet connection. + +The ultimate performance arbiter for a personal computer is its responsiveness. Quick? You're good. Sluggish… that indicates room for improvement. + +Most Linux distributions require little configuration by personal computer users: they're efficient from the start. However, an overview of the important tools you use daily can be useful when you're narrowing your focus on what could use optimization. + +### Tweak your browser + +Most users run their browser nearly all the time. For some, it's their only app. So browser selection and tuning potentially offer big payoffs. + +Here are some tuning tips: + + * As research by the Brave browser indicates, many website ads and trackers [consume over half the CPU][10] your PC spends on page processing. So block ads with a browser extension like [uBlock Origin][11], and block trackers with a tool like [Privacy Badger][12]. + * Disable autoplay for videos and animation (including those little video windows that automatically appear and run in the corner of your screen). In Firefox, you can install the open source [Disable HTML5 Autoplay][13] extension. In Chromium or Google Chrome, install the open source [Yet Another Autoplay Blocker][14] extension. + * Remove all non-essential add-ons and extensions from the browser. Carefully consider whether each is worth its overhead. + + + +#### Browser tips for powerful PCs + +For a high-end PC, select a browser that leverages your abundant processor and memory resources to provide optimal web surfing. Multiprocess, multithread browsers work best. Your goal is to apply all your hardware power for a better browsing experience. + +Which browser performs best? That's a highly debatable issue that requires a separate article for an answer. Many people start their search with Chromium or Firefox, popular open source products that are widely respected for their ability to leverage hardware for high-performance browsing. There are many other [open source browsers][15] you might try, though. + +#### Browser tips for low-end PCs + +For a limited-resource PC, you don't want a browser that consumes resources and swamps your PC. Instead, you want one that performs efficiently using limited resources. Call it a lightweight browser. It probably won't be the one that spawns lots of processes and threads. + +Users hold different views about which lightweight browser performs best. I've had good experience with [Dillo][16]. [Wikipedia][17] provides a comprehensive list of lightweight browsers, if you'd like to research others. Keep in mind that most lightweight browsers sacrifice some features and functions to reduce PC resource consumption. + +For a limited-resource PC, you can reduce browser resource consumption by opening only a couple of tabs at a time rather than a dozen. Close tabs you're done using. And run only a single instance of one browser at a time. + +JavaScript can add a lot of demand on your browser, so toggle it off when you don't need it. Most browsers offer add-ons that allow you to manage JavaScript on a per-website basis or by flipping it on or off at your direction. Firefox offers several such extensions. I use one called [JavaScript Toggle On and Off][18]. + +On low-end PCs, you can also tailor browser performance to your liking by manually starting and stopping background tab processing. Just click on the page-load button in the browser to toggle processing on or off for a web page. In Firefox, for example, this button is located on the left side of the toolbar. + +Here's how to use this. If you want to load a specific web page quickly, toggle off page loading in other tabs so that they don't compete with your page of interest. Conversely, if you're spending a lot of time reading a web page you've already loaded, let other tabs load their pages in the background while you're occupied. In this way, you can often browse with decent performance, even on a minimal-resource computer. + +### Stop multitasking + +Some apps, including games, video editors, and virtual machine hosts, require more resources than others. For best performance when you run a resource hog, run _only_ that program. Conversely, don't run a resource hog in the background while focusing on some other app. + +This performance principle applies everywhere: Limit how many apps you use at one time, and close any you aren't using. Limit concurrency, and you improve performance for the apps you run. + +Background processing presents a similar opportunity. Virus scanners, software updates, backups, image copies, filesystem verification, and big downloads are resource-intensive. Schedule these activities for off-hours to optimize performance. A good open source GUI scheduler makes this easy. For example, you can [install and use Zeit][19], and [KCron][20] is available in many repositories. + +### Choose software wisely + +Your software choices make a big difference in how much processor and memory your computer uses. + +For many people today, this hardly matters. Their state-of-the-art personal computers have more than enough processing power and memory to quickly run any app they choose. (If this is you, you can skip this section.) Yet, software choices remain crucial for others. + +#### Office suites + +If you run LibreOffice or OpenOffice, but you don't use **Base** (the database creation component), then it's safe to disable the Java runtime. You can do this in the **Tools** > **Options** > **LibreOffice** > **Advanced** setting panel. + +Alternately, replace your big office suite with what's commonly known as **GNOME Office**. This includes [AbiWord][21] and [Gnumeric][22], both of which require less from your hardware and are functionally equivalent to a word processor and spreadsheet for many users. + +You could even consider ditching the local office suite altogether. Instead, offload your workload to the cloud with a product like [Etherpad][23], [EtherCalc][24], or the [ONLYOFFICE suite][25]. + +This principle applies generally. If you have a low-end computer, offload whatever you can to the cloud. This is why [Chromebooks][26] are effective, even though most offer low-power hardware. + +#### Desktop environment + +Your desktop environment runs every minute you use your PC. If it's not responsive, install a lighter desktop that requires fewer resources. I recommend [Xfce][27], [LXQt or LXDE][28]. + +Whichever desktop you use, you can increase its responsiveness by disabling visual effects. Turn off things like animation, compositing, and the thumbnail images in your file manager, or use a file manager (such as [PCManFM, XFE, or Thunar][29]) without those features. This can have a noticeable impact on slower computers because your screen is involved in every mouse click. Use keyboard shortcuts to eliminate having to move your hand between the mouse and keyboard. + +You can configure some desktops to use a lightweight window manager. The window manager dictates how windows look and feel and how users interact with these elements. + +If you really want to skimp on resources, forgo a desktop altogether in favor of a simple windows manager. Popular choices include [JWM][30], [Openbox][31], and [Fluxbox][32]. These run faster than a full desktop but at the cost of a less user-friendly interface. For example, you often can't put icons on your desktop, and you may not have a system tray or dock. + +### Right-size your Linux distribution for your PC + +Your Linux distribution can impact PC performance. Some distros assume they're running on powerful state-of-the-art computers, while others are designed to run with fewer resources. So if you're running a full-featured distro and it doesn't perform well, test a lightweight alternative to see if it improves responsiveness. + +Testing different distros is easy. Just download the Linux distro you want to try. [Write it to a USB memory stick][33] with an open source tool like [Fedora Media Writer][34] or [Unetbootin][35]. Then boot your PC from the memory stick to test drive the distro. Start up one of the system monitoring tools I mentioned earlier, and measure whether the new distro uses hardware more efficiently. + +The lightest distros I've used are AntiX and Puppy Linux. These use window managers instead of a desktop, bundle lightweight apps, and are specifically designed to run on limited-resource computers. They even run well on 15-year-old machines! (You can even [refurbish old computers using lightweight Linux software][36].) + +The tradeoff is that their desktops aren't glitzy. Their interfaces may be unfamiliar to you, and you may have to learn how to configure them as you would a full desktop environment. For some people, that's frustrating, but for others, it's a fun challenge and an opportunity to learn something new. + +### Make PC configuration changes + +I'll conclude with some basic Linux configuration changes you may want to try. Taken individually, each won't improve performance enough that you'd notice. But in the aggregate, they can have a measurable impact: + + * Verify that you have optimal device drivers for all devices. + * Avoid overheating to prevent step-downs in CPU speed (CPU throttling). + * Reduce boot time by [reducing the default GRUB_TIMEOUT parameter][37] for the Grub menu.) + * Eliminate unneeded apps and services from your startup list (the programs that run every time you boot your computer). Linux desktop environments typically provide GUI panels for this so that you don't need to edit configuration files or scripts directly. + * Speed updates and downloads by using the fastest mirror available. + * Avoid using swap memory. + * If you do use swap, place it on your fastest device. + * Verify your WiFi is operating at peak bandwidth by comparing its WiFi speed versus when it's directly cabled to your modem. + * Verify your router isn't causing a slowdown by testing internet connection speeds without it. + * Match USB standards between your USB ports and devices to ensure they don't step down to the speed of the slower partner. + * Verify your USB transfer rates with the benchmark feature in GNOME Disks. + * If you must use virtual machines, tune them for performance. + * Clean out old history, log, and junk files with open source GUI tools like [BleachBit][38] and [Sweeper][39]. + * Clean out unused junk files by uninstalling apps you don't use. On Debian-based systems, clean the APT cache. + * Find and delete duplicate files by using an open source GUI tool like [FSlint][40]. + + + +If readers express interest, I'll discuss these tweaks in detail in a future article. (Please let me know in the comments if you'd like to see this.) + +### Summary + +In a previous article, I discussed how to identify and remove performance bottlenecks. In my last article, I explained how to efficiently upgrade your Linux PC hardware. This article completes the series by presenting software and behavioral changes that improve PC performance. + +I'm sure you have many good performance tips of your own. Please add your favorites in the comments. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/improve-linux-pc-performance + +作者:[Howard Fosdick][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/howtech +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-concentration-focus-windows-office.png?itok=-8E2ihcF (Woman using laptop concentrating) +[2]: https://opensource.com/article/21/3/linux-performance-bottlenecks +[3]: https://opensource.com/article/21/4/upgrade-linux-hardware +[4]: https://wiki.gnome.org/Apps/SystemMonitor +[5]: https://apps.kde.org/ksysguard/ +[6]: http://gkrellm.srcbox.net/ +[7]: https://oguzhaninan.github.io/Stacer-Web/ +[8]: https://github.com/brndnmtthws/conky +[9]: https://nicolargo.github.io/glances/ +[10]: https://brave.com/accurately-predicting-ad-blocker-savings/ +[11]: https://github.com/gorhill/uBlock +[12]: https://privacybadger.org/ +[13]: https://addons.mozilla.org/en-US/firefox/addon/disable-autoplay/ +[14]: https://chrome.google.com/webstore/detail/yet-another-autoplay-bloc/fjekfkbibnnjlkfjaeifgecjfmpmdaad +[15]: https://opensource.com/article/19/7/open-source-browsers +[16]: https://www.dillo.org +[17]: https://en.wikipedia.org/wiki/Comparison_of_lightweight_web_browsers +[18]: https://addons.mozilla.org/en-US/firefox/addon/javascript-toggler/ +[19]: https://github.com/loimu/zeit +[20]: https://apps.kde.org/kcron/ +[21]: https://flathub.org/apps/details/com.abisource.AbiWord +[22]: http://www.gnumeric.org +[23]: https://etherpad.org/ +[24]: http://ethercalc.net +[25]: https://opensource.com/article/20/12/onlyoffice-docs +[26]: https://opensource.com/article/21/2/chromebook-linux +[27]: https://opensource.com/article/19/12/xfce-linux-desktop +[28]: https://opensource.com/article/19/12/lxqt-lxde-linux-desktop +[29]: https://opensource.com/business/15/4/eight-linux-file-managers +[30]: https://opensource.com/article/19/12/joes-window-manager-linux-desktop +[31]: https://opensource.com/article/19/12/openbox-linux-desktop +[32]: https://opensource.com/article/19/12/fluxbox-linux-desktop +[33]: https://opensource.com/article/20/4/first-linux-computer +[34]: https://opensource.com/article/20/10/fedora-media-writer +[35]: https://opensource.com/life/14/10/test-drive-linux-nothing-flash-drive +[36]: https://opensource.com/article/19/7/how-make-old-computer-useful-again +[37]: https://www.unixmen.com/quick-tip-change-grub-2-default-timeout/ +[38]: https://www.bleachbit.org/ +[39]: https://apps.kde.org/sweeper/ +[40]: https://github.com/pixelb/fslint diff --git a/sources/tech/20210707 Parsing config files with Java.md b/sources/tech/20210707 Parsing config files with Java.md new file mode 100644 index 0000000000..c7c3474d5a --- /dev/null +++ b/sources/tech/20210707 Parsing config files with Java.md @@ -0,0 +1,358 @@ +[#]: subject: (Parsing config files with Java) +[#]: via: (https://opensource.com/article/21/7/parsing-config-files-java) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: (Starryi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Parsing config files with Java +====== +Implement persistent settings when you're writing software in Java. +![Person drinking a hot drink at the computer][1] + +When you write an application, you often want users to be able to configure how they interact with it and how it interacts with their system. These are commonly called "preferences" or "settings," and they're stored in "preference files" or "configuration files," or just "configs." There are many different formats for config files, including INI, JSON, YAML, and XML, and every language parses these languages differently. This article discusses some of the ways you can implement persistent settings when you're writing software in the [Java programming language][2]. + +### Choose a format + +Writing configuration files is surprisingly flexible. I've kept configuration options in a simple comma-delimited text file, and I've kept options in highly detailed YAML or XML. The most important thing about configuration files is that they are consistent and predictable. This makes it easy for you to write code that can quickly and easily extract data from the configuration file, as well as save and update options when the user decides to make a change. + +There are [several popular formats for configuration files][3]. Java has libraries for most of the common configuration formats, but in this article, I'll use the XML format. For some projects, you might choose to use XML for its inherent ability to provide lots of metadata about the data it contains, while for others, you may choose to avoid it due to its verbosity. Java makes working with XML relatively easy because it includes robust XML libraries by default. + +### XML basics + +XML is a big topic. Just one of the books I own about XML is over 700 pages. Fortunately, using XML doesn't require in-depth knowledge of all its many features. Like HTML, XML is a hierarchical markup language with opening and closing tags, which may contain zero or more data. Here's a sample snippet of XML: + + +``` +<xml> +  <node> +    <element>Penguin</element> +  </node> +</xml> +``` + +In this rather self-descriptive example, here are the terms that XML parsers use: + + * **Document:** The `` tag opens a _document_, and the `` tag closes it. + * **Node:** The `` tag is a _node_. + * **Element:** The `Penguin`, from the first `<` to the last `>`, is an _element_. + * **Content:** In the `` element, the string `Penguin` is the _content_. + + + +Believe it or not, that's all you need to know about XML to be able to write and parse it. + +### Create a sample config file + +A minimal example of a config file is all you need to learn how to parse XML. Imagine a config file tracking some display properties of a GUI window: + + +``` +<xml> +  <window> +    <theme>Dark</theme> +    <fullscreen>0</fullscreen> +    <icons>Tango</icons> +</window> +</xml> +``` + +Create a directory called `~/.config/DemoXMLParser`: + + +``` +`$ mkdir ~/.config/DemoXMLParser` +``` + +On Linux, the `~/.config` directory is the default configuration file location, as defined by the [Freedesktop][4] specification. If you're on an operating system that doesn't follow Freedesktop standards, you can still use this location, but you may have to create all the directories yourself. + +Copy and paste the sample configuration XML into a file and save it as `~/.config/DemoXMLParser/myconfig.xml`. + +### Parse XML with Java + +If you're new to Java, start by reading my [7 tips for new Java developers][5] article. Once you're relatively comfortable with Java, open your favorite integrated development environment (IDE) and create a new project. I call mine **myConfigParser**. + +Without worrying too much about imports and error catching initially, you can instantiate a parser using the standard Java extensions found in the `javax` and `java.io` libraries. If you're using an IDE, you'll be prompted to import the appropriate libraries; otherwise, you can find a full list of libraries in the complete version of this code later in this article. + + +``` +Path configPath = Paths.get([System][6].getProperty("user.home"), ".config", "DemoXMLParser"); +[File][7] configFile = new [File][7](configPath.toString(), "myconfig.xml"); + +DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + +DocumentBuilder builder = null; +builder = factory.newDocumentBuilder(); + +[Document][8] doc = null; +doc = builder.parse(configFile); +doc.getDocumentElement().normalize(); +``` + +This example code uses the `java.nio.Paths` library to locate the user's home directory, adding the default configuration location to the path. Then it defines the configuration file to be parsed as a File object using the `java.io.File` library. + +Next, it uses the `javax.xml.parsers.DocumentBuilder` and `javax.xml.parsers.DocumentBuilderFactory` libraries to create an internal document builder so that the Java program can ingest and parse XML data. + +Finally, Java builds a document called `doc` and loads the `configFile` file into it. Using `org.w3c.dom` libraries, it normalizes the ingested XML data. + +That's essentially it. Technically, you're done parsing the data. But parsed data isn't of much use to you if you can't access it, so write some queries to extract important values from your configuration. + +### Accessing XML values with Java + +Getting data from your ingested XML document is a matter of referencing a specific node and then "walking" through the elements it contains. It's common to use a series of loops to iterate through elements in nodes, but I'll keep that to a minimum here, just to keep the code easy to read: + + +``` +NodeList nodes = doc.getElementsByTagName("window"); + +for (int i = 0; i < nodes.getLength(); i++) { + Node mynode = nodes.item(i); + System.out.println("Property = " + mynode.getNodeName()); +        + if (mynode.getNodeType() == Node.ELEMENT_NODE) { +   Element myelement = (Element) mynode; +              +   System.out.println("Theme = " + myelement.getElementsByTagName("theme").item(0).getTextContent()); +   System.out.println("Fullscreen = " + myelement.getElementsByTagName("fullscreen").item(0).getTextContent()); +   System.out.println("Icon set = " + myelement.getElementsByTagName("icons").item(0).getTextContent()); + } +} +``` + +This sample code creates a `NodeList` object called `nodes` using the `org.w3c.dom.NodeList;` library. This object contains any child node with a name that matches the string `window`, which is the only node in the sample config file created in this article. + +Next, it creates a for-loop to iterate over the `nodes` list, taking each node in order of appearance and processing it with an if-then loop. The if-then loop creates an `Element` object called `myelement` that contains all elements within the current node. You can query the elements using methods like `getChildNodes`, `getElementById`, and others, as [documented][9] by the project. + +In this example, the elements are essentially the configuration keys. The values are stored as the content of the element, which you can extract with the `.getTextContent` method. + +Run the code either in your IDE or as a binary: + + +``` +$ java ./DemoXMLParser.java +Property = window +Theme = Dark +Fullscreen = 0 +Icon set = Tango +``` + +Here's the full code: + + +``` +package myConfigParser; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +public class ConfigParser { + +        public static void main([String][10][] args) { +                Path configPath = Paths.get([System][6].getProperty("user.home"), ".config", "DemoXMLParser"); +                [File][7] configFile = new [File][7](configPath.toString(), "myconfig.xml"); +                DocumentBuilderFactory factory = +                DocumentBuilderFactory.newInstance(); +                DocumentBuilder builder = null; +                +                try { +                        builder = factory.newDocumentBuilder(); +                } catch (ParserConfigurationException e) { +                        e.printStackTrace(); +                } +        +                [Document][8] doc = null; +        +                try { +                        doc = builder.parse(configFile); +                } catch (SAXException e) { +                        e.printStackTrace(); +                } catch ([IOException][11] e) { +                        e.printStackTrace(); +                } +        doc.getDocumentElement().normalize(); +        +        NodeList nodes = doc.getElementsByTagName("window"); +        for (int i = 0; i < nodes.getLength(); i++) { +           Node mynode = nodes.item(i); +           [System][6].out.println("Property = " + mynode.getNodeName()); +            +           if (mynode.getNodeType() == Node.ELEMENT_NODE) { +               [Element][12] myelement = ([Element][12]) mynode; + +               [System][6].out.println("Theme = " + myelement.getElementsByTagName("theme").item(0).getTextContent()); +               [System][6].out.println("Fullscreen = " + myelement.getElementsByTagName("fullscreen").item(0).getTextContent()); +               [System][6].out.println("Icon set = " + myelement.getElementsByTagName("icons").item(0).getTextContent()); +           } // close if +        } // close for +    } // close method +} //close class +``` + +### Updating XML with Java + +From time to time, a user is going to change a preference. The `org.w3c.dom` libraries can update the contents of an XML element; you only have to select the XML element the same way you did when reading it. Instead of using the `.getTextContent` method, you use the `.setTextContent` method: + + +``` +updatePref = myelement.getElementsByTagName("fullscreen").item(0); +updatePref.setTextContent("1"); + +[System][6].out.println("Updated fullscreen to " + myelement.getElementsByTagName("fullscreen").item(0).getTextContent());   +``` + +This changes the XML document in your application's memory, but it doesn't write the data back to the drive. Using a combination of `javax` and `w3c` libraries, you can place your ingested XML back into your configuration file: + + +``` +TransformerFactory transformerFactory = TransformerFactory.newInstance(); + +Transformer xtransform; +xtransform = transformerFactory.newTransformer(); + +DOMSource mydom = new DOMSource(doc); +StreamResult streamResult = new StreamResult(configFile); + +xtransform.transform(mydom, streamResult); +``` + +This silently overwrites the previous configuration file with transformed data. + +Here's the full code, complete with the updater: + + +``` +package myConfigParser; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +public class ConfigParser { + +        public static void main([String][10][] args) { +                Path configPath = Paths.get([System][6].getProperty("user.home"), ".config", "DemoXMLParser"); +                [File][7] configFile = new [File][7](configPath.toString(), "myconfig.xml"); +                DocumentBuilderFactory factory = +                DocumentBuilderFactory.newInstance(); +                DocumentBuilder builder = null; +                +                try { +                        builder = factory.newDocumentBuilder(); +                } catch (ParserConfigurationException e) { +                        // TODO Auto-generated catch block +                        e.printStackTrace(); +                } +        +                [Document][8] doc = null; +        +                try { +                        doc = builder.parse(configFile); +                } catch (SAXException e) { +                        // TODO Auto-generated catch block +                        e.printStackTrace(); +                } catch ([IOException][11] e) { +                        // TODO Auto-generated catch block +                        e.printStackTrace(); +                } +        doc.getDocumentElement().normalize(); +        Node updatePref = null; +//        NodeList nodes = doc.getChildNodes(); +        NodeList nodes = doc.getElementsByTagName("window"); +        for (int i = 0; i < nodes.getLength(); i++) { +           Node mynode = nodes.item(i); +           [System][6].out.println("Property = " + mynode.getNodeName()); +            +           if (mynode.getNodeType() == Node.ELEMENT_NODE) { +               [Element][12] myelement = ([Element][12]) mynode; + +               [System][6].out.println("Theme = " + myelement.getElementsByTagName("theme").item(0).getTextContent()); +               [System][6].out.println("Fullscreen = " + myelement.getElementsByTagName("fullscreen").item(0).getTextContent()); +               [System][6].out.println("Icon set = " + myelement.getElementsByTagName("icons").item(0).getTextContent()); + +               updatePref = myelement.getElementsByTagName("fullscreen").item(0); +               updatePref.setTextContent("2"); +               [System][6].out.println("Updated fullscreen to " + myelement.getElementsByTagName("fullscreen").item(0).getTextContent());           +           } // close if +            +        }// close for + +        // write DOM back to the file +        TransformerFactory transformerFactory = TransformerFactory.newInstance(); +        Transformer xtransform; + +        DOMSource mydom = new DOMSource(doc); +        StreamResult streamResult = new StreamResult(configFile); + +        try { +                xtransform = transformerFactory.newTransformer(); +                xtransform.transform(mydom, streamResult); +        } catch (TransformerException e) { +                e.printStackTrace(); +        } +                        +    } // close method +} //close class +``` + +### Keep configuration trouble-free + +Configuration can be a deceptively simple routine. You might start with a simple plain text config format while your application has only a few configurable features, but as you introduce more options, reading or writing incorrect data can cause unexpected behavior from your application. One way to help keep your configuration process safe from failure is to use a strict format like XML and to lean on your programming language's built-in features to handle the complexity. + +I like using Java and XML for this very reason. When I try to read the wrong configuration value, Java lets me know, often because the node my code claims to want to read doesn't exist in the XML path I expect. XML's highly structured format helps me keep my code reliable, and that benefits both the users and the developer. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/parsing-config-files-java + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_tea_laptop_computer_work_desk.png?itok=D5yMx_Dr (Person drinking a hot drink at the computer) +[2]: https://opensource.com/resources/java +[3]: https://opensource.com/article/21/6/what-config-files +[4]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html +[5]: https://opensource.com/article/19/10/java-basics +[6]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system +[7]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+file +[8]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+document +[9]: https://www.w3.org/2003/01/dom2-javadoc/org/w3c/dom/Document.html +[10]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string +[11]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+ioexception +[12]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+element diff --git a/sources/tech/20210708 3 reasons Quarkus 2.0 improves developer productivity on Linux.md b/sources/tech/20210708 3 reasons Quarkus 2.0 improves developer productivity on Linux.md new file mode 100644 index 0000000000..a8510faa57 --- /dev/null +++ b/sources/tech/20210708 3 reasons Quarkus 2.0 improves developer productivity on Linux.md @@ -0,0 +1,126 @@ +[#]: subject: (3 reasons Quarkus 2.0 improves developer productivity on Linux) +[#]: via: (https://opensource.com/article/21/7/developer-productivity-linux) +[#]: author: (Daniel Oh https://opensource.com/users/daniel-oh) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +3 reasons Quarkus 2.0 improves developer productivity on Linux +====== +New features in Quarkus 2.0 make it easier to test code in the developer +console. +![Person using a laptop][1] + +No matter how long you work as an application developer and no matter what programming language you use, you probably still struggle to increase your development productivity. Additionally, new paradigms, including cloud computing, DevOps, and test-driven development, have significantly accelerated the development lifecycle for individual developers and multifunctional teams. + +You might think open source tools could help fix this problem, but I'd say many open source development frameworks and tools for coding, building, and testing make these challenges worse. Also, it's not easy to find appropriate [Kubernetes][2] development tools to install on Linux distributions due to system dependencies and support restrictions. + +Fortunately, you can increase development productivity on Linux with [Quarkus][3], a Kubernetes-native Java stack. Quarkus 2.0 was released recently with useful new features for testing in the developer console. + +### Interactive developer UX/UI + +If you need to add more than 10 dependencies (e.g., database connections, object-relational mapping, JSON formatting, REST API specifications) to your Java Maven project, you must define more than 60 configurations with keys and values in one or more `application.properties` files. More configurations decrease readability for individual developers and are harder for developer teams to manage. + +Quarkus has an interactive interface to display all dependencies that have been added. It is available at the `localhost:8080/q/dev` endpoint after you start Quarkus dev mode with the `mvn quarkus:dev` command. You can also update configurations in the DEV user interface (UI), as Figure 1 shows, and the changes will automatically sync with the `application.properties` file. + +(Note: You can find the entire Quarkus application code for this article in my [GitHub repository][4].) + +![Quarkus DEV UI][5] + +Figure 1. Quarkus DEV UI (Daniel Oh, [CC BY-SA 4.0][6]) + +### Better continuous testing + +When developing an application, anything from a monolith to microservices, you have to test your code. Often, a dedicated quality assurance (QA) team using external continuous integration (CI) tools is responsible for verifying unit tests. That's worked for years, and it still does, but Quarkus allows programmers to run tests in the runtime environment where their code is running as it's being developed. Quarkus 2.0 provides this continuous testing feature through the command-line interface (CLI) and the DEV UI, as shown in Figure 2. + +![Quarkus Testing in DEV UI][7] + +Figure 2. Quarkus testing in DEV UI (Daniel Oh, [CC BY-SA 4.0][6]) + +Continuous testing is not running when a Quarkus application starts. To start it, click "Tests not running" on the bottom-right of the DEV UI. You can also open a web terminal by clicking "Open" on the left-hand side of the DEV UI. Both of those options are highlighted in Figure 2, and an example test result is shown in Figure 3. + +![Quarkus console in DEV UI][8] + +Figure 3. Quarkus console in DEV UI (Daniel Oh, [CC BY-SA 4.0][6]) + +If you change the code (e.g., "Hello" to "Hi" in the `hello()` method) but not the test code (regardless of whether the feature works), the test will fail, as shown in Figure 4. To fix it, update the test code along with the logic code. + +![Test failures in Quarkus DEV UI][9] + +Figure 4. Test failures in Quarkus DEV UI (Daniel Oh, [CC BY-SA 4.0][6]) + +You can rerun the test cases implemented in the `src/test/java/` directory. This feature alleviates the need to integrate with an external CI tool and ensures functionality while developing business logic continuously. + +### Zero configuration with dev services + +When you're developing for a specific target, it's important that your development environment is an accurate reflection of the environment where it is meant to run. That can make installing a database in a place like a local environment a little difficult. If you're developing on Linux, you could run the requisite database in a container, but they tend to run differently based on what resources are available, and your local environment probably doesn't have the same resources as the target production environment. + +Quarkus 2.0 helps solve this problem by providing dev services built on [Testcontainers][10]. For example, you can test applications if they work in the production database, PostgreSQL, rather than an H2 in-memory datastore with the following [configurations][11]: + + +``` +quarkus.datasource.db-kind = postgresql (1) +quarkus.hibernate-orm.log.sql = true + +quarkus.datasource.username=person (2) +quarkus.datasource.password=password (3) +quarkus.hibernate-orm.database.generation=drop-and-create + +%prod.quarkus.datasource.db-kind = postgresql (4) +%prod.quarkus.datasource.jdbc.url = jdbc:postgresql://db:5432/person (5) +%prod.quarkus.datasource.jdbc.driver=postgresql + +quarkus.datasource.devservices.image-name=postgres:latest (6) +``` + +In the code above: + +(1) The kind of database you will connect for development and test +(2) Datasource username +(3) Datasource password +(4) The kind of database you will connect for production +(5) Datasource URL +(6) The container image name to use for DevServices providers; if the provider is not container-based (e.g., H2 database), then this has no effect + +When Quarkus restarts with the new configuration, the Postgres container image will be created and start running automatically, as in Figure 5. + +![Quarkus DevServices][12] + +Figure 5. Quarkus DevServices (Daniel Oh, [CC BY-SA 4.0][6]) + +This feature enables you to remove the production datastore integration test. It also increases your development productivity due to avoiding environmental disparities in the development loop. + +### Conclusion + +Quarkus 2.0 increases developer productivity with built-in continuous testing, an interactive DEV UI, and dev services. In addition, it offers additional features for improving developer experiences such as [live coding][13], [remote development mode on Kubernetes][14], and unified configurations that accelerate the development loop. Quarkus 2.0 is certainly no exception! Try it out for yourself [here][15]! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/developer-productivity-linux + +作者:[Daniel Oh][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/daniel-oh +[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/resources/what-is-kubernetes +[3]: https://quarkus.io/ +[4]: https://github.com/danieloh30/quarkus-testing +[5]: https://opensource.com/sites/default/files/uploads/quarkus-devui.png (Quarkus DEV UI) +[6]: https://creativecommons.org/licenses/by-sa/4.0/ +[7]: https://opensource.com/sites/default/files/uploads/quarkustesting.png (Quarkus Testing in DEV UI) +[8]: https://opensource.com/sites/default/files/uploads/quarkusconsole.png (Quarkus console in DEV UI) +[9]: https://opensource.com/sites/default/files/uploads/failedtest.png (Test failures in Quarkus DEV UI) +[10]: https://www.testcontainers.org/ +[11]: https://github.com/danieloh30/quarkus-testing/blob/main/src/main/resources/application.properties +[12]: https://opensource.com/sites/default/files/uploads/quarkusdevservices.png (Quarkus DevServices) +[13]: https://quarkus.io/guides/getting-started#development-mode +[14]: https://developers.redhat.com/blog/2021/02/11/enhancing-the-development-loop-with-quarkus-remote-development +[15]: https://quarkus.io/quarkus2/ diff --git a/sources/tech/20210709 OS Chroot 101- covering btrfs subvolumes.md b/sources/tech/20210709 OS Chroot 101- covering btrfs subvolumes.md new file mode 100644 index 0000000000..01b092cc57 --- /dev/null +++ b/sources/tech/20210709 OS Chroot 101- covering btrfs subvolumes.md @@ -0,0 +1,261 @@ +[#]: subject: (OS Chroot 101: covering btrfs subvolumes) +[#]: via: (https://fedoramagazine.org/os-chroot-101-covering-btrfs-subvolumes/) +[#]: author: (yannick duclap https://fedoramagazine.org/author/cybermeme/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +OS Chroot 101: covering btrfs subvolumes +====== + +![][1] + +OS chroot command allows you to mount and run another Gnu/Linux from within your current Gnu/Linux. It does this by mounting nested partition(s) within your system and it gives you a shell which allows access to this chrooted OS. This will allow you to manage or debug another Gnu/Linux from your running Fedora Linux + +### Intro + +##### Disclaimer + +When I say _chroot_, I mean the command, and _chrootDir_ a folder. _OSext_ is the external OS to work with. All the following commands are executed as superuser. For extra readability I removed the sudo at the beginning, just don’t forget to be superadmin when performing the tasks. […] means I cut some terminal output. + +First I’m going to review how to do a chroot on a classic filesystem (ext4, xfs, fat, etc) and then we’ll see how to do it on our brand new standard Btrfs and its subvolumes. + +The process is similar to that used to [change the root password][2], or that we may use to repair a corrupted fstab (it happens, trust me). We can also use the chroot command to mount a Gnu/Linux in our Fedora Linux in order to perform operations (updates, file recovery, debugging, etc). + +#### A few explanations + +The [chroot][3] command lets you “change” temporarily the root location. This lets you partition a service or a user in the directory tree. + +When you use _chroot_ to run a mounted Gnu/Linux OS, in order for it to be fully functional, you have to mount the special system folders in their “original places in the directory tree” in the chrootDir. This allows the chrooted OS to talk to the kernel. + +These special system folders are: + + * _/dev_ for the devices; + * _/proc_ which contains the information about the system (kernel and process); + * _/sys_ which contains the information about the hardware. + + + +For example, _/dev_ has to be mounted in _chrootDir/dev_. + +As I always learn better by practicing, let’s do some hands on. + +### Filesystems without btrfs subvolumes + +#### The classic method + +In the following example, the partition we are going to mount is the OSext root (_/_). This is located in _/dev/vda2_ and we will mount it in the chrootDir (_/mnt_) directory. _/mnt_ is not a necessity, you can also mount the partition somewhere else. + +``` +# mount /dev/vda2 /mnt +# mount --bind /dev /mnt/dev +# mount -t proc /proc /mnt/proc +# mount -t sysfs /sys /mnt/sys +# mount -t tmpfs tmpfs /mnt/run +# mkdir -p /mnt/run/systemd/resolve/ +# echo 'nameserver 1.1.1.1' > /mnt/run/systemd/resolve/stub-resolv.conf +# chroot /mnt +``` + +The _–bind_ option makes the contents accessible in both locations, _-t_ defines the filesystem type. See the [manpage][4] for more information. + +We will mount _/run_ as _tmpfs_ (in the memory) because we are using systemd-resolved (this is the default now in Fedora). Then we will create the folder and the file _stub-resolv.conf,_ which is associated by a symbolic link to /_etc/resolv.conf_. This file contains the resolver IP. In this example, the resolver is 1.1.1.1, but you can use any resolver IP you like. + +To exit the chroot, the shell command is _exit_. After that, we unmount all the folders we just mounted: + +``` +exit +# umount /mnt/dev +# umount /mnt/proc +# umount /mnt/sys +# umount /mnt/run +# umount /mnt +``` + +#### The case of lvm + +In the case of lvm, the partitions are not available directly and must be mapped first. + +``` +# fdisk -l /dev/vda2 +Disk /dev/vda2: 19 GiB, 20400046080 bytes, 39843840 sectors +[...] +I/O size (minimum/optimal): 512 bytes / 512 bytes + +# mount /dev/vda2 /mnt/ +mount: /mnt: unknown filesystem type 'LVM2_member'. +``` + +As you can see, we are not able to mount _/dev/vda2_ directly. We will now use the lvm tools to locate our partitions. + +``` +# pvscan +PV /dev/vda2 VG cl lvm2 [<19.00 GiB / 0 free] +Total: 1 [<19.00 GiB] / in use: 1 [<19.00 GiB] / in no VG: 0 [0] + +# vgscan +Found volume group "cl" using metadata type lvm2 + +# lvscan +ACTIVE '/dev/cl/root' [10.00 GiB] inherit +ACTIVE '/dev/cl/swap' [2.00 GiB] inherit +ACTIVE '/dev/cl/home' [1.00 GiB] inherit +ACTIVE '/dev/cl/var' [<6.00 GiB] inherit +``` + +So here we can see where the logical volumes are mapped _/dev/cl_ and we can mount these partitions like we did before, using the same method: + +``` +# mount /dev/cl/root /mnt/ +# mount /dev/cl/home /mnt/home/ +# mount /dev/cl/var /mnt/var/ +# mount --bind /dev /mnt/dev +# mount -t proc /proc /mnt/proc +# mount -t sysfs /sys /mnt/sys +# mount -t tmpfs tmpfs /mnt/run +# mkdir -p /mnt/run/systemd/resolve/ +# echo 'nameserver 1.1.1.1' > /mnt/run/systemd/resolve/stub-resolv.conf +# chroot /mnt +``` + +### Btrfs filesystem with subvolumes + +#### Overview of a btrfs partition with subvolumes + +Let’s have a look at the filesystem. + +Fdisk tells us that there are only two partitions on the physical media. + +``` +# fdisk -l +Disk /dev/vda: 20 GiB, 21474836480 bytes, 41943040 sectors + […] + Device Boot Start End Sectors Size Id Type + /dev/vda1 * 2048 2099199 2097152 1G 83 Linux + /dev/vda2 2099200 41943039 39843840 19G 83 Linux +``` + +Here are the contents of the target system’s fstab (OSext): + +``` +UUID=3de441bd-59fc-4a12-8343-8392faab5ac7 / btrfs subvol=root,compress=zstd:1 0 0 +UUID=71dc4f0f-9562-40d6-830b-bea065d4f246 /boot ext4 defaults 1 2 +UUID=3de441bd-59fc-4a12-8343-8392faab5ac7 /home btrfs subvol=home,compress=zstd:1 0 0 +``` + +Looking at the _UUID_s in the _fstab_, we can see that there are two different ones. + +One is an ext4, used here for _/boot_ and the other is a btrfs containing two mount points (the subvolumes), _/_ and _/home_. + +#### Overview of a btrfs filesystem with subvolumes + +Let’s have a look at what is in the btrfs partition (_/dev/vda2_ here) by mounting it directly: + +``` +# mount /dev/vda2 /mnt/ +# ls /mnt/ +home root + +# ls /mnt/root/ +bin dev home lib64 media opt root sbin sys usr +boot etc lib lost+found mnt proc run srv tmp var + +# ls /mnt/home/ +user + +# umount /mnt +``` + +Here we can see that in the mounted partition there are two folders (the subvolumes), that contain lots of different directories (the target file hierarchy). + +To get this information about the subvolumes, there is a much more elegant way. + +``` +# mount /dev/vda2 /mnt/ + +# btrfs subvolume list /mnt +ID 256 gen 178 top level 5 path home +ID 258 gen 200 top level 5 path root +ID 262 gen 160 top level 258 path root/var/lib/machines + +# umount /mnt +``` + +#### Practical chroot with btrfs subvolumes + +Now that we’ve had a look at the contents of our partition, we will mount the system on chrootDir (_/mnt_ in the example). We will do this by adding the mount type as btrfs and the option for subvolume _subvol=SubVolumeName_. We will also add the special system folders and other partitions in the same way. + +``` +# mount /dev/vda2 /mnt/ -t btrfs -o subvol=root + +# ls /mnt/ +bin dev home lib64 media opt root sbin sys usr +boot etc lib lost+found mnt proc run srv tmp var + +# ls /mnt/home/ + + +# mount /dev/vda2 /mnt/home -t btrfs -o subvol=home + +# ls /mnt/home/ +user + +# mount /dev/vda1 /boot +# mount --bind /dev /mnt/dev +# mount -t proc /proc /mnt/proc +# mount -t sysfs /sys /mnt/sys +# mount -t tmpfs tmpfs /mnt/run +# mkdir -p /mnt/run/systemd/resolve/ +# echo 'nameserver 1.1.1.1' > /mnt/run/systemd/resolve/stub-resolv.conf +# chroot /mnt +``` + +When the job is done, we use the shell command _exit_ and unmount all previously mounted directories as well as the chrootDir itself (_/mnt_). + +``` +exit +# umount /mnt/boot +# umount /mnt/sys +# umount /mnt/proc +# umount /mnt/sys +# umount /mnt/run +# umount /mnt +``` + +### Conclusion + +As you can see on the screenshot below, I performed a dnf update on a Fedora Linux 34 Workstation from a live [Fedora 33 security lab CD][5], that way, if a friend needs you to debug his/her/their Gnu/Linux, he/she/they just have to bring the hard drive to you and not the whole desktop/server machine. + +![][6] + +Be careful if you use a different shell between your host OS and OSext (the chrooted OS), for example ksh <-> bash. +In this case you’ll have to make sure that both systems have the same shell installed. + +I hope this will be useful to anyone needing to debug, or if you just need to update your other Fedora Linux in your dual boot and don’t want to have to restart 😉 + +This article just referred to a part of btrfs, for more information you can have a look at the the [wiki][7] which will give you all the information you need. + +Have fun chrooting. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/os-chroot-101-covering-btrfs-subvolumes/ + +作者:[yannick duclap][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/cybermeme/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2021/07/chroot-btrfs-816x345.jpg +[2]: https://fedoramagazine.org/reset-root-password-fedora/ +[3]: https://man7.org/linux/man-pages/man2/chroot.2.html +[4]: https://man7.org/linux/man-pages/man8/mount.8.html +[5]: https://labs.fedoraproject.org/security/download/index.html +[6]: https://fedoramagazine.org/wp-content/uploads/2021/07/fedoraSecurity.png +[7]: https://fedoraproject.org/wiki/Btrfs diff --git a/sources/tech/20210709 Troubleshooting bugs in an API implementation.md b/sources/tech/20210709 Troubleshooting bugs in an API implementation.md new file mode 100644 index 0000000000..a8f5885c8d --- /dev/null +++ b/sources/tech/20210709 Troubleshooting bugs in an API implementation.md @@ -0,0 +1,99 @@ +[#]: subject: (Troubleshooting bugs in an API implementation) +[#]: via: (https://opensource.com/article/21/7/listing-prefixes-s3-implementations) +[#]: author: (Alay Patel https://opensource.com/users/alpatel) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Troubleshooting bugs in an API implementation +====== +Different API versions can cause unexpected problems. +![magnifying glass on computer screen, finding a bug in the code][1] + +As distributed and cloud computing adoption increase, things are intrinsically getting harder to debug. This article shares a situation where you would expect a library to safeguard against different versions of an API. However, it didn't and it caused unexpected behavior that was very hard to debug. This might be a useful example of how ripping out layers of abstractions is sometimes necessary to get to the root cause of a problem in a systematic manner. + +The S3 (Simple Storage Solution) API is an industry standard that provides the capability to interact with cloud storage programmatically. Many cloud providers implement it as one of the ways to interact with the object-store. Having different vendors to choose from is good to avoid vendor lock-in. Also, having different implementations to choose from means you get to select open source implementations of the popular standard that works best for you and your team. + +However, the differences in API versions may cause unexpected problems, as we learned. This article leverages those differences to illustrate the troubleshooting process. + +### Konveyor Crane + +[Crane][2] is part of the [Konveyor community][3], which works to solve problems related to app modernization and portability to further the adoption of Kubernetes. Crane allows users to migrate applications (and the associated data) deployed on OpenShift 3 to OpenShift 4. Behind the scenes, it uses [Velero][4] to orchestrate the migration. Velero uses the object store to perform backup and restore operations. + +### How Velero stores data + +Velero can be configured to use a bucket from the object store as a backup storage location (where backup data is stored). Velero organizes backups in a directory called `/backups` (with `prefix` being configurable). Under the `backups` directory, Velero creates a separate directory for each backup, e.g., `/backups/`. + +Additionally, to ensure that a backup created in the object store is available in the cluster and available for restoration, Velero makes a prefix list of all the directories under `backups`. It uses the ListObjectsV2 S3 API to implement this. The [ListObjectsV2][5] API differs from the [ListObjects][6] API in how it handles pagination. + +### How API differences produced a bug + +The differences between these two API versions are subtle. First, clients see the difference in the request that they send to the S3 server. When requesting a ListObjectV2, the client sends something like this: + + +``` +GET /?list-type=2&delimiter=Delimiter&prefix=Prefix +HTTP/1.1 +Host: Bucket.s3.example.objectstorage.softlayer.net +x-amz-request-payer: RequestPayer +x-amz-expected-bucket-owner: ExpectedBucketOwner +``` + +For ListObjects, the request looks very similar, but it's missing `list-type=2`: + + +``` +GET /?delimiter=Delimiter&marker=Marker&prefix=Prefix +HTTP/1.1 +Host: Bucket.s3.example.objectstorage.softlayer.net +x-amz-request-payer: RequestPayer +x-amz-expected-bucket-owner: ExpectedBucketOwner +``` + +For a server that ignores the `list-type=2` parameter, it is easy to respond to a basic ListObjectsV2 call with a ListObject response type. + +The interesting difference between the API versions' response types is how pagination is implemented. Both versions share a common field called `isTruncated` in the response; this indicates whether the server has sent a complete set of keys in its response. In ListObjectsV2, this field is used along with the `NextContinuousToken` field to get the next page (and, hence, the next set of keys) and is iterated upon until the `isTruncated` field is false. However, in ListObjects API, the `NextMarker` field is used instead. There are subtle differences in how this is implemented. + +### Our observations + +When we observed the Velero debug logs, we discovered 555 total backup objects were found. However, when we ran the [s3cmd][7] command against the same bucket to list objects, it returned 788. After looking at the debug logs of the s3cmd command-line interface (CLI), we found that the s3cmd could talk to the server using ListObjects. We also noticed that the last field on the first page of the s3cmd debug log was the last field Velero saw in its list. This immediately rang bells that pagination is not implemented correctly with the ListObjectsV2 API. + +In a ListObjectsV2 API, the `NextContinuousToken` field is used to take the client to the next page, and the `ListObjectV2Pages` method in the `aws-go-sdk` uses this field in its implementation. The logic is: if the `NextContinuousToken` field is empty, no more pages exist, so set `LastPage=true`. + +Considering that a server could send a ListObject response without a `NextContinuousToken` set on a ListObjectV2Pages API call, it is clear that if the response is pagination with a ListObject response, ListObjectsV2Pages will read only the first page. This is exactly what happened and was verified by observing it in a debugger using a [sample program][8]. + +Simply by changing Velero's implementation to use the ListObjectsPages method (which uses the ListObjects API), Velero was able to report a backup count of 788, which was consistent with the s3cmd CLI. + +Because of this semantic difference, the customer's migration efforts were blocked. The root cause stemmed from the libraries being used, and the analysis unblocked the customer. + +### Conclusion + +This case study shows how implementations of something as widely adopted as the S3 API could have bugs and can cause problems in unexpected ways. + +To follow the technical analysis of how Konveyor's development team is solving modernization and migration issues, check out our engineering [knowledge base][9]. For updates on the Konveyor tools, join the community at [konveyor.io][10] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/listing-prefixes-s3-implementations + +作者:[Alay Patel][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alpatel +[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.konveyor.io/crane +[3]: https://www.redhat.com/en/blog/red-hat-and-ibm-research-launch-konveyor-project +[4]: https://velero.io/ +[5]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html +[6]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjects.html +[7]: https://s3tools.org/usage +[8]: https://gist.github.com/alaypatel07/c2a1f34095813e8887ddcb3f6e90d262 +[9]: http://engineering.konveyor.io/ +[10]: https://konveyor.io/ diff --git a/sources/tech/20210709 What you need to know about security policies.md b/sources/tech/20210709 What you need to know about security policies.md new file mode 100644 index 0000000000..43920a4927 --- /dev/null +++ b/sources/tech/20210709 What you need to know about security policies.md @@ -0,0 +1,90 @@ +[#]: subject: (What you need to know about security policies) +[#]: via: (https://opensource.com/article/21/7/what-security-policy) +[#]: author: (Chris Collins https://opensource.com/users/clcollins) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +What you need to know about security policies +====== +Learn about protecting your personal computer, server, and cloud systems +with SELinux, Kubernetes pod security, and firewalls. +![Lock][1] + +A **security policy** is a set of permissions that govern access to a system, whether the system is an organization, a computer, a network, an application, a file, or any other resource. Security policies often start from the top down: Assume nobody can do anything, and then allow exceptions. + +On a desktop PC, the default policy is that no user may interact with the computer until after logging in. Once you've successfully logged in, you inherit a set of digital permissions (in the form of metadata associated with your login account) to perform some set of actions. The same is true for your phone, a server or network on the internet, or any node in the cloud. + +There are security policies designed for filesystems, firewalls, services, daemons, and individual files. Securing your digital infrastructure is a job that's never truly finished, and that can seem frustrating and intimidating. However, security policies exist so that you don't have to think about who or what can access your data. Being comfortably familiar with potential security issues is important, and reading through known security issues (such as NIST's great [RSS feed][2] for [CVE entries][3]) over your [power breakfast][4] can be more eye-opening than a good cup of coffee, but equally important is being familiar with the tools at your disposal to give you sensible defaults. These vary depending on what you're securing, so this article focuses on three areas: your personal computer, the server, and the cloud. + +### SELinux + +[SELinux][5] is a **labeling system** for your personal computer, servers, and the Linux nodes of the cloud. On a modern Linux system running SELinux, every process has a label, as does every file and directory. In fact, any system object gets a label. Luckily, you're not the one who has to do the labeling. These labels are created for you automatically by SELinux. + +Policy rules govern what access is granted between labeled **processes** and labeled **objects**. The kernel enforces these rules. In other words, SELinux can ensure that an action is safe whether a user appears to deserve the right to perform that action or not. It does this by understanding what processes are permitted. This protects a system from a bad actor who gains escalated permissions—whether it's through a security exploit or by wandering over to your desk after you've gotten up for a coffee refill—by understanding the expected interactions of all of your computer's components. + +For more information about SELinux, read our [illustrated guide to SELinux][6] by Dan Walsh. To learn more about using SELinux, read [A sysadmin's guide to SELinux][7] by Alex Callejas, and download our free [SELinux cheat sheet][8]. + +### Kubernetes pod security + +In the world of the Kubernetes cloud, there are **Security Policies** and **Security Contexts**. + +Pod [Security Policies][9] are an implementation of Kubernetes pod security resources. They are built-in resources that describe specific conditions that pods must conform to in order to be accepted and scheduled. For example, Pod Security Policies can leverage restrictions on which types of volumes a pod may be allowed to mount or what user or group IDs the pod is not allowed to use. Unlike Security Contexts, these are restrictions controlled by the cluster's Control Plane that decide if a given pod is allowed within the Kubernetes system, even before it is created. If the pod spec does not meet the requirements of the Pod Security Policy, it is rejected. + +[Security Contexts][10] are similar to Pod Security Policies, in that they describe what a pod or container can and cannot do but in the context of the container runtime. Recall that the Pod Security Policies are enforced in the Control Plane. Security Contexts are provided in the spec of the pod and describe to the container runtime (e.g., Docker, CRI-O, etc.) specifically how the pod should run. There's a lot of overlap in the kinds of restrictions found in Pod Security Policies and Security Contexts. The former can be thought of as "these are the things a pod in this policy may do," while the latter is "this pod must be run with these specific rules." + +#### The state of Pod Security Policies + +Pod Security Policies are deprecated and will be removed in Kubernetes 1.25. In April 2021, Tabitha Sable of Kubernetes SIG Security wrote about the [deprecation and replacement of Pod Security Policies][11]. There's an open pull request that describes proposed [Kubernetes enhancements][12] with a new admission controller to enforce pod security standards, which is suggested as the replacement for the deprecated Pod Security Policies. The architecture acknowledges, however, that there's a large ecosystem of add-ons and complementary services that can be mixed and matched to provide coverage that meets an organization's needs. + +For now, Kubernetes has published [Pod Security Standards][13] describing the overall concept of layered policy types, from totally unrestricted **Privileged** pods to minimally restricted **Baseline** and then heavily **Restricted** policies, and publishing these example policies as Pod Security Policies. The documentation describes what restrictions make up these different profiles and provide an excellent starting point to get familiar with different types of restrictions that might be applied to a pod to increase security. + +#### Future of security policies + +The future of pod security in Kubernetes will likely include an admission controller like the one proposed in the enhancement PR and a mix of add-ons for tweaking and adjusting how pods run in the cluster, such as [Open Policy Agent][14] (OPA). Kubernetes is extremely flexible given just how complicated its job is, and this change follows the same pattern that has allowed Kubernetes to be so successful: managing container orchestration well and allowing an entire ecosystem of add-ons and tools to enhance and extend the core so that it is not a one-size-fits-all solution. + +### Firewalls + +Protecting your network is just as important as protecting the computers inside it. For that, there are firewalls. Some firewalls come embedded in routers, but computers have firewalls too, and in large organizations, they run the firewall for the entire network. + +Typical firewall policies are constructed by denying all traffic, followed by judicious exceptions for necessary incoming and outgoing communication. Individual users can learn more about the `firewall-cmd` in Seth Kenlon's [Getting started with Linux firewalls][15]. Sysadmins can learn more about firewalls in Seth's [Secure your network with firewall-cmd][16]. And both users and admins can benefit from our free [firewall-cmd cheat sheet][17]. + +### Security policies + +Security policies are important for protecting people and their data no matter what the system. Buildings and tech conferences need security policies to keep people physically safe, and computers need security policies to keep data safe from abuse. + +Spend some time thinking about the security of the systems in your life, getting familiar with the default policies, and choosing your level of comfort for the different risks you identify. Then establish a security policy, and stick to it. As with [backup plans][18], security won't get addressed unless it's _easy_, so make it second nature to maintain good security practices. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/what-security-policy + +作者:[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/security-lock-password.jpg?itok=KJMdkKum (Lock) +[2]: https://nvd.nist.gov/feeds/xml/cve/misc/nvd-rss-analyzed.xml +[3]: https://nvd.nist.gov/vuln/data-feeds#APIS +[4]: https://opensource.com/article/21/6/breakfast +[5]: https://en.wikipedia.org/wiki/Security-Enhanced_Linux +[6]: https://opensource.com/business/13/11/selinux-policy-guide +[7]: https://opensource.com/article/18/7/sysadmin-guide-selinux +[8]: https://opensource.com/downloads/cheat-sheet-selinux +[9]: https://kubernetes.io/docs/concepts/policy/pod-security-policy/ +[10]: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ +[11]: https://kubernetes.io/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/ +[12]: https://github.com/kubernetes/enhancements/issues/2579 +[13]: https://kubernetes.io/docs/concepts/security/pod-security-standards/ +[14]: https://www.openpolicyagent.org/ +[15]: https://opensource.com/article/20/2/firewall-cheat-sheet +[16]: https://www.redhat.com/sysadmin/secure-linux-network-firewall-cmd +[17]: https://opensource.com/downloads/firewall-cheat-sheet +[18]: https://opensource.com/article/19/3/backup-solutions diff --git a/sources/tech/20210710 A new open source operating system for embedded systems.md b/sources/tech/20210710 A new open source operating system for embedded systems.md new file mode 100644 index 0000000000..e8658cdb55 --- /dev/null +++ b/sources/tech/20210710 A new open source operating system for embedded systems.md @@ -0,0 +1,92 @@ +[#]: subject: (A new open source operating system for embedded systems) +[#]: via: (https://opensource.com/article/21/7/rt-thread-smart) +[#]: author: (Zhu Tianlong https://opensource.com/users/zhu-tianlong) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +A new open source operating system for embedded systems +====== +RT-Thread Smart is working to open source the world of IoT and edge +computing. +![An intersection of pipes.][1] + +There's a growing demand for [embedded operating systems][2], and it's best when the one you build upon is open source. The [RT-Thread][3] project's R&D team has spent three years of research and intensive development to arrive at the project's latest offering: RT-Thread Smart. It is a microkernel operating system aimed primarily at midrange to high-end processors such as RISC-V with a memory management unit (MMU) and provides a competitive software platform for all industries in the embedded space. + +### Who needs RT-Thread Smart? + +RT-Thread Smart is a professional, high-performance, microkernel operating system for real-time applications. It offers an open source foundation for embedded devices in any market, including security (e.g., internet protocol cameras), industrial control, onboard devices, consumer electronics, and anything else using embedded technology (which is increasingly coming to mean "everything"). It's significant because, unlike traditional IoT operating systems, a microkernel operating system can fill the gap between a traditional real-time operating system (RTOS) and a comparatively large operating system like Linux to achieve the best balance between real-time performance, cost, security, startup speed, and more. + +### RT-Thread Smart's architecture + +RT-Thread Smart separates a system into kernel mode and user mode by taking advantage of the MMU and system call methods. It then divides the address space for each mode (a 32-bit system provides 4G address space). + +![RT-Thread Smart architecture][4] + +(RT-Thread, [CC BY-SA 4.0)][5] + +The RT-Thread Smart kernel includes the platform's basic functionality and supports customizations. RT-Thread Smart's userspace application environment uses [musl libc][6] to provide [POSIX][7] interface calls and C runtime supports. It also inherits the original RT-Thread ecosystem, using [SCons][8] or other build tools such as [Autotools][9], Makefiles, [CMake][10], and so on to support development, as well as RT-Thread's out-of-the-box online software packages (over 342 at the time of this writing). You can even port Linux applications, such as wget/cURL, BusyBox, OpenSSL, and Simple DirectMedia Layer, to your platform. + +The compressed RT-Thread Smart kernel is just 217KB, with a root filesystem of 127KB. Typical memory usage is about 2MB. + +Including full support for filesystems, network protocol stacks, and multimedia, it takes only three to five seconds for RT-Thread to finish its startup process. Without running any functional components, RT-Thread Smart requires less than 500ms to start and be ready. + +With its integrated Persimmon user interface (UI) component, the time it takes from power-on to a running UI is about one second. In other words, this is a seriously tiny and fast system. Of course, "real time" isn't about startup but how the system performs consistently over time. For RT-Thread, real-time performance is a priority, and the interrupt latency is less than 1 μs, which meets most application cases with the strictest real-time requirements. + +### RT-Thread Smart vs. RT-Thread + +You might be wondering about the differences between RT-Thread Smart and RT-Thread. Simply put, RT-Thread Smart is an RT-Thread RTOS-based operating system, but it integrates the user-state process. The kernel part of RT-Smart is essentially RT-Thread RTOS; it runs on virtual addresses, joins process management, and uses interprocess communication mechanisms, virtual memory/address space management, ELF loaders, and so on, and it makes all of these features components within RT-Thread RTOS. When the IwP components are disabled, RT-Smart falls back onto RT-Thread RTOS. + +Here's a comparison: + +| RT-Thread | RT-Thread Smart +---|---|--- +Supported chips | Cortex-M/R, RISC-V RV32IMAC (and similar), Cortex-A MPU | MPU with MMU, such as Cortex-A +Compiling | The kernel and application are compiled into an image program. | The kernel and application can be separately compiled and executed. +Memory | Runs on a linear address space (even with MMU) and uses virtual addressing with the physical address | Runs on a 32-bit system with the kernel running on more than 1GB, the user-state process has separate address spaces that are isolated from each other. Peripheral drivers must access peripherals with virtual addresses. +Running errors | When an application fails, the overall system collapses. | When an application fails, it does not affect kernel and other process execution. +Running model | Multiprocess model | Multiprocess model (multithread is supported within the process, and kernel threads are supported by the kernel) +User model | Single-user model | Single-user model +API | RT-Thread API, POSIX PSE52 | RT-Thread API (on kernel and userspace), plus a full POSIX API +Real time | Preemptive hard real-time system | Preemptive hard real-time system +Resource utilization | Very small | Relatively small +Debugging | Generally debugged through the emulator | No emulator required according to the way the software debugs + +RT-Thread RTOS is very compact. All applications and subsystems are compiled into the image, and multitasking runs and shares the same address space. + +RT-Thread Smart is independent. Systems and applications are separately compiled and executed. Applications have a complete address space and are kept isolated from each other. It also inherits all the great real-time features of RT-Thread and features a POSIX environment. + +Similarly, they're both compatible with the RT-Thread API, so applications on RT-Thread RTOS can be smoothly ported to RT-Thread Smart. + +### Embed open source + +RT-Thread Smart is an open source project, with its code available on [GitHub][11]. You can download the code and its documentation, give it a try, submit comments and feedback, and help spread it to more open source advocates. Embedded systems should belong to their users, and there are too many embedded developers out there who don't realize what's available. + +If you're a developer, help hack on RT-Thread Smart! As the RT-Thread project continues to advance, we aim to make the exciting worlds of IoT and edge computing open source. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/rt-thread-smart + +作者:[Zhu Tianlong][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/zhu-tianlong +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LAW-Internet_construction_9401467_520x292_0512_dc.png?itok=RPkPPtDe (An intersection of pipes.) +[2]: https://opensource.com/article/20/6/open-source-rtos +[3]: https://www.rt-thread.io/ +[4]: https://opensource.com/sites/default/files/uploads/rt-thread-smart.png (RT-Thread Smart architecture) +[5]: https://creativecommons.org/licenses/by-sa/4.0/legalcode +[6]: https://musl.libc.org/ +[7]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains +[8]: https://scons.org/ +[9]: https://opensource.com/article/19/7/introduction-gnu-autotools +[10]: https://opensource.com/article/21/5/cmake +[11]: https://github.com/RT-Thread/rt-thread/tree/rt-smart diff --git a/sources/tech/20210711 Explore waterways with this open source nautical navigation tool.md b/sources/tech/20210711 Explore waterways with this open source nautical navigation tool.md new file mode 100644 index 0000000000..2509b03452 --- /dev/null +++ b/sources/tech/20210711 Explore waterways with this open source nautical navigation tool.md @@ -0,0 +1,94 @@ +[#]: subject: (Explore waterways with this open source nautical navigation tool) +[#]: via: (https://opensource.com/article/21/7/open-source-nautical-navigation) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Explore waterways with this open source nautical navigation tool +====== +Whether you're sailing down a local river or setting out on the open +seas, keep track of your nautical location with OpenCPN. +![Boat helm at sunset for navigation][1] + +If you're traveling by boat down your local waterway or sailing around the world, you can bring great navigation software with you and maintain your commitment to open source software. [OpenCPN][2] is free and open source software developed by sailors. It serves as the primary navigation interface for vessels with full-time helm-visible navigational suites. The software is written in C and released under a [GPLv2 license][3]. + +### Install OpenCPN + +OpenCPN can be installed on Linux, macOS, or Windows. Packages are available for [Fedora][4], [Ubuntu][5], and [Raspberry Pi][6]. I installed OpenCPN on my Linux laptop using [Flatpak][7]. For macOS and Windows, you can download and install packages from the [OpenCPN website][8]. + +There's also an [Android app][9] version available from the Google Play store. + +### Use OpenCPN + +Once it's installed, launch OpenCPN to try it out. The main menu bar is located on the left. + +The first choice from the top is **Options**. Here, you can select how the program appears in the display and what units of measurement of speed, distance, and depth to use. You also can set how latitude and longitude are displayed in [decimal degrees][10]. + +![OpenCPN map showing latitude and longitude measurements][11] + +(Don Watkins, [CC BY-SA 4.0][12]) + +### Get charts + +OpenCPN doesn't come preinstalled with charts. Which charts you choose to install are generally determined by your location and, potentially, your destination. + +Many free [charts are available][13], including those from the US NOAA Office of Coast Survey, Marinha Do Brasil (which includes parts of Antarctica), East Asia Hydrographic Commission, many sources of inland European waterway charts, and many other sources. The chart page also links to commercial sources, should you require them. + +### Learn more + +The project provides an excellent [quickstart guide][14] to make it easy for new users. + +The OpenCPN project also has excellent [documentation][15] to guide you through the installation and setup process. It provides step-by-step directions for first use and [installing charts][16]. The program also comes with a list of [supplementary software][17] you can use with it. + +OpenCPN is available in 20 languages. There are lots of how-to videos available on [Vimeo][18] and [YouTube][19] to help you become familiar with the software. + +![OpenCPN map of Long Island and Nantucket Sounds][20] + +(Don Watkins, [CC BY-SA 4.0][12]) + +### Get involved + +David S. Register is the lead developer for the project. He originally developed OpenCPN in 2009 for his own use. Other folks expressed an interest in his software, and now there are thousands of users and more than 40 active developers worldwide. + +You can [get involved][21] with the project by consulting its excellent [developer documentation][22]. + +Take a look at two open source applications that bring the far reaches of space a little bit closer. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/open-source-nautical-navigation + +作者:[Don Watkins][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/boat-helm-sunset.jpg?itok=g1MYhF_s (Boat helm at sunset) +[2]: https://opencpn.org/ +[3]: https://github.com/OpenCPN/OpenCPN/blob/master/COPYING.gplv2 +[4]: https://opencpn.org/wiki/dokuwiki/doku.php?id=opencpn:opencpn_user_manual:getting_started:opencpn_installation:fedora +[5]: https://opencpn.org/wiki/dokuwiki/doku.php?id=opencpn:opencpn_user_manual:getting_started:opencpn_installation:ubuntu_ppa +[6]: https://opencpn.org/wiki/dokuwiki/doku.php?id=opencpn:opencpn_user_manual:getting_started:opencpn_installation:raspberrypi_rpi2 +[7]: https://opencpn.org/wiki/dokuwiki/doku.php?id=opencpn:opencpn_user_manual:getting_started:opencpn_installation:flatpak +[8]: https://opencpn.org/OpenCPN/info/downloadopencpn.html +[9]: https://www.bigdumboat.com/aocpn/cpnapp.html +[10]: http://wiki.gis.com/wiki/index.php/Decimal_degrees +[11]: https://opensource.com/sites/default/files/uploads/opencpn-map.png (OpenCPN map showing latitude and longitude measurements) +[12]: https://creativecommons.org/licenses/by-sa/4.0/ +[13]: https://opencpn.org/OpenCPN/info/chartsource.html +[14]: https://opencpn.org/OpenCPN/info/quickstart.html +[15]: https://opencpn.org/wiki/dokuwiki/doku.php?id=opencpn:opencpn_user_manual:getting_started:opencpn_installation +[16]: https://opencpn.org/wiki/dokuwiki/doku.php?id=opencpn:opencpn_user_manual:getting_started:chart_installation +[17]: https://opencpn.org/wiki/dokuwiki/doku.php?id=opencpn:supplementary_hardware +[18]: https://vimeo.com/user17026077/videos +[19]: https://www.youtube.com/results?search_query=OpenCPN +[20]: https://opensource.com/sites/default/files/uploads/opencpn-map2.png (OpenCPN map of Long Island and Nantucket Sounds) +[21]: https://github.com/OpenCPN/OpenCPN +[22]: https://opencpn.org/wiki/dokuwiki/doku.php?id=opencpn:developer_manual diff --git a/sources/tech/20210711 How to Dual Boot Fedora and Windows.md b/sources/tech/20210711 How to Dual Boot Fedora and Windows.md new file mode 100644 index 0000000000..023ed5963b --- /dev/null +++ b/sources/tech/20210711 How to Dual Boot Fedora and Windows.md @@ -0,0 +1,242 @@ +[#]: subject: (How to Dual Boot Fedora and Windows) +[#]: via: (https://itsfoss.com/dual-boot-fedora-windows/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +How to Dual Boot Fedora and Windows +====== + +_**Brief:** This detailed tutorial shows you **how to dual boot Fedora Linux with Windows 10**, step-by-step, accompanied by proper screenshots._ + +Dual booting Linux and Windows is one of the popular ways to enjoy the full potential of the two operating systems. You have both Linux and Windows installed on the same system and you can choose which one to use after starting your system. + +![On the grub screen, you can select the operating system][1] + +If you have a system with Windows installed already, you’ll learn how to install Fedora alongside Windows in this tutorial. + +### Installing Fedora alongside Windows + +![][2] + +The tutorial has been performed on a system with Windows already installed, GPT partitioning and UEFI boot. It should be applicable to other systems with MBR partitioning and legacy BIOS system as well, but I cannot confirm that. + +Note: If your Windows system uses BitLocker encryption, it will be a good idea to disable it first before you go on installing Fedora. + +#### Requirements + +Here’s what you’ll need to follow this tutorial: + + * A system preinstalled with Windows + * Good speed internet connection + * A USB key (pen drive) with at least 4 GB in size + * Optional: External USB disk for making back up of your existing data on Windows. + * Optional: Windows recovery or bootable disk (if you encounter any major boot issues, you can fix with it). + + + +Let’s see the steps. + +#### Step 1: Make a backup of data on your Windows system [optional] + +Backup is always a good idea. You will be dealing with the disk partitions. In the rare unfortunate case, if you make a mistake and delete the wrong partition, you’ll lose your data. + +The simplest way would to be to copy the data in Documents, Videos, Music, Pictures and other folders to an external USB disk. You can use an external HDD (slower but cheaper) or SSD (faster but expensive) and copy the important files and folders on it. + +Preview | Product | Price | +---|---|---|--- +![SanDisk 500GB Extreme Portable SSD - Up to 1050MB/s - USB-C, USB 3.2 Gen 2 - External Solid State Drive - SDSSDE61-500G-G25][3] ![SanDisk 500GB Extreme Portable SSD - Up to 1050MB/s - USB-C, USB 3.2 Gen 2 - External Solid State Drive - SDSSDE61-500G-G25][3] | [SanDisk 500GB Extreme Portable SSD - Up to 1050MB/s - USB-C, USB 3.2 Gen 2 - External Solid State...][4] | $89.99[][5] | [Buy on Amazon][6] +Preview | Product | Price | +---|---|---|--- +![Toshiba Canvio Advance 1TB Portable External Hard Drive USB 3.0, Black - HDTCA10XK3AA][7] ![Toshiba Canvio Advance 1TB Portable External Hard Drive USB 3.0, Black - HDTCA10XK3AA][7] | [Toshiba Canvio Advance 1TB Portable External Hard Drive USB 3.0, Black - HDTCA10XK3AA][8] | $51.99[][5] | [Buy on Amazon][9] + +#### Step 2: Make some free space for Fedora installation + +You need to create a partition where you’ll be installing Fedora. If you just have C drive, shrink it. If you have D, E or F drive, see if you can move their data to some other partition and delete or shrink one of them. Anything above 40 GB should be comfortable enough space for Fedora. + +In the Windows menu, search for ‘disk partitions’ and go to ‘Create and format hard disk partitions’. + +![][10] + +In the Disk Management tool, right-click on the drive which you want to partition and select **shrink volume**. + +If you have just one partition like this, you need to make some free space out of it for Linux. If you have several partitions of considerable size, use any of them except C drive because it may erase the data. + +![][11] + +#### Step 3: Making a live USB of Fedora in Windows + +Now, this can be done in different ways. You can download the ISO and [use Etcher][12] or Rufus or some other tool to write the ISO image to the USB disk. + +However, Fedora provides a dedicated tool for downloading and making live USB. I am going to use that in this tutorial. The Fedora team put some effort in creating this tool, so why not use it. + +But first, **plug in the USB key**. Now, go to the download page of Fedora: + +[Fedora Download][13] + +You’ll see the option to download the Fedora Media Writer tool for Windows. + +![][14] + +It will download an exe file. Once downloaded, go to your downloads folder and double-click the FedoraMediaWriter exe file to install the Fedora Media Writer tool. Just keep on hitting next. + +![][15] + +Once installed, run the Fedora Media Writer tool. But before that, **make sure that you have plugged in the USB**. + +It will give you the option to install various editions of Fedora. For desktops, go with Workstation. + +![][16] + +On the next screen, you’ll get the option to create live USB. When you hit that button, it starts downloading the ISO. It will also recognize your inserted USB key. + +You need to have a good speed internet connection to download the 2 GB of ISO in a comfortable time span. + +![][17] + +After downloading the ISO, it checks the download automatically and then gives you the option to write the ISO image to the USB disk, i.e. create the live USB. Hit the “Write to Disk” button. + +![][18] + +It will take a couple of minutes to complete the process. It displays “Finished” message and you can close the Fedora Media Writer tool now. + +![][19] + +Good! So now you have the Fedora live USB ready with you. Time to use it for installing Fedora with Windows. + +#### Step 4: Boot from live USB and install Fedora + +Some systems do not allow you to boot from live USB with secure boot. If that’s the case with you, please [disable secure boot][20]. + +At the screen that shows the logo of your system manufacturer, press the **F2 or F10 or F12** key. You may try pressing all of them one by one if you are not sure of the key. But **be quick** when you do that otherwise it will boot into the operating system. + +This key is different for different brand of computers. Some may even use **Esc** or **Del** keys for this purpose. + +![Quickly press F2, F10 or F12 keys at the screen showing your system manufacturer’s logo][21] + +In some rare cases, you may have to [access the UEFI boot settings from within Windows][22]. + +In the BIOS settings, normally, you should see a screen like this. Here, you use the arrow keys to move down to USB option and press enter to boot from the USB. Please note that the screen may look different in different systems. + +![][23] + +If things go right, you should see a screen like below. **Go with the first option “Start Fedora Workstation”:** + +![][24] + +After some seconds, you should boot into the live Fedora session and see the option to try or install it. Go with “Install to Hard Drive”. + +![][25] + +It will ask to choose the language of choice for the installation process. + +![][26] + +The next screen is important. If you had created the free space in the step 2, you should be able to hit on the “Begin Installation”. If you see an exclamation mark on the disk icon under System, click on it and see what kind of disk configuration you can use here. + +If you have more than one disk, you can choose which disk to use for Fedora. + +![][27] + +Select the disk and click on Done. You may see a warning message now. In my case, I did not create free space in the step 2 and hence it complained that there is not enough free space to install Fedora. + +![][28] + +I clicked on reclaim space and shrank the Windows partition here. + +![][29] + +After this, the “Begin Installation” option appeared to start the installation. + +![][30] + +Now it’s just a waiting game. It will take a few minutes to extract files and install them. + +![][31] + +When the process completes, you’ll see the “Finish Installation” button. Hit it. + +![][32] + +You’ll be back to Fedora live session. Click the top right corner to bring down the menu and select Restart. + +![][33] + +When the system starts now, you should see the [Grub bootloader][34] screen with option to boot into Fedora and Windows. + +![][1] + +#### Step 5: Complete Fedora setup + +You are almost there. Did you notice that Fedora didn’t ask you to enter username and password? Many distributions like Ubuntu ask you to create an admin user during the installation itself. On the other hand, Fedora gives you this option when you log in to the installed system for the first time. + +When you first log in, it runs a setup and creation of user and password is part of this initial setup. + +![][35] + +![][36] + +![][37] + +Once you do that, you are ready to enjoy Fedora Linux. + +![][38] + +That’s it. You can enjoy Fedora Linux and Windows in dual boot mode on the same system. + +If you have any questions or if you are facing any issues while following this tutorial, please let me know in the comment system. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/dual-boot-fedora-windows/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/dual-boot-grub-screen-fedora-windows.jpg?resize=800%2C350&ssl=1 +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/07/fedora-windows-dual-boot.jpg?resize=800%2C450&ssl=1 +[3]: https://i1.wp.com/m.media-amazon.com/images/I/41zwkV8VfPL._SL160_.jpg?ssl=1 +[4]: https://www.amazon.com/dp/B08GTXVG9P?tag=chmod7mediate-20&linkCode=ogi&th=1&psc=1 (SanDisk 500GB Extreme Portable SSD - Up to 1050MB/s - USB-C, USB 3.2 Gen 2 - External Solid State Drive - SDSSDE61-500G-G25) +[5]: https://www.amazon.com/gp/prime/?tag=chmod7mediate-20 (Amazon Prime) +[6]: https://www.amazon.com/dp/B08GTXVG9P?tag=chmod7mediate-20&linkCode=ogi&th=1&psc=1 (Buy on Amazon) +[7]: https://i0.wp.com/m.media-amazon.com/images/I/31-nRLIONWL._SL160_.jpg?ssl=1 +[8]: https://www.amazon.com/dp/B08JKFY8FH?tag=chmod7mediate-20&linkCode=ogi&th=1&psc=1 (Toshiba Canvio Advance 1TB Portable External Hard Drive USB 3.0, Black - HDTCA10XK3AA) +[9]: https://www.amazon.com/dp/B08JKFY8FH?tag=chmod7mediate-20&linkCode=ogi&th=1&psc=1 (Buy on Amazon) +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/03/disc-management-windows.png?resize=800%2C561&ssl=1 +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/04/making-free-space-for-dual-boot.jpg?resize=1226%2C728&ssl=1 +[12]: https://itsfoss.com/install-etcher-linux/ +[13]: https://getfedora.org/en/workstation/download/ +[14]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/download-fedora-media-writer-tool.png?resize=800%2C373&ssl=1 +[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/installing-Fedora-Media-Writer-tool-Windows.png?resize=745%2C581&ssl=1 +[16]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/07/fedora-media-writer-1.png?resize=800%2C425&ssl=1 +[17]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/fedora-media-writer-2.jpg?resize=800%2C422&ssl=1 +[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/writing-fedora-iso-to-usb-with-Fedora-Media-Writer-Tool.png?resize=800%2C285&ssl=1 +[19]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/fedoa-live-usb-with-fedora-media-writer.png?resize=800%2C300&ssl=1 +[20]: https://itsfoss.com/disable-secure-boot-windows/ +[21]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/04/acer-predator-boot.jpg?resize=800%2C600&ssl=1 +[22]: https://itsfoss.com/access-uefi-settings-windows-10/ +[23]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/select-boot-from-live-usb.jpg?resize=800%2C330&ssl=1 +[24]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/07/fedora-live-screen.jpg?resize=800%2C350&ssl=1 +[25]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/Fedora-install-screen.jpg?resize=800%2C450&ssl=1 +[26]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/installing-fedora-1.png?resize=800%2C450&ssl=1 +[27]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/installing-fedora-2.png?resize=800%2C450&ssl=1 +[28]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/installing-fedora-3.png?resize=800%2C450&ssl=1 +[29]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/07/installing-fedora-4.png?resize=800%2C450&ssl=1 +[30]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/installing-fedora-5.png?resize=800%2C450&ssl=1 +[31]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/07/installing-fedora-6.png?resize=800%2C450&ssl=1 +[32]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/07/installing-fedora-7.png?resize=800%2C450&ssl=1 +[33]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/restart-gnome-fedora.jpg?resize=799%2C439&ssl=1 +[34]: https://itsfoss.com/what-is-grub/ +[35]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/fedora-setup-1.png?resize=800%2C575&ssl=1 +[36]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/07/fedora-setup-2.png?resize=800%2C593&ssl=1 +[37]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/fedora-setup-3.png?resize=800%2C591&ssl=1 +[38]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/fedora-setup-completed.jpg?resize=800%2C500&ssl=1 diff --git a/sources/tech/20210711 Ubuntu 21.10 Impish Indri - New Features and Release Date.md b/sources/tech/20210711 Ubuntu 21.10 Impish Indri - New Features and Release Date.md new file mode 100644 index 0000000000..50c7bd5414 --- /dev/null +++ b/sources/tech/20210711 Ubuntu 21.10 Impish Indri - New Features and Release Date.md @@ -0,0 +1,166 @@ +[#]: subject: (Ubuntu 21.10 Impish Indri – New Features and Release Date) +[#]: via: (https://www.debugpoint.com/2021/07/ubuntu-21-10/) +[#]: author: (Arindam https://www.debugpoint.com/author/admin1/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Ubuntu 21.10 Impish Indri – New Features and Release Date +====== +Final release of 2021, Ubuntu 21.10 Impish Indri development is in +progress. In this post, we sum up the new features known so far and +planned release dates. +This post includes information about ongoing development. The information may change frequently, and this page is regularly updated until the final release. + +This page contains the following topics – + + * [Ubuntu 21.10 – Code name history][1] + * [New Features in desktop flavor][2] + * [Ubuntu Official flavor information][3] + * [Release schedule][4] + * [Daily-build .ISO download][5] + * [Canary build .ISO download][6] + + + +Before we list out the features, you should remember that, we are at a very early stage of the development considering October as of publishing this. And the final pieces may change as we move closer to the final release. + +Historically, October releases are somewhat quieter but impactful. They create the base for next LTS in every alternate year. So having said that, this is an important release due to many factors. + +### The Code Name + +Following the trend, Ubuntu 21.10 is code named “impish indri” as we are at “I” based names. The “Indri” refers to _“babakoto, is one of the largest living lemurs, with a head-and-body length of about 64–72 cm and a weight of between 6 to 9.5 kg. It has a black and white coat and maintains an upright posture when climbing or clinging” (from Wikipedia)_. Well, the final mascot is yet to be revealed. + +So, all the packages and repo is tagged with “impish” for this version of Ubuntu. + +Let’s take a look at other new features. + +### Ubuntu 21.10 New Features + +![Ubuntu 21.10 Desktop \(daily build\)][7] + + * Ubuntu 21.10 would feature **Linux Kernel 5.14**. This is currently in development and will be released before the feature freeze. + + + * If you are wondering of about GNOME, well yes, Ubuntu 21.10 features [GNOME 40 desktop][8] – but with a twist. The **GNOME 40** version brings some fundamental changes to GNOME desktop, which you are already aware of by now. But with the usual left fixed dock! So, the customized GNOME 40 with left fixed doc, eliminates the bottom dock of vanilla GNOME 40. + + + * So, initially it would feel a bit strange with have **left fixed dock** with horizontal workspaces, overview and scrolling. But it would be interesting to observe user reactions and feedback once it releases. + + + * Version wise, this release would feature **GNOME 40.3** (it’s due by July 2021). + + + * A brand **new Desktop Installer** which would replace the decade old Ubiquity. This is created in collaboration with Google in Flutter and gives a nice and easy way of installing Ubuntu. We covered more about this installer in detail when it was launched. You can read the coverage [here][9]. + + + +![New Installer – Ubuntu 21.10][10] + + * The new installer is still in Canary build and not arrived in daily build as of publishing this. And when I tested, it has many bugs which are simple ones. I hope they would be sorted out before final release. + + + * The default theme would be set to **Yaru Light**. As per the Ubuntu team, it is difficult to maintain a mixed theme with both and dark and light together. + + + * In the prior Ubuntu 21.04, the Wayland display server is made default. In this release, **NVIDIA** driver users also would be able to Wayland, hopefully. + + + * With the **wallpaper** competition is back, we expect a stunning default wallpaper with “Indri” mascot. Already there are beautiful wallpapers submitted by the community, and they look promising. + + + * The applications and packages sees their respective version upgrades in this release. Here’s a quick summary. + + + 1. Firefox 89 + 2. LibreOffice 7.1 (I am still hopeful whether [LibreOffice 7.2][11] is an option) + 3. Thunderbird 78.12 + + + +### Official Flavors + +The official Ubuntu desktop flavors would have their respective version upgrades. Here’s a quick update. + + * Xubuntu with Xfce 4.16 + * Ubuntu MATE with MATE 1.24 + * Kubuntu with KDE Plasma 5.22 (I don’t think Plasma 5.23 would be ready before BETA) + + + +### Ubuntu 21.10 Release Date + +Ubuntu 21.10 releases on October 14, 2021. Here is the schedule of this release. + + * **Feature Freeze**: August 19, 2021 + * **Beta Release**: September 23, 2021 + * **Final Releas**e: October 14, 2021 + + + +### Daily Build Downloads for Ubuntu 21.10 + +Default desktop image .ISO for daily build is available in below link. The following images are unstable so, do not use this as your serious work. Try for testing only. + +[download ubuntu 21.10 daily build – GNOME][12] + +#### Other flavors + +Ubuntu Flavor | Link for Daily build .iso image (64 bit) +---|--- +Ubuntu 21.10 Desktop (GNOME) | +Xubuntu 21.10 | +Ubuntu MATE 21.10 | +Ubuntu Kylin 21.10 | +Lubuntu 21.10 | +Kubuntu 21.10 | +Ubuntu Budgie 21.10 | + +### Untested Canary build + +The daily canary build can be downloaded from the below link. This is super unstable and did not pass automatic testing. So, unless absolutely necessary, do not use this .iso. + + + +### Closing Notes + +I am specifically interested on the new desktop installer. Because it gives a repair option and a brand-new way of installing Ubuntu. We know there are many powerful installers out there like Calamares – but it would be interesting to see Ubuntu’s new Flutter based app. And the adaptation of GNOME 40 is really a thing to observe with more users. + +I will keep this post updated with the latest info when available with details. + + * _[Official change log and schedule][13]_ + * _[Launchpad source][14]_ + + + +* * * + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2021/07/ubuntu-21-10/ + +作者:[Arindam][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lujun9972 +[1]: tmp.Bd5zVlb4BJ#code-name +[2]: tmp.Bd5zVlb4BJ#new-features +[3]: tmp.Bd5zVlb4BJ#official-flavors +[4]: tmp.Bd5zVlb4BJ#release-schedule +[5]: tmp.Bd5zVlb4BJ#daily-build-download +[6]: tmp.Bd5zVlb4BJ#canary-build-download +[7]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/Ubuntu-21.10-Desktop-daily-build-1024x535.jpeg +[8]: https://www.debugpoint.com/2021/03/gnome-40-release/ +[9]: https://www.debugpoint.com/2021/02/new-ubuntu-desktop-installer/ +[10]: https://www.debugpoint.com/blog/wp-content/uploads/2021/07/New-Installer-Ubuntu-21.10.jpeg +[11]: https://www.debugpoint.com/2021/05/libreoffice-7-2/ +[12]: https://cdimage.ubuntu.com/daily-live/current/ +[13]: https://discourse.ubuntu.com/t/impish-indri-release-schedule/18540 +[14]: https://launchpad.net/ubuntu/impish diff --git a/sources/tech/20210712 Set up temperature sensors in your home with a Raspberry Pi.md b/sources/tech/20210712 Set up temperature sensors in your home with a Raspberry Pi.md new file mode 100644 index 0000000000..56e46b4630 --- /dev/null +++ b/sources/tech/20210712 Set up temperature sensors in your home with a Raspberry Pi.md @@ -0,0 +1,205 @@ +[#]: subject: (Set up temperature sensors in your home with a Raspberry Pi) +[#]: via: (https://opensource.com/article/21/7/temperature-sensors-pi) +[#]: author: (Chris Collins https://opensource.com/users/clcollins) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Set up temperature sensors in your home with a Raspberry Pi +====== +Find out how hot your house is with a simple home Internet of Things +project. +![Orange home vintage thermostat][1] + +It's HOT! I suppose I can't complain too much about living in paradise, but when my wife and I moved to Hawaii last fall, I didn't really think too much about the weather. Don't get me wrong, the weather is lovely pretty much all the time, and we keep our windows open 24/7, but that means it is pretty warm in the house right now in the middle of summer. + +So, where does all this humble bragging intersect with open source? Well, we're planning to get a whole-house fan—one of those big ones that suck all the air out of your house and force it into the attic, pushing all the hot air out of the attic in the process. I am _sure_ this will make the house way cooler, but the geek in me wants to know just how much cooler. + +So today, I'm playing with temperature sensors, [Raspberry Pis][2], and [Python][3]. + +Play along at home! Nothing like a little #CitizenScience! + +![DHT22 sensor and Raspberry Pi Zero W][4] + + Charming little development environment, isn't it? (Chris Collins, [CC BY-SA 4.0][5]) + +Yes, OK, I could just buy a thermometer or two, check them each day, and see what happens. But why do that when you can totally overengineer a solution, automate the data collection, and graph it all over time, amirite? + +Here's what I need: + + * Raspberry Pi Zero W (or, really, any Raspberry Pi) + * DHT22 digital sensor + * SD card + + + +### Connect the DHT22 sensor to the Raspberry Pi + +You can find a bunch of inexpensive DHT22 temperature and humidity sensors with a quick web search. The DHT22 is a digital sensor, making it easy to interact with. If you purchase a raw sensor, you'll need a resistor and some soldering skills to get it working (check out Pi My Life Up's DHT22 article for [great instructions on working with the raw sensor][6]), but you can also purchase one with a small PCB that includes all that, which is what I did. + +The DHT22 with the PCB attached has three pins: a Positive pin (marked with **+**), a Data pin, and a Ground pin (marked with **-**). You can wire the DHT22 directly to the Raspberry Pi Zero W. I used Raspberry Pi Spy's [Raspberry Pi GPIO guide][7] to make sure I connected everything correctly. + +The Positive pin provides power from the Pi to the DHT22. The DHT22 runs on 3v-6v, so I selected one of the 5v pins on the Raspberry Pi to provide the power. I connected the Data pin on the DHT22 to one of the Raspberry Pi GPIO pins. I am using GPIO4 for this, but any would work; just make a note of the one you choose, as the Python code that reads the data from the sensor will need to know which pin to read from. Finally, I connected the Ground pin on the DHT22 to a ground pin on the Raspberry Pi header. + +This is how I wired it up: + + * DHT22 Positive pin <-> Raspberry Pi GPIO v5 pin (#2) + * DHT22 Data pin <-> Raspberry Pi GPIO4 pin (#7) + * DHT22 Ground pin <-> Raspberry Pi Group pin (#6) + + + +This diagram from Raspberry Pi Spy shows the pin layout for the Raspberry Pi Zero W (among others). + +![Raspberry Pi GPIO header diagram][8] + +(Copyright 2021, [Matt Hawkins][7]) + +### Install the DHT sensor software + +Before proceeding, make sure you have an operating system installed on the Raspberry Pi Zero W and can connect to it remotely or with a keyboard. If not, consult my article about [customizing different operating system images][9] for Raspberry Pi. I am using [Raspberry Pi OS Lite][10], released May 7, 2021, as the image for the Raspberry Pi Zero W. + +Once you've installed the operating system on an SD card and booted the Raspberry Pi from the card, there are only a couple of other software packages to install to interact with the DHT22. + +First, install the Python Preferred Installer Program (pip) with `apt-get`, and then use pip to install the [Adafruit DHT sensor library for Python][11] to interact with the DHT22 sensor. + + +``` +# Install pip3 +sudo apt-get install python3-pip + +# Install the Adafruit DHT sensor library +sudo pip3 install Adafruit_DHT +``` + +### Get sensor data with Python + +With the DHT libraries installed, you can connect to the sensor and retrieve temperature and humidity data. + +Create a file with: + + +``` +#!/usr/bin/env python3 + +import sys +import argparse +import time + +# This imports the Adafruit DHT software installed via pip +import Adafruit_DHT + +# Initialize the DHT22 sensor +SENSOR = Adafruit_DHT.DHT22 + +# GPIO4 on the Raspberry Pi +SENSOR_PIN = 4 + +def parse_args(): +    parser = argparse.ArgumentParser() +    parser.add_argument("-f", "--fahrenheit", help="output temperature in Fahrenheit", action="store_true") + +    return parser.parse_args() + +def celsius_to_fahrenheit(degrees_celsius): +        return (degrees_celsius * 9/5) + 32 + +def main(): +    args = parse_args() + +    while True: +        try: +            # Gather the humidity and temperature +            # data from the sensor; GPIO Pin 4 +            humidity, temperature = Adafruit_DHT.read_retry(SENSOR, SENSOR_PIN) + +        except RuntimeError as e: +            # GPIO access may require sudo permissions +            # Other RuntimeError exceptions may occur, but +            # are common.  Just try again. +            print(f"RuntimeError: {e}") +            print("GPIO Access may need sudo permissions.") + +            time.sleep(2.0) +            continue + +        if args.fahrenheit: +            print("Temp: {0:0.1f}*F, Humidity: {1:0.1f}%".format(celsius_to_fahrenheit(temperature), humidity)) +        else: +            print("Temp:{0:0.1f}*C, Humidity: {1:0.1f}%".format(temperature, humidity)) + +        time.sleep(2.0) + +if __name__ == "__main__": +    main() +``` + +The important bits here are initializing the sensor and setting the correct GPIO pin to use on the Raspberry Pi: + + +``` +# Initialize the DHT22 sensor +SENSOR = Adafruit_DHT.DHT22 + +# GPIO4 on the Raspberry Pi +SENSOR_PIN = 4 +``` + +Another important bit is reading the data from the sensor with the variables set above for the sensor and pin: + + +``` +# This connects to the sensor "SENSOR" +# Using the Raspberry Pi GPIO Pin 4, "SENSOR_PIN" +    humidity, temperature = Adafruit_DHT.read_retry(SENSOR, SENSOR_PIN) +``` + +Finally, run the script! You should end up with something like this: + +![Output of the sensor script][12] + +84 degrees and 50% humidity. Oof! Hot and humid in here! (Chris Collins, [CC BY-SA 4.0][5]) + +Success! + +### Where to go from here + +I have three of these DHT22 sensors and three Raspberry Pi Zero Ws connected to my WiFi. I've installed them into some small project boxes, hot-glued the sensors to the outside, and set them up in my living room, office, and bedroom. With this setup, I can collect sensor data from them whenever I want by SSHing into the Raspberry Pi and running this script. + +But why stop there? Manually SSHing into them each time is tedious and too much work. I can do better! + +In a future article, I'll explain how to set up this script to run automatically at startup with a [systemd service][13], set up a web server to display the data, and instrument this script to export data in a format that can be read by [Prometheus][14], a monitoring system and time series database. I use Prometheus at work to collect data about OpenShift/Kubernetes clusters, plot trends, and create alerts based on the data. Why not go totally overboard and do the same thing with temperature and humidity data at home? This way, I can get baseline data and then see how well the whole-house fan changes things! + +#CitizenScience! + +Jeff Geerling is a father concered with his kid's cold room and their sleep because of it. To... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/temperature-sensors-pi + +作者:[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/home-thermostat.jpg?itok=wuV1XL7t (Orange home vintage thermostat) +[2]: https://www.raspberrypi.org/ +[3]: https://www.python.org/ +[4]: https://opensource.com/sites/default/files/uploads/dht22.png (DHT22 sensor and Raspberry Pi Zero W) +[5]: https://creativecommons.org/licenses/by-sa/4.0/ +[6]: https://pimylifeup.com/raspberry-pi-humidity-sensor-dht22/ +[7]: https://www.raspberrypi-spy.co.uk/2012/06/simple-guide-to-the-rpi-gpio-header-and-pins/ +[8]: https://opensource.com/sites/default/files/uploads/raspberry_pi_gpio_layout_model_b_plus.png (Raspberry Pi GPIO header diagram) +[9]: https://opensource.com/article/20/5/disk-image-raspberry-pi +[10]: https://www.raspberrypi.org/software/operating-systems/ +[11]: https://github.com/adafruit/Adafruit_Python_DHT +[12]: https://opensource.com/sites/default/files/uploads/temperature_sensor.png (Output of the sensor script) +[13]: https://www.freedesktop.org/software/systemd/man/systemd.service.html +[14]: https://prometheus.io/ diff --git a/sources/tech/20210712 Use Docker Compose with Podman to Orchestrate Containers on Fedora.md b/sources/tech/20210712 Use Docker Compose with Podman to Orchestrate Containers on Fedora.md new file mode 100644 index 0000000000..f5c65324cf --- /dev/null +++ b/sources/tech/20210712 Use Docker Compose with Podman to Orchestrate Containers on Fedora.md @@ -0,0 +1,161 @@ +[#]: subject: (Use Docker Compose with Podman to Orchestrate Containers on Fedora) +[#]: via: (https://fedoramagazine.org/use-docker-compose-with-podman-to-orchestrate-containers-on-fedora/) +[#]: author: (Mehdi Haghgoo https://fedoramagazine.org/author/powergame/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Use Docker Compose with Podman to Orchestrate Containers on Fedora +====== + +![][1] + +Photo by [Jonas][2] on [Unsplash][3] + +Docker Compose is an open-source tool used by developers for orchestrating containers locally or in production. If you are new to containers, I suggest checking out the following links: + + * [Get Started with Docker][4] + * [A Practical Introduction to Container Terminology][5] + * [Using Pods with Podman on Fedora][6] + * [Podman with Capabilities on Fedora][7] + + + +Podman, a powerful alternative to Docker CLI, has attracted a lot of developers recently. However, Podman users faced a challenge. Docker Compose was expected to work with Docker daemon only. So, Podman users had to use other alternatives to Docker Compose like using [Podman Compose][8] that runs services defined in the Compose file inside a Podman pod. (To learn more about Podman Compose, check out my article [Manage Containers on Fedora with Podman Compose][9] on [Fedora Magazine][10].) Another method was manually running different containers of an application and then generating a Kubernetes file with + +podman generate + +to be later re-run with + +podman play + +. (To learn more about this method, check out this [Moving from docker-compose to Podman pods][11] on [Red Hat][12].) + +### Podman and Docker Compose + +Both of the Docker Compose alternatives mentioned previously have their limitations. At the least they need you to know a little bit more than Container and Docker basics.The good news is that Podman has added [support for Docker Compose][13] since version 3.0 so you can now run your traditional docker-compose.yml files with Podman backend. Podman does this by setting up a UNIX socket for + +docker-compose + +to interact with, similar to the Docker daemon. In this article I will show you how to use Docker Compose both with rootful and rootless Podman. + +### Required Software + +Install the following packages on your system to run Docker Compose with Podman: + + * podman: Tool for managing containers + * docker-compose: Tool for orchestrating containers + * podman-docker: Installs a script named docker that emulates docker CLI using Podman. Also links Docker CLI man pages and podman. + + + +Install the above packages using dnf: + +``` +sudo dnf install -y podman podman-docker docker-compose +``` + +### Setting Up Podman Socket + +Set up the Podman socket in order for Docker Compose to work: + +``` +sudo systemctl enable podman.socket +sudo systemctl start podman.socket +sudo systemctl status podman.socket +``` + +This sets up a Unix socket in to communicate with Docker Compose and symlinks it to /var/run/docker.sock. To test if you can communicate with the socket, run the following curl command: + +``` +sudo curl -H "Content-Type: application/json" --unix-socket /var/run/docker.sock http://localhost/_ping +``` + +If the output from the above command is OK, it means your setup was successful. + +### Running A Sample Project with Docker Compose + +Now, you can start orchestrating your project by going to the project folder and running + +sudo docker-compose up + +. As an example, I will be using a docker-compose.yml from a sample WordPress project I created as a demo for this article. You can find it . Clone the repository on your system and from within the directory, start docker-compose. + +``` +sudo docker-compose up +``` + +If everything goes well, you will see docker-compose bringing up the services defined in the compose YAML file. Access the new WordPress instance at after the containers are created. To stop the project, you can press Ctrl + C in the terminal where you executed _docker-compose up_. To remove the containers, execute + +``` +sudo docker-compose down +``` + +### Running Docker Compose with Rootless Podman + +The setup shown above uses Podman in root-ful mode. Notice the _sudo_ keyword preceding most of the commands used. Often you will not need to run your projects as root. So, having the option to run docker-compose as a regular user is pretty handy. As of [version 3.2.0][14], Podman supports Docker-Compose with rootless Podman. The setup, however, changes as follows: + +``` +systemctl --user enable podman.socket +systemctl --user start podman.socket +systemctl --user status podman.socket +export DOCKER_HOST=///run/user/$UID/podman/podman.sock +``` + +Note that when starting the podman socket as non-root user, a user-level socket will be created at _/run/user/$UID/podman/podman.sock_, where _$UID_ refers is the non-root user’s user ID. We need to set the DOCKER_HOST environment variable to that socket so that Docker Compose can talk to the correct socket. You can add the environment variable to your ~/.bash_profile to make it persistent across system reboots. In root-ful mode, the socket is created in _/run/podman/podman.sock_ which is symlinked to _/var/run/docker.sock_ (the default socket expected by the docker-compose binary). So, we didn’t need to set DOCKER_HOST variable then. + +Now, in rootless mode, we can simply run the command +``` + +``` + +docker-compose up +``` + +``` + +without “sudo” in the project root folder. This will bring up our WordPress site running on Docker Compose with Podman backend. + +![WordPress instance running with Docker Compose with Podman backend][15] + +### Further Reading: + + * [][13][][16][Running Podman and Docker Compose, Red Hat][13] + * [From Docker Compose to Kubernetes with Podman][17] + * [Convert docker-compose Services to Pods with Podman][18] + + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/use-docker-compose-with-podman-to-orchestrate-containers-on-fedora/ + +作者:[Mehdi Haghgoo][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/powergame/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2021/07/docker-compose-w-podman-816x345.jpg +[2]: https://unsplash.com/@jonason_b?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]: https://unsplash.com/s/photos/docker-container?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: https://docs.docker.com/get-started +[5]: https://developers.redhat.com/blog/2018/02/22/container-terminology-practical-introduction +[6]: https://fedoramagazine.org/podman-pods-fedora-containers/ +[7]: https://fedoramagazine.org/podman-with-capabilities-on-fedora/ +[8]: http://github.com/containers/podman-compose +[9]: https://fedoramagazine.org/manage-containers-with-podman-compose/ +[10]: https://fedoramagazine.org +[11]: https://www.redhat.com/sysadmin/compose-podman-pods +[12]: https://redhat.com +[13]: https://www.redhat.com/sysadmin/podman-docker-compose +[14]: https://github.com/containers/podman/releases/tag/v3.2.0 +[15]: https://fedoramagazine.org/wp-content/uploads/2021/06/Screenshot-from-2021-06-25-06-48-39.png +[16]: tmp.Svb0n6PVdg +[17]: https://www.redhat.com/sysadmin/compose-kubernetes-podman +[18]: https://balagetech.com/convert-docker-compose-services-to-pods/ diff --git a/sources/tech/20210713 Use VS Code to develop in containers.md b/sources/tech/20210713 Use VS Code to develop in containers.md new file mode 100644 index 0000000000..d2248aa19d --- /dev/null +++ b/sources/tech/20210713 Use VS Code to develop in containers.md @@ -0,0 +1,138 @@ +[#]: subject: (Use VS Code to develop in containers) +[#]: via: (https://opensource.com/article/21/7/vs-code-remote-containers-podman) +[#]: author: (Brant Evans https://opensource.com/users/branic) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Use VS Code to develop in containers +====== +Create consistency to avoid problems when you have multiple developers +working on the same project. +![Women programming][1] + +Coding and testing inconsistencies are a risk when you have multiple developers with different development environments working on a project. [Visual Studio Code][2] (VS Code) is an integrated development environment (IDE) that can help minimize these issues. It can be combined with containers to provide separate development environments for each application alongside a consistent development environment. + +VS Code's [Remote - Containers extension][3] enables you to define a container, use that definition to build a container, and develop inside the container. This container definition can be checked into the source code repository along with the application code, which allows all developers to use the same definition to build and develop within a container. + +By default, the Remote - Containers extension uses Docker to build and run the container, but it is easy to use [Podman][4] for container runtimes, and it enables using [rootless containers][5]. + +This article walks you through the setup to develop inside a rootless container using Podman with VS Code and the Remote - Containers extension. + +### Initial configuration + +Before continuing, ensure your Red Hat Enterprise Linux (RHEL) or Fedora workstation is updated with the latest errata and that VS Code and the Remote - Containers extension are installed. (See the [VS Code website][2] for more information on installing.) + +Next, install Podman and its supporting packages with a simple `dnf install` command: + + +``` +`$ sudo dnf install -y podman` +``` + +After you install Podman, configure VS Code to use the Podman executable (instead of Docker) for interacting with the container. Within VS Code, navigate to **File > Preferences > Settings** and click the **>** icon next to **Extensions**. In the dropdown menu that appears, select **Remote - Containers**, and scroll down to find the **Remote > Containers: Docker Path** option. In the text box, replace docker with **podman**. + +![Enter "podman" in the text box][6] + +(Brant Evans, [CC BY-SA 4.0][7]) + +Now that the configurations are done, create and open a new folder or an existing folder for the project in VS Code. + +### Define the container + +This tutorial uses the example of creating a container for Python 3 development. + +The Remote - Containers extension can add the necessary basic configuration files to the project folder. To add these files, open the Command Pallet by entering **Ctrl+Shift+P** on your keyboard, search for **Remote-Containers: Add Development Container Configuration Files**, and select it. + +![Remote-Containers: Add Development Container Configuration Files][8] + +(Brant Evans, [CC BY-SA 4.0][7]) + +In the next pop-up, define the type of development environment you want to set up. For this example configuration, search for the **Python 3** definition and select it. + +![Select Python 3 definition][9] + +(Brant Evans, [CC BY-SA 4.0][7]) + +Next, select the version of Python that will be used in the container. Select the **3 (default)** option to use the latest version. + +![Select the 3 \(default\) option][10] + +(Brant Evans, [CC BY-SA 4.0][7]) + +The Python configuration can also install Node.js, but for this example, **uncheck Install Node.js** and click OK. + +![Uncheck "Install Node.js"][11] + +(Brant Evans, [CC BY-SA 4.0][7]) + +It will create a `.devcontainer` folder containing files named `devcontainer.json` and `Dockerfile`. VS Code automatically opens the `devcontainer.json` file so that you can customize it. + +### Enable rootless containers + +In addition to the obvious security benefits, one of the other reasons to run a container as rootless is that all the files created in the project folder will be owned by the correct user ID (UID) outside the container. To run the development container as a rootless container, modify the `devcontainer.json` file by adding the following lines to the end of it: + + +``` +"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,Z", +"workspaceFolder": "/workspace", + +"runArgs": ["--userns=keep-id"], +"containerUser": "vscode" +``` + +These options tell VS Code to mount the Workspace with the proper SELinux context, create a user namespace that maps your UID and GID to the same values inside the container, and use `vscode` as your username inside the container. The `devcontainer.json` file should look like this (don't forget the commas at the end of the lines, as indicated): + +![Updated devcontainer.json file][12] + +(Brant Evans, [CC BY-SA 4.0][7]) + +Now that you've set up the container configuration, you can build the container and open the workspace inside it. Reopen the Command Palette (with **Ctrl+Shift+P**), and search for **Remote-Containers: Rebuild and Reopen in Container**. Click on it, and VS Code will start to build the container. Now is a great time to take a break (and get your favorite beverage), as building the container may take several minutes. + +![Building the container][13] + +(Brant Evans, [CC BY-SA 4.0][7]) + +Once the container build completes, the project will open inside the container. Files created or edited within the container will be reflected in the filesystem outside the container with the proper user permissions applied to the files. Now, you can proceed with development within the container. VS Code can even bring your SSH keys and Git configuration into the container so that committing code will work just like it does when editing outside the container. + +### Next steps + +Now that you've completed the basic setup and configuration, you can further enhance the configuration's usefulness. For example: + + * Modify the Dockerfile to install additional software (e.g., required Python modules). + * Use a customized container image. For example, if you're doing Ansible development, you could use Quay.io's [Ansible Toolset][14]. (Be sure to add the `vscode` user to the container image via the Dockerfile.) + * Commit the files in the `.devcontainer` directory to the source code repository so that other developers can take advantage of the container definition for their development efforts. + + + +Developing inside a container helps prevent conflicts between different projects by keeping the dependencies and code for each separate. You can use Podman to run containers in a rootless environment that increases security. By combining VS Code, the Remote - Containers extension, and Podman, you can easily set up a consistent environment for multiple developers, decrease setup time, and reduce bugs from differences in development environments in a secure fashion. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/vs-code-remote-containers-podman + +作者:[Brant 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://opensource.com/users/branic +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/collab-team-pair-programming-code-keyboard2.png?itok=WnKfsl-G (Women programming) +[2]: https://code.visualstudio.com/ +[3]: https://code.visualstudio.com/docs/remote/containers +[4]: https://podman.io/ +[5]: https://www.redhat.com/sysadmin/rootless-podman-makes-sense +[6]: https://opensource.com/sites/default/files/uploads/vscode-remote_podman.png (Enter "podman" in the text box) +[7]: https://creativecommons.org/licenses/by-sa/4.0/ +[8]: https://opensource.com/sites/default/files/uploads/adddevelopmentcontainerconfigurationfiles.png (Remote-Containers: Add Development Container Configuration Files) +[9]: https://opensource.com/sites/default/files/uploads/python3.png (Select Python 3 definition) +[10]: https://opensource.com/sites/default/files/uploads/python3default.png (Select the 3 (default) option) +[11]: https://opensource.com/sites/default/files/uploads/unchecknodejs.png (Uncheck "Install Node.js") +[12]: https://opensource.com/sites/default/files/uploads/newdevcontainerjson.png (Updated devcontainer.json file) +[13]: https://opensource.com/sites/default/files/uploads/buildingcontainer.png (Building the container) +[14]: https://quay.io/repository/ansible/toolset diff --git a/sources/tech/20210714 5 Rust tools worth trying on the Linux command line.md b/sources/tech/20210714 5 Rust tools worth trying on the Linux command line.md new file mode 100644 index 0000000000..ba030d55fd --- /dev/null +++ b/sources/tech/20210714 5 Rust tools worth trying on the Linux command line.md @@ -0,0 +1,143 @@ +[#]: subject: (5 Rust tools worth trying on the Linux command line) +[#]: via: (https://opensource.com/article/21/7/rust-tools-linux) +[#]: author: (Sudeshna Sur https://opensource.com/users/sudeshna-sur) +[#]: collector: (lujun9972) +[#]: translator: (amwps290 ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +5 Rust tools worth trying on the Linux command line +====== +Try some new commands for common tasks. +![Terminal command prompt on orange background][1] + +Linux inherited a lot from Unix, which has been around for a half-century. This means most of the tools you use in your Linux terminal probably either have a very long history or were written to emulate those historical commands. It's a point of pride in the POSIX world that tools don't _need_ constant reinvention. In fact, there's a subset of Linux users today who could run a version of Linux from [before they were born][2] without having to learn anything new. It's tried, true, and reliable. + +That doesn't mean there hasn't been evolution, though. All the commands Linux users know and love have been improved over the years. Some have even been replaced entirely and are so common now that few people still care to remember the old ones. Can you imagine Linux without SSH? Well, believe it or not, the `ssh` command replaced one called `rsh`. + +I'm often on the lookout for new commands because I'm always intrigued by the possibility of getting things done more efficiently. If there's a better, faster, or more robust command out there for doing a common task, I want to know about it. And while there's equal opportunity for any language to invent new Linux commands, Rust developers have been delivering an impressive collection of useful general-purpose utilities. + +### Replace man with tealdeer + +Tealdeer provides the `tldr` command, which displays an abbreviated, no-nonsense summary of how a command is used. It's not that manual and info pages aren't useful, because they are, but sometimes they can be a little verbose and a little obtuse. Tealdeer keeps its hints clear and concise, with examples of how to use the command you're struggling to recall. + + +``` +$ tldr tar + +  Archiving utility. +  Often combined with a compression method, such as gzip or bzip2. +  More information: <[https://www.gnu.org/software/tar\>][3]. + +  [c]reate an archive and write it to a [f]ile: + +      tar cf target.tar file1 file2 file3 + +  [c]reate a g[z]ipped archive and write it to a [f]ile: + +      tar czf target.tar.gz file1 file2 file3 + +  [c]reate a g[z]ipped archive from a directory using relative paths: + +      tar czf target.tar.gz --directory=path/to/directory . +[...] +``` + +Read the full article [about tldr][4]. + +### Replace du with dust + +The `du` command gives feedback about disk usage. It's a relatively simple task; likewise, the command is pretty simple, too. The `dust` command is `du` written in Rust, and it uses color-coding and bar graphs for users who prefer added visual context. + + +``` +$ dust + 5.7M   ┌── exa                                   │                                   ██ │   2% + 5.9M   ├── tokei                                 │                                   ██ │   2% + 6.1M   ├── dust                                  │                                   ██ │   2% + 6.2M   ├── tldr                                  │                                   ██ │   2% + 9.4M   ├── fd                                    │                                   ██ │   4% + 2.9M   │ ┌── exa                                 │                                 ░░░█ │   1% +  15M   │ ├── rustdoc                             │                                 ░███ │   6% +  18M   ├─┴ bin                                   │                                 ████ │   7% +  27M   ├── rg                                    │                               ██████ │  11% + 1.3M   │     ┌── libz-sys-1.1.3.crate            │  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │   0% + 1.4M   │     ├── libgit2-sys-0.12.19+1.1.0.crate │  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │   1% + 4.5M   │   ┌─┴ github.com-1ecc6299db9ec823       │  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │   2% + 4.5M   │ ┌─┴ cache                               │  ░░░░░░░░░░░░░░░░░░░░░░░░ +[...] +``` + +Read the full article [about dust][5]. + +### Replace find with fd + +The `find` command is a useful tool for finding files on your computer, but its syntax can be difficult to master. Not only are there a lot of options, but the order of those options can be significant, depending on what you're doing. Some people have [written scripts][6] to abstract the task away from the command. Other people just write a new tool altogether, like `fd`. + +Syntax doesn't get any easier than this: + + +``` +$ fd example +Documents/example.txt +Documents/example-java +Downloads/example.com/index.html +``` + +Read the full article [about fd][7]. + +### Replace ls with exa + +You might not think that the `ls` command would have much room for improvement. But `exa` proves that even the most mundane utility can benefit from small adjustments. For instance, why not have a list command with built-in Git awareness? Why not get extra metadata in your file lists?  + +Read the full [article about exa][8]. + +### Try Tokei + +Unlike the other tools on this list, the `tokei` utility doesn't replace one command, but it does demonstrate how the Linux terminal is—as always—an environment very much in constant growth. The terminal may contain lots of legacy commands, but there are new and exciting commands surfacing all the time. + +When I'm looking at a project in my local file system, and I need to know what languages it contains, I rely on a tool like Tokei. It's a program that displays statistics about a codebase, with wide support for 150 programming languages. I don't need to remember what languages have been used, or how many lines of code there are, or how many blanks or spaces or comments are there. It's a complete code-analysis tool, making my entry into and navigation of the code easy. + + +``` +$ tokei ~/exa/src ~/Work/wildfly/jaxrs +================== +Language   Files Lines Code Comments Blank +Java        46    6135  4324  945     632 +XML         23    5211  4839  473     224 +\--------------------------------- +Rust +Markdown +\----------------------------------- +Total +``` + +Read the full [article about tokei][9]. + +### Find your favorite + +Open source users never have to settle for just a small set of commands, or even just one version of a command. Find the commands you love, whether they're new ideas for emerging workflows, or reimplementations of old tools, or timeless classics that are just as good today as they were decades ago. Find the commands that make your life better and enjoy! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/rust-tools-linux + +作者:[Sudeshna Sur][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/sudeshna-sur +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/terminal_command_linux_desktop_code.jpg?itok=p5sQ6ODE (Terminal command prompt on orange background) +[2]: https://opensource.com/article/16/12/yearbook-linux-test-driving-distros +[3]: https://www.gnu.org/software/tar\> +[4]: https://opensource.com/article/21/6/tealdeer +[5]: https://opensource.com/article/21/6/dust +[6]: https://opensource.com/article/20/2/find-file-script +[7]: https://opensource.com/article/21/6/fd +[8]: https://opensource.com/article/21/3/replace-ls-exa +[9]: https://opensource.com/article/21/6/tokei diff --git a/sources/tech/20210715 Linux for Education- Best Distributions for Kids, Teachers - Schools.md b/sources/tech/20210715 Linux for Education- Best Distributions for Kids, Teachers - Schools.md new file mode 100644 index 0000000000..c0799f7647 --- /dev/null +++ b/sources/tech/20210715 Linux for Education- Best Distributions for Kids, Teachers - Schools.md @@ -0,0 +1,197 @@ +[#]: subject: (Linux for Education: Best Distributions for Kids, Teachers & Schools) +[#]: via: (https://itsfoss.com/educational-linux-distros/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Linux for Education: Best Distributions for Kids, Teachers & Schools +====== + +Can kids use Linux distributions? And is it suitable for school use? + +Well, that depends on what are your options and what you choose to go with. No matter whether you want something for a kid or the school teacher, there are options available. + +Hence, to give you a head start, we have curated a list of [best Linux distributions][1] tailored for education. + +### Best Linux Distribution for Kids + +For a kid, a distribution has to offer a user-friendly UI minus the advanced functionalities. + +You may argue that it can be done with any mainstream, [beginner-friendly distro like Ubuntu][2], Mint or Zorin. You are right, but if a distribution comes with [essential tools][3] baked in and makes it easy to use, kids will quickly learn to use it and have fun. + +#### 1\. Endless OS + +![Image Credits: Distrowatch][4] + +Endless OS is a popular option to go for as a Linux distro tailored for education. + +It is based on Debian and uses GNOME desktop environment. Even though it restricts usage of its OS on more than five hundred computers in a year, it is free to download. + +The user interface is easy to use and looks attractive for installation in a modern PC. You get variety of applications pre-installed. Hence, this comes handy for computers with no internet access. + +[Endless OS][5] + +#### 2\. Ubermix + +![][6] + +Ubermix is an Ubuntu-based Linux distribution that aims to reduce the complexity by tweaking the user interface, getting rid of unnecessary apps, and adding essential tools/apps for education. + +It also offers a way to easily recover from a system issue in case there is a problem. An optional parental control feature is present for content filtering and [screen time controls][7], which is indeed useful. + +Ubermix is actively maintained and provides plenty of instructions for installation and troubleshooting on its official website. + +[ubermix][8] + +#### 3\. Kano OS (for Raspberry Pi) + +![][9] + +Kano is a computing kit tailored for educating children from 6 to 14 years. It’s like a premium version of Raspberry Pi with plenty of DIY and coding activities for the young ones. + +Preview | Product | Price | +---|---|---|--- +![Kano Computer Kit – A Computer Anyone Can Make][10] ![Kano Computer Kit – A Computer Anyone Can Make][10] | [Kano Computer Kit – A Computer Anyone Can Make][11] | $345.00[][12] | [Buy on Amazon][13] + +Kano also has Debian based [operating system for Raspberry Pi][14]. You don’t need to have Kano kit for this purpose. You can use it on your Raspberry Pi. + +It aims to provide the benefits of it—curated for education when coupled with their computer kits. Ranging from coding apps to games, there should be something for everyone. + +You will also find useful parental control settings to limit/tweak the experience for your kid. For additional help, the [official help resources][15] will come in handy as well. + +[Kano OS][16] + +#### 4\. AcademiX GNU/Linux + +![][17] + +Yet another distribution based on Debian focused for learning. + +Not just for primary-level education, but the programs included in the operating system should be useful for university students as well. It also includes virtual interactive labs and virtual microscope. + +**While it makes learning easy with the utilities pre-installed, teachers can also use it to create content and publish.** + +So, it can be an all-in-one choice for a lot of potential learners and teachers in school. + +[AcademiX][18] + +#### 5\. Sugar (makes any distro kids friendly) + +![][19] + +Sugar is not a full-fledged OS but a learning platform (environment) that can be installed on top of any Linux distro to set it up for learning. + +Not just to help your kid learn with an easy-to-use interface, it also helps collaborating, sharing, and learning pre-installed software tools. + +It is also available for Raspberry Pi computers. And a [Flatpak package][20] lets you easily install some of its activities in any Linux distribution. + +[Sugar][21] + +#### 6\. Li-f-e + +Linux for education (Li-f-e) was originally a project by OpenSUSE and this is a continuation of that. + +Even though it is not backed by OpenSUSE now (I couldn’t find any references), it could be a useful option for kids and schools. + +This is based on Ubuntu MATE and offers several built-in applications as per some of the textbooks. It does not offer anything extraordinary but more like Ubuntu for education, which is actively maintained at the time of writing this. + +[Li-f-e][22] + +### Best Linux Distribution for Schools + +The ones I mentioned so far were tailored to be used by children for their education and learning. But education has two parts: students and teachers. + +This is why this list is divided into two parts. This second part lists some options that can be a good fit for school administrators, management, and teachers. + +Of course, you can always use Linux Mint, elementary OS, or Ubuntu if you want to utilize a stable and reliable Linux desktop OS to manage your school (or) content creation. However, there are some choices that are customized for the purpose. + +#### 1\. Debian Edu/Skolelinux + +![Image Credits: Distrowatch][23] + +Skolelinux is a Debian-based distribution that comes packed with several applications and networking services fit for students and teachers in school. + +It is also known as Debian Edu. You get the ability to opt for offline installation by downloading the required ISO or the base system with online installation for the rest. + +Even though kids can use it after setup, it requires a bit of learning curve to configure and maintain. Hence, this is more inclined towards school administrators or teachers than kids. + +[Skolelinux][24] + +#### 2\. Linux Schools (Karoshi Server) + +A Linux distribution with the perks of Ubuntu LTS built for school servers. If you want to setup a server and monitor/control a network of connected servers, Linux Schools (or Karoshi Server) is a good fit. + +It lets you administer a network of servers using a web interface. You do not need in-depth knowledge about Linux system administration to utilize it. + +[Linux Schools][25] + +#### 3\. Escuelas Linux + +![][26] + +[Escuelas Linux][27] is based on Bodhi Linux. It comes baked in with several applications fit for educational environments. + +It has custom tools for resetting the distro in the post-installed state in seconds. There is also options to reinstate users. Apart from that, it comes with applications for distributing educational material within the network, screen broadcasting, mirroring, remote command execution, message sending, screen locking and muting sound to the students’s computers. + +Considering it is based on Bodhi Linux, which is one of the [best lightweight Linux distros][28], this can be a good pick for older systems. + +You also get an added developer pack, which is optional to install, if you need advanced tools like NetBeans, Git, Android Studio. + +[Escuelas Linux][29] + +In addition to these options, there is also [EduBOSS][30], an education version of BOSS Linux which is tailored for Indian schools, if that is relevant to you. + +### Wrapping Up + +While there are 100s of Linux distribution, only a handful exist that are specially crafted for education. + +It is a good thing that there some viable options for students, teachers, and school administration. + +After all, Linux can be used everywhere and by anyone. Am I right? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/educational-linux-distros/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/best-linux-distributions/ +[2]: https://itsfoss.com/best-linux-beginners/ +[3]: https://itsfoss.com/essential-linux-applications/ +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/endless-os-distrowatch.png?resize=800%2C500&ssl=1 +[5]: https://endlessos.com/home/ +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/ubermix-4-official.png?resize=800%2C452&ssl=1 +[7]: https://itsfoss.com/activitywatch/ +[8]: https://ubermix.org/download.html +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/kano-os.png?resize=800%2C570&ssl=1 +[10]: https://i1.wp.com/m.media-amazon.com/images/I/41-VaIktpgL._SL160_.jpg?ssl=1 +[11]: https://www.amazon.com/dp/B073VTCS66?tag=chmod7mediate-20&linkCode=ogi&th=1&psc=1 (Kano Computer Kit – A Computer Anyone Can Make) +[12]: https://www.amazon.com/gp/prime/?tag=chmod7mediate-20 (Amazon Prime) +[13]: https://www.amazon.com/dp/B073VTCS66?tag=chmod7mediate-20&linkCode=ogi&th=1&psc=1 (Buy on Amazon) +[14]: https://itsfoss.com/raspberry-pi-os/ +[15]: https://help.kano.me/hc/en-us/sections/360001083699-Kano-OS +[16]: https://kano.me/row/downloadable +[17]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/academix-edu.png?resize=800%2C450&ssl=1 +[18]: https://academixproject.com/en/home/ +[19]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/sugarlabs.jpg?resize=992%2C744&ssl=1 +[20]: https://itsfoss.com/what-is-flatpak/ +[21]: https://www.sugarlabs.org +[22]: https://sourceforge.net/projects/cyberorg-home/files/Li-f-e/ +[23]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/skolelinux.png?resize=800%2C450&ssl=1 +[24]: http://www.skolelinux.org +[25]: https://www.linuxschools.com/forum/index-main.php +[26]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/07/escuelas-linux.jpg?resize=800%2C450&ssl=1 +[27]: https://itsfoss.com/escuelas-linux/ +[28]: https://itsfoss.com/lightweight-linux-beginners/ +[29]: https://escuelaslinux.sourceforge.io/english/index.html +[30]: https://bosslinux.in/eduboss diff --git a/sources/tech/20210716 What does the Open-Closed Principle mean for refactoring.md b/sources/tech/20210716 What does the Open-Closed Principle mean for refactoring.md new file mode 100644 index 0000000000..1a52b9ba8e --- /dev/null +++ b/sources/tech/20210716 What does the Open-Closed Principle mean for refactoring.md @@ -0,0 +1,80 @@ +[#]: subject: (What does the Open-Closed Principle mean for refactoring?) +[#]: via: (https://opensource.com/article/21/7/open-closed-principle-refactoring) +[#]: author: (Alex Bunardzic https://opensource.com/users/alex-bunardzic) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +What does the Open-Closed Principle mean for refactoring? +====== +Resolve the tension between protecting clients from unwanted changes and +extending the capabilities of services. +![Brain on a computer screen][1] + +In his 1988 book, _[Object-Oriented Software Construction][2]_, professor [Bertrand Meyer][3] defined the [Open-Closed Principle][4] as: + +> "A module will be said to be open if it is still available for extension. For example, it should be possible to add fields to the data structures it contains or new elements to the set of functions it performs. +> +> "A module will be said to be closed if it is available for use by other modules. This assumes that the module has been given a well-defined, stable description (the interface in the sense of information hiding)." + +A more succinct way to put it would be: + +> Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification. + +Similarly (and in parallel to Meyer's findings), [Alistair Cockburn][5] defined the [Protected Variation][6] pattern: + +> "Identify points of predicted variation and create a stable interface around them." + +Both of these deal with volatility in software. When, as is always the case, you need to make some change to a software module, the ripple effects can be disastrous. The root cause of disastrous ripple effects is tight coupling, so the Open-Closed Principle and Protected Variation Pattern teach us how to properly decouple various modules, components, functions, and so forth. + +### Does the Open-Closed Principle preclude refactoring? + +If a module (i.e., a named block of code) must remain closed to any modifications, does that mean you're not allowed to touch it once it gets deployed? And if yes, wouldn't that eliminate any possibility of refactoring? + +Without the ability to refactor the code, you are forced to adopt the Finality Principle. This holds that rework is not allowed (why would stakeholders agree to pay you to work again on something they already paid for?) and you must carefully craft your code, because you will get only one chance to do it right. This is in total contradiction to the discipline of refactoring. + +If you are allowed to extend the deployed code but not change it, are you doomed to swim forever in the waterfall rivers? Being given only one shot at doing anything is a recipe for disaster. + +Let's review the approach to solve this conundrum. + +### How to protect clients from unwanted changes + +Clients (meaning modules or functions that use some block of code) utilize some functionality by adhering to the protocol as originally implemented in the component or service. However, as the component or service inevitably changes, the original "partnership" between the service or component and various clients breaks down. Clients "discover" the change by breakage, which is always an unpleasant surprise that often ruins the initial trust. + +Clients must be protected from those breakages. The only way to do so is by introducing a layer of abstraction between the clients and the service or component. In software engineering lingo, we call that layer of abstraction an "interface" (or an API). + +Interfaces and APIs hide the implementation. Once you arrange for a service to be delivered via an interface or API, you free yourself from the worries of changing the implementation code. No matter how much you change the service's implementation, your clients remain blissfully unaffected. + +That way, you are back to your comfortable world of iterations. You are now completely free to refactor, to rearrange the code, and to keep rearranging it in pursuit of a more optimal solution. + +The thing in this arrangement that remains closed for modification is the interface or API. The volatility of an interface or API is the thing that threatens to break the established trust between the service and its clients. Interfaces and APIs must remain open for extension. And that extension happens behind the scenes—by refactoring and adding new capabilities while guaranteeing non-volatility of the public-facing protocol. + +### How to extend capabilities of services + +While services remain non-volatile from the client's perspective, they also remain open for business when it comes to enhancing their capabilities. This Open-Closed Principle is implemented through refactoring. + +For example, if the first increment of the `OrderPayment` service offers mere bare-bones capabilities (e.g., able to process the order total and calculate sales tax), the next increment can be safely added by respecting the Open-Closed Principle. Without breaking the handshake between the clients and the `OrderPayment` service, you can refactor the implementation behind the `OrderPayment` API by adding new blocks of code. + +So, the second increment could contain the ability to calculate shipping costs. And so on, you get the picture; you accomplish the Protected Variation Pattern by observing the Open-Closed Principle. It's all about carefully modeling business abstractions. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/open-closed-principle-refactoring + +作者:[Alex Bunardzic][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/alex-bunardzic +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brain_computer_solve_fix_tool.png?itok=okq8joti (Brain on a computer screen) +[2]: https://en.wikipedia.org/wiki/Object-Oriented_Software_Construction +[3]: https://en.wikipedia.org/wiki/Bertrand_Meyer +[4]: https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle +[5]: https://en.wikipedia.org/wiki/Alistair_Cockburn +[6]: https://martinfowler.com/ieeeSoftware/protectedVariation.pdf diff --git a/sources/tech/20210717 How to avoid waste when writing code.md b/sources/tech/20210717 How to avoid waste when writing code.md new file mode 100644 index 0000000000..7438dd9031 --- /dev/null +++ b/sources/tech/20210717 How to avoid waste when writing code.md @@ -0,0 +1,84 @@ +[#]: subject: (How to avoid waste when writing code) +[#]: via: (https://opensource.com/article/21/7/avoid-waste-coding) +[#]: author: (Alex Bunardzic https://opensource.com/users/alex-bunardzic) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +How to avoid waste when writing code +====== +The more we can reduce waste in software development, the better off +everyone will be. +![Learning to program][1] + +The long road toward quality is filled with diversions, false starts, and detours. The enemy of quality is waste, because waste is never desirable. No one pays anyone to deliver waste. We sometimes tolerate waste as part of the process of making something useful and desirable, but the more we can reduce waste while making something, the better. + +In software engineering, waste can be expressed in a few ways: + + 1. Defects + 2. Idling and waiting + 3. Overproduction + 4. Overprocessing + 5. Any other activity that doesn't directly put value in users' hands + + + +Let's examine each of these five types of waste. + +### Defects + +There seems to be a prevailing sentiment in the software industry that bugs (defects) are inevitable. It's not if—but when and how many—bugs find their way into production. + +You can fight that defeatist sentiment by reminding software engineers that each and every bug is authored. Bugs don't occur spontaneously. They're created by us, human beings trying to do the best software development we can. But nobody's perfect. Of course we don't create bugs intentionally, but they do happen. They're often a result of rushing things through, or perhaps due to inadequate education and training. + +Whatever the reason, bugs are _caused_, which means we can eliminate bugs by solving the problems that cause them. + +### Idling and waiting + +Our business partners funding our software development efforts tend to perceive any time we're not producing shipping code as time spent idling. Why are we idling, and what are we waiting on? It's a reasonable question to ask, if you consider they're paying potentially thousands of dollars per hour to keep the team going. + +Idling is wasteful. It does not contribute to the bottom line and may be a sign of confusion. If the team says they're waiting on someone to return from their leave of absence, that signals poor organizing skills. No team should ever get to the point where they paint themselves into a corner and are suffering from a single point of failure. If a team member can't participate, other members should step in and continue the work. If that's not possible, you are dealing with a very brittle, inflexible, and unreliable team. + +Of course, there are many other possible reasons the team is idling. Maybe there is confusion about the current highest priority, so the team is hanging and waiting to learn about the correct priority. + +There are many other [reasonable causes of idling][2], which is why this type of waste seems hardest to get on top of. Whatever the case, mature organizations take precautionary steps to minimize potential idling and waiting time. + +### Overproduction + +Often labeled "gold plating," overproduction is one of the most insidious forms of waste. Software engineers are notorious for their propensity to go overboard in their enthusiasm for building features and nifty capabilities. And because software, as its name implies, is very pliable and malleable, there is very little pushback against the onslaught of bloat. + +This dreadful bloat creates a lot of waste. Fighting bloat is what prudent software engineering discipline is all about. + +### Overprocessing + +One of the biggest problems in software engineering is known as Geek-At-Keyboard (GAK). A common misconception is that software engineers spend most of their time writing code. That is far from the truth. Most of the time spent on regular daily activities (aside from attending meetings) goes toward keyboard activities unrelated to writing code: messing with configurations and environments, manually running and navigating the app, typing and retyping test data, stepping through the debugger, etc. + +All those activities are waste. They don't contribute to delivering value. One of the most effective remedies for minimizing unproductive GAK time is [test-driven development][3] (TDD). Writing tests before writing code is a proven method for avoiding overprocessing. The test-first approach is a very effective way of eliminating waste. + +### Other activities that don't put value in users' hands + +In the early days of our profession, value was measured by the number of lines of code produced per unit of time (per day, week, month, etc.). Later, this rather ineffective way of measuring value was abandoned in favor of working code. There is no convincing correlation between the number of lines of code and working code. And once working code became the measure of value, the number of lines of code became irrelevant. + +Today, we recognize that [working code][4] is also a meaningless metric. Just because code compiles, builds, and works doesn't mean it is doing anything of value. Successfully running code could be doing inane processing, such as counting from 0 to 10 and then back to 0. It is much more important to focus on code that meets end users' expectations. + +Helping end users fulfill their goals when using your software product is the only measure of value. Any other activity that does not contribute to that value should be regarded as waste. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/avoid-waste-coding + +作者:[Alex Bunardzic][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/alex-bunardzic +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/learn-programming-code-keyboard.png?itok=xaLyptT4 (Learning to program) +[2]: https://opensource.com/article/21/2/simplicity +[3]: https://opensource.com/article/20/1/test-driven-development +[4]: https://opensource.com/article/20/7/code-tdd diff --git a/sources/tech/20210718 Up for a Challenge- Try These ‘Advanced- Linux Distros -Not Based on Debian, Arch or Red Hat.md b/sources/tech/20210718 Up for a Challenge- Try These ‘Advanced- Linux Distros -Not Based on Debian, Arch or Red Hat.md new file mode 100644 index 0000000000..3feed5306f --- /dev/null +++ b/sources/tech/20210718 Up for a Challenge- Try These ‘Advanced- Linux Distros -Not Based on Debian, Arch or Red Hat.md @@ -0,0 +1,140 @@ +[#]: subject: (Up for a Challenge? Try These ‘Advanced’ Linux Distros [Not Based on Debian, Arch or Red Hat]) +[#]: via: (https://itsfoss.com/advanced-linux-distros/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) +[#]: collector: (lujun9972) +[#]: translator: (zepoch) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Up for a Challenge? Try These ‘Advanced’ Linux Distros [Not Based on Debian, Arch or Red Hat] +====== + +There are hundreds of Linux distributions. Some are for general purpose usage, while some are specifically tailored for education, robotics, hacking, gaming and what not. + +You’ll notice that most of them originate from Debian/Ubuntu, Arch and Red Hat/Fedora. If you like distrohopping and experiment with a range of distributions, you may soon get ‘bored’ out of it. Most Linux distributions would feel too similar after a point and apart from a few visual changes here and there, you won’t get a different experience. + +Does that sound familiar? If yes, let me list some advanced, independent, Linux distributions to test your expertise. + +### Advanced Linux distributions for experts + +![][1] + +You may argue against the use of term “expert” here. After all, ‘expert Linux users’ don’t necessarily need to use advanced Linux distributions. They can easily utilize their expertise on [beginner-friendly distributions like Linux Mint][2]. + +The term expert here is intended for people who won’t easily get overwhelmed when they are taken out of their comfort zone and land in an unfamiliar environment. + +Alright then. Let’s see which distributions you can use to test your expertise on. + +#### NixOS + +![NixOS Linux illustration][3] + +[NixOS][4] is a unique distribution in the terms of how it approaches everything from the kernel to configuration to applications. + +NixOS is built on top of the Nix package manager and everything from the kernel to configuration is based on it. All packages are kept in isolation from each other. + +It ensures that installing or upgrading one package does not break other packages. You can also easily roll back to previous versions. + +The isolation feature also helps you in trying new tools without hesitation, creating development environments and more. + +Sounds good enough to give it a try? You call, truly. + +#### Void Linux + +![Void Linux illustration][5] + +[Void Linux][6] is another independent Linux distribution which was implemented from scratch. It is a rolling release distribution but it focuses on stability rather than being bleeding edge like Arch Linux. + +Void Linux has its own XBPS package management system for installing and removing software with option to build packages from sources (from XBPS source packages collection). + +Another thing that sets Void Linux apart from the crowd of other distribution is its use of [runit][7] as init system instead of systemd. + +Can Void Linux fill the void in your distrohopping life? Find it out yourself. + +#### Slackware + +![Slackware Linux illustration][8] + +The oldest active Linux distribution, [Slackware][9], can surely be counted as an expert Linux distribution. + +Which is amusing because once upon a time, many new Linux users started their Linux journey with Slackware. But that was back in the mid-90s and it is safe to assume that those newbies have turned into veteran with their neck beard touching the ground. + +Originally, Slackware was based on Softlanding Linux System (SLS), one of the earliest Linux distributions in 1992. + +Slackware is an advanced Linux distribution with aim to produce the most “UNIX-like” Linux distribution out there. + +No slacking here. Be ready to use the command line extensively in Slackware. + +#### Gentoo + +![Gentoo Linux illustration][10] + +[Gentoo Linux][11] is named after the fast swimming Gentoo penguin. It reflects the speed optimization capabilities of Gentoo Linux. + +How? It’s software distribution system, Portage, gives it extreme configurability and performance. Portage keeps a collection of build scripts for the packages and it automatically builds a custom version of package based on end user’s preference and optimized for end user’s hardware. + +This ‘build’ stuff is why there are many jokes and meme in Linux-verse about compiling everything in Gentoo. + +Can you catch up with the Gentoo? + +#### Clear Linux + +![Clear Linux illustration][12] + +[Clear Linux][13] is not your general purpose desktop Linux distribution. It is an open source, rolling release distribution, created from the ground up by Intel and obviously, it is highly tuned for Intel platforms. + +Clear Linux OS primarily targets professionals in the field of IT, DevOps, Cloud/Container deployments, and AI. + +The package management is done through [swupd][14] but unlike regular package managers, versioning happens at the individual file level. This means that it generates an entirely new OS version when any software change takes place in the system. + +Is it clear enough to try Clear Linux? + +#### Linux From Scratch + +![Linux From Scratch illustration][15] + +If you think installing Arch Linux was a challenge, try [Linux From Scratch][16] (LFS). As the name suggests, here you ~~get~~ have to do everything from scratch. + +From installing to using, you do everything at a low level and that’s the beauty of it. You are not installing a pre-compiled Linux distribution here. You build your own customized Linux system entirely from the source code. + +It is often suggested to use Linux From Scratch to learn the core functioning of the Linux and it is indeed a learning experience. + +Still scratching your head about Linux From Scratch? You can [read it][17][s][17] [documentation in book format][17]. + +#### Conclusion + +There are a few more independent Linux distributions. Mageia and Solus are two of the relatively more popular ones. I did not include them in this list because I consider them more friendly and not as complicated to use as others on the list. Feel free to disagree with me in the comments. + +It is your turn now. Have you used any advanced Linux distributions ever? Was it in the past or are you still using it? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/advanced-linux-distros/ + +作者:[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://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/advanced-linux-distros.png?resize=800%2C450&ssl=1 +[2]: https://itsfoss.com/best-linux-beginners/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/nix-os.png?resize=800%2C350&ssl=1 +[4]: https://nixos.org/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/void-linux.png?resize=800%2C350&ssl=1 +[6]: https://voidlinux.org/ +[7]: http://smarden.org/runit/ +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/07/slackware.png?resize=800%2C350&ssl=1 +[9]: http://www.slackware.com/ +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/gentoo-linux.png?resize=800%2C350&ssl=1 +[11]: https://www.gentoo.org/ +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/07/clear-linux.png?resize=800%2C350&ssl=1 +[13]: https://clearlinux.org/ +[14]: https://docs.01.org/clearlinux/latest/guides/clear/swupd.html#swupd-guide +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/07/linux-from-scratch.png?resize=800%2C350&ssl=1 +[16]: https://www.linuxfromscratch.org/ +[17]: https://www.linuxfromscratch.org/lfs/read.html diff --git a/sources/tech/20210719 Apps for daily needs part 2- office suites.md b/sources/tech/20210719 Apps for daily needs part 2- office suites.md new file mode 100644 index 0000000000..d5a84fe848 --- /dev/null +++ b/sources/tech/20210719 Apps for daily needs part 2- office suites.md @@ -0,0 +1,124 @@ +[#]: subject: (Apps for daily needs part 2: office suites) +[#]: via: (https://fedoramagazine.org/apps-for-daily-needs-part-2-office-suites/) +[#]: author: (Arman Arisman https://fedoramagazine.org/author/armanwu/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Apps for daily needs part 2: office suites +====== + +![][1] + +Photo by [Brooke Cagle][2] on [Unsplash][3] + +Today, almost every family has a desktop computer or laptop. That’s because the computer has become a very important requirement. Moreover, many people have to create documents and presentations in digital format for work or study. Therefore, the office suites are must-have application on almost all computers. This article will introduce some of the open source office suites that you can use on Fedora Linux. You may need to install the software mentioned. If you are unfamiliar with how to add software packages in Fedora Linux, see my earlier article [Things to do after installing Fedora 34 Workstation][4]. Here is the list of apps for daily needs in the office suites category. + +### LibreOffice + +LibreOffice is the most popular office suite among GNU/Linux users. It has a user interface and user experience similar to Microsoft Office. This makes LibreOffice easy to learn for those who have just migrated from Microsoft Office. LibreOffice has complete features to meet your needs working on documents and presentations. It consists of six applications: Writer, Calc, Impress, Draw, Math, and Base. + +The first application is Writer that is used to create various kinds of documents, such as letters, faxes, agendas, minutes, etc. It is a full-featured word processing and desktop publishing tool. The second application is Calc which is a spreadsheet program that is perfect for presenting data and documenting it in tabular format. Calc can create simple tables or do professional data analysis. The third application is Impress which is an easy-to-use presentation application. You can easily choose what you features want in your presentation slides, such as text, images, tables, diagrams, etc. + +![LibreOffice Writer][5] + +![LibreOffice Calc][6] + +![LibreOffice Impress][7] + +The three LibreOffice applications mentioned earlier are the most commonly used applications in creating documents and presentations. However, LibreOffice provides three other applications that are also very useful. The first is Draw which can be used to create drawings and diagrams, ranging from simple to complex. The next application is Math which can help us make perfectly formatted mathematical and scientific formulas. The last is Base which is an application for processing databases. + +![LibreOffice Draw][8] + +![LibreOffice Math][9] + +![LibreOffice Base][10] + +More information is available at this link: + +* * * + +### ONLYOFFICE + +ONLYOFFICE is an office suite application that is highly compatible with Microsoft Office. Therefore we do not have to worry about collaborating with colleagues who use Microsoft Office because it can read various file formats such as docx, xlsx, and pptx. + +ONLYOFFICE provides three applications with a clean and modern look. We can easily find the features and tools that we need. Although the features are not as complete as LibreOffice, they are very sufficient to help us create good documents and presentations. + +The first application is Documents Editor which has the same function as Writer from LibreOffice. It has all the basic features needed in a word processor, such as managing fonts and styles, formatting text, adjusting line and paragraph spacing, inserting headers and footers, customizing page layout, and setting margins. The second application is Spreadsheet Editor which is an application for processing data and creating it as a document in tabular format. It is an application with the same functionality as Calc. The last one is Presentations Editor which is a presentation application with functions similar to Impress. + +Unfortunately ONLYOFFICE is not available in the official Fedora Linux repositories. But you can still install it on Fedora Linux using Flatpak or Appimages. + +![ONLYOFFICE Documents Editor][11] + +![ONLYOFFICE Spreadsheets Editor][12] + +![ONLYOFFICE Presentations Editor][13] + +More information is available at this link: + +* * * + +### Calligra + +Calligra is an office suite created by KDE. Therefore, this application is actually more suitable for users of the KDE Plasma desktop environment. But it can still run well on other desktop environments, such as Fedora Workstation using GNOME. + +Calligra provides several applications with a slightly different look from LibreOffice or ONLYOFFICE. It may take some adjustment for those who are used to mainstream office suite applications. However, Calligra is still a reliable office suite to support our daily needs. + +The first application is Words which is an intuitive word processor with desktop publishing features. It has a full range of features to help us in document creation. The second application is Sheets which has the same functionality as Calc and Spreadsheet Editors as a fully-featured spreadsheet application. The third application is Stage which can help us in making presentation slides. + +![Calligra Words][14] + +![Calligra Sheets][15] + +![Calligra Stage][16] + +The three Calligra applications are the most commonly used applications for creating documents and presentations. There are three other applications that are also very useful. The first is Karbon which can be used to create drawings and diagrams, ranging from simple to complex. The next application is Plan which is project management application that can help in managing moderately large projects with multiple resources. The last is KEXI which is a visual database application creator. + +![Calligra Karbon][17] + +![Calligra Plan][18] + +![Calligra Kexi][19] + +More information is available at this link: + +* * * + +### Conclusion + +This article presented 3 office suites for your daily needs that you can use on Fedora Linux. If you want a complete set of features in your office suite, then LibreOffice may be the right choice. For good compatibility with Microsoft Office, then you may choose ONLYOFFICE. However, if you want a different user interface and experience in creating documents and presentations, you can try Calligra. Hopefully this article can help you to choose the right office suite. If you have experience in using these applications, please share your experience in the comments. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/apps-for-daily-needs-part-2-office-suites/ + +作者:[Arman Arisman][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/armanwu/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2021/07/FedoraMagz-Apps-2-Office-816x345.jpg +[2]: https://unsplash.com/@brookecagle?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]: https://unsplash.com/s/photos/meeting-on-cafe-computer?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: https://fedoramagazine.org/things-to-do-after-installing-fedora-34-workstation/ +[5]: https://fedoramagazine.org/wp-content/uploads/2021/07/office-libre-writer-1-1024x575.png +[6]: https://fedoramagazine.org/wp-content/uploads/2021/07/office-libre-calc-1-1024x575.png +[7]: https://fedoramagazine.org/wp-content/uploads/2021/07/office-libre-impress-1-1024x575.png +[8]: https://fedoramagazine.org/wp-content/uploads/2021/07/office-libre-draw-1-1024x575.png +[9]: https://fedoramagazine.org/wp-content/uploads/2021/07/office-libre-math-1-1024x575.png +[10]: https://fedoramagazine.org/wp-content/uploads/2021/07/office-libre-base-1-1024x575.png +[11]: https://fedoramagazine.org/wp-content/uploads/2021/07/office-only-doc-1024x575.png +[12]: https://fedoramagazine.org/wp-content/uploads/2021/07/office-only-sheet-1024x575.png +[13]: https://fedoramagazine.org/wp-content/uploads/2021/07/office-only-presentation-1024x575.png +[14]: https://fedoramagazine.org/wp-content/uploads/2021/07/office-calligra-words-1024x575.png +[15]: https://fedoramagazine.org/wp-content/uploads/2021/07/office-calligra-sheets-1024x575.png +[16]: https://fedoramagazine.org/wp-content/uploads/2021/07/office-calligra-stage-1024x575.png +[17]: https://fedoramagazine.org/wp-content/uploads/2021/07/office-calligra-karbon-1-1024x575.png +[18]: https://fedoramagazine.org/wp-content/uploads/2021/07/office-calligra-plan-1024x575.png +[19]: https://fedoramagazine.org/wp-content/uploads/2021/07/office-calligra-kexi-1024x575.png diff --git a/sources/tech/20210720 Access cloud files on Windows with ownCloud.md b/sources/tech/20210720 Access cloud files on Windows with ownCloud.md new file mode 100644 index 0000000000..a517fd3a4c --- /dev/null +++ b/sources/tech/20210720 Access cloud files on Windows with ownCloud.md @@ -0,0 +1,117 @@ +[#]: subject: (Access cloud files on Windows with ownCloud) +[#]: via: (https://opensource.com/article/21/7/owncloud-windows-files) +[#]: author: (Martin Loschwitz https://opensource.com/users/martinloschwitzorg) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Access cloud files on Windows with ownCloud +====== +ownCloud VFS leverages Microsoft's cloud files API to make opening, +modifying, and saving online files seamless. +![Scissors cutting open access to files][1] + +Most computer users nowadays rely on online file storage. Thanks to the rise of cloud computing, the idea of storing files remotely and downloading them when needed has gained a lot of fresh air in recent years. Yet, the principle's technical roots are anything but new, with implementations reaching back decades. While the protocols used and features expected for accessing data on online storage have changed massively, the basic idea hasn't altered much since the days of FTP and similar protocols. + +There's an easy explanation for why online (or "cloud") storage has so many fans. Cloud storage usually resides on highly redundant infrastructure, often distributed across physical sites. Ordinary people would have a tough time setting up anything similar with the tools generally available to them. Cloud storage also allows users to extend their storage space easily without having to fiddle with their device hardware. It also enables people to share files with relatives, friends, or colleagues in just a few simple steps. + +Smartphones are an excellent example of cloud storage's advantages; clients including Dropbox, Google Drive, and iCloud are deeply integrated into mobile operating systems and can be used in apps just like local storage. + +Classical desktop and laptop computers don't integrate online storage as well as smartphones do. Rather, accessing iCloud, ownCloud, or other storage solutions from a computer is a tedious task for several reasons. + +### A matter of protocol + +Many of the reasons boil down to the protocol. The methods and protocols for accessing online storage have changed often, and no single protocol has established itself as a de-facto standard. Online storage services such as Dropbox, S3, and iCloud use proprietary protocols (partially based on open protocols such as WebDAV), which cannot be implemented easily on desktop operating systems. As a result, desktop users often face tedious user interfaces (UIs), reduced comfort, and poor user experience (UX) with online file storage. + +It helps to look a bit deeper to understand the problem and come up with possible solutions. To start, all modern operating systems—notably Windows, macOS, and Linux (along with its numerous derivatives)—assume they are exclusively in charge of a user's files. This comes from the old-fashioned assumption that a user's files will be hosted on a single device. If all a user's files are stored on the same device, it is easy to put them in a tree-like structure (as desktop operating systems have been doing for ages) and present a unique view to the user. + +With cloud-based storage, things are not so easy. Because these files are not available locally, a computer's operating system cannot manage or display them the same way it displays local files. To edit an Excel sheet stored in the cloud, you must download the file from the cloud, store it locally, modify it, and upload it again. Not only does this break your UI and UX; it also creates chaos. + +Some online storage providers try to work around the issue with clients that synchronize contents between the cloud and the local machine. This is an ugly workaround. For instance, you might not want the dozens of gigabytes of data stored in your cloud to also reside on your small local device. To mitigate this challenge, some tools allow you to select a subset of data to synchronize between the client and the online service; this shifts the problem to the side a bit but certainly does not solve it. + +### How WebDAV failed the industry + +Many IT professionals are likely shaking their heads fiercely, knowing there's a protocol for these types of tasks that could be used. And they are not completely wrong. [WebDAV][2] was specified as early as June 2007 by the IETF to extend the HTTP protocol for Web Distributed Authoring and Versioning (WebDAV for short). WebDAV's sole purpose was to provide an interface that allows files in a remote location, such as online cloud storage, to be accessed and edited the same way local files can be. WebDAV has gained traction since then: Private cloud solutions such as ownCloud and NextCloud support and can be accessed through it. + +Yet to call WebDAV a ringing success would be unrealistic, as neither the server nor the client side has achieved widespread use. Matters are especially bad on the server side: many online storage services, including Dropbox, Google Drive, and Microsoft OneDrive, do not support the WebDAV extension to HTTP. Some put proxy services in place. Dropbox, for instance, can be used with DAVbox to achieve WebDAV access. Other services provide tools to mitigate the lack of a working WebDAV server. Generally speaking, though, WebDAV support is not widespread throughout the industry, and that will probably not change anytime soon. + +### Poor operating system support for WebDAV + +This leads right into the second aspect of WebDAV's disastrous history: the client side. At this time, only one operating system has somewhat complete client support throughout the relevant tools of its userland, and that is Linux. Standard desktop environments such as KDE, GNOME, and Xfce can connect to WebDAV drives from the desktop. They also integrate WebDAV drives as if they were normal local disks, effectively allowing users to move data back and forth between the remote site and the local machine. Last but not least, they can download files from WebDAV devices on demand instead of keeping files continuously in sync between a remote site and the local drive. In Linux, life with WebDAV is mostly good—mostly because WebDAV doesn't feature inherent caching. + +Matters change a bit when looking at macOS. Apple equipped macOS with a WebDAV client a while ago, and it mostly works fine. However, it is tedious for less experienced users to set up. And macOS's WebDAV client tends to misbehave when the connection between the client and the server is brittle—like it would be for users in Germany behind LTE connectivity. In such setups, users have to clean up their WebDAV directories regularly to be able to use them. + +The most widespread operating system, Windows, also offers the most dramatic failure in terms of WebDAV integration. To even set up a WebDAV-based storage drive, you would have to edit the Windows Registry—a task that easily exceeds the average computer user's knowledge. If that were not bad enough, even after modifying the Registry, the Windows client for the WebDAV protocol looks more like a stub than a usable feature. You will soon experience problems like those found with the macOS WebDAV implementation, and the experience of using the protocol will be terrible. + +### ownCloud's VFS alternative + +[ownCloud][3] is a private cloud solution that allows users to store, sync, and share data on their own terms, including on a Raspberry Pi, a private cloud, or in a hybrid setup. ownCloud offers a client for the world's most common operating system. But for many years, it relied upon workarounds, like requiring users to explicitly choose which files to synchronize. + +ownCloud has come up with a solution to the problem—and it's a rather sophisticated one. Windows offers an interface to connect to cloud-based online storage, and ownCloud leverages that interface with its [virtual file system][4] (VFS).  + +### How VFS works + +ownCloud's VFS functionality for Windows heavily relies on a Microsoft feature named [cloud files API][5]. It was officially introduced in Windows 10, version 1809 in 2017. Microsoft designed it for file synchronization with OneDrive, but other services are free to use the API, which is now part of the Windows 10 core. The cloud files API is kind of a demarcation line for synchronizing data from the cloud to a local machine and vice versa. It's split into two parts: + + * The **API** provides functions on the API level to perform tasks such as opening, saving, and uploading files to the remote host after the user commits changes. The cloud files API handles a lot of things invisible to the user; for instance, a client using the API will display all remote files as "present" in the local view without downloading them. The cloud files API will download a file only after the user explicitly requests to open it from the remote drive. + * The **Windows.Storage.Provider** namespace allows applications in the userland to configure a client to access a remote service through the cloud files API. + + + +### What the user sees + +The revolutionary way that cloud files API deals with files in remote storage under Windows becomes clear when you see ownCloud VFS in action. + +First, set up a connection to your ownCloud drives from within the ownCloud Client for Windows. Make sure _virtual file support_ is enabled; this makes the directories in your ownCloud drive immediately visible and selectable in Windows tools, such as the Explorer. You won't be able to tell them apart from the files on your local storage devices, and when you open a file stored in ownCloud, it will appear like it is locally present. For files not synchronized to the local host, the cloud files API generates a placeholder that is replaced with the actual file when you open it. This allows a seamless user experience while preserving bandwidth on the client's and the server's internet links. + +Setting up a VFS drive in Windows does not require administrator privileges, as editing the Windows Registry for WebDAV connectivity requires. This means ownCloud VFS might be usable on devices such as business laptops, where the administrator account is usually not available to the user. Compliance policies may still forbid using ownCloud if the instance is not run by the company under its compliance regime, however. + +### Major differences from WebDAV + +Not only does VFS work considerably better on Windows 10 operating systems, it also offers a few features not available in protocols like WebDAV. One of these is implicit caching. During normal operations, VFS will synchronize files when they are opened until a locally defined cache is full; if the user requests additional files, VFS will remove the oldest files from the cache. + +Furthermore, VFS allows you to specify "favorite" files that will always be synchronized automatically from the remote drive whether or not you are trying to access them. This shortens the initial time to access frequently used files, especially if the files are large. + +### Storage Sense makes sense + +Another helpful feature in the Windows cloud files API is the "Storage Sense" feature added in Windows 1809. While primarily aimed at OneDrive users, Storage Sense can be used in the background with an ownCloud online storage drive due to its cloud files API support. Storage Sense regularly scans the Windows C: drive for files that have not been used for a long time. It synchronizes these files to the remote cloud storage and deletes them from the local device, freeing up space for data used more often. + +The user can determine Storage Sense's intervals and when Windows will trigger scans. The latter factor is not very important anymore because searching an SSD or NVMe device is very fast compared to the old days of searching spinning disk drives. Storage Sense aims to increase available disk space on systems, and ownCloud drives can be targets for offloading unused files. + +### VFS on other operating systems + +By creating a virtual file system based on the cloud files API, ownCloud improves the experience of using ownCloud online storage as a web drive in Microsoft Windows 10. ownCloud is one of the few free, libre, and open source software projects using this API at all—even other vendors' commercial support for it is rather weak. Apple's iCloud client for Windows uses the cloud files API, but the list is short. + +How does ownCloud use VFS on other operating systems? It's not as easy as porting the Windows functionality to other operating systems because the cloud files API is not present on non-Windows machines. + +ownCloud still implements comparable functionality—sort of. The macOS and Linux ownCloud clients behave as though the cloud files API were available even on non-Windows systems. Certain Windows functions have been replaced in the background with stubs for the corresponding system. There are a few notable differences between the Windows client and the view in Linux or macOS. For instance, Windows shows the correct file size even for remote files represented locally by a placeholder. On Linux and macOS, all files are displayed with a size of 1 byte and a local extension of .owncloud. This makes it clear that the files do not exist locally—at least until the user asks to open them and ownCloud initiates the download. + +It's true, though, that the VFS experience on macOS and Linux is not quite as smooth as it is on Windows 10. + +### Summary + +ownCloud's VFS dramatically improves the integration of ownCloud cloud storage drives into Windows 10. In contrast to WebDAV and related protocols, the cloud files API is a native API in Windows, integrated seamlessly with the operating system. This eliminates the ugly hacking required to enable WebDAV access in Windows 10, let alone the contortions needed to use it effectively. Older Windows clients do not benefit from the API, and its advantages might create an incentive to update old Windows versions in environments where ownCloud is heavily used. + +macOS and Linux users do not benefit as much from ownCloud's VFS support. On Linux, hobby projects like [elokab-files-manager][6] provide better support for ownCloud VFS. But this is certainly not something you would want to bet on as your daily driver. The situation on macOS is even worse: While Apple has long promised to add similar API functionality to macOS, only Big Sur seems to have the required feature set. As of this writing, ownCloud's developers have not yet adapted the ownCloud client for macOS to the new features in Big Sur. Consequently, Linux and macOS users can use VFS on their platforms with minor limitations. Windows 10 users, however, get the biggest bang for their buck. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/owncloud-windows-files + +作者:[Martin Loschwitz][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/martinloschwitzorg +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/document_free_access_cut_security.png?itok=ocvCv8G2 (Scissors cutting open access to files) +[2]: https://en.wikipedia.org/wiki/WebDAV +[3]: https://owncloud.com/ +[4]: https://owncloud.com/features/virtual-files/ +[5]: https://docs.microsoft.com/en-us/windows/win32/cfapi/build-a-cloud-file-sync-engine +[6]: https://github.com/dragotin/elokab-files-manager diff --git a/sources/tech/20210721 Accessibility in open source for people with ADHD, dyslexia, and Autism Spectrum Disorder.md b/sources/tech/20210721 Accessibility in open source for people with ADHD, dyslexia, and Autism Spectrum Disorder.md new file mode 100644 index 0000000000..ea4aa1b63a --- /dev/null +++ b/sources/tech/20210721 Accessibility in open source for people with ADHD, dyslexia, and Autism Spectrum Disorder.md @@ -0,0 +1,167 @@ +[#]: subject: (Accessibility in open source for people with ADHD, dyslexia, and Autism Spectrum Disorder) +[#]: via: (https://opensource.com/article/21/7/open-source-neurodiversity) +[#]: author: (Rikard Grossman-Nielsen https://opensource.com/users/rikardgn) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Accessibility in open source for people with ADHD, dyslexia, and Autism Spectrum Disorder +====== +Open source accommodations help people with neurodiversity use their +talents to their highest ability. +![a magnifying glass looking at a brain illustration][1] + +For a long time, attention deficit hyperactivity disorder (ADHD), autism, Asperger syndrome, dyslexia, and other neurodiverse conditions were considered things that hold people back. But now, many researchers and employers recognize that [neurodiversity is a competitive advantage][2], especially in technology, and especially when certain accommodations are provided. + +This is certainly true for me. I'm a 39-year-old teacher in Sweden diagnosed with ADHD and Asperger's (also referred to as Autism Level 1). I'm also an intermediate Linux user and use it daily for Java programming, productivity, and gaming. I've been using Linux since the late 1990s, and I've learned ways open source programs can be made more accessible for people with these conditions. For example, I use accessibility software, including speech synthesis to find spelling errors and calendar software accommodations to help with my Asperger's and ADHD. + +### Asperger's, ADHD, and dyslexia + +Before I get into open source software accommodations, I'll share some information about these conditions. + +#### Asperger syndrome + +[Asperger's][3] is a form of autism without intellectual disability. People with Asperger's often have: + + * Difficulties in social contact with other people + * Special interest areas that may consume a large part of their attention and time + * Difficulties understanding and using language in communicating with other people + * Deficits in motor skills + * A tendency to easily get caught in up certain routines or actions + * Unusual perception of and sensitivity to stimuli such as sound, light, etc. + + + +#### ADHD + +The three core symptoms of [ADHD][4] are: + + * **Attention:** Difficulties in concentration and forgetfulness; distractability; easily bored and fail to complete things that don't interest them + * **Impulsivity:** Strong emotional reactions to different things; difficulty listening to others; problems handling unstructured situations that require reflection and thinking things through; sometimes impulsivity may lead to difficulties in motor control + * **Hyperactivity:** Difficulty regulating activity to an appropriate level for the situation; trouble sitting still and winding down, possibly mixed with periods of exhaustion + + + +Hyperactivity in children is often physical; in adults, it's more of an internal restlessness that might cause sleeping problems (among other things). Some people with ADHD have one of the three core symptoms, and others have two or all of them. + +#### Dyslexia + +Some people with neurodiverse conditions also have problems with reading and writing. This might be related to difficulties in attention, hyperactivity, and impulsivity. However, they might also be caused by [dyslexia][5]. + + * People with dyslexia have difficulty recognizing and understanding words. They might place letters in the incorrect order, making reading comprehension more difficult. + * Dyslexia isn't correlated with intelligence. + * Dyslexia can't be cured, but accommodations can help a great deal in school and work. + * Reading a lot and listening to audiobooks can improve the ability of people with dyslexia to read and write. + + + +### Asperger's and ADHD at work + +While the symptoms associated with Asperger's and ADHD can make some parts of work challenging, other aspects give neurodiverse people advantages in the workplace. + +#### Asperger's + +Some of the skills people with [autism spectrum disorders bring to the workplace][6]: + + * High concentration power and precision in work + * Attention to minute details + * Patience for repetitive tasks + * Higher memory power (can remember tiny details) + * Hard-working + * Loyal + + + +#### ADHD + +Some of the skills people with [ADHD bring to the workforce][7]: + + * Able to find unique solutions to difficult problems + * Can talk about many different topics at one time + * Good in a crisis; some of the most stressful jobs are staffed by those with ADHD + * Empathetic and intuitive + * Entrepreneurial + + + +### Making software more accessible + +The descriptions above are highly generalized and may not apply to all adults with Asperger's, ADHD, and dyslexia. One problem with current accessibility standards is that they confuse different neurodiversities. For example, they may not differentiate between autism with and without intellectual disability, the latter of which is called Asperger's or Autism Level 1, or they may assume dyslexia is an intellectual disability. + +In his article [_User interface for people with autism spectrum disorders_][8], Nikolay Pavlov provides some suggestions to improve UI design: + + * Use simple graphics + * Strive for simple, clear navigation + * Do not use complex menus + + + +People with Asperger's have different needs, abilities, and preferences, so these accommodations won't be beneficial to everyone. These UI features could also help people who have autism with intellectual disability, ADHD, dyslexia without intellectual disability, and other conditions. Therefore, when considering making accommodations in software, think carefully about your target group. And know that if you ask people for input, you will probably get many different answers. + +People with ADHD especially might benefit from one of Pavlov's other recommendations: + + * Use visual indicators for time-consuming actions + + + +This is valuable when people perceive that an app or web page is not loading quickly enough. I appreciate when systems give continuous feedback on their progress because it tells me that everything is in working order. + +### Examples of accessibility + +The GNOME calendar offers a good example of making software more accessible. + +Compare the standard date view: + +![Standard GNOME calendar][9] + +(Rikard Grossman-Nielsen, [CC BY-SA 4.0][10]) + +To this modified view: + +![Modified GNOME calendar][11] + +(Rikard Grossman-Nielsen, [CC BY-SA 4.0][10]) + +It's a lot easier to find the marked date with the yellow circle around the number 29. + +In contrast, [Vi and Vim][12] are among the least accessible text editors I've ever used, but note they aren't designed with accessibility in mind. My biggest problem is that that they don't offer any cues to their different commands. When I use a terminal editor, I prefer [Nano][13] because it provides cues to what keyboard commands to use. Most often, I use a graphical user interface (GUI) editor like [Gedit][14] or Nedit because it's easier for me to create text in a GUI editor. + +### How GNOME embraces diversity + +I've found that [GNOME][15] is the best of the large Linux desktop environments for offering accessibility features, but it can definitely still improve. Because I'm interested in Linux on the desktop and making it even more accessible, I joined the team planning [GUADEC][16], the GNOME Users And Developers European Conference. + +GUADEC embraces a climate of diversity, both in theory and practice. The conference provides accommodations, such as captioning for online lectures and quiet rooms at physical events. The 2021 conference, to be held online July 21–25, will have a few lectures on UI design, and I will offer a workshop on [making open source applications more accessible][17]. If you'd like to learn more, visit the GUADEC website and [register][18]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/open-source-neurodiversity + +作者:[Rikard Grossman-Nielsen][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/rikardgn +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LAW_EvidencedBasedIP_520x292_CS.png?itok=mmhCWuZR (a magnifying glass looking at a brain illustration) +[2]: https://hbr.org/2017/05/neurodiversity-as-a-competitive-advantage +[3]: https://en.wikipedia.org/wiki/Asperger_syndrome +[4]: https://en.wikipedia.org/wiki/Attention_deficit_hyperactivity_disorder +[5]: https://en.wikipedia.org/wiki/Dyslexia +[6]: https://www.thehrdigest.com/autistic-workers-strength-not-weakness/ +[7]: https://adhdatwork.add.org/potential-benefits-of-having-an-adhd-employee/ +[8]: https://www.researchgate.net/publication/276495184_User_Interface_for_People_with_Autism_Spectrum_Disorders +[9]: https://opensource.com/sites/default/files/uploads/gnome-calendar-standard.png (Standard GNOME calendar) +[10]: https://creativecommons.org/licenses/by-sa/4.0/ +[11]: https://opensource.com/sites/default/files/uploads/gnome-calendar-modified.png (Modified GNOME calendar) +[12]: https://opensource.com/resources/what-vim +[13]: https://opensource.com/article/20/12/gnu-nano +[14]: https://opensource.com/article/20/12/gedit +[15]: https://opensource.com/downloads/cheat-sheet-gnome-3 +[16]: https://events.gnome.org/event/9/ +[17]: https://events.gnome.org/event/9/contributions/240/ +[18]: https://events.gnome.org/event/9/registrations/34/ diff --git a/sources/tech/20210721 Run GitHub Actions on Fedora CoreOS.md b/sources/tech/20210721 Run GitHub Actions on Fedora CoreOS.md new file mode 100644 index 0000000000..c4b80e2b99 --- /dev/null +++ b/sources/tech/20210721 Run GitHub Actions on Fedora CoreOS.md @@ -0,0 +1,219 @@ +[#]: subject: (Run GitHub Actions on Fedora CoreOS) +[#]: via: (https://fedoramagazine.org/run-github-actions-on-fedora-coreos/) +[#]: author: (Clément Verna https://fedoramagazine.org/author/cverna/) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Run GitHub Actions on Fedora CoreOS +====== + +![][1] + +[United Artists][2], Public domain, via Wikimedia Commons + +[GitHub Actions][3] is a service provided to quickly setup continuous integration and delivery (CI/CD) workflows . These workflows run on hosts called _runners_. GitHub provides [hosted runners][4] with a limited set of operating system choice (Windows Server, Ubuntu, MacOS). + +Another option is to use [self-hosted][5] runners which gives the repository administrator more control on the runners. Self-hosted runners are dedicated to a repository or organization. The following article goes through the steps of configuring self-hosted runners using Fedora CoreOS. + +### Getting Started + +Fedora CoreOS is a minimalist operating system designed to be easy to deploy and maintain at scale. The operating system will automaticaly update and provide, by default, the tools needed to run containers. For all of these reasons, Fedora CoreOS is a great choice to consider for running CI/CD workflows. + +The first step to configure and provision a Fedora CoreOS machine is to generate an [Ignition][6] file. [Butane][7] allows you to generate Ignition’s file using a friendlier format (YAML). + +#### Configure a Fedora CoreOS runner + +To execute GitHub actions on Fedora CoreOS, the host needs the binaries and scripts used to register and run the runner. Download the binaries and scripts from the [actions runner project][8] and deploy under _/usr/local/sbin/actions-runner_. + +``` +version: "1.3.0" +variant: fcos +storage: + directories: + - path: /usr/local/sbin/actions-runner + mode: 0755 + user: + name: core + group: + name: core + files: + - path: /usr/local/sbin/actions-runner/actions-runner-linux.tar.gz + overwrite: true + contents: + source: https://github.com/actions/runner/releases/download/v2.278.0/actions-runner-linux-x64-2.278.0.tar.gz + mode: 0755 + user: + name: core + group: + name: core +``` + +#### Registration and Removal token + +Configuring runners for a project requires a “token”. This prevents registering or removing self-hosted runners from projects without the correct permissions. Tokens provided by Github have a one hour expiration time. If the runner restarts after this time it will require a new registration token. + +The token can be problematic, in particular with Fedora CoreOS automatic updates. The update process expects that the host will restart at least once every couple weeks after receiving new data. + +Luckily, it is possible to use GitHub REST API to obtain these tokens and automatically configure the runner every time the host restarts. The following _manage-runner.sh_ script uses the APIs to retrieve a token, remove any runner already configured and register the runner with a new token. + +``` +#!/bin/bash +# Handles the Github Action runner configuration. +# Remove and Registration token expires after 1 hour, if we want our runner +# to work after a reboot (auto update) we need to refresh the tokens. + +# First remove the runner with a fresh remove token +REMOVE_TOKEN=$(curl -u ${GITHUB_USER}:${GITHUB_TOKEN} -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${GITHUB_USER}/${GITHUB_REPO}/actions/runners/remove-token | jq -r '.token') +/usr/local/sbin/actions-runner/config.sh remove --token ${REMOVE_TOKEN} + + +# Then register the runner with a fresh registration token +REGISTRATION_TOKEN=$(curl -u ${GITHUB_USER}:${GITHUB_TOKEN} -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${GITHUB_USER}/${GITHUB_REPO}/actions/runners/registration-token | jq -r '.token') +/usr/local/sbin/actions-runner/config.sh --url https://github.com/cverna/fcos-actions-runner --token ${REGISTRATION_TOKEN} --labels fcos --unattended +``` + +The script above uses a few environment variables that contain a GitHub username and a [Personal Access Token][9] used to authenticate the REST API requests. The Personal Access Token requires the repo permissions in order to successfully retrieve the runner registration and removal tokens. The token is security sensitive so it is better to store it in a different file with stricter permissions. In this example that file is _actions-runner_. + +``` +GITHUB_USER= +GITHUB_REPO= +GITHUB_TOKEN= +``` + +Following is the Butane snippet that creates these two files – _manage-runner.sh_ and _actions-runner_. + +``` +- path: /usr/local/sbin/actions-runner/manage-runner.sh + contents: + local: manage-runner.sh + mode: 0755 + user: + name: core + group: + name: core + - path: /etc/actions-runner + contents: + local: actions-runner + mode: 0700 + user: + name: core + group: + name: core +``` + +### Running Actions on Fedora CoreOS + +Finally, create the systemd services that will configure and start the runner. Define the services in the Butane configuration file. + +``` +systemd: + units: + - name: github-runner-configure.service + enabled: true + contents: | + [Unit] + Description=Configure the github action runner for a repository + After=network-online.target boot-complete.target + Requires=boot-complete.target + [Service] + EnvironmentFile=/etc/actions-runner + Type=oneshot + RemainAfterExit=yes + User=core + WorkingDirectory=/usr/local/sbin/actions-runner + ExecStartPre=tar xvf actions-runner-linux.tar.gz --no-same-owner + ExecStart=/usr/local/sbin/actions-runner/manage-runner.sh + [Install] + WantedBy=multi-user.target + - name: github-runner.service + enabled: true + contents: | + [Unit] + Description=Run the github action runner + After=github-runner-configure.service + [Service] + WorkingDirectory=/usr/local/sbin/actions-runner + User=core + ExecStart=/usr/local/sbin/actions-runner/run.sh + [Install] + WantedBy=multi-user.target +``` + +This creates two services, _github-runner-configure.service_ (running once when the host has finished booting) and _github-runner.service_ (running the Actions runner binaries and waiting for new CI/CD jobs). + +Now that the Butane configuration is complete, generate an Ignition file out of it and provision a Fedora CoreOS Actions runner. + +``` +$ podman run -i --rm -v $PWD:/code:z --workdir /code quay.io/coreos/butane:release --pretty --strict --files-dir /code config.yaml -o config.ignition +``` + +Once the Ignition file is generated, it can be used to provision a runner on the platforms where Fedora CoreOS is [available][10]. + +> [Getting started with Fedora CoreOS][11] + +### Configure an Action to use a self-hosted runner + +The following test Action workflow will test the FCOS self-hosted worker. Create the following file in your git repository _.github/workflows/main.yml_ + +``` +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: [ main ] + pull_request: + branches: [ main ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: fcos + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Runs a single command using the runners shell + - name: Run a one-line script + run: podman run --rm fedora-minimal:34 echo Hello World ! +``` + +Note that the _runs-on_ configuration is set up to use a runner with the label _fcos_. + +The code presented in this article is available [here][12]. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/run-github-actions-on-fedora-coreos/ + +作者:[Clément Verna][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/cverna/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2021/07/modern-times-816x345.jpg +[2]: https://commons.wikimedia.org/wiki/File:Chaplin_-_Modern_Times.jpg +[3]: https://docs.github.com/en/actions +[4]: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners +[5]: https://docs.github.com/en/actions/hosting-your-own-runners +[6]: https://github.com/coreos/ignition +[7]: https://github.com/coreos/butane +[8]: https://github.com/actions/runner +[9]: https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token +[10]: https://docs.fedoraproject.org/en-US/fedora-coreos/bare-metal/ +[11]: https://fedoramagazine.org/getting-started-with-fedora-coreos/ +[12]: https://github.com/cverna/fcos-actions-runner diff --git a/sources/tech/20210721 Write your first web component.md b/sources/tech/20210721 Write your first web component.md new file mode 100644 index 0000000000..a2029f8ec6 --- /dev/null +++ b/sources/tech/20210721 Write your first web component.md @@ -0,0 +1,191 @@ +[#]: subject: (Write your first web component) +[#]: via: (https://opensource.com/article/21/7/web-components) +[#]: author: (Ramakrishna Pattnaik https://opensource.com/users/rkpattnaik780) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +Write your first web component +====== +Don't repeat yourself; create elements you can reuse when writing web +apps for any browser. +![Digital creative of a browser on the internet][1] + +Web components are a collection of open source technologies such as JavaScript and HTML that allow you to create custom elements that you can use and reuse in web apps. The components you create are independent of the rest of your code, so they're easy to reuse across many projects. + +Best of all, it's a platform standard supported by all major modern browsers. + +### What's in a web component? + + * **Custom elements:** This JavaScript API allows you to define new types of HTML elements. + * **Shadow DOM:** This JavaScript API provides a way to attach a hidden separate [Document Object Model][2] (DOM) to an element. This encapsulates your web component by keeping the styling, markup structure, and behavior isolated from other code on the page. It ensures that styles are not overridden by external styles or, conversely, that a style from your web component doesn't "leak" into the rest of the page**.** + * **HTML templates:** The element allows you to define reusable DOM elements. The element and its contents are not rendered in the DOM but can still be referenced using JavaScript. + + + +### Write your first web component + +You can write a simple web component with your favorite text editor and JavaScript. This how-to uses bootstrap to generate simple stylings then creates a simple card web component to display the temperature of a location passed to it as an attribute. The component uses the [Open Weather API][3], which requires you to generate an APPID/APIKey by signing in. + +The syntax of calling this web component requires the location's longitude and latitude: + + +``` +`` +``` + +Create a file named **weather-card.js** that will contain all the code for your web component. Start by defining your component. This can be done by creating a template element and adding some simple HTML elements into it: + + +``` +const template = document.createElement('template'); + +template.innerHTML = ` +  <div class="card"> +    <div class="card-body"></div> +  </div> +` +``` + +Start defining the WebComponent class and its constructor: + + +``` +class WeatherCard extends HTMLElement { +  constructor() { +    super(); +    this._shadowRoot = this.attachShadow({ 'mode': 'open' }); +    this._shadowRoot.appendChild(template.content.cloneNode(true)); +  } +  …. +} +``` + +The constructor attaches the shadowRoot and sets it to open mode. Then the template is cloned to shadowRoot. + +Next, access the attributes. These are the longitude and latitude, and you need them to make a GET request to the Open Weather API. This needs to be done in the `connectedCallback` function. You can use the `getAttribute` method to access the attributes or define getters to bind them to this object: + + +``` +get longitude() { +  return this.getAttribute('longitude'); +} + +get latitude() { +  return this.getAttribute('latitude'); +} +``` + +Now define the `connectedCallBack` method that fetches weather data whenever it is mounted: + + +``` +connectedCallback() { +  var xmlHttp = new XMLHttpRequest(); +  const url = `[http://api.openweathermap.org/data/2.5/weather?lat=${this.latitude}\&lon=${this.longitude}\&appid=API\\_KEY\\`][4] +  xmlHttp.open("GET", url, false); +  xmlHttp.send(null); +  this.$card = this._shadowRoot.querySelector('.card-body'); +  let responseObj = JSON.parse(xmlHttp.responseText); +  let $townName = document.createElement('p'); +  $townName.innerHTML = `Town: ${responseObj.name}`; +  this._shadowRoot.appendChild($townName); +  let $temperature = document.createElement('p'); +  $temperature.innerHTML = `${parseInt(responseObj.main.temp - 273)} &deg;C` +  this._shadowRoot.appendChild($temperature); +} +``` + +Once the weather data is retrieved, additional HTML elements are added to the template. Now, your class is defined. + +Finally, define and register a new custom element by using the method `window.customElements.define`: + + +``` +`window.customElements.define('weather-card', WeatherCard);` +``` + +The first argument is the name of the custom element, and the second argument is the defined class. Here's a [link to the entire component][5]. + +You've written your first web component! Now it's time to bring it to the DOM. To do that, you must load the JavaScript file with your web component definition in your HTML file (name it **index.html**): + + +``` +<!DOCTYPE html> +<html> + +<head> +  <meta charset="UTF-8"> +</head> + +<body> +  <weather-card longitude='85.8245' latitude='20.296'></weather-card> +  <script src='./weather-card.js'></script> +</body> + +</html> +``` + +Here's your web component in a browser: + +![Web component displayed in a browser][6] + +(Ramakrishna Pattnaik, [CC BY-SA 4.0][7]) + +Because web components need only HTML, CSS, and JavaScript, they are natively supported by browsers and can be used seamlessly with frontend frameworks, including React and Vue. The following simple code snippet shows how to use web components with a simple React App bootstrapped with [Create React App][8]. For this, you need to import the **weather-card.js** file you defined earlier and use it as a component: + + +``` +import './App.css'; +import './weather-card'; + +function App() { +  return ( +  <weather-card longitude='85.8245' latitude='20.296'></weather-card> +  ); +} + +export default App; +``` + +### Lifecycle of a web component + +All components follow a lifecycle from initialization to removal from the DOM (i.e., unmount). Methods are associated with each lifecycle event so that you can control the components better. The various lifecycle events of a web component include: + + * **Constructor:** The constructor for a web component is called before it is mounted, meaning it's created before the element is attached to the document. It's used for initializing local state, binding event handlers, and creating the shadow DOM. The constructor must make a call to `super()` to call the class the Web Component class extends. + * **ConnectedCallBack:** This is called when an element is mounted (that is, inserted into the DOM tree). It deals with initializations creating DOM nodes and is used mostly for operations like instantiating network requests. React developers can relate it to `componentDidMount`. + * **attributeChangedCallback:** This method accepts three arguments: `name`, `oldValue`, and `newValue`. It is called whenever one of the component's observed attributes gets changed. Attributes are declared observed attributes using a static `observedAttributes` getter: [code] static get observedAttributes() { +  return ['name', '_id']; +} [/code] `attributeChangedCallback` will be called whenever the attribute name or `_id` is changed. + * **DisconnectedCallBack:** This is called when an element is removed from the DOM tree (i.e., unmounted). It is equivalent to React's `componentWillUnmount`. It is used to free resources that won't be garbage-collected automatically, like unsubscribing from DOM events, stopping interval timers, or unregistering all registered callbacks. + * **AdoptedCallback:** It is called each time the custom element is moved to a new document. It only occurs when dealing with IFrames. + + + +### Modular open source + +Web components can be a powerful way to develop web apps. Whether you're comfortable with JavaScript or just getting started with it, it's easy to create reusable code with this great open standard, no matter what browser your target audience uses. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/web-components + +作者:[Ramakrishna Pattnaik][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/rkpattnaik780 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet) +[2]: https://en.wikipedia.org/wiki/Document_Object_Model +[3]: https://openweathermap.org/api +[4]: http://api.openweathermap.org/data/2.5/weather?lat=${this.latitude}\&lon=${this.longitude}\&appid=API\_KEY\` +[5]: https://gist.github.com/rkpattnaik780/acc683d3796102c26c1abb03369e31f8 +[6]: https://opensource.com/sites/default/files/uploads/webcomponent.png (Web component displayed in a browser) +[7]: https://creativecommons.org/licenses/by-sa/4.0/ +[8]: https://create-react-app.dev/docs/getting-started/ diff --git a/sources/tech/20210722 How to manage feedback on your open project.md b/sources/tech/20210722 How to manage feedback on your open project.md new file mode 100644 index 0000000000..64190179ed --- /dev/null +++ b/sources/tech/20210722 How to manage feedback on your open project.md @@ -0,0 +1,99 @@ +[#]: subject: (How to manage feedback on your open project) +[#]: via: (https://opensource.com/open-organization/21/7/manage-feedback-open-project) +[#]: author: (Laura Hilliger https://opensource.com/users/laurahilliger) +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +How to manage feedback on your open project +====== +Open projects generate feedback—lots of it. How can leaders manage it +all? This process might help. +![red pen editing mistakes][1] + +People who let open principles guide their leadership practices in open organizations inevitably find themselves fielding feedback. Lots of feedback. + +That's by design. Open leaders [invite comment and critique][2] on just about anything they can. + +But it also poses a regular challenge: How to sift through, manage, evaluate, and address that feedback in authentic and useful ways? + +Members of the Open Organization project got a taste of this process recently. Working on the Open Leadership Definition—a robust, [collaborative description][3] of the specific mindsets and behaviors associated with open styles of leadership—collaborators solicited community-wide feedback on a multi-hundred-word draft document. The results were impressive—even if a bit intimidating. + +As we continue diligently working through the feedback we received, we thought we'd offer some insight into our own process for managing a significant amount of feedback—in case it's useful to others trying to do the same. + +### The challenge + +First, we [invited anyone to read and comment][4] directly on our draft documents. Results were humbling. We're so pleased to have received so many thoughtful comments and ideas for improvement. But we received _a lot_ of comments. + +We needed some way to organize, analyze, review, address, and respond to all those comments. After all, in open organizations, feedback is only valuable and effective to the extent that people respond to and act on it.  + +So we turned to a well-known technological advancement that has changed the lives of many: the spreadsheet. We collected all the comments we received in a single place—and made sure everyone could see what we were doing along the way. + +The result: a [collaborative and transparent worksheet][5] anyone can follow as they watch us edit and revise in line with the community's stellar feedback. + +### The process + +But collecting feedback is only part of the work (and the easiest part, at that). Next, we knew we needed to create (and publish) a step-by-step process anyone could follow when collaborating on edits to the Open Leadership Definition. + +But collecting feedback is only part of the work (and the easiest part, at that). + +Here's what we can up with: + + 1. Review feedback left in section documents. + 2. Record/transcribe feedback, comments, and suggestions into our spreadsheet. + 3. Assign editorial leads for each document section. + 4. (Editorial leads) Systematically review comments in biweekly community calls with other contributors. + 5. (Editorial leads) Address reviewer comments, make necessary editorial changes to documents. + 6. (Editorial leads) Record their decisions, changes, and/or correspondence in the spreadsheet. + + + +Without a doubt, it's more work than simply jumping into the document and making the changes we thought were most appropriate. Because all our work—all the feedback we received, and all the ways we were _responding_ to that feedback—was open and transparent, we'll need to _reflect on_ and _justify_ every editorial decision we made. It takes time. But it's the least we can do to reciprocate the kindness our community showed us in leaving their feedback (after all, that took time, too!). + +### The results (so far) + +As we've worked, we've categorized feedback into seven different "types." Some, like typos and grammar issues, are no-brainers; we'll integrate this feedback and clean up our mistakes. Others, like those that suggest additional ideas or ask us to rethink assumptions, might _also_ be no-brainers—but not all of them can be integrated so easily. So, we're using our biweekly calls to work through and discuss this feedback. + +That's the most fun part—the part where we get to connect for live chatter and debate about how we are—or aren't—going to address what the community has raised. + +Here's a summary of what we've seen and debated so far. + +#### Working on the preamble + +The first section we reviewed was the document's "preamble," which received a lot of insightful and important comments that underscored the importance of nuance. This piece of the definition summarizes the rest, and so we need to get it right. Here's what we discussed. + +**The types of organizations where open leaders thrive.** We've discussed the ways open leaders can enhance organizations operating with all kinds of cultures—but argued that they're _especially_ important in _open_ organizations (because of the way command-and-control thinking can stymie openness). We acknowledge that all kinds of organizations can be open organizations—not just those wrestling with ambiguity or focusing on innovation. + +**Organizations as actors.** One interesting debate centered on writing that seemed to treat _organizations themselves_ as individual actors—rather than, say, _groups_ of individual actors. Some of us argued that organizations are more than the sum of their components and that sentences like "open leaders make organizations more self-aware" made perfect sense. Others countered that this made organizations seem like sentient beings, when in fact they're _collections_ of sentient beings. We were personifying organizations, in other words. Ultimately, we were able to find a way to both defend the sentiment that an organization can be reflective (concerned with its own context, boundaries, and limitations) and yet do so in a way that doesn't completely anthropomorphize the organization. The line is blurry at best. So we discussed how open leaders support a culture of self awareness and edited our language in the preamble to try and better balance this philosophical point. + +That's the most fun part—the part where we get to connect for live chatter and debate about how we are—or aren't—going to address what the community has raised. + +**Mindsets and behaviors.** Here again we arrived at the question that motivated this project in the first place: _What is open leadership?_ We debated the status of "open leadership" as a "mindset" versus a "skill" versus a "practice" (each of these designations has implications for how we define open leadership and how we help others adopt it), and doing this meant negotiating the complexities of character, ego, mindfulness, and more. For instance, a skill can generally be taught, but there's more nuance to what we all believe can be "taught" versus "experienced." And as our document shows, open leadership isn't just a set of things people _do_; it's a _way of thinking_, too. So we settled on open leadership as being a specific set of "mindsets and behaviors," an organic decision [inspired by Red Hat's definition][6] of the "open leadership" concept. + +**Open leaders and character.** Other excellent reviewer comments led us to discuss distributed leadership, planned obsolescence as a positive attribute and how "authority" to lead only lasts as long as people grant that authority. We discussed a nebulous quality open leaders have, character traits and experience that people value and therefore are willing to go to when support is needed. Some of our revisions will certainly reflect this discussion. + +### Slow and steady wins the race + +We've only just begun processing feedback on the Open Leadership Definition draft. We'll continue revising (and discussing!) in our biweekly calls, and we're planning new pieces about this work. We're eager to learn from our community and hear how this work can be more useful, so while the current draft is closed to comments, we always invite feedback. [Why not follow along][5]? And keep an eye out for future opportunities to get involved. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/21/7/manage-feedback-open-project + +作者:[Laura Hilliger][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/laurahilliger +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_mistakes.png?itok=dN0OoIl5 (red pen editing mistakes) +[2]: https://opensource.com/open-organization/17/8/what-to-do-when-nobody-participates +[3]: https://github.com/open-organization/editorial/issues/94 +[4]: https://opensource.com/open-organization/21/6/celebrate-sixth-anniversary +[5]: https://docs.google.com/spreadsheets/d/1ETyMtoNK9MpkTOm2wUvqBBtcnf1S6wGWOUPvOYFyrx8/edit#gid=0 +[6]: https://github.com/red-hat-people-team/red-hat-multiplier diff --git a/sources/tech/20210722 Write your first JavaScript code.md b/sources/tech/20210722 Write your first JavaScript code.md new file mode 100644 index 0000000000..0450e56fdd --- /dev/null +++ b/sources/tech/20210722 Write your first JavaScript code.md @@ -0,0 +1,204 @@ +[#]: 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: (lixin555) +[#]: 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 `