mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-03 23:40:14 +08:00
commit
607b48c19b
@ -0,0 +1,69 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (ShuyRoy)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13109-1.html)
|
||||
[#]: subject: (Intel formally launches Optane for data center memory caching)
|
||||
[#]: via: (https://www.networkworld.com/article/3387117/intel-formally-launches-optane-for-data-center-memory-caching.html#tk.rss_all)
|
||||
[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/)
|
||||
|
||||
英特尔 Optane:用于数据中心内存缓存
|
||||
======
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/12/111720yq1rvxcncjdsjb0g.jpg)
|
||||
|
||||
> 英特尔推出了包含 3D Xpoint 内存技术的 Optane 持久内存产品线。英特尔的这个解决方案介乎于 DRAM 和 NAND 中间,以此来提升性能。
|
||||
|
||||
![Intel][1]
|
||||
|
||||
英特尔在 2019 年 4 月的[大规模数据中心活动][2]中正式推出 Optane 持久内存产品线。它已经问世了一段时间,但是目前的 Xeon 服务器处理器还不能充分利用它。而新的 Xeon8200 和 9200 系列可以充分利用 Optane 持久内存的优势。
|
||||
|
||||
由于 Optane 是英特尔的产品(与美光合作开发),所以意味着 AMD 和 ARM 的服务器处理器不能够支持它。
|
||||
|
||||
正如[我之前所说的][3],OptaneDC 持久内存采用与美光合作研发的 3D Xpoint 内存技术。3D Xpoint 是一种比 SSD 更快的非易失性内存,速度几乎与 DRAM 相近,而且它具有 NAND 闪存的持久性。
|
||||
|
||||
第一个 3D Xpoint 产品是被称为英特尔“尺子”的 SSD,因为它们被设计成细长的样子,很像尺子的形状。它们被设计这样是为了适合 1u 的服务器机架。在发布的公告中,英特尔推出了新的利用四芯或者 QLC 3D NAND 内存的英特尔 SSD D5-P4325 [尺子][7] SSD,可以在 1U 的服务器机架上放 1PB 的存储。
|
||||
|
||||
OptaneDC 持久内存的可用容量最初可以通过使用 128GB 的 DIMM 达到 512GB。英特尔数据中心集团执行副总裁及总经理 Navin Shenoy 说:“OptaneDC 持久内存可达到的容量是 DRAM 的 2 到 4 倍。”
|
||||
|
||||
他说:“我们希望服务器系统的容量可以扩展到每个插槽 4.5TB 或者 8 个插槽 36TB,这是我们第一代 Xeon 可扩展芯片的 3 倍。”
|
||||
|
||||
### 英特尔Optane内存的使用和速度
|
||||
|
||||
Optane 有两种不同的运行模式:内存模式和应用直连模式。内存模式是将 DRAM 放在 Optane 内存之上,将 DRAM 作为 Optane 内存的缓存。应用直连模式是将 DRAM 和 OptaneDC 持久内存一起作为内存来最大化总容量。并不是每个工作负载都适合这种配置,所以应该在对延迟不敏感的应用程序中使用。正如英特尔推广的那样,Optane 的主要使用情景是内存模式。
|
||||
|
||||
几年前,当 3D Xpoint 最初发布时,英特尔宣称 Optane 的速度是 NAND 的 1000 倍,耐用是 NAND 的 1000 倍,密度潜力是 DRAM 的 10 倍。这虽然有点夸张,但这些因素确实很令人着迷。
|
||||
|
||||
在 256B 的连续 4 个缓存行中使用 Optane 内存可以达到 8.3GB/秒的读速度和 3.0GB/秒的写速度。与 SATA SSD 的 500MB/秒左右的读/写速度相比,可以看到性能有很大提升。请记住,Optane 充当内存,所以它会缓存被频繁访问的 SSD 中的内容。
|
||||
|
||||
这是了解 OptaneDC 的关键。它能将非常大的数据集存储在离内存非常近的位置,因此具有很低延迟的 CPU 可以最小化访问较慢的存储子系统的访问延迟,无论存储是 SSD 还是 HDD。现在,它提供了一种可能性,即把多个 TB 的数据放在非常接近 CPU 的地方,以实现更快的访问。
|
||||
|
||||
### Optane 内存的一个挑战
|
||||
|
||||
唯一真正的挑战是 Optane 插进内存所在的 DIMM 插槽。现在有些主板的每个 CPU 有多达 16 个 DIMM 插槽,但是这仍然是客户和设备制造商之间需要平衡的电路板空间:Optane 还是内存。有一些 Optane 驱动采用了 PCIe 接口进行连接,可以减轻主板上内存的拥挤。
|
||||
|
||||
3D Xpoint 由于它写数据的方式,提供了比传统的 NAND 闪存更高的耐用性。英特尔承诺 Optane 提供 5 年保修期,而很多 SSD 只提供 3 年保修期。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3387117/intel-formally-launches-optane-for-data-center-memory-caching.html#tk.rss_all
|
||||
|
||||
作者:[Andy Patrizio][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://www.networkworld.com/author/Andy-Patrizio/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://images.idgesg.net/images/article/2018/06/intel-optane-persistent-memory-100760427-large.jpg
|
||||
[2]: https://www.networkworld.com/article/3386142/intel-unveils-an-epic-response-to-amds-server-push.html
|
||||
[3]: https://www.networkworld.com/article/3279271/intel-launches-optane-the-go-between-for-memory-and-storage.html
|
||||
[4]: https://www.networkworld.com/article/3290421/why-nvme-users-weigh-benefits-of-nvme-accelerated-flash-storage.html
|
||||
[5]: https://www.networkworld.com/article/3242807/data-center/top-10-data-center-predictions-idc.html#nww-fsb
|
||||
[6]: https://www.networkworld.com/newsletters/signup.html#nww-fsb
|
||||
[7]: https://www.theregister.co.uk/2018/02/02/ruler_and_miniruler_ssd_formats_look_to_banish_diskstyle_drives/
|
||||
[8]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fapple-certified-technical-trainer-10-11
|
||||
[9]: https://www.facebook.com/NetworkWorld/
|
||||
[10]: https://www.linkedin.com/company/network-world
|
@ -0,0 +1,305 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (chensanle)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13107-1.html)
|
||||
[#]: subject: (Tmux Command Examples To Manage Multiple Terminal Sessions)
|
||||
[#]: via: (https://www.ostechnix.com/tmux-command-examples-to-manage-multiple-terminal-sessions/)
|
||||
[#]: author: (sk https://www.ostechnix.com/author/sk/)
|
||||
|
||||
基于 Tmux 的多会话终端管理示例
|
||||
======
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/11/101058ffso6wzzw94wm2ng.jpg)
|
||||
|
||||
我们已经了解到如何通过 [GNU Screen][2] 进行多会话管理。今天,我们将要领略另一个著名的管理会话的命令行实用工具 **Tmux**。类似 GNU Screen,Tmux 是一个帮助我们在单一终端窗口中创建多个会话,同一时间内同时运行多个应用程序或进程的终端复用工具。Tmux 自由、开源并且跨平台,支持 Linux、OpenBSD、FreeBSD、NetBSD 以及 Mac OS X。本文将讨论 Tmux 在 Linux 系统下的高频用法。
|
||||
|
||||
### Linux 下安装 Tmux
|
||||
|
||||
Tmux 可以在绝大多数的 Linux 官方仓库下获取。
|
||||
|
||||
在 Arch Linux 或它的变种系统下,执行下列命令来安装:
|
||||
|
||||
```
|
||||
$ sudo pacman -S tmux
|
||||
```
|
||||
|
||||
Debian、Ubuntu 或 Linux Mint:
|
||||
|
||||
```
|
||||
$ sudo apt-get install tmux
|
||||
```
|
||||
|
||||
Fedora:
|
||||
```
|
||||
$ sudo dnf install tmux
|
||||
```
|
||||
|
||||
RHEL 和 CentOS:
|
||||
|
||||
```
|
||||
$ sudo yum install tmux
|
||||
```
|
||||
|
||||
SUSE/openSUSE:
|
||||
|
||||
```
|
||||
$ sudo zypper install tmux
|
||||
```
|
||||
|
||||
以上,我们已经完成 Tmux 的安装。之后我们继续看看一些 Tmux 示例。
|
||||
|
||||
### Tmux 命令示例: 多会话管理
|
||||
|
||||
Tmux 默认所有命令的前置命令都是 `Ctrl+b`,使用前牢记这个快捷键即可。
|
||||
|
||||
> **注意**:**Screen** 的前置命令都是 `Ctrl+a`.
|
||||
|
||||
#### 创建 Tmux 会话
|
||||
|
||||
在终端中运行如下命令创建 Tmux 会话并附着进入:
|
||||
|
||||
```
|
||||
tmux
|
||||
```
|
||||
|
||||
抑或,
|
||||
|
||||
```
|
||||
tmux new
|
||||
```
|
||||
|
||||
一旦进入 Tmux 会话,你将看到一个 **沉在底部的绿色的边栏**,如下图所示。
|
||||
|
||||
![][3]
|
||||
|
||||
*创建 Tmux 会话*
|
||||
|
||||
这个绿色的边栏能很容易提示你当前是否身处 Tmux 会话当中。
|
||||
|
||||
#### 退出 Tmux 会话
|
||||
|
||||
退出当前 Tmux 会话仅需要使用 `Ctrl+b` 和 `d`。无需同时触发这两个快捷键,依次按下 `Ctrl+b` 和 `d` 即可。
|
||||
|
||||
退出当前会话后,你将能看到如下输出:
|
||||
|
||||
```
|
||||
[detached (from session 0)]
|
||||
```
|
||||
|
||||
#### 创建有名会话
|
||||
|
||||
如果使用多个会话,你很可能会混淆运行在多个会话中的应用程序。这种情况下,我们需要会话并赋予名称。譬如需要 web 相关服务的会话,就创建一个名称为 “webserver”(或任意一个其他名称) 的 Tmux 会话。
|
||||
|
||||
```
|
||||
tmux new -s webserver
|
||||
```
|
||||
|
||||
这里是新的 Tmux 有名会话:
|
||||
|
||||
![][4]
|
||||
|
||||
*拥有自定义名称的 Tmux 会话*
|
||||
|
||||
如你所见上述截图,这个 Tmux 会话的名称已经被标注为 “webserver”。如此,你可以在多个会话中,轻易的区分应用程序的所在。
|
||||
|
||||
退出会话,轻按 `Ctrl+b` 和 `d`。
|
||||
|
||||
#### 查看 Tmux 会话清单
|
||||
|
||||
查看 Tmux 会话清单,执行:
|
||||
|
||||
```
|
||||
tmux ls
|
||||
```
|
||||
|
||||
示例输出:
|
||||
|
||||
![][5]
|
||||
|
||||
*列出 Tmux 会话*
|
||||
|
||||
如你所见,我们开启了两个 Tmux 会话。
|
||||
|
||||
#### 创建非附着会话
|
||||
|
||||
有时候,你可能想要简单创建会话,但是并不想自动切入该会话。
|
||||
|
||||
创建一个非附着会话,并赋予名称 “ostechnix”,运行:
|
||||
|
||||
```
|
||||
tmux new -s ostechnix -d
|
||||
```
|
||||
|
||||
上述命令将会创建一个名为 “ostechnix” 的会话,但是并不会附着进入。
|
||||
|
||||
你可以通过使用 `tmux ls` 命令验证:
|
||||
|
||||
![][6]
|
||||
|
||||
*创建非附着会话*
|
||||
|
||||
#### 附着进入 Tmux 会话
|
||||
|
||||
通过如下命令,你可以附着进入最后一个被创建的会话:
|
||||
|
||||
```
|
||||
tmux attach
|
||||
```
|
||||
|
||||
抑或,
|
||||
|
||||
```
|
||||
tmux a
|
||||
```
|
||||
|
||||
如果你想附着进入任意一个指定的有名会话,譬如 “ostechnix”,运行:
|
||||
|
||||
```
|
||||
tmux attach -t ostechnix
|
||||
```
|
||||
|
||||
或者,简写为:
|
||||
|
||||
```
|
||||
tmux a -t ostechnix
|
||||
```
|
||||
|
||||
#### 关闭 Tmux 会话
|
||||
|
||||
当你完成或者不再需要 Tmux 会话,你可以通过如下命令关闭:
|
||||
|
||||
```
|
||||
tmux kill-session -t ostechnix
|
||||
```
|
||||
|
||||
当身处该会话时,使用 `Ctrl+b` 以及 `x`。点击 `y` 来关闭会话。
|
||||
|
||||
可以通过 `tmux ls` 命令验证。
|
||||
|
||||
关闭所有 Tmux 服务下的所有会话,运行:
|
||||
|
||||
```
|
||||
tmux kill-server
|
||||
```
|
||||
|
||||
谨慎!这将终止所有 Tmux 会话,并不会产生任何警告,即便会话存在运行中的任务。
|
||||
|
||||
如果不存在活跃的 Tmux 会话,将看到如下输出:
|
||||
|
||||
```
|
||||
$ tmux ls
|
||||
no server running on /tmp/tmux-1000/default
|
||||
```
|
||||
|
||||
#### 切割 Tmux 窗口
|
||||
|
||||
切割窗口成多个小窗口,在 Tmux 中,这个叫做 “Tmux 窗格”。每个窗格中可以同时运行不同的程序,并同时与所有的窗格进行交互。每个窗格可以在不影响其他窗格的前提下可以调整大小、移动位置和控制关闭。我们可以以水平、垂直或者二者混合的方式切割屏幕。
|
||||
|
||||
##### 水平切割窗格
|
||||
|
||||
欲水平切割窗格,使用 `Ctrl+b` 和 `"`(半个双引号)。
|
||||
|
||||
![][7]
|
||||
|
||||
*水平切割 Tmux 窗格*
|
||||
|
||||
可以使用组合键进一步切割面板。
|
||||
|
||||
##### 垂直切割窗格
|
||||
|
||||
垂直切割面板,使用 `Ctrl+b` 和 `%`。
|
||||
|
||||
![][8]
|
||||
|
||||
*垂直切割 Tmux 窗格*
|
||||
|
||||
##### 水平、垂直混合切割窗格
|
||||
|
||||
我们也可以同时采用水平和垂直的方案切割窗格。看看如下截图:
|
||||
|
||||
![][9]
|
||||
|
||||
*切割 Tmux 窗格*
|
||||
|
||||
首先,我通过 `Ctrl+b` `"` 水平切割,之后通过 `Ctrl+b` `%` 垂直切割下方的窗格。
|
||||
|
||||
如你所见,每个窗格下我运行了不同的程序。
|
||||
|
||||
##### 切换窗格
|
||||
|
||||
通过 `Ctrl+b` 和方向键(上下左右)切换窗格。
|
||||
|
||||
##### 发送命令给所有窗格
|
||||
|
||||
之前的案例中,我们在每个窗格中运行了三个不同命令。其实,也可以发送相同的命令给所有窗格。
|
||||
|
||||
为此,使用 `Ctrl+b` 然后键入如下命令,之后按下回车:
|
||||
|
||||
```
|
||||
:setw synchronize-panes
|
||||
```
|
||||
|
||||
现在在任意窗格中键入任何命令。你将看到相同命令影响了所有窗格。
|
||||
|
||||
##### 交换窗格
|
||||
|
||||
使用 `Ctrl+b` 和 `o` 交换窗格。
|
||||
|
||||
##### 展示窗格号
|
||||
|
||||
使用 `Ctrl+b` 和 `q` 展示窗格号。
|
||||
|
||||
##### 终止窗格
|
||||
|
||||
要关闭窗格,直接键入 `exit` 并且按下回车键。或者,按下 `Ctrl+b` 和 `x`。你会看到确认信息。按下 `y` 关闭窗格。
|
||||
|
||||
![][10]
|
||||
|
||||
*关闭窗格*
|
||||
|
||||
##### 放大和缩小 Tmux 窗格
|
||||
|
||||
我们可以将 Tmux 窗格放大到当前终端窗口的全尺寸,以获得更好的文本可视性,并查看更多的内容。当你需要更多的空间或专注于某个特定的任务时,这很有用。在完成该任务后,你可以将 Tmux 窗格缩小(取消放大)到其正常位置。更多详情请看以下链接。
|
||||
|
||||
- [如何缩放 Tmux 窗格以提高文本可见度?](https://ostechnix.com/how-to-zoom-tmux-panes-for-better-text-visibility/)
|
||||
|
||||
#### 自动启动 Tmux 会话
|
||||
|
||||
当通过 SSH 与远程系统工作时,在 Tmux 会话中运行一个长期运行的进程总是一个好的做法。因为,它可以防止你在网络连接突然中断时失去对运行进程的控制。避免这个问题的一个方法是自动启动 Tmux 会话。更多详情,请参考以下链接。
|
||||
|
||||
- [通过 SSH 登录远程系统时自动启动 Tmux 会话](https://ostechnix.com/autostart-tmux-session-on-remote-system-when-logging-in-via-ssh/)
|
||||
|
||||
### 总结
|
||||
|
||||
这个阶段下,你已经获得了基本的 Tmux 技能来进行多会话管理,更多细节,参阅 man 页面。
|
||||
|
||||
```
|
||||
$ man tmux
|
||||
```
|
||||
|
||||
GNU Screen 和 Tmux 工具都能透过 SSH 很好的管理远程服务器。学习 Screen 和 Tmux 命令,像个行家一样,彻底通过这些工具管理远程服务器。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/tmux-command-examples-to-manage-multiple-terminal-sessions/
|
||||
|
||||
作者:[sk][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[chensanle](https://github.com/chensanle)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.ostechnix.com/author/sk/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.ostechnix.com/wp-content/uploads/2019/06/Tmux-720x340.png
|
||||
[2]: https://www.ostechnix.com/screen-command-examples-to-manage-multiple-terminal-sessions/
|
||||
[3]: https://www.ostechnix.com/wp-content/uploads/2019/06/Tmux-session.png
|
||||
[4]: https://www.ostechnix.com/wp-content/uploads/2019/06/Named-Tmux-session.png
|
||||
[5]: https://www.ostechnix.com/wp-content/uploads/2019/06/List-Tmux-sessions.png
|
||||
[6]: https://www.ostechnix.com/wp-content/uploads/2019/06/Create-detached-sessions.png
|
||||
[7]: https://www.ostechnix.com/wp-content/uploads/2019/06/Horizontal-split.png
|
||||
[8]: https://www.ostechnix.com/wp-content/uploads/2019/06/Vertical-split.png
|
||||
[9]: https://www.ostechnix.com/wp-content/uploads/2019/06/Split-Panes.png
|
||||
[10]: https://www.ostechnix.com/wp-content/uploads/2019/06/Kill-panes.png
|
@ -0,0 +1,98 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (Chao-zhi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13096-1.html)
|
||||
[#]: subject: (EndeavourOS Aims to Fill the Void Left by Antergos in Arch Linux World)
|
||||
[#]: via: (https://itsfoss.com/endeavouros/)
|
||||
[#]: author: (John Paul https://itsfoss.com/author/john/)
|
||||
|
||||
EndeavourOS:填补 Antergos 在 ArchLinux 世界留下的空白
|
||||
======
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/07/225558rdb85bmm6uumro71.jpg)
|
||||
|
||||
我相信我们的大多数读者都知道 [Antergos 项目的终结][2]。在这一消息宣布之后,Antergos 社区的成员创建了几个发行版来继承 Antergos。今天,我们将着眼于 Antergos 的“精神继承人”之一:[EndeavourOS][3]。
|
||||
|
||||
### EndeavourOS 不是 Antergos 的分支
|
||||
|
||||
在我们开始之前,我想非常明确地指出,EndeavourOS 并不是一个 Antergos 的复刻版本。开发者们以 Antergos 为灵感,创建了一个基于 Arch 的轻量级发行版。
|
||||
|
||||
![Endeavouros First Boot][4]
|
||||
|
||||
根据 [这个项目网站][5] 的说法,EndeavourOS 的诞生是因为 Antergos 社区的人们想要保持 Antergos 的精神。他们的目标很简单:“让 Arch 拥有一个易于使用的安装程序和一个友好、有帮助的社区,在掌握系统的过程中能够有一个社区可以依靠。”
|
||||
|
||||
与许多基于 Arch 的发行版不同,EndeavourOS 打算像 [原生 Arch][5] 那样使用,“所以没有一键式安装你喜欢的应用程序的解决方案,也没有一堆你最终不需要的预装应用程序。”对于大多数人来说,尤其是那些刚接触 Linux 和 Arch 的人,会有一个学习曲线,但 EndeavourOS 的目标是建立一个大型友好的社区,鼓励人们提出问题并了解他们的系统。
|
||||
|
||||
![Endeavouros Installing][6]
|
||||
|
||||
### 正在进行的工作
|
||||
|
||||
EndeavourOS 在 [2019 年 5 月 23 日首次宣布成立][8] 随后 [在 7 月 15 日发布第一个版本][7]。不幸的是,这意味着开发人员无法将他们计划的所有功能全部整合进来。(LCTT 译注:本文原文发表于 2019 年,而现在,EndeavourOS 还在持续活跃着。)
|
||||
|
||||
例如,他们想要一个类似于 Antergos 的在线安装,但却遇到了[当前选项的问题][9]。“Cnchi 运行在 Antergos 生态系统之外会造成严重的问题,需要彻底重写才能发挥作用。RebornOS 的 Fenix 安装程序还没有完全成型,需要更多时间才能正常运行。”于是现在,EndeavourOS 将会和 [Calamares 安装程序 ][10] 一起发布。
|
||||
|
||||
EndeavourOS 会提供 [比 Antergos 少的东西][9]:它的存储库比 Antergos 小,尽管他们会附带一些 AUR 包。他们的目标是提供一个接近 Arch 却不是原生 Arch 的系统。
|
||||
|
||||
![Endeavouros Updating With Kalu][12]
|
||||
|
||||
开发者[进一步声明 ][13]:
|
||||
|
||||
> “Linux,特别是 Arch,核心精神是自由选择,我们提供了一个基本的安装,让你在一个精细的层面上方便地探索各项选择。我们永远不会强行为你作决定,比如为你安装 GUI 应用程序,如 Pamac,甚至采用沙盒解决方案,如 Flatpak 或 Snaps。想安装成什么样子完全取决于你,这是我们与 Antergos 或 Manjaro 的主要区别,但与 Antergos 一样,如果你安装的软件包遇到问题,我们会尽力帮助你。”
|
||||
|
||||
### 体验 EndeavourOS
|
||||
|
||||
我在 [VirtualBox][14] 中安装了 EndeavourOS,并且研究了一番。当我第一次启动时,我看到一个窗口,里面有关于安装的 EndeavourOS 网站的链接。它还有一个安装按钮和一个手动分区工具。Calamares 安装程序的安装过程非常顺利。
|
||||
|
||||
在我重新启动到新安装的 EndeavourOS 之后,迎接我的是一个彩色主题的 XFCE 桌面。我还收到了一堆通知消息。我使用过的大多数基于 Arch 的发行版都带有一个 GUI 包管理器,比如 [pamac][15] 或 [octopi][16],以进行系统更新。EndeavourOS 配有 [kalu][17](kalu 是 “Keeping Arch Linux Up-to-date” 的缩写)。它可以更新软件包、可以看 Archlinux 新闻、可以更新 AUR 包等等。一旦它检查到有更新,它就会显示通知消息。
|
||||
|
||||
我浏览了一下菜单,看看默认安装了什么。默认的安装并不多,连办公套件都没有。他们想让 EndeavourOS 成为一块空白画布,让任何人都可以创建他们想要的系统。他们正朝着正确的方向前进。
|
||||
|
||||
![Endeavouros Desktop][18]
|
||||
|
||||
### 总结思考
|
||||
|
||||
EndeavourOS 还很年轻。第一个稳定版本都没有发布多久。它缺少一些东西,最重要的是一个在线安装程序。这就是说,我们无法估计他能够走到哪一步。(LCTT 译注:本文发表于 2019 年)
|
||||
|
||||
虽然它不是 Antergos 的精确复刻,但 EndeavourOS 希望复制 Antergos 最重要的部分——热情友好的社区。很多时候,Linux 社区对初学者似乎是不受欢迎甚至是完全敌对的。我看到越来越多的人试图与这种消极情绪作斗争,并将更多的人引入 Linux。随着 EndeavourOS 团队把焦点放在社区建设上,我相信一个伟大的发行版将会诞生。
|
||||
|
||||
如果你当前正在使用 Antergos,有一种方法可以让你[不用重装系统就切换到 EndeavourOS][20]
|
||||
|
||||
如果你想要一个 Antergos 的精确复刻,我建议你去看看 [RebornOS][21]。他们目前正在开发一个名为 Fenix 的 Cnchi 安装程序的替代品。
|
||||
|
||||
你试过 EndeavourOS 了吗?你的感受如何?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/endeavouros/
|
||||
|
||||
作者:[John Paul][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[Chao-zhi](https://github.com/Chao-zhi)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/john/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/endeavouros-logo.png?ssl=1
|
||||
[2]: https://itsfoss.com/antergos-linux-discontinued/
|
||||
[3]: https://endeavouros.com/
|
||||
[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/endeavouros-first-boot.png?resize=800%2C600&ssl=1
|
||||
[5]: https://endeavouros.com/info-2/
|
||||
[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/endeavouros-installing.png?resize=800%2C600&ssl=1
|
||||
[7]: https://endeavouros.com/endeavouros-first-stable-release-has-arrived/
|
||||
[8]: https://forum.antergos.com/topic/11780/endeavour-antergos-community-s-next-stage
|
||||
[9]: https://endeavouros.com/what-to-expect-on-the-first-release/
|
||||
[10]: https://calamares.io/
|
||||
[11]: https://itsfoss.com/veltos-linux/
|
||||
[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/endeavouros-updating-with-kalu.png?resize=800%2C600&ssl=1
|
||||
[13]: https://endeavouros.com/second-week-after-the-stable-release/
|
||||
[14]: https://itsfoss.com/install-virtualbox-ubuntu/
|
||||
[15]: https://aur.archlinux.org/packages/pamac-aur/
|
||||
[16]: https://octopiproject.wordpress.com/
|
||||
[17]: https://github.com/jjk-jacky/kalu
|
||||
[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/08/endeavouros-desktop.png?resize=800%2C600&ssl=1
|
||||
[19]: https://itsfoss.com/clear-linux/
|
||||
[20]: https://forum.endeavouros.com/t/how-to-switch-from-antergos-to-endevouros/105/2
|
||||
[21]: https://rebornos.org/
|
@ -0,0 +1,72 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (stevenzdg988)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13082-1.html)
|
||||
[#]: subject: (The importance of consistency in your Python code)
|
||||
[#]: via: (https://opensource.com/article/19/12/zen-python-consistency)
|
||||
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
|
||||
|
||||
Python 代码一致性的重要性
|
||||
======
|
||||
|
||||
> 本文是 Python 之禅特殊系列的一部分,重点是第十二、十三和十四原则:模糊性和明确性的作用。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/03/231758po1lcicxmxyjxlba.jpg)
|
||||
|
||||
最小惊喜原则是设计用户界面时的一个 [准则][2]。它是说,当用户执行某项操作时,程序执行的事情应该使用户尽量少地感到意外。这和孩子们喜欢一遍又一遍地读同一本书的原因是一样的:没有什么比能够预测并让预测成真更让人欣慰的了。
|
||||
|
||||
在开发 [ABC 语言][3](Python 的灵感来源)的过程中,一个重要的见解是,编程设计是用户界面,需要使用与 UI 设计者相同的工具来设计。值得庆幸的是,从那以后,越来越多的语言采用了 UI 设计中的<ruby>可承受性<rt>affordance</rt></ruby>和<ruby>人体工程学<rt>ergonomics</rt></ruby>的概念,即使它们的应用并不严格。
|
||||
|
||||
这就引出了 [Python 之禅][4] 中的三个原则。
|
||||
|
||||
### <ruby>面对歧义,要拒绝猜测的诱惑<rt>In the face of ambiguity, refuse the temptation to guess</rt></ruby>
|
||||
|
||||
`1 + "1"` 的结果应该是什么? `"11"` 和 `2` 都是猜测。这种表达方式是*歧义的*:无论如何做都会让一些人感到惊讶。
|
||||
|
||||
一些语言选择猜测。在 JavaScript 中,结果为 `"11"`。在 Perl 中,结果为 `2`。在 C 语言中,结果自然是空字符串。面对歧义,JavaScript、Perl 和 C 都在猜测。
|
||||
|
||||
在 Python 中,这会引发 `TypeError`:这不是能忽略的错误。捕获 `TypeError` 是非典型的:它通常将终止程序或至少终止当前任务(例如,在大多数 Web 框架中,它将终止对当前请求的处理)。
|
||||
|
||||
Python 拒绝猜测 `1 + "1"` 的含义。程序员必须以明确的意图编写代码:`1 + int("1")`,即 `2`;或者 `str(1) + "1"`,即 `"11"`;或 `"1"[1:]`,这将是一个空字符串。通过拒绝猜测,Python 使程序更具可预测性。
|
||||
|
||||
### <ruby>尽量找一种,最好是唯一一种明显的解决方案<rt>There should be one—and preferably only one—obvious way to do it</rt></ruby>
|
||||
|
||||
预测也会出现偏差。给定一个任务,你能预知要实现该任务的代码吗?当然,不可能完美地预测。毕竟,编程是一项具有创造性的任务。
|
||||
|
||||
但是,不必有意提供多种冗余方式来实现同一目标。从某种意义上说,某些解决方案或许 “更好” 或 “更 <ruby>Python 化<rt>Pythonic</rt></ruby>”。
|
||||
|
||||
对 Python 美学欣赏部分是因为,可以就哪种解决方案更好进行健康的辩论。甚至可以持不同观点而继续编程。甚至为使其达成一致,接受不同意的观点也是可以的。但在这一切之下,必须有一种这样的认识,即正确的解决方案终将会出现。我们必须希望,通过商定实现目标的最佳方法,而最终达成真正的一致。
|
||||
|
||||
### <ruby>虽然这种方式一开始可能并不明显(除非你是荷兰人)<rt>Although that way may not be obvious at first (unless you're Dutch)</rt></ruby>
|
||||
|
||||
这是一个重要的警告:首先,实现任务的最佳方法往往*不*明显。观念在不断发展。Python 也在进化。逐块读取文件的最好方法,可能要等到 Python 3.8 时使用 [walrus 运算符][5](`:=`)。
|
||||
|
||||
逐块读取文件这样常见的任务,在 Python 存在近 *30年* 的历史中并没有 “唯一的最佳方法”。
|
||||
|
||||
当我在 1998 年从 Python 1.5.2 开始使用 Python 时,没有一种逐行读取文件的最佳方法。多年来,知道字典中是否有某个键的最佳方法是使用关键字 `.haskey`,直到 `in` 操作符出现才发生改变。
|
||||
|
||||
只是要意识到找到实现目标的一种(也是唯一一种)方法可能需要 30 年的时间来尝试其它方法,Python 才可以不断寻找这些方法。这种历史观认为,为了做一件事用上 30 年是可以接受的,但对于美国这个存在仅 200 多年的国家来说,人们常常会感到不习惯。
|
||||
|
||||
从 Python 之禅的这一部分来看,荷兰人,无论是 Python 的创造者 [Guido van Rossum][6] 还是著名的计算机科学家 [Edsger W. Dijkstra][7],他们的世界观是不同的。要理解这一部分,某种程度的欧洲人对时间的感受是必不可少的。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/12/zen-python-consistency
|
||||
|
||||
作者:[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/rh_003499_01_other11x_cc.png?itok=I_kCDYj0 (Two animated computers waving one missing an arm)
|
||||
[2]: https://www.uxpassion.com/blog/the-principle-of-least-surprise/
|
||||
[3]: https://en.wikipedia.org/wiki/ABC_(programming_language)
|
||||
[4]: https://www.python.org/dev/peps/pep-0020/
|
||||
[5]: https://www.python.org/dev/peps/pep-0572/#abstract
|
||||
[6]: https://en.wikipedia.org/wiki/Guido_van_Rossum
|
||||
[7]: http://en.wikipedia.org/wiki/Edsger_W._Dijkstra
|
@ -0,0 +1,45 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13103-1.html)
|
||||
[#]: subject: (The Zen of Python: Why timing is everything)
|
||||
[#]: via: (https://opensource.com/article/19/12/zen-python-timeliness)
|
||||
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
|
||||
|
||||
Python 之禅:时机最重要
|
||||
======
|
||||
|
||||
> 这是 Python 之禅特别系列的一部分,重点是第十五和第十六条原则:现在与将来。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/09/231557dkuzz22ame4ja2jj.jpg)
|
||||
|
||||
Python 一直在不断发展。Python 社区对特性请求的渴求是无止境的,对现状也总是不满意的。随着 Python 越来越流行,这门语言的变化会影响到更多的人。
|
||||
|
||||
确定什么时候该进行变化往往很难,但 [Python 之禅][2] 给你提供了指导。
|
||||
|
||||
### <ruby>现在有总比永远没有好<rt>Now is better than never</rt></ruby>
|
||||
|
||||
总有一种诱惑,就是要等到事情完美才去做,虽然,它们永远没有完美的一天。当它们看起来已经“准备”得足够好了,那就大胆采取行动吧,去做出改变吧。无论如何,变化总是发生在*某个*现在:拖延的唯一作用就是把它移到未来的“现在”。
|
||||
|
||||
### <ruby>虽然将来总比现在好<rt>Although never is often better than right now</rt></ruby>
|
||||
|
||||
然而,这并不意味着应该急于求成。从测试、文档、用户反馈等方面决定发布的标准。在变化就绪之前的“现在”,并不是一个好时机。
|
||||
|
||||
这不仅对 Python 这样的流行语言是个很好的经验,对你个人的小开源项目也是如此。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/12/zen-python-timeliness
|
||||
|
||||
作者:[Moshe Zadka][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/moshez
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/desk_clock_job_work.jpg?itok=Nj4fuhl6 (Clock, pen, and notepad on a desk)
|
||||
[2]: https://www.python.org/dev/peps/pep-0020/
|
@ -0,0 +1,244 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (Chao-zhi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13099-1.html)
|
||||
[#]: subject: (Getting Started With Pacman Commands in Arch-based Linux Distributions)
|
||||
[#]: via: (https://itsfoss.com/pacman-command/)
|
||||
[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/)
|
||||
|
||||
Arch Linux 的 pacman 命令入门
|
||||
======
|
||||
|
||||
> 这本初学者指南向你展示了在 Linux 中可以使用 pacman 命令做什么,如何使用它们来查找新的软件包,安装和升级新的软件包,以及清理你的系统。
|
||||
|
||||
[pacman][1] 包管理器是 [Arch Linux][2] 和其他主要发行版如 Red Hat 和 Ubuntu/Debian 之间的主要区别之一。它结合了简单的二进制包格式和易于使用的 [构建系统][3]。`pacman` 的目标是方便地管理软件包,无论它是来自 [官方库][4] 还是用户自己构建的软件库。
|
||||
|
||||
如果你曾经使用过 Ubuntu 或基于 debian 的发行版,那么你可能使用过 `apt-get` 或 `apt` 命令。`pacman` 在 Arch Linux 中是同样的命令。如果你 [刚刚安装了 Arch Linux][5],在安装 Arch Linux 后,首先要做的 [几件事][6] 之一就是学习使用 `pacman` 命令。
|
||||
|
||||
在这个初学者指南中,我将解释一些基本的 `pacman` 命令的用法,你应该知道如何用这些命令来管理你的基于 Archlinux 的系统。
|
||||
|
||||
### Arch Linux 用户应该知道的几个重要的 pacman 命令
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/09/111411uqadijqdd8afgk56.jpg)
|
||||
|
||||
与其他包管理器一样,`pacman` 可以将包列表与软件库同步,它能够自动解决所有所需的依赖项,以使得用户可以通过一个简单的命令下载和安装软件。
|
||||
|
||||
#### 通过 pacman 安装软件
|
||||
|
||||
你可以用以下形式的代码来安装一个或者多个软件包:
|
||||
|
||||
```
|
||||
pacman -S 软件包名1 软件包名2 ...
|
||||
```
|
||||
|
||||
![安装一个包][8]
|
||||
|
||||
`-S` 选项的意思是<ruby>同步<rt>synchronization</rt></ruby>,它的意思是 `pacman` 在安装之前先与软件库进行同步。
|
||||
|
||||
`pacman` 数据库根据安装的原因将安装的包分为两组:
|
||||
|
||||
* **显式安装**:由 `pacman -S` 或 `-U` 命令直接安装的包
|
||||
* **依赖安装**:由于被其他显式安装的包所 [依赖][9],而被自动安装的包。
|
||||
|
||||
#### 卸载已安装的软件包
|
||||
|
||||
卸载一个包,并且删除它的所有依赖。
|
||||
|
||||
```
|
||||
pacman -R 软件包名
|
||||
```
|
||||
|
||||
![移除一个包][10]
|
||||
|
||||
删除一个包,以及其不被其他包所需要的依赖项:
|
||||
|
||||
```
|
||||
pacman -Rs 软件包名
|
||||
```
|
||||
|
||||
如果需要这个依赖的包已经被删除了,这条命令可以删除所有不再需要的依赖项:
|
||||
|
||||
```
|
||||
pacman -Qdtq | pacman -Rs -
|
||||
```
|
||||
|
||||
#### 升级软件包
|
||||
|
||||
`pacman` 提供了一个简单的办法来 [升级 Arch Linux][11]。你只需要一条命令就可以升级所有已安装的软件包。这可能需要一段时间,这取决于系统的新旧程度。
|
||||
|
||||
以下命令可以同步存储库数据库,*并且* 更新系统的所有软件包,但不包括不在软件库中的“本地安装的”包:
|
||||
|
||||
```
|
||||
pacman -Syu
|
||||
```
|
||||
|
||||
* `S` 代表同步
|
||||
* `y` 代表更新本地存储库
|
||||
* `u` 代表系统更新
|
||||
|
||||
也就是说,同步到中央软件库(主程序包数据库),刷新主程序包数据库的本地副本,然后执行系统更新(通过更新所有有更新版本可用的程序包)。
|
||||
|
||||
![系统更新][12]
|
||||
|
||||
> 注意!
|
||||
>
|
||||
> 对于 Arch Linux 用户,在系统升级前,建议你访问 [Arch-Linux 主页][2] 查看最新消息,以了解异常更新的情况。如果系统更新需要人工干预,主页上将发布相关的新闻。你也可以订阅 [RSS 源][13] 或 [Arch 的声明邮件][14]。
|
||||
>
|
||||
> 在升级基础软件(如 kernel、xorg、systemd 或 glibc) 之前,请注意查看相应的 [论坛][15],以了解大家报告的各种问题。
|
||||
>
|
||||
> 在 Arch 和 Manjaro 等滚动发行版中不支持**部分升级**。这意味着,当新的库版本被推送到软件库时,软件库中的所有包都需要根据库版本进行升级。例如,如果两个包依赖于同一个库,则仅升级一个包可能会破坏依赖于该库的旧版本的另一个包。
|
||||
|
||||
#### 用 Pacman 查找包
|
||||
|
||||
`pacman` 使用 `-Q` 选项查询本地包数据库,使用 `-S` 选项查询同步数据库,使用 `-F` 选项查询文件数据库。
|
||||
|
||||
`pacman` 可以在数据库中搜索包,包括包的名称和描述:
|
||||
|
||||
```
|
||||
pacman -Ss 字符串1 字符串2 ...
|
||||
```
|
||||
|
||||
![查找一个包][16]
|
||||
|
||||
查找已经被安装的包:
|
||||
|
||||
```
|
||||
pacman -Qs 字符串1 字符串2 ...
|
||||
```
|
||||
|
||||
根据文件名在远程软包中查找它所属的包:
|
||||
|
||||
```
|
||||
pacman -F 字符串1 字符串2 ...
|
||||
```
|
||||
|
||||
查看一个包的依赖树:
|
||||
|
||||
```
|
||||
pactree 软件包名
|
||||
```
|
||||
|
||||
#### 清除包缓存
|
||||
|
||||
`pacman` 将其下载的包存储在 `/var/cache/Pacman/pkg/` 中,并且不会自动删除旧版本或卸载的版本。这有一些优点:
|
||||
|
||||
1. 它允许 [降级][17] 一个包,而不需要通过其他来源检索以前的版本。
|
||||
2. 已卸载的软件包可以轻松地直接从缓存文件夹重新安装。
|
||||
|
||||
但是,有必要定期清理缓存以防止文件夹增大。
|
||||
|
||||
[pacman contrib][19] 包中提供的 [paccache(8)][18] 脚本默认情况下会删除已安装和未安装包的所有缓存版本,但最近 3 个版本除外:
|
||||
|
||||
```
|
||||
paccache -r
|
||||
```
|
||||
|
||||
![清除缓存][20]
|
||||
|
||||
要删除当前未安装的所有缓存包和未使用的同步数据库,请执行:
|
||||
|
||||
```
|
||||
pacman -Sc
|
||||
```
|
||||
|
||||
要从缓存中删除所有文件,请使用清除选项两次,这是最激进的方法,不会在缓存文件夹中留下任何内容:
|
||||
|
||||
```
|
||||
pacman -Scc
|
||||
```
|
||||
|
||||
#### 安装本地或者第三方的包
|
||||
|
||||
安装不是来自远程存储库的“本地”包:
|
||||
|
||||
```
|
||||
pacman -U 本地软件包路径.pkg.tar.xz
|
||||
```
|
||||
|
||||
安装官方存储库中未包含的“远程”软件包:
|
||||
|
||||
```
|
||||
pacman -U http://www.example.com/repo/example.pkg.tar.xz
|
||||
```
|
||||
|
||||
### 额外内容:用 pacman 排除常见错误
|
||||
|
||||
下面是使用 `pacman` 管理包时可能遇到的一些常见错误。
|
||||
|
||||
#### 提交事务失败(文件冲突)
|
||||
|
||||
如果你看到以下报错:
|
||||
|
||||
```
|
||||
error: could not prepare transaction
|
||||
error: failed to commit transaction (conflicting files)
|
||||
package: /path/to/file exists in filesystem
|
||||
Errors occurred, no packages were upgraded.
|
||||
```
|
||||
|
||||
这是因为 `pacman` 检测到文件冲突,不会为你覆盖文件。
|
||||
|
||||
解决这个问题的一个安全方法是首先检查另一个包是否拥有这个文件(`pacman-Qo 文件路径`)。如果该文件属于另一个包,请提交错误报告。如果文件不属于另一个包,请重命名“存在于文件系统中”的文件,然后重新发出更新命令。如果一切顺利,文件可能会被删除。
|
||||
|
||||
你可以显式地运行 `pacman -S –overwrite 要覆盖的文件模式**,强制 `pacman` 覆盖与 给模式匹配的文件,而不是手动重命名并在以后删除属于该包的所有文件。
|
||||
|
||||
#### 提交事务失败(包无效或损坏)
|
||||
|
||||
在 `/var/cache/pacman/pkg/` 中查找 `.part` 文件(部分下载的包),并将其删除。这通常是由在 `pacman.conf` 文件中使用自定义 `XferCommand` 引起的。
|
||||
|
||||
#### 初始化事务失败(无法锁定数据库)
|
||||
|
||||
当 `pacman` 要修改包数据库时,例如安装包时,它会在 `/var/lib/pacman/db.lck` 处创建一个锁文件。这可以防止 `pacman` 的另一个实例同时尝试更改包数据库。
|
||||
|
||||
如果 `pacman` 在更改数据库时被中断,这个过时的锁文件可能仍然保留。如果你确定没有 `pacman` 实例正在运行,那么请删除锁文件。
|
||||
|
||||
检查进程是否持有锁定文件:
|
||||
|
||||
```
|
||||
lsof /var/lib/pacman/db.lck
|
||||
```
|
||||
|
||||
如果上述命令未返回任何内容,则可以删除锁文件:
|
||||
|
||||
```
|
||||
rm /var/lib/pacman/db.lck
|
||||
```
|
||||
|
||||
如果你发现 `lsof` 命令输出了使用锁文件的进程的 PID,请先杀死这个进程,然后删除锁文件。
|
||||
|
||||
我希望你喜欢我对 `pacman` 基础命令的介绍。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/pacman-command/
|
||||
|
||||
作者:[Dimitrios Savvopoulos][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[Chao-zhi](https://github.com/Chao-zhi)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/dimitrios/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.archlinux.org/pacman/
|
||||
[2]: https://www.archlinux.org/
|
||||
[3]: https://wiki.archlinux.org/index.php/Arch_Build_System
|
||||
[4]: https://wiki.archlinux.org/index.php/Official_repositories
|
||||
[5]: https://itsfoss.com/install-arch-linux/
|
||||
[6]: https://itsfoss.com/things-to-do-after-installing-arch-linux/
|
||||
[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/essential-pacman-commands.jpg?ssl=1
|
||||
[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/sudo-pacman-S.png?ssl=1
|
||||
[9]: https://wiki.archlinux.org/index.php/Dependency
|
||||
[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/sudo-pacman-R.png?ssl=1
|
||||
[11]: https://itsfoss.com/update-arch-linux/
|
||||
[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/sudo-pacman-Syu.png?ssl=1
|
||||
[13]: https://www.archlinux.org/feeds/news/
|
||||
[14]: https://mailman.archlinux.org/mailman/listinfo/arch-announce/
|
||||
[15]: https://bbs.archlinux.org/
|
||||
[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/sudo-pacman-Ss.png?ssl=1
|
||||
[17]: https://wiki.archlinux.org/index.php/Downgrade
|
||||
[18]: https://jlk.fjfi.cvut.cz/arch/manpages/man/paccache.8
|
||||
[19]: https://www.archlinux.org/packages/?name=pacman-contrib
|
||||
[20]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/sudo-paccache-r.png?ssl=1
|
@ -0,0 +1,201 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (Chao-zhi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13104-1.html)
|
||||
[#]: subject: (Top Arch-based User Friendly Linux Distributions That are Easier to Install and Use Than Arch Linux Itself)
|
||||
[#]: via: (https://itsfoss.com/arch-based-linux-distros/)
|
||||
[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/)
|
||||
|
||||
9 个易用的基于 Arch 的用户友好型 Linux 发行版
|
||||
======
|
||||
|
||||
在 Linux 社区中,[Arch Linux][1] 有一群狂热的追随者。这个轻量级的发行版以 DIY 的态度提供了最前沿的更新。
|
||||
|
||||
但是,Arch 的目标用户是那些更有经验的用户。因此,它通常被认为是那些技术不够(或耐心不够)的人所无法触及的。
|
||||
|
||||
事实上,只是最开始的步骤,[安装 Arch Linux 就足以把很多人吓跑][2]。与大多数其他发行版不同,Arch Linux 没有一个易于使用的图形安装程序。安装过程中涉及到的磁盘分区,连接到互联网,挂载驱动器和创建文件系统等只用命令行工具来操作。
|
||||
|
||||
对于那些不想经历复杂的安装和设置的人来说,有许多用户友好的基于 Arch 的发行版。
|
||||
|
||||
在本文中,我将向你展示一些 Arch 替代发行版。这些发行版附带了图形安装程序、图形包管理器和其他工具,比它们的命令行版本更容易使用。
|
||||
|
||||
### 更容易设置和使用的基于 Arch 的 Linux 发行版
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/10/112812sc42txp4eexco44x.jpg)
|
||||
|
||||
请注意,这不是一个排名列表。这些数字只是为了计数的目的。排第二的发行版不应该被认为比排第七的发行版好。
|
||||
|
||||
#### 1、Manjaro Linux
|
||||
|
||||
![][4]
|
||||
|
||||
[Manjaro][5] 不需要任何介绍。它是几年来最流行的 Linux 发行版之一,它值得拥有。
|
||||
|
||||
Manjaro 提供了 Arch Linux 的所有优点,同时注重用户友好性和可访问性。Manjaro 既适合新手,也适合有经验的 Linux 用户。
|
||||
|
||||
**对于新手**,它提供了一个用户友好的安装程序,系统本身也设计成可以在你[最喜爱的桌面环境 ][6](DE)或窗口管理器中直接“开箱即用”。
|
||||
|
||||
**对于更有经验的用户**,Manjaro 还提供多种功能,以满足每个个人的口味和喜好。[Manjaro Architect][7] 提供了安装各种 Manjaro 风格的选项,并为那些想要完全自由地塑造系统的人提供了各种桌面环境、文件系统([最近推出的 ZFS][8]) 和引导程序的选择。
|
||||
|
||||
Manjaro 也是一个滚动发布的前沿发行版。然而,与 Arch 不同的是,Manjaro 首先测试更新,然后将其提供给用户。稳定在这里也很重要。
|
||||
|
||||
#### 2、ArcoLinux
|
||||
|
||||
![][9]
|
||||
|
||||
[ArcoLinux][10](以前称为 ArchMerge)是一个基于 Arch Linux 的发行版。开发团队提供了三种变体。ArcoLinux、ArcoLinuxD 和 ArcoLinuxB。
|
||||
|
||||
ArcoLinux 是一个功能齐全的发行版,附带有 [Xfce 桌面][11]、[Openbox][12] 和 [i3 窗口管理器][13]。
|
||||
|
||||
**ArcoLinuxD** 是一个精简的发行版,它包含了一些脚本,可以让高级用户安装任何桌面和应用程序。
|
||||
|
||||
**ArcoLinuxB** 是一个让用户能够构建自定义发行版的项目,同时还开发了几个带有预配置桌面的社区版本,如 Awesome、bspwm、Budgie、Cinnamon、Deepin、GNOME、MATE 和 KDE Plasma。
|
||||
|
||||
ArcoLinux 还提供了各种视频教程,因为它非常注重学习和获取 Linux 技能。
|
||||
|
||||
#### 3、Archlabs Linux
|
||||
|
||||
![][14]
|
||||
|
||||
[ArchLabs Linux][15] 是一个轻量级的滚动版 Linux 发行版,基于最精简的 Arch Linux,带有 [Openbox][16] 窗口管理器。[ArchLabs][17] 在观感设计中受到 [BunsenLabs][18] 的影响和启发,主要考虑到中级到高级用户的需求。
|
||||
|
||||
#### 4、Archman Linux
|
||||
|
||||
![][19]
|
||||
|
||||
[Archman][20] 是一个独立的项目。Arch Linux 发行版对于没有多少 Linux 经验的用户来说通常不是理想的操作系统。要想在最小的挫折感下让事情变得更有意义,必须要有相当的背景知识。Archman Linux 的开发人员正试图改变这种评价。
|
||||
|
||||
Archman 的开发是基于对开发的理解,包括用户反馈和体验组件。根据团队过去的经验,将用户的反馈和要求融合在一起,确定路线图并完成构建工作。
|
||||
|
||||
#### 5、EndeavourOS
|
||||
|
||||
![][21]
|
||||
|
||||
当流行的基于 Arch 的发行版 [Antergos 在 2019 结束][22] 时,它留下了一个友好且非常有用的社区。Antergos 项目结束的原因是因为该系统对于开发人员来说太难维护了。
|
||||
|
||||
在宣布结束后的几天内,一些有经验的用户通过创建一个新的发行版来填补 Antergos 留下的空白,从而维护了以前的社区。这就是 [EndeavourOS][23] 的诞生。
|
||||
|
||||
[EndeavourOS][24] 是轻量级的,并且附带了最少数量的预装应用程序。一块近乎空白的画布,随时可以个性化。
|
||||
|
||||
#### 6、RebornOS
|
||||
|
||||
![][25]
|
||||
|
||||
[RebornOS][26] 开发人员的目标是将 Linux 的真正威力带给每个人,一个 ISO 提供了 15 个桌面环境可供选择,并提供无限的定制机会。
|
||||
|
||||
RebornOS 还声称支持 [Anbox][27],它可以在桌面 Linux 上运行 Android 应用程序。它还提供了一个简单的内核管理器 GUI 工具。
|
||||
|
||||
再加上 [Pacman][28]、[AUR][29],以及定制版本的 Cnchi 图形安装程序,Arch Linux 终于可以让最没有经验的用户也能够使用了。
|
||||
|
||||
#### 7、Chakra Linux
|
||||
|
||||
![][30]
|
||||
|
||||
一个社区开发的 GNU/Linux 发行版,它的亮点在 KDE 和 Qt 技术。[Chakra Linux][31] 不在特定日期安排发布,而是使用“半滚动发布”系统。
|
||||
|
||||
这意味着 Chakra Linux 的核心包被冻结,只在修复安全问题时才会更新。这些软件包是在最新版本经过彻底测试后更新的,然后再转移到永久软件库(大约每六个月更新一次)。
|
||||
|
||||
除官方软件库外,用户还可以安装 Chakra 社区软件库 (CCR) 的软件包,该库为官方存储库中未包含的软件提供用户制作的 PKGINFOs 和 [PKGBUILD][32] 脚本,其灵感来自于 Arch 用户软件库(AUR)。
|
||||
|
||||
#### 8、Artix Linux
|
||||
|
||||
![Artix Mate Edition][33]
|
||||
|
||||
[Artix Linux][34] 也是一个基于 Arch Linux 的滚动发行版,它使用 [OpenRC][35]、[runit][36] 或 [s6][37] 作为初始化工具而不是 [systemd][38]。
|
||||
|
||||
Artix Linux 有自己的软件库,但作为一个基于 `pacman` 的发行版,它可以使用 Arch Linux 软件库或任何其他衍生发行版的软件包,甚至可以使用明确依赖于 systemd 的软件包。也可以使用 [Arch 用户软件库][29](AUR)。
|
||||
|
||||
#### 9、BlackArch Linux
|
||||
|
||||
![][39]
|
||||
|
||||
BlackArch 是一个基于 Arch Linux 的 [渗透测试发行版][40],它提供了大量的网络安全工具。它是专门为渗透测试人员和安全研究人员创建的。该软件库包含 2400 多个[黑客和渗透测试工具 ][41],可以单独安装,也可以分组安装。BlackArch Linux 兼容现有的 Arch Linux 包。
|
||||
|
||||
### 想要真正的原版 Arch Linux 吗?可以使用图形化 Arch 安装程序简化安装
|
||||
|
||||
如果你想使用原版的 Arch Linux,但又被它困难的安装所难倒。幸运的是,你可以下载一个带有图形安装程序的 Arch Linux ISO。
|
||||
|
||||
Arch 安装程序基本上是 Arch Linux ISO 的一个相对容易使用的基于文本的安装程序。它比裸奔的 Arch 安装容易得多。
|
||||
|
||||
#### Anarchy Installer
|
||||
|
||||
![][42]
|
||||
|
||||
[Anarchy installer][43] 打算为新手和有经验的 Linux 用户提供一种简单而无痛苦的方式来安装 ArchLinux。在需要的时候安装,在需要的地方安装,并且以你想要的方式安装。这就是 Anarchy 的哲学。
|
||||
|
||||
启动安装程序后,将显示一个简单的 [TUI 菜单][44],列出所有可用的安装程序选项。
|
||||
|
||||
#### Zen Installer
|
||||
|
||||
![][45]
|
||||
|
||||
[Zen Installer][46] 为安装 Arch Linux 提供了一个完整的图形(点击式)环境。它支持安装多个桌面环境 、AUR 以及 Arch Linux 的所有功能和灵活性,并且易于图形化安装。
|
||||
|
||||
ISO 将引导一个临场环境,然后在你连接到互联网后下载最新稳定版本的安装程序。因此,你将始终获得最新的安装程序和更新的功能。
|
||||
|
||||
### 总结
|
||||
|
||||
对于许多用户来说,基于 Arch 的发行版会是一个很好的无忧选择,而像 Anarchy 这样的图形化安装程序至少离原版的 Arch Linux 更近了一步。
|
||||
|
||||
在我看来,[Arch Linux 的真正魅力在于它的安装过程][2],对于 Linux 爱好者来说,这是一个学习的机会,而不是麻烦。Arch Linux 及其衍生产品有很多东西需要你去折腾,但是在折腾的过程中你就会进入到开源软件的世界,这里是神奇的新世界。下次再见!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/arch-based-linux-distros/
|
||||
|
||||
作者:[Dimitrios Savvopoulos][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[Chao-zhi](https://github.com/Chao-zhi)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/dimitrios/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.archlinux.org/
|
||||
[2]: https://itsfoss.com/install-arch-linux/
|
||||
[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/arch-based-linux-distributions.png?ssl=1
|
||||
[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/manjaro-20.jpg?ssl=1
|
||||
[5]: https://manjaro.org/
|
||||
[6]: https://itsfoss.com/best-linux-desktop-environments/
|
||||
[7]: https://itsfoss.com/manjaro-architect-review/
|
||||
[8]: https://itsfoss.com/manjaro-20-release/
|
||||
[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/arcolinux.png?ssl=1
|
||||
[10]: https://arcolinux.com/
|
||||
[11]: https://www.xfce.org/
|
||||
[12]: http://openbox.org/wiki/Main_Page
|
||||
[13]: https://i3wm.org/
|
||||
[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/Archlabs.jpg?ssl=1
|
||||
[15]: https://itsfoss.com/archlabs-review/
|
||||
[16]: https://en.wikipedia.org/wiki/Openbox
|
||||
[17]: https://archlabslinux.com/
|
||||
[18]: https://www.bunsenlabs.org/
|
||||
[19]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/Archman.png?ssl=1
|
||||
[20]: https://archman.org/en/
|
||||
[21]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/04_endeavouros_slide.jpg?ssl=1
|
||||
[22]: https://itsfoss.com/antergos-linux-discontinued/
|
||||
[23]: https://itsfoss.com/endeavouros/
|
||||
[24]: https://endeavouros.com/
|
||||
[25]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/RebornOS.png?ssl=1
|
||||
[26]: https://rebornos.org/
|
||||
[27]: https://anbox.io/
|
||||
[28]: https://itsfoss.com/pacman-command/
|
||||
[29]: https://itsfoss.com/aur-arch-linux/
|
||||
[30]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/Chakra_Goedel_Screenshot.png?ssl=1
|
||||
[31]: https://www.chakralinux.org/
|
||||
[32]: https://wiki.archlinux.org/index.php/PKGBUILD
|
||||
[33]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/Artix_MATE_edition.png?ssl=1
|
||||
[34]: https://artixlinux.org/
|
||||
[35]: https://en.wikipedia.org/wiki/OpenRC
|
||||
[36]: https://en.wikipedia.org/wiki/Runit
|
||||
[37]: https://en.wikipedia.org/wiki/S6_(software)
|
||||
[38]: https://en.wikipedia.org/wiki/Systemd
|
||||
[39]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/BlackArch.png?ssl=1
|
||||
[40]: https://itsfoss.com/linux-hacking-penetration-testing/
|
||||
[41]: https://itsfoss.com/best-kali-linux-tools/
|
||||
[42]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/anarchy.jpg?ssl=1
|
||||
[43]: https://anarchyinstaller.org/
|
||||
[44]: https://en.wikipedia.org/wiki/Text-based_user_interface
|
||||
[45]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/zen.jpg?ssl=1
|
||||
[46]: https://sourceforge.net/projects/revenge-installer/
|
297
published/20201013 My first day using Ansible.md
Normal file
297
published/20201013 My first day using Ansible.md
Normal file
@ -0,0 +1,297 @@
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: "MjSeven"
|
||||
[#]: reviewer: "wxy"
|
||||
[#]: publisher: "wxy"
|
||||
[#]: url: "https://linux.cn/article-13079-1.html"
|
||||
[#]: subject: "My first day using Ansible"
|
||||
[#]: via: "https://opensource.com/article/20/10/first-day-ansible"
|
||||
[#]: author: "David Both https://opensource.com/users/dboth"
|
||||
|
||||
使用 Ansible 的第一天
|
||||
======
|
||||
|
||||
> 一名系统管理员分享了如何使用 Ansible 在网络中配置计算机并把其带入实际工作的信息和建议。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/03/105826sn41jj0i8evu19nn.jpg)
|
||||
|
||||
无论是第一次还是第五十次,启动并运行一台新的物理或虚拟计算机都非常耗时,而且需要大量的工作。多年来,我一直使用我创建的一系列脚本和 RPM 来安装所需的软件包,并为我喜欢的工具配置各种选项。这种方法效果很好,简化了我的工作,而且还减少了在键盘上输入命令的时间。
|
||||
|
||||
我一直在寻找更好的工作方式。近几年来,我一直在听到并且读到有关 [Ansible][2] 的信息,它是一个自动配置和管理系统的强大工具。Ansible 允许系统管理员在一个或多个<ruby>剧本<rt>playbook</rt></ruby>中为每个主机指定一个特定状态,然后执行各种必要的任务,使主机进入该状态。这包括安装或删除各种资源,例如 RPM 或 Apt 软件包、配置文件和其它文件、用户、组等等。
|
||||
|
||||
因为一些琐事,我推迟了很长一段时间学习如何使用它。直到最近,我遇到了一个我认为 Ansible 可以轻松解决的问题。
|
||||
|
||||
这篇文章并不会完整地告诉你如何入门 Ansible,相反,它只是对我遇到的问题和我在一些隐秘的地方发现的信息的做了一些记录。我在各种在线讨论和问答小组中找到的有关 Ansible 的许多信息都是错误的。错误范围包括明显的老旧信息(没有任何日期或来源的迹象),还有一些是完全错误的信息。
|
||||
|
||||
本文所介绍的内容是有用的,尽管可能还有其它方法可以完成相同的事情,但我使用的是 Ansible 2.9.13 和 [Python][3] 3.8.5。
|
||||
|
||||
### 我的问题
|
||||
|
||||
我所有的最佳学习经历都始于我需要解决的问题,这次也不例外。
|
||||
|
||||
我一直在做一个小项目,修改 [Midnight Commander][4] 文件管理器的配置文件,并将它们推送到我网络上的各种系统中进行测试。尽管我有一个脚本可以自动执行这个操作,但它仍然需要使用命令行循环来提供我想要推送新代码的系统名称。我对配置文件进行了大量的更改,这使我必须频繁推送新的配置文件。但是,就在我以为我的新配置刚刚好时,我发现了一个问题,所以我需要在修复后再进行一次推送。
|
||||
|
||||
这种环境使得很难跟踪哪些系统有新文件,哪些没有。我还有几个主机需要区别对待。我对 Ansible 的一点了解表明,它可能能够满足我的全部或大部分工作。
|
||||
|
||||
### 开始
|
||||
|
||||
我读过许多有关 Ansible 的好文章和书籍,但从来没有在“我必须现在就把这个做好!”的情况下读过。而现在 —— 好吧,就是现在!
|
||||
|
||||
在重读这些文档时,我发现它们主要是在讨论如何从 GitHub 开始安装并使用 Ansible,这很酷。但是我真的只是想尽快开始,所以我使用 DNF 和 Fedora 仓库中的版本在我的 Fedora 工作站上安装了它,非常简单。
|
||||
|
||||
但是后来我开始寻找文件位置,并尝试确定需要修改哪些配置文件、将我的剧本保存在什么位置,甚至一个剧本怎么写以及它的作用,我脑海中有一大堆(到目前为止)悬而未决的问题。
|
||||
|
||||
因此,不不需要进一步描述我的困难的情况下,以下是我发现的东西以及促使我继续前进的东西。
|
||||
|
||||
### 配置
|
||||
|
||||
Ansible 的配置文件保存在 `/etc/ansible` 中,这很有道理,因为 `/etc/` 是系统程序应该保存配置文件的地方。我需要使用的两个文件是 `ansible.cfg` 和 `hosts`。
|
||||
|
||||
#### ansible.cfg
|
||||
|
||||
在进行了从文档和线上找到的一些实践练习之后,我遇到了一些有关弃用某些较旧的 Python 文件的警告信息。因此,我在 `ansible.cfg` 中将 `deprecation_warnings` 设置为 `false`,这样那些愤怒的红色警告消息就不会出现了:
|
||||
|
||||
```
|
||||
deprecation_warnings = False
|
||||
```
|
||||
|
||||
这些警告很重要,所以我稍后将重新回顾它们,并弄清楚我需要做什么。但是现在,它们不会再扰乱屏幕,也不会让我混淆实际上需要关注的错误。
|
||||
|
||||
#### hosts 文件
|
||||
|
||||
与 `/etc/hosts` 文件不同,`hosts` 文件也被称为<ruby>清单<rt>inventory</rt></ruby>文件,它列出了网络上的主机。此文件允许将主机分组到相关集合中,例如“servers”、“workstations”和任何你所需的名称。这个文件包含帮助和大量示例,所以我在这里就不详细介绍了。但是,有些事情你必须知道。
|
||||
|
||||
主机也可以列在组之外,但是组对于识别具有一个或多个共同特征的主机很有帮助。组使用 INI 格式,所以服务器组看起来像这样:
|
||||
|
||||
```
|
||||
[servers]
|
||||
server1
|
||||
server2
|
||||
......
|
||||
```
|
||||
|
||||
这个文件中必须有一个主机名,这样 Ansible 才能对它进行操作。即使有些子命令允许指定主机名,但除非主机名在 `hosts` 文件中,否则命令会失败。一个主机也可以放在多个组中。因此,除了 `[servers]` 组之外,`server1` 也可能是 `[webservers]` 组的成员,还可以是 `[ubuntu]` 组的成员,这样以区别于 Fedora 服务器。
|
||||
|
||||
Ansible 很智能。如果 `all` 参数用作主机名,Ansible 会扫描 `hosts` 文件并在它列出的所有主机上执行定义的任务。Ansible 只会尝试在每个主机上工作一次,不管它出现在多少个组中。这也意味着不需要定义 `all` 组,因为 Ansible 可以确定文件中的所有主机名,并创建自己唯一的主机名列表。
|
||||
|
||||
另一件需要注意的事情是单个主机的多个条目。我在 DNS 文件中使用 `CNAME` 记录来创建别名,这些别名指向某些主机的 [A 记录][5],这样,我可以将一个主机称为 `host1` 或 `h1` 或 `myhost`。如果你在 `hosts` 文件中为同一主机指定多个主机名,则 Ansible 将尝试在所有这些主机名上执行其任务,它无法知道它们指向同一主机。好消息是,这并不会影响整体结果;它只是多花了一点时间,因为 Ansible 会在次要主机名上工作,它会确定所有操作均已执行。
|
||||
|
||||
### Ansible 实情
|
||||
|
||||
我阅读过 Ansible 的大多数材料都谈到了 Ansible <ruby>[实情][6]<rt>facts</rt></ruby>,它是与远程系统相关的数据,包括操作系统、IP 地址、文件系统等等。这些信息可以通过其它方式获得,如 `lshw`、`dmidecode` 或 `/proc` 文件系统等。但是 Ansible 会生成一个包含此信息的 JSON 文件。每次 Ansible 运行时,它都会生成这些实情数据。在这个数据流中,有大量的信息,都是以键值对形式出现的:`<"variable-name": "value">`。所有这些变量都可以在 Ansible 剧本中使用,理解大量可用信息的最好方法是实际显示一下:
|
||||
|
||||
```
|
||||
# ansible -m setup <hostname> | less
|
||||
```
|
||||
|
||||
明白了吗?你想知道的有关主机硬件和 Linux 发行版的所有内容都在这里,它们都可以在剧本中使用。我还没有达到需要使用这些变量的地步,但是我相信在接下来的几天中会用到。
|
||||
|
||||
### 模块
|
||||
|
||||
上面的 `ansible` 命令使用 `-m` 选项来指定 `setup` 模块。Ansible 已经内置了许多模块,所以你对这些模块不需要使用 `-m`。也可以安装许多下载的模块,但是内置模块可以完成我目前项目所需的一切。
|
||||
|
||||
### 剧本
|
||||
|
||||
<ruby>剧本<rt>playbook</rt></ruby>几乎可以放在任何地方。因为我需要以 root 身份运行,所以我将它放在了 `/root/ansible` 下。当我运行 Ansible 时,只要这个目录是当前的工作目录(PWD),它就可以找到我的剧本。Ansible 还有一个选项,用于在运行时指定不同的剧本和位置。
|
||||
|
||||
剧本可以包含注释,但是我看到的文章或书籍很少提及此。但作为一个相信记录一切的系统管理员,我发现使用注释很有帮助。这并不是说在注释中做和任务名称同样的事情,而是要确定任务组的目的,并确保我以某种方式或顺序记录我做这些事情的原因。当我可能忘记最初的想法时,这可以帮助以后解决调试问题。
|
||||
|
||||
剧本只是定义主机所需状态的任务集合。在剧本的开头指定主机名或清单组,并定义 Ansible 将在其上运行剧本的主机。
|
||||
|
||||
以下是我的一个剧本示例:
|
||||
|
||||
```
|
||||
################################################################################
|
||||
# This Ansible playbook updates Midnight commander configuration files. #
|
||||
################################################################################
|
||||
- name: Update midnight commander configuration files
|
||||
hosts: all
|
||||
|
||||
tasks:
|
||||
- name: ensure midnight commander is the latest version
|
||||
dnf:
|
||||
name: mc
|
||||
state: present
|
||||
|
||||
- name: create ~/.config/mc directory for root
|
||||
file:
|
||||
path: /root/.config/mc
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: create ~/.config/mc directory for dboth
|
||||
file:
|
||||
path: /home/dboth/.config/mc
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: dboth
|
||||
group: dboth
|
||||
|
||||
- name: copy latest personal skin
|
||||
copy:
|
||||
src: /root/ansible/UpdateMC/files/MidnightCommander/DavidsGoTar.ini
|
||||
dest: /usr/share/mc/skins/DavidsGoTar.ini
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: copy latest mc ini file
|
||||
copy:
|
||||
src: /root/ansible/UpdateMC/files/MidnightCommander/ini
|
||||
dest: /root/.config/mc/ini
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: copy latest mc panels.ini file
|
||||
copy:
|
||||
src: /root/ansible/UpdateMC/files/MidnightCommander/panels.ini
|
||||
dest: /root/.config/mc/panels.ini
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
<截断>
|
||||
```
|
||||
|
||||
剧本从它自己的名字和它将要操作的主机开始,在本文中,所有主机都在我的 `hosts` 文件中。`tasks` 部分列出了使主机达到所需状态的特定任务。这个剧本从使用 DNF 更新 Midnight Commander 开始(如果它不是最新的版本的话)。下一个任务确保创建所需的目录(如果它们不存在),其余任务将文件复制到合适的位置,这些 `file` 和 `copy` 任务还可以为目录和文件设置所有权和文件模式。
|
||||
|
||||
剧本细节超出了本文的范围,但是我对这个问题使用了一点蛮力。还有其它方法可以确定哪些用户需要更新文件,而不是对每个用户的每个文件使用一个任务。我的下一个目标是简化这个剧本,使用一些更先进的技术。
|
||||
|
||||
运行剧本很容易,只需要使用 `ansible-playbook` 命令。`.yml` 扩展名代表 YAML,我看到过它的几种不同含义,但我认为它是“<ruby>另一种标记语言<rt>Yet Another Markup Language</rt></ruby>”,尽管有些人声称 YAML 不是这种语言。
|
||||
|
||||
这个命令将会运行剧本,它会更新 Midnight Commander 文件:
|
||||
|
||||
```
|
||||
# ansible-playbook -f 10 UpdateMC.yml
|
||||
```
|
||||
|
||||
`-f` 选项指定 Ansible 使用 10 个线程来执行操作。这可以大大加快整个任务的完成速度,特别是在多台主机上工作时。
|
||||
|
||||
### 输出
|
||||
|
||||
剧本运行时会列出每个任务和执行结果。`ok` 代表任务管理的机器状态已经完成,因为在任务中定义的状态已经为真,所以 Ansible 不需要执行任何操作。
|
||||
|
||||
`changed` 表示 Ansible 已经执行了指定的任务。在这种情况下,任务中定义的机器状态不为真,所以执行指定的操作使其为真。在彩色终端上,`TASK` 行会以彩色显示。我的终端配色为“amber-on-black”,`TASK` 行显示为琥珀色,`changed` 是棕色,`ok` 为绿色,错误是红色。
|
||||
|
||||
下面的输出是我最终用于在新主机执行安装后配置的剧本:
|
||||
|
||||
```
|
||||
PLAY [Post-installation updates, package installation, and configuration]
|
||||
|
||||
TASK [Gathering Facts]
|
||||
ok: [testvm2]
|
||||
|
||||
TASK [Ensure we have connectivity]
|
||||
ok: [testvm2]
|
||||
|
||||
TASK [Install all current updates]
|
||||
changed: [testvm2]
|
||||
|
||||
TASK [Install a few command line tools]
|
||||
changed: [testvm2]
|
||||
|
||||
TASK [copy latest personal Midnight Commander skin to /usr/share]
|
||||
changed: [testvm2]
|
||||
|
||||
TASK [create ~/.config/mc directory for root]
|
||||
changed: [testvm2]
|
||||
|
||||
TASK [Copy the most current Midnight Commander configuration files to /root/.config/mc]
|
||||
changed: [testvm2] => (item=/root/ansible/PostInstallMain/files/MidnightCommander/DavidsGoTar.ini)
|
||||
changed: [testvm2] => (item=/root/ansible/PostInstallMain/files/MidnightCommander/ini)
|
||||
changed: [testvm2] => (item=/root/ansible/PostInstallMain/files/MidnightCommander/panels.ini)
|
||||
|
||||
TASK [create ~/.config/mc directory in /etc/skel]
|
||||
changed: [testvm2]
|
||||
|
||||
<截断>
|
||||
```
|
||||
|
||||
### cowsay
|
||||
|
||||
如果你的计算机上安装了 [cowsay][7] 程序,你会发现 `TASK` 的名字出现在奶牛的语音泡泡中:
|
||||
|
||||
```
|
||||
____________________________________
|
||||
< TASK [Ensure we have connectivity] >
|
||||
------------------------------------
|
||||
\ ^__^
|
||||
\ (oo)\\_______
|
||||
(__)\ )\/\
|
||||
||----w |
|
||||
|| ||
|
||||
```
|
||||
|
||||
如果你没有这个有趣的程序,你可以使用发行版的包管理器安装 Cowsay 程序。如果你有这个程序但不想要它,可以通过在 `/etc/ansible/ansible.cfg` 文件中设置 `nocows=1` 将其禁用。
|
||||
|
||||
我喜欢这头奶牛,它很有趣,但是它会占用我的一部分屏幕。因此,在它开始妨碍我使用时,我就把它禁用了。
|
||||
|
||||
### 目录
|
||||
|
||||
与我的 Midnight Commander 任务一样,经常需要安装和维护各种类型的文件。创建用于存储剧本的目录树的“最佳实践”和系统管理员一样多,至少与编写有关 Ansible 书和文章的作者数量一样多。
|
||||
|
||||
我选择了一个对我有意义的简单结构:
|
||||
|
||||
```bash
|
||||
/root/ansible
|
||||
└── UpdateMC
|
||||
├── files
|
||||
│ └── MidnightCommander
|
||||
│ ├── DavidsGoTar.ini
|
||||
│ ├── ini
|
||||
│ └── panels.ini
|
||||
└── UpdateMC.yml
|
||||
```
|
||||
|
||||
你可以使用任何结构。但是请注意,其它系统管理员可能需要使用你设置的剧本来工作,所以目录应该具有一定程度的逻辑。当我使用 RPM 和 Bash 脚本执行安装任务后,我的文件仓库有点分散,绝对没有任何逻辑结构。当我为许多管理任务创建剧本时,我将介绍一个更有逻辑的结构来管理我的目录。
|
||||
|
||||
### 多次运行剧本
|
||||
|
||||
根据需要或期望多次运行剧本是安全的。只有当主机状态与任务中指定的状态不匹配时,才会执行每个任务。这使得很容易从先前的剧本运行中遇到的错误中恢复。因为当剧本遇到错误时,它将停止运行。
|
||||
|
||||
在测试我的第一个剧本时,我犯了很多错误并改正了它们。假设我的修正正确,那么剧本每次运行,都会跳过那些状态已与指定状态匹配的任务,执行不匹配状态的任务。当我的修复程序起作用时,之前失败的任务就会成功完成,并且会执行此任务之后的任务 —— 直到遇到另一个错误。
|
||||
|
||||
这使得测试变得容易。我可以添加新任务,并且在运行剧本时,只有新任务会被执行,因为它们是唯一与测试主机期望状态不匹配的任务。
|
||||
|
||||
### 一些思考
|
||||
|
||||
有些任务不适合用 Ansible,因为有更好的方法可以实现特定的计算机状态。我想到的场景是使 VM 返回到初始状态,以便可以多次使用它来执行从已知状态开始的测试。让 VM 进入特定状态,然后对此时的计算机状态进行快照要容易得多。还原到该快照与 Ansible 将主机返回到之前状态相比,通常还原到快照通常会更容易且更快。在研究文章或测试新代码时,我每天都会做几次这样的事情。
|
||||
|
||||
在完成用于更新 Midnight Commander 的剧本之后,我创建了一个新的剧本,用于在新安装的 Fedora 主机上执行安装任务。我已经取得了不错的进步,剧本比我第一个的更加复杂,但没有那么粗暴。
|
||||
|
||||
在使用 Ansible 的第一天,我创建了一个解决问题的剧本,我还开始编写第二个剧本,它将解决安装后配置的大问题,在这个过程中我学到了很多东西。
|
||||
|
||||
尽管我真的很喜欢使用 [Bash][8] 脚本来管理任务,但是我发现 Ansible 可以完成我想要的一切,并且可以使系统保持在我所需的状态。只用了一天,我就成为了 Ansible 的粉丝。
|
||||
|
||||
### 资源
|
||||
|
||||
我找到的最完整、最有用的参考文档是 Ansible 网站上的[用户指南][9]。本文仅供参考,不作为入门文档。
|
||||
|
||||
多年来,我们已经发布了许多[有关 Ansible 的文章][10],我发现其中大多数对我的需求很有帮助。Enable Sysadmin 网站上也有很多对我有帮助 [Ansible 文章][11]。你可以通过查看本周(2020 年 10 月 13 日至 14 日)的 [AnsibleFest][12] 了解更多信息。该活动完全是线上的,可以免费注册。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/10/first-day-ansible
|
||||
|
||||
作者:[David Both][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/dboth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux11x_cc.png?itok=XMDOouJR "People work on a computer server with devices"
|
||||
[2]: https://www.ansible.com/
|
||||
[3]: https://www.python.org/
|
||||
[4]: https://midnight-commander.org/
|
||||
[5]: https://en.wikipedia.org/wiki/List_of_DNS_record_types
|
||||
[6]: https://docs.ansible.com/ansible/latest/user_guide/playbooks_vars_facts.html#ansible-facts
|
||||
[7]: https://en.wikipedia.org/wiki/Cowsay
|
||||
[8]: https://opensource.com/downloads/bash-cheat-sheet
|
||||
[9]: https://docs.ansible.com/ansible/latest/user_guide/index.html
|
||||
[10]: https://opensource.com/tags/ansible
|
||||
[11]: https://www.redhat.com/sysadmin/topics/ansible
|
||||
[12]: https://www.ansible.com/ansiblefest
|
@ -1,8 +1,8 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13053-1.html)
|
||||
[#]: subject: (Making trade-offs when writing Python code)
|
||||
[#]: via: (https://opensource.com/article/19/12/zen-python-trade-offs)
|
||||
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
> 本文是 Python 之禅特别系列的一部分,重点此篇着眼于第七、八、九条原则:可读性、特殊情况和实用性。
|
||||
|
||||
![开发人员和运营经理两个人之间的铜墙铁壁][1]
|
||||
![](https://img.linux.net.cn/data/attachment/album/202101/26/105645c1looxqxns12loen.jpg)
|
||||
|
||||
软件开发是一门充满了取舍的学科。每一个选择,都有一个同样合理但相反的选择。将一个方法私有化?你在鼓励复制粘贴。将一个方法公开?你在过早地对一个接口做出承诺。
|
||||
|
||||
@ -20,27 +20,19 @@
|
||||
|
||||
### <ruby>可读性很重要<rt>Readability counts</rt></ruby>
|
||||
|
||||
从某种意义上说,这一中间原则确实是整个 Python 之禅的中心。这条原则与编写高效的程序无关。在大多数情况下,它甚至与编写健壮的程序无关。它讲的是编写出*别人能读懂的程序*。
|
||||
从某种意义上说,这一中间原则确实是整个 Python 之禅的中心。这条原则与编写高效的程序无关。在大多数情况下,它甚至与编写健壮的程序也无关。它讲的是编写出*别人能读懂的程序*。
|
||||
|
||||
阅读代码,就其本质而言,发生在代码被添加到系统中之后。通常,它会发生在很久很久以后。忽略可读性是最简单的选择,因为它对现在没有伤害。无论添加新代码的原因是什么,它都会对现在造成影响,无论是一个令人痛苦的 bug 还是一个被强烈要求的功能。
|
||||
|
||||
面对巨大的压力,把可读性扔到一边,只管“解决问题”,Python 之禅提醒我们:可读性很重要。编写代码让它适合阅读,是对自己和他人的一种慈悲。
|
||||
|
||||
###特殊情况还没有特殊到违反规则的地步。
|
||||
|
||||
总有个借口。这个bug特别痛苦,我们不要担心简单。这个功能特别紧急,我们不要担心美观。这个案例所涉及的领域规则特别毛躁,我们不要担心嵌套程度。
|
||||
|
||||
一旦我们允许特殊恳求,大坝墙就会破裂,没有原则了;事情就会演变成一个疯狂的麦克斯荒诞症,每个程序员都为自己,试图找到最好的借口。
|
||||
|
||||
纪律需要承诺。只有在事情困难的时候,在强烈的诱惑下,才会考验一个软件开发人员。总有一个合理的借口来破坏规则,这就是为什么必须守规矩的原因。纪律是向例外说不的艺术。 任何解释都无法改变这一点。
|
||||
如果面对巨大的压力,把可读性扔到一边,只管“解决问题”,而 Python 之禅提醒我们:可读性很重要。编写代码让它适合阅读,无论是对自己还是他人,都是一种慈悲。
|
||||
|
||||
### <ruby>特殊情况不足以违反规则<rt>Special cases aren't special enough to break the rules</rt></ruby>
|
||||
|
||||
总是有各种借口。这个 bug 特别麻烦,先简单处理一下吧;这个功能特别紧急,别管美观了;这种情况下所涉及的领域规则特别复杂,嵌套深点也没事。
|
||||
总是有各种借口:这个 bug 特别麻烦,先简单处理一下吧;这个功能特别紧急,别管美观了;这种情况下所涉及的领域规则特别复杂,嵌套深点也没关系。
|
||||
|
||||
一旦我们允许特例的借口,大坝就会破裂,就丧失原则了;事情就会演变成一个疯狂麦克斯的荒诞症,每个程序员都会为自己试图找到最好的借口。
|
||||
一旦我们对特例的借口妥协,大坝就会破裂,就丧失了原则;事情就会演变成一个疯狂麦克斯的荒诞症,每个程序员都会为自己试图找到最好的借口。
|
||||
|
||||
纪律需要承诺。只有当事情艰辛、有强烈的诱惑时,才是对一个软件开发人员的考验。总是有合理的借口来破坏规则,这就是为什么必须守规矩的原因。纪律就是向例外说不的艺术。没有任何解释可以改变这一点。
|
||||
纪律需要承诺。只有当事情艰辛、有强烈的诱惑时,才是对一个软件开发人员的考验。总是有合理的借口来破坏规则,这就是为什么必须坚守规矩的原因。纪律就是向例外说不的艺术。没有任何解释可以改变这一点。
|
||||
|
||||
### <ruby>虽然,实用性胜过纯洁性<rt>Although, practicality beats purity</rt></ruby>
|
||||
|
||||
@ -49,7 +41,7 @@
|
||||
|
||||
归根结底,软件开发是一门实用的学科。它的目标是解决真实的人所面临的实际问题。实用性比纯粹性更重要:首先,我们必须*解决问题*。如果我们只考虑可读性、简单性或美观性,我们将无法真正*解决问题*。
|
||||
|
||||
正如宫本武藏所说的,每一次代码修改的首要目标应该是*解决问题°。这个问题需要我们心心念念去解决它。如果我们不以解决问题为目标,只想着 Python 之禅,我们就辜负了这些原则。这是 Python 之禅所固有的另一种矛盾。
|
||||
正如宫本武藏所说的,每一次代码修改的首要目标应该是*解决问题*。这个问题需要我们心心念念地去解决它。如果我们不以解决问题为目标,只想着 Python 之禅,我们就辜负了这些原则。这是 Python 之禅所固有的另一种矛盾。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -58,7 +50,7 @@ via: https://opensource.com/article/19/12/zen-python-trade-offs
|
||||
作者:[Moshe Zadka][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[wxy](https://github.com/wxys)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxys)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -0,0 +1,57 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13058-1.html)
|
||||
[#]: subject: (How the Zen of Python handles errors)
|
||||
[#]: via: (https://opensource.com/article/19/12/zen-python-errors)
|
||||
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
|
||||
|
||||
Python 处理错误的原则
|
||||
======
|
||||
|
||||
> 这是 Python 之禅特别系列的一部分,重点是第十和第十一条原则:沉默的错误(或不沉默)。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202101/27/223251q261j2ndoccajc16.jpg)
|
||||
|
||||
处理“异常情况”是编程中争论最多的问题之一。这可能是因为风险很大:处理不当的错误值甚至可以使庞大的系统瘫痪。由于“异常情况”从本质上来说,是测试不足的,但发生的频率却令人不快,因此,是否正确处理它们往往可以将一个噩梦般的系统与一个“可以工作”的系统区分开来。
|
||||
|
||||
从 Java 的 `checked` 异常,到 Erlang 的故障隔离,再到 Haskell 的 `Maybe`,不同的语言对错误处理的态度截然不同。
|
||||
|
||||
这两条 [Python 之禅][2]是 Python 对这个话题的冥思。
|
||||
|
||||
### <ruby>错误绝不应该悄悄传递...<rt>Errors should never pass silently…</rt></ruby>
|
||||
|
||||
当 Python 之禅在 Tim Peters 眼里闪烁而出之前,在维基百科被俗称为“维基”之前,第一个维基网站 [C2][3] 就已经存在了,它是一个编程指南的宝库。这些原则大多来自于 [Smalltalk][4] 编程社区。Smalltalk 的思想影响了许多面向对象的语言,包括 Python。
|
||||
|
||||
C2 维基定义了<ruby>武士原则<rt>Samurai Principle</rt></ruby>:“胜利归来,要么不归。”用 Python 人的术语来说,它鼓励摒弃<ruby>哨兵值<rt>sentinel value</rt></ruby>,比如用返回 `None` 或 `-1` 来表示无法完成任务,而是采用引发异常的方式。一个 `None` 是无声的:它看起来像一个值,可以放在一个变量中,然后到处传递。有时,它甚至是一个*有效*的返回值。
|
||||
|
||||
这里的原则是,如果一个函数不能完成它的契约,它应该“高调失败”:引发一个异常。所引发的异常永远不会看起来像是一个可能的值。它将跳过 `returned_value = call_to_function(parameter)` 行,并上升到调用栈中,可能使程序崩溃。
|
||||
|
||||
崩溃的调试是很直接的:有一个堆栈跟踪来指示问题以及调用堆栈。崩溃可能意味着程序的必要条件没有满足,需要人为干预。它可能意味着程序的逻辑有问题。无论是哪种情况,高调失败都比一个隐藏的、“缺失”的值要好。用 `None` 来感染程序的有效数据,直到它被用在某个地方,就如你可能已经知道的,错误信息会说 “**None 没有方法进行拆分**”。
|
||||
|
||||
### <ruby>除非显式消除<rt>Unless explicitly silenced</rt></ruby>
|
||||
|
||||
有时需要显式地捕获异常。我们可能会预见到文件中的某些行格式错误,并希望以特殊的方式来处理它们,也许可以把它们放在一个“需要人来看看的行”的文件中,而不是让整个程序崩溃。
|
||||
|
||||
Python 允许我们用 `except` 来捕获异常。这意味着错误可以被*显式*消除。这种明确性意味着 `except` 行在代码审查中是可见的。质疑为什么应该在这里显式消除异常并从异常中恢复,是有意义的。自问一下我们是否捕获了太多或太少的异常也是有意义的。
|
||||
|
||||
因为这些全都是明确的,所以有人可以阅读代码并了解哪些异常是可以恢复的。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/12/zen-python-errors
|
||||
|
||||
作者:[Moshe Zadka][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/moshez
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_hands_team_collaboration.png?itok=u82QepPk (a checklist for a team)
|
||||
[2]: https://www.python.org/dev/peps/pep-0020/
|
||||
[3]: https://wiki.c2.com/
|
||||
[4]: https://en.wikipedia.org/wiki/Smalltalk
|
@ -0,0 +1,115 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (stevenzdg988)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13055-1.html)
|
||||
[#]: subject: (5 Python scripts for automating basic community management tasks)
|
||||
[#]: via: (https://opensource.com/article/20/3/automating-community-management-python)
|
||||
[#]: author: (Rich Bowen https://opensource.com/users/rbowen)
|
||||
|
||||
用于基本社区管理任务自动化的 5 个 Python 脚本
|
||||
======
|
||||
|
||||
> 如果某些事情不得不重复做三遍,尝试使其自动化。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202101/27/000544aakdc4mnmn6tzj8y.jpg)
|
||||
|
||||
我 [之前写过关于社区管理员的工作][2],如果你问 10 位社区管理员,你会得到 12 个不同的答案。不过,大多数情况下,你做的是社区需要你在任何特定时刻做的事情。而且很多事情可能是重复的。
|
||||
|
||||
当我还是系统管理员时,我遵循一个规则:如果某些事必须做三遍,我会尝试使其自动化。当然,如今,使用诸如 Ansible 这样的强大工具,就有了一整套科学的方法。
|
||||
|
||||
我每天或每周要做的一些事情涉及在一些地方查找内容,然后生成信息的摘要或报告,然后发布到别处。这样的任务是自动化的理想选择。这些并不是什么 [难事][3],当我与同事共享其中一些脚本时,总是至少有一个能证明这是有用的。
|
||||
|
||||
[在 GitHub][4] 上,我有几个每周都要使用的脚本。它们都不是很复杂,但每次都为我节省几分钟。其中一些是用 Perl 写的,因为我快 50 岁了(这些是我早些年写的)。有些是用 Python 写的,因为几年前,我决定要学习 Python。
|
||||
|
||||
以下是概述:
|
||||
|
||||
### tshirts.py
|
||||
|
||||
这个简单的 [tshirts.py 脚本][5]会根据你要定制的活动 T 恤的数量,然后告诉你尺寸分布是什么。它将这些尺寸分布在一条正态曲线(也称为 “钟形曲线”)上,以我的经验,这和一个正常的会议观众的实际需求非常吻合。如果在美国使用,则可能需要将脚本中的值调整的稍大一些;如果在欧洲使用,则可能需要将脚本中的值稍稍缩小一些。你的情况也许不同。
|
||||
|
||||
用法:
|
||||
|
||||
```
|
||||
[rbowen@sasha:community-tools/scripts]$ ./tshirts.py
|
||||
How many shirts? 300
|
||||
For a total of 300 shirts, order:
|
||||
|
||||
30.0 small
|
||||
72.0 medium
|
||||
96.0 large
|
||||
72.0 xl
|
||||
30.0 2xl
|
||||
```
|
||||
|
||||
### followers.py
|
||||
|
||||
[followers.py 脚本][6]为我提供了我关心的 Twitter 账号的关注者数量。
|
||||
|
||||
该脚本只有 14 行,没什么复杂的,但是它可能节省我十分钟的加载网页和查找数字的时间。
|
||||
|
||||
你需要编辑 `feed` 数组以添加你关心的帐户:
|
||||
|
||||
```
|
||||
feeds = [
|
||||
'centosproject',
|
||||
'centos'
|
||||
];
|
||||
```
|
||||
|
||||
注意:如果你在英语国家以外的地方运行它,则可能无法正常工作,因为它只是一个简单的屏幕抓取脚本,它读取 HTML 并查找其中包含的特定信息。因此,当输出使用其他语言时,正则表达式可能不匹配。
|
||||
|
||||
用法:
|
||||
|
||||
```
|
||||
[rbowen@sasha:community-tools/scripts]$ ./followers.py
|
||||
centosproject: 11,479 Followers
|
||||
centos: 18,155 Followers
|
||||
```
|
||||
|
||||
### get_meetups
|
||||
|
||||
[get_meetups 脚本][7]S 另一种类别的脚本 —— API脚本。这个特定的脚本使用 [meetup.com][8] 网站的 API 来寻找在特定区域和时间范围内特定主题的聚会,以便我可以将它报告给我的社区。你所依赖的许多服务都提供了 API,因此你的脚本可以查找信息,而无需手动查找网页。学习如何使用这些 API 既令人沮丧又耗时,但是最终将获得可以节省大量时间的技能。
|
||||
|
||||
_免责声明:[meetup.com][8] 已于 2019 年 8 月更改了他们的 API,我还没有将这个脚本更新到新的API,所以它现在实际上并没有工作。在接下来的几周内请关注此版本的修复版本。_
|
||||
|
||||
### centos-announcements.pl
|
||||
|
||||
[centos-announcements.pl 脚本][9]要复杂得多,而且对我的用例来说非常特殊,但你可能有类似的情况。在本例中该脚本查看邮件列表存档(`centos-announce` 邮件列表),并查找具有特定格式的邮件,然后生成这些邮件的报告。报告有两种不同的格式:一种用于我的每月新闻通讯,另一种用于安排 Twitter 信息(借助于 Hootsuite)。
|
||||
|
||||
我使用 Hootsuite 为 Twitter 安排内容,它们具有便捷的 CSV(逗号分隔值)格式,你可以一次批量安排整整一周的推文。从各种数据源(比如:邮件列表、博客、其他网页)自动生成 CSV 格式可以节省大量时间。但是请注意,这可能只应该用于初稿,然后你可以对其进行检查和编辑,以便最终不会自动发布你不想要内容的推文。
|
||||
|
||||
### reporting.pl
|
||||
|
||||
[reporting.pl 脚本][10]也是相当特定的,以满足我的特殊需求,但是这个概念本身是通用的。我每月向 [CentOS SIG][11](特殊兴趣小组)发送邮件,这些邮件计划在给定的月份报告。该脚本只是告诉我本月有哪些 SIG,并记录需要发送给他们的电子邮件。
|
||||
|
||||
但是,因以下两个原因,实际上并未发送该电子邮件。第一,我希望在消息发送之前对其进行编辑。第二,虽然发送电子邮件的脚本在过去很有效,但如今,很可能被当做垃圾邮件而被过滤。
|
||||
|
||||
### 总结
|
||||
|
||||
在这个存储库中还有一些其他脚本,这些脚本或多或少是针对我的特定需求的,但是我希望其中至少有一个脚本对你有用,并且希望这些脚本的多样性能激励你去自动化一些你自己的东西。我也希望看到你的自动化脚本存储库;在评论中链接他们!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/3/automating-community-management-python
|
||||
|
||||
作者:[Rich Bowen][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/rbowen
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/Open%20Pharma.png?itok=GP7zqNZE (shapes of people symbols)
|
||||
[2]: http://drbacchus.com/what-does-a-community-manager-do/
|
||||
[3]: https://6dollarshirts.com/rocket-surgery
|
||||
[4]: https://github.com/rbowen/centos-community-tools/tree/master/scripts
|
||||
[5]: https://github.com/rbowen/centos-community-tools/blob/master/scripts/tshirts.py
|
||||
[6]: https://github.com/rbowen/centos-community-tools/blob/master/scripts/followers.py
|
||||
[7]: https://github.com/rbowen/centos-community-tools/blob/master/scripts/get_meetups
|
||||
[8]: http://meetup.com
|
||||
[9]: https://github.com/rbowen/centos-community-tools/blob/master/scripts/centos-announcements.pl
|
||||
[10]: https://github.com/rbowen/centos-community-tools/blob/master/scripts/sig_reporting/reporting.pl
|
||||
[11]: https://wiki.centos.org/SpecialInterestGroup
|
@ -1,43 +1,45 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (mengxinayan)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13069-1.html)
|
||||
[#]: subject: (Understanding 52-bit virtual address support in the Arm64 kernel)
|
||||
[#]: via: (https://opensource.com/article/20/12/52-bit-arm64-kernel)
|
||||
[#]: author: (Bhupesh Sharma https://opensource.com/users/bhsharma)
|
||||
|
||||
理解 ARM64 内核中对 52 比特虚拟地址的支持
|
||||
理解 ARM64 内核中对 52 位虚拟地址的支持
|
||||
======
|
||||
随着 64 比特硬件的普及,增加了处理更大地址空间的需求。
|
||||
![拼图碎片聚在一起形成计算机屏幕][1]
|
||||
|
||||
当 64 比特硬件变得可用之后,处理更大地址空间(大于232字节)的需求变得显而易见。现如今一些公司已经提供 64TiB 或更大内存的服务器,x86_64 架构和 arm64 架构现在允许寻址的地址空间大于 248 字节(可以使用默认的 48 比特地址支持)。
|
||||
> 随着 64 位硬件的引入,增加了处理更大地址空间的需求。
|
||||
|
||||
x86_64 架构通过让硬件和软件支持五级页表以支持这些用例。它允许寻址的地址空间等于 257 字节(详情见 [x86:在 4.12 内核中启用 5 级页表][2])。它突破了过去虚拟地址空间 128PiB 和 物理地址空间 4PiB 的上限。
|
||||
![](https://img.linux.net.cn/data/attachment/album/202101/30/170448rynbm9b6nmb90403.jpg)
|
||||
|
||||
arm64 架构通过引入两个新的体系结构拓展来实现相同的功能—ARMv8.2 LVA(更大的虚拟寻址) 和 ARMv8.2 LPA(更大的物理地址寻址)。这允许使用 4PiB 的虚拟地址空间和 4PiB 的物理地址空间(即分别为 252 比特)。
|
||||
当 64 位硬件变得可用之后,处理更大地址空间(大于 2^32 字节)的需求变得显而易见。现如今一些公司已经提供 64TiB 或更大内存的服务器,x86_64 架构和 arm64 架构现在允许寻址的地址空间大于 2^48 字节(可以使用默认的 48 位地址支持)。
|
||||
|
||||
在新的 arm64 CPU 中已经支持了 ARMv8.2 体系结构拓展,同时现在开源软件也支持了这两种新的硬件拓展。
|
||||
x86_64 架构通过让硬件和软件启用五级页表以支持这些用例。它允许寻址的地址空间等于 2^57 字节(详情见 [x86:在 4.12 内核中启用 5 级页表][2])。它突破了过去虚拟地址空间 128PiB 和物理地址空间 4PiB 的上限。
|
||||
|
||||
从 5.4 内核开始, arm64 架构中的52 比特(大)虚拟地址(VA)和物理地址(PA)得到支持。尽管[内核文档][3]描述了这些特性和新的内核运行时对旧的 CPU(硬件层面不支持 52 比特虚拟地址拓展)和新的 CPU(硬件层面支持 52 比特虚拟地址拓展)的影响,但对普通用户而言理解这些并且如何“选择使用”52比特的地址空间可能会很复杂。
|
||||
arm64 架构通过引入两个新的体系结构 —— ARMv8.2 LVA(更大的虚拟寻址) 和 ARMv8.2 LPA(更大的物理地址寻址) —— 拓展来实现相同的功能。这允许使用 4PiB 的虚拟地址空间和 4PiB 的物理地址空间(即分别为 2^52 位)。
|
||||
|
||||
随着新的 arm64 CPU 中支持了 ARMv8.2 体系结构拓展,同时现在开源软件也支持了这两种新的硬件拓展。
|
||||
|
||||
从 Linux 5.4 内核开始, arm64 架构中的 52 位(大)虚拟地址(VA)和物理地址(PA)得到支持。尽管[内核文档][3]描述了这些特性和新的内核运行时对旧的 CPU(硬件层面不支持 52 位虚拟地址拓展)和新的 CPU(硬件层面支持 52 位虚拟地址拓展)的影响,但对普通用户而言,理解这些并且如何 “选择使用” 52 位的地址空间可能会很复杂。
|
||||
|
||||
因此,我会在本文中介绍下面这些比较新的概念:
|
||||
|
||||
1. 在增加了对这些功能的支持后,内核的内存布局如何“翻转”到 Arm64 架构
|
||||
2. 对用户态应用的影响,尤其是对提供调试支持的程序(例如:kexec-tools, makedumpfile 和 crash-utility)
|
||||
3. 如何通过指定大于 48 比特的 mmap 参数,使用户态应用“选择”接收 52 比特地址?
|
||||
2. 对用户态应用的影响,尤其是对提供调试支持的程序(例如:kexec-tools、 makedumpfile 和 crash-utility)
|
||||
3. 如何通过指定大于 48 位的 mmap 参数,使用户态应用“选择”从 52 位地址空间接受 VA?
|
||||
|
||||
### ARMv8.2 架构的 LVA 和 LPA 拓展
|
||||
|
||||
ARMv8.2 架构提供两种重要的拓展:更大的虚拟地址(LVA)和更大的物理地址(LPA)。
|
||||
ARMv8.2 架构提供两种重要的拓展:大虚拟寻址(LVA)和大物理寻址(LPA)。
|
||||
|
||||
当使用 64 KB 转换粒度时,ARMv8.2-LVA 为每个基地址寄存器提供了一个更大的 52 比特虚拟地址空间。
|
||||
当使用 64 KB 转换粒度时,ARMv8.2-LVA 为每个翻译表基地址寄存器提供了一个更大的 52 位虚拟地址空间。
|
||||
|
||||
在 ARMv8.2-LVA 中包含:
|
||||
在 ARMv8.2-LVA 中允许:
|
||||
|
||||
* 当使用 64 KB 转换粒度时,中间物理地址(IPA)和物理地址空间拓展为 52 比特。
|
||||
* 如果使用 64 KB 转换粒度来实现对 52 比特物理地址的支持,那么一级块将会覆盖 4TB 的地址空间。
|
||||
* 当使用 64 KB 转换粒度时,中间物理地址(IPA)和物理地址空间拓展为 52 位。
|
||||
* 如果使用 64 KB 转换粒度来实现对 52 位物理地址的支持,那么一级块将会覆盖 4TB 的地址空间。
|
||||
|
||||
_需要注意的是这些特性仅在 AArch64 架构中支持。_
|
||||
|
||||
@ -49,13 +51,13 @@ _需要注意的是这些特性仅在 AArch64 架构中支持。_
|
||||
|
||||
更多细节请参考 [Armv8 架构参考手册][4]。
|
||||
|
||||
### Arm64 中的内核内存布局
|
||||
### Arm64 的内核内存布局
|
||||
|
||||
伴随着 ARMv8.2 拓展增加了对 LVA 地址的支持(仅当页大小为 64 KB 是可用),在第一级翻译中,描述符的数量会增加。
|
||||
伴随着 ARMv8.2 拓展增加了对 LVA 地址的支持(仅当以页大小为 64 KB 运行时可用),在第一级转换中,描述符的数量会增加。
|
||||
|
||||
用户地址将 63-48 比特位置为 0,然而内核地址将这些比特位置为 1。TTBRx 选择由虚拟地址的 63 比特位决定。`swapper_pg_dir` 仅包含内核全局映射,然而 `pgd` 仅包含用户(非全局)的映射。`swapper_pg_dir` 地址会写入 TTBR1 且永远不会写入 TTBR0。
|
||||
用户地址将 63-48 位位置为 0,然而内核地址将这些位设置为 1。TTBRx 的选择由虚拟地址的 63 位决定。`swapper_pg_dir` 仅包含内核(全局)映射,然而 `pgd` 仅包含用户(非全局)的映射。`swapper_pg_dir` 地址会写入 TTBR1,且永远不会写入 TTBR0。
|
||||
|
||||
**页面大小为 64 KB 和三个级别的(具有 52 比特硬件支持)的 AArch64 架构下 Linux 内存布局如下:**
|
||||
**页面大小为 64 KB 和三个级别的(具有 52 位硬件支持)的 AArch64 架构下 Linux 内存布局如下:**
|
||||
|
||||
```
|
||||
开始 结束 大小 用途
|
||||
@ -85,11 +87,11 @@ _需要注意的是这些特性仅在 AArch64 架构中支持。_
|
||||
| | | | | |
|
||||
| | | | | v
|
||||
| | | | | [11:0] 页内偏移量
|
||||
| | | | +-> [20:12] L3 索引
|
||||
| | | +-----------> [29:21] L2 索引
|
||||
| | +---------------------> [38:30] L1 索引
|
||||
| +-------------------------------> [47:39] L0 索引
|
||||
+-------------------------------------------------> [63] TTBR0/1
|
||||
| | | | +-> [20:12] L3 索引
|
||||
| | | +-----------> [29:21] L2 索引
|
||||
| | +---------------------> [38:30] L1 索引
|
||||
| +-------------------------------> [47:39] L0 索引
|
||||
+-------------------------------------------------> [63] TTBR0/1
|
||||
```
|
||||
|
||||
**64 KB 页面的转换查询表如下:**
|
||||
@ -101,18 +103,18 @@ _需要注意的是这些特性仅在 AArch64 架构中支持。_
|
||||
| | | | |
|
||||
| | | | v
|
||||
| | | | [15:0] 页内偏移量
|
||||
| | | +----------> [28:16] L3 索引
|
||||
| | +--------------------------> [41:29] L2 索引
|
||||
| +-------------------------------> [47:42] L1 索引 (48 比特)
|
||||
| [51:42] L1 索引 (52 比特)
|
||||
+-------------------------------------------------> [63] TTBR0/1
|
||||
| | | +----------> [28:16] L3 索引
|
||||
| | +--------------------------> [41:29] L2 索引
|
||||
| +-------------------------------> [47:42] L1 索引 (48 位)
|
||||
| [51:42] L1 索引 (52 位)
|
||||
+-------------------------------------------------> [63] TTBR0/1
|
||||
```
|
||||
|
||||
![][5]
|
||||
|
||||
### 内核对 52 比特虚拟地址的支持
|
||||
### 内核对 52 位虚拟地址的支持
|
||||
|
||||
因为支持 LVA 的较新的内核应在旧的CPU(硬件不支持 LVA 拓展)和新的CPU(硬件支持 LVA 拓展)上都可以正常运行,因此采用的设计方法是使用单个二进制文件来支持 52 比特(如果硬件不支持该特性,则必须在刚开始启动时能回到 48 比特)。也就是说,为了满足 52 比特的虚拟地址以及固定大小的 `PAGE_OFFSET`,VMEMMAP 必须设置得足够大。
|
||||
因为支持 LVA 的较新的内核应该可以在旧的 CPU(硬件不支持 LVA 拓展)和新的 CPU(硬件支持 LVA 拓展)上都正常运行,因此采用的设计方法是使用单个二进制文件来支持 52 位(如果硬件不支持该特性,则必须在刚开始启动时能回退到 48 位)。也就是说,为了满足 52 位的虚拟地址以及固定大小的 `PAGE_OFFSET`,`VMEMMAP` 必须设置得足够大。
|
||||
|
||||
这样的设计方式要求内核为了新的虚拟地址空间而支持下面的变量:
|
||||
|
||||
@ -122,13 +124,13 @@ VA_BITS 常量 *最大的* 虚拟地址空间大小
|
||||
vabits_actual 变量 *实际的* 虚拟地址空间大小
|
||||
```
|
||||
|
||||
因此,尽管 `VA_BITS` 设置了最大的虚拟地址空间大小,但实际上支持的虚拟地址空间大小由 `vabits_actual` 确定(具体取决于启动时的切换)
|
||||
因此,尽管 `VA_BITS` 设置了最大的虚拟地址空间大小,但实际上支持的虚拟地址空间大小由 `vabits_actual` 确定(具体取决于启动时的切换)。
|
||||
|
||||
#### 翻转内核内存布局
|
||||
|
||||
保持一个单内核二进制文件的设计方法要求内核的 .text 文件位于高位地址中,因此它们对于 48/52 比特虚拟地址都不变。因为内核地址检测器(KASAN)区域仅占整个内核虚拟地址空间的一小部分,因此对于 48 比特或 52 比特的虚拟地址空间,KASAN 区域的末尾也必须在内核虚拟地址空间的上半部分。(从 48 比特切换到 52 比特,KASAN 区域的末尾是不变的且依赖于 `~0UL`,而起始地址将“增长”到低位地址)
|
||||
保持一个单一内核二进制文件的设计方法要求内核的 `.text` 位于高位地址中,因此它们对于 48/52 位虚拟地址是不变的。因为内核地址检测器(KASAN)区域仅占整个内核虚拟地址空间的一小部分,因此对于 48 位或 52 位的虚拟地址空间,KASAN 区域的末尾也必须在内核虚拟地址空间的上半部分。(从 48 位切换到 52 位,KASAN 区域的末尾是不变的,且依赖于 `~0UL`,而起始地址将“增长”到低位地址)
|
||||
|
||||
为了优化 `phys_to_virt()` 和 `virt_to_phys()`,页偏移量将被保持在 `0xFFF0000000000000` (对应于 52 比特),这消除了读取额外变量的需求。在早期启动时将会计算 `physvirt` 和 `vmemmap` 偏移量以启用这个逻辑。
|
||||
为了优化 `phys_to_virt()` 和 `virt_to_phys()`,页偏移量将被保持在 `0xFFF0000000000000` (对应于 52 位),这消除了读取额外变量的需求。在早期启动时将会计算 `physvirt` 和 `vmemmap` 偏移量以启用这个逻辑。
|
||||
|
||||
考虑下面的物理和虚拟 RAM 地址空间的转换:
|
||||
|
||||
@ -139,8 +141,8 @@ vabits_actual 变量 *实际的* 虚拟地址空间大小
|
||||
*/
|
||||
|
||||
#define virt_to_phys(addr) ({ \
|
||||
if (!(((u64)addr) & BIT(vabits_actual - 1))) \
|
||||
(((addr) & ~PAGE_OFFSET) + PHYS_OFFSET)
|
||||
if (!(((u64)addr) & BIT(vabits_actual - 1))) \
|
||||
(((addr) & ~PAGE_OFFSET) + PHYS_OFFSET)
|
||||
})
|
||||
|
||||
#define phys_to_virt(addr) ((unsigned long)((addr) - PHYS_OFFSET) | PAGE_OFFSET)
|
||||
@ -152,11 +154,11 @@ vabits_actual 变量 *实际的* 虚拟地址空间大小
|
||||
|
||||
### 对用于调试内核的用户态程序的影响
|
||||
|
||||
一些用户空间应用程序用于调试正在运行的/活动中的内核或者分析系统崩溃时的 vmcore 转储(例如确定内核奔溃的根本原因):kexec-tools, makedumpfile, 和 crash-utility。
|
||||
有几个用户空间应用程序可以用于调试正在运行的/活动中的内核或者分析系统崩溃时的 vmcore 转储(例如确定内核奔溃的根本原因):kexec-tools、makedumpfile 和 crash-utility。
|
||||
|
||||
当用它们来调试 Arm64 内核时,因为 Arm64 内核内存映射被“翻转”,因此也会对它们产生影响。这些应用程序还需要遍历转换表以确定与虚拟地址相应的物理地址(类似于内核中的完成方式)。
|
||||
|
||||
相应地,在将“翻转”引入内核内存映射之后,由于上游中断了用户态应用程序,因此必须对其进行修改。
|
||||
相应地,在将“翻转”引入内核内存映射之后,由于上游破坏了用户态应用程序,因此必须对其进行修改。
|
||||
|
||||
我已经提议了对三个受影响的用户态应用程序的修复;有一些已经被上游接受,但其他仍在等待中:
|
||||
|
||||
@ -166,25 +168,25 @@ vabits_actual 变量 *实际的* 虚拟地址空间大小
|
||||
|
||||
除非在用户空间应用程序进行了这些修改,否则它们将仍然无法调试运行/活动中的内核或分析系统崩溃时的 vmcore 转储。
|
||||
|
||||
### 52 比特用户态虚拟地址
|
||||
### 52 位用户态虚拟地址
|
||||
|
||||
为了保持与依赖 ARMv8.0 虚拟地址空间的最大为 48 比特的用户空间应用程序的兼容性,在默认情况下内核会将虚拟地址从 48 比特范围返回给用户空间。
|
||||
为了保持与依赖 ARMv8.0 虚拟地址空间的最大为 48 位的用户空间应用程序的兼容性,在默认情况下内核会将虚拟地址从 48 位范围返回给用户空间。
|
||||
|
||||
通过指定大于48位的mmap提示参数,用户态程序可以“选择”从 52 比特空间接收虚拟地址。
|
||||
通过指定大于 48 位的 mmap 提示参数,用户态程序可以“选择”从 52 位空间接收虚拟地址。
|
||||
|
||||
例如:
|
||||
|
||||
```
|
||||
.mmap_high_addr.c
|
||||
\----
|
||||
----
|
||||
|
||||
maybe_high_address = mmap(~0UL, size, prot, flags,...);
|
||||
```
|
||||
|
||||
通过启用以下的内核配置选项,还可以构建一个从 52 比特空间返回地址的调试内核:
|
||||
通过启用以下的内核配置选项,还可以构建一个从 52 位空间返回地址的调试内核:
|
||||
|
||||
```
|
||||
` CONFIG_EXPERT=y && CONFIG_ARM64_FORCE_52BIT=y`
|
||||
CONFIG_EXPERT=y && CONFIG_ARM64_FORCE_52BIT=y
|
||||
```
|
||||
|
||||
_请注意此选项仅用于调试应用程序,不应在实际生产中使用。_
|
||||
@ -193,9 +195,9 @@ _请注意此选项仅用于调试应用程序,不应在实际生产中使用
|
||||
|
||||
总结一下:
|
||||
|
||||
1. 内核版本从 5.14 开始,新的 Armv8.2 硬件拓展 LVA 和 LPA 在内核中得到很好的拓展。
|
||||
1. 内核版本从 5.14 开始,新的 Armv8.2 硬件拓展 LVA 和 LPA 在内核中得到良好支持。
|
||||
2. 像 kexec-tools 和 makedumpfile 被用来调试内核的用户态应用程序现在无法支持新拓展,仍在等待上游接受修补。
|
||||
3. 过去的用户态应用程序依赖于 Arm64 内核提供的 48 比特虚拟地址将继续原样工作,而较新的用户态应用程序通构指定超过 48 比特更大的 mmap 提示参数来 “选择加入”已接受来自 52 比特的虚拟地址。
|
||||
3. 过去的用户态应用程序依赖于 Arm64 内核提供的 48 位虚拟地址将继续原样工作,而较新的用户态应用程序通构指定超过 48 位更大的 mmap 提示参数来 “选择加入”已接受来自 52 位的虚拟地址。
|
||||
|
||||
* * *
|
||||
|
||||
@ -208,7 +210,7 @@ via: https://opensource.com/article/20/12/52-bit-arm64-kernel
|
||||
作者:[Bhupesh Sharma][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/) 荣誉推出
|
||||
|
@ -0,0 +1,104 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13067-1.html)
|
||||
[#]: subject: (Super Productivity: A Super Cool Open Source To-Do List App with GitHub Integration)
|
||||
[#]: via: (https://itsfoss.com/super-productivity/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
超级生产力:一款集成了 GitHub 的超酷开源待办事项列表应用
|
||||
======
|
||||
|
||||
> “超级生产力”是一款很棒的开源待办事项应用,可以帮助你管理任务、跟踪事务和管理时间。
|
||||
|
||||
无论你做什么,提高工作效率是大多数人的共同目标。通常,你总会尝试各种[待办事项列表应用][1]或者[记事应用][2]来帮助自己组织和提醒事情,从而高效地跟上工作进度。
|
||||
|
||||
当然,你可以看看那些清单,根据自己的喜好去尝试其中的一些。在这里,我遇到了一些独特的东西,如果你想要一个具有可靠的用户界面、GitHub/GitLab 集成以及一系列基本功能的桌面待办事项应用,你也许可以尝试一下。
|
||||
|
||||
<ruby>超级生产力<rt>Super Productivity</rt></ruby>看起来是一个令人印象深刻的待办事项列表应用,并提供一些独特的功能。在本文中,我将让你简单了解它的一切。
|
||||
|
||||
### 超级生产力:一个简单的而有吸引力的开源待办事项应用程序
|
||||
|
||||
![][3]
|
||||
|
||||
“超级生产力”是一款开源应用,它由 [Johannes Millan][4] 在 GitHub 上积极维护。
|
||||
|
||||
对我来说,用户体验是最重要的,“超级生产力”提供的用户界面给我留下了十分深刻的印象。
|
||||
|
||||
它还提供了一堆基本功能以及一些有趣的选项。让我们来看看它们。
|
||||
|
||||
### “超级生产力”的功能
|
||||
|
||||
![][5]
|
||||
|
||||
* 添加待办事项、说明
|
||||
* 追踪花费在任务和休息上的时间
|
||||
* 项目管理(与 JIRA、GitHub 和 GitLab 整合)
|
||||
* 安排任务的能力
|
||||
* 语言选择选项
|
||||
* 同步到 Dropbox、Google Drive 或任何其他 WebDAV 存储位置
|
||||
* 导入/导出功能
|
||||
* 自动备份功能
|
||||
* 能够调整定时器和计数器的行为
|
||||
* 黑暗模式
|
||||
* 在任务中添加附件
|
||||
* 完全免费的重复任务
|
||||
* 跨平台支持
|
||||
|
||||
除了我提到的功能外,你还会发现更多详细的设置和调整配置。
|
||||
|
||||
尤其是与 [JIRA][6]、[GitHub][7] 和 [GitLab][8] 的整合。你可以自动分配要进行的工作任务,而不需要检查你的电子邮件以了解问题跟踪器或议题的最近更新。
|
||||
|
||||
与我目前使用过的许多收费版的待办事项 Web 服务相比,你会惊讶地发现许多有用的功能完全免费。
|
||||
|
||||
### 在 Linux 上安装“超级生产力”
|
||||
|
||||
![][9]
|
||||
|
||||
它有各种安装方式。我下载了 AppImage 文件测试了一下。但是,你也可以得到基于 Debian 的发行版的 deb 包。
|
||||
|
||||
它也可以作为一个 [snap][10] 来安装。你可以在 [GitHub 的发布部分][11]中找到所有的包。
|
||||
|
||||
如果你感兴趣,可以查看它的 [GitHub 页面][12]来了解它的更多信息。
|
||||
|
||||
- [下载超级生产力](https://github.com/johannesjo/super-productivity/releases)
|
||||
|
||||
### 总结
|
||||
|
||||
我发现“超级生产力”的用户体验非常棒。所提供的功能非常有用,考虑到你可以获得一些你通常从收费版的待办事项 Web 服务中才能获得的高级功能,它可以成为大多数用户的完美替代品。
|
||||
|
||||
你可以简单地使用 Google Drive、Dropbox 或任何其他 WebDAV 存储位置同步数据。
|
||||
|
||||
它也可以取代像 [ActivityWatch][13] 这样的服务,帮助你追踪你工作任务和保持闲置的时间。所以,它可以成为你提高生产力的一体化解决方案!
|
||||
|
||||
听起来很不错,对吧?
|
||||
|
||||
你对“超级生产力”有什么看法?请在下面的评论区告诉我你的想法。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/super-productivity/
|
||||
|
||||
作者:[Ankush Das][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[wxy](https://github.com/wxy)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/ankush/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://itsfoss.com/to-do-list-apps-linux/
|
||||
[2]: https://itsfoss.com/note-taking-apps-linux/
|
||||
[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/01/super-productivity.jpg?resize=800%2C569&ssl=1
|
||||
[4]: https://github.com/johannesjo
|
||||
[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/01/super-productivity-2.jpg?resize=800%2C575&ssl=1
|
||||
[6]: https://www.atlassian.com/software/jira
|
||||
[7]: https://github.com/
|
||||
[8]: https://about.gitlab.com
|
||||
[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/01/super-productivity-1.jpg?resize=800%2C574&ssl=1
|
||||
[10]: https://snapcraft.io/superproductivity
|
||||
[11]: https://github.com/johannesjo/super-productivity/releases
|
||||
[12]: https://github.com/johannesjo/super-productivity
|
||||
[13]: https://itsfoss.com/activitywatch/
|
@ -1,32 +1,34 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13056-1.html)
|
||||
[#]: subject: (3 plain text note-taking tools)
|
||||
[#]: via: (https://opensource.com/article/21/1/plain-text)
|
||||
[#]: author: (Kevin Sonney https://opensource.com/users/ksonney)
|
||||
|
||||
3 个纯文本记事工具
|
||||
======
|
||||
记笔记很重要,而纯文本是一种简单、中性的方式。这里有三个工具,你可以在不失去纯文本的简易和便携性的前提下,给你的笔记加点东西。
|
||||
![Typewriter with hands][1]
|
||||
|
||||
> 记笔记很重要,而纯文本是一种简单、中性的方式。这里有三个工具,你可以在不失去纯文本的简易和便携性的前提下,给你的笔记加点东西。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202101/27/153329o0waw16448hq0avf.jpg)
|
||||
|
||||
在前几年,这个年度系列涵盖了单个的应用。今年,我们除了关注 2021 年的策略外,还将关注一体化解决方案。欢迎来到 2021 年 21 天生产力的第五天。
|
||||
|
||||
纯文本是最具弹性的文档格式。纯文本文档体积小,可以在机器之间快速传输,并且可以在_任意_设备上阅读。因此,在纯文本文档中做笔记是很有意义的。
|
||||
纯文本是最具弹性的文档格式。纯文本文档体积小,可以在机器之间快速传输,并且可以在*任意*设备上阅读。因此,在纯文本文档中做笔记是很有意义的。
|
||||
|
||||
然而,纯文本也仅是纯文本。我们生活在一个富文本世界中,我们仍然需要标题、列表以及区分一个部分和另一个部分的方法。幸运的是,我们有几种方法可以添加这些元素,而不需要在纯文本文档中添加复杂的标记。
|
||||
然而,纯文本也仅是纯文本。我们生活在一个富文本世界中,我们仍然需要标题、列表以及区分一个章节和另一个章节的方法。幸运的是,我们有几种方法可以添加这些元素,而不需要在纯文本文档中添加复杂的标记。
|
||||
|
||||
### Markdown
|
||||
|
||||
![Markdown][2]
|
||||
|
||||
Markdown (Kevin Sonney, [CC BY-SA 4.0][3])
|
||||
*Markdown (Kevin Sonney, [CC BY-SA 4.0][3])*
|
||||
|
||||
由 Aaron Schwartz 和 John Gruber 创建的 [Markdown][4],是我如今每天使用最多的格式。从读写 README 文件、文档、记笔记,甚至源代码注释,Markdown 让我可以在不牺牲轻松阅读文档的能力的情况下添加格式。
|
||||
|
||||
此外,Markdown 还有几个”扩展版本“,以允许那些不属于原始设计的项目。特别是,[GitHub 风格的 Markdown][5] 由于其在同名的源码控制网站中的使用而异常流行。
|
||||
此外,Markdown 还有几个“扩展版本”,以允许那些不属于原始设计的项目。特别是,[GitHub 风格的 Markdown][5] 由于其在同名的源码控制网站中的使用而异常流行。
|
||||
|
||||
许多文件编辑器都支持 Markdown 高亮显示,不需要额外的附加组件或工作。
|
||||
|
||||
@ -34,21 +36,21 @@ Markdown (Kevin Sonney, [CC BY-SA 4.0][3])
|
||||
|
||||
![AsciiDoc][6]
|
||||
|
||||
AsciiDoc (Kevin Sonney, [CC BY-SA 4.0][3])
|
||||
*AsciiDoc (Kevin Sonney, [CC BY-SA 4.0][3])*
|
||||
|
||||
由 Stuart Rackham 创建的 [AsciiDoc][7] 是向纯文本文档添加富文本元素的另一种方式。AsciiDoc 有许多生成文档、书籍和论文的功能。然而,这并不意味着它不能被用来做笔记。有很多环境(特别是在教育和研究领域),能够快速将笔记转换为更”正式“的格式是很有帮助的。
|
||||
由 Stuart Rackham 创建的 [AsciiDoc][7] 是向纯文本文档添加富文本元素的另一种方式。AsciiDoc 有许多生成文档、书籍和论文的功能。然而,这并不意味着它不能被用来做笔记。有很多环境(特别是在教育和研究领域),能够快速将笔记转换为更“正式”的格式是很有帮助的。
|
||||
|
||||
AsciiDoc 也有很多工具可以将文本转换为其他格式进行协作。还有一些附加组件可以从不同的源导入数据,并将其放入最终的文档中,或者处理特殊的格式,如 MathML 或 LaTeX。
|
||||
|
||||
### Org Mode
|
||||
### Org 模式
|
||||
|
||||
![ORG-Mode][8]
|
||||
|
||||
ORG-Mode (Kevin Sonney, [CC BY-SA 4.0][3])
|
||||
*ORG-Mode (Kevin Sonney, [CC BY-SA 4.0][3])*
|
||||
|
||||
说到文本格式,我不能不提 [Org][9]。Org Mode 最初是为 [GNU Emacs][10] 设计的,现在已经成为笔记、待办事项、文档等常用的纯文本格式之一。Org 可以在包括 [Vim][11] 在内的众多文本编辑器中编写和使用。Org 简单、易学,是我最喜欢的笔记文本格式之一。
|
||||
说到文本格式,我不能不提 [Org 模式][9]。它最初是为 [GNU Emacs][10] 设计的,现在已经成为笔记、待办事项、文档等常用的纯文本格式之一。Org 模式可以在包括 [Vim][11] 在内的众多文本编辑器中编写和使用。Org 模式简单、易学,是我最喜欢的笔记文本格式之一。
|
||||
|
||||
最后,选择 Markdown、AsciiDoc 或 Org 作为纯文本笔记,是确保它们可以在任何地方被阅读和更新的一种方式。如果你和我一样,你会发现自己在做纸质笔记的时候,也会使用同样的语法!
|
||||
最后,选择 Markdown、AsciiDoc 或 Org 模式作为纯文本笔记,是确保它们可以在任何地方被阅读和更新的一种方式。如果你和我一样,你会发现自己在做纸质笔记的时候,也会使用同样的语法!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -57,7 +59,7 @@ via: https://opensource.com/article/21/1/plain-text
|
||||
作者:[Kevin Sonney][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/) 荣誉推出
|
||||
|
@ -0,0 +1,76 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13059-1.html)
|
||||
[#]: subject: (How to use KDE's productivity suite, Kontact)
|
||||
[#]: via: (https://opensource.com/article/21/1/kde-kontact)
|
||||
[#]: author: (Kevin Sonney https://opensource.com/users/ksonney)
|
||||
|
||||
如何使用 KDE 的生产力套件 Kontact
|
||||
======
|
||||
|
||||
> KDE 很棒,但当你使用这个统一个人信息管理器 Kontact 时,它才真正发挥了作用。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202101/28/094146fyx79l7zwbwej7ym.jpg)
|
||||
|
||||
在前几年,这个年度系列涵盖了单个的应用。今年,我们除了关注 2021 年的策略外,还将关注一体化解决方案。欢迎来到 2021 年 21 天生产力的第六天。
|
||||
|
||||
在很久很久以前,当编译内核还是获取 WiFi 驱动的唯一途径时,图形环境主要是用来运行网页浏览器和打开大量终端窗口。其外观和感觉是由程序作者选择使用的各种工具箱组成的大杂烩。然后,在 1996 年 [Matthias Ettrich][2] 提出并随后发布了第一个版本的 [KDE][3]。它是基于当时专有的 [Qt][4] 工具箱(后来成为自由而开源的)。这个版本引发了 Linux 上的桌面革命,同一时期出现的还有使用当时的自由开源软件 GTK 工具包所创建的 [GNOME 桌面][5] 。不管是 KDE 还是 GNOME,Linux 从一个*只有电脑操作人员使用的 Linux 操作系统*变成了一个人人都能使用的强大桌面环境。
|
||||
|
||||
![Fedora KDE Spin Default Desktop][6]
|
||||
|
||||
*Fedora KDE 版的默认桌面 (Kevin Sonney, [CC BY-SA 4.0][7])*
|
||||
|
||||
KDE Plasma 5 是最新的 KDE 版本,它的功能非常丰富,可以提高你的工作效率。它包括了 Konqueror 网页浏览器、Dolphin 文件管理器和 Konsole 终端模拟器,所有这些都为这个桌面环境提供了一个很好的坚实基础,但是 KDE 真正提高生产力的方法是这个统一个人信息管理器:[Kontact][8]。
|
||||
|
||||
Kontact 为其他几个 KDE 程序提供了一个单一的界面,包括:KMail(电子邮件)、KOrganizer(日历、待办事项和日记)、KAddressBook(地址簿)、KNotes(笔记)、Akregator(RSS/ATOM 订阅阅读器)等。第一次启动时,Kontact 会引导你完成电子邮件提供商的设置,它支持本地和远程邮件配置。然后,Kontact 会进入一个仪表板,默认情况下,该仪表板会显示最近的电子邮件、日历事件、计划任务和最近的笔记。
|
||||
|
||||
![Kontact Summary screen][9]
|
||||
|
||||
*Kontact 概览页面 (Kevin Sonney, [CC BY-SA 4.0][7])*
|
||||
|
||||
设置“流程”看起来有点奇怪,因为在内置的本地账户之外没有配置统一的单一账户。在 Kontact(通过 KMail)引导你完成邮件设置后,你就可以进入日历页面添加你的日历,这里也配置了待办事项和日记应用(对于某些提供商,还可以配置通讯录)。
|
||||
|
||||
邮件和日历组件非常简单明了,可以如你期望地正常工作。待办事项页面和日记是与日历绑定的,这对于一些不完全支持所有日历类型的日历提供商来说可能是个问题(Google,我说的是你)。如果你使用的是这些提供商中的一个,你将需要为日记和待办事项创建一个特定的本地日历。
|
||||
|
||||
![Kontact Calendar][10]
|
||||
|
||||
*Kontact Calendar (Kevin Sonney, [CC BY-SA 4.0][7])*
|
||||
|
||||
待办事项列表有很多功能。虽然它可以作为一个简单的任务清单与提醒,它也支持一些轻量级的项目管理功能。它有一个完成百分比的滑块,可以从主列表视图中更新,这样你就可以跟踪进度。它能够附加文件和分配 1-10 的优先级。最后,它可以像其他日历约会一样将用户添加到任务中。
|
||||
|
||||
创建一个日记条目本质上是在日历上给自己创建一个笔记。它是一段形式自由的文本,就像写在实体笔记本和计划手册的某一天上那样。如果你要记录工作,写下每天的日记,或只是需要个地方记录会议记录,这个功能是非常*方便*的(本系列后面有更多关于这个的内容)。
|
||||
|
||||
![Kontact Journal][11]
|
||||
|
||||
*Kontact Journal (Kevin Sonney, [CC BY-SA 4.0][7])*
|
||||
|
||||
构成 Kontact 的这些程序非常强大,如果你愿意的话,也可以作为单独的应用运行。Kontact 通过给你提供一个集中的地方,在一个应用内找到你所有的信息,从而提升了它们的实用性。
|
||||
|
||||
大多数发行版都允许你在没有 KDE 的情况下安装 Kontact 和它所使用的组件,但当它作为 KDE 桌面的一部分使用时,它才会真正发挥其作用。KDE 在 Fedora KDE 版、KUbuntu、KDE Neon(基于 Ubuntu LTS)和其他几个发行版中都是默认桌面。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/kde-kontact
|
||||
|
||||
作者:[Kevin Sonney][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/ksonney
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/team_dev_email_chat_video_work_wfm_desk_520.png?itok=6YtME4Hj (Working on a team, busy worklife)
|
||||
[2]: https://en.wikipedia.org/wiki/Matthias_Ettrich
|
||||
[3]: https://kde.org/
|
||||
[4]: https://en.wikipedia.org/wiki/Qt_(software)
|
||||
[5]: https://www.gnome.org/
|
||||
[6]: https://opensource.com/sites/default/files/pictures/fedora-kde-spin-default-desktop.png (Fedora KDE Spin Default Desktop)
|
||||
[7]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[8]: https://kontact.kde.org/
|
||||
[9]: https://opensource.com/sites/default/files/pictures/kontact-summary-screen_0.png (Kontact Summary screen)
|
||||
[10]: https://opensource.com/sites/default/files/pictures/kontact-calendar.png (Kontact Calendar)
|
||||
[11]: https://opensource.com/sites/default/files/pictures/kontact-journal.png (Kontact Journal)
|
@ -1,50 +1,50 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13062-1.html)
|
||||
[#]: subject: (Organize your task list using labels)
|
||||
[#]: via: (https://opensource.com/article/21/1/labels)
|
||||
[#]: author: (Kevin Sonney https://opensource.com/users/ksonney)
|
||||
|
||||
使用标签组织你的任务列表
|
||||
======
|
||||
文件夹的用途是存储信息和任务。使用标签来帮助你更好地组织这些文件夹中的内容。
|
||||
![Kanban-style organization action][1]
|
||||
|
||||
在前几年,这个年度系列涵盖了单个的应用。今年,我们除了关注 2021 年的策略外,还将关注一体化解决方案。欢迎来到 2021 年 21 天生产力的第九天。
|
||||
> 文件夹的用途是存储信息和任务。使用标签来帮助你更好地组织这些文件夹中的内容。
|
||||
|
||||
我用电子邮件、待办列表和笔记来做这件事,有一天我决定我要把这些“组织起来”,重新安排我保存东西的方式和位置。有时我发现了一个新的程序,我必须(再次)从头开始配置。有时,当前的方法已经花了很多时间,与我使用系统的时间相比,我花了更多的时间在保持存储顺序最新。我去年测试一些待办列表软件时,最后一个软件让我有了一个非常重要的认识。
|
||||
![](https://img.linux.net.cn/data/attachment/album/202101/29/150011k9sz3n0q99mmkems.jpg)
|
||||
|
||||
在前几年,这个年度系列报道了诸如 Notmuch 和 Syncthing 之类的开源的组织应用程序。今年,我们除了关注 2021 年的策略外,还将关注一体化解决方案。欢迎来到 2021 年 21 天生产力的第九天。
|
||||
|
||||
我用我的电子邮件、待办列表和笔记来做这件事,有一天我决定我要把这些“组织起来”,重新安排我保存东西的方式和位置。有时我发现了一个新的程序,我必须(再次)从头开始配置。有时,当前的方法已经花了很多时间,与我使用系统的时间相比,我花了更多的时间在保持存储顺序最新。我去年测试一些待办列表软件时,最后一个软件让我有了一个非常重要的认识。
|
||||
|
||||
![List of labels][4]
|
||||
|
||||
所有事情都有存放的地方(Kevin Sonney, [CC BY-SA 4.0][5])
|
||||
*所有事情都有存放的地方(Kevin Sonney, [CC BY-SA 4.0][5])*
|
||||
|
||||
让我先打个比方。一个任务(或电子邮件或笔记)就像你在一次活动中收到的那件很酷的 T 恤。它是黑色的,有一个很棒的图案,后面有一个标签,上面写着尺寸,领口有一个标签,上面写着洗涤说明。到了该收起来的时候,它该放在哪里呢?是和黑色的 T 恤放在一起吗?是和类似主题的衬衫放在一起吗?是按尺码放吗?是按需要洗涤的方式?还是按材质?
|
||||
让我打个比方。一个任务(或电子邮件或笔记)就像你在一次活动中收到的那件很酷的 T 恤。它是黑色的,有一个很棒的图案,后面有一个标签,上面写着尺寸,领口有一个标签,上面写着洗涤说明。到了该收起来的时候,它该放在哪里呢?是和黑色的 T 恤放在一起吗?是和类似主题的衬衫放在一起吗?是按尺码放吗?是按需要洗涤的方式?还是按材质?
|
||||
|
||||
一件 T 恤只能放在_一_个地方,即使它可以有多种特质。我们需要以同样的方式对待任务、电子邮件和笔记。一个非常大的[电子邮件提供商][6]已经允许我们把一个标签当作一个文件夹。一封邮件(或一个文档或一个任务)可以同时在两个文件夹中!或者三个!甚至 11 个!
|
||||
一件 T 恤只能放在*一*个地方,即使它可以有多种特质。我们需要以同样的方式对待任务、电子邮件和笔记。大型[电子邮件提供商][6]已经允许我们把一个标签当作一个文件夹。一封邮件(或一个文档或一个任务)可以同时在两个文件夹中!或者三个!甚至 11 个!
|
||||
|
||||
![Guitar volume 11][7]
|
||||
|
||||
它高达 11 个(Seth Kenlon, [CC BY-SA 4.0][5])
|
||||
*它高达 11 个(Seth Kenlon, [CC BY-SA 4.0][5])*
|
||||
|
||||
我必须明智地决定不再这样做。文件夹不是标签,标签也不是文件夹。这让我找到了我目前整理待办事项清单(和笔记,以及电子邮件)的规则。
|
||||
我必须明智地决定不再这样做。文件夹不是标签,标签也不是文件夹。这让我找到了我目前整理待办事项清单(和笔记,以及电子邮件)的规则:
|
||||
|
||||
1. 一个任务只应该在一个文件夹里。文件夹是以“大的事情”命名的,比如一个地方或组织。我目前有三个文件夹来存放任务。“工作”、“家庭”和 “爱好”。当我专注于其中一个领域时,我知道我在看什么任务。
|
||||
1. 一个任务只应该在一个文件夹里。文件夹是以“大事”来命名的,比如一个地方或组织。我目前有三个文件夹来存放任务。“工作”、“家庭”和 “爱好”。当我专注于其中一个领域时,我知道我在看什么任务。
|
||||
2. 一个任务可以有任意个我需要的标签。我尽量保持在三个左右或更少。
|
||||
3. 一个任务应该有一个明确的意义。也许是你要写的程序的名字。也许是一些通用的东西,比如“要读的书”或“账单”。但如果你记不起 “4rg8sn5” 就是“要支付的账单”,这就对你没有帮助。
|
||||
|
||||
利用这些规则,如果我有一个“写第 9 天文章”的任务,它就会进入”爱好“文件夹,我给它打上 “OSDC”、“文章”、“2021” 的标签。如果我想在我的 [Elementary Planner][8] 中看到我所有的 2021 年的任务,我可以搜索这个标签。任务最终会出现在 “OSDC” 的搜索中,其中可能还包括一个对文章发表评论的待办事项,一个开始规划 2022 年系列的待办事项,还有一个跟进我认为有好文章想法的人。
|
||||
|
||||
|
||||
利用这些规则,如果我有一个“写第 9 天文章”的任务,它就会进入”爱好“文件夹,我给它打上 ”OSDC“、”文章“、”2021“ 的标签。如果我想在我的 [Elementary Planner][8] 中看到我所有的 2021 年的任务,我可以搜索这个标签。任务最终会出现在 ”OSDC“ 的搜索中,其中可能还包括一个对文章发表评论的待办事项,一个开始规划 2022 年系列的待办事项,还有一个跟进我认为有好文章想法的人。
|
||||
|
||||
我的”工作“文件夹里的东西通常是按项目标记的。”完成管理 CLI 文档“可能会被分为 “github”、“prod” 和 “admin”。“docs” 标签包含了“工作”和”爱好“文件夹中的项目,因为写文档是这两个文件夹都需要做的事情。
|
||||
我的“工作”文件夹里的东西通常是按项目标记的。“完成管理 CLI 文档”可能会被分为 “github”、“prod” 和 “admin”。“docs” 标签包含了“工作”和”爱好“文件夹中的项目,因为写文档是这两个文件夹都需要做的事情。
|
||||
|
||||
![Linux Elementary planner][9]
|
||||
|
||||
文件夹和标签(Kevin Sonney, [CC BY-SA 4.0][5])
|
||||
*文件夹和标签(Kevin Sonney, [CC BY-SA 4.0][5])*
|
||||
|
||||
将”标签“和”文件夹“进行心理分离,帮助我将任务进行分组和分类,而不至于过度。这也意味着我可以更快地找到事情,花更少的时间去维护我的待办事项清单,而花更多的时间去做清单上的事情。
|
||||
将“标签”和“文件夹”进行心理分离,帮助我将任务进行分组和分类,而不至于过度。这也意味着我可以更快地找到事情,花更少的时间去维护我的待办事项清单,而花更多的时间去做清单上的事情。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -53,7 +53,7 @@ via: https://opensource.com/article/21/1/labels
|
||||
作者:[Kevin Sonney][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/) 荣誉推出
|
||||
|
@ -1,46 +1,48 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13070-1.html)
|
||||
[#]: subject: (Why keeping a journal improves productivity)
|
||||
[#]: via: (https://opensource.com/article/21/1/open-source-journal)
|
||||
[#]: author: (Kevin Sonney https://opensource.com/users/ksonney)
|
||||
|
||||
为什么写日志能提高效率
|
||||
为什么写日记能提高效率
|
||||
======
|
||||
写日志有着悠久的历史。这里有三个开源工具,可以帮助你写日志变得更轻松。
|
||||
![Note taking hand writing][1]
|
||||
|
||||
> 写日记有着悠久的历史。这里有三个开源工具,可以帮助你写日记变得更轻松。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202101/31/082622p6wgh7szzuvevug4.jpg)
|
||||
|
||||
在前几年,这个年度系列涵盖了单个的应用。今年,我们除了关注 2021 年的策略外,还将关注一体化解决方案。欢迎来到 2021 年 21 天生产力的第十天。
|
||||
|
||||
在商业互联网还没有出现的我的小学时代,老师经常会给我们班级布置一个让我们写日志的作业。有时会针对一些特定的内容,例如特定格式的虫子列表和说明,或者是公民课的每周新闻摘要。
|
||||
在我的小学时代,商业互联网还没有出现,老师经常会给我们班级布置一个让我们写日记的作业。有时会针对一些特定的内容,例如特定格式的虫子列表和说明,或者是公民课的每周新闻摘要。
|
||||
|
||||
几个世纪以来,人们一直在写日志。它们是一种方便的信息保存方式。它们有很多形式,比如意大利的 [Zibaldone][2]、[备忘录][3],或者记录今天做了什么的事件日志。
|
||||
几个世纪以来,人们一直在写日记。它们是一种方便的信息保存方式。它们有很多形式,比如意大利的 [Zibaldone][2]、[备忘录][3],或者记录今天做了什么的事件日记。
|
||||
|
||||
![Notebook folders][4]
|
||||
|
||||
(Kevin Sonney, [CC BY-SA 4.0][5])
|
||||
*(Kevin Sonney, [CC BY-SA 4.0][5])*
|
||||
|
||||
为什么我们要写某种日志呢?第一个原因是为了让我们不至于把所有的事情都记在脑子里。我们中没有多少人有[遗觉记忆][6],维护运行日志或一组笔记可以让我们更容易地参考我们之前做的一些事情。日志也更容易分享,因为它们可以在聊天、邮件中复制/粘贴。正如 [Robert Boyce][7]的名言:”知识就是力量。知识共享就是力量倍增。“知识的共享是开源的一个内在组成部分。
|
||||
为什么我们要写某种日记呢?第一个原因是为了让我们不至于把所有的事情都记在脑子里。我们中没有多少人有<ruby>[遗觉记忆][6]<rt>Eidetic memory</rt></ruby>,维护运行日记或一组笔记可以让我们更容易地参考我们之前做的一些事情。日记也更容易分享,因为它们可以在聊天、邮件中复制/粘贴。正如 [Robert Boyce][7] 的名言:“知识就是力量。知识共享使力量倍增。”知识的共享是开源的一个内在组成部分。
|
||||
|
||||
![Today's journal][8]
|
||||
|
||||
今天的日志 (Kevin Sonney, [CC BY-SA 4.0][5])
|
||||
*今天的日记 (Kevin Sonney, [CC BY-SA 4.0][5])*
|
||||
|
||||
在写事件日志的时候,有一个很关键的点就是要快速、简单、方便。最简单的方法是打开文档,添加一行当前日期和备注,然后保存。
|
||||
在写事件日记的时候,有一个很关键的点就是要快速、简单、方便。最简单的方法是打开文档,添加一行当前日期和备注,然后保存。
|
||||
|
||||
有几个程序或附加软件可以让这一切变得更简单。[GNote 的 Note of the Day 插件][9]会自动创建一个以日期为标题的笔记,可以用来保存当天的内容。
|
||||
|
||||
Emacs Org 有一个热键组合,可以”捕捉“事物并将其放入文档中。结合 [org-journal][10] 附加组件,这将在文档中创建当天的条目。
|
||||
Emacs Org 模式有一个热键组合,可以“捕捉”事物并将其放入文档中。结合 [org-journal][10] 附加组件,这将在文档中创建当天的条目。
|
||||
|
||||
Kontact 的 KNotes 组件会自动将日期和时间添加到新笔记中。
|
||||
|
||||
![Finding a note][11]
|
||||
|
||||
查找笔记 (Kevin Sonney, [CC BY-SA 4.0][5])
|
||||
*查找笔记 (Kevin Sonney, [CC BY-SA 4.0][5])*
|
||||
|
||||
写日志或记录事情是一种方便的方法,可以记录做了什么和怎么做的。它的作用不仅仅是”我做了什么“,它还可以包括阅读的书籍、吃过的食物、去过的地方,以及一大堆对未来有用的信息。
|
||||
写日记或记录事情是一种方便的方法,可以记录做了什么和怎么做的。它的作用不仅仅是“我做了什么”,它还可以包括阅读的书籍、吃过的食物、去过的地方,以及一大堆对未来有用的信息。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -49,7 +51,7 @@ via: https://opensource.com/article/21/1/open-source-journal
|
||||
作者:[Kevin Sonney][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/) 荣誉推出
|
||||
|
@ -0,0 +1,89 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (AnyISalIn)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13063-1.html)
|
||||
[#]: subject: (How to implement a DevOps toolchain)
|
||||
[#]: via: (https://opensource.com/article/21/1/devops-tool-chain)
|
||||
[#]: author: (Tereza Denkova https://opensource.com/users/tereza-denkova)
|
||||
|
||||
如何实现 DevOps 工具链
|
||||
======
|
||||
|
||||
> 一套完整启用的 DevOps 工具链可推动你的创新计划,实现快速部署并节约成本。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202101/29/153905o35h8u9zy5k58bll.jpg)
|
||||
|
||||
不同规模和不同行业组织都致力于为提高软件交付的速度和质量提供解决方案。这不仅保证了他们的生存,还令他们在全球市场取得了成功。DevOps 可以帮助他们规划出一条最佳路线。
|
||||
|
||||
DevOps 是一个系统,通过引入不同的工具链连接不同工作流程,以便及时交付项目并降低所需的开销。
|
||||
|
||||
在我工作的 IT 服务公司 [Accedia][2],我们会帮助客户落地一套完整的 DevOps 工具链,这套工具链能帮助他们达到甚至超越他们的业务目标。在这篇文章,我会分享目前为止从 DevOps 项目中汲取的经验。
|
||||
|
||||
### DevOps 工具链是什么?
|
||||
|
||||
一套完善的 DevOps 工具链可以在不同阶段中使用不同的 DevOps 工具来解决特定的业务带来的挑战。一条工具链能保证前端和后端开发者、质量测试人员、客户都能够从中获得收益。构建工具链的目的是为了自动化开发和部署过程,以确保快速、可靠、预算友好地交付与创新。
|
||||
|
||||
我们发现成功构建一套 DevOps 工具链不是一个简单的事情。它需要实验和不断的完善,保证必要的流程是完全自动化的。
|
||||
|
||||
### 为什么你需要 DevOps 工具链
|
||||
|
||||
DevOps 工具链自动化了工作流中的所有技术元素。它能让不同团队在一个平台上进行工作,因此可以使你专注于业务战略以推动组织走向未来。
|
||||
|
||||
我们总结了五个实现 DevOps 工具链所带来的好处。你可以让管理层相信,是值得为 DevOps 工具链的开发投入资源和时间的。
|
||||
|
||||
1. **更快、更高效的生产部署**:DevOps 工具自动化了大部分软件开发进程。这会使产品开发专注于创新,交付更加敏捷,更领先于竞争对手。
|
||||
2. **预算和时间优化**:将手动的任务转变为自动化会使你的组织节省时间和资源。当没有人为的错误和时间管理不足带来的额外支出,预算自然会得到优化。
|
||||
3. **高效的开发**:DevOps 工具链会减少开发工作中不必要的延时,提高开发效率。前端、后端、质量测试人员的工作是一致的,所以没有人需要协调不同团队之间人员的交付。
|
||||
4. **更快的部署意味着更高的质量**:DevOps 工具链保证了缺陷能够很快被解决,并且迅速完成高质量的部署进程。怎么样?它可以生成有针对性的告警,并将重要的事件通知给你的团队。这会让你主动地发现并解决潜在的问题,从而规避故障的不断的升级从而导致的客户服务不可用。
|
||||
5. **及时事件管理**:DevOps 工具链有助于优化事件管理记录。它能够识别 IT 事件并且逐渐升级事件级别,通知给指定团队的成员,直到问题被解决。这意味着消息的接受和处理会更加的迅速,因为它们发送给了正确的目标。
|
||||
|
||||
### DevOps 工具链的实践
|
||||
|
||||
对我的团队来说,DevOps 并不新鲜。我们已经敏捷开发很长时间了,并且我们总是热衷于探索最优的工作流。在我们的实践中,往往都是应用复杂性增加从而带来了自动化的需求。
|
||||
|
||||
这是我们为一个客户配置的工具链。这个项目包含了移动运营方案,连接了金融交易的所有参与者 (卖方、买方、银行)。这个客户需要动态响应用户反馈并且将故障时间缩短到最小,从而来提高用户体验。我的团队设计了一套工具链用于自动化应用的维护和部署新功能。
|
||||
|
||||
![Accedia's DevOps toolchain][3]
|
||||
|
||||
*(Accedia, [CC BY-NC-SA 4.0][4])*
|
||||
|
||||
1. 首先,我们团队编写了自动化测试,可以立即识别应用程序的变更。
|
||||
2. 当新版本已经准备就绪的时候,代码将被提交到 Gitlab 中。
|
||||
3. 通过 Gitlab,提交会自动触发 Jenkins 构建。
|
||||
4. 在 **持续集成中**,新的代码版本通过 [Chai][5] 和 [Mocha][6] 进行了测试,以检测是否运行正常。
|
||||
5. 当测试通过,**持续部署阶段** 将会开始并创建一个可用的 Docker 镜像并上传到 Sonatype 的 [Nexus][7]。(这是 Sonatype 公司的的一个开源工具)
|
||||
6. 最后,新版本应用会通过 Nexus 下载并且部署到线上环境中,例如 [Docker][8] 容器 (**持续部署阶段**)
|
||||
|
||||
简而言之,每当有人在仓库中创建一个新的提交,又或者团队上传新的代码版本、功能、升级、缺陷修复等,应用程序包都会自动更新并且交付给客户。
|
||||
|
||||
这套系统拥有良好的事故控制能力以保证快速部署,但不以牺牲质量为代价。它对于用户的反馈是动态的,意味着新功能和旧功能的和更新只需要之前一半的时间,同时将故障时间降低到最低。
|
||||
|
||||
### 把它封装起来
|
||||
|
||||
一套完整并且正确实施的 DevOps 工具链可以从始至终推动你的创新计划并且加速部署。
|
||||
|
||||
根据你的需求,你的工具链可能看起来和这些不一样,但是我希望我们的工作流能够让你了解如何将自动化作为一种解决方案。
|
||||
|
||||
-------------------------------------------------- -----------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/devops-tool-chain
|
||||
|
||||
作者:[Tereza Denkova][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[AnyISalIn](https://github.com/AnyISalIn)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/tereza-denkova
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tools_osyearbook2016_sysadmin_cc.png?itok=Y1AHCKI4 (Wratchet set tools)
|
||||
[2]: https://accedia.com/services/operations/devops/
|
||||
[3]: https://opensource.com/sites/default/files/uploads/devopstoolchain.png (Accedia's DevOps toolchain)
|
||||
[4]: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
[5]: https://www.chaijs.com/
|
||||
[6]: https://mochajs.org/
|
||||
[7]: https://www.sonatype.com/nexus/repository-oss
|
||||
[8]: https://opensource.com/resources/what-docker
|
||||
[9]: https://accedia.com/blog/5-good-reasons-why-you-need-a-devops-toolchain/
|
@ -0,0 +1,69 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (Chao-zhi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13090-1.html)
|
||||
[#]: subject: (7 Bash tutorials to enhance your command line skills in 2021)
|
||||
[#]: via: (https://opensource.com/article/21/1/bash)
|
||||
[#]: author: (Jim Hall https://opensource.com/users/jim-hall)
|
||||
|
||||
7 个 Bash 教程,提高你的命令行技能(2021 版)
|
||||
======
|
||||
|
||||
> Bash 是大多数 Linux 系统上的默认命令行 shell。所以你为什么不试着学习如何最大限度地利用它呢?
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/06/001837cujo0ql3utfobrrj.jpg)
|
||||
|
||||
Bash 是大多数 Linux 系统上的默认命令行 shell。所以你为什么不试着学习如何最大限度地利用它呢?今年,我们推荐了许多很棒的文章来帮助你充分利用 Bash shell 的强大功能。以下是一些关于 Bash 阅读次数最多的文章:
|
||||
|
||||
### 《通过重定向在 Linux 终端任意读写数据》
|
||||
|
||||
输入和输出重定向是任何编程或脚本语言的基础功能。从技术上讲,只要你与电脑互动,它就会自然而然地发生。输入从 stdin(标准输入,通常是你的键盘或鼠标)读取,输出到 stdout(标准输出,一般是文本或数据流),而错误被发送到 stderr(标准错误,一般和标准输出是一个位置)。了解这些数据流的存在,使你能够在使用 Bash 等 shell 时控制信息的去向。Seth Kenlon [分享][2]了这些很棒的技巧,可以让你在不需要大量鼠标移动和按键的情况下从一个地方获取数据。你可能不经常使用重定向,但学习使用它可以为你节省大量不必要的打开文件和复制粘贴数据的时间。
|
||||
|
||||
### 《系统管理员 Bash 脚本入门》
|
||||
|
||||
Bash 是自由开源软件,所以任何人都可以安装它,不管他们运行的是 Linux、BSD、OpenIndiana、Windows 还是 macOS。Seth Kenlon [帮助][3]你学习如何使用 Bash 的命令和特性,使其成为最强大的 shell 之一。
|
||||
|
||||
### 《针对大型文件系统可以试试此 Bash 脚本》
|
||||
|
||||
你是否曾经想列出一个目录中的所有文件,只显示其中的文件,不包括其他内容?或者只显示目录?如果你有,那么 Nick Clifton 的[文章][4]可能正是你正在寻找的。Nick 分享了一个漂亮的 Bash 脚本,它可以列出目录、文件、链接或可执行文件。该脚本使用 `find` 命令进行搜索,然后运行 `ls` 显示详细信息。对于管理大型 Linux 系统的人来说,这是一个漂亮的解决方案。
|
||||
|
||||
### 《用 Bash 工具对你的 Linux 系统配置进行快照》
|
||||
|
||||
你可能想与他人分享你的 Linux 配置,原因有很多。你可能需要帮助排除系统上的一个问题,或者你对自己创建的环境非常自豪,想向其他开源爱好者展示它。Don Watkins 向我们[展示][5]了 screenFetch 和 Neofetch 来捕获和分享你的系统配置。
|
||||
|
||||
### 《6 个方便的 Git 脚本》
|
||||
|
||||
Git 已经成为一个无处不在的代码管理系统。了解如何管理 Git 存储库可以简化你的开发体验。Bob Peterson [分享][6]了 6 个 Bash 脚本,它们将使你在使用 Git 存储库时更加轻松。`gitlog` 打印当前补丁的简略列表,并与主版本相对照。这个脚本的不同版本可以显示补丁的 SHA1 id 或在一组补丁中搜索字符串。
|
||||
|
||||
### 《改进你 Bash 脚本的 5 种方法》
|
||||
|
||||
系统管理员通常编写各种或长或短的 Bash 脚本,以完成各种任务。Alan Formy-Duval [解释][7]了如何使 Bash 脚本更简单、更健壮、更易于阅读和调试。我们可能会考虑到我们需要使用诸如 Python、C 或 Java 之类的语言来实现更高的功能,但其实也不一定需要。因为 Bash 脚本语言就已经非常强大。要最大限度地发挥它的效用,还有很多东西要学。
|
||||
|
||||
### 《我珍藏的 Bash 秘籍》
|
||||
|
||||
Katie McLaughlin 帮助你提高你的工作效率,用别名和其他快捷方式解决你经常忘记的事情。当你整天与计算机打交道时,找到可重复的命令并标记它们以方便以后使用是非常美妙的。Katie [总结][8]了一些有用的 Bash 特性和帮助命令,可以节省你的时间。
|
||||
|
||||
这些 Bash 小技巧将一个已经很强大的 shell 提升到一个全新的级别。也欢迎分享你自己的建议。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/bash
|
||||
|
||||
作者:[Jim Hall][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[Chao-zhi](https://github.com/Chao-zhi)
|
||||
校对:[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/terminal_command_linux_desktop_code.jpg?itok=p5sQ6ODE (Terminal command prompt on orange background)
|
||||
[2]: https://linux.cn/article-12385-1.html
|
||||
[3]: https://opensource.com/article/20/4/bash-sysadmins-ebook
|
||||
[4]: https://linux.cn/article-12025-1.html
|
||||
[5]: https://opensource.com/article/20/1/screenfetch-neofetch
|
||||
[6]: https://linux.cn/article-11797-1.html
|
||||
[7]: https://opensource.com/article/20/1/improve-bash-scripts
|
||||
[8]: https://linux.cn/article-11841-1.html
|
@ -0,0 +1,286 @@
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: "amwps290"
|
||||
[#]: reviewer: "wxy"
|
||||
[#]: publisher: "wxy"
|
||||
[#]: url: "https://linux.cn/article-13087-1.html"
|
||||
[#]: subject: "Learn JavaScript by writing a guessing game"
|
||||
[#]: via: "https://opensource.com/article/21/1/learn-javascript"
|
||||
[#]: author: "Mandy Kendall https://opensource.com/users/mkendall"
|
||||
|
||||
通过编写一个简单的游戏学习 JavaScript
|
||||
======
|
||||
|
||||
> 通过使用一个简单的游戏来练习一些基本的 JavaScript 概念,迈出创建交互性动态 Web 内容的第一步。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/05/151531z6fzqx8vk8tdan81.jpg)
|
||||
|
||||
可以肯定地说,没有 [JavaScript][2],大多数现代 Web 都将不存在。它是三种标准 Web 技术(以及 HTML 和 CSS )之一,它使任何人都可以创建我们在万维网体验中所期待的交互式、动态内容。从 [React][3] 这样的框架到 [D3][4] 这样的数据可视化库,很难想象没有它的 Web。
|
||||
|
||||
现在有很多东西要学习,开始学习这种流行语言的好方法是编写一个简单的应用程序以熟悉某些概念。 最近,一些人写了关于如何通过编写简单的猜谜游戏来学习自己喜欢的语言的文章,因此这是一个很好的起点!
|
||||
|
||||
### 现在开始吧
|
||||
|
||||
JavaScript 有许多种风格,但我将从最基本的开始,通常称为 “普通 JavaScript”。 JavaScript 主要是一种客户端脚本语言,因此它可以在任何标准浏览器中运行,而无需安装任何程序。你只需要一个代码编辑器([Brackets][5] 就是一个不错的选择)和一个 Web 浏览器。
|
||||
|
||||
### HTML 用户界面
|
||||
|
||||
JavaScript 在 Web 浏览器中运行,并与其他标准 Web 技术 HTML 和 CSS 交互。要创建此游戏,你首先需要使用 HTML(超文本标记语言)来创建供玩家使用的简单界面。如果你不清楚,HTML 是一种标记语言,用于为 Web 内容提供结构。
|
||||
|
||||
首先,先创建一个 HTML 文件。该文件应具有 `.html` 扩展名,以使浏览器知道它是 HTML 文档。你可以将文件命名为 `guessingGame.html`。
|
||||
|
||||
在此文件中使用一些基本的 HTML 标签来显示游戏的标题、玩法说明,供玩家用来输入和提交其猜测的交互式元素以及用于向玩家提供反馈的占位符:
|
||||
|
||||
```
|
||||
<!DOCTYPE>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title> JavaScript Guessing Game </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Guess the Number!</h1>
|
||||
<p>I am thinking of a number between 1 and 100. Can you guess what it is?</p>
|
||||
|
||||
<label for="guess">My Guess</label>
|
||||
<input type="number" id="guess">
|
||||
<input type="submit" id="submitGuess" value="Check My Guess">
|
||||
|
||||
<p id="feedback"></p>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
`<h1>` 和 `<p>` 元素使浏览器知道在页面上显示什么类型的文本。标签对 `<h1></h1>` 表示标签之间的文本(`Guess the Number!`)是标题。后面的一组 `<p>` 标签表示带有说明的短文本是一个段落。此代码块末尾的空 `<p>` 标签用作占位符,用于根据用户的输入提供一些反馈。
|
||||
|
||||
### `<script>` 标签
|
||||
|
||||
在网页中包含 JavaScript 的方法有很多种,但是对于像这样的简短脚本,可以使用一组 `<script>` 标签并将 JavaScript 直接写在 HTML 文件中。 这些 `<script>` 标签应位于 HTML 文件末尾附近的 `</body>` 标签之前。
|
||||
|
||||
现在,你可以开始在这两个脚本标签之间编写 JavaScript。 最终文件如下所示:
|
||||
|
||||
```
|
||||
<!DOCTYPE>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title> JavaScript Guessing Game </title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Guess the Number!</h1>
|
||||
<p>I am thinking of a number between 1 and 100. Can you guess what it is?</p>
|
||||
|
||||
<form>
|
||||
<label for="guess">My Guess</label>
|
||||
<input type="number" id="guess">
|
||||
<input type="submit" id="submitGuess" value="Check My Guess">
|
||||
</form>
|
||||
|
||||
<p id="feedback"></p>
|
||||
|
||||
<script>
|
||||
const randomNumber = Math.floor(Math.random() * 100) + 1
|
||||
console.log('Random Number', randomNumber)
|
||||
|
||||
function checkGuess() {
|
||||
let myGuess = guess.value
|
||||
if (myGuess === randomNumber) {
|
||||
feedback.textContent = "You got it right!"
|
||||
} else if (myGuess > randomNumber) {
|
||||
feedback.textContent = "Your guess was " + myGuess + ". That's too high. Try Again!"
|
||||
} else if (myGuess < randomNumber) {
|
||||
feedback.textContent = "Your guess was " + myGuess + ". That's too low. Try Again!"
|
||||
}
|
||||
}
|
||||
submitGuess.addEventListener('click', checkGuess)
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
```
|
||||
|
||||
要在浏览器中运行此文件,请双击文件或打开你喜欢的浏览器,点击菜单,然后选择**文件->打开文件**。(如果使用 Brackets 软件,也可以使用角落处的闪电图标在浏览器中打开文件)。
|
||||
|
||||
### 生成伪随机数
|
||||
|
||||
猜谜游戏的第一步是为玩家生成一个数字供玩家猜测。JavaScript 包含几个内置的全局对象,可帮助你编写代码。要生成随机数,请使用 `Math` 对象。
|
||||
|
||||
JavaScript中的 [Math][17] 具有处理和数学相关的属性和功能。你将使用两个数学函数来生成随机数,供你的玩家猜测。
|
||||
|
||||
[Math.random()][18],会将生成一个介于 0 和 1 之间的伪随机数。(`Math.random` 包含 0 但不包含 1。这意味着该函数可以生成 0 ,永远不会产生 1)
|
||||
|
||||
对于此游戏,请将随机数设置在 1 到 100 之间以缩小玩家的选择范围。取刚刚生成的小数,然后乘以 100,以产生一个介于 0 到……甚至不是 100 之间的小数。至此,你将需要其他步骤来解决这个问题。
|
||||
|
||||
现在,你的数字仍然是小数,但你希望它是一个整数。为此,你可以使用属于 `Math` 对象的另一个函数 [Math.floor()][19]。`Math.floor()` 的目的是返回小于或等于你作为参数指定的数字的最大整数,这意味着它会四舍五入为最接近的整数:
|
||||
|
||||
```
|
||||
Math.floor(Math.random() * 100)
|
||||
```
|
||||
|
||||
这样你将得到 0 到 99 之间的整数,这不是你想要的范围。你可以在最后一步修复该问题,即在结果中加 1。瞧!现在,你有一个(有点)随机生成的数字,介于 1 到 100 之间:
|
||||
|
||||
```
|
||||
Math.floor(Math.random() * 100) + 1
|
||||
```
|
||||
|
||||
### 变量
|
||||
|
||||
现在,你需要存储随机生成的数字,以便可以将其与玩家的猜测进行比较。为此,你可以将其存储到一个 **变量**。
|
||||
|
||||
JavaScript 具有不同类型的变量,你可以选择这些类型,具体取决于你要如何使用该变量。对于此游戏,请使用 `const` 和 `let`。
|
||||
|
||||
* `let` 用于指示变量在整个程序中可以改变。
|
||||
* `const` 用于指示变量不应该被修改。
|
||||
|
||||
`const` 和 `let` 还有很多要说的,但现在知道这些就足够了。
|
||||
|
||||
随机数在游戏中仅生成一次,因此你将使用 `const` 变量来保存该值。你想给变量起一个清楚地表明要存储什么值的名称,因此将其命名为 `randomNumber`:
|
||||
|
||||
```
|
||||
const randomNumber
|
||||
```
|
||||
|
||||
有关命名的注意事项:JavaScript 中的变量和函数名称以驼峰形式编写。如果只有一个单词,则全部以小写形式书写。如果有多个单词,则第一个单词均为小写,其他任何单词均以大写字母开头,且单词之间没有空格。
|
||||
|
||||
### 打印到控制台
|
||||
|
||||
通常,你不想向任何人显示随机数,但是开发人员可能想知道生成的数字以使用它来帮助调试代码。 使用 JavaScript,你可以使用另一个内置函数 [console.log()][20] 将数字输出到浏览器的控制台。
|
||||
|
||||
大多数浏览器都包含开发人员工具,你可以通过按键盘上的 `F12` 键来打开它们。从那里,你应该看到一个 **控制台** 标签。打印到控制台的所有信息都将显示在此处。由于到目前为止编写的代码将在浏览器加载后立即运行,因此,如果你查看控制台,你应该会看到刚刚生成的随机数!
|
||||
|
||||
![Javascript game with console][21]
|
||||
|
||||
### 函数
|
||||
|
||||
接下来,你需要一种方法来从数字输入字段中获得玩家的猜测,将其与你刚刚生成的随机数进行比较,并向玩家提供反馈,让他们知道他们是否正确猜到了。为此,编写一个函数。 **函数** 是执行一定任务的代码块。函数是可以重用的,这意味着如果你需要多次运行相同的代码,则可以调用函数,而不必重写执行任务所需的所有步骤。
|
||||
|
||||
根据你使用的 JavaScript 版本,有许多不同的方法来编写或声明函数。由于这是该语言的基础入门,因此请使用基本函数语法声明函数。
|
||||
|
||||
以关键字 `function` 开头,然后起一个函数名。好的做法是使用一个描述该函数的功能的名称。在这个例子中,你正在检查玩家的猜测的数,因此此函数的名字可以是 `checkGuess`。在函数名称之后,写上一组小括号,然后写上一组花括号。 你将在以下花括号之间编写函数的主体:
|
||||
|
||||
```
|
||||
function checkGuess() {}
|
||||
```
|
||||
|
||||
### 使用 DOM
|
||||
|
||||
JavaScript 的目的之一是与网页上的 HTML 交互。它通过文档对象模型(DOM)进行此操作,DOM 是 JavaScript 用于访问和更改网页信息的对象。现在,你需要从 HTML 中获取数字输入字段中玩家的猜测。你可以使用分配给 HTML 元素的 `id` 属性(在这种情况下为 `guess`)来做到这一点:
|
||||
|
||||
```
|
||||
<input type="number" id="guess">
|
||||
```
|
||||
|
||||
JavaScript 可以通过访问玩家输入到数字输入字段中的数来获取其值。你可以通过引用元素的 ID 并在末尾添加 `.value` 来实现。这次,使用 `let` 定义的变量来保存用户的猜测值:
|
||||
|
||||
```
|
||||
let myGuess = guess.value
|
||||
```
|
||||
|
||||
玩家在数字输入字段中输入的任何数字都将被分配给 `checkGuess` 函数中的 `myGuess` 变量。
|
||||
|
||||
### 条件语句
|
||||
|
||||
下一步是将玩家的猜测与游戏产生的随机数进行比较。你还想给玩家反馈,让他们知道他们的猜测是太高,太低还是正确。
|
||||
|
||||
你可以使用一系列条件语句来决定玩家将收到的反馈。**条件语句** 在运行代码块之前检查是否满足条件。如果不满足条件,则代码停止,继续检查下一个条件,或者继续执行其余代码,而无需执行条件块中的代码:
|
||||
|
||||
```
|
||||
if (myGuess === randomNumber){
|
||||
feedback.textContent = "You got it right!"
|
||||
}
|
||||
else if(myGuess > randomNumber) {
|
||||
feedback.textContent = "Your guess was " + myGuess + ". That's too high. Try Again!"
|
||||
}
|
||||
else if(myGuess < randomNumber) {
|
||||
feedback.textContent = "Your guess was " + myGuess + ". That's too low. Try Again!"
|
||||
}
|
||||
```
|
||||
|
||||
第一个条件块使用比较运算符 `===` 将玩家的猜测与游戏生成的随机数进行比较。比较运算符检查右侧的值,将其与左侧的值进行比较,如果匹配则返回布尔值 `true`,否则返回布尔值 `false`。
|
||||
|
||||
如果数字匹配(猜对了!),为了让玩家知道。通过将文本添加到具有 `id` 属性 `feedback` 的 `<p>` 标记中来操作 DOM。就像上面的 `guess.value` 一样,除了不是从 DOM 获取信息,而是更改其中的信息。`<p>` 元素没有像 `<input>` 元素那样的值,而是具有文本,因此请使用 `.textContent` 访问元素并设置要显示的文本:
|
||||
|
||||
```
|
||||
feedback.textContent = "You got it right!"
|
||||
```
|
||||
|
||||
当然,玩家很有可能在第一次尝试时就猜错了,因此,如果 `myGuess` 和 `randomNumber` 不匹配,请给玩家一个线索,以帮助他们缩小猜测范围。如果第一个条件失败,则代码将跳过该 `if` 语句中的代码块,并检查下一个条件是否为 `true`。 这使你进入 `else if` 块:
|
||||
|
||||
```
|
||||
else if(myGuess > randomNumber) {
|
||||
feedback.textContent = "Your guess was " + myGuess + ". That's too high. Try Again!"
|
||||
}
|
||||
```
|
||||
|
||||
如果你将其作为句子阅读,则可能是这样的:“如果玩家的猜测等于随机数,请让他们知道他们猜对了。否则,请检查玩家的猜测是否大于 `randomNumber`,如果是,则显示玩家的猜测并告诉他们太高了。”
|
||||
|
||||
最后一种可能性是玩家的猜测低于随机数。 要检查这一点,再添加一个 `else if` 块:
|
||||
|
||||
```
|
||||
else if(myGuess < randomNumber) {
|
||||
feedback.textContent = "Your guess was " + myGuess + ". That's too low. Try Again!"
|
||||
}
|
||||
```
|
||||
|
||||
### 用户事件和事件监听器
|
||||
|
||||
如果你看上面的代码,则会看到某些代码在页面加载时自动运行,但有些则不会。你想在玩游戏之前生成随机数,但是你不想在玩家将数字输入到数字输入字段并准备检查它之前检查其猜测。
|
||||
|
||||
生成随机数并将其打印到控制台的代码不在函数的范围内,因此它将在浏览器加载脚本时自动运行。 但是,要使函数内部的代码运行,你必须对其进行调用。
|
||||
|
||||
调用函数有几种方法。在此,你希望该函数在用户单击 “Check My Guess” 按钮时运行。单击按钮将创建一个用户事件,然后 JavaScript 可以 “监听” 这个事件,以便知道何时需要运行函数。
|
||||
|
||||
代码的最后一行将事件侦听器添加到按钮上,以在单击按钮时调用函数。当它“听到”该事件时,它将运行分配给事件侦听器的函数:
|
||||
|
||||
```
|
||||
submitGuess.addEventListener('click', checkGuess)
|
||||
```
|
||||
|
||||
就像访问 DOM 元素的其他实例一样,你可以使用按钮的 ID 告诉 JavaScript 与哪个元素进行交互。 然后,你可以使用内置的 `addEventListener` 函数来告诉 JavaScript 要监听的事件。
|
||||
|
||||
你已经看到了带有参数的函数,但花点时间看一下它是如何工作的。参数是函数执行其任务所需的信息。并非所有函数都需要参数,但是 `addEventListener` 函数需要两个参数。它采用的第一个参数是将为其监听的用户事件的名称。用户可以通过多种方式与 DOM 交互,例如键入、移动鼠标,键盘上的 `TAB` 键和粘贴文本。在这种情况下,你正在监听的用户事件是单击按钮,因此第一个参数将是 `click`。
|
||||
|
||||
`addEventListener`的第二个所需的信息是用户单击按钮时要运行的函数的名称。 这里我们需要 `checkGuess` 函数。
|
||||
|
||||
现在,当玩家按下 “Check My Guess” 按钮时,`checkGuess` 函数将获得他们在数字输入字段中输入的值,将其与随机数进行比较,并在浏览器中显示反馈,以使玩家知道他们猜的怎么样。 太棒了!你的游戏已准备就绪。
|
||||
|
||||
### 学习 JavaScript 以获取乐趣和收益
|
||||
|
||||
这一点点的平凡无奇的 JavaScript 只是这个庞大的生态系统所提供功能的一小部分。这是一种值得花时间投入学习的语言,我鼓励你继续挖掘并学习更多。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/learn-javascript
|
||||
|
||||
作者:[Mandy Kendall][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/mkendall
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_javascript.jpg?itok=60evKmGl "Javascript code close-up with neon graphic overlay"
|
||||
[2]: https://opensource.com/tags/javascript
|
||||
[3]: https://opensource.com/article/20/11/reactjs-tutorial
|
||||
[4]: https://opensource.com/article/18/9/open-source-javascript-chart-libraries
|
||||
[5]: https://opensource.com/article/20/12/brackets
|
||||
[6]: http://december.com/html/4/element/html.html
|
||||
[7]: http://december.com/html/4/element/head.html
|
||||
[8]: http://december.com/html/4/element/meta.html
|
||||
[9]: http://december.com/html/4/element/title.html
|
||||
[10]: http://december.com/html/4/element/body.html
|
||||
[11]: http://december.com/html/4/element/h1.html
|
||||
[12]: http://december.com/html/4/element/p.html
|
||||
[13]: http://december.com/html/4/element/label.html
|
||||
[14]: http://december.com/html/4/element/input.html
|
||||
[15]: http://december.com/html/4/element/form.html
|
||||
[16]: http://december.com/html/4/element/script.html
|
||||
[17]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math
|
||||
[18]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
|
||||
[19]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor
|
||||
[20]: https://developer.mozilla.org/en-US/docs/Web/API/Console/log
|
||||
[21]: https://opensource.com/sites/default/files/javascript-game-with-console.png "Javascript game with console"
|
@ -0,0 +1,70 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13077-1.html)
|
||||
[#]: subject: (How Nextcloud is the ultimate open source productivity suite)
|
||||
[#]: via: (https://opensource.com/article/21/1/nextcloud-productivity)
|
||||
[#]: author: (Kevin Sonney https://opensource.com/users/ksonney)
|
||||
|
||||
Nextcloud 是如何成为终极开源生产力套件的
|
||||
======
|
||||
|
||||
> Nextcloud 可以取代你用于协作、组织和任务管理的许多在线应用。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/02/121553uhl3pjljjkhj0h8p.jpg)
|
||||
|
||||
在前几年,这个年度系列涵盖了单个的应用。今年,我们除了关注 2021 年的策略外,还将关注一体化解决方案。欢迎来到 2021 年 21 天生产力的第十一天。
|
||||
|
||||
基于 Web 的服务几乎可以在任何地方访问你的数据,它们每小时可以支持数百万用户。不过对于我们中的一些人来说,由于各种原因,运行自己的服务比使用大公司的服务更可取。也许我们的工作是受监管的或有明确安全要求。也许我们有隐私方面的考虑,或者只是喜欢能够自己构建、运行和修复事物。不管是什么情况,[Nextcloud][2] 都可以提供你所需要的大部分服务,但是是在你自己的硬件上。
|
||||
|
||||
![NextCloud Dashboard displaying service options][3]
|
||||
|
||||
*Nextcloud 控制面板(Kevin Sonney, [CC BY-SA 4.0][4])*
|
||||
|
||||
大多数时候,当我们想到 Nextcloud 时,我们会想到文件共享和同步,类似于 Dropbox、OneDrive 和 Google Drive 等商业产品。然而,如今,它是一个完整的生产力套件,拥有电子邮件客户端、日历、任务和笔记本。
|
||||
|
||||
有几种方法可以安装和运行 Nextcloud。你可以把它安装到裸机服务器上、在 Docker 容器中运行,或者作为虚拟机运行。如果可以考虑,还有一些托管服务将为你运行 Nextcloud。最后,有适用于所有主流操作系统的应用,包括移动应用,以便随时访问。
|
||||
|
||||
![Nextcloud virtual machine][5]
|
||||
|
||||
*Nextcloud 虚拟机(Kevin Sonney, [CC BY-SA 4.0][4])*
|
||||
|
||||
默认情况下,Nextcloud 会安装文件共享和其他一些相关应用(或附加组件)。你可以在管理界面中找到“应用”页面,这里允许你安装单个附加组件和一些预定义的相关应用捆绑。对我而言,我选择了 “Groupware Bundle”,其中包括“邮件”、“日历”、“联系人”和 “Deck”。“Deck” 是一个轻量级的看板,用于处理任务。我也安装了“记事本”和“任务”应用。
|
||||
|
||||
Nextcloud “邮件” 是一个非常直白的 IMAP 邮件客户端。虽然 Nextcloud 没有将 IMAP 或 SMTP 服务器作为软件包的一部分,但你可以很容易地在操作系统中添加一个或使用远程服务。“日历”应用是相当标准的,也允许你订阅远程日历。有一个缺点是,远程日历(例如,来自大型云提供商)是只读的,所以你可以查看但不能修改它们。
|
||||
|
||||
![NextCoud App Interface][6]
|
||||
|
||||
*Nextcloud 应用界面 (Kevin Sonney, [CC BY-SA 4.0][4])*
|
||||
|
||||
“记事本” 是一个简单的文本记事本,允许你创建和更新简短的笔记、日记和相关的东西。“任务” 是一款待办事项应用,支持多个列表、任务优先级、完成百分比以及其他一些用户期待的标准功能。如果你安装了 “Deck”,它的任务卡也会被列出来。每个看板都会显示自己的列表,所以你可以使用 “Deck” 或 “任务” 来跟踪完成的内容。
|
||||
|
||||
“Deck” 本身就是一个看板应用,将任务以卡片的形式呈现在流程中。如果你喜欢看板流程,它是一个追踪进度的优秀应用。
|
||||
|
||||
![Taking notes][7]
|
||||
|
||||
*做笔记 (Kevin Sonney, [CC BY-SA 4.0][4])*
|
||||
|
||||
Nextcloud 中所有的应用都原生支持通过标准协议进行共享。与一些类似的解决方案不同,它的分享并不是为了完成功能列表中的一项而加上去的。分享是 Nextcloud 存在的主要原因之一,所以使用起来非常简单。你还可以将链接分享到社交媒体、通过电子邮件分享等。你可以用一个 Nextcloud 取代多个在线服务,它在任何地方都可以访问,以协作为先。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/nextcloud-productivity
|
||||
|
||||
作者:[Kevin Sonney][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/ksonney
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/team_dev_email_chat_video_work_wfm_desk_520.png?itok=6YtME4Hj (Working on a team, busy worklife)
|
||||
[2]: https://nextcloud.com/
|
||||
[3]: https://opensource.com/sites/default/files/day11-image1_0.png
|
||||
[4]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[5]: https://opensource.com/sites/default/files/pictures/nextcloud-vm.png (Nextcloud virtual machine)
|
||||
[6]: https://opensource.com/sites/default/files/pictures/nextcloud-app-interface.png (NextCoud App Interface)
|
||||
[7]: https://opensource.com/sites/default/files/day11-image3.png (Taking notes in Nextcloud)
|
@ -0,0 +1,60 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13073-1.html)
|
||||
[#]: subject: (3 tips for automating your email filters)
|
||||
[#]: via: (https://opensource.com/article/21/1/email-filter)
|
||||
[#]: author: (Kevin Sonney https://opensource.com/users/ksonney)
|
||||
|
||||
3 个自动化电子邮件过滤器的技巧
|
||||
======
|
||||
|
||||
> 通过这些简单的建议,减少你的电子邮件并让你的生活更轻松。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/01/103638ozdejmy6eycm6omx.jpg)
|
||||
|
||||
在前几年,这个年度系列涵盖了单个的应用。今年,我们除了关注 2021 年的策略外,还将关注一体化解决方案。欢迎来到 2021 年 21 天生产力的第十二天。
|
||||
|
||||
如果有一件事是我喜欢的,那就是自动化。只要有机会,我就会把小任务进行自动化。早起打开鸡舍的门?我买了一扇门,可以在日出和日落时开门和关门。每天从早到晚实时监控鸡群?用 Node-RED 和 [OBS-Websockets][2] 稍微花点时间,就能搞定。
|
||||
|
||||
我们还有电子邮件。几天前,我写过关于处理邮件的文章,也写过关于标签和文件夹的文章。只要做一点前期的工作,你就可以在邮件进来的时候,你就可以自动摆脱掉大量管理邮件的开销。
|
||||
|
||||
![Author has 480 filters][3]
|
||||
|
||||
*是的,我有很多过滤器。(Kevin Sonney, [CC BY-SA 4.0][4])*
|
||||
|
||||
有两种主要方式来过滤你的电子邮件:在服务端或者客户端上。我更喜欢在服务端上做,因为我不断地在尝试新的和不同的电子邮件客户端。(不,真的,我光这个星期就已经使用了五个不同的客户端。我可能有问题。)
|
||||
|
||||
无论哪种方式,我都喜欢用电子邮件过滤规则做几件事,以使我的电子邮件更容易浏览,并保持我的收件箱不混乱。
|
||||
|
||||
1. 将不紧急的邮件移到“稍后阅读”文件夹中。对我而言,这包括来自社交网络、新闻简报和邮件列表的通知。
|
||||
2. 按列表或主题给消息贴上标签。我属于几个组织,虽然它们经常会被放在“稍后阅读”文件夹中,但我会添加第二个或第三个标签,以说明该来源或项目的内容,以帮助搜索时找到相关的东西。
|
||||
3. 不要把规则搞得太复杂。这个想法让我困难了一段时间。我想把邮件发送到某个文件夹的所有可能情况都加到一个规则里。如果有什么问题或需要添加或删除的东西,有一个大规则只是让它更难修复。
|
||||
|
||||
![Unsubscribe from email][5]
|
||||
|
||||
*点击它,点击它就行!(Kevin Sonney, [CC BY-SA 4.0][4])*
|
||||
|
||||
说了这么多,还有一件事我一直在做,它有助于减少我花在电子邮件上的时间:退订邮件。两年前我感兴趣的那个邮件列表已经不感兴趣了,所以就不订阅了。产品更新通讯是我去年停止使用的商品?退订!这一直在积极解放我。我每年都会试着评估几次列表中的邮件信息是否(仍然)有用。
|
||||
|
||||
过滤器和规则可以是非常强大的工具,让你的电子邮件保持集中,减少花在它们身上的时间。而点击取消订阅按钮是一种解放。试试就知道了!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/email-filter
|
||||
|
||||
作者:[Kevin Sonney][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/ksonney
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/innovation_lightbulb_gears_devops_ansible.png?itok=TSbmp3_M (gears and lightbulb to represent innovation)
|
||||
[2]: https://opensource.com/article/20/6/obs-websockets-streaming
|
||||
[3]: https://opensource.com/sites/default/files/day12-image1_0.png
|
||||
[4]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[5]: https://opensource.com/sites/default/files/day12-image2_0.png
|
@ -0,0 +1,635 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13074-1.html)
|
||||
[#]: subject: (Explore binaries using this full-featured Linux tool)
|
||||
[#]: via: (https://opensource.com/article/21/1/linux-radare2)
|
||||
[#]: author: (Gaurav Kamathe https://opensource.com/users/gkamathe)
|
||||
|
||||
全功能的二进制文件分析工具 Radare2 指南
|
||||
======
|
||||
|
||||
> Radare2 是一个为二进制分析定制的开源工具。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/01/112611baw4gpqlch10ps1c.jpg)
|
||||
|
||||
在《[Linux 上分析二进制文件的 10 种方法][2]》中,我解释了如何使用 Linux 上丰富的原生工具集来分析二进制文件。但如果你想进一步探索你的二进制文件,你需要一个为二进制分析定制的工具。如果你是二进制分析的新手,并且大多使用的是脚本语言,这篇文章《[GNU binutils 里的九种武器][3]》可以帮助你开始学习编译过程和什么是二进制。
|
||||
|
||||
### 为什么我需要另一个工具?
|
||||
|
||||
如果现有的 Linux 原生工具也能做类似的事情,你自然会问为什么需要另一个工具。嗯,这和你用手机做闹钟、做笔记、做相机、听音乐、上网、偶尔打电话和接电话的原因是一样的。以前,使用单独的设备和工具处理这些功能 —— 比如拍照的实体相机,记笔记的小记事本,起床的床头闹钟等等。对用户来说,有一个设备来做多件(但相关的)事情是*方便的*。另外,杀手锏就是独立功能之间的*互操作性*。
|
||||
|
||||
同样,即使许多 Linux 工具都有特定的用途,但在一个工具中捆绑类似(和更好)的功能是非常有用的。这就是为什么我认为 [Radare2][4] 应该是你需要处理二进制文件时的首选工具。
|
||||
|
||||
根据其 [GitHub 简介][5],Radare2(也称为 r2)是一个“类 Unix 系统上的逆向工程框架和命令行工具集”。它名字中的 “2” 是因为这个版本从头开始重写的,使其更加模块化。
|
||||
|
||||
### 为什么选择 Radare2?
|
||||
|
||||
有大量(非原生的)Linux 工具可用于二进制分析,为什么要选择 Radare2 呢?我的理由很简单。
|
||||
|
||||
首先,它是一个开源项目,有一个活跃而健康的社区。如果你正在寻找新颖的功能或提供着 bug 修复的工具,这很重要。
|
||||
|
||||
其次,Radare2 可以在命令行上使用,而且它有一个功能丰富的图形用户界面(GUI)环境,叫做 Cutter,适合那些对 GUI 比较熟悉的人。作为一个长期使用 Linux 的用户,我对习惯于在 shell 上输入。虽然熟悉 Radare2 的命令稍微有一点学习曲线,但我会把它比作 [学习 Vim][6]。你可以先学习基本的东西,一旦你掌握了它们,你就可以继续学习更高级的东西。很快,它就变成了肌肉记忆。
|
||||
|
||||
第三,Radare2 通过插件可以很好的支持外部工具。例如,最近开源的 [Ghidra][7] 二进制分析和<ruby>逆向工具<rt>reversing tool</rt></ruby>很受欢迎,因为它的反编译器功能是逆向软件的关键要素。你可以直接从 Radare2 控制台安装 Ghidra 反编译器并使用,这很神奇,让你两全其美。
|
||||
|
||||
### 开始使用 Radare2
|
||||
|
||||
要安装 Radare2,只需克隆其存储库并运行 `user.sh` 脚本。如果你的系统上还没有一些预备软件包,你可能需要安装它们。一旦安装完成,运行 `r2 -v` 命令来查看 Radare2 是否被正确安装:
|
||||
|
||||
```
|
||||
$ git clone https://github.com/radareorg/radare2.git
|
||||
$ cd radare2
|
||||
$ ./sys/user.sh
|
||||
|
||||
# version
|
||||
|
||||
$ r2 -v
|
||||
radare2 4.6.0-git 25266 @ linux-x86-64 git.4.4.0-930-g48047b317
|
||||
commit: 48047b3171e6ed0480a71a04c3693a0650d03543 build: 2020-11-17__09:31:03
|
||||
$
|
||||
```
|
||||
|
||||
#### 获取二进制测试样本
|
||||
|
||||
现在 `r2` 已经安装好了,你需要一个样本二进制程序来试用它。你可以使用任何系统二进制文件(`ls`、`bash` 等),但为了使本教程的内容简单,请编译以下 C 程序:
|
||||
|
||||
```
|
||||
$ cat adder.c
|
||||
```
|
||||
|
||||
```
|
||||
#include <stdio.h>
|
||||
|
||||
int adder(int num) {
|
||||
return num + 1;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int res, num1 = 100;
|
||||
res = adder(num1);
|
||||
printf("Number now is : %d\n", res);
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
$ gcc adder.c -o adder
|
||||
$ file adder
|
||||
adder: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=9d4366f7160e1ffb46b14466e8e0d70f10de2240, not stripped
|
||||
$ ./adder
|
||||
Number now is : 101
|
||||
```
|
||||
|
||||
#### 加载二进制文件
|
||||
|
||||
要分析二进制文件,你必须在 Radare2 中加载它。通过提供文件名作为 `r2` 命令的一个命令行参数来加载它。你会进入一个独立的 Radare2 控制台,这与你的 shell 不同。要退出控制台,你可以输入 `Quit` 或 `Exit` 或按 `Ctrl+D`:
|
||||
|
||||
```
|
||||
$ r2 ./adder
|
||||
-- Learn pancake as if you were radare!
|
||||
[0x004004b0]> quit
|
||||
$
|
||||
```
|
||||
|
||||
#### 分析二进制
|
||||
|
||||
在你探索二进制之前,你必须让 `r2` 为你分析它。你可以通过在 `r2` 控制台中运行 `aaa` 命令来实现:
|
||||
|
||||
```
|
||||
$ r2 ./adder
|
||||
-- Sorry, radare2 has experienced an internal error.
|
||||
[0x004004b0]>
|
||||
[0x004004b0]>
|
||||
[0x004004b0]> aaa
|
||||
[x] Analyze all flags starting with sym. and entry0 (aa)
|
||||
[x] Analyze function calls (aac)
|
||||
[x] Analyze len bytes of instructions for references (aar)
|
||||
[x] Check for vtables
|
||||
[x] Type matching analysis for all functions (aaft)
|
||||
[x] Propagate noreturn information
|
||||
[x] Use -AA or aaaa to perform additional experimental analysis.
|
||||
[0x004004b0]>
|
||||
```
|
||||
|
||||
这意味着每次你选择一个二进制文件进行分析时,你必须在加载二进制文件后输入一个额外的命令 `aaa`。你可以绕过这一点,在命令后面跟上 `-A` 来调用 `r2`;这将告诉 `r2` 为你自动分析二进制:
|
||||
|
||||
```
|
||||
$ r2 -A ./adder
|
||||
[x] Analyze all flags starting with sym. and entry0 (aa)
|
||||
[x] Analyze function calls (aac)
|
||||
[x] Analyze len bytes of instructions for references (aar)
|
||||
[x] Check for vtables
|
||||
[x] Type matching analysis for all functions (aaft)
|
||||
[x] Propagate noreturn information
|
||||
[x] Use -AA or aaaa to perform additional experimental analysis.
|
||||
-- Already up-to-date.
|
||||
[0x004004b0]>
|
||||
```
|
||||
|
||||
#### 获取一些关于二进制的基本信息
|
||||
|
||||
在开始分析一个二进制文件之前,你需要一些背景信息。在许多情况下,这可以是二进制文件的格式(ELF、PE 等)、二进制的架构(x86、AMD、ARM 等),以及二进制是 32 位还是 64 位。方便的 `r2` 的 `iI` 命令可以提供所需的信息:
|
||||
|
||||
```
|
||||
[0x004004b0]> iI
|
||||
arch x86
|
||||
baddr 0x400000
|
||||
binsz 14724
|
||||
bintype elf
|
||||
bits 64
|
||||
canary false
|
||||
class ELF64
|
||||
compiler GCC: (GNU) 8.3.1 20190507 (Red Hat 8.3.1-4)
|
||||
crypto false
|
||||
endian little
|
||||
havecode true
|
||||
intrp /lib64/ld-linux-x86-64.so.2
|
||||
laddr 0x0
|
||||
lang c
|
||||
linenum true
|
||||
lsyms true
|
||||
machine AMD x86-64 architecture
|
||||
maxopsz 16
|
||||
minopsz 1
|
||||
nx true
|
||||
os linux
|
||||
pcalign 0
|
||||
pic false
|
||||
relocs true
|
||||
relro partial
|
||||
rpath NONE
|
||||
sanitiz false
|
||||
static false
|
||||
stripped false
|
||||
subsys linux
|
||||
va true
|
||||
|
||||
[0x004004b0]>
|
||||
[0x004004b0]>
|
||||
```
|
||||
|
||||
### 导入和导出
|
||||
|
||||
通常情况下,当你知道你要处理的是什么样的文件后,你就想知道二进制程序使用了什么样的标准库函数,或者了解程序的潜在功能。在本教程中的示例 C 程序中,唯一的库函数是 `printf`,用来打印信息。你可以通过运行 `ii` 命令看到这一点,它显示了该二进制所有导入的库:
|
||||
|
||||
```
|
||||
[0x004004b0]> ii
|
||||
[Imports]
|
||||
nth vaddr bind type lib name
|
||||
―――――――――――――――――――――――――――――――――――――
|
||||
1 0x00000000 WEAK NOTYPE _ITM_deregisterTMCloneTable
|
||||
2 0x004004a0 GLOBAL FUNC printf
|
||||
3 0x00000000 GLOBAL FUNC __libc_start_main
|
||||
4 0x00000000 WEAK NOTYPE __gmon_start__
|
||||
5 0x00000000 WEAK NOTYPE _ITM_registerTMCloneTable
|
||||
```
|
||||
|
||||
该二进制也可以有自己的符号、函数或数据。这些函数通常显示在 `Exports` 下。这个测试的二进制导出了两个函数:`main` 和 `adder`。其余的函数是在编译阶段,当二进制文件被构建时添加的。加载器需要这些函数来加载二进制文件(现在不用太关心它们):
|
||||
|
||||
```
|
||||
[0x004004b0]>
|
||||
[0x004004b0]> iE
|
||||
[Exports]
|
||||
|
||||
nth paddr vaddr bind type size lib name
|
||||
――――――――――――――――――――――――――――――――――――――――――――――――――――――
|
||||
82 0x00000650 0x00400650 GLOBAL FUNC 5 __libc_csu_fini
|
||||
85 ---------- 0x00601024 GLOBAL NOTYPE 0 _edata
|
||||
86 0x00000658 0x00400658 GLOBAL FUNC 0 _fini
|
||||
89 0x00001020 0x00601020 GLOBAL NOTYPE 0 __data_start
|
||||
90 0x00000596 0x00400596 GLOBAL FUNC 15 adder
|
||||
92 0x00000670 0x00400670 GLOBAL OBJ 0 __dso_handle
|
||||
93 0x00000668 0x00400668 GLOBAL OBJ 4 _IO_stdin_used
|
||||
94 0x000005e0 0x004005e0 GLOBAL FUNC 101 __libc_csu_init
|
||||
95 ---------- 0x00601028 GLOBAL NOTYPE 0 _end
|
||||
96 0x000004e0 0x004004e0 GLOBAL FUNC 5 _dl_relocate_static_pie
|
||||
97 0x000004b0 0x004004b0 GLOBAL FUNC 47 _start
|
||||
98 ---------- 0x00601024 GLOBAL NOTYPE 0 __bss_start
|
||||
99 0x000005a5 0x004005a5 GLOBAL FUNC 55 main
|
||||
100 ---------- 0x00601028 GLOBAL OBJ 0 __TMC_END__
|
||||
102 0x00000468 0x00400468 GLOBAL FUNC 0 _init
|
||||
|
||||
[0x004004b0]>
|
||||
```
|
||||
|
||||
### 哈希信息
|
||||
|
||||
如何知道两个二进制文件是否相似?你不能只是打开一个二进制文件并查看里面的源代码。在大多数情况下,二进制文件的哈希值(md5sum、sha1、sha256)是用来唯一识别它的。你可以使用 `it` 命令找到二进制的哈希值:
|
||||
|
||||
```
|
||||
[0x004004b0]> it
|
||||
md5 7e6732f2b11dec4a0c7612852cede670
|
||||
sha1 d5fa848c4b53021f6570dd9b18d115595a2290ae
|
||||
sha256 13dd5a492219dac1443a816ef5f91db8d149e8edbf26f24539c220861769e1c2
|
||||
[0x004004b0]>
|
||||
```
|
||||
|
||||
### 函数
|
||||
|
||||
代码按函数分组;要列出二进制中存在的函数,请运行 `afl` 命令。下面的列表显示了 `main` 函数和 `adder` 函数。通常,以 `sym.imp` 开头的函数是从标准库(这里是 glibc)中导入的:
|
||||
|
||||
```
|
||||
[0x004004b0]> afl
|
||||
0x004004b0 1 46 entry0
|
||||
0x004004f0 4 41 -> 34 sym.deregister_tm_clones
|
||||
0x00400520 4 57 -> 51 sym.register_tm_clones
|
||||
0x00400560 3 33 -> 32 sym.__do_global_dtors_aux
|
||||
0x00400590 1 6 entry.init0
|
||||
0x00400650 1 5 sym.__libc_csu_fini
|
||||
0x00400658 1 13 sym._fini
|
||||
0x00400596 1 15 sym.adder
|
||||
0x004005e0 4 101 loc..annobin_elf_init.c
|
||||
0x004004e0 1 5 loc..annobin_static_reloc.c
|
||||
0x004005a5 1 55 main
|
||||
0x004004a0 1 6 sym.imp.printf
|
||||
0x00400468 3 27 sym._init
|
||||
[0x004004b0]>
|
||||
```
|
||||
|
||||
### 交叉引用
|
||||
|
||||
在 C 语言中,`main` 函数是一个程序开始执行的地方。理想情况下,其他函数都是从 `main` 函数调用的,在退出程序时,`main` 函数会向操作系统返回一个退出状态。这在源代码中是很明显的,然而,二进制程序呢?如何判断 `adder` 函数的调用位置呢?
|
||||
|
||||
你可以使用 `axt` 命令,后面加上函数名,看看 `adder` 函数是在哪里调用的;如下图所示,它是从 `main` 函数中调用的。这就是所谓的<ruby>交叉引用<rt>cross-referencing</rt></ruby>。但什么调用 `main` 函数本身呢?从下面的 `axt main` 可以看出,它是由 `entry0` 调用的(关于 `entry0` 的学习我就不说了,留待读者练习)。
|
||||
|
||||
```
|
||||
[0x004004b0]> axt sym.adder
|
||||
main 0x4005b9 [CALL] call sym.adder
|
||||
[0x004004b0]>
|
||||
[0x004004b0]> axt main
|
||||
entry0 0x4004d1 [DATA] mov rdi, main
|
||||
[0x004004b0]>
|
||||
```
|
||||
|
||||
### 寻找定位
|
||||
|
||||
在处理文本文件时,你经常通过引用行号和行或列号在文件内移动;在二进制文件中,你需要使用地址。这些是以 `0x` 开头的十六进制数字,后面跟着一个地址。要找到你在二进制中的位置,运行 `s` 命令。要移动到不同的位置,使用 `s` 命令,后面跟上地址。
|
||||
|
||||
函数名就像标签一样,内部用地址表示。如果函数名在二进制中(未剥离的),可以使用函数名后面的 `s` 命令跳转到一个特定的函数地址。同样,如果你想跳转到二进制的开始,输入 `s 0`:
|
||||
|
||||
```
|
||||
[0x004004b0]> s
|
||||
0x4004b0
|
||||
[0x004004b0]>
|
||||
[0x004004b0]> s main
|
||||
[0x004005a5]>
|
||||
[0x004005a5]> s
|
||||
0x4005a5
|
||||
[0x004005a5]>
|
||||
[0x004005a5]> s sym.adder
|
||||
[0x00400596]>
|
||||
[0x00400596]> s
|
||||
0x400596
|
||||
[0x00400596]>
|
||||
[0x00400596]> s 0
|
||||
[0x00000000]>
|
||||
[0x00000000]> s
|
||||
0x0
|
||||
[0x00000000]>
|
||||
```
|
||||
|
||||
### 十六进制视图
|
||||
|
||||
通常情况下,原始二进制没有意义。在十六进制模式下查看二进制及其等效的 ASCII 表示法会有帮助:
|
||||
|
||||
```
|
||||
[0x004004b0]> s main
|
||||
[0x004005a5]>
|
||||
[0x004005a5]> px
|
||||
- offset - 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF
|
||||
0x004005a5 5548 89e5 4883 ec10 c745 fc64 0000 008b UH..H....E.d....
|
||||
0x004005b5 45fc 89c7 e8d8 ffff ff89 45f8 8b45 f889 E.........E..E..
|
||||
0x004005c5 c6bf 7806 4000 b800 0000 00e8 cbfe ffff ..x.@...........
|
||||
0x004005d5 b800 0000 00c9 c30f 1f40 00f3 0f1e fa41 .........@.....A
|
||||
0x004005e5 5749 89d7 4156 4989 f641 5541 89fd 4154 WI..AVI..AUA..AT
|
||||
0x004005f5 4c8d 2504 0820 0055 488d 2d04 0820 0053 L.%.. .UH.-.. .S
|
||||
0x00400605 4c29 e548 83ec 08e8 57fe ffff 48c1 fd03 L).H....W...H...
|
||||
0x00400615 741f 31db 0f1f 8000 0000 004c 89fa 4c89 t.1........L..L.
|
||||
0x00400625 f644 89ef 41ff 14dc 4883 c301 4839 dd75 .D..A...H...H9.u
|
||||
0x00400635 ea48 83c4 085b 5d41 5c41 5d41 5e41 5fc3 .H...[]A\A]A^A_.
|
||||
0x00400645 9066 2e0f 1f84 0000 0000 00f3 0f1e fac3 .f..............
|
||||
0x00400655 0000 00f3 0f1e fa48 83ec 0848 83c4 08c3 .......H...H....
|
||||
0x00400665 0000 0001 0002 0000 0000 0000 0000 0000 ................
|
||||
0x00400675 0000 004e 756d 6265 7220 6e6f 7720 6973 ...Number now is
|
||||
0x00400685 2020 3a20 2564 0a00 0000 0001 1b03 3b44 : %d........;D
|
||||
0x00400695 0000 0007 0000 0000 feff ff88 0000 0020 ...............
|
||||
[0x004005a5]>
|
||||
```
|
||||
|
||||
### 反汇编
|
||||
|
||||
如果你使用的是编译后的二进制文件,则无法查看源代码。编译器将源代码转译成 CPU 可以理解和执行的机器语言指令;其结果就是二进制或可执行文件。然而,你可以查看汇编指令(的助记词)来理解程序正在做什么。例如,如果你想查看 `main` 函数在做什么,你可以使用 `s main` 寻找 `main` 函数的地址,然后运行 `pdf` 命令来查看反汇编的指令。
|
||||
|
||||
要理解汇编指令,你需要参考体系结构手册(这里是 x86),它的应用二进制接口(ABI,或调用惯例),并对堆栈的工作原理有基本的了解:
|
||||
|
||||
```
|
||||
[0x004004b0]> s main
|
||||
[0x004005a5]>
|
||||
[0x004005a5]> s
|
||||
0x4005a5
|
||||
[0x004005a5]>
|
||||
[0x004005a5]> pdf
|
||||
; DATA XREF from entry0 @ 0x4004d1
|
||||
┌ 55: int main (int argc, char **argv, char **envp);
|
||||
│ ; var int64_t var_8h @ rbp-0x8
|
||||
│ ; var int64_t var_4h @ rbp-0x4
|
||||
│ 0x004005a5 55 push rbp
|
||||
│ 0x004005a6 4889e5 mov rbp, rsp
|
||||
│ 0x004005a9 4883ec10 sub rsp, 0x10
|
||||
│ 0x004005ad c745fc640000. mov dword [var_4h], 0x64 ; 'd' ; 100
|
||||
│ 0x004005b4 8b45fc mov eax, dword [var_4h]
|
||||
│ 0x004005b7 89c7 mov edi, eax
|
||||
│ 0x004005b9 e8d8ffffff call sym.adder
|
||||
│ 0x004005be 8945f8 mov dword [var_8h], eax
|
||||
│ 0x004005c1 8b45f8 mov eax, dword [var_8h]
|
||||
│ 0x004005c4 89c6 mov esi, eax
|
||||
│ 0x004005c6 bf78064000 mov edi, str.Number_now_is__:__d ; 0x400678 ; "Number now is : %d\n" ; const char *format
|
||||
│ 0x004005cb b800000000 mov eax, 0
|
||||
│ 0x004005d0 e8cbfeffff call sym.imp.printf ; int printf(const char *format)
|
||||
│ 0x004005d5 b800000000 mov eax, 0
|
||||
│ 0x004005da c9 leave
|
||||
└ 0x004005db c3 ret
|
||||
[0x004005a5]>
|
||||
```
|
||||
|
||||
这是 `adder` 函数的反汇编结果:
|
||||
|
||||
```
|
||||
[0x004005a5]> s sym.adder
|
||||
[0x00400596]>
|
||||
[0x00400596]> s
|
||||
0x400596
|
||||
[0x00400596]>
|
||||
[0x00400596]> pdf
|
||||
; CALL XREF from main @ 0x4005b9
|
||||
┌ 15: sym.adder (int64_t arg1);
|
||||
│ ; var int64_t var_4h @ rbp-0x4
|
||||
│ ; arg int64_t arg1 @ rdi
|
||||
│ 0x00400596 55 push rbp
|
||||
│ 0x00400597 4889e5 mov rbp, rsp
|
||||
│ 0x0040059a 897dfc mov dword [var_4h], edi ; arg1
|
||||
│ 0x0040059d 8b45fc mov eax, dword [var_4h]
|
||||
│ 0x004005a0 83c001 add eax, 1
|
||||
│ 0x004005a3 5d pop rbp
|
||||
└ 0x004005a4 c3 ret
|
||||
[0x00400596]>
|
||||
```
|
||||
|
||||
### 字符串
|
||||
|
||||
查看二进制中存在哪些字符串可以作为二进制分析的起点。字符串是硬编码到二进制中的,通常会提供重要的提示,可以让你将重点转移到分析某些区域。在二进制中运行 `iz` 命令来列出所有的字符串。这个测试二进制中只有一个硬编码的字符串:
|
||||
|
||||
```
|
||||
[0x004004b0]> iz
|
||||
[Strings]
|
||||
nth paddr vaddr len size section type string
|
||||
―――――――――――――――――――――――――――――――――――――――――――――――――――――――
|
||||
0 0x00000678 0x00400678 20 21 .rodata ascii Number now is : %d\n
|
||||
|
||||
[0x004004b0]>
|
||||
```
|
||||
|
||||
### 交叉引用字符串
|
||||
|
||||
和函数一样,你可以交叉引用字符串,看看它们是从哪里被打印出来的,并理解它们周围的代码:
|
||||
|
||||
```
|
||||
[0x004004b0]> ps @ 0x400678
|
||||
Number now is : %d
|
||||
|
||||
[0x004004b0]>
|
||||
[0x004004b0]> axt 0x400678
|
||||
main 0x4005c6 [DATA] mov edi, str.Number_now_is__:__d
|
||||
[0x004004b0]>
|
||||
```
|
||||
|
||||
### 可视模式
|
||||
|
||||
当你的代码很复杂,有多个函数被调用时,很容易迷失方向。如果能以图形或可视化的方式查看哪些函数被调用,根据某些条件采取了哪些路径等,会很有帮助。在移动到感兴趣的函数后,可以通过 `VV` 命令来探索 `r2` 的可视化模式。例如,对于 `adder` 函数:
|
||||
|
||||
```
|
||||
[0x004004b0]> s sym.adder
|
||||
[0x00400596]>
|
||||
[0x00400596]> VV
|
||||
```
|
||||
|
||||
![Radare2 Visual mode][8]
|
||||
|
||||
*(Gaurav Kamathe, [CC BY-SA 4.0][9])*
|
||||
|
||||
### 调试器
|
||||
|
||||
到目前为止,你一直在做的是静态分析 —— 你只是在看二进制文件中的东西,而没有运行它,有时你需要执行二进制文件,并在运行时分析内存中的各种信息。`r2` 的内部调试器允许你运行二进制文件、设置断点、分析变量的值、或者转储寄存器的内容。
|
||||
|
||||
用 `-d` 标志启动调试器,并在加载二进制时添加 `-A` 标志进行分析。你可以通过使用 `db <function-name>` 命令在不同的地方设置断点,比如函数或内存地址。要查看现有的断点,使用 `dbi` 命令。一旦你放置了断点,使用 `dc` 命令开始运行二进制文件。你可以使用 `dbt` 命令查看堆栈,它可以显示函数调用。最后,你可以使用 `drr` 命令转储寄存器的内容:
|
||||
|
||||
```
|
||||
$ r2 -d -A ./adder
|
||||
Process with PID 17453 started...
|
||||
= attach 17453 17453
|
||||
bin.baddr 0x00400000
|
||||
Using 0x400000
|
||||
asm.bits 64
|
||||
[x] Analyze all flags starting with sym. and entry0 (aa)
|
||||
[x] Analyze function calls (aac)
|
||||
[x] Analyze len bytes of instructions for references (aar)
|
||||
[x] Check for vtables
|
||||
[x] Type matching analysis for all functions (aaft)
|
||||
[x] Propagate noreturn information
|
||||
[x] Use -AA or aaaa to perform additional experimental analysis.
|
||||
-- git checkout hamster
|
||||
[0x7f77b0a28030]>
|
||||
[0x7f77b0a28030]> db main
|
||||
[0x7f77b0a28030]>
|
||||
[0x7f77b0a28030]> db sym.adder
|
||||
[0x7f77b0a28030]>
|
||||
[0x7f77b0a28030]> dbi
|
||||
0 0x004005a5 E:1 T:0
|
||||
1 0x00400596 E:1 T:0
|
||||
[0x7f77b0a28030]>
|
||||
[0x7f77b0a28030]> afl | grep main
|
||||
0x004005a5 1 55 main
|
||||
[0x7f77b0a28030]>
|
||||
[0x7f77b0a28030]> afl | grep sym.adder
|
||||
0x00400596 1 15 sym.adder
|
||||
[0x7f77b0a28030]>
|
||||
[0x7f77b0a28030]> dc
|
||||
hit breakpoint at: 0x4005a5
|
||||
[0x004005a5]>
|
||||
[0x004005a5]> dbt
|
||||
0 0x4005a5 sp: 0x0 0 [main] main sym.adder+15
|
||||
1 0x7f77b0687873 sp: 0x7ffe35ff6858 0 [??] section..gnu.build.attributes-1345820597
|
||||
2 0x7f77b0a36e0a sp: 0x7ffe35ff68e8 144 [??] map.usr_lib64_ld_2.28.so.r_x+65034
|
||||
[0x004005a5]> dc
|
||||
hit breakpoint at: 0x400596
|
||||
[0x00400596]> dbt
|
||||
0 0x400596 sp: 0x0 0 [sym.adder] rip entry.init0+6
|
||||
1 0x4005be sp: 0x7ffe35ff6838 0 [main] main+25
|
||||
2 0x7f77b0687873 sp: 0x7ffe35ff6858 32 [??] section..gnu.build.attributes-1345820597
|
||||
3 0x7f77b0a36e0a sp: 0x7ffe35ff68e8 144 [??] map.usr_lib64_ld_2.28.so.r_x+65034
|
||||
[0x00400596]>
|
||||
[0x00400596]>
|
||||
[0x00400596]> dr
|
||||
rax = 0x00000064
|
||||
rbx = 0x00000000
|
||||
rcx = 0x7f77b0a21738
|
||||
rdx = 0x7ffe35ff6948
|
||||
r8 = 0x7f77b0a22da0
|
||||
r9 = 0x7f77b0a22da0
|
||||
r10 = 0x0000000f
|
||||
r11 = 0x00000002
|
||||
r12 = 0x004004b0
|
||||
r13 = 0x7ffe35ff6930
|
||||
r14 = 0x00000000
|
||||
r15 = 0x00000000
|
||||
rsi = 0x7ffe35ff6938
|
||||
rdi = 0x00000064
|
||||
rsp = 0x7ffe35ff6838
|
||||
rbp = 0x7ffe35ff6850
|
||||
rip = 0x00400596
|
||||
rflags = 0x00000202
|
||||
orax = 0xffffffffffffffff
|
||||
[0x00400596]>
|
||||
```
|
||||
|
||||
### 反编译器
|
||||
|
||||
能够理解汇编是二进制分析的前提。汇编语言总是与二进制建立和预期运行的架构相关。一行源代码和汇编代码之间从来没有 1:1 的映射。通常,一行 C 源代码会产生多行汇编代码。所以,逐行读取汇编代码并不是最佳的选择。
|
||||
|
||||
这就是反编译器的作用。它们试图根据汇编指令重建可能的源代码。这与用于创建二进制的源代码绝不完全相同,它是基于汇编的源代码的近似表示。另外,要考虑到编译器进行的优化,它会生成不同的汇编代码以加快速度,减小二进制的大小等,会使反编译器的工作更加困难。另外,恶意软件作者经常故意混淆代码,让恶意软件的分析人员望而却步。
|
||||
|
||||
Radare2 通过插件提供反编译器。你可以安装任何 Radare2 支持的反编译器。使用 `r2pm -l` 命令可以查看当前插件。使用 `r2pm install` 命令来安装一个示例的反编译器 `r2dec`:
|
||||
|
||||
```
|
||||
$ r2pm -l
|
||||
$
|
||||
$ r2pm install r2dec
|
||||
Cloning into 'r2dec'...
|
||||
remote: Enumerating objects: 100, done.
|
||||
remote: Counting objects: 100% (100/100), done.
|
||||
remote: Compressing objects: 100% (97/97), done.
|
||||
remote: Total 100 (delta 18), reused 27 (delta 1), pack-reused 0
|
||||
Receiving objects: 100% (100/100), 1.01 MiB | 1.31 MiB/s, done.
|
||||
Resolving deltas: 100% (18/18), done.
|
||||
Install Done For r2dec
|
||||
gmake: Entering directory '/root/.local/share/radare2/r2pm/git/r2dec/p'
|
||||
[CC] duktape/duktape.o
|
||||
[CC] duktape/duk_console.o
|
||||
[CC] core_pdd.o
|
||||
[CC] core_pdd.so
|
||||
gmake: Leaving directory '/root/.local/share/radare2/r2pm/git/r2dec/p'
|
||||
$
|
||||
$ r2pm -l
|
||||
r2dec
|
||||
$
|
||||
```
|
||||
|
||||
### 反编译器视图
|
||||
|
||||
要反编译一个二进制文件,在 `r2` 中加载二进制文件并自动分析它。在本例中,使用 `s sym.adder` 命令移动到感兴趣的 `adder` 函数,然后使用 `pdda` 命令并排查看汇编和反编译后的源代码。阅读这个反编译后的源代码往往比逐行阅读汇编更容易:
|
||||
|
||||
```
|
||||
$ r2 -A ./adder
|
||||
[x] Analyze all flags starting with sym. and entry0 (aa)
|
||||
[x] Analyze function calls (aac)
|
||||
[x] Analyze len bytes of instructions for references (aar)
|
||||
[x] Check for vtables
|
||||
[x] Type matching analysis for all functions (aaft)
|
||||
[x] Propagate noreturn information
|
||||
[x] Use -AA or aaaa to perform additional experimental analysis.
|
||||
-- What do you want to debug today?
|
||||
[0x004004b0]>
|
||||
[0x004004b0]> s sym.adder
|
||||
[0x00400596]>
|
||||
[0x00400596]> s
|
||||
0x400596
|
||||
[0x00400596]>
|
||||
[0x00400596]> pdda
|
||||
; assembly | /* r2dec pseudo code output */
|
||||
| /* ./adder @ 0x400596 */
|
||||
| #include <stdint.h>
|
||||
|
|
||||
; (fcn) sym.adder () | int32_t adder (int64_t arg1) {
|
||||
| int64_t var_4h;
|
||||
| rdi = arg1;
|
||||
0x00400596 push rbp |
|
||||
0x00400597 mov rbp, rsp |
|
||||
0x0040059a mov dword [rbp - 4], edi | *((rbp - 4)) = edi;
|
||||
0x0040059d mov eax, dword [rbp - 4] | eax = *((rbp - 4));
|
||||
0x004005a0 add eax, 1 | eax++;
|
||||
0x004005a3 pop rbp |
|
||||
0x004005a4 ret | return eax;
|
||||
| }
|
||||
[0x00400596]>
|
||||
```
|
||||
|
||||
### 配置设置
|
||||
|
||||
随着你对 Radare2 的使用越来越熟悉,你会想改变它的配置,以适应你的工作方式。你可以使用 `e` 命令查看 `r2` 的默认配置。要设置一个特定的配置,在 `e` 命令后面添加 `config = value`:
|
||||
|
||||
```
|
||||
[0x004005a5]> e | wc -l
|
||||
593
|
||||
[0x004005a5]> e | grep syntax
|
||||
asm.syntax = intel
|
||||
[0x004005a5]>
|
||||
[0x004005a5]> e asm.syntax = att
|
||||
[0x004005a5]>
|
||||
[0x004005a5]> e | grep syntax
|
||||
asm.syntax = att
|
||||
[0x004005a5]>
|
||||
```
|
||||
|
||||
要使配置更改永久化,请将它们放在 `r2` 启动时读取的名为 `.radare2rc` 的启动文件中。这个文件通常在你的主目录下,如果没有,你可以创建一个。一些示例配置选项包括:
|
||||
|
||||
```
|
||||
$ cat ~/.radare2rc
|
||||
e asm.syntax = att
|
||||
e scr.utf8 = true
|
||||
eco solarized
|
||||
e cmd.stack = true
|
||||
e stack.size = 256
|
||||
$
|
||||
```
|
||||
|
||||
### 探索更多
|
||||
|
||||
你已经看到了足够多的 Radare2 功能,对这个工具有了一定的了解。因为 Radare2 遵循 Unix 哲学,即使你可以从它的主控台做各种事情,它也会在下面使用一套独立的二进制来完成它的任务。
|
||||
|
||||
探索下面列出的独立二进制文件,看看它们是如何工作的。例如,用 `iI` 命令在控制台看到的二进制信息也可以用 `rabin2 <binary>` 命令找到:
|
||||
|
||||
```
|
||||
$ cd bin/
|
||||
$
|
||||
$ ls
|
||||
prefix r2agent r2pm rabin2 radiff2 ragg2 rarun2 rasm2
|
||||
r2 r2-indent r2r radare2 rafind2 rahash2 rasign2 rax2
|
||||
$
|
||||
```
|
||||
|
||||
你觉得 Radare2 怎么样?请在评论中分享你的反馈。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/linux-radare2
|
||||
|
||||
作者:[Gaurav Kamathe][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[wxy](https://github.com/wxy)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/gkamathe
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/binary_code_computer_screen.png?itok=7IzHK1nn (Binary code on a computer screen)
|
||||
[2]: https://linux.cn/article-12187-1.html
|
||||
[3]: https://linux.cn/article-11441-1.html
|
||||
[4]: https://rada.re/n/
|
||||
[5]: https://github.com/radareorg/radare2
|
||||
[6]: https://opensource.com/article/19/3/getting-started-vim
|
||||
[7]: https://ghidra-sre.org/
|
||||
[8]: https://opensource.com/sites/default/files/uploads/radare2_visual-mode_0.png (Radare2 Visual mode)
|
||||
[9]: https://creativecommons.org/licenses/by-sa/4.0/
|
63
published/20210125 Use Joplin to find your notes faster.md
Normal file
63
published/20210125 Use Joplin to find your notes faster.md
Normal file
@ -0,0 +1,63 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13080-1.html)
|
||||
[#]: subject: (Use Joplin to find your notes faster)
|
||||
[#]: via: (https://opensource.com/article/21/1/notes-joplin)
|
||||
[#]: author: (Kevin Sonney https://opensource.com/users/ksonney)
|
||||
|
||||
使用 Joplin 更快地找到你的笔记
|
||||
======
|
||||
|
||||
> 在多个手写和数字平台上整理笔记是一个严峻的挑战。这里有一个小技巧,可以更好地组织你的笔记,并快速找到你需要的东西。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/03/120141dkiqil1vlqiz6wql.jpg)
|
||||
|
||||
在前几年,这个年度系列涵盖了单个的应用。今年,我们除了关注 2021 年的策略外,还将关注一体化解决方案。欢迎来到 2021 年 21 天生产力的第十五天。
|
||||
|
||||
保持生产力也意味着(在某种程度上)要有足够的组织能力,以便找到笔记并在需要时参考它们。这不仅是对我自己的挑战,也是与我交谈的很多人的挑战。
|
||||
|
||||
多年来,我在应用中单独或使用数字笔记、纸质笔记、便签、数字便签、Word 文档、纯文本文件以及一堆我忘记的其他格式的组合。这不仅让寻找笔记变得困难,而且知道把它们放在哪里是一个更大的挑战。
|
||||
|
||||
![Stacks of paper notes on a desk][2]
|
||||
|
||||
*一堆笔记 (Jessica Cherry, [CC BY-SA 4.0][3])*
|
||||
|
||||
还有就是做笔记最重要的一点:如果你以后找不到它,笔记就没有任何价值。知道含有你所需信息的笔记存在于你保存笔记的*某处*,根本没有任何帮助。
|
||||
|
||||
我是如何为自己解决这个问题的呢?正如他们所说,这是一个过程,我希望这也是一个对其他人有效的过程。
|
||||
|
||||
我首先看了看自己所做的笔记种类。不同的主题需要用不同的方式保存吗?由于我为我的播客手写笔记,而几乎所有其他的东西都使用纯文本笔记,我需要两种不同的方式来维护它们。对于手写的笔记,我把它们都放在一个文件夹里,方便我参考。
|
||||
|
||||
![Man holding a binder full of notes][4]
|
||||
|
||||
*三年多的笔记 (Kevin Sonney, [CC BY-SA 4.0][3])*
|
||||
|
||||
为了保存我的数字笔记,我需要将它们全部集中到一个地方。这个工具需要能够从多种设备上访问,具有有用的搜索功能,并且能够导出或共享我的笔记。在尝试了很多很多不同的选项之后,我选择了 [Joplin][5]。Joplin 可以让我用 Markdown 写笔记,有一个相当不错的搜索功能,有适用于所有操作系统(包括手机)的应用,并支持几种不同的设备同步方式。另外,它还有文件夹*和*标签,因此我可以按照对我有意义的方式将笔记分组。
|
||||
|
||||
![Organized Joplin notes management page][6]
|
||||
|
||||
*我的 Joplin*
|
||||
|
||||
我花了一些时间才把所有的东西都放在我想要的地方,但最后,这真的是值得的。现在,我可以找到我所做的笔记,而不是让它们散落在我的办公室、不同的机器和各种服务中。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/notes-joplin
|
||||
|
||||
作者:[Kevin Sonney][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/ksonney
|
||||
[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/sites/default/files/day15-image1.jpg
|
||||
[3]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[4]: https://opensource.com/sites/default/files/day15-image2.png
|
||||
[5]: https://joplinapp.org/
|
||||
[6]: https://opensource.com/sites/default/files/day15-image3.png
|
201
published/20210125 Why you need to drop ifconfig for ip.md
Normal file
201
published/20210125 Why you need to drop ifconfig for ip.md
Normal file
@ -0,0 +1,201 @@
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: "MjSeven"
|
||||
[#]: reviewer: "wxy"
|
||||
[#]: publisher: "wxy"
|
||||
[#]: url: "https://linux.cn/article-13089-1.html"
|
||||
[#]: subject: "Why you need to drop ifconfig for ip"
|
||||
[#]: via: "https://opensource.com/article/21/1/ifconfig-ip-linux"
|
||||
[#]: author: "Rajan Bhardwaj https://opensource.com/users/rajabhar"
|
||||
|
||||
放弃 ifconfig,拥抱 ip 命令
|
||||
======
|
||||
|
||||
> 开始使用现代方法配置 Linux 网络接口。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/05/233847lpg1lnz7kl2czgfj.jpg)
|
||||
|
||||
在很长一段时间内,`ifconfig` 命令是配置网络接口的默认方法。它为 Linux 用户提供了很好的服务,但是网络很复杂,所以配置网络的命令必须健壮。`ip` 命令是现代系统中新的默认网络命令,在本文中,我将向你展示如何使用它。
|
||||
|
||||
`ip` 命令工作在 [OSI 网络栈][2] 的两个层上:第二层(数据链路层)和第三层(网络 或 IP)层。它做了之前 `net-tools` 包的所有工作。
|
||||
|
||||
### 安装 ip
|
||||
|
||||
`ip` 命令包含在 `iproute2util` 包中,它可能已经在你的 Linux 发行版中安装了。如果没有,你可以从发行版的仓库中进行安装。
|
||||
|
||||
### ifconfig 和 ip 使用对比
|
||||
|
||||
`ip` 和 `ifconfig` 命令都可以用来配置网络接口,但它们做事方法不同。接下来,作为对比,我将用它们来执行一些常见的任务。
|
||||
|
||||
#### 查看网口和 IP 地址
|
||||
|
||||
如果你想查看主机的 IP 地址或网络接口信息,`ifconfig` (不带任何参数)命令提供了一个很好的总结。
|
||||
|
||||
```
|
||||
$ ifconfig
|
||||
|
||||
eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
|
||||
ether bc:ee:7b:5e:7d:d8 txqueuelen 1000 (Ethernet)
|
||||
RX packets 0 bytes 0 (0.0 B)
|
||||
RX errors 0 dropped 0 overruns 0 frame 0
|
||||
TX packets 0 bytes 0 (0.0 B)
|
||||
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
||||
|
||||
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
|
||||
inet 127.0.0.1 netmask 255.0.0.0
|
||||
inet6 ::1 prefixlen 128 scopeid 0x10<host>
|
||||
loop txqueuelen 1000 (Local Loopback)
|
||||
RX packets 41 bytes 5551 (5.4 KiB)
|
||||
RX errors 0 dropped 0 overruns 0 frame 0
|
||||
TX packets 41 bytes 5551 (5.4 KiB)
|
||||
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
||||
|
||||
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
|
||||
inet 10.1.1.6 netmask 255.255.255.224 broadcast 10.1.1.31
|
||||
inet6 fdb4:f58e:49f:4900:d46d:146b:b16:7212 prefixlen 64 scopeid 0x0<global>
|
||||
inet6 fe80::8eb3:4bc0:7cbb:59e8 prefixlen 64 scopeid 0x20<link>
|
||||
ether 08:71:90:81:1e:b5 txqueuelen 1000 (Ethernet)
|
||||
RX packets 569459 bytes 779147444 (743.0 MiB)
|
||||
RX errors 0 dropped 0 overruns 0 frame 0
|
||||
TX packets 302882 bytes 38131213 (36.3 MiB)
|
||||
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
||||
```
|
||||
|
||||
新的 `ip` 命令提供了类似的结果,但命令是 `ip address show`,或者简写为 `ip a`:
|
||||
|
||||
```
|
||||
$ ip a
|
||||
|
||||
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
|
||||
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
|
||||
inet 127.0.0.1/8 scope host lo
|
||||
valid_lft forever preferred_lft forever
|
||||
inet6 ::1/128 scope host
|
||||
valid_lft forever preferred_lft forever
|
||||
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
|
||||
link/ether bc:ee:7b:5e:7d:d8 brd ff:ff:ff:ff:ff:ff
|
||||
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
|
||||
link/ether 08:71:90:81:1e:b5 brd ff:ff:ff:ff:ff:ff
|
||||
inet 10.1.1.6/27 brd 10.1.1.31 scope global dynamic wlan0
|
||||
valid_lft 83490sec preferred_lft 83490sec
|
||||
inet6 fdb4:f58e:49f:4900:d46d:146b:b16:7212/64 scope global noprefixroute dynamic
|
||||
valid_lft 6909sec preferred_lft 3309sec
|
||||
inet6 fe80::8eb3:4bc0:7cbb:59e8/64 scope link
|
||||
valid_lft forever preferred_lft forever
|
||||
```
|
||||
|
||||
#### 添加 IP 地址
|
||||
|
||||
使用 `ifconfig` 命令添加 IP 地址命令为:
|
||||
|
||||
```
|
||||
$ ifconfig eth0 add 192.9.203.21
|
||||
```
|
||||
|
||||
`ip` 类似:
|
||||
|
||||
```
|
||||
$ ip address add 192.9.203.21 dev eth0
|
||||
```
|
||||
|
||||
`ip` 中的子命令可以缩短,所以下面这个命令同样有效:
|
||||
|
||||
```
|
||||
$ ip addr add 192.9.203.21 dev eth0
|
||||
```
|
||||
|
||||
你甚至可以更短些:
|
||||
|
||||
```
|
||||
$ ip a add 192.9.203.21 dev eth0
|
||||
```
|
||||
|
||||
#### 移除一个 IP 地址
|
||||
|
||||
添加 IP 地址与删除 IP 地址正好相反。
|
||||
|
||||
使用 `ifconfig`,命令是:
|
||||
|
||||
```
|
||||
$ ifconfig eth0 del 192.9.203.21
|
||||
```
|
||||
|
||||
`ip` 命令的语法是:
|
||||
|
||||
```
|
||||
$ ip a del 192.9.203.21 dev eth0
|
||||
```
|
||||
|
||||
#### 启用或禁用组播
|
||||
|
||||
使用 `ifconfig` 接口来启用或禁用 <ruby>[组播][3]<rt>multicast</rt></ruby>:
|
||||
|
||||
```
|
||||
# ifconfig eth0 multicast
|
||||
```
|
||||
|
||||
对于 `ip`,使用 `set` 子命令与设备(`dev`)以及一个布尔值和 `multicast` 选项:
|
||||
|
||||
```
|
||||
# ip link set dev eth0 multicast on
|
||||
```
|
||||
|
||||
#### 启用或禁用网络
|
||||
|
||||
每个系统管理员都熟悉“先关闭,然后打开”这个技巧来解决问题。对于网络接口来说,即打开或关闭网络。
|
||||
|
||||
`ifconfig` 命令使用 `up` 或 `down` 关键字来实现:
|
||||
|
||||
```
|
||||
# ifconfig eth0 up
|
||||
```
|
||||
|
||||
或者你可以使用一个专用命令:
|
||||
|
||||
```
|
||||
# ifup eth0
|
||||
```
|
||||
|
||||
`ip` 命令使用 `set` 子命令将网络设置为 `up` 或 `down` 状态:
|
||||
|
||||
```
|
||||
# ip link set eth0 up
|
||||
```
|
||||
|
||||
#### 开启或关闭地址解析功能(ARP)
|
||||
|
||||
使用 `ifconfig`,你可以通过声明它来启用:
|
||||
|
||||
```
|
||||
# ifconfig eth0 arp
|
||||
```
|
||||
|
||||
使用 `ip`,你可以将 `arp` 属性设置为 `on` 或 `off`:
|
||||
|
||||
```
|
||||
# ip link set dev eth0 arp on
|
||||
```
|
||||
|
||||
### ip 和 ipconfig 的优缺点
|
||||
|
||||
`ip` 命令比 `ifconfig` 更通用,技术上也更有效,因为它使用的是 `Netlink` 套接字,而不是 `ioctl` 系统调用。
|
||||
|
||||
`ip` 命令可能看起来比 `ifconfig` 更详细、更复杂,但这是它拥有更多功能的一个原因。一旦你开始使用它,你会了解它的内部逻辑(例如,使用 `set` 而不是看起来随意混合的声明或设置)。
|
||||
|
||||
最后,`ifconfig` 已经过时了(例如,它缺乏对网络命名空间的支持),而 `ip` 是为现代网络而生的。尝试并学习它,使用它,你会由衷高兴的!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/ifconfig-ip-linux
|
||||
|
||||
作者:[Rajan Bhardwaj][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/rajabhar
|
||||
[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/OSI_model
|
||||
[3]: https://en.wikipedia.org/wiki/Multicast
|
@ -0,0 +1,75 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13084-1.html)
|
||||
[#]: subject: (Use your Raspberry Pi as a productivity powerhouse)
|
||||
[#]: via: (https://opensource.com/article/21/1/raspberry-pi-productivity)
|
||||
[#]: author: (Kevin Sonney https://opensource.com/users/ksonney)
|
||||
|
||||
将你的树莓派用作生产力源泉
|
||||
======
|
||||
|
||||
> 树莓派已经从主要为黑客和业余爱好者服务,成为了小型生产力工作站的可靠选择。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/04/103826pjbxb7j1m8ok6ezf.jpg)
|
||||
|
||||
在前几年,这个年度系列涵盖了单个的应用。今年,我们除了关注 2021 年的策略外,还将关注一体化解决方案。欢迎来到 2021 年 21 天生产力的第十六天。
|
||||
|
||||
[树莓派][2]是一台相当棒的小电脑。它体积小,功能却出奇的强大,而且非常容易设置和使用。我曾将它们用于家庭自动化项目、面板和专用媒体播放器。但它也能成为生产力的动力源泉么?
|
||||
|
||||
答案相当简单:是的。
|
||||
|
||||
![Geary and Calendar apps on the Raspberry Pi][3]
|
||||
|
||||
*Geary 和 Calendar 应用 (Kevin Sonney, [CC BY-SA 4.0][4])*
|
||||
|
||||
基本的 [Raspbian][5] 安装包括 [Claw Mail][6],这是一个轻量级的邮件客户端。它的用户界面有点过时了,而且非常的简陋。如果你是一个 [Mutt 用户][7],它可能会满足你的需求。
|
||||
|
||||
我更喜欢安装 [Geary][8],因为它也是轻量级的,而且有一个现代化的界面。另外,与 Claws 不同的是,Geary 默认支持富文本 (HTML) 邮件。我不喜欢富文本电子邮件,但它已经成为必要的,所以对它有良好的支持是至关重要的。
|
||||
|
||||
默认的 Raspbian 安装不包含日历,所以我添加了 [GNOME 日历][9] ,因为它可以与远程服务通信(因为我的几乎所有日历都在云提供商那里)。
|
||||
|
||||
![GTG and GNote open on Raspberry Pi][10]
|
||||
|
||||
*GTG 和 GNote(Kevin Sonney, [CC BY-SA 4.0][4])*
|
||||
|
||||
那笔记和待办事项清单呢?有很多选择,但我喜欢用 [GNote][11] 来做笔记,用 [Getting-Things-GNOME!][12] 来做待办事项。两者都相当轻量级,并且可以相互同步,也可以同步到其他服务。
|
||||
|
||||
你会注意到,我在这里使用了不少 GNOME 应用。为什么不直接安装完整的 GNOME 桌面呢?在内存为 4Gb(或 8Gb)的树莓派 4 上,GNOME 工作得很好。你需要采取一些额外的步骤来禁用 Raspbian 上的默认 wifi 设置,并用 Network Manager 来代替它,但这个在网上有很好的文档,而且真的很简单。
|
||||
|
||||
GNOME 中包含了 [Evolution][13],它将邮件、日历、笔记、待办事项和联系人管理整合到一个应用中。与 Geary 和 GNOME Calendar 相比,它有点重,但在树莓派 4 上却很稳定。这让我很惊讶,因为我习惯了 Evolution 有点消耗资源,但树莓派 4 却和我的品牌笔记本一样运行良好,而且资源充足。
|
||||
|
||||
![Evolution on Raspbian][14]
|
||||
|
||||
*Raspbian 上的 Evolution (Kevin Sonney, [CC BY-SA 4.0][4])*
|
||||
|
||||
树莓派在过去的几年里进步很快,已经从主要为黑客和业余爱好者服务,成为了小型生产力工作站的可靠选择。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/raspberry-pi-productivity
|
||||
|
||||
作者:[Kevin Sonney][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/ksonney
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/todo_checklist_team_metrics_report.png?itok=oB5uQbzf (Team checklist and to dos)
|
||||
[2]: https://www.raspberrypi.org/
|
||||
[3]: https://opensource.com/sites/default/files/day16-image1.png
|
||||
[4]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[5]: https://www.raspbian.org/
|
||||
[6]: https://www.claws-mail.org/
|
||||
[7]: http://www.mutt.org/
|
||||
[8]: https://wiki.gnome.org/Apps/Geary
|
||||
[9]: https://wiki.gnome.org/Apps/Calendar
|
||||
[10]: https://opensource.com/sites/default/files/day16-image2.png
|
||||
[11]: https://wiki.gnome.org/Apps/Gnote
|
||||
[12]: https://wiki.gnome.org/Apps/GTG
|
||||
[13]: https://opensource.com/business/18/1/desktop-email-clients
|
||||
[14]: https://opensource.com/sites/default/files/day16-image3.png
|
@ -0,0 +1,234 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (amwps290)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13093-1.html)
|
||||
[#]: subject: (Write GIMP scripts to make image processing faster)
|
||||
[#]: via: (https://opensource.com/article/21/1/gimp-scripting)
|
||||
[#]: author: (Cristiano L. Fontana https://opensource.com/users/cristianofontana)
|
||||
|
||||
编写 GIMP 脚本使图像处理更快
|
||||
======
|
||||
|
||||
> 通过向一批图像添加效果来学习 GIMP 的脚本语言 Script-Fu。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/06/231011c0xhvxitxjv899qv.jpg)
|
||||
|
||||
前一段时间,我想给方程图片加一个黑板式的外观。我开始是使用 [GIMP][2] 来处理的,我对结果很满意。问题是我必须对图像执行几个操作,当我想再次使用此样式,不想对所有图像重复这些步骤。此外,我确信我会很快忘记这些步骤。
|
||||
|
||||
![Fourier transform equations][3]
|
||||
|
||||
*傅立叶变换方程式(Cristiano Fontana,[CC BY-SA 4.0] [4])*
|
||||
|
||||
GIMP 是一个很棒的开源图像编辑器。尽管我已经使用了多年,但从未研究过其批处理功能或 [Script-Fu][5] 菜单。这是探索它们的绝好机会。
|
||||
|
||||
### 什么是 Script-Fu?
|
||||
|
||||
[Script-Fu][6] 是 GIMP 内置的脚本语言。是一种基于 [Scheme][7] 的编程语言。如果你从未使用过 Scheme,请尝试一下,因为它可能非常有用。我认为 Script-Fu 是一个很好的入门方法,因为它对图像处理具有立竿见影的效果,所以你可以很快感觉到自己的工作效率的提高。你也可以使用 [Python][8] 编写脚本,但是 Script-Fu 是默认选项。
|
||||
|
||||
为了帮助你熟悉 Scheme,GIMP 的文档提供了深入的 [教程][9]。Scheme 是一种类似于 [Lisp][10] 的语言,因此它的主要特征是使用 [前缀][11] 表示法和 [许多括号][12]。函数和运算符通过前缀应用到操作数列表中:
|
||||
|
||||
```
|
||||
(函数名 操作数 操作数 ...)
|
||||
|
||||
(+ 2 3)
|
||||
↳ 返回 5
|
||||
|
||||
(list 1 2 3 5)
|
||||
↳ 返回一个列表,包含 1、 2、 3 和 5
|
||||
```
|
||||
|
||||
我花了一些时间才找到完整的 GIMP 函数列表文档,但实际上很简单。在 **Help** 菜单中,有一个 **Procedure Browser**,其中包含所有可用的函数的丰富详尽文档。
|
||||
|
||||
![GIMP Procedure Browser][13]
|
||||
|
||||
### 使用 GIMP 的批处理模式
|
||||
|
||||
你可以使用 `-b` 选项以批处理的方式启动 GIMP。`-b` 选项的参数可以是你想要运行的脚本,或者用一个 `-` 来让 GIMP 进入交互模式而不是命令行模式。正常情况下,当你启动 GIMP 的时候,它会启动图形界面,但是你可以使用 `-i` 选项来禁用它。
|
||||
|
||||
### 开始编写你的第一个脚本
|
||||
|
||||
创建一个名为 `chalk.scm` 的文件,并把它保存在 **Preferences** 窗口中 **Folders** 选项下的 **Script** 中指定的 `script` 文件夹下。就我而言,是在 `$HOME/.config/GIMP/2.10/scripts`。
|
||||
|
||||
在 `chalk.scm` 文件中,写入下面的内容:
|
||||
|
||||
```
|
||||
(define (chalk filename grow-pixels spread-amount percentage)
|
||||
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
|
||||
(drawable (car (gimp-image-get-active-layer image)))
|
||||
(new-filename (string-append "modified_" filename)))
|
||||
(gimp-image-select-color image CHANNEL-OP-REPLACE drawable '(0 0 0))
|
||||
(gimp-selection-grow image grow-pixels)
|
||||
(gimp-context-set-foreground '(0 0 0))
|
||||
(gimp-edit-bucket-fill drawable BUCKET-FILL-FG LAYER-MODE-NORMAL 100 255 TRUE 0 0)
|
||||
(gimp-selection-none image)
|
||||
(plug-in-spread RUN-NONINTERACTIVE image drawable spread-amount spread-amount)
|
||||
(gimp-drawable-invert drawable TRUE)
|
||||
(plug-in-randomize-hurl RUN-NONINTERACTIVE image drawable percentage 1 TRUE 0)
|
||||
(gimp-file-save RUN-NONINTERACTIVE image drawable new-filename new-filename)
|
||||
(gimp-image-delete image)))
|
||||
```
|
||||
|
||||
### 定义脚本变量
|
||||
|
||||
在脚本中, `(define (chalk filename grow-pixels spread-amound percentage) ...)` 函数定义了一个名叫 `chalk` 的新函数。它的函数参数是 `filename`、`grow-pixels`、`spread-amound` 和 `percentage`。在 `define` 中的所有内容都是 `chalk` 函数的主体。你可能已经注意到,那些名字比较长的变量中间都有一个破折号来分割。这是类 Lisp 语言的惯用风格。
|
||||
|
||||
`(let* ...)` 函数是一个特殊<ruby>过程<rt>procedure</rt></ruby>,可以让你定义一些只有在这个函数体中才有效的临时变量。临时变量有 `image`、`drawable` 以及 `new-filename`。它使用 `gimp-file-load` 来载入图片,这会返回它所包含的图片的一个列表。并通过 `car` 函数来选取第一项。然后,它选择第一个活动层并将其引用存储在 `drawable` 变量中。最后,它定义了包含图像新文件名的字符串。
|
||||
|
||||
为了帮助你更好地了解该过程,我将对其进行分解。首先,启动带 GUI 的 GIMP,然后你可以通过依次点击 **Filters → Script-Fu → Console** 来打开 Script-Fu 控制台。 在这种情况下,不能使用 `let *`,因为变量必须是持久的。使用 `define` 函数定义 `image` 变量,并为其提供查找图像的正确路径:
|
||||
|
||||
```
|
||||
(define image (car (gimp-file-load RUN-NONINTERACTIVE "Fourier.png" "Fourier.png")))
|
||||
```
|
||||
|
||||
似乎在 GUI 中什么也没有发生,但是图像已加载。 你需要通过以下方式来让图像显示:
|
||||
|
||||
```
|
||||
(gimp-display-new image)
|
||||
```
|
||||
|
||||
![GUI with the displayed image][14]
|
||||
|
||||
现在,获取活动层并将其存储在 `drawable` 变量中:
|
||||
|
||||
```
|
||||
(define drawable (car (gimp-image-get-active-layer image)))
|
||||
```
|
||||
|
||||
最后,定义图像的新文件名:
|
||||
|
||||
```
|
||||
(define new-filename "modified_Fourier.png")
|
||||
```
|
||||
|
||||
运行命令后,你将在 Script-Fu 控制台中看到以下内容:
|
||||
|
||||
![Script-Fu console][15]
|
||||
|
||||
在对图像执行操作之前,需要定义将在脚本中作为函数参数的变量:
|
||||
|
||||
```
|
||||
(define grow-pixels 2)
|
||||
(define spread-amount 4)
|
||||
(define percentage 3)
|
||||
```
|
||||
|
||||
### 处理图片
|
||||
|
||||
现在,所有相关变量都已定义,你可以对图像进行操作了。 脚本的操作可以直接在控制台上执行。第一步是在活动层上选择黑色。颜色被写成一个由三个数字组成的列表,即 `(list 0 0 0)` 或者是 `'(0 0 0)`:
|
||||
|
||||
```
|
||||
(gimp-image-select-color image CHANNEL-OP-REPLACE drawable '(0 0 0))
|
||||
```
|
||||
|
||||
![Image with the selected color][16]
|
||||
|
||||
扩大选取两个像素:
|
||||
|
||||
```
|
||||
(gimp-selection-grow image grow-pixels)
|
||||
```
|
||||
|
||||
![Image with the selected color][17]
|
||||
|
||||
将前景色设置为黑色,并用它填充选区:
|
||||
|
||||
```
|
||||
(gimp-context-set-foreground '(0 0 0))
|
||||
(gimp-edit-bucket-fill drawable BUCKET-FILL-FG LAYER-MODE-NORMAL 100 255 TRUE 0 0)
|
||||
```
|
||||
|
||||
![Image with the selection filled with black][18]
|
||||
|
||||
删除选区:
|
||||
|
||||
```
|
||||
(gimp-selection-none image)
|
||||
```
|
||||
|
||||
![Image with no selection][19]
|
||||
|
||||
随机移动像素:
|
||||
|
||||
```
|
||||
(plug-in-spread RUN-NONINTERACTIVE image drawable spread-amount spread-amount)
|
||||
```
|
||||
|
||||
![Image with pixels moved around][20]
|
||||
|
||||
反转图像颜色:
|
||||
|
||||
```
|
||||
(gimp-drawable-invert drawable TRUE)
|
||||
```
|
||||
|
||||
![Image with pixels moved around][21]
|
||||
|
||||
随机化像素:
|
||||
|
||||
```
|
||||
(plug-in-randomize-hurl RUN-NONINTERACTIVE image drawable percentage 1 TRUE 0)
|
||||
```
|
||||
|
||||
![Image with pixels moved around][22]
|
||||
|
||||
将图像保存到新文件:
|
||||
|
||||
```
|
||||
(gimp-file-save RUN-NONINTERACTIVE image drawable new-filename new-filename)
|
||||
```
|
||||
|
||||
![Equations of the Fourier transform and its inverse][23]
|
||||
|
||||
*傅立叶变换方程 (Cristiano Fontana, [CC BY-SA 4.0][4])*
|
||||
|
||||
### 以批处理模式运行脚本
|
||||
|
||||
现在你知道了脚本的功能,可以在批处理模式下运行它:
|
||||
|
||||
```
|
||||
gimp -i -b '(chalk "Fourier.png" 2 4 3)' -b '(gimp-quit 0)'
|
||||
```
|
||||
|
||||
在运行 `chalk` 函数之后,它将使用 `-b` 选项调用第二个函数 `gimp-quit` 来告诉 GIMP 退出。
|
||||
|
||||
### 了解更多
|
||||
|
||||
本教程向你展示了如何开始使用 GIMP 的内置脚本功能,并介绍了 GIMP 的 Scheme 实现:Script-Fu。如果你想继续前进,建议你查看官方文档及其[入门教程][9]。如果你不熟悉 Scheme 或 Lisp,那么一开始的语法可能有点吓人,但我还是建议你尝试一下。这可能是一个不错的惊喜。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/gimp-scripting
|
||||
|
||||
作者:[Cristiano L. Fontana][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/cristianofontana
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/painting_computer_screen_art_design_creative.png?itok=LVAeQx3_ (Painting art on a computer screen)
|
||||
[2]: https://www.gimp.org/
|
||||
[3]: https://opensource.com/sites/default/files/uploads/fourier.png (Fourier transform equations)
|
||||
[4]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[5]: https://docs.gimp.org/en/gimp-filters-script-fu.html
|
||||
[6]: https://docs.gimp.org/en/gimp-concepts-script-fu.html
|
||||
[7]: https://en.wikipedia.org/wiki/Scheme_(programming_language)
|
||||
[8]: https://docs.gimp.org/en/gimp-filters-python-fu.html
|
||||
[9]: https://docs.gimp.org/en/gimp-using-script-fu-tutorial.html
|
||||
[10]: https://en.wikipedia.org/wiki/Lisp_%28programming_language%29
|
||||
[11]: https://en.wikipedia.org/wiki/Polish_notation
|
||||
[12]: https://xkcd.com/297/
|
||||
[13]: https://opensource.com/sites/default/files/uploads/procedure_browser.png (GIMP Procedure Browser)
|
||||
[14]: https://opensource.com/sites/default/files/uploads/gui01_image.png (GUI with the displayed image)
|
||||
[15]: https://opensource.com/sites/default/files/uploads/console01_variables.png (Script-Fu console)
|
||||
[16]: https://opensource.com/sites/default/files/uploads/gui02_selected.png (Image with the selected color)
|
||||
[17]: https://opensource.com/sites/default/files/uploads/gui03_grow.png (Image with the selected color)
|
||||
[18]: https://opensource.com/sites/default/files/uploads/gui04_fill.png (Image with the selection filled with black)
|
||||
[19]: https://opensource.com/sites/default/files/uploads/gui05_no_selection.png (Image with no selection)
|
||||
[20]: https://opensource.com/sites/default/files/uploads/gui06_spread.png (Image with pixels moved around)
|
||||
[21]: https://opensource.com/sites/default/files/uploads/gui07_invert.png (Image with pixels moved around)
|
||||
[22]: https://opensource.com/sites/default/files/uploads/gui08_hurl.png (Image with pixels moved around)
|
||||
[23]: https://opensource.com/sites/default/files/uploads/modified_fourier.png (Equations of the Fourier transform and its inverse)
|
77
published/20210127 3 email mistakes and how to avoid them.md
Normal file
77
published/20210127 3 email mistakes and how to avoid them.md
Normal file
@ -0,0 +1,77 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13086-1.html)
|
||||
[#]: subject: (3 email mistakes and how to avoid them)
|
||||
[#]: via: (https://opensource.com/article/21/1/email-mistakes)
|
||||
[#]: author: (Kevin Sonney https://opensource.com/users/ksonney)
|
||||
|
||||
3 个电子邮件错误以及如何避免它们
|
||||
======
|
||||
|
||||
> 自动化是美好的,但也不总是那样。确保你的电子邮件自动回复和抄送配置正确,这样你就不会浪费大家的时间。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/05/090335a888nqn7pcolblzn.jpg)
|
||||
|
||||
在前几年,这个年度系列涵盖了单个的应用。今年,我们除了关注 2021 年的策略外,还将关注一体化解决方案。欢迎来到 2021 年 21 天生产力的第十七天。
|
||||
|
||||
好了,我们已经谈到了一些我们应该对电子邮件做的事情:[不要再把它当作即时通讯工具][2]、[优先处理事情][3]、[努力达到收件箱 0 新邮件][4],以及[有效过滤][5]。但哪些事情是我们不应该做的呢?
|
||||
|
||||
![Automated email reply][6]
|
||||
|
||||
*你真幸运 (Kevin Sonney, [CC BY-SA 4.0][7])*
|
||||
|
||||
### 1、请不要对所有事情自动回复
|
||||
|
||||
邮件列表中总有些人,他们去度假了,并设置了一个“我在度假”的自动回复信息。然而,他们没有正确地设置,所以它对列表上的每一封邮件都会回复“我在度假”,直到管理员将其屏蔽或取消订阅。
|
||||
|
||||
我们都感受到了这种痛苦,我承认过去至少有一次,我就是那个人。
|
||||
|
||||
从我的错误中吸取教训,并确保你的自动回复器或假期信息对它们将回复谁和多久回复一次有限制。
|
||||
|
||||
![An actual email with lots of CC'd recipients][8]
|
||||
|
||||
*这是一封真实的电子邮件 (Kevin Sonney, [CC BY-SA 4.0][7])*
|
||||
|
||||
### 2、请不要抄送给所有人
|
||||
|
||||
我们都至少做过一次。我们需要发送邮件的人员众多,因此我们只需抄送他们*所有人*。有时这是有必要的,但大多数时候,它并不是。当然,你邀请每个人在庭院吃生日蛋糕,或者你的表姐要结婚了,或者公司刚拿到一个大客户,这都是好事。如果你有邮件列表的话,请用邮件列表,如果没有的话,请给每个人密送。说真的,密送是你的朋友。
|
||||
|
||||
### 3、回复所有人不是你的朋友
|
||||
|
||||
![Reply options in Kmail][9]
|
||||
|
||||
这一条与上一条是相辅相成的。我不知道有多少次看到有人向一个名单(或者是一个大群的人)发送信息,而这个信息本来是要发给一个人的。我见过这样发送的相对好的邮件,以及随之而来的纪律处分邮件。
|
||||
|
||||
认真地说,除非必须,不要使用“回复全部”按钮。即使是这样,也要确保你*真的*需要这样做。
|
||||
|
||||
有些电子邮件应用比其他应用管理得更好。Kmail,[KDE Kontact][10] 的电子邮件组件,在**回复**工具栏按钮的子菜单中,有几个不同的回复选项。你可以选择只回复给**发件人**字段中的任何实体(通常是一个人,但有时是一个邮件列表),或者回复给作者(在抄送或密送中去除每一个人),或者只回复给一个邮件列表,或者回复*所有人*(不要这样做)。看到明确列出的选项,的确可以帮助你了解谁会收到你要发送的邮件副本,这有时比你想象的更发人深省。我曾经发现,当我意识到一个评论并不一定会对一个复杂的讨论的最终目标有所帮助时,我就会把邮件的收件人改为只是作者,而不是整个列表。
|
||||
|
||||
(另外,如果你写的邮件可能会给你的 HR 或公司带来麻烦,请在点击发送之前多考虑下。——
|
||||
|
||||
希望你已经*不再*在电子邮件中这么做了。如果你认识的人是这样的呢?欢迎与他们分享。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/email-mistakes
|
||||
|
||||
作者:[Kevin Sonney][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/ksonney
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_screen_windows_files.png?itok=kLTeQUbY (Computer screen with files or windows open)
|
||||
[2]: https://opensource.com/article/21/1/email-rules
|
||||
[3]: https://opensource.com/article/21/1/prioritize-tasks
|
||||
[4]: https://opensource.com/article/21/1/inbox-zero
|
||||
[5]: https://opensource.com/article/21/1/email-filter
|
||||
[6]: https://opensource.com/sites/default/files/day17-image1.png
|
||||
[7]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[8]: https://opensource.com/sites/default/files/day17-image2.png
|
||||
[9]: https://opensource.com/sites/default/files/kmail-replies.jpg (Reply options in Kmail)
|
||||
[10]: https://opensource.com/article/21/1/kde-kontact
|
@ -0,0 +1,176 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13100-1.html)
|
||||
[#]: subject: (Why I use the D programming language for scripting)
|
||||
[#]: via: (https://opensource.com/article/21/1/d-scripting)
|
||||
[#]: author: (Lawrence Aberba https://opensource.com/users/aberba)
|
||||
|
||||
我为什么要用 D 语言写脚本?
|
||||
======
|
||||
|
||||
> D 语言以系统编程语言而闻名,但它也是编写脚本的一个很好的选择。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/09/134351j4m3hrhll0h38plp.jpg)
|
||||
|
||||
D 语言由于其静态类型和元编程能力,经常被宣传为系统编程语言。然而,它也是一种非常高效的脚本语言。
|
||||
|
||||
由于 Python 在自动化任务和快速实现原型想法方面的灵活性,它通常被选为脚本语言。这使得 Python 对系统管理员、[管理者][2]和一般的开发人员非常有吸引力,因为它可以自动完成他们可能需要手动完成的重复性任务。
|
||||
|
||||
我们自然也可以期待任何其他的脚本编写语言具有 Python 的这些特性和能力。以下是我认为 D 是一个不错的选择的两个原因。
|
||||
|
||||
### 1、D 很容易读和写
|
||||
|
||||
作为一种类似于 C 的语言,D 应该是大多数程序员所熟悉的。任何使用 JavaScript、Java、PHP 或 Python 的人对 D 语言都很容易上手。
|
||||
|
||||
如果你还没有安装 D,请[安装 D 编译器][3],这样你就可以[运行本文中的 D 代码][4]。你也可以使用[在线 D 编辑器][5]。
|
||||
|
||||
下面是一个 D 代码的例子,它从一个名为 `words.txt` 的文件中读取单词,并在命令行中打印出来:
|
||||
|
||||
```
|
||||
open
|
||||
source
|
||||
is
|
||||
cool
|
||||
```
|
||||
|
||||
用 D 语言写脚本:
|
||||
|
||||
```
|
||||
#!/usr/bin/env rdmd
|
||||
// file print_words.d
|
||||
|
||||
// import the D standard library
|
||||
import std;
|
||||
|
||||
void main(){
|
||||
// open the file
|
||||
File("./words.txt")
|
||||
|
||||
//iterate by line
|
||||
.byLine
|
||||
|
||||
// print each number
|
||||
.each!writeln;
|
||||
}
|
||||
```
|
||||
|
||||
这段代码以 [释伴][6] 开头,它将使用 [rdmd][7] 来运行这段代码,`rdmd` 是 D 编译器自带的编译和运行代码的工具。假设你运行的是 Unix 或 Linux,在运行这个脚本之前,你必须使用` chmod` 命令使其可执行:
|
||||
|
||||
```
|
||||
chmod u+x print_words.d
|
||||
```
|
||||
|
||||
现在脚本是可执行的,你可以运行它:
|
||||
|
||||
```
|
||||
./print_words.d
|
||||
```
|
||||
|
||||
这将在你的命令行中打印以下内容:
|
||||
|
||||
```
|
||||
open
|
||||
source
|
||||
is
|
||||
cool
|
||||
```
|
||||
|
||||
恭喜你,你写了第一个 D 语言脚本。你可以看到 D 是如何让你按顺序链式调用函数,这让阅读代码的感觉很自然,类似于你在头脑中思考问题的方式。这个[功能让 D 成为我最喜欢的编程语言][8]。
|
||||
|
||||
试着再写一个脚本:一个非营利组织的管理员有一个捐款的文本文件,每笔金额都是单独的一行。管理员想把前 10 笔捐款相加,然后打印出金额:
|
||||
|
||||
```
|
||||
#!/usr/bin/env rdmd
|
||||
// file sum_donations.d
|
||||
|
||||
import std;
|
||||
|
||||
void main()
|
||||
{
|
||||
double total = 0;
|
||||
|
||||
// open the file
|
||||
File("monies.txt")
|
||||
|
||||
// iterate by line
|
||||
.byLine
|
||||
|
||||
// pick first 10 lines
|
||||
.take(10)
|
||||
|
||||
// remove new line characters (\n)
|
||||
.map!(strip)
|
||||
|
||||
// convert each to double
|
||||
.map!(to!double)
|
||||
|
||||
// add element to total
|
||||
.tee!((x) { total += x; })
|
||||
|
||||
// print each number
|
||||
.each!writeln;
|
||||
|
||||
// print total
|
||||
writeln("total: ", total);
|
||||
}
|
||||
```
|
||||
|
||||
与 `each` 一起使用的 `!` 操作符是[模板参数][9]的语法。
|
||||
|
||||
### 2、D 是快速原型设计的好帮手
|
||||
|
||||
D 是灵活的,它可以快速地将代码敲打在一起,并使其发挥作用。它的标准库中包含了丰富的实用函数,用于执行常见的任务,如操作数据(JSON、CSV、文本等)。它还带有一套丰富的通用算法,用于迭代、搜索、比较和 mutate 数据。这些巧妙的算法通过定义通用的 [基于范围的接口][10] 而按照序列进行处理。
|
||||
|
||||
上面的脚本显示了 D 中的链式调用函数如何提供顺序处理和操作数据的要领。D 的另一个吸引人的地方是它不断增长的用于执行普通任务的第三方包的生态系统。一个例子是,使用 [Vibe.d][11] web 框架构建一个简单的 web 服务器很容易。下面是一个例子:
|
||||
|
||||
```
|
||||
#!/usr/bin/env dub
|
||||
/+ dub.sdl:
|
||||
dependency "vibe-d" version="~>0.8.0"
|
||||
+/
|
||||
void main()
|
||||
{
|
||||
import vibe.d;
|
||||
listenHTTP(":8080", (req, res) {
|
||||
res.writeBody("Hello, World: " ~ req.path);
|
||||
});
|
||||
runApplication();
|
||||
}
|
||||
```
|
||||
|
||||
它使用官方的 D 软件包管理器 [Dub][12],从 [D 软件包仓库][13]中获取 vibe.d Web 框架。Dub 负责下载 Vibe.d 包,然后在本地主机 8080 端口上编译并启动一个 web 服务器。
|
||||
|
||||
### 尝试一下 D 语言
|
||||
|
||||
这些只是你可能想用 D 来写脚本的几个原因。
|
||||
|
||||
D 是一种非常适合开发的语言。你可以很容易从 D 下载页面安装,因此下载编译器,看看例子,并亲自体验 D 语言。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/d-scripting
|
||||
|
||||
作者:[Lawrence Aberba][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/aberba
|
||||
[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/20/3/automating-community-management-python
|
||||
[3]: https://tour.dlang.org/tour/en/welcome/install-d-locally
|
||||
[4]: https://tour.dlang.org/tour/en/welcome/run-d-program-locally
|
||||
[5]: https://run.dlang.io/
|
||||
[6]: https://en.wikipedia.org/wiki/Shebang_(Unix)
|
||||
[7]: https://dlang.org/rdmd.html
|
||||
[8]: https://opensource.com/article/20/7/d-programming
|
||||
[9]: http://ddili.org/ders/d.en/templates.html
|
||||
[10]: http://ddili.org/ders/d.en/ranges.html
|
||||
[11]: https://vibed.org
|
||||
[12]: https://dub.pm/getting_started
|
||||
[13]: https://code.dlang.org
|
@ -0,0 +1,75 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13094-1.html)
|
||||
[#]: subject: (4 tips for preventing notification fatigue)
|
||||
[#]: via: (https://opensource.com/article/21/1/alert-fatigue)
|
||||
[#]: author: (Kevin Sonney https://opensource.com/users/ksonney)
|
||||
|
||||
防止通知疲劳的 4 个技巧
|
||||
======
|
||||
|
||||
> 不要让提醒淹没自己:设置重要的提醒,让其它提醒消失。你会感觉更好,工作效率更高。
|
||||
|
||||
![W】(https://img.linux.net.cn/data/attachment/album/202102/06/234924mo3okotjlv7lo3yo.jpg)
|
||||
|
||||
在前几年,这个年度系列涵盖了单个的应用。今年,我们除了关注 2021 年的策略外,还将关注一体化解决方案。欢迎来到 2021 年 21 天生产力的第十八天。
|
||||
|
||||
当我和人们谈论生产力时,我注意到一件事,那就是几乎每个人都是为了保持更清晰的头脑。我们不是把所有的约会都记在脑子里,而是把它们放在一个数字日历上,在事件发生前提醒我们。我们有数字或实体笔记,这样我们就不必记住某件事的每一个小细节。我们有待办事项清单,提醒我们去做该做的事情。
|
||||
|
||||
![Text box offering to send notifications][2]
|
||||
|
||||
*NOPE(Kevin Sonney, [CC BY-SA 4.0][3])*
|
||||
|
||||
如此多的应用、网站和服务想要提醒我们每一件小事,我们很容易就把它们全部调出来。而且,如果我们不这样做,我们将开始遭受**提醒疲劳**的困扰 —— 这时我们处于边缘的状态,只是等待下一个提醒,并生活在恐惧之中。
|
||||
|
||||
提醒疲劳在那些因工作而被随叫随到的人中非常常见。它也发生在那些 **FOMO** (错失恐惧症)的人身上,从而对每一个关键词、标签或在社交媒体上提到他们感兴趣的事情都会设置提醒。
|
||||
|
||||
此时,设置能引起我们的注意,但不会被忽略的提醒是件棘手的事情。不过,我确实有一些有用的提示,这样重要的提醒可能会在这个忙碌的世界中越过我们自己的心理过滤器。
|
||||
|
||||
![Alert for a task][4]
|
||||
|
||||
*我可以忽略这个,对吧?(Kevin Sonney, [CC BY-SA 4.0][3])*
|
||||
|
||||
1. 弄清楚什么更适合你:视觉提醒或声音提醒。我使用视觉弹出和声音的组合,但这对我是有效的。有些人需要触觉提醒。比如手机或手表的震动。找到适合你的那一种。
|
||||
2. 为重要的提醒指定独特的音调或视觉效果。我有一个朋友,他的工作页面的铃声最响亮、最讨厌。这旨在吸引他的注意力,让他看到提醒。我的显示器上有一盏灯,当我在待命时收到工作提醒时,它就会闪烁红灯,以及发送通知到我手机上。
|
||||
3. 关掉那些实际上无关紧要的警报。社交网络、网站和应用都希望得到你的关注。它们不会在意你是否错过会议、约会迟到,或者熬夜到凌晨 4 点。关掉那些不重要的,让那些重要的可以被看到。
|
||||
4. 每隔一段时间就改变一下。上个月有效的东西,下个月可能就不行了。我们会适应、习惯一些东西,然后我们会忽略。如果有些东西不奏效,就换个东西试试吧!它不会伤害你,即使无法解决问题,也许你也会学到一些新知识。
|
||||
|
||||
![Blue alert indicators light][5]
|
||||
|
||||
*蓝色是没问题。红色是有问题。(Kevin Sonney, [CC BY-SA 4.0][3])*
|
||||
|
||||
### 开源和选择
|
||||
|
||||
一个好的应用可以通知提供很多选择。我最喜欢的一个是 Android 的 Etar 日历应用。[Etar 可以从开源 F-droid 仓库中获得][6]。
|
||||
|
||||
Etar 和许多开源应用一样,为你提供了很多选项,尤其是通知设置。
|
||||
|
||||
![Etar][7]
|
||||
|
||||
通过 Etar,你可以激活或停用弹出式通知,设置打盹时间、打盹延迟、是否提醒你已拒绝的事件等。结合有计划的日程安排策略,你可以通过控制数字助手对你需要做的事情进行提示的频率来改变你一天的进程。
|
||||
|
||||
提醒和警报真的很有用,只要我们收到重要的提醒并予以注意即可。这可能需要做一些实验,但最终,少一些噪音是好事,而且更容易注意到真正需要我们注意的提醒。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/alert-fatigue
|
||||
|
||||
作者:[Kevin Sonney][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/ksonney
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/team_dev_email_chat_video_work_wfm_desk_520.png?itok=6YtME4Hj (Working on a team, busy worklife)
|
||||
[2]: https://opensource.com/sites/default/files/day18-image1.png
|
||||
[3]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[4]: https://opensource.com/sites/default/files/day18-image2.png
|
||||
[5]: https://opensource.com/sites/default/files/day18-image3.png
|
||||
[6]: https://f-droid.org/en/packages/ws.xsoh.etar/
|
||||
[7]: https://opensource.com/sites/default/files/etar.jpg (Etar)
|
@ -0,0 +1,168 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (robsean)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13106-1.html)
|
||||
[#]: subject: (How to Run a Shell Script in Linux [Essentials Explained for Beginners])
|
||||
[#]: via: (https://itsfoss.com/run-shell-script-linux/)
|
||||
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
|
||||
|
||||
基础:如何在 Linux 中运行一个 Shell 脚本
|
||||
======
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/10/235325tkv7h8dvlp4makkk.jpg)
|
||||
|
||||
在 Linux 中有两种运行 shell 脚本的方法。你可以使用:
|
||||
|
||||
```
|
||||
bash script.sh
|
||||
```
|
||||
|
||||
或者,你可以像这样执行 shell 脚本:
|
||||
|
||||
```
|
||||
./script.sh
|
||||
```
|
||||
|
||||
这可能很简单,但没太多解释。不要担心,我将使用示例来进行必要的解释,以便你能理解为什么在运行一个 shell 脚本时要使用给定的特定语法格式。
|
||||
|
||||
我将使用这一行 shell 脚本来使需要解释的事情变地尽可能简单:
|
||||
|
||||
```
|
||||
abhishek@itsfoss:~/Scripts$ cat hello.sh
|
||||
|
||||
echo "Hello World!"
|
||||
```
|
||||
|
||||
### 方法 1:通过将文件作为参数传递给 shell 以运行 shell 脚本
|
||||
|
||||
第一种方法涉及将脚本文件的名称作为参数传递给 shell 。
|
||||
|
||||
考虑到 bash 是默认 shell,你可以像这样运行一个脚本:
|
||||
|
||||
```
|
||||
bash hello.sh
|
||||
```
|
||||
|
||||
你知道这种方法的优点吗?**你的脚本不需要执行权限**。对于简单的任务非常方便快速。
|
||||
|
||||
![在 Linux 中运行一个 Shell 脚本][1]
|
||||
|
||||
如果你还不熟悉,我建议你 [阅读我的 Linux 文件权限详细指南][2] 。
|
||||
|
||||
记住,将其作为参数传递的需要是一个 shell 脚本。一个 shell 脚本是由命令组成的。如果你使用一个普通的文本文件,它将会抱怨错误的命令。
|
||||
|
||||
![运行一个文本文件为脚本][3]
|
||||
|
||||
在这种方法中,**你要明确地具体指定你想使用 bash 作为脚本的解释器** 。
|
||||
|
||||
shell 只是一个程序,并且 bash 只是 Shell 的一种实现。还有其它的 shell 程序,像 ksh 、[zsh][4] 等等。如果你安装有其它的 shell ,你也可以使用它们来代替 bash 。
|
||||
|
||||
例如,我已安装了 zsh ,并使用它来运行相同的脚本:
|
||||
|
||||
![使用 Zsh 来执行 Shell 脚本][5]
|
||||
|
||||
### 方法 2:通过具体指定 shell 脚本的路径来执行脚本
|
||||
|
||||
另外一种运行一个 shell 脚本的方法是通过提供它的路径。但是要这样做之前,你的文件必须是可执行的。否则,当你尝试执行脚本时,你将会得到 “权限被拒绝” 的错误。
|
||||
|
||||
因此,你首先需要确保你的脚本有可执行权限。你可以 [使用 chmod 命令][8] 来给予你自己脚本的这种权限,像这样:
|
||||
|
||||
```
|
||||
chmod u+x script.sh
|
||||
```
|
||||
|
||||
使你的脚本是可执行之后,你只需输入文件的名称及其绝对路径或相对路径。大多数情况下,你都在同一个目录中,因此你可以像这样使用它:
|
||||
|
||||
```
|
||||
./script.sh
|
||||
```
|
||||
|
||||
如果你与你的脚本不在同一个目录中,你可以具体指定脚本的绝对路径或相对路径:
|
||||
|
||||
![在其它的目录中运行 Shell 脚本][9]
|
||||
|
||||
在脚本前的这个 `./` 是非常重要的(当你与脚本在同一个目录中)。
|
||||
|
||||
![][10]
|
||||
|
||||
为什么当你在同一个目录下,却不能使用脚本名称?这是因为你的 Linux 系统会在 `PATH` 环境变量中指定的几个目录中查找可执行的文件来运行。
|
||||
|
||||
这里是我的系统的 `PATH` 环境变量的值:
|
||||
|
||||
```
|
||||
abhishek@itsfoss:~$ echo $PATH
|
||||
/home/abhishek/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
|
||||
```
|
||||
|
||||
这意味着在下面目录中具有可执行权限的任意文件都可以在系统的任何位置运行:
|
||||
|
||||
* `/home/abhishek/.local/bin`
|
||||
* `/usr/local/sbin`
|
||||
* `/usr/local/bin`
|
||||
* `/usr/sbin`
|
||||
* `/usr/bin`
|
||||
* `/sbin`
|
||||
* `/bin`
|
||||
* `/usr/games`
|
||||
* `/usr/local/games`
|
||||
* `/snap/bin`
|
||||
|
||||
Linux 命令(像 `ls`、`cat` 等)的二进制文件或可执行文件都位于这些目录中的其中一个。这就是为什么你可以在你系统的任何位置通过使用命令的名称来运作这些命令的原因。看看,`ls` 命令就是位于 `/usr/bin` 目录中。
|
||||
|
||||
![][11]
|
||||
|
||||
当你使用脚本而不具体指定其绝对路径或相对路径时,系统将不能在 `PATH` 环境变量中找到提及的脚本。
|
||||
|
||||
> 为什么大多数 shell 脚本在其头部包含 #! /bin/bash ?
|
||||
>
|
||||
> 记得我提过 shell 只是一个程序,并且有 shell 程序的不同实现。
|
||||
>
|
||||
> 当你使用 `#! /bin/bash` 时,你是具体指定 bash 作为解释器来运行脚本。如果你不这样做,并且以 `./script.sh` 的方式运行一个脚本,它通常会在你正在运行的 shell 中运行。
|
||||
>
|
||||
> 有问题吗?可能会有。看看,大多数的 shell 语法是大多数种类的 shell 中通用的,但是有一些语法可能会有所不同。
|
||||
>
|
||||
> 例如,在 bash 和 zsh 中数组的行为是不同的。在 zsh 中,数组索引是从 1 开始的,而不是从 0 开始。
|
||||
>
|
||||
>![Bash Vs Zsh][12]
|
||||
>
|
||||
> 使用 `#! /bin/bash` 来标识该脚本是 bash 脚本,并且应该使用 bash 作为脚本的解释器来运行,而不受在系统上正在使用的 shell 的影响。如果你使用 zsh 的特殊语法,你可以通过在脚本的第一行添加 `#! /bin/zsh` 的方式来标识其是 zsh 脚本。
|
||||
>
|
||||
> 在 `#!` 和 `/bin/bash` 之间的空格是没有影响的。你也可以使用 `#!/bin/bash` 。
|
||||
|
||||
### 它有帮助吗?
|
||||
|
||||
我希望这篇文章能够增加你的 Linux 知识。如果你还有问题或建议,请留下评论。
|
||||
|
||||
专家用户可能依然会挑出我遗漏的东西。但这种初级题材的问题是,要找到信息的平衡点,避免细节过多或过少,并不容易。
|
||||
|
||||
如果你对学习 bash 脚本感兴趣,在我们专注于系统管理的网站 [Linux Handbook][14] 上,我们有一个 [完整的 Bash 初学者系列][13] 。如果你想要,你也可以 [购买带有附加练习的电子书][15] ,以支持 Linux Handbook。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/run-shell-script-linux/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[robsean](https://github.com/robsean)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/abhishek/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/01/run-a-shell-script-linux.png?resize=741%2C329&ssl=1
|
||||
[2]: https://linuxhandbook.com/linux-file-permissions/
|
||||
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/01/running-text-file-as-script.png?resize=741%2C329&ssl=1
|
||||
[4]: https://www.zsh.org
|
||||
[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/01/execute-shell-script-with-zsh.png?resize=741%2C253&ssl=1
|
||||
[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/09/run-multiple-commands-in-linux.png?fit=800%2C450&ssl=1
|
||||
[7]: https://itsfoss.com/run-multiple-commands-linux/
|
||||
[8]: https://linuxhandbook.com/chmod-command/
|
||||
[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/01/running-shell-script-in-other-directory.png?resize=795%2C272&ssl=1
|
||||
[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/01/executing-shell-scripts-linux.png?resize=800%2C450&ssl=1
|
||||
[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/01/locating-command-linux.png?resize=795%2C272&ssl=1
|
||||
[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/01/bash-vs-zsh.png?resize=795%2C386&ssl=1
|
||||
[13]: https://linuxhandbook.com/tag/bash-beginner/
|
||||
[14]: https://linuxhandbook.com
|
||||
[15]: https://www.buymeacoffee.com/linuxhandbook
|
@ -0,0 +1,81 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13097-1.html)
|
||||
[#]: subject: (Generate QR codes with this open source tool)
|
||||
[#]: via: (https://opensource.com/article/21/2/zint-barcode-generator)
|
||||
[#]: author: (Don Watkins https://opensource.com/users/don-watkins)
|
||||
|
||||
Zint:用这个开源工具生成二维码
|
||||
======
|
||||
|
||||
> Zint 可以轻松生成 50 多种类型的自定义条码。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202102/07/231854y8ffstg0m6l2fcmz.jpg)
|
||||
|
||||
二维码是一种很好的可以向人们提供信息的方式,且没有打印的麻烦和费用。大多数人的智能手机都支持二维码扫描,无论其操作系统是什么。
|
||||
|
||||
你可能想使用二维码的原因有很多。也许你是一名教师,希望通过补充材料来测试你的学生,以增强学习效果,或者是一家餐厅,需要在遵守社交距离准则的同时提供菜单。我经常行走于自然小径,那里贴有树木和其他植物的标签。用二维码来补充这些小标签是一种很好的方式,它可以提供关于公园展品的额外信息,而无需花费和维护标识牌。在这些和其他情况下,二维码是非常有用的。
|
||||
|
||||
在互联网上搜索一个简单的、开源的方法来创建二维码时,我发现了 [Zint][2]。Zint 是一个优秀的开源 (GPLv3.0) 生成条码的解决方案。根据该项目的 [GitHub 仓库][3]:“Zint 是一套可以方便地对任何一种公共领域条形码标准的数据进行编码的程序,并允许你将这种功能集成到你自己的程序中。”
|
||||
|
||||
Zint 支持 50 多种类型的条形码,包括二维码(ISO 18004),你可以轻松地创建这些条形码,然后复制和粘贴到 word 文档、博客、维基和其他数字媒体中。人们可以用智能手机扫描这些二维码,快速链接到信息。
|
||||
|
||||
### 安装 Zint
|
||||
|
||||
Zint 适用于 Linux、macOS 和 Windows。
|
||||
|
||||
你可以在基于 Ubuntu 的 Linux 发行版上使用 `apt` 安装 Zint 命令:
|
||||
|
||||
```
|
||||
$ sudo apt install zint
|
||||
```
|
||||
|
||||
我还想要一个图形用户界面(GUI),所以我安装了 Zint-QT:
|
||||
|
||||
```
|
||||
$ sudo apt install zint-qt
|
||||
```
|
||||
|
||||
请参考手册的[安装部分][4],了解 macOS 和 Windows 的说明。
|
||||
|
||||
### 用 Zint 生成二维码
|
||||
|
||||
安装好后,我启动了它,并创建了我的第一个二维码,这是一个指向 Opensource.com 的链接。
|
||||
|
||||
![Generating QR code with Zint][5]
|
||||
|
||||
Zint 的 50 多个其他条码选项包括许多国家的邮政编码、DotCode、EAN、EAN-14 和通用产品代码 (UPC)。[项目文档][2]中包含了它可以渲染的所有代码的完整列表。
|
||||
|
||||
你可以将任何条形码复制为 BMP 或 SVG,或者将输出保存为你应用中所需要的任何尺寸的图像文件。这是我的 77x77 像素的二维码。
|
||||
|
||||
![QR code][7]
|
||||
|
||||
该项目维护了一份出色的用户手册,其中包含了在[命令行][8]和 [GUI][9] 中使用 Zint 的说明。你甚至可以[在线][10]试用 Zint。对于功能请求或错误报告,请[访问网站][11]或[发送电子邮件][12]。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/2/zint-barcode-generator
|
||||
|
||||
作者:[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/wfh_work_home_laptop_work.png?itok=VFwToeMy (Working from home at a laptop)
|
||||
[2]: http://www.zint.org.uk/
|
||||
[3]: https://github.com/zint/zint
|
||||
[4]: http://www.zint.org.uk/Manual.aspx?type=p&page=2
|
||||
[5]: https://opensource.com/sites/default/files/uploads/zintqrcode_generation.png (Generating QR code with Zint)
|
||||
[6]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[7]: https://opensource.com/sites/default/files/uploads/zintqrcode_77px.png (QR code)
|
||||
[8]: http://zint.org.uk/Manual.aspx?type=p&page=4
|
||||
[9]: http://zint.org.uk/Manual.aspx?type=p&page=3
|
||||
[10]: http://www.barcode-generator.org/
|
||||
[11]: https://lists.sourceforge.net/lists/listinfo/zint-barcode
|
||||
[12]: mailto:zint-barcode@lists.sourceforge.net
|
@ -1,296 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (bestony)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (lawyer The MIT License, Line by Line)
|
||||
[#]: via: (https://writing.kemitchell.com/2016/09/21/MIT-License-Line-by-Line.html)
|
||||
[#]: author: (Kyle E. Mitchell https://kemitchell.com/)
|
||||
|
||||
lawyer The MIT License, Line by Line
|
||||
======
|
||||
|
||||
### The MIT License, Line by Line
|
||||
|
||||
[The MIT License][1] is the most popular open-source software license. Here’s one read of it, line by line.
|
||||
|
||||
#### Read the License
|
||||
|
||||
If you’re involved in open-source software and haven’t taken the time to read the license from top to bottom—it’s only 171 words—you need to do so now. Especially if licenses aren’t your day-to-day. Make a mental note of anything that seems off or unclear, and keep trucking. I’ll repeat every word again, in chunks and in order, with context and commentary. But it’s important to have the whole in mind.
|
||||
|
||||
> The MIT License (MIT)
|
||||
>
|
||||
> Copyright (c) <year> <copyright holders>
|
||||
>
|
||||
> 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.
|
||||
|
||||
The license is arranged in five paragraphs, but breaks down logically like this:
|
||||
|
||||
* **Header**
|
||||
* **License Title** : “The MIT License”
|
||||
* **Copyright Notice** : “Copyright (c) …”
|
||||
* **License Grant** : “Permission is hereby granted …”
|
||||
* **Grant Scope** : “… to deal in the Software …”
|
||||
* **Conditions** : “… subject to …”
|
||||
* **Attribution and Notice** : “The above … shall be included …”
|
||||
* **Warranty Disclaimer** : “The software is provided ‘as is’ …”
|
||||
* **Limitation of Liability** : “In no event …”
|
||||
|
||||
|
||||
|
||||
Here we go:
|
||||
|
||||
#### Header
|
||||
|
||||
##### License Title
|
||||
|
||||
> The MIT License (MIT)
|
||||
|
||||
“The MIT License” is a not a single license, but a family of license forms derived from language prepared for releases from the Massachusetts Institute of Technology. It has seen a lot of changes over the years, both for the original projects that used it, and also as a model for other projects. The Fedora Project maintains a [kind of cabinet of MIT license curiosities][2], with insipid variations preserved in plain text like anatomical specimens in formaldehyde, tracing a wayward kind of evolution.
|
||||
|
||||
Fortunately, the [Open Source Initiative][3] and [Software Package Data eXchange][4] groups have standardized a generic MIT-style license form as “The MIT License”. OSI in turn has adopted SPDX’ standardized [string identifiers][5] for common open-source licenses, with `MIT` pointing unambiguously to the standardized form “MIT License”. If you want MIT-style terms for a new project, use [the standardized form][1].
|
||||
|
||||
Even if you include “The MIT License” or “SPDX:MIT” in a `LICENSE` file, any responsible reviewer will still run a comparison of the text against the standard form, just to be sure. While various license forms calling themselves “MIT License” vary only in minor details, the looseness of what counts as an “MIT License” has tempted some authors into adding bothersome “customizations”. The canonical horrible, no good, very bad example of this is [the JSON license][6], an MIT-family license plus “The Software shall be used for Good, not Evil.”. This kind of thing might be “very Crockford”. It is definitely a pain in the ass. Maybe the joke was supposed to be on the lawyers. But they laughed all the way to the bank.
|
||||
|
||||
Moral of the story: “MIT License” alone is ambiguous. Folks probably have a good idea what you mean by it, but you’re only going to save everyone—yourself included—time by copying the text of the standard MIT License form into your project. If you use metadata, like the `license` property in package manager metadata files, to designate the `MIT` license, make sure your `LICENSE` file and any header comments use the standard form text. All of this can be [automated][7].
|
||||
|
||||
##### Copyright Notice
|
||||
|
||||
> Copyright (c) <year> <copyright holders>
|
||||
|
||||
Until the 1976 Copyright Act, United States copyright law required specific actions, called “formalities”, to secure copyright in creative works. If you didn’t follow those formalities, your rights to sue others for unauthorized use of your work were limited, often completely lost. One of those formalities was “notice”: Putting marks on your work and otherwise making it known to the market that you were claiming copyright. The © is a standard symbol for marking copyrighted works, to give notice of copyright. The ASCII character set doesn’t have the © symbol, but `Copyright (c)` gets the same point across.
|
||||
|
||||
The 1976 Copyright Act, which “implemented” many requirements of the international Berne Convention, eliminated formalities for securing copyright. At least in the United States, copyright holders still need to register their copyrighted works before suing for infringement, with potentially higher damages if they register before infringement begins. In practice, however, many register copyright right before bringing suit against someone in particular. You don’t lose your copyright just by failing to put notices on it, registering, sending a copy to the Library of Congress, and so on.
|
||||
|
||||
Even if copyright notices aren’t as absolutely necessary as they used to be, they are still plenty useful. Stating the year a work was authored and who the copyright belonged to give some sense of when copyright in the work might expire, bringing the work into the public domain. The identity of the author or authors is also useful: United States law calculates copyright terms differently for individual and “corporate” authors. Especially in business use, it may also behoove a company to think twice about using software from a known competitor, even if the license terms give very generous permission. If you’re hoping others will see your work and want to license it from you, copyright notices serve nicely for attribution.
|
||||
|
||||
As for “copyright holder”: Not all standard form licenses have a space to write this out. More recent license forms, like [Apache 2.0][8] and [GPL 3.0][9], publish `LICENSE` texts that are meant to be copied verbatim, with header comments and separate files elsewhere to indicate who owns copyright and is giving the license. Those approaches neatly discourage changes to the “standard” texts, accidental or intentional. They also make automated license identification more reliable.
|
||||
|
||||
The MIT License descends from language written for releases of code by institutions. For institutional releases, there was just one clear “copyright holder”, the institution releasing the code. Other institutions cribbed these licenses, replacing “MIT” with their own names, leading eventually to the generic forms we have now. This process repeated for other short-form institutional licenses of the era, notably the [original four-clause BSD License][10] for the University of California, Berkeley, now used in [three-clause][11] and [two-clause][12] variants, as well as [The ISC License][13] for the Internet Systems Consortium, an MIT variant.
|
||||
|
||||
In each case, the institution listed itself as the copyright holder in reliance on rules of copyright ownership, called “[works made for hire][14]” rules, that give employers and clients ownership of copyright in some work their employees and contractors do on their behalf. These rules don’t usually apply to distributed collaborators submitting code voluntarily. This poses a problem for project-steward foundations, like the Apache Foundation and Eclipse Foundation, that accept contributions from a more diverse group of contributors. The usual foundation approach thus far has been to use a house license that states a single copyright holder—[Apache 2.0][8] and [EPL 1.0][15]—backed up by contributor license agreements—[Apache CLAs][16] and [Eclipse CLAs][17]—to collect rights from contributors. Collecting copyright ownership in one place is even more important under “copyleft” licenses like the GPL, which rely on copyright owners to enforce license conditions to promote software-freedom values.
|
||||
|
||||
These days, loads of projects without any kind of institutional or business steward use MIT-style license terms. SPDX and OSI have helped these use cases by standardizing forms of licenses like MIT and ISC that don’t refer to a specific entity or institutional copyright holder. Armed with those forms, the prevailing practice of project authors is to fill their own name in the copyright notice of the form very early on … and maybe bump the year here and there. At least under United States copyright law, the resulting copyright notice doesn’t give a full picture.
|
||||
|
||||
The original owner of a piece of software retains ownership of their work. But while MIT-style license terms give others rights to build on and change the software, creating what the law calls “derivative works”, they don’t give the original author ownership of copyright in others’ contributions. Rather, each contributor has copyright in any [even marginally creative][18] work they make using the existing code as a starting point.
|
||||
|
||||
Most of these projects also balk at the idea of taking contributor license agreements, to say nothing of signed copyright assignments. That’s both naive and understandable. Despite the assumption of some newer open-source developers that sending a pull request on GitHub “automatically” licenses the contribution for distribution on the terms of the project’s existing license, United States law doesn’t recognize any such rule. Strong copyright protection, not permissive licensing, is the default.
|
||||
|
||||
Update: GitHub later changed its site-wide terms of service to include an attempt to flip this default, at least on GitHub.com. I’ve written up some thoughts on that development, not all of them positive, in [another post][19].
|
||||
|
||||
To fill the gap between legally effective, well-documented grants of rights in contributions and no paper trail at all, some projects have adopted the [Developer Certificate of Origin][20], a standard statement contributors allude to using `Signed-Off-By` metadata tags in their Git commits. The Developer Certificate of Origin was developed for Linux kernel development in the wake of the infamous SCO lawsuits, which alleged that chunks of Linux’ code derived from SCO-owned Unix source. As a means of creating a paper trail showing that each line of Linux came from a contributor, the Developer Certificate of Origin functions nicely. While the Developer Certificate of Origin isn’t a license, it does provide lots of good evidence that those submitting code expected the project to distribute their code, and for others to use it under the kernel’s existing license terms. The kernel also maintains a machine-readable `CREDITS` file listing contributors with name, affiliation, contribution area, and other metadata. I’ve done [some][21] [experiments][22] adapting that approach for projects that don’t use the kernel’s development flow.
|
||||
|
||||
#### License Grant
|
||||
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”),
|
||||
|
||||
The meat of The MIT License is, you guessed it, a license. In general terms, a license is permission that one person or legal entity—the “licensor”—gives another—the “licensee”—to do something the law would otherwise let them sue for. The MIT License is a promise not to sue.
|
||||
|
||||
The law sometimes distinguishes licenses from promises to give licenses. If someone breaks a promise to give a license, you may be able to sue them for breaking their promise, but you may not end up with a license. “Hereby” is one of those hokey, archaic-sounding words lawyers just can’t get rid of. It’s used here to show that the license text itself gives the license, and not just a promise of a license. It’s a legal [IIFE][23].
|
||||
|
||||
While many licenses give permission to a specific, named licensee, The MIT License is a “public license”. Public licenses give everybody—the public at large—permission. This is one of the three great ideas in open-source licensing. The MIT License captures this idea by giving a license “to any person obtaining a copy of … the Software”. As we’ll see later, there is also a condition to receiving this license that ensures others will learn about their permission, too.
|
||||
|
||||
The parenthetical with a capitalized term in quotation marks (a “Definition”), is the standard way to give terms specific meanings in American-style legal documents. Courts will reliably look back to the terms of the definition when they see a defined, capitalized term used elsewhere in the document.
|
||||
|
||||
##### Grant Scope
|
||||
|
||||
> to deal in the Software without restriction,
|
||||
|
||||
From the licensee’s point of view, these are the seven most important words in The MIT License. The key legal concerns are getting sued for copyright infringement and getting sued for patent infringement. Neither copyright law nor patent law uses “to deal in” as a term of art; it has no specific meaning in court. As a result, any court deciding a dispute between a licensor and a licensee would ask what the parties meant and understood by this language. What the court will see is that the language is intentionally broad and open-ended. It gives licensees a strong argument against any claim by a licensor that they didn’t give permission for the licensee to do that specific thing with the software, even if the thought clearly didn’t occur to either side when the license was given.
|
||||
|
||||
> 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,
|
||||
|
||||
No piece of legal writing is perfect, “fully settled in meaning”, or unmistakably clear. Beware anyone who pretends otherwise. This is the least perfect part of The MIT License. There are three main issues:
|
||||
|
||||
First, “including without limitation” is a legal antipattern. It crops up in any number of flavors:
|
||||
|
||||
* “including, without limitation”
|
||||
* “including, without limiting the generality of the foregoing”
|
||||
* “including, but not limited to”
|
||||
* many, many pointless variations
|
||||
|
||||
|
||||
|
||||
All of these share a common purpose, and they all fail to achieve it reliably. Fundamentally, drafters who use them try to have their cake and eat it, too. In The MIT License, that means introducing specific examples of “dealing in the Software”—“use, copy, modify” and so on—without implying that licensee action has to be something like the examples given to count as “dealing in”. The trouble is that, if you end up needing a court to review and interpret the terms of a license, the court will see its job as finding out what those fighting meant by the language. If the court needs to decide what “deal in” means, it cannot “unsee” the examples, even if you tell it to. I’d argue that “deal in the Software without restriction” alone would be better for licensees. Also shorter.
|
||||
|
||||
Second, the verbs given as examples of “deal in” are a hodgepodge. Some have specific meanings under copyright or patent law, others almost do or just plain don’t:
|
||||
|
||||
* use appears in [United States Code title 35, section 271(a)][24], the patent law’s list of what patent owners can sue others for doing without permission.
|
||||
|
||||
* copy appears in [United States Code title 17, section 106][25], the copyright law’s list of what copyright owners can sue others for doing without permission.
|
||||
|
||||
* modify doesn’t appear in either copyright or patent statute. It is probably closest to “prepare derivative works” under the copyright statute, but may also implicate improving or otherwise derivative inventions.
|
||||
|
||||
* merge doesn’t appear in either copyright or patent statute. “Merger” has a specific meaning in copyright, but that’s clearly not what’s intended here. Rather, a court would probably read “merge” according to its meaning in industry, as in “to merge code”.
|
||||
|
||||
* publish doesn’t appear in either copyright or patent statute. Since “the Software” is what’s being published, it probably hews closest to “distribute” under the [copyright statute][25]. That statute also covers rights to perform and display works “publicly”, but those rights apply only to specific kinds of copyrighted work, like plays, sound recordings, and motion pictures.
|
||||
|
||||
* distribute appears in the [copyright statute][25].
|
||||
|
||||
* sublicense is a general term of intellectual property law. The right to sublicense means the right to give others licenses of their own, to do some or all of what you have permission to do. The MIT License’s right to sublicense is actually somewhat unusual in open-source licenses generally. The norm is what Heather Meeker calls a “direct licensing” approach, where everyone who gets a copy of the software and its license terms gets a license direct from the owner. Anyone who might get a sublicense under the MIT License will probably end up with a copy of the license telling them they have a direct license, too.
|
||||
|
||||
* sell copies of is a mongrel. It is close to “offer to sell” and “sell” in the [patent statute][24], but refers to “copies”, a copyright concept. On the copyright side, it seems close to “distribute”, but the [copyright statute][25] makes no mention of sales.
|
||||
|
||||
* permit persons to whom the Software is furnished to do so seems redundant of “sublicense”. It’s also unnecessary to the extent folks who get copies also get a direct license.
|
||||
|
||||
|
||||
|
||||
|
||||
Lastly, as a result of this mishmash of legal, industry, general-intellectual-property, and general-use terms, it isn’t clear whether The MIT License includes a patent license. The general language “deal in” and some of the example verbs, especially “use”, point toward a patent license, albeit a very unclear one. The fact that the license comes from the copyright holder, who may or may not have patent rights in inventions in the software, as well as most of the example verbs and the definition of “the Software” itself, all point strongly toward a copyright license. More recent permissive open-source licenses, like [Apache 2.0][8], address copyright, patent, and even trademark separately and specifically.
|
||||
|
||||
##### Three License Conditions
|
||||
|
||||
> subject to the following conditions:
|
||||
|
||||
There’s always a catch! MIT has three!
|
||||
|
||||
If you don’t follow The MIT License’s conditions, you don’t get the permission the license offers. So failing to do what the conditions say at least theoretically leaves you open to a lawsuit, probably a copyright lawsuit.
|
||||
|
||||
Using the value of the software to the licensee to motivate compliance with conditions, even though the licensee paid nothing for the license, is the second great idea of open-source licensing. The last, not found in The MIT License, builds off license conditions: “Copyleft” licenses like the [GNU General Public License][9] use license conditions to control how those making changes can license and distribute their changed versions.
|
||||
|
||||
##### Notice Condition
|
||||
|
||||
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
If you give someone a copy of the software, you need to include the license text and any copyright notice. This serves a few critical purposes:
|
||||
|
||||
1. Gives others notice that they have permission for the software under the public license. This is a key part of the direct-licensing model, where each user gets a license direct from the copyright holder.
|
||||
|
||||
2. Makes known who’s behind the software, so they can be showered in praises, glory, and cold, hard cash donations.
|
||||
|
||||
3. Ensures the warranty disclaimer and limitation of liability (coming up next) follow the software around. Everyone who gets a copy should get a copy of those licensor protections, too.
|
||||
|
||||
|
||||
|
||||
|
||||
There’s nothing to stop you charging for providing a copy, or even a copy in compiled form, without source code. But when you do, you can’t pretend that the MIT code is your own proprietary code, or provided under some other license. Those receiving get to know their rights under the “public license”.
|
||||
|
||||
Frankly, compliance with this condition is breaking down. Nearly every open-source license has such an “attribution” condition. Makers of system and installed software often understand they’ll need to compile a notices file or “license information” screen, with copies of license texts for libraries and components, for each release of their own. The project-steward foundations have been instrumental in teaching those practices. But web developers, as a whole, haven’t got the memo. It can’t be explained away by a lack of tooling—there is plenty—or the highly modular nature of packages from npm and other repositories—which uniformly standardize metadata formats for license information. All the good JavaScript minifiers have command-line flags for preserving license header comments. Other tools will concatenate `LICENSE` files from package trees. There’s really no excuse.
|
||||
|
||||
##### Warranty Disclaimer
|
||||
|
||||
> 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.
|
||||
|
||||
Nearly every state in the United States has enacted a version of the Uniform Commercial Code, a model statute of laws governing commercial transactions. Article 2 of the UCC—“Division 2” in California—governs contracts for sales of goods, from used automobiles bought off the lot to large shipments of industrial chemicals to manufacturing plants.
|
||||
|
||||
Some of the UCC’s rules about sales contracts are mandatory. These rules always apply, whether those buying and selling like them or not. Others are just “defaults”. Unless buyers and sellers opt out in writing, the UCC implies that they want the baseline rule found in the UCC’s text for their deal. Among the default rules are implied “warranties”, or promises by sellers to buyers about the quality and usability of the goods being sold.
|
||||
|
||||
There is a big theoretical debate about whether public licenses like The MIT License are contracts—enforceable agreements between licensors and licensees—or just licenses, which go one way, but may come with strings attached, their conditions. There is less debate about whether software counts as “goods”, triggering the UCC’s rules. There is no debate among licensors on liability: They don’t want to get sued for lots of money if the software they give away for free breaks, causes problems, doesn’t work, or otherwise causes trouble. That’s exactly the opposite of what three default rules for “implied warranties” do:
|
||||
|
||||
1. The implied warranty of “merchantability” under [UCC section 2-314][26] is a promise that “the goods”—the Software—are of at least average quality, properly packaged and labeled, and fit for the ordinary purposes they are intended to serve. This warranty applies only if the one giving the software is a “merchant” with respect to the software, meaning they deal in software and hold themselves out as skilled in software.
|
||||
|
||||
2. The implied warranty of “fitness for a particular purpose” under [UCC section 2-315][27] kicks in when the seller knows the buyer is relying on them to provide goods for a particular purpose. The goods need to actually be “fit” for that purpose.
|
||||
|
||||
3. The implied warranty of “noninfringement” is not part of the UCC, but is a common feature of general contract law. This implied promise protects the buyer if it turns out the goods they received infringe somebody else’s intellectual property rights. That would be the case if the software under The MIT License didn’t actually belong to the one trying to license it, or if it fell under a patent owned by someone else.
|
||||
|
||||
|
||||
|
||||
|
||||
[Section 2-316(3)][28] of the UCC requires language opting out of, or “excluding”, implied warranties of merchantability and fitness for a particular purpose to be conspicuous. “Conspicuous” in turn means written or formatted to call attention to itself, the opposite of microscopic fine print meant to slip past unwary consumers. State law may impose a similar attention-grabbing requirement for disclaimers of noninfringement.
|
||||
|
||||
Lawyers have long suffered under the delusion that writing anything in `ALL-CAPS` meets the conspicuous requirement. That isn’t true. Courts have criticized the Bar for pretending as much, and most everyone agrees all-caps does more to discourage reading than compel it. All the same, most open-source-license forms set their warranty disclaimers in all-caps, in part because that’s the only obvious way to make it stand out in plain-text `LICENSE` files. I’d prefer to use asterisks or other ASCII art, but that ship sailed long, long ago.
|
||||
|
||||
##### Limitation of Liability
|
||||
|
||||
> 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.
|
||||
|
||||
The MIT License gives permission for software “free of charge”, but the law does not assume that folks receiving licenses free of charge give up their rights to sue when things go wrong and the licensor is to blame. “Limitations of liability”, often paired with “damages exclusions”, work a lot like licenses, as promises not to sue. But these are protections for the licensor against lawsuits by licensees.
|
||||
|
||||
In general, courts read limitations of liability and damages exclusions warily, since they can shift an incredible amount of risk from one side to another. To protect the community’s vital interest in giving folks a way to redress wrongs done in court, they “strictly construe” language limiting liability, reading it against the one protected by it where possible. Limitations of liability have to be specific to stand up. Especially in “consumer” contracts and other situations where those giving up the right to sue lack sophistication or bargaining power, courts have sometimes refused to honor language that seemed buried out of sight. Partly for that reason, partly by sheer force of habit, lawyers tend to give limits of liability the all-caps treatment, too.
|
||||
|
||||
Drilling down a bit, the “limitation of liability” part is a cap on the amount of money a licensee can sue for. In open-source licenses, that limit is always no money at all, $0, “not liable”. By contrast, in commercial licenses, it’s often a multiple of license fees paid in the last 12-month period, though it’s often negotiated.
|
||||
|
||||
The “exclusion” part lists, specifically, kinds of legal claims—reasons to sue for damages—the licensor cannot use. Like many, many legal forms, The MIT License mentions actions “of contract”—for breaching a contract—and “of tort”. Tort rules are general rules against carelessly or maliciously harming others. If you run someone down on the road while texting, you have committed a tort. If your company sells faulty headphones that burn peoples’ ears off, your company has committed a tort. If a contract doesn’t specifically exclude tort claims, courts sometimes read exclusion language in a contract to prevent only contract claims. For good measure, The MIT License throws in “or otherwise”, just to catch the odd admiralty law or other, exotic kind of legal claim.
|
||||
|
||||
The phrase “arising from, out of or in connection with” is a recurring tick symptomatic of the legal draftsman’s inherent, anxious insecurity. The point is that any lawsuit having anything to do with the software is covered by the limitation and exclusions. On the off chance something can “arise from”, but not “out of”, or “in connection with”, it feels better to have all three in the form, so pack ‘em in. Never mind that any court forced to split hairs in this part of the form will have to come up with different meanings for each, on the assumption that a professional drafter wouldn’t use different words in a row to mean the same thing. Never mind that in practice, where courts don’t feel good about a limitation that’s disfavored to begin with, they’ll be more than ready to read the scope trigger narrowly. But I digress. The same language appears in literally millions of contracts.
|
||||
|
||||
#### Overall
|
||||
|
||||
All these quibbles are a bit like spitting out gum on the way into church. The MIT License is a legal classic. The MIT License works. It is by no means a panacea for all software IP ills, in particular the software patent scourge, which it predates by decades. But MIT-style licenses have served admirably, fulfilling a narrow purpose—reversing troublesome default rules of copyright, sales, and contract law—with a minimal combination of discreet legal tools. In the greater context of computing, its longevity is astounding. The MIT License has outlasted and will outlast the vast majority of software licensed under it. We can only guess how many decades of faithful legal service it will have given when it finally loses favor. It’s been especially generous to those who couldn’t have afforded their own lawyer.
|
||||
|
||||
We’ve seen how the The MIT License we know today is a specific, standardized set of terms, bringing order at long last to a chaos of institution-specific, haphazard variations.
|
||||
|
||||
We’ve seen how its approach to attribution and copyright notice informed intellectual property management practices for academic, standards, commercial, and foundation institutions.
|
||||
|
||||
We’ve seen how The MIT Licenses grants permission for software to all, for free, subject to conditions that protect licensors from warranties and liability.
|
||||
|
||||
We’ve seen that despite some crusty verbiage and lawyerly affectation, one hundred and seventy one little words can get a hell of a lot of legal work done, clearing a path for open-source software through a dense underbrush of intellectual property and contract.
|
||||
|
||||
I’m so grateful for all who’ve taken the time to read this rather long post, to let me know they found it useful, and to help improve it. As always, I welcome your comments via [e-mail][29], [Twitter][30], and [GitHub][31].
|
||||
|
||||
A number of folks have asked where they can read more, or find run-downs of other licenses, like the GNU General Public License or the Apache 2.0 license. No matter what your particular continuing interest may be, I heartily recommend the following books:
|
||||
|
||||
* Andrew M. St. Laurent’s [Understanding Open Source & Free Software Licensing][32], from O’Reilly.
|
||||
|
||||
I start with this one because, while it’s somewhat dated, its approach is also closest to the line-by-line approach used above. O’Reilly has made it [available online][33].
|
||||
|
||||
* Heather Meeker’s [Open (Source) for Business][34]
|
||||
|
||||
In my opinion, by far the best writing on the GNU General Public License and copyleft more generally. This book covers the history, the licenses, their development, as well as compatibility and compliance. It’s the book I lend to clients considering or dealing with the GPL.
|
||||
|
||||
* Larry Rosen’s [Open Source Licensing][35], from Prentice Hall.
|
||||
|
||||
A great first book, also available for free [online][36]. This is the best introduction to open-source licensing and related law for programmers starting from scratch. This one is also a bit dated in some specific details, but Larry’s taxonomy of licenses and succinct summary of open-source business models stand the test of time.
|
||||
|
||||
|
||||
|
||||
|
||||
All of these were crucial to my own education as an open-source licensing lawyer. Their authors are professional heroes of mine. Have a read! — K.E.M
|
||||
|
||||
I license this article under a [Creative Commons Attribution-ShareAlike 4.0 license][37].
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://writing.kemitchell.com/2016/09/21/MIT-License-Line-by-Line.html
|
||||
|
||||
作者:[Kyle E. Mitchell][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[bestony](https://github.com/bestony)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://kemitchell.com/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: http://spdx.org/licenses/MIT
|
||||
[2]: https://fedoraproject.org/wiki/Licensing:MIT?rd=Licensing/MIT
|
||||
[3]: https://opensource.org
|
||||
[4]: https://spdx.org
|
||||
[5]: http://spdx.org/licenses/
|
||||
[6]: https://spdx.org/licenses/JSON
|
||||
[7]: https://www.npmjs.com/package/licensor
|
||||
[8]: https://www.apache.org/licenses/LICENSE-2.0
|
||||
[9]: https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||
[10]: http://spdx.org/licenses/BSD-4-Clause
|
||||
[11]: https://spdx.org/licenses/BSD-3-Clause
|
||||
[12]: https://spdx.org/licenses/BSD-2-Clause
|
||||
[13]: http://www.isc.org/downloads/software-support-policy/isc-license/
|
||||
[14]: http://worksmadeforhire.com/
|
||||
[15]: https://www.eclipse.org/legal/epl-v10.html
|
||||
[16]: https://www.apache.org/licenses/#clas
|
||||
[17]: https://wiki.eclipse.org/ECA
|
||||
[18]: https://en.wikipedia.org/wiki/Feist_Publications,_Inc.,_v._Rural_Telephone_Service_Co.
|
||||
[19]: https://writing.kemitchell.com/2017/02/16/Against-Legislating-the-Nonobvious.html
|
||||
[20]: http://developercertificate.org/
|
||||
[21]: https://github.com/berneout/berneout-pledge
|
||||
[22]: https://github.com/berneout/authors-certificate
|
||||
[23]: https://en.wikipedia.org/wiki/Immediately-invoked_function_expression
|
||||
[24]: https://www.govinfo.gov/app/details/USCODE-2017-title35/USCODE-2017-title35-partIII-chap28-sec271
|
||||
[25]: https://www.govinfo.gov/app/details/USCODE-2017-title17/USCODE-2017-title17-chap1-sec106
|
||||
[26]: https://leginfo.legislature.ca.gov/faces/codes_displaySection.xhtml?sectionNum=2314.&lawCode=COM
|
||||
[27]: https://leginfo.legislature.ca.gov/faces/codes_displaySection.xhtml?sectionNum=2315.&lawCode=COM
|
||||
[28]: https://leginfo.legislature.ca.gov/faces/codes_displaySection.xhtml?sectionNum=2316.&lawCode=COM
|
||||
[29]: mailto:kyle@kemitchell.com
|
||||
[30]: https://twitter.com/kemitchell
|
||||
[31]: https://github.com/kemitchell/writing/tree/master/_posts/2016-09-21-MIT-License-Line-by-Line.md
|
||||
[32]: https://lccn.loc.gov/2006281092
|
||||
[33]: http://www.oreilly.com/openbook/osfreesoft/book/
|
||||
[34]: https://www.amazon.com/dp/1511617772
|
||||
[35]: https://lccn.loc.gov/2004050558
|
||||
[36]: http://www.rosenlaw.com/oslbook.htm
|
||||
[37]: https://creativecommons.org/licenses/by-sa/4.0/legalcode
|
@ -92,7 +92,7 @@ via: https://twobithistory.org/2017/09/28/the-lineage-of-man.html
|
||||
|
||||
作者:[Two-Bit History][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[bestony](https://github.com/bestony)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,78 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Where are all the IoT experts going to come from?)
|
||||
[#]: via: (https://www.networkworld.com/article/3404489/where-are-all-the-iot-experts-going-to-come-from.html)
|
||||
[#]: author: (Fredric Paul https://www.networkworld.com/author/Fredric-Paul/)
|
||||
|
||||
Where are all the IoT experts going to come from?
|
||||
======
|
||||
The fast growth of the internet of things (IoT) is creating a need to train cross-functional experts who can combine traditional networking and infrastructure expertise with database and reporting skills.
|
||||
![Kevin \(CC0\)][1]
|
||||
|
||||
If the internet of things (IoT) is going to fulfill its enormous promise, it’s going to need legions of smart, skilled, _trained_ workers to make everything happen. And right now, it’s not entirely clear where those people are going to come from.
|
||||
|
||||
That’s why I was interested in trading emails with Keith Flynn, senior director of product management, R&D at asset-optimization software company [AspenTech][2], who says that when dealing with the slew of new technologies that fall under the IoT umbrella, you need people who can understand how to configure the technology and interpret the data. Flynn sees a growing need for existing educational institutions to house IoT-specific programs, as well as an opportunity for new IoT-focused private colleges, offering a well -ounded curriculum
|
||||
|
||||
“In the future,” Flynn told me, “IoT projects will differ tremendously from the general data management and automation projects of today. … The future requires a more holistic set of skills and cross-trading capabilities so that we’re all speaking the same language.”
|
||||
|
||||
**[ Also read: [20 hot jobs ambitious IT pros should shoot for][3] ]**
|
||||
|
||||
With the IoT growing 30% a year, Flynn added, rather than a few specific skills, “everything from traditional deployment skills, like networking and infrastructure, to database and reporting skills and, frankly, even basic data science, need to be understood together and used together.”
|
||||
|
||||
### Calling all IoT consultants
|
||||
|
||||
“The first big opportunity for IoT-educated people is in the consulting field,” Flynn predicted. “As consulting companies adapt or die to the industry trends … having IoT-trained people on staff will help position them for IoT projects and make a claim in the new line of business: IoT consulting.”
|
||||
|
||||
The problem is especially acute for startups and smaller companies. “The bigger the organization, the more likely they have a means to hire different people across different lines of skillsets,” Flynn said. “But for smaller organizations and smaller IoT projects, you need someone who can do both.”
|
||||
|
||||
Both? Or _everything?_ The IoT “requires a combination of all knowledge and skillsets,” Flynn said, noting that “many of the skills aren’t new, they’ve just never been grouped together or taught together before.”
|
||||
|
||||
**[ [Looking to upgrade your career in tech? This comprehensive online course teaches you how.][4] ]**
|
||||
|
||||
### The IoT expert of the future
|
||||
|
||||
True IoT expertise starts with foundational instrumentation and electrical skills, Flynn said, which can help workers implement new wireless transmitters and boost technology for better battery life and power consumption.
|
||||
|
||||
“IT skills, like networking, IP addressing, subnet masks, cellular and satellite are also pivotal IoT needs,” Flynn said. He also sees a need for database management skills and cloud management and security expertise, “especially as things like [advanced process control] APC and sending sensor data directly to databases and data lakes become the norm.”
|
||||
|
||||
### Where will IoT experts come from?
|
||||
|
||||
Flynn said standardized formal education courses would be the best way to make sure that graduates or certificate holders have the right set of skills. He even laid out a sample curriculum: “Start in chronological order with the basics like [Electrical & Instrumentation] E&I and measurement. Then teach networking, and then database administration and cloud courses should follow that. This degree could even be looped into an existing engineering course, and it would probably take two years … to complete the IoT component.”
|
||||
|
||||
While corporate training could also play role, “that’s easier said than done,” Flynn warned. “Those trainings will need to be organization-specific efforts and pushes.”
|
||||
|
||||
Of course, there are already [plenty of online IoT training courses and certificate programs][5]. But, ultimately, the responsibility lies with the workers themselves.
|
||||
|
||||
“Upskilling is incredibly important in this world as tech continues to transform industries,” Flynn said. “If that upskilling push doesn’t come from your employer, then online courses and certifications would be an excellent way to do that for yourself. We just need those courses to be created. ... I could even see organizations partnering with higher-education institutions that offer these courses to give their employees better access to it. Of course, the challenge with an IoT program is that it will need to constantly evolve to keep up with new advancements in tech.”
|
||||
|
||||
**[ For more on IoT, see [tips for securing IoT on your network][6], our list of [the most powerful internet of things companies][7] and learn about the [industrial internet of things][8]. | Get regularly scheduled insights by [signing up for Network World newsletters][9]. ]**
|
||||
|
||||
Join the Network World communities on [Facebook][10] and [LinkedIn][11] to comment on topics that are top of mind.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3404489/where-are-all-the-iot-experts-going-to-come-from.html
|
||||
|
||||
作者:[Fredric Paul][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.networkworld.com/author/Fredric-Paul/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://images.idgesg.net/images/article/2018/07/programmer_certification-skills_code_devops_glasses_student_by-kevin-unsplash-100764315-large.jpg
|
||||
[2]: https://www.aspentech.com/
|
||||
[3]: https://www.networkworld.com/article/3276025/careers/20-hot-jobs-ambitious-it-pros-should-shoot-for.html
|
||||
[4]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fupgrading-your-technology-career
|
||||
[5]: https://www.google.com/search?client=firefox-b-1-d&q=iot+training
|
||||
[6]: https://www.networkworld.com/article/3254185/internet-of-things/tips-for-securing-iot-on-your-network.html#nww-fsb
|
||||
[7]: https://www.networkworld.com/article/2287045/internet-of-things/wireless-153629-10-most-powerful-internet-of-things-companies.html#nww-fsb
|
||||
[8]: https://www.networkworld.com/article/3243928/internet-of-things/what-is-the-industrial-iot-and-why-the-stakes-are-so-high.html#nww-fsb
|
||||
[9]: https://www.networkworld.com/newsletters/signup.html#nww-fsb
|
||||
[10]: https://www.facebook.com/NetworkWorld/
|
||||
[11]: https://www.linkedin.com/company/network-world
|
@ -0,0 +1,72 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (7 ways open source was essential to business in 2020)
|
||||
[#]: via: (https://opensource.com/article/21/1/open-source-business)
|
||||
[#]: author: (Jessica Cherry https://opensource.com/users/cherrybomb)
|
||||
|
||||
7 ways open source was essential to business in 2020
|
||||
======
|
||||
Moving work online created challenges and opportunities for innovation
|
||||
in 2020.
|
||||
![A chair in a field.][1]
|
||||
|
||||
The COVID-19 pandemic created many new challenges for businesses in 2020 as they rapidly moved non-essential workers to remote operations. However, it also created tremendous opportunities for innovation as people searched for effective ways to work and collaborate virtually.
|
||||
|
||||
Opensource.com responded to the need by publishing a variety of articles in 2020 on working better with open source. Since it appears working remotely is here to stay for the foreseeable future, make sure you're doing everything you can to adapt by reading the top seven articles about open source business from 2020.
|
||||
|
||||
### Open source live streaming with Open Broadcaster Software
|
||||
|
||||
If you want to start reaching your customers with live streaming, Seth Kenlon's article on [open source live streaming][2] explains how to use Open Broadcaster Software (OBS) to connect to various streaming services to share your skills or gameplay. He outlines OBS and offers a detailed walk-through of its installation and use, making your start in streaming quick and easy. Seth also explains how to connect your devices to a streaming server and shares a powerful message about the value of teaching others and broadcasting words of encouragement.
|
||||
|
||||
### Manage knowledge with BlueSpice, an open source alternative to Confluence
|
||||
|
||||
Most enterprises have a wiki for sharing and managing knowledge across their teams. Instead of risking vendor lock-in with proprietary software, Martin Loschwitz recommends [considering BlueSpice][3], an open source alternative to Confluence. He covers the structural differences between BlueSpice and Confluence, how to use the optional BlueSpice Farm to connect multiple wikis, and BlueSpice's amazing search capabilities that use Elasticsearch to enable narrower searches. Martin also gets into BlueSpice's compliance and security features, editor functions, extensions, and design features that match your wiki to your company's branding.
|
||||
|
||||
### Choosing open source as a marketing strategy
|
||||
|
||||
Lucas Galvanni and Nathalie Risbakk discuss how to use [open source in your marketing strategy][4]. They use the example of Brewdog, which opened its beer recipes to the public, a strategy that paid off by making the brand extremely popular with the homebrewing community. They also cover developing marketing strategies based on customers' needs and desires and explain how moving their company to an open source model helped it engage with the community. Finally, they get into the challenges, risks, and rewards of open source with some final notes about building success over time.
|
||||
|
||||
### 7 Ways NOT to manage your remote team
|
||||
|
||||
Matt Shealy says [remote teams are susceptible to miscommunication][5], but rethinking how things have always been done can help avoid disaster. His tips include continuous training on technical and emotional topics, creating standards around communications in remote chat systems, and keeping work on schedule. Matt also recommends keeping your eye on the big picture with goals and milestones, avoiding micromanagement, and promoting diversity to leverage different viewpoints and help teams shine. He also describes the benefits and barriers of teams working across different time zones and recommends keeping your eye on costs to find a middle ground to keep trust between IT and finance teams.
|
||||
|
||||
### 5 humans review 5 open source video chat tools
|
||||
|
||||
During the lockdowns in summer 2020, Opensource.com writers Matt Broberg, Alan Formy-Duval, Chris Hermansen, Seth Kenlon, and I joined forces to [review open source video chat tools][6]. We looked at the tools' security risks, capabilities, and performance, considering our various locations and internet quality, to discover what's out there in open source video-conferencing solutions. This review may give you new ideas on tools to improve your video chats.
|
||||
|
||||
### Love or hate chat? 4 best practices for remote teams
|
||||
|
||||
To help the many teams working remotely, Jen Wike Huger offers [best practices for using chat][7] in your day-to-day life. Before getting into her tips, Jen recommends asking team members about their comfort level using chat to keep in touch during the workday. Next, she offers best practices, including creating rooms and threads, setting expectations around when people are expected to respond (or not) in chat, and communicating clearly and kindly.
|
||||
|
||||
### The FSF reveals the tools they use for chat, video, and more
|
||||
|
||||
The Free Software Foundation's Greg Farough shares the [software the organization uses for remote communications][8]. He explains that self-reliance on some of the tools (by self-hosting or having a friend or colleague host them) can be difficult but beneficial. He concludes by saying, "This is just a small selection of the huge amount of free software out there, all ready to be used, shared, and improved by the community," and asks the community to share knowledge "to help people find ways of communicating that put user freedom as a priority."
|
||||
|
||||
### 2020: The year open source remote business became essential
|
||||
|
||||
These seven articles offer many suggestions for teams working remotely and which open source tools will help them do it better. In 2020, open source software proved its value for expanding and improving work across great distances. And these tools will remain key business enablers in 2021, as many of us continue working from home.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/open-source-business
|
||||
|
||||
作者:[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/BIZ_WorkInPublic_4618517_1110_CS_A.png?itok=RwVrWArk (A chair in a field.)
|
||||
[2]: https://opensource.com/article/20/4/open-source-live-stream
|
||||
[3]: https://opensource.com/article/20/9/bluespice
|
||||
[4]: https://opensource.com/article/20/7/open-source-marketing
|
||||
[5]: https://opensource.com/article/20/1/ways-not-manage-remote-team
|
||||
[6]: https://opensource.com/article/20/5/open-source-video-conferencing
|
||||
[7]: https://opensource.com/article/20/4/chat-tools-best-practices
|
||||
[8]: https://opensource.com/article/20/5/free-software-communication
|
263
sources/talk/20210207 The Real Novelty of the ARPANET.md
Normal file
263
sources/talk/20210207 The Real Novelty of the ARPANET.md
Normal file
@ -0,0 +1,263 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (The Real Novelty of the ARPANET)
|
||||
[#]: via: (https://twobithistory.org/2021/02/07/arpanet.html)
|
||||
[#]: author: (Two-Bit History https://twobithistory.org)
|
||||
|
||||
The Real Novelty of the ARPANET
|
||||
======
|
||||
|
||||
If you run an image search for the word “ARPANET,” you will find lots of maps showing how the [government research network][1] expanded steadily across the country throughout the late ’60s and early ’70s. I’m guessing that most people reading or hearing about the ARPANET for the first time encounter one of these maps.
|
||||
|
||||
Obviously, the maps are interesting—it’s hard to believe that there were once so few networked computers that their locations could all be conveyed with what is really pretty lo-fi cartography. (We’re talking 1960s overhead projector diagrams here. You know the vibe.) But the problem with the maps, drawn as they are with bold lines stretching across the continent, is that they reinforce the idea that the ARPANET’s paramount achievement was connecting computers across the vast distances of the United States for the first time.
|
||||
|
||||
Today, the internet is a lifeline that keeps us tethered to each other even as an airborne virus has us all locked up indoors. So it’s easy to imagine that, if the ARPANET was the first draft of the internet, then surely the world that existed before it was entirely disconnected, since that’s where we’d be without the internet today, right? The ARPANET must have been a big deal because it connected people via computers when that hadn’t before been possible.
|
||||
|
||||
That view doesn’t get the history quite right. It also undersells what made the ARPANET such a breakthrough.
|
||||
|
||||
### The Debut
|
||||
|
||||
The Washington Hilton stands near the top of a small rise about a mile and a half northeast of the National Mall. Its two white-painted modern facades sweep out in broad semicircles like the wings of a bird. The New York Times, reporting on the hotel’s completion in 1965, remarked that the building looks “like a sea gull perched on a hilltop nest.”[1][2]
|
||||
|
||||
The hotel hides its most famous feature below ground. Underneath the driveway roundabout is an enormous ovoid event space known as the International Ballroom, which was for many years the largest pillar-less ballroom in DC. In 1967, the Doors played a concert there. In 1968, Jimi Hendrix also played a concert there. In 1972, a somewhat more sedate act took over the ballroom to put on the inaugural International Conference on Computing Communication, where a promising research project known as the ARPANET was demonstrated publicly for the first time.
|
||||
|
||||
The 1972 ICCC, which took place from October 24th to 26th, was attended by about 800 people.[2][3] It brought together all of the leading researchers in the nascent field of computer networking. According to internet pioneer Bob Kahn, “if somebody had dropped a bomb on the Washington Hilton, it would have destroyed almost all of the networking community in the US at that point.”[3][4]
|
||||
|
||||
Not all of the attendees were computer scientists, however. An advertisement for the conference claimed it would be “user-focused” and geared toward “lawyers, medical men, economists, and government men as well as engineers and communicators.”[4][5] Some of the conference’s sessions were highly technical, such as the session titled “Data Network Design Problems I” and its sequel session, “Data Network Design Problems II.” But most of the sessions were, as promised, focused on the potential social and economic impacts of computer networking. One session, eerily prescient today, sought to foster a discussion about how the legal system could act proactively “to safeguard the right of privacy in the computer data bank.”[5][6]
|
||||
|
||||
The ARPANET demonstration was intended as a side attraction of sorts for the attendees. Between sessions, which were held either in the International Ballroom or elsewhere on the lower level of the hotel, attendees were free to wander into the Georgetown Ballroom (a smaller ballroom/conference room down the hall from the big one),[6][7] where there were 40 terminals from a variety of manufacturers set up to access the ARPANET.[7][8] These terminals were dumb terminals—they only handled input and output and could do no computation on their own. (In fact, in 1972, it’s likely that all of these terminals were hardcopy terminals, i.e. teletype machines.) The terminals were all hooked up to a computer known as a Terminal Interface Message Processor or TIP, which sat on a raised platform in the middle of the room. The TIP was a kind of archaic router specially designed to connect dumb terminals to the ARPANET. Using the terminals and the TIP, the ICCC attendees could experiment with logging on and accessing some of the computers at the 29 host sites then comprising the ARPANET.[8][9]
|
||||
|
||||
To exhibit the network’s capabilities, researchers at the host sites across the country had collaborated to prepare 19 simple “scenarios” for users to experiment with. These scenarios were compiled into [a booklet][10] that was handed to conference attendees as they tentatively approached the maze of wiring and terminals.[9][11] The scenarios were meant to prove that the new technology worked but also that it was useful, because so far the ARPANET was “a highway system without cars,” and its Pentagon funders hoped that a public demonstration would excite more interest in the network.[10][12]
|
||||
|
||||
The scenarios thus showed off a diverse selection of the software that could be accessed over the ARPANET: There were programming language interpreters, one for a Lisp-based language at MIT and another for a numerical computing environment called Speakeasy hosted at UCLA; there were games, including a chess program and an implementation of Conway’s Game of Life; and—perhaps most popular among the conference attendees—there were several AI chat programs, including the famous ELIZA chat program developed at MIT by Joseph Weizenbaum.
|
||||
|
||||
The researchers who had prepared the scenarios were careful to list each command that users were expected to enter at their terminals. This was especially important because the sequence of commands used to connect to any given ARPANET host could vary depending on the host in question. To experiment with the AI chess program hosted on the MIT Artificial Intelligence Laboratory’s PDP-10 minicomputer, for instance, conference attendees were instructed to enter the following:
|
||||
|
||||
_`[LF]`, `[SP]`, and `[CR]` below stand for the line feed, space, and carriage return keys respectively. I’ve explained each command after `//`, but this syntax was not used for the annotations in the original._
|
||||
|
||||
```
|
||||
@r [LF] // Reset the TIP
|
||||
@e [SP] r [LF] // "Echo remote" setting, host echoes characters rather than TIP
|
||||
@L [SP] 134 [LF] // Connect to host number 134
|
||||
:login [SP] iccXXX [CR] // Login to the MIT AI Lab's system, where "XXX" should be user's initials
|
||||
:chess [CR] // Start chess program
|
||||
```
|
||||
|
||||
If conference attendees were successfully able to enter those commands, their reward was the opportunity to play around with some of the most cutting-edge chess software available at the time, where the layout of the board was represented like this:
|
||||
|
||||
```
|
||||
BR BN BB BQ BK BB BN BR
|
||||
BP BP BP BP ** BP BP BP
|
||||
-- ** -- ** -- ** -- **
|
||||
** -- ** -- BP -- ** --
|
||||
-- ** -- ** WP ** -- **
|
||||
** -- ** -- ** -- ** --
|
||||
WP WP WP WP -- WP WP WP
|
||||
WR WN WB WQ WK WB WN WR
|
||||
```
|
||||
|
||||
In contrast, to connect to UCLA’s IBM System/360 and run the Speakeasy numerical computing environment, conference attendees had to enter the following:
|
||||
|
||||
```
|
||||
@r [LF] // Reset the TIP
|
||||
@t [SP] o [SP] L [LF] // "Transmit on line feed" setting
|
||||
@i [SP] L [LF] // "Insert line feed" setting, i.e. send line feed with each carriage return
|
||||
@L [SP] 65 [LF] // Connect to host number 65
|
||||
tso // Connect to IBM Time-Sharing Option system
|
||||
logon [SP] icX [CR] // Log in with username, where "X" should be a freely chosen digit
|
||||
iccc [CR] // This is the password (so secure!)
|
||||
speakez [CR] // Start Speakeasy
|
||||
```
|
||||
|
||||
Successfully running that gauntlet gave attendees the power to multiply and transpose and do other operations on matrices as quickly as they could input them at their terminal:
|
||||
|
||||
```
|
||||
:+! a=m*transpose(m);a [CR]
|
||||
:+! eigenvals(a) [CR]
|
||||
```
|
||||
|
||||
Many of the attendees were impressed by the demonstration, but not for the reasons that we, from our present-day vantage point, might assume. The key piece of context hard to keep in mind today is that, in 1972, being able to use a computer remotely, even from a different city, was not new. Teletype devices had been used to talk to distant computers for decades already. Almost a full five years before the ICCC, Bill Gates was in a Seattle high school using a teletype to run his first BASIC programs on a General Electric computer housed elsewhere in the city. Merely logging in to a host computer and running a few commands or playing a text-based game was routine. The software on display here was pretty neat, but the two scenarios I’ve told you about so far could ostensibly have been experienced without going over the ARPANET.
|
||||
|
||||
Of course, something new was happening under the hood. The lawyers, policy-makers, and economists at the ICCC might have been enamored with the clever chess program and the chat bots, but the networking experts would have been more interested in two other scenarios that did a better job of demonstrating what the ARPANET project had achieved.
|
||||
|
||||
The first of these scenarios involved a program called `NETWRK` running on MIT’s ITS operating system. The `NETWRK` command was the entrypoint for several subcommands that could report various aspects of the ARPANET’s operating status. The `SURVEY` subcommand reported which hosts on the network were functioning and available (they all fit on a single list), while the `SUMMARY.OF.SURVEY` subcommand aggregated the results of past `SURVEY` runs to report an “up percentage” for each host as well as how long, on average, it took for each host to respond to messages. The output of the `SUMMARY.OF.SURVEY` subcommand was a table that looked like this:
|
||||
|
||||
```
|
||||
--HOST-- -#- -%-UP- -RESP-
|
||||
UCLA-NMC 001 097% 00.80
|
||||
SRI-ARC 002 068% 01.23
|
||||
UCSB-75 003 059% 00.63
|
||||
...
|
||||
```
|
||||
|
||||
The host number field, as you can see, has room for no more than three digits (ha!). Other `NETWRK` subcommands allowed users to look at summary of survey results over a longer historical period or to examine the log of survey results for a single host.
|
||||
|
||||
The second of these scenarios featured a piece of software called the SRI-ARC Online System being developed at Stanford. This was a fancy piece of software with lots of functionality (it was the software system that Douglas Engelbart demoed in the “Mother of All Demos”), but one of the many things it could do was make use of what was essentially a file hosting service run on the host at UC Santa Barbara. From a terminal at the Washington Hilton, conference attendees could copy a file created at Stanford onto the host at UCSB simply by running a `copy` command and answering a few of the computer’s questions:
|
||||
|
||||
_`[ESC]`, `[SP]`, and `[CR]` below stand for the escape, space, and carriage return keys respectively. The words in parentheses are prompts printed by the computer. The escape key is used to autocomplete the filename on the third line. The file being copied here is called `<system>sample.txt;1`, where the trailing one indicates the file’s version number and `<system>` indicates the directory. This was a convention for filenames used by the TENEX operating system._[11][13]
|
||||
|
||||
```
|
||||
@copy
|
||||
(TO/FROM UCSB) to
|
||||
(FILE) <system>sample [ESC] .TXT;1 [CR]
|
||||
(CREATE/REPLACE) create
|
||||
```
|
||||
|
||||
These two scenarios might not look all that different from the first two, but they were remarkable. They were remarkable because they made it clear that, on the ARPANET, humans could talk to computers but computers could also talk to _each other._ The `SURVEY` results collected at MIT weren’t collected by a human regularly logging in to each machine to check if it was up—they were collected by a program that knew how to talk to the other machines on the network. Likewise, the file transfer from Stanford to UCSB didn’t involve any humans sitting at terminals at either Stanford or UCSB—the user at a terminal in Washington DC was able to get the two computers to talk each other merely by invoking a piece of software. Even more, it didn’t matter which of the 40 terminals in the Ballroom you were sitting at, because you could view the MIT network monitoring statistics or store files at UCSB using any of the terminals with almost the same sequence of commands.
|
||||
|
||||
This is what was totally new about the ARPANET. The ICCC demonstration didn’t just involve a human communicating with a distant computer. It wasn’t just a demonstration of remote I/O. It was a demonstration of software remotely communicating with other software, something nobody had seen before.
|
||||
|
||||
To really appreciate why it was this aspect of the ARPANET project that was important and not the wires-across-the-country, physical connection thing that the host maps suggest (the wires were leased phone lines anyhow and were already there!), consider that, before the ARPANET project began in 1966, the ARPA offices in the Pentagon had a terminal room. Inside it were three terminals. Each connected to a different computer; one computer was at MIT, one was at UC Berkeley, and another was in Santa Monica.[12][14] It was convenient for the ARPA staff that they could use these three computers even from Washington DC. But what was inconvenient for them was that they had to buy and maintain terminals from three different manufacturers, remember three different login procedures, and familiarize themselves with three different computing environments in order to use the computers. The terminals might have been right next to each other, but they were merely extensions of the host computing systems on the other end of the wire and operated as differently as the computers did. Communicating with a distant computer was possible before the ARPANET; the problem was that the heterogeneity of computing systems limited how sophisticated the communication could be.
|
||||
|
||||
### Come Together, Right Now
|
||||
|
||||
So what I’m trying to drive home here is that there is an important distinction between statement A, “the ARPANET connected people in different locations via computers for the first time,” and statement B, “the ARPANET connected computer systems to each other for the first time.” That might seem like splitting hairs, but statement A elides some illuminating history in a way that statement B does not.
|
||||
|
||||
To begin with, the historian Joy Lisi Rankin has shown that people were socializing in cyberspace well before the ARPANET came along. In _A People’s History of Computing in the United States_, she describes several different digital communities that existed across the country on time-sharing networks prior to or apart from the ARPANET. These time-sharing networks were not, technically speaking, computer networks, since they consisted of a single mainframe computer running computations in a basement somewhere for many dumb terminals, like some portly chthonic creature with tentacles sprawling across the country. But they nevertheless enabled most of the social behavior now connoted by the word “network” in a post-Facebook world. For example, on the Kiewit Network, which was an extension of the Dartmouth Time-Sharing System to colleges and high schools across the Northeast, high school students collaboratively maintained a “gossip file” that allowed them to keep track of the exciting goings-on at other schools, “creating social connections from Connecticut to Maine.”[13][15] Meanwhile, women at Mount Holyoke College corresponded with men at Dartmouth over the network, perhaps to arrange dates or keep in touch with boyfriends.[14][16] This was all happening in the 1960s. Rankin argues that by ignoring these early time-sharing networks we impoverish our understanding of how American digital culture developed over the last 50 years, leaving room for a “Silicon Valley mythology” that credits everything to the individual genius of a select few founding fathers.
|
||||
|
||||
As for the ARPANET itself, if we recognize that the key challenge was connecting the computer _systems_ and not just the physical computers, then that might change what we choose to emphasize when we tell the story of the innovations that made the ARPANET possible. The ARPANET was the first ever packet-switched network, and lots of impressive engineering went into making that happen. I think it’s a mistake, though, to say that the ARPANET was a breakthrough because it was the first packet-switched network and then leave it at that. The ARPANET was meant to make it easier for computer scientists across the country to collaborate; that project was as much about figuring out how different operating systems and programs written in different languages would interface with each other than it was about figuring out how to efficiently ferry data back and forth between Massachusetts and California. So the ARPANET was the first packet-switched network, but it was also an amazing standards success story—something I find especially interesting given [how][17] [many][18] [times][19] I’ve written about failed standards on this blog.
|
||||
|
||||
Inventing the protocols for the ARPANET was an afterthought even at the time, so naturally the job fell to a group made up largely of graduate students. This group, later known as the Network Working Group, met for the first time at UC Santa Barbara in August of 1968.[15][20] There were 12 people present at that first meeting, most of whom were representatives from the four universities that were to be the first host sites on the ARPANET when the equipment was ready.[16][21] Steve Crocker, then a graduate student at UCLA, attended; he told me over a Zoom call that it was all young guys at that first meeting, and that Elmer Shapiro, who chaired the meeting, was probably the oldest one there at around 38. ARPA had not put anyone in charge of figuring out how the computers would communicate once they were connected, but it was obvious that some coordination was necessary. As the group continued to meet, Crocker kept expecting some “legitimate adult” with more experience and authority to fly out from the East Coast to take over, but that never happened. The Network Working Group had ARPA’s tacit approval—all those meetings involved lots of long road trips, and ARPA money covered the travel expenses—so they were it.[17][22]
|
||||
|
||||
The Network Working Group faced a huge challenge. Nobody had ever sat down to connect computer systems together in a general-purpose way; that flew against all of the assumptions that prevailed in computing in the late 1960s:
|
||||
|
||||
> The typical mainframe of the period behaved as if it were the only computer in the universe. There was no obvious or easy way to engage two diverse machines in even the minimal communication needed to move bits back and forth. You could connect machines, but once connected, what would they say to each other? In those days a computer interacted with devices that were attached to it, like a monarch communicating with his subjects. Everything connected to the main computer performed a specific task, and each peripheral device was presumed to be ready at all times for a fetch-my-slippers type command…. Computers were strictly designed for this kind of interaction; they send instructions to subordinate card readers, terminals, and tape units, and they initiate all dialogues. But if another device in effect tapped the computer on the shoulder with a signal and said, “Hi, I’m a computer too,” the receiving machine would be stumped.[18][23]
|
||||
|
||||
As a result, the Network Working Group’s progress was initially slow.[19][24] The group did not settle on an “official” specification for any protocol until June, 1970, nearly two years after the group’s first meeting.[20][25]
|
||||
|
||||
But by the time the ARPANET was to be shown off at the 1972 ICCC, all the key protocols were in place. A scenario like the chess scenario exercised many of them. When a user ran the command `@e r`, short for `@echo remote`, that instructed the TIP to make use of a facility in the new TELNET virtual teletype protocol to inform the remote host that it should echo the user’s input. When a user then ran the command `@L 134`, short for `@login 134`, that caused the TIP to invoke the Initial Connection Protocol with host 134, which in turn would cause the remote host to allocate all the necessary resources for the connection and drop the user into a TELNET session. (The file transfer scenario I described may well have made use of the File Transfer Protocol, though that protocol was only ready shortly before the conference.[21][26]) All of these protocols were known as “level three” protocols, and below them were the host-to-host protocol at level two (which defined the basic format for the messages the hosts should expect from each other), and the host-to-IMP protocol at level one (which defined how hosts communicated with the routing equipment they were linked to). Incredibly, the protocols all worked.
|
||||
|
||||
In my view, the Network Working Group was able to get everything together in time and just generally excel at its task because it adopted an open and informal approach to standardization, as exemplified by the famous Request for Comments (RFC) series of documents. These documents, originally circulated among the members of the Network Working Group by snail mail, were a way of keeping in touch between meetings and soliciting feedback to ideas. The “Request for Comments” framing was suggested by Steve Crocker, who authored the first RFC and supervised the RFC mailing list in the early years, in an attempt to emphasize the open-ended and collaborative nature of what the group was trying to do. That framing, and the availability of the documents themselves, made the protocol design process into a melting pot of contributions and riffs on other people’s contributions where the best ideas could emerge without anyone losing face. The RFC process was a smashing success and is still used to specify internet standards today, half a century later.
|
||||
|
||||
It’s this legacy of the Network Working Group that I think we should highlight when we talk about ARPANET’s impact. Though today one of the most magical things about the internet is that it can connect us with people on the other side of the planet, it’s only slightly facetious to say that that technology has been with us since the 19th century. Physical distance was conquered well before the ARPANET by the telegraph. The kind of distance conquered by the ARPANET was instead the logical distance between the operating systems, character codes, programming languages, and organizational policies employed at each host site. Implementing the first packet-switched network was of course a major feat of engineering that should also be mentioned, but the problem of agreeing on standards to connect computers that had never been designed to play nice with each other was the harder of the two big problems involved in building the ARPANET—and its solution was the most miraculous part of the ARPANET story.
|
||||
|
||||
In 1981, ARPA issued a “Completion Report” reviewing the first decade of the ARPANET’s history. In a section with the belabored title, “Technical Aspects of the Effort Which Were Successful and Aspects of the Effort Which Did Not Materialize as Originally Envisaged,” the authors wrote:
|
||||
|
||||
> Possibly the most difficult task undertaken in the development of the ARPANET was the attempt—which proved successful—to make a number of independent host computer systems of varying manufacture, and varying operating systems within a single manufactured type, communicate with each other despite their diverse characteristics.[22][27]
|
||||
|
||||
There you have it from no less a source than the federal government of the United States.
|
||||
|
||||
_If you enjoyed this post, more like it come out every four weeks! Follow [@TwoBitHistory][28] on Twitter or subscribe to the [RSS feed][29] to make sure you know when a new post is out._
|
||||
|
||||
_Previously on TwoBitHistory…_
|
||||
|
||||
> It's been too long, I know, but I finally got around to writing a new post. This one is about how REST APIs should really be known as FIOH APIs instead (Fuck It, Overload HTTP):<https://t.co/xjMZVZgsEz>
|
||||
>
|
||||
> — TwoBitHistory (@TwoBitHistory) [June 28, 2020][30]
|
||||
|
||||
1. “Hilton Hotel Opens in Capital Today.” _The New York Times_, 20 March 1965, <https://www.nytimes.com/1965/03/20/archives/hilton-hotel-opens-in-capital-today.html?searchResultPosition=1>. Accessed 7 Feb. 2021. [↩︎][31]
|
||||
|
||||
2. James Pelkey. _Entrepreneurial Capitalism and Innovation: A History of Computer Communications 1968-1988,_ Chapter 4, Section 12, 2007, <http://www.historyofcomputercommunications.info/Book/4/4.12-ICCC%20Demonstration71-72.html>. Accessed 7 Feb. 2021. [↩︎][32]
|
||||
|
||||
3. Katie Hafner and Matthew Lyon. _Where Wizards Stay Up Late: The Origins of the Internet_. New York, Simon & Schuster, 1996, p. 178. [↩︎][33]
|
||||
|
||||
4. “International Conference on Computer Communication.” _Computer_, vol. 5, no. 4, 1972, p. c2, <https://www.computer.org/csdl/magazine/co/1972/04/01641562/13rRUxNmPIA>. Accessed 7 Feb. 2021. [↩︎][34]
|
||||
|
||||
5. “Program for the International Conference on Computer Communication.” _The Papers of Clay T. Whitehead_, Box 42, <https://d3so5znv45ku4h.cloudfront.net/Box+042/013_Speech-International+Conference+on+Computer+Communications,+Washington,+DC,+October+24,+1972.pdf>. Accessed 7 Feb. 2021. [↩︎][35]
|
||||
|
||||
6. It’s actually not clear to me which room was used for the ARPANET demonstration. Lots of sources talk about a “ballroom,” but the Washington Hilton seems to consider the room with the name “Georgetown” more of a meeting room. So perhaps the demonstration was in the International Ballroom instead. But RFC 372 alludes to a booking of the “Georgetown Ballroom” for the demonstration. A floorplan of the Washington Hilton can be found [here][36]. [↩︎][37]
|
||||
|
||||
7. Hafner, p. 179. [↩︎][38]
|
||||
|
||||
8. ibid., p. 178. [↩︎][39]
|
||||
|
||||
9. Bob Metcalfe. “Scenarios for Using the ARPANET.” _Collections-Computer History Museum_, <https://www.computerhistory.org/collections/catalog/102784024>. Accessed 7 Feb. 2021. [↩︎][40]
|
||||
|
||||
10. Hafner, p. 176. [↩︎][41]
|
||||
|
||||
11. Robert H. Thomas. “Planning for ACCAT Remote Site Operations.” BBN Report No. 3677, October 1977, <https://apps.dtic.mil/sti/pdfs/ADA046366.pdf>. Accessed 7 Feb. 2021. [↩︎][42]
|
||||
|
||||
12. Hafner, p. 12. [↩︎][43]
|
||||
|
||||
13. Joy Lisi Rankin. _A People’s History of Computing in the United States_. Cambridge, MA, Harvard University Press, 2018, p. 84. [↩︎][44]
|
||||
|
||||
14. Rankin, p. 93. [↩︎][45]
|
||||
|
||||
15. Steve Crocker. Personal interview. 17 Dec. 2020. [↩︎][46]
|
||||
|
||||
16. Crocker sent me the minutes for this meeting. The document lists everyone who attended. [↩︎][47]
|
||||
|
||||
17. Steve Crocker. Personal interview. [↩︎][48]
|
||||
|
||||
18. Hafner, p. 146. [↩︎][49]
|
||||
|
||||
19. “Completion Report / A History of the ARPANET: The First Decade.” BBN Report No. 4799, April 1981, <https://walden-family.com/bbn/arpanet-completion-report.pdf>, p. II-13. [↩︎][50]
|
||||
|
||||
20. I’m referring here to RFC 54, “Official Protocol Proffering.” [↩︎][51]
|
||||
|
||||
21. Hafner, p. 175. [↩︎][52]
|
||||
|
||||
22. “Completion Report / A History of the ARPANET: The First Decade,” p. II-29. [↩︎][53]
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://twobithistory.org/2021/02/07/arpanet.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://en.wikipedia.org/wiki/ARPANET
|
||||
[2]: tmp.pnPpRrCI3S#fn:1
|
||||
[3]: tmp.pnPpRrCI3S#fn:2
|
||||
[4]: tmp.pnPpRrCI3S#fn:3
|
||||
[5]: tmp.pnPpRrCI3S#fn:4
|
||||
[6]: tmp.pnPpRrCI3S#fn:5
|
||||
[7]: tmp.pnPpRrCI3S#fn:6
|
||||
[8]: tmp.pnPpRrCI3S#fn:7
|
||||
[9]: tmp.pnPpRrCI3S#fn:8
|
||||
[10]: https://archive.computerhistory.org/resources/access/text/2019/07/102784024-05-001-acc.pdf
|
||||
[11]: tmp.pnPpRrCI3S#fn:9
|
||||
[12]: tmp.pnPpRrCI3S#fn:10
|
||||
[13]: tmp.pnPpRrCI3S#fn:11
|
||||
[14]: tmp.pnPpRrCI3S#fn:12
|
||||
[15]: tmp.pnPpRrCI3S#fn:13
|
||||
[16]: tmp.pnPpRrCI3S#fn:14
|
||||
[17]: https://twobithistory.org/2018/05/27/semantic-web.html
|
||||
[18]: https://twobithistory.org/2018/12/18/rss.html
|
||||
[19]: https://twobithistory.org/2020/01/05/foaf.html
|
||||
[20]: tmp.pnPpRrCI3S#fn:15
|
||||
[21]: tmp.pnPpRrCI3S#fn:16
|
||||
[22]: tmp.pnPpRrCI3S#fn:17
|
||||
[23]: tmp.pnPpRrCI3S#fn:18
|
||||
[24]: tmp.pnPpRrCI3S#fn:19
|
||||
[25]: tmp.pnPpRrCI3S#fn:20
|
||||
[26]: tmp.pnPpRrCI3S#fn:21
|
||||
[27]: tmp.pnPpRrCI3S#fn:22
|
||||
[28]: https://twitter.com/TwoBitHistory
|
||||
[29]: https://twobithistory.org/feed.xml
|
||||
[30]: https://twitter.com/TwoBitHistory/status/1277259930555363329?ref_src=twsrc%5Etfw
|
||||
[31]: tmp.pnPpRrCI3S#fnref:1
|
||||
[32]: tmp.pnPpRrCI3S#fnref:2
|
||||
[33]: tmp.pnPpRrCI3S#fnref:3
|
||||
[34]: tmp.pnPpRrCI3S#fnref:4
|
||||
[35]: tmp.pnPpRrCI3S#fnref:5
|
||||
[36]: https://www3.hilton.com/resources/media/hi/DCAWHHH/en_US/pdf/DCAWH.Floorplans.Apr25.pdf
|
||||
[37]: tmp.pnPpRrCI3S#fnref:6
|
||||
[38]: tmp.pnPpRrCI3S#fnref:7
|
||||
[39]: tmp.pnPpRrCI3S#fnref:8
|
||||
[40]: tmp.pnPpRrCI3S#fnref:9
|
||||
[41]: tmp.pnPpRrCI3S#fnref:10
|
||||
[42]: tmp.pnPpRrCI3S#fnref:11
|
||||
[43]: tmp.pnPpRrCI3S#fnref:12
|
||||
[44]: tmp.pnPpRrCI3S#fnref:13
|
||||
[45]: tmp.pnPpRrCI3S#fnref:14
|
||||
[46]: tmp.pnPpRrCI3S#fnref:15
|
||||
[47]: tmp.pnPpRrCI3S#fnref:16
|
||||
[48]: tmp.pnPpRrCI3S#fnref:17
|
||||
[49]: tmp.pnPpRrCI3S#fnref:18
|
||||
[50]: tmp.pnPpRrCI3S#fnref:19
|
||||
[51]: tmp.pnPpRrCI3S#fnref:20
|
||||
[52]: tmp.pnPpRrCI3S#fnref:21
|
||||
[53]: tmp.pnPpRrCI3S#fnref:22
|
@ -0,0 +1,90 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Understanding Linus's Law for open source security)
|
||||
[#]: via: (https://opensource.com/article/21/2/open-source-security)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
Understanding Linus's Law for open source security
|
||||
======
|
||||
Linus's Law is that given enough eyeballs, all bugs are shallow. How
|
||||
does this apply to open source software security?
|
||||
![Hand putting a Linux file folder into a drawer][1]
|
||||
|
||||
In 2021, there are more reasons why people love Linux than ever before. In this series, I'll share 21 different reasons to use Linux. This article discusses Linux's influence on the security of open source software.
|
||||
|
||||
An often-praised virtue of open source software is that its code can be reviewed (or "audited," as security professionals like to say) by anyone and everyone. However, if you actually ask many open source users when the last time they reviewed code was, you might get answers ranging from a blank stare to an embarrassed murmur. And besides, there are some really big open source applications out there, so it can be difficult to review every single line of code effectively.
|
||||
|
||||
Extrapolating from these slightly uncomfortable truths, you have to wonder: When nobody looks at the code, does it really matter whether it's open or not?
|
||||
|
||||
### Should you trust open source?
|
||||
|
||||
We tend to make a trite assumption in hobbyist computing that open source is "more secure" than anything else. We don't often talk about what that means, what the basis of comparison is ("more" secure than what?), or how the conclusion has even been reached. It's a dangerous statement to make because it implies that as long as you call something _open source_, it automatically and magically inherits enhanced security. That's not what open source is about, and in fact, it's what open source security is very much against.
|
||||
|
||||
You should never assume an application is secure unless you have personally audited and understood its code. Once you have done this, you can assign _ultimate trust_ to that application. Ultimate trust isn't a thing you do on a computer; it's something you do in your own mind: You trust software because you choose to believe that it is secure, at least until someone finds a way to exploit that software.
|
||||
|
||||
You're the only person who can place ultimate trust in that code, so every user who wants that luxury must audit the code for themselves. Taking someone else's word for it doesn't count!
|
||||
|
||||
So until you have audited and understood a codebase for yourself, the maximum trust level you can give to an application is a spectrum ranging from approximately, _not trustworthy at all_ to _pretty trustworthy_. There's no cheat sheet for this. It's a personal choice you must make for yourself. If you've heard from people you strongly trust that an application is secure, then you might trust that software more than you trust something for which you've gotten no trusted recommendations.
|
||||
|
||||
Because you cannot audit proprietary (non-open source) code, you can never assign it _ultimate trust_.
|
||||
|
||||
### Linus's Law
|
||||
|
||||
The reality is, not everyone is a programmer, and not everyone who is a programmer has the time to dedicate to reviewing hundreds and hundreds of lines of code. So if you're not going to audit code yourself, then you must choose to trust (to some degree) the people who _do_ audit code.
|
||||
|
||||
So exactly who does audit code, anyway?
|
||||
|
||||
Linus's Law asserts that _given enough eyeballs, all bugs are shallow_, but we don't really know how many eyeballs are "enough." However, don't underestimate the number. Software is very often reviewed by more people than you might imagine. The original developer or developers obviously know the code that they've written. However, open source is often a group effort, so the longer code is open, the more software developers end up seeing it. A developer must review major portions of a project's code because they must learn a codebase to write new features for it.
|
||||
|
||||
Open source packagers also get involved with many projects in order to make them available to a Linux distribution. Sometimes an application can be packaged with almost no familiarity with the code, but often a packager gets familiar with a project's code, both because they don't want to sign off on software they don't trust and because they may have to make modifications to get it to compile correctly. Bug reporters and triagers also sometimes get familiar with a codebase as they try to solve anomalies ranging from quirks to major crashes. Of course, some bug reporters inadvertently reveal code vulnerabilities not by reviewing it themselves but by bringing attention to something that obviously doesn't work as intended. Sysadmins frequently get intimately familiar with the code of an important software their users rely upon. Finally, there are security researchers who dig into code exclusively to uncover potential exploits.
|
||||
|
||||
### Trust and transparency
|
||||
|
||||
Some people assume that because major software is composed of hundreds of thousands of lines of code, it's basically impossible to audit. Don't be fooled by how much code it takes to make an application run. You don't actually have to read millions of lines. Code is highly structured, and exploitable flaws are rarely just a single line hidden among the millions of lines; there are usually whole functions involved.
|
||||
|
||||
There are exceptions, of course. Sometimes a serious vulnerability is enabled with just one system call or by linking to one flawed library. Luckily, those kinds of errors are relatively easy to notice, thanks to the active role of security researchers and vulnerability databases.
|
||||
|
||||
Some people point to bug trackers, such as the [Common Vulnerabilities and Exposures (CVE)][2] website, and deduce that it's actually as plain as day that open source isn't secure. After all, hundreds of security risks are filed against lots of open source projects, out in the open for everyone to see. Don't let that fool you, though. Just because you don't get to see the flaws in closed software doesn't mean those flaws don't exist. In fact, we know that they do because exploits are filed against them, too. The difference is that _all_ exploits against open source applications are available for developers (and users) to see so those flaws can be mitigated. That's part of the system that boosts trust in open source, and it's wholly missing from proprietary software.
|
||||
|
||||
There may never be "enough" eyeballs on any code, but the stronger and more diverse the community around the code, the better chance there is to uncover and fix weaknesses.
|
||||
|
||||
### Trust and people
|
||||
|
||||
In open source, the probability that many developers, each working on the same project, have noticed something _not secure_ but have all remained equally silent about that flaw is considered to be low because humans rarely mutually agree to conspire in this way. We've seen how disjointed human behavior can be recently with COVID-19 mitigation:
|
||||
|
||||
* We've all identified a flaw (a virus).
|
||||
* We know how to prevent it from spreading (stay home).
|
||||
* Yet the virus continues to spread because one or more people deviate from the mitigation plan.
|
||||
|
||||
|
||||
|
||||
The same is true for bugs in software. If there's a flaw, someone noticing it will bring it to light (provided, of course, that someone sees it).
|
||||
|
||||
However, with proprietary software, there can be a high probability that many developers working on a project may notice something not secure but remain equally silent because the proprietary model relies on paychecks. If a developer speaks out against a flaw, then that developer may at best hurt the software's reputation, thereby decreasing sales, or at worst, may be fired from their job. Developers being paid to work on software in secret do not tend to talk about its flaws. If you've ever worked as a developer, you've probably signed an NDA, and you've been lectured on the importance of trade secrets, and so on. Proprietary software encourages, and more often enforces, silence even in the face of serious flaws.
|
||||
|
||||
### Trust and software
|
||||
|
||||
Don't trust software you haven't audited.
|
||||
|
||||
If you must trust software you haven't audited, then choose to trust code that's exposed to many developers who independently are likely to speak up about a vulnerability.
|
||||
|
||||
Open source isn't inherently more secure than proprietary software, but the systems in place to fix it are far better planned, implemented, and staffed.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/2/open-source-security
|
||||
|
||||
作者:[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://cve.mitre.org
|
100
sources/talk/20210211 Understanding Open Governance Networks.md
Normal file
100
sources/talk/20210211 Understanding Open Governance Networks.md
Normal file
@ -0,0 +1,100 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Understanding Open Governance Networks)
|
||||
[#]: via: (https://www.linux.com/news/understanding-open-governance-networks/)
|
||||
[#]: author: (The Linux Foundation https://www.linuxfoundation.org/en/blog/understanding-open-governance-networks/)
|
||||
|
||||
Understanding Open Governance Networks
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
Throughout the modern business era, industries and commercial operations have shifted substantially to digital processes. Whether you look at EDI as a means to exchange invoices or cloud-based billing and payment solutions today, businesses have steadily been moving towards increasing digital operations. In the last few years, we’ve seen the promises of digital transformation come alive, particularly in [industries that have shifted to software-defined models][2]. The next step of this journey will involve enabling digital transactions through decentralized networks.
|
||||
|
||||
A fundamental adoption issue will be figuring out who controls and decides how a decentralized network is governed. It may seem oxymoronic at first, but decentralized networks still need governance. A future may hold autonomously self-governing decentralized networks, but this model is not accepted in industries today. The governance challenge with a decentralized network technology lies in who and how participants in a network will establish and maintain policies, network operations, on/offboarding of participants, setting fees, configurations, and software changes and are among the issues that will have to be decided to achieve a successful network. No company wants to participate or take a dependency on a network that is controlled or run by a competitor, potential competitor, or any single stakeholder at all for that matter.
|
||||
|
||||
Earlier this year, [we presented a solution for Open Governance Networks][3] that enable an industry or ecosystem to govern itself in an open, inclusive, neutral, and participatory model. You may be surprised to learn that it’s based on best practices in open governance we’ve developed over decades of facilitating the world’s most successful and competitive open source projects.
|
||||
|
||||
### The Challenge
|
||||
|
||||
For the last few years, a running technology joke has been “describe your problem, and someone will tell you blockchain is the solution.” There have been many other concerns raised and confusion created, as overnight headlines hyped cryptocurrency schemes. Despite all this, behind the scenes, and all along, sophisticated companies understood a distributed ledger technology would be a powerful enabler for tackling complex challenges in an industry, or even a section of an industry.
|
||||
|
||||
At the Linux Foundation, we focused on enabling those organizations to collaborate on open source enterprise blockchain technologies within our Hyperledger community. That community has driven collaboration on every aspect of enterprise blockchain technology, including identity, security, and transparency. Like other Linux Foundation projects, these enterprise blockchain communities are open, collaborative efforts. We have had many vertical industry participants engage, from retail, automotive, aerospace, banking, and others participate with real industry challenges they needed to solve. And in this subset of cases, enterprise blockchain is the answer.
|
||||
|
||||
The technology is ready. Enterprise blockchain has been through many proof-of-concept implementations, and we’ve already seen that many organizations have shifted to production deployments. A few notable examples are:
|
||||
|
||||
* [Trust Your Supplier Network][4] 25 major corporate members from Anheuser-Busch InBev to UPS In production since September 2019.
|
||||
* [Foodtrust][5] Launched Aug 2017 with ten members, now being used by all major retailers.
|
||||
* [Honeywell][6] 50 vendors with storefronts in the new marketplace. In its first year, GoDirect Trade processed more than $5 million in online transactions.
|
||||
|
||||
|
||||
|
||||
However, just because we have the technology doesn’t mean we have the appropriate conditions to solve adoption challenges. A certain set of challenges about networks’ governance have become a “last mile” problem for industry adoption. While there are many examples of successful production deployments and multi-stakeholder engagements for commercial enterprise blockchains already, specific adoption scenarios have been halted over uncertainty, or mistrust, over who and how a blockchain network will be governed.
|
||||
|
||||
To precisely state the issue, in many situations, company A does not want to be dependent on, or trust, company B to control a network. For specific solutions that require broad industry participation to succeed, you can name any industry, and there will be company A and company B.
|
||||
|
||||
We think the solution to this challenge will be Open Governance Networks.
|
||||
|
||||
### The Linux Foundation vision of the Open Governance Network
|
||||
|
||||
An Open Governance Network is a distributed ledger service, composed of nodes, operated under the policies and directions of an inclusive set of industry stakeholders.
|
||||
|
||||
Open Governance Networks will set the policies and rules for participation in a decentralized ledger network that acts as an industry utility for transactions and data sharing among participants that have permissions on the network. The Open Governance Network model allows any organization to participate. Those organizations that want to be active in sharing the operational costs will benefit from having a representative say in the policies and rules for the network itself. The software underlying the Open Governance Network will be open source software, including the configurations and build tools so that anyone can validate whether a network node complies with the appropriate policies.
|
||||
|
||||
Many who have worked with the Linux Foundation will realize an open, neutral, and participatory governance model under a nonprofit structure that has already been thriving for decades in successful open source software communities. All we’re doing here is taking the same core principles of what makes open governance work for open source software, open standards, and open collaboration and applying those principles to managing a distributed ledger. This is a model that the Linux Foundation has used successfully in other communities, such as the [Let’s Encrypt][7] certificate authority.
|
||||
|
||||
Our ecosystem members trust the Linux Foundation to help solve this last mile problem using open governance under a neutral nonprofit entity. This is one solution to the concerns about neutrality and distributed control. In pan-industry use cases, it is generally not acceptable for one participant in the network to have power in any way that could be used as an advantage over someone else in the industry. The control of a ledger is a valuable asset, and competitive organizations generally have concerns in allowing one entity to control this asset. If not hosted in a neutral environment for the community’s benefit, network control can become a leverage point over network users.
|
||||
|
||||
We see this neutrality of control challenge as the primary reason why some privately held networks have struggled to gain widespread adoption. In order to encourage participation, industry leaders are looking for a neutral governance structure, and the Linux Foundation has proven the open governance models accomplish that exceptionally well.
|
||||
|
||||
This neutrality of control issue is very similar to the rationale for public utilities. Because the economic model mirrors a public utility, we debated calling these “industry utility networks.” In our conversations, we have learned industry participants are open to sharing the cost burden to stand up and maintain a utility. Still, they want a low-cost, not profit-maximizing model. That is why our nonprofit model makes the most sense.
|
||||
|
||||
It’s also not a public utility in that each network we foresee today would be restricted in participation to those who have a stake in the network, not any random person in the world. There’s a layer of human trust that our communities have been enabling on top of distributed networks, which started with the [Trust over IP Foundation][8].
|
||||
|
||||
Unlike public cryptocurrency networks where anyone can view the ledger or submit proposed transactions, industries have a natural need to limit access to legitimate parties in their industry. With minor adjustments to address the need for policies for transactions on the network, we believe a similar governance model applied to distributed ledger ecosystems can resolve concerns about the neutrality of control.
|
||||
|
||||
### Understanding LF Open Governance Networks
|
||||
|
||||
Open Governance Networks can be reduced to the following building block components:
|
||||
|
||||
* Business Governance: Networks need a decision-making body to establish core policies (e.g., network policies), make funding and budget decisions, contracting with a network manager, and other business matters necessary for the network’s success. The Linux Foundation establishes a governing board to manage the business governance.
|
||||
* Technical Governance: Networks will require software. A technical open source community will openly maintain the software, specifications, or configuration decisions implemented by the network nodes. The Linux Foundation establishes a technical steering committee to oversee technical projects, configurations, working groups, etc.
|
||||
* Transaction Entity: Networks will require a transaction entity that will a) act as counterparty to agreements with parties transacting on the network, b) collect fees from participants, and c) execute contracts for operational support (e.g., hiring a network manager).
|
||||
|
||||
|
||||
|
||||
Of these building blocks, the Linux Foundation already offers its communities the Business and Technical Governance needed for Open Governance Networks. The final component is the new, LF Open Governance Networks.
|
||||
|
||||
LF Open Governance Networks will enable our communities to establish their own Open Governance Network and have an entity to process agreements and collect transaction fees. This new entity is a Delaware nonprofit, a nonstock corporation that will maximize utility and not profit. Through agreements with the Linux Foundation, LF Governance Networks will be available to Open Governance Networks hosted at the Linux Foundation.
|
||||
|
||||
If you’re interested in learning more about hosting an Open Governance Network at the Linux Foundation, please contact us at **[governancenetworks@linuxfoundation.org][9]**
|
||||
|
||||
The post [Understanding Open Governance Networks][10] appeared first on [Linux Foundation][11].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linux.com/news/understanding-open-governance-networks/
|
||||
|
||||
作者:[The Linux Foundation][a]
|
||||
选题:[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.linuxfoundation.org/en/blog/understanding-open-governance-networks/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.linux.com/wp-content/uploads/2021/02/understanding-opengovnetworks.png
|
||||
[2]: https://www.linuxfoundation.org/blog/2020/09/software-defined-vertical-industries-transformation-through-open-source/
|
||||
[3]: https://www.linuxfoundation.org/blog/2020/10/introducing-the-open-governance-network-model/
|
||||
[4]: https://www.hyperledger.org/learn/publications/chainyard-case-study
|
||||
[5]: https://www.hyperledger.org/learn/publications/walmart-case-study
|
||||
[6]: https://www.hyperledger.org/learn/publications/honeywell-case-study
|
||||
[7]: https://letsencrypt.org/
|
||||
[8]: https://trustoverip.org/
|
||||
[9]: mailto:governancenetworks@linuxfoundation.org
|
||||
[10]: https://www.linuxfoundation.org/en/blog/understanding-open-governance-networks/
|
||||
[11]: https://www.linuxfoundation.org/
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (stevenzdg988)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
@ -245,7 +245,7 @@ via: https://opensource.com/article/19/2/testing-bash-bats
|
||||
|
||||
作者:[Darin London][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[stevenzdg988](https://github.com/stevenzdg988)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,73 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (ShuyRoy)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Intel formally launches Optane for data center memory caching)
|
||||
[#]: via: (https://www.networkworld.com/article/3387117/intel-formally-launches-optane-for-data-center-memory-caching.html#tk.rss_all)
|
||||
[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/)
|
||||
|
||||
Intel formally launches Optane for data center memory caching
|
||||
======
|
||||
|
||||
### Intel formally launched the Optane persistent memory product line, which includes 3D Xpoint memory technology. The Intel-only solution is meant to sit between DRAM and NAND and to speed up performance.
|
||||
|
||||
![Intel][1]
|
||||
|
||||
As part of its [massive data center event][2] on Tuesday, Intel formally launched the Optane persistent memory product line. It had been out for a while, but the current generation of Xeon server processors could not fully utilize it. The new Xeon 8200 and 9200 lines take full advantage of it.
|
||||
|
||||
And since Optane is an Intel product (co-developed with Micron), that means AMD and Arm server processors are out of luck.
|
||||
|
||||
As I have [stated in the past][3], Optane DC Persistent Memory uses 3D Xpoint memory technology that Intel developed with Micron Technology. 3D Xpoint is a non-volatile memory type that is much faster than solid-state drives (SSD), almost at the speed of DRAM, but it has the persistence of NAND flash.
|
||||
|
||||
**[ Read also:[Why NVMe? Users weigh benefits of NVMe-accelerated flash storage][4] and [IDC’s top 10 data center predictions][5] | Get regularly scheduled insights [Sign up for Network World newsletters][6] ]**
|
||||
|
||||
The first 3D Xpoint products were SSDs called Intel’s ["ruler,"][7] because they were designed in a long, thin format similar to the shape of a ruler. They were designed that way to fit in 1u server carriages. As part of Tuesday’s announcement, Intel introduced the new Intel SSD D5-P4326 'Ruler' SSD, using four-cell or QLC 3D NAND memory, with up to 1PB of storage in a 1U design.
|
||||
|
||||
Optane DC Persistent Memory will be available in DIMM capacities of 128GB on up to 512GB initially. That’s two to four times what you can get with DRAM, said Navin Shenoy, executive vice president and general manager of Intel’s Data Center Group, who keynoted the event.
|
||||
|
||||
“We expect system capacity in a server system to scale to 4.5 terabytes per socket or 36 TB in an 8-socket system. That’s three times larger than what we were able to do with the first-generation of Xeon Scalable,” he said.
|
||||
|
||||
## Intel Optane memory uses and speed
|
||||
|
||||
Optane runs in two different modes: Memory Mode and App Direct Mode. Memory mode is what I have been describing to you, where Optane memory exists “above” the DRAM and acts as a cache. In App Direct mode, the DRAM and Optane DC Persistent Memory are pooled together to maximize the total capacity. Not every workload is ideal for this kind of configuration, so it should be used in applications that are not latency-sensitive. The primary use case for Optane, as Intel is promoting it, is Memory Mode.
|
||||
|
||||
**[[Get certified as an Apple Technical Coordinator with this seven-part online course from PluralSight.][8] ]**
|
||||
|
||||
When 3D Xpoint was initially announced a few years back, Intel claimed it was 1,000 times faster than NAND, with 1000 times the endurance, and 10 times the density potential of DRAM. Well that was a little exaggerated, but it does have some intriguing elements.
|
||||
|
||||
Optane memory, when used in 256B contiguous 4 cacheline, can achieve read speeds of 8.3GB/sec and write speeds of 3.0GB/sec. Compare that with the read/write speed of 500 or so MB/sec for a SATA SSD, and you can see the performance gain. Optane, remember, is feeding memory, so it caches frequently accessed SSD content.
|
||||
|
||||
This is the key takeaware of Optane DC. It will keep very large data sets very close to memory, and hence the CPU, with low latency while at the same time minimizing the need to access the slower storage subsystem, whether it’s SSD or HDD. It now offers the possibility of putting multiple terabytes of data very close to the CPU for much faster access.
|
||||
|
||||
## One challenge with Optane memory
|
||||
|
||||
The only real challenge is that Optane goes into DIMM slots, which is where memory goes. Now some motherboards come with as many as 16 DIMM slots per CPU socket, but that’s still board real estate that the customer and OEM provider will need to balance out: Optane vs. memory. There are some Optane drives in PCI Express format, which alleviate the memory crowding on the motherboard.
|
||||
|
||||
3D Xpoint also offers higher endurance than traditional NAND flash memory due to the way it writes data. Intel promises a five-year warranty with its Optane, while a lot of SSDs offer only three years.
|
||||
|
||||
Join the Network World communities on [Facebook][9] and [LinkedIn][10] to comment on topics that are top of mind.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3387117/intel-formally-launches-optane-for-data-center-memory-caching.html#tk.rss_all
|
||||
|
||||
作者:[Andy Patrizio][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://www.networkworld.com/author/Andy-Patrizio/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://images.idgesg.net/images/article/2018/06/intel-optane-persistent-memory-100760427-large.jpg
|
||||
[2]: https://www.networkworld.com/article/3386142/intel-unveils-an-epic-response-to-amds-server-push.html
|
||||
[3]: https://www.networkworld.com/article/3279271/intel-launches-optane-the-go-between-for-memory-and-storage.html
|
||||
[4]: https://www.networkworld.com/article/3290421/why-nvme-users-weigh-benefits-of-nvme-accelerated-flash-storage.html
|
||||
[5]: https://www.networkworld.com/article/3242807/data-center/top-10-data-center-predictions-idc.html#nww-fsb
|
||||
[6]: https://www.networkworld.com/newsletters/signup.html#nww-fsb
|
||||
[7]: https://www.theregister.co.uk/2018/02/02/ruler_and_miniruler_ssd_formats_look_to_banish_diskstyle_drives/
|
||||
[8]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fapple-certified-technical-trainer-10-11
|
||||
[9]: https://www.facebook.com/NetworkWorld/
|
||||
[10]: https://www.linkedin.com/company/network-world
|
@ -1,296 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Tmux Command Examples To Manage Multiple Terminal Sessions)
|
||||
[#]: via: (https://www.ostechnix.com/tmux-command-examples-to-manage-multiple-terminal-sessions/)
|
||||
[#]: author: (sk https://www.ostechnix.com/author/sk/)
|
||||
|
||||
Tmux Command Examples To Manage Multiple Terminal Sessions
|
||||
======
|
||||
|
||||
![tmux command examples][1]
|
||||
|
||||
We’ve already learned to use [**GNU Screen**][2] to manage multiple Terminal sessions. Today, we will see yet another well-known command-line utility named **“Tmux”** to manage Terminal sessions. Similar to GNU Screen, Tmux is also a Terminal multiplexer that allows us to create number of terminal sessions and run more than one programs or processes at the same time inside a single Terminal window. Tmux is free, open source and cross-platform program that supports Linux, OpenBSD, FreeBSD, NetBSD and Mac OS X. In this guide, we will discuss most-commonly used Tmux commands in Linux.
|
||||
|
||||
### Installing Tmux in Linux
|
||||
|
||||
Tmux is available in the official repositories of most Linux distributions.
|
||||
|
||||
On Arch Linux and its variants, run the following command to install it.
|
||||
|
||||
```
|
||||
$ sudo pacman -S tmux
|
||||
```
|
||||
|
||||
On Debian, Ubuntu, Linux Mint:
|
||||
|
||||
```
|
||||
$ sudo apt-get install tmux
|
||||
```
|
||||
|
||||
On Fedora:
|
||||
|
||||
```
|
||||
$ sudo dnf install tmux
|
||||
```
|
||||
|
||||
On RHEL and CentOS:
|
||||
|
||||
```
|
||||
$ sudo yum install tmux
|
||||
```
|
||||
|
||||
On SUSE/openSUSE:
|
||||
|
||||
```
|
||||
$ sudo zypper install tmux
|
||||
```
|
||||
|
||||
Well, we have just installed Tmux. Let us go ahead and see some examples to learn how to use Tmux.
|
||||
|
||||
### Tmux Command Examples To Manage Multiple Terminal Sessions
|
||||
|
||||
The default prefix shortcut to all commands in Tmux is **Ctrl+b**. Just remember this keyboard shortcut when using Tmux.
|
||||
|
||||
* * *
|
||||
|
||||
**Note:** The default prefix to all **Screen** commands is **Ctrl+a**.
|
||||
|
||||
* * *
|
||||
|
||||
##### Creating Tmux sessions
|
||||
|
||||
To create a new Tmux session and attach to it, run the following command from the Terminal:
|
||||
|
||||
```
|
||||
tmux
|
||||
```
|
||||
|
||||
Or,
|
||||
|
||||
```
|
||||
tmux new
|
||||
```
|
||||
|
||||
Once you are inside the Tmux session, you will see a **green bar at the bottom** as shown in the screenshot below.
|
||||
|
||||
![][3]
|
||||
|
||||
New Tmux session
|
||||
|
||||
It is very handy to verify whether you’re inside a Tmux session or not.
|
||||
|
||||
##### Detaching from Tmux sessions
|
||||
|
||||
To detach from a current Tmux session, just press **Ctrl+b** and **d**. You don’t need to press this both Keyboard shortcut at a time. First press “Ctrl+b” and then press “d”.
|
||||
|
||||
Once you’re detached from a session, you will see an output something like below.
|
||||
|
||||
```
|
||||
[detached (from session 0)]
|
||||
```
|
||||
|
||||
##### Creating named sessions
|
||||
|
||||
If you use multiple sessions, you might get confused which programs are running on which sessions. In such cases, you can just create named sessions. For example if you wanted to perform some activities related to web server in a session, just create the Tmux session with a custom name, for example **“webserver”** (or any name of your choice).
|
||||
|
||||
```
|
||||
tmux new -s webserver
|
||||
```
|
||||
|
||||
Here is the new named Tmux session.
|
||||
|
||||
![][4]
|
||||
|
||||
Tmux session with a custom name
|
||||
|
||||
As you can see in the above screenshot, the name of the Tmux session is **webserver**. This way you can easily identify which program is running on which session.
|
||||
|
||||
To detach, simply press **Ctrl+b** and **d**.
|
||||
|
||||
##### List Tmux sessions
|
||||
|
||||
To view the list of open Tmux sessions, run:
|
||||
|
||||
```
|
||||
tmux ls
|
||||
```
|
||||
|
||||
Sample output:
|
||||
|
||||
![][5]
|
||||
|
||||
List Tmux sessions
|
||||
|
||||
As you can see, I have two open Tmux sessions.
|
||||
|
||||
##### Creating detached sessions
|
||||
|
||||
Sometimes, you might want to simply create a session and don’t want to attach to it automatically.
|
||||
|
||||
To create a new detached session named **“ostechnix”** , run:
|
||||
|
||||
```
|
||||
tmux new -s ostechnix -d
|
||||
```
|
||||
|
||||
The above command will create a new Tmux session called “ostechnix”, but won’t attach to it.
|
||||
|
||||
You can verify if the session is created using “tmux ls” command:
|
||||
|
||||
![][6]
|
||||
|
||||
Create detached Tmux sessions
|
||||
|
||||
##### Attaching to Tmux sessions
|
||||
|
||||
You can attach to the last created session by running this command:
|
||||
|
||||
```
|
||||
tmux attach
|
||||
```
|
||||
|
||||
Or,
|
||||
|
||||
```
|
||||
tmux a
|
||||
```
|
||||
|
||||
If you want to attach to any specific named session, for example “ostechnix”, run:
|
||||
|
||||
```
|
||||
tmux attach -t ostechnix
|
||||
```
|
||||
|
||||
Or, shortly:
|
||||
|
||||
```
|
||||
tmux a -t ostechnix
|
||||
```
|
||||
|
||||
##### Kill Tmux sessions
|
||||
|
||||
When you’re done and no longer required a Tmux session, you can kill it at any time with command:
|
||||
|
||||
```
|
||||
tmux kill-session -t ostechnix
|
||||
```
|
||||
|
||||
To kill when attached, press **Ctrl+b** and **x**. Hit “y” to kill the session.
|
||||
|
||||
You can verify if the session is closed with “tmux ls” command.
|
||||
|
||||
To Kill Tmux server along with all Tmux sessions, run:
|
||||
|
||||
```
|
||||
tmux kill-server
|
||||
```
|
||||
|
||||
Be careful! This will terminate all Tmux sessions even if there are any running jobs inside the sessions without any warning.
|
||||
|
||||
When there were no running Tmux sessions, you will see the following output:
|
||||
|
||||
```
|
||||
$ tmux ls
|
||||
no server running on /tmp/tmux-1000/default
|
||||
```
|
||||
|
||||
##### Split Tmux Session Windows
|
||||
|
||||
Tmux has an option to split a single Tmux session window into multiple smaller windows called **Tmux panes**. This way we can run different programs on each pane and interact with all of them simultaneously. Each pane can be resized, moved and closed without affecting the other panes. We can split a Tmux window either horizontally or vertically or both at once.
|
||||
|
||||
**Split panes horizontally**
|
||||
|
||||
To split a pane horizontally, press **Ctrl+b** and **”** (single quotation mark).
|
||||
|
||||
![][7]
|
||||
|
||||
Split Tmux pane horizontally
|
||||
|
||||
Use the same key combination to split the panes further.
|
||||
|
||||
**Split panes vertically**
|
||||
|
||||
To split a pane vertically, press **Ctrl+b** and **%**.
|
||||
|
||||
![][8]
|
||||
|
||||
Split Tmux panes vertically
|
||||
|
||||
**Split panes horizontally and vertically**
|
||||
|
||||
We can also split a pane horizontally and vertically at the same time. Take a look at the following screenshot.
|
||||
|
||||
![][9]
|
||||
|
||||
Split Tmux panes
|
||||
|
||||
First, I did a horizontal split by pressing **Ctrl+b “** and then split the lower pane vertically by pressing **Ctrl+b %**.
|
||||
|
||||
As you see in the above screenshot, I am running three different programs on each pane.
|
||||
|
||||
**Switch between panes**
|
||||
|
||||
To switch between panes, press **Ctrl+b** and **Arrow keys (Left, Right, Up, Down)**.
|
||||
|
||||
**Send commands to all panes**
|
||||
|
||||
In the previous example, we run three different commands on each pane. However, it is also possible to run send the same commands to all panes at once.
|
||||
|
||||
To do so, press **Ctrl+b** and type the following command and hit ENTER:
|
||||
|
||||
```
|
||||
:setw synchronize-panes
|
||||
```
|
||||
|
||||
Now type any command on any pane. You will see that the same command is reflected on all panes.
|
||||
|
||||
**Swap panes**
|
||||
|
||||
To swap panes, press **Ctrl+b** and **o**.
|
||||
|
||||
**Show pane numbers**
|
||||
|
||||
Press **Ctrl+b** and **q** to show pane numbers.
|
||||
|
||||
**Kill panes**
|
||||
|
||||
To kill a pane, simply type **exit** and ENTER key. Alternatively, press **Ctrl+b** and **x**. You will see a confirmation message. Just press **“y”** to close the pane.
|
||||
|
||||
![][10]
|
||||
|
||||
Kill Tmux panes
|
||||
|
||||
At this stage, you will get a basic idea of Tmux and how to use it to manage multiple Terminal sessions. For more details, refer man pages.
|
||||
|
||||
```
|
||||
$ man tmux
|
||||
```
|
||||
|
||||
Both GNU Screen and Tmux utilities can be very helpful when managing servers remotely via SSH. Learn Screen and Tmux commands thoroughly to manage your remote servers like a pro.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/tmux-command-examples-to-manage-multiple-terminal-sessions/
|
||||
|
||||
作者:[sk][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.ostechnix.com/author/sk/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.ostechnix.com/wp-content/uploads/2019/06/Tmux-720x340.png
|
||||
[2]: https://www.ostechnix.com/screen-command-examples-to-manage-multiple-terminal-sessions/
|
||||
[3]: https://www.ostechnix.com/wp-content/uploads/2019/06/Tmux-session.png
|
||||
[4]: https://www.ostechnix.com/wp-content/uploads/2019/06/Named-Tmux-session.png
|
||||
[5]: https://www.ostechnix.com/wp-content/uploads/2019/06/List-Tmux-sessions.png
|
||||
[6]: https://www.ostechnix.com/wp-content/uploads/2019/06/Create-detached-sessions.png
|
||||
[7]: https://www.ostechnix.com/wp-content/uploads/2019/06/Horizontal-split.png
|
||||
[8]: https://www.ostechnix.com/wp-content/uploads/2019/06/Vertical-split.png
|
||||
[9]: https://www.ostechnix.com/wp-content/uploads/2019/06/Split-Panes.png
|
||||
[10]: https://www.ostechnix.com/wp-content/uploads/2019/06/Kill-panes.png
|
@ -1,106 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (EndeavourOS Aims to Fill the Void Left by Antergos in Arch Linux World)
|
||||
[#]: via: (https://itsfoss.com/endeavouros/)
|
||||
[#]: author: (John Paul https://itsfoss.com/author/john/)
|
||||
|
||||
EndeavourOS Aims to Fill the Void Left by Antergos in Arch Linux World
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
I’m sure that most of our readers are aware of the [end of the Antergos project][2]. In the wake of the announcement, the members of the Antergos community created several successors. Today, we will be looking at one of the ‘spiritual successors’ of Antergos: [EndeavourOS][3].
|
||||
|
||||
### EndeavourOS is not a fork of Antergos
|
||||
|
||||
Before we start, I would like to make it very clear that EndeavourOS is not a fork of Antergos. The developers used Antergos as their inspiration to create a light Arch-based distro.
|
||||
|
||||
![Endeavouros First Boot][4]
|
||||
|
||||
According to the [project’s site][5], EndeavourOS came into existence because people in the Antergos community wanted to keep the spirit of Antergos alive. Their goal was simply to “have Arch installed with an easy to use installer and a friendly, helpful community to fall back on during the journey to master the system”.
|
||||
|
||||
Unlike many Arch-based distros, EndeavourOS is intending to work [like vanilla Arch][5], “so no one-click solutions to install your favorite app or a bunch of preinstalled apps you’ll eventually don’t need”. For most people, especially those new to Linux and Arch, there will be a learning curve, but EndeavourOS aims to have a large friendly community where people are encouraged to ask questions and learn about their systems.
|
||||
|
||||
![Endeavouros Installing][6]
|
||||
|
||||
### A Work in Progress
|
||||
|
||||
EndeavourOS was [first released on July 15th][7] of this year after the project was first announced on [May 23rd][8]. Unfortunately, this means that the developers were unable to incorporate all of the features that they have planned.
|
||||
|
||||
For example, they want to have an online install similar to the one used by Antergos but ran into [issues with the current options][9]. “Cnchi has caused serious problems to be working outside the Antergos eco system and it needs a complete rewrite to work. The Fenix installer by RebornOS is getting more into shape, but needs more time to properly function.” For now, EndeavourOS will ship with the [Calamares installer][10].
|
||||
|
||||
[][11]
|
||||
|
||||
Suggested read Velt/OS: A Material Design-Themed Desktop Environment
|
||||
|
||||
EndeavourOS will also offer [less stuff than Antergos][9]: It’s repo is smaller than Antergos though they ship with some AUR packages. Their goal is to deliver a system that’s close to Arch an not vanilla Arch.
|
||||
|
||||
![Endeavouros Updating With Kalu][12]
|
||||
|
||||
The developers [stated further][13]:
|
||||
|
||||
> “Linux and specifically Arch are all about freedom of choice, we provide a basic install that lets you explore those choices with a small layer of convenience. We will never judge you by installing GUI apps like Pamac or even work with sandbox solutions like Flatpak or Snaps. It’s up to you what you are installing to make EndeavourOS work in your circumstances, that’s the main difference we have with Antergos or Manjaro, but like Antergos we will try to help you if you run into a problem with one of your installed packages.”
|
||||
|
||||
### Experiencing EndeavourOS
|
||||
|
||||
I installed EndeavourOS in [VirtualBox][14] and took a look around. When I first booted from the image, I was greeted by a little box with links to the EndeavourOS site about installing. It also has a button to install and one to manually partition the drive. The Calamares installer worked very smoothly for me.
|
||||
|
||||
After I rebooted into a fresh install of EndeavourOS, I was greeted by a colorful themed XFCE desktop. I was also treated to a bunch of notification balloons. Most Arch-based distros I’ve used come with a GUI tool like [pamac][15] or [octopi][16] to keep the system up-to-date. EndeavourOS comes with [kalu][17]. (kalu stands for “Keeping Arch Linux Up-to-date”.) It checks for updated packages, Arch Linux News, updated AUR packages and more. Once it sees an update for any of those areas, it will create a notification balloon.
|
||||
|
||||
I took a look through the menu to see what was installed by default. The answer is not much, not even an office suite. If they intend for EndeavourOS to be a blank canvas for anyone to create the system they want. they are headed in the right direction.
|
||||
|
||||
![Endeavouros Desktop][18]
|
||||
|
||||
### Final Thoughts
|
||||
|
||||
EndeavourOS is still very young. The first stable release was issued only 3 weeks ago. It is missing some stuff, most importantly an online installer. That being said, it is possible to gauge where EndeavourOS will be heading.
|
||||
|
||||
[][19]
|
||||
|
||||
Suggested read An Overview of Intel's Clear Linux, its Features and Installation Procedure
|
||||
|
||||
While it is not an exact clone of Antergos, EndeavourOS wants to replicate the most important part of Antergos the welcoming, friendly community. All to often, the Linux community can seem to be unwelcoming and downright hostile to the beginner. I’ve seen more and more people trying to combat that negativity and bring more people into Linux. With the EndeavourOS team making that their main focus, a great distro can be the only result.
|
||||
|
||||
If you are currently using Antergos, there is a way for you to [switch to EndeavourOS without performing a clean install.][20]
|
||||
|
||||
If you want an exact clone of Antergos, I would recommend checking out [RebornOS][21]. They are currently working on a replacement of the Cnchi installer named Fenix.
|
||||
|
||||
Have you tried EndeavourOS already? How’s your experience with it?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/endeavouros/
|
||||
|
||||
作者:[John Paul][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/john/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/endeavouros-logo.png?ssl=1
|
||||
[2]: https://itsfoss.com/antergos-linux-discontinued/
|
||||
[3]: https://endeavouros.com/
|
||||
[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/endeavouros-first-boot.png?resize=800%2C600&ssl=1
|
||||
[5]: https://endeavouros.com/info-2/
|
||||
[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/endeavouros-installing.png?resize=800%2C600&ssl=1
|
||||
[7]: https://endeavouros.com/endeavouros-first-stable-release-has-arrived/
|
||||
[8]: https://forum.antergos.com/topic/11780/endeavour-antergos-community-s-next-stage
|
||||
[9]: https://endeavouros.com/what-to-expect-on-the-first-release/
|
||||
[10]: https://calamares.io/
|
||||
[11]: https://itsfoss.com/veltos-linux/
|
||||
[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/endeavouros-updating-with-kalu.png?resize=800%2C600&ssl=1
|
||||
[13]: https://endeavouros.com/second-week-after-the-stable-release/
|
||||
[14]: https://itsfoss.com/install-virtualbox-ubuntu/
|
||||
[15]: https://aur.archlinux.org/packages/pamac-aur/
|
||||
[16]: https://octopiproject.wordpress.com/
|
||||
[17]: https://github.com/jjk-jacky/kalu
|
||||
[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/08/endeavouros-desktop.png?resize=800%2C600&ssl=1
|
||||
[19]: https://itsfoss.com/clear-linux/
|
||||
[20]: https://forum.endeavouros.com/t/how-to-switch-from-antergos-to-endevouros/105/2
|
||||
[21]: https://rebornos.org/
|
@ -1,56 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How the Zen of Python handles errors)
|
||||
[#]: via: (https://opensource.com/article/19/12/zen-python-errors)
|
||||
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
|
||||
|
||||
How the Zen of Python handles errors
|
||||
======
|
||||
This is part of a special series about the Zen of Python focusing on the
|
||||
10th and 11th principles: on the silence (or not) of errors.
|
||||
![a checklist for a team][1]
|
||||
|
||||
Handling "exceptional conditions" is one of the most debated issues in programming. That could be because the stakes are high: mishandled error values can bring down even the largest systems. Since "exception conditions," by nature, are the least tested but occur with unpleasant frequency, correctly handling them can often distinguish a system that horror stories are told about to a system that "just works."
|
||||
|
||||
From Java's **checked** exceptions through Erlang's fault isolation to Haskell's **Maybe**, different languages have remarkably different attitudes to error handling.
|
||||
|
||||
The [Zen][2] offers Python's meditation on the topic.
|
||||
|
||||
### Errors should never pass silently…
|
||||
|
||||
Before the Zen of Python was a twinkle in Tim Peters' eye, before Wikipedia became informally known as "wiki," the first WikiWiki site, [C2][3], existed as a trove of programming guidelines. These are principles that mostly came out of a [Smalltalk][4] programming community. Smalltalk's ideas influenced many object-oriented languages, Python included.
|
||||
|
||||
The C2 wiki defines the Samurai Principle: "return victorious, or not at all." In Pythonic terms, it encourages eschewing sentinel values, such as returning **None** or **-1** to indicate an inability to complete the task, in favor of raising exceptions. A **None** is silent: it looks like a value and can be put in a variable and passed around. Sometimes, it is even a _valid_ return value.
|
||||
|
||||
The principle here is that if a function cannot accomplish its contract, it should "fail loudly": raise an exception. The raised exception will never look like a possible value. It will skip past the **returned_value = call_to_function(parameter)** line and go up the stack, potentially crashing the program.
|
||||
|
||||
A crash is straightforward to debug: there is a stack trace indicating the problem as well as the call stack. The failure might mean that a necessary condition for the program was not met, and human intervention is needed. It might mean that the program's logic is faulty. In either case, the loud failure is better than a hidden, "missing" value, infecting the program's valid data with **None**, until it is used somewhere and an error message says "**None does not have method split**," which you probably already knew.
|
||||
|
||||
### Unless explicitly silenced.
|
||||
|
||||
Exceptions sometimes need to be explicitly caught. We might anticipate some of the lines in a file are misformatted and want to handle those in a special way, maybe by putting them in a "lines to be looked at by a human" file, instead of crashing the entire program.
|
||||
|
||||
Python allows us to catch exceptions with **except**. This means errors can be _explicitly_ silenced. This explicitness means that the **except** line is visible in code reviews. It makes sense to question why this is the right place to silence, and potentially recover from, the exception. It makes sense to ask if we are catching too many exceptions or too few.
|
||||
|
||||
Because this is all explicit, it is possible for someone to read the code and understand which exceptional conditions are recoverable.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/12/zen-python-errors
|
||||
|
||||
作者:[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/checklist_hands_team_collaboration.png?itok=u82QepPk (a checklist for a team)
|
||||
[2]: https://www.python.org/dev/peps/pep-0020/
|
||||
[3]: https://wiki.c2.com/
|
||||
[4]: https://en.wikipedia.org/wiki/Smalltalk
|
@ -1,44 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (The Zen of Python: Why timing is everything)
|
||||
[#]: via: (https://opensource.com/article/19/12/zen-python-timeliness)
|
||||
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
|
||||
|
||||
The Zen of Python: Why timing is everything
|
||||
======
|
||||
This is part of a special series about the Zen of Python focusing on the
|
||||
15th and 16th principles: now vs. never.
|
||||
![Clock, pen, and notepad on a desk][1]
|
||||
|
||||
Python is always evolving. The Python community has an unending appetite for feature requests but also an unending bias toward the status quo. As Python gets more popular, changes to the language affect more people.
|
||||
|
||||
The exact timing for when a change happens is often hard, but the [Zen of Python][2] offers guidance.
|
||||
|
||||
### Now is better than never.
|
||||
|
||||
There is always the temptation to delay things until they are perfect. They will never be perfect, though. When they look "ready" enough, that is when it is time to take the plunge and put them out there. Ultimately, a change always happens at _some_ now: the only thing that delaying does is move it to a future person's "now."
|
||||
|
||||
### Although never is often better than _right now_.
|
||||
|
||||
This, however, does not mean things should be rushed. Decide the criteria for release in terms of testing, documentation, user feedback, and so on. "Right now," as in before the change is ready, is not a good time.
|
||||
|
||||
This is a good lesson not just for popular languages like Python, but also for your personal little open source project.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/12/zen-python-timeliness
|
||||
|
||||
作者:[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/desk_clock_job_work.jpg?itok=Nj4fuhl6 (Clock, pen, and notepad on a desk)
|
||||
[2]: https://www.python.org/dev/peps/pep-0020/
|
@ -1,46 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to tell if implementing your Python code is a good idea)
|
||||
[#]: via: (https://opensource.com/article/19/12/zen-python-implementation)
|
||||
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
|
||||
|
||||
How to tell if implementing your Python code is a good idea
|
||||
======
|
||||
This is part of a special series about the Zen of Python focusing on the
|
||||
17th and 18th principles: hard vs. easy.
|
||||
![Brick wall between two people, a developer and an operations manager][1]
|
||||
|
||||
A language does not exist in the abstract. Every single language feature has to be implemented in code. It is easy to promise some features, but the implementation can get hairy. Hairy implementation means more potential for bugs, and, even worse, a maintenance burden for the ages.
|
||||
|
||||
The [Zen of Python][2] has answers for this conundrum.
|
||||
|
||||
### If the implementation is hard to explain, it's a bad idea.
|
||||
|
||||
The most important thing about programming languages is predictability. Sometimes we explain the semantics of a certain construct in terms of abstract programming models, which do not correspond exactly to the implementation. However, the best of all explanations just _explains the implementation_.
|
||||
|
||||
If the implementation is hard to explain, it means the avenue is impossible.
|
||||
|
||||
### If the implementation is easy to explain, it may be a good idea.
|
||||
|
||||
Just because something is easy does not mean it is worthwhile. However, once it is explained, it is much easier to judge whether it is a good idea.
|
||||
|
||||
This is why the second half of this principle intentionally equivocates: nothing is certain to be a good idea, but it always allows people to have that discussion.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/12/zen-python-implementation
|
||||
|
||||
作者:[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/devops_confusion_wall_questions.png?itok=zLS7K2JG (Brick wall between two people, a developer and an operations manager)
|
||||
[2]: https://www.python.org/dev/peps/pep-0020/
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: ( chensanle )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -1,250 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Getting Started With Pacman Commands in Arch-based Linux Distributions)
|
||||
[#]: via: (https://itsfoss.com/pacman-command/)
|
||||
[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/)
|
||||
|
||||
Getting Started With Pacman Commands in Arch-based Linux Distributions
|
||||
======
|
||||
|
||||
_**Brief: This beginner’s guide shows you what you can do with pacmancommands in Linux, how to use them to find new packages, install and upgrade new packages, and clean your system.**_
|
||||
|
||||
The [pacman][1] package manager is one of the main difference between [Arch Linux][2] and other major distributions like Red Hat and Ubuntu/Debian. It combines a simple binary package format with an easy-to-use [build system][3]. The aim of pacman is to easily manage packages, either from the [official repositories][4] or the user’s own builds.
|
||||
|
||||
If you ever used Ubuntu or Debian-based distributions, you might have used the apt-get or apt commands. Pacman is the equivalent in Arch Linux. If you [just installed Arch Linux][5], one of the first few [things to do after installing Arch Linux][6] is to learn to use pacman commands.
|
||||
|
||||
In this beginner’s guide, I’ll explain some of the essential usage of the pacmand command that you should know for managing your Arch-based system.
|
||||
|
||||
### Essential pacman commands Arch Linux users should know
|
||||
|
||||
![][7]
|
||||
|
||||
Like other package managers, pacman can synchronize package lists with the software repositories to allow the user to download and install packages with a simple command by solving all required dependencies.
|
||||
|
||||
#### Install packages with pacman
|
||||
|
||||
You can install a single package or multiple packages using pacman command in this fashion:
|
||||
|
||||
```
|
||||
pacman -S _package_name1_ _package_name2_ ...
|
||||
```
|
||||
|
||||
![Installing a package][8]
|
||||
|
||||
The -S stands for synchronization. It means that pacman first synchronizes
|
||||
|
||||
The pacman database categorises the installed packages in two groups according to the reason why they were installed:
|
||||
|
||||
* **explicitly-installed**: the packages that were installed by a generic pacman -S or -U command
|
||||
* **dependencies**: the packages that were implicitly installed because [required][9] by another package that was explicitly installed.
|
||||
|
||||
|
||||
|
||||
#### Remove an installed package
|
||||
|
||||
To remove a single package, leaving all of its dependencies installed:
|
||||
|
||||
```
|
||||
pacman -R package_name_
|
||||
```
|
||||
|
||||
![Removing a package][10]
|
||||
|
||||
To remove a package and its dependencies which are not required by any other installed package:
|
||||
|
||||
```
|
||||
pacman -Rs _package_name_
|
||||
```
|
||||
|
||||
To remove dependencies that are no longer needed. For example, the package which needed the dependencies was removed.
|
||||
|
||||
```
|
||||
pacman -Qdtq | pacman -Rs -
|
||||
```
|
||||
|
||||
#### Upgrading packages
|
||||
|
||||
Pacman provides an easy way to [update Arch Linux][11]. You can update all installed packages with just one command. This could take a while depending on how up-to-date the system is.
|
||||
|
||||
The following command synchronizes the repository databases _and_ updates the system’s packages, excluding “local” packages that are not in the configured repositories:
|
||||
|
||||
```
|
||||
pacman -Syu
|
||||
```
|
||||
|
||||
* S stands for sync
|
||||
* y is for refresh (local
|
||||
* u is for system update
|
||||
|
||||
|
||||
|
||||
Basically it is saying that sync to central repository (master package database), refresh the local copy of the master package database and then perform the system update (by updating all packages that have a newer version available).
|
||||
|
||||
![System update][12]
|
||||
|
||||
Attention!
|
||||
|
||||
If you are an Arch Linux user before upgrading, it is advised to visit the [Arch Linux home page][2] to check the latest news for out-of-the-ordinary updates. If manual intervention is needed an appropriate news post will be made. Alternatively you can subscribe to the [RSS feed][13] or the [arch-announce mailing list][14].
|
||||
|
||||
Be also mindful to look over the appropriate [forum][15] before upgrading fundamental software (such as the kernel, xorg, systemd, or glibc), for any reported problems.
|
||||
|
||||
**Partial upgrades are unsupported** at a rolling release distribution such as Arch and Manjaro. That means when new library versions are pushed to the repositories, all the packages in the repositories need to be rebuilt against the libraries. For example, if two packages depend on the same library, upgrading only one package, might break the other package which depends on an older version of the library.
|
||||
|
||||
#### Use pacman to search for packages
|
||||
|
||||
Pacman queries the local package database with the -Q flag, the sync database with the -S flag and the files database with the -F flag.
|
||||
|
||||
Pacman can search for packages in the database, both in packages’ names and descriptions:
|
||||
|
||||
```
|
||||
pacman -Ss _string1_ _string2_ ...
|
||||
```
|
||||
|
||||
![Searching for a package][16]
|
||||
|
||||
To search for already installed packages:
|
||||
|
||||
```
|
||||
pacman -Qs _string1_ _string2_ ...
|
||||
```
|
||||
|
||||
To search for package file names in remote packages:
|
||||
|
||||
```
|
||||
pacman -F _string1_ _string2_ ...
|
||||
```
|
||||
|
||||
To view the dependency tree of a package:
|
||||
|
||||
```
|
||||
pactree _package_naenter code hereme_
|
||||
```
|
||||
|
||||
#### Cleaning the package cache
|
||||
|
||||
Pacman stores its downloaded packages in /var/cache/pacman/pkg/ and does not remove the old or uninstalled versions automatically. This has some advantages:
|
||||
|
||||
1. It allows to [downgrade][17] a package without the need to retrieve the previous version through other sources.
|
||||
2. A package that has been uninstalled can easily be reinstalled directly from the cache folder.
|
||||
|
||||
|
||||
|
||||
However, it is necessary to clean up the cache periodically to prevent the folder to grow in size.
|
||||
|
||||
The [paccache(8)][18] script, provided within the [pacman-contrib][19] package, deletes all cached versions of installed and uninstalled packages, except for the most recent 3, by default:
|
||||
|
||||
```
|
||||
paccache -r
|
||||
```
|
||||
|
||||
![Clear cache][20]
|
||||
|
||||
To remove all the cached packages that are not currently installed, and the unused sync database, execute:
|
||||
|
||||
```
|
||||
pacman -Sc
|
||||
```
|
||||
|
||||
To remove all files from the cache, use the clean switch twice, this is the most aggressive approach and will leave nothing in the cache folder:
|
||||
|
||||
```
|
||||
pacman -Scc
|
||||
```
|
||||
|
||||
#### Installing local or third-party packages
|
||||
|
||||
Install a ‘local’ package that is not from a remote repository:
|
||||
|
||||
```
|
||||
pacman -U _/path/to/package/package_name-version.pkg.tar.xz_
|
||||
```
|
||||
|
||||
Install a ‘remote’ package, not contained in an official repository:
|
||||
|
||||
```
|
||||
pacman -U http://www.example.com/repo/example.pkg.tar.xz
|
||||
```
|
||||
|
||||
### Bonus: Troubleshooting common errors with pacman
|
||||
|
||||
Here are some common errors you may encounter while managing packages with pacman.
|
||||
|
||||
#### Failed to commit transaction (conflicting files)
|
||||
|
||||
If you see the following error:
|
||||
|
||||
```
|
||||
error: could not prepare transaction
|
||||
error: failed to commit transaction (conflicting files)
|
||||
package: /path/to/file exists in filesystem
|
||||
Errors occurred, no packages were upgraded.
|
||||
```
|
||||
|
||||
This is happening because pacman has detected a file conflict and will not overwrite files for you.
|
||||
|
||||
A safe way to solve this is to first check if another package owns the file (pacman -Qo _/path/to/file_). If the file is owned by another package, file a bug report. If the file is not owned by another package, rename the file which ‘exists in filesystem’ and re-issue the update command. If all goes well, the file may then be removed.
|
||||
|
||||
Instead of manually renaming and later removing all the files that belong to the package in question, you may explicitly run _**pacman -S –overwrite glob package**_ to force pacman to overwrite files that match _glob_.
|
||||
|
||||
#### Failed to commit transaction (invalid or corrupted package)
|
||||
|
||||
Look for .part files (partially downloaded packages) in /var/cache/pacman/pkg/ and remove them. It is often caused by usage of a custom XferCommand in pacman.conf.
|
||||
|
||||
#### Failed to init transaction (unable to lock database)
|
||||
|
||||
When pacman is about to alter the package database, for example installing a package, it creates a lock file at /var/lib/pacman/db.lck. This prevents another instance of pacman from trying to alter the package database at the same time.
|
||||
|
||||
If pacman is interrupted while changing the database, this stale lock file can remain. If you are certain that no instances of pacman are running then delete the lock file.
|
||||
|
||||
Check if a process is holding the lock file:
|
||||
|
||||
```
|
||||
lsof /var/lib/pacman/db.lck
|
||||
```
|
||||
|
||||
If the above command doesn’t return anything, you can remove the lock file:
|
||||
|
||||
```
|
||||
rm /var/lib/pacman/db.lck
|
||||
```
|
||||
|
||||
If you find the PID of the process holding the lock file with lsof command output, kill it first and then remove the lock file.
|
||||
|
||||
I hope you like my humble effort in explaining the basic pacman commands. Please leave your comments below and don’t forget to subscribe on our social media. Stay safe!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/pacman-command/
|
||||
|
||||
作者:[Dimitrios Savvopoulos][a]
|
||||
选题:[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/dimitrios/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.archlinux.org/pacman/
|
||||
[2]: https://www.archlinux.org/
|
||||
[3]: https://wiki.archlinux.org/index.php/Arch_Build_System
|
||||
[4]: https://wiki.archlinux.org/index.php/Official_repositories
|
||||
[5]: https://itsfoss.com/install-arch-linux/
|
||||
[6]: https://itsfoss.com/things-to-do-after-installing-arch-linux/
|
||||
[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/essential-pacman-commands.jpg?ssl=1
|
||||
[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/sudo-pacman-S.png?ssl=1
|
||||
[9]: https://wiki.archlinux.org/index.php/Dependency
|
||||
[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/sudo-pacman-R.png?ssl=1
|
||||
[11]: https://itsfoss.com/update-arch-linux/
|
||||
[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/sudo-pacman-Syu.png?ssl=1
|
||||
[13]: https://www.archlinux.org/feeds/news/
|
||||
[14]: https://mailman.archlinux.org/mailman/listinfo/arch-announce/
|
||||
[15]: https://bbs.archlinux.org/
|
||||
[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/sudo-pacman-Ss.png?ssl=1
|
||||
[17]: https://wiki.archlinux.org/index.php/Downgrade
|
||||
[18]: https://jlk.fjfi.cvut.cz/arch/manpages/man/paccache.8
|
||||
[19]: https://www.archlinux.org/packages/?name=pacman-contrib
|
||||
[20]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/sudo-paccache-r.png?ssl=1
|
@ -1,201 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Top Arch-based User Friendly Linux Distributions That are Easier to Install and Use Than Arch Linux Itself)
|
||||
[#]: via: (https://itsfoss.com/arch-based-linux-distros/)
|
||||
[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/)
|
||||
|
||||
Top Arch-based User Friendly Linux Distributions That are Easier to Install and Use Than Arch Linux Itself
|
||||
======
|
||||
|
||||
In the Linux community, [Arch Linux][1] has a cult following. This lightweight distribution provides the bleeding edge updates with a DIY (do it yourself) attitude.
|
||||
|
||||
However, Arch is also aimed at more experienced users. As such, it is generally considered to be beyond the reach of those who lack the technical expertise (or persistence) required to use it.
|
||||
|
||||
In fact, the very first steps, [installing Arch Linux itself is enough to scare many people off][2]. Unlike most other distributions, Arch Linux doesn’t have an easy to use graphical installer. You have to do disk partitions, connect to internet, mount drives and create file system etc using command line tools only.
|
||||
|
||||
For those who want to experience Arch without the hassle of the complicated installation and set up, there exists a number of user-friendly Arch-based distributions.
|
||||
|
||||
In this article, I’ll show you some of these Arch alternative distributions. These distributions come with graphical installer, graphical package manager and other tools that are easier to use than their command line alternatives.
|
||||
|
||||
### Arch-based Linux distributions that are easier to set up and use
|
||||
|
||||
![][3]
|
||||
|
||||
Please note that this is not a ranking list. The numbers are just for counting purpose. Distribution at number two should not be considered better than distribution at number seven.
|
||||
|
||||
#### 1\. Manjaro Linux
|
||||
|
||||
![][4]
|
||||
|
||||
[Manjaro][5] doesn’t need any introduction. It is one of the most popular Linux distributions for several years and it deserves it.
|
||||
|
||||
Manjaro provides all the benefits of the Arch Linux combined with a focus on user-friendliness and accessibility. Manjaro is suitable for both newcomers and experienced Linux users alike.
|
||||
|
||||
**For newcomers**, a user-friendly installer is provided, and the system itself is designed to work fully ‘straight out of the box’ with your [favourite desktop environment][6] (DE) or window manager.
|
||||
|
||||
**For more experienced users,** Manjaro also offers versatility to suit every personal taste and preference. [Manjaro Architect][7] is giving the option to install any Manjaro flavour and offers unflavoured DE installation, filesystem ([recently introduced ZFS][8]) and bootloader choice for those who wants complete freedom to shape their system.
|
||||
|
||||
Manjaro is also a rolling release cutting-edge distribution. However, unlike Arch, Manjaro tests the updates first and then provides it to its users. Stability also gets importance here.
|
||||
|
||||
#### 2\. ArcoLinux
|
||||
|
||||
![][9]
|
||||
|
||||
[ArcoLinux][10] (previously known as ArchMerge) is a distribution based on Arch Linux. The development team offers three variations. ArcoLinux, ArcoLinuxD and ArcoLinuxB.
|
||||
|
||||
ArcoLinux ****is a full-featured distribution that ships with the [Xfce desktop][11], [Openbox][12] and [i3 window managers][13].
|
||||
|
||||
**ArcoLinuxD** is a minimal distribution that includes scripts that enable power users to install any desktop and application.
|
||||
|
||||
**ArcoLinuxB** is a project that gives users the power to build custom distributions, while also developing several community editions with pre-configured desktops, such as Awesome, bspwm, Budgie, Cinnamon, Deepin, GNOME, MATE and KDE Plasma.
|
||||
|
||||
ArcoLinux also provides various video tutorials as it places strong focus on learning and acquiring Linux skills.
|
||||
|
||||
#### Archlabs Linux
|
||||
|
||||
![][14]
|
||||
|
||||
[ArchLabs Linux][15] is a lightweight rolling release Linux distribution based on a minimal Arch Linux base with the [Openbox][16] window manager. [ArchLabs][17] is influenced and inspired by the look and feel of [BunsenLabs][18] with the intermediate to advanced user in mind.
|
||||
|
||||
#### Archman Linux
|
||||
|
||||
![][19]
|
||||
|
||||
[Archman][20] is an independent project. Arch Linux distros in general are not ideal operating systems for users with little Linux experience. Considerable background reading is necessary for things to make sense with minimal frustration. Developers of Archman Linux are trying to change that reputation.
|
||||
|
||||
Archman’s development is based on an understanding of development that includes user feedback and experience components. With the past experience of our team, the feedbacks and requests from the users are blended together and the road maps are determined and the build works are done.
|
||||
|
||||
#### EndeavourOS
|
||||
|
||||
![][21]
|
||||
|
||||
When the popular Arch-based distribution [Antergos was discontinued in 2019][22], it left a friendly and extremely helpful community behind. The Antergos project ended because the system was too hard to maintain for the developers.
|
||||
|
||||
Within a matter of days after the announcement, a few experienced users palnned on maintaining the former community by creating a new distribution to fill the void left by Antergos. That’s how [EndeavourOS][23] was born.
|
||||
|
||||
[EndeavourOS][24] is lightweight and ships with a minimum amount of preinstalled apps. An almost blank canvas ready to personalise.
|
||||
|
||||
#### RebornOS
|
||||
|
||||
![][25]
|
||||
|
||||
[RebornOS][26] developers’ goal is to bring the true power of Linux to everyone, with one ISO for 15 desktop environments and full of unlimited opportunities for customization.
|
||||
|
||||
RebornOS also claims to have support for [Anbox][27] for running Android applications on desktop Linux. It also offers a simple kernel manager GUI tool.
|
||||
|
||||
Coupled with [Pacman][28], the [AUR][29], and a customized version of Cnchi graphical installer, Arch Linux is finally available for even the least inexperienced users.
|
||||
|
||||
#### Chakra Linux
|
||||
|
||||
![][30]
|
||||
|
||||
A community-developed GNU/Linux distribution with an emphasis on KDE and Qt technologies. [Chakra Linux][31] does not schedule releases for specific dates but uses a “Half-Rolling release” system.
|
||||
|
||||
This means that the core packages of Chakra Linux are frozen and only updated to fix any security problems. These packages are updated after the latest versions have been thoroughly tested before being moved to permanent repository (about every six months).
|
||||
|
||||
In addition to the official repositories, users can install packages from the Chakra Community Repository (CCR), which provides user made PKGINFOs and [PKGBUILD][32] scripts for software which is not included in the official repositories and is inspired by the Arch User Repository.
|
||||
|
||||
#### Artix Linux
|
||||
|
||||
![Artix Mate Edition][33]
|
||||
|
||||
[Artix Linux][34] is a rolling-release distribution based on Arch Linux that uses [OpenRC][35], [runit][36] or [s6][37] init instead of [systemd][38].
|
||||
|
||||
Artix Linux has its own package repositories but as a pacman-based distribution, it can use packages from Arch Linux repositories or any other derivative distribution, even packages explicitly depending on systemd. The [Arch User Repository][29] (AUR) can also be used.
|
||||
|
||||
#### BlackArch Linux
|
||||
|
||||
![][39]
|
||||
|
||||
BlackArch is a [penetration testing distribution][40] based on Arch Linux that provides a large amount of cyber security tools. It is specially created for penetration testers and security researchers. The repository contains more than 2400 [hacking and pen-testing tools][41] that can be installed individually or in groups. BlackArch Linux is compatible with existing Arch Linux packages.
|
||||
|
||||
### Want real Arch Linux? Simplify the installation with graphical Arch installer
|
||||
|
||||
If you want to use the actual Arch Linux but you are not comfortable with the difficult installation, fortunately you can download an Arch Linux iso baked with a graphical installer.
|
||||
|
||||
An Arch installer is basically Arch Linux ISO with a relatively easy to use text-based installer. It is much easier than bare-bone Arch installation.
|
||||
|
||||
#### Anarchy Installer
|
||||
|
||||
![][42]
|
||||
|
||||
The [Anarchy installer][43] intends to provide both novice and experienced Linux users a simple and pain free way to install Arch Linux. Install when you want it, where you want it, and however you want it. That is the Anarchy philosophy.
|
||||
|
||||
Once you boot up the installer, you’ll be shown a simple [TUI menu][44], listing all the available installer options.
|
||||
|
||||
#### Zen Installer
|
||||
|
||||
![][45]
|
||||
|
||||
The [Zen Installer][46] provides a full graphical (point and click) environment for installing Arch Linux. It provides support for installing multiple desktop environments, AUR, and all of the power and flexiblity of Arch Linux with the ease of a graphical installer.
|
||||
|
||||
The ISO will boot the live environment, and then download the most current stable version of the installer after you connect to the internet. So, you will always get the newest installer with updated features.
|
||||
|
||||
### Conclusion
|
||||
|
||||
An Arch-based distribution is always an excellent hassle-free choice for the many users, but a graphical installer like Anarchy is at least a step closer to how Arch Linux truly tastes.
|
||||
|
||||
In my opinion the [real beauty of Arch Linux is its installation process][2] and for a Linux enthusiast is an opportunity to learn rather than a hassle. Arch Linux and its derivatives has a lot for you mess up with, but It’s FOSS will unravel the mystery behind the scenes. See you at my next tutorial!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/arch-based-linux-distros/
|
||||
|
||||
作者:[Dimitrios Savvopoulos][a]
|
||||
选题:[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/dimitrios/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.archlinux.org/
|
||||
[2]: https://itsfoss.com/install-arch-linux/
|
||||
[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/arch-based-linux-distributions.png?ssl=1
|
||||
[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/manjaro-20.jpg?ssl=1
|
||||
[5]: https://manjaro.org/
|
||||
[6]: https://itsfoss.com/best-linux-desktop-environments/
|
||||
[7]: https://itsfoss.com/manjaro-architect-review/
|
||||
[8]: https://itsfoss.com/manjaro-20-release/
|
||||
[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/arcolinux.png?ssl=1
|
||||
[10]: https://arcolinux.com/
|
||||
[11]: https://www.xfce.org/
|
||||
[12]: http://openbox.org/wiki/Main_Page
|
||||
[13]: https://i3wm.org/
|
||||
[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/Archlabs.jpg?ssl=1
|
||||
[15]: https://itsfoss.com/archlabs-review/
|
||||
[16]: https://en.wikipedia.org/wiki/Openbox
|
||||
[17]: https://archlabslinux.com/
|
||||
[18]: https://www.bunsenlabs.org/
|
||||
[19]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/Archman.png?ssl=1
|
||||
[20]: https://archman.org/en/
|
||||
[21]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/04_endeavouros_slide.jpg?ssl=1
|
||||
[22]: https://itsfoss.com/antergos-linux-discontinued/
|
||||
[23]: https://itsfoss.com/endeavouros/
|
||||
[24]: https://endeavouros.com/
|
||||
[25]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/RebornOS.png?ssl=1
|
||||
[26]: https://rebornos.org/
|
||||
[27]: https://anbox.io/
|
||||
[28]: https://itsfoss.com/pacman-command/
|
||||
[29]: https://itsfoss.com/aur-arch-linux/
|
||||
[30]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/Chakra_Goedel_Screenshot.png?ssl=1
|
||||
[31]: https://www.chakralinux.org/
|
||||
[32]: https://wiki.archlinux.org/index.php/PKGBUILD
|
||||
[33]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/Artix_MATE_edition.png?ssl=1
|
||||
[34]: https://artixlinux.org/
|
||||
[35]: https://en.wikipedia.org/wiki/OpenRC
|
||||
[36]: https://en.wikipedia.org/wiki/Runit
|
||||
[37]: https://en.wikipedia.org/wiki/S6_(software)
|
||||
[38]: https://en.wikipedia.org/wiki/Systemd
|
||||
[39]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/BlackArch.png?ssl=1
|
||||
[40]: https://itsfoss.com/linux-hacking-penetration-testing/
|
||||
[41]: https://itsfoss.com/best-kali-linux-tools/
|
||||
[42]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/anarchy.jpg?ssl=1
|
||||
[43]: https://anarchyinstaller.org/
|
||||
[44]: https://en.wikipedia.org/wiki/Text-based_user_interface
|
||||
[45]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/zen.jpg?ssl=1
|
||||
[46]: https://sourceforge.net/projects/revenge-installer/
|
@ -1,262 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (zhangxiangping)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (LaTeX Typesetting – Part 1 (Lists))
|
||||
[#]: via: (https://fedoramagazine.org/latex-typesetting-part-1/)
|
||||
[#]: author: (Earl Ramirez https://fedoramagazine.org/author/earlramirez/)
|
||||
|
||||
LaTeX Typesetting – Part 1 (Lists)
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
This series builds on the previous articles: [Typeset your docs with LaTex and TeXstudio on Fedora][2] and [LaTeX 101 for beginners][3]. This first part of the series is about LaTeX lists.
|
||||
|
||||
### Types of lists
|
||||
|
||||
LaTeX lists are enclosed environments, and each item in the list can take a line of text to a full paragraph. There are three types of lists available in LaTeX. They are:
|
||||
|
||||
* **Itemized**: unordered or bullet
|
||||
* **Enumerated**: ordered
|
||||
* **Description**: descriptive
|
||||
|
||||
|
||||
|
||||
### Creating lists
|
||||
|
||||
To create a list, prefix each list item with the \_item_ command. Precede and follow the list of items with the \_begin_{<type>} and \_end_{<type>} commands respectively where <type> is substituted with the type of the list as illustrated in the following examples.
|
||||
|
||||
#### Itemized list
|
||||
|
||||
```
|
||||
\begin{itemize}
|
||||
\item Fedora
|
||||
\item Fedora Spin
|
||||
\item Fedora Silverblue
|
||||
\end{itemize}
|
||||
```
|
||||
|
||||
![][4]
|
||||
|
||||
#### Enumerated list
|
||||
|
||||
```
|
||||
\begin{enumerate}
|
||||
\item Fedora CoreOS
|
||||
\item Fedora Silverblue
|
||||
\item Fedora Spin
|
||||
\end{enumerate}
|
||||
```
|
||||
|
||||
![][5]
|
||||
|
||||
#### Descriptive list
|
||||
|
||||
```
|
||||
\begin{description}
|
||||
\item[Fedora 6] Code name Zod
|
||||
\item[Fedora 8] Code name Werewolf
|
||||
\end{description}
|
||||
```
|
||||
|
||||
![][6]
|
||||
|
||||
### Spacing list items
|
||||
|
||||
The default spacing can be customized by adding \_usepackage{enumitem}_ to the preamble. The _enumitem_ package enables the _noitemsep_ option and the \_itemsep_ command which you can use on your lists as illustrated below.
|
||||
|
||||
#### Using the noitemsep option
|
||||
|
||||
Enclose the _noitemsep_ option in square brackets and place it on the \_begin_ command as shown below. This option removes the default spacing.
|
||||
|
||||
```
|
||||
\begin{itemize}[noitemsep]
|
||||
\item Fedora
|
||||
\item Fedora Spin
|
||||
\item Fedora Silverblue
|
||||
\end{itemize}
|
||||
```
|
||||
|
||||
![][7]
|
||||
|
||||
#### Using the \itemsep command
|
||||
|
||||
The \_itemsep_ command must be suffixed with a number to indicate how much space there should be between the list items.
|
||||
|
||||
```
|
||||
\begin{itemize} \itemsep0.75pt
|
||||
\item Fedora Silverblue
|
||||
\item Fedora CoreOS
|
||||
\end{itemize}
|
||||
```
|
||||
|
||||
![][8]
|
||||
|
||||
### Nesting lists
|
||||
|
||||
LaTeX supports nested lists up to four levels deep as illustrated below.
|
||||
|
||||
#### Nested itemized lists
|
||||
|
||||
```
|
||||
\begin{itemize}[noitemsep]
|
||||
\item Fedora Versions
|
||||
\begin{itemize}
|
||||
\item Fedora 8
|
||||
\item Fedora 9
|
||||
\begin{itemize}
|
||||
\item Werewolf
|
||||
\item Sulphur
|
||||
\begin{itemize}
|
||||
\item 2007-05-31
|
||||
\item 2008-05-13
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\item Fedora Spin
|
||||
\item Fedora Silverblue
|
||||
\end{itemize}
|
||||
```
|
||||
|
||||
![][9]
|
||||
|
||||
#### Nested enumerated lists
|
||||
|
||||
```
|
||||
\begin{enumerate}[noitemsep]
|
||||
\item Fedora Versions
|
||||
\begin{enumerate}
|
||||
\item Fedora 8
|
||||
\item Fedora 9
|
||||
\begin{enumerate}
|
||||
\item Werewolf
|
||||
\item Sulphur
|
||||
\begin{enumerate}
|
||||
\item 2007-05-31
|
||||
\item 2008-05-13
|
||||
\end{enumerate}
|
||||
\end{enumerate}
|
||||
\end{enumerate}
|
||||
\item Fedora Spin
|
||||
\item Fedora Silverblue
|
||||
\end{enumerate}
|
||||
```
|
||||
|
||||
![][10]
|
||||
|
||||
### List style names for each list type
|
||||
|
||||
**Enumerated** | **Itemized**
|
||||
---|---
|
||||
\alph* | $\bullet$
|
||||
\Alph* | $\cdot$
|
||||
\arabic* | $\diamond$
|
||||
\roman* | $\ast$
|
||||
\Roman* | $\circ$
|
||||
| $-$
|
||||
|
||||
### Default style by list depth
|
||||
|
||||
**Level** | **Enumerated** | **Itemized**
|
||||
---|---|---
|
||||
1 | Number | Bullet
|
||||
2 | Lowercase alphabet | Dash
|
||||
3 | Roman numerals | Asterisk
|
||||
4 | Uppercase alphabet | Period
|
||||
|
||||
### Setting list styles
|
||||
|
||||
The below example illustrates each of the different itemiszed list styles.
|
||||
|
||||
```
|
||||
% Itemize style
|
||||
\begin{itemize}
|
||||
\item[$\ast$] Asterisk
|
||||
\item[$\diamond$] Diamond
|
||||
\item[$\circ$] Circle
|
||||
\item[$\cdot$] Period
|
||||
\item[$\bullet$] Bullet (default)
|
||||
\item[--] Dash
|
||||
\item[$-$] Another dash
|
||||
\end{itemize}
|
||||
```
|
||||
|
||||
![][11]
|
||||
|
||||
There are three methods of setting list styles. They are illustrated below. These methods are listed by priority; highest priority first. A higher priority will override a lower priority if more than one is defined for a list item.
|
||||
|
||||
#### List styling method 1 – per item
|
||||
|
||||
Enclose the name of the desired style in square brackets and place it on the \_item_ command as demonstrated below.
|
||||
|
||||
```
|
||||
% First method
|
||||
\begin{itemize}
|
||||
\item[$\ast$] Asterisk
|
||||
\item[$\diamond$] Diamond
|
||||
\item[$\circ$] Circle
|
||||
\item[$\cdot$] period
|
||||
\item[$\bullet$] Bullet (default)
|
||||
\item[--] Dash
|
||||
\item[$-$] Another dash
|
||||
\end{itemize}
|
||||
```
|
||||
|
||||
#### List styling method 2 – on the list
|
||||
|
||||
Prefix the name of the desired style with _label=_. Place the parameter, including the _label=_ prefix, in square brackets on the \_begin_ command as demonstrated below.
|
||||
|
||||
```
|
||||
% Second method
|
||||
\begin{enumerate}[label=\Alph*.]
|
||||
\item Fedora 32
|
||||
\item Fedora 31
|
||||
\item Fedora 30
|
||||
\end{enumerate}
|
||||
```
|
||||
|
||||
#### List styling method 3 – on the document
|
||||
|
||||
This method changes the default style for the entire document. Use the \_renewcommand_ to set the values for the labelitems. There is a different labelitem for each of the four label depths as demonstrated below.
|
||||
|
||||
```
|
||||
% Third method
|
||||
\renewcommand{\labelitemi}{$\ast$}
|
||||
\renewcommand{\labelitemii}{$\diamond$}
|
||||
\renewcommand{\labelitemiii}{$\bullet$}
|
||||
\renewcommand{\labelitemiv}{$-$}
|
||||
```
|
||||
|
||||
### Summary
|
||||
|
||||
LaTeX supports three types of lists. The style and spacing of each of the list types can be customized. More LaTeX elements will be explained in future posts.
|
||||
|
||||
Additional reading about LaTeX lists can be found here: [LaTeX List Structures][12]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/latex-typesetting-part-1/
|
||||
|
||||
作者:[Earl Ramirez][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[zhangxiangping](https://github.com/zxp93)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/earlramirez/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2020/06/latex-series-816x345.png
|
||||
[2]: https://fedoramagazine.org/typeset-latex-texstudio-fedora
|
||||
[3]: https://fedoramagazine.org/fedora-classroom-latex-101-beginners
|
||||
[4]: https://fedoramagazine.org/wp-content/uploads/2020/06/image-1.png
|
||||
[5]: https://fedoramagazine.org/wp-content/uploads/2020/06/image-2.png
|
||||
[6]: https://fedoramagazine.org/wp-content/uploads/2020/06/image-3.png
|
||||
[7]: https://fedoramagazine.org/wp-content/uploads/2020/06/image-4.png
|
||||
[8]: https://fedoramagazine.org/wp-content/uploads/2020/06/image-5.png
|
||||
[9]: https://fedoramagazine.org/wp-content/uploads/2020/06/image-7.png
|
||||
[10]: https://fedoramagazine.org/wp-content/uploads/2020/06/image-8.png
|
||||
[11]: https://fedoramagazine.org/wp-content/uploads/2020/06/image-9.png
|
||||
[12]: https://en.wikibooks.org/wiki/LaTeX/List_Structures
|
@ -1,128 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Give Your GNOME Desktop a Tiling Makeover With Material Shell GNOME Extension)
|
||||
[#]: via: (https://itsfoss.com/material-shell/)
|
||||
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
|
||||
|
||||
Give Your GNOME Desktop a Tiling Makeover With Material Shell GNOME Extension
|
||||
======
|
||||
|
||||
There is something about tiling windows that attracts many people. Perhaps it looks good or perhaps it is time-saving if you are a fan of [keyboard shortcuts in Linux][1]. Or maybe it’s the challenge of using the uncommon tiling windows.
|
||||
|
||||
![Tiling Windows in Linux | Image Source][2]
|
||||
|
||||
From i3 to [Sway][3], there are so many tiling window managers available for Linux desktop. Configuring a tiling window manager itself requires a steep learning curve.
|
||||
|
||||
This is why projects like [Regolith desktop][4] exist to give you preconfigured tiling desktop so that you can get started with tiling windows with less effort.
|
||||
|
||||
Let me introduce you to a similar project named Material Shell that makes using tiling feature even easier than [Regolith][5].
|
||||
|
||||
### Material Shell GNOME Extension: Convert GNOME desktop into a tiling window manager
|
||||
|
||||
[Material Shell][6] is a GNOME extension and that’s the best thing about it. This means that you don’t have to log out and log in to another desktop environment or window manager. You can enable or disable it from within your current session.
|
||||
|
||||
I’ll list the features of Material Shell but it will be easier to see it in action:
|
||||
|
||||
[Subscribe to our YouTube channel for more Linux videos][7]
|
||||
|
||||
The project is called Material Shell because it follows the [Material Design][8] guideline and thus gives the applications an aesthetically pleasing interface. Here are its main features:
|
||||
|
||||
#### Intuitive interface
|
||||
|
||||
Material Shell adds a left panel for quick access. On this panel, you can find the system tray at the bottom and the search and workspaces on the top.
|
||||
|
||||
All the new apps are added to the current workspace. You can create new workspace and switch to it for organizing your running apps into categories. This is the essential concept of workspace anyway.
|
||||
|
||||
In Material Shell, every workspace can be visualized as a row with several apps rather than a box with several apps in it.
|
||||
|
||||
#### Tiling windows
|
||||
|
||||
In a workspace, you can see all your opened applications on the top all the time. By default, the applications are opened to take the entire screen like you do in GNOME desktop. You can change the layout to split it in half or multiple columns or a grid of apps using the layout changer in the top right corner.
|
||||
|
||||
This video shows all the above features at a glance:
|
||||
|
||||
#### Persistent layout and workspaces
|
||||
|
||||
That’s not it. Material Shell also remembers the workspaces and windows you open so that you don’t have to reorganize your layout again. This is a good feature to have as it saves time if you are particular about which application goes where.
|
||||
|
||||
#### Hotkeys/Keyboard shortcut
|
||||
|
||||
Like any tiling windows manager, you can use keyboard shortcuts to navigate between applications and workspaces.
|
||||
|
||||
* `Super+W` Navigate to the upper workspace.
|
||||
* `Super+S` Navigate to the lower workspace.
|
||||
* `Super+A` Focus the window at the left of the current window.
|
||||
* `Super+D` Focus the window at the right of the current window.
|
||||
* `Super+1`, `Super+2` … `Super+0` Navigate to specific workspace
|
||||
* `Super+Q` Kill the current window focused.
|
||||
* `Super+[MouseDrag]` Move window around.
|
||||
* `Super+Shift+A` Move the current window to the left.
|
||||
* `Super+Shift+D` Move the current window to the right.
|
||||
* `Super+Shift+W` Move the current window to the upper workspace.
|
||||
* `Super+Shift+S` Move the current window to the lower workspace.
|
||||
|
||||
|
||||
|
||||
### Installing Material Shell
|
||||
|
||||
Warning!
|
||||
|
||||
Tiling windows could be confusing for many users. You should be familiar with GNOME Extensions to use it. Avoid trying it if you are absolutely new to Linux or if you are easily panicked if anything changes in your system.
|
||||
|
||||
Material Shell is a GNOME extension. So, please [check your desktop environment][9] to make sure you are running _**GNOME 3.34 or higher version**_.
|
||||
|
||||
I would also like to add that tiling windows could be confusing for many users.
|
||||
|
||||
Apart from that, I noticed that after disabling Material Shell it removes the top bar from Firefox and the Ubuntu dock. You can get the dock back by disabling/enabling Ubuntu dock extension from the Extensions app in GNOME. I haven’t tried but I guess these problems should also go away after a system reboot.
|
||||
|
||||
I hope you know [how to use GNOME extensions][10]. The easiest way is to just [open this link in the browser][11], install GNOME extension plugin and then enable the Material Shell extension.
|
||||
|
||||
![][12]
|
||||
|
||||
If you don’t like it, you can disable it from the same extension link you used earlier or use the GNOME Extensions app:
|
||||
|
||||
![][13]
|
||||
|
||||
**To tile or not?**
|
||||
|
||||
I use multiple screens and I found that Material Shell doesn’t work well with multiple monitors. This is something the developer(s) can improve in the future.
|
||||
|
||||
Apart from that, it’s a really easy to get started with tiling windows with Material Shell. If you try Material Shell and like it, appreciate the project by [giving it a star or sponsoring it on GitHub][14].
|
||||
|
||||
For some reasons, tiling windows are getting popular. Recently released [Pop OS 20.04][15] also added tiling window features.
|
||||
|
||||
But as I mentioned previously, tiling layouts are not for everyone and it could confuse many people.
|
||||
|
||||
How about you? Do you prefer tiling windows or you prefer the classic desktop layout?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/material-shell/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/abhishek/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://itsfoss.com/ubuntu-shortcuts/
|
||||
[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/linux-ricing-example-800x450.jpg?resize=800%2C450&ssl=1
|
||||
[3]: https://itsfoss.com/sway-window-manager/
|
||||
[4]: https://itsfoss.com/regolith-linux-desktop/
|
||||
[5]: https://regolith-linux.org/
|
||||
[6]: https://material-shell.com
|
||||
[7]: https://www.youtube.com/c/itsfoss?sub_confirmation=1
|
||||
[8]: https://material.io/
|
||||
[9]: https://itsfoss.com/find-desktop-environment/
|
||||
[10]: https://itsfoss.com/gnome-shell-extensions/
|
||||
[11]: https://extensions.gnome.org/extension/3357/material-shell/
|
||||
[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/09/install-material-shell.png?resize=800%2C307&ssl=1
|
||||
[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/09/material-shell-gnome-extension.png?resize=799%2C497&ssl=1
|
||||
[14]: https://github.com/material-shell/material-shell
|
||||
[15]: https://itsfoss.com/pop-os-20-04-review/
|
@ -1,304 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (My first day using Ansible)
|
||||
[#]: via: (https://opensource.com/article/20/10/first-day-ansible)
|
||||
[#]: author: (David Both https://opensource.com/users/dboth)
|
||||
|
||||
My first day using Ansible
|
||||
======
|
||||
A sysadmin shares information and advice about putting Ansible into
|
||||
real-world use configuring computers on his network.
|
||||
![People work on a computer server with devices][1]
|
||||
|
||||
Getting a new computer, whether physical or virtual, up and running is time-consuming and requires a good deal of work—whether it's your first time or the 50th. For many years, I have used a series of scripts and RPMs that I created to install the packages I need and to perform many bits of configuration for my favorite tools. This approach has worked well and simplified my work, as well as reduced the amount of time I spend typing commands.
|
||||
|
||||
I am always looking for better ways of doing things, and, for several years now, I have been hearing and reading about [Ansible][2], which is a powerful tool for automating system configuration and management. Ansible allows a sysadmin to define a specific state for each host in one or more playbooks and then performs whatever tasks are necessary to bring the host to that state. This includes installing or deleting various resources such as RPM or Apt packages, configuration and other files, users, groups, and much more.
|
||||
|
||||
I have delayed learning how to use it for a long time because—stuff. Until recently, when I ran into a problem that I thought Ansible could easily solve.
|
||||
|
||||
This article is not a complete how-to for getting started with Ansible; rather, it is intended to provide insight into some of the issues that I encountered and some information that I found only in some very obscure places. Much of the information I found in various online discussions and Q&A groups about Ansible was incorrect. Errors ranged from information that was really old with no indication of its date or provenance to information that was just wrong.
|
||||
|
||||
The information in this article is known to work—although there might be other ways of accomplishing the same things—and it works with Ansible 2.9.13 and [Python][3] 3.8.5.
|
||||
|
||||
### My problem
|
||||
|
||||
All of my best learning experiences start with a problem I need to solve, and this was no exception.
|
||||
|
||||
I have been working on a little project to modify the configuration files for the [Midnight Commander][4] (mc) file manager and pushing them out to various systems on my network for testing. Although I have a script to automate this, it still requires a bit of fussing with a command-line loop to provide the names of the systems to which I want to push the new code. The large number of changes I was making to the configuration files made it necessary for me to push the new ones frequently. But, just when I thought I had my new configuration just right, I would find a problem and need to do another push after making the fix.
|
||||
|
||||
This environment made it difficult to keep track of which systems had the new files and which did not. I also have a couple of hosts that need to be treated differently. And my little bit of knowledge about Ansible suggested that it would probably be able to do all or most of what I need.
|
||||
|
||||
### Getting started
|
||||
|
||||
I had read a number of good articles and books about Ansible, but never in an "I have to get this working NOW!" kind of situation. And now was—well, NOW!
|
||||
|
||||
In rereading these documents, I discovered that they mostly talk about how to install Ansible from GitHub using—wait for it—Ansible. That is cool, but I really just wanted to get started, so I installed it on my Fedora workstation using DNF and the version in the Fedora repository. Easy.
|
||||
|
||||
But then I started looking for the file locations and trying to determine which configuration files I needed to modify, where to keep my playbooks, what a playbook even looks like, and what it does. I had lots of (so far) unanswered questions running around in my head.
|
||||
|
||||
So, without further descriptions of my tribulations, here are the things I discovered and that got me going.
|
||||
|
||||
### Configuration
|
||||
|
||||
Ansible's configuration files are kept in `/etc/ansible`. Makes sense, right, since `/etc` is where system programs are supposed to keep their configuration files. The two files I needed to work with are `ansible.cfg` and `hosts`.
|
||||
|
||||
#### ansible.cfg
|
||||
|
||||
After getting started with some of the exercises I found in the documents and online, I began receiving warning messages about deprecating certain older Python files. So, I set `deprecation_warnings` to `false` in `ansible.cfg` and those angry red warning messages stopped:
|
||||
|
||||
|
||||
```
|
||||
`deprecation_warnings = False`
|
||||
```
|
||||
|
||||
Those warnings are important, so I will revisit them later and figure out what I need to do. But for now, they no longer clutter the screen and obfuscate the errors I actually need to be concerned about.
|
||||
|
||||
#### The hosts file
|
||||
|
||||
Not the same as the `/etc/hosts` file, the `hosts` file is also known as the inventory file, and it lists the hosts on your network. This file allows grouping hosts together in related sets, such as servers, workstations, and pretty much any designation you need. This file contains its own help and plenty of examples, so I won't go into boring detail here. However, there are some things to know.
|
||||
|
||||
Hosts can be listed outside of any groups, but groups can be helpful in identifying hosts with one or more common characteristics. Groups use the INI format, so a server group looks like this:
|
||||
|
||||
|
||||
```
|
||||
[servers]
|
||||
server1
|
||||
server2
|
||||
...etc.
|
||||
```
|
||||
|
||||
A hostname must be present in this file for Ansible to work on it. Even though some subcommands allow you to specify a hostname, the command will fail unless the hostname is in the `hosts` file. A host can also be listed in multiple groups. So `server1` might also be a member of the `[webservers]` group in addition to the `[servers]` group, and a member of the `[ubuntu]` group to differentiate it from Fedora servers.
|
||||
|
||||
Ansible is smart. If the `all` argument is used for the hostname, Ansible scans the file and performs the defined tasks on all hosts listed in the file. Ansible will only attempt to work on each host once, no matter how many groups it appears in. This also means that there does not need to be a defined "all" group because Ansible can determine all hostnames in the file and create its own list of unique hostnames.
|
||||
|
||||
Another little thing to look out for is multiple entries for a single host. I use `CNAME` records in my DNS zone file to create aliased names that point to the [A records][5] for some of my hosts. That way, I can refer to a host as `host1` or `h1` or `myhost`. If you use multiple hostnames for the same host in the `hosts` file, Ansible will try to perform its tasks on all of those hostnames; it has no way of knowing that they refer to the same host. The good news is that this does not affect the overall result; it just takes a bit more time as Ansible works on the secondary hostnames and determines that all of the operations have already been performed.
|
||||
|
||||
### Ansible facts
|
||||
|
||||
Most of the materials I have read on Ansible talk about [Ansible facts][6], which "are data related to your remote systems, including operating systems, IP addresses, attached filesystems, and more." This information is available in other ways, such as `lshw`, `dmidecode`, the `/proc` filesystem, and more, but Ansible generates a JSON file containing this information. Each time Ansible runs, it generates this facts data. There is an amazing amount of information in this data stream, all of which are in `<"variable-name": "value">` pairs. All of these variables are available for use within an Ansible playbook. The best way to understand the huge amount of information available is to display it yourself:
|
||||
|
||||
|
||||
```
|
||||
`# ansible -m setup <hostname> | less`
|
||||
```
|
||||
|
||||
See what I mean? Everything you ever wanted to know about your host hardware and Linux distribution is there and usable in a playbook. I have not yet gotten to the point where I need to use those variables, but I am certain I will in the next couple of days.
|
||||
|
||||
### Modules
|
||||
|
||||
The `ansible` command above uses the `-m` option to specify the "setup" module. Ansible has many modules already built-in, so you do not need to use the `-m` for those. There are also many downloadable modules that can be installed, but the built-ins do everything I have needed for my current projects so far.
|
||||
|
||||
### Playbooks
|
||||
|
||||
Playbooks can be located almost anywhere. Since I need to run my playbooks as root, I placed mine in `/root/ansible`. As long as this directory is the present working directory (PWD) when I run Ansible, it can find my playbook. Ansible also has a runtime option to specify a different playbook and location.
|
||||
|
||||
Playbooks can contain comments, although I have seen very few articles or books that mention this. As a sysadmin who believes in documenting everything, I find using comments can be very helpful. This is not so much about saying the same things in the comments as I do in the task name; rather, it is about identifying the purpose of groups of tasks and ensuring that I record my reasons for doing certain things in a certain way or order. This can help with debugging problems later when I may have forgotten my original thinking.
|
||||
|
||||
Playbooks are simply collections of tasks that define the desired state of a host. A hostname or inventory group is specified at the beginning of the playbook and defines the hosts on which Ansible will run the playbook.
|
||||
|
||||
Here is a sample of my playbook:
|
||||
|
||||
|
||||
```
|
||||
################################################################################
|
||||
# This Ansible playbook updates Midnight commander configuration files. #
|
||||
################################################################################
|
||||
\- name: Update midnight commander configuration files
|
||||
hosts: all
|
||||
|
||||
tasks:
|
||||
- name: ensure midnight commander is the latest version
|
||||
dnf:
|
||||
name: mc
|
||||
state: present
|
||||
|
||||
- name: create ~/.config/mc directory for root
|
||||
file:
|
||||
path: /root/.config/mc
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: create ~/.config/mc directory for dboth
|
||||
file:
|
||||
path: /home/dboth/.config/mc
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: dboth
|
||||
group: dboth
|
||||
|
||||
- name: copy latest personal skin
|
||||
copy:
|
||||
src: /root/ansible/UpdateMC/files/MidnightCommander/DavidsGoTar.ini
|
||||
dest: /usr/share/mc/skins/DavidsGoTar.ini
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: copy latest mc ini file
|
||||
copy:
|
||||
src: /root/ansible/UpdateMC/files/MidnightCommander/ini
|
||||
dest: /root/.config/mc/ini
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: copy latest mc panels.ini file
|
||||
copy:
|
||||
src: /root/ansible/UpdateMC/files/MidnightCommander/panels.ini
|
||||
dest: /root/.config/mc/panels.ini
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
<SNIP>
|
||||
```
|
||||
|
||||
The playbook starts with its own name and the hosts it will act on—in this case, all of the hosts listed in my `hosts` file. The `tasks` section lists the specific tasks required to bring the host into compliance with the desired state. This playbook starts with a task in which Ansible's built-in DNF updates Midnight Commander if it is not the most recent release. The next tasks ensure that the required directories are created if they do not exist, and the remainder of the tasks copy the files to the proper locations. These `file` and `copy` tasks can also set the ownership and file modes for the directories and files.
|
||||
|
||||
The details of my playbook are beyond the scope of this article, but I used a bit of a brute-force attack on the problem. There are other methods for determining which users need to have the files updated rather than using a task for each file for each user. My next objective is to simplify this playbook to use some of the more advanced techniques.
|
||||
|
||||
Running a playbook is easy; just use the `ansible-playbook` command. The .yml extension stands for YAML. I have seen several meanings for that, but my bet is on "Yet Another Markup Language," despite the fact that some claim that YAML is not one.
|
||||
|
||||
This command runs the playbook I created for updating my Midnight Commander files:
|
||||
|
||||
|
||||
```
|
||||
`# ansible-playbook -f 10 UpdateMC.yml`
|
||||
```
|
||||
|
||||
The `-f` option specifies that Ansible should fork up to 10 threads in order to perform operations in parallel. This can greatly speed overall task completion, especially when working on multiple hosts.
|
||||
|
||||
### Output
|
||||
|
||||
The output from a running playbook lists each task and the results. An `ok` means the machine state managed by the task is already defined in the task stanza. Because the state defined in the task is already true, Ansible did not need to perform the actions defined in the task stanza.
|
||||
|
||||
The response `changed` indicates that Ansible performed the task specified in the stanza in order to bring it to the desired state. In this case, the machine state defined in the stanza was not true, so the actions defined were performed to make it true. On a color-capable terminal, the `TASK` lines are shown in color. On my host with my amber-on-black terminal color configuration, the `TASK` lines are shown in amber, `changed` lines are in brown, and `ok` lines are shown in green. Error lines are displayed in red.
|
||||
|
||||
The following output is from the playbook I will eventually use to perform post-install configuration on new hosts:
|
||||
|
||||
|
||||
```
|
||||
PLAY [Post-installation updates, package installation, and configuration]
|
||||
|
||||
TASK [Gathering Facts]
|
||||
ok: [testvm2]
|
||||
|
||||
TASK [Ensure we have connectivity]
|
||||
ok: [testvm2]
|
||||
|
||||
TASK [Install all current updates]
|
||||
changed: [testvm2]
|
||||
|
||||
TASK [Install a few command line tools]
|
||||
changed: [testvm2]
|
||||
|
||||
TASK [copy latest personal Midnight Commander skin to /usr/share]
|
||||
changed: [testvm2]
|
||||
|
||||
TASK [create ~/.config/mc directory for root]
|
||||
changed: [testvm2]
|
||||
|
||||
TASK [Copy the most current Midnight Commander configuration files to /root/.config/mc]
|
||||
changed: [testvm2] => (item=/root/ansible/PostInstallMain/files/MidnightCommander/DavidsGoTar.ini)
|
||||
changed: [testvm2] => (item=/root/ansible/PostInstallMain/files/MidnightCommander/ini)
|
||||
changed: [testvm2] => (item=/root/ansible/PostInstallMain/files/MidnightCommander/panels.ini)
|
||||
|
||||
TASK [create ~/.config/mc directory in /etc/skel]
|
||||
changed: [testvm2]
|
||||
|
||||
<SNIP>
|
||||
```
|
||||
|
||||
### The cow
|
||||
|
||||
If you have the [cowsay][7] program installed on your computer, you will notice that the `TASK` names appear in the cow's speech bubble:
|
||||
|
||||
|
||||
```
|
||||
____________________________________
|
||||
< TASK [Ensure we have connectivity] >
|
||||
------------------------------------
|
||||
\ ^__^
|
||||
\ (oo)\\_______
|
||||
(__)\ )\/\
|
||||
||----w |
|
||||
|| ||
|
||||
```
|
||||
|
||||
If you do not have this fun feature and want it, install the cowsay package using your distribution's package manager. If you have this and don't want it, disable it with by setting `nocows = 1` in the `/etc/ansible/ansible.cfg` file.
|
||||
|
||||
I like the cow and think it is fun, but it reduces the amount of screen space that can be used to display messages. So I disabled it after it started getting in the way.
|
||||
|
||||
### Files
|
||||
|
||||
As with my Midnight Commander task, it is frequently necessary to install and maintain files of various types. There are as many "best practices" for creating a directory tree for storing files used in playbooks as there are sysadmins—or at least as many as the number of authors writing books and articles about Ansible.
|
||||
|
||||
I chose a simple structure that makes sense to me:
|
||||
|
||||
|
||||
```
|
||||
/root/ansible
|
||||
└── UpdateMC
|
||||
├── files
|
||||
│ └── MidnightCommander
|
||||
│ ├── DavidsGoTar.ini
|
||||
│ ├── ini
|
||||
│ └── panels.ini
|
||||
└── UpdateMC.yml
|
||||
```
|
||||
|
||||
You should use whatever structure works for you. Just be aware that some other sysadmin will likely need to work with whatever you set up, so there should be some level of logic to it. When I was using RPM and Bash scripts to perform my post-install tasks, my file repository was a bit scattered and definitely not structured with any logic. As I work through creating playbooks for many of my administrative tasks, I will introduce a much more logical structure for managing my files.
|
||||
|
||||
### Multiple playbook runs
|
||||
|
||||
It is safe to run a playbook as many times as needed or desired. Each task will only be executed if the state does not match the one specified in the task stanza. This makes it easy to recover from errors encountered during previous playbook runs. The playbook stops running when it encounters an error.
|
||||
|
||||
While testing my first playbook, I made many mistakes and corrected them. Each additional run of the playbook—assuming my fix is a good one—skips the tasks whose state already matches the specified one and executes those that did not. When my fix works, the previously failed task completes successfully, and any tasks after that one in my playbook also execute—until it encounters another error.
|
||||
|
||||
This also makes testing easy. I can add new tasks and, when I run the playbook, only those new tasks are performed because they are the only ones that do not match the test host's desired state.
|
||||
|
||||
### Some thoughts
|
||||
|
||||
Some tasks are not appropriate for Ansible because there are better methods for achieving a specific machine state. The use case that comes to mind is that of returning a VM to an initial state so that it can be used as many times as necessary to perform testing beginning with that known state. It is much easier to get the VM into the desired state and then to take a snapshot of the then-current machine state. Reverting to that snapshot is usually going to be easier and much faster than using Ansible to return the host to that desired state. This is something I do several times a day when researching articles or testing new code.
|
||||
|
||||
After completing my playbook for updating Midnight Commander, I started a new playbook that I will use to perform post-installation tasks on newly installed Fedora hosts. I have already made good progress, and the playbook is a bit more sophisticated and less brute-force than my first one.
|
||||
|
||||
On my very first day using Ansible, I created a playbook that solves a problem. I also started a second playbook that will solve the very big problem of post-install configuration. And I have learned a lot.
|
||||
|
||||
Although I really like using [Bash][8] scripts for many of my administrative tasks, I am already finding that Ansible can do everything I want—and in a way that can maintain the system in the state I want. After only a single day of use, I am an Ansible fan.
|
||||
|
||||
### Resources
|
||||
|
||||
The most complete and useful document I have found is the [User Guide][9] on the Ansible website. This document is intended as a reference and not a how-to or getting-started document.
|
||||
|
||||
Opensource.com has published many [articles about Ansible][10] over the years, and I have found most of them very helpful for my needs. The Enable Sysadmin website also has a lot of [Ansible articles][11] that I have found to be helpful. You can learn even more by checking out [AnsibleFest][12] happening this week (October 13-14, 2020). The event is completely virtual and free to register.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/10/first-day-ansible
|
||||
|
||||
作者:[David Both][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/dboth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux11x_cc.png?itok=XMDOouJR (People work on a computer server with devices)
|
||||
[2]: https://www.ansible.com/
|
||||
[3]: https://www.python.org/
|
||||
[4]: https://midnight-commander.org/
|
||||
[5]: https://en.wikipedia.org/wiki/List_of_DNS_record_types
|
||||
[6]: https://docs.ansible.com/ansible/latest/user_guide/playbooks_vars_facts.html#ansible-facts
|
||||
[7]: https://en.wikipedia.org/wiki/Cowsay
|
||||
[8]: https://opensource.com/downloads/bash-cheat-sheet
|
||||
[9]: https://docs.ansible.com/ansible/latest/user_guide/index.html
|
||||
[10]: https://opensource.com/tags/ansible
|
||||
[11]: https://www.redhat.com/sysadmin/topics/ansible
|
||||
[12]: https://www.ansible.com/ansiblefest
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user