diff --git a/published/20170918 Fun and Games in Emacs.md b/published/20170918 Fun and Games in Emacs.md new file mode 100644 index 0000000000..2602ba804c --- /dev/null +++ b/published/20170918 Fun and Games in Emacs.md @@ -0,0 +1,220 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11949-1.html) +[#]: subject: (Fun and Games in Emacs) +[#]: via: (https://www.masteringemacs.org/article/fun-games-in-emacs) +[#]: author: (Mickey Petersen https://www.masteringemacs.org/about) + +“Emacs 游戏机”完全指南 +====== + +又是周一,你正在为你的老板 Lumbergh (LCTT 译注:《上班一条虫》中的副总裁)努力倒腾那些 [无聊之极的文档][1]。为什么不玩玩 Emacs 中类似 zork 的文字冒险游戏来让你的大脑从单调的工作中解脱出来呢? + +但说真的,Emacs 中既有游戏,也有古怪的玩物。有些你可能有所耳闻。这些玩意唯一的共同点就是,它们大多是很久以前就添加到 Emacs 中的:有些东西真的是相当古怪(如你将在下面看到的),而另一些则显然是由无聊的员工或学生们编写的。它们全有一个共同点,都带着一种奇思妙想和随意性,这在今天的 Emacs 中很少见。Emacs 现在变得十分严肃,在某种程度上,它已经与 20 世纪 80 年代那些游戏被编写出来的时候大不一样。 + +### 汉诺塔 + +[汉诺塔][2] 是一款古老的数学解密游戏,有些人可能对它很熟悉,因为它的递归和迭代解决方案经常被用于计算机科学教学辅助。 + +![Tower of Hanoi Screenshot](https://www.masteringemacs.org/static/uploads/hanoi.png) + +Emacs 中有三个命令可以运行汉诺塔:`M-x hanoi` 默认为 3 个碟子; `M-x hanoi-unix` 和 `M-x hanoi-unix-64` 使用 unix 时间戳的位数(32 位或 64 位)作为默认盘子的个数,并且每秒钟自动移动一次,两者不同之处在于后者假装使用 64 位时钟(因此有 64 个碟子)。 + +Emacs 中汉诺塔的实现可以追溯到 20 世纪 80 年代中期——确实是久得可怕。它有一些自定义选项(`M-x customize-group RET hanoi RET`),如启用彩色碟子等。当你离开汉诺塔缓冲区或输入一个字符,你会收到一个讽刺的告别信息(见上图)。 + +### 5x5 + +![5x5 game grid](https://www.masteringemacs.org/static/uploads/5x5.png) + +5x5 的游戏是一个逻辑解密游戏:你有一个 5x5 的网格,中间的十字被填满;你的目标是通过按正确的顺序切换它们的空满状态来填充所有的单元格,从而获得胜利。这并不像听起来那么容易! + +输入 `M-x 5x5` 就可以开始玩了,使用可选的数字参数可以改变网格的大小。这款游戏的有趣之处在于它能向你建议下一步行动并尝试找到该游戏网格的解法。它用到了 Emacs 自己的一款非常酷的符号 RPN 计算器 `M-x calc`(在《[Emacs 快乐计算][3]》这篇文章中,我使用它来解决了一个简单的问题)。 + +所以我喜欢这个游戏的原因是它提供了一个非常复杂的解题器——真的,你应该通过 `M-x find-library RET 5x5` 来阅读其源代码——这是一个试图通过暴力破解游戏解法的“破解器”。 + +创建一个更大的游戏网格,例如输入 `M-10 M-x 5x5`,然后运行下面某个 `crack` 命令。破解器将尝试通过迭代获得最佳解决方案。它会实时运行该游戏,观看起来非常有趣: + +- `M-x 5x5-crack-mutating-best`: 试图通过变异最佳解决方案来破解 5x5。 +- `M-x 5x5-crack-mutating-current`: 试图通过变异当前解决方案来破解 5x5。 +- `M-x 5x5-crack-random`: 尝试使用随机方案解破解 5x5。 +- `M-x 5x5-crack-xor-mutate`: 尝试通过将当前方案和最佳方案进行异或运算来破解 5x5。 + +### 文本动画 + +你可以通过运行 `M-x animation-birthday-present` 并给出你的名字来显示一个奇特的生日礼物动画。它看起来很酷! + +![xkcd](https://imgs.xkcd.com/comics/real_programmers.png) + +这里用的 `animate` 包也用在了 `M-x butterfly` 命令中,这是一个向上面的 [XKCD][4] 漫画致敬而添加到 Emacs 中的命令。当然,漫画中的 Emacs 命令在技术上是无效的,但它的幽默足以弥补这一点。 + +### 黑箱 + +我将逐字引用这款游戏的目标: + +> 游戏的目标是通过向黑盒子发射光线来找到四个隐藏的球。有四种可能: +> 1) 射线将通过盒子不受干扰; +> 2) 它将击中一个球并被吸收; +> 3) 它将偏转并退出盒子,或 +> 4) 立即偏转,甚至不能进入盒子。 + +所以,这有点像我们小时候玩的[战舰游戏][5],但是……是专为物理专业高学历的人准备的吧? + +这是另一款添加于 20 世纪 80 年代的游戏。我建议你输入 `C-h f blackbox` 来阅读玩法说明(文档巨大)。 + + +### 泡泡 + +![Bubbles game](https://www.masteringemacs.org/static/uploads/bubbles.png) + +`M-x bubble` 游戏相当简单:你必须用尽可能少移动清除尽可能多的“泡泡”。当你移除气泡时,其他气泡会掉落并粘在一起。这是一款有趣的游戏,此外如果你使用 Emacs 的图形用户界面,它还支持图像显示。而且它还支持鼠标。 + +你可以通过调用 `M-x bubbles-set-game-` 来设置难度,其中 `` 可以是这些之一:`easy`、`medium`、`difficult`、`hard` 或 `userdefined`。此外,你可以使用:`M-x custom-group bubbles` 来更改图形、网格大小和颜色。 + +由于它即简单又有趣,这是 Emacs 中我最喜欢的游戏之一。 + +### 幸运饼干 + +我喜欢 `fortune` 命令。每当我启动一个新 shell 时,这些与文学片段、谜语相结合的刻薄、无益、常常带有讽刺意味的“建议”就会点亮我的一天。 + +令人困惑的是,Emacs 中有两个包或多或少地做着类似的事情:`fortune` 和 `cookie`。前者主要用于在电子邮件签名中添加幸运饼干消息,而后者只是一个简单的 fortune 格式阅读器。 + +不管怎样,使用 Emacs 的 `cookie` 包前,你首先需要通过 `customize-option RET cookie RET` 来自定义变量 `cookie-file` 告诉它从哪找到 fortune 文件。 + +如果你的操作系统是 Ubuntu,那么你先安装 `fortune` 软件包,然后就能在 `/usr/share/games/fortune/` 目录中找到这些文件了。 + +之后你就可以调用 `M-x cookie` 随机显示 fortune 内容,或者,如果你想的话,也可以调用 `M-x cookie-apropos` 查找所有匹配的饼干。 + +### 破译器 + +这个包完美地抓住了 Emacs 的功利本质:这个包为你破解简单的替换密码(如“密码谜题”)提供了一个很有用的界面。你知道,二十多年前,有些人确实迫切需要破解很多基本的密码。正是像这个模块这样的小玩意让我非常高兴地用起 Emacs 来:一个只对少数人有用的模块,但是,如果你突然需要它了,那么它就在那里等着你。 + +那么如何使用它呢?让我们假设使用 “rot13” 密码:在 26 个字符的字母表中,将字符旋转 13 个位置。 +通过 `M-x ielm` (Emacs 用于 [运行 Elisp][6] 的 REPL 环境)可以很容易在 Emacs 中进行尝试: + +``` +*** Welcome to IELM *** Type (describe-mode) for help. +ELISP> (rot13 "Hello, World") +"Uryyb, Jbeyq" +ELISP> (rot13 "Uryyb, Jbeyq") +"Hello, World" +ELISP> +``` + +简而言之,你将明文旋转了 13 个位置,就得到了密文。你又旋转了一次 13 个位置,就返回了最初的明文。 这就是这个包可以帮助你解决的问题。 + +那么,decipher 模块又是如何帮助我们的呢?让我们创建一个新的缓冲区 `test-cipher` 并输入你的密文(在我的例子中是 `Uryyb,Jbeyq`)。 + +![cipher](https://www.masteringemacs.org/static/uploads/cipher.png) + +你现在面对的是一个相当复杂的界面。现在把光标放在紫色行的密文的任意字符上,并猜测这个字符可能是什么:Emacs 将根据你的选择更新其他明文的猜测结果,并告诉你目前为止字母表中的字符是如何分配的。 + +你现在可以用下面各种助手命令来关闭选项,以帮助推断密码字符可能对应的明文字符: + +- `D`: 列出示意图(该加密算法中双字符对)及其频率 +- `F`: 表示每个密文字母的频率 +- `N`: 显示字符的邻近信息。我不确定这是干啥的。 +- `M` 和 `R`: 保存和恢复一个检查点,允许你对工作进行分支以探索破解密码的不同方法。 + +总而言之,对于这样一个深奥的任务,这个包是相当令人印象深刻的!如果你经常破解密码,也许这个程序包能帮上忙? + +### 医生 + +![doctor](https://www.masteringemacs.org/static/uploads/doctor.png) + +啊,Emacs 医生。其基于最初的 [ELIZA][7],“医生”试图对你说的话进行心理分析,并试图把问题复述给你。体验几分钟,相当有趣,它也是 Emacs 中最著名的古怪玩意之一。你可以使用 `M-x doctor` 来运行它。 + +### Dunnet + +Emacs 自己特有的类 Zork 文字冒险游戏。输入 `M-x dunnet` 就能玩了。这是一款相当不错的游戏,简单的说,它是另一款非常著名的 Emacs 游戏,很少有人真正玩到通关。 + +如果你发现自己能在无聊的文档工作之间空出时间来,那么这是一个超级棒的游戏,内置“老板屏幕”,因为它是纯文本的。 + +哦,还有,不要想着吃掉那块 CPU 卡 :) + +### 五子棋 + +![gomoku](https://www.masteringemacs.org/static/uploads/gomoku.png) + +另一款写于 20 世纪 80 年代的游戏。你必须将 5 个方块连成一条线,井字棋风格。你可以运行 `M-x gomoku` 来与 Emacs 对抗。游戏还支持鼠标,非常方便。你也可以自定义 `gomoku` 组来调整网格的大小。 + +### 生命游戏 + +[康威的生命游戏][8] 是细胞自动机的一个著名例子。Emacs 版本提供了一些启动模式,你可以(通过 elisp 编程)调整 `life-patterns` 变量来更改这些模式。 + +你可以用 `M-x life` 触发生命游戏。事实上,所有的东西,包括显示代码、注释等等一切,总共不到 300 行,这也让人印象深刻。 + +### 乒乓,贪吃蛇和俄罗斯方块 + +![tetris](https://www.masteringemacs.org/static/uploads/tetris.png) + +这些经典游戏都是使用 Emacs 包 `gamegrid` 实现的,这是一个用于构建网格游戏(如俄罗斯方块和贪吃蛇)的通用框架。gamegrid 包的伟大之处在于它同时兼容图形化和终端 Emacs:如果你在 GUI 中运行 Emacs,你会得到精美的图形;如果你没有,你看到简单的 ASCII 艺术。 + +你可以通过输入 `M-x pong`、`M-x snake`、`M-x tetris` 来运行这些游戏。 + +特别是俄罗斯方块游戏实现的非常到位,会逐渐增加速度并且能够滑块。而且既然你已经有了源代码,你完全可以移除那个讨厌的 Z 形块,没人喜欢它! + +### Solitaire + +![solitaire image](https://www.masteringemacs.org/static/uploads/solitaire.png) + +可惜,这不是纸牌游戏,而是一个基于“钉子”的游戏,你可以选择一块石头(`o`)并“跳过”相邻的石头进入洞中(`.`),并在这个过程中去掉你跳过的石头,最终只能在棋盘上留下一块石头,重复该过程直到棋盘被请空(只保留一个石头)。 + +如果你卡住了,有一个内置的解题器名为 `M-x solitire-solve`。 + +### Zone + +我的另一个最爱。这是一个屏幕保护程序——或者更确切地说,是一系列的屏幕保护程序。 + +输入 `M-x zone`,然后看看屏幕上发生了什么! + +你可以通过运行 `M-x zone-when-idle`(或从 elisp 调用它)来配置屏幕保护程序的空闲时间,时间以秒为单位。你也可以通过 `M-x zone-leave-me-alone` 来关闭它。 + +如果在你的同事看着的时候启动它,你的同事肯定会抓狂的。 + +### 乘法解谜 + +![mpuz](https://www.masteringemacs.org/static/uploads/mpuz.png) + +这是另一个脑筋急转弯的益智游戏。当你运行 `M-x mpuz` 时,将看到一个乘法解谜题,你必须将字母替换为对应的数字,并确保数字相加(相乘?)符合结果。 + +如果遇到难题,可以运行 `M-x mpuz-show-solution` 来解决。 + +### 杂项 + +还有更多好玩的东西,但它们就不如刚才那些那么好玩好用了: + +- 你可以通过 `M-x morse-region` 和 `M-x unmorse-region` 将一个区域翻译成莫尔斯电码。 +- Dissociated Press 是一个非常简单的命令,它将一个类似随机穿行的马尔可夫链生成器应用到缓冲区中的文本中,并以此生成无意义的文本。试一下 `M-x dissociated-press`。 +- `gametree` 软件包是一个通过电子邮件记录和跟踪国际象棋游戏的复杂方法。 +- `M-x spook` 命令插入随机单词(通常是到电子邮件中),目的是混淆/超载 “NSA 拖网渔船” —— 记住,这个模块可以追溯到 20 世纪 80 年代和 90 年代,那时应该有间谍们在监听各种单词。当然,即使是在十年前,这样做也会显得非常偏执和古怪,不过现在看来已经不那么奇怪了…… + +### 总结 + +我喜欢 Emacs 附带的游戏和玩具。它们大多来自于,嗯,我们姑且称之为一个不同的时代:一个允许或甚至鼓励奇思妙想的时代。有些玩意非常经典(如俄罗斯方块和汉诺塔),有些对经典游戏进行了有趣的变种(如黑盒)——但我很高兴这么多年后它们依然存在于 Emacs 中。我想知道时至今日,类似这些的玩意是否还会再纳入 Emacs 的代码库中;嗯,它们很可能不会——它们将被归入包管理仓库中,而在这个干净而无菌的世界中,它们无疑属于包管理仓库。 + +Emacs 要求将对 Emacs 体验不重要的内容转移到包管理仓库 ELPA 中。我的意思是,作为一个开发者,这是有道理的,但是……对于每一个被移出并流放到 ELPA 的包,我们是不是在蚕食 Emacs 的精髓? + +-------------------------------------------------------------------------------- + + +via: https://www.masteringemacs.org/article/fun-games-in-emacs + +作者:[Mickey Petersen][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.masteringemacs.org/about +[b]:https://github.com/lujun9972 +[1]:https://en.wikipedia.org/wiki/Office_Space +[2]:https://en.wikipedia.org/wiki/Tower_of_Hanoi +[3]:https://www.masteringemacs.org/article/fun-emacs-calc +[4]:http://www.xkcd.com +[5]:https://en.wikipedia.org/wiki/Battleship_(game) +[6]:https://www.masteringemacs.org/article/evaluating-elisp-emacs +[7]:https://en.wikipedia.org/wiki/ELIZA +[8]:https://en.wikipedia.org/wiki/Conway's_Game_of_Life diff --git a/sources/tech/20181231 Troubleshooting hardware problems in Linux.md b/published/20181231 Troubleshooting hardware problems in Linux.md similarity index 57% rename from sources/tech/20181231 Troubleshooting hardware problems in Linux.md rename to published/20181231 Troubleshooting hardware problems in Linux.md index dcc89034db..34dbed5f44 100644 --- a/sources/tech/20181231 Troubleshooting hardware problems in Linux.md +++ b/published/20181231 Troubleshooting hardware problems in Linux.md @@ -1,26 +1,28 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11953-1.html) [#]: subject: (Troubleshooting hardware problems in Linux) [#]: via: (https://opensource.com/article/18/12/troubleshooting-hardware-problems-linux) [#]: author: (Daniel Oh https://opensource.com/users/daniel-oh) -Troubleshooting hardware problems in Linux +Linux 硬件故障排除指南 ====== -Learn what's causing your Linux hardware to malfunction so you can get it back up and running quickly. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_other11x_cc.png?itok=I_kCDYj0) -[Linux servers][1] run mission-critical business applications in many different types of infrastructures including physical machines, virtualization, private cloud, public cloud, and hybrid cloud. It's important for Linux sysadmins to understand how to manage Linux hardware infrastructure—including software-defined functionalities related to [networking][2], storage, Linux containers, and multiple tools on Linux servers. +> 了解是什么原因导致你的 Linux 硬件发生故障,以便你可以将其恢复并快速运行。 -It can take some time to troubleshoot and solve hardware-related issues on Linux. Even highly experienced sysadmins sometimes spend hours working to solve mysterious hardware and software discrepancies. +![](https://img.linux.net.cn/data/attachment/album/202003/03/101312zcazy02wl2g8uhy1.jpg) -The following tips should make it quicker and easier to troubleshoot hardware in Linux. Many different things can cause problems with Linux hardware; before you start trying to diagnose them, it's smart to learn about the most common issues and where you're most likely to find them. +[Linux 服务器][1]在物理机、虚拟化、私有云、公共云和混合云等许多不同种类的基础设施中运行着关键的业务应用程序。对于 Linux 系统管理员来说,了解如何管理 Linux 硬件基础设施(包括与 [网络][2]、存储、Linux 容器相关的软件定义功能)和 Linux 服务器上的多种工具非常重要。 -### Quick-diagnosing devices, modules, and drivers +在 Linux 上进行排除和解决与硬件相关的问题可能需要一些时间。即使是经验丰富的系统管理员,有时也会花费数小时来解决神秘的硬件和软件差异。 -The first step in troubleshooting usually is to display a list of the hardware installed on your Linux server. You can obtain detailed information on the hardware using **ls** commands such as **[lspci][3]** , **[lsblk][4]** , **[lscpu][5]** , and **[lsscsi][6]**. For example, here is output of the **lsblk** command: +以下提示可以使你更快、更轻松地对 Linux 中的硬件进行故障排除。许多不同的事情都可能导致 Linux 硬件出现问题。在开始诊断它们之前,明智的做法是了解最常见的问题以及最有可能找到问题的地方。 + +### 快速诊断设备、模块和驱动程序 + +故障排除的第一步通常是显示 Linux 服务器上安装的硬件的列表。你可以使用诸如 [lspci][3]、[lsblk][4]、[lscpu][5] 和 [lsscsi][6] 之类的列出命令获取有关硬件的详细信息。例如,这是 `lsblk` 命令的输出: ``` # lsblk @@ -32,7 +34,7 @@ xvdb    202:16   0  20G  0 disk └─xvdb1 202:17   0  20G  0 part ``` -If the **ls** commands don't reveal any errors, use init processes (e.g., **systemd** ) to see how the Linux server is working. **systemd** is the most popular init process for bootstrapping user spaces and controlling multiple system processes. For example, here is output of the **systemctl status** command: +如果这些列出命令没有显示任何错误,请使用初始化系统(例如 systemd)查看 Linux 服务器的工作方式。 systemd 是最流行的初始化系统,用于启动用户空间并控制多个系统进程。例如,这是 `systemctl status` 命令的输出: ``` # systemctl status @@ -52,9 +54,9 @@ If the **ls** commands don't reveal any errors, use init processes (e.g., **syst .... ``` -### Digging into multiple loggings +### 深入到各个日志当中 -**Dmesg** allows you to figure out errors and warnings in the kernel's latest messages. For example, here is output of the **dmesg | more** command: +使用 `dmesg` 可以找出内核最新消息中的错误和警告。例如,这是 `dmesg | more` 命令的输出: ``` # dmesg | more @@ -73,7 +75,7 @@ If the **ls** commands don't reveal any errors, use init processes (e.g., **syst .... ``` -You can also look at all Linux system logs in the **/var/log/messages** file, which is where you'll find errors related to specific issues. It's worthwhile to monitor the messages via the **tail** command in real time when you make modifications to your hardware, such as mounting an extra disk or adding an Ethernet network interface. For example, here is output of the **tail -f /var/log/messages** command: +你还可以在 `/var/log/messages` 文件中查看所有 Linux 系统日志,在该文件中你可以找到与特定问题相关的错误。当你对硬件进行修改(例如安装额外的磁盘或添加以太网网卡)时,通过 `tail` 命令实时监视消息是值得的。例如,这是 `tail -f /var/log/messages` 命令的输出: ``` # tail -f /var/log/messages @@ -89,9 +91,9 @@ Dec  1 13:21:33 bastion dnsmasq[30201]: using nameserver 127.0.0.1#53 for domai Dec  1 13:21:33 bastion dnsmasq[30201]: using nameserver 127.0.0.1#53 for domain cluster.local ``` -### Analyzing networking functions +### 分析网络功能 -You may have hundreds of thousands of cloud-native applications to serve business services in a complex networking environment; these may include virtualization, multiple cloud, and hybrid cloud. This means you should analyze whether networking connectivity is working correctly as part of your troubleshooting. Useful commands to figure out networking functions in the Linux server include **ip addr** , **traceroute** , **nslookup** , **dig** , and **ping** , among others. For example, here is output of the **ip addr show** command: +你可能有成千上万的云原生应用程序在一个复杂的网络环境中为业务提供服务,其中可能包括虚拟化、多云和混合云。这意味着,作为故障排除的一部分,你应该分析网络连接是否正常工作。弄清 Linux 服务器中网络功能的有用命令包括:`ip addr`、`traceroute`、`nslookup`、`dig` 和 `ping` 等。例如,这是 `ip addr show` 命令的输出: ``` # ip addr show @@ -116,9 +118,9 @@ You may have hundreds of thousands of cloud-native applications to serve busines .... ``` -### In conclusion +### 总结 -Troubleshooting Linux hardware requires considerable knowledge, including how to use powerful command-line tools and figure out system loggings. You should also know how to diagnose the kernel space, which is where you can find the root cause of many hardware problems. Keep in mind that hardware issues in Linux may come from many different sources, including devices, modules, drivers, BIOS, networking, and even plain old hardware malfunctions. +对 Linux 硬件进行故障排除需要大量的知识,包括如何使用功能强大的命令行工具以及找出系统日志记录。 你还应该知道如何诊断内核空间,在那里你可以找到许多硬件问题的根本原因。请记住,Linux 中的硬件问题可能来自许多不同的来源,包括设备、模块、驱动程序、BIOS、网络,甚至是普通的旧硬件故障。 -------------------------------------------------------------------------------- @@ -126,8 +128,8 @@ via: https://opensource.com/article/18/12/troubleshooting-hardware-problems-linu 作者:[Daniel Oh][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20190113 Editing Subtitles in Linux.md b/published/20190113 Editing Subtitles in Linux.md new file mode 100644 index 0000000000..fe3a66da99 --- /dev/null +++ b/published/20190113 Editing Subtitles in Linux.md @@ -0,0 +1,235 @@ +[#]: collector: (lujun9972) +[#]: translator: (chenmu-kk) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11946-1.html) +[#]: subject: (Editing Subtitles in Linux) +[#]: via: (https://itsfoss.com/editing-subtitles) +[#]: author: (Shirish https://itsfoss.com/author/shirish/) + +如何在 Linux 中编辑字幕 +====== + +我作为一位世界电影和地区电影爱好者已经几十年了。这期间字幕是一个必不可少的工具,它可以使我享受来自不同国家不同语言的优秀电影。 + +如果你喜欢观看带有字幕的电影,你可能会注意到有时字幕并不同步或者说并不正确。 + +你知道你可以自己编写字幕并使得它们更完美吗?让我们向你展示一些 Linux 中的基本字幕编辑吧。 + +![Editing subtitles in Linux][1] + +### 从闭路字幕数据中提取字幕 + +大概在 2012、2013 年我开始了解到有一款叫做 [CCEextractor][2] 的工具。随着时间的推移,它已经成为我必不可少的工具之一,尤其是当我偶然发现一份内含有字幕的媒体文件。 + +CCExtractor 负责解析视频文件以及从闭路字幕closed captions数据中产生独立的字幕文件。 + +CCExtractor 是一个跨平台的、自由开源工具。自它形成的那年起该工具已经成熟了不少而如今已成为 [GSOC][3] 和谷歌编码输入的一部分。 + +简单来说,这个工具基本上是一系列脚本,这些脚本以一种顺序方式一个接着一个地给你提供提取到的字幕。 + +你可以按照[本页][5]的 CCExtractor 安装指南进行操作。 + +若安装后你想从媒体文件中提取字幕,请按以下步骤操作: + +``` +ccextractor +``` + +该命令将会输出以下内容: + +``` +$ ccextractor $something.mkv +CCExtractor 0.87, Carlos Fernandez Sanz, Volker Quetschke. +Teletext portions taken from Petr Kutalek's telxcc +-------------------------------------------------------------------------- +Input: $something.mkv +[Extract: 1] [Stream mode: Autodetect] +[Program : Auto ] [Hauppage mode: No] [Use MythTV code: Auto] +[Timing mode: Auto] [Debug: No] [Buffer input: No] +[Use pic_order_cnt_lsb for H.264: No] [Print CC decoder traces: No] +[Target format: .srt] [Encoding: UTF-8] [Delay: 0] [Trim lines: No] +[Add font color data: Yes] [Add font typesetting: Yes] +[Convert case: No] [Video-edit join: No] +[Extraction start time: not set (from start)] +[Extraction end time: not set (to end)] +[Live stream: No] [Clock frequency: 90000] +[Teletext page: Autodetect] +[Start credits text: None] +[Quantisation-mode: CCExtractor's internal function] +----------------------------------------------------------------- +Opening file: $something.mkv +File seems to be a Matroska/WebM container +Analyzing data in Matroska mode + +Document type: matroska +Timecode scale: 1000000 +Muxing app: libebml v1.3.1 + libmatroska v1.4.2 +Writing app: mkvmerge v8.2.0 ('World of Adventure') 64bit +Title: $something + +Track entry: + Track number: 1 + UID: 1 + Type: video + Codec ID: V_MPEG4/ISO/AVC + Language: mal + Name: $something + +Track entry: + Track number: 2 + UID: 2 + Type: audio + Codec ID: A_MPEG/L3 + Language: mal + Name: $something + +Track entry: + Track number: 3 + UID: somenumber + Type: subtitle + Codec ID: S_TEXT/UTF8 + Name: $something + 99% | 144:34 +100% | 144:34 +Output file: $something_eng.srt +Done, processing time = 6 seconds +Issues? Open a ticket here +https://github.com/CCExtractor/ccextractor/issues +``` +它会大致浏览媒体文件。在这个例子中,它发现该媒体文件是马拉雅拉姆语言(mal)并且格式是 [.mkv][6]。之后它将字幕文件提取出来,命名为源文件名并添加“_eng”后缀。 + +CCExtractor 是一款用来增强字幕功能和字幕编辑的优秀工具,我将在下一部分对它进行介绍。 + +> 趣味阅读:在 [vicaps][7] 有一份有趣的字幕提要,它讲解和分享为何字幕对我们如此重要。对于那些对这类话题感兴趣的人来说,这里面也有许多电影制作的细节。 + +### 用 SubtitleEditor 工具编辑字幕 + +你大概意识到大多数的字幕都是 [.srt 格式][8] 的。这种格式的优点在于你可以将它加载到文本编辑器中并对它进行少量的修改。 + +当进入一个简单的文本编辑器时,一个 srt 文件看起来会是这个样子: + +``` +1 +00:00:00,959 --> 00:00:13,744 +"THE CABINET +OF DR. CALIGARI" + +2 +00:00:40,084 --> 00:01:02,088 +A TALE of the modern re-appearance of an 11th Century Myth +involting the strange and mysterious influence +of a mountebank monk over a somnambulist. +``` + +我分享的节选字幕来自于一部非常老的德国电影《[卡里加里博士的小屋][9]》(1920)。 + +Subtitleeditor 是一款非常棒的字幕编辑软件。字幕编辑器可以用来设置字幕持续时间、与多媒体文件同步的字幕帧率以及字幕间隔时间等等。接下来我将在这分享一些基本的字幕编辑。 + +![][10] + +首先,以安装 ccextractor 工具同样的方式安装 subtitleeditor 工具,使用你自己喜爱的安装方式。在 Debian 中,你可以使用命令: + +``` +sudo apt install subtitleeditor +``` + +当你安装完成后,让我们来看一下在你编辑字幕时一些常见的场景。 + +#### 调整帧率使其媒体文件同步 + +如果你发现字幕与视频不同步,一个原因可能是视频文件的帧率与字幕文件的帧率并不一致。 + +你如何得知这些文件的帧率呢,然后呢?为了获取视频文件的帧率,你可以使用 `mediainfo` 工具。首先你可能需要发行版的包管理器来安装它。 + +使用 `mediainfo` 非常简单: + +``` +$ mediainfo somefile.mkv | grep Frame + Format settings : CABAC / 4 Ref Frames + Format settings, ReFrames : 4 frames + Frame rate mode : Constant + Frame rate : 25.000 FPS + Bits/(Pixel*Frame) : 0.082 + Frame rate : 46.875 FPS (1024 SPF) +``` + +现在你可以看到视频文件的帧率是 25.000 FPS 。我们看到的另一个帧率则是音频文件的帧率。虽然我可以分享为何在视频解码和音频解码等地方会使用特定的 fps,但这将会是一个不同的主题,与它相关的历史信息有很多。 + +下一个问题是解决字幕文件的帧率,这个稍微有点复杂。 + +通常情况下,大多数字幕都是压缩格式的。将.zip 归档文件和字幕文件(以 XXX.srt 结尾)一起解压缩。除此之外,通常还会有一个同名的 .info 文件,该文件可能包含字幕的帧率。 + +如果不是,那么通常最好去某个站点并从具有该帧速率信息的站点下载字幕。对于这个特定的德文文件,我使用 [Opensubtitle.org][11] 来找到它。 + +正如你在链接中所看到的,字幕的帧率是 23.976 FPS 。很明显,它不能与帧率为 25.000 FPS 的视频文件一起很好地播放。 + +在这种情况下,你可以使用字幕编辑工具来改变字幕文件的帧率。 + +按下 `CTRL+A` 选择字幕文件中的全部内容。点击 “Timings -> Change Framerate” ,将 23.976 fps 改为 25.000 fps 或者你想要的其他帧率,保存已更改的文件。 + +![synchronize frame rates of subtitles in Linux][12] + +#### 改变字幕文件的起点 + +有时以上的方法就足够解决问题了,但有时候以上方法并不足够解决问题。 + +在帧率相同时,你可能会发现字幕文件的开头与电影或媒体文件中起点并不相同。 + +在这种情况下,请按以下步骤进行操作: + +按下 `CTRL+A` 键选中字幕文件的全部内容。点击 “Timings -> Select Move Subtitle” 。 + +![Move subtitles using Subtitle Editor on Linux][13] + +设定字幕文件的新起点,保存已更改的文件。 + +![Move subtitles using Subtitle Editor in Linux][14] + +如果你想要时间更精确一点,那么可以使用 [mpv][15] 来查看电影或者媒体文件并点击进度条(可以显示电影或者媒体文件的播放进度),它也会显示微秒。 + +通常我喜欢精准无误的操作,因此我会试着尽可能地仔细调节。相较于人类的反应时间来说,MPV 中的反应时间很精确。如果我想要极其精确的时间,那么我可以使用像 [Audacity][16] 之类的东西,但是那是另一种工具,你可以在上面做更多的事情。那也将会是我未来博客中将要探讨的东西。 + +#### 调整字幕间隔时间 + +有时,两种方法都采用了还不够,甚至你可能需要缩短或增加间隔时间以使其与媒体文件同步。这是较为繁琐的工作之一,因为你必须单独确定每个句子的间隔时间。尤其是在媒体文件中帧率可变的情况下(现已很少见,但你仍然会得到此类文件) + +在这种设想下,你可能因为无法实现自动编辑而不得不手动的修改间隔时间。最好的方式是修改视频文件(会降低视频质量)或者换另一个更高质量的片源,用你喜欢的设置对它进行[转码][17] 。这又是一重大任务,以后我会在我的一些博客文章上阐明。 + +### 总结 + +以上我分享的内容或多或少是对现有字幕文件的改进。如果从头开始,你需要花费大量的时间。我完全没有分享这一点,因为一部电影或一个小时内的任何视频材料都可以轻易地花费 4-6 个小时,甚至更多的时间,这取决于字幕员的技巧、耐心、上下文、行话、口音、是否是以英语为母语的人、翻译等,所有的这些都会对字幕的质量产生影响。 + +我希望自此以后你会觉得这件事很有趣,并将你的字幕处理的更好一点。如果你有其他想要补充的问题,请在下方留言。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/editing-subtitles + +作者:[Shirish][a] +选题:[lujun9972][b] +译者:[chenmu-kk](https://github.com/chenmu-kk) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/shirish/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/editing-subtitles-in-linux.jpeg?resize=800%2C450&ssl=1 +[2]: https://www.ccextractor.org/ +[3]: https://itsfoss.com/best-open-source-internships/ +[4]: https://www.ccextractor.org/public:codein:google_code-in_2018 +[5]: https://github.com/CCExtractor/ccextractor/wiki/Installation +[6]: https://en.wikipedia.org/wiki/Matroska +[7]: https://www.vicaps.com/blog/history-of-silent-movies-and-subtitles/ +[8]: https://en.wikipedia.org/wiki/SubRip#SubRip_text_file_format +[9]: https://www.imdb.com/title/tt0010323/ +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/12/subtitleeditor.jpg?ssl=1 +[11]: https://www.opensubtitles.org/en/search/sublanguageid-eng/idmovie-4105 +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/subtitleeditor-frame-rate-sync.jpg?resize=800%2C450&ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/Move-subtitles-Caligiri.jpg?resize=800%2C450&ssl=1 +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/move-subtitles.jpg?ssl=1 +[15]: https://itsfoss.com/mpv-video-player/ +[16]: https://www.audacityteam.org/ +[17]: https://en.wikipedia.org/wiki/Transcoding +[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/editing-subtitles-in-linux.jpeg?fit=800%2C450&ssl=1 diff --git a/published/20180810 Use Plank On Multiple Monitors Without Creating Multiple Docks With autoplank.md b/published/201911/20180810 Use Plank On Multiple Monitors Without Creating Multiple Docks With autoplank.md similarity index 100% rename from published/20180810 Use Plank On Multiple Monitors Without Creating Multiple Docks With autoplank.md rename to published/201911/20180810 Use Plank On Multiple Monitors Without Creating Multiple Docks With autoplank.md diff --git a/published/20181109 Must-Have Tools for Writers on the Linux Platform.md b/published/201911/20181109 Must-Have Tools for Writers on the Linux Platform.md similarity index 100% rename from published/20181109 Must-Have Tools for Writers on the Linux Platform.md rename to published/201911/20181109 Must-Have Tools for Writers on the Linux Platform.md diff --git a/published/20190328 Can Better Task Stealing Make Linux Faster.md b/published/201911/20190328 Can Better Task Stealing Make Linux Faster.md similarity index 100% rename from published/20190328 Can Better Task Stealing Make Linux Faster.md rename to published/201911/20190328 Can Better Task Stealing Make Linux Faster.md diff --git a/published/20190404 Why blockchain (might be) coming to an IoT implementation near you.md b/published/201911/20190404 Why blockchain (might be) coming to an IoT implementation near you.md similarity index 100% rename from published/20190404 Why blockchain (might be) coming to an IoT implementation near you.md rename to published/201911/20190404 Why blockchain (might be) coming to an IoT implementation near you.md diff --git a/published/20190610 Why containers and Kubernetes have the potential to run almost anything.md b/published/201911/20190610 Why containers and Kubernetes have the potential to run almost anything.md similarity index 100% rename from published/20190610 Why containers and Kubernetes have the potential to run almost anything.md rename to published/201911/20190610 Why containers and Kubernetes have the potential to run almost anything.md diff --git a/published/20190718 What you need to know to be a sysadmin.md b/published/201911/20190718 What you need to know to be a sysadmin.md similarity index 100% rename from published/20190718 What you need to know to be a sysadmin.md rename to published/201911/20190718 What you need to know to be a sysadmin.md diff --git a/published/20190801 Linux permissions 101.md b/published/201911/20190801 Linux permissions 101.md similarity index 100% rename from published/20190801 Linux permissions 101.md rename to published/201911/20190801 Linux permissions 101.md diff --git a/published/20190822 11 Essential Keyboard Shortcuts Google Chrome-Chromium Users Should Know.md b/published/201911/20190822 11 Essential Keyboard Shortcuts Google Chrome-Chromium Users Should Know.md similarity index 100% rename from published/20190822 11 Essential Keyboard Shortcuts Google Chrome-Chromium Users Should Know.md rename to published/201911/20190822 11 Essential Keyboard Shortcuts Google Chrome-Chromium Users Should Know.md diff --git a/published/20190826 How RPM packages are made- the source RPM.md b/published/201911/20190826 How RPM packages are made- the source RPM.md similarity index 100% rename from published/20190826 How RPM packages are made- the source RPM.md rename to published/201911/20190826 How RPM packages are made- the source RPM.md diff --git a/published/20190828 Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word.md b/published/201911/20190828 Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word.md similarity index 100% rename from published/20190828 Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word.md rename to published/201911/20190828 Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word.md diff --git a/published/20190902 How RPM packages are made- the spec file.md b/published/201911/20190902 How RPM packages are made- the spec file.md similarity index 100% rename from published/20190902 How RPM packages are made- the spec file.md rename to published/201911/20190902 How RPM packages are made- the spec file.md diff --git a/published/20190905 Building CI-CD pipelines with Jenkins.md b/published/201911/20190905 Building CI-CD pipelines with Jenkins.md similarity index 100% rename from published/20190905 Building CI-CD pipelines with Jenkins.md rename to published/201911/20190905 Building CI-CD pipelines with Jenkins.md diff --git a/published/20190906 6 Open Source Paint Applications for Linux Users.md b/published/201911/20190906 6 Open Source Paint Applications for Linux Users.md similarity index 100% rename from published/20190906 6 Open Source Paint Applications for Linux Users.md rename to published/201911/20190906 6 Open Source Paint Applications for Linux Users.md diff --git a/published/20190912 How to fix common pitfalls with the Python ORM tool SQLAlchemy.md b/published/201911/20190912 How to fix common pitfalls with the Python ORM tool SQLAlchemy.md similarity index 100% rename from published/20190912 How to fix common pitfalls with the Python ORM tool SQLAlchemy.md rename to published/201911/20190912 How to fix common pitfalls with the Python ORM tool SQLAlchemy.md diff --git a/published/20191007 7 Java tips for new developers.md b/published/201911/20191007 7 Java tips for new developers.md similarity index 100% rename from published/20191007 7 Java tips for new developers.md rename to published/201911/20191007 7 Java tips for new developers.md diff --git a/published/20191008 5 Best Password Managers For Linux Desktop.md b/published/201911/20191008 5 Best Password Managers For Linux Desktop.md similarity index 100% rename from published/20191008 5 Best Password Managers For Linux Desktop.md rename to published/201911/20191008 5 Best Password Managers For Linux Desktop.md diff --git a/published/20191013 How to Enable EPEL Repository on CentOS 8 and RHEL 8 Server.md b/published/201911/20191013 How to Enable EPEL Repository on CentOS 8 and RHEL 8 Server.md similarity index 100% rename from published/20191013 How to Enable EPEL Repository on CentOS 8 and RHEL 8 Server.md rename to published/201911/20191013 How to Enable EPEL Repository on CentOS 8 and RHEL 8 Server.md diff --git a/published/20191018 How to use Protobuf for data interchange.md b/published/201911/20191018 How to use Protobuf for data interchange.md similarity index 100% rename from published/20191018 How to use Protobuf for data interchange.md rename to published/201911/20191018 How to use Protobuf for data interchange.md diff --git a/published/20191021 How to program with Bash- Syntax and tools.md b/published/201911/20191021 How to program with Bash- Syntax and tools.md similarity index 100% rename from published/20191021 How to program with Bash- Syntax and tools.md rename to published/201911/20191021 How to program with Bash- Syntax and tools.md diff --git a/published/20191022 Initializing arrays in Java.md b/published/201911/20191022 Initializing arrays in Java.md similarity index 100% rename from published/20191022 Initializing arrays in Java.md rename to published/201911/20191022 Initializing arrays in Java.md diff --git a/published/20191023 How to dual boot Windows 10 and Debian 10.md b/published/201911/20191023 How to dual boot Windows 10 and Debian 10.md similarity index 100% rename from published/20191023 How to dual boot Windows 10 and Debian 10.md rename to published/201911/20191023 How to dual boot Windows 10 and Debian 10.md diff --git a/published/20191024 Open Source CMS Ghost 3.0 Released with New features for Publishers.md b/published/201911/20191024 Open Source CMS Ghost 3.0 Released with New features for Publishers.md similarity index 100% rename from published/20191024 Open Source CMS Ghost 3.0 Released with New features for Publishers.md rename to published/201911/20191024 Open Source CMS Ghost 3.0 Released with New features for Publishers.md diff --git a/published/20191025 4 cool new projects to try in COPR for October 2019.md b/published/201911/20191025 4 cool new projects to try in COPR for October 2019.md similarity index 100% rename from published/20191025 4 cool new projects to try in COPR for October 2019.md rename to published/201911/20191025 4 cool new projects to try in COPR for October 2019.md diff --git a/published/20191025 How I used the wget Linux command to recover lost images.md b/published/201911/20191025 How I used the wget Linux command to recover lost images.md similarity index 100% rename from published/20191025 How I used the wget Linux command to recover lost images.md rename to published/201911/20191025 How I used the wget Linux command to recover lost images.md diff --git a/published/20191025 Understanding system calls on Linux with strace.md b/published/201911/20191025 Understanding system calls on Linux with strace.md similarity index 100% rename from published/20191025 Understanding system calls on Linux with strace.md rename to published/201911/20191025 Understanding system calls on Linux with strace.md diff --git a/published/20191025 Why I made the switch from Mac to Linux.md b/published/201911/20191025 Why I made the switch from Mac to Linux.md similarity index 100% rename from published/20191025 Why I made the switch from Mac to Linux.md rename to published/201911/20191025 Why I made the switch from Mac to Linux.md diff --git a/published/20191027 How to Install and Configure Nagios Core on CentOS 8 - RHEL 8.md b/published/201911/20191027 How to Install and Configure Nagios Core on CentOS 8 - RHEL 8.md similarity index 100% rename from published/20191027 How to Install and Configure Nagios Core on CentOS 8 - RHEL 8.md rename to published/201911/20191027 How to Install and Configure Nagios Core on CentOS 8 - RHEL 8.md diff --git a/published/20191028 SQLite is really easy to compile.md b/published/201911/20191028 SQLite is really easy to compile.md similarity index 100% rename from published/20191028 SQLite is really easy to compile.md rename to published/201911/20191028 SQLite is really easy to compile.md diff --git a/published/20191029 Collapse OS - An OS Created to Run After the World Ends.md b/published/201911/20191029 Collapse OS - An OS Created to Run After the World Ends.md similarity index 100% rename from published/20191029 Collapse OS - An OS Created to Run After the World Ends.md rename to published/201911/20191029 Collapse OS - An OS Created to Run After the World Ends.md diff --git a/published/20191029 Upgrading Fedora 30 to Fedora 31.md b/published/201911/20191029 Upgrading Fedora 30 to Fedora 31.md similarity index 100% rename from published/20191029 Upgrading Fedora 30 to Fedora 31.md rename to published/201911/20191029 Upgrading Fedora 30 to Fedora 31.md diff --git a/published/20191029 What you probably didn-t know about sudo.md b/published/201911/20191029 What you probably didn-t know about sudo.md similarity index 100% rename from published/20191029 What you probably didn-t know about sudo.md rename to published/201911/20191029 What you probably didn-t know about sudo.md diff --git a/published/20191030 Getting started with awk, a powerful text-parsing tool.md b/published/201911/20191030 Getting started with awk, a powerful text-parsing tool.md similarity index 100% rename from published/20191030 Getting started with awk, a powerful text-parsing tool.md rename to published/201911/20191030 Getting started with awk, a powerful text-parsing tool.md diff --git a/published/20191030 How to Find Out Top Memory Consuming Processes in Linux.md b/published/201911/20191030 How to Find Out Top Memory Consuming Processes in Linux.md similarity index 100% rename from published/20191030 How to Find Out Top Memory Consuming Processes in Linux.md rename to published/201911/20191030 How to Find Out Top Memory Consuming Processes in Linux.md diff --git a/published/20191030 Viewing network bandwidth usage with bmon.md b/published/201911/20191030 Viewing network bandwidth usage with bmon.md similarity index 100% rename from published/20191030 Viewing network bandwidth usage with bmon.md rename to published/201911/20191030 Viewing network bandwidth usage with bmon.md diff --git a/published/20191031 Why you don-t have to be afraid of Kubernetes.md b/published/201911/20191031 Why you don-t have to be afraid of Kubernetes.md similarity index 100% rename from published/20191031 Why you don-t have to be afraid of Kubernetes.md rename to published/201911/20191031 Why you don-t have to be afraid of Kubernetes.md diff --git a/published/20191101 Keyboard Shortcuts to Speed Up Your Work in Linux.md b/published/201911/20191101 Keyboard Shortcuts to Speed Up Your Work in Linux.md similarity index 100% rename from published/20191101 Keyboard Shortcuts to Speed Up Your Work in Linux.md rename to published/201911/20191101 Keyboard Shortcuts to Speed Up Your Work in Linux.md diff --git a/published/20191104 Cloning a MAC address to bypass a captive portal.md b/published/201911/20191104 Cloning a MAC address to bypass a captive portal.md similarity index 100% rename from published/20191104 Cloning a MAC address to bypass a captive portal.md rename to published/201911/20191104 Cloning a MAC address to bypass a captive portal.md diff --git a/published/20191104 Fields, records, and variables in awk.md b/published/201911/20191104 Fields, records, and variables in awk.md similarity index 100% rename from published/20191104 Fields, records, and variables in awk.md rename to published/201911/20191104 Fields, records, and variables in awk.md diff --git a/published/20191104 How To Update a Fedora Linux System -Beginner-s Tutorial.md b/published/201911/20191104 How To Update a Fedora Linux System -Beginner-s Tutorial.md similarity index 100% rename from published/20191104 How To Update a Fedora Linux System -Beginner-s Tutorial.md rename to published/201911/20191104 How To Update a Fedora Linux System -Beginner-s Tutorial.md diff --git a/published/20191106 Bash Script to Generate Patching Compliance Report on CentOS-RHEL Systems.md b/published/201911/20191106 Bash Script to Generate Patching Compliance Report on CentOS-RHEL Systems.md similarity index 100% rename from published/20191106 Bash Script to Generate Patching Compliance Report on CentOS-RHEL Systems.md rename to published/201911/20191106 Bash Script to Generate Patching Compliance Report on CentOS-RHEL Systems.md diff --git a/published/20191106 How to Schedule and Automate tasks in Linux using Cron Jobs.md b/published/201911/20191106 How to Schedule and Automate tasks in Linux using Cron Jobs.md similarity index 100% rename from published/20191106 How to Schedule and Automate tasks in Linux using Cron Jobs.md rename to published/201911/20191106 How to Schedule and Automate tasks in Linux using Cron Jobs.md diff --git a/published/201911/20191107 Demystifying Kubernetes.md b/published/201911/20191107 Demystifying Kubernetes.md new file mode 100644 index 0000000000..f98c0d4387 --- /dev/null +++ b/published/201911/20191107 Demystifying Kubernetes.md @@ -0,0 +1,234 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11628-1.html) +[#]: subject: (Demystifying Kubernetes) +[#]: via: (https://opensourceforu.com/2019/11/demystifying-kubernetes/) +[#]: author: (Abhinav Nath Gupta https://opensourceforu.com/author/abhinav-gupta/) + +揭开 Kubernetes 的神秘面纱 +====== + +![][2] + +> Kubernetes 是一款生产级的开源系统,用于容器化应用程序的自动部署、扩展和管理。本文关于使用 Kubernetes 来管理容器。 + + “容器”已成为最新的流行语之一。但是,这个词到底意味着什么呢?说起“容器”,人们通常会把它和 Docker 联系起来,Docker 是一个被定义为软件的标准化单元容器。该容器将软件和运行软件所需的环境封装到一个易于交付的单元中。 + +容器是一个软件的标准单元,用它来打包代码及其所有依赖项,这样应用程序就可以从一个计算环境到另一个计算环境快速可靠地运行。容器通过创建类似于 ISO 镜像的方式来实现此目的。容器镜像是一个轻量级的、独立的、可执行的软件包,其中包含运行应用程序所需的所有信息,包括代码、运行时、系统工具、系统库和设置。 + +容器镜像在运行时变成容器,对于 Docker 容器,镜像在 Docker 引擎上运行时变成容器。容器将软件与环境隔离开来,确保不同环境下的实例,都可以正常运行。 + +###什么是容器管理? + +容器管理是组织、添加或替换大量软件容器的过程。容器管理使用软件来自动化创建、部署和扩展容器。这一过程就需要容器编排,容器编排是一个自动对基于容器的应用程序进行部署、管理、扩展、联网和提供可用性的工具。 + +### Kubernetes + +Kubernetes 是一个可移植的、可扩展的开源平台,用于管理容器化的工作负载和服务,它有助于配置和自动化。它最初由 Google 开发,拥有一个庞大且快速增长的生态系统。Kubernetes 的服务、技术支持和工具得到广泛应用。 + +Google 在 2014 年开源了 Kubernetes 项目。Kubernetes 建立在 Google 十五年大规模运行生产工作负载的经验基础上,并结合了社区中最好的想法和实践以及声明式句法的使用。 + +下面列出了与Kubernetes生态系统相关的一些常用术语。 + +**Pod**:Pod 是 Kubernetes 应用程序的基本执行单元,是你创建或部署的 Kubernetes 对象模型中的最小和最简单的单元。Pod 代表在 Kubernetes 集群上运行的进程。 + +Pod 将运行中的容器、存储、网络 IP(唯一)和控制容器应如何运行的命令封装起来。它代表 Kubernetes 生态系统内的单个部署单元,代表一个应用程序的单个实例,该程序可能包含一个或多个紧密耦合并共享资源的容器。 + +Kubernetes 集群中的 Pod 有两种主要的使用方式。第一种是运行单个容器。即“一个容器一个 Pod”,这种方式是最常见的。第二种是运行多个需要一起工作的容器。 + +Pod 可能封装一个由紧密关联且需要共享资源的多个同位容器组成的应用程序。 + +副本集ReplicaSet:副本集的目的是维护在任何给定时间运行的一组稳定的副本容器集。 副本集包含有关一个特定 Pod 应该运行多少个副本的信息。为了创建多个 Pod 以匹配副本集条件,Kubernetes 使用 Pod 模板。副本集与其 Pod 的链接是通过后者的 `metas.ownerReferences` 字段实现,该字段指定哪个资源拥有当前对象。 + +服务Services:服务是一种抽象,用来公开一组 Pod 功能。使用 Kubernetes,你无需修改应用程序即可使用陌生服务发现机制。Kubernetes 给 Pod 提供了其自己的 IP 地址和一组 Pod 的单个 DNS 名称,并且可以在它们之间负载平衡。 + +服务解决的一个主要问题是 Web 应用程序前端和后端的集成。由于 Kubernetes 将幕后的 IP 地址提供给 Pod,因此当 Pod 被杀死并复活时,IP 地址会更改。这给给定的后端 IP 地址连接到相应的前端 IP 地址带来一个大问题。服务通过在 Pod 上提供抽象来解决此问题,类似于负载均衡器。 + +Volumes: Kubernetes 卷具有明确的生命周期,与围绕它的 Pod 相同。 因此,卷超过了 Pod 中运行的任何容器的寿命,并且在容器重新启动后保留了数据。当然,当 Pod 不存在时,该卷也将不再存在。也许比这更重要的是 Kubernetes 支持多种类型的卷,并且 Pod 可以同时使用任意数量的卷。 + +卷的核心只是一个目录,其中可能包含一些数据,Pod 中的容器可以访问该目录。该目录是如何产生的,它后端基于什么存储介质,其中的数据内容是什么,这些都由使用的特定卷类型来决定的。 + +### 为什么选择 Kubernetes? + +容器是捆绑和运行应用程序的好方法。在生产环境中,你需要管理运行应用程序的容器,并确保没有停机时间。例如,如果一个容器发生故障,则需要启动另一个容器。如果由系统自动实现这一操作,岂不是更好? Kubernetes 就是来解决这个问题的!Kubernetes 提供了一个框架来弹性运行分布式系统。该框架负责扩展需求、故障转移、部署模式等。例如,Kubernetes 可以轻松管理系统的金丝雀部署。 + +Kubernetes 为用户提供了: + +1. 服务发现和负载平衡 +2. 存储编排 +3. 自动退出和回退 +4. 自动打包 +5. 自我修复 +6. 秘密配置管理 + +### Kubernetes 可以做什么? + +在本文中,我们将会看到一些从头构建 Web 应用程序时如何使用 Kubernetes 的代码示例。我们将在 Python 中使用 Flask 创建一个简单的后端服务器。 + +对于那些想从头开始构建 Web 应用程序的人,有一些前提条件,即: + +1. 对 Docker、Docker 容器和 Docker 镜像的基本了解。可以访问[这里][8]快速了解。 +2. 系统中应该安装 Docker。 +3. 系统中应该安装 Kubernetes,有关如何在本地计算机上安装的说明,请访问[这里][9]。 + +现在,创建一个目录,如下代码片段所示: + +``` +mkdir flask-kubernetes/app && cd flask-kubernetes/app +``` + +接下来,在 `flask-kubernetes/app` 目录中,创建一个名为 `main.py` 的文件,如下面的代码片段所示: + +``` +touch main.py +``` + +在新创建的 `main.py` 文件中,粘贴下面代码: + +``` +from flask import Flask +app = Flask(__name__) + +@app.route("/") +def hello(): + return "Hello from Kubernetes!" + +if __name__ == "__main__": + app.run(host='0.0.0.0') +``` + +使用下面命令在本地安装 Flask: + +``` +pip install Flask==0.10.1 +``` + +Flask 安装后,执行下面的命令: + +``` +python app.py +``` + +应该在本地 5000 端口运行 Flask 服务器,这是 Flask 应用程序的默认端口,并且你可以在 http://localhost:5000 上看到输出 “Hello from Kubernetes!”。服务器在本地运行之后,我们创建一个供 Kubernetes 使用的 Docker 镜像。创建一个名为 `Dockerfile` 的文件,并将以下代码片段粘贴到其中: + +``` +FROM python:3.7 + +RUN mkdir /app +WORKDIR /app +ADD . /app/ +RUN pip install -r requirements.txt + +EXPOSE 5000 +CMD ["python", "/app/main.py"] +``` + +`Dockerfile` 文件的说明如下: + +1. Docker 将从 DockerHub 获取 Python 3.7 镜像。 +2. 将在镜像中创建一个应用程序目录。 +3. 它将一个 `/app` 目录设置为工作目录。 +4. 将内容从主机中的应用程序目录复制到镜像应用程序目录。 +5. 发布端口 5000。 +6. 最后,它运行命令,启动 Flask 服务器。 + +接下来,我们将使用以下命令创建 Docker 镜像: + +``` +docker build -f Dockerfile -t flask-kubernetes:latest . +``` + +创建 Docker 镜像后,我们可以使用以下命令在本地运行该镜像进行测试: + +``` +docker run -p 5001:5000 flask-kubernetes +``` + +通过运行容器在本地完成测试之后,我们需要在 Kubernetes 中部署它。我们将首先使用 `kubectl` 命令验证 Kubernetes 是否正在运行。如果没有报错,则说明它正在工作。如果有报错,请参考[该信息][9]。 + +接下来,我们创建一个部署文件。这是一个 Yaml 文件,其中包含有关 Kubernetes 的说明,该说明涉及如何以声明性的方式创建 Pod 和服务。因为我们有 Flask Web 应用程序,我们将创建一个 `deployment.yaml` 文件,并在其中包含 Pod 和服务声明。 + +创建一个名为 `deployment.yaml` 的文件并向其中添加以下内容,然后保存: + +``` +apiVersion: v1 +kind: Service +metadata: + name: flask-kubernetes -service +spec: + selector: + app: flask-kubernetes + ports: + - protocol: "TCP" + port: 6000 + targetPort: 5000 + type: LoadBalancer + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: flask-kubernetes +spec: + replicas: 4 + template: + metadata: + labels: + app: flask-kubernetes + spec: + containers: + - name: flask-kubernetes + image: flask-kubernetes:latest + imagePullPolicy: Never + ports: + - containerPort: 5000 +``` + +使用以下命令将 yaml 文件发送到 Kubernetes: + +``` +kubectl apply -f deployment.yaml +``` + +如果执行以下命令,你会看到 Pod 正在运行: + +``` +kubectl get pods +``` + +现在,导航至 http://localhost:6000,你应该会看到 “Hello from Kubernetes!”消息。成功了! 该应用程序现在正在 Kubernetes 中运行! + +### Kubernetes 做不了什么? + +Kubernetes 不是一个传统的,包罗万象的 PaaS(平台即服务)系统。 由于 Kubernetes 运行在容器级别而非硬件级别,因此它提供了 PaaS 产品共有的一些普遍适用功能,如部署、扩展、负载平衡、日志记录和监控。Kubernetes 为开发人员平台提供了构建块,但在重要的地方保留了用户的选择和灵活性。 + +* Kubernetes 不限制所支持的应用程序的类型。如果应用程序可以在容器中运行,那么它应该可以在 Kubernetes 上更好地运行。 +* 它不部署和构建源代码。 +* 它不决定日志记录、监视或警报解决方案。 +* 它不提供或不要求配置语言/系统。它提供了一个声明式的 API 供所有人使用。 +* 它不提供或不采用任何全面的机器配置、维护、管理或自我修复系统。 + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/demystifying-kubernetes/ + +作者:[Abhinav Nath Gupta][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensourceforu.com/author/abhinav-gupta/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Gear-kubernetes.jpg?resize=696%2C457&ssl=1 (Gear kubernetes) +[2]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Gear-kubernetes.jpg?fit=800%2C525&ssl=1 +[3]: https://secure.gravatar.com/avatar/f65917facf5f28936663731fedf545c4?s=100&r=g +[4]: https://opensourceforu.com/author/abhinav-gupta/ +[5]: mailto:abhi.aec89@gmail.com +[6]: http://opensourceforu.com/wp-content/uploads/2013/10/assoc.png +[7]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US +[8]: https://www.docker.com/sites/default/files/Docker_CheatSheet_08.09.2016_0.pdf +[9]: https://kubernetes.io/docs/setup/learning-environment/minikube/ diff --git a/published/20191107 How to add a user to your Linux desktop.md b/published/201911/20191107 How to add a user to your Linux desktop.md similarity index 100% rename from published/20191107 How to add a user to your Linux desktop.md rename to published/201911/20191107 How to add a user to your Linux desktop.md diff --git a/published/20191107 Tuning your bash or zsh shell on Fedora Workstation and Silverblue.md b/published/201911/20191107 Tuning your bash or zsh shell on Fedora Workstation and Silverblue.md similarity index 100% rename from published/20191107 Tuning your bash or zsh shell on Fedora Workstation and Silverblue.md rename to published/201911/20191107 Tuning your bash or zsh shell on Fedora Workstation and Silverblue.md diff --git a/published/20191108 7 Best Open Source Tools that will help in AI Technology.md b/published/201911/20191108 7 Best Open Source Tools that will help in AI Technology.md similarity index 100% rename from published/20191108 7 Best Open Source Tools that will help in AI Technology.md rename to published/201911/20191108 7 Best Open Source Tools that will help in AI Technology.md diff --git a/published/20191108 Budget-friendly Linux Smartphone PinePhone Will be Available to Pre-order Next Week.md b/published/201911/20191108 Budget-friendly Linux Smartphone PinePhone Will be Available to Pre-order Next Week.md similarity index 100% rename from published/20191108 Budget-friendly Linux Smartphone PinePhone Will be Available to Pre-order Next Week.md rename to published/201911/20191108 Budget-friendly Linux Smartphone PinePhone Will be Available to Pre-order Next Week.md diff --git a/published/20191108 How to manage music tags using metaflac.md b/published/201911/20191108 How to manage music tags using metaflac.md similarity index 100% rename from published/20191108 How to manage music tags using metaflac.md rename to published/201911/20191108 How to manage music tags using metaflac.md diff --git a/published/20191111 Confirmed- Microsoft Edge Will be Available on Linux.md b/published/201911/20191111 Confirmed- Microsoft Edge Will be Available on Linux.md similarity index 100% rename from published/20191111 Confirmed- Microsoft Edge Will be Available on Linux.md rename to published/201911/20191111 Confirmed- Microsoft Edge Will be Available on Linux.md diff --git a/published/20191112 Getting started with PostgreSQL.md b/published/201911/20191112 Getting started with PostgreSQL.md similarity index 100% rename from published/20191112 Getting started with PostgreSQL.md rename to published/201911/20191112 Getting started with PostgreSQL.md diff --git a/published/20191113 Getting Started With ZFS Filesystem on Ubuntu 19.10.md b/published/201911/20191113 Getting Started With ZFS Filesystem on Ubuntu 19.10.md similarity index 100% rename from published/20191113 Getting Started With ZFS Filesystem on Ubuntu 19.10.md rename to published/201911/20191113 Getting Started With ZFS Filesystem on Ubuntu 19.10.md diff --git a/published/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md b/published/201911/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md similarity index 100% rename from published/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md rename to published/201911/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md diff --git a/published/20191114 Cleaning up with apt-get.md b/published/201911/20191114 Cleaning up with apt-get.md similarity index 100% rename from published/20191114 Cleaning up with apt-get.md rename to published/201911/20191114 Cleaning up with apt-get.md diff --git a/published/20191114 Microsoft Defender ATP is Coming to Linux- What Does it Mean.md b/published/201911/20191114 Microsoft Defender ATP is Coming to Linux- What Does it Mean.md similarity index 100% rename from published/20191114 Microsoft Defender ATP is Coming to Linux- What Does it Mean.md rename to published/201911/20191114 Microsoft Defender ATP is Coming to Linux- What Does it Mean.md diff --git a/published/20191114 Red Hat Responds to Zombieload v2.md b/published/201911/20191114 Red Hat Responds to Zombieload v2.md similarity index 100% rename from published/20191114 Red Hat Responds to Zombieload v2.md rename to published/201911/20191114 Red Hat Responds to Zombieload v2.md diff --git a/published/20191115 Developing a Simple Web Application Using Flutter.md b/published/201911/20191115 Developing a Simple Web Application Using Flutter.md similarity index 100% rename from published/20191115 Developing a Simple Web Application Using Flutter.md rename to published/201911/20191115 Developing a Simple Web Application Using Flutter.md diff --git a/translated/tech/20191117 How to Install VirtualBox 6.0 on CentOS 8 - RHEL 8.md b/published/201911/20191117 How to Install VirtualBox 6.0 on CentOS 8 - RHEL 8.md similarity index 69% rename from translated/tech/20191117 How to Install VirtualBox 6.0 on CentOS 8 - RHEL 8.md rename to published/201911/20191117 How to Install VirtualBox 6.0 on CentOS 8 - RHEL 8.md index e1b325f4d4..be7b3f9d4f 100644 --- a/translated/tech/20191117 How to Install VirtualBox 6.0 on CentOS 8 - RHEL 8.md +++ b/published/201911/20191117 How to Install VirtualBox 6.0 on CentOS 8 - RHEL 8.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11627-1.html) [#]: subject: (How to Install VirtualBox 6.0 on CentOS 8 / RHEL 8) [#]: via: (https://www.linuxtechi.com/install-virtualbox-6-centos-8-rhel-8/) [#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) @@ -10,27 +10,29 @@ 如何在 CentOS 8 / RHEL 8 上安装 VirtualBox 6.0 ====== -**VirtualBox** 是一款免费的开源**虚拟化工具**,它允许技术人员同时运行多个不同风格的虚拟机。它通常用于运行桌面(Linux 和 Windows),当人们尝试探索新的 Linux 发行版的功能或希望在 VM 中安装 **OpenStack**、**Ansible** 和 **Puppet** 等软件时,它会非常方便,在这种情况下,我们可以使用 VirtualBox 启动 VM。 +![](https://img.linux.net.cn/data/attachment/album/201911/30/095031gbnm59ux0dw979wb.jpg) -VirtualBox 被分类为**2 类虚拟机管理程序**,这意味着它需要一个现有的操作系统,在上面安装 VirtualBox 软件。VirtualBox 提供功能来创建本机网络或 NAT 网络。在本文中,我们将演示如何在 CentOS 8 和 RHEL 8 系统上安装最新版本的 VirtualBox 6.0,并演示如何安装 VirtualBox 扩展。 +VirtualBox 是一款自由开源的虚拟化工具,它允许技术人员同时运行多个不同风格的虚拟机(VM)。它通常用于运行桌面(Linux 和 Windows),当人们尝试探索新的 Linux 发行版的功能或希望在 VM 中安装 OpenStack、Ansible 和 Puppet 等软件时,它会非常方便,在这种情况下,我们可以使用 VirtualBox 启动 VM。 + +VirtualBox 被分类为 2 类虚拟机管理程序,这意味着它需要一个现有的操作系统,在上面安装 VirtualBox 软件。VirtualBox 提供功能来创建本机网络或 NAT 网络。在本文中,我们将演示如何在 CentOS 8 和 RHEL 8 系统上安装最新版本的 VirtualBox 6.0,并演示如何安装 VirtualBox 扩展。 ### 在 CentOS 8 / RHEL 8 上安装 VirtualBox 6.0 的安装步骤 #### 步骤 1: 启用 VirtualBox 和 EPEL 仓库 -登录到你的 CentOS 8 或 RHEL 8 系统并打开终端,执行以下命令并启用 VirtualBox 和 EPEL 包仓库。 +登录到你的 CentOS 8 或 RHEL 8 系统并打开终端,执行以下命令并启用 VirtualBox 和 EPEL 包仓库: ``` [root@linuxtechi ~]# dnf config-manager --add-repo=https://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo ``` -使用以下 rpm 命令导入 Oracle VirtualBox 公钥 +使用以下 `rpm` 命令导入 Oracle VirtualBox 公钥: ``` [root@linuxtechi ~]# rpm --import https://www.virtualbox.org/download/oracle_vbox.asc ``` -使用以下 dnf 命令启用 EPEL 仓库, +使用以下 `dnf` 命令启用 EPEL 仓库: ``` [root@linuxtechi ~]# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y @@ -38,17 +40,17 @@ VirtualBox 被分类为**2 类虚拟机管理程序**,这意味着它需要一 #### 步骤 2: 安装 VirtualBox 构建工具和依赖项 -运行以下命令来安装所有 VirtualBox 构建工具和依赖项, +运行以下命令来安装所有 VirtualBox 构建工具和依赖项: ``` [root@linuxtechi ~]# dnf install binutils kernel-devel kernel-headers libgomp make patch gcc glibc-headers glibc-devel dkms -y ``` -成功安装上面的依赖项和构建工具后,使用 dnf 命令继续安装 VirtualBox, +成功安装上面的依赖项和构建工具后,使用 `dnf` 命令继续安装 VirtualBox。 #### 步骤 3: 在 CentOS 8 / RHEL 8 上安装 VirtualBox 6.0 -如果希望在安装之前列出 VirtualBox 的可用版本,请执行以下 [dnf 命令][1], +如果希望在安装之前列出 VirtualBox 的可用版本,请执行以下 dnf 命令: ``` [root@linuxtechi ~]# dnf search virtualbox @@ -59,13 +61,13 @@ VirtualBox-6.0.x86_64 : Oracle VM VirtualBox [root@linuxtechi ~]# ``` -让我们使用以下 dnf 命令安装最新版本的 VirtualBox 6.0, +让我们使用以下 `dnf` 命令安装最新版本的 VirtualBox 6.0: ``` [root@linuxtechi ~]# dnf install VirtualBox-6.0 -y ``` -如果有本地用户希望将 usb 设备连接到 VirtualBox VM,那么他/她应该是 “**vboxusers**” 组的一员,请使用下面的 usermod 命令将本地用户添加到 “vboxusers” 组。 +如果有本地用户希望将 usb 设备连接到 VirtualBox VM,那么他/她应该是 `vboxusers` 组的一员,请使用下面的 `usermod` 命令将本地用户添加到 `vboxusers` 组。 ``` @@ -74,7 +76,7 @@ VirtualBox-6.0.x86_64 : Oracle VM VirtualBox #### 步骤 4: 访问 CentOS 8 / RHEL 8 上的 VirtualBox -有两种方法可以访问 VirtualBox,在命令行输入 “**virtualbox**” 然后回车: +有两种方法可以访问 VirtualBox,在命令行输入 `virtualbox` 然后回车: ``` [root@linuxtechi ~]# virtualbox @@ -82,11 +84,11 @@ VirtualBox-6.0.x86_64 : Oracle VM VirtualBox 在桌面环境中,在搜索框中搜索 “VirtualBox”。 -[![Access-VirtualBox-CentOS8][2]][3] +![Access-VirtualBox-CentOS8][3] -单击 VirtualBox 图标, +单击 VirtualBox 图标: -[![VirtualBox-CentOS8][2]][4] +![VirtualBox-CentOS8][4] 这确认 VirtualBox 6.0 已成功安装,让我们安装它的扩展包。 @@ -100,37 +102,28 @@ VirtualBox-6.0.x86_64 : Oracle VM VirtualBox * Intel PXE 启动 * 主机网络摄像头 - - -使用下面的 wget 命令下载 Virtualbox 扩展包到下载文件夹中, +使用下面的 `wget` 命令下载 Virtualbox 扩展包到下载文件夹中: ``` [root@linuxtechi ~]$ cd Downloads/ [root@linuxtechi Downloads]$ wget https://download.virtualbox.org/virtualbox/6.0.14/Oracle_VM_VirtualBox_Extension_Pack-6.0.14.vbox-extpack ``` -下载后,打开 VirtualBox 并依次点击 **File** –>**Preferences** –> **Extension**,然后点击 “+” 号图标添加下载的扩展包, +下载后,打开 VirtualBox 并依次点击 “File -> Preferences -> Extension”,然后点击 “+” 号图标添加下载的扩展包: -[![Install-VirtualBox-Extension-Pack-CentOS8][2]][5] +![Install-VirtualBox-Extension-Pack-CentOS8][5] -单击 “Install” 开始安装扩展包。 +单击 “Install” 开始安装扩展包: -[![Accept-VirtualBox-Extension-Pack-License-CentOS8][2]][6] +![Accept-VirtualBox-Extension-Pack-License-CentOS8][6] -单击 "I Agree" 接受 VirtualBox 扩展包许可证。 +单击 “I Agree” 接受 VirtualBox 扩展包许可证。 -成功安装 VirtualBox 扩展包后,我们将看到下面的页面,单击 OK 并开始使用 VirtualBox。 - -[![VirtualBox-Extension-Pack-Install-Message-CentOS8][2]][7] - -本文就是这些了,我希望这些步骤可以帮助你在 CentOS 8 和 RHEL 8 系统上安装 VirtualBox 6.0。请分享你的宝贵反馈和意见。 - - * [Facebook][9] - * [Twitter][10] - * [LinkedIn][11] - * [Reddit][12] +成功安装 VirtualBox 扩展包后,我们将看到下面的页面,单击 “OK” 并开始使用 VirtualBox。 +![VirtualBox-Extension-Pack-Install-Message-CentOS8][7] +本文就是这些了,我希望这些步骤可以帮助你在 CentOS 8 和 RHEL 8 系统上安装 VirtualBox 6.0。请分享你的宝贵的反馈和意见。 -------------------------------------------------------------------------------- @@ -139,7 +132,7 @@ via: https://www.linuxtechi.com/install-virtualbox-6-centos-8-rhel-8/ 作者:[Pradeep Kumar][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20191118 How containers work- overlayfs.md b/published/201911/20191118 How containers work- overlayfs.md similarity index 100% rename from published/20191118 How containers work- overlayfs.md rename to published/201911/20191118 How containers work- overlayfs.md diff --git a/published/20191119 How to use pkgsrc on Linux.md b/published/201911/20191119 How to use pkgsrc on Linux.md similarity index 100% rename from published/20191119 How to use pkgsrc on Linux.md rename to published/201911/20191119 How to use pkgsrc on Linux.md diff --git a/published/20191120 How to Use TimeShift to Backup and Restore Ubuntu Linux.md b/published/201911/20191120 How to Use TimeShift to Backup and Restore Ubuntu Linux.md similarity index 100% rename from published/20191120 How to Use TimeShift to Backup and Restore Ubuntu Linux.md rename to published/201911/20191120 How to Use TimeShift to Backup and Restore Ubuntu Linux.md diff --git a/published/20191120 How to install Java on Linux.md b/published/201911/20191120 How to install Java on Linux.md similarity index 100% rename from published/20191120 How to install Java on Linux.md rename to published/201911/20191120 How to install Java on Linux.md diff --git a/translated/tech/20191121 How to document Python code with Sphinx.md b/published/201911/20191121 How to document Python code with Sphinx.md similarity index 56% rename from translated/tech/20191121 How to document Python code with Sphinx.md rename to published/201911/20191121 How to document Python code with Sphinx.md index 8c7cc395ad..3b14624f5d 100644 --- a/translated/tech/20191121 How to document Python code with Sphinx.md +++ b/published/201911/20191121 How to document Python code with Sphinx.md @@ -1,25 +1,25 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11624-1.html) [#]: subject: (How to document Python code with Sphinx) [#]: via: (https://opensource.com/article/19/11/document-python-sphinx) [#]: author: (Moshe Zadka https://opensource.com/users/moshez) 如何使用 Sphinx 给 Python 代码写文档 ====== -最好将文档作为开发过程的一部分。Sphinx 加上 Tox,让文档可以轻松书写,并且外观漂亮。 + +> 最好将文档作为开发过程的一部分。Sphinx 加上 Tox,让文档可以轻松书写,并且外观漂亮。 + ![Python in a coffee cup.][1] -Python 代码可以在源码中包含文档。这种方式默认依靠 **docstring**,它以三引号格式定义。虽然文档的价值是很大的,但是代码没有充足的文档还是很常见。让我们演练一个场景,了解出色的文档的强大功能。 - -经历了太多白板技术面试,要求你实现斐波那契数列,你已经受够了。你回家用 Python 写了一个可重用的斐波那契计算器,使用浮点技巧来实现 O(1) 复杂度。 +Python 代码可以在源码中包含文档。这种方式默认依靠 **docstring**,它以三引号格式定义。虽然文档的价值是很大的,但是没有充足的文档的代码还是很常见。让我们演练一个场景,了解出色的文档的强大功能。 +经历了太多在白板技术面试上要求你实现斐波那契数列,你已经受够了。你回家用 Python 写了一个可重用的斐波那契计算器,使用浮点技巧来实现 `O(1)` 复杂度。 代码很简单: - ``` # fib.py import math @@ -33,8 +33,7 @@ def approx_fib(n): (该斐波那契数列是四舍五入到最接近的整数的几何序列,这是我最喜欢的鲜为人知的数学事实之一。) -作为一个好人,你可以将代码开源,并将它放在 [PyPI][2] 上。setup.py 文件很简单: - +作为一个好人,你可以将代码开源,并将它放在 [PyPI][2] 上。`setup.py` 文件很简单: ``` import setuptools @@ -47,7 +46,7 @@ setuptools.setup( ) ``` -但是,没有文档的代码是没有用的。因此,你可以向函数添加 docstring。我最喜欢的 docstring 样式之一是 [“Google” 样式][3]。标记很轻量,这在它位于源代码中时很好。 +但是,没有文档的代码是没有用的。因此,你可以向函数添加 docstring。我最喜欢的 docstring 样式之一是 [“Google” 样式][3]。标记很轻量,当它放在源代码中时很好。 ``` @@ -64,10 +63,9 @@ def approx_fib(n): # ... ``` -但是函数的文档只是成功的一半。普通文档对于情境化代码用法很重要。在这种情况下,上下文是恼人的技术面试。 - -有一种添加更多文档的方式,Pythonic 模式通常是在 **docs/** 添加 **rst** 文件 ( [reStructuredText][4] 的缩写)。因此**docs/index.rst** 文件最终看起来像这样: +但是函数的文档只是成功的一半。普通文档对于情境化代码用法很重要。在这种情况下,情景是恼人的技术面试。 +有一种添加更多文档的方式,专业 Python 人的方式通常是在 `docs/` 添加 rst 文件( [reStructuredText][4] 的缩写)。因此 `docs/index.rst` 文件最终看起来像这样: ``` Fibonacci @@ -86,21 +84,17 @@ fib off. :members: ``` -我们完成了,对吧?我们已经将文本放在了文件中。人们应该看看。 +我们完成了,对吧?我们已经将文本放在了文件中。人们应该会看的。 ### 使 Python 文档更漂亮 为了使你的文档看起来更漂亮,你可以利用 [Sphinx][5],它旨在制作漂亮的 Python 文档。这三个 Sphinx 扩展特别有用: -* **sphinx.ext.autodoc**:从模块内部获取文档 - * **sphinx.ext.napoleon**:支持 Google 样式的 docstring - * **sphinx.ext.viewcode**:将 ReStructured Text 源码与生成的文档打包在一起 - - - - -为了告诉 Sphinx 该生成什么以及如何生成,我们在 **docs/conf.py** 中配置一个辅助文件: +* `sphinx.ext.autodoc`:从模块内部获取文档 +* `sphinx.ext.napoleon`:支持 Google 样式的 docstring +* `sphinx.ext.viewcode`:将 ReStructured Text 源码与生成的文档打包在一起 +为了告诉 Sphinx 该生成什么以及如何生成,我们在 `docs/conf.py` 中配置一个辅助文件: ``` extensions = [ @@ -108,12 +102,12 @@ extensions = [ 'sphinx.ext.napoleon', 'sphinx.ext.viewcode', ] -# The name of the entry point, without the ".rst" extension. -# By convention this will be "index" +# 该入口点的名称,没有 .rst 扩展名。 +# 惯例该名称是 index master_doc = "index" -# This values are all used in the generated documentation. -# Usually, the release and version are the same, -# but sometimes we want to have the release have an "rc" tag. +# 这些值全部用在生成的文档当中。 +# 通常,发布(release)与版本(version)是一样的, +# 但是有时候我们会有带有 rc 标签的发布。 project = "Fib" copyright = "2019, Moshe Zadka" author = "Moshe Zadka" @@ -122,43 +116,43 @@ version = release = "2019.1.0" 此文件使我们可以使用所需的所有元数据来发布代码,并注意扩展名(上面的注释说明了方式)。最后,要确保生成我们想要的文档,请使用 [Tox][6] 管理虚拟环境以确保我们顺利生成文档: - ``` [tox] -# By default, .tox is the directory. -# Putting it in a non-dot file allows opening the generated -# documentation from file managers or browser open dialogs -# that will sometimes hide dot files. +# 默认情况下,`.tox` 是该目录。 +# 将其放在非点文件中可以从 +# 文件管理器或浏览器的 +# 打开对话框中打开生成的文档, +# 这些对话框有时会隐藏点文件。 toxworkdir = {toxinidir}/build/tox [testenv:docs] -# Running sphinx from inside the "docs" directory -# ensures it will not pick up any stray files that might -# get into a virtual environment under the top-level directory -# or other artifacts under build/ +# 从 `docs` 目录内运行 `sphinx`, +# 以确保它不会拾取任何可能进入顶层目录下的 +# 虚拟环境或 `build/` 目录下的其他工件的杂散文件。 changedir = docs -# The only dependency is sphinx -# If we were using extensions packaged separately, -# we would specify them here. -# A better practice is to specify a specific version of sphinx. +# 唯一的依赖关系是 `sphinx`。 +# 如果我们使用的是单独打包的扩展程序, +# 我们将在此处指定它们。 +# 更好的做法是指定特定版本的 sphinx。 deps = sphinx -# This is the sphinx command to generate HTML. -# In other circumstances, we might want to generate a PDF or an ebook +# 这是用于生成 HTML 的 `sphinx` 命令。 +# 在其他情况下,我们可能想生成 PDF 或电子书。 commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html -# We use Python 3.7. Tox sometimes tries to autodetect it based on the name of -# the testenv, but "docs" does not give useful clues so we have to be explicit. +# 我们使用 Python 3.7。 +# Tox 有时会根据 testenv 的名称尝试自动检测它, +# 但是 `docs` 没有给出有用的线索,因此我们必须明确它。 basepython = python3.7 ``` -现在,无论何时运行T ox,它都会为你的 Python 代码生成漂亮的文档。 +现在,无论何时运行 Tox,它都会为你的 Python 代码生成漂亮的文档。 ### 在 Python 中写文档很好 -作为 Python 开发人员,我们可以使用的工具链很棒。 我们可以从 **docstring** 开始,添加 **.rst** 文件,然后添加 Sphinx 和 Tox 来为用户美化结果。 +作为 Python 开发人员,我们可以使用的工具链很棒。我们可以从 **docstring** 开始,添加 .rst 文件,然后添加 Sphinx 和 Tox 来为用户美化结果。 -你对好的文档有何评价? 你还有其他喜欢的方式么? 请在评论中分享它们! +你对好的文档有何评价?你还有其他喜欢的方式么?请在评论中分享它们! -------------------------------------------------------------------------------- @@ -167,7 +161,7 @@ via: https://opensource.com/article/19/11/document-python-sphinx 作者:[Moshe Zadka][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -178,4 +172,4 @@ via: https://opensource.com/article/19/11/document-python-sphinx [3]: http://google.github.io/styleguide/pyguide.html#381-docstrings [4]: http://docutils.sourceforge.net/rst.html [5]: http://www.sphinx-doc.org/en/master/ -[6]: https://tox.readthedocs.io/en/latest/ \ No newline at end of file +[6]: https://tox.readthedocs.io/en/latest/ diff --git a/published/20191122 Zorin OS 15 Lite Release- Good Looking Lightweight Linux.md b/published/201911/20191122 Zorin OS 15 Lite Release- Good Looking Lightweight Linux.md similarity index 100% rename from published/20191122 Zorin OS 15 Lite Release- Good Looking Lightweight Linux.md rename to published/201911/20191122 Zorin OS 15 Lite Release- Good Looking Lightweight Linux.md diff --git a/published/20191124 Bauh - Manage Snaps, Flatpaks and AppImages from One Interface.md b/published/201911/20191124 Bauh - Manage Snaps, Flatpaks and AppImages from One Interface.md similarity index 100% rename from published/20191124 Bauh - Manage Snaps, Flatpaks and AppImages from One Interface.md rename to published/201911/20191124 Bauh - Manage Snaps, Flatpaks and AppImages from One Interface.md diff --git a/published/20191126 Google to Add Mainline Linux Kernel Support to Android.md b/published/201911/20191126 Google to Add Mainline Linux Kernel Support to Android.md similarity index 100% rename from published/20191126 Google to Add Mainline Linux Kernel Support to Android.md rename to published/201911/20191126 Google to Add Mainline Linux Kernel Support to Android.md diff --git a/published/201911/20191127 Displaying dates and times your way.md b/published/201911/20191127 Displaying dates and times your way.md new file mode 100644 index 0000000000..4366136a80 --- /dev/null +++ b/published/201911/20191127 Displaying dates and times your way.md @@ -0,0 +1,168 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11623-1.html) +[#]: subject: (Displaying dates and times your way) +[#]: via: (https://www.networkworld.com/article/3481602/displaying-dates-and-times-your-way-with-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +在终端里按你的方式显示日期和时间 +====== + +> Linux 的 date 命令提供了很多显示日期和时间的选项,要比你想的还要多。这是一些有用的选择。 + +![](https://img.linux.net.cn/data/attachment/album/201911/29/144555a8mq82mcc9cfttt9.jpg) + +在 Linux 系统上,`date` 命令非常简单。你键入 `date`,日期和时间将以一种有用的方式显示。它包括星期几、日期、时间和时区: + +``` +$ date +Tue 26 Nov 2019 11:45:11 AM EST +``` + +只要你的系统配置正确,你就会看到日期和当前时间以及时区。 + +但是,该命令还提供了许多选项来以不同方式显示日期和时间信息。例如,如果要显示日期以便进行排序,则可能需要使用如下命令: + +``` +$ date "+%Y-%m-%d" +2019-11-26 +``` + +在这种情况下,年、月和日按该顺序排列。请注意,我们使用大写字母 `Y` 来获得四位数的年份。如果我们使用小写的 `y`,则只会看到两位数字的年份(例如 19)。不要让这种做法使你错误地联想到如果 `%m` 给你一个数字月份,`%M` 可能会给你月份的名称。不,`%M` 将给你分钟数。要以缩写名称格式获得月份,你要使用 `%b`,而对于完全拼写的月份,则要使用 `%B`。 + +``` +$ date "+%b %B" +Nov November +``` + +或者,你可能希望以这种常用格式显示日期: + +``` +$ date "+%D" +11/26/19 +``` + +如果你需要四位数的年份,则可以执行以下操作: + +``` +$ date "+%x" +11/26/2019 +``` + +下面是一个可能有用的示例。假设你需要创建一个每日报告并在文件名中包含日期,则可以使用以下命令来创建文件(可能用在脚本中): + +``` +$ touch Report-`date "+%Y-%m-%d"` +``` + +当你列出你的报告时,它们将按日期顺序或反向日期顺序(如果你添加 `-r`)列出。 + +``` +$ ls -r Report* +Report-2019-11-26 +Report-2019-11-25 +Report-2019-11-22 +Report-2019-11-21 +Report-2019-11-20 +``` + +你还可以在日期字符串中添加其他详细信息。可用的各种选项多得令人惊讶。你可以使用 `date "+%q"` 来显示你所在的一年中的哪个季度,或使用类似以下命令来显示两个月前的日期: + +``` +$ date --date="2 months ago" +Thu 26 Sep 2019 09:02:43 AM EDT +``` + +是否想知道下周四的日期?你可以使用类似 `date --date="next thu"` 的命令,但是要理解,对于Linux,下个周四意味着今天之后的周四。如果今天是星期三,那就是明天,而不是下周的星期四。但是,你可以像下面的第二个命令一样指定下周的星期四。 + +``` +$ date --date="next thu" +Thu 28 Nov 2019 12:00:00 AM EST +$ date --date="next week thu" +Thu 05 Dec 2019 12:00:00 AM EST +``` + +`date` 命令的手册页列出了其所有选项。该列表多得令人难以置信,但是你可能会发现一些日期/时间显示选项非常适合你。以下是一些你可能会发现有趣的东西。 + +世界标准时间(UTC): + +``` +$ date -u +Tue 26 Nov 2019 01:13:59 PM UTC +``` + +自 1970 年 1 月 1 日以来的秒数(与 Linux 系统上日期的存储方式有关): + +``` +$ date +%s +1574774137 +``` + +以下是 `date` 命令选项的完整列表。正如我所说,它比我们大多数人想象的要广泛得多。 + +- `%%` 显示字母 % +- `%a` 本地语言环境的缩写星期名称(例如,日 / Sun) +- `%A` 本地语言环境的完整星期名称(例如,星期日 / Sunday) +- `%b` 本地语言环境的缩写月份名称(例如 一 / Jan) +- `%B` 本地语言环境的完整月份名称(例如,一月 / January) +- `%c` 本地语言环境的日期和时间(例如 2005年3月3日 星期四 23:05:25 / Thu Mar 3 23:05:25 2005) +- `%C` 世纪;类似于 `%Y`,但省略了后两位数字(例如,20) +- `%d` 月份的天(例如,01) +- `%D` 日期;与 `%m/%d/%y` 相同 +- `%e` 月份的天,填充前缀空格;与 `%_d` 相同 +- `%F` 完整日期;与 `%Y-%m-%d` 相同 +- `%g` ISO 周号的年份的后两位数字(请参见 `%G`) +- `%G` ISO 周号的年份(请参阅 `%V`);通常仅配合 `%V` 使用 +- `%h` 与 `%b` 相同 +- `%H` 24 小时制的小时(00..23) +- `%I` 12 小时制的小时(01..12) +- `%j` 一年的天(001..366) +- `%k` 24 小时制的小时,填充前缀空格( 0..23);与 `%_H` 相同 +- `%l` 12 小时制的小时,填充前缀空格( 1..12);与 `%_I` 相同 +- `%m` 月份(01..12) +- `%M` 分钟(00..59) +- `%n` 换行符 +- `%N` 纳秒(000000000..999999999) +- `%p` 本地语言环境中等同于 AM 或 PM 的字符串;如果未知,则为空白 +- `%P` 像 `%p`,但使用小写 +- `%q` 季度(1..4) +- `%r` 本地语言环境的 12 小时制时间(例如,晚上 11:11:04 / 11:11:04 PM) +- `%R` 24 小时制的小时和分钟;与 `%H:%M` 相同 +- `%s` 自 1970-01-01 00:00:00 UTC 以来的秒数 +- `%S` 秒(00..60) +- `%t` 制表符 +- `%T` 时间;与 `%H:%M:%S` 相同 +- `%u` 星期(1..7);1 是星期一 +- `%U` 年的周号,以星期日为一周的第一天,从 00 开始(00..53) +- `%V` ISO 周号,以星期一为一周的第一天,从 01 开始(01..53) +- `%w` 星期(0..6);0 是星期日 +- `%W` 年的周号,星期一为一周的第一天,从 00 开始(00..53) +- `%x` 本地语言环境的日期表示形式(例如,1999年12月31日 / 12/31/99) +- `%X` 本地语言环境的时间表示形式(例如,23:13:48) +- `%y` 年的最后两位数字(00..99) +- `%Y` 年份 +- `%z` +hhmm 格式的数字时区(例如,-0400) +- `%:z` +hh:mm 格式的数字时区(例如,-04:00) +- `%::z` +hh:mm:ss 格式的数字时区(例如,-04:00:00) +- `%:::z` 数字时区,`:` 指明精度(例如,-04, +05:30) +- `%Z` 字母时区缩写(例如,EDT) + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3481602/displaying-dates-and-times-your-way-with-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/201912/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md b/published/201912/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md new file mode 100644 index 0000000000..fd24ef3c36 --- /dev/null +++ b/published/201912/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md @@ -0,0 +1,240 @@ +自动共享和上传文件到兼容的托管站点 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2017/10/Upload-720x340.png) + +前阵子我们写了一个关于 [Transfer.sh][1]的指南,它允许你使用命令行通过互联网来分享文件。今天,我们来看看另一种文件分享实用工具 Anypaste。这是一个基于文件类型自动共享和上传文件到兼容托管站点的简单脚本。你不需要去手动登录到托管站点来上传或分享你的文件。Anypaste 将会根据你想上传的文件的类型来**自动挑选合适的托管站点**。简单地说,照片将被上传到图像托管站点,视频被传到视频站点,代码被传到 pastebin。难道不是很酷的吗?Anypaste 是一个完全开源、免费、轻量的脚本,你可以通过命令行完成所有操作。因此,你不需要依靠那些臃肿的、需要消耗大量内存的 GUI 应用来上传和共享文件。 + +### 安装 + +正如我所说,这仅仅是一个脚本。所以不存在任何复杂的安装步骤。只需要将脚本下载后放置在你想要运行的位置(例如 `/usr/bin/`),并将其设置为可执行文件后就可以直接使用了。此外,你也可以通过下面的这两条命令来快速安装 Anypaste。 + +``` +sudo curl -o /usr/bin/anypaste https://anypaste.xyz/sh +sudo chmod +x /usr/bin/anypaste +``` + +就是这样简单。如果需要更新老的 Anypaste 版本,只需要用新的可执行文件覆写旧的即可。 + +现在,让我们看看一些实例。 + +### 配置 + +Anypaste 开箱即用,并不需要特别的配置。默认的配置文件是 `~/.config/anypaste.conf`,这个文件在你第一次运行 Anypaste 时会自动创建。 + +需要配置的选项只有 `ap_plugins`。Anypaste 使用插件系统上传文件。每个站点(的上传)都由一个特定的插件表示。你可以在 `anypaste.conf` 文件中的 `ap-plugins directive` 位置浏览可用的插件列表。 + +``` +# List of plugins +# If there are multiple compatible plugins, precedence is determined +# by which one is listed first in this array +ap_plugins=( +# Videos/Gifs +'sendvid' 'streamable' 'gfycat' +# Images +'tinyimg' 'vgyme' +# Audio +'instaudio' +# Text +'hastebin' 'ixio' 'sprunge' +# Documents +'docdroid' +# Any file +'jirafeau' 'fileio' +) +[...] +``` + +如果你要安装一个新的插件,将它添加进这个列表中就可以了。如果你想禁用一个默认插件,只需要将它从列表中移除即可。如果有多个兼容的插件,排列中的第一个会被选择,因此**顺序很重要**。 + +### 用法 + +上传一个简单的文件,例如 `test.png`,可以运行以下命令: + +``` +anypaste test.png +``` + +输出示例: + +``` +Current file: test.png +Attempting to upload with plugin 'tinyimg' +######################################################################## 100.0% + +Direct Link: https://tinyimg.io/i/Sa1zsjj.png + +Upload complete. +All files processed. Have a nice day! +``` + +正如输出结果中所看到的,Anypaste 通过自动匹配图像文件 `test.png` 发现了兼容的托管站点(https://tinyimg.io),并将文件上传到了该站点。此外,Anypaste 也为我们提供了用于直接浏览/下载该文件的链接。 + +不仅是 png 格式文件,你还可以上传任何其他图片格式的文件。例如,下面的命令将会上传 gif 格式文件: + +``` +$ anypaste file.gif +Current file: file.gif +Plugin 'streamable' is compatible, but missing config parameters: 'streamable_email' 'streamable_password' +You can set them in /home/sk/.config/anypaste.conf +Attempting to upload with plugin 'gfycat' +######################################################################## 100.0% +Reminder: Gfycat needs time to encode. Your video will not appear right away. + +Link: https://gfycat.com/MisguidedQuaintBergerpicard +Direct(ish) Link: https://thumbs.gfycat.com/MisguidedQuaintBergerpicard-size_restricted.gif + +Upload complete. +All files processed. Have a nice day! +``` + +你可以将链接分享给你的家庭、朋友和同事们。下图是我刚刚将图片上传到 gfycat 网站的截图。 + +![][3] + +也可以一次同时上传多个(相同格式或不同格式)文件。 + +下面的例子提供参考,这里我会上传两个不同的文件,包含一个图片文件和一个视频文件: + +``` +anypaste image.png video.mp4 +``` + +输出示例: + +``` +Current file: image.png +Attempting to upload with plugin 'tinyimg' +######################################################################## 100.0% + +Direct Link: https://tinyimg.io/i/au1PHpg.png + +Upload complete. +Current file: video.mp4 +Plugin 'streamable' is compatible, but missing config parameters: 'streamable_email' 'streamable_password' +You can set them in /home/sk/.config/anypaste.conf +Attempting to upload with plugin 'sendvid' +######################################################################## 100.0% + +Link: http://sendvid.com/wwy7w96h +Delete/Edit: http://sendvid.com/wwy7w96h?secret=39c0af2d-d8bf-4d3d-bad3-ad37432a40a5 + +Upload complete. +All files processed. Have a nice day! +``` + +Anypaste 针对两个文件自动发现了与之相兼容的托管站点并成功上传。 + +正如你在上述用法介绍部分的例子中注意到的,Anypaste 会自动挑选最佳的插件。此外,你可以指定插件进行文件上传,这里提供一个上传到 gfycat 的案例,运行以下命令: + +``` +anypaste -p gfycat file.gif +``` + +输出示例: + +``` +Current file: file.gif +Plugin 'streamable' is compatible, but missing config parameters: 'streamable_email' 'streamable_password' +You can set them in /home/sk/.config/anypaste.conf +Attempting to upload with plugin 'gfycat' +######################################################################## 100.0% +Reminder: Gfycat needs time to encode. Your video will not appear right away. + +Link: https://gfycat.com/GrayDifferentCollie +Direct(ish) Link: https://thumbs.gfycat.com/GrayDifferentCollie-size_restricted.gif + +Upload complete. +All files processed. Have a nice day! +``` + +如果要使用特定插件进行文件上传,可以通过以下命令绕过兼容性检查: + +``` +anypaste -fp gfycat file.gif +``` + +如果你发现在配置文件中忽略了特定的插件,你仍然可以强制 Anypaste 去使用特定的插件,只不过需要加上 `-xp` 参数。 + +``` +anypaste -xp gfycat file.gif +``` + +如果想要以交互模式上传文件,可以在命令后加上 `-i` 标签: + +``` +$ anypaste -i file.gif +Current file: file.gif +Determine compatible plugins automatically? [Y/n] **n** +The following plugins were found: 'sendvid' 'streamable' 'gfycat' 'tinyimg' 'vgyme' 'instaudio' 'hastebin' 'ixio' 'sprunge' 'docdroid' 'jirafeau' 'fileio' + +Enter the (partial) name of a plugin, or nothing for automatic selection +**gfycat** +Attempt to upload with plugin 'gfycat'? [Y/n] **y** +Attempting to upload with plugin 'gfycat' +######################################################################## 100.0% +Reminder: Gfycat needs time to encode. Your video will not appear right away. + +Link: https://gfycat.com/WaryAshamedBlackbear +Direct(ish) Link: https://thumbs.gfycat.com/WaryAshamedBlackbear-size_restricted.gif + +Upload complete. +All files processed. Have a nice day! +``` + +正如你所见,Anypaste 首先询问了我是否需要自动确定插件。因为我不想自动寻找插件,所以我回复了 “No”。之后,Anypaste 列出了所有可选择的插件,并要求我从列表中选择一个。同样的,你可以上传和共享不同类型的文件,相关文件会被上传到相兼容的站点。 + +无论你何时上传一个视频文件,Anypaste 都会将其上传到以下站点中的一个: + + 1. sendvid + 2. streamable + 3. gfycat + +这里注意列表顺序,Anypaste 将首先将文件上传到 sendvid 站点,如果没有 sendvid 的插件可供使用,Anypaste 将会尝试顺序中的另外两个站点。当然你也可以通过更改配置文件来修改顺序。 + +图像文件上传站点: + + 1. tinyimg.io + 2. vgy.me + +音频文件上传站点: + + 1. instaud + +文本文件上传站点: + + 1. hastebin + 2. ix.io + 3. sprunge.us + +文档上传站点: + + 1. docdroid + +其他任意类型的文件上传站点: + + 1. jirafeau + 2. file.io + +上面列出来的部分站点一段特定的时间后会删除上传的内容,所以在上传和分享内容时应先明确这些站点的条款和条件。 + +### 结论 + +在我看来,识别文件并决定将其上传到何处的想法非常棒,而且开发者也以恰当的方式完美地实现了它。毫无疑问,Anypaste 对那些在互联网上需要频繁分享文件的人们非常有用,我希望你也能这么觉得。 + +这就是今天的全部内容,后面会有越来越多的好东西分享给大家。再见啦! + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/anypaste-share-upload-files-compatible-hosting-sites-automatically/ + +作者:[SK][a] +译者:[lixin555](https://github.com/lixin555) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://www.ostechnix.com/easy-fast-way-share-files-internet-command-line/ +[2]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]:http://www.ostechnix.com/wp-content/uploads/2017/10/gfycat.png diff --git a/published/201912/20180207 23 open source audio-visual production tools.md b/published/201912/20180207 23 open source audio-visual production tools.md new file mode 100644 index 0000000000..3df9236b46 --- /dev/null +++ b/published/201912/20180207 23 open source audio-visual production tools.md @@ -0,0 +1,289 @@ +23 款开源的声音、视觉生产工具 +====== + +> 无论你是要进行音频、图形、视频、动画还是它们的任意组合,都有一个开源工具可以帮助你产生专业水平的结果。 + +![](https://img.linux.net.cn/data/attachment/album/201912/04/093037w8ab8v0voz0b5u88.jpg) + +“开源”在云基础设施、网站托管、嵌入式设备和其他领域已经建立的相当完善。很少数人知道开源在生产专业级的声音视觉素材上也是一个不错的选择。 + +作为一名产品经理(有时候也是市场支持),我为终端用户提供很多内容:文档、文章、视频教学,甚至是展台物料、白皮书、采访等等。我找到了很多可以帮我制作音频、视频、排版、截屏的开源软件。人们选择开源软件而不是专有软件的[原因][1]有很多,而我也为以下人群编制了一份开源音视频工具清单: + +* 想要入坑 GNU/Linux,但需要在原来的操作系统上慢慢从使用跨平台软件开始 +* 热爱开源,但对音视频开源软件所知甚少,不知道该如何选择 +* 想要为创造力充电而探索新的工具,并且不想使用其他人使用过的方法工具 +* 存在某些其他的原因使用开源音视频解决方案(如果是你,不妨在评论里分享一下) + +幸运的是,存在着很多开源的音视频创作软件,也存在着很多硬件来支持这些应用。本文清单里的所有软件都符合以下标准: + +* 跨平台 +* 开源(软件和驱动) +* 稳定 +* 积极维护 +* 良好的文档与技术支持 + +我将清单中的解决方案划分为图形、音频、视频和动画。注意,本文中提到的应用程序并不完全等同于一些有名的私有软件,它们需要花时间来学习,并且可能需要改变你的工作流程,但是学习新的工具能够让体验全新的创造方式。 + +### 图形 + +我制作过很多出版和网站使用的图形,包括徽标、横幅、视频节目、草图。这里是一些我用过的开源应用,也包括一同使用的硬件。 + +#### 软件 + +**1、[Inkscape][2]**(矢量图) + +Inkscape 是一款不错的矢量图编辑器,用来制作 RGB 颜色空间下的 SVG 和 PDF 文件。(它可以制作 CMYK 图像,但不是主要用途)它是为 web 应用制作 SVG 格式的地图和图表的人的救命稻草。你不仅可以使用集成的 XML 编辑器打开文件,也可以用它查看对象的所有参数。但有一个缺点:它在 Mac 上的优化不是很好。有很多样例,可以看[Inkscape 画廊][3]。 + +**2、[GIMP][4]**(图片编辑器) + +GIMP 是我最喜欢的图片编辑程序,它包括了色彩调整、裁剪和拉伸,并且(尤其是)对于网页使用的文件大小进行了优化(很多使用 Photoshop 的同事让我帮他们做这最后一步)。你也可以从头制作并绘制一张图片,但 GIMP 并不是我最喜欢用来做这件事的工具。在 [GIMP Artists on DevianArt][5] 上查看众多的样例。 + +**3、[Krita][6]**(数字绘画) + +当你桌子上摆着一个漂亮的 Wacom 数位板,你肯定想试试真正的数字绘画应用。Krita 就是你创作漂亮插画所需要的工具。在 [Krita 画廊][7] 里看看我说的东西吧。 + +**4、[Scribus][8]**(桌面印刷系统) + +你可以使用 Scribus 来创建一个完整的文档,或者只是把用 Inkscape 或 Libre Office 制作的 PDF 从 RGB 转换到 CMYK。有一个功能我非常喜欢:你可以试着模拟视觉障碍人士使用 Scribus 时的体验。当我发送 PDF 文件给商业印刷公司时全指望 Scribus。尽管出版社可能使用像 InDesign 这样的私有软件创建文档,但如果你用 Scribus 正确的完成一份文档,那么打印时就不会出现任何问题。免费建议:第一次发送文件给印刷公司时,不要告诉印刷公司创建该文档所使用的软件。你可以在 [Scribus 教程][9]中寻找创建文档的例子。 + +**5、[RawTherapee][10]**(RAW 图像开发工具) + +RawTherapee 是我所知道唯一跨平台可替代 Lightroom 的软件。你可以将相机调整到 RAW 模式,然后使用 RawTherapee 来修图。它提供了非常强大的引擎和对图片没有破坏的编辑器。例如,可以见 [Raw Therapee 截图][11]。 + +**6、[LibreOffice Draw][12]**(桌面印刷系统) + +尽管你可能认为 LibraOffice Draw 不是一款专业的桌面印刷解决方案,但它仍然能够在很多情况下帮助你。例如,制作其他人(尽管是那些不懂图形软件的人)以后可以修改的白皮书、图表或海报。它不仅方便使用,而且当创建有趣的文档时也是 Impress 或 PowerPoint 的绝佳替代软件。 + +#### 图形硬件 + +**绘图板** + +[Wacom][13] 数位板(和兼容设备)通常支持所有的操作系统。 + +**颜色校正** + +颜色校正产品通常可用于所有操作系统,也包括了 GNU/Linux。Datacolor 生产的 [Spyder][14] 在所有平台上都有应用程序的支持。 + +**扫描仪和打印机** + +图形艺术家需要输出(无论是打印还是电子版)的颜色是精确的。但是真正跨平台的设备,以及所有平台都易于安装的驱动,并不像你想的那样普遍。你的最佳选择是兼容 TWAIN 的扫描仪和兼容 Postscript 的打印机。以我的经验,Epson 和 Xerox 的专业级扫描仪和打印机更不容易出现驱动问题,并且它们通常也是开箱即用,拥有漂亮精确的颜色。 + +### 音频 + +有许多可供音乐家、视频制作者、游戏制作者、音乐出版商等等人群选择的开源音频软件。这里有一些我曾经用来进行内容创作与声音录制时所使用的软件。 + +#### 软件 + +**7、[Ardour][15]**(数字音频录制) + +对录音与编辑来说,最专业级的工具选择当然是唾手可得的 Ardour。听起来很棒,它的混音部分非常的完整灵活,能够提供给你喜欢的插件,并且易于回放、编辑、对比修改。我经常用它进行声音录制和视频混音。要找出一些使用 Ardour 录制好的音乐并不容易,因为音乐家们很少表明他们使用的软件。然而,你可以查看它的[截图][16]和一些特性来了解它的功能。 + +(如果你在寻求一种声音制作方面的“模拟体验”,你可以试试 [Harrison Mixbus][17],它并不是一个开源项目,但是高度基于 Ardour,拥有模拟显示的终端。我非常喜欢用它进行工作,我的客户也喜欢用它制作的声音。Mixbus 也是跨平台的) + +**8、[Audacity][18]** (声音编辑) + +Audacity 属于“瑞士军刀”级的声音制作软件。它并不完美,但你几乎可以用它做所有的事情。加上非常易于使用,任何人都能在几分钟之内上手。像 Ardour 一样,很难找到一份归功于 Audacity 的作品,但你可以从这些[截图][19]中了解如何使用它。 + +**9、[LMMS][20]** (音乐制作) + +LMMS,设计作为 FL Studio 的替代品,也许使用并不那么广泛,但它非常完整并易于使用。你可以使用自己最喜欢的插件,使用“钢琴键”编辑乐器,使用步定序器step sequencer播放鼓点,混合音轨...几乎能做任何事情。在我没有时间为音乐家录音的时候我就使用它为视频创建声音片段。查看[最好的 LMMS][21] 榜单来看看一些例子。 + +**10、[Mixxx][22]** (DJ,音乐混音) + +如果你需要强大的混音和播放 DJ 软件,Mixxx 就可以满足你的需求。它与大多数 MIDI 控制器、唱片、专用声卡所兼容。你可以用它管理音乐库、添加音效,做一些有趣的事情。查看它的[功能][23]来了解它是如何工作的。 + +#### 音频接口硬件 + +尽管你可以使用任何一个计算机的声卡录制音频,但要录制的很好,就需要一个音频接口——一个录制高质量音频输入的专用的外部声卡。对于跨平台兼容性来说,大多数“兼容 USB”和“兼容 iOS”的音频接口设备应该都能录制 MIDI 或其他音频。下面是一些我用过的一些有名气的跨平台设备。 + +**[Behringer U-PHORIA UMC22][24]** + +UMC22 是你可以考虑的最便宜的选择。但它的前置放大器噪音太大,音腔box质量也比较低。 + +**[Presonus AudioBox USB][25]** + +AudioBox USB 是第一个兼容 USB(因此也跨平台)的录音系统。它非常的耐用,经常在二手市场也能见到。 + +**[Focusrite Scarlett][26]** + +Scarlett 在我看来是目前最高质量的跨平台声卡。不同种类的设备可以涵盖 2-18 个输入/输出端口。你可以在二手市场找到它的最初版本,而最新的第二代具有更好的前置放大器与规格。[2i2][27] 型号是我经常使用的那一款。 + +**[Arturia AudioFuse][28]** + +AudioFuse 几乎可以让你接入任何设备,从麦克风到黑胶唱片机再到各种数字输入设备。它具有优质的声音与良好的设计,也是我目前用的最多的一款设备。它是跨平台的,但目前配置软件还不能在 GUN/Linux 上使用。即使我把它从 Windows 电脑上断开,它仍然保留着我的配置。但是讲真,Arturia,劳烦认真考虑做一个 Linux 的软件。 + +#### MIDI 控制器 + +MIDI 控制器是一种乐器——例如电子琴、鼓垫等等。可以让你控制音乐软件或者硬件。现有的大多数 USB MIDI 控制器都跨平台并兼容主流的录音编辑软件。基于网页的教程可以帮你对不同的软件进行配置。尽管找到有关在 GNU/Linux 上配置的信息可能比较困难,但它们仍然是可以使用的。我用过许多 Akai 和 M-Audio 设备,没有任何问题。在买乐器之前最好先试一下,至少去听一下它们的音质或体验一下按键触感。 + +#### 音频编解码器 + +音频编解码器压缩或解压数字音频,用尽可能小的文件大小获得最佳质量的声音。幸运的是,用于收听或流媒体播放的编解码器恰好是开源的:[FLAC][29]。[Ogg Vorbis][30] 是另一个值得了解的开源音频编解码器;在相同的比特率下比 MP3 好的多。如果你需要输出不同的音频格式,我建议通常存档最好质量的音频,然后再压缩成特定的版本。 + +### 视频 + +视频对于品牌的传播是影响巨大的。即使你不是一个视频专家,学习一些基础的东西也是非常明智的。 + +#### 软件 + +**11、[VLC][31]** (视频播放器与转换器) + +最初是为流媒体而开发的,VLC 现在因能够在所有设备上读取所有的视频格式被人们熟知。它非常的实用,例如,你可以使用它将视频转换成其他编解码格式或容器,也可以用来恢复破损的视频。 + +**12、[OpenShot][32]** (视频编辑) + +OpenShot 是一个简单的软件,但它却可以制作出很好的效果,尤其是在短视频上。(在编辑或改善音质方面有一定的限制,但它也能够完成)我非常喜欢它的移动、拉伸、裁剪工具;用它创建视频的开头或结尾,导出之后使用更复杂的编辑器进行编辑,非常的完美。你可以在 OpenShot 的网站上看这些[例子][33](并获取更多信息)。 + +**13、[Shotcut][34]** (视频编辑) + +我认为 Shotcut 是比 OpenShot 更完整一些的工具——它在你的操作系统上比起其他较为基础的编辑器更具有竞争力,并且它支持 4K 分辨率,具有专业的解码器。尝试一下,我相信你会爱上它的。你可以在这些[视频教程][35]里看一些范例。 + +**14、[Blender Velvets][36]** (视频编辑、合成、特效) + +尽管这一章节不是本文的学习重点,但 Blender Velvets 是你能找到的最强大的解决方案之一。它是由一些视频创作者所制作的一系列扩展工具和脚本的合集,是通过 Blender 3D 制作软件转换成的 2D 视频编辑器。尽管它的复杂度意味着不是我的首选视频编辑器,但你仍可以在 YouTube 和其他网站上找到它的教程,并且一旦你学习了它,你就能通过它做任何事情。观看这个[视频教程][37]来了解它的功能与运作方式。 + +**15、[Natron][38]**(合成) + +我不使用 Natron,但我听说它广受好评。它是 Adobe After Effects 的替代品,但运作方式并不同。想了解更多可以观看一些视频教程,比如这些 Natron 的 [YouTube 频道][39]。 + +**16、[OBS][40]** (实时编辑、录制、流媒体) + +Open Broadcaster Software(OBS)是一个领先的在 YouTube 或 Twitch 上进行现场录制或现场直播电子竞技、电视游戏的解决方案。我经常使用它记录用户的屏幕、会议和聚会。要获取更多信息,查看我曾经在 Opensource.com 上写的关于录制现场汇报的教程,[第一部分:选择你的设备][42]和[第二部分:软件安装][43]。 + +#### 视频硬件 + +结论先行:你需要一个强大的工作站以及快速的硬盘和更新的软件和驱动。 + +**图形处理单元(GPU)** + +一部分包含在清单里的软件比如 Blender 和 Shotcut 使用 OpenGL 和硬件加速,这些都高度依赖 GPU。我建议你使用可以负担起的最强大的 GPU。我所使用过的 AMD 和 Nvidia 都有着良好的体验,这取决于使用的平台。不要忘记安装最新的驱动。 + +**硬盘** + +大体上来说,越快越大的硬盘,对视频越好。不要忘记在软件里配置好正确的路径。 + +**视频录制硬件** + +* [Blackmagic Design][44]: Blackmagic 提供了非常好的、专业级的视频录制和回放硬件。驱动支持 Mac、Windows 和 GNU/Linux(但不是所有的发行版) +* [Epiphan][45]: 在 Epiphan 的专业级 USB 视频录制设备中有一款新型产品,它适用于 HDMI 和高分辨率的屏幕。然而,你也可以在二手市场找到旧的 VGA 设备,因为他们还在继续为 GNU/Linux 和 Windows 上提供专用的驱动程序。 + +#### 视频编解码 + +不幸的是,使用开源的编解码器仍然很困难。例如,许多相机使用专有的编解码器录制 H.264 的视频和 AC3 的音频,组成称为 AVCHD 的格式。因此,我们必须务实,尽可能利用现有资源。 + +好消息是内容产业正在步向开源的编解码器来避免一些费用,并使用开源标准。对于出版和流媒体,[谷歌][46]的 [WebM][46] 便是一款优秀的开源编解码器,并且大多数视频编辑器可以导入这种格式。同样地, [GoPro][47]的超高分辨率和 360° 视频编解码器 [Cineform][47] 现在也进行了开源。希望更多的设备和供应商将会在不久之后使用它。 + +### 2D 和 3D 动画 + +动画不是我的专业领域,因此我问了从事于动画内容生产的朋友一些建议并加入到清单中,他的工作包含儿童电影和连续剧。 + +#### 软件 + +**17、[Blender][48]** (3D 模型和渲染) + +Blender 是顶级的开源跨平台 3D 建模和渲染软件。你可以直接在 Blender 中完成整个项目的工作,或者使用它为电影或视频创建 3D 效果。你能够在网上找到许多视频教程,因此即使它不是一个简单的软件,但也非常容易上手。Blender 是一个非常活跃的项目,经常还会制作一些微电影来展示他们的技术。你可以在 [Blender Open Movies][49] 上观看。 + +**18、[Synfig Studio][50]** (2D 动画) + +第一次用 Synfig 时,它让我想起了那个不错的 Macromedia 老式 Flash 编辑器。在那之后,它已经发展成一个全功能的 2D 动画工作室。你可以使用它制作宣传故事、商业广告、演示、开场或结尾动画以及视频中的转场,或者甚至用它制作全动画的电影。见 [Synfig 作品集][51]。 + +**19、[TupiTube][52]** (定格 2D 动画) + +使用 TupiTube 是一个学习基本 2D 动画的极好方法。你可以将一系列绘画或其他图片转换成一个视频或者创建一个 GIF 循环动画。它是一个相当简单的软件,但非常完整。查看 [TupiTude 的 YouTube][53] 频道获取一些教程和范例。 + +#### 硬件 + +动画制作使用与图形设计相同的硬件,因此查看第一小结中的硬件清单获取一些建议。 + +有一点需要注意:你要用一个强大的 GPU 来进行 3D 建模和渲染。选择可能有些限制,因为这取决于你使用的平台或电脑制造商,但是不要忘记安装最新的驱动。谨慎选择你的显卡:它们非常昂贵,并且在大型的 3D 项目中至关重要,尤其是在渲染步骤中。 + +### Linux 上的选择 + +如果你是 GUN/Linux 用户,那么我为你提供了更多不错的选择。它们并不是完全跨平台的,但部分拥有 Windows 版本,还有一些可以在 Mac 上使用 Macports 安装。 + +**20、[Kdenlive][54]** (视频编辑) + +伴随着最新版本的发布(几个月之前),Kdenlive 成为了我最喜欢的视频编辑器,尤其是当我在 Linux 机器上处理一些长视频的时候。如果你经常使用流行的非线性视频编辑器,Kdenlive(全称是 KDE 非线性视频编辑器KDE Non-Linear Video Editor)对你来说将非常简单。它拥有很棒的视频和音频特效,强大的细节处理能力。并且在 BSD 和 MacOS(尽管它对准的是 GNU/Linux)都能使用,还有望移植到 Windows 上。 + +**21、[Darktable][55]** (RAW 图像开发) + +Darktable 是一款由摄影师制作的非常完整的 DxO PhotoLab 替代品。一些研究型项目使用它当做开发平台并测试一些图像处理算法。它是一个非常活跃的项目,我已经等不及的见到它的跨平台版本了。 + +**22、[MyPaint][56]** (digital painting数字绘画) + +MyPaint 就像数字绘画领域的 light table(LCTT 译注:集成开发环境)。它在 Wacom 设备上表现良好,并且它的笔刷引擎尤其值得赞赏,因此 GIMP 开发人员正在密切的关注它。 + +**23、[Shutter][57]** (桌面截图) + +当我写这篇教程的时候,我使用了许多截图来进行展示。我最喜欢的 GNU/Linux 截图工具就是 Shutter。事实上,我都找不到在 Windows 或 Mac 上能与之抗衡的一些功能。有一点小遗憾:我很期待 Shutter 在将来能够增加新的功能来创建几秒动态的 GIF 截图。 + +我希望这些足以说服你开源软件是一种非常卓越且可行的音视频内容生产解决方案。如果你正在使用其他开源软件,或者对于使用跨平台软件和硬件进行音视频项目有好的建议,请在评论中分享你的观点。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/2/open-source-audio-visual-production-tools + +作者:[Antoine Thomas][a] +译者:[LuuMing](https://github.com/LuuMing) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/ttoine +[1]:https://opensource.com/resources/what-open-source +[2]:https://inkscape.org/ +[3]:https://inkscape.org/en/gallery/ +[4]:https://www.gimp.org/ +[5]:https://gimp-artists.deviantart.com/gallery/ +[6]:https://krita.org/ +[7]:https://krita.org/en/features/gallery/ +[8]:https://www.scribus.net/ +[9]:https://www.scribus.net/category/made-with-scribus/ +[10]:http://rawtherapee.com/ +[11]:http://rawtherapee.com/blog/screenshots +[12]:https://www.libreoffice.org/discover/draw/ +[13]:http://www.wacom.com/en-us +[14]:http://www.datacolor.com/photography-design/product-overview/#workflow_2 +[15]:https://www.ardour.org/ +[16]:http://ardour.org/features.html +[17]:http://harrisonconsoles.com/site/mixbus.html +[18]:http://www.audacityteam.org/ +[19]:http://www.audacityteam.org/about/screenshots/ +[20]:https://lmms.io/ +[21]:https://lmms.io/showcase/ +[22]:https://www.mixxx.org/ +[23]:https://www.mixxx.org/features/ +[24]:http://www.musictri.be/Categories/Behringer/Computer-Audio/Interfaces/UMC22/p/P0AUX +[25]:https://www.presonus.com/products/audiobox-usb +[26]:https://us.focusrite.com/scarlett-range +[27]:https://us.focusrite.com/usb-audio-interfaces/scarlett-2i2 +[28]:https://www.arturia.com/products/audio/audiofuse/overview +[29]:https://en.wikipedia.org/wiki/FLAC +[30]:https://xiph.org/vorbis/ +[31]:https://www.videolan.org/ +[32]:https://www.openshot.org/ +[33]:https://www.openshot.org/videos/ +[34]:https://shotcut.com/ +[35]:https://shotcut.org/tutorials/ +[36]:http://blendervelvets.org/ +[37]:http://blendervelvets.org/video-tutorial-new-functions-for-the-blender-velvets/ +[38]:https://natron.fr/ +[39]:https://www.youtube.com/playlist?list=PL2n8LbT_b5IeMwi3AIzqG4Rbg8y7d6Amk +[40]:https://obsproject.com/ +[41]:https://opensource.com/article/17/7/obs-studio-pro-level-streaming +[42]:https://opensource.com/article/17/9/equipment-recording-presentations +[43]:https://opensource.com/article/17/9/equipment-setup-live-presentations +[44]:https://www.blackmagicdesign.com/ +[45]:https://www.epiphan.com/ +[46]:https://www.webmproject.org/ +[47]:https://fr.gopro.com/news/gopro-open-sources-the-cineform-codec +[48]:https://www.blender.org/ +[49]:https://www.blender.org/about/projects/ +[50]:https://www.synfig.org/ +[51]:https://www.synfig.org/#portfolio +[52]:https://maefloresta.com/ +[53]:https://www.youtube.com/channel/UCBavSfmoZDnqZalr52QZRDw +[54]:https://kdenlive.org/ +[55]:https://www.darktable.org/ +[56]:http://mypaint.org/ +[57]:http://shutter-project.org/ diff --git a/published/201912/20181018 Think global- How to overcome cultural communication challenges.md b/published/201912/20181018 Think global- How to overcome cultural communication challenges.md new file mode 100644 index 0000000000..5b214ec331 --- /dev/null +++ b/published/201912/20181018 Think global- How to overcome cultural communication challenges.md @@ -0,0 +1,95 @@ +全球化思考:怎样克服交流中的文化差异 +====== + +> 这有一些建议帮助你的全球化开发团队能够更好地理解你们的讨论并能参与其中。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/people_remote_teams_world.png?itok=_9DCHEel) + +几周前,我见证了两位同事之间一次有趣的互动,他们分别是 Jason,我们的一位美国员工,和 Raj,一位来自印度的访问工作人员。 + +Raj 在印度时,他一般会通过电话参加美国中部时间上午 9 点的每日立会,现在他到美国工作了,就可以和组员们坐在同一间会议室里开会了。Jason 拦下了 Raj,说:“Raj 你要去哪?你不是一直和我们开电话会议吗?你突然出现在会议室里我还不太适应。” Raj 听了说,“是这样吗?没问题。”就回到自己工位前准备和以前一样参加电话会议了。 + +我去找 Raj,问他为什么不去参加每日立会,Raj 说 Jason 让自己给组员们打电话参会,而与此同时,Jason 也在会议室等着 Raj 来参加立会。 + +到底是哪里出的问题?Jason 明显只是调侃 Raj 终于能来一起开会了,为什么 Raj 没能听懂呢? + +Jason 明显是在开玩笑,但 Raj 把它当真了。这就是在两人互相不了解对方文化语境时发生的一个典型误会。 + +我经常会遇到有人在电子邮件的末尾写“请复原”,最开始我很迷惑,“这有什么需要我复原的内容?”后来我才搞懂,“请复原”其实是“请回复”的意思。 + +在 Ricardo Fernandez 的TED 演讲“[如何管理跨文化团队][1]” 中,他提到了自己与一位南非同事发生的小故事。那位同事用一句“我一会给你打电话。”结束了两人的 IM 会话,Ricardo 回到办公室后就开始等这位同事的电话,十五分钟后他忍不住主动给这位同事打了电话,问他:“你不是说要给我打电话吗?”,这位同事答到:“是啊,我是说以后有机会给你打电话。”这时 Ricardo 才理解那位同事说的“一会”是“以后”的意思。 + +现在是全球化时代,我们的同事很可能不跟我们面对面接触,甚至不在同一座城市,来自不同的国家。越来越多的技术公司拥有全球化的工作场所,和来自世界各地的员工,他们有着不同的背景和经历。这种多样性使得技术公司能够在这个快速发展的科技大环境下拥有更强的竞争力。 + +但是这种地域的多样性也会给团队带来挑战。管理和维持高性能的团队发展对于同地协作的团队来说就有着很大难度,对于有着多样背景成员的全球化团队来说,无疑更加困难。成员之间的交流会发生延迟,误解时有发生,成员之间甚至会互相怀疑,这些都会影响着公司的成功。 + +到底是什么因素让全球化交流间发生误解呢?我们可以参照 Erin Meyer 的书《[文化地图][2]》,她在书中将全球文化分为八个类型,其中美国文化被分为低语境文化,与之相对的,日本为高语境文化。 + +看到这里你可能会问,高、低语境文化到底是什么意思?美国人从小就教育孩子们简洁表达,“直言不讳”是他们的表达准则;另一边,日本人从小学习在高效处理社交线索的同时进行交流,“察言观色”是他们的交流习惯。 + +大部分亚洲国家的文化都属于高语境文化。作为一个年轻的移民国家,美国毫不意外地拥有着低语境文化。移民来自于世界各地,拥有着不同的文化背景,他们不得不选择简洁而直接的交流方式,这或许就是其拥有低语境文化的原因。 + +### 从文化语境的角度与异国同事交流的三个步骤: + +怎样面临跨文化交流中遇到的挑战?比如说一位美国人与他的日本同事交流,他更应该注重日本同事的非语言线索,同样的日本同事应当更关注美国人直接表达出的信息。如果你也面临类似的挑战,按照下面这三个步骤做,可以帮助你更有效地和异国同事交流,增进与他们的感情。 + +#### 认识到文化语境的差异 + +跨文化交流的第一步是认识到文化差异,跨文化交流从认识其他文化开始。 + +#### 尊重文化语境的差异 + +一旦你意识到了文化语境的差异会影响跨文化交流,你要做的就是尊重这些差异。在你遇到一种不同的交流方式时,学会接受差异,学会积极听取他人意见。 + +#### 调和文化语境的差异 + +只是认识和尊重差异还远远不够,你还需要学会如何调和这些差异。互相理解和换位思考可以增进差异的调和,你还要学着用它们去提高同事间的交流效率,推动生产力。 + +### 五种促进不同文化语境间交流的方法 + +为了加强组员们之间关系,这么多年来我一直在收集各种各样的方法和建议。这些方法帮助我解决了与外国组员间产生的很多交流问题,下面有其中一些例子: + +#### 与外国组员交流时尽量使用视频会议的形式 + +研究表明,交流中约 55% 的内容不是靠语言传递的。肢体语言传达着一种十分微妙的信息,你可以根据它们理解对方的意思,而视频会议中处于异地的组员们能够看到对方的肢体语言。因此,组织远程会议时我一般都会采用视频会议的形式。 + +#### 确保每位成员都有机会分享他们的想法 + +我虽然喜欢开视频会议,但不是每次都能开的成。如果视频会议对你的团队来说并不常用,大家可能要一些时间去适应,你需要积极鼓励大家参与到其中,先从进行语音会议开始。 + +我们有一个外地的组员,每次都和我们进行语音会议,和我们提到她经常会有些想法想要分享,或者想做些贡献,但是我们互相看不到,她不知道该怎样开口。如果你一直在进行语音会议,注意要给组员们足够的时间和机会分享他们的想法。 + +#### 互相学习 + +通过你身边一两名外国朋友来学习他们的文化,你可以把从一位同事身上学到的应用于所有来自这个国家的同事。我有几位南亚和南美的同事,他们帮助我理解他们的文化,而这些也使得我更加专业。 + +对编程人员来说,我建议请你全世界的同行们检查你的代码,这个过程能让你观察到其他文化中人们怎样进行反馈、劝说他人,和最终进行技术决策。 + +#### 学会感同身受 + +同理心是一段牢固关系的核心。你越能换位思考,就越容易获得信任,来建立长久的关系。你可以在每次会议开始之前和大家闲聊几句,这样大家更容易处于一个放松的状态,如果团队中有很多外国人,要确保大家都能参与进来。 + +#### 和你的外国同事们单独见面 + +保持长久关系最好的方法是和你的组员们单独见面。如果你的公司可以报销这些费用,那么努力去和组员们见面吧。和一起工作了很长时间的组员们见面能够使你们的关系更加坚固。我所在的公司就有着周期性交换员工的传统,每隔一段时间,世界各地的员工就会来到美国工作,美国员工再到其他分部工作。 + +另一种聚齐组员们的机会是研讨会。研讨会创造的不仅是学习和培训的机会,你还可以挤出一些时间和组员们培养感情。 + +在如今,全球化经济不断发展,拥有来自不同国家和地区的员工对维持一个公司的竞争力来说越来越重要。即使组员们来自世界各地,团队中会出现一些交流问题,但拥有一支国际化的高绩效团队不是问题。如果你在工作中有什么促进团队交流的小窍门,请在评论中告诉我们吧。 + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/think-global-communication-challenges + +作者:[Avindra Fernando][a] +选题:[lujun9972][b] +译者:[Valoniakim](https://github.com/Valoniakim) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/avindrafernando +[b]: https://github.com/lujun9972 +[1]: https://www.youtube.com/watch?v=QIoAkFpN8wQ +[2]: https://www.amazon.com/The-Culture-Map-Invisible-Boundaries/dp/1610392507 diff --git a/published/201912/20181231 Easily Upload Text Snippets To Pastebin-like Services From Commandline.md b/published/201912/20181231 Easily Upload Text Snippets To Pastebin-like Services From Commandline.md new file mode 100644 index 0000000000..d92f3a4b24 --- /dev/null +++ b/published/201912/20181231 Easily Upload Text Snippets To Pastebin-like Services From Commandline.md @@ -0,0 +1,247 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11691-1.html) +[#]: subject: (Easily Upload Text Snippets To Pastebin-like Services From Commandline) +[#]: via: (https://www.ostechnix.com/how-to-easily-upload-text-snippets-to-pastebin-like-services-from-commandline/) +[#]: author: (SK https://www.ostechnix.com/author/sk/) + +从命令行轻松将文本片段上传到类似 Pastebin 的服务中 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-720x340.png) + +每当需要在线共享代码片段时,我们想到的第一个便是 Pastebin.com,这是 Paul Dixon 于 2002 年推出的在线文本共享网站。现在,有几种可供选择的文本共享服务可以上传和共享文本片段、错误日志、配置文件、命令输出或任何类型的文本文件。如果你碰巧经常使用各种类似于 Pastebin 的服务来共享代码,那么这对你来说确实是个好消息。向 Wgetpaste 打个招呼吧,它是一个命令行 BASH 实用程序,可轻松地将文本摘要上传到类似 Pastebin 的服务中。使用 Wgetpaste 脚本,任何人都可以与自己的朋友、同事或想在类似 Unix 的系统中的命令行中查看/使用/审查代码的人快速共享文本片段。 + +### 安装 Wgetpaste + +Wgetpaste 在 Arch Linux [Community] 存储库中可用。要将其安装在 Arch Linux 及其变体(如 Antergos 和 Manjaro Linux)上,只需运行以下命令: + +``` +$ sudo pacman -S wgetpaste +``` + +对于其他发行版,请从 [Wgetpaste 网站][1] 获取源代码,并按如下所述手动安装。 + +首先下载最新的 Wgetpaste tar 文件: + +``` +$ wget http://wgetpaste.zlin.dk/wgetpaste-2.28.tar.bz2 +``` + +提取它: + +``` +$ tar -xvjf wgetpaste-2.28.tar.bz2 +``` + +它将 tar 文件的内容提取到名为 `wgetpaste-2.28` 的文件夹中。 + +转到该目录: + +``` +$ cd wgetpaste-2.28/ +``` + +将 `wgetpaste` 二进制文件复制到 `$PATH` 中,例如 `/usr/local/bin/`。 + +``` +$ sudo cp wgetpaste /usr/local/bin/ +``` + +最后,使用命令使其可执行: + +``` +$ sudo chmod +x /usr/local/bin/wgetpaste +``` + +### 将文本片段上传到类似 Pastebin 的服务中 + +使用 Wgetpaste 上传文本片段很简单。让我向你展示一些示例。 + +#### 1、上传文本文件 + +要使用 Wgetpaste 上传任何文本文件,只需运行: + +``` +$ wgetpaste mytext.txt +``` + +此命令将上传 `mytext.txt` 文件的内容。 + +示例输出: + +``` +Your paste can be seen here: https://paste.pound-python.org/show/eO0aQjTgExP0wT5uWyX7/ +``` + +![](https://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-1.png) + +你可以通过邮件、短信、whatsapp 或 IRC 等任何媒体共享 pastebin 的 URL。拥有此 URL 的人都可以访问它,并在他们选择的 Web 浏览器中查看文本文件的内容。 + +这是 Web 浏览器中 `mytext.txt` 文件的内容: + +![](https://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-2.png) + +你也可以使用 `tee` 命令显示粘贴的内容,而不是盲目地上传它们。 + +为此,请使用如下的 `-t` 选项。 + +``` +$ wgetpaste -t mytext.txt +``` + +![][3] + +#### 2、将文字片段上传到其他服务 + +默认情况下,Wgetpaste 会将文本片段上传到 poundpython()服务。 + +要查看支持的服务列表,请运行: + +``` +$ wgetpaste -S +``` + +示例输出: + +``` +Services supported: (case sensitive): +Name: | Url: +=============|================= +bpaste | https://bpaste.net/ +codepad | http://codepad.org/ +dpaste | http://dpaste.com/ +gists | https://api.github.com/gists +*poundpython | https://paste.pound-python.org/ +``` + +在这里,`*` 表示默认服务。 + +如你所见,Wgetpaste 当前支持五种文本共享服务。我并没有全部尝试,但是我相信所有服务都可以使用。 + +要将内容上传到其他服务,例如 bpaste.net,请使用如下所示的 `-s` 选项。 + +``` +$ wgetpaste -s bpaste mytext.txt +Your paste can be seen here: https://bpaste.net/show/5199e127e733 +``` + +#### 3、从标准输入读取输入 + +Wgetpaste 也可以从标准输入读取。 + +``` +$ uname -a | wgetpaste +``` + +此命令将上传 `uname -a` 命令的输出。 + +#### 4、上传命令及命令的输出 + +有时,你可能需要粘贴命令及其输出。为此,请在如下所示的引号内指定命令的内容。 + +``` +$ wgetpaste -c 'ls -l' +``` + +这会将命令 `ls -l` 及其输出上传到 pastebin 服务。 + +当你想让其他人清楚地知道你刚运行的确切命令及其输出时,此功能很有用。 + +![][4] + +如你在输出中看到的,我运行了 `ls -l` 命令。 + +#### 5、上载系统日志文件、配置文件 + +就像我已经说过的,我们可以上载你的系统中任何类型的文本文件,而不仅仅是普通的文本文件,例如日志文件、特定命令的输出等。例如,你刚刚更新了 Arch Linux 机器,最后系统损坏了。你问你的同事该如何解决此问题,他(她)想阅读 `pacman.log` 文件。 这是上传 `pacman.log` 文件内容的命令: + +``` +$ wgetpaste /var/log/pacman.log +``` + +与你的同事共享 pastebin URL,以便他/她可以查看 `pacman.log`,并通过查看日志文件来帮助你解决问题。 + +通常,日志文件的内容可能太长,你不希望全部共享它们。在这种情况下,只需使用 `cat` 命令读取输出,然后使用 `tail -n` 命令定义要共享的行数,最后将输出通过管道传递到 Wgetpaste,如下所示。 + +``` +$ cat /var/log/pacman.log | tail -n 50 | wgetpaste +``` + +上面的命令将仅上传 `pacman.log` 文件的“最后 50 行”。 + +#### 6、将输入网址转换为短链接 + +默认情况下,Wgetpaste 将在输出中显示完整的 pastebin URL。如果要将输入 URL 转换为短链接,只需使用 `-u` 选项。 + +``` +$ wgetpaste -u mytext.txt +Your paste can be seen here: http://tinyurl.com/y85d8gtz +``` + +#### 7、设定语言 + +默认情况下,Wgetpaste 将上传“纯文本”中的文本片段。 + +要列出指定服务支持的语言,请使用 `-L` 选项。 + +``` +$ wgetpaste -L +``` + +该命令将列出默认服务(poundpython )支持的所有语言。 + +我们可以使用 `-l` 选项来改变它。 + +``` +$ wgetpaste -l Bash mytext.txt +``` + +#### 8、在输出中禁用语法突出显示或 html + +如上所述,文本片段将以特定的语言格式(纯文本、Bash 等)显示。 + +但是,你可以更改此行为,以使用 `-r` 选项显示原始文本摘要。 + +``` +$ wgetpaste -r mytext.txt +Your raw paste can be seen here: https://paste.pound-python.org/raw/CUJhQ3jEmr2UvfmD2xCL/ +``` + +![](https://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-5.png) + +如你在上面的输出中看到的,没有语法突出显示,没有 html 格式。只是原始输出。 + +#### 9、更改 Wgetpaste 默认值 + +所有默认值(`DEFAULT_{NICK,LANGUAGE,EXPIRATION}[_${SERVICE}]` 和 `DEFAULT_SERVICE`)都可以在 `/etc/wgetpaste.conf` 中全局更改,也可以在 `~/.wgetpaste.conf` 文件中针对每个用户更改。但是,这些文件在我的系统中默认情况下并不存在。我想我们需要手动创建它们。开发人员已经在[这里][5]和[这里][6]为这两个文件提供了示例内容。只需使用给定的样本内容手动创建这些文件,并相应地修改参数即可更改 Wgetpaste 的默认设置。 + +#### 10、获得帮助 + +要显示帮助部分,请运行: + +``` +$ wgetpaste -h +``` + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-easily-upload-text-snippets-to-pastebin-like-services-from-commandline/ + +作者:[SK][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: http://wgetpaste.zlin.dk/ +[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]: http://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-3.png +[4]: http://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-4.png +[5]: http://wgetpaste.zlin.dk/zlin.conf +[6]: http://wgetpaste.zlin.dk/wgetpaste.example diff --git a/published/201912/20190217 Install Android 8.1 Oreo on Linux To Run Apps - Games.md b/published/201912/20190217 Install Android 8.1 Oreo on Linux To Run Apps - Games.md new file mode 100644 index 0000000000..3babf263f3 --- /dev/null +++ b/published/201912/20190217 Install Android 8.1 Oreo on Linux To Run Apps - Games.md @@ -0,0 +1,207 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11711-1.html) +[#]: subject: (Install Android 8.1 Oreo on Linux To Run Apps & Games) +[#]: via: (https://fosspost.org/tutorials/install-android-8-1-oreo-on-linux) +[#]: author: (Python Programmer;Open Source Software Enthusiast. Worked On Developing A Lot Of Free Software. The Founder Of Foss Post;Foss Project. Computer Science Major. ) + +在 Linux 上安装安卓 8.1 Oreo 来运行应用程序和游戏 +====== + +![](https://i2.wp.com/fosspost.org/wp-content/uploads/2019/02/android-8.1-oreo-x86-on-linux.png?resize=1237%2C527&ssl=1) + +[android x86][1] 是一个自由而开源的项目,将谷歌制作的安卓系统从 ARM 架构移植到了 x86 架构,可以让用户在他们的桌面电脑上运行安卓系统来享受所有的安卓功能和应用程序及游戏。 + +在前一段时间,android x86 项目完成了安卓 8.1 Oreo 系统的 x86 架构移植。在这篇文章中,我们将解释如何在你的 Linux 系统上安装它,以便你能够随时使用你的安卓 用程序和游戏。 + +### 在 Linux 上安装安卓 x86 8.1 Oreo + +#### 准备环境 + +首先,让我们下载 android x86 8.1 Oreo 系统镜像。你可以从[这个页面][2]下载它,只需单击 “android-x86_64-8.1-r1.iso” 文件下的 “View” 按钮。 + +我们将在我们的 Linux 系统上使用 QEMU 来运行 android x86。QEMU 是一个非常好的模拟器软件,它也是自由而开源的,并且在所有主要的 Linux 发行版存储库中都是可用的。 + +在 Ubuntu/Linux Mint/Debian 上安装 QEMU: + +``` +sudo apt-get install qemu qemu-kvm libvirt-bin +``` + +在 Fedora 上安装 QEMU: + +``` +sudo dnf install qemu qemu-kvm +``` + +对于其它发行版,只需要搜索 “qemu” 和 “qemu-kvm” 软件包,并安装它们。 + +在你安装 QEMU 后,我们将需要运行下面的命令来创建 `android.img` 文件,它就像某种分配给安卓系统的磁盘空间。所有安卓文件和系统都将位于该镜像文件中: + +``` +qemu-img create -f qcow2 android.img 15G +``` + +我们在这里的意思是,我们想为该安卓系统分配一个最大 15GB 的磁盘空间,但是,你可以更改它到你想要的任意大小(确保它至少大于 5GB)。 + +现在,首次启动运行该安卓系统,运行: + +``` +sudo qemu-system-x86_64 -m 2048 -boot d -enable-kvm -smp 3 -net nic -net user -hda android.img -cdrom /home/mhsabbagh/android-x86_64-8.1-r1.iso +``` + +将 `/home/mhsabbagh/android-x86_64-8.1-r1.iso` 替换为你从 android x86 网站下载的文件的路径。关于我们在这里正在使用的其它选项的解释,你可以参考[这篇文章][3]。 + +在你运行上面的命令后,该安卓系统将启动: + +![][4] + +#### 安装系统 + +从这个窗口中,选择 “Advanced options”, 它将引导到下面的菜单,你应如下在其中选择 “Auto_installation” : + +![][5] + +在这以后,安装器将告知你是否想要继续,选择 “Yes”: + +![][6] + +接下来,安装器将无需你的指示而继续进行: + +![][7] + +最后,你将收到这个信息,它表示你已经成功安装安卓 8.1 : + +![][8] + +现在,关闭 QEMU 窗口即可。 + +#### 启动和使用 安卓 8.1 Oreo + +现在,安卓系统已经完全安装在你的 `android.img` 文件中,你应该使用下面的 QEMU 命令来启动它,而不是前面的命令: + +``` +sudo qemu-system-x86_64 -m 2048 -boot d -enable-kvm -smp 3 -net nic -net user -hda android.img +``` + +注意,我们所做的只是移除 `-cdrom` 选项及其参数。这是告诉 QEMU,我们不再想从我们下载的 ISO 文件启动,相反,从这个安装的安卓系统启动。 + +你现在能够看到安卓的启动菜单: + +![][9] + +然后,你将进入第一个准备向导,选择你的语言并继续: + +![][10] + +从这里,选择 “Set up as new” 选项: + +![][11] + +然后,安卓将询问你是否想登录到你当前的谷歌账号。这步骤是可选的,但是这很重要,以便你随后可以使用谷歌 Play 商店: + +![][12] + +然后,你将需要接受条款: + +![][13] + +现在,你可以选择你当前的时区: + +![][14] + +系统将询问你是否想启动一些数据收集功能。如果我是你的话,我将简单地全部关闭它们,像这样: + +![][15] + +最后,你将有两种启动类型可供选择,我建议你选择 Launcher3 选项,并使其成为默认项: + +![][16] + +然后,你将看到完整工作的安卓系统主屏幕: + +![][17] + +从现在起,你可以做你想做的任何事情;你可以使用内置的安卓应用程序,或者你可以浏览你的系统设置来根据你的喜好进行调整。你可以更改你的系统的外观和体验,或者你可以像示例一样运行 Chrome : + +![][18] + +你可以开始从谷歌 Play 商店安装一些应用程序程序,像 WhatsApp 和其它的应用程序,以供你自己使用: + +![][19] + +你现在可以用你的系统做任何你想做的事。恭喜! + +### 以后如何轻松地运行安卓 8.1 Oreo + +我们不想总是不得不打开终端窗口,并写那些长长的 QEMU 命令来运行安卓系统,相反,我们想在我们需要时一次单击就运行它。 + +为此,我们将使用下面的命令在 `/usr/share/applications` 下创建一个名为 `android.desktop` 的新文件: + +``` +sudo nano /usr/share/applications/android.desktop +``` + +并在其中粘贴下面的内容(右键单击然后粘贴): + +``` +[Desktop Entry] +Name=Android 8.1 +Comment=Run Android 8.1 Oreo on Linux using QEMU +Icon=phone +Exec=bash -c 'pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY qemu-system-x86_64 -m 2048 -boot d -enable-kvm -smp 3 -net nic -net user -hda /home/mhsabbagh/android.img' +Terminal=false +Type=Application +StartupNotify=true +Categories=GTK; +``` + +再强调一次,你必需使用你系统上的本地镜像路径来替换 `/home/mhsabbagh/android.img` 。然后保存文件(`Ctrl+X`,然后按 `Y`,然后按回车)。 + +注意,我们需要使用 `pkexec` 来使用 root 权限运行 QEMU ,因为从较新的版本开始,普通用户不允许通过 libvirt 访问 KVM 技术;这就是为什么它将每次要求你输入 root 密码的原因。 + +现在,你将在应用程序菜单中看到安卓图标,你可以在你想使用安卓的任何时间来简单地单击该图标,QEMU 程序将启动: + +![][20] + +### 总结 + +我们向你展示如何在你的 Linux 系统上安装和运行安卓 8.1 Oreo 。从现在起,在没有其它一些软件的(像 Blutsticks 和类似的方法)的情况下,你可以更容易地完成基于安卓的任务。在这里,你有一个完整工作和功能的安卓系统,你可以随心所欲地操作它,如果一些东西出错,你可以简单地干掉该镜像文件,然后随时再一次重新运行安装程序。 + +你之前尝试过 android x86 吗?你的体验如何? + +-------------------------------------------------------------------------------- + +via: https://fosspost.org/tutorials/install-android-8-1-oreo-on-linux + +作者:[M.Hanny Sabbagh][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://fosspost.org/author/mhsabbagh +[b]: https://github.com/lujun9972 +[1]: http://www.android-x86.org/ +[2]: http://www.android-x86.org/download +[3]: https://fosspost.org/tutorials/use-qemu-test-operating-systems-distributions +[4]: https://i0.wp.com/fosspost.org/wp-content/uploads/2019/02/Android-8.1-Oreo-on-Linux-16.png?resize=694%2C548&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 40 android 8.1 oreo on linux) +[5]: https://i0.wp.com/fosspost.org/wp-content/uploads/2019/02/Android-8.1-Oreo-on-Linux-15.png?resize=673%2C537&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 42 android 8.1 oreo on linux) +[6]: https://i1.wp.com/fosspost.org/wp-content/uploads/2019/02/Android-8.1-Oreo-on-Linux-14.png?resize=769%2C469&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 44 android 8.1 oreo on linux) +[7]: https://i1.wp.com/fosspost.org/wp-content/uploads/2019/02/Android-8.1-Oreo-on-Linux-13.png?resize=767%2C466&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 46 android 8.1 oreo on linux) +[8]: https://i0.wp.com/fosspost.org/wp-content/uploads/2019/02/Android-8.1-Oreo-on-Linux-12.png?resize=750%2C460&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 48 android 8.1 oreo on linux) +[9]: https://i1.wp.com/fosspost.org/wp-content/uploads/2019/02/Android-8.1-Oreo-on-Linux-11.png?resize=754%2C456&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 50 android 8.1 oreo on linux) +[10]: https://i0.wp.com/fosspost.org/wp-content/uploads/2019/02/Android-8.1-Oreo-on-Linux-10.png?resize=850%2C559&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 52 android 8.1 oreo on linux) +[11]: https://i0.wp.com/fosspost.org/wp-content/uploads/2019/02/Android-8.1-Oreo-on-Linux-09.png?resize=850%2C569&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 54 android 8.1 oreo on linux) +[12]: https://i1.wp.com/fosspost.org/wp-content/uploads/2019/02/Android-8.1-Oreo-on-Linux-08.png?resize=850%2C562&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 56 android 8.1 oreo on linux) +[13]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/02/Android-8.1-Oreo-on-Linux-07-1.png?resize=850%2C561&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 58 android 8.1 oreo on linux) +[14]: https://i0.wp.com/fosspost.org/wp-content/uploads/2019/02/Android-8.1-Oreo-on-Linux-06.png?resize=850%2C569&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 60 android 8.1 oreo on linux) +[15]: https://i1.wp.com/fosspost.org/wp-content/uploads/2019/02/Android-8.1-Oreo-on-Linux-05.png?resize=850%2C559&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 62 android 8.1 oreo on linux) +[16]: https://i1.wp.com/fosspost.org/wp-content/uploads/2019/02/Android-8.1-Oreo-on-Linux-04.png?resize=850%2C553&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 64 android 8.1 oreo on linux) +[17]: https://i0.wp.com/fosspost.org/wp-content/uploads/2019/02/Android-8.1-Oreo-on-Linux-03.png?resize=850%2C571&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 66 android 8.1 oreo on linux) +[18]: https://i1.wp.com/fosspost.org/wp-content/uploads/2019/02/Android-8.1-Oreo-on-Linux-02.png?resize=850%2C555&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 68 android 8.1 oreo on linux) +[19]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/02/Android-8.1-Oreo-on-Linux-01.png?resize=850%2C557&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 70 android 8.1 oreo on linux) +[20]: https://i0.wp.com/fosspost.org/wp-content/uploads/2019/02/Screenshot-at-2019-02-17-1539.png?resize=850%2C557&ssl=1 (Install Android 8.1 Oreo on Linux To Run Apps & Games 72 android 8.1 oreo on linux) diff --git a/published/201912/20190225 Netboot a Fedora Live CD.md b/published/201912/20190225 Netboot a Fedora Live CD.md new file mode 100644 index 0000000000..928f1eeed8 --- /dev/null +++ b/published/201912/20190225 Netboot a Fedora Live CD.md @@ -0,0 +1,183 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11708-1.html) +[#]: subject: (Netboot a Fedora Live CD) +[#]: via: (https://fedoramagazine.org/netboot-a-fedora-live-cd/) +[#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/) + +网络启动一个 Fedora Live CD +====== + +![](https://fedoramagazine.org/wp-content/uploads/2019/02/netboot-livecd-816x345.jpg) + +[Live CD][1] 对于很多任务是很有用的,例如: + +* 将操作系统安装到一个硬盘驱动器 +* 修复一个启动加载程序或执行其它救援模式操作 +* 为 Web 浏览提供一个相适应的最小环境 +* …以及[更多的东西][2]。 + +作为使用 DVD 和 USB 驱动器来存储你的 Live CD 镜像是一个替代方案,你可以上传它们到一个不太可能丢失或损坏的 [iSCSI][3] 服务器中。这个指南向你展示如何加载你的 Live CD 镜像到一个 ISCSI 服务器上,并使用 [iPXE][4] 启动加载程序来访问它们。 + +### 下载一个 Live CD 镜像 + +``` +$ MY_RLSE=27 +$ MY_LIVE=$(wget -q -O - https://dl.fedoraproject.org/pub/archive/fedora/linux/releases/$MY_RLSE/Workstation/x86_64/iso | perl -ne '/(Fedora[^ ]*?-Live-[^ ]*?\.iso)(?{print $^N})/;') +$ MY_NAME=fc$MY_RLSE +$ wget -O $MY_NAME.iso https://dl.fedoraproject.org/pub/archive/fedora/linux/releases/$MY_RLSE/Workstation/x86_64/iso/$MY_LIVE +``` + +上面的命令下载 `Fedora-Workstation-Live-x86_64-27-1.6.iso` Fedora Live 镜像,并保存为 `fc27.iso`。更改 `MY_RLSE` 的值来下载其它档案版本。或者,你可以浏览 来下载最新的 Fedora live 镜像。在 21 之前的版本使用不同的命名约定,必需[在这里手动下载][5]。如果你手动下载一个 Live CD 镜像,设置 `MY_NAME` 变量为不带有扩展名的文件的基本名称。用此方法,下面部分中命令将引用正确的文件。 + +### 转换 Live CD 镜像 + +使用 `livecd-iso-to-disk` 工具来转换 ISO 文件为一个磁盘镜像,并添加 `netroot` 参数到嵌入的内核命令行: + +``` +$ sudo dnf install -y livecd-tools +$ MY_SIZE=$(du -ms $MY_NAME.iso | cut -f 1) +$ dd if=/dev/zero of=$MY_NAME.img bs=1MiB count=0 seek=$(($MY_SIZE+512)) +$ MY_SRVR=server-01.example.edu +$ MY_RVRS=$(echo $MY_SRVR | tr '.' "\n" | tac | tr "\n" '.' | cut -b -${#MY_SRVR}) +$ MY_LOOP=$(sudo losetup --show --nooverlap --find $MY_NAME.img) +$ sudo livecd-iso-to-disk --format --extra-kernel-args netroot=iscsi:$MY_SRVR:::1:iqn.$MY_RVRS:$MY_NAME $MY_NAME.iso $MY_LOOP +$ sudo losetup -d $MY_LOOP +``` + +### 上传 Live 镜像到你的服务器 + +在你的 ISCSI 服务器上创建一个目录来存储你的 live 镜像,随后上传你修改的镜像到其中。 + +对于 21 及更高发布版本: + +``` +$ MY_FLDR=/images +$ scp $MY_NAME.img $MY_SRVR:$MY_FLDR/ +``` + +对于 21 以前发布版本: + +``` +$ MY_FLDR=/images +$ MY_LOOP=$(sudo losetup --show --nooverlap --find --partscan $MY_NAME.img) +$ sudo tune2fs -O ^has_journal ${MY_LOOP}p1 +$ sudo e2fsck ${MY_LOOP}p1 +$ sudo dd status=none if=${MY_LOOP}p1 | ssh $MY_SRVR "dd of=$MY_FLDR/$MY_NAME.img" +$ sudo losetup -d $MY_LOOP +``` + +### 定义 iSCSI 目标 + +在你的 iSCSI 服务器上运行下面的命令: + +``` +$ sudo -i +# MY_NAME=fc27 +# MY_FLDR=/images +# MY_SRVR=`hostname` +# MY_RVRS=$(echo $MY_SRVR | tr '.' "\n" | tac | tr "\n" '.' | cut -b -${#MY_SRVR}) +# cat << END > /etc/tgt/conf.d/$MY_NAME.conf + + backing-store $MY_FLDR/$MY_NAME.img + readonly 1 + allow-in-use yes + +END +# tgt-admin --update ALL +``` + +### 创建一个可启动 USB 驱动器 + +[iPXE][4] 启动加载程序有一个 [sanboot][6] 命令,你可以使用它来连接并启动托管于你 ISCSI 服务器上运行的 live 镜像。它可以以很多不同的[格式][7]编译。最好的工作格式依赖于你正在运行的硬件。例如,下面的说明向你展示如何在一个 USB 驱动器上从 [syslinux][9] 中 [链式加载][8] iPXE。 + +首先,下载 iPXE,并以它的 lkrn 格式构建。这应该作为一个工作站上的普通用户完成: + +``` +$ sudo dnf install -y git +$ git clone http://git.ipxe.org/ipxe.git $HOME/ipxe +$ sudo dnf groupinstall -y "C Development Tools and Libraries" +$ cd $HOME/ipxe/src +$ make clean +$ make bin/ipxe.lkrn +$ cp bin/ipxe.lkrn /tmp +``` + +接下来,准备一个带有一个 MSDOS 分区表和一个 FAT32 文件系统的 USB 驱动器。下面的命令假设你已经连接将要格式化的 USB 驱动器。**注意:你要格式正确的驱动器!** + +``` +$ sudo -i +# dnf install -y parted util-linux dosfstools +# echo; find /dev/disk/by-id ! -regex '.*-part.*' -name 'usb-*' -exec readlink -f {} \; | xargs -i bash -c "parted -s {} unit MiB print | perl -0 -ne '/^Model: ([^(]*).*\n.*?([0-9]*MiB)/i && print \"Found: {} = \$2 \$1\n\"'"; echo; read -e -i "$(find /dev/disk/by-id ! -regex '.*-part.*' -name 'usb-*' -exec readlink -f {} \; -quit)" -p "Drive to format: " MY_USB +# umount $MY_USB? +# wipefs -a $MY_USB +# parted -s $MY_USB mklabel msdos mkpart primary fat32 1MiB 100% set 1 boot on +# mkfs -t vfat -F 32 ${MY_USB}1 +``` + +最后,在 USB 驱动器上安装并配置 syslinux ,来链式加载 iPXE: + +``` +# dnf install -y syslinux-nonlinux +# syslinux -i ${MY_USB}1 +# dd if=/usr/share/syslinux/mbr.bin of=${MY_USB} +# MY_MNT=$(mktemp -d) +# mount ${MY_USB}1 $MY_MNT +# MY_NAME=fc27 +# MY_SRVR=server-01.example.edu +# MY_RVRS=$(echo $MY_SRVR | tr '.' "\n" | tac | tr "\n" '.' | cut -b -${#MY_SRVR}) +# cat << END > $MY_MNT/syslinux.cfg +ui menu.c32 +default $MY_NAME +timeout 100 +menu title SYSLINUX +label $MY_NAME + menu label ${MY_NAME^^} + kernel ipxe.lkrn + append dhcp && sanboot iscsi:$MY_SRVR:::1:iqn.$MY_RVRS:$MY_NAME +END +# cp /usr/share/syslinux/menu.c32 $MY_MNT +# cp /usr/share/syslinux/libutil.c32 $MY_MNT +# cp /tmp/ipxe.lkrn $MY_MNT +# umount ${MY_USB}1 +``` + +通过简单地编辑 `syslinux.cfg` 文件,并添加附加的菜单项,你应该能够使用这同一个 USB 驱动器来网络启动附加的 ISCSI 目标。 + +这仅是加载 IPXE 的一种方法。你可以直接在你的工作站上安装 syslinux 。再一种选项是编译 iPXE 为一个 EFI 可执行文件,并直接放置它到你的 [ESP][10] 中。又一种选项是编译 iPXE 为一个 PXE 加载器,并放置它到你的能够被 DHCP 引用的 TFTP 服务器。最佳的选项依赖于的环境 + +### 最后说明 + +* 如果你以 IPXE 的 EFI 格式编译 IPXE ,你可能想添加 `–filename \EFI\BOOT\grubx64.efi` 参数到 `sanboot` 命令。 +* 能够创建自定义 live 镜像。更多信息参考[创建和使用 live CD][11]。 +* 可以添加 `–overlay-size-mb` 和 `–home-size-mb` 参数到 `livecd-iso-to-disk` 命令来创建永久存储的 live 镜像。然而,如果你有多个并发用户,你将需要设置你的 ISCSI 服务器来管理独立的每个用户的可写覆盖。这与 “[如何构建一个网络启动服务器,部分 4][12]” 一文所示类似。 +* Live 镜像在它们的内核命令行中支持一个 `persistenthome` 选项(例如, `persistenthome=LABEL=HOME`)。与经过 CHAP 身份验证的 iSCSI 目标一起使用,对于中心控制主目录,`persistenthome` 选项为 NFS 提供一个有趣的替代方案。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/netboot-a-fedora-live-cd/ + +作者:[Gregory Bartholomew][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://fedoramagazine.org/author/glb/ +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Live_CD +[2]: https://en.wikipedia.org/wiki/Live_CD#Uses +[3]: https://en.wikipedia.org/wiki/ISCSI +[4]: https://ipxe.org/ +[5]: https://dl.fedoraproject.org/pub/archive/fedora/linux/releases/https://dl.fedoraproject.org/pub/archive/fedora/linux/releases/ +[6]: http://ipxe.org/cmd/sanboot/ +[7]: https://ipxe.org/appnote/buildtargets#boot_type +[8]: https://en.wikipedia.org/wiki/Chain_loading +[9]: https://www.syslinux.org/wiki/index.php?title=SYSLINUX +[10]: https://en.wikipedia.org/wiki/EFI_system_partition +[11]: https://docs.fedoraproject.org/en-US/quick-docs/creating-and-using-a-live-installation-image/#proc_creating-and-using-live-cd +[12]: https://fedoramagazine.org/how-to-build-a-netboot-server-part-4/ + diff --git a/published/201912/20190322 Easy means easy to debug.md b/published/201912/20190322 Easy means easy to debug.md new file mode 100644 index 0000000000..8777acf660 --- /dev/null +++ b/published/201912/20190322 Easy means easy to debug.md @@ -0,0 +1,79 @@ +[#]: collector: (lujun9972) +[#]: translator: (LuuMing) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11693-1.html) +[#]: subject: (Easy means easy to debug) +[#]: via: (https://arp242.net/weblog/easy.html) +[#]: author: (Martin Tournoij https://arp242.net/) + +简单就是易于调试 +====== + +对于框架、库或者工具来说,怎样做才算是“简单”?也许有很多的定义,但我的理解通常是**易于调试**。我经常见到人们宣传某个特定的程序、框架、库、文件格式或者其它什么东西是简单的,因为他们会说“看,我只需要这么一点工作量就能够完成某项工作,这太简单了”。非常好,但并不完善。 + +你可能只编写一次软件,但几乎总要经历好几个调试周期。注意我说的调试周期并不意味着“代码里面有 bug 你需要修复”,而是说“我需要再看一下这份代码来修复 bug”。为了调试代码,你需要理解它,因此“易于调试”延伸来讲就是“易于理解”。 + +抽象使得程序易于编写,但往往是以难以理解为代价。有时候这是一个很好的折中,但通常不是。大体上,如果能使程序在日后易于理解和调试,我很乐意花更多的时间来写一些东西,因为这样实际上更省时间。 + +简洁并不是让程序易于调试的**唯一**方法,但它也许是最重要的。良好的文档也是,但不幸的是好的文档太少了。(注意,质量并**不**取决于字数!) + +这种影响是真是存在的。难以调试的程序会有更多的 bug,即使最初的 bug 数量与易于调试的程序完全相同,而是因为修复 bug 更加困难、更花时间。 + +在公司的环境中,把时间花在难以修复的 bug 上通常被认为是不划算的投资。而在开源的环境下,人们花的时间会更少。(大多数项目都有一个或多个定期的维护者,但成百上千的贡献者提交的仅只是几个补丁) + +--- + +这并不全是 1974 年由 Brian W. Kernighan 和 P. J. Plauger 合著的《编程风格的元素The Elements of Programming Style》中的观点: + +> 每个人都知道调试比起编写程序困难两倍。当你写程序的时候耍小聪明,那么将来应该怎么去调试? + +我见过许多看起来写起来“极尽精妙”,但却导致难以调试的代码。我会在下面列出几种样例。争论这些东西本身有多坏并不是我的本意,我仅想强调对于“易于使用”和“易于调试”之间的折中。 + +* ORM对象关系映射 库可以让数据库查询变得简单,代价是一旦你想解决某个问题,事情就变得难以理解。 +* 许多测试框架让调试变得困难。Ruby 的 rspec 就是一个很好的例子。有一次我不小心使用错了,结果花了很长时间搞清楚**究竟**哪里出了问题(因为它给出错误提示非常含糊)。 + + 我在《[测试并非万能][1]》这篇文章中写了更多关于以上的例子。 +* 我用过的许多 JavaScript 框架都很难完全理解。Clever(LCTT 译注:一种 JS 框架)的语句一向很有逻辑,直到某条语句不能如你预期的工作,这时你就只能指望 Stack Overflow 上的某篇文章或 GitHub 上的某个回帖来帮助你了。 + + 这些函数库**确实**让任务变得非常简单,使用它们也没有什么错。但通常人们都过于关注“易于使用”而忽视了“易于调试”这一点。 +* Docker 非常棒,并且让许多事情变得非常简单,直到你看到了这条提示: + + ``` + ERROR: for elasticsearch Cannot start service elasticsearch: +oci runtime error: container_linux.go:247: starting container process caused "process_linux.go:258: +applying cgroup configuration for process caused \"failed to write 898 to cgroup.procs: write +/sys/fs/cgroup/cpu,cpuacct/docker/b13312efc203e518e3864fc3f9d00b4561168ebd4d9aad590cc56da610b8dd0e/cgroup.procs: +invalid argument\"" +``` + + 或者这条: + + ``` +ERROR: for elasticsearch Cannot start service elasticsearch: EOF +``` + + 那么...你怎么看? +* `Systemd` 比起 `SysV`、`init.d` 脚本更加简单,因为编写 `systemd` 单元文件比起编写 `shell` 脚本更加方便。这也是 Lennart Poetterin 在他的 [systemd 神话][2] 中解释 `systemd` 为何简单时使用的论点。 + + 我非常赞同 Poettering 的观点——也可以看 [shell 脚本陷阱][3] 这篇文章。但是这种角度并不全面。单元文件简单的背后意味着 `systemd` 作为一个整体要复杂的多,并且用户确实会受到它的影响。看看我遇到的这个[问题][4]和为它所做的[修复][5]。看起来很简单吗? + + +-------------------------------------------------------------------------------- + +via: https://arp242.net/weblog/easy.html + +作者:[Martin Tournoij][a] +选题:[lujun9972][b] +译者:[LuuMing](https://github.com/LuuMing) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://arp242.net/ +[b]: https://github.com/lujun9972 +[1]: https://www.arp242.net/testing.html +[2]: http://0pointer.de/blog/projects/the-biggest-myths.html +[3]:https://www.arp242.net/shell-scripting-trap.html +[4]:https://unix.stackexchange.com/q/185495/33645 +[5]:https://cgit.freedesktop.org/systemd/systemd/commit/?id=6e392c9c45643d106673c6643ac8bf4e65da13c1 diff --git a/published/201912/20190513 How To Set Password Complexity On Linux.md b/published/201912/20190513 How To Set Password Complexity On Linux.md new file mode 100644 index 0000000000..f9dfca1e8e --- /dev/null +++ b/published/201912/20190513 How To Set Password Complexity On Linux.md @@ -0,0 +1,186 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11709-1.html) +[#]: subject: (How To Set Password Complexity On Linux?) +[#]: via: (https://www.2daygeek.com/how-to-set-password-complexity-policy-on-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +Linux 如何设置密码复杂度? +====== + +对于 Linux 系统管理员来说,用户管理是最重要的事之一。这涉及到很多因素,实现强密码策略是用户管理的其中一个方面。移步后面的 URL 查看如何 [在 Linux 上生成一个强密码][1]。它会限制系统未授权的用户的访问。 + +所有人都知道 Linux 的默认策略很安全,然而我们还是要做一些微调,这样才更安全。弱密码有安全隐患,因此,请特别注意。移步后面的 URL 查看生成的强密码的[密码长度和分值][2]。本文将教你在 Linux 中如何实现最安全的策略。 + +在大多数 Linux 系统中,我们可以用 PAM(可插拔认证模块pluggable authentication module)来加强密码策略。在下面的路径可以找到这个文件。 + +- 在红帽系列的系统中,路径:`/etc/pam.d/system-auth`。 +- Debian 系列的系统中,路径:`/etc/pam.d/common-password`。 + +关于默认的密码过期时间,可以在 `/etc/login.defs` 文件中查看详细信息。 + +为了更好理解,我摘取了文件的部分内容: + +``` +# vi /etc/login.defs + +PASS_MAX_DAYS 99999 +PASS_MIN_DAYS 0 +PASS_MIN_LEN 5 +PASS_WARN_AGE 7 +``` + +详细解释: + +* `PASS_MAX_DAYS`:一个密码可使用的最大天数。 +* `PASS_MIN_DAYS`:两次密码修改之间最小的间隔天数。 +* `PASS_MIN_LEN`:密码最小长度。 +* `PASS_WARN_AGE`:密码过期前给出警告的天数。 + +我们将会展示在 Linux 中如何实现下面的 11 个密码策略。 + +* 一个密码可使用的最大天数 +* 两次密码修改之间最小的间隔天数 +* 密码过期前给出警告的天数 +* 密码历史记录/拒绝重复使用密码 +* 密码最小长度 +* 最少的大写字母个数 +* 最少的小写字母个数 +* 最少的数字个数 +* 最少的其他字符(符号)个数 +* 账号锁定 — 重试 +* 账号解锁时间 + +### 密码可使用的最大天数是什么? + +这一参数限制一个密码可使用的最大天数。它强制用户在过期前修改他/她的密码。如果他们忘记修改,那么他们会登录不了系统。他们需要联系管理员才能正常登录。这个参数可以在 `/etc/login.defs` 文件中设置。我把这个参数设置为 90 天。 + +``` +# vi /etc/login.defs + +PASS_MAX_DAYS 90 +``` + +### 密码最小天数是什么? + +这个参数限制两次修改之间的最少天数。举例来说,如果这个参数被设置为 15 天,用户今天修改了密码,那么在 15 天之内他都不能修改密码。这个参数可以在 `/etc/login.defs` 文件中设置。我设置为 15 天。 + +``` +# vi /etc/login.defs + +PASS_MIN_DAYS 15 +``` + +### 密码警告天数是什么? + +这个参数控制密码警告的前置天数,在密码即将过期时会给用户警告提示。在警告天数结束前,用户会收到日常警告提示。这可以提醒用户在密码过期前修改他们的密码,否则我们就需要联系管理员来解锁密码。这个参数可以在 `/etc/login.defs` 文件中设置。我设置为 10 天。 + +``` +# vi /etc/login.defs + +PASS_WARN_AGE 10 +``` + +**注意:** 上面的所有参数仅对新账号有效,对已存在的账号无效。 + +### 密码历史或拒绝重复使用密码是什么? + +这个参数控制密码历史。它记录曾经使用过的密码(禁止使用的曾用密码的个数)。当用户设置新的密码时,它会检查密码历史,如果他们要设置的密码是一个曾经使用过的旧密码,将会发出警告提示。这个参数可以在 `/etc/pam.d/system-auth` 文件中设置。我设置密码历史为 5。 + +``` +# vi /etc/pam.d/system-auth + +password sufficient pam_unix.so md5 shadow nullok try_first_pass use_authtok remember=5 +``` + +### 密码最小长度是什么? + +这个参数表示密码的最小长度。当用户设置新密码时,系统会检查这个参数,如果新设的密码长度小于这个参数设置的值,会收到警告提示。这个参数可以在 `/etc/pam.d/system-auth` 文件中设置。我设置最小密码长度为 12。 + +``` +# vi /etc/pam.d/system-auth + +password requisite pam_cracklib.so try_first_pass retry=3 minlen=12 +``` + +`try_first_pass retry=3`:在密码设置交互界面,用户有 3 次机会重设密码。 + +### 设置最少的大写字母个数? + +这个参数表示密码中至少需要的大写字母的个数。这些是密码强度参数,可以让密码更健壮。当用户设置新密码时,系统会检查这个参数,如果密码中没有大写字母,会收到警告提示。这个参数可以在 `/etc/pam.d/system-auth` 文件中设置。我设置密码(中的大写字母)的最小长度为 1 个字母。 + +``` +# vi /etc/pam.d/system-auth + +password requisite pam_cracklib.so try_first_pass retry=3 minlen=12 ucredit=-1 +``` + +### 设置最少的小写字母个数? + +这个参数表示密码中至少需要的小写字母的个数。这些是密码强度参数,可以让密码更健壮。当用户设置新密码时,系统会检查这个参数,如果密码中没有小写字母,会收到警告提示。这个参数可以在 `/etc/pam.d/system-auth` 文件中设置。我设置为 1 个字母。 + +``` +# vi /etc/pam.d/system-auth + +password requisite pam_cracklib.so try_first_pass retry=3 minlen=12 lcredit=-1 +``` + +### 设置密码中最少的数字个数? + +这个参数表示密码中至少需要的数字的个数。这些是密码强度参数,可以让密码更健壮。当用户设置新密码时,系统会检查这个参数,如果密码中没有数字,会收到警告提示。这个参数可以在 `/etc/pam.d/system-auth` 文件中设置。我设置为 1 个数字。 + +``` +# vi /etc/pam.d/system-auth + +password requisite pam_cracklib.so try_first_pass retry=3 minlen=12 dcredit=-1 +``` + +### 设置密码中最少的其他字符(符号)个数? + +这个参数表示密码中至少需要的特殊符号的个数。这些是密码强度参数,可以让密码更健壮。当用户设置新密码时,系统会检查这个参数,如果密码中没有特殊符号,会收到警告提示。这个参数可以在 `/etc/pam.d/system-auth` 文件中设置。我设置为 1 个字符。 + +``` +# vi /etc/pam.d/system-auth + +password requisite pam_cracklib.so try_first_pass retry=3 minlen=12 ocredit=-1 +``` + +### 设置账号锁定? + +这个参数控制用户连续登录失败的最大次数。当达到设定的连续失败登录次数阈值时,锁定账号。这个参数可以在 `/etc/pam.d/system-auth` 文件中设置。 + +``` +# vi /etc/pam.d/system-auth + +auth required pam_tally2.so onerr=fail audit silent deny=5 +account required pam_tally2.so +``` + +### 设定账号解锁时间? + +这个参数表示用户解锁时间。如果一个用户账号在连续认证失败后被锁定了,当过了设定的解锁时间后,才会解锁。设置被锁定中的账号的解锁时间(900 秒 = 15分钟)。这个参数可以在 `/etc/pam.d/system-auth` 文件中设置。 + +``` +# vi /etc/pam.d/system-auth + +auth required pam_tally2.so onerr=fail audit silent deny=5 unlock_time=900 +account required pam_tally2.so +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-set-password-complexity-policy-on-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/5-ways-to-generate-a-random-strong-password-in-linux-terminal/ +[2]: https://www.2daygeek.com/how-to-check-password-complexity-strength-and-score-in-linux/ diff --git a/published/201912/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md b/published/201912/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md new file mode 100644 index 0000000000..c3c7d5d3bf --- /dev/null +++ b/published/201912/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md @@ -0,0 +1,196 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11631-1.html) +[#]: subject: (How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server) +[#]: via: (https://www.linuxtechi.com/install-lemp-stack-fedora-30-server/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +如何在 Fedora 30 Server 上安装 LEMP(Linux、Nginx、MariaDB、PHP) +====== + +在这篇文章中,我们将看看如何在 Fedora 30 Server 上安装 **LEMP** 。LEMP 代表: + + * L -> Linux + * E -> Nginx + * M -> Maria DB + * P -> PHP + +我假设 [Fedora 30][1] 已经安装在你的电脑系统上。 + +![](https://img.linux.net.cn/data/attachment/album/201912/01/103537wil7hd36dhcxdh03.jpg) + +LEMP 是一组强大的软件设置集合,它安装在一个 Linux 服务器上以帮助使用流行的开发平台来构建网站,LEMP 是 LAMP 的一个变种,在其中不是 Apache ,而是使用 EngineX(Nginx),此外,使用 MariaDB 代替 MySQL。这篇入门指南是一个安装 Nginx、Maria DB 和 PHP 的独立指南的作品集合。 + +### 在 Fedora 30 Server 上安装 Nginx、PHP 7.3 和 PHP-FPM + +让我们看看如何在 Fedora 30 Server 上安装 Nginx 和 PHP 以及 PHP FPM。 + +#### 步骤 1) 切换到 root 用户 + +在系统上安装 Nginx 的第一步是切换到 root 用户。使用下面的命令: + +``` +root@linuxtechi ~]$ sudo -i +[sudo] password for pkumar: +[root@linuxtechi ~]# +``` + +#### 步骤 2) 使用 dnf 命令安装 Nginx、PHP 7.3 和 PHP FPM + +使用下面的 `dnf` 命令安装 Nginx: + +``` +[root@linuxtechi ~]# dnf install nginx php php-fpm php-common -y +``` + +#### 步骤 3) 安装额外的 PHP 模块 + +PHP 的默认安装仅自带基本模块和最需要的模块,如果你需要额外的模块,像 PHP 支持的 GD、XML、命令行接口、Zend OPCache 功能等等,你总是能够选择你的软件包,并一次性安装所有的东西。查看下面的示例命令: + +``` +[root@linuxtechi ~]# sudo dnf install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-pecl-mongodb php-pecl-redis php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml -y +``` + +#### 步骤 4) 开始 & 启用 Nginx 和 PHP-fpm 服务 + +使用下面的命令来开始并启用 Nginx 服务: + +``` +[root@linuxtechi ~]# systemctl start nginx && systemctl enable nginx +Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service. +[root@linuxtechi ~]# +``` + +使用下面的命令来开始并启用 PHP-FPM 服务: + +``` +[root@linuxtechi ~]# systemctl start php-fpm && systemctl enable php-fpm +Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service. +[root@linuxtechi ~]# +``` + +#### 步骤 5) 核实 Nginx (Web 服务) 和 PHP 安装 + +注意:假使操作系统防火墙是启用的,并运行在你的 Fedora 30 系统上,那么使用下面的命令来准许 80 和 443 端口: + +``` +[root@linuxtechi ~]# firewall-cmd --permanent --add-service=http +success +[root@linuxtechi ~]# +[root@linuxtechi ~]# firewall-cmd --permanent --add-service=https +success +[root@linuxtechi ~]# firewall-cmd --reload +success +[root@linuxtechi ~]# +``` + +打开网页浏览器,输入下面的 URL: http:// 。 + +![Test-Page-HTTP-Server-Fedora-30][4] + +上面的屏幕证实 Nginx 已经成功地安装。 + +现在,让我们核实 PHP 安装,使用下面的命令创建一个测试 php 页(`info.php`): + +``` +[root@linuxtechi ~]# echo "" > /usr/share/nginx/html/info.php +[root@linuxtechi ~]# +``` + +在网页浏览器中输入下面的 URL, http:///info.php + +![Php-info-page-fedora30][6] + +上面的页面验证 PHP 7.3.5 已经被成功地安装。现在,让我们安装 MariaDB 数据库服务器。 + +### 在 Fedora 30 上安装 MariaDB + +MariaDB 是 MySQL 数据库的一个极好的替代品,因为它的工作方式与 MySQL 非常类似,并且兼容性也与 MySQL 一致。让我们看看在 Fedora 30 Server 上安装 MariaDB 的步骤。 + +#### 步骤 1) 切换到 root 用户 + +在系统上安装 MariaDB 的第一步是切换到 root 用户,或者你可以使用有 root 权限的本地用户。使用下面的命令: + +``` +[root@linuxtechi ~]# sudo -i +[root@linuxtechi ~]# +``` + +#### 步骤 2) 使用 dnf 命令安装 MariaDB(10.3)的最新版本 + +在 Fedora 30 Server 上使用下面的命令来安装 MariaDB: + +``` +[root@linuxtechi ~]# dnf install mariadb-server -y +``` + +#### 步骤 3) 开启并启用 MariaDB 服务 + +在步骤 2 中成功地安装 MariaDB 后,接下来的步骤是开启 MariaDB 服务。使用下面的命令: + +``` +[root@linuxtechi ~]# systemctl start mariadb.service ; systemctl enable mariadb.service +``` + +#### 步骤 4) 保护安装好的 MariaDB + +当我们安装 MariaDB 服务器时,因为默认情况下没有 root 密码,在数据库中也会创建匿名用户。因此,要保护安装好的 MariaDB,运行下面的 `mysql_secure_installation` 命令: + +``` +[root@linuxtechi ~]# mysql_secure_installation +``` + +接下来你将被提示一些问题,仅回答下面展示的问题: + +![Secure-MariaDB-Installation-Part1][7] + +![Secure-MariaDB-Installation-Part2][8] + +#### 步骤 5) 测试 MariaDB 安装 + +在你安装后,你总是能够测试是否 MariaDB 被成功地安装在 Fedora 30 Server 上。使用下面的命令: + +``` +[root@linuxtechi ~]# mysql -u root -p +Enter password: +``` + +接下来,你将被提示一个密码。输入在保护安装好的 MariaDB 期间你设置的密码,接下来你可以看到 MariaDB 欢迎屏幕。 + +``` +Welcome to the MariaDB monitor. Commands end with ; or \g. +Your MariaDB connection id is 17 +Server version: 10.3.12-MariaDB MariaDB Server + +Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. + +Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. + +MariaDB [(none)]> +``` + +最后,我们已经在你的 Fedora 30 Server 上成功地完成安装 LEMP(Linux、Nginx、MariaDB 和 PHP)的所有工作。请在下面的反馈部分发布你的评论和建议,我们将尽快在后面回应。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/install-lemp-stack-fedora-30-server/ + +作者:[Pradeep Kumar][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://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/fedora-30-workstation-installation-guide/ +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/06/LEMP-Stack-Fedora30.jpg +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Test-Page-HTTP-Server-Fedora-30-1024x732.jpg +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Test-Page-HTTP-Server-Fedora-30.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Php-info-page-fedora30-1024x732.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Php-info-page-fedora30.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Secure-MariaDB-Installation-Part1.jpg +[8]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Secure-MariaDB-Installation-Part2.jpg diff --git a/published/201912/20190711 DevOps for introverted people.md b/published/201912/20190711 DevOps for introverted people.md new file mode 100644 index 0000000000..e18b27da4f --- /dev/null +++ b/published/201912/20190711 DevOps for introverted people.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: (XLCYun) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11725-1.html) +[#]: subject: (DevOps for introverted people) +[#]: via: (https://opensource.com/article/19/7/devops-introverted-people) +[#]: author: (Matthew Broberg https://opensource.com/users/mbbroberg) + +内向者的 DevOps +====== + +> 我们邀请 Opensource.com 的 DevOps 团队,希望他们能够谈一谈作为 DevOps 内向者的休验,同时给 DevOps 外向者一些建议。下面是他们的回答。 + +![](https://img.linux.net.cn/data/attachment/album/201912/29/103642jmzt6t6mggjjx5yt.jpg) + +我们邀请我们的 [DevOps 团队][2] 谈一谈他们作为一个内向者的体验,并给外向者们一些建议。但是在我们开始了解他们的回答之前,让我们先来定义一下这些词汇。 + +### “内向者”是什么意思? + +内向者通常指的是一部分人群,当他们和别人相处的时候,会使他们的能量耗尽,而不是激发他们更多的能量。当我们思考我们是如何恢复能量时,这是一个非常有用的词汇:内向者通常需要更多的独处时间来恢复能量,特别是和一群人在一起很长时间后。关于内向者的一个非常大的误解就是他们一定是“害羞的”,但是科学表明,那不过是另一种不同的性格特征。 + +内向性与外向性是通过 [Myers Briggs 类型指标][4] 而为人所知的,现在也常常被称作一个 [光谱][5] 的两端。虽然这个世界看起来好像外向者比内向者要多,但是心理学者则倾向于认为大部分人在光谱上的位置是落在 [中间性格或偏内向性格的][6]。 + +现在,我们来看看问答。 + +### DevOps 技术主管可以通过哪些方式来让内向者感觉他们是团队的一部分并且愿意分享他们的想法? + +“每个人都会不大一样,所以观察敏锐就很重要了。从 GitLab 过来的一个人告诉我,他们的哲学就是如果他们没有提供任何意见,那么他们就是被排除在外的。如果有人在一个会议上没有提供任何的意见,那就想办法让他们加入进来。**当我知道一个内向者对我们将要讨论的会议论题感兴趣的时候,我会提前请他写一些书面文本。有非常多的会议其实是可以避免的,只要通过把讨论放到 Slack 或者 GitLab 上就行了,内向者会更愿意参与进来**。在站立会议中,每个人都会交代最新的进展,在这个环境下,内向者表现得很好。有时候我们在其实会议上会重复做一些事情,仅仅是为了保证每个人都有时间发言。我同时也会鼓励内向者在工作小组或者社区小组面前发言,以此来锻炼他们的这些技能。”—— 丹·巴克 + +“**我觉得别人对我做的最好的事情,就是他们保证了当重大问题来临的时候,我拥有必要的技能去回答它**。彼时,我作为一名非常年轻的入伍空军的一员,我需要给我们部队的高级领导做状态简报的汇报。我必须在任何时候都有一些可用的数据点,以及在实现我们确立的目标的过程中,产生延误以及偏差的背后的原因。那样的经历推动着我从一个‘幕后人员’逐渐变得更加愿意和别人分享自己的观点和想法。”—— 克里斯·肖特 + +“**通过文化去领导。为你的同僚一起设计和尝试仪式。**你可以为给你的小组或团队设计一个小的每周仪式,甚至给你的部门或组织设计一个年度的大仪式。它的意义在于去尝试一些事物,并观察你在其中的领导角色。去找到你们文化当中的代沟以及对立。回顾团队的信仰和行为。你能从哪里观察到对立?你们的文化中缺失了什么?从一个小陈述开始‘我从 X 和 Y 之间看到了对立’,或者‘我的团队缺少了 Z’。接着,将代沟与对立转换为问题:写下三个‘我们如何能……(How might we's, HMWs)’。”—— 凯瑟琳·路易斯 + +“内向者不是一个不同的群体,他们要么是在分享他们的想法之前想得太多或等得太久的一些人,要么就是一些根本不知道发生了什么的人。我就是第一种,我想太多了,有时候还担心我的意见会被其他人嘲笑,或者没有什么意思,或者想偏了。形成那样的思维方式很难,但它同时也在吞噬着我学习更好事物的机会。有一次,我们团队在讨论一个实现问题。我当时的老大一次又一次地问我,为什么我没有作为团队中更具经验的人参与进来,然后我就(集齐了全宇宙的力量之后)开口说我想说的大家都已经说过了。他说,有时候我可以重复说一次,事情纷繁,如果你能够重复一遍你的想法,即使它已经被讨论过了,也会大有裨益。好吧,虽然它不是一种特别信服的方式,但是我知道了至少有人想听听我怎么说,它给了我一点信心。 + +“现在,我所使用的让团队中的人发言的方法是**我经常向内向的人求助,即使我知道解决方法,并且在团队会议和讨论中感谢他们来建立他们的自信心,通过给他们时间让他们一点一点的从他们寡言的本性中走出来,从而跟团队分享很多的知识**。他们在外面的世界中可能仍然会有一点点孤立,但是在团队里面,有些会成为我们可以信赖的人。”—— 阿布希什克·塔姆拉卡尔 + +“我给参加会议的内向者的建议是,找一个同样要参加会议的朋友或者同事,这样到时你就会有人可以跟你一起舒服地交谈,在会议开始之前,提前跟其他的与会者(朋友、行业联系人、前同事等等)约着见个面或者吃顿饭,**要注意你的疲劳程度,并且照顾好自己**:如果你需要重新恢复能量,就跳过那些社交或者夜晚的活动,在事后回顾中记录一下自己的感受。”—— 伊丽莎白·约瑟夫 + +### 和一个内向者倾向的同事一起工作时,有什么提高生产效率的小建议? + +“在保证质量时,生产效率会越来越具备挑战性。在大多数时候,工作中的一个小憩或者轻松随意的交谈,可能正是我们的创造性活动中需要的一个火花。再说一次,我发现当你的团队中有内向者时, Slack 和 Github 会是一个非常有用的用于交换想法以及和其他人互动的媒介。**我同时也发现,结对编程对于大部分的内向者也非常有用,虽然一对一的交流对于他们来说,并不像交税那么频繁,但是生产质量和效率的提升却是重大的**。但是,当一个内向者在独自工作的时间,团队中的所有人都不应该去打断他们。最好是发个邮件,或者使用没有那么强的侵入性的媒介。”—— 丹·巴克 + +“给他们趁手的工具,让他们工作并归档他们的工作。**让他们能够在他们的工作上做到最好**。要足够经常地去检查一下,保证他们没有走偏路,但是要记住,相比外向者而言,这样做是更大的一种让人分心的困扰。”—— 克里斯·肖特 + +“**当我低着头的时候,不要打断我。真的,别打断我!**当我沉浸在某件事物中时,这样做会造成我至少需要花费两个小时,才能让我的大脑重新回到之前的状态。感觉很痛苦。真的。你可以发个邮件让我去有白板的地方。然后从客户的角度而不是你的角度——通过画图的方式——分享下有什么问题。要知道,可能同时会有十几个客户问题缠绕在我的脑海中,如果你的问题听起来就是‘这样子做会让我在我的领导面前显得很好’的那一类问题,那么相比我脑袋中已经有的真正的客户问题而言,它不会得到更多的关注的。画个图,给我点时间思考。当我准备分享我的看法的时候,保证有多支马克笔可以使用。准备好接受你对问题的假设有可能完全是错误的。”—— 凯瑟琳·路易斯 + +“感谢和鼓励就是解决的方法,感谢可能不是一份工作评估,但是感谢能让人舒服地感受到自己并不仅仅是一个活着的独立实体,**因而每个人都能够感觉到自己是被倾听的,而不是被嘲笑或者低估的**。”—— 阿布希什克·塔姆拉卡尔 + +### 结语 + +在与内向的 DevOps 爱好者的这次交谈中,我们最大的启迪就是平等:其他人需要被怎样对待,就怎样对待他们,同时你想被怎样对待,就去要求别人怎样对待你。无论你是内向还是外向,我们都需要承认我们并非全以相同的一种方式体验这个世界。我们的同事应当被给予足够的空间以完成他们的工作,通过讨论他们的需求作为了解如何支持他们的开始。我们的差异正是我们的社区如此特别的原因,它让我们的工作对更多的人更加的有用。与别人沟通最有效的方式,就是对于你们两者而言都可行的方式。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/devops-introverted-people + +作者:[Matthew Broberg][a] +选题:[lujun9972][b] +译者:[XLCYun](https://github.com/XLCYun) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mbbroberg +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_QandAorange_520x292_0311LL.png?itok=qa3hHSou (Q and A letters) +[2]: https://opensource.com/devops-team +[3]: https://www.inc.com/melanie-curtin/are-you-shy-or-introverted-science-says-this-is-1-primary-difference.html +[4]: https://www.myersbriggs.org/my-mbti-personality-type/mbti-basics/extraversion-or-introversion.htm?bhcp=1 +[5]: https://lifehacker.com/lets-quit-it-with-the-introvert-extrovert-nonsense-1713772952 +[6]: https://www.psychologytoday.com/us/blog/the-gen-y-guide/201710/the-majority-people-are-not-introverts-or-extroverts diff --git a/published/201912/20190725 24 sysadmin job interview questions you should know.md b/published/201912/20190725 24 sysadmin job interview questions you should know.md new file mode 100644 index 0000000000..b2b6f9b812 --- /dev/null +++ b/published/201912/20190725 24 sysadmin job interview questions you should know.md @@ -0,0 +1,235 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11673-1.html) +[#]: subject: (24 sysadmin job interview questions you should know) +[#]: via: (https://opensource.com/article/19/7/sysadmin-job-interview-questions) +[#]: author: (DirectedSoul https://opensource.com/users/directedsoul) + +24 个必知必会的系统管理员面试问题 +====== + +> 即将进行系统管理员工作面试吗?阅读本文,了解你可能会遇到的一些问题以及可能的答案。 + +![](https://img.linux.net.cn/data/attachment/album/201912/14/124906g3vrkr3vrvqdkw7f.jpg) + +作为一个经常与计算机打交道的极客,在硕士毕业后在 IT 行业选择我的职业是很自然的选择。因此,我认为走上系统管理员之路是正确的路径。在我的职业生涯中,我对求职面试过程非常熟悉。现在来看一下对该职位的预期、职业发展道路,以及一系列常见面试问题及我的回答。 + +### 系统管理员的典型任务和职责 + +组织需要了解系统工作原理的人员,以确保数据安全并保持服务平稳运行。你可能会问:“等等,是不是系统管理员还能做更多的事情?” + +你是对的。现在,一般来说,让我们看一下典型的系统管理员的日常任务。根据公司的需求和人员的技能水平,系统管理员的任务从管理台式机、笔记本电脑、网络和服务器到设计组织的 IT 策略不等。有时,系统管理员甚至负责购买和订购新的 IT 设备。 + +那些寻求系统管理工作以作为其职业发展道路的人可能会发现,由于 IT 领域的快速变化是不可避免的,因此难以保持其技能和知识的最新状态。所有人都会想到的下一个自然而然的问题是 IT 专业人员如何掌握最新的更新和技能。 + +### 简单的问题 + +这是你将遇到的一些最基本的问题,以及我的答案: + +**1、你在 \*nix 服务器上登录后键入的前五个命令是什么?** + +> * `lsblk` 以查看所有的块设备信息 +> * `who` 查看谁登录到服务器 +> * `top`,以了解服务器上正在运行的进程 +> * `df -khT` 以查看服务器上可用的磁盘容量 +> * `netstat` 以查看哪些 TCP 网络连接处于活动状态 + +**2、如何使进程在后台运行,这样做的好处是什么?** + +> 你可以通过在命令末尾添加特殊字符 `&` 来使进程在后台运行。通常,执行时间太长并且不需要用户交互的应用程序可以放到后台,以便我们可以在终端中继续工作。([引文][2]) + +**3、以 root 用户身份运行这些命令是好事还是坏事?** + +> 由于两个主要问题,以 root 身份运行(任何命令)是不好的。第一个是*风险*。当你以 **root** 身份登录时,无法避免你由于粗心大意而犯错。如果你尝试以带有潜在危害的方式更改系统,则需要使用 `sudo`,它会引入一个暂停(在你输入密码时),以确保你不会犯错。 +> +> 第二个原因是*安全*。如果你不知道管理员用户的登录信息,则系统更难被攻击。拥有 root 的访问权限意味着你已经能够进行管理员身份下的一半工作任务。 + +**4、`rm` 和 `rm -rf` 有什么区别?** + +> `rm` 命令本身仅删除指明的文件(而不删除目录)。使用 `-rf` 标志,你添加了两个附加功能:`-r`(或等价的 `-R`、`--recursive`)标志可以递归删除目录的内容,包括隐藏的文件和子目录;而 `-f`(或 `--force`)标志使 `rm` 忽略不存在的文件,并且从不提示你进行确认。 + +**5、有一个大小约为 15GB 的 `Compress.tgz` 文件。你如何列出其内容,以及如何仅提取出特定文件?** + +> 要列出文件的内容: +> +> `tar tf archive.tgz` +> +> 要提取特定文件: +> +> `tar xf archive.tgz filename` + +### 有点难度的问题 + +这是你可能会遇到的一些较难的问题,以及我的答案: + +**6、什么是 RAID?什么是 RAID 0、RAID 1、RAID 5、RAID 6 和 RAID 10?** + +> RAID(廉价磁盘冗余阵列Redundant Array of Inexpensive Disks)是一种用于提高数据存储性能和/或可靠性的技术。RAID 级别为: +> +> * RAID 0:也称为磁盘条带化,这是一种分解文件并将数据分布在 RAID 组中所有磁盘驱动器上的技术。它没有防止磁盘失败的保障。([引文][3]) +> * RAID 1:一种流行的磁盘子系统,通过在两个驱动器上写入相同的数据来提高安全性。RAID 1 被称为*镜像*,它不会提高写入性能,但读取性能可能会提高到每个磁盘性能的总和。另外,如果一个驱动器发生故障,则会使用第二个驱动器,发生故障的驱动器需要手动更换。更换后,RAID 控制器会将可工作的驱动器的内容复制到新驱动器上。 +> * RAID 5:一种磁盘子系统,可通过计算奇偶校验数据来提高安全性和提高速度。RAID 5 通过跨三个或更多驱动器交错数据(条带化)来实现此目的。在单个驱动器发生故障时,后续读取可以从分布式奇偶校验计算出,从而不会丢失任何数据。 +> * RAID 6:通过添加另一个奇偶校验块来扩展 RAID 5。此级别至少需要四个磁盘,并且可以在任何两个并发磁盘故障的情况下继续执行读/写操作。RAID 6 不会对读取操作造成性能损失,但由于与奇偶校验计算相关的开销,因此确实会对写入操作造成性能损失。 +> * RAID 10:RAID 10 也称为 RAID 1 + 0,它结合了磁盘镜像和磁盘条带化功能来保护数据。它至少需要四个磁盘,并且跨镜像对对数据进行条带化。只要每个镜像对中的一个磁盘起作用,就可以检索数据。如果同一镜像对中的两个磁盘发生故障,则所有数据将丢失,因为带区集中没有奇偶校验。([引文][4]) + +**7、`ping` 命令使用哪个端口?** + +> `ping` 命令使用 ICMP。具体来说,它使用 ICMP 回显请求和应答包。 +> +> ICMP 不使用 UDP 或 TCP 通信服务:相反,它使用原始的 IP 通信服务。这意味着,ICMP 消息直接承载在 IP 数据报数据字段中。 + +**8、路由器和网关之间有什么区别?什么是默认网关?** + +> *路由器*描述的是一种通用技术功能(第 3 层转发)或用于该目的的硬件设备,而*网关*描述的是本地网段的功能(提供到其他地方的连接性)。你还可以说“将路由器设置为网关”。另一个术语是“跳”,它描述了子网之间的转发。 +> +> 术语*默认网关*表示局域网上的路由器,它的责任是作为对局域网外部的计算机通信的第一个联系点。 + +**9、解释一下 Linux 的引导过程。** + +> BIOS -> 主引导记录(MBR) -> GRUB -> 内核 -> 初始化 -> 运行级 + +**10、服务器启动时如何检查错误消息?** + +> 内核消息始终存储在 kmsg 缓冲区中,可通过 `dmesg` 命令查看。 +> +> 引导出现的问题和错误要求系统管理员结合某些特定命令来查看某些重要文件,这些文件不同版本的 Linux 处理方式不同: +> +> * `/var/log/boot.log` 是系统引导日志,其中包含系统引导过程中展开的所有内容。 +> * `/var/log/messages` 存储全局系统消息,包括系统引导期间记录的消息。 +> * `/var/log/dmesg` 包含内核环形缓冲区信息。 + +**11、符号链接和硬链接有什么区别?** + +> *符号链接*(*软链接*)实际是到原始文件的链接,而*硬链接*是原始文件的镜像副本。如果删除原始文件,则该软链接就没有用了,因为它指向的文件不存在了。如果是硬链接,则完全相反。如果删除原始文件,则硬链接仍然包含原始文件中的数据。([引文][5]) + +**12、如何更改内核参数?你可能需要调整哪些内核选项?** + +> 要在类 Unix 系统中设置内核参数,请首先编辑文件 `/etc/sysctl.conf`。进行更改后,保存文件并运行 `sysctl -p` 命令。此命令使更改永久生效,而无需重新启动计算机 + +**13、解释一下 `/proc` 文件系统。** + +> `/proc` 文件系统是虚拟的,并提供有关内核、硬件和正在运行的进程的详细信息。由于 `/proc` 包含虚拟文件,因此称为“虚拟文件系统”。这些虚拟文件具有独特性。其中大多数显示为零字节。 +> +> 虚拟文件,例如 `/proc/interrupts`、`/proc/meminfo`、`/proc/mounts` 和 `/proc/partitions`,提供了系统硬件的最新信息。其他诸如 `/proc/filesystems` 和 `/proc/sys` 目录提供系统配置信息和接口。 + +**14、如何在没有密码的情况下以其他用户身份运行脚本?** + +> 例如,如果你可以编辑 sudoers 文件(例如 `/private/etc/sudoers`),则可以使用 `visudo` 添加以下[内容][2]: +> +> `user1 ALL =(user2)NOPASSWD:/opt/scripts/bin/generate.sh` + +**15、什么是 UID 0 toor 帐户?是被入侵了么?** + +> `toor` 用户是备用的超级用户帐户,其中 `toor` 是 `root` 反向拼写。它预期与非标准 shell 一起使用,因此 `root` 的默认 shell 不需要更改。 +> +> 此用途很重要。这些 shell 不是基本发行版的一部分,而是从 ports 或软件包安装的,它们安装在 `/usr/local/bin` 中,默认情况下,位于其他文件系统上。如果 root 的 shell 位于 `/usr/local/bin` 中,并且未挂载包含 `/usr/local/bin` 的文件系统,则 root 无法登录以解决问题,并且系统管理员必须重新启动进入单用户模式来输入 shell 程序的路径。 + +### 更难的问题 + +这是你可能会遇到的甚至更困难的问题: + +**16、`tracert` 如何工作,使用什么协议?** + +> 命令 `tracert`(或 `traceroute`,具体取决于操作系统)使你可以准确地看到在连接到最终目的地的连接链条中所触及的路由器。如果你遇到无法连接或无法 `ping` 通最终目的地的问题,则可以使用 `tracert` 来帮助你确定连接链在何处停止。([引文][6]) +> +> 通过此信息,你可以联系正确的人;无论是你自己的防火墙、ISP、目的地的 ISP 还是中间的某个位置。 `tracert` 命令像 `ping` 一样使用 ICMP 协议,但也可以使用 TCP 三步握手的第一步来发送 SYN 请求以进行响应。 + +**17、使用 `chroot` 的主要优点是什么?我们何时以及为什么使用它?在 chroot 环境中,`mount /dev`、`mount /proc` 和 `mount /sys` 命令的作用是什么?** + +> chroot 环境的优点是文件系统与物理主机是隔离的,因为 chroot 在文件系统内部有一个单独的文件系统。区别在于 `chroot` 使用新创建的根目录(`/`)作为其根目录。 +> +> chroot 监狱可让你将进程及其子进程与系统其余部分隔离。它仅应用于不以 root 身份运行的进程,因为 root 用户可以轻松地脱离监狱。 +> +> 该思路是创建一个目录树,在其中复制或链接运行该进程所需的所有系统文件。然后,你可以使用 `chroot()` 系统调用来告诉它根目录现在位于此新树的基点上,然后启动在该 chroot 环境中运行的进程。由于该命令因此而无法引用修改后的根目录之外的路径,因此它无法在这些位置上执行恶意操作(读取、写入等)。([引文][7]) + +**18、如何保护你的系统免遭黑客攻击?** + +> 遵循最低特权原则和这些做法: +> +> * 使用公钥加密,它可提供出色的安全性。 +> * 增强密码复杂性。 +> * 了解为什么要对上述规则设置例外。 +> * 定期检查你的例外情况。 +> * 让具体的人对失败负责。(它使你保持警惕。)([引文][8]) + +**19、什么是 LVM,使用 LVM 有什么好处?** + +> LVM(逻辑卷管理)是一种存储设备管理技术,该技术使用户能够合并和抽象化组件存储设备的物理布局,从而可以更轻松、灵活地进行管理。使用设备映射器的 Linux 内核框架,当前迭代(LVM2)可用于将现有存储设备收集到组中,并根据需要从组合的空间分配逻辑单元。 + +**20、什么是粘性端口?** + +> 粘性端口是网络管理员最好的朋友,也是最头痛的事情之一。它们允许你设置网络,以便通过将交换机上的每个端口锁定到特定的 MAC 地址,仅允许一台(或你指定的数字)计算机在该端口上进行连接。 + +**21、解释一下端口转发?** + +> 尝试与安全的网络内部的系统进行通信时,从外部进行通信可能非常困难,这是很显然的。因此,在路由器本身或其他连接管理设备中使用端口转发表可以使特定流量自动转发到特定目的地。例如,如果你的网络上运行着一台 Web 服务器,并且想从外部授予对该服务器的访问权限,则可以将端口转发设置为该服务器上的端口 80。这意味着在 Web 浏览器中输入你的(外网)IP 地址的任何人都将立即连接到该服务器的网站。 +> +> 请注意,通常不建议允许从你的网络外部直接访问服务器。 + +**22、对于 IDS,误报和漏报是什么?** + +> 当入侵检测系统(IDS)设备为实际上没有发生的入侵生成警报时,这是误报(假阳性)false positive。如果设备未生成任何警报,而入侵实际上已发生,则为漏报(假阴性)。 + +**23、解释一下 `:(){ :|:& };:`,如果已经登录系统,如何停止此代码?** + +> 这是一枚复刻炸弹。它分解如下: +> +> * `:()` 定义了函数,以 `:` 作为函数名,并且空括号表示它不接受任何参数。 +> * `{}` 是函数定义的开始和结束。 +> * `:|:` 将函数 `:` 的副本加载到内存中,并将其输出通过管道传递给函数 `:` 的另一个副本,该副本也必须加载到内存中。 +> * `&` 使前一个命令行成为后台进程,因此即使父进程被自动杀死,子进程也不会被杀死。 +> * `:` 执行该函数,因此连锁反应开始。 +> +> 保护多用户系统的最佳方法是使用特权访问管理(PAM)来限制用户可以使用的进程数。 +> +> 复刻炸弹的最大问题是它发起了太多进程。因此,如果你已经登录系统,我们有两种尝试解决此问题的方法。一种选择是执行一个 `SIGSTOP` 命令来停止进程,例如: +> +> `killall -STOP -u user1` +> +> 如果由于占用了所有进程而无法使用命令行,则必须使用 `exec` 强制其运行: +> +> `exec killall -STOP -u user1` +> +> 对于复刻炸弹,最好的选择是防患于未然。 + +**24、什么是 OOM 杀手,它如何决定首先杀死哪个进程?** + +> 如果内存被进程彻底耗尽,可能会威胁到系统的稳定性,那么内存不足out of memory(OOM)杀手就登场了。 +> +> OOM 杀手首先必须选择要杀死的最佳进程。*最佳*在这里指的是在被杀死时将释放最大内存的进程,并且对系统来说最不重要。主要目标是杀死最少数量的进程,以最大程度地减少造成的损害,同时最大化释放的内存量。 +> +> 为了实现此目标,内核为每个进程维护一个 `oom_score`。你可以在 `/proc` 文件系统中的 `pid` 目录下的看到每个进程的 `oom_score`: +> +> `$ cat /proc/10292/oom_score` +> +> 任何进程的 `oom_score` 值越高,在内存不足的情况下被 OOM 杀手杀死的可能性就越高。([引文][9]) + +### 总结 + +系统管理人员的薪水[差别很大][10],有些网站上说年薪在 70,000 到 100,000 美元之间,具体取决于地点、组织的规模以及你的教育水平以及多年的工作经验。系统管理的职业道路最终归结为你对使用服务器和解决那些酷问题的兴趣。现在,我要说,继续前进,实现你的梦想之路吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/sysadmin-job-interview-questions + +作者:[DirectedSoul][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/directedsoul +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_HowToFish_520x292.png?itok=DHbdxv6H (Question and answer.) +[2]: https://github.com/trimstray/test-your-sysadmin-skills +[3]: https://www.waytoeasylearn.com/2016/05/netapp-filer-tutorial.html +[4]: https://searchstorage.techtarget.com/definition/RAID-10-redundant-array-of-independent-disks +[5]: https://www.answers.com/Q/What_is_hard_link_and_soft_link_in_Linux +[6]: https://www.wisdomjobs.com/e-university/network-administrator-interview-questions.html +[7]: https://unix.stackexchange.com/questions/105/chroot-jail-what-is-it-and-how-do-i-use-it +[8]: https://serverfault.com/questions/391370/how-to-prevent-zero-day-attacks +[9]: https://unix.stackexchange.com/a/153586/8369 +[10]: https://blog.netwrix.com/2018/07/23/systems-administrator-salary-in-2018-how-much-can-you-earn/ diff --git a/published/201912/20190827 curl exercises.md b/published/201912/20190827 curl exercises.md new file mode 100644 index 0000000000..35984c6e31 --- /dev/null +++ b/published/201912/20190827 curl exercises.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (hanwckf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11648-1.html) +[#]: subject: (curl exercises) +[#]: via: (https://jvns.ca/blog/2019/08/27/curl-exercises/) +[#]: author: (Julia Evans https://jvns.ca/) + +21 个 curl 命令练习 +====== + +最近,我对人们如何学习新事物感兴趣。我正在读 Kathy Sierra 的好书《[Badass: Making Users Awesome][1]》,它探讨了有关“刻意练习”的想法。这个想法是,你找到一个可以用三节 45 分钟课程内能够学会的小技能,并专注于学习这项小技能。因此,作为一项练习,我尝试考虑一项能够在三节 45 分钟课程内学会的计算机技能。 + +我认为使用 `curl` 构造 HTTP 请求也许就是这样的一项技能,所以这里有一些 `curl` 练习作为实验! + +### 什么是 curl ? + +`curl` 是用于构造 HTTP 请求的命令行工具。我喜欢使用 `curl`,因为它能够很轻松地测试服务器或 API 的行为是否符合预期,但是刚开始接触它的时候会让你感到一些困惑! + +下面是一幅解释 `curl` 常用命令行参数的漫画 (在我的 [Bite Size Networking][2] 杂志的第 6 页)。 + +![](https://jvns.ca/images/curl.jpeg) + +### 熟能生巧 + +对于任何命令行工具,我认为熟练使用是很有帮助的,能够做到只输入必要的命令真是太好了。例如,最近我在测试 Gumroad API,我只需要输入: + +``` +curl https://api.gumroad.com/v2/sales \ + -d "access_token=" \ + -X GET -d "before=2016-09-03" +``` + +就能从命令行中得到想要的结果。 + +### 21 个 curl 练习 + +这些练习是用来理解如何使用 `curl` 构造不同种类的 HTTP 请求的,它们是故意有点重复的,基本上包含了我需要 `curl` 做的任何事情。 + +为了简单起见,我们将对 https://httpbin.org 发起一系列 HTTP 请求,httpbin 接受 HTTP 请求,然后在响应中回显你所发起的 HTTP 请求。 + + 1. 请求 + 2. 请求 ,它将会解析你发起的请求,并且在响应中回显。`curl` 默认发起的是 GET 请求 + 3. 向 发起 GET 请求 + 4. 向 发起 GET 请求,但是这次需要添加一些查询参数(设置 `value=panda`) + 5. 请求 Google 的 `robots.txt` 文件 ([www.google.com/robots.txt][3]) + 6. 向 发起 GET 请求,并且设置请求头为 `User-Agent: elephant` + 7. 向 发起 DELETE 请求 + 8. 请求 并获取响应头信息 + 9. 向 发起请求体为 JSON `{"value": "panda"}` 的 POST 请求 + 10. 发起与上一次相同的 POST 请求,但是这次要把请求头中的 `Content-Type` 字段设置成 `application/json`(因为 POST 请求需要一个与请求体相匹配的 `Content-Type` 请求头字段)。查看响应体中的 `json` 字段,对比上一次得到的响应体 + 11. 向 发起 GET 请求,并且在请求头中设置 `Accept-Encoding: gzip`(将会发生什么?为什么会这样?) + 12. 将一些 JSON 放在文件中,然后向 发起请求体为该文件的 POST 请求 + 13. 设置请求头为 `Accept: image/png` 并且向 发起请求,将输出保存为 PNG 文件,然后使用图片浏览器打开。尝试使用不同的 `Accept:` 字段去请求此 URL + 14. 向 发起 PUT 请求 + 15. 请求 并保存为文件,然后使用你的图片编辑器打开这个文件 + 16. 请求 ,你将会得到空的响应。让 `curl` 显示出响应头信息,并尝试找出响应内容为空的原因 + 17. 向 发起任意的请求,同时设置一些无意义的请求头(例如:`panda: elephant`) + 18. 请求 ,然后再次请求它们并且让 curl 显示响应头信息 + 19. 请求 并且设置用户名和密码(使用 `-u username:password`) + 20. 设置 `Accept-Language: es-ES` 的请求头用以下载 Twitter 的西班牙语主页 () + 21. 使用 `curl` 向 Stripe API 发起请求(请查看 了解如何使用,他们会给你一个测试用的 API key)。尝试向 发起相同的请求 + + + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/08/27/curl-exercises/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[hanwckf](https://github.com/hanwckf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://www.amazon.com/Badass-Making-Awesome-Kathy-Sierra/dp/1491919019 +[2]: https://wizardzines.com/zines/bite-size-networking +[3]: http://www.google.com/robots.txt diff --git a/published/201912/20190927 5 tips for GNU Debugger.md b/published/201912/20190927 5 tips for GNU Debugger.md new file mode 100644 index 0000000000..9bb6329a4b --- /dev/null +++ b/published/201912/20190927 5 tips for GNU Debugger.md @@ -0,0 +1,220 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11647-1.html) +[#]: subject: (5 tips for GNU Debugger) +[#]: via: (https://opensource.com/article/19/9/tips-gnu-debugger) +[#]: author: (Tim Waugh https://opensource.com/users/twaugh) + +5 个鲜为人知 GNU 调试器(GDB)技巧 +====== + +> 了解如何使用 gdb 的一些鲜为人知的功能来检查和修复代码。 + +![](https://img.linux.net.cn/data/attachment/album/201912/05/203701ss8onfvpsnvnsnn5.jpg) + +[GNU 调试器][2](`gdb`)是一种宝贵的工具,可用于在开发程序时检查正在运行的进程并解决问题。 + +你可以在特定位置(按函数名称、行号等)设置断点、启用和禁用这些断点、显示和更改变量值,并执行所有调试器希望执行的所有标准操作。但是它还有许多其它你可能没有尝试过的功能。这里有五个你可以尝试一下。 + +### 条件断点 + +设置断点是学习使用 GNU 调试器的第一步。程序在达到断点时停止,你可以运行 `gdb` 的命令对其进行检查或更改变量,然后再允许该程序继续运行。 + +例如,你可能知道一个经常调用的函数有时会崩溃,但仅当它获得某个参数值时才会崩溃。你可以在该函数的开始处设置一个断点并运行程序。每次碰到该断点时都会显示函数参数,并且如果未提供触发崩溃的参数值,则可以继续操作,直到再次调用该函数为止。当这个惹了麻烦的参数触发崩溃时,你可以单步执行代码以查看问题所在。 + + +``` +(gdb) break sometimes_crashes +Breakpoint 1 at 0x40110e: file prog.c, line 5. +(gdb) run +[...] +Breakpoint 1, sometimes_crashes (f=0x7fffffffd1bc) at prog.c:5 +5 fprintf(stderr, +(gdb) continue +Breakpoint 1, sometimes_crashes (f=0x7fffffffd1bc) at prog.c:5 +5 fprintf(stderr, +(gdb) continue +``` + +为了使此方法更具可重复性,你可以在你感兴趣的特定调用之前计算该函数被调用的次数,并在该断点处设置一个计数器(例如,`continue 30` 以使其在接下来的 29 次到达该断点时忽略它)。 + +但是断点真正强大的地方在于它们在运行时评估表达式的能力,这使你可以自动化这种测试。 + +``` +break [LOCATION] if CONDITION + +(gdb) break sometimes_crashes if !f +Breakpoint 1 at 0x401132: file prog.c, line 5. +(gdb) run +[...] +Breakpoint 1, sometimes_crashes (f=0x0) at prog.c:5 +5 fprintf(stderr, +(gdb) +``` + +条件断点使你不必让 `gdb` 每次调用该函数时都去问你要做什么,而是让条件断点仅在特定表达式的值为 `true` 时才使 `gdb` 停止在该位置。如果执行到达条件断点的位置,但表达式的计算结果为 `false`,调试器会自动使程序继续运行,而无需询问用户该怎么做。 + +### 断点命令 + +GNU 调试器中断点的一个甚至更复杂的功能是能够编写对到达断点的响应的脚本。断点命令使你可以编写一系列 GNU 调试器命令,以在到达该断点时运行。 + +我们可以使用它来规避在 `sometimes_crashes` 函数中我们已知的错误,并在它提供空指针时使其无害地从该函数返回。 + +我们可以使用 `silent` 作为第一行,以更好地控制输出。否则,每次命中断点时,即使在运行断点命令之前,也会显示堆栈帧。 + +``` +(gdb) break sometimes_crashes +Breakpoint 1 at 0x401132: file prog.c, line 5. +(gdb) commands 1 +Type commands for breakpoint(s) 1, one per line. +End with a line saying just "end". +>silent +>if !f + >frame + >printf "Skipping call\n" + >return 0 + >continue + >end +>printf "Continuing\n" +>continue +>end +(gdb) run +Starting program: /home/twaugh/Documents/GDB/prog +warning: Loadable section ".note.gnu.property" outside of ELF segments +Continuing +Continuing +Continuing +#0 sometimes_crashes (f=0x0) at prog.c:5 +5 fprintf(stderr, +Skipping call +[Inferior 1 (process 9373) exited normally] +(gdb) +``` + +### 转储二进制内存 + +GNU 调试器内置支持使用 `x` 命令以各种格式检查内存,包括八进制、十六进制等。但是我喜欢并排看到两种格式:左侧为十六进制字节,右侧为相同字节表示的 ASCII 字符。 + +当我想逐字节查看文件的内容时,经常使用 `hexdump -C`(`hexdump` 来自 [util-linux][3] 软件包)。这是 `gdb` 的 `x` 命令显示的十六进制字节: + +``` +(gdb) x/33xb mydata +0x404040 : 0x02 0x01 0x00 0x02 0x00 0x00 0x00 0x01 +0x404048 : 0x01 0x47 0x00 0x12 0x61 0x74 0x74 0x72 +0x404050 : 0x69 0x62 0x75 0x74 0x65 0x73 0x2d 0x63 +0x404058 : 0x68 0x61 0x72 0x73 0x65 0x75 0x00 0x05 +0x404060 : 0x00 +``` + +如果你想让 `gdb` 像 `hexdump` 一样显示内存怎么办?这是可以的,实际上,你可以将这种方法用于你喜欢的任何格式。 + +通过使用 `dump` 命令以将字节存储在文件中,结合 `shell` 命令以在文件上运行 `hexdump` 以及`define` 命令,我们可以创建自己的新的 `hexdump` 命令来使用 `hexdump` 显示内存内容。 + +``` +(gdb) define hexdump +Type commands for definition of "hexdump". +End with a line saying just "end". +>dump binary memory /tmp/dump.bin $arg0 $arg0+$arg1 +>shell hexdump -C /tmp/dump.bin +>end +``` + +这些命令甚至可以放在 `~/.gdbinit` 文件中,以永久定义 `hexdump` 命令。以下是它运行的例子: + +``` +(gdb) hexdump mydata sizeof(mydata) +00000000 02 01 00 02 00 00 00 01 01 47 00 12 61 74 74 72 |.........G..attr| +00000010 69 62 75 74 65 73 2d 63 68 61 72 73 65 75 00 05 |ibutes-charseu..| +00000020 00 |.| +00000021 +``` + +### 行内反汇编 + +有时你想更多地了解导致崩溃的原因,而源代码还不够。你想查看在 CPU 指令级别发生了什么。 + +`disassemble` 命令可让你查看实现函数的 CPU 指令。但是有时输出可能很难跟踪。通常,我想查看与该函数源代码的特定部分相对应的指令。为此,请使用 `/s` 修饰符在反汇编中包括源代码行。 + +``` +(gdb) disassemble/s main +Dump of assembler code for function main: +prog.c: +11 { + 0x0000000000401158 <+0>: push %rbp + 0x0000000000401159 <+1>: mov %rsp,%rbp + 0x000000000040115c <+4>: sub $0x10,%rsp + +12 int n = 0; + 0x0000000000401160 <+8>: movl $0x0,-0x4(%rbp) + +13 sometimes_crashes(&n); + 0x0000000000401167 <+15>: lea -0x4(%rbp),%rax + 0x000000000040116b <+19>: mov %rax,%rdi + 0x000000000040116e <+22>: callq 0x401126 +[...snipped...] +``` + +这里,用 `info` 寄存器查看所有 CPU 寄存器的当前值,以及用如 `stepi` 这样命令一次执行一条指令,可以使你对程序有了更详细的了解。 + +### 反向调试 + +有时,你希望自己可以逆转时间。想象一下,你已经达到了变量的监视点。监视点像是一个断点,但不是在程序中的某个位置设置,而是在表达式上设置(使用 `watch` 命令)。每当表达式的值更改时,执行就会停止,并且调试器将获得控制权。 + +想象一下你已经达到了这个监视点,并且由该变量使用的内存已更改了值。事实证明,这可能是由更早发生的事情引起的。例如,内存已释放,现在正在重新使用。但是它是何时何地被释放的呢? + +GNU 调试器甚至可以解决此问题,因为你可以反向运行程序! + +它通过在每个步骤中仔细记录程序的状态来实现此目的,以便可以恢复以前记录的状态,从而产生时间倒流的错觉。 + +要启用此状态记录,请使用 `target record-full` 命令。然后,你可以使用一些听起来不太可行的命令,例如: + +* `reverse-step`,倒退到上一个源代码行 +* `*reverse-next`,它倒退到上一个源代码行,向后跳过函数调用 +* `reverse-finish`,倒退到当前函数即将被调用的时刻 +* `reverse-continue`,它返回到程序中的先前状态,该状态将(现在)触发断点(或其他导致断点停止的状态) + +这是运行中的反向调试的示例: + +``` +(gdb) b main +Breakpoint 1 at 0x401160: file prog.c, line 12. +(gdb) r +Starting program: /home/twaugh/Documents/GDB/prog +[...] + +Breakpoint 1, main () at prog.c:12 +12 int n = 0; +(gdb) target record-full +(gdb) c +Continuing. + +Program received signal SIGSEGV, Segmentation fault. +0x0000000000401154 in sometimes_crashes (f=0x0) at prog.c:7 +7 return *f; +(gdb) reverse-finish +Run back to call of #0 0x0000000000401154 in sometimes_crashes (f=0x0) + at prog.c:7 +0x0000000000401190 in main () at prog.c:16 +16 sometimes_crashes(0); +``` + +这些只是 GNU 调试器可以做的一些有用的事情。还有更多有待发现。你最喜欢 `gdb` 的哪个隐藏的、鲜为人知或令人吃惊的功能?请在评论中分享。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/9/tips-gnu-debugger + +作者:[Tim Waugh][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/twaugh +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bug_software_issue_tracking_computer_screen.jpg?itok=6qfIHR5y (Bug tracking magnifying glass on computer screen) +[2]: https://www.gnu.org/software/gdb/ +[3]: https://en.wikipedia.org/wiki/Util-linux diff --git a/published/201912/20191004 What-s in an open source name.md b/published/201912/20191004 What-s in an open source name.md new file mode 100644 index 0000000000..2b6d45c599 --- /dev/null +++ b/published/201912/20191004 What-s in an open source name.md @@ -0,0 +1,200 @@ +[#]: collector: (lujun9972) +[#]: translator: (laingke) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11688-1.html) +[#]: subject: (What's in an open source name?) +[#]: via: (https://opensource.com/article/19/10/open-source-name-origins) +[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja) + +开源软件名称中的故事 +====== + +> 有没有想过你喜欢的开源项目或编程语言的名称来自何处?让我们按字母顺序了解一下流行的技术术语背后的起源故事。 + +![](https://img.linux.net.cn/data/attachment/album/201912/17/225902ogkk85zm4gqlim9h.jpg) + +GNOME、Java、Jupyter、Python……如果你的朋友或家人曾留意过你的工作对话,他们可能会认为你从事文艺复兴时期的民间文学艺术、咖啡烘焙、天文学或动物学工作。这些开源技术的名称从何而来?我们请我们的作者社区提供意见,并汇总了一些我们最喜欢的技术名称的起源故事。 + +### Ansible + +“Ansible”这个名称直接来自科幻小说。Ursula Le Guin 的《Rocannon's World》一书中能进行即时(比光速更快)通信的设备被称为 ansibles(显然来自 “answerable” 一词)。Ansibles 开始流行于科幻小说之中,Orson Scott Card 的《Ender's Game》(后来成为受欢迎的电影)中,该设备控制了许多远程太空飞船。对于控制分布式机器的软件来说,这似乎是一个很好的模型,因此 Michael DeHaan(Ansible 的创建者和创始人)借用了这个名称。 + +### Apache + +[Apache][2] 是最初于 1995 年发布的开源 Web 服务器。它的名称与著名的美国原住民部落无关;相反,它是指对原始软件代码的重复补丁。因此称之为,“一个修补的A-patchy服务器”。 + +### awk + +“awk(1) 代表着 Aho、Weinberger、Kernighan(作者)”—— Michael Greenberg + +### Bash + +“最初的 Unix shell,即 Bourne shell,是以其创造者的名字命名的。在开发出来 Bash 时,csh(发音为 ‘seashell’)实际上更受交互登录用户的欢迎。Bash 项目旨在赋予 Bourne shell 新的生命,使其更适合于交互式使用,因此它被命名为 ‘Bourne again shell’,是‘重生born again’的双关语。”——Ken Gaillot + +### C + +在早期,AT&T 的 Ken Thompson 和 Dennis Ritchie 发现可以使用更高级的编程语言(而不是低级的、可移植性更低的汇编编程)来编写操作系统和工具。早期有一个叫做 BCPL(基本组合编程语言Basic Combined programming Language)的编程系统,Thompson 创建了一个名为 B 的简化版 BCPL,但 B 的灵活性和速度都不高。然后,Ritchie 把 B 的思想扩展成一种叫做 C 的编译语言。”——Jim Hall + +### dd + +“我想你发表这样一篇文章不能不提到 dd。我的外号叫 Didi。发音正确的话听起来像 ‘dd’。我开始学的是 Unix,然后是 Linux,那是在 1993 年,当时我还是个学生。然后我去了军队,来到了我的部队中少数几个使用 Unix(Ultrix)的部门之一(其它部门主要是 VMS),那里的一个人说:‘这么说,你是一个黑客,对吗?你以为你了解 Unix 吗?好的,那么 dd 这个名字的是怎么来的呢?’我不知道,试着猜道:‘数据复印机Data duplicator?’所以他说,‘我要告诉你 dd 的故事。dd 是转换convert复制copy的缩写(如今人们仍然可以在手册页中看到),但由于 cc 这个缩写已经被 C 编译器占用,所以它被命名为 dd。’就在几年后,我听闻了关于 JCL 的数据定义和 Unix dd 命令不统一的、半开玩笑的语法的真实故事,某种程度是基于此的。”——Yedidyah Bar David + +### Emacs + +经典的反 vianti-vi编辑器,其名称的真正词源并不明显,因为它源自“编辑宏Editing MACroS”。但是,它作为一个伟大的宗教亵渎和崇拜的对象,吸引了许多恶作剧般的缩写,例如“Escape Meta Alt Control Shift”(以调侃其对键盘的大量依赖),“8MB 并经常发生内存交换Eight Megabytes And Constantly Swapping”(从那时起就很吃内存了),“最终分配了所有的计算机存储空间Eventually malloc()s All Computer Storage”和 “EMACS 使一台计算机慢EMACS Makes A Computer Slow”——改编自 Jargon File/Hacker's Dictionary + +### Enarx + +[Enarx][3] 是机密计算领域的一个新项目。该项目的设计原则之一是它应该是“可替代的”。因此最初的名字是“psilocybin”(著名的魔术蘑菇)。一般情况下,经理级别的人可能会对这个名称有所抵触,因此考虑使用新名称。该项目的两位创始人 Mike Bursell 和 Nathaniel McCallum 都是古老语言极客,因此他们考虑了许多不同的想法,包括 тайна(Tayna——俄语中代表秘密或神秘——虽然俄语并不是一门古老的语言,但你就不要在乎这些细节了),crypticon(希腊语的意思是完全私生的),cryptidion(希腊中表示小密室),arconus(拉丁语中表示秘密的褒义形容词),arcanum(拉丁语中表示秘密的中性形容词)和 ærn(盎格鲁撒克逊人表示地方、秘密的地方、壁橱、住所、房子,或小屋的词汇)。最后,由于各种原因,包括域名和 GitHub 项目名称的可用性,他们选择了 enarx,这是两个拉丁词根的组合:en-(表示内部)和 -arx(表示城堡、要塞或堡垒)。 + +### GIMP + +没有 [GIMP][4] 我们会怎么样?GNU 图像处理项目GNU Image Manipulation Project多年来一直是开源的重要基础。[维基百科][5]指出,“1995 年,[Spencer Kimball][6] 和 [Peter Mattis][7] 在加州大学伯克利分校开始为实验计算设施eXperimental Computing Facility开发 GIMP,这是一个为期一个学期的项目。” + +### GNOME + +你有没有想过为什么 GNOME 被称为 GNOME?根据[维基百科][8],GNOME 最初是一个表示“GNU 网络对象模型环境GNU Network Object Model Environment”的缩写词。现在,该名称不再表示该项目,并且该项目已被放弃,但这个名称仍然保留了下来。[GNOME 3][9] 是 Fedora、红帽企业版、Ubuntu、Debian、SUSE Linux 企业版等发行版的默认桌面环境。 + +### Java + +你能想象这种编程语言还有其它名称吗?Java 最初被称为 Oak,但是遗憾的是,Sun Microsystems 的法律团队由于已有该商标而否决了它。所以开发团队又重新给它命名。[据说][10]该语言的工作组在 1995 年 1 月举行了一次大规模的头脑风暴。许多其它名称也被扔掉了,包括 Silk、DNA、WebDancer 等。该团队不希望新名称与过度使用的术语“web”或“net”有任何关系。取而代之的是,他们在寻找更有活力、更有趣、更容易记住的东西。Java 满足了这些要求,并且奇迹般地,团队同意通过了! + +### Jupyter + +现在许多数据科学家和学生在工作中使用 [Jupyter][11] 笔记本。“Jupyter”这个名字是三种开源计算机语言的融合,这三种语言在这个笔记本中都有使用,在数据科学中也很突出:[Julia][12]、[Python][13] 和 [R][14]。 + +### Kubernetes + +Kubernetes 源自希腊语中的舵手。Kubernetes 项目创始人 Craig McLuckie 在 [2015 Hacker News][15] 回应中证实了这种词源。他坚持航海主题,解释说,这项技术可以驱动集装箱,就像舵手或驾驶员驾驶集装箱船一样,因此,他选择了 Kubernetes 这个名字。我们中的许多人仍然在尝试正确的发音(koo-bur-NET-eez),因此 替代使用 K8s 也是可以接受的。有趣的是,它与英语单词“行政长官governor”具有相同的词源,也与蒸汽机上的机械负反馈装置相同。 + +### KDE + +那 K 桌面呢?KDE 最初代表“酷桌面环境Kool Desktop Environment”。 它由 [Matthias Ettrich][16] 于 1996 年创立。根据[维基百科][17]上的说法,该名称是对 Unix 上 [通用桌面环境][18]Common Desktop Environment(CDE)一词的调侃。 + +### Linux + +[Linux][19] 因其发明者 Linus Torvalds 的名字命名的。Linus 最初想将他的作品命名为“Freax”,因为他认为以他自己的名字命名太自负了。根据[维基百科][19]的说法,“赫尔辛基科技大学 Torvalds 的同事 Ari Lemmke 当时是 FTP 服务器的志愿管理员之一,他并不认为‘Freax’是个好名字。因此,他没有征询 Torvalds 就将服务器上的这个项目命名为‘Linux’。” + +以下是一些最受欢迎的 Linux 发行版。 + +#### CentOS + +[CentOS][20] 是社区企业操作系统Community Enterprise Operating System的缩写。它包含来自 Red Hat Enterprise Linux 的上游软件包。 + +#### Debian + +[Debian][21] Linux 创建于 1993 年 9 月,是其创始人 Ian Murdock 和他当时的女友 Debra Lynn 的名字的混成词。 + +#### RHEL + +[Red Hat Linux][22] 得名于它的创始人 Marc Ewing,他戴着一顶祖父送给他的康奈尔大学红色软呢帽fedora。红帽公司成立于 1993 年 3 月 26 日。[Fedora Linux][23] 最初是一个志愿者项目,旨在为红帽发行版提供额外的软件,它的名字来自红帽的“Shadowman”徽标。 + +#### Ubuntu + +[Ubuntu][24] 旨在广泛分享开源软件,它以非洲哲学“人的本质ubuntu”命名,可以翻译为“对他人的人道主义”或“我之所以是我,是因为我们都是这样的人”。 + +### Moodle + +开源学习平台 [Moodle][25] 是“模块化面向对象动态学习环境modular object-oriented dynamic learning environment”的首字母缩写。Moodle 仍然是领先的线上学习平台。全球有近 10.4 万个注册的 Moodle 网站。 + +另外两个流行的开源内容管理系统是 Drupal 和 Joomla。Drupal 的名字来自荷兰语 “druppel”,意思是“掉落”。根据维基百科,Joomla 是斯瓦希里语单词“jumla”的[英式拼写][26],在阿拉伯语、乌尔都语和其他语言中是“在一起”的意思。 + +### Mozilla + +[Mozilla][27] 是一个成立于 1998 年的开源软件社区。根据其网站,“Mozilla 项目创建于 1998 年,发布了 Netscape 浏览器套件源代码。其旨在利用互联网上成千上万的程序员的创造力,并推动浏览器市场上前所未有的创新水平。” 这个名字是 [Mosaic] [28] 和 Godzilla 的混成词。 + +### Nginx + +“许多技术人员都试图装酷,并将它念成‘n’‘g’‘n’‘x’。实际上,很少的一些人做点基本的调查工作,就可以很快发现该名称实际上应该被念成是“EngineX”,指的是功能强大的 web 服务器,像个引擎。”——Jean Sebastien Tougne + +### Perl + +Perl 的创始人 Larry Wall 最初将他的项目命名为“Pearl”。根据维基百科,Wall 想给这种语言起一个有积极含义的简短名字。在 Perl 正式发布之前,Wall 发现了已有 [PEARL][29] 编程语言,于是更改了名称的拼写。 + +### Piet 和 Mondrian + +“有两种编程语言以艺术家 Piet Mondrian 命名。一种叫做‘Piet’,另一种叫做‘Mondrian’。(David Morgan-Mar [写道][30]):‘Piet 是一种编程语言,其中的程序看起来像抽象绘画。该语言以几何抽象艺术的开创者 Piet Mondrian 的名字命名。我曾想将这种语言命名为 Mondrian,但是有人告诉我这会让它看起来像一种很普通的脚本语言。哦,好吧,我想我们不能都是深奥的语言作家。’”——Yuval Lifshitz + +### Python + +Python 编程语言的独特名称来自其创建者 Guido Van Rossum,他是英国六人喜剧团体 Monty Python 的粉丝。 + +### Raspberry Pi + +Raspberry Pi 以其微小但强大的功能和对低廉的价格而闻名,在开源社区中是最受欢迎的。但是它可爱(和好吃)的名字是从哪里来的呢?在 70 年代和 80 年代,以水果命名的计算机是一种流行的趋势。苹果、橘子、杏……有人饿了吗?根据创始人 Eben Upton 的 [2012 采访] [31],“树莓派Raspberry Pi”这个名称是对这种趋势的致敬。树莓也很小,但却很有味道。名称中的“Pi”暗示着这样的事实:最初,该计算机只能运行 Python。 + +### Samba + +[Server Message Block][32] 用于在 Linux 上共享 Windows 文件。 + +### ScummVM + +[ScummVM][33](《疯狂大楼》虚拟机的脚本创建实用程序)是一个程序,可以在现代计算机上运行一些经典的计算机冒险游戏。最初,它旨在玩用 SCUMM 构建的 LucasArts 的冒险游戏,该游戏最初用于开发《疯狂大楼》,后来又被用来开发 LucasArts 的其它大多数冒险游戏。目前,ScummVM 支持大量游戏引擎,包括 Sierra Online 的 AGI 和 SCI,但仍保留着名称 ScummVM。 + +有一个相关的项目 [ResidualVM][34] 之所以得名,是因为它涵盖了 ScummVM 未涵盖的“剩余的residual” LucasArts 冒险游戏。 ResidualVM 涵盖的 LucasArts 游戏是使用 GrimE(Grim Engine)开发的,该引擎最初用于开发 Grim Fandango,因此 ResidualVM 的名称是双关语。 + +### SQL + +“你可能知道 SQL 代表结构化查询语言Structured Query Language,但你知道为什么它经常被读作‘sequel’吗?它是作为原本的‘QUEL’(查询语言QUEry Language)的后续(如结局sequel)而创建的。”——Ken Gaillot + +### XFCE + +[XFCE][35] 是由 [Olivier Fourdan][36] 创建的一个流行的桌面。它在 1996 年作为 CDE 的替代品出现,最初是 XForms 公共环境XForms Common Environment的缩写。 + +### Zsh + +Zsh 是一个交互式登录 shell。1990 年,普林斯顿大学的学生 Paul Falstad 写了该 shell 的第一个版本。他在看到当时在普林斯顿大学担任助教的 Zhong Sha 的登录 ID(zsh)后,觉得这个名字听起来像 [shell 的好名字][37],给它起了这个名字。 + +还有更多的项目和名称还没有包括在这个列表中。请一定要在评论中分享你的收藏。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/open-source-name-origins + +作者:[Joshua Allen Holm][a] +选题:[lujun9972][b] +译者:[laingke](https://github.com/laingke) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/holmja +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareers_resume_rh1x.png?itok=S3HGxi6E (A person writing.) +[2]: https://httpd.apache.org/ +[3]: https://enarx.io +[4]: https://www.gimp.org/ +[5]: https://en.wikipedia.org/wiki/GIMP +[6]: https://en.wikipedia.org/wiki/Spencer_Kimball_(computer_programmer) +[7]: https://en.wikipedia.org/wiki/Peter_Mattis +[8]: https://en.wikipedia.org/wiki/GNOME +[9]: https://www.gnome.org/gnome-3/ +[10]: https://www.javaworld.com/article/2077265/so-why-did-they-decide-to-call-it-java-.html +[11]: https://jupyter.org/ +[12]: https://julialang.org/ +[13]: https://www.python.org/ +[14]: https://www.r-project.org/ +[15]: https://news.ycombinator.com/item?id=9653797 +[16]: https://en.wikipedia.org/wiki/Matthias_Ettrich +[17]: https://en.wikipedia.org/wiki/KDE +[18]: https://sourceforge.net/projects/cdesktopenv/ +[19]: https://en.wikipedia.org/wiki/Linux +[20]: https://www.centos.org/ +[21]: https://www.debian.org/ +[22]: https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux +[23]: https://getfedora.org/ +[24]: https://ubuntu.com/about +[25]: https://moodle.org/ +[26]: https://en.wikipedia.org/wiki/Joomla#Historical_background +[27]: https://www.mozilla.org/en-US/ +[28]: https://en.wikipedia.org/wiki/Mosaic_(web_browser) +[29]: https://en.wikipedia.org/wiki/PEARL_(programming_language) +[30]: http://www.dangermouse.net/esoteric/piet.html +[31]: https://www.techspot.com/article/531-eben-upton-interview/ +[32]: https://www.samba.org/ +[33]: https://www.scummvm.org/ +[34]: https://www.residualvm.org/ +[35]: https://www.xfce.org/ +[36]: https://en.wikipedia.org/wiki/Olivier_Fourdan +[37]: http://www.zsh.org/mla/users/2005/msg00951.html diff --git a/published/201912/20191007 Using the Java Persistence API.md b/published/201912/20191007 Using the Java Persistence API.md new file mode 100644 index 0000000000..8f5c20d3cc --- /dev/null +++ b/published/201912/20191007 Using the Java Persistence API.md @@ -0,0 +1,265 @@ +[#]: collector: (lujun9972) +[#]: translator: (runningwater) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11717-1.html) +[#]: subject: (Using the Java Persistence API) +[#]: via: (https://opensource.com/article/19/10/using-java-persistence-api) +[#]: author: (Stephon Brown https://opensource.com/users/stephb) + +使用 Java 持久化 API +====== + +> 我们通过为自行车商店构建示例应用程序来学习如何使用 JPA。 + +![](https://img.linux.net.cn/data/attachment/album/201912/27/000705dymv92hnba2a2322.jpg) + +对应用开发者来说,Java 持久化 APIJava Persistence API(JPA)是一项重要的 java 功能,需要透彻理解。它为 Java 开发人员定义了如何将对象的方法调用转换为访问、持久化及管理存储在 NoSQL 和关系型数据库中的数据的方案。 + +本文通过构建自行车借贷服务的教程示例来详细研究 JPA。此示例会使用 Spring Boot 框架、MongoDB 数据库([已经不开源][2])和 Maven 包管理来构建一个大型应用程序,并且构建一个创建、读取、更新和删除(CRUD)层。这儿我选择 NetBeans 11 作为我的 IDE。 + +此教程仅从开源的角度来介绍 Java 持久化 API 的工作原理,不涉及其作为工具的使用说明。这全是关于编写应用程序模式的学习,但对于理解具体的软件实现也很益处。可以从我的 [GitHub 仓库][3]来获取相关代码。 + +### Java: 不仅仅是“豆子” + +Java 是一门面向对象的编程语言,自 1996 年发布第一版 Java 开发工具(JDK)起,已经变化了很多很多。要了解其各种发展及其虚拟机本身就是一堂历史课。简而言之,和 Linux 内核很相似,自发布以来,该语言已经向多个方向分支发展。有对社区免费的标准版本、有针对企业的企业版本及由多家供应商提供的开源替代品。主要版本每六个月发布一次,其功能往往差异很大,所以确认选用版本前得先做些研究。 + +总而言之,Java 的历史很悠久。本教程重点介绍 Java 11 的开源实现 [JDK 11][4]。因其是仍然有效的长期支持版本之一。 + + * **Spring Boot** 是由 Pivotal 公司开发的大型 Spring 框架的一个模块。Spring 是 Java 开发中一个非常流行的框架。它支持各种框架和配置,也为 WEB 应用程序及安全提供了保障。Spring Boot 为快速构建各种类型的 Java 项目提供了基本的配置。本教程使用 Spring Boot 来快速编写控制台应用程序并针对数据库编写测试用例。 + * **Maven** 是由 Apache 开发的项目/包管理工具。Maven 通过 `POM.xml` 文件来管理包及其依赖项。如果你使用过 NPM 的话,可能会非常熟悉包管理器的功能。此外 Maven 也用来进行项目构建及生成功能报告。 + * **Lombok** 是一个库,它通过在对象文件里面添加注解来自动创建 getters/setters 方法。像 C# 这些语言已经实现了此功能,Lombok 只是把此功能引入 Java 语言而已。 + * **NetBeans** 是一款很流行的开源 IDE,专门用于 Java 开发。它的许多工具都随着 Java SE 和 EE 的版本更新而更新。 + +我们会用这组工具为一个虚构自行车商店创建一个简单的应用程序。会实现对 `Customer` 和 `Bike` 对象集合的的插入操作。 + +### 酿造完美 + +导航到 [Spring Initializr][5] 页面。该网站可以生成基于 Spring Boot 和其依赖项的基本项目。选择以下选项: + + 1. **项目:** Maven 工程 + 2. **语言:** Java + 3. **Spring Boot:** 2.1.8(或最稳定版本) + 4. **项目元数据:** 无论你使用什么名字,其命名约定都是像 `com.stephb` 这样的。 + * 你可以保留 Artifact 名字为 “Demo”。 + 5. **依赖项:** 添加: + * Spring Data MongoDB + * Lombok + +点击 **下载**,然后用你的 IDE(例如 NetBeans) 打开此新项目。 + +#### 模型层概要 + +在项目里面,模型model代表从数据库里取出的信息的具体对象。我们关注两个对象:`Customer` 和 `Bike`。首先,在 `src` 目录创建 `dto` 目录;然后,创建两个名为 `Customer.java` 和 `Bike.java` 的 Java 类对象文件。其结构如下示: + +```Java +package com.stephb.JavaMongo.dto; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.data.annotation.Id; + +/** + * + * @author stephon + */ +@Getter @Setter +public class Customer { + + private @Id String id; + private String emailAddress; + private String firstName; + private String lastName; + private String address; + +} +``` + +*Customer.Java* + +```Java +package com.stephb.JavaMongo.dto; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.data.annotation.Id; + +/** + * + * @author stephon + */ +@Getter @Setter +public class Bike { + private @Id String id; + private String modelNumber; + private String color; + private String description; + + @Override + public String toString() { + return "This bike model is " + this.modelNumber + " is the color " + this.color + " and is " + description; + } +} +``` + +*Bike.java* + +如你所见,对象中使用 Lombok 注解来为定义的属性properties/特性attributes生成 getters/setters 方法。如果你不想对该类的所有特性都生成 getters/setters 方法,可以在属性上专门定义这些注解。这两个类会变成容器,里面携带有数据,无论在何处想显示信息都可以使用。 + +#### 配置数据库 + +我使用 [Mongo Docker][7] 容器来进行此次测试。如果你的系统上已经安装了 MongoDB,则不必运行 Docker 实例。你也可以登录其官网,选择系统信息,然后按照安装说明来安装 MongoDB。 + +安装后,就可以使用命令行、GUI(例如 MongoDB Compass)或用于连接数据源的 IDE 驱动程序来与新的 MongoDB 服务器进行交互。到目前为止,可以开始定义数据层了,用来拉取、转换和持久化数据。需要设置数据库访问属性,请导航到程序中的 `applications.properties` 文件,然后添加如下内容: + +``` +spring.data.mongodb.host=localhost +spring.data.mongodb.port=27017 +spring.data.mongodb.database=BikeStore +``` + +#### 定义数据访问对象/数据访问层 + +数据访问层data access layer(DAL)中的数据访问对象data access objects(DAO)定义了与数据库中的数据的交互过程。令人惊叹的就是在使用 `spring-boot-starter` 后,查询数据库的大部分工作已经完成。 + +让我们从 `Customer` DAO 开始。在 `src` 下的新目录 `dao` 中创建一个接口文件,然后再创建一个名为 `CustomerRepository.java` 的 Java 类文件,其内容如下示: + +``` +package com.stephb.JavaMongo.dao; + +import com.stephb.JavaMongo.dto.Customer; +import java.util.List; +import org.springframework.data.mongodb.repository.MongoRepository; + +/** + * + * @author stephon + */ +public interface CustomerRepository extends MongoRepository{ + @Override + public List findAll(); + public List findByFirstName(String firstName); + public List findByLastName(String lastName); +} +``` + +这个类是一个接口,扩展或继承于 `MongoRepository` 类,而 `MongoRepository` 类依赖于 DTO (`Customer.java`)和一个字符串,它们用来实现自定义函数查询功能。因为你已继承自此类,所以你可以访问许多方法函数,这些函数允许持久化和查询对象,而无需实现或引用自己定义的方法函数。例如,在实例化 `CustomerRepository` 对象后,你就可以直接使用 `Save` 函数。如果你需要扩展更多的功能,也可以重写这些函数。我创建了一些自定义查询来搜索我的集合,这些集合对象是我自定义的元素。 + +`Bike` 对象也有一个存储源负责与数据库交互。与 `CustomerRepository` 的实现非常类似。其实现如下所示: + +``` +package com.stephb.JavaMongo.dao; + +import com.stephb.JavaMongo.dto.Bike; +import java.util.List; +import org.springframework.data.mongodb.repository.MongoRepository; + +/** + * + * @author stephon + */ +public interface BikeRepository extends MongoRepository{ + public Bike findByModelNumber(String modelNumber); + @Override + public List findAll(); + public List findByColor(String color); +} +``` + +#### 运行程序 + +现在,你已经有了一种结构化数据的方式,可以对数据进行提取、转换和持久化,然后运行这个程序。 + +找到 `Application.java` 文件(有可能不是此名称,具体取决于你的应用程序名称,但都会包含有 “application” )。在定义此类的地方,在后面加上 `implements CommandLineRunner`。这将允许你实现 `run` 方法来创建命令行应用程序。重写 `CommandLineRunner` 接口提供的 `run` 方法,并包含如下内容用来测试 `BikeRepository` : + +``` +package com.stephb.JavaMongo; + +import com.stephb.JavaMongo.dao.BikeRepository; +import com.stephb.JavaMongo.dao.CustomerRepository; +import com.stephb.JavaMongo.dto.Bike; +import java.util.Scanner; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +@SpringBootApplication +public class JavaMongoApplication implements CommandLineRunner { + @Autowired + private BikeRepository bikeRepo; + private CustomerRepository custRepo; + + public static void main(String[] args) { + SpringApplication.run(JavaMongoApplication.class, args); + } + @Override + public void run(String... args) throws Exception { + Scanner scan = new Scanner(System.in); + String response = ""; + boolean running = true; + while(running){ + System.out.println("What would you like to create? \n C: The Customer \n B: Bike? \n X:Close"); + response = scan.nextLine(); + if ("B".equals(response.toUpperCase())) { + String[] bikeInformation = new String[3]; + System.out.println("Enter the information for the Bike"); + System.out.println("Model Number"); + bikeInformation[0] = scan.nextLine(); + System.out.println("Color"); + bikeInformation[1] = scan.nextLine(); + System.out.println("Description"); + bikeInformation[2] = scan.nextLine(); + + Bike bike = new Bike(); + bike.setModelNumber(bikeInformation[0]); + bike.setColor(bikeInformation[1]); + bike.setDescription(bikeInformation[2]); + + bike = bikeRepo.save(bike); + System.out.println(bike.toString()); + + + } else if ("X".equals(response.toUpperCase())) { + System.out.println("Bye"); + running = false; + } else { + System.out.println("Sorry nothing else works right now!"); + } + } + + } +} +``` + +其中的 `@Autowired` 注解会自动依赖注入 `BikeRepository` 和 `CustomerRepository` Bean。我们将使用这些类来从数据库持久化和采集数据。 + +已经好了。你已经创建了一个命令行应用程序。该应用程序连接到数据库,并且能够以最少的代码执行 CRUD 操作 + +### 结论 + +从诸如对象和类之类的编程语言概念转换为用于在数据库中存储、检索或更改数据的调用对于构建应用程序至关重要。Java 持久化 API(JPA)正是为 Java 开发人员解决这一难题的重要工具。你正在使用 Java 操纵哪些数据库呢?请在评论中分享。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/using-java-persistence-api + +作者:[Stephon Brown][a] +选题:[lujun9972][b] +译者:[runningwater](https://github.com/runningwater) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/stephb +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/java-coffee-beans.jpg?itok=3hkjX5We (Coffee beans) +[2]: https://www.techrepublic.com/article/mongodb-ceo-tells-hard-truths-about-commercial-open-source/ +[3]: https://github.com/StephonBrown/SpringMongoJava +[4]: https://openjdk.java.net/projects/jdk/11/ +[5]: https://start.spring.io/ +[6]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string +[7]: https://hub.docker.com/_/mongo +[8]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+exception +[9]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system diff --git a/published/201912/20191017 How to type emoji on Linux.md b/published/201912/20191017 How to type emoji on Linux.md new file mode 100644 index 0000000000..7c11e45b76 --- /dev/null +++ b/published/201912/20191017 How to type emoji on Linux.md @@ -0,0 +1,140 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11702-1.html) +[#]: subject: (How to type emoji on Linux) +[#]: via: (https://opensource.com/article/19/10/how-type-emoji-linux) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何在 Linux 系统中输入 emoji +====== + +> 使用 GNOME 桌面可以让你在文字中轻松加入 emoji。 + +![](https://img.linux.net.cn/data/attachment/album/201912/22/003829tsuogoonoxunn33o.jpg) + +emoji 是潜藏在 Unicode 字符空间里的有趣表情图,它们已经风靡于整个互联网。emoji 可以用来在社交媒体上表示自己的心情状态,也可以作为重要文件名的视觉标签,总之它们的各种用法层出不穷。在 Linux 系统中有很多种方式可以输入 Unicode 字符,但 GNOME 桌面能让你更轻松地查找和输入 emoji。 + +![Emoji in Emacs][2] + +### 准备工作 + +首先,你需要一个运行 [GNOME][3] 桌面的 Linux 系统。 + +同时还需要安装一款支持 emoji 的字体。符合这个要求的字体有很多,使用你喜欢的软件包管理器直接搜索 `emoji` 并选择一款安装就可以了。 + +例如在 Fedora 上: + +``` +$ sudo dnf search emoji +emoji-picker.noarch : An emoji selection tool +unicode-emoji.noarch : Unicode Emoji Data Files +eosrei-emojione-fonts.noarch : A color emoji font +twitter-twemoji-fonts.noarch : Twitter Emoji for everyone +google-android-emoji-fonts.noarch : Android Emoji font released by Google +google-noto-emoji-fonts.noarch : Google “Noto Emoji” Black-and-White emoji font +google-noto-emoji-color-fonts.noarch : Google “Noto Color Emoji” colored emoji font +[...] +``` + +对于 Ubuntu 或者 Debian,需要使用 `apt search`。 + +在这篇文章中,我会使用 [Google Noto Color Emoji][4] 这款字体为例。 + +### 设置 + +要开始设置,首先打开 GNOME 的设置面板。 + +1、在左边侧栏中,选择“地区与语言Region & Language”类别。 + +2、点击“输入源Input Sources”选项下方的加号(+)打开“添加输入源Add an Input Source”面板。 + +![Add a new input source][5] + +3、在“添加输入源Add an Input Source”面板中,点击底部的菜单按钮。 + +![Add an Input Source panel][6] + +4、滑动到列表底部并选择“其它Other”。 + +5、在“其它Other”列表中,找到“其它Other快速输入Typing Booster)”。 + +![Find Other \(Typing Booster\) in inputs][7] + +6、点击右上角的“添加Add”按钮,将输入源添加到 GNOME 桌面。 + +以上操作完成之后,就可以关闭设置面板了。 + +#### 切换到快速输入 + +现在 GNOME 桌面的右上角会出现一个新的图标,一般情况下是当前语言的双字母缩写(例如英语是 en,世界语是 eo,西班牙语是 es,等等)。如果你按下了超级键Super key(也就是键盘上带有 Linux 企鹅/Windows 徽标/Mac Command 标志的键)+ 空格键的组合键,就会切换到输入列表中的下一个输入源。在这里,我们只有两个输入源,也就是默认语言和快速输入。 + +你可以尝试使用一下这个组合键,观察图标的变化。 + +#### 配置快速输入 + +在快速输入模式下,点击右上角的输入源图标,选择“Unicode 符号和 emoji 联想Unicode symbols and emoji predictions”选项,设置为“On”。 + +![Set Unicode symbols and emoji predictions to On][8] + +现在快速输入模式已经可以输入 emoji 了。这正是我们现在所需要的,当然快速输入模式的功能也并不止于此。 + +### 输入 emoji + +在快速输入模式下,打开一个文本编辑器,或者网页浏览器,又或者是任意一种支持输入 Unicode 字符的软件,输入“thumbs up”,快速输入模式就会帮你迅速匹配的 emoji 了。 + +![Typing Booster searching for emojis][9] + +要退出 emoji 模式,只需要再次使用超级键+空格键的组合键,输入源就会切换回你的默认输入语言。 + +### 使用其它切换方式 + +如果你觉得“超级键+空格键”这个组合用起来不顺手,你也可以换成其它键的组合。在 GNOME 设置面板中选择“设备Device”→“键盘Keyboard”。 + +在“键盘Keyboard”页面中,将“切换到下一个输入源Switch to next input source”更改为你喜欢的组合键。 + +![Changing keystroke combination in GNOME settings][10] + +### 输入 Unicode + +实际上,现代键盘的设计只是为了输入 26 个字母以及尽可能多的数字和符号。但 ASCII 字符的数量已经比键盘上能看到的字符多得多了,遑论上百万个 Unicode 字符。因此,如果你想要在 Linux 应用程序中输入 Unicode,但又不想使用快速输入,你可以尝试一下 Unicode 输入。 + +1. 打开任意一种支持输入 Unicode 字符的软件,但仍然使用你的默认输入语言 +2. 使用 `Ctrl+Shift+U` 组合键进入 Unicode 输入模式 +3. 在 Unicode 输入模式下,只需要输入某个 Unicode 字符的对应序号,就实现了对这个 Unicode 字符的输入。例如 `1F44D` 对应的是 👍,而 `2620` 则对应了 ☠。想要查看所有 Unicode 字符的对应序号,可以参考 [Unicode 规范][11]。 + +### emoji 的实用性 + +emoji 可以让你的文本变得与众不同,这就是它们有趣和富有表现力的体现。同时 emoji 也有很强的实用性,因为它们本质上是 Unicode 字符,在很多支持自定义字体的地方都可以用到它们,而且跟使用其它常规字符没有什么太大的差别。因此,你可以使用 emoji 来对不同的文件做标记,在搜索的时候就可以使用 emoji 把这些文件快速筛选出来。 + +![Labeling a file with emoji][12] + +你可以在 Linux 中尽情地使用 emoji,因为 Linux 是一个对 Unicode 友好的环境,未来也会对 Unicode 有着越来越好的支持。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/how-type-emoji-linux + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-lead_cat-keyboard.png?itok=fuNmiGV- "A cat under a keyboard." +[2]: https://opensource.com/sites/default/files/uploads/emacs-emoji.jpg "Emoji in Emacs" +[3]: https://www.gnome.org/ +[4]: https://www.google.com/get/noto/help/emoji/ +[5]: https://opensource.com/sites/default/files/uploads/gnome-setting-region-add.png "Add a new input source" +[6]: https://opensource.com/sites/default/files/uploads/gnome-setting-input-list.png "Add an Input Source panel" +[7]: https://opensource.com/sites/default/files/uploads/gnome-setting-input-other-typing-booster.png "Find Other (Typing Booster) in inputs" +[8]: https://opensource.com/sites/default/files/uploads/emoji-input-on.jpg "Set Unicode symbols and emoji predictions to On" +[9]: https://opensource.com/sites/default/files/uploads/emoji-input.jpg "Typing Booster searching for emojis" +[10]: https://opensource.com/sites/default/files/uploads/gnome-setting-keyboard-switch-input.jpg "Changing keystroke combination in GNOME settings" +[11]: http://unicode.org/emoji/charts/full-emoji-list.html +[12]: https://opensource.com/sites/default/files/uploads/file-label.png "Labeling a file with emoji" + diff --git a/published/201912/20191017 Using multitail on Linux.md b/published/201912/20191017 Using multitail on Linux.md new file mode 100644 index 0000000000..0d8870c9fc --- /dev/null +++ b/published/201912/20191017 Using multitail on Linux.md @@ -0,0 +1,118 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11643-1.html) +[#]: subject: (Using multitail on Linux) +[#]: via: (https://www.networkworld.com/article/3445228/using-multitail-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +在 Linux 上使用 Multitail +====== + +![](https://img.linux.net.cn/data/attachment/album/201912/05/053423mpnrn95hqqknzheq.jpg) + +当你想同时查看多个文件(尤其是日志文件)的活动时,`multitail` 命令会非常有用。它的工作方式类似于多窗口形式的 `tail -f` 命令。也就是说,它显示这些文件的底部和添加的新行。虽然通常使用简单,但是 `multitail` 提供了一些命令行和交互式选项,在开始使用它之前,你应该了解它们。 + +### 基本 multitail 使用 + +`multitail` 的最简单用法是在命令行中列出你要查看的文件名称。此命令水平分割屏幕(即顶部和底部),并显示每个文件的底部以及更新。 + +``` +$ multitail /var/log/syslog /var/log/dmesg +``` + +显示内容将像这样拆分: + +``` ++-----------------------+ +| | +| | ++-----------------------| +| | +| | ++-----------------------+ +``` + +每个文件都有一行显示该文件的文件编号(从 00 开始)、文件名、文件大小、最新内容的添加日期和时间。每个文件将被分配一半空间,而不论它的大小和活动情况。比如: + +``` +content lines from my1.log +more content +more lines + +00] my1.log 59KB - 2019/10/14 12:12:09 +content lines from my2.log +more content +more lines + +01] my2.log 120KB - 2019/10/14 14:22:29 +``` + +请注意,如果你要求 `multitail` 显示非文本文件或者你无权查看的文件,它不会报错。你只是看不到内容。 + +你还可以使用通配符指定要查看的文件: + +``` +$ multitail my*.log +``` + +要记住的一件事是,`multitail` 将平均分割屏幕。如果指定的文件太多,那么除非你采取额外的步骤查看之后的文件(参考下面的滚动选项),否则你将只会看到前面 7 个文件的前面几行。确切的结果取决于终端窗口中有多少行可用。 + +按 `q` 退出 `multitail` 并返回到正常的屏幕视图。 + +### 分割屏幕 + +如果你愿意,`multitail` 也可以垂直分割你的终端窗口(即,左和右)。为此,请使用 `-s` 选项。如果指定了三个文件,那么屏幕右侧的窗口将会水平分隔。四个文件的话,你将拥有四个大小相等的窗口。 + +``` ++-----------+-----------+ +-----------+-----------+ +-----------+-----------+ +| | | | | | | | | +| | | | | | | | | +| | | | +-----------+ +-----------+-----------+ +| | | | | | | | | +| | | | | | | | | ++-----------+-----------+ +-----------+-----------+ +-----------+-----------+ + 2 个文件 3 个文件 4 个文件 +``` + +如果要将屏幕分为三列,请使用 `multitail -s 3 file1 file2 file3`。 + +``` ++-------+-------+-------+ +| | | | +| | | | +| | | | +| | | | +| | | | ++-------+-------+-------+ + 3 个文件带上 -s 3 选项 +``` + +### 滚动 + +你可以上下滚动文件,但是需要按下 `b` 弹出选择菜单,然后使用向上和向下箭头按钮选择要滚动浏览的文件。然后按下回车键。然后,你可以再次使用向上和向下箭头在放大的区域中滚动浏览各行。完成后按下 `q` 返回正常视图。 + +### 获得帮助 + +在 `multitail` 中按下 `h` 将打开一个帮助菜单,其中描述了一些基本操作,但是手册页提供了更多信息,如果莫想了解更多有关使用此工具的信息,请仔细阅读。 + +默认情况下,你的系统上不会安装 `multitail`,但是使用 `apt-get` 或 `yum` 可以使你轻松安装。该工具提供了许多功能,不过它是基于字符显示的,窗口边框只是 `q` 和 `x` 的字符串组成的。当你需要关注文件更新时,它非常方便。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3445228/using-multitail-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.flickr.com/photos/glenbowman/7992498919/in/photolist-dbgDtv-gHfRRz-5uRM4v-gHgFnz-6sPqTZ-5uaP7H-USFPqD-pbtRUe-fiKiYn-nmgWL2-pQNepR-q68p8d-dDsUxw-dbgFKG-nmgE6m-DHyqM-nCKA4L-2d7uFqH-Kbqzk-8EwKg-8Vy72g-2X3NSN-78Bv84-buKWXF-aeM4ok-yhweWf-4vwpyX-9hu8nq-9zCoti-v5nzP5-23fL48r-24y6pGS-JhWDof-6zF75k-24y6nHS-9hr19c-Gueh6G-Guei7u-GuegFy-24y6oX5-26qu5iX-wKrnMW-Gueikf-24y6oYh-27y4wwA-x4z19F-x57yP4-24BY6gc-24y6nPo-QGwbkf +[2]: https://creativecommons.org/licenses/by-sa/2.0/legalcode +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/201912/20191020 14 SCP Command Examples to Securely Transfer Files in Linux.md b/published/201912/20191020 14 SCP Command Examples to Securely Transfer Files in Linux.md new file mode 100644 index 0000000000..9fafdca9cf --- /dev/null +++ b/published/201912/20191020 14 SCP Command Examples to Securely Transfer Files in Linux.md @@ -0,0 +1,245 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11669-1.html) +[#]: subject: (14 SCP Command Examples to Securely Transfer Files in Linux) +[#]: via: (https://www.linuxtechi.com/scp-command-examples-in-linux/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +在 Linux 上安全传输文件的 14 SCP 命令示例 +====== + +![](https://img.linux.net.cn/data/attachment/album/201912/13/100239f31is1ios31vvoo3.jpg) + +SCP(安全复制Secure Copy)是 Linux 和 Unix 之类的系统中的命令行工具,用于通过网络安全地跨系统传输文件和目录。当我们使用 `scp` 命令将文件和目录从本地系统复制到远程系统时,则在后端与远程系统建立了 ssh 连接。换句话说,我们可以说 `scp` 在后端使用了相同的 SSH 安全机制,它需要密码或密钥进行身份验证。 + +![scp-command-examples-linux][2] + +在本教程中,我们将讨论 14 个有用的 Linux `scp` 命令示例。 + +`scp` 命令语法: + +``` +# scp <选项> <文件或目录> 用户名@目标主机:/<文件夹> + +# scp <选项> 用户名@目标主机:/文件 <本地文件夹> +``` + +`scp` 命令的第一个语法演示了如何将文件或目录从本地系统复制到特定文件夹下的目标主机。 + +`scp` 命令的第二种语法演示了如何将目标主机中的文件复制到本地系统中。 + +下面列出了 `scp` 命令中使用最广泛的一些选项, + +* `-C` 启用压缩 +* `-i` 指定识别文件或私钥 +* `-l` 复制时限制带宽 +* `-P` 指定目标主机的 ssh 端口号 +* `-p` 复制时保留文件的权限、模式和访问时间 +* `-q` 禁止 SSH 警告消息 +* `-r` 递归复制文件和目录 +* `-v` 详细输出 + +现在让我们跳入示例! + +### 示例:1)使用 scp 将文件从本地系统复制到远程系统 + +假设我们要使用 `scp` 命令将 jdk 的 rpm 软件包从本地 Linux 系统复制到远程系统(172.20.10.8),请使用以下命令, + +``` +[root@linuxtechi ~]$ scp jdk-linux-x64_bin.rpm root@linuxtechi:/opt +root@linuxtechi's password: +jdk-linux-x64_bin.rpm 100% 10MB 27.1MB/s 00:00 +[root@linuxtechi ~]$ +``` + +上面的命令会将 jdk 的 rpm 软件包文件复制到 `/opt` 文件夹下的远程系统。 + +### 示例:2)使用 scp 将文件从远程系统复制到本地系统 + +假设我们想将文件从远程系统复制到本地系统下的 `/tmp` 文件夹,执行以下 `scp` 命令, + +``` +[root@linuxtechi ~]$ scp root@linuxtechi:/root/Technical-Doc-RHS.odt /tmp +root@linuxtechi's password: +Technical-Doc-RHS.odt 100% 1109KB 31.8MB/s 00:00 +[root@linuxtechi ~]$ ls -l /tmp/Technical-Doc-RHS.odt +-rwx------. 1 pkumar pkumar 1135521 Oct 19 11:12 /tmp/Technical-Doc-RHS.odt +[root@linuxtechi ~]$ +``` + +### 示例:3)使用 scp 传输文件时的详细输出(-v) + +在 `scp` 命令中,我们可以使用 `-v` 选项启用详细输出。使用详细输出,我们可以轻松地发现后台确切发生了什么。这对于调试连接、认证和配置等问题非常有用。 + +``` +root@linuxtechi ~]$ scp -v jdk-linux-x64_bin.rpm root@linuxtechi:/opt +Executing: program /usr/bin/ssh host 172.20.10.8, user root, command scp -v -t /opt +OpenSSH_7.8p1, OpenSSL 1.1.1 FIPS 11 Sep 2018 +debug1: Reading configuration data /etc/ssh/ssh_config +debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf +debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config +debug1: /etc/ssh/ssh_config.d/05-redhat.conf line 8: Applying options for * +debug1: Connecting to 172.20.10.8 [172.20.10.8] port 22. +debug1: Connection established. +………… +debug1: Next authentication method: password +root@linuxtechi's password: +``` + +### 示例:4)将多个文件传输到远程系统 + +可以使用 `scp` 命令一次性将多个文件复制/传输到远程系统,在 `scp` 命令中指定多个文件,并用空格隔开,示例如下所示 + +``` +[root@linuxtechi ~]$ scp install.txt index.html jdk-linux-x64_bin.rpm root@linuxtechi:/mnt +root@linuxtechi's password: +install.txt 100% 0 0.0KB/s 00:00 +index.html 100% 85KB 7.2MB/s 00:00 +jdk-linux-x64_bin.rpm 100% 10MB 25.3MB/s 00:00 +[root@linuxtechi ~]$ +``` + +### 示例:5)在两个远程主机之间传输文件 + +使用 `scp` 命令,我们可以在两个远程主机之间复制文件和目录,假设我们有一个可以连接到两个远程 Linux 系统的本地 Linux 系统,因此从我的本地 Linux 系统中,我可以使用 `scp` 命令在这两个系统之间复制文件, + +命令语法: + +``` +# scp 用户名@远程主机1:/<要传输的文件> 用户名@远程主机2:/<文件夹> +``` + +示例如下: + +``` +# scp root@linuxtechi:~/backup-Oct.zip root@linuxtechi:/tmp +# ssh root@linuxtechi "ls -l /tmp/backup-Oct.zip" +-rwx------. 1 root root 747438080 Oct 19 12:02 /tmp/backup-Oct.zip +``` + +### 示例:6)递归复制文件和目录(-r) + +在 `scp` 命令中使用 `-r` 选项将整个目录从一个系统递归地复制到另一个系统,示例如下所示: + +``` +[root@linuxtechi ~]$ scp -r Downloads root@linuxtechi:/opt +``` + +使用以下命令验证 `Downloads` 文件夹是否已复制到远程系统, + +``` +[root@linuxtechi ~]$ ssh root@linuxtechi "ls -ld /opt/Downloads" +drwxr-xr-x. 2 root root 75 Oct 19 12:10 /opt/Downloads +[root@linuxtechi ~]$ +``` + +### 示例:7)通过启用压缩来提高传输速度(-C) + +在 `scp` 命令中,我们可以通过使用 `-C` 选项启用压缩来提高传输速度,它将自动在源主机上启用压缩并在目标主机上解压缩。 + +``` +root@linuxtechi ~]$ scp -r -C Downloads root@linuxtechi:/mnt +``` + +在以上示例中,我们正在启用压缩的情况下传输下载目录。 + +### 示例:8)复制时限制带宽(-l) + +在 `scp` 命令中使用 `-l` 选项设置复制时对带宽使用的限制。带宽以 Kbit/s 为单位指定,示例如下所示: + +``` +[root@linuxtechi ~]$ scp -l 500 jdk-linux-x64_bin.rpm root@linuxtechi:/var +``` + +### 示例:9)在 scp 时指定其他 ssh 端口(-P) + +在某些情况下,目标主机上的 ssh 端口会更改,因此在使用 `scp` 命令时,我们可以使用 `-P` 选项指定 ssh 端口号。 + +``` +[root@linuxtechi ~]$ scp -P 2022 jdk-linux-x64_bin.rpm root@linuxtechi:/var +``` + +在上面的示例中,远程主机的 ssh 端口为 “2022”。 + +### 示例:10)复制时保留文件的权限、模式和访问时间(-p) + +从源复制到目标时,在 `scp` 命令中使用 `-p` 选项保留权限、访问时间和模式。 + +``` +[root@linuxtechi ~]$ scp -p jdk-linux-x64_bin.rpm root@linuxtechi:/var/tmp +jdk-linux-x64_bin.rpm 100% 10MB 13.5MB/s 00:00 +[root@linuxtechi ~]$ +``` + +### 示例:11)在 scp 中以安静模式传输文件(-q) + +在 `scp` 命令中使用 `-q` 选项可禁止显示 ssh 的传输进度、警告和诊断消息。示例如下所示: + +``` +[root@linuxtechi ~]$ scp -q -r Downloads root@linuxtechi:/var/tmp +[root@linuxtechi ~]$ +``` + +### 示例:12)在传输时使用 scp 中的识别文件(-i) + +在大多数 Linux 环境中,首选基于密钥的身份验证。在 `scp` 命令中,我们使用 `-i` 选项指定识别文件(私钥文件),示例如下所示: + +``` +[root@linuxtechi ~]$ scp -i my_key.pem -r Downloads root@linuxtechi:/root +``` + +在上面的示例中,`my_key.pem` 是识别文件或私钥文件。 + +### 示例:13)在 scp 中使用其他 ssh_config 文件(-F) + +在某些情况下,你使用不同的网络连接到 Linux 系统,可能某些网络位于代理服务器后面,因此在这种情况下,我们必须具有不同的 `ssh_config` 文件。 + +通过 `-F` 选项在 `scp` 命令中指定了不同的 `ssh_config` 文件,示例如下所示: + +``` +[root@linuxtechi ~]$ scp -F /home/pkumar/new_ssh_config -r Downloads root@linuxtechi:/root +root@linuxtechi's password: +jdk-linux-x64_bin.rpm 100% 10MB 16.6MB/s 00:00 +backup-Oct.zip 100% 713MB 41.9MB/s 00:17 +index.html 100% 85KB 6.6MB/s 00:00 +[root@linuxtechi ~]$ +``` + +### 示例:14)在 scp 命令中使用其他加密方式(-c) + +默认情况下,`scp` 使用 AES-128 加密方式来加密文件。如果你想在 `scp` 命令中使用其他加密方式,请使用 `-c` 选项,后接加密方式名称。 + +假设我们要在用 `scp` 命令传输文件时使用 3des-cbc 加密方式,请运行以下 `scp` 命令: + +``` +[root@linuxtechi ~]# scp -c 3des-cbc -r Downloads root@linuxtechi:/root +``` + +使用以下命令列出 `ssh` 和 `scp` 支持的加密方式: + +``` +[root@linuxtechi ~]# ssh -Q cipher localhost | paste -d , -s - +3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc,root@linuxtechi,aes128-ctr,aes192-ctr,aes256-ctr,root@linuxtechi,root@linuxtechi,root@linuxtechi +[root@linuxtechi ~]# +``` + +以上就是本教程的全部内容,要获取有关 `scp` 命令的更多详细信息,请参考其手册页。请在下面的评论部分中分享你的反馈和评论。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/scp-command-examples-in-linux/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/10/scp-command-examples-linux.jpg +[3]: https://www.linuxtechi.com/cdn-cgi/l/email-protection diff --git a/published/201912/20191022 How to program with Bash- Logical operators and shell expansions.md b/published/201912/20191022 How to program with Bash- Logical operators and shell expansions.md new file mode 100644 index 0000000000..31f0e3ef32 --- /dev/null +++ b/published/201912/20191022 How to program with Bash- Logical operators and shell expansions.md @@ -0,0 +1,467 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11687-1.html) +[#]: subject: (How to program with Bash: Logical operators and shell expansions) +[#]: via: (https://opensource.com/article/19/10/programming-bash-logical-operators-shell-expansions) +[#]: author: (David Both https://opensource.com/users/dboth) + +怎样用 Bash 编程:逻辑操作符和 shell 扩展 +====== + +> 学习逻辑操作符和 shell 扩展,本文是三篇 Bash 编程系列的第二篇。 + +![](https://img.linux.net.cn/data/attachment/album/201912/17/173459pxhz0aiicimzd1m2.jpg) + +Bash 是一种强大的编程语言,完美契合命令行和 shell 脚本。本系列(三篇文章,基于我的 [三集 Linux 自学课程][2])讲解如何在 CLI 使用 Bash 编程。 + +[第一篇文章][3] 讲解了 Bash 的一些简单命令行操作,包括如何使用变量和控制操作符。第二篇文章探讨文件、字符串、数字等类型和各种各样在执行流中提供控制逻辑的的逻辑运算符,还有 Bash 中的各类 shell 扩展。本系列第三篇也是最后一篇文章,将会探索能重复执行操作的 `for` 、`while` 和 `until` 循环。 + +逻辑操作符是程序中进行判断的根本要素,也是执行不同的语句组合的依据。有时这也被称为流控制。 + +### 逻辑操作符 + +Bash 中有大量的用于不同条件表达式的逻辑操作符。最基本的是 `if` 控制结构,它判断一个条件,如果条件为真,就执行一些程序语句。操作符共有三类:文件、数字和非数字操作符。如果条件为真,所有的操作符返回真值(`0`),如果条件为假,返回假值(`1`)。 + +这些比较操作符的函数语法是,一个操作符加一个或两个参数放在中括号内,后面跟一系列程序语句,如果条件为真,程序语句执行,可能会有另一个程序语句列表,该列表在条件为假时执行: + + +``` +if [ arg1 operator arg2 ] ; then list +或 +if [ arg1 operator arg2 ] ; then list ; else list ; fi +``` + +像例子中那样,在比较表达式中,空格不能省略。中括号的每部分,`[` 和 `]`,是跟 `test` 命令一样的传统的 Bash 符号: + +``` +if test arg1 operator arg2 ; then list +``` + +还有一个更新的语法能提供一点点便利,一些系统管理员比较喜欢用。这种格式对于不同版本的 Bash 和一些 shell 如 ksh(Korn shell)兼容性稍差。格式如下: + +``` +if [[ arg1 operator arg2 ]] ; then list +``` + +#### 文件操作符 + +文件操作符是 Bash 中一系列强大的逻辑操作符。图表 1 列出了 20 多种不同的 Bash 处理文件的操作符。在我的脚本中使用频率很高。 + +操作符 | 描述 +---|--- +`-a filename` | 如果文件存在,返回真值;文件可以为空也可以有内容,但是只要它存在,就返回真值 +`-b filename` | 如果文件存在且是一个块设备,如 `/dev/sda` 或 `/dev/sda1`,则返回真值 +`-c filename` | 如果文件存在且是一个字符设备,如 `/dev/TTY1`,则返回真值 +`-d filename` | 如果文件存在且是一个目录,返回真值 +`-e filename` | 如果文件存在,返回真值;与上面的 `-a` 相同 +`-f filename` | 如果文件存在且是一个一般文件,不是目录、设备文件或链接等的其他的文件,则返回 真值 +`-g filename` | 如果文件存在且 `SETGID` 标记被设置在其上,返回真值 +`-h filename` | 如果文件存在且是一个符号链接,则返回真值 +`-k filename` | 如果文件存在且粘滞位已设置,则返回真值 +`-p filename` | 如果文件存在且是一个命名的管道(FIFO),返回真值 +`-r filename` | 如果文件存在且有可读权限(它的可读位被设置),返回真值 +`-s filename` | 如果文件存在且大小大于 0,返回真值;如果一个文件存在但大小为 0,则返回假值 +`-t fd` | 如果文件描述符 `fd` 被打开且被关联到一个终端设备上,返回真值 +`-u filename` | 如果文件存在且它的 `SETUID` 位被设置,返回真值 +`-w filename` | 如果文件存在且有可写权限,返回真值 +`-x filename` | 如果文件存在且有可执行权限,返回真值 +`-G filename` | 如果文件存在且文件的组 ID 与当前用户相同,返回真值 +`-L filename` | 如果文件存在且是一个符号链接,返回真值(同 `-h`) +`-N filename` | 如果文件存在且从文件上一次被读取后文件被修改过,返回真值 +`-O filename` | 如果文件存在且你是文件的拥有者,返回真值 +`-S filename` | 如果文件存在且文件是套接字,返回真值 +`file1 -ef file2` | 如果文件 `file1` 和文件 `file2` 指向同一设备的同一 INODE 号,返回真值(即硬链接) +`file1 -nt file2` | 如果文件 `file1` 比 `file2` 新(根据修改日期),或 `file1` 存在而 `file2` 不存在,返回真值 +`file1 -ot file2` | 如果文件 `file1` 比 `file2` 旧(根据修改日期),或 `file1` 不存在而 `file2` 存在 + +*图表 1:Bash 文件操作符* + +以测试一个文件存在与否来举例: + +``` +[student@studentvm1 testdir]$ File="TestFile1" ; if [ -e $File ] ; then echo "The file $File exists." ; else echo "The file $File does not exist." ; fi +The file TestFile1 does not exist. +[student@studentvm1 testdir]$ +``` + +创建一个用来测试的文件,命名为 `TestFile1`。目前它不需要包含任何数据: + +``` +[student@studentvm1 testdir]$ touch TestFile1 +``` + +在这个简短的 CLI 程序中,修改 `$File` 变量的值相比于在多个地方修改表示文件名的字符串的值要容易: + +``` +[student@studentvm1 testdir]$ File="TestFile1" ; if [ -e $File ] ; then echo "The file $File exists." ; else echo "The file $File does not exist." ; fi +The file TestFile1 exists. +[student@studentvm1 testdir]$ +``` + +现在,运行一个测试来判断一个文件是否存在且长度不为 0(表示它包含数据)。假设你想判断三种情况: + +1. 文件不存在; +2. 文件存在且为空; +3. 文件存在且包含数据。 + +因此,你需要一组更复杂的测试代码 — 为了测试所有的情况,使用 `if-elif-else` 结构中的 `elif` 语句: + +``` +[student@studentvm1 testdir]$ File="TestFile1" ; if [ -s $File ] ; then echo "$File exists and contains data." ; fi +[student@studentvm1 testdir]$ +``` + +在这个情况中,文件存在但不包含任何数据。向文件添加一些数据再运行一次: + +``` +[student@studentvm1 testdir]$ File="TestFile1" ; echo "This is file $File" > $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; fi +TestFile1 exists and contains data. +[student@studentvm1 testdir]$ +``` + +这组语句能返回正常的结果,但是仅仅是在我们已知三种可能的情况下测试某种确切的条件。添加一段 `else` 语句,这样你就可以更精确地测试。把文件删掉,你就可以完整地测试这段新代码: + +``` +[student@studentvm1 testdir]$ File="TestFile1" ; rm $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; else echo "$File does not exist or is empty." ; fi +TestFile1 does not exist or is empty. +``` + +现在创建一个空文件用来测试: + +``` +[student@studentvm1 testdir]$ File="TestFile1" ; touch $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; else echo "$File does not exist or is empty." ; fi +TestFile1 does not exist or is empty. +``` + +向文件添加一些内容,然后再测试一次: + +``` +[student@studentvm1 testdir]$ File="TestFile1" ; echo "This is file $File" > $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; else echo "$File does not exist or is empty." ; fi +TestFile1 exists and contains data. +``` + +现在加入 `elif` 语句来辨别是文件不存在还是文件为空: + +``` +[student@studentvm1 testdir]$ File="TestFile1" ; touch $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; elif [ -e $File ] ; then echo "$File exists and is empty." ; else echo "$File does not exist." ; fi +TestFile1 exists and is empty. +[student@studentvm1 testdir]$ File="TestFile1" ; echo "This is $File" > $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; elif [ -e $File ] ; then echo "$File exists and is empty." ; else echo "$File does not exist." ; fi +TestFile1 exists and contains data. +[student@studentvm1 testdir]$ +``` + +现在你有一个可以测试这三种情况的 Bash CLI 程序,但是可能的情况是无限的。 + +如果你能像保存在文件中的脚本那样组织程序语句,那么即使对于更复杂的命令组合也会很容易看出它们的逻辑结构。图表 2 就是一个示例。 `if-elif-else` 结构中每一部分的程序语句的缩进让逻辑更变得清晰。 + + +``` +File="TestFile1" +echo "This is $File" > $File +if [ -s $File ] + then + echo "$File exists and contains data." +elif [ -e $File ] + then + echo "$File exists and is empty." +else + echo "$File does not exist." +fi +``` + +*图表 2: 像在脚本里一样重写书写命令行程序* + +对于大多数 CLI 程序来说,让这些复杂的命令变得有逻辑需要写很长的代码。虽然 CLI 可能是用 Linux 或 Bash 内置的命令,但是当 CLI 程序很长或很复杂时,创建一个保存在文件中的脚本将更有效,保存到文件中后,可以随时运行。 + +#### 字符串比较操作符 + +字符串比较操作符使我们可以对字符串中的字符按字母顺序进行比较。图表 3 列出了仅有的几个字符串比较操作符。 + +操作符 | 描述 +---|--- +`-z string` | 如果字符串的长度为 0 ,返回真值 +`-n string` |如果字符串的长度不为 0 ,返回真值 +`string1 == string2` 或 `string1 = string2` | 如果两个字符串相等,返回真值。处于遵从 POSIX 一致性,在测试命令中应使用一个等号 `=`。与命令 `[[` 一起使用时,会进行如上描述的模式匹配(混合命令)。 +`string1 != string2` | 两个字符串不相等,返回真值 +`string1 < string2` | 如果对 `string1` 和 `string2` 按字母顺序进行排序,`string1` 排在 `string2` 前面(即基于地区设定的对所有字母和特殊字符的排列顺序) +`string1 > string2` | 如果对 `string1` 和 `string2` 按字母顺序进行排序,`string1` 排在 `string2` 后面 + +*图表 3: Bash 字符串逻辑操作符* + +首先,检查字符串长度。比较表达式中 `$MyVar` 两边的双引号不能省略(你仍应该在目录 `~/testdir` 下 )。 + +``` +[student@studentvm1 testdir]$ MyVar="" ; if [ -z "" ] ; then echo "MyVar is zero length." ; else echo "MyVar contains data" ; fi +MyVar is zero length. +[student@studentvm1 testdir]$ MyVar="Random text" ; if [ -z "" ] ; then echo "MyVar is zero length." ; else echo "MyVar contains data" ; fi +MyVar is zero length. +``` + +你也可以这样做: + +``` +[student@studentvm1 testdir]$ MyVar="Random text" ; if [ -n "$MyVar" ] ; then echo "MyVar contains data." ; else echo "MyVar is zero length" ; fi +MyVar contains data. +[student@studentvm1 testdir]$ MyVar="" ; if [ -n "$MyVar" ] ; then echo "MyVar contains data." ; else echo "MyVar is zero length" ; fi +MyVar is zero length +``` + +有时候你需要知道一个字符串确切的长度。这虽然不是比较,但是也与比较相关。不幸的是,计算字符串的长度没有简单的方法。有很多种方法可以计算,但是我认为使用 `expr`(求值表达式)命令是相对最简单的一种。阅读 `expr` 的手册页可以了解更多相关知识。注意表达式中你检测的字符串或变量两边的引号不要省略。 + +``` +[student@studentvm1 testdir]$ MyVar="" ; expr length "$MyVar" +0 +[student@studentvm1 testdir]$ MyVar="How long is this?" ; expr length "$MyVar" +17 +[student@studentvm1 testdir]$ expr length "We can also find the length of a literal string as well as a variable." +70 +``` + +关于比较操作符,在我们的脚本中使用了大量的检测两个字符串是否相等(例如,两个字符串是否实际上是同一个字符串)的操作。我使用的是非 POSIX 版本的比较表达式: + +``` +[student@studentvm1 testdir]$ Var1="Hello World" ; Var2="Hello World" ; if [ "$Var1" == "$Var2" ] ; then echo "Var1 matches Var2" ; else echo "Var1 and Var2 do not match." ; fi +Var1 matches Var2 +[student@studentvm1 testdir]$ Var1="Hello World" ; Var2="Hello world" ; if [ "$Var1" == "$Var2" ] ; then echo "Var1 matches Var2" ; else echo "Var1 and Var2 do not match." ; fi +Var1 and Var2 do not match. +``` + +在你自己的脚本中去试一下这些操作符。 + +#### 数字比较操作符 + +数字操作符用于两个数字参数之间的比较。像其他类操作符一样,大部分都很容易理解。 + +操作符 | 描述 +---|--- +`arg1 -eq arg2` | 如果 `arg1` 等于 `arg2`,返回真值 +`arg1 -ne arg2` | 如果 `arg1` 不等于 `arg2`,返回真值 +`arg1 -lt arg2` | 如果 `arg1` 小于 `arg2`,返回真值 +`arg1 -le arg2` | 如果 `arg1` 小于或等于 `arg2`,返回真值 +`arg1 -gt arg2` | 如果 `arg1` 大于 `arg2`,返回真值 +`arg1 -ge arg2` | 如果 `arg1` 大于或等于 `arg2`,返回真值 + +*图表 4: Bash 数字比较逻辑操作符* + +来看几个简单的例子。第一个示例设置变量 `$X` 的值为 1,然后检测 `$X` 是否等于 1。第二个示例中,`$X` 被设置为 0,所以比较表达式返回结果不为真值。 + +``` +[student@studentvm1 testdir]$ X=1 ; if [ $X -eq 1 ] ; then echo "X equals 1" ; else echo "X does not equal 1" ; fi +X equals 1 +[student@studentvm1 testdir]$ X=0 ; if [ $X -eq 1 ] ; then echo "X equals 1" ; else echo "X does not equal 1" ; fi +X does not equal 1 +[student@studentvm1 testdir]$ +``` + +自己来多尝试一下其他的。 + +#### 杂项操作符 + +这些杂项操作符展示一个 shell 选项是否被设置,或一个 shell 变量是否有值,但是它不显示变量的值,只显示它是否有值。 + +操作符 | 描述 +---|--- +`-o optname` | 如果一个 shell 选项 `optname` 是启用的(查看内建在 Bash 手册页中的 set `-o` 选项描述下面的选项列表),则返回真值 +`-v varname` | 如果 shell 变量 `varname` 被设置了值(被赋予了值),则返回真值 +`-R varname` | 如果一个 shell 变量 `varname` 被设置了值且是一个名字引用,则返回真值 + +*图表 5: 杂项 Bash 逻辑操作符* + +自己来使用这些操作符实践下。 + +### 扩展 + +Bash 支持非常有用的几种类型的扩展和命令替换。根据 Bash 手册页,Bash 有七种扩展格式。本文只介绍其中五种:`~` 扩展、算术扩展、路径名称扩展、大括号扩展和命令替换。 + +#### 大括号扩展 + +大括号扩展是生成任意字符串的一种方法。(下面的例子是用特定模式的字符创建大量的文件。)大括号扩展可以用于产生任意字符串的列表,并把它们插入一个用静态字符串包围的特定位置或静态字符串的两端。这可能不太好想象,所以还是来实践一下。 + +首先,看一下大括号扩展的作用: + +``` +[student@studentvm1 testdir]$ echo {string1,string2,string3} +string1 string2 string3 +``` + +看起来不是很有用,对吧?但是用其他方式使用它,再来看看: + +``` +[student@studentvm1 testdir]$ echo "Hello "{David,Jen,Rikki,Jason}. +Hello David. Hello Jen. Hello Rikki. Hello Jason. +``` + +这看起来貌似有点用了 — 我们可以少打很多字。现在试一下这个: + +``` +[student@studentvm1 testdir]$ echo b{ed,olt,ar}s +beds bolts bars +``` + +我可以继续举例,但是你应该已经理解了它的用处。 + +#### ~ 扩展 + +资料显示,使用最多的扩展是波浪字符(`~`)扩展。当你在命令中使用它(如 `cd ~/Documents`)时,Bash shell 把这个快捷方式展开成用户的完整的家目录。 + +使用这个 Bash 程序观察 `~` 扩展的作用: + +``` +[student@studentvm1 testdir]$ echo ~ +/home/student +[student@studentvm1 testdir]$ echo ~/Documents +/home/student/Documents +[student@studentvm1 testdir]$ Var1=~/Documents ; echo $Var1 ; cd $Var1 +/home/student/Documents +[student@studentvm1 Documents]$ +``` + +#### 路径名称扩展 + +路径名称扩展是展开文件通配模式为匹配该模式的完整路径名称的另一种说法,匹配字符使用 `?` 和 `*`。文件通配指的是在大量操作中匹配文件名、路径和其他字符串时用特定的模式字符产生极大的灵活性。这些特定的模式字符允许匹配字符串中的一个、多个或特定字符。 + +* `?` — 匹配字符串中特定位置的一个任意字符 +* `*` — 匹配字符串中特定位置的 0 个或多个任意字符 + +这个扩展用于匹配路径名称。为了弄清它的用法,请确保 `testdir` 是当前工作目录(`PWD`),先执行基本的列出清单命令 `ls`(我家目录下的内容跟你的不一样)。 + +``` +[student@studentvm1 testdir]$ ls +chapter6  cpuHog.dos    dmesg1.txt  Documents  Music       softlink1  testdir6    Videos +chapter7  cpuHog.Linux  dmesg2.txt  Downloads  Pictures    Templates  testdir +testdir  cpuHog.mac    dmesg3.txt  file005    Public      testdir    tmp +cpuHog     Desktop       dmesg.txt   link3      random.txt  testdir1   umask.test +[student@studentvm1 testdir]$ +``` + +现在列出以 `Do`、`testdir/Documents` 和 `testdir/Downloads` 开头的目录: + +``` +Documents: +Directory01  file07  file15        test02  test10  test20      testfile13  TextFiles +Directory02  file08  file16        test03  test11  testfile01  testfile14 +file01       file09  file17        test04  test12  testfile04  testfile15 +file02       file10  file18        test05  test13  testfile05  testfile16 +file03       file11  file19        test06  test14  testfile09  testfile17 +file04       file12  file20        test07  test15  testfile10  testfile18 +file05       file13  Student1.txt  test08  test16  testfile11  testfile19 +file06       file14  test01        test09  test18  testfile12  testfile20 + +Downloads: +[student@studentvm1 testdir]$ +``` + +然而,并没有得到你期望的结果。它列出了以 `Do` 开头的目录下的内容。使用 `-d` 选项,仅列出目录而不列出它们的内容。 + +``` +[student@studentvm1 testdir]$ ls -d Do* +Documents  Downloads +[student@studentvm1 testdir]$ +``` + +在两个例子中,Bash shell 都把 `Do*` 模式展开成了匹配该模式的目录名称。但是如果有文件也匹配这个模式,会发生什么? + +``` +[student@studentvm1 testdir]$ touch Downtown ; ls -d Do* +Documents  Downloads  Downtown +[student@studentvm1 testdir]$ +``` + +因此所有匹配这个模式的文件也被展开成了完整名字。 + +#### 命令替换 + +命令替换是让一个命令的标准输出数据流被当做参数传给另一个命令的扩展形式,例如,在一个循环中作为一系列被处理的项目。Bash 手册页显示:“命令替换可以让你用一个命令的输出替换为命令的名字。”这可能不太好理解。 + +命令替换有两种格式:\`command\` 和 `$(command)`。在更早的格式中使用反引号(\`),在命令中使用反斜杠(`\`)来保持它转义之前的文本含义。然而,当用在新版本的括号格式中时,反斜杠被当做一个特殊字符处理。也请注意带括号的格式打开个关闭命令语句都是用一个括号。 + +我经常在命令行程序和脚本中使用这种能力,一个命令的结果能被用作另一个命令的参数。 + +来看一个非常简单的示例,这个示例使用了这个扩展的两种格式(再一次提醒,确保 `testdir` 是当前工作目录): + +``` +[student@studentvm1 testdir]$ echo "Todays date is `date`" +Todays date is Sun Apr 7 14:42:46 EDT 2019 +[student@studentvm1 testdir]$ echo "Todays date is $(date)" +Todays date is Sun Apr 7 14:42:59 EDT 2019 +[student@studentvm1 testdir]$ +``` + +`-seq` 工具用于一个数字序列: + +``` +[student@studentvm1 testdir]$ seq 5 +1 +2 +3 +4 +5 +[student@studentvm1 testdir]$ echo `seq 5` +1 2 3 4 5 +[student@studentvm1 testdir]$ +``` + +现在你可以做一些更有用处的操作,比如创建大量用于测试的空文件。 + +``` +[student@studentvm1 testdir]$ for I in $(seq -w 5000) ; do touch file-$I ; done +``` + +`seq` 工具加上 `-w` 选项后,在生成的数字前面会用 0 补全,这样所有的结果都等宽,例如,忽略数字的值,它们的位数一样。这样在对它们按数字顺序进行排列时很容易。 + +`seq -w 5000` 语句生成了 1 到 5000 的数字序列。通过把命令替换用于 `for` 语句,`for` 语句就可以使用该数字序列来生成文件名的数字部分。 + +#### 算术扩展 + +Bash 可以进行整型的数学计算,但是比较繁琐(你一会儿将看到)。数字扩展的语法是 `$((arithmetic-expression))` ,分别用两个括号来打开和关闭表达式。算术扩展在 shell 程序或脚本中类似命令替换;表达式结算后的结果替换了表达式,用于 shell 后续的计算。 + +我们再用一个简单的用法来开始: + +``` +[student@studentvm1 testdir]$ echo $((1+1)) +2 +[student@studentvm1 testdir]$ Var1=5 ; Var2=7 ; Var3=$((Var1*Var2)) ; echo "Var 3 = $Var3" +Var 3 = 35 +``` + +下面的除法结果是 0,因为表达式的结果是一个小于 1 的整型数字: + +``` +[student@studentvm1 testdir]$ Var1=5 ; Var2=7 ; Var3=$((Var1/Var2)) ; echo "Var 3 = $Var3" +Var 3 = 0 +``` + +这是一个我经常在脚本或 CLI 程序中使用的一个简单的计算,用来查看在 Linux 主机中使用了多少虚拟内存。 `free` 不提供我需要的数据: + +``` +[student@studentvm1 testdir]$ RAM=`free | grep ^Mem | awk '{print $2}'` ; Swap=`free | grep ^Swap | awk '{print $2}'` ; echo "RAM = $RAM and Swap = $Swap" ; echo "Total Virtual memory is $((RAM+Swap))" ; +RAM = 4037080 and Swap = 6291452 +Total Virtual memory is 10328532 +``` + +我使用 \` 字符来划定用作命令替换的界限。 + +我用 Bash 算术扩展的场景主要是用脚本检查系统资源用量后基于返回的结果选择一个程序运行的路径。 + +### 总结 + +本文是 Bash 编程语言系列的第二篇,探讨了 Bash 中文件、字符串、数字和各种提供流程控制逻辑的逻辑操作符还有不同种类的 shell 扩展。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/programming-bash-logical-operators-shell-expansions + +作者:[David Both][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[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/OSDC_women_computing_5.png?itok=YHpNs_ss (Women in computing and open source v5) +[2]: http://www.both.org/?page_id=1183 +[3]: https://linux.cn/article-11552-1.html diff --git a/published/201912/20191023 How to program with Bash- Loops.md b/published/201912/20191023 How to program with Bash- Loops.md new file mode 100644 index 0000000000..6a4d3ae653 --- /dev/null +++ b/published/201912/20191023 How to program with Bash- Loops.md @@ -0,0 +1,336 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11714-1.html) +[#]: subject: (How to program with Bash: Loops) +[#]: via: (https://opensource.com/article/19/10/programming-bash-loops) +[#]: author: (David Both https://opensource.com/users/dboth) + +怎样用 Bash 编程:循环 +====== + +> 本文是 Bash 编程系列三篇中的最后一篇,来学习使用循环执行迭代的操作。 + +![](https://img.linux.net.cn/data/attachment/album/201912/26/111437f9pa3zqqwcc9wwg1.jpg) + +Bash 是一种强大的用于命令行和 shell 脚本的编程语言。本系列的三部分都是基于我的三集 [Linux 自学课程][2] 写的,探索怎么用 CLI 进行 bash 编程。 + +本系列的 [第一篇文章][3] 讨论了 bash 编程的一些简单命令行操作,如使用变量和控制操作符。[第二篇文章][4] 探讨了文件、字符串、数字等类型和各种各样在执行流中提供控制逻辑的的逻辑运算符,还有 bash 中不同种类的扩展。本文是第三篇(也是最后一篇),意在考察在各种迭代的操作中使用循环以及怎么合理控制循环。 + +### 循环 + +我使用过的所有编程语言都至少有两种循环结构来用来执行重复的操作。我经常使用 `for` 循环,然而我发现 `while` 和 `until` 循环也很有用处。 + +#### for 循环 + +我的理解是,在 bash 中实现的 `for` 命令比大部分语言灵活,因为它可以处理非数字的值;与之形成对比的是,诸如标准 C 语言的 `for` 循环只能处理数字类型的值。 + +Bash 版的 `for` 命令基本的结构很简单: + +``` +for Var in list1 ; do list2 ; done +``` + +解释一下:“对于 `list1` 中的每一个值,把 `$Var` 设置为那个值,使用该值执行 `list2` 中的程序语句;`list1` 中的值都执行完后,整个循环结束,退出循环。” `list1` 中的值可以是一个简单的显式字符串值,也可以是一个命令执行后的结果(`` 包含其内的命令执行的结果,本系列第二篇文章中有描述)。我经常使用这种结构。 + +要测试它,确认 `~/testdir` 仍然是当前的工作目录(PWD)。删除目录下所有东西,来看下这个显式写出值列表的 `for` 循环的简单的示例。这个列表混合了字母和数字 — 但是不要忘了,在 bash 中所有的变量都是字符串或者可以被当成字符串来处理。 + +``` +[student@studentvm1 testdir]$ rm * +[student@studentvm1 testdir]$ for I in a b c d 1 2 3 4 ; do echo $I ; done +a +b +c +d +1 +2 +3 +4 +``` + +给变量赋予更有意义的名字,变成前面版本的进阶版: + +``` +[student@studentvm1 testdir]$ for Dept in "Human Resources" Sales Finance "Information Technology" Engineering Administration Research ; do echo "Department $Dept" ; done +Department Human Resources +Department Sales +Department Finance +Department Information Technology +Department Engineering +Department Administration +Department Research +``` + +创建几个目录(创建时显示一些处理信息): + +``` +[student@studentvm1 testdir]$ for Dept in "Human Resources" Sales Finance "Information Technology" Engineering Administration Research ; do echo "Working on Department $Dept" ; mkdir "$Dept"  ; done +Working on Department Human Resources +Working on Department Sales +Working on Department Finance +Working on Department Information Technology +Working on Department Engineering +Working on Department Administration +Working on Department Research +[student@studentvm1 testdir]$ ll +total 28 +drwxrwxr-x 2 student student 4096 Apr  8 15:45  Administration +drwxrwxr-x 2 student student 4096 Apr  8 15:45  Engineering +drwxrwxr-x 2 student student 4096 Apr  8 15:45  Finance +drwxrwxr-x 2 student student 4096 Apr  8 15:45 'Human Resources' +drwxrwxr-x 2 student student 4096 Apr  8 15:45 'Information Technology' +drwxrwxr-x 2 student student 4096 Apr  8 15:45  Research +drwxrwxr-x 2 student student 4096 Apr  8 15:45  Sales +``` + +在 `mkdir` 语句中 `$Dept` 变量必须用引号包裹起来;否则名字中间有空格(如 `Information Technology`)会被当做两个独立的目录处理。我一直信奉的一条实践规则:所有的文件和目录都应该为一个单词(中间没有空格)。虽然大部分现代的操作系统可以处理名字中间有空格的情况,但是系统管理员需要花费额外的精力去确保脚本和 CLI 程序能正确处理这些特例。(即使它们很烦人,也务必考虑它们,因为你永远不知道将拥有哪些文件。) + +再次删除 `~/testdir` 下的所有东西 — 再运行一次下面的命令: + +``` +[student@studentvm1 testdir]$ rm -rf * ; ll +total 0 +[student@studentvm1 testdir]$ for Dept in Human-Resources Sales Finance Information-Technology Engineering Administration Research ; do echo "Working on Department $Dept" ; mkdir "$Dept"  ; done +Working on Department Human-Resources +Working on Department Sales +Working on Department Finance +Working on Department Information-Technology +Working on Department Engineering +Working on Department Administration +Working on Department Research +[student@studentvm1 testdir]$ ll +total 28 +drwxrwxr-x 2 student student 4096 Apr  8 15:52 Administration +drwxrwxr-x 2 student student 4096 Apr  8 15:52 Engineering +drwxrwxr-x 2 student student 4096 Apr  8 15:52 Finance +drwxrwxr-x 2 student student 4096 Apr  8 15:52 Human-Resources +drwxrwxr-x 2 student student 4096 Apr  8 15:52 Information-Technology +drwxrwxr-x 2 student student 4096 Apr  8 15:52 Research +drwxrwxr-x 2 student student 4096 Apr  8 15:52 Sales +``` + +假设现在有个需求,需要列出一台 Linux 机器上所有的 RPM 包并对每个包附上简短的描述。我为北卡罗来纳州工作的时候,曾经遇到过这种需求。由于当时开源尚未得到州政府的“批准”,而且我只在台式机上使用 Linux,对技术一窍不通的老板(PHB)需要我列出我计算机上安装的所有软件,以便他们可以“批准”一个特例。 + +你怎么实现它?有一种方法是,已知 `rpm –qa` 命令提供了 RPM 包的完整描述,包括了白痴老板想要的东西:软件名称和概要描述。 + +让我们一步步执行出最后的结果。首先,列出所有的 RPM 包: + +``` +[student@studentvm1 testdir]$ rpm -qa +perl-HTTP-Message-6.18-3.fc29.noarch +perl-IO-1.39-427.fc29.x86_64 +perl-Math-Complex-1.59-429.fc29.noarch +lua-5.3.5-2.fc29.x86_64 +java-11-openjdk-headless-11.0.ea.28-2.fc29.x86_64 +util-linux-2.32.1-1.fc29.x86_64 +libreport-fedora-2.9.7-1.fc29.x86_64 +rpcbind-1.2.5-0.fc29.x86_64 +libsss_sudo-2.0.0-5.fc29.x86_64 +libfontenc-1.1.3-9.fc29.x86_64 +<snip> +``` + +用 `sort` 和 `uniq` 命令对列表进行排序和打印去重后的结果(有些已安装的 RPM 包具有相同的名字): + + +``` +[student@studentvm1 testdir]$ rpm -qa | sort | uniq +a2ps-4.14-39.fc29.x86_64 +aajohan-comfortaa-fonts-3.001-3.fc29.noarch +abattis-cantarell-fonts-0.111-1.fc29.noarch +abiword-3.0.2-13.fc29.x86_64 +abrt-2.11.0-1.fc29.x86_64 +abrt-addon-ccpp-2.11.0-1.fc29.x86_64 +abrt-addon-coredump-helper-2.11.0-1.fc29.x86_64 +abrt-addon-kerneloops-2.11.0-1.fc29.x86_64 +abrt-addon-pstoreoops-2.11.0-1.fc29.x86_64 +abrt-addon-vmcore-2.11.0-1.fc29.x86_64 +<snip> +``` + +以上命令得到了想要的 RPM 列表,因此你可以把这个列表作为一个循环的输入信息,循环最终会打印每个 RPM 包的详细信息: + +``` +[student@studentvm1 testdir]$ for RPM in `rpm -qa | sort | uniq` ; do rpm -qi $RPM ; done +``` + +这段代码产出了多余的信息。当循环结束后,下一步就是提取出白痴老板需要的信息。因此,添加一个 `egrep` 命令用来搜索匹配 `^Name` 或 `^Summary` 的行。脱字符(`^`)表示行首,整个命令表示显示所有以 Name 或 Summary 开头的行。 + +``` +[student@studentvm1 testdir]$ for RPM in `rpm -qa | sort | uniq` ; do rpm -qi $RPM ; done | egrep -i "^Name|^Summary" +Name        : a2ps +Summary     : Converts text and other types of files to PostScript +Name        : aajohan-comfortaa-fonts +Summary     : Modern style true type font +Name        : abattis-cantarell-fonts +Summary     : Humanist sans serif font +Name        : abiword +Summary     : Word processing program +Name        : abrt +Summary     : Automatic bug detection and reporting tool +<snip> +``` + +在上面的命令中你可以试试用 `grep` 代替 `egrep` ,你会发现用 `grep` 不能得到正确的结果。你也可以通过管道把命令结果用 `less` 过滤器来查看。最终命令像这样: + +``` +[student@studentvm1 testdir]$ for RPM in `rpm -qa | sort | uniq` ; do rpm -qi $RPM ; done | egrep -i "^Name|^Summary" > RPM-summary.txt +``` + +这个命令行程序用到了管道、重定向和 `for` 循环,这些全都在一行中。它把你的 CLI 程序的结果重定向到了一个文件,这个文件可以在邮件中使用或在其他地方作为输入使用。 + +这个一次一步构建程序的过程让你能看到每步的结果,以此来确保整个程序以你期望的流程进行且输出你想要的结果。 + +白痴老板最终收到了超过 1900 个不同的 RPM 包的清单,我严重怀疑根本就没人读过这个列表。我给了他们想要的东西,没有从他们嘴里听到过任何关于 RPM 包的信息。 + +### 其他循环 + +Bash 中还有两种其他类型的循环结构:`while` 和 `until` 结构,两者在语法和功能上都类似。这些循环结构的基础语法很简单: + +``` +while [ expression ] ; do list ; done +``` + +逻辑解释:表达式(`expression`)结果为 true 时,执行程序语句 `list`。表达式结果为 false 时,退出循环。 + +``` +until [ expression ] ; do list ; done +``` + +逻辑解释:执行程序语句 `list`,直到表达式的结果为 true。当表达式结果为 true 时,退出循环。 + +#### While 循环 + +`while` 循环用于当逻辑表达式结果为 true 时执行一系列程序语句。假设你的 PWD 仍是 `~/testdir`。 + +最简单的 `while` 循环形式是这个会一直运行下去的循环。下面格式的条件语句永远以 `true` 作为返回。你也可以用简单的 `1` 代替 `true`,结果一样,但是这解释了 true 表达式的用法。 + +``` +[student@studentvm1 testdir]$ X=0 ; while [ true ] ; do echo $X ; X=$((X+1)) ; done | head +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +[student@studentvm1 testdir]$ +``` + +既然你已经学了 CLI 的各部分知识,那就让它变得更有用处。首先,为了防止变量 `$X` 在前面的程序或 CLI 命令执行后有遗留的值,设置 `$X` 的值为 0。然后,因为逻辑表达式 `[ true ]` 的结果永远是 1,即 true,在 `do` 和 `done` 中间的程序指令列表会一直执行 — 或者直到你按下 `Ctrl+C` 抑或发送一个 2 号信号给程序。那些程序指令是算数扩展,用来打印变量 `$X` 当前的值并加 1. + +《[系统管理员的 Linux 哲学][5]》的信条之一是追求优雅,实现优雅的一种方式就是简化。你可以用操作符 `++` 来简化这个程序。在第一个例子中,变量当前的值被打印出来,然后变量的值增加了。可以在变量后加一个 `++` 来表示这个逻辑: + +``` +[student@studentvm1 ~]$ X=0 ; while [ true ] ; do echo $((X++)) ; done | head +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +``` + +现在删掉程序最后的 `| head` 再运行一次。 + +在下面这个版本中,变量在值被打印之前就自增了。这是通过在变量之前添加 `++` 操作符实现的。你能看出区别吗? + +``` +[student@studentvm1 ~]$ X=0 ; while [ true ] ; do echo $((++X)) ; done | head +1 +2 +3 +4 +5 +6 +7 +8 +9 +``` + +你已经把打印变量的值和自增简化到了一条语句。类似 `++` 操作符,也有 `--` 操作符。 + +你需要一个在循环到某个特定数字时终止循环的方法。把 true 表达式换成一个数字比较表达式来实现它。这里有一个循环到 5 终止的程序。在下面的示例代码中,你可以看到 `-le` 是 “小于或等于” 的数字逻辑操作符。整个语句的意思:只要 `$X` 的值小于或等于 5,循环就一直运行。当 `$X` 增加到 6 时,循环终止。 + +``` +[student@studentvm1 ~]$ X=0 ; while [ $X -le 5 ] ; do echo $((X++)) ; done +0 +1 +2 +3 +4 +5 +[student@studentvm1 ~]$ +``` + +#### Until 循环 + +`until` 命令非常像 `while` 命令。不同之处是,它直到逻辑表达式的值是 `true` 之前,会一直循环。看一下这种结构最简单的格式: + +``` +[student@studentvm1 ~]$ X=0 ; until false  ; do echo $((X++)) ; done | head +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +[student@studentvm1 ~]$ +``` + +它用一个逻辑比较表达式来计数到一个特定的值: + +``` +[student@studentvm1 ~]$ X=0 ; until [ $X -eq 5 ]  ; do echo $((X++)) ; done +0 +1 +2 +3 +4 +[student@studentvm1 ~]$ X=0 ; until [ $X -eq 5 ]  ; do echo $((++X)) ; done +1 +2 +3 +4 +5 +[student@studentvm1 ~]$ +``` + +### 总结 + +本系列探讨了构建 Bash 命令行程序和 shell 脚本的很多强大的工具。但是这仅仅是你能用 Bash 做的很多有意思的事中的冰山一角,接下来就看你的了。 + +我发现学习 Bash 编程最好的方法就是实践。找一个需要多个 Bash 命令的简单项目然后写一个 CLI 程序。系统管理员们要做很多适合 CLI 编程的工作,因此我确信你很容易能找到自动化的任务。 + +很多年前,尽管我对其他的 Shell 语言和 Perl 很熟悉,但还是决定用 Bash 做所有系统管理员的自动化任务。我发现,有时稍微搜索一下,我可以用 Bash 实现我需要的所有事情。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/programming-bash-loops + +作者:[David Both][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[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/fail_progress_cycle_momentum_arrow.png?itok=q-ZFa_Eh (arrows cycle symbol for failing faster) +[2]: http://www.both.org/?page_id=1183 +[3]: https://linux.cn/article-11552-1.html +[4]: https://linux.cn/article-11687-1.html +[5]: https://www.apress.com/us/book/9781484237298 diff --git a/published/201912/20191024 Get sorted with sort at the command line.md b/published/201912/20191024 Get sorted with sort at the command line.md new file mode 100644 index 0000000000..55916bdcad --- /dev/null +++ b/published/201912/20191024 Get sorted with sort at the command line.md @@ -0,0 +1,240 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11657-1.html) +[#]: subject: (Get sorted with sort at the command line) +[#]: via: (https://opensource.com/article/19/10/get-sorted-sort) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +在命令行用 sort 进行排序 +====== + +> 在 Linux、BSD 或 Mac 的终端中使用 sort 命令,按自己的需求重新整理数据。 + +![](https://img.linux.net.cn/data/attachment/album/201912/09/065444f42xl2lddxillz09.jpg) + +如果你曾经用过数据表应用程序,你就会知道可以按列的内容对行进行排序。例如,如果你有一个费用列表,你可能希望对它们进行按日期或价格升序抑或按类别进行排序。如果你熟悉终端的使用,你不会仅为了排序文本数据就去使用庞大的办公软件。这正是 [sort][2] 命令的用处。 + +### 安装 + +你不必安装 `sort` ,因为它向来都包含在 [POSIX][3] 系统里。在大多数 Linux 系统中,`sort` 命令来自 GNU 组织打包的实用工具集合中。在其他的 POSIX 系统中,像 BSD 和 Mac,默认的 `sort` 命令不是 GNU 提供的,所以有一些选项可能不一样。本文中我尽量对 GNU 和 BSD 两者的实现都进行说明。 + +### 按字母顺序排列行 + +`sort` 命令默认会读取文件每行的第一个字符并对每行按字母升序排序后输出。两行中的第一个字符相同的情况下,对下一个字符进行对比。例如: + +``` +$ cat distro.list +Slackware +Fedora +Red Hat Enterprise Linux +Ubuntu +Arch +1337 +Mint +Mageia +Debian +$ sort distro.list +1337 +Arch +Debian +Fedora +Mageia +Mint +Red Hat Enterprise Linux +Slackware +Ubuntu +``` + +使用 `sort` 不会改变原文件。`sort` 仅起到过滤的作用,所以如果你希望按排序后的格式保存数据,你需要用 `>` 或 `tee` 进行重定向。 + + +``` +$ sort distro.list | tee distro.sorted +1337 +Arch +Debian +[...] +$ cat distro.sorted +1337 +Arch +Debian +[...] +``` + +### 按列排序 + +复杂数据集有时候不止需要对每行的第一个字符进行排序。例如,假设有一个动物列表,每个都有其种和属,用可预见的分隔符分隔每一个“字段”(即数据表中的“单元格”)。这类由数据表导出的格式很常见,CSV(以逗号分隔的数据comma-separated values)后缀可以标识这些文件(虽然 CSV 文件不一定用逗号分隔,有分隔符的文件也不一定用 CSV 后缀)。以下数据作为示例: + +``` +Aptenodytes;forsteri;Miller,JF;1778;Emperor +Pygoscelis;papua;Wagler;1832;Gentoo +Eudyptula;minor;Bonaparte;1867;Little Blue +Spheniscus;demersus;Brisson;1760;African +Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed +Eudyptes;chrysocome;Viellot;1816;Southern Rockhopper +Torvaldis;linux;Ewing,L;1996;Tux +``` + +对于这组示例数据,你可以用 `--field-separator` (在 BSD 和 Mac 用 `-t`,在 GNU 上也可以用简写 `-t` )设置分隔符为分号(因为该示例数据中是用分号而不是逗号,理论上分隔符可以是任意字符),用 `--key`(在 BSD 和 Mac 上用 `-k`,在 GNU 上也可以用简写 `-k`)选项指定哪个字段被排序。例如,对每行第二个字段进行排序(计数以 1 开头而不是 0): + +``` +sort --field-separator=";" --key=2 +Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed +Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper +Spheniscus;demersus;Brisson;1760;African +Aptenodytes;forsteri;Miller,JF;1778;Emperor +Torvaldis;linux;Ewing,L;1996;Tux +Eudyptula;minor;Bonaparte;1867;Little Blue +Pygoscelis;papua;Wagler;1832;Gentoo +``` + +结果有点不容易读,但是 Unix 以构造命令的管道方式而闻名,所以你可以使用 `column` 命令美化输出结果。使用 GNU `column`: + +``` +$ sort --field-separator=";" \ +\--key=2 penguins.list | column --table --separator ";" +Megadyptes   antipodes   Milne-Edwards  1880  Yellow-eyed +Eudyptes     chrysocome  Viellot        1816  Southern Rockhopper +Spheniscus   demersus    Brisson        1760  African +Aptenodytes  forsteri    Miller,JF      1778  Emperor +Torvaldis    linux       Ewing,L        1996  Tux +Eudyptula    minor       Bonaparte      1867  Little Blue +Pygoscelis   papua       Wagler         1832  Gentoo +``` + +对于初学者可能有点不好理解(但是写起来简单),BSD 和 Mac 上的命令选项: + +``` +$ sort -t ";" \ +-k2 penguins.list | column -t -s ";" +Megadyptes   antipodes   Milne-Edwards  1880  Yellow-eyed +Eudyptes     chrysocome  Viellot        1816  Southern Rockhopper +Spheniscus   demersus    Brisson        1760  African +Aptenodytes  forsteri    Miller,JF      1778  Emperor +Torvaldis    linux       Ewing,L        1996  Tux +Eudyptula    minor       Bonaparte      1867  Little Blue +Pygoscelis   papua       Wagler         1832  Gentoo +``` + +当然 `-k` 不一定非要设为 `2`。任意存在的字段都可以被设为排序的键。 + +### 逆序排列 + +你可以用 `--reverse`(BSD/Mac 上用 `-r`,GNU 上也可以用简写 `-r`)选项来颠倒已经排好序的列表。 + +``` +$ sort --reverse alphabet.list +z +y +x +w +[...] +``` + +你也可以把输出结果通过管道传给命令 [tac][4] 来实现相同的效果。 + +### 按月排序(仅 GNU 支持) + +理想情况下,所有人都按照 ISO 8601 标准来写日期:年、月、日。这是一种合乎逻辑的指定精确日期的方法,也可以很容易地被计算机理解。也有很多情况下,人类用其他的方式标注日期,包括用很名字随意的月份。 + +幸运的是,GNU `sort` 命令能识别这种写法,并可以按月份的名称正确排序。使用 `--month-sort`(`-M`)选项: + +``` +$ cat month.list +November +October +September +April +[...] +$ sort --month-sort month.list +January +February +March +April +May +[...] +November +December +``` + +月份的全称和简写都可以被识别。 + +### 人类可读的数字排序(仅 GNU 支持) + +另一个人类和计算机的常见混淆点是数字的组合。例如,人类通常把 “1024 kilobytes” 写成 “1KB”,因为人类解析 “1 KB” 比 “1024” 要容易且更快(数字越大,这种差异越明显)。对于计算机来说,一个 9 KB 的字符串要比诸如 1 MB 的字符串大(尽管 9 KB 是 1 MB 很小一部分)。GNU `sort` 命令提供了`--human-numeric-sort`(`-h`)选项来帮助正确解析这些值。 + +``` +$ cat sizes.list +2M +12MB +1k +9k +900 +7000 +$ sort --human-numeric-sort +900 +7000 +1k +9k +2M +12MB +``` + +有一些情况例外。例如,“16000 bytes” 比 “1 KB” 大,但是 `sort` 识别不了。 + +``` +$ cat sizes0.list +2M +12MB +16000 +1k +$ sort -h sizes0.list +16000 +1k +2M +12MB +``` + +逻辑上来说,这个示例中 16000 应该写成 16 KB,所以也不应该全部归咎于GNU `sort`。只要你确保数字的一致性,`--human-numeric-sort` 可以用一种计算机友好的方式解析成人类可读的数字。 + +### 随机排序(仅 GNU 支持) + +有时候工具也提供了一些与设计初衷相悖的选项。某种程度上说,`sort` 命令提供对一个文件进行随机排序的能力没有任何意义。这个命令的工作流让这个特性变得很方便。你*可以*用其他的命令,像 [shuf][5] ,或者你可以用现在的命令添加一个选项。不管你认为它是一个臃肿的还是极具创造力的用户体验设计,GNU `sort` 命令提供了对文件进行随机排序的功能。 + +最纯粹的随机排序格式选项是 `--random-sort` 或 `-R`(不要跟 `-r` 混淆,`-r` 是 `--reverse` 的简写)。 + +``` +$ sort --random-sort alphabet.list +d +m +p +a +[...] +``` + +每次对文件运行随机排序都会有不同的结果。 + +### 结语 + +GNU 和 BSD 的 `sort` 命令还有很多功能,所以花点时间去了解这些选项。你会惊异于 `sort` 的灵活性,尤其是当它和其他的 Unix 工具一起使用时。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/get-sorted-sort + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl "Coding on a computer" +[2]: https://en.wikipedia.org/wiki/Sort_(Unix) +[3]: https://en.wikipedia.org/wiki/POSIX +[4]: https://opensource.com/article/19/9/tac-command +[5]: https://www.gnu.org/software/coreutils/manual/html_node/shuf-invocation.html diff --git a/published/201912/20191028 6 signs you might be a Linux user.md b/published/201912/20191028 6 signs you might be a Linux user.md new file mode 100644 index 0000000000..42688e4e2b --- /dev/null +++ b/published/201912/20191028 6 signs you might be a Linux user.md @@ -0,0 +1,153 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11635-1.html) +[#]: subject: (6 signs you might be a Linux user) +[#]: via: (https://opensource.com/article/19/10/signs-linux-user) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Linux 资深用户的 6 大特征 +====== + +> 如果你是 Linux 资深用户,则可能会有这些共同倾向。 + +![](https://img.linux.net.cn/data/attachment/album/201912/02/093348ek4jcyvj4wahytwq.jpg) + +Linux 用户千差万别,但是我们许多人都有一些相同的习惯。你可能没有本文列出的任何特征,而且如果你是个 Linux 新用户,你可能还不能理解这些特征…… + +下面是你可能是 Linux 用户的六个特征。 + +### 1、理所当然,纪元始于 1970 年 1 月 1 日 + +关于 Unix 计算机时钟为何在重置时总是将其设置回 1970-01-01 的传闻有很多。但有点令人感到乏味的事实是,Unix “纪元”是用于同步的通用且简单的参考点。例如,万圣节在儒略历中是今年的 304 日,但我们通常将该节日称为 “31 号”。我们知道指的是哪个月的 31 号,因为我们有个共同的参考点:我们知道万圣节在 10 月庆祝,而 10 月是一年中的第十个月,并且我们知道前面每一个月包含多少天。没有这些值,虽然我们可以使用传统的计时方法(如月相)来跟踪特殊的季节性事件,但是计算机显然不具备这种能力。 + +计算机需要确定且明确定义的值,因此将值 `1970-01-01T00:00:00Z` 选择为 Unix 纪元的开始。每当 [POSIX][2] 计算机的时间不准确时,诸如网络时间协议(NTP)之类的服务就可以向其提供自 `1970-01-01T00:00:00Z` 以来的秒数,计算机可以将其转换为人类易于识别的日期。 + +日期和时间是在计算中要追踪的著名的复杂事物,主要是因为几乎所有标准都有例外。一个月并不总是有 30 天,一年也不总是有 365 天,甚至每年有多少秒钟也往往会有所不同。如果你正在寻找一个有趣而令人沮丧的编程练习,那么请尝试编程一个可靠的日历应用程序! + +### 2、输入超过两个字母你就会觉得麻烦 + +众所周知,最常见的 Unix 命令都超简短。除了 `cd`、`ls` 和 `mv` 之类的命令外,还有一个命令简直不能再短了:`w`(它根据 `/var/run/utmp` 文件显示当前谁登录了)。 + +一方面,极短的命令似乎很不直观。新用户可能不会猜测到键入 `ls` 会列出list目录。但是,一旦学习命令,它们肯定是越短越好。如果你整天都在终端上度过,那么你键入的击键次数越少就意味着你可以有更多的时间来完成工作。 + +幸运的是,单字母命令并不太多,因此你可以使用大多数字母作为别名。例如,我经常使用 Emacs,以至于我觉得 `emacs` 的输入时间太长,因此通过将下面这行添加到 `.bashrc` 文件中,将其别名为 `e`: + +``` +alias e='emacs' +``` + +你也可以临时为命令添加别名。例如,如果你在解决网络问题时发现自己反复运行 [firewall-cmd][3],则可以为当前会话创建别名: + +``` +$ alias f='firewall-cmd' +$ f +usage: see firewall-cmd man page +No option specified. +``` + +只要你打开着终端,你的别名就会一直存在。当终端一旦关闭,它便会被遗忘。 + +### 3、做任何事都不应该单击两次以上 + +Linux 用户喜欢效率。尽管并非每个 Linux 用户都总是急于完成工作,但 Linux 桌面中有一些旨在减少完成任务所需的操作数量的惯例。这里有些例子。 + +* 在 KDE 文件管理器 Dolphin 中,单击即可打开文件或目录。假定如果要选择一个文件,则可以单击并拖动,也可以 `Ctrl + 点击`。这可能会使习惯于双击所有内容的用户感到困惑,但是一旦你尝试了单击操作,通常就无法返回费力的双击操作。 +* 在大多数 Linux 桌面上,单击鼠标中键可粘贴剪贴板的最新内容。 +* 在许多 Linux 桌面上,可以通过按 `Alt`、`Ctrl` 或 `Shift` 键来修改拖动动作。例如,`Alt + 拖动` 在 KDE 中移动窗口,而 GNOME 中的 `Ctrl + 拖动` 会复制文件而不是移动。 + +### 4、任何操作你都不会执行三次以上,因为第三次时你已经将它自动化了 + +请原谅我有点夸张,但是许多 Linux 用户期望他们的计算机比他们更努力地工作。虽然学习如何自动执行常见任务需要花费时间,但在 Linux 上它往往比在其它平台上更容易,因为 Linux 终端和 Linux 操作系统是如此紧密地集成在一起。最容易自动化的是你在终端中已经执行的操作,因为命令只是你在解释器中键入的字符串,而该解释器(终端)不会在乎你是手动键入字符串还是将其指向一个脚本。 + +例如,如果你发现自己经常将一组文件从一个位置移动到另一个位置,则或许可以将相同的指令序列用作一个脚本,你可以使用单个命令来触发该脚本。假设你每天早上手动执行此操作: + +``` +$ cd Documents +$ trash reports-latest.txt +$ wget myserver.local/reports/daily/report-latest.txt +$ cp report-latest.txt reports_daily/2019-31-10.log +``` + +这是一个简单的序列,但是每天重复一次并不是消磨时间的最有效方法。做一点点抽象,你可以使用一个简单的脚本将其自动化: + +``` +#!/bin/sh + +trash $HOME/Documents/reports-latest.txt + +wget myserver.local/reports/daily/report-latest.txt \ + -P $HOME/Documents/udpates_daily/`date --iso-8601`.log + +cp $HOME/Documents/udpates_daily/`date --iso-8601`.log \ + $HOME/Documents/reports-latest.txt +``` + +你可以把你的脚本叫做 `get-reports.sh` 并在每天早晨手动启动它,或者甚至可以将其输入到 crontab 中,以便计算机可以执行此任务而无需你进行任何干预。 + +对于新用户来说,这可能会有点困扰,因为什么和什么是一体的并不总是很明显。例如,如果你经常发现自己打开图像并将其按比例缩小 50%,那么你可能习惯于执行以下操作: + +1. 打开你的照片查看器或编辑器 +2. 缩放图像 +3. 将图像导出为修改后的文件 +4. 关闭应用程序 + +如果你一天要做几次,你可能会对这种重复感到厌倦。但是,由于你是在图形用户界面(GUI)中执行这些操作的,因此你需要知道如何对 GUI 编写脚本以使其自动化。某些应用程序,例如 [GIMP][4],具有丰富的脚本接口,但是其过程显然不同于仅修改一堆命令并将其存储到文件中那么简单。 + +再说一次,有时在命令行中有与你在 GUI 中所做的等效的操作。将文档从一种文本格式转换为另一种格式可以使用 [Pandoc][5],处理图像可以使用 [Image Magick][6],音乐和视频也可以通过命令行进行编辑和转换,等等。最大的问题是你需要知道要查找什么,通常是学习新的(有时是复杂的)命令。但是,在终端中按比例缩小图像比在 GUI 中显然更简单: + +``` +#!/bin/sh + +convert "${1}" -scale 50% `basename "${1}" .jpg`_50.jpg +``` + +这些麻烦、重复的任务值得研究。你永远不知道你的工作让计算机做起来是有多么的简单和快捷! + +### 5、发行版之间跳来跳去 + +我在家里是一个热情的 Slackware 用户,而在工作时是一个 RHEL 用户。实际上,这不是事实,我现在在工作时是 Fedora 用户。除了有时候我使用 CentOS,偶尔我还会运行 [Mageia][7]。 + +![Debian on a PowerPC64 box, image CC BY SA Claudio Miranda][8] + +*运行在 PowerPC64 机器上的 Debian* + +发行版好不好无关紧要,成为 Linux 用户的极致乐趣之一是可以自由决定运行哪个发行版。乍一看,它们基本相同,令人耳目一新。但是根据你的心情,你可能更喜欢 CentOS 的稳定性而不是 Fedora 的不断更新,或者你可能有一天会真正享受 Mageia 的集中控制中心,然后又对原始的 [Debian][9] 配置文件进行模块化乐在其中,而有时你又会完全转向其他操作系统。 + +![OpenBSD, image CC BY SA Claudio Miranda][10] + +*OpenBSD,不是 Linux 发行版* + +关键是,Linux 发行版是激情项目,成为其他人的开源激情的一部分很有趣。 + +### 6、你对开源充满热情 + +无论你的经验如何,如果你是 Linux 用户,那么你无疑会对开源充满热情。无论你是每天通过[共创艺术品] [11]还是代码来表达你的热情,还是将其升华到只在自由而自在的环境中完成工作,你都生活并构筑于开源之上。因为有了千千万万个你,所以有了开源社区,社区因你而变得更加丰富。 + +有太多的东西我没有提到。作为 Linux 用户,还有什么可以出卖你的身份?让我们在评论中知道! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/signs-linux-user + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tux_linux_penguin_code_binary.jpg?itok=TxGxW0KY (Tux with binary code background) +[2]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains +[3]: https://opensource.com/article/19/7/make-linux-stronger-firewalls +[4]: https://www.gimp.org/ +[5]: https://opensource.com/article/19/5/convert-markdown-to-word-pandoc +[6]: https://opensource.com/article/17/8/imagemagick +[7]: http://mageia.org +[8]: https://opensource.com/sites/default/files/uploads/debian.png (Debian on a PowerPC64 box) +[9]: http://debian.org +[10]: https://opensource.com/sites/default/files/uploads/openbsd.jpg (OpenBSD) +[11]: http://freesvg.org diff --git a/published/201912/20191028 How to remove duplicate lines from files with awk.md b/published/201912/20191028 How to remove duplicate lines from files with awk.md new file mode 100644 index 0000000000..8a5148e708 --- /dev/null +++ b/published/201912/20191028 How to remove duplicate lines from files with awk.md @@ -0,0 +1,222 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11666-1.html) +[#]: subject: (How to remove duplicate lines from files with awk) +[#]: via: (https://opensource.com/article/19/10/remove-duplicate-lines-files-awk) +[#]: author: (Lazarus Lazaridis https://opensource.com/users/iridakos) + +怎样使用 awk 删掉文件中重复的行 +====== + +> 学习怎样使用 awk 的 `!visited[$0]++` 在不重新排序或改变原排列顺序的前提下删掉重复的行。 + +![](https://img.linux.net.cn/data/attachment/album/201912/12/124322vwe3tq3wlw33tw1f.jpg) + +假设你有一个文本文件,你需要删掉所有重复的行。 + +### TL;DR + +*要保持原来的排列顺序*删掉重复行,使用: + +``` +awk '!visited[$0]++' your_file > deduplicated_file +``` + +### 工作原理 + +这个脚本维护一个关联数组,索引(键)为文件中去重后的行,每个索引对应的值为该行出现的次数。对于文件的每一行,如果这行(之前)出现的次数为 0,则值加 1,并打印这行,否则值加 1,不打印这行。 + +我之前不熟悉 `awk`,我想弄清楚这么短小的一个脚本是怎么实现的。我调研了下,下面是调研心得: + +* 这个 awk “脚本” `!visited[$0]++` 对输入文件的*每一行*都执行。 +* `visited[]` 是一个[关联数组][2](又名[映射][3])类型的变量。`awk` 会在第一次执行时初始化它,因此我们不需要初始化。 +* `$0` 变量的值是当前正在被处理的行的内容。 +* `visited[$0]` 通过与 `$0`(正在被处理的行)相等的键来访问该映射中的值,即出现次数(我们在下面设置的)。 +* `!` 对表示出现次数的值取反: + * 在 `awk` 中,[任意非零的数或任意非空的字符串的值是 `true`][4]。 + * [变量默认的初始值为空字符串][5],如果被转换为数字,则为 0。 + * 也就是说: + * 如果 `visited[$0]` 的值是一个比 0 大的数,取反后被解析成 `false`。 + * 如果 `visited[$0]` 的值为等于 0 的数字或空字符串,取反后被解析成 `true` 。 + * `++` 表示变量 `visited[$0]` 的值加 1。 + * 如果该值为空,`awk` 自动把它转换为 `0`(数字) 后加 1。 + * 注意:加 1 操作是在我们取到了变量的值之后执行的。 + +总的来说,整个表达式的意思是: + + * `true`:如果表示出现次数为 0 或空字符串 + * `false`:如果出现的次数大于 0 + +`awk` 由 [模式或表达式和一个与之关联的动作][6] 组成: + +``` +<模式/表达式> { <动作> } +``` + +如果匹配到了模式,就会执行后面的动作。如果省略动作,`awk` 默认会打印(`print`)输入。 + +> 省略动作等价于 `{print $0}`。 + +我们的脚本由一个 `awk` 表达式语句组成,省略了动作。因此这样写: + +``` +awk '!visited[$0]++' your_file > deduplicated_file +``` + +等于这样写: + +``` +awk '!visited[$0]++ { print $0 }' your_file > deduplicated_file +``` + +对于文件的每一行,如果表达式匹配到了,这行内容被打印到输出。否则,不执行动作,不打印任何东西。 + +### 为什么不用 uniq 命令? + +`uniq` 命令仅能对相邻的行去重。这是一个示例: + +``` +$ cat test.txt +A +A +A +B +B +B +A +A +C +C +C +B +B +A +$ uniq < test.txt +A +B +A +C +B +A +``` + +### 其他方法 + +#### 使用 sort 命令 + +我们也可以用下面的 [sort][7] 命令来去除重复的行,但是*原来的行顺序没有被保留*。 + + +``` +sort -u your_file > sorted_deduplicated_file +``` + +#### 使用 cat + sort + cut + +上面的方法会产出一个去重的文件,各行是基于内容进行排序的。[通过管道连接命令][8]可以解决这个问题。 + + +``` +cat -n your_file | sort -uk2 | sort -nk1 | cut -f2- +``` + +**工作原理** + +假设我们有下面一个文件: + +``` +abc +ghi +abc +def +xyz +def +ghi +klm +``` + +`cat -n test.txt` 在每行前面显示序号: + +``` +1       abc +2       ghi +3       abc +4       def +5       xyz +6       def +7       ghi +8       klm +``` + +`sort -uk2` 基于第二列(`k2` 选项)进行排序,对于第二列相同的值只保留一次(`u` 选项): + +``` +1       abc +4       def +2       ghi +8       klm +5       xyz +``` + +`sort -nk1` 基于第一列排序(`k1` 选项),把列的值作为数字来处理(`-n` 选项): + +``` +1       abc +2       ghi +4       def +5       xyz +8       klm +``` + +最后,`cut -f2-` 从第二列开始打印每一行,直到最后的内容(`-f2-` 选项:留意 `-` 后缀,它表示这行后面的内容都包含在内)。 + +``` +abc +ghi +def +xyz +klm +``` + +### 参考 + +* [GNU awk 用户手册][9] +* [awk 中的数组][2] +* [Awk — 真值][4] +* [Awk 表达式][5] +* [Unix 怎么删除文件中重复的行?][10] +* [不用排序去掉重复的行(去重)][11] +* ['!a[$0]++' 工作原理][12] + +以上为全文。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/remove-duplicate-lines-files-awk + +作者:[Lazarus Lazaridis][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/iridakos +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: http://kirste.userpage.fu-berlin.de/chemnet/use/info/gawk/gawk_12.html +[3]: https://en.wikipedia.org/wiki/Associative_array +[4]: https://www.gnu.org/software/gawk/manual/html_node/Truth-Values.html +[5]: https://ftp.gnu.org/old-gnu/Manuals/gawk-3.0.3/html_chapter/gawk_8.html +[6]: http://kirste.userpage.fu-berlin.de/chemnet/use/info/gawk/gawk_9.html +[7]: http://man7.org/linux/man-pages/man1/sort.1.html +[8]: https://stackoverflow.com/a/20639730/2292448 +[9]: https://www.gnu.org/software/gawk/manual/html_node/ +[10]: https://stackoverflow.com/questions/1444406/how-can-i-delete-duplicate-lines-in-a-file-in-unix +[11]: https://stackoverflow.com/questions/11532157/remove-duplicate-lines-without-sorting +[12]: https://unix.stackexchange.com/questions/159695/how-does-awk-a0-work/159734#159734 +[13]: https://opensource.com/sites/default/files/uploads/duplicate-cat.jpg (Duplicate cat) +[14]: https://iridakos.com/about/ +[15]: http://creativecommons.org/licenses/by-nc/4.0/ diff --git a/published/201912/20191101 Awk one-liners and scripts to help you sort text files.md b/published/201912/20191101 Awk one-liners and scripts to help you sort text files.md new file mode 100644 index 0000000000..a22edd71eb --- /dev/null +++ b/published/201912/20191101 Awk one-liners and scripts to help you sort text files.md @@ -0,0 +1,242 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11684-1.html) +[#]: subject: (Awk one-liners and scripts to help you sort text files) +[#]: via: (https://opensource.com/article/19/11/how-sort-awk) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +帮助你排序文本文件的 Awk 命令行或脚本 +====== + +> Awk 是一个强大的工具,可以执行某些可能由其它常见实用程序(包括 `sort`)来完成的任务。 + +![](https://img.linux.net.cn/data/attachment/album/201912/17/095222q7m5da4h8facvmtv.jpg) + +Awk 是个普遍存在的 Unix 命令,用于扫描和处理包含可预测模式的文本。但是,由于它具有函数功能,因此也可以合理地称之为编程语言。 + +令人困惑的是,有不止一个 awk。(或者,如果你认为只有一个,那么其它几个就是克隆。)有 `awk`(由Aho、Weinberger 和 Kernighan 编写的原始程序),然后有 `nawk` 、`mawk` 和 GNU 版本的 `gawk`。GNU 版本的 awk 是该实用程序的一个高度可移植的自由软件版本,具有几个独特的功能,因此本文是关于 GNU awk 的。 + +虽然它的正式名称是 `gawk`,但在 GNU+Linux 系统上,它的别名是 `awk`,并用作该命令的默认版本。 在其他没有带有 GNU awk 的系统上,你必须先安装它并将其称为 `gawk`,而不是 `awk`。本文互换使用术语 `awk` 和 `gawk`。 + +`awk` 既是命令语言又是编程语言,这使其成为一个强大的工具,可以处理原本留给 `sort`、`cut`、`uniq` 和其他常见实用程序的任务。幸运的是,开源中有很多冗余空间,因此,如果你面临是否使用 `awk` 的问题,答案可能是肯定的“随便”。 + +`awk` 的灵活之美在于,如果你已经确定使用 `awk` 来完成一项任务,那么无论接下来发生什么,你都可以继续使用 `awk`。这包括对数据排序而不是按交付给你的顺序的永恒需求。 + +### 样本数据集 + +在探索 `awk` 的排序方法之前,请生成要使用的样本数据集。保持简单,这样你就不会为极端情况和意想不到的复杂性所困扰。这是本文使用的样本集: + +``` +Aptenodytes;forsteri;Miller,JF;1778;Emperor +Pygoscelis;papua;Wagler;1832;Gentoo +Eudyptula;minor;Bonaparte;1867;Little Blue +Spheniscus;demersus;Brisson;1760;African +Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed +Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper +Torvaldis;linux;Ewing,L;1996;Tux +``` + +这是一个很小的数据集,但它提供了多种数据类型: + +* 属名和种名,彼此相关但又是分开的 +* 姓,有时是以逗号开头的首字母缩写 +* 代表日期的整数 +* 任意术语 +* 所有字段均以分号分隔 + +根据你的教育背景,你可能会认为这是二维数组或表格,或者只是行分隔的数据集合。你如何看待它只是你的问题,而 `awk` 只认识文本。由你决定告诉 `awk` 你想如何解析它。 + +### 只想排序 + +如果你只想按特定的可定义字段(例如电子表格中的“单元格”)对文本数据集进行排序,则可以使用 [sort 命令][2]。 + +### 字段和记录 + +无论输入的格式如何,都必须在其中找到模式才可以专注于对你重要的数据部分。在此示例中,数据由两个因素定界:行和字段。每行都代表一个新的*记录*,就如你在电子表格或数据库转储中看到的一样。在每一行中,都有用分号(`;`)分隔的不同的*字段*(将其视为电子表格中的单元格)。 + +`awk` 一次只处理一条记录,因此,当你在构造发给 `awk` 的这指令时,你可以只关注一行记录。写下你想对一行数据执行的操作,然后在下一行进行测试(无论是心理上还是用 `awk` 进行测试),然后再进行其它的一些测试。最后,你要对你的 `awk` 脚本要处理的数据做好假设,以便可以按你要的数据结构提供给你数据。 + +在这个例子中,很容易看到每个字段都用分号隔开。为简单起见,假设你要按每行的第一字段对列表进行排序。 + +在进行排序之前,你必须能够让 `awk` 只关注在每行的第一个字段上,因此这是第一步。终端中 awk 命令的语法为 `awk`,后跟相关选项,最后是要处理的数据文件。 + +``` +$ awk --field-separator=";" '{print $1;}' penguins.list +Aptenodytes +Pygoscelis +Eudyptula +Spheniscus +Megadyptes +Eudyptes +Torvaldis +``` + +因为字段分隔符是对 Bash shell 具有特殊含义的字符,所以必须将分号括在引号中或在其前面加上反斜杠。此命令仅用于证明你可以专注于特定字段。你可以使用另一个字段的编号尝试相同的命令,以查看数据的另一个“列”的内容: + +``` +$ awk --field-separator=";" '{print $3;}' penguins.list +Miller,JF +Wagler +Bonaparte +Brisson +Milne-Edwards +Viellot +Ewing,L +``` + +我们尚未进行任何排序,但这是良好的基础。 + +### 脚本编程 + +`awk` 不仅仅是命令,它是一种具有索引、数组和函数的编程语言。这很重要,因为这意味着你可以获取要排序的字段列表,将列表存储在内存中,进行处理,然后打印结果数据。对于诸如此类的一系列复杂操作,在文本文件中进行操作会更容易,因此请创建一个名为 `sort.awk` 的新文件并输入以下文本: + +``` +#!/bin/gawk -f + +BEGIN { +        FS=";"; +} +``` + +这会将该文件建立为 `awk` 脚本,该脚本中包含执行的行。 + +`BEGIN` 语句是 `awk` 提供的特殊设置功能,用于只需要执行一次的任务。定义内置变量 `FS`,它代表字段分隔符field separator,并且与你在 `awk` 命令中使用 `--field-separator` 设置的值相同,它只需执行一次,因此它包含在 `BEGIN` 语句中。 + +#### awk 中的数组 + +你已经知道如何通过使用 `$` 符号和字段编号来收集特定字段的值,但是在这种情况下,你需要将其存储在数组中而不是将其打印到终端。这是通过 `awk` 数组完成的。`awk` 数组的重要之处在于它包含键和值。 想象一下有关本文的内容;它看起来像这样:`author:"seth",title:"How to sort with awk",length:1200`。诸如作者、标题和长度之类的元素是键,跟着的内容为值。 + +在排序的上下文中这样做的好处是,你可以将任何字段分配为键,将任何记录分配为值,然后使用内置的 `awk` 函数 `asorti()`(按索引排序)按键进行排序。现在,随便假设你*只*想按第二个字段排序。 + +*没有*被特殊关键字 `BEGIN` 或 `END` 引起来的 `awk` 语句是在每个记录都要执行的循环。这是脚本的一部分,该脚本扫描数据中的模式并进行相应的处理。每次 `awk` 将注意力转移到一条记录上时,都会执行 `{}` 中的语句(除非以 `BEGIN` 或 `END` 开头)。 + +要将键和值添加到数组,请创建一个包含数组的变量(在本示例脚本中,我将其称为 `ARRAY`,虽然不是很原汁原味,但很清楚),然后在方括号中分配给它键,用等号(`=`)连接值。 + +``` +{   # dump each field into an array +    ARRAY[$2] = $R; +} +``` + +在此语句中,第二个字段的内容(`$2`)用作关键字,而当前记录(`$R`)用作值。 + +### asorti() 函数 + +除了数组之外,`awk` 还具有一些基本函数,你可以将它们用作常见任务的快速简便的解决方案。GNU awk中引入的函数之一 `asorti()` 提供了按键(*索引*)或值对数组进行排序的功能。 + +你只能在对数组进行填充后对其进行排序,这意味着此操作不能对每个新记录都触发,而只能在脚本的最后阶段进行。为此,`awk` 提供了特殊的 `END` 关键字。与 `BEGIN` 相反,`END` 语句仅在扫描了所有记录之后才触发一次。 + +将这些添加到你的脚本: + +``` +END { +    asorti(ARRAY,SARRAY); +    # get length +    j = length(SARRAY); +    +    for (i = 1; i <= j; i++) { +        printf("%s %s\n", SARRAY[i],ARRAY[SARRAY[i]]) +    } +} +``` + +`asorti()` 函数获取 `ARRAY` 的内容,按索引对其进行排序,然后将结果放入名为 `SARRAY` 的新数组(我在本文中发明的任意名称,表示“排序的 ARRAY”)。 + +接下来,将变量 `j`(另一个任意名称)分配给 `length()` 函数的结果,该函数计算 `SARRAY` 中的项数。 + +最后,使用 `for` 循环使用 `printf()` 函数遍历 `SARRAY` 中的每一项,以打印每个键,然后在 `ARRAY` 中打印该键的相应值。 + +### 运行该脚本 + +要运行你的 `awk` 脚本,先使其可执行: + +``` +$ chmod +x sorter.awk +``` + +然后针对 `penguin.list` 示例数据运行它: + +``` +$ ./sorter.awk penguins.list +antipodes Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed +chrysocome Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper +demersus Spheniscus;demersus;Brisson;1760;African +forsteri Aptenodytes;forsteri;Miller,JF;1778;Emperor +linux Torvaldis;linux;Ewing,L;1996;Tux +minor Eudyptula;minor;Bonaparte;1867;Little Blue +papua Pygoscelis;papua;Wagler;1832;Gentoo +``` + +如你所见,数据按第二个字段排序。 + +这有点限制。最好可以在运行时灵活选择要用作排序键的字段,以便可以在任何数据集上使用此脚本并获得有意义的结果。 + +### 添加命令选项 + +你可以通过在脚本中使用字面值 `var` 将命令变量添加到 `awk` 脚本中。更改脚本,以使迭代子句在创建数组时使用 `var`: + +``` +{ # dump each field into an array +    ARRAY[$var] = $R; +} +``` + +尝试运行该脚本,以便在执行脚本时使用 `-v var` 选项将其按第三字段排序: + +``` +$ ./sorter.awk -v var=3 penguins.list +Bonaparte Eudyptula;minor;Bonaparte;1867;Little Blue +Brisson Spheniscus;demersus;Brisson;1760;African +Ewing,L Torvaldis;linux;Ewing,L;1996;Tux +Miller,JF Aptenodytes;forsteri;Miller,JF;1778;Emperor +Milne-Edwards Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed +Viellot Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper +Wagler Pygoscelis;papua;Wagler;1832;Gentoo +``` + +### 修正 + +本文演示了如何在纯 GNU awk 中对数据进行排序。你可以对脚本进行改进,以便对你有用,花一些时间在`gawk` 的手册页上研究 [awk 函数][3]并自定义脚本以获得更好的输出。 + +这是到目前为止的完整脚本: + +``` +#!/usr/bin/awk -f +# GPLv3 appears here +# usage: ./sorter.awk -v var=NUM FILE + +BEGIN { FS=";"; } + +{ # dump each field into an array +    ARRAY[$var] = $R; +} + +END { +    asorti(ARRAY,SARRAY); +    # get length +    j = length(SARRAY); +    +    for (i = 1; i <= j; i++) { +        printf("%s %s\n", SARRAY[i],ARRAY[SARRAY[i]]) +    } +} +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/how-sort-awk + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_lead-steps-measure.png?itok=DG7rFZPk (Green graph of measurements) +[2]: https://opensource.com/article/19/10/get-sorted-sort +[3]: https://www.gnu.org/software/gawk/manual/html_node/Built_002din.html#Built_002din diff --git a/published/201912/20191113 Edit images on Fedora easily with GIMP.md b/published/201912/20191113 Edit images on Fedora easily with GIMP.md new file mode 100644 index 0000000000..c4fa6c8b67 --- /dev/null +++ b/published/201912/20191113 Edit images on Fedora easily with GIMP.md @@ -0,0 +1,85 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11632-1.html) +[#]: subject: (Edit images on Fedora easily with GIMP) +[#]: via: (https://fedoramagazine.org/edit-images-on-fedora-easily-with-gimp/) +[#]: author: (Mehdi Haghgoo https://fedoramagazine.org/author/powergame/) + +在 Fedora 上使用 GIMP 轻松编辑图像 +====== + +![][1] + +GIMP(GNU Image Manipulation Program 的缩写)是自由开源的图像处理软件。它有很多的功能,从简单的图像编辑,到复杂的滤镜、脚本,甚至是动画,它是流行的商业同类软件的一款很好的替代品。 + +继续阅读来学习如何在 Fedora 上安装和使用 GIMP。这篇文章涉及基本的日常图像编辑工作。 + +### 安装 GIMP + +GIMP 在官方 Fedora 存储库中可获得。为安装它,运行: + +``` +sudo dnf install gimp +``` + +### 单窗口模式 + +在你打开应用程序后,它显示带有工具箱和主编辑区的暗色主题窗口。注意,它有两种窗口模式,你可以通过选择“窗口Windows -> 单窗口模式Single Window Mode”在其中切换。通过选中这个选项,用户界面的所有组件将显示在单个窗口中。否则,它们将是分离的。 + +### 加载图像 + +![][2] + +为加载图像,转到“文件File -> 打开Open”,然后选择你的文件并选择你的图像文件。 + +### 重新调整一个图像的大小 + +为重新调整图像大小,你可以基于一对参数重新调整大小,包括像素和百分比 —— 在编辑图像时,这两个参数很方便。 + +让我们假使我们需要缩小 Fedora 30 背景图像到它当前大小的 75%。为此,选择“图像 Image -> 比例Scale”,然后在比例对话框上,在单位下拉列表中选择“百分比percentage”。接下来,输入 “75” 作为宽度或高度,然后按 Tab 键。默认情况下,其它尺寸将自动地调整大小,以相应地与更改的尺寸保持纵横比。现在,保存其它选项不变,并按比例。 + +![][3] + +该图像缩小到其原始尺寸的 75%。 + +### 旋转图像 + +旋转是一种变换操作,因此,你可以从主菜单下的“图像Image -> 变换Transform”下找到它,其中有图像旋转 90° 或 180° 的选项。在上述选项下也有垂直或水平翻转图像的选项。 + +让我们假使我们需要旋转图像 90°。在应用一次 90° 顺时针旋转和水平翻转后,我们的图像将看起来像这样: + +![Transforming an image with GIMP][4] + +### 添加文本 + +添加文本非常简单。只需要从工具箱中选择 “A” 图标,然后,在你的图像上,单击你想要添加文本的位置。如果工具箱不可见,从“窗口Windows -> 新建工具箱New Toolbox”打开它。 + +当你编辑文本时,你可能注意到,文本对话框有字体自定义选项,包括字体系列、字体大小等等。 + +![Adding text to image in GIMP][5] + +### 保存和导出 + +你可以从“文件File -> 保存Save”或通过按 `Ctrl+S` 来将你的编辑保存为一个带有 `.xcf` 扩展名的 GIMP 工程。或者,你可以导出你的图像,例如,以 PNG 或 JPEG 格式。为导出图像,转到“文件File -> 导出为Export As”或按 `Ctrl+Shift+E`,接下来,在你面前将产生一个你可以选择输出图像和名称的对话框。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/edit-images-on-fedora-easily-with-gimp/ + +作者:[Mehdi Haghgoo][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://fedoramagazine.org/author/powergame/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/10/gimp-magazine-816x346.jpg +[2]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-00-44-300x165.png +[3]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-17-33-300x262.png +[4]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-41-28-300x243.png +[5]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-47-54-300x237.png + diff --git a/published/201912/20191114 Debugging Software Deployments with strace.md b/published/201912/20191114 Debugging Software Deployments with strace.md new file mode 100644 index 0000000000..c3557e89ef --- /dev/null +++ b/published/201912/20191114 Debugging Software Deployments with strace.md @@ -0,0 +1,345 @@ +[#]: collector: (lujun9972) +[#]: translator: (hanwckf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11667-1.html) +[#]: subject: (Debugging Software Deployments with strace) +[#]: via: (https://theartofmachinery.com/2019/11/14/deployment_debugging_strace.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +在软件部署中使用 strace 进行调试 +====== + +![](https://img.linux.net.cn/data/attachment/album/201912/12/130413poennny2pbrgy9ot.jpg) + +我的大部分工作都涉及到部署软件系统,这意味着我需要花费很多时间来解决以下问题: + +* 这个软件可以在原开发者的机器上工作,但是为什么不能在我这里运行? +* 这个软件昨天可以在我的机器上工作,但是为什么今天就不行? + +这是一种调试的类型,但是与一般的软件调试有所不同。一般的调试通常只关心代码的逻辑,但是在软件部署中的调试关注的是程序的代码和它所在的运行环境之间的相互影响。即便问题的根源是代码的逻辑错误,但软件显然可以在别的机器上运行的事实意味着这类问题与运行环境密切相关。 + +所以,在软件部署过程中,我没有使用传统的调试工具(例如 `gdb`),而是选择了其它工具进行调试。我最喜欢的用来解决“为什么这个软件无法在这台机器上运行?”这类问题的工具就是 `strace`。 + +### 什么是 strace? + +[strace][1] 是一个用来“追踪系统调用”的工具。它主要是一个 Linux 工具,但是你也可以在其它系统上使用类似的工具(例如 [DTrace][2] 和 [ktrace][3])。 + +它的基本用法非常简单。只需要在 `strace` 后面跟上你需要运行的命令,它就会显示出该命令触发的所有系统调用(你可能需要先安装好 `strace`): + +``` +$ strace echo Hello +...Snip lots of stuff... +write(1, "Hello\n", 6) = 6 +close(1) = 0 +close(2) = 0 +exit_group(0) = ? ++++ exited with 0 +++ +``` + +这些系统调用都是什么?它们就像是操作系统内核提供的 API。很久以前,软件拥有直接访问硬件的权限。如果软件需要在屏幕上显示一些东西,它将会与视频硬件的端口和内存映射寄存器纠缠不清。当多任务操作系统变得流行以后,这就导致了混乱的局面,因为不同的应用程序将“争夺”硬件,并且一个应用程序的错误可能致使其它应用程序崩溃,甚至导致整个系统崩溃。所以 CPU 开始支持多种不同的特权模式(或者称为“保护环”)。它们让操作系统内核在具有完全硬件访问权限的最高特权模式下运行,于此同时,其它在低特权模式下运行的应用程序必须通过向内核发起系统调用才能够与硬件进行交互。 + +在二进制级别上,发起系统调用相比简单的函数调用有一些区别,但是大部分程序都使用标准库提供的封装函数。例如,POSIX C 标准库包含一个 `write()` 函数,该函数包含用于进行 `write` 系统调用的所有与硬件体系结构相关的代码。 + +![][4] + +简单来说,一个应用程序与其环境(计算机系统)的交互都是通过系统调用来完成的。所以当软件在一台机器上可以工作但是在另一台机器无法工作的时候,追踪系统调用是一个很好的查错方法。具体地说,你可以通过追踪系统调用分析以下典型操作: + + * 控制台输入与输出 (IO) + * 网络 IO + * 文件系统访问以及文件 IO + * 进程/线程生命周期管理 + * 原始内存管理 + * 访问特定的设备驱动 + +### 什么时候可以使用 strace? + +理论上,`strace` 适用于任何用户空间程序,因为所有的用户空间程序都需要进行系统调用。`strace` 对于已编译的低级程序最有效果,但如果你可以避免运行时环境和解释器带来的大量额外输出,则仍然可以与 Python 等高级语言程序一起使用。 + +当软件在一台机器上正常工作,但在另一台机器上却不能正常工作,同时抛出了有关文件、权限或者不能运行某某命令等模糊的错误信息时,`strace` 往往能大显身手。不幸的是,它不能诊断高等级的问题,例如数字证书验证错误等。这些问题通常需要组合使用 `strace`(有时候是 [`ltrace`][5])和其它高级工具(例如使用 `openssl` 命令行工具调试数字证书错误)。 + +本文中的示例基于独立的服务器,但是对系统调用的追踪通常也可以在更复杂的部署平台上完成,仅需要找到合适的工具。 + +### 一个简单的例子 + +假设你正在尝试运行一个叫做 `foo` 的服务器应用程序,但是发生了以下情况: + +``` +$ foo +Error opening configuration file: No such file or directory +``` + +显然,它没有找到你已经写好的配置文件。之所以会发生这种情况,是因为包管理工具有时候在编译应用程序时指定了自定义的路径,所以你应当遵循特定发行版提供的安装指南。如果错误信息告诉你正确的配置文件应该在什么地方,你就可以在几秒钟内解决这个问题,但如果没有告诉你呢?你该如何找到正确的路径? + +如果你有权访问源代码,则可以通过阅读源代码来解决问题。这是一个好的备用计划,但不是最快的解决方案。你还可以使用类似 `gdb` 的单步调试器来观察程序的行为,但使用专门用于展示程序与系统环境交互作用的工具 `strace` 更加有效。 + +一开始, `strace` 产生的大量输出可能会让你不知所措,幸好你可以忽略其中大部分的无用信息。我经常使用 `-o` 参数把输出的追踪结果保存到单独的文件里: + +``` +$ strace -o /tmp/trace foo +Error opening configuration file: No such file or directory +$ cat /tmp/trace +execve("foo", ["foo"], 0x7ffce98dc010 /* 16 vars */) = 0 +brk(NULL) = 0x56363b3fb000 +access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) +openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 +fstat(3, {st_mode=S_IFREG|0644, st_size=25186, ...}) = 0 +mmap(NULL, 25186, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2f12cf1000 +close(3) = 0 +openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 +read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260A\2\0\0\0\0\0"..., 832) = 832 +fstat(3, {st_mode=S_IFREG|0755, st_size=1824496, ...}) = 0 +mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2f12cef000 +mmap(NULL, 1837056, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2f12b2e000 +mprotect(0x7f2f12b50000, 1658880, PROT_NONE) = 0 +mmap(0x7f2f12b50000, 1343488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f2f12b50000 +mmap(0x7f2f12c98000, 311296, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16a000) = 0x7f2f12c98000 +mmap(0x7f2f12ce5000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b6000) = 0x7f2f12ce5000 +mmap(0x7f2f12ceb000, 14336, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2f12ceb000 +close(3) = 0 +arch_prctl(ARCH_SET_FS, 0x7f2f12cf0500) = 0 +mprotect(0x7f2f12ce5000, 16384, PROT_READ) = 0 +mprotect(0x56363b08b000, 4096, PROT_READ) = 0 +mprotect(0x7f2f12d1f000, 4096, PROT_READ) = 0 +munmap(0x7f2f12cf1000, 25186) = 0 +openat(AT_FDCWD, "/etc/foo/config.json", O_RDONLY) = -1 ENOENT (No such file or directory) +dup(2) = 3 +fcntl(3, F_GETFL) = 0x2 (flags O_RDWR) +brk(NULL) = 0x56363b3fb000 +brk(0x56363b41c000) = 0x56363b41c000 +fstat(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x8), ...}) = 0 +write(3, "Error opening configuration file"..., 60) = 60 +close(3) = 0 +exit_group(1) = ? ++++ exited with 1 +++ +``` + +`strace` 输出的第一页通常是低级的进程启动过程。(你可以看到很多 `mmap`、`mprotect`、`brk` 调用,这是用来分配原始内存和映射动态链接库的。)实际上,在查找错误时,最好从下往上阅读 `strace` 的输出。你可以看到 `write` 调用在最后返回了错误信息。如果你向上找,你将会看到第一个失败的系统调用是 `openat`,它在尝试打开 `/etc/foo/config.json` 时抛出了 `ENOENT` (“No such file or directory”)的错误。现在我们已经知道了配置文件应该放在哪里。 + +这是一个简单的例子,但我敢说在 90% 的情况下,使用 `strace` 进行调试不需要更多复杂的工作。以下是完整的调试步骤: + +1. 从程序中获得含糊不清的错误信息 +2. 使用 `strace` 运行程序 +3. 在输出中找到错误信息 +4. 往前追溯并找到第一个失败的系统调用 + +第四步中的系统调用很可能向你显示出问题所在。 + +### 小技巧 + +在开始更加复杂的调试之前,这里有一些有用的调试技巧帮助你高效使用 `strace`: + +#### man 是你的朋友 + +在很多 *nix 操作系统中,你可以通过 `man syscalls` 查看系统调用的列表。你将会看到类似于 `brk(2)` 之类的东西,这意味着你可以通过运行 `man 2 brk` 得到与此相关的更多信息。 + +一个小问题:`man 2 fork` 会显示出在 GNU `libc` 里封装的 `fork()` 手册页,而 `fork()` 现在实际上是由 `clone` 系统调用实现的。`fork` 的语义与 `clone` 相同,但是如果我写了一个含有 `fork()` 的程序并使用 `strace` 去调试它,我将找不到任何关于 `fork` 调用的信息,只能看到 `clone` 调用。如果将源代码与 `strace` 的输出进行比较的时候,像这种问题会让人感到困惑。 + +#### 使用 -o 将输出保存到文件 + +`strace` 可以生成很多输出,所以将输出保存到单独的文件是很有帮助的(就像上面的例子一样)。它还能够在控制台中避免程序自身的输出与 `strace` 的输出发生混淆。 + +#### 使用 -s 查看更多的参数 + +你可能已经注意到,错误信息的第二部分没有出现在上面的例子中。这是因为 `strace` 默认仅显示字符串参数的前 32 个字节。如果你需要捕获更多参数,请向 `strace` 追加类似于 `-s 128` 之类的参数。 + +#### -y 使得追踪文件或套接字更加容易 + +“一切皆文件”意味着 *nix 系统通过文件描述符进行所有 IO 操作,不管是真实的文件还是通过网络或者进程间管道。这对于编程而言是很方便的,但是在追踪系统调用时,你将很难分辨出 `read` 和 `write` 的真实行为。 + +`-y` 参数使 `strace` 在注释中注明每个文件描述符的具体指向。 + +#### 使用 -p 附加到正在运行的进程中 + +正如我们将在后面的例子中看到的,有时候你想追踪一个正在运行的程序。如果你知道这个程序的进程号为 1337 (可以通过 `ps` 查询),则可以这样操作: + +``` +$ strace -p 1337 +...system call trace output... +``` + +你可能需要 root 权限才能运行。 + +#### 使用 -f 追踪子进程 + +`strace` 默认只追踪一个进程。如果这个进程产生了一个子进程,你将会看到创建子进程的系统调用(一般是 `clone`),但是你看不到子进程内触发的任何调用。 + +如果你认为在子进程中存在错误,则需要使用 `-f` 参数启用子进程追踪功能。这样做的缺点是输出的内容会让人更加困惑。当追踪一个进程时,`strace` 显示的是单个调用事件流。当追踪多个进程的时候,你将会看到以 `` 开始的初始调用,接着是一系列针对其它线程的调用,最后才出现以 `<... foocall resumed>` 结束的初始调用。此外,你可以使用 `-ff` 参数将所有的调用分离到不同的文件中(查看 [strace 手册][6] 获取更多信息)。 + +#### 使用 -e 进行过滤 + +正如你所看到的,默认的追踪输出是所有的系统调用。你可以使用 `-e` 参数过滤你需要追踪的调用(查看 [strace 手册][6])。这样做的好处是运行过滤后的 `strace` 比起使用 `grep` 进行二次过滤要更快。老实说,我大部分时间都不会被打扰。 + +#### 并非所有的错误都是不好的 + +一个简单而常用的例子是一个程序在多个位置搜索文件,例如 shell 搜索哪个 `bin/` 目录包含可执行文件: + +``` +$ strace sh -c uname +... +stat("/home/user/bin/uname", 0x7ffceb817820) = -1 ENOENT (No such file or directory) +stat("/usr/local/bin/uname", 0x7ffceb817820) = -1 ENOENT (No such file or directory) +stat("/usr/bin/uname", {st_mode=S_IFREG|0755, st_size=39584, ...}) = 0 +... +``` + +“错误信息之前的最后一次失败调用”这种启发式方法非常适合于查找错误。无论如何,自下而上地查找是有道理的。 + +#### C 编程指南非常有助于理解系统调用 + +标准 C 库函数调用不属于系统调用,但它们仅是系统调用之上的唯一一个薄层。所以如果你了解(甚至只是略知一二)如何使用 C 语言,那么阅读系统调用追踪信息就非常容易。例如,如果你在调试网络系统调用,你可以尝试略读 [Beej 经典的《网络编程指南》][7]。 + +### 一个更复杂的调试例子 + +就像我说的那样,简单的调试例子表现了我在大部分情况下如何使用 `strace`。然而,有时候需要一些更加细致的工作,所以这里有一个稍微复杂(且真实)的例子。 + +[bcron][8] 是一个任务调度器,它是经典 *nix `cron` 守护程序的另一种实现。它已经被安装到一台服务器上,但是当有人尝试编辑作业时间表时,发生了以下情况: + +``` +# crontab -e -u logs +bcrontab: Fatal: Could not create temporary file +``` + +好的,现在 bcron 尝试写入一些文件,但是它失败了,也没有告诉我们原因。以下是 `strace` 的输出: + +``` +# strace -o /tmp/trace crontab -e -u logs +bcrontab: Fatal: Could not create temporary file +# cat /tmp/trace +... +openat(AT_FDCWD, "bcrontab.14779.1573691864.847933", O_RDONLY) = 3 +mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f82049b4000 +read(3, "#Ansible: logsagg\n20 14 * * * lo"..., 8192) = 150 +read(3, "", 8192) = 0 +munmap(0x7f82049b4000, 8192) = 0 +close(3) = 0 +socket(AF_UNIX, SOCK_STREAM, 0) = 3 +connect(3, {sa_family=AF_UNIX, sun_path="/var/run/bcron-spool"}, 110) = 0 +mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f82049b4000 +write(3, "156:Slogs\0#Ansible: logsagg\n20 1"..., 161) = 161 +read(3, "32:ZCould not create temporary f"..., 8192) = 36 +munmap(0x7f82049b4000, 8192) = 0 +close(3) = 0 +write(2, "bcrontab: Fatal: Could not creat"..., 49) = 49 +unlink("bcrontab.14779.1573691864.847933") = 0 +exit_group(111) = ? ++++ exited with 111 +++ +``` + +在程序结束之前有一个 `write` 的错误信息,但是这次有些不同。首先,在此之前没有任何相关的失败系统调用。其次,我们看到这个错误信息是由 `read` 从别的地方读取而来的。这看起来像是真正的错误发生在别的地方,而 `bcrontab` 只是在转播这些信息。 + +如果你查阅了 `man 2 read`,你将会看到 `read` 的第一个参数 (`3`) 是一个文件描述符,这是 *nix 操作系统用于所有 IO 操作的句柄。你该如何知道文件描述符 3 代表什么?在这种情况下,你可以使用 `-y` 参数运行 `strace`(如上文所述),它将会在注释里告诉你文件描述符的具体指向,但是了解如何从上面这种输出中分析追踪结果是很有用的。 + +一个文件描述符可以来自于许多系统调用之一(这取决于它是用于控制台、网络套接字还是真实文件等的描述符),但不论如何,我们都可以搜索返回值为 `3` 的系统调用(例如,在 `strace` 的输出中查找 `=3`)。在这次 `strace` 中可以看到有两个这样的调用:最上面的 `openat` 以及中间的 `socket`。`openat` 打开一个文件,但是紧接着的 `close(3)` 表明其已经被关闭。(注意:文件描述符可以在打开并关闭后重复使用。)所以 `socket` 调用才是与此相关的(它是在 `read` 之前的最后一个),这告诉我们 `brcontab` 正在与一个网络套接字通信。在下一行,`connect` 表明文件描述符 3 是一个连接到 `/var/run/bcron-spool` 的 Unix 域套接字。 + +因此,我们需要弄清楚 Unix 套接字的另一侧是哪个进程在监听。有两个巧妙的技巧适用于在服务器部署中调试。一个是使用 `netstat` 或者较新的 `ss`。这两个命令都描述了当前系统中活跃的网络套接字,使用 `-l` 参数可以显示出处于监听状态的套接字,而使用 `-p` 参数可以得到正在使用该套接字的程序信息。(它们还有更多有用的选项,但是这两个已经足够完成工作了。) + +``` +# ss -pl | grep /var/run/bcron-spool +u_str LISTEN 0 128 /var/run/bcron-spool 1466637 * 0 users:(("unixserver",pid=20629,fd=3)) +``` + +这告诉我们 `/var/run/bcron-spool` 套接字的监听程序是 `unixserver` 这个命令,它的进程 ID 为 20629。(巧合的是,这个程序也使用文件描述符 `3` 去连接这个套接字。) + +第二个常用的工具就是使用 `lsof` 查找相同的信息。它可以列出当前系统中打开的所有文件(或文件描述符)。或者,我们可以得到一个具体文件的信息: + +``` +# lsof /var/run/bcron-spool +COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME +unixserve 20629 cron 3u unix 0x000000005ac4bd83 0t0 1466637 /var/run/bcron-spool type=STREAM +``` + +进程 20629 是一个常驻进程,所以我们可以使用 `strace -o /tmp/trace -p 20629` 去查看该进程的系统调用。如果我们在另一个终端尝试编辑 cron 的计划任务表,就可以在错误发生时捕获到以下信息: + +``` +accept(3, NULL, NULL) = 4 +clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7faa47c44810) = 21181 +close(4) = 0 +accept(3, NULL, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set) +--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=21181, si_uid=998, si_status=0, si_utime=0, si_stime=0} --- +wait4(0, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG|WSTOPPED, NULL) = 21181 +wait4(0, 0x7ffe6bc36764, WNOHANG|WSTOPPED, NULL) = -1 ECHILD (No child processes) +rt_sigaction(SIGCHLD, {sa_handler=0x55d244bdb690, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7faa47ab9840}, {sa_handler=0x55d244bdb690, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7faa47ab9840}, 8) = 0 +rt_sigreturn({mask=[]}) = 43 +accept(3, NULL, NULL) = 4 +clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7faa47c44810) = 21200 +close(4) = 0 +accept(3, NULL, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set) +--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=21200, si_uid=998, si_status=111, si_utime=0, si_stime=0} --- +wait4(0, [{WIFEXITED(s) && WEXITSTATUS(s) == 111}], WNOHANG|WSTOPPED, NULL) = 21200 +wait4(0, 0x7ffe6bc36764, WNOHANG|WSTOPPED, NULL) = -1 ECHILD (No child processes) +rt_sigaction(SIGCHLD, {sa_handler=0x55d244bdb690, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7faa47ab9840}, {sa_handler=0x55d244bdb690, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7faa47ab9840}, 8) = 0 +rt_sigreturn({mask=[]}) = 43 +accept(3, NULL, NULL +``` + +(最后一个 `accept` 调用没有在追踪期间完成。)不幸的是,这次追踪没有包含我们想要的错误信息。我们没有观察到 `bcrontan` 往套接字发送或接受的任何信息。然而,我们看到了很多进程管理操作(`clone`、`wait4`、`SIGCHLD`,等等)。这个进程产生了子进程,我们猜测真实的工作是由子进程完成的。如果我们想捕获子进程的追踪信息,就必须往 `strace` 追加 `-f` 参数。以下是我们最终使用 `strace -f -o /tmp/trace -p 20629` 找到的错误信息: + +``` +21470 openat(AT_FDCWD, "tmp/spool.21470.1573692319.854640", O_RDWR|O_CREAT|O_EXCL, 0600) = -1 EACCES (Permission denied) +21470 write(1, "32:ZCould not create temporary f"..., 36) = 36 +21470 write(2, "bcron-spool[21470]: Fatal: logs:"..., 84) = 84 +21470 unlink("tmp/spool.21470.1573692319.854640") = -1 ENOENT (No such file or directory) +21470 exit_group(111) = ? +21470 +++ exited with 111 +++ +``` + +现在我们知道了进程 ID 21470 在尝试创建文件 `tmp/spool.21470.1573692319.854640` (相对于当前的工作目录)时得到了一个没有权限的错误。如果我们知道当前的工作目录,就可以得到完整路径并能指出为什么该进程无法在此处创建临时文件。不幸的是,这个进程已经退出了,所以我们不能使用 `lsof -p 21470` 去找出当前的工作目录,但是我们可以往前追溯,查找进程 ID 21470 使用哪个系统调用改变了它的工作目录。这个系统调用是 `chdir`(可以在搜索引擎很轻松地找到)。以下是一直往前追溯到服务器进程 ID 20629 的结果: + +``` +20629 clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7faa47c44810) = 21470 +... +21470 execve("/usr/sbin/bcron-spool", ["bcron-spool"], 0x55d2460807e0 /* 27 vars */) = 0 +... +21470 chdir("/var/spool/cron") = 0 +... +21470 openat(AT_FDCWD, "tmp/spool.21470.1573692319.854640", O_RDWR|O_CREAT|O_EXCL, 0600) = -1 EACCES (Permission denied) +21470 write(1, "32:ZCould not create temporary f"..., 36) = 36 +21470 write(2, "bcron-spool[21470]: Fatal: logs:"..., 84) = 84 +21470 unlink("tmp/spool.21470.1573692319.854640") = -1 ENOENT (No such file or directory) +21470 exit_group(111) = ? +21470 +++ exited with 111 +++ +``` + +(如果你在这里迷糊了,你可能需要阅读 [我之前有关 \*nix 进程管理和 shell 的文章][9]) + +现在 PID 为 20629 的服务器进程没有权限在 `/var/spool/cron/tmp/spool.21470.1573692319.854640` 创建文件。最可能的原因就是典型的 *nix 文件系统权限设置。让我们检查一下: + +``` +# ls -ld /var/spool/cron/tmp/ +drwxr-xr-x 2 root root 4096 Nov 6 05:33 /var/spool/cron/tmp/ +# ps u -p 20629 +USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND +cron 20629 0.0 0.0 2276 752 ? Ss Nov14 0:00 unixserver -U /var/run/bcron-spool -- bcron-spool +``` + +这就是问题所在!这个服务进程以 `cron` 用户运行,但是只有 `root` 用户才有向 `/var/spool/cron/tmp/` 目录写入的权限。一个简单 `chown cron /var/spool/cron/tmp/` 命令就能让 `bcron` 正常工作。(如果不是这个问题,那么下一个最有可能的怀疑对象是诸如 SELinux 或者 AppArmor 之类的内核安全模块,因此我将会使用 `dmesg` 检查内核日志。) + +### 总结 + +最初,系统调用追踪可能会让人不知所措,但是我希望我已经证明它们是调试一整套常见部署问题的快速方法。你可以设想一下尝试用单步调试器去调试多进程的 `bcron` 问题。 + +通过一连串的系统调用解决问题是需要练习的,但正如我说的那样,在大多数情况下,我只需要使用 `strace` 从下往上追踪并查找错误。不管怎样,`strace` 节省了我很多的调试时间。我希望这也对你有所帮助。 + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2019/11/14/deployment_debugging_strace.html + +作者:[Simon Arneaud][a] +选题:[lujun9972][b] +译者:[hanwckf](https://github.com/hanwckf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: https://strace.io/ +[2]: http://dtrace.org/blogs/about/ +[3]: https://man.openbsd.org/ktrace +[4]: https://theartofmachinery.com/images/strace/system_calls.svg +[5]: https://linux.die.net/man/1/ltrace +[6]: https://linux.die.net/man/1/strace +[7]: https://beej.us/guide/bgnet/html/index.html +[8]: https://untroubled.org/bcron/ +[9]: https://theartofmachinery.com/2018/11/07/writing_a_nix_shell.html diff --git a/published/201912/20191115 How to port an awk script to Python.md b/published/201912/20191115 How to port an awk script to Python.md new file mode 100644 index 0000000000..f163b2db42 --- /dev/null +++ b/published/201912/20191115 How to port an awk script to Python.md @@ -0,0 +1,201 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11654-1.html) +[#]: subject: (How to port an awk script to Python) +[#]: via: (https://opensource.com/article/19/11/awk-to-python) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +如何把 awk 脚本移植到 Python +====== + +> 将一个 awk 脚本移植到 Python 主要在于代码风格而不是转译。 + +![](https://img.linux.net.cn/data/attachment/album/201912/08/095256ko6xdfwooe8zctfz.jpg) + +脚本是解决问题的有效方法,而 awk 是编写脚本的出色语言。它特别擅长于简单的文本处理,它可以带你完成配置文件的某些复杂重写或目录中文件名的重新格式化。 + +### 何时从 awk 转向 Python + +但是在某些方面,awk 的限制开始显现出来。它没有将文件分解为模块的真正概念,它缺乏质量错误报告,并且缺少了现在被认为是编程语言工作原理的其他内容。当编程语言的这些丰富功能有助于维护关键脚本时,移植将是一个不错的选择。 + +我最喜欢的完美移植 awk 的现代编程语言是 Python。 + +在将 awk 脚本移植到 Python 之前,通常值得考虑一下其原始使用场景。例如,由于 awk 的局限性,通常从 Bash 脚本调用 awk 代码,其中包括一些对 `sed`、`sort` 之类的其它命令行常见工具的调用。 最好将所有内容转换为一个一致的 Python 程序。有时,脚本会做出过于宽泛的假设,例如,即使实际上只运行一个文件,该代码也可能允许任意数量的文件。 + +在仔细考虑了上下文并确定了要用 Python 替代的东西之后,该编写代码了。 + +### 标准 awk 到 Python 功能 + +以下 Python 功能是有用的,需要记住: + +``` +with open(some_file_name) as fpin: +    for line in fpin: +        pass # do something with line +``` + +此代码将逐行循环遍历文件并处理这些行。 + +如果要访问行号(相当于 awk 的 `NR`),则可以使用以下代码: + +``` +with open(some_file_name) as fpin: +    for nr, line in enumerate(fpin): +        pass # do something with line +``` + +### 在 Python 中实现多文件的 awk 式行为 + +如果你需要能够遍历任意数量的文件同时保持行数的持续计数(类似 awk 的 `FNR`),则此循环可以做到这一点: + +``` +def awk_like_lines(list_of_file_names): +    def _all_lines(): +        for filename in list_of_file_names: +            with open(filename) as fpin: +                yield from fpin +    yield from enumerate(_all_lines()) +``` + +此语法使用 Python 的*生成器*和 `yield from` 来构建*迭代器*,该迭代器将遍历所有行并保持一个持久计数。 + +如果你需要同时使用 `FNR` 和 `NR`,这是一个更复杂的循环: + +``` +def awk_like_lines(list_of_file_names): +    def _all_lines(): +        for filename in list_of_file_names: +            with open(filename) as fpin: +                yield from enumerate(fpin) +    for nr, (fnr, line) in _all_lines: +        yield nr, fnr, line +``` + +### 更复杂的 FNR、NR 和行数的 awk 行为 + +如果 `FNR`、`NR` 和行数这三个你全都需要,仍然会有一些问题。如果确实如此,则使用三元组(其中两个项目是数字)会导致混淆。命名参数可使该代码更易于阅读,因此最好使用 `dataclass`: + +``` +import dataclass + +@dataclass.dataclass(frozen=True) +class AwkLikeLine: +    content: str +    fnr: int +    nr: int + +def awk_like_lines(list_of_file_names): +    def _all_lines(): +        for filename in list_of_file_names: +            with open(filename) as fpin: +                yield from enumerate(fpin) +    for nr, (fnr, line) in _all_lines: +        yield AwkLikeLine(nr=nr, fnr=fnr, line=line) +``` + +你可能想知道,为什么不一直用这种方法呢?使用其它方式的的原因是总用这种方法太复杂了。如果你的目标是把一个通用库更容易地从 awk 移植到 Python,请考虑这样做。但是编写一个可以使你确切地了解特定情况所需的循环的方法通常更容易实现,也更容易理解(因而易于维护)。 + +### 理解 awk 字段 + +一旦有了与一行相对应的字符串,如果要转换 awk 程序,则通常需要将其分解为*字段*。Python 有几种方法可以做到这一点。这将把行按任意数量的连续空格拆分,返回一个字符串列表: + +``` +line.split() +``` + +如果需要另一个字段分隔符,比如以 `:` 分隔行,则需要 `rstrip` 方法来删除最后一个换行符: + +``` +line.rstrip("\n").split(":") +``` + +完成以下操作后,列表 `parts` 将存有分解的字符串: + +``` +parts = line.rstrip("\n").split(":") +``` + +这种拆分非常适合用来处理参数,但是我们处于[偏差一个的错误][2]场景中。现在 `parts[0]` 将对应于 awk 的 `$1`,`parts[1]` 将对应于 awk 的 `$2`,依此类推。之所以偏差一个,是因为 awk 计数“字段”从 1 开始,而 Python 从 0 开始计数。在 awk 中,`$0` 是整个行 —— 等同于 `line.rstrip("\n")`,而 awk 的 `NF`(字段数)更容易以 `len(parts)` 的形式得到。 + +### 移植 awk 字段到 Python + +例如,让我们将这个单行代码“[如何使用 awk 从文件中删除重复行][3]”转换为 Python。 + +`awk` 中的原始代码是: + +``` +awk '!visited[$0]++' your_file > deduplicated_file +``` + +“真实的” Python 转换将是: + +``` +import collections +import sys + +visited = collections.defaultdict(int) +for line in open("your_file"): +    did_visit = visited[line] +    visited[line] += 1 +    if not did_visit: +        sys.stdout.write(line) +``` + +但是,Python 比 awk 具有更多的数据结构。与其计数访问次数(除了知道是否看到一行,我们不使用它),为什么不记录访问的行呢? + +``` +import sys + +visited = set() +for line in open("your_file"): +    if line in visited: +        continue +    visited.add(line) +    sys.stdout.write(line) +``` + +### 编写 Python 化的 awk 代码 + +Python 社区提倡编写 Python 化的代码,这意味着它要遵循公认的代码风格。更加 Python 化的方法将区分*唯一性*和输入/输出的关注点。此更改将使对代码进行单元测试更加容易: + +``` +def unique_generator(things): +    visited = set() +    for thing in things: +        if thing in visited: +            continue +        visited.add(things) +        yield thing + +import sys +    +for line in unique_generator(open("your_file")): +    sys.stdout.write(line) +``` + +将所有逻辑置于输入/输出代码之外,可以更好地分离问题,并提高代码的可用性和可测试性。 + +### 结论:Python 可能是一个不错的选择 + +将 awk 脚本移植到 Python 时,通常是在考虑适当的 Python 代码风格时重新实现核心需求,而不是按条件/操作进行笨拙的音译。考虑原始上下文并产生高质量的 Python 解决方案。虽然有时候使用 awk 的 Bash 单行代码可以完成这项工作,但 Python 编码是通往更易于维护的代码的途径。 + +另外,如果你正在编写 awk 脚本,我相信您也可以学习 Python!如果你有任何疑问,请告诉我。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/awk-to-python + +作者:[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/OSDC_women_computing_4.png?itok=VGZO8CxT (Woman sitting in front of her laptop) +[2]: https://en.wikipedia.org/wiki/Off-by-one_error +[3]: https://opensource.com/article/19/10/remove-duplicate-lines-files-awk diff --git a/sources/tech/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md b/published/201912/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md similarity index 53% rename from sources/tech/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md rename to published/201912/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md index 85e70ba6a8..222e24b4c7 100644 --- a/sources/tech/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md +++ b/published/201912/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md @@ -1,40 +1,26 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11661-1.html) [#]: subject: (6 Methods to Quickly Check if a Website is up or down from the Linux Terminal) [#]: via: (https://www.2daygeek.com/linux-command-check-website-is-up-down-alive/) [#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) -6 Methods to Quickly Check if a Website is up or down from the Linux Terminal +在 Linux 终端快速检测网站是否宕机的 6 个方法 ====== -This tutorial shows you how to quickly check whether a given website is up (alive) or down from a Linux terminal. +> 本教程教你怎样在 Linux 终端快速检测一个网站是否宕机。 -You may already know some of these commands to verify about this, namely ping, curl, and wget. +![](https://img.linux.net.cn/data/attachment/album/201912/10/093801u332115oocxz4531.jpg) -But we have added some other commands as well in this tutorial. +你可能已经了解了一些类似的命令,像 `ping`、`curl` 和 `wget`。我们在本教程中又加入了一些其他命令。同时,我们也加入了不同的选项来检测单个和多个主机的信息。 -Also, we have added various options to check this information for single host and multiple hosts. +本文将帮助你检测网站是否宕机。但是如果你在维护一些网站,希望网站宕掉时得到实时的报警,我推荐你去使用实时网站监控工具。这种工具有很多,有些是免费的,大部分收费。根据你的需求,选择合适的工具。在后续的文章中我们会涉及这个主题。 -This article will help you to check whether the website is up or down. +### 方法 1:使用 fping 命令检测一个网站是否宕机 -But if you maintain some websites and want to get real-time alerts when the website is down. - -I recommend you to use real-time website monitoring tools. There are many tools for this, and some are free and most of them are paid. - -So choose the preferred one based on your needs. We will cover this topic in our upcoming article. - -### Method-1: How to Check if a Website is up or down Using the fping Command - -**[fping command][1]** is a program such as ping, which uses the Internet Control Message Protocol (ICMP) echo request to determine whether a target host is responding. - -fping differs from ping because it allows users to ping any number of host in parallel. Also, hosts can be entered from a text file. - -fping sends an ICMP echo request, moves the next target in a round-robin fashion, and does not wait until the target host responds. - -If a target host replies, it is noted as active and removed from the list of targets to check; if a target does not respond within a certain time limit and/or retry limit it is designated as unreachable. +[fping 命令][1] 是一个类似 `ping` 的程序,使用互联网控制消息协议(ICMP)的回应请求报文echo request来判断目标主机是否能回应。`fping` 与 `ping` 的不同之处在于它可以并行地 `ping` 任意数量的主机,也可以从一个文本文件读入主机名称。`fping` 发送一个 ICMP 回应请求后不等待目标主机响应,就以轮询模式向下一个目标主机发请求。如果一个目标主机有响应,那么它就被标记为存活的,然后从检查目标列表里去掉。如果一个目标主机在限定的时间和(或)重试次数内没有响应,则被指定为网站无法到达的。 ``` # fping 2daygeek.com linuxtechnews.com magesh.co.in @@ -44,15 +30,9 @@ linuxtechnews.com is alive magesh.co.in is alive ``` -### Method-2: How to Quickly Check Whether a Website is up or down Using the http Command +### 方法 2:使用 http 命令检测一个网站是否宕机 -HTTPie (pronounced aitch-tee-tee-pie) is a command line HTTP client. - -The **[httpie tool][2]** is a modern command line http client which makes CLI interaction with web services. - -It provides a simple http command that allows for sending arbitrary HTTP requests using a simple and natural syntax, and displays colorized output. - -HTTPie can be used for testing, debugging, and generally interacting with HTTP servers. +HTTPie(读作 aitch-tee-tee-pie)是一个命令行 HTTP 客户端。[httpie][2] 是一个可以与 web 服务通过 CLI 进行交互的现代工具。httpie 工具提供了简单的 `http` 命令,可以通过发送简单的、自然语言语法的任意 HTTP 请求得到多彩的结果输出。HTTPie 可以用来对 HTTP 服务器进行测试、调试和基本的交互。 ``` # http 2daygeek.com @@ -69,15 +49,9 @@ Transfer-Encoding: chunked Vary: Accept-Encoding ``` -### Method-3: How to Check if a Website is up or down Using the curl Command +### 方法 3:使用 curl 命令检测一个网站是否宕机 -**[curl command][3]** is a tool to transfer data from a server or to server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP). - -The command is designed to work without user interaction. - -Also curl support proxy support, user authentication, FTP upload, HTTP post, SSL connections, cookies, file transfer resume, Metalink, and more. - -curl is powered by libcurl for all transfer-related features. +[curl 命令][3] 是一个用于在服务器间通过支持的协议(DICT、FILE、FTP、FTPS、GOPHER、HTTP、HTTPS、IMAP、IMAPS、LDAP、LDAPS、POP3、POP3S、RTMP、RTSP、SCP、SFTP、SMTP、SMTPS、TELNET 和 TFTP)传输数据的工具。这个工具不支持用户交互。`curl` 也支持使用代理、用户认证、FTP 上传、HTTP POST 请求、SSL 连接、cookie、断点续传、Metalink 等等。`curl `由 libcurl 库提供所有与传输有关的能力。 ``` # curl -I https://www.magesh.co.in @@ -95,14 +69,14 @@ server: cloudflare cf-ray: 535b74123ca4dbf3-LHR ``` -Use the following curl command if you want to see only the HTTP status code instead of entire output. +如果你只想看 HTTP 状态码而不是返回的全部信息,用下面的 `curl` 命令: ``` # curl -I "www.magesh.co.in" 2>&1 | awk '/HTTP\// {print $2}' 200 ``` -If you want to see if a given website is up or down, use the following Bash script. +如果你想看一个网站是否宕机,用下面的 bash 脚本: ``` # vi curl-url-check.sh @@ -115,7 +89,7 @@ else fi ``` -Once you have added the above script to a file, run the file to see the output. +当你把脚本内容添加到一个文件后,执行文件,查看结果: ``` # sh curl-url-check.sh @@ -124,7 +98,7 @@ HTTP/2 200 magesh.co.in is up ``` -Use the following shell script if you want to see the status of multiple websites. +如果你想看多个网站的状态,使用下面的 shell 脚本: ``` # vi curl-url-check-1.sh @@ -141,7 +115,7 @@ echo "----------------------------------" done ``` -Once you have added the above script to a file, run the file to see the output. +当你把上面脚本内容添加到一个文件后,执行文件,查看结果: ``` # sh curl-url-check-1.sh @@ -156,13 +130,9 @@ www.xyzzz.com is down ---------------------------------- ``` -### Method-4: How to Quickly Check Whether a Website is up or down Using the wget Command +### 方法 4:使用 wget 命令检测一个网站是否宕机 -**[wget command][4]** (formerly known as Geturl) is a Free, open source, command line download tool which is retrieving files using HTTP, HTTPS and FTP, the most widely-used Internet protocols. - -It is a non-interactive command line tool and Its name is derived from World Wide Web and get. - -wget handle download pretty much good compared with other tools, futures included working in background, recursive download, multiple file downloads, resume downloads, non-interactive downloads & large file downloads. +[wget 命令][4](前身是 Geturl)是一个自由开源的命令行下载工具,通过 HTTP、HTTPS、FTP 和其他广泛使用的互联网协议获取文件。`wget` 是非交互式的命令行工具,由 World Wide Web 和 get 得名。`wget` 相对于其他工具来说更优秀,功能包括后台运行、递归下载、多文件下载、断点续传、非交互式下载和大文件下载。 ``` # wget -S --spider https://www.magesh.co.in @@ -190,14 +160,14 @@ Remote file exists and could contain further links, but recursion is disabled -- not retrieving. ``` -Use the following wget command if you want to see only the HTTP status code instead of entire output. +如果你只想看 HTTP 状态码而不是返回的全部结果,用下面的 `wget` 命令: ``` # wget --spider -S "www.magesh.co.in" 2>&1 | awk '/HTTP\// {print $2}' 200 ``` -If you want to see if a given website is up or down, use the following Bash script. +如果你想看一个网站是否宕机,用下面的 bash 脚本: ``` # vi wget-url-check.sh @@ -210,7 +180,7 @@ else fi ``` -Once you have added the above script to a file, run the file to see the output. +当你把脚本内容添加到一个文件后,执行文件,查看结果: ``` # wget-url-check.sh @@ -219,7 +189,7 @@ HTTP/1.1 200 OK Google.com is up ``` -Use the following shell script if you want to see the status of multiple websites. +如果你想看多个网站的状态,使用下面的 shell 脚本: ``` # vi curl-url-check-1.sh @@ -236,7 +206,7 @@ echo "----------------------------------" done ``` -Once you have added the above script to a file, run the file to see the output. +当你把上面脚本内容添加到一个文件后,执行文件,查看结果: ``` # sh wget-url-check-1.sh @@ -251,9 +221,9 @@ www.xyzzz.com is down ---------------------------------- ``` -### Method-5: How to Quickly Check Whether a Website is up or down Using the lynx Command +### 方法 5:使用 lynx 命令检测一个网站是否宕机 -**[lynx][5]** is a highly configurable text-based web browser for use on cursor-addressable character cell terminals. It’s the oldest web browser and it’s still in active development. +[lynx][5] 是一个在可寻址光标字符单元终端cursor-addressable character cell terminals上使用的基于文本的高度可配的 web 浏览器,它是最古老的 web 浏览器并且现在仍在活跃开发。 ``` # lynx -head -dump http://www.magesh.co.in @@ -272,14 +242,14 @@ Server: cloudflare CF-RAY: 535fc5704a43e694-LHR ``` -Use the following lynx command if you want to see only the HTTP status code instead of entire output. +如果你只想看 HTTP 状态码而不是返回的全部结果,用下面的 `lynx` 命令: ``` # lynx -head -dump https://www.magesh.co.in 2>&1 | awk '/HTTP\// {print $2}' 200 ``` -If you want to see if a given website is up or down, use the following Bash script. +如果你想看一个网站是否宕机,用下面的 bash 脚本: ``` # vi lynx-url-check.sh @@ -292,7 +262,7 @@ else fi ``` -Once you have added the above script to a file, run the file to see the output. +当你把脚本内容添加到一个文件后,执行文件,查看结果: ``` # sh lynx-url-check.sh @@ -301,7 +271,7 @@ HTTP/1.1 200 OK magesh.co.in is up ``` -Use the following shell script if you want to see the status of multiple websites. +如果你想看多个网站的状态,使用下面的 shell 脚本: ``` # vi lynx-url-check-1.sh @@ -318,7 +288,7 @@ echo "----------------------------------" done ``` -Once you have added the above script to a file, run the file to see the output. +当你把上面脚本内容添加到一个文件后,执行文件,查看结果: ``` # sh lynx-url-check-1.sh @@ -333,13 +303,9 @@ www.xyzzz.com is down ---------------------------------- ``` -### Method-6: How to Check if a Website is up or down Using the ping Command +### 方法 6:使用 ping 命令检测一个网站是否宕机 -**[ping command][1]** stands for (Packet Internet Groper) command is a networking utility that used to test the target of a host availability/connectivity on an Internet Protocol (IP) network. - -It’s verify a host availability by sending Internet Control Message Protocol (ICMP) Echo Request packets to the target host and waiting for an ICMP Echo Reply. - -It summarize statistical results based on the packets transmitted, packets received, packet loss, typically including the min/avg/max times. +[ping 命令][1](Packet Internet Groper)是网络工具的代表,用于在互联网协议(IP)的网络中测试一个目标主机是否可用/可连接。通过向目标主机发送 ICMP 回应请求报文包并等待 ICMP 回应响应报文来检测主机的可用性。它基于已发送的包、接收到的包和丢失了的包来统计结果数据,通常包含最小/平均/最大响应时间。 ``` # ping -c 5 2daygeek.com @@ -356,15 +322,9 @@ PING 2daygeek.com (104.27.157.177) 56(84) bytes of data. rtt min/avg/max/mdev = 170.668/213.824/250.295/28.320 ms ``` -### Method-7: How to Quickly Check Whether a Website is up or down Using the telnet Command +### 附加 1:使用 telnet 命令检测一个网站是否宕机 -The Telnet command is an old network protocol used to communicate with another host over a TCP/IP network using the TELNET protocol. - -It uses port 23 to connect to other devices, such as computer and network equipment. - -Telnet is not a secure protocol and is now not recommended to use because the data sent to the protocol is not encrypted and can be intercepted by hackers. - -Everyone uses SSH protocol instead of telnet, which is encrypted and very secure. +`telnet` 命令是一个使用 TELNET 协议用于 TCP/IP 网络中多个主机相互通信的古老的网络协议。它通过 23 端口连接其他设备如计算机和网络设备。`telnet` 是不安全的协议,现在由于用这个协议发送的数据没有经过加密可能被黑客拦截,所以不推荐使用。大家都使用经过加密且非常安全的 SSH 协议来代替 `telnet`。 ``` # telnet google.com 80 @@ -377,13 +337,11 @@ telnet> quit Connection closed. ``` -### Method-8: How to Check if a Website is up or down Using the Bash Script +### 附加 2:使用 bash 脚本检测一个网站是否宕机 -In simple words, a **[shell script][6]** is a file that contains a series of commands. The shell reads this file and executes the commands one by one as they are entered directly on the command line. +简而言之,一个 [shell 脚本][6] 就是一个包含一系列命令的文件。shell 从文件读取内容按输入顺序逐行在命令行执行。为了让它更有效,我们添加一些条件。这也减轻了 Linux 管理员的负担。 -To make this more useful we can add some conditions. This reduces the Linux admin task. - -If you want to see the status of multiple websites using the wget command, use the following shell script. +如果你想想用 `wget` 命令看多个网站的状态,使用下面的 shell 脚本: ``` # vi wget-url-check-2.sh @@ -399,7 +357,7 @@ fi done ``` -Once you have added the above script to a file, run the file to see the output. +当你把上面脚本内容添加到一个文件后,执行文件,查看结果: ``` # sh wget-url-check-2.sh @@ -409,7 +367,7 @@ google.co.in is up www.xyzzz.com is down ``` -If you want to see the status of multiple websites using the curl command, use the following **[bash script][7]**. +如果你想用 `wget` 命令看多个网站的状态,使用下面的 [shell 脚本][7]: ``` # vi curl-url-check-2.sh @@ -425,7 +383,7 @@ fi done ``` -Once you have added the above script to a file, run the file to see the output. +当你把上面脚本内容添加到一个文件后,执行文件,查看结果: ``` # sh curl-url-check-2.sh @@ -441,8 +399,8 @@ via: https://www.2daygeek.com/linux-command-check-website-is-up-down-alive/ 作者:[Magesh Maruthamuthu][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/201912/20191118 How internet security works- TLS, SSL, and CA.md b/published/201912/20191118 How internet security works- TLS, SSL, and CA.md new file mode 100644 index 0000000000..144fe836e8 --- /dev/null +++ b/published/201912/20191118 How internet security works- TLS, SSL, and CA.md @@ -0,0 +1,136 @@ +[#]: collector: (lujun9972) +[#]: translator: (hopefully2333) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11699-1.html) +[#]: subject: (How internet security works: TLS, SSL, and CA) +[#]: via: (https://opensource.com/article/19/11/internet-security-tls-ssl-certificate-authority) +[#]: author: (Bryant Son https://opensource.com/users/brson) + +互联网的安全是如何保证的:TLS、SSL 和 CA +====== + +> 你的浏览器里的锁的图标的后面是什么? + +![Lock][1] + +每天你都会重复这件事很多次,访问网站,网站需要你用你的用户名或者电子邮件地址和你的密码来进行登录。银行网站、社交网站、电子邮件服务、电子商务网站和新闻网站。这里只在使用了这种机制的网站中列举了其中一小部分。 + +每次你登录进一个这种类型的网站时,你实际上是在说:“是的,我信任这个网站,所以我愿意把我的个人信息共享给它。”这些数据可能包含你的姓名、性别、实际地址、电子邮箱地址,有时候甚至会包括你的信用卡信息。 + +但是你怎么知道你可以信任这个网站?换个方式问,为了让你可以信任它,网站应该如何保护你的交易? + +本文旨在阐述使网站变得安全的机制。我会首先论述 web 协议 http 和 https,以及传输层安全Transport Layer Security(TLS)的概念,后者是互联网协议Internet Protocol(IP)层中的加密协议之一。然后,我会解释证书颁发机构certificate authority和自签名证书,以及它们如何帮助保护一个网站。最后,我会介绍一些开源的工具,你可以使用它们来创建和管理你的证书。 + +### 通过 https 保护路由 + +了解一个受保护的网站的最简单的方式就是在交互中观察它,幸运的是,在今天的互联网上,发现一个安全的网站远远比找到一个不安全的网站要简单。但是,因为你已经在 Opensource.com 这个网站上了,我会使用它来作为案例,无论你使用的是哪个浏览器,你应该在你的地址栏旁边看到一个像锁一样的图标。点击这个锁图标,你应该会看见一些和下面这个类似的东西。 + +![Certificate information][2] + +默认情况下,如果一个网站使用的是 http 协议,那么它是不安全的。为通过网站主机的路由添加一个配置过的证书,可以把这个网站从一个不安全的 http 网站变为一个安全的 https 网站。那个锁图标通常表示这个网站是受 https 保护的。 + +点击证书来查看网站的 CA,根据你的浏览器,你可能需要下载证书来查看它。 + +![Certificate information][3] + +在这里,你可以了解有关 Opensource.com 证书的信息。例如,你可以看到 CA 是 DigiCert,并以 Opensource.com 的名称提供给 Red Hat。 + +这个证书信息可以让终端用户检查该网站是否可以安全访问。 + +> 警告:如果你没有在网站上看到证书标志,或者如果你看见的标志显示这个网站不安全——请不要登录或者做任何需要你个人数据的操作。这种情况非常危险! + +如果你看到的是警告标志,对于大多数面向公众开放的网站来说,这很少见,它通常意味着该证书已经过期或者是该证书是自签名的,而非通过一个受信任的第三方来颁发。在我们进入这些主题之前,我想解释一下 TLS 和 SSL。 + +### 带有 TLS 和 SSL 的互联网协议 + +TLS 是旧版安全套接字层协议Secure Socket Layer(SSL)的最新版本。理解这一点的最好方法就是仔细理解互联网协议的不同协议层。 + +![IP layers][4] + +我们知道当今的互联网是由 6 个层面组成的:物理层、数据链路层、网络层、传输层、安全层、应用层。物理层是基础,这一层是最接近实际的硬件设备的。应用层是最抽象的一层,是最接近终端用户的一层。安全层可以被认为是应用层的一部分,TLS 和 SSL,是被设计用来在一个计算机网络中提供通信安全的加密协议,它们位于安全层中。 + +这个过程可以确保终端用户使用网络服务时,通信的安全性和保密性。 + +### 证书颁发机构和自签名证书 + +证书颁发机构Certificate authority(CA)是受信任的组织,它可以颁发数字证书。 + +TLS 和 SSL 可以使连接更安全,但是这个加密机制需要一种方式来验证它;这就是 SSL/TLS 证书。TLS 使用了一种叫做非对称加密的加密机制,这个机制有一对称为私钥和公钥的安全密钥。(这是一个非常复杂的主题,超出了本文的讨论范围,但是如果你想去了解这方面的东西,你可以阅读“[密码学和公钥密码基础体系简介][5]”)你要知道的基础内容是,证书颁发机构们,比如 GlobalSign、DigiCert 和 GoDaddy,它们是受人们信任的可以颁发证书的供应商,它们颁发的证书可以用于验证网站使用的 TLS/SSL 证书。网站使用的证书是导入到主机服务器里的,用于保护网站。 + +然而,如果你只是要测试一下正在开发中的网站或服务,CA 证书可能对你而言太昂贵或者是太复杂了。你必须有一个用于生产目的的受信任的证书,但是开发者和网站管理员需要有一种更简单的方式来测试网站,然后他们才能将其部署到生产环境中;这就是自签名证书的来源。 + +自签名证书是一种 TLS/SSL 证书,是由创建它的人而非受信任的 CA 机构颁发的。用电脑生成一个自签名证书很简单,它可以让你在无需购买昂贵的 CA 颁发的证书的情况下测试一个安全网站。虽然自签名证书肯定不能拿到生产环境中去使用,但对于开发和测试阶段来说,这是一种简单灵活的方法。 + +### 生成证书的开源工具 + +有几种开源工具可以用来管理 TLS/SSL 证书。其中最著名的就是 openssl,这个工具包含在很多 Linux 发行版中和 MacOS 中。当然,你也可以使用其他开源工具。 + +| 工具名 | 描述 | 许可证 | +| --------- | ------------------------------------------------------------------------------ | --------------------------------- | +| [OpenSSL][7] | 实现 TLS 和加密库的最著名的开源工具 | Apache License 2.0 | +| [EasyRSA][8] | 用于构建 PKI CA 的命令行实用工具 | GPL v2 | +| [CFSSL][9] | 来自 cloudflare 的 PKI/TLS 瑞士军刀 | BSD 2-Clause "Simplified" License | +| [Lemur][10] | 来自网飞Netflix的 TLS 创建工具 | Apache License 2.0 | + +如果你的目的是扩展和对用户友好,网飞的 Lemur 是一个很有趣的选择。你在[网飞的技术博客][6]上可以查看更多有关它的信息。 + +### 如何创建一个 Openssl 证书 + +你可以靠自己来创建证书,下面这个案例就是使用 Openssl 生成一个自签名证书。 + +1、使用 `openssl` 命令行生成一个私钥: + +``` +openssl genrsa -out example.key 2048 +``` + +![](https://opensource.com/sites/default/files/uploads/4_openssl_generatekey.jpg) + +2、使用在第一步中生成的私钥来创建一个证书签名请求certificate signing request(CSR): + +``` +openssl req -new -key example.key -out example.csr -subj "/C=US/ST=TX/L=Dallas/O=Red Hat/OU=IT/CN=test.example.com" +``` + +![](https://opensource.com/sites/default/files/uploads/5_openssl_generatecsr.jpg) + +3、使用你的 CSR 和私钥创建一个证书: + +``` +openssl x509 -req -days 366 -in example.csr -signkey example.key -out example.crt +``` + +![](https://opensource.com/sites/default/files/uploads/6_openssl_generatecert.jpg) + +### 了解更多关于互联网安全的知识 + +如果你想要了解更多关于互联网安全和网站安全的知识,请看我为这篇文章一起制作的 Youtube 视频。 + +- + +你有什么问题?发在评论里让我们知道。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/internet-security-tls-ssl-certificate-authority + +作者:[Bryant Son][a] +选题:[lujun9972][b] +译者:[hopefully2333](https://github.com/hopefully2333) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/brson +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security-lock-password.jpg?itok=KJMdkKum +[2]: https://opensource.com/sites/default/files/uploads/1_certificatecheckwebsite.jpg +[3]: https://opensource.com/sites/default/files/uploads/2_certificatedisplaywebsite.jpg +[4]: https://opensource.com/sites/default/files/uploads/3_internetprotocol.jpg +[5]: https://opensource.com/article/18/5/cryptography-pki +[6]: https://medium.com/netflix-techblog/introducing-lemur-ceae8830f621 +[7]: https://www.openssl.org/ +[8]: https://github.com/OpenVPN/easy-rsa +[9]: https://github.com/cloudflare/cfssl +[10]: https://github.com/Netflix/lemur diff --git a/published/201912/20191119 Top 10 Vim plugins for programming in multiple languages.md b/published/201912/20191119 Top 10 Vim plugins for programming in multiple languages.md new file mode 100644 index 0000000000..a4a6d82093 --- /dev/null +++ b/published/201912/20191119 Top 10 Vim plugins for programming in multiple languages.md @@ -0,0 +1,138 @@ +[#]: collector: "lujun9972" +[#]: translator: "hello-wn" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11644-1.html" +[#]: subject: "Top 10 Vim plugins for programming in multiple languages" +[#]: via: "https://opensource.com/article/19/11/vim-plugins" +[#]: author: "Maxim Burgerhout https://opensource.com/users/wzzrd" + +多语言编程必备的十大 Vim 插件 +====== + +> 使用这 10 个 Vim 插件,可以让你在写代码或运维时,感觉更棒。 + +![](https://img.linux.net.cn/data/attachment/album/201912/05/062256bnauidfsf7155d1n.jpeg) + +我使用 [Vim][2] 文本编辑器大约 20 年了。有一段时间,我一直在定制我的 Vim 配置,但在只有在最近两年我才会使用插件。 + +最近,当我重新安装系统时(就像我经常做的那样),我觉得这是一次好的机会,我想找出多种编程语言环境下的最佳 Vim 插件,以及如何将这些插件和每种语言结合起来。 + +有时,我会为特定的语言和配置使用特定的插件(例如,我只在 Ansible 配置中安装 Rocannon),在此不细讲了。不过下面介绍的 10 个 Vim 插件都是我的最爱,无论使用哪种编程语言,我几乎都会使用它们。 + +### 1、Volt + +我的首选并不是一个插件,但是它可以替换类似于 [Vundle][3] 的插件,所以在此介绍。 + +[Volt][4] 是一个不依存于 Vim 的 Vim 插件管理器。你可以用它安装插件,并创建名为“profile”的插件组合。你可以使用一个简单的命令 `volt profile set myprofile` 启用新的配置。这样我可以做到这样的事情,如为 Python 配置单独启用 [indentpython][5] 插件。Volt 还提供了一种针对每个插件配置的简单方法,这些配置会在“profile”之间共享,因此只需要安装一次插件,就可以在多个“profile”之间使用。 + +Volt 还是相对较新且不够完美(比如,不管你想要使用多少个“profile”,每个插件只能有一个配置文件),但除此之外,我发现它非常方便、快速和简单。 + +![Volt plugin][6] + +### 2、Vim-Rainbow + +除了 Python,几乎所有的主流编程语言都使用括号(小括号、方括号和大括号)。通常,它们会嵌套使用多对括号,因此很难搞清楚某个括号的开闭区间。我发现自己经常要数小括号,尤其是在复杂的 Bash 脚本中,以确保无误。 + +这时候就需要 [vim-rainbow][7] 插件!它为每对括号设置不同的颜色,因此很容易识别出哪些括号是一对括号。它非常有用而且五彩斑斓。 + +![vim-rainbow plugin][8] + +### 3、lightline + +Vim 有很多这种插件,例如 [Powerline][9],它会在底部栏显示你正在处理的文件、光标所在的文件位置以及文件类型等信息。这些插件各有利弊,在简单比较后,我选择了 [lightline][10]。它相对较小,便于安装和扩展,并且不依赖于其他工具或插件。 + +![Lightline plugin][11] + +### 4、NERDTree + +[NERDTree][12] 是一个很经典的插件。在大型项目中,你可能很难找到想要编辑的内容所在文件的确切名称和路径。使用快捷键(我使用的是 `F7`,因为我在 `.vimrc` 中配置了这个快捷键),搜索窗会以垂直分屏的方式打开,就可以轻松找到所需文件并打开它。对于大型项目,这是必备插件。对于那些经常忘记文件名的人也很有用,比如我。 + +![NERDTree vim plugin][13] + +### 5、NERD Commenter + +程序员们在写代码时,有时会遇到一些难以调试的问题,导致他们想要注释或不执行某段代码。这时候就需要 [NERD Commenter][14] 出场了。选择代码段,按 `Leader 键 + cc`,代码就会被注释掉。(标准的 Vim Leader 键 是 `/` 字符。)按 `Leader 键 + cn`,取消注释。对于大多数文件类型,NERD Commenter 会自动使用正确的注释符。例如,如果你正在编辑 [BIND 区域文件][15],并将文件类型设置为 BIND 区域文件,Vim 会正确地使用 `;`(分号)字符进行注释。 + +![NERD Commenter][16] + +### 6、Solarized + +我喜欢我的 Vim 主题配色。我也喜欢终端的主题色。我一直在 Vim 上使用 [Solarized][17] 配色,并且将我的终端、文件夹配色和 Vim 设为一致。 + +但是,有时我会根据周边环境、屏幕亮度以及是否需要分享投屏,来切换明暗模式。 + +显然,你可以选择自己喜欢的任何配色方案,但我喜欢 `Solarized`,因为它有明暗模式功能,它可以简单快捷地切换两种模式。我的第二个选择是 [Monokai][18]。Volt 插件管理器让我可以轻松地在两者之间切换,因此我在 Python 编程时,使用 Monokai;Bash 编程时,使用 Solarized。 + +我没有给 Solarized 找相应的图片,因为本文中的所有其他图片都使用了 Solarized 中的浅色或深色效果,可以确认一下这些图片。 + +### 7、fzf + +当寻找一个文件时,有时你想要一个文件浏览器,有时你只想在键盘上敲打出与文件名模糊匹配的内容,对吗? + +[fzf][19](全称 “模糊查找器”)插件提供了这一功能。打出 `:FZF` 并输入文件名内容。不断缩短的列表将显示出与你输入的文件名内容相匹配的一些文件。我经常使用它,最近使用它的频率估计比使用 NERDTree 还多。缺点是这个插件依赖于 `fzf binary`,因此也必须安装这个依赖包。它适用于 Fedora、Debian 和 Arch,据我所知并不在 EPEL 中。 + +![fzf Vim plugin][20] + +### 8、ack + +有时,你需要搜索包含特定行或特定单词的文件。我真的很喜欢使用 [ack][21] 插件,最好与 `ag` 结合使用,它俩的组合又被称为 “[silver searcher][22]”。这一组合的速度非常快,覆盖了 `grep` 或 `vimgrep` 的绝大多数使用场景。缺点是你需要安装 `ack` 或 `ag` 才能正常运行。好消息是 Fedora 和 EPEL7 都可以使用 `ag` 和 `ack`。 + +![ack vim plugin][23] + +### 9、gitgutter + +大多数 IT 人员都使用 [Git][24] 和 Git 仓库中的文件进行工作。[gitgutter][25] 插件在行号附近添加了一列,通过符号显示该行的状态为:已更改(`~`)、已添加(`+`)或者已删除(`-`)。这有利于跟踪你所做的更改,并且可以使你专注于手头的任务,例如编写补丁来修复一个关键错误。 + +![gitgutter vim plugin][26] + +### 10、Tag List + +如果你在一个很大的文件中编写代码,会很容易忘记当前所在的位置,你可能需要上下滚动来查找某个功能。使用 [Tag List][27] 插件,只需要输入 `:Tlist`,就能垂直分屏显示出包含变量、类型、类和函数的代码,你可以轻松跳转到这些变量、类型、类和函数。这个功能对于多语言同样适用,例如 Java、Python 以及任何能够使用 `ctags` 功能的文件类型。 + +![Tag List vim plugin][28] + +以上介绍的 10 个 Vim 插件使我作为系统管理员和兼职程序员的生活变得更轻松。你正在使用哪些 Vim 插件?请在评论中分享你最爱的插件。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/vim-plugins + +作者:[Maxim Burgerhout][a] +选题:[lujun9972][b] +译者:[hello-wn][c] +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/wzzrd +[b]: https://github.com/lujun9972 +[c]: https://github.com/hello-wn +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openstack_python_vim_1.jpg?itok=lHQK5zpm "OpenStack source code (Python) in VIM" +[2]: https://www.vim.org/ +[3]: https://github.com/VundleVim/Vundle.vim +[4]: https://github.com/vim-volt/volt +[5]: https://github.com/vim-scripts/indentpython.vim +[6]: https://opensource.com/sites/default/files/uploads/vim-volt.gif "Volt plugin" +[7]: http://github.com/frazrepo/vim-rainbow +[8]: https://opensource.com/sites/default/files/uploads/vim-rainbox.png "vim-rainbow plugin" +[9]: https://github.com/powerline/powerline +[10]: http://github.com/itchyny/lightline.vim +[11]: https://opensource.com/sites/default/files/uploads/lightline.png "Lightline plugin" +[12]: http://github.com/scrooloose/nerdtree +[13]: https://opensource.com/sites/default/files/uploads/nerdtree.gif "NERDTree vim plugin" +[14]: http://github.com/scrooloose/nerdcommenter +[15]: https://en.wikipedia.org/wiki/Zone_file#File_format +[16]: https://opensource.com/sites/default/files/uploads/nerdcommenter.gif "NERD Commenter" +[17]: https://github.com/altercation/vim-colors-solarized +[18]: https://github.com/sickill/vim-monokai +[19]: https://github.com/junegunn/fzf.vim +[20]: https://opensource.com/sites/default/files/uploads/fzf.gif "fzf Vim plugin" +[21]: https://github.com/mileszs/ack.vim +[22]: https://github.com/ggreer/the_silver_searcher +[23]: https://opensource.com/sites/default/files/uploads/ack.gif "ack vim plugin" +[24]: https://opensource.com/resources/what-is-git +[25]: https://github.com/airblade/vim-gitgutter +[26]: https://opensource.com/sites/default/files/uploads/gitgutter.png "gitgutter vim plugin" +[27]: https://github.com/vim-scripts/taglist.vim +[28]: https://opensource.com/sites/default/files/uploads/taglist.gif "Tag List vim plugin) ) ) " diff --git a/published/201912/20191120 Switching from Python 2 to Python 3- What you need to know.md b/published/201912/20191120 Switching from Python 2 to Python 3- What you need to know.md new file mode 100644 index 0000000000..f89984a90c --- /dev/null +++ b/published/201912/20191120 Switching from Python 2 to Python 3- What you need to know.md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11629-1.html) +[#]: subject: (Switching from Python 2 to Python 3: What you need to know) +[#]: via: (https://opensource.com/article/19/11/end-of-life-python-2) +[#]: author: (Katie McLaughlin https://opensource.com/users/glasnt) + +从 Python 2 切换到 Python 3 你所需要了解的 +====== + +> Python 2 将在几周内走到生命终点,这篇文章是你迁移到 Python 3 之前应该知道的。 + +![](https://img.linux.net.cn/data/attachment/album/201912/01/095336lbppn8qp1nnnwqqp.jpg) + +从 2020 年 1 月 1 日开始,Python 2.7 将不再得到正式支持。在此日期之后,将会发布一个[最终错误修复][2]计划,但是仅此而已。 + +Python 2 的生命终点(EOL)对你意味着什么?如果正在运行着 Python 2,你需要迁移。 + +### 是谁决定 Python 2 的生命终点? + +在 [2012][3] 年,维护 Python 编程语言的团队审查了其选项。有两个越来越不同的代码库,Python 2 和 Python 3。这两者都很流行,但是较新的版本并未得到广泛采用。 + +除了 Python 3 中完全重写的 Unicode 支持改变了处理数据的底层方式造成的断层,这个主要版本的变化还一次性出现了一些非向后兼容的更改。这种断层的决定成文于 [2006 年][4]。为了减轻该断层的影响,Python 2 继续保持了维护,并向后移植了一些 Python 3 的功能。为了进一步帮助社区过渡,EOL 日期[从 2015 年延长至 2020 年][5],又延长了五年。 + +该团队知道,维护不同的代码库是必须解决的麻烦。最终,他们[宣布了][6]一项决定: + +>“我们是制作和照料 Python 编程语言的志愿者。我们已决定 2020 年 1 月 1 日将是我们停止使用 Python 2 的日子。这意味着在这一天之后,即使有人发现其中存在安全问题,我们也将不再对其进行改进。你应尽快升级到 Python 3。” + +[Nick Coghlan][7] 是 CPython 的核心开发人员,也是 Python 指导委员会的现任成员,[在他的博客中添加了更多信息][8]。由 [Barry Warsaw][10](也是 Python 指导委员会的成员)撰写的 [PEP 404][9] 详细说明了 Python 2.8 永远不会面世的原因。 + +### 有人还在支持 Python 2 吗? + +提供者和供应商对 Python 2 的支持会有所不同。[Google Cloud 宣布了][11]它计划未来如何支持 Python 2。红帽还[宣布了红帽企业 Linux(RHEL)的计划][12],而 AWS 宣布了 AWS 命令行界面和 [SDK][14] 的[次要版本更新要求][13]。 + +你还可以阅读 [Vicki Boykis][16] 在 Stack Overflow 撰写的博客文章“[为什么迁移到 Python 3 需要这么长时间?][15]”,其中她指出了采用 Python 3 缓慢的三个原因。 + +### 使用 Python 3 的原因 + +不管是否有持续的支持,尽快迁移到 Python 3 是一个好主意。Python 3 将继续受到支持,它具有 Python 2 所没有的一些非常优雅的东西。 + +最近发布的 [Python 3.8][17] 包含 [海象运算符][19]、[位置参数][20]和[自描述的格式化字符串][21]等[功能][18]。Python 3 的早期版本引入的[功能][22],例如 [异步 IO][23]、[格式化字符串][24]、[类型提示][25] 和 [pathlib][26],这里只提及了一点点。 + +下载最多的前 360 个软件包[已迁移到 Python 3][27]。你可以使用 [caniusepython3][28] 软件包检查你的 `requirements.txt` 文件,以查看你依赖的任何软件包是否尚未迁移。 + +### 将 Python 2 移植到 Python 3 的参考资源 + +有许多参考资源可简化你向 Python 3 的迁移。例如,“[将 Python 2 移植到 Python 3 指南][29]”列出了许多工具和技巧,可帮助你实现与 Python 2/3 单一源代码的兼容性。在 [Python3statement.org][30] 上也有一些有用的技巧。 + +[Dustin Ingram][31] 和 [Chris Wilcox][32] 在 [Cloud Next '19][33]上作了一个演讲,详细介绍了向 Python 3 过渡的一些动机和迁移模式。[Trey Hunner][34] 在 [PyCon 2018 演讲][35]上介绍了 Python 3 最有用的功能,鼓励你进行迁移,以便你可以利用它们。 + +### 加入我们! + +距 2020 年 1 月 1 日仅有几周了。如果你需要每天提醒一下它即将到来的时间(并且你使用 Twitter 的话),请关注 [Python 2 日落倒计时][36] Twitter 机器人。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/end-of-life-python-2 + +作者:[Katie McLaughlin][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/glasnt +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/govt_a%20new%20dawn.png?itok=b4zU-VAY (A sunrise) +[2]: https://www.python.org/dev/peps/pep-0373/#maintenance-releases +[3]: https://github.com/python/peps/commit/a733bc927acbca16bfa3de486fb2c7d3f767a748 +[4]: https://www.python.org/dev/peps/pep-3000/#compatibility-and-transition +[5]: https://github.com/python/peps/commit/f82462002b86feff36215b4230be28967039b0cc +[6]: https://www.python.org/doc/sunset-python-2/ +[7]: https://twitter.com/ncoghlan_dev +[8]: http://python-notes.curiousefficiency.org/en/latest/python3/questions_and_answers.html +[9]: https://www.python.org/dev/peps/pep-0404/ +[10]: https://twitter.com/pumpichank +[11]: https://cloud.google.com/python/docs/python2-sunset/?utm_source=osdc&utm_medium=blog&utm_campaign=pysunset +[12]: https://access.redhat.com/solutions/4455511 +[13]: https://aws.amazon.com/blogs/developer/deprecation-of-python-2-6-and-python-3-3-in-botocore-boto3-and-the-aws-cli/ +[14]: https://aws.amazon.com/sdk-for-python/ +[15]: https://stackoverflow.blog/2019/11/14/why-is-the-migration-to-python-3-taking-so-long/ +[16]: https://twitter.com/vboykis +[17]: https://www.python.org/downloads/ +[18]: https://docs.python.org/3.8/whatsnew/3.8.html +[19]: https://docs.python.org/3.8/whatsnew/3.8.html#assignment-expressions +[20]: https://docs.python.org/3.8/whatsnew/3.8.html#positional-only-parameters +[21]: https://docs.python.org/3.8/whatsnew/3.8.html#f-strings-support-for-self-documenting-expressions-and-debugging +[22]: https://docs.python.org/3.8/whatsnew/index.html +[23]: https://docs.python.org/3.8/library/asyncio.html#module-asyncio +[24]: https://docs.python.org/3.7/whatsnew/3.6.html#pep-498-formatted-string-literals +[25]: https://docs.python.org/3.7/whatsnew/3.5.html#pep-484-type-hints +[26]: https://docs.python.org/3.8/library/pathlib.html#module-pathlib +[27]: http://py3readiness.org/ +[28]: https://pypi.org/project/caniusepython3/ +[29]: https://docs.python.org/3/howto/pyporting.html +[30]: https://python3statement.org/practicalities/ +[31]: https://twitter.com/di_codes +[32]: https://twitter.com/chriswilcox47 +[33]: https://www.youtube.com/watch?v=Bye7Rms0Vgw&utm_source=osdc&utm_medium=blog&utm_campaign=pysunset +[34]: https://twitter.com/treyhunner +[35]: https://www.youtube.com/watch?v=klaGx9Q_SOA +[36]: https://twitter.com/python2sunset diff --git a/sources/tech/20191121 Bash Script to View System Information on Linux Every Time You Log into Shell.md b/published/201912/20191121 Bash Script to View System Information on Linux Every Time You Log into Shell.md similarity index 51% rename from sources/tech/20191121 Bash Script to View System Information on Linux Every Time You Log into Shell.md rename to published/201912/20191121 Bash Script to View System Information on Linux Every Time You Log into Shell.md index 9efdc87ec1..74bca82720 100644 --- a/sources/tech/20191121 Bash Script to View System Information on Linux Every Time You Log into Shell.md +++ b/published/201912/20191121 Bash Script to View System Information on Linux Every Time You Log into Shell.md @@ -1,69 +1,63 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Bash Script to View System Information on Linux Every Time You Log into Shell) -[#]: via: (https://www.2daygeek.com/bash-shell-script-view-linux-system-information/) -[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) +[#]: collector: "lujun9972" +[#]: translator: "lxbwolf" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11645-1.html" +[#]: subject: "Bash Script to View System Information on Linux Every Time You Log into Shell" +[#]: via: "https://www.2daygeek.com/bash-shell-script-view-linux-system-information/" +[#]: author: "Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/" -Bash Script to View System Information on Linux Every Time You Log into Shell +Bash 脚本实现每次登录到 Shell 时可以查看 Linux 系统信息 ====== -There are several commands in Linux to obtain system information such as processor information, manufacturer name, and serial number, etc,. +Linux 中有很多可以查看系统信息如处理器信息、生产商名字、序列号等的命令。你可能需要执行多个命令来收集这些信息。同时,记住所有的命令和他们的选项也是有难度。 -You may need to run several commands to collect this information. +你可以写一个 [shell 脚本](https://www.2daygeek.com/category/shell-script/) 基于你的需求来自定义显示的信息。 -Also, it is very difficult to remember all the commands and their options. +以前我们出于不同的目的需要写很多个 [bash 脚本](https://www.2daygeek.com/category/bash-script/)。 -Instead you can write a **[shell script][1]** to customize the output based on your needs. +现在我们写一个新的 shell 脚本,在每次登录到 shell 时显示需要的系统信息。 -In the past we have written many **[bash scripts][2]** for a variety of purposes. +这个j脚本有 6 部分,细节如下: -Today, we came up with a new shell script, which shows you the required system information every time you log into the shell. +1. 通用系统信息 +2. CPU/内存当前使用情况 +3. 硬盘使用率超过 80% +4. 列出系统 WWN 详情 +5. Oracle DB 实例 +6. 可更新的包 -There are six parts to this script, and more details below. +我们已经基于我们的需求把可能需要到的信息加到了每个部分。之后你可以基于自己的意愿修改这个脚本。 - * **Part-1:** General System Information - * **Part-2:** CPU/Memory Current Usage - * **Part-3:** Disk Usage >80% - * **Part-4:** List System WWN Details - * **Part-5:** Oracle DB Instances - * **Part-6:** Available Package Updates +这个j脚本需要用到很多工具,其中大部分我们之前已经涉及到了。 +你可以参照以前文章,了解工具详情。 +* [inxi – 在 Linux 上检查硬件信息的绝佳工具][3] +* [Dmidecode – 获取 Linux 系统硬件信息的简便方法][4] +* [LSHW(硬件列表程序)– 在 Linux 上获取硬件信息的漂亮工具][5] +* [hwinfo(硬件信息)– 在 Linux 上检测系统硬件信息的漂亮工具][6] +* [python-hwinfo:使用标准 Linux 实用工具显示硬件信息摘要][7] +* [如何使用 lspci、lsscsi、lsusb 和 lsblk 获取 Linux 系统设备信息][8] +* [如何在 Linux 中检查系统硬件制造商、型号和序列号][9] +* [如何在 Linux 中查找 HBA 卡的 WWN、WWNN 和 WWPN 号][10] +* [如何从 Linux 命令行检查 HP iLO 固件版本][11] +* [如何从 Linux 命令行检查无线网卡和 WiFi 信息][12] +* [如何在 Linux 上检查 CPU 和硬盘温度][13] +* [Hegemon – Linux 的模块化系统和硬件监视工具][14] +* [如何在 Linux 上检查系统配置和硬件信息][15] -We’ve added potential information to each area based on our needs. You can further customize this script to your needs if you wish. +如果你想为这个脚本增加其他的信息,请在评论去留下你的需求,以便我们帮助你。 -There are many tools for this, most of which we have already covered. +### Bash 脚本实现每次登录到 Shell 时可以查看 Linux 系统信息 -To read them, go to the following articles. - - * **[inxi – A Great Tool to Check Hardware Information on Linux][3]** - * **[Dmidecode – Easy Way To Get Linux System Hardware Information][3]** - * **[LSHW (Hardware Lister) – A Nifty Tool To Get A Hardware Information On Linux][3]** - * **[hwinfo (Hardware Info) – A Nifty Tool To Detect System Hardware Information On Linux][3]** - * **[python-hwinfo : Display Summary Of Hardware Information Using Standard Linux Utilities][3]** - * **[How To Use lspci, lsscsi, lsusb, And lsblk To Get Linux System Devices Information][3]** - * **[How To Check System Hardware Manufacturer, Model And Serial Number In Linux][3]** - * **[How To Find WWN, WWNN and WWPN Number Of HBA Card In Linux][3]** - * **[How to check HP iLO Firmware version from Linux command line][3]** - * **[How to check Wireless network card and WiFi information from Linux Command Line][3]** - * **[How to check CPU & Hard Disk temperature on Linux][3]** - * **[Hegemon – A modular System & Hardware monitoring tool for Linux][3]** - * **[How to Check System Configuration and Hardware Information on Linux][3]** - - - -If anyone wants to add any other information in the script, please let us know your requirements in the comment section so that we can help you. - -### Bash Script to View System Information on Linux Every Time You Log into the Shell - -This basic script will bring the system information to your terminal whenever you log into the shell. +这个脚本会在你每次登录 shell 时把系统信息打印到 terminal。 ``` -#vi /opt/scripts/system-info.sh +# vi /opt/scripts/system-info.sh +``` +``` #!/bin/bash echo -e "-------------------------------System Information----------------------------" echo -e "Hostname:\t\t"`hostname` @@ -90,12 +84,12 @@ df -Ph | sed s/%//g | awk '{ if($5 > 80) print $0;}' echo "" echo -e "-------------------------------For WWN Details-------------------------------" -vserver=$(lscpu | grep vendor | wc -l) +vserver=$(lscpu | grep Hypervisor | wc -l) if [ $vserver -gt 0 ] then echo "$(hostname) is a VM" else -systool -c fc_host -v | egrep "(Class Device path | port_name |port_state)" > systool.out +cat /sys/class/fc_host/host?/port_name fi echo "" @@ -120,41 +114,37 @@ echo -e "----------------------------------------------------------------------- fi ``` -Once the above script is added to a file. Set the executable permission for the “system-info.sh” file. +把上面脚本内容保存到一个文件 `system-info.sh`,之后添加可执行权限: ``` # chmod +x ~root/system-info.sh ``` -When the script is ready, add the file path at the end of the “.bash_profile” file in RHEL-based systems CentOS, Oracle Linux and Fedora. +当脚本准备好后,把脚本文件的路径加到 `.bash_profile` 文件末尾(红帽系列的系统:CentOS、Oracle Linux 和 Fedora): ``` # echo "/root/system-info.sh" >> ~root/.bash_profile ``` -To take this change effect, run the following command. +执行以下命令,来让修改的内容生效: ``` # source ~root/.bash_profile ``` -For Debian-based systems, you may need to add a file path to the “.profile” file. +对于 Debian 系统的系统,你可能需要把文件路径加到 `.profile` 文件中: ``` # echo "/root/system-info.sh" >> ~root/.profile ``` -Run the following command to take this change effect. +运行以下命令使修改生效: ``` # source ~root/.profile ``` -You may have seen an output like the one below when running the above “source” command. - -From next time on-wards, you will get this information every time you log into the shell. - -Alternatively, you can manually run this script at any time if you need to. +你以前运行上面 `source` 命令时可能见过类似下面的输出。从下次开始,你在每次登录 shell 时会看到这些信息。当然,如果有必要你也可以随时手动执行这个脚本。 ``` -------------------------------System Information--------------------------- @@ -206,8 +196,8 @@ via: https://www.2daygeek.com/bash-shell-script-view-linux-system-information/ 作者:[Magesh Maruthamuthu][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -216,3 +206,15 @@ via: https://www.2daygeek.com/bash-shell-script-view-linux-system-information/ [1]: https://www.2daygeek.com/category/shell-script/ [2]: https://www.2daygeek.com/category/bash-script/ [3]: https://www.2daygeek.com/inxi-system-hardware-information-on-linux/ +[4]: https://www.2daygeek.com/dmidecode-get-print-display-check-linux-system-hardware-information/ +[5]: https://www.2daygeek.com/lshw-find-check-system-hardware-information-details-linux/ +[6]: https://www.2daygeek.com/hwinfo-check-display-detect-system-hardware-information-linux/ +[7]: https://www.2daygeek.com/python-hwinfo-check-display-system-hardware-configuration-information-linux/ +[8]: https://www.2daygeek.com/check-system-hardware-devices-bus-information-lspci-lsscsi-lsusb-lsblk-linux/ +[9]: https://www.2daygeek.com/how-to-check-system-hardware-manufacturer-model-and-serial-number-in-linux/ +[10]: https://www.2daygeek.com/how-to-find-wwn-wwnn-and-wwpn-number-of-hba-card-in-linux/ +[11]: https://www.2daygeek.com/how-to-check-hp-ilo-firmware-version-from-linux-command-line/ +[12]: https://www.2daygeek.com/linux-find-out-wireless-network-wifi-speed-signal-strength-quality/ +[13]: https://www.2daygeek.com/view-check-cpu-hard-disk-temperature-linux/ +[14]: https://www.2daygeek.com/hegemon-a-modular-system-and-hardware-monitoring-tool-for-linux/ +[15]: https://www.2daygeek.com/check-linux-hardware-information-system-configuration/ diff --git a/published/201912/20191125 How to Install Ansible (Automation Tool) on CentOS 8-RHEL 8.md b/published/201912/20191125 How to Install Ansible (Automation Tool) on CentOS 8-RHEL 8.md new file mode 100644 index 0000000000..9128c142b5 --- /dev/null +++ b/published/201912/20191125 How to Install Ansible (Automation Tool) on CentOS 8-RHEL 8.md @@ -0,0 +1,200 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11633-1.html) +[#]: subject: (How to Install Ansible (Automation Tool) on CentOS 8/RHEL 8) +[#]: via: (https://www.linuxtechi.com/install-ansible-centos-8-rhel-8/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +如何在 CentOS 8/RHEL 8 上安装 Ansible(自动化工具) +====== + +Ansible 是给 Linux 系统管理员使用的出色自动化工具。它是一种开源配置工具,能让系统管理员可以从一个中心节点(即 Ansible 服务器)管理数百台服务器。将 Ansible 与 Puppet、Chef 和 Salt 等类似工具进行比较时,它是首选的配置工具,因为它不需要任何代理,并且可以工作在 SSH 和 python 上。 + +![](https://img.linux.net.cn/data/attachment/album/201912/01/223012czkxt6dhku6snhxn.jpg) + +在本教程中,我们将学习如何在 CentOS 8 和 RHEL 8 系统上安装和使用 Ansble。 + +Ansible 实验环境信息: + +* 最小化安装的 CentOS 8 / RHEL 8 服务器(192.168.1.10),且有互联网连接 +* 两个 Ansible 节点 - Ubuntu 18.04 LTS (192.168.1.20) 和 CentOS 7 (192.168.1.30) + +### CentOS 8 上的 Ansible 安装步骤 + +Ansible 包不在 CentOS 8 默认的软件包仓库中。因此,我们需要执行以下命令启用 [EPEL 仓库][3]: + +``` +[root@linuxtechi ~]$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y +``` + +启用 epel 仓库后,执行以下 `dnf` 命令安装 Ansible: + +``` +[root@linuxtechi ~]$ sudo dnf install ansible +``` + +上面命令的输出: + +![dnf-install-ansible-centos8][4] + +成功安装 Ansible 后,运行以下命令验证它的版本: + +``` +[root@linuxtechi ~]$ sudo ansible --version +``` + +![Ansible-version-CentOS8][5] + +上面的输出确认在 CentOS 8 上安装完成。 + +让我们看下 RHEL 8 系统。 + +### RHEL 8 上的 Ansible 安装步骤 + +如果你有有效的 RHEL 8 订阅,请使用以下订阅管理器命令启用 Ansble 仓库: + +``` +[root@linuxtechi ~]$ sudo subscription-manager repos --enable ansible-2.8-for-rhel-8-x86_64-rpms +``` + +启用仓库后,执行以下 `dnf` 命令安装 Ansible: + +``` +[root@linuxtechi ~]$ sudo dnf install ansible -y +``` + +安装 Ansible 及其依赖包后,执行以下命令来验证它的版本: + +``` +[root@linuxtechi ~]$ sudo ansible --version +``` + +### 在 CentOS 8 / RHEL 8 上通过 pip3 安装 Ansible 的可选方法 + +如果你希望使用 `pip`(Python 的包管理器)安装 Ansible,请首先使用以下命令安装 pyhton3 和 python3-pip 包: + +``` +[root@linuxtechi ~]$ sudo dnf install python3 python3-pip -y +``` + +安装 python3 后,运行以下命令来验证它的版本: + +``` +[root@linuxtechi ~]$ python3 -V +Python 3.6.8 +[root@linuxtechi ~]$ +``` + +用下面的 `pip3` 命令安装 Ansible: + +``` +[root@linuxtechi ~]$ pip3 install ansible --user +``` + +输出: + +![Ansible-Install-pip3-centos8][6] + +上面的输出确认 Ansible 已成功使用 `pip3` 安装。让我们看下如何使用 Ansible。 + +### 如何使用 Ansible 自动化工具? + +当我们使用 `yum` 或 `dnf` 命令安装 Ansible 时,它的配置文件、清单文件和角色目录会自动在 `/etc/ansible` 文件夹下创建。 + +让我们添加一个名称为 `labservers` 的组,并在 `/etc/ansible/hosts` 文件中给该组添加上述的 Ubuntu 18.04 和 CentOS 7 系统的 IP 地址: + +``` +[root@linuxtechi ~]$ sudo vi /etc/ansible/hosts +… +[labservers] +192.168.1.20 +192.168.1.30 +… +``` + +保存并退出文件。 + +更新清单文件(`/etc/ansible/hosts`)后,将用户的 ssh 公钥放到属于 `labservers` 组的远程系统。 + +让我们首先使用 `ssh-keygen` 命令生成本地用户的公钥和私钥: + +``` +[root@linuxtechi ~]$ ssh-keygen +``` + +现在使用以下命令在 Ansible 服务器及其客户端之间交换公钥: + +``` +[root@linuxtechi ~]$ ssh-copy-id root@linuxtechi +[root@linuxtechi ~]$ ssh-copy-id root@linuxtechi +``` + +现在,让我们尝试几个 Ansible 命令,首先使用 `ping` 模块验证 Ansible 服务器与客户端的连接: + +``` +[root@linuxtechi ~]$ ansible -m ping "labservers" +``` + +注意: 如果我们没有在上面的命令中指定清单文件,那么它将引用默认主机文件(即 `/etc/ansible/hosts`)。 + +输出: + +![ansible-ping-module-centos8][7] + +让我们使用 Ansible shell 命令检查每个客户端的内核版本: + +``` +[root@linuxtechi ~]$ ansible -m command -a "uname -r" "labservers" +192.168.1.30 | CHANGED | rc=0 >> +4.15.0-20-generic +192.168.1.20 | CHANGED | rc=0 >> +3.10.0-327.el7.x86_64 +[root@linuxtechi ~]$ +``` + +使用以下命令列出清单文件中的所有主机: + +``` +[root@linuxtechi ~]$ ansible all -i /etc/ansible/hosts --list-hosts + hosts (4): + 192.168.100.1 + 192.168.100.10 + 192.168.1.20 + 192.168.1.30 +[root@linuxtechi ~]$ +``` + +使用以下 Ansible 命令仅列出 `labservers` 组中的主机: + +``` +root@linuxtechi ~]$ ansible labservers -i /etc/ansible/hosts --list-hosts + hosts (2): + 192.168.1.20 + 192.168.1.30 +[root@linuxtechi ~]$ +``` + +本文就是这些了,我们成功演示了如何在 CentOS 8 和 RHEL 8 系统中安装和使用 Ansible。请分享你的反馈和意见。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/install-ansible-centos-8-rhel-8/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: http://www.linuxtechi.com/wp-content/uploads/2019/11/Install-Ansible-CentOS8-RHEL8.png +[3]: http://www.linuxtechi.com/enable-epel-repo-centos8-rhel8-server/ +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/11/dnf-install-ansible-centos8-1536x652.png +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Ansible-version-CentOS8.png +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Ansible-Install-pip3-centos8-1536x545.png +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/11/ansible-ping-module-centos8.png diff --git a/published/201912/20191125 How to use loops in awk.md b/published/201912/20191125 How to use loops in awk.md new file mode 100644 index 0000000000..35c2b33d7a --- /dev/null +++ b/published/201912/20191125 How to use loops in awk.md @@ -0,0 +1,153 @@ +[#]: collector: "lujun9972" +[#]: translator: "lxbwolf" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11636-1.html" +[#]: subject: "How to use loops in awk" +[#]: via: "https://opensource.com/article/19/11/loops-awk" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" + +在 awk 中怎么使用循环 +====== + +> 来学习一下多次执行同一条命令的不同类型的循环。 + +![](https://img.linux.net.cn/data/attachment/album/201912/02/232951h3ibohlh77bk77d7.jpg) + +`awk` 脚本有三个主要部分:`BEGIN` 和 `END` 函数(都可选),用户自己写的每次要执行的函数。某种程度上,`awk` 的主体部分就是一个循环,因为函数中的命令对每一条记录都会执行一次。然而,有时你希望对于一条记录执行多次命令,那么你就需要用到循环。 + +有多种类型的循环,分别适合不同的场景。 + +### while 循环 + +一个 `while` 循环检测一个表达式,如果表达式为 `true` 就执行命令。当表达式变为 `false` 时,循环中断。 + +``` +#!/bin/awk -f + +BEGIN { + # Loop through 1 to 10 + + i=1; + while (i <= 10) { + print i, " to the second power is ", i*i; + i = i+1; + } +exit; +} +``` + +在这个简单实例中,`awk` 打印了放在变量 `i` 中的整数值的平方。`while (i <= 10)` 语句告诉 `awk` 仅在 `i` 的值小于或等于 10 时才执行循环。在循环最后一次执行时(`i` 的值是 10),循环终止。 + +### do-while 循环 + +do-while 循环执行在关键字 `do` 之后的命令。在每次循环结束时检测一个测试表达式来决定是否终止循环。仅在测试表达式返回 `true` 时才会重复执行命令(即还没有到终止循环的条件)。如果测试表达式返回 `false`,因为到了终止循环的条件所以循环被终止。 + +``` +#!/usr/bin/awk -f +BEGIN { + + i=2; + do { + print i, " to the second power is ", i*i; + i = i + 1 + } + while (i < 10) + +exit; +} +``` + +### for 循环 + +`awk` 中有两种 `for` 循环。 + +一种 `for` 循环初始化一个变量,检测一个测试表达式,执行变量递增,当表达式的结果为 `true` 时循环就会一直执行。 + +``` +#!/bin/awk -f + +BEGIN { + for (i=1; i <= 10; i++) { + print i, " to the second power is ", i*i; + } +exit; +} +``` + +另一种 `for` 循环设置一个有连续索引的数组变量,对每一个索引执行一个命令集。换句话说,它用一个数组“收集”每一条命令执行后的结果。 + +本例实现了一个简易版的 Unix 命令 `uniq`。通过把一系列字符串作为键加到数组 `a` 中,当相同的键再次出现时就增加键值,可以得到某个字符串出现的次数(就像 `uniq` 的 `--count` 选项)。如果你打印该数组的所有键,将会得到出现过的所有字符串。 + +用演示文件 `colours.txt`(前一篇文章中的文件)来举例: + +``` +name       color  amount +apple      red    4 +banana     yellow 6 +raspberry  red    99 +strawberry red    3 +grape      purple 10 +apple      green  8 +plum       purple 2 +kiwi       brown  4 +potato     brown  9 +pineapple  yellow 5 +``` + +这是 `awk` 版的简易 `uniq -c`: + +``` +#! /usr/bin/awk -f + +NR != 1 { +    a[$2]++ +} +END { +    for (key in a) { +                print a[key] " " key +    } +} +``` + +示例数据文件的第三列是第一列列出的条目的计数。你可以用一个数组和 `for` 循环来按颜色统计第三列的条目。 + +``` +#! /usr/bin/awk -f + +BEGIN { +    FS=" "; +    OFS="\t"; +    print("color\tsum"); +} +NR != 1 { +    a[$2]+=$3; +} +END { +    for (b in a) { +        print b, a[b] +    } +} +``` + +你可以看到,在处理文件之前也需要在 `BEFORE` 函数(仅仅执行一次)中打印一列表头。 + +### 循环 + +在任何编程语言中循环都是很重要的一部分,`awk` 也不例外。使用循环你可以控制 `awk` 脚本怎样去运行,它可以统计什么信息,还有它怎么去处理你的数据。我们下一篇文章会讨论 `switch`、`continue` 和 `next` 语句。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/loops-awk + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fail_progress_cycle_momentum_arrow.png?itok=q-ZFa_Eh "arrows cycle symbol for failing faster" +[2]: http://hackerpublicradio.org/eps.php?id=2330 diff --git a/published/201912/20191125 The many faces of awk.md b/published/201912/20191125 The many faces of awk.md new file mode 100644 index 0000000000..53ac02c910 --- /dev/null +++ b/published/201912/20191125 The many faces of awk.md @@ -0,0 +1,225 @@ +[#]: collector: (lujun9972) +[#]: translator: (luuming) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11658-1.html) +[#]: subject: (The many faces of awk) +[#]: via: (https://www.networkworld.com/article/3454979/the-many-faces-of-awk.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +千面 awk +====== + +> `awk` 命令不仅提供了简单的输入字符串筛选功能,还包含提取数据列、打印简单文本、筛选内容——甚至做一些数学计算。 + +![Thinkstock][6] + +如果你仅使用 `awk` 选取一行中的特定文本,那么你可能错过了它的很多功能。在这篇文章中,我们会来看看使用 `awk` 可以帮你做一些其他的什么事情,并提供一些例子。 + +### 提取数据列 + +`awk` 所提供的最简单与最常用的功能便是从文件或管道传输的数据中选取特定的内容。默认使用空格当做分隔符,这非常简单。 + +``` +$ echo one two three four five | awk ‘{print $4}’ +four +$ who | awk ‘{print $1}’ +jdoe +fhenry +``` + +空格指的是一系列的 `space` 或 `tab` 字符。在下面所展示的命令里,`awk` 从提供的数据中筛选第一和第四项。 + +`awk` 命令也可以通过在其后增加文件名参数的方式从文本文件中获取数据。 + +``` +$ awk '{print $1,$5,$NF}' HelenKellerQuote +The beautiful heart. +``` + +(LCTT 译注:“The best and most beautiful things in the world can not be seen or even touched , they must be felt with heart.” ——海伦凯勒) + +在这个例子中,`awk` 挑选了一行中的第一个、第五个和最后一个字段。 + +命令中的 `$NF` 指定选取每行的最后一个字段。这是因为 `NF` 代表一行中的字段数量Number of Field,也就是 23,而 `$NF` 就代表着那个字段的值,也就是`heart`。最后的句号也包含进去了,因为它是最后一个字符串的一部分。 + +字段能以任何有用的形式打印。在这个例子中,我们将字段以日期的格式进行打印输出。 + +``` +$ date | awk '{print $4,$3,$2}' +2019 Nov 22 +``` + +如果你省略了 `awk` 命令中字段指示符之间的逗号,输出将会挤成一个字符串。 + +``` +$ date | awk '{print $4 $3 $2}' +2019Nov21 +``` + +如果你将通常使用的逗号替换为连字符,`awk` 就会尝试将两个字段的值相减——或许这并不是你想要的。它不会将连字符插入到输出结果中。相反地,它对输出做了一些数学计算。 + +``` +$ date | awk '{print $4-$3-$2}' +1997 +``` + +在这个例子中,它将年 “2019” 和日期 “22” 相减,并忽略了中间的 “Nov”。 + +如果你想要空格之外的字符作为输出分隔符,你可以通过 `OFS`(输出分隔符output field separator)指定分隔符,就像这样: + +``` +$ date | awk '{OFS="-"; print $4,$3,$2}' +2019-Nov-22 +``` + +### 打印简单文本 + +你也可以使用 `awk` 简单地显示一些文本。当然了,比起 `awk` 你可能更想使用 `echo` 命令。但换句话说,作为 `awk` 脚本的一部分,打印某些相关性文本将会非常实用。这里有一个没什么用的例子: + +``` +$ awk 'BEGIN {print "Hello, World" }' +Hello, World +``` + +下面的例子更加合理,添加一行文本标签来更好的辨识数据。 + +``` +$ who | awk 'BEGIN {print "Current logins:"} {print $1}' +Current logins: +shs +nemo +``` + +### 指定字段分隔符 + +不是所有的输入都以空格作为分隔符的。如果你的文本通过其它的字符作为分隔符(例如:逗号、冒号、分号),你可以通过 `-F` 选项(输入分隔符)告诉 `awk`: + +``` +$ cat testfile +a:b:c,d:e +$ awk -F : '{print $2,$3}' testfile +b c,d +``` + +下面是一个更加有用的例子——从冒号分隔的 `/etc/passwd` 文件中获取数据: + +``` +$ awk -F: '{print $1}' /etc/passwd | head -11 +root +daemon +bin +sys +sync +games +man +lp +mail +news +uucp +``` + +### 筛选内容 + +你也可以使用 `awk` 命令评估字段。例如你仅仅想列出 `/etc/passwd` 中的用户账号,就可以对第三个字段做一些筛选。下面的例子中我们只关注大于等于 1000 的 UID: + +``` +$ awk -F":" ' $3 >= 1000 ' /etc/passwd +nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin +shs:x:1000:1000:Sandra Henry-Stocker,,,:/home/shs:/bin/bash +nemo:x:1001:1001:Nemo,,,:/home/nemo:/usr/bin/zsh +dory:x:1002:1002:Dory,,,:/home/dory:/bin/bash +... +``` + +如果你想为输出增加标题,可以添加 `BEGIN` 从句: + +``` +$ awk -F":" 'BEGIN {print "user accounts:"} $3 >= 1000 ' /etc/passwd +user accounts: +nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin +shs:x:1000:1000:Sandra Henry-Stocker,,,:/home/shs:/bin/bash +nemo:x:1001:1001:Nemo,,,:/home/nemo:/usr/bin/zsh +dory:x:1002:1002:Dory,,,:/home/dory:/bin/bash +``` + +如果你想要不止一行的标题,你可以通过 `"\n"` 分隔输出: + +``` +$ awk -F":" 'BEGIN {print "user accounts\n============="} $3 >= 1000 ' /etc/passwd +user accounts +============= +nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin +shs:x:1000:1000:Sandra Henry-Stocker,,,:/home/shs:/bin/bash +nemo:x:1001:1001:Nemo,,,:/home/nemo:/usr/bin/zsh +dory:x:1002:1002:Dory,,,:/home/dory:/bin/bash +``` + +### 在 awk 中进行数学计算 + +`awk` 提供了惊人的数学计算能力,并且可以开平方,算 `log`,算 `tan` 等等。 + +这里有一对例子: + +``` +$ awk 'BEGIN {print sqrt(2019)}' +44.9333 +$ awk 'BEGIN {print log(2019)}' +7.61036 +``` + +想要详细了解 `awk` 的数学计算能力,可以看《[使用 awk 进行数学计算][3]》这篇文章。 + +### awk 脚本 + +你也可以使用 `awk` 写一套单独的脚本。下面的例子模仿了之前写过的一个,不过还计算了系统里账户的数量。 + +``` +#!/usr/bin/awk -f + +# 这一行是注释 + +BEGIN { + printf "%s\n","User accounts:" + print "==============" + FS=":" + n=0 +} + +# 现在开始遍历数据 +{ + if ($3 >= 1000) { + print $1 + n ++ + } +} + +END { + print "==============" + print n " accounts" +} +``` + +注意 `BEGIN` 那一节是如何提供标题、指定字段分隔符和初始化计数器的,它仅在脚本初始化时期执行。这个脚本也包含 `END` 节,它仅在中间所有命令处理完成之后运行,显示了所有中间小节所筛选数据的最终行数(第三个字段大于等于 1000)。 + +作为一个长存于 Unix 之上的命令,`awk` 依旧提供着非常有用的服务,这也是我几十年前爱上 Unix 的原因之一。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3454979/the-many-faces-of-awk.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[LuuMing](https://github.com/LuuMing) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.networkworld.com/article/2974753/doing-math-with-awk.html +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world +[6]:https://images.techhive.com/images/article/2015/09/thinkstockphotos-512100549-100611755-large.jpg diff --git a/published/201912/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md b/published/201912/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md new file mode 100644 index 0000000000..eb23278dc6 --- /dev/null +++ b/published/201912/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md @@ -0,0 +1,259 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11637-1.html) +[#]: subject: (5 Commands to Find the IP Address of a Domain in the Linux Terminal) +[#]: via: (https://www.2daygeek.com/linux-command-find-check-domain-ip-address/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +5 个用于在 Linux 终端中查找域名 IP 地址的命令 +====== + +![](https://img.linux.net.cn/data/attachment/album/201912/03/000402c0ekkgku1f011kzt.jpg) + +本教程介绍了如何在 Linux 终端验证域名或计算机名的 IP 地址。本教程将允许你一次检查多个域。你可能已经使用过这些命令来验证信息。但是,我们将教你如何有效使用这些命令在 Linux 终端中识别多个域的 IP 地址信息。 + +可以使用以下 5 个命令来完成此操作。 + +* `dig` 命令:它是一个用于查询 DNS 名称服务器的灵活命令行工具。 +* `host` 命令:它是用于执行 DNS 查询的简单程序。 +* `nslookup` 命令:它用于查询互联网域名服务器。 +* `fping` 命令:它用于向网络主机发送 ICMP ECHO_REQUEST 数据包。 +* `ping` 命令:它用于向网络主机发送 ICMP ECHO_REQUEST 数据包。 + +为了测试,我们创建了一个名为 `domains-list.txt` 的文件,并添加了以下域。 + +``` +# vi /opt/scripts/domains-list.txt + +2daygeek.com +magesh.co.in +linuxtechnews.com +``` + +### 方法 1:如何使用 dig 命令查找域的 IP 地址 + +[dig 命令][1]代表 “域名信息抓手Domain Information Groper”,它是一个功能强大且灵活的命令行工具,用于查询 DNS 名称服务器。 + +它执行 DNS 查询,并显示来自查询的名称服务器的返回信息。大多数 DNS 管理员使用 `dig` 命令来解决 DNS 问题,因为它灵活、易用且输出清晰。 + +它还有批处理模式,可以从文件读取搜索请求。 + +``` +# dig 2daygeek.com | awk '{print $1,$5}' + +2daygeek.com. 104.27.157.177 +2daygeek.com. 104.27.156.177 +``` + +使用以下 bash 脚本查找多个域的 IP 地址。 + +``` +# vi /opt/scripts/dig-command.sh + +#!/bin/bash +for server in `cat /opt/scripts/domains-list.txt` +do echo $server "-" +dig $server +short +done | paste -d " " - - - +``` + +添加以上内容到脚本后,给 `dig-command.sh` 文件设置可执行权限。 + +``` +# chmod +x /opt/scripts/dig-command.sh +``` + +最后运行 bash 脚本获得输出。 + +``` +# sh /opt/scripts/dig-command.sh + +2daygeek.com - 104.27.156.177 104.27.157.177 +magesh.co.in - 104.18.35.52 104.18.34.52 +linuxtechnews.com - 104.27.144.3 104.27.145.3 +``` + +如果要在一行中运行上面的脚本,请使用以下脚本。 + +``` +# for server in 2daygeek.com magesh.co.in linuxtechnews.com; do echo $server "-"; dig $server +short; done | paste -d " " - - - +``` + +或者,你可以使用以下 Shell 脚本查找多个域的 IP 地址。 + +``` +# for server in 2daygeek.com magesh.co.in linuxtechnews.com; do dig $server | awk '{print $1,$5}'; done + +2daygeek.com. 104.27.157.177 +2daygeek.com. 104.27.156.177 +magesh.co.in. 104.18.34.52 +magesh.co.in. 104.18.35.52 +linuxtechnews.com. 104.27.144.3 +linuxtechnews.com. 104.27.145.3 +``` + +### 方法 2:如何使用 host 命令查找域的 IP 地址 + +[host 命令][2]是一个简单的命令行程序,用于执行 [DNS 查询][3]。它通常用于将名称转换为 IP 地址,反之亦然。如果未提供任何参数或选项,`host` 将打印它的命令行参数和选项摘要。 + +你可以在 `host` 命令中添加特定选项或记录类型来查看域中的所有记录类型。 + +``` +# host 2daygeek.com | grep "has address" | sed 's/has address/-/g' + +2daygeek.com - 104.27.157.177 +2daygeek.com - 104.27.156.177 +``` + +使用以下 bash 脚本查找多个域的 IP 地址。 + +``` +# vi /opt/scripts/host-command.sh + +for server in `cat /opt/scripts/domains-list.txt` +do host $server | grep "has address" | sed 's/has address/-/g' +done +``` + +添加以上内容到脚本后,给 `host-command.sh` 文件设置可执行权限。 + +``` +# chmod +x /opt/scripts/host-command.sh +``` + +最后运行 bash 脚本获得输出。 + +``` +# sh /opt/scripts/host-command.sh + +2daygeek.com - 104.27.156.177 +2daygeek.com - 104.27.157.177 +magesh.co.in - 104.18.35.52 +magesh.co.in - 104.18.34.52 +linuxtechnews.com - 104.27.144.3 +linuxtechnews.com - 104.27.145.3 +``` + +### 方法 3:如何使用 nslookup 命令查找域的 IP 地址 + +[nslookup 命令][4]是用于查询互联网[域名服务器(DNS)] [5]的程序。 + +`nslookup` 有两种模式,分别是交互式和非交互式。交互模式允许用户查询名称服务器以获取有关各种主机和域的信息,或打印域中的主机列表。非交互模式用于仅打印主机或域的名称和请求的信息。 + +它是一个网络管理工具,可以帮助诊断和解决 DNS 相关问题。 + +``` +# nslookup -q=A 2daygeek.com | tail -n+4 | sed -e '/^$/d' -e 's/Address://g' | grep -v 'Name|answer' | xargs -n1 + +104.27.157.177 +104.27.156.177 +``` + +使用以下 bash 脚本查找多个域的 IP 地址。 + +``` +# vi /opt/scripts/nslookup-command.sh + +#!/bin/bash +for server in `cat /opt/scripts/domains-list.txt` +do echo $server "-" +nslookup -q=A $server | tail -n+4 | sed -e '/^$/d' -e 's/Address://g' | grep -v 'Name|answer' | xargs -n1 done | paste -d " " - - - +``` + +添加以上内容到脚本后,给 `nslookup-command.sh` 文件设置可执行权限。 + +``` +# chmod +x /opt/scripts/nslookup-command.sh +``` + +最后运行 bash 脚本获得输出。 + +``` +# sh /opt/scripts/nslookup-command.sh + +2daygeek.com - 104.27.156.177 104.27.157.177 +magesh.co.in - 104.18.35.52 104.18.34.52 +linuxtechnews.com - 104.27.144.3 104.27.145.3 +``` + +### 方法 4:如何使用 fping 命令查找域的 IP 地址 + +[fping 命令][6]是类似 `ping` 之类的程序,它使用互联网控制消息协议(ICMP)echo 请求来确定目标主机是否响应。 + +`fping` 与 `ping` 不同,因为它允许用户并行 ping 任意数量的主机。另外,它可以从文本文件输入主机。 + +`fping` 发送 ICMP echo 请求,并以循环方式移到下一个目标,并且不等到目标主机做出响应。 + +如果目标主机答复,那么将其标记为活动主机并从要检查的目标列表中删除;如果目标在特定时间限制和/或重试限制内未响应,那么将其指定为不可访问。 + +``` +# fping -A -d 2daygeek.com magesh.co.in linuxtechnews.com + +104.27.157.177 (104.27.157.177) is alive +104.18.35.52 (104.18.35.52) is alive +104.27.144.3 (104.27.144.3) is alive +``` + +### 方法 5:如何使用 ping 命令查找域的 IP 地址 + +[ping 命令][6](数据包互联网抓手Packet Internet Groper)是一个网络程序,用于测试 Internet 协议(IP)网络上主机的可用性/连接性。 + +通过向目标主机发送互联网控制消息协议(ICMP)Echo 请求数据包并等待 ICMP Echo 应答来验证主机的可用性。 + +它基于发送的数据包、接收的数据包、丢失的数据包,通常包含最小/平均/最大时间来汇总统计结果。 + +``` +# ping -c 2 2daygeek.com | head -2 | tail -1 | awk '{print $5}' | sed 's/[(:)]//g' + +104.27.157.177 +``` + +使用以下 bash 脚本查找多个域的 IP 地址。 + +``` +# vi /opt/scripts/ping-command.sh + +#!/bin/bash +for server in `cat /opt/scripts/domains-list.txt` +do echo $server "-" +ping -c 2 $server | head -2 | tail -1 | awk '{print $5}' | sed 's/[(:)]//g' +done | paste -d " " - - +``` + +添加以上内容到脚本后,给 `ping-command.sh` 文件设置可执行权限。 + +``` +# chmod +x /opt/scripts/ping-command.sh +``` + +最后运行 bash 脚本获得输出。 + +``` +# sh /opt/scripts/ping-command.sh + +2daygeek.com - 104.27.156.177 +magesh.co.in - 104.18.35.52 +linuxtechnews.com - 104.27.144.3 +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-command-find-check-domain-ip-address/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/dig-command-check-find-dns-records-lookup-linux/ +[2]: https://www.2daygeek.com/linux-host-command-check-find-dns-records-lookup/ +[3]: https://www.2daygeek.com/category/dns-lookup/ +[4]: https://www.2daygeek.com/nslookup-command-check-find-dns-records-lookup-linux/ +[5]: https://www.2daygeek.com/check-find-dns-records-of-domain-in-linux-terminal/ +[6]: https://www.2daygeek.com/how-to-use-ping-fping-gping-in-linux/ diff --git a/published/201912/20191127 Create virtual machines with Cockpit in Fedora.md b/published/201912/20191127 Create virtual machines with Cockpit in Fedora.md new file mode 100644 index 0000000000..c4de8df42f --- /dev/null +++ b/published/201912/20191127 Create virtual machines with Cockpit in Fedora.md @@ -0,0 +1,95 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11716-1.html) +[#]: subject: (Create virtual machines with Cockpit in Fedora) +[#]: via: (https://fedoramagazine.org/create-virtual-machines-with-cockpit-in-fedora/) +[#]: author: (Karlis KavacisPaul W. Frields https://fedoramagazine.org/author/karlisk/https://fedoramagazine.org/author/pfrields/) + +在 Fedora 中使用 Cockpit 创建虚拟机 +====== + +![][1] + +本文向你展示如何在 Fedora 31 上使用安装 Cockpit 所需软件来创建和管理虚拟机。Cockpit 是一个[交互式管理界面][2],可让你在任何受支持的 Web 浏览器上访问和管理系统。随着 [virt-manager 逐渐被废弃][3],鼓励用户使用 Cockpit 来替换它。 + +Cockpit 是一个正在活跃开发的项目,它有许多扩展其工作的插件。例如,其中一个是 “Machines”,它与 libvirtd 交互并允许用户创建和管理虚拟机。 + +### 安装软件 + +先决所需软件是 `libvirt`、`cockpit` 和 `cockpit-machines`。要将它们安装在 Fedora 31 上,请在终端[使用 sudo][4] 运行以下命令: + +``` +$ sudo dnf install libvirt cockpit cockpit-machines +``` + +Cockpit 也在 “Headless Management” 软件包组中。该软件组对于仅通过网络访问的基于 Fedora 的服务器很有用。在这里,请使用以下命令进行安装: + +``` +$ sudo dnf groupinstall "Headless Management" +``` + +### 设置 Cockpit 服务 + +安装了必要的软件包后,就该启用服务了。`libvirtd` 服务运行虚拟机,而 Cockpit 有一个激活的套接字服务,可让你访问 Web GUI: + +``` +$ sudo systemctl enable libvirtd --now +$ sudo systemctl enable cockpit.socket --now +``` + +这应该足以运行虚拟机并通过 Cockpit 对其进行管理。(可选)如果要从网络上的另一台设备访问并管理计算机,那么需要将该服务开放给网络。为此,请在防火墙配置中添加新规则: + +``` +$ sudo firewall-cmd --zone=public --add-service=cockpit --permanent +$ sudo firewall-cmd --reload +``` + +要确认服务正在运行并且没有发生任何问题,请检查服务的状态: + +``` +$ sudo systemctl status libvirtd +$ sudo systemctl status cockpit.socket +``` + +此时一切都应该正常工作。Cockpit Web GUI 应该可通过 访问。或者,在连接到同一网络的任何其他设备上的 Web 浏览器中输入本地网络 IP。(如果未设置 SSL 证书,那么可能需要允许来自浏览器的连接。) + +### 创建和安装机器 + +使用系统的用户名和密码登录界面。你还可以选择是否允许在此会话中将密码用于管理任务。 + +选择 “Virtual Machines”,然后选择 “Create VM” 来创建一台新的虚拟机。控制台为你提供几个选项: + + * 使用 Cockpit 的内置库下载操作系统 + * 使用系统上已下载的安装媒体 + * 指向系统安装树的 URL + * 通过 [PXE][5] 协议通过网络引导媒体 + +输入所有必要的参数。然后选择 “Create” 启动新虚拟机。 + +此时,将出现一个图形控制台。大多数现代 Web 浏览器都允许你使用键盘和鼠标与 VM 控制台进行交互。现在,你可以完成安装并使用新的 VM,就像[过去通过 virt-manager][6] 一样。 + +*照片由 [Miguel Teixeira][7] 发布于 [Flickr][8](CC BY-SA 2.0)* + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/create-virtual-machines-with-cockpit-in-fedora/ + +作者:[Karlis Kavacis][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/karlisk/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/11/create-vm-cockpit-816x345.jpg +[2]: https://cockpit-project.org/ +[3]: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/8.0_release_notes/rhel-8_0_0_release#virtualization_4 +[4]: https://fedoramagazine.org/howto-use-sudo/ +[5]: https://en.wikipedia.org/wiki/Preboot_Execution_Environment +[6]: https://fedoramagazine.org/full-virtualization-system-on-fedora-workstation-30/ +[7]: https://flickr.com/photos/miguelteixeira/ +[8]: https://flickr.com/photos/miguelteixeira/2964851828/ diff --git a/published/201912/20191127 How to write a Python web API with Flask.md b/published/201912/20191127 How to write a Python web API with Flask.md new file mode 100644 index 0000000000..8e28adebdf --- /dev/null +++ b/published/201912/20191127 How to write a Python web API with Flask.md @@ -0,0 +1,140 @@ +[#]: collector: (lujun9972) +[#]: translator: (hj24) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11701-1.html) +[#]: subject: (How to write a Python web API with Flask) +[#]: via: (https://opensource.com/article/19/11/python-web-api-flask) +[#]: author: (Rachel Waston https://opensource.com/users/rachelwaston) + +如何使用 Flask 编写 Python Web API +====== + +> 这是一个快速教程,用来展示如何通过 Flask(目前发展最迅速的 Python 框架之一)来从服务器获取数据。 + +![spiderweb diagram][1] + +[Python][2] 是一个以语法简洁著称的高级的、面向对象的程序语言。它一直都是一个用来构建 RESTful API 的顶级编程语言。 + +[Flask][3] 是一个高度可定制化的 Python 框架,可以为开发人员提供用户访问数据方式的完全控制。Flask 是一个基于 Werkzeug 的 [WSGI][4] 工具包和 Jinja 2 模板引擎的”微框架“。它是一个被设计来开发 RESTful API 的 web 框架。 + +Flask 是 Python 发展最迅速的框架之一,很多知名网站如:Netflix、Pinterest 和 LinkedIn 都将 Flask 纳入了它们的开发技术栈。下面是一个简单的示例,展示了 Flask 是如何允许用户通过 HTTP GET 请求来从服务器获取数据的。 + +### 初始化一个 Flask 应用 + +首先,创建一个你的 Flask 项目的目录结构。你可以在你系统的任何地方来做这件事。 + +``` +$ mkdir tutorial +$ cd tutorial +$ touch main.py +$ python3 -m venv env +$ source env/bin/activate +(env) $ pip3 install flask-restful +Collecting flask-restful +Downloading https://files.pythonhosted.org/packages/17/44/6e49...8da4/Flask_RESTful-0.3.7-py2.py3-none-any.whl +Collecting Flask>=0.8 (from flask-restful) +[...] +``` + +### 导入 Flask 模块 + +然后,在你的 `main.py` 代码中导入 `flask` 模块和它的 `flask_restful` 库: + +``` +from flask import Flask +from flask_restful import Resource, Api + +app = Flask(__name__) +api = Api(app) + +class Quotes(Resource): + def get(self): + return { + 'William Shakespeare': { + 'quote': ['Love all,trust a few,do wrong to none', + 'Some are born great, some achieve greatness, and some greatness thrust upon them.'] + }, + 'Linus': { + 'quote': ['Talk is cheap. Show me the code.'] + } + } + +api.add_resource(Quotes, '/') + +if __name__ == '__main__': + app.run(debug=True) +``` + +### 运行 app + +Flask 包含一个内建的用于测试的 HTTP 服务器。来测试一下这个你创建的简单的 API: + +``` +(env) $ python main.py + * Serving Flask app "main" (lazy loading) + * Environment: production + WARNING: This is a development server. Do not use it in a production deployment. + Use a production WSGI server instead. + * Debug mode: on + * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) +``` + +启动开发服务器时将启动 Flask 应用程序,该应用程序包含一个名为 `get` 的方法来响应简单的 HTTP GET 请求。你可以通过 `wget`、`curl` 命令或者任意的 web 浏览器来测试它。 + +``` +$ curl http://localhost:5000 +{ + "William Shakespeare": { + "quote": [ + "Love all,trust a few,do wrong to none", + "Some are born great, some achieve greatness, and some greatness thrust upon them." + ] + }, + "Linus": { + "quote": [ + "Talk is cheap. Show me the code." + ] + } +} +``` + +要查看使用 Python 和 Flask 的类似 Web API 的更复杂版本,请导航至美国国会图书馆的 [Chronicling America][5] 网站,该网站可提供有关这些信息的历史报纸和数字化报纸。 + +### 为什么使用 Flask? + +Flask 有以下几个主要的优点: + + 1. Python 很流行并且广泛被应用,所以任何熟悉 Python 的人都可以使用 Flask 来开发。 + 2. 它轻巧而简约。 + 3. 考虑安全性而构建。 + 4. 出色的文档,其中包含大量清晰,有效的示例代码。 + +还有一些潜在的缺点: + + 1. 它轻巧而简约。但如果你正在寻找具有大量捆绑库和预制组件的框架,那么这可能不是最佳选择。 + 2. 如果必须围绕 Flask 构建自己的框架,则你可能会发现维护自定义项的成本可能会抵消使用 Flask 的好处。 + + +如果你要构建 Web 程序或 API,可以考虑选择 Flask。它功能强大且健壮,并且其优秀的项目文档使入门变得容易。试用一下,评估一下,看看它是否适合你的项目。 + +在本课中了解更多信息关于 Python 异常处理以及如何以安全的方式进行操作。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/python-web-api-flask + +作者:[Rachel Waston][a] +选题:[lujun9972][b] +译者:[hj24](https://github.com/hj24) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/rachelwaston +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web-cms-build-howto-tutorial.png?itok=bRbCJt1U (spiderweb diagram) +[2]: https://www.python.org/ +[3]: https://palletsprojects.com/p/flask/ +[4]: https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface +[5]: https://chroniclingamerica.loc.gov/about/api diff --git a/published/201912/20191127 Nvidia quietly unveils faster, lower power Tesla GPU accelerator.md b/published/201912/20191127 Nvidia quietly unveils faster, lower power Tesla GPU accelerator.md new file mode 100644 index 0000000000..cbb4c747d1 --- /dev/null +++ b/published/201912/20191127 Nvidia quietly unveils faster, lower power Tesla GPU accelerator.md @@ -0,0 +1,54 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11640-1.html) +[#]: subject: (Nvidia quietly unveils faster, lower power Tesla GPU accelerator) +[#]: via: (https://www.networkworld.com/article/3482097/nvidia-quietly-unveils-faster-lower-power-tesla-gpu-accelerator.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Nvidia 悄悄推出更快、更低功耗的 Tesla GPU 加速器 +====== + +> Nvidia 升级了其 Volta 系列的 Tesla GPU 加速卡,使其能够以旧型号的相同功率更快地工作。 + +![](https://images.idgesg.net/images/article/2019/01/nvidia_logo-2-100785663-large.jpg) + +Nvidia 上周举行了 Supercomputing 19 大会,不出意外的是公布了很多新闻,这些我们将稍后提到。但被忽略的一条或许是其中最有趣的:一张更快、功耗更低的新一代图形加速卡。 + +多名与会者与多个新闻站点发现了这点,Nvidia 向我证实这确实是一张新卡。Nvidia 的 “Volta” 这代 Tesla GPU 加速卡在 2017 年就已淘汰,因此升级工作应该早已过期。 + +V100S 目前仅提供 PCI Express 3 接口,但有望最终支持 Nvidia 的 SXM2 接口。SXM 是 Nvidia 的双插槽卡设计,与 PCIe 卡不同,它不需要连接电源。SXM2 允许 GPU 通过 Nvidia 的 NVLink(一种高带宽、节能的互连)相互之间或与 CPU 进行通信,其数据传输速度比 PCIe 快十倍。 + +借助此卡,Nvidia 声称拥有单精度 16.4 TFLOPS,双精度 8.2 TFLOPS 并且 Tensor Core 性能高达 130 TFLOPS。这仅比 V100 SXM2 设计提高了 4% 至 5%,但比 PCIe V100 变体提高了 16% 至 17%。 + +内存容量保持在 32 GB,但 Nvidia 添加了 High Bandwidth Memory 2(HBM2),以将内存性能提高到 1,134 GB/s,这比 PCIe 和 SXM2 都提高了 26%。 + +通常情况下,性能提升将同时导致功率增加,但在这里,PCIe 卡的总体功率为 250 瓦,与上一代 PCIe 卡相同。因此,在相同功耗下,该卡可额外提供 16-17% 的计算性能,并增加 26% 的内存带宽。 + +### 其他新闻 + +Nvidia 在会上还发布了其他新闻: + +* 其 GPU 加速的基于 Arm 的高性能计算参考服务器的新参考设计和生态系统支持。该公司表示,它得到了 HPE/Cray、Marvell、富士通和 Ampere 的支持,Ampere 是 Intel 前高管勒尼·詹姆斯(Renee James)领导的一家初创公司,它希望建立基于 Arm 的服务器处理器。 +* 这些公司将使用 Nvidia 的参考设计(包括硬件和软件组件)来使用 GPU 构建从超大规模云提供商到高性能存储和百亿亿次超级计算等。该设计还带来了 CUDA-X,这是 Nvidia 用于 Arm 处理器的 CUDA GPU 的特殊版本开发语言。 +* 推出 Nvidia Magnum IO 套件,旨在帮助数据科学家和 AI 以及高性能计算研究人员在几分钟而不是几小时内处理大量数据。它经过优化,消除了存储和 I/O 瓶颈,可为多服务器、多 GPU 计算节点提供高达 20 倍的数据处理速度。 +* Nvidia 和 DDN (AI 以及多云数据管理开发商)宣布将 DDN 的 A3ITM 数据管理系统与 Nvidia 的 DGX SuperPOD 系统捆绑在一起,以便客户能够以最小的复杂性和更短的时限部署 HPC 基础架构。SuperPOD 还带有新的 NVIDIA Magnum IO 软件栈。 +* DDN 表示,SuperPOD 能够在数小时内部署,并且单个设备可扩展至 80 个节点。不同的深度学习模型的基准测试表明,DDN 系统可以使 DGXSuperPOD 系统完全保持数据饱和。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3482097/nvidia-quietly-unveils-faster-lower-power-tesla-gpu-accelerator.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/201912/20191129 A quick introduction to Toolbox on Fedora.md b/published/201912/20191129 A quick introduction to Toolbox on Fedora.md new file mode 100644 index 0000000000..bfcad3cc06 --- /dev/null +++ b/published/201912/20191129 A quick introduction to Toolbox on Fedora.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11651-1.html) +[#]: subject: (A quick introduction to Toolbox on Fedora) +[#]: via: (https://fedoramagazine.org/a-quick-introduction-to-toolbox-on-fedora/) +[#]: author: (Ryan Walter https://fedoramagazine.org/author/rwaltr/) + +Fedora 中的 Toolbox 简介 +====== + +![][1] + +Toolbox 使你可以[在容器中分类和管理开发环境][2],而无需 root 权限或手动添加卷。它创建一个容器,你可以在其中安装自己的命令行工具,而无需在基础系统中安装它们。当你没有 root 权限或无法直接安装程序时,也可以使用它。本文会介绍 Toolbox 及其功能。 + +### 安装 Toolbox + +[Silverblue][3] 默认包含 Toolbox。对于 Workstation 和 Server 版本,你可以使用 `dnf install toolbox` 从默认仓库中获取它。 + +### 创建 Toolbox + +打开终端并运行 `toolbox enter`。程序将自动请求许可来下载最新的镜像,创建第一个容器并将你的 shell 放在该容器中。 + +``` +$ toolbox enter +No toolbox containers found. Create now? [y/N] y +Image required to create toolbox container. +Download registry.fedoraproject.org/f30/fedora-toolbox:30 (500MB)? [y/N]: y +``` + +当前,Toolbox 和你的基本系统之间没有区别。你的文件系统和软件包未曾改变。下面是一个使用仓库的示例,它包含 `~/src/resume` 文件夹下的简历的文档源文件。简历是使用 `pandoc` 工具构建的。 + +``` +$ pwd +/home/rwaltr +$ cd src/resume/ +$ head -n 5 Makefile +all: pdf html rtf text docx + +pdf: init + pandoc -s -o BUILDS/resume.pdf markdown/* + +$ make pdf +bash: make: command not found +$ pandoc -v +bash: pandoc: command not found +``` + +这个 toolbox 没有构建简历所需的程序。你可以通过使用 `dnf` 安装工具来解决此问题。由于正在容器中运行,因此不会提示你输入 root 密码。 + +``` +$ sudo dnf groupinstall "Authoring and Publishing" -y && sudo dnf install pandoc make -y +... +$ make all #Successful builds +mkdir -p BUILDS +pandoc -s -o BUILDS/resume.pdf markdown/* +pandoc -s -o BUILDS/resume.html markdown/* +pandoc -s -o BUILDS/resume.rtf markdown/* +pandoc -s -o BUILDS/resume.txt markdown/* +pandoc -s -o BUILDS/resume.docx markdown/* +$ ls BUILDS/ +resume.docx resume.html resume.pdf resume.rtf resume.txt +``` + +运行 `exit` 可以退出 toolbox。 + +``` +$ cd BUILDS/ +$ pandoc --version || ls +pandoc 2.2.1 +Compiled with pandoc-types 1.17.5.4, texmath 0.11.1.2, skylighting 0.7.5 +... +for a particular purpose. +resume.docx resume.html resume.pdf resume.rtf resume.txt +$ exit +logout +$ pandoc --version || ls +bash: pandoc: command not found... +resume.docx resume.html resume.pdf resume.rtf resume.txt +``` + +你会在主目录中得到由 toolbox 创建的文件。而在 toolbox 中安装的程序无法在外部访问。 + +### 提示和技巧 + +本介绍仅涉及 toolbox 的表面。还有一些其他提示,但是你也可以查看[官方文档][2]。 + +* `toolbox –help` 会显示 Toolbox 的手册页。 +* 你可以一次有多个 toolbox。使用 `toolbox create -c Toolboxname` 和 `toolbox enter -c Toolboxname`。 +* Toolbox 使用 [Podman][4] 来完成繁重的工作。使用 `toolbox list` 可以查找 Toolbox 创建的容器的 ID。Podman 可以使用这些 ID 来执行 `rm` 和 `stop` 之类的操作。 (你也可以在[此文章][5]中阅读有关 Podman 的更多信息。) + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/a-quick-introduction-to-toolbox-on-fedora/ + +作者:[Ryan Walter][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/rwaltr/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/11/toolbox-816x345.jpg +[2]: https://docs.fedoraproject.org/en-US/fedora-silverblue/toolbox/ +[3]: https://fedoramagazine.org/what-is-silverblue/ +[4]: https://podman.io/ +[5]: https://fedoramagazine.org/running-containers-with-podman/ +[6]: https://flickr.com/photos/florianric/ +[7]: https://flickr.com/photos/florianric/7263382550/ diff --git a/published/201912/20191202 Use the Window Maker desktop on Linux.md b/published/201912/20191202 Use the Window Maker desktop on Linux.md new file mode 100644 index 0000000000..d3225b5a59 --- /dev/null +++ b/published/201912/20191202 Use the Window Maker desktop on Linux.md @@ -0,0 +1,63 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11650-1.html) +[#]: subject: (Use the Window Maker desktop on Linux) +[#]: via: (https://opensource.com/article/19/12/linux-window-maker-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +在 Linux 上使用 Window Maker 桌面 +====== +> 本文是 24 天 Linux 桌面特别系列的一部分。让我们和 Window Maker 一起时光倒流,它为如今的用户实现了老式 Unix NeXTSTEP 环境。 + +![Penguin with green background][1] + +在 Mac OS X 之前,有一个奇怪的闭源 Unix 系统,称为 [NeXTSTEP][2]。Sun Microsystems 后来将 NeXTSTEP 的底层设为开放规范,这使其它项目可以创建许多自由开源的 NeXT 库和组件。GNUStep 实现了许多 NeXTSTEP 库,而 [Window Maker][3] 实现了其桌面环境。 + +Window Maker 非常接近地模仿了 NeXTSTEP 桌面 GUI,并提供了一个有趣的视角,可以让人了解 80 年代末 90 年代初的 Unix 是什么样子的。它还揭示了窗口管理器(例如 Fluxbox 和 Openbox)背后的一些基本概念。 + +你可以从发行版的仓库中安装 Window Maker。要尝试它,请在安装完成后退出桌面会话。默认情况下,会话管理器(KDM、GDM、LightDM 或 XDM,这取决于你的设置)将继续将登录到默认桌面,因此登录时必须覆盖默认设置。 + +要在 GDM 上切换到 Window Maker: + +![Selecting the Window Maker desktop in GDM][4] + +在 KDM 上: + +![Selecting the Window Maker desktop in KDM][5] + +### Window Maker 程序坞 + +默认情况下,Window Maker 桌面是空的,但每个角落都有几个*程序坞*。像在 NeXTSTEP 中一样,在 Window Maker 中,在程序坞区域,应用可最小化成图标后停靠,可创建启动器来快速访问常见应用,并且可运行微型的 “dockapp”。 + +你可以在软件仓库中搜索 “dockapp” 来试用 dockapp。它们常常是网络和系统监控器、音频设置面板、时钟等。这是在 Fedora 上运行的 Window Maker: + +![Window Maker running on Fedora][6] + +### 应用菜单 + +要访问应用菜单,请右键单击桌面上的任意位置。要关闭它,请再次单击鼠标右键。Window Maker 不是桌面环境(DE),而是一个窗口管理器(DM)。它可以帮助你安排和管理窗口。它唯一捆绑的程序是 [WPrefs][7](或更常见的说法 Window Maker 偏好),它可帮助你配置常用设置,而应用菜单则提供对其他选项(包括主题)的访问。 + +运行什么应用完全由你决定。在 Window Maker 中,你可以选择运行 KDE 应用、GNOME 应用以及不被视为任何其他主流桌面应用的程序。你可以创建自己的工作环境,并且可以使用 Window Maker 对其进行管理。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/linux-window-maker-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_penguin_green.png?itok=ENdVzW22 (Penguin with green background) +[2]: https://en.wikipedia.org/wiki/NeXTSTEP +[3]: https://www.windowmaker.org/ +[4]: https://opensource.com/sites/default/files/uploads/advent-windowmaker-gdm.jpg (Selecting the Window Maker desktop in GDM) +[5]: https://opensource.com/sites/default/files/uploads/advent-windowmaker-kdm.jpg (Selecting the Window Maker desktop in KDM) +[6]: https://opensource.com/sites/default/files/uploads/advent-windowmaker.jpg (Window Maker running on Fedora) +[7]: http://www.windowmaker.org/docs/guidedtour/prefs.html diff --git a/published/201912/20191203 An idiot-s guide to Kubernetes, low-code developers, and other industry trends.md b/published/201912/20191203 An idiot-s guide to Kubernetes, low-code developers, and other industry trends.md new file mode 100644 index 0000000000..6e13e0dbfd --- /dev/null +++ b/published/201912/20191203 An idiot-s guide to Kubernetes, low-code developers, and other industry trends.md @@ -0,0 +1,72 @@ +[#]: collector: (lujun9972) +[#]: translator: (algzjh) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11681-1.html) +[#]: subject: (An idiot's guide to Kubernetes, low-code developers, and other industry trends) +[#]: via: (https://opensource.com/article/19/12/technology-advice-and-other-industry-trends) +[#]: author: (Tim Hildred https://opensource.com/users/thildred) + +每周开源点评:Kubernetes 傻瓜指南、低代码开发人员和其他行业趋势 +====== +> 每周开源社区、市场和行业趋势。 + +![Person standing in front of a giant computer screen with numbers, data][1] + +作为我在具有开源开发模型的企业软件公司担任高级产品营销经理的角色的一部分,我为产品营销人员、经理和其他影响者定期发布有关开源社区,市场和行业趋势的定期更新。这里有该更新中我和他们最喜欢的四篇文章。 + +### Kubernetes 傻瓜指南 + +- [文章链接][2] + +> Kubernetes 已经发展出了新的特性,这使其成为企业软件的更好的容器平台。安全性和高级网络等元素已被纳入 Kubernetes 上游代码的主体,并且现在可供所有人使用。 +> +> 然而,企业解决方案的其他方面总会有补充需求;比如日志记录和性能监控。这就是像 Istio 等辅助包发挥作用的地方,它带来了额外的功能,但是仍使 Kubernetes 的核心保持了合理的大小和特性集。 + +**影响**: 我总是发现,人们很容易把对技术发展的认识视为理所当然。当与你打交道的每个人都处于“最前沿”时,你的观点就会歪曲到这样的程度:你甚至可能会认为对最新的(*此处插入首选技术*)一无所知的人跟不上潮流,而实际上这并没有开始影响他们做自己需要做的事情的能力。那些人不是白痴;他们是我们的朋友、客户、合作伙伴、合作者和社区。 + +### Gartner: 采用低代码开发之前应该考虑什么 + +- [文章链接][3] + +> 尽管专注于商业 IT 团队,但 Gartner 发现,一个日益重要的开发人员社区是需要快速开发简单应用程序或构建最低可行产品或多体验功能的核心 IT 专业开发人员。当应用程序领导者在传统的应用程序项目中使用低代码时,他们可能希望使用标准的 IT DevOps 自动化方法和低代码工具。 + +**影响**: 越来越多的用例和用户体验可以通过需要更少时间和技能来创建的应用程序来处理和交互。而低代码开发人员也可能会结合成一个具有他们自己的规范和亚文化的独特群体。 + +### 诺基亚认为云原生对 5G 核心至关重要 + +- [文章链接][4] + +> 诺基亚概述了 5G 的五个关键业务目标,这些目标只能通过云原生环境来实现。其中包括:更好的带宽、延迟和密度;通过网络切片将服务扩展到新的企业、行业和[物联网][5]市场;根据敏捷性和效率定义的快速服务部署;超越传统带宽、语音和信息传递的新服务;以及利用端到端网络获取更多收入的数字服务的出现。 + +**影响**: 在越来越多的事物连接到网络的情况下,这是最有意义的。4G 主要与越来越多的手机有关;只有当你开始连接其他所有东西时,5G 才是真正必要的。4G 意味着我们的手机上有更丰富的应用程序,而 5G 几乎与手机无关。 + +### API:隐藏的业务加速器 + +- [文章链接][6] + +> 要想让组织成功地进行数字化转型,API 策略至关重要。从解锁有价值的数据到加快开发时间,API 都是数字时代的幕后英雄。那些已经尝试过 API 的人已经感受到了好处。例如,研究表明,使用 API 的企业中,有 53% 认为它们提高了生产力,而 29% 声称它们的收入增长是使用 API 的直接结果。当 API 被视为存在于一个项目之外的可发现和可重用的产品时,它有助于为持续的变更奠定灵活的基础。 + +**影响**: 隐藏的业务加速器实际上是这样一种思想,即功能应该以一种方式进行打包,使其能够在原始提供者没有预料到的环境中进行重新利用和组合。 + +我希望你喜欢这份上周给我留下深刻印象的列表,并于下周一回来了解更多开源社区、市场和行业的趋势。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/technology-advice-and-other-industry-trends + +作者:[Tim Hildred][a] +选题:[lujun9972][b] +译者:[algzjh](https://github.com/algzjh) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/thildred +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr "Person standing in front of a giant computer screen with numbers, data" +[2]: https://www.cbronline.com/feature/an-idiots-guide-to-kubernetes +[3]: https://www.computerweekly.com/feature/Gartner-What-to-consider-before-adopting-low-code-development +[4]: https://www.sdxcentral.com/articles/news/nokia-argues-cloud-native-is-essential-to-5g-core/2019/11/ +[5]: https://www.sdxcentral.com/5g/iot/ "IoT" +[6]: https://www.cbronline.com/opinion/digital-transformation-3 diff --git a/published/201912/20191203 Using Ansible to organize your SSH keys in AWS.md b/published/201912/20191203 Using Ansible to organize your SSH keys in AWS.md new file mode 100644 index 0000000000..ff844803c7 --- /dev/null +++ b/published/201912/20191203 Using Ansible to organize your SSH keys in AWS.md @@ -0,0 +1,121 @@ +[#]: collector: (lujun9972) +[#]: translator: (hj24) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11653-1.html) +[#]: subject: (Using Ansible to organize your SSH keys in AWS) +[#]: via: (https://fedoramagazine.org/using-ansible-to-organize-your-ssh-keys-in-aws/) +[#]: author: (Daniel Leite de Abreu https://fedoramagazine.org/author/dabreu/) + +在 AWS 中使用 Ansible 来管理你的 SSH 密钥 +====== + +![][1] + +如果你长期使用亚马逊 Web 服务(AWS)中的实例,你可能会遇到下面这个常见的问题,它不是因为技术性的原因导致的,更多的是因为人类追求方便舒适的天性:当你登录一台你最近没有使用的区域的新实例,你最终会创建一个新的 SSH 密钥对,久而久之这最终就会造成个人拥有太多密钥,导致管理起来复杂混乱。 + +本文将会介绍一种在所有区域中使用你的公钥的方法。最近,一篇 [Fedora Magazine 的文章][2]介绍了另一种解决方案。但本文中的解决方案可以进一步的以更简洁和可扩展的方式实现自动化。 + +假设你有一个 Fedora 30 或 31 系统,其中存储了你的密钥,并且还安装了 Ansible。当这两件事同时满足时,就提供了解决这个问题的办法,甚至它还能做到更多。 + +使用 Ansible 的 [ec2_key 模块][3],你可以创建一个简单的 Ansible 剧本来在所有区域中维护你的 SSH 密钥对。如果你需要增加或者删除密钥,在 Ansible 中这就像从文件中添加和删除行一样简单。 + +### 设置和运行 Ansible 剧本 + +如果要使用剧本,首先需要安装 `ec2_key` 模块的必要依赖项: + +``` +$ sudo dnf install python3-boto python3-boto3 +``` + +该剧本很简单:你只需要像下面的例子一样,修改其中的密钥及其对应的名称。然后,运行该剧本,它会帮你遍历所有列出的公共 AWS 区域。该示例还包括一些你可能要访问的受限区域,只需根据需要来取消对应行的注释,然后,保存文件重新运行剧本即可。 + +``` +--- +- name: Maintain an ssh key pair in ec2 + hosts: localhost + connection: local + gather_facts: no + vars: + ansible_python_interpreter: python + tasks: + - name: Make available your ssh public key in ec2 for new instances + ec2_key: + name: "YOUR KEY NAME GOES HERE" + key_material: 'YOUR KEY GOES HERE' + state: present + region: "{{ item }}" + with_items: + - us-east-2 #US East (Ohio) + - us-east-1 #US East (N. Virginia) + - us-west-1 #US West (N. California) + - us-west-2 #US West (Oregon) + - ap-east-1 #Asia Pacific (Hong Kong) + - ap-south-1 #Asia Pacific (Mumbai) + - ap-northeast-2 #Asia Pacific (Seoul) + - ap-southeast-1 #Asia Pacific (Singapore) + - ap-southeast-2 #Asia Pacific (Sydney) + - ap-northeast-1 #Asia Pacific (Tokyo) + - ca-central-1 #Canada (Central) + - eu-central-1 #EU (Frankfurt) + - eu-west-1 #EU (Ireland) + - eu-west-2 #EU (London) + - eu-west-3 #EU (Paris) + - eu-north-1 #EU (Stockholm) + - me-south-1 #Middle East (Bahrain) + - sa-east-1 #South America (Sao Paulo) + # - us-gov-east-1 #AWS GovCloud (US-East) + # - us-gov-west-1 #AWS GovCloud (US-West) + # - ap-northeast-3 #Asia Pacific (Osaka-Local) + # - cn-north-1 #China (Beijing) + # - cn-northwest-1 #China (Ningxia) +``` + +这个剧本需要通过 API 访问 AWS,为此,请使用环境变量,如下所示: + +``` +$ AWS_ACCESS_KEY="aws-access-key-id" AWS_SECRET_KEY="aws-secret-key-id" ansible-playbook ec2-playbook.yml +``` + +另一个方式是安装 aws 命令行工具并添加凭据,如以前的一篇 [Fedora Magazine 文章][4]所述。如果你在线存储它们,这些参数将**不建议**插入到剧本中!你可以在 [GitHub][5] 中找到本文的剧本代码。 + +完成该剧本之后,请确认你的密钥在 AWS 控制台上可用。为此,可以做如下操作: + + 1. 登录你的 AWS 控制台 + 2. 转到 “EC2 > Key Pairs” + 3. 你应该会看到列出的密钥。唯一的限制是你必须使用此方法逐个区域来检查。 + +另一种方法是在 shell 中使用一个快速命令来为你做这些检查。 + +首先在剧本上创建一个包含所有区域的变量: + +``` +AWS_REGION="us-east-1 us-west-1 us-west-2 ap-east-1 ap-south-1 ap-northeast-2 ap-southeast-1 ap-southeast-2 ap-northeast-1 ca-central-1 eu-central-1 eu-west-1 eu-west-2 eu-west-3 eu-north-1 me-south-1 sa-east-1" +``` + +然后,执行如下循环,你就可以从 aws 的 API 获得结果: + +``` +for each in ${AWS_REGION} ; do aws ec2 describe-key-pairs --key-name ; done +``` + +请记住,要执行上述操作,你需要安装 aws 命令行。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/using-ansible-to-organize-your-ssh-keys-in-aws/ + +作者:[Daniel Leite de Abreu][a] +选题:[lujun9972][b] +译者:[hj24](https://github.com/hj24) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/dabreu/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/12/ansible-aws-keys-816x345.jpg +[2]: https://fedoramagazine.org/ssh-key-aws-regions/ +[3]: https://docs.ansible.com/ansible/latest/modules/ec2_key_module.html +[4]: https://fedoramagazine.org/aws-tools-fedora/ +[5]: https://github.com/dlabreu/aws diff --git a/published/201912/20191203 Why use the Pantheon desktop for Linux Elementary OS.md b/published/201912/20191203 Why use the Pantheon desktop for Linux Elementary OS.md new file mode 100644 index 0000000000..e54061f81e --- /dev/null +++ b/published/201912/20191203 Why use the Pantheon desktop for Linux Elementary OS.md @@ -0,0 +1,72 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11660-1.html) +[#]: subject: (Why use the Pantheon desktop for Linux Elementary OS) +[#]: via: (https://opensource.com/article/19/12/pantheon-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +为何 Elementary OS 中使用 Pantheon 桌面 +====== + +> 本文是 Linux 桌面特别系列的一部分。通过在 Elementary OS 上运行 Pantheon 桌面获得广受喜爱的 Mac OS 特性。 + +![](https://img.linux.net.cn/data/attachment/album/201912/10/085342dfgngrpt6sgzl3af.jpg) + +你愿意为 Linux 桌面支付 20 美元吗?事实上,我会在下载自由软件时选择支付更多的钱!我这样做的原因是开源是值得的。对于 [Elementary OS][2] 的拷贝,默认价格是 20 美元(你可以选择 1 美元,如果你无法负担,你甚至可以用 0 美元下载)。作为回报,你将获得一个出色且精心制作的发行版,同时拥有它自己的 Pantheon 桌面设计。 + +你可能会发现 Pantheon 已包含在软件仓库中,因为它是开源的,但你更可能需要下载并安装 [Elementary][3] Linux 才能体验它。如果你还不准备在计算机上将 Elementary 作为主操作系统,那么可以将其安装到虚拟机中,例如 [GNOME Boxes][4] 中。 + +Pantheon 桌面整洁、吸引人,并且有许多用户希望在桌面中获得的东西,但在普通的 Linux 桌面上却无法获得。 + +### Pantheon 桌面之旅 + +乍一看,Pantheon 桌面看起来有点像 Cinnamon、Budgie 或 GNOME 3 的经典模式。但是,Pantheon 最令人兴奋的功能是极小的接触。它在你很少注意到的地方都表现出色,直到有一天这里成为了你一天都会看的地方,并且会意识到它的工作方式确实改善了你的生活质量,更不用说让你过得愉快多了。 + +最明显的例子是“文件名高亮”。几十年来,Mac OS 一直有一个广受欢迎的功能,你可以高亮显示重要文件的名称。人们使用此功能作为快速视觉指示器,来告诉自己哪个文件是这几个的“最佳”版本,或者哪个文件应该发送给朋友,或者哪个文件仍然需要处理。它们可以是任意颜色,可以表示用户想要的任何含义。最重要的是,它是引人注目的视觉元数据。 + +从 Mac OS 切换过来用户往往会在 GNOME 和 KDE 以及 Linux 提供的其它桌面里怀念这个功能。Pantheon 悄悄地随手解决了这个问题。 + +![A highlighted file in the Pantheon desktop][5] + +当然,那只是其中一个例子。Pantheon 有很多你直到用才会想到的小功能。 + +桌面精致而吸引人,有所有其他很多桌面缺少的直观组件。在许多方面,它充分吸取了其他桌面好的想法,并避免实现多余的东西。 + +![Pantheon desktop on Elementary OS][6] + +### 自定义 Pantheon 桌面 + +Pantheon 桌面表达了如何操作计算机的清晰愿景。这种设计的“问题”(至少在开源之外)是,一个人的偏好可能无法满足另一个人的效率。 + +但它是开源的。它可以更改,任何不能改变的东西都可以被丢弃。Pantheon 绝对是针对特定用户群的桌面,但是即使对于那些对桌面应该如何工作抱有自己期望的人,Pantheon 也会比初看上去更加灵活。许多内置设计都具有替代选项,当你无法根据自己的喜好进行调整时,你可以轻松选择其他应用。主题引擎可确保你的替换应用看起来与桌面的其它部分和谐一致,而通常的 Linux 系统兼容性可确保你选择的所有应用都能按预期相互配合。 + +![Which one is the guest?][7] + +这些替代品,可使你事半功倍。 + +### 受欢迎的补充 + +撇开这个桌面的词源不说,此桌面确实是许多 Linux 用户祈祷的答案(LCTT 译注:Pantheon 的意思是“万神庙”)。无论它是否是你的风格,Pantheon 桌面都是 Linux 用户体验中重要且受欢迎的补充。自己尝试一下,看看它是否是你一直期待的。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/pantheon-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb (A person programming) +[2]: https://elementary.io/ +[3]: http://elementary.io +[4]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization +[5]: https://opensource.com/sites/default/files/uploads/advent-pantheon-highlight.jpg (A highlighted file in the Pantheon desktop) +[6]: https://opensource.com/sites/default/files/uploads/advent-pantheon.jpg (Pantheon desktop on Elementary OS) +[7]: https://opensource.com/sites/default/files/uploads/advent-pantheon-pcmanfm.jpg (Which one is the guest?) diff --git a/published/201912/20191204 Dell XPS 13 7390 Review- The Best Laptop For Desktop Linux Users.md b/published/201912/20191204 Dell XPS 13 7390 Review- The Best Laptop For Desktop Linux Users.md new file mode 100644 index 0000000000..e97c3a570b --- /dev/null +++ b/published/201912/20191204 Dell XPS 13 7390 Review- The Best Laptop For Desktop Linux Users.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11664-1.html) +[#]: subject: (Dell XPS 13 7390 Review: The Best Laptop For Desktop Linux Users) +[#]: via: (https://www.linux.com/articles/dell-xps-13-7390-review-the-best-laptop-for-desktop-linux-user/) +[#]: author: (Swapnil Bhartiya https://www.linux.com/author/swapnil/) + +Dell XPS 13 7390:最好的 Linux 桌面笔记本 +====== + +![](https://img.linux.net.cn/data/attachment/album/201912/11/090509vwdm33q8dwqdgnnx.jpg) + +曾经,我们必须进行大量研究、阅读大量评论,才能找到一种在所选的 Linux 桌面发行版上可以以最少的麻烦工作的机器。而如今,这种日子已经一去不复返了,几乎每台机器都可以运行 Linux。Linux 内核社区在设备驱动程序支持方面做得非常出色,可以使一切都开箱即用。 + +不过,有的是**可以**运行 Linux d 机器,有的是运行 Linux 的机器。戴尔计算机属于后一类。五年前,Barton George 在戴尔内部启动了一项计划,将桌面版 Linux 引入到消费级的高端戴尔系统。从一台机器开始,到现在整套从产品线的高端笔记本电脑和台式机都可以运行 Linux。 + +在这些机器中,XPS 13 是我的最爱。尽管我需要一个功能强大的台式机来处理 4K UHD、多机位视频制作,但我还需要一台超便携的笔记本电脑,可以随身携带,而不必担心笨重的背包和充电器。XPS 13 也是我的第一台笔记本电脑,陪了我 7 年多。因此,是的,这还有一个怀旧因素。 + +戴尔几乎每年都会更新其 XPS 产品线,并且最新的[产品展示宣布于 10 月][3]。[XPS 13(7390)] [4] 是该系列的增量更新,而且戴尔非常乐意向我寄来一台测评设备。 + +![](https://img.linux.net.cn/data/attachment/album/201912/11/090524z2xk670shp0080mx.jpg) + +它由 6 核 Core i7-10710U CPU 所支持。它配备 16GB 内存和 1TB SSD。在 1.10 GHz 的基本频率(可以超频到 4.1 GHz)的情况下,这是一台用于常规工作负载的出色机器。它没有使用任何专用的 GPU,因此它并不适合进行游戏或从源代码进行编译的 Gentoo Linux 或 Arch Linux。但是,我确实设法在上面运行了一些 Steam 游戏。 + +如果你想运行 Kubernetes 集群、AI 框架或虚拟现实,那么 Precision 系列中还有更强大的机器,这些机器可以运行 Red Hat Enterprise Linux 和 Ubuntu。 + +该机器的底盘与上一代相同。边框保持与上一代一样的薄,依旧比 MacBook 和微软的 Surface Pro 薄。 + +它具有三个端口,其中两个是 USB-C Thunderbolt 3,可用于连接 4K 显示器、USB 附件以及用于对等网络的计算机之间的高速数据传输。 + +它还具有一个 microSD 插槽。作为视频记者,SD 卡插槽会更有用。大量使用树莓派的用户也会喜欢这种卡。 + +它具有 4 个麦克风和一个改进的摄像头,该摄像头现在位于顶部(再见,鼻孔摄像头!)。 + +XPS 13(7390)光滑纤薄。它的重量仅为 2.7 磅(1.2kg),可以与苹果的 MacBook Air 相提并论。 这台机器可以成为你的旅行伴侣,并且可以执行日常任务,例如检查电子邮件、浏览网络和写作。 + +其 4K UHD 屏幕支持 HDR,这意味着你将可以尽享《The Mandalorian》的全部美妙之处。另外,车载扬声器并没有那么好,听起来有些沉闷。它们适合进行视频聊天或休闲的 YouTube 观看,但是如果你想在今年晚些时候观看《The Witcher》剧集,或者想欣赏 Amazon、Apple Music 或 YouTube Music 的音乐,则需要耳机或外接扬声器。 + +![](https://img.linux.net.cn/data/attachment/album/201912/11/091107p8de88jk5pwffd4a.jpg) + +但是,在插入充电线之前,你可以能使用这台机器多少时间?在正常工作量的情况下,它为我提供了大约 7-8 个小时的电池续航时间:我打开了几个选项卡浏览网络,只是看看电影或听音乐。多任务处理,尤其是各种 Web 活动,都会加速消耗电池电量。在 Linux 上进行一些微调可能会给你带来更多的续航时间,而在 Windows 10 上,我可以使用 10 多个小时呢! + +作为仍在从事大量写作工作的视频记者,我非常喜欢键盘。但是,我们这么多年来在 Linux 台式机上听到的触控板故事一直没变:它与 MacBook 或 Windows 上的品质相差甚远。这或许有一天能改变。值得称道的是,他们确实发布了可增强体验的触控板驱动程序,但我没有运行此系统随附的提供的 Ubuntu 18.04 LTS。我全新安装了 Ubuntu 19.10,因为 Gnome 在 18.04 中的运行速度非常慢。我尝试过 openSUSE Tumbleweed、Zorin OS、elementary OS、Fedora、KDE neon 和 Arch Linux。一切正常,尽管有些需要额外的努力才能运行。 + +那么,该系统适用于谁?显然,这是给那些想要设计精良的、他们信赖的品牌的高端机器的专业人士打造的。适用于喜欢 MacBook Air,但更喜欢 Linux 台式机生态系统的用户。适用于那些希望使用 Linux 来工作,而不是使 Linux 可以工作的人。 + +我使用这台机器一周的时间,进一步说明了为什么我如此喜欢戴尔的 XPS 系列。它们是目前最好的 Linux 笔记本电脑。这款 XPS 13(7390),你值得拥有! + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/articles/dell-xps-13-7390-review-the-best-laptop-for-desktop-linux-user/ + +作者:[Swapnil Bhartiya][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/author/swapnil/ +[b]: https://github.com/lujun9972 +[1]: https://www.linux.com/wp-content/uploads/2019/12/dell-xps-13-7390-1068x665.jpg (dell-xps-13-7390) +[2]: https://www.linux.com/wp-content/uploads/2019/12/dell-xps-13-7390.jpg +[3]: https://bartongeorge.io/2019/08/21/please-welcome-the-9th-generation-of-the-xps-13-developer-edition/ +[4]: https://blog.dell.com/en-us/dells-new-consumer-pc-portfolio-unveiled-ifa-2019/ diff --git a/published/201912/20191204 Fedora Desktops - Memory Footprints.md b/published/201912/20191204 Fedora Desktops - Memory Footprints.md new file mode 100644 index 0000000000..21ae866e77 --- /dev/null +++ b/published/201912/20191204 Fedora Desktops - Memory Footprints.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11733-1.html) +[#]: subject: (Fedora Desktops – Memory Footprints) +[#]: via: (https://fedoramagazine.org/fedora-desktops-memory-footprints/) +[#]: author: (Troy Dawson https://fedoramagazine.org/author/tdawson/) + +Fedora 上的桌面环境内存占用测试 +====== + +![][1] + +Fedora 中有 40 多种桌面环境(DE)。每种桌面环境都有自己的优点和缺点。通常,根据功能、外观和其它品质,选择桌面是一件非常个人的偏好。但有时,你选择的桌面环境还会受到硬件限制。 + +本文旨在帮助人们根据桌面环境占用的基准内存来比较 Fedora 桌面环境。为了缩小范围,我们仅查看具有正式 Fedora Live 镜像的桌面环境。 + +### 安装与系统配置 + +每个桌面环境都安装在自己的 KVM 虚拟机上。每个虚拟机都有 1 个 CPU、4GB 内存、15GB virtio 固态磁盘,以及 RHEL 8.0 kvm 上所有其他标准配置。 + +用于安装的镜像是标准的 Fedora 31 Live 镜像。对于 GNOME,该镜像是 “Fedora 工作站”。对于其它桌面,使用了相应的 Spin 版本。未对“糖葫芦Sugar On A Stick”(SOAS)进行测试,因为它不容易安装到本地驱动器上。 + +用 Live CD 启动虚拟机,然后选择“安装到硬盘”。在安装过程中,仅使用默认值。创建了一个 root 用户和一个普通用户。安装并重新启动后,live 镜像已确认不在虚拟 CDROM 中。 + +每个桌面环境的设置都没有改动。它们每个都以 Live CD 环境中默认的设置运行。每个桌面环境都是通过普通用户登录的。打开了一个终端,在每台虚拟机中都使用 `sudo` 运行了 `dnf -y update`。在更新后,在该 sudo 终端中,每台虚拟机都运行 `/sbin/shutdown -h now` 以关闭。 + +### 测试方式 + +每台机器都已启动。桌面环境已通过普通用户登录。打开了三个桌面终端。xterm 从未使用过,始终用的是该桌面环境的终端,例如 konsole。 + +在一个终端中,启动 `top` 并按下 `M`,以显示按内存排序的进程。在另一个终端中,一个简单的 `while` 循环每 30 秒显示一次 `free -m`。第三个终端闲置。 + +然后,我等待了 5 分钟。这样就可以让所有启动的服务都启动完成。我记录了最终的 `free` 结果,以及 `top` 中最终的前三名内存使用者。 + +### 结果 + + * Cinnamon + * 使用了624 MB + * cinnamon 4.8% / Xorg 2.2% / dnfdragora 1.8% + * GNOME + * 使用了 612 MB + * gnome-shell 6.9% / gnome-software 1.8% / ibus-x11 1.5% + * KDE + * 使用了 733 MB + * plasmashell 6.2% / kwin\_x11 3.6% / akonadi\_mailfil 2.9% + * LXDE + * 使用了 318 MB + * Xorg 1.9% / nm-applet 1.8% / dnfdragora 1.8% + * LXQt + * 使用了 391 MB + * lxqt-panel 2.2% / pcmanfm-qt 2.1% / Xorg 2.1% + * MATE + * 使用了 465 MB + * Xorg 2.5% / dnfdragora 1.8% / caja 1.5% + * XFCE + * 使用了 448 MB + * Xorg 2.3% / xfwm4 2.0% / dnfdragora 1.8% + + + +### 结论 + +我会让数字说明一切。 + +请记住,这些数字来自默认的 Live 安装环境。如果删除或添加服务和功能,则内存使用量将发生变化。但是,如果要根据内存消耗确定桌面环境,这是一个很好的基准。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/fedora-desktops-memory-footprints/ + +作者:[Troy Dawson][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/tdawson/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/11/desktop-memory-footprint-816x346.jpg diff --git a/published/201912/20191204 Java vs. Python- Which should you choose.md b/published/201912/20191204 Java vs. Python- Which should you choose.md new file mode 100644 index 0000000000..82e3d842c2 --- /dev/null +++ b/published/201912/20191204 Java vs. Python- Which should you choose.md @@ -0,0 +1,130 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11679-1.html) +[#]: subject: (Java vs. Python: Which should you choose?) +[#]: via: (https://opensource.com/article/19/12/java-vs-python) +[#]: author: (Archit Modi https://opensource.com/users/architmodi) + +Java 与 Python:你应该选择哪个? +====== + +> 比较世界上最流行的两种编程语言,并在投票中让我们知道你喜欢哪一个。 + +![](https://img.linux.net.cn/data/attachment/album/201912/16/095025dppnl2lgtykgggkt.jpg) + +让我们比较一下世界上两种最受欢迎、最强大的编程语言:Java 和 Python!这两种语言有巨大的社区支持和库来执行几乎任何编程任务,尽管选择编程语言通常取决于开发人员的场景。在比较和对比之后,请投票分享你的观点。 + +### 是什么? + +* **Java** 是一门通用面向对象的编程语言,主要用于开发从移动端到 Web 到企业级应用的各种应用。 +* **Python** 是一门高级面向对象的编程语言,主要用于 Web 开发、人工智能、机器学习、自动化和其他数据科学应用。 + +### 创建者 + +* **Java** 是由 James Gosling(Sun Microsystems)创造的。 +* **Python** 是由 Guido van Rossum 创造的。 + +### 开源状态 + +* **Java** 是免费的,(大部分)开源,但商业用途除外。 +* **Python** 对于所有场景都是免费、开源的。 + +### 平台依赖 + +* **Java** 根据它的 WORA (“一次编写,到处运行write once, run anywhere”)哲学,它是平台无关的。 +* **Python** 依赖于平台。 + +### 编译或解释 + +* **Java** 是一门编译语言。Java 程序在编译时转换为字节码,而不是运行时。 +* **Python** 是一门解释性语言。Python 程序在运行时进行解释。 + +### 文件创建 + +* **Java**:编译后生成 `.class` 文件。 +* **Python**:在运行期,创建 `.pyc` 文件。 + +### 错误类型 + +* **Java** 有 2 种错误类型:编译和运行时错误。 +* **Python** 有 1 种错误类型:回溯(或运行时)错误。 + +### 静态或动态类型 + +* **Java** 是静态类型。当初始化变量时,需要在程序中指定变量的类型,因为类型检查是在编译时完成的。 +* **Python** 是动态类型。变量不需要在初始化时指定类型,因为类型检查是在运行时完成的。 + +### 语法 + +* **Java**:每个语句都需要以分号(`;` )结尾,并且代码块由大括号( `{}` )分隔。 +* **Python**:代码块通过缩进分隔(用户可以选择要使用的空格数,但在整个块中应保持一致)。 + +### 类的数量 + +* **Java**:在 Java 中的单个文件中只能存在一个公有顶级类。 +* **Python**:Python 中的单个文件中可以存在任意数量的类。 + +### 代码多少? + +* **Java** 通常比 Python 要写更多代码行。 +* **Python**通常比 Java 要写更少代码行。 + +### 多重继承 + +* **Java** 不支持多重继承(从两个或多个基类继承)。 +* **Python** 支持多重继承,但由于继承复杂性、层次结构、依赖等各种问题,它很少实现。 + +### 多线程 + +* **Java** 多线程可以支持同时运行的两个或多个并发线程。 +* **Python** 使用全局解释器锁 (GIL),一次只允许运行单个线程(一个 CPU 核)。 + +### 执行速度 + +* **Java** 的执行时间通常比 Python 快。 +* **Python** 的执行时间通常比 Java 慢。 + +### Hello world + +Java 的: + +``` +public class Hello { +   public static void main([String][3][] args) { +      [System][4].out.println("Hello Opensource.com from Java!"); +   } +} +``` + +Python 的: + +``` +print("Hello Opensource.com from Java!") +``` + +### 运行程序 + +![Java vs. Python][5] + +要运行 java 程序 `Hello.java`,你需要先编译它,这将创建一个 `Hello.class` 文件。只需运行类名 `java Hello`。对于 Python,只需运行文件 `python3 helloworld.py`。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/java-vs-python + +作者:[Archit Modi][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/architmodi +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_development_programming.png?itok=M_QDcgz5 (Developing code.) +[2]: tmp.Bpi8QYfp8j#poll +[3]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string +[4]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system +[5]: https://opensource.com/sites/default/files/uploads/python-java-hello-world_0.png (Java vs. Python) diff --git a/published/201912/20191206 5 cool terminal pagers in Fedora.md b/published/201912/20191206 5 cool terminal pagers in Fedora.md new file mode 100644 index 0000000000..8126cbc54d --- /dev/null +++ b/published/201912/20191206 5 cool terminal pagers in Fedora.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11676-1.html) +[#]: subject: (5 cool terminal pagers in Fedora) +[#]: via: (https://fedoramagazine.org/5-cool-terminal-pagers-in-fedora/) +[#]: author: (Jacob Burns https://fedoramagazine.org/author/jaek/) + +5 个最酷的终端分页器 +====== + +![][1] + +像日志或源代码这样的大文件可能会多达成千上万行,这使得在文件内导航非常困难,尤其是在终端上。此外,大多数终端仿真器的回滚缓冲区只有几百行。这可能使得无法使用打印到标准输出的实用程序(例如 `cat`、`head` 和 `tail`)在终端中浏览大型文件。在计算时代的早期,程序员通过开发用于以虚拟“页面”形式显示文本的实用程序来解决这些问题,该实用程序被形象地描述为分页器pager。 + +*分页器*提供了许多使文本文件导航更加简单的功能,包括滚动、搜索功能,以及作为命令[管道][2]的一部分而具有的功能。与大多数文本编辑器相比,某些终端分页器不需要加载整个文件即可查看,这使得它们更快,特别是对于非常大的文件。 + +在现代 Linux 计算时代,终端仿真器比以往更加复杂。它们提供了对缤纷的色彩、终端尺寸调整以及许多其它功能的支持,这些功能使得辨析屏幕上的文本变得更加轻松和高效。从诸如 `pg` 和 `more` 这样极其简单的 UNIX 实用程序,到涵盖各种使用场景的、功能广泛的复杂程序,终端分页器也经历了类似的演变。考虑到这一点,我们或“多”或“少”地汇总了一些最受欢迎的终端分页实用程序的列表。 + +### more + +`more` 是最早的分页器之一,最初在 3.0 BSD 版本中出现。`more` 的第一个实现由 [Daniel Halbert][3] 编写于 1978 年。从那时起,`more` 已成为许多操作系统的普遍功能,包括 Windows、OS/2,MacOS 和大多数 Linux 发行版。 + +`more` 是一个非常轻量级的实用程序。util-linux 软件包中提供的版本只有不到 2100 行的 C 语言代码。但是,这种较小的代码大小是有代价的。大多数版本的 `more` 的功能相对有限,不支持向后滚动或搜索。命令也同样精简:按回车键可滚动一行,或按空格键滚动一页。其他一些有用的命令包括: + +* 在阅读时按 `v` 键以在默认的终端编辑器中打开当前文件。 +* `/模式` 可以让你搜索下一个出现的“模式”。 +* 以多个文件作为参数调用 `more` 时,`:n` 和 `:p` 将分别打开下一个和上一个文件 +   +### less + +`less` 最初被认为是 `more` 的继承者,解决了它的一些局限性。`less` 以 `more` 的功能为基础,增加了许多有用的功能,包括向后滚动、向后搜索。它也更适合窗口大小调整。 + +`less` 中的导航方式与 `more` 类似,尽管 `less` 也从 `vi` 编辑器借用了一些有用的命令。用户可以使用熟悉的主行导航键home row navigational keys(LCTT 译注:指 左手的 `A`、`S`、`D`、`F` 和右手的 `J`、`K`、`L`、`;`,及大拇指所在的空格键)浏览文档。看一眼 `less` 的手册页,就会发现相当多的可用命令。一些特别有用的示例包括: + +* `?模式` 可让你在文件中向后搜索“模式”。 +* `&模式` 仅显示具有“模式”特征的行。这对于发现自己经常要使用 `$ grep 模式 | less` 的人特别有用。 +* 使用 `-s`(或 `–sqeueeze-blank-lines`)标志来调用 `less`,使你可以查看空白较大的文本文件。 多个换行符被简化为单个中断行。 +* 在该程序中调用的 `s 文件名` 将输入保存到 `文件名`中(如果输入来自管道)。 +* 或者,使用 `-o 文件名` 标志来调用 `less` 将把 `less` 的输入保存到 `文件名` 中。 +   +随着这些增强的功能也带来了体积的略微增大。在写作本文时,Fedora 随附的 `less` 版本大约有 25000 行源代码。当然,除非是受存储限制最大的系统,在所有其它的系统上这都不是问题。`less` 比 `more` 功能更多。 + +### most + +`less` 旨在扩展 `more` 的现有功能,而 `most` 采用另一种方法。`most` 不是在传统的单个文件视图上进行扩展,而是使用户能够将其视图拆分为“窗口”。每个窗口以不同的查看模式包含不同的文件。 + +重要的是,`most` 考虑了其输入文本的宽度。默认的查看模式是不换行的(`less` 中的 `-S` 参数),此功能在处理“宽”文件时特别有用。尽管对于某些用户来说,这些设计决策可能代表着与传统的重大偏离,但最终结果却非常强大。 + +除了 `more` 提供的导航命令外,`most` 使用直观的助记符进行文件导航。例如,`t` 移至文件的顶部(Top),而 `b` 移至底部(Bottom)。这样,不熟悉 `vi` 及其衍生品的用户会发现 `most` 非常简单好用。 + +`most` 的与众不同之处在于它能够快速轻松地拆分窗口和上下文。例如,可以使用以下命令打开两个不同的文本文件: + +``` +$ most textFile1.txt textFile2.txt +``` + +为了水平拆分屏幕,请使用组合键 `Ctrl+x, 2` 或 `Ctrl+w, 2`。 `:n` 命令将在给定窗口中打开下一个文件参数,提供两个文件的分屏视图: + +![][4] + +如果在一个窗口中关闭自动换行,它不会影响其他窗口的行为。(行末的)`\` 字符表示换行或折叠,而 `$` 字符表示文件超出了当前窗口的限制。 + +### pspg + +使用 SQL 数据库的人员通常需要能够一目了然地检查数据库的内容。许多流行的开源 DBMS(例如 MySQL 和 PostGreSQL)的命令行界面都使用系统默认的分页器来查看无法显示在单个屏幕上的输出。诸如 `more` 和 `less` 之类的实用程序是围绕呈现文本文件的想法而设计的,但是对于更结构化的数据,还有一些不足之处。天真的文本分页程序没有宽的表格数据的概念,当处理大型查询时,这可能会令人感到沮丧。 + +[pspg][5] 试图通过为用户提供在查看时冻结列、*原位*排序数据并为输出着色的功能来解决此问题。尽管`pspg` 最初是专门用作 `psql` 的分页器的替代品,但该程序还支持查看 CSV 数据,并且是 `mysql` 和 `pgcli` 的合适的直接替代品。 + +### Vim + +在现代的颜色鲜明的终端中,无休止的黑色页面上的灰色文字感觉太过时了。强大的文本编辑器(如 `vim`)提供的语法高亮显示选项对于浏览源代码很有用。此外,`vim` 提供的搜索功能远远超过了竞争对手。考虑到这一点,`vim` 附带了一个 shell 脚本 `less.sh`,该脚本可以使 `vim` 替代传统的分页器。 + +要将 `vim` 设置为手册页的[默认分页器][6],请将以下内容添加到 shell 的配置中(如果使用默认的bash shell 的话是 `~/.bashrc`): + +``` +export MANPAGER="/bin/sh -c \"col -b | vim -c 'set ft=man ts=8 nomod nolist nonu noma' -\"" +``` + +或者,要将 `vim` 设置为系统范围内的默认分页器,请找到 `less.sh` 脚本。(你可以在当前 Fedora 系统上的 `/usr/share/vim/vim81/macros/` 找到它。)将此位置导出为变量 `PAGER` 以将其设置为默认值,或者将其设置为别名以显式调用它。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/5-cool-terminal-pagers-in-fedora/ + +作者:[Jacob Burns][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/jaek/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/11/5-pagers-816x345.jpg +[2]: https://fedoramagazine.org/command-line-quick-tips-using-pipes-to-connect-tools/ +[3]: https://danhalbert.org/more.html +[4]: https://fedoramagazine.org/wp-content/uploads/2019/11/image-2.png +[5]: https://github.com/okbob/pspg +[6]: https://zameermanji.com/blog/2012/12/30/using-vim-as-manpager/ +[7]: https://unsplash.com/@zyljosa?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[8]: https://unsplash.com/s/photos/pages?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/published/201912/20191206 6 Ways to Send Email from the Linux Command Line.md b/published/201912/20191206 6 Ways to Send Email from the Linux Command Line.md new file mode 100644 index 0000000000..dcfb8ff8ce --- /dev/null +++ b/published/201912/20191206 6 Ways to Send Email from the Linux Command Line.md @@ -0,0 +1,225 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11663-1.html) +[#]: subject: (6 Ways to Send Email from the Linux Command Line) +[#]: via: (https://www.2daygeek.com/6-ways-to-send-email-from-the-linux-command-line/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +Linux 命令行发送邮件的 5 种方法 +====== + +当你需要在 shell 脚本中创建邮件时,就需要用到命令行发送邮件的知识。Linux 中有很多命令可以实现发送邮件。本教程中包含了最流行的 5 个命令行邮件客户端,你可以选择其中一个。这 5 个命令分别是: + + * `mail` / `mailx` + * `mutt` + * `mpack` + * `sendmail` + * `ssmtp` + +### 工作原理 + +我先从整体上来解释下 Linux 中邮件命令怎么把邮件传递给收件人的。邮件命令撰写邮件并发送给一个本地邮件传输代理(MTA,如 sendmail、Postfix)。邮件服务器和远程邮件服务器之间通信以实际发送和接收邮件。下面的流程可以看得更详细。 + +![](https://www.2daygeek.com/wp-content/uploads/2019/12/smtp-simple-mail-transfer-protocol.png) + +### 1) 如何在 Linux 上安装 mail/mailx 命令 + +`mail` 命令是 Linux 终端发送邮件用的最多的命令。`mailx` 是 `mail` 命令的更新版本,基于 Berkeley Mail 8.1,意在提供 POSIX `mailx` 命令的功能,并支持 MIME、IMAP、POP3、SMTP 和 S/MIME 扩展。mailx 在某些交互特性上更加强大,如缓冲邮件消息、垃圾邮件评分和过滤等。在 Linux 发行版上,`mail` 命令是 `mailx` 命令的软链接。可以运行下面的命令从官方发行版仓库安装 `mail` 命令。 + +对于 Debian/Ubuntu 系统,使用 [APT-GET 命令][3] 或 [APT 命令][4] 安装 mailutils。 + +``` +$ sudo apt-get install mailutils +``` + +对于 RHEL/CentOS 系统,使用 [YUM 命令][5] 安装 mailx。 + +``` +$ sudo yum install mailx +``` + +对于 Fedora 系统,使用 [DNF 命令][6] 安装 mailx。 + +``` +$ sudo dnf install mailx +``` + +#### 1a) 如何在 Linux 上使用 mail 命令发送邮件 + +`mail` 命令简单易用。如果你不需要发送附件,使用下面的 `mail` 命令格式就可以发送邮件了: + +``` +$ echo "This is the mail body" | mail -s "Subject" 2daygeek@gmail.com +``` + +如果你要发送附件,使用下面的 `mail` 命令格式: + +``` +$ echo "This is the mail body" | mail -a test1.txt -s "Subject" 2daygeek@gmail.com +``` + +- `-a`:用于在基于 Red Hat 的系统上添加附件。 +- `-A`:用于在基于 Debian 的系统上添加附件。 +- `-s`:指定消息标题。 + +### 2) 如何在 Linux 上安装 mutt 命令 + +`mutt` 是另一个很受欢迎的在 Linux 终端发送邮件的命令。`mutt` 是一个小而强大的基于文本的程序,用来在 unix 操作系统下阅读和发送电子邮件,并支持彩色终端、MIME、OpenPGP 和按邮件线索排序的模式。可以运行下面的命令从官方发行版仓库安装 `mutt` 命令。 + +对于 Debian/Ubuntu 系统,使用 [APT-GET 命令][3] 或 [APT 命令][4] 安装 mutt。 + +``` +$ sudo apt-get install mutt +``` + +对于 RHEL/CentOS 系统,使用 [YUM 命令][5] 安装 mutt。 + +``` +$ sudo yum install mutt +``` + +对于 Fedora 系统,使用 [DNF 命令][6] 安装 mutt。 + +``` +$ sudo dnf install mutt +``` + +#### 2b) 如何在 Linux 上使用 mutt 命令发送邮件 + +`mutt` 一样简单易用。如果你不需要发送附件,使用下面的 `mutt` 命令格式就可以发送邮件了: + +``` +$ echo "This is the mail body" | mutt -s "Subject" 2daygeek@gmail.com +``` + +如果你要发送附件,使用下面的 `mutt` 命令格式: + +``` +$ echo "This is the mail body" | mutt -s "Subject" 2daygeek@gmail.com -a test1.txt +``` + +### 3) 如何在 Linux 上安装 mpack 命令 + +`mpack` 是另一个很受欢迎的在 Linux 终端上发送邮件的命令。`mpack` 程序会在一个或多个 MIME 消息中对命名的文件进行编码。编码后的消息被发送到一个或多个收件人。可以运行下面的命令从官方发行版仓库安装 `mpack` 命令。 + +对于 Debian/Ubuntu 系统,使用 [APT-GET 命令][3] 或 [APT 命令][4] 安装 mpack。 + +``` +$ sudo apt-get install mpack +``` + +对于 RHEL/CentOS 系统,使用 [YUM 命令][5] 安装 mpack。 + +``` +$ sudo yum install mpack +``` + +对于 Fedora 系统,使用 [DNF 命令][6] 安装 mpack。 + +``` +$ sudo dnf install mpack +``` + +#### 3a) 如何在 Linux 上使用 mpack 命令发送邮件 + +`mpack` 同样简单易用。如果你不需要发送附件,使用下面的 `mpack` 命令格式就可以发送邮件了: + +``` +$ echo "This is the mail body" | mpack -s "Subject" 2daygeek@gmail.com +``` + +如果你要发送附件,使用下面的 mpack 命令格式: + +``` +$ echo "This is the mail body" | mpack -s "Subject" 2daygeek@gmail.com -a test1.txt +``` + +### 4) 如何在 Linux 上安装 sendmail 命令 + +sendmail 是一个上广泛使用的通用 SMTP 服务器,你也可以从命令行用 `sendmail` 发邮件。可以运行下面的命令从官方发行版仓库安装 `sendmail` 命令。 + +对于 Debian/Ubuntu 系统,使用 [APT-GET 命令][3] 或 [APT 命令][4]安装 sendmail。 + +``` +$ sudo apt-get install sendmail +``` + +对于 RHEL/CentOS 系统,使用 [YUM 命令][5] 安装 sendmail。 + +``` +$ sudo yum install sendmail +``` + +对于 Fedora 系统,使用 [DNF 命令][6] 安装 sendmail。 + +``` +$ sudo dnf install sendmail +``` + +#### 4a) 如何在 Linux 上使用 sendmail 命令发送邮件 + +`sendmail` 同样简单易用。使用下面的 `sendmail` 命令发送邮件。 + +``` +$ echo -e "Subject: Test Mail\nThis is the mail body" > /tmp/send-mail.txt +``` + +``` +$ sendmail 2daygeek@gmail.com < send-mail.txt +``` + +### 5) 如何在 Linux 上安装 ssmtp 命令 + +`ssmtp` 是类似 `sendmail` 的一个只发送不接收的工具,可以把邮件从本地计算机传递到配置好的 邮件主机(mailhub)。用户可以在 Linux 命令行用 `ssmtp` 把邮件发送到 SMTP 服务器。可以运行下面的命令从官方发行版仓库安装 `ssmtp` 命令。 + +对于 Debian/Ubuntu 系统,使用 [APT-GET 命令][3] 或 [APT 命令][4]安装 ssmtp。 + +``` +$ sudo apt-get install ssmtp +``` + +对于 RHEL/CentOS 系统,使用 [YUM 命令][5] 安装 ssmtp。 + +``` +$ sudo yum install ssmtp +``` + +对于 Fedora 系统,使用 [DNF 命令][6] 安装 ssmtp。 + +``` +$ sudo dnf install ssmtp +``` + +### 5a) 如何在 Linux 上使用 ssmtp 命令发送邮件 + +`ssmtp` 同样简单易用。使用下面的 `ssmtp` 命令格式发送邮件。 + +``` +$ echo -e "Subject: Test Mail\nThis is the mail body" > /tmp/ssmtp-mail.txt +``` + +``` +$ ssmtp 2daygeek@gmail.com < /tmp/ssmtp-mail.txt +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/6-ways-to-send-email-from-the-linux-command-line/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: https://www.2daygeek.com/wp-content/uploads/2019/12/smtp-simple-mail-transfer-protocol.png +[3]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[4]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[5]: https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ +[6]: https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ diff --git a/published/201912/20191206 Pekwm- A lightweight Linux desktop.md b/published/201912/20191206 Pekwm- A lightweight Linux desktop.md new file mode 100644 index 0000000000..099fe46553 --- /dev/null +++ b/published/201912/20191206 Pekwm- A lightweight Linux desktop.md @@ -0,0 +1,93 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11670-1.html) +[#]: subject: (Pekwm: A lightweight Linux desktop) +[#]: via: (https://opensource.com/article/19/12/pekwm-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Pekwm:一个轻量级的 Linux 桌面 +====== + +> 本文是 24 天 Linux 桌面特别系列的一部分。如果你是一个觉得传统桌面会妨碍你的极简主义者,那么试试 Pekwm Linux 桌面。 + +![](https://img.linux.net.cn/data/attachment/album/201912/13/133626l5t2z2awjstu9zbe.png) + +假设你想要一个轻量级桌面环境,它只需要能在屏幕上显示图形、四处移动窗口,而别无杂物。你会发现传统桌面的通知、任务栏和系统托盘会妨碍你的工作。你想主要通过终端工作,但也希望运行图形应用。如果听起来像是你的想法,那么 [Pekwm][2] 可能是你一直在寻找的东西。 + +Pekwm 的灵感大概来自于 Window Maker 和 Fluxbox 等。它提供了一个应用菜单、窗口装饰、而不是一大堆其他东西。它非常适合极简主义者,即那些希望节省资源的用户和喜欢在终端工作的用户。 + +从发行版仓库安装 Pekwm。安装后,请先退出当前桌面会话,以便可以登录到新桌面。默认情况下,会话管理器(KDM、GDM、LightDM 或 XDM,具体取决于你的设置)将继续登录到以前的桌面,因此需要在登录之前修改它。 + +在 GDM 中覆盖之前的桌面: + +![Selecting your desktop in GDM][3] + +在 KDM 中: + +![Selecting your desktop in KDM][4] + +第一次登录 Pekwm 时,你可能会看到黑屏。可能难以置信,但这是正常的。你看到的是一个空白桌面,没有背景壁纸。你可以使用 `feh` 命令设置壁纸(你可能需要从仓库中安装它)。此命令有几个用于设置背景的选项,包括 `--bg-fill` 用壁纸填充屏幕,`--bg-scale` 缩放到合适大小,等等。 + +``` +$ feh --bg-fill ~/Pictures/wallpapers/mybackground.jpg +``` + +### 应用菜单 + +默认情况下,Pekwm 自动生成一个菜单,可在桌面上的任意位置右键单击,从而可让你运行应用。此菜单还提供一些首选项设置,例如选择主题和注销 Pekwm 会话。 + +![Pekwm running on Fedora][5] + +### 配置 + +Pekwm 主要通过保存在 `$HOME/.pekwm` 下的文本配置文件来配置。`menu` 文件定义你的应用菜单,`keys` 文件定义键盘快捷键,等等。 + +`start` 文件是在 Pekwm 启动后执行的 shell 脚本。它类似于传统 Unix 系统上的 `rc.local`。它故意放在最后执行的,因此这里的东西将覆盖之前的一切。这是一个重要文件,它可能是你要设置背景的地方,以便*你的*选择会覆盖正在使用的主题的默认值。 + +`start` 文件也是可以启动 dockapp 的地方。dockapp 是一种小程序,它在 Window Maker 和 Fluxbox 引起了人们的关注。它们通常有网络监视器、时钟、音频设置,和其它你可能会在系统托盘或作为一个 KDE plasmoid 或者完整桌面环境中看到的小部件。你可能会在发行版仓库中找到一些 dockapp,或者可以在 [dockapps.net][6] 上在线查找它们。 + +你可以在启动时运行 dockapp,将它们列在 `start` 文件中,跟上 `&` 符号: + + +``` +feh --bg-fill ~/Pictures/wallpapers/mybackground.jpg +wmnd & +bubblemon -d & +``` + +`start` 文件必须[设置为可执行][7],才能在 Pekwm 启动时运行。 + +``` +$ chmod +x $HOME/.pekwm/start +``` + +### 功能 + +Pekwm 的功能不多,但这就是它的美。如果你希望在桌面上运行额外的服务,那么由你来启动这些服务。如果你仍在学习 Linux,这是了解那些与完整的桌面环境捆绑在一起时通常不会注意到的微小 GUI 组件的好方法(像是[任务栏][8])。这也习惯一些 Linux 命令(例如 [nmcli][9])的好方法。 + +Pekwm 是一个有趣的窗口管理器。它分散、简洁、轻巧。请试试看! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/pekwm-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_penguin_green.png?itok=ENdVzW22 (Penguin with green background) +[2]: http://www.pekwm.org/ +[3]: https://opensource.com/sites/default/files/uploads/advent-gdm_1.jpg (Selecting your desktop in GDM) +[4]: https://opensource.com/sites/default/files/uploads/advent-enlightenment-kdm_0.jpg (Selecting your desktop in KDM) +[5]: https://opensource.com/sites/default/files/uploads/advent-pekwm.jpg (Pekwm running on Fedora) +[6]: http://dockapps.net +[7]: https://opensource.com/article/19/6/understanding-linux-permissions +[8]: https://opensource.com/article/19/1/productivity-tool-tint2 +[9]: https://opensource.com/article/19/5/set-static-network-connection-linux diff --git a/published/201912/20191207 Getting started with the GNOME Linux desktop.md b/published/201912/20191207 Getting started with the GNOME Linux desktop.md new file mode 100644 index 0000000000..d762dbe15c --- /dev/null +++ b/published/201912/20191207 Getting started with the GNOME Linux desktop.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11675-1.html) +[#]: subject: (Getting started with the GNOME Linux desktop) +[#]: via: (https://opensource.com/article/19/12/gnome-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +GNOME Linux 桌面入门 +====== + +> 本文是 24 天 Linux 桌面特别系列的一部分。GNOME 是大多数现代 Linux 发行版的默认桌面,它干净、简单、组织良好。 + +![](https://img.linux.net.cn/data/attachment/album/201912/14/150510z2227x177x8liwww.jpg) + +[GNOME][2] 项目理所应当是 Linux 桌面的宠儿。它起初是专有桌面(当时包括 KDE)的自由开源的桌面替代品,此后一直发展强劲。GNOME 采用了[由 GIMP 项目开发][3]的 GTK+,并将其开发为强大的通用 GTK 框架。该项目开创了用户界面的先声,挑战了桌面“应有”外观的先入之见,并为用户提供了新的范例和选项。 + +在大多数主流现代 Linux 发行版(包括 RHEL、Fedora、Debian 和 Ubuntu)中,GNOME 作为默认桌面而广泛使用。如果你的发行版不提供它的某个版本,那么你可以从软件仓库中安装 GNOME。但是,在执行此操作之前,请注意,为了提供完整的桌面体验,这会随桌面一起安装许多 GNOME 应用。如果你在用其他桌面,那么你可能会发现有冗余的应用(两个 PDF 阅读器、两个媒体播放器、两个文件管理器,等等)。如果你只想尝试 GNOME 桌面,请考虑在虚拟机,如 [GNOME Boxes][4],中安装 GNOME 发行版。 + +### GNOME 功能 + +GNOME 桌面很干净,顶部有一个简单的任务栏,右上角的系统托盘中只有很少的图标。GNOME 上没有桌面图标,这是设计使然。如果你是喜欢在桌面上保存*任何东西*的用户,那么你可能会意识到桌面会定期地变得混乱,而且,更糟糕的是,由于你的应用掩盖了桌面,因此桌面永远不会显示出来。 + +GNOME 解决了两个问题:(在功能上)没有桌面,并且动态生成新的虚拟工作区,因此你可以在全屏模式下运行应用。如果你常把屏幕弄乱,那么可能需要一些时间来习惯,但实际上,从各个方面来说,这都是一种改进的工作流程。你将学习如何使文件井井有条(或者将它们分散在家目录中),并且可以像在手机上一样快速地在屏幕之间切换。 + +当然,并非所有应用都设计为在全屏模式下运行,因此,如果你更喜欢单击切换窗口,也可以这样做。 + +![GNOME running on Debian][5] + +GNOME 哲学褒扬了 Canonical 对常见任务的解决方案。在 GNOME 中,你通常不会发现“回字有四种写法”。你会找到一种或两种官方方法来完成一项任务,你了解了这些方法后,便只需记住这些即​​可。它非常简单,但由于它在 Linux 上运行,因此在技术上也很灵活(毕竟,你不必因为运行 GNOME 桌面而必须要使用 GNOME 应用)。 + +### 应用菜单 + +要访问名为“活动”的应用菜单,请在桌面的左上角单击。此菜单将占满整个屏幕,屏幕最左侧有一栏常见应用的 dock,或可以在网格中浏览应用的图标。你可以通过浏览已安装的应用,或输入软件的头几个字母来过滤列表,然后来启动应用。 + +![GNOME activities][6] + +### GNOME 应用 + +GNOME 不仅是桌面。它是一个桌面以及一组丰富的集成应用,例如 Gedit 文本编辑器、Evince PDF 查看器、Web 浏览器、图像查看器、Nautilus 文件管理器等等。GNOME 应用(例如桌面本身)遵循 [GNOME 人机界面指南][7],因此用户体验既愉悦又一致。无论你是否使用 GNOME 桌面,都可能使用 GTK 应用,也可能会使用 GNOME 应用。 + +### GNOME 3 及更高版本 + +GNOME 项目进展顺利,还有几个令人兴奋的项目(例如 MATE 和 [Cinnamon][8])。它流行、令人舒适,被视为 Linux 桌面的代表。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/gnome-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/custom_gnomes.png?itok=iG98iL8d (Gnomes in a window.) +[2]: https://www.gnome.org/ +[3]: https://www.gtk.org/overview.php +[4]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization +[5]: https://opensource.com/sites/default/files/uploads/advent-gnome.jpg (GNOME running on Debian) +[6]: https://opensource.com/sites/default/files/uploads/advent-gnome-activities.jpg (GNOME activities) +[7]: https://developer.gnome.org/hig/stable/ +[8]: https://opensource.com/article/19/11/advent-2019-cinnamon diff --git a/published/201912/20191209 Counting down the days using bash.md b/published/201912/20191209 Counting down the days using bash.md new file mode 100644 index 0000000000..d68dc742b6 --- /dev/null +++ b/published/201912/20191209 Counting down the days using bash.md @@ -0,0 +1,125 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11672-1.html) +[#]: subject: (Counting down the days using bash) +[#]: via: (https://www.networkworld.com/article/3487712/counting-down-the-days-using-bash.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +用 bash 倒计时日期 +====== + +> 需要知道重要事件发生前有多少天吗?让 Linux bash 和 date 命令可以帮助你! + +![](https://img.linux.net.cn/data/attachment/album/201912/13/140725vdc3c7zj0o7ozc7j.jpg) + +随着即将来临的重要假期,你可能需要提醒你还要准备多久。 + +幸运的是,你可以从 `date` 命令获得很多帮助。在本篇中,我们将研究 `date` 和 bash 脚本如何告诉你从今天到你预期的事件之间有多少天。 + +首先,在进行之前有几个提示。`date` 命令的 `%j` 选项将以 1 至 366 之间的数字显示当前日期。如你所想的一样,1 月 1 日将显示为 1,12 月 31 日将显示为 365 或 366,这取决于是否是闰年。继续尝试。你应该会看到以下内容: + +``` +$ date +%j +339 +``` + +但是,你可以通过以下方式,在 `date` 命令中得到一年中*任何*一天的数字: + +``` +$ date -d "Mar 18" +%j +077 +``` + +要记住的是,即使该日期是过去的日期,上面命令也会向你显示*当年*的日期。但是,你可以在命令中添加年来修复该问题: + +``` +$ date -d "Apr 29" +%j +119 +$ date -d "Apr 29 2020" +%j +120 +``` + +在闰年中,4 月 29 日将是一年的 120 天,而不是 119 天。 + +如果你想倒数圣诞节之前的日子并且不想在挂历上留下指纹,你可以使用以下脚本: + +``` +#!/bin/sh + +XMAS=`date -d "Dec 25" +%j` +TODAY=`date +%j` +DAYS=$(($XMAS - $TODAY)) + +case $DAYS in + 0) echo "It's today! Merry Christmas!";; + [0-9]*) echo "$DAYS days remaining";; + -[0-9]*) echo "Oops, you missed it";; +esac +``` + +在此脚本中,我们获取 12 月 25 日和今天的日期,然后相减。如果结果是正数,我们将显示剩余天数。如果为零,则发出 “Merry Christmas” 的消息,如果为负,那么仅告诉运行脚本的人他们错过了假期。也许他们沉迷在蛋酒中了。 + +`case` 语句由用来打印信息的语句组成,当剩余时间等于 0,或任意数字或以 `-` 符号开头的数字(也就是过去)分别打印不同的信息。 + +对于人们想要关注的任何日期,都可以使用相同方法。实际上,我们可以要求运行脚本的人员提供日期,然后让他们知道从现在到那天还有多少天。这个脚本是这样的。 + +``` +#!/bin/sh + +echo -n "Enter event date (e.g., June 6): " +read dt +EVENT=`date -d "$dt" +%j` +TODAY=`date +%j` +DAYS=`expr $EVENT - $TODAY` + +case $DAYS in + 0) echo "It's today!";; + [0-9]*) echo "$DAYS days remaining";; + -[0-9]*) echo "Oops, you missed it";; +esac +``` + +使用此脚本会遇到的一个问题,如果运行该脚本的人希望知道到第二年这个特殊日子还有多少天,他们会感到失望。即使他们输入日期时提供了年,`date -d` 命令仍将仅提供今年中的天数,而不会提供从现在到那时的天数。 + +计算从今天到某年的日期之间的天数可能有些棘手。你需要包括所有中间年份,并注意那些闰年。 + +### 使用 Unix 纪元时间 + +计算从现在到某个特殊日期之间的天数的另一种方法是利用 Unix 系统存储日期的方法。如果将自 1970 年 1 月 1 日开始的秒数转换为天数,那么就可以很容易地执行此操作,如下脚本所示: + +``` +#!/bin/bash + +echo -n "Enter target date (e.g., Mar 18 2021)> " +read target_date +today=`echo $(($(date --utc --date "$1" +%s)/86400))` +target=`echo $(($(date --utc --date "$target_date" +%s)/86400))` +days=`expr $target - $today` +echo "$days days until $target_date" +``` + +解释一下,86400 是一天中的秒数。将自 Unix 纪元开始以来的秒数除该数即为天数。 + +``` +$ ./countdown +Enter target date (e.g., Mar 18 2021)> Mar 18 2020 +104 days until Mar 18 2020 +``` + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3487712/counting-down-the-days-using-bash.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/201912/20191210 3 easy steps to update your apps to Python 3.md b/published/201912/20191210 3 easy steps to update your apps to Python 3.md new file mode 100644 index 0000000000..19ff8e16db --- /dev/null +++ b/published/201912/20191210 3 easy steps to update your apps to Python 3.md @@ -0,0 +1,158 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11696-1.html) +[#]: subject: (3 easy steps to update your apps to Python 3) +[#]: via: (https://opensource.com/article/19/12/update-apps-python-3) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +将你的应用迁移到 Python 3 的三个步骤 +====== + +> Python 2 气数将尽,是时候将你的项目从 Python 2 迁移到 Python 3 了。 + +![](https://img.linux.net.cn/data/attachment/album/201912/20/095224r0kp79s0cnc0z77p.jpg) + +Python 2.x 很快就要[失去官方支持][2]了,尽管如此,从 Python 2 迁移到 Python 3 却并没有想象中那么难。我在上周用了一个晚上的时间将一个 3D 渲染器的前端代码及其对应的 [PySide][3] 迁移到 Python 3,回想起来,尽管在迁移过程中无可避免地会遇到一些牵一发而动全身的修改,但整个过程相比起痛苦的重构来说简直是出奇地简单。 + +每个人都别无选择地有各种必须迁移的原因:或许是觉得已经拖延太久了,或许是依赖了某个在 Python 2 下不再维护的模块。但如果你仅仅是想通过做一些事情来对开源做贡献,那么把一个 Python 2 应用迁移到 Python 3 就是一个简单而又有意义的做法。 + +无论你从 Python 2 迁移到 Python 3 的原因是什么,这都是一项重要的任务。按照以下三个步骤,可以让你把任务完成得更加清晰。 + +### 1、使用 2to3 + +从几年前开始,Python 在你或许还不知道的情况下就已经自带了一个名叫 [2to3][4] 的脚本,它可以帮助你实现大部分代码从 Python 2 到 Python 3 的自动转换。 + +下面是一段使用 Python 2.6 编写的代码: + +``` +#!/usr/bin/env python +# -*- coding: utf-8 -*- +mystring = u'abcdé' +print ord(mystring[-1]) +``` + +对其执行 2to3 脚本: + + +``` +$ 2to3 example.py +RefactoringTool: Refactored example.py +--- example.py (original) ++++ example.py (refactored) +@@ -1,5 +1,5 @@ + #!/usr/bin/env python + # -*- coding: utf-8 -*- + +-mystring = u'abcdé' +-print ord(mystring[-1]) ++mystring = 'abcdé' ++print(ord(mystring[-1])) +RefactoringTool: Files that need to be modified: +RefactoringTool: example.py +``` + +在默认情况下,`2to3` 只会对迁移到 Python 3 时必须作出修改的代码进行标示,在输出结果中显示的 Python 3 代码是直接可用的,但你可以在 2to3 加上 `-w` 或者 `--write` 参数,这样它就可以直接按照给出的方案修改你的 Python 2 代码文件了。 + +``` +$ 2to3 -w example.py +[...] +RefactoringTool: Files that were modified: +RefactoringTool: example.py +``` + +`2to3` 脚本不仅仅对单个文件有效,你还可以把它用于一个目录下的所有 Python 文件,同时它也会递归地对所有子目录下的 Python 文件都生效。 + +### 2、使用 Pylint 或 Pyflakes + +有一些不良的代码在 Python 2 下运行是没有异常的,在 Python 3 下运行则会或多或少报出错误,这种情况并不鲜见。因为这些不良代码无法通过语法转换来修复,所以 `2to3` 对它们没有效果,但一旦使用 Python 3 来运行就会产生报错。 + +要找出这种问题,你需要使用 [Pylint][5]、[Pyflakes][6](或 [flake8][7] 封装器)这类工具。其中我更喜欢 Pyflakes,它会忽略代码风格上的差异,在这一点上它和 Pylint 不同。尽管代码优美是 Python 的一大特点,但在代码迁移的层面上,“让代码功能保持一致”无疑比“让代码风格保持一致”重要得多。 + +以下是 Pyflakes 的输出样例: + +``` +$ pyflakes example/maths +example/maths/enum.py:19: undefined name 'cmp' +example/maths/enum.py:105: local variable 'e' is assigned to but never used +example/maths/enum.py:109: undefined name 'basestring' +example/maths/enum.py:208: undefined name 'EnumValueCompareError' +example/maths/enum.py:208: local variable 'e' is assigned to but never used +``` + +上面这些由 Pyflakes 输出的内容清晰地给出了代码中需要修改的问题。相比之下,Pylint 会输出多达 143 行的内容,而且多数是诸如代码缩进这样无关紧要的问题。 + +值得注意的是第 19 行这个容易产生误导的错误。从输出来看你可能会以为 `cmp` 是一个在使用前未定义的变量,实际上 `cmp` 是 Python 2 的一个内置函数,而它在 Python 3 中被移除了。而且这段代码被放在了 `try` 语句块中,除非认真检查这段代码的输出值,否则这个问题很容易被忽略掉。 + +``` +    try: +        result = cmp(self.index, other.index) +    except: +        result = 42 +        +    return result +``` + +在代码迁移过程中,你会发现很多原本在 Python 2 中能正常运行的函数都发生了变化,甚至直接在 Python 3 中被移除了。例如 PySide 的绑定方式发生了变化、`importlib` 取代了 `imp` 等等。这样的问题只能见到一个解决一个,而涉及到的功能需要重构还是直接放弃,则需要你自己权衡。但目前来说,大多数问题都是已知的,并且有[完善的文档记录][8]。所以难的不是修复问题,而是找到问题,从这个角度来说,使用 Pyflake 是很有必要的。 + +### 3、修复被破坏的 Python 2 代码 + +尽管 `2to3` 脚本能够帮助你把代码修改成兼容 Python 3 的形式,但对于一个完整的代码库,它就显得有点无能为力了,因为一些老旧的代码在 Python 3 中可能需要不同的结构来表示。在这样的情况下,只能人工进行修改。 + +例如以下代码在 Python 2.6 中可以正常运行: + +``` +class CLOCK_SPEED: +        TICKS_PER_SECOND = 16 +        TICK_RATES = [int(i * TICKS_PER_SECOND) +                      for i in (0.5, 1, 2, 3, 4, 6, 8, 11, 20)] + +class FPS: +        STATS_UPDATE_FREQUENCY = CLOCK_SPEED.TICKS_PER_SECOND +``` + +类似 `2to3` 和 Pyflakes 这些自动化工具并不能发现其中的问题,但如果上述代码使用 Python 3 来运行,解释器会认为 `CLOCK_SPEED.TICKS_PER_SECOND` 是未被明确定义的。因此就需要把代码改成面向对象的结构: + +``` +class CLOCK_SPEED: +        def TICKS_PER_SECOND(): +                TICKS_PER_SECOND = 16 +                TICK_RATES = [int(i * TICKS_PER_SECOND) +                        for i in (0.5, 1, 2, 3, 4, 6, 8, 11, 20)] +                return TICKS_PER_SECOND + +class FPS: +        STATS_UPDATE_FREQUENCY = CLOCK_SPEED.TICKS_PER_SECOND() +``` + +你也许会认为如果把 `TICKS_PER_SECOND()` 改写为一个构造函数(用 `__init__` 函数设置默认值)能让代码看起来更加简洁,但这样就需要把这个方法的调用形式从 `CLOCK_SPEED.TICKS_PER_SECOND()` 改为 `CLOCK_SPEED()` 了,这样的改动或多或少会对整个库造成一些未知的影响。如果你对整个代码库的结构烂熟于心,那么你确实可以随心所欲地作出这样的修改。但我通常认为,只要我做出了修改,都可能会影响到其它代码中的至少三处地方,因此我更倾向于不使代码的结构发生改变。 + +### 坚持信念 + +如果你正在尝试将一个大项目从 Python 2 迁移到 Python 3,也许你会觉得这是一个漫长的过程。你可能会费尽心思也找不到一条有用的报错信息,这种情况下甚至会有将代码推倒重建的冲动。但从另一个角度想,代码原本在 Python 2 中就可以运行,要让它能在 Python 3 中继续运行,你需要做的只是对它稍加转换而已。 + +但只要你完成了迁移,你就得到了这个模块或者整个应用程序的 Python 3 版本,外加 Python 官方的长期支持。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/update-apps-python-3 + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd "Hands on a keyboard with a Python book " +[2]: https://linux.cn/article-11629-1.html +[3]: https://pypi.org/project/PySide/ +[4]: https://docs.python.org/3.1/library/2to3.html +[5]: https://opensource.com/article/19/10/python-pylint-introduction +[6]: https://pypi.org/project/pyflakes/ +[7]: https://opensource.com/article/19/5/python-flake8 +[8]: https://docs.python.org/3.0/whatsnew/3.0.html + diff --git a/published/201912/20191210 Breaking Linux files into pieces with the split command.md b/published/201912/20191210 Breaking Linux files into pieces with the split command.md new file mode 100644 index 0000000000..0151b678df --- /dev/null +++ b/published/201912/20191210 Breaking Linux files into pieces with the split command.md @@ -0,0 +1,108 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11682-1.html) +[#]: subject: (Breaking Linux files into pieces with the split command) +[#]: via: (https://www.networkworld.com/article/3489256/breaking-linux-files-into-pieces-with-the-split-command.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +使用 split 命令分割 Linux 文件 +====== + +> 一些简单的 Linux 命令能让你根据需要分割以及重新组合文件,来适应存储或电子邮件附件大小的限制。 + +![Marco Verch][1] + +Linux 系统提供了一个非常易于使用的命令来分割文件。在将文件上传到限制大小的存储网站或者作为邮件附件之前,你可能需要执行此操作。要将文件分割为多个文件块,只需使用 `split` 命令。 + +``` +$ split bigfile +``` + +默认情况下,`split` 命令使用非常简单的命名方案。文件块将被命名为 `xaa`、`xab`、`xac` 等,并且,大概地,如果你将足够大的文件分割,你甚至可能会得到名为 `xza` 和 `xzz` 的块。 + +除非你要求,否则该命令将无任何反馈地运行。但是,如果你想在创建文件块时看到反馈,可以使用 `--verbose` 选项。 + +``` +$ split –-verbose bigfile +creating file 'xaa' +creating file 'xab' +creating file 'xac' +``` + +你还可以给文件命名前缀。例如,要将你原始文件分割并命名为 `bigfile.aa`、`bigfile.ab` 等,你可以将前缀添加到 `split` 命令的末尾,如下所示: + +``` +$ split –-verbose bigfile bigfile. +creating file 'bigfile.aa' +creating file 'bigfile.ab' +creating file 'bigfile.ac' +``` + +请注意,上述命令中显示的前缀的末尾会添加一个点。否则,文件将是 `bigfileaa` 之类的名称,而不是 `bigfile.aa`。 + +请注意,`split` 命令*不会*删除你的原始文件,只是创建了文件块。如果要指定文件块的大小,可以使用 `-b` 选项将其添加到命令中。例如: + +``` +$ split -b100M bigfile +``` + +文件大小可以是 KB、MB,GB,最大可以是 YB!只需使 K、M、G、T、P、E、Z 和 Y 这些合适的字母。 + +如果要基于每个块中的行数而不是字节数来拆分文件,那么可以使用 `-l`(行)选项。在此示例中,每个文件将有 1000 行,当然,最后一个文件可能有较少的行。 + +``` +$ split --verbose -l1000 logfile log. +creating file 'log.aa' +creating file 'log.ab' +creating file 'log.ac' +creating file 'log.ad' +creating file 'log.ae' +creating file 'log.af' +creating file 'log.ag' +creating file 'log.ah' +creating file 'log.ai' +creating file 'log.aj' +``` + +如果你需要在远程站点上重新组合文件,那么可以使用如下所示的 `cat` 命令轻松地完成此操作: + +``` +$ cat x?? > original.file +$ cat log.?? > original.file +``` + +上面所示的分割和组合命令适合于二进制和文本文件。在此示例中,我们将 zip 二进制文件分割为 50KB 的块,之后使用 `cat` 重新组合了它们,然后比较了组合后的文件和原始文件。`diff` 命令验证文件是否相同。 + +``` +$ split --verbose -b50K zip zip. +creating file 'zip.aa' +creating file 'zip.ab' +creating file 'zip.ac' +creating file 'zip.ad' +creating file 'zip.ae' +$ cat zip.a? > zip.new +$ diff zip zip.new +$ <== 无输出 = 无差别 +``` + +我唯一要提醒的一点的是,如果你经常使用 `split` 并使用默认命名,那么某些文件块可能会覆盖其他的文件块,甚至会比你预期的更多,因为有些是更早之前分割的。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3489256/breaking-linux-files-into-pieces-with-the-split-command.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/08/chocolate-chunks-100767935-large.jpg +[2]: https://creativecommons.org/licenses/by/2.0/legalcode +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/201912/20191210 Customize your Linux desktop with FVWM.md b/published/201912/20191210 Customize your Linux desktop with FVWM.md new file mode 100644 index 0000000000..d53602de31 --- /dev/null +++ b/published/201912/20191210 Customize your Linux desktop with FVWM.md @@ -0,0 +1,77 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11712-1.html) +[#]: subject: (Customize your Linux desktop with FVWM) +[#]: via: (https://opensource.com/article/19/12/fvwm-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +使用 FVWM 自定义 Linux 桌面 +====== + +> 本文是 24 天 Linux 桌面特别系列的一部分。如果你正在寻找轻巧、快速且简单的 Linux 窗口管理器,那么 FVWM 可以胜任。但是,如果你正在寻找可以深入、探索和魔改的窗口管理器,那么 FVWM 是必须的。 + +![](https://img.linux.net.cn/data/attachment/album/201912/25/062800dwh3yhfcpx3ggjxp.jpg) + +[FVWM][2] 窗口管理器最早脱胎于对 1993 年的 [TWM][3] 的修改。经过几年的迭代,诞生了一个可高度自定义的环境,它可以配置任何行为、动作或事件。它支持自定义键绑定、鼠标手势、主题、脚本等。 + +尽管 FVWM 在安装后即可投入使用,但默认分发版本仅提供了极其少的配置。这是开始自定义桌面环境的良好基础,但是,如果你只想将其用作桌面,那么可能要安装由其它用户发布的完整配置版本。FVWM 有几种不同的分发版,包括模仿 Windows 95 的 FVWM95(至少在外观和布局上)。我尝试了 [FVWM-Crystal][4],这是一个具有一些现代 Linux 桌面约定的现代主题。 + +可以从 Linux 发行版的软件仓库中安装要尝试的 FVWM 分发版。如果找不到特定的 FVWM 分发版,那么可以安装基础的 FVWM2 包,然后进入 [Box-Look.org][5] 手动下载主题包。这样就需要更多的工作,但比从头开始构建要少。 + +安装后,请注销当前的桌面会话,以便你可以登录 FVWM。默认情况下,会话管理器(KDM、GDM、LightDM 或 XDM,取决于你的设置)将继续登录到以前的桌面,因此你必须在登录之前覆盖该桌面。 + +对于 GDM: + +![Select your desktop session in GDM][6] + +对于 KDM: + +![Select your desktop session with KDM][7] + +### FVWM 桌面 + +无论你使用什么主题和配置,当你在桌面上单击鼠标左键时,FVWM 至少会显示一个菜单。菜单的内容取决于你所安装的内容。FVWM-Crystal 分发版中的菜单包含对常用首选项的快速访问,例如屏幕分辨率、壁纸设置、窗口装饰等。 + +同 FVWM 中的几乎所有东西一样,你可以编辑菜单中你要想的内容,但 FVWM-Crystal 的特色在于其应用菜单栏。应用菜单位于屏幕的左上角,每个图标都包含了相关的应用启动器的菜单。例如,GIMP 图标表示图像编辑器,KDevelop 图标表示集成开发环境(IDE),GNU 图标表示文本编辑器,等等,具体取决于你在系统上安装的程序。 + +![FVWM-crystal running on Slackware 14.2][8] + +FVWM-Crystal 还提供了虚拟桌面、任务栏、时钟和应用栏。 + +关于背景,你可以使用与 FVWM-Crystal 捆绑在一起的壁纸,也可以使用 `feh` 命令设置自己的壁纸(你可能需要从仓库中安装它)。此命令有一些设置背景的选项,包括 `--bg-scale` 使用你选择的图片缩放填充屏幕,`--bg-fill` 直接填充而不缩放图片,等等。 + +``` +$ feh --bg-scale ~/Pictures/wallpapers/mybackground.jpg +``` + +大多数配置文件都包含在 `$HOME/.fvwm-crystal` 中,某些系统范围的默认文件位于 `/usr/share/fvwm-crystal`。 + +### 自己尝试一下 + +FVWM 是大多作为一个桌面构建平台,它也是窗口管理器。它不会为你做到面面俱到,它期望你来配置尽可能的一切。 + +如果你正在寻找轻巧、快速且简单的窗口管理器,那么 FVWM 可以胜任。但是,如果你正在寻找可以深入、探索和魔改的窗口管理器,那么 FVWM 是必须的。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/fvwm-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: http://www.fvwm.org/ +[3]: https://en.wikipedia.org/wiki/Twm +[4]: https://www.box-look.org/p/1018270/ +[5]: http://box-look.org +[6]: https://opensource.com/sites/default/files/advent-gdm_0.jpg (Select your desktop session in GDM) +[7]: https://opensource.com/sites/default/files/advent-kdm.jpg (Select your desktop session with KDM) +[8]: https://opensource.com/sites/default/files/advent-fvwm-crystal.jpg (FVWM-crystal running on Slackware 14.2) diff --git a/published/201912/20191211 Annotate screenshots on Linux with Ksnip.md b/published/201912/20191211 Annotate screenshots on Linux with Ksnip.md new file mode 100644 index 0000000000..2e940a50cd --- /dev/null +++ b/published/201912/20191211 Annotate screenshots on Linux with Ksnip.md @@ -0,0 +1,100 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11695-1.html) +[#]: subject: (Annotate screenshots on Linux with Ksnip) +[#]: via: (https://opensource.com/article/19/12/annotate-screenshots-linux-ksnip) +[#]: author: (Clayton Dewey https://opensource.com/users/cedewey) + +在 Linux 上使用 Ksnip 注释截图 +====== + +> Ksnip 让你能轻松地在 Linux 中创建和标记截图。 + +![a checklist for a team][1] + +我最近从 MacOS 切换到了 [Elementary OS][2],这是一个专注于易用性和隐私性的 Linux 发行版。作为用户体验设计师和自由软件支持者,我会经常截图并进行注释。在尝试了几种不同的工具之后,到目前为止,我最喜欢的工具是 [Ksnip][3],它是 GPLv2 许可下的一种开源工具。 + +![Ksnip screenshot][4] + +### 安装 + +使用你首选的包管理器安装 Ksnip。我通过 Apt 安装了它: + +``` +sudo apt-get install ksnip +``` + +### 配置 + +Ksnip 有许多配置选项,包括: + +* 保存截图的地方 +* 默认截图的文件名 +* 图像采集器行为 +* 光标颜色和宽度 +* 文字字体 + +你也可以将其与你的 Imgur 帐户集成。 + +![Ksnip configuration options][5] + +### 用法 + +Ksnip 提供了大量的[功能][6]。我最喜欢的 Ksnip 部分是它拥有我需要的所有注释工具(还有一个我没想到的工具!)。 + +你可以使用以下注释: + + * 钢笔 + * 记号笔 + * 矩形 + * 椭圆 + * 文字 + +你还可以模糊区域来移除敏感信息。还有使用我最喜欢的新工具:用于在界面上表示步骤的带数字的点。 + +### 关于作者 + +我非常喜欢 Ksnip,因此我联系了作者 [Damir Porobic][7] 来了解有关该项目的更多信息。 + +当我问到是什么启发了他编写 Ksnip 时,他说: + +> “几年前我从 Windows 切换到 Linux,却没有了在 Windows 中常用的 Windows Snipping Tool。当时的所有其他截图工具要么很大(很多按钮和复杂功能),要么缺少诸如注释等关键功能,所以我决定编写一个简单的 Windows Snipping Tool 克隆版,但是随着时间的流逝,它开始有越来越多的功能。“ + +这正是我在评估截图工具时发现的。他花时间构建解决方案并免费共享给他人使用,这真是太好了。 + +至于 Ksnip 的未来,Damir 希望添加全局快捷方式(至少对于 Windows 是这样)和用于新截图的选项卡,并允许该应用在后台运行。GitHub 上的功能请求列表也越来越多。 + +### 帮助的方式 + +Damir 最需要的是帮助开发 Ksnip。他和他的妻子很快就会有孩子了,所以他将没有太多的时间放在这个项目上。不过,他可以检查和接受拉取请求。 + +此外,此项目还可以通过 Snap 、Flatpak 以及 MacOS 安装包、Windows 安装包等其他安装方式安装。如果你想提供帮助,请查看 Ksnip 的 README 的 [Contribution][8] 部分。 + +* * * + +> 此文章最初发表在 [Agaric Tech Cooperative 的博客][9]上,并经允许重新发布。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/annotate-screenshots-linux-ksnip + +作者:[Clayton Dewey][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/cedewey +[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://elementary.io/ +[3]: https://github.com/damirporobic/ksnip +[4]: https://opensource.com/sites/default/files/uploads/ksnip.png (Ksnip screenshot) +[5]: https://opensource.com/sites/default/files/uploads/ksnip-configuration.png (Ksnip configuration options) +[6]: https://github.com/DamirPorobic/ksnip#features +[7]: https://github.com/damirporobic/ +[8]: https://github.com/DamirPorobic/ksnip/blob/master/README.md#contribution +[9]: https://agaric.coop/blog/annotate-screenshots-linux-ksnip diff --git a/published/201912/20191211 How to Find High CPU Consumption Processes in Linux.md b/published/201912/20191211 How to Find High CPU Consumption Processes in Linux.md new file mode 100644 index 0000000000..69516fa8b8 --- /dev/null +++ b/published/201912/20191211 How to Find High CPU Consumption Processes in Linux.md @@ -0,0 +1,166 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11678-1.html) +[#]: subject: (How to Find High CPU Consumption Processes in Linux) +[#]: via: (https://www.2daygeek.com/how-to-find-high-cpu-consumption-processes-in-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +如何在 Linux 中找出 CPU 占用高的进程 +====== + +![](https://img.linux.net.cn/data/attachment/album/201912/15/152614cp9bjmfwpofwvsx1.jpg) + +在之前的文章中我们已经讨论过 [如何在 Linux 中找出内存消耗最大的进程][1]。你可能也会遇到在 Linux 系统中找出 CPU 占用高的进程的情形。如果是这样,那么你需要列出系统中 CPU 占用高的进程列表来确定。我认为只有两种方法能实现:使用 [top 命令][2] 和 [ps 命令][3]。出于一些理由,我更倾向于用 `top` 命令而不是 `ps` 命令。但是两个工具都能达到你要的目的,所以你可以根据需求决定使用哪个。这两个工具都被 Linux 系统管理员广泛使用。 + +### 1) 怎样使用 top 命令找出 Linux 中 CPU 占用高的进程 + +在所有监控 Linux 系统性能的工具中,Linux 的 `top` 命令是最好的也是最知名的一个。`top` 命令提供了 Linux 系统运行中的进程的动态实时视图。它能显示系统的概览信息和 Linux 内核当前管理的进程列表。它显示了大量的系统信息,如 CPU 使用、内存使用、交换内存、运行的进程数、目前系统开机时间、系统负载、缓冲区大小、缓存大小、进程 PID 等等。默认情况下,`top` 命令的输出结果按 CPU 占用进行排序,每 5 秒中更新一次结果。如果你想要一个更清晰的视图来更深入的分析结果,[以批处理模式运行 top 命令][4] 是最好的方法。同时,你需要 [理解 top 命令输出结果的含义][5] ,这样才能解决系统的性能问题。 + +``` +# top -b | head -50 + +top - 00:19:17 up 14:23, 1 user, load average: 2.46, 2.18, 1.97 +Tasks: 306 total, 1 running, 305 sleeping, 0 stopped, 0 zombie +%Cpu0 : 10.4 us, 3.0 sy, 0.0 ni, 83.9 id, 0.0 wa, 1.3 hi, 1.3 si, 0.0 st +%Cpu1 : 17.0 us, 3.0 sy, 0.0 ni, 78.7 id, 0.0 wa, 0.3 hi, 1.0 si, 0.0 st +%Cpu2 : 13.0 us, 4.0 sy, 0.0 ni, 81.3 id, 0.0 wa, 0.3 hi, 1.3 si, 0.0 st +%Cpu3 : 12.3 us, 3.3 sy, 0.0 ni, 82.5 id, 0.3 wa, 0.7 hi, 1.0 si, 0.0 st +%Cpu4 : 12.2 us, 3.0 sy, 0.0 ni, 82.8 id, 0.7 wa, 0.3 hi, 1.0 si, 0.0 st +%Cpu5 : 6.4 us, 2.7 sy, 0.0 ni, 89.2 id, 0.0 wa, 0.7 hi, 1.0 si, 0.0 st +%Cpu6 : 26.7 us, 3.4 sy, 0.0 ni, 68.6 id, 0.0 wa, 0.7 hi, 0.7 si, 0.0 st +%Cpu7 : 15.6 us, 4.0 sy, 0.0 ni, 78.8 id, 0.0 wa, 0.7 hi, 1.0 si, 0.0 st +KiB Mem : 16248556 total, 1448920 free, 8571484 used, 6228152 buff/cache +KiB Swap: 17873388 total, 17873388 free, 0 used. 4596044 avail Mem +PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 2179 daygeek 20 3106324 613584 327564 S 79.5 3.8 14:19.76 Web Content + 1714 daygeek 20 4603372 974600 403504 S 20.2 6.0 65:18.91 firefox + 1227 daygeek 20 4192012 376332 180348 S 13.9 2.3 20:43.26 gnome-shell +18324 daygeek 20 3296192 766040 127948 S 6.3 4.7 9:18.12 Web Content + 1170 daygeek 20 1008264 572036 546180 S 6.0 3.5 18:07.85 Xorg + 4684 daygeek 20 3363708 1.1g 1.0g S 3.6 7.2 13:49.92 VirtualBoxVM + 4607 daygeek 20 4591040 1.7g 1.6g S 3.0 11.0 14:09.65 VirtualBoxVM + 1211 daygeek 9 -11 2865268 21032 16588 S 2.0 0.1 10:46.37 pulseaudio + 4562 daygeek 20 1096888 28812 21044 S 1.7 0.2 4:42.93 VBoxSVC + 1783 daygeek 20 3123888 376896 134788 S 1.3 2.3 39:32.56 Web Content + 3286 daygeek 20 3089736 404088 184968 S 1.0 2.5 41:57.44 Web Content +``` + +上面的命令的各部分解释: + + * `top`:命令 + * `-b`:批次档模式 + * `head -50`:显示输出结果的前 50 个 + * `PID`:进程的 ID + * `USER`:进程的归属者 + * `PR`:进程的等级 + * `NI`:进程的 NICE 值 + * `VIRT`:进程使用的虚拟内存 + * `RES`:进程使用的物理内存 + * `SHR`:进程使用的共享内存 + * `S`:这个值表示进程的状态: `S` = 睡眠,`R` = 运行,`Z` = 僵尸进程 + * `%CPU`:进程占用的 CPU 比例 + * `%MEM`:进程使用的 RAM 比例 + * `TIME+`:进程运行了多长时间 + * `COMMAND`:进程名字 + +如果你想看命令的完整路径而不是命令名字,以运行下面的格式 `top` 命令: + +``` +# top -c -b | head -50 + +top - 00:28:49 up 14:33, 1 user, load average: 2.43, 2.49, 2.23 +Tasks: 305 total, 1 running, 304 sleeping, 0 stopped, 0 zombie +%Cpu0 : 11.7 us, 3.7 sy, 0.0 ni, 82.3 id, 0.0 wa, 1.0 hi, 1.3 si, 0.0 st +%Cpu1 : 13.6 us, 3.3 sy, 0.0 ni, 81.1 id, 0.7 wa, 0.3 hi, 1.0 si, 0.0 st +%Cpu2 : 10.9 us, 2.6 sy, 0.0 ni, 85.1 id, 0.0 wa, 0.3 hi, 1.0 si, 0.0 st +%Cpu3 : 16.0 us, 2.6 sy, 0.0 ni, 80.1 id, 0.0 wa, 0.3 hi, 1.0 si, 0.0 st +%Cpu4 : 9.2 us, 3.6 sy, 0.0 ni, 85.9 id, 0.0 wa, 0.3 hi, 1.0 si, 0.0 st +%Cpu5 : 15.6 us, 2.9 sy, 0.0 ni, 80.5 id, 0.0 wa, 0.3 hi, 0.7 si, 0.0 st +%Cpu6 : 11.6 us, 4.3 sy, 0.0 ni, 82.7 id, 0.0 wa, 0.3 hi, 1.0 si, 0.0 st +%Cpu7 : 8.0 us, 3.0 sy, 0.0 ni, 87.3 id, 0.0 wa, 0.7 hi, 1.0 si, 0.0 st +KiB Mem : 16248556 total, 1022456 free, 8778508 used, 6447592 buff/cache +KiB Swap: 17873388 total, 17873388 free, 0 used. 4201560 avail Mem +PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND +18527 daygeek 20 3151820 624808 325748 S 52.8 3.8 59:26.72 /usr/lib/firefox/firefox -contentproc -childID 18 -isForBrowser -prefsLen 10002 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /+ + 1714 daygeek 20 4764668 910940 443228 S 21.5 5.6 68:59.33 /usr/lib/firefox/firefox --new-window + 1227 daygeek 20 4193108 377344 181404 S 11.6 2.3 21:47.36 /usr/bin/gnome-shell + 1170 daygeek 20 1008820 572700 546844 S 5.6 3.5 19:05.10 /usr/lib/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -nolisten tcp -background none -noreset -keeptty -verbose 3 +18324 daygeek 20 3300288 789344 127948 S 5.0 4.9 9:46.89 /usr/lib/firefox/firefox -contentproc -childID 16 -isForBrowser -prefsLen 10002 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /+ + 4684 daygeek 20 3363708 1.1g 1.0g S 3.6 7.2 14:10.18 /usr/lib/virtualbox/VirtualBoxVM --comment CentOS7 --startvm 002f47b8-2af2-48f5-be1d-67b67e03514c --no-startvm-errormsgbox + 4607 daygeek 20 4591040 1.7g 1.6g S 3.0 11.0 14:28.86 /usr/lib/virtualbox/VirtualBoxVM --comment Ubuntu-18.04 --startvm e8c32dbb-8b01-41b0-977a-bf28b9db1117 --no-startvm-errormsgbox + 1783 daygeek 20 3132640 451924 132168 S 2.6 2.8 39:49.66 /usr/lib/firefox/firefox -contentproc -childID 1 -isForBrowser -prefsLen 1 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /usr/l+ + 1211 daygeek 9 -11 2865268 21272 16828 S 2.0 0.1 11:01.29 /usr/bin/pulseaudio --daemonize=no + 4562 daygeek 20 1096888 28812 21044 S 1.7 0.2 4:49.33 /usr/lib/virtualbox/VBoxSVC --auto-shutdown +16865 daygeek 20 3073364 430596 124652 S 1.3 2.7 8:04.02 /usr/lib/firefox/firefox -contentproc -childID 15 -isForBrowser -prefsLen 10002 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /+ + 2179 daygeek 20 2945348 429644 172940 S 1.0 2.6 15:20.90 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -prefsLen 7821 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /us+ +``` + +### 2) 怎样使用 ps 命令找出 Linux 中 CPU 占用高的进程 + +`ps` 是进程状态process status的缩写,它能显示系统中活跃的/运行中的进程的信息。它提供了当前进程及其详细信息,诸如用户名、用户 ID、CPU 使用率、内存使用、进程启动日期时间、命令名等等的快照。 + +``` +# ps -eo pid,ppid,%mem,%cpu,cmd --sort=-%cpu | head + + PID PPID %MEM %CPU CMD +18527 1714 4.2 40.3 /usr/lib/firefox/firefox -contentproc -childID 18 -isForBrowser -prefsLen 10002 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 1714 true tab + 1714 1152 5.6 8.0 /usr/lib/firefox/firefox --new-window +18324 1714 4.9 6.3 /usr/lib/firefox/firefox -contentproc -childID 16 -isForBrowser -prefsLen 10002 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 1714 true tab + 3286 1714 2.0 5.1 /usr/lib/firefox/firefox -contentproc -childID 14 -isForBrowser -prefsLen 8078 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 1714 true tab + 1783 1714 3.0 4.5 /usr/lib/firefox/firefox -contentproc -childID 1 -isForBrowser -prefsLen 1 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 1714 true tab + 1227 1152 2.3 2.5 /usr/bin/gnome-shell + 1170 1168 3.5 2.2 /usr/lib/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -nolisten tcp -background none -noreset -keeptty -verbose 3 +16865 1714 2.5 2.1 /usr/lib/firefox/firefox -contentproc -childID 15 -isForBrowser -prefsLen 10002 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 1714 true tab + 2179 1714 2.7 1.8 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -prefsLen 7821 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 1714 true tab +``` + +上面的命令的各部分解释: + + * `ps`:命令名字 + * `-e`:选择所有进程 + * `-o`:自定义输出格式 + * `–sort=-%cpu`:基于 CPU 使用率对输出结果排序 + * `head`:显示结果的前 10 行 + * `PID`:进程的 ID + * `PPID`:父进程的 ID + * `%MEM`:进程使用的 RAM 比例 + * `%CPU`:进程占用的 CPU 比例 + * `Command`:进程名字 + +如果你只想看命令名字而不是命令的绝对路径,以运行下面的格式 `ps` 命令: + +``` +# ps -eo pid,ppid,%mem,%cpu,comm --sort=-%cpu | head + + PID PPID %MEM %CPU COMMAND +18527 1714 4.1 40.4 Web Content + 1714 1152 5.7 8.0 firefox +18324 1714 4.9 6.3 Web Content + 3286 1714 2.0 5.1 Web Content + 1783 1714 3.0 4.5 Web Content + 1227 1152 2.3 2.5 gnome-shell + 1170 1168 3.5 2.2 Xorg +16865 1714 2.4 2.1 Web Content + 2179 1714 2.7 1.8 Web Content +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-find-high-cpu-consumption-processes-in-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-11542-1.html +[2]: https://www.2daygeek.com/linux-top-command-linux-system-performance-monitoring-tool/ +[3]: https://www.2daygeek.com/linux-ps-command-find-running-process-monitoring/ +[4]: https://www.2daygeek.com/linux-run-execute-top-command-in-batch-mode/ +[5]: https://www.2daygeek.com/understanding-linux-top-command-output-usage/ diff --git a/published/201912/20191212 How to configure Openbox for your Linux desktop.md b/published/201912/20191212 How to configure Openbox for your Linux desktop.md new file mode 100644 index 0000000000..d400c04d36 --- /dev/null +++ b/published/201912/20191212 How to configure Openbox for your Linux desktop.md @@ -0,0 +1,69 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11698-1.html) +[#]: subject: (How to configure Openbox for your Linux desktop) +[#]: via: (https://opensource.com/article/19/12/openbox-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何为 Linux 桌面配置 Openbox +====== + +> 本文是 24 天 Linux 桌面特别系列的一部分。Openbox 窗口管理器占用很小的系统资源、易于配置、使用愉快。 + +![](https://img.linux.net.cn/data/attachment/album/201912/20/102327hdl3gcychsc53y3m.jpg) + +你可能不知道你使用过 [Openbox][2] 桌面:尽管 Openbox 本身是一个出色的窗口管理器,但它还是 LXDE 和 LXQT 等桌面环境的窗口管理器“引擎”,它甚至可以管理 KDE 和 GNOME。除了作为多个桌面的基础之外,Openbox 可以说是最简单的窗口管理器之一,可以为那些不想学习那么多配置选项的人配置。通过使用基于菜单的 obconf 的配置应用,可以像在 GNOME 或 KDE 这样的完整桌面中一样轻松地设置所有常用首选项。 + +### 安装 Openbox + +你可能会在 Linux 发行版的软件仓库中找到 Openbox,也可以在 [Openbox.org][3] 中找到它。如果你已经在运行其他桌面,那么可以安全地在同一系统上安装 Openbox,因为 Openbox 除了几个配置面板之外,不包括任何捆绑的应用。 + +安装后,退出当前桌面会话,以便你可以登录 Openbox 桌面。默认情况下,会话管理器(KDM、GDM、LightDM 或 XDM,这取决于你的设置)将继续登录到以前的桌面,因此你必须在登录之前覆盖该选择。 + +要使用 GDM 覆盖它: + +![Select your desktop session in GDM][4] + +要使用 SDDM 覆盖它: + +![Select your desktop session with KDM][5] + +### 配置 Openbox 桌面 + +默认情况下,Openbox 包含 obconf 应用,你可以使用它来选择和安装主题、修改鼠标行为、设置桌面首选项等。你可能会在仓库中发现其他配置应用,如 obmenu,用于配置窗口管理器的其他部分。 + +![Openbox Obconf configuration application][6] + +构建你自己的桌面环境相对容易。它有一些所有常见的桌面组件,例如系统托盘 [stalonetray][7]、任务栏 [Tint2][8] 或 [Xfce4-panel][9] 等几乎你能想到的。任意组合应用,直到拥有梦想的开源桌面为止。 + +![Openbox][10] + +### 为何使用 Openbox + +Openbox 占用的系统资源很小、易于配置、使用起来很愉悦。它基本不会让你感觉到阻碍,会是一个容易熟悉的系统。你永远不会知道你面前的桌面环境秘密使用了 Openbox 作为窗口管理器(知道如何自定义它会不会很高兴?)。如果开源吸引你,那么试试看 Openbox。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/openbox-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_general_openfield.png?itok=MeVN97oy (open with sky and grass) +[2]: http://openbox.org +[3]: http://openbox.org/wiki/Openbox:Download +[4]: https://opensource.com/sites/default/files/advent-gdm_0.jpg (Select your desktop session in GDM) +[5]: https://opensource.com/sites/default/files/advent-kdm.jpg (Select your desktop session with KDM) +[6]: https://opensource.com/sites/default/files/uploads/advent-openbox-obconf_675px.jpg (Openbox Obconf configuration application) +[7]: https://sourceforge.net/projects/stalonetray/ +[8]: https://opensource.com/article/19/1/productivity-tool-tint2 +[9]: http://xfce.org +[10]: https://opensource.com/sites/default/files/uploads/advent-openbox_675px.jpg (Openbox) diff --git a/published/201912/20191213 What GNOME 2 fans love about the Mate Linux desktop.md b/published/201912/20191213 What GNOME 2 fans love about the Mate Linux desktop.md new file mode 100644 index 0000000000..61f485fc27 --- /dev/null +++ b/published/201912/20191213 What GNOME 2 fans love about the Mate Linux desktop.md @@ -0,0 +1,56 @@ +[#]: collector: (lujun9972) +[#]: translator: (mayunmeiyouming) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11703-1.html) +[#]: subject: (What GNOME 2 fans love about the Mate Linux desktop) +[#]: via: (https://opensource.com/article/19/12/mate-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +GNOME 2 粉丝喜欢 Mate Linux 桌面的什么? +====== + +> 本文是 24 天 Linux 桌面特别系列的一部分。如果你还在怀念 GNOME 2,那么 Mate Linux 桌面将满足你的怀旧情怀。 + +![](https://img.linux.net.cn/data/attachment/album/201912/22/073751ugrt47kye0begk3k.jpg) + +如果你以前听过这个传闻:当 GNOME3 第一次发布时,很多 GNOME 用户还没有准备好放弃 GNOME 2。[Mate][2](以马黛茶yerba mate植物命名)项目的开始是为了延续 GNOME 2 桌面,刚开始时它使用 GTK 2(GNOME 2 所基于的工具包),然后又合并了 GTK 3。由于 Linux Mint 的简单易用,使得该桌面变得非常流行,并且从那时起,它已经普遍用于 Fedora、Ubuntu、Slackware、Arch 和许多其他 Linux 发行版上。今天,Mate 继续提供一个传统的桌面环境,它的外观和感觉与 GNOME 2 完全一样,使用 GTK 3 工具包。 + +你可以在你的 Linux 发行版的软件仓库中找到 Mate,也可以下载并[安装][3]一个把 Mate 作为默认桌面的发行版。不过,在你这样做之前,请注意为了提供完整的桌面体验,所以许多 Mate 应用程序都是随该桌面一起安装的。如果你运行的是不同的桌面,你可能会发现自己有多余的应用程序(两个 PDF 阅读器、两个媒体播放器、两个文件管理器,等等)。所以如果你只想尝试 Mate 桌面,可以在虚拟机(例如 [GNOME box][4])中安装基于 Mate 的发行版。 + +### Mate 桌面之旅 + +Mate 项目不仅仅可以让你想起来 GNOME 2;它就是 GNOME 2。如果你是 00 年代中期 Linux 桌面的粉丝,至少,你会从中感受到 Mate 的怀旧情怀。我不是 GNOME 2 的粉丝,我更倾向于使用 KDE,但是有一个地方我无法想象没有 GNOME 2:[OpenSolaris][5]。OpenSolaris 项目并没有持续太久,在 Sun Microsystems 被并入 Oracle 之前,Ian Murdock 加入 Sun 时它就显得非常突出,我当时是一个初级的 Solaris 管理员,使用 OpenSolaris 来让自己更多学会那种 Unix 风格。这是我使用过 GNOME 2 的唯一平台(因为我一开始不知道如何更改桌面,后来习惯了它),而今天的 [OpenIndiana project][6] 是 OpenSolaris 的社区延续,它通过 Mate 桌面使用 GNOME 2。 + +![Mate on OpenIndiana][7] + +Mate 的布局由左上角的三个菜单组成:应用程序、位置和系统。应用程序菜单提供对系统上安装的所有的应用程序启动器的快速访问。位置菜单提供对常用位置(如家目录、网络文件夹等)的快速访问。系统菜单包含全局选项,如关机和睡眠。右上角是一个系统托盘,屏幕底部有一个任务栏和一个虚拟桌面切换栏。 + +就桌面设计而言,这是一种稍微有点奇怪的配置。它从早期的 Linux 桌面、MacFinder 和 Windows 中借用了一些相同的部分,但是又创建了一个独特的配置,这种配置很直观而有些熟悉。Mate 执意保持这个模型,而这正是它的用户喜欢的地方。 + +### Mate 和开源 + +Mate 是一个最直接的例子,展示了开源如何使开发人员能够对抗项目生命的终结。从理论上讲,GNOME 2 会被 GNOME 3 所取代,但它依然存在,因为一个开发人员建立了该代码的一个分支并继续发展了下去。它的发展势头越来越庞大,更多的开发人员加入进来,并且这个让用户喜爱的桌面比以往任何时候都要更好。并不是所有的软件都有第二次机会,但是开源永远是一个机会,否则就永远没有机会。 + +使用和支持开源意味着支持用户和开发人员的自由。而且 Mate 桌面是他们的努力的有力证明。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/mate-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[mayunmeiyouming](https://github.com/mayunmeiyouming) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_keyboard_desktop.png?itok=I2nGw78_ (Linux keys on the keyboard for a desktop computer) +[2]: https://mate-desktop.org/ +[3]: https://mate-desktop.org/install/ +[4]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization +[5]: https://en.wikipedia.org/wiki/OpenSolaris +[6]: https://www.openindiana.org/documentation/faq/#what-is-openindiana +[7]: https://opensource.com/sites/default/files/uploads/advent-mate-openindiana_675px.jpg (Mate on OpenIndiana) diff --git a/published/201912/20191214 Get started with Lumina for your Linux desktop.md b/published/201912/20191214 Get started with Lumina for your Linux desktop.md new file mode 100644 index 0000000000..213e4eff5b --- /dev/null +++ b/published/201912/20191214 Get started with Lumina for your Linux desktop.md @@ -0,0 +1,69 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11706-1.html) +[#]: subject: (Get started with Lumina for your Linux desktop) +[#]: via: (https://opensource.com/article/19/12/linux-lumina-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +在 Linux 桌面中开始使用 Lumina +====== + +> 本文是 24 天 Linux 桌面特别系列的一部分。Lumina 桌面是让你使用快速、合理的基于 Fluxbox 桌面的捷径,它具有你无法缺少的所有功能。 + +![](https://img.linux.net.cn/data/attachment/album/201912/23/070658vtgg3wkrpg5g36rs.jpg) + +多年来,有一个名为 PC-BSD 的基于 FreeBSD 的桌面操作系统(OS)。它旨在作为一个常规使用的系统,因此值得注意,因为 BSD 主要用于服务器。大多数时候,PC-BSD 默认带 KDE 桌面,但是 KDE 越来越依赖于 Linux 特定的技术,因此 PC-BSD 越来越从 KDE 迁离。PC-BSD 变成了 [Trident][2],它的默认桌面是 [Lumina][3],它是一组小部件,它们使用与 KDE 相同的基于 Qt 的工具包,运行在 Fluxbox 窗口管理器上。 + +你可以在 Linux 发行版的软件仓库或 BSD 的 ports 树中找到 Lumina 桌面。如果你安装了 Lumina 并且已经在运行另一个桌面,那么你可能会发现有冗余的应用(两个 PDF 阅读器、两个文件管理器,等等),因为 Lumina 包含一些集成的应用。如果你只想尝试 Lumina 桌面,那么可以在虚拟机如 [GNOME Boxes][4] 中安装基于 Lumina 的 BSD 发行版。 + +如果在当前的操作系统上安装 Lumina,那么必须注销当前的桌面会话,才能登录到新的会话。默认情况下,会话管理器(SDDM、GDM、LightDM 或 XDM,取决于你的设置)将继续登录到以前的桌面,因此你必须在登录之前覆盖该桌面。 + +在 GDM 中: + +![Selecting your desktop in GDM][5] + +在 SDDM 中: + +![Selecting your desktop in KDM][6] + +### Lumina 桌面 + +Lumina 提供了一个简单而轻巧的桌面环境。屏幕底部有一个面板,它的左侧是应用菜单,中间是任务栏,右边是系统托盘。桌面上有图标,可以快速访问常见的应用和路径。 + +除了这个基本的桌面结构外,Lumina 还有自定义文件管理器、PDF 查看器,截图工具、媒体播放器、文本编辑器和存档工具。还有一个配置程序可以帮助你自定义 Lumina 桌面,并且右键单击桌面可以找到更多配置选项。 + +![Lumina desktop running on Project Trident][7] + +Lumina 与几个 Linux 轻量级桌面非常相似,尤其是 LXQT,不同之处在于 Lumina 完全不依赖于基于 Linux 的桌面框架(例如 ConsoleKit、PolicyKit、D-Bus 或 systemd)。对于你而言,这是否具有优势取决于所运行的操作系统。毕竟,如果你运行的是可以访问这些功能的 Linux,那么使用不使用这些特性的桌面可能就没有多大意义,还会减少功能。如果你运行的是 BSD,那么在 Fluxbox 中运行 Lumina 部件意味着你不必从 ports 安装 Linux 兼容库。 + +### 为什么要使用 Lumina + +Lumina 设计简单,它没有很多功能,但是你可以安装 Fluxbox 你喜欢的组件(用于文件管理的 [PCManFM][8]、各种 [LXQt 应用][9]、[Tint2][10] 面板等)。在开源中,开源用户喜欢寻找不要重复发明轮子的方法(几乎与我们喜欢重新发明轮子一样多)。 + +Lumina 桌面是让你使用快速、合理的基于 Fluxbox 桌面的捷径,它具有你无法缺少的所有功能,并且你很少需要调整细节。试一试 Lumina 桌面,看看它是否适合你。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/linux-lumina-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lightbulb-idea-think-yearbook-lead.png?itok=5ZpCm0Jh (Lightbulb) +[2]: https://project-trident.org/ +[3]: https://lumina-desktop.org/ +[4]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization +[5]: https://opensource.com/sites/default/files/uploads/advent-gdm_400x400_1.jpg (Selecting your desktop in GDM) +[6]: https://opensource.com/sites/default/files/uploads/advent-kdm_400x400_1.jpg (Selecting your desktop in KDM) +[7]: https://opensource.com/sites/default/files/uploads/advent-lumina.jpg (Lumina desktop running on Project Trident) +[8]: https://wiki.lxde.org/en/PCManFM +[9]: http://lxqt.org +[10]: https://opensource.com/article/19/1/productivity-tool-tint2 diff --git a/published/201912/20191217 5 interview questions every Kubernetes job candidate should know.md b/published/201912/20191217 5 interview questions every Kubernetes job candidate should know.md new file mode 100644 index 0000000000..f6d0f6685f --- /dev/null +++ b/published/201912/20191217 5 interview questions every Kubernetes job candidate should know.md @@ -0,0 +1,90 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11730-1.html) +[#]: subject: (5 interview questions every Kubernetes job candidate should know) +[#]: via: (https://opensource.com/article/19/12/kubernetes-interview-questions) +[#]: author: (Jessica Repka https://opensource.com/users/jrepka) + +每个 Kubernetes 应聘者应该知道的 5 个面试题 +====== + +> 如果你是要面试 Kubernetes 相关职位的应聘者,这里给出了要提问的问题以及这些问题的重要性。 + +![](https://img.linux.net.cn/data/attachment/album/201912/31/101229mmjumsesrzhh6rhk.jpg) + +面试对面试官及候选人来说都很不容易。最近,我发现面试 Kubernetes 相关工作的候选人似乎尤其困难。为什么呢?一方面,很难找到可以回答他们问题的人。而且,不管回答者回答的怎样,都很难确定他们是否有正确的经验。 + +跳过这个问题,让我们来看看面试 [Kubernetes][2] 求职者时应该提问的一些问题。 + +### Kubernetes 是什么? + +我发现这个问题是面试中最好的问题之一。我经常听到有人说“我用 Kubernetes 工作”,但是当我问道“Kubernetes 是什么”时,从来都没有得到过一个满意答案。 + +我最喜欢 [Chris Short][3] 给出的答案:“Kubernetes 就是带有一些 YAML 文件的 API 。” + +虽然他的回答没有错,但我会给你更详细的解释。 Kubernetes 是一个可移植容器的编排工具,用于自动执行管理、监控、扩展和部署容器化应用程序。 + +我认为“用于部署容器化应用程序的编排工具”这个回答可能与你期望的答案差不多了。能回答出这个,我觉得已经很不错了。尽管许多人认为 Kubernetes 做了更多更棒的工作,但总的来说,它为其核心功能——容器编排——添加了许多 API。 + +我认为,这是你在面试中可以提问的最好的问题之一,因为它至少证明了候选人是否知道 Kubernetes 是什么。 + +### Kubernetes 的节点和 Pod 有什么区别? + +该问题揭示了候选人对 Kubernetes 复杂性的初步了解。它将面试对话转换为对体系结构的概述,并可能导向许多有趣的后续细节问题。我已经听到了无数次关于该问题的错误解释了。 + +[节点][4] 是工作计算机。该计算机可以是虚拟机(VM)或物理计算机,具体取决于你是在虚拟机监控程序上运行还是在裸机上运行。该节点包含用于运行容器的服务,包括 kubelet、kube-proxy 和容器运行时。 + +[Pod][5] 包括:一个或多个**容器**、具有共享**网络**和**存储**,以及有关如何运行一起部署的容器的**规范**。这四个细节都很重要。更进一步,职位申请人应从技术层面解释,Pod 是 Kubernetes 可以创建和管理的最小可部署单元,而不是容器。 + +对于这个问题,我听到的最好的简答是:“节点是计算机,而 Pod 是容器运行于其中的东西。”这个区别很重要。Kubernetes 管理员的大部分工作是知道什么时间要部署什么,而节点的部署成本可能非常非常高,具体取决于它们的运行位置。我不希望有人一遍又一遍地部署节点,他们需要做的就是部署一堆 Pod。 + +### kubectl 是什么?(你怎么发音?) + +这个问题是我优先级较高的问题之一,但可能与你和你的团队无关。在我的团队中,我们不会使用图形化界面来管理 Kubernetes 环境,我们使用命令行操作。 + +那么什么是 [kubectl][6]?它是 Kubernetes 的命令行界面。你可以从该界面获取并设置任何内容,从收集日志和事件到编辑部署环境和机密文件。随机提问候选人关于如何使用此工具对测试候选人对 kubectl 的熟悉度是很有帮助的。 + +你是怎么读的?好吧,你随便吧(对此有很大的分歧),但是我很高兴向你介绍我朋友 [Waldo][7] 的精彩视频演示。 + +### 命名空间是什么? + +在多次面试中,我都没有得到关于这个问题的答案。我不确定在其他环境中使用的命名空间是否会在我所在的团队经常使用。我在这里给出一个简短的答案:命名空间是 Pod 中的虚拟集群。这种抽象可以使你将多个虚拟集保留在多个环境中以此来进行隔离。 + +### 容器是什么? + +了解 Pod 中正在部署的内容总是有帮助的,因为如果都不知道其中部署的是什么,何谈部署?容器是打包代码及其所有依赖项的软件的标准单元。我收到了两个可以接受的答案,其中包括:a)精简的操作系统镜像,以及 b)在受限的操作系统环境中运行的应用程序。如果你可以叫得出使用 [Docker][8] 以外的其他容器的编排软件(例如你最喜欢的公共云的容器服务),则可以得到加分。 + +### 其他问题 + +如果你想知道为什么我没有在此问题列表中添加更多问题,那么我可以给出一个简单的答案:我所列出的这些问题是在面试候选人时应了解的最基本的问题。接下来的问题应该是基于具体的团队、环境及组织。当你仔细研究这些内容时,尝试寻找有关技术如何相互作用的有趣问题,以了解人们如何应对基础架构挑战。考虑一下你的团队最近遇到的挑战(中断),要求逐步进行部署,或者考虑改善团队积极想要改进的策略(例如减少部署时间)。问题越不抽象,对面试后真正重要的技能的询问就越多。 + +没有两个环境是完全相同的。这也适用于面试中。我在每次面试中都会混合提问。我也有一个测试面试者的小环境。我经常发现回答问题是最容易的部分,而你所做的工作才是对你的真正的考验。 + +我给面试官的最后一点建议是:如果你遇到一个很有潜力但没有经验的候选人时,请给他们一个证明自己的机会。如果当初没有人看到我的潜力,没有给我机会的话,我不会拥有今天的知识和经验。 + +还有哪些重要的问题?请留言告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/kubernetes-interview-questions + +作者:[Jessica Repka][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jrepka +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/collab-team-pair-programming-code-keyboard.png?itok=kBeRTFL1 (Pair programming) +[2]: https://kubernetes.io/ +[3]: https://twitter.com/ChrisShort +[4]: https://kubernetes.io/docs/concepts/architecture/nodes/ +[5]: https://kubernetes.io/docs/concepts/workloads/pods/pod/ +[6]: https://kubernetes.io/docs/reference/kubectl/kubectl/ +[7]: https://opensource.com/article/18/12/kubectl-definitive-pronunciation-guide +[8]: https://opensource.com/resources/what-docker +[9]: https://enterprisersproject.com/article/2019/2/kubernetes-job-interview-questions-how-prepare diff --git a/published/201912/20191217 Build a retro Apple desktop with the Linux MLVWM.md b/published/201912/20191217 Build a retro Apple desktop with the Linux MLVWM.md new file mode 100644 index 0000000000..6aee6a3fec --- /dev/null +++ b/published/201912/20191217 Build a retro Apple desktop with the Linux MLVWM.md @@ -0,0 +1,207 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11720-1.html) +[#]: subject: (Build a retro Apple desktop with the Linux MLVWM) +[#]: via: (https://opensource.com/article/19/12/linux-mlvwm-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +使用 Linux MLVWM 打造复古苹果桌面 +====== + +> 本文是 24 天 Linux 桌面特别系列的一部分。如果老式的苹果电脑是用开源 POSIX 构建的呢?你可以通过构建 Macintosh 式的虚拟窗口管理器来实现。 + +![Person typing on a 1980's computer][1] + +想象一下穿越到另一段平行历史,Apple II GS 和 MacOS 7 是基于开源 [POSIX][2] 构建的,它使用了与现代 Linux 相同的所有惯例,例如纯文本配置文件和模块化系统设计。这样的操作系统将为其用户带来什么?你可以使用 [Macintosh 式的虚拟窗口管理器(MLVWM)][3]来回答这些问题(甚至更多!)。 + +![MLVWM running on Slackware 14.2][4] + +### 安装 MLVWM + +MLVWM 安装并不容易,并且可能不在你的发行版软件仓库中。如果你有时间理解翻译不佳的 README 文件,编辑一些配置文件,收集并调整一些旧的 .xpm 图片,编辑一两个 Xorg 选项,那么你就可以体验 MLVWM。不管怎么说,这是一个新奇的窗口管理器,其最新版本可以追溯到 2000 年。 + +要编译 MLVWM,你必须安装 imake,它提供了 `xmkmf` 命令。你可以从发行版的软件仓库中安装 imake,也可以直接从 [Freedesktop.org][5] 获得。假设你已经有 `xmkmf` 命令,请进入包含 MLVWM 源码的目录,然后运行以下命令进行构建: + +``` +$ xmkmf -a +$ make +``` + +构建后,编译后的 `mlvwm` 二进制文件位于 `mlvwm` 目录中。将其移动到[你的 PATH][6] 的任何位置: + +``` +$ mv mlvwm/mlvwm /usr/local/bin/ +``` + +#### 编辑配置文件 + +现在已经安装好 MLVWM,但是如果不调整几个配置文件并仔细放好所需的图像文件,它将无法正确启动。示例配置文件位于你下载的源代码的 `sample_rc` 目录中。将文件 `Mlvwm-Netscape` 和 `Mlvwm-Xterm` 复制到你的主目录: + +``` +$ cp sample_rc/Mlvwm-{Netscape,Xterm} $HOME +``` + +将 `Mlvwmrc` 改名为 `$HOME/.mlvwmrc`(是的,即使示例文件的名称看似是大写字母,但你也必须使用小写的 “m”): + +``` +$ cp sample_rc/Mlvwmrc $HOME/.mlvwmrc +``` + +打开 `.mlwmrc` 并找到第 54-55 行,它们定义了 MLVWM 在菜单和 UI 中使用的像素图的路径(`IconPath`): + +``` +# Set icon search path. It needs before "Style". +IconPath /usr/local/include/X11/pixmaps:/home2/tak/bin/pixmap +``` + +调整路径以匹配你填充图像的路径(我建议使用 `$HOME/.local/share/pixmaps`)。MLVWM 不提供像素图,因此需要你提供构建桌面所需图标。 + +即使你有位于系统其他位置的像素图(例如 `/usr/share/pixmaps`),也要这样做,因为你需要调整像素图的大小,你可能也不想在系统范围内执行此操作。 + +``` +# Set icon search path. It needs before "Style". +IconPath /home/seth/.local/share/pixmaps +``` + +#### 选择像素图 + +你已将 `.local/share/pixmaps` 目录定义为像素图源路径,但是该目录和图像均不存在。创建目录: + +``` +$ mkdir -p $HOME/.local/share/pixmaps +``` + +现在,配置文件将图像分配给菜单项和 UI 元素,但是系统中不存在这些图像。要解决此问题,请通读配置文件并找到每个 .xpm 图像。对于配置中列出的每个图像,将具有相同文件名的图像(或更改配置文件中的文件名)添加到你的 IconPath 目录。 + +`.mlvwmrc` 文件的注释很好,因此你可以大致了解要编辑的内容。无论如何,这只是第一步。你可以随时回来更改桌面外观。 + +这有些例子。 + +此代码块设置屏幕左上角的图标: + +``` +# Register the menu +Menu Apple, Icon label1.xpm, Stick +``` + +`label1.xpm` 图像实际上在源代码的 `pixmap` 目录中,但我更喜欢使用来自 `/usr/share/pixmaps` 的 `Penguin.xpm`(在 Slackware 上)。无论使用什么,都必须将自定义像素图放在 `~/.local/share/pixmaps` 中,并在配置中更改像素图的名称,或者重命名像素图以匹配配置文件中当前的名称。 + +此代码块定义了左侧菜单中列出的应用: + +``` +"About this Workstation..." NonSelect, Gray, Action About +"" NonSelect +"Terminal"      Icon mini-display.xpm, Action Exec "kterm" exec kterm -ls +"Editor"  Action Exec "mule" exec mule, Icon mini-edit.xpm +"calculator" Action Exec "xcal" exec xcalc, Icon mini-calc.xpm +END +``` + +通过遵循与配置文件中相同的语法,你可以自定义像素图并将自己的应用添加到菜单中(例如,我将 `mule` 更改为 `emacs`)。这是你在 MLVWM GUI 中打开应用的入口,因此请列出你要快速访问的所有内容。你可能还希望包括指向 `/usr/share/applications` 文件夹的快捷方式。 + +``` +"Applications" Icon Penguin.xpm, Action Exec "thunar /usr/share/applications" exec thunar /usr/share/applications +``` + +完成编辑配置文件并将自己的图像添加到 IconPath 目录后,必须将所有像素图的大小都调整为大约 16x16 像素。(MLVWM 的默认设置不一致,因此存在变化空间。)你可以使用 ImageMagick 进行批量操作: + +``` +$ for i in ~/.local/share/mlvwm-pixmaps/*xpm ; do convert -resize '16x16^' $i; done +``` + +### 启动 MLVWM + +最简单的运行 MLVWM 的方式是让 Xorg 完成大部分工作。首先,你必须创建一个 `$HOME/.xinitrc` 文件。我从 Slackware 复制了这个,它也是从 Xorg 拿来的: + +``` +#!/bin/sh +# $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $ + +userresources=$HOME/.Xresources +usermodmap=$HOME/.Xmodmap +sysresources=/etc/X11/xinit/.Xresources +sysmodmap=/etc/X11/xinit/.Xmodmap + +# merge in defaults and keymaps + +if [ -f $sysresources ]; then + xrdb -merge $sysresources +fi + +if [ -f $sysmodmap ]; then + xmodmap $sysmodmap +fi + +if [ -f $userresources ]; then + xrdb -merge $userresources +fi + +if [ -f $usermodmap ]; then + xmodmap $usermodmap +fi + +# Start the window manager: +if [ -z "$DESKTOP_SESSION" -a -x /usr/bin/ck-launch-session ]; then + exec ck-launch-session /usr/local/bin/mlvwm +else + exec /usr/local/bin/mlvwm +fi +``` + +根据此文件,`startx` 命令的默认操作是启动 MLVWM。但是,你的发行版可能对于图形服务器启动(或被终止以重新启动)时会发生的情况有其他做法,因此此文件可能对你没有什么帮助。在许多发行版上,你可以添加 .desktop 文件到 `/usr/share/xsessions` 中,以将其列在 GDM 或 KDM 菜单中,因此创建名为 `mlvwm.desktop` 的文件并输入: + +``` +[Desktop Entry] +Name=Mlvwm +Comment=Macintosh-like virtual window manager +Exec=/usr/local/bin/mlvwm +TryExec=ck-launch-session /usr/local/bin/mlvwm +Type=Application +``` + +从桌面会话注销并重新登录到 MLVWM。默认情况下,会话管理器(KDM、GDM 或 LightDM,具体取决于你的设置)将继续登录到以前的桌面,因此在登录之前必须覆盖它。 + +对于 GDM: + +![][7] + +对于 SDDM: + +![][8] + +#### 强制启动 + +如果 MLVWM 无法启动,请尝试安装 XDM,这是一个轻量级会话管理器,它不会查询 `/usr/share/xsessions` 的内容,而是执行经过身份验证用户的所有 `.xinitrc` 操作。 + +![MLVWM][9] + +### 打造自己的复古苹果 + +MLVWM 桌面未经打磨、不完美、模仿到位且充满乐趣。你看到的许多菜单项都是未实现的,但你可以使它们变得活跃且有意义。 + +这是一次让你时光倒流、改变历史,让老式苹果系列电脑成为开源堡垒的机会。成为一名修正主义者,设计你自己的复古苹果桌面,最重要的是,它有乐趣。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/linux-mlvwm-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/1980s-computer-yearbook.png?itok=eGOYEKK- (Person typing on a 1980's computer) +[2]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains +[3]: http://www2u.biglobe.ne.jp/~y-miyata/mlvwm.html +[4]: https://opensource.com/sites/default/files/uploads/advent-mlvwm-file.jpg (MLVWM running on Slackware 14.2) +[5]: http://cgit.freedesktop.org/xorg/util/imake +[6]: https://opensource.com/article/17/6/set-path-linux +[7]: https://opensource.com/sites/default/files/advent-gdm_2.jpg +[8]: https://opensource.com/sites/default/files/advent-kdm_1.jpg +[9]: https://opensource.com/sites/default/files/uploads/advent-mlvwm-chess.jpg (MLVWM) diff --git a/published/201912/20191218 How tracking pixels work.md b/published/201912/20191218 How tracking pixels work.md new file mode 100644 index 0000000000..5a47b5197f --- /dev/null +++ b/published/201912/20191218 How tracking pixels work.md @@ -0,0 +1,131 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11721-1.html) +[#]: subject: (How tracking pixels work) +[#]: via: (https://jvns.ca/blog/how-tracking-pixels-work/) +[#]: author: (Julia Evans https://jvns.ca/) + +网络广告商的像素追踪是如何工作的? +====== + +![](https://img.linux.net.cn/data/attachment/album/201912/27/214125hvpv4e5ijepa0aqj.jpg) + +昨天,我和一名记者谈到了一个问题:广告商是如何在互联网上对人们进行追踪的?我们津津有味地查看了 Firefox 的开发者工具(虽然我不是一个互联网隐私专家,但至少还会使用开发者工具中的“network”标签页),从中我终于弄明白像素追踪tracking pixels在实际中是如何工作的了。 + +### 问题:Facebook 怎么知道你逛了 Old Navy? + +我时常听人们说起这种有些诡异的上网经历:你在线上浏览了一个商品,一天之后,竟然看到了同一款靴子(或者是别的什么你当时浏览的商品)的广告。这就是所谓的“再营销”,但它到底是如何实现的呢? + +在本文中,我们来进行一个小实验,看看 Facebook 究竟是怎么知道你在线上浏览了什么商品的。这里使用 Facebook 作为示例,只是因为很容易找到使用了 Facebook 像素追踪技术的网站;其实,几乎所有互联网广告公司都会使用类似的追踪技术。 + +### 准备:允许第三方追踪器,同时关闭广告拦截器 + +我使用的浏览器是 Firefox,但是 Firefox 默认拦截了很多这种类型的追踪,所以需要修改 Firefox 的隐私设置,才能让这种追踪生效。 + +首先,我将隐私设置从默认设置([截图][1])修改为允许第三方追踪器的个性化设置([截图][2]),然后禁用了一些平时运行的隐私保护扩展。 + +![截图][1] + +![截图][2] + +### 像素追踪:关键不在于 gif,而在于请求参数 + +像素追踪是网站用来追踪你的一个 1x1 大小的 gif。就其本身而言,一个小小的 1x1 gif 显然起不到什么作用。那么,像素追踪到底是如何进行追踪的?其中涉及两个方面: + +1. 通过使用像素追踪上的**请求参数**,网站可以添加额外的信息,比如你正在访问的页面。这样一来,请求的就不是 `https://www.facebook.com/tr/`(这个链接是一个 44 字节大小的 1x1 gif),而是 `https://www.facebook.com/tr/?the_website_you're_on`。(邮件营销人员会使用类似的技巧,通过为像素追踪指定一个独特的 URL,弄清楚你是否打开了某一封邮件。) +2. 在发送该请求的同时,还发送了相应的 cookie。这样一来广告商就可以知道,访问 oldnavy.com 的这个人和在同一台电脑上使用 Facebook 的是同一个人。 + +### Old Navy 网站上的 Facebook 像素追踪 + +为了对此进行验证,我在 Old Navy(GAP 旗下的一个服装品牌)网站上浏览了一个商品,相应的 URL 是 `https://oldnavy.gap.com/browse/product.do?pid=504753002&cid=1125694&pcid=1135640&vid=1&grid=pds_0_109_1`(这是一件“男款短绒格子花呢大衣”)。 + +在我浏览这个商品的同时,页面上运行的 Javascript(用的应该是[这段代码][4])向 facebook.com 发送了一个请求。在开发者工具中,该请求看上去是这样的:(我屏蔽了大部分 cookie 值,因为其中有一些是我的登录 cookie) + +![][5] + +下面对其进行拆解分析: + +1. 我的浏览器向如下 URL 发送了一个请求; + + ``` +https://www.facebook.com/tr/?id=937725046402747&ev=PageView&dl=https%3A%2F%2Foldnavy.gap.com%2Fbrowse%2Fproduct.do%3Fpid%3D504753002%26cid%3D1125694%26pcid%3Dxxxxxx0%26vid%3D1%26grid%3Dpds_0_109_1%23pdp-page-content&rl=https%3A%2F%2Foldnavy.gap.com%2Fbrowse%2Fcategory.do%3Fcid%3D1135640%26mlink%3D5155%2Cm_mts_a&if=false&ts=1576684838096&sw=1920&sh=1080&v=2.9.15&r=stable&a=tmtealium&ec=0&o=30&fbp=fb.1.1576684798512.1946041422&it=15xxxxxxxxxx4&coo=false&rqm=GET +``` +2. 与该请求同时发送的,还有一个名为 `fr` 的 cookie,取值为 + + ``` +10oGXEcKfGekg67iy.AWVdJq5MG3VLYaNjz4MTNRaU1zg.Bd-kxt.KU.F36.0.0.Bd-kx6. +``` +(估计是我的 Facebook 广告追踪 ID) + +在所发送的像素追踪查询字符串里,有三个值得注意的地方: + +* 我当前访问的页面:`https://oldnavy.gap.com/browse/product.do?pid=504753002&cid=1125694&pcid=1135640&vid=1&grid=pds_0_109_1#pdp-page-content` +* 引导我来到当前页面的上一级页面:`https://oldnavy.gap.com/browse/category.do?cid=1135640&mlink=5155,m_mts_a`; +* 作为我的身份标识的 cookie:`10oGXEcKfGekg67iy.AWVdJq5MG3VLYaNjz4MTNRaU1zg.Bd-kxt.KU.F36.0.0.Bd-kx6.` + +### 下面来逛逛 Facebook! + +下面来逛逛 Facebook 吧。我之前已经登入了 Facebook,猜猜看,我的浏览器发送给 Facebook 的 cookie 是什么? + +不出所料,正是之前见过的 `fr` cookie:`10oGXEcKfGekg67iy.AWVdJq5MG3VLYaNjz4MTNRaU1zg.Bd-kxt.KU.F36.0.0.Bd-kx6.`。Facebook 现在一定知道我(Julia Evans,这个 Facebook 账号所关联的人)在几分钟之前访问了 Old Navy 网站,并且浏览了“男款短绒格子花呢大衣”,因为他们可以使用这个 cookie 将数据串联起来。 + +### 这里涉及到的是第三方 cookie + +Facebook 用来追踪我访问了哪些网站的 cookie,属于所谓的“第三方 cookie”,因为 Old Navy 的网站使用它为一个第三方(即 facebook.com)确认我的身份。这和用来维持登录状态的“第一方 cookie”有所不同。 + +Safari 和 Firefox 默认都会拦截许多第三方 cookie(所以需要更改 Firefox 的隐私设置,才能够进行这个实验),而 Chrome 目前并不进行拦截(很可能是因为 Chrome 的所有者正是一个广告公司)。(LCTT 译注:Chrome 可以设置阻拦) + +### 网站上的像素追踪有很多 + +如我所料,网站上的像素追踪有 **很多**。比如,wrangler.com 在我的浏览器里加载了来自不同域的 19 个不同的像素追踪。wrangler.com 上的像素追踪分别来自:`ct.pinterest.com`、`af.monetate.net`、`csm.va.us.criteo.net`、`google-analytics.com`、`dpm.demdex.net`、`google.ca`、`a.tribalfusion.com`、`data.photorank.me`、`stats.g.doubleclick.net`、`vfcorp.dl.sc.omtrdc.net`、`ib.adnxs.com`、`idsync.rlcdn.com`、`p.brsrvr.com`,以及 `adservice.google.com`。 + +Firefox 贴心地指出,如果使用 Firefox 的标准隐私设置,其中的大部分追踪器都会被拦截: + +![][8] + +### 浏览器的重要性 + +浏览器之所以如此重要,是因为你的浏览器最终决定了发送你的什么信息、发送到哪些网站。Old Navy 网站上的 Javascript 可以请求你的浏览器向 Facebook 发送关于你的追踪信息,但浏览器可以拒绝执行。浏览器的决定可以是:“哈,我知道 facebook.com/tr/ 是一个像素追踪,我不想让我的用户被追踪,所以我不会发送这个请求”。 + +浏览器还可以允许用户对上述行为进行配置,方法包括更改浏览器设置,以及安装浏览器扩展(所以才会有如此多的隐私保护扩展)。 + +### 摸清其中原理,实为一件趣事 + +在我看来,弄清楚 cookie/像素追踪是怎么用于对你进行追踪的,实在是一件趣事(尽管有点吓人)。我之前大概明白其中的道理,但是并没有亲自查看过像素追踪上的 cookie,也没有看过发送的查询参数上究竟包含什么样的信息。 + +当然,明白了其中的原理,也就更容易降低被追踪的概率了。 + +### 可以采取的措施 + +为了尽量避免在互联网上被追踪,我采取了几种简单的措施: + +* 安装一个广告拦截器(比如 ublock origin 之类)。广告拦截器可以针对许多追踪器的域进行拦截。 +* 使用目前默认隐私保护强度更高的 Firefox/Safari,而不是 Chrome。 +* 使用 [Facebook Container][9] 这个 Firefox 扩展。该扩展针对 Facebook 进一步采取了防止追踪的措施。 + +虽然在互联网上被追踪的方式还有很多(尤其是在使用手机应用的时候,因为在这种情况下,你没有和像对浏览器一样的控制程度),但是能够理解这种追踪方法的工作原理,稍微减少一些被追踪的可能性,也总归是一件好事。 + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/how-tracking-pixels-work/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://jvns.ca/images/trackers.png +[2]: https://jvns.ca/images/firefox-insecure-settings.png +[3]: https://oldnavy.gap.com/browse/product.do?pid=504753002&cid=1125694&pcid=1135640&vid=1&grid=pds_0_109_1 +[4]: https://developers.facebook.com/docs/facebook-pixel/implementation/ +[5]: https://jvns.ca/images/fb-old-navy.png +[6]: https://oldnavy.gap.com/browse/product.do?pid=504753002&cid=1125694&pcid=1135640&vid=1&grid=pds_0_109_1#pdp-page-content +[7]: https://oldnavy.gap.com/browse/category.do?cid=1135640&mlink=5155,m_mts_a +[8]: https://jvns.ca/images/firefox-helpful.png +[9]: https://addons.mozilla.org/en-CA/firefox/addon/facebook-container/ diff --git a/published/201912/20191220 How to Start, Stop - Restart Services in Ubuntu and Other Linux Distributions.md b/published/201912/20191220 How to Start, Stop - Restart Services in Ubuntu and Other Linux Distributions.md new file mode 100644 index 0000000000..bcb25f74e6 --- /dev/null +++ b/published/201912/20191220 How to Start, Stop - Restart Services in Ubuntu and Other Linux Distributions.md @@ -0,0 +1,179 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11722-1.html) +[#]: subject: (How to Start, Stop & Restart Services in Ubuntu and Other Linux Distributions) +[#]: via: (https://itsfoss.com/start-stop-restart-services-linux/) +[#]: author: (Sergiu https://itsfoss.com/author/sergiu/) + +如何在 Ubuntu 和其他 Linux 发行版中启动、停止和重启服务 +====== + +![](https://img.linux.net.cn/data/attachment/album/201912/28/081645vee5lkult55kituu.jpg) + +服务是必不可少的后台进程,它通常随系统启动,并在关机时关闭。如果你是系统管理员,那么你会定期处理服务。如果你是普通桌面用户,你可能会遇到需要重启服务的情况,例如[安装 Barrier 来用于在计算机之间共享鼠标和键盘][1]。或[在使用 ufw 设置防火墙][2]时。 + +今天,我将向你展示两种管理服务的方式。你将学习在 Ubuntu 或任何其他 Linux 发行版中启动、停止和重启服务。 + +> systemd 与 init +> +> 如今,Ubuntu 和许多其他发行版都使用 systemd 而不是旧的 init。 +> +> 在 systemd 中,可以使用 `systemctl` 命令管理服务。 +> +> 在 init 中,你可以使用 `service` 命令管理服务。 +> +> 你会注意到,即使你的 Linux 系统使用 systemd,它仍然可以使用 `service` 命令(与 init 系统一起使用的)。这是因为 `service` 命令实际上已重定向到 `systemctl`。systemd 引入了向后兼容性,因为系统管理员们习惯使用 `service` 命令。 +> +> 在本教程中,我将同时展示 `systemctl` 和 `service` 命令。 + +我用的是 Ubuntu 18.04,但其他版本的过程也一样。 + +### 方法 1:使用 systemd 在 Linux 中管理服务 + +我从 systemd 开始,因为它被广泛接受。 + +#### 1、列出所有服务 + +为了管理服务,你首先需要知道系统上有哪些服务可用。你可以使用 systemd 的命令列出 Linux 系统上的所有服务: + +``` +systemctl list-unit-files --type service -all +``` + +![systemctl list-unit-files][3] + +此命令将输出所有服务的状态。服务状态有启用enabled禁用disabled屏蔽masked(在取消屏蔽之前处于非活动状态)、静态static已生成generated。 + +与 [grep 命令][4] 结合,你可以仅显示正在运行的服务: + +``` +sudo systemctl | grep running +``` + +![Display running services systemctl][5] + +现在,你知道了如何引用所有不同的服务,你可以开始主动管理它们。 + +**注意:** 下列命令中的 `` 应该用你想管理的服务名代替。(比如:network-manager、ufw 等) + +#### 2、启动服务 + +要在 Linux 中启动服务,你只需使用它的名字: + +``` +systemctl start +``` + +#### 3、停止服务 + +要停止 systemd 服务,可以使用 `systemctl` 命令的 `stop` 选项: + +``` +systemctl stop +``` + +#### 4、重启服务 + +要重启 systemd 服务,可以使用: + +``` +systemctl restart +``` + +#### 5、检查服务状态 + +你可以通过打印服务状态来确认你已经成功执行特定操作: + +``` +systemctl status +``` + +这将以以下方式输出: + +![systemctl status][6] + +这是 systemd 的内容。现在切换到 init。 + +### 方法 2:使用 init 在 Linux 中管理服务 + +init 的命令和 systemd 的一样简单。 + +#### 1、列出所有服务 + +要列出所有 Linux 服务,使用: + +``` +service --status-all +``` + +![service –status-all][7] + +前面的 `[ – ]` 代表**禁用**,`[ + ]` 代表**启用**。 + +#### 2、启动服务 + +要在 Ubuntu 和其他发行版中启动服务,使用命令: + +``` +service start +``` + +#### 3、停止服务 + +停止服务同样简单。 + +``` +service stop +``` + +#### 4、重启服务 + +如果你想重启服务,命令是: + +``` +service restart +``` + +#### 5、检查服务状态 + +此外,要检查是否达到了预期的结果,你可以输出服务状态: + +``` +service status +``` + +这将以以下方式输出: + +![service status][8] + +最重要的是,这将告诉你某项服务是否处于活跃状态(正在运行)。 + +### 总结 + +今天,我详细介绍了两种在 Ubuntu 或任何其他 Linux 系统上管理服务的非常简单的方法。 希望本文对你有所帮助。 + +你更喜欢哪种方法? 让我在下面的评论中知道! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/start-stop-restart-services-linux/ + +作者:[Sergiu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/sergiu/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/keyboard-mouse-sharing-between-computers/ +[2]: https://itsfoss.com/set-up-firewall-gufw/ +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/systemctl_list_services.png?ssl=1 +[4]: https://linuxhandbook.com/grep-command-examples/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/systemctl_grep_running.jpg?ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/systemctl_status.jpg?ssl=1 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/service_status_all.png?ssl=1 +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/service_status.jpg?ssl=1 diff --git a/published/201912/20191221 Customize your Linux desktop with KDE Plasma.md b/published/201912/20191221 Customize your Linux desktop with KDE Plasma.md new file mode 100644 index 0000000000..23f83f5d41 --- /dev/null +++ b/published/201912/20191221 Customize your Linux desktop with KDE Plasma.md @@ -0,0 +1,70 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11728-1.html) +[#]: subject: (Customize your Linux desktop with KDE Plasma) +[#]: via: (https://opensource.com/article/19/12/linux-kde-plasma) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +使用 KDE Plasma 定制 Linux 桌面 +====== + +> 本文是 24 天 Linux 桌面特别系列的一部分。如果你认为没有太多自定义桌面的需要,KDE Plasma 可能适合你。 + +![5 pengiuns floating on iceburg][1] + +KDE 社区的 Plasma 桌面是开源桌面环境中的巅峰之作。KDE 很早就进入了 Linux 桌面环境市场,但是由于它的基础 Qt 工具包当时没有完全开放的许可证,因此才有 [GNOME][2] 桌面。在此之后,Qt 开源了,并且 KDE(及其衍生产品,例如 [Trinity 桌面][3])开始蓬勃发展。 + +你可能会在发行版的软件仓库中找到 KDE 桌面,或者可以下载并安装将 KDE 作为默认桌面的发行版。在安装之前,请注意,KDE 提供了完整、集成且强大的桌面体验,因此会同时安装几个 KDE 应用。如果你已经在运行其他桌面,那么将发现有几个冗余的应用(两个 PDF 阅读器、多个媒体播放器、两个或多个文件管理器,等等)。如果你只想尝试而不是一直使用 KDE 桌面,那么可以在虚拟机,如 [GNOME Boxes][4] 中安装基于 KDE 的发行版,也可以尝试使用可引导的操作系统,例如 [Porteus][5]。 + +### KDE 桌面之旅 + +乍一看,[KDE Plasma][6] 桌面相对无聊,但让人感到舒适。它有行业标准的布局:左下角弹出应用菜单,中间是任务栏,右边是系统托盘。这正是你对标准家用或商用计算机的期望。 + +![KDE Plasma desktop][7] + +但是,使 KDE 与众不同的是,你几乎可以更改任何想要的东西。Qt 工具包可以以令人惊讶的方式分割和重新排列,这意味着你实质上可以使用 KDE 的部件作为基础来设计自己的桌面。桌面行为的可用设置也很多。KDE 可以充当标准桌面、平铺窗口管理器以及两者之间的任意形式。你可以通过窗口类、角色、类型、标题或它们的任意组合来创建自己的窗口规则,因此,如果希望特定应用的行为不同于其他行为,那么可以创建全局设置的例外。 + +此外,它还有丰富的小部件集合,使你可以自定义与桌面交互的方式。它有一个类似 GNOME 的全屏应用启动器,一个类似 Unity 的 dock 启动器和仅有图标的任务栏,以及一个传统的任务栏。你可以在屏幕的任何边缘上创建和放置面板。 + +![A slightly customized KDE desktop][8] + +实际上,它有太多的自定义项了,因此 KDE 最常见的批评之一是它的*太过可定制化*,所以请记住,自定义项是可选的。你可以在默认配置下使用 Plasma 桌面,并仅在你认为必要时逐步进行更改。Plasma 桌面配置选项最重要的不是它们的数目,而是它们容易发现和直观,它们都在系统设置应用或者右键单击中。 + +事实是,在 KDE 上,几乎绝不会只有一种方法可以完成任何给定的任务,并且它的用户将这个视为其最大的优势。KDE 中没有隐含的工作流,只有默认的。并且可以更改所有默认设置,直到你需要桌面做的成为你的习惯。 + +### 一致性和集成 + +KDE 社区以一致性和集成为荣,出色的开发人员、社区管理以及 KDE 库使其成为可能。KDE 的开发人员不只是桌面开发人员。它们提供了[惊人的应用集合][9],每个应用都使用 KDE 库创建,这些库扩展并标准化了常见的 Qt 小部件。使用 KDE 几个月后,无论是打开 [DigiKam][10] 进行照片管理,还是打开 Kmail 来检查电子邮件,还是打开 KTorrent 来获取最新的 ISO 或者使用 Dolphin 管理文件,你的肌肉记忆会在你思考之前直接带你进入对应 UI。 + +![KDE on Porteus][11] + +### 尝试 KDE + +KDE 适合所有人。使用其默认设置可获得流畅、原始的桌面体验,或对其进行自定义以使其成为自己专属。它是一个稳定、有吸引力且强大的桌面环境,可能有你想要在 Linux 完成要做的事的一切。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/linux-kde-plasma + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux31x_cc.png?itok=Pvim4U-B (5 pengiuns floating on iceburg) +[2]: https://opensource.com/article/19/12/gnome-linux-desktop +[3]: https://opensource.com/article/19/12/linux-trinity-desktop-environment-tde +[4]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization +[5]: https://opensource.com/article/19/6/linux-distros-to-try +[6]: https://kde.org/plasma-desktop +[7]: https://opensource.com/sites/default/files/uploads/advent-kde-presskit.jpg (KDE Plasma desktop) +[8]: https://opensource.com/sites/default/files/uploads/advent-kde-dock.jpg (A slightly customized KDE desktop) +[9]: https://kde.org/applications/ +[10]: https://opensource.com/life/16/5/how-use-digikam-photo-management +[11]: https://opensource.com/sites/default/files/uploads/advent-kde.jpg (KDE on Porteus) diff --git a/published/201912/20191222 How to Update Grub on Ubuntu and Other Linux Distributions.md b/published/201912/20191222 How to Update Grub on Ubuntu and Other Linux Distributions.md new file mode 100644 index 0000000000..c422b4d808 --- /dev/null +++ b/published/201912/20191222 How to Update Grub on Ubuntu and Other Linux Distributions.md @@ -0,0 +1,129 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11726-1.html) +[#]: subject: (How to Update Grub on Ubuntu and Other Linux Distributions) +[#]: via: (https://itsfoss.com/update-grub/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Ubuntu 和其它 Linux 发行版上更新 grub +====== + +![](https://img.linux.net.cn/data/attachment/album/201912/29/110155d51bhogs5ezp5p71.png) + +在这篇文章中,你将学习在 Ubuntu 或任何其它 Linux 发行版上更新 grub 。你也将学习一个或两个关于更新这个 grub 过程如何工作的事情。 + +### 如何更新 grub + +Ubuntu 和很多其它的 Linux 发行版提供一个易使用的称为 `update-grub` 命令行实用程序。 + +为更新 grub ,你所要的全部工作就是使用 `sudo` 在终端中运行这个命令。 + +``` +sudo update-grub +``` + +你应该看到一个像这样的输出: + +``` +[email protected]:~$ sudo update-grub +[sudo] password for abhishek: +Sourcing file `/etc/default/grub' +Generating grub configuration file ... +Found linux image: /boot/vmlinuz-5.0.0-37-generic +Found initrd image: /boot/initrd.img-5.0.0-37-generic +Found linux image: /boot/vmlinuz-5.0.0-36-generic +Found initrd image: /boot/initrd.img-5.0.0-36-generic +Found linux image: /boot/vmlinuz-5.0.0-31-generic +Found initrd image: /boot/initrd.img-5.0.0-31-generic +Found Ubuntu 19.10 (19.10) on /dev/sda4 +Found MX 19 patito feo (19) on /dev/sdb1 +Adding boot menu entry for EFI firmware configuration +done +``` + +你可能看到一个类似的称为 `update-grub2` 的命令。不需要在 `update-grub` 和 `update-grub2` 之间感到害怕或不知所措。这两个命令执行相同的动作。 + +大约在 10 年前,当 grub2 刚刚被引进时,`update-grub2` 命令也被引进。现在,`update-grub2` 只是一个链接到 `update-grub` 的符号,它们都更新 grub2 配置(因为 grub2 是默认的)。 + +#### 不能找到 update-grub 命令?这里是在这种情况下该做什么 + +它可能是,你的 Linux 发行版可能没有可用的 `update-grub` 命令。 + +在这种情况下你该做什么?你如何在这样一个 Linux 发行版上更新 grub ? + +在这里不需要惊慌。`update-grub` 命令只是一个入口,用于运行 `grub-mkconfig -o /boot/grub/grub.cfg` 来生成 grub2 配置文件。 + +这意味着你可以在任意 Linux 发行版上使用下面的命令更新 grub : + +``` +sudo grub-mkconfig -o /boot/grub/grub.cfg +``` + +当然,记住 `update-grub` 命令比上面的命令容易很多,这是为什么它在一开始被创建的原因。 + +### update-grub 是如何工作的? + +当你安装一个 Linux 发行版时,它(通常)要求你安装 [grub 启动引导程序][1]。 + +grub 的一部分安装在 MBR/ESP 分区上。grub 的剩余部分保留在 Linux 发行版的 `/boot/grub` 目录中。 + +依据它的 [man 页面][2],`update-grub` 通过查找 `/boot` 目录来工作。所有以 [vmlinuz-][3] 开头的文件将被作为内核来对待,并且它们将得到一个 grub 菜单项。它也将为与所找到内核版本相同的 [ramdisk][4] 镜像添加 initrd 行。 + +它也使用 [os-prober][5] 为其它操作系统查找所有磁盘分区。如果找到其它操作系统,它添加它们到 grub 菜单。 + +![Representational image of Grub Menu][6] + +### 为什么你需要更新 grub ? + +在有很多场景下你需要更新 grub。 + +假设你修改 grub 配置文件(`/etc/default/grub`)以 [更改默认启动顺序][7] 或减少默认启动时间。除非你更新 grub ,否则你的修改将不会生效。 + +另一种情况是,你在同一个电脑系统上安装多个 Linux 发行版。 + +例如,在我的 Intel NUC 上,我有两个磁盘。第一个磁盘有 Ubuntu 19.10 ,并且我在其上面安装了 Ubuntu 18.04 。第二个操作系统(Ubuntu 18.04)安装了其自己的 grub ,现在 grub 启动屏幕由 Ubuntu 18.04 grub 控制。 + +在第二个磁盘上,我安装了 MX Linux ,但是这次我没有安装 grub。我希望现有的 grub(由 Ubuntu 18.04 控制)来处理所有的操作系统项目。 + +现在,在这种情况中,在 Ubuntu 18.04 上的 grub 需要更新,以便它能够看到 [MX Linux][8] 。 + +![][9] + +如上图所示,当我更新 grub 时,它在 18.04 上找到很多安装的 Linux 内核, 以及在不同的分区上 Ubntu 19.10 和 MX Linux 。 + +如果你想让 MX Linux 控制 grub ,我可以使用 [grub-install][10] 命令来在 MX Linux 上安装 grub,然后在 MX Linux 上的 grub 将开始控制 grub 启动屏幕。你已经明白这点,对吧? + +使用一个像 [Grub Customizer][11] 的 GUI 工具是在 grub 中进行更改的一种简单的方法。 + +### 最后… + +最初,我打算保持它为一篇短文作为一种快速提示。但是后来我想解释一些与之相关的东西,以便(相对)新的 Linux 用户能够学到更多,而不仅仅是一个简单命令。 + +你喜欢它吗?你有一些问题或建议吗?请随意发表评论。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/update-grub/ + +作者:[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://en.wikipedia.org/wiki/GNU_GRUB +[2]: https://manpages.debian.org/testing/grub-legacy/update-grub.8.en.html +[3]: https://www.ibm.com/developerworks/community/blogs/mhhaque/entry/anatomy_of_the_initrd_and_vmlinuz?lang=en +[4]: https://en.wikipedia.org/wiki/Initial_ramdisk +[5]: https://packages.debian.org/sid/utils/os-prober +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/grub_screen.png?ssl=1 +[7]: https://itsfoss.com/grub-customizer-ubuntu/ +[8]: https://mxlinux.org/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/update_grub.png?ssl=1 +[10]: https://www.gnu.org/software/grub/manual/grub/html_node/Installing-GRUB-using-grub_002dinstall.html +[11]: https://itsfoss.com/customize-grub-linux/ diff --git a/published/201912/20191222 Why your Python code needs to be beautiful and explicit.md b/published/201912/20191222 Why your Python code needs to be beautiful and explicit.md new file mode 100644 index 0000000000..4afb58bbb0 --- /dev/null +++ b/published/201912/20191222 Why your Python code needs to be beautiful and explicit.md @@ -0,0 +1,69 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11718-1.html) +[#]: subject: (Why your Python code needs to be beautiful and explicit) +[#]: via: (https://opensource.com/article/19/12/zen-python-beauty-clarity) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +为什么 Python 代码要写得美观而明确 +====== + +> 欢迎阅读“Python 光明节(Pythonukkah)”系列文章,这个系列文章将会讨论《Python 之禅》。我们首先来看《Python 之禅》里的前两个原则:美观与明确。 + +![](https://img.linux.net.cn/data/attachment/album/201912/27/091634drq96c2fojzp6okr.png) + +早在 1999 年,Python 的贡献者之一,Tim Peters 就提出了《[Python 之禅][2]》,直到二十年后的今天,《Python 之禅》中的 19 条原则仍然对整个社区都产生着深远的影响。为此,就像庆典光明的光明节Hanukkah一样,我们举行了这一次的“Python 光明节Pythonukkah”。首先,我们会讨论《Python 之禅》中的前两个原则:美观和明确。 + +> “Hanukkah is the Festival of Lights, +> +> Instead of one day of presents, we get eight crazy nights.” +> +> —亚当·桑德勒,[光明节之歌][3] + +### 美观胜于丑陋 + +著名的《[计算机程序的构造和解释Structure and Interpretation of Computer Programs][4]》中有这么一句话:代码是写给人看的,只是恰好能让机器运行。Programs must be written for people to read and only incidentally for machines to execute.机器并不在乎代码的美观性,但人类在乎。 + +阅读美观的代码对人们来说是一种享受,这就要求在整套代码中保持一致的风格。使用诸如 [Black][5]、[flake8][6]、[Pylint][7] 这一类工具能够有效地接近这一个目标。 + +但实际上,只有人类自己才知道什么才是真正的美观。因此,代码审查和协同开发是其中的不二法门,同时,在开发过程中倾听别人的意见也是必不可少的。 + +最后,个人的主观能动性也很重要,否则一切工具和流程都会变得毫无意义。只有意识到美观的重要性,才能主动编写出美观的代码。 + +这就是为什么美观在众多原则当中排到了首位,它让“美”成为了 Python 社区的一种价值。如果有人要问,”我们*真的*在乎美吗?“社区会以代码给出肯定的答案。 + +### 明确胜于隐晦 + +人类会欢庆光明、惧怕黑暗,那是因为光能够让我们看到难以看清的事物。同样地,尽管有些时候我们会不自觉地把代码写得含糊不清,但明确地编写代码确实能够让我们理解很多抽象的概念。 + +“为什么类方法中要将 `self` 显式指定为第一个参数?” + +这个问题已经是老生常谈了,但网络上很多流传已久的回答都是不准确的。在编写元类metaclass时,显式指定 `self` 参数就显得毫无意义。如果你没有编写过元类,希望你可以尝试一下,这是很多 Python 程序员的必经之路。 + +显式指定 `self` 参数的原因并不是 Python 的设计者不想将这样的元类视为“默认”元类,而是因为第一个参数必须是*显式*的。 + +即使 Python 中确实允许非显式的情况存在(例如上下文变量),但我们还是应该提出疑问:某个东西是不是有存在的必要呢?如果非显式地传递参数会不会出现问题呢?有些时候,由于种种原因,这是会有问题的。总之,在写代码时一旦能够优先考虑到明确性,至少意味着能对不明确的地方提出疑问并对结果作出有效的估计。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/zen-python-beauty-clarity + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/search_find_code_python_programming.png?itok=ynSL8XRV "Searching for code" +[2]: https://www.python.org/dev/peps/pep-0020/ +[3]: https://en.wikipedia.org/wiki/The_Chanukah_Song +[4]: https://en.wikipedia.org/wiki/Structure_and_Interpretation_of_Computer_Programs +[5]: https://opensource.com/article/19/5/python-black +[6]: https://opensource.com/article/19/5/python-flake8 +[7]: https://opensource.com/article/19/10/python-pylint-introduction + diff --git a/published/201912/20191224 App Highlight- Falkon Open Source Web Browser from KDE.md b/published/201912/20191224 App Highlight- Falkon Open Source Web Browser from KDE.md new file mode 100644 index 0000000000..bd4a26bc8e --- /dev/null +++ b/published/201912/20191224 App Highlight- Falkon Open Source Web Browser from KDE.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11732-1.html) +[#]: subject: (App Highlight: Falkon Open Source Web Browser from KDE) +[#]: via: (https://itsfoss.com/falkon-browser/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +应用推荐:来自 KDE 的 Falkon 开源 Web 浏览器 +====== + +> Falkon 是基于 QtWebEngine 的 Web 浏览器,它以前称为 Qupzilla。在本周的“应用推荐”中,我们来看看这个开源软件。 + +![](https://img.linux.net.cn/data/attachment/album/201912/31/105027tblfjlzn9xx8keud.png) + +### Falkon:适用于 Linux(和 Windows)的开源 Web 浏览器 + +![][1] + +首先,[Falkon][2] 并不是一款新的 Web 浏览器。它自 2010 年以来一直在开发中,但被称为 Qupzilla。2017 年,QupZilla 移到 KDE 旗下,并更名为 Falkon。处于 KDE 旗下意味着项目会按照 KDE 标准积极维护。 + +它使用 [QtWebEngine][3] 渲染引擎,这是 Chromium 核心的简化版本。 + +在本文中,我将仔细研究它提供的功能以及与 Linux 上其他主流 Web 浏览器的不同之处。 + +### Falkon 浏览器的功能 + +我认为它可能不是流行的浏览器,但我发现它足以浏览现代 Web 服务。让我重点介绍 Falkon 的主要功能,如果你觉得它很有趣,请尝试一下。 + +#### 简单的用户界面 + +![][4] + +我知道这不完全是一项“功能”,但是用户体验(UX)至关重要。尽管是轻量级的浏览器,但你会拥有一个不错的界面。你不会觉得使用的是一款源自 2000 年早期的浏览器。 + +#### AdBlock 扩展 + +![][5] + +它附带了 AdBlock 扩展程序,如果你想在浏览网站时摆脱广告,它的效果很好。你还可以自定义 AdBlock 扩展的行为。 + +#### DuckDuckGo 作为默认搜索引擎 + +如果你不喜欢使用 Google,那么这是一件好事,它将这个[主打隐私的搜索引擎][6]设为默认搜索引擎。 + +#### 会话管理器 + +![][7] + +Falkon 在浏览器菜单的可用选项中包含了一个有用的会话管理器。你可以用它还原特定的近期会话,这应该能派上用场。 + +#### 扩展支持 + +![][8] + +它确实支持添加扩展,但你不能从 Chrome/Firefox 插件市场添加扩展。你只能选择有限的一组扩展。 + +#### 主题支持 + +Falkon 还允许你在某种程度上自定义外观。如果要更改浏览器的外观,可以尝试一下。 + +![][9] + +#### 其他基本设置 + +![][10] + +我还尝试了其他设置/功能,例如添加书签或管理密码。或者,管理网页的通知。我还试了 YouTube,没有任何问题。 + +当然,这不是一个详尽的评测。但是,Falkon 确实拥有浏览器中需要的所有基本功能(除非你有特定要求)。 + +### 安装 Falkon 浏览器 + +你可以在软件中心轻松找到 Falkon 浏览器。如果没有,你可以从它的[官方下载页面][11]中找到 Flatpak/Snap 包。你还可以在下载页面上找到 Windows 的安装程序。 + +[Download Falkon Browser][11] + +### 总结 + +作为 KDE 产品,Falkon 是为 KDE 桌面环境量身定制的。一些 KDE 发行版(例如 OpenMandriva)使用 Falkon 作为默认的 Web 浏览器。 + +Falkon 浏览器适合那些正在寻求轻巧且功能丰富的 Web 浏览器的人。值得尝试的另一个替代是 [Midori][12]。 + +我认为,除非你需要大量的扩展、跨平台同步并且需要访问某些特定于浏览器的网站,不然它是一个很好的替代浏览器。 + +你如何看待 Falkon 浏览器?请在下面的评论中让我知道你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/falkon-browser/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/falkon-browser-screenshot.jpg?ssl=1 +[2]: https://www.falkon.org/ +[3]: https://wiki.qt.io/QtWebEngine +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/falkon-browser.png?ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/falkon-adblock.jpg?ssl=1 +[6]: https://itsfoss.com/privacy-search-engines/ +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/session-manager-falkon.jpg?ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/falkon-browser-extensions.png?ssl=1 +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/falkon-browser-theme.png?ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/falkon-browser-preference.png?ssl=1 +[11]: https://www.falkon.org/download/ +[12]: https://itsfoss.com/midori-browser/ diff --git a/published/201912/20191224 Unix is turning 50. What does that mean.md b/published/201912/20191224 Unix is turning 50. What does that mean.md new file mode 100644 index 0000000000..948adc58bf --- /dev/null +++ b/published/201912/20191224 Unix is turning 50. What does that mean.md @@ -0,0 +1,116 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11724-1.html) +[#]: subject: (Unix is turning 50. What does that mean?) +[#]: via: (https://www.networkworld.com/article/3511428/unix-is-turning-50-what-does-that-mean.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +Unix 即将迎来 50 岁 +====== + +Unix 时间(又称为“纪元时间epoch time”)是自 1970 年 1 月 1 日以来经过的秒数。当 Unix 即将 50 岁时,让我们看一下让内核开发人员担心的地方。 + +![](https://img.linux.net.cn/data/attachment/album/201912/28/120311hzghpxux1hp5t4xo.jpg) + +对于 Unix 而言,2020 年是重要的一年。在这一年年初,Unix 进入 50 岁。 + +尽管 Unix 的某些早期开发早于其“纪元”的正式开始,但 1970 年 1 月 1 日仍然是 POSIX 时间的零点,也是公认的 Unix 的万物之始。自那一刻算起,2020 年 1 月 1 日将是其 50 周年。(LCTT 译注:实际上,在 1971/11/3 出版的第一版《Unix 程序员手册》中,将 1971/1/1 作为 Unix 纪元的开始,并且一秒钟记录 60 个数,但是后来发现这样 32 位整型数字只能记录两年多,后来这个纪元被一再重新定义,改为从 1970/1/1 开始,每秒 1 个数。) + +### Unix 时间与人类时间 + +就人类时间而言,50 年是很重要的。就 Unix 时间而言,50 年没有什么特别的。48.7 年同样重要。 + +Unix(包括 Linux)系统将日期/时间值存储为自 1970-01-01 00:00:00 UTC 以来经过的秒数(32 位整型)。要确定自该时间以来经过了多少秒钟,看看 Unix 时间值是什么样子,你可以发出如下命令: + +``` +$ date +%s +1576883876 +``` + +`%s` 参数告诉 `date` 命令将当前日期/时间显示为自 1970-01-01 开始以来的秒数。 + +### Unix 系统可以管理多少时间? + +要了解 Unix 系统可以容纳多少时间,我们需要查看 32 位字段的容量。可以这样计算: + +``` +$ echo '2^32' | bc +4294967296 +``` + +但是,由于 Unix 需要容纳负数,因此它会为数字的符号保留一位,从而将其减少为: + +``` +$ echo '2^31' | bc +2147483648 +``` + +并且,由于 Unix 计数以 0 开头,这意味着我们有 2,147,483,648 个值,但最大的可能值为 2,147,483,647 个。Unix 日期/时间值不能超过该数字——就像汽车上的里程表可能不能超过 999,999 英里一样。加 1 该值就变为了 -2147483648。(LCTT 译注:此处原文描述有误,已修改。在达到最大值之后,即 2038/1/19 03:14:07,下 1 秒导致符号位变为 1,其余 31 位为 0,即 -2147483648,时间变为 1901/12/13 20:45:52,这就是 Y2K38 问题。) + +### 一年有多少秒? + +大多数年份的秒数可以这样计算:每天的小时数乘以每小时的分钟数乘以每分钟的秒数乘以一年中的天数: + +``` +$ expr 24 \* 60 \* 60 \* 365 +31536000 +``` + +在闰年,我们再增加一天: + +``` +$ expr 24 \* 60 \* 60 \* 366 +31622400 +``` + +(LCTT 译注:Unix 时间将一天精确定义为 24 * 60 * 60 = 86400 秒,忽略闰秒。) + +### Unix 将如何庆祝其 50 岁生日? + +2020 年 1 月 1 日中午 12:00 是纪元时间的 1577836800。这个计算有些棘手,但主要是因为我们必须适应闰年。自该纪元开始以来,我们经历了 12 个闰年,从 1972 年开始,到上一个闰年是 2016 年。而且,当我们达到 2020 年时,我们将有 38 个常规年份。 + +这是使用 `expr` 命令进行的计算,以计算这 50 年的秒数: + +``` +$ expr 24 \* 60 \* 60 \* 365 \* 38 + 24 \* 60 \* 60 \* 366 \* 12 +1577836800 +``` + +前半部分是计算 38 个非闰年的秒数。然后,我们加上闰年的 366 天的类似计算。或者,你可以使用前面介绍的每年秒数,然后执行以下操作: + +``` +$ expr 31536000 \* 38 + 31622400 \* 12 +1577836800 +``` + +这种跟踪日期和时间的方式使 Unix 系统完全不受 Y2K 恐慌的影响,1999 年末人们开始担心进入 2000 年会对计算机系统造成严重破坏,但是实际遇到的问题比人们担心的少得多。实际上,只有以两位数格式存储年份的应用程序才会将年份变为 00,以表示时间倒退。尽管如此,许多应用程序开发人员还是做了很多额外的繁琐工作,以确保 2000 年到来时,他们的系统不会出现严重问题。 + +### Unix 时间何时会遇到问题? + +在 2038 年之前,Unix 系统不会遇到 Y2K 类型的问题,直到如上所述存储的日期将超过其 32 位空间分配。但这距离现在已经只有 18 年了,内核开发人员已经在研究如何避免灾难。但现在开始恐慌还为时过早。 + +2038 年的问题有时称为 Y2K38 问题。我们必须在 2038 年 1 月 19 日星期二之前解决这个问题。如果问题到时候仍未解决,则该日期之后的系统可能会认为是 1901 年。解决该问题的一种方法是切换为日期/时间信息的 64 位表示形式。有些人认为,即使那样,也会有比听起来更复杂的问题。无论如何,恐慌还为时过早。并且,与此同时,也许在新年前夜演唱了《Auld Lang Syne》之后,你可以向 Unix 唱《生日快乐》歌了。Unix 50 岁了,这仍然是大事。 + +(LCTT 译注:建议阅读一下 Unix 时间的[维基百科][6]页面,有更多有趣和不为人知的信息。) + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3511428/unix-is-turning-50-what-does-that-mean.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2017/10/birthday-cake-candles-100739452-large.jpg +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world +[6]: https://en.wikipedia.org/wiki/Unix_time diff --git a/published/202001/20171018 How to create an e-book chapter template in LibreOffice Writer.md b/published/202001/20171018 How to create an e-book chapter template in LibreOffice Writer.md new file mode 100644 index 0000000000..be6ce008f5 --- /dev/null +++ b/published/202001/20171018 How to create an e-book chapter template in LibreOffice Writer.md @@ -0,0 +1,118 @@ +如何在 LibreOffice Writer 中创建一个电子书章节模板 +====== + +> 将电子书分成几章,创建电子书会更容易。这是设置模板的分步指南。 + +![](https://img.linux.net.cn/data/attachment/album/202001/02/102817vmflleeemehetblt.jpg) + +对于很多人来说,使用 word 程序来撰写和发布一本电子书是一种最好的、最容易的、最熟悉的方法。但是,启动你的 word 程序和打字是不够的 —— 你需要遵循一种格式。 + +这就是模板的来源。一个模板确保你的电子书有一个一致的外观和体验。幸运的是,创建模板是快速和容易的,并你在其上花费的时间和努力将带给你一本更好感观的书。 + +在这篇文章中,我将陪伴你走过如何使用 LibreOffice Writer 创建一个简单的模板,可以用于一本电子书的各个章节。你可以将这个模板用于 PDF 和 EPUB 书籍,并加以修改来满足你的需要。 + +### 我的方法 + +为什么我着重于为一个章节创建一个模板,而不是为一整本书创建一个模板?因为编写和管理单独的章节比编写和管理单个庞大而僵化的文档更容易。 + +通过关注于单独的章节,你可以专心于你需要编写的东西。你可以很容易地四处移动这些章节,给审阅者发单独一章节比发送你的完整原稿更简单而高效。当你写完一章后,你可以简单地把你的章节拼凑在一起来出版这本书(我将在下面讨论如何做到这一点)。但是不要觉得你被这种方法所束缚 —— 如果你更喜欢在单个文件中编写,简单地调整在这篇文章中描述的步骤就行。 + +让我们开始吧。 + +### 设置页面 + +仅当你计划发布你的电子书为一本 PDF 书时,这是很重要的。设置页面意味着你的书将不包含大量的跨越屏幕的让眼睛疲劳的文本。 + +选择 **格式 > 页面** 来打开 **页面样式** 窗口。我的 PDF 电子书通常是 5x8 英寸高(大约 13x20cm ,对于我们这些生活在米制世界的人来说)。我也设置页边距为半英寸(约 1.25 cm)。这些是我较喜欢的尺寸;你可以使用任何适合你的尺寸。 + +![LibreOffice Page Style window][2] + +*在 LibreOffice Writer 中的页面样式窗口让你设置页边距和页格式。* + +接下来,添加页脚以显示页码。保持页面样式窗口打开着,并单击 **页脚** 选项卡。选择 **在页脚上** 并单击 **确定** 。 + +在该页面上,在页脚中单击,然后选择 **插入 > 字段 > 页码**。不要担心页码的位置和外观;我们接下来会处理。 + +### 设置你的样式 + +像模板本身一样,样式为你的文档提供一种一致的外观和体验。如果你想更改一个标题的字体或大小,例如,你只需要在一个地方完成它,而不是手动应用格式化到每个标题。 + +标准化的 LibreOffice 模板带有许多样式,你可以调整它们以适应你的需要。为此,按 `F11` 来打开 **样式和格式** 窗口。 + +![LibreOffice styles and formatting][4] + +*使用样式和格式窗口更改字体和其它细节。* + +在一个样式上右键单击,并选择 **修改** 来编辑它。 这里是我在每本中使用的主要样式: + + 样式 | 字体 | 间距 / 对齐方式 + :-: | :-: | :-: + 标题 1 | Liberation Sans, 36 pt | 上面 36 pt ,下面 48 pt ,左对齐 + 标题 2 | Liberation Sans, 18 pt | 上面 12 pt ,下面 12 pt ,左对齐 + 标题 3 | Liberation Sans, 14 pt | 上面 12 pt ,下面 12 pt ,左对齐 + 正文 | Liberation Sans, 12 pt | 上面 12 pt ,下面 12 pt ,左对齐 + 页脚 | Liberation Sans, 10 pt | 居中对齐 + + +![LibreOffice styles in action][6] + +*这是当我们应用到电子书内容时的一个选择的样式外观。* + +对于大多数书来说,这通常是最小要求。可以随便更改字体和空格来适应你的要求。 + +根据你正在编写书的类型,你可能也想创建或修改项目符合样式,以及数字列表、引号、代码示例、数字符号等等。只需要记住始终如一地使用字体以及其大小。 + +### 保存你的模板 + +选择 **文件 > 另存为** 。在保持对话框中,从格式列表中选择 “ODF 文本文档模板 (.ott)” 。这将保存模板为一个模板,以后你可以快速调用该模板。 + +保存模板的最佳位置是 LibreOffice 模板文件夹。例如,在 Linux 中,那是在你的家目录下,在 `.config/libreoffice/4/user/template` 下。 + +### 编写你的书 + +在你开始编写前,在你的计算机上创建一个文件夹,它将为你的书保存所有的文件 —— 章节、图像、笔记等等。 + +当你准备编写时,启动 LibreOffice Writer 并选择 **文件 > 新建 > 模板** 。然后从列表中选择你的模板,并单击 **打开**。 + +![LibreOffice Writer template list][8] + +*从你在 LibreOffice Writer 中设置的列表中选择你的模板,并开始编写。* + +然后用一个描述性名称保存文档。 + +建议使用像 “第 1 章” 和 “第 2 章” 这样的惯例 —— 在某些时候,你可能决定重新编排你的章节,当你尝试管理这些章节时,它可能会变得混乱。然而,你可以在文件名称中放置章节数字,像 “第 1 章” 或 “一” 。如果你最后要重新排列全书的章节,像这样重命名更容易。 + +无需赘言,开始编写吧。记住在模板中使用样式来格式化文本 —— 这就是为什么你要创建模板,对吧? + +### 发布你的电子书 + +在完成编写一堆章节后,并准备发布它们时,创建一个主控文档。把一个主控文档作为你所编写章节的一个容器。使用一个主控文档,你可以快速地组装你的书,并任意重新排序你的章节。LibreOffice 的帮助提供了使用[主控文档][9]的详细信息。 + +假设你想生成一个 PDF ,不要只是单击**直接导出到 PDF** 按钮。这将创建一个相当不错的 PDF ,但是你可能想优化它。为此,选择 **文件 > 导出为 PDF** ,并在 PDF 选项窗口中轻微调整。你可以在这篇 [LibreOffice Writer 文档][10] 中学到更多东西。 + +如果你想创建一个 EPUB 而不是一个 PDF,或者除了一个 PDF 以外,另外创建一个 EPUB,请安装 [Writer2EPUB][11] 扩展。Opensource.com 的 Bryan Behrenshausen 为这个扩展[分享了一些有用的说明][12] 。 + +### 结束语 + +我们在这里创建的模板是极简单的,但是你可以将其用于一本简单的书,或者作为构建一个复杂模板的起点。不管怎样,这个模板都会让你快速地开始编写和发布你的电子书。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/10/creating-ebook-chapter-template-libreoffice-writer + +作者:[Scott Nesbitt][a] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/scottnesbitt +[2]:https://opensource.com/sites/default/files/images/life-uploads/lo-page-style.png (LibreOffice Page Style window) +[4]:https://opensource.com/sites/default/files/images/life-uploads/lo-paragraph-style.png (LibreOffice styles and formatting window) +[5]:/file/374466 +[6]:https://opensource.com/sites/default/files/images/life-uploads/lo-styles-in-action.png (Example of LibreOffice styles) +[8]:https://opensource.com/sites/default/files/images/life-uploads/lo-template-list.png (Template list - LibreOffice Writer) +[9]:https://help.libreoffice.org/Writer/Working_with_Master_Documents_and_Subdocuments +[10]:https://help.libreoffice.org/Common/Export_as_PDF +[11]:http://writer2epub.it/en/ +[12]:https://opensource.com/life/13/8/how-create-ebook-open-source-way diff --git a/published/202001/20190405 File sharing with Git.md b/published/202001/20190405 File sharing with Git.md new file mode 100644 index 0000000000..57d89c14c8 --- /dev/null +++ b/published/202001/20190405 File sharing with Git.md @@ -0,0 +1,230 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11768-1.html) +[#]: subject: (File sharing with Git) +[#]: via: (https://opensource.com/article/19/4/file-sharing-git) +[#]: author: (Seth Kenlon) + +用 Git 来共享文件 +====== + +> SparkleShare 是一个开源的基于 Git 的 Dropbox 风格的文件共享应用程序。在我们的系列文章中了解有关 Git 鲜为人知的用法。 + +![](https://img.linux.net.cn/data/attachment/album/202001/10/113645qb2ufvuu2ttimugv.png) + +[Git][2] 是一个少有的能将如此多的现代计算封装到一个程序之中的应用程序,它可以用作许多其他应用程序的计算引擎。虽然它以跟踪软件开发中的源代码更改而闻名,但它还有许多其他用途,可以让你的生活更轻松、更有条理。在这个 Git 系列中,我们将分享七种鲜为人知的使用 Git 的方法。 + +今天,我们将看看 SparkleShare,它使用 Git 作为文件共享的基础。 + +### 用于文件共享的 Git + +Git 的优点之一是它具有固有的分发能力。它可用来建立共享。即使你只是与自己网络上的其他计算机共享资源库,Git 也会为从共享位置获取文件的行为带来透明性。 + +随着其界面的发展,Git 变得非常简单。虽然因用户而异,他们坐下来完成一些工作时的共同点仅仅是 `git pull` 或稍微复杂一点的 `git pull && git checkout -b my-branch`。但是,对于某些人来说,将*命令输入*到他们的计算机中的做法完全是令人困惑或烦恼的。计算机旨在使生活变得轻松,它擅长于重复性工作,因此有更简便的方法可以与 Git 共享文件。 + +### SparkleShare + +[SparkleShare][3] 项目是一个基于 Git 的跨平台的、开源的 Dropbox 式的文件共享应用程序。它通过将文件拖放到专门指定的 SparkleShare 目录中的简单操作,自动执行所有 Git 命令,触发添加、提交、推送和拉取过程。因为它基于 Git,所以你可以获得基于差异(diff)的快速推送和拉取,并且继承了 Git 版本控制和后端基础设施(如 Git 挂钩)的所有优点。它可以完全自托管,也可以将其与 [GitLab][4]、GitHub、Bitbucket 等 Git 托管服务一起使用。此外,由于它基本上只是一个 Git 的前端,因此你可以在可能没有 SparkleShare 客户端但有 Git 客户端的设备上访问 SparkleShare 中的文件。 + +正如你获得 Git 的所有好处一样,你也会受到所有常见的 Git 限制:使用 SparkleShare 存储数百张照片、音乐和视频是不切实际的,因为 Git 是为文本而设计和优化的。Git 当然可以存储二进制文件的大文件,但是因为它可以跟踪历史记录,因此一旦将文件添加到其中,几乎就不可能完全删除它。这在某种程度上限制了 SparkleShare 对某些人的实用性,但使其非常适合许多工作流程,包括[日程安排][5]。 + +#### 安装 SparkleShare + +SparkleShare 是跨平台的,可从[网站][6]获得适用于 Windows 和 Mac 的安装程序。对于 Linux,有一个 [Flatpak][7] 安装包,或者你可以在终端中运行以下命令: + +``` +$ sudo flatpak remote-add flathub https://flathub.org/repo/flathub.flatpakrepo +$ sudo flatpak install flathub org.sparkleshare.SparkleShare +``` + +### 创建一个 Git 存储库 + +SparkleShare 并不是软件即服务(SaaS)。你在计算机上运行 SparkleShare 与 Git 存储库进行通信,而 SparkleShare 并不存储你的数据。如果你还没有与文件夹同步的 Git 存储库,则必须在启动 SparkleShare 之前创建一个文件夹。你有三个选择:托管的 Git、自托管 Git 或自托管 SparkleShare。 + +#### 托管的 Git + +SparkleShare 可以使用你能访问的任何 Git 存储库进行存储,因此,如果你拥有 GitLab 或任何其他托管服务的帐户(或创建一个),则它可以成为 SparkleShare 的后端。例如,开源 [Notabug.org][8] 服务是一个类似于 GitHub 和 GitLab 的 Git 托管服务,但其独特性足以证明 SparkleShare 的灵活性。根据用户界面的不同,不同的托管服务创建新存储库的方法也有所不同,但是所有主要存储库都遵循相同的通用模型。 + +首先,在托管服务中找到创建新项目或存储库的按钮,单击它以开始。然后逐步完成存储库的创建过程,为存储库提供名称、隐私级别(存储库通常默认为公共),以及是否使用 `README` 文件初始化存储库。无论你是否需要个 `README` 文件,请初始化建立一个。使用一个文件来创建存储库不是绝对必要的,但是它会强制 Git 主机实例化存储库中的 `master` 分支,这有助于确保前端应用程序(例如 SparkleShare)具有要提交并推送的分支。即使文件是几乎空的 `README` 文件,也可以用来查看该文件以确认你已连接成功。 + +![Creating a Git repository][9] + +创建存储库后,获取其用于 SSH 克隆的 URL。就像从 Git 项目获得其 URL 一样,你也可以获取此 URL:导航至存储库页面并查找 “Clone” 按钮或字段。 + +![Cloning a URL on GitHub][10] + +*GitHub 的克隆 URL。* + +![Cloning a URL on GitLab][11] + +*GitLab 的克隆 URL。* + +这是 SparkleShare 用于获取数据的地址,因此请记下它。你的 Git 存储库现已配置好。 + +#### 自托管的 Git + +你可以使用 SparkleShare 访问你有权访问的任何计算机上的 Git 存储库。除了一个 Git 裸存储库外,无需任何特殊设置。但是,如果你想将对 Git 存储库的访问权授予其他任何人,则应运行 [Gitolite][12] 之类的 Git 管理器或 SparkleShare 自己的 Dazzle 服务器来帮助你管理 SSH 密钥和帐户。至少,创建一个特定于 Git 的用户,以便有权访问你的 Git 存储库的用户不会自动获得对服务器其余部分的访问权限。 + +以 Git 用户身份登录服务器(如果你非常擅长管理用户和组权限,则可以以自己的用户登录)并创建存储库: + +``` +$ mkdir ~/sparkly.git +$ cd ~/sparkly.git +$ git init --bare . +``` + +你的 Git 存储库现已配置好。 + +#### Dazzle + +SparkleShare 的开发人员提供了一个名为 [Dazzle][13] 的 Git 管理系统,以帮助你自托管 Git 存储库。 + +在你的服务器上,将 Dazzle 应用程序下载到你的路径中的某个位置: + +``` +$ curl https://raw.githubusercontent.com/hbons/Dazzle/master/dazzle.sh --output ~/bin/dazzle +$ chmod +x ~/bin/dazzle +``` + +Dazzle 设置了一个特定于 Git 和 SparkleShare 的用户,并且还基于 SparkleShare 应用程序生成的密钥实现了访问权限。现在,只需设置一个项目: + +``` +$ dazzle create sparkly +``` + +你的服务器现在已经配置好,可以用作 SparkleShare 托管了。 + +### 配置 SparkleShare + +首次启动 SparkleShare 时,系统会提示你配置 SparkleShare 用于存储的服务器。这个过程可能看起来像一个首次运行的安装向导,但实际上是在 SparkleShare 中设置新共享位置的通常过程。与许多共享驱动器应用程序不同,使用 SparkleShare 可以一次配置多个位置。你配置的第一个共享位置并不比你以后可以配置的任何共享位置更重要,并且你也不用注册 SparkleShare 或任何其他服务。你只是将 SparkleShare 指向 Git 存储库,以便它知道如何使第一个 SparkleShare 文件夹保持同步。 + +在第一个屏幕上,给出一个身份信息,SparkleShare 将在代表你进行的 Git 提交记录中使用这些信息。你可以使用任何内容,甚至可以使用不代表任何意义的伪造信息。它仅用于提交消息,如果你对审查 Git 后端进程没有兴趣,你可能甚至看不到它们。 + +下一个屏幕提示你选择主机类型。如果你使用的是 GitLab、GitHub、Planio 或 Bitbucket,则可以选择一个适当的。否则,请选择“自己的服务器”。 + +![Choosing a Sparkleshare host][14] + +在此屏幕底部,你必须输入 SSH 的克隆 URL。如果你是自托管的 Git,则地址类似于 ``,而远程路径是为此目的而创建的 Git 存储库的绝对路径。 + +根据上面的自托管示例,我虚构的服务器的地址为 `ssh://git@example.com:22122`(`:22122` 表示一个非标准的 SSH 端口),远程路径为 `/home/git/sparkly.git`。 + +如果我改用 Notabug.org 帐户,则上例中的地址为 `ssh://git@notabug.org`,路径为 `seth/sparkly.git`。 + +SparkleShare 首次尝试连接到主机时会失败,因为你尚未将 SparkleShare 客户端 ID(特定于 SparkleShare 应用程序的 SSH 密钥)复制到 Git 主机。这是预料之中的,所以不要取消该过程。将 SparkleShare 设置窗口保持打开状态,并从系统任务栏中的 SparkleShare 图标处获取客户端 ID。然后将客户端 ID 复制到剪贴板,以便可以将其添加到 Git 主机。 + +![Getting the client ID from Sparkleshare][16] + +#### 将你的客户端 ID 添加到托管的 Git 帐户 + +除了较小的 UI 差异外,在任何托管服务上添加 SSH 密钥(所有客户端 ID 都是这样)的过程基本上是相同的。在你的 Git 主机的 Web 仪表板中,导航到你的用户设置,然后找到 “SSH 密钥”类别。单击“添加新密钥”按钮(或类似按钮),然后粘贴你的 SparkleShare 客户端 ID 的内容。 + +![Adding an SSH key][17] + +保存密钥。如果你希望其他人(例如协作者或家庭成员)能够访问同一存储库,则他们必须向你提供其 SparkleShare 客户端 ID,以便你可以将其添加到帐户中。 + +#### 将你的客户端 ID 添加到自托管的 Git 帐户 + +SparkleShare 客户端 ID 只是一个 SSH 密钥,因此将其复制并粘贴到 Git 用户的 `~/.ssh/authorized_keys` 文件中。 + +#### 使用 Dazzle 添加你的客户 ID + +如果你使用 Dazzle 管理 SparkleShare 项目,请使用以下命令添加客户端 ID: + +``` +$ dazzle link +``` + +当 Dazzle 提示你输入该 ID 时,请粘贴在 SparkleShare 菜单中找到的客户端 ID。 + +### 使用 SparkleShare + +将客户端 ID 添加到 Git 主机后,在 SparkleShare 窗口中单击“重试”按钮以完成设置。克隆存储库完成后,你可以关闭 SparkleShare 设置窗口,并在你的家目录中找到一个新的 `SparkleShare` 文件夹。如果你设置了带有托管服务的 Git 存储库,并选择包括 `README` 文件或许可证文件,则可以在 SparkleShare 目录中看到它们。 + +![Sparkleshare file manager][18] + +此外,有一些隐藏目录,你可以通过在文件管理器中显示隐藏目录来查看。 + +![Showing hidden files in GNOME][19] + +使用 SparkleShare 的方式与使用计算机上任何目录的方式相同:将文件放入其中。每当将文件或目录放入 SparkleShare 文件夹时,它都会在后台复制到你的 Git 存储库。 + +#### 排除某些文件 + +由于 Git 从设计上就是要记住*一切*,因此你可能希望从记录中排除特定的文件类型。排除一些文件是有原因的。通过定义摆脱 SparkleShare 管理的文件,可以避免意外复制大文件。你还可以为自己设计一种方案,使你可以将存储在一个目录中的逻辑上属于同一个文件(例如,MIDI 文件及其 .flac 导出文件),但是可以自己手动备份大文件,而同时让 SparkleShare 备份基于文本的文件。 + +如果在系统的文件管理器中看不到隐藏的文件,请显示它们。导航到你的 SparkleShare 文件夹,然后到代表你的存储库的目录,找到一个名为 `.gitignore` 的文件,然后在文本编辑器中将其打开。你可以在 `.gitignore` 中输入文件扩展名或文件名(每行一个),任何与你列出的文件匹配的文件都会被忽略(如文件名所示)。 + +``` +Thumbs.db +$RECYCLE.BIN/ +.DS_Store +._* +.fseventsd +.Spotlight-V100 +.Trashes +.directory +.Trash-* +*.wav +*.ogg +*.flac +*.mp3 +*.m4a +*.opus +*.jpg +*.png +*.mp4 +*.mov +*.mkv +*.avi +*.pdf +*.djvu +*.epub +*.od{s,t} +*.cbz +``` + +你知道最经常遇到哪些文件类型,因此请集中精力处理最有可能潜入你的 SparkleShare 目录的文件。如果你想稍微矫枉过正一些,可以在 Notabug.org 以及整个网上找到 `.gitignore` 文件的好集合。 + +通过将这些条目保存在 `.gitignore` 文件中,你可以将不需要发送到 Git 主机的大文件放在 SparkleShare 目录中,SparkleShare 将完全忽略它们。当然,这意味着你需要确保它们可以备份或通过其他方式分发给你的 SparkleShare 协作者。 + +### 自动化 + +[自动化][20] 是我们与计算机达成的默契之一:计算机执行重复的、无聊的工作,而我们人类要么不擅长做这些,要么不擅长记忆这些。SparkleShare 是一种很好的、简单的自动执行例行数据分发的方法。但不管怎么说,这并不适合每个 Git 存储库。它没有用于高级 Git 功能的接口,它没有暂停按钮或手动管理的操作。没关系,因为它的使用范围是有意限制的。SparkleShare 可以完成它计划要做的事情,它做得很好,而且它是你无需关心的一个 Git 存储库。 + +如果你想使用这种稳定的、看不见的自动化,请尝试一下 SparkleShare。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/file-sharing-git + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_cloud21x_cc.png?itok=5UwC92dO +[2]: https://git-scm.com/ +[3]: http://www.sparkleshare.org/ +[4]: http://gitlab.com +[5]: https://opensource.com/article/19/4/calendar-git +[6]: http://sparkleshare.org +[7]: /business/16/8/flatpak +[8]: http://notabug.org +[9]: https://opensource.com/sites/default/files/uploads/git-new-repo.jpg (Creating a Git repository) +[10]: https://opensource.com/sites/default/files/uploads/github-clone-url.jpg (Cloning a URL on GitHub) +[11]: https://opensource.com/sites/default/files/uploads/gitlab-clone-url.jpg (Cloning a URL on GitLab) +[12]: http://gitolite.org +[13]: https://github.com/hbons/Dazzle +[14]: https://opensource.com/sites/default/files/uploads/sparkleshare-host.jpg (Choosing a Sparkleshare host) +[15]: mailto:git@notabug.org +[16]: https://opensource.com/sites/default/files/uploads/sparkleshare-clientid.jpg (Getting the client ID from Sparkleshare) +[17]: https://opensource.com/sites/default/files/uploads/git-ssh-key.jpg (Adding an SSH key) +[18]: https://opensource.com/sites/default/files/uploads/sparkleshare-file-manager.jpg (Sparkleshare file manager) +[19]: https://opensource.com/sites/default/files/uploads/gnome-show-hidden-files.jpg (Showing hidden files in GNOME) +[20]: /downloads/ansible-quickstart diff --git a/published/202001/20190406 Run a server with Git.md b/published/202001/20190406 Run a server with Git.md new file mode 100644 index 0000000000..ee4497eb51 --- /dev/null +++ b/published/202001/20190406 Run a server with Git.md @@ -0,0 +1,226 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11795-1.html) +[#]: subject: (Run a server with Git) +[#]: via: (https://opensource.com/article/19/4/server-administration-git) +[#]: author: (Seth Kenlon https://opensource.com/users/seth/users/seth) + +使用 Git 来管理 Git 服务器 +====== + +> 借助 Gitolite,你可以使用 Git 来管理 Git 服务器。在我们的系列文章中了解这些鲜为人知的 Git 用途。 + +![](https://img.linux.net.cn/data/attachment/album/202001/18/132045yrr1pb9n497tfbiy.png) + +正如我在系列文章中演示的那样,[Git][2] 除了跟踪源代码外,还可以做很多事情。信不信由你,Git 甚至可以管理你的 Git 服务器,因此你可以或多或少地使用 Git 本身来运行 Git 服务器。 + +当然,这涉及除日常使用 Git 之外的许多组件,其中最重要的是 [Gitolite][3],该后端应用程序可以管理你使用 Git 的每个细微的配置。Gitolite 的优点在于,由于它使用 Git 作为其前端接口,因此很容易将 Git 服务器管理集成到其他基于 Git 的工作流中。Gitolite 可以精确控制谁可以访问你服务器上的特定存储库以及他们具有哪些权限。你可以使用常规的 Linux 系统工具自行管理此类事务,但是如果有好几个用户和不止一两个仓库,则需要大量的工作。 + +Gitolite 的开发人员做了艰苦的工作,使你可以轻松地为许多用户提供对你的 Git 服务器的访问权,而又不让他们访问你的整个环境 —— 而这一切,你可以使用 Git 来完成全部工作。 + +Gitolite 并**不是**图形化的管理员和用户面板。优秀的 [Gitea][4] 项目可提供这种体验,但是本文重点介绍 Gitolite 的简单优雅和令人舒适的熟悉感。 + +### 安装 Gitolite + +假设你的 Git 服务器运行在 Linux 上,则可以使用包管理器安装 Gitolite(在 CentOS 和 RHEL 上为 `yum`,在 Debian 和 Ubuntu 上为 `apt`,在 OpenSUSE 上为 `zypper` 等)。例如,在 RHEL 上: + +``` +$ sudo yum install gitolite3 +``` + +许多发行版的存储库提供的仍是旧版本的 Gitolite,但最新版本为版本 3。 + +你必须具有对服务器的无密码 SSH 访问权限。如果愿意,你可以使用密码登录服务器,但是 Gitolite 依赖于 SSH 密钥,因此必须配置使用密钥登录的选项。如果你不知道如何配置服务器以进行无密码 SSH 访问,请首先学习如何进行操作(Steve Ovens 的 Ansible 文章的[设置 SSH 密钥身份验证][5]部分对此进行了很好的说明)。这是加强服务器管理的安全以及运行 Gitolite 的重要组成部分。 + +### 配置 Git 用户 + +如果没有 Gitolite,则如果某人请求访问你在服务器上托管的 Git 存储库时,则必须向该人提供用户帐户。Git 提供了一个特殊的外壳,即 `git-shell`,这是一个仅执行 Git 任务的特别的特定 shell。这可以让你有个只能通过非常受限的 Shell 环境来过滤访问你的服务器的用户。 + +这个解决方案是一个办法,但通常意味着用户可以访问服务器上的所有存储库,除非你具有用于组权限的良好模式,并在创建新存储库时严格遵循这些权限。这种方式还需要在系统级别进行大量手动配置,这通常是只有特定级别的系统管理员才能做的工作,而不一定是通常负责 Git 存储库的人员。 + +Gitolite 通过为需要访问任何存储库的每个人指定一个用户名来完全回避此问题。默认情况下,该用户名是 `git`,并且由于 Gitolite 的文档中假定使用的是它,因此在学习该工具时保留它是一个很好的默认设置。对于曾经使用过 GitLab 或 GitHub 或任何其他 Git 托管服务的人来说,这也是一个众所周知的约定。 + +Gitolite 将此用户称为**托管用户**。在服务器上创建一个帐户以充当托管用户(我习惯使用 `git`,因为这是惯例): + +``` +$ sudo adduser --create-home git +``` + +为了控制该 `git` 用户帐户,该帐户必须具有属于你的有效 SSH 公钥。你应该已经进行了设置,因此复制你的公钥(**而不是你的私钥**)添加到 `git` 用户的家目录中: + +``` +$ sudo cp ~/.ssh/id_ed25519.pub /home/git/ +$ sudo chown git:git /home/git/id_ed25519.pub +``` + +如果你的公钥不以扩展名 `.pub` 结尾,则 Gitolite 不会使用它,因此请相应地重命名该文件。切换为该用户帐户以运行 Gitolite 的安装程序: + +``` +$ sudo su - git +$ gitolite setup --pubkey id_ed25519.pub +``` + +安装脚本运行后,`git` 的家用户目录将有一个 `repository` 目录,该目录(目前)包含存储库 `git-admin.git` 和 `testing.git`。这就是该服务器所需的全部设置,现在请登出 `git` 用户。 + +### 使用 Gitolite + +管理 Gitolite 就是编辑 Git 存储库中的文本文件,尤其是 `gitolite-admin.git` 中的。你不会通过 SSH 进入服务器来进行 Git 管理,并且 Gitolite 也建议你不要这样尝试。在 Gitolite 服务器上存储你和你的用户的存储库是个**裸**存储库,因此最好不要使用它们。 + +``` +$ git clone git@example.com:gitolite-admin.git gitolite-admin.git +$ cd gitolite-admin.git +$ ls -1 +conf +keydir +``` + +该存储库中的 `conf` 目录包含一个名为 `gitolite.conf` 的文件。在文本编辑器中打开它,或使用 `cat` 查看其内容: + +``` +repo gitolite-admin + RW+ = id_ed22519 + +repo testing + RW+ = @all +``` + +你可能对该配置文件的功能有所了解:`gitolite-admin` 代表此存储库,并且 `id_ed25519` 密钥的所有者具有读取、写入和管理 Git 的权限。换句话说,不是将用户映射到普通的本地 Unix 用户(因为所有用户都使用 `git` 用户托管用户身份),而是将用户映射到 `keydir` 目录中列出的 SSH 密钥。 + +`testing.git` 存储库使用特殊组符号为访问服务器的每个人提供了全部权限。 + +#### 添加用户 + +如果要向 Git 服务器添加一个名为 `alice` 的用户,Alice 必须向你发送她的 SSH 公钥。Gitolite 使用文件名的 `.pub` 扩展名左边的任何内容作为该 Git 用户的标识符。不要使用默认的密钥名称值,而是给密钥指定一个指示密钥所有者的名称。如果用户有多个密钥(例如,一个用于笔记本电脑,一个用于台式机),则可以使用子目录来避免文件名冲突。例如,Alice 在笔记本电脑上使用的密钥可能是默认的 `id_rsa.pub`,因此将其重命名为`alice.pub` 或类似名称(或让用户根据其计算机上的本地用户帐户来命名密钥),然后将其放入 `gitolite-admin.git/keydir/work/laptop/` 目录中。如果她从她的桌面计算机发送了另一个密钥,命名为 `alice.pub`(与上一个相同),然后将其添加到 `keydir/home/desktop/` 中。另一个密钥可能放到 `keydir/home/desktop/` 中,依此类推。Gitolite 递归地在 `keydir` 中搜索与存储库“用户”相匹配的 `.pub` 文件,并将所有匹配项视为相同的身份。 + +当你将密钥添加到 `keydir` 目录时,必须将它们提交回服务器。这是一件很容易忘记的事情,这里有一个使用自动化的 Git 应用程序(例如 [Sparkleshare][7])的真正的理由,因此任何更改都将立即提交给你的 Gitolite 管理员。第一次忘记提交和推送,在浪费了三个小时的你和你的用户的故障排除时间之后,你会发现 Gitolite 是使用 Sparkleshare 的完美理由。 + +``` +$ git add keydir +$ git commit -m 'added alice-laptop-0.pub' +$ git push origin HEAD +``` + +默认情况下,Alice 可以访问 `testing.git` 目录,因此她可以使用该目录测试连接性和功能。 + +#### 设置权限 + +与用户一样,目录权限和组也是从你可能习惯的的常规 Unix 工具中抽象出来的(或可从在线信息查找)。在 `gitolite-admin.git/conf` 目录中的 `gitolite.conf` 文件中授予对项目的权限。权限分为四个级别: + +* `R` 允许只读。在存储库上具有 `R` 权限的用户可以克隆它,仅此而已。 +* `RW` 允许用户执行分支的快进推送、创建新分支和创建新标签。对于大多数用户来说,这个基本上就像是一个“普通”的 Git 存储库。 +* `RW+` 允许可能具有破坏性的 Git 动作。用户可以执行常规的快进推送、回滚推送、变基以及删除分支和标签。你可能想要或不希望将其授予项目中的所有贡献者。 +* `-` 明确拒绝访问存储库。这与未在存储库的配置中列出的用户相同。 + +通过调整 `gitolite.conf` 来创建一个新的存储库或修改现有存储库的权限。例如,授予 Alice 权限来管理一个名为 `widgets.git` 的新存储库: + +``` +repo gitolite-admin + RW+ = id_ed22519 + +repo testing + RW+ = @all + +repo widgets + RW+ = alice +``` + +现在,Alice(也仅有 Alice 一个人)可以克隆该存储库: + +``` +[alice]$ git clone git@example.com:widgets.git +Cloning into 'widgets'... +warning: You appear to have cloned an empty repository. +``` + +在第一次推送时,Alice 必须使用 `-u` 选项将其分支发送到空存储库(如同她在任何 Git 主机上做的一样)。 + +为了简化用户管理,你可以定义存储库组: + +``` +@qtrepo = widgets +@qtrepo = games + +repo gitolite-admin + RW+ = id_ed22519 + +repo testing + RW+ = @all + +repo @qtrepo + RW+ = alice +``` + +正如你可以创建组存储库一样,你也可以对用户进行分组。默认情况下存在一个用户组:`@all`。如你所料,它包括所有用户,无一例外。你也可以创建自己的组: + +``` +@qtrepo = widgets +@qtrepo = games + +@developers = alice bob + +repo gitolite-admin + RW+ = id_ed22519 + +repo testing + RW+ = @all + +repo @qtrepo + RW+ = @developers +``` + +与添加或修改密钥文件一样,对 `gitolite.conf` 文件的任何更改都必须提交并推送以生效。 + +### 创建存储库 + +默认情况下,Gitolite 假设存储库的创建是从上至下进行。例如,有权访问 Git 服务器的项目经理创建了一个项目存储库,并通过 Gitolite 管理仓库添加了开发人员。 + +实际上,你可能更愿意向用户授予创建存储库的权限。Gitolite 称这些为“野生仓库(通配仓库)wild repos”(我不确定这是关于仓库的形成方式的描述,还是指配置文件所需的通配符)。这是一个例子: + +``` +@managers = alice bob + +repo foo/CREATOR/[a-z]..* + C = @managers + RW+ = CREATOR + RW = WRITERS + R = READERS +``` + +第一行定义了一组用户:该组称为 `@managers`,其中包含用户 `alice` 和 `bob`。下一行设置了通配符允许创建尚不存在的存储库,放在名为 `foo` 的目录下的创建该存储库的用户名的子目录中。例如: + +``` +[alice]$ git clone git@example.com:foo/alice/cool-app.git +Cloning into cool-app'... +Initialized empty Git repository in /home/git/repositories/foo/alice/cool-app.git +warning: You appear to have cloned an empty repository. +``` + +野生仓库的创建者可以使用一些机制来定义谁可以读取和写入其存储库,但是他们是有范围限定的。在大多数情况下,Gitolite 假定由一组特定的用户来管理项目权限。一种解决方案是使用 Git 挂钩来授予所有用户对 `gitolite-admin` 的访问权限,以要求管理者批准将更改合并到 master 分支中。 + +### 了解更多 + +Gitolite 具有比此介绍性文章所涵盖的更多功能,因此请尝试一下。其[文档][8]非常出色,一旦你通读了它,就可以自定义 Gitolite 服务器,以向用户提供你喜欢的任何级别的控制。Gitolite 是一种维护成本低、简单的系统,你可以安装、设置它,然后基本上就可以将其忘却。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/server-administration-git + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/server_data_system_admin.png?itok=q6HCfNQ8 (computer servers processing data) +[2]: https://git-scm.com/ +[3]: http://gitolite.com +[4]: http://gitea.io +[5]: Setting%20up%20SSH%20key%20authentication +[6]: mailto:git@example.com +[7]: https://opensource.com/article/19/4/file-sharing-git +[8]: http://gitolite.com/gitolite/quick_install.html diff --git a/published/202001/20190619 Getting started with OpenSSL- Cryptography basics.md b/published/202001/20190619 Getting started with OpenSSL- Cryptography basics.md new file mode 100644 index 0000000000..d7cd09934e --- /dev/null +++ b/published/202001/20190619 Getting started with OpenSSL- Cryptography basics.md @@ -0,0 +1,333 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11810-1.html) +[#]: subject: (Getting started with OpenSSL: Cryptography basics) +[#]: via: (https://opensource.com/article/19/6/cryptography-basics-openssl-part-1) +[#]: author: (Marty Kalin https://opensource.com/users/mkalindepauledu/users/akritiko/users/clhermansen) + +OpenSSL 入门:密码学基础知识 +====== + +> 想要入门密码学的基础知识,尤其是有关 OpenSSL 的入门知识吗?继续阅读。 + +![](https://img.linux.net.cn/data/attachment/album/202001/23/142249fpnhyqz9y2cz1exe.jpg) + +本文是使用 [OpenSSL][2] 的密码学基础知识的两篇文章中的第一篇,OpenSSL 是在 Linux 和其他系统上流行的生产级库和工具包。(要安装 OpenSSL 的最新版本,请参阅[这里][3]。)OpenSSL 实用程序可在命令行使用,程序也可以调用 OpenSSL 库中的函数。本文的示例程序使用的是 C 语言,即 OpenSSL 库的源语言。 + +本系列的两篇文章涵盖了加密哈希、数字签名、加密和解密以及数字证书。你可以从[我的网站][4]的 ZIP 文件中找到这些代码和命令行示例。 + +让我们首先回顾一下 OpenSSL 名称中的 SSL。 + +### OpenSSL 简史 + +[安全套接字层][5]Secure Socket Layer(SSL)是 Netscape 在 1995 年发布的一种加密协议。该协议层可以位于 HTTP 之上,从而为 HTTPS 提供了 S:安全secure。SSL 协议提供了各种安全服务,其中包括两项在 HTTPS 中至关重要的服务: + +* 对等身份验证Peer authentication(也称为相互质询):连接的每一边都对另一边的身份进行身份验证。如果 Alice 和 Bob 要通过 SSL 交换消息,则每个人首先验证彼此的身份。 +* 机密性Confidentiality:发送者在通过通道发送消息之前先对其进行加密。然后,接收者解密每个接收到的消息。此过程可保护网络对话。即使窃听者 Eve 截获了从 Alice 到 Bob 的加密消息(即*中间人*攻击),Eve 会发现他无法在计算上解密此消息。 + +反过来,这两个关键 SSL 服务与其他不太受关注的服务相关联。例如,SSL 支持消息完整性,从而确保接收到的消息与发送的消息相同。此功能是通过哈希函数实现的,哈希函数也随 OpenSSL 工具箱一起提供。 + +SSL 有多个版本(例如 SSLv2 和 SSLv3),并且在 1999 年出现了一个基于 SSLv3 的类似协议传输层安全性Transport Layer Security(TLS)。TLSv1 和 SSLv3 相似,但不足以相互配合工作。不过,通常将 SSL/TLS 称为同一协议。例如,即使正在使用的是 TLS(而非 SSL),OpenSSL 函数也经常在名称中包含 SSL。此外,调用 OpenSSL 命令行实用程序以 `openssl` 开始。 + +除了 man 页面之外,OpenSSL 的文档是零零散散的,鉴于 OpenSSL 工具包很大,这些页面很难以查找使用。命令行和代码示例可以将主要主题集中起来。让我们从一个熟悉的示例开始(使用 HTTPS 访问网站),然后使用该示例来选出我们感兴趣的加密部分进行讲述。 + +### 一个 HTTPS 客户端 + +此处显示的 `client` 程序通过 HTTPS 连接到 Google: + +``` +/* compilation: gcc -o client client.c -lssl -lcrypto */ +#include +#include +#include /* BasicInput/Output streams */ +#include /* errors */ +#include /* core library */ +#define BuffSize 1024 + +void report_and_exit(const char* msg) { + perror(msg); + ERR_print_errors_fp(stderr); + exit(-1); +} + +void init_ssl() { + SSL_load_error_strings(); + SSL_library_init(); +} + +void cleanup(SSL_CTX* ctx, BIO* bio) { + SSL_CTX_free(ctx); + BIO_free_all(bio); +} + +void secure_connect(const char* hostname) { + char name[BuffSize]; + char request[BuffSize]; + char response[BuffSize]; + + const SSL_METHOD* method = TLSv1_2_client_method(); + if (NULL == method) report_and_exit("TLSv1_2_client_method..."); + + SSL_CTX* ctx = SSL_CTX_new(method); + if (NULL == ctx) report_and_exit("SSL_CTX_new..."); + + BIO* bio = BIO_new_ssl_connect(ctx); + if (NULL == bio) report_and_exit("BIO_new_ssl_connect..."); + + SSL* ssl = NULL; + + /* 链路 bio 通道,SSL 会话和服务器端点 */ + + sprintf(name, "%s:%s", hostname, "https"); + BIO_get_ssl(bio, &ssl); /* 会话 */ + SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); /* 鲁棒性 */ + BIO_set_conn_hostname(bio, name); /* 准备连接 */ + + /* 尝试连接 */ + if (BIO_do_connect(bio) <= 0) { + cleanup(ctx, bio); + report_and_exit("BIO_do_connect..."); + } + + /* 验证信任库,检查证书 */ + if (!SSL_CTX_load_verify_locations(ctx, + "/etc/ssl/certs/ca-certificates.crt", /* 信任库 */ + "/etc/ssl/certs/")) /* 其它信任库 */ + report_and_exit("SSL_CTX_load_verify_locations..."); + + long verify_flag = SSL_get_verify_result(ssl); + if (verify_flag != X509_V_OK) + fprintf(stderr, + "##### Certificate verification error (%i) but continuing...\n", + (int) verify_flag); + + /* 获取主页作为示例数据 */ + sprintf(request, + "GET / HTTP/1.1\x0D\x0AHost: %s\x0D\x0A\x43onnection: Close\x0D\x0A\x0D\x0A", + hostname); + BIO_puts(bio, request); + + /* 从服务器读取 HTTP 响应并打印到输出 */ + while (1) { + memset(response, '\0', sizeof(response)); + int n = BIO_read(bio, response, BuffSize); + if (n <= 0) break; /* 0 代表流结束,< 0 代表有错误 */ + puts(response); + } + + cleanup(ctx, bio); +} + +int main() { + init_ssl(); + + const char* hostname = "www.google.com:443"; + fprintf(stderr, "Trying an HTTPS connection to %s...\n", hostname); + secure_connect(hostname); + +return 0; +} +``` + +可以从命令行编译和执行该程序(请注意 `-lssl` 和 `-lcrypto` 中的小写字母 `L`): + +``` +gcc -o client client.c -lssl -lcrypto +``` + +该程序尝试打开与网站 [www.google.com][13] 的安全连接。在与 Google Web 服务器的 TLS 握手过程中,`client` 程序会收到一个或多个数字证书,该程序会尝试对其进行验证(但在我的系统上失败了)。尽管如此,`client` 程序仍继续通过安全通道获取 Google 主页。该程序取决于前面提到的安全工件,尽管在上述代码中只着重突出了数字证书。但其它工件仍在幕后发挥作用,稍后将对它们进行详细说明。 + +通常,打开 HTTP(非安全)通道的 C 或 C++ 的客户端程序将使用诸如*文件描述符*或*网络套接字*之类的结构,它们是两个进程(例如,这个 `client` 程序和 Google Web 服务器)之间连接的端点。另一方面,文件描述符是一个非负整数值,用于在程序中标识该程序打开的任何文件类的结构。这样的程序还将使用一种结构来指定有关 Web 服务器地址的详细信息。 + +这些相对较低级别的结构不会出现在客户端程序中,因为 OpenSSL 库会将套接字基础设施和地址规范等封装在更高层面的安全结构中。其结果是一个简单的 API。下面首先看一下 `client` 程序示例中的安全性详细信息。 + +* 该程序首先加载相关的 OpenSSL 库,我的函数 `init_ssl` 中对 OpenSSL 进行了两次调用: + + ``` +SSL_load_error_strings(); +SSL_library_init(); +``` +* 下一个初始化步骤尝试获取安全*上下文*,这是建立和维护通往 Web 服务器的安全通道所需的信息框架。如对 OpenSSL 库函数的调用所示,在示例中使用了 TLS 1.2: + + ``` +const SSL_METHOD* method = TLSv1_2_client_method(); /* TLS 1.2 */ +``` + + 如果调用成功,则将 `method` 指针被传递给库函数,该函数创建类型为 `SSL_CTX` 的上下文: + + ``` +SSL_CTX* ctx = SSL_CTX_new(method); +``` + + `client` 程序会检查每个关键的库调用的错误,如果其中一个调用失败,则程序终止。 +* 现在还有另外两个 OpenSSL 工件也在发挥作用:SSL 类型的安全会话,从头到尾管理安全连接;以及类型为 BIO(基本输入/输出Basic Input/Output)的安全流,用于与 Web 服务器进行通信。BIO 流是通过以下调用生成的: + + ``` +BIO* bio = BIO_new_ssl_connect(ctx); +``` + + 请注意,这个最重要的上下文是其参数。`BIO` 类型是 C 语言中 `FILE` 类型的 OpenSSL 封装器。此封装器可保护 `client` 程序与 Google 的网络服务器之间的输入和输出流的安全。 +* 有了 `SSL_CTX` 和 `BIO`,然后程序在 SSL 会话中将它们组合在一起。三个库调用可以完成工作: + + ``` +BIO_get_ssl(bio, &ssl); /* 会话 */ +SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); /* 鲁棒性 */ +BIO_set_conn_hostname(bio, name); /* 准备连接 */ +``` + + 安全连接本身是通过以下调用建立的: + + ``` +BIO_do_connect(bio); +``` + + 如果最后一个调用不成功,则 `client` 程序终止;否则,该连接已准备就绪,可以支持 `client` 程序与 Google Web 服务器之间的机密对话。 + +在与 Web 服务器握手期间,`client` 程序会接收一个或多个数字证书,以认证服务器的身份。但是,`client` 程序不会发送自己的证书,这意味着这个身份验证是单向的。(Web 服务器通常配置为**不**需要客户端证书)尽管对 Web 服务器证书的验证失败,但 `client` 程序仍通过了连接到 Web 服务器的安全通道继续获取 Google 主页。 + +为什么验证 Google 证书的尝试会失败?典型的 OpenSSL 安装目录为 `/etc/ssl/certs`,其中包含 `ca-certificates.crt` 文件。该目录和文件包含着 OpenSSL 自带的数字证书,以此构成信任库truststore。可以根据需要更新信任库,尤其是可以包括新信任的证书,并删除不再受信任的证书。 + +`client` 程序从 Google Web 服务器收到了三个证书,但是我的计算机上的 OpenSSL 信任库并不包含完全匹配的证书。如目前所写,`client` 程序不会通过例如验证 Google 证书上的数字签名(一个用来证明该证书的签名)来解决此问题。如果该签名是受信任的,则包含该签名的证书也应受信任。尽管如此,`client` 程序仍继续获取页面,然后打印出 Google 的主页。下一节将更详细地介绍这些。 + +### 客户端程序中隐藏的安全性 + +让我们从客户端示例中可见的安全工件(数字证书)开始,然后考虑其他安全工件如何与之相关。数字证书的主要格式标准是 X509,生产级的证书由诸如 [Verisign][14] 的证书颁发机构Certificate Authority(CA)颁发。 + +数字证书中包含各种信息(例如,激活日期和失效日期以及所有者的域名),也包括发行者的身份和*数字签名*(这是加密过的*加密哈希*值)。证书还具有未加密的哈希值,用作其标识*指纹*。 + +哈希值来自将任意数量的二进制位映射到固定长度的摘要。这些位代表什么(会计报告、小说或数字电影)无关紧要。例如,消息摘要版本 5Message Digest version 5(MD5)哈希算法将任意长度的输入位映射到 128 位哈希值,而 SHA1(安全哈希算法版本 1Secure Hash Algorithm version 1)算法将输入位映射到 160 位哈希值。不同的输入位会导致不同的(实际上在统计学上是唯一的)哈希值。下一篇文章将会进行更详细的介绍,并着重介绍什么使哈希函数具有加密功能。 + +数字证书的类型有所不同(例如根证书、中间证书和最终实体证书),并形成了反映这些证书类型的层次结构。顾名思义,*根*证书位于层次结构的顶部,其下的证书继承了根证书所具有的信任。OpenSSL 库和大多数现代编程语言都具有 X509 数据类型以及处理此类证书的函数。来自 Google 的证书具有 X509 格式,`client` 程序会检查该证书是否为 `X509_V_OK`。 + +X509 证书基于公共密钥基础结构public-key infrastructure(PKI),其中包括的算法(RSA 是占主导地位的算法)用于生成*密钥对*:公共密钥及其配对的私有密钥。公钥是一种身份:[Amazon][15] 的公钥对其进行标识,而我的公钥对我进行标识。私钥应由其所有者负责保密。 + +成对出现的密钥具有标准用途。可以使用公钥对消息进行加密,然后可以使用同一个密钥对中的私钥对消息进行解密。私钥也可以用于对文档或其他电子工件(例如程序或电子邮件)进行签名,然后可以使用该对密钥中的公钥来验证签名。以下两个示例补充了一些细节。 + +在第一个示例中,Alice 将她的公钥分发给全世界,包括 Bob。然后,Bob 用 Alice 的公钥加密邮件,然后将加密的邮件发送给 Alice。用 Alice 的公钥加密的邮件将可以用她的私钥解密(假设是她自己的私钥),如下所示: + +``` + +------------------+ encrypted msg +-------------------+ +Bob's msg--->|Alice's public key|--------------->|Alice's private key|---> Bob's msg + +------------------+ +-------------------+ +``` + +理论上可以在没有 Alice 的私钥的情况下解密消息,但在实际情况中,如果使用像 RSA 这样的加密密钥对系统,则在计算上做不到。 + +现在,第二个示例,请对文档签名以证明其真实性。签名算法使用密钥对中的私钥来处理要签名的文档的加密哈希: + +``` + +-------------------+ +Hash of document--->|Alice's private key|--->Alice's digital signature of the document + +-------------------+ +``` + +假设 Alice 以数字方式签署了发送给 Bob 的合同。然后,Bob 可以使用 Alice 密钥对中的公钥来验证签名: + +``` + +------------------+ +Alice's digital signature of the document--->|Alice's public key|--->verified or not + +------------------+ +``` + +假若没有 Alice 的私钥,就无法轻松伪造 Alice 的签名:因此,Alice 有必要保密她的私钥。 + +在 `client` 程序中,除了数字证书以外,这些安全性都没有明确展示。下一篇文章使用使用 OpenSSL 实用程序和库函数的示例填充更多详细的信息。 + +### 命令行的 OpenSSL + +同时,让我们看一下 OpenSSL 命令行实用程序:特别是在 TLS 握手期间检查来自 Web 服务器的证书的实用程序。调用 OpenSSL 实用程序可以使用 `openssl` 命令,然后添加参数和标志的组合以指定所需的操作。 + +看看以下命令: + +``` +openssl list-cipher-algorithms +``` + +该输出是组成加密算法套件cipher suite的相关算法的列表。下面是列表的开头,加了澄清首字母缩写词的注释: + +``` +AES-128-CBC ## Advanced Encryption Standard, Cipher Block Chaining +AES-128-CBC-HMAC-SHA1 ## Hash-based Message Authentication Code with SHA1 hashes +AES-128-CBC-HMAC-SHA256 ## ditto, but SHA256 rather than SHA1 +... +``` + +下一条命令使用参数 `s_client` 将打开到 [www.google.com][13] 的安全连接,并在屏幕上显示有关此连接的所有信息: + +``` +openssl s_client -connect www.google.com:443 -showcerts +``` + +端口号 443 是 Web 服务器用于接收 HTTPS(而不是 HTTP 连接)的标准端口号。(对于 HTTP,标准端口为 80)Web 地址 www.google.com:443 也出现在 `client` 程序的代码中。如果尝试连接成功,则将显示来自 Google 的三个数字证书以及有关安全会话、正在使用的加密算法套件以及相关项目的信息。例如,这是开头的部分输出,它声明*证书链*即将到来。证书的编码为 base64: + + +``` +Certificate chain + 0 s:/C=US/ST=California/L=Mountain View/O=Google LLC/CN=www.google.com + i:/C=US/O=Google Trust Services/CN=Google Internet Authority G3 +-----BEGIN CERTIFICATE----- +MIIEijCCA3KgAwIBAgIQdCea9tmy/T6rK/dDD1isujANBgkqhkiG9w0BAQsFADBU +MQswCQYDVQQGEwJVUzEeMBwGA1UEChMVR29vZ2xlIFRydXN0IFNlcnZpY2VzMSUw +... +``` + +诸如 Google 之类的主要网站通常会发送多个证书进行身份验证。 + +输出以有关 TLS 会话的摘要信息结尾,包括加密算法套件的详细信息: + +``` +SSL-Session: +    Protocol : TLSv1.2 +    Cipher : ECDHE-RSA-AES128-GCM-SHA256 +    Session-ID: A2BBF0E4991E6BBBC318774EEE37CFCB23095CC7640FFC752448D07C7F438573 +... +``` + +`client` 程序中使用了协议 TLS 1.2,`Session-ID` 唯一地标识了 `openssl` 实用程序和 Google Web 服务器之间的连接。`Cipher` 条目可以按以下方式进行解析: + +* `ECDHE`(椭圆曲线 Diffie-Hellman(临时)Elliptic Curve Diffie Hellman Ephemeral)是一种用于管理 TLS 握手的高效的有效算法。尤其是,ECDHE 通过确保连接双方(例如,`client` 程序和 Google Web 服务器)使用相同的加密/解密密钥(称为*会话密钥*)来解决“密钥分发问题”。后续文章会深入探讨该细节。 +* `RSA`(Rivest Shamir Adleman)是主要的公共密钥密码系统,并以 1970 年代末首次描述了该系统的三位学者的名字命名。这个正在使用的密钥对是使用 RSA 算法生成的。 +* `AES128`(高级加密标准Advanced Encryption Standard)是一种块式加密算法block cipher,用于加密和解密位块blocks of bits。(另一种算法是流式加密算法stream cipher,它一次加密和解密一个位。)这个加密算法是对称加密算法,因为使用同一个密钥进行加密和解密,这首先引起了密钥分发问题。AES 支持 128(此处使用)、192 和 256 位的密钥大小:密钥越大,安全性越好。 + + 通常,像 AES 这样的对称加密系统的密钥大小要小于像 RSA 这样的非对称(基于密钥对)系统的密钥大小。例如,1024 位 RSA 密钥相对较小,而 256 位密钥则当前是 AES 最大的密钥。 +* `GCM`(伽罗瓦计数器模式Galois Counter Mode)处理在安全对话期间重复应用的加密算法(在这种情况下为 AES128)。AES128 块的大小仅为 128 位,安全对话很可能包含从一侧到另一侧的多个 AES128 块。GCM 非常有效,通常与 AES128 搭配使用。 +* `SHA256`(256 位安全哈希算法Secure Hash Algorithm 256 bits)是我们正在使用的加密哈希算法。生成的哈希值的大小为 256 位,尽管使用 SHA 甚至可以更大。 + +加密算法套件正在不断发展中。例如,不久前,Google 使用 RC4 流加密算法(RSA 的 Ron Rivest 后来开发的 Ron's Cipher 版本 4)。 RC4 现在有已知的漏洞,这大概部分导致了 Google 转换为 AES128。 + +### 总结 + +我们通过安全的 C Web 客户端和各种命令行示例对 OpenSSL 做了首次了解,使一些需要进一步阐明的主题脱颖而出。[下一篇文章会详细介绍][17],从加密散列开始,到对数字证书如何应对密钥分发挑战为结束的更全面讨论。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/cryptography-basics-openssl-part-1 + +作者:[Marty Kalin][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mkalindepauledu/users/akritiko/users/clhermansen +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_3reasons.png?itok=k6F3-BqA (A lock on the side of a building) +[2]: https://www.openssl.org/ +[3]: https://www.howtoforge.com/tutorial/how-to-install-openssl-from-source-on-linux/ +[4]: http://condor.depaul.edu/mkalin +[5]: https://en.wikipedia.org/wiki/Transport_Layer_Security +[6]: https://en.wikipedia.org/wiki/Netscape +[7]: http://www.opengroup.org/onlinepubs/009695399/functions/perror.html +[8]: http://www.opengroup.org/onlinepubs/009695399/functions/exit.html +[9]: http://www.opengroup.org/onlinepubs/009695399/functions/sprintf.html +[10]: http://www.opengroup.org/onlinepubs/009695399/functions/fprintf.html +[11]: http://www.opengroup.org/onlinepubs/009695399/functions/memset.html +[12]: http://www.opengroup.org/onlinepubs/009695399/functions/puts.html +[13]: http://www.google.com +[14]: https://www.verisign.com +[15]: https://www.amazon.com +[16]: http://www.google.com:443 +[17]: https://opensource.com/article/19/6/cryptography-basics-openssl-part-2 diff --git a/published/202001/20190724 How to make an old computer useful again.md b/published/202001/20190724 How to make an old computer useful again.md new file mode 100644 index 0000000000..726436a18a --- /dev/null +++ b/published/202001/20190724 How to make an old computer useful again.md @@ -0,0 +1,182 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11746-1.html) +[#]: subject: (How to make an old computer useful again) +[#]: via: (https://opensource.com/article/19/7/how-make-old-computer-useful-again) +[#]: author: (Howard Fosdick https://opensource.com/users/howtech) + +如何把你的老爷机重新利用起来 +====== + +> 按照下面各个步骤,让你的老爷机焕然一新。 + +![](https://img.linux.net.cn/data/attachment/album/202001/04/064017ztl28cn6jjhnjnaj.jpg) + +你的地下室里是不是有一台用来落灰的旧电脑?为什么不把它利用起来呢?如果你常用的电脑坏了,又想用一个比手机更大的屏幕上网,这时候一台备用电脑可能就派上用场了。或者,它也可以充当一台全家人共用的廉价备用电脑,甚至还可以改造为一台复古游戏机。 + +哪怕是一台有十余年历史的老爷机,只要选对了软件,也可以胜任很多新电脑能够完成的任务。其中的关键在于,要使用开源软件。 + +我进行电脑翻新已经有二十年了。在这篇文章里,我会分享一下电脑翻新的技巧。此处讨论的范围包括双核笔记本,以及机龄在 5 到 12 年之间的台式机。 + +### 检查硬件 + +第一步是检查硬件是否运转正常。如果在这个环节忽略了一个问题,后面可能会让你非常头疼。 + +灰尘是电子器件的天敌,所以第一件事应该是打开机箱,清除灰尘。[压缩空气设备][2]这时候可能会派上用场。请注意,进行任何接触电脑的操作时,都应该确保[接地][3]。此外,**不要**用清洁布擦拭任何东西。即使是一次小到你无法察觉的静电放电,也可能会导致电路损毁。 + +清洁工作完成之后,关闭机箱,检查是否所有硬件都可以正常工作。需要测试的项目包括: + +* 内存 +* 硬盘 +* 主板 +* 外围设备(DVD 驱动器、USB 接口、声卡,等等) + +首先,将计算机启动界面([UEFI][4] 或者是 [BIOS][5] 界面)上的诊断测试依次运行一遍。如果不知道按哪个功能键进入你电脑的启动界面,可以参考 [这份列表][6]。 + +此外,也可以使用诸如 [Hirens BootCD][7] 和 [Ultimate Boot CD][8] 之类的免费资源工具包,进行启动界面覆盖不到的测试。这些资源工具包涵盖了数百个测试程序,并且都是免费的,尽管不都开源。运行这些工具包无需安装任何软件,因为它们都是从 U 盘或者 DVD 驱动器启动的。 + +测试一定要彻底!对于内存和硬盘来说,基础测试还不够,应该运行深度测试,哪怕是运行一整夜也无妨。只有这样,才能够查出那些不易发现的瞬时故障。 + +如果发现了问题,可以参考我的[硬件故障排除快速指南][9],可以帮你解决最常见的硬件问题。 + +### 选择软件 + +电脑翻新的关键在于,根据手头的硬件资源,恰如其分地安装软件。最核心的三种硬件资源分别是: + +1. 处理器(内核数、速度) +2. 内存 +3. 显存 + +可以在启动时的 UEFI/BIOS 界面上,弄清楚你电脑的硬件资源。记得抄下数据,以免遗忘。接下来,可以在 [CPU Benchmark][10] 网站上查看你的处理器,该网站除了提供 CPU 的背景资料,还提供一个 CPU 的性能分数。 + +了解了硬件性能之后,就可以选择能够在硬件上高效运行的软件了。软件的选择涉及四个重要的层面: + +1. 操作系统(OS) +2. 桌面环境(DE) +3. 浏览器 +4. 应用 + +一个优秀的 Linux 发行版可以满足上述全部四个层面。不要试图使用已经停止维护的 Windows 版本,例如 Windows 8、Vista 或者 XP,哪怕已经安装在电脑上了。恶意软件的[风险][11]你是承受不起的。明智的做法是,使用一个更抗病毒的最新版本操作系统。 + +那 Windows 7 呢?[维护宽限期][12]至 2020 年 1 月 14 日结束,也就是说,在此日期之前你还可以获得安全补丁,之后就想都别想了。现在正是迁出 Windows 7 的绝佳时机。 + +Linux 的巨大优势在于,有许多专门为过时硬件设计的[发行版][13]。此外,[桌面环境][14]和操作系统在 Linux 的设计中是分开的,你可以自行选择搭配。这一点非常重要,因为桌面环境对低端系统的性能有很大影响。(对于 Windows 和 MacOS 来说,你选择的操作系统版本决定了桌面环境,没得可选。) + +Linux 的另一个好处是,拥有数以千计自由且开源的应用,不需要担心激活或者许可的问题。此外,Linux 是可移植的,可以在不同的分区、硬盘、设备或计算机之间,对操作系统和应用进行复制、移动或克隆。(Windows 则不然,使用注册表将系统捆绑在了所安装的计算机上。) + +### 翻新后的电脑能够做什么? + +这里讨论的是大约在 2006 年到 2013 年之间生产的双核计算机,尤其是装载了 [Intel 酷睿 2][15] CPU 或 [AMD 速龙 64 X2][16] 系列处理器的计算机。它们的 [CPU 分数][10] 大多在 1000 到 4000 分之间。这种电脑卖不了几个钱,但用在运行轻量级 Linux 软件上,性能还是足够的。 + +有一点需要注意:你的电脑应该至少拥有 2 GB 内存,如果不够就进行升级。就我翻新过的电脑来说,使用者用到的内存(不包括数据缓存)一般在 0.5 到 2 GB 之间,很少超过 2 GB。如果将内存升级到 2GB,系统就不至于进行**内存交换**,即将硬盘当做内存使用。如果想要获得良好性能,这一点十分关键。 + +以我自己为例,我用来写作这篇文章的是一台有十年机龄的翻新电脑。取下 1 GB 内存条之后,它只剩下了 1 GB 内存,然后就慢得像一只乌龟。用它浏览网页,或者是做类似的事情,都让人感到灰心,甚至痛苦。一旦把内存条重新装回去,有了 2 GB 内存,它就立马回到了可以使用的状态。 + +一台 2 GB 的双核计算机可以满足大多数人的需求,只要安装的是轻量级发行版和浏览器。你可以用它浏览网页、发送电子邮件、编辑文档和电子表格、观看 YouTube 视频、参与 eBay 拍卖竞标、在社交网络上发帖、听播客、查看相簿、管理家庭收支和个人日程、玩游戏,等等。 + +### 翻新电脑的局限 + +那么,这些老爷机又有什么局限呢?由于它们的并发性能比不上最先进的计算机,所以应该使用轻量级浏览器,同时拦截广告(广告正是让网页加载变慢的罪魁祸首)。如果可以使用虚拟专用网络(VPN)拦截广告,为处理器免除加载广告的负荷,那就再好不过。此外,还需要禁用视频自动播放、Flash 以及网页动画效果;将浏览器上的标签页控制在少数几个,不要同时打开 20 个;以及下载可以开启/禁用 JavaScript 的浏览器扩展。 + +让处理器专注于你目前正在做的事情吧,不要同时打开一堆应用,也不要在后台运行很多程序。图像编辑和视频编辑的高级工具可能会很慢;至于运行虚拟机,还是别想了吧。 + +那游戏呢?开源软件仓库提供了数以千计的游戏。这就是我为什么将显存列为三种核心硬件资源之一。如果你的电脑没有独立显卡,那很可能只有 32 或者 64 MB 的显存。可以增加一张显卡,将显存提升到 256 或者 512 MB,这样一来,处理器密集型的游戏就会顺畅很多了。如果不确定你的电脑有多少显存,可以参考[这里][17]。请注意,需要确保显卡与电脑的[显卡插槽][18](AGP、PCI-Express 或者 PCI)相匹配,同时使用正确的[连接线][19](VGA、DVI 或者 HDMI)。 + +#### 与 Windows 系统的兼容性如何? + +许多人关心 Linux 与 Windows 系统的兼容性如何。首先,对于任何一个 Windows 程序,都有一个 [Linux 版本的替代品][20]。 + +退一步说,即使你真的必须要运行某个特定的 Windows 程序,通常也可以借助 [Wine][21] 在 Linux 上运行。可以在 [Wine 数据库][22] 里查找一下你的应用,看看是否可以在 Wine 上运行,顺便学一些特殊安装技巧。[Winetricks][23] 和 [PlayOnLinux][24] 这两个辅助工具可以帮助你进行安装和配置。 + +Wine 的另一个优势是可以运行旧版本 Windows(例如 Vista、XP、ME/98/95 和 3.1)上的程序。我认识一个家伙,搭建了一台特别赞的游戏电脑,然后用来玩 XP 上的老游戏。借助 [DOSBox][26],你甚至还可以运行数以千计的[免费 DOS 程序][25]。但是有一点需要注意,如果 Windows 程序可以运行,那么 Windows [病毒][27]也同样可以。你需要保护 Linux 上的 Wine 环境,正如保护任何其他 Windows 环境一样。 + +对了,与 Microsoft Office 的兼容性又如何呢?我使用的是 LibreOffice,经常编辑并交换 Word 和 Excel 文件,完全没有问题。不过,你应该避免使用隐晦或者过于专业的功能。 + +### 如何选择发行版? + +假设选择了 Linux 作为操作系统,那么你还需要选择桌面环境、浏览器和各种应用。最简单的方法是,安装一个包含了你所需要的一切的发行版。 + +通过从 [live USB][28] U 盘或者 DVD 启动,你无需安装任何程序,就可以尝试不同的发行版。关于在 Linux 或 Windows 上创建可启动的 Linux 的方法,可以参考[这里][29]。 + +我进行电脑翻新的目的是做慈善,所以无法指望电脑使用者具备任何相应知识。我需要的发行版应该具有以下特性: + +* 用户友好 +* 具有轻量级界面 +* 自带各种轻量级应用 +* 拥有足够大的软件仓库 +* 历史表现良好 +* 拥有庞大的用户社区和活跃的论坛 +* 通过长期维护版本(而不是滚动发布版本)确保稳定性 +* 更重视可靠性,而不是尖端功能 +* 可以通过图形化用户界面进行设置,而不是只能通过文本文件进行设置 + +许多发行版都能够满足上面的要求。我曾经尝试成功的有 [Mint/Xfce][30]、[Xubuntu][31] 和 [Lubuntu][32]。前两个发行版使用 Xfce 桌面环境,第三个使用 LXQt。相比 GNOME、Unity、KDE、MATE 和 Cinnamon 这些桌面环境,运行上面这两种桌面环境只需要[更少][33]的处理器和内存资源。 + +Xfce 和 LXQt 用起来非常简单,我的客户们之前从未见过 Linux,但是都可以自如使用这些简单的、菜单驱动的用户界面。 + +对于旧电脑来说,运行最快速、最高效的浏览器是一件非常重要的事情。[很多人觉得][34] Chromium 是最好的浏览器;此外,我还安装了 Firefox Quantum,因为大家比较熟悉它,并且[它的性能][35]可以和 [Chromium 的性能][36]媲美。我还加上了 Opera,因为它速度快,而且有一些独特功能,比如内置的广告拦截,以及免费的[虚拟专用网络][37]。Opera 是免费的,但并非开源。 + +无论你使用什么浏览器,一定要拦截广告和追踪器,尽量降低浏览器的负荷。此外,除非得到你的明确批准,否则视频和 Flash 都不应该被允许运行。 + +至于应用,我使用的是 Mint/Xfce、Xubuntu 和 Lubuntu 自带的轻量级应用。它们足以满足一切需求了。 + +### 行动起来吧 + +你是否会对翻新后的电脑感到满意呢?就我来说,我所使用的两台电脑的机龄都已经超过十年了,其中一个装载的是 Intel 双核处理器([eMachines T5274a][38]),另一个装载的是 AMD 速龙 64 x2 处理器([HP dc5750][39]),两台电脑都有 2 GB 内存。它们和我的另一台具备四核 i5 处理器和 16 GB 内存的电脑一样,完全能够胜任我的办公工作。如果说有什么功能是这两台电脑缺失的,那就是运行虚拟机了。 + +我们生活在一个非常神奇的年代。只需要付出一点努力,就可以将一台机龄在 5 到 12 年之间的旧电脑,翻新为一台具备实用价值的机器。还有什么比这更有趣吗? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/how-make-old-computer-useful-again + +作者:[Howard Fosdick][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/howtech +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/1980s-computer-yearbook.png?itok=eGOYEKK- (Person typing on a 1980's computer) +[2]: https://www.amazon.com/s/ref=nb_sb_noss_1?url=search-alias%3Daps&field-keywords=compressed+air+for+computers&rh=i%3Aaps%2Ck%3Acompressed+air+for+computers +[3]: https://www.wikihow.com/Ground-Yourself-to-Avoid-Destroying-a-Computer-with-Electrostatic-Discharge +[4]: https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface +[5]: http://en.wikipedia.org/wiki/BIOS +[6]: http://www.disk-image.com/faq-bootmenu.htm +[7]: http://www.hirensbootcd.org/download/ +[8]: http://www.ultimatebootcd.com/ +[9]: http://www.rexxinfo.org/Quick_Guide/Quick_Guide_To_Fixing_Computer_Hardware +[10]: http://www.cpubenchmark.net/ +[11]: https://askleo.com/unsupported-software-really-mean/ +[12]: http://home.bt.com/tech-gadgets/computing/windows-7/windows-7-support-end-11364081315419 +[13]: https://fossbytes.com/best-lightweight-linux-distros/ +[14]: http://en.wikipedia.org/wiki/Desktop_environment +[15]: https://en.wikipedia.org/wiki/Intel_Core_2 +[16]: https://en.wikipedia.org/wiki/Athlon_64_X2 +[17]: http://www.cyberciti.biz/faq/howto-find-linux-vga-video-card-ram/ +[18]: https://www.onlinecomputertips.com/support-categories/hardware/493-pci-vs-agp-vs-pci-express-video-cards/ +[19]: https://silentpc.com/articles/video-connectors +[20]: http://wiki.linuxquestions.org/wiki/Linux_software_equivalent_to_Windows_software +[21]: https://en.wikipedia.org/wiki/Wine_%28software%29 +[22]: https://appdb.winehq.org/ +[23]: https://en.wikipedia.org/wiki/Winetricks +[24]: https://en.wikipedia.org/wiki/PlayOnLinux +[25]: https://archive.org/details/softwarelibrary_msdos +[26]: https://en.wikipedia.org/wiki/DOSBox +[27]: https://wiki.winehq.org/FAQ#Is_Wine_malware-compatible.3F +[28]: https://www.howtogeek.com/howto/linux/create-a-bootable-ubuntu-usb-flash-drive-the-easy-way/ +[29]: https://unetbootin.github.io/ +[30]: https://linuxmint.com/ +[31]: https://xubuntu.org/ +[32]: https://lubuntu.me/ +[33]: https://www.makeuseof.com/tag/best-lean-linux-desktop-environment-lxde-vs-xfce-vs-mate/ +[34]: https://www.zdnet.com/article/chrome-is-the-most-popular-web-browser-of-all/ +[35]: https://www.laptopmag.com/articles/firefox-quantum-vs-chrome +[36]: https://www.zdnet.com/article/just-how-fast-is-firefox-quantum/ +[37]: http://en.wikipedia.org/wiki/Virtual_private_network +[38]: https://www.cnet.com/products/emachines-t5274/specs/ +[39]: https://community.spiceworks.com/products/7727-hewlett-packard-dc5750-microtower diff --git a/published/202001/20190924 An advanced look at Python interfaces using zope.interface.md b/published/202001/20190924 An advanced look at Python interfaces using zope.interface.md new file mode 100644 index 0000000000..f2918057fc --- /dev/null +++ b/published/202001/20190924 An advanced look at Python interfaces using zope.interface.md @@ -0,0 +1,127 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11752-1.html) +[#]: subject: (An advanced look at Python interfaces using zope.interface) +[#]: via: (https://opensource.com/article/19/9/zopeinterface-python-package) +[#]: author: (Moshe Zadka https://opensource.com/users/moshezhttps://opensource.com/users/lauren-pritchetthttps://opensource.com/users/sethhttps://opensource.com/users/drmjg) + +借助 zope.interface 深入了解 Python 接口 +====== + +> Zope.interface 可以帮助声明存在哪些接口,是由哪些对象提供的,以及如何查询这些信息。 + +![Snake charmer cartoon with a yellow snake and a blue snake][1] + +`zope.interface` 库可以克服 Python 接口设计中的歧义性。让我们来研究一下。 + +### 隐式接口不是 Python 之禅 + +[Python 之禅][2] 很宽松,但是有点自相矛盾,以至于你可以用它来例证任何东西。让我们来思考其中最著名的原则之一:“显示胜于隐式”。 + +传统上,在 Python 中会隐含的一件事是预期的接口。比如函数已经记录了它期望一个“类文件对象”或“序列”。但是什么是类文件对象呢?它支持 `.writelines`吗?`.seek` 呢?什么是一个“序列”?是否支持步进切片,例如 `a[1:10:2]`? + +最初,Python 的答案是所谓的“鸭子类型”,取自短语“如果它像鸭子一样行走,像鸭子一样嘎嘎叫,那么它可能就是鸭子”。换句话说,“试试看”,这可能是你能得到的最具隐式的表达。 + +为了使这些内容显式地表达出来,你需要一种方法来表达期望的接口。[Zope][3] Web 框架是最早用 Python 编写的大型系统之一,它迫切需要这些东西来使代码明确呈现出来,例如,期望从“类似用户的对象”获得什么。 + +`zope.interface` 由 Zope 开发,但作为单独的 Python 包发布。`Zope.interface` 可以帮助声明存在哪些接口,是由哪些对象提供的,以及如何查询这些信息。 + +想象编写一个简单的 2D 游戏,它需要各种东西来支持精灵界面(LCTT 译注:“精灵 Sprite”是指游戏面板中各个组件)。例如,表示一个边界框,但也要表示对象何时与一个框相交。与一些其他语言不同,在 Python 中,将属性访问作为公共接口一部分是一种常见的做法,而不是实现 getter 和 setter。边界框应该是一个属性,而不是一个方法。 + +呈现精灵列表的方法可能类似于: + +``` +def render_sprites(render_surface, sprites): +    """ +    sprites 应该是符合 Sprite 接口的对象列表: +    * 一个名为 "bounding_box" 的属性,包含了边界框 +    * 一个名为 "intersects" 的方法,它接受一个边界框并返回 True 或 False +    """ +    pass # 一些做实际渲染的代码 +``` + +该游戏将具有许多处理精灵的函数。在每个函数中,你都必须在随附文档中指定预期。 + +此外,某些函数可能期望使用更复杂的精灵对象,例如具有 Z 序的对象。我们必须跟踪哪些方法需要 Sprite 对象,哪些方法需要 SpriteWithZ 对象。 + +如果能够使精灵是显式而直观的,这样方法就可以声明“我需要一个精灵”,并有个严格定义的接口,这不是很好吗?来看看 `zope.interface`。 + +``` +from zope import interface + +class ISprite(interface.Interface): + +    bounding_box = interface.Attribute( +        "边界框" +    ) + +    def intersects(box): +        "它和一个框相交吗?" +``` + +乍看起来,这段代码有点奇怪。这些方法不包括 `self`,而包含 `self` 是一种常见的做法,并且它有一个**属性**。这是在 `zope.interface` 中声明接口的方法。这看起来很奇怪,因为大多数人不习惯严格声明接口。 + +这样做的原因是接口显示了如何调用方法,而不是如何定义方法。因为接口不是超类,所以它们可以用来声明数据属性。 + +下面是一个能带有圆形精灵的接口的一个实现: + +``` +@implementer(ISprite) +@attr.s(auto_attribs=True) +class CircleSprite: +    x: float +    y: float +    radius: float + +    @property +    def bounding_box(self): +        return ( +            self.x - self.radius, +            self.y - self.radius, +            self.x + self.radius, +            self.y + self.radius, +        ) + +    def intersects(self, box): +        # 当且仅当至少一个角在圆内时,方框与圆相交 +        top_left, bottom_right = box[:2], box[2:] +        for choose_x_from (top_left, bottom_right): +            for choose_y_from (top_left, bottom_right): +                x = choose_x_from[0] +                y = choose_y_from[1] +                if (((x - self.x) ` 2 + (y - self.y) ` 2) <= +                    self.radius ` 2): +                     return True +        return False +``` + +这**显式**声明了实现了该接口的 `CircleSprite` 类。它甚至能让我们验证该类是否正确实现了接口: + +``` +from zope.interface import verify + +def test_implementation(): +    sprite = CircleSprite(x=0, y=0, radius=1) +    verify.verifyObject(ISprite, sprite) +``` + +这可以由 pytest、nose 或其他测试框架运行,它将验证创建的精灵是否符合接口。测试通常是局部的:它不会测试仅在文档中提及的内容,甚至不会测试方法是否可以在没有异常的情况下被调用!但是,它会检查是否存在正确的方法和属性。这是对单元测试套件一个很好的补充,至少可以防止简单的拼写错误通过测试。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/9/zopeinterface-python-package + +作者:[Moshe Zadka][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/moshezhttps://opensource.com/users/lauren-pritchetthttps://opensource.com/users/sethhttps://opensource.com/users/drmjg +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/getting_started_with_python.png?itok=MFEKm3gl (Snake charmer cartoon with a yellow snake and a blue snake) +[2]: https://en.wikipedia.org/wiki/Zen_of_Python +[3]: http://zope.org diff --git a/published/202001/20190930 How the Linux screen tool can save your tasks - and your sanity - if SSH is interrupted.md b/published/202001/20190930 How the Linux screen tool can save your tasks - and your sanity - if SSH is interrupted.md new file mode 100644 index 0000000000..f52dbd55f6 --- /dev/null +++ b/published/202001/20190930 How the Linux screen tool can save your tasks - and your sanity - if SSH is interrupted.md @@ -0,0 +1,107 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11822-1.html) +[#]: subject: (How the Linux screen tool can save your tasks – and your sanity – if SSH is interrupted) +[#]: via: (https://www.networkworld.com/article/3441777/how-the-linux-screen-tool-can-save-your-tasks-and-your-sanity-if-ssh-is-interrupted.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +如果 SSH 被中断,Linux screen 工具如何拯救你的任务以及理智 +====== + +> 当你需要确保长时间运行的任务不会在 SSH 会话中断时被杀死时,Linux screen 命令可以成为救生员。以下是使用方法。 + +![](https://images.idgesg.net/images/article/2019/09/working_w_screen-shs-100812448-large.jpg) + +如果因 SSH 会话断开而不得不重启一个耗时的进程,那么你可能会很高兴了解一个有趣的工具,可以用来避免此问题:`screen` 工具。 + +`screen` 是一个终端多路复用器,它使你可以在单个 SSH 会话中运行多个终端会话,并随时从它们之中脱离或重新接驳。做到这一点的过程非常简单,仅涉及少数命令。 + +要启动 `screen` 会话,只需在 SSH 会话中键入 `screen`。 然后,你可以开始启动需要长时间运行的进程,并在适当的时候键入 `Ctrl + A Ctrl + D` 从会话中脱离,然后键入 `screen -r` 重新接驳。 + +如果你要运行多个 `screen` 会话,更好的选择是为每个会话指定一个有意义的名称,以帮助你记住正在处理的任务。使用这种方法,你可以在启动每个会话时使用如下命令命名: + +``` +$ screen -S slow-build +``` + +一旦运行了多个会话,要重新接驳到一个会话,需要从列表中选择它。在以下命令中,我们列出了当前正在运行的会话,然后再重新接驳其中一个。请注意,一开始这两个会话都被标记为已脱离。 + +``` +$ screen -ls +There are screens on: + 6617.check-backups (09/26/2019 04:35:30 PM) (Detached) + 1946.slow-build (09/26/2019 02:51:50 PM) (Detached) +2 Sockets in /run/screen/S-shs +``` + +然后,重新接驳到该会话要求你提供分配给会话的名称。例如: + +``` +$ screen -r slow-build +``` + +在脱离的会话中,保持运行状态的进程会继续进行处理,而你可以执行其他工作。如果你使用这些 `screen` 会话之一来查询 `screen` 会话情况,可以看到当前重新接驳的会话再次显示为 `Attached`。 + +``` +$ screen -ls +There are screens on: + 6617.check-backups (09/26/2019 04:35:30 PM) (Attached) + 1946.slow-build (09/26/2019 02:51:50 PM) (Detached) +2 Sockets in /run/screen/S-shs. +``` + +你可以使用 `-version` 选项查询正在运行的 `screen` 版本。 + +``` +$ screen -version +Screen version 4.06.02 (GNU) 23-Oct-17 +``` + +### 安装 screen + +如果 `which screen` 未在屏幕上提供信息,则可能你的系统上未安装该工具。 + +``` +$ which screen +/usr/bin/screen +``` + +如果你需要安装它,则以下命令之一可能适合你的系统: + +``` +sudo apt install screen +sudo yum install screen +``` + +当你需要运行耗时的进程时,如果你的 SSH 会话由于某种原因断开连接,则可能会中断这个耗时的进程,那么 `screen` 工具就会派上用场。而且,如你所见,它非常易于使用和管理。 + +以下是上面使用的命令的摘要: + +``` +screen -S 开始会话 +Ctrl+A Ctrl+D 从会话中脱离 +screen -ls 列出会话 +screen -r 重新接驳会话 +``` + +尽管还有更多关于 `screen` 的知识,包括可以在 `screen` 会话之间进行操作的其他方式,但这已经足够帮助你开始使用这个便捷的工具了。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3441777/how-the-linux-screen-tool-can-save-your-tasks-and-your-sanity-if-ssh-is-interrupted.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/202001/20191015 How GNOME uses Git.md b/published/202001/20191015 How GNOME uses Git.md new file mode 100644 index 0000000000..d39600f1ef --- /dev/null +++ b/published/202001/20191015 How GNOME uses Git.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11806-1.html) +[#]: subject: (How GNOME uses Git) +[#]: via: (https://opensource.com/article/19/10/how-gnome-uses-git) +[#]: author: (Molly de Blanc https://opensource.com/users/mollydb) + +一个非技术人员对 GNOME 项目使用 GitLab 的感受 +====== + +> 将 GNOME 项目集中在 GitLab 上的决定为整个社区(不只是开发人员)带来了好处。 + +![red panda][1] + +“您的 GitLab 是什么?”这是我在 [GNOME 基金会][2]工作的第一天被问到的第一个问题之一,该基金会是支持 GNOME 项目(包括[桌面环境][3]、[GTK][4] 和 [GStreamer][5])的非盈利组织。此人问的是我在 [GNOME 的 GitLab 实例][6]上的用户名。我在 GNOME 期间,经常有人要求我提供我的 GitLab。 + +我们使用 GitLab 进行几乎所有操作。通常情况下,我会收到一些提案issue和参考错误报告,有时还需要修改文件。我不是以开发人员或系统管理员的身份进行此操作的。我参与了“参与度、包容性和多样性(I&D)”团队。我为 GNOME 朋友们撰写新闻通讯,并采访该项目的贡献者。我为 GNOME 活动提供赞助。我不写代码,但我每天都使用 GitLab。 + +在过去的二十年中,GNOME 项目的管理采用了各种方式。该项目的不同部分使用不同的系统来跟踪代码更改、协作以及作为项目和社交空间共享信息。但是,该项目决定,它需要更加地一体化,这从构思到完成大约花费了一年的时间。 + +GNOME 希望切换到单个工具供整个社区使用的原因很多。外部项目与 GNOME 息息相关,并为它们提供更简单的与资源交互的方式对于项目至关重要,无论是支持社区还是发展生态系统。我们还希望更好地跟踪 GNOME 的指标,即贡献者的数量、贡献的类型和数量以及项目不同部分的开发进度。 + +当需要选择一种协作工具时,我们考虑了我们需要的东西。最重要的要求之一是它必须由 GNOME 社区托管。由第三方托管并不是一种选择,因此像 GitHub 和 Atlassian 这样的服务就不在考虑之中。而且,当然了,它必须是自由软件。很快,唯一真正的竞争者出现了,它就是 GitLab。我们希望确保进行贡献很容易。GitLab 具有诸如单点登录的功能,该功能允许人们使用 GitHub、Google、GitLab.com 和 GNOME 帐户登录。 + +我们认为 GitLab 是一条出路,我们开始从许多工具迁移到单个工具。GNOME 董事会成员 [Carlos Soriano][7] 领导这项改变。在 GitLab 和 GNOME 社区的大力支持下,我们于 2018 年 5 月完成了该过程。 + +人们非常希望迁移到 GitLab 有助于社区的发展,并使贡献更加容易。由于 GNOME 以前使用了许多不同的工具,包括 Bugzilla 和 CGit,因此很难定量地评估这次切换对贡献量的影响。但是,我们可以更清楚地跟踪一些统计数据,例如在 2018 年 6 月至 2018 年 11 月之间关闭了近 10,000 个提案,合并了 7,085 个合并请求。人们感到社区在发展壮大,越来越受欢迎,而且贡献实际上也更加容易。 + +人们因不同的原因而开始使用自由软件,重要的是,可以通过为需要软件的人提供更好的资源和更多的支持来公平竞争。Git 作为一种工具已被广泛使用,并且越来越多的人使用这些技能来参与到自由软件当中。自托管的 GitLab 提供了将 Git 的熟悉度与 GitLab 提供的功能丰富、用户友好的环境相结合的绝佳机会。 + +切换到 GitLab 已经一年多了,变化确实很明显。持续集成(CI)为开发带来了巨大的好处,并且已经完全集成到 GNOME 的几乎每个部分当中。不进行代码开发的团队也转而使用 GitLab 生态系统进行工作。无论是使用问题跟踪来管理分配的任务,还是使用版本控制来共享和管理资产,就连“参与度、包容性和多样性(I&D)”这样的团队都已经使用了 GitLab。 + +一个社区,即使是一个正在开发的自由软件,也很难适应新技术或新工具。在类似 GNOME 的情况下,这尤其困难,该项目[最近已经 22 岁了] [8]。像 GNOME 这样经过了 20 多年建设的项目,太多的人和组织使用了太多的部件,但迁移工作之所以能实现,这要归功于 GNOME 社区的辛勤工作和 GitLab 的慷慨帮助。 + +在为使用 Git 进行版本控制的项目工作时,我发现很方便。这是一个令人感觉舒适和熟悉的系统,是一个在工作场所和爱好项目之间保持一致的工具。作为 GNOME 社区的新成员,能够参与并使用 GitLab 真是太好了。作为社区建设者,看到这样结果是令人鼓舞的:越来越多的相关项目加入并进入生态系统;新的贡献者和社区成员对该项目做出了首次贡献;以及增强了衡量我们正在做的工作以了解其成功和成功的能力。 + +如此多的做着完全不同的事情(例如他们正在从事的不同工作以及所使用的不同技能)的团队同意汇集在一个工具上(尤其是被认为是跨开源的标准工具),这一点很棒。作为 GNOME 的贡献者,我真的非常感谢我们使用了 GitLab。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/how-gnome-uses-git + +作者:[Molly de Blanc][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/mollydb +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/redpanda_firefox_pet_animal.jpg?itok=aSpKsyna (red panda) +[2]: https://www.gnome.org/foundation/ +[3]: https://gnome.org/ +[4]: https://www.gtk.org/ +[5]: https://gstreamer.freedesktop.org/ +[6]: https://gitlab.gnome.org/ +[7]: https://twitter.com/csoriano1618?lang=en +[8]: https://opensource.com/article/19/8/poll-favorite-gnome-version diff --git a/published/202001/20191016 Open source interior design with Sweet Home 3D.md b/published/202001/20191016 Open source interior design with Sweet Home 3D.md new file mode 100644 index 0000000000..814f0bdb23 --- /dev/null +++ b/published/202001/20191016 Open source interior design with Sweet Home 3D.md @@ -0,0 +1,137 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11774-1.html) +[#]: subject: (Open source interior design with Sweet Home 3D) +[#]: via: (https://opensource.com/article/19/10/interior-design-sweet-home-3d) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Sweet Home 3D 开放源码室内设计 +====== + +> 在你去真实世界购物前,在虚拟世界中尝试家具布局、配色方案等等。 + +![](https://img.linux.net.cn/data/attachment/album/202001/12/092633eyc3c9f7u3gfgj4e.jpg) + +这里有关于如何装饰房间的三大流派: + +1. 购买一堆家具,并把它们塞进房间。 +2. 仔细测量每件家具,计算房间的理论容量,然后把它们全部塞进房间,忽略你在床上放置一个书架的事实。 +3. 使用一台计算机进行预先可视化。 + +之前,我还实践了鲜为人知的第四个方式:不要家具。然而,自从我成为一个远程工作者,我发现家庭办公需要一些便利的设施,像一张桌子和一张椅子,一个用于存放参考书和技术手册的书架等等。因此,我一直在制定一个使用实际的家具来迁移我的生活和工作空间的计划,在该*计划*上强调由实木制作,而不是牛奶箱子(或胶水和锯末板之类的东西)。我最不想做的一件事:从旧货市场淘到得宝贝带回家时,发现其进不了门,或者比另一件家具大很多。 + +是时候做专业人士该做的事了,是时候做视觉预览了。 + +### 开放源码室内设计 + +[Sweet Home 3D][2] 是一个开源的(GPLv2)室内设计应用程序,可以帮助你绘制你的住宅平面图,然后定义、重新调整大小以及安排家具。你可以使用精确的尺寸来完成这些,精确到一厘米以下,而不使用任何数学运算,仅使用简单的拖拽操作就行。当你完成后,你可以以 3D 方式查看结果。在 Sweet Home 3D 中规划你家的室内设计,就和在 Word 程序中创建基本的表格一样简单。 + +### 安装 + +Sweet Home 3D 是一个 [Java][3] 应用程序,因此它是平台通用的。它运行在任何可以运行 Java 的操作系统上,包括 Linux、Windows、MacOS 和 BSD 。不用理会你的操作系统,你可以从网站[下载][4]该应用程序。 + +* 在 Linux 上,[untar][5] 存档文件。在 `SweetHome3D` 文件上右键单击,并选择**属性**。在**权限**选项卡中,授予文件可执行权限。 +* 在 MacOS 和 Windows 上,展开存档文件并启动应用程序。当系统提示时,你必需授予它权限来在你的系统上运行。 + +![Sweet Home 3D permissions][6] + +在 Linux 上,你也可以像一个 Snap 软件包一样安装 Sweet Home 3D ,前提是你已经安装并启用 **snapd**。 + +### 成功的测量 + +首先:打开你的卷尺。为充分利用 Sweet Home 3D,你必须知道你所计划的生活空间的实际尺寸。你可能需要测量精度到毫米或 1/16 英寸;你可以自己把握对偏差幅度的容忍度。但是你必需获得基本的尺寸,包括测量墙壁和门窗。 + +用你最好的判断力来判断常识。例如,当测量门时,包括门框;虽然从技术上讲它不是*门*本身的一部分,但它可能是你不想用家具遮挡的一部分墙壁空间。 + +![Measure twice, execute once][7] + +### 创建一间房间 + +当你第一次启动 Sweet Home 3D 时,它会以其默认查看模式来打开一个空白的画布,蓝图视图在顶部面板中,3D 渲染在底部面板中。在我的 [Slackware][8] 桌面计算机上,它可以很好地工作,不过我的桌面计算机也是我的视频编辑和游戏计算机,所以它有一个极好的 3D 渲染显卡。在我的笔记本计算机上,这种视图模式是非常慢的。为了最好的性能(尤其是在一台计没有 3D 渲染的专用计算机上),转到窗口顶部的 **3D 视图** 菜单,并选择 **虚拟访问** 。这个视图模式基于虚拟访客的位置从地面视图渲染你的工作。这意味着你可以控制渲染的内容和时机。 + +不管你计算机是否强力,切换到这个视图的有意义的,因为地表以上的 3D 渲染不比蓝图平面图向你提供更多有用的详细信息。在你更改视图模式后,你可以开始设计。 + +第一步是定义你家的墙壁。使用**创建墙壁**工具完成,可以在顶部工具栏的**手形**图标右侧找到。绘制墙壁很简单:单击你想要墙壁开始的位置,单击以锚定位置,不断单击锚定,直到你的房间完成。 + +![Drawing walls in Sweet Home 3D][9] + +在你闭合墙壁后,按 `Esc` 来退出工具。 + +#### 定义一间房间 + +Sweet Home 3D 在你如何创建墙壁的问题上是灵活的。你可以先绘制你房子的外部边界,然后再细分内部,或者你可以绘制每个房间作为结成一体的“容器”,最终形成你房子所占的空间量。这种灵活性是能做到的,因为在现实生活中和在 Sweet Home 3D 中,墙壁并不总是用来定义一间房间。为定义一间房间,使用在顶部工具栏的**创建墙壁**按钮右侧的**创建房间**按钮。 + +如果房间的地板空间是通过四面墙所定义,你需要做的全部的定义是像一间房间一样在四面墙壁内双击来圈占地方。Sweet Home 3D 将定义该空间为一间房间,并根据你的喜好,以英尺或米为单位向你提供房间的面积。 + +对于不规则的房间,你必需使用每次单击来手动定义房间的每个墙角。根据房间形状的复杂性,你可能不得不进行试验来发现你是否需要从你的原点来顺时针或逆时针工作,以避免奇怪的莫比斯条形地板。不过,一般来说,定义一间房间的地板空间是简单的。 + +![Defining rooms in Sweet Home 3D][10] + +在你给定房间一层地板后,你可以更改到**箭头**工具,并在房间上双击来给予它一个名称。你也可以设置地板、墙壁、天花板和踢脚线的颜色及纹理。 + +![Modifying room floors, ceilings, etc. in Sweet Home 3D][11] + +默认情况下,这些都不会在蓝图视图中渲染。为启用在你蓝图面板中的房间渲染,转到**文件**菜单并选择**首选项**。在**首选项**面板中,设置**平面图中房间渲染**为**地板颜色或纹理**。 + +### 门和窗 + +在你完成基本的地板平面图后,你可以长期地切换到**箭头**工具。 + +你可以在 Sweet Home 3D 的左栏中的**门和窗**类别下找到门和窗。你有很多选择,所以选择最接近你家的东西。 + +![Moving a door in Sweet Home 3D][12] + +为放置一扇门或窗到你的平面图中,在你的蓝图平面图中的合适的墙壁上拖拽门或窗。要调整它的位置和大小,请双击门或窗。 + +### 添加家具 + +随着基本平面图完成,这部分工作感觉像是结束了!从这点继续,你可以摆弄家具布置以及其它装饰。 + +你可以在左栏中找到家具,按预期的方式来组织每个房间。你可以拖拽任何项目到你的蓝图平面图中,当你的鼠标悬停在项目的区域上时,使用可视化工具控制方向和大小。在任何项目上双击双击来调整它的颜色和成品表面。 + +### 查看和导出 + +为了看看你未来的家将会看起来是什么样子,在你的蓝图视图中拖拽“人”图标到一个房间中。 + +![Sweet Home 3D rendering][13] + +你可以在现实和空间感受之间找到自己的平衡,你的想象力是你唯一的限制。你可以从 Sweet Home 3D [下载页面][4]获取附加的有用的资源来添加到你的家中。你甚至可以使用**库编辑器**应用程序创建你自己的家具和纹理,它可以从该项目的网站下载。 + +Sweet Home 3D 可以导出你的蓝图平面图为 SVG 格式,以便在 [Inkscape][14] 中使用,并且它可以导出你的 3D 模型为 OBJ 格式,以便在 [Blender][15] 中使用。为导出你的蓝图,转到**平面图**菜单,并选择**导出为 SVG 格式**。为导出一个 3D 模型,转到 **3D 视图** 菜单并选择**导出为 OBJ 格式**。 + +你也可以拍摄你家的"快照,以便于不打开 Sweet Home 3D 而回顾你的想法。为创建一个快照,转到 **3D 视图**菜单并选择**创建照片**。快照是按照蓝图视图中的人的图标的角度展现的,因此按照需要调整,然后在**创建照片**窗口中单击**创建**按钮。如果你对快照满意,单击**保存**。 + +### 甜蜜的家 + +在 Sweet Home 3D 中有更多的特色。你可以添加一片天空和一片草坪,为你的照片定位光线,设置天花板高度,给你房子添加另一楼层等等。不管你是打算租一套公寓,还是买一套房子,或是(尚)不存在的房子,Sweet Home 3D 是一款简单迷人的应用程序,当你匆忙购买家具时,它可以帮助你快乐地做出更好的购买选择。因此,你终于可以停止在厨房的柜台上吃早餐以及蹲在地上工作了。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/interior-design-sweet-home-3d + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LIFE_housing.png?itok=s7i6pQL1 (Several houses) +[2]: http://www.sweethome3d.com/ +[3]: https://opensource.com/resources/java +[4]: http://www.sweethome3d.com/download.jsp +[5]: https://opensource.com/article/17/7/how-unzip-targz-file +[6]: https://opensource.com/sites/default/files/uploads/sweethome3d-permissions.png (Sweet Home 3D permissions) +[7]: https://opensource.com/sites/default/files/images/life/sweethome3d-measure.jpg (Measure twice, execute once) +[8]: http://www.slackware.com/ +[9]: https://opensource.com/sites/default/files/uploads/sweethome3d-walls.jpg (Drawing walls in Sweet Home 3D) +[10]: https://opensource.com/sites/default/files/uploads/sweethome3d-rooms.jpg (Defining rooms in Sweet Home 3D) +[11]: https://opensource.com/sites/default/files/uploads/sweethome3d-rooms-modify.jpg (Modifying room floors, ceilings, etc. in Sweet Home 3D) +[12]: https://opensource.com/sites/default/files/uploads/sweethome3d-move.jpg (Moving a door in Sweet Home 3D) +[13]: https://opensource.com/sites/default/files/uploads/sweethome3d-view.jpg (Sweet Home 3D rendering) +[14]: http://inkscape.org +[15]: http://blender.org diff --git a/published/202001/20191017 Intro to the Linux useradd command.md b/published/202001/20191017 Intro to the Linux useradd command.md new file mode 100644 index 0000000000..d088a1d16d --- /dev/null +++ b/published/202001/20191017 Intro to the Linux useradd command.md @@ -0,0 +1,204 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11756-1.html) +[#]: subject: (Intro to the Linux useradd command) +[#]: via: (https://opensource.com/article/19/10/linux-useradd-command) +[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss) + +Linux useradd 命令介绍 +====== + +> 使用 useradd 命令来添加用户(并且根据需要修改账号)。 + +![](https://img.linux.net.cn/data/attachment/album/202001/06/225733hv1u7f4z4vbt8u5x.jpg) + +任何计算机系统中,添加用户都是最重要的事之一;本文着重介绍如何在 Linux 系统中添加用户。 + +正式开始之前,我先提三个概念。首先,跟大多数操作系统一样,Linux 用户也需要一个账号才能登录。本文只介绍本地账号,不涉及网络账号,如 LDAP。其次,每个账号都有一个名字(username)和一个对应的数字(用户 ID)。最后,每个用户通常都在一个组内,每个组都有一个名字和一个组 ID。 + +你可能已经想到了,Linux 提供了添加用户的命令行工具,就是 `useradd` 命令。有些版本也叫 `adduser`。为了方便使用,很多发行版上这个命令是一个指向 `useradd` 命令的符号链接。 + +``` +$ file `which adduser` +/usr/sbin/adduser: symbolic link to useradd +``` + +来看一下 `useradd`。 + +> 注意:本文描述的默认环境是 Red Hat Enterprise Linux 8.0。你可能会发现本文描述的这些文件和某些默认值与某些 Linux 发行版或其他 Unix 操作系统(FreeBSD 或 Solaris)偶尔会有差异。 + +### 默认处理 + +`useradd` 的基本用法相当简单:提供一个用户名就可以添加一个用户。 + +```bash +$ sudo useradd sonny +``` + +在本例中,`useradd` 命令创建了一个名为 `sonny` 的账号。此命令同时创建了一个同名的组,`sonny` 被放进了这个组,这个组也是 `sonny` 账号的主组。命令执行时,根据配置文件 `/etc/default/useradd` 和 `/etc/login.defs` 中的不同设置,也会有其他的参数,如语言和 shell。对于一个私人系统或微小的单服务商业环境,这些参数已经足够了。 + +上面两个文件控制 `useradd` 的处理,用户的信息保存在 `/etc` 目录下的一些其他文件中,关于这些信息的讲解会贯穿全文。 + +| 文件 | 描述 | 域 (加粗的表示由 useradd 命令设置) | +| ------ | ------------------------------------ | ------------------------------------------------------------ | +| `passwd` | 存储用户账号信息 | **用户名**:未使用:**UID**:**GID**:**备注**:**家目录**:**shell** | +| `shadow` | 存储用户账号的安全信息 | **用户名**:加密密码:上次修改时间:最短使用天数:最长使用天数间:**修改前警示天数**:**过期后宽限时间**:未使用 | +| `group` | 存储组信息 | **组名**:未使用:**GID**:**成员列表** | + +### 自定义处理 + +当管理员需要更好地控制账号时,可以使用命令行来自定义,如指定一个用户的 ID。 + +#### 用户和组 ID + +默认情况下,`useradd` 试图使用相同的用户 ID(UID)和主组 ID(GID),但也不完全是。虽然 UID 与 GID 相同不是必须的,但如果相同,会更方便管理员管理。 + +下面的场景就是一个 GID 与 UID 不同的例子。现在我添加另一账号,名为 Timmy。通过使用 `getent` 命令来比较 `sonny` 和 `timmy` 两个账号,显示两个用户和对应的主组。 + +```bash +$ getent passwd sonny timmy +sonny:x:1001:1002:Sonny:/home/sonny:/bin/bash +timmy:x:1002:1003::/home/timmy:/bin/bash + +$ getent group sonny timmy +sonny:x:1002: +timmy:x:1003: +``` + +不幸的是,两者的 UID 和 GID 都不相同。因为默认的处理是,创建用户时,把下一个可用的 UID 赋给用户,然后把同一个数字作为主组 ID 赋给它。然而,当要使用的组 ID 已经被使用时,就再把下一个可用的 GID 赋给它。为了弄清细节,我猜想 1001 这个 GID 已经被使用了,用一个命令确认了一下。 + +```bash +$ getent group 1001 +book:x:1001:alan +``` + +`book` 的 ID 是 `1001`,因此新创建的用户的 GID 都有偏移量 1。这就是为什么系统管理员在用户创建过程中需要多设置一些值的一个实例。为了解决这个问题,我必须先确定下一个可用的 UID 和 GID 是否相同。确定下一个可用值时,可以使用 `getent group` 和 `getent passwd` 命令,通过 `-u` 参数传递要确认的值。 + +```bash +$ sudo useradd -u 1004 bobby + +$ getent passwd bobby; getent group bobby +bobby:x:1004:1004::/home/bobby:/bin/bash +bobby:x:1004: +``` + +另一个需要指定 ID 的场景是,通过 NFS 访问远程系统上的文件时。对于一个给定的用户,当 NFS 所有客户端和服务系统的 ID 都一样时,管理员更容易控制。在我的文章 [使用 autofs 挂载 NFS][2] 中有详细介绍。 + +### 更多自定义 + +一些其他的指定用户信息的参数也用得比较频繁。这里是一些你会经常用到的参数的概括例子。 + +#### 注释 + +注释选项是通过 `-c` 参数指定的一个解释文本字段,可以提供一段简短的描述或其他信息。 + +```bash +$ sudo useradd -c "Bailey is cool" bailey +$ getent passwd bailey +bailey:x:1011:1011:Bailey is cool:/home/bailey:/bin/bash +``` + +#### 组 + +一个用户可以被指定一个主组和多个次组。`-g` 参数指定主组名称或 GID。如果不指定,`useradd` 会以用户名创建一个主组(前面演示过)。`-G`(大写)参数用一个逗号分隔的组列表来指定此用户所属的组,这些组就是次组。 + +```bash +$ sudo useradd -G tgroup,fgroup,libvirt milly +$ id milly +uid=1012(milly) gid=1012(milly) groups=1012(milly),981(libvirt),4000(fgroup),3000(tgroup) +``` + +#### 家目录 + +`useradd` 的默认处理是,在 `/home` 目录下创建用户的家目录。然而,下面的参数可以改写家目录的基础目录。`-b` 设置另一个可以创建家目录的基础目录。例如指定 `/home2` 而不是 `/home`。 + +```bash +$ sudo useradd -b /home2 vicky +$ getent passwd vicky +vicky:x:1013:1013::/home2/vicky:/bin/bash +``` + +`-d` 参数可以指定一个与用户名不同的家目录。 + +```bash +$ sudo useradd -d /home/ben jerry +$ getent passwd jerry +jerry:x:1014:1014::/home/ben:/bin/bash +``` + +#### 目录模板 + +指定 `-k` 参数会在创建新用户时,复制 `/etc/skel` 目录下的所有文件到用户的家目录中。这些文件通常是 shell 配置文件,当然也可以是系统管理员想在新建用户时使用的任何文件。 + +#### Shell + +`-s` 参数可以指定 shell。如果不指定,则使用默认的 shell。例如,下面的例子中 ,配置文件中定义的 shell 是 `bash`,但 `wally` 这个用户指定的是 `zsh`。 + +```bash +SHELL=/bin/bash + +$ sudo useradd -s /usr/bin/zsh wally +$ getent passwd wally +wally:x:1004:1004::/home/wally:/usr/bin/zsh +``` + +#### 安全 + +安全是用户管理的重中之重,因此 `useradd` 命令也提供了很多关于安全的选项。可以使用 `-e` 参数,以 YYYY-MM-DD 的格式指定一个用户的过期时间。 + +```bash +$ sudo useradd -e 20191231 sammy +$ sudo getent shadow sammy +sammy:!!:18171:0:99999:7::20191231: +``` + +当密码过期时,账号也会自动失效。`-f` 参数指定密码过期后经过几天账号失效。如果设为 0,则立即失效。 + +```bash +$ sudo useradd -f 30 willy +$ sudo getent shadow willy +willy:!!:18171:0:99999:7:30:: +``` + +### 实例 + +生产环境中,创建一个用户账号时会用到多个参数。例如,我要创建一个 Perry 账号,可能会用下面的命令: + +```bash +$ sudo useradd -u 1020 -c "Perry Example" \ +-G tgroup -b /home2 \ +-s /usr/bin/zsh \ +-e 20201201 -f 5 perry +``` + +查看前面的内容来理解每个选项。用下面的命令确认结果: + +```bash +$ getent passwd perry; getent group perry; getent shadow perry; id perry +perry:x:1020:1020:Perry Example:/home2/perry:/usr/bin/zsh +perry:x:1020: +perry:!!:18171:0:99999:7:5:20201201: +uid=1020(perry) gid=1020(perry) groups=1020(perry),3000(tgroup) +``` + +### 一点小建议 + +`useradd` 命令是所有 Unix(不仅仅是 Linux)系统管理员都必知必会的命令。由于用户创建不能出错,需要第一次就正确,所以理解它的每一个选项很重要。这意味着你需要有一套深思熟虑的命名约定,包括为整个企业环境而不仅仅是一个单系统预留一个专用的 UID/GID 范围,尤其是你为一个成长中的组织工作时。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/linux-useradd-command + +作者:[Alan Formy-Duval][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alanfdoss +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/connection_people_team_collaboration.png?itok=0_vQT8xV (people in different locations who are part of the same team) +[2]: https://opensource.com/article/18/6/using-autofs-mount-nfs-shares diff --git a/published/202001/20191108 My Linux story- Learning Linux in the 90s.md b/published/202001/20191108 My Linux story- Learning Linux in the 90s.md new file mode 100644 index 0000000000..f31ae62e4f --- /dev/null +++ b/published/202001/20191108 My Linux story- Learning Linux in the 90s.md @@ -0,0 +1,62 @@ +[#]: collector: (lujun9972) +[#]: translator: (alim0x) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11831-1.html) +[#]: subject: (My Linux story: Learning Linux in the 90s) +[#]: via: (https://opensource.com/article/19/11/learning-linux-90s) +[#]: author: (Mike Harris https://opensource.com/users/mharris) + +我的 Linux 故事:在 90 年代学习 Linux +====== + +> 这是一个关于我如何在 WiFi 时代之前学习 Linux 的故事,那时的发行版还以 CD 的形式出现。 + +![](https://img.linux.net.cn/data/attachment/album/202001/29/213829t00wmwu2w0z502zg.jpg) + +大部分人可能不记得 1996 年时计算产业或日常生活世界的样子。但我很清楚地记得那一年。我那时候是堪萨斯中部一所高中的二年级学生,那是我的自由与开源软件(FOSS)旅程的开端。 + +我从这里开始进步。我在 1996 年之前就开始对计算机感兴趣。我在我家的第一台 Apple ][e 上启蒙成长,然后多年之后是 IBM Personal System/2。(是的,在这过程中有一些代际的跨越。)IBM PS/2 有一个非常激动人心的特性:一个 1200 波特的 Hayes 调制解调器。 + +我不记得是怎样了,但在那不久之前,我得到了一个本地 [BBS][2] 的电话号码。一旦我拨号进去,我可以得到本地的一些其他 BBS 的列表,我的网络探险就此开始了。 + +在 1995 年,[足够幸运][3]的人拥有了家庭互联网连接,每月可以使用不到 30 分钟。那时的互联网不像我们现代的服务那样,通过卫星、光纤、有线电视同轴电缆或任何版本的铜线提供。大多数家庭通过一个调制解调器拨号,它连接到他们的电话线上。(这时离移动电话无处不在的时代还早得很,大多数人只有一部家庭电话。)尽管这还要取决你所在的位置,但我不认为那时有很多独立的互联网服务提供商(ISP),所以大多数人从仅有的几家大公司获得服务,包括 America Online,CompuServe 以及 Prodigy。 + +你能获取到的服务速率非常低,甚至在拨号上网革命性地达到了顶峰的 56K,你也只能期望得到最高 3.5Kbps 的速率。如果你想要尝试 Linux,下载一个 200MB 到 800MB 的 ISO 镜像或(更加切合实际的)一套软盘镜像要贡献出时间、决心,以及减少电话的使用。 + +我走了一条简单一点的路:在 1996 年,我从一家主要的 Linux 发行商订购了一套 “tri-Linux” CD 集。这些光盘提供了三个发行版,我的这套包含了 Debian 1.1(Debian 的第一个稳定版本)、Red Hat Linux 3.0.3 以及 Slackware 3.1(代号 Slackware '96)。据我回忆,这些光盘是从一家叫做 [Linux Systems Labs][4] 的在线商店购买的。这家在线商店如今已经不存在了,但在 90 年代和 00 年代早期,这样的发行商很常见。这些是多光盘 Linux 套件。这是 1998 年的一套光盘,你可以了解到他们都包含了什么: + +![A tri-linux CD set][5] + +![A tri-linux CD set][6] + +在 1996 年夏天一个命中注定般的日子,那时我住在堪萨斯一个新的并且相对较为乡村的城市,我做出了安装并使用 Linux 的第一次尝试。在 1996 年的整个夏天,我尝试了那套三张 Linux CD 套件里的全部三个发行版。他们都在我母亲的老 Pentium 75MHz 电脑上完美运行。 + +我最终选择了 [Slackware][7] 3.1 作为我的首选发行版,相比其它发行版可能更多的是因为它的终端的外观,这是决定选择一个发行版前需要考虑的重要因素。 + +我将系统设置完毕并运行了起来。我连接到一家 “不太知名的” ISP(一家这个区域的本地服务商),通过我家的第二条电话线拨号(为了满足我的所有互联网使用而订购)。那就像在天堂一样。我有一台完美运行的双系统(Microsoft Windows 95 和 Slackware 3.1)电脑。我依然拨号进入我所知道和喜爱的 BBS,游玩在线 BBS 游戏,比如 Trade Wars、Usurper 以及 Legend of the Red Dragon。 + +我能够记得在 EFNet(IRC)上 #Linux 频道上渡过的日子,帮助其他用户,回答他们的 Linux 问题以及和版主们互动。 + +在我第一次在家尝试使用 Linux 系统的 20 多年后,已经是我进入作为 Red Hat 顾问的第五年,我仍然在使用 Linux(现在是 Fedora)作为我的日常系统,并且依然在 IRC 上帮助想要使用 Linux 的人们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/learning-linux-90s + +作者:[Mike Harris][a] +选题:[lujun9972][b] +译者:[alim0x](https://github.com/alim0x) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mharris +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus-cloud.png?itok=vz0PIDDS (Sky with clouds and grass) +[2]: https://en.wikipedia.org/wiki/Bulletin_board_system +[3]: https://en.wikipedia.org/wiki/Global_Internet_usage#Internet_users +[4]: https://web.archive.org/web/19961221003003/http://lsl.com/ +[5]: https://opensource.com/sites/default/files/20191026_142009.jpg (A tri-linux CD set) +[6]: https://opensource.com/sites/default/files/20191026_142020.jpg (A tri-linux CD set) +[7]: http://slackware.com diff --git a/published/202001/20191113 How to cohost GitHub and GitLab with Ansible.md b/published/202001/20191113 How to cohost GitHub and GitLab with Ansible.md new file mode 100644 index 0000000000..c9a05d6b40 --- /dev/null +++ b/published/202001/20191113 How to cohost GitHub and GitLab with Ansible.md @@ -0,0 +1,168 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11735-1.html) +[#]: subject: (How to cohost GitHub and GitLab with Ansible) +[#]: via: (https://opensource.com/article/19/11/how-host-github-gitlab-ansible) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何使用 Ansible 同步 GitHub 和 GitLab +====== + +> 通过使用 Ansible 镜像 Git 存储库,保护对重要项目的访问。 + +![](https://img.linux.net.cn/data/attachment/album/202001/01/104040fbdu68wosg8o99wg.jpg) + +开源无处不在。它在家里的计算机上、在工作场所的计算机上、在互联网上,并且很多都由 [Git][2] 管理。由于 Git 是分布式的,因此许多人也将其视为一种众包的备份解决方案。从理论上讲,每当有人将 Git 存储库克隆到其本地计算机时,他们就创建了该项目源代码的备份。如果有 100 个人这样做,则存储库就有 100 个备份副本。 + +从理论上讲,这可以缓解“灾难”的影响,例如当项目维护者[突然决定删除存储库][3]或[莫名其妙地阻止所有流量][4],导致开发人员们无头苍蝇般地寻找谁拥有主分支的最新版本。类似的,整个代码托管站点也会消失。没有人会想到 Google Code、Microsoft CodePlex 或 Gitorious 会在鼎盛时期将被关闭。 + +简而言之,如果在过去的几十年中互联网教给了我们一些东西,那就是依靠互联网神奇地创建备份并不是冗余的最可靠途径。 + +此外,对于许多人来说,很多开源项目都托管在 GitHub 上是个问题 —— GitHub 并不是开放平台。许多开发人员和用户都希望支持诸如 GitLab 之类的堆栈并与之交互,它具有开源社区版本。 + +### 使用 Ansible 管理 Git + +Git 的去中心方式对于解决这个问题很有用。使用纯 Git,你可以使用一个 `push` 命令轻松地将其推到两个或多个存储库。但是,为了使其在发生意外故障时有用,你必须经常与 Git 存储库进行交互(特别是推送)。此外,即使你可能永远不会自己推送或拉出代码,也可能有一些要备份的存储库。 + +但是,使用 Ansible,你可以自动执行项目主分支(或其他任何分支)的 Git 拉取,然后自动进行存储库到“异地”镜像的 Git 推送。换句话说,你可以让你的计算机定期从 GitHub 拉取并推送到 GitLab 或 [Gitolite][5] 或 Gitea(或你喜欢的任何 Git 托管主机)。 + +### Ansible 模块 + +如果不是因其出色的模块集合,那么 Ansible 就没那么出色。像 Python 的第三方库或 Linux 的应用程序一样,这个技术引擎的一个有用而令人惊讶的简单技巧是,Ansible 以其他人贡献的组件而闻名。因为本文正在研究如何有效和可靠地备份 Git 存储库,所以这里使用的模块是 [Git 模块][6]和 [ini_file][7] 模块。 + +首先,创建一个名为 `mirror.yaml` 的文件作为剧本playbook。你可以像通常使用 Ansible 一样,从 `name` 和 `task` 条目开始。本示例将 `localhost` 添加到 `hosts` 列表中,以便在控制器计算机(你现在坐在前面的计算机)上运行动作play,但是在现实生活中,你可能会在特定的主机或一组网络上的主机上运行它。 + +``` +--- +- name: "Mirror a Git repo with Ansible" + hosts: localhost + tasks: +``` + +### Git 拉取和克隆 + +如果要进行备份,则需要最新代码的副本。明显,在 Git 仓库中实现这一目标的方法是执行 `git pull`。 但是,`pull` 会假定克隆已经存在,而写得很好的 Ansible 动作(Ansible 脚本)则尽可能少的假定。最好告诉 Ansible 先克隆存储库。 + +将你的第一个任务添加到剧本: + +``` +--- +- name: "Mirror a Git repo with Ansible" + hosts: localhost + vars: + git_dir: /tmp/soso.git + tasks: + + - name: "Clone the git repo" + git: + repo: 'https://github.com/ozkl/soso.git' + dest: '{{ git_dir }}' + clone: yes + update: yes +``` + +这个例子使用了开源的、类似于 Unix 的操作系统 soso 作为我要镜像的存储库。这是一个完全任意的选择,绝不意味着我对该存储库的未来缺乏信心。它还使用变量来引用目标文件夹 `/tmp/soso.git`,这很方便,并且如果以后你希望将它扩展为一个通用的镜像脚本也会受益。在现实生活中,你的工作机上可能会比 `/tmp` 具有更永久的位置,例如 `/home/gitmirrors/soso.git` 或 `/opt/gitmirrors/soso.git`。 + +运行你的剧本: + +``` +$ ansible-playbook mirror.yaml +``` + +首次运行该剧本时,Ansible 会正确检测到 Git 存储库在本地尚不存在,因此将其克隆。 + +``` +PLAY [Ansible Git mirror] ******** + +TASK [Gathering Facts] *********** +ok: [localhost] + +TASK [Clone git repo] ************ +changed: [localhost] + +PLAY RECAP *********************** +localhost: ok=2 changed=1 failed=0 [...] +``` + +如果你再次运行该剧本,Ansible 会正确检测到自上次运行以来没有任何更改,并且会报告未执行任何操作: + +``` +localhost: ok=2 changed=0 failed=0 [...] +``` + +接下来,必须指示 Ansible 将存储库推送到另一个 Git 服务器。 + +### Git 推送 + +Ansible 中的 Git 模块不提供 `push` 功能,因此该过程的一部分是手动的。但是,在将存储库推送到备用镜像之前,你必须具有一个镜像,并且必须将镜像配置为备用远程服务器remote。 + +首先,必须将备用的远程服务器添加到 Git 配置。因为 Git 配置文件是 INI 样式的配置,所以你可以使用 `ini_file` Ansible 模块轻松地添加所需的信息。将此添加到你的剧本: + +``` + - name: "Add alternate remote" + ini_file: dest={{ git_dir }}/.git/config section='remote \"mirrored\"' option=url value='git@gitlab.com:example/soso-mirror.git' + tags: configuration +``` + +为此,你必须在目标服务器上有一个空的存储库(在本例中为 [GitLab.com][9])。如果需要在剧本中创建目标存储库,可以按照 Steve Ovens 的出色文章《[如何使用 Ansible 通过 SSH 设置 Git 服务器][10]》来完成。 + +最后,直接使用 Git 将 HEAD 推送到备用远程服务器: + +``` + - name: "Push the repo to alternate remote" + shell: 'git --verbose --git-dir={{ git_dir }}/.git push mirrored HEAD' +``` + +像往常一样运行该剧本,然后使该过程自动化,这样你就不必再次直接运行它了。你可以使用变量和特定的 Git 命令来调整脚本以适应你的需求,但是通过常规的拉取和推送操作,可以确保驻留在一台服务器上的重要项目可以安全地镜像到另一台服务器上。 + +这是完整的剧本,供参考: + +``` +--- +- name: "Mirror a Git repository with Ansible" + hosts: localhost + vars: + git_dir: /tmp/soso.git + + tasks: + + - name: "Clone the Git repo" + git: + repo: 'https://github.com/ozkl/soso.git' + dest: '{{ git_dir }}' + clone: yes + update: yes + + - name: "Add alternate remote" + ini_file: dest={{ git_dir }}/.git/config section='remote \"mirrored\"' option=url value='git@gitlab.com:example/soso-mirror.git' + tags: configuration + + - name: "Push the repo to alternate remote" + shell: 'git --verbose --git-dir={{ git_dir }}/.git push mirrored HEAD' +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/how-host-github-gitlab-ansible + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop.png?itok=pGfEfu2S (Hands programming) +[2]: https://opensource.com/resources/what-is-git +[3]: https://github.com/AntiMicro/antimicro/issues/3 +[4]: https://opensource.com/article/19/10/how-community-saved-artwork-creative-commons +[5]: https://opensource.com/article/19/4/server-administration-git +[6]: https://docs.ansible.com/ansible/latest/modules/git_module.html +[7]: https://docs.ansible.com/ansible/latest/modules/ini_file_module.html +[8]: mailto:git@gitlab.com +[9]: http://GitLab.com +[10]: https://opensource.com/article/17/8/ansible-environment-management diff --git a/published/202001/20191121 Simulate gravity in your Python game.md b/published/202001/20191121 Simulate gravity in your Python game.md new file mode 100644 index 0000000000..309dbf2091 --- /dev/null +++ b/published/202001/20191121 Simulate gravity in your Python game.md @@ -0,0 +1,395 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11780-1.html) +[#]: subject: (Simulate gravity in your Python game) +[#]: via: (https://opensource.com/article/19/11/simulate-gravity-python) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +在你的 Python 游戏中模拟引力 +====== + +> 学习如何使用 Python 的 Pygame 模块编程电脑游戏,并开始操作引力。 + +![](https://img.linux.net.cn/data/attachment/album/202001/13/223923k6t4zmvvmo6tfmmg.png) + +真实的世界充满了运动和生活。物理学使得真实的生活如此忙碌和动态。物理学是物质在空间中运动的方式。既然一个电脑游戏世界没有物质,它也就没有物理学规律,使用游戏程序员不得不*模拟*物理学。 + +从大多数电脑游戏来说,这里基本上仅有两个方面的物理学是重要的:引力和碰撞。 + +当你[添加一个敌人][2]到你的游戏中时,你实现了一些碰撞检测,但是这篇文章要添加更多的东西,因为引力需要碰撞检测。想想为什么引力可能涉及碰撞。如果你不能想到任何原因,不要担心 —— 它会随着你开发示例代码工作而且显然。 + +在真实世界中的引力是有质量的物体来相互吸引的倾向性。物体(质量)越大,它施加越大的引力作用。在电脑游戏物理学中,你不必创建质量足够大的物体来证明引力的正确;你可以在电脑游戏世界本身中仅编程一个物体落向假设的最大的对象的倾向。 + +### 添加一个引力函数 + +记住你的玩家已经有了一个决定动作的属性。使用这个属性来将玩家精灵拉向屏幕底部。 + +在 Pygame 中,较高的数字更接近屏幕的底部边缘。 + +在真实的世界中,引力影响一切。然而,在平台游戏中,引力是有选择性的 —— 如果你添加引力到你的整个游戏世界,你的所有平台都将掉到地上。反之,你可以仅添加引力到你的玩家和敌人精灵中。 + +首先,在你的 `Player` 类中添加一个 `gravity` 函数: + +``` +    def gravity(self): +        self.movey += 3.2 # 玩家掉落的多快 +``` + +这是一个简单的函数。首先,不管你的玩家是否想运动,你设置你的玩家垂直运动。也就是说,你已经编程你的玩家总是在下降。这基本上就是引力。 + +为使引力函数生效,你必须在你的主循环中调用它。这样,当每一个处理循环时,Python 都应用下落运动到你的玩家。 + +在这代码中,添加第一行到你的循环中: + +``` +    player.gravity() # 检查引力 +    player.update() +``` + +启动你的游戏来看看会发生什么。要注意,因为它发生的很快:你是玩家从天空上下落,马上掉出了你的游戏屏幕。 + +你的引力模拟是工作的,但是,也许太好了。 + +作为一次试验,尝试更改你玩家下落的速度。 + +### 给引力添加一个地板 + +你的游戏没有办法发现你的角色掉落出世界的问题。在一些游戏中,如果一个玩家掉落出世界,该精灵被删除,并在某个新的位置重生。在另一些游戏中,玩家会丢失分数或一条生命。当一个玩家掉落出世界时,不管你想发生什么,你必须能够侦测出玩家何时消失在屏幕外。 + +在 Python 中,要检查一个条件,你可以使用一个 `if` 语句。 + +你必需查看你玩家**是否**正在掉落,以及你的玩家掉落的程度。如果你的玩家掉落到屏幕的底部,那么你可以做*一些事情*。简化一下,设置玩家精灵的位置为底部边缘上方 20 像素。 + +使你的 `gravity` 函数看起来像这样: + +``` +    def gravity(self): +        self.movey += 3.2 # 玩家掉落的多快 +        +        if self.rect.y > worldy and self.movey >= 0: +            self.movey = 0 +            self.rect.y = worldy-ty +``` + +然后,启动你的游戏。你的精灵仍然下落,但是它停在屏幕的底部。不过,你也许不能*看到*你在地面层之上的精灵。一个简单的解决方法是,在精灵碰撞游戏世界的底部后,通过添加另一个 `-ty` 到它的新 Y 位置,从而使你的精灵弹跳到更高处: + +``` +    def gravity(self): +        self.movey += 3.2 # 玩家掉落的多快 +        +        if self.rect.y > worldy and self.movey >= 0: +            self.movey = 0 +            self.rect.y = worldy-ty-ty +``` + +现在你的玩家在屏幕底部弹跳,恰好在你地面精灵上面。 + +你的玩家真正需要的是反抗引力的方法。引力问题是,你不能反抗它,除非你有一些东西来推开引力作用。因此,在接下来的文章中,你将添加地面和平台碰撞以及跳跃能力。在这期间,尝试应用引力到敌人精灵。 + +到目前为止,这里是全部的代码: + +``` +#!/usr/bin/env python3 +# draw a world +# add a player and player control +# add player movement +# add enemy and basic collision +# add platform +# add gravity + +# GNU All-Permissive License +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. + +import pygame +import sys +import os + +''' +Objects +''' + +class Platform(pygame.sprite.Sprite): + # x location, y location, img width, img height, img file + def __init__(self,xloc,yloc,imgw,imgh,img): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(os.path.join('images',img)).convert() + self.image.convert_alpha() + self.rect = self.image.get_rect() + self.rect.y = yloc + self.rect.x = xloc + +class Player(pygame.sprite.Sprite): + ''' + Spawn a player + ''' + def __init__(self): + pygame.sprite.Sprite.__init__(self) + self.movex = 0 + self.movey = 0 + self.frame = 0 + self.health = 10 + self.score = 1 + self.images = [] + for i in range(1,9): + img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert() + img.convert_alpha() + img.set_colorkey(ALPHA) + self.images.append(img) + self.image = self.images[0] + self.rect = self.image.get_rect() + + def gravity(self): + self.movey += 3.2 # how fast player falls + + if self.rect.y > worldy and self.movey >= 0: + self.movey = 0 + self.rect.y = worldy-ty-ty + + def control(self,x,y): + ''' + control player movement + ''' + self.movex += x + self.movey += y + + def update(self): + ''' + Update sprite position + ''' + + self.rect.x = self.rect.x + self.movex + self.rect.y = self.rect.y + self.movey + + # moving left + if self.movex < 0: + self.frame += 1 + if self.frame > ani*3: + self.frame = 0 + self.image = self.images[self.frame//ani] + + # moving right + if self.movex > 0: + self.frame += 1 + if self.frame > ani*3: + self.frame = 0 + self.image = self.images[(self.frame//ani)+4] + + # collisions + enemy_hit_list = pygame.sprite.spritecollide(self, enemy_list, False) + for enemy in enemy_hit_list: + self.health -= 1 + print(self.health) + + ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) + for g in ground_hit_list: + self.health -= 1 + print(self.health) + +class Enemy(pygame.sprite.Sprite): + ''' + Spawn an enemy + ''' + def __init__(self,x,y,img): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(os.path.join('images',img)) + #self.image.convert_alpha() + #self.image.set_colorkey(ALPHA) + self.rect = self.image.get_rect() + self.rect.x = x + self.rect.y = y + self.counter = 0 + + def move(self): + ''' + enemy movement + ''' + distance = 80 + speed = 8 + + if self.counter >= 0 and self.counter <= distance: + self.rect.x += speed + elif self.counter >= distance and self.counter <= distance*2: + self.rect.x -= speed + else: + self.counter = 0 + + self.counter += 1 + +class Level(): + def bad(lvl,eloc): + if lvl == 1: + enemy = Enemy(eloc[0],eloc[1],'yeti.png') # spawn enemy + enemy_list = pygame.sprite.Group() # create enemy group + enemy_list.add(enemy) # add enemy to group + + if lvl == 2: + print("Level " + str(lvl) ) + + return enemy_list + + def loot(lvl,lloc): + print(lvl) + + def ground(lvl,gloc,tx,ty): + ground_list = pygame.sprite.Group() + i=0 + if lvl == 1: + while i < len(gloc): + ground = Platform(gloc[i],worldy-ty,tx,ty,'ground.png') + ground_list.add(ground) + i=i+1 + + if lvl == 2: + print("Level " + str(lvl) ) + + return ground_list + + def platform(lvl,tx,ty): + plat_list = pygame.sprite.Group() + ploc = [] + i=0 + if lvl == 1: + ploc.append((0,worldy-ty-128,3)) + ploc.append((300,worldy-ty-256,3)) + ploc.append((500,worldy-ty-128,4)) + + while i < len(ploc): + j=0 + while j <= ploc[i][2]: + plat = Platform((ploc[i][0]+(j*tx)),ploc[i][1],tx,ty,'ground.png') + plat_list.add(plat) + j=j+1 + print('run' + str(i) + str(ploc[i])) + i=i+1 + + if lvl == 2: + print("Level " + str(lvl) ) + + return plat_list + +''' +Setup +''' +worldx = 960 +worldy = 720 + +fps = 40 # frame rate +ani = 4 # animation cycles +clock = pygame.time.Clock() +pygame.init() +main = True + +BLUE = (25,25,200) +BLACK = (23,23,23 ) +WHITE = (254,254,254) +ALPHA = (0,255,0) + +world = pygame.display.set_mode([worldx,worldy]) +backdrop = pygame.image.load(os.path.join('images','stage.png')).convert() +backdropbox = world.get_rect() +player = Player() # spawn player +player.rect.x = 0 +player.rect.y = 0 +player_list = pygame.sprite.Group() +player_list.add(player) +steps = 10 # how fast to move + +eloc = [] +eloc = [200,20] +gloc = [] +#gloc = [0,630,64,630,128,630,192,630,256,630,320,630,384,630] +tx = 64 #tile size +ty = 64 #tile size + +i=0 +while i <= (worldx/tx)+tx: + gloc.append(i*tx) + i=i+1 + +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) +plat_list = Level.platform( 1,tx,ty ) + +''' +Main loop +''' +while main == True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit(); sys.exit() + main = False + + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_LEFT or event.key == ord('a'): + print("LEFT") + player.control(-steps,0) + if event.key == pygame.K_RIGHT or event.key == ord('d'): + print("RIGHT") + player.control(steps,0) + if event.key == pygame.K_UP or event.key == ord('w'): + print('jump') + + if event.type == pygame.KEYUP: + if event.key == pygame.K_LEFT or event.key == ord('a'): + player.control(steps,0) + if event.key == pygame.K_RIGHT or event.key == ord('d'): + player.control(-steps,0) + if event.key == pygame.K_UP or event.key == ord('w'): + print('jump') + + if event.key == ord('q'): + pygame.quit() + sys.exit() + main = False + + world.blit(backdrop, backdropbox) + player.gravity() # check gravity + player.update() + player_list.draw(world) + enemy_list.draw(world) + ground_list.draw(world) + plat_list.draw(world) + for e in enemy_list: + e.move() + pygame.display.flip() + clock.tick(fps) +``` + +* * * + +这是仍在进行中的关于使用 [Pygame][4] 模块来在 [Python 3][3] 在创建电脑游戏的第七部分。先前的文章是: + + * [通过构建一个简单的掷骰子游戏去学习怎么用 Python 编程][5] + * [使用 Python 和 Pygame 模块构建一个游戏框架][6] + * [如何在你的 Python 游戏中添加一个玩家][7] + * [用 Pygame 使你的游戏角色移动起来][8] + * [如何向你的 Python 游戏中添加一个敌人][2] + * [在 Pygame 游戏中放置平台][9] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/simulate-gravity-python + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/space_stars_cosmic.jpg?itok=bE94WtN- (Cosmic stars in outer space) +[2]: https://linux.cn/article-10883-1.html +[3]: https://www.python.org/ +[4]: https://www.pygame.org +[5]: https://linux.cn/article-9071-1.html +[6]: https://linux.cn/article-10850-1.html +[7]: https://linux.cn/article-10858-1.html +[8]: https://linux.cn/article-10874-1.html +[9]: https://linux.cn/article-10902-1.html diff --git a/published/202001/20191129 How to write a Python web API with Django.md b/published/202001/20191129 How to write a Python web API with Django.md new file mode 100644 index 0000000000..5ba1650a1f --- /dev/null +++ b/published/202001/20191129 How to write a Python web API with Django.md @@ -0,0 +1,232 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to write a Python web API with Django) +[#]: via: (https://opensource.com/article/19/11/python-web-api-django) +[#]: author: (Rachel Waston https://opensource.com/users/rachelwaston) + +如何借助 Django 来编写一个 Python Web API +====== + +> Django 是 Python API 开发中最流行的框架之一,在这个教程中,我们来学习如何使用它。 + +![](https://img.linux.net.cn/data/attachment/album/202001/11/142503aio2325mk5weiozz.jpg) + +[Django][2] 所有 Web 框架中最全面的,也是最受欢迎的一个。自 2005 年以来,其流行度大幅上升。 + +Django 是由 Django 软件基金会维护,并且获得了社区的大力支持,在全球拥有超过 11,600 名成员。在 Stack Overflow 上,约有 191,000 个带 Django 标签的问题。Spotify、YouTube 和 Instagram 等都使用 Django 来构建应用程序和数据管理。 + +本文演示了一个简单的 API,通过它可以使用 HTTP 协议的 GET 方法来从服务器获取数据。 + +### 构建一个项目 + +首先,为你的 Django 应用程序创建一个目录结构,你可以在系统的任何位置创建: + +``` +$ mkdir myproject +$ cd myproject +``` + +然后,在项目目录中创建一个虚拟环境来隔离本地包依赖关系: + +``` +$ python3 -m venv env +$ source env/bin/activate +``` + +在 Windows 上,使用命令 `env\Scripts\activate` 来激活虚拟环境。 + +### 安装 Django 和 Django REST framework + +然后,安装 Django 和 Django REST 模块: + +``` +$ pip3 install django +$ pip3 install djangorestframework +``` + +### 实例化一个新的 Django 项目 + +现在你的应用程序已经有了一个工作环境,你必须实例化一个新的 Django 项目。与 [Flask][3] 这样微框架不同的是,Django 有专门的命令来创建(注意第一条命令后的 `.` 字符)。 + +``` +$ django-admin startproject tutorial . +$ cd tutorial +$ django-admin startapp quickstart +``` + +Django 使用数据库来管理后端,所以你应该在开始开发之前同步数据库,数据库可以通过 `manage.py` 脚本管理,它是在你运行 `django-admin` 命令时创建的。因为你现在在 `tutorial` 目录,所以使用 `../` 符号来运行脚本,它位于上一层目录: + +``` +$ python3 ../manage.py makemigrations +No changes detected +$ python4 ../manage.py migrate +Operations to perform: + Apply all migrations: admin, auth, contenttypes, sessions +Running migrations: + Applying contenttypes.0001_initial... OK + Applying auth.0001_initial... OK + Applying admin.0001_initial... OK + Applying admin.0002_logentry_remove_auto_add... OK + Applying admin.0003_logentry_add_action_flag_choices... OK + Applying contenttypes.0002_remove_content_type_name... OK + Applying auth.0002_alter_permission_name_max_length... OK + Applying auth.0003_alter_user_email_max_length... OK + Applying auth.0004_alter_user_username_opts... OK + Applying auth.0005_alter_user_last_login_null... OK + Applying auth.0006_require_contenttypes_0002... OK + Applying auth.0007_alter_validators_add_error_messages... OK + Applying auth.0008_alter_user_username_max_length... OK + Applying auth.0009_alter_user_last_name_max_length... OK + Applying auth.0010_alter_group_name_max_length... OK + Applying auth.0011_update_proxy_permissions... OK + Applying sessions.0001_initial... OK +``` + +### 在 Django 中创建用户 + +创建一个名为 `admin`,示例密码为 `password123` 的初始用户: + +``` +$ python3 ../manage.py createsuperuser \ + --email admin@example.com \ + --username admin +``` + +在提示时创建密码。 + +### 在 Django 中实现序列化和视图 + +为了使 Django 能够将信息传递给 HTTP GET 请求,必须将信息对象转化为有效的响应数据。Django 为此实现了“序列化类” `serializers`。 + +在你的项目中,创建一个名为 `quickstart/serializers.py` 的新模块,使用它来定义一些序列化器,模块将用于数据展示: + +``` +from django.contrib.auth.models import User, Group +from rest_framework import serializers + +class UserSerializer(serializers.HyperlinkedModelSerializer): + class Meta: + model = User + fields = ['url', 'username', 'email', 'groups'] + +class GroupSerializer(serializers.HyperlinkedModelSerializer): + class Meta: + model = Group + fields = ['url', 'name'] +``` + +Django 中的[视图][5]是一个接受 Web 请求并返回 Web 响应的函数。响应可以是 HTML、HTTP 重定向、HTTP 错误、JSON 或 XML 文档、图像或 TAR 文件,或者可以是从 Internet 获得的任何其他内容。要创建视图,打开 `quickstart/views.py` 并输入以下代码。该文件已经存在,并且其中包含一些示例文本,保留这些文本并将以下代码添加到文件中: + +``` +from django.contrib.auth.models import User, Group +from rest_framework import viewsets +from tutorial.quickstart.serializers import UserSerializer, GroupSerializer + +class UserViewSet(viewsets.ModelViewSet): + """ + API 允许查看或编辑用户 + """ + queryset = User.objects.all().order_by('-date_joined') + serializer_class = UserSerializer + +class GroupViewSet(viewsets.ModelViewSet): + """ + API 允许查看或编辑组 + """ + queryset = Group.objects.all() + serializer_class = GroupSerializer +``` + +### 使用 Django 生成 URL + +现在,你可以生成 URL 以便人们可以访问你刚起步的 API。在文本编辑器中打开 `urls.py` 并将默认示例代码替换为以下代码: + +``` +from django.urls import include, path +from rest_framework import routers +from tutorial.quickstart import views + +router = routers.DefaultRouter() +router.register(r'users', views.UserViewSet) +router.register(r'groups', views.GroupViewSet) + +# 使用自动路由 URL +# 还有登录 URL +urlpatterns = [ + path('', include(router.urls)), + path('api-auth/', include('rest_framework.urls', namespace='rest_framework')) +] +``` + +### 调整你的 Django 项目设置 + +这个示例项目的设置模块存储在 `tutorial/settings.py` 中,因此在文本编辑器中将其打开,然后在 `INSTALLED_APPS` 列表的末尾添加 `rest_framework`: + +``` +INSTALLED_APPS = [ + ... + 'rest_framework', +] +``` + +### 测试 Django API + +现在,你可以测试构建的 API。首先,从命令行启动内置服务器: + +``` +$ python3 manage.py runserver +``` + +你可以通过使用 `curl` 导航至 URL `http://localhost:8000/users` 来访问 API: + +``` +$ curl --get http://localhost:8000/users/?format=json +[{"url":"http://localhost:8000/users/1/?format=json","username":"admin","email":"admin@example.com","groups":[]}] +``` + +使用 Firefox 或你选择的[开源浏览器][6]: + +![一个简单的 Django API][7] + +有关使用 Django 和 Python 的 RESTful API 的更多深入知识,参考出色的 [Django 文档][8]。 + +### 为什么要使用 Djago? + +Django 的主要优点: + + 1. Django 社区的规模正在不断扩大,因此即使你做一个复杂项目,也会有大量的指导资源。 + 2. 默认包含模板、路由、表单、身份验证和管理工具等功能,你不必寻找外部工具,也不必担心第三方工具会引入兼容性问题。 + 3. 用户、循环和条件的简单结构使你可以专注于编写代码。 + 4. 这是一个成熟且经过优化的框架,它非常快速且可靠。 + +Django 的主要缺点: + + 1. Django 很复杂!从开发人员视角的角度来看,它可能比简单的框架更难学。 + 2. Django 有一个很大的生态系统。一旦你熟悉它,这会很棒,但是当你深入学习时,它可能会令人感到无所适从。 + +对你的应用程序或 API 来说,Django 是绝佳选择。下载并熟悉它,开始开发一个迷人的项目! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/python-web-api-django + +作者:[Rachel Waston][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/rachelwaston +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd (Hands on a keyboard with a Python book ) +[2]: https://www.djangoproject.com/ +[3]: https://opensource.com/article/19/11/python-web-api-flask +[4]: mailto:admin@example.com +[5]: https://docs.djangoproject.com/en/2.2/topics/http/views/ +[6]: https://opensource.com/article/19/7/open-source-browsers +[7]: https://opensource.com/sites/default/files/uploads/django-api.png (A simple Django API) +[8]: https://docs.djangoproject.com/en/2.2 diff --git a/published/202001/20191130 7 maker gifts for kids and teens.md b/published/202001/20191130 7 maker gifts for kids and teens.md new file mode 100644 index 0000000000..c92bcc29c9 --- /dev/null +++ b/published/202001/20191130 7 maker gifts for kids and teens.md @@ -0,0 +1,177 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11762-1.html) +[#]: subject: (7 maker gifts for kids and teens) +[#]: via: (https://opensource.com/article/19/11/maker-gifts-kids) +[#]: author: (Jess Weichler https://opensource.com/users/cyanide-cupcake) + +给儿童和青少年的 7 件创客礼物 +====== + +> 这份礼物指南使你轻松完成节日礼物的采购,它们可给婴儿、儿童、青少年及年龄更大的人们带来创造和创新能力。 + +![](https://img.linux.net.cn/data/attachment/album/202001/08/140516t4ewey9ryu24tpz5.jpg) + +还在纠结这个假期给年轻人买什么礼物?这是我精选的开源礼物,这些礼物将激发未来的创意和灵感。 + +### 蜂鸟机器人套件 + +![Hummingbird Robotics Kit][2] + +**年龄:**8 岁 - 成人 + +**这是什么:**[蜂鸟机器人套件][3]是一套完整的机器人套件,带有微控制器、电机、LED 和传感器。机器人的大脑具有特殊的端口,小手可以轻松地将其连接到机器人的组件上。蜂鸟套件并没有身体,而是鼓励用户自己创建一个。 + +**为什么我喜欢它:**蜂鸟可以使用多种编程语言 —— 从可视化编程(BirdBlox、MakeCode、Snap)到代码编程(Python 和 Java)—— 可以随着用户编码技能的提高而可扩展。所有组件均与你在电子商店中找到的组件完全相同,没有像其他机器人套件那样被塑料所遮盖。这使机器人的内部工作不再神秘,并在你需要时易于采购更多零件。 + +由于没有固定组装项目,因此蜂鸟是发挥创造力的完美机器人。 + +蜂鸟具有开源的软件和固件。它适用于 Linux、Windows、Mac、Chromebook、Android 和 iOS。 + +**费用:**起价为 99 美元。 + +### Makey Makey 经典版 + +![Makey Makey Classic][4] + +**年龄:** 6岁 - 成人 + +**这是什么:** [Makey Makey 经典版][5]可将任何导电物体(从棉花糖到你的朋友)变成计算机钥匙。 + +你可以使用鳄鱼夹将 Makey Makey 连接到你选择的导电物体上。然后,通过同时触摸两个导电物体来闭合接地和任何触发键之间的电路。Makey Makey 是一种安全的方法,可以安全地在家中探索电力,同时创造与计算机进行交互的有趣方式。 + +**为什么我喜欢它:** Makey Makey 可以与 Scratch 开发的视频游戏搭配使用,以创建独特的控制器,使用户进一步沉浸在游戏中。从用卫生纸卷和铝箔制成的工具到互动艺术和故事,可能性是无限的。它可以在具有 USB 端口的 Linux、Windows 和 Mac 计算机上使用。 + +**费用:** 49.95 美金 + +### Arduino Uno + +![Arduino Uno][6] + +**年龄:** 10 岁 - 成人 + +**这是什么:** Arduino 是随同电子套件购买的微控制器,也可以单独购买,它们具有多种版本,而我最喜欢 [Arduino Uno][7]。你可以根据需要从任何电子商店购买其他组件,例如 LED、电机和传感器。 + +**为什么我喜欢它:** Arduino Uno 的文档很完善,因此创客们很容易在线上找到教程。Arduino 可以实现从简单到复杂的各种电子项目。Arduino 具有开源的固件和硬件。它适用于 Linux、Mac 和 Windows。 + +**费用:** 主板的起价为 22.00 美元。总成本取决于项目和技能水平。 + +### DIY 创客套件 + +![A maker kit assembled in a quick trip to the hardware store][8] + +**年龄**:8 岁 - 成人 + +**这是什么:**当今许多创客、发明家和程序员都是从鼓捣碰巧出现在身边东西开始的。你可以快速前往最近的电子产品商店,为家里的年轻人创建一套出色的创客工具包。这是我的创客工具包中的内容: + +* 护目镜 +* 锤子 +* 钉子和螺丝 +* 碎木 +* 螺丝起子 +* 电线 +* LED +* 压电蜂鸣器 +* 马达 +* 带引线的 AA 电池组 +* 剪线钳 +* 纸板 +* 美纹纸胶带 +* 废布 +* 纽扣 +* 线程 +* 针 +* 拉链 +* 钩子 +* 一个很酷的工具盒,用来存放所有东西 + +**我为什么喜欢它:**还记得小时候,你把父母带回家的空纸箱变成了宇宙飞船、房屋或超级计算机吗?这就是为大孩子们准备的 DIY 创客工具包。 + +原始的组件使孩子们可以尝试并运用他们的想象力。DIY 创客工具包可以完全针对接收者定制。可以放入一些接受这份礼品的人可能从未想到过用之发挥创意的某些组件,例如为下水道提供一些 LED 或木工结构。 + +**费用:**不等 + +### 启发式游戏篮 + +![Heuristic play kit][9] + +**年龄:** 8 个月至 5 岁 + +**这是什么:**启发式游戏篮充满了由天然、无毒材料制成的有趣物品,可供婴幼儿使用其五种感官进行探索。这是一种开放式、自娱自乐的游戏。其想法是,成年人将监督(但不指导)儿童使用篮子及其物品半小时,然后将篮子拿走,等下一次再玩。 + +创建带有常见家用物品的可爱游戏篮很容易。尝试包括质地、声音、气味、形状和重量各不相同的物品。这里有一些想法可以帮助您入门。 + +* 漏勺或脊状柳条篮可容纳所有物品 +* 木勺子 +* 金属打蛋器和汤匙 +* 板刷 +* 海绵 +* 小型鸡蛋纸箱 +* 纸板管 +* 小擀面杖 +* 带纹理的毛巾 +* 岩石 +* 手铃 +* 钩针桌巾 +* 带盖的小铁罐 +   +游戏篮中不应包括任何容易破碎的东西或足够小到可以装入纸巾卷的东西,因为它们有窒息危险,应将所有物品彻底清洁后再交给孩子。 + +**我为什么喜欢它:**游戏篮非常适合感官发育,并可以帮助幼儿提出问题和探索周围的世界。这是培养创客思维方式的重要组成部分! + +很容易获得适合这个游戏篮的物品。你可能已经在家中或附近的二手商店里找到了很多有趣的物品。幼儿使用游戏篮的方式与婴儿不同。随着孩子们开始模仿成人生活并通过他们的游戏讲故事,这些物品将随孩子一起成长。 + +**费用:**不等 + +### 《Hello Ruby》 + +![Hello Ruby book cover][10] + +**年龄**:5-8 岁 + +**这是什么:** 《[Hello Ruby][11]:编码历险记》是 Linda Liukas 的插图书,通过有趣的故事讲述了一个遇到各种问题和朋友(每个都用一个码代表)的女孩,向孩子们介绍了编程概念。Liukas 还有其他副标题为《互联网探险》和《计算机内的旅程》的《Hello Ruby》系列书籍,而《编码历险记》已以 20 多种语言出版。 + +**为什么我喜欢它:**作者在书中附带了许多免费、有趣和无障碍的活动,可以从 Hello Ruby 网站下载和打印这些活动。这些活动教授编码概念、还涉及艺术表达、沟通、甚至时间安排。 + +**费用:**精装书的标价为 17.99 美元,但你可以通过本地或在线书店以较低的价格买到这本书。 + +### 《编程少女:学会编程和改变世界》 + +![Girls Who Code book cover][12] + +**年龄**:10 岁 - 成人 + +**内容是什么:**由《编程少女》的创始人 Reshma Saujani 撰写,《[编程少女:学会编程和改变世界][13]》为年轻女孩(以及男孩)提供了科技领域的实用信息。它涵盖了广泛的主题,包括编程语言、用例、术语和词汇、职业选择以及技术行业人士的个人简介和访谈。 + +**为什么我喜欢它:**本书以讲述了大多数面向成年人的网站都没有的技术故事。这些技术涉及许多学科,对于年轻人来说,重要的是要了解他们可以使用它来解决现实世界中的问题并有所作为。 + +**成本:**精装书的标价为 17.99 美元,平装书的标价为 10.99 美元,但你可以通过本地或在线书店以更低的价格找到。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/maker-gifts-kids + +作者:[Jess Weichler][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/cyanide-cupcake +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_gift_giveaway_box_520x292.png?itok=w1YQhNH1 (Gift box opens with colors coming out) +[2]: https://opensource.com/sites/default/files/uploads/hummingbird.png (Hummingbird Robotics Kit) +[3]: https://www.birdbraintechnologies.com/hummingbirdbit/ +[4]: https://opensource.com/sites/default/files/uploads/makeymakey2.jpg (Makey Makey Classic) +[5]: https://makeymakey.com/ +[6]: https://opensource.com/sites/default/files/uploads/arduinouno.jpg (Arduino Uno) +[7]: https://www.arduino.cc/ +[8]: https://opensource.com/sites/default/files/makerbox-makerkit.jpg (A maker kit assembled in a quick trip to the hardware store) +[9]: https://opensource.com/sites/default/files/makerbox-sensorykit.jpg (Heuristic play kit) +[10]: https://opensource.com/sites/default/files/uploads/helloruby2.jpg (Hello Ruby book cover) +[11]: https://www.helloruby.com/ +[12]: https://opensource.com/sites/default/files/uploads/girlswhocodebook.jpg (Girls Who Code book cover) +[13]: https://girlswhocode.com/book/girls-code-learn-code-change-world/ diff --git a/published/202001/20191205 Add jumping to your Python platformer game.md b/published/202001/20191205 Add jumping to your Python platformer game.md new file mode 100644 index 0000000000..d7195a008a --- /dev/null +++ b/published/202001/20191205 Add jumping to your Python platformer game.md @@ -0,0 +1,504 @@ +[#]: collector: (lujun9972) +[#]: translator: (cycoe) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11790-1.html) +[#]: subject: (Add jumping to your Python platformer game) +[#]: via: (https://opensource.com/article/19/12/jumping-python-platformer-game) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +为你的 Python 平台类游戏添加跳跃功能 +====== + +> 在本期使用 Python Pygame 模块编写视频游戏中,学会如何使用跳跃来对抗重力。 + +![](https://img.linux.net.cn/data/attachment/album/202001/16/214917c8mxn82fot82fx88.jpg) + +在本系列的 [前一篇文章][2] 中,你已经模拟了重力。但现在,你需要赋予你的角色跳跃的能力来对抗重力。 + +跳跃是对重力作用的暂时延缓。在这一小段时间里,你是向*上*跳,而不是被重力拉着向下落。但你一旦到达了跳跃的最高点,重力就会重新发挥作用,将你拉回地面。 + +在代码中,这种变化被表示为变量。首先,你需要为玩家精灵建立一个变量,使得 Python 能够跟踪该精灵是否正在跳跃中。一旦玩家精灵开始跳跃,他就会再次受到重力的作用,并被拉回最近的物体。 + +### 设置跳跃状态变量 + +你需要为你的 `Player` 类添加两个新变量: + + * 一个是为了跟踪你的角色是否正在跳跃中,可通过你的玩家精灵是否站在坚实的地面来确定 + * 一个是为了将玩家带回地面 + +将如下两个变量添加到你的 `Player` 类中。在下方的代码中,注释前的部分用于提示上下文,因此只需要添加最后两行: + +``` +                self.movex = 0 +                self.movey = 0 +                self.frame = 0 +                self.health = 10 +                # 此处是重力相关变量 +                self.collide_delta = 0 +                self.jump_delta = 6 +``` + +第一个变量 `collide_delta` 被设为 0 是因为在正常状态下,玩家精灵没有处在跳跃中的状态。另一个变量 `jump_delta` 被设为 6,是为了防止精灵在第一次进入游戏世界时就发生反弹(实际上就是跳跃)。当你完成了本篇文章的示例,尝试把该变量设为 0 看看会发生什么。 + +### 跳跃中的碰撞 + +如果你是跳到一个蹦床上,那你的跳跃一定非常优美。但是如果你是跳向一面墙会发生什么呢?(千万不要去尝试!)不管你的起跳多么令人印象深刻,当你撞到比你更大更硬的物体时,你都会立马停下。(LCTT 译注:原理参考动量守恒定律) + +为了在你的视频游戏中模拟这一点,你需要在你的玩家精灵与地面等东西发生碰撞时,将 `self.collide_delta` 变量设为 0。如果你的 `self.collide_delta` 不是 0 而是其它的什么值,那么你的玩家就会发生跳跃,并且当你的玩家与墙或者地面发生碰撞时无法跳跃。 + +在你的 `Player` 类的 `update` 方法中,将地面碰撞相关代码块修改为如下所示: + +``` +        ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) +        for g in ground_hit_list: +            self.movey = 0 +            self.rect.y = worldy-ty-ty +            self.collide_delta = 0 # 停止跳跃 + if self.rect.y > g.rect.y: + self.health -=1 + print(self.health) +``` + +这段代码块检查了地面精灵和玩家精灵之间发生的碰撞。当发生碰撞时,它会将玩家 Y 方向的坐标值设置为游戏窗口的高度减去一个瓷砖的高度再减去另一个瓷砖的高度。以此保证了玩家精灵是站在地面*上*,而不是嵌在地面里。同时它也将 `self.collide_delta` 设为 0,使得程序能够知道玩家未处在跳跃中。除此之外,它将 `self.movey` 设为 0,使得程序能够知道玩家当前未受到重力的牵引作用(这是游戏物理引擎的奇怪之处,一旦玩家落地,也就没有必要继续将玩家拉向地面)。 + +此处 `if` 语句用来检测玩家是否已经落到地面之*下*,如果是,那就扣除一点生命值作为惩罚。此处假定了你希望当你的玩家落到地图之外时失去生命值。这个设定不是必需的,它只是平台类游戏的一种惯例。更有可能的是,你希望这个事件能够触发另一些事件,或者说是一种能够让你的现实世界玩家沉迷于让精灵掉到屏幕之外的东西。一种简单的恢复方式是在玩家精灵掉落到地图之外时,将 `self.rect.y` 重新设置为 0,这样它就会在地图上方重新生成,并落到坚实的地面上。 + +### 撞向地面 + +模拟的重力使你玩家的 Y 坐标不断增大(LCTT 译注:此处原文中为 0,但在 Pygame 中越靠下方 Y 坐标应越大)。要实现跳跃,完成如下代码使你的玩家精灵离开地面,飞向空中。 + +在你的 `Player` 类的 `update` 方法中,添加如下代码来暂时延缓重力的作用: + +``` +        if self.collide_delta < 6 and self.jump_delta < 6: +            self.jump_delta = 6*2 +            self.movey -= 33  # 跳跃的高度 +            self.collide_delta += 6 +            self.jump_delta    += 6 +``` + +根据此代码所示,跳跃使玩家精灵向空中移动了 33 个像素。此处是*负* 33 是因为在 Pygame 中,越小的数代表距离屏幕顶端越近。 + +不过此事件视条件而定,只有当 `self.collide_delta` 小于 6(缺省值定义在你 `Player` 类的 `init` 方法中)并且 `self.jump_delta` 也于 6 的时候才会发生。此条件能够保证直到玩家碰到一个平台,才能触发另一次跳跃。换言之,它能够阻止空中二段跳。 + +在某些特殊条件下,你可能不想阻止空中二段跳,或者说你允许玩家进行空中二段跳。举个栗子,如果玩家获得了某个战利品,那么在他被敌人攻击到之前,都能够拥有空中二段跳的能力。 + +当你完成本篇文章中的示例,尝试将 `self.collide_delta` 和 `self.jump_delta` 设置为 0,从而获得百分之百的几率触发空中二段跳。 + +### 在平台上着陆 + +目前你已经定义了在玩家精灵摔落地面时的抵抗重力条件,但此时你的游戏代码仍保持平台与地面置于不同的列表中(就像本文中做的很多其他选择一样,这个设定并不是必需的,你可以尝试将地面作为另一种平台)。为了允许玩家精灵站在平台之上,你必须像检测地面碰撞一样,检测玩家精灵与平台精灵之间的碰撞。将如下代码放于你的 `update` 方法中: + +``` +        plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) +        for p in plat_hit_list: +            self.collide_delta = 0 # 跳跃结束 +            self.movey = 0 +``` + +但此处还有一点需要考虑:平台悬在空中,也就意味着玩家可以通过从上面或者从下面接触平台来与之互动。 + +确定平台如何与玩家互动取决于你,阻止玩家从下方到达平台也并不稀奇。将如下代码加到上方的代码块中,使得平台表现得像天花板或者说是藤架。只有在玩家精灵跳得比平台上沿更高时才能跳到平台上,但会阻止玩家从平台下方跳上来: + +``` +            if self.rect.y > p.rect.y: +                self.rect.y = p.rect.y+ty +            else: +                self.rect.y = p.rect.y-ty +``` + +此处 `if` 语句代码块的第一个子句阻止玩家精灵从平台正下方跳到平台上。如果它检测到玩家精灵的坐标比平台更大(在 Pygame 中,坐标更大意味着在屏幕的更下方),那么将玩家精灵新的 Y 坐标设置为当前平台的 Y 坐标加上一个瓷砖的高度。实际效果就是保证玩家精灵距离平台一个瓷砖的高度,防止其从下方穿过平台。 + +`else` 子句做了相反的事情。当程序运行到此处时,如果玩家精灵的 Y 坐标*不*比平台的更大,意味着玩家精灵是从空中落下(不论是由于玩家刚刚从此处生成,或者是玩家执行了跳跃)。在这种情况下,玩家精灵的 Y 坐标被设为平台的 Y 坐标减去一个瓷砖的高度(切记,在 Pygame 中更小的 Y 坐标代表在屏幕上的更高处)。这样就能保证玩家在平台*上*,除非他从平台上跳下来或者走下来。 + +你也可以尝试其他的方式来处理玩家与平台之间的互动。举个栗子,也许玩家精灵被设定为处在平台的“前面”,他能够无障碍地跳跃穿过平台并站在上面。或者你可以设计一种平台会减缓而又不完全阻止玩家的跳跃过程。甚至你可以通过将不同平台分到不同列表中来混合搭配使用。 + +### 触发一次跳跃 + +目前为此,你的代码已经模拟了所有必需的跳跃条件,但仍缺少一个跳跃触发器。你的玩家精灵的 `self.jump_delta` 初始值被设置为 6,只有当它比 6 小的时候才会触发更新跳跃的代码。 + +为跳跃变量设置一个新的设置方法,在你的 `Player` 类中创建一个 `jump` 方法,并将 `self.jump_delta` 设为小于 6 的值。通过使玩家精灵向空中移动 33 个像素,来暂时减缓重力的作用。 + + +``` +    def jump(self,platform_list): +        self.jump_delta = 0 +``` + +不管你相信与否,这就是 `jump` 方法的全部。剩余的部分在 `update` 方法中,你已经在前面实现了相关代码。 + +要使你游戏中的跳跃功能生效,还有最后一件事情要做。如果你想不起来是什么,运行游戏并观察跳跃是如何生效的。 + +问题就在于你的主循环中没有调用 `jump` 方法。先前你已经为该方法创建了一个按键占位符,现在,跳跃键所做的就是将 `jump` 打印到终端。 + +### 调用 jump 方法 + +在你的主循环中,将*上*方向键的效果从打印一条调试语句,改为调用 `jump` 方法。 + +注意此处,与 `update` 方法类似,`jump` 方法也需要检测碰撞,因此你需要告诉它使用哪个 `plat_list`。 + +``` +            if event.key == pygame.K_UP or event.key == ord('w'): +                player.jump(plat_list) +``` + +如果你倾向于使用空格键作为跳跃键,使用 `pygame.K_SPACE` 替代 `pygame.K_UP` 作为按键。另一种选择,你可以同时使用两种方式(使用单独的 `if` 语句),给玩家多一种选择。 + +现在来尝试你的游戏吧!在下一篇文章中,你将让你的游戏卷动起来。 + +![Pygame 平台类游戏][3] + +以下是目前为止的所有代码: + +``` +#!/usr/bin/env python3 +# draw a world +# add a player and player control +# add player movement +# add enemy and basic collision +# add platform +# add gravity +# add jumping + +# GNU All-Permissive License +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved.  This file is offered as-is, +# without any warranty. + +import pygame +import sys +import os + +''' +Objects +''' + +class Platform(pygame.sprite.Sprite): + # x 坐标,y 坐标,图像宽度,图像高度,图像文件 +    def __init__(self,xloc,yloc,imgw,imgh,img): +        pygame.sprite.Sprite.__init__(self) +        self.image = pygame.image.load(os.path.join('images',img)).convert() +        self.image.convert_alpha() +        self.rect = self.image.get_rect() +        self.rect.y = yloc +        self.rect.x = xloc + +class Player(pygame.sprite.Sprite): +    ''' +    生成一个玩家 +    ''' +    def __init__(self): +        pygame.sprite.Sprite.__init__(self) +        self.movex = 0 +        self.movey = 0 +        self.frame = 0 +        self.health = 10 +        self.collide_delta = 0 +        self.jump_delta = 6 +        self.score = 1 +        self.images = [] +        for i in range(1,9): +            img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert() +            img.convert_alpha() +            img.set_colorkey(ALPHA) +            self.images.append(img) +            self.image = self.images[0] +            self.rect  = self.image.get_rect() + +    def jump(self,platform_list): +        self.jump_delta = 0 + +    def gravity(self): +        self.movey += 3.2 # how fast player falls +        +        if self.rect.y > worldy and self.movey >= 0: +            self.movey = 0 +            self.rect.y = worldy-ty +        +    def control(self,x,y): +        ''' +        控制玩家移动 +        ''' +        self.movex += x +        self.movey += y +        +    def update(self): +        ''' +        更新精灵位置 +        ''' +        +        self.rect.x = self.rect.x + self.movex +        self.rect.y = self.rect.y + self.movey + +        # 向左移动 +        if self.movex < 0: +            self.frame += 1 +            if self.frame > ani*3: +                self.frame = 0 +            self.image = self.images[self.frame//ani] + +        # 向右移动 +        if self.movex > 0: +            self.frame += 1 +            if self.frame > ani*3: +                self.frame = 0 +            self.image = self.images[(self.frame//ani)+4] + +        # 碰撞 +        enemy_hit_list = pygame.sprite.spritecollide(self, enemy_list, False) +        for enemy in enemy_hit_list: +            self.health -= 1 +            #print(self.health) + +        plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) +        for p in plat_hit_list: +            self.collide_delta = 0 # stop jumping +            self.movey = 0 +            if self.rect.y > p.rect.y: +                self.rect.y = p.rect.y+ty +            else: +                self.rect.y = p.rect.y-ty +            +        ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) +        for g in ground_hit_list: +            self.movey = 0 +            self.rect.y = worldy-ty-ty +            self.collide_delta = 0 # stop jumping +            if self.rect.y > g.rect.y: +                self.health -=1 +                print(self.health) +                +        if self.collide_delta < 6 and self.jump_delta < 6: +            self.jump_delta = 6*2 +            self.movey -= 33  # how high to jump +            self.collide_delta += 6 +            self.jump_delta    += 6 +            +class Enemy(pygame.sprite.Sprite): +    ''' +    生成一个敌人 +    ''' +    def __init__(self,x,y,img): +        pygame.sprite.Sprite.__init__(self) +        self.image = pygame.image.load(os.path.join('images',img)) +        self.movey = 0 +        #self.image.convert_alpha() +        #self.image.set_colorkey(ALPHA) +        self.rect = self.image.get_rect() +        self.rect.x = x +        self.rect.y = y +        self.counter = 0 + +                +    def move(self): +        ''' +        敌人移动 +        ''' +        distance = 80 +        speed = 8 + +        self.movey += 3.2 +        +        if self.counter >= 0 and self.counter <= distance: +            self.rect.x += speed +        elif self.counter >= distance and self.counter <= distance*2: +            self.rect.x -= speed +        else: +            self.counter = 0 +        +        self.counter += 1 + +        if not self.rect.y >= worldy-ty-ty: +            self.rect.y += self.movey + +        plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) +        for p in plat_hit_list: +            self.movey = 0 +            if self.rect.y > p.rect.y: +                self.rect.y = p.rect.y+ty +            else: +                self.rect.y = p.rect.y-ty + +        ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) +        for g in ground_hit_list: +            self.rect.y = worldy-ty-ty + +        +class Level(): +    def bad(lvl,eloc): +        if lvl == 1: +            enemy = Enemy(eloc[0],eloc[1],'yeti.png') # 生成敌人 +            enemy_list = pygame.sprite.Group() # 创建敌人组 +            enemy_list.add(enemy)              # 将敌人添加到敌人组 +            +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return enemy_list + +    def loot(lvl,lloc): +        print(lvl) + +    def ground(lvl,gloc,tx,ty): +        ground_list = pygame.sprite.Group() +        i=0 +        if lvl == 1: +            while i < len(gloc): +                ground = Platform(gloc[i],worldy-ty,tx,ty,'ground.png') +                ground_list.add(ground) +                i=i+1 + +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return ground_list + +    def platform(lvl,tx,ty): +        plat_list = pygame.sprite.Group() +        ploc = [] +        i=0 +        if lvl == 1: +            ploc.append((0,worldy-ty-128,3)) +            ploc.append((300,worldy-ty-256,3)) +            ploc.append((500,worldy-ty-128,4)) + +            while i < len(ploc): +                j=0 +                while j <= ploc[i][2]: +                    plat = Platform((ploc[i][0]+(j*tx)),ploc[i][1],tx,ty,'ground.png') +                    plat_list.add(plat) +                    j=j+1 +                print('run' + str(i) + str(ploc[i])) +                i=i+1 + +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return plat_list + +''' +Setup +''' +worldx = 960 +worldy = 720 + +fps = 40 # 帧率 +ani = 4  # 动画循环 +clock = pygame.time.Clock() +pygame.init() +main = True + +BLUE  = (25,25,200) +BLACK = (23,23,23 ) +WHITE = (254,254,254) +ALPHA = (0,255,0) + +world = pygame.display.set_mode([worldx,worldy]) +backdrop = pygame.image.load(os.path.join('images','stage.png')).convert() +backdropbox = world.get_rect() +player = Player() # 生成玩家 +player.rect.x = 0 +player.rect.y = 0 +player_list = pygame.sprite.Group() +player_list.add(player) +steps = 10 # how fast to move +jump = -24 + +eloc = [] +eloc = [200,20] +gloc = [] +#gloc = [0,630,64,630,128,630,192,630,256,630,320,630,384,630] +tx = 64 # 瓷砖尺寸 +ty = 64 # 瓷砖尺寸 + +i=0 +while i <= (worldx/tx)+tx: +    gloc.append(i*tx) +    i=i+1 + +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) +plat_list = Level.platform( 1,tx,ty ) + +''' +主循环 +''' +while main == True: +    for event in pygame.event.get(): +        if event.type == pygame.QUIT: +            pygame.quit(); sys.exit() +            main = False + +        if event.type == pygame.KEYDOWN: +            if event.key == pygame.K_LEFT or event.key == ord('a'): +                print("LEFT") +                player.control(-steps,0) +            if event.key == pygame.K_RIGHT or event.key == ord('d'): +                print("RIGHT") +                player.control(steps,0) +            if event.key == pygame.K_UP or event.key == ord('w'): +                print('jump') + +        if event.type == pygame.KEYUP: +            if event.key == pygame.K_LEFT or event.key == ord('a'): +                player.control(steps,0) +            if event.key == pygame.K_RIGHT or event.key == ord('d'): +                player.control(-steps,0) +            if event.key == pygame.K_UP or event.key == ord('w'): +                player.jump(plat_list) + +            if event.key == ord('q'): +                pygame.quit() +                sys.exit() +                main = False + +#    world.fill(BLACK) +    world.blit(backdrop, backdropbox) +    player.gravity() # 检查重力 +    player.update() +    player_list.draw(world) # 刷新玩家位置 +    enemy_list.draw(world)  # 刷新敌人 +    ground_list.draw(world)  # 刷新地面 +    plat_list.draw(world)   # 刷新平台 +    for e in enemy_list: +        e.move() +    pygame.display.flip() +    clock.tick(fps) +``` + +本期是使用 [Pygame][5] 模块在 [Python 3][4] 中创建视频游戏连载系列的第 7 期。往期文章为: + + * [通过构建一个简单的掷骰子游戏去学习怎么用 Python 编程][6] + * [使用 Python 和 Pygame 模块构建一个游戏框架][7] + * [如何在你的 Python 游戏中添加一个玩家][8] + * [用 Pygame 使你的游戏角色移动起来][9] + * [如何向你的 Python 游戏中添加一个敌人][10] + * [在 Pygame 游戏中放置平台][11] + * [在你的 Python 游戏中模拟引力][2] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/jumping-python-platformer-game + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[cycoe](https://github.com/cycoe) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/arcade_game_gaming.jpg?itok=84Rjk_32 (Arcade games) +[2]: https://linux.cn/article-11780-1.html +[3]: https://opensource.com/sites/default/files/uploads/pygame-jump.jpg (Pygame platformer) +[4]: https://www.python.org/ +[5]: https://www.pygame.org/ +[6]: https://linux.cn/article-9071-1.html +[7]: https://linux.cn/article-10850-1.html +[8]: https://linux.cn/article-10858-1.html +[9]: https://linux.cn/article-10874-1.html +[10]: https://linux.cn/article-10883-1.html +[11]: https://linux.cn/article-10902-1.html diff --git a/published/202001/20191208 What-s your favorite terminal emulator.md b/published/202001/20191208 What-s your favorite terminal emulator.md new file mode 100644 index 0000000000..3979bb4a53 --- /dev/null +++ b/published/202001/20191208 What-s your favorite terminal emulator.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11814-1.html) +[#]: subject: (What's your favorite terminal emulator?) +[#]: via: (https://opensource.com/article/19/12/favorite-terminal-emulator) +[#]: author: (Opensource.com https://opensource.com/users/admin) + +你最喜欢的终端模拟器是什么? +====== + +> 我们让社区讲述他们在终端仿真器方面的经验。以下是我们收到的一些回复。 + +![](https://img.linux.net.cn/data/attachment/album/202001/24/000846qsmpz7s7spig77qg.jpg) + +终端仿真器的偏好可以说明一个人的工作流程。无鼠标操作能力是否必须具备?你想要标签页还是窗口?对于终端仿真器你还有什么选择的原因?是否有酷的因素?欢迎参加调查或给我们留下评论,告诉我们你最喜欢的终端模拟器。你尝试过多少种终端仿真器呢? + +我们让社区讲述他们在终端仿真器方面的经验。以下是我们收到的一些回复。 + +“我最喜欢的终端仿真器是用 Powerline 定制的 Tilix。我喜欢它支持在一个窗口中打开多个终端。” —Dan Arel + +“[urxvt][2]。它可以通过文件简单配置,轻巧,并且在大多数程序包管理器存储库中都很容易找到。” —Brian Tomlinson + +“即使我不再使用 GNOME,gnome-terminal 仍然是我的首选。:)” —Justin W. Flory + +“现在 FC31 上的 Terminator。我刚刚开始使用它,我喜欢它的分屏功能,对我来说感觉很轻巧。我正在研究它的插件。” —Marc Maxwell + +“不久前,我切换到了 Tilix,它完成了我需要终端执行的所有工作。:) 多个窗格、通知,很精简,用来运行我的 tmux 会话很棒。” —Kevin Fenzi + +“alacritty。它针对速度进行了优化,是用 Rust 实现的,并且具有很多常规功能,但是老实说,我只关心一个功能:可配置的字形间距,使我可以进一步压缩字体。” —Alexander Sosedkin +  +“我是个老古板:KDE Konsole。如果是远程会话,请使用 tmux。” —Marcin Juszkiewicz + +“在 macOS 上用 iTerm2。是的,它是开源的。:-) 在 Linux 上是 Terminator。” —Patrick Mullins + +“我现在已经使用 alacritty 一两年了,但是最近我在全屏模式下使用 cool-retro-term,因为我必须运行一个输出内容有很多的脚本,而它看起来很酷,让我感觉很酷。这对我很重要。” —Nick Childers + +“我喜欢 Tilix,部分是因为它擅长免打扰(我通常全屏运行它,里面是 tmux),而且还提供自定义热链接支持:在我的终端中,像 ‘rhbz#1234’ 之类的文本是将我带到 Bugzilla 的热链接。类似的还有 LaunchPad 提案,OpenStack 的 Gerrit 更改 ID 等。” —Lars Kellogg-Stedman + +“Eterm,在使用 Vintage 配置文件的 cool-retro-term 中,演示效果也最好。” —Ivan Horvath + +“Tilix +1。这是 GNOME 用户最好的选择,我是这么觉得的!” —Eric Rich + +“urxvt。快速、小型、可配置、可通过 Perl 插件扩展,这使其可以无鼠标操作。” —Roman Dobosz  + +“Konsole 是最好的,也是 KDE 项目中我唯一使用的应用程序。所有搜索结果都高亮显示是一个杀手级功能,据我所知没有任何其它 Linux 终端有这个功能(如果能证明我错了,那我也很高兴)。最适合搜索编译错误和输出日志。” —Jan Horak + +“我过去经常使用 Terminator。现在我在 Tilix 中克隆了它的主题(深色主题),而感受一样好。它可以在选项卡之间轻松移动。就是这样。” —Alberto Fanjul Alonso + +“我开始使用的是 Terminator,自从差不多过去这三年,我已经完全切换到 Tilix。” —Mike Harris + +“我使用下拉式终端 X。这是 GNOME 3 的一个非常简单的扩展,使我始终可以通过一个按键(对于我来说是`F12`)拉出一个终端。它还支持制表符,这正是我所需要的。 ” —Germán Pulido + +“xfce4-terminal:支持 Wayland、缩放、无边框、无标题栏、无滚动条 —— 这就是我在 tmux 之外全部想要的终端仿真器的功能。我希望我的终端仿真器可以尽可能多地使用屏幕空间,我通常在 tmux 窗格中并排放着编辑器(Vim)和 repl。” —Martin Kourim + +“别问,问就是 Fish ! ;-)” —Eric Schabell + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/favorite-terminal-emulator + +作者:[Opensource.com][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/admin +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_terminals_0.png?itok=XwIRERsn (Terminal window with green text) +[2]: https://opensource.com/article/19/10/why-use-rxvt-terminal diff --git a/published/202001/20191210 Lessons learned from programming in Go.md b/published/202001/20191210 Lessons learned from programming in Go.md new file mode 100644 index 0000000000..3c5e495b89 --- /dev/null +++ b/published/202001/20191210 Lessons learned from programming in Go.md @@ -0,0 +1,320 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11778-1.html) +[#]: subject: (Lessons learned from programming in Go) +[#]: via: (https://opensource.com/article/19/12/go-common-pitfalls) +[#]: author: (Eduardo Ferreira https://opensource.com/users/edufgf) + +Go 并发编程中的经验教训 +====== + +> 通过学习如何定位并发处理的陷阱来避免未来处理这些问题时的困境。 + +![](https://img.linux.net.cn/data/attachment/album/202001/13/150539n217ak1vcf717uzx.jpg) + +在复杂的分布式系统进行任务处理时,你通常会需要进行并发的操作。在 [Mode.net][2] 公司,我们每天都要和实时、快速和灵活的软件打交道。而没有一个高度并发的系统,就不可能构建一个毫秒级的动态地路由数据包的全球专用网络。这个动态路由是基于网络状态的,尽管这个过程需要考虑众多因素,但我们的重点是链路指标。在我们的环境中,链路指标可以是任何跟网络链接的状态和当前属性(如链接延迟)有关的任何内容。 + +### 并发探测链接监控 + +我们的动态路由算法 [H.A.L.O.][4](逐跳自适应链路状态最佳路由Hop-by-Hop Adaptive Link-State Optimal Routing)部分依赖于链路指标来计算路由表。这些指标由位于每个 PoP(存活节点Point of Presence)上的独立组件收集。PoP 是表示我们的网络中单个路由实体的机器,通过链路连接并分布在我们的网络拓扑中的各个位置。某个组件使用网络数据包探测周围的机器,周围的机器回复数据包给前者。从接收到的探测包中可以获得链路延迟。由于每个 PoP 都有不止一个临近节点,所以这种探测任务实质上是并发的:我们需要实时测量每个临近连接点的延迟。我们不能串行地处理;为了计算这个指标,必须尽快处理每个探测。 + +![latency computation graph][6] + +### 序列号和重置:一个重新排列场景 + +我们的探测组件互相发送和接收数据包,并依靠序列号进行数据包处理。这旨在避免处理重复的包或顺序被打乱的包。我们的第一个实现依靠特殊的序列号 0 来重置序列号。这个数字仅在组件初始化时使用。主要的问题是我们考虑了递增的序列号总是从 0 开始。在该组件重启后,包的顺序可能会重新排列,某个包的序列号可能会轻易地被替换成重置之前使用过的值。这意味着,后继的包都会被忽略掉,直到排到重置之前用到的序列值。 + +### UDP 握手和有限状态机 + +这里的问题是该组件重启前后的序列号是否一致。有几种方法可以解决这个问题,经过讨论,我们选择了实现一个带有清晰状态定义的三步握手协议。这个握手过程在初始化时通过链接建立会话。这样可以确保节点通过同一个会话进行通信且使用了适当的序列号。 + +为了正确实现这个过程,我们必须定义一个有清晰状态和过渡的有限状态机。这样我们就可以正确管理握手过程中的所有极端情况。 + +![finite state machine diagram][7] + +会话 ID 由握手的初始化程序生成。一个完整的交换顺序如下: + +1. 发送者发送一个 `SYN(ID)` 数据包。 +2. 接收者存储接收到的 `ID` 并发送一个 `SYN-ACK(ID)`。 +3. 发送者接收到 `SYN-ACK(ID)` 并发送一个 `ACK(ID)`。它还发送一个从序列号 0 开始的数据包。 +4. 接收者检查最后接收到的 `ID`,如果 ID 匹配,则接受 `ACK(ID)`。它还开始接受序列号为 0 的数据包。 + +### 处理状态超时 + +基本上,每种状态下你都需要处理最多三种类型的事件:链接事件、数据包事件和超时事件。这些事件会并发地出现,因此你必须正确处理并发。 + +* 链接事件包括网络连接或网络断开的变化,相应的初始化一个链接会话或断开一个已建立的会话。 +* 数据包事件是控制数据包(`SYN`/`SYN-ACK`/`ACK`)或只是探测响应。 +* 超时事件在当前会话状态的预定超时时间到期后触发。 + +这里面临的最主要的问题是如何处理并发的超时到期和其他事件。这里很容易陷入死锁和资源竞争的陷阱。 + +### 第一种方法 + +本项目使用的语言是 [Golang][8]。它确实提供了原生的同步机制,如自带的通道和锁,并且能够使用轻量级线程来进行并发处理。 + +![gophers hacking together][9] + +*gopher 们聚众狂欢* + +首先,你可以设计两个分别表示我们的会话和超时处理程序的结构体。 + +```go +type Session struct {   +  State SessionState   +  Id SessionId   +  RemoteIp string   +} + +type TimeoutHandler struct {   +  callback func(Session)   +  session Session   +  duration int   +  timer *timer.Timer   +} +``` + +`Session` 标识连接会话,内有表示会话 ID、临近的连接点的 IP 和当前会话状态的字段。 + +`TimeoutHandler` 包含回调函数、对应的会话、持续时间和指向调度计时器的指针。 + +每一个临近连接点的会话都包含一个保存调度 `TimeoutHandler` 的全局映射。 + +``` +SessionTimeout map[Session]*TimeoutHandler +``` + +下面方法注册和取消超时: + +```go +// schedules the timeout callback function.   +func (timeout* TimeoutHandler) Register() {   +  timeout.timer = time.AfterFunc(time.Duration(timeout.duration) * time.Second, func() {   +    timeout.callback(timeout.session)   +  })   +} + +func (timeout* TimeoutHandler) Cancel() {   +  if timeout.timer == nil {   +    return   +  }   +  timeout.timer.Stop()   +} +``` + +你可以使用类似下面的方法来创建和存储超时: + +```go +func CreateTimeoutHandler(callback func(Session), session Session, duration int) *TimeoutHandler {   +  if sessionTimeout[session] == nil {   +    sessionTimeout[session] := new(TimeoutHandler)   +  }   +    +  timeout = sessionTimeout[session]   +  timeout.session = session   +  timeout.callback = callback   +  timeout.duration = duration   +  return timeout   +} +``` + +超时处理程序创建后,会在经过了设置的 `duration` 时间(秒)后执行回调函数。然而,有些事件会使你重新调度一个超时处理程序(与 `SYN` 状态时的处理一样,每 3 秒一次)。 + +为此,你可以让回调函数重新调度一次超时: + +```go +func synCallback(session Session) {   +  sendSynPacket(session) + +  // reschedules the same callback.   +  newTimeout := NewTimeoutHandler(synCallback, session, SYN_TIMEOUT_DURATION)   +  newTimeout.Register() + +  sessionTimeout[state] = newTimeout   +} +``` + +这次回调在新的超时处理程序中重新调度自己,并更新全局映射 `sessionTimeout`。 + +### 数据竞争和引用 + +你的解决方案已经有了。可以通过检查计时器到期后超时回调是否执行来进行一个简单的测试。为此,注册一个超时,休眠 `duration` 秒,然后检查是否执行了回调的处理。执行这个测试后,最好取消预定的超时时间(因为它会重新调度),这样才不会在下次测试时产生副作用。 + +令人惊讶的是,这个简单的测试发现了这个解决方案中的一个问题。使用 `cancel` 方法来取消超时并没有正确处理。以下顺序的事件会导致数据资源竞争: + +1. 你有一个已调度的超时处理程序。 +2. 线程 1: + 1. 你接收到一个控制数据包,现在你要取消已注册的超时并切换到下一个会话状态(如发送 `SYN` 后接收到一个 `SYN-ACK`) + 2. 你调用了 `timeout.Cancel()`,这个函数调用了 `timer.Stop()`。(请注意,Golang 计时器的停止不会终止一个已过期的计时器。) +3. 线程 2: + 1. 在取消调用之前,计时器已过期,回调即将执行。 + 2. 执行回调,它调度一次新的超时并更新全局映射。 +4. 线程 1: + 1. 切换到新的会话状态并注册新的超时,更新全局映射。 + +两个线程并发地更新超时映射。最终结果是你无法取消注册的超时,然后你也会丢失对线程 2 重新调度的超时的引用。这导致处理程序在一段时间内持续执行和重新调度,出现非预期行为。 + +### 锁也解决不了问题 + +使用锁也不能完全解决问题。如果你在处理所有事件和执行回调之前加锁,它仍然不能阻止一个过期的回调运行: + +```go +func (timeout* TimeoutHandler) Register() {   +  timeout.timer = time.AfterFunc(time.Duration(timeout.duration) * time._Second_, func() {   +    stateLock.Lock()   +    defer stateLock.Unlock() + +    timeout.callback(timeout.session)   +  })   +} +``` + +现在的区别就是全局映射的更新是同步的,但是这还是不能阻止在你调用 `timeout.Cancel()` 后回调的执行 —— 这种情况出现在调度计时器过期了但是还没有拿到锁的时候。你还是会丢失一个已注册的超时的引用。 + +### 使用取消通道 + +你可以使用取消通道,而不必依赖不能阻止到期的计时器执行的 golang 函数 `timer.Stop()`。 + +这是一个略有不同的方法。现在你可以不用再通过回调进行递归地重新调度;而是注册一个死循环,这个循环接收到取消信号或超时事件时终止。 + +新的 `Register()` 产生一个新的 go 线程,这个线程在超时后执行你的回调,并在前一个超时执行后调度新的超时。返回给调用方一个取消通道,用来控制循环的终止。 + +```go +func (timeout *TimeoutHandler) Register() chan struct{} {   +  cancelChan := make(chan struct{})   +    +  go func () {   +    select {   +    case _ = <- cancelChan:   +      return   +    case _ = <- time.AfterFunc(time.Duration(timeout.duration) * time.Second):   +      func () {   +        stateLock.Lock()   +        defer stateLock.Unlock() + +        timeout.callback(timeout.session)   +      } ()   +    }   +  } () + +  return cancelChan   +} + +func (timeout* TimeoutHandler) Cancel() {   +  if timeout.cancelChan == nil {   +    return   +  }   +  timeout.cancelChan <- struct{}{}   +} +``` + +这个方法给你注册的所有超时提供了取消通道。一个取消调用向通道发送一个空结构体并触发取消操作。然而,这并不能解决前面的问题;可能在你通过通道取消之前以及超时线程拿到锁之前,超时时间就已经到了。 + +这里的解决方案是,在拿到锁**之后**,检查一下超时范围内的取消通道。 + +```go +  case _ = <- time.AfterFunc(time.Duration(timeout.duration) * time.Second):   +    func () {   +      stateLock.Lock()   +      defer stateLock.Unlock()   +      +      select {   +      case _ = <- handler.cancelChan:   +        return   +      default:   +        timeout.callback(timeout.session)   +      }   +    } ()   +  } +``` + +最终,这可以确保在拿到锁之后执行回调,不会触发取消操作。 + +### 小心死锁 + +这个解决方案看起来有效;但是还是有个隐患:[死锁][10]。 + +请阅读上面的代码,试着自己找到它。考虑下描述的所有函数的并发调用。 + +这里的问题在取消通道本身。我们创建的是无缓冲通道,即发送的是阻塞调用。当你在一个超时处理程序中调用取消函数时,只有在该处理程序被取消后才能继续处理。问题出现在,当你有多个调用请求到同一个取消通道时,这时一个取消请求只被处理一次。当多个事件同时取消同一个超时处理程序时,如连接断开或控制包事件,很容易出现这种情况。这会导致死锁,可能会使应用程序停机。 + +![gophers on a wire, talking][11] + +*有人在听吗?* + +(已获得 Trevor Forrey 授权。) + +这里的解决方案是创建通道时指定缓存大小至少为 1,这样向通道发送数据就不会阻塞,也显式地使发送变成非阻塞的,避免了并发调用。这样可以确保取消操作只发送一次,并且不会阻塞后续的取消调用。 + +```go +func (timeout* TimeoutHandler) Cancel() {   +  if timeout.cancelChan == nil {   +    return   +  }   +    +  select {   +  case timeout.cancelChan <- struct{}{}:   +  default:   +    // can’t send on the channel, someone has already requested the cancellation.   +  }   +} +``` + +### 总结 + +在实践中你学到了并发操作时出现的常见错误。由于其不确定性,即使进行大量的测试,也不容易发现这些问题。下面是我们在最初的实现中遇到的三个主要问题: + +#### 在非同步的情况下更新共享数据 + +这似乎是个很明显的问题,但如果并发更新发生在不同的位置,就很难发现。结果就是数据竞争,由于一个更新会覆盖另一个,因此对同一数据的多次更新中会有某些更新丢失。在我们的案例中,我们是在同时更新同一个共享映射里的调度超时引用。(有趣的是,如果 Go 检测到在同一个映射对象上的并发读写,会抛出致命错误 — 你可以尝试下运行 Go 的[数据竞争检测器](https://golang.org/doc/articles/race_detector.html))。这最终会导致丢失超时引用,且无法取消给定的超时。当有必要时,永远不要忘记使用锁。 + +![gopher assembly line][13] + +*不要忘记同步 gopher 们的工作* + +#### 缺少条件检查 + +在不能仅依赖锁的独占性的情况下,就需要进行条件检查。我们遇到的场景稍微有点不一样,但是核心思想跟[条件变量][14]是一样的。假设有个一个生产者和多个消费者使用一个共享队列的经典场景,生产者可以将一个元素添加到队列并唤醒所有消费者。这个唤醒调用意味着队列中的数据是可访问的,并且由于队列是共享的,消费者必须通过锁来进行同步访问。每个消费者都可能拿到锁;然而,你仍然需要检查队列中是否有元素。因为在你拿到锁的瞬间并不知道队列的状态,所以还是需要进行条件检查。 + +在我们的例子中,超时处理程序收到了计时器到期时发出的“唤醒”调用,但是它仍需要检查是否已向其发送了取消信号,然后才能继续执行回调。 + +![gopher boot camp][15] + +*如果你要唤醒多个 gopher,可能就需要进行条件检查* + +#### 死锁 + +当一个线程被卡住,无限期地等待一个唤醒信号,但是这个信号永远不会到达时,就会发生这种情况。死锁可以通过让你的整个程序停机来彻底杀死你的应用。 + +在我们的案例中,这种情况的发生是由于多次发送请求到一个非缓冲且阻塞的通道。这意味着向通道发送数据只有在从这个通道接收完数据后才能返回。我们的超时线程循环迅速从取消通道接收信号;然而,在接收到第一个信号后,它将跳出循环,并且再也不会从这个通道读取数据。其他的调用会一直被卡住。为避免这种情况,你需要仔细检查代码,谨慎处理阻塞调用,并确保不会发生线程饥饿。我们例子中的解决方法是使取消调用成为非阻塞调用 — 我们不需要阻塞调用。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/go-common-pitfalls + +作者:[Eduardo Ferreira][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/edufgf +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/go-golang.png?itok=OAW9BXny (Goland gopher illustration) +[2]: http://mode.net +[3]: https://en.wikipedia.org/wiki/Metrics_%28networking%29 +[4]: https://people.ece.cornell.edu/atang/pub/15/HALO_ToN.pdf +[5]: https://en.wikipedia.org/wiki/Point_of_presence +[6]: https://opensource.com/sites/default/files/uploads/image2_0_3.png (latency computation graph) +[7]: https://opensource.com/sites/default/files/uploads/image3_0.png (finite state machine diagram) +[8]: https://golang.org/ +[9]: https://opensource.com/sites/default/files/uploads/image4.png (gophers hacking together) +[10]: https://en.wikipedia.org/wiki/Deadlock +[11]: https://opensource.com/sites/default/files/uploads/image5_0_0.jpg (gophers on a wire, talking) +[12]: https://golang.org/doc/articles/race_detector.html +[13]: https://opensource.com/sites/default/files/uploads/image6.jpeg (gopher assembly line) +[14]: https://en.wikipedia.org/wiki/Monitor_%28synchronization%29#Condition_variables +[15]: https://opensource.com/sites/default/files/uploads/image7.png (gopher boot camp) diff --git a/published/202001/20191211 Enable your Python game player to run forward and backward.md b/published/202001/20191211 Enable your Python game player to run forward and backward.md new file mode 100644 index 0000000000..38d25cc1ab --- /dev/null +++ b/published/202001/20191211 Enable your Python game player to run forward and backward.md @@ -0,0 +1,467 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11819-1.html) +[#]: subject: (Enable your Python game player to run forward and backward) +[#]: via: (https://opensource.com/article/19/12/python-platformer-game-run) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +使你的 Python 游戏玩家能够向前和向后跑 +====== +> 使用 Pygame 模块来使你的 Python 平台开启侧滚效果,来让你的玩家自由奔跑。 + +![](https://img.linux.net.cn/data/attachment/album/202001/25/220636x5mabbl47xvtsk55.jpg) + +这是仍在进行中的关于使用 Pygame 模块来在 Python 3 中在创建电脑游戏的第九部分。先前的文章是: + + * [通过构建一个简单的掷骰子游戏去学习怎么用 Python 编程][2] + * [使用 Python 和 Pygame 模块构建一个游戏框架][3] + * [如何在你的 Python 游戏中添加一个玩家][4] + * [用 Pygame 使你的游戏角色移动起来][5] + * [如何向你的 Python 游戏中添加一个敌人][6] + * [在 Pygame 游戏中放置平台][12] + * [在你的 Python 游戏中模拟引力][7] + * [为你的 Python 平台类游戏添加跳跃功能][8] + +在这一系列关于使用 [Pygame][10] 模块来在 [Python 3][9] 中创建电脑游戏的先前文章中,你已经设计了你的关卡设计布局,但是你的关卡的一些部分可能已近超出你的屏幕的可视区域。在平台类游戏中,这个问题的普遍解决方案是,像术语“侧滚side-scroller”表明的一样,滚动。 + +滚动的关键是当玩家精灵接近屏的幕边缘时,使在玩家精灵周围的平台移动。这样给予一种错觉,屏幕是一个在游戏世界中穿梭追拍的"摄像机"。 + +这个滚动技巧需要两个在屏幕边缘的绝对区域,在绝对区域内的点处,在世界滚动期间,你的化身静止不动。 + +### 在侧滚动条中放置卷轴 + +如果你希望你的玩家能够后退,你需要一个触发点来向前和向后。这两个点仅仅是两个变量。设置它们各个距各个屏幕边缘大约 100 或 200 像素。在你的设置部分中创建变量。在下面的代码中,前两行用于上下文说明,所以仅需要添加这行后的代码: + +``` +player_list.add(player) +steps = 10 +forwardX  = 600 +backwardX = 230 +``` + +在主循环中,查看你的玩家精灵是否在 `forwardx` 或 `backwardx` 滚动点处。如果是这样,向左或向右移动使用的平台,取决于世界是向前或向后移动。在下面的代码中,代码的最后三行仅供你参考: + +``` +        # scroll the world forward +        if player.rect.x >= forwardx: +                scroll = player.rect.x - forwardx +                player.rect.x = forwardx +                for p in plat_list: +                        p.rect.x -= scroll + +        # scroll the world backward +        if player.rect.x <= backwardx: +                scroll = backwardx - player.rect.x +                player.rect.x = backwardx +                for p in plat_list: +                        p.rect.x += scroll + +        ## scrolling code above +    world.blit(backdrop, backdropbox) +    player.gravity() # check gravity +    player.update() +``` + +启动你的游戏,并尝试它。 + +![Scrolling the world in Pygame][11] + +滚动像预期的一样工作,但是你可能注意到一个发生的小问题,当你滚动你的玩家和非玩家精灵周围的世界时:敌人精灵不随同世界滚动。除非你要你的敌人精灵要无休止地追逐你的玩家,你需要修改敌人代码,以便当你的玩家快速撤退时,敌人被留在后面。 + +### 敌人卷轴 + +在你的主循环中,你必须对卷轴平台为你的敌人的位置的应用相同的规则。因为你的游戏世界将(很可能)有不止一个敌人在其中,该规则应该被应用于你的敌人列表,而不是一个单独的敌人精灵。这是分组类似元素到列表中的优点之一。 + +前两行用于上下文注释,所以只需添加这两行后面的代码到你的主循环中: + +``` +    # scroll the world forward +    if player.rect.x >= forwardx: +        scroll = player.rect.x - forwardx +        player.rect.x = forwardx +        for p in plat_list: +            p.rect.x -= scroll +        for e in enemy_list: +            e.rect.x -= scroll +``` + +来滚向另一个方向: + +``` +    # scroll the world backward +    if player.rect.x <= backwardx: +        scroll = backwardx - player.rect.x +        player.rect.x = backwardx +        for p in plat_list: +            p.rect.x += scroll +        for e in enemy_list: +            e.rect.x += scroll +``` + +再次启动游戏,看看发生什么。 + +这里是到目前为止你已经为这个 Python 平台所写所有的代码: + +``` +#!/usr/bin/env python3 +# draw a world +# add a player and player control +# add player movement +# add enemy and basic collision +# add platform +# add gravity +# add jumping +# add scrolling + +# GNU All-Permissive License +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. + +import pygame +import sys +import os + +''' +Objects +''' + +class Platform(pygame.sprite.Sprite): + # x location, y location, img width, img height, img file + def __init__(self,xloc,yloc,imgw,imgh,img): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(os.path.join('images',img)).convert() + self.image.convert_alpha() + self.rect = self.image.get_rect() + self.rect.y = yloc + self.rect.x = xloc + +class Player(pygame.sprite.Sprite): + ''' + Spawn a player + ''' + def __init__(self): + pygame.sprite.Sprite.__init__(self) + self.movex = 0 + self.movey = 0 + self.frame = 0 + self.health = 10 + self.collide_delta = 0 + self.jump_delta = 6 + self.score = 1 + self.images = [] + for i in range(1,9): + img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert() + img.convert_alpha() + img.set_colorkey(ALPHA) + self.images.append(img) + self.image = self.images[0] + self.rect = self.image.get_rect() + + def jump(self,platform_list): + self.jump_delta = 0 + + def gravity(self): + self.movey += 3.2 # how fast player falls + + if self.rect.y > worldy and self.movey >= 0: + self.movey = 0 + self.rect.y = worldy-ty + + def control(self,x,y): + ''' + control player movement + ''' + self.movex += x + self.movey += y + + def update(self): + ''' + Update sprite position + ''' + + self.rect.x = self.rect.x + self.movex + self.rect.y = self.rect.y + self.movey + + # moving left + if self.movex < 0: + self.frame += 1 + if self.frame > ani*3: + self.frame = 0 + self.image = self.images[self.frame//ani] + + # moving right + if self.movex > 0: + self.frame += 1 + if self.frame > ani*3: + self.frame = 0 + self.image = self.images[(self.frame//ani)+4] + + # collisions + enemy_hit_list = pygame.sprite.spritecollide(self, enemy_list, False) + for enemy in enemy_hit_list: + self.health -= 1 + #print(self.health) + + plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) + for p in plat_hit_list: + self.collide_delta = 0 # stop jumping + self.movey = 0 + if self.rect.y > p.rect.y: + self.rect.y = p.rect.y+ty + else: + self.rect.y = p.rect.y-ty + + ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) + for g in ground_hit_list: + self.movey = 0 + self.rect.y = worldy-ty-ty + self.collide_delta = 0 # stop jumping + if self.rect.y > g.rect.y: + self.health -=1 + print(self.health) + + if self.collide_delta < 6 and self.jump_delta < 6: + self.jump_delta = 6*2 + self.movey -= 33 # how high to jump + self.collide_delta += 6 + self.jump_delta += 6 + +class Enemy(pygame.sprite.Sprite): + ''' + Spawn an enemy + ''' + def __init__(self,x,y,img): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(os.path.join('images',img)) + self.movey = 0 + #self.image.convert_alpha() + #self.image.set_colorkey(ALPHA) + self.rect = self.image.get_rect() + self.rect.x = x + self.rect.y = y + self.counter = 0 + + + def move(self): + ''' + enemy movement + ''' + distance = 80 + speed = 8 + + self.movey += 3.2 + + if self.counter >= 0 and self.counter <= distance: + self.rect.x += speed + elif self.counter >= distance and self.counter <= distance*2: + self.rect.x -= speed + else: + self.counter = 0 + + self.counter += 1 + + if not self.rect.y >= worldy-ty-ty: + self.rect.y += self.movey + + plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) + for p in plat_hit_list: + self.movey = 0 + if self.rect.y > p.rect.y: + self.rect.y = p.rect.y+ty + else: + self.rect.y = p.rect.y-ty + + ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) + for g in ground_hit_list: + self.rect.y = worldy-ty-ty + + +class Level(): + def bad(lvl,eloc): + if lvl == 1: + enemy = Enemy(eloc[0],eloc[1],'yeti.png') # spawn enemy + enemy_list = pygame.sprite.Group() # create enemy group + enemy_list.add(enemy) # add enemy to group + + if lvl == 2: + print("Level " + str(lvl) ) + + return enemy_list + + def loot(lvl,lloc): + print(lvl) + + def ground(lvl,gloc,tx,ty): + ground_list = pygame.sprite.Group() + i=0 + if lvl == 1: + while i < len(gloc): + ground = Platform(gloc[i],worldy-ty,tx,ty,'ground.png') + ground_list.add(ground) + i=i+1 + + if lvl == 2: + print("Level " + str(lvl) ) + + return ground_list + + def platform(lvl,tx,ty): + plat_list = pygame.sprite.Group() + ploc = [] + i=0 + if lvl == 1: + ploc.append((0,worldy-ty-128,3)) + ploc.append((300,worldy-ty-256,3)) + ploc.append((500,worldy-ty-128,4)) + + while i < len(ploc): + j=0 + while j <= ploc[i][2]: + plat = Platform((ploc[i][0]+(j*tx)),ploc[i][1],tx,ty,'ground.png') + plat_list.add(plat) + j=j+1 + print('run' + str(i) + str(ploc[i])) + i=i+1 + + if lvl == 2: + print("Level " + str(lvl) ) + + return plat_list + +''' +Setup +''' +worldx = 960 +worldy = 720 + +fps = 40 # frame rate +ani = 4 # animation cycles +clock = pygame.time.Clock() +pygame.init() +main = True + +BLUE = (25,25,200) +BLACK = (23,23,23 ) +WHITE = (254,254,254) +ALPHA = (0,255,0) + +world = pygame.display.set_mode([worldx,worldy]) +backdrop = pygame.image.load(os.path.join('images','stage.png')).convert() +backdropbox = world.get_rect() +player = Player() # spawn player +player.rect.x = 0 +player.rect.y = 0 +player_list = pygame.sprite.Group() +player_list.add(player) +steps = 10 +forwardx = 600 +backwardx = 230 + +eloc = [] +eloc = [200,20] +gloc = [] +#gloc = [0,630,64,630,128,630,192,630,256,630,320,630,384,630] +tx = 64 #tile size +ty = 64 #tile size + +i=0 +while i <= (worldx/tx)+tx: + gloc.append(i*tx) + i=i+1 + +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) +plat_list = Level.platform( 1,tx,ty ) + +''' +Main loop +''' +while main == True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit(); sys.exit() + main = False + + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_LEFT or event.key == ord('a'): + print("LEFT") + player.control(-steps,0) + if event.key == pygame.K_RIGHT or event.key == ord('d'): + print("RIGHT") + player.control(steps,0) + if event.key == pygame.K_UP or event.key == ord('w'): + print('jump') + + if event.type == pygame.KEYUP: + if event.key == pygame.K_LEFT or event.key == ord('a'): + player.control(steps,0) + if event.key == pygame.K_RIGHT or event.key == ord('d'): + player.control(-steps,0) + if event.key == pygame.K_UP or event.key == ord('w'): + player.jump(plat_list) + + if event.key == ord('q'): + pygame.quit() + sys.exit() + main = False + + # scroll the world forward + if player.rect.x >= forwardx: + scroll = player.rect.x - forwardx + player.rect.x = forwardx + for p in plat_list: + p.rect.x -= scroll + for e in enemy_list: + e.rect.x -= scroll + + # scroll the world backward + if player.rect.x <= backwardx: + scroll = backwardx - player.rect.x + player.rect.x = backwardx + for p in plat_list: + p.rect.x += scroll + for e in enemy_list: + e.rect.x += scroll + + world.blit(backdrop, backdropbox) + player.gravity() # check gravity + player.update() + player_list.draw(world) #refresh player position + enemy_list.draw(world) # refresh enemies + ground_list.draw(world) # refresh enemies + plat_list.draw(world) # refresh platforms + for e in enemy_list: + e.move() + pygame.display.flip() + clock.tick(fps) +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/python-platformer-game-run + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/open_gaming_games_roundup_news.png?itok=KM0ViL0f (Gaming artifacts with joystick, GameBoy, paddle) +[2]: https://linux.cn/article-9071-1.html +[3]: https://linux.cn/article-10850-1.html +[4]: https://linux.cn/article-10858-1.html +[5]: https://linux.cn/article-10874-1.html +[6]: https://linux.cn/article-10883-1.html +[7]: https://linux.cn/article-11780-1.html +[8]: https://linux.cn/article-11790-1.html +[9]: https://www.python.org/ +[10]: https://www.pygame.org/news +[11]: https://opensource.com/sites/default/files/uploads/pygame-scroll.jpg (Scrolling the world in Pygame) +[12]:https://linux.cn/article-10902-1.html diff --git a/published/202001/20191214 Make VLC More Awesome With These Simple Tips.md b/published/202001/20191214 Make VLC More Awesome With These Simple Tips.md new file mode 100644 index 0000000000..3bb170df03 --- /dev/null +++ b/published/202001/20191214 Make VLC More Awesome With These Simple Tips.md @@ -0,0 +1,128 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11776-1.html) +[#]: subject: (Make VLC More Awesome With These Simple Tips) +[#]: via: (https://itsfoss.com/simple-vlc-tips/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +这些简单的技巧使 VLC 更加出色 +====== + +![](https://img.linux.net.cn/data/attachment/album/202001/13/090635eu9va9999rr4ue92.jpeg) + +如果 [VLC][1] 不是最好的播放器,那它也是[最好的开源视频播放器][2]之一。大多数人不知道的是,它不仅仅是视频播放器。 + +你可以进行许多复杂的任务,如直播视频、捕捉设备等。只需打开菜单,你就可以看到它有多少选项。 + +我们有一个详细的教程,讨论一些[专业的 VLC 技巧][3],但这些对于普通用户太复杂。 + +这就是为什么我要写另一篇文章的原因,来向你展示一些可以在 VLC 中使用的简单技巧。 + +### 使用这些简单技巧让 VLC 做更多事 + +让我们看看除了播放视频文件之外,你还可以使用 VLC 做什么。 + +#### 1、使用 VLC 观看 YouTube 视频 + +![][4] + +如果你不想在 [YouTube][5] 上观看令人讨厌的广告,或者只想体验没有打扰地观看 YouTube 视频,你可以使用 VLC。 + +是的,在 VLC 上流式传输 YouTube 视频是非常容易的。 + +只需启动 VLC 播放器,前往媒体设置,然后单击 ”Open Network Stream“ 或使用快捷方式 `CTRL + N`。 + +![][6] + +接下来,你只需要粘贴要观看的视频的 URL。有一些选项可以调整,但通常你无需担心这些。如果你好奇,你可以点击 ”Advanced options“ 来探索。 + +你还可以通过这种方式向 YouTube 视频添加字幕。然而,[一个更简单的带字幕观看 Youtube 视频的办法是使用 Penguin 字幕播放器][7]。 + +#### 2、将视频转换为不同格式 + +![][8] + +你可以[在 Linux 命令行使用 ffmpeg 转换视频][9]。你还可以使用图形工具,如 [HandBrake 转换视频格式][10]。 + +但是,如果你不想用一个单独的应用来转码视频,你可以使用 VLC 播放器来完成该工作。 + +为此,只需点击 VLC 上的媒体选项,然后单击 “Convert/Save”,或者在 VLC 播放器处于活动状态时按下快捷键 `CTRL + R`。接下来,你需要从计算机/硬盘或者 URL 导入你想保存/转换的的视频。 + +不管是什么来源,只需选择文件后点击 “Convert/Save” 按钮。你现在会看到另外一个窗口可以更改 “Profile” 设置。点击并选择你想转换的格式(并保存)。 + +你还可以在转换之前通过在屏幕底部设置目标文件夹来更改转换文件的存储路径。 + +#### 3、从源录制音频/视频 + +![Vlc Advanced Controls][11] + +你是否想在 VLC 播放器中录制正在播放的音频/视频? + +如果是的话,有一个简单的解决方案。只需通过 “View”,然后点击 “Advanced Controls”。 + +完成后,你会看到一个新按钮(包括 VLC 播放器中的红色录制按钮)。 + +#### 4、自动下载字幕 + +![][12] + +是的,你可以[使用 VLC 自动下载字幕][13]。你甚至不必在单独的网站上查找字幕。你只需点击 +“View”->“VLSub”。 + +默认情况下,它是禁用的,因此当你单击该选项时,它会被激活,并允许你搜索/下载想要的字幕。 + +[VLC 还能让你使用简单的键盘快捷键同步字幕][14] + +#### 5、截图 + +![][15] + +你可以在观看视频时使用 VLC 获取一些视频的截图/图像。你只需在视频播放/暂停时右击播放器,你会看到一组选项,点击 “Video”->“Take Snapshot”。 + +如果安装了旧版本,你可能在右键时看到截图选项。 + +#### 额外技巧:给视频添加音频/视频效果 + +在菜单中,进入 “Tools” 选项。单击 “Effects and Filters”,或者在 VLC 播放器窗口中按 `CTRL + E` 打开选项。 + +好了,你可以观察你给视频添加的音频和视频效果了。你也许无法实时看到效果,因此你需要调整并保存来看发生了什么。 + +![][16] + +我建议在修改视频之前保存一份原始视频备份。 + +#### 你最喜欢的 VLC 技巧是什么? + +我分享了一些我最喜欢的 VLC 技巧。你知道什么你经常使用的很酷的 VLC 技巧吗?为什么不和我们分享呢?我可以把它添加到列表中。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/simple-vlc-tips/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://www.videolan.org/ +[2]: https://itsfoss.com/video-players-linux/ +[3]: https://itsfoss.com/vlc-pro-tricks-linux/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/youtube-video-stream.jpg?ssl=1 +[5]: https://www.youtube.com/ +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/youtube-video-play.jpg?ssl=1 +[7]: https://itsfoss.com/penguin-subtitle-player/ +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc-video-convert.jpg?ssl=1 +[9]: https://itsfoss.com/ffmpeg/ +[10]: https://itsfoss.com/handbrake/ +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc-advanced-controls.png?ssl=1 +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc-subtitles-automatic.png?ssl=1 +[13]: https://itsfoss.com/download-subtitles-automatically-vlc-media-player-ubuntu/ +[14]: https://itsfoss.com/how-to-synchronize-subtitles-with-movie-quick-tip/ +[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc-snapshot.png?ssl=1 +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc-effects-screenshot.jpg?ssl=1 diff --git a/published/202001/20191215 How to Add Border Around Text in GIMP.md b/published/202001/20191215 How to Add Border Around Text in GIMP.md new file mode 100644 index 0000000000..6a59c6ac66 --- /dev/null +++ b/published/202001/20191215 How to Add Border Around Text in GIMP.md @@ -0,0 +1,139 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11799-1.html) +[#]: subject: (How to Add Border Around Text in GIMP) +[#]: via: (https://itsfoss.com/gimp-text-outline/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +在 GIMP 中如何在文本周围添加边框 +====== + +![](https://img.linux.net.cn/data/attachment/album/202001/19/230506fzkyktqglfcyzkuh.jpg) + +这个简单的教程介绍了在 [GIMP][1] 中显示文本的轮廓的步骤。文本轮廓可以帮助你在其它颜色下高亮显示该文本。 + +![Outlined Text created in GIMP][2] + +让我们看看如何在你的文本周围添加一个边框。 + +### 在 GIMP 中添加文本轮廓 + +整个过程可以用这些简单的步骤描述: + +* 创建文本,并复制它的轮廓路径 +* 添加一层新的透明层,并添加轮廓路径到透明层中 +* 更改轮廓的大小,给它添加一种不同的颜色 + +这就是全部的东西。不用担心,我将使用适当地截图详细的展示每个步骤。按照这个教程,你应该能够为文本添加轮廓,即使你在此之前从未使用过 GIMP 。 + +仅需要确保你已经 [在 Linux 上安装 GIMP][3],或者也可以使用的其它任何操作系统。 + +这篇教程在 GIMP 2.10 版本下演示。 + +#### 步骤 1: 创建你的主要文本,并复制它的轮廓 + +打开 GIMP ,并通过转到 “菜单 -> 文件 -> 新建” 来创建一个新的文件。你应该可以使用 `Ctrl+N` 键盘快捷键。 + +![Create New File][4] + +你可以在这里选择画布的大小。你也可以选择要白色背景或一种透明背景。它在 “高级选项 -> 颜色” 配置文件下。 + +我选择默认的白色背景。它在以后能够更改。 + +现在从左边栏的工具箱中选择文本工具。 + +![Adding text in GIMP][5] + +写你想要的文本。你可以根据你的选择以更改文本的字体、大小和对齐方式。我保持这篇文章的文本的默认左对齐。 + +我故意为文本选择一种浅色,以便难于阅读。在这篇教程中我将添加一个深色轮廓到这个浅色的文本。 + +![Text added in GIMP][6] + +当你写完文本后,右键文本框并选择 “文本的路径” 。 + +![Right click on the text box and select ‘Path from Text’][7] + +#### 步骤 2: 添加一个带有文本轮廓的透明层 + +现在,转到顶部菜单,转到“层”,并添加一个新层。 + +![Use Shift+Ctrl+N to add a new layer][8] + +确保添加新层为透明的。你可以给它一个合适的名称,像“文本大纲”。单击确定来添加这个透明层。 + +![Add a transparent layer][9] + +再次转到菜单,这次转到 “选择” ,并单击 “来自路径” 。你将看到你的文本应该被高亮显示。 + +![Go to Select and choose From Path][10] + +总的来说,你只创建了一个透明层,它有像你的原文一样相同的文本(但是透明)。现在你需要做的是在这个层上增加文本的大小。 + +#### 步骤 3: 通过增加它的大小和更改它的颜色来添加文本轮廓 + +为此,再次在菜单中转到 “选择” ,这次选择 “增加”。这将允许增大透明层上的文本的大小。 + +![Grow the selection on the additional layer][11] + +以 5 或 10 像素增加,或者你喜欢的任意像素。 + +![Grow it by 5 or 10 pixel][12] + +你选择需要做是使用一种你选择的颜色来填充这个扩大的选择区。因为我的原文是浅色,在这里我将为轮廓使用背景色。 + +如果尚未选择的话,先选择你的主图像层。这些层在右侧栏中可视。然后转到工具箱并选择油漆桶工具。为你的轮廓选择想要的颜色。 + +选择使用该工具来填充黑色到你的选择区。记住。你填充文本外部的轮廓,而不是文本本身。 + +![Fill the outline of the text with a different color][13] + +在这里你完成了很多。使用 `Ctrl+Shift+A` 来取消你当前的选择区。 + +![Outline added to the text][14] + +如此,你现在已经在 GIMP 中成功地添加轮廓到你的文本。它是在白色背景中,如果你想要一个透明背景,只需要在右侧栏的图层菜单中删除背景层。 + +![Remove the white background layer if you want a transparent background][15] + +如果你对结果感到满意,保存文件未 PNG 文件(来保留透明背景),或你喜欢的任何文件格式。 + +### 你使它工作了吗? + +就这样。这就是你在 GIMP 中为添加一个文本轮廓而需要做的全部工作。 + +我希望你发现这个 GIMP 教程有帮助。你可能想查看另一个 [关于在 GIMP 中添加一个水印的简单教程][16]。 + +如果你有问题或建议,请在下面自由留言。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/gimp-text-outline/ + +作者:[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://www.gimp.org/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/outlined_text_GIMP.png?ssl=1 +[3]: https://itsfoss.com/gimp-2-10-release/ +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/12/create_outline_text_gimp_1.jpeg?ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_2.jpg?ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp-3.jpg?ssl=1 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_4.jpg?ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_5.jpg?ssl=1 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_6.jpg?ssl=1 +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_7.jpg?ssl=1 +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_8.jpg?ssl=1 +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_9.jpg?ssl=1 +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_10.jpg?ssl=1 +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_11.jpg?ssl=1 +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_12.jpg?ssl=1 +[16]: https://itsfoss.com/add-watermark-gimp-linux/ diff --git a/published/202001/20191217 App Highlight- Open Source Disk Partitioning Tool GParted.md b/published/202001/20191217 App Highlight- Open Source Disk Partitioning Tool GParted.md new file mode 100644 index 0000000000..088b578c82 --- /dev/null +++ b/published/202001/20191217 App Highlight- Open Source Disk Partitioning Tool GParted.md @@ -0,0 +1,118 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11770-1.html) +[#]: subject: (App Highlight: Open Source Disk Partitioning Tool GParted) +[#]: via: (https://itsfoss.com/gparted/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +应用推荐:开源磁盘分区工具 GParted +====== + +![](https://img.linux.net.cn/data/attachment/album/202001/10/220015lp58jjjt22xfppjj.jpg) + +> GParted 是一个可用于 Linux 发行版的非常受欢迎且免费的分区编辑器。在这里,我们简要地介绍一下它提供的功能。 + +### GParted:一个自由开源的图形化分区管理器 + +![][1] + +GParted 无疑是 [Linux 下的最好的分区管理器][2]之一。用户界面非常简单而可以完成任务。 + +在某些情况下,你最终还是会使用 [GParted][3] 来修复或格式化你的 USB 驱动器。我有一个[在 Ubuntu 中使用“磁盘”应用程序不能格式化的 USB 磁盘][4],而这是 GParted 用来救援的地方。 + +所以,它是一个非常有用的工具,有很多出色的功能。让我为你们重点介绍一下。 + +> 警告! +> +> 进行磁盘分区是一件危险的工作。除非绝对必要,否则不要做。否则,你可能最终擦除了整个磁盘。 + +### GParted 的功能 + +从简单地格式化任务到重要的分区任务,你可以使用 GParted 做很多事。我将使用一些屏幕截图突出关键功能,以帮助你在安装它前进一步了解它。 + +#### 创建分区表 + +你可以为新磁盘创建一个新的分区表,也可以擦除你现存的磁盘内容来修改分区表。 + +![][5] + +你能够选择 msdos、gpt、atari,以及更多类型的分区表。 + +#### 创建、移动、标记、删除和修改分区表 + +你可以使用 GParted 中一系列选项来轻松地创建、标记、删除或修改分区表。 + +![][6] + +当然,你必须要谨慎你要做的事情。 + +好的是,GParted 可以确保你不能直接应用任何更改 —— 在你点击应用更改之前,它将排队你选择的操作/任务,并在你执行前最后再要求确认一次。 + +顶部的对号标记符号 `✓` 可以让你确认更改,然后你的更改才会生效。 + +这是分区可用选项的另一个屏幕截图: + +![][7] + +#### 尝试数据救援 + +除了编辑分区以外,你也可以试着使用“尝试数据救援”功能以[在 Linux 中恢复丢失的数据][8],如下面的屏幕截图所示。 + +![][9] + +值得注意的是,默认情况下你没有安装此功能 —— 你只是能看到这个选项。因此,要使这个数据恢复功能可以正常工作,你必须使用下面的命令来单独地安装 gpart (在基于 Ubuntu/Debian 的发行版上): + +``` +sudo apt install gpart +``` + +除了所有这些关键功能以外,它支持各种存储设备和文件系统。你可以从其官方网站的[功能列表][10]中了解到更多信息。 + +### 在 Ubuntu 和其它 Linux 发行版上安装 GParted + +你可能已经预安装了 GParted 。所以,务必核实一下。如果你尚未安装它,则可以进入软件中心安装它。 + +如果你想使用终端,简单地键入下面的命令: + +``` +sudo apt install gparted +``` + +如上所述,如果你想要使用数据恢复选项,除了安装 gparted 软件包外,还应该安装 gpart 软件包。 + +如果你使用的是其它 Linux 发行版,你可以在各自的软件管理器中找到它,或者直接查看[官方下载操作说明][11]。 + +- [下载 GParted][11] + +### 总结 + +当涉及处理磁盘管理和分区时,GParted 是一个非常有用且重要的工具。但是,因为显而易见的原因,当你使用它时,你必须要小心。 + +你尝试过 GParted 吗?你在 Linux 上使用的其它哪个分区工具?请在下面的评论中分享你的经验。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/gparted/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-screenshot.png?ssl=1 +[2]: https://itsfoss.com/partition-managers-linux/ +[3]: https://gparted.org/ +[4]: https://itsfoss.com/format-usb-drive-sd-card-ubuntu/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-create-partition-table.png?ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-modify-partitions.png?ssl=1 +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-partition-options.png?ssl=1 +[8]: https://itsfoss.com/recover-deleted-files-linux/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-attempt-data-rescue-feature.png?ssl=1 +[10]: https://gparted.org/features.php +[11]: https://gparted.org/download.php diff --git a/published/202001/20191219 Kubernetes namespaces for beginners.md b/published/202001/20191219 Kubernetes namespaces for beginners.md new file mode 100644 index 0000000000..c45aa74d42 --- /dev/null +++ b/published/202001/20191219 Kubernetes namespaces for beginners.md @@ -0,0 +1,189 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11749-1.html) +[#]: subject: (Kubernetes namespaces for beginners) +[#]: via: (https://opensource.com/article/19/12/kubernetes-namespaces) +[#]: author: (Jessica Cherry https://opensource.com/users/jrepka) + +Kubernetes 命名空间入门 +====== + +> 命名空间是什么?你为什么需要它? + +![](https://img.linux.net.cn/data/attachment/album/202001/05/094542qnq3qc3nrkkrjanh.jpg) + +kubernetes 命名空间namespace是什么?正如 Shakespeare 以前写过的,我们所谓的命名空间,或者任何其他名字,就是虚拟集群。通过虚拟集群,意味着 kubernetes 可以在单个集群上提供多个 kubernetes 的集群,类似一个在其主机抽象出来的虚拟机。[kubernetes 文档][2] 中的解释: + +> kubernetes 在一个物理集群上提供了多个虚拟集群。这些虚拟集群被称为命名空间。 + +你为什么需要命名空间?一言以蔽之:隔离。 + +隔离有很多优点,如它提供了安全和干净的环境。如果你是基础设施的所属者,并且要为开发者提供环境,隔离就相当重要。你最不需要的就是,一个不熟悉你集群是如何搭建的人去修改系统配置 —— 这可能导致所有人都无法登录。 + +### 初始命名空间 + +一个集群的三个初始命名空间:`default`、`kube-system` 和 `kube-public`。虽然技术上你可以用这三个命名空间作部署,但我还是推荐你把这三个命名空间留作系统配置用,而不是你的项目。 + +* `Default` 用于某些没有指明命名空间的部署,这是一种快速创建混乱的做法,如果你在没有正确信息的情况下做了很多部署,将很难清理。我不会去动它,因为它只有这一个用途,而且在不止一种情况下误导过我。 +* `Kube-system` 是 Kubernetes 系统相关的所有对象组成的命名空间。任何对此命名空间的部署都可能是危险的操作,可能对系统本身造成不可挽回的破坏。没错,我试过;所以我不推荐。 +* `Kube-public` 所有人可读,但是这个命名空间是为系统保留的。 + +### 用命名空间来实现隔离 + +我用了多种方式通过命名空间来实现隔离。我经常用命名空间来把多个用户项目分割到不同的环境。这种方式可以有效防止跨项目的污染,因为命名空间提供了独立的环境。例如,用户可以安装不同版本的 Jenkins,如果它们的环境变量是在不同的命名空间,就不会冲突。 + +这种隔离对于清理也很有帮助。如果开发小组的多个项目突然被废弃,你可以用命令 `kubectl delete ns <$NAMESPACENAME>` 一键删除命名空间,清理命名空间内的所有东西。(请确认被删除的是正确的命名空间。我曾经在生产环境删除了错误的命名空间,这很不好。) + +如果你是基础设施所有者,请谨慎操作,因为这可能会引发其他团队的的故障或引发其他问题。例如,如果你创建了一个特定的命名空间,里面有特殊的额外安全的 DNS 功能,但是其他人删除了它,那么命名空间内的所有 pod 和它们运行的应用都会被清空。所有的**删除**操作在真正实施之前都应该由同事(通过 [GitOps][3])评审一下。 + +虽然官方文档不建议 [10 人以下团队][2] 使用多个命名空间,但出于架构需要,在我自己的集群上还是用了多个命名空间。集群越干净越好。 + +### 关于命名空间管理员应该知道的 + +首先,命名空间不能嵌套。部署只能在一个命名空间中进行。对于版本化项目,你不一定要用命名空间,你可以使用标签来区分有相同名字的版本化应用。命名空间使用配额来为不同的用户划分资源;例如,*某个命名空间最多能有 x 个节点*。最后,所有的命名空间对于该资源类型只能使用一个独一无二的名字。 + +### 命名空间命令操作 + +你需要安装 [Minikube][4]、[Helm][5] 和 [kubectl][6] 命令行,才能使用下面的命名空间命令。我的文章《[安全扫描你的 DevOps 流水线][7]》中有它们的安装教程,你也可以去每个项目的官方主页去找安装教程。我使用的是最新的 Minikube。手动安装很快,第一次就能成功运行。 + +获取你的第一组命名空间: + +``` +jess@Athena:~$ kubectl get namespace +NAME            STATUS   AGE +default         Active   5m23s +kube-public     Active   5m24s +kube-system     Active   5m24s +``` + +创建一个命名空间: + +``` +jess@Athena:~$ kubectl create namespace athena +namespace/athena created +``` + +现在开发者可以部署到你创建的命名空间了;例如,这里是一个简短的 Helm chart: + +``` +jess@Athena:~$ helm install teset-deploy stable/redis --namespace athena +NAME: teset-deploy +LAST DEPLOYED: Sat Nov 23 13:47:43 2019 +NAMESPACE: athena +STATUS: deployed +REVISION: 1 +TEST SUITE: None +NOTES: +` Please be patient while the chart is being deployed ` +Redis can be accessed via port 6379 on the following DNS names from within your cluster: + +teset-deploy-redis-master.athena.svc.cluster.local for read/write operations +teset-deploy-redis-slave.athena.svc.cluster.local for read-only operations +``` + +获取你的密码: + +``` +export REDIS_PASSWORD=$(kubectl get secret --namespace athena teset-deploy-redis -o jsonpath="{.data.redis-password}" | base64 --decode) +``` + +连接你的 redis 服务: + +1. 运行一个你可以作为客户端用的 Redis pod: + + ```bash + kubectl run --namespace athena teset-deploy-redis-client --rm --tty -i --restart='Never' \ +   --env REDIS_PASSWORD=$REDIS_PASSWORD \ + --image docker.io/bitnami/redis:5.0.7-debian-9-r0 -- bash + ``` + +2. 使用 Redis CLI 连接: + + ```bash + redis-cli -h teset-deploy-redis-master -a $REDIS_PASSWORD + redis-cli -h teset-deploy-redis-slave -a $REDIS_PASSWORD + ``` + +从集群外连接你的数据库: + +```bash +kubectl port-forward --namespace athena svc/teset-deploy-redis-master 6379:6379 & +redis-cli -h 127.0.0.1 -p 6379 -a $REDIS_PASSWORD +``` + +现在这一套部署已经完成了,你有一个在命名空间 `test-deploy` 中部署的 chart。 + +查看你的命名空间中有哪些 pod: + +``` +jess@Athena:~$ kubectl get pods --namespace athena +NAME                            READY   STATUS  RESTARTS   AGE +teset-deploy-redis-master-0   1/1       Running   0             2m38s +teset-deploy-redis-slave-0      1/1     Running   0             2m38s +teset-deploy-redis-slave-1      1/1     Running   0             90s +``` + +现在,你已经正式把你的应用隔离到了一个命名空间,创建了一个只在内部通信的虚拟集群。 + +一键删除所有东西: + +```bash +jess@Athena:~$ kubectl delete namespace athena +namespace "athena" deleted +``` + +因为这会删除应用的所有内部配置,所以这个删除操作可能会持续一段时间,持续时间取决于你的部署到底有多大。 + +再次检查一下所有东西是否被删除了: + +```bash +jess@Athena:~$ kubectl get pods --all-namespaces +NAMESPACE       NAME                            READY   STATUS  RESTARTS   AGE +kube-system   coredns-5644d7b6d9-4vxv6          1/1     Running   0             32m +kube-system   coredns-5644d7b6d9-t5wn7          1/1     Running   0             32m +kube-system   etcd-minikube                     1/1     Running   0             31m +kube-system   kube-addon-manager-minikube       1/1     Running   0             32m +kube-system   kube-apiserver-minikube           1/1     Running   0             31m +kube-system   kube-controller-manager-minikube  1/1     Running   0             31m +kube-system   kube-proxy-5tdmh                  1/1     Running   0             32m +kube-system   kube-scheduler-minikube           1/1     Running   0             31m +kube-system   storage-provisioner               1/1     Running   0             27m +``` + +这是一个所有 pod 及它们存在于的已知命名空间的列表。你可以看到,之前创建的应用和命名空间现在已经不在了。 + +### 命名空间实践 + +当前我是出于安全考虑才使用命名空间,如限制用户的权限。你可以限制所有的东西 —— 从哪些角色可以访问命名空间,到命名空间可使用的集群资源(CPU 等)的配额等级。例如,我通过资源配额和基于角色的访问控制role-based access control(RBAC)配置来确保只有允许的服务账号可以访问命名空间。 + +对于隔离方面的安全,我不希望我的私人 Jenkins 应用可以通过一个信任的本地网络被当做一个有公共 IP 地址的安全镜像来访问(我不得不假定,可能会被侵袭)。 + +如果你很难提前计算出到底要在你的云平台上部署多少节点(或者,就我而言,是在[搞崩][8]我的家庭服务器之前我能部署多少个),那么命名空间在预算方面也很有用。虽然这超出了本文的讨论范围,而且很复杂,但值得你去调研和使用来防止你的集群过分扩展。 + +### 总结 + +命名空间是一个很好的隔离项目和应用的方法。本文仅是一个关于命名空间的简短介绍,所以我建议你更深入地研究下命名空间,在你的实践中更多地去使用它们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/kubernetes-namespaces + +作者:[Jessica Cherry][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jrepka +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/ship_captain_devops_kubernetes_steer.png?itok=LAHfIpek (Ship captain sailing the Kubernetes seas) +[2]: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ +[3]: https://www.weave.works/blog/gitops-operations-by-pull-request +[4]: https://kubernetes.io/docs/tasks/tools/install-minikube/ +[5]: https://helm.sh/ +[6]: https://kubernetes.io/docs/tasks/tools/install-kubectl/ +[7]: https://opensource.com/article/19/7/security-scanning-your-devops-pipeline +[8]: https://en.wikipedia.org/wiki/Segmentation_fault diff --git a/published/202001/20191220 4 ways to volunteer this holiday season.md b/published/202001/20191220 4 ways to volunteer this holiday season.md new file mode 100644 index 0000000000..ca2c8fb8e0 --- /dev/null +++ b/published/202001/20191220 4 ways to volunteer this holiday season.md @@ -0,0 +1,69 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11803-1.html) +[#]: subject: (4 ways to volunteer this holiday season) +[#]: via: (https://opensource.com/article/19/12/ways-volunteer) +[#]: author: (John Jones https://opensource.com/users/johnjones4) + +假期志愿服务的 4 种方式 +====== + +> 想要洒播些节日的快乐吗?为开源组织做贡献,帮助有需要的社区。 + +![](https://img.linux.net.cn/data/attachment/album/202001/20/223730f7983z8atxp1tf4l.jpg) + +当领导者们配置人员和资源以做出积极改变时,就会产生社会影响。但是,许多社会努力都缺乏能够为这些改变者提供服务的技术资源。然而,有些组织通过将想要做出改变的开发人员与迫切需要更好技术的社区和非营利组织联系起来,来促进技术进步。这些组织通常为特定的受众提供服务,并招募特定种类的技术人员,它们有一个共同点:开源。 + +作为开发人员,我们出于各种原因试图加入开源社区。有些是为了专业发展,有些是为了能够与广阔的网络上令人印象深刻的技术人员合作,还有其他人则是因为他们清楚自己的贡献对于项目的成功的必要性。为什么不将你作为开发人员的才华投入到需要它的地方,而同时又为开源组织做贡献呢?以下组织是实现此目标的一些主要事例。 + +### Code for America + +“Code for America” 是在数字时代,政府如何依靠人民为人民服务的一个例子。通过其 Brigade Network,该组织在美国各个城市中组织了一个由志愿程序员、数据科学家、相关公民和设计师组成的全国联盟。这些本地分支机构定期举行聚会,向社区开放。这样既可以向小组推出新项目,又可以协调正在进行的工作。为了使志愿者与项目相匹配,该网站经常列出项目所需的特定技能,例如数据分析、内容创建和JavaScript。同时,Brigade 网站也会关注当地问题,分享自然灾害等共同经验,这些都可以促进成员之间的合作。例如,新奥尔良、休斯敦和坦帕湾团队合作开发了一个飓风响应网站,当灾难发生时,该网站可以快速响应不同的城市灾难情况。 + +想要加入该组织,请访问 [该网站][2] 获取 70 多个 Brigade 的清单,以及个人加入组织的指南。 + +### Code for Change + +“Code for Change” 显示了即使在高中时期,也可以为社会做贡献。印第安纳波利斯的一群高中开发爱好者成立了自己的俱乐部,他们通过创建针对社区问题的开源软件解决方案来回馈当地组织。“Code for Change” 鼓励当地组织提出项目构想,学生团体加入并开发完全自由和开源的解决方案。该小组已经开发了诸如“蓝宝石”之类的项目,该项目优化了当地难民组织的志愿者管理系统,并建立了民权委员会的投诉表格,方便公民就他们所关心的问题在网上发表意见。 + +有关如何在你自己的社区中创建 “Code for Change”,[访问他们的网站][3]。 + +### Python for Good/Ruby for Good + +“Python for Good” 和 “Ruby for Good” 是在俄勒冈州波特兰市和弗吉尼亚州费尔法克斯市举办的双年展活动,该活动将人们聚集在一起,为各自的社区开发和制定解决方案。 + +在周末,人们聚在一起聆听当地非营利组织的建议,并通过构建开源解决方案来解决他们的问题。 2017 年,“Ruby For Good” 参与者创建了 “Justice for Juniors”,该计划指导当前和以前被监禁的年轻人,并将他们重新融入社区。参与者还创建了 “Diaperbase”,这是一种库存管理系统,为美国各地的尿布库diaper bank所使用。这些活动的主要目标之一是将看似不同的行业和思维方式的组织和个人聚集在一起,以谋求共同利益。公司可以赞助活动,非营利组织可以提交项目构想,各种技能的人都可以注册参加活动并做出贡献。通过两岸(美国大西洋和太平洋东西海岸)的努力,“Ruby for Good” 和 “Python for Good” 一直恪守“使世界变得更好”的座右铭。 + +“[Ruby for Good][4]” 在夏天举行,举办地点在弗吉尼亚州费尔法克斯的乔治•梅森大学。 + +### Social Coder + +英国的 Ed Guiness 创建了 “Social Coder”,将志愿者和慈善机构召集在一起,为六大洲的非营利组织创建和使用开源项目。“Social Coder” 积极招募来自世界各地的熟练 IT 志愿者,并将其与通过 Social Coder 注册的慈善机构和非营利组织进行匹配。项目范围从简单的网站更新到整个移动应用程序的开发。 + +例如,PHASE Worldwide 是一个在尼泊尔支持工作的小型非政府组织,因为 “Social Coder”,它获得了利用开源技术的关键支持和专业知识。 + +有许多慈善机构已经与英国的 “Social Coder”进行了合作,也欢迎其它国家的组织加入。通过他们的网站,个人可以注册为社会软件项目工作,找到寻求帮助的组织和慈善机构。 + +对 “Social Coder” 的志愿服务感兴趣的个人可以 [在此][5]注册. + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/ways-volunteer + +作者:[John Jones][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/johnjones4 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_gift_giveaway_box_520x292.png?itok=w1YQhNH1 (Gift box opens with colors coming out) +[2]: https://brigade.codeforamerica.org/ +[3]: http://codeforchange.herokuapp.com/ +[4]: https://rubyforgood.org/ +[5]: https://socialcoder.org/Home/Programmer diff --git a/published/202001/20191220 Why Vim fans love the Herbstluftwm Linux window manager.md b/published/202001/20191220 Why Vim fans love the Herbstluftwm Linux window manager.md new file mode 100644 index 0000000000..91bb816e93 --- /dev/null +++ b/published/202001/20191220 Why Vim fans love the Herbstluftwm Linux window manager.md @@ -0,0 +1,101 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11734-1.html) +[#]: subject: (Why Vim fans love the Herbstluftwm Linux window manager) +[#]: via: (https://opensource.com/article/19/12/herbstluftwm-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +为什么 Vim 爱好者喜欢 Herbstluftwm Linux 窗口管理器 +====== + +> 本文是 24 天 Linux 桌面特别系列的一部分。如果你是 Vim 爱好者,请试试 Herbstluftwm,这是一个受到 “Vim 方式”启发的平铺式 Linux 窗口管理器。 + +![](https://img.linux.net.cn/data/attachment/album/201912/31/215943pisvzwkm8mvsefhm.jpg) + +每个人都喜欢 Vim(除了 Dvorak 和 Emacs 用户)。Vim 非常流行,它不仅仅是个编辑器,还有整个都使用 Vim 键绑定来浏览网页的 Web 浏览器,在非常流行的 [Zsh][2] 终端仿真器中也有 Vim 模式。此外,还有一个名为 [herbstluftwm][3] 的窗口管理器,它部分模仿了 “Vim 方式”。Herbstluftwm 取消了窗口,而是在程序载入和使用时使用平铺的贴片或者象限代替。你可以使用键盘(`Alt+h`、`Alt+j`、`Alt+k` 和 `Alt+l`)从一个平铺贴片移动到另一个平铺贴片。 + +可以从发行版软件仓库安装 Herbstluftwm。安装后,请退出当前桌面会话,以便可以登录到新会话。默认情况下,会话管理器(KDM、GDM、LightDM 或 XDM,具体取决于你的设置)将继续登录到以前的桌面,因此在登录之前必须覆盖它。 + +在 GDM 中: + +![][5] + +在 SDDM 中: + +![][6] + +### Herbstluftwm 桌面之旅 + +第一次登录 Herbstluftwm 时,你只会看到一个绿屏,边缘有深绿色边框。你所看到的是初始的平铺贴片,其中没有加载任何应用程序。要启动默认应用,请按 `Alt+Enter`。 + +![][4] + +文档中强调使用 `$HOME/.config/herbstluftwm/autostart` 作为登录时启动重要应用的配置文件。对于不必在每次登录时启动的应用,可以使用 xterm 作为启动守护进程。与往常一样,在命令后加一个 `&` 符号会将 shell 的控制权返回给你。例如,要启动 Emacs: + +``` +% emacs & +``` + +这将在新的平铺贴片中启动 Emacs 窗口,然后返回命令行。 + +![Emacs running in Herbstluftwm][7] + +#### 切换平铺贴片 + +要从一个平铺贴片移动到另一个平铺贴片,请使用经典的 `h`、`j`、`k` 或 `l` 与 `Alt` 的 Vim 导航组合键。例如,要从终端切换到其下方的平铺贴片中的应用(即屏幕底部),请按 `Alt+j`。要返回,请按 `Alt+k`。左移和右移分别为 `Alt+h` 和 `Alt+l`。 + +#### 分割屏幕 + +你可以使用 `Alt+o` 垂直分割屏幕,使用 `Alt+u` 水平分割屏幕。 + +要删除空白平铺贴片,请移动到该平铺贴片,然后按 `Alt+r`。 + +### 配置 herbstluftwm + +除了 `Alt` 键绑定外,你还可通过 `herbstclient` 命令与 Herbstluftwm 进行通信。此命令可以在 shell 中交互,或者你可在配置文件中保留你的首选项。 + +你可以查看 Herbstluftwm 中的所有可用属性: + +``` +$ herbstclient attr +``` + +Herbstluftwm 的默认行为定义在其默认配置文件中,你可以将其复制到你的家目录并进行修改。启动后,Herbstluftwm 执行配置文件中包含的命令。例如,你觉得使用以 `Alt` 为中心的键绑定很笨拙(它传统上是应用内保留快捷键),那你可以在配置文件中更改触发 Herbstluftwm 操作的键: + +``` +% mkdir ~/.config/herbstluftwm +% cp /usr/xdg/herbstluftwm/autostart ~/.config/herbstluftwm +% sed -i 's/Mod=Mod1/Mod=Mod4/' ~/.config/herbstluftwm +% herbstclient reload +``` + +这将使 Herbstluftwm 的修饰键更改为 `Super` 键(“Windows” 或 “Tux” 键,具体取决于你的键盘)。 + +使用 `autostart` 文件,你可以设置自定义键绑定,为特定类型的应用创建标签,以便以一致的方式平铺应用,并执行更多操作。 + +### 为何你要尝试 herbstluftwm + +Herbstluftwm 是一个平铺窗口管理器的很好例子。它默认平铺窗口,并允许用户定义全局规则的例外。它使用类似 Vim 的导航方式,但可以快速简单地覆盖它。它可能是你一直在寻找的平铺管理器,所以请马上尝试一下。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/herbstluftwm-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openstack_python_vim_2.jpg?itok=4fza48WU (OpenStack source code (Python) in VIM) +[2]: https://opensource.com/article/19/9/getting-started-zsh +[3]: https://herbstluftwm.org +[4]: https://opensource.com/sites/default/files/uploads/advent-herbsluftwm.png (Herbstluftwm) +[5]: https://opensource.com/sites/default/files/advent-gdm_1.jpg +[6]: https://opensource.com/sites/default/files/advent-kdm_0.jpg +[7]: https://opensource.com/sites/default/files/uploads/advent-herbsluftwm-emacs.jpg (Emacs running in Herbstluftwm) diff --git a/published/202001/20191221 Pop-_OS vs Ubuntu- Which One is Better.md b/published/202001/20191221 Pop-_OS vs Ubuntu- Which One is Better.md new file mode 100644 index 0000000000..dd86eb3196 --- /dev/null +++ b/published/202001/20191221 Pop-_OS vs Ubuntu- Which One is Better.md @@ -0,0 +1,154 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11744-1.html) +[#]: subject: (Pop!_OS vs Ubuntu: Which One is Better?) +[#]: via: (https://itsfoss.com/pop-os-vs-ubuntu/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Pop!_OS 与 Ubuntu:哪个更棒? +====== + +好吧,你可能会发现从[最佳 Linux 发行版][1]列表中选择一个发行版很容易,但是,将两个类似的 Linux 发行版进行比较通常会令人困惑,就像 Pop!_OS 与 Ubuntu 一样。 + +有趣的是,Pop!\_OS 是基于 [Ubuntu][2] 的。那么,Pop!\_OS 和 Ubuntu 之间有什么区别呢?为什么要从中选择一个呢? + +在本文中,我将比较 Pop!_OS 和 Ubuntu(两者都是我的最爱)。 + +**注意:**你可能会发现一些武断的观点,而本文只是一份比较的参考。随着 Linux 发行版的不断开发和更新,随着时间的流逝,很多事情都会改变。 + +### 比较 Ubuntu 和 Pop!_OS + +![Pop!_OS Vs Ubuntu][3] + +发现相似之处可帮助你区分其他差异之处。因此,让我们从一些明显的相似之处开始。 + +就像我提到的,Pop!\_OS 是基于 Ubuntu 之上的 Linux 发行版。因此,当你使用 Pop!\_OS 时,你将获得使用 Ubuntu 的所有好处(从技术上说,其核心是一样的)。 + +它们都默认带有 [GNOME 桌面环境][4],因此它们具有相似的用户界面(UI)。 + +在不讨论所有底层差异的情况下,我将在这里重点介绍一些重要的差异。 + +#### 用户体验及主题 + +![Pop!_OS][5] + +许多用户认为 Pop!_OS 只是具有不同外观的 Ubuntu。 + +根据我的经验,我觉得这并非完全正确。 + +是的,它们俩都很喜欢 [GNOME 桌面环境][4] —— 但是,Pop!_OS 让人感觉更加优美。 + +除了外观之外,[Ubuntu 还通过添加程序坞和其他一些小花巧来定制了 GNOME 的体验][6]。如果你喜欢定制的 GNOME 体验,可能会发现它更好。 + +但是,如果你更喜欢纯粹的 GNOME 体验,Pop!_OS 默认情况下为你提供的就是这样。 + +在你亲自尝试之前,我无法说服你。但是,Pop!_OS 中的总体配色方案、图标和主题可以说是令人愉悦的高级用户体验。 + +这可能是一个主观的事情,但这是我所观察到的。你还可以查看 Ubuntu 19.10 的视频教程,亲自感受一下。 + +#### 易于安装第三方应用 + +![Pop Os PPA][7] + +Ubuntu 非常重视 Snap 软件包。这增加了它提供的应用程序的数量。 + +但是 Snap 软件包存在一些重要的问题。它们占用了过多的磁盘空间,并且启动要花费大量的时间。 + +这就是为什么我更喜欢使用应用程序的 APT 版本的原因。 + +我为什么要说这个呢? + +因为 Pop!_OS 具有其[自己的官方 PPA][8],并已默认启用。你会在此处找到一些有用的应用程序,例如 Android Studio、TensorFlow。无需下载 Android Studio 的 1GB 大的 Snap 程序包。只需使用 [apt-get install][9]就可以了。 + +#### 预装应用 + +![Ubuntu installation slideshow][10] + +对于某些人来说,它可能不是最大的问题,但是拥有大量预安装的应用程序可能会影响体验和性能。即使不影响性能,某些用户也只喜欢较少的预装应用程序。 + +与 Ubuntu 相比,Pop!_OS 捆绑了更少的默认应用程序(潜在地减少了胖软件)。 + +再一次提醒,这是主观的看法。如果你希望预安装更多应用程序,则可以考虑使用 Ubuntu 而不是 Pop!_OS。 + +#### Snap 软件包支持 + +![][11] + +对于熟悉 Snap 程序包的用户来说,Ubuntu 的软件中心是比 Pop!_OS 商店更好的解决方案,因为你可以在软件中心中列出 Snap 程序包。 + +你无法在软件中心中过滤 Snap 软件包,但是当你在软件中心中发现一个 Snap 软件包(查看应用程序来源的详细信息为 “Snap store”/“Snapcraft”)时安装它就更容易了。 + +可能你会感到困惑,Pop!\_OS 也确实支持 Snap 软件包。但是,你不会在 Pop!\_OS 商店中找到它们,这是唯一的区别。 + +如果不确定什么是 Snap 软件包及其功能,可以查看我们的文章《[在 Linux 上安装 Snap 应用][12]》。 + +#### 单独的 NVIDIA/AMD ISO 文件 + +![ISOs][13] + +从技术上讲,它不是内部比较的一部分,而是某些用户关心的一个因素。 + +因此,值得强调的是 Pop!_OS 提供了单独的 ISO。一个用于带 NVIDIA 显卡的系统,另一个用于带/不带 AMD 显卡的系统。 + +使用 Ubuntu 19.10,你可以在 Ubuntu ISO 上获得 NVIDIA 驱动程序,但 AMD 显卡没有这个。 + +#### 可靠性与问题 + +毫无疑问,这两个[发行版都适合初学者][14],并且相当可靠。如果你想要更好的可靠性和更少的问题,则可能希望一直使用长期支持(LTS)版本。 + +当出现新版本的 Ubuntu 时,Pop!_OS 将在其上开发,并有可能解决用户在 Ubuntu 原始发行版上遇到的问题,然后再进行新的升级。这给它们带来了一点优势,但这没什么实质性的不同,因为这些修复最终都可以运用于 Ubuntu。 + +#### 性能 + +性能将高度取决于你所安装的内容以及所安装的硬件配置。 + +除非你有一个超级旧的系统,否则这两个发行版似乎都表现良好。 + +我的机器是 i5-7400 处理器和 16GB 的 RAM(带有 GTX 1050ti 显卡),我发现两种发行版上的体验都足够好。 + +当然,你可以手动进行一些优化调整以满足要求——无论它们中的哪个不满足你的硬件配置。 + +但是,如果你想使用 System76 笔记本电脑,那么 Pop!\_OS 将可以证明自己是 [Linux 领域的苹果][15],因为 Pop!\_OS 是针对其硬件量身定制的,与 Ubuntu 有所不同。 + +#### 硬件兼容性 + +在比较其他 Linux 发行版时,这绝对是要考虑的事情。但是,在这种情况下,实际上并没有太大的区别。 + +你可能会考虑 Pop!_OS 一直在使用较新的硬件配置,因为他们主要是为他们的笔记本电脑量身定制具有各种配置的 OS。而且,这只是一个观察,而不是事实。 + +### 结语 + +我知道在不亲自尝试的情况下从两个流行的 Linux 发行版中选择一个并不容易。如果可能的话,我建议你在进行比较的同时尝试两者,以供参考。 + +你在这两者之间有何选择?我在比较中错过了什么吗?在下面的评论中让我知道。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/pop-os-vs-ubuntu/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/best-linux-distributions/ +[2]: https://ubuntu.com/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/pop_os_vs_ubuntu.png?ssl=1 +[4]: https://www.gnome.org/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/pop-os-UI.jpg?ssl=1 +[6]: https://itsfoss.com/gnome-tricks-ubuntu/ +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/pop-os-ppa.jpg?ssl=1 +[8]: https://launchpad.net/~system76/+archive/ubuntu/pop/ +[9]: https://itsfoss.com/apt-get-linux-guide/ +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/install-ubuntu-linux-on-intel-nuc-14_tutorial.jpg?resize=800%2C516&ssl=1 +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/snapcraft.jpg?ssl=1 +[12]: https://itsfoss.com/install-snap-linux/ +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/iso-amd-nvidia-pop-os.jpg?ssl=1 +[14]: https://itsfoss.com/best-linux-beginners/ +[15]: https://www.phoronix.com/scan.php?page=news_item&px=System76-Integrated-Vision diff --git a/published/202001/20191224 Chill out with the Linux Equinox Desktop Environment.md b/published/202001/20191224 Chill out with the Linux Equinox Desktop Environment.md new file mode 100644 index 0000000000..c6a96672d7 --- /dev/null +++ b/published/202001/20191224 Chill out with the Linux Equinox Desktop Environment.md @@ -0,0 +1,90 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11745-1.html) +[#]: subject: (Chill out with the Linux Equinox Desktop Environment) +[#]: via: (https://opensource.com/article/19/12/ede-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +轻松使用 Linux Equinox 桌面环境 +====== + +> 本文是 24 天 Linux 桌面特别系列的一部分。EDE 不是最迷人、最小或效率最高的桌面。但它的柔和、安宁让人平静,它让人感到熟悉舒缓,它的图标主题也很有趣。 + +我还没有认真用过 Fast Light Toolkit([FLTK] [2]),但我是 C++ GUI 工具箱的粉丝,它非常易于学习,并且即使进行更新也很可靠。当我发现有一个用 FLTK 构建的桌面环境时,我很想尝试一下,并且我很快为我的决定感到高兴。[Equinox 桌面环境(EDE)][3] 是用 C++ 和 FLTK 为 Unix 桌面编写的快速、简单的桌面环境。它使用通用的桌面约定,因此外观和感觉都非常熟悉,并且在使用几天后,我发现它的简单性提供了我所喜欢的最低限度的优雅。 + +![EDE desktop][4] + +### 安装 EDE + +你可能会发现 EDE 包含在发行版的软件仓库中,但你也可以在它的 [SourceForge 仓库][5]中找到它。如果你已经在运行其他桌面环境,你可以安全地在同一系统上安装 EDE,因为它仅带来了一些额外的应用,这些应用程序特定于 EDE,因此它们不会妨碍你的其他桌面。 + +EDE 只是桌面环境,它使用 [Pekwm][6] 窗口管理器来处理布局。 + +安装 EDE 之后,注销当前的桌面会话,以便你可以登录到新的会话。默认情况下,会话管理器(KDM、GDM、LightDM 或 XDM,取决于你的设置)将继续登录到以前的桌面环境,因此你必须在登录之前覆盖该桌面环境。 + +在 GDM 中: + +![][7] + +在 SDDM 中: + +![][8] + +首次启动 EDE 时,可能会提示你确认一些启动任务。在我的 Slackware 工作站上,KDE 将某些服务标记为启动任务(例如 HPLIP 打印监视器和蓝牙守护程序),并且 EDE 在一个确认框中显示了它们。 + +![Importing desktop services in EDE][9] + +设置一次后,你无需再次进行设置。 + +### EDE 桌面之旅 + +EDE 的布局恰恰是大多数人在桌面上所期望的布局:左侧的应用菜单、中间的任务栏、右侧的系统托盘。这是标准的现成布局,不会让任何人感到困惑。这是一个可以安全地装在 Linux 上并且可以自信地给任何没有使用过 Linux 的人使用的桌面。他们将以舒适的方式很快地适应这个桌面。 + +你可以单击鼠标右键打开一个小型桌面菜单。这可以让你在桌面上创建应用启动器、创建文件夹并设置一些主题选项。 + +屏幕底部的面板是可伸缩的,因此你可以根据需要在全屏模式下工作。单击屏幕右下角的时钟来调出日历和时区设置。 + +EDE 有一个小的配置应用,可用于设置一些简单的选项: + +* 背景和图标设置 +* 屏幕保护程序设置 +* 时间和时钟 +* 系统铃声 +* 键盘 +* 偏好应用 + +![EDE Configuration Place][10] + +EDE 的功能不多。没有文件管理器、文本编辑器、绘画程序或纸牌游戏。你必须安装你想在桌面运行的程序。这意味着你可以从各种各样的 Linux 应用中进行选择,并使用你最喜欢的。 + +### EDE 总结 + +我发现 EDE 至少作为一种“假日”桌面而言,它的简单性令人舒适。它值得一看。它不是最迷人的桌面,也不是最精简的、也不是最高效的。但它的柔和、安宁让人平静,它让人感到熟悉舒缓,并且它的图标主题充满乐趣和生气。EDE 是一个以其缓慢而稳定的步调而自豪的桌面。 + +如果你想放松心情使用一个干净和令人愉悦的界面,请试试 EDE。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/ede-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/penguin.igloo_.png?itok=K92O7H6b (Linux penguin at the north pole beside an igloo) +[2]: https://www.fltk.org/ +[3]: https://sourceforge.net/projects/ede/ +[4]: https://opensource.com/sites/default/files/uploads/advent-ede.jpg (EDE desktop) +[5]: http://ede.sf.net +[6]: https://opensource.com/article/19/12/pekwm-linux-desktop +[7]: https://opensource.com/sites/default/files/advent-gdm_2.jpg +[8]: https://opensource.com/sites/default/files/advent-kdm_1.jpg +[9]: https://opensource.com/sites/default/files/uploads/advent-ede-init.jpg (Importing desktop services in EDE) +[10]: https://opensource.com/sites/default/files/uploads/advent-ede-conf.jpg (EDE Configuration Place) diff --git a/published/202001/20191226 Darktable 3 Released With GUI Rework and New Features.md b/published/202001/20191226 Darktable 3 Released With GUI Rework and New Features.md new file mode 100644 index 0000000000..b7c6b53cbb --- /dev/null +++ b/published/202001/20191226 Darktable 3 Released With GUI Rework and New Features.md @@ -0,0 +1,110 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11741-1.html) +[#]: subject: (Darktable 3 Released With GUI Rework and New Features) +[#]: via: (https://itsfoss.com/darktable-3-release/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Darktable 3 发布,带来重新打造的 UI 及新的功能 +====== + +> 这是给摄影爱好者的圣诞节礼物。Darktable 3.0 刚刚发布了。 + +[Darktable][1] 是[在 Linux 上编辑 RAW 图像的最佳应用之一][2]。你可以将其视为 [Adobe Lightroom 的自由开源替代品][3]。 + +Darktable 3 是一个主版本更新,它带来了大量的功能改进和重新打造的用户界面。现在,GUI 完全由 GTK+ CSS 规则所控制,这使得整个 GUI 都可定制主题。它默认有八个主题。 + +借助 3000 多个提交和 553 个拉取请求,新版本修复了 66 个 bug 并添加了许多新功能。 + +让我们看看这个新版本带来了什么功能。 + +### Darktable 3.0 的新功能 + +![Darktable 3.0 Screenshot][4] + +以下是重要的新功能: + +* 重新打造的 UI +* 用于处理 3D RGB Lut 变换的新模块 +* 对“降噪(轮廓化)”模块进行了许多改进 +* 添加了新的“剔除”模式和时间轴视图 +* 对“降噪(轮廓化)”模块进行了许多改进 +* 新色调均衡器的基本和电影 RGB 模块 +* 更好的 4K/5K 显示支持 +* 撤消/重做支持更多操作 +* 针对 CPU 和 SSE 路径的许多代码优化 +* 支持导出到 Google 相册 +* 支持更多的相机,白平衡预设和噪点配置 +* 大量的 bug 修复和功能改进 + +你可以在 [GitHub 发行说明][5]中了解所有更改。 + +### 在 Linux 上安装 Darktable 3.0 + +让我们看看如何获​​取最新的 Darktable 版本。 + +#### 在基于 Ubuntu 的发行版上安装 Darktable 3.0 + +Ubuntu 仓库中有 Darktable,但你不能得到马上最新的版本。对于 LTS 版本,它的更新可能需要几个月的时间。 + +不用担心!Darktable 提供了[自己的 PPA][6] 来在基于 Ubuntu 的发行版上安装最新版本。 + +不幸的是,此 Darktable PPA 尚未随新版本更新。 + +不用担心了!多亏了我们的朋友 [Ubuntu Handbook 的 Ji M][7],我们有一个非正式的 PPA,可以轻松地在 Ubuntu 和其他基于 Ubuntu 的发行版上安装 Darktable 3.0。 + +打开终端,并使用这些命令: + +``` +sudo add-apt-repository ppa:ubuntuhandbook1/darktable +sudo apt update +sudo apt install darktable +``` + +#### 卸载 Darktable 3 + +要删除通过此 PPA 安装的 Darktable,你可以先卸载该应用: + +``` +sudo apt remove darktable +``` + +接着[删除 PPA][8]: + +``` +sudo add-apt-repository -r ppa:ubuntuhandbook1/darktable +``` + +#### 在其他 Linux 发行版上安装 Darktable + +你可以等待到你的发行版的软件管理器提供新版本。 + +你也可以从 GitHub 发布页面(位于页面底部)下载 tarball 或所有源代码。 + +- [下载 Darktable 3.0][5] + +使用 Darktable 3,你可以更好地编辑自己的假期照片:) + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/darktable-3-release/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.darktable.org/ +[2]: https://itsfoss.com/raw-image-tools-linux/ +[3]: https://itsfoss.com/open-source-photoshop-alternatives/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/darktable_3_screenshot.jpg?ssl=1 +[5]: https://github.com/darktable-org/darktable/releases/tag/release-3.0.0 +[6]: https://launchpad.net/~pmjdebruijn/+archive/ubuntu/darktable-release +[7]: http://ubuntuhandbook.org/index.php/2019/12/install-darktable-3-0-0-ubuntu-18-04-19-10/ +[8]: https://itsfoss.com/how-to-remove-or-delete-ppas-quick-tip/ diff --git a/published/202001/20191227 10 resources to boost your Git skills.md b/published/202001/20191227 10 resources to boost your Git skills.md new file mode 100644 index 0000000000..8dc63c18bf --- /dev/null +++ b/published/202001/20191227 10 resources to boost your Git skills.md @@ -0,0 +1,57 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11737-1.html) +[#]: subject: (10 resources to boost your Git skills) +[#]: via: (https://opensource.com/article/19/12/git-resources) +[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja) + +10 个提高 Git 技能的资源 +====== + +> 年末总结一下 Git 的最佳表现。以下是告诉你可以在新的一年中以新奇的方式使用 Git 的十篇文章。 + +![](https://img.linux.net.cn/data/attachment/album/202001/02/093934q5ifu46u4nuq4lgi.jpg) + +2019 年过去了,是时候回顾一下我们(opensource.com)今年发表的有关 Git 的前 10 篇文章了。 + +这些文章包括从用例和教程到一些非常有趣的(甚至有些非常规的)使用 Git 的方法。所有这些文章都可以帮助你提高 Git 技能,但是,如果你确实需要 Git 入门介绍,请务必查看我们的《[Git 入门:术语入门][2]》文章,并下载我们的 [Git 备忘单][3]。 + +1. Molly de Blanc 写的《[GNOME 项目如何使用 Git][4]》考察了 GNOME 项目采用的自托管 GitLab 实例的做法,该实例作为 GNOME 项目集中保存对 GNOME 做出的贡献的位置。De Blanc 从事于非编码职位,因此她的文章还探讨了切换到 GitLab 如何使主要角色不是编写代码的贡献者受益。 +2. Ahmad Awais 写的《[Emoji-Log:编写 Git 提交信息的新方法][5]》解释了如何使用 Emoji-Log(一种直白的、开源的 Git 提交日志标准)来编写更好、更用户友好的 Git 提交消息。本文概述了 Emoji-Log 背后的理论以及可添加到 `.bashrc`、`.zshrc` 或 `.gitconfig` 中的配置示例,以便你快速开始使用 Emoji-Log。 +3. 在《[用 Git 管理你的每日行程][6]》中,Seth Kenlon 解释了如何使用 Git 来管理日历。通过结合 Org 模式、Git 和其他一些工具,Kenlon 描述了如何创建可在设备之间同步的基于 Git 的日历工作流。 +4. 《[用 Git 作为聊天应用的后端][7]》,Seth Kenlon 探索了另一种使用 Git 的非常规方式。在本文中,他探讨了 GIC,这是一个用 Node.js 编写的聊天客户端,其中 Git 用作后端数据库。GIC 是一个概念验证模型,不是供产品环境使用的东西,但是它提供了一个有趣的示例,说明了使用 Git 的真正独特方法。 +5. Alan Formy-Duval 的《[Git 学习实用练习][8]》是一份他为提高 Git 技能而努力的编年史。他分享了自己的经验,以使其他人受益于他所学,而 Git 新手将从这篇对 Git 核心功能的出色概述中受益匪浅。 +6. 《[用 Git 帮助写作者更好地完成工作][9]》的作者 Seth Kenlon 着眼于写作者如何从基于 Git 的工作流中受益。本文介绍了如何使用 Git 和 Atom 利用 Markdown 进行书写。通过遵循本文中的示例,写作者可以轻松地将复杂的版本控制系统添加到其编写工作流中。 +7. Sachin Patil 在《[如何使用 Magit 管理 Git 项目][10]》中,解释了如何使用 Emacs 的 Magit 扩展来管理 Git 存储库。本文提供了有关如何在 Emacs 中执行一系列关键 Git 任务的清晰示例。这些示例带有说明各种任务的屏幕截图。 +8. 《[把“点文件”放到版本控制中][11]》的作者 Matthew Broberg 演示了如何使用 Git 存储放在主目录中的点文件。将你的点文件存储在 Git 存储库中,可以更轻松地在计算机之间共享系统配置,并且,如果你愿意的话,也可以与其他人共享配置。这篇文章也有不要共享哪些文件的警告,因为共享错误的点文件会将其暴露给其他人。 +9. Austin Dewey 的《[4 种用于 Git 加密的机密管理工具][12]》在本文中比较了 Git-crypt、BlackBox、SOPS 和 Transcrypt,研究了在 Git 中存储机密的工具。本文涵盖四个主要领域:支持的加密类型、每个项目的目标、项目的工作流和差异以及其他功能。 +10. Seth Kenlon 的《[使用 Git 管理 Git 服务器][13]》解释了如何使用 Gitolite 管理 Git 服务器。Gitolite 是使用 Git 来管理 Git 服务器的“管理杂项的后端应用程序”。本文演示了如何安装、配置和使用 Gitolite,并提供了清晰的示例详细说明了该过程的每个步骤。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/git-resources + +作者:[Joshua Allen Holm][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/holmja +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/button_push_open_keyboard_file_organize.png?itok=KlAsk1gx (open source button on keyboard) +[2]: https://opensource.com/article/19/2/git-terminology +[3]: https://opensource.com/downloads/cheat-sheet-git +[4]: https://opensource.com/article/19/10/how-gnome-uses-git +[5]: https://linux.cn/article-10627-1.html +[6]: https://linux.cn/article-11320-1.html +[7]: https://linux.cn/article-11342-1.html +[8]: https://opensource.com/article/19/5/practical-learning-exercise-git +[9]: https://linux.cn/article-11499-1.html +[10]: https://opensource.com/article/19/1/how-use-magit +[11]: https://linux.cn/article-11419-1.html +[12]: https://opensource.com/article/19/2/secrets-management-tools-git +[13]: https://opensource.com/article/19/4/server-administration-git diff --git a/published/202001/20191227 Explained- Why Your Distribution Still Using an ‘Outdated- Linux Kernel.md b/published/202001/20191227 Explained- Why Your Distribution Still Using an ‘Outdated- Linux Kernel.md new file mode 100644 index 0000000000..4075e017a8 --- /dev/null +++ b/published/202001/20191227 Explained- Why Your Distribution Still Using an ‘Outdated- Linux Kernel.md @@ -0,0 +1,120 @@ +[#]: collector: (lujun9972) +[#]: translator: (chen-ni) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11791-1.html) +[#]: subject: (Explained! Why Your Distribution Still Using an ‘Outdated’ Linux Kernel?) +[#]: via: (https://itsfoss.com/why-distros-use-old-kernel/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +为什么你的发行版仍然在使用“过时的”Linux 内核? +====== + +![](https://img.linux.net.cn/data/attachment/album/202001/16/225806jbqyacu3loolobae.png) + +[检查一下你的系统所使用的 Linux 内核版本][1],你十有八九会发现,按照 Linux 内核官网提供的信息,该内核版本已经达到使用寿命终期(EOL)了。 + +一个软件一旦达到了使用寿命终期,那么就意味着它再也不会得到 bug 修复和维护了。 + +这自然会引发一连串问题:为什么我的 Linux 发行版会使用一个已经达到使用寿命终期的内核呢?这样做有没有安全风险?我的系统还安全吗? + +下面将逐一解答这些问题。 + +> **总结** +> +> 上游内核维护与你的发行版的内核维护是两个不同的概念。 +> +> 例如,根据 Linux 内核官网,Linux 内核 4.15 版本可能已经达到使用寿命终期了,但是在 2023 年 4 月之前,Ubuntu 18.04 长期维护版本将会继续使用这个版本,并通过向后移植安全补丁和修复 bug 来提供维护。 + +### 检查 Linux 内核版本,以及是否达到使用寿命终期 + +首先,查看你的系统所使用的 Linux 内核版本: + +``` +uname -r +``` + +我使用的是 Ubuntu 18.04,输出的 Linux 内核版本如下: + +``` +abhishek@itsfoss:~$ uname -r +5.0.0-37-generic +``` + +接下来,可以到 [Linux 内核官网][2]上看看哪些 Linux 内核版本仍然在维护状态。在网站主页上就可以看到相关信息。 + +你看到的内核版本状态应该类似于下图: + +![Linux 内核状态][3] + +如果你的内核版本没有列在内核官网主页上,就说明该版本已经达到了使用寿命终期。 + +可以看到,5.0 内核版本并不在列,这说明该内核版本已经不再得到维护。事实上,该版本在 [2019 年 6 月就已经达到使用寿命终期了][4]。 + +不幸的是,Linux 内核的生命周期没有任何规律可循。不是说常规的内核稳定发布版可以得到 X 月的维护、长期维护版本(LTS)可以得到 Y 年的维护。没有这回事。 + +根据实际需求,可能会存在内核的多个 LTS 版本,其使用寿命终期各不相同。在[这个页面][5]上可以查到这些 LTS 版本的相关信息,包括计划的使用寿命终期。 + +那么问题来了:既然 Linux 内核官网上明确表示 5.0 版本的内核已经达到了使用寿命终期,Ubuntu 为什么还在提供这个内核版本呢? + +### 你的发行版使用的 Linux 内核已经达到了使用寿命终期,但是没关系! + +![][6] + +你是否想过,为什么 Ubuntu/Debian/Fedora 等发行版被称为 Linux “发行版”?这是因为,它们“发行” Linux 内核。 + +这些发行版会对 Linux 内核进行不同的修改,并添加各种 GUI 元素(包括桌面环境、显示服务器等)以及软件,然后再呈现给用户。 + +按照通常的工作流,Linux 发行版会选择一个内核,提供给其用户,然后在接下来的几个月、几年中,甚至是达到内核的使用寿命终期之后,仍然会继续使用该内核。 + +这样能够保障安全吗?其实是可以的,因为 **发行版会通过向后移植全部的重要修补来维护内核**。 + +换句话说,你的 Linux 发行版会确保 Linux 内核没有漏洞和 bug,并且已经通过向后移植获得了重要的新特性。在“过时的旧版本 Linux 内核”上,其实有着数以千计的改动。 + +如果 Linux 内核网站上说某个内核版本已经达到了使用寿命终期,那么就意味着 Linux 内核的核心维护团队不会再对该内核版本进行升级和打补丁了。 + +但与此同时,Debian/Ubuntu 或者其他发行版的开发者们会继续工作,通过从(由内核核心团队维护的)更新的内核版本中迁移相关的修改,维持这个老版本的生命力。 + +重点在于,即使你的发行版看上去是在使用一个已经过时的 Linux 内核,其实该内核也得到了良好的维护,并非是真的过时了。 + +### 你是否应该使用最新的稳定内核版本? + +![][7] + +新的 Linux 内核稳定版本每隔 2 到 3 个月发布一次,有不少用户跃跃欲试。 + +实话说,除非有十分充分的理由,否则不应该使用最新版本的稳定内核。你使用的发行版并不会提供这个选项,你也不能指望通过在键盘上敲出 `sudo apt give-me-the-latest-stable-kernel` 解决问题。 + +此外,手动[安装主流 Linux 内核版本][8]本身就是一个挑战。即使安装成功,之后每次发布 bug 修复的时候,负责更新内核的就会是你了。此外,当新内核达到使用寿命终期之后,你就有责任将它升级到更新的内核版本了。和常规的 [Ubuntu 更新][9]不同,内核升级无法通过 `apt upgrade` 完成。 + +同样需要记住的是,切换到主流内核之后,可能就无法使用你的发行版提供的一些驱动程序和补丁了。 + +正如 [Greg Kroah-Hartman][10]所言,“**你能使用的最好的内核,就是别人在维护的内核。**”除了你的 Linux 发行版之外,又有谁更胜任这份工作呢! + +希望你对这个主题已经有了更好的理解。下回发现你的系统正在使用的内核版本已经达到使用寿命终期的时候,希望你不会感到惊慌失措。 + +欢迎在下面的评论区中留下你的疑问或建议。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/why-distros-use-old-kernel/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[chen-ni](https://github.com/chen-ni) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/find-which-kernel-version-is-running-in-ubuntu/ +[2]: https://www.kernel.org/ +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/linux-kernel-status.jpg?ssl=1 +[4]: http://lkml.iu.edu/hypermail/linux/kernel/1906.0/02354.html +[5]: https://www.kernel.org/category/releases.html +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/Keep_Calm_and_Trust_Your_Distribution.png?ssl=1 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/using_latest_kernel.png?ssl=1 +[8]: https://wiki.ubuntu.com/Kernel/MainlineBuilds +[9]: https://itsfoss.com/update-ubuntu/ +[10]: https://en.wikipedia.org/wiki/Greg_Kroah-Hartman diff --git a/published/202001/20191229 The best resources for agile software development.md b/published/202001/20191229 The best resources for agile software development.md new file mode 100644 index 0000000000..7ffc566009 --- /dev/null +++ b/published/202001/20191229 The best resources for agile software development.md @@ -0,0 +1,64 @@ +[#]: collector: (lujun9972) +[#]: translator: (algzjh) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11816-1.html) +[#]: subject: (The best resources for agile software development) +[#]: via: (https://opensource.com/article/19/12/agile-resources) +[#]: author: (Leigh Griffin https://opensource.com/users/lgriffin) + +敏捷软件开发的最佳资源 +====== + +> 请阅读我们的热门文章,这些文章着重讨论了敏捷的过去、现在和未来。 + +![](https://img.linux.net.cn/data/attachment/album/202001/25/121308jrs4speu2y09u09e.jpg) + +对于 Opensource.com 上的敏捷主题来说,2019 年是非常棒的一年。随着 2020 年的到来,我们回顾了我们读者所读的与敏捷相关的热门文章。 + +### 小规模 Scrum 指南 + +Opensource.com 关于[小规模 Scrum][2] 的指南(我曾参与合著)由六部分组成,为小型团队提供了关于如何将敏捷引入到他们的工作中的建议。在官方的 [Scrum 指南][3]的概述中,传统的 Scrum 框架推荐至少三个人来实现,以充分发挥其潜力。但是,它并没有为一两个人的团队如何成功遵循 Scrum 提供指导。我们的六部分系列旨在规范化小规模的 Scrum,并检验我们在现实世界中使用它的经验。该系列受到了读者的热烈欢迎,以至于这六篇文章占据了前 10 名文章的 60%。因此,如果你还没有阅读的话,一定要从我们的[小规模 Scrum 介绍页面][2]下载。 + +### 全面的敏捷项目管理指南 + +遵循传统项目管理方法的团队最初对敏捷持怀疑态度,现在已经热衷于敏捷的工作方式。目前,敏捷已被接受,并且一种更加灵活的混合风格已经找到了归宿。Matt Shealy 撰写的[有关敏捷项目管理的综合指南][4]涵盖了敏捷项目管理的 12 条指导原则,对于希望为其项目带来敏捷性的传统项目经理而言,它是完美的选择。 + +### 成为出色的敏捷开发人员的 4 个步骤 + +DevOps 文化已经出现在许多现代软件团队中,这些团队采用了敏捷软件开发原则,利用了最先进的工具和自动化技术。但是,这种机械的敏捷方法并不能保证开发人员在日常工作中遵循敏捷实践。Daniel Oh 在[成为出色的敏捷开发人员的 4 个步骤][5]中给出了一些很棒的技巧,通过关注设计思维,使用可预测的方法,以质量为中心并不断学习和探索来提高你的敏捷性。用你的敏捷工具补充这些方法将形成非常灵活和强大的敏捷开发人员。 + +### Scrum 和 kanban:哪种敏捷框架更好? + +对于以敏捷方式运行的团队来说,Scrum 和 kanban 是两种最流行的方法。在 “[Scrum 与 kanban:哪种敏捷框架更好?][6]” 中,Taz Brown 探索了两者的历史和目的。在阅读本文时,我想起一句名言:“如果你的工具箱里只有锤子,那么所有问题看起来都像钉子。”知道何时使用 kanban 以及何时使用 Scrum 非常重要,本文有助于说明两者都有一席之地,这取决于你的团队、挑战和目标。 + +### 开发人员对敏捷发表意见的 4 种方式 + +当采用敏捷的话题出现时,开发人员常常会担心自己会被强加上一种工作风格。在“[开发人员对敏捷发表意见的 4 种方式][7]”中,[Clément Verna][8] 着眼于开发人员通过帮助确定敏捷在其团队中的表现形式来颠覆这种说法的方法。检查敏捷的起源和基础是一个很好的起点,但是真正的价值在于拥有可帮助指导你的过程的指标。知道你将面临什么样的挑战会给你的前进提供坚实的基础。根据经验进行决策不仅可以增强团队的能力,还可以使他们对整个过程有一种主人翁意识。Verna 的文章还探讨了将人置于过程之上并作为一个团队来实现目标的重要性。 + +### 敏捷的现在和未来 + +今年,Opensource.com 的作者围绕敏捷的过去、现在以及未来可能会是什么样子进行了大量的讨论。感谢他们所有人,请一定于 2020 年在这里分享[你自己的敏捷故事][9]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/agile-resources + +作者:[Leigh Griffin][a] +选题:[lujun9972][b] +译者:[algzjh](https://github.com/algzjh) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lgriffin +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/collab-team-pair-programming-code-keyboard2.png?itok=WnKfsl-G "Women programming" +[2]: https://opensource.com/downloads/small-scale-scrum +[3]: https://scrumguides.org/scrum-guide.html +[4]: https://opensource.com/article/19/8/guide-agile-project-management +[5]: https://opensource.com/article/19/2/steps-agile-developer +[6]: https://opensource.com/article/19/8/scrum-vs-kanban +[7]: https://opensource.com/article/19/10/ways-developers-what-agile +[8]: https://twitter.com/clemsverna +[9]: https://opensource.com/how-submit-article diff --git a/published/202001/20191230 10 articles to enhance your security aptitude.md b/published/202001/20191230 10 articles to enhance your security aptitude.md new file mode 100644 index 0000000000..4f55e44590 --- /dev/null +++ b/published/202001/20191230 10 articles to enhance your security aptitude.md @@ -0,0 +1,92 @@ +[#]: collector: "lujun9972" +[#]: translator: "nacyro" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11742-1.html" +[#]: subject: "10 articles to enhance your security aptitude" +[#]: via: "https://opensource.com/article/19/12/security-resources" +[#]: author: "Ben Cotton https://opensource.com/users/bcotton" + +10 篇强化你的安全能力的文章 +====== + +> 无论你是新手还是想要增加技能,这十篇安全文章中都有适合你的内容。 + +![](https://img.linux.net.cn/data/attachment/album/202001/03/004344rco51cnc153ns1zz.jpg) + +如果安全是一个过程(确实如此),那么理所当然的,不同的项目(及其贡献者)的情况各有不同。有些应用程序经历了多年的安全测试,由在信息安全领域工作了几十年的人员所设计。而另外一些则是由开发人员在他们的第一个开源项目中开发的全新项目。毫不奇怪,这十大安全文章囊括了代表这一范围的经验。我们有介绍基本安全实践的文章,也有深入探讨更高级主题的文章。 + +无论你是新手还是想要增加你在传奇职业生涯中获得的技能,2019 年十大安全文章中都有适合你的内容。 + +### 《安全强化你的 Linux 服务器的七个步骤》 + +安全如舍,地基不牢,房屋不稳。Patrick H. Mullins 的杰作《[安全强化你的 Linux 服务器的七个步骤][2]》让你从 Linux 服务器的基本安全步骤开始。即使你有很多管理服务器的经验,本文也提供了一个很好的清单以确保你掌握了基础知识。在此基础上,你可以开始添加额外的安全层。 + +### 《使用防火墙让你的 Linux 更加强大》 + +七步捍卫你的 Linux 服务器中的一步即是启用防火墙。但什么**是**防火墙,它是如何工作的呢? Seth Kenlon 在《[使用防火墙让你的 Linux 更加强大][3]》一文中回答了这些问题,然后详细描述了为了更好的安全性应如何配置你的防火墙。使用 firewalld 与 Network Manager,你可以为不同的网络设置不同的防火墙配置。例如,这允许你在家庭网络上进行信任配置,并在你最喜欢的咖啡店的 WiFi 网络上进行更多疑的配置。 + +### 《用集中日志减少安全风险》 + +保护系统安全,只有开始,没有结束:安全是一个过程而不是状态。**保持**系统安全工作的一部分即是密切关注所发生的事情。集中化日志是实现这一点的一种方法,尤其是在管理多系统时。在《[减少集中日志的安全风险][4]》中 Hannah Suarez 分享了要如何开始(她这篇文章基于她在 FOSDEM'19 [自由及开源软件开发者欧洲会议] 中的闪电演讲)。 + +### 《在 SSH 中使用 GPG 密钥》 + +大多数人都会为 SSH 的密钥认证使用 SSH 密钥。为什么不呢?毕竟 SSH 就在名字里。从安全的角度来看,这些方法非常好。但若想简化某些形式的密钥分发与备份还有另一种方法,Brian Exelbierd 的三部曲系列介绍了《[如何启用使用 GPG 子钥的 SSH 访问][5]》、《[如何导入现有 SSH 密钥][6]》、《[如何将备份量减少到单个密钥文件][7]》 + +### 《使用 Seahorse 图形化管理 SSH 密钥》 + +并不是所有人都喜欢用 GPG 作为 SSH 密钥,但这并不意味着你在密钥管理上会不顺利。Seahorse 是一个在 GNOME 桌面中用于管理 SSH 密钥及其他身份验证方法的图形化工具。Alan Formy-Duval 的《[使用 Seahorse 图形化管理 SSH 密钥》对新手用户特别有帮助。 + +### 《安全扫描你的 DevOps 流程》 + +如今到处都是容器。但它们容纳着什么?了解容器满足你的安全策略是保持安全性的重要部分。幸运的是,你可以使用开源工具来帮助自动化合规检查。Jessica Cherry(原名: Repka)的《[安全扫描你的 DevOps 流程][9]》是一个循序渐进的教程,向你展示了如何使用 Jenkins 构建系统和 Anchore 检查服务为容器镜像和注册库创建扫描流程。 + +### 《4 种开源云安全工具》 + +云服务的一大优点是你的数据可以从任何地方访问。云服务的一个缺点是你的数据可以从任何地方访问。如果你使用的是 “-as-a-Service”(LCTT 译注: 某某即服务,如 IaaS、PaaS、Saa)产品,那么你需要确保它们是经过安全配置的。Anderson Silva、Alison Naylor、Travis McPeak 和 Rich Monk 联合推出《[4 种开源云安全工具][10]》以帮助在使用 GitHub 和 AWS 时提高安全性。如果你正在寻找被不小心提交的机密信息,或尝试从一开始就阻止这些机密信息被提交,这篇文章提供了工具。 + +### 《如何使用 OpenSSL:哈希、数字签名等》 + +许多信息安全是基于数学的:特别是用于加密数据和验证用户或文件内容的加密函数。在《[开始使用 OpenSSL:密码学基础][11]》中进行介绍后,Marty Kalin 深入讨论了《[如何使用 OpenSSL:哈希、数字签名等][12]》的细节,解释了如何使用 OpenSSL 实用程序来探索这些常用但不常被理解的概念。 + +### 《使用树莓派和 Kali Linux 学习计算机安全》 + +廉价硬件与开源软件构成了一个很好的组合,特别是对于那些希望边做边学的人来说。在《[使用树莓派和 Kali Linux 学习计算机安全][13]》这篇文章中,Anderson Silva 介绍了面向安全的 Kali Linux 发行版。这是一篇短文,但它满是关于文档和安全相关项目的有用的链接,你可以在自己的树莓派上使用它们。 + +### 《量子计算会打破现有的安全体系吗?》 + +这篇文章的余下部分是浪费吗?量子计算会让我们对安全的所知变得过时吗?好消息是:回答是否定的,但是量子计算仍然可以在更广泛的范围内对安全和计算世界产生深远的影响。在《[量子计算会打破现有的安全体系吗?][14]》一文中,Mike Bursell 剖析了它好坏两方面的影响,当然,量子计算可能会让加密的破解变得更容易,但如果坏人一开始就无法获得你的数据,那也没有关系。 + +### 展望 2020 + +安全永远是重要的,(正如那篇量子计算文章所建议的)未来几年将是该领域的一个有趣时期。在 2020 年,我们的文章将着眼于开源安全的前沿,并帮助向不断增长的开源社区解释基础知识。如果你有一个你想要我们报导的主题,请在评论中分享它,或者更进一步 —— 如果你想写一篇文章,就写给我们吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/security-resources + +作者:[Ben Cotton][a] +选题:[lujun9972][b] +译者:[nacyro](https://github.com/nacyro) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bcotton +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003601_05_mech_osyearbook2016_security_cc.png?itok=3V07Lpko "A secure lock." +[2]: https://linux.cn/article-11444-1.html +[3]: https://linux.cn/article-11093-1.html +[4]: https://opensource.com/article/19/2/reducing-security-risks-centralized-logging +[5]: https://opensource.com/article/19/4/gpg-subkeys-ssh +[6]: https://opensource.com/article/19/4/gpg-subkeys-ssh-multiples +[7]: https://opensource.com/article/19/4/gpg-subkeys-ssh-manage +[8]: https://opensource.com/article/19/4/ssh-keys-seahorse +[9]: https://opensource.com/article/19/7/security-scanning-your-devops-pipeline +[10]: https://linux.cn/article-11432-1.html +[11]: https://opensource.com/article/19/6/cryptography-basics-openssl-part-1 +[12]: https://opensource.com/article/19/6/cryptography-basics-openssl-part-2 +[13]: https://opensource.com/article/19/3/computer-security-raspberry-pi +[14]: https://linux.cn/article-10566-1.html +[15]: https://opensource.com/how-submit-article diff --git a/published/202001/20191230 Fixing -VLC is Unable to Open the MRL- Error -Quick Tip.md b/published/202001/20191230 Fixing -VLC is Unable to Open the MRL- Error -Quick Tip.md new file mode 100644 index 0000000000..51b076d906 --- /dev/null +++ b/published/202001/20191230 Fixing -VLC is Unable to Open the MRL- Error -Quick Tip.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11748-1.html) +[#]: subject: (Fixing “VLC is Unable to Open the MRL” Error [Quick Tip]) +[#]: via: (https://itsfoss.com/vlc-is-unable-to-open-the-mrl/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +修复 “VLC is Unable to Open the MRL” 错误 +====== + +![](https://img.linux.net.cn/data/attachment/album/202001/05/084139mzlt1lfivilnnbkl.jpg) + +一个使用 [VLC 的技巧][1]是使用 [VLC] [2] 播放 YouTube 和其他在线视频。这可以帮助你[观看带有字幕的在线视频][3]。 + +但是事情并不总是这么简单,因为有时使用 VLC 打开 YouTube 视频时会遇到此错误: + +> Your input can’t be opened: VLC is unable to open the MRL ''. Check the log for details. + +![VLC error while playing YouTube videos][4] + +这是因为 Google 不想让你使用任何第三方应用观看 YouTube,因为这样他们就无法正常收集数据。 + +因此,他们不断修改服务端,以使第三发开发更难与 Youtube 集成。 + +以 [youtube-dl][5] 为例。你会发现自己无法突然[下载 YouTube 视频] [6],最简单的方案是安装最新版本的 youtube-dl。 + +对于 VLC 也是如此。如果你[在 Ubuntu 或任何你用的系统中安装了最新的 VLC][7],那么可能不会看到此错误。 + +### 修复 “VLC is unable to open the MRL” 错误 + +让我向你展示对于 YouTube 的修复步骤。 + +进入 VLC 媒体播放器的官方 Github 仓库页面的[这个页面][8],并使用 `Ctrl+S` 保存文件: + +现在,你需要做的是用此下载文件替换 `lib/vlc/lua/playlist` 目录中的 `youtube.luac`(注意 luac 中的 “c”)。 + +#### Linux 中的步骤 + +如果你使用的是 Linux,请打开终端并使用 [locate 命令][9]查找 `youtube.luac` 文件的确切位置: + +``` +locate youtube.luac +``` + +当你得到文件的路径时,只需将该文件替换为下载的文件即可。我相信你可以完成这项简单的任务。 + +对我而言,以下是文件路径: + +``` +abhishek@itsfoss:~$ locate youtube.lua +/usr/lib/x86_64-linux-gnu/vlc/lua/playlist/youtube.luac +``` + +因此,我要做的就是将下载的文件移到该位置并替换它的内容: + +``` +sudo cp ~/Downloads/youtube.lua /usr/lib/x86_64-linux-gnu/vlc/lua/playlist/youtube.luac +``` + +你现在应该可以在 VLC 中播放 YouTube 视频了。 + +#### Windows 中的步骤 + +如果你使用的是 Windows,那么应遵循以下步骤: + + * 将下载的 `youtube.lua` 文件重命名为 `youtube.luac` + * 复制此文件并将其粘贴到 `C:\Program Files (x86)\VideoLAN\VLC\lua\playlist\` + +就是这些了。 + +如果你在 Dailymotion 或其他视频流网站上遇到问题,那么可以从 VLC 仓库的[此处][10]下载它们各自的 lua 文件,并替换 VLC 安装中的现有 lua 文件。 + +我希望这个快速提示可以解决 VLC 无法为你播放 YouTube 视频的问题。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/vlc-is-unable-to-open-the-mrl/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/simple-vlc-tips/ +[2]: https://www.videolan.org/index.html +[3]: https://itsfoss.com/penguin-subtitle-player/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc_error_input_cant_be_played.png?ssl=1 +[5]: https://itsfoss.com/download-youtube-linux/ +[6]: https://itsfoss.com/download-youtube-videos-ubuntu/ +[7]: https://itsfoss.com/install-latest-vlc/ +[8]: https://raw.githubusercontent.com/videolan/vlc/master/share/lua/playlist/youtube.lua +[9]: https://linuxhandbook.com/locate-command/ +[10]: https://github.com/videolan/vlc/tree/master/share/lua/playlist diff --git a/published/202001/20191231 10 Ansible resources to accelerate your automation skills.md b/published/202001/20191231 10 Ansible resources to accelerate your automation skills.md new file mode 100644 index 0000000000..00d31b98a2 --- /dev/null +++ b/published/202001/20191231 10 Ansible resources to accelerate your automation skills.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: (BrunoJu) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11760-1.html) +[#]: subject: (10 Ansible resources to accelerate your automation skills) +[#]: via: (https://opensource.com/article/19/12/ansible-resources) +[#]: author: (James Farrell https://opensource.com/users/jamesf) + +提升自动化技巧的 10 篇 Ansible 文章 +====== + +> 今年,准备好,用出色的 Ansible 自动化技能装备自己的技能包吧。 + +![](https://img.linux.net.cn/data/attachment/album/202001/07/231057fbtfjwrn29ficxj0.jpg) + +今年我关注了大量关于 Ansible 的文章,以下这些内容都值得每个人学习,无论是否是 Ansible 的新手。 + +这些文章值得大家标记为书签,或者设置个计划任务(亦或者是设置一个 Tower/AWX 任务),用来提醒自己常读常新。 + +如果你是 Ansible 的新手,那么就从这些文章开始着手吧: + +* 《[Ansible 快速入门指南][2]》拥有一些对新手非常有用的信息,同时还介绍了一些更高级的话题。 +* 《[你需要知道的 10 个 Ansible 模块][3]》和《[5 个 Ansible 运维任务][4]》(译文)这两篇文章有每一位 Ansible 管理员都应该熟悉并认真研习的一些最基础的 Ansible 功能。 +* 《[如何使用 Ansible 记录流程][5]》这篇文章是对一些额外话题的纵览,我猜你一定会感到很有趣。 + +剩余的这些文章包含了更多高级的话题,比如 Windows 管理、测试、硬件、云和容器,甚至包括了一个案例研究,如何管理那些对技术有兴趣的孩子的需求。 + +我希望你能像我一样好好享受 Ansible 带来的乐趣。不要停止学习哦! + +1. 《[Ansible 如何为我的家庭带来和平][6]》这个异想天开的案例,你能看到如何利用 Ansible 为孩子们快速部署一个新的笔记本(或者重装旧笔记本) +2. Taz Brown 和 Abner Malivert 的《[适用于 Windows 管理员的 Ansible][7]》:你知道 Ansible 也可以管理 Windows 的节点吗?这篇文章以部署一个 IIS 为案例,阐述了基础的 Ansible 服务器和 Windows 客户端的安装。 +3. Shashank Hegde 的《[你需要知道的 10 个 Ansible 模块][3]》是个学习你最应该知道的那些最常见、最基础的 Ansible 模块的好文章。运行命令、安装软件包和操作文件是许多有用的自动化工作的基础。 +4. Marco Bravo 的《[如何使用 Ansible 记录流程][5]》:Ansible 的 YAML 文件易于阅读,因此它们可以被用于记录完成任务所需的手动步骤。这一特性可以帮助你调试与扩展,这令工作变得异常轻松。同时,这篇文章还包含关于测试和分析等 Ansible 相关主题的指导。 +5. Clement Verna 的《[使用 Testinfra 和 Ansible 验证服务器状态][8]》(译文):测试环节是任何一个 CI/CD DevOps 流程不可或缺的一部分。所以为什么不把测试 Ansible 的运行结果也纳入其中呢?这个测试架构 Testinfra 的入门级文章可以帮助你检查配置结果。 +6. Mark Phillips 的《[Ansible 硬件起步][9]》:这个世界并不是完全已经被容器和虚拟机所占据。许多系统管理员仍然需要管理众多硬件资源。通过 Ansible 与一点 PXE、DHCP 以及其他技巧的结合,你可以创建一个方便的管理框架使硬件易于启动和运行。 +7. Jairo da Silva Junior 的《[你需要了解的关于 Ansible 模块的知识][10]》:模块给 Ansible 带来了巨大的潜力,已经有许多模块可以拿来利用。但如果没有你所需的模块,那你可以尝试给自己打造一个。看看这篇文章吧,它能让你了解如何从零开始打造自己所需的模块。 +8. Mark Phillips 的《[5 个 Ansible 运维任务][4]》(译文):这是另一个有关于如何使用 Ansible 来管理常见的系统操作任务的文章。这里描述了一系列可以取代命令行操作的 Tower(或 AWX)的案例。 +9. Chris Short 的《[Ansible 快速入门指南][2]》是个可以下载的 PDF 文档。它可以作为一本随时拿来翻阅的手册。这篇文章的开头有助于初学者入门。同时,还包括了一些其他的研究领域,比如模块测试、系统管理任务和针对 K8S 对象的管理。 +10. Mark Phillips 的《[Ansible 参考指南,带有 Ansible Tower 和 GitHub 的 CI/CD,等等][11]》:这是一篇每月进行总结更新的文章,充满了有趣的链接。话题包括了 Ansible 的基础内容、管理 Netapp 的 E 系列存储产品、调试、打补丁包和其他一些相关内容。文章中还包括了一些视频以及一些聚会的链接。请查看详情。 + +如果你也有一些你喜爱的 Ansible 文章,那请留言告诉我们吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/ansible-resources + +作者:[James Farrell][a] +选题:[lujun9972][b] +译者:[BrunoJu](https://github.com/BrunoJu) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jamesf +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/chaos_engineer_monster_scary_devops_gear_kubernetes.png?itok=GPYLvfVh (Gears above purple clouds) +[2]: https://opensource.com/article/19/2/quickstart-guide-ansible +[3]: https://opensource.com/article/19/9/must-know-ansible-modules +[4]: https://linux.cn/article-11312-1.html +[5]: https://opensource.com/article/19/4/ansible-procedures +[6]: https://opensource.com/article/19/9/ansible-documentation-kids-laptops +[7]: https://opensource.com/article/19/2/ansible-windows-admin +[8]: https://linux.cn/article-10943-1.html +[9]: https://opensource.com/article/19/5/hardware-bootstrapping-ansible +[10]: https://opensource.com/article/19/3/developing-ansible-modules +[11]: https://opensource.com/article/19/7/ansible-news-edition-one diff --git a/published/202001/20191231 12 programming resources for coders of all levels.md b/published/202001/20191231 12 programming resources for coders of all levels.md new file mode 100644 index 0000000000..2e32ec2515 --- /dev/null +++ b/published/202001/20191231 12 programming resources for coders of all levels.md @@ -0,0 +1,79 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11751-1.html) +[#]: subject: (12 programming resources for coders of all levels) +[#]: via: (https://opensource.com/article/19/12/programming-resources) +[#]: author: (Erik O'Shaughnessy https://opensource.com/users/jnyjny) + +12 个给全等级码农们的编程资源 +====== + +> 无论你身处编程旅程中的何处,这 12 篇编程文章都有你需要学习一些东西。 + +![](https://img.linux.net.cn/data/attachment/album/202001/05/102002cdjy66jucbcfs6dg.jpg) + +> “学习计算机编程的最佳时间是 20 年前,其次是现在。” +> — 计算机科学的谚语(也许是) + +无论你是新程序员、经验丰富的 Web 开发人员、后端大师、头发花白的系统程序员,还是其他神秘物种的计算机极客?无论你身处广阔的软件开发人员生态系统中的何处,在我们领域中唯一不变的就是需要了解新技术及其应用方法。这是过去一年来阅读量最大的 Opensource.com 文章的集合,我很高兴在这里与你分享它们。 + +### 好好学习 + +无论你的技能或兴趣是什么,学习如何编写计算机程序都可以将特定领域的知识变成一种超能力。不幸的是,至少从现在开始,还不可能通过坐在计算机前面接受电磁辐射就能学会如何编程。在这之前,我推荐这些出色的文章来帮助激发你的编程技能。它们解决了一些重要的问题,例如考虑学习哪种语言以及不同的入门方式。 + +* [你应该学习哪种编程语言?][2](译文) +* [学习 Python 的 12 个方式][3](译文) +* [你可以使用树莓派学习的三种流行编程语言][4](译文) +* [利用 Python 引导孩子的计算机思维][5](译文) + +### 天天向上 + +经验丰富的程序员知道,与学习编程相比,唯一更难的就是使你的技能和知识保持最新。但是我们是[自学成才][6]的一族,总是希望提高我们的专业知识和理解力。即使我们不期望使用新技术,我们也知道总会有人问起它们。这些有关 Rust、WebAssembly 和 Podman 的文章是开始学习软件技术一些即将出现的趋势的好地方。 + +* [为什么要在 WebAssembly 中使用 Rust?][7] +* [使用 WebAssembly 扩展命令行领域][8] +* [免 root 的 Podman 如何工作?][9] +* [为什么选择 Rust 作为你的下一种编程语言][10] + +### 老兵不死 + +尽管新技术层出不穷,但回顾过去可以帮助你前进。当今惊人的技术是建立在昨天的工具之上的,即使我们从未使用这些传奇语言编写过代码,它也将使我们很好地理解这些工具的功能和局限性。这一系列文章集中于 C 语言、用 AWK 编写的实际应用程序,以及对流行度下降但也许还没有消亡的计算机语言的有趣讨论。 + +* [C 的巨大影响] [11] +* [如何写好 C main 函数][12](译文) +* [用 AWK 喝咖啡][13](译文) +* [你最喜欢的“死”语言是什么?][14] + +### 学习不止 + +无论你在编程过程中处于何处,总有更多东西需要学习。我希望这些来自 2019 年的顶级资源能帮助你为 2020 年做好准备。感谢作者们和你——读者。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/programming-resources + +作者:[Erik O'Shaughnessy][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/jnyjny +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_3.png?itok=qw2A18BM (Woman sitting in front of her computer) +[2]: https://linux.cn/article-10769-1.html +[3]: https://linux.cn/article-11280-1.html +[4]: https://linux.cn/article-10661-1.html +[5]: https://linux.cn/article-11116-1.html +[6]: https://en.wikipedia.org/wiki/Autodidacticism +[7]: https://opensource.com/article/19/2/why-use-rust-webassembly +[8]: https://opensource.com/article/19/4/command-line-playgrounds-webassembly +[9]: https://opensource.com/article/19/2/how-does-rootless-podman-work +[10]: https://opensource.com/article/19/10/choose-rust-programming-language +[11]: https://opensource.com/article/19/10/command-line-heroes-c +[12]: https://linux.cn/article-10949-1.html +[13]: https://linux.cn/article-10555-1.html +[14]: https://opensource.com/article/19/6/favorite-dead-language diff --git a/published/202001/20200101 5 predictions for Kubernetes in 2020.md b/published/202001/20200101 5 predictions for Kubernetes in 2020.md new file mode 100644 index 0000000000..2ad58abd67 --- /dev/null +++ b/published/202001/20200101 5 predictions for Kubernetes in 2020.md @@ -0,0 +1,84 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11758-1.html) +[#]: subject: (5 predictions for Kubernetes in 2020) +[#]: via: (https://opensource.com/article/20/1/kubernetes-2020) +[#]: author: (Scott McCarty https://opensource.com/users/fatherlinux) + +2020 年对 Kubernetes 的 5 个预测 +====== + +> 以及,对 2019 年最受欢迎的 Kubernetes 文章的回顾。 + +![](https://img.linux.net.cn/data/attachment/album/202001/07/094358qucr5o2lu2lo23od.jpg) + +你是怎么追踪一个广受欢迎的项目(如 Kubernetes)的发展轨迹?你是怎么了解它发展到什么程度了?如果你在为这个项目作贡献或加入了特殊兴趣组(SIG),可能你会在潜移默化中了解到它的发展轨迹,但如果你的全日工作不涉及到为 Kubernetes 作贡献,那么你可能需要一点关于未来的预测来帮助你了解。对于一个诸如 Kubernetes 的快速发展的项目,年末是回顾过去的一年和展望新的一年的最好时机。 + +今年,Kubernetes 取得了很大的进展。除了去查看源码、文档、会议笔记,你也可以去浏览博客。为了深入了解,我在 Opensource.com 上找到了 Kubernetes 排名前十的文章。通过这些文章,我们能了解开发者们更喜欢读和写哪些话题的文章。我们开始吧! + +- [为什么数据科学家喜欢Kubernetes][13] +- [Kubernetes 机密信息和 ConfigMap 简介][14] +- [怎样在 Kubernetes 上运行 PostgreSQL][15](译文) +- [为什么说 Kubernetes 是一辆翻斗车][16](译文) +- [安全扫描你的 DevOps 流程][17] +- [在 Kubernetes 上部署 InfluxDB 和 Grafana 以收集 Twitter 统计信息][18] +- [使用 Kubernetes 操作器扩展 PostgreSQL][19] +- [使用 Kubernetes 控制器减少系统管理员的工作量][20] +- [将 Kubernetes 带到裸金属边缘计算][21] +- [为什么你不必担心 Kubernetes][22] + +首先,我要指明这些文章中有 5 篇是关于 Kubernetes 工作负载的扩展以及它们可以运行在什么场景。这些工作负载涵盖数据科学、PostgreSQL、InfluxDB、Grafana(不仅仅监控集群本身)和边缘计算。从历史角度看,Kubernetes 和容器都是在虚拟机上运行的,尤其是运行在由云提供的基础设施上时。抛开对于 Kubernetes 的兴趣因素,这也表明了终端用户们极度希望在裸机上安装 Kubernetes(参照 [用 OpenShift 在裸机环境运行 Kubernetes][2])。 + +其次,也有很多开发者希望了解操作相关的知识以及 Kubernetes 的最佳实践。从 [Kubernetes 操作器][3] 到 [Kubernetes 控制器][4],从 [机密信息][5] 到 [ConfigMaps][6],开发者和运维人员都希望能找到简化部署和管理工作的最佳实践。我们经常纠结在怎么去修改配置文件或别人会怎么配置,而不去回头想想这些配置是怎么让应用部署运转的(不是怎么安装,也不是怎么运行 Kubernetes)。 + +最后,人们似乎对入门教程真的感兴趣。事实上,构建 Kubernetes 所需了解的信息太多了,以至于让人们望而却步,也使他们走了错误的路。流行度高的文章中有几篇讲述了为什么你需要了解用 Kubernetes 运行应用程序,而不仅仅是安装它。就像最佳实践类的文章一样,人们也通常不会回头分析在入门时他们应该在什么地方花费时间。我一直秉持的理念是,把有限的时间和金钱投入到如何使用某项技术上,而不是如何构建它。 + +### 2020 年对 Kubernetes 的 5 个预测 + +回顾了 2019 年的相关主题,这些主题告诉我们 2020 年将如何发展?结合这些文章中的观点,加上我自己的看法,我来分享下我对于 2020 年以及未来发展趋势的想法: + +1. 工作负载扩展。我会关注高性能计算、AI/ML 以及使用操作器的有状态工作负载。 +2. 更多的生产中的最佳实践,尤其是跟一些成熟的标准相关的,像 PCI、HIPAA、NIST 等等。 +3. 提升免 root 和更安全的[运行时类][7](如 [gVisor][8]、[Kata Containers][9] 等等)的安全性。 +4. 在部署和开发者们共享应用时,把 Kubernetes 清单的更好的规范标准作为部署的核心要素。如 [podman 生成 kube][10]、[podman 运行 kube][11],还有多合一 Kubernetes 环境,如 [CodeReady Containers (CRC)][12] +5. 一个前所未有的网络、存储和专业硬件(如 GPU 等等)供应商的生态系统,为 Kubernetes 提供 BoB(LCTT 译注:best of breed,单项最佳品牌)解决方案(在自由软件中,我们相信开放的生态系统好过垂直整合的解决方案)。 + +期待 Kubernetes 在新的一年里再创辉煌! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/kubernetes-2020 + +作者:[Scott McCarty][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/fatherlinux +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_tea_laptop_computer_work_desk.png?itok=D5yMx_Dr (Person drinking a hat drink at the computer) +[2]: https://blog.openshift.com/kubernetes-on-metal-with-openshift/ +[3]: https://kubernetes.io/docs/concepts/extend-kubernetes/operator/ +[4]: https://kubernetes.io/docs/concepts/architecture/controller/ +[5]: https://kubernetes.io/docs/concepts/configuration/secret/ +[6]: https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/ +[7]: https://kubernetes.io/docs/concepts/containers/runtime-class/ +[8]: https://gvisor.dev/ +[9]: https://katacontainers.io/ +[10]: https://developers.redhat.com/blog/2019/01/29/podman-kubernetes-yaml/ +[11]: https://www.redhat.com/en/blog/rhel-81-minor-release-major-new-container-capabilities +[12]: https://developers.redhat.com/products/codeready-containers/overview +[13]: https://opensource.com/article/19/1/why-data-scientists-love-kubernetes +[14]: https://opensource.com/article/19/6/introduction-kubernetes-secrets-and-configmaps +[15]: https://linux.cn/article-10762-1.html +[16]: https://linux.cn/article-11011-1.html +[17]: https://opensource.com/article/19/7/security-scanning-your-devops-pipeline +[18]: https://opensource.com/article/19/2/deploy-influxdb-grafana-kubernetes +[19]: https://opensource.com/article/19/2/scaling-postgresql-kubernetes-operators +[20]: https://opensource.com/article/19/3/reducing-sysadmin-toil-kubernetes-controllers +[21]: https://opensource.com/article/19/3/bringing-kubernetes-bare-metal-edge +[22]: https://opensource.com/article/19/10/kubernetes-complex-business-problem diff --git a/published/202001/20200101 9 cheat sheets and guides to enhance your tech skills.md b/published/202001/20200101 9 cheat sheets and guides to enhance your tech skills.md new file mode 100644 index 0000000000..966b7aee3a --- /dev/null +++ b/published/202001/20200101 9 cheat sheets and guides to enhance your tech skills.md @@ -0,0 +1,85 @@ +[#]: collector: (lujun9972) +[#]: translator: (nacyro) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11753-1.html) +[#]: subject: (9 cheat sheets and guides to enhance your tech skills) +[#]: via: (https://opensource.com/article/20/1/cheat-sheets-guides) +[#]: author: (Lauren Pritchett https://opensource.com/users/lauren-pritchett) + +九个提升程序员技术技能的备忘单和指南 +====== + +> 用我们最新的编程备忘单和指南来为新年开局,它适合所有技能水平的人。 + +![](https://img.linux.net.cn/data/attachment/album/202001/05/233115etzm6hv4a3z5yvhg.jpg) + +对刚接触命令行的新程序员来说备忘单是完美的。然而,即便是最有经验的程序员也需要时不时地依靠参考资料。假如你刚好敲不出那个讨厌的快捷键,那么手边有个备忘单就很赞了。这是一份我们可供下载指南的综述,它将助你在 2020 年取得成功。 + +### 备忘单 + +#### Markdown + +[Markdown][2] 不仅针对程序员,任何人都可以借助它为纯文本文档增添语法和结构。此备忘单提供了使用 CommonMark 规范的 Markdown 基础要点。它还包括 GitHub 和 GitLab 的语法。 + +#### Linux 权限和用户 + +用这个 Linux 备忘单把[用户管理][3]命令放在手边。快速学习如何增删用户、查看历史以及设置权限。 + +#### Bash + +一旦你了解了 [Bash][4],在命令行中就蕴含了无限可能。我们的 Bash 备忘单可以帮助你更有效地使用键盘快捷键。不知不觉间,你就能在睡眠中(字面意义上)运行脚本。 + +#### Linux 常用命令 + +毫不奇怪,我们的 [Linux 常用命令备忘单][5]是如此受欢迎。这个备忘单包含了开始安装软件和导览文件系统的要点。为自己和你的同事打印出来吧。 + +#### 微服务 + +似乎每个人都在谈论[微服务][6],而且理由很充分。微服务使应用程序模块化,因此更容易构建和维护。它不再只是这个备忘单上的流行语。在[微服务开源指南][7]中了解重要的术语并学习更多关于微服务的基础知识。 + +#### Java + +此备忘单非常适合初级和中级 [Java][8] 程序员。它包括重要的上下文以及处理导入、变量、类等的代码。 + +#### pip + +程序员爱用 [pip][9] 命令来帮助安装、管理和使用 Python 软件包。然而,pip 可以做的远不止这些。这个备忘单将教你如何构建 wheels 和 record 包。 + +### 指南 + +#### 七个不可或缺的 PyPI 库 + +[这组 Python 教程][10]将帮助你学习如何更快地编写扩展、格式化代码、自动化测试、确保代码一致性,以及更多使用 PyPI 库的方法。 + +#### 开始学习 Kubernetes + +在这份平易近人的[指南][11]中,作者 Scott McCarty 用了一个出人意料的类比来解释 Kubernetes 的价值和上手步骤。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/cheat-sheets-guides + +作者:[Lauren Pritchett][a] +选题:[lujun9972][b] +译者:[nacyro](https://github.com/nacyro) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lauren-pritchett +[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://opensource.com/downloads/cheat-sheet-markdown +[3]: https://opensource.com/downloads/linux-permissions-cheat-sheet +[4]: https://opensource.com/downloads/bash-cheat-sheet +[5]: https://opensource.com/downloads/linux-common-commands-cheat-sheet +[6]: https://opensource.com/downloads/microservices-cheat-sheet +[7]: https://opensource.com/article/19/11/microservices-cheat-sheet +[8]: https://opensource.com/downloads/java-cheat-sheet +[9]: https://opensource.com/downloads/pip-cheat-sheet +[10]: https://opensource.com/downloads/7-essential-pypi-libraries +[11]: https://opensource.com/downloads/getting-started-kubernetes-ebook +[12]: https://opensource.com/users/fatherlinux +[13]: https://opensource.com/downloads/cheat-sheets +[14]: https://opensource.com/email-newsletter diff --git a/published/202001/20200101 Signal- A Secure, Open Source Messaging App.md b/published/202001/20200101 Signal- A Secure, Open Source Messaging App.md new file mode 100644 index 0000000000..4248470b90 --- /dev/null +++ b/published/202001/20200101 Signal- A Secure, Open Source Messaging App.md @@ -0,0 +1,122 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11764-1.html) +[#]: subject: (Signal: A Secure, Open Source Messaging App) +[#]: via: (https://itsfoss.com/signal-messaging-app/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Signal:安全、开源的聊天应用 +====== + +> Signal 是一款智能手机上的安全开源聊天应用。它还提供了适用于 Linux、Windows 和 macOS 的独立桌面应用。在本文中,我们来看看它的功能和可用性。 + +### 对于关注隐私的人来说,Signal 是 WhatsApp(和 Telegram)的绝佳替代品 + +![Signal App On Linux][1] + +Signal 是一款关注隐私的开源应用。像[爱德华·斯诺登][2]这样的隐私权倡导者建议使用它。 + +它可能没有 Telegram 或 WhatsApp 这么多的功能。但是,如果你想在交流时增强隐私,这是一个可靠的开源方案。 + +你可以在智能手机([iOS][3]/[Android][4])上安装,也可以在 Linux、Windows 和 macOS 上安装。 + +### Signal 的功能 + +**注意:** 某些功能是智能手机特有的。你可能无法在桌面应用上看到所有功能。 + +另请注意,目前,Signal 需要电话号码才能注册。如果你不想公开自己的私人电话号码,则可以使用 Google 语音或类似服务。 + +正如我已经提到的,这是为增强你的隐私而量身定制的。因此,用户体验可能不是你见过“最佳”的。但是,从隐私/安全角度考虑,我认为这是一个不错的选择。 + +![Signal Features][5] + +#### 消失的消息 + +你可以为对话中的消息设置一个计时器,以便根据它自动删除消息。 + +本质上,对话中的任何人都可以激活此功能。因此,你可以控制对话中的消息时保留还是消失。 + +#### 用作默认短信应用 + +如果你想在短信中使用开源应用,那么只需进入 Signal 的设置,并将其设置为短信和彩信的默认设置。 + +#### 屏幕安全 + +有一个巧妙的功能可以阻止应用内截图,它就是“屏幕安全”。 + +如果你开启它,那么你将无法为应用中的任何对话截图。你可以从应用设置中找到启用或禁用它的选项。 + +它可能并不是对所有人有用,但你可以尝试一下。 + +#### 安全数字 + +如果你想与朋友一起验证加密的安全性,只需点击个人资料并向下滚动找到“查看安全数字”。 + +你可以扫描验证或者看一眼并标记为已验证。 + +#### 锁定消息 + +如果你使用了锁(密码/指纹)来保护应用,那么即使你的设备已解锁,你也无法在通知中看到消息。 + +因此,当 Signal 处于锁定状态收到通知时,你会注意到通知的内容为 “**Locked Message**”,这对于注重隐私的用户来说是一个加分项。 + +#### 其它功能 + +![][6] + +如你所期待的聊天应用,你可以使用几个标签,并且可以根据需要创建一个组。但是,你无法管理你的组,你只能添加成员和更改群头像。 + +此外,Signal 还为其应用支持生物识别。 + +### 在 Ubuntu/Linux 上安装 Signal + +不幸的是,你无法在你的 Linux 发行版上找到 .deb 或者 .AppImage。因此,你需要根据[官方安装说明][7]在终端上安装。 + +在终端中输入以下内容: + +``` +curl -s https://updates.signal.org/desktop/apt/keys.asc | sudo apt-key add - +echo "deb [arch=amd64] https://updates.signal.org/desktop/apt xenial main" | sudo tee -a /etc/apt/sources.list.d/signal-xenial.list +sudo apt update && sudo apt install signal-desktop +``` + +只需在终端中一个接一个地复制并粘贴命令。 + +[Download Signal for Other Devices][7] + +### 我对 Signal 的想法 + +我已经使用 Signal 有几年了,它的功能已经得到了改善。但是,我仍然认为可以改善用户体验。 + +在隐私方面,(在我看来)这绝对是我们已有软件的一个很好的替代方案。你可以尝试一下,看看它的使用效果如何。 + +如果你想尝试一下它,也可以看看它的 [GitHub 页面][8]以获取最新的开发和 beta 版本。 + +与 WhatsApp 甚至 [Linux 上的 Telegram][9] 相比,Signal 可能不是流行的聊天应用。但是,你可以自己尝试一下,并鼓励你的朋友使用它。 + +你尝试过了吗?在下面的评论中,让我知道你对 “Signal” 的看法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/signal-messaging-app/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/signal-shot.jpg?ssl=1 +[2]: https://en.wikipedia.org/wiki/Edward_Snowden +[3]: https://apps.apple.com/us/app/signal-private-messenger/id874139669 +[4]: https://play.google.com/store/apps/details?id=org.thoughtcrime.securesms&hl=en_IN +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/signal-phone.jpg?ssl=1 +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/12/signal-shot-1.jpg?ssl=1 +[7]: https://signal.org/download/ +[8]: https://github.com/signalapp +[9]: https://itsfoss.com/install-telegram-desktop-linux/ diff --git a/published/202001/20200102 Put some loot in your Python platformer game.md b/published/202001/20200102 Put some loot in your Python platformer game.md new file mode 100644 index 0000000000..e379cc1307 --- /dev/null +++ b/published/202001/20200102 Put some loot in your Python platformer game.md @@ -0,0 +1,525 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11828-1.html) +[#]: subject: (Put some loot in your Python platformer game) +[#]: via: (https://opensource.com/article/20/1/loot-python-platformer-game) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +在你的 Python 平台类游戏中放一些奖励 +====== + +> 这部分是关于在使用 Python 的 Pygame 模块开发的视频游戏总给你的玩家提供收集的宝物和经验值的内容。 + +![](https://img.linux.net.cn/data/attachment/album/202001/29/131158jkwnhgd1nnawzn86.jpg) + +这是正在进行的关于使用 [Python 3][2] 的 [Pygame][3] 模块创建视频游戏的系列文章的第十部分。以前的文章有: + + * [通过构建一个简单的掷骰子游戏去学习怎么用 Python 编程][4] + * [使用 Python 和 Pygame 模块构建一个游戏框架][5] + * [如何在你的 Python 游戏中添加一个玩家][6] + * [用 Pygame 使你的游戏角色移动起来][7] + * [如何向你的 Python 游戏中添加一个敌人][8] + * [在 Pygame 游戏中放置平台][13] + * [在你的 Python 游戏中模拟引力][9] + * [为你的 Python 平台类游戏添加跳跃功能][10] + * [使你的 Python 游戏玩家能够向前和向后跑][11] + +如果你已经阅读了本系列的前几篇文章,那么你已经了解了编写游戏的所有基础知识。现在你可以在这些基础上,创造一个全功能的游戏。当你第一次学习时,遵循本系列代码示例,这样的“用例”是有帮助的,但是,用例也会约束你。现在是时候运用你学到的知识,以新的方式应用它们了。 + +如果说,说起来容易做起来难,这篇文章展示了一个如何将你已经了解的内容用于新目的的例子中。具体来说,就是它涵盖了如何使用你以前的课程中已经了解到的来实现奖励系统。 + +在大多数电子游戏中,你有机会在游戏世界中获得“奖励”或收集到宝物和其他物品。奖励通常会增加你的分数或者你的生命值,或者为你的下一次任务提供信息。 + +游戏中包含的奖励类似于编程平台。像平台一样,奖励没有用户控制,随着游戏世界的滚动进行,并且必须检查与玩家的碰撞。 + +### 创建奖励函数 + +奖励和平台非常相似,你甚至不需要一个奖励的类。你可以重用 `Platform` 类,并将结果称为“奖励”。 + +由于奖励类型和位置可能因关卡不同而不同,如果你还没有,请在你的 `Level` 中创建一个名为 `loot` 的新函数。因为奖励物品不是平台,你也必须创建一个新的 `loot_list` 组,然后添加奖励物品。与平台、地面和敌人一样,该组用于检查玩家碰撞: + +``` + def loot(lvl,lloc): + if lvl == 1: + loot_list = pygame.sprite.Group() + loot = Platform(300,ty*7,tx,ty, 'loot_1.png') + loot_list.add(loot) + + if lvl == 2: + print(lvl) + + return loot_list +``` + +你可以随意添加任意数量的奖励对象;记住把每一个都加到你的奖励清单上。`Platform` 类的参数是奖励图标的 X 位置、Y 位置、宽度和高度(通常让你的奖励精灵保持和所有其他方块一样的大小最为简单),以及你想要用作的奖励的图片。奖励的放置可以和贴图平台一样复杂,所以使用创建关卡时需要的关卡设计文档。 + +在脚本的设置部分调用新的奖励函数。在下面的代码中,前三行是上下文,所以只需添加第四行: + +``` +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) +plat_list = Level.platform( 1,tx,ty ) +loot_list = Level.loot(1,tx,ty) +``` + +正如你现在所知道的,除非你把它包含在你的主循环中,否则奖励不会被显示到屏幕上。将下面代码示例的最后一行添加到循环中: + +``` +    enemy_list.draw(world) +    ground_list.draw(world) +    plat_list.draw(world) +    loot_list.draw(world) +``` + +启动你的游戏看看会发生什么。 + +![Loot in Python platformer][12] + +你的奖励将会显示出来,但是当你的玩家碰到它们时,它们不会做任何事情,当你的玩家经过它们时,它们也不会滚动。接下来解决这些问题。 + +### 滚动奖励 + +像平台一样,当玩家在游戏世界中移动时,奖励必须滚动。逻辑与平台滚动相同。要向前滚动奖励物品,添加最后两行: + +``` +        for e in enemy_list: +            e.rect.x -= scroll +        for l in loot_list: +            l.rect.x -= scroll +``` + +要向后滚动,请添加最后两行: + +``` +        for e in enemy_list: +            e.rect.x += scroll +        for l in loot_list: +            l.rect.x += scroll +``` + +再次启动你的游戏,看看你的奖励物品现在表现得像在游戏世界里一样了,而不是仅仅画在上面。 + +### 检测碰撞 + +就像平台和敌人一样,你可以检查奖励物品和玩家之间的碰撞。逻辑与其他碰撞相同,除了撞击不会(必然)影响重力或生命值。取而代之的是,命中会导致奖励物品会消失并增加玩家的分数。 + +当你的玩家触摸到一个奖励对象时,你可以从 `loot_list` 中移除该对象。这意味着当你的主循环在 `loot_list` 中重绘所有奖励物品时,它不会重绘那个特定的对象,所以看起来玩家已经获得了奖励物品。 + +在 `Player` 类的 `update` 函数中的平台碰撞检测之上添加以下代码(最后一行仅用于上下文): + +``` +                loot_hit_list = pygame.sprite.spritecollide(self, loot_list, False) +                for loot in loot_hit_list: +                        loot_list.remove(loot) +                        self.score += 1 +                print(self.score) +  +        plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) +``` + +当碰撞发生时,你不仅要把奖励从它的组中移除,还要给你的玩家一个分数提升。你还没有创建分数变量,所以请将它添加到你的玩家属性中,该属性是在 `Player` 类的 `__init__` 函数中创建的。在下面的代码中,前两行是上下文,所以只需添加分数变量: + +``` +        self.frame = 0 +        self.health = 10 +        self.score = 0 +``` + +当在主循环中调用 `update` 函数时,需要包括 `loot_list`: + +``` +        player.gravity() +        player.update() +``` + +如你所见,你已经掌握了所有的基本知识。你现在要做的就是用新的方式使用你所知道的。 + +在下一篇文章中还有一些提示,但是与此同时,用你学到的知识来制作一些简单的单关卡游戏。限制你试图创造的东西的范围是很重要的,这样你就不会埋没自己。这也使得最终的成品看起来和感觉上更容易完成。 + +以下是迄今为止你为这个 Python 平台编写的所有代码: + +``` +#!/usr/bin/env python3 +# draw a world +# add a player and player control +# add player movement +# add enemy and basic collision +# add platform +# add gravity +# add jumping +# add scrolling + +# GNU All-Permissive License +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. + +import pygame +import sys +import os + +''' +Objects +''' + +class Platform(pygame.sprite.Sprite): + # x location, y location, img width, img height, img file + def __init__(self,xloc,yloc,imgw,imgh,img): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(os.path.join('images',img)).convert() + self.image.convert_alpha() + self.rect = self.image.get_rect() + self.rect.y = yloc + self.rect.x = xloc + +class Player(pygame.sprite.Sprite): + ''' + Spawn a player + ''' + def __init__(self): + pygame.sprite.Sprite.__init__(self) + self.movex = 0 + self.movey = 0 + self.frame = 0 + self.health = 10 + self.collide_delta = 0 + self.jump_delta = 6 + self.score = 1 + self.images = [] + for i in range(1,9): + img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert() + img.convert_alpha() + img.set_colorkey(ALPHA) + self.images.append(img) + self.image = self.images[0] + self.rect = self.image.get_rect() + + def jump(self,platform_list): + self.jump_delta = 0 + + def gravity(self): + self.movey += 3.2 # how fast player falls + + if self.rect.y > worldy and self.movey >= 0: + self.movey = 0 + self.rect.y = worldy-ty + + def control(self,x,y): + ''' + control player movement + ''' + self.movex += x + self.movey += y + + def update(self): + ''' + Update sprite position + ''' + + self.rect.x = self.rect.x + self.movex + self.rect.y = self.rect.y + self.movey + + # moving left + if self.movex < 0: + self.frame += 1 + if self.frame > ani*3: + self.frame = 0 + self.image = self.images[self.frame//ani] + + # moving right + if self.movex > 0: + self.frame += 1 + if self.frame > ani*3: + self.frame = 0 + self.image = self.images[(self.frame//ani)+4] + + # collisions + enemy_hit_list = pygame.sprite.spritecollide(self, enemy_list, False) + for enemy in enemy_hit_list: + self.health -= 1 + #print(self.health) + + loot_hit_list = pygame.sprite.spritecollide(self, loot_list, False) + for loot in loot_hit_list: + loot_list.remove(loot) + self.score += 1 + print(self.score) + + plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) + for p in plat_hit_list: + self.collide_delta = 0 # stop jumping + self.movey = 0 + if self.rect.y > p.rect.y: + self.rect.y = p.rect.y+ty + else: + self.rect.y = p.rect.y-ty + + ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) + for g in ground_hit_list: + self.movey = 0 + self.rect.y = worldy-ty-ty + self.collide_delta = 0 # stop jumping + if self.rect.y > g.rect.y: + self.health -=1 + print(self.health) + + if self.collide_delta < 6 and self.jump_delta < 6: + self.jump_delta = 6*2 + self.movey -= 33 # how high to jump + self.collide_delta += 6 + self.jump_delta += 6 + +class Enemy(pygame.sprite.Sprite): + ''' + Spawn an enemy + ''' + def __init__(self,x,y,img): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(os.path.join('images',img)) + self.movey = 0 + #self.image.convert_alpha() + #self.image.set_colorkey(ALPHA) + self.rect = self.image.get_rect() + self.rect.x = x + self.rect.y = y + self.counter = 0 + + + def move(self): + ''' + enemy movement + ''' + distance = 80 + speed = 8 + + self.movey += 3.2 + + if self.counter >= 0 and self.counter <= distance: + self.rect.x += speed + elif self.counter >= distance and self.counter <= distance*2: + self.rect.x -= speed + else: + self.counter = 0 + + self.counter += 1 + + if not self.rect.y >= worldy-ty-ty: + self.rect.y += self.movey + + plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) + for p in plat_hit_list: + self.movey = 0 + if self.rect.y > p.rect.y: + self.rect.y = p.rect.y+ty + else: + self.rect.y = p.rect.y-ty + + ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) + for g in ground_hit_list: + self.rect.y = worldy-ty-ty + + +class Level(): + def bad(lvl,eloc): + if lvl == 1: + enemy = Enemy(eloc[0],eloc[1],'yeti.png') # spawn enemy + enemy_list = pygame.sprite.Group() # create enemy group + enemy_list.add(enemy) # add enemy to group + + if lvl == 2: + print("Level " + str(lvl) ) + + return enemy_list + + def loot(lvl,tx,ty): + if lvl == 1: + loot_list = pygame.sprite.Group() + loot = Platform(200,ty*7,tx,ty, 'loot_1.png') + loot_list.add(loot) + + if lvl == 2: + print(lvl) + + return loot_list + + def ground(lvl,gloc,tx,ty): + ground_list = pygame.sprite.Group() + i=0 + if lvl == 1: + while i < len(gloc): + ground = Platform(gloc[i],worldy-ty,tx,ty,'ground.png') + ground_list.add(ground) + i=i+1 + + if lvl == 2: + print("Level " + str(lvl) ) + + return ground_list + + def platform(lvl,tx,ty): + plat_list = pygame.sprite.Group() + ploc = [] + i=0 + if lvl == 1: + ploc.append((20,worldy-ty-128,3)) + ploc.append((300,worldy-ty-256,3)) + ploc.append((500,worldy-ty-128,4)) + + while i < len(ploc): + j=0 + while j <= ploc[i][2]: + plat = Platform((ploc[i][0]+(j*tx)),ploc[i][1],tx,ty,'ground.png') + plat_list.add(plat) + j=j+1 + print('run' + str(i) + str(ploc[i])) + i=i+1 + + if lvl == 2: + print("Level " + str(lvl) ) + + return plat_list + +''' +Setup +''' +worldx = 960 +worldy = 720 + +fps = 40 # frame rate +ani = 4 # animation cycles +clock = pygame.time.Clock() +pygame.init() +main = True + +BLUE = (25,25,200) +BLACK = (23,23,23 ) +WHITE = (254,254,254) +ALPHA = (0,255,0) + +world = pygame.display.set_mode([worldx,worldy]) +backdrop = pygame.image.load(os.path.join('images','stage.png')).convert() +backdropbox = world.get_rect() +player = Player() # spawn player +player.rect.x = 0 +player.rect.y = 0 +player_list = pygame.sprite.Group() +player_list.add(player) +steps = 10 +forwardx = 600 +backwardx = 230 + +eloc = [] +eloc = [200,20] +gloc = [] +#gloc = [0,630,64,630,128,630,192,630,256,630,320,630,384,630] +tx = 64 #tile size +ty = 64 #tile size + +i=0 +while i <= (worldx/tx)+tx: + gloc.append(i*tx) + i=i+1 + +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) +plat_list = Level.platform( 1,tx,ty ) +loot_list = Level.loot(1,tx,ty) + +''' +Main loop +''' +while main == True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit(); sys.exit() + main = False + + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_LEFT or event.key == ord('a'): + print("LEFT") + player.control(-steps,0) + if event.key == pygame.K_RIGHT or event.key == ord('d'): + print("RIGHT") + player.control(steps,0) + if event.key == pygame.K_UP or event.key == ord('w'): + print('jump') + + if event.type == pygame.KEYUP: + if event.key == pygame.K_LEFT or event.key == ord('a'): + player.control(steps,0) + if event.key == pygame.K_RIGHT or event.key == ord('d'): + player.control(-steps,0) + if event.key == pygame.K_UP or event.key == ord('w'): + player.jump(plat_list) + + if event.key == ord('q'): + pygame.quit() + sys.exit() + main = False + + # scroll the world forward + if player.rect.x >= forwardx: + scroll = player.rect.x - forwardx + player.rect.x = forwardx + for p in plat_list: + p.rect.x -= scroll + for e in enemy_list: + e.rect.x -= scroll + for l in loot_list: + l.rect.x -= scroll + + # scroll the world backward + if player.rect.x <= backwardx: + scroll = backwardx - player.rect.x + player.rect.x = backwardx + for p in plat_list: + p.rect.x += scroll + for e in enemy_list: + e.rect.x += scroll + for l in loot_list: + l.rect.x += scroll + + world.blit(backdrop, backdropbox) + player.gravity() # check gravity + player.update() + player_list.draw(world) #refresh player position + enemy_list.draw(world) # refresh enemies + ground_list.draw(world) # refresh enemies + plat_list.draw(world) # refresh platforms + loot_list.draw(world) # refresh loot + + for e in enemy_list: + e.move() + pygame.display.flip() + clock.tick(fps) +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/loot-python-platformer-game + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUS_lovemoneyglory2.png?itok=AvneLxFp (Hearts, stars, and dollar signs) +[2]: https://www.python.org/ +[3]: https://www.pygame.org/news +[4]: https://linux.cn/article-9071-1.html +[5]: https://linux.cn/article-10850-1.html +[6]: https://linux.cn/article-10858-1.html +[7]: https://linux.cn/article-10874-1.html +[8]: https://linux.cn/article-10883-1.html +[9]: https://linux.cn/article-11780-1.html +[10]: https://linux.cn/article-11790-1.html +[11]: https://linux.cn/article-11819-1.html +[12]: https://opensource.com/sites/default/files/uploads/pygame-loot.jpg (Loot in Python platformer) +[13]: https://linux.cn/article-10902-1.html diff --git a/published/202001/20200103 GNOME has a Secret- Screen Recorder. Here-s How to Use it.md b/published/202001/20200103 GNOME has a Secret- Screen Recorder. Here-s How to Use it.md new file mode 100644 index 0000000000..87e445c9b0 --- /dev/null +++ b/published/202001/20200103 GNOME has a Secret- Screen Recorder. Here-s How to Use it.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11766-1.html) +[#]: subject: (GNOME has a ‘Secret’ Screen Recorder. Here’s How to Use it!) +[#]: via: (https://itsfoss.com/gnome-screen-recorder/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +GNOME 有一个“隐藏”的屏幕录像机 +====== + +[GNOME][1] 是[最受欢迎的桌面环境][2]之一。它有现代的 UI,并且带有许多特定于 GNOME 的应用,这些应用与桌面整体外观完美融合。 + +你可以根据自己的喜好来[调整 GNOME][3],但我不在这里讨论。GNOME 桌面有一些你可能不知道的隐藏功能。 + +这种不太显眼的功能之一是内置的屏幕录像机。 + +是的,你没有看错。如果你使用的是 GNOME 桌面,那么不必安装其他的 [Linux 屏幕录像机][4]。你只需要知道正确的快捷键即可。 + +### 立即使用 GNOME 屏幕录像机录制屏幕 + +要快速打开 GNOME 屏幕录像机,你需要[在 Ubuntu 或其他带有 GNOME 桌面的发行版中按下此快捷键][5]: + +``` +Ctrl + Alt + Shift + R +``` + +这将会立即开始录制你的桌面。你可以通过顶部的系统托盘区域的红点了解到正在录制: + +![The red dot in the system tray area indicates that screen recording is in progress][6] + +#### 增加录制时间 + +默认的最大录制时间仅为 30 秒。但是可以增加。 + +打开终端并使用以下命令: + +``` +gsettings set org.gnome.settings-daemon.plugins.media-keys max-screencast-length 300 +``` + +在上面的命令中,我将录音的最大长度增加到 300 秒(即 5 分钟)。你可以将其更改为任何其它值,但应以秒为单位。 + +如果你**不希望最长录音时间有任何限制,请将其设置为 `0`**,之后它会在你手动停止或者磁盘空间不足才会停止。 + +#### 停止屏幕录制 + +如前所述,你的桌面录制将在达到最大时间限制后自动停止。 + +要在此之前停止录制,你可以按下相同的组合键: + +``` +Ctrl + Alt + Shift + R +``` + +你的录制内容将以 [webm][7] 格式保存在家目录的 `Videos` 文件夹中。 + +#### 局限性 + +尽管使用这个小工具可以方便地快速录制桌面,但是与功能强大的 [Simple Screen Recorder][8] 这样的屏幕录制工具相比,它有一些局限性。 + +* 录制开始之前没有时间延迟选项 +* 没有暂停和播放选项 +* 它录制整个屏幕。无法仅录制应用窗口、特定区域或特定屏幕(如果你有多个屏幕)。 +* 视频以 webm 格式保存在用户的 `Videos` 目录中。你无法更改。你必须使用 [HandBrake 之类的工具将视频转换为其他格式][9]。 + +如你所见,这个秘密的 GNOME 屏幕录像机与 [Kazam][10] 之类的工具或其他此类工具所提供的功能相差很远。但是,它并不会尝试成为全功能的屏幕录像机。它只是为你提供录制屏幕的快速方法。 + +GNOME 是一个多功能的现代桌面环境。你可以大量地[调整 GNOME][3]。[GNOME 扩展][11]为桌面自定义提供了另一个维度。 + +该屏幕录像机是 GNOME 的隐藏功能之一,就像你自己很难轻易找到的挂起选项。 + +你喜欢它吗?你是否还想与我们分享其他隐藏的 GNOME 功能?请在评论区留言。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/gnome-screen-recorder/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://gnome.org/ +[2]: https://itsfoss.com/best-linux-desktop-environments/ +[3]: https://itsfoss.com/gnome-tweak-tool/ +[4]: https://itsfoss.com/best-linux-screen-recorders/ +[5]: https://itsfoss.com/ubuntu-shortcuts/ +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/gnome_screen_recording.jpg?ssl=1 +[7]: https://www.webmproject.org/about/ +[8]: https://itsfoss.com/record-screen-ubuntu-simplescreenrecorder/ +[9]: https://itsfoss.com/handbrake/ +[10]: https://itsfoss.com/kazam-screen-recorder/ +[11]: https://itsfoss.com/best-gnome-extensions/ diff --git a/published/202001/20200103 Introducing the guide to inter-process communication in Linux.md b/published/202001/20200103 Introducing the guide to inter-process communication in Linux.md new file mode 100644 index 0000000000..91a1f7821b --- /dev/null +++ b/published/202001/20200103 Introducing the guide to inter-process communication in Linux.md @@ -0,0 +1,168 @@ +[#]: collector: (lujun9972) +[#]: translator: (laingke) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11832-1.html) +[#]: subject: (Introducing the guide to inter-process communication in Linux) +[#]: via: (https://opensource.com/article/20/1/inter-process-communication-linux) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +免费电子书《Linux 进程间通信指南》介绍 +====== + +> 这本免费的电子书使经验丰富的程序员更深入了解 Linux 中进程间通信(IPC)的核心概念和机制。 + +![](https://img.linux.net.cn/data/attachment/album/202001/30/115631jthl0h61zhhmwpv1.jpeg) + +让一个软件过程与另一个软件过程进行对话是一个微妙的平衡行为。但是,它对于应用程序而言可能是至关重要的功能,因此这是任何从事复杂项目的程序员都必须解决的问题。你的应用程序是否需要启动由其它软件处理的工作;监视外设或网络上正在执行的操作;或者检测来自其它来源的信号,当你的软件需要依赖其自身代码之外的东西来知道下一步做什么或什么时候做时,你就需要考虑进程间通信inter-process communication(IPC)。 + +这在 Unix 操作系统上已经由来已久了,这可能是因为人们早期预期软件会来自各种来源。按照相同的传统,Linux 提供了一些同样的 IPC 接口和一些新接口。Linux 内核具有多种 IPC 方法,[util-linux 包][2]包含了 `ipcmk`、`ipcrm`、`ipcs` 和 `lsipc` 命令,用于监视和管理 IPC 消息。 + +### 显示进程间通信信息 + +在尝试 IPC 之前,你应该知道系统上已经有哪些 IPC 设施。`lsipc` 命令提供了该信息。 + +``` +RESOURCE DESCRIPTION LIMIT USED USE% +MSGMNI Number of message queues 32000 0 0.00% +MSGMAX Max size of message (byt.. 8192 - - +MSGMNB Default max size of queue 16384 - - +SHMMNI Shared memory segments 4096 79 1.93% +SHMALL Shared memory pages 184[...] 25452 0.00% +SHMMAX Max size of shared memory 18446744073692774399 +SHMMIN Min size of shared memory 1 - - +SEMMNI Number of semaphore ident 32000 0 0.00% +SEMMNS Total number of semaphore 1024000.. 0 0.00% +SEMMSL Max semaphores per semap 32000 - - +SEMOPM Max number of operations p 500 - - +SEMVMX Semaphore max value 32767 - - +``` + +你可能注意到,这个示例清单包含三种不同类型的 IPC 机制,每种机制在 Linux 内核中都是可用的:消息(MSG)、共享内存(SHM)和信号量(SEM)。你可以用 `ipcs` 命令查看每个子系统的当前活动: + +``` +$ ipcs + +------ Message Queues Creators/Owners --- +msqid perms cuid cgid [...] + +------ Shared Memory Segment Creators/Owners +shmid perms cuid cgid [...] +557056 700 seth users [...] +3571713 700 seth users [...] +2654210 600 seth users [...] +2457603 700 seth users [...] + +------ Semaphore Arrays Creators/Owners --- +semid perms cuid cgid [...] +``` + +这表明当前没有消息或信号量阵列,但是使用了一些共享内存段。 + +你可以在系统上执行一个简单的示例,这样就可以看到正在工作的系统之一。它涉及到一些 C 代码,所以你必须在系统上有构建工具。必须安装这些软件包才能从源代码构建软件,这些软件包的名称取决于发行版,因此请参考文档以获取详细信息。例如,在基于 Debian 的发行版上,你可以在 wiki 的[构建教程][3]部分了解构建需求,而在基于 Fedora 的发行版上,你可以参考该文档的[从源代码安装软件][4]部分。 + +### 创建一个消息队列 + +你的系统已经有一个默认的消息队列,但是你可以使用 `ipcmk` 命令创建你自己的消息队列: + +``` +$ ipcmk --queue +Message queue id: 32764 +``` + +编写一个简单的 IPC 消息发送器,为了简单,在队列 ID 中硬编码: + +``` +#include +#include +#include +#include + +struct msgbuffer { + char text[24]; +} message; + +int main() { + int msqid = 32764; + strcpy(message.text,"opensource.com"); + msgsnd(msqid, &message, sizeof(message), 0); + printf("Message: %s\n",message.text); + printf("Queue: %d\n",msqid); + return 0; + } +``` + +编译该应用程序并运行: + +``` +$ gcc msgsend.c -o msg.bin +$ ./msg.bin +Message: opensource.com +Queue: 32769 +``` + +你刚刚向你的消息队列发送了一条消息。你可以使用 `ipcs` 命令验证这一点,可以使用 `——queue` 选项将输出限制到该消息队列: + +``` +$ ipcs -q + +------ Message Queues -------- +key msqid owner perms used-bytes messages +0x7b341ab9 0 seth 666 0 0 +0x72bd8410 32764 seth 644 24 1 +``` + +你也可以检索这些消息: + +``` +#include +#include +#include + +struct msgbuffer { + char text[24]; +} message; + +int main() { + int msqid = 32764; + msgrcv(msqid, &message, sizeof(message),0,0); + printf("\nQueue: %d\n",msqid); + printf("Got this message: %s\n", message.text); + msgctl(msqid,IPC_RMID,NULL); + return 0; +``` + +编译并运行: + +``` +$ gcc get.c -o get.bin +$ ./get.bin + +Queue: 32764 +Got this message: opensource.com +``` + +### 下载这本电子书 + +这只是 Marty Kalin 的《[Linux 进程间通信指南][5]》中课程的一个例子,可从 Opensource.com 下载的这本最新免费(且 CC 授权)的电子书。在短短的几节课中,你将从消息队列、共享内存和信号量、套接字、信号等中了解 IPC 的 POSIX 方法。认真阅读 Marty 的书,你将成为一个博识的程序员。而这不仅适用于经验丰富的编码人员,如果你编写的只是 shell 脚本,那么你将拥有有关管道(命名和未命名)和共享文件的大量实践知识,以及使用共享文件或外部消息队列时需要了解的重要概念。 + +如果你对制作具有动态和具有系统感知的优秀软件感兴趣,那么你需要了解 IPC。让[这本书][5]做你的向导。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/inter-process-communication-linux + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[laingke](https://github.com/laingke) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coverimage_inter-process_communication_linux_520x292.png?itok=hPoen7oI (Inter-process Communication in Linux) +[2]: https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/ +[3]: https://wiki.debian.org/BuildingTutorial +[4]: https://docs.pagure.org/docs-fedora/installing-software-from-source.html +[5]: https://opensource.com/downloads/guide-inter-process-communication-linux diff --git a/published/202001/20200103 My Raspberry Pi retrospective- 6 projects and more.md b/published/202001/20200103 My Raspberry Pi retrospective- 6 projects and more.md new file mode 100644 index 0000000000..ad2ff90485 --- /dev/null +++ b/published/202001/20200103 My Raspberry Pi retrospective- 6 projects and more.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11771-1.html) +[#]: subject: (My Raspberry Pi retrospective: 6 projects and more) +[#]: via: (https://opensource.com/article/20/1/raspberry-pi-best) +[#]: author: (Anderson Silva https://opensource.com/users/ansilva) + +我的树莓派项目回顾 +====== + +> 看看我在好玩、能学习、有用处的树莓派上做了些什么。 + +![](https://img.linux.net.cn/data/attachment/album/202001/11/091748wekfv77t5ux5zzv2.jpg) + +无论是从历史上,还是从理论上讲,当时钟走到一个十年份第一年的 1 月 1 日的午夜 0 点时,就开始了一个十年或一个世纪或一个千年纪元。例如,20 世纪始于 1901 年 1 月 1 日,而不是 1900 年 1 月 1 日。原因很简单:现代日历中没有 0 年,因此这些时间段始于 1 年(使用公历)。但这不是我们在口语上和文化上指代时间段的方式。例如,当我们提到 80 年代的音乐或电影时,我们所说的是 1980 年至 1989 年。 + +我可以说,最近过去的 21 世纪 10 年代是云计算、社交媒体、移动技术和物联网(IoT)的十年,这其中就包括[树莓派][2]。最近,《时代》杂志将树莓派称为[过去十年中 10 个最佳小玩意][3]之一。我非常同意这点。 + +树莓派最初的于 2012 年推出,我过了几年才使用上了它。不过从那以后,我在家中做了许多有趣的教育项目,还在 Opensource.com 中记录了一些。 + +### 圣诞灯三部曲 + +三年来,我写了三篇探讨如何使用树莓派和开源项目 LightShowPi 控制圣诞灯的文章。第一篇文章《[用树莓派创建你自己的音乐灯光秀][4]》,非常基础地介绍了电子开发介绍和灯光秀的结合。第二篇文章,《[使用树莓派 SSH 进入你的圣诞树][5]》,稍微深入地介绍了通过远程管理和电子按钮控制灯光的方法。三部曲的最后一章《[用树莓派设置假期心情][6]》,回顾了上一年 LightShowPi 项目中引入的更改。 + +### DIY 项目 + +多年来,我已经将树莓派变成了几种有用的设备。有一次,我将树莓派变成了 [Pi MusicBox 音乐播放设备][7],它可以让你在 Web 界面中导入你喜欢的音乐流并在房间中播放。 + +将树莓派做成[移动视频录制设备][8]是另一个 DIY 项目。它需要一些额外的硬件,例如触摸屏、树莓派摄像头和电池组,但是它工作的很好。这个设备的最大缺点之一是当时树莓派的可用内存很小。我认为如果我将它重新配置在具有 4GB 内存的树莓派 4 上,那么这款便携式摄像机的功能可能会更好。这可能是一个会在 2020 年重新打造的项目。 + +我做的另一个小项目[客厅的数字时钟][9]使用了 Adafruit PiTFT 小屏幕。尽管这个项目很简单,但它可能是我使用时间最长的项目。那个时钟在我的电视机上呆了一年多,一天 24 小时不间断运行,直到屏幕烧坏为止。 + +### 圆周率日系列 + +最后但并非最不重要的一点是,在 2019 年的圆周率日(3 月 14 日)之前,我在 [14 内发布了 14 篇文章][10]。这是迄今为止我完成过的最具挑战性的写作项目,但是它使我能够涵盖许多不同的主题,并希望使读者对树莓派的丰富功能有更多的了解。 + +### 走向未来 + +我不认识树莓派基金会中的任何人,因此我不了解它的任何路线图和未来计划。我可以(但我不会)推测品牌及其设备的未来,它们让世界各地这么多不同社会地位的人扩展他们对计算机科学、电子和开源开发的知识。我希望基金会的管理层能够忠于其愿景和使命,并继续为世界各地的人们提供价格合理的技术。 + +21 世纪 10 年代过去了,那是多么甜蜜的十年。对我来说,它闻起来就像树莓派馅饼。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/raspberry-pi-best + +作者:[Anderson Silva][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/ansilva +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberrypi4_board_hardware.jpg?itok=KnFU7NvR (Raspberry Pi 4 board, posterized filter) +[2]: https://www.raspberrypi.org/ +[3]: https://time.com/5745302/best-gadgets-of-the-2010s-decade/?utm_source=reddit.com +[4]: https://opensource.com/life/15/2/music-light-show-with-raspberry-pi +[5]: https://opensource.com/life/15/12/ssh-your-christmas-tree-raspberry-pi +[6]: https://opensource.com/article/18/12/lightshowpi-raspberry-pi +[7]: https://opensource.com/life/15/3/pi-musicbox-guide +[8]: https://opensource.com/life/15/9/turning-raspberry-pi-portable-streaming-camera +[9]: https://opensource.com/article/17/7/raspberry-pi-clock +[10]: https://opensource.com/article/19/3/happy-pi-day diff --git a/published/202001/20200105 PaperWM- tiled window management for GNOME.md b/published/202001/20200105 PaperWM- tiled window management for GNOME.md new file mode 100644 index 0000000000..ea412dae95 --- /dev/null +++ b/published/202001/20200105 PaperWM- tiled window management for GNOME.md @@ -0,0 +1,71 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11779-1.html) +[#]: subject: (PaperWM: tiled window management for GNOME) +[#]: via: (https://jvns.ca/blog/2020/01/05/paperwm/) +[#]: author: (Julia Evans https://jvns.ca/) + +PaperWM:GNOME 下的平铺窗口管理 +====== + +![](https://img.linux.net.cn/data/attachment/album/202001/13/212936hsk572f4jrsj2jsh.jpg) + +当我开始在个人计算机上使用 Linux 时,首先令我兴奋的就是轻巧的窗口管理器,这主要是因为当时我的笔记本电脑只有有 32MB 的内存,其它的都运行不了了。 + +接着我开始接触 [xmonad][1] 之类的平铺窗口管理器!我可以用键盘管理窗口了!它们是如此之快!我可以通过编写 Haskell 程序来配置 xmonad!我可以用各种有趣的方式自定义所有内容(例如使用 [dmenu][2] 作为启动器)!这些年来,我用过 3、4 个不同的平铺窗口管理器,它们都很有趣。 + +大约 6 年前,我觉得配置平铺窗口管理器对我来说不再是一件有趣的事情,因此转而使用 Ubuntu 桌面环境 Gnome。(现在,我的笔记本电脑中的内存增加了 500 倍,这要快得多 :) ) + +我使用 Gnome 已有很长时间了,但是我仍然有点想念平铺窗口管理器。六个月前,一个朋友告诉我有关 [PaperWM][3] 的消息,它使你可以在 Gnome 中平铺窗口!我立即安装了它,并从那时起我一直在使用它。 + +### PaperWM:Gnome 下的平铺窗口管理 + +[PaperWM][3] 的基本思想是:你想继续使用 Gnome(因为在 Gnome 中各种任务都能完成),但是你也希望使用平铺窗口管理器。 + +它是一个 Gnome 扩展程序(而不是一个独立的窗口管理器),并且使用 Javascript。 + +### “Paper” 表示你的所有窗户都在一行中 + +PaperWM 的主要想法是将所有窗口排成一行,这实际上与传统的平铺窗口管理器大不相同,在传统的平铺窗口管理器中,你可以按任意方式平铺窗口。这是我写这篇博客时在几个窗口之间切换/调整大小的 gif 图像(有一个浏览器和两个终端窗口): + +![][4] + +PaperWM 的 Github README 链接了此视频:,它描述为一个类似的”线性窗口管理器“。 + +我以前从未听说过这种组织窗口的方式,但是我喜欢它的简单性。如果要查找特定的窗口,只需向左/向右移动,直到找到它。 + +### 我在 PaperWM 中所做的一切 + +还有很多其他功能,但这是我使用的功能: + +* 在窗口之间左右移动(`Super + ,`、`Super + .`) +* 按顺序向左/向右移动窗口(`Super+Shift+,`、`Super+Shift+.`) +* 全屏显示窗口(`Super + f`) +* 缩小窗口(`Super + r`) + +### 我喜欢不需要配置的工具 + +我在笔记本上使用 PaperWM 已经 6 个月了,我真的很喜欢它!即使它是可配置(通过编写 Javascript 配置文件),我也非常欣赏它,它自带我想要的功能,我无需研究如何去配置。 + +[fish shell][5] 是另一个类似的令人愉悦的工具,我基本上没有配置 fish(除了设置环境变量等),我真的很喜欢它的默认功能。 + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2020/01/05/paperwm/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://xmonad.org/ +[2]: https://wiki.archlinux.org/index.php/Dmenu +[3]: https://github.com/paperwm/PaperWM +[4]: https://jvns.ca/images/paperwm.gif +[5]: https://jvns.ca/blog/2017/04/23/the-fish-shell-is-awesome/ diff --git a/published/202001/20200106 How to write a Python web API with Pyramid and Cornice.md b/published/202001/20200106 How to write a Python web API with Pyramid and Cornice.md new file mode 100644 index 0000000000..1ebcc920e9 --- /dev/null +++ b/published/202001/20200106 How to write a Python web API with Pyramid and Cornice.md @@ -0,0 +1,151 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11788-1.html) +[#]: subject: (How to write a Python web API with Pyramid and Cornice) +[#]: via: (https://opensource.com/article/20/1/python-web-api-pyramid-cornice) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +如何使用 Pyramid 和 Cornice 编写 Python Web API +====== + +> 使用 Pyramid 和 Cornice 构建和描述可扩展的 RESTful Web 服务。 + +![](https://img.linux.net.cn/data/attachment/album/202001/16/120352fcgeeccvfgt8sfvc.jpg) + +[Python][2] 是一种高级的、面向对象的编程语言,它以其简单的语法而闻名。它一直是构建 RESTful API 的顶级编程语言之一。 + +[Pyramid][3] 是一个 Python Web 框架,旨在随着应用的扩展而扩展:这可以让简单的应用很简单,也可以增长为大型、复杂的应用。此外,Pyramid 为 PyPI (Python 软件包索引)提供了强大的支持。[Cornice][4] 为使用 Pyramid 构建和描述 RESTful Web 服务提供了助力。 + +本文将使用 Web 服务的例子来获取名人名言,来展示如何使用这些工具。 + +### 建立 Pyramid 应用 + +首先为你的应用创建一个虚拟环境,并创建一个文件来保存代码: + +``` +$ mkdir tutorial +$ cd tutorial +$ touch main.py +$ python3 -m venv env +$ source env/bin/activate +(env) $ pip3 install cornice twisted +``` + +### 导入 Cornice 和 Pyramid 模块 + +使用以下命令导入这些模块: + +``` +from pyramid.config import Configurator +from cornice import Service +``` + +### 定义服务 + +将引用服务定义为 `Service` 对象: + +``` +QUOTES = Service(name='quotes', +                 path='/', +                 description='Get quotes') +``` + +### 编写引用逻辑 + +到目前为止,这仅支持获取名言。用 `QUOTES.get` 装饰函数。这是将逻辑绑定到 REST 服务的方法: + +``` +@QUOTES.get() +def get_quote(request): +    return { +        'William Shakespeare': { +            'quote': ['Love all, trust a few, do wrong to none', +            'Some are born great, some achieve greatness, and some have greatness thrust upon them.'] +    }, +    'Linus': { +        'quote': ['Talk is cheap. Show me the code.'] +        } +    } +``` + +请注意,与其他框架不同,装饰器*不会*更改 `get_quote` 函数。如果导入此模块,你仍然可以定期调用该函数并检查结果。 + +在为 Pyramid RESTful 服务编写单元测试时,这很有用。 + +### 定义应用对象 + +最后,使用 `scan` 查找所有修饰的函数并将其添加到配置中: + +``` +with Configurator() as config: +    config.include("cornice") +    config.scan() +    application = config.make_wsgi_app() +``` + +默认扫描当前模块。如果要扫描软件包中的所有模块,你也可以提供软件包的名称。 + +### 运行服务 + +我使用 Twisted 的 WSGI 服务器运行该应用,但是如果需要,你可以使用任何其他 [WSGI][5] 服务器,例如 Gunicorn 或 uWSGI。 + +``` +(env)$ python -m twisted web --wsgi=main.application +``` + +默认情况下,Twisted 的 WSGI 服务器运行在端口 8080 上。你可以使用 [HTTPie][6] 测试该服务: + +``` +(env) $ pip install httpie +... +(env) $ http GET +HTTP/1.1 200 OK +Content-Length: 220 +Content-Type: application/json +Date: Mon, 02 Dec 2019 16:49:27 GMT +Server: TwistedWeb/19.10.0 +X-Content-Type-Options: nosniff + +{ +    "Linus": { +        "quote": [ +            "Talk is cheap. Show me the code." +        ] +    }, +    "William Shakespeare": { +        "quote": [ +            "Love all,trust a few,do wrong to none", +            "Some are born great, some achieve greatness, and some greatness thrust upon them." +        ] +    } +} +``` + +### 为什么要使用 Pyramid? + +Pyramid 并不是最受欢迎的框架,但它已在 [PyPI][7] 等一些引人注目的项目中使用。我喜欢 Pyramid,因为它是认真对待单元测试的框架之一:因为装饰器不会修改函数并且没有线程局部变量,所以可以直接从单元测试中调用函数。例如,需要访问数据库的函数将从通过 `request.config` 传递的 `request.config` 对象中获取它。这允许单元测试人员将模拟(或真实)数据库对象放入请求中,而不用仔细设置全局变量、线程局部变量或其他特定于框架的东西。 + +如果你正在寻找一个经过测试的库来构建你接下来的 API,请尝试使用 Pyramid。你不会失望的。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/python-web-api-pyramid-cornice + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/search_find_code_python_programming.png?itok=ynSL8XRV (Searching for code) +[2]: https://opensource.com/resources/python +[3]: https://opensource.com/article/18/5/pyramid-framework +[4]: https://cornice.readthedocs.io/en/latest/ +[5]: https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface +[6]: https://opensource.com/article/19/8/getting-started-httpie +[7]: https://pypi.org/ diff --git a/published/202001/20200107 Generating numeric sequences with the Linux seq command.md b/published/202001/20200107 Generating numeric sequences with the Linux seq command.md new file mode 100644 index 0000000000..c04fc6ff3a --- /dev/null +++ b/published/202001/20200107 Generating numeric sequences with the Linux seq command.md @@ -0,0 +1,151 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11784-1.html) +[#]: subject: (Generating numeric sequences with the Linux seq command) +[#]: via: (https://www.networkworld.com/article/3511954/generating-numeric-sequences-with-the-linux-seq-command.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +使用 Linux seq 命令生成数字序列 +====== + +![](https://img.linux.net.cn/data/attachment/album/202001/15/112717drpb9nuwss84xebu.jpg) + +> Linux 的 seq 命令可以以闪电般的速度生成数字列表,而且它也易于使用而且灵活。 + +在 Linux 中生成数字列表的最简单方法之一是使用 `seq`(系列sequence)命令。其最简单的形式是,`seq` 接收一个数字参数,并输出从 1 到该数字的列表。例如: + +``` +$ seq 5 +1 +2 +3 +4 +5 +``` + +除非另有指定,否则 `seq` 始终以 1 开头。你可以在最终数字前面插上不同数字开始一个序列。 + +``` +$ seq 3 5 +3 +4 +5 +``` + +### 指定增量 + +你还可以指定增量步幅。假设你要列出 3 的倍数。指定起点(在此示例中为第一个 3 ),增量(第二个 3)和终点(18)。 + +``` +$ seq 3 3 18 +3 +6 +9 +12 +15 +18 +``` + +你可以选择使用负增量(即减量)将数字从大变小。 + +``` +$ seq 18 -3 3 +18 +15 +12 +9 +6 +3 +``` + +`seq` 命令也非常快。你或许可以在 10 秒内生成一百万个数字的列表。 + +``` +$ time seq 1000000 +1 +2 +3 +… +… +999998 +999999 +1000000 + +real 0m9.290s <== 9+ seconds +user 0m0.020s +sys 0m0.899s +``` + +### 使用分隔符 + +另一个非常有用的选项是使用分隔符。你可以插入逗号、冒号或其他一些字符,而不是在每行上列出单个数字。`-s` 选项后跟要使用的字符。 + +``` +$ seq -s: 3 3 18 +3:6:9:12:15:18 +``` + +实际上,如果只是希望将数字列在一行上,那么可以使用空格代替默认的换行符。 + +``` +$ seq -s' ' 3 3 18 +3 6 9 12 15 18 +``` + +### 开始数学运算 + +从生成数字序列到进行数学运算似乎是一个巨大的飞跃,但是有了正确的分隔符,`seq` 可以轻松地传递给 `bc` 进行计算。例如: + +``` +$ seq -s* 5 | bc +120 +``` + +该命令中发生了什么?让我们来看看。首先,`seq` 生成一个数字列表,并使用 `*` 作为分隔符。 + +``` +$ seq -s* 5 +1*2*3*4*5 +``` + +然后,它将字符串传递给计算器(`bc`),计算器立即将数字相乘。你可以在不到一秒的时间内进行相当庞大的计算。 + +``` +$ time seq -s* 117 | bc +39699371608087208954019596294986306477904063601683223011297484643104\ +22041758630649341780708631240196854767624444057168110272995649603642\ +560353748940315749184568295424000000000000000000000000000 + +real 0m0.003s +user 0m0.004s +sys 0m0.000s +``` + +### 局限性 + +你只能选择一个分隔符,因此计算将非常有限。而单独使用 `bc` 可进行更复杂的数学运算。此外,`seq` 仅适用于数字。要生成单个字母的序列,请改用如下命令: + +``` +$ echo {a..g} +a b c d e f g +``` + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3511954/generating-numeric-sequences-with-the-linux-seq-command.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://creativecommons.org/licenses/by/2.0/ +[2]: https://creativecommons.org/licenses/by/2.0/legalcode +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/202001/20200107 How piwheels will save Raspberry Pi users time in 2020.md b/published/202001/20200107 How piwheels will save Raspberry Pi users time in 2020.md new file mode 100644 index 0000000000..2fc0aafef9 --- /dev/null +++ b/published/202001/20200107 How piwheels will save Raspberry Pi users time in 2020.md @@ -0,0 +1,126 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11786-1.html) +[#]: subject: (How piwheels will save Raspberry Pi users time in 2020) +[#]: via: (https://opensource.com/article/20/1/piwheels) +[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall) + +piwheels 是如何为树莓派用户节省时间的 +====== + +> 通过为树莓派提供预编译的 Python 包,piwheels 项目为用户节省了大量的时间和精力。 + +![rainbow colors on pinwheels in the sun][1] + +piwheels 自动为 Python 包索引 [PiPi][2] 上的所有项目构建 Python wheels(预编译的 Python包),并使用了树莓派硬件以确保其兼容性。这意味着,当树莓派用户想要使用 `pip` 安装一个 Python 库时,他们会得到一个现成编译好的版本,并保证可以在树莓派上良好的工作。这使得树莓派用户更容易入门并开始他们的项目。 + +![Piwheels logo][3] + +当我在 2018 年 10 月写 [piwheels:为树莓派提供快速 Python 包安装][4]时,那时 piwheels 项目已经有一年了,并且已经证明了其为树莓派用户节省大量时间和精力。但当这个项目进入第二年时,它为树莓派提供了预编译的 Python 包做了更多工作。 + +![Raspberry Pi 4][5] + +### 它是怎么工作的 + +树莓派的主要操作系统 [Raspbian][6] 预配置使用了 piwheels,所以用户不需要做任何特殊的事情就可以使用 piwheels。 + +配置文件(在 `/etc/pip.conf`)告诉 `pip` 使用 [piwheels.org][7] 作*附加索引*,因此 `pip` 会首先查找 PyPI,然后查找 piwheels。piwheels 的网站被托管在一个树莓派 3 上,该项目构建的所有 wheels 都托管在该树莓派上。它每月提供 100 多万个软件包——这对于一台 35 美元的电脑来说还真不赖! + +除了提供网站服务的主树莓派以外,piwheels 项目还使用其他七个树莓派来构建软件包。其中一些运行 Raspbian Jessie,为 Python 3.4 构建 wheels;另外一些运行 Raspbian Stretch 为 Python 3.5 构建;还有一些运行 Raspbian Buster 为 Python 3.7 构建。该项目通常不支持其他 Python 版本。还有一个“合适的服务器”——一台运行 Postgres 数据库的虚拟机。由于树莓派 3 只有 1GB 的内存,所以(非常大的)数据库不能在其上很好地运行,所以我们把它移到了虚拟机上。带 4GB 内存的树莓派 4 可能是合用的,所以我们将来可能会用到它。 + +这些树莓派都在“派云”中的 IPv6 网络上——这是一项由总部位于剑桥的托管公司 [Mythic Beasts][8] 提供的卓越服务。 + +![Mythic Beasts hosting service][9] + +### 下载和统计趋势 + +每次下载 piwheels 文件时,它都会记录在数据库中。这提供了对什么包最受欢迎以及人们使用什么 Python 版本和操作系统的统计。我们没有太多来自用户代理的信息,但是因为树莓派 1/Zero 的架构显示为 “armv6”,树莓派 2/3/4 显示为 “armv7”,所以我们可以将它们区分开来。 + +截至 2019 年 12 月中旬,从 piwheels 下载的软件包超过 1400 万个,仅 2019 年就有近 900 万个。 + +自项目开始以来最受欢迎的 10 个软件包是: + + 1. [pycparser][10](821,060 个下载) + 2. [PyYAML][11](366,979 个下载) + 3. [numpy][12](354,531 个下载) + 4. [cffi][13](336,982 个下载) + 5. [MarkupSafe][14](318,878 个下载) + 6. [future][15](282,349 个下载) + 7. [aiohttp][16](277,046 个下载) + 8. [cryptography][17](276,167 个下载) + 9. [home-assistant-frontend][18](266,667 个下载) + 10. [multidict][19](256,185 个下载) + +请注意,许多纯 Python 包,如 [urllib3][20],都是作为 PyPI 上的 wheels 提供的;因为这些是跨平台兼容的,所以通常不会从 piwheels 下载,因为 PyPI 优先。 + +随着时间的推移,我们也看到了使用哪些 Python 版本的趋势。这里显示了 Raspbian Buster 发布时从 3.5 版快速升级到了 Python 3.7: + +![Data from piwheels on Python versions used over time][21] + +你可以在我们的这篇 [统计博文][22] 看到更多的统计趋势。 + +### 节省的时间 + +每个包构建都被记录在数据库中,并且每个下载也被存储。交叉引用下载数和构建时间显示了节省了多少时间。一个例子是 numpy —— 最新版本大约需要 11 分钟来构建。 + +迄今为止,piwheels 项目已经为用户节省了总计超过 165 年的构建时间。按照目前的使用率,piwheels 项目每天可以节省 200 多天。 + +除了节省构建时间,拥有预编译的 wheels 也意味着人们不必安装各种开发工具来构建包。一些包需要其他 apt 包来访问共享库。弄清楚你需要哪一个可能会很痛苦,所以我们也让这一步变得容易了。首先,我们找到了这个过程,[在博客上记录了这个过程][23]。然后,我们将这个逻辑添加到构建过程中,这样当构建一个 wheels 时,它的依赖关系会被自动计算并添加到包的项目页面中: + +![numpy dependencies][24] + +### piwheels 的下一步是什么? + +今年,我们推出了项目页面(例如,[numpy][25]),这是一种非常有用的方式,可以让人们以人类可读的方式查找项目信息。它们还使人们更容易报告问题,例如 piwheels 中缺少一个项目,或者他们下载的包有问题。 + +2020 年初,我们计划对 piwheels 项目进行一些升级,以启用新的 JSON 应用编程接口,这样你就可以自动检查哪些版本可用,查找项目的依赖关系,等等。 + +下一次 Debian/Raspbian 升级要到 2021 年年中才会发生,所以在那之前我们不会开始为任何新的 Python 版本构建 wheels。 + +你可以在这个项目的[博客][26]上读到更多关于 piwheels 的信息,我将在 2020 年初在那里发表一篇 2019 年的综述。你也可以在推特上关注 [@piwheels][27],在那里你可以看到每日和每月的统计数据以及任何达到的里程碑。 + +当然,piwheels 是一个开源项目,你可以在 [GitHub][28] 上看到整个项目源代码。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/piwheels + +作者:[Ben Nuttall][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bennuttall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rainbow-pinwheel-piwheel-diversity-inclusion.png?itok=di41Wd3V (rainbow colors on pinwheels in the sun) +[2]: https://pypi.org/ +[3]: https://opensource.com/sites/default/files/uploads/piwheels.png (Piwheels logo) +[4]: https://opensource.com/article/18/10/piwheels-python-raspberrypi +[5]: https://opensource.com/sites/default/files/uploads/raspberry-pi-4_0.jpg (Raspberry Pi 4) +[6]: https://www.raspberrypi.org/downloads/raspbian/ +[7]: http://piwheels.org +[8]: https://www.mythic-beasts.com/order/rpi +[9]: https://opensource.com/sites/default/files/uploads/pi-cloud.png (Mythic Beasts hosting service) +[10]: https://www.piwheels.org/project/pycparser +[11]: https://www.piwheels.org/project/PyYAML +[12]: https://www.piwheels.org/project/numpy +[13]: https://www.piwheels.org/project/cffi +[14]: https://www.piwheels.org/project/MarkupSafe +[15]: https://www.piwheels.org/project/future +[16]: https://www.piwheels.org/project/aiohttp +[17]: https://www.piwheels.org/project/cryptography +[18]: https://www.piwheels.org/project/home-assistant-frontend +[19]: https://www.piwheels.org/project/multidict +[20]: https://piwheels.org/project/urllib3/ +[21]: https://opensource.com/sites/default/files/uploads/pyvers2019.png (Data from piwheels on Python versions used over time) +[22]: https://blog.piwheels.org/piwheels-stats-for-2019/ +[23]: https://blog.piwheels.org/how-to-work-out-the-missing-dependencies-for-a-python-package/ +[24]: https://opensource.com/sites/default/files/uploads/numpy-deps.png (numpy dependencies) +[25]: https://www.piwheels.org/project/numpy/ +[26]: https://blog.piwheels.org/ +[27]: https://twitter.com/piwheels +[28]: https://github.com/piwheels/ diff --git a/published/202001/20200108 How to setup multiple monitors in sway.md b/published/202001/20200108 How to setup multiple monitors in sway.md new file mode 100644 index 0000000000..153933d6be --- /dev/null +++ b/published/202001/20200108 How to setup multiple monitors in sway.md @@ -0,0 +1,85 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11809-1.html) +[#]: subject: (How to setup multiple monitors in sway) +[#]: via: (https://fedoramagazine.org/how-to-setup-multiple-monitors-in-sway/) +[#]: author: (arte219 https://fedoramagazine.org/author/arte219/) + +如何在 Sway 中设置多个显示器 +====== + +![][1] + +Sway 是一种平铺式 Wayland 合成器,具有与 [i3 X11 窗口管理器][2]相同的功能、外观和工作流程。由于 Sway 使用 Wayland 而不是 X11,因此就不能一如既往地使用设置 X11 的工具。这包括 `xrandr` 之类的工具,这些工具在 X11 窗口管理器或桌面中用于设置显示器。这就是为什么必须通过编辑 Sway 配置文件来设置显示器的原因,这就是本文的目的。 + +### 获取你的显示器 ID + +首先,你必须获得 Sway 用来指代显示器的名称。你可以通过运行以下命令进行操作: + +``` +$ swaymsg -t get_outputs +``` + +你将获得所有显示器的相关信息,每个显示器都用空行分隔。 + +你必须查看每个部分的第一行,以及 `Output` 之后的内容。例如,当你看到 `Output DVI-D-1 'Philips Consumer Electronics Company'` 之类的行时,则该输出 ID 为 `DVI-D-1`。注意这些 ID 及其所属的物理监视器。 + +### 编辑配置文件 + +如果你之前没有编辑过 Sway 配置文件,则必须通过运行以下命令将其复制到主目录中: + +``` +cp -r /etc/sway/config ~/.config/sway/config +``` + +现在,默认配置文件位于 `~/.config/sway` 中,名为 `config`。你可以使用任何文本编辑器进行编辑。 + +现在你需要做一点数学。想象有一个网格,其原点在左上角。X 和 Y 坐标的单位是像素。Y 轴反转。这意味着,例如,如果你从原点开始,向右移动 100 像素,向下移动 80 像素,则坐标将为 `(100, 80)`。 + +你必须计算最终显示在此网格上的位置。显示器的位置由左上方的像素指定。例如,如果我们要使用名称为“HDMI1”且分辨率为 1920×1080 的显示器,并在其右侧使用名称为 “eDP1” 且分辨率为 1600×900 的笔记本电脑显示器,则必须在配置文件中键入 : + +``` +output HDMI1 pos 0 0 +output eDP1 pos 1920 0 +``` + +你还可以使用 `res` 选项手动指定分辨率: + +``` +output HDMI1 pos 0 0 res 1920x1080 +output eDP1 pos 1920 0 res 1600x900 +``` + +### 将工作空间绑定到显示器上 + +与多个监视器一起使用 Sway 在工作区管理中可能会有些棘手。幸运的是,你可以将工作区绑定到特定的显示器上,因此你可以轻松地切换到该显示器并更有效地使用它。只需通过配置文件中的 `workspace` 命令即可完成。例如,如果要绑定工作区 1 和 2 到显示器 “DVI-D-1”,绑定工作区 8 和 9 到显示器 “HDMI-A-1”,则可以使用以下方法: + +``` +workspace 1 output DVI-D-1 +workspace 2 output DVI-D-1 +``` + +``` +workspace 8 output HDMI-A-1 +workspace 9 output HDMI-A-1 +``` + +就是这样。这就在 Sway 中多显示器设置的基础知识。可以在 中找到更详细的指南。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/how-to-setup-multiple-monitors-in-sway/ + +作者:[arte219][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/arte219/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/01/sway-multiple-monitors-816x345.png +[2]: https://fedoramagazine.org/getting-started-i3-window-manager/ diff --git a/published/202001/20200109 Huawei-s Linux Distribution openEuler is Available Now.md b/published/202001/20200109 Huawei-s Linux Distribution openEuler is Available Now.md new file mode 100644 index 0000000000..891902da7e --- /dev/null +++ b/published/202001/20200109 Huawei-s Linux Distribution openEuler is Available Now.md @@ -0,0 +1,89 @@ +[#]: collector: (lujun9972) +[#]: translator: (qianmingtian) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11787-1.html) +[#]: subject: (Huawei’s Linux Distribution openEuler is Available Now!) +[#]: via: (https://itsfoss.com/openeuler/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +外媒:华为的 Linux 发行版 openEuler 可以使用了! +====== + +> 华为提供了一个基于 CentOS 的企业级 Linux 发行版 EulerOS。最近,华为发布了一个名为 [openEuler][1] 的 EulerOS 社区版。 + +openEuler 的源代码也一同发布了。你在微软旗下的 GitHub 上找不到它——源代码可以在 [Gitee][2] 找到,这是一个中文的 [GitHub 的替代品][3]。 + +它有两个独立的存储库,一个用于存储[源代码][2];另一个作为[软件包的源代码][4],存储有助于构建该操作系统的软件包。 + +![][5] + +openEuler 基础架构团队分享了他们使源代码可用的经验: + +> 我们现在很兴奋。很难想象我们会管理成千上万的仓库。为了确保它们能被成功地编译,我们要感谢所有参与贡献的人。 + +### openEuler 是基于 CentOS 的 Linux 发行版 + +与 EulerOS 一样,openEuler OS 也是基于 [CentOS][6],但华为技术有限公司为企业应用进一步开发了该操作系统。 + +它是为 ARM64 架构的服务器量身定做的,同时华为声称已经做了一些改变来提高其性能。你可以在[华为开发博客][7]上了解更多。 + +![][8] + +目前,根据 openEuler 的官方声明,有 50 多名贡献者为 openEuler 贡献了近 600 个提交。 + +贡献者们使源代码对社区可用成为可能。 + +值得注意的是,存储库还包括两个与之相关的新项目(或子项目),[iSulad][9] 和 A-Tune。 + +A-Tune 是一个基于 AI 的操作系统调优软件,iSulad 是一个轻量级的容器运行时守护进程,如在 [Gitee][2] 中提到的那样,它是为物联网和云基础设施设计的。 + +另外,官方的[公告][10]提到,这些系统是在华为云上通过脚本自动构建的。这确实十分有趣。 + +### 下载 openEuler + +![][11] + +到目前为止,你找不到它的英文文档,所以你必须等待或选择通过(贡献)[文档][12]来帮助他们。 + +你可以直接从它的[官方网站][13]下载 ISO 来测试它: + +- [下载 openEuler ][13] + +### 你认为华为的 openEuler 怎么样? + +据 cnTechPost 报道,华为曾宣布 EulerOS 将以新名字 openEuler 成为开源软件。 + +目前还不清楚 openEuler 是否会取代 EulerOS ,或者两者会像 CentOS(社区版)和 Red Hat(商业版)一样同时存在。 + +我还没有测试过它,所以我不能说 openEuler 是否适合英文用户。 + +你愿意试一试吗?如果你已经尝试过了,欢迎在下面的评论中告诉我你的体验。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/openeuler/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[qianmingtian][c] +校对:[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 +[c]: (https://github.com/qianmingtian) +[1]: https://openeuler.org/en/ +[2]: https://gitee.com/openeuler +[3]: https://itsfoss.com/github-alternatives/ +[4]: https://gitee.com/src-openeuler +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/openEuler-website.jpg?ssl=1 +[6]: https://www.centos.org/ +[7]: https://developer.huaweicloud.com/en-us/euleros/euleros-introduction.html +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/openeuler-gitee.jpg?ssl=1 +[9]: https://gitee.com/openeuler/iSulad +[10]: https://openeuler.org/en/news/20200101.html +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/01/openEuler.jpg?ssl=1 +[12]: https://gitee.com/openeuler/docs +[13]: https://openeuler.org/en/download.html diff --git a/published/202001/20200110 Bash Script to Send eMail With a List of User Accounts Expiring in -X- Days.md b/published/202001/20200110 Bash Script to Send eMail With a List of User Accounts Expiring in -X- Days.md new file mode 100644 index 0000000000..9a46a42281 --- /dev/null +++ b/published/202001/20200110 Bash Script to Send eMail With a List of User Accounts Expiring in -X- Days.md @@ -0,0 +1,139 @@ +[#]: collector: (lujun9972) +[#]: translator: (qianmingtian) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11781-1.html) +[#]: subject: (Bash Script to Send eMail With a List of User Accounts Expiring in “X” Days) +[#]: via: (https://www.2daygeek.com/bash-script-to-check-user-account-password-expiry-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +使用 Bash 脚本发送包含几天内到期的用户账号列表的电子邮件 +====== + +![](https://img.linux.net.cn/data/attachment/album/202001/13/232047vfxkrr47mn7eapda.jpg) + +密码强制策略对所有操作系统和应用程序都是通用的。如果要[在 Linux 上实现密码强制策略][1],请参阅以下文章。 + +默认情况下,大多数公司都会强制执行密码强制策略,但根据公司的要求,密码的时间周期会有所不同。通常每个人都使用 90 天的密码周期。用户只会在他们使用的一些服务器上[更改密码][2],而不会在他们不经常使用的服务器上更改密码。 + +特别地,大多数团队忘记更改服务帐户密码,这可能导致日常工作的中断,即使他们配置有[基于 SSH 密钥的身份验证][3]。如果用户帐户密码过期,基于SSH密钥的身份验证和 [cronjob][4] 将不起作用。 + +为了避免这种情况,我们创建了一个 [shell 脚本][5]来向你发送 10 天内到期的用户帐户列表。 + +本教程中包含两个 [bash 脚本][6]可以帮助你收集系统中用户到期天数的信息。 + +### 1) 检查 10 天后到期的用户帐户列表 + +此脚本将帮助你在终端上检查 10 天内到期的用户帐户列表。 + +``` +# vi /opt/script/user-password-expiry.sh +``` + +``` +#!/bin/sh +/tmp/user-expiry-1.txt +/tmp/user-expiry.txt +echo "-------------------------------------------------" +echo "UserName The number of days the password expires" +echo "-------------------------------------------------" +for usern in u1 u2 u3 u4 +do +today=$(date +%s) +userexpdate=$(chage -l $usern | grep 'Password expires' |cut -d: -f2) +passexp=$(date -d "$userexpdate" "+%s") +exp=`expr \( $passexp - $today \)` +expday=`expr \( $exp / 86400 \)` +echo "$usern $expday" >> /tmp/user-expiry.txt +done +cat /tmp/user-expiry.txt | awk '$2 <= 10' > /tmp/user-expiry-1.txt +cat /tmp/user-expiry-1.txt | column -t +``` + +将文件 `user-password-expiry.sh` 设置为可执行的 Linux 文件权限。 + +``` +# chmod +x /opt/script/user-password-expiry.sh +``` + +你将得到如下输出,但用户与天数可能不同。 + +``` +# sh /opt/script/user-password-expiry.sh + +------------------------------------------------- +UserName The number of days the password expires +------------------------------------------------- +u1 -25 +u2 9 +u3 3 +u4 5 +``` + +### 2) 发送包含 10 天内到期的用户帐户列表的电子邮件 + +此脚本将发送一封包含 10 天内到期的用户帐户列表的邮件。 + +``` +# vi /opt/script/user-password-expiry-mail.sh +``` + +``` +#!/bin/sh +SUBJECT="Information About User Password Expiration on "`date`"" +MESSAGE="/tmp/user-expiry.txt" +MESSAGE1="/tmp/user-expiry-1.txt" +TO="magesh.m@rentacenter.com" +echo "-------------------------------------------------" >> $MESSAGE1 +echo "UserName The number of days the password expires" >> $MESSAGE1 +echo "-------------------------------------------------" >> $MESSAGE1 +for usern in u1 u2 u3 u4 +do +today=$(date +%s) +userexpdate=$(chage -l $usern | grep 'Password expires' |cut -d: -f2) +passexp=$(date -d "$userexpdate" "+%s") +exp=`expr \( $passexp - $today \)` +expday=`expr \( $exp / 86400 \)` +echo "$usern $expday" >> $MESSAGE +done +cat $MESSAGE | awk '$2 <= 10' >> $MESSAGE1 +mail -s "$SUBJECT" "$TO" < $MESSAGE1 +rm $MESSAGE +rm $MESSAGE1 +``` + +将文件 `user-password-expiry-mail.sh` 设置为可执行的 Linux 文件权限。 + +``` +# chmod +x /opt/script/user-password-expiry-mail.sh +``` + +最后,添加一个 [cronjob][4] 去自动执行脚本。每天早上 8 点运行一次。 + +``` +# crontab -e +0 8 * * * /bin/bash /opt/script/user-password-expiry-mail.sh +``` + +你将收到一封与第一个脚本输出类似的电子邮件。 + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/bash-script-to-check-user-account-password-expiry-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[qianmingtian][c] +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[c]: https://github.com/qianmingtian +[1]: https://linux.cn/article-11709-1.html +[2]: https://www.2daygeek.com/linux-passwd-chpasswd-command-set-update-change-users-password-in-linux-using-shell-script/ +[3]: https://www.2daygeek.com/configure-setup-passwordless-ssh-key-based-authentication-linux/ +[4]: https://www.2daygeek.com/linux-crontab-cron-job-to-schedule-jobs-task/ +[5]: https://www.2daygeek.com/category/shell-script/ +[6]: https://www.2daygeek.com/category/bash-script/ diff --git a/published/202001/20200111 Sync files across multiple devices with Syncthing.md b/published/202001/20200111 Sync files across multiple devices with Syncthing.md new file mode 100644 index 0000000000..65959e3d59 --- /dev/null +++ b/published/202001/20200111 Sync files across multiple devices with Syncthing.md @@ -0,0 +1,65 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11793-1.html) +[#]: subject: (Sync files across multiple devices with Syncthing) +[#]: via: (https://opensource.com/article/20/1/sync-files-syncthing) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 Syncthing 在多个设备间同步文件 +====== + +> 2020 年,在我们的 20 个使用开源提升生产力的系列文章中,首先了解如何使用 Syncthing 同步文件。 + +![](https://img.linux.net.cn/data/attachment/album/202001/18/123416rebvs7sjwm6c889y.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 Synthing 同步文件 + +设置新机器很麻烦。我们都有在机器之间复制的“标准设置”。多年来,我使用了很多方法来使它们在计算机之间同步。在过去(这会告诉你我年纪有多大了),曾经是软盘、然后是 Zip 磁盘、U 盘、SCP、Rsync、Dropbox、ownCloud,你想到的都试过。但这些似乎对我都不够好。 + +然后我偶然发现了 [Syncthing][2]。 + +![syncthing console][3] + +Syncthing 是一个轻量级的点对点文件同步系统。你不需要为服务付费,也不需要第三方服务器,而且速度很快。以我的经验,比文件同步中的许多“大牌”要快得多。 + +Syncthing 可在 Linux、MacOS、Windows 和多种 BSD 中使用。还有一个 Android 应用(但尚无官方 iOS 版本)。以上所有终端都有方便的图形化前端(尽管我不会在这里介绍)。在 Linux 上,大多数发行版都有可用的软件包,因此安装非常简单。 + +![Installing Syncthing on Ubuntu][4] + +首次启动 Syncthing 时,它将启动 Web 浏览器以配置守护程序。第一台计算机上没有太多要做,但是这是一个很好的机会来介绍一下用户界面 (UI)。最重要的是在右上方的 “Actions” 菜单下的 “System ID”。 + +![Machine ID][5] + +设置第一台计算机后,请在第二台计算机上重复安装。在 UI 中,右下方将显示一个按钮,名为 “Add Remote Device”。单击该按钮,你将会看到一个要求输入 “Device ID and a Name” 的框。从第一台计算机上复制并粘贴 “Device ID”,然后单击 “Save”。 + +你应该会在第一台上看到一个请求添加第二台的弹出窗口。接受后,新机器将显示在第一台机器的右下角。与第二台计算机共享默认目录。单击 “Default Folder”,然后单击 “Edit” 按钮。弹出窗口的顶部有四个链接。单击 “Sharing”,然后选择第二台计算机。单击 “Save”,然后查看第二台计算机。你会看到一个接受共享目录的提示。接受后,它将开始在两台计算机之间同步文件。 + +![Sharing a directory in Syncthing][6] + +测试从一台计算机上复制文件到默认目录(“/你的家目录/Share”)。它应该很快会在另一台上出现。 + +你可以根据需要添加任意数量的目录,这非常方便。如你在第一张图中所看到的,我有一个用于保存配置的 `myconfigs` 文件夹。当我买了一台新机器时,我只需安装 Syncthing,如果我在一台机器上调整了配置,我不必更新所有,它会自动更新。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/sync-files-syncthing + +作者:[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/files_documents_paper_folder.png?itok=eIJWac15 (Files in a folder) +[2]: https://syncthing.net/ +[3]: https://opensource.com/sites/default/files/uploads/productivity_1-1.png (syncthing console) +[4]: https://opensource.com/sites/default/files/uploads/productivity_1-2.png (Installing Syncthing on Ubuntu) +[5]: https://opensource.com/sites/default/files/uploads/productivity_1-3.png (Machine ID) +[6]: https://opensource.com/sites/default/files/uploads/productivity_1-4.png (Sharing a directory in Syncthing) diff --git a/published/202001/20200112 Use Stow for configuration management of multiple machines.md b/published/202001/20200112 Use Stow for configuration management of multiple machines.md new file mode 100644 index 0000000000..cf673d3e6b --- /dev/null +++ b/published/202001/20200112 Use Stow for configuration management of multiple machines.md @@ -0,0 +1,59 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11796-1.html) +[#]: subject: (Use Stow for configuration management of multiple machines) +[#]: via: (https://opensource.com/article/20/1/configuration-management-stow) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 Stow 管理多台机器配置 +====== +> 2020 年,在我们的 20 个使用开源提升生产力的系列文章中,让我们了解如何使用 Stow 跨机器管理配置。 + +![](https://img.linux.net.cn/data/attachment/album/202001/18/141330jdcjalqzjal84a03.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 Stow 管理符号链接 + +昨天,我解释了如何使用 [Syncthing][2] 在多台计算机上保持文件同步。但是,这只是我用来保持配置一致性的工具之一。还有另一个表面上看起来更简单的工具:[Stow][3]。 + +![Stow help screen][4] + +Stow 管理符号链接。默认情况下,它会链接目录到上一级目录。还有设置源和目标目录的选项,但我通常不使用它们。 + +正如我在 Syncthing 的[文章][5] 中提到的,我使用 Syncthing 来保持 `myconfigs` 目录在我所有的计算机上一致。`myconfigs` 目录下面有多个子目录。每个子目录包含我经常使用的应用之一的配置文件。 + +![myconfigs directory][6] + +在每台计算机上,我进入 `myconfigs` 目录,并运行 `stow -S <目录名称>` 以将目录中的文件符号链接到我的家目录。例如,在 `vim` 目录下,我有 `.vimrc` 和 `.vim` 目录。在每台机器上,我运行 `stow -S vim` 来创建符号链接 `~/.vimrc` 和 `~/.vim`。当我在一台计算机上更改 Vim 配置时,它会应用到我的所有机器上。 + +然而,有时候,我需要一些特定于机器的配置,这就是为什么我有如 `msmtp-personal` 和 `msmtp-elastic`(我的雇主)这样的目录。由于我的 `msmtp` SMTP 客户端需要知道要中继电子邮件服务器,并且每个服务器都有不同的设置和凭据,我会使用 `-D` 标志来取消链接,接着链接另外一个。 + +![Unstow one, stow the other][7] + +有时我要给配置添加文件。为此,有一个 `-R` 选项来“重新链接”。例如,我喜欢在图形化 Vim 中使用一种与控制台不同的特定字体。除了标准 `.vimrc` 文件,`.gvimrc` 文件能让我设置特定于图形化版本的选项。当我第一次设置它时,我移动 `~/.gvimrc` 到 `~/myconfigs/vim` 中,然后运行 `stow -R vim`,它取消链接并重新链接该目录中的所有内容。 + +Stow 让我使用一个简单的命令行在多种配置之间切换,并且,结合 Syncthing,我可以确保无论我身在何处或在哪里进行更改,我都有我喜欢的工具的设置。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/configuration-management-stow + +作者:[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/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb (A person programming) +[2]: https://syncthing.net/ +[3]: https://www.gnu.org/software/stow/ +[4]: https://opensource.com/sites/default/files/uploads/productivity_2-1.png (Stow help screen) +[5]: https://linux.cn/article-11793-1.html +[6]: https://opensource.com/sites/default/files/uploads/productivity_2-2.png (myconfigs directory) +[7]: https://opensource.com/sites/default/files/uploads/productivity_2-3.png (Unstow one, stow the other) diff --git a/published/202001/20200113 Keep your email in sync with OfflineIMAP.md b/published/202001/20200113 Keep your email in sync with OfflineIMAP.md new file mode 100644 index 0000000000..64ecd19ab6 --- /dev/null +++ b/published/202001/20200113 Keep your email in sync with OfflineIMAP.md @@ -0,0 +1,78 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11804-1.html) +[#]: subject: (Keep your email in sync with OfflineIMAP) +[#]: via: (https://opensource.com/article/20/1/sync-email-offlineimap) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 OfflineIMAP 同步邮件 +====== + +> 将邮件镜像保存到本地是整理消息的第一步。在我们的 20 个使用开源提升生产力的系列的第三篇文章中了解该如何做。 + +![](https://img.linux.net.cn/data/attachment/album/202001/20/235324nbgfyuwl98syowta.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 OfflineIMAP 在本地同步你的邮件 + +我与邮件之间存在爱恨交织的关系。我喜欢它让我与世界各地的人交流的方式。但是,像你们中的许多人一样,我收到过很多邮件,许多是来自邮件列表的,但也有很多垃圾邮件、广告等。这些积累了很多。 + +![The OfflineIMAP "blinkenlights" UI][2] + +我尝试过的大多数工具(除了大型邮件服务商外)都可以很好地处理大量邮件,它们都有一个共同点:它们都依赖于以 [Maildir][3] 格式存储的本地邮件副本。这其中最有用的是 [OfflineIMAP][4]。OfflineIMAP 是将 IMAP 邮箱镜像到本地 Maildir 文件夹树的 Python 脚本。我用它来创建邮件的本地副本并使其保持同步。大多数 Linux 发行版都包含它,并且可以通过 Python 的 pip 包管理器获得。 + +示例的最小配置文件是一个很好的模板。首先将其复制到 `~/.offlineimaprc`。我的看起来像这样: + +``` +[general] +accounts = LocalSync +ui=Quiet +autorefresh=30 + +[Account LocalSync] +localrepository = LocalMail +remoterepository = MirrorIMAP + +[Repository MirrorIMAP] +type = IMAP +remotehost = my.mail.server +remoteuser = myusername +remotepass = mypassword +auth_mechanisms = LOGIN +createfolder = true +ssl = yes +sslcacertfile = OS-DEFAULT + +[Repository LocalMail] +type = Maildir +localfolders = ~/Maildir +sep = . +createfolder = true +``` + +我的配置要做的是定义两个仓库:远程 IMAP 服务器和本地 Maildir 文件夹。还有一个**帐户**,告诉 OfflineIMAP 运行时要同步什么。你可以定义链接到不同仓库的多个帐户。除了本地复制外,这还允许你从一台 IMAP 服务器复制到另一台作为备份。 + +如果你有很多邮件,那么首次运行 OfflineIMAP 将花费一些时间。但是完成后,下次会花*少得多*的时间。你也可以将 OfflineIMAP 作为 cron 任务(我的偏好)或作为守护程序在仓库之间不断进行同步。其文档涵盖了所有这些内容以及 Gmail 等高级配置选项。 + +现在,我的邮件已在本地复制,并有多种工具用来加快搜索、归档和管理邮件的速度。这些我明天再说。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/sync-email-offlineimap + +作者:[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/newsletter_email_mail_web_browser.jpg?itok=Lo91H9UH (email or newsletters via inbox and browser) +[2]: https://opensource.com/sites/default/files/uploads/productivity_3-1.png (The OfflineIMAP "blinkenlights" UI) +[3]: https://en.wikipedia.org/wiki/Maildir +[4]: http://www.offlineimap.org/ diff --git a/published/202001/20200113 setV- A Bash function to maintain Python virtual environments.md b/published/202001/20200113 setV- A Bash function to maintain Python virtual environments.md new file mode 100644 index 0000000000..45e4beaf52 --- /dev/null +++ b/published/202001/20200113 setV- A Bash function to maintain Python virtual environments.md @@ -0,0 +1,296 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11800-1.html) +[#]: subject: (setV: A Bash function to maintain Python virtual environments) +[#]: via: (https://opensource.com/article/20/1/setv-bash-function) +[#]: author: (Sachin Patil https://opensource.com/users/psachin) + +setV:一个管理 Python 虚拟环境的 Bash 函数 +====== + +> 了解一下 setV,它是一个轻量级的 Python 虚拟环境管理器,是 virtualenvwrapper 的替代产品。 + +![](https://img.linux.net.cn/data/attachment/album/202001/19/234306tvvg5ffwakrzr5vv.jpg) + +这一年多来,我的 [bash_scripts][3] 项目中悄悄隐藏这 [setV][2],但现在是时候该公开了。setV 是一个 Bash 函数,我可以用它代替 [virtualenvwrapper][4]。它提供了使你能够执行以下操作的基本功能: + +* 默认使用 Python 3 +* 创建一个新的虚拟环境 +* 使用带有 `-p`(或 `--python`)的自定义 Python 路径来创建新的虚拟环境 +* 删除现有的虚拟环境 +* 列出所有现有的虚拟环境 +* 使用制表符补全(以防你忘记虚拟环境名称) + +### 安装 + +要安装 setV,请下载该脚本: + +``` +curl https://gitlab.com/psachin/setV/raw/master/install.sh +``` + +审核一下脚本,然后运行它: + +``` +sh ./install.sh +``` + +当安装 setV 时,安装脚本会要求你引入(`source`)一下 `~/.bashrc` 或 `~/.bash_profile` 的配置,根据你的喜好选择一个。 + +### 用法 + +基本的命令格式是 `setv`。 + +#### 创建虚拟环境 + +``` +setv --new rango  # setv -n rango + +# 或使用定制的 Python 路径 +setv --new --python /opt/python/python3 rango  # setv -n -p /opt/python/python3 rango +``` + +#### 激活已有的虚拟环境 + +``` +setv VIRTUAL_ENVIRONMENT_NAME +``` + +``` +# 示例 +setv rango +``` + +#### 列出所有的虚拟环境 + +``` +setv --list +# 或 +setv [TAB] [TAB] +``` + +#### 删除虚拟环境 + +``` +setv --delete rango +``` + +#### 切换到另外一个虚拟环境 + +``` +# 假设你现在在 'rango',切换到 'tango' +setv tango +``` + +#### 制表符补完 + +如果你不完全记得虚拟环境的名称,则 Bash 式的制表符补全也可以适用于虚拟环境名称。 + +### 参与其中 + +setV 在 GNU [GPLv3][5]下开源,欢迎贡献。要了解更多信息,请访问它的 GitLab 存储库中的 setV 的 [README][6] 的贡献部分。 + +### setV 脚本 + +``` +#!/usr/bin/env bash +# setV - A Lightweight Python virtual environment manager. +# Author: Sachin (psachin) +# Author's URL: https://psachin.gitlab.io/about +# +# License: GNU GPL v3, See LICENSE file +# +# Configure(Optional): +# Set `SETV_VIRTUAL_DIR_PATH` value to your virtual environments +# directory-path. By default it is set to '~/virtualenvs/' +# +# Usage: +# Manual install: Added below line to your .bashrc or any local rc script(): +# --- +# source /path/to/virtual.sh +# --- +# +# Now you can 'activate' the virtual environment by typing +# $ setv +# +# For example: +# $ setv rango +# +# or type: +# setv [TAB] [TAB] (to list all virtual envs) +# +# To list all your virtual environments: +# $ setv --list +# +# To create new virtual environment: +# $ setv --new new_virtualenv_name +# +# To delete existing virtual environment: +# $ setv --delete existing_virtualenv_name +# +# To deactivate, type: +# $ deactivate + +# Path to virtual environment directory +SETV_VIRTUAL_DIR_PATH="$HOME/virtualenvs/" +# Default python version to use. This decides whether to use `virtualenv` or `python3 -m venv` +SETV_PYTHON_VERSION=3 # Defaults to Python3 +SETV_PY_PATH=$(which python${SETV_PYTHON_VERSION}) + +function _setvcomplete_() +{ + # Bash-autocompletion. + # This ensures Tab-auto-completions work for virtual environment names. + local cmd="${1##*/}" # to handle command(s). + # Not necessary as such. 'setv' is the only command + + local word=${COMP_WORDS[COMP_CWORD]} # Words thats being completed + local xpat='${word}' # Filter pattern. Include + # only words in variable '$names' + local names=$(ls -l "${SETV_VIRTUAL_DIR_PATH}" | egrep '^d' | awk -F " " '{print $NF}') # Virtual environment names + + COMPREPLY=($(compgen -W "$names" -X "$xpat" -- "$word")) # compgen generates the results +} + +function _setv_help_() { + # Echo help/usage message + echo "Usage: setv [OPTIONS] [NAME]" + echo Positional argument: + echo -e "NAME Activate virtual env." + echo Optional arguments: + echo -e "-l, --list List all Virtual Envs." + echo -e "-n, --new NAME Create a new Python Virtual Env." + echo -e "-d, --delete NAME Delete existing Python Virtual Env." + echo -e "-p, --python PATH Python binary path." +} + +function _setv_custom_python_path() +{ + if [ -f "${1}" ]; + then + if [ "`expr $1 : '.*python\([2,3]\)'`" = "3" ]; + then + SETV_PYTHON_VERSION=3 + else + SETV_PYTHON_VERSION=2 + fi + SETV_PY_PATH=${1} + _setv_create $2 + else + echo "Error: Path ${1} does not exist!" + fi +} + +function _setv_create() +{ + # Creates new virtual environment if ran with -n|--new flag + if [ -z ${1} ]; + then + echo "You need to pass virtual environment name" + _setv_help_ + else + echo "Creating new virtual environment with the name: $1" + + if [ ${SETV_PYTHON_VERSION} -eq 3 ]; + then + ${SETV_PY_PATH} -m venv ${SETV_VIRTUAL_DIR_PATH}${1} + else + virtualenv -p ${SETV_PY_PATH} ${SETV_VIRTUAL_DIR_PATH}${1} + fi + + echo "You can now activate the Python virtual environment by typing: setv ${1}" + fi +} + +function _setv_delete() +{ + # Deletes virtual environment if ran with -d|--delete flag + # TODO: Refactor + if [ -z ${1} ]; + then + echo "You need to pass virtual environment name" + _setv_help_ + else + if [ -d ${SETV_VIRTUAL_DIR_PATH}${1} ]; + then + read -p "Really delete this virtual environment(Y/N)? " yes_no + case $yes_no in + Y|y) rm -rvf ${SETV_VIRTUAL_DIR_PATH}${1};; + N|n) echo "Leaving the virtual environment as it is.";; + *) echo "You need to enter either Y/y or N/n" + esac + else + echo "Error: No virtual environment found by the name: ${1}" + fi + fi +} + +function _setv_list() +{ + # Lists all virtual environments if ran with -l|--list flag + echo -e "List of virtual environments you have under ${SETV_VIRTUAL_DIR_PATH}:\n" + for virt in $(ls -l "${SETV_VIRTUAL_DIR_PATH}" | egrep '^d' | awk -F " " '{print $NF}') + do + echo ${virt} + done +} + +function setv() { + # Main function + if [ $# -eq 0 ]; + then + _setv_help_ + elif [ $# -le 3 ]; + then + case "${1}" in + -n|--new) _setv_create ${2};; + -d|--delete) _setv_delete ${2};; + -l|--list) _setv_list;; + *) if [ -d ${SETV_VIRTUAL_DIR_PATH}${1} ]; + then + # Activate the virtual environment + source ${SETV_VIRTUAL_DIR_PATH}${1}/bin/activate + else + # Else throw an error message + echo "Sorry, you don't have any virtual environment with the name: ${1}" + _setv_help_ + fi + ;; + esac + elif [ $# -le 5 ]; + then + case "${2}" in + -p|--python) _setv_custom_python_path ${3} ${4};; + *) _setv_help_;; + esac + fi +} + +# Calls bash-complete. The compgen command accepts most of the same +# options that complete does but it generates results rather than just +# storing the rules for future use. +complete -F _setvcomplete_ setv +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/setv-bash-function + +作者:[Sachin Patil][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/psachin +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: https://gitlab.com/psachin/setV +[3]: https://github.com/psachin/bash_scripts +[4]: https://virtualenvwrapper.readthedocs.org/ +[5]: https://gitlab.com/psachin/setV/blob/master/LICENSE +[6]: https://gitlab.com/psachin/setV/blob/master/ReadMe.org +[7]: mailto:iclcoolster@gmail.com diff --git a/published/202001/20200114 Organize your email with Notmuch.md b/published/202001/20200114 Organize your email with Notmuch.md new file mode 100644 index 0000000000..dc9a67f7d6 --- /dev/null +++ b/published/202001/20200114 Organize your email with Notmuch.md @@ -0,0 +1,109 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11807-1.html) +[#]: subject: (Organize your email with Notmuch) +[#]: via: (https://opensource.com/article/20/1/organize-email-notmuch) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 Notmuch 组织你的邮件 +====== + +> Notmuch 可以索引、标记和排序电子邮件。在我们的 20 个使用开源提升生产力的系列的第四篇文章中了解该如何使用它。 + +![](https://img.linux.net.cn/data/attachment/album/202001/22/112231xg5dgv6f6g5a1iv1.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 用 Notmuch 为你的邮件建立索引 + +昨天,我谈到了如何使用 OfflineIMAP [将我的邮件同步][2]到本地计算机。今天,我将讨论如何在阅读之前预处理所有邮件。 + +![Notmuch][3] + +[Maildir][4] 可能是最有用的邮件存储格式之一。有很多工具可以帮助你管理邮件。我经常使用一个名为 [Notmuch][5] 的小程序,它能索引、标记和搜索邮件。Notmuch 配合其他几个程序一起使用可以使处理大量邮件更加容易。 + +大多数 Linux 发行版都包含 Notmuch,你也可以在 MacOS 上获得它。Windows 用户可以通过 Linux 的 Windows 子系统([WSL][6])访问它,但可能需要进行一些其他调整。 + +![Notmuch's first run][7] + +Notmuch 首次运行时,它将询问你一些问题,并在家目录中创建 `.notmuch-config` 文件。接下来,运行 `notmuch new` 来索引并标记所有邮件。你可以使用 `notmuch search tag:new` 进行验证,它会找到所有带有 `new` 标签的消息。这可能会有很多邮件,因为 Notmuch 使用 `new` 标签来指示新邮件,因此你需要对其进行清理。 + +运行 `notmuch search tag:unread` 来查找未读消息,这会减少很多邮件。要从你已阅读的消息中删除 `new` 标签,请运行 `notmuch tag -new not tag:unread`,它将搜索所有没有 `unread` 标签的消息,并从其中删除 `new` 标签。现在,当你运行 `notmuch search tag:new` 时,它将仅显示未读邮件。 + +但是,批量标记消息可能更有用,因为在每次运行时手动更新标记可能非常繁琐。`--batch` 命令行选项告诉 Notmuch 读取多行命令并执行它们。还有一个 `--input=filename` 选项,该选项从文件中读取命令并应用它们。我有一个名为 `tagmail.notmuch` 的文件,用于给“新”邮件添加标签;它看起来像这样: + +``` +# Manage sent, spam, and trash folders +-unread -new folder:Trash +-unread -new folder:Spam +-unread -new folder:Sent + +# Note mail sent specifically to me (excluding bug mail) ++to-me to:kevin at sonney.com and tag:new and not tag:to-me + +# And note all mail sent from me ++sent from:kevin at sonney.com and tag:new and not tag:sent + +# Remove the new tag from messages +-new tag:new +``` + +我可以在运行 `notmuch new` 后运行 `notmuch tag --input=tagmail.notmuch` 批量处理我的邮件,之后我也可以搜索这些标签。 + +Notmuch 还支持 `pre-new` 和 `post-new` 钩子。这些脚本存放在 `Maildir/.notmuch/hooks` 中,它们定义了在使用 `notmuch new` 索引新邮件之前(`pre-new`)和之后(`post-new`)要做的操作。在昨天的文章中,我谈到了使用 [OfflineIMAP][8] 同步来自 IMAP 服务器的邮件。从 `pre-new` 钩子运行它非常容易: + + +``` +#!/bin/bash +# Remove the new tag from messages that are still tagged as new +notmuch tag -new tag:new + +# Sync mail messages +offlineimap -a LocalSync -u quiet +``` + +你还可以使用可以操作 Notmuch 数据库的 Python 应用 [afew][9],来为你标记*邮件列表*和*垃圾邮件*。你可以用类似的方法在 `post-new` 钩子中使用 `afew`: + +``` +#!/bin/bash +# tag with my custom tags +notmuch tag --input=~/tagmail.notmuch + +# Run afew to tag new mail +afew -t -n +``` + +我建议你在使用 `afew` 标记邮件时,不要使用 `[ListMailsFilter]`,因为某些邮件处理程序会在邮件中添加模糊或者彻头彻尾是垃圾的列表标头(我说的就是你 Google)。 + +![alot email client][10] + +此时,任何支持 Notmuch 或 Maildir 的邮件阅读器都可以读取我的邮件。有时,我会使用 [alot][11](一个 Notmuch 特定的客户端)在控制台中阅读邮件,但是它不像其他邮件阅读器那么美观。 + +在接下来的几天,我将向你展示其他一些邮件客户端,它们可能会与你在使用的工具集成在一起。同时,请查看可与 Maildir 邮箱一起使用的其他工具。你可能会发现我没发现的好东西。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/organize-email-notmuch + +作者:[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/files_documents_organize_letter.png?itok=GTtiiabr (Filing cabinet for organization) +[2]: https://linux.cn/article-11804-1.html +[3]: https://opensource.com/sites/default/files/uploads/productivity_4-1.png (Notmuch) +[4]: https://en.wikipedia.org/wiki/Maildir +[5]: https://notmuchmail.org/ +[6]: https://docs.microsoft.com/en-us/windows/wsl/install-win10 +[7]: https://opensource.com/sites/default/files/uploads/productivity_4-2.png (Notmuch's first run) +[8]: http://www.offlineimap.org/ +[9]: https://afew.readthedocs.io/en/latest/index.html +[10]: https://opensource.com/sites/default/files/uploads/productivity_4-3.png (alot email client) +[11]: https://github.com/pazz/alot diff --git a/published/202001/20200115 6 handy Bash scripts for Git.md b/published/202001/20200115 6 handy Bash scripts for Git.md new file mode 100644 index 0000000000..8a43bb3220 --- /dev/null +++ b/published/202001/20200115 6 handy Bash scripts for Git.md @@ -0,0 +1,510 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11797-1.html) +[#]: subject: (6 handy Bash scripts for Git) +[#]: via: (https://opensource.com/article/20/1/bash-scripts-git) +[#]: author: (Bob Peterson https://opensource.com/users/bobpeterson) + +6 个方便的 Git 脚本 +====== + +> 当使用 Git 存储库时,这六个 Bash 脚本将使你的生活更轻松。 + +![](https://img.linux.net.cn/data/attachment/album/202001/18/231713jegbk8fyek798gxb.jpg) + +我编写了许多 Bash 脚本,这些脚本使我在使用 Git 存储库时工作更加轻松。我的许多同事说没有必要:我所做的一切都可以用 Git 命令完成。虽然这可能是正确的,但我发现脚本远比尝试找出适当的 Git 命令来执行我想要的操作更加方便。 + +### 1、gitlog + +`gitlog` 打印针对 master 分支的当前补丁的简短列表。它从最旧到最新打印它们,并显示作者和描述,其中 `H` 代表 `HEAD`,`^` 代表 `HEAD^`,`2` 代表 `HEAD~2`,依此类推。例如: + +``` +$ gitlog +-----------------------[ recovery25 ]----------------------- +(snip) +11 340d27a33895 Bob Peterson gfs2: drain the ail2 list after io errors +10 9b3c4e6efb10 Bob Peterson gfs2: clean up iopen glock mess in gfs2_create_inode + 9 d2e8c22be39b Bob Peterson gfs2: Do proper error checking for go_sync family of glops + 8 9563e31f8bfd Christoph Hellwig gfs2: use page_offset in gfs2_page_mkwrite + 7 ebac7a38036c Christoph Hellwig gfs2: don't use buffer_heads in gfs2_allocate_page_backing + 6 f703a3c27874 Andreas Gruenbacher gfs2: Improve mmap write vs. punch_hole consistency + 5 a3e86d2ef30e Andreas Gruenbacher gfs2: Multi-block allocations in gfs2_page_mkwrite + 4 da3c604755b0 Andreas Gruenbacher gfs2: Fix end-of-file handling in gfs2_page_mkwrite + 3 4525c2f5b46f Bob Peterson Rafael Aquini's slab instrumentation + 2 a06a5b7dea02 Bob Peterson GFS2: Add go_get_holdtime to gl_ops + ^ 8ba93c796d5c Bob Peterson gfs2: introduce new function remaining_hold_time and use it in dq + H e8b5ff851bb9 Bob Peterson gfs2: Allow rgrps to have a minimum hold time +``` + +如果我想查看其他分支上有哪些补丁,可以指定一个替代分支: + +``` +$ gitlog recovery24 +``` + +### 2、gitlog.id + +`gitlog.id` 只是打印出补丁的 SHA1 ID: + +``` +$ gitlog.id +-----------------------[ recovery25 ]----------------------- +56908eeb6940 2ca4a6b628a1 fc64ad5d99fe 02031a00a251 f6f38da7dd18 d8546e8f0023 fc3cc1f98f6b 12c3e0cb3523 76cce178b134 6fc1dce3ab9c 1b681ab074ca 26fed8de719b 802ff51a5670 49f67a512d8c f04f20193bbb 5f6afe809d23 2030521dc70e dada79b3be94 9b19a1e08161 78a035041d3e f03da011cae2 0d2b2e068fcd 2449976aa133 57dfb5e12ccd 53abedfdcf72 6fbdda3474b3 49544a547188 187032f7a63c 6f75dae23d93 95fc2a261b00 ebfb14ded191 f653ee9e414a 0e2911cb8111 73968b76e2e3 8a3e4cb5e92c a5f2da803b5b 7c9ef68388ed 71ca19d0cba8 340d27a33895 9b3c4e6efb10 d2e8c22be39b 9563e31f8bfd ebac7a38036c f703a3c27874 a3e86d2ef30e da3c604755b0 4525c2f5b46f a06a5b7dea02 8ba93c796d5c e8b5ff851bb9 +``` + +同样,它假定是当前分支,但是如果需要,我可以指定其他分支。 + +### 3、gitlog.id2 + +`gitlog.id2` 与 `gitlog.id` 相同,但顶部没有显示分支的行。这对于从一个分支挑选所有补丁到当前分支很方便: + +``` +$ # 创建一个新分支 +$ git branch --track origin/master +$ # 检出刚刚创建的新分支 +$ git checkout recovery26 +$ # 从旧的分支挑选所有补丁到新分支 +$ for i in `gitlog.id2 recovery25` ; do git cherry-pick $i ;done +``` + +### 4、gitlog.grep + +`gitlog.grep` 会在该补丁集合中寻找一个字符串。例如,如果我发现一个错误并想修复引用了函数 `inode_go_sync` 的补丁,我可以简单地执行以下操作: + +``` +$ gitlog.grep inode_go_sync +-----------------------[ recovery25 - 50 patches ]----------------------- +(snip) +11 340d27a33895 Bob Peterson gfs2: drain the ail2 list after io errors +10 9b3c4e6efb10 Bob Peterson gfs2: clean up iopen glock mess in gfs2_create_inode + 9 d2e8c22be39b Bob Peterson gfs2: Do proper error checking for go_sync family of glops +152:-static void inode_go_sync(struct gfs2_glock *gl) +153:+static int inode_go_sync(struct gfs2_glock *gl) +163:@@ -296,6 +302,7 @@ static void inode_go_sync(struct gfs2_glock *gl) + 8 9563e31f8bfd Christoph Hellwig gfs2: use page_offset in gfs2_page_mkwrite + 7 ebac7a38036c Christoph Hellwig gfs2: don't use buffer_heads in gfs2_allocate_page_backing + 6 f703a3c27874 Andreas Gruenbacher gfs2: Improve mmap write vs. punch_hole consistency + 5 a3e86d2ef30e Andreas Gruenbacher gfs2: Multi-block allocations in gfs2_page_mkwrite + 4 da3c604755b0 Andreas Gruenbacher gfs2: Fix end-of-file handling in gfs2_page_mkwrite + 3 4525c2f5b46f Bob Peterson Rafael Aquini's slab instrumentation + 2 a06a5b7dea02 Bob Peterson GFS2: Add go_get_holdtime to gl_ops + ^ 8ba93c796d5c Bob Peterson gfs2: introduce new function remaining_hold_time and use it in dq + H e8b5ff851bb9 Bob Peterson gfs2: Allow rgrps to have a minimum hold time +``` + +因此,现在我知道补丁 `HEAD~9` 是需要修复的补丁。我使用 `git rebase -i HEAD~10` 编辑补丁 9,`git commit -a --amend`,然后 `git rebase --continue` 以进行必要的调整。 + +### 5、gitbranchcmp3 + +`gitbranchcmp3` 使我可以将当前分支与另一个分支进行比较,因此我可以将较旧版本的补丁与我的较新版本进行比较,并快速查看已更改和未更改的内容。它生成一个比较脚本(使用了 KDE 工具 [Kompare][2],该工具也可在 GNOME3 上使用)以比较不太相同的补丁。如果除行号外没有其他差异,则打印 `[SAME]`。如果仅存在注释差异,则打印 `[same]`(小写)。例如: + +``` +$ gitbranchcmp3 recovery24 +Branch recovery24 has 47 patches +Branch recovery25 has 50 patches + +(snip) +38 87eb6901607a 340d27a33895 [same] gfs2: drain the ail2 list after io errors +39 90fefb577a26 9b3c4e6efb10 [same] gfs2: clean up iopen glock mess in gfs2_create_inode +40 ba3ae06b8b0e d2e8c22be39b [same] gfs2: Do proper error checking for go_sync family of glops +41 2ab662294329 9563e31f8bfd [SAME] gfs2: use page_offset in gfs2_page_mkwrite +42 0adc6d817b7a ebac7a38036c [SAME] gfs2: don't use buffer_heads in gfs2_allocate_page_backing +43 55ef1f8d0be8 f703a3c27874 [SAME] gfs2: Improve mmap write vs. punch_hole consistency +44 de57c2f72570 a3e86d2ef30e [SAME] gfs2: Multi-block allocations in gfs2_page_mkwrite +45 7c5305fbd68a da3c604755b0 [SAME] gfs2: Fix end-of-file handling in gfs2_page_mkwrite +46 162524005151 4525c2f5b46f [SAME] Rafael Aquini's slab instrumentation +47 a06a5b7dea02 [ ] GFS2: Add go_get_holdtime to gl_ops +48 8ba93c796d5c [ ] gfs2: introduce new function remaining_hold_time and use it in dq +49 e8b5ff851bb9 [ ] gfs2: Allow rgrps to have a minimum hold time + +Missing from recovery25: +The missing: +Compare script generated at: /tmp/compare_mismatches.sh +``` + +### 6、gitlog.find + +最后,我有一个 `gitlog.find` 脚本,可以帮助我识别补丁程序的上游版本在哪里以及每个补丁的当前状态。它通过匹配补丁说明来实现。它还会生成一个比较脚本(再次使用了 Kompare),以将当前补丁与上游对应补丁进行比较: + +``` +$ gitlog.find +-----------------------[ recovery25 - 50 patches ]----------------------- +(snip) +11 340d27a33895 Bob Peterson gfs2: drain the ail2 list after io errors +lo 5bcb9be74b2a Bob Peterson gfs2: drain the ail2 list after io errors +10 9b3c4e6efb10 Bob Peterson gfs2: clean up iopen glock mess in gfs2_create_inode +fn 2c47c1be51fb Bob Peterson gfs2: clean up iopen glock mess in gfs2_create_inode + 9 d2e8c22be39b Bob Peterson gfs2: Do proper error checking for go_sync family of glops +lo feb7ea639472 Bob Peterson gfs2: Do proper error checking for go_sync family of glops + 8 9563e31f8bfd Christoph Hellwig gfs2: use page_offset in gfs2_page_mkwrite +ms f3915f83e84c Christoph Hellwig gfs2: use page_offset in gfs2_page_mkwrite + 7 ebac7a38036c Christoph Hellwig gfs2: don't use buffer_heads in gfs2_allocate_page_backing +ms 35af80aef99b Christoph Hellwig gfs2: don't use buffer_heads in gfs2_allocate_page_backing + 6 f703a3c27874 Andreas Gruenbacher gfs2: Improve mmap write vs. punch_hole consistency +fn 39c3a948ecf6 Andreas Gruenbacher gfs2: Improve mmap write vs. punch_hole consistency + 5 a3e86d2ef30e Andreas Gruenbacher gfs2: Multi-block allocations in gfs2_page_mkwrite +fn f53056c43063 Andreas Gruenbacher gfs2: Multi-block allocations in gfs2_page_mkwrite + 4 da3c604755b0 Andreas Gruenbacher gfs2: Fix end-of-file handling in gfs2_page_mkwrite +fn 184b4e60853d Andreas Gruenbacher gfs2: Fix end-of-file handling in gfs2_page_mkwrite + 3 4525c2f5b46f Bob Peterson Rafael Aquini's slab instrumentation + Not found upstream + 2 a06a5b7dea02 Bob Peterson GFS2: Add go_get_holdtime to gl_ops + Not found upstream + ^ 8ba93c796d5c Bob Peterson gfs2: introduce new function remaining_hold_time and use it in dq + Not found upstream + H e8b5ff851bb9 Bob Peterson gfs2: Allow rgrps to have a minimum hold time + Not found upstream +Compare script generated: /tmp/compare_upstream.sh +``` + +补丁显示为两行,第一行是你当前的修补程序,然后是相应的上游补丁,以及 2 个字符的缩写,以指示其上游状态: + +* `lo` 表示补丁仅在本地(`local`)上游 Git 存储库中(即尚未推送到上游)。 +* `ms` 表示补丁位于 Linus Torvald 的主(`master`)分支中。 +* `fn` 意味着补丁被推送到我的 “for-next” 开发分支,用于下一个上游合并窗口。 +   +我的一些脚本根据我通常使用 Git 的方式做出假设。例如,当搜索上游补丁时,它使用我众所周知的 Git 树的位置。因此,你需要调整或改进它们以适合你的条件。`gitlog.find` 脚本旨在仅定位 [GFS2][3] 和 [DLM][4] 补丁,因此,除非你是 GFS2 开发人员,否则你需要针对你感兴趣的组件对其进行自定义。 + +### 源代码 + +以下是这些脚本的源代码。 + +#### 1、gitlog + +``` +#!/bin/bash +branch=$1 + +if test "x$branch" = x; then + branch=`git branch -a | grep "*" | cut -d ' ' -f2` +fi + +patches=0 +tracking=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` + +LIST=`git log --reverse --abbrev-commit --pretty=oneline $tracking..$branch | cut -d ' ' -f1 |paste -s -d ' '` +for i in $LIST; do patches=$(echo $patches + 1 | bc);done + +if [[ $branch =~ .*for-next.* ]] +then + start=HEAD +# start=origin/for-next +else + start=origin/master +fi + +tracking=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` + +/usr/bin/echo "-----------------------[" $branch "]-----------------------" +patches=$(echo $patches - 1 | bc); +for i in $LIST; do + if [ $patches -eq 1 ]; then + cnt=" ^" + elif [ $patches -eq 0 ]; then + cnt=" H" + else + if [ $patches -lt 10 ]; then + cnt=" $patches" + else + cnt="$patches" + fi + fi + /usr/bin/git show --abbrev-commit -s --pretty=format:"$cnt %h %<|(32)%an %s %n" $i + patches=$(echo $patches - 1 | bc) +done +#git log --reverse --abbrev-commit --pretty=format:"%h %<|(32)%an %s" $tracking..$branch +#git log --reverse --abbrev-commit --pretty=format:"%h %<|(32)%an %s" ^origin/master ^linux-gfs2/for-next $branch +``` + +#### 2、gitlog.id + +``` +#!/bin/bash +branch=$1 + +if test "x$branch" = x; then + branch=`git branch -a | grep "*" | cut -d ' ' -f2` +fi + +tracking=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` + +/usr/bin/echo "-----------------------[" $branch "]-----------------------" +git log --reverse --abbrev-commit --pretty=oneline $tracking..$branch | cut -d ' ' -f1 |paste -s -d ' ' +``` + +#### 3、gitlog.id2 + +``` +#!/bin/bash +branch=$1 + +if test "x$branch" = x; then + branch=`git branch -a | grep "*" | cut -d ' ' -f2` +fi + +tracking=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` +git log --reverse --abbrev-commit --pretty=oneline $tracking..$branch | cut -d ' ' -f1 |paste -s -d ' ' +``` + +#### 4、gitlog.grep + +``` +#!/bin/bash +param1=$1 +param2=$2 + +if test "x$param2" = x; then + branch=`git branch -a | grep "*" | cut -d ' ' -f2` + string=$param1 +else + branch=$param1 + string=$param2 +fi + +patches=0 +tracking=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` + +LIST=`git log --reverse --abbrev-commit --pretty=oneline $tracking..$branch | cut -d ' ' -f1 |paste -s -d ' '` +for i in $LIST; do patches=$(echo $patches + 1 | bc);done +/usr/bin/echo "-----------------------[" $branch "-" $patches "patches ]-----------------------" +patches=$(echo $patches - 1 | bc); +for i in $LIST; do + if [ $patches -eq 1 ]; then + cnt=" ^" + elif [ $patches -eq 0 ]; then + cnt=" H" + else + if [ $patches -lt 10 ]; then + cnt=" $patches" + else + cnt="$patches" + fi + fi + /usr/bin/git show --abbrev-commit -s --pretty=format:"$cnt %h %<|(32)%an %s" $i + /usr/bin/git show --pretty=email --patch-with-stat $i | grep -n "$string" + patches=$(echo $patches - 1 | bc) +done +``` + +#### 5、gitbranchcmp3 + +``` +#!/bin/bash +# +# gitbranchcmp3 [] +# +oldbranch=$1 +newbranch=$2 +script=/tmp/compare_mismatches.sh + +/usr/bin/rm -f $script +echo "#!/bin/bash" > $script +/usr/bin/chmod 755 $script +echo "# Generated by gitbranchcmp3.sh" >> $script +echo "# Run this script to compare the mismatched patches" >> $script +echo " " >> $script +echo "function compare_them()" >> $script +echo "{" >> $script +echo " git show --pretty=email --patch-with-stat \$1 > /tmp/gronk1" >> $script +echo " git show --pretty=email --patch-with-stat \$2 > /tmp/gronk2" >> $script +echo " kompare /tmp/gronk1 /tmp/gronk2" >> $script +echo "}" >> $script +echo " " >> $script + +if test "x$newbranch" = x; then + newbranch=`git branch -a | grep "*" | cut -d ' ' -f2` +fi + +tracking=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` + +declare -a oldsha1s=(`git log --reverse --abbrev-commit --pretty=oneline $tracking..$oldbranch | cut -d ' ' -f1 |paste -s -d ' '`) +declare -a newsha1s=(`git log --reverse --abbrev-commit --pretty=oneline $tracking..$newbranch | cut -d ' ' -f1 |paste -s -d ' '`) + +#echo "old: " $oldsha1s +oldcount=${#oldsha1s[@]} +echo "Branch $oldbranch has $oldcount patches" +oldcount=$(echo $oldcount - 1 | bc) +#for o in `seq 0 ${#oldsha1s[@]}`; do +# echo -n ${oldsha1s[$o]} " " +# desc=`git show $i | head -5 | tail -1|cut -b5-` +#done + +#echo "new: " $newsha1s +newcount=${#newsha1s[@]} +echo "Branch $newbranch has $newcount patches" +newcount=$(echo $newcount - 1 | bc) +#for o in `seq 0 ${#newsha1s[@]}`; do +# echo -n ${newsha1s[$o]} " " +# desc=`git show $i | head -5 | tail -1|cut -b5-` +#done +echo + +for new in `seq 0 $newcount`; do + newsha=${newsha1s[$new]} + newdesc=`git show $newsha | head -5 | tail -1|cut -b5-` + oldsha=" " + same="[ ]" + for old in `seq 0 $oldcount`; do + if test "${oldsha1s[$old]}" = "match"; then + continue; + fi + olddesc=`git show ${oldsha1s[$old]} | head -5 | tail -1|cut -b5-` + if test "$olddesc" = "$newdesc" ; then + oldsha=${oldsha1s[$old]} + #echo $oldsha + git show $oldsha |tail -n +2 |grep -v "index.*\.\." |grep -v "@@" > /tmp/gronk1 + git show $newsha |tail -n +2 |grep -v "index.*\.\." |grep -v "@@" > /tmp/gronk2 + diff /tmp/gronk1 /tmp/gronk2 &> /dev/null + if [ $? -eq 0 ] ;then +# No differences + same="[SAME]" + oldsha1s[$old]="match" + break + fi + git show $oldsha |sed -n '/diff/,$p' |grep -v "index.*\.\." |grep -v "@@" > /tmp/gronk1 + git show $newsha |sed -n '/diff/,$p' |grep -v "index.*\.\." |grep -v "@@" > /tmp/gronk2 + diff /tmp/gronk1 /tmp/gronk2 &> /dev/null + if [ $? -eq 0 ] ;then +# Differences in comments only + same="[same]" + oldsha1s[$old]="match" + break + fi + oldsha1s[$old]="match" + echo "compare_them $oldsha $newsha" >> $script + fi + done + echo "$new $oldsha $newsha $same $newdesc" +done + +echo +echo "Missing from $newbranch:" +the_missing="" +# Now run through the olds we haven't matched up +for old in `seq 0 $oldcount`; do + if test ${oldsha1s[$old]} != "match"; then + olddesc=`git show ${oldsha1s[$old]} | head -5 | tail -1|cut -b5-` + echo "${oldsha1s[$old]} $olddesc" + the_missing=`echo "$the_missing ${oldsha1s[$old]}"` + fi +done + +echo "The missing: " $the_missing +echo "Compare script generated at: $script" +#git log --reverse --abbrev-commit --pretty=oneline $tracking..$branch | cut -d ' ' -f1 |paste -s -d ' ' +``` + +#### 6、gitlog.find + +``` +#!/bin/bash +# +# Find the upstream equivalent patch +# +# gitlog.find +# +cwd=$PWD +param1=$1 +ubranch=$2 +patches=0 +script=/tmp/compare_upstream.sh +echo "#!/bin/bash" > $script +/usr/bin/chmod 755 $script +echo "# Generated by gitbranchcmp3.sh" >> $script +echo "# Run this script to compare the mismatched patches" >> $script +echo " " >> $script +echo "function compare_them()" >> $script +echo "{" >> $script +echo " cwd=$PWD" >> $script +echo " git show --pretty=email --patch-with-stat \$2 > /tmp/gronk2" >> $script +echo " cd ~/linux.git/fs/gfs2" >> $script +echo " git show --pretty=email --patch-with-stat \$1 > /tmp/gronk1" >> $script +echo " cd $cwd" >> $script +echo " kompare /tmp/gronk1 /tmp/gronk2" >> $script +echo "}" >> $script +echo " " >> $script + +#echo "Gathering upstream patch info. Please wait." +branch=`git branch -a | grep "*" | cut -d ' ' -f2` +tracking=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` + +cd ~/linux.git +if test "X${ubranch}" = "X"; then + ubranch=`git branch -a | grep "*" | cut -d ' ' -f2` +fi +utracking=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` +# +# gather a list of gfs2 patches from master just in case we can't find it +# +#git log --abbrev-commit --pretty=format:" %h %<|(32)%an %s" master |grep -i -e "gfs2" -e "dlm" > /tmp/gronk +git log --reverse --abbrev-commit --pretty=format:"ms %h %<|(32)%an %s" master fs/gfs2/ > /tmp/gronk.gfs2 +# ms = in Linus's master +git log --reverse --abbrev-commit --pretty=format:"ms %h %<|(32)%an %s" master fs/dlm/ > /tmp/gronk.dlm + +cd $cwd +LIST=`git log --reverse --abbrev-commit --pretty=oneline $tracking..$branch | cut -d ' ' -f1 |paste -s -d ' '` +for i in $LIST; do patches=$(echo $patches + 1 | bc);done +/usr/bin/echo "-----------------------[" $branch "-" $patches "patches ]-----------------------" +patches=$(echo $patches - 1 | bc); +for i in $LIST; do + if [ $patches -eq 1 ]; then + cnt=" ^" + elif [ $patches -eq 0 ]; then + cnt=" H" + else + if [ $patches -lt 10 ]; then + cnt=" $patches" + else + cnt="$patches" + fi + fi + /usr/bin/git show --abbrev-commit -s --pretty=format:"$cnt %h %<|(32)%an %s" $i + desc=`/usr/bin/git show --abbrev-commit -s --pretty=format:"%s" $i` + cd ~/linux.git + cmp=1 + up_eq=`git log --reverse --abbrev-commit --pretty=format:"lo %h %<|(32)%an %s" $utracking..$ubranch | grep "$desc"` +# lo = in local for-next + if test "X$up_eq" = "X"; then + up_eq=`git log --reverse --abbrev-commit --pretty=format:"fn %h %<|(32)%an %s" master..$utracking | grep "$desc"` +# fn = in for-next for next merge window + if test "X$up_eq" = "X"; then + up_eq=`grep "$desc" /tmp/gronk.gfs2` + if test "X$up_eq" = "X"; then + up_eq=`grep "$desc" /tmp/gronk.dlm` + if test "X$up_eq" = "X"; then + up_eq=" Not found upstream" + cmp=0 + fi + fi + fi + fi + echo "$up_eq" + if [ $cmp -eq 1 ] ; then + UP_SHA1=`echo $up_eq|cut -d' ' -f2` + echo "compare_them $UP_SHA1 $i" >> $script + fi + cd $cwd + patches=$(echo $patches - 1 | bc) +done +echo "Compare script generated: $script" +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/bash-scripts-git + +作者:[Bob Peterson][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/bobpeterson +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003588_01_rd3os.combacktoschoolseriesk12_rh_021x_0.png?itok=fvorN0e- (Digital hand surrounding by objects, bike, light bulb, graphs) +[2]: https://kde.org/applications/development/org.kde.kompare +[3]: https://en.wikipedia.org/wiki/GFS2 +[4]: https://en.wikipedia.org/wiki/Distributed_lock_manager diff --git a/published/202001/20200115 Organize and sync your calendar with khal and vdirsyncer.md b/published/202001/20200115 Organize and sync your calendar with khal and vdirsyncer.md new file mode 100644 index 0000000000..5ddb647095 --- /dev/null +++ b/published/202001/20200115 Organize and sync your calendar with khal and vdirsyncer.md @@ -0,0 +1,106 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11812-1.html) +[#]: subject: (Organize and sync your calendar with khal and vdirsyncer) +[#]: via: (https://opensource.com/article/20/1/open-source-calendar) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 khal 和 vdirsyncer 组织和同步你的日历 +====== + +> 保存和共享日历可能会有点麻烦。在我们的 20 个使用开源提升生产力的系列的第五篇文章中了解如何让它更简单。 + +![](https://img.linux.net.cn/data/attachment/album/202001/23/150009wsr3d5ovg4g1vzws.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 khal 和 vdirsyncer 跟踪你的日程 + +处理日历很*麻烦*,要找到好的工具总是很困难的。但是自从我去年将日历列为[我的“失败"之一][2]以来,我已经取得了一些进步。 + +目前使用日历最困难的是一直需要以某种方式在线共享。两种最受欢迎的在线日历是 Google Calendar 和 Microsoft Outlook/Exchange。两者都在公司环境中大量使用,这意味着我的日历必须支持其中之一或者两个。 + +![khal calendar][3] + +[Khal][4] 是基于控制台的日历,可以读取和写入 VCalendar 文件。它配置相当容易,但是不支持与其他应用同步。 + +幸运的是,khal 能与 [vdirsyncer][5] 一起使用,它是一个漂亮的命令行程序,可以将在线日历(和联系人,我将在另一篇文章中讨论)同步到本地磁盘。是的,它还可以上传新事件。 + +![vdirsyncer][6] + +Vdirsyncer 是个 Python 3 程序,可以通过软件包管理器或 `pip` 安装。它可以同步 CalDAV、VCalendar/iCalendar、Google Calendar 和目录中的本地文件。由于我使用 Google Calendar,尽管这不是最简单的设置,我也将以它为例。 + +在 vdirsyncer 中设置 Google Calendar 是[有文档参考的][7],所以这里我不再赘述。重要的是确保设置你的同步对,将 Google Calendar 设置为冲突解决的“赢家”。也就是说,如果同一事件有两个更新,那么需要知道哪个更新优先。类似这样做: + +``` +[general] +status_path = "~/.calendars/status" + +[pair personal_sync] +a = "personal" +b = "personallocal" +collections = ["from a", "from b"] +conflict_resolution = "a wins" +metadata = ["color"] + +[storage personal] +type = "google_calendar" +token_file = "~/.vdirsyncer/google_calendar_token" +client_id = "google_client_id" +client_secret = "google_client_secret" + +[storage personallocal] +type = "filesystem" +path = "~/.calendars/Personal" +fileext = ".ics" +``` + +在第一次 vdirsyncer 同步之后,你将在存储路径中看到一系列目录。每个文件夹都将包含多个文件,日历中的每个事件都是一个文件。下一步是导入 khal。首先运行 `khal configure` 进行初始设置。 + +![Configuring khal][8] + +现在,运行 `khal interactive` 将显示本文开头的界面。输入 `n` 将打开“新事件”对话框。这里要注意的一件事:日历的名称与 vdirsyncer 创建的目录匹配,但是你可以更改 khal 配置文件来指定更清晰的名称。根据条目所在的日历,向条目添加颜色还可以帮助你确定日历内容: + +``` +[calendars] +[[personal]] +path = ~/.calendars/Personal/kevin@sonney.com/ +color = light magenta +[[holidays]] +path = ~/.calendars/Personal/cln2stbjc4hmgrrcd5i62ua0ctp6utbg5pr2sor1dhimsp31e8n6errfctm6abj3dtmg@virtual/ +color = light blue +[[birthdays]] +path = ~/.calendars/Personal/c5i68sj5edpm4rrfdchm6rreehgm6t3j81jn4rrle0n7cbj3c5m6arj4c5p2sprfdtjmop9ecdnmq@virtual/ +color = brown +``` + +现在,当你运行 `khal interactive` 时,每个日历将被着色以区别于其他日历,并且当你添加新条目时,它将有更具描述性的名称。 + +![Adding a new calendar entry][9] + +设置有些麻烦,但是完成后,khal 和 vdirsyncer 可以一起为你提供一种简便的方法来管理日历事件并使它们与你的在线服务保持同步。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/open-source-calendar + +作者:[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/calendar.jpg?itok=jEKbhvDT (Calendar close up snapshot) +[2]: https://opensource.com/article/19/1/productivity-tool-wish-list +[3]: https://opensource.com/sites/default/files/uploads/productivity_5-1.png (khal calendar) +[4]: https://khal.readthedocs.io/en/v0.9.2/index.html +[5]: https://github.com/pimutils/vdirsyncer +[6]: https://opensource.com/sites/default/files/uploads/productivity_5-2.png (vdirsyncer) +[7]: https://vdirsyncer.pimutils.org/en/stable/config.html#google +[8]: https://opensource.com/sites/default/files/uploads/productivity_5-3.png (Configuring khal) +[9]: https://opensource.com/sites/default/files/uploads/productivity_5-4.png diff --git a/published/202001/20200115 Root User in Ubuntu- Important Things You Should Know.md b/published/202001/20200115 Root User in Ubuntu- Important Things You Should Know.md new file mode 100644 index 0000000000..0abc566f4b --- /dev/null +++ b/published/202001/20200115 Root User in Ubuntu- Important Things You Should Know.md @@ -0,0 +1,169 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11837-1.html) +[#]: subject: (Root User in Ubuntu: Important Things You Should Know) +[#]: via: (https://itsfoss.com/root-user-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Ubuntu 中的 root 用户:你应该知道的重要事情 +====== + +![][5] + +当你刚开始使用 Linux 时,你将发现与 Windows 的很多不同。其中一个“不同的东西”是 root 用户的概念。 + +在这个初学者系列中,我将解释几个关于 Ubuntu 的 root 用户的重要的东西。 + +**请记住,尽管我正在从 Ubuntu 用户的角度编写这篇文章,它应该对大多数的 Linux 发行版也是有效的。** + +你将在这篇文章中学到下面的内容: + +* 为什么在 Ubuntu 中禁用 root 用户 +* 像 root 用户一样使用命 +* 切换为 root 用户 +* 解锁 root 用户 + +### 什么是 root 用户?为什么它在 Ubuntu 中被锁定? + +在 Linux 中,有一个称为 [root][6] 的超级用户。这是超级管理员账号,它可以做任何事以及使用系统的一切东西。它可以在你的 Linux 系统上访问任何文件和运行任何命令。 + +能力越大,责任越大。root 用户给予你完全控制系统的能力,因此,它应该被谨慎地使用。root 用户可以访问系统文件,运行更改系统配置的命令。因此,一个错误的命令可能会破坏系统。 + +这就是为什么 [Ubuntu][7] 和其它基于 Ubuntu 的发行版默认锁定 root 用户,以从意外的灾难中挽救你的原因。 + +对于你的日常任务,像移动你家目录中的文件,从互联网下载文件,创建文档等等,你不需要拥有 root 权限。 + +**打个比方来更好地理解它。假设你想要切一个水果,你可以使用一把厨房用刀。假设你想要砍一颗树,你就得使用一把锯子。现在,你可以使用锯子来切水果,但是那不明智,不是吗?**_ + +这意味着,你不能是 Ubuntu 中 root 用户或者不能使用 root 权限来使用系统吗?不,你仍然可以在 `sudo` 的帮助下来拥有 root 权限来访问(在下一节中解释)。 + +> **要点:** 使用于常规任务,root 用户权限太过强大。这就是为什么不建议一直使用 root 用户。你仍然可以使用 root 用户来运行特殊的命令。 + +### 如何在 Ubuntu 中像 root 用户一样运行命令? + +![Image Credit: xkcd][8] + +对于一些系统的特殊任务来说,你将需要 root 权限。例如。如果你想[通过命令行更新 Ubuntu][9],你不能作为一个常规用户运行该命令。它将给出权限被拒绝的错误。 + +``` +apt update +Reading package lists... Done +E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied) +E: Unable to lock directory /var/lib/apt/lists/ +W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied) +W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied) +``` + +那么,你如何像 root 用户一样运行命令?简单的答案是,在命令前添加 `sudo`,来像 root 用户一样运行。 + +``` +sudo apt update +``` + +Ubuntu 和很多其它的 Linux 发行版使用一个被称为 `sudo` 的特殊程序机制。`sudo` 是一个以 root 用户(或其它用户)来控制运行命令访问的程序。 + +实际上,`sudo` 是一个非常多用途的工具。它可以配置为允许一个用户像 root 用户一样来运行所有的命令,或者仅仅一些命令。你也可以配置为无需密码即可使用 sudo 运行命令。这个主题内容比较丰富,也许我将在另一篇文章中详细讨论它。 + +就目前而言,你应该知道[当你安装 Ubuntu 时][10],你必须创建一个用户账号。这个用户账号在你系统上以管理员身份来工作,并且按照 Ubuntu 中的默认 sudo 策略,它可以在你的系统上使用 root 用户权限来运行任何命令。 + +`sudo` 的问题是,运行 **sudo 不需要 root 用户密码,而是需要用户自己的密码**。 + +并且这就是为什么当你使用 `sudo` 运行一个命令,会要求输入正在运行 `sudo` 命令的用户的密码的原因: + +``` +[email protected]:~$ sudo apt update +[sudo] password for abhishek: +``` + +正如你在上面示例中所见 `abhishek` 在尝试使用 `sudo` 来运行 `apt update` 命令,系统要求输入 `abhishek` 的密码。 + +**如果你对 Linux 完全不熟悉,当你在终端中开始输入密码时,你可能会惊讶,在屏幕上什么都没有发生。这是十分正常的,因为作为默认的安全功能,在屏幕上什么都不会显示。甚至星号(`*`)都没有。输入你的密码并按回车键。** + +> **要点:**为在 Ubuntu 中像 root 用户一样运行命令,在命令前添加 `sudo`。 当被要求输入密码时,输入你的账户的密码。当你在屏幕上输入密码时,什么都看不到。请继续输入密码,并按回车键。 + +### 如何在 Ubuntu 中成为 root 用户? + +你可以使用 `sudo` 来像 root 用户一样运行命令。但是,在某些情况下,你必须以 root 用户身份来运行一些命令,而你总是忘了在命令前添加 `sudo`,那么你可以临时切换为 root 用户。 + +`sudo` 命令允许你来模拟一个 root 用户登录的 shell ,使用这个命令: + +``` +sudo -i +``` + +``` +[email protected]:~$ sudo -i +[sudo] password for abhishek: +[email protected]:~# whoami +root +[email protected]:~# +``` + +你将注意到,当你切换为 root 用户时,shell 命令提示符从 `$`(美元符号)更改为 `#`(英镑符号)。我开个(拙劣的)玩笑,英镑比美元强大。 + +**虽然我已经向你显示如何成为 root 用户,但是我必须警告你,你应该避免作为 root 用户使用系统。毕竟它有阻拦你使用 root 用户的原因。** + +另外一种临时切换为 root 用户的方法是使用 `su` 命令: + +``` +sudo su +``` + +如果你尝试使用不带有的 `sudo` 的 `su` 命令,你将遇到 “su authentication failure” 错误。 + +你可以使用 `exit` 命令来恢复为正常用户。 + +``` +exit +``` + +### 如何在 Ubuntu 中启用 root 用户? + +现在你知道,root 用户在基于 Ubuntu 发行版中是默认锁定的。 + +Linux 给予你在系统上想做什么就做什么的自由。解锁 root 用户就是这些自由之一。 + +如果出于某些原因,你决定启用 root 用户,你可以通过为其设置一个密码来做到: + +``` +sudo passwd root +``` + +再强调一次,不建议使用 root 用户,并且我也不鼓励你在桌面上这样做。如果你忘记了密码,你将不能再次[在 Ubuntu 中更改 root 用户密码][11]。(LCTT 译注:可以通过单用户模式修改。) + +你可以通过移除密码来再次锁定 root 用户: + +``` +sudo passwd -dl root +``` + +### 最后… + +我希望你现在对 root 概念理解得更好一点。如果你仍然有些关于它的困惑和问题,请在评论中让我知道。我将尝试回答你的问题,并且也可能更新这篇文章。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/root-user-ubuntu/ + +作者:[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]: tmp.IrHYJBAqVn#what-is-root +[2]: tmp.IrHYJBAqVn#run-command-as-root +[3]: tmp.IrHYJBAqVn#become-root +[4]: tmp.IrHYJBAqVn#enable-root +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/root_user_ubuntu.png?ssl=1 +[6]: http://www.linfo.org/root.html +[7]: https://ubuntu.com/ +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/sudo_sandwich.png?ssl=1 +[9]: https://itsfoss.com/update-ubuntu/ +[10]: https://itsfoss.com/install-ubuntu/ +[11]: https://itsfoss.com/how-to-hack-ubuntu-password/ diff --git a/published/202001/20200115 Why everyone is talking about WebAssembly.md b/published/202001/20200115 Why everyone is talking about WebAssembly.md new file mode 100644 index 0000000000..e8fdb04ce0 --- /dev/null +++ b/published/202001/20200115 Why everyone is talking about WebAssembly.md @@ -0,0 +1,87 @@ +[#]: collector: (lujun9972) +[#]: translator: (laingke) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11823-1.html) +[#]: subject: (Why everyone is talking about WebAssembly) +[#]: via: (https://opensource.com/article/20/1/webassembly) +[#]: author: (Mike Bursell https://opensource.com/users/mikecamel) + +为什么每个人都在谈论 WebAssembly +====== + +> 了解有关在 Web 浏览器中运行任何代码的最新方法的更多信息。 + +![](https://img.linux.net.cn/data/attachment/album/202001/27/125343ch0hxdfbzibrihfn.jpg) + +如果你还没有听说过 [WebAssembly][2],那么你很快就会知道。这是业界最保密的秘密之一,但它无处不在。所有主流的浏览器都支持它,并且它也将在服务器端使用。它很快,它能用于游戏编程。这是主要的国际网络标准组织万维网联盟(W3C)的一个开放标准。 + +你可能会说:“哇,这听起来像是我应该学习编程的东西!”你可能是对的,但也是错的。你不需要用 WebAssembly 编程。让我们花一些时间来学习这种通常被缩写为“Wasm”的技术。 + +### 它从哪里来? + +大约十年前,人们越来越认识到,广泛使用的 JavaScript 不够快速,无法满足许多目的。JavaScript 无疑是成功和方便的。它可以在任何浏览器中运行,并启用了今天我们认为理所当然的动态网页类型。但这是一种高级语言,在设计时并没有考虑到计算密集型工作负载。 + +然而,尽管负责主流 web 浏览器的工程师们对性能问题的看法大体一致,但他们对如何解决这个问题却意见不一。出现了两个阵营,谷歌开始了它的原生客户端Native Client项目,后来又推出了可移植原生客户端Portable Native Client变体,着重于允许用 C/C++ 编写的游戏和其它软件在 Chrome 的一个安全隔间中运行。与此同时,Mozilla 赢得了微软对 asm.js 的支持。该方法更新了浏览器,因此它可以非常快速地运行 JavaScript 指令的低级子集(有另一个项目可以将 C/C++ 代码转换为这些指令)。 + +由于这两个阵营都没有得到广泛采用,各方在 2015 年同意围绕一种称为 WebAssembly 的新标准,以 asm.js 所采用的基本方法为基础,联合起来。[如 CNET 的 Stephen Shankland 当时所写][3],“在当今的 Web 上,浏览器的 JavaScript 将这些指令转换为机器代码。但是,通过 WebAssembly,程序员可以在此过程的早期阶段完成很多工作,从而生成介于两种状态之间的程序。这使浏览器摆脱了创建机器代码的繁琐工作,但也实现了 Web 的承诺 —— 该软件将在具有浏览器的任何设备上运行,而无需考虑基础硬件的细节。” + +在 2017 年,Mozilla 宣布了它的最小可行的产品(MVP),并使其脱离预览版阶段。到该年年底,所有主流的浏览器都采用了它。[2019 年 12 月][4],WebAssembly 工作组发布了三个 W3C 推荐的 WebAssembly 规范。 + +WebAssembly 定义了一种可执行程序的可移植二进制代码格式、相应的文本汇编语言以及用于促进此类程序与其宿主环境之间的交互接口。WebAssembly 代码在低级虚拟机中运行,这个可运行于许多微处理器之上的虚拟机可模仿这些处理器的功能。通过即时(JIT)编译或解释,WebAssembly 引擎可以以近乎原生平台编译代码的速度执行。 + +### 为什么现在感兴趣? + +当然,最近对 WebAssembly 感兴趣的部分原因是最初希望在浏览器中运行更多计算密集型代码。尤其是笔记本电脑用户,越来越多的时间都花在浏览器上(或者,对于 Chromebook 用户来说,基本上是所有时间)。这种趋势已经迫切需要消除在浏览器中运行各种应用程序的障碍。这些障碍之一通常是性能的某些方面,这正是 WebAssembly 及其前身最初旨在解决的问题。 + +但是,WebAssembly 并不仅仅适用于浏览器。在 2019 年,[Mozilla 宣布了一个名为 WASI][5](WebAssembly 系统接口WebAssembly System Interface)的项目,以标准化 WebAssembly 代码如何与浏览器上下文之外的操作系统进行交互。通过将浏览器对 WebAssembly 和 WASI 的支持结合在一起,编译后的二进制文件将能够以接近原生的速度,跨不同的设备和操作系统在浏览器内外运行。 + +WebAssembly 的低开销立即使它可以在浏览器之外使用,但这无疑是赌注;显然,还有其它不会引入性能瓶颈的运行应用程序的方法。为什么要专门使用 WebAssembly? + +一个重要的原因是它的可移植性。如今,像 C++ 和 Rust 这样的广泛使用的编译语言可能是与 WebAssembly 关联最紧密的语言。但是,[各种各样的其他语言][6]可以编译为 WebAssembly 或拥有它们的 WebAssembly 虚拟机。此外,尽管 WebAssembly 为其执行环境[假定了某些先决条件][7],但它被设计为在各种操作系统和指令集体系结构上有效执行。因此,WebAssembly 代码可以使用多种语言编写,并可以在多种操作系统和处理器类型上运行。 + +另一个 WebAssembly 优势源于这样一个事实:代码在虚拟机中运行。因此,每个 WebAssembly 模块都在沙盒环境中执行,并使用故障隔离技术将其与宿主机运行时环境分开。这意味着,对于其它部分而言,应用程序独立于其宿主机环境的其余部分执行,如果不调用适当的 API,就无法摆脱沙箱。 + +### WebAssembly 现状 + +这一切在实践中意味着什么? + +如今在运作中的 WebAssembly 的一个例子是 [Enarx][8]。 + +Enarx 是一个提供硬件独立性的项目,可使用受信任的执行环境Trusted Execution Environments(TEE)保护应用程序的安全。Enarx 使你可以安全地将编译为 WebAssembly 的应用程序始终交付到云服务商,并远程执行它。正如 Red Hat 安全工程师 [Nathaniel McCallum 指出的那样][9]:“我们这样做的方式是,我们将你的应用程序作为输入,并使用远程硬件执行认证过程。我们使用加密技术验证了远程硬件实际上是它声称的硬件。最终的结果不仅是我们对硬件的信任度提高了;它也是一个会话密钥,我们可以使用它将加密的代码和数据传递到我们刚刚要求加密验证的环境中。” + +另一个例子是 OPA,开放策略代理Open Policy Agent,它[发布][10]于 2019 年 11 月,你可以[编译][11]他们的策略定义语言 Rego 为 WebAssembly。Rego 允许你编写逻辑来搜索和组合来自不同来源的 JSON/YAML 数据,以询问诸如“是否允许使用此 API?”之类的问题。 + +OPA 已被用于支持策略的软件,包括但不限于 Kubernetes。使用 OPA 之类的工具来简化策略[被认为是在各种不同环境中正确保护 Kubernetes 部署的重要步骤][12]。WebAssembly 的可移植性和内置的安全功能非常适合这些工具。 + +我们的最后一个例子是 [Unity][13]。还记得我们在文章开头提到过 WebAssembly 可用于游戏吗?好吧,跨平台游戏引擎 Unity 是 WebAssembly 的较早采用者,它提供了在浏览器中运行的 Wasm 的首个演示品,并且自 2018 年 8 月以来,[已将 WebAssembly][14]用作 Unity WebGL 构建目标的输出目标。 + +这些只是 WebAssembly 已经开始产生影响的几种方式。你可以在 上查找更多信息并了解 Wasm 的所有最新信息。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/webassembly + +作者:[Mike Bursell][a] +选题:[lujun9972][b] +译者:[laingke](https://github.com/laingke) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mikecamel +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet) +[2]: https://opensource.com/article/19/8/webassembly-speed-code-reuse +[3]: https://www.cnet.com/news/the-secret-alliance-that-could-give-the-web-a-massive-speed-boost/ +[4]: https://www.w3.org/blog/news/archives/8123 +[5]: https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/ +[6]: https://github.com/appcypher/awesome-wasm-langs +[7]: https://webassembly.org/docs/portability/ +[8]: https://enarx.io +[9]: https://enterprisersproject.com/article/2019/9/application-security-4-facts-confidential-computing-consortium +[10]: https://blog.openpolicyagent.org/tagged/webassembly +[11]: https://github.com/open-policy-agent/opa/tree/master/wasm +[12]: https://enterprisersproject.com/article/2019/11/kubernetes-reality-check-3-takeaways-kubecon +[13]: https://opensource.com/article/20/1/www.unity.com +[14]: https://blogs.unity3d.com/2018/08/15/webassembly-is-here/ diff --git a/published/202001/20200116 3 open source tools to manage your contacts.md b/published/202001/20200116 3 open source tools to manage your contacts.md new file mode 100644 index 0000000000..a1862377d8 --- /dev/null +++ b/published/202001/20200116 3 open source tools to manage your contacts.md @@ -0,0 +1,141 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11834-1.html) +[#]: subject: (3 open source tools to manage your contacts) +[#]: via: (https://opensource.com/article/20/1/sync-contacts-locally) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +用于联系人管理的三个开源工具 +====== + +> 通过将联系人同步到本地从而更快访问它。在我们的 20 个使用开源提升生产力的系列的第六篇文章中了解该如何做。 + +![](https://img.linux.net.cn/data/attachment/album/202001/30/194811bbtt449zfr9zppb3.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 用于联系人管理的开源工具 + +在本系列之前的文章中,我解释了如何在本地同步你的[邮件][2]和[日历][3]。希望这些加速了你访问邮件和日历。现在,我将讨论联系人同步,你可以给他们发送邮件和日历邀请。 + +![abook][4] + +我目前收集了很多邮件地址。管理这些数据可能有点麻烦。有基于 Web 的服务,但它们不如本地副本快。 + +几天前,我谈到了用于管理日历的 [vdirsyncer][5]。vdirsyncer 还使用 CardDAV 协议处理联系人。vdirsyncer 除了可以使用**文件系统**存储日历外,还支持通过 **google_contacts** 和 **carddav** 进行联系人同步,但 `fileext` 设置会被更改,因此你无法在日历文件中存储联系人。 + +我在配置文件添加了一块配置,并从 Google 镜像了我的联系人。设置它需要额外的步骤。从 Google 镜像完成后,配置非常简单: + +``` +[pair address_sync] +a = "googlecard" +b = "localcard" +collections = ["from a", "from b"] +conflict_resolution = "a wins" + +[storage googlecard] +type = "google_contacts" +token_file = "~/.vdirsyncer/google_token" +client_id = "my_client_id" +client_secret = "my_client_secret" + +[storage localcard] +type = "filesystem" +path = "~/.calendars/Addresses/" +fileext = ".vcf" +``` + +现在,当我运行 `vdirsyncer discover` 时,它会找到我的 Google 联系人,并且 `vdirsyncer sync` 将它们复制到我的本地计算机。但同样,这只进行到一半。现在我想查看和使用联系人。需要 [khard][6] 和 [abook][7]。 + +![khard search][8] + +为什么选择两个应用?因为每个都有它自己的使用场景,在这里,越多越好。khard 用于管理地址,类似于 [khal][9] 用于管理日历条目。如果你的发行版附带了旧版本,你可能需要通过 `pip` 安装最新版本。安装 khard 后,你需要创建 `~/.config/khard/khard.conf`,因为 khard 没有与 khal 那样漂亮的配置向导。我的看起来像这样: + +``` +[addressbooks] +[[addresses]] +path = ~/.calendars/Addresses/default/ + +[general] +debug = no +default_action = list +editor = vim, -i, NONE +merge_editor = vimdiff + +[contact table] +display = first_name +group_by_addressbook = no +reverse = no +show_nicknames = yes +show_uids = no +sort = last_name +localize_dates = yes + +[vcard] +preferred_version = 3.0 +search_in_source_files = yes +skip_unparsable = no +``` + +这会定义源通讯簿(并给它一个友好的名称)、显示内容和联系人编辑程序。运行 `khard list` 将列出所有条目,`khard list ` 可以搜索特定条目。如果要添加或编辑条目,`add` 和 `edit` 命令将使用相同的基本模板打开配置的编辑器,唯一的区别是 `add` 命令的模板将为空。 + +![editing in khard][11] + +abook 需要你导入和导出 VCF 文件,但它为查找提供了一些不错的功能。要将文件转换为 abook 格式,请先安装 abook 并创建 `~/.abook` 默认目录。然后让 abook 解析所有文件,并将它们放入 `~/.abook/addresses` 文件中: + +``` +apt install abook +ls ~/.calendars/Addresses/default/* | xargs cat | abook --convert --informat vcard --outformat abook > ~/.abook/addresses +``` + +现在运行 `abook`,你将有一个非常漂亮的 UI 来浏览、搜索和编辑条目。将它们导出到单个文件有点痛苦,所以我用 khard 进行大部分编辑,并有一个 cron 任务将它们导入到 abook 中。 + +abook 还可在命令行中搜索,并有大量有关将其与邮件客户端集成的文档。例如,你可以在 `.config/alot/config` 文件中添加一些信息,从而在 [Nmuch][12] 的邮件客户端 [alot][13] 中使用 abook 查询联系人: + +``` +[accounts] + [[Personal]] + realname = Kevin Sonney + address = kevin@sonney.com + alias_regexp = kevin\+.+@sonney.com + gpg_key = 7BB612C9 + sendmail_command = msmtp --account=Personal -t + # ~ expansion works + sent_box = maildir://~/Maildir/Sent + draft_box = maildir://~/Maildir/Drafts + [[[abook]]] + type = abook +``` + +这样你就可以在邮件和日历中快速查找联系人了! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/sync-contacts-locally + +作者:[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/talk_chat_team_mobile_desktop.png?itok=d7sRtKfQ (Team communication, chat) +[2]: https://linux.cn/article-11804-1.html +[3]: https://linux.cn/article-11812-1.html +[4]: https://opensource.com/sites/default/files/uploads/productivity_6-1.png (abook) +[5]: https://github.com/pimutils/vdirsyncer +[6]: https://github.com/scheibler/khard +[7]: http://abook.sourceforge.net/ +[8]: https://opensource.com/sites/default/files/uploads/productivity_6-2.png (khard search) +[9]: https://khal.readthedocs.io/en/v0.9.2/index.html +[10]: mailto:some@email.adr +[11]: https://opensource.com/sites/default/files/uploads/productivity_6-3.png (editing in khard) +[12]: https://opensource.com/article/20/1/organize-email-notmuch +[13]: https://github.com/pazz/alot +[14]: mailto:kevin@sonney.com +[15]: mailto:+.+@sonney.com diff --git a/published/202001/20200117 C vs. Rust- Which to choose for programming hardware abstractions.md b/published/202001/20200117 C vs. Rust- Which to choose for programming hardware abstractions.md new file mode 100644 index 0000000000..dcdbc98b5a --- /dev/null +++ b/published/202001/20200117 C vs. Rust- Which to choose for programming hardware abstractions.md @@ -0,0 +1,477 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11825-1.html) +[#]: subject: (C vs. Rust: Which to choose for programming hardware abstractions) +[#]: via: (https://opensource.com/article/20/1/c-vs-rust-abstractions) +[#]: author: (Dan Pittman https://opensource.com/users/dan-pittman) + +C 还是 Rust:选择哪个用于硬件抽象编程 +====== + +> 在 Rust 中使用类型级编程可以使硬件抽象更加安全。 + +![](https://img.linux.net.cn/data/attachment/album/202001/28/123350k2w4mr3tp7crd4m2.jpg) + +Rust 是一种日益流行的编程语言,被视为硬件接口的最佳选择。通常会将其与 C 的抽象级别相比较。本文介绍了 Rust 如何通过多种方式处理按位运算,并提供了既安全又易于使用的解决方案。 + +语言 | 诞生于 | 官方描述 | 总览 +---|---|---|--- +C | 1972 年 | C 是一种通用编程语言,具有表达式简约、现代的控制流和数据结构,以及丰富的运算符集等特点。(来源:[CS 基础知识] [2])| C 是(一种)命令式语言,旨在以相对简单的方式进行编译,从而提供对内存的低级访问。(来源:[W3schools.in] [3]) +Rust | 2010 年 | 一种赋予所有人构建可靠、高效的软件的能力的语言(来源:[Rust 网站] [4])| Rust 是一种专注于安全性(尤其是安全并发性)的多范式系统编程语言。(来源:[维基百科] [5]) + +### 在 C 语言中对寄存器值进行按位运算 + +在系统编程领域,你可能经常需要编写硬件驱动程序或直接与内存映射设备进行交互,而这些交互几乎总是通过硬件提供的内存映射寄存器来完成的。通常,你通过对某些固定宽度的数字类型进行按位运算来与这些寄存器进行交互。 + +例如,假设一个 8 位寄存器具有三个字段: + +``` ++----------+------+-----------+---------+ +| (unused) | Kind | Interrupt | Enabled | ++----------+------+-----------+---------+ +   5-7       2-4        1          0 +``` + +字段名称下方的数字规定了该字段在寄存器中使用的位。要启用该寄存器,你将写入值 `1`(以二进制表示为 `0000_0001`)来设置 `Enabled` 字段的位。但是,通常情况下,你也不想干扰寄存器中的现有配置。假设你要在设备上启用中断功能,但也要确保设备保持启用状态。为此,必须将 `Interrupt` 字段的值与 `Enabled` 字段的值结合起来。你可以通过按位操作来做到这一点: + +``` +1 | (1 << 1) +``` + +通过将 1 和 2(`1` 左移一位得到)进行“或”(`|`)运算得到二进制值 `0000_0011` 。你可以将其写入寄存器,使其保持启用状态,但也启用中断功能。 + +你的头脑中要记住很多事情,特别是当你要在一个完整的系统上和可能有数百个之多的寄存器打交道时。在实践上,你可以使用助记符来执行此操作,助记符可跟踪字段在寄存器中的位置以及字段的宽度(即它的上边界是什么) + +下面是这些助记符之一的示例。它们是 C 语言的宏,用右侧的代码替换它们的出现的地方。这是上面列出的寄存器的简写。`&` 的左侧是该字段的起始位置,而右侧则限制该字段所占的位: + +``` +#define REG_ENABLED_FIELD(x) (x << 0) & 1 +#define REG_INTERRUPT_FIELD(x) (x << 1) & 2 +#define REG_KIND_FIELD(x) (x << 2) & (7 << 2) +``` + +然后,你可以使用这些来抽象化寄存器值的操作,如下所示: + +``` +void set_reg_val(reg* u8, val u8); + +fn enable_reg_with_interrupt(reg* u8) { +    set_reg_val(reg, REG_ENABLED_FIELD(1) | REG_INTERRUPT_FIELD(1)); +} +``` + +这就是现在的做法。实际上,这就是大多数驱动程序在 Linux 内核中的使用方式。 + +有没有更好的办法?如果能够基于对现代编程语言研究得出新的类型系统,就可能能够获得安全性和可表达性的好处。也就是说,如何使用更丰富、更具表现力的类型系统来使此过程更安全、更持久? + +### 在 Rust 语言中对寄存器值进行按位运算 + +继续用上面的寄存器作为例子: + +``` ++----------+------+-----------+---------+ +| (unused) | Kind | Interrupt | Enabled | ++----------+------+-----------+---------+ +   5-7       2-4        1          0 +``` + +你想如何用 Rust 类型来表示它呢? + +你将以类似的方式开始,为每个字段的*偏移*定义常量(即,距最低有效位有多远)及其掩码。*掩码*是一个值,其二进制表示形式可用于更新或读取寄存器内部的字段: + +``` +const ENABLED_MASK: u8 = 1; +const ENABLED_OFFSET: u8 = 0; + +const INTERRUPT_MASK: u8 = 2; +const INTERRUPT_OFFSET: u8 = 1; + +const KIND_MASK: u8 = 7 << 2; +const KIND_OFFSET: u8 = 2; +``` + +接下来,你将声明一个 `Field` 类型并进行操作,将给定值转换为与其位置相关的值,以供在寄存器内使用: + +``` +struct Field { + value: u8, +} + +impl Field { + fn new(mask: u8, offset: u8, val: u8) -> Self { + Field { + value: (val << offset) & mask, + } + } +} +``` + +最后,你将使用一个 `Register` 类型,该类型会封装一个与你的寄存器宽度匹配的数字类型。 `Register` 具有 `update` 函数,可使用给定字段来更新寄存器: + +``` +struct Register(u8); + +impl Register { + fn update(&mut self, val: Field) { + self.0 = self.0 | field.value; + } +} + +fn enable_register(&mut reg) { + reg.update(Field::new(ENABLED_MASK, ENABLED_OFFSET, 1)); +} +``` + +使用 Rust,你可以使用数据结构来表示字段,将它们与特定的寄存器联系起来,并在与硬件交互时提供简洁明了的工效。这个例子使用了 Rust 提供的最基本的功能。无论如何,添加的结构都会减轻上述 C 示例中的某些晦涩的地方。现在,字段是个带有名字的事物,而不是从模糊的按位运算符派生而来的数字,并且寄存器是具有状态的类型 —— 这在硬件上多了一层抽象。 + +### 一个易用的 Rust 实现 + +用 Rust 重写的第一个版本很好,但是并不理想。你必须记住要带上掩码和偏移量,并且要手工进行临时计算,这容易出错。人类不擅长精确且重复的任务 —— 我们往往会感到疲劳或失去专注力,这会导致错误。一次一个寄存器地手动记录掩码和偏移量几乎可以肯定会以糟糕的结局而告终。这是最好留给机器的任务。 + +其次,从结构上进行思考:如果有一种方法可以让字段的类型携带掩码和偏移信息呢?如果可以在编译时就发现硬件寄存器的访问和交互的实现代码中存在错误,而不是在运行时才发现,该怎么办?也许你可以依靠一种在编译时解决问题的常用策略,例如类型。 + +你可以使用 [typenum][6] 来修改前面的示例,该库在类型级别提供数字和算术。在这里,你将使用掩码和偏移量对 `Field` 类型进行参数化,使其可用于任何 `Field` 实例,而无需将其包括在调用处: + +``` +#[macro_use] +extern crate typenum; + +use core::marker::PhantomData; + +use typenum::*; + +// Now we'll add Mask and Offset to Field's type +struct Field { + value: u8, + _mask: PhantomData, + _offset: PhantomData, +} + +// We can use type aliases to give meaningful names to +// our fields (and not have to remember their offsets and masks). +type RegEnabled = Field; +type RegInterrupt = Field; +type RegKind = Field; +``` + +现在,当重新访问 `Field` 的构造函数时,你可以忽略掩码和偏移量参数,因为类型中包含该信息: + +``` +impl Field { + fn new(val: u8) -> Self { + Field { + value: (val << Offset::U8) & Mask::U8, + _mask: PhantomData, + _offset: PhantomData, + } + } +} + +// And to enable our register... +fn enable_register(&mut reg) { + reg.update(RegEnabled::new(1)); +} +``` + +看起来不错,但是……如果你在给定的值是否*适合*该字段方面犯了错误,会发生什么?考虑一个简单的输入错误,你在其中放置了 `10` 而不是 `1`: + +``` +fn enable_register(&mut reg) { +    reg.update(RegEnabled::new(10)); +} +``` + +在上面的代码中,预期结果是什么?好吧,代码会将启用位设置为 0,因为 `10&1 = 0`。那真不幸;最好在尝试写入之前知道你要写入字段的值是否适合该字段。事实上,我认为截掉错误字段值的高位是一种 1*未定义的行为*(哈)。 + +### 出于安全考虑使用 Rust + +如何以一般方式检查字段的值是否适合其规定的位置?需要更多类型级别的数字! + +你可以在 `Field` 中添加 `Width` 参数,并使用它来验证给定的值是否适合该字段: + +``` +struct Field { + value: u8, + _mask: PhantomData, + _offset: PhantomData, + _width: PhantomData, +} + +type RegEnabled = Field; +type RegInterrupt = Field; +type RegKind = Field; + +impl Field { + fn new(val: u8) -> Option { + if val <= (1 << Width::U8) - 1 { + Some(Field { + value: (val << Offset::U8) & Mask::U8, + _mask: PhantomData, + _offset: PhantomData, + _width: PhantomData, + }) + } else { + None + } + } +} +``` + +现在,只有给定值适合时,你才能构造一个 `Field` !否则,你将得到 `None` 信号,该信号指示发生了错误,而不是截掉该值的高位并静默写入意外的值。 + +但是请注意,这将在运行时环境中引发错误。但是,我们事先知道我们想写入的值,还记得吗?鉴于此,我们可以教编译器完全拒绝具有无效字段值的程序 —— 我们不必等到运行它! + +这次,你将向 `new` 的新实现 `new_checked` 中添加一个特征绑定(`where` 子句),该函数要求输入值小于或等于给定字段用 `Width` 所能容纳的最大可能值: + +``` +struct Field { + value: u8, + _mask: PhantomData, + _offset: PhantomData, + _width: PhantomData, +} + +type RegEnabled = Field; +type RegInterrupt = Field; +type RegKind = Field; + +impl Field { + const fn new_checked() -> Self + where + V: IsLessOrEqual, + { + Field { + value: (V::U8 << Offset::U8) & Mask::U8, + _mask: PhantomData, + _offset: PhantomData, + _width: PhantomData, + } + } +} +``` + +只有拥有此属性的数字才实现此特征,因此,如果使用不适合的数字,它将无法编译。让我们看一看! + +``` +fn enable_register(&mut reg) { + reg.update(RegEnabled::new_checked::()); +} +12 | reg.update(RegEnabled::new_checked::()); + | ^^^^^^^^^^^^^^^^ expected struct `typenum::B0`, found struct `typenum::B1` + | + = note: expected type `typenum::B0` + found type `typenum::B1` +``` + +`new_checked` 将无法生成一个程序,因为该字段的值有错误的高位。你的输入错误不会在运行时环境中才爆炸,因为你永远无法获得一个可以运行的工件。 + +就使内存映射的硬件进行交互的安全性而言,你已经接近 Rust 的极致。但是,你在 C 的第一个示例中所写的内容比最终得到的一锅粥的类型参数更简洁。当你谈论潜在可能有数百甚至数千个寄存器时,这样做是否容易处理? + +### 让 Rust 恰到好处:既安全又方便使用 + +早些时候,我认为手工计算掩码有问题,但我又做了同样有问题的事情 —— 尽管是在类型级别。虽然使用这种方法很不错,但要达到编写任何代码的地步,则需要大量样板和手动转录(我在这里谈论的是类型的同义词)。 + +我们的团队想要像 [TockOS mmio 寄存器][7]之类的东西,而以最少的手动转录生成类型安全的实现。我们得出的结果是一个宏,该宏生成必要的样板以获得类似 Tock 的 API 以及基于类型的边界检查。要使用它,请写下一些有关寄存器的信息,其字段、宽度和偏移量以及可选的[枚举][8]类的值(你应该为字段可能具有的值赋予“含义”): + +``` +register! { + // The register's name + Status, + // The type which represents the whole register. + u8, + // The register's mode, ReadOnly, ReadWrite, or WriteOnly. + RW, + // And the fields in this register. + Fields [ + On WIDTH(U1) OFFSET(U0), + Dead WIDTH(U1) OFFSET(U1), + Color WIDTH(U3) OFFSET(U2) [ + Red = U1, + Blue = U2, + Green = U3, + Yellow = U4 + ] + ] +} +``` + +由此,你可以生成寄存器和字段类型,如上例所示,其中索引:`Width`、`Mask` 和 `Offset` 是从一个字段定义的 `WIDTH` 和 `OFFSET` 部分的输入值派生的。另外,请注意,所有这些数字都是 “类型数字”;它们将直接进入你的 `Field` 定义! + +生成的代码通过为寄存器及字段指定名称来为寄存器及其相关字段提供名称空间。这很绕口,看起来是这样的: + +``` +mod Status { + struct Register(u8); + mod On { + struct Field; // There is of course more to this definition + } + mod Dead { + struct Field; + } + mod Color { + struct Field; + pub const Red: Field = Field::new(); + // &c. + } +} +``` + +生成的 API 包含名义上期望的读取和写入的原语,以获取原始寄存器的值,但它也有办法获取单个字段的值、执行集合操作以及确定是否设置了任何(或全部)位集合的方法。你可以阅读[完整生成的 API][9]上的文档。 + +### 粗略检查 + +将这些定义用于实际设备会是什么样?代码中是否会充斥着类型参数,从而掩盖了视图中的实际逻辑? + +不会!通过使用类型同义词和类型推断,你实际上根本不必考虑程序的类型层面部分。你可以直接与硬件交互,并自动获得与边界相关的保证。 + +这是一个 [UART][10] 寄存器块的示例。我会跳过寄存器本身的声明,因为包括在这里就太多了。而是从寄存器“块”开始,然后帮助编译器知道如何从指向该块开头的指针中查找寄存器。我们通过实现 `Deref` 和 `DerefMut` 来做到这一点: + +``` +#[repr(C)] +pub struct UartBlock { + rx: UartRX::Register, + _padding1: [u32; 15], + tx: UartTX::Register, + _padding2: [u32; 15], + control1: UartControl1::Register, +} + +pub struct Regs { + addr: usize, +} + +impl Deref for Regs { + type Target = UartBlock; + + fn deref(&self) -> &UartBlock { + unsafe { &*(self.addr as *const UartBlock) } + } +} + +impl DerefMut for Regs { + fn deref_mut(&mut self) -> &mut UartBlock { + unsafe { &mut *(self.addr as *mut UartBlock) } + } +} +``` + +一旦到位,使用这些寄存器就像 `read()` 和 `modify()` 一样简单: + +``` +fn main() { + // A pretend register block. + let mut x = [0_u32; 33]; + + let mut regs = Regs { + // Some shenanigans to get at `x` as though it were a + // pointer. Normally you'd be given some address like + // `0xDEADBEEF` over which you'd instantiate a `Regs`. + addr: &mut x as *mut [u32; 33] as usize, + }; + + assert_eq!(regs.rx.read(), 0); + + regs.control1 + .modify(UartControl1::Enable::Set + UartControl1::RecvReadyInterrupt::Set); + + // The first bit and the 10th bit should be set. + assert_eq!(regs.control1.read(), 0b_10_0000_0001); +} +``` + +当我们使用运行时值时,我们使用如前所述的**选项**。这里我使用的是 `unwrap`,但是在一个输入未知的真实程序中,你可能想检查一下从新调用中返回的**某些东西**: [^1] [^2] + +``` +fn main() { +    // A pretend register block. +    let mut x = [0_u32; 33]; + +    let mut regs = Regs { +        // Some shenanigans to get at `x` as though it were a +        // pointer. Normally you'd be given some address like +        // `0xDEADBEEF` over which you'd instantiate a `Regs`. +        addr: &mut x as *mut [u32; 33] as usize, +    }; + +    let input = regs.rx.get_field(UartRX::Data::Field::Read).unwrap(); +    regs.tx.modify(UartTX::Data::Field::new(input).unwrap()); +} +``` + +### 解码失败条件 + +根据你的个人痛苦忍耐程度,你可能已经注意到这些错误几乎是无法理解的。看一下我所说的不那么微妙的提醒: + +``` +error[E0271]: type mismatch resolving `, typenum::B0>, typenum::B1>, typenum::B0>, typenum::B0> as typenum::IsLessOrEqual, typenum::B0>, typenum::B1>, typenum::B0>>>::Output == typenum::B1` + --> src/main.rs:12:5 + | +12 | less_than_ten::(); + | ^^^^^^^^^^^^^^^^^^^^ expected struct `typenum::B0`, found struct `typenum::B1` + | + = note: expected type `typenum::B0` + found type `typenum::B1` +``` + +`expected struct typenum::B0, found struct typenum::B1` 部分是有意义的,但是 ` typenum::UInt疯了,地狱了,不要再忍受了Mad As Hell And Wasn't Going To Take It Anymore》,并做了一个小工具 `tnfilt`,从这种命名空间的二进制 cons 单元的痛苦中解脱出来。`tnfilt` 将 cons 单元格式的表示法替换为可让人看懂的十进制数字。我们认为其他人也会遇到类似的困难,所以我们分享了 [tnfilt][14]。你可以像这样使用它: + +``` +$ cargo build 2>&1 | tnfilt +``` + +它将上面的输出转换为如下所示: + +``` +error[E0271]: type mismatch resolving `>::Output == typenum::B1` +``` + +现在*这*才有意义! + +### 结论 + +当在软件与硬件进行交互时,普遍使用内存映射寄存器,并且有无数种方法来描述这些交互,每种方法在易用性和安全性上都有不同的权衡。我们发现使用类型级编程来取得内存映射寄存器交互的编译时检查可以为我们提供制作更安全软件的必要信息。该代码可在 [bounded-registers][15] crate(Rust 包)中找到。 + +我们的团队从安全性较高的一面开始,然后尝试找出如何将易用性滑块移近易用端。从这些雄心壮志中,“边界寄存器”就诞生了,我们在 Auxon 公司的冒险中遇到内存映射设备的任何时候都可以使用它。 + +* * * + +[^1]: 从技术上讲,从定义上看,从寄存器字段读取的值只能在规定的范围内,但是我们当中没有一个人生活在一个纯净的世界中,而且你永远都不知道外部系统发挥作用时会发生什么。你是在这里接受硬件之神的命令,因此与其强迫你进入“可能的恐慌”状态,还不如给你提供处理“这将永远不会发生”的机会。 +[^2]: `get_field` 看起来有点奇怪。我正在专门查看 `Field::Read` 部分。`Field` 是一种类型,你需要该类型的实例才能传递给 `get_field`。更干净的 API 可能类似于:`regs.rx.get_field::();` 但是请记住,`Field` 是一种具有固定的宽度、偏移量等索引的类型的同义词。要像这样对 `get_field` 进行参数化,你需要使用更高级的类型。 + +* * * + +此内容最初发布在 [Auxon Engineering 博客][16]上,并经许可进行编辑和重新发布。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/c-vs-rust-abstractions + +作者:[Dan Pittman][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/dan-pittman +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tools_hardware_purple.png?itok=3NdVoYhl (Tools illustration) +[2]: https://cs-fundamentals.com/c-programming/history-of-c-programming-language.php +[3]: https://www.w3schools.in/c-tutorial/history-of-c/ +[4]: https://www.rust-lang.org/ +[5]: https://en.wikipedia.org/wiki/Rust_(programming_language) +[6]: https://docs.rs/crate/typenum +[7]: https://docs.rs/tock-registers/0.3.0/tock_registers/ +[8]: https://en.wikipedia.org/wiki/Enumerated_type +[9]: https://github.com/auxoncorp/bounded-registers#the-register-api +[10]: https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter +[11]: tmp.shpxgDsodx#1 +[12]: tmp.shpxgDsodx#2 +[13]: https://en.wikipedia.org/wiki/Cons +[14]: https://github.com/auxoncorp/tnfilt +[15]: https://crates.io/crates/bounded-registers +[16]: https://blog.auxon.io/2019/10/25/type-level-registers/ diff --git a/published/202001/20200117 Get started with this open source to-do list manager.md b/published/202001/20200117 Get started with this open source to-do list manager.md new file mode 100644 index 0000000000..deaa6da72a --- /dev/null +++ b/published/202001/20200117 Get started with this open source to-do list manager.md @@ -0,0 +1,106 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11835-1.html) +[#]: subject: (Get started with this open source to-do list manager) +[#]: via: (https://opensource.com/article/20/1/open-source-to-do-list) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +开始使用开源待办事项清单管理器 +====== + +> 待办事项清单是跟踪任务列表的强大方法。在我们的 20 个使用开源提升生产力的系列的第七篇文章中了解如何使用它。 + +![](https://img.linux.net.cn/data/attachment/album/202001/31/111103kmv55ploshuso4ot.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 todo 跟踪任务 + +任务管理和待办事项清单是我非常喜欢0的东西。我是一位生产效率的狂热粉丝(以至于我为此做了一个[播客][2]),我尝试了各种不同的应用。我甚至为此[做了演讲][3]并[写了些文章][4]。因此,当我谈到提高工作效率时,肯定会出现任务管理和待办事项清单工具。 + +![Getting fancy with Todo.txt][5] + +说实话,由于简单、跨平台且易于同步,用 [todo.txt][6] 肯定不会错。它是我不断反复提到的两个待办事项清单以及任务管理应用之一(另一个是 [Org 模式][7])。让我反复使用它的原因是它简单、可移植、易于理解,并且有许多很好的附加组件,并且当一台机器有附加组件,而另一台没有,也不会破坏它。由于它是一个 Bash shell 脚本,我还没发现一个无法支持它的系统。 + +#### 设置 todo.txt + +首先,你需要安装基本 shell 脚本并将默认配置文件复制到 `~/.todo` 目录: + +``` +git clone https://github.com/todotxt/todo.txt-cli.git +cd todo.txt-cli +make +sudo make install +mkdir ~/.todo +cp todo.cfg ~/.todo/config +``` + +接下来,设置配置文件。一般,我想取消对颜色设置的注释,但必须马上设置的是 `TODO_DIR` 变量: + +``` +export TODO_DIR="$HOME/.todo" +``` + +#### 添加待办事件 + +要添加第一个待办事件,只需输入 `todo.sh add ` 就能添加。这还将在 `$HOME/.todo/` 中创建三个文件:`todo.txt`、`done.txt` 和 `reports.txt`。 + +添加几个项目后,运行 `todo.sh ls` 查看你的待办事项。 + +![Basic todo.txt list][8] + +#### 管理任务 + +你可以通过给项目设置优先级来稍微改善它。要向项目添加优先级,运行 `todo.sh pri # A`。数字是列表中任务的数量,而字母 `A` 是优先级。你可以将优先级设置为从 A 到 Z,因为这是它的排序方式。 + +要完成任务,运行 `todo.sh do #` 来标记项目已完成并将它移动到 `done.txt`。运行 `todo.sh report` 会向 `report.txt` 写入已完成和未完成项的数量。 + +所有这三个文件的格式都有详细的说明,因此你可以使用你的文本编辑器修改。`todo.txt` 的基本格式是: + +``` +(Priority) YYYY-MM-DD Task +``` + +该日期表示任务的到期日期(如果已设置)。手动编辑文件时,只需在任务前面加一个 `x` 来标记为已完成。运行 `todo.sh archive` 会将这些项目移动到 `done.txt`,你可以编辑该文本文件,并在有时间时将已完成的项目归档。 + +#### 设置重复任务 + +我有很多重复的任务,我需要以每天/周/月来计划。 + +![Recurring tasks with the ice_recur add-on][9] + +这就是 `todo.txt` 的灵活性所在。通过在 `~/.todo.actions.d/` 中使用[附加组件][10],你可以添加命令并扩展基本 `todo.sh` 的功能。附加组件基本上是实现特定命令的脚本。对于重复执行的任务,插件 [ice_recur][11] 应该符合要求。按照其页面上的说明操作,你可以设置任务以非常灵活的方式重复执行。 + +![Todour on MacOS][12] + +在该[附加组件目录][10]中有很多附加组件,包括同步到某些云服务,也有链接到桌面或移动端应用的组件,这样你可以随时看到待办列表。 + +我只是简单介绍了这个代办事项清单功能,请花点时间深入了解这个工具的强大!它确实可以帮助我每天完成任务。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/open-source-to-do-list + +作者:[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/checklist_todo_clock_time_team.png?itok=1z528Q0y (Team checklist) +[2]: https://productivityalchemy.com/ +[3]: https://www.slideshare.net/AllThingsOpen/getting-to-done-on-the-command-line +[4]: https://opensource.com/article/18/2/getting-to-done-agile-linux-command-line +[5]: https://opensource.com/sites/default/files/uploads/productivity_7-1.png +[6]: http://todotxt.org/ +[7]: https://orgmode.org/ +[8]: https://opensource.com/sites/default/files/uploads/productivity_7-2.png (Basic todo.txt list) +[9]: https://opensource.com/sites/default/files/uploads/productivity_7-3.png (Recurring tasks with the ice_recur add-on) +[10]: https://github.com/todotxt/todo.txt-cli/wiki/Todo.sh-Add-on-Directory +[11]: https://github.com/rlpowell/todo-text-stuff +[12]: https://opensource.com/sites/default/files/uploads/productivity_7-4.png (Todour on MacOS) diff --git a/published/202001/20200117 Locking and unlocking accounts on Linux systems.md b/published/202001/20200117 Locking and unlocking accounts on Linux systems.md new file mode 100644 index 0000000000..64a19e1010 --- /dev/null +++ b/published/202001/20200117 Locking and unlocking accounts on Linux systems.md @@ -0,0 +1,112 @@ +[#]: collector: (lujun9972) +[#]: translator: (FSSlc) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11813-1.html) +[#]: subject: (Locking and unlocking accounts on Linux systems) +[#]: via: (https://www.networkworld.com/article/3513982/locking-and-unlocking-accounts-on-linux-systems.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +在 Linux 系统中禁用与解禁用户的账号 +====== + +> 总有这样的时候:有时你需要禁用某位 Linux 用户的账号,有时你还需要反过来解禁用户的账号。 +本文将介绍一些管理用户访问的命令,并介绍它们背后的原理。 + +![](https://images.idgesg.net/images/article/2019/10/cso_cybersecurity_mysterious_padlock_complex_circuits_gold_by_sqback_gettyimages-1177918748_2400x1600-100813830-large.jpg) + +假如你正管理着一台 [Linux][1] 系统,那么很有可能将遇到需要禁用一个账号的情况。可能是某人已经换了职位,他们是否还需要该账号仍是个问题;或许有理由相信再次使用该账号并没有大碍。不管上述哪种情况,知晓如何禁用账号并解禁账号都是你需要知道的知识。 + +需要你记住的一件重要的事是尽管有多种方法来禁用账号,但它们并不都达到相同的效果。假如用户使用公钥/私钥来使用该账号而不是使用密码来访问,那么你使用的某些命令来阻止用户获取该账号或许将不会生效。 + +### 使用 passwd 来禁用一个账号 + +最为简单的用来禁用一个账号的方法是使用 `passwd -l` 命令。例如: + +``` +$ sudo passwd -l tadpole +``` + +上面这个命令的效果是在加密后的密码文件 `/etc/shadow` 中,用户对应的那一行的最前面加上一个 `!` 符号。这样就足够阻止用户使用密码来访问账号了。 + +在没有使用上述命令前,加密后的密码行如下所示(请注意第一个字符): + +``` +$6$IC6icrWlNhndMFj6$Jj14Regv3b2EdK.8iLjSeO893fFig75f32rpWpbKPNz7g/eqeaPCnXl3iQ7RFIN0BGC0E91sghFdX2eWTe2ET0:18184:0:99999:7::: +``` + +而禁用该账号后,这一行将变为: + +``` +!$6$IC6icrWlNhndMFj6$Jj14Regv3b2EdK.8iLjSeO893fFig75f32rpWpbKPNz7g/eqeaPCnXl3iQ7RFIN0BGC0E91sghFdX2eWTe2ET0:18184:0:99999:7::: +``` + +在 tadpole 下一次尝试登录时,他可能会使用他原有的密码来尝试多次登录,但就是无法再登录成功了。另一方面,你则可以使用下面的命令来查看他这个账号的状态(`-S` = status): + +``` +$ sudo passwd -S tadpole +tadpole L 10/15/2019 0 99999 7 -1 +``` + +第二项的 `L` 告诉你这个账号已经被禁用了。在该账号被禁用前,这一项应该是 `P`。如果显示的是 `NP` 则意味着该账号还没有设置密码。 + +命令 `usermod -L` 也具有相同的效果(添加 `!` 来禁用账号的使用)。 + +使用这种方法来禁用某个账号的一个好处是当需要解禁某个账号时非常容易。只需要使用一个文本编辑器或者使用 `passwd -u` 命令来执行相反的操作,即将添加的 `!` 移除即可。 + +``` +$ sudo passwd -u tadpole +passwd: password expiry information changed. +``` + +但使用这种方式的问题是如果用户使用公钥/私钥对的方式来访问他/她的账号,这种方式将不能阻止他们使用该账号。 + +### 使用 chage 命令来禁用账号 + +另一种禁用用户账号的方法是使用 `chage` 命令,它可以帮助管理用户账号的过期日期。 + +``` +$ sudu chage -E0 tadpole +$ sudo passwd -S tadpole +tadpole P 10/15/2019 0 99999 7 -1 +``` + +`chage` 命令将会稍微修改 `/etc/shadow` 文件。在这个使用 `:` 来分隔的文件(下面将进行展示)中,某行的第 8 项将被设置为 `0`(先前为空),这就意味着这个账号已经过期了。`chage` 命令会追踪密码更改期间的天数,通过选项也可以提供账号过期信息。第 8 项如果是 0 则意味着这个账号在 1970 年 1 月 1 日后的一天过期,当使用上面显示的那个命令时可以用来禁用账号。 + +``` +$ sudo grep tadpole /etc/shadow | fold +tadpole:$6$IC6icrWlNhndMFj6$Jj14Regv3b2EdK.8iLjSeO893fFig75f32rpWpbKPNz7g/eqeaPC +nXl3iQ7RFIN0BGC0E91sghFdX2eWTe2ET0:18184:0:99999:7::0: + ^ + | + +--- days until expiration +``` + +为了执行相反的操作,你可以简单地使用下面的命令将放置在 `/etc/shadow` 文件中的 `0` 移除掉: + +``` +% sudo chage -E-1 tadpole +``` + +一旦一个账号使用这种方式被禁用,即便是无密码的 [SSH][4] 登录也不能再访问该账号了。 + + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3513982/locking-and-unlocking-accounts-on-linux-systems.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[FSSlc](https://github.com/FSSlc) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3215226/what-is-linux-uses-featres-products-operating-systems.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua +[4]: https://www.networkworld.com/article/3441777/how-the-linux-screen-tool-can-save-your-tasks-and-your-sanity-if-ssh-is-interrupted.html +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/202001/20200119 What-s your favorite Linux terminal trick.md b/published/202001/20200119 What-s your favorite Linux terminal trick.md new file mode 100644 index 0000000000..675f36a935 --- /dev/null +++ b/published/202001/20200119 What-s your favorite Linux terminal trick.md @@ -0,0 +1,57 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11817-1.html) +[#]: subject: (What's your favorite Linux terminal trick?) +[#]: via: (https://opensource.com/article/20/1/linux-terminal-trick) +[#]: author: (Opensource.com https://opensource.com/users/admin) + +你有什么喜欢的 Linux 终端技巧? +====== + +> 告诉我们你最喜欢的终端技巧,无论是提高生产率的快捷方式还是有趣的彩蛋。 + +![](https://img.linux.net.cn/data/attachment/album/202001/25/135858accxc70tfxuifxx1.jpg) + +新年伊始始终是评估提高效率的新方法的好时机。许多人尝试使用新的生产力工具,或者想找出如何优化其最常用的流程。终端是一个需要评估的领域,尤其是在开源世界中,有无数种方法可以通过快捷键和命令使终端上的生活更加高效(又有趣!)。 + +我们向作者们询问了他们最喜欢的终端技巧。他们分享了一些节省时间的技巧,甚至还有一个有趣的终端彩蛋。你会采用这些键盘快捷键或命令行技巧吗?你有喜欢分享的最爱吗?请发表评论来告诉我们。 + +“我找不出哪个是我最喜欢的;每天我都会使用这三个: + +* `Ctrl + L` 来清除屏幕(而不是键入 `clear`)。 +* `sudo !!` 以 `sudo` 特权运行先前的命令。 +* `grep -Ev '^#|^$' ` 将显示文件内容,不带注释或空行。” —Mars Toktonaliev + +“对我来说,如果我正在使用终端文本编辑器,并且希望将其丢开,以便可以快速执行其他操作,则可以使用 `Ctrl + Z` 将其放到后台,接着执行我需要做的一切,然后用 `fg` 将其带回前台。有时我也会对 `top` 或 `htop` 做同样的事情。我可以将其丢到后台,并在我想检查当前性能时随时将其带回前台。我不会将通常很快能完成的任务在前后台之间切换,它确实可以增强终端上的多任务处理能力。” —Jay LaCroix + +“我经常在某一天在终端中做很多相同的事情,有两件事是每天都不变的: + +* `Ctrl + R` 反向搜索我的 Bash 历史记录以查找我已经运行并且希望再次执行的命令。 +* 插入号(`^`)替换是最好的,因为我经常做诸如 `sudo dnf search ` 之类的事情,然后,如果我以这种方式找到合适的软件包,则执行 `^search^install` 来重新运行该命令,以 `install` 替换 `search`。 + +这些东西肯定是很基本的,但是对我来说却节省了时间。” —Steve Morris + +“我的炫酷终端技巧不是我在终端上执行的操作,而是我使用的终端。有时候我只是想要使用 Apple II 或旧式琥珀色终端的感觉,那我就启动了 Cool-Retro-Term。它的截屏可以在这个[网站][2]上找到。” —Jim Hall + +“可能是用 `ssh -X` 来在其他计算机上运行图形程序。(在某些终端仿真器上,例如 gnome-terminal)用 `C-S c` 和 `C-S v` 复制/粘贴。我不确定这是否有价值(因为它有趣的是以 ssh 启动的图形化)。最近,我需要登录另一台计算机,但是我的孩子们可以在笔记本电脑的大屏幕上看到它。这个[链接][3]向我展示了一些我从未见过的内容:通过局域网从我的笔记本电脑上镜像来自另一台计算机屏幕上的活动会话(`x11vnc -desktop`),并能够同时从两台计算机上进行控制。” —Kyle R. Conway + +“你可以安装 `sl`(`$ sudo apt install sl` 或 `$ sudo dnf install sl`),并且当在 Bash 中输入命令 `sl` 时,一个基于文本的蒸汽机车就会在显示屏上移动。” —Don Watkins + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/linux-terminal-trick + +作者:[Opensource.com][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/admin +[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://github.com/Swordfish90/cool-retro-term +[3]: https://elinux.org/Screen_Casting_on_a_Raspberry_Pi diff --git a/published/202001/20200122 Setting up passwordless Linux logins using public-private keys.md b/published/202001/20200122 Setting up passwordless Linux logins using public-private keys.md new file mode 100644 index 0000000000..89f54a6b45 --- /dev/null +++ b/published/202001/20200122 Setting up passwordless Linux logins using public-private keys.md @@ -0,0 +1,202 @@ +[#]: collector: (lujun9972) +[#]: translator: (laingke) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11830-1.html) +[#]: subject: (Setting up passwordless Linux logins using public/private keys) +[#]: via: (https://www.networkworld.com/article/3514607/setting-up-passwordless-linux-logins-using-publicprivate-keys.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +使用公钥/私钥对设定免密的 Linux 登录方式 +====== + +> 使用一组公钥/私钥对让你不需要密码登录到远程 Linux 系统或使用 ssh 运行命令,这会非常方便,但是设置过程有点复杂。下面是帮助你的方法和脚本。 + +![](https://img.linux.net.cn/data/attachment/album/202001/29/141343ldps4muy4kp64k4l.jpg) + +在 [Linux][1] 系统上设置一个允许你无需密码即可远程登录或运行命令的帐户并不难,但是要使它正常工作,你还需要掌握一些繁琐的细节。在本文,我们将完成整个过程,然后给出一个可以帮助处理琐碎细节的脚本。 + +设置好之后,如果希望在脚本中运行 `ssh` 命令,尤其是希望配置自动运行的命令,那么免密访问特别有用。 + +需要注意的是,你不需要在两个系统上使用相同的用户帐户。实际上,你可以把公用密钥用于系统上的多个帐户或多个系统上的不同帐户。 + +设置方法如下。 + +### 在哪个系统上启动? + +首先,你需要从要发出命令的系统上着手。那就是你用来创建 `ssh` 密钥的系统。你还需要可以访问远程系统上的帐户并在其上运行这些命令。 + +为了使角色清晰明了,我们将场景中的第一个系统称为 “boss”,因为它将发出要在另一个系统上运行的命令。 + +因此,命令提示符如下: + +``` +boss$ +``` + +如果你还没有在 boss 系统上为你的帐户设置公钥/私钥对,请使用如下所示的命令创建一个密钥对。注意,你可以在各种加密算法之间进行选择。(一般使用 RSA 或 DSA。)注意,要在不输入密码的情况下访问系统,你需要在下面的对话框中的两个提示符出不输入密码。 + +如果你已经有一个与此帐户关联的公钥/私钥对,请跳过此步骤。 + +``` +boss$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key (/home/myself/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): <== 按下回车键即可 +Enter same passphrase again: <== 按下回车键即可 +Your identification has been saved in /home/myself/.ssh/id_rsa. +Your public key has been saved in /home/myself/.ssh/id_rsa.pub. +The key fingerprint is: +SHA256:1zz6pZcMjA1av8iyojqo6NVYgTl1+cc+N43kIwGKOUI myself@boss +The key's randomart image is: ++---[RSA 3072]----+ +| . .. | +| E+ .. . | +| .+ .o + o | +| ..+.. .o* . | +| ... So+*B o | +| + ...==B . | +| . o . ....++. | +|o o . . o..o+ | +|=..o.. ..o o. | ++----[SHA256]-----+ +``` + +上面显示的命令将创建公钥和私钥。其中公钥用于加密,私钥用于解密。因此,这些密钥之间的关系是关键的,私有密钥**绝不**应该被共享。相反,它应该保存在 boss 系统的 `.ssh` 文件夹中。 + +注意,在创建时,你的公钥和私钥将会保存在 `.ssh` 文件夹中。 + +下一步是将**公钥**复制到你希望从 boss 系统免密访问的系统。你可以使用 `scp` 命令来完成此操作,但此时你仍然需要输入密码。在本例中,该系统称为 “target”。 + +``` +boss$ scp .ssh/id_rsa.pub myacct@target:/home/myaccount +myacct@target's password: +``` + +你需要安装公钥在 target 系统(将运行命令的系统)上。如果你没有 `.ssh` 目录(例如,你从未在该系统上使用过 `ssh`),运行这样的命令将为你设置一个目录: + +``` +target$ ssh localhost date +target$ ls -la .ssh +total 12 +drwx------ 2 myacct myacct 4096 Jan 19 11:48 . +drwxr-xr-x 6 myacct myacct 4096 Jan 19 11:49 .. +-rw-r--r-- 1 myacct myacct 222 Jan 19 11:48 known_hosts +``` + +仍然在目标系统上,你需要将从“boss”系统传输的公钥添加到 `.ssh/authorized_keys` 文件中。如果该文件已经存在,使用下面的命令将把它添加到文件的末尾;如果文件不存在,则创建该文件并添加密钥。 + +``` +target$ cat id_rsa.pub >> .ssh/authorized_keys +``` + +下一步,你需要确保你的 `authorized_keys` 文件权限为 600。如果还不是,执行命令 `chmod 600 .ssh/authorized_keys`。 + +``` +target$ ls -l authorized_keys +-rw------- 1 myself myself 569 Jan 19 12:10 authorized_keys +``` + +还要检查目标系统上 `.ssh` 目录的权限是否设置为 700。如果需要,执行 `chmod 700 .ssh` 命令修改权限。 + +``` +target$ ls -ld .ssh +drwx------ 2 myacct myacct 4096 Jan 14 15:54 .ssh +``` + +此时,你应该能够从 boss 系统远程免密运行命令到目标系统。除非目标系统上的目标用户帐户拥有与你试图连接的用户和主机相同的旧公钥,否则这应该可以工作。如果是这样,你应该删除早期的(并冲突的)条目。 + +### 使用脚本 + +使用脚本可以使某些工作变得更加容易。但是,在下面的示例脚本中,你会遇到的一个烦人的问题是,在配置免密访问权限之前,你必须多次输入目标用户的密码。一种选择是将脚本分为两部分——需要在 boss 系统上运行的命令和需要在 target 系统上运行的命令。 + +这是“一步到位”版本的脚本: + +``` +#!/bin/bash +# NOTE: This script requires that you have the password for the remote acct +# in order to set up password-free access using your public key + +LOC=`hostname` # the local system from which you want to run commands from + # wo a password + +# get target system and account +echo -n "target system> " +read REM +echo -n "target user> " +read user + +# create a key pair if no public key exists +if [ ! -f ~/.ssh/id_rsa.pub ]; then + ssh-keygen -t rsa +fi + +# ensure a .ssh directory exists in the remote account +echo checking for .ssh directory on remote system +ssh $user@$REM "if [ ! -d /home/$user/.ssh ]; then mkdir /home/$user/.ssh; fi" + +# share the public key (using local hostname) +echo copying the public key +scp ~/.ssh/id_rsa.pub $user@$REM:/home/$user/$user-$LOC.pub + +# put the public key into the proper location +echo adding key to authorized_keys +ssh $user@$REM "cat /home/$user/$user-$LOC.pub >> /home/$user/.ssh/authorized_ke +ys" + +# set permissions on authorized_keys and .ssh (might be OK already) +echo setting permissions +ssh $user@$REM "chmod 600 ~/.ssh/authorized_keys" +ssh $user@$REM "chmod 700 ~/.ssh" + +# try it out -- should NOT ask for a password +echo testing -- if no password is requested, you are all set +ssh $user@$REM /bin/hostname +``` + +脚本已经配置为在你每次必须输入密码时告诉你它正在做什么。交互看起来是这样的: + +``` +$ ./rem_login_setup +target system> fruitfly +target user> lola +checking for .ssh directory on remote system +lola@fruitfly's password: +copying the public key +lola@fruitfly's password: +id_rsa.pub 100% 567 219.1KB/s 00:00 +adding key to authorized_keys +lola@fruitfly's password: +setting permissions +lola@fruitfly's password: +testing -- if no password is requested, you are all set +fruitfly +``` + +在上面的场景之后,你就可以像这样登录到 lola 的帐户: + +``` +$ ssh lola@fruitfly +[lola@fruitfly ~]$ +``` + +一旦设置了免密登录,你就可以不需要键入密码从 boss 系统登录到 target 系统,并且运行任意的 `ssh` 命令。以这种免密的方式运行并不意味着你的帐户不安全。然而,根据 target 系统的性质,保护你在 boss 系统上的密码可能变得更加重要。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3514607/setting-up-passwordless-linux-logins-using-publicprivate-keys.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[laingke](https://github.com/laingke) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3215226/what-is-linux-uses-featres-products-operating-systems.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.networkworld.com/article/3143050/linux/linux-hardening-a-15-step-checklist-for-a-secure-linux-server.html#tk.nww-fsb +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/202001/20200123 Wine 5.0 is Released- Here-s How to Install it.md b/published/202001/20200123 Wine 5.0 is Released- Here-s How to Install it.md new file mode 100644 index 0000000000..683f033104 --- /dev/null +++ b/published/202001/20200123 Wine 5.0 is Released- Here-s How to Install it.md @@ -0,0 +1,165 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11827-1.html) +[#]: subject: (Wine 5.0 is Released! Here’s How to Install it) +[#]: via: (https://itsfoss.com/wine-5-release/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Wine 5.0 发布了! +====== + +> Wine 的一个新的主要版本发布了。使用 Wine 5.0,在 Linux 上运行 Windows 应用程序和游戏的体验得到进一步改进。 + +通过一些努力,你可以使用 Wine [在 Linux 上运行 Windows 应用程序][1]。当你必须使用一个仅在 Windows 上可用的软件时,Wine 是一个可以尝试的工具。它支持许多这样的软件。 + +Wine 的一个新的主要发布版本已经降临,即 Wine 5.0,几乎距它的 4.0 发布一年之后。 + +Wine 5.0 发布版本引进了几个主要特性和很多显著的更改/改进。在这篇文章中,我将重点介绍新的特性是什么,并且也将提到安装说明。 + +### 在 Wine 5.0 中有什么新的特性? + +![][2] + +如他们的[官方声明][3]所述,这是 5.0 发布版本中的关键更改: + +* PE 格式的内置模块。 +* 支持多显示器。 +* 重新实现了 XAudio2。 +* 支持 Vulkan 1.1。 +* 支持微软安装程序(MSI)补丁文件。 +* 性能提升。 + +因此,随着 Vulkan 1.1 和对多显示器的支持 —— Wine 5.0 发布版本是一件大事。 + +除了上面强调的这些关键内容以外,在新的版本中包含成千上万的更改/改进中,你还可以期待对控制器的支持更好。 + +值得注意的是,此版本特别纪念了 **Józef Kucia**(vkd3d 项目的首席开发人员)。 + +他们也已经在[发布说明][4]中提到这一点: + +> 这个发布版本特别纪念了 Józef Kucia,他于 2019 年 8 月去世,年仅 30 岁。Józef 是 Wine 的 Direct3D 实现的一个主要贡献者,并且是 vkd3d 项目的首席开发人员。我们都非常怀念他的技能和友善。 + +### 如何在 Ubuntu 和 Linux Mint 上安装 Wine 5.0 + +> 注意: + +> 如果你在以前安装过 Wine,你应该将其完全移除,以(如你希望的)避免一些冲突。此外,WineHQ 存储库的密钥最近已被更改,针对你的 Linux 发行版的更多的操作指南,你可以参考它的[下载页面][5]。 + +Wine 5.0 的源码可在它的[官方网站][3]上获得。为了使其工作,你可以阅读更多关于[构建 Wine][6] 的信息。基于 Arch 的用户应该很快就会得到它。 + +在这里,我将向你展示在 Ubuntu 和其它基于 Ubuntu 的发行版上安装 Wine 5.0 的步骤。请耐心,并按照步骤一步一步安装和使用 Wine。这里涉及几个步骤。 + +请记住,Wine 安装了太多软件包。你会看到大量的软件包列表,下载大小约为 1.3 GB。 + +### 在 Ubuntu 上安装 Wine 5.0(不适用于 Linux Mint) + +首先,使用这个命令来移除现存的 Wine: + +``` +sudo apt remove winehq-stable wine-stable wine1.6 wine-mono wine-geco winetricks +``` + +然后确保添加 32 位体系结构支持: + +``` +sudo dpkg --add-architecture i386 +``` + +下载并添加官方 Wine 存储库密钥: + +``` +wget -qO - https://dl.winehq.org/wine-builds/winehq.key | sudo apt-key add - +``` + +现在,接下来的步骤需要添加存储库,为此, 你需要首先[知道你的 Ubuntu 版本][7]。 + +对于 **Ubuntu 18.04 和 19.04**,用这个 PPA 添加 FAudio 依赖, **Ubuntu 19.10** 不需要它: + +``` +sudo add-apt-repository ppa:cybermax-dexter/sdl2-backport +``` + +现在使用此命令添加存储库: + +``` +sudo apt-add-repository "deb https://dl.winehq.org/wine-builds/ubuntu $(lsb_release -cs) main" +``` + +现在你已经添加了正确的存储库,可以使用以下命令安装 Wine 5.0: + +``` +sudo apt update && sudo apt install --install-recommends winehq-stable +``` + +请注意,尽管[在软件包列表中将 Wine 5 列为稳定版][8],但你仍可能会看到 winehq-stable 的 wine 4.0.3。也许它不会传播到所有地理位置。从今天早上开始,我可以看到 Wine 5.0。 + +### 在 Linux Mint 19.1、19.2 和 19.3 中安装 Wine 5.0 + +正如一些读者通知我的那样,[apt-add 存储库命令][9]不适用于 Linux Mint 19.x 系列。 + +这是添加自定义存储库的另一种方法。你必须执行与 Ubuntu 相同的步骤。如删除现存的 Wine 包: + +``` +sudo apt remove winehq-stable wine-stable wine1.6 wine-mono wine-geco winetricks +``` + +添加 32 位支持: + +``` +sudo dpkg --add-architecture i386 +``` + +然后添加 GPG 密钥: + +``` +wget -qO - https://dl.winehq.org/wine-builds/winehq.key | sudo apt-key add - +``` + +添加 FAudio 依赖: + +``` +sudo add-apt-repository ppa:cybermax-dexter/sdl2-backport +``` + +现在为 Wine 存储库创建一个新条目: + +``` +sudo sh -c "echo 'deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main' >> /etc/apt/sources.list.d/winehq.list" +``` + +更新软件包列表并安装Wine: + +``` +sudo apt update && sudo apt install --install-recommends winehq-stable +``` + +### 总结 + +你尝试过最新的 Wine 5.0 发布版本吗?如果是的话,在运行中你看到什么改进? + +在下面的评论区域,让我知道你对新的发布版本的看法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/wine-5-release/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/use-windows-applications-linux/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/wine_5.png?ssl=1 +[3]: https://www.winehq.org/news/2020012101 +[4]: https://www.winehq.org/announce/5.0 +[5]: https://wiki.winehq.org/Download +[6]: https://wiki.winehq.org/Building_Wine +[7]: https://itsfoss.com/how-to-know-ubuntu-unity-version/ +[8]: https://dl.winehq.org/wine-builds/ubuntu/dists/bionic/main/binary-amd64/ +[9]: https://itsfoss.com/add-apt-repository-command-not-found/ diff --git a/published/202002/20180503 How the four components of a distributed tracing system work together.md b/published/202002/20180503 How the four components of a distributed tracing system work together.md new file mode 100644 index 0000000000..1f073d897e --- /dev/null +++ b/published/202002/20180503 How the four components of a distributed tracing system work together.md @@ -0,0 +1,149 @@ +分布式跟踪系统的四大功能模块如何协同工作 +====== + +> 了解分布式跟踪中的主要体系结构决策,以及各部分如何组合在一起。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/touch-tracing.jpg?itok=rOmsY-nU) + +早在十年前,认真研究过分布式跟踪基本上只有学者和一小部分大型互联网公司中的人。对于任何采用微服务的组织来说,它如今成为一种筹码。其理由是确立的:微服务通常会发生让人意想不到的错误,而分布式跟踪则是描述和诊断那些错误的最好方法。 + +也就是说,一旦你准备将分布式跟踪集成到你自己的应用程序中,你将很快意识到对于不同的人来说“分布式跟踪Distributed Tracing”一词意味着不同的事物。此外,跟踪生态系统里挤满了具有相似内容的重叠项目。本文介绍了分布式跟踪系统中四个(可能)独立的功能模块,并描述了它们间将如何协同工作。 + +### 分布式跟踪:一种思维模型 + +大多数用于跟踪的思维模型来源于 [Google 的 Dapper 论文][1]。[OpenTracing][2] 使用相似的术语,因此,我们从该项目借用了以下术语: + +![Tracing][3] + +* 跟踪Trace:事物在分布式系统运行的过程描述。 +* 跨度Span:一种命名的定时操作,表示工作流的一部分。跨度可接受键值对标签以及附加到特定跨度实例的细粒度的、带有时间戳的结构化日志。 +* 跨度上下文Span context:携带分布式事务的跟踪信息,包括当它通过网络或消息总线将服务传递给服务时。跨度上下文包含跟踪标识符、跨度标识符以及跟踪系统所需传播到下游服务的任何其他数据。 + +如果你想要深入研究这种思维模式的细节,请仔细参照 [OpenTracing 技术规范][1]。 + +### 四大功能模块 + +从应用层分布式跟踪系统的观点来看,现代软件系统架构如下图所示: + +![Tracing][5] + +现代软件系统的组件可分为三类: + +* **应用程序和业务逻辑**:你的代码。 +* **广泛共享库**:他人的代码 +* **广泛共享服务**:他人的基础架构 + +这三类组件有着不同的需求,驱动着监控应用程序的分布式跟踪系统的设计。最终的设计得到了四个重要的部分: + +* 跟踪检测 APIA tracing instrumentation API:修饰应用程序代码 +* 线路协议Wire protocol:在 RPC 请求中与应用程序数据一同发送的规定 +* 数据协议Data protocol:将异步信息(带外)发送到你的分析系统的规定 +* 分析系统Analysis system:用于处理跟踪数据的数据库和交互式用户界面 + +为了更深入的解释这个概念,我们将深入研究驱动该设计的细节。如果你只需要我的一些建议,请跳转至下方的四大解决方案。 + +### 需求,细节和解释 + +应用程序代码、共享库以及共享式服务在操作上有显著的差别,这种差别严重影响了对其进行检测的请求操作。 + +#### 检测应用程序代码和业务逻辑 + +在任何特定的微服务中,由微服务开发者编写的大部分代码是应用程序或者商业逻辑。这部分代码规定了特定区域的操作。通常,它包含任何特殊、独一无二的逻辑判断,这些逻辑判断首先证明了创建新型微服务的合理性。基本上按照定义,**该代码通常不会在多个服务中共享或者以其他方式出现。** + +也即是说你仍需了解它,这也意味着需要以某种方式对它进行检测。一些监控和跟踪分析系统使用黑盒代理black-box agents自动检测代码,另一些系统更想使用显式的白盒检测工具。对于后者,抽象跟踪 API 提供了许多对于微服务的应用程序代码来说更为实用的优势: + +* 抽象 API 允许你在不重新编写检测代码的条件下换新的监视工具。你可能想要变更云服务提供商、供应商和监测技术,而一大堆不可移植的检测代码将会为该过程增加有意义的开销和麻烦。 +* 事实证明,除了生产监控之外,该工具还有其他有趣的用途。现有的项目使用相同的跟踪工具来驱动测试工具、分布式调试器、“混沌工程”故障注入器和其他元应用程序。 +* 但更重要的是,若将应用程序组件提取到共享库中要怎么办呢?由上述内容可得到结论: + +#### 检测共享库 + +在大多数应用程序中出现的实用程序代码(处理网络请求、数据库调用、磁盘写操作、线程、并发管理等)通常情况下是通用的,而非特别应用于某个特定应用程序。这些代码会被打包成库和框架,而后就可以被装载到许多的微服务上并且被部署到多种不同的环境中。 + +其真正的不同是:对于共享代码,其他人则成为了使用者。大多数用户有不同的依赖关系和操作风格。如果尝试去使用该共享代码,你将会注意到几个常见的问题: + +* 你需要一个 API 来编写检测。然而,你的库并不知道你正在使用哪个分析系统。会有多种选择,并且运行在相同应用下的所有库无法做出不兼容的选择。 +* 由于这些包封装了所有网络处理代码,因此从请求报头注入和提取跨度上下文的任务往往指向 RPC 库。然而,共享库必须了解到每个应用程序正在使用哪种跟踪协议。 +* 最后,你不想强制用户使用相互冲突的依赖项。大多数用户有不同的依赖关系和操作风格。即使他们使用 gRPC,绑定的 gRPC 版本是否相同?因此任何你的库附带用于跟踪的监控 API 必定是免于依赖的。 + +**因此,一个(a)没有依赖关系、(b)与线路协议无关、(c)使用流行的供应商和分析系统的抽象 API 应该是对检测共享库代码的要求。** + +#### 检测共享式服务 + +最后,有时整个服务(或微服务集合体)的通用性足以使许多独立的应用程序使用它们。这种共享式服务通常由第三方托管和管理,例如缓存服务器、消息队列以及数据库。 + +从应用程序开发者的角度来看,理解共享式服务本质上是黑盒子是极其重要的。它不可能将你的应用程序监控注入到共享式服务。恰恰相反,托管服务通常会运行它自己的监控方案。 + +### 四个方面的解决方案 + +因此,抽象的跟踪应用程序接口将会帮助库发出数据并且注入/抽取跨度上下文。标准的线路协议将会帮助黑盒服务相互连接,而标准的数据格式将会帮助分离的分析系统合并其中的数据。让我们来看一下部分有希望解决这些问题的方案。 + +#### 跟踪 API:OpenTracing 项目 + +如你所见,我们需要一个跟踪 API 来检测应用程序代码。为了将这种工具扩展到大多数进行跨度上下文注入和提取的共享库中,则必须以某种关键方式对 API 进行抽象。 + +[OpenTracing][2] 项目主要针对解决库开发者的问题,OpenTracing 是一个与供应商无关的跟踪 API,它没有依赖关系,并且迅速得到了许多监控系统的支持。这意味着,如果库附带了内置的本地 OpenTracing 工具,当监控系统在应用程序启动连接时,跟踪将会自动启动。 + +就个人而言,作为一个已经编写、发布和操作开源软件十多年的人,在 OpenTracing 项目上工作并最终解决这个观察性的难题令我十分满意。 + +除了 API 之外,OpenTracing 项目还维护了一个不断增长的工具列表,其中一些可以在[这里][6]找到。如果你想参与进来,无论是通过提供一个检测插件,对你自己的 OSS 库进行本地测试,或者仅仅只想问个问题,都可以通过 [Gitter][7] 向我们打招呼。 + +#### 线路协议: HTTP 报头 trace-context + +为了监控系统能进行互操作,以及减轻从一个监控系统切换为另外一个时带来的迁移问题,需要标准的线路协议来传播跨度上下文。 + +[w3c 分布式跟踪上下文社区小组][8]在努力制定此标准。目前的重点是制定一系列标准的 HTTP 报头。该规范的最新草案可以在[此处][9]找到。如果你对此小组有任何的疑问,[邮件列表][10]和[Gitter 聊天室][11]是很好的解惑地点。 + +(LCTT 译注:本文原文发表于 2018 年 5 月,可能现在社区已有不同进展) + +#### 数据协议 (还未出现!!) + +对于黑盒服务,在无法安装跟踪程序或无法与程序进行交互的情况下,需要使用数据协议从系统中导出数据。 + +目前这种数据格式和协议的开发工作尚处在初级阶段,并且大多在 w3c 分布式跟踪上下文工作组的上下文中进行工作。需要特别关注的是在标准数据模式中定义更高级别的概念,例如 RPC 调用、数据库语句等。这将允许跟踪系统对可用数据类型做出假设。OpenTracing 项目也通过定义一套[标准标签集][12]来解决这一事务。该计划是为了使这两项努力结果相互配合。 + +注意当前有一个中间地带。对于由应用程序开发者操作但不想编译或以其他方式执行代码修改的“网络设备”,动态链接可以帮助避免这种情况。主要的例子就是服务网格和代理,就像 Envoy 或者 NGINX。针对这种情况,可将兼容 OpenTracing 的跟踪器编译为共享对象,然后在运行时动态链接到可执行文件中。目前 [C++ OpenTracing API][13] 提供了该选项。而 JAVA 的 OpenTracing [跟踪器解析][14]也在开发中。 + +这些解决方案适用于支持动态链接,并由应用程序开发者部署的的服务。但从长远来看,标准的数据协议可以更广泛地解决该问题。 + +#### 分析系统:从跟踪数据中提取有见解的服务 + +最后不得不提的是,现在有足够多的跟踪监视解决方案。可以在[此处][15]找到已知与 OpenTracing 兼容的监控系统列表,但除此之外仍有更多的选择。我更鼓励你研究你的解决方案,同时希望你在比较解决方案时发现本文提供的框架能派上用场。除了根据监控系统的操作特性对其进行评级外(更不用提你是否喜欢 UI 和其功能),确保你考虑到了上述三个重要方面、它们对你的相对重要性以及你感兴趣的跟踪系统如何为它们提供解决方案。 + +### 结论 + +最后,每个部分的重要性在很大程度上取决于你是谁以及正在建立什么样的系统。举个例子,开源库的作者对 OpenTracing API 非常感兴趣,而服务开发者对 trace-context 规范更感兴趣。当有人说一部分比另一部分重要时,他们的意思通常是“一部分对我来说比另一部分重要”。 + +然而,事实是:分布式跟踪已经成为监控现代系统所必不可少的事物。在为这些系统进行构建模块时,“尽可能解耦”的老方法仍然适用。在构建像分布式监控系统一样的跨系统的系统时,干净地解耦组件是维持灵活性和前向兼容性地最佳方式。 + +感谢你的阅读!现在当你准备好在你自己的应用程序中实现跟踪服务时,你已有一份指南来了解他们正在谈论哪部分部分以及它们之间如何相互协作。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/distributed-tracing + +作者:[Ted Young][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[chenmu-kk](https://github.com/chenmu-kk) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/tedsuo +[1]:https://research.google.com/pubs/pub36356.html +[2]:http://opentracing.io/ +[3]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/tracing1_0.png?itok=dvDTX0JJ (Tracing) +[4]:https://github.com/opentracing/specification/blob/master/specification.md +[5]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/tracing2_0.png?itok=yokjNLZk (Tracing) +[6]:https://github.com/opentracing-contrib/ +[7]:https://gitter.im/opentracing/public +[8]:https://www.w3.org/community/trace-context/ +[9]:https://w3c.github.io/distributed-tracing/report-trace-context.html +[10]:http://lists.w3.org/Archives/Public/public-trace-context/ +[11]:https://gitter.im/TraceContext/Lobby +[12]:https://github.com/opentracing/specification/blob/master/semantic_conventions.md +[13]:https://github.com/opentracing/opentracing-cpp +[14]:https://github.com/opentracing-contrib/java-tracerresolver +[15]:http://opentracing.io/documentation/pages/supported-tracers +[16]:https://events.linuxfoundation.org/kubecon-eu-2018/ +[17]:https://events.linuxfoundation.org/events/kubecon-cloudnativecon-north-america-2018/ diff --git a/published/202002/20180511 MidnightBSD Could Be Your Gateway to FreeBSD.md b/published/202002/20180511 MidnightBSD Could Be Your Gateway to FreeBSD.md new file mode 100644 index 0000000000..48ebc210e1 --- /dev/null +++ b/published/202002/20180511 MidnightBSD Could Be Your Gateway to FreeBSD.md @@ -0,0 +1,159 @@ +MidnightBSD:或许是你通往 FreeBSD 的大门 +====== + +![](https://www.linux.com/wp-content/uploads/2019/08/midnight_4_0.jpg) + +[FreeBSD][1] 是一个开源操作系统,衍生自著名的 [伯克利软件套件][2]Berkeley Software Distribution(BSD)。FreeBSD 的第一个版本发布于 1993 年,并且仍然在继续发展。2007 年左右,Lucas Holt 想要利用 OpenStep(现在是 Cocoa)的 Objective-C 框架、widget 工具包和应用程序开发工具的 [GnuStep][3] 实现,来创建一个 FreeBSD 的分支。为此,他开始开发 MidnightBSD 桌面发行版。 + +MidnightBSD(以 Lucas 的猫 Midnight 命名)仍然在积极地(尽管缓慢)开发。从 2017 年 8 月开始,可以获得最新的稳定发布版本(0.8.6)(LCTT 译注:截止至本译文发布时,当前是 2019/10/31 发布的 1.2 版)。尽管 BSD 发行版不是你所说的用户友好型发行版,但上手安装是熟悉如何处理 文本(ncurses)安装过程以及通过命令行完成安装的好方法。 + +这样,你最终会得到一个非常可靠的 FreeBSD 分支的桌面发行版。这需要花费一点精力,但是如果你是一名正在寻找扩展你的技能的 Linux 用户……这是一个很好的起点。 + +我将带你走过安装 MidnightBSD 的流程,如何添加一个图形桌面环境,然后如何安装应用程序。 + +### 安装 + +正如我所提到的,这是一个文本(ncurses)安装过程,因此在这里找不到可以用鼠标点击的地方。相反,你将使用你键盘的 `Tab` 键和箭头键。在你下载[最新的发布版本][4]后,将它刻录到一个 CD/DVD 或 USB 驱动器,并启动你的机器(或者在 [VirtualBox][5] 中创建一个虚拟机)。安装程序将打开并给你三个选项(图 1)。使用你的键盘的箭头键选择 “Install”,并敲击回车键。 + +![MidnightBSD installer][6] + +*图 1: 启动 MidnightBSD 安装程序。* + +在这里要经历相当多的屏幕。其中很多屏幕是一目了然的: + +1. 设置非默认键盘映射(是/否) +2. 设置主机名称 +3. 添加可选系统组件(文档、游戏、32 位兼容性、系统源码代码) +4. 对硬盘分区 +5. 管理员密码 +6. 配置网络接口 +7. 选择地区(时区) +8. 启用服务(例如 ssh) +9. 添加用户(图 2) + +![Adding a user][7] + +*图 2: 向系统添加一个用户。* + +在你向系统添加用户后,你将被进入到一个窗口中(图 3),在这里,你可以处理任何你可能忘记配置或你想重新配置的东西。如果你不需要作出任何更改,选择 “Exit”,然后你的配置就会被应用。 + +![Applying your configurations][8] + +*图 3: 应用你的配置。* + +在接下来的窗口中,当出现提示时,选择 “No”,接下来系统将重启。在 MidnightBSD 重启后,你已经为下一阶段的安装做好了准备。 + +### 后安装阶段 + +当你最新安装的 MidnightBSD 启动时,你将发现你自己处于命令提示符当中。此刻,还没有图形界面。要安装应用程序,MidnightBSD 依赖于 `mport` 工具。比如说你想安装 Xfce 桌面环境。为此,登录到 MidnightBSD 中,并发出下面的命令: + +``` +sudo mport index +sudo mport install xorg +``` + +你现在已经安装好 Xorg 窗口服务器了,它允许你安装桌面环境。使用命令来安装 Xfce : + +``` +sudo mport install xfce +``` + +现在 Xfce 已经安装好。不过,我们必须让它同命令 `startx` 一起启用。为此,让我们先安装 nano 编辑器。发出命令: + +``` +sudo mport install nano +``` + +随着 nano 安装好,发出命令: + +``` +nano ~/.xinitrc +``` + +这个文件仅包含一行内容: + +``` +exec startxfce4 +``` + +保存并关闭这个文件。如果你现在发出命令 `startx`, Xfce 桌面环境将会启动。你应该会感到有点熟悉了吧(图 4)。 + +![ Xfce][9] + +*图 4: Xfce 桌面界面已准备好服务。* + +因为你不会总是想必须发出命令 `startx`,你希望启用登录守护进程。然而,它却没有安装。要安装这个子系统,发出命令: + +``` +sudo mport install mlogind +``` + +当完成安装后,通过在 `/etc/rc.conf` 文件中添加一个项目来在启动时启用 mlogind。在 `rc.conf` 文件的底部,添加以下内容: + +``` +mlogind_enable=”YES” +``` + +保存并关闭该文件。现在,当你启动(或重启)机器时,你应该会看到图形登录屏幕。在写这篇文章的时候,在登录后我最后得到一个空白屏幕和讨厌的 X 光标。不幸的是,目前似乎并没有这个问题的解决方法。所以,要访问你的桌面环境,你必须使用 `startx` 命令。 + +### 安装应用 + +默认情况下,你找不到很多能可用的应用程序。如果你尝试使用 `mport` 安装应用程序,你很快就会感到沮丧,因为只能找到很少的应用程序。为解决这个问题,我们需要使用 `svnlite` 命令来查看检出的可用 mport 软件列表。回到终端窗口,并发出命令: + +``` +svnlite co http://svn.midnightbsd.org/svn/mports/trunk mports +``` + +在你完成这些后,你应该看到一个命名为 `~/mports` 的新目录。使用命令 `cd ~/.mports` 更改到这个目录。发出 `ls` 命令,然后你应该看到许多的类别(图 5)。 + +![applications][10] + +*图 5: mport 现在可用的应用程序类别。* + +你想安装 Firefox 吗?如果你查看 `www` 目录,你将看到一个 `linux-firefox` 列表。发出命令: + +``` +sudo mport install linux-firefox +``` + +现在你应该会在 Xfce 桌面菜单中看到一个 Firefox 项。翻找所有的类别,并使用 `mport` 命令来安装你需要的所有软件。 + +### 一个悲哀的警告 + +一个悲哀的小警告是,`mport` (通过 `svnlite`)仅能找到的一个办公套件的版本是 OpenOffice 3 。那是非常过时的。尽管在 `~/mports/editors` 目录中能找到 Abiword ,但是它看起来不能安装。甚至在安装 OpenOffice 3 后,它会输出一个执行格式错误。换句话说,你不能使用 MidnightBSD 在办公生产效率方面做很多的事情。但是,嘿嘿,如果你周围正好有一个旧的 Palm Pilot,你可以安装 pilot-link。换句话说,可用的软件不足以构成一个极其有用的桌面发行版……至少对普通用户不是。但是,如果你想在 MidnightBSD 上开发,你将找到很多可用的工具可以安装(查看 `~/mports/devel` 目录)。你甚至可以使用命令安装 Drupal : + +``` +sudo mport install drupal7 +``` + +当然,在此之后,你将需要创建一个数据库(MySQL 已经安装)、安装 Apache(`sudo mport install apache24`),并配置必要的 Apache 配置。 + +显然地,已安装的和可以安装的是一个应用程序、系统和服务的大杂烩。但是随着足够多的工作,你最终可以得到一个能够服务于特殊目的的发行版。 + +### 享受 \*BSD 优良 + +这就是如何使 MidnightBSD 启动,并使其运行某种有用的桌面发行版的方法。它不像很多其它的 Linux 发行版一样快速简便,但是如果你想要一个促使你思考的发行版,这可能正是你正在寻找的。尽管大多数竞争对手都准备了很多可以安装的应用软件,但 MidnightBSD 无疑是一个 Linux 爱好者或管理员应该尝试的有趣挑战。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2018/5/midnightbsd-could-be-your-gateway-freebsd + +作者:[Jack Wallen][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/jlwallen +[1]:https://www.freebsd.org/ +[2]:https://en.wikipedia.org/wiki/Berkeley_Software_Distribution +[3]:https://en.wikipedia.org/wiki/GNUstep +[4]:http://www.midnightbsd.org/download/ +[5]:https://www.virtualbox.org/ +[6]:https://lcom.static.linuxfound.org/sites/lcom/files/midnight_1.jpg (MidnightBSD installer) +[7]:https://lcom.static.linuxfound.org/sites/lcom/files/midnight_2.jpg (Adding a user) +[8]:https://lcom.static.linuxfound.org/sites/lcom/files/mightnight_3.jpg (Applying your configurations) +[9]:https://lcom.static.linuxfound.org/sites/lcom/files/midnight_4.jpg (Xfce) +[10]:https://lcom.static.linuxfound.org/sites/lcom/files/midnight_5.jpg (applications) +[11]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/published/202002/20190114 Some Advice for How to Make Emacs Tetris Harder.md b/published/202002/20190114 Some Advice for How to Make Emacs Tetris Harder.md new file mode 100644 index 0000000000..7e06e1b241 --- /dev/null +++ b/published/202002/20190114 Some Advice for How to Make Emacs Tetris Harder.md @@ -0,0 +1,150 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11938-1.html) +[#]: subject: (Some Advice for How to Make Emacs Tetris Harder) +[#]: via: (https://nickdrozd.github.io/2019/01/14/tetris.html) +[#]: author: (nickdrozd https://nickdrozd.github.io) + +如何让 Emacs 俄罗斯方块变得更难 +====== + +你知道吗,Emacs 捆绑了一个俄罗斯方块的实现?只需要输入 `M-x tetris` 就行了。 + +![](https://nickdrozd.github.io/assets/2019-01-14-tetris/tetris-normal.png) + +在对文本编辑器的讨论中,Emacs 鼓吹者经常提到这一点。“没错,但是你那个编辑器能运行俄罗斯方块吗?”我很好奇,这会让大家相信 Emacs 更优秀吗?比如,为什么有人会关心他们是否可以在文本编辑器中玩游戏呢?“没错,但是你那台吸尘器能播放 mp3 吗?” + +有人说,俄罗斯方块总是很有趣的。像 Emacs 中的所有东西一样,它的源代码是开放的,易于检查和修改,因此 **我们可以使它变得更加有趣**。所谓更加有趣,我的意思是更难。 + +让游戏变得更难的一个最简单的方法就是“隐藏下一个块预览”。你无法在知道下一个块会填满空间的情况下有意地将 S/Z 块放在一个危险的位置——你必须碰碰运气,希望出现最好的情况。下面是没有预览的情况(如你所见,没有预览,我做出的某些选择带来了“可怕的后果”): + +![](https://nickdrozd.github.io/assets/2019-01-14-tetris/tetris-no-preview.png) + +预览框由一个名为 `tetris-draw-next-shape` [^1] 的函数设置: + +``` +(defun tetris-draw-next-shape () + (dotimes (x 4) + (dotimes (y 4) + (gamegrid-set-cell (+ tetris-next-x x) + (+ tetris-next-y y) + tetris-blank))) + (dotimes (i 4) + (let ((tetris-shape tetris-next-shape) + (tetris-rot 0)) + (gamegrid-set-cell (+ tetris-next-x + (aref (tetris-get-shape-cell i) 0)) + (+ tetris-next-y + (aref (tetris-get-shape-cell i) 1)) + tetris-shape)))) +``` + +首先,我们引入一个标志,决定是否允许显示下一个预览块 [^2]: + +``` +(defvar tetris-preview-next-shape nil + "When non-nil, show the next block the preview box.") +``` + +现在的问题是,我们如何才能让 `tetris-draw-next-shape` 遵从这个标志?最明显的方法是重新定义它: + +``` +(defun tetris-draw-next-shape () + (when tetris-preview-next-shape + ;; existing tetris-draw-next-shape logic + )) +``` + +但这不是理想的解决方案。同一个函数有两个定义,这很容易引起混淆,如果上游版本发生变化,我们必须维护修改后的定义。 + +一个更好的方法是使用 **advice**。Emacs 的 advice 类似于 **Python 装饰器**,但是更加灵活,因为 advice 可以从任何地方添加到函数中。这意味着我们可以修改函数而不影响原始的源文件。 + +有很多不同的方法使用 Emacs advice([查看手册][4]),但是这里我们只使用 `advice-add` 函数和 `:around` 标志。advice 函数将原始函数作为参数,原始函数可能执行也可能不执行。我们这里,我们让原始函数只有在预览标志是非空的情况下才能执行: + +``` +(defun tetris-maybe-draw-next-shape (tetris-draw-next-shape) + (when tetris-preview-next-shape + (funcall tetris-draw-next-shape))) + +(advice-add 'tetris-draw-next-shape :around #'tetris-maybe-draw-next-shape) +``` + +这段代码将修改 `tetris-draw-next-shape` 的行为,而且它可以存储在配置文件中,与实际的俄罗斯方块代码分离。 + +去掉预览框是一个简单的改变。一个更激烈的变化是,**让块随机停止在空中**: + +![](https://nickdrozd.github.io/assets/2019-01-14-tetris/tetris-air.png) + +本图中,红色的 I 和绿色的 T 部分没有掉下来,它们被固定下来了。这会让游戏变得 **极其困难**,但却很容易实现。 + +和前面一样,我们首先定义一个标志: + +``` +(defvar tetris-stop-midair t + "If non-nil, pieces will sometimes stop in the air.") +``` + +目前,**Emacs 俄罗斯方块的工作方式** 类似这样子:活动部件有 x 和 y 坐标。在每个时钟滴答声中,y 坐标递增(块向下移动一行),然后检查是否有与现存的块重叠。如果检测到重叠,则将该块回退(其 y 坐标递减)并设置该活动块到位。为了让一个块在半空中停下来,我们所要做的就是破解检测函数 `tetris-test-shape`。 + +**这个函数内部做什么并不重要** —— 重要的是它是一个返回布尔值的无参数函数。我们需要它在正常情况下返回布尔值 true(否则我们将出现奇怪的重叠情况),但在其他时候也需要它返回 true。我相信有很多方法可以做到这一点,以下是我的方法的: + +``` +(defun tetris-test-shape-random (tetris-test-shape) + (or (and + tetris-stop-midair + ;; Don't stop on the first shape. + (< 1 tetris-n-shapes ) + ;; Stop every INTERVAL pieces. + (let ((interval 7)) + (zerop (mod tetris-n-shapes interval))) + ;; Don't stop too early (it makes the game unplayable). + (let ((upper-limit 8)) + (< upper-limit tetris-pos-y)) + ;; Don't stop at the same place every time. + (zerop (mod (random 7) 10))) + (funcall tetris-test-shape))) + +(advice-add 'tetris-test-shape :around #'tetris-test-shape-random) +``` + +这里的硬编码参数使游戏变得更困难,但仍然可玩。当时我在飞机上喝醉了,所以它们可能需要进一步调整。 + +顺便说一下,根据我的 `tetris-scores` 文件,我的 **最高分** 是: + +``` +01389 Wed Dec 5 15:32:19 2018 +``` + +该文件中列出的分数默认最多为五位数,因此这个分数看起来不是很好。 + +### 给读者的练习 + +1. 使用 advice 修改 Emacs 俄罗斯方块,使得每当方块下移动时就闪烁显示讯息 “OH SHIT”。消息的大小与块堆的高度成比例(当没有块时,消息应该很小的或不存在的,当最高块接近天花板时,消息应该很大)。 +2. 在这里给出的 `tetris-test-shape-random` 版本中,每隔七格就有一个半空中停止。一个玩家有可能能计算出时间间隔,并利用它来获得优势。修改它,使间隔随机在一些合理的范围内(例如,每 5 到 10 格)。 +3. 另一个对使用 Tetris 使用 advise 的场景,你可以试试 [autotetris-mode][1]。 +4. 想出一个有趣的方法来打乱块的旋转机制,然后使用 advice 来实现它。 + +[^1]: Emacs 只有一个巨大的全局命名空间,因此函数和变量名一般以包名做前缀以避免冲突。 +[^2]: 很多人会说你不应该使用已有的命名空间前缀而且应该将自己定义的所有东西都放在一个预留的命名空间中,比如像这样 `my/tetris-preview-next-shape`,然而这样很难看而且没什么意义,因此我不会这么干。 + +-------------------------------------------------------------------------------- + +via: https://nickdrozd.github.io/2019/01/14/tetris.html + +作者:[nickdrozd][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://nickdrozd.github.io +[b]: https://github.com/lujun9972 +[1]: https://nullprogram.com/blog/2014/10/19/ +[2]: https://nickdrozd.github.io/2019/01/14/tetris.html#fn.1 +[3]: https://nickdrozd.github.io/2019/01/14/tetris.html#fn.2 +[4]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Functions.html +[5]: https://nickdrozd.github.io/2019/01/14/tetris.html#fnr.1 +[6]: https://nickdrozd.github.io/2019/01/14/tetris.html#fnr.2 diff --git a/sources/tech/20190116 Zipping files on Linux- the many variations and how to use them.md b/published/202002/20190116 Zipping files on Linux- the many variations and how to use them.md similarity index 61% rename from sources/tech/20190116 Zipping files on Linux- the many variations and how to use them.md rename to published/202002/20190116 Zipping files on Linux- the many variations and how to use them.md index fb98f78b06..fbd32f20ca 100644 --- a/sources/tech/20190116 Zipping files on Linux- the many variations and how to use them.md +++ b/published/202002/20190116 Zipping files on Linux- the many variations and how to use them.md @@ -1,21 +1,24 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11913-1.html) [#]: subject: (Zipping files on Linux: the many variations and how to use them) [#]: via: (https://www.networkworld.com/article/3333640/linux/zipping-files-on-linux-the-many-variations-and-how-to-use-them.html) [#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) -Zipping files on Linux: the many variations and how to use them +在 Linux 上压缩文件:zip 命令的各种变体及用法 ====== -![](https://images.idgesg.net/images/article/2019/01/zipper-100785364-large.jpg) -Some of us have been zipping files on Unix and Linux systems for many decades — to save some disk space and package files together for archiving. Even so, there are some interesting variations on zipping that not all of us have tried. So, in this post, we’re going to look at standard zipping and unzipping as well as some other interesting zipping options. +> 除了压缩和解压缩文件外,你还可以使用 zip 命令执行许多有趣的操作。这是一些其他的 zip 选项以及它们如何提供帮助。 -### The basic zip command +![](https://img.linux.net.cn/data/attachment/album/202002/21/120507ox11ak23f9x2hxaq.jpg) -First, let’s look at the basic **zip** command. It uses what is essentially the same compression algorithm as **gzip** , but there are a couple important differences. For one thing, the gzip command is used only for compressing a single file where zip can both compress files and join them together into an archive. For another, the gzip command zips “in place”. In other words, it leaves a compressed file — not the original file alongside the compressed copy. Here's an example of gzip at work: +为了节省一些磁盘空间并将文件打包在一起进行归档,我们中的一些人已经在 Unix 和 Linux 系统上压缩文件数十年了。即使这样,并不是所有人都尝试过一些有趣的压缩工具的变体。因此,在本文中,我们将介绍标准的压缩和解压缩以及其他一些有趣的压缩选项。 + +### 基本的 zip 命令 + +首先,让我们看一下基本的 `zip` 命令。它使用了与 `gzip` 基本上相同的压缩算法,但是有一些重要的区别。一方面,`gzip` 命令仅用于压缩单个文件,而 `zip` 既可以压缩文件,也可以将多个文件结合在一起成为归档文件。另外,`gzip` 命令是“就地”压缩。换句话说,它会只留下一个压缩文件,而原始文件则没有了。 这是工作中的 `gzip` 示例: ``` $ gzip onefile @@ -23,7 +26,7 @@ $ ls -l -rw-rw-r-- 1 shs shs 10514 Jan 15 13:13 onefile.gz ``` -And here's zip. Notice how this command requires that a name be provided for the zipped archive where gzip simply uses the original file name and adds the .gz extension. +而下面是 `zip`。请注意,此命令要求为压缩存档提供名称,其中 `gzip`(执行压缩操作后)仅使用原始文件名并添加 `.gz` 扩展名。 ``` $ zip twofiles.zip file* @@ -35,9 +38,9 @@ $ ls -l -rw-rw-r-- 1 shs shs 21289 Jan 15 13:35 twofiles.zip ``` -Notice also that the original files are still sitting there. +请注意,原始文件仍位于原处。 -The amount of disk space that is saved (i.e., the degree of compression obtained) will depend on the content of each file. The variation in the example below is considerable. +所节省的磁盘空间量(即获得的压缩程度)将取决于每个文件的内容。以下示例中的变化很大。 ``` $ zip mybin.zip ~/bin/* @@ -56,9 +59,9 @@ $ zip mybin.zip ~/bin/* adding: bin/tt (deflated 6%) ``` -### The unzip command +### unzip 命令 -The **unzip** command will recover the contents from a zip file and, as you'd likely suspect, leave the zip file intact, whereas a similar gunzip command would leave only the uncompressed file. +`unzip` 命令将从一个 zip 文件中恢复内容,并且,如你所料,原来的 zip 文件还保留在那里,而类似的 `gunzip` 命令将仅保留未压缩的文件。 ``` $ unzip twofiles.zip @@ -71,9 +74,9 @@ $ ls -l -rw-rw-r-- 1 shs shs 21289 Jan 15 13:35 twofiles.zip ``` -### The zipcloak command +### zipcloak 命令 -The **zipcloak** command encrypts a zip file, prompting you to enter a password twice (to help ensure you don't "fat finger" it) and leaves the file in place. You can expect the file size to vary a little from the original. +`zipcloak` 命令对一个 zip 文件进行加密,提示你输入两次密码(以确保你不会“胖手指”),然后将该文件原位存储。你可以想到,文件大小与原始文件会有所不同。 ``` $ zipcloak twofiles.zip @@ -89,11 +92,11 @@ total 204 unencrypted version ``` -Keep in mind that the original files are still sitting there unencrypted. +请记住,压缩包之外的原始文件仍处于未加密状态。 -### The zipdetails command +### zipdetails 命令 -The **zipdetails** command is going to show you details — a _lot_ of details about a zipped file, likely a lot more than you care to absorb. Even though we're looking at an encrypted file, zipdetails does display the file names along with file modification dates, user and group information, file length data, etc. Keep in mind that this is all "metadata." We don't see the contents of the files. +`zipdetails` 命令将向你显示详细信息:有关压缩文件的详细信息,可能比你想象的要多得多。即使我们正在查看一个加密的文件,`zipdetails` 也会显示文件名以及文件修改日期、用户和组信息、文件长度数据等。请记住,这都是“元数据”。我们看不到文件的内容。 ``` $ zipdetails twofiles.zip @@ -233,9 +236,9 @@ $ zipdetails twofiles.zip Done ``` -### The zipgrep command +### zipgrep命令 -The **zipgrep** command is going to use a grep-type feature to locate particular content in your zipped files. If the file is encrypted, you will need to enter the password provided for the encryption for each file you want to examine. If you only want to check the contents of a single file from the archive, add its name to the end of the zipgrep command as shown below. +`zipgrep` 命令将使用 `grep` 类的功能来找到压缩文件中的特定内容。如果文件已加密,则需要为要检查的每个文件输入为加密所提供的密码。如果只想检查归档文件中单个文件的内容,请将其名称添加到 `zipgrep` 命令的末尾,如下所示。 ``` $ zipgrep hazard twofiles.zip file1 @@ -243,9 +246,9 @@ $ zipgrep hazard twofiles.zip file1 Certain pesticides should be banned since they are hazardous to the environment. ``` -### The zipinfo command +### zipinfo 命令 -The **zipinfo** command provides information on the contents of a zipped file whether encrypted or not. This includes the file names, sizes, dates and permissions. +`zipinfo` 命令提供有关压缩文件内容的信息,无论是否加密。这包括文件名、大小、日期和权限。 ``` $ zipinfo twofiles.zip @@ -256,9 +259,9 @@ Zip file size: 21313 bytes, number of entries: 2 2 files, 116954 bytes uncompressed, 20991 bytes compressed: 82.1% ``` -### The zipnote command +### zipnote 命令 -The **zipnote** command can be used to extract comments from zip archives or add them. To display comments, just preface the name of the archive with the command. If no comments have been added previously, you will see something like this: +`zipnote` 命令可用于从 zip 归档中提取注释或添加注释。要显示注释,只需在命令前面加上归档名称即可。如果之前未添加任何注释,你将看到类似以下内容: ``` $ zipnote twofiles.zip @@ -269,21 +272,21 @@ $ zipnote twofiles.zip @ (zip file comment below this line) ``` -If you want to add comments, write the output from the zipnote command to a file: +如果要添加注释,请先将 `zipnote` 命令的输出写入到文件: ``` $ zipnote twofiles.zip > comments ``` -Next, edit the file you've just created, inserting your comments above the **(comment above this line)** lines. Then add the comments using a zipnote command like this one: +接下来,编辑你刚刚创建的文件,将注释插入到 `(comment above this line)` 行上方。然后使用像这样的 `zipnote` 命令添加注释: ``` $ zipnote -w twofiles.zip < comments ``` -### The zipsplit command +### zipsplit 命令 -The **zipsplit** command can be used to break a zip archive into multiple zip archives when the original file is too large — maybe because you're trying to add one of the files to a small thumb drive. The easiest way to do this seems to be to specify the max size for each of the zipped file portions. This size must be large enough to accomodate the largest included file. +当归档文件太大时,可以使用 `zipsplit` 命令将一个 zip 归档文件分解为多个 zip 归档文件,这样你就可以将其中某一个文件放到小型 U 盘中。最简单的方法似乎是为每个部分的压缩文件指定最大大小,此大小必须足够大以容纳最大的所包含的文件。 ``` $ zipsplit -n 12000 twofiles.zip @@ -296,15 +299,11 @@ $ ls twofile*.zip -rw-rw-r-- 1 shs shs 21377 Jan 15 14:27 twofiles.zip ``` -Notice how the extracted files are sequentially named "twofile1" and "twofile2". +请注意,提取的文件是如何依次命名为 `twofile1` 和 `twofile2` 的。 -### Wrap-up +### 总结 -The **zip** command, along with some of its zipping compatriots, provide a lot of control over how you generate and work with compressed file archives. - -**[ Also see:[Invaluable tips and tricks for troubleshooting Linux][1] ]** - -Join the Network World communities on [Facebook][2] and [LinkedIn][3] to comment on topics that are top of mind. +`zip` 命令及其一些压缩工具变体,对如何生成和使用压缩文件归档提供了很多控制。 -------------------------------------------------------------------------------- @@ -312,8 +311,8 @@ via: https://www.networkworld.com/article/3333640/linux/zipping-files-on-linux-t 作者:[Sandra Henry-Stocker][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/202002/20190322 12 open source tools for natural language processing.md b/published/202002/20190322 12 open source tools for natural language processing.md new file mode 100644 index 0000000000..ee4bf2e0ec --- /dev/null +++ b/published/202002/20190322 12 open source tools for natural language processing.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: (zhangxiangping) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11927-1.html) +[#]: subject: (12 open source tools for natural language processing) +[#]: via: (https://opensource.com/article/19/3/natural-language-processing-tools) +[#]: author: (Dan Barker https://opensource.com/users/barkerd427) + +12 种自然语言处理的开源工具 +====== + +> 让我们看看可以用在你自己的 NLP 应用中的十几个工具吧。 + +![](https://img.linux.net.cn/data/attachment/album/202002/25/103230j77i7zx8uyymj7y3.jpg) + +在过去的几年里,自然语言处理(NLP)推动了聊天机器人、语音助手、文本预测等这些渗透到我们的日常生活中的语音或文本应用程技术的发展。目前有着各种各样开源的 NLP 工具,所以我决定调查一下当前开源的 NLP 工具来帮助你制定开发下一个基于语音或文本的应用程序的计划。 + +尽管我并不熟悉所有工具,但我将从我所熟悉的编程语言出发来介绍这些工具(对于我不熟悉的语言,我无法找到大量的工具)。也就是说,出于各种原因,我排除了三种我熟悉的语言之外的工具。 + +R 语言可能是没有被包含在内的最重要的语言,因为我发现的大多数库都有一年多没有更新了。这并不一定意味着它们没有得到很好的维护,但我认为它们应该得到更多的更新,以便和同一领域的其他工具竞争。我还选择了最有可能用在生产场景中的语言和工具(而不是在学术界和研究中使用),而我主要是使用 R 作为研究和发现工具。 + +我也惊讶地发现 Scala 的很多库都没有更新了。我上次使用 Scala 已经过去了两年了,当时它非常流行。但是大多数库从那个时候就再没有更新过,或者只有少数一些有更新。 + +最后,我排除了 C++。 这主要是因为我上次使用 C++ 编写程序已经有很多年了,而我所工作的组织还没有将 C++ 用于 NLP 或任何数据科学方面的工作。 + +### Python 工具 + +#### 自然语言工具包(NLTK) + +毋庸置疑,[自然语言工具包(NLTK)][2]是我调研过的所有工具中功能最完善的一个。它几乎实现了自然语言处理中多数功能组件,比如分类、令牌化、词干化、标注、分词和语义推理。每一个都有多种不同的实现方式,所以你可以选择具体的算法和方式。同时,它也支持不同的语言。然而,它以字符串的形式表示所有的数据,对于一些简单的数据结构来说可能很方便,但是如果要使用一些高级的功能来说就可能有点困难。它的使用文档有点复杂,但也有很多其他人编写的使用文档,比如[这本很棒的书][3]。和其他的工具比起来,这个工具库的运行速度有点慢。但总的来说,这个工具包非常不错,可以用于需要具体算法组合的实验、探索和实际应用当中。 + +#### SpaCy + +[SpaCy][4] 可能是 NLTK 的主要竞争者。在大多数情况下都比 NLTK 的速度更快,但是 SpaCy 的每个自然语言处理的功能组件只有一个实现。SpaCy 把所有的东西都表示为一个对象而不是字符串,从而简化了应用构建接口。这也方便它与多种框架和数据科学工具的集成,使得你更容易理解你的文本数据。然而,SpaCy 不像 NLTK 那样支持多种语言。它确实接口简单,具有简化的选项集和完备的文档,以及用于语言处理和分析各种组件的多种神经网络模型。总的来说,对于需要在生产中表现出色且不需要特定算法的新应用程序,这是一个很不错的工具。 + +#### TextBlob + +[TextBlob][5] 是 NLTK 的一个扩展库。你可以通过 TextBlob 用一种更简单的方式来使用 NLTK 的功能,TextBlob 也包括了 Pattern 库中的功能。如果你刚刚开始学习,这将会是一个不错的工具,可以用于对性能要求不太高的生产环境的应用。总体来说,TextBlob 适用于任何场景,但是对小型项目尤佳。 + +#### Textacy + +这个工具是我用过的名字最好听的。先重读“ex”再带出“cy”,多读“[Textacy][6]”几次试试。它不仅仅是名字读起来好,同时它本身也是一个很不错的工具。它使用 SpaCy 作为它自然语言处理核心功能,但它在处理过程的前后做了很多工作。如果你想要使用 SpaCy,那么最好使用 Textacy,从而不用去编写额外的附加代码就可以处理不同种类的数据。 + +#### PyTorch-NLP + +[PyTorch-NLP][7] 才出现短短的一年,但它已经有一个庞大的社区了。它适用于快速原型开发。当出现了最新的研究,或大公司或者研究人员推出了完成新奇的处理任务的其他工具时,比如图像转换,它就会被更新。总体来说,PyTorch 的目标用户是研究人员,但它也能用于原型开发,或使用最先进算法的初始生产载荷中。基于此基础上的创建的库也是值得研究的。 + +### Node.js 工具 + +#### Retext + +[Retext][8] 是 [Unified 集合][9]的一部分。Unified 是一个接口,能够集成不同的工具和插件以便它们能够高效的工作。Retext 是 Unified 工具中使用的三种语法之一,另外的两个分别是用于 Markdown 的 Remark 和用于 HTML 的 Rehype。这是一个非常有趣的想法,我很高兴看到这个社区的发展。Retext 没有涉及很多的底层技术,更多的是使用插件去完成你在 NLP 任务中想要做的事情。拼写检查、字形修复、情绪检测和增强可读性都可以用简单的插件来完成。总体来说,如果你不想了解底层处理技术又想完成你的任务的话,这个工具和社区是一个不错的选择。 + +#### Compromise + +[Compromise][10] 显然不是最复杂的工具,如果你正在找拥有最先进的算法和最完备的系统的话,它可能不适合你。然而,如果你想要一个性能好、功能广泛、还能在客户端运行的工具的话,Compromise 值得一试。总体来说,它的名字(“折中”)是准确的,因为作者更关注更具体功能的小软件包,而在功能性和准确性上有所折中,这些小软件包得益于用户对使用环境的理解。 + +#### Natural + +[Natural][11] 包含了常规自然语言处理库所具有的大多数功能。它主要是处理英文文本,但也包括一些其它语言,它的社区也欢迎支持其它的语言。它能够进行令牌化、词干化、分类、语音处理、词频-逆文档频率计算(TF-IDF)、WordNet、字符相似度计算和一些变换。它和 NLTK 有的一比,因为它想要把所有东西都包含在一个包里头,但它更易于使用,而且不一定专注于研究。总的来说,这是一个非常完整的库,目前仍在活跃开发中,但可能需要对底层实现有更多的了解才能完全发挥效力。 + +#### Nlp.js + +[Nlp.js][12] 建立在其他几个 NLP 库之上,包括 Franc 和 Brain.js。它为许多 NLP 组件提供了一个很好的接口,比如分类、情感分析、词干化、命名实体识别和自然语言生成。它也支持一些其它语言,在你处理英语之外的语言时能提供一些帮助。总之,它是一个不错的通用工具,并且提供了调用其他工具的简化接口。在你需要更强大或更灵活的工具之前,这个工具可能会在你的应用程序中用上很长一段时间。 + +### Java 工具 + +#### OpenNLP + +[OpenNLP][13] 是由 Apache 基金会管理的,所以它可以很方便地集成到其他 Apache 项目中,比如 Apache Flink、Apache NiFi 和 Apache Spark。这是一个通用的 NLP 工具,包含了所有 NLP 组件中的通用功能,可以通过命令行或者以包的形式导入到应用中来使用它。它也支持很多种语言。OpenNLP 是一个很高效的工具,包含了很多特性,如果你用 Java 开发生产环境产品的话,它是个很好的选择。 + +#### Stanford CoreNLP + +[Stanford CoreNLP][14] 是一个工具集,提供了统计 NLP、深度学习 NLP 和基于规则的 NLP 功能。这个工具也有许多其他编程语言的版本,所以可以脱离 Java 来使用。它是由高水平的研究机构创建的一个高效的工具,但在生产环境中可能不是最好的。此工具采用双许可证,具有可以用于商业目的的特定许可证。总之,在研究和实验中它是一个很棒的工具,但在生产系统中可能会带来一些额外的成本。比起 Java 版本来说,读者可能对它的 Python 版本更感兴趣。同样,在 Coursera 上最好的机器学习课程之一是斯坦福教授提供的,[点此][15]访问其他不错的资源。 + +#### CogCompNLP + +[CogCompNLP][16] 由伊利诺斯大学开发的一个工具,它也有一个相似功能的 Python 版本。它可以用于处理文本,包括本地处理和远程处理,能够极大地缓解你本地设备的压力。它提供了很多处理功能,比如令牌化、词性标注、断句、命名实体标注、词型还原、依存分析和语义角色标注。它是一个很好的研究工具,你可以自己探索它的不同功能。我不确定它是否适合生产环境,但如果你使用 Java 的话,它值得一试。 + +* * * + +你最喜欢的开源 NLP 工具和库是什么?请在评论区分享文中没有提到的工具。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/3/natural-language-processing-tools + +作者:[Dan Barker][a] +选题:[lujun9972][b] +译者:[zxp](https://github.com/zhangxiangping) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/barkerd427 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/talk_chat_communication_team.png?itok=CYfZ_gE7 (Chat bubbles) +[2]: http://www.nltk.org/ +[3]: http://www.nltk.org/book_1ed/ +[4]: https://spacy.io/ +[5]: https://textblob.readthedocs.io/en/dev/ +[6]: https://readthedocs.org/projects/textacy/ +[7]: https://pytorchnlp.readthedocs.io/en/latest/ +[8]: https://www.npmjs.com/package/retext +[9]: https://unified.js.org/ +[10]: https://www.npmjs.com/package/compromise +[11]: https://www.npmjs.com/package/natural +[12]: https://www.npmjs.com/package/node-nlp +[13]: https://opennlp.apache.org/ +[14]: https://stanfordnlp.github.io/CoreNLP/ +[15]: https://opensource.com/article/19/2/learn-data-science-ai +[16]: https://github.com/CogComp/cogcomp-nlp diff --git a/published/202002/20190407 Manage multimedia files with Git.md b/published/202002/20190407 Manage multimedia files with Git.md new file mode 100644 index 0000000000..befd819d4f --- /dev/null +++ b/published/202002/20190407 Manage multimedia files with Git.md @@ -0,0 +1,236 @@ +[#]: collector: (lujun9972) +[#]: translator: (svtter) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11889-1.html) +[#]: subject: (Manage multimedia files with Git) +[#]: via: (https://opensource.com/article/19/4/manage-multimedia-files-git) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + + +通过 Git 来管理多媒体文件 +====== + +> 在我们有关 Git 鲜为人知的用法系列的最后一篇文章中,了解如何使用 Git 跟踪项目中的大型多媒体文件。 + +![](https://img.linux.net.cn/data/attachment/album/202002/13/235436mhub12qhxzmbw11p.png) + +Git 是专用于源代码版本控制的工具。因此,Git 很少被用于非纯文本的项目以及行业。然而,异步工作流的优点是十分诱人的,尤其是在一些日益增长的行业中,这种类型的行业把重要的计算和重要的艺术创作结合起来,这包括网页设计、视觉效果、视频游戏、出版、货币设计(是的,这是一个真实的行业)、教育……等等。还有许多行业属于这个类型。 + +在这个 Git 系列文章中,我们分享了六种鲜为人知的 Git 使用方法。在最后一篇文章中,我们将介绍将 Git 的优点带到管理多媒体文件的软件。 + +### Git 管理多媒体文件的问题 + +众所周知,Git 用于处理非文本文件不是很好,但是这并不妨碍我们进行尝试。下面是一个使用 Git 来复制照片文件的例子: + +``` +$ du -hs +108K . +$ cp ~/photos/dandelion.tif . +$ git add dandelion.tif +$ git commit -m 'added a photo' +[master (root-commit) fa6caa7] two photos + 1 file changed, 0 insertions(+), 0 deletions(-) + create mode 100644 dandelion.tif +$ du -hs +1.8M . +``` + +目前为止没有什么异常。增加一个 1.8MB 的照片到一个目录下,使得目录变成了 1.8 MB 的大小。所以下一步,我们尝试删除文件。 + +``` +$ git rm dandelion.tif +$ git commit -m 'deleted a photo' +$ du -hs +828K . +``` + +在这里我们可以看到有些问题:删除一个已经被提交的文件,还是会使得存储库的大小扩大到原来的 8 倍(从 108K 到 828K)。我们可以测试多次来得到一个更好的平均值,但是这个简单的演示与我的经验一致。提交非文本文件,在一开始花费空间比较少,但是一个工程活跃地时间越长,人们可能对静态内容修改的会更多,更多的零碎文件会被加和到一起。当一个 Git 存储库变的越来越大,主要的成本往往是速度。拉取和推送的时间,从最初抿一口咖啡的时间到你觉得你可能断网了。 + +静态内容导致 Git 存储库的体积不断扩大的原因是什么呢?那些通过文本的构成的文件,允许 Git 只拉取那些修改的部分。光栅图以及音乐文件对 Git 文件而言与文本不同,你可以查看一下 .png 和 .wav 文件中的二进制数据。所以,Git 只不过是获取了全部的数据,并且创建了一个新的副本,哪怕是一张图仅仅修改了一个像素。 + +### Git-portal + +在实践中,许多多媒体项目不需要或者不想追踪媒体的历史记录。相对于文本或者代码的部分,项目的媒体部分一般有一个不同的生命周期。媒体资源一般按一个方向产生:一张图片从铅笔草稿开始,以数字绘画的形式抵达它的目的地。然后,尽管文本能够回滚到早起的版本,但是艺术制品只会一直向前发展。工程中的媒体很少被绑定到一个特定的版本。例外情况通常是反映数据集的图形,通常是可以用基于文本的格式(如 SVG)完成的表、图形或图表。 + +所以,在许多同时包含文本(无论是叙事散文还是代码)和媒体的工程中,Git 是一个用于文件管理的,可接受的解决方案,只要有一个在版本控制循环之外的游乐场来给艺术家游玩就行。 + +![Graphic showing relationship between art assets and Git][2] + +一个启用这个特性的简单方法是 [Git-portal][3],这是一个通过带有 Git 钩子的 Bash 脚本,它可将静态文件从文件夹中移出 Git 的范围,并通过符号链接来取代它们。Git 提交链接文件(有时候称作别名或快捷方式),这种符号链接文件比较小,所以所有的提交都是文本文件和那些代表媒体文件的链接。因为替身文件是符号链接,所以工程还会像预期的运行,因为本地机器会处理他们,转换成“真实的”副本。当用符号链接替换出文件时,Git-portal 维护了项目的结构,因此,如果你认为 Git-portal 不适合你的项目,或者你需要构建项目的一个没有符号链接的版本(比如用于分发),则可以轻松地逆转该过程。 + +Git-portal 也允许通过 `rsync` 来远程同步静态资源,所以用户可以设置一个远程存储位置,来做为一个中心的授权源。 + +Git-portal 对于多媒体的工程是一个理想的解决方案。类似的多媒体工程包括视频游戏、桌面游戏、需要进行大型 3D 模型渲染和纹理的虚拟现实工程、[带图][4]以及 .odt 输出的书籍、协作型的[博客站点][5]、音乐项目,等等。艺术家在应用程序中以图层(在图形世界中)和曲目(在音乐世界中)的形式执行版本控制并不少见——因此,Git 不会向多媒体项目文件本身添加任何内容。Git 的功能可用于艺术项目的其他部分(例如散文和叙述、项目管理、字幕文件、致谢、营销副本、文档等),而结构化远程备份的功能则由艺术家使用。 + +#### 安装 Git-portal + +Git-portal 的 RPM 安装包位于 ,可用于下载和安装。 + +此外,用户可以从 Git-portal 的 Gitlab 主页手动安装。这仅仅是一个 Bash 脚本以及一些 Git 钩子(也是 Bash 脚本),但是需要一个快速的构建过程来让它知道安装的位置。 + +``` +$ git clone https://gitlab.com/slackermedia/git-portal.git git-portal.clone +$ cd git-portal.clone +$ ./configure +$ make +$ sudo make install +``` + +#### 使用 Git-portal + +Git-portal 与 Git 一起使用。这意味着,如同 Git 的所有大型文件扩展一样,都需要记住一些额外的步骤。但是,你仅仅需要在处理你的媒体资源的时候使用 Git-portal,所以很容易记住,除非你把大文件都当做文本文件来进行处理(对于 Git 用户很少见)。使用 Git-portal 必须做的一个安装步骤是: + +``` +$ mkdir bigproject.git +$ cd !$ +$ git init +$ git-portal init +``` + +Git-portal 的 `init` 函数在 Git 存储库中创建了一个 `_portal` 文件夹并且添加到 `.gitignore` 文件中。 + +在平日里使用 Git-portal 和 Git 协同十分平滑。一个较好的例子是基于 MIDI 的音乐项目:音乐工作站产生的项目文件是基于文本的,但是 MIDI 文件是二进制数据: + +``` +$ ls -1 +_portal +song.1.qtr +song.qtr +song-Track_1-1.mid +song-Track_1-3.mid +song-Track_2-1.mid +$ git add song*qtr +$ git-portal song-Track*mid +$ git add song-Track*mid +``` + +如果你查看一下 `_portal` 文件夹,你会发现那里有最初的 MIDI 文件。这些文件在原本的位置被替换成了指向 `_portal` 的链接文件,使得音乐工作站像预期一样运行。 + +``` +$ ls -lG +[...] _portal/ +[...] song.1.qtr +[...] song.qtr +[...] song-Track_1-1.mid -> _portal/song-Track_1-1.mid* +[...] song-Track_1-3.mid -> _portal/song-Track_1-3.mid* +[...] song-Track_2-1.mid -> _portal/song-Track_2-1.mid* +``` + +与 Git 相同,你也可以添加一个目录下的文件。 + +``` +$ cp -r ~/synth-presets/yoshimi . +$ git-portal add yoshimi +Directories cannot go through the portal. Sending files instead. +$ ls -lG _portal/yoshimi +[...] yoshimi.stat -> ../_portal/yoshimi/yoshimi.stat* +``` + +删除功能也像预期一样工作,但是当从 `_portal` 中删除一些东西时,你应该使用 `git-portal rm` 而不是 `git rm`。使用 Git-portal 可以确保文件从 `_portal` 中删除: + +``` +$ ls +_portal/ song.qtr song-Track_1-3.mid@ yoshimi/ +song.1.qtr song-Track_1-1.mid@ song-Track_2-1.mid@ +$ git-portal rm song-Track_1-3.mid +rm 'song-Track_1-3.mid' +$ ls _portal/ +song-Track_1-1.mid* song-Track_2-1.mid* yoshimi/ +``` + +如果你忘记使用 Git-portal,那么你需要手动删除 `_portal` 下的文件: + +``` +$ git-portal rm song-Track_1-1.mid +rm 'song-Track_1-1.mid' +$ ls _portal/ +song-Track_1-1.mid* song-Track_2-1.mid* yoshimi/ +$ trash _portal/song-Track_1-1.mid +``` + +Git-portal 其它的唯一功能,是列出当前所有的链接并且找到里面可能已经损坏的符号链接。有时这种情况会因为项目文件夹中的文件被移动而发生: + +``` +$ mkdir foo +$ mv yoshimi foo +$ git-portal status +bigproject.git/song-Track_2-1.mid: symbolic link to _portal/song-Track_2-1.mid +bigproject.git/foo/yoshimi/yoshimi.stat: broken symbolic link to ../_portal/yoshimi/yoshimi.stat +``` + +如果你使用 Git-portal 用于私人项目并且维护自己的备份,以上就是技术方面所有你需要知道关于 Git-portal 的事情了。如果你想要添加一个协作者或者你希望 Git-portal 来像 Git 的方式来管理备份,你可以创建一个远程位置。 + +#### 增加 Git-portal 远程位置 + +为 Git-portal 增加一个远程位置是通过 Git 已有的远程功能来实现的。Git-portal 实现了 Git 钩子(隐藏在存储库 `.git` 文件夹中的脚本),来寻找你的远程位置上是否存在以 `_portal` 开头的文件夹。如果它找到一个,它会尝试使用 `rsync` 来与远程位置同步文件。Git-portal 在用户进行 Git 推送以及 Git 合并的时候(或者在进行 Git 拉取的时候,实际上是进行一次获取和自动合并),都会执行此操作。 + +如果你仅克隆了 Git 存储库,那么你可能永远不会自己添加一个远程位置。这是一个标准的 Git 过程: + +``` +$ git remote add origin git@gitdawg.com:seth/bigproject.git +$ git remote -v +origin git@gitdawg.com:seth/bigproject.git (fetch) +origin git@gitdawg.com:seth/bigproject.git (push) +``` + +对你的主要 Git 存储库来说,`origin` 这个名字是一个流行的惯例,将其用于 Git 数据是有意义的。然而,你的 Git-portal 数据是分开存储的,所以你必须创建第二个远程位置来让 Git-portal 了解向哪里推送和从哪里拉取。取决于你的 Git 主机,你可能需要一个单独的服务器,因为空间有限的 Git 主机不太可能接受 GB 级的媒体资产。或者,可能你的服务器仅允许你访问你的 Git 存储库而不允许访问外部的存储文件夹: + +``` +$ git remote add _portal seth@example.com:/home/seth/git/bigproject_portal +$ git remote -v +origin git@gitdawg.com:seth/bigproject.git (fetch) +origin git@gitdawg.com:seth/bigproject.git (push) +_portal seth@example.com:/home/seth/git/bigproject_portal (fetch) +_portal seth@example.com:/home/seth/git/bigproject_portal (push) +``` + +你可能不想为所有用户提供服务器上的个人帐户,也不必这样做。为了提供对托管资源库大文件资产的服务器的访问权限,你可以运行一个 Git 前端,比如 [Gitolite][8] 或者你可以使用 `rrsync` (受限的 rsync)。 + +现在你可以推送你的 Git 数据到你的远程 Git 存储库,并将你的 Git-portal 数据到你的远程的门户: + +``` +$ git push origin HEAD +master destination detected +Syncing _portal content... +sending incremental file list +sent 9,305 bytes received 18 bytes 1,695.09 bytes/sec +total size is 60,358,015 speedup is 6,474.10 +Syncing _portal content to example.com:/home/seth/git/bigproject_portal +``` + +如果你已经安装了 Git-portal,并且配置了 `_portal` 的远程位置,你的 `_portal` 文件夹将会被同步,并且从服务器获取新的内容,以及在每一次推送的时候发送新的内容。尽管你不需要进行 Git 提交或者推送来和服务器同步(用户可以使用直接使用 `rsync`),但是我发现对于艺术性内容的改变,提交是有用的。这将会把艺术家及其数字资产集成到工作流的其余部分中,并提供有关项目进度和速度的有用元数据。 + +### 其他选择 + +如果 Git-portal 对你而言太过简单,还有一些用于 Git 管理大型文件的其他选择。[Git 大文件存储][9](LFS)是一个名为 git-media 的停工项目的分支,这个分支由 GitHub 维护和支持。它需要特殊的命令(例如 `git lfs track` 来保护大型文件不被 Git 追踪)并且需要用户维护一个 `.gitattributes` 文件来更新哪些存储库中的文件被 LFS 追踪。对于大文件而言,它**仅**支持 HTTP 和 HTTPS 远程主机。所以你必须配置 LFS 服务器,才能使得用户可以通过 HTTP 而不是 SSH 或 `rsync` 来进行鉴权。 + +另一个相对 LFS 更灵活的选择是 [git-annex][10]。你可以在我的文章 [管理 Git 中大二进制 blob][11] 中了解更多(忽略其中 git-media 这个已经废弃项目的章节,因为其灵活性没有被它的继任者 Git LFS 延续下来)。Git-annex 是一个灵活且优雅的解决方案。它拥有一个细腻的系统来用于添加、删除、移动存储库中的大型文件。因为它灵活且强大,有很多新的命令和规则需要进行学习,所以建议看一下它的[文档][12]。 + +然而,如果你的需求很简单,你可能更加喜欢整合已有技术来进行简单且明显任务的解决方案,则 Git-portal 可能是对于工作而言比较合适的工具。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/manage-multimedia-files-git + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[svtter](https://github.com/svtter) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/video_editing_folder_music_wave_play.png?itok=-J9rs-My (video editing dashboard) +[2]: https://opensource.com/sites/default/files/uploads/git-velocity.jpg (Graphic showing relationship between art assets and Git) +[3]: http://gitlab.com/slackermedia/git-portal.git +[4]: https://www.apress.com/gp/book/9781484241691 +[5]: http://mixedsignals.ml +[6]: mailto:git@gitdawg.com +[7]: mailto:seth@example.com +[8]: https://opensource.com/article/19/4/file-sharing-git +[9]: https://git-lfs.github.com/ +[10]: https://git-annex.branchable.com/ +[11]: https://opensource.com/life/16/8/how-manage-binary-blobs-git-part-7 +[12]: https://git-annex.branchable.com/walkthrough/ diff --git a/published/202002/20190729 How to structure a multi-file C program- Part 1.md b/published/202002/20190729 How to structure a multi-file C program- Part 1.md new file mode 100644 index 0000000000..196892cb41 --- /dev/null +++ b/published/202002/20190729 How to structure a multi-file C program- Part 1.md @@ -0,0 +1,189 @@ +[#]: collector: (lujun9972) +[#]: translator: (mengxinayan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11935-1.html) +[#]: subject: (How to structure a multi-file C program: Part 1) +[#]: via: (https://opensource.com/article/19/7/structure-multi-file-c-part-1) +[#]: author: (Erik O'Shaughnessy https://opensource.com/users/jnyjnyhttps://opensource.com/users/jnyjnyhttps://opensource.com/users/jim-salterhttps://opensource.com/users/cldxsolutions) + +如何组织构建多文件 C 语言程序(一) +====== + +> 准备好你喜欢的饮料、编辑器和编译器,放一些音乐,然后开始构建一个由多个文件组成的 C 语言程序。 + +![](https://img.linux.net.cn/data/attachment/album/202002/26/214517o5p7q45l2a8jkx4k.jpg) + +大家常说计算机编程的艺术部分是处理复杂性,部分是命名某些事物。此外,我认为“有时需要添加绘图”是在很大程度上是正确的。 + +在这篇文章里,我会编写一个小型 C 程序,命名一些东西,同时处理一些复杂性。该程序的结构大致基于我在 《[如何写一个好的 C 语言 main 函数][2]》 文中讨论的。但是,这次做一些不同的事。准备好你喜欢的饮料、编辑器和编译器,放一些音乐,让我们一起编写一个有趣的 C 语言程序。 + +### 优秀 Unix 程序哲学 + +首先,你要知道这个 C 程序是一个 [Unix][3] 命令行工具。这意味着它运行在(或者可被移植到)那些提供 Unix C 运行环境的操作系统中。当贝尔实验室发明 Unix 后,它从一开始便充满了[设计哲学][4]。用我自己的话来说就是:程序只做一件事,并做好它,并且对文件进行一些操作。虽然“只做一件事,并做好它”是有意义的,但是“对文件进行一些操作”的部分似乎有点儿不合适。 + +事实证明,Unix 中抽象的 “文件” 非常强大。一个 Unix 文件是以文件结束符(EOF)标志为结尾的字节流。仅此而已。文件中任何其它结构均由应用程序所施加而非操作系统。操作系统提供了系统调用,使得程序能够对文件执行一套标准的操作:打开、读取、写入、寻址和关闭(还有其他,但说起来那就复杂了)。对于文件的标准化访问使得不同的程序共用相同的抽象,而且可以一同工作,即使它们是不同的人用不同语言编写的程序。 + +具有共享的文件接口使得构建*可组合的*的程序成为可能。一个程序的输出可以作为另一个程序的输入。Unix 家族的操作系统默认在执行程序时提供了三个文件:标准输入(`stdin`)、标准输出(`stdout`)和标准错误(`stderr`)。其中两个文件是只写的:`stdout` 和 `stderr`。而 `stdin` 是只读的。当我们在常见的 Shell 比如 Bash 中使用文件重定向时,可以看到其效果。 + +``` +$ ls | grep foo | sed -e 's/bar/baz/g' > ack +``` + +这条指令可以被简要地描述为:`ls` 的结果被写入标准输出,它重定向到 `grep` 的标准输入,`grep` 的标准输出重定向到 `sed` 的标准输入,`sed` 的标准输出重定向到当前目录下文件名为 `ack` 的文件中。 + +我们希望我们的程序在这个灵活又出色的生态系统中运作良好,因此让我们编写一个可以读写文件的程序。 + +### 喵呜喵呜:流编码器/解码器概念 + +当我还是一个露着豁牙的孩子懵懵懂懂地学习计算机科学时,学过很多编码方案。它们中的有些用于压缩文件,有些用于打包文件,另一些毫无用处因此显得十分愚蠢。列举最后这种情况的一个例子:[哞哞编码方案][5]。 + +为了让我们的程序有个用途,我为它更新了一个 [21 世纪][6] 的概念,并且实现了一个名为“喵呜喵呜” 的编码方案的概念(毕竟网上大家都喜欢猫)。这里的基本的思路是获取文件并且使用文本 “meow” 对每个半字节(半个字节)进行编码。小写字母代表 0,大写字母代表 1。因为它会将 4 个比特替换为 32 个比特,因此会扩大文件的大小。没错,这毫无意义。但是想象一下人们看到经过这样编码后的惊讶表情。 + +``` +$ cat /home/your_sibling/.super_secret_journal_of_my_innermost_thoughts +MeOWmeOWmeowMEoW... +``` + +这非常棒。 + +### 最终的实现 + +完整的源代码可以在 [GitHub][7] 上面找到,但是我会写下我在编写程序时的思考。目的是说明如何组织构建多文件 C 语言程序。 + +既然已经确定了要编写一个编码和解码“喵呜喵呜”格式的文件的程序时,我在 Shell 中执行了以下的命令 : + +``` +$ mkdir meowmeow +$ cd meowmeow +$ git init +$ touch Makefile     # 编译程序的方法 +$ touch main.c       # 处理命令行选项 +$ touch main.h       # “全局”常量和定义 +$ touch mmencode.c   # 实现对喵呜喵呜文件的编码 +$ touch mmencode.h   # 描述编码 API +$ touch mmdecode.c   # 实现对喵呜喵呜文件的解码 +$ touch mmdecode.h   # 描述解码 API +$ touch table.h      # 定义编码查找表 +$ touch .gitignore   # 这个文件中的文件名会被 git 忽略 +$ git add . +$ git commit -m "initial commit of empty files" +``` + +简单的说,我创建了一个目录,里面全是空文件,并且提交到 git。 + +即使这些文件中没有内容,你依旧可以从它的文件名推断每个文件的用途。为了避免万一你无法理解,我在每条 `touch` 命令后面进行了简单描述。 + +通常,程序从一个简单 `main.c` 文件开始,只有两三个解决问题的函数。然后程序员轻率地向自己的朋友或者老板展示了该程序,然后为了支持所有新的“功能”和“需求”,文件中的函数数量就迅速爆开了。“程序俱乐部”的第一条规则便是不要谈论“程序俱乐部”,第二条规则是尽量减少单个文件中的函数。 + +老实说,C 编译器并不关心程序中的所有函数是否都在一个文件中。但是我们并不是为计算机或编译器写程序,我们是为其他人(有时也包括我们)去写程序的。我知道这可能有些奇怪,但这就是事实。程序体现了计算机解决问题所采用的一组算法,当问题的参数发生了意料之外的变化时,保证人们可以理解它们是非常重要的。当在人们修改程序时,发现一个文件中有 2049 函数时他们会诅咒你的。 + +因此,优秀的程序员会将函数分隔开,将相似的函数分组到不同的文件中。这里我用了三个文件 `main.c`、`mmencode.c` 和 `mmdecode.c`。对于这样小的程序,也许看起来有些过头了。但是小的程序很难保证一直小下去,因此哥忒拓展做好计划是一个“好主意”。 + +但是那些 `.h` 文件呢?我会在后面解释一般的术语,简单地说,它们被称为头文件,同时它们可以包含 C 语言类型定义和 C 预处理指令。头文件中不应该包含任何函数。你可以认为头文件是提供了应用程序接口(API)的定义的一种 `.c` 文件,可以供其它 `.c` 文件使用。 + +### 但是 Makefile 是什么呢? + +我知道下一个轰动一时的应用都是你们这些好孩子们用 “终极代码粉碎者 3000” 集成开发环境来编写的,而构建项目是用 Ctrl-Meta-Shift-Alt-Super-B 等一系列复杂的按键混搭出来的。但是如今(也就是今天),使用 `Makefile` 文件可以在构建 C 程序时帮助做很多有用的工作。`Makefile` 是一个包含如何处理文件的方式的文本文件,程序员可以使用其自动地从源代码构建二进制程序(以及其它东西!) + +以下面这个小东西为例: + +``` +00 # Makefile +01 TARGET= my_sweet_program +02 $(TARGET): main.c +03    cc -o my_sweet_program main.c +``` + +`#` 符号后面的文本是注释,例如 00 行。 + +01 行是一个变量赋值,将 `TARGET` 变量赋值为字符串 `my_sweet_program`。按照惯例,也是我的习惯,所有 `Makefile` 变量均使用大写字母并用下划线分隔单词。 + +02 行包含该步骤recipe要创建的文件名和其依赖的文件。在本例中,构建目标target是 `my_sweet_program`,其依赖是 `main.c`。 + +最后的 03 行使用了一个制表符号(`tab`)而不是四个空格。这是将要执行创建目标的命令。在本例中,我们使用 C 编译器C compiler前端 `cc` 以编译链接为 `my_sweet_program`。 + +使用 `Makefile` 是非常简单的。 + +``` +$ make +cc -o my_sweet_program main.c +$ ls +Makefile  main.c  my_sweet_program +``` + +构建我们喵呜喵呜编码器/解码器的 [Makefile][8] 比上面的例子要复杂,但其基本结构是相同的。我将在另一篇文章中将其分解为 Barney 风格。 + +### 形式伴随着功能 + +我的想法是程序从一个文件中读取、转换它,并将转换后的结果存储到另一个文件中。以下是我想象使用程序命令行交互时的情况: + +``` +$ meow < clear.txt > clear.meow +$ unmeow < clear.meow > meow.tx +$ diff clear.txt meow.tx +$ +``` + +我们需要编写代码以进行命令行解析和处理输入/输出流。我们需要一个函数对流进行编码并将结果写到另一个流中。最后,我们需要一个函数对流进行解码并将结果写到另一个流中。等一下,我们在讨论如何写一个程序,但是在上面的例子中,我调用了两个指令:`meow` 和 `unmeow`?我知道你可能会认为这会导致越变越复杂。 + +### 次要内容:argv[0] 和 ln 指令 + +回想一下,C 语言 main 函数的结构如下: + +``` +int main(int argc, char *argv[]) +``` + +其中 `argc` 是命令行参数的数量,`argv` 是字符指针(字符串)的列表。`argv[0]` 是包含正在执行的程序的文件路径。在 Unix 系统中许多互补功能的程序(比如:压缩和解压缩)看起来像两个命令,但事实上,它们是在文件系统中拥有两个名称的一个程序。这个技巧是通过使用 `ln` 命令创建文件系统链接来实现两个名称的。 + +在我笔记本电脑中 `/usr/bin` 的一个例子如下: + +``` +$ ls -li /usr/bin/git* +3376 -rwxr-xr-x. 113 root root     1.5M Aug 30  2018 /usr/bin/git +3376 -rwxr-xr-x. 113 root root     1.5M Aug 30  2018 /usr/bin/git-receive-pack +... +``` + +这里 `git` 和 `git-receive-pack` 是同一个文件但是拥有不同的名字。我们说它们是相同的文件因为它们具有相同的 inode 值(第一列)。inode 是 Unix 文件系统的一个特点,对它的介绍超越了本文的内容范畴。 + +优秀或懒惰的程序可以通过 Unix 文件系统的这个特点达到写更少的代码但是交付双倍的程序。首先,我们编写一个基于其 `argv[0]` 的值而作出相应改变的程序,然后我们确保为导致该行为的名称创建链接。 + +在我们的 `Makefile` 中,`unmeow` 链接通过以下的方式来创建: + +``` +# Makefile +... +$(DECODER): $(ENCODER) + $(LN) -f $< $@ + ... +``` + +我倾向于在 `Makefile` 中将所有内容参数化,很少使用 “裸” 字符串。我将所有的定义都放置在 `Makefile` 文件顶部,以便可以简单地找到并改变它们。当你尝试将程序移植到新的平台上时,需要将 `cc` 改变为某个 `cc` 时,这会很方便。 + +除了两个内置变量 `$@` 和 `$<` 之外,该步骤recipe看起来相对简单。第一个便是该步骤的目标的快捷方式,在本例中是 `$(DECODER)`(我能记得这个是因为 `@` 符号看起来像是一个目标)。第二个,`$<` 是规则依赖项,在本例中,它解析为 `$(ENCODER)`。 + +事情肯定会变得复杂,但它还在管理之中。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/structure-multi-file-c-part-1 + +作者:[Erik O'Shaughnessy][a] +选题:[lujun9972][b] +译者:[萌新阿岩](https://github.com/mengxinayan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jnyjnyhttps://opensource.com/users/jnyjnyhttps://opensource.com/users/jim-salterhttps://opensource.com/users/cldxsolutions +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming_keyboard_coding.png?itok=E0Vvam7A (Programming keyboard.) +[2]: https://linux.cn/article-10949-1.html +[3]: https://en.wikipedia.org/wiki/Unix +[4]: http://harmful.cat-v.org/cat-v/ +[5]: http://www.jabberwocky.com/software/moomooencode.html +[6]: https://giphy.com/gifs/nyan-cat-sIIhZliB2McAo +[7]: https://github.com/JnyJny/meowmeow +[8]: https://github.com/JnyJny/meowmeow/blob/master/Makefile diff --git a/published/202002/20191022 How to Go About Linux Boot Time Optimisation.md b/published/202002/20191022 How to Go About Linux Boot Time Optimisation.md new file mode 100644 index 0000000000..b6db365389 --- /dev/null +++ b/published/202002/20191022 How to Go About Linux Boot Time Optimisation.md @@ -0,0 +1,208 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11881-1.html) +[#]: subject: (How to Go About Linux Boot Time Optimisation) +[#]: via: (https://opensourceforu.com/2019/10/how-to-go-about-linux-boot-time-optimisation/) +[#]: author: (B Thangaraju https://opensourceforu.com/author/b-thangaraju/) + +如何进行 Linux 启动时间优化 +====== + +![][2] + +> 快速启动嵌入式设备或电信设备,对于时间要求紧迫的应用程序是至关重要的,并且在改善用户体验方面也起着非常重要的作用。这个文章给予一些关于如何增强任意设备的启动时间的重要技巧。 + +快速启动或快速重启在各种情况下起着至关重要的作用。为了保持所有服务的高可用性和更好的性能,嵌入式设备的快速启动至关重要。设想有一台运行着没有启用快速启动的 Linux 操作系统的电信设备,所有依赖于这个特殊嵌入式设备的系统、服务和用户可能会受到影响。这些设备维持其服务的高可用性是非常重要的,为此,快速启动和重启起着至关重要的作用。 + +一台电信设备的一次小故障或关机,即使只是几秒钟,都可能会对无数互联网上的用户造成破坏。因此,对于很多对时间要求严格的设备和电信设备来说,在它们的设备中加入快速启动的功能以帮助它们快速恢复工作是非常重要的。让我们从图 1 中理解 Linux 启动过程。 + +![图 1:启动过程][3] + +### 监视工具和启动过程 + +在对机器做出更改之前,用户应注意许多因素。其中包括计算机的当前启动速度,以及占用资源并增加启动时间的服务、进程或应用程序。 + +#### 启动图 + +为监视启动速度和在启动期间启动的各种服务,用户可以使用下面的命令来安装: + +``` +sudo apt-get install pybootchartgui +``` + +你每次启动时,启动图会在日志中保存一个 png 文件,使用户能够查看该 png 文件来理解系统的启动过程和服务。为此,使用下面的命令: + +``` +cd /var/log/bootchart +``` + +用户可能需要一个应用程序来查看 png 文件。Feh 是一个面向控制台用户的 X11 图像查看器。不像大多数其它的图像查看器,它没有一个精致的图形用户界面,但它只用来显示图片。Feh 可以用于查看 png 文件。你可以使用下面的命令来安装它: + +``` +sudo apt-get install feh +``` + +你可以使用 `feh xxxx.png` 来查看 png 文件。 + + +![图 2:启动图][4] + +图 2 显示了一个正在查看的引导图 png 文件。 + +#### systemd-analyze + +但是,对于 Ubuntu 15.10 以后的版本不再需要引导图。为获取关于启动速度的简短信息,使用下面的命令: + +``` +systemd-analyze +``` + +![图 3:systemd-analyze 的输出][5] + +图表 3 显示命令 `systemd-analyze` 的输出。 + +命令 `systemd-analyze blame` 用于根据初始化所用的时间打印所有正在运行的单元的列表。这个信息是非常有用的,可用于优化启动时间。`systemd-analyze blame` 不会显示服务类型为简单(`Type=simple`)的服务,因为 systemd 认为这些服务应是立即启动的;因此,无法测量初始化的延迟。 + +![图 4:systemd-analyze blame 的输出][6] + +图 4 显示 `systemd-analyze blame` 的输出。 + +下面的命令打印时间关键的服务单元的树形链条: + +``` +command systemd-analyze critical-chain +``` + +图 5 显示命令 `systemd-analyze critical-chain` 的输出。 + +![图 5:systemd-analyze critical-chain 的输出][7] + +### 减少启动时间的步骤 + +下面显示的是一些可以减少启动时间的各种步骤。 + +#### BUM(启动管理器) + +BUM 是一个运行级配置编辑器,允许在系统启动或重启时配置初始化服务。它显示了可以在启动时启动的每个服务的列表。用户可以打开和关闭各个服务。BUM 有一个非常清晰的图形用户界面,并且非常容易使用。 + +在 Ubuntu 14.04 中,BUM 可以使用下面的命令安装: + +``` +sudo apt-get install bum +``` + +为在 15.10 以后的版本中安装它,从链接 http://apt.ubuntu.com/p/bum 下载软件包。 + +以基本的服务开始,禁用扫描仪和打印机相关的服务。如果你没有使用蓝牙和其它不想要的设备和服务,你也可以禁用它们中一些。我强烈建议你在禁用相关的服务前学习服务的基础知识,因为这可能会影响计算机或操作系统。图 6 显示 BUM 的图形用户界面。 + +![图 6:BUM][8] + +#### 编辑 rc 文件 + +要编辑 rc 文件,你需要转到 rc 目录。这可以使用下面的命令来做到: + +``` +cd /etc/init.d +``` + +然而,访问 `init.d` 需要 root 用户权限,该目录基本上包含的是开始/停止脚本,这些脚本用于在系统运行时或启动期间控制(开始、停止、重新加载、启动启动)守护进程。 + +在 `init.d` 目录中的 `rc` 文件被称为运行控制run control脚本。在启动期间,`init` 执行 `rc` 脚本并发挥它的作用。为改善启动速度,我们可以更改 `rc` 文件。使用任意的文件编辑器打开 `rc` 文件(当你在 `init.d` 目录中时)。 + +例如,通过输入 `vim rc` ,你可以更改 `CONCURRENCY=none` 为 `CONCURRENCY=shell`。后者允许某些启动脚本同时执行,而不是依序执行。 + +在最新版本的内核中,该值应该被更改为 `CONCURRENCY=makefile`。 + +图 7 和图 8 显示编辑 `rc` 文件前后的启动时间比较。可以注意到启动速度有所提高。在编辑 `rc` 文件前的启动时间是 50.98 秒,然而在对 `rc` 文件进行更改后的启动时间是 23.85 秒。 + +但是,上面提及的更改方法在 Ubuntu 15.10 以后的操作系统上不工作,因为使用最新内核的操作系统使用 systemd 文件,而不再是 `init.d` 文件。 + +![图 7:对 rc 文件进行更改之前的启动速度][9] + +![图 8:对 rc 文件进行更改之后的启动速度][10] + +#### E4rat + +E4rat 代表 e4 减少访问时间reduced access time(仅在 ext4 文件系统的情况下)。它是由 Andreas Rid 和 Gundolf Kiefer 开发的一个项目。E4rat 是一个通过碎片整理来帮助快速启动的应用程序。它还会加速应用程序的启动。E4rat 使用物理文件的重新分配来消除寻道时间和旋转延迟,因而达到较高的磁盘传输速度。 + +E4rat 可以 .deb 软件包形式获得,你可以从它的官方网站 http://e4rat.sourceforge.net/ 下载。 + +Ubuntu 默认安装的 ureadahead 软件包与 e4rat 冲突。因此必须使用下面的命令安装这几个软件包: + +``` +sudo dpkg purge ureadahead ubuntu-minimal +``` + +现在使用下面的命令来安装 e4rat 的依赖关系: + +``` +sudo apt-get install libblkid1 e2fslibs +``` + +打开下载的 .deb 文件,并安装它。现在需要恰当地收集启动数据来使 e4rat 工作。 + +遵循下面所给的步骤来使 e4rat 正确地运行并提高启动速度。 + +* 在启动期间访问 Grub 菜单。这可以在系统启动时通过按住 `shift` 按键来完成。 +* 选择通常用于启动的选项(内核版本),并按 `e`。 +* 查找以 `linux /boot/vmlinuz` 开头的行,并在该行的末尾添加下面的代码(在句子的最后一个字母后按空格键):`init=/sbin/e4rat-collect or try - quiet splash vt.handsoff =7 init=/sbin/e4rat-collect +`。 +* 现在,按 `Ctrl+x` 来继续启动。这可以让 e4rat 在启动后收集数据。在这台机器上工作,并在接下来的两分钟时间内打开并关闭应用程序。 +* 通过转到 e4rat 文件夹,并使用下面的命令来访问日志文件:`cd /var/log/e4rat`。 +* 如果你没有找到任何日志文件,重复上面的过程。一旦日志文件就绪,再次访问 Grub 菜单,并对你的选项按 `e`。 +* 在你之前已经编辑过的同一行的末尾输入 `single`。这可以让你访问命令行。如果出现其它菜单,选择恢复正常启动(Resume normal boot)。如果你不知为何不能进入命令提示符,按 `Ctrl+Alt+F1` 组合键。 +* 在你看到登录提示后,输入你的登录信息。 +* 现在输入下面的命令:`sudo e4rat-realloc /var/lib/e4rat/startup.log`。此过程需要一段时间,具体取决于机器的磁盘速度。 +* 现在使用下面的命令来重启你的机器:`sudo shutdown -r now`。 +* 现在,我们需要配置 Grub 来在每次启动时运行 e4rat。 +* 使用任意的编辑器访问 grub 文件。例如,`gksu gedit /etc/default/grub`。 +* 查找以 `GRUB CMDLINE LINUX DEFAULT=` 开头的一行,并在引号之间和任何选项之前添加下面的行:`init=/sbin/e4rat-preload 18`。 +* 它应该看起来像这样:`GRUB CMDLINE LINUX DEFAULT = init=/sbin/e4rat- preload quiet splash`。 +* 保存并关闭 Grub 菜单,并使用 `sudo update-grub` 更新 Grub 。 +* 重启系统,你将发现启动速度有明显变化。 + +图 9 和图 10 显示在安装 e4rat 前后的启动时间之间的差异。可注意到启动速度的提高。在使用 e4rat 前启动所用时间是 22.32 秒,然而在使用 e4rat 后启动所用时间是 9.065 秒。 + +![图 9:使用 e4rat 之前的启动速度][11] + +![图 10:使用 e4rat 之后的启动速度][12] + +### 一些易做的调整 + +使用很小的调整也可以达到良好的启动速度,下面列出其中两个。 + +#### SSD + +使用固态设备而不是普通的硬盘或者其它的存储设备将肯定会改善启动速度。SSD 也有助于加快文件传输和运行应用程序方面的速度。 + +#### 禁用图形用户界面 + +图形用户界面、桌面图形和窗口动画占用大量的资源。禁用图形用户界面是获得良好的启动速度的另一个好方法。 + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/10/how-to-go-about-linux-boot-time-optimisation/ + +作者:[B Thangaraju][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://opensourceforu.com/author/b-thangaraju/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/10/Screenshot-from-2019-10-07-13-16-32.png?&ssl=1 (Screenshot from 2019-10-07 13-16-32) +[2]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/10/Screenshot-from-2019-10-07-13-16-32.png?fit=700%2C499&ssl=1 +[3]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-1.png?ssl=1 +[4]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-2.png?ssl=1 +[5]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-3.png?ssl=1 +[6]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-4.png?ssl=1 +[7]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-5.png?ssl=1 +[8]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-6.png?ssl=1 +[9]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-7.png?ssl=1 +[10]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-8.png?ssl=1 +[11]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-9.png?ssl=1 +[12]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-10.png?ssl=1 diff --git a/published/202002/20191204 --acid -words- Handle Chromium - Firefox sessions with org-mode.md b/published/202002/20191204 --acid -words- Handle Chromium - Firefox sessions with org-mode.md new file mode 100644 index 0000000000..31c93609ab --- /dev/null +++ b/published/202002/20191204 --acid -words- Handle Chromium - Firefox sessions with org-mode.md @@ -0,0 +1,147 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11926-1.html) +[#]: subject: (Handle Chromium & Firefox sessions with org-mode) +[#]: via: (https://acidwords.com/posts/2019-12-04-handle-chromium-and-firefox-sessions-with-org-mode.html) +[#]: author: (Sanel Z https://acidwords.com/) + +通过 Org 模式管理 Chromium 和 Firefox 会话 +====== + +![](https://img.linux.net.cn/data/attachment/album/202002/24/113047w8jtoh2o5j085750.jpg) + +我是[会话管理器][1]的铁粉,它是 Chrome 和 Chromium 的小插件,可以保存所有打开的选项卡,为会话命名,并在需要时恢复会话。 + +它非常有用,特别是如果你像我一样,白天的时候需要在多个“思维活动”之间切换——研究、开发或者阅读新闻。或者你只是单纯地希望记住几天前的工作流(和选项卡)。 + +在我决定放弃 chromium 上除了 [uBlock Origin][2] 之外的所有扩展后,就必须寻找一些替代品了。我的主要目标是使之与浏览器无关,同时会话链接必须保存在文本文件中,这样我就可以享受所有纯文本的好处了。还有什么比 [org 模式][3]更好呢 ;) + +很久以前我就发现了这个小诀窍:[通过命令行获取当前在谷歌 Chrome 中打开的标签][4] 再加上些 elisp 代码: + +``` +(require 'cl-lib) + +(defun save-chromium-session () + "Reads chromium current session and generate org-mode heading with items." + (interactive) + (save-excursion + (let* ((cmd "strings ~/'.config/chromium/Default/Current Session' | 'grep' -E '^https?://' | sort | uniq") + (ret (shell-command-to-string cmd))) + (insert + (concat + "* " + (format-time-string "[%Y-%m-%d %H:%M:%S]") + "\n" + (mapconcat 'identity + (cl-reduce (lambda (lst x) + (if (and x (not (string= "" x))) + (cons (concat " - " x) lst) + lst)) + (split-string ret "\n") + :initial-value (list)) + "\n")))))) + +(defun restore-chromium-session () + "Restore session, by openning each link in list with (browse-url). +Make sure to put cursor on date heading that contains list of urls." + (interactive) + (save-excursion + (beginning-of-line) + (when (looking-at "^\\*") + (forward-line 1) + (while (looking-at "^[ ]+-[ ]+\\(http.?+\\)$") + (let* ((ln (thing-at-point 'line t)) + (ln (replace-regexp-in-string "^[ ]+-[ ]+" "" ln)) + (ln (replace-regexp-in-string "\n" "" ln))) + (browse-url ln)) + (forward-line 1))))) +``` + +那么,它的工作原理是什么呢? + +运行上述代码,打开一个新 org 模式文件并调用 `M-x save-chromium-session`。它会创建类似这样的东西: + +``` +* [2019-12-04 12:14:02] + - https://www.reddit.com/r/emacs/comments/... + - https://www.reddit.com/r/Clojure + - https://news.ycombinator.com +``` + +也就是任何在 chromium 实例中运行着的 URL。要还原的话,则将光标置于所需日期上然后运行 `M-x restore-chromium-session`。所有标签都应该恢复了。 + +以下是我的使用案例,其中的数据是随机生成的: + +``` +#+TITLE: Browser sessions + +* [2019-12-01 23:15:00]... +* [2019-12-02 18:10:20]... +* [2019-12-03 19:00:12] + - https://www.reddit.com/r/emacs/comments/... + - https://www.reddit.com/r/Clojure + - https://news.ycombinator.com + +* [2019-12-04 12:14:02] + - https://www.reddit.com/r/emacs/comments/... + - https://www.reddit.com/r/Clojure + - https://news.ycombinator.com +``` + +请注意,用于读取 Chromium 会话的方法并不完美:`strings` 将从二进制数据库中读取任何类似 URL 字符串的内容,有时这将产生不完整的 URL。不过,你可以很方便地地编辑它们,从而保持会话文件简洁。 + +为了真正打开标签,elisp 代码中使用到了 [browse-url][5],它可以通过 `browse-url-browser-function` 变量进一步定制成运行 Chromium、Firefox 或任何其他浏览器。请务必阅读该变量的相关文档。 + +别忘了把会话文件放在 git、mercurial 或 svn 中,这样你就再也不会丢失会话历史记录了 :) + +### 那么 Firefox 呢? + +如果你正在使用 Firefox(最近的版本),并且想要获取会话 URL,下面是操作方法。 + +首先,下载并编译 [lz4json][6],这是一个可以解压缩 Mozilla lz4json 格式的小工具,Firefox 以这种格式来存储会话数据。会话数据(在撰写本文时)存储在 `$HOME/.mozilla/firefox//sessionstore-backup /recovery.jsonlz4` 中。 + +如果 Firefox 没有运行,则没有 `recovery.jsonlz4`,这种情况下用 `previous.jsonlz4` 代替。 + +要提取网址,尝试在终端运行: + +``` +$ lz4jsoncat recovery.jsonlz4 | grep -oP '"(http.+?)"' | sed 's/"//g' | sort | uniq +``` + +然后更新 `save-chromium-session` 为: + +``` +(defun save-chromium-session () + "Reads chromium current session and converts it to org-mode chunk." + (interactive) + (save-excursion + (let* ((path "~/.mozilla/firefox//sessionstore-backups/recovery.jsonlz4") + (cmd (concat "lz4jsoncat " path " | grep -oP '\"(http.+?)\"' | sed 's/\"//g' | sort | uniq")) + (ret (shell-command-to-string cmd))) +... +;; rest of the code is unchanged +``` + +更新本函数的文档字符串、函数名以及进一步的重构都留作练习。 + +-------------------------------------------------------------------------------- + +via: https://acidwords.com/posts/2019-12-04-handle-chromium-and-firefox-sessions-with-org-mode.html + +作者:[Sanel Z][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://acidwords.com/ +[b]: https://github.com/lujun9972 +[1]: https://chrome.google.com/webstore/detail/session-manager/mghenlmbmjcpehccoangkdpagbcbkdpc?hl=en-US +[2]: https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm?hl=en +[3]: https://orgmode.org/ +[4]: https://superuser.com/a/1310873 +[5]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Browse_002dURL.html +[6]: https://github.com/andikleen/lz4json diff --git a/published/202002/20191225 8 Commands to Check Memory Usage on Linux.md b/published/202002/20191225 8 Commands to Check Memory Usage on Linux.md new file mode 100644 index 0000000000..70e07c8181 --- /dev/null +++ b/published/202002/20191225 8 Commands to Check Memory Usage on Linux.md @@ -0,0 +1,373 @@ +[#]: collector: (lujun9972) +[#]: translator: (mengxinayan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11870-1.html) +[#]: subject: (8 Commands to Check Memory Usage on Linux) +[#]: via: (https://www.2daygeek.com/linux-commands-check-memory-usage/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +检查 Linux 中内存使用情况的 8 条命令 +====== + +![](https://img.linux.net.cn/data/attachment/album/202002/09/121112mg0jigxtcc5xr8or.jpg) + +Linux 并不像 Windows,你经常不会有图形界面可供使用,特别是在服务器环境中。 + +作为一名 Linux 管理员,知道如何获取当前可用的和已经使用的资源情况,比如内存、CPU、磁盘等,是相当重要的。如果某一应用在你的系统上占用了太多的资源,导致你的系统无法达到最优状态,那么你需要找到并修正它。 + +如果你想找到消耗内存前十名的进程,你需要去阅读这篇文章:[如何在 Linux 中找出内存消耗最大的进程][1]。 + +在 Linux 中,命令能做任何事,所以使用相关命令吧。在这篇教程中,我们将会给你展示 8 个有用的命令来即查看在 Linux 系统中内存的使用情况,包括 RAM 和交换分区。 + +创建交换分区在 Linux 系统中是非常重要的,如果你想了解如何创建,可以去阅读这篇文章:[在 Linux 系统上创建交换分区][2]。 + +下面的命令可以帮助你以不同的方式查看 Linux 内存使用情况。 + + * `free` 命令 + * `/proc/meminfo` 文件 + * `vmstat` 命令 + * `ps_mem` 命令 + * `smem` 命令 + * `top` 命令 + * `htop` 命令 + * `glances` 命令 + +### 1)如何使用 free 命令查看 Linux 内存使用情况 + +[free 命令][3] 是被 Linux 管理员广泛使用的主要命令。但是它提供的信息比 `/proc/meminfo` 文件少。 + +`free` 命令会分别展示物理内存和交换分区内存中已使用的和未使用的数量,以及内核使用的缓冲区和缓存。 + +这些信息都是从 `/proc/meminfo` 文件中获取的。 + +``` +# free -m + total used free shared buff/cache available +Mem: 15867 9199 1702 3315 4965 3039 +Swap: 17454 666 16788 +``` + + * `total`:总的内存量 + * `used`:被当前运行中的进程使用的内存量(`used` = `total` – `free` – `buff/cache`) + * `free`: 未被使用的内存量(`free` = `total` – `used` – `buff/cache`) + * `shared`: 在两个或多个进程之间共享的内存量 + * `buffers`: 内存中保留用于内核记录进程队列请求的内存量 + * `cache`: 在 RAM 中存储最近使用过的文件的页缓冲大小 + * `buff/cache`: 缓冲区和缓存总的使用内存量 + * `available`: 可用于启动新应用的可用内存量(不含交换分区) + +### 2) 如何使用 /proc/meminfo 文件查看 Linux 内存使用情况 + +`/proc/meminfo` 文件是一个包含了多种内存使用的实时信息的虚拟文件。它展示内存状态单位使用的是 kB,其中大部分属性都难以理解。然而它也包含了内存使用情况的有用信息。 + +``` +# cat /proc/meminfo + +MemTotal: 16248572 kB +MemFree: 1764576 kB +MemAvailable: 3136604 kB +Buffers: 234132 kB +Cached: 4731288 kB +SwapCached: 28516 kB +Active: 9004412 kB +Inactive: 3552416 kB +Active(anon): 8094128 kB +Inactive(anon): 2896064 kB +Active(file): 910284 kB +Inactive(file): 656352 kB +Unevictable: 80 kB +Mlocked: 80 kB +SwapTotal: 17873388 kB +SwapFree: 17191328 kB +Dirty: 252 kB +Writeback: 0 kB +AnonPages: 7566736 kB +Mapped: 3692368 kB +Shmem: 3398784 kB +Slab: 278976 kB +SReclaimable: 125480 kB +SUnreclaim: 153496 kB +KernelStack: 23936 kB +PageTables: 73880 kB +NFS_Unstable: 0 kB +Bounce: 0 kB +WritebackTmp: 0 kB +CommitLimit: 25997672 kB +Committed_AS: 24816804 kB +VmallocTotal: 34359738367 kB +VmallocUsed: 0 kB +VmallocChunk: 0 kB +Percpu: 3392 kB +HardwareCorrupted: 0 kB +AnonHugePages: 0 kB +ShmemHugePages: 0 kB +ShmemPmdMapped: 0 kB +HugePages_Total: 0 +HugePages_Free: 0 +HugePages_Rsvd: 0 +HugePages_Surp: 0 +Hugepagesize: 2048 kB +Hugetlb: 0 kB +DirectMap4k: 1059088 kB +DirectMap2M: 14493696 kB +DirectMap1G: 2097152 kB +``` + +### 3) 如何使用 vmstat 命令查看 Linux 内存使用情况 + +[vmstat 命令][4] 是另一个报告虚拟内存统计信息的有用工具。 + +`vmstat` 报告的信息包括:进程、内存、页面映射、块 I/O、陷阱、磁盘和 CPU 特性信息。`vmstat` 不需要特殊的权限,并且它可以帮助诊断系统瓶颈。 + +``` +# vmstat + +procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- + r b swpd free buff cache si so bi bo in cs us sy id wa st + 1 0 682060 1769324 234188 4853500 0 3 25 91 31 16 34 13 52 0 0 +``` + +如果你想详细了解每一项的含义,阅读下面的描述。 + +* `procs`:进程 + * `r`: 可以运行的进程数目(正在运行或等待运行) + * `b`: 处于不可中断睡眠中的进程数目 +* `memory`:内存 + * `swpd`: 使用的虚拟内存数量 + * `free`: 空闲的内存数量 + * `buff`: 用作缓冲区内存的数量 + * `cache`: 用作缓存内存的数量 + * `inact`: 不活动的内存数量(使用 `-a` 选项) + * `active`: 活动的内存数量(使用 `-a` 选项) +* `Swap`:交换分区 + * `si`: 每秒从磁盘交换的内存数量 + * `so`: 每秒交换到磁盘的内存数量 +* `IO`:输入输出 + * `bi`: 从一个块设备中收到的块(块/秒) + * `bo`: 发送到一个块设备的块(块/秒) +* `System`:系统 + * `in`: 每秒的中断次数,包括时钟。 + * `cs`: 每秒的上下文切换次数。 +* `CPU`:下面这些是在总的 CPU 时间占的百分比 + * `us`: 花费在非内核代码上的时间占比(包括用户时间,调度时间) + * `sy`: 花费在内核代码上的时间占比 (系统时间) + * `id`: 花费在闲置的时间占比。在 Linux 2.5.41 之前,包括 I/O 等待时间 + * `wa`: 花费在 I/O 等待上的时间占比。在 Linux 2.5.41 之前,包括在空闲时间中 + * `st`: 被虚拟机偷走的时间占比。在 Linux 2.6.11 之前,这部分称为 unknown + +运行下面的命令查看详细的信息。 + +``` +# vmstat -s + + 16248580 K total memory + 2210256 K used memory + 2311820 K active memory + 2153352 K inactive memory + 11368812 K free memory + 107584 K buffer memory + 2561928 K swap cache + 17873388 K total swap + 0 K used swap + 17873388 K free swap + 44309 non-nice user cpu ticks + 164 nice user cpu ticks + 14332 system cpu ticks + 382418 idle cpu ticks + 1248 IO-wait cpu ticks + 1407 IRQ cpu ticks + 2147 softirq cpu ticks + 0 stolen cpu ticks + 1022437 pages paged in + 260296 pages paged out + 0 pages swapped in + 0 pages swapped out + 1424838 interrupts + 4979524 CPU context switches + 1577163147 boot time + 3318 forks +``` +### 4) 如何使用 ps_mem 命令查看 Linux 内存使用情况 + +[ps_mem][5] 是一个用来查看当前内存使用情况的简单的 Python 脚本。该工具可以确定每个程序使用了多少内存(不是每个进程)。 + +该工具采用如下的方法计算每个程序使用内存:总的使用 = 程序进程私有的内存 + 程序进程共享的内存。 + +计算共享内存是存在不足之处的,该工具可以为运行中的内核自动选择最准确的方法。 + +``` +# ps_mem + + Private + Shared = RAM used Program +180.0 KiB + 30.0 KiB = 210.0 KiB xf86-video-intel-backlight-helper (2) +192.0 KiB + 66.0 KiB = 258.0 KiB cat (2) +312.0 KiB + 38.5 KiB = 350.5 KiB lvmetad +380.0 KiB + 25.5 KiB = 405.5 KiB crond +392.0 KiB + 32.5 KiB = 424.5 KiB rtkit-daemon +852.0 KiB + 117.0 KiB = 969.0 KiB gnome-session-ctl (2) +928.0 KiB + 56.5 KiB = 984.5 KiB gvfs-mtp-volume-monitor + 1.0 MiB + 42.5 KiB = 1.0 MiB dconf-service + 1.0 MiB + 106.5 KiB = 1.1 MiB gvfs-goa-volume-monitor + 1.0 MiB + 180.5 KiB = 1.2 MiB gvfsd +. +. + 5.3 MiB + 3.0 MiB = 8.3 MiB evolution-addressbook-factory + 8.5 MiB + 1.2 MiB = 9.7 MiB gnome-session-binary (4) + 7.5 MiB + 3.1 MiB = 10.5 MiB polkitd + 7.4 MiB + 3.3 MiB = 10.7 MiB pulseaudio (2) + 7.0 MiB + 7.0 MiB = 14.0 MiB msm_notifier + 12.7 MiB + 2.3 MiB = 15.0 MiB evolution-source-registry + 13.3 MiB + 2.5 MiB = 15.8 MiB gnome-terminal-server + 15.8 MiB + 1.0 MiB = 16.8 MiB tracker-miner-fs + 18.7 MiB + 1.8 MiB = 20.5 MiB python3.7 + 16.6 MiB + 4.0 MiB = 20.5 MiB evolution-calendar-factory + 22.3 MiB + 753.0 KiB = 23.0 MiB gsd-keyboard (2) + 22.4 MiB + 832.0 KiB = 23.2 MiB gsd-wacom (2) + 20.8 MiB + 2.5 MiB = 23.3 MiB blueman-tray + 22.0 MiB + 1.8 MiB = 23.8 MiB blueman-applet + 23.1 MiB + 934.0 KiB = 24.0 MiB gsd-xsettings (2) + 23.7 MiB + 1.2 MiB = 24.9 MiB gsd-media-keys (2) + 23.4 MiB + 1.6 MiB = 25.0 MiB gsd-color (2) + 23.9 MiB + 1.2 MiB = 25.1 MiB gsd-power (2) + 16.5 MiB + 8.9 MiB = 25.4 MiB evolution-alarm-notify + 27.2 MiB + 2.0 MiB = 29.2 MiB systemd-journald + 28.7 MiB + 2.8 MiB = 31.5 MiB c + 29.6 MiB + 2.2 MiB = 31.8 MiB chrome-gnome-sh (2) + 43.9 MiB + 6.8 MiB = 50.7 MiB WebExtensions + 46.7 MiB + 6.7 MiB = 53.5 MiB goa-daemon + 86.5 MiB + 55.2 MiB = 141.7 MiB Xorg (2) +191.4 MiB + 24.1 MiB = 215.4 MiB notepadqq-bin +306.7 MiB + 29.0 MiB = 335.7 MiB gnome-shell (2) +601.6 MiB + 77.7 MiB = 679.2 MiB firefox + 1.0 GiB + 109.7 MiB = 1.1 GiB chrome (15) + 2.3 GiB + 123.1 MiB = 2.5 GiB Web Content (8) +---------------------------------- + 5.6 GiB +================================== +``` + +### 5)如何使用 smem 命令查看 Linux 内存使用情况 + +[smem][6] 是一个可以为 Linux 系统提供多种内存使用情况报告的工具。不同于现有的工具,`smem` 可以报告比例集大小Proportional Set Size(PSS)、唯一集大小Unique Set Size(USS)和驻留集大小Resident Set Size(RSS)。 + +- 比例集大小(PSS):库和应用在虚拟内存系统中的使用量。 +- 唯一集大小(USS):其报告的是非共享内存。 +- 驻留集大小(RSS):物理内存(通常多进程共享)使用情况,其通常高于内存使用量。 + +``` +# smem -tk + + PID User Command Swap USS PSS RSS +3383 daygeek cat 0 92.0K 123.0K 1.7M +3384 daygeek cat 0 100.0K 129.0K 1.7M +1177 daygeek /usr/lib/gnome-session-ctl 0 436.0K 476.0K 4.6M +1171 daygeek /usr/bin/dbus-daemon --conf 0 524.0K 629.0K 3.8M +1238 daygeek /usr/lib/xdg-permission-sto 0 592.0K 681.0K 5.9M +1350 daygeek /usr/lib/gsd-screensaver-pr 0 652.0K 701.0K 5.8M +1135 daygeek /usr/lib/gdm-x-session --ru 0 648.0K 723.0K 6.0M +. +. +1391 daygeek /usr/lib/evolution-data-ser 0 16.5M 25.2M 63.3M +1416 daygeek caffeine-ng 0 28.7M 31.4M 66.2M +4855 daygeek /opt/google/chrome/chrome - 0 38.3M 46.3M 120.6M +2174 daygeek /usr/lib/firefox/firefox -c 0 44.0M 50.7M 120.3M +1254 daygeek /usr/lib/goa-daemon 0 46.7M 53.3M 80.4M +3416 daygeek /opt/google/chrome/chrome - 0 44.7M 54.2M 103.3M +4782 daygeek /opt/google/chrome/chrome - 0 57.2M 65.8M 142.3M +1137 daygeek /usr/lib/Xorg vt2 -displayf 0 77.2M 129.6M 192.3M +3376 daygeek /opt/google/chrome/chrome 0 117.8M 131.0M 210.9M +4448 daygeek /usr/lib/firefox/firefox -c 0 124.4M 133.8M 224.1M +3558 daygeek /opt/google/chrome/chrome - 0 157.3M 165.7M 242.2M +2310 daygeek /usr/lib/firefox/firefox -c 0 159.6M 169.4M 259.6M +4331 daygeek /usr/lib/firefox/firefox -c 0 176.8M 186.2M 276.8M +4034 daygeek /opt/google/chrome/chrome - 0 179.3M 187.9M 264.6M +3911 daygeek /opt/google/chrome/chrome - 0 183.1M 191.8M 269.4M +3861 daygeek /opt/google/chrome/chrome - 0 199.8M 208.2M 285.2M +2746 daygeek /usr/bin/../lib/notepadqq/n 0 193.5M 217.5M 261.5M +1194 daygeek /usr/bin/gnome-shell 0 203.7M 219.0M 285.1M +2945 daygeek /usr/lib/firefox/firefox -c 0 294.5M 308.0M 410.2M +2786 daygeek /usr/lib/firefox/firefox -c 0 341.2M 354.3M 459.1M +4193 daygeek /usr/lib/firefox/firefox -c 0 417.4M 427.6M 519.3M +2651 daygeek /usr/lib/firefox/firefox -c 0 417.0M 430.1M 535.6M +2114 daygeek /usr/lib/firefox/firefox -c 0 430.6M 473.9M 610.9M +2039 daygeek /usr/lib/firefox/firefox -- 0 601.3M 677.5M 840.6M +------------------------------------------------------------------------------- + 90 1 0 4.8G 5.2G 8.0G +``` + +### 6) 如何使用 top 命令查看 Linux 内存使用情况 + +[top 命令][7] 是一个 Linux 系统的管理员最常使用的用于查看进程的资源使用情况的命令。 + +该命令会展示了系统总的内存量、当前内存使用量、空闲内存量和缓冲区使用的内存总量。此外,该命令还会展示总的交换空间内存量、当前交换空间的内存使用量、空闲的交换空间内存量和缓存使用的内存总量。 + +``` +# top -b | head -10 + +top - 11:04:39 up 40 min, 1 user, load average: 1.59, 1.42, 1.28 +Tasks: 288 total, 2 running, 286 sleeping, 0 stopped, 0 zombie +%Cpu(s): 13.3 us, 1.5 sy, 0.0 ni, 84.4 id, 0.0 wa, 0.3 hi, 0.5 si, 0.0 st +KiB Mem : 16248572 total, 7755928 free, 4657736 used, 3834908 buff/cache +KiB Swap: 17873388 total, 17873388 free, 0 used. 9179772 avail Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 2114 daygeek 20 3182736 616624 328228 R 83.3 3.8 7:09.72 Web Content + 2039 daygeek 20 4437952 849616 261364 S 13.3 5.2 7:58.54 firefox + 1194 daygeek 20 4046856 291288 165460 S 4.2 1.8 1:57.68 gnome-shell + 4034 daygeek 20 808556 273244 88676 S 4.2 1.7 1:44.72 chrome + 2945 daygeek 20 3309832 416572 150112 S 3.3 2.6 4:04.60 Web Content + 1137 daygeek 20 564316 197292 183380 S 2.5 1.2 2:55.76 Xorg + 2651 daygeek 20 3098420 547260 275700 S 1.7 3.4 2:15.96 Web Content + 2786 daygeek 20 2957112 463912 240744 S 1.7 2.9 3:22.29 Web Content + 1 root 20 182756 10208 7760 S 0.8 0.1 0:04.51 systemd + 442 root -51 S 0.8 0:05.02 irq/141-iw+ + 1426 daygeek 20 373660 48948 29820 S 0.8 0.3 0:03.55 python3 + 2174 daygeek 20 2466680 122196 78604 S 0.8 0.8 0:17.75 WebExtensi+ +``` + +### 7) 如何使用 htop 命令查看 Linux 内存使用情况 + +[htop 命令][8] 是一个可交互的 Linux/Unix 系统进程查看器。它是一个文本模式应用,且使用它需要 Hisham 开发的 ncurses 库。 + +该名令的设计目的使用来代替 `top` 命令。该命令与 `top` 命令很相似,但是其允许你可以垂直地或者水平地的滚动以便可以查看系统中所有的进程情况。 + +`htop` 命令拥有不同的颜色,这个额外的优点当你在追踪系统性能情况时十分有用。 + +此外,你可以自由地执行与进程相关的任务,比如杀死进程或者改变进程的优先级而不需要其进程号(PID)。 + +![][10] + +### 8)如何使用 glances 命令查看 Linux 内存使用情况 + +[Glances][11] 是一个 Python 编写的跨平台的系统监视工具。 + +你可以在一个地方查看所有信息,比如:CPU 使用情况、内存使用情况、正在运行的进程、网络接口、磁盘 I/O、RAID、传感器、文件系统信息、Docker、系统信息、运行时间等等。 + +![][12] + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-commands-check-memory-usage/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[萌新阿岩](https://github.com/mengxinayan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-11542-1.html +[2]: https://linux.cn/article-9579-1.html +[3]: https://linux.cn/article-8314-1.html +[4]: https://linux.cn/article-8157-1.html +[5]: https://linux.cn/article-8639-1.html +[6]: https://linux.cn/article-7681-1.html +[7]: https://www.2daygeek.com/linux-top-command-linux-system-performance-monitoring-tool/ +[8]: https://www.2daygeek.com/linux-htop-command-linux-system-performance-resource-monitoring-tool/ +[9]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[10]: https://www.2daygeek.com/wp-content/uploads/2019/12/linux-commands-check-memory-usage-2.jpg +[11]: https://www.2daygeek.com/linux-glances-advanced-real-time-linux-system-performance-monitoring-tool/ +[12]: https://www.2daygeek.com/wp-content/uploads/2019/12/linux-commands-check-memory-usage-3.jpg diff --git a/published/202002/20191227 Top CI-CD resources to set you up for success.md b/published/202002/20191227 Top CI-CD resources to set you up for success.md new file mode 100644 index 0000000000..a19cea5720 --- /dev/null +++ b/published/202002/20191227 Top CI-CD resources to set you up for success.md @@ -0,0 +1,57 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11875-1.html) +[#]: subject: (Top CI/CD resources to set you up for success) +[#]: via: (https://opensource.com/article/19/12/cicd-resources) +[#]: author: (Jessica Cherry https://opensource.com/users/jrepka) + +顶级 CI / CD 资源,助你成功 +====== + +> 随着企业期望实现无缝、灵活和可扩展的部署,持续集成和持续部署成为 2019 年的关键主题。 + +![Plumbing tubes in many directions][1] + +对于 CI/CD 和 DevOps 来说,2019 年是非常棒的一年。Opensource.com 的作者分享了他们专注于无缝、灵活和可扩展部署时是如何朝着敏捷和 scrum 方向发展的。以下是我们 2019 年发布的 CI/CD 文章中的一些重要文章。 + +### 学习和提高你的 CI/CD 技能 + +我们最喜欢的一些文章集中在 CI/CD 的实操经验上,并涵盖了许多方面。通常以 [Jenkins][2] 管道开始,Bryant Son 的文章《[用 Jenkins 构建 CI/CD 管道][3]》将为你提供足够的经验,以开始构建你的第一个管道。Daniel Oh 在《[用 DevOps 管道进行自动验收测试][4]》一文中,提供了有关验收测试的重要信息,包括可用于自行测试的各种 CI/CD 应用程序。我写的《[安全扫描 DevOps 管道][5]》非常简短,其中简要介绍了如何使用 Jenkins 平台在管道中设置安全性。 + +### 交付工作流程 + +正如 Jithin Emmanuel 在《[Screwdriver:一个用于持续交付的可扩展构建平台][6]》中分享的,在学习如何使用和提高你的 CI/CD 技能方面,工作流程很重要,特别是当涉及到管道时。Emily Burns 在《[为什么 Spinnaker 对 CI/CD 很重要][7]》中解释了灵活地使用 CI/CD 工作流程准确构建所需内容的原因。Willy-Peter Schaub 还盛赞了为所有产品创建统一管道的想法,以便《[在一个 CI/CD 管道中一致地构建每个产品][8]》。这些文章将让你很好地了解在团队成员加入工作流程后会发生什么情况。 + +### CI/CD 如何影响企业 + +2019 年也是认识到 CI/CD 的业务影响以及它是如何影响日常运营的一年。Agnieszka Gancarczyk 分享了 Red Hat 《[小型 Scrum vs. 大型 Scrum][9]》的调查结果, 包括受访者对 Scrum、敏捷运动及对团队的影响的不同看法。Will Kelly 的《[持续部署如何影响整个组织][10]》,也提及了开放式沟通的重要性。Daniel Oh 也在《[DevOps 团队必备的 3 种指标仪表板][11]》中强调了指标和可观测性的重要性。最后是 Ann Marie Fred 的精彩文章《[不在生产环境中测试?要在生产环境中测试!][12]》详细说明了在验收测试前在生产环境中测试的重要性。 + +感谢许多贡献者在 2019 年与 Opensource 的读者分享他们的见解,我期望在 2020 年里从他们那里了解更多有关 CI/CD 发展的信息。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/cicd-resources + +作者:[Jessica Cherry][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jrepka +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/plumbing_pipes_tutorial_how_behind_scenes.png?itok=F2Z8OJV1 (Plumbing tubes in many directions) +[2]: https://jenkins.io/ +[3]: https://linux.cn/article-11546-1.html +[4]: https://opensource.com/article/19/4/devops-pipeline-acceptance-testing +[5]: https://opensource.com/article/19/7/security-scanning-your-devops-pipeline +[6]: https://opensource.com/article/19/3/screwdriver-cicd +[7]: https://opensource.com/article/19/8/why-spinnaker-matters-cicd +[8]: https://opensource.com/article/19/7/cicd-pipeline-rule-them-all +[9]: https://opensource.com/article/19/3/small-scale-scrum-vs-large-scale-scrum +[10]: https://opensource.com/article/19/7/organizational-impact-continuous-deployment +[11]: https://linux.cn/article-11183-1.html +[12]: https://opensource.com/article/19/5/dont-test-production diff --git a/published/202002/20200102 Data streaming and functional programming in Java.md b/published/202002/20200102 Data streaming and functional programming in Java.md new file mode 100644 index 0000000000..cf3b1bd11d --- /dev/null +++ b/published/202002/20200102 Data streaming and functional programming in Java.md @@ -0,0 +1,456 @@ +[#]: collector: (lujun9972) +[#]: translator: (laingke) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11857-1.html) +[#]: subject: (Data streaming and functional programming in Java) +[#]: via: (https://opensource.com/article/20/1/javastream) +[#]: author: (Marty Kalin https://opensource.com/users/mkalindepauledu) + +Java 中的数据流和函数式编程 +====== + +> 学习如何使用 Java 8 中的流 API 和函数式编程结构。 + +![](https://img.linux.net.cn/data/attachment/album/202002/06/002505flazlb4cg4aavvb4.jpg) + +当 Java SE 8(又名核心 Java 8)在 2014 年被推出时,它引入了一些更改,从根本上影响了用它进行的编程。这些更改中有两个紧密相连的部分:流 API 和函数式编程构造。本文使用代码示例,从基础到高级特性,介绍每个部分并说明它们之间的相互作用。 + +### 基础特性 + +流 API 是在数据序列中迭代元素的简洁而高级的方法。包 `java.util.stream` 和 `java.util.function` 包含了用于流 API 和相关函数式编程构造的新库。当然,代码示例胜过千言万语。 + +下面的代码段用大约 2,000 个随机整数值填充了一个 `List`: + +``` +Random rand = new Random2(); +List list = new ArrayList(); // 空 list +for (int i = 0; i < 2048; i++) list.add(rand.nextInt()); // 填充它 +``` + +另外用一个 `for` 循环可用于遍历填充列表,以将偶数值收集到另一个列表中。 + +流 API 提供了一种更简洁的方法来执行此操作: + +``` +List evens = list + .stream() // 流化 list + .filter(n -> (n & 0x1) == 0) // 过滤出奇数值 + .collect(Collectors.toList()); // 收集偶数值 +``` + +这个例子有三个来自流 API 的函数: + +- `stream` 函数可以将**集合**转换为流,而流是一个每次可访问一个值的传送带。流化是惰性的(因此也是高效的),因为值是根据需要产生的,而不是一次性产生的。 +- `filter` 函数确定哪些流的值(如果有的话)通过了处理管道中的下一个阶段,即 `collect` 阶段。`filter` 函数是 高阶的higher-order,因为它的参数是一个函数 —— 在这个例子中是一个 lambda 表达式,它是一个未命名的函数,并且是 Java 新的函数式编程结构的核心。 + +lambda 语法与传统的 Java 完全不同: + +``` +n -> (n & 0x1) == 0 +``` + +箭头(一个减号后面紧跟着一个大于号)将左边的参数列表与右边的函数体分隔开。参数 `n` 虽未明确类型,但也可以明确。在任何情况下,编译器都会发现 `n` 是个 `Integer`。如果有多个参数,这些参数将被括在括号中,并用逗号分隔。 + +在本例中,函数体检查一个整数的最低位(最右)是否为零,这用来表示偶数。过滤器应返回一个布尔值。尽管可以,但该函数的主体中没有显式的 `return`。如果主体没有显式的 `return`,则主体的最后一个表达式即是返回值。在这个例子中,主体按照 lambda 编程的思想编写,由一个简单的布尔表达式 `(n & 0x1) == 0` 组成。 + +- `collect` 函数将偶数值收集到引用为 `evens` 的列表中。如下例所示,`collect` 函数是线程安全的,因此,即使在多个线程之间共享了过滤操作,该函数也可以正常工作。 + +### 方便的功能和轻松实现多线程 + +在生产环境中,数据流的源可能是文件或网络连接。为了学习流 API, Java 提供了诸如 `IntStream` 这样的类型,它可以用各种类型的元素生成流。这里有一个 `IntStream` 的例子: + +``` +IntStream // 整型流 + .range(1, 2048) // 生成此范围内的整型流 + .parallel() // 为多个线程分区数据 + .filter(i -> ((i & 0x1) > 0)) // 奇偶校验 - 只允许奇数通过 + .forEach(System.out::println); // 打印每个值 +``` + +`IntStream` 类型包括一个 `range` 函数,该函数在指定的范围内生成一个整数值流,在本例中,以 1 为增量,从 1 递增到 2048。`parallel` 函数自动划分该工作到多个线程中,在各个线程中进行过滤和打印。(线程数通常与主机系统上的 CPU 数量匹配。)函数 `forEach` 参数是一个*方法引用*,在本例中是对封装在 `System.out` 中的 `println` 方法的引用,方法输出类型为 `PrintStream`。方法和构造器引用的语法将在稍后讨论。 + +由于具有多线程,因此整数值整体上以任意顺序打印,但在给定线程中是按顺序打印的。例如,如果线程 T1 打印 409 和 411,那么 T1 将按照顺序 409-411 打印,但是其它某个线程可能会预先打印 2045。`parallel` 调用后面的线程是并发执行的,因此它们的输出顺序是不确定的。 + +### map/reduce 模式 + +*map/reduce* 模式在处理大型数据集方面变得很流行。一个 map/reduce 宏操作由两个微操作构成。首先,将数据分散(映射mapped)到各个工作程序中,然后将单独的结果收集在一起 —— 也可能收集统计起来成为一个值,即归约reduction。归约可以采用不同的形式,如以下示例所示。 + +下面 `Number` 类的实例用 `EVEN` 或 `ODD` 表示有奇偶校验的整数值: + +``` +public class Number { + enum Parity { EVEN, ODD } + private int value; + public Number(int n) { setValue(n); } + public void setValue(int value) { this.value = value; } + public int getValue() { return this.value; } + public Parity getParity() { + return ((value & 0x1) == 0) ? Parity.EVEN : Parity.ODD; + } + public void dump() { + System.out.format("Value: %2d (parity: %s)\n", getValue(), + (getParity() == Parity.ODD ? "odd" : "even")); + } +} +``` + +下面的代码演示了用 `Number` 流进行 map/reduce 的情形,从而表明流 API 不仅可以处理 `int` 和 `float` 等基本类型,还可以处理程序员自定义的类类型。 + +在下面的代码段中,使用了 `parallelStream` 而不是 `stream` 函数对随机整数值列表进行流化处理。与前面介绍的 `parallel` 函数一样,`parallelStream` 变体也可以自动执行多线程。 + +``` +final int howMany = 200; +Random r = new Random(); +Number[] nums = new Number[howMany]; +for (int i = 0; i < howMany; i++) nums[i] = new Number(r.nextInt(100)); +List listOfNums = Arrays.asList(nums); // 将数组转化为 list + +Integer sum4All = listOfNums + .parallelStream() // 自动执行多线程 + .mapToInt(Number::getValue) // 使用方法引用,而不是 lambda + .sum(); // 将流值计算出和值 +System.out.println("The sum of the randomly generated values is: " + sum4All); +``` + +高阶的 `mapToInt` 函数可以接受一个 lambda 作为参数,但在本例中,它接受一个方法引用,即 `Number::getValue`。`getValue` 方法不需要参数,它返回给定的 `Number` 实例的 `int` 值。语法并不复杂:类名 `Number` 后跟一个双冒号和方法名。回想一下先前的例子 `System.out::println`,它在 `System` 类中的 `static` 属性 `out` 后面有一个双冒号。 + +方法引用 `Number::getValue` 可以用下面的 lambda 表达式替换。参数 `n` 是流中的 `Number` 实例中的之一: + +``` +mapToInt(n -> n.getValue()) +``` + +通常,lambda 表达式和方法引用是可互换的:如果像 `mapToInt` 这样的高阶函数可以采用一种形式作为参数,那么这个函数也可以采用另一种形式。这两个函数式编程结构具有相同的目的 —— 对作为参数传入的数据执行一些自定义操作。在两者之间进行选择通常是为了方便。例如,lambda 可以在没有封装类的情况下编写,而方法则不能。我的习惯是使用 lambda,除非已经有了适当的封装方法。 + +当前示例末尾的 `sum` 函数通过结合来自 `parallelStream` 线程的部分和,以线程安全的方式进行归约。但是,程序员有责任确保在 `parallelStream` 调用引发的多线程过程中,程序员自己的函数调用(在本例中为 `getValue`)是线程安全的。 + +最后一点值得强调。lambda 语法鼓励编写纯函数pure function,即函数的返回值仅取决于传入的参数(如果有);纯函数没有副作用,例如更新一个类中的 `static` 字段。因此,纯函数是线程安全的,并且如果传递给高阶函数的函数参数(例如 `filter` 和 `map` )是纯函数,则流 API 效果最佳。 + +对于更细粒度的控制,有另一个流 API 函数,名为 `reduce`,可用于对 `Number` 流中的值求和: + +``` +Integer sum4AllHarder = listOfNums + .parallelStream() // 多线程 + .map(Number::getValue) // 每个 Number 的值 + .reduce(0, (sofar, next) -> sofar + next); // 求和 +``` + +此版本的 `reduce` 函数带有两个参数,第二个参数是一个函数: + +- 第一个参数(在这种情况下为零)是*特征*值,该值用作求和操作的初始值,并且在求和过程中流结束时用作默认值。 +- 第二个参数是*累加器*,在本例中,这个 lambda 表达式有两个参数:第一个参数(`sofar`)是正在运行的和,第二个参数(`next`)是来自流的下一个值。运行的和以及下一个值相加,然后更新累加器。请记住,由于开始时调用了 `parallelStream`,因此 `map` 和 `reduce` 函数现在都在多线程上下文中执行。 + +在到目前为止的示例中,流值被收集,然后被规约,但是,通常情况下,流 API 中的 `Collectors` 可以累积值,而不需要将它们规约到单个值。正如下一个代码段所示,收集活动可以生成任意丰富的数据结构。该示例使用与前面示例相同的 `listOfNums`: + +``` +Map> numMap = listOfNums + .parallelStream() + .collect(Collectors.groupingBy(Number::getParity)); + +List evens = numMap.get(Number.Parity.EVEN); +List odds = numMap.get(Number.Parity.ODD); +``` + +第一行中的 `numMap` 指的是一个 `Map`,它的键是一个 `Number` 奇偶校验位(`ODD` 或 `EVEN`),其值是一个具有指定奇偶校验位值的 `Number` 实例的 `List`。同样,通过 `parallelStream` 调用进行多线程处理,然后 `collect` 调用(以线程安全的方式)将部分结果组装到 `numMap` 引用的 `Map` 中。然后,在 `numMap` 上调用 `get` 方法两次,一次获取 `evens`,第二次获取 `odds`。 + +实用函数 `dumpList` 再次使用来自流 API 的高阶 `forEach` 函数: + +``` +private void dumpList(String msg, List list) { + System.out.println("\n" + msg); + list.stream().forEach(n -> n.dump()); // 或者使用 forEach(Number::dump) +} +``` + +这是示例运行中程序输出的一部分: + +``` +The sum of the randomly generated values is: 3322 +The sum again, using a different method: 3322 + +Evens: + +Value: 72 (parity: even) +Value: 54 (parity: even) +... +Value: 92 (parity: even) + +Odds: + +Value: 35 (parity: odd) +Value: 37 (parity: odd) +... +Value: 41 (parity: odd) +``` + +### 用于代码简化的函数式结构 + +函数式结构(如方法引用和 lambda 表达式)非常适合在流 API 中使用。这些构造代表了 Java 中对高阶函数的主要简化。即使在糟糕的过去,Java 也通过 `Method` 和 `Constructor` 类型在技术上支持高阶函数,这些类型的实例可以作为参数传递给其它函数。由于其复杂性,这些类型在生产级 Java 中很少使用。例如,调用 `Method` 需要对象引用(如果方法是非**静态**的)或至少一个类标识符(如果方法是**静态**的)。然后,被调用的 `Method` 的参数作为**对象**实例传递给它,如果没有发生多态(那会出现另一种复杂性!),则可能需要显式向下转换。相比之下,lambda 和方法引用很容易作为参数传递给其它函数。 + +但是,新的函数式结构在流 API 之外具有其它用途。考虑一个 Java GUI 程序,该程序带有一个供用户按下的按钮,例如,按下以获取当前时间。按钮按下的事件处理程序可能编写如下: + +``` +JButton updateCurrentTime = new JButton("Update current time"); +updateCurrentTime.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + currentTime.setText(new Date().toString()); + } +}); +``` + +这个简短的代码段很难解释。关注第二行,其中方法 `addActionListener` 的参数开始如下: + +``` +new ActionListener() { +``` + +这似乎是错误的,因为 `ActionListener` 是一个**抽象**接口,而**抽象**类型不能通过调用 `new` 实例化。但是,事实证明,还有其它一些实例被实例化了:一个实现此接口的未命名内部类。如果上面的代码封装在名为 `OldJava` 的类中,则该未命名的内部类将被编译为 `OldJava$1.class`。`actionPerformed` 方法在这个未命名的内部类中被重写。 + +现在考虑使用新的函数式结构进行这个令人耳目一新的更改: + +``` +updateCurrentTime.addActionListener(e -> currentTime.setText(new Date().toString())); +``` + +lambda 表达式中的参数 `e` 是一个 `ActionEvent` 实例,而 lambda 的主体是对按钮上的 `setText` 的简单调用。 + +### 函数式接口和函数组合 + +到目前为止,使用的 lambda 已经写好了。但是,为了方便起见,我们可以像引用封装方法一样引用 lambda 表达式。以下一系列简短示例说明了这一点。 + +考虑以下接口定义: + +``` +@FunctionalInterface // 可选,通常省略 +interface BinaryIntOp { + abstract int compute(int arg1, int arg2); // abstract 声明可以被删除 +} +``` + +注释 `@FunctionalInterface` 适用于声明*唯一*抽象方法的任何接口;在本例中,这个抽象接口是 `compute`。一些标准接口,(例如具有唯一声明方法 `run` 的 `Runnable` 接口)同样符合这个要求。在此示例中,`compute` 是已声明的方法。该接口可用作引用声明中的目标类型: + +``` +BinaryIntOp div = (arg1, arg2) -> arg1 / arg2; +div.compute(12, 3); // 4 +``` + +包 `java.util.function` 提供各种函数式接口。以下是一些示例。 + +下面的代码段介绍了参数化的 `Predicate` 函数式接口。在此示例中,带有参数 `String` 的 `Predicate` 类型可以引用具有 `String` 参数的 lambda 表达式或诸如 `isEmpty` 之类的 `String` 方法。通常情况下,Predicate 是一个返回布尔值的函数。 + +``` +Predicate pred = String::isEmpty; // String 方法的 predicate 声明 +String[] strings = {"one", "two", "", "three", "four"}; +Arrays.asList(strings) + .stream() + .filter(pred) // 过滤掉非空字符串 + .forEach(System.out::println); // 只打印空字符串 +``` + +在字符串长度为零的情况下,`isEmpty` Predicate 判定结果为 `true`。 因此,只有空字符串才能进入管道的 `forEach` 阶段。 + +下一段代码将演示如何将简单的 lambda 或方法引用组合成更丰富的 lambda 或方法引用。考虑这一系列对 `IntUnaryOperator` 类型的引用的赋值,它接受一个整型参数并返回一个整型值: + +``` +IntUnaryOperator doubled = n -> n * 2; +IntUnaryOperator tripled = n -> n * 3; +IntUnaryOperator squared = n -> n * n; +``` + +`IntUnaryOperator` 是一个 `FunctionalInterface`,其唯一声明的方法为 `applyAsInt`。现在可以单独使用或以各种组合形式使用这三个引用 `doubled`、`tripled` 和 `squared`: + +``` +int arg = 5; +doubled.applyAsInt(arg); // 10 +tripled.applyAsInt(arg); // 15 +squared.applyAsInt(arg); // 25 +``` + +以下是一些函数组合的样例: + +``` +int arg = 5; +doubled.compose(squared).applyAsInt(arg); // 5 求 2 次方后乘 2:50 +tripled.compose(doubled).applyAsInt(arg); // 5 乘 2 后再乘 3:30 +doubled.andThen(squared).applyAsInt(arg); // 5 乘 2 后求 2 次方:100 +squared.andThen(tripled).applyAsInt(arg); // 5 求 2 次方后乘 3:75 +``` + +函数组合可以直接使用 lambda 表达式实现,但是引用使代码更简洁。 + +### 构造器引用 + +构造器引用是另一种函数式编程构造,而这些引用在比 lambda 和方法引用更微妙的上下文中非常有用。再一次重申,代码示例似乎是最好的解释方式。 + +考虑这个 [POJO][13] 类: + +``` +public class BedRocker { // 基岩的居民 + private String name; + public BedRocker(String name) { this.name = name; } + public String getName() { return this.name; } + public void dump() { System.out.println(getName()); } +} +``` + +该类只有一个构造函数,它需要一个 `String` 参数。给定一个名字数组,目标是生成一个 `BedRocker` 元素数组,每个名字代表一个元素。下面是使用了函数式结构的代码段: + +``` +String[] names = {"Fred", "Wilma", "Peebles", "Dino", "Baby Puss"}; + +Stream bedrockers = Arrays.asList(names).stream().map(BedRocker::new); +BedRocker[] arrayBR = bedrockers.toArray(BedRocker[]::new); + +Arrays.asList(arrayBR).stream().forEach(BedRocker::dump); +``` + +在较高的层次上,这个代码段将名字转换为 `BedRocker` 数组元素。具体来说,代码如下所示。`Stream` 接口(在包 `java.util.stream` 中)可以被参数化,而在本例中,生成了一个名为 `bedrockers` 的 `BedRocker` 流。 + +`Arrays.asList` 实用程序再次用于流化一个数组 `names`,然后将流的每一项传递给 `map` 函数,该函数的参数现在是构造器引用 `BedRocker::new`。这个构造器引用通过在每次调用时生成和初始化一个 `BedRocker` 实例来充当一个对象工厂。在第二行执行之后,名为 `bedrockers` 的流由五项 `BedRocker` 组成。 + +这个例子可以通过关注高阶 `map` 函数来进一步阐明。在通常情况下,一个映射将一个类型的值(例如,一个 `int`)转换为另一个*相同*类型的值(例如,一个整数的后继): + +``` +map(n -> n + 1) // 将 n 映射到其后继 +``` + +然而,在 `BedRocker` 这个例子中,转换更加戏剧化,因为一个类型的值(代表一个名字的 `String`)被映射到一个*不同*类型的值,在这个例子中,就是一个 `BedRocker` 实例,这个字符串就是它的名字。转换是通过一个构造器调用来完成的,它是由构造器引用来实现的: + +``` +map(BedRocker::new) // 将 String 映射到 BedRocker +``` + +传递给构造器的值是 `names` 数组中的其中一项。 + +此代码示例的第二行还演示了一个你目前已经非常熟悉的转换:先将数组先转换成 `List`,然后再转换成 `Stream`: + +``` +Stream bedrockers = Arrays.asList(names).stream().map(BedRocker::new); +``` + +第三行则是另一种方式 —— 流 `bedrockers` 通过使用*数组*构造器引用 `BedRocker[]::new` 调用 `toArray` 方法: + +``` +BedRocker[ ] arrayBR = bedrockers.toArray(BedRocker[]::new); +``` + +该构造器引用不会创建单个 `BedRocker` 实例,而是创建这些实例的整个数组:该构造器引用现在为 `BedRocker[]:new`,而不是 `BedRocker::new`。为了进行确认,将 `arrayBR` 转换为 `List`,再次对其进行流式处理,以便可以使用 `forEach` 来打印 `BedRocker` 的名字。 + +``` +Fred +Wilma +Peebles +Dino +Baby Puss +``` + +该示例对数据结构的微妙转换仅用几行代码即可完成,从而突出了可以将 lambda,方法引用或构造器引用作为参数的各种高阶函数的功能。 + +### 柯里化Currying + +*柯里化*函数是指减少函数执行任何工作所需的显式参数的数量(通常减少到一个)。(该术语是为了纪念逻辑学家 Haskell Curry。)一般来说,函数的参数越少,调用起来就越容易,也更健壮。(回想一下一些需要半打左右参数的噩梦般的函数!)因此,应将柯里化视为简化函数调用的一种尝试。`java.util.function` 包中的接口类型适合于柯里化,如以下示例所示。 + +引用的 `IntBinaryOperator` 接口类型是为函数接受两个整型参数,并返回一个整型值: + +``` +IntBinaryOperator mult2 = (n1, n2) -> n1 * n2; +mult2.applyAsInt(10, 20); // 200 +mult2.applyAsInt(10, 30); // 300 +``` + +引用 `mult2` 强调了需要两个显式参数,在本例中是 10 和 20。 + +前面介绍的 `IntUnaryOperator` 比 `IntBinaryOperator` 简单,因为前者只需要一个参数,而后者则需要两个参数。两者均返回整数值。因此,目标是将名为 `mult2` 的两个参数 `IntBinraryOperator` 柯里化成一个单一的 `IntUnaryOperator` 版本 `curriedMult2`。 + +考虑 `IntFunction` 类型。此类型的函数采用整型参数,并返回类型为 `R` 的结果,该结果可以是另一个函数 —— 更准确地说,是 `IntBinaryOperator`。让一个 lambda 返回另一个 lambda 很简单: + +``` +arg1 -> (arg2 -> arg1 * arg2) // 括号可以省略 +``` + +完整的 lambda 以 `arg1` 开头,而该 lambda 的主体以及返回的值是另一个以 `arg2` 开头的 lambda。返回的 lambda 仅接受一个参数(`arg2`),但返回了两个数字的乘积(`arg1` 和 `arg2`)。下面的概述,再加上代码,应该可以更好地进行说明。 + +以下是如何柯里化 `mult2` 的概述: + +- 类型为 `IntFunction` 的 lambda 被写入并调用,其整型值为 10。返回的 `IntUnaryOperator` 缓存了值 10,因此变成了已柯里化版本的 `mult2`,在本例中为 `curriedMult2`。 +- 然后使用单个显式参数(例如,20)调用 `curriedMult2` 函数,该参数与缓存的参数(在本例中为 10)相乘以生成返回的乘积。。 + +这是代码的详细信息: + +``` +// 创建一个接受一个参数 n1 并返回一个单参数 n2 -> n1 * n2 的函数,该函数返回一个(n1 * n2 乘积的)整型数。 +IntFunction curriedMult2Maker = n1 -> (n2 -> n1 * n2); +``` + +调用 `curriedMult2Maker` 生成所需的 `IntUnaryOperator` 函数: + +``` +// 使用 curriedMult2Maker 获取已柯里化版本的 mult2。 +// 参数 10 是上面的 lambda 的 n1。 +IntUnaryOperator curriedMult2 = curriedMult2Maker2.apply(10); +``` + +值 `10` 现在缓存在 `curriedMult2` 函数中,以便 `curriedMult2` 调用中的显式整型参数乘以 10: + +``` +curriedMult2.applyAsInt(20); // 200 = 10 * 20 +curriedMult2.applyAsInt(80); // 800 = 10 * 80 +``` + +缓存的值可以随意更改: + +``` +curriedMult2 = curriedMult2Maker.apply(50); // 缓存 50 +curriedMult2.applyAsInt(101); // 5050 = 101 * 50 +``` + +当然,可以通过这种方式创建多个已柯里化版本的 `mult2`,每个版本都有一个 `IntUnaryOperator`。 + +柯里化充分利用了 lambda 的强大功能:可以很容易地编写 lambda 表达式来返回需要的任何类型的值,包括另一个 lambda。 + +### 总结 + +Java 仍然是基于类的面向对象的编程语言。但是,借助流 API 及其支持的函数式构造,Java 向函数式语言(例如 Lisp)迈出了决定性的(同时也是受欢迎的)一步。结果是 Java 更适合处理现代编程中常见的海量数据流。在函数式方向上的这一步还使以在前面的代码示例中突出显示的管道的方式编写清晰简洁的 Java 代码更加容易: + +``` +dataStream + .parallelStream() // 多线程以提高效率 + .filter(...) // 阶段 1 + .map(...) // 阶段 2 + .filter(...) // 阶段 3 + ... + .collect(...); // 或者,也可以进行归约:阶段 N +``` + +自动多线程,以 `parallel` 和 `parallelStream` 调用为例,建立在 Java 的 fork/join 框架上,该框架支持 任务窃取task stealing 以提高效率。假设 `parallelStream` 调用后面的线程池由八个线程组成,并且 `dataStream` 被八种方式分区。某个线程(例如,T1)可能比另一个线程(例如,T7)工作更快,这意味着应该将 T7 的某些任务移到 T1 的工作队列中。这会在运行时自动发生。 + +在这个简单的多线程世界中,程序员的主要职责是编写线程安全函数,这些函数作为参数传递给在流 API 中占主导地位的高阶函数。尤其是 lambda 鼓励编写纯函数(因此是线程安全的)函数。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/javastream + +作者:[Marty Kalin][a] +选题:[lujun9972][b] +译者:[laingke](https://github.com/laingke) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mkalindepauledu +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/features_solutions_command_data.png?itok=4_VQN3RK (computer screen ) +[2]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+random +[3]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+list +[4]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system +[5]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+number +[6]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+arrays +[7]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+integer +[8]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string +[9]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+jbutton +[10]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+actionlistener +[11]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+actionevent +[12]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+date +[13]: https://en.wikipedia.org/wiki/Plain_old_Java_object diff --git a/published/202002/20200103 Add scorekeeping to your Python game.md b/published/202002/20200103 Add scorekeeping to your Python game.md new file mode 100644 index 0000000000..62fa3fe600 --- /dev/null +++ b/published/202002/20200103 Add scorekeeping to your Python game.md @@ -0,0 +1,626 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11839-1.html) +[#]: subject: (Add scorekeeping to your Python game) +[#]: via: (https://opensource.com/article/20/1/add-scorekeeping-your-python-game) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +添加计分到你的 Python 游戏 +====== + +> 在本系列的第十一篇有关使用 Python Pygame 模块进行编程的文章中,显示玩家获得战利品或受到伤害时的得分。 + +![](https://img.linux.net.cn/data/attachment/album/202002/01/154838led0y08y2aqetz1q.jpg) + +这是仍在进行中的关于使用 [Pygame][3] 模块来在 [Python 3][2] 在创建电脑游戏的第十一部分。先前的文章是: + + * [通过构建一个简单的掷骰子游戏去学习怎么用 Python 编程][4] + * [使用 Python 和 Pygame 模块构建一个游戏框架][5] + * [如何在你的 Python 游戏中添加一个玩家][6] + * [用 Pygame 使你的游戏角色移动起来][7] + * [如何向你的 Python 游戏中添加一个敌人][8] + * [在 Pygame 游戏中放置平台][19] + * [在你的 Python 游戏中模拟引力][9] + * [为你的 Python 平台类游戏添加跳跃功能][10] + * [使你的 Python 游戏玩家能够向前和向后跑][11] + * [在你的 Python 平台类游戏中放一些奖励][12] + +如果你已经跟随这一系列很久,那么已经学习了使用 Python 创建一个视频游戏所需的所有基本语法和模式。然而,它仍然缺少一个至关重要的组成部分。这一组成部分不仅仅对用 Python 编程游戏重要;不管你探究哪个计算机分支,你都必需精通:作为一个程序员,通过阅读一种语言的或库的文档来学习新的技巧。 + +幸运的是,你正在阅读本文的事实表明你熟悉文档。为了使你的平台类游戏更加美观,在这篇文章中,你将在游戏屏幕上添加得分和生命值显示。不过,教你如何找到一个库的功能以及如何使用这些新的功能的这节课程并没有多神秘。 + +### 在 Pygame 中显示得分 + +现在,既然你有了可以被玩家收集的奖励,那就有充分的理由来记录分数,以便你的玩家看到他们收集了多少奖励。你也可以跟踪玩家的生命值,以便当他们被敌人击中时会有相应结果。 + +你已经有了跟踪分数和生命值的变量,但是这一切都发生在后台。这篇文章教你在游戏期间在游戏屏幕上以你选择的一种字体来显示这些统计数字。 + +### 阅读文档 + +大多数 Python 模块都有文档,即使那些没有文档的模块,也能通过 Python 的帮助功能来进行最小的文档化。[Pygame 的主页面][13] 链接了它的文档。不过,Pygame 是一个带有很多文档的大模块,并且它的文档不像在 Opensource.com 上的文章一样,以同样易理解的(和友好的、易解释的、有用的)叙述风格来撰写的。它们是技术文档,并且列出在模块中可用的每个类和函数,各自要求的输入类型等等。如果你不适应参考代码组件描述,这可能会令人不知所措。 + +在烦恼于库的文档前,第一件要做的事,就是来想想你正在尝试达到的目标。在这种情况下,你想在屏幕上显示玩家的得分和生命值。 + +在你确定你需要的结果后,想想它需要什么的组件。你可以从变量和函数的方面考虑这一点,或者,如果你还没有自然地想到这一点,你可以进行一般性思考。你可能意识到需要一些文本来显示一个分数,你希望 Pygame 在屏幕上绘制这些文本。如果你仔细思考,你可能会意识到它与在屏幕上渲染一个玩家、奖励或一个平台并多么大的不同。 + +从技术上讲,你*可以*使用数字图形,并让 Pygame 显示这些数字图形。它不是达到你目标的最容易的方法,但是如果它是你唯一知道的方法,那么它是一个有效的方法。不过,如果你参考 Pygame 的文档,你看到列出的模块之一是 `font`,这是 Pygame 使得在屏幕上来使打印文本像输入文字一样容易的方法。 + +### 解密技术文档 + +`font` 文档页面以 `pygame.font.init()` 开始,它列出了用于初始化字体模块的函数。它由 `pygame.init()` 自动地调用,你已经在代码中调用了它。再强调一次,从技术上讲,你已经到达一个*足够好*的点。虽然你尚不知道*如何做*,你知道你*能够*使用 `pygame.font` 函数来在屏幕上打印文本。 + +然而,如果你阅读更多一些,你会找到这里还有一种更好的方法来打印字体。`pygame.freetype` 模块在文档中的描述方式如下: + +> `pygame.freetype` 模块是 `pygame.fontpygame` 模块的一个替代品,用于加载和渲染字体。它有原函数的所有功能,外加很多新的功能。 + +在 `pygame.freetype` 文档页面的下方,有一些示例代码: + +``` +import pygame +import pygame.freetype +``` + +你的代码应该已经导入了 Pygame,不过,请修改你的 `import` 语句以包含 Freetype 模块: + +``` +import pygame +import sys +import os +import pygame.freetype +``` + +### 在 Pygame 中使用字体 + +从 `font` 模块的描述中可以看出,显然 Pygame 使用一种字体(不管它的你提供的或内置到 Pygame 的默认字体)在屏幕上渲染字体。滚动浏览 `pygame.freetype` 文档来找到 `pygame.freetype.Font` 函数: + +``` +pygame.freetype.Font +从支持的字体文件中创建一个新的字体实例。 + +Font(file, size=0, font_index=0, resolution=0, ucs4=False) -> Font + +pygame.freetype.Font.name +  符合规则的字体名称。 + +pygame.freetype.Font.path +  字体文件路径。 + +pygame.freetype.Font.size +  在渲染中使用的默认点大小 +``` + +这描述了如何在 Pygame 中构建一个字体“对象”。把屏幕上的一个简单对象视为一些代码属性的组合对你来说可能不太自然,但是这与你构建英雄和敌人精灵的方式非常类似。你需要一个字体文件,而不是一个图像文件。在你有一个字体文件后,你可以在你的代码中使用 `pygame.freetype.Font` 函数来创建一个字体对象,然后使用该对象来在屏幕上渲染文本。 + +因为并不是世界上的每个人的电脑上都有完全一样的字体,因此将你选择的字体与你的游戏捆绑在一起是很重要的。要捆绑字体,首先在你的游戏文件夹中创建一个新的目录,放在你为图像而创建的文件目录旁边。称其为 `fonts` 。 + +即使你的计算机操作系统随附了几种字体,但是将这些字体给予其他人是非法的。这看起来很奇怪,但法律就是这样运作的。如果想与你的游戏一起随附一种字体,你必需找到一种开源或知识共享的字体,以允许你随游戏一起提供该字体。 + +专门提供自由和合法字体的网站包括: + + * [Font Library][14] + * [Font Squirrel][15] + * [League of Moveable Type][16] + +当你找到你喜欢的字体后,下载下来。解压缩 ZIP 或 [TAR][17] 文件,并移动 `.ttf` 或 `.otf` 文件到你的项目目录下的 `fonts` 文件夹中。 + +你没有安装字体到你的计算机上。你只是放置字体到你游戏的 `fonts` 文件夹中,以便 Pygame 可以使用它。如果你想,你*可以*在你的计算机上安装该字体,但是没有必要。重要的是将字体放在你的游戏目录中,这样 Pygame 可以“描绘”字体到屏幕上。 + +如果字体文件的名称复杂且带有空格或特殊字符,只需要重新命名它即可。文件名称是完全任意的,并且对你来说,文件名称越简单,越容易将其键入你的代码中。 + +现在告诉 Pygame 你的字体。从文档中你知道,当你至少提供了字体文件路径给 `pygame.freetype.Font` 时(文档明确指出所有其余属性都是可选的),你将在返回中获得一个字体对象: + +``` +Font(file, size=0, font_index=0, resolution=0, ucs4=False) -> Font +``` + +创建一个称为 `myfont` 的新变量来充当你在游戏中字体,并放置 `Font` 函数的结果到这个变量中。这个示例中使用 `amazdoom.ttf` 字体,但是你可以使用任何你想使用的字体。在你的设置部分放置这些代码: + +``` +font_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),"fonts","amazdoom.ttf") +font_size = tx +myfont = pygame.freetype.Font(font_path, font_size) +``` + +### 在 Pygame 中显示文本 + +现在你已经创建一个字体对象,你需要一个函数来绘制你想绘制到屏幕上的文本。这和你在你的游戏中绘制背景和平台是相同的原理。 + +首先,创建一个函数,并使用 `myfont` 对象来创建一些文本,设置颜色为某些 RGB 值。这必须是一个全局函数;它不属于任何具体的类: + +``` +def stats(score,health): +    myfont.render_to(world, (4, 4), "Score:"+str(score), WHITE, None, size=64) +    myfont.render_to(world, (4, 72), "Health:"+str(health), WHITE, None, size=64) +``` + +当然,你此刻已经知道,如果它不在主循环中,你的游戏将不会发生任何事,所以在文件的底部添加一个对你的 `stats` 函数的调用: + +``` +    for e in enemy_list: +        e.move() +    stats(player.score,player.health) # draw text +    pygame.display.flip() +``` + +尝试你的游戏。 + +当玩家收集奖励品时,得分会上升。当玩家被敌人击中时,生命值下降。成功! + +![Keeping score in Pygame][18] + +不过,这里有一个问题。当一个玩家被敌人击中时,健康度会*一路*下降,这是不公平的。你刚刚发现一个非致命的错误。非致命的错误是这些在应用程序中小问题,(通常)不会阻止应用程序启动或甚至导致停止工作,但是它们要么没有意义,要么会惹恼用户。这里是如何解决这个问题的方法。 + +### 修复生命值计数 + +当前生命值系统的问题是,敌人接触玩家时,Pygame 时钟的每一次滴答,健康度都会减少。这意味着一个缓慢移动的敌人可能在一次遭遇中将一个玩家降低健康度至 -200 ,这不公平。当然,你可以给你的玩家一个 10000 的起始健康度得分,而不用担心它;这可以工作,并且可能没有人会注意。但是这里有一个更好的方法。 + +当前,你的代码侦查出一个玩家和一个敌人发生碰撞的时候。生命值问题的修复是检测*两个*独立的事件:什么时候玩家和敌人碰撞,并且,在它们碰撞后,什么时候它们*停止*碰撞。 + +首先,在你的玩家类中,创建一个变量来代表玩家和敌人碰撞在一起: + +``` +        self.frame = 0 +        self.health = 10 +        self.damage = 0 +``` + +在你的 `Player` 类的 `update` 函数中,*移除*这块代码块: + +``` +        for enemy in enemy_hit_list: +            self.health -= 1 +            #print(self.health) +``` + +并且在它的位置,只要玩家当前没有被击中,检查碰撞: + +``` +        if self.damage == 0: +            for enemy in enemy_hit_list: +                if not self.rect.contains(enemy): +                    self.damage = self.rect.colliderect(enemy) +``` + +你可能会在你删除的语句块和你刚刚添加的语句块之间看到相似之处。它们都在做相同的工作,但是新的代码更复杂。最重要的是,只有当玩家*当前*没有被击中时,新的代码才运行。这意味着,当一个玩家和敌人碰撞时,这些代码运行一次,而不是像以前那样一直发生碰撞。 + +新的代码使用两个新的 Pygame 函数。`self.rect.contains` 函数检查一个敌人当前是否在玩家的边界框内,并且当它是 `true` 时, `self.rect.colliderect` 设置你的新的 `self.damage` 变量为 1,而不管它多少次是 `true` 。 + +现在,即使被一个敌人击中 3 秒,对 Pygame 来说仍然看作一次击中。 + +我通过通读 Pygame 的文档而发现了这些函数。你没有必要一次阅读完全部的文档,并且你也没有必要阅读每个函数的每个单词。不过,花费时间在你正在使用的新的库或模块的文档上是很重要的;否则,你极有可能在重新发明轮子。不要花费一个下午的时间来尝试修改拼接一个解决方案到一些东西,而这些东西已经被你正在使用的框架的所解决。阅读文档,知悉函数,并从别人的工作中获益! + +最后,添加另一个代码语句块来侦查出什么时候玩家和敌人不再接触。然后直到那时,才从玩家减少一个生命值。 + +``` +        if self.damage == 1: +            idx = self.rect.collidelist(enemy_hit_list) +            if idx == -1: +                self.damage = 0   # set damage back to 0 +                self.health -= 1  # subtract 1 hp +``` + +注意,*只有*当玩家被击中时,这个新的代码才会被触发。这意味着,在你的玩家在你的游戏世界正在探索或收集奖励时,这个代码不会运行。它仅当 `self.damage` 变量被激活时运行。 + +当代码运行时,它使用 `self.rect.collidelist` 来查看玩家是否*仍然*接触在你敌人列表中的敌人(当其未侦查到碰撞时,`collidelist` 返回 -1)。在它没有接触敌人时,是该处理 `self.damage` 的时机:通过设置 `self.damage` 变量回到 0 来使其无效,并减少一点生命值。 + +现在尝试你的游戏。 + +### 得分反应 + +现在,你有一个来让你的玩家知道它们分数和生命值的方法,当你的玩家达到某些里程碑时,你可以确保某些事件发生。例如,也许这里有一个特殊的恢复一些生命值的奖励项目。也许一个到达 0 生命值的玩家不得不从一个关卡的起始位置重新开始。 + +你可以在你的代码中检查这些事件,并且相应地操纵你的游戏世界。你已经知道该怎么做,所以请浏览文档来寻找新的技巧,并且独立地尝试这些技巧。 + +这里是到目前为止所有的代码: + +``` +#!/usr/bin/env python3 +# draw a world +# add a player and player control +# add player movement +# add enemy and basic collision +# add platform +# add gravity +# add jumping +# add scrolling +# add loot +# add score + +# GNU All-Permissive License +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. + +import pygame +import sys +import os +import pygame.freetype + +''' +Objects +''' + +class Platform(pygame.sprite.Sprite): + # x location, y location, img width, img height, img file + def __init__(self,xloc,yloc,imgw,imgh,img): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(os.path.join('images',img)).convert() + self.image.convert_alpha() + self.rect = self.image.get_rect() + self.rect.y = yloc + self.rect.x = xloc + +class Player(pygame.sprite.Sprite): + ''' + Spawn a player + ''' + def __init__(self): + pygame.sprite.Sprite.__init__(self) + self.movex = 0 + self.movey = 0 + self.frame = 0 + self.health = 10 + self.damage = 0 + self.collide_delta = 0 + self.jump_delta = 6 + self.score = 1 + self.images = [] + for i in range(1,9): + img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert() + img.convert_alpha() + img.set_colorkey(ALPHA) + self.images.append(img) + self.image = self.images[0] + self.rect = self.image.get_rect() + + def jump(self,platform_list): + self.jump_delta = 0 + + def gravity(self): + self.movey += 3.2 # how fast player falls + + if self.rect.y > worldy and self.movey >= 0: + self.movey = 0 + self.rect.y = worldy-ty + + def control(self,x,y): + ''' + control player movement + ''' + self.movex += x + self.movey += y + + def update(self): + ''' + Update sprite position + ''' + + self.rect.x = self.rect.x + self.movex + self.rect.y = self.rect.y + self.movey + + # moving left + if self.movex < 0: + self.frame += 1 + if self.frame > ani*3: + self.frame = 0 + self.image = self.images[self.frame//ani] + + # moving right + if self.movex > 0: + self.frame += 1 + if self.frame > ani*3: + self.frame = 0 + self.image = self.images[(self.frame//ani)+4] + + # collisions + enemy_hit_list = pygame.sprite.spritecollide(self, enemy_list, False) + if self.damage == 0: + for enemy in enemy_hit_list: + if not self.rect.contains(enemy): + self.damage = self.rect.colliderect(enemy) + + if self.damage == 1: + idx = self.rect.collidelist(enemy_hit_list) + if idx == -1: + self.damage = 0 # set damage back to 0 + self.health -= 1 # subtract 1 hp + + loot_hit_list = pygame.sprite.spritecollide(self, loot_list, False) + for loot in loot_hit_list: + loot_list.remove(loot) + self.score += 1 + print(self.score) + + plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) + for p in plat_hit_list: + self.collide_delta = 0 # stop jumping + self.movey = 0 + if self.rect.y > p.rect.y: + self.rect.y = p.rect.y+ty + else: + self.rect.y = p.rect.y-ty + + ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) + for g in ground_hit_list: + self.movey = 0 + self.rect.y = worldy-ty-ty + self.collide_delta = 0 # stop jumping + if self.rect.y > g.rect.y: + self.health -=1 + print(self.health) + + if self.collide_delta < 6 and self.jump_delta < 6: + self.jump_delta = 6*2 + self.movey -= 33 # how high to jump + self.collide_delta += 6 + self.jump_delta += 6 + +class Enemy(pygame.sprite.Sprite): + ''' + Spawn an enemy + ''' + def __init__(self,x,y,img): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(os.path.join('images',img)) + self.movey = 0 + #self.image.convert_alpha() + #self.image.set_colorkey(ALPHA) + self.rect = self.image.get_rect() + self.rect.x = x + self.rect.y = y + self.counter = 0 + + + def move(self): + ''' + enemy movement + ''' + distance = 80 + speed = 8 + + self.movey += 3.2 + + if self.counter >= 0 and self.counter <= distance: + self.rect.x += speed + elif self.counter >= distance and self.counter <= distance*2: + self.rect.x -= speed + else: + self.counter = 0 + + self.counter += 1 + + if not self.rect.y >= worldy-ty-ty: + self.rect.y += self.movey + + plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) + for p in plat_hit_list: + self.movey = 0 + if self.rect.y > p.rect.y: + self.rect.y = p.rect.y+ty + else: + self.rect.y = p.rect.y-ty + + ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) + for g in ground_hit_list: + self.rect.y = worldy-ty-ty + + +class Level(): + def bad(lvl,eloc): + if lvl == 1: + enemy = Enemy(eloc[0],eloc[1],'yeti.png') # spawn enemy + enemy_list = pygame.sprite.Group() # create enemy group + enemy_list.add(enemy) # add enemy to group + + if lvl == 2: + print("Level " + str(lvl) ) + + return enemy_list + + def loot(lvl,tx,ty): + if lvl == 1: + loot_list = pygame.sprite.Group() + loot = Platform(200,ty*7,tx,ty, 'loot_1.png') + loot_list.add(loot) + + if lvl == 2: + print(lvl) + + return loot_list + + def ground(lvl,gloc,tx,ty): + ground_list = pygame.sprite.Group() + i=0 + if lvl == 1: + while i < len(gloc): + ground = Platform(gloc[i],worldy-ty,tx,ty,'ground.png') + ground_list.add(ground) + i=i+1 + + if lvl == 2: + print("Level " + str(lvl) ) + + return ground_list + + def platform(lvl,tx,ty): + plat_list = pygame.sprite.Group() + ploc = [] + i=0 + if lvl == 1: + ploc.append((20,worldy-ty-128,3)) + ploc.append((300,worldy-ty-256,3)) + ploc.append((500,worldy-ty-128,4)) + + while i < len(ploc): + j=0 + while j <= ploc[i][2]: + plat = Platform((ploc[i][0]+(j*tx)),ploc[i][1],tx,ty,'ground.png') + plat_list.add(plat) + j=j+1 + print('run' + str(i) + str(ploc[i])) + i=i+1 + + if lvl == 2: + print("Level " + str(lvl) ) + + return plat_list + +def stats(score,health): + myfont.render_to(world, (4, 4), "Score:"+str(score), SNOWGRAY, None, size=64) + myfont.render_to(world, (4, 72), "Health:"+str(health), SNOWGRAY, None, size=64) + +''' +Setup +''' +worldx = 960 +worldy = 720 + +fps = 40 # frame rate +ani = 4 # animation cycles +clock = pygame.time.Clock() +pygame.init() +main = True + +BLUE = (25,25,200) +BLACK = (23,23,23 ) +WHITE = (254,254,254) +SNOWGRAY = (137,164,166) +ALPHA = (0,255,0) + +world = pygame.display.set_mode([worldx,worldy]) +backdrop = pygame.image.load(os.path.join('images','stage.png')).convert() +backdropbox = world.get_rect() +player = Player() # spawn player +player.rect.x = 0 +player.rect.y = 0 +player_list = pygame.sprite.Group() +player_list.add(player) +steps = 10 +forwardx = 600 +backwardx = 230 + +eloc = [] +eloc = [200,20] +gloc = [] +tx = 64 #tile size +ty = 64 #tile size + +font_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),"fonts","amazdoom.ttf") +font_size = tx +myfont = pygame.freetype.Font(font_path, font_size) + +i=0 +while i <= (worldx/tx)+tx: + gloc.append(i*tx) + i=i+1 + +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) +plat_list = Level.platform( 1,tx,ty ) +loot_list = Level.loot(1,tx,ty) + +''' +Main loop +''' +while main == True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit(); sys.exit() + main = False + + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_LEFT or event.key == ord('a'): + print("LEFT") + player.control(-steps,0) + if event.key == pygame.K_RIGHT or event.key == ord('d'): + print("RIGHT") + player.control(steps,0) + if event.key == pygame.K_UP or event.key == ord('w'): + print('jump') + + if event.type == pygame.KEYUP: + if event.key == pygame.K_LEFT or event.key == ord('a'): + player.control(steps,0) + if event.key == pygame.K_RIGHT or event.key == ord('d'): + player.control(-steps,0) + if event.key == pygame.K_UP or event.key == ord('w'): + player.jump(plat_list) + + if event.key == ord('q'): + pygame.quit() + sys.exit() + main = False + + # scroll the world forward + if player.rect.x >= forwardx: + scroll = player.rect.x - forwardx + player.rect.x = forwardx + for p in plat_list: + p.rect.x -= scroll + for e in enemy_list: + e.rect.x -= scroll + for l in loot_list: + + l.rect.x -= scroll + + # scroll the world backward + if player.rect.x <= backwardx: + scroll = backwardx - player.rect.x + player.rect.x = backwardx + for p in plat_list: + p.rect.x += scroll + for e in enemy_list: + e.rect.x += scroll + for l in loot_list: + l.rect.x += scroll + + world.blit(backdrop, backdropbox) + player.gravity() # check gravity + player.update() + player_list.draw(world) #refresh player position + enemy_list.draw(world) # refresh enemies + ground_list.draw(world) # refresh enemies + plat_list.draw(world) # refresh platforms + loot_list.draw(world) # refresh loot + for e in enemy_list: + e.move() + stats(player.score,player.health) # draw text + pygame.display.flip() + clock.tick(fps) +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/add-scorekeeping-your-python-game + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LAW_maze.png?itok=mZ5LP4-X (connecting yellow dots in a maze) +[2]: https://www.python.org/ +[3]: https://www.pygame.org/news +[4]: https://linux.cn/article-9071-1.html +[5]: https://linux.cn/article-10850-1.html +[6]: https://linux.cn/article-10858-1.html +[7]: https://linux.cn/article-10874-1.html +[8]: https://linux.cn/article-10883-1.html +[9]: https://linux.cn/article-11780-1.html +[10]: https://linux.cn/article-11790-1.html +[11]: https://linux.cn/article-11819-1.html +[12]: https://linux.cn/article-11828-1.html +[13]: http://pygame.org/news +[14]: https://fontlibrary.org/ +[15]: https://www.fontsquirrel.com/ +[16]: https://www.theleagueofmoveabletype.com/ +[17]: https://opensource.com/article/17/7/how-unzip-targz-file +[18]: https://opensource.com/sites/default/files/uploads/pygame-score.jpg (Keeping score in Pygame) +[19]: https://linux.cn/article-10902-1.html diff --git a/published/202002/20200109 My favorite Bash hacks.md b/published/202002/20200109 My favorite Bash hacks.md new file mode 100644 index 0000000000..da0173b7a2 --- /dev/null +++ b/published/202002/20200109 My favorite Bash hacks.md @@ -0,0 +1,135 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11841-1.html) +[#]: subject: (My favorite Bash hacks) +[#]: via: (https://opensource.com/article/20/1/bash-scripts-aliases) +[#]: author: (Katie McLaughlin https://opensource.com/users/glasnt) + +我珍藏的 Bash 秘籍 +====== + +> 通过别名和其他捷径来提高你经常忘记的那些事情的效率。 + +![bash logo on green background][1] + +要是你整天使用计算机,如果能找到需要重复执行的命令并记下它们以便以后轻松使用那就太棒了。它们全都呆在那里,藏在 `~/.bashrc` 中(或 [zsh 用户][2]的 `~/.zshrc` 中),等待着改善你的生活! + +在本文中,我分享了我最喜欢的这些助手命令,对于我经常遗忘的事情,它们很有用,也希望这可以帮助到你,以及为你解决一些经常头疼的问题。 + +### 完事吱一声 + +当我执行一个需要长时间运行的命令时,我经常采用多任务的方式,然后就必须回头去检查该操作是否已完成。然而通过有用的 `say` 命令,现在就不用再这样了(这是在 MacOS 上;请根据你的本地环境更改为等效的方式): + +``` +function looooooooong { + START=$(date +%s.%N) + $* + EXIT_CODE=$? + END=$(date +%s.%N) + DIFF=$(echo "$END - $START" | bc) + RES=$(python -c "diff = $DIFF; min = int(diff / 60); print('%s min' % min)") + result="$1 completed in $RES, exit code $EXIT_CODE." + echo -e "\n⏰ $result" + ( say -r 250 $result 2>&1 > /dev/null & ) +} +``` + +这个命令会记录命令的开始和结束时间,计算所需的分钟数,并“说”出调用的命令、花费的时间和退出码。当简单的控制台铃声无法使用时,我发现这个超级有用。 + +### 安装小助手 + +我在小时候就开始使用 Ubuntu,而我需要学习的第一件事就是如何安装软件包。我曾经首先添加的别名之一是它的助手(根据当天的流行梗命名的): + +``` +alias canhas="sudo apt-get install -y" +``` + +### GPG 签名 + +有时候,我必须在没有 GPG 扩展程序或应用程序的情况下给电子邮件签署 [GPG][3] 签名,我会跳到命令行并使用以下令人讨厌的别名: + +``` +alias gibson="gpg --encrypt --sign --armor" +alias ungibson="gpg --decrypt" +``` + +### Docker + +Docker 的子命令很多,但是 Docker compose 的更多。我曾经使用这些别名来将 `--rm` 标志丢到脑后,但是现在不再使用这些有用的别名了: + +``` +alias dc="docker-compose" +alias dcr="docker-compose run --rm" +alias dcb="docker-compose run --rm --build" +``` + +### Google Cloud 的 gcurl 助手 + +对于我来说,Google Cloud 是一个相对较新的东西,而它有[极多的文档][4]。`gcurl` 是一个别名,可确保在用带有身份验证标头的本地 `curl` 命令连接 Google Cloud API 时,可以获得所有正确的标头。 + +### Git 和 ~/.gitignore + +我工作中用 Git 很多,因此我有一个专门的部分来介绍 Git 助手。 + +我最有用的助手之一是我用来克隆 GitHub 存储库的。你不必运行: + +``` +git clone git@github.com:org/repo /Users/glasnt/git/org/repo +``` + +我设置了一个克隆函数: + +``` +clone(){ +    echo Cloning $1 to ~/git/$1 +    cd ~/git +    git clone git@github.com:$1 $1 +    cd $1 +} +``` + +即使每次进入 `~/.bashrc` 文件看到这个时,我总是会忘记和傻笑,我也有一个“刷新上游”命令: + +``` +alias yoink="git checkout master && git fetch upstream master && git merge upstream/master" +``` + +给 Git 一族的另一个助手是全局忽略文件。在你的 `git config --global --list` 中,你应该看到一个 `core.excludesfile`。如果没有,请[创建一个][6],然后将你总是放到各个 `.gitignore` 文件中的内容填满它。作为 MacOS 上的 Python 开发人员,对我来说,这些内容是: + +``` +.DS_Store     # macOS clutter +venv/         # I never want to commit my virtualenv +*.egg-info/*  # ... nor any locally compiled packages +__pycache__   # ... or source +*.swp         # ... nor any files open in vim +``` + +你可以在 [Gitignore.io][7] 或 GitHub 上的 [Gitignore 存储库][8]上找到其他建议。 + +### 轮到你了 + +你最喜欢的助手命令是什么?请在评论中分享。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/bash-scripts-aliases + +作者:[Katie McLaughlin][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/glasnt +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bash_command_line.png?itok=k4z94W2U (bash logo on green background) +[2]: https://opensource.com/article/19/9/getting-started-zsh +[3]: https://gnupg.org/ +[4]: https://cloud.google.com/service-infrastructure/docs/service-control/getting-started +[5]: mailto:git@github.com +[6]: https://help.github.com/en/github/using-git/ignoring-files#create-a-global-gitignore +[7]: https://www.gitignore.io/ +[8]: https://github.com/github/gitignore diff --git a/published/202002/20200109 What-s HTTPS for secure computing.md b/published/202002/20200109 What-s HTTPS for secure computing.md new file mode 100644 index 0000000000..975b4ebdff --- /dev/null +++ b/published/202002/20200109 What-s HTTPS for secure computing.md @@ -0,0 +1,65 @@ +[#]: collector: (lujun9972) +[#]: translator: (hopefully2333) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11877-1.html) +[#]: subject: (What's HTTPS for secure computing?) +[#]: via: (https://opensource.com/article/20/1/confidential-computing) +[#]: author: (Mike Bursell https://opensource.com/users/mikecamel) + +用于安全计算的 HTTPS 是什么? +====== + +> 在默认的情况下,网站的安全性还不足够。 + +![](https://img.linux.net.cn/data/attachment/album/202002/11/123552rqncn4c7474j44jq.jpg) + +在过去的几年里,寻找一个只以 “http://...” 开头的网站变得越来越难,这是因为业界终于意识到,网络安全“是件事”,同时也是因为客户端和服务端之间建立和使用 https 连接变得更加容易了。类似的转变可能正以不同的方式发生在云计算、边缘计算、物联网、区块链,人工智能、机器学习等领域。长久以来,我们都知道我们应该对存储的静态数据和在网络中传输的数据进行加密,但是在使用和处理数据的时候对它进行加密是困难且昂贵的。可信计算(使用例如受信任的执行环境Trusted Execution Environments TEEs 这样的硬件功能来提供数据和算法这种类型的保护)可以保护主机系统中的或者易受攻击的环境中的数据。 + +关于 [TEEs][2],当然,还有我和 Nathaniel McCallum 共同创立的 [Enarx 项目][3],我已经写了几次文章(参见《[给每个人的 Enarx(一个任务)][4]》 和 《[Enarx 迈向多平台][5]》)。Enarx 使用 TEEs 来提供独立于平台和语言的部署平台,以此来让你能够安全地将敏感应用或者敏感组件(例如微服务)部署在你不信任的主机上。当然,Enarx 是完全开源的(顺便提一下,我们使用的是 Apache 2.0 许可证)。能够在你不信任的主机上运行工作负载,这是可信计算的承诺,它扩展了使用静态敏感数据和传输中数据的常规做法: + +* **存储**:你要加密你的静态数据,因为你不完全信任你的基础存储架构。 +* **网络**:你要加密你正在传输中的数据,因为你不完全信任你的基础网络架构。 +* **计算**:你要加密你正在使用中的数据,因为你不完全信任你的基础计算架构。 + +关于信任,我有非常多的话想说,而且,上述说法里的单词“**完全**”是很重要的(在重新读我写的这篇文章的时候,我新加了这个单词)。不论哪种情况,你必须在一定程度上信任你的基础设施,无论是传递你的数据包还是存储你的数据块,例如,对于计算基础架构,你必须要去信任 CPU 和与之关联的固件,这是因为如果你不信任他们,你就无法真正地进行计算(现在有一些诸如同态加密homomorphic encryption一类的技术,这些技术正在开始提供一些可能性,但是它们依然有限,这些技术还不够成熟)。 + +考虑到发现的一些 CPU 安全性问题,是否应该完全信任 CPU 有时自然会产生疑问,以及它们是否在针对其所在的主机的物理攻击中具有完全的安全性。 + +这两个问题的回答都是“不”,但是在考虑到大规模可用性和普遍推广的成本,这已经是我们当前拥有的最好的技术了。为了解决第二个问题,没有人去假装这项技术(或者任何的其他技术)是完全安全的:我们需要做的是思考我们的[威胁模型][6]并确定这个情况下的 TEEs 是否为我们的特殊需求提供了足够的安全防护。关于第一个问题,Enarx 采用的模型是在部署时就对你是否信任一个特定的 CPU 组做出决定。举个例子,如果供应商 Q 的 R 代芯片被发现有漏洞,可以很简单地说“我拒绝将我的工作内容部署到 Q 的 R 代芯片上去,但是仍然可以部署到 Q 的 S 型号、T 型号和 U 型号的芯片以及任何 P、M 和 N 供应商的任何芯片上去。” + +我认为这里发生了三处改变,这些改变引起了人们现在对机密计算confidential computing的兴趣和采用。 + +1. **硬件可用**:只是在过去的 6 到 12 个月里,支持 TEEs 的硬件才开始变得广泛可用,这会儿市场上的主要例子是 Intel 的 SGX 和 AMD 的 SEV。我们期望在未来可以看到支持 TEE 的硬件的其他例子。 +2. **行业就绪**:就像上云越来越多地被接受作为应用程序部署的模型,监管机构和立法机构也在提高各类组织保护其管理的数据的要求。组织开始呼吁在不受信任的主机运行敏感程序(或者是处理敏感数据的应用程序)的方法,更确切地说,是在无法完全信任且带有敏感数据的主机上运行的方法。这不足为奇:如果芯片制造商看不到这项技术的市场,他们就不会投太多的钱在这项技术上。Linux 基金会的[机密计算联盟(CCC)][7]的成立就是业界对如何寻找使用加密计算的通用模型并且鼓励开源项目使用这些技术感兴趣的案例。(红帽发起的 Enarx 是一个 CCC 项目。) +3. **开放源码**:就像区块链一样,机密计算是使用开源绝对明智的技术之一。如果你要运行敏感程序,你需要去信任正在为你运行的程序。不仅仅是 CPU 和固件,同样还有在 TEE 内执行你的工作负载的框架。可以很好地说,“我不信任主机机器和它上面的软件栈,所以我打算使用 TEE,”但是如果你不够了解 TEE 软件环境,那你就是将一种软件不透明换成另外一种。TEEs 的开源支持将允许你或者社区(实际上是你与社区)以一种专有软件不可能实现的方式来检查和审计你所运行的程序。这就是为什么 CCC 位于 Linux 基金会旗下(这个基金会致力于开放式开发模型)并鼓励 TEE 相关的软件项目加入且成为开源项目(如果它们还没有成为开源)。 + +我认为,在过去的 15 到 20 年里,硬件可用、行业就绪和开放源码已成为推动技术改变的驱动力。区块链、人工智能、云计算、大规模计算webscale computing、大数据和互联网商务都是这三个点同时发挥作用的例子,并且在业界带来了巨大的改变。 + +在一般情况下,安全是我们这数十年来听到的一种承诺,并且其仍然未被实现。老实说,我不确定它未来会不会实现。但是随着新技术的到来,特定用例的安全变得越来越实用和无处不在,并且在业内受到越来越多的期待。这样看起来,机密计算似乎已准备好成为成为下一个重大变化 —— 而你,我亲爱的读者,可以一起来加入到这场革命(毕竟它是开源的)。 + +这篇文章最初是发布在 Alice, Eve, and Bob 上的,这是得到了作者许可的重发。 + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/confidential-computing + +作者:[Mike Bursell][a] +选题:[lujun9972][b] +译者:[hopefully2333](https://github.com/hopefully2333) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mikecamel +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/secure_https_url_browser.jpg?itok=OaPuqBkG (Secure https browser) +[2]: https://aliceevebob.com/2019/02/26/oh-how-i-love-my-tee-or-do-i/ +[3]: https://enarx.io/ +[4]: https://aliceevebob.com/2019/08/20/enarx-for-everyone-a-quest/ +[5]: https://aliceevebob.com/2019/10/29/enarx-goes-multi-platform/ +[6]: https://aliceevebob.com/2018/02/20/there-are-no-absolutes-in-security/ +[7]: https://confidentialcomputing.io/ +[8]: tmp.VEZpFGxsLv#1 +[9]: https://aliceevebob.com/2019/12/03/confidential-computing-the-new-https/ diff --git a/published/202002/20200112 What I learned going from prison to Python.md b/published/202002/20200112 What I learned going from prison to Python.md new file mode 100644 index 0000000000..283212f4b4 --- /dev/null +++ b/published/202002/20200112 What I learned going from prison to Python.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11893-1.html) +[#]: subject: (What I learned going from prison to Python) +[#]: via: (https://opensource.com/article/20/1/prison-to-python) +[#]: author: (Shadeed "Sha" Wallace-Stepter https://opensource.com/users/shastepter) + +从监狱到 Python +====== + +> 入狱后,开源编程是如何提供机会的。 + +![书架上的编程书籍][1] + +不到一年前,我还在圣昆廷州立监狱服刑,我是无期徒刑。 + +我高三的时候,我抢劫了一个人并向他开了枪。现在,我经过一段时间才意识到并承认自己做错了,这是在经历了陪审团审判并看到我的行为带来的恶果后,我知道需要改变自己,我也确实做到了。尽管我对我的行为表示懊悔,但我毕竟开枪打了一个人,并差点杀了他。做这样的事是有后果的,这是理所当然的。所以在我 18 岁的时候,我被判了终身监禁。 + +监狱是一个非常可怕的地方;我是不推荐你去的。但是我必须去,所以我去了。我不告诉你具体的细节,但你可以放心,这是一个没有太多动机去改变的地方,许多人在这里养成的坏习惯比他们过去在别处养成的更多。 + +我是幸运儿之一。当我在服刑的时候,发生了一些不同寻常的事情。我开始想象自己出狱后的的未来,虽然在这之前,我还是已经在那里度过了我整个成年生活。 + +现在你想想:我是黑人,只受过高中教育。我没有工作经历,如果我离开监狱,在被释放前,我还是一个被定罪的重罪犯。当每个雇主看到我的简历,都不会有“我需要雇用这个人”想法,我认为是正常的。 + +我不知道我的选择是什么,但我已经下定决心了。我需要做些活下去的事情,并且这和我入狱前的生活一点也不像。 + +### Python 之路 + +最终,我被关在了圣昆廷州立监狱,我不知道我为何幸运地被关在那里。圣昆廷提供了几个自助和教育编程项目。这些[改造机会][2]帮助囚犯使他们拥有在获释后避免再次犯罪的技能。 + +作为其中一个编程项目的一部分,2017 年我通过圣昆廷媒体项目认识了[杰西卡·麦凯拉][3]。杰西卡是编程语言 [Python][4] 的爱好者,她开始向我推荐 Python 有多棒,以及它是刚起步的人学习的完美语言。这就是故事变得比小说更精彩的地方。 + +> 感谢 [@northbaypython][5] 让 [@ShaStepter][6] 和我重复 [@pycon][7] 的主题演讲,让他们被录制下来。我很荣幸与大家分享: +> +> 从监狱到 Pythone: https://t.co/rcumoAgZHm +> +> 大规模裁员:如果我们不雇佣被判重罪的人,谁会呢? https://t.co/fENDUFdxfX +> +> [pic.Twitter.com/kpjo8d3ul6][8] +> +> —杰西卡·麦凯拉(@jessicamckellar)[2019 年 11 月 5 日][9] + +杰西卡向我介绍了一些 Python 视频教程,这些教程是她为一家名叫 [O’Reilly Media][10] 的公司做的,课程是在线的,如果我能接触到它们,那该有多好呀。不幸的是,在监狱里上网是不可能的。但是,我遇到了一个叫 Tim O’Reilly 的人,他最近刚来到圣昆廷。在他访问之后,Tim 从他的公司 O’Reilly Media 公司向监狱的编程班捐赠了大量内容。最终,我拿到了一款平板电脑,上面有杰西卡的 Python 教程,并学会了如何使用这些 Python 教程进行编码。 + +真是难以置信。背景和生活与我完全不同的陌生人把这些联系在一起,让我学会了编码。 + +### 对 Python 社区的热爱 + +在这之后,我开始经常和杰西卡见面,她开始告诉我关于开源社区的情况。我了解到,从根本上说,开源社区就是关于伙伴关系和协作的社区。之所以如此有效,是因为没有人被排除在外。 + +对我来说,一个努力寻找自己定位的人,我所看到的是一种非常基本的爱——通过合作和接受的爱,通过接触的爱,通过包容的爱。我渴望成为其中的一部分。所以我继续学习 Python,不幸的是,我无法获得更多的教程,但是我能够从开源社区收集的大量书面知识中获益。我读一切提到 Python 的东西,从平装本到晦涩难懂的杂志文章,我使用平板电脑来解决我读到的 Python 问题。 + +我对 Python 和编程的热情不是我的许多同龄人所共有的。除了监狱编程课上的极少数人之外,我认识的其他人都没有提到过编程;一般囚犯都不知道。我认为这是因为有过监禁经历的人无法接触编程,尤其是如果你是有色人种。 + +### 监狱外的 Python 生活 + +然而,在 2018 年 8 月 17 日,我得到了生命中的惊喜。时任州长的杰里·布朗将我 27 年的刑期减刑,在服刑将近 19 年后,我被释放出狱了。 + +但现实情况是,这也是为什么我认为编程和开源社区如此有价值。我是一名 37 岁的黑人罪犯,没有工作经历,刚刚在监狱服刑 18 年。我有犯罪史,并且现存偏见导致没有多少职业适合我。但是编程是少数例外之一。 + +现在,监禁后重返社会的人们迫切需要包容,但当谈及工作场所的多样性以及对多样性的需求时,你真的听不到这个群体被提及或包容。 + +> 还有什么: +> +> 1、背景调查:询问他们在你的公司是如何使用的。 +> +> 2、初级角色:删除虚假的、不必要的先决条件,这些条件将排除有记录的合格人员。 +> +> 3、积极拓展:与当地再就业项目合作,创建招聘渠道。 +> +> [pic.twitter.com/WnzdEUTuxr][11] +> +> —杰西卡·麦凯拉(@jessicamckellar)[2019 年 5 月 12 日][12] +  + +因此,我想谦卑地挑战开源社区的所有程序员和成员,让他们围绕包容和多样性展开思考。今天,我自豪地站在你们面前,代表一个大多数人都没有想到的群体——以前被监禁的人。但是我们存在,我们渴望证明我们的价值,最重要的是,我们期待被接受。当我们重返社会时,许多挑战等待着我们,我请求你们允许我们有机会展示我们的价值。欢迎我们,接受我们,最重要的是,包容我们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/prison-to-python + +作者:[Shadeed "Sha" Wallace-Stepter][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/shastepter +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/books_programming_languages.jpg?itok=KJcdnXM2 (Programming books on a shelf) +[2]: https://www.dailycal.org/2019/02/27/san-quentin-rehabilitation-programs-offer-inmates-education-a-voice/ +[3]: https://twitter.com/jessicamckellar?lang=en +[4]: https://www.python.org/ +[5]: https://twitter.com/northbaypython?ref_src=twsrc%5Etfw +[6]: https://twitter.com/ShaStepter?ref_src=twsrc%5Etfw +[7]: https://twitter.com/pycon?ref_src=twsrc%5Etfw +[8]: https://t.co/Kpjo8d3ul6 +[9]: https://twitter.com/jessicamckellar/status/1191601209917837312?ref_src=twsrc%5Etfw +[10]: http://shop.oreilly.com/product/110000448.do +[11]: https://t.co/WnzdEUTuxr +[12]: https://twitter.com/jessicamckellar/status/1127640222504636416?ref_src=twsrc%5Etfw diff --git a/published/202002/20200117 Use this Python script to find bugs in your Overcloud.md b/published/202002/20200117 Use this Python script to find bugs in your Overcloud.md new file mode 100644 index 0000000000..94428426e4 --- /dev/null +++ b/published/202002/20200117 Use this Python script to find bugs in your Overcloud.md @@ -0,0 +1,172 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11886-1.html) +[#]: subject: (Use this Python script to find bugs in your Overcloud) +[#]: via: (https://opensource.com/article/20/1/logtool-root-cause-identification) +[#]: author: (Arkady Shtempler https://opensource.com/users/ashtempl) + +用 Python 脚本发现 OpenStack Overcloud 中的问题 +====== + +> LogTool 是一组 Python 脚本,可帮助你找出 Overcloud 节点中问题的根本原因。 + +![](https://img.linux.net.cn/data/attachment/album/202002/12/211455woy57xx5q19cx175.jpg) + +OpenStack 在其 Overcloud 节点和 Undercloud 主机上存储和管理了一堆日志文件。因此,使用 OSP 日志文件来排查遇到的问题并不是一件容易的事,尤其在你甚至都不知道是什么原因导致问题时。 + +如果你正处于这种情况,那么 [LogTool][2] 可以使你的生活变得更加轻松!它会为你节省本需要人工排查问题所需的时间和精力。LogTool 基于模糊字符串匹配算法,可提供过去发生的所有唯一错误和警告信息。你可以根据日志中的时间戳导出特定时间段(例如 10 分钟前、一个小时前、一天前等)的这些信息。 + +LogTool 是一组 Python 脚本,其主要模块 `PyTool.py` 在 Undercloud 主机上执行。某些操作模式使用直接在 Overcloud 节点上执行的其他脚本,例如从 Overcloud 日志中导出错误和警告信息。 + +LogTool 支持 Python 2 和 Python 3,你可以根据需要更改工作目录:[LogTool_Python2][3] or [LogTool_Python3][4]。 + +### 操作方式 + +#### 1、从 Overcloud 日志中导出错误和警告信息 + +此模式用于从过去发生的 Overcloud 节点中提取 **错误** 和 **警告** 信息。作为用户,系统将提示你提供“开始时间”和“调试级别”,以用于提取错误或警告消息。例如,如果在过去 10 分钟内出了问题,你则可以只提取该时间段内的错误和警告消息。 + +此操作模式将为每个 Overcloud 节点生成一个包含结果文件的目录。结果文件是经过压缩的简单文本文件(`*.gz`),以减少从 Overcloud 节点下载所需的时间。将压缩文件转换为常规文本文件,可以使用 `zcat` 或类似工具。此外,Vi 的某些版本和 Emacs 的任何最新版本均支持读取压缩数据。结果文件分为几部分,并在底部包含目录。 + +LogTool 可以即时检测两种日志文件:标准和非标准。在标准文件中,每条日志行都有一个已知的和已定义的结构:时间戳、调试级别、信息等等。在非标准文件中,日志的结构未知。例如,它可能是第三方的日志。在目录中,你可以找到每个部分的“名称 --> 行号”例如: + + * **原始数据 - 从标准 OSP 日志中提取的错误/警告消息:** 这部分包含所有提取的错误/警告消息,没有任何修改或更改。这些消息是 LogTool 用于模糊匹配分析的原始数据。 + * **统计信息 - 每个标准 OSP 日志的错误/警告信息数量:** 在此部分,你将找到每个标准日志文件的错误和警告数量。这些信息可以帮助你了解用于排查问题根本原因的潜在组件。 + * **统计信息 - 每个标准 OSP 日志文件的唯一消息:** 这部分提供指定时间戳内的唯一的错误和警告消息。有关每个唯一错误或警告的更多详细信息,请在“原始数据”部分中查找相同的消息。 + * **统计信息 - 每个非标准日志文件在任意时间的唯一消息:** 此部分包含非标准日志文件中的唯一消息。遗憾的是,LogTool 无法像标准日志文件那样的处理方式处理这些日志文件。因此,在你提取“特定时间”的日志信息时会被忽略,你会看到过去创建的所有唯一的错误/警告消息。因此,首先,向下滚动到结果文件底部的目录并查看其部分-使用目录中的行索引跳到相关部分,其中第 3、4 和 5 行的信息最重要。 + +#### 2、从 Overcloud 节点下载所有日志 + +所有 Overcloud 节点的日志将被压缩并下载到 Undercloud 主机上的本地目录。 + +#### 3、所有 Overcloud 日志中搜索字符串 + +该模式“grep”(搜索)由用户在所有 Overcloud 日志上提供的字符串。例如,你可能希望查看特定请求的所有日志消息,例如,“Create VM”的失败的请求 ID。 + +#### 4、检查 Overcloud 上当前的 CPU、RAM 和磁盘使用情况 + +该模式显示每个 Overcloud 节点上的当前 CPU、RAM 和磁盘信息。 + +#### 5、执行用户脚本 + +该模式使用户可以在 Overcloud 节点上运行自己的脚本。例如,假设 Overcloud 部署失败,你就需要在每个控制器节点上执行相同的过程来修复该问题。你可以实现“替代方法”脚本,并使用此模式在控制器上运行它。 + +#### 6、仅按给定的时间戳下载相关日志 + +此模式仅下载 Overcloud 上 “给定的时间戳”的“上次修改时间”的日志。例如,如果 10 分钟前出现错误,则与旧日志文件就没有关系,因此无需下载。此外,你不能(或不应)在某些错误报告工具中附加大文件,因此此模式可能有助于编写错误报告。 + +#### 7、从 Undercloud 日志中导出错误和警告信息 + +这与上面的模式 1 相同。 + +#### 8、在 Overcloud 上检查不正常的 docker + +此模式用于在节点上搜索不正常的 Docker。 + +#### 9、下载 OSP 日志并在本地运行 LogTool + +此模式允许你从 Jenkins 或 Log Storage 下载 OSP 日志(例如,`cougar11.scl.lab.tlv.redhat.com`),并在本地分析。 + +#### 10、在 Undercloud 上分析部署日志 + +此模式可以帮助你了解 Overcloud 或 Undercloud 部署过程中出了什么问题。例如,在`overcloud_deploy.sh` 脚本中,使用 `--log` 选项时会生成部署日志;此类日志的问题是“不友好”,你很难理解是什么出了问题,尤其是当详细程度设置为 `vv` 或更高时,使得日志中的数据难以读取。此模式提供有关所有失败任务的详细信息。 + +#### 11、分析 Gerrit(Zuul)失败的日志 + +此模式用于分析 Gerrit(Zuul)日志文件。它会自动从远程 Gerrit 门下载所有文件(HTTP 下载)并在本地进行分析。 + +### 安装 + +GitHub 上有 LogTool,使用以下命令将其克隆到你的 Undercloud 主机: + +``` +git clone https://github.com/zahlabut/LogTool.git +``` + +该工具还使用了一些外部 Python 模块: + +#### Paramiko + +默认情况下,SSH 模块通常会安装在 Undercloud 上。使用以下命令来验证是否已安装: + +``` +ls -a /usr/lib/python2.7/site-packages | grep paramiko +``` + +如果需要安装模块,请在 Undercloud 上执行以下命令: + +``` +sudo easy_install pip +sudo pip install paramiko==2.1.1 +``` + +#### BeautifulSoup + +此 HTML 解析器模块仅在使用 HTTP 下载日志文件的模式下使用。它用于解析 Artifacts HTML 页面以获取其中的所有链接。安装 BeautifulSoup,请输入以下命令: + +``` +pip install beautifulsoup4 +``` + +你还可以通过执行以下命令使用 [requirements.txt][6] 文件安装所有必需的模块: + +``` +pip install -r requirements.txt +``` + +### 配置 + +所有必需的参数都直接在 `PyTool.py` 脚本中设置。默认值为: + +``` +overcloud_logs_dir = '/var/log/containers' +overcloud_ssh_user = 'heat-admin' +overcloud_ssh_key = '/home/stack/.ssh/id_rsa' +undercloud_logs_dir ='/var/log/containers' +source_rc_file_path='/home/stack/' +``` + +### 用法 + +此工具是交互式的,因此要启动它,只需输入: + +``` +cd LogTool +python PyTool.py +``` + +### 排除 LogTool 故障 + + +在运行时会创建两个日志文件:`Error.log` 和 `Runtime.log`。请在你要打开的问题的描述中添加两者的内容。 + +### 局限性 + +LogTool 进行硬编码以处理最大 500 MB 的文件。 + +### LogTool_Python3 脚本 + +在 [github.com/zahlabut/LogTool][2] 获取。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/logtool-root-cause-identification + +作者:[Arkady Shtempler][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/译者ID) +校对:[wxy](https://github.com/wxy) + + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ashtempl +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/search_find_code_python_programming.png?itok=ynSL8XRV (Searching for code) +[2]: https://github.com/zahlabut/LogTool +[3]: https://github.com/zahlabut/LogTool/tree/master/LogTool_Python2 +[4]: https://github.com/zahlabut/LogTool/tree/master/LogTool_Python3 +[5]: https://opensource.com/article/19/2/getting-started-cat-command +[6]: https://github.com/zahlabut/LogTool/blob/master/LogTool_Python3/requirements.txt diff --git a/published/202002/20200118 Keep a journal of your activities with this Python program.md b/published/202002/20200118 Keep a journal of your activities with this Python program.md new file mode 100644 index 0000000000..6426f86baa --- /dev/null +++ b/published/202002/20200118 Keep a journal of your activities with this Python program.md @@ -0,0 +1,76 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11846-1.html) +[#]: subject: (Keep a journal of your activities with this Python program) +[#]: via: (https://opensource.com/article/20/1/python-journal) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用这个 Python 程序记录你的活动 +====== + +> jrnl 可以创建可搜索、带时间戳、可导出、加密的(如果需要)的日常活动日志。在我们的 20 个使用开源提升生产力的系列的第八篇文章中了解更多。 + +![](https://img.linux.net.cn/data/attachment/album/202002/03/105455tx03zo2pu7woyusp.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 jrnl 记录日志 + +在我的公司,许多人会在下班之前在 Slack 上发送一个“一天结束”的状态。在有着许多项目和全球化的团队里,这是一个分享你已完成、未完成以及你需要哪些帮助的一个很好的方式。但有时候我太忙了,以至于我忘了做了什么。这时候就需要记录日志了。 + +![jrnl][2] + +打开一个文本编辑器并在你做一些事的时候添加一行很容易。但是在需要找出你在什么时候做的笔记,或者要快速提取相关的行时会有挑战。幸运的是,[jrnl][3] 可以提供帮助。 + +jrnl 能让你在命令行中快速输入条目、搜索过去的条目并导出为 HTML 和 Markdown 等富文本格式。你可以有多个日志,这意味着你可以将工作条目与私有条目分开。它将条目存储为纯文本,因此即使 jrnl 停止工作,数据也不会丢失。 + +由于 jrnl 是一个 Python 程序,最简单的安装方法是使用 `pip3 install jrnl`。这将确保你获得最新和最好的版本。第一次运行它会询问一些问题,接下来就能正常使用。 + +![jrnl's first run][4] + +现在,每当你需要做笔记或记录日志时,只需输入 `jrnl `,它将带有时间戳的记录保存到默认文件中。你可以使用 `jrnl -on YYYY-MM-DD` 搜索特定日期条目,`jrnl -from YYYY-MM-DD` 搜索在那日期之后的条目,以及用 `jrnl -to YYYY-MM-DD` 搜索到那日期的条目。搜索词可以与 `-and` 参数结合使用,允许像 `jrnl -from 2019-01-01 -and -to 2019-12-31` 这类搜索。 + +你还可以使用 `--edit` 标志编辑日志中的条目。开始之前,通过编辑文件 `~/.config/jrnl/jrnl.yaml` 来设置默认编辑器。你还可以指定日志使用什么文件、用于标签的特殊字符以及一些其他选项。现在,重要的是设置编辑器。我使用 Vim,jrnl 的文档中有一些使用其他编辑器如 VSCode 和 Sublime Text 的[有用提示][5]。 + +![Example jrnl config file][6] + +jrnl 还可以加密日志文件。通过设置全局 `encrypt` 变量,你将告诉 jrnl 加密你定义的所有日志。还可在配置文件中的针对文件设置 `encrypt: true` 来加密文件。 + +``` +journals: +  default: ~/journals/journal.txt +  work: ~/journals/work.txt +  private: +    journal: ~/journals/private.txt +    encrypt: true +``` + +如果日志尚未加密,系统将提示你输入在对它进行任何操作的密码。日志文件将加密保存在磁盘上,以免受窥探。[jrnl 文档][7] 中包含其工作原理、使用哪些加密方式等的更多信息。 + +![Encrypted jrnl file][8] + +日志记录帮助我记住什么时候做了什么事,并在我需要的时候能够找到它。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/python-journal + +作者:[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/notebook-writing-pen.jpg?itok=uA3dCfu_ (Writing in a notebook) +[2]: https://opensource.com/sites/default/files/uploads/productivity_8-1.png (jrnl) +[3]: https://jrnl.sh/ +[4]: https://opensource.com/sites/default/files/uploads/productivity_8-2.png (jrnl's first run) +[5]: https://jrnl.sh/recipes/#external-editors +[6]: https://opensource.com/sites/default/files/uploads/productivity_8-3.png (Example jrnl config file) +[7]: https://jrnl.sh/encryption/ +[8]: https://opensource.com/sites/default/files/uploads/productivity_8-4.png (Encrypted jrnl file) diff --git a/published/202002/20200119 How to Set or Change Timezone in Ubuntu Linux -Beginner-s Tip.md b/published/202002/20200119 How to Set or Change Timezone in Ubuntu Linux -Beginner-s Tip.md new file mode 100644 index 0000000000..5395a64b6e --- /dev/null +++ b/published/202002/20200119 How to Set or Change Timezone in Ubuntu Linux -Beginner-s Tip.md @@ -0,0 +1,128 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11838-1.html) +[#]: subject: (How to Set or Change Timezone in Ubuntu Linux [Beginner’s Tip]) +[#]: via: (https://itsfoss.com/change-timezone-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Ubuntu Linux 中设置或更改时区 +====== + +[你安装 Ubuntu 时][1],它会要求你设置时区。如果你选择一个错误的时区,或者你移动到世界的一些其它地方,你可以很容易地在以后更改它。 + +### 如何在 Ubuntu 和其它 Linux 发行版中更改时区 + +这里有两种方法来更改 Ubuntu 中的时区。你可以使用图形化设置或在终端中使用 `timedatectl` 命令。你也可以直接更改 `/etc/timezone` 文件,但是我不建议这样做。 + +在这篇初学者教程中,我将向你展示图形化和终端两种方法: + + * [通过 GUI 更改 Ubuntu 中的时区][2] (适合桌面用户) + * [通过命令行更改 Ubuntu 中的时区][3] (桌面和服务器都工作) + +![][4] + +#### 方法 1: 通过终端更改 Ubuntu 时区 + +[Ubuntu][5] 或一些使用 systemd 的其它发行版可以在 Linux 终端中使用 `timedatectl` 命令来设置时区。 + +你可以使用没有任何参数的 `timedatectl` 命令来检查当前是日期和时区设置: + +``` +[email protected]:~$ timedatectl + Local time: Sat 2020-01-18 17:39:52 IST + Universal time: Sat 2020-01-18 12:09:52 UTC + RTC time: Sat 2020-01-18 12:09:52 + Time zone: Asia/Kolkata (IST, +0530) + System clock synchronized: yes +systemd-timesyncd.service active: yes + RTC in local TZ: no +``` + +正如你在上面的输出中所看,我的系统使用 Asia/Kolkata 。它也告诉我现在比世界时早 5 小时 30 分钟。 + +为在 Linux 中设置时区,你需要知道准确的时区。你必需使用时区的正确的格式 (时区格式是洲/城市)。 + +为获取时区列表,使用 `timedatectl` 命令的 `list-timezones` 参数: + +``` +timedatectl list-timezones +``` + +它将向你显示大量可用的时区列表。 + +![Timezones List][6] + +你可以使用向上箭头和向下箭头或 `PgUp` 和 `PgDown` 键来在页面之间移动。 + +你也可以 `grep` 输出,并搜索你的时区。例如,假如你正在寻找欧洲的时区,你可以使用: + +``` +timedatectl list-timezones | grep -i europe +``` + +比方说,你想设置时区为巴黎。在这里,使用的时区值的 Europe/Paris : + +``` +timedatectl set-timezone Europe/Paris +``` + +它虽然不显示任何成功信息,但是时区会立即更改。你不需要重新启动或注销。 + +记住,虽然你不需要成为 root 用户并对命令使用 `sudo`,但是你的账户仍然需要拥有管理器权限来更改时区。 + +你可以使用 [date 命令][7] 来验证更改的时间好时区: + +``` +[email protected]:~$ date +Sat Jan 18 13:56:26 CET 2020 +``` + +#### 方法 2: 通过 GUI 更改 Ubuntu 时区 + +按下 `super` 键 (Windows 键) ,并搜索设置: + +![Applications Menu Settings][8] + +在左侧边栏中,向下滚动一点,查看详细信息: + +![Go to Settings -> Details][9] + +在详细信息中,你将在左侧边栏中找到“日期和时间”。在这里,你应该关闭自动时区选项(如果它已经被启用),然后在时区上单击: + +![In Details -> Date & Time, turn off the Automatic Time Zone][10] + +当你单击时区时,它将打开一个交互式地图,你可以在你选择的地理位置上单击,关闭窗口。 + +![Select a timezone][11] + +在选择新的时区后,除了关闭这个地图后,你不必做任何事情。不需要注销或 [关闭 Ubuntu][12]。 + +我希望这篇快速教程能帮助你在 Ubuntu 和其它 Linux 发行版中更改时区。如果你有问题或建议,请告诉我。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/change-timezone-ubuntu/ + +作者:[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://itsfoss.com/install-ubuntu/ +[2]: tmp.bHvVztzy6d#change-timezone-gui +[3]: tmp.bHvVztzy6d#change-timezone-command-line +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/01/Ubuntu_Change-_Time_Zone.png?ssl=1 +[5]: https://ubuntu.com/ +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/timezones_in_ubuntu.jpg?ssl=1 +[7]: https://linuxhandbook.com/date-command/ +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/applications_menu_settings.jpg?ssl=1 +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/settings_detail_ubuntu.jpg?ssl=1 +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/change_timezone_in_ubuntu.jpg?ssl=1 +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/01/change_timezone_in_ubuntu_2.jpg?ssl=1 +[12]: https://itsfoss.com/schedule-shutdown-ubuntu/ diff --git a/published/202002/20200119 One open source chat tool to rule them all.md b/published/202002/20200119 One open source chat tool to rule them all.md new file mode 100644 index 0000000000..1d2240f8f7 --- /dev/null +++ b/published/202002/20200119 One open source chat tool to rule them all.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11856-1.html) +[#]: subject: (One open source chat tool to rule them all) +[#]: via: (https://opensource.com/article/20/1/open-source-chat-tool) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +一个通过 IRC 管理所有聊天的开源聊天工具 +====== + +> BitlBee 将多个聊天应用集合到一个界面中。在我们的 20 个使用开源提升生产力的系列的第九篇文章中了解如何设置和使用 BitlBee。 + +![](https://img.linux.net.cn/data/attachment/album/202002/05/123636dw8uw34mbkqzmw84.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 将所有聊天都放到 BitlBee 中 + +即时消息和聊天已经成为网络世界的主要内容。如果你像我一样,你可能打开五六个不同的应用与你的朋友、同事和其他人交谈。关注所有聊天真的很痛苦。谢天谢地,你可以使用一个应用(好吧,是两个)将这些聊天整个到一个地方。 + +![BitlBee on XChat][2] + +[BitlBee][3] 是作为服务运行的应用,它可以将标准的 IRC 客户端与大量的消息服务进行桥接。而且,由于它本质上是 IRC 服务器,因此你可以选择很多客户端。 + +BitlBee 几乎包含在所有 Linux 发行版中。在 Ubuntu 上安装(我选择的 Linux 桌面),类似这样: + +``` +sudo apt install bitlbee-libpurple +``` + +在其他发行版上,包名可能略有不同,但搜索 “bitlbee” 应该就能看到。 + +你会注意到我用的 libpurple 版的 BitlBee。这个版本能让我使用 [libpurple][4] 即时消息库中提供的所有协议,该库最初是为 [Pidgin][5] 开发的。 + +安装完成后,服务应会自动启动。现在,使用一个 IRC 客户端(图片中为 [XChat][6]),我可以连接到端口 6667(标准 IRC 端口)上的服务。 + +![Initial BitlBee connection][7] + +你将自动连接到控制频道 &bitlbee。此频道对于你是独一无二的,在多用户系统上每个人都有一个自己的。在这里你可以配置该服务。 + +在控制频道中输入 `help`,你可以随时获得完整的文档。浏览它,然后使用 `register` 命令在服务器上注册帐户。 + +``` +register +``` + +现在,你在服务器上所做的任何配置更改(IM 帐户、设置等)都将在输入 `save` 时保存。每当你连接时,使用 `identify ` 连接到你的帐户并加载这些设置。 + +![purple settings][8] + +命令 `help purple` 将显示 libpurple 提供的所有可用协议。例如,我安装了 [telegram-purple][9] 包,它增加了连接到 Telegram 的能力。我可以使用 `account add` 命令将我的电话号码作为帐户添加。 + +``` +account add telegram +15555555 +``` + +BitlBee 将显示它已添加帐户。你可以使用 `account list` 列出你的帐户。因为我只有一个帐户,我可以通过 `account 0 on` 登录,它会进行 Telegram 登录,列出我所有的朋友和聊天,接下来就能正常聊天了。 + +但是,对于 Slack 这个最常见的聊天系统之一呢?你可以安装 [slack-libpurple][10] 插件,并且对 Slack 执行同样的操作。如果你不愿意编译和安装这些,这可能不适合你。 + +按照插件页面上的说明操作,安装后重新启动 BitlBee 服务。现在,当你运行 `help purple` 时,应该会列出 Slack。像其他协议一样添加一个 Slack 帐户。 + +``` +account add slack ksonney@myslack.slack.com +account 1 set password my_legcay_API_token +account 1 on +``` + +你知道么,你已经连接到 Slack 中,你可以通过 `chat add` 命令添加你感兴趣的 Slack 频道。比如: + +``` +chat add 1 happyparty +``` + +将 Slack 频道 happyparty 添加为本地频道 #happyparty。现在可以使用标准 IRC `/join` 命令访问该频道。这很酷。 + +BitlBee 和 IRC 客户端帮助我的(大部分)聊天和即时消息保存在一个地方,并减少了我的分心,因为我不再需要查找并切换到任何一个刚刚找我的应用上。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/open-source-chat-tool + +作者:[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/laptop_screen_desk_work_chat_text.png?itok=UXqIDRDD (Person using a laptop) +[2]: https://opensource.com/sites/default/files/uploads/productivity_9-1.png (BitlBee on XChat) +[3]: https://www.bitlbee.org/ +[4]: https://developer.pidgin.im/wiki/WhatIsLibpurple +[5]: http://pidgin.im/ +[6]: http://xchat.org/ +[7]: https://opensource.com/sites/default/files/uploads/productivity_9-2.png (Initial BitlBee connection) +[8]: https://opensource.com/sites/default/files/uploads/productivity_9-3.png (purple settings) +[9]: https://github.com/majn/telegram-purple +[10]: https://github.com/dylex/slack-libpurple +[11]: mailto:ksonney@myslack.slack.com diff --git a/published/202002/20200120 Use this Twitter client for Linux to tweet from the terminal.md b/published/202002/20200120 Use this Twitter client for Linux to tweet from the terminal.md new file mode 100644 index 0000000000..6a6bf89b13 --- /dev/null +++ b/published/202002/20200120 Use this Twitter client for Linux to tweet from the terminal.md @@ -0,0 +1,65 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11858-1.html) +[#]: subject: (Use this Twitter client for Linux to tweet from the terminal) +[#]: via: (https://opensource.com/article/20/1/tweet-terminal-rainbow-stream) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用这个 Twitter 客户端在 Linux 终端中发推特 +====== + +> 在我们的 20 个使用开源提升生产力的系列的第十篇文章中,使用 Rainbow Stream 跟上你的 Twitter 流而无需离开终端。 + +![](https://img.linux.net.cn/data/attachment/album/202002/06/113720bwi55j7xcccwwwi0.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 通过 Rainbow Stream 跟上Twitter + +我喜欢社交网络和微博。它快速、简单,还有我可以与世界分享我的想法。当然,缺点是几乎所有非 Windows 的桌面客户端都对是网站的封装。[Twitter][2] 有很多客户端,但我真正想要的是轻量、易于使用,最重要的是吸引人的客户端。 + +![Rainbow Stream for Twitter][3] + +[Rainbow Stream][4] 是好看的 Twitter 客户端之一。它简单易用,并且可以通过 `pip3 install rainbowstream` 快速安装。第一次运行时,它将打开浏览器窗口,并让你通过 Twitter 授权。完成后,你将回到命令行,你的 Twitter 时间线将开始滚动。 + +![Rainbow Stream first run][5] + +要了解的最重要的命令是 `p` 暂停推流、`r` 继续推流、`h` 得到帮助,以及 `t` 发布新的推文。例如,`h tweets` 将提供发送和回复推文的所有选项。另一个有用的帮助页面是 `h messages`,它提供了处理直接消息的命令,这是我妻子和我经常使用的东西。还有很多其他命令,我会回头获得很多帮助。 + +随着时间线的滚动,你可以看到它有完整的 UTF-8 支持,并以正确的字体显示推文被转推以及喜欢的次数,图标和 emoji 也能正确显示。 + +![Kill this love][6] + +关于 Rainbow Stream 的*最好*功能之一就是你不必放弃照片和图像。默认情况下,此功能是关闭的,但是你可以使用 `config` 命令尝试它。 + +``` +config IMAGE_ON_TERM = true +``` + +此命令将任何图像渲染为 ASCII 艺术。如果你有大量照片流,它可能会有点多,但是我喜欢。它有非常复古的 1990 年代 BBS 感觉,我也确实喜欢 1990 年代的 BBS 场景。 + +你还可以使用 Rainbow Stream 管理列表、屏蔽某人、拉黑某人、关注、取消关注以及 Twitter API 的所有其他功能。它还支持主题,因此你可以用喜欢的颜色方案自定义流。 + +当我正在工作并且不想在浏览器上打开另一个选项卡时,Rainbow Stream 让我可以留在终端中。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/tweet-terminal-rainbow-stream + +作者:[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/talk_chat_communication_team.png?itok=CYfZ_gE7 (Chat bubbles) +[2]: https://twitter.com/home +[3]: https://opensource.com/sites/default/files/uploads/productivity_10-1.png (Rainbow Stream for Twitter) +[4]: https://rainbowstream.readthedocs.io/en/latest/ +[5]: https://opensource.com/sites/default/files/uploads/productivity_10-2.png (Rainbow Stream first run) +[6]: https://opensource.com/sites/default/files/uploads/day10-image3_1.png (Kill this love) diff --git a/published/202002/20200121 Read Reddit from the Linux terminal.md b/published/202002/20200121 Read Reddit from the Linux terminal.md new file mode 100644 index 0000000000..2910769f83 --- /dev/null +++ b/published/202002/20200121 Read Reddit from the Linux terminal.md @@ -0,0 +1,63 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11869-1.html) +[#]: subject: (Read Reddit from the Linux terminal) +[#]: via: (https://opensource.com/article/20/1/open-source-reddit-client) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +在 Linux 终端中阅读 Reddit +====== + +> 在我们的 20 个使用开源提升生产力的系列的第十一篇文章中使用 Reddit 客户端 Tuir 在工作中短暂休息一下。 + +![](https://img.linux.net.cn/data/attachment/album/202002/09/104113w1ytjmlv1jly0j1t.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 Tuir 阅读 Reddit + +短暂休息对于保持生产力很重要。我休息时喜欢去的地方之一是 [Reddit][2],如果你愿意,这可能是一个很好的资源。我在那里发现了各种有关 DevOps、生产力、Emacs、鸡和 ChromeOS 项目的文章。这些讨论可能很有价值。我还关注了一些只有动物图片的子板,因为我喜欢动物(而不只是鸡)照片,有时经过长时间的工作后,我真正需要的是小猫照片。 + +![/r/emacs in Tuir][3] + +当我阅读 Reddit(不仅仅是看动物宝宝的图片)时,我使用 [Tuir][4](Reddit 终端 UI)。Tuir 是功能齐全的 Reddit 客户端,可以在运行 Python 的任何系统上运行。安装是通过 `pip` 完成的,非常简单。 + +首次运行时,Tuir 会进入 Reddit 默认文章列表。屏幕的顶部和底部有列出不同命令的栏。顶部栏显示你在 Reddit 上的位置,第二行显示根据 Reddit “Hot/New/Controversial” 等类别筛选的命令。按下筛选器前面的数字触发筛选。 + +![Filtering by Reddit's "top" category][5] + +你可以使用箭头键或 `j`、`k`、`h` 和 `l` 键浏览列表,这与 Vi/Vim 使用的键相同。底部栏有用于应用导航的命令。如果要跳转到另一个子板,只需按 `/` 键打开提示,然后输入你要进入的子板名称。 + +![Logging in][6] + +某些东西除非你登录,否则无法访问。如果你尝试执行需要登录的操作,那么 Tuir 就会提示你,例如发布新文章 (`c`)或赞成/反对 (`a` 和 `z`)。要登录,请按 `u` 键。这将打开浏览器以通过 OAuth2 登录,Tuir 将保存令牌。之后,你的用户名应出现在屏幕的右上方。 + +Tuir 还可以打开浏览器来查看图像、加载链接等。稍作调整,它甚至可以在终端中显示图像(尽管我没有让它可以正常工作)。 + +总的来说,我对 Tuir 在我需要休息时能快速跟上 Reddit 感到很满意。 + +Tuir 是现已淘汰的 [RTV][7] 的两个分叉之一。另一个是 [TTRV][8],它还无法通过 `pip` 安装,但功能相同。我期待看到它们随着时间的推移脱颖而出。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/open-source-reddit-client + +作者:[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_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet) +[2]: https://www.reddit.com/ +[3]: https://opensource.com/sites/default/files/uploads/productivity_11-1.png (/r/emacs in Tuir) +[4]: https://gitlab.com/ajak/tuir +[5]: https://opensource.com/sites/default/files/uploads/productivity_11-2.png (Filtering by Reddit's "top" category) +[6]: https://opensource.com/sites/default/files/uploads/productivity_11-3.png (Logging in) +[7]: https://github.com/michael-lazar/rtv +[8]: https://github.com/tildeclub/ttrv diff --git a/published/202002/20200122 Get your RSS feeds and podcasts in one place with this open source tool.md b/published/202002/20200122 Get your RSS feeds and podcasts in one place with this open source tool.md new file mode 100644 index 0000000000..ec53804d3a --- /dev/null +++ b/published/202002/20200122 Get your RSS feeds and podcasts in one place with this open source tool.md @@ -0,0 +1,72 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11876-1.html) +[#]: subject: (Get your RSS feeds and podcasts in one place with this open source tool) +[#]: via: (https://opensource.com/article/20/1/open-source-rss-feed-reader) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用此开源工具在一起收取你的 RSS 订阅源和播客 +====== + +> 在我们的 20 个使用开源提升生产力的系列的第十二篇文章中使用 Newsboat 收取你的新闻 RSS 源和播客。 + +![](https://img.linux.net.cn/data/attachment/album/202002/10/162526wv5jdl0m12sw10md.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 Newsboat 访问你的 RSS 源和播客 + +RSS 新闻源是了解各个网站最新消息的非常方便的方法。除了 Opensource.com,我还会关注 [SysAdvent][2] sysadmin 年度工具,还有一些我最喜欢的作者以及一些网络漫画。RSS 阅读器可以让我“批处理”阅读内容,因此,我每天不会在不同的网站上花费很多时间。 + +![Newsboat][3] + +[Newsboat][4] 是一个基于终端的 RSS 订阅源阅读器,外观感觉很像电子邮件程序 [Mutt][5]。它使阅读新闻变得容易,并有许多不错的功能。 + +安装 Newsboat 非常容易,因为它包含在大多数发行版(以及 MacOS 上的 Homebrew)中。安装后,只需在 `~/.newsboat/urls` 中添加订阅源。如果你是从其他阅读器迁移而来,并有导出的 OPML 文件,那么可以使用以下方式导入: + +``` +newsboat -i +``` + +添加订阅源后,Newsboat 的界面非常熟悉,特别是如果你使用过 Mutt。你可以使用箭头键上下滚动,使用 `r` 检查某个源中是否有新项目,使用 `R` 检查所有源中是否有新项目,按回车打开订阅源,并选择要阅读的文章。 + +![Newsboat article list][6] + +但是,你不仅限于本地 URL 列表。Newsboat 还是 [Tiny Tiny RSS][7]、ownCloud 和 Nextcloud News 等新闻阅读服务以及一些 Google Reader 后续产品的客户端。[Newsboat 的文档][8]中涵盖了有关此的详细信息以及其他许多配置选项。 + +![Reading an article in Newsboat][9] + +#### 播客 + +Newsboat 还通过 Podboat 提供了[播客支持][10],Podboat 是一个附带的应用,它可帮助下载和排队播客节目。在 Newsboat 中查看播客源时,按下 `e` 将节目添加到你的下载队列中。所有信息将保存在 `~/.newsboat` 目录中的队列文件中。Podboat 读取此队列并将节目下载到本地磁盘。你可以在 Podboat 的用户界面(外观和行为类似于 Newsboat)执行此操作,也可以使用 `podboat -a` 让 Podboat 下载所有内容。作为播客人和播客听众,我认为这*真的*很方便。 + +![Podboat][11] + +总体而言,Newsboat 有一些非常好的功能,并且是一些基于 Web 或桌面应用的不错的轻量级替代方案。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/open-source-rss-feed-reader + +作者:[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/ship_captain_devops_kubernetes_steer.png?itok=LAHfIpek (Ship captain sailing the Kubernetes seas) +[2]: https://sysadvent.blogspot.com/ +[3]: https://opensource.com/sites/default/files/uploads/productivity_12-1.png (Newsboat) +[4]: https://newsboat.org +[5]: http://mutt.org/ +[6]: https://opensource.com/sites/default/files/uploads/productivity_12-2.png (Newsboat article list) +[7]: https://tt-rss.org/ +[8]: https://newsboat.org/releases/2.18/docs/newsboat.html +[9]: https://opensource.com/sites/default/files/uploads/productivity_12-3.png (Reading an article in Newsboat) +[10]: https://newsboat.org/releases/2.18/docs/newsboat.html#_podcast_support +[11]: https://opensource.com/sites/default/files/uploads/productivity_12-4.png (Podboat) diff --git a/published/202002/20200122 Screenshot your Linux system configuration with Bash tools.md b/published/202002/20200122 Screenshot your Linux system configuration with Bash tools.md new file mode 100644 index 0000000000..e8507162f9 --- /dev/null +++ b/published/202002/20200122 Screenshot your Linux system configuration with Bash tools.md @@ -0,0 +1,107 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11920-1.html) +[#]: subject: (Screenshot your Linux system configuration with Bash tools) +[#]: via: (https://opensource.com/article/20/1/screenfetch-neofetch) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +使用 Bash 工具截屏 Linux 系统配置 +====== + +> 使用 ScreenFetch 和 Neofetch 与其他人轻松分享你的 Linux 环境。 + +![](https://img.linux.net.cn/data/attachment/album/202002/23/124525yiiqs18ll736oro8.jpg) + +你可能有很多原因想要与他人分享你的 Linux 配置。你可能正在寻求帮助来对系统上的问题进行故障排除,或者你对所创建的环境感到非常自豪,因此想向其他开源爱好者展示。 + +你可以在 Bash 提示符下使用 `cat /proc/cpuinfo` 或 `lscpu` 命令获取某些信息。但是,如果你想共享更多详细信息,例如你的操作系统、内核、运行时间、shell 环境,屏幕分辨率等,那么可以选择两个很棒的工具:screenFetch 和 Neofetch。 + +### screenFetch + +[screenFetch][2] 是 Bash 命令行程序,它可以产生非常漂亮的系统配置和运行时间的截图。这是方便的与它人共享系统配置的方法。 + +在许多 Linux 发行版上安装 screenFetch 很简单。 + +在 Fedora 上,输入: + +``` +$ sudo dnf install screenfetch +``` + +在 Ubuntu 上,输入: + +``` +$ sudo apt install screenfetch +``` + +对于其他操作系统,包括 FreeBSD、MacOS 等,请查阅 screenFetch 的 wiki [安装页面][3]。安装 screenFetch 后,它可以生成详细而彩色的截图,如下所示: + +![screenFetch][4] + +ScreenFetch 还提供各种命令行选项来调整你的结果。例如,`screenfetch -v` 返回详细输出,逐行显示每个选项以及上面的显示。 + +`screenfetch -n` 在显示系统信息时消除了操作系统图标。 + +![screenfetch -n option][5] + +其他选项包括 `screenfetch -N`,它去除所有输出的颜色。`screenfetch -t`,它根据终端的大小截断输出。`screenFetch -E`,它可抑制错误输出。 + +请检查手册页来了解其他选项。screenFetch 在 GPLv3 许可证下的开源,你可以在它的 [GitHub 仓库][6]中了解有关该项目的更多信息。 + +### Neofetch + +[Neofetch][7] 是创建系统信息截图的另一个工具。它是用 Bash 3.2 编写的,在 [MIT 许可证][8]下开源。 + +根据项目网站所述,“Neofetch 支持近 150 种不同的操作系统。从 Linux 到 Windows,一直到 Minix、AIX 和 Haiku 等更晦涩的操作系统。” + +![Neofetch][9] + +该项目维护了一个 wiki,其中包含用于各种发行版和操作系统的出色的[安装文档][10]。 + +如果你使用的是 Fedora、RHEL 或 CentOS,那么可以在 Bash 提示符下使用以下命令安装 Neofetch: + +``` +$ sudo dnf install neofetch +``` + +在 Ubuntu 17.10 及更高版本上,你可以使用: + +``` +$ sudo apt install neofetch +``` + +首次运行时,Neofetch 将 `~/.config/neofetch/config.conf` 文件写入主目录(`.config/config.conf`),它让你可以[自定义和控制][11] Neofetch 输出的各个方面。例如,你可以配置 Neofetch 使用图像、ASCII 文件、你选择的壁纸,或者完全不使用。config.conf 文件还让与它人分享配置变得容易。 + +如果 Neofetch 不支持你的操作系统或不提供所需选项,请在项目的 [GitHub 仓库][12]中打开一个问题。 + +### 总结 + +无论为什么要共享系统配置,screenFetch 或 Neofetch 都应该能做到。你是否知道在 Linux 上提供此功能的另一个开源工具?请在评论中分享你的最爱。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/screenfetch-neofetch + +作者:[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/metrics_data_dashboard_system_computer_analytics.png?itok=oxAeIEI- (metrics and data shown on a computer screen) +[2]: https://github.com/KittyKatt/screenFetch +[3]: https://github.com/KittyKatt/screenFetch/wiki/Installation +[4]: https://opensource.com/sites/default/files/uploads/screenfetch.png (screenFetch) +[5]: https://opensource.com/sites/default/files/uploads/screenfetch-n.png (screenfetch -n option) +[6]: http://github.com/KittyKatt/screenFetch +[7]: https://github.com/dylanaraps/neofetch +[8]: https://github.com/dylanaraps/neofetch/blob/master/LICENSE.md +[9]: https://opensource.com/sites/default/files/uploads/neofetch.png (Neofetch) +[10]: https://github.com/dylanaraps/neofetch/wiki/Installation +[11]: https://github.com/dylanaraps/neofetch/wiki/Customizing-Info +[12]: https://github.com/dylanaraps/neofetch/issues diff --git a/published/202002/20200123 How to stop typosquatting attacks.md b/published/202002/20200123 How to stop typosquatting attacks.md new file mode 100644 index 0000000000..728bf29f50 --- /dev/null +++ b/published/202002/20200123 How to stop typosquatting attacks.md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11899-1.html) +[#]: subject: (How to stop typosquatting attacks) +[#]: via: (https://opensource.com/article/20/1/stop-typosquatting-attacks) +[#]: author: (Sam Bocetta https://opensource.com/users/sambocetta) + +如何防范误植攻击 +====== + +> 误植Typosquatting是一种引诱用户将敏感数据泄露给不法分子的方式,针对这种攻击方式,我们很有必要了解如何保护我们的组织、我们的开源项目以及我们自己。 + +![Gears above purple clouds][1] + +除了常规手段以外,网络罪犯还会利用社会工程的方式,试图让安全意识较弱的人泄露私人信息或是有价值的证书。很多[网络钓鱼骗局][2]的实质都是攻击者伪装成信誉良好的公司或组织,然后借此大规模传播病毒或恶意软件。 + +[误植][3]Typosquatting就是其中一个常用的手法。它是一种社会工程学的攻击方式,通过使用一些合法网站的错误拼写的 URL 以引诱用户访问恶意网站,这样的做法既使真正的原网站遭受声誉上的损害,又诱使用户向这些恶意网站提交个人敏感信息。因此,网站的管理人员和用户双方都应该意识到这个问题带来的风险,并采取措施加以保护。 + +一些由广大开发者在公共代码库中维护的开源软件通常都被认为具有安全上的优势,但当面临社会工程学攻击或恶意软件植入时,开源软件也需要注意以免受到伤害。 + +下面就来关注一下误植攻击的发展趋势,以及这种攻击方式在未来可能对开源软件造成的影响。 + +### 什么是误植? + +误植是一种非常特殊的网络犯罪形式,其背后通常是一个更大的网络钓鱼骗局。不法分子首先会购买和注册域名,而他们注册的域名通常是一个常用网站的错误拼写形式,例如在正确拼写的基础上添加一个额外的元音字母,又或者是将字母“i”替换成字母“l”。对于同一个正常域名,不法分子通常会注册数十个拼写错误的变体域名。 + +用户一旦访问这样的域名,不法分子的目的就已经成功了一半。为此,他们会通过电子邮件的方式,诱导用户访问这样的伪造域名。伪造域名指向的页面中,通常都带有一个简单的登录界面,还会附上熟悉的被模仿网站的徽标,尽可能让用户认为自己访问的是真实的网站。 + +如果用户没有识破这一个骗局,在页面中提交了诸如银行卡号、用户名、密码等敏感信息,这些数据就会被不法分子所完全掌控。进一步来看,如果这个用户在其它网站也使用了相同的用户名和密码,那就有同样受到波及的风险。受害者最终可能会面临身份被盗、信用记录被破坏等危险。 + +### 最近的一些案例 + +从网站的所有方来看,遭到误植攻击可能会带来一场公关危机。尽管网站域名的所有者没有参与到犯罪当中,但这会被认为是一次管理上的失职,因为域名所有者有主动防御误植攻击的责任,以避免这一类欺诈事件的发生。 + +在几年之前就发生过[一起案件][4],很多健康保险客户收到了一封指向 we11point.com 的钓鱼电子邮件,其中 URL 里正确的字母“l”被换成了数字“1”,从而导致一批用户成为了这一次攻击的受害者。 + +最初,与特定国家/地区相关的顶级域名是不允许随意注册的。但后来国际域名规则中放开这一限制之后,又兴起了一波新的误植攻击。例如最常见的一种手法就是注册一个与 .com 域名类似的 .om 域名,一旦在输入 URL 时不慎遗漏了字母 c 就会给不法分子带来可乘之机。 + +### 网站如何防范误植攻击 + +对于一个公司来说,最好的策略就是永远比误植攻击采取早一步的行动。 + +也就是说,在注册域名的时候,不仅要注册自己商标名称的域名,最好还要同时注册可能由于拼写错误产生的其它域名。当然,没有太大必要把可能导致错误的所有顶级域名都注册掉,但至少要把可能导致错误的一些一级域名抢注下来。 + +如果你有让用户跳转到一个第三方网站的需求,务必要让用户从你的官方网站上进行跳转,而不应该通过类似群发邮件的方式向用户告知 URL。因此,必须明确一个策略:在与用户通信交流时,不将用户引导到官方网站以外的地方去。在这样的情况下,如果有不法分子试图以你公司的名义发布虚假消息,用户将会从带有异样的页面或 URL 上有所察觉。 + +你可以使用类似 [DNS Twist][5] 的开源工具来扫描公司正在使用的域名,它可以确定是否有相似的域名已被注册,从而暴露潜在的误植攻击。DNS Twist 可以在 Linux 系统上通过一系列的 shell 命令来运行。 + +还有一些网络提供商(ISP)会将防护误植攻击作为他们网络产品的一部分。这就相当于一层额外的保护,如果用户不慎输入了带有拼写错误的 URL,就会被提示该页面已经被阻止并重定向到正确的域名。 + +如果你是系统管理员,还可以考虑运行一个自建的 [DNS 服务器][6],以便通过黑名单的机制禁止对某些域名的访问。 + +你还可以密切监控网站的访问流量,如果来自某个特定地区的用户被集体重定向到了虚假的站点,那么访问量将会发生骤降。这也是一个有效监控误植攻击的角度。 + +防范误植攻击与防范其它网络攻击一样需要保持警惕。所有用户都希望网站的所有者能够扫除那些与正主类似的假冒站点,如果这项工作没有做好,用户的信任对你的信任程度就会每况愈下。 + +### 误植对开源软件的影响 + +因为开源项目的源代码是公开的,所以其中大部分项目都会进行安全和渗透测试。但错误是不可能完全避免的,如果你参与了开源项目,还是有需要注意的地方。 + +当你收到一个不明来源的合并请求Merge Request或补丁时,必须在合并之前仔细检查,尤其是相关代码涉及到网络层面的时候。不要屈服于只测试构建的诱惑; 一定要进行严格的检查和测试,以确保没有恶意代码混入正常的代码当中。 + +同时,还要严格按照正确的方法使用域名,避免不法分子创建仿冒的下载站点并提供带有恶意代码的软件。可以通过如下所示的方法使用数字签名来确保你的软件没有被篡改: + +``` +gpg --armor --detach-sig \ + --output advent-gnome.sig \ + example-0.0.1.tar.xz +``` + +同时给出你提供的文件的校验和: + +``` +sha256sum example-0.0.1.tar.xz > example-0.0.1.txt +``` + +无论你的用户会不会去用上这些安全措施,你也应该提供这些必要的信息。因为只要有那么一个人留意到签名有异样,就能为你敲响警钟。 + +### 总结 + +人类犯错在所难免。世界上数百万人输入同一个网址时,总会有人出现拼写的错误。不法分子也正是抓住了这个漏洞才得以实施误植攻击。 + +用抢注域名的方式去完全根治误植攻击也是不太现实的,我们更应该关注这种攻击的传播方式以减轻它对我们的影响。最好的保护就是和用户之间建立信任,并积极检测误植攻击的潜在风险。作为开源社区,我们更应该团结起来一起应对误植攻击。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/stop-typosquatting-attacks + +作者:[Sam Bocetta][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sambocetta +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/chaos_engineer_monster_scary_devops_gear_kubernetes.png?itok=GPYLvfVh (Gears above purple clouds) +[2]: https://www.cloudberrylab.com/resources/guides/types-of-phishing/ +[3]: https://en.wikipedia.org/wiki/Typosquatting +[4]: https://www.menlosecurity.com/blog/-a-new-approach-to-end-typosquatting +[5]: https://github.com/elceef/dnstwist +[6]: https://opensource.com/article/17/4/build-your-own-name-server diff --git a/published/202002/20200123 Use this open source tool to get your local weather forecast.md b/published/202002/20200123 Use this open source tool to get your local weather forecast.md new file mode 100644 index 0000000000..e0022dfdee --- /dev/null +++ b/published/202002/20200123 Use this open source tool to get your local weather forecast.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11879-1.html) +[#]: subject: (Use this open source tool to get your local weather forecast) +[#]: via: (https://opensource.com/article/20/1/open-source-weather-forecast) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用这个开源工具获取本地天气预报 +====== + +> 在我们的 20 个使用开源提升生产力的系列的第十三篇文章中使用 wego 来了解出门前你是否要需要外套、雨伞或者防晒霜。 + +![](https://img.linux.net.cn/data/attachment/album/202002/11/140842a8qwomfeg9mwegg8.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 wego 了解天气 + +过去十年我对我的职业最满意的地方之一是大多数时候是远程工作。尽管现实情况是我很多时候是在家里办公,但我可以在世界上任何地方工作。缺点是,离家时我会根据天气做出一些决定。在我居住的地方,“晴朗”可以表示从“酷热”、“低于零度”到“一小时内会小雨”。能够了解实际情况和快速预测非常有用。 + +![Wego][2] + +[Wego][3] 是用 Go 编写的程序,可以获取并显示你的当地天气。如果你愿意,它甚至可以用闪亮的 ASCII 艺术效果进行渲染。 + +要安装 `wego`,你需要确保在系统上安装了[Go][4]。之后,你可以使用 `go get` 命令获取最新版本。你可能还想将 `~/go/bin` 目录添加到路径中: + +``` +go get -u github.com/schachmat/wego +export PATH=~/go/bin:$PATH +wego +``` + +首次运行时,`wego` 会报告缺失 API 密钥。现在你需要决定一个后端。默认后端是 [Forecast.io][5],它是 [Dark Sky][6]的一部分。`wego` 还支持 [OpenWeatherMap][7] 和 [WorldWeatherOnline][8]。我更喜欢 OpenWeatherMap,因此我将在此向你展示如何设置。 + +你需要在 OpenWeatherMap 中[注册 API 密钥][9]。注册是免费的,尽管免费的 API 密钥限制了一天可以查询的数量,但这对于普通用户来说应该没问题。得到 API 密钥后,将它放到 `~/.wegorc` 文件中。现在可以填写你的位置、语言以及使用公制、英制(英国/美国)还是国际单位制(SI)。OpenWeatherMap 可通过名称、邮政编码、坐标和 ID 确定位置,这是我喜欢它的原因之一。 + +``` +# wego configuration for OEM +aat-coords=false +aat-monochrome=false +backend=openweathermap +days=3 +forecast-lang=en +frontend=ascii-art-table +jsn-no-indent=false +location=Pittsboro +owm-api-key=XXXXXXXXXXXXXXXXXXXXX +owm-debug=false +owm-lang=en +units=imperial +``` + +现在,在命令行运行 `wego` 将显示接下来三天的当地天气。 + +`wego` 还可以输出 JSON 以便程序使用,还可显示 emoji。你可以使用 `-f` 参数或在 `.wegorc` 文件中指定前端。 + +![Wego at login][10] + +如果你想在每次打开 shell 或登录主机时查看天气,只需将 wego 添加到 `~/.bashrc`(我这里是 `~/.zshrc`)即可。 + +[wttr.in][11] 项目是 wego 上的基于 Web 的封装。它提供了一些其他显示选项,并且可以在同名网站上看到。关于 wttr.in 的一件很酷的事情是,你可以使用 `curl` 获取一行天气信息。我有一个名为 `get_wttr` 的 shell 函数,用于获取当前简化的预报信息。 + +``` +get_wttr() { +  curl -s "wttr.in/Pittsboro?format=3"     +} +``` + +![weather tool for productivity][12] + +现在,在我离开家之前,我就可以通过命令行快速简单地获取我是否需要外套、雨伞或者防晒霜了。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/open-source-weather-forecast + +作者:[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/bus-cloud.png?itok=vz0PIDDS (Sky with clouds and grass) +[2]: https://opensource.com/sites/default/files/uploads/productivity_13-1.png (Wego) +[3]: https://github.com/schachmat/wego +[4]: https://golang.org/doc/install +[5]: https://forecast.io +[6]: https://darksky.net +[7]: https://openweathermap.org/ +[8]: https://www.worldweatheronline.com/ +[9]: https://openweathermap.org/api +[10]: https://opensource.com/sites/default/files/uploads/productivity_13-2.png (Wego at login) +[11]: https://github.com/chubin/wttr.in +[12]: https://opensource.com/sites/default/files/uploads/day13-image3.png (weather tool for productivity) diff --git a/published/202002/20200124 3 handy command-line internet speed tests.md b/published/202002/20200124 3 handy command-line internet speed tests.md new file mode 100644 index 0000000000..58426cffea --- /dev/null +++ b/published/202002/20200124 3 handy command-line internet speed tests.md @@ -0,0 +1,147 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11882-1.html) +[#]: subject: (3 handy command-line internet speed tests) +[#]: via: (https://opensource.com/article/20/1/internet-speed-tests) +[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall) + +3 个方便的命令行网速测试工具 +====== + +> 用这三个开源工具检查你的互联网和局域网速度。 + +![](https://img.linux.net.cn/data/attachment/album/202002/12/115915kk6hkax1vparkuvk.jpg) + +能够验证网络连接速度使您可以控制计算机。 使您可以在命令行中检查互联网和网络速度的三个开源工具是 Speedtest、Fast 和 iPerf。 + +### Speedtest + +[Speedtest][2] 是一个旧宠。它用 Python 实现,并打包在 Apt 中,也可用 `pip` 安装。你可以将它作为命令行工具或在 Python 脚本中使用。 + +使用以下命令安装: + +``` +sudo apt install speedtest-cli +``` + +或者 + +``` +sudo pip3 install speedtest-cli +``` + +然后使用命令 `speedtest` 运行它: + +``` +$ speedtest +Retrieving speedtest.net configuration... +Testing from CenturyLink (65.128.194.58)... +Retrieving speedtest.net server list... +Selecting best server based on ping... +Hosted by CenturyLink (Cambridge, UK) [20.49 km]: 31.566 ms +Testing download speed................................................................................ +Download: 68.62 Mbit/s +Testing upload speed...................................................................................................... +Upload: 10.93 Mbit/s +``` + +它给你提供了互联网上传和下载的网速。它快速而且可脚本调用,因此你可以定期运行它,并将输出保存到文件或数据库中,以记录一段时间内的网络速度。 + +### Fast + +[Fast][3] 是 Netflix 提供的服务。它的网址是 [Fast.com][4],同时它有一个可通过 `npm` 安装的命令行工具: + +``` +npm install --global fast-cli +``` + +网站和命令行程序都提供了相同的基本界面:它是一个尽可能简单的速度测试: + +``` +$ fast + +     82 Mbps ↓ +``` + +该命令返回你的网络下载速度。要获取上传速度,请使用 `-u` 标志: + +``` +$ fast -u + +   ⠧ 80 Mbps ↓ / 8.2 Mbps ↑ +``` + +### iPerf + +[iPerf][5] 测试的是局域网速度(而不是像前两个工具一样测试互联网速度)的好方法。Debian、Raspbian 和 Ubuntu 用户可以使用 apt 安装它: + +``` +sudo apt install iperf +``` + +它还可用于 Mac 和 Windows。 + +安装完成后,你需要在同一网络上的两台计算机上使用它(两台都必须安装 iPerf)。指定其中一台作为服务器。 + +获取服务端计算机的 IP 地址: + +``` +ip addr show | grep inet.*brd +``` + +你的本地 IP 地址(假设为 IPv4 本地网络)以 `192.168` 或 `10` 开头。记下 IP 地址,以便可以在另一台计算机(指定为客户端的计算机)上使用它。 + +在服务端启动 `iperf`: + +``` +iperf -s +``` + +它会等待来自客户端的传入连接。将另一台计算机作为为客户端并运行此命令,将示例中的 IP 替换为服务端计算机的 IP: + +``` +iperf -c 192.168.1.2 +``` + +![iPerf][6] + +只需几秒钟即可完成测试,然后返回传输大小和计算出的带宽。我使用家用服务器作为服务端,在 PC 和笔记本电脑上进行了一些测试。我最近在房屋周围安装了六类线以太网,因此我的有线连接速度达到 1Gbps,但 WiFi 连接速度却低得多。 + +![iPerf][7] + +你可能注意到它记录到 16Gbps。那是我使用服务器进行自我测试,因此它只是在测试写入磁盘的速度。该服务器具有仅 16 Gbps 的硬盘驱动器,但是我的台式机有 46Gbps,另外我的(较新的)笔记本超过了 60Gbps,因为它们都有固态硬盘。 + +![iPerf][8] + +### 总结 + +通过这些工具来了解你的网络速度是一项非常简单的任务。如果你更喜欢脚本或者在命令行中运行,上面的任何一个都能满足你。如果你要了解点对点的指标,iPerf 能满足你。 + +你还使用其他哪些工具来衡量家庭网络?在评论中分享你的评论。 + +本文最初发表在 Ben Nuttall 的 [Tooling blog][9] 上,并获准在此使用。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/internet-speed-tests + +作者:[Ben Nuttall][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/bennuttall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/train-plane-speed-big-machine.png?itok=f377dXKs (Old train) +[2]: https://github.com/sivel/speedtest-cli +[3]: https://github.com/sindresorhus/fast-cli +[4]: https://fast.com/ +[5]: https://iperf.fr/ +[6]: https://opensource.com/sites/default/files/uploads/iperf.png (iPerf) +[7]: https://opensource.com/sites/default/files/uploads/iperf2.png (iPerf) +[8]: https://opensource.com/sites/default/files/uploads/iperf3.png (iPerf) +[9]: https://tooling.bennuttall.com/command-line-speedtest-tools/ diff --git a/published/202002/20200124 Run multiple consoles at once with this open source window environment.md b/published/202002/20200124 Run multiple consoles at once with this open source window environment.md new file mode 100644 index 0000000000..33593eb788 --- /dev/null +++ b/published/202002/20200124 Run multiple consoles at once with this open source window environment.md @@ -0,0 +1,111 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11892-1.html) +[#]: subject: (Run multiple consoles at once with this open source window environment) +[#]: via: (https://opensource.com/article/20/1/multiple-consoles-twin) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用开源窗口环境 twin 一次运行多个控制台 +====== + +> 在我们的 20 个使用开源提升生产力的系列的第十四篇文章中用 twin 模拟了老式的 DESQview 体验。 + +![](https://img.linux.net.cn/data/attachment/album/202002/14/193658tlbyft0lbu44f0s3.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 通过 twin 克服“一个屏幕,一个应用程序”的限制 + +还有人记得 [DESQview][2] 吗?我们在 Windows、Linux 和 MacOS 中理所当然地可以在屏幕上同时运行多个程序,而 DESQview 赋予了 DOS 同样的功能。在我运营拨号 BBS 服务的初期,DESQview 是必需的,它使我能够让 BBS 在后台运行,同时在前台进行其他操作。例如,当有人拨打电话时,我可能正在开发新功能或设置新的外部程序而不会影响他们的体验。后来,在我早期做支持工作的时候,我可以同时运行我的工作电子邮件([MHS 上的 DaVinci 电子邮件][3])、支持单据系统和其他 DOS 程序。这是令人吃惊的! + +![twin][4] + +从那时起,运行多个控制台应用程序的功能已经发展了很多。但是 [tmux][5] 和 [Screen][6] 等应用仍然遵循“一个屏幕,一个应用”的显示方式。好吧,是的,tmux 具有屏幕拆分和窗格,但是不像 DESQview 那样具有将窗口“浮动”在其他窗口上的功能,就我个人而言,我怀念那个功能。 + +让我们来看看 [twin][7](文本模式窗口环境)。我认为,这个相对年轻的项目是 DESQview 的精神继任者。它支持控制台和图形环境,并具有与会话脱离和重新接驳的功能。设置起来并不是那么容易,但是它可以在大多数现代操作系统上运行。 + +Twin 是从源代码安装的(现在是这样)。但是首先,你需要安装所需的开发库。库名称将因操作系统而异。 以下示例显示了在我的 Ubuntu 19.10 系统中的情况。一旦安装了依赖库,请从 Git 中检出 twin 源代码,并运行 `./configure` 和 `make`,它们应自动检测所有内容并构建 twin: + +``` +sudo apt install libx11-dev libxpm-dev libncurses-dev zlib1g-dev libgpm-dev +git clone git@github.com:cosmos72/twin.git +cd twin +./configure +make +sudo make install +``` + +注意:如果要在 MacOS 或 BSD 上进行编译,则需要在运行 `make` 之前在文件 `include/Tw/autoconf.h` 和 `include/twautoconf.h` 中注释掉 `#define socklen_t int`。这个问题应该在 [twin #57][9] 解决了。 + +![twin text mode][10] + +第一次调用 twin 是一个挑战。你需要通过 `--hw` 参数告诉它正在使用哪种显示。例如,要启动文本模式的 twin,请输入 `twin --hw=tty,TERM=linux`。这里指定的 `TERM` 变量替代了你当前 Shell 中终端变量。要启动图形版本,运行 `twin --hw=X@$DISPLAY`。在 Linux 上,twin 一般都“可以正常工作”,而在 MacOS 上,Twin 基本是只能在终端上使用。 + +*真正*的乐趣是可以通过 `twattach` 和 `twdisplay` 命令接驳到正在运行的会话的功能。它们使你可以接驳到其他正在运行的 twin 会话。例如,在 Mac 上,我可以运行以下命令以接驳到演示机器上运行的 twin 会话: + +``` +twdisplay --twin@20days2020.local:0 --hw=tty,TERM=linux +``` + +![remote twin session][11] + +通过多做一些工作,你还可以将其用作登录外壳,以代替控制台上的 [getty][12]。这需要 gdm 鼠标守护程序、twdm 应用程序(包括)和一些额外的配置。在使用 systemd 的系统上,首先安装并启用 gdm(如果尚未安装),然后使用 `systemctl` 为控制台(我使用 tty6)创建一个覆盖。这些命令必须以 root 用户身份运行;在 Ubuntu 上,它们看起来像这样: + +``` +apt install gdm +systemctl enable gdm +systemctl start gdm +systemctl edit getty@tty6 +``` + +`systemctl edit getty@tty6` 命令将打开一个名为 `override.conf` 的空文件。它可以定义 systemd 服务设置以覆盖 tty6 的默认设置。将内容更新为: + +``` +[service] +ExecStart= +ExecStart=-/usr/local/sbin/twdm --hw=tty@/dev/tty6,TERM=linux +StandardInput=tty +StandardOutput=tty +``` + +现在,重新加载 systemd 并重新启动 tty6 以获得 twin 登录提示界面: + +``` +systemctl daemon-reload +systemctl restart getty@tty6 +``` + +![twin][13] + +这将为登录的用户启动一个 twin 会话。我不建议在多用户系统中使用此会话,但是对于个人桌面来说,这是很酷的。并且,通过使用 `twattach` 和 `twdisplay`,你可以从本地 GUI 或远程桌面访问该会话。 + +我认为 twin 真是太酷了。它还有一些细节不够完善,但是基本功能都已经有了,并且有一些非常好的文档。另外,它也使我可以在现代操作系统上稍解对 DESQview 式的体验的渴望。我希望随着时间的推移它会有所改进,希望你和我一样喜欢它。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/multiple-consoles-twin + +作者:[Kevin Sonney][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/ksonney +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet) +[2]: https://en.wikipedia.org/wiki/DESQview +[3]: https://en.wikipedia.org/wiki/Message_Handling_System +[4]: https://opensource.com/sites/default/files/uploads/productivity_14-1.png (twin) +[5]: https://github.com/tmux/tmux/wiki +[6]: https://www.gnu.org/software/screen/ +[7]: https://github.com/cosmos72/twin +[8]: mailto:git@github.com +[9]: https://github.com/cosmos72/twin/issues/57 +[10]: https://opensource.com/sites/default/files/uploads/productivity_14-2.png (twin text mode) +[11]: https://opensource.com/sites/default/files/uploads/productivity_14-3.png (remote twin session) +[12]: https://en.wikipedia.org/wiki/Getty_(Unix) +[13]: https://opensource.com/sites/default/files/uploads/productivity_14-4.png (twin) diff --git a/published/202002/20200125 Use tmux to create the console of your dreams.md b/published/202002/20200125 Use tmux to create the console of your dreams.md new file mode 100644 index 0000000000..9e1d32dbd3 --- /dev/null +++ b/published/202002/20200125 Use tmux to create the console of your dreams.md @@ -0,0 +1,117 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11900-1.html) +[#]: subject: (Use tmux to create the console of your dreams) +[#]: via: (https://opensource.com/article/20/1/tmux-console) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 tmux 创建你的梦想主控台 +====== + +> 使用 tmux 可以做很多事情,尤其是在将 tmuxinator 添加到其中时。在我们的二十篇系列文章的第十五期中查看它们,以在 2020 年实现开源生产力的提高。 + +![](https://img.linux.net.cn/data/attachment/album/202002/16/220832bd4l1ag4tlqxlpr4.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 tmux 和 tmuxinator 全部放到主控台上 + +到目前为止,在本系列文章中,我已经撰写了有关单个应用程序和工具的文章。从今天开始,我将把它们放在一起进行全面设置以简化操作。让我们从命令行开始。为什么使用命令行?简而言之,在命令行上工作可以使我能够从运行 SSH 的任何位置访问许多这些工具和功能。我可以 SSH 进入我的一台个人计算机,并在工作计算机上运行与我的个人计算机上所使用的相同设置。我要使用的主要工具是 [tmux][2]。 + +大多数人都只使用了 tmux 非常基础的功能,比如说在远程服务器上打开 tmux,然后启动进程,也许还会打开第二个会话以查看日志文件或调试信息,然后断开连接并在稍后返回。但是其实你可以使用 tmux 做很多工作。 + +![tmux][3] + +首先,如果你有一个已有的 tmux 配置文件,请对其进行备份。tmux 的配置文件是 `~/.tmux.conf`。将其移动到另一个目录,例如 `~/tmp`。现在,用 Git 克隆 [Oh My Tmux][4] 项目。从该克隆目录中将 `.tmux.conf` 符号链接到你的家目录,并复制该克隆目录中的 `.tmux.conf.local` 文件到家目录中以进行调整: + +``` +cd ~ +mkdir ~/tmp +mv ~/.tmux.conf ~/tmp/ +git clone https://github.com/gpakosz/.tmux.git +ln -s ~/.tmux/.tmux.conf ./ +cp ~/.tmux/.tmux.conf.local ./ +``` + +`.tmux.conf.local` 文件包含了本地设置和覆盖的设置。例如,我稍微更改了默认颜色,然后启用了 [Powerline][5] 分隔线。下面的代码段仅显示了我更改过的内容: + +``` +tmux_conf_theme_24b_colour=true +tmux_conf_theme_focused_pane_bg='default' +tmux_conf_theme_pane_border_style=fat +tmux_conf_theme_left_separator_main='\uE0B0' +tmux_conf_theme_left_separator_sub='\uE0B1' +tmux_conf_theme_right_separator_main='\uE0B2' +tmux_conf_theme_right_separator_sub='\uE0B3' +#tmux_conf_battery_bar_symbol_full='◼' +#tmux_conf_battery_bar_symbol_empty='◻' +tmux_conf_battery_bar_symbol_full='♥' +tmux_conf_battery_bar_symbol_empty='·' +tmux_conf_copy_to_os_clipboard=true +set -g mouse on +``` + +请注意,你不需要安装 Powerline,你只需要支持 Powerline 符号的字体即可。我在与控制台相关的所有内容中几乎都使用 [Hack Nerd Font][6],因为它易于阅读并且具有许多有用的额外符号。你还会注意到,我打开了操作系统剪贴板支持和鼠标支持。 + +现在,当 tmux 启动时,底部的状态栏会以吸引人的颜色提供更多信息。`Ctrl` + `b` 仍然是输入命令的 “引导” 键,但其他一些进行了更改。现在水平拆分(顶部/底部)窗格为 `Ctrl` + `b` + `-`,垂直拆分为 `Ctrl` + `b` + `_`。启用鼠标模式后,你可以单击以在窗格之间切换,并拖动分隔线以调整其大小。打开新窗口仍然是 `Ctrl` + `b` + `n`,你现在可以单击底部栏上的窗口名称在它们之间进行切换。同样,`Ctrl` + `b` + `e` 将打开 `.tmux.conf.local` 文件以进行编辑。退出编辑器时,tmux 将重新加载配置,而不会重新加载其他任何内容。这很有用。 + +到目前为止,我仅对功能和视觉显示进行了一些简单的更改,并增加了鼠标支持。现在,我将它设置为以一种有意义的方式启动我想要的应用程序,而不必每次都重新定位和调整它们的大小。为此,我将使用 [tmuxinator][7]。tmuxinator 是 tmux 的启动器,它允许你指定和管理布局以及使用 YAML 文件自动启动应用程序。要使用它,请启动 tmux 并创建要在其中运行程序的窗格。然后,使用 `Ctrl` + `b` + `n` 打开一个新窗口,并执行 `tmux list-windows`。你将获得有关布局的详细信息。 + +![tmux layout information][8] + +请注意上面代码中的第一行,我在其中设置了四个窗格,每个窗格中都有一个应用程序。保存运行时的输出以供以后使用。现在,运行 `tmuxinator new 20days` 以创建名为 “20days” 的布局。这将显示一个带有默认布局文件的文本编辑器。它包含很多有用的内容,我建议你阅读所有选项。首先输入上方的布局信息以及所需的应用程序: + +``` +# /Users/ksonney/.config/tmuxinator/20days.yml +name: 20days +root: ~/ +windows: + - mail: + layout: d9da,208x60,0,0[208x26,0,0{104x26,0,0,0,103x26,105,0,5},208x33,0,27{104x33,0,27,1,103x33,105,27,4}]] @0 + panes: + - alot + - abook + - ikhal + - todo.sh ls +20days +``` + +注意空格缩进!与 Python 代码一样,空格和缩进关系到文件的解释方式。保存该文件,然后运行 `tmuxinator 20days`。你应该会得到四个窗格,分别是 [alot][9] 邮件程序、[abook][10]、ikhal(交互式 [khal][11] 的快捷方式)以及 [todo.txt][12] 中带有 “+20days” 标签的任何内容。 + +![sample layout launched by tmuxinator][13] + +你还会注意到,底部栏上的窗口标记为 “Mail”。你可以单击该名称(以及其他命名的窗口)以跳到该视图。漂亮吧?我在同一个文件中还设置了名为 “Social” 的第二个窗口,包括 [Tuir][14]、[Newsboat][15]、连接到 [BitlBee][16] 的 IRC 客户端和 [Rainbow Stream][17]。 + +tmux 是我跟踪所有事情的生产力动力之源,有了 tmuxinator,我不必在不断调整大小、放置和启动我的应用程序上费心。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/tmux-console + +作者:[Kevin Sonney][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/ksonney +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_tea_laptop_computer_work_desk.png?itok=D5yMx_Dr (Person drinking a hat drink at the computer) +[2]: https://github.com/tmux/tmux +[3]: https://opensource.com/sites/default/files/uploads/productivity_15-1.png (tumux) +[4]: https://github.com/gpakosz/.tmux +[5]: https://github.com/powerline/powerline +[6]: https://www.nerdfonts.com/ +[7]: https://github.com/tmuxinator/tmuxinator +[8]: https://opensource.com/sites/default/files/uploads/productivity_15-2.png (tmux layout information) +[9]: https://opensource.com/article/20/1/organize-email-notmuch +[10]: https://opensource.com/article/20/1/sync-contacts-locally +[11]: https://opensource.com/article/20/1/open-source-calendar +[12]: https://opensource.com/article/20/1/open-source-to-do-list +[13]: https://opensource.com/sites/default/files/uploads/productivity_15-3.png (sample layout launched by tmuxinator) +[14]: https://opensource.com/article/20/1/open-source-reddit-client +[15]: https://opensource.com/article/20/1/open-source-rss-feed-reader +[16]: https://opensource.com/article/20/1/open-source-chat-tool +[17]: https://opensource.com/article/20/1/tweet-terminal-rainbow-stream diff --git a/published/202002/20200126 Use Vim to send email and check your calendar.md b/published/202002/20200126 Use Vim to send email and check your calendar.md new file mode 100644 index 0000000000..032329e76e --- /dev/null +++ b/published/202002/20200126 Use Vim to send email and check your calendar.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11908-1.html) +[#]: subject: (Use Vim to send email and check your calendar) +[#]: via: (https://opensource.com/article/20/1/vim-email-calendar) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 Vim 发送邮件和检查日历 +====== + +> 在 2020 年用开源实现更高生产力的二十种方式的第十六篇文章中,直接通过文本编辑器管理你的电子邮件和日历。 + +![](https://img.linux.net.cn/data/attachment/album/202002/19/185842eyz2znxx1yc2ctnc.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 用 Vim 做(几乎)所有事情,第一部分 + +我经常使用两个文本编辑器 —— [Vim][2] 和 [Emacs][3]。为什么两者都用呢?它们有不同的使用场景,在本系列的后续几篇文章中,我将讨论其中的一些用例。 + +![][4] + +好吧,为什么要在 Vim 中执行所有操作?因为如果有一个应用程序是我可以访问的每台计算机上都有的,那就是 Vim。如果你像我一样,可能已经在 Vim 中打发了很多时光。那么,为什么不将其用于**所有事情**呢? + +但是,在此之前,你需要做一些事情。首先是确保你的 Vim 具有 Ruby 支持。你可以使用 `vim --version | grep ruby`。如果结果不是 `+ruby`,则需要解决这个问题。这可能有点麻烦,你应该查看发行版的文档以获取正确的软件包。在 MacOS 上,用的是官方的 MacVim(不是 Brew 发行的),在大多数 Linux 发行版中,用的是 vim-nox 或 vim-gtk,而不是 vim-gtk3。 + +我使用 [Pathogen][5] 自动加载插件和捆绑软件。如果你使用 [Vundle][6] 或其他 Vim 软件包管理器,则需要调整以下命令才能使用它。 + +#### 在 Vim 中管理你的邮件 + +使 Vim 在你的生产力计划中发挥更大作用的一个很好的起点是使用它通过 [Notmuch] [7] 发送和接收电子邮件,和使用 [abook] [8] 访问你的联系人列表。你需要为此安装一些东西。下面的所有示例代码都运行在 Ubuntu 上,因此如果你使用其他发行版,则需要对此进行调整。通过以下步骤进行设置: + +``` +sudo apt install notmuch-vim ruby-mail +curl -o ~/.vim/plugin/abook --create-dirs https://raw.githubusercontent.com/dcbaker/vim-abook/master/plugin/abook.vim +``` + +到目前为止,一切都很顺利。现在启动 Vim 并执行 `:NotMuch`。由于是用较旧版本的邮件库 `notmuch-vim` 编写的,可能会出现一些警告,但总的来说,Vim 现在将成为功能齐全的 Notmuch 邮件客户端。 + +![Reading Mail in Vim][9] + +如果要搜索特定标签,请输入 `\t`,输入标签名称,然后按回车。这将拉出一个带有该标签的所有消息的列表。`\s` 组合键会弹出 `Search:` 提示符,可以对 Notmuch 数据库进行全面搜索。使用箭头键浏览消息列表,按回车键显示所选项目,然后输入 `\q` 退出当前视图。 + +要撰写邮件,请使用 `\c` 按键。你将看到一条空白消息。这是 `abook.vim` 插件发挥作用的位置。按下 `Esc` 并输入 `:AbookQuery `,其中 `` 是你要查找的名称或电子邮件地址的一部分。你将在 abook 数据库中找到与你的搜索匹配的条目列表。通过键入你想要的地址的编号,将其添加到电子邮件的地址行中。完成电子邮件的键入和编辑,按 `Esc` 退出编辑模式,然后输入 `,s` 发送。 + +如果要在 `:NotMuch` 启动时更改默认文件夹视图,则可以将变量 `g:notmuch_folders` 添加到你的 `.vimrc` 文件中: + +``` +let g:notmuch_folders = [ + \ [ 'new', 'tag:inbox and tag:unread' ], + \ [ 'inbox', 'tag:inbox' ], + \ [ 'unread', 'tag:unread' ], + \ [ 'News', 'tag:@sanenews' ], + \ [ 'Later', 'tag:@sanelater' ], + \ [ 'Patreon', 'tag:@patreon' ], + \ [ 'LivestockConservancy', 'tag:livestock-conservancy' ], + \ ] +``` + +Notmuch 插件的文档中涵盖了更多设置,包括设置标签键和使用其它的邮件程序。 + +#### 在 Vim 中查询日历 + +![][10] + +遗憾的是,似乎没有使用 vCalendar 或 iCalendar 格式的 Vim 日历程序。有个 [Calendar.vim][11],做得很好。设置 Vim 通过以下方式访问你的日历: + +``` +cd ~/.vim/bundle +git clone git@github.com:itchyny/calendar.vim.git +``` + +现在,你可以通过输入 `:Calendar` 在 Vim 中查看日历。你可以使用 `<` 和 `>` 键在年、月、周、日和时钟视图之间切换。如果要从一个特定的视图开始,请使用 `-view=` 标志告诉它你希望看到哪个视图。你也可以在任何视图中定位日期。例如,如果我想查看 2020 年 7 月 4 日这一周的情况,请输入 `:Calendar -view week 7 4 2020`。它的帮助信息非常好,可以使用 `?` 键参看。 + +![][13] + +Calendar.vim 还支持 Google Calendar(我需要),但是在 2019 年 12 月,Google 禁用了它的访问权限。作者已在 [GitHub 上的这个提案][14]中发布了一种变通方法。 + +这样你就在 Vim 中有了这些:你的邮件、地址簿和日历。但是这些还没有完成; 下一篇你将在 Vim 上做更多的事情! + +Vim 为作家提供了很多好处,无论他们是否具有技术意识。 + +需要保持时间表正确吗?了解如何使用这些免费的开源软件来做到这一点。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/vim-email-calendar + +作者:[Kevin Sonney][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/ksonney +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/calendar.jpg?itok=jEKbhvDT (Calendar close up snapshot) +[2]: https://www.vim.org/ +[3]: https://www.gnu.org/software/emacs/ +[4]: https://opensource.com/sites/default/files/uploads/day16-image1.png +[5]: https://github.com/tpope/vim-pathogen +[6]: https://github.com/VundleVim/Vundle.vim +[7]: https://opensource.com/article/20/1/organize-email-notmuch +[8]: https://opensource.com/article/20/1/sync-contacts-locally +[9]: https://opensource.com/sites/default/files/uploads/productivity_16-2.png (Reading Mail in Vim) +[10]: https://opensource.com/sites/default/files/uploads/day16-image3.png +[11]: https://github.com/itchyny/calendar.vim +[12]: mailto:git@github.com +[13]: https://opensource.com/sites/default/files/uploads/day16-image4.png +[14]: https://github.com/itchyny/calendar.vim/issues/156 diff --git a/published/202002/20200126 What-s your favorite Linux distribution.md b/published/202002/20200126 What-s your favorite Linux distribution.md new file mode 100644 index 0000000000..d3d8e99b87 --- /dev/null +++ b/published/202002/20200126 What-s your favorite Linux distribution.md @@ -0,0 +1,56 @@ +[#]: collector: (lujun9972) +[#]: translator: (LazyWolfLin) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11867-1.html) +[#]: subject: (What's your favorite Linux distribution?) +[#]: via: (https://opensource.com/article/20/1/favorite-linux-distribution) +[#]: author: (Opensource.com https://opensource.com/users/admin) + +你最喜欢哪个 Linux 发行版? +====== + +![](https://img.linux.net.cn/data/attachment/album/202002/08/004438ei1y4pp44pw4xy3w.jpg) + +你最喜欢哪个 Linux 发行版?虽然有所变化,但现在仍有数百种 [Linux 发行版][2]保持活跃且运作良好。发行版、包管理器和桌面的组合为 Linux 用户创建了无数客制化系统环境。 + +我们询问了社区的作者们,哪个是他们的最爱以及原因。尽管回答中存在一些共性(由于各种原因,Fedora 和 Ubuntu 是最受欢迎的选择),但我们也听到一些惊奇的回答。以下是他们的一些回答: + +> “我使用 Fedora 发行版!我喜欢这样的社区,成员们共同创建一个令人惊叹的操作系统,展现了开源软件世界最伟大的造物。”——Matthew Miller + +> “我在家中使用 Arch。作为一名游戏玩家,我希望可以轻松使用最新版本的 Wine 和 GFX 驱动,同时最大限度地掌控我的系统。所以我选择一个滚动升级并且每个包都保持领先的发行版。”——Aimi Hobson + +> “NixOS,在业余爱好者市场中没有比这更合适的。”——Alexander Sosedkin + +> “我用过每个 Fedora 版本作为我的工作系统。这意味着我从第一个版本开始使用。从前,我问自己是否会忘记我使用的是哪一个版本。而这一天已经到来了,是从什么时候开始忘记了的呢?”——Hugh Brock + +> “通常,在我的家里和办公室里都有运行 Ubuntu、CentOS 和 Fedora 的机器。我依赖这些发行版来完成各种工作。Fedora 速度很快,而且可以获取最新版本的应用和库。Ubuntu 有大型社区支持,可以轻松使用。CentOS 则当我们需要稳如磐石的服务器平台时。”——Steve Morris + +> “我最喜欢?对于社区以及如何为发行版构建软件包(从源码构建而非二进制文件),我选择 Fedora。对于可用包的范围和包的定义和开发,我选择 Debian。对于文档,我选择 Arch。对于新手的提问,我以前会推荐 Ubuntu,而现在会推荐 Fedora。”——Al Stone + +* * * + +自从 2014 以来,我们一直向社区提出这一问题。除了 2015 年 PCLinuxOS 出乎意料的领先,Ubuntu 往往每年都获得粉丝们的青睐。其他受欢迎的竞争者还包括 Fedora、Debian、Mint 和 Arch。在新的十年里,哪个发行版更吸引你?如果我们的投票列表中没有你最喜欢的选择,请在评论中告诉我们。 + +下面是过去七年来你最喜欢的 Linux 发行版投票的总览。你可以在我们去年的年刊《[Opensource.com 上的十年最佳][3]》中看到它。[点击这里][3]下载完整版电子书! + +![Poll results for favorite Linux distribution through the years][4] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/favorite-linux-distribution + +作者:[Opensource.com][a] +选题:[lujun9972][b] +译者:[LazyWolfLin](https://github.com/LazyWolfLin) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/admin +[b]: https://github.com/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://distrowatch.com/ +[3]: https://opensource.com/downloads/2019-yearbook-special-edition +[4]: https://opensource.com/sites/default/files/pictures/linux-distributions-through-the-years.jpg (favorite Linux distribution through the years) +[5]: https://opensource.com/article/20/1/favorite-linux-distribution diff --git a/published/202002/20200127 Use Vim to manage your task list and access Reddit and Twitter.md b/published/202002/20200127 Use Vim to manage your task list and access Reddit and Twitter.md new file mode 100644 index 0000000000..dcf7ef9dd8 --- /dev/null +++ b/published/202002/20200127 Use Vim to manage your task list and access Reddit and Twitter.md @@ -0,0 +1,106 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11912-1.html) +[#]: subject: (Use Vim to manage your task list and access Reddit and Twitter) +[#]: via: (https://opensource.com/article/20/1/vim-task-list-reddit-twitter) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 Vim 管理任务列表和访问 Reddit 和 Twitter +====== + +> 在 2020 年用开源实现更高生产力的二十种方式的第十七篇文章中,了解在编辑器中处理待办列表以及获取社交信息。 + +![](https://img.linux.net.cn/data/attachment/album/202002/21/112633yf3mx8qlssltugzm.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 用 Vim 做(几乎)所有事情,第 2 部分 + +在[昨天的文章][2]中,你开始用 Vim 检查邮件和日历。今天,你可以做的更多。首先,你会在 Vim 编辑器中跟踪任务,然后获取社交信息。 + +#### 使用 todo.txt-vim 在 Vim 中跟踪待办任务 + +![to-dos and Twitter with Vim][3] + +使用 Vim 编辑一个文本待办事件是一件自然的事,而 [todo.txt-vim][4] 包使其更加简单。首先安装 todo.txt-vim 包: + +``` +git clone https://github.com/freitass/todo.txt-vim ~/.vim/bundle/todo.txt-vim +vim ~/path/to/your/todo.txt +``` + +todo.txt-vim 自动识别以 `todo.txt` 和 `done.txt` 结尾的文件作为 [todo.txt][5] 文件。它添加特定于 todo.txt 格式的键绑定。你可以使用 `\x` 标记“已完成”的内容,使用 `\d` 将其设置为当前日期,然后使用 `\a`、`\b` 和 `\c` 更改优先级。你可以提升(`\k`)或降低(`\j`)优先级,并根据项目(`\s+`)、上下文(`\s@`)或日期(`\sd`)排序(`\s`)。完成后,你可以和平常一样关闭和保存文件。 + +todo.txt-vim 包是我几天前写的 [todo.sh 程序][6]的一个很好的补充,使用 [todo edit][7] 加载项,它可以增强的你待办事项列表跟踪。 + +#### 使用 vim-reddit 读取 Reddit + +![Reddit in Vim][8] + +Vim 还有一个不错的用于 [Reddit][9] 的加载项,叫 [vim-reddit][10]。它不如 [Tuir][11] 好,但是用于快速查看最新的文章,它还是不错的。首先安装捆绑包: + +``` +git clone https://github.com/DougBeney/vim-reddit.git ~/.vim/bundle/vim-reddit +vim +``` + +现在输入 `:Reddit` 将加载 Reddit 首页。你可以使用 `:Reddit name` 加载特定子板。打开文章列表后,使用箭头键导航或使用鼠标滚动。按 `o` 将在 Vim 中打开文章(除非它多媒体文章,它会打开浏览器),然后按 `c` 打开评论。如果要直接转到页面,请按 `O` 而不是 `o`。只需按 `u` 就能返回。当你 Reddit 看完后,输入 `:bd` 就行。vim-reddit 唯一的缺点是无法登录或发布新文章和评论。话又说回来,有时这是一件好事。 + +#### 使用 twitvim 在 Vim 中发推 + +![Twitter in Vim][12] + +最后,我们有 [twitvim][13],这是一个于阅读和发布 Twitter 的 Vim 软件包。它需要更多设置。首先从 GitHub 安装 twitvim: + +``` +git clone https://github.com/twitvim/twitvim.git ~/.vim/bundle/twitvim +``` + +现在你需要编辑 `.vimrc` 文件并设置一些选项。它帮助插件知道使用哪些库与 Twitter 交互。运行 `vim --version` 并查看哪些语言的前面有 `+` 就代表你的 Vim 支持它。 + +![Enabled and Disabled things in vim][14] + +因为我的是 `+perl -python +python3`,所以我知道我可以启用 Perl 和 Python 3 但不是 Python 2 (python)。 + +``` +" TwitVim Settings +let twitvim_enable_perl = 1 +" let twitvim_enable_python = 1 +let twitvim_enable_python3 = 1 +``` + +现在,你可以通过运行 `:SetLoginTwitter` 启动浏览器窗口,它会打开一个浏览器窗口要求你授权 VimTwit 访问你的帐户。在 Vim 中输入提供的 PIN 后就可以了。 + +Twitvim 的命令不像其他包中一样简单。要加载好友和关注者的时间线,请输入 `:FriendsTwitter`。要列出提及你的和回复,请使用 `:MentionsTwitter`。发布新推文是 `:PosttoTwitter `。你可以滚动列表并输入 `\r` 回复特定推文,你可以用 `\d` 直接给某人发消息。 + +就是这些了。你现在可以在 Vim 中做(几乎)所有事了! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/vim-task-list-reddit-twitter + +作者:[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/email_chat_communication_message.png?itok=LKjiLnQu (Chat via email) +[2]: https://linux.cn/article-11908-1.html +[3]: https://opensource.com/sites/default/files/uploads/productivity_17-1.png (to-dos and Twitter with Vim) +[4]: https://github.com/freitass/todo.txt-vim +[5]: http://todotxt.org +[6]: https://opensource.com/article/20/1/open-source-to-do-list +[7]: https://github.com/todotxt/todo.txt-cli/wiki/Todo.sh-Add-on-Directory#edit-open-in-text-editor +[8]: https://opensource.com/sites/default/files/uploads/productivity_17-2.png (Reddit in Vim) +[9]: https://reddit.com +[10]: https://github.com/DougBeney/vim-reddit +[11]: https://opensource.com/article/20/1/open-source-reddit-client +[12]: https://opensource.com/sites/default/files/uploads/productivity_17-3.png (Twitter in Vim) +[13]: https://github.com/twitvim/twitvim +[14]: https://opensource.com/sites/default/files/uploads/productivity_17-4.png (Enabled and Disabled things in vim) diff --git a/published/202002/20200128 Send email and check your calendar with Emacs.md b/published/202002/20200128 Send email and check your calendar with Emacs.md new file mode 100644 index 0000000000..2ffdbd22d7 --- /dev/null +++ b/published/202002/20200128 Send email and check your calendar with Emacs.md @@ -0,0 +1,146 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11932-1.html) +[#]: subject: (Send email and check your calendar with Emacs) +[#]: via: (https://opensource.com/article/20/1/emacs-mail-calendar) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 Emacs 发送电子邮件和检查日历 +====== + +> 在 2020 年用开源实现更高生产力的二十种方式的第十八篇文章中,使用 Emacs 文本编辑器管理电子邮件和查看日程安排。 + +![](https://img.linux.net.cn/data/attachment/album/202002/26/103647mnee75vxhcc00z06.jpg) + +去年,我给你们带来了 2019 年的 19 天新生产力工具系列。今年,我将采取一种不同的方式:建立一个新的环境,让你使用已用或未用的工具来在新的一年里变得更有效率。 + +### 使用 Emacs 做(几乎)所有的事情,第 1 部分 + +两天前,我曾经说过我经常使用 [Vim][2] 和 [Emacs][3],在本系列的 [16][4] 和 [17][5] 天,我讲解了如何在 Vim 中做几乎所有的事情。现在,Emacs 的时间到了! + +![Emacs 中的邮件和日历][6] + +在深入之前,我需要说明两件事。首先,我这里使用默认的 Emacs 配置,而不是我之前[写过][8]的 [Spacemacs][7]。为什么呢?因为这样一来我使用的就是默认快捷键,从而使你可以参考文档,而不必将“原生的 Emacs” 转换为 Spacemacs。第二,在本系列文章中我没有对 Org 模式进行任何设置。Org 模式本身几乎可以自成一个完整的系列,它非常强大,但是设置可能非常复杂。 + +#### 配置 Emacs + +配置 Emacs 比配置 Vim 稍微复杂一些,但以我之见,从长远来看,这样做是值得的。首先我们创建一个配置文件,并在 Emacs 中打开它: + +``` +mkdir ~/.emacs.d +emacs ~/.emacs.d/init.el +``` + +接下来,向内置的包管理器添加一些额外的包源。在 `init.el` 中添加以下内容: + +``` +(package-initialize) +(add-to-list 'package-archives '("melpa" . "")) +(add-to-list 'package-archives '("org" . "") t) +(add-to-list 'package-archives '("gnu" . "")) +(package-refresh-contents) +``` + +使用 `Ctrl+x Ctrl+s` 保存文件,然后按下 `Ctrl+x Ctrl+c` 退出,再重启 Emacs。Emacs 会在启动时下载所有的插件包列表,之后你就可以使用内置的包管理器安装插件了。输入 `Meta+x` 会弹出命令提示符(大多数键盘上 `Meta` 键就是的 `Alt` 键,而在 MacOS 上则是 `Option`)。在命令提示符下输入 `package-list-packages` 就会显示可以安装的包列表。遍历该列表并使用 `i` 键选择以下包: + +``` +bbdb +bbdb-vcard +calfw +calfw-ical +notmuch +``` + +选好软件包后按 `x` 安装它们。根据你的网络连接情况,这可能需要一段时间。你也许会看到一些编译错误,但是可以忽略它们。安装完成后,使用组合键 `Ctrl+x Ctrl+f` 打开 `~/.emacs.d/init.el`,并在 `(package-refresh-packages)` 之后、 `(custom-set-variables` 之前添加以下行到文件中。 +`(custom-set-variables` 行由 Emacs 内部维护,你永远不应该修改它之后的任何内容。以 `;;` 开头的行则是注释。 + +``` +;; Set up bbdb +(require 'bbdb) +(bbdb-initialize 'message) +(bbdb-insinuate-message) +(add-hook 'message-setup-hook 'bbdb-insinuate-mail) +;; set up calendar +(require 'calfw) +(require 'calfw-ical) +;; Set this to the URL of your calendar. Google users will use +;; the Secret Address in iCalendar Format from the calendar settings +(cfw:open-ical-calendar "") +;; Set up notmuch +(require 'notmuch) +;; set up mail sending using sendmail +(setq send-mail-function (quote sendmail-send-it)) +(setq user-mail-address "[myemail@mydomain.com][9]" +      user-full-name "My Name") +``` + +现在,你已经准备好使用自己的配置启动 Emacs 了!保存 `init.el` 文件(`Ctrl+x Ctrl+s`),退出 Emacs(`Ctrl+x Ctrl+c`),然后重启之。这次重启要多花些时间。 + +#### 使用 Notmuch 在 Emacs 中读写电子邮件 + +一旦你看到了 Emacs 启动屏幕,你就可以使用 [Notmuch][10] 来阅读电子邮件了。键入 `Meta+x notmuch`,你将看到 notmuch 的 Emacs 界面。 + +![使用 notmuch 阅读邮件][11] + +所有加粗的项目都是指向电子邮件视图的链接。你可以通过点击鼠标或者使用 `tab` 键在它们之间跳转并按回车来访问它们。你可以使用搜索栏来搜索 Notmuch 的数据库,语法与 Notmuch 命令行上的[语法][12] 相同。如果你愿意,还可以使用 `[save]` 按钮保存搜索以便未来使用,这些搜索会被添加到屏幕顶部的列表中。如果你进入一个链接就会看到一个相关电子邮件的列表。你可以使用箭头键在列表中导航,并在要读取的消息上按回车。按 `r` 可以回复一条消息,`f` 转发该消息,`q` 退出当前屏幕。 + +你可以通过键入 `Meta+x compose-mail` 来编写新消息。撰写、回复和转发都将打开编写邮件的界面。写完邮件后,按 `Ctrl+c Ctrl+c` 发送。如果你决定不发送它,按 `Ctrl+c Ctrl+k` 关闭消息撰写缓冲区(窗口)。 + +#### 使用 BBDB 在 Emacs 中自动补完电子邮件地址 + +![在消息中使用 BBDB 地址][13] + +那么通讯录怎么办?这就是 [BBDB][14] 发挥作用的地方。但首先我们需要从 [abook][15] 导入所有地址,方法是打开命令行并运行以下导出命令: + +``` +abook --convert --outformat vcard --outfile ~/all-my-addresses.vcf --infile ~/.abook/addresses +``` + +Emacs 启动后,运行 `Meta+x bbdb-vcard-import-file`。它将提示你输入要导入的文件名,即 `~/all-my-address.vcf`。导入完成后,在编写消息时,可以开始输入名称并使用 `Tab` 搜索和自动完成 “to” 字段的内容。BBDB 还会打开一个联系人缓冲区,以便你确保它是正确的。 + +既然在 [vdirsyncer][16] 中已经为每个地址都生成了对应的 .vcf 文件了,为什么我们还要这样做呢?如果你像我一样,有许多地址,一次处理一个地址是很麻烦的。这样做,你就可以把所有的东西都放在 abook 里,做成一个大文件。 + +#### 使用 calfw 在 Emacs 中浏览日历 + +![calfw 日历 ][17] + +最后,你可以使用 Emacs 查看日历。在上面的配置中,你安装了 [calfw][18] 包,并添加了一些行来告诉它在哪里可以找到要加载的日历。Calfw 是 “Emacs 日历框架Calendar Framework for Emacs”的简称,它支持多种日历格式。我使用的是谷歌日历,这也是我放在配置中的链接。日历将在启动时自动加载,你可以通过 `Ctrl+x+b` 命令切换到 cfw-calendar 缓冲区来查看日历。 + +Calfw 提供日、周、双周和月视图。你可以在日历顶部选择视图,并使用箭头键导航日历。不幸的是,calfw 只能查看日历,所以你仍然需要使用 [khal][19] 之类的工具或通过 web 界面来添加、删除和修改事件。 + +这就是 Emacs 中的邮件、日历和邮件地址。明天我会展示更多。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/emacs-mail-calendar + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[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/email_paper_envelope_document.png?itok=uPj_kouJ (Document sending) +[2]: https://www.vim.org/ +[3]: https://www.gnu.org/software/emacs/ +[4]: https://linux.cn/article-11908-1.html +[5]: https://linux.cn/article-11912-1.html +[6]: https://opensource.com/sites/default/files/uploads/productivity_18-1.png (Mail and calendar in Emacs) +[7]: https://www.spacemacs.org/ +[8]: https://opensource.com/article/19/12/spacemacs +[9]: mailto:myemail@mydomain.com +[10]: https://notmuchmail.org/ +[11]: https://opensource.com/sites/default/files/uploads/productivity_18-2.png (Reading mail with Notmuch) +[12]: https://linux.cn/article-11807-1.html +[13]: https://opensource.com/sites/default/files/uploads/productivity_18-3.png (Composing a message with BBDB addressing) +[14]: https://www.jwz.org/bbdb/ +[15]: https://linux.cn/article-11834-1.html +[16]: https://linux.cn/article-11812-1.html +[17]: https://opensource.com/sites/default/files/uploads/productivity_18-4.png (calfw calendar) +[18]: https://github.com/kiwanami/emacs-calfw +[19]: https://khal.readthedocs.io/en/v0.9.2/index.html diff --git a/published/202002/20200129 4 cool new projects to try in COPR for January 2020.md b/published/202002/20200129 4 cool new projects to try in COPR for January 2020.md new file mode 100644 index 0000000000..d6c46e11ea --- /dev/null +++ b/published/202002/20200129 4 cool new projects to try in COPR for January 2020.md @@ -0,0 +1,101 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11863-1.html) +[#]: subject: (4 cool new projects to try in COPR for January 2020) +[#]: via: (https://fedoramagazine.org/4-cool-new-projects-to-try-in-copr-for-january-2020/) +[#]: author: (Dominik Turecek https://fedoramagazine.org/author/dturecek/) + +COPR 仓库中 4 个很酷的新项目(2020.01) +====== + +![][1] + +COPR 是个人软件仓库[集合][2],它不在 Fedora 中。这是因为某些软件不符合轻松打包的标准;或者它可能不符合其他 Fedora 标准,尽管它是自由而开源的。COPR 可以在 Fedora 套件之外提供这些项目。COPR 中的软件不受 Fedora 基础设施的支持,或者是由项目自己背书的。但是,这是一种尝试新的或实验性的软件的一种巧妙的方式。 + +本文介绍了 COPR 中一些有趣的新项目。如果你第一次使用 COPR,请参阅 [COPR 用户文档][3]。 + +### Contrast + +[Contrast][4] 是一款小应用,用于检查两种颜色之间的对比度并确定其是否满足 [WCAG][5] 中指定的要求。可以使用十六进制 RGB 代码或使用颜色选择器选择颜色。除了显示对比度之外,Contrast 还以选定的颜色为背景上显示短文本来显示比较。 + +![][6] + +#### 安装说明 + +[仓库][7]当前为 Fedora 31 和 Rawhide 提供了 Contrast。要安装 Contrast,请使用以下命令: + +``` +sudo dnf copr enable atim/contrast +sudo dnf install contrast +``` + +### Pamixer + +[Pamixer][8] 是一个使用 PulseAudio 调整和监控声音设备音量的命令行工具。你可以显示设备的当前音量并直接增加/减小它,或静音/取消静音。Pamixer 可以列出所有源和接收器。 + +#### 安装说明 + +[仓库][7]当前为 Fedora 31 和 Rawhide 提供了 Pamixer。要安装 Pamixer,请使用以下命令: + +``` +sudo dnf copr enable opuk/pamixer +sudo dnf install pamixer +``` + +### PhotoFlare + +[PhotoFlare][10] 是一款图像编辑器。它有简单且布局合理的用户界面,其中的大多数功能都可在工具栏中使用。尽管它不支持使用图层,但 PhotoFlare 提供了诸如各种颜色调整、图像变换、滤镜、画笔和自动裁剪等功能。此外,PhotoFlare 可以批量编辑图片,来对所有图片应用相同的滤镜和转换,并将结果保存在指定目录中。 + +![][11] + +#### 安装说明 + +[仓库][7]当前为 Fedora 31 提供了 PhotoFlare。要安装 PhotoFlare,请使用以下命令: + +``` +sudo dnf copr enable adriend/photoflare +sudo dnf install photoflare +``` + +### Tdiff + +[Tdiff][13] 是用于比较两个文件树的命令行工具。除了显示某些文件或目录仅存在于一棵树中之外,tdiff 还显示文件大小、类型和内容,所有者用户和组 ID、权限、修改时间等方面的差异。 + +#### 安装说明 + +[仓库][7]当前为 Fedora 29-31、Rawhide、EPEL 6-8 和其他发行版提供了 tdiff。要安装 tdiff,请使用以下命令: + +``` +sudo dnf copr enable fif/tdiff +sudo dnf install tdiff +``` + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/4-cool-new-projects-to-try-in-copr-for-january-2020/ + +作者:[Dominik Turecek][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/dturecek/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2017/08/4-copr-945x400.jpg +[2]: https://copr.fedorainfracloud.org/ +[3]: https://docs.pagure.org/copr.copr/user_documentation.html# +[4]: https://gitlab.gnome.org/World/design/contrast +[5]: https://www.w3.org/WAI/standards-guidelines/wcag/ +[6]: https://fedoramagazine.org/wp-content/uploads/2020/01/contrast-screenshot.png +[7]: https://copr.fedorainfracloud.org/coprs/atim/contrast/ +[8]: https://github.com/cdemoulins/pamixer +[9]: https://copr.fedorainfracloud.org/coprs/opuk/pamixer/ +[10]: https://photoflare.io/ +[11]: https://fedoramagazine.org/wp-content/uploads/2020/01/photoflare-screenshot.png +[12]: https://copr.fedorainfracloud.org/coprs/adriend/photoflare/ +[13]: https://github.com/F-i-f/tdiff +[14]: https://copr.fedorainfracloud.org/coprs/fif/tdiff/ diff --git a/published/202002/20200129 Joplin- The True Open Source Evernote Alternative.md b/published/202002/20200129 Joplin- The True Open Source Evernote Alternative.md new file mode 100644 index 0000000000..106d670f11 --- /dev/null +++ b/published/202002/20200129 Joplin- The True Open Source Evernote Alternative.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11896-1.html) +[#]: subject: (Joplin: The True Open Source Evernote Alternative) +[#]: via: (https://itsfoss.com/joplin/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Joplin:真正的 Evernote 开源替代品 +====== + +> Joplin 是一个开源笔记记录和待办应用。你可以将笔记组织到笔记本中并标记它们。Joplin 还提供网络剪贴板来保存来自互联网的文章。 + +### Joplin:开源笔记管理器 + +![][4] + +如果你喜欢 [Evernote][2],那么你不会不太适应这个开源软件 [Joplin][3]。 + +Joplin 是一个优秀的开源笔记应用,拥有丰富的功能。你可以记笔记、记录待办事项并且通过和 Dropbox 和 NextCloud 等云服务链接来跨设备同步笔记。同步过程通过端到端加密保护。 + +Joplin 还有一个 Web 剪贴板,能让你将网页另存为笔记。这个网络剪贴板可用于 Firefox 和 Chrome/Chromium 浏览器。 + +Joplin 可以导入 enex 格式的 Evernote 文件,这让从 Evernote 切换变得容易。 + +因为数据自行保存,所以你可以用 Joplin 格式或者原始格式导出所有文件。 + +### Joplin 的功能 + +![][1] + +以下是 Joplin 的所有功能列表: + +* 将笔记保存到笔记本和子笔记本中,以便更好地组织 +* 创建待办事项清单 +* 可以标记和搜索笔记 +* 离线优先,因此即使没有互联网连接,所有数据始终在设备上可用 +* Markdown 笔记支持图片、数学符号和复选框 +* 支持附件 +* 可在桌面、移动设备和终端(CLI)使用 +* 可在 Firefox 和 Chrome 使用[网页剪切板][5] +* 端到端加密 +* 保留笔记历史 +* 根据名称、时间等对笔记进行排序 +* 可与 [Nextcloud][7]、Dropbox、WebDAV 和 OneDrive 等各种[云服务][6]同步 +* 从 Evernote 导入文件 +* 导出 JEX 文件(Joplin 导出格式)和原始文件 +* 支持笔记、待办事项、标签和笔记本 +* 任意跳转功能 +* 支持移动设备和桌面应用通知 +* 地理位置支持 +* 支持多种语言 +* 外部编辑器支持:在 Joplin 中一键用你最喜欢的编辑器打开笔记 + +### 在 Linux 和其它平台上安装 Joplin + +![][10] + +[Joplin][11] 是一个跨平台应用,可用于 Linux、macOS 和 Windows。在移动设备上,你可以[获取 APK 文件][12]将其安装在 Android 和基于 Android 的 ROM 上。你也可以[从谷歌 Play 商店下载][13]。 + +在 Linux 中,你可以获取 Joplin 的 [AppImage][14] 文件,并作为可执行文件运行。你需要为下载的文件授予执行权限。 + +- [下载 Joplin][15] + +### 体验 Joplin + +Joplin 中的笔记使用 Markdown,但你不需要了解它。编辑器的顶部面板能让你以图形方式选择项目符号、标题、图像、链接等。 + +虽然 Joplin 提供了许多有趣的功能,但你需要自己去尝试。例如,默认情况下未启用 Web 剪切板,我需要发现如何打开它。 + +你需要从桌面应用启用剪切板。在顶部菜单中,进入 “Tools->Options”。你可以在此处找到 Web 剪切板选项: + +![Enable Web Clipper from the desktop application first][16] + +它的 Web 剪切板不如 Evernote 的 Web 剪切板聪明,后者可以以图形方式剪辑网页文章的一部分。但是,也足够了。 + +这是一个在活跃开发中的开源软件,我希望它随着时间的推移得到更多的改进。 + +### 总结 + +如果你正在寻找一个不错的拥有 Web 剪切板的笔记应用,你可以试试 Joplin。如果你喜欢它,并将继续使用,尝试通过捐赠或改进代码和文档来帮助 Joplin 开发。我以 FOSS 的名义[捐赠][17]了 25 欧。 + +如果你曾经使用过 Joplin,或者仍在使用它,你对此的体验如何?如果你用的是其他笔记应用,你会切换到 Joplin 么?欢迎分享你的观点。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/joplin/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/joplin_logo.png?ssl=1 +[2]: https://evernote.com/ +[3]: https://joplinapp.org/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/01/joplin_featured.jpg?ssl=1 +[5]: https://joplinapp.org/clipper/ +[6]: https://itsfoss.com/cloud-services-linux/ +[7]: https://nextcloud.com/ +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/joplin_ubuntu.jpg?ssl=1 +[11]: https://github.com/laurent22/joplin +[12]: https://itsfoss.com/download-apk-ubuntu/ +[13]: https://play.google.com/store/apps/details?id=net.cozic.joplin&hl=en_US +[14]: https://itsfoss.com/use-appimage-linux/ +[15]: https://github.com/laurent22/joplin/releases +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/01/joplin_web_clipper.jpg?ssl=1 +[17]: https://itsfoss.com/donations-foss/ diff --git a/published/202002/20200129 Showing memory usage in Linux by process and user.md b/published/202002/20200129 Showing memory usage in Linux by process and user.md new file mode 100644 index 0000000000..e1cd22286b --- /dev/null +++ b/published/202002/20200129 Showing memory usage in Linux by process and user.md @@ -0,0 +1,189 @@ +[#]: collector: (lujun9972) +[#]: translator: (mengxinayan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11849-1.html) +[#]: subject: (Showing memory usage in Linux by process and user) +[#]: via: (https://www.networkworld.com/article/3516319/showing-memory-usage-in-linux-by-process-and-user.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +查看 Linux 系统中进程和用户的内存使用情况 +====== + +> 有一些命令可以用来检查 Linux 系统中的内存使用情况,下面是一些更好的命令。 + +![Fancycrave][1] + +有许多工具可以查看 Linux 系统中的内存使用情况。一些命令被广泛使用,比如 `free`、`ps`。而另一些命令允许通过多种方式展示系统的性能统计信息,比如 `top`。在这篇文章中,我们将介绍一些命令以帮助你确定当前占用着最多内存资源的用户或者进程。 + +下面是一些按照进程查看内存使用情况的命令: + +### 按照进程查看内存使用情况 + +#### 使用 top + +`top` 是最好的查看内存使用情况的命令之一。为了查看哪个进程使用着最多的内存,一个简单的办法就是启动 `top`,然后按下 `shift+m`,这样便可以查看按照内存占用百分比从高到底排列的进程。当你按下了 `shift+m` ,你的 `top` 应该会得到类似于下面这样的输出结果: + +``` +$top +top - 09:39:34 up 5 days, 3 min, 3 users, load average: 4.77, 4.43, 3.72 +Tasks: 251 total, 3 running, 247 sleeping, 1 stopped, 0 zombie +%Cpu(s): 50.6 us, 35.9 sy, 0.0 ni, 13.4 id, 0.2 wa, 0.0 hi, 0.0 si, 0.0 st +MiB Mem : 5944.4 total, 128.9 free, 2509.3 used, 3306.2 buff/cache +MiB Swap: 2048.0 total, 2045.7 free, 2.2 used. 3053.5 avail Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 400 nemo 20 0 3309580 550188 168372 S 0.3 9.0 1:33.27 Web Content +32469 nemo 20 0 3492840 447372 163296 S 7.3 7.3 3:55.60 firefox +32542 nemo 20 0 2845732 433388 140984 S 6.0 7.1 4:11.16 Web Content + 342 nemo 20 0 2848520 352288 118972 S 10.3 5.8 4:04.89 Web Content + 2389 nemo 20 0 1774412 236700 90044 S 39.7 3.9 9:32.64 vlc +29527 nemo 20 0 2735792 225980 84744 S 9.6 3.7 3:02.35 gnome-shell +30497 nemo 30 10 1088476 159636 88884 S 0.0 2.6 0:11.99 update-manager +30058 nemo 20 0 1089464 140952 33128 S 0.0 2.3 0:04.58 gnome-software +32533 nemo 20 0 2389088 104712 79544 S 0.0 1.7 0:01.43 WebExtensions + 2256 nemo 20 0 1217884 103424 31304 T 0.0 1.7 0:00.28 vlc + 1713 nemo 20 0 2374396 79588 61452 S 0.0 1.3 0:00.49 Web Content +29306 nemo 20 0 389668 74376 54340 S 2.3 1.2 0:57.25 Xorg +32739 nemo 20 0 289528 58900 34480 S 1.0 1.0 1:04.08 RDD Process +29732 nemo 20 0 789196 57724 42428 S 0.0 0.9 0:00.38 evolution-alarm + 2373 root 20 0 150408 57000 9924 S 0.3 0.9 10:15.35 nessusd +``` + +注意 `%MEM` 排序。列表的大小取决于你的窗口大小,但是占据着最多的内存的进程将会显示在列表的顶端。 + +#### 使用 ps + +`ps` 命令中的一列用来展示每个进程的内存使用情况。为了展示和查看哪个进程使用着最多的内存,你可以将 `ps` 命令的结果传递给 `sort` 命令。下面是一个有用的示例: + +``` +$ ps aux | sort -rnk 4 | head -5 +nemo 400 3.4 9.2 3309580 563336 ? Sl 08:59 1:36 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -prefsLen 9086 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 32469 8.2 7.7 3492840 469516 ? Sl 08:54 4:15 /usr/lib/firefox/firefox -new-window +nemo 32542 8.9 7.6 2875428 462720 ? Sl 08:55 4:36 /usr/lib/firefox/firefox -contentproc -childID 2 -isForBrowser -prefsLen 1 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 342 9.9 5.9 2854664 363528 ? Sl 08:59 4:44 /usr/lib/firefox/firefox -contentproc -childID 5 -isForBrowser -prefsLen 8763 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 2389 39.5 3.8 1774412 236116 pts/1 Sl+ 09:15 12:21 vlc videos/edge_computing.mp4 +``` + +在上面的例子中(文中已截断),`sort` 命令使用了 `-r` 选项(反转)、`-n` 选项(数字值)、`-k` 选项(关键字),使 `sort` 命令对 `ps` 命令的结果按照第四列(内存使用情况)中的数字逆序进行排列并输出。如果我们首先显示 `ps` 命令的标题,那么将会便于查看。 + +``` +$ ps aux | head -1; ps aux | sort -rnk 4 | head -5 +USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND +nemo 400 3.4 9.2 3309580 563336 ? Sl 08:59 1:36 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -prefsLen 9086 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 32469 8.2 7.7 3492840 469516 ? Sl 08:54 4:15 /usr/lib/firefox/firefox -new-window +nemo 32542 8.9 7.6 2875428 462720 ? Sl 08:55 4:36 /usr/lib/firefox/firefox -contentproc -childID 2 -isForBrowser -prefsLen 1 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 342 9.9 5.9 2854664 363528 ? Sl 08:59 4:44 /usr/lib/firefox/firefox -contentproc -childID 5 -isForBrowser -prefsLen 8763 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 2389 39.5 3.8 1774412 236116 pts/1 Sl+ 09:15 12:21 vlc videos/edge_computing.mp4 +``` + +如果你喜欢这个命令,你可以用下面的命令为他指定一个别名,如果你想一直使用它,不要忘记把该命令添加到你的 `~/.bashrc` 文件中。 + +``` +$ alias mem-by-proc="ps aux | head -1; ps aux | sort -rnk 4" +``` + +下面是一些根据用户查看内存使用情况的命令: + +### 按用户查看内存使用情况 + +#### 使用 top + +按照用户检查内存使用情况会更复杂一些,因为你需要找到一种方法把用户所拥有的所有进程统计为单一的内存使用量。 + +如果你只想查看单个用户进程使用情况,`top` 命令可以采用与上文中同样的方法进行使用。只需要添加 `-U` 选项并在其后面指定你要查看的用户名,然后按下 `shift+m` 便可以按照内存使用有多到少进行查看。 + +``` +$ top -U nemo +top - 10:16:33 up 5 days, 40 min, 3 users, load average: 1.91, 1.82, 2.15 +Tasks: 253 total, 2 running, 250 sleeping, 1 stopped, 0 zombie +%Cpu(s): 28.5 us, 36.8 sy, 0.0 ni, 34.4 id, 0.3 wa, 0.0 hi, 0.0 si, 0.0 st +MiB Mem : 5944.4 total, 224.1 free, 2752.9 used, 2967.4 buff/cache +MiB Swap: 2048.0 total, 2042.7 free, 5.2 used. 2812.0 avail Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 400 nemo 20 0 3315724 623748 165440 S 1.0 10.2 1:48.78 Web Content +32469 nemo 20 0 3629380 607492 161688 S 2.3 10.0 6:06.89 firefox +32542 nemo 20 0 2886700 404980 136648 S 5.6 6.7 6:50.01 Web Content + 342 nemo 20 0 2922248 375784 116096 S 19.5 6.2 8:16.07 Web Content + 2389 nemo 20 0 1762960 234644 87452 S 0.0 3.9 13:57.53 vlc +29527 nemo 20 0 2736924 227260 86092 S 0.0 3.7 4:09.11 gnome-shell +30497 nemo 30 10 1088476 156372 85620 S 0.0 2.6 0:11.99 update-manager +30058 nemo 20 0 1089464 138160 30336 S 0.0 2.3 0:04.62 gnome-software +32533 nemo 20 0 2389088 102532 76808 S 0.0 1.7 0:01.79 WebExtensions +``` + +#### 使用 ps + +你依旧可以使用 `ps` 命令通过内存使用情况来排列某个用户的进程。在这个例子中,我们将使用 `grep` 命令来筛选得到某个用户的所有进程。 + +``` +$ ps aux | head -1; ps aux | grep ^nemo| sort -rnk 4 | more +USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND +nemo 32469 7.1 11.5 3724364 701388 ? Sl 08:54 7:21 /usr/lib/firefox/firefox -new-window +nemo 400 2.0 8.9 3308556 543232 ? Sl 08:59 2:01 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -prefsLen 9086 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni/usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 32542 7.9 7.1 2903084 436196 ? Sl 08:55 8:07 /usr/lib/firefox/firefox -contentproc -childID 2 -isForBrowser -prefsLen 1 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 342 10.8 7.0 2941056 426484 ? Rl 08:59 10:45 /usr/lib/firefox/firefox -contentproc -childID 5 -isForBrowser -prefsLen 8763 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 2389 16.9 3.8 1762960 234644 pts/1 Sl+ 09:15 13:57 vlc videos/edge_computing.mp4 +nemo 29527 3.9 3.7 2736924 227448 ? Ssl 08:50 4:11 /usr/bin/gnome-shell +``` +### 使用 ps 和其他命令的搭配 + +如果你想比较某个用户与其他用户内存使用情况将会比较复杂。在这种情况中,创建并排序一个按照用户总的内存使用量是一个不错的方法,但是它需要做一些更多的工作,并涉及到许多命令。在下面的脚本中,我们使用 `ps aux | grep -v COMMAND | awk '{print $1}' | sort -u` 命令得到了用户列表。其中包含了系统用户比如 `syslog`。我们对每个任务使用 `awk` 命令以收集每个用户总的内存使用情况。在最后一步中,我们展示每个用户总的内存使用量(按照从大到小的顺序)。 + +``` +#!/bin/bash + +stats=”” +echo "% user" +echo "============" + +# collect the data +for user in `ps aux | grep -v COMMAND | awk '{print $1}' | sort -u` +do + stats="$stats\n`ps aux | egrep ^$user | awk 'BEGIN{total=0}; \ + {total += $4};END{print total,$1}'`" +done + +# sort data numerically (largest first) +echo -e $stats | grep -v ^$ | sort -rn | head +``` + +这个脚本的输出可能如下: + +``` +$ ./show_user_mem_usage +% user +============ +69.6 nemo +5.8 root +0.5 www-data +0.3 shs +0.2 whoopsie +0.2 systemd+ +0.2 colord +0.2 clamav +0 syslog +0 rtkit +``` + +在 Linux 有许多方法可以报告内存使用情况。可以通过一些用心设计的工具和命令,来查看并获得某个进程或者用户占用着最多的内存。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3516319/showing-memory-usage-in-linux-by-process-and-user.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[萌新阿岩](https://github.com/mengxinayan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/06/chips_processors_memory_cards_by_fancycrave_cc0_via_unsplash_1200x800-100760955-large.jpg +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/202002/20200130 Meet FuryBSD- A New Desktop BSD Distribution.md b/published/202002/20200130 Meet FuryBSD- A New Desktop BSD Distribution.md new file mode 100644 index 0000000000..611ed7c315 --- /dev/null +++ b/published/202002/20200130 Meet FuryBSD- A New Desktop BSD Distribution.md @@ -0,0 +1,92 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11915-1.html) +[#]: subject: (Meet FuryBSD: A New Desktop BSD Distribution) +[#]: via: (https://itsfoss.com/furybsd/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +认识 FuryBSD:一个新的桌面 BSD 发行版 +====== + +在过去的几个月中,出现了一些新的桌面 BSD。之前有 [HyperbolaBSD,它之前是 Hyperbola GNU/Linux][1]。[BSD][2] 世界中的另一个新入者是 [FuryBSD][3]。 + +### FuryBSD:一个新的 BSD 发行版 + +![][4] + +从本质上讲,FuryBSD 是一个非常简单的小东西。根据[它的网站][5]:“FuryBSD 一个是基于 FreeBSD 的轻量级桌面发行版。” 它基本上是预配置了桌面环境,并预安装了多个应用的 FreeBSD。目地是快速地在你的计算机上运行基于 FreeBSD 的系统。 + +你可能会认为这听起来很像其他几个已有的 BSD,例如 [NomadBSD][6] 和 [GhostBSD][7]。这些 BSD 与 FuryBSD 之间的主要区别在于 FuryBSD 与现有的 FreeBSD 更加接近。例如,FuryBSD 使用 FreeBSD 安装程序,而其他发行版则用了自己的安装程序和工具。 + +正如[它的网站][8]所说:“尽管 FuryBSD 可能类似于 PC-BSD 和 TrueOS 等图形化 BSD 项目,但 FuryBSD 是由不同的团队创建的,并且采用了不同与 FreeBSD 着重于紧密集成的方法。这样可以降低开销,并保持与上游的兼容性。”开发负责人还告诉我:“FuryBSD 的一个主要重点是使其成为一种小型现场版介质,并带有一些测试硬件驱动程序的辅助工具。” + +当前,你可以进入 [FuryBSD 主页][3]并下载 XFCE 或 KDE 的 LiveCD。GNOME 版本正在开发中。 + +### FuryBSD 的背后是谁 + +FuryBSD 的主要开发者是 [Joe Maloney][9]。Joe 多年来一直是 FreeBSD 的用户。他为 PC-BSD 等其他 BSD 项目做过贡献。他还与 GhostBSD 的创建者 Eric Turgeon 一起重写了 GhostBSD LiveCD。在此过程中,他对 BSD 有了更好的了解,并开始形成自己如何做一个发行版的想法。 + +Joe 与其他参与 BSD 世界多年的开发者一起加入了开发,例如 Jaron Parsons、Josh Smith 和 Damian Szidiropulosz。 + +### FuryBSD 的未来 + +目前,FuryBSD 仅仅是预配置的 FreeBSD。但是,开发者有一份[要改进的清单][5]。包括: + +* 可靠的加载框架、第三方专有图形驱动、无线网络 +* 进一步整理 LiveCD 体验,以使其更加友好 +* 开箱即用的打印支持 +* 包含更多默认应用,以提供完整的桌面体验 +* 集成的 [ZFS][10] 复制工具,用于备份和还原 +* Live 镜像持久化选项 +* 默认自定义 pkg 仓库 +* 用于应用更新的持续集成 +* 桌面 FreeBSD 的质量保证 +* 自定义、色彩方案和主题 +* 目录服务集成 +* 安全加固 + +开发者非常清楚地表明,他们所做的任何更改都需要大量的思考和研究。他们不会改进某个功能,只会在它破坏一些东西时删除或者修改它。 + +![FuryBSD desktop][11] + +### 你可以如何帮助 FuryBSD? + +目前,该项目还很年轻。由于所有项目都需要帮助才能生存,所以我问 Joe 他们正在寻求什么样的帮助。他说:“我们可以帮助[在论坛上回答问题][12]、回答 [GitHub][13] 上的问题,完善文档。”他还说如果人们想增加对其他桌面环境的支持,欢迎发起拉取请求。 + +### 最后的想法 + +尽管我还没有尝试过,但是我对 FuryBSD 感觉不错。听起来项目在掌握中。十多年来,Joe Maloney 一直在思考如何达到最佳的 BSD 桌面体验。与大多数 Linux 发行版基本上都是经过重新设计的 Ubuntu 不同,FuryBSD 背后的开发者知道他们在做什么,并且他们在更看重质量而不是花哨的功能。 + +你对这个在不断增长的桌面 BSD 市场的新入者怎么看?你尝试过 FuryBSD 或者会尝试一下吗?请在下面的评论中告诉我们。 + +如果你觉得这篇文章有趣,请在 Hacker News 或 [Reddit][14] 等社交媒体上分享它。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/furybsd/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/hyperbola-linux-bsd/ +[2]: https://itsfoss.com/bsd/ +[3]: https://www.furybsd.org/ +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/fury-bsd.jpg?ssl=1 +[5]: https://www.furybsd.org/manifesto/ +[6]: https://itsfoss.com/nomadbsd/ +[7]: https://ghostbsd.org/ +[8]: https://www.furybsd.org/furybsd-video-overview-at-knoxbug/ +[9]: https://github.com/pkgdemon +[10]: https://itsfoss.com/what-is-zfs/ +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/FuryBSDS-desktop.jpg?resize=800%2C450&ssl=1 +[12]: https://forums.furybsd.org/ +[13]: https://github.com/furybsd +[14]: https://reddit.com/r/linuxusersgroup diff --git a/published/202002/20200131 Intro to the Linux command line.md b/published/202002/20200131 Intro to the Linux command line.md new file mode 100644 index 0000000000..49550210fe --- /dev/null +++ b/published/202002/20200131 Intro to the Linux command line.md @@ -0,0 +1,87 @@ +[#]: collector: (lujun9972) +[#]: translator: (qianmingtian) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11864-1.html) +[#]: subject: (Intro to the Linux command line) +[#]: via: (https://www.networkworld.com/article/3518440/intro-to-the-linux-command-line.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +Linux 命令行简介 +====== + +> 下面是一些针对刚开始使用 Linux 命令行的人的热身练习。警告:它可能会上瘾。 + +![](https://images.idgesg.net/images/article/2020/01/cmd_linux-control_linux-logo_-100828420-large.jpg) + +如果你是 Linux 新手,或者从来没有花时间研究过命令行,你可能不会理解为什么这么多 Linux 爱好者坐在舒适的桌面前兴奋地输入命令来使用大量工具和应用。在这篇文章中,我们将快速浏览一下命令行的奇妙之处,看看能否让你着迷。 + +首先,要使用命令行,你必须打开一个命令工具(也称为“命令提示符”)。如何做到这一点将取决于你运行的 Linux 版本。例如,在 RedHat 上,你可能会在屏幕顶部看到一个 “Activities” 选项卡,它将打开一个选项列表和一个用于输入命令的小窗口(类似 “cmd” 为你打开的窗口)。在 Ubuntu 和其他一些版本中,你可能会在屏幕左侧看到一个小的终端图标。在许多系统上,你可以同时按 `Ctrl+Alt+t` 键打开命令窗口。 + +如果你使用 PuTTY 之类的工具登录 Linux 系统,你会发现自己已经处于命令行界面。 + +一旦你得到你的命令行窗口,你会发现自己坐在一个提示符面前。它可能只是一个 `$` 或者像 `user@system:~$` 这样的东西,但它意味着系统已经准备好为你运行命令了。 + +一旦你走到这一步,就应该开始输入命令了。下面是一些要首先尝试的命令,以及这里是一些特别有用的命令的 [PDF][4] 和适合打印和做成卡片的双面命令手册。 + + +| 命令 | 用途 | +|---|---| +| `pwd` | 显示我在文件系统中的位置(在最初进入系统时运行将显示主目录) | +| `ls` | 列出我的文件 | +| `ls -a` | 列出我更多的文件(包括隐藏文件) | +| `ls -al` | 列出我的文件,并且包含很多详细信息(包括日期、文件大小和权限) | +| `who` | 告诉我谁登录了(如果只有你,不要失望) | +| `date` | 日期提醒我今天是星期几(也显示时间) | +| `ps` | 列出我正在运行的进程(可能只是你的 shell 和 `ps` 命令) | + +一旦你从命令行角度习惯了 Linux 主目录之后,就可以开始探索了。也许你会准备好使用以下命令在文件系统中闲逛: + +| 命令 | 用途 | +|---|---| +| `cd /tmp` | 移动到其他文件夹(本例中,打开 `/tmp` 文件夹) | +| `ls` | 列出当前位置的文件 | +| `cd` | 回到主目录(不带参数的 `cd` 总是能将你带回到主目录) | +| `cat .bashrc` | 显示文件的内容(本例中显示 `.bashrc` 文件的内容) | +| `history` | 显示最近执行的命令 | +| `echo hello` | 跟自己说 “hello” | +| `cal` | 显示当前月份的日历 | + +要了解为什么高级 Linux 用户如此喜欢命令行,你将需要尝试其他一些功能,例如重定向和管道。“重定向”是当你获取命令的输出并将其放到文件中而不是在屏幕上显示时。“管道”是指你将一个命令的输出发送给另一条将以某种方式对其进行操作的命令。这是可以尝试的命令: + +| 命令 | 用途 | +|---|---| +| `echo "echo hello" > tryme` | 创建一个新的文件并将 “echo hello” 写入该文件 | +| `chmod 700 tryme` | 使新建的文件可执行 | +| `tryme` | 运行新文件(它应当运行文件中包含的命令并且显示 “hello” )| +| `ps aux` | 显示所有运行中的程序 | +| `ps aux | grep $USER` | 显示所有运行中的程序,但是限制输出的内容包含你的用户名 | +| `echo $USER` | 使用环境变量显示你的用户名 | +| `whoami` | 使用命令显示你的用户名 | +| `who | wc -l` | 计数所有当前登录的用户数目 | + +### 总结 + +一旦你习惯了基本命令,就可以探索其他命令并尝试编写脚本。 你可能会发现 Linux 比你想象的要强大并且好用得多. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3518440/intro-to-the-linux-command-line.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[qianmingtian][c] +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[c]: https://github.com/qianmingtian +[1]: https://commons.wikimedia.org/wiki/File:Tux.svg +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[4]: https://www.networkworld.com/article/3391029/must-know-linux-commands.html +[5]: https://www.networkworld.com/newsletters/signup.html +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/published/202002/20200202 4 Key Changes to Look Out for in Linux Kernel 5.6.md b/published/202002/20200202 4 Key Changes to Look Out for in Linux Kernel 5.6.md new file mode 100644 index 0000000000..e6bf7ef27a --- /dev/null +++ b/published/202002/20200202 4 Key Changes to Look Out for in Linux Kernel 5.6.md @@ -0,0 +1,96 @@ +[#]: collector: (lujun9972) +[#]: translator: (LazyWolfLin) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11853-1.html) +[#]: subject: (4 Key Changes to Look Out for in Linux Kernel 5.6) +[#]: via: (https://itsfoss.com/linux-kernel-5-6/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +四大亮点带你看 Linux 内核 5.6 +====== + +当我们还在体验 Linux 5.5 稳定发行版带来更好的硬件支持时,Linux 5.6 已经来了。 + +说实话,Linux 5.6 比 5.5 更令人兴奋。即使即将发布的 Ubuntu 20.04 LTS 发行版将自带 Linux 5.5,你也需要切实了解一下 Linux 5.6 内核为我们提供了什么。 + +我将在本文中重点介绍 Linux 5.6 发布版中值得期待的关键更改和功能: + +### Linux 5.6 功能亮点 + +![][1] + +当 Linux 5.6 有新消息时,我会努力更新这份功能列表。但现在让我们先看一下当前已知的内容: + +#### 1、支持 WireGuard + +WireGuard 将被添加到 Linux 5.6,出于各种原因的考虑它可能将取代 [OpenVPN][2]。 + +你可以在官网上进一步了解 [WireGuard][3] 的优点。当然,如果你使用过它,那你可能已经知道它比 OpenVPN 更好的原因。 + +同样,[Ubuntu 20.04 LTS 将支持 WireGuard][4]。 + +#### 2、支持 USB4 + +Linux 5.6 也将支持 **USB4**。 + +如果你不了解 USB 4.0 (USB4),你可以阅读这份[文档][5]。 + +根据文档,“USB4 将使 USB 的最大带宽增大一倍并支持多并发数据和显示协议multiple simultaneous data and display protocols。” + +另外,虽然我们都知道 USB4 基于 Thunderbolt 接口协议,但它将向后兼容 USB 2.0、USB 3.0 以及 Thunderbolt 3,这将是一个好消息。 + +#### 3、使用 LZO/LZ4 压缩 F2FS 数据 + +Linux 5.6 也将支持使用 LZO/LZ4 算法压缩 F2FS 数据。 + +换句话说,这只是 Linux 文件系统的一种新压缩技术,你可以选择待定的文件扩展技术。 + +#### 4、解决 32 位系统的 2038 年问题 + +Unix 和 Linux 将时间值以 32 位有符号整数格式存储,其最大值为 2147483647。时间值如果超过这个数值则将由于整数溢出而存储为负数。 + +这意味着对于 32 位系统,时间值不能超过 1970 年 1 月 1 日后的 2147483647 秒。也就是说,在 UTC 时间 2038 年 1 月 19 日 03:14:07 时,由于整数溢出,时间将显示为 1901 年 12 月 13 日而不是 2038 年 1 月 19 日。 + +Linux kernel 5.6 解决了这个问题,因此 32 位系统也可以运行到 2038 年以后。 + +#### 5、改进硬件支持 + +很显然,在下一个发布版中,硬件支持也将继续提升。而支持新式无线外设的计划也同样是优先的。 + +新内核中将增加对 MX Master 3 鼠标以及罗技其他无线产品的支持。 + +除了罗技的产品外,你还可以期待获得许多不同硬件的支持(包括对 AMD GPU、NVIDIA GPU 和 Intel Tiger Lake 芯片组的支持)。 + +#### 6、其他更新 + +此外,Linux 5.6 中除了上述主要的新增功能或支持外,下一个内核版本也将进行其他一些改进: + + * 改进 AMD Zen 的温度/功率报告 + * 修复华硕飞行堡垒系列笔记本中 AMD CPU 过热 + * 开源支持 NVIDIA RTX 2000 图灵系列显卡 + * 内建 FSCRYPT 加密 + +[Phoronix][6] 跟踪了 Linux 5.6 带来的许多技术性更改。因此,如果你好奇 Linux 5.6 所涉及的全部更改,则可以亲自了解一下。 + +现在你已经了解了 Linux 5.6 发布版带来的新功能,对此有什么看法呢?在下方评论中留下你的看法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/linux-kernel-5-6/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[LazyWolfLin](https://github.com/LazyWolfLin) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/linux-kernel-5.6.jpg?ssl=1 +[2]: https://openvpn.net/ +[3]: https://www.wireguard.com/ +[4]: https://www.phoronix.com/scan.php?page=news_item&px=Ubuntu-20.04-Adds-WireGuard +[5]: https://www.usb.org/sites/default/files/2019-09/USB-IF_USB4%20spec%20announcement_FINAL.pdf +[6]: https://www.phoronix.com/scan.php?page=news_item&px=Linux-5.6-Spectacular diff --git a/published/202002/20200203 Give an old MacBook new life with Linux.md b/published/202002/20200203 Give an old MacBook new life with Linux.md new file mode 100644 index 0000000000..4a2ec03b17 --- /dev/null +++ b/published/202002/20200203 Give an old MacBook new life with Linux.md @@ -0,0 +1,83 @@ +[#]: collector: (lujun9972) +[#]: translator: (qianmingtian) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11902-1.html) +[#]: subject: (Give an old MacBook new life with Linux) +[#]: via: (https://opensource.com/article/20/2/macbook-linux-elementary) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +用 Linux 让旧 MacBook 焕发新生 +====== + +> Elementary OS 的最新版本 Hera 是一个令人印象深刻的平台,它可以让过时的 MacBook 得以重生。 + +![](https://img.linux.net.cn/data/attachment/album/202002/18/113614k2jx6ju7uuu0alhk.png) + +当我安装苹果的 [MacOS Mojave][2] 时,它使我以前可靠的 MacBook Air 慢得像爬一样。我的计算机发售于 2015 年,具有 4 GB 内存、i5 处理器和 Broadcom 4360 无线卡,但是对于我的日常使用来说,Mojava 有点过分了,它不能和 [GnuCash][3] 一起工作,这激起了我重返 Linux 的欲望。我很高兴能重返,但是我深感遗憾的是,我的这台出色的 MacBook 被闲置了。 + +我在 MacBook Air 上尝试了几种 Linux 发行版,但总会有缺陷。有时是无线网卡;还有一次,它缺少对触摸板的支持。看了一些不错的评论后,我决定尝试 [Elementary OS][4] 5.0(Juno)。我用 USB [制作了启动盘][5],并将其插入 MacBook Air 。我来到了一个现场live桌面,并且操作系统识别出了我的 Broadcom 无线芯片组 —— 我认为这可能行得通! + +我喜欢在 Elementary OS 中看到的内容。它的 [Pantheon][6] 桌面真的很棒,并且其外观和使用起来的感觉对 Apple 用户来说很熟悉 —— 它的显示屏底部有一个扩展坞,并带有一些指向常用应用程序的图标。我对我之前期待的预览感到满意,所以我决定安装它,然后我的无线设备消失了。真的很令人失望。我真的很喜欢 Elementary OS ,但是没有无线网络是不行的。 + +时间快进到 2019 年 12 月,当我在 [Linux4Everyone][7] 播客上听到有关 Elementary 最新版本 v.5.1(Hera) 使 MacBook 复活的评论时,我决定用 Hera 再试一次。我下载了 ISO ,创建了可启动驱动器,将其插入电脑,这次操作系统识别了我的无线网卡。我可以在上面工作了。 + +![运行 Hera 的 MacBook Air][8] + +我非常高兴我轻巧又功能强大的 MacBook Air 通过 Linux 焕然一新。我一直在更详细地研究 Elementary OS,我可以告诉你我印象深刻的东西。 + +### Elementary OS 的功能 + +根据 [Elementary 的博客][9],“新设计的登录和锁定屏幕问候语看起来更清晰、效果更好,并且修复了以前问候语中报告的许多问题,包括输入焦点问题,HiDPI 问题和更好的本地化。Hera 的新设计是为了响应来自 Juno 的用户反馈,并启用了一些不错的新功能。” + +“不错的新功能”是在轻描淡写 —— Elementary OS 拥有我见过的最佳设计的 Linux 用户界面之一。默认情况下,系统上的“系统设置”图标位于扩展坞上。更改设置很容易,很快我就按照自己的喜好配置了系统。我需要的文字大小比默认值大,辅助功能是易于使用的,允许我设置大文字和高对比度。我还可以使用较大的图标和其他选项来调整扩展坞。 + +![Elementary OS 的设置界面][10] + +按下 Mac 的 Command 键将弹出一个键盘快捷键列表,这对新用户非常有帮助。 + +![Elementary OS 的键盘快捷键][11] + +Elementary OS 附带的 [Epiphany][12] Web 浏览器,我发现它非常易于使用。它与 Chrome、Chromium 或 Firefox 略有不同,但它已经绰绰有余。 + +对于注重安全的用户(我们应该都是),Elementary OS 的安全和隐私设置提供了多个选项,包括防火墙、历史记录、锁定,临时和垃圾文件的自动删除以及用于位置服务开/关的开关。 + +![Elementary OS 的隐私与安全][13] + +### 有关 Elementray OS 的更多信息 + +Elementary OS 最初于 2011 年发布,其最新版本 Hera 于 2019 年 12 月 3 日发布。 Elementary 的联合创始人兼 CXO 的 [Cassidy James Blaede][14] 是操作系统的 UX 架构师。 Cassidy 喜欢使用开放技术来设计和构建有用、可用和令人愉悦的数字产品。 + +Elementary OS 具有出色的用户[文档][15],其代码(在 GPL 3.0 下许可)可在 [GitHub][16] 上获得。Elementary OS 鼓励参与该项目,因此请务必伸出援手并[加入社区][17]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/macbook-linux-elementary + +作者:[Don Watkins][a] +选题:[lujun9972][b] +译者:[qianmingtian][c] +校对:[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 +[c]: https://github.com/qianmingtian +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_cafe_brew_laptop_desktop.jpg?itok=G-n1o1-o (Coffee and laptop) +[2]: https://en.wikipedia.org/wiki/MacOS_Mojave +[3]: https://www.gnucash.org/ +[4]: https://elementary.io/ +[5]: https://opensource.com/life/14/10/test-drive-linux-nothing-flash-drive +[6]: https://opensource.com/article/19/12/pantheon-linux-desktop +[7]: https://www.linux4everyone.com/20-macbook-pro-elementary-os +[8]: https://opensource.com/sites/default/files/uploads/macbookair_hera.png (MacBook Air with Hera) +[9]: https://blog.elementary.io/introducing-elementary-os-5-1-hera/ +[10]: https://opensource.com/sites/default/files/uploads/elementaryos_settings.png (Elementary OS's Settings screen) +[11]: https://opensource.com/sites/default/files/uploads/elementaryos_keyboardshortcuts.png (Elementary OS's Keyboard shortcuts) +[12]: https://en.wikipedia.org/wiki/GNOME_Web +[13]: https://opensource.com/sites/default/files/uploads/elementaryos_privacy-security.png (Elementary OS's Privacy and Security screen) +[14]: https://github.com/cassidyjames +[15]: https://elementary.io/docs/learning-the-basics#learning-the-basics +[16]: https://github.com/elementary +[17]: https://elementary.io/get-involved diff --git a/published/202002/20200203 Troubleshoot Kubernetes with the power of tmux and kubectl.md b/published/202002/20200203 Troubleshoot Kubernetes with the power of tmux and kubectl.md new file mode 100644 index 0000000000..8fe0552828 --- /dev/null +++ b/published/202002/20200203 Troubleshoot Kubernetes with the power of tmux and kubectl.md @@ -0,0 +1,158 @@ +[#]: collector: (lujun9972) +[#]: translator: (guevaraya) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11930-1.html) +[#]: subject: (Troubleshoot Kubernetes with the power of tmux and kubectl) +[#]: via: (https://opensource.com/article/20/2/kubernetes-tmux-kubectl) +[#]: author: (Abhishek Tamrakar https://opensource.com/users/tamrakar) + +利用 Tmux 和 kubectl 解决 Kubernetes 故障 +====== + +> 一个使用 tmux 的 kubectl 插件可以使 Kubernetes 疑难问题变得更简单。 + +![](https://img.linux.net.cn/data/attachment/album/202002/25/125435a4v3vpss3s4w3sks.jpg) + +[Kubernetes][2] 是一个活跃的开源容器管理平台,它提供了可扩展性、高可用性、健壮性和富有弹性的应用程序管理。它的众多特性之一是支持通过其主要的二进制客户端 [kubectl][3] 运行定制脚本或可执行程序,kubectl 很强大的,允许用户在 Kubernetes 集群上用它直接做很多事情。 + +### 使用别名进行 Kubernetes 的故障排查 + +使用 Kubernetes 进行容器编排的人都知道由于设计上原因带来了其功能的复杂性。举例说,迫切需要以更快的速度并且几乎不需要手动干预的方式来简化 Kubernetes 中的故障排除(除过特殊情况)。 + +在故障排查功能方面,有很多场景需要考虑。在一种场景下,你知道你需要运行什么,但是这个命令的语法(即使作为一个单独的命令运行)过于复杂,或需要一、两次交互才能起作用。 + +例如,如果你需要经常进入一个系统命名空间中运行的容器,你可能发现自己在重复地键入: + +``` +kubectl --namespace=kube-system exec -i -t +``` + +为了简化故障排查,你可以用这些指令的命令行别名。比如,你可以增加下面命令到你的隐藏配置文件(`.bashrc` 或 `.zshrc`): + +``` +alias ksysex='kubectl --namespace=kube-system exec -i -t' +``` + +这是来自于 [Kubernetes 常见别名][4]存储库的一个例子,它展示了一种简化 `kubectl` 中的功能的方法。像这种场景下的简单情形,使用别名很有用。 + +### 切换到 kubectl 插件 + +更复杂的故障排查场景是需要一个一个的执行很多命令,调查环境,最后得出结论。仅仅用别名方法是不能解决这种情况的;你需要知道你所部署的 Kubernetes 之间逻辑和相关性,你真正需要的是自动化,以在更短的时间内输出你想要的。 + +考虑到你的集群有 10 ~ 20 或 50 ~ 100 个命名空间来提供不同的微服务。一般在进行故障排查时,什么对你有帮助? + +* 你需要能够快速分辨出抛出错误的是哪个 命名空间的哪个 Pod 的东西。 +* 你需要一些可监视一个命名空间的所有 Pod 日志的东西。 +* 你可能也需要监视特定命名空间的出现错误的某个 Pod 的日志。 + +涵盖这些要点的解决方案对于定位生产环境的问题有很大的帮助,以及在开发和测试环节中也很有用。 + +你可以用 [kubectl 插件][5]创建比简单的别名更强大的功能。插件类似于其它用任何语言编写的独立脚本,但被设计为可以扩充 Kubernetes 管理员的主要命令。 + +创建一个插件,你必须用 `kubectl-` 的正确的语法来拷贝这个脚本到 `$PATH` 中的导出目录之一,并需要为其赋予可执行权限(`chmod +x`)。 + +创建插件之后将其移动到路径中,你可以立即运行它。例如,我的路径下有一个 `kubectl-krawl` 和 `kubectl-kmux`: + +``` +$ kubectl plugin list +The following compatible plugins are available: + +/usr/local/bin/kubectl-krawl +/usr/local/bin/kubectl-kmux + +$ kubectl kmux +``` + +现在让我们见识下带有 tmux 的 Kubernetes 的有多强大。 + +### 驾驭强大的 tmux + +[Tmux][6] 是一个非常强大的工具,许多管理员和运维团队都依赖它来解决与易操作性相关的问题:通过将窗口分成多个窗格以便在多台计算机上运行并行的调试来监视日志。它的主要的优点是可在命令行或自动化脚本中使用。 + +我创建[一个 kubectl 插件][7],使用 tmux 使故障排查更加简单。我将通过注释来解析插件背后的逻辑(插件的完整代码留待给你实现): + +``` +# NAMESPACE 是要监控的名字空间 +# POD 是 Pod 名称 +# Containers 是容器名称 + +# 初始化一个计数器 n 以计算循环计数的数量, +# 之后 tmux 使用它来拆分窗格。 +n=0; + +# 在 Pod 和容器列表上开始循环 +while IFS=' ' read -r POD CONTAINERS +do + # tmux 为每个 Pod 创建一个新窗口 + tmux neww $COMMAND -n $POD 2>/dev/null + # 对运行中的 Pod 中 的所有容器启动循环 + for CONTAINER in ${CONTAINERS//,/ } + do + if [ x$POD = x -o x$CONTAINER = x ]; then + # 如果任何值为 null,则退出。 + warn "Looks like there is a problem getting pods data." + break + fi + + # 设置要执行的命令 + COMMAND=”kubectl logs -f $POD -c $CONTAINER -n $NAMESPACE” + # 检查 tmux 会话 + if tmux has-session -t <会话名> 2>/dev/null; + then + <设置会话退出> + else + <创建会话> + fi + # 在当前窗口为每个容器切分窗格 + tmux selectp -t $n \; \ + splitw $COMMAND \; \ + select-layout tiled \; + # 终止容器循环 + done + + # 用 Pod 名称重命名窗口以识别 + tmux renamew $POD 2>/dev/null + + # 增加计数器 + ((n+=1)) + +# 终止 Pod 循环 +done<<(<从 kubernetes 集群获取 Pod 和容器的列表>) + +# 最后选择窗口并附加会话 +tmux selectw -t <会话名>:1 \; \ +attach-session -t <会话名>\; +``` + +运行插件脚本后,将产生类似于下图的输出。每个 Pod 有一个自己的窗口,每个容器(如果有多个)被分割到其窗口中 Pod 窗格中,并在日志到达时输出。Tmux 之美如下可见;通过正确的配置,你甚至会看到哪个窗口正处于激活运行状态(可看到标签是白色的)。 + +![kmux 插件的输出][8] + +### 总结 + +别名是在 Kubernetes 环境下常见的也有用的简易故障排查方法。当环境变得复杂,用高级脚本生成的kubectl 插件是一个更强大的方法。至于用哪个编程语言来编写 kubectl 插件是没有限制。唯一的要求是该名字在路径中是可执行的,并且不能与已知的 kubectl 命令重复。 + +要阅读完整的插件源码,或试试我创建的插件,请查看我的 [kube-plugins-github][7] 存储库。欢迎提交提案和补丁。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/kubernetes-tmux-kubectl + +作者:[Abhishek Tamrakar][a] +选题:[lujun9972][b] +译者:[guevaraya](https://github.com/guevaraya) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/tamrakar +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_4.png?itok=VGZO8CxT (一个坐在笔记本面前的妇女) +[2]: https://opensource.com/resources/what-is-kubernetes +[3]: https://kubernetes.io/docs/reference/kubectl/overview/ +[4]: https://github.com/ahmetb/kubectl-aliases/blob/master/.kubectl_aliases +[5]: https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/ +[6]: https://opensource.com/article/19/6/tmux-terminal-joy +[7]: https://github.com/abhiTamrakar/kube-plugins +[8]: https://raw.githubusercontent.com/abhiTamrakar/kube-plugins/master/kmux/kmux.png diff --git a/published/202002/20200204 Ubuntu 19.04 Has Reached End of Life- Existing Users Must Upgrade to Ubuntu 19.10.md b/published/202002/20200204 Ubuntu 19.04 Has Reached End of Life- Existing Users Must Upgrade to Ubuntu 19.10.md new file mode 100644 index 0000000000..3526c8e6ec --- /dev/null +++ b/published/202002/20200204 Ubuntu 19.04 Has Reached End of Life- Existing Users Must Upgrade to Ubuntu 19.10.md @@ -0,0 +1,76 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11866-1.html) +[#]: subject: (Ubuntu 19.04 Has Reached End of Life! Existing Users Must Upgrade to Ubuntu 19.10) +[#]: via: (https://itsfoss.com/ubuntu-19-04-end-of-life/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Ubuntu 19.04 已经到期!现有用户必须升级到 Ubuntu 19.10 +====== + +> Ubuntu 19.04 已在 2020 年 1 月 23 日到期,这意味着运行 Ubuntu 19.04 的系统将不再会接收到安全和维护更新,因此将使其容易受到攻击。 + +![][1] + +[Ubuntu 19.04][2] 发布于 2019 年 4 月 18 日。由于它不是长期支持(LTS)版本,因此只有 9 个月的支持。完成它的发行周期后,Ubuntu 19.04 于 2020 年 1 月 23 日到期。 + +Ubuntu 19.04 带来了一些视觉和性能方面的改进,为时尚和美观的 Ubuntu 外观铺平了道路。与其他常规 Ubuntu 版本一样,它的生命周期为 9 个月。它如今结束了。 + +### Ubuntu 19.04 终止了吗?这是什么意思? + +EOL(End of life)是指在某个日期之后操作系统版本将无法获得更新。你可能已经知道 Ubuntu(或其他操作系统)提供了安全性和维护升级,以使你的系统免受网络攻击。当发行版到期后,操作系统将停止接收这些重要更新。 + +如果你的操作系统版本到期后继续使用该系统,那么系统将容易受到网络和恶意软件的攻击。不仅如此。在 Ubuntu 中,你使用 APT 从软件中心下载的应用也不会更新。实际上,你将不再能够[使用 apt-get 命令安装新软件][3](如果不是立即,那就是逐渐地)。 + +### 所有 Ubuntu 19.04 用户必须升级到 Ubuntu 19.10 + +从 2020 年 1 月 23 日开始,Ubuntu 19.04 将停止接收更新。你必须升级到 2020 年 7 月之前受支持的 Ubuntu 19.10。这也适用于其他[官方 Ubuntu 衍生版][4],例如 Lubuntu、Xubuntu、Kubuntu 等。 + +你可以在“设置 -> 细节” 或使用如下命令来[检查你的 Ubuntu 版本][9]: + +``` +lsb_release -a +``` + +#### 如何升级到 Ubuntu 19.10? + +值得庆幸的是,Ubuntu 提供了简单的方法来将现有系统升级到新版本。实际上,Ubuntu 还会提示你有新的 Ubuntu 版本可用,你应该升级到该版本。 + +![Existing Ubuntu 19.04 should see a message to upgrade to Ubuntu 19.10][5] + +如果你的互联网连接良好,那么可以使用[和更新 Ubuntu 一样的 Software Updater 工具][6]。在上图中,你只需单击 “Upgrade” 按钮并按照说明进行操作。我已经编写了有关使用此方法[升级到 Ubuntu 18.04][7]的文章。 + +如果你没有良好的互联网连接,那么有一种临时方案。在外部磁盘上备份家目录或重要数据。 + +然后,制作一个 Ubuntu 19.10 的 Live USB。下载 Ubuntu 19.10 ISO,并使用 Ubuntu 系统上已安装的启动磁盘创建器从该 ISO 创建 Live USB。 + +从该 Live USB 引导,然后继续“安装” Ubuntu 19.10。在安装过程中,你应该看到一个删除 Ubuntu 19.04 并将其替换为 Ubuntu 19.10 的选项。选择此选项,然后像重新[安装 Ubuntu][8]一样进行下去。 + +#### 你是否仍在使用 Ubuntu 19.04、18.10、17.10 或其他不受支持的版本? + +你应该注意,目前仅 Ubuntu 16.04、18.04 和 19.10(或更高版本)版本还受支持。如果你运行的不是这些 Ubuntu 版本,那么你必须升级到较新版本。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-19-04-end-of-life/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/End-of-Life-Ubuntu-19.04.png?ssl=1 +[2]: https://itsfoss.com/ubuntu-19-04-release/ +[3]: https://itsfoss.com/apt-get-linux-guide/ +[4]: https://itsfoss.com/which-ubuntu-install/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/ubuntu_19_04_end_of_life.jpg?ssl=1 +[6]: https://itsfoss.com/update-ubuntu/ +[7]: https://itsfoss.com/upgrade-ubuntu-version/ +[8]: https://itsfoss.com/install-ubuntu/ +[9]: https://itsfoss.com/how-to-know-ubuntu-unity-version/ diff --git a/published/202002/20200205 Getting started with GnuCash.md b/published/202002/20200205 Getting started with GnuCash.md new file mode 100644 index 0000000000..00dc0465c5 --- /dev/null +++ b/published/202002/20200205 Getting started with GnuCash.md @@ -0,0 +1,96 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11895-1.html) +[#]: subject: (Getting started with GnuCash) +[#]: via: (https://opensource.com/article/20/2/gnucash) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +开始使用 GnuCash +====== + +> 使用 GnuCash 管理你的个人或小型企业会计。 + +![](https://img.linux.net.cn/data/attachment/album/202002/15/124236wz5e0z5vq7571qby.jpg) + +在过去的四年里,我一直在用 [GnuCash][2] 来管理我的个人财务,我对此非常满意。这个开源(GPL v3)项目自 1998 年首次发布以来一直成长和改进,2019 年 12 月发布的最新版本 3.8 增加了许多改进和 bug 修复。 + +GnuCash 可在 Windows、MacOS 和 Linux 中使用。它实现了一个复式记账系统,并可以导入各种流行的开放和专有文件格式,包括 QIF、QFX、OFX、CSV 等。这使得从其他财务应用转换(包括 Quicken)而来很容易,它是为取代这些而出现的。 + +借助 GnuCash,你可以跟踪个人财务状况以及小型企业会计和开票。它没有集成的工资系统。根据文档,你可以在 GnuCash 中跟踪工资支出,但你必须在该软件外计算税金和扣减。 + +### 安装 + +要在 Linux 上安装 GnuCash: + + * 在 Red Hat、CentOS 或 Fedora 中: `$ sudo dnf install gnucash` + * 在 Debian、Ubuntu 或 Pop_OS 中: `$ sudo apt install gnucash` + +你也可以从 [Flathub][3] 安装它,我在运行 Elementary OS 的笔记本上使用它。(本文中的所有截图都来自此次安装)。 + +### 设置 + +安装并启动程序后,你将看到一个欢迎屏幕,该页面提供了创建新账户集、导入 QIF 文件或打开新用户教程的选项。 + +![GnuCash Welcome screen][4] + +#### 个人账户 + +如果你选择第一个选项(正如我所做的那样),GnuCash 会打开一个页面帮你起步。它收集初始数据并设置账户首选项,例如账户类型和名称、商业数据(例如,税号)和首选货币。 + +![GnuCash new account setup][5] + +GnuCash 支持个人银行账户、商业账户、汽车贷款、CD 和货币市场账户、儿童保育账户等。 + +例如,首先创建一个简单的支票簿。你可以输入账户的初始余额或以多种格式导入现有账户数据。 + +![GnuCash import data][6] + +#### 开票 + +GnuCash 还支持小型企业功能,包括客户、供应商和开票。要创建发票,请在 “Business -> Invoice” 中输入数据。 + +![GnuCash create invoice][7] + +然后,你可以将发票打印在纸上,也可以将其导出到 PDF 并通过电子邮件发送给你的客户。 + +![GnuCash invoice][8] + +### 获取帮助 + +如果你有任何疑问,它有一个优秀的帮助,你可在菜单栏的右侧获取指导。 + +![GnuCash help][9] + +该项目的网站包含许多有用的信息的链接,例如 GnuCash [功能][10]的概述。GnuCash 还提供了[详细的文档][11],可供下载和离线阅读,它还有一个 [wiki][12],为用户和开发人员提供了有用的信息。 + +你可以在项目的 [GitHub][13] 仓库中找到其他文件和文档。GnuCash 项目由志愿者驱动。如果你想参与,请查看项目的 wiki 上的 [Getting involved][14] 部分。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/gnucash + +作者:[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/osdc_whitehurst_money.png?itok=ls-SOzM0 (A dollar sign in a network) +[2]: https://www.gnucash.org/ +[3]: https://flathub.org/apps/details/org.gnucash.GnuCash +[4]: https://opensource.com/sites/default/files/images/gnucash_welcome.png (GnuCash Welcome screen) +[5]: https://opensource.com/sites/default/files/uploads/gnucash_newaccountsetup.png (GnuCash new account setup) +[6]: https://opensource.com/sites/default/files/uploads/gnucash_importdata.png (GnuCash import data) +[7]: https://opensource.com/sites/default/files/uploads/gnucash_enter-invoice.png (GnuCash create invoice) +[8]: https://opensource.com/sites/default/files/uploads/gnucash_invoice.png (GnuCash invoice) +[9]: https://opensource.com/sites/default/files/uploads/gnucash_help.png (GnuCash help) +[10]: https://www.gnucash.org/features.phtml +[11]: https://www.gnucash.org/docs/v3/C/gnucash-help.pdf +[12]: https://wiki.gnucash.org/wiki/GnuCash +[13]: https://github.com/Gnucash +[14]: https://wiki.gnucash.org/wiki/GnuCash#Getting_involved_in_the_GnuCash_project diff --git a/published/202002/20200206 3 ways to use PostgreSQL commands.md b/published/202002/20200206 3 ways to use PostgreSQL commands.md new file mode 100644 index 0000000000..edb92e9144 --- /dev/null +++ b/published/202002/20200206 3 ways to use PostgreSQL commands.md @@ -0,0 +1,218 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11904-1.html) +[#]: subject: (3 ways to use PostgreSQL commands) +[#]: via: (https://opensource.com/article/20/2/postgresql-commands) +[#]: author: (Greg Pittman https://opensource.com/users/greg-p) + +3 种使用 PostgreSQL 命令的方式 +====== + +> 无论你需要的东西简单(如一个购物清单)亦或复杂(如色卡生成器) ,PostgreSQL 命令都能使它变得容易起来。 + +![](https://img.linux.net.cn/data/attachment/album/202002/18/124003twk7fryz2krw2r39.jpg) + +在 [PostgreSQL 入门][2]一文中, 我解释了如何安装、设置和开始使用这个开源数据库软件。不过,使用 [PostgreSQL][3] 中的命令可以做更多事情。 + +例如,我使用 Postgres 来跟踪我的杂货店购物清单。我的大多数杂货店购物是在家里进行的,而且每周进行一次大批量的采购。我去几个不同的地方购买清单上的东西,因为每家商店都提供特定的选品或质量,亦或更好的价格。最初,我制作了一个 HTML 表单页面来管理我的购物清单,但这样无法保存我的输入内容。因此,在想到要购买的物品时我必须马上列出全部清单,然后到采购时我常常会忘记一些我需要或想要的东西。 + +相反,使用 PostgreSQL,当我想到需要的物品时,我可以随时输入,并在购物前打印出来。你也可以这样做。 + +### 创建一个简单的购物清单 + +首先,输入 `psql` 命令进入数据库,然后用下面的命令创建一个表: + +``` +Create table groc (item varchar(20), comment varchar(10)); +``` + +输入如下命令在清单中加入商品: + +``` +insert into groc values ('milk', 'K'); +insert into groc values ('bananas', 'KW'); +``` + +括号中有两个信息(逗号隔开):前面是你需要买的东西,后面字母代表你要购买的地点以及哪些东西是你每周通常都要买的(`W`)。 + +因为 `psql` 有历史记录,你可以按向上键在括号内编辑信息,而无需输入商品的整行信息。 + +在输入一小部分商品后,输入下面命令来检查前面的输入内容。 + +``` +Select * from groc order by comment; + + item | comment +----------------+--------- + ground coffee | H + butter | K + chips | K + steak | K + milk | K + bananas | KW + raisin bran | KW + raclette | L + goat cheese | L + onion | P + oranges | P + potatoes | P + spinach | PW + broccoli | PW + asparagus | PW + cucumber | PW + sugarsnap peas | PW + salmon | S +(18 rows) +``` + +此命令按 `comment` 列对结果进行排序,以便按购买地点对商品进行分组,从而使你的购物更加方便。 + +使用 `W` 来指明你每周要买的东西,当你要清除表单为下周的列表做准备时,你可以将每周的商品保留在购物清单上。输入: + +``` +delete from groc where comment not like '%W'; +``` + +注意,在 PostgreSQL 中 `%` 表示通配符(而非星号)。所以,要保存输入内容,需要输入: + +``` +delete from groc where item like 'goat%'; +``` + +不能使用 `item = 'goat%'`,这样没用。 + +在购物时,用以下命令输出清单并打印或发送到你的手机: + +``` +\o groclist.txt +select * from groc order by comment; +\o +``` + +最后一个命令 `\o` 后面没有任何内容,将重置输出到命令行。否则,所有的输出会继续输出到你创建的杂货店购物文件 `groclist.txt` 中。 + +### 分析复杂的表 + +这个逐项列表对于数据量小的表来说没有问题,但是对于数据量大的表呢?几年前,我帮 [FreieFarbe.de][4] 的团队从 HLC 调色板中创建一个自由色的色样册。事实上,任何能想象到的打印色都可按色调、亮度、浓度(饱和度)来规定。最终结果是 [HLC Color Atlas][5],下面是我们如何实现的。 + +该团队向我发送了具有颜色规范的文件,因此我可以编写可与 Scribus 配合使用的 Python 脚本,以轻松生成色样册。一个例子像这样开始: + +``` +HLC, C, M, Y, K +H010_L15_C010, 0.5, 49.1, 0.1, 84.5 +H010_L15_C020, 0.0, 79.7, 15.1, 78.9 +H010_L25_C010, 6.1, 38.3, 0.0, 72.5 +H010_L25_C020, 0.0, 61.8, 10.6, 67.9 +H010_L25_C030, 0.0, 79.5, 18.5, 62.7 +H010_L25_C040, 0.4, 94.2, 17.3, 56.5 +H010_L25_C050, 0.0, 100.0, 15.1, 50.6 +H010_L35_C010, 6.1, 32.1, 0.0, 61.8 +H010_L35_C020, 0.0, 51.7, 8.4, 57.5 +H010_L35_C030, 0.0, 68.5, 17.1, 52.5 +H010_L35_C040, 0.0, 81.2, 22.0, 46.2 +H010_L35_C050, 0.0, 91.9, 20.4, 39.3 +H010_L35_C060, 0.1, 100.0, 17.3, 31.5 +H010_L45_C010, 4.3, 27.4, 0.1, 51.3 +``` + +这与原始数据相比,稍有修改,原始数据用制表符分隔。我将其转换成 CSV 格式(用逗号分割值),我更喜欢其与 Python 一起使用(CSV 文也很有用,因为它可轻松导入到电子表格程序中)。 + +在每一行中,第一项是颜色名称,其后是其 C、M、Y 和 K 颜色值。 该文件包含 1,793 种颜色,我想要一种分析信息的方法,以了解这些值的范围。这就是 PostgreSQL 发挥作用的地方。我不想手动输入所有数据 —— 我认为输入过程中我不可能不出错,而且令人头痛。幸运的是,PostgreSQL 为此提供了一个命令。 + +首先用以下命令创建数据库: + +``` +Create table hlc_cmyk (color varchar(40), c decimal, m decimal, y decimal, k decimal); +``` + +然后通过以下命令引入数据: + +``` +\copy hlc_cmyk from '/home/gregp/HLC_Atlas_CMYK_SampleData.csv' with (header, format CSV); +``` + +开头有反斜杠,是因为使用纯 `copy` 命令的权限仅限于 root 用户和 Postgres 的超级用户。在括号中,`header` 表示第一行包含标题,应忽略,`CSV` 表示文件格式为 CSV。请注意,在此方法中,颜色名称不需要用括号括起来。 + +如果操作成功,会看到 `COPY NNNN`,其中 N 表示插入到表中的行数。 + +最后,可以用下列命令查询: + +``` +select * from hlc_cmyk; + + color | c | m | y | k +---------------+-------+-------+-------+------ + H010_L15_C010 | 0.5 | 49.1 | 0.1 | 84.5 + H010_L15_C020 | 0.0 | 79.7 | 15.1 | 78.9 + H010_L25_C010 | 6.1 | 38.3 | 0.0 | 72.5 + H010_L25_C020 | 0.0 | 61.8 | 10.6 | 67.9 + H010_L25_C030 | 0.0 | 79.5 | 18.5 | 62.7 + H010_L25_C040 | 0.4 | 94.2 | 17.3 | 56.5 + H010_L25_C050 | 0.0 | 100.0 | 15.1 | 50.6 + H010_L35_C010 | 6.1 | 32.1 | 0.0 | 61.8 + H010_L35_C020 | 0.0 | 51.7 | 8.4 | 57.5 + H010_L35_C030 | 0.0 | 68.5 | 17.1 | 52.5 +``` + + +所有的 1,793 行数据都是这样的。回想起来,我不能说此查询对于 HLC 和 Scribus 任务是绝对必要的,但是它减轻了我对该项目的一些担忧。 + +为了生成 HLC 色谱,我使用 Scribus 为色板页面中的 13,000 多种颜色自动创建了颜色图表。 + +我可以使用 `copy` 命令输出数据: + +``` +\copy hlc_cmyk to '/home/gregp/hlc_cmyk_backup.csv' with (header, format CSV); +``` + +我还可以使用 `where` 子句根据某些值来限制输出。 + +例如,以下命令将仅发送以 `H10` 开头的色调值。 + +``` +\copy hlc_cmyk to '/home/gregp/hlc_cmyk_backup.csv' with (header, format CSV) where color like 'H10%'; +``` + +### 备份或传输数据库或表 + +我在此要提到的最后一个命令是 `pg_dump`,它用于备份 PostgreSQL 数据库,并在 `psql` 控制台之外运行。 例如: + +``` +pg_dump gregp -t hlc_cmyk > hlc.out +pg_dump gregp > dball.out +``` + +第一行是导出 `hlc_cmyk` 表及其结构。第二行将转储 `gregp` 数据库中的所有表。这对于备份或传输数据库或表非常有用。 + +要将数据库或表传输到另一台电脑(查看 [PostgreSQL 入门][2]那篇文章获取详细信息),首先在要转入的电脑上创建一个数据库,然后执行相反的操作。 + +``` +psql -d gregp -f dball.out +``` + +一步创建所有表并输入数据。 + +### 总结 + +在本文中,我们了解了如何使用 `WHERE` 参数限制操作,以及如何使用 PostgreSQL 通配符 `%`。我们还了解了如何将大批量数据加载到表中,然后将部分或全部表数据输出到文件,甚至是将整个数据库及其所有单个表输出。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/postgresql-commands + +作者:[Greg Pittman][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/greg-p +[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://linux.cn/article-11593-1.html +[3]: https://www.postgresql.org/ +[4]: http://freiefarbe.de +[5]: https://www.freiefarbe.de/en/thema-farbe/hlc-colour-atlas/ diff --git a/published/202002/20200207 Best Open Source eCommerce Platforms to Build Online Shopping Websites.md b/published/202002/20200207 Best Open Source eCommerce Platforms to Build Online Shopping Websites.md new file mode 100644 index 0000000000..ae38ffcddd --- /dev/null +++ b/published/202002/20200207 Best Open Source eCommerce Platforms to Build Online Shopping Websites.md @@ -0,0 +1,186 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11884-1.html) +[#]: subject: (Best Open Source eCommerce Platforms to Build Online Shopping Websites) +[#]: via: (https://itsfoss.com/open-source-ecommerce/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +7 个可用于自建电商站点的开源解决方案 +====== + +在[之前的文章][1]中,我介绍过一些开源内容管理系统Content Management System(CMS),顾名思义,这些 CMS 平台更适用于以内容为主的站点。 + +那如果想要建立自己的线上购物站点呢?我们正好还有一些优秀的开源电商解决方案,可以自行部署在自己的 Linux 服务器上。 + +这些电商解决方案是专为搭建线上购物站点设计的,因此都集成了库存管理、商品列表、购物车、下单、愿望清单以及支付这些必需的基础功能。 + +但请注意,这篇文章并不会进行深入介绍。因此,我建议最好广泛试用其中的多个产品,以便进一步的了解和比较。 + +### 优秀的开源电商解决方案 + +![][2] + +开源电商解决方案种类繁多,一些缺乏维护的都会被我们忽略掉,以免搭建出来的站点因维护不及时而受到影响。 + +另外,以下的列表排名不分先后。 + +#### 1、nopCommerce + +![][3] + +nopCommerce 是基于 [ASP.NET Core][4] 的自由开源的电商解决方案。如果你要找的是基于 PHP 的解决方案,可以跳过这一节了。 + +nopCommerce 的管理面板界面具有简洁易用的特点,如果你还使用过 OpenCart,就可能会感到似曾相识(我不是在抱怨)。在默认情况下,它就已经自带了很多基本的功能,同时还为移动端用户提供了响应式的设计。 + +你可以在其[官方商店][5]中获取到一些兼容的界面主题和应用扩展,还可以选择付费的支持服务。 + +在开始使用前,你可以从 nopCommerce 的[官方网站][6]下载源代码包,然后进行自定义配置和部署;也可以直接下载完整的软件包快速安装到 web 服务器上。详细信息可以查阅 nopCommerce 的 [GitHub 页面][7]或官方网站。 + +- [nopCommerce][8] + +#### 2、OpenCart + +![][9] + +OpenCart 是一个基于 PHP 的非常流行的电商解决方案,就我个人而言,我曾为一个项目用过它,并且体验非常好,如果不是最好的话。 + +或许你会觉得它维护得不是很频繁,但实际上使用 OpenCart 的开发者并不在少数。你可以获得许多受支持的扩展并将它们的功能加入到 OpenCart 中。 + +OpenCart 不一定是适合所有人的“现代”电商解决方案,但如果你需要的只是一个基于 PHP 的开源解决方案,OpenCart 是个值得一试的选择。在大多数具有一键式应用程序安装支持的网络托管平台中,应该可以安装 OpenCart。想要了解更多,可以查阅 OpenCart 的官方网站或 [GitHub 页面][10]。 + +- [OpenCart][11] + +#### 3、PrestaShop + +![][12] + +PrestaShop 也是一个可以尝试的开源电商解决方案。 + +PrestaShop 是一个积极维护下的开源解决方案,它的官方商店中也有额外提供主题和扩展。与 OpenCart 不同,在托管服务平台上,你可能找不到一键安装的 PrestaShop。但不需要担心,从官方网站下载下来之后,它的部署过程也并不复杂。如果你需要帮助,也可以参考 PrestaShop 的[安装指南][15]。 + +PrestaShop 的特点就是配置丰富和易于使用,我发现很多其它用户也在用它,你也不妨试用一下。 + +你也可以在 PrestaShop 的 [GitHub 页面][16]查阅到更多相关内容。 + +- [PrestaShop][17] + +#### 4、WooCommerce + +![][18] + +如果你想用 [WordPress][19] 来搭建电商站点,不妨使用 WooCommerce。 + +从技术上来说,这种方式其实是搭建一个 WordPress 应用,然后把 WooCommerce 作为一个插件或扩展以实现电商站点所需要的功能。很多 web 开发者都知道如何使用 WordPress,因此 WooCommerce 的学习成本不会很高。 + +WordPress 作为目前最好的开源站点项目之一,对大部分人来说都不会有太高的门槛。它具有易用、稳定的特点,同时还支持大量的扩展插件。 + +WooCommerce 的灵活性也是一大亮点,在它的线上商店提供了许多设计和扩展可供选择。你也可以到它的 [GitHub 页面][20]查看相关介绍。 + +- [WooCommerce][21] + +#### 5、Zen Cart + +![][22] + +这或许是一个稍显古老的电商解决方案,但同时也是最好的开源解决方案之一。如果你喜欢老式风格的模板(主要基于 HTML),而且只需要一些基础性的扩展,那你也可以尝试使用 Zen Cart。 + +就我个人而言,我不建议把 Zen Cart 用在一个新项目当中。但考虑到它仍然是一个活跃更新中的解决方案,如果你喜欢的话,也不妨用它来进行试验。 + +你也可以在 [SourceForge][23] 找到 Zen Cart 这个项目。 + +- [Zen Cart][24] + +#### 6、Magento + +![Image Credits: Magestore][25] + +Magento 是 Abode 旗下的开源电商解决方案,从某种角度来说,可能比 WordPress 表现得更为优秀。 + +Magento 完全是作为电商应用程序而生的,因此你会发现它的很多基础功能都非常好用,甚至还提供了高级的定制。 + +但如果你使用的是 Magento 的开源版,可能会接触不到托管版的一些高级功能,两个版本的差异,可以在[官方文档][26]中查看到。如果你使用托管版,还可以选择相关的托管支持服务。 + +想要了解更多,可以查看 Magento 的 [GitHub 页面][27]。 + +- [Magento][28] + +#### 7、Drupal + +![Drupal][29] + +Drupal 是一个适用于创建电商站点的开源 CMS 解决方案。 + +我没有使用过 Drupal,因此我不太确定它用起来是否足够灵活。但从它的官方网站上来看,它提供的扩展模块和主题列表,足以让你轻松完成一个电商站点需要做的任何事情。 + +跟 WordPress 类似,Drupal 在服务器上的部署并不复杂,不妨看看它的使用效果。在它的[下载页面][30]可以查看这个项目以及下载最新的版本。 + +- [Drupal][31] + +#### 8、Odoo eCommerce + +![Odoo Ecommerce Platform][32] + +如果你还不知道,Odoo 提供了一套开源商务应用程序。他们还提供了[开源会计软件][33]和 CRM 解决方案,我们将会在单独的列表中进行介绍。 + +对于电子商务门户,你可以根据需要使用其在线拖放生成器自定义网站。你也可以推广该网站。除了简单的主题安装和自定义选项之外,你还可以利用 HTML/CSS 在一定程度上手动自定义外观。 + +你也可以查看其 [GitHub][34] 页面以进一步了解它。 + +- [Odoo eCommerce][35] + +### 总结 + +我敢肯定还有更多的开源电子商务平台,但是,我现在还没有遇到比我上面列出的更好的东西。 + +如果你还有其它值得一提的产品,可以在评论区发表。也欢迎在评论区分享你对开源电商解决方案的经验和想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/open-source-ecommerce/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/open-source-cms/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/open-source-eCommerce.png?ssl=1 +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/nopCommerce.png?ssl=1 +[4]: https://en.wikipedia.org/wiki/ASP.NET_Core +[5]: https://www.nopcommerce.com/marketplace +[6]: https://www.nopcommerce.com/download-nopcommerce +[7]: https://github.com/nopSolutions/nopCommerce +[8]: https://www.nopcommerce.com/ +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/opencart.jpg?ssl=1 +[10]: https://github.com/opencart/opencart +[11]: https://www.opencart.com/ +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/01/prestashop.jpg?ssl=1 +[13]: https://addons.prestashop.com/en/3-templates-prestashop +[14]: https://addons.prestashop.com/en/ +[15]: http://doc.prestashop.com/display/PS17/Installing+PrestaShop +[16]: https://github.com/PrestaShop/PrestaShop +[17]: https://www.prestashop.com/en +[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/01/woocommerce.jpg?ssl=1 +[19]: https://wordpress.org/ +[20]: https://github.com/woocommerce/woocommerce +[21]: https://woocommerce.com/ +[22]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/Zen-cart.jpg?ssl=1 +[23]: https://sourceforge.net/projects/zencart/ +[24]: https://www.zen-cart.com/ +[25]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/magento.jpg?ssl=1 +[26]: https://magento.com/compare-open-source-and-magento-commerce +[27]: https://github.com/magento +[28]: https://magento.com/ +[29]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/drupal.png?ssl=1 +[30]: https://www.drupal.org/project/drupal +[31]: https://www.drupal.org/industries/ecommerce +[32]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/odoo-ecommerce-platform.jpg?w=800&ssl=1 +[33]: https://itsfoss.com/open-source-accounting-software/ +[34]: https://github.com/odoo/odoo +[35]: https://www.odoo.com/page/open-source-ecommerce diff --git a/published/202002/20200207 Connect Fedora to your Android phone with GSConnect.md b/published/202002/20200207 Connect Fedora to your Android phone with GSConnect.md new file mode 100644 index 0000000000..80a2884a6f --- /dev/null +++ b/published/202002/20200207 Connect Fedora to your Android phone with GSConnect.md @@ -0,0 +1,112 @@ +[#]: collector: (lujun9972) +[#]: translator: (chai-yuan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11897-1.html) +[#]: subject: (Connect Fedora to your Android phone with GSConnect) +[#]: via: (https://fedoramagazine.org/connect-fedora-to-your-android-phone-with-gsconnect/) +[#]: author: (Lokesh Krishna https://fedoramagazine.org/author/lowkeyskywalker/) + +使用 GSConnect 将 Android 手机连接到 Fedora 系统 +====== + +![][1] + +苹果和微软公司都不同程度的提供了桌面产品与移动设备集成。Fedora 提供了类似甚至更高集成度的工具——GSConnect。它可以让你将安卓手机和你的 Fedora 桌面配对并使用。请继续阅读,以了解更多关于它的情况以及它是如何工作的信息。 + +### GSConnect 是什么? + +GSConnect 是针对 GNOME 桌面定制的 KDE Connect 程序。KDE Connect 可以使你的设备能够互相通信。但是,在 Fedora 默认的 GNOME 桌面上安装它需要安装大量的 KDE 依赖。 + +GSConnect 是一个 KDE Connect 的完整实现,其以 GNOME shell 的拓展形式出现。安装后,GSConnect 允许你执行以下操作及更多: + +* 在计算机上接收电话通知并回复信息 +* 用手机操纵你的桌面 +* 在不同设备之间分享文件与链接 +* 在计算机上查看手机电量 +* 让手机响铃以便你能找到它 + +### 设置 GSConnect 扩展 + +设置 GSConnect 需要安装两个组件:计算机上的 GSConnect 扩展和 Android 设备上的 KDE Connect 应用。 + +首先,从 GNOME Shell 扩展网站上安装 [GSConnect][2] 扩展。(Fedora Magazine 有一篇关于[如何安装 GNOME Shell 扩展][3]的文章,可以帮助你完成这一步。) + +KDE Connect 应用程序可以在 Google 的 [Play 商店][4]上找到。它也可以在 FOSS Android 应用程序库 [F-Droid][5] 上找到。 + +一旦安装了这两个组件,就可以配对两个设备。安装扩展后它在你的系统菜单中显示为“移动设备Mobile Devices”。单击它会出现一个下拉菜单,你可以从中访问“移动设置Mobile Settings”。 + +![][6] + +你可以在这里用 GSConnect 查看并管理已配对的设备。进入此界面后,需要在 Android 设备上启动应用程序。 + +你可以在任意一台设备上进行配对初始化,在这里我们从 Android 设备连接到计算机。点击应用程序上的“刷新”,只要两个设备都在同一个无线网络环境中,你的 Android 设备便可以搜索到你的计算机。现在可以向桌面发送配对请求,并在桌面上接受配对请求以完成配对。 + +![][7] + +### 使用 GSConnect + +配对后,你将需要在 Android 设备授予权限,才能使用 GSConnect 上提供的许多功能。单击设备列表中的已配对设备,便可以查看所有可用功能,并根据你的偏好和需要启用或禁用它们。 + +![][8] + +请记住,你还需要在这个 Android 应用程序中授予相应的权限才能使用这些功能。启用权限后,你现在可以访问桌面上的移动联系人,获得消息通知并回复消息,甚至同步桌面和 Android 设备的剪贴板。 + +### 将你的浏览器与“文件”应用集成 + +GSConnect 允许你直接从计算机上的文件资源管理器的关联菜单向 Android 设备发送文件。 + +在 Fedora 的默认 GNOME 桌面上,你需要安装 `nautilus-python` 依赖包,以便在关联菜单中显示配对的设备。安装此命令非常简单,只需要在你的首选终端运行以下命令: + +``` +$ sudo dnf install nautilus-python +``` + +完成后,将在“文件Files”应用的关联菜单中显示“发送到移动设备Send to Mobile Device”选项。 + +![][9] + +同样,为你的浏览器安装相应的 WebExtension,无论是 [Firefox][10] 还是 [Chrome][11] 浏览器,都可以将链接发送到你的 Android 设备。你可以选择直接发送链接以在浏览器中直接打开,或将其作为短信息发送。 + +### 运行命令 + +GSConnect 允许你定义命令,然后可以从远程设备在计算机上运行这些命令。这使得你可以远程截屏,或者从你的 Android 设备锁定和解锁你的桌面。 + +![][12] + +要使用此功能,可以使用标准的 shell 命令和 GSConnect 提供的 CLI。该项目的 GitHub 存储库(CLI Scripting)中提供了有关此操作的文档。 + +[KDE UserBase Wiki][13] 有一个命令示例列表。这些例子包括控制桌面的亮度和音量、锁定鼠标和键盘,甚至更改桌面主题。其中一些命令是针对 KDE Plasma 设计的,需要进行修改才能在 GNOME 桌面上运行。 + +### 探索并享受乐趣 + +GSConnect 使我们能够享受到极大的便利和舒适。深入研究首选项,查看你可以做的所有事情,灵活的使用这些命令功能发挥创意,并在下面的评论中自由分享你解锁的新方式。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/connect-fedora-to-your-android-phone-with-gsconnect/ + +作者:[Lokesh Krishna][a] +选题:[lujun9972][b] +译者:[chai-yuan](https://github.com/chai-yuan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/lowkeyskywalker/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/12/gsconnect-816x345.jpg +[2]: https://extensions.gnome.org/extension/1319/gsconnect/ +[3]: https://fedoramagazine.org/install-gnome-shell-extension/ +[4]: https://play.google.com/store/apps/details?id=org.kde.kdeconnect_tp +[5]: https://f-droid.org/en/packages/org.kde.kdeconnect_tp/ +[6]: https://fedoramagazine.org/wp-content/uploads/2020/01/within-the-menu-1024x576.png +[7]: https://fedoramagazine.org/wp-content/uploads/2020/01/pair-request-1024x576.png +[8]: https://fedoramagazine.org/wp-content/uploads/2020/01/permissions-1024x576.png +[9]: https://fedoramagazine.org/wp-content/uploads/2020/01/send-to-mobile-2-1024x576.png +[10]: https://addons.mozilla.org/en-US/firefox/addon/gsconnect/ +[11]: https://chrome.google.com/webstore/detail/gsconnect/jfnifeihccihocjbfcfhicmmgpjicaec +[12]: https://fedoramagazine.org/wp-content/uploads/2020/01/commands-1024x576.png +[13]: https://userbase.kde.org/KDE_Connect/Tutorials/Useful_commands +[14]: https://unsplash.com/@pathum_danthanarayana?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[15]: https://unsplash.com/s/photos/android?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/published/202002/20200207 Customize your internet with an open source search engine.md b/published/202002/20200207 Customize your internet with an open source search engine.md new file mode 100644 index 0000000000..ed102d2f0e --- /dev/null +++ b/published/202002/20200207 Customize your internet with an open source search engine.md @@ -0,0 +1,118 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11905-1.html) +[#]: subject: (Customize your internet with an open source search engine) +[#]: via: (https://opensource.com/article/20/2/open-source-search-engine) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +用开源搜索引擎定制你的互联网 +====== + +> 上手开源的对等 Web 索引器 YaCy。 + +![](https://img.linux.net.cn/data/attachment/album/202002/19/103541la7erglz7oloa4ye.jpg) + +很久以前,互联网很小,小到几个人就可以索引它们,这些人收集了所有网站的名称和链接,并按主题将它们分别列在页面或印刷书籍中。随着万维网网络的发展,形成了“网站环”形式,具有类似的内容、主题或敏感性的站点捆绑在一起,形成了通往每个成员的循环路径。环中任何站点的访问者都可以单击按钮以转到环中的下一个或上一个站点,以发现与其兴趣相关的新站点。 + +又过了一段时间,互联网似乎变得臃肿不堪了。每个人都在网络上,有很多冗余信息和垃圾邮件,多到让你无法找到任何东西。Yahoo 和 AOL、CompuServe 以及类似的服务各自采用了不同的方法来解决这个问题,但是直到谷歌出现后,现代的搜索模型才得以普及。按谷歌的做法,互联网应该通过搜索引擎进行索引、排序和排名。 + +### 为什么选择开源替代品? + +像谷歌和 DuckDuckGo 这样的搜索引擎显然是卓有成效的。你可能是通过搜索引擎访问的本站。尽管对于因主机没有选择遵循优化搜索引擎的最佳实践从而导致会内容陷入困境这件事仍存在争论,但用于管理丰富的文化、知识和轻率的信息(即互联网)的现代解决方案是冷冰冰的索引。 + +但是也许出于隐私方面的考虑,或者你希望为使互联网更加独立而做出贡献,你或许不愿意使用谷歌或 DuckDuckGo。如果你对此感兴趣,那么可以考虑参加 [YaCy][2],这是一个对等互联网索引器和搜索引擎。 + +### 安装 YaCy + +要安装并尝试 YaCy,请首先确保已安装 Java。如果你使用的是 Linux,则可以按照我的《[如何在 Linux 上安装 Java][3]》中的说明进行操作。如果你使用 Windows 或 MacOS,请从 [AdoptOpenJDK.net][4] 获取安装程序。 + +安装 Java 后,请根据你的平台[下载安装程序][5]。 + +如果你使用的是 Linux,请解压缩 tarball 并将其移至 `/opt` 目录: + +``` +$ sudo tar --extract --file  yacy_*z --directory /opt +``` + +根据下载的安装程序的说明启动 YaCy。 + +在 Linux 上,启动在后台运行的 YaCy: + +``` +$ /opt/startYACY.sh & +``` + +在 Web 浏览器中,导航到 `localhost:8090` 并进行搜索。 + +![YaCy start page][6] + +### 将 YaCy 添加到你的地址栏 + +如果你使用的是 Firefox Web 浏览器,则只需单击几下,即可在 Awesome Bar(Mozilla 给 URL 栏起的名称)中将 YaCy 设置为默认搜索引擎。 + +首先,如果尚未显示,在 Firefox 工具栏中使专用搜索栏显示出来(你不必使搜索栏保持一直可见;只需要激活它足够长的时间即可添加自定义搜索引擎)。Firefox 右上角的“汉堡”菜单中的“自定义”菜单中提供了搜索栏。在 Firefox 工具栏上的搜索栏可见后,导航至 `localhost:8090`,然后单击刚添加的 Firefox 搜索栏中的放大镜图标。单击选项将 YaCy 添加到你的 Firefox 的搜索引擎中。 + +![Adding YaCy to Firefox][7] + +完成此操作后,你可以在 Firefox 首选项中将其标记为默认值,或者仅在 Firefox 搜索栏中执行的搜索中选择性地使用它。如果将其设置为默认搜索引擎,则可能不需要专用搜索栏,因为 Awesome Bar 也使用默认引擎,因此可以将其从工具栏中删除。 + +### 对等搜索引擎如何工作 + +YaCy 是一个开源的分布式搜索引擎。它是用 [Java][8] 编写的,因此可以在任何平台上运行,并且可以执行 Web 爬网、索引和搜索。这是一个对等(P2P)网络,因此每个运行 YaCy 的用户都将努力地不断跟踪互联网的变化情况。当然,没有单个用户能拥有整个互联网的完整索引,因为这将需要一个数据中心来容纳,但是该索引分布在所有 YaCy 用户中且是冗余的。它与 BitTorrent 非常相似(因为它使用分布式哈希表 DHT 来引用索引条目),只不过你所共享的数据是单词和 URL 关联的矩阵。通过混合哈希表返回的结果,没人能说出谁搜索了哪些单词,因此所有搜索在功能上都是匿名的。这是用于无偏见、无广告、未跟踪和匿名搜索的有效系统,你只需要使用它就加入了它。 + +### 搜索引擎和算法 + +索引互联网的行为是指将网页分成单个单词,然后将页面的 URL 与每个单词相关联。在搜索引擎中搜索一个或多个单词将获取与该查询关联的所有 URL。YaCy 客户端在运行时也是如此。 + +客户端要做的另一件事是为你的浏览器提供搜索界面。你可以将 Web 浏览器指向 `localhost:8090` 来搜索 YaCy,而不是在要搜索时导航到谷歌。你甚至可以将其添加到浏览器的搜索栏中(取决于浏览器的可扩展性),因此可以从 URL 栏中进行搜索。 + +### YaCy 的防火墙设置 + +首次开始使用 YaCy 时,它可能运行在“初级”模式下。这意味着你的客户端爬网的站点仅对你可用,因为其他 YaCy 客户端无法访问你的索引条目。要加入对等环境,必须在路由器的防火墙(或者你正在运行的软件防火墙)中打开端口 8090,这称为“高级”模式。 + +如果你使用的是 Linux,则可以在《[使用防火墙让你的 Linux 更加强大][9]》中找到有关计算机防火墙的更多信息。在其他平台上,请参考操作系统的文档。 + +互联网服务提供商(ISP)提供的路由器上几乎总是启用了防火墙,并且有太多种类的防火墙无法准确说明。大多数路由器都提供了在防火墙上“打洞”的选项,因为许多流行的联网游戏都需要双向流量。 + +如果你知道如何登录路由器(通常为 192.168.0.1 或 10.1.0.1,但可能因制造商的设置而异),则登录并查找配置面板来控制“防火墙”或“端口转发”或“应用”。 + +找到路由器防火墙的首选项后,将端口 8090 添加到白名单。例如: + +![Adding YaCy to an ISP router][10] + +如果路由器正在进行端口转发,则必须使用相同的端口将传入的流量转发到计算机的 IP 地址。例如: + +![Adding YaCy to an ISP router][11] + +如果由于某种原因无法调整防火墙设置,那也没事。YaCy 将继续以初级模式运行并作为对等搜索网络的客户端运行。 + +### 你的互联网 + +使用 YaCy 搜索引擎可以做的不仅仅是被动搜索。你可以强制抓取不太显眼的网站,可以请求对网站进行网络抓取,可以选择使用 YaCy 进行本地搜索等等。你可以更好地控制*你的*互联网的所呈现的一切。高级用户越多,索引的网站就越多。索引的网站越多,所有用户的体验就越好。加入吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/open-source-search-engine + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/laptop_screen_desk_work_chat_text.png?itok=UXqIDRDD (Person using a laptop) +[2]: https://yacy.net/ +[3]: https://linux.cn/article-11614-1.html +[4]: https://adoptopenjdk.net/releases.html +[5]: https://yacy.net/download_installation/ +[6]: https://opensource.com/sites/default/files/uploads/yacy-startpage.jpg (YaCy start page) +[7]: https://opensource.com/sites/default/files/uploads/yacy-add-firefox.jpg (Adding YaCy to Firefox) +[8]: https://opensource.com/resources/java +[9]: https://opensource.com/article/19/7/make-linux-stronger-firewalls +[10]: https://opensource.com/sites/default/files/uploads/router-add-app.jpg (Adding YaCy to an ISP router) +[11]: https://opensource.com/sites/default/files/uploads/router-add-app1.jpg (Adding YaCy to an ISP router) diff --git a/published/202002/20200207 NVIDIA-s Cloud Gaming Service GeForce NOW Shamelessly Ignores Linux.md b/published/202002/20200207 NVIDIA-s Cloud Gaming Service GeForce NOW Shamelessly Ignores Linux.md new file mode 100644 index 0000000000..4a6e9f660f --- /dev/null +++ b/published/202002/20200207 NVIDIA-s Cloud Gaming Service GeForce NOW Shamelessly Ignores Linux.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11888-1.html) +[#]: subject: (NVIDIA’s Cloud Gaming Service GeForce NOW Shamelessly Ignores Linux) +[#]: via: (https://itsfoss.com/geforce-now-linux/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +NVIDIA 的云游戏服务 GeForce NOW 无耻地忽略了Linux +====== + +NVIDIA 的 [GeForce NOW][1] 云游戏服务对于那些可能没有硬件但想使用 GeForce NOW 在最新的最好的游戏上获得尽可能好的游戏体验玩家来说是充满前景的(在线推流游戏,并可以在任何设备上玩)。 + +该服务仅限于一些用户(以等待列表的形式)使用。然而,他们最近宣布 [GeForce NOW 面向所有人开放][2]。但实际上并不是。 + +有趣的是,它**并不是面向全球所有区域**。而且,更糟的是 **GeForce NOW 不支持 Linux**。 + +![][3] + +### GeForce NOW 并不是向“所有人开放” + +制作一个基于订阅的云服务来玩游戏的目的是消除平台依赖性。 + +就像你通常使用浏览器访问网站一样,你应该能够在每个平台上玩游戏。是这个概念吧? + +![][4] + +好吧,这绝对不是火箭科学,但是 NVIDIA 仍然不支持 Linux(和 iOS)? + +### 是因为没有人使用 Linux 吗? + +我非常不同意这一点,即使这是某些不支持 Linux 的原因。如果真是这样,我不会使用 Linux 作为主要桌面操作系统来为 “It’s FOSS” 写文章。 + +不仅如此,如果 Linux 不值一提,你认为为何一个 Twitter 用户会提到缺少 Linux 支持? + +![][5] + +是的,也许用户群不够大,但是在考虑将其作为基于云的服务时,**不支持 Linux** 显得没有意义。 + +从技术上讲,如果 Linux 上没有游戏,那么 **Valve** 就不会在 Linux 上改进 [Steam Play][6] 来帮助更多用户在 Linux 上玩纯 Windows 的游戏。 + +我不想说任何不正确的说法,但台式机 Linux 游戏的发展比以往任何时候都要快(即使统计上要比 Mac 和 Windows 要低)。 + +### 云游戏不应该像这样 + +![][7] + +如上所述,找到使用 Steam Play 的 Linux 玩家不难。只是你会发现 Linux 上游戏玩家的整体“市场份额”低于其他平台。 + +即使这是事实,云游戏也不应该依赖于特定平台。而且,考虑到 GeForce NOW 本质上是一种基于浏览器的可以玩游戏的流媒体服务,所以对于像 NVIDIA 这样的大公司来说,支持 Linux 并不困难。 + +来吧,Nvidia,*你想要我们相信在技术上支持 Linux 有困难?或者,你只是想说不值得支持 Linux 平台?* + +### 结语 + +不管我为 GeForce NOW 服务发布而感到多么兴奋,当看到它根本不支持 Linux,我感到非常失望。 + +如果像 GeForce NOW 这样的云游戏服务在不久的将来开始支持 Linux,**你可能没有理由使用 Windows 了**(*咳嗽*)。 + +你怎么看待这件事?在下面的评论中让我知道你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/geforce-now-linux/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://www.nvidia.com/en-us/geforce-now/ +[2]: https://blogs.nvidia.com/blog/2020/02/04/geforce-now-pc-gaming/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/nvidia-geforce-now-linux.jpg?ssl=1 +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/nvidia-geforce-now.png?ssl=1 +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/geforce-now-twitter-1.jpg?ssl=1 +[6]: https://itsfoss.com/steam-play/ +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/ge-force-now.jpg?ssl=1 diff --git a/published/202002/20200207 What is WireGuard- Why Linux Users Going Crazy Over it.md b/published/202002/20200207 What is WireGuard- Why Linux Users Going Crazy Over it.md new file mode 100644 index 0000000000..56b1584ee1 --- /dev/null +++ b/published/202002/20200207 What is WireGuard- Why Linux Users Going Crazy Over it.md @@ -0,0 +1,98 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11916-1.html) +[#]: subject: (What is WireGuard? Why Linux Users Going Crazy Over it?) +[#]: via: (https://itsfoss.com/wireguard/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +什么是 WireGuard?为什么 Linux 用户为它疯狂? +====== + +从普通的 Linux 用户到 Linux 创建者 [Linus Torvalds][1],每个人都对 WireGuard 很感兴趣。什么是 WireGuard,它为何如此特别? + +### 什么是 WireGuard? + +![][2] + +[WireGuard][3] 是一个易于配置、快速且安全的开源 [VPN][4],它利用了最新的加密技术。目的是提供一种更快、更简单、更精简的通用 VPN,它可以轻松地在树莓派这类低端设备到高端服务器上部署。 + +[IPsec][5] 和 OpenVPN 等大多数其他解决方案是几十年前开发的。安全研究人员和内核开发人员 Jason Donenfeld 意识到它们速度慢且难以正确配置和管理。 + +这让他创建了一个新的开源 VPN 协议和解决方案,它更加快速、安全、易于部署和管理。 + +WireGuard 最初是为 Linux 开发的,但现在可用于 Windows、macOS、BSD、iOS 和 Android。它仍在活跃开发中。 + +### 为什么 WireGuard 如此受欢迎? + +![][6] + +除了可以跨平台之外,WireGuard 的最大优点之一就是易于部署。配置和部署 WireGuard 就像配置和使用 SSH 一样容易。 + +看看 [WireGuard 设置指南][7]。安装 WireGuard、生成公钥和私钥(像 SSH 一样),设置防火墙规则并启动服务。现在将它和 [OpenVPN 设置指南][8]进行比较——有太多要做的了。 + +WireGuard 的另一个好处是它有一个仅 4000 行代码的精简代码库。将它与 [OpenVPN][9](另一个流行的开源 VPN)的 100,000 行代码相比。显然,调试 WireGuard 更加容易。 + +不要因其简单而小看它。WireGuard 支持所有最新的加密技术,例如 [Noise 协议框架][10]、[Curve25519][11]、[ChaCha20][12]、[Poly1305][13]、[BLAKE2][14]、[SipHash24][15]、[HKDF][16] 和安全受信任结构。 + +由于 WireGuard 运行在[内核空间][17],因此可以高速提供安全的网络。 + +这些是 WireGuard 越来越受欢迎的一些原因。Linux 创造者 Linus Torvalds 非常喜欢 WireGuard,以至于将其合并到 [Linux Kernel 5.6][18] 中: + +> 我能否再次声明对它的爱,并希望它能很快合并?也许代码不是完美的,但我不在乎,与 OpenVPN 和 IPSec 的恐怖相比,这是一件艺术品。 +> +> Linus Torvalds + +### 如果 WireGuard 已经可用,那么将其包含在 Linux 内核中有什么大惊小怪的? + +这可能会让新的 Linux 用户感到困惑。你知道可以在 Linux 上安装和配置 WireGuard VPN 服务器,但同时也会看到 Linux Kernel 5.6 将包含 WireGuard 的消息。让我向您解释。 + +目前,你可以将 WireGuard 作为[内核模块][19]安装在 Linux 中。而诸如 VLC、GIMP 等常规应用安装在 Linux 内核之上(在 [用户空间][20]中),而不是内部。 + +当将 WireGuard 安装为内核模块时,基本上需要你自行修改 Linux 内核并向其添加代码。从 5.6 内核开始,你无需手动添加内核模块。默认情况下它将包含在内核中。 + +在 5.6 内核中包含 WireGuard 很有可能[扩展 WireGuard 的采用,从而改变当前的 VPN 场景][21]。 + +### 总结 + +WireGuard 之所以受欢迎是有充分理由的。诸如 [Mullvad VPN][23] 之类的一些流行的[关注隐私的 VPN][22] 已经在使用 WireGuard,并且在不久的将来,采用率可能还会增长。 + +希望你对 WireGuard 有所了解。与往常一样,欢迎提供反馈。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/wireguard/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/linus-torvalds-facts/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/wireguard.png?ssl=1 +[3]: https://www.wireguard.com/ +[4]: https://en.wikipedia.org/wiki/Virtual_private_network +[5]: https://en.wikipedia.org/wiki/IPsec +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/wireguard-logo.png?ssl=1 +[7]: https://www.linode.com/docs/networking/vpn/set-up-wireguard-vpn-on-ubuntu/ +[8]: https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-16-04 +[9]: https://openvpn.net/ +[10]: https://noiseprotocol.org/ +[11]: https://cr.yp.to/ecdh.html +[12]: https://cr.yp.to/chacha.html +[13]: https://cr.yp.to/mac.html +[14]: https://blake2.net/ +[15]: https://131002.net/siphash/ +[16]: https://eprint.iacr.org/2010/264 +[17]: http://www.linfo.org/kernel_space.html +[18]: https://itsfoss.com/linux-kernel-5-6/ +[19]: https://wiki.archlinux.org/index.php/Kernel_module +[20]: http://www.linfo.org/user_space.html +[21]: https://www.zdnet.com/article/vpns-will-change-forever-with-the-arrival-of-wireguard-into-linux/ +[22]: https://itsfoss.com/best-vpn-linux/ +[23]: https://mullvad.net/en/ diff --git a/published/202002/20200210 Install All Essential Media Codecs in Ubuntu With This Single Command -Beginner-s Tip.md b/published/202002/20200210 Install All Essential Media Codecs in Ubuntu With This Single Command -Beginner-s Tip.md new file mode 100644 index 0000000000..5c6d5e90ea --- /dev/null +++ b/published/202002/20200210 Install All Essential Media Codecs in Ubuntu With This Single Command -Beginner-s Tip.md @@ -0,0 +1,114 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11906-1.html) +[#]: subject: (Install All Essential Media Codecs in Ubuntu With This Single Command [Beginner’s Tip]) +[#]: via: (https://itsfoss.com/install-media-codecs-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +一条命令在 Ubuntu 中安装所有基本的媒体编解码器 +====== + +如果你刚刚安装了 Ubuntu 或其他 [Ubuntu 特色版本][1] 如 Kubuntu、Lubuntu 等,你会注意到系统无法播放某些音频或视频文件。 + +对于视频文件,你可以[在 Ubuntu 上安装 VLC][2]。[VLC][3] 是 [Linux 上的最佳视频播放器][4]之一,它几乎可以播放任何视频文件格式。但你仍然会遇到无法播放音频和 flash 的麻烦。 + +好消息是 [Ubuntu][5] 提供了一个软件包来安装所有基本的媒体编解码器:ubuntu-restricted-extras。 + +![][6] + +### 什么是 Ubuntu Restricted Extras? + +ubuntu-restricted-extras 是一个包含各种基本软件,如 Flash 插件、[unrar][7]、[gstreamer][8]、mp4、[Ubuntu 中的 Chromium 浏览器][9]的编解码器等的软件包。 + +由于这些软件不是开源软件,并且其中一些涉及软件专利,因此 Ubuntu 默认情况下不会安装它们。你必须使用 multiverse 仓库,它是 Ubuntu 专门为用户提供非开源软件而创建的仓库。 + +请阅读本文以[了解有关各种 Ubuntu 仓库的更多信息][10]。 + +### 如何安装 Ubuntu Restricted Extras? + +令我惊讶的是,我发现软件中心未列出 Ubuntu Restricted Extras。不管怎样,你都可以使用命令行安装该软件包,这非常简单。 + +在菜单中搜索或使用[终端键盘快捷键 Ctrl+Alt+T][11] 打开终端。 + +由于 ubuntu-restrcited-extras 软件包在 multiverse 仓库中,因此你应验证系统上已启用 multiverse 仓库: + +``` +sudo add-apt-repository multiverse +``` + +然后你可以使用以下命令安装: + +``` +sudo apt install ubuntu-restricted-extras +``` + +输入回车后,你会被要求输入密码,**当你输入密码时,屏幕不会有显示**。这是正常的。输入你的密码并回车。 + +它将显示大量要安装的包。按回车确认选择。 + +你会看到 [EULA][12](最终用户许可协议),如下所示: + +![Press Tab key to select OK and press Enter key][13] + +浏览此页面可能会很麻烦,但是请放心。只需按 Tab 键,它将高亮选项。当高亮在正确的选项上,按下回车确认你的选择。 + +![Press Tab key to highlight Yes and press Enter key][14] + +安装完成后,由于新安装的媒体编解码器,你应该可以播放 MP3 和其他媒体格式了。 + +##### 在 Kubuntu、Lubuntu、Xubuntu 上安装受限制的额外软件包 + +请记住,Kubuntu、Lubuntu 和 Xubuntu 都有此软件包,并有各自不同的名称。它们本应使用相同的名字,但不幸的是并不是。 + +在 Kubuntu 上,使用以下命令: + +``` +sudo apt install kubuntu-restricted-extras +``` + +在 Lubuntu 上,使用: + +``` +sudo apt install lubuntu-restricted-extras +``` + +在 Xubuntu 上,你应该使用: + +``` +sudo apt install xubuntu-restricted-extras +``` + +我一直建议将 ubuntu-restricted-extras 作为[安装 Ubuntu 后要做的基本事情][15]之一。只需一个命令即可在 Ubuntu 中安装多个编解码器。 + +希望你喜欢 Ubuntu 初学者系列中这一技巧。以后,我将分享更多此类技巧。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-media-codecs-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/which-ubuntu-install/ +[2]: https://itsfoss.com/install-latest-vlc/ +[3]: https://www.videolan.org/index.html +[4]: https://itsfoss.com/video-players-linux/ +[5]: https://ubuntu.com/ +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/Media_Codecs_in_Ubuntu.png?ssl=1 +[7]: https://itsfoss.com/use-rar-ubuntu-linux/ +[8]: https://gstreamer.freedesktop.org/ +[9]: https://itsfoss.com/install-chromium-ubuntu/ +[10]: https://itsfoss.com/ubuntu-repositories/ +[11]: https://itsfoss.com/ubuntu-shortcuts/ +[12]: https://en.wikipedia.org/wiki/End-user_license_agreement +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/installing_ubuntu_restricted_extras.jpg?ssl=1 +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/installing_ubuntu_restricted_extras_1.jpg?ssl=1 +[15]: https://itsfoss.com/things-to-do-after-installing-ubuntu-18-04/ diff --git a/published/202002/20200210 Playing Music on your Fedora Terminal with MPD and ncmpcpp.md b/published/202002/20200210 Playing Music on your Fedora Terminal with MPD and ncmpcpp.md new file mode 100644 index 0000000000..b78452578b --- /dev/null +++ b/published/202002/20200210 Playing Music on your Fedora Terminal with MPD and ncmpcpp.md @@ -0,0 +1,118 @@ +[#]: collector: (lujun9972) +[#]: translator: (chai-yuan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11909-1.html) +[#]: subject: (Playing Music on your Fedora Terminal with MPD and ncmpcpp) +[#]: via: (https://fedoramagazine.org/playing-music-on-your-fedora-terminal-with-mpd-and-ncmpcpp/) +[#]: author: (Carmine Zaccagnino https://fedoramagazine.org/author/carzacc/) + +在你的 Fedora 终端上播放音乐 +====== + +![][1] + +MPD(Music Playing Daemon),顾名思义,是一个音乐(Music)播放(Playing)守护进程(Daemon)。它可以播放音乐,并且作为一个守护进程,任何软件都可以与之交互并播放声音,包括一些 CLI 客户端。 + +其中一个被称为 `ncmpcpp`,它是对之前 `ncmpc` 工具的改进。名字的变化与编写它们的语言没有太大关系:都是 C++,而之所以被称为 `ncmpcpp`,因为它是 “NCurses Music Playing Client Plus Plus”。 缘故 + +### 安装 MPD 和 ncmpcpp + +`ncmpmpcc` 的客户端可以从官方 Fedora 库中通过 `dnf` 命令直接安装。 + +``` +$ sudo dnf install ncmpcpp +``` + +另一方面,MPD 必须从 RPMFusion free 库安装,你可以通过运行: + +``` +$ sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm +``` + +然后你可以运行下面的命令安装它: + +``` +$ sudo dnf install mpd +``` + +### 配置并启用 MPD + +设置 MPD 最简单的方法是以普通用户的身份运行它。默认情况是以专用 `mpd` 用户的身份运行它,但这会导致各种权限问题。 + +在运行它之前,我们需要创建一个本地配置文件,允许我们作为普通用户运行。 + +首先在 `~/.config` 里创建一个名叫 `mpd` 的目录: + +``` +$ mkdir ~/.config/mpd +``` + +将配置文件拷贝到此目录下: + +``` +$ cp /etc/mpd.conf ~/.config/mpd +``` + +然后用 `vim`、`nano` 或 `gedit` 之类的软件编辑它: + +``` +$ nano ~/.config/mpd/mpd.conf +``` + +我建议你通读所有内容,检查是否有任何需要做的事情,但对于大多数设置你都可以删除,只需保留以下内容: + +``` +db_file "~/.config/mpd/mpd.db" +log_file "syslog" +``` + +现在你可以运行它了: + +``` +$ mpd +``` + +没有报错,这将在后台启动 MPD 守护进程。 + +### 使用 ncmpcpp + +只需运行: + +``` +$ ncmpcpp +``` + +你将在终端中看到一个由 ncurses 所支持的图形用户界面。 + +按下 `4` 键,然后就可以看到本地的音乐目录,用方向键进行选择并按下回车进行播放。 + +多播放几个歌曲就会创建一个*播放列表*,让你可以使用 `>` 键(不是右箭头, 是右尖括号)移动到下一首,并使用 `<` 返回上一首。`+` 和 `–` 键可以调节音量。`Q` 键可以让你退出 `ncmpcpp` 但不停止播放音乐。你可以按下 `P` 来控制暂停和播放。 + +你可以按下 `1` 键来查看当前播放列表(这是默认的视图)。从这个视图中,你可以按 `i` 查看有关当前歌曲的信息(标签)。按 `6` 可更改当前歌曲的标签。 + +按 `\` 按钮将在视图顶部添加(或删除)信息面板。在左上角,你可以看到如下的内容: + +``` +[------] +``` + +按下 `r`、`z`、`y`、`R`、`x` 将会分别切换到 `repeat`、`random`、`single`、`consume` 和 `crossfade` 等播放模式,并将这个小指示器中的 `–` 字符替换为选定模式。 + +按下 `F1` 键将会显示一些帮助文档,包含一系列的键绑定列表,因此无需在此处列出完整列表。所以继续吧!做一个极客,在你的终端上播放音乐! + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/playing-music-on-your-fedora-terminal-with-mpd-and-ncmpcpp/ + +作者:[Carmine Zaccagnino][a] +选题:[lujun9972][b] +译者:[chai-yuan](https://github.com/chai-yuan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/carzacc/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/02/play_music_mpd-816x346.png +[2]: https://rpmfusion.org/Configuration diff --git a/published/202002/20200210 Scan Kubernetes for errors with KRAWL.md b/published/202002/20200210 Scan Kubernetes for errors with KRAWL.md new file mode 100644 index 0000000000..22fcd2a098 --- /dev/null +++ b/published/202002/20200210 Scan Kubernetes for errors with KRAWL.md @@ -0,0 +1,220 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11936-1.html) +[#]: subject: (Scan Kubernetes for errors with KRAWL) +[#]: via: (https://opensource.com/article/20/2/kubernetes-scanner) +[#]: author: (Abhishek Tamrakar https://opensource.com/users/tamrakar) + +使用 KRAWL 扫描 Kubernetes 错误 +====== + +> 用 KRAWL 脚本来识别 Kubernetes Pod 和容器中的错误。 + +![Ship captain sailing the Kubernetes seas][1] + +当你使用 Kubernetes 运行容器时,你通常会发现它们堆积在一起。这是设计使然。它是容器的优点之一:每当需要新的容器时,它们启动成本都很低。你可以使用前端工具(如 OpenShift 或 OKD)来管理 Pod 和容器。这些工具使可视化设置变得容易,并且它具有一组丰富的用于快速交互的命令。 + +如果管理容器的平台不符合你的要求,你也可以仅使用 Kubernetes 工具链获取这些信息,但这需要大量命令才能全面了解复杂环境。出于这个原因,我编写了 [KRAWL][2],这是一个简单的脚本,可用于扫描 Kubernetes 集群命名空间下的 Pod 和容器,并在发现任何事件时,显示事件的输出。它也可用作为 Kubernetes 插件使用。这是获取大量有用信息的快速简便方法。 + +### 先决条件 + + * 必须安装 `kubectl`。 + * 集群的 kubeconfig 配置必须在它的默认位置(`$HOME/.kube/config`)或已被导出到环境变量(`KUBECONFIG=/path/to/kubeconfig`)。 + +### 使用 + + +``` +$ ./krawl +``` + +![KRAWL script][3] + +### 脚本 + + +``` +#!/bin/bash +# AUTHOR: Abhishek Tamrakar +# EMAIL: abhishek.tamrakar08@gmail.com +# LICENSE: Copyright (C) 2018 Abhishek Tamrakar +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## +#define the variables +KUBE_LOC=~/.kube/config +#define variables +KUBECTL=$(which kubectl) +GET=$(which egrep) +AWK=$(which awk) +red=$(tput setaf 1) +normal=$(tput sgr0) +# define functions + +# wrapper for printing info messages +info() +{ + printf '\n\e[34m%s\e[m: %s\n' "INFO" "$@" +} + +# cleanup when all done +cleanup() +{ + rm -f results.csv +} + +# just check if the command we are about to call is available +checkcmd() +{ + #check if command exists + local cmd=$1 + if [ -z "${!cmd}" ] + then + printf '\n\e[31m%s\e[m: %s\n' "ERROR" "check if $1 is installed !!!" + exit 1 + fi +} + +get_namespaces() +{ + #get namespaces + namespaces=( \ + $($KUBECTL get namespaces --ignore-not-found=true | \ + $AWK '/Active/ {print $1}' \ + ORS=" ") \ + ) +#exit if namespaces are not found +if [ ${#namespaces[@]} -eq 0 ] +then + printf '\n\e[31m%s\e[m: %s\n' "ERROR" "No namespaces found!!" + exit 1 +fi +} + +#get events for pods in errored state +get_pod_events() +{ + printf '\n' + if [ ${#ERRORED[@]} -ne 0 ] + then + info "${#ERRORED[@]} errored pods found." + for CULPRIT in ${ERRORED[@]} + do + info "POD: $CULPRIT" + info + $KUBECTL get events \ + --field-selector=involvedObject.name=$CULPRIT \ + -ocustom-columns=LASTSEEN:.lastTimestamp,REASON:.reason,MESSAGE:.message \ + --all-namespaces \ + --ignore-not-found=true + done + else + info "0 pods with errored events found." + fi +} + +#define the logic +get_pod_errors() +{ + printf "%s %s %s\n" "NAMESPACE,POD_NAME,CONTAINER_NAME,ERRORS" > results.csv + printf "%s %s %s\n" "---------,--------,--------------,------" >> results.csv + for NAMESPACE in ${namespaces[@]} + do + while IFS=' ' read -r POD CONTAINERS + do + for CONTAINER in ${CONTAINERS//,/ } + do + COUNT=$($KUBECTL logs --since=1h --tail=20 $POD -c $CONTAINER -n $NAMESPACE 2>/dev/null| \ + $GET -c '^error|Error|ERROR|Warn|WARN') + if [ $COUNT -gt 0 ] + then + STATE=("${STATE[@]}" "$NAMESPACE,$POD,$CONTAINER,$COUNT") + else + #catch pods in errored state + ERRORED=($($KUBECTL get pods -n $NAMESPACE --no-headers=true | \ + awk '!/Running/ {print $1}' ORS=" ") \ + ) + fi + done + done< <($KUBECTL get pods -n $NAMESPACE --ignore-not-found=true -o=custom-columns=NAME:.metadata.name,CONTAINERS:.spec.containers[*].name --no-headers=true) + done + printf "%s\n" ${STATE[@]:-None} >> results.csv + STATE=() +} +#define usage for seprate run +usage() +{ +cat << EOF + + USAGE: "${0##*/} (optional)" + + This program is a free software under the terms of Apache 2.0 License. + COPYRIGHT (C) 2018 Abhishek Tamrakar + +EOF +exit 0 +} + +#check if basic commands are found +trap cleanup EXIT +checkcmd KUBECTL +# +#set the ground +if [ $# -lt 1 ]; then + if [ ! -e ${KUBE_LOC} -a ! -s ${KUBE_LOC} ] + then + info "A readable kube config location is required!!" + usage + fi +elif [ $# -eq 1 ] +then + export KUBECONFIG=$1 +elif [ $# -gt 1 ] +then + usage +fi +#play +get_namespaces +get_pod_errors + +printf '\n%40s\n' 'KRAWL' +printf '%s\n' '---------------------------------------------------------------------------------' +printf '%s\n' ' Krawl is a command line utility to scan pods and prints name of errored pods ' +printf '%s\n\n' ' +and containers within. To use it as kubernetes plugin, please check their page ' +printf '%s\n' '=================================================================================' + +cat results.csv | sed 's/,/,|/g'| column -s ',' -t +get_pod_events +``` + +此文最初发布在 [KRAWL 的 GitHub 仓库][2]下的 README 中,并被或许重用。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/kubernetes-scanner + +作者:[Abhishek Tamrakar][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/tamrakar +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/ship_captain_devops_kubernetes_steer.png?itok=LAHfIpek (Ship captain sailing the Kubernetes seas) +[2]: https://github.com/abhiTamrakar/kube-plugins/tree/master/krawl +[3]: https://opensource.com/sites/default/files/uploads/krawl_0.png (KRAWL script) +[4]: mailto:abhishek.tamrakar08@gmail.com diff --git a/published/202002/20200210 Top hacks for the YaCy open source search engine.md b/published/202002/20200210 Top hacks for the YaCy open source search engine.md new file mode 100644 index 0000000000..aaa71c4f0e --- /dev/null +++ b/published/202002/20200210 Top hacks for the YaCy open source search engine.md @@ -0,0 +1,101 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11919-1.html) +[#]: subject: (Top hacks for the YaCy open source search engine) +[#]: via: (https://opensource.com/article/20/2/yacy-search-engine-hacks) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +使用开源搜索引擎 YaCy 的技巧 +====== + +> 无需适应其他人的眼光,而是使用 YaCY 搜索引擎定义你想要的互联网。 + +![](https://img.linux.net.cn/data/attachment/album/202002/23/115822jqkdyjwzdqwdad0y.jpg) + +在我以前介绍 [YaCy 入门][2]的文章中讲述过 [YaCy][3] 这个对等peer-to-peer式的搜索引擎是如何安装和使用的。YaCy 最令人兴奋的一点就是它事实上是一个本地客户端,全球范围内的每一个 YaCy 用户都是构成整个这个分布式搜索引擎架构的一个节点,这意味着每个用户都可以掌控自己的互联网搜索体验。 + +Google 曾经提供过 google.com/linux 这样的主题简便方式以便快速筛选出和 Linux 相关的搜索内容,这个小功能受到了很多人的青睐,但 Google 最终还是在 2011 年的时候把它[下线][4]了。 + +而 YaCy 则让自定义搜索引擎变得可能。 + +### 自定义 YaCy + +YaCy 安装好之后,只需要访问 `localhost:8090` 就可以使用了。要自定义搜索引擎,只需要点击右上角的“管理Administration”按钮(它可能隐藏在小屏幕的菜单图标中)。 + +你可以在管理面板中配置 YaCy 对系统资源的使用策略,以及如何跟其它的 YaCy 客户端进行交互。 + +![YaCy profile selector][5] + +例如,点击侧栏中的“第一步First steps”按钮可以配置备用端口,以及设置 YaCy 对内存和硬盘的使用量;而“监控Monitoring”面板则可以监控 YaCy 的运行状况。大多数功能都只需要在面板上点击几下就可以完成了,例如以下几个常用的功能。 + +### 内网搜索应用 + +目前市面上也有不少公司推出了[内网搜索应用][6],而 YaCy 可以免费为你提供一个。对于能够通过 HTTP、FTP、Samba 等协议访问的文件,YaCy 都可以进行索引,因此无论是作为私人的文件搜索还是企业内部的本地共享文件搜索,YaCy 都可以实现。它可以让内部网络中的用户使用你个人的 YaCy 实例来查找共享文件,于此同时保持对内部网络以外的用户不可见。 + +### 网络配置 + +YaCy 在默认情况下就支持隐私和隔离。点击“用例与账号Use Case & Account”页面顶部的“网络配置Network Configuration”链接,即可进入网络配置面板设置对等网络。 + +![YaCy network configuration][7] + +### 爬取站点 + +YaCy 的分布式运作方式决定了它对页面的爬取是由用户驱动的。并没有一个大型公司对整个互联网上的所有可访问页面都进行搜索,对于 YaCy 来说也是这样,一个站点只有在被用户指定爬取的前提下,才会被 YaCy 爬取并进入索引。 + +YaCy 客户端提供了两种爬取页面的方式:你可以手动爬取,并让 YaCy 根据建议去爬取。 + +![YaCy advanced crawler][8] + +#### 手动爬取 + +手动爬取是指由用户输入指定的网站 URL 并启动 YaCy 的爬虫任务。只需要点击“高级爬虫Advanced Crawler”并输入计划爬取的若干 URL,然后选择页面底部的“进行远程索引Do Remote indexing”选项,这个选项会让客户端向互联网广播它要索引的 URL,可选地接受这些请求的客户端可以帮助你爬取这些 URL。 + +点击页面底部的“开始新爬虫任务Start New Crawl Job”按钮就可以开始进行爬取了,我就是这样对一些常用和有用站点进行爬取和索引的。 + +爬虫任务启动之后,YaCy 会将这些 URL 对应的页面在本地生成和存储索引。在高级模式下,也就是本地计算机允许 8090 端口流量进出时,全网的 YaCy 用户都可以使用到这一份索引。 + +#### 加入爬虫网络 + +尽管一些非常敬业的 YaCy 高级用户已经强迫症般地在互联网上爬取了很多页面,但对于全网浩如烟海的页面而言也只是沧海一粟。单个用户所拥有的资源远不及很多大公司的网络爬虫,但大量 YaCy 用户如果联合起来成为一个社区,能产生的力量就大得多了。只要开启了 YaCy 的爬虫请求广播功能,就可以让其它客户端参与进来爬取更多页面。 + +只需要在“高级爬虫Advanced Crawler”面板中点击页面顶部的“远程爬取Remote Crawling”,勾选“加载Load”旁边的复选框,就可以让你的客户端接受其它人发来的爬虫任务请求了。 + +![YaCy remote crawling][9] + +### YaCy 监控相关 + +YaCy 除了作为一个非常强大的搜索引擎,还提供了很丰富的主题和用户体验。你可以在“监控Monitor”面板中监控 YaCy 客户端的网络运行状况,甚至还可以了解到有多少人从 YaCy 社区中获取到了自己所需要的东西。 + +![YaCy monitoring screen][10] + +### 搜索引擎发挥了作用 + +你使用 YaCy 的时间越长,就越会思考搜索引擎如何改变自己的视野,因为你对互联网的体验很大一部分来自于你在搜索引擎中一次次简单查询的结果。实际上,当你和不同行业的人交流时,可能会注意到每个人对“互联网”的理解都有所不同。有些人会认为,互联网的搜索引擎中充斥着各种广告和推广,同时也仅仅能从搜索结果中获取到有限的信息。例如,假设有人不断搜索关于关键词 X 的内容,那么大部分商业搜索引擎都会在搜索结果中提高关键词 X 的权重,但与此同时,另一个关键词 Y 的权重则会相对降低,从而让关键词 Y 被淹没在搜索结果当中,即使这样对完成特定任务更好。 + +就像在现实生活中一样,走出虚拟的世界视野会让你看到一个更广阔的世界。尝试使用 YaCy,看看你发现了什么。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/yacy-search-engine-hacks + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_desktop_website_checklist_metrics.png?itok=OKKbl1UR (Browser of things) +[2]: https://linux.cn/article-11905-1.html +[3]: https://yacy.net/ +[4]: https://www.linuxquestions.org/questions/linux-news-59/is-there-no-more-linux-google-884306/ +[5]: https://opensource.com/sites/default/files/uploads/yacy-profiles.jpg (YaCy profile selector) +[6]: https://en.wikipedia.org/wiki/Vivisimo +[7]: https://opensource.com/sites/default/files/uploads/yacy-network-config.jpg (YaCy network configuration) +[8]: https://opensource.com/sites/default/files/uploads/yacy-advanced-crawler.jpg (YaCy advanced crawler) +[9]: https://opensource.com/sites/default/files/uploads/yacy-remote-crawl-accept.jpg (YaCy remote crawling) +[10]: https://opensource.com/sites/default/files/uploads/yacy-monitor.jpg (YaCy monitoring screen) diff --git a/published/202002/20200211 Dino is a Modern Looking Open Source XMPP Client.md b/published/202002/20200211 Dino is a Modern Looking Open Source XMPP Client.md new file mode 100644 index 0000000000..82b969948c --- /dev/null +++ b/published/202002/20200211 Dino is a Modern Looking Open Source XMPP Client.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11917-1.html) +[#]: subject: (Dino is a Modern Looking Open Source XMPP Client) +[#]: via: (https://itsfoss.com/dino-xmpp-client/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Dino:一个有着现代外观的开源 XMPP 客户端 +====== + +> Dino 是一个相对较新的开源 XMPP 客户端,它试图提供良好的用户体验,鼓励注重隐私的用户使用 XMPP 发送消息。 + +![](https://img.linux.net.cn/data/attachment/album/202002/22/102844mhzgzb3533xgq6d8.jpg) + +### Dino:一个开源 XMPP 客户端 + +![][1] + +[XMPP][2](可扩展通讯和表示协议eXtensible Messaging Presence Protocol) 是一个去中心化的网络模型,可促进即时消息传递和协作。去中心化意味着没有中央服务器可以访问你的数据。通信直接点对点。 + +我们中的一些人可能会称它为“老派”技术,可能是因为 XMPP 客户端通常用户体验非常糟糕,或者仅仅是因为它需要时间来适应(或设置它)。 + +这时候 [Dino][3] 作为现代 XMPP 客户端出现了,在不损害你的隐私的情况下提供干净清爽的用户体验。 + +### 用户体验 + +![][4] + +Dino 试图改善 XMPP 客户端的用户体验,但值得注意的是,它的外观和感受将在一定程度上取决于你的 Linux 发行版。你的图标主题或 Gnome 主题会让你的个人体验更好或更糟。 + +从技术上讲,它的用户界面非常简单,易于使用。所以,我建议你看下 Ubuntu 中的[最佳图标主题][5]和 [GNOME 主题][6]来调整 Dino 的外观。 + +### Dino 的特性 + +![Dino Screenshot][7] + +你可以将 Dino 用作 Slack、[Signal][8] 或 [Wire][9] 的替代产品,来用于你的业务或个人用途。 + +它提供了消息应用所需的所有基本特性,让我们看下你可以从中得到的: + +* 去中心化通信 +* 如果无法设置自己的服务器,它支持公共 XMPP 的服务器 +* 和其他流行消息应用相似的 UI,因此易于使用 +* 图像和文件共享 +* 支持多个帐户 +* 高级消息搜索 +* 支持 [OpenPGP][10] 和 [OMEMO][11] 加密 +* 轻量级原生桌面应用 + +### 在 Linux 上安装 Dino + +你可能会发现它列在你的软件中心中,也可能未找到。Dino 为基于 Debian(deb)和 Fedora(rpm)的发行版提供了可用的二进制文件。 + +Dino 在 Ubuntu 的 universe 仓库中,你可以使用以下命令安装它: + +``` +sudo apt install dino-im +``` + +类似地,你可以在 [GitHub 分发包页面][12]上找到其他 Linux 发行版的包。 + +如果你想要获取最新的,你可以在 [OpenSUSE 的软件页面][13]找到 Dino 的 **.deb** 和 .**rpm** (每日构建版)安装在 Linux 中。 + +在任何一种情况下,前往它的 [Github 页面][14]或点击下面的链接访问官方网站。 + +- [下载 Dino][3] + +### 总结 + +在我编写这篇文章时快速测试过它,它工作良好,没有出过问题。我将尝试探索更多,并希望能涵盖更多有关 XMPP 的文章来鼓励用户使用 XMPP 的客户端和服务器用于通信。 + +你觉得 Dino 怎么样?你会推荐另一个可能好于 Dino 的开源 XMPP 客户端吗?在下面的评论中让我知道你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/dino-xmpp-client/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/dino-main.png?ssl=1 +[2]: https://xmpp.org/about/ +[3]: https://dino.im/ +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/dino-xmpp-client.jpg?ssl=1 +[5]: https://itsfoss.com/best-icon-themes-ubuntu-16-04/ +[6]: https://itsfoss.com/best-gtk-themes/ +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/dino-screenshot.png?ssl=1 +[8]: https://itsfoss.com/signal-messaging-app/ +[9]: https://itsfoss.com/wire-messaging-linux/ +[10]: https://www.openpgp.org/ +[11]: https://en.wikipedia.org/wiki/OMEMO +[12]: https://github.com/dino/dino/wiki/Distribution-Packages +[13]: https://software.opensuse.org/download.html?project=network:messaging:xmpp:dino&package=dino +[14]: https://github.com/dino/dino + diff --git a/published/202002/20200212 How to Change the Default Terminal in Ubuntu.md b/published/202002/20200212 How to Change the Default Terminal in Ubuntu.md new file mode 100644 index 0000000000..b90a79887f --- /dev/null +++ b/published/202002/20200212 How to Change the Default Terminal in Ubuntu.md @@ -0,0 +1,84 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11903-1.html) +[#]: subject: (How to Change the Default Terminal in Ubuntu) +[#]: via: (https://itsfoss.com/change-default-terminal-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Ubuntu 中更改默认终端 +====== + +终端Terminal是 Linux 系统的关键部分。它能让你通过 shell 访问 Linux 系统。Linux 上有多个终端应用(技术上称为终端仿真器)。 + +大多数[桌面环境][1]都有自己的终端实现。它们的外观可能有所不同,并且可能有不同的快捷键。例如,[Guake 终端][2]对高级用户非常有用,它提供了一些可能无法在发行版默认终端中使用的功能。 + +你可以在系统上安装其他终端,并将其设为默认,并能通过[快捷键 Ctrl+Alt+T][3] 打开。 + +现在问题来了,如何在 Ubuntu 中更改默认终端。它没有遵循[更改 Ubuntu 中的默认应用][4]的标准方式,要怎么做? + +### 更改 Ubuntu 中的默认终端 + +![][5] + +在基于 Debian 的发行版中,有一个方便的命令行程序,称为 [update-alternatives][6],可用于处理默认应用。 + +你可以使用它来更改默认的命令行文本编辑器、终端等。为此,请运行以下命令: + +``` +sudo update-alternatives --config x-terminal-emulator +``` + +它将显示系统上存在的所有可作为默认值的终端仿真器。当前的默认终端标有星号。 + +``` +abhishek@nuc:~$ sudo update-alternatives --config x-terminal-emulator +There are 2 choices for the alternative x-terminal-emulator (providing /usr/bin/x-terminal-emulator). + + Selection Path Priority Status +------------------------------------------------------------ + 0 /usr/bin/gnome-terminal.wrapper 40 auto mode + 1 /usr/bin/gnome-terminal.wrapper 40 manual mode +* 2 /usr/bin/st 15 manual mode + +Press to keep the current choice[*], or type selection number: +``` + +你要做的就是输入选择编号。对我而言,我想使用 GNOME 终端,而不是来自 [Regolith 桌面][7]的终端。 + +``` +Press to keep the current choice[*], or type selection number: 1 +update-alternatives: using /usr/bin/gnome-terminal.wrapper to provide /usr/bin/x-terminal-emulator (x-terminal-emulator) in manual mode +``` + +> **自动模式 vs 手动模式** +> +> 你可能已经在 `update-alternatives` 命令的输出中注意到了自动模式和手动模式。 +> +> 如果选择自动模式,那么在安装或删除软件包时,系统可能会自动决定默认应用。该决定受优先级数字的影响(如上一节中的命令输出所示)。 +> +> 假设你的系统上安装了 5 个终端仿真器,并删除了默认的仿真器。现在,你的系统将检查哪些仿真器处于自动模式。如果有多个,它将​​选择优先级最高的一个作为默认仿真器。 + +我希望你觉得这个小技巧有用。随时欢迎提出问题和建议。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/change-default-terminal-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/best-linux-desktop-environments/ +[2]: http://guake-project.org/ +[3]: https://itsfoss.com/ubuntu-shortcuts/ +[4]: https://itsfoss.com/change-default-applications-ubuntu/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/switch_default_terminal_ubuntu.png?ssl=1 +[6]: https://manpages.ubuntu.com/manpages/trusty/man8/update-alternatives.8.html +[7]: https://itsfoss.com/regolith-linux-desktop/ diff --git a/published/202002/20200212 How to use byobu to multiplex SSH sessions.md b/published/202002/20200212 How to use byobu to multiplex SSH sessions.md new file mode 100644 index 0000000000..061ca4c41a --- /dev/null +++ b/published/202002/20200212 How to use byobu to multiplex SSH sessions.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11944-1.html) +[#]: subject: (How to use byobu to multiplex SSH sessions) +[#]: via: (https://opensource.com/article/20/2/byobu-ssh) +[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall) + +如何使用 byobu 复用 SSH 会话 +====== + +> Byobu 能让你在保持会话活跃的情况下维护多个终端窗口,通过 SSH 连接、断开、重连以及共享访问。 + +![Person drinking a hat drink at the computer][1] + +[Byobu][2] 是基于文本的窗口管理器和终端多路复用器。它类似于 [GNU Screen][3],但更现代、更直观。它还适用于大多数 Linux、BSD 和 Mac 发行版。 + +Byobu 能让你在保持会话活跃的情况下维护多个终端窗口、通过 SSH(secure shell)连接、断开、重连,甚至让其他人访问。 + +比如,你 SSH 进入树莓派或服务器,并运行(比如) `sudo apt update && sudo apt upgrade`,然后你在它运行的时候失去了互联网连接,你的命令会丢失无效。然而,如果你首先启动 byobu 会话,那么它会继续运行,在你重连后,你会发现它仍在继续运行。 + +![The byobu logo is a fun play on screens.][4] + +Byobu 名称来自于日语的装饰性多面板屏风,它可作为折叠式隔断,我认为这很合适。 + +要在 Debian/Raspbian/Ubuntu 上安装 byobu: + +``` +sudo apt install byobu +``` + +接着启用它: + +``` +byobu-enable +``` + +现在,请退出 SSH 会话并重新登录,你将会在 byobu 会话中登录。运行类似 `sudo apt update` 命令并关闭窗口(或输入转义序列([Enter + ~ + .][5])并重新登录。你将看到更新命令在你离开后还在运行。 + +有*很多*我不常使用的功能。我通常使用的是: + + * `F2` – 新窗口 + * `F3/F4` – 在窗口间导航 + * `Ctrl`+`F2` – 垂直拆分窗格 + * `Shift`+`F2` – 水平拆分窗格 + * `Shift`+`左箭头/Shift`+`右箭头` – 在拆分窗格间导航 + * `Shift`+`F11` – 放大(或缩小)拆分窗格 + +### 我们如何使用 byobu + +Byobu 对于维护 [piwheels][6](一个用于树莓派的方便的,预编译 Python 包)很好用。我水平拆分了窗格,在上半部分显示了 piwheels 监视器,在下半部分实时显示了 syslog 条目。接着,如果我们想要做其他事情,我们可以切换到另外一个窗口。当我们进行协作分析时,这特别方便,因为当我在 IRC 中聊天时,我可以看到我的同事 Dave 输入了什么(并纠正他的错字)。 + +我在家庭和办公服务器上启用了 byobu,因此,当我登录到任何一台计算机时,一切都与我离开时一样。它正在运行多个作业、在特定目录中保留一个窗口,以另一个用户身份运行进程等。 + +![byobu screenshot][7] + +Byobu 对于在树莓派上进行开发也很方便。你可以在桌面上启动它,运行命令,然后 SSH 进入,并连接到该命令运行所在的会话。请注意,启用 byobu 不会更改终端启动器的功能。只需运行 `byobu` 即可启动它。 + +本文最初发表在 Ben Nuttall 的 [Tooling blog][8] 中,并获许重用。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/byobu-ssh + +作者:[Ben Nuttall][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/bennuttall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_tea_laptop_computer_work_desk.png?itok=D5yMx_Dr (Person drinking a hat drink at the computer) +[2]: https://byobu.org/ +[3]: http://www.gnu.org/software/screen/ +[4]: https://opensource.com/sites/default/files/uploads/byobu.png (byobu screen) +[5]: https://www.google.com/search?client=ubuntu&channel=fs&q=Enter-tilde-dot&ie=utf-8&oe=utf-8 +[6]: https://opensource.com/article/20/1/piwheels +[7]: https://opensource.com/sites/default/files/uploads/byobu-screenshot.png (byobu screenshot) +[8]: https://tooling.bennuttall.com/byobu/ diff --git a/published/202002/20200212 elementary OS is Building an App Center Where You Can Buy Open Source Apps for Your Linux Distribution.md b/published/202002/20200212 elementary OS is Building an App Center Where You Can Buy Open Source Apps for Your Linux Distribution.md new file mode 100644 index 0000000000..6619254799 --- /dev/null +++ b/published/202002/20200212 elementary OS is Building an App Center Where You Can Buy Open Source Apps for Your Linux Distribution.md @@ -0,0 +1,95 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11939-1.html) +[#]: subject: (elementary OS is Building an App Center Where You Can Buy Open Source Apps for Your Linux Distribution) +[#]: via: (https://itsfoss.com/appcenter-for-everyone/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +elementary OS 正在构建一个可以买应用的开源应用商店 +====== + +> elementary OS 正在构建一个应用中心生态系统,你可以在其中购买用于 Linux 发行版的开源应用程序。 + +### 众筹构建一个开源应用中心 + +![][1] + +[elementary OS][2] 最近宣布,它正在[众筹举办一个构建应用中心的活动][3],你可以从这个应用中心购买开源应用程序。应用中心中的应用程序将为 Flatpak 格式。 + +尽管这是 elementary OS 发起的活动,但这个新的应用中心也将适用于其他发行版。 + +该活动旨在资助在美国科罗拉多州丹佛市进行的一项一周个人开发冲刺活动,其中包括来自 elementary OS、[Endless][4]、[Flathub][5] 和 [GNOME][6] 的开发人员。 + +众筹活动已经超过了筹集 1 万美元的目标(LCTT 译注:截止至本译文发布,已近 15000 美金)。但你仍然可以为其提供资金,因为其他资金将用于开发 elementary OS。 + +### 这个应用中心将带来什么功能 + +其重点是提供“安全”应用程序,因此使用 [Flatpak][7] 应用来提供受限的应用程序。在这种格式下,默认情况下将会限制应用程序访问系统或个人文件,并在技术层面上将它们与其他应用程序隔离。 + +仅当你明确表示同意时,应用程序才能访问操作系统和个人文件。 + +除了安全性,[Flatpak][8] 还捆绑了所有依赖项。这样,即使当前 Linux 发行版中不提供这些依赖项,应用程序开发人员也可以利用这种最先进的技术使用它。 + +AppCenter 还具有钱包功能,可以保存你的信用卡详细信息。这样,你无需每次输入卡的详细信息即可快速为应用付费。 + +![][9] + +这个新的开源“应用中心”也将适用于其他 Linux 发行版。 + +### 受到了 elementary OS 自己的“按需付费”应用中心模型成功的启发 + +几年前,elementary OS 推出了自己的应用中心。应用中心的“按需付费”方法很受欢迎。开发人员可以为其开源应用设置最低金额,而用户可以选择支付等于或高于最低金额的金额。 + +![][10] + +这帮助了几位独立开发人员可以对其开源应用程序接受付款。该应用中心现在拥有约 160 个原生应用程序,elementary OS 表示已通过应用中心向开发人员支付了数千美元。 + +受到此应用中心实验在 elementary OS 中的成功的启发,他们现在也希望将此应用中心的方法也引入其他发行版。 + +### 如果应用程序是开源的,你怎么为此付费? + +某些人仍然对 FOSS(自由而开源)的概念感到困惑。在这里,该软件的“源代码”是“开源的”,任何人都可以“自由”进行修改和重新分发。 + +但这并不意味着开源软件必须免费。一些开发者依靠捐赠,而另一些则收取支持费用。 + +获得开源应用程序的报酬可能会鼓励开发人员创建 [Linux 应用程序][11]。 + +### 让我们拭目以待 + +![][12] + +就个人而言,我不是 Flatpak 或 Snap 包格式的忠实拥护者。它们确实有其优点,但是它们花费了相对更多的时间来启动,并且它们的包大小很大。如果安装了多个此类 Snap 或 Flatpak 软件包,磁盘空间就会慢慢耗尽。 + +也需要对这个新的应用程序生态系统中的假冒和欺诈开发者保持警惕。想象一下,如果某些骗子开始创建冷门的开源应用程序的 Flatpak 程序包,并将其放在应用中心上?我希望开发人员采用某种机制来淘汰此类应用程序。 + +我确实希望这个新的应用中心能够复制在 elementary OS 中已经看到的成功。对于桌面 Linux 的开源应用程序,我们绝对需要更好的生态系统。 + +你对此有何看法?这是正确的方法吗?你对改进应用中心有什么建议? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/appcenter-for-everyone/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/appcenter.png?ssl=1 +[2]: https://elementary.io/ +[3]: https://www.indiegogo.com/projects/appcenter-for-everyone/ +[4]: https://itsfoss.com/endless-linux-computers/ +[5]: https://flathub.org/ +[6]: https://www.gnome.org/ +[7]: https://flatpak.org/ +[8]: https://itsfoss.com/flatpak-guide/ +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/appcenter-wallet.png?ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/appcenter-payment.png?ssl=1 +[11]: https://itsfoss.com/essential-linux-applications/ +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/open_source_app_center.png?ssl=1 diff --git a/published/202002/20200213 Why developers like to code at night.md b/published/202002/20200213 Why developers like to code at night.md new file mode 100644 index 0000000000..144345c44f --- /dev/null +++ b/published/202002/20200213 Why developers like to code at night.md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11924-1.html) +[#]: subject: (Why developers like to code at night) +[#]: via: (https://opensource.com/article/20/2/why-developers-code-night) +[#]: author: (Matt Shealy https://opensource.com/users/mshealy) + +程序员为什么喜欢在晚上编码 +====== + +> 对许多开源程序员来说,夜间的工作计划是创造力和生产力来源的关键。 + +![](https://img.linux.net.cn/data/attachment/album/202002/24/104251b2hxch46h45c8zwd.jpg) + +如果你问大多数开发人员更喜欢在什么时候工作,大部人会说他们最高效的时间在晚上。这对于那些在工作之余为开源项目做贡献的人来说更是如此(尽管如此,希望在他们的健康范围内[避免透支][2])。 + +有些人喜欢从晚上开始,一直工作到凌晨,而另一些人则很早就起床(例如,凌晨 4 点),以便在开始日常工作之前完成大部分编程工作。 + +这种工作习惯可能会使许多开发人员看起来像个怪人,不合时宜。但是,为什么有这么多的程序员喜欢在非正常时间工作,原因有很多: + +### 制造者日程 + +根据 [保罗·格雷厄姆][3]Paul Graham 的观点,“生产东西”的人倾向于遵守 制造者日程 —— 他们更愿意以半天或更长时间为单位使用时间。事实上,大多数[开发人员也有相同的偏好][4]。(LCTT 译注:保罗·格雷厄姆有[一篇文章][8]述及制造者日程和管理者日程。) + +一方面,开发人员从事大型抽象系统工作,需要思维空间来处理整个模型。将他们的日程分割成 15 分钟或 30 分钟的时间段来处理电子邮件、会议、电话以及来自同事的打断,工作效果只会适得其反。 + +另一方面,通常不可能以小时为单位进行有效编程。因为这么短的时间几乎不够让你把思绪放在手头的任务上并开始工作。 + +上下文切换也会对编程产生不利影响。在晚上工作,开发人员可以避免尽可能多的干扰。在没有不断的干扰的情况下,他们可以花几个小时专注于手头任务,并尽可能提高工作效率。 + +### 平和安静的环境 + +由于晚上或凌晨不太会有来自各种活动的噪音(例如,办公室闲谈、街道上的交通),这使许多程序员感到放松,促使他们更具创造力和生产力,特别是在处理诸如编码之类的精神刺激任务时。 + +独处与平静,加上他们知道自己将有几个小时不被中断的工作时间,通常会使他们摆脱白天工作计划相关的时间压力,从而产出高质量的工作。 + +更不用说了,当解决了一个棘手的问题后,没有什么比尽情享受自己最喜欢的午夜小吃更美好的事情了! + +### 沟通 + +与在公司内工作的程序员相比,从事开源项目的开发人员可以拥有不同的沟通节奏。大多数开源项目的沟通都是通过邮件或 GitHub 上的评论等渠道异步完成的。很多时候,其他程序员在不同的国家和时区,因此实时交流通常需要开发人员变成一个夜猫子。 + +### 昏昏欲睡的大脑 + +这听起来可能违反直觉,但是随着时间的推移,大脑会变得非常疲倦,因此只能专注于一项任务。晚上工作从根本上消除了多任务处理,而这是保持专注和高效的主要障碍。当大脑处于昏昏欲睡的状态时,你是无法保持专注的! + +此外,许多开发人员在入睡时思考要解决的问题通常会取得重大进展。潜意识开始工作,答案通常在他们半睡半醒的凌晨时分就出现了。 + +这不足为奇,因为[睡眠可增强大脑功能][5],可帮助我们理解新信息并进行更有创造性的思考。当解决方案在凌晨出现时,这些开发人员便会起来开始工作,不错过任何机会。 + +### 灵活和创造性思考 + +许多程序员体会到晚上创造力会提升。前额叶皮层,即大脑中与集中能力有关的部分,在一天结束时会感到疲倦。这似乎为某些人提供了更灵活和更具创造性的思考。 + +匹兹堡大学医学院精神病学助理教授 [Brant Hasler][6] 表示:“由于自上而下的控制和‘认知抑制’的减少,大脑可能会解放出来进行更发散的思考,从而使人们更容易地将不同概念之间的联系建立起来。” 结合轻松环境所带来的积极情绪,开发人员可以更轻松地产生创新想法。 + +此外,在没有干扰的情况下集中精力几个小时,“沉浸在你做的事情中”。这可以帮助你更好地专注于项目并参与其中,而不必担心周围发生的事情。 + +### 明亮的电脑屏幕 + +因为整天看着明亮的屏幕, 许多程序员的睡眠周期被延迟。电脑屏幕发出的蓝光[扰乱我们的昼夜节律][7],延迟了释放诱发睡眠的褪黑激素和提高人的机敏性,并将人体生物钟重置到更晚的时间。从而导致,开发人员往往睡得越来越晚。 + +### 来自过去的影响 + +过去,大多数开发人员是出于必要在晚上工作,因为在白天当公司其他人都在使用服务器时,共享服务器的计算能力支撑不了编程工作,所以开发人员需要等到深夜才能执行白天无法进行的任务,例如测试项目、运行大量的“编码-编译-运行-调试”周期以及部署新代码。现在尽管服务器功能变强大了,大多数可以满足需求,但夜间工作的趋势仍是这种文化的一部分。 + +### 结语 + +尽管开发人员喜欢在晚上工作的原因很多,但请记住,做为夜猫子并不意味着你应该克扣睡眠时间。睡眠不足会导致压力和焦虑,并最终导致倦怠。 + +获得足够质量的睡眠是维持良好身体健康和大脑功能的关键。例如,它可以帮助你整合新信息、巩固记忆、创造性思考、清除身体积聚的毒素、调节食欲并防止过早衰老。 + +无论你是哪种日程,请确保让你的大脑得到充分的休息,这样你就可以在一整天及每天的工作中发挥最大的作用! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/why-developers-code-night + +作者:[Matt Shealy][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mshealy +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_code_programming_laptop.jpg?itok=ormv35tV (Person programming on a laptop on a building) +[2]: https://opensource.com/article/19/11/burnout-open-source-communities +[3]: http://www.paulgraham.com/makersschedule.html +[4]: https://www.chamberofcommerce.com/business-advice/software-development-trends-overtaking-the-market +[5]: https://amerisleep.com/blog/sleep-impacts-brain-health/ +[6]: https://www.vice.com/en_us/article/mb58a8/late-night-creativity-spike +[7]: https://www.sleepfoundation.org/articles/how-blue-light-affects-kids-sleep +[8]: http://www.paulgraham.com/makersschedule.html diff --git a/published/202002/20200214 Digging up IP addresses with the Linux dig command.md b/published/202002/20200214 Digging up IP addresses with the Linux dig command.md new file mode 100644 index 0000000000..01f72b47fd --- /dev/null +++ b/published/202002/20200214 Digging up IP addresses with the Linux dig command.md @@ -0,0 +1,196 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11931-1.html) +[#]: subject: (Digging up IP addresses with the Linux dig command) +[#]: via: (https://www.networkworld.com/article/3527430/digging-up-ip-addresses-with-the-dig-command.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +使用 dig 命令挖掘域名解析信息 +====== + +> 命令行工具 `dig` 是用于解析域名和故障排查的一个利器。 + +![](https://img.linux.net.cn/data/attachment/album/202002/26/094028jgvzguau1pdgicpz.jpg) + +从主要功能上来说,`dig` 和 `nslookup` 之间差异不大,但 `dig` 更像一个加强版的 `nslookup`,可以查询到一些由域名服务器管理的信息,这在排查某些问题的时候非常有用。总的来说,`dig` 是一个既简单易用又功能强大的命令行工具。(LCTT 译注:`dig` 和 `nslookup` 行为的主要区别来自于 `dig` 使用是是操作系统本身的解析库,而 `nslookup` 使用的是该程序自带的解析库,这有时候会带来一些行为差异。此外,从表现形式上看,`dig` 返回是结果是以 BIND 配置信息的格式返回的,也带有更多的技术细节。) + +`dig` 最基本的功能就是查询域名信息,因此它的名称实际上是“域名信息查询工具Domain Information Groper”的缩写。`dig` 向用户返回的内容可以非常详尽,也可以非常简洁,展现内容的多少完全由用户在查询时使用的选项来决定。 + +### 我只需要查询 IP 地址 + +如果只需要查询某个域名指向的 IP 地址,可以使用 `+short` 选项: + +``` +$ dig facebook.com +short +31.13.66.35 +``` + +在查询的时候发现有的域名会指向多个 IP 地址?这其实是网站提高其可用性的一种措施。 + +``` +$ dig networkworld.com +short +151.101.2.165 +151.101.66.165 +151.101.130.165 +151.101.194.165 +``` + +也正是由于这些网站通过负载均衡实现高可用,在下一次查询的时候,或许会发现这几个 IP 地址的排序有所不同。(LCTT 译注:浏览器等应用默认会使用返回的第一个 IP 地址,因此这样实现了一种简单的负载均衡。) + +``` +$ dig networkworld.com +short +151.101.130.165 +151.101.194.165 +151.101.2.165 +151.101.66.165 +``` + +### 标准返回 + +`dig` 的标准返回内容则包括这个工具本身的一些信息,以及请求域名服务器时返回的响应内容: + +``` +$ dig networkworld.com + +; <<>> DiG 9.11.5-P4-5.1ubuntu2.1-Ubuntu <<>*gt; networkworld.com +;; global options: +cmd +;; Got answer: +;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39932 +;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1 + +;; OPT PSEUDOSECTION: +; EDNS: version: 0, flags:; udp: 65494 +;; QUESTION SECTION: +;networkworld.com. IN A + +;; ANSWER SECTION: +networkworld.com. 300 IN A 151.101.194.165 +networkworld.com. 300 IN A 151.101.130.165 +networkworld.com. 300 IN A 151.101.66.165 +networkworld.com. 300 IN A 151.101.2.165 + +;; Query time: 108 msec +;; SERVER: 127.0.0.53#53(127.0.0.53) +;; WHEN: Thu Feb 13 13:49:53 EST 2020 +;; MSG SIZE rcvd: 109 +``` + +由于域名服务器有缓存机制,返回的内容可能是之前缓存好的信息。在这种情况下,`dig` 最后显示的查询时间Query time会是 0 毫秒(0 msec): + +``` +;; Query time: 0 msec <== +;; SERVER: 127.0.0.53#53(127.0.0.53) +;; WHEN: Thu Feb 13 15:30:09 EST 2020 +;; MSG SIZE rcvd: 109 +``` + +### 向谁查询? + +在默认情况下,`dig` 会根据 `/etc/resolv.conf` 这个文件的内容决定向哪个域名服务器获取查询结果。你也可以使用 `@` 来指定 `dig` 请求的域名服务器。 + +在下面的例子中,就指定了 `dig` 向 Google 的域名服务器 8.8.8.8 查询域名信息。 + +``` +$ dig @8.8.8.8 networkworld.com + +; <<>> DiG 9.11.5-P4-5.1ubuntu2.1-Ubuntu <<>> @8.8.8.8 networkworld.com +; (1 server found) +;; global options: +cmd +;; Got answer: +;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21163 +;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1 + +;; OPT PSEUDOSECTION: +; EDNS: version: 0, flags:; udp: 512 +;; QUESTION SECTION: +;networkworld.com. IN A + +;; ANSWER SECTION: +networkworld.com. 299 IN A 151.101.130.165 +networkworld.com. 299 IN A 151.101.66.165 +networkworld.com. 299 IN A 151.101.194.165 +networkworld.com. 299 IN A 151.101.2.165 + +;; Query time: 48 msec +;; SERVER: 8.8.8.8#53(8.8.8.8) +;; WHEN: Thu Feb 13 14:26:14 EST 2020 +;; MSG SIZE rcvd: 109 +``` + +想要知道正在使用的 `dig` 工具的版本,可以使用 `-v` 选项。你会看到类似这样: + +``` +$ dig -v +DiG 9.11.5-P4-5.1ubuntu2.1-Ubuntu +``` + +或者这样的返回信息: + +``` +$ dig -v +DiG 9.11.4-P2-RedHat-9.11.4-22.P2.el8 +``` + +如果你觉得 `dig` 返回的内容过于详细,可以使用 `+noall`(不显示所有内容)和 `+answer`(仅显示域名服务器的响应内容)选项,域名服务器的详细信息就会被忽略,只保留域名解析结果。 + +``` +$ dig networkworld.com +noall +answer + +; <<>> DiG 9.11.5-P4-5.1ubuntu2.1-Ubuntu <<>> networkworld.com +noall +answer +;; global options: +cmd +networkworld.com. 300 IN A 151.101.194.165 +networkworld.com. 300 IN A 151.101.130.165 +networkworld.com. 300 IN A 151.101.66.165 +networkworld.com. 300 IN A 151.101.2.165 +``` + +### 批量查询域名 + +如果你要查询多个域名,可以把这些域名写入到一个文件内(`domains`),然后使用下面的 `dig` 命令遍历整个文件并给出所有查询结果。 + +``` +$ dig +noall +answer -f domains +networkworld.com. 300 IN A 151.101.66.165 +networkworld.com. 300 IN A 151.101.2.165 +networkworld.com. 300 IN A 151.101.130.165 +networkworld.com. 300 IN A 151.101.194.165 +world.std.com. 77972 IN A 192.74.137.5 +uushenandoah.org. 1982 IN A 162.241.24.209 +amazon.com. 18 IN A 176.32.103.205 +amazon.com. 18 IN A 176.32.98.166 +amazon.com. 18 IN A 205.251.242.103 +``` + +你也可以在上面的命令中使用 `+short` 选项,但如果其中有些域名指向多个 IP 地址,就无法看出哪些 IP 地址对应哪个域名了。在这种情况下,更好地做法应该是让 `awk` 对返回内容进行处理,只留下第一列和最后一列: + +``` +$ dig +noall +answer -f domains | awk '{print $1,$NF}' +networkworld.com. 151.101.66.165 +networkworld.com. 151.101.130.165 +networkworld.com. 151.101.194.165 +networkworld.com. 151.101.2.165 +world.std.com. 192.74.137.5 +amazon.com. 176.32.98.166 +amazon.com. 205.251.242.103 +amazon.com. 176.32.103.205 +``` + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3527430/digging-up-ip-addresses-with-the-dig-command.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/202002/20200217 How to get MongoDB Server on Fedora.md b/published/202002/20200217 How to get MongoDB Server on Fedora.md new file mode 100644 index 0000000000..8c5522b477 --- /dev/null +++ b/published/202002/20200217 How to get MongoDB Server on Fedora.md @@ -0,0 +1,115 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11942-1.html) +[#]: subject: (How to get MongoDB Server on Fedora) +[#]: via: (https://fedoramagazine.org/how-to-get-mongodb-server-on-fedora/) +[#]: author: (Honza Horak https://fedoramagazine.org/author/hhorak/) + +如何在 Fedora 上安装 MongoDB 服务器 +====== + +![][1] + +Mongo(来自 “humongous” —— 巨大的)是一个高性能、开源、无模式的、面向文档的数据库,它是最受欢迎的 [NoSQL][2] 数据库之一。它使用 JSON 作为文档格式,并且可以在多个服务器节点之间进行扩展和复制。 + +### 有关许可证更改的故事 + +MongoDB 上游决定更改服务器代码的许可证已经一年多了。先前的许可证是 GNU Affero General Public License v3(AGPLv3)。但是,上游公司写了一个新许可证,旨在使运行 MongoDB 即服务的公司可以回馈社区。新许可证称为 Server Side Public License(SSPLv1),关于这个举措及其解释的更多说明,请参见 [MongoDB SSPL FAQ][3]。 + +Fedora 一直只包含自由软件。当 SSPL 发布后,Fedora [确定][4]它并不是自由软件许可证。许可证更改日期(2018 年 10 月)之前发布的所有 MongoDB 版本都可保留在 Fedora 中,但之后再也不更新的软件包会带来安全问题。因此,从 Fedora 30 开始,Fedora 社区决定完全[移除 MongoDB 服务器][5]。 + +### 开发人员还有哪些选择? + +是的,还有替代方案,例如 PostgreSQL 在最新版本中也支持 JSON,它可以在无法再使用 MongoDB 的情况下使用它。使用 JSONB 类型,索引在 PostgreSQL 中可以很好地工作,其性能可与 MongoDB 媲美,甚至不会受到 ACID 的影响。 + +开发人员可能选择 MongoDB 的技术原因并未随许可证而改变,因此许多人仍想使用它。重要的是要意识到,SSPL 许可证仅更改仅针对 MongoDB 服务器。MongoDB 上游还开发了其他项目,例如 MongoDB 工具、C 和 C++ 客户端库以及用于各种动态语言的连接器,这些项目在客户端使用(通过网络与服务器通信的应用中)。由于这些包的许可证人保持自由(主要是 Apache 许可证),因此它们保留在 Fedora 仓库中,因此用户可以将其用于应用开发。 + +唯一的变化实际是服务器软件包本身,它已从 Fedora 仓库中完全删除。让我们看看 Fedora 用户可以如何获取非自由的包。 + +### 如何从上游安装 MongoDB 服务器 + +当 Fedora 用户想要安装 MongoDB 服务器时,他们需要直接向上游获取 MongoDB。但是,上游不为 Fedora 提供 RPM 包。相反,MongoDB 服务器可以获取源码 tarball,用户需要自己进行编译(这需要一些开发知识),或者 Fedora 用户可以使用一些兼容的包。在兼容的选项中,最好的选择是 RHEL-8 RPM。以下步骤描述了如何安装它们以及如何启动守护进程。 + +#### 1、使用上游 RPM 创建仓库(RHEL-8 构建) + +``` +$ sudo cat > /etc/yum.repos.d/mongodb.repo >>EOF +[mongodb-upstream] +name=MongoDB Upstream Repository +baseurl=https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/4.2/x86_64/ +gpgcheck=1 +enabled=1 +gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc +EOF +``` + +#### 2、安装元软件包,来拉取服务器和工具包 + +``` +$ sudo dnf install mongodb-org +...... +Installed: + mongodb-org-4.2.3-1.el8.x86_64 mongodb-org-mongos-4.2.3-1.el8.x86_64 + mongodb-org-server-4.2.3-1.el8.x86_64 mongodb-org-shell-4.2.3-1.el8.x86_64 + mongodb-org-tools-4.2.3-1.el8.x86_64 + +Complete! +``` + +#### 3、启动 MongoDB 守护进程 + +``` +$ sudo systemctl status mongod +● mongod.service - MongoDB Database Server + Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled) + Active: active (running) since Sat 2020-02-08 12:33:45 EST; 2s ago + Docs: https://docs.mongodb.org/manual + Process: 15768 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS) + Process: 15769 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS) + Process: 15770 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS) + Process: 15771 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS) + Main PID: 15773 (mongod) + Memory: 70.4M + CPU: 611ms + CGroup: /system.slice/mongod.service + +``` + +#### 4、通过 mongo shell 连接服务器来验证是否运行 + +``` +$ mongo +MongoDB shell version v4.2.3 +connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb +Implicit session: session { "id" : UUID("20b6e61f-c7cc-4e9b-a25e-5e306d60482f") } +MongoDB server version: 4.2.3 +Welcome to the MongoDB shell. +For interactive help, type "help". +For more comprehensive documentation, see + http://docs.mongodb.org/ +--- +``` + + +就是这样了。如你所见,RHEL-8 包完美兼容,只要 Fedora 包还与 RHEL-8 兼容,它就应该会一直兼容。请注意,在使用时必须遵守 SSPLv1 许可证。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/how-to-get-mongodb-server-on-fedora/ + +作者:[Honza Horak][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/hhorak/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/02/mongodb-816x348.png +[2]: https://en.wikipedia.org/wiki/NoSQL +[3]: https://www.mongodb.com/licensing/server-side-public-license/faq +[4]: https://lists.fedoraproject.org/archives/list/legal@lists.fedoraproject.org/thread/IQIOBOGWJ247JGKX2WD6N27TZNZZNM6C/ +[5]: https://fedoraproject.org/wiki/Changes/MongoDB_Removal diff --git a/published/202002/20200217 How to install Vim plugins.md b/published/202002/20200217 How to install Vim plugins.md new file mode 100644 index 0000000000..f3ce601e53 --- /dev/null +++ b/published/202002/20200217 How to install Vim plugins.md @@ -0,0 +1,166 @@ +[#]: collector: (lujun9972) +[#]: translator: (qianmingtian) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11923-1.html) +[#]: subject: (How to install Vim plugins) +[#]: via: (https://opensource.com/article/20/2/how-install-vim-plugins) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何安装 Vim 插件 +====== + +> 无论你是手动安装还是通过包管理器安装,插件都可以帮助你在工作流中打造一个完美的 Vim 。 + +![](https://img.linux.net.cn/data/attachment/album/202002/23/215719kwhqzwwj1ezoen6o.jpg) + +虽然 [Vim][2] 是快速且高效的,但在默认情况下,它仅仅只是一个文本编辑器。至少,这就是没有插件的情况 Vim 应当具备的样子,插件构建在 Vim 之上,并添加额外的功能,使 Vim 不仅仅是一个输入文本的窗口。有了合适的插件组合,你可以控制你的生活,形成你自己独特的 Vim 体验。你可以[自定义你的主题][3],你可以添加语法高亮,代码 linting,版本跟踪器等等。 + +### 怎么安装 Vim 插件 + +Vim 可以通过插件进行扩展,但很长一段时间以来,并没有官方的安装方式去安装这些插件。从 Vim 8 开始,有一个关于插件如何安装和加载的结构。你可能会在网上或项目自述文件中遇到旧的说明,但只要你运行 Vim 8 或更高版本,你应该根据 Vim 的[官方插件安装方法][4]安装或使用 Vim 包管理器。你可以使用包管理器,无论你运行的是什么版本(包括比 8.x 更老的版本),这使得安装过程比你自己维护更新更容易。 + +手动和自动安装方法都值得了解,所以请继续阅读以了解这两种方法。 + +### 手动安装插件(Vim 8 及以上版本) + +所谓的 “Vim 包”是一个包含一个或多个插件的目录。默认情况下,你的 Vim 设置包含在 `~/.vim` 中,这是 Vim 在启动时寻找插件的地方。(下面的示例使用了通用名称 `vendor` 来表示插件是从其它地方获得的。) + +当你启动 Vim 时,它首先处理你的 `.vimrc`文件,然后扫描 `~/.vim` 中的所有目录,查找包含在 `pack/*/start` 中的插件。 + +默认情况下,你的 `~/.vim` 目录(如果你有的话)中没有这样的文件结构,所以设置为: + +``` +$ mkdir -p ~/.vim/pack/vendor/start +``` + +现在,你可以将 Vim 插件放在 `~/.vim/pack/vendor/start` 中,它们会在你启动 Vim 时自动加载。 + +例如,尝试安装一下 [NERDTree][5],这是一个基于文本的 Vim 文件管理器。首先,使用 Git 克隆 NERDTree 存储库的快照: + +``` +$ git clone --depth 1 \ +  https://github.com/preservim/nerdtree.git \ +  ~/.vim/pack/vendor/start/nerdtree +``` + +启动 Vim 或者 gvim,然后键入如下命令: + +``` +:NERDTree +``` + +Vim 窗口左侧将打开一个文件树。 + +![NERDTree plugin][6] + +如果你不想让一个插件每次启动 Vim 时都自动加载,你可以在 `~/.vim/pack/vendor` 中创建 `opt` 文件夹: + +``` +$ mkdir ~/.vim/pack/vendor/opt +``` + +任何安装到 `opt` 的插件都可被 Vim 使用,但是只有当你使用 `packadd` 命令将它们添加到一个会话中时,它们才会被加载到内存中。例如,一个虚构的叫 foo 的插件: + +``` +:packadd foo +``` + +Vim 官方建议每个插件项目在 `~/.Vim/pack` 中创建自己的目录。例如,如果你要安装 NERDTree 插件和假想的 foo 插件,你需要创建这样的目录结构: + +``` +$ mkdir -p ~/.vim/pack/NERDTree/start/ +$ git clone --depth 1 \ + https://github.com/preservim/nerdtree.git \ + ~/.vim/pack/NERDTree/start/NERDTree +$ mkdir -p ~/.vim/pack/foo/start/ +$ git clone --depth 1 \ + https://notabug.org/foo/foo.git \ + ~/.vim/pack/foo/start/foo +``` + +这样做是否方便取决于你。 + +### 使用 Vim 包管理器(任何 Vim 版本) + +自从 Vim 8 以后,包管理器变得不那么有用了,但是一些用户仍然喜欢它们,因为它们能够自动更新一些插件。有几个包管理器可供选择,并且它们各不相同,但是 [vim-plug][7] 有一些很棒的特性和最好的文档,这使我们很容易开始并在以后深入研究。 + +#### 使用 vim-plug 安装插件 + +安装 vim-plug,以便它在启动时自动加载: + +``` +$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ +  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +``` + +创建一个 `~/.vimrc` 文件(如果你还没有这个文件),然后输入以下文本: + +``` +call plug#begin() +Plug 'preservim/NERDTree' +call plug#end() +``` + +每次要安装插件时,都必须在 `plug#begin()` 和 `plug#end()` 之间输入插件的名称和位置(上面以 NERDTree 文件管理器为例)。如果你所需的插件未托管在 GitHub 上,你可以提供完整的 URL,而不仅仅是 GitHub 的用户名和项目 ID。你甚至可以在 `~/.vim` 目录之外“安装”本地插件。 + +最后,启动 Vim 并提示 vim-plug 安装 `~/.vimrc` 中列出的插件: + +``` +:PlugInstall +``` + +等待插件下载。 + +#### 通过 vim-plug 更新插件 + +与手动安装过程相比,编辑 `~/.vimrc` 并使用命令来进行安装可能看起来并没有多省事,但是 vim-plug 的真正优势在更新。更新所有安装的插件,使用这个 Vim 命令: + +``` +:PlugUpdate +``` + +如果你不想更新所有的插件,你可以通过添加插件的名字来更新任何插件: + +``` +:PlugUpdate NERDTree +``` + +#### 恢复插件 + +vim-plug 的另一个优点是它的导出和恢复功能。Vim 用户都知道,正是插件的缘故,通常每个用户使用 Vim 的工作方式都是独一无二的。一旦你安装和配置了正确的插件组合,你最不想要的局面就是再也找不到它们。 + +Vim-plug 有这个命令来生成一个脚本来恢复所有当前的插件: + +``` +:PlugSnapshot ~/vim-plug.list +``` +vim-plug 还有许多其他的功能,所以请参考它的[项目页面][7]以获得完整的文档。 + +### 打造一个完美的 Vim + +当你整天都在做一个项目时,你希望每一个小细节都能为你提供最好的服务。了解 Vim 和它的许多插件,直到你为你所做的事情构建出一个完美的应用程序。 + +有喜欢的 Vim 插件吗?请在评论中告诉我们吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/how-install-vim-plugins + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[qianmingtian][c] +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[c]: https://github.com/qianmingtian +[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.vim.org/ +[3]: https://opensource.com/article/19/12/colors-themes-vim +[4]: https://github.com/vim/vim/blob/03c3bd9fd094c1aede2e8fe3ad8fd25b9f033053/runtime/doc/repeat.txt#L515 +[5]: https://github.com/preservim/nerdtree +[6]: https://opensource.com/sites/default/files/uploads/vim-nerdtree.jpg (NERDTree plugin) +[7]: https://github.com/junegunn/vim-plug diff --git a/published/202002/20200219 Don-t like IDEs- Try grepgitvi.md b/published/202002/20200219 Don-t like IDEs- Try grepgitvi.md new file mode 100644 index 0000000000..7284c57f0f --- /dev/null +++ b/published/202002/20200219 Don-t like IDEs- Try grepgitvi.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11934-1.html) +[#]: subject: (Don't like IDEs? Try grepgitvi) +[#]: via: (https://opensource.com/article/20/2/no-ide-script) +[#]: author: (Yedidyah Bar David https://opensource.com/users/didib) + +不喜欢 IDE?试试看 grepgitvi +====== + +> 一个简单又原始的脚本来用 Vim 打开你选择的文件。 + +![](https://img.linux.net.cn/data/attachment/album/202002/26/113942a99a1aujmjpfnfrh.jpg) + +像大多数开发者一样,我整天都在搜索和阅读源码。就我个人而言,我从来没有习惯过集成开发环境 (IDE),多年来,我主要使用 `grep` (找到文件),并复制/粘贴文件名来打开 Vi(m)。 + +最终,我写了这个脚本,并根据需要缓慢地对其进行了完善。 + +它依赖 [Vim][2] 和 [rlwrap][3],并使用 Apache 2.0 许可证开源。要使用该脚本,请[将它放到 PATH 中][4],然后在文本目录下运行: + +``` +grepgitvi +``` + +它将返回搜索结果的编号列表,并提示你输入结果编号并打开 Vim。退出 Vim 后,它将再次显示列表,直到你输入除结果编号以外的任何内容。你也可以使用向上和向下箭头键选择一个文件。(这对我来说)更容易找到我已经看过的结果。 + +与现代 IDE 甚至与 Vim 的更复杂的用法相比,它简单而原始,但它对我有用。 + +### 脚本 + + +``` +#!/bin/bash + +# grepgitvi - grep source files, interactively open vim on results +# Doesn't really have to do much with git, other than ignoring .git +# +# Copyright Yedidyah Bar David 2019 +# +# SPDX-License-Identifier: Apache-2.0 +# +# Requires vim and rlwrap +# +# Usage: grepgitvi +# + +TMPD=$(mktemp -d /tmp/grepgitvi.XXXXXX) +UNCOLORED=${TMPD}/uncolored +COLORED=${TMPD}/colored + +RLHIST=${TMPD}/readline-history + +[ -z "${DIRS}" ] && DIRS=. + +cleanup() { + rm -rf "${TMPD}" +} + +trap cleanup 0 + +find ${DIRS} -iname .git -prune -o \! -iname "*.min.css*" -type f -print0 > ${TMPD}/allfiles + +cat ${TMPD}/allfiles | xargs -0 grep --color=always -n -H "$@" > $COLORED +cat ${TMPD}/allfiles | xargs -0 grep -n -H "$@" > $UNCOLORED + +max=`cat $UNCOLORED | wc -l` +pat="${@: -1}" + +inp='' +while true; do + echo "============================ grep results ===============================" + cat $COLORED | nl + echo "============================ grep results ===============================" + prompt="Enter a number between 1 and $max or anything else to quit: " + inp=$(rlwrap -H $RLHIST bash -c "read -p \"$prompt\" inp; echo \$inp") + if ! echo "$inp" | grep -q '^[0-9][0-9]*$' || [ "$inp" -gt "$max" ]; then + break + fi + + filename=$(cat $UNCOLORED | awk -F: "NR==$inp"' {print $1}') + linenum=$(cat $UNCOLORED | awk -F: "NR==$inp"' {print $2-1}') + vim +:"$linenum" +"norm zz" +/"${pat}" "$filename" +done +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/no-ide-script + +作者:[Yedidyah Bar David][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/didib +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/files_documents_paper_folder.png?itok=eIJWac15 (Files in a folder) +[2]: https://www.vim.org/ +[3]: https://linux.die.net/man/1/rlwrap +[4]: https://opensource.com/article/17/6/set-path-linux diff --git a/published/202002/20200219 How Kubernetes Became the Standard for Compute Resources.md b/published/202002/20200219 How Kubernetes Became the Standard for Compute Resources.md new file mode 100644 index 0000000000..3d1a903916 --- /dev/null +++ b/published/202002/20200219 How Kubernetes Became the Standard for Compute Resources.md @@ -0,0 +1,49 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11940-1.html) +[#]: subject: (How Kubernetes Became the Standard for Compute Resources) +[#]: via: (https://www.linux.com/articles/how-kubernetes-became-the-standard-for-compute-resources/) +[#]: author: (Swapnil Bhartiya https://www.linux.com/author/swapnil/) + +Kubernetes 如何成为计算资源的标准 +====== + +![](https://img.linux.net.cn/data/attachment/album/202002/28/131634mwzyylmv93m4ccws.jpg) + +对于原生云生态系统来说,2019 年是改变游戏规则的一年。有大的[并购][1],如 Red Hat Docker 和 Pivotal,并出现其他的玩家,如 Rancher Labs 和 Mirantis。 + +Rancher Labs (一家为采用容器的团队提供完整软件栈的公司)的联合创始人兼首席执行官盛亮表示:“所有这些整合和并购,都表明这一领域的市场成熟的速度很快。” + +传统上,像 Kubernetes 和 Docker 这样的新兴技术吸引着开发者和像脸书和谷歌这样的超级用户。除了这群人之外则没什么兴趣。然而,这两种技术都在企业层面得到了广泛采用。突然间,出现了一个巨大的市场,有着巨大的机会。几乎每个人都跳了进去。有人带来了创新的解决方案,也有人试图赶上其他人。它很快变得非常拥挤和热闹起来。 + +它也改变了创新的方式。[早期采用者通常是精通技术的公司][2]。现在,几乎每个人都在使用它,即使是在不被认为是 Kubernetes 地盘的地方。它改变了市场动态,像 Rancher Labs 这样的公司见证了独特的用例。 + +盛亮补充道,“我从来没有经历过像 Kubernete 这样快速、动态的市场或技术演变。当我们五年前开始的时候,这是一个非常拥挤的空间。随着时间的推移,我们大多数的友商因为这样或那样的原因消失了。他们要么无法适应变化,要么选择不适应某些变化。” + +在 Kubernetes 的早期,最明显的机会是建立 Kubernetes 发行版本和 Kubernetes 业务。这是新技术。众所周知,它的安装、升级和操作相当的复杂。 + +当谷歌、AWS 和微软进入市场时,一切都变了。当时,一群供应商蜂拥而至,为平台提供解决方案。盛亮表示:“一旦像谷歌这样的云提供商决定将 Kubernetes 作为一项服务,并免费提供亏本出售的商品,以推动基础设施消费;我们就知道,运营和支持 Kubernetes 业务的优势将非常有限了。” + +对谷歌之外的其它玩家来说,并非一切都不好。由于云供应商通过将它作为服务来提供,消除了 Kubernetes 带来的所有复杂性,这意味着更广泛地采用该技术,即使是那些由于运营成本而不愿使用该技术的人也是如此。这意味着 Kubernetes 将变得无处不在,并将成为一个行业标准。 + +“Rancher Labs 是极少数将此视为机遇并比其他公司看得更远的公司之一。我们意识到 Kubernetes 将成为新的计算标准,就像 TCP/IP 成为网络标准一样,”盛亮说。 + +CNCF 在围绕 Kubernetes 构建一个充满活力的生态系统方面发挥着至关重要的作用,创建了一个庞大的社区来构建、培育和商业化原生云开源技术。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/articles/how-kubernetes-became-the-standard-for-compute-resources/ + +作者:[Swapnil Bhartiya][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/author/swapnil/ +[b]: https://github.com/lujun9972 +[1]: https://www.cloudfoundry.org/blog/2019-is-the-year-of-consolidation-why-ibms-deal-with-red-hat-is-a-harbinger-of-things-to-come/ +[2]: https://www.packet.com/blog/open-source-season-on-the-kubernetes-highway/ diff --git a/published/202002/20200219 How to Install Latest Git Version on Ubuntu.md b/published/202002/20200219 How to Install Latest Git Version on Ubuntu.md new file mode 100644 index 0000000000..c05c0d3c02 --- /dev/null +++ b/published/202002/20200219 How to Install Latest Git Version on Ubuntu.md @@ -0,0 +1,128 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11929-1.html) +[#]: subject: (How to Install Latest Git Version on Ubuntu) +[#]: via: (https://itsfoss.com/install-git-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Ubuntu 上安装最新版本的 Git +====== + +在 Ubuntu 上安装 Git 非常容易。它存在于 [Ubuntu 的主仓库][1]中,你可以像这样[使用 apt 命令][2]安装它: + +``` +sudo apt install git +``` + +很简单?是不是? + +只有一点点小问题(这可能根本不是问题),就是它安装的 [Git][3] 版本。 + +在 LTS 系统上,软件稳定性至关重要,这就是为什么 Ubuntu 18.04 和其他发行版经常提供较旧但稳定的软件版本的原因,它们都经过发行版的良好测试。 + +这就是为什么当你检查 Git 版本时,会看到安装的版本会比 [Git 网站上当前最新 Git 版本][4]旧: + +``` +$ git --version +git version 2.17.1 +``` + +在编写本教程时,网站上提供的版本为 2.25。那么,如何在 Ubuntu 上安装最新的 Git? + +### 在基于 Ubuntu 的 Linux 发行版上安装最新的 Git + +![][5] + +一种方法是[从源代码安装][6]。这种很酷又老派的方法不适合所有人。值得庆幸的是,Ubuntu Git 维护团队提供了 [PPA][7],莫可以使用它轻松地安装最新的稳定 Git 版本。 + +``` +sudo add-apt-repository ppa:git-core/ppa +sudo apt update +sudo apt install git +``` + +即使你以前使用 `apt` 安装了 Git,它也将更新为最新的稳定版本。 + +``` +$ git --version +git version 2.25.0 +``` + +[使用PPA][8] 的好处在于,如果发布了新的 Git 稳定版本,那么就可以通过系统更新获得它。[仅更新 Ubuntu][9] 来获取最新的 Git 稳定版本。 + +### 配置 Git (推荐给开发者) + +如果你出于开发目的安装了 Git,你会很快开始克隆仓库,进行更改并提交更改。 + +如果你尝试提交代码,那么你可能会看到 “Please tell me who you are” 这样的错误: + +``` +$ git commit -m "update readme" + +*** Please tell me who you are. + +Run + + git config --global user.email "you@example.com" + git config --global user.name "Your Name" + +to set your account's default identity. +Omit --global to set the identity only in this repository. + +fatal: unable to auto-detect email address (got 'abhishek@itsfoss.(none)') +``` + +这是因为你还没配置必要的个人信息。 + +正如错误已经暗示的那样,你可以像这样设置全局 Git 配置: + +``` +git config --global user.name "Your Name" +git config --global user.email "you@example.com" +``` + +你可以使用以下命令检查 Git 配置: + +``` +git config --list +``` + +它应该显示如下输出: + +``` +user.email=you@example.com +user.name=Your Name +``` + +配置保存在 `~/.gitconfig` 中。你可以手动修改配置。 + +### 结尾 + +我希望这个小教程可以帮助你在 Ubuntu 上安装 Git。使用 PPA,你可以轻松获得最新的 Git 版本。 + +如果你有任何疑问或建议,请随时在评论部分提问。也欢迎直接写“谢谢” :) + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-git-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/ubuntu-repositories/ +[2]: https://itsfoss.com/apt-command-guide/ +[3]: https://git-scm.com/ +[4]: https://git-scm.com/downloads +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/install_git_ubuntu.png?ssl=1 +[6]: https://itsfoss.com/install-software-from-source-code/ +[7]: https://launchpad.net/~git-core/+archive/ubuntu/ppa +[8]: https://itsfoss.com/ppa-guide/ +[9]: https://itsfoss.com/update-ubuntu/ diff --git a/published/202002/20200220 Using Python and GNU Octave to plot data.md b/published/202002/20200220 Using Python and GNU Octave to plot data.md new file mode 100644 index 0000000000..5f2b7dba66 --- /dev/null +++ b/published/202002/20200220 Using Python and GNU Octave to plot data.md @@ -0,0 +1,483 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11943-1.html) +[#]: subject: (Using Python and GNU Octave to plot data) +[#]: via: (https://opensource.com/article/20/2/python-gnu-octave-data-science) +[#]: author: (Cristiano L. Fontana https://opensource.com/users/cristianofontana) + +使用 Python 和 GNU Octave 绘制数据 +====== + +> 了解如何使用 Python 和 GNU Octave 完成一项常见的数据科学任务。 + +![](https://img.linux.net.cn/data/attachment/album/202002/29/114750tr7qykssk90yrvyz.jpg) + +数据科学是跨越编程语言的知识领域。有些语言以解决这一领域的问题而闻名,而另一些则鲜为人知。这篇文章将帮助你熟悉用一些流行的语言完成数据科学的工作。 + +### 选择 Python 和 GNU Octave 做数据科学工作 + +我经常尝试学习一种新的编程语言。为什么?这既有对旧方式的厌倦,也有对新方式的好奇。当我开始学习编程时,我唯一知道的语言是 C 语言。那些年的编程生涯既艰难又危险,因为我必须手动分配内存、管理指针、并记得释放内存。 + +后来一个朋友建议我试试 Python,现在我的编程生活变得轻松多了。虽然程序运行变得慢多了,但我不必通过编写分析软件来受苦了。然而,我很快就意识到每种语言都有比其它语言更适合自己的应用场景。后来我学习了一些其它语言,每种语言都给我带来了一些新的启发。发现新的编程风格让我可以将一些解决方案移植到其他语言中,这样一切都变得有趣多了。 + +为了对一种新的编程语言(及其文档)有所了解,我总是从编写一些执行我熟悉的任务的示例程序开始。为此,我将解释如何用 Python 和 GNU Octave 编写一个程序来完成一个你可以归类为数据科学的特殊任务。如果你已经熟悉其中一种语言,从它开始,然后通过其他语言寻找相似之处和不同之处。这篇文章并不是对编程语言的详尽比较,只是一个小小的展示。 + +所有的程序都应该在[命令行][2]上运行,而不是用[图形用户界面][3](GUI)。完整的例子可以在 [polyglot_fit 存储库][4]中找到。 + +### 编程任务 + +你将在本系列中编写的程序: + + * 从 [CSV 文件][5]中读取数据 + * 用直线插入数据(例如 `f(x)=m ⋅ x + q`) + * 将结果生成图像文件 + +这是许多数据科学家遇到的常见情况。示例数据是 [Anscombe 的四重奏][6]的第一组,如下表所示。这是一组人工构建的数据,当用直线拟合时会给出相同的结果,但是它们的曲线非常不同。数据文件是一个文本文件,以制表符作为列分隔符,开头几行作为标题。此任务将仅使用第一组(即前两列)。 + +![](https://img.linux.net.cn/data/attachment/album/202002/29/122805h3yrs1dkrgysssxk.png) + +### Python 方式 + +[Python][7] 是一种通用编程语言,是当今最流行的语言之一(依据 [TIOBE 指数][8]、[RedMonk 编程语言排名][9]、[编程语言流行指数][10]、[GitHub Octoverse 状态][11]和其他来源的调查结果)。它是一种[解释型语言][12];因此,源代码由执行该指令的程序读取和评估。它有一个全面的[标准库][13]并且总体上非常好用(我对这最后一句话没有证据;这只是我的拙见)。 + +#### 安装 + +要使用 Python 开发,你需要解释器和一些库。最低要求是: + +* [NumPy][14] 用于简化数组和矩阵的操作 +* [SciPy][15] 用于数据科学 +* [Matplotlib][16] 用于绘图 + +在 [Fedora][17] 安装它们是很容易的: + +``` +sudo dnf install python3 python3-numpy python3-scipy python3-matplotlib +``` + +#### 代码注释 + +在 Python中,[注释][18]是通过在行首添加一个 `#` 来实现的,该行的其余部分将被解释器丢弃: + +``` +# 这是被解释器忽略的注释。 +``` + +[fitting_python.py][19] 示例使用注释在源代码中插入许可证信息,第一行是[特殊注释][20],它允许该脚本在命令行上执行: + +``` +#!/usr/bin/env python3 +``` + +这一行通知命令行解释器,该脚本需要由程序 `python3` 执行。 + +#### 需要的库 + +在 Python 中,库和模块可以作为一个对象导入(如示例中的第一行),其中包含库的所有函数和成员。可以通过使用 `as` 方式用自定义标签重命名它们: + +``` +import numpy as np +from scipy import stats +import matplotlib.pyplot as plt +``` + +你也可以决定只导入一个子模块(如第二行和第三行)。语法有两个(基本上)等效的方式:`import module.submodule` 和 `from module import submodule`。 + +#### 定义变量 + +Python 的变量是在第一次赋值时被声明的: + +``` +input_file_name = "anscombe.csv" +delimiter = "\t" +skip_header = 3 +column_x = 0 +column_y = 1 +``` + +变量类型由分配给变量的值推断。没有具有常量值的变量,除非它们在模块中声明并且只能被读取。习惯上,不应被修改的变量应该用大写字母命名。 + +#### 打印输出 + +通过命令行运行程序意味着输出只能打印在终端上。Python 有 [print()][21] 函数,默认情况下,该函数打印其参数,并在输出的末尾添加一个换行符: + +``` +print("#### Anscombe's first set with Python ####") +``` + +在 Python 中,可以将 `print()` 函数与[字符串类][23]的[格式化能力][22]相结合。字符串具有`format` 方法,可用于向字符串本身添加一些格式化文本。例如,可以添加格式化的浮点数,例如: + +``` +print("Slope: {:f}".format(slope)) +``` + +#### 读取数据 + +使用 NumPy 和函数 [genfromtxt()][24] 读取 CSV 文件非常容易,该函数生成 [NumPy 数组][25]: + +``` +data = np.genfromtxt(input_file_name, delimiter = delimiter, skip_header = skip_header) +``` + +在 Python 中,一个函数可以有数量可变的参数,你可以通过指定所需的参数来传递一个参数的子集。数组是非常强大的矩阵状对象,可以很容易地分割成更小的数组: + +``` +x = data[:, column_x] +y = data[:, column_y] +``` + +冒号选择整个范围,也可以用来选择子范围。例如,要选择数组的前两行,可以使用: + +``` +first_two_rows = data[0:1, :] +``` + +#### 拟合数据 + +SciPy 提供了方便的数据拟合功能,例如 [linregress()][26] 功能。该函数提供了一些与拟合相关的重要值,如斜率、截距和两个数据集的相关系数: + +``` +slope, intercept, r_value, p_value, std_err = stats.linregress(x, y) + +print("Slope: {:f}".format(slope)) +print("Intercept: {:f}".format(intercept)) +print("Correlation coefficient: {:f}".format(r_value)) +``` + +因为 `linregress()` 提供了几条信息,所以结果可以同时保存到几个变量中。 + +#### 绘图 + +Matplotlib 库仅仅绘制数据点,因此,你应该定义要绘制的点的坐标。已经定义了 `x` 和 `y` 数组,所以你可以直接绘制它们,但是你还需要代表直线的数据点。 + +``` +fit_x = np.linspace(x.min() - 1, x.max() + 1, 100) +``` + +[linspace()][27] 函数可以方便地在两个值之间生成一组等距值。利用强大的 NumPy 数组可以轻松计算纵坐标,该数组可以像普通数值变量一样在公式中使用: + +``` +fit_y = slope * fit_x + intercept +``` + +该公式在数组中逐元素应用;因此,结果在初始数组中具有相同数量的条目。 + +要绘图,首先,定义一个包含所有图形的[图形对象][28]: + +``` +fig_width = 7 #inch +fig_height = fig_width / 16 * 9 #inch +fig_dpi = 100 + +fig = plt.figure(figsize = (fig_width, fig_height), dpi = fig_dpi) +``` + +一个图形可以画几个图;在 Matplotlib 中,这些图被称为[轴][29]。本示例定义一个单轴对象来绘制数据点: + +``` +ax = fig.add_subplot(111) + +ax.plot(fit_x, fit_y, label = "Fit", linestyle = '-') +ax.plot(x, y, label = "Data", marker = '.', linestyle = '') + +ax.legend() +ax.set_xlim(min(x) - 1, max(x) + 1) +ax.set_ylim(min(y) - 1, max(y) + 1) +ax.set_xlabel('x') +ax.set_ylabel('y') +``` + +将该图保存到 [PNG 图形文件][30]中,有: + +``` +fig.savefig('fit_python.png') +``` + +如果要显示(而不是保存)该绘图,请调用: + +``` +plt.show() +``` + +此示例引用了绘图部分中使用的所有对象:它定义了对象 `fig` 和对象 `ax`。这在技术上是不必要的,因为 `plt` 对象可以直接用于绘制数据集。《[Matplotlib 教程][31]》展示了这样一个接口: + +``` +plt.plot(fit_x, fit_y) +``` + +坦率地说,我不喜欢这种方法,因为它隐藏了各种对象之间发生的重要交互。不幸的是,有时[官方的例子][32]有点令人困惑,因为他们倾向于使用不同的方法。在这个简单的例子中,引用图形对象是不必要的,但是在更复杂的例子中(例如在图形用户界面中嵌入图形时),引用图形对象就变得很重要了。 + +#### 结果 + +命令行输入: + +``` +#### Anscombe's first set with Python #### +Slope: 0.500091 +Intercept: 3.000091 +Correlation coefficient: 0.816421 +``` + +这是 Matplotlib 产生的图像: + +![Plot and fit of the dataset obtained with Python][33] + +### GNU Octave 方式 + +[GNU Octave][34] 语言主要用于数值计算。它提供了一个简单的操作向量和矩阵的语法,并且有一些强大的绘图工具。这是一种像 Python 一样的解释语言。由于 Octave 的语法[几乎兼容][35] [MATLAB][36],它经常被描述为一个替代 MATLAB 的免费方案。Octave 没有被列为最流行的编程语言,而 MATLAB 则是,所以 Octave 在某种意义上是相当流行的。MATLAB 早于 NumPy,我觉得它是受到了前者的启发。当你看这个例子时,你会看到相似之处。 + +#### 安装 + +[fitting_octave.m][37] 的例子只需要基本的 Octave 包,在 Fedora 中安装相当简单: + +``` +sudo dnf install octave +``` + +#### 代码注释 + +在 Octave 中,你可以用百分比符号(`%`)为代码添加注释,如果不需要与 MATLAB 兼容,你也可以使用 `#`。使用 `#` 的选项允许你编写像 Python 示例一样的特殊注释行,以便直接在命令行上执行脚本。 + +#### 必要的库 + +本例中使用的所有内容都包含在基本包中,因此你不需要加载任何新的库。如果你需要一个库,[语法][38]是 `pkg load module`。该命令将模块的功能添加到可用功能列表中。在这方面,Python 具有更大的灵活性。 + +#### 定义变量 + +变量的定义与 Python 的语法基本相同: + +``` +input_file_name = "anscombe.csv"; +delimiter = "\t"; +skip_header = 3; +column_x = 1; +column_y = 2; +``` + +请注意,行尾有一个分号;这不是必需的,但是它会抑制该行结果的输出。如果没有分号,解释器将打印表达式的结果: + +``` +octave:1> input_file_name = "anscombe.csv" +input_file_name = anscombe.csv +octave:2> sqrt(2) +ans = 1.4142 +``` + +#### 打印输出结果 + +强大的函数 [printf()][39] 是用来在终端上打印的。与 Python 不同,`printf()` 函数不会自动在打印字符串的末尾添加换行,因此你必须添加它。第一个参数是一个字符串,可以包含要传递给函数的其他参数的格式信息,例如: + +``` +printf("Slope: %f\n", slope); +``` + +在 Python 中,格式是内置在字符串本身中的,但是在 Octave 中,它是特定于 `printf()` 函数。 + +#### 读取数据 + +[dlmread()][40] 函数可以读取类似 CSV 文件的文本内容: + +``` +data = dlmread(input_file_name, delimiter, skip_header, 0); +``` + +结果是一个[矩阵][41]对象,这是 Octave 中的基本数据类型之一。矩阵可以用类似于 Python 的语法进行切片: + +``` +x = data(:, column_x); +y = data(:, column_y); +``` + +根本的区别是索引从 1 开始,而不是从 0 开始。因此,在该示例中,`x` 列是第一列。 + +#### 拟合数据 + +要用直线拟合数据,可以使用 [polyfit()][42] 函数。它用一个多项式拟合输入数据,所以你只需要使用一阶多项式: + +``` +p = polyfit(x, y, 1); + +slope = p(1); +intercept = p(2); +``` + +结果是具有多项式系数的矩阵;因此,它选择前两个索引。要确定相关系数,请使用 [corr()][43] 函数: + +``` +r_value = corr(x, y); +``` + +最后,使用 `printf()` 函数打印结果: + +``` +printf("Slope: %f\n", slope); +printf("Intercept: %f\n", intercept); +printf("Correlation coefficient: %f\n", r_value); +``` + +#### 绘图 + +与 Matplotlib 示例一样,首先需要创建一个表示拟合直线的数据集: + +``` +fit_x = linspace(min(x) - 1, max(x) + 1, 100); +fit_y = slope * fit_x + intercept; +``` + +与 NumPy 的相似性也很明显,因为它使用了 [linspace()][44] 函数,其行为就像 Python 的等效版本一样。 + +同样,与 Matplotlib 一样,首先创建一个[图][45]对象,然后创建一个[轴][46]对象来保存这些图: + +``` +fig_width = 7; %inch +fig_height = fig_width / 16 * 9; %inch +fig_dpi = 100; + +fig = figure("units", "inches", +             "position", [1, 1, fig_width, fig_height]); + +ax = axes("parent", fig); + +set(ax, "fontsize", 14); +set(ax, "linewidth", 2); +``` + +要设置轴对象的属性,请使用 [set()][47] 函数。然而,该接口相当混乱,因为该函数需要一个逗号分隔的属性和值对列表。这些对只是代表属性名的一个字符串和代表该属性值的第二个对象的连续。还有其他设置各种属性的函数: + +``` +xlim(ax, [min(x) - 1, max(x) + 1]); +ylim(ax, [min(y) - 1, max(y) + 1]); +xlabel(ax, 'x'); +ylabel(ax, 'y'); +``` + +绘图是用 [plot()][48] 功能实现的。默认行为是每次调用都会重置坐标轴,因此需要使用函数 [hold()][49]。 + +``` +hold(ax, "on"); + +plot(ax, fit_x, fit_y, +     "marker", "none", +     "linestyle", "-", +     "linewidth", 2); +plot(ax, x, y, +     "marker", ".", +     "markersize", 20, +     "linestyle", "none"); + +hold(ax, "off"); +``` + +此外,还可以在 `plot()` 函数中添加属性和值对。[legend][50] 必须单独创建,标签应手动声明: + +``` +lg = legend(ax, "Fit", "Data"); +set(lg, "location", "northwest"); +``` + +最后,将输出保存到 PNG 图像: + +``` +image_size = sprintf("-S%f,%f", fig_width * fig_dpi, fig_height * fig_dpi); +image_resolution = sprintf("-r%f,%f", fig_dpi); + +print(fig, 'fit_octave.png', +      '-dpng', +      image_size, +      image_resolution); +``` + +令人困惑的是,在这种情况下,选项被作为一个字符串传递,带有属性名和值。因为在 Octave 字符串中没有 Python 的格式化工具,所以必须使用 [sprintf()][51] 函数。它的行为就像 `printf()` 函数,但是它的结果不是打印出来的,而是作为字符串返回的。 + +在这个例子中,就像在 Python 中一样,图形对象很明显被引用以保持它们之间的交互。如果说 Python 在这方面的文档有点混乱,那么 [Octave 的文档][52]就更糟糕了。我发现的大多数例子都不关心引用对象;相反,它们依赖于绘图命令作用于当前活动图形。全局[根图形对象][53]跟踪现有的图形和轴。 + +#### 结果 + +命令行上的结果输出是: + +``` +#### Anscombe's first set with Octave #### +Slope: 0.500091 +Intercept: 3.000091 +Correlation coefficient: 0.816421 +``` + +它显示了用 Octave 生成的结果图像。 + +![Plot and fit of the dataset obtained with Octave][54] + +###接下来 + +Python 和 GNU Octave 都可以绘制出相同的信息,尽管它们的实现方式不同。如果你想探索其他语言来完成类似的任务,我强烈建议你看看 [Rosetta Code][55]。这是一个了不起的资源,可以看到如何用多种语言解决同样的问题。 + +你喜欢用什么语言绘制数据?在评论中分享你的想法。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/python-gnu-octave-data-science + +作者:[Cristiano L. Fontana][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[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/analytics-graphs-charts.png?itok=sersoqbV (Analytics: Charts and Graphs) +[2]: https://en.wikipedia.org/wiki/Command-line_interface +[3]: https://en.wikipedia.org/wiki/Graphical_user_interface +[4]: https://gitlab.com/cristiano.fontana/polyglot_fit +[5]: https://en.wikipedia.org/wiki/Comma-separated_values +[6]: https://en.wikipedia.org/wiki/Anscombe%27s_quartet +[7]: https://www.python.org/ +[8]: https://www.tiobe.com/tiobe-index/ +[9]: https://redmonk.com/sogrady/2019/07/18/language-rankings-6-19/ +[10]: http://pypl.github.io/PYPL.html +[11]: https://octoverse.github.com/ +[12]: https://en.wikipedia.org/wiki/Interpreted_language +[13]: https://docs.python.org/3/library/ +[14]: https://numpy.org/ +[15]: https://www.scipy.org/ +[16]: https://matplotlib.org/ +[17]: https://getfedora.org/ +[18]: https://en.wikipedia.org/wiki/Comment_(computer_programming) +[19]: https://gitlab.com/cristiano.fontana/polyglot_fit/-/blob/master/fitting_python.py +[20]: https://en.wikipedia.org/wiki/Shebang_(Unix) +[21]: https://docs.python.org/3/library/functions.html#print +[22]: https://docs.python.org/3/library/string.html#string-formatting +[23]: https://docs.python.org/3/library/string.html +[24]: https://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html +[25]: https://docs.scipy.org/doc/numpy/reference/generated/numpy.array.html +[26]: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.linregress.html +[27]: https://docs.scipy.org/doc/numpy/reference/generated/numpy.linspace.html +[28]: https://matplotlib.org/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure +[29]: https://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes +[30]: https://en.wikipedia.org/wiki/Portable_Network_Graphics +[31]: https://matplotlib.org/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py +[32]: https://matplotlib.org/gallery/index.html +[33]: https://opensource.com/sites/default/files/uploads/fit_python.png (Plot and fit of the dataset obtained with Python) +[34]: https://www.gnu.org/software/octave/ +[35]: https://wiki.octave.org/FAQ#Differences_between_Octave_and_Matlab +[36]: https://en.wikipedia.org/wiki/MATLAB +[37]: https://gitlab.com/cristiano.fontana/polyglot_fit/-/blob/master/fitting_octave.m +[38]: https://octave.org/doc/v5.1.0/Using-Packages.html#Using-Packages +[39]: https://octave.org/doc/v5.1.0/Formatted-Output.html#XREFprintf +[40]: https://octave.org/doc/v5.1.0/Simple-File-I_002fO.html#XREFdlmread +[41]: https://octave.org/doc/v5.1.0/Matrices.html +[42]: https://octave.org/doc/v5.1.0/Polynomial-Interpolation.html +[43]: https://octave.org/doc/v5.1.0/Correlation-and-Regression-Analysis.html#XREFcorr +[44]: https://octave.sourceforge.io/octave/function/linspace.html +[45]: https://octave.org/doc/v5.1.0/Multiple-Plot-Windows.html +[46]: https://octave.org/doc/v5.1.0/Graphics-Objects.html#XREFaxes +[47]: https://octave.org/doc/v5.1.0/Graphics-Objects.html#XREFset +[48]: https://octave.org/doc/v5.1.0/Two_002dDimensional-Plots.html#XREFplot +[49]: https://octave.org/doc/v5.1.0/Manipulation-of-Plot-Windows.html#XREFhold +[50]: https://octave.org/doc/v5.1.0/Plot-Annotations.html#XREFlegend +[51]: https://octave.org/doc/v5.1.0/Formatted-Output.html#XREFsprintf +[52]: https://octave.org/doc/v5.1.0/Two_002dDimensional-Plots.html#Two_002dDimensional-Plots +[53]: https://octave.org/doc/v5.1.0/Graphics-Objects.html#XREFgroot +[54]: https://opensource.com/sites/default/files/uploads/fit_octave.png (Plot and fit of the dataset obtained with Octave) +[55]: http://www.rosettacode.org/ diff --git a/published/20200220 Tools for SSH key management.md b/published/20200220 Tools for SSH key management.md new file mode 100644 index 0000000000..9331cf701f --- /dev/null +++ b/published/20200220 Tools for SSH key management.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11947-1.html) +[#]: subject: (Tools for SSH key management) +[#]: via: (https://opensource.com/article/20/2/ssh-tools) +[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall) + +SSH 密钥管理工具 +====== + +> 常用开源工具的省时快捷方式。 + +![](https://img.linux.net.cn/data/attachment/album/202003/01/122336zyldgpse6eyrbymt.jpg) + +我经常使用 SSH。我发现自己每天都要登录多个服务器和树莓派(与我位于同一房间,并接入互联网)。我有许多设备需要访问,并且获得访问权限的要求也不同,因此,除了使用各种 `ssh` / `scp` 命令选项之外,我还必须维护一个包含所有连接详细信息的配置文件。 + +随着时间的推移,我发现了一些省时的技巧和工具,你可能也会发现它们有用。 + +### SSH 密钥 + +SSH 密钥是一种在不使用密码的情况下认证 SSH 连接的方法,可以用来加快访问速度或作为一种安全措施(如果你关闭了密码访问权限并确保仅允许授权的密钥)。要创建 SSH 密钥,请运行以下命令: + +``` +$ ssh-keygen +``` + +这将在 `~/.ssh/` 中创建一个密钥对(公钥和私钥)。将私钥(`id_rsa`)保留在 PC 上,切勿共享。你可以与其他人共享公钥(`id_rsa.pub`)或将其放置在其他服务器上。 + +### ssh-copy-id + +如果我在家中或公司工作时使用树莓派,则倾向于将 SSH 设置保留为默认设置,因为我不担心内部信任网络上的安全性,并且通常将 SSH 密钥(公钥)复制到树莓派上,以避免每次都使用密码进行身份验证。为此,我使用 `ssh-copy-id` 命令将其复制到树莓派。这会自动将你的密钥(公钥)添加到树莓派: + +``` +$ ssh-copy-id pi@192.168.1.20 +``` + +在生产服务器上,我倾向于关闭密码身份验证,仅允许授权的 SSH 密钥登录。 + +### ssh-import-id + +另一个类似的工具是 `ssh-import-id`。你可以使用此方法通过从 GitHub 导入密钥来授予你自己(或其他人)对计算机或服务器的访问权限。例如,我已经在我的 GitHub 帐户中注册了各个 SSH 密钥,因此无需密码即可推送到 GitHub。这些公钥是有效的,因此 `ssh-import-id` 可以使用它们在我的任何计算机上授权我: + +``` +$ ssh-import-id gh:bennuttall +``` + +我还可以使用它来授予其他人访问服务器的权限,而无需询问他们的密钥: + +``` +$ ssh-import-id gh:waveform80 +``` + +### storm + +我还使用了名为 Storm 的工具,该工具可帮助你将 SSH 连接添加到 SSH 配置中,因此你不必记住这些连接细节信息。你可以使用 `pip` 安装它: + +``` +$ sudo pip3 install stormssh +``` + +然后,你可以使用以下命令将 SSH 连接信息添加到配置中: + +``` +$ storm add pi3 pi@192.168.1.20 +``` + +然后,你可以只使用 `ssh pi3` 来获得访问权限。类似的还有 `scp file.txt pi3:` 或 `sshfs pi pi3:`。 + +你还可以使用更多的 SSH 选项,例如端口号: + +``` +$ storm add pi3 pi@192.168.1.20:2000 +``` + +你可以参考 Storm 的[文档][2]轻松列出、搜索和编辑已保存的连接。Storm 实际所做的只是管理 SSH 配置文件 `~/.ssh/config` 中的项目。一旦了解了它们是如何存储的,你就可以选择手动编辑它们。配置中的示例连接如下所示: + +``` +Host pi3 +   user pi +   hostname 192.168.1.20 +   port 22 +``` + +### 结论 + +从树莓派到大型的云基础设施,SSH 是系统管理的重要工具。熟悉密钥管理会很方便。你还有其他 SSH 技巧要添加吗?我希望你在评论中分享他们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/ssh-tools + +作者:[Ben Nuttall][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/bennuttall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_BUS_Apple_520.png?itok=ZJu-hBV1 (collection of hardware on blue backround) +[2]: https://stormssh.readthedocs.io/en/stable/usage.html diff --git a/published/20200224 Using C and C-- for data science.md b/published/20200224 Using C and C-- for data science.md new file mode 100644 index 0000000000..f1dfdce174 --- /dev/null +++ b/published/20200224 Using C and C-- for data science.md @@ -0,0 +1,514 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11950-1.html) +[#]: subject: (Using C and C++ for data science) +[#]: via: (https://opensource.com/article/20/2/c-data-science) +[#]: author: (Cristiano L. Fontana https://opensource.com/users/cristianofontana) + +在数据科学中使用 C 和 C++ +====== + +> 让我们使用 C99 和 C++11 完成常见的数据科学任务。 + +![metrics and data shown on a computer screen][1] + +虽然 [Python][2] 和 [R][3] 之类的语言在数据科学中越来越受欢迎,但是 C 和 C++ 对于高效的数据科学来说是一个不错的选择。在本文中,我们将使用 [C99][4] 和 [C++11][5] 编写一个程序,该程序使用 [Anscombe 的四重奏][6]数据集,下面将对其进行解释。 + +我在一篇涉及 [Python 和 GNU Octave][7] 的文章中写了我不断学习编程语言的动机,值得大家回顾。这里所有的程序都需要在[命令行][8]上运行,而不是在[图形用户界面(GUI)][9]上运行。完整的示例可在 [polyglot_fit 存储库][10]中找到。 + +### 编程任务 + +你将在本系列中编写的程序: + +* 从 [CSV 文件][11]中读取数据 +* 用直线插值数据(即 `f(x)=m ⋅ x + q`) +* 将结果绘制到图像文件 + +这是许多数据科学家遇到的普遍情况。示例数据是 [Anscombe 的四重奏][6]的第一组,如下表所示。这是一组人工构建的数据,当拟合直线时可以提供相同的结果,但是它们的曲线非常不同。数据文件是一个文本文件,其中的制表符用作列分隔符,前几行作为标题。该任务将仅使用第一组(即前两列)。 + +![](https://img.linux.net.cn/data/attachment/album/202002/29/122805h3yrs1dkrgysssxk.png) + +### C 语言的方式 + +[C][12] 语言是通用编程语言,是当今使用最广泛的语言之一(依据 [TIOBE 指数][13]、[RedMonk 编程语言排名][14]、[编程语言流行度指数][15]和 [GitHub Octoverse 状态][16] 得来)。这是一种相当古老的语言(大约诞生在 1973 年),并且用它编写了许多成功的程序(例如 Linux 内核和 Git 仅是其中的两个例子)。它也是最接近计算机内部运行机制的语言之一,因为它直接用于操作内存。它是一种[编译语言][17];因此,源代码必须由[编译器][18]转换为[机器代码][19]。它的[标准库][20]很小,功能也不多,因此人们开发了其它库来提供缺少的功能。 + +我最常在[数字运算][21]中使用该语言,主要是因为其性能。我觉得使用起来很繁琐,因为它需要很多[样板代码][22],但是它在各种环境中都得到了很好的支持。C99 标准是最新版本,增加了一些漂亮的功能,并且得到了编译器的良好支持。 + +我将一路介绍 C 和 C++ 编程的必要背景,以便初学者和高级用户都可以继续学习。 + +#### 安装 + +要使用 C99 进行开发,你需要一个编译器。我通常使用 [Clang][23],不过 [GCC][24] 是另一个有效的开源编译器。对于线性拟合,我选择使用 [GNU 科学库][25]。对于绘图,我找不到任何明智的库,因此该程序依赖于外部程序:[Gnuplot][26]。该示例还使用动态数据结构来存储数据,该结构在[伯克利软件分发版(BSD)][27]中定义。 + +在 [Fedora][28] 中安装很容易: + +``` +sudo dnf install clang gnuplot gsl gsl-devel +``` + +#### 代码注释 + +在 C99 中,[注释][29]的格式是在行的开头放置 `//`,行的其它部分将被解释器丢弃。另外,`/*` 和 `*/` 之间的任何内容也将被丢弃。 + +``` +// 这是一个注释,会被解释器忽略 +/* 这也被忽略 */ +``` + +#### 必要的库 + +库由两部分组成: + +* [头文件][30],其中包含函数说明 +* 包含函数定义的源文件 + +头文件包含在源文件中,而库文件的源文件则[链接][31]到可执行文件。因此,此示例所需的头文件是: + +``` +// 输入/输出功能 +#include +// 标准库 +#include +// 字符串操作功能 +#include +// BSD 队列 +#include +// GSL 科学功能 +#include +#include +``` + +#### 主函数 + +在 C 语言中,程序必须位于称为主函数 [main()][32] 的特殊函数内: + +``` +int main(void) { +    ... +} +``` + +这与上一教程中介绍的 Python 不同,后者将运行在源文件中找到的所有代码。 + +#### 定义变量 + +在 C 语言中,变量必须在使用前声明,并且必须与类型关联。每当你要使用变量时,都必须决定要在其中存储哪种数据。你也可以指定是否打算将变量用作常量值,这不是必需的,但是编译器可以从此信息中受益。 以下来自存储库中的 [fitting_C99.c 程序][33]: + +``` +const char *input_file_name = "anscombe.csv"; +const char *delimiter = "\t"; +const unsigned int skip_header = 3; +const unsigned int column_x = 0; +const unsigned int column_y = 1; +const char *output_file_name = "fit_C99.csv"; +const unsigned int N = 100; +``` + +C 语言中的数组不是动态的,从某种意义上说,数组的长度必须事先确定(即,在编译之前): + +``` +int data_array[1024]; +``` + +由于你通常不知道文件中有多少个数据点,因此请使用[单链列表][34]。这是一个动态数据结构,可以无限增长。幸运的是,BSD [提供了链表][35]。这是一个示例定义: + +``` +struct data_point { + double x; + double y; + + SLIST_ENTRY(data_point) entries; +}; + +SLIST_HEAD(data_list, data_point) head = SLIST_HEAD_INITIALIZER(head); +SLIST_INIT(&head); +``` + +该示例定义了一个由结构化值组成的 `data_point` 列表,该结构化值同时包含 `x` 值和 `y` 值。语法相当复杂,但是很直观,详细描述它就会太冗长了。 + +#### 打印输出 + +要在终端上打印,可以使用 [printf()][36] 函数,其功能类似于 Octave 的 `printf()` 函数(在第一篇文章中介绍): + +``` +printf("#### Anscombe's first set with C99 ####\n"); +``` + +`printf()` 函数不会在打印字符串的末尾自动添加换行符,因此你必须添加换行符。第一个参数是一个字符串,可以包含传递给函数的其他参数的格式信息,例如: + +``` +printf("Slope: %f\n", slope); +``` + +#### 读取数据 + +现在来到了困难的部分……有一些用 C 语言解析 CSV 文件的库,但是似乎没有一个库足够稳定或流行到可以放入到 Fedora 软件包存储库中。我没有为本教程添加依赖项,而是决定自己编写此部分。同样,讨论这些细节太啰嗦了,所以我只会解释大致的思路。为了简洁起见,将忽略源代码中的某些行,但是你可以在存储库中找到完整的示例代码。 + +首先,打开输入文件: + +``` +FILE* input_file = fopen(input_file_name, "r"); +``` + +然后逐行读取文件,直到出现错误或文件结束: + +``` +while (!ferror(input_file) && !feof(input_file)) { + size_t buffer_size = 0; + char *buffer = NULL; + + getline(&buffer, &buffer_size, input_file); + + ... +} +``` + +[getline()][39] 函数是 [POSIX.1-2008 标准][40]新增的一个不错的函数。它可以读取文件中的整行,并负责分配必要的内存。然后使用 [strtok()][42] 函数将每一行分成[字元][41]token。遍历字元,选择所需的列: + +``` +char *token = strtok(buffer, delimiter); + +while (token != NULL) +{ + double value; + sscanf(token, "%lf", &value); + + if (column == column_x) { + x = value; + } else if (column == column_y) { + y = value; + } + + column += 1; + token = strtok(NULL, delimiter); +} +``` + +最后,当选择了 `x` 和 `y` 值时,将新数据点插入链表中: + +``` +struct data_point *datum = malloc(sizeof(struct data_point)); +datum->x = x; +datum->y = y; + +SLIST_INSERT_HEAD(&head, datum, entries); +``` + +[malloc()][46] 函数为新数据点动态分配(保留)一些持久性内存。 + +#### 拟合数据 + +GSL 线性拟合函数 [gsl_fit_linear()][47] 期望其输入为简单数组。因此,由于你将不知道要创建的数组的大小,因此必须手动分配它们的内存: + +``` +const size_t entries_number = row - skip_header - 1; + +double *x = malloc(sizeof(double) * entries_number); +double *y = malloc(sizeof(double) * entries_number); +``` + +然后,遍历链表以将相关数据保存到数组: + +``` +SLIST_FOREACH(datum, &head, entries) { + const double current_x = datum->x; + const double current_y = datum->y; + + x[i] = current_x; + y[i] = current_y; + + i += 1; +} +``` + +现在你已经处理完了链表,请清理它。要**总是**释放已手动分配的内存,以防止[内存泄漏][48]。内存泄漏是糟糕的、糟糕的、糟糕的(重要的话说三遍)。每次内存没有释放时,花园侏儒都会找不到自己的头: + +``` +while (!SLIST_EMPTY(&head)) { + struct data_point *datum = SLIST_FIRST(&head); + + SLIST_REMOVE_HEAD(&head, entries); + + free(datum); +} +``` + +终于,终于!你可以拟合你的数据了: + +``` +gsl_fit_linear(x, 1, y, 1, entries_number, + &intercept, &slope, + &cov00, &cov01, &cov11, &chi_squared); +const double r_value = gsl_stats_correlation(x, 1, y, 1, entries_number); + +printf("Slope: %f\n", slope); +printf("Intercept: %f\n", intercept); +printf("Correlation coefficient: %f\n", r_value); +``` + +#### 绘图 + +你必须使用外部程序进行绘图。因此,将拟合数据保存到外部文件: + +``` +const double step_x = ((max_x + 1) - (min_x - 1)) / N; + +for (unsigned int i = 0; i < N; i += 1) { + const double current_x = (min_x - 1) + step_x * i; + const double current_y = intercept + slope * current_x; + + fprintf(output_file, "%f\t%f\n", current_x, current_y); +} +``` + +用于绘制两个文件的 Gnuplot 命令是: + +``` +plot 'fit_C99.csv' using 1:2 with lines title 'Fit', 'anscombe.csv' using 1:2 with points pointtype 7 title 'Data' +``` + +#### 结果 + +在运行程序之前,你必须编译它: + +``` +clang -std=c99 -I/usr/include/ fitting_C99.c -L/usr/lib/ -L/usr/lib64/ -lgsl -lgslcblas -o fitting_C99 +``` + +这个命令告诉编译器使用 C99 标准、读取 `fitting_C99.c` 文件、加载 `gsl` 和 `gslcblas` 库、并将结果保存到 `fitting_C99`。命令行上的结果输出为: + +``` +#### Anscombe's first set with C99 #### +Slope: 0.500091 +Intercept: 3.000091 +Correlation coefficient: 0.816421 +``` + +这是用 Gnuplot 生成的结果图像: + +![Plot and fit of the dataset obtained with C99][52] + +### C++11 方式 + +[C++][53] 语言是一种通用编程语言,也是当今使用的最受欢迎的语言之一。它是作为 [C 的继承人][54]创建的(诞生于 1983 年),重点是[面向对象程序设计(OOP)][55]。C++ 通常被视为 C 的超集,因此 C 程序应该能够使用 C++ 编译器进行编译。这并非完全正确,因为在某些极端情况下它们的行为有所不同。 根据我的经验,C++ 与 C 相比需要更少的样板代码,但是如果要进行面向对象开发,语法会更困难。C++11 标准是最新版本,增加了一些漂亮的功能,并且基本上得到了编译器的支持。 + +由于 C++ 在很大程度上与 C 兼容,因此我将仅强调两者之间的区别。我在本部分中没有涵盖的任何部分,则意味着它与 C 中的相同。 + +#### 安装 + +这个 C++ 示例的依赖项与 C 示例相同。 在 Fedora 上,运行: + +``` +sudo dnf install clang gnuplot gsl gsl-devel +``` + +#### 必要的库 + +库的工作方式与 C 语言相同,但是 `include` 指令略有不同: + +``` +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} +``` + +由于 GSL 库是用 C 编写的,因此你必须将这个特殊情况告知编译器。 + +#### 定义变量 + +与 C 语言相比,C++ 支持更多的数据类型(类),例如,与其 C 语言版本相比,`string` 类型具有更多的功能。相应地更新变量的定义: + +``` +const std::string input_file_name("anscombe.csv"); +``` + +对于字符串之类的结构化对象,你可以定义变量而无需使用 `=` 符号。 + +#### 打印输出 + +你可以使用 `printf()` 函数,但是 `cout` 对象更惯用。使用运算符 `<<` 来指示要使用 `cout` 打印的字符串(或对象): + +``` +std::cout << "#### Anscombe's first set with C++11 ####" << std::endl; + +... + +std::cout << "Slope: " << slope << std::endl; +std::cout << "Intercept: " << intercept << std::endl; +std::cout << "Correlation coefficient: " << r_value << std::endl; +``` + +#### 读取数据 + +该方案与以前相同。将打开文件并逐行读取文件,但语法不同: + +``` +std::ifstream input_file(input_file_name); + +while (input_file.good()) { + std::string line; + + getline(input_file, line); + + ... +} +``` + +使用与 C99 示例相同的功能提取行字元。代替使用标准的 C 数组,而是使用两个[向量][56]。向量是 [C++ 标准库][57]中对 C 数组的扩展,它允许动态管理内存而无需显式调用 `malloc()`: + +``` +std::vector x; +std::vector y; + +// Adding an element to x and y: +x.emplace_back(value); +y.emplace_back(value); +``` + +#### 拟合数据 + +要在 C++ 中拟合,你不必遍历列表,因为向量可以保证具有连续的内存。你可以将向量缓冲区的指针直接传递给拟合函数: + +``` +gsl_fit_linear(x.data(), 1, y.data(), 1, entries_number, + &intercept, &slope, + &cov00, &cov01, &cov11, &chi_squared); +const double r_value = gsl_stats_correlation(x.data(), 1, y.data(), 1, entries_number); + +std::cout << "Slope: " << slope << std::endl; +std::cout << "Intercept: " << intercept << std::endl; +std::cout << "Correlation coefficient: " << r_value << std::endl; +``` + +#### 绘图 + +使用与以前相同的方法进行绘图。 写入文件: + +``` +const double step_x = ((max_x + 1) - (min_x - 1)) / N; + +for (unsigned int i = 0; i < N; i += 1) { + const double current_x = (min_x - 1) + step_x * i; + const double current_y = intercept + slope * current_x; + + output_file << current_x << "\t" << current_y << std::endl; +} + +output_file.close(); +``` + +然后使用 Gnuplot 进行绘图。 + +#### 结果 + +在运行程序之前,必须使用类似的命令对其进行编译: + +``` +clang++ -std=c++11 -I/usr/include/ fitting_Cpp11.cpp -L/usr/lib/ -L/usr/lib64/ -lgsl -lgslcblas -o fitting_Cpp11 +``` + +命令行上的结果输出为: + +``` +#### Anscombe's first set with C++11 #### +Slope: 0.500091 +Intercept: 3.00009 +Correlation coefficient: 0.816421 +``` + +这就是用 Gnuplot 生成的结果图像: + +![Plot and fit of the dataset obtained with C++11][58] + +### 结论 + +本文提供了用 C99 和 C++11 编写的数据拟合和绘图任务的示例。由于 C++ 在很大程度上与 C 兼容,因此本文利用了它们的相似性来编写了第二个示例。在某些方面,C++ 更易于使用,因为它部分减轻了显式管理内存的负担。但是其语法更加复杂,因为它引入了为 OOP 编写类的可能性。但是,仍然可以用 C 使用 OOP 方法编写软件。由于 OOP 是一种编程风格,因此可以在任何语言中使用。在 C 中有一些很好的 OOP 示例,例如 [GObject][59] 和 [Jansson][60]库。 + +对于数字运算,我更喜欢在 C99 中进行,因为它的语法更简单并且得到了广泛的支持。直到最近,C++11 还没有得到广泛的支持,我倾向于避免使用先前版本中的粗糙不足之处。对于更复杂的软件,C++ 可能是一个不错的选择。 + +你是否也将 C 或 C++ 用于数据科学?在评论中分享你的经验。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/c-data-science + +作者:[Cristiano L. Fontana][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/cristianofontana +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_data_dashboard_system_computer_analytics.png?itok=oxAeIEI- (metrics and data shown on a computer screen) +[2]: https://opensource.com/article/18/9/top-3-python-libraries-data-science +[3]: https://opensource.com/article/19/5/learn-python-r-data-science +[4]: https://en.wikipedia.org/wiki/C99 +[5]: https://en.wikipedia.org/wiki/C%2B%2B11 +[6]: https://en.wikipedia.org/wiki/Anscombe%27s_quartet +[7]: https://linux.cn/article-11943-1.html +[8]: https://en.wikipedia.org/wiki/Command-line_interface +[9]: https://en.wikipedia.org/wiki/Graphical_user_interface +[10]: https://gitlab.com/cristiano.fontana/polyglot_fit +[11]: https://en.wikipedia.org/wiki/Comma-separated_values +[12]: https://en.wikipedia.org/wiki/C_%28programming_language%29 +[13]: https://www.tiobe.com/tiobe-index/ +[14]: https://redmonk.com/sogrady/2019/07/18/language-rankings-6-19/ +[15]: http://pypl.github.io/PYPL.html +[16]: https://octoverse.github.com/ +[17]: https://en.wikipedia.org/wiki/Compiled_language +[18]: https://en.wikipedia.org/wiki/Compiler +[19]: https://en.wikipedia.org/wiki/Machine_code +[20]: https://en.wikipedia.org/wiki/C_standard_library +[21]: https://en.wiktionary.org/wiki/number-crunching +[22]: https://en.wikipedia.org/wiki/Boilerplate_code +[23]: https://clang.llvm.org/ +[24]: https://gcc.gnu.org/ +[25]: https://www.gnu.org/software/gsl/ +[26]: http://www.gnuplot.info/ +[27]: https://en.wikipedia.org/wiki/Berkeley_Software_Distribution +[28]: https://getfedora.org/ +[29]: https://en.wikipedia.org/wiki/Comment_(computer_programming) +[30]: https://en.wikipedia.org/wiki/Include_directive +[31]: https://en.wikipedia.org/wiki/Linker_%28computing%29 +[32]: https://en.wikipedia.org/wiki/Entry_point#C_and_C++ +[33]: https://gitlab.com/cristiano.fontana/polyglot_fit/-/blob/master/fitting_C99.c +[34]: https://en.wikipedia.org/wiki/Linked_list#Singly_linked_list +[35]: http://man7.org/linux/man-pages/man3/queue.3.html +[36]: https://en.wikipedia.org/wiki/Printf_format_string +[37]: http://www.opengroup.org/onlinepubs/009695399/functions/ferror.html +[38]: http://www.opengroup.org/onlinepubs/009695399/functions/feof.html +[39]: http://man7.org/linux/man-pages/man3/getline.3.html +[40]: https://en.wikipedia.org/wiki/POSIX +[41]: https://en.wikipedia.org/wiki/Lexical_analysis#Token +[42]: http://man7.org/linux/man-pages/man3/strtok.3.html +[43]: http://www.opengroup.org/onlinepubs/009695399/functions/strtok.html +[44]: http://www.opengroup.org/onlinepubs/009695399/functions/sscanf.html +[45]: http://www.opengroup.org/onlinepubs/009695399/functions/malloc.html +[46]: http://man7.org/linux/man-pages/man3/malloc.3.html +[47]: https://www.gnu.org/software/gsl/doc/html/lls.html +[48]: https://en.wikipedia.org/wiki/Memory_leak +[49]: http://www.opengroup.org/onlinepubs/009695399/functions/free.html +[50]: http://www.opengroup.org/onlinepubs/009695399/functions/printf.html +[51]: http://www.opengroup.org/onlinepubs/009695399/functions/fprintf.html +[52]: https://opensource.com/sites/default/files/uploads/fit_c99.png (Plot and fit of the dataset obtained with C99) +[53]: https://en.wikipedia.org/wiki/C%2B%2B +[54]: http://www.cplusplus.com/info/history/ +[55]: https://en.wikipedia.org/wiki/Object-oriented_programming +[56]: https://en.wikipedia.org/wiki/Sequence_container_%28C%2B%2B%29#Vector +[57]: https://en.wikipedia.org/wiki/C%2B%2B_Standard_Library +[58]: https://opensource.com/sites/default/files/uploads/fit_cpp11.png (Plot and fit of the dataset obtained with C++11) +[59]: https://en.wikipedia.org/wiki/GObject +[60]: http://www.digip.org/jansson/ diff --git a/sources/README.md b/sources/README.md new file mode 100644 index 0000000000..5615087474 --- /dev/null +++ b/sources/README.md @@ -0,0 +1 @@ +这里放待翻译的文件。 diff --git a/sources/news/20191008 Kubernetes communication, SRE struggles, and more industry trends.md b/sources/news/20191008 Kubernetes communication, SRE struggles, and more industry trends.md deleted file mode 100644 index a3ba0a6a52..0000000000 --- a/sources/news/20191008 Kubernetes communication, SRE struggles, and more industry trends.md +++ /dev/null @@ -1,64 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Kubernetes communication, SRE struggles, and more industry trends) -[#]: via: (https://opensource.com/article/19/10/kubernetes-sre-more-industry-trends) -[#]: author: (Tim Hildred https://opensource.com/users/thildred) - -Kubernetes communication, SRE struggles, and more industry trends -====== -A weekly look at open source community and industry trends. -![Person standing in front of a giant computer screen with numbers, data][1] - -As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update. - -## [Review of pod-to-pod communications in Kubernetes][2] - -> In this article, we dive into pod-to-pod communications by showing you ways in which pods within a Kubernetes network can communicate with one another. -> -> While Kubernetes is opinionated in how containers are deployed and operated, it is very non-prescriptive of how the network should be designed in which pods are to be run. Kubernetes imposes the following fundamental requirements on any networking implementation (barring any intentional network segmentation policies) - -**The impact**: Networking is one of the most complicated parts of making computers work together to solve our problems. Kubernetes turns that complexity up to 11, and this article dials it back down to 10.75. - -## [One SRE's struggle and success to improve Infrastructure as Code][3] - -> Convergence is our goal because we expect our infrastructure to reach a desired state over time expressed in the code. Software idempotence means software can run as many times as it wants and unintended changes don’t happen. As a result, we built an in-house service that runs as specified to apply configurations in source control. Traditionally, we’ve aimed for a masterless configuration design so our configuration agent looks for information on the host. - -**The impact**: I've heard it said that the [human element][4] is the most important element of any digital transformation. While I don't know that the author would use that term to describe the outcome he was after, he does a great job of showing that it is not automation for automation's sake we want but rather automation that makes a meaningful impact on the lives of the people it supports. - -## [Why GitHub is the gold standard for developer-focused companies][5] - -> Now, with last year’s purchase by Microsoft supporting them, it is clear that GitHub has a real opportunity to continue building out a robust ecosystem, with billion dollar companies built upon what could turn into a powerful platform. Is GitHub the next ecosystem success story? In a word, yes. At my company, we bet on GitHub as a successful platform to build upon from the very start. We felt it was the place to build our solution if we wanted to streamline project management and keep software teams close to the code. - -**The impact**: It is one of the great ironies of open source that the most popular tool for open source development is not itself open source. The only way this works is if that tool is so good that open source developers are willing to overlook that inconsistency. - -## [KubeVirt joins Cloud Native Computing Foundation][6] - -> This month the Cloud Native Computing Foundation (CNCF) formally adopted [KubeVirt][7] into the CNCF Sandbox. KubeVirt allows you to provision, manage and run virtual machines from and within Kubernetes. In joining the CNCF Sandbox, KubeVirt now has a more substantial platform to grow as well as educate the CNCF community on the use cases for placing virtual machines within Kubernetes. The CNCF onboards projects into the CNCF Sandbox when they warrant experimentation on neutral ground to promote and foster collaborative development. - -**The impact**: The convergence of containers and virtual machines is clearly a direction vendors think is valuable. Moving this project to the CNCF gives a way to see whether this idea is going to be as popular with users and customers as vendors hope it will be. - -_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/kubernetes-sre-more-industry-trends - -作者:[Tim Hildred][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/thildred -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) -[2]: https://superuser.openstack.org/articles/review-of-pod-to-pod-communications-in-kubernetes/ -[3]: https://thenewstack.io/one-sres-struggle-and-success-to-improve-infrastructure-as-code/ -[4]: https://devops.com/the-secret-to-digital-transformation-is-human-connection/ -[5]: https://thenextweb.com/podium/2019/10/02/why-github-is-the-gold-standard-for-developer-focused-companies/ -[6]: https://blog.openshift.com/kubevirt-joins-cloud-native-computing-foundation/ -[7]: https://kubevirt.io/ diff --git a/sources/news/20191013 System76 will ship Coreboot-powered firmware, a new OS for the apocalypse, and more open source news.md b/sources/news/20191013 System76 will ship Coreboot-powered firmware, a new OS for the apocalypse, and more open source news.md deleted file mode 100644 index eab1e9bd0e..0000000000 --- a/sources/news/20191013 System76 will ship Coreboot-powered firmware, a new OS for the apocalypse, and more open source news.md +++ /dev/null @@ -1,103 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (System76 will ship Coreboot-powered firmware, a new OS for the apocalypse, and more open source news) -[#]: via: (https://opensource.com/article/19/10/news-october-13) -[#]: author: (Lauren Maffeo https://opensource.com/users/lmaffeo) - -System76 will ship Coreboot-powered firmware, a new OS for the apocalypse, and more open source news -====== -Catch up on the biggest open source headlines from the past two weeks. -![Weekly news roundup with TV][1] - -In this edition of our open source news roundup, we cover System76 shipping Coreboot-powered firmware, a new OS for the apocalypse, and more open source news! - -### System76 will ship 2 Linux laptops with Coreboot-powered open source firmware - -The Denver-based Linux PC manufacturer announced plans to start shipping two laptop models with its Coreboot-powered open source firmware later this month. Jason Evangelho, Senior Contributor at _Forbes_, cited this move as a march towards offering open source software and hardware from the ground up.  - -System76, which also develops [Pop OS][2], is now taking pre-orders for its Galago Pro and Darter Pro laptops. It claims that Coreboot will let users boot from power off to the desktop 29% faster. - -Coreboot is a lightweight firmware designed to simplify the boot cycle of systems using it. It requires the minimum number of tasks needed to load and run a modern 32-bit or 64-bit operating system. Coreboot can offer a replacement for proprietary firmware, though it omits features like execution environments. Our own [Don Watkins][3] asked if Coreboot will ship on other System76 machines. Their response, [as reported by _Forbes_][4]: - -> _"Yes. Long term, System76 is working to open source all aspects of the computer. Thelio Io, the controller board in the Thelio desktop, is both open hardware and open firmware. This is a long journey but we're picking up speed. It's been less than a year since the our open hardware Thelio desktop was released and we're now producing two laptops with System76 Open Firmware."_ - -### Collapse OS is an operating system for the post-apocalypse - -Virgil Dupras, a software developer based in Quebec, is convinced the world's global supply chain will collapse before 2030. And he's worried that most [electronics will get caught in the crosshairs][5] due to "a very complex supply chain that we won't be able to achieve again for decades (ever?)."  - -To prepare for the worst, Dupras built Collapse OS. It's [designed to run][6] on "minimal or improvised machines" and perform simple tasks that are helpful in a post-apocalyptic society. These include editing text files, collecting sources files for MCUs and CPUs, and reading/writing from several storage devices. - -Dupras says it's intended for worst-case scenarios, and that a "weak collapse" might not be enough to justify its use. If you err on the side of caution, the Collapse OS project is accepting new contributors [on GitHub][7].  - -Per the project website, Dupras says his goal is for Collapse OS to be as self-contained as possible with the ability for users to install the OS without Internet access or other resources. Ideally, the goal is for Collapse OS to not be used at all. - -### ExpressionEngine will stay open source post-acquisition - -The team behind open source CMS ExpressEngine was acquired by Packet Tide - EEHarbor's parent company - in early October. [This announcement ][8]comes one year after Digital Locations acquired EllisLab, which develops EE core.  - -[In an announcement][9] on ExpressionEngine's website, EllisLab founder Rick Ellis said Digital Locations wasn't a good fit for ExpressionEngine. Citing Digital Location's goals to build an AI business, Ellis realized several months ago that ExpressionEngine needed a new home: - -> _"We decided that what was best for ExpressionEngine was to seek a new owner, one that could devote all the resources necessary for ExpressionEngine to flourish. Our top candidate was Packet Tide due to their development capability, extensive catalog of add-ons, and deep roots in the ExpressionEngine community._ -> -> _We are thrilled that they immediately expressed enthusiastic interest in becoming the caretakers of ExpressionEngine."_ - -Ellis says Packet Tide's first goal is to finish building ExpressionEngine 6.0, which will have a new control panel with a dark theme (who doesn't love dark mode?). ExpressionEngine adopted the Apache License Version 2.0 in November 2018, after 16 years as a proprietary tool. - -The tool is still marketed as an open source CMS, and EE Harbor developer Tom Jaeger said [in the EE Slack][10] that their plan is to keep ExpressionEngine open source now. But he also left the door open to possible changes.  - -### McAfee and IBM Security to lead the Open Source Cybersecurity Alliance - -The two tech giants will contribute the initiative's first open source code and content, under guidance from the OASIS consortium. The Alliance aims to share best practices, tech stacks, and security solutions in an open source platform.  - -Carol Geyer, chief development officer of OASIS, said the lack of standard language makes it hard for businesses to share data between tools and products. Despite efforts to collaborate, the lack of a standardized format yields more integration costs that are expensive and time-consuming. - -In lieu of building connections and integrations, [the Alliance wants members][11] to "develop protocols and standards which enable tools to work together and share information across vendors."  - -According to _Tech Republic_, IBM Security will contribute [STIX-Shifter][12], an open source library that offer a universal security system. Meanwhile, McAfee added its [OpenDXL Standard Ontology][13], a cybersecurity messaging format. Other members of the Alliance include CrowdStrike, CyberArk, and SafeBreach. - -#### In other news - - * [Paris uses open source to get closer to the citizen][14] - * [SD Times open source project of the week: ABAP SDK for IBM Watson][15] - * [Google's keeping Knative development under its thumb 'for the foreseeable future'][16] - * [Devs engage in soul-searching on future of open source][17] - * [Why leading Formula 1 teams back 'copycat' open source design idea][18] - - - -_Thanks, as always, to Opensource.com staff members and moderators for their help this week._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/news-october-13 - -作者:[Lauren Maffeo][a] -选题:[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/lmaffeo -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/weekly_news_roundup_tv.png?itok=B6PM4S1i (Weekly news roundup with TV) -[2]: https://system76.com/pop -[3]: https://opensource.com/users/don-watkins -[4]: https://www.forbes.com/sites/jasonevangelho/2019/10/10/system76-will-begin-shipping-2-linux-laptops-with-coreboot-based-open-source-firmware/#15a4da174e64 -[5]: https://collapseos.org/why.html -[6]: https://www.digitaltrends.com/cool-tech/collapse-os-after-societys-collapse/ -[7]: https://github.com/hsoft/collapseos -[8]: https://wptavern.com/expressionengine-under-new-ownership-will-remain-open-source-for-now -[9]: https://expressionengine.com/blog/expressionengine-has-a-new-owner -[10]: https://eecms.slack.com/?redir=%2Farchives%2FC04CUNNR9%2Fp1570576465005500 -[11]: https://www.techrepublic.com/article/mcafee-ibm-join-forces-for-global-open-source-cybersecurity-initiative/ -[12]: https://github.com/opencybersecurityalliance/stix-shifter -[13]: https://www.opendxl.com/ -[14]: https://www.smartcitiesworld.net/special-reports/special-reports/paris-uses-open-source-to-get-closer-to-the-citizen -[15]: https://sdtimes.com/os/sd-times-open-source-project-of-the-week-abap-sdk-for-ibm-watson/ -[16]: https://www.datacenterknowledge.com/google-alphabet/googles-keeping-knative-development-under-its-thumb-foreseeable-future -[17]: https://www.linuxinsider.com/story/86282.html -[18]: https://www.autosport.com/f1/news/146407/why-leading-f1-teams-back-copycat-design-proposal diff --git a/sources/news/20191023 Cisco issues critical security warning for IOS XE REST API container.md b/sources/news/20191023 Cisco issues critical security warning for IOS XE REST API container.md deleted file mode 100644 index 13bc238c2c..0000000000 --- a/sources/news/20191023 Cisco issues critical security warning for IOS XE REST API container.md +++ /dev/null @@ -1,68 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Cisco issues critical security warning for IOS XE REST API container) -[#]: via: (https://www.networkworld.com/article/3447558/cisco-issues-critical-security-warning-for-ios-xe-rest-api-container.html) -[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) - -Cisco issues critical security warning for IOS XE REST API container -====== -This Cisco IOS XE REST API vulnerability could lead to attackers obtaining the token-id of an authenticated user. -D3Damon / Getty Images - -Cisco this week said it issued a software update to address a vulnerability in its [Cisco REST API virtual service container for Cisco IOS XE][1] software that scored a critical 10 out of 10 on the Common Vulnerability Scoring System (CVSS) system. - -With the vulnerability an attacker could submit malicious HTTP requests to the targeted device and if successful, obtain the _token-id_ of an authenticated user. This _token-id_ could be used to bypass authentication and execute privileged actions through the interface of the REST API virtual service container on the affected Cisco IOS XE device, the company said. - -[[Get regularly scheduled insights by signing up for Network World newsletters.]][2] - -According to Cisco the REST API is an application that runs in a virtual services container. A virtual services container is a virtualized environment on a device and is delivered as an open virtual application (OVA).  The OVA package has to be installed and enabled on a device through the device virtualization manager (VMAN) CLI. - -**[ [Prepare to become a Certified Information Security Systems Professional with this comprehensive online course from PluralSight. Now offering a 10-day free trial!][3] ]** - -The Cisco REST API provides a set of RESTful APIs as an alternative method to the Cisco IOS XE CLI to provision selected functions on Cisco devices. - -Cisco said the vulnerability can be exploited under the  following conditions: - - * The device runs an affected Cisco IOS XE Software release. - * The device has installed and enabled an affected version of the Cisco REST API virtual service container. - * An authorized user with administrator credentials (level 15) is authenticated to the REST API interface. - - - -The REST API interface is not enabled by default. To be vulnerable, the virtual services container must be installed and activated. Deleting the OVA package from the device storage memory removes the attack vector. If the Cisco REST API virtual service container is not enabled, this operation will not impact the device's normal operating conditions, Cisco stated.    - -This vulnerability affects Cisco devices that are configured to use a vulnerable version of Cisco REST API virtual service container. This vulnerability affected the following products: - - * Cisco 4000 Series Integrated Services Routers - * Cisco ASR 1000 Series Aggregation Services Routers - * Cisco Cloud Services Router 1000V Series - * Cisco Integrated Services Virtual Router - - - -Cisco said it has [released a fixed version of the REST API][4] virtual service container and   a hardened IOS XE release that prevents installation or activation of a vulnerable container on a device. If the device was already configured with an active vulnerable container, the IOS XE software upgrade will deactivate the container, making the device not vulnerable. In that case, to restore the REST API functionality, customers should upgrade the Cisco REST API virtual service container to a fixed software release, the company said. - -Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3447558/cisco-issues-critical-security-warning-for-ios-xe-rest-api-container.html - -作者:[Michael Cooney][a] -选题:[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/Michael-Cooney/ -[b]: https://github.com/lujun9972 -[1]: https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20190828-iosxe-rest-auth-bypass -[2]: https://www.networkworld.com/newsletters/signup.html -[3]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr -[4]: https://www.cisco.com/c/en/us/about/legal/cloud-and-software/end_user_license_agreement.html -[5]: https://www.facebook.com/NetworkWorld/ -[6]: https://www.linkedin.com/company/network-world diff --git a/sources/news/20191026 Netflix builds a Jupyter Lab alternative, a bug bounty to fight election hacking, Raspberry Pi goes microscopic, and more open source news.md b/sources/news/20191026 Netflix builds a Jupyter Lab alternative, a bug bounty to fight election hacking, Raspberry Pi goes microscopic, and more open source news.md deleted file mode 100644 index b50a93d8c1..0000000000 --- a/sources/news/20191026 Netflix builds a Jupyter Lab alternative, a bug bounty to fight election hacking, Raspberry Pi goes microscopic, and more open source news.md +++ /dev/null @@ -1,78 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Netflix builds a Jupyter Lab alternative, a bug bounty to fight election hacking, Raspberry Pi goes microscopic, and more open source news) -[#]: via: (https://opensource.com/article/19/10/news-october-26) -[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) - -Netflix builds a Jupyter Lab alternative, a bug bounty to fight election hacking, Raspberry Pi goes microscopic, and more open source news -====== -Catch up on the biggest open source headlines from the past two weeks. -![Weekly news roundup with TV][1] - -In this edition of our open source news roundup, we take a look at a machine learning tool from Netflix, Microsoft's election software bug bounty, a cost-effective microscope built with Raspberry Pi, and more! - -### Netflix release Polynote machine learning tool - -While there have been numerous advances in machine learning over the last decade, it's still a difficult, laborious, and sometimes frustrating task. To help make that task easier, Netflix has [released a machine learning notebook environment][2] called Polynote as open source. - -Polynote enables "data scientists and AI researchers to integrate Netflix’s JVM-based machine learning framework with Python machine learning and visualization libraries". What make Polynote unique is its reproducibility feature, which "takes cells’ positions in the notebook into account before executing them, helping prevent bad practices that make notebooks difficult to rerun from the top." It's also quite flexible—Polynote works with Apache Spark and supports languages like Python, Scala, and SQL. - -You can grab Polynote [off GitHub][3] or learn more about it at the Polynote website. - -### Microsoft announces bug bounty program for its election software - -Hoping that more eyeballs on its code will make bugs shallow, Microsoft announced a [a bug bounty][4] for its open source ElectionGuard software development kit for voting machines. The goal of the program is to "uncover vulnerabilities and help bolster election security." - -The bounty is open to "security professionals, part-time hobbyists, and students." Successful submissions, which must include proofs of concept demonstrating how bugs could compromise the security of voters, are worth up to $15,000 (USD). - -If you're interested in participating, you can find ElectionGuard's code on [GitHub][5], and read more about the [bug bounty][6]. - -### microscoPI: a microscope built on Raspberry Pi - -It's not a stretch to say that the Raspberry Pi is one of the most flexible platforms for hardware and software hackers. Micropalaeontologist Martin Tetard saw the potential of the tiny computers in his field of study and [create the microscoPI][7]. - -The microscoPI is a Raspberry Pi-assisted microscope that can "capture, process, and store images and image analysis results." Using an old adjustable microscope with a movable stage as a base, Tetard added a Raspberry Pi B, a Raspberry Pi camera module, and a small touchscreen to the device. The result is a compact rig that's "completely portable and measuring less than 30 cm (12 inches) in height." The entire setup cost him €159 (about $177 USD). - -Tetard has set up [a website][8] for the microscoPI, where you can learn more about it. - -#### In other news - - * [Happy 15th birthday, Ubuntu][9] - * [Open-Source Arm Puts Robotics Within Reach][10] - * [Apache Rya matures open source triple store database][11] - * [UNICEF Launches Cryptocurrency Fund to Back Open Source Technology][12] - * [Open-source Delta Lake project moves to the Linux Foundation][13] - - - -_Thanks, as always, to Opensource.com staff members and moderators for their help this week._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/news-october-26 - -作者:[Scott Nesbitt][a] -选题:[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/scottnesbitt -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/weekly_news_roundup_tv.png?itok=B6PM4S1i (Weekly news roundup with TV) -[2]: https://venturebeat.com/2019/10/23/netflix-open-sources-polynote-to-simplify-data-science-and-machine-learning-workflows/ -[3]: https://github.com/polynote/polynote -[4]: https://thenextweb.com/security/2019/10/21/microsofts-open-source-election-software-now-has-a-bug-bounty-program/ -[5]: https://github.com/microsoft/ElectionGuard-SDK -[6]: https://www.microsoft.com/en-us/msrc/bounty -[7]: https://www.geeky-gadgets.com/raspberry-pi-microscope-07-10-2019/ -[8]: https://microscopiproject.wordpress.com/ -[9]: https://www.omgubuntu.co.uk/2019/10/happy-birthday-ubuntu-2019 -[10]: https://hackaday.com/2019/10/17/open-source-arm-puts-robotics-within-reach/ -[11]: https://searchdatamanagement.techtarget.com/news/252472464/Apache-Rya-matures-open-source-triple-store-database -[12]: https://www.coindesk.com/unicef-launches-cryptocurrency-fund-to-back-open-source-technology -[13]: https://siliconangle.com/2019/10/16/open-source-delta-lake-project-moves-linux-foundation/ diff --git a/sources/news/20191104 Hypervisor comeback, Linus says no and reads email, and more industry trends.md b/sources/news/20191104 Hypervisor comeback, Linus says no and reads email, and more industry trends.md deleted file mode 100644 index b8a6aafc80..0000000000 --- a/sources/news/20191104 Hypervisor comeback, Linus says no and reads email, and more industry trends.md +++ /dev/null @@ -1,70 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Hypervisor comeback, Linus says no and reads email, and more industry trends) -[#]: via: (https://opensource.com/article/19/11/hypervisor-stable-kernel-and-more-industry-trends) -[#]: author: (Tim Hildred https://opensource.com/users/thildred) - -Hypervisor comeback, Linus says no and reads email, and more industry trends -====== -A weekly look at open source community and industry trends. -![Person standing in front of a giant computer screen with numbers, data][1] - -As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update. - -## [Containers in 2019: They're calling it a [hypervisor] comeback][2] - -> So what does all this mean as we continue with rapid adoption and hyper-ecosystem growth around Kubernetes and containers? Let’s try and break that down into a few key areas and see what all the excitement is about. - -**The impact**: I'm pretty sure that the title of the article is an LL Cool J reference, which I wholeheartedly approve of. Even more important though is a robust unpacking of developments in the hypervisor space over the last year and how they square up against the trend towards cloud-native and container-based development. - -## [Linux kernel is getting more reliable, says Linus Torvalds. Plus: What do you need to do to be him?][3] - -> "In the end my job is to say no. Somebody has to be able to say no, because other developers know that if they do something bad I will say no. They hopefully in turn are more careful. But in order to be able to say no, I have to know the background, because otherwise I can't do my job. I spend all my time basically reading email about what people are working on. - -**The impact**: The rehabilitation of Linus as a much chiller guy continues; this one has some good advice for people leading distributed teams. - -## [Automated infrastructure in the on-premise datacenter—OpenShift 4.2 on OpenStack 15 (Stein)][4] - -> Up until now IPI (Installer Provision Infrastructure) has only supported public clouds: AWS, Azure, and Google. Now with OpenShift 4.2 it is supporting OpenStack. For the first time we can bring IPI into the on-premise datacenter where it is IMHO most needed. This single feature has the potential to revolutionize on-premise environments and bring them into the cloud-age with a single click and that promise is truly something to get excited about! - -**The impact**: So much tech press has started with the assumption that every company should run their infrastructure like a hyperscaler. The technology is catching up to make the user experience of that feasible. - -## [Kubernetes autoscaling 101: Cluster autoscaler, horizontal autoscaler, and vertical pod autoscaler][5] - -> I’m providing in this post a high-level overview of different scalability mechanisms inside Kubernetes and best ways to make them serve your needs. Remember, to truly master Kubernetes, you need to master different ways to manage the scale of cluster resources, that’s [the core of promise of Kubernetes][6]. -> -> _Configuring Kubernetes clusters to balance resources and performance can be challenging, and requires expert knowledge of the inner workings of Kubernetes. Just because your app or services’ workload isn’t constant, it rather fluctuates throughout the day if not the hour. Think of it as a journey and ongoing process._ - -**The impact**: You can tell whether someone knows what they're talking about if they can represent it in a simple diagram. Thanks to the excellent diagrams in this post, I know more day 2 concerns of Kubernetes operators than I ever wanted to. - -## [GitHub: All open source developers anywhere are welcome][7] - -> Eighty percent of all open-source contributions today, come from outside of the US. The top two markets for open source development outside of the US are China and India. These markets, although we have millions of developers in them, are continuing to grow faster than any others at about 30% year-over-year average. - -**The impact**: One of my open source friends likes to muse on the changing culture within the open source community. He posits that the old guard gatekeepers are already becoming irrelevant. I don't know if I completely agree, but I think you can look at the exponentially increasing contributions from places that haven't been on the open source map before and safely speculate that the open source culture of tomorrow will be radically different than that of today. - -_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/11/hypervisor-stable-kernel-and-more-industry-trends - -作者:[Tim Hildred][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/thildred -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) -[2]: https://www.infoq.com/articles/containers-hypervisors-2019/ -[3]: https://www.theregister.co.uk/2019/10/30/linux_kernel_is_getting_more_reliable_says_linus_torvalds/ -[4]: https://keithtenzer.com/2019/10/29/automated-infrastructure-in-the-on-premise-datacenter-openshift-4-2-on-openstack-15-stein/ -[5]: https://www.cncf.io/blog/2019/10/29/kubernetes-autoscaling-101-cluster-autoscaler-horizontal-autoscaler-and-vertical-pod-autoscaler/ -[6]: https://speakerdeck.com/thockin/everything-you-ever-wanted-to-know-about-resource-scheduling-dot-dot-dot-almost -[7]: https://www.zdnet.com/article/github-all-open-source-developers-anywhere-are-welcome/#ftag=RSSbaffb68 diff --git a/sources/news/20191105 Red Hat announces RHEL 8.1 with predictable release cadence.md b/sources/news/20191105 Red Hat announces RHEL 8.1 with predictable release cadence.md deleted file mode 100644 index 9addd4102c..0000000000 --- a/sources/news/20191105 Red Hat announces RHEL 8.1 with predictable release cadence.md +++ /dev/null @@ -1,92 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Red Hat announces RHEL 8.1 with predictable release cadence) -[#]: via: (https://www.networkworld.com/article/3451367/red-hat-announces-rhel-8-1-with-predictable-release-cadence.html) -[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) - -Red Hat announces RHEL 8.1 with predictable release cadence -====== - -[Clkr / Pixabay][1] [(CC0)][2] - -[Red Hat][3] has just today announced the availability of Red Hat Enterprise Linux (RHEL) 8.1, promising improvements in manageability, security and performance. - -RHEL 8.1 will enhance the company’s open [hybrid-cloud][4] portfolio and continue to provide a consistent user experience between on-premises and public-cloud deployments. - -[[Get regularly scheduled insights by signing up for Network World newsletters.]][5] - -RHEL 8.1 is also the first release that will follow what Red Hat is calling its "predictable release cadence". Announced at Red Hat Summit 2019, this means that minor releases will be available every six months. The expectation is that this rhythmic release cycle will make it easier both for customer organizations and other software providers to plan their upgrades. - -[][6] - -BrandPost Sponsored by HPE - -[Take the Intelligent Route with Consumption-Based Storage][6] - -Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. - -Red Hat Enterprise Linux 8.1 provides product enhancements in many areas. - -### Enhanced automation - -All supported RHEL subscriptions now include access to Red Hat's proactive analytics, **Red Hat Insights**. With more than 1,000 rules for operating RHEL systems whether on-premises or cloud deployments, Red Hat Insights help IT administrators flag potential configuration, security, performance, availability and stability issues before they impact production. - -### New system roles - -RHEL 8.1 streamlines the process for setting up subsystems to handle specific functions such as storage, networking, time synchronization, kdump and SELinux. This expands on the variety of Ansible system roles. - -### Live kernel patching - -RHEL 8.1 adds full support for live kernel patching. This critically important feature allows IT operations teams to deal with ongoing threats without incurring excessive system downtime. Kernel updates can be applied to remediate common vulnerabilities and exposures (CVE) while reducing the need for a system reboot. Additional security enhancements include enhanced CVE remediation, kernel-level memory protection and application whitelisting. - -### Container-centric SELinux profiles - -These profiles allow the creation of more tailored security policies to control how containerized services access host-system resources, making it easier to harden systems against security threats. - -### Enhanced hybrid-cloud application development - -A reliably consistent set of supported development tools is included, among them the latest stable versions of popular open-source tools and languages like golang and .NET Core as well as the ability to power modern data-processing workloads such as Microsoft SQL Server and SAP solutions. - -Red Hat Linux 8.1 is available now for RHEL subscribers via the [Red Hat Customer Portal][7]. Red Hat Developer program members may obtain the latest releases at no cost at the [Red Hat Developer][8] site. - -#### Additional resources - -Here are some links to  additional information: - - * More about [Red Hat Enterprise Linux][9] - * Get a [RHEL developer subscription][10] - * More about the latest features at [Red Hat Insights][11] - - - -Join the Network World communities on [Facebook][12] and [LinkedIn][13] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3451367/red-hat-announces-rhel-8-1-with-predictable-release-cadence.html - -作者:[Sandra Henry-Stocker][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ -[b]: https://github.com/lujun9972 -[1]: https://pixabay.com/vectors/red-hat-fedora-fashion-style-26734/ -[2]: https://creativecommons.org/publicdomain/zero/1.0/ -[3]: https://www.networkworld.com/article/3316960/ibm-closes-34b-red-hat-deal-vaults-into-multi-cloud.html -[4]: https://www.networkworld.com/article/3268448/what-is-hybrid-cloud-really-and-whats-the-best-strategy.html -[5]: https://www.networkworld.com/newsletters/signup.html -[6]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) -[7]: https://access.redhat.com/ -[8]: https://developer.redhat.com -[9]: https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux -[10]: https://developers.redhat.com/ -[11]: https://www.redhat.com/en/blog/whats-new-red-hat-insights-november-2019 -[12]: https://www.facebook.com/NetworkWorld/ -[13]: https://www.linkedin.com/company/network-world diff --git a/sources/news/20191105 System76 introduces laptops with open source BIOS coreboot.md b/sources/news/20191105 System76 introduces laptops with open source BIOS coreboot.md deleted file mode 100644 index 4d9c336304..0000000000 --- a/sources/news/20191105 System76 introduces laptops with open source BIOS coreboot.md +++ /dev/null @@ -1,57 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (System76 introduces laptops with open source BIOS coreboot) -[#]: via: (https://opensource.com/article/19/11/coreboot-system76-laptops) -[#]: author: (Don Watkins https://opensource.com/users/don-watkins) - -System76 introduces laptops with open source BIOS coreboot -====== -The company answers open hardware fans by revealing two laptops powered -with open source firmware coreboot. -![Guy on a laptop on a building][1] - -In mid-October, [System76][2] made an exciting announcement for open source hardware fans: It would soon begin shipping two of its laptop models, [Galago Pro][3] and [Darter Pro][4], with the open source BIOS [coreboot][5]. - -The coreboot project [says][6] its open source firmware "is a replacement for your BIOS / UEFI with a strong focus on boot speed, security, and flexibility. It is designed to boot your operating system as fast as possible without any compromise to security, with no back doors, and without any cruft from the '80s." Coreboot was previously known as LinuxBIOS, and the engineers who work on coreboot have also contributed to the Linux kernel. - -Most firmware on computers sold today is proprietary, which means even if you are running an open source operating system, you have no access to your machine's BIOS. This is not so with coreboot. Its developers share the improvements they make, rather than keeping them secret from other vendors. Coreboot's source code can be inspected, learned from, and modified, just like any other open source code. - -[Joshua Woolery][7], marketing director at System76, says coreboot differs from a proprietary BIOS in several important ways. "Traditional firmware is closed source and impossible to review and inspect. It's bloated with unnecessary features and unnecessarily complex [ACPI][8] implementations that lead to PCs operating in unpredictable ways. System76 Open Firmware, on the other hand, is lightweight, fast, and cleanly written." This means your computer boots faster and is more secure, he says. - -I asked Joshua about the impact of coreboot on open hardware overall. "The combination of open hardware and open firmware empowers users beyond what's possible when one or the other is proprietary," he says. "Imagine an open hardware controller like [System76's] [Thelio Io][9] without open source firmware. One could read the schematic and write software to control it, but why? With open firmware, the user starts from functioning hardware and software and can expand from there. Open hardware and firmware enable the community to learn from, adapt, and expand on our work, thus moving technology forward as a whole rather than requiring individuals to constantly re-implement what's already been accomplished." - -Joshua says System76 is working to open source all aspects of the computer, and we will see coreboot on other System76 machines. The hardware and firmware in Thelio Io, the controller board in the company's Thelio desktops, are both open. Less than a year after System76 introduced Thelio, the company is now marketing two laptops with open firmware. - -If you would like to see System76's firmware contributions to the coreboot project, visit the code repository on [GitHub][10]. You can also see the schematics for any supported System76 model by sending an [email][11] with the subject line: _Schematics for <MODEL>_. (Bear in mind that the only currently supported models are darp6 and galp4.) Using the coreboot firmware on other devices is not supported and may render them inoperable, - -Coreboot is licensed under the GNU Public License. You can view the [documentation][12] on the project's website and find out how to [contribute][13] to the project on GitHub. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/11/coreboot-system76-laptops - -作者:[Don Watkins][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/don-watkins -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_code_programming_laptop.jpg?itok=ormv35tV (Guy on a laptop on a building) -[2]: https://opensource.com/article/19/5/system76-secret-sauce -[3]: https://system76.com/laptops/galago -[4]: https://system76.com/laptops/darter -[5]: https://www.coreboot.org/ -[6]: https://www.coreboot.org/users.html -[7]: https://www.linkedin.com/in/joshuawoolery -[8]: https://en.wikipedia.org/wiki/Advanced_Configuration_and_Power_Interface -[9]: https://opensource.com/article/18/11/system76-thelio-desktop-computer -[10]: https://github.com/system76/firmware-open -[11]: mailto:productdev@system76.com -[12]: https://doc.coreboot.org/index.html -[13]: https://github.com/coreboot/coreboot diff --git a/sources/news/20191112 GitHub report surprises, serverless hotness, and more industry trends.md b/sources/news/20191112 GitHub report surprises, serverless hotness, and more industry trends.md deleted file mode 100644 index df2db0d6f8..0000000000 --- a/sources/news/20191112 GitHub report surprises, serverless hotness, and more industry trends.md +++ /dev/null @@ -1,74 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (GitHub report surprises, serverless hotness, and more industry trends) -[#]: via: (https://opensource.com/article/19/11/github-report-serverless-hotness-more-industry-trends) -[#]: author: (Tim Hildred https://opensource.com/users/thildred) - -GitHub report surprises, serverless hotness, and more industry trends -====== -A weekly look at open source community and industry trends. -![Person standing in front of a giant computer screen with numbers, data][1] - -As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update. - -## [GitHub tops 40 million developers as Python, data science, machine learning popularity surges][2] - -> In its annual Octoverse report, GitHub, owned by Microsoft, said it had more than 10 million new users, 44 million repositories created and 87 million pull requests in the last 12 months. The report is a good view of open source software and where the community is headed. - -**The impact:** The finding that hit home hardest for me is that "nearly 80% of GitHub users are outside of the US." While an important part of open source history comes from the east and west coasts of America, there is a good chance that the future of the movement will happen elsewhere. - -## [Serverless: Is it the Kubernetes killer?][3] - -> Serverless isn't here to destroy Kubernetes. The cloud infrastructure space race isn't a zero-sum game. Kubernetes is an obvious evolution following OpenStack and can be run successfully inside of it. There will be OpenStack users for a long time to come, and there are also reasons many companies have moved on from there. Serverless is another tool in the belt of forward-thinking development teams. And increasingly, it can be [run on top of Kubernetes][4] (see Knative), enabling you to get the benefits of the simplicity of serverless and the complexity of Kubernetes where it makes sense for both in your stack. - -**The impact:** The moral of the story is that legacy doesn't really go away, it just gets built in and around. - -## [When Quarkus meets Knative serverless workloads][5] - -> Now, let's discuss how developers can use Quarkus to bring Java into serverless, a place where previously, it was unable to go. Quarkus introduces a comprehensive and seamless approach to generating an operating system specific (aka native) executable from your Java code, as you do with languages like Go and C/C++. Environments such as event-driven and serverless, where you need to start a service to react to an event, require a low time-to-first-response, and traditional Java stacks simply cannot provide this. Knative enables developers to run cloud-native applications as serverless containers in seconds and the containers will go down to zero on demand. -> -> In addition to compiling Java to Knative, Quarkus aims to improve developer productivity. Quarkus works out of the box with popular Java standards, frameworks and libraries like Eclipse MicroProfile, Apache Kafka, RESTEasy, Hibernate, Spring, and many more. Developers familiar with these will feel at home with Quarkus, which should streamline code for the majority of common use cases while providing the flexibility to cover others that come up. - -**The impact:** It's good to start getting specific with how and where the new hotness can be used. The answer, in this case, is "with the other new hotness." - -## [Why you should join the CNCF Meetup Program][6] - -> With the recent changes to Meetup’s [policies][7], we wanted to share a reminder of the benefits of joining the [CNCF Meetup Program][8] and encourage Meetups in the CNCF ecosystem to apply.  -> -> As part of our Meetup Pro membership, CNCF is able to organize a network with an unlimited number of groups on a single account. - -**The impact:** The long term response to this unfortunate fallout from the WeWork debacle is to build a distributed open source Meetup alternative. Thankfully in the meantime, the CNCF has a more pragmatic response. - -## [Introducing your friends to automation (and overcoming their fear)][9] - -> My team and I were in a meeting a little while back with a third party vendor when they asked us what our stance was on automation. My reply was, "We want to automate everything." On top of my reply, my teammates added, "Well, we don’t want to automate ourselves out of a job." - -**The impact:** I've always thought it was a bit cavalier when someone would say, "I think it's my job to automate myself out of a job." There is plenty of circumstances where that is the last measure of success someone would want to be measured by. I'm happy to see this addressed head-on. - -_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/11/github-report-serverless-hotness-more-industry-trends - -作者:[Tim Hildred][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/thildred -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) -[2]: https://www.zdnet.com/article/github-tops-40-million-developers-as-python-data-science-machine-learning-popularity-surges/#ftag=RSSbaffb68 -[3]: https://www.forbes.com/sites/forbestechcouncil/2019/11/04/serverless-is-it-the-kubernetes-killer/#7e6740711f77 -[4]: https://github.com/knative -[5]: https://vmblog.com/archive/2019/10/29/when-quarkus-meets-knative-serverless-workloads.aspx#.XbiN1JNKiuN -[6]: https://www.cncf.io/blog/2019/11/01/why-you-should-join-the-cncf-meetup-program/ -[7]: https://www.meetup.com/lp/paymentchanges?mpId=9038 -[8]: https://www.meetup.com/pro/cncf -[9]: https://www.redhat.com/sysadmin/introducing-automation diff --git a/sources/news/20191121 The Cross-Platform Source Explorer Sourcetrail is Now Open Source.md b/sources/news/20191121 The Cross-Platform Source Explorer Sourcetrail is Now Open Source.md deleted file mode 100644 index c4f25f1419..0000000000 --- a/sources/news/20191121 The Cross-Platform Source Explorer Sourcetrail is Now Open Source.md +++ /dev/null @@ -1,79 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (The Cross-Platform Source Explorer Sourcetrail is Now Open Source) -[#]: via: (https://itsfoss.com/sourcetrail/) -[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) - -The Cross-Platform Source Explorer Sourcetrail is Now Open Source -====== - -[Sourcetrail][1] is a cross-platform source explorer that lets you visualize the unfamiliar source code by using graph visualization. - -![][2] - -In other words, it makes it easy to understand the structure of source code and how it works (technically) by visually representing them using a graph. - -This is particularly helpful when you join a project and you have to work on existing code written in the past by several developers. - -You can use it with your favorite IDE like Eclipse, IntelliJ IDEA, PyCharm or code editors like Atom, Visual Studio Code, Sublime Text etc. It supports C, C++, Java and Python. - -This old video gives you the introduction to Sourcetrail: - -Even though it was free for non-commercial use, they charged for a commercial license. However, they recently decided to make the whole thing free and open source. - -So, yes, you can find their source code listed on [GitHub][3] now. - -### What Has Changed for Sourcetrail? - -The reason they switched as an open-source solution is that they wanted their tool to be accessible to more developers. - -Their commercial licensing plan was supposed to help them make money – however, it limited the reach of their project. - -In their [announcement post][4], they mentioned their idea of this decision as follows: - -> We have been going back and forth, discussing and testing potential solutions to many of those issues for a long time now. Many of our thoughts revolved around how to make more money and use it to solve those issues. Looking at other companies in the field, it seemed that to make more money, our only option was making our licenses more and more expensive, which in turn would limit our audience to fewer developers. We always dismissed the idea because **we started to make Sourcetrail to benefit as many developers as possible** and not to be a premium product for a few people in a handful of companies. - -Also, they found it tough to provide cross-platform support while trying to reproduce the issues and apply a fix to them, especially for Linux distros. So, making their project open source was an ideal choice. - -To further clarify the situation they also explained why their commercial licensing plan wasn’t working out: - -> Initially we received a couple of public grants that allowed us to launch Sourcetrail publicly. We decided to go down the traditional road of selling software licenses to sustain further development. Of course that meant to keep the code private if we wanted to protect our business…In retrospect, this decision really narrowed down our user base, making it hard for developers to start using Sourcetrail for multiple reasons - -You can find all the details for what they plan for the future in their [announcement post][4]. - -### How to get Sourcetrail on Linux? - -You can find and download the latest release of Sourcetrail on its release page on GitHub: - -[Download Sourcetrail][5] - -Extract the downloaded file and you’ll see a Sourcetrail.sh shell script. Run this script with sudo to install Sourcerail. - -You should [read the documentation][6] for the project setup. They also have some [useful tutorial videos on their YouTube channel][7]. - -Sourcetrail was free before but now it’s free in the true sense. It’s good to see that the developers have made it open source and now more programmers can use this tool to understand large, shared code base. You may also checkout a slightly similar open source tool [Sourcegraph][8]. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/sourcetrail/ - -作者:[Ankush Das][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/ankush/ -[b]: https://github.com/lujun9972 -[1]: https://www.sourcetrail.com/ -[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/sourcetrail-ui.png?ssl=1 -[3]: https://github.com/CoatiSoftware/Sourcetrail -[4]: https://www.sourcetrail.com/blog/open_source/ -[5]: https://github.com/CoatiSoftware/Sourcetrail/releases -[6]: https://www.sourcetrail.com/documentation/#PROJECTSETUP -[7]: https://www.youtube.com/channel/UCuKthdG-V4n2RZ1HDJhGVpQ/videos -[8]: https://itsfoss.com/sourcegraph/ diff --git a/sources/news/20191125 Fail-free Kubernetes, significant events, and more industry trends.md b/sources/news/20191125 Fail-free Kubernetes, significant events, and more industry trends.md deleted file mode 100644 index 009e30cd40..0000000000 --- a/sources/news/20191125 Fail-free Kubernetes, significant events, and more industry trends.md +++ /dev/null @@ -1,61 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Fail-free Kubernetes, significant events, and more industry trends) -[#]: via: (https://opensource.com/article/19/11/fail-free-kubernetes-and-more-trends) -[#]: author: (Tim Hildred https://opensource.com/users/thildred) - -Fail-free Kubernetes, significant events, and more industry trends -====== -A weekly look at open source community, market, and industry trends. -![Person standing in front of a giant computer screen with numbers, data][1] - -As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update. - -## [Why teams fail with Kubernetes—and what to do about it][2] - -> Fail to address the questions "Who is responsible for _x_?" and "Who is affected by _y_?" and you'll put all your efforts at risk. For example, replace "_x_" above with "deciding on namespaces versus clusters for service and environment isolation" or "upgrading all clusters to a new Kubernetes version," and you start to see why you need to clarify the boundaries of responsibility and their impacts. - -**The impact**: Wouldn't it be nice if operators and role-based access control could make the messiness of human interaction go away? Why can't auto-scaling just mean auto-scaling? Tough luck! You're going to have to figure out the people side of it too! - -## [The New Stack Context: The past, present, and future of Kubernetes][3] - -> What have been some of the most significant events in the Kubernetes and cloud native community over the past year? A lot of work has been done in slimming and stabilizing the core. Operators were a growing trend over the past year—operators are mechanisms to expand the number of things you can build on top of Kubernetes. We are seeing Kubernetes expand into new workloads as well. - -**The impact**: In some way, Kubernetes is an ongoing effort in re-building the airplane mid-flight. The good news is that we're getting better at doing that, and the future holds ubiquity, according to this podcast. - -## [Q&A: Fidelity invests in cloud-native, open source projects to step up innovation][4] - -> “We are seeing that Kubernetes, CNCF, and cloud-native technology are the key players for us when we go multicloud and hybrid-cloud model,” said [Amr Abdelhalem][5] (pictured), head of cloud platforms at Fidelity Investments. “That’s why we are here. We are here actually in Kubernetes and KubeCon for that reason. That’s where we see this abstract layer that guarantees you the portability for moving your application from one cloud provider to another.” - -**The impact**: Think about this: Fidelity is a member of the CNCF. What does that mean about the distance between the creator and consumer of open source software? It's exciting because it exemplifies the participatory ideals of open source; its a new challenge for the ecosystem because participants are starting to represent industry verticals that might not have much overlap whose needs need reconciliation. Fun times! - -## [The future of hybrid cloud is bright as 73% of enterprises moving apps back on Prem][6] - -> This year’s report illustrated that creating and executing a cloud strategy has become a multidimensional challenge. At one time, a primary value proposition associated with the public cloud was substantial upfront capex savings. Now, enterprises have discovered that there are other considerations when selecting the best cloud for the business as well, and that one size cloud strategy doesn’t fit all use cases. For example, while applications with unpredictable usage may be best suited to the public clouds offering elastic IT resources, workloads with more predictable characteristics can often run on-premises at a lower cost than public cloud. Savings are also dependent on businesses’ ability to match each application to the appropriate cloud service and pricing tier, and to remain diligent about regularly reviewing service plans and fees, which change frequently. - -**The impact**: The short version is that cost is not the only, or even the most important factor, in choosing where to run a workload. More and more often it is the nature of the workload itself. - -_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/11/fail-free-kubernetes-and-more-trends - -作者:[Tim Hildred][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/thildred -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) -[2]: https://techbeacon.com/enterprise-it/why-teams-fail-kubernetes-what-do-about-it -[3]: https://thenewstack.io/the-new-stack-context-the-past-present-and-future-of-kubernetes/ -[4]: https://siliconangle.com/2019/11/21/qa-fidelity-invests-cloud-native-open-source-projects-step-innovation-kubecon/ -[5]: https://www.linkedin.com/in/amrhalem/ -[6]: https://www.dqindia.com/the-future-of-hybrid-cloud-is-bright-as-73-of-enterprises-moving-apps-back-on-prem/ diff --git a/sources/news/20191127 Nvidia quietly unveils faster, lower power Tesla GPU accelerator.md b/sources/news/20191127 Nvidia quietly unveils faster, lower power Tesla GPU accelerator.md deleted file mode 100644 index 5ac59b5cac..0000000000 --- a/sources/news/20191127 Nvidia quietly unveils faster, lower power Tesla GPU accelerator.md +++ /dev/null @@ -1,70 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Nvidia quietly unveils faster, lower power Tesla GPU accelerator) -[#]: via: (https://www.networkworld.com/article/3482097/nvidia-quietly-unveils-faster-lower-power-tesla-gpu-accelerator.html) -[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) - -Nvidia quietly unveils faster, lower power Tesla GPU accelerator -====== -Nvidia has upgraded its Volta line of Tesla GPU-accelerator cards to work faster using the same power as its old model. -client - -Nvidia was all over Supercomputing 19 last week, not surprisingly, and made a lot of news which we will get into later. But overlooked was perhaps the most interesting news of all: a new generation graphics-acceleration card that is faster and way more power efficient. - -Multiple attendees and news sites spotted it at the show, and Nvidia confirmed to me that this is indeed a new card. Nvidia’s “Volta” generation of Tesla GPU-accelerator cards has been out since 2017, so an upgrade was well overdue. - -[[Get regularly scheduled insights by signing up for Network World newsletters.]][1] - -The V100S comes only in PCI Express 3 form factor for now but is expected to eventually support Nvidia’s SXM2 interface. SXM is a dual-slot card design by Nvidia that requires no connection to the power supply, unlike the PCIe cards. SXM2 allows the GPU to communicate either with each other or to the CPU through Nvidia’s NVLink, a high-bandwidth, energy-efficient interconnect that can transfer data up to ten times faster than PCIe. - -[][2] - -BrandPost Sponsored by HPE - -[Take the Intelligent Route with Consumption-Based Storage][2] - -Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. - -With this card, Nvidia is claiming 16.4 single-precision TFLOPS, 8.2 double-precision TFLOPS, and Tensor Core performance of up to 130 TFLOPS. That is only a 4-to-5 percent improvement over the V100 SXM2 design, but 16-to-17 percent faster than the PCIe V100 variant. - -Memory capacity remains at 32GB but Nvidia added High Bandwidth Memory 2 (HBM2) to increase memory performance to 1,134GB/s, a 26 percent improvement over both PCIe and SXM2. - -Now normally a performance boost would see a concurrent increase in power demand, but in this case, the power envelope for the PCIe card is 250 watts, same as the prior generation PCIe card. So this card delivers 16-to-17 percent more compute performance and 26 percent more memory bandwidth at the same power draw. - -**Other News** - -Nvidia made some other news at the conference: - - * A new reference design and ecosystem support for its GPU-accelerated Arm-based reference servers for high-performance computing. The company says it has support from HPE/Cray, Marvell, Fujitsu, and Ampere, the startup led by former Intel executive Renee James looking to build Arm-based server processors. - * These companies will use Nvidia's reference design, which consists of hardware and software components, to build their own GPU-accelerated servers for everything from hyperscale cloud providers to high-performance storage and exascale supercomputing. The design also comes with CUDA-X, a special version of Nvidia’s CUDA GPU development language for Arm processors. - * Launch of Nvidia Magnum IO suite of software designed to help data scientists and AI and high-performance-computing researchers process massive amounts of data in minutes rather than hours. It is optimized to eliminate storage and I/O bottlenecks to deliver up to 20x faster data processing for multi-server, multi-GPU computing nodes. - * Nvidia and DDN, developer of AI and multicloud data management, announced a bundling of DDN’s A3ITM data management system with Nvidia’s DGX SuperPOD systems with so customers can deploy HPC infrastructure with minimal complexity and reduced timelines. The SuperPODs would also come with the new NVIDIA Magnum IO software stack. - * DDN said that SuperPOD was able to be deployed within hours and a single appliance could scale all to 80 nodes.  Benchmarks over a variety of different deep-learning models showed that the DDN system could keep a DGXSuperPOD system fully saturated with data. - - - -**Now see** [**10 of the world's fastest supercomputers**][3] - -Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3482097/nvidia-quietly-unveils-faster-lower-power-tesla-gpu-accelerator.html - -作者:[Andy Patrizio][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Andy-Patrizio/ -[b]: https://github.com/lujun9972 -[1]: https://www.networkworld.com/newsletters/signup.html -[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) -[3]: https://www.networkworld.com/article/3236875/embargo-10-of-the-worlds-fastest-supercomputers.html -[4]: https://www.facebook.com/NetworkWorld/ -[5]: https://www.linkedin.com/company/network-world diff --git a/sources/news/20191127 Zorin OS Responds to the Privacy Concerns.md b/sources/news/20191127 Zorin OS Responds to the Privacy Concerns.md deleted file mode 100644 index 51151d2e87..0000000000 --- a/sources/news/20191127 Zorin OS Responds to the Privacy Concerns.md +++ /dev/null @@ -1,105 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Zorin OS Responds to the Privacy Concerns) -[#]: via: (https://itsfoss.com/zorin-os-privacy-concerns/) -[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) - -Zorin OS Responds to the Privacy Concerns -====== - -_**There were some privacy concerns around ‘data collection’ in Zorin OS. It’s FOSS spoke to Zorin OS CEO and here is his response to the controversy.**_ - -After a few days of [Zorin OS 15 Lite][1] release, a Reddit thread surfaced which flagged a privacy concern regarding the Linux distribution. - -The [Reddit thread][2] focuses on the [privacy policy][3] of Zorin OS and warns users that Zorin OS is sending anonymous pings every 60 minutes without users’ consent, which is potentially a privacy issue. - -![][4] - -The policy in question can be quoted here as: - -> _**Anonymous pings**: When using Zorin OS, your computer may occasionally send us a ping which includes an anonymous unique identifier for your computer. We use this information to count the number of active users of Zorin OS. The unique identifier does not identify you unless you (or someone acting on your behalf) discloses it separately. You may choose to disable these pings by uninstalling the “Zorin-os-census” package from your computer_ - -Now, there’s a lot of [discussions][5] surrounding the concern. There’s also a [YouTube video][6] talking about it. - -In a nutshell, it’s a mess. Some insist that they collect our IP addresses and some users complain that they should ask about it while installing Zorin OS. - -While I agree that they could add an opt-out option in the installation process – so I reached out to **Artyom Zorin** (_CEO, Zorin Group_) to clarify the situation. - -### Zorin’s Clarification On What They Collect With Every Anonymous Ping - -When I asked for an elaborate explanation of what the “**anonymous unique identifier**” includes, Artyom mentioned – “_It appears that there are some inaccuracies and misconceptions about the census in the comments sections_“. - -To continue the explanation about the unique identifier, he assured that **their servers do not log IP addresses** when a ping arrives. - -The zorin-os-census script **simply counts the number of unique computers using Zorin OS** and no personal data is being collected along with it. - -Artyom explained in detail: - -> The anonymous identifier is a series of letters and numbers which is randomly generated (not based on any external data) and only used for the Zorin OS Census. Its single purpose is to make sure that the computer isn’t double-counted when a ping is sent from a computer to the server. On a fully-installed Zorin OS system, the anonymous identifier can be found in /var/lib/zorin-os-census/uuid and should look like this:_68f2d95b-f51f-4a5d-9b48-a99c28691b89_ -> * -> *We would like to clarify that no personal or personally-identifiable data is being collected by us and the server does not log IP addresses when pings arrive. The zorin-os-census script is only used to count the number of computers and users running Zorin OS after installation. Even I wouldn’t be able to tell which computer is my own from looking at the server-side database. I have attached a screenshot of a snippet of the database table displaying the information we store. - -He also stressed his ‘commitment on privacy’: - -> Privacy is an essential human right. It’s a core tenet of our mission to give you back control of your technology, and not the other way around. We make privacy a priority with every decision we make, and we’re committed to protecting it in every level of the software we build. - -As you can observe in the response above, he shared a screenshot of how their database of unique identifiers looks like: - -![][7] - -If you’re still curious, you can also check out the [source code][8] for the zorin-os-census script. - -### Can We Opt-Out Of It? - -While the data collected may be ‘harmless’, it is important to give the option to the user whether or not they want Zorin OS to collect the data, right? - -So, when I inquired about the same, he mentioned that i**t was already something planned for Zorin OS 15 Lite release**. - -However, they did not want to rush to add it before properly testing it. Hence, they decided to keep it for the upcoming release (**Zorin OS 15.1**) which is planned to arrive in **early-to-mid December this year.** - -> We have in fact been working on implementing an opt-out option for this into the Zorin OS installer (Ubiquity). To ensure the stability and accessibility of this new functionality we’re adding to Ubiquity, we have scheduled a period of time to translate the text strings and rigorously test the software (in order to avoid regressions), as the installer is a critical component of the operating system. Unfortunately, the testing period for the opt-out option didn’t complete before our planned release of Zorin OS 15 Lite, and we, therefore, decided not to risk adding it before we could guarantee its stability. However, we are on track to include the opt-out option in the upcoming Zorin OS 15.1 release, which we plan to release in early-to-mid December. - -### Will It Be Something Similar To What Ubuntu Does? - -Ubuntu does let you opt-out from collecting information about your computer. - -So, when I asked if Zorin OS will add something similar to that, he responded with some details about how Ubuntu collects data and how Zorin OS is different from that. - -He mentioned the fact that Ubuntu comes pre-installed with a **popularity-contest** package that **occasionally sends data of what packages the user has installed** to the Ubuntu Developers. - -And, further clarified that **Zorin OS does not include that**. - -> While Ubuntu’s telemetry tool gives users the option to not send extensive information about the computers to the Ubuntu developers, selecting the “No” option still sends a ping to Ubuntu’s servers . -> -> From our research, it is not clear whether Ubuntu’s servers store logs of users’ IP addresses when they receive telemetry data. In addition, Zorin OS does not include the “popularity-contest” package that is pre-installed in Ubuntu. This package is designed to occasionally send a list of all packages a user has installed on their computer to the Ubuntu developers. - -**In the end…** - -While the concern regarding the anonymous pings may not seem to a privacy threat, an opt-out option should be presented to the user while installing Zorin OS. Let’s wait and watch if it should arrive in the upcoming Zorin OS 15.1 release. - -What do you think about the privacy concern mentioned above? Let us know your thoughts in the comments down below. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/zorin-os-privacy-concerns/ - -作者:[Ankush Das][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/ankush/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/zorin-os-lite/ -[2]: https://www.reddit.com/r/FreeAsInFreedom/comments/e0yhw4/beware_zorin_os_sends_anonymous_pings_every_60/ -[3]: https://zorinos.com/legal/privacy/ -[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/zorin-os-privacy-reddit.jpg?ssl=1 -[5]: https://www.reddit.com/r/linux/comments/e0zd5n/beware_zorin_os_sends_anonymous_pings_every_60/ -[6]: https://www.youtube.com/watch?v=bcgk9LvC36Y&feature=youtu.be&t=860 -[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/zorin-census-database.png?ssl=1 -[8]: https://launchpad.net/~zorinos/+archive/ubuntu/stable/+sourcepub/10183568/+listing-archive-extra diff --git a/sources/news/20191128 Open Source Music Notations Software MuseScore 3.3 Released.md b/sources/news/20191128 Open Source Music Notations Software MuseScore 3.3 Released.md deleted file mode 100644 index 2835a5d06a..0000000000 --- a/sources/news/20191128 Open Source Music Notations Software MuseScore 3.3 Released.md +++ /dev/null @@ -1,89 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Open Source Music Notations Software MuseScore 3.3 Released!) -[#]: via: (https://itsfoss.com/musescore/) -[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) - -Open Source Music Notations Software MuseScore 3.3 Released! -====== - -_**Brief: MuseScore is an open-source software to help you create, play, and print sheet music. They released a major update recently. So, we take a look at what MuseScore has to offer**_ _**overall.**_ - -### MuseScore: A Music Composition and Notation Software - -![][1] - -[MuseScore][2] is open-source software that lets you create, play, and print [sheet music][3]. - -You can even use a MIDI keyboard as input and simply play the tune you want to create the notation of. - -In order to make use of it, you need to know how sheet music notations work. In either case, you can just play something using your MIDI keyboard or any other instrument and learn how the music notations work while using it. - -So, it should come in handy for beginners and experts as well. - -You can download and use MuseScore for free. However, if you want to share your music/composition and reach out to a wider community on the MuseScore platform, you can opt to create a free or premium account on [MuseScore.com][4]. - -### Features of MuseScore - -![Musescore 3 Screenshot][5] - -MuseScore includes a lot of things that can be highlighted. If you are someone who is not involved in making music notations for your compositions – you might have to dig deeper just like me. - -Usually, I just head over to any [DAW available on Linux][6] and start playing something to record/loop it without needing to create the music notations. So, for me, MuseScore definitely presents a learning curve with all the features offered. - -I’ll just list out the features with some brief descriptions – so you can explore them if it sounds interesting to you. - - * Supports Input via MIDI keyboard - * You can transfer to/from other programs via [MusicXML][7], MIDI, and other options. - * A Huge collection of palettes (music symbols) to choose from. - * You also get the ability to re-arrange the palettes and create your own list of most-used palettes or edit them. - * Some plugins supported to extend the functionality - * Import PDFs to read and play notations - * Several instruments supported - * Basic or Advanced layout of palettes to get started - - - -Some of the recent key changes include the palettes redesign, accessibility, and the not input workflow. For reference, you can check out how the new palettes work: - -### Installing MuseScore 3.3.3 on Ubuntu/Linux - -The latest version of MuseScore is 3.3.3 with all the bug fixes and improvements to its recent [MuseScore 3.3 release][8]. - -You may find an older release in your Software Center (or your official repo). So, you can either opt for a Flatpak package, Snap, or maybe an AppImage from its [download page][9] with links for different Linux distributions. - -[Download MuseScore][9] - -**Wrapping Up** - -I was quite fascinated to learn about MuseScore being an open-source and free solution to create, play, and print sheet music. - -It may not be the most easy-to-use software there is – but when considering the work with music notations, it will help you learn more about it and help you with your work as well. - -What do you think about MuseScore? Do share your thoughts in the comments below. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/musescore/ - -作者:[Ankush Das][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/ankush/ -[b]: https://github.com/lujun9972 -[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/musescore-3.jpg?ssl=1 -[2]: https://musescore.org/en -[3]: https://en.wikipedia.org/wiki/Sheet_music -[4]: https://musescore.com/ -[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/musescore-3-screenshot.jpg?ssl=1 -[6]: https://itsfoss.com/best-audio-editors-linux/ -[7]: https://en.wikipedia.org/wiki/MusicXML -[8]: https://musescore.org/en/3.3 -[9]: https://musescore.org/en/download diff --git a/sources/news/20200301 Remember Unity8 from Ubuntu- UBports is Renaming it to Lomiri.md b/sources/news/20200301 Remember Unity8 from Ubuntu- UBports is Renaming it to Lomiri.md new file mode 100644 index 0000000000..7badbfc8a2 --- /dev/null +++ b/sources/news/20200301 Remember Unity8 from Ubuntu- UBports is Renaming it to Lomiri.md @@ -0,0 +1,91 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Remember Unity8 from Ubuntu? UBports is Renaming it to Lomiri) +[#]: via: (https://itsfoss.com/unity8-lomiri/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +Remember Unity8 from Ubuntu? UBports is Renaming it to Lomiri +====== + +Ever since Ubuntu abandoned the Unity project, UBports continued the maintenance and development of Unity. On February 27th 2020, [UBports][1] announced that they are giving Unity8 a new branding in the form of Lomiri. + +### Unity8 is now Lomiri + +![Unity8 in action | Image Credit: UBports][2] + +[UBports announced][3] that the Unity8 desktop environment would be renamed as Lomiri. They gave three reasons for this fairly drastic announcement. + +First, they want to avoid confusion with the [Unity game engine][4]. Quite a few people confused the two. UBports noted that they are frequently receiving questions regarding “how to import 3D models and meshes into our shell”. When you search “Unity” in your favorite search engine, most of the top links are for the game engine. + +The second reason for the name change has to do with the new effort to package Unity8 for Debian. Unfortunately, many of the Unity8’s dependencies have Ubuntu in the name, for example, _**ubuntu-ui-toolkit**_. Debian packagers warned that packages that have Ubuntu in the name may not be accepted into [Debian][5]. + +Finally, UBports said the name change would improve verbal communications. Saying Unity8 repeatedly can be a mouthful. People would not have to worry about confusing “users of Ubuntu Unity and Unity (the game engine)”. + +UBports went on to stress that the name change was not “triggered by any action from Canonical or the Ubuntu community, legal or otherwise”. + +They noted that this name change was the perfect time for them to switch to [GitHub alternative GitLab][6] for their development. + +Interestingly, the announcement did not explain how they picked Lomiri as the new name. All they said is that “We went through many different names before settling on Lomiri. All of them had problems with pronunciation, availability, or other related issues.” + +UBports noted that most Ubuntu Touch users would be unaffected by the name change. Developers and power users might notice some changes, but UBports “will strive to maintain backwards compatibility within Ubuntu Touch for the foreseeable future”. + +### What Exactly is Being Renamed? + +![][7] + +According to the announcement, packages that have either Ubuntu or Unity in the title will be affected. For example, + + * **unity8**, containing the shell, will become **lomiri** + * **ubuntu-ui-toolkit** will become **lomiri-ui-toolkit** + * **ubuntu-download-manager** will become **lomiri-download-manager** + + + +On top of this, interfaces call will change, as well. “For example, the **Ubuntu.Components** QML import will change to **Lomiri.Components**.” For the sake of backwards compatibility, Ubuntu Touch images will not change too much. “Developers will only need to update to the new API when they’d like to package their apps for other distributions.” + +### What Will Stay the Same? + +Since renaming packages can cause quite a few cascading problems, UBports wants to limit the number of packages they change. They don’t expect the following things to change. + + * Packages that don’t use the “Ubuntu” or “Unity” names + * Ubuntu Touch will remain the same + * Any components which are already used by other projects and accepted into other distributions + + + +### Final Thoughts + +![][8] + +Overall, I think this change will be good for Ubuntu Touch in the long run. I understand why [Canonical][9] picked the Unity name for their convergence desktop, but I think the desktop environment was overshadowed by the game engine from the beginning. This will give them room to breathe and also free up valuable coding time. The less time spent replying to questions about 3D models the more time that can be spent creating a convergent desktop. + +If you have any further questions or concerns about the name change, you visit the [UBports forms][10]. They have set up a thread specifically for this topic. + +Don’t hesitate to share our views on it in the comment section. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/unity8-lomiri/ + +作者:[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://ubports.com/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/unity8_ubports.png?ssl=1 +[3]: https://ubports.com/blog/ubports-blog-1/post/lomiri-new-name-same-great-unity8-265 +[4]: https://en.wikipedia.org/wiki/Unity_(game_engine) +[5]: https://www.debian.org/ +[6]: https://itsfoss.com/github-alternatives/ +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/Unity8-lomiri.png?ssl=1 +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/ubports.jpeg?ssl=1 +[9]: https://canonical.com/ +[10]: https://forums.ubports.com/topic/3874/unity8-is-now-lomiri diff --git a/sources/news/README.md b/sources/news/README.md new file mode 100644 index 0000000000..98d53847b1 --- /dev/null +++ b/sources/news/README.md @@ -0,0 +1 @@ +这里放新闻类文章,要求时效性 diff --git a/sources/talk/20170717 The Ultimate Guide to JavaScript Fatigue- Realities of our industry.md b/sources/talk/20170717 The Ultimate Guide to JavaScript Fatigue- Realities of our industry.md deleted file mode 100644 index 923d4618a9..0000000000 --- a/sources/talk/20170717 The Ultimate Guide to JavaScript Fatigue- Realities of our industry.md +++ /dev/null @@ -1,221 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (The Ultimate Guide to JavaScript Fatigue: Realities of our industry) -[#]: via: (https://lucasfcosta.com/2017/07/17/The-Ultimate-Guide-to-JavaScript-Fatigue.html) -[#]: author: (Lucas Fernandes Da Costa https://lucasfcosta.com) - -The Ultimate Guide to JavaScript Fatigue: Realities of our industry -====== - -**Complaining about JS Fatigue is just like complaining about the fact that humanity has created too many tools to solve the problems we have** , from email to airplanes and spaceships. - -Last week I’ve done a talk about this very same subject at the NebraskaJS 2017 Conference and I got so many positive feedbacks that I just thought this talk should also become a blog post in order to reach more people and help them deal with JS Fatigue and understand the realities of our industry. **My goal with this post is to change the way you think about software engineering in general and help you in any areas you might work on**. - -One of the things that has inspired me to write this blog post and that totally changed my life is [this great post by Patrick McKenzie, called “Don’t Call Yourself a Programmer and other Career Advice”][1]. **I highly recommend you read that**. Most of this blog post is advice based on what Patrick has written in that post applied to the JavaScript ecosystem and with a few more thoughts I’ve developed during these last years working in the tech industry. - -This first section is gonna be a bit philosophical, but I swear it will be worth reading. - -### Realities of Our Industry 101 - -Just like Patrick has done in [his post][1], let’s start with the most basic and essential truth about our industry: - -Software solves business problems - -This is it. **Software does not exist to please us as programmers** and let us write beautiful code. Neither it exists to create jobs for people in the tech industry. **Actually, it exists to kill as many jobs as possible, including ours** , and this is why basic income will become much more important in the next few years, but that’s a whole other subject. - -I’m sorry to say that, but the reason things are that way is that there are only two things that matter in the software engineering (and any other industries): - -**Cost versus Revenue** - -**The more you decrease cost and increase revenue, the more valuable you are** , and one of the most common ways of decreasing cost and increasing revenue is replacing human beings by machines, which are more effective and usually cost less in the long run. - -You are not paid to write code - -**Technology is not a goal.** Nobody cares about which programming language you are using, nobody cares about which frameworks your team has chosen, nobody cares about how elegant your data structures are and nobody cares about how good is your code. **The only thing that somebody cares about is how much does your software cost and how much revenue it generates**. - -Writing beautiful code does not matter to your clients. We write beautiful code because it makes us more productive in the long run and this decreases cost and increases revenue. - -The whole reason why we try not to write bugs is not that we value correctness, but that **our clients** value correctness. If you have ever seen a bug becoming a feature you know what I’m talking about. That bug exists but it should not be fixed. That happens because our goal is not to fix bugs, our goal is to generate revenue. If our bugs make clients happy then they increase revenue and therefore we are accomplishing our goals. - -Reusable space rockets, self-driving cars, robots, artificial intelligence: these things do not exist just because someone thought it would be cool to create them. They exist because there are business interests behind them. And I’m not saying the people behind them just want money, I’m sure they think that stuff is also cool, but the truth is that if they were not economically viable or had any potential to become so, they would not exist. - -Probably I should not even call this section “Realities of Our Industry 101”, maybe I should just call it “Realities of Capitalism 101”. - -And given that our only goal is to increase revenue and decrease cost, I think we as programmers should be paying more attention to requirements and design and start thinking with our minds and participating more actively in business decisions, which is why it is extremely important to know the problem domain we are working on. How many times before have you found yourself trying to think about what should happen in certain edge cases that have not been thought before by your managers or business people? - -In 1975, Boehm has done a research in which he found out that about 64% of all errors in the software he was studying were caused by design, while only 36% of all errors were coding errors. Another study called [“Higher Order Software—A Methodology for Defining Software”][2] also states that **in the NASA Apollo project, about 73% of all errors were design errors**. - -The whole reason why Design and Requirements exist is that they define what problems we’re going to solve and solving problems is what generates revenue. - -> Without requirements or design, programming is the art of adding bugs to an empty text file. -> -> * Louis Srygley -> - - -This same principle also applies to the tools we’ve got available in the JavaScript ecosystem. Babel, webpack, react, Redux, Mocha, Chai, Typescript, all of them exist to solve a problem and we gotta understand which problem they are trying to solve, we need to think carefully about when most of them are needed, otherwise, we will end up having JS Fatigue because: - -JS Fatigue happens when people use tools they don't need to solve problems they don't have. - -As Donald Knuth once said: “Premature optimization is the root of all evil”. Remember that software only exists to solve business problems and most software out there is just boring, it does not have any high scalability or high-performance constraints. Focus on solving business problems, focus on decreasing cost and generating revenue because this is all that matters. Optimize when you need, otherwise you will probably be adding unnecessary complexity to your software, which increases cost, and not generating enough revenue to justify that. - -This is why I think we should apply [Test Driven Development][3] principles to everything we do in our job. And by saying this I’m not just talking about testing. **I’m talking about waiting for problems to appear before solving them. This is what TDD is all about**. As Kent Beck himself says: “TDD reduces fear” because it guides your steps and allows you take small steps towards solving your problems. One problem at a time. By doing the same thing when it comes to deciding when to adopt new technologies then we will also reduce fear. - -Solving one problem at a time also decreases [Analysis Paralysis][4], which is basically what happens when you open Netflix and spend three hours concerned about making the optimal choice instead of actually watching something. By solving one problem at a time we reduce the scope of our decisions and by reducing the scope of our decisions we have fewer choices to make and by having fewer choices to make we decrease Analysis Paralysis. - -Have you ever thought about how easier it was to decide what you were going to watch when there were only a few TV channels available? Or how easier it was to decide which game you were going to play when you had only a few cartridges at home? - -### But what about JavaScript? - -By the time I’m writing this post NPM has 489,989 packages and tomorrow approximately 515 new ones are going to be published. - -And the packages we use and complain about have a history behind them we must comprehend in order to understand why we need them. **They are all trying to solve problems.** - -Babel, Dart, CoffeeScript and other transpilers come from our necessity of writing code other than JavaScript but making it runnable in our browsers. Babel even lets us write new generation JavaScript and make sure it will work even on older browsers, which has always been a great problem given the inconsistencies and different amount of compliance to the ECMA Specification between browsers. Even though the ECMA spec is becoming more and more solid these days, we still need Babel. And if you want to read more about Babel’s history I highly recommend that you read [this excellent post by Henry Zhu][5]. - -Module bundlers such as Webpack and Browserify also have their reason to exist. If you remember well, not so long ago we used to suffer a lot with lots of `script` tags and making them work together. They used to pollute the global namespace and it was reasonably hard to make them work together when one depended on the other. In order to solve this [`Require.js`][6] was created, but it still had its problems, it was not that straightforward and its syntax also made it prone to other problems, as you can see [in this blog post][7]. Then Node.js came with `CommonJS` imports, which were synchronous, simple and clean, but we still needed a way to make that work on our browsers and this is why we needed Webpack and Browserify. - -And Webpack itself actually solves more problems than that by allowing us to deal with CSS, images and many other resources as if they were JavaScript dependencies. - -Front-end frameworks are a bit more complicated, but the reason why they exist is to reduce the cognitive load when we write code so that we don’t need to worry about manipulating the DOM ourselves or even dealing with messy browser APIs (another problem JQuery came to solve), which is not only error prone but also not productive. - -This is what we have been doing this whole time in computer science. We use low-level abstractions and build even more abstractions on top of it. The more we worry about describing how our software should work instead of making it work, the more productive we are. - -But all those tools have something in common: **they exist because the web platform moves too fast**. Nowadays we’re using web technology everywhere: in web browsers, in desktop applications, in phone applications or even in watch applications. - -This evolution also creates problems we need to solve. PWAs, for example, do not exist only because they’re cool and we programmers have fun writing them. Remember the first section of this post: **PWAs exist because they create business value**. - -And usually standards are not fast enough to be created and therefore we need to create our own solutions to these things, which is why it is great to have such a vibrant and creative community with us. We’re solving problems all the time and **we are allowing natural selection to do its job**. - -The tools that suit us better thrive, get more contributors and develop themselves more quickly and sometimes other tools end up incorporating the good ideas from the ones that thrive and becoming even more popular than them. This is how we evolve. - -By having more tools we also have more choices. If you remember the UNIX philosophy well, it states that we should aim at creating programs that do one thing and do it well. - -We can clearly see this happening in the JS testing environment, for example, where we have Mocha for running tests and Chai for doing assertions, while in Java JUnit tries to do all these things. This means that if we have a problem with one of them or if we find another one that suits us better, we can simply replace that small part and still have the advantages of the other ones. - -The UNIX philosophy also states that we should write programs that work together. And this is exactly what we are doing! Take a look at Babel, Webpack and React, for example. They work very well together but we still do not need one to use the other. In the testing environment, for example, if we’re using Mocha and Chai all of a sudden we can just install Karma and run those same tests in multiple environments. - -### How to Deal With It - -My first advice for anyone suffering from JS Fatigue would definitely be to stay aware that **you don’t need to know everything**. Trying to learn it all at once, even when we don’t have to do so, only increases the feeling of fatigue. Go deep in areas that you love and for which you feel an inner motivation to study and adopt a lazy approach when it comes to the other ones. I’m not saying that you should be lazy, I’m just saying that you can learn those only when needed. Whenever you face a problem that requires you to use a certain technology to solve it, go learn. - -Another important thing to say is that **you should start from the beginning**. Make sure you have learned enough about JavaScript itself before using any JavaScript frameworks. This is the only way you will be able to understand them and bend them to your will, otherwise, whenever you face an error you have never seen before you won’t know which steps to take in order to solve it. Learning core web technologies such as CSS, HTML5, JavaScript and also computer science fundamentals or even how the HTTP protocol works will help you master any other technologies a lot more quickly. - -But please, don’t get too attached to that. Sometimes you gotta risk yourself and start doing things on your own. As Sacha Greif has written in [this blog post][8], spending too much time learning the fundamentals is just like trying to learn how to swim by studying fluid dynamics. Sometimes you just gotta jump into the pool and try to swim by yourself. - -And please, don’t get too attached to a single technology. All of the things we have available nowadays have already been invented in the past. Of course, they have different features and a brand new name, but, in their essence, they are all the same. - -If you look at NPM, it is nothing new, we already had Maven Central and Ruby Gems quite a long time ago. - -In order to transpile your code, Babel applies the very same principles and theory as some of the oldest and most well-known compilers, such as the GCC. - -Even JSX is not a new idea. It E4X (ECMAScript for XML) already existed more than 10 years ago. - -Now you might ask: “what about Gulp, Grunt and NPM Scripts?” Well, I’m sorry but we can solve all those problems with GNU Make in 1976. And actually, there are a reasonable number of JavaScript projects that still use it, such as Chai.js, for example. But we do not do that because we are hipsters that like vintage stuff. We use `make` because it solves our problems, and this is what you should aim at doing, as we’ve talked before. - -If you really want to understand a certain technology and be able to solve any problems you might face, please, dig deep. One of the most decisive factors to success is curiosity, so **dig deep into the technologies you like**. Try to understand them from bottom-up and whenever you think something is just “magic”, debunk that myth by exploring the codebase by yourself. - -In my opinion, there is no better quote than this one by Richard Feinman, when it comes to really learning something: - -> What I cannot create, I do not understand - -And just below this phrase, [in the same blackboard, Richard also wrote][9]: - -> Know how to solve every problem that has been solved - -Isn’t this just amazing? - -When Richard said that, he was talking about being able to take any theoretical result and re-derive it, but I think the exact same principle can be applied to software engineering. The tools that solve our problems have already been invented, they already exist, so we should be able to get to them all by ourselves. - -This is the very reason I love [some of the videos available in Egghead.io][10] in which Dan Abramov explains how to implement certain features that exist in Redux from scratch or [blog posts that teach you how to build your own JSX renderer][11]. - -So why not trying to implement these things by yourself or going to GitHub and reading their codebase in order to understand how they work? I’m sure you will find a lot of useful knowledge out there. Comments and tutorials might lie and be incorrect sometimes, the code cannot. - -Another thing that we have been talking a lot in this post is that **you should not get ahead of yourself**. Follow a TDD approach and solve one problem at a time. You are paid to increase revenue and decrease cost and you do this by solving problems, this is the reason why software exists. - -And since we love comparing our role to the ones related to civil engineering, let’s do a quick comparison between software development and civil engineering, just as [Sam Newman does in his brilliant book called “Building Microservices”][12]. - -We love calling ourselves “engineers” or “architects”, but is that term really correct? We have been developing software for what we know as computers less than a hundred years ago, while the Colosseum, for example, exists for about two thousand years. - -When was the last time you’ve seen a bridge falling and when was the last time your telephone or your browser crashed? - -In order to explain this, I’ll use an example I love. - -This is the beautiful and awesome city of Barcelona: - -![The City of Barcelona][13] - -When we look at it this way and from this distance, it just looks like any other city in the world, but when we look at it from above, this is how Barcelona looks: - -![Barcelona from above][14] - -As you can see, every block has the same size and all of them are very organized. If you’ve ever been to Barcelona you will also know how good it is to move through the city and how well it works. - -But the people that planned Barcelona could not predict what it was going to look like in the next two or three hundred years. In cities, people come in and people move through it all the time so what they had to do was make it grow organically and adapt as the time goes by. They had to be prepared for changes. - -This very same thing happens to our software. It evolves quickly, refactors are often needed and requirements change more frequently than we would like them to. - -So, instead of acting like a Software Engineer, act as a Town Planner. Let your software grow organically and adapt as needed. Solve problems as they come by but make sure everything still has its place. - -Doing this when it comes to software is even easier than doing this in cities due to the fact that **software is flexible, civil engineering is not**. **In the software world, our build time is compile time**. In Barcelona we cannot simply destroy buildings to give space to new ones, in Software we can do that a lot easier. We can break things all the time, we can make experiments because we can build as many times as we want and it usually takes seconds and we spend a lot more time thinking than building. Our job is purely intellectual. - -So **act like a town planner, let your software grow and adapt as needed**. - -By doing this you will also have better abstractions and know when it’s the right time to adopt them. - -As Sam Koblenski says: - -> Abstractions only work well in the right context, and the right context develops as the system develops. - -Nowadays something I see very often is people looking for boilerplates when they’re trying to learn a new technology, but, in my opinion, **you should avoid boilerplates when you’re starting out**. Of course boilerplates and generators are useful if you are already experienced, but they take a lot of control out of your hands and therefore you won’t learn how to set up a project and you won’t understand exactly where each piece of the software you are using fits. - -When you feel like you are struggling more than necessary to get something simple done, it might be the right time for you to look for an easier way to do this. In our role **you should strive to be lazy** , you should work to not work. By doing that you have more free time to do other things and this decreases cost and increases revenue, so that’s another way of accomplishing your goal. You should not only work harder, you should work smarter. - -Probably someone has already had the same problem as you’re having right now, but if nobody did it might be your time to shine and build your own solution and help other people. - -But sometimes you will not be able to realize you could be more effective in your tasks until you see someone doing them better. This is why it is so important to **talk to people**. - -By talking to people you share experiences that help each other’s careers and we discover new tools to improve our workflow and, even more important than that, learn how they solve their problems. This is why I like reading blog posts in which companies explain how they solve their problems. - -Especially in our area we like to think that Google and StackOverflow can answer all our questions, but we still need to know which questions to ask. I’m sure you have already had a problem you could not find a solution for because you didn’t know exactly what was happening and therefore didn’t know what was the right question to ask. - -But if I needed to sum this whole post in a single advice, it would be: - -Solve problems. - -Software is not a magic box, software is not poetry (unfortunately). It exists to solve problems and improves peoples’ lives. Software exists to push the world forward. - -**Now it’s your time to go out there and solve problems**. - - --------------------------------------------------------------------------------- - -via: https://lucasfcosta.com/2017/07/17/The-Ultimate-Guide-to-JavaScript-Fatigue.html - -作者:[Lucas Fernandes Da Costa][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://lucasfcosta.com -[b]: https://github.com/lujun9972 -[1]: http://www.kalzumeus.com/2011/10/28/dont-call-yourself-a-programmer/ -[2]: http://ieeexplore.ieee.org/document/1702333/ -[3]: https://en.wikipedia.org/wiki/Test_Driven_Development -[4]: https://en.wikipedia.org/wiki/Analysis_paralysis -[5]: https://babeljs.io/blog/2016/12/07/the-state-of-babel -[6]: http://requirejs.org -[7]: https://benmccormick.org/2015/05/28/moving-past-requirejs/ -[8]: https://medium.freecodecamp.org/a-study-plan-to-cure-javascript-fatigue-8ad3a54f2eb1 -[9]: https://www.quora.com/What-did-Richard-Feynman-mean-when-he-said-What-I-cannot-create-I-do-not-understand -[10]: https://egghead.io/lessons/javascript-redux-implementing-store-from-scratch -[11]: https://jasonformat.com/wtf-is-jsx/ -[12]: https://www.barnesandnoble.com/p/building-microservices-sam-newman/1119741399/2677517060476?st=PLA&sid=BNB_DRS_Marketplace+Shopping+Books_00000000&2sid=Google_&sourceId=PLGoP4760&k_clickid=3x4760 -[13]: /assets/barcelona-city.jpeg -[14]: /assets/barcelona-above.jpeg -[15]: https://twitter.com/thewizardlucas diff --git a/sources/talk/20170911 What every software engineer should know about search.md b/sources/talk/20170911 What every software engineer should know about search.md deleted file mode 100644 index 474a63201f..0000000000 --- a/sources/talk/20170911 What every software engineer should know about search.md +++ /dev/null @@ -1,513 +0,0 @@ -What every software engineer should know about search -============================================================ - -![](https://cdn-images-1.medium.com/max/2000/1*5AlsVRQrewLw74uHYTZ36w.jpeg) - - -### Want to build or improve a search experience? Start here. - -Ask a software engineer: “[How would you add search functionality to your product?][78]” or “[How do I build a search engine?][79]” You’ll probably immediately hear back something like: “Oh, we’d just launch an ElasticSearch cluster. Search is easy these days.” - -But is it? Numerous current products [still][80] [have][81] [suboptimal][82] [search][83] [experiences][84]. Any true search expert will tell you that few engineers have a very deep understanding of how search engines work, knowledge that’s often needed to improve search quality. - -Even though many open source software packages exist, and the research is vast, the knowledge around building solid search experiences is limited to a select few. Ironically, [searching online][85] for search-related expertise doesn’t yield any recent, thoughtful overviews. - -#### Emoji Legend - -``` -❗ “Serious” gotcha: consequences of ignorance can be deadly -🔷 Especially notable idea or piece of technology -☁️ ️Cloud/SaaS -🍺 Open source / free software -🦏 JavaScript -🐍 Python -☕ Java -🇨 C/C++ -``` - -### Why read this? - -Think of this post as a collection of insights and resources that could help you to build search experiences. It can’t be a complete reference, of course, but hopefully we can improve it based on feedback (please comment or reach out!). - -I’ll point at some of the most popular approaches, algorithms, techniques, and tools, based on my work on general purpose and niche search experiences of varying sizes at Google, Airbnb and several startups. - -❗️Not appreciating or understanding the scope and complexity of search problems can lead to bad user experiences, wasted engineering effort, and product failure. - -If you’re impatient or already know a lot of this, you might find it useful to jump ahead to the tools and services sections. - -### Some philosophy - -This is a long read. But most of what we cover has four underlying principles: - -#### 🔷 Search is an inherently messy problem: - -* Queries are highly variable. The search problems are highly variablebased on product needs. - -* Think about how different Facebook search (searching a graph of people). - -* YouTube search (searching individual videos). - -* Or how different both of those are are from Kayak ([air travel planning is a really hairy problem][2]). - -* Google Maps (making sense of geo-spacial data). - -* Pinterest (pictures of a brunch you might cook one day). - -#### Quality, metrics, and processes matter a lot: - -* There is no magic bullet (like PageRank) nor a magic ranking formula that makes for a good approach. Processes are always evolving collection of techniques and processes that solve aspects of the problem and improve overall experience, usually gradually and continuously. - -* ❗️In other words, search is not just just about building software that does ranking or retrieval (which we will discuss below) for a specific domain. Search systems are usually an evolving pipeline of components that are tuned and evolve over time and that build up to a cohesive experience. - -* In particular, the key to success in search is building processes for evaluation and tuning into the product and development cycles. A search system architect should think about processes and metrics, not just technologies. - -#### Use existing technologies first: - -* As in most engineering problems, don’t reinvent the wheel yourself. When possible, use existing services or open source tools. If an existing SaaS (such as [Algolia][3] or managed Elasticsearch) fits your constraints and you can afford to pay for it, use it. This solution will likely will be the best choice for your product at first, even if down the road you need to customize, enhance, or replace it. - -#### ❗️Even if you buy, know the details: - -* Even if you are using an existing open source or commercial solution, you should have some sense of the complexity of the search problem and where there are likely to be pitfalls. - -### Theory: the search problem - -Search is different for every product, and choices depend on many technical details of the requirements. It helps to identify the key parameters of your search problem: - -1. Size: How big is the corpus (a complete set of documents that need to be searched)? Is it thousands or billions of documents? - -2. Media: Are you searching through text, images, graphical relationships, or geospatial data? - -3. 🔷 Corpus control and quality: Are the sources for the documents under your control, or coming from a (potentially adversarial) third party? Are all the documents ready to be indexed or need to be cleaned up and selected? - -4. Indexing speed: Do you need real-time indexing, or is building indices in batch is fine? - -5. Query language: Are the queries structured, or you need to support unstructured ones? - -6. Query structure: Are your queries textual, images, sounds? Street addresses, record ids, people’s faces? - -7. Context-dependence: Do the results depend on who the user is, what is their history with the product, their geographical location, time of the day etc? - -8. Suggest support: Do you need to support incomplete queries? - -9. Latency: What are the serving latency requirements? 100 milliseconds or 100 seconds? - -10. Access control: Is it entirely public or should users only see a restricted subset of the documents? - -11. Compliance: Are there compliance or organizational limitations? - -12. Internationalization: Do you need to support documents with multilingual character sets or Unicode? (Hint: Always use UTF-8 unless you really know what you’re doing.) Do you need to support a multilingual corpus? Multilingual queries? - -Thinking through these points up front can help you make significant choices designing and building individual search system components. - - ** 此处有Canvas,请手动处理 ** - -![](https://cdn-images-1.medium.com/max/1600/1*qTK1iCtyJUr4zOyw4IFD7A.jpeg) -A production indexing pipeline. - -### Theory: the search pipeline - -Now let’s go through a list of search sub-problems. These are usually solved by separate subsystems that form a pipeline. What that means is that a given subsystem consumes the output of previous subsystems, and produces input for the following subsystems. - -This leads to an important property of the ecosystem: once you change how an upstream subsystem works, you need to evaluate the effect of the change and possibly change the behavior downstream. - -Here are the most important problems you need to solve: - -#### Index selection: - -given a set of documents (e.g. the entirety of the Internet, all the Twitter posts, all the pictures on Instagram), select a potentially smaller subset of documents that may be worthy for consideration as search results and only include those in the index, discarding the rest. This is done to keep your indexes compact, and is almost orthogonal to selecting the documents to show to the user. Examples of particular classes of documents that don’t make the cut may include: - -#### Spam: - -oh, all the different shapes and sizes of search spam! A giant topic in itself, worthy of a separate guide. [A good web spam taxonomy overview][86]. - -#### Undesirable documents: - -domain constraints might require filtering: [porn][87], illegal content, etc. The techniques are similar to spam filtering, probably with extra heuristics. - -#### Duplicates: - -Or near-duplicates and redundant documents. Can be done with [Locality-sensitive hashing][88], [similarity measures][89], clustering techniques or even [clickthrough data][90]. A [good overview][91] of techniques. - -#### Low-utility documents: - -The definition of utility depends highly on the problem domain, so it’s hard to recommend the approaches here. Some ideas are: it might be possible to build a utility function for your documents; heuristics might work, or example an image that contains only black pixels is not a useful document; utility might be learned from user behavior. - -#### Index construction: - -For most search systems, document retrieval is performed using an [inverted index][92] — often just called the index. - -* The index is a mapping of search terms to documents. A search term could be a word, an image feature or any other document derivative useful for query-to-document matching. The list of the documents for a given term is called a [posting list][1]. It can be sorted by some metric, like document quality. - -* Figure out whether you need to index the data in real time.❗️Many companies with large corpora of documents use a batch-oriented indexing approach, but then find this is unsuited to a product where users expect results to be current. - -* With text documents, term extraction usually involves using NLP techniques, such as stop lists, [stemming][4] and [entity extraction][5]; for images or videos computer vision methods are used etc. - -* In addition, documents are mined for statistical and meta information, such as references to other documents (used in the famous [PageRank][6]ranking signal), [topics][7], counts of term occurrences, document size, entities A mentioned etc. That information can be later used in ranking signal construction or document clustering. Some larger systems might contain several indexes, e.g. for documents of different types. - -* Index formats. The actual structure and layout of the index is a complex topic, since it can be optimized in many ways. For instance there are [posting lists compression methods][8], one could target [mmap()able data representation][9] or use[ LSM-tree][10] for continuously updated index. - -#### Query analysis and document retrieval: - -Most popular search systems allow non-structured queries. That means the system has to extract structure out of the query itself. In the case of an inverted index, you need to extract search terms using [NLP][93] techniques. - -The extracted terms can be used to retrieve relevant documents. Unfortunately, most queries are not very well formulated, so it pays to do additional query expansion and rewriting, like: - -* [Term re-weighting][11]. - -* [Spell checking][12]. Historical query logs are very useful as a dictionary. - -* [Synonym matching][13]. [Another survey][14]. - -* [Named entity recognition][15]. A good approach is to use [HMM-based language modeling][16]. - -* Query classification. Detect queries of particular type. For example, Google Search detects queries that contain a geographical entity, a porny query, or a query about something in the news. The retrieval algorithm can then make a decision about which corpora or indexes to look at. - -* Expansion through [personalization][17] or [local context][18]. Useful for queries like “gas stations around me”. - -#### Ranking: - -Given a list of documents (retrieved in the previous step), their signals, and a processed query, create an optimal ordering (ranking) for those documents. - -Originally, most ranking models in use were hand-tuned weighted combinations of all the document signals. Signal sets might include PageRank, clickthrough data, topicality information and [others][94]. - -To further complicate things, many of those signals, such as PageRank, or ones generated by [statistical language models][95] contain parameters that greatly affect the performance of a signal. Those have to be hand-tuned too. - -Lately, 🔷 [learning to rank][96], signal-based discriminative supervised approaches are becoming more and more popular. Some popular examples of LtR are [McRank][97] and [LambdaRank][98] from Microsoft, and [MatrixNet][99] from Yandex. - -A new, [vector space based approach][100] for semantic retrieval and ranking is gaining popularity lately. The idea is to learn individual low-dimensional vector document representations, then build a model which maps queries into the same vector space. - -Then, retrieval is just finding several documents that are closest by some metric (e.g. Eucledian distance) to the query vector. Ranking is the distance itself. If the mapping of both the documents and queries is built well, the documents are chosen not by a fact of presence of some simple pattern (like a word), but how close the documents are to the query by  _meaning_ . - -### Indexing pipeline operation - -Usually, each of the above pieces of the pipeline must be operated on a regular basis to keep the search index and search experience current. - -❗️Operating a search pipeline can be complex and involve a lot of moving pieces. Not only is the data moving through the pipeline, but the code for each module and the formats and assumptions embedded in the data will change over time. - -A pipeline can be run in “batch” or based on a regular or occasional basis (if indexing speed does not need to be real time) or in a streamed way (if real-time indexing is needed) or based on certain triggers. - -Some complex search engines (like Google) have several layers of pipelines operating on different time scales — for example, a page that changes often (like [cnn.com][101]) is indexed with a higher frequency than a static page that hasn’t changed in years. - -### Serving systems - -Ultimately, the goal of a search system is to accept queries, and use the index to return appropriately ranked results. While this subject can be incredibly complex and technical, we mention a few of the key aspects to this part of the system. - -* Performance: users notice when the system they interact with is laggy. ❗️Google has done [extensive research][19], and they have noticed that number of searches falls 0.6%, when serving is slowed by 300ms. They recommend to serve results under 200 ms for most of your queries. A good article [on the topic][20]. This is the hard part: the system needs to collect documents from, possibly, many computers, than merge them into possible a very long list and then sort that list in the ranking order. To complicate things further, ranking might be query-dependent, so, while sorting, the system is not just comparing 2 numbers, but performing computation. - -* 🔷 Caching results: is often necessary to achieve decent performance. ❗️ But caches are just one large gotcha. The might show stale results when indices are updated or some results are blacklisted. Purging caches is a can of warm of itself: a search system might not have the capacity to serve the entire query stream with an empty (cold) cache, so the [cache needs to be pre-warmed][21] before the queries start arriving. Overall, caches complicate a system’s performance profile. Choosing a cache size and a replacement algorithm is also a [challenge][22]. - -* Availability: is often defined by an uptime/(uptime + downtime) metric. When index is distributed, in order to serve any search results, the system often needs to query all the shards for their share of results. ❗️That means, that if one shard is unavailable, the entire search system is compromised. The more machines are involved in serving the index — the higher the probability of one of them becoming defunct and bringing the whole system down. - -* Managing multiple indices: Indices for large systems may separated into shards (pieces) or divided by media type or indexing cadence (fresh versus long-term indices). Results can then be merged. - -* Merging results of different kinds: e.g. Google showing results from Maps, News etc. - - ** 此处有Canvas,请手动处理 ** - -![](https://cdn-images-1.medium.com/max/1600/1*M8WQu17E7SDziV0rVwUKbw.jpeg) -A human rater. Yeah, you should still have those. - -### Quality, evaluation, and improvement - -So you’ve launched your indexing pipeline and search servers, and it’s all running nicely. Unfortunately the road to a solid search experience only begins with running infrastructure. - -Next, you’ll need to build a set of processes around continuous search quality evaluation and improvement. In fact, this is actually most of the work and the hardest problem you’ll have to solve. - -🔷 What is quality? First, you’ll need to determine (and get your boss or the product lead to agree), what quality means in your case: - -* Self-reported user satisfaction (includes UX) - -* Perceived relevance of the returned results (not including UX) - -* Satisfaction relative to competitors - -* Satisfaction relative performance of the previous version of the search engine (e.g. last week) - -* [User engagement][23] - -Metrics: Some of these concepts can be quite hard to quantify. On the other hand, it’s incredibly useful to be able to express how well a search engine is performing in a single number, a quality metric. - -Continuously computing such a metric for your (and your competitors’) system you can both track your progress and explain how well you are doing to your boss. Here are some classical ways to quantify quality, that can help you construct your magic quality metric formula: - -* [Precision][24] and [recall][25] measure how well the retrieved set of documents corresponds to the set you expected to see. - -* [F score][26] (specifically F1 score) is a single number, that represents both precision and recall well. - -* [Mean Average Precision][27] (MAP) allows to quantify the relevance of the top returned results. - -* 🔷 [Normalized Discounted Cumulative Gain][28] (nDCG) is like MAP, but weights the relevance of the result by its position. - -* [Long and short clicks][29] — Allow to quantify how useful the results are to the real users. - -* [A good detailed overview][30]. - -🔷 Human evaluations: Quality metrics might seem like statistical calculations, but they can’t all be done by automated calculations. Ultimately, metrics need to represent subjective human evaluation, and this is where a “human in the loop” comes into play. - -❗️Skipping human evaluation is probably the most spread reason of sub-par search experiences. - -Usually, at early stages the developers themselves evaluate the results manually. At later point [human raters][102] (or assessors) may get involved. Raters typically use custom tools to look at returned search results and provide feedback on the quality of the results. - -Subsequently, you can use the feedback signals to guide development, help make launch decisions or even feed them back into the index selection, retrieval or ranking systems. - -Here is the list of some other types of human-driven evaluation, that can be done on a search system: - -* Basic user evaluation: The user ranks their satisfaction with the whole experience - -* Comparative evaluation: Compare with other search results (compare with search results from earlier versions of the system or competitors) - -* Retrieval evaluation: The query analysis and retrieval quality is often evaluated using manually constructed query-document sets. A user is shown a query and the list of the retrieved documents. She can then mark all the documents that are relevant to the query, and the ones that are not. The resulting pairs of (query, [relevant docs]) are called a “golden set”. Golden sets are remarkably useful. For one, an engineer can set up automatic retrieval regression tests using those sets. The selection signal from golden sets can also be fed back as ground truth to term re-weighting and other query re-writing models. - -* Ranking evaluation: Raters are presented with a query and two documents side-by-side. The rater must choose the document that fits the query better. This creates a partial ordering on the documents for a given query. That ordering can be later be compared to the output of the ranking system. The usual ranking quality measures used are MAP and nDCG. - -#### Evaluation datasets: - -One should start thinking about the datasets used for evaluation (like “golden sets” mentioned above) early in the search experience design process. How you collect and update them? How you push them to the production eval pipeline? Is there a built-in bias? - -Live experiments: - -After your search engine catches on and gains enough users, you might want to start conducting [live search experiments][103] on a portion of your traffic. The basic idea is to turn some optimization on for a group of people, and then compare the outcome with that of a “control” group — a similar sample of your users that did not have the experiment feature on for them. How you would measure the outcome is, once again, very product specific: it could be clicks on results, clicks on ads etc. - -Evaluation cycle time: How fast you improve your search quality is directly related to how fast you can complete the above cycle of measurement and improvement. It is essential from the beginning to ask yourself, “how fast can we measure and improve our performance?” - -Will it take days, hours, minutes or seconds to make changes and see if they improve quality? ❗️Running evaluation should also be as easy as possible for the engineers and should not take too much hands-on time. - -### 🔷 So… How do I PRACTICALLY build it? - -This blogpost is not meant as a tutorial, but here is a brief outline of how I’d approach building a search experience right now: - -1. As was said above, if you can afford it — just buy the existing SaaS (some good ones are listed below). An existing service fits if: - -* Your experience is a “connected” one (your service or app has internet connection). - -* Does it support all the functionality you need out of box? This post gives a pretty good idea of what functions would you want. To name a few, I’d at least consider: support for the media you are searching; real-time indexing support; query flexibility, including context-dependent queries. - -* Given the size of the corpus and the expected [QpS][31], can you afford to pay for it for the next 12 months? - -* Can the service support your expected traffic within the required latency limits? In case when you are querying the service from an app, make sure that the given service is accessible quickly enough from where your users are. - -2\. If a hosted solution does not fit your needs or resources, you probably want to use one of the open source libraries or tools. In case of connected apps or websites, I’d choose ElasticSearch right now. For embedded experiences, there are multiple tools below. - -3\. You most likely want to do index selection and clean up your documents (say extract relevant text from HTML pages) before uploading them to the search index. This will decrease the index size and make getting to good results easier. If your corpus fits on a single machine, just write a script (or several) to do that. If not, I’d use [Spark][104]. - - ** 此处有Canvas,请手动处理 ** - -![](https://cdn-images-1.medium.com/max/1600/1*lGw4kVVQyj8E5by2GWVoQg.jpeg) -You can never have too many tools. - -### ☁️ SaaS - -☁️ 🔷[Algolia][105] — a proprietary SaaS that indexes a client’s website and provides an API to search the website’s pages. They also have an API to submit your own documents, support context dependent searches and serve results really fast. If I were building a web search experience right now and could afford it, I’d probably use Algolia first — and buy myself time to build a comparable search experience. - -* Various ElasticSearch providers: AWS (☁️ [ElasticSearch Cloud)][32], ☁️[elastic.co][33] and from ☁️ [Qbox][34]. - -* ☁️[ Azure Search][35] — a SaaS solution from Microsoft. Accessible through a REST API, it can scale to billions of documents. Has a Lucene query interface to simplify migrations from Lucene-based solutions. - -* ☁️[ Swiftype][36] — an enterprise SaaS that indexes your company’s internal services, like Salesforce, G Suite, Dropbox and the intranet site. - -### Tools and libraries - -🍺☕🔷[ Lucene][106] is the most popular IR library. Implements query analysis, index retrieval and ranking. Either of the components can be replaced by an alternative implementation. There is also a C port — 🍺[Lucy][107]. - -* 🍺☕🔷[ Solr][37] is a complete search server, based on Lucene. It’s a part of the [Hadoop][38] ecosystem of tools. - -* 🍺☕🔷[ Hadoop][39] is the most widely used open source MapReduce system, originally designed as a indexing pipeline framework for Solr. It has been gradually loosing ground to 🍺[Spark][40] as the batch data processing framework used for indexing. ☁️[EMR][41] is a proprietary implementation of MapReduce on AWS. - -* 🍺☕🔷 [ElasticSearch][42] is also based on Lucene ([feature comparison with Solr][43]). It has been getting more attention lately, so much that a lot of people think of ES when they hear “search”, and for good reasons: it’s well supported, has [extensive API][44], [integrates with Hadoop][45] and [scales well][46]. There are open source and [Enterprise][47] versions. ES is also available as a SaaS on Can scale to billions of documents, but scaling to that point can be very challenging, so typical scenario would involve orders of magnitude smaller corpus. - -* 🍺🇨 [Xapian][48] — a C++-based IR library. Relatively compact, so good for embedding into desktop or mobile applications. - -* 🍺🇨 [Sphinx][49] — an full-text search server. Has a SQL-like query language. Can also act as a [storage engine for MySQL][50] or used as a library. - -* 🍺☕ [Nutch][51] — a web crawler. Can be used in conjunction with Solr. It’s also the tool behind [🍺Common Crawl][52]. - -* 🍺🦏 [Lunr][53] — a compact embedded search library for web apps on the client-side. - -* 🍺🦏 [searchkit][54] — a library of web UI components to use with ElasticSearch. - -* 🍺🦏 [Norch][55] — a [LevelDB][56]-based search engine library for Node.js. - -* 🍺🐍 [Whoosh][57] — a fast, full-featured search library implemented in pure Python. - -* OpenStreetMaps has it’s own 🍺[deck of search software][58]. - -### Datasets - -A few fun or useful data sets to try building a search engine or evaluating search engine quality: - -* 🍺🔷 [Commoncrawl][59] — a regularly-updated open web crawl data. There is a [mirror on AWS][60], accessible for free within the service. - -* 🍺🔷 [Openstreetmap data dump][61] is a very rich source of data for someone building a geospacial search engine. - -* 🍺 [Google Books N-grams][62] can be very useful for building language models. - -* 🍺 [Wikipedia dumps][63] are a classic source to build, among other things, an entity graph out of. There is a [wide range of helper tools][64] available. - -* [IMDb dumps][65] are a fun dataset to build a small toy search engine for. - -### References - -* [Modern Information Retrieval][66] by R. Baeza-Yates and B. Ribeiro-Neto is a good, deep academic treatment of the subject. This is a good overview for someone completely new to the topic. - -* [Information Retrieval][67] by S. Büttcher, C. Clarke and G. Cormack is another academic textbook with a wide coverage and is more up-to-date. Covers learn-to-rank and does a pretty good job at discussing theory of search systems evaluation. Also is a good overview. - -* [Learning to Rank][68] by T-Y Liu is a best theoretical treatment of LtR. Pretty thin on practical aspects though. Someone considering building an LtR system should probably check this out. - -* [Managing Gigabytes][69] — published in 1999, is still a definitive reference for anyone embarking on building an efficient index of a significant size. - -* [Text Retrieval and Search Engines][70] — a MOOC from Coursera. A decent overview of basics. - -* [Indexing the World Wide Web: The Journey So Far][71] ([PDF][72]), an overview of web search from 2012, by Ankit Jain and Abhishek Das of Google. - -* [Why Writing Your Own Search Engine is Hard][73] a classic article from 2004 from Anna Patterson. - -* [https://github.com/harpribot/awesome-information-retrieval][74] — a curated list of search-related resources. - -* A [great blog][75] on everything search by [Daniel Tunkelang][76]. - -* Some good slides on [search engine evaluation][77]. - -This concludes my humble attempt to make a somewhat-useful “map” for an aspiring search engine engineer. Did I miss something important? I’m pretty sure I did — you know, [the margin is too narrow][108] to contain this enormous topic. Let me know if you think that something should be here and is not — you can reach [me][109] at[ forwidur@gmail.com][110] or at [@forwidur][111]. - -> P.S. — This post is part of a open, collaborative effort to build an online reference, the Open Guide to Practical AI, which we’ll release in draft form soon. See [this popular guide][112] for an example of what’s coming. If you’d like to get updates on or help with with this effort, sign up [here][113]. - -> Special thanks to [Joshua Levy][114], [Leo Polovets][115] and [Abhishek Das][116] for reading drafts of this and their invaluable feedback! - -> Header image courtesy of [Mickaël Forrett][117]. The beautiful toolbox is called [The Studley Tool Chest][118]. - --------------------------------------------------------------------------------- - -作者简介: - -Max Grigorev -distributed systems, data, AI - -------------- - - -via: https://medium.com/startup-grind/what-every-software-engineer-should-know-about-search-27d1df99f80d - -作者:[Max Grigorev][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://medium.com/@forwidur?source=post_header_lockup -[1]:https://en.wikipedia.org/wiki/Inverted_index -[2]:http://www.demarcken.org/carl/papers/ITA-software-travel-complexity/ITA-software-travel-complexity.pdf -[3]:https://www.algolia.com/ -[4]:https://en.wikipedia.org/wiki/Stemming -[5]:https://en.wikipedia.org/wiki/Named-entity_recognition -[6]:http://ilpubs.stanford.edu:8090/422/1/1999-66.pdf -[7]:https://gofishdigital.com/semantic-topic-modeling/ -[8]:https://nlp.stanford.edu/IR-book/html/htmledition/postings-file-compression-1.html -[9]:https://deplinenoise.wordpress.com/2013/03/31/fast-mmapable-data-structures/ -[10]:https://en.wikipedia.org/wiki/Log-structured_merge-tree -[11]:http://orion.lcg.ufrj.br/Dr.Dobbs/books/book5/chap11.htm -[12]:http://norvig.com/spell-correct.html -[13]:http://nlp.stanford.edu/IR-book/html/htmledition/query-expansion-1.html -[14]:https://www.iro.umontreal.ca/~nie/IFT6255/carpineto-Survey-QE.pdf -[15]:https://en.wikipedia.org/wiki/Named-entity_recognition -[16]:http://www.aclweb.org/anthology/P02-1060 -[17]:https://en.wikipedia.org/wiki/Personalized_search -[18]:http://searchengineland.com/future-search-engines-context-217550 -[19]:http://services.google.com/fh/files/blogs/google_delayexp.pdf -[20]:http://highscalability.com/latency-everywhere-and-it-costs-you-sales-how-crush-it -[21]:https://stackoverflow.com/questions/22756092/what-does-it-mean-by-cold-cache-and-warm-cache-concept -[22]:https://en.wikipedia.org/wiki/Cache_performance_measurement_and_metric -[23]:http://blog.popcornmetrics.com/5-user-engagement-metrics-for-growth/ -[24]:https://en.wikipedia.org/wiki/Information_retrieval#Precision -[25]:https://en.wikipedia.org/wiki/Information_retrieval#Recall -[26]:https://en.wikipedia.org/wiki/F1_score -[27]:http://fastml.com/what-you-wanted-to-know-about-mean-average-precision/ -[28]:https://en.wikipedia.org/wiki/Discounted_cumulative_gain -[29]:http://www.blindfiveyearold.com/short-clicks-versus-long-clicks -[30]:https://arxiv.org/pdf/1302.2318.pdf -[31]:https://en.wikipedia.org/wiki/Queries_per_second -[32]:https://aws.amazon.com/elasticsearch-service/ -[33]:https://www.elastic.co/ -[34]:https://qbox.io/ -[35]:https://azure.microsoft.com/en-us/services/search/ -[36]:https://swiftype.com/ -[37]:http://lucene.apache.org/solr/ -[38]:http://hadoop.apache.org/ -[39]:http://hadoop.apache.org/ -[40]:http://spark.apache.org/ -[41]:https://aws.amazon.com/emr/ -[42]:https://www.elastic.co/products/elasticsearch -[43]:http://solr-vs-elasticsearch.com/ -[44]:https://www.elastic.co/guide/en/elasticsearch/reference/current/docs.html -[45]:https://github.com/elastic/elasticsearch-hadoop -[46]:https://www.elastic.co/guide/en/elasticsearch/guide/current/distributed-cluster.html -[47]:https://www.elastic.co/cloud/enterprise -[48]:https://xapian.org/ -[49]:http://sphinxsearch.com/ -[50]:https://mariadb.com/kb/en/mariadb/sphinx-storage-engine/ -[51]:https://nutch.apache.org/ -[52]:http://commoncrawl.org/ -[53]:https://lunrjs.com/ -[54]:https://github.com/searchkit/searchkit -[55]:https://github.com/fergiemcdowall/norch -[56]:https://github.com/google/leveldb -[57]:https://bitbucket.org/mchaput/whoosh/wiki/Home -[58]:http://wiki.openstreetmap.org/wiki/Search_engines -[59]:http://commoncrawl.org/ -[60]:https://aws.amazon.com/public-datasets/common-crawl/ -[61]:http://wiki.openstreetmap.org/wiki/Downloading_data -[62]:http://commondatastorage.googleapis.com/books/syntactic-ngrams/index.html -[63]:https://dumps.wikimedia.org/ -[64]:https://www.mediawiki.org/wiki/Alternative_parsers -[65]:http://www.imdb.com/interfaces -[66]:https://www.amazon.com/dp/0321416910 -[67]:https://www.amazon.com/dp/0262528878/ -[68]:https://www.amazon.com/dp/3642142664/ -[69]:https://www.amazon.com/dp/1558605703 -[70]:https://www.coursera.org/learn/text-retrieval -[71]:https://research.google.com/pubs/pub37043.html -[72]:https://pdfs.semanticscholar.org/28d8/288bff1b1fc693e6d80c238de9fe8b5e8160.pdf -[73]:http://queue.acm.org/detail.cfm?id=988407 -[74]:https://github.com/harpribot/awesome-information-retrieval -[75]:https://medium.com/@dtunkelang -[76]:https://www.cs.cmu.edu/~quixote/ -[77]:https://web.stanford.edu/class/cs276/handouts/lecture8-evaluation_2014-one-per-page.pdf -[78]:https://stackoverflow.com/questions/34314/how-do-i-implement-search-functionality-in-a-website -[79]:https://www.quora.com/How-to-build-a-search-engine-from-scratch -[80]:https://github.com/isaacs/github/issues/908 -[81]:https://www.reddit.com/r/Windows10/comments/4jbxgo/can_we_talk_about_how_bad_windows_10_search_sucks/d365mce/ -[82]:https://www.reddit.com/r/spotify/comments/2apwpd/the_search_function_sucks_let_me_explain/ -[83]:https://medium.com/@RohitPaulK/github-issues-suck-723a5b80a1a3#.yp8ui3g9i -[84]:https://thenextweb.com/opinion/2016/01/11/netflix-search-sucks-flixed-fixes-it/ -[85]:https://www.google.com/search?q=building+a+search+engine -[86]:http://airweb.cse.lehigh.edu/2005/gyongyi.pdf -[87]:https://www.researchgate.net/profile/Gabriel_Sanchez-Perez/publication/262371199_Explicit_image_detection_using_YCbCr_space_color_model_as_skin_detection/links/549839cf0cf2519f5a1dd966.pdf -[88]:https://en.wikipedia.org/wiki/Locality-sensitive_hashing -[89]:https://en.wikipedia.org/wiki/Similarity_measure -[90]:https://www.microsoft.com/en-us/research/wp-content/uploads/2011/02/RadlinskiBennettYilmaz_WSDM2011.pdf -[91]:http://infolab.stanford.edu/~ullman/mmds/ch3.pdf -[92]:https://en.wikipedia.org/wiki/Inverted_index -[93]:https://en.wikipedia.org/wiki/Natural_language_processing -[94]:http://backlinko.com/google-ranking-factors -[95]:http://times.cs.uiuc.edu/czhai/pub/slmir-now.pdf -[96]:https://en.wikipedia.org/wiki/Learning_to_rank -[97]:https://papers.nips.cc/paper/3270-mcrank-learning-to-rank-using-multiple-classification-and-gradient-boosting.pdf -[98]:https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/lambdarank.pdf -[99]:https://yandex.com/company/technologies/matrixnet/ -[100]:https://arxiv.org/abs/1708.02702 -[101]:http://cnn.com/ -[102]:http://static.googleusercontent.com/media/www.google.com/en//insidesearch/howsearchworks/assets/searchqualityevaluatorguidelines.pdf -[103]:https://googleblog.blogspot.co.uk/2008/08/search-experiments-large-and-small.html -[104]:https://spark.apache.org/ -[105]:https://www.algolia.com/ -[106]:https://lucene.apache.org/ -[107]:https://lucy.apache.org/ -[108]:https://www.brainyquote.com/quotes/quotes/p/pierredefe204944.html -[109]:https://www.linkedin.com/in/grigorev/ -[110]:mailto:forwidur@gmail.com -[111]:https://twitter.com/forwidur -[112]:https://github.com/open-guides/og-aws -[113]:https://upscri.be/d29cfe/ -[114]:https://twitter.com/ojoshe -[115]:https://twitter.com/lpolovets -[116]:https://www.linkedin.com/in/abhishek-das-3280053/ -[117]:https://www.behance.net/gallery/3530289/-HORIZON- -[118]:https://en.wikipedia.org/wiki/Henry_O._Studley diff --git a/sources/talk/20171030 Why I love technical debt.md b/sources/talk/20171030 Why I love technical debt.md deleted file mode 100644 index da071d370a..0000000000 --- a/sources/talk/20171030 Why I love technical debt.md +++ /dev/null @@ -1,69 +0,0 @@ -Why I love technical debt -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUS_lovemoneyglory1.png?itok=nbSRovsj) -This is not necessarily the title you'd expect for an article, I guess,* but I'm a fan of [technical debt][1]. There are two reasons for this: a Bad Reason and a Good Reason. I'll be upfront about the Bad Reason first, then explain why even that isn't really a reason to love it. I'll then tackle the Good Reason, and you'll nod along in agreement. - -### The Bad Reason I love technical debt - -We'll get this out of the way, then, shall we? The Bad Reason is that, well, there's just lots of it, it's interesting, it keeps me in a job, and it always provides a reason, as a security architect, for me to get involved in** projects that might give me something new to look at. I suppose those aren't all bad things. It can also be a bit depressing, because there's always so much of it, it's not always interesting, and sometimes I need to get involved even when I might have better things to do. - -And what's worse is that it almost always seems to be security-related, and it's always there. That's the bad part. - -Security, we all know, is the piece that so often gets left out, or tacked on at the end, or done in half the time it deserves, or done by people who have half an idea, but don't quite fully grasp it. I should be clear at this point: I'm not saying that this last reason is those people's fault. That people know they need security is fantastic. If we (the security folks) or we (the organization) haven't done a good enough job in making sufficient security resources--whether people, training, or visibility--available to those people who need it, the fact that they're trying is great and something we can work on. Let's call that a positive. Or at least a reason for hope.*** - -### The Good Reason I love technical debt - -Let's get on to the other reason: the legitimate reason. I love technical debt when it's named. - -What does that mean? - -We all get that technical debt is a bad thing. It's what happens when you make decisions for pragmatic reasons that are likely to come back and bite you later in a project's lifecycle. Here are a few classic examples that relate to security: - - * Not getting around to applying authentication or authorization controls on APIs that might, at some point, be public. - * Lumping capabilities together so it's difficult to separate out appropriate roles later on. - * Hard-coding roles in ways that don't allow for customisation by people who may use your application in different ways from those you initially considered. - * Hard-coding cipher suites for cryptographic protocols, rather than putting them in a config file where they can be changed or selected later. - - - -There are lots more, of course, but those are just a few that jump out at me and that I've seen over the years. Technical debt means making decisions that will mean more work later on to fix them. And that can't be good, can it? - -There are two words in the preceding paragraphs that should make us happy: they are "decisions" and "pragmatic." Because, in order for something to be named technical debt, I'd argue, it has to have been subject to conscious decision-making, and trade-offs must have been made--hopefully for rational reasons. Those reasons may be many and various--lack of qualified resources; project deadlines; lack of sufficient requirement definition--but if they've been made consciously, then the technical debt can be named, and if technical debt can be named, it can be documented. - -And if it's documented, we're halfway there. As a security guy, I know that I can't force everything that goes out of the door to meet all the requirements I'd like--but the same goes for the high availability gal, the UX team, the performance folks, etc. - -What we need--what we all need--is for documentation to exist about why decisions were made, because when we return to the problem we'll know it was thought about. And, what's more, the recording of that information might even make it into product documentation. "This API is designed to be used in a protected environment and should not be exposed on the public Internet" is a great piece of documentation. It may not be what a customer is looking for, but at least they know how to deploy the product, and, crucially, it's an opportunity for them to come back to the product manager and say, "We'd really like to deploy that particular API in this way. Could you please add this as a feature request?" Product managers like that. Very much.**** - -The best thing, though, is not just that named technical debt is visible technical debt, but that if you encourage your developers to document the decisions in code,***** then there's a decent chance that they'll record some ideas about how this should be done in the future. If you're really lucky, they might even add some hooks in the code to make it easier (an "auth" parameter on the API, which is unused in the current version, but will make API compatibility so much simpler in new releases; or cipher entry in the config file that currently only accepts one option, but is at least checked by the code). - -I've been a bit disingenuous, I know, by defining technical debt as named technical debt. But honestly, if it's not named, then you can't know what it is, and until you know what it is, you can't fix it.******* My advice is this: when you're doing a release close-down (or in your weekly standup--EVERY weekly standup), have an agenda item to record technical debt. Name it, document it, be proud, sleep at night. - -* Well, apart from the obvious clickbait reason--for which I'm (a little) sorry. - -** I nearly wrote "poke my nose into." - -*** Work with me here. - -**** If you're software engineer/coder/hacker, here's a piece of advice: Learn to talk to product managers like real people, and treat them nicely. They (the better ones, at least) are invaluable allies when you need to prioritize features or have tricky trade-offs to make. - -***** Do this. Just do it. Documentation that isn't at least mirrored in code isn't real documentation.****** - -****** Don't believe me? Talk to developers. "Who reads product documentation?" "Oh, the spec? I skimmed it. A few releases back. I think." "I looked in the header file; couldn't see it there." - -******* Or decide not to fix it, which may also be an entirely appropriate decision. - -This article originally appeared on [Alice, Eve, and Bob - a security blog][2] and is republished with permission. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/10/why-i-love-technical-debt - -作者:[Mike Bursell][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/mikecamel -[1]:https://en.wikipedia.org/wiki/Technical_debt -[2]:https://aliceevebob.wordpress.com/2017/08/29/why-i-love-technical-debt/ diff --git a/sources/talk/20171107 How to Monetize an Open Source Project.md b/sources/talk/20171107 How to Monetize an Open Source Project.md deleted file mode 100644 index ab51006101..0000000000 --- a/sources/talk/20171107 How to Monetize an Open Source Project.md +++ /dev/null @@ -1,86 +0,0 @@ -How to Monetize an Open Source Project -====== - -![](http://www.itprotoday.com/sites/itprotoday.com/files/styles/article_featured_standard/public/ThinkstockPhotos-629994230_0.jpg?itok=5dZ68OTn) -The problem for any small group of developers putting the finishing touches on a commercial open source application is figuring out how to monetize the software in order to keep the bills paid and food on the table. Often these small pre-startups will start by deciding which of the recognized open source business models they're going to adapt, whether that be following Red Hat's lead and offering professional services, going the SaaS route, releasing as open core or something else. - -Steven Grandchamp, general manager for MariaDB's North America operations and CEO for Denver-based startup [Drud Tech][1], thinks that might be putting the cart before the horse. With an open source project, the best first move is to get people downloading and using your product for free. - -**Related:** [Demand for Open Source Skills Continues to Grow][2] - -"The number one tangent to monetization in any open source product is adoption, because the key to monetizing an open source product is you flip what I would call the sales funnel upside down," he told ITPro at the recent All Things Open conference in Raleigh, North Carolina. - -In many ways, he said, selling open source solutions is the opposite of marketing traditional proprietary products, where adoption doesn't happen until after a contract is signed. - -**Related:** [Is Raleigh the East Coast's Silicon Valley?][3] - -"In a proprietary software company, you advertise, you market, you make claims about what the product can do, and then you have sales people talk to customers. Maybe you have a free trial or whatever. Maybe you have a small version. Maybe it's time bombed or something like that, but you don't really get to realize the benefit of the product until there's a contract and money changes hands." - -Selling open source solutions is different because of the challenge of selling software that's freely available as a GitHub download. - -"The whole idea is to put the product out there, let people use it, experiment with it, and jump on the chat channels," he said, pointing out that his company Drud has a public chat channel that's open to anybody using their product. "A subset of that group is going to raise their hand and go, 'Hey, we need more help. We'd like a tighter relationship with the company. We'd like to know where your road map's going. We'd like to know about customization. We'd like to know if maybe this thing might be on your road map.'" - -Grandchamp knows more than a little about making software pay, from both the proprietary and open source sides of the fence. In the 1980s he served as VP of research and development at Formation Technologies, and became SVP of R&D at John H. Harland after it acquired Formation in the mid-90s. He joined MariaDB in 2016, after serving eight years as CEO at OpenLogic, which was providing commercial support for more than 600 open-source projects at the time it was acquired by Rogue Wave Software. Along the way, there was a two year stint at Microsoft's Redmond campus. - -OpenLogic was where he discovered open source, and his experiences there are key to his approach for monetizing open source projects. - -"When I got to OpenLogic, I was told that we had 300 customers that were each paying $99 a year for access to our tool," he explained. "But the problem was that nobody was renewing the tool. So I called every single customer that I could find and said 'did you like the tool?'" - -It turned out that nearly everyone he talked to was extremely happy with the company's software, which ironically was the reason they weren't renewing. The company's tool solved their problem so well there was no need to renew. - -"What could we have offered that would have made you renew the tool?" he asked. "They said, 'If you had supported all of the open source products that your tool assembled for me, then I would have that ongoing relationship with you.'" - -Grandchamp immediately grasped the situation, and when the CTO said such support would be impossible, Grandchamp didn't mince words: "Then we don't have a company." - -"We figured out a way to support it," he said. "We created something called the Open Logic Expert Community. We developed relationships with committers and contributors to a couple of hundred open source packages, and we acted as sort of the hub of the SLA for our customers. We had some people on staff, too, who knew the big projects." - -After that successful launch, Grandchamp and his team began hearing from customers that they were confused over exactly what open source code they were using in their projects. That lead to the development of what he says was the first software-as-a-service compliance portal of open source, which could scan an application's code and produce a list of all of the open source code included in the project. When customers then expressed confusion over compliance issues, the SaaS service was expanded to flag potential licensing conflicts. - -Although the product lines were completely different, the same approach was used to monetize MariaDB, then called SkySQL, after MySQL co-founders Michael "Monty" Widenius, David Axmark, and Allan Larsson created the project by forking MySQL, which Oracle had acquired from Sun Microsystems in 2010. - -Again, users were approached and asked what things they would be willing to purchase. - -"They wanted different functionality in the database, and you didn't really understand this if you didn't talk to your customers," Grandchamp explained. "Monty and his team, while they were being acquired at Sun and Oracle, were working on all kinds of new functionality, around cloud deployments, around different ways to do clustering, they were working on lots of different things. That work, Oracle and MySQL didn't really pick up." - -Rolling in the new features customers wanted needed to be handled gingerly, because it was important to the folks at MariaDB to not break compatibility with MySQL. This necessitated a strategy around when the code bases would come together and when they would separate. "That road map, knowledge, influence and technical information was worth paying for." - -As with OpenLogic, MariaDB customers expressed a willingness to spend money on a variety of fronts. For example, a big driver in the early days was a project called Remote DBA, which helped customers make up for a shortage of qualified database administrators. The project could help with design issues, as well as monitor existing systems to take the workload off of a customer's DBA team. The service also offered access to MariaDB's own DBAs, many of whom had a history with the database going back to the early days of MySQL. - -"That was a subscription offering that people were definitely willing to pay for," he said. - -The company also learned, again by asking and listening to customers, that there were various types of support subscriptions that customers were willing to purchase, including subscriptions around capability and functionality, and a managed service component of Remote DBA. - -These days Grandchamp is putting much of his focus on his latest project, Drud, a startup that offers a suite of integrated, automated, open source development tools for developing and managing multiple websites, which can be running on any combination of content management systems and deployment platforms. It is monetized partially through modules that add features like a centralized dashboard and an "intelligence engine." - -As you might imagine, he got it off the ground by talking to customers and giving them what they indicated they'd be willing to purchase. - -"Our number one customer target is the agency market," he said. "The enterprise market is a big target, but I believe it's our second target, not our first. And the reason it's number two is they don't make decisions very fast. There are technology refresh cycles that have to come up, there are lots of politics involved and lots of different vendors. It's lucrative once you're in, but in a startup you've got to figure out how to pay your bills. I want to pay my bills today. I don't want to pay them in three years." - -Drud's focus on the agency market illustrates another consideration: the importance of understanding something about your customers' business. When talking with agencies, many said they were tired of being offered generic software that really didn't match their needs from proprietary vendors that didn't understand their business. In Drud's case, that understanding is built into the company DNA. The software was developed by an agency to fill its own needs. - -"We are a platform designed by an agency for an agency," Grandchamp said. "Right there is a relationship that they're willing to pay for. We know their business." - -Grandchamp noted that startups also need to be able to distinguish users from customers. Most of the people downloading and using commercial open source software aren't the people who have authorization to make purchasing decisions. These users, however, can point to the people who control the purse strings. - -"It's our job to build a way to communicate with those users, provide them value so that they'll give us value," he explained. "It has to be an equal exchange. I give you value of a tool that works, some advice, really good documentation, access to experts who can sort of guide you along. Along the way I'm asking you for pieces of information. Who do you work for? How are the technology decisions happening in your company? Are there other people in your company that we should refer the product to? We have to create the dialog." - -In the end, Grandchamp said, in the open source world the people who go out to find business probably shouldn't see themselves as salespeople, but rather, as problem solvers. - -"I believe that you're not really going to need salespeople in this model. I think you're going to need customer success people. I think you're going to need people who can enable your customers to be successful in a business relationship that's more highly transactional." - -"People don't like to be sold," he added, "especially in open source. The last person they want to see is the sales person, but they like to ply and try and consume and give you input and give you feedback. They love that." - --------------------------------------------------------------------------------- - -via: http://www.itprotoday.com/software-development/how-monetize-open-source-project - -作者:[Christine Hall][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://www.itprotoday.com/author/christine-hall -[1]:https://www.drud.com/ -[2]:http://www.itprotoday.com/open-source/demand-open-source-skills-continues-grow -[3]:http://www.itprotoday.com/software-development/raleigh-east-coasts-silicon-valley diff --git a/sources/talk/20171114 Why pair writing helps improve documentation.md b/sources/talk/20171114 Why pair writing helps improve documentation.md deleted file mode 100644 index ff3bbb5888..0000000000 --- a/sources/talk/20171114 Why pair writing helps improve documentation.md +++ /dev/null @@ -1,87 +0,0 @@ -Why pair writing helps improve documentation -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/doc-dish-lead-2.png?itok=lPO6tqPd) - -Professional writers, at least in the Red Hat documentation team, nearly always work on docs alone. But have you tried writing as part of a pair? In this article, I'll explain a few benefits of pair writing. -### What is pair writing? - -Pair writing is when two writers work in real time, on the same piece of text, in the same room. This approach improves document quality, speeds up writing, and allows writers to learn from each other. The idea of pair writing is borrowed from [pair programming][1]. - -When pair writing, you and your colleague work on the text together, making suggestions and asking questions as needed. Meanwhile, you're observing each other's work. For example, while one is writing, the other writer observes details such as structure or context. Often discussion around the document turns into sharing experiences and opinions, and brainstorming about writing in general. - -At all times, the writing is done by only one person. Thus, you need only one computer, unless you want one writer to do online research while the other person does the writing. The text workflow is the same as if you are working alone: a text editor, the documentation source files, git, and so on. - -### Pair writing in practice - -My colleague Aneta Steflova and I have done more than 50 hours of pair writing working on the Red Hat Enterprise Linux System Administration docs and on the Red Hat Identity Management docs. I've found that, compared to writing alone, pair writing: - - * is as productive or more productive; - * improves document quality; - * helps writers share technical expertise; and - * is more fun. - - - -### Speed - -Two writers writing one text? Sounds half as productive, right? Wrong. (Usually.) - -Pair writing can help you work faster because two people have solutions to a bigger set of problems, which means getting blocked less often during the process. For example, one time we wrote urgent API docs for identity management. I know at least the basics of web APIs, the REST protocol, and so on, which helped us speed through those parts of the documentation. Working alone, Aneta would have needed to interrupt the writing process frequently to study these topics. - -### Quality - -Poor wording or sentence structure, inconsistencies in material, and so on have a harder time surviving under the scrutiny of four eyes. For example, one of our pair writing documents was reviewed by an extremely critical developer, who was known for catching technical inaccuracies and bad structure. After this particular review, he said, "Perfect. Thanks a lot." - -### Sharing expertise - -Each of us lives in our own writing bubble, and we normally don't know how others approach writing. Pair writing can help you improve your own writing process. For example, Aneta showed me how to better handle assignments in which the developer has provided starting text (as opposed to the writer writing from scratch using their own knowledge of the subject), which I didn't have experience with. Also, she structures the docs thoroughly, which I began doing as well. - -As another example, I'm good enough at Vim that XML editing (e.g., tags manipulation) is enjoyable instead of torturous. Aneta saw how I was using Vim, asked about it, suffered through the learning curve, and now takes advantage of the Vim features that help me. - -Pair writing is especially good for helping and mentoring new writers, and it's a great way to get to know professionally (and have fun with) colleagues. - -### When pair writing shines - -In addition to benefits I've already listed, pair writing is especially good for: - - * **Working with[Bugzilla][2]** : Bugzillas can be cumbersome and cause problems, especially for administration-clumsy people (like me). - * **Reviewing existing documents** : When documentation needs to be expanded or fixed, it is necessary to first examine the existing document. - * **Learning new technology** : A fellow writer can be a better teacher than an engineer. - * **Writing emails/requests for information to developers with well-chosen questions** : The difficulty of this task rises in proportion to the difficulty of technology you are documenting. - - - -Also, with pair writing, feedback is in real time, as-needed, and two-way. - -On the downside, pair writing can be a faster pace, giving a writer less time to mull over a topic or wording. On the other hand, generally peer review is not necessary after pair writing. - -### Words of caution - -To get the most out of pair writing: - - * Go into the project well prepared, otherwise you can waste your colleague's time. - * Talkative types need to stay focused on the task, otherwise they end up talking rather than writing. - * Be prepared for direct feedback. Pair writing is not for feedback-allergic writers. - * Beware of session hijackers. Dominant personalities can turn pair writing into writing solo with a spectator. (However, it _can _ be good if one person takes over at times, as long as the less-experienced partner learns from the hijacker, or the more-experienced writer is providing feedback to the hijacker.) - - - -### Conclusion - -Pair writing is a meeting, but one in which you actually get work done. It's an activity that lets writers focus on the one indispensable thing in our vocation--writing. - -_This post was written with the help of pair writing with Aneta Steflova._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/11/try-pair-writing - -作者:[Maxim Svistunov][a] -译者:[译者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/maxim-svistunov -[1]:https://developer.atlassian.com/blog/2015/05/try-pair-programming/ -[2]:https://www.bugzilla.org/ diff --git a/sources/talk/20171115 Why and How to Set an Open Source Strategy.md b/sources/talk/20171115 Why and How to Set an Open Source Strategy.md deleted file mode 100644 index 79ec071b4d..0000000000 --- a/sources/talk/20171115 Why and How to Set an Open Source Strategy.md +++ /dev/null @@ -1,120 +0,0 @@ -Why and How to Set an Open Source Strategy -============================================================ - -![](https://www.linuxfoundation.org/wp-content/uploads/2017/11/open-source-strategy-1024x576.jpg) - -This article explains how to walk through, measure, and define strategies collaboratively in an open source community. - - _“If you don’t know where you are going, you’ll end up someplace else.” _ _—_  Yogi Berra - -Open source projects are generally started as a way to scratch one’s itch — and frankly that’s one of its greatest attributes. Getting code down provides a tangible method to express an idea, showcase a need, and solve a problem. It avoids over thinking and getting a project stuck in analysis-paralysis, letting the project pragmatically solve the problem at hand. - -Next, a project starts to scale up and gets many varied users and contributions, with plenty of opinions along the way. That leads to the next big challenge — how does a project start to build a strategic vision? In this article, I’ll describe how to walk through, measure, and define strategies collaboratively, in a community. - -Strategy may seem like a buzzword of the corporate world rather something that an open source community would embrace, so I suggest stripping away the negative actions that are sometimes associated with this word (e.g., staff reductions, discontinuations, office closures). Strategy done right isn’t a tool to justify unfortunate actions but to help show focus and where each community member can contribute. - -A good application of strategy achieves the following: - -* Why the project exists? - -* What the project looks to achieve? - -* What is the ideal end state for a project is. - -The key to success is answering these questions as simply as possible, with consensus from your community. Let’s look at some ways to do this. - -### Setting a mission and vision - - _“_ _Efforts and courage are not enough without purpose and direction.”_  — John F. Kennedy - -All strategic planning starts off with setting a course for where the project wants to go. The two tools used here are  _Mission_  and  _Vision_ . They are complementary terms, describing both the reason a project exists (mission) and the ideal end state for a project (vision). - -A great way to start this exercise with the intent of driving consensus is by asking each key community member the following questions: - -* What drove you to join and/or contribute the project? - -* How do you define success for your participation? - -In a company, you’d ask your customers these questions usually. But in open source projects, the customers are the project participants — and their time investment is what makes the project a success. - -Driving consensus means capturing the answers to these questions and looking for themes across them. At R Consortium, for example, I created a shared doc for the board to review each member’s answers to the above questions, and followed up with a meeting to review for specific themes that came from those insights. - -Building a mission flows really well from this exercise. The key thing is to keep the wording of your mission short and concise. Open Mainframe Project has done this really well. Here’s their mission: - - _Build community and adoption of Open Source on the mainframe by:_ - -* _Eliminating barriers to Open Source adoption on the mainframe_ - -* _Demonstrating value of the mainframe on technical and business levels_ - -* _Strengthening collaboration points and resources for the community to thrive_ - -At 40 words, it passes the key eye tests of a good mission statement; it’s clear, concise, and demonstrates the useful value the project aims for. - -The next stage is to reflect on the mission statement and ask yourself this question: What is the ideal outcome if the project accomplishes its mission? That can be a tough one to tackle. Open Mainframe Project put together its vision really well: - - _Linux on the Mainframe as the standard for enterprise class systems and applications._ - -You could read that as a [BHAG][1], but it’s really more of a vision, because it describes a future state that is what would be created by the mission being fully accomplished. It also hits the key pieces to an effective vision — it’s only 13 words, inspirational, clear, memorable, and concise. - -Mission and vision add clarity on the who, what, why, and how for your project. But, how do you set a course for getting there? - -### Goals, Objectives, Actions, and Results - - _“I don’t focus on what I’m up against. I focus on my goals and I try to ignore the rest.”_  — Venus Williams - -Looking at a mission and vision can get overwhelming, so breaking them down into smaller chunks can help the project determine how to get started. This also helps prioritize actions, either by importance or by opportunity. Most importantly, this step gives you guidance on what things to focus on for a period of time, and which to put off. - -There are lots of methods of time bound planning, but the method I think works the best for projects is what I’ve dubbed the GOAR method. It’s an acronym that stands for: - -* Goals define what the project is striving for and likely would align and support the mission. Examples might be “Grow a diverse contributor base” or “Become the leading project for X.” Goals are aspirational and set direction. - -* Objectives show how you measure a goal’s completion, and should be clear and measurable. You might also have multiple objectives to measure the completion of a goal. For example, the goal “Grow a diverse contributor base” might have objectives such as “Have X total contributors monthly” and “Have contributors representing Y different organizations.” - -* Actions are what the project plans to do to complete an objective. This is where you get tactical on exactly what needs done. For example, the objective “Have contributors representing Y different organizations” would like have actions of reaching out to interested organizations using the project, having existing contributors mentor new mentors, and providing incentives for first time contributors. - -* Results come along the way, showing progress both positive and negative from the actions. - -You can put these into a table like this: - -| Goals | Objectives | Actions | Results | -|:--|:--|:--|:--| -| Grow a diverse contributor base     | Have X total contributors monthly | Existing contributors mentor new mentors Providing incentives for first time contributors | | -| | Have contributors representing Y different organizations | Reach out to interested organizations using the project | | - - -In large organizations, monthly or quarterly goals and objectives often make sense; however, on open source projects, these time frames are unrealistic. Six- even 12-month tracking allows the project leadership to focus on driving efforts at a high level by nurturing the community along. - -The end result is a rubric that provides clear vision on where the project is going. It also lets community members more easily find ways to contribute. For example, your project may include someone who knows a few organizations using the project — this person could help introduce those developers to the codebase and guide them through their first commit. - -### What happens if the project doesn’t hit the goals? - - _“I have not failed. I’ve just found 10,000 ways that won’t work.”_  — Thomas A. Edison - -Figuring out what is within the capability of an organization — whether Fortune 500 or a small open source project — is hard. And, sometimes the expectations or market conditions change along the way. Does that make the strategy planning process a failure? Absolutely not! - -Instead, you can use this experience as a way to better understand your project’s velocity, its impact, and its community, and perhaps as a way to prioritize what is important and what’s not. - --------------------------------------------------------------------------------- - -via: https://www.linuxfoundation.org/blog/set-open-source-strategy/ - -作者:[ John Mertic][a] -译者:[译者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/author/jmertic/ -[1]:https://en.wikipedia.org/wiki/Big_Hairy_Audacious_Goal -[2]:https://www.linuxfoundation.org/author/jmertic/ -[3]:https://www.linuxfoundation.org/category/blog/ -[4]:https://www.linuxfoundation.org/category/audience/c-level/ -[5]:https://www.linuxfoundation.org/category/audience/developer-influencers/ -[6]:https://www.linuxfoundation.org/category/audience/entrepreneurs/ -[7]:https://www.linuxfoundation.org/category/campaigns/membership/how-to/ -[8]:https://www.linuxfoundation.org/category/campaigns/events-campaigns/linux-foundation/ -[9]:https://www.linuxfoundation.org/category/audience/open-source-developers/ -[10]:https://www.linuxfoundation.org/category/audience/open-source-professionals/ -[11]:https://www.linuxfoundation.org/category/audience/open-source-users/ -[12]:https://www.linuxfoundation.org/category/blog/thought-leadership/ diff --git a/sources/talk/20171116 Why is collaboration so difficult.md b/sources/talk/20171116 Why is collaboration so difficult.md deleted file mode 100644 index 6567b75dca..0000000000 --- a/sources/talk/20171116 Why is collaboration so difficult.md +++ /dev/null @@ -1,94 +0,0 @@ -Why is collaboration so difficult? -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cube_innovation_block_collaboration.png?itok=pKbXpr1e) - -Many contemporary definitions of "collaboration" define it simply as "working together"--and, in part, it is working together. But too often, we tend to use the term "collaboration" interchangeably with cognate terms like "cooperation" and "coordination." These terms also refer to some manner of "working together," yet there are subtle but important differences between them all. - -How does collaboration differ from coordination or cooperation? What is so important about collaboration specifically? Does it have or do something that coordination and cooperation don't? The short answer is a resounding "yes!" - -[This unit explores collaboration][1], a problematic term because it has become a simple buzzword for "working together." By the time you've studied the cases and practiced the exercises contained in this section, you will understand that it's so much more than that. - -### Not like the others - -"Coordination" can be defined as the ordering of a variety of people acting in an effective, unified manner toward an end goal or state - -In traditional organizations and businesses, people contributed according to their role definitions, such as in manufacturing, where each employee was responsible for adding specific components to the widget on an assembly line until the widget was complete. In contexts like these, employees weren't expected to contribute beyond their pre-defined roles (they were probably discouraged from doing so), and they didn't necessarily have a voice in the work or in what was being created. Often, a manager oversaw the unification of effort (hence the role "project coordinator"). Coordination is meant to connote a sense of harmony and unity, as if elements are meant to go together, resulting in efficiency among the ordering of the elements. - -One common assumption is that coordinated efforts are aimed at the same, single goal. So some end result is "successful" when people and parts work together seamlessly; when one of the parts breaks down and fails, then the whole goal fails. Many traditional businesses (for instance, those with command-and-control hierarchies) manage work through coordination. - -Cooperation is another term whose surface meaning is "working together." Rather than the sense of compliance that is part of "coordination," it carries a sense of agreement and helpfulness on the path toward completing a shared activity or goal. - -"Collaboration" also means "working together"--but that simple definition obscures the complex and often difficult process of collaborating. - -People tend to use the term "cooperation" when joining two semi-related entities where one or more entity could decide not to cooperate. The people and pieces that are part of a cooperative effort make the shared activity easier to perform or the shared goal easier to reach. "Cooperation" implies a shared goal or activity we agree to pursue jointly. One example is how police and witnesses cooperate to solve crimes. - -"Collaboration" also means "working together"--but that simple definition obscures the complex and often difficult process of collaborating. - -Sometimes collaboration involves two or more groups that do not normally work together; they are disparate groups or not usually connected. For instance, a traitor collaborates with the enemy, or rival businesses collaborate with each other. The subtlety of collaboration is that the two groups may have oppositional initial goals but work together to create a shared goal. Collaboration can be more contentious than coordination or cooperation, but like cooperation, any one of the entities could choose not to collaborate. Despite the contention and conflict, however, there is discourse--whether in the form of multi-way discussion or one-way feedback--because without discourse, there is no way for people to express a point of dissent that is ripe for negotiation. - -The success of any collaboration rests on how well the collaborators negotiate their needs to create the shared objective, and then how well they cooperate and coordinate their resources to execute a plan to reach their goals. - -### For example - -One way to think about these things is through a real-life example--like the writing of [this book][1]. - -The editor, [Bryan][2], coordinates the authors' work through the call for proposals, setting dates and deadlines, collecting the writing, and meeting editing dates and deadlines for feedback about our work. He coordinates the authors, the writing, the communications. In this example, I'm not coordinating anything except myself (still a challenge most days!). - -The success of any collaboration rests on how well the collaborators negotiate their needs to create the shared objective, and then how well they cooperate and coordinate their resources to execute a plan to reach their goals. - -I cooperate with Bryan's dates and deadlines, and with the ways he has decided to coordinate the work. I propose the introduction on GitHub; I wait for approval. I comply with instructions, write some stuff, and send it to him by the deadlines. He cooperates by accepting a variety of document formats. I get his edits,incorporate them, send it back him, and so forth. If I don't cooperate (or something comes up and I can't cooperate), then maybe someone else writes this introduction instead. - -Bryan and I collaborate when either one of us challenges something, including pieces of the work or process that aren't clear, things that we thought we agreed to, or things on which we have differing opinions. These intersections are ripe for negotiation and therefore indicative of collaboration. They are the opening for us to negotiate some creative work. - -Once the collaboration is negotiated and settled, writing and editing the book returns to cooperation/coordination; that is why collaboration relies on the other two terms of joint work. - -One of the most interesting parts of this example (and of work and shared activity in general) is the moment-by-moment pivot from any of these terms to the other. The writing of this book is not completely collaborative, coordinated, or cooperative. It's a messy mix of all three. - -### Why is collaboration important? - -Collaboration is an important facet of contemporary organizations--specifically those oriented toward knowledge work--because it allows for productive disagreement between actors. That kind of disagreement then helps increase the level of engagement and provide meaning to the group's work. - -In his book, The Age of Discontinuity: Guidelines to our Changing Society, [Peter Drucker discusses][3] the "knowledge worker" and the pivot from work based on experience (e.g. apprenticeships) to work based on knowledge and the application of knowledge. This change in work and workers, he writes: - -> ...will make the management of knowledge workers increasingly crucial to the performance and achievement of the knowledge society. We will have to learn to manage the knowledge worker both for productivity and for satisfaction, both for achievement and for status. We will have to learn to give the knowledge worker a job big enough to challenge him, and to permit performance as a "professional." - -In other words, knowledge workers aren't satisfied with being subordinate--told what to do by managers as, if there is one right way to do a task. And, unlike past workers, they expect more from their work lives, including some level of emotional fulfillment or meaning-making from their work. The knowledge worker, according to Drucker, is educated toward continual learning, "paid for applying his knowledge, exercising his judgment, and taking responsible leadership." So it then follows that knowledge workers expect from work the chance to apply and share their knowledge, develop themselves professionally, and continuously augment their knowledge. - -Interesting to note is the fact that Peter Drucker wrote about those concepts in 1969, nearly 50 years ago--virtually predicting the societal and organizational changes that would reveal themselves, in part, through the development of knowledge sharing tools such as forums, bulletin boards, online communities, and cloud knowledge sharing like DropBox and GoogleDrive as well as the creation of social media tools such as MySpace, Facebook, Twitter, YouTube and countless others. All of these have some basis in the idea that knowledge is something to liberate and share. - -In this light, one might view the open organization as one successful manifestation of a system of management for knowledge workers. In other words, open organizations are a way to manage knowledge workers by meeting the needs of the organization and knowledge workers (whether employees, customers, or the public) simultaneously. The foundational values this book explores are the scaffolding for the management of knowledge, and they apply to ways we can: - - * make sure there's a lot of varied knowledge around (inclusivity) - * help people come together and participate (community) - * circulate information, knowledge, and decision making (transparency) - * innovate and not become entrenched in old ways of thinking and being (adaptability) - * develop a shared goal and work together to use knowledge (collaboration) - - - -Collaboration is an important process because of the participatory effect it has on knowledge work and how it aids negotiations between people and groups. As we've discovered, collaboration is more than working together with some degree of compliance; in fact, it describes a type of working together that overcomes compliance because people can disagree, question, and express their needs in a negotiation and in collaboration. And, collaboration is more than "working toward a shared goal"; collaboration is a process which defines the shared goals via negotiation and, when successful, leads to cooperation and coordination to focus activity on the negotiated outcome. - -Collaboration is an important process because of the participatory effect it has on knowledge work and how it aids negotiations between people and groups. - -Collaboration works best when the other four open organization values are present. For instance, when people are transparent, there is no guessing about what is needed, why, by whom, or when. Also, because collaboration involves negotiation, it also needs diversity (a product of inclusivity); after all, if we aren't negotiating among differing views, needs, or goals, then what are we negotiating? During a negotiation, the parties are often asked to give something up so that all may gain, so we have to be adaptable and flexible to the different outcomes that negotiation can provide. Lastly, collaboration is often an ongoing process rather than one which is quickly done and over, so it's best to enter collaboration as if you are part of the same community, desiring everyone to benefit from the negotiation. In this way, acts of authentic and purposeful collaboration directly necessitate the emergence of the other four values--transparency, inclusivity, adaptability, and community--as they assemble part of the organization's collective purpose spontaneously. - -### Collaboration in open organizations - -Traditional organizations advance an agreed-upon set of goals that people are welcome to support or not. In these organizations, there is some amount of discourse and negotiation, but often a higher-ranking or more powerful member of the organization intervenes to make a decision, which the membership must accept (and sometimes ignores). In open organizations, however, the focus is for members to perform their activity and to work out their differences; only if necessary would someone get involved (and even then would try to do it in the most minimal way that support the shared values of community, transparency, adaptability, collaboration and inclusivity.) This make the collaborative processes in open organizations "messier" (or "chaotic" to use Jim Whitehurst's term) but more participatory and, hopefully, innovative. - -This article is part of the [Open Organization Workbook project][1]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/open-organization/17/11/what-is-collaboration - -作者:[Heidi Hess Von Ludewig][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/heidi-hess-von-ludewig -[1]:https://opensource.com/open-organization/17/8/workbook-project-announcement -[2]:http://opensource.com/users/bbehrens -[3]:https://www.elsevier.com/books/the-age-of-discontinuity/drucker/978-0-434-90395-5 diff --git a/sources/talk/20171221 Changing how we use Slack solved our transparency and silo problems.md b/sources/talk/20171221 Changing how we use Slack solved our transparency and silo problems.md deleted file mode 100644 index d68bab55bf..0000000000 --- a/sources/talk/20171221 Changing how we use Slack solved our transparency and silo problems.md +++ /dev/null @@ -1,95 +0,0 @@ -Changing how we use Slack solved our transparency and silo problems -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/open_abstract_pieces.jpg?itok=tGR1d2MU) - -Collaboration and information silos are a reality in most organizations today. People tend to regard them as huge barriers to innovation and organizational efficiency. They're also a favorite target for solutions from software tool vendors of all types. - -Tools by themselves, however, are seldom (if ever), the answer to a problem like organizational silos. The reason for this is simple: Silos are made of people, and human dynamics are key drivers for the existence of silos in the first place. - -So what is the answer? - -Successful communities are the key to breaking down silos. Tools play an important role in the process, but if you don't build successful communities around those tools, then you'll face an uphill battle with limited chances for success. Tools enable communities; they do not build them. This takes a thoughtful approach--one that looks at culture first, process second, and tools last. - -Successful communities are the key to breaking down silos. - -However, this is a challenge because, in most cases, this is not the way the process works in most businesses. Too many companies begin their journey to fix silos by thinking about tools first and considering metrics that don't evaluate the right factors for success. Too often, people choose tools for purely cost-based, compliance-based, or effort-based reasons--instead of factoring in the needs and desires of the user base. But subjective measures like "customer/user delight" are a real factor for these internal tools, and can make or break the success of both the tool adoption and the goal of increased collaboration. - -It's critical to understand the best technical tool (or what the business may consider the most cost-effective) is not always the solution that drives community, transparency, and collaboration forward. There is a reason that "Shadow IT"--users choosing their own tool solution, building community and critical mass around them--exists and is so effective: People who choose their own tools are more likely to stay engaged and bring others with them, breaking down silos organically. - -This is a story of how Autodesk ended up adopting Slack at enterprise scale to help solve our transparency and silo problems. Interestingly, Slack wasn't (and isn't) an IT-supported application at Autodesk. It's an enterprise solution that was adopted, built, and is still run by a group of passionate volunteers who are committed to a "default to open" paradigm. - -Utilizing Slack makes transparency happen for us. - -### Chat-tastrophe - -First, some perspective: My job at Autodesk is running our [Open@ADSK][1] initiative. I was originally hired to drive our open source strategy, but we quickly expanded my role to include driving open source best practices for internal development (inner source), and transforming how we collaborate internally as an organization. This last piece is where we pick up our story of Slack adoption in the company. - -But before we even begin to talk about our journey with Slack, let's address why lack of transparency and openness was a challenge for us. What is it that makes transparency such a desirable quality in organizations, and what was I facing when I started at Autodesk? - -Every company says they want "better collaboration." In our case, we are a 35-year-old software company that has been immensely successful at selling desktop "shrink-wrapped" software to several industries, including architecture, engineering, construction, manufacturing, and entertainment. But no successful company rests on its laurels, and Autodesk leadership recognized that a move to Cloud-based solutions for our products was key to the future growth of the company, including opening up new markets through product combinations that required Cloud computing and deep product integrations. - -The challenge in making this move was far more than just technical or architectural--it was rooted in the DNA of the company, in everything from how we were organized to how we integrated our products. The basic format of integration in our desktop products was file import/export. While this is undoubtedly important, it led to a culture of highly-specialized teams working in an environment that's more siloed than we'd like and not sharing information (or code). Prior to the move to a cloud-based approach, this wasn't as a much of a problem--but, in an environment that requires organizations to behave more like open source projects do, transparency, openness, and collaboration go from "nice-to-have" to "business critical." - -Like many companies our size, Autodesk has had many different collaboration solutions through the years, some of them commercial, and many of them home-grown. However, none of them effectively solved the many-to-many real-time collaboration challenge. Some reasons for this were technical, but many of them were cultural. - -I relied on a philosophy I'd formed through challenging experiences in my career: "Culture first, tools last." - -When someone first tasked me with trying to find a solution for this, I relied on a philosophy I'd formed through challenging experiences in my career: "Culture first, tools last." This is still a challenge for engineering folks like myself. We want to jump immediately to tools as the solution to any problem. However, it's critical to evaluate a company's ethos (culture), as well as existing processes to determine what kinds of tools might be a good fit. Unfortunately, I've seen too many cases where leaders have dictated a tool choice from above, based on the factors discussed earlier. I needed a different approach that relied more on fitting a tool into the culture we wanted to become, not the other way around. - -What I found at Autodesk were several small camps of people using tools like HipChat, IRC, Microsoft Lync, and others, to try to meet their needs. However, the most interesting thing I found was 85 separate instances of Slack in the company! - -Eureka! I'd stumbled onto a viral success (one enabled by Slack's ability to easily spin up "free" instances). I'd also landed squarely in what I like to call "silo-land." - -All of those instances were not talking to each other--so, effectively, we'd created isolated islands of information that, while useful to those in them, couldn't transform the way we operated as an enterprise. Essentially, our existing organizational culture was recreated in digital format in these separate Slack systems. Our organization housed a mix of these small, free instances, as well as multiple paid instances, which also meant we were not taking advantage of a common billing arrangement. - -My first (open source) thought was: "Hey, why aren't we using IRC, or some other open source tool, for this?" I quickly realized that didn't matter, as our open source engineers weren't the only people using Slack. People from all areas of the company--even senior leadership--were adopting Slack in droves, and, in some cases, convincing their management to pay for it! - -My second (engineering) thought was: "Oh, this is simple. We just collapse all 85 of those instances into a single cohesive Slack instance." What soon became obvious was that was the easy part of the solution. Much harder was the work of cajoling, convincing, and moving people to a single, transparent instance. Building in the "guard rails" to enable a closed source tool to provide this transparency was key. These guard rails came in the form of processes, guidelines, and community norms that were the hardest part of this transformation. - -### The real work begins - -As I began to slowly help users migrate to the common instance (paying for it was also a challenge, but a topic for another day), I discovered a dedicated group of power users who were helping each other in the #adsk-slack-help channel on our new common instance of Slack. These power users were, in effect, building the roots of our transparency and community through their efforts. - -The open source community manager in me quickly realized these users were the path to successfully scaling Slack at Autodesk. I enlisted five of them to help me, and, together we set about fabricating the community structure for the tool's rollout. - -We did, however, learn an important lesson about transparency and company culture along the way. - -Here I should note the distinction between a community structure/governance model and traditional IT policies: With the exception of security and data privacy/legal policies, volunteer admins and user community members completely define and govern our Slack instance. One of the keys to our success with Slack (currently approximately 9,100 users and roughly 4,300 public channels) was how we engaged and involved our users in building these governance structures. Things like channel naming conventions and our growing list of frequently asked questions were organic and have continued in that same vein. Our community members feel like their voices are heard (even if some disagree), and that they have been a part of the success of our deployment of Slack. - -We did, however, learn an important lesson about transparency and company culture along the way. - -### It's not the tool - -When we first launched our main Slack instance, we left the ability for anyone to make a channel private turned on. After about three months of usage, we saw a clear trend: More people were creating private channels (and messages) than they were public channels (the ratio was about two to one, private versus public). Since our effort to merge 85 Slack instances was intended to increase participation and transparency, we quickly adjusted our policy and turned off this feature for regular users. We instead implemented a policy of review by the admin team, with clear criteria (finance, legal, personnel discussions among the reasons) defined for private channels. - -This was probably the only time in this entire process that I regretted something. - -We took an amazing amount of flak for this decision because we were dealing with a corporate culture that was used to working in independent units that had minimal interaction with each other. Our defining moment of clarity (and the tipping point where things started to get better) occurred in an all-hands meeting when one of our senior executives asked me to address a question about Slack. I stood up to answer the question, and said (paraphrased from memory): "It's not about the tool. I could give you all the best, gold-plated collaboration platform in existence, but we aren't going to be successful if we don't change our approach to collaboration and learn to default to open." - -I didn't think anything more about that statement--until that senior executive starting using the phrase "default to open" in his slide decks, in his staff meetings, and with everyone he met. That one moment has defined what we have been trying to do with Slack: The tool isn't the sole reason we've been successful; it's the approach that we've taken around building a self-sustaining community that not only wants to use this tool, but craves the ability it gives them to work easily across the enterprise. - -### What we learned - -The tool isn't the sole reason we've been successful; it's the approach that we've taken around building a self-sustaining community that not only wants to use this tool, but craves the ability it gives them to work easily across the enterprise. - -I say all the time that this could have happened with other, similar tools (Hipchat, IRC, etc), but it works in this case specifically because we chose an approach of supporting a solution that the user community adopted for their needs, not strictly what the company may have chosen if the decision was coming from the top of the organizational chart. We put a lot of work into making it an acceptable solution (from the perspectives of security, legal, finance, etc.) for the company, but, ultimately, our success has come from the fact that we built this rollout (and continue to run the tool) as a community, not as a traditional corporate IT system. - -The most important lesson I learned through all of this is that transparency and community are evolutionary, not revolutionary. You have to understand where your culture is, where you want it to go, and utilize the lever points that the community is adopting itself to make sustained and significant progress. There is a fine balance point between an anarchy, and a thriving community, and we've tried to model our approach on the successful practices of today's thriving open source communities. - -Communities are personal. Tools come and go, but keeping your community at the forefront of your push to transparency is the key to success. - -This article is part of the [Open Organization Workbook project][2]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/open-organization/17/12/chat-platform-default-to-open - -作者:[Guy Martin][a] -译者:[译者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/guyma -[1]:mailto:Open@ADSK -[2]:https://opensource.com/open-organization/17/8/workbook-project-announcement diff --git a/sources/talk/20180109 How Mycroft used WordPress and GitHub to improve its documentation.md b/sources/talk/20180109 How Mycroft used WordPress and GitHub to improve its documentation.md deleted file mode 100644 index 9e35e0ede7..0000000000 --- a/sources/talk/20180109 How Mycroft used WordPress and GitHub to improve its documentation.md +++ /dev/null @@ -1,116 +0,0 @@ -How Mycroft used WordPress and GitHub to improve its documentation -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/doc-dish-lead-2.png?itok=lPO6tqPd) - -Image credits : Photo by Unsplash; modified by Rikki Endsley. CC BY-SA 4.0 - -Imagine you've just joined a new technology company, and one of the first tasks you're assigned is to improve and centralize the organization's developer-facing documentation. There's just one catch: That documentation exists in many different places, across several platforms, and differs markedly in accuracy, currency, and style. - -So how did we tackle this challenge? - -### Understanding the scope - -As with any project, we first needed to understand the scope and bounds of the problem we were trying to solve. What documentation was good? What was working? What wasn't? How much documentation was there? What format was it in? We needed to do a **documentation audit**. Luckily, [Aneta Šteflova][1] had recently [published an article on OpenSource.com][2] about this, and it provided excellent guidance. - -![mycroft doc audit][4] - -Mycroft documentation audit, showing source, topic, medium, currency, quality and audience - -Next, every piece of publicly facing documentation was assessed for the topic it covered, the medium it used, currency, and quality. A pattern quickly emerged that different platforms had major deficiencies, allowing us to make a data-driven approach to decommission our existing Jekyll-based sites. The audit also highlighted just how fragmented our documentation sources were--we had developer-facing documentation across no fewer than seven sites. Although search engines were finding this content just fine, the fragmentation made it difficult for developers and users of Mycroft--our primary audiences--to navigate the information they needed. Again, this data helped us make the decision to centralize our documentation on to one platform. - -### Choosing a central platform - -As an organization, we wanted to constrain the number of standalone platforms in use. Over time, maintenance and upkeep of multiple platforms and integration touchpoints becomes cumbersome for any organization, but this is exacerbated for a small startup. - -One of the other business drivers in platform choice was that we had two primary but very different audiences. On one hand, we had highly technical developers who we were expecting would push documentation to its limits--and who would want to contribute to technical documentation using their tools of choice--[Git][5], [GitHub][6], and [Markdown][7]. Our second audience--end users--would primarily consume technical documentation and would want to do so in an inviting, welcoming platform that was visually appealing and provided additional features such as the ability to identify reading time and to provide feedback. The ability to capture feedback was also a key requirement from our side as without feedback on the quality of the documentation, we would not have a solid basis to undertake continuous quality improvement. - -Would we be able to identify one platform that met all of these competing needs? - -We realised that two platforms covered all of our needs: - - * [WordPress][8]: Our existing website is built on WordPress, and we have some reasonably robust WordPress skills in-house. The flexibility of WordPress also fulfilled our requirements for functionality like reading time and the ability to capture user feedback. - * [GitHub][9]: Almost [all of Mycroft.AI's source code is available on GitHub][10], and our development team uses this platform daily. - - - -But how could we marry the two? - - -![](https://opensource.com/sites/default/files/images/life-uploads/wordpress-github-sync.png) - -### Integrating WordPress and GitHub with WordPress GitHub Sync - -Luckily, our COO, [Nate Tomasi][11], spotted a WordPress plugin that promised to integrate the two. - -This was put through its paces on our test website, and it passed with flying colors. It was easy to install, had a straightforward configuration, which just required an OAuth token and webhook with GitHub, and provided two-way integration between WordPress and GitHub. - -It did, however, have a dependency--on Markdown--which proved a little harder to implement. We trialed several Markdown plugins, but each had several quirks that interfered with the rendering of non-Markdown-based content. After several days of frustration, and even an attempt to custom-write a plugin for our needs, we stumbled across [Parsedown Party][12]. There was much partying! With WordPress GitHub Sync and Parsedown Party, we had integrated our two key platforms. - -Now it was time to make our content visually appealing and usable for our user audience. - -### Reading time and feedback - -To implement the reading time and feedback functionality, we built a new [page template for WordPress][13], and leveraged plugins within the page template. - -Knowing the estimated reading time of an article in advance has been [proven to increase engagement with content][14] and provides developers and users with the ability to decide whether to read the content now or bookmark it for later. We tested several WordPress plugins for reading time, but settled on [Reading Time WP][15] because it was highly configurable and could be easily embedded into WordPress page templates. Our decision to place Reading Time at the top of the content was designed to give the user the choice of whether to read now or save for later. With Reading Time in place, we then turned our attention to gathering user feedback and ratings for our documentation. - -![](https://opensource.com/sites/default/files/images/life-uploads/screenshot-from-2017-12-08-00-55-31.png) - -There are several rating and feedback plugins available for WordPress. We needed one that could be easily customized for several use cases, and that could aggregate or summarize ratings. After some experimentation, we settled on [Multi Rating Pro][16] because of its wide feature set, especially the ability to create a Review Ratings page in WordPress--i.e., a central page where staff can review ratings without having to be logged in to the WordPress backend. The only gap we ran into here was the ability to set the display order of rating options--but it will likely be added in a future release. - -The WordPress GitHub Integration plugin also gave us the ability to link back to the GitHub repository where the original Markdown content was held, inviting technical developers to contribute to improving our documentation. - -### Updating the existing documentation - -Now that the "container" for our new documentation had been developed, it was time to update the existing content. Because much of our documentation had grown organically over time, there were no style guidelines to shape how keywords and code were styled. This was tackled first, so that it could be applied to all content. [You can see our content style guidelines on GitHub.][17] - -As part of the update, we also ran several checks to ensure that the content was technically accurate, augmenting the existing documentation with several images for better readability. - -There were also a couple of additional tools that made creating internal links for documentation pieces easier. First, we installed the [WP Anchor Header][18] plugin. This plugin provided a small but important function: adding `id` content in GitHub using the `[markdown-toc][19]` library, then simply copied in to the WordPress content, where they would automatically link to the `id` attributes to each `

`, `

` (and so on) element. This meant that internal anchors could be automatically generated on the command line from the Markdown content in GitHub using the `[markdown-toc][19]` library, then simply copied in to the WordPress content, where they would automatically link to the `id` attributes generated by WP Anchor Header. - -Next, we imported the updated documentation into WordPress from GitHub, and made sure we had meaningful and easy-to-search on slugs, descriptions, and keywords--because what good is excellent documentation if no one can find it?! A final activity was implementing redirects so that people hitting the old documentation would be taken to the new version. - -### What next? - -[Please do take a moment and have a read through our new documentation][20]. We know it isn't perfect--far from it--but we're confident that the mechanisms we've baked into our new documentation infrastructure will make it easier to identify gaps--and resolve them quickly. If you'd like to know more, or have suggestions for our documentation, please reach out to Kathy Reid on [Chat][21] (@kathy-mycroft) or via [email][22]. - -_Reprinted with permission from[Mycroft.ai][23]._ - -### About the author -Kathy Reid - Director of Developer Relations @MycroftAI, President of @linuxaustralia. Kathy Reid has expertise in open source technology management, web development, video conferencing, digital signage, technical communities and documentation. She has worked in a number of technical and leadership roles over the last 20 years, and holds Arts and Science undergraduate degrees... more about Kathy Reid - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/1/rocking-docs-mycroft - -作者:[Kathy Reid][a] -译者:[译者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/kathyreid -[1]:https://opensource.com/users/aneta -[2]:https://opensource.com/article/17/10/doc-audits -[3]:/file/382466 -[4]:https://opensource.com/sites/default/files/images/life-uploads/mycroft-documentation-audit.png (mycroft documentation audit) -[5]:https://git-scm.com/ -[6]:https://github.com/MycroftAI -[7]:https://en.wikipedia.org/wiki/Markdown -[8]:https://www.wordpress.org/ -[9]:https://github.com/ -[10]:https://github.com/mycroftai -[11]:http://mycroft.ai/team/ -[12]:https://wordpress.org/plugins/parsedown-party/ -[13]:https://developer.wordpress.org/themes/template-files-section/page-template-files/ -[14]:https://marketingland.com/estimated-reading-times-increase-engagement-79830 -[15]:https://jasonyingling.me/reading-time-wp/ -[16]:https://multiratingpro.com/ -[17]:https://github.com/MycroftAI/docs-rewrite/blob/master/README.md -[18]:https://wordpress.org/plugins/wp-anchor-header/ -[19]:https://github.com/jonschlinkert/markdown-toc -[20]:https://mycroft.ai/documentation -[21]:https://chat.mycroft.ai/ -[22]:mailto:kathy.reid@mycroft.ai -[23]:https://mycroft.ai/blog/improving-mycrofts-documentation/ diff --git a/sources/talk/20180111 The open organization and inner sourcing movements can share knowledge.md b/sources/talk/20180111 The open organization and inner sourcing movements can share knowledge.md deleted file mode 100644 index 272c1b03ae..0000000000 --- a/sources/talk/20180111 The open organization and inner sourcing movements can share knowledge.md +++ /dev/null @@ -1,121 +0,0 @@ -The open organization and inner sourcing movements can share knowledge -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/gov_collaborative_risk.png?itok=we8DKHuL) -Image by : opensource.com - -Red Hat is a company with roughly 11,000 employees. The IT department consists of roughly 500 members. Though it makes up just a fraction of the entire organization, the IT department is still sufficiently staffed to have many application service, infrastructure, and operational teams within it. Our purpose is "to enable Red Hatters in all functions to be effective, productive, innovative, and collaborative, so that they feel they can make a difference,"--and, more specifically, to do that by providing technologies and related services in a fashion that is as open as possible. - -Being open like this takes time, attention, and effort. While we always strive to be as open as possible, it can be difficult. For a variety of reasons, we don't always succeed. - -In this story, I'll explain a time when, in the rush to innovate, the Red Hat IT organization lost sight of its open ideals. But I'll also explore how returning to those ideals--and using the collaborative tactics of "inner source"--helped us to recover and greatly improve the way we deliver services. - -### About inner source - -Before I explain how inner source helped our team, let me offer some background on the concept. - -Inner source is the adoption of open source development practices between teams within an organization to promote better and faster delivery without requiring project resources be exposed to the world or openly licensed. It allows an organization to receive many of the benefits of open source development methods within its own walls. - -In this way, inner source aligns well with open organization strategies and principles; it provides a path for open, collaborative development. While the open organization defines its principles of openness broadly as transparency, inclusivity, adaptability, collaboration, and community--and covers how to use these open principles for communication, decision making, and many other topics--inner source is about the adoption of specific and tactical practices, processes, and patterns from open source communities to improve delivery. - -For instance, [the Open Organization Maturity Model][1] suggests that in order to be transparent, teams should, at minimum, share all project resources with the project team (though it suggests that it's generally better to share these resources with the entire organization). The common pattern in both inner source and open source development is to host all resources in a publicly available version control system, for source control management, which achieves the open organization goal of high transparency. - -Inner source aligns well with open organization strategies and principles. - -Another example of value alignment appears in the way open source communities accept contributions. In open source communities, source code is transparently available. Community contributions in the form of patches or merge requests are commonly accepted practices (even expected ones). This provides one example of how to meet the open organization's goal of promoting inclusivity and collaboration. - -### The challenge - -Early in 2014, Red Hat IT began its first steps toward making Amazon Web Services (AWS) a standard hosting offering for business critical systems. While teams within Red Hat IT had built several systems and services in AWS by this time, these were bespoke creations, and we desired to make deploying services to IT standards in AWS both simple and standardized. - -In order to make AWS cloud hosting meet our operational standards (while being scalable), the Cloud Enablement team within Red Hat IT decided that all infrastructure in AWS would be configured through code, rather than manually, and that everyone would use a standard set of tools. The Cloud Enablement team designed and built these standard tools; a separate group, the Platform Operations team, was responsible for provisioning and hosting systems and services in AWS using the tools. - -The Cloud Enablement team built a toolset, obtusely named "Template Util," based on AWS Cloud Formations configurations wrapped in a management layer to enforce certain configuration requirements and make stamping out multiple copies of services across environments easier. While the Template Util toolset technically met all our initial requirements, and we eventually provisioned the infrastructure for more than a dozen services with it, engineers in every team working with the tool found using it to be painful. Michael Johnson, one engineer using the tool, said "It made doing something relatively straightforward really complicated." - -Among the issues Template Util exhibited were: - - * Underlying cloud formations technologies implied constraints on application stack management at odds with how we managed our application systems. - * The tooling was needlessly complex and brittle in places, using multiple layered templating technologies and languages making syntax issues hard to debug. - * The code for the tool--and some of the data users needed to manipulate the tool--were kept in a repository that was difficult for most users to access. - * There was no standard process to contributing or accepting changes. - * The documentation was poor. - - - -As more engineers attempted to use the Template Util toolset, they found even more issues and limitations with the tools. Unhappiness continued to grow. To make matters worse, the Cloud Enablement team then shifted priorities to other deliverables without relinquishing ownership of the tool, so bug fixes and improvements to the tools were further delayed. - -The real, core issues here were our inability to build an inclusive community to collaboratively build shared tooling that met everyone's needs. Fear of losing "ownership," fear of changing requirements, and fear of seeing hard work abandoned all contributed to chronic conflict, which in turn led to poorer outcomes. - -### Crisis point - -By September 2015, more than a year after launching our first major service in AWS with the Template Util tool, we hit a crisis point. - -Many engineers refused to use the tools. That forced all of the related service provisioning work on a small set of engineers, further fracturing the community and disrupting service delivery roadmaps as these engineers struggled to deal with unexpected work. We called an emergency meeting and invited all the teams involved to find a solution. - -During the emergency meeting, we found that people generally thought we needed immediate change and should start the tooling effort over, but even the decision to start over wasn't unanimous. Many solutions emerged--sometimes multiple solutions from within a single team--all of which would require significant work to implement. While we couldn't reach a consensus on which solution to use during this meeting, we did reach an agreement to give proponents of different technologies two weeks to work together, across teams, to build their case with a prototype, which the community could then review. - -While we didn't reach a final and definitive decision, this agreement was the first point where we started to return to the open source ideals that guide our mission. By inviting all involved parties, we were able to be transparent and inclusive, and we could begin rebuilding our internal community. By making clear that we wanted to improve things and were open to new options, we showed our commitment to adaptability and meritocracy. Most importantly, the plan for building prototypes gave people a clear, return path to collaboration. - -When the community reviewed the prototypes, it determined that the clear leader was an Ansible-based toolset that would eventually become known, internally, as Ansicloud. (At the time, no one involved with this work had any idea that Red Hat would acquire Ansible the following month. It should also be noted that other teams within Red Hat have found tools based on Cloud Formation extremely useful, even when our specific Template Util tool did not find success.) - -This prototyping and testing phase didn't fix things overnight, though. While we had consensus on the general direction we needed to head, we still needed to improve the new prototype to the point at which engineers could use it reliably for production services. - -So over the next several months, a handful of engineers worked to further build and extend the Ansicloud toolset. We built three new production services. While we were sharing code, that sharing activity occurred at a low level of maturity. Some engineers had trouble getting access due to older processes. Other engineers headed in slightly different directions, with each engineer having to rediscover some of the core design issues themselves. - -### Returning to openness - -This led to a turning point: Building on top of the previous agreement, we focused on developing a unified vision and providing easier access. To do this, we: - - 1. created a list of specific goals for the project (both "must-haves" and "nice-to-haves"), - 2. created an open issue log for the project to avoid solving the same problem repeatedly, - 3. opened our code base so anyone in Red Hat could read or clone it, and - 4. made it easy for engineers to get trusted committer access - - - -Our agreement to collaborate, our finally unified vision, and our improved tool development methods spurred the growth of our community. Ansicloud adoption spread throughout the involved organizations, but this led to a new problem: The tool started changing more quickly than users could adapt to it, and improvements that different groups submitted were beginning to affect other groups in unanticipated ways. - -These issues resulted in our recent turn to inner source practices. While every open source project operates differently, we focused on adopting some best practices that seemed common to many of them. In particular: - - * We identified the business owner of the project and the core-contributor group of developers who would govern the development of the tools and decide what contributions to accept. While we want to keep things open, we can't have people working against each other or breaking each other's functionality. - * We developed a project README clarifying the purpose of the tool and specifying how to use it. We also created a CONTRIBUTING document explaining how to contribute, what sort of contributions would be useful, and what sort of tests a contribution would need to pass to be accepted. - * We began building continuous integration and testing services for the Ansicloud tool itself. This helped us ensure we could quickly and efficiently validate contributions technically, before the project accepted and merged them. - - - -With these basic agreements, documents, and tools available, we were back onto the path of open collaboration and successful inner sourcing. - -### Why it matters - -Why does inner source matter? - -From a developer community point of view, shifting from a traditional siloed development model to the inner source model has produced significant, quantifiable improvements: - - * Contributions to our tooling have grown 72% per week (by number of commits). - * The percentage of contributions from non-core committers has grown from 27% to 78%; the users of the toolset are driving its development. - * The contributor list has grown by 15%, primarily from new users of the tool set, rather than core committers, increasing our internal community. - - - -And the tools we've delivered through this project have allowed us to see dramatic improvements in our business outcomes. Using the Ansicloud tools, 54 new multi-environment application service deployments were created in 385 days (compared to 20 services in 1,013 days with the Template Util tools). We've gone from one new service deployment in a 50-day period to one every week--a seven-fold increase in the velocity of our delivery. - -What really matters here is that the improvements we saw were not aberrations. Inner source provides common, easily understood patterns that organizations can adopt to effectively promote collaboration (not to mention other open organization principles). By mirroring open source production practices, inner source can also mirror the benefits of open source code, which have been seen time and time again: higher quality code, faster development, and more engaged communities. - -This article is part of the [Open Organization Workbook project][2]. - -### about the author -Tom Benninger - Tom Benninger is a Solutions Architect, Systems Engineer, and continual tinkerer at Red Hat, Inc. Having worked with startups, small businesses, and larger enterprises, he has experience within a broad set of IT disciplines. His current area of focus is improving Application Lifecycle Management in the enterprise. He has a particular interest in how open source, inner source, and collaboration can help support modern application development practices and the adoption of DevOps, CI/CD, Agile,... - --------------------------------------------------------------------------------- - -via: https://opensource.com/open-organization/18/1/open-orgs-and-inner-source-it - -作者:[Tom Benninger][a] -译者:[译者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/tomben -[1]:https://opensource.com/open-organization/resources/open-org-maturity-model -[2]:https://opensource.com/open-organization/17/8/workbook-project-announcement diff --git a/sources/talk/20180112 in which the cost of structured data is reduced.md b/sources/talk/20180112 in which the cost of structured data is reduced.md deleted file mode 100644 index 992ad57a39..0000000000 --- a/sources/talk/20180112 in which the cost of structured data is reduced.md +++ /dev/null @@ -1,181 +0,0 @@ -in which the cost of structured data is reduced -====== -Last year I got the wonderful opportunity to attend [RacketCon][1] as it was hosted only 30 minutes away from my home. The two-day conference had a number of great talks on the first day, but what really impressed me was the fact that the entire second day was spent focusing on contribution. The day started out with a few 15- to 20-minute talks about how to contribute to a specific codebase (including that of Racket itself), and after that people just split off into groups focused around specific codebases. Each table had maintainers helping guide other folks towards how to work with the codebase and construct effective patch submissions. - -![lensmen chronicles][2] - -I came away from the conference with a great sense of appreciation for how friendly and welcoming the Racket community is, and how great Racket is as a swiss-army-knife type tool for quick tasks. (Not that it's unsuitable for large projects, but I don't have the opportunity to start any new large projects very frequently.) - -The other day I wanted to generate colored maps of the world by categorizing countries interactively, and Racket seemed like it would fit the bill nicely. The job is simple: show an image of the world with one country selected; when a key is pressed, categorize that country, then show the map again with all categorized countries colored, and continue with the next country selected. - -### GUIs and XML - -I have yet to see a language/framework more accessible and straightforward out of the box for drawing1. Here's the entry point which sets up state and then constructs a canvas that handles key input and display: -``` -(define (main path) - (let ([frame (new frame% [label "World color"])] - [categorizations (box '())] - [doc (call-with-input-file path read-xml/document)]) - (new (class canvas% - (define/override (on-char event) - (handle-key this categorizations (send event get-key-code))) - (super-new)) - [parent frame] - [paint-callback (draw doc categorizations)]) - (send frame show #t))) - -``` - -While the class system is not one of my favorite things about Racket (most newer code seems to avoid it in favor of [generic interfaces][3] in the rare case that polymorphism is truly called for), the fact that classes can be constructed in a light-weight, anonymous way makes it much less onerous than it could be. This code sets up all mutable state in a [`box`][4] which you use in the way you'd use a `ref` in ML or Clojure: a mutable wrapper around an immutable data structure. - -The world map I'm using is [an SVG of the Robinson projection][5] from Wikipedia. If you look closely there's a call to bind `doc` that calls [`call-with-input-file`][6] with [`read-xml/document`][7] which loads up the whole map file's SVG; just about as easily as you could ask for. - -The data you get back from `read-xml/document` is in fact a [document][8] struct, which contains an `element` struct containing `attribute` structs and lists of more `element` structs. All very sensible, but maybe not what you would expect in other dynamic languages like Clojure or Lua where free-form maps reign supreme. Racket really wants structure to be known up-front when possible, which is one of the things that help it produce helpful error messages when things go wrong. - -Here's how we handle keyboard input; we're displaying a map with one country highlighted, and `key` here tells us what the user pressed to categorize the highlighted country. If that key is in the `categories` hash then we put it into `categorizations`. -``` -(define categories #hash((select . "eeeeff") - (#\1 . "993322") - (#\2 . "229911") - (#\3 . "ABCD31") - (#\4 . "91FF55") - (#\5 . "2439DF"))) - -(define (handle-key canvas categorizations key) - (cond [(equal? #\backspace key) (swap! categorizations cdr)] - [(member key (dict-keys categories)) (swap! categorizations (curry cons key))] - [(equal? #\space key) (display (unbox categorizations))]) - (send canvas refresh)) - -``` - -### Nested updates: the bad parts - -Finally once we have a list of categorizations, we need to apply it to the map document and display. We apply a [`fold`][9] reduction over the XML document struct and the list of country categorizations (plus `'select` for the country that's selected to be categorized next) to get back a "modified" document struct where the proper elements have the style attributes applied for the given categorization, then we turn it into an image and hand it to [`draw-pict`][10]: -``` - -(define (update original-doc categorizations) - (for/fold ([doc original-doc]) - ([category (cons 'select (unbox categorizations))] - [n (in-range (length (unbox categorizations)) 0 -1)]) - (set-style doc n (style-for category)))) - -(define ((draw doc categorizations) _ context) - (let* ([newdoc (update doc categorizations)] - [xml (call-with-output-string (curry write-xml newdoc))]) - (draw-pict (call-with-input-string xml svg-port->pict) context 0 0))) - -``` - -The problem is in that pesky `set-style` function. All it has to do is reach deep down into the `document` struct to find the `n`th `path` element (the one associated with a given country), and change its `'style` attribute. It ought to be a simple task. Unfortunately this function ends up being anything but simple: -``` - -(define (set-style doc n new-style) - (let* ([root (document-element doc)] - [g (list-ref (element-content root) 8)] - [paths (element-content g)] - [path (first (drop (filter element? paths) n))] - [path-num (list-index (curry eq? path) paths)] - [style-index (list-index (lambda (x) (eq? 'style (attribute-name x))) - (element-attributes path))] - [attr (list-ref (element-attributes path) style-index)] - [new-attr (make-attribute (source-start attr) - (source-stop attr) - (attribute-name attr) - new-style)] - [new-path (make-element (source-start path) - (source-stop path) - (element-name path) - (list-set (element-attributes path) - style-index new-attr) - (element-content path))] - [new-g (make-element (source-start g) - (source-stop g) - (element-name g) - (element-attributes g) - (list-set paths path-num new-path))] - [root-contents (list-set (element-content root) 8 new-g)]) - (make-document (document-prolog doc) - (make-element (source-start root) - (source-stop root) - (element-name root) - (element-attributes root) - root-contents) - (document-misc doc)))) - -``` - -The reason for this is that while structs are immutable, they don't support functional updates. Whenever you're working with immutable data structures, you want to be able to say "give me a new version of this data, but with field `x` replaced by the value of `(f (lookup x))`". Racket can [do this with dictionaries][11] but not with structs2. If you want a modified version you have to create a fresh one3. - -### Lenses to the rescue? - -![first lensman][12] - -When I brought this up in the `#racket` channel on Freenode, I was helpfully pointed to the 3rd-party [Lens][13] library. Lenses are a general-purpose way of composing arbitrarily nested lookups and updates. Unfortunately at this time there's [a flaw][14] preventing them from working with `xml` structs, so it seemed I was out of luck. - -But then I was pointed to [X-expressions][15] as an alternative to structs. The [`xml->xexpr`][16] function turns the structs into a deeply-nested list tree with symbols and strings in it. The tag is the first item in the list, followed by an associative list of attributes, then the element's children. While this gives you fewer up-front guarantees about the structure of the data, it does work around the lens issue. - -For this to work, we need to compose a new lens based on the "path" we want to use to drill down into the `n`th country and its `style` attribute. The [`lens-compose`][17] function lets us do that. Note that the order here might be backwards from what you'd expect; it works deepest-first (the way [`compose`][18] works for functions). Also note that defining one lens gives us the ability to both get nested values (with [`lens-view`][19]) and update them. -``` -(define (style-lens n) - (lens-compose (dict-ref-lens 'style) - second-lens - (list-ref-lens (add1 (* n 2))) - (list-ref-lens 10))) -``` - -Our `` XML elements are under the 10th item of the root xexpr, (hence the [`list-ref-lens`][20] with 10) and they are interspersed with whitespace, so we have to double `n` to find the `` we want. The [`second-lens`][21] call gets us to that element's attribute alist, and [`dict-ref-lens`][22] lets us zoom in on the `'style` key out of that alist. - -Once we have our lens, it's just a matter of replacing `set-style` with a call to [`lens-set`][23] in our `update` function we had above, and then we're off: -``` -(define (update doc categorizations) - (for/fold ([d doc]) - ([category (cons 'select (unbox categorizations))] - [n (in-range (length (unbox categorizations)) 0 -1)]) - (lens-set (style-lens n) d (list (style-for category))))) -``` - -![second stage lensman][24] - -Often times the trade-off between freeform maps/hashes vs structured data feels like one of convenience vs long-term maintainability. While it's unfortunate that they can't be used with the `xml` structs4, lenses provide a way to get the best of both worlds, at least in some situations. - -The final version of the code clocks in at 51 lines and is is available [on GitLab][25]. - -๛ - --------------------------------------------------------------------------------- - -via: https://technomancy.us/185 - -作者:[Phil Hagelberg][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://technomancy.us/ -[1]:https://con.racket-lang.org/ -[2]:https://technomancy.us/i/chronicles-of-lensmen.jpg -[3]:https://docs.racket-lang.org/reference/struct-generics.html -[4]:https://docs.racket-lang.org/reference/boxes.html?q=box#%28def._%28%28quote._~23~25kernel%29._box%29%29 -[5]:https://commons.wikimedia.org/wiki/File:BlankMap-World_gray.svg -[6]:https://docs.racket-lang.org/reference/port-lib.html#(def._((lib._racket%2Fport..rkt)._call-with-input-string)) -[7]:https://docs.racket-lang.org/xml/index.html?q=read-xml#%28def._%28%28lib._xml%2Fmain..rkt%29._read-xml%2Fdocument%29%29 -[8]:https://docs.racket-lang.org/xml/#%28def._%28%28lib._xml%2Fmain..rkt%29._document%29%29 -[9]:https://docs.racket-lang.org/reference/for.html?q=for%2Ffold#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for%2Ffold%29%29 -[10]:https://docs.racket-lang.org/pict/Rendering.html?q=draw-pict#%28def._%28%28lib._pict%2Fmain..rkt%29._draw-pict%29%29 -[11]:https://docs.racket-lang.org/reference/dicts.html?q=dict-update#%28def._%28%28lib._racket%2Fdict..rkt%29._dict-update%29%29 -[12]:https://technomancy.us/i/first-lensman.jpg -[13]:https://docs.racket-lang.org/lens/lens-guide.html -[14]:https://github.com/jackfirth/lens/issues/290 -[15]:https://docs.racket-lang.org/pollen/second-tutorial.html?q=xexpr#%28part._.X-expressions%29 -[16]:https://docs.racket-lang.org/xml/index.html?q=xexpr#%28def._%28%28lib._xml%2Fmain..rkt%29._xml-~3exexpr%29%29 -[17]:https://docs.racket-lang.org/lens/lens-reference.html#%28def._%28%28lib._lens%2Fcommon..rkt%29._lens-compose%29%29 -[18]:https://docs.racket-lang.org/reference/procedures.html#%28def._%28%28lib._racket%2Fprivate%2Flist..rkt%29._compose%29%29 -[19]:https://docs.racket-lang.org/lens/lens-reference.html?q=lens-view#%28def._%28%28lib._lens%2Fcommon..rkt%29._lens-view%29%29 -[20]:https://docs.racket-lang.org/lens/lens-reference.html?q=lens-view#%28def._%28%28lib._lens%2Fdata%2Flist..rkt%29._list-ref-lens%29%29 -[21]:https://docs.racket-lang.org/lens/lens-reference.html?q=lens-view#%28def._%28%28lib._lens%2Fdata%2Flist..rkt%29._second-lens%29%29 -[22]:https://docs.racket-lang.org/lens/lens-reference.html?q=lens-view#%28def._%28%28lib._lens%2Fdata%2Fdict..rkt%29._dict-ref-lens%29%29 -[23]:https://docs.racket-lang.org/lens/lens-reference.html?q=lens-view#%28def._%28%28lib._lens%2Fcommon..rkt%29._lens-set%29%29 -[24]:https://technomancy.us/i/second-stage-lensman.jpg -[25]:https://gitlab.com/technomancy/world-color/blob/master/world-color.rkt diff --git a/sources/talk/20180124 Security Chaos Engineering- A new paradigm for cybersecurity.md b/sources/talk/20180124 Security Chaos Engineering- A new paradigm for cybersecurity.md deleted file mode 100644 index 35c89150c8..0000000000 --- a/sources/talk/20180124 Security Chaos Engineering- A new paradigm for cybersecurity.md +++ /dev/null @@ -1,87 +0,0 @@ -Security Chaos Engineering: A new paradigm for cybersecurity -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/life_bank_vault_secure_safe.png?itok=YoW93h7C) - -Security is always changing and failure always exists. - -This toxic scenario requires a fresh perspective on how we think about operational security. We must understand that we are often the primary cause of our own security flaws. The industry typically looks at cybersecurity and failure in isolation or as separate matters. We believe that our lack of insight and operational intelligence into our own security control failures is one of the most common causes of security incidents and, subsequently, data breaches. - -> Fall seven times, stand up eight." --Japanese proverb - -The simple fact is that "to err is human," and humans derive their success as a direct result of the failures they encounter. Their rate of failure, how they fail, and their ability to understand that they failed in the first place are important building blocks to success. Our ability to learn through failure is inherent in the systems we build, the way we operate them, and the security we use to protect them. Yet there has been a lack of focus when it comes to how we approach preventative security measures, and the spotlight has trended toward the evolving attack landscape and the need to buy or build new solutions. - -### Security spending is continually rising and so are security incidents - -We spend billions on new information security technologies, however, we rarely take a proactive look at whether those security investments perform as expected. This has resulted in a continual increase in security spending on new solutions to keep up with the evolving attacks. - -Despite spending more on security, data breaches are continuously getting bigger and more frequent across all industries. We have marched so fast down this path of the "get-ahead-of-the-attacker" strategy that we haven't considered that we may be a primary cause of our own demise. How is it that we are building more and more security measures, but the problem seems to be getting worse? Furthermore, many of the notable data breaches over the past year were not the result of an advanced nation-state or spy-vs.-spy malicious advanced persistent threats (APTs); rather the principal causes of those events were incomplete implementation, misconfiguration, design flaws, and lack of oversight. - -The 2017 Ponemon Cost of a Data Breach Study breaks down the [root causes of data breaches][1] into three areas: malicious or criminal attacks, human factors or errors, and system glitches, including both IT and business-process failure. Of the three categories, malicious or criminal attacks comprises the largest distribution (47%), followed by human error (28%), and system glitches (25%). Cybersecurity vendors have historically focused on malicious root causes of data breaches, as it is the largest sole cause, but together human error and system glitches total 53%, a larger share of the overall problem. - -What is not often understood, whether due to lack of insight, reporting, or analysis, is that malicious or criminal attacks are often successful due to human error and system glitches. Both human error and system glitches are, at their root, primary markers of the existence of failure. Whether it's IT system failures, failures in process, or failures resulting from humans, it begs the question: "Should we be focusing on finding a method to identify, understand, and address our failures?" After all, it can be an arduous task to predict the next malicious attack, which often requires investment of time to sift threat intelligence, dig through forensic data, or churn threat feeds full of unknown factors and undetermined motives. Failure instrumentation, identification, and remediation are mostly comprised of things that we know, have the ability to test, and can measure. - -Failures we can analyze consist not only of IT, business, and general human factors but also the way we design, build, implement, configure, operate, observe, and manage security controls. People are the ones designing, building, monitoring, and managing the security controls we put in place to defend against malicious attackers. How often do we proactively instrument what we designed, built, and are operationally managing to determine if the controls are failing? Most organizations do not discover that their security controls were failing until a security incident results from that failure. The worst time to find out your security investment failed is during a security incident at 3 a.m. - -> Security incidents are not detective measures and hope is not a strategy when it comes to operating effective security controls. - -We hypothesize that a large portion of data breaches are caused not by sophisticated nation-state actors or hacktivists, but rather simple things rooted in human error and system glitches. Failure in security controls can arise from poor control placement, technical misconfiguration, gaps in coverage, inadequate testing practices, human error, and numerous other things. - -### The journey into Security Chaos Testing - -Our venture into this new territory of Security Chaos Testing has shifted our thinking about the root cause of many of our notable security incidents and data breaches. - -We were brought together by [Bruce Wong][2], who now works at Stitch Fix with Charles, one of the authors of this article. Prior to Stitch Fix, Bruce was a founder of the Chaos Engineering and System Reliability Engineering (SRE) practices at Netflix, the company commonly credited with establishing the field. Bruce learned about this article's other author, Aaron, through the open source [ChaoSlingr][3] Security Chaos Testing tool project, on which Aaron was a contributor. Aaron was interested in Bruce's perspective on the idea of applying Chaos Engineering to cybersecurity, which led Bruce to connect us to share what we had been working on. As security practitioners, we were both intrigued by the idea of Chaos Engineering and had each begun thinking about how this new method of instrumentation might have a role in cybersecurity. - -Within a short timeframe, we began finishing each other's thoughts around testing and validating security capabilities, which we collectively call "Security Chaos Engineering." We directly challenged many of the concepts we had come to depend on in our careers, such as compensating security controls, defense-in-depth, and how to design preventative security. Quickly we realized that we needed to challenge the status quo "set-it-and-forget-it" model and instead execute on continuous instrumentation and validation of security capabilities. - -Businesses often don't fully understand whether their security capabilities and controls are operating as expected until they are not. We had both struggled throughout our careers to provide measurements on security controls that go beyond simple uptime metrics. Our journey has shown us there is a need for a more pragmatic approach that emphasizes proactive instrumentation and experimentation over blind faith. - -### Defining new terms - -In the security industry, we have a habit of not explaining terms and assuming we are speaking the same language. To correct that, here are a few key terms in this new approach: - - * **(Security) Chaos Experiments** are foundationally rooted in the scientific method, in that they seek not to validate what is already known to be true or already known to be false, rather they are focused on deriving new insights about the current state. - * **Security Chaos Engineering** is the discipline of instrumentation, identification, and remediation of failure within security controls through proactive experimentation to build confidence in the system's ability to defend against malicious conditions in production. - - - -### Security and distributed systems - -Consider the evolving nature of modern application design where systems are becoming more and more distributed, ephemeral, and immutable in how they operate. In this shifting paradigm, it is becoming difficult to comprehend the operational state and health of our systems' security. Moreover, how are we ensuring that it remains effective and vigilant as the surrounding environment is changing its parameters, components, and methodologies? - -What does it mean to be effective in terms of security controls? After all, a single security capability could easily be implemented in a wide variety of diverse scenarios in which failure may arise from many possible sources. For example, a standard firewall technology may be implemented, placed, managed, and configured differently depending on complexities in the business, web, and data logic. - -It is imperative that we not operate our business products and services on the assumption that something works. We must constantly, consistently, and proactively instrument our security controls to ensure they cut the mustard when it matters. This is why Security Chaos Testing is so important. What Security Chaos Engineering does is it provides a methodology for the experimentation of the security of distributed systems in order to build confidence in the ability to withstand malicious conditions. - -In Security Chaos Engineering: - - * Security capabilities must be end-to-end instrumented. - * Security must be continuously instrumented to build confidence in the system's ability to withstand malicious conditions. - * Readiness of a system's security defenses must be proactively assessed to ensure they are battle-ready and operating as intended. - * The security capability toolchain must be instrumented from end to end to drive new insights into not only the effectiveness of the functionality within the toolchain but also to discover where added value and improvement can be injected. - * Practiced instrumentation seeks to identify, detect, and remediate failures in security controls. - * The focus is on vulnerability and failure identification, not failure management. - * The operational effectiveness of incident management is sharpened. - - - -As Henry Ford said, "Failure is only the opportunity to begin again, this time more intelligently." Security Chaos Engineering and Security Chaos Testing give us that opportunity. - -Would you like to learn more? Join the discussion by following [@aaronrinehart][4] and [@charles_nwatu][5] on Twitter. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/1/new-paradigm-cybersecurity - -作者:[Aaron Rinehart][a] -译者:[译者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/aaronrinehart -[1]:https://www.ibm.com/security/data-breach -[2]:https://twitter.com/bruce_m_wong?lang=en -[3]:https://github.com/Optum/ChaoSlingr -[4]:https://twitter.com/aaronrinehart -[5]:https://twitter.com/charles_nwatu diff --git a/sources/talk/20180131 How to write a really great resume that actually gets you hired.md b/sources/talk/20180131 How to write a really great resume that actually gets you hired.md deleted file mode 100644 index b54b3944ae..0000000000 --- a/sources/talk/20180131 How to write a really great resume that actually gets you hired.md +++ /dev/null @@ -1,395 +0,0 @@ -How to write a really great resume that actually gets you hired -============================================================ - - -![](https://cdn-images-1.medium.com/max/2000/1*k7HRLZAsuINP9vIs2BIh1g.png) - -This is a data-driven guide to writing a resume that actually gets you hired. I’ve spent the past four years analyzing which resume advice works regardless of experience, role, or industry. The tactics laid out below are the result of what I’ve learned. They helped me land offers at Google, Microsoft, and Twitter and have helped my students systematically land jobs at Amazon, Apple, Google, Microsoft, Facebook, and more. - -### Writing Resumes Sucks. - -It’s a vicious cycle. - -We start by sifting through dozens of articles by career “gurus,” forced to compare conflicting advice and make our own decisions on what to follow. - -The first article says “one page MAX” while the second says “take two or three and include all of your experience.” - -The next says “write a quick summary highlighting your personality and experience” while another says “summaries are a waste of space.” - -You scrape together your best effort and hit “Submit,” sending your resume into the ether. When you don’t hear back, you wonder what went wrong: - - _“Was it the single page or the lack of a summary? Honestly, who gives a s**t at this point. I’m sick of sending out 10 resumes every day and hearing nothing but crickets.”_ - - -![](https://cdn-images-1.medium.com/max/1000/1*_zQqAjBhB1R4fz55InrrIw.jpeg) -How it feels to try and get your resume read in today’s world. - -Writing resumes sucks but it’s not your fault. - -The real reason it’s so tough to write a resume is because most of the advice out there hasn’t been proven against the actual end goal of getting a job. If you don’t know what consistently works, you can’t lay out a system to get there. - -It’s easy to say “one page works best” when you’ve seen it happen a few times. But how does it hold up when we look at 100 resumes across different industries, experience levels, and job titles? - -That’s what this article aims to answer. - -Over the past four years, I’ve personally applied to hundreds of companies and coached hundreds of people through the job search process. This has given me a huge opportunity to measure, analyze, and test the effectiveness of different resume strategies at scale. - -This article is going to walk through everything I’ve learned about resumes over the past 4 years, including: - -* Mistakes that more than 95% of people make, causing their resumes to get tossed immediately - -* Three things that consistently appear in the resumes of highly effective job searchers (who go on to land jobs at the world’s best companies) - -* A quick hack that will help you stand out from the competition and instantly build relationships with whomever is reading your resume (increasing your chances of hearing back and getting hired) - -* The exact resume template that got me interviews and offers at Google, Microsoft, Twitter, Uber, and more - -Before we get to the unconventional strategies that will help set you apart, we need to make sure our foundational bases are covered. That starts with understanding the mistakes most job seekers make so we can make our resume bulletproof. - -### Resume Mistakes That 95% Of People Make - -Most resumes that come through an online portal or across a recruiter’s desk are tossed out because they violate a simple rule. - -When recruiters scan a resume, the first thing they look for is mistakes. Your resume could be fantastic, but if you violate a rule like using an unprofessional email address or improper grammar, it’s going to get tossed out. - -Our goal is to fully understand the triggers that cause recruiters/ATS systems to make the snap decisions on who stays and who goes. - -In order to get inside the heads of these decision makers, I collected data from dozens of recruiters and hiring mangers across industries. These people have several hundred years of hiring experience under their belts and they’ve reviewed 100,000+ resumes across industries. - -They broke down the five most common mistakes that cause them to cut resumes from the pile: - - -![](https://cdn-images-1.medium.com/max/1000/1*5Zbr3HFeKSjvPGZdq_LCKA.png) - -### The Five Most Common Resume Mistakes (According To Recruiters & Hiring Managers) - -Issue #1: Sloppiness (typos, spelling errors, & grammatical mistakes). Close to 60% of resumes have some sort of typo or grammatical issue. - -Solution: Have your resume reviewed by three separate sources — spell checking software, a friend, and a professional. Spell check should be covered if you’re using Microsoft Word or Google Docs to create your resume. - -A friend or family member can cover the second base, but make sure you trust them with reviewing the whole thing. You can always include an obvious mistake to see if they catch it. - -Finally, you can hire a professional editor on [Upwork][1]. It shouldn’t take them more than 15–20 minutes to review so it’s worth paying a bit more for someone with high ratings and lots of hours logged. - -Issue #2: Summaries are too long and formal. Many resumes include summaries that consist of paragraphs explaining why they are a “driven, results oriented team player.” When hiring managers see a block of text at the top of the resume, you can bet they aren’t going to read the whole thing. If they do give it a shot and read something similar to the sentence above, they’re going to give up on the spot. - -Solution: Summaries are highly effective, but they should be in bullet form and showcase your most relevant experience for the role. For example, if I’m applying for a new business sales role my first bullet might read “Responsible for driving $11M of new business in 2018, achieved 168% attainment (#1 on my team).” - -Issue #3: Too many buzz words. Remember our driven team player from the last paragraph? Phrasing like that makes hiring managers cringe because your attempt to stand out actually makes you sound like everyone else. - -Solution: Instead of using buzzwords, write naturally, use bullets, and include quantitative results whenever possible. Would you rather hire a salesperson who “is responsible for driving new business across the healthcare vertical to help companies achieve their goals” or “drove $15M of new business last quarter, including the largest deal in company history”? Skip the buzzwords and focus on results. - -Issue #4: Having a resume that is more than one page. The average employer spends six seconds reviewing your resume — if it’s more than one page, it probably isn’t going to be read. When asked, recruiters from Google and Barclay’s both said multiple page resumes “are the bane of their existence.” - -Solution: Increase your margins, decrease your font, and cut down your experience to highlight the most relevant pieces for the role. It may seem impossible but it’s worth the effort. When you’re dealing with recruiters who see hundreds of resumes every day, you want to make their lives as easy as possible. - -### More Common Mistakes & Facts (Backed By Industry Research) - -In addition to personal feedback, I combed through dozens of recruitment survey results to fill any gaps my contacts might have missed. Here are a few more items you may want to consider when writing your resume: - -* The average interviewer spends 6 seconds scanning your resume - -* The majority of interviewers have not looked at your resume until -  you walk into the room - -* 76% of resumes are discarded for an unprofessional email address - -* Resumes with a photo have an 88% rejection rate - -* 58% of resumes have typos - -* Applicant tracking software typically eliminates 75% of resumes due to a lack of keywords and phrases being present - -Now that you know every mistake you need to avoid, the first item on your to-do list is to comb through your current resume and make sure it doesn’t violate anything mentioned above. - -Once you have a clean resume, you can start to focus on more advanced tactics that will really make you stand out. There are a few unique elements you can use to push your application over the edge and finally get your dream company to notice you. - - -![](https://cdn-images-1.medium.com/max/1000/1*KthhefFO33-8tm0kBEPbig.jpeg) - -### The 3 Elements Of A Resume That Will Get You Hired - -My analysis showed that highly effective resumes typically include three specific elements: quantitative results, a simple design, and a quirky interests section. This section breaks down all three elements and shows you how to maximize their impact. - -### Quantitative Results - -Most resumes lack them. - -Which is a shame because my data shows that they make the biggest difference between resumes that land interviews and resumes that end up in the trash. - -Here’s an example from a recent resume that was emailed to me: - -> Experience - -> + Identified gaps in policies and processes and made recommendations for solutions at the department and institution level - -> + Streamlined processes to increase efficiency and enhance quality - -> + Directly supervised three managers and indirectly managed up to 15 staff on multiple projects - -> + Oversaw execution of in-house advertising strategy - -> + Implemented comprehensive social media plan - -As an employer, that tells me absolutely nothing about what to expect if I hire this person. - -They executed an in-house marketing strategy. Did it work? How did they measure it? What was the ROI? - -They also also identified gaps in processes and recommended solutions. What was the result? Did they save time and operating expenses? Did it streamline a process resulting in more output? - -Finally, they managed a team of three supervisors and 15 staffers. How did that team do? Was it better than the other teams at the company? What results did they get and how did those improve under this person’s management? - -See what I’m getting at here? - -These types of bullets talk about daily activities, but companies don’t care about what you do every day. They care about results. By including measurable metrics and achievements in your resume, you’re showcasing the value that the employer can expect to get if they hire you. - -Let’s take a look at revised versions of those same bullets: - -> Experience - -> + Managed a team of 20 that consistently outperformed other departments in lead generation, deal size, and overall satisfaction (based on our culture survey) - -> + Executed in-house marketing strategy that resulted in a 15% increase in monthly leads along with a 5% drop in the cost per lead - -> + Implemented targeted social media campaign across Instagram & Pintrest, which drove an additional 50,000 monthly website visits and generated 750 qualified leads in 3 months - -If you were in the hiring manager’s shoes, which resume would you choose? - -That’s the power of including quantitative results. - -### Simple, Aesthetic Design That Hooks The Reader - -These days, it’s easy to get carried away with our mission to “stand out.” I’ve seen resume overhauls from graphic designers, video resumes, and even resumes [hidden in a box of donuts.][2] - -While those can work in very specific situations, we want to aim for a strategy that consistently gets results. The format I saw the most success with was a black and white Word template with sections in this order: - -* Summary - -* Interests - -* Experience - -* Education - -* Volunteer Work (if you have it) - -This template is effective because it’s familiar and easy for the reader to digest. - -As I mentioned earlier, hiring managers scan resumes for an average of 6 seconds. If your resume is in an unfamiliar format, those 6 seconds won’t be very comfortable for the hiring manager. Our brains prefer things we can easily recognize. You want to make sure that a hiring manager can actually catch a glimpse of who you are during their quick scan of your resume. - -If we’re not relying on design, this hook needs to come from the  _Summary_ section at the top of your resume. - -This section should be done in bullets (not paragraph form) and it should contain 3–4 highlights of the most relevant experience you have for the role. For example, if I was applying for a New Business Sales position, my summary could look like this: - -> Summary - -> Drove quarterly average of $11M in new business with a quota attainment of 128% (#1 on my team) - -> Received award for largest sales deal of the year - -> Developed and trained sales team on new lead generation process that increased total leads by 17% in 3 months, resulting in 4 new deals worth $7M - -Those bullets speak directly to the value I can add to the company if I was hired for the role. - -### An “Interests” Section That’s Quirky, Unique, & Relatable - -This is a little “hack” you can use to instantly build personal connections and positive associations with whomever is reading your resume. - -Most resumes have a skills/interests section, but it’s usually parked at the bottom and offers little to no value. It’s time to change things up. - -[Research shows][3] that people rely on emotions, not information, to make decisions. Big brands use this principle all the time — emotional responses to advertisements are more influential on a person’s intent to buy than the content of an ad. - -You probably remember Apple’s famous “Get A Mac” campaign: - - -When it came to specs and performance, Macs didn’t blow every single PC out of the water. But these ads solidified who was “cool” and who wasn’t, which was worth a few extra bucks to a few million people. - -By tugging at our need to feel “cool,” Apple’s campaign led to a [42% increase in market share][4] and a record sales year for Macbooks. - -Now we’re going to take that same tactic and apply it to your resume. - -If you can invoke an emotional response from your recruiter, you can influence the mental association they assign to you. This gives you a major competitive advantage. - -Let’s start with a question — what could you talk about for hours? - -It could be cryptocurrency, cooking, World War 2, World of Warcraft, or how Google’s bet on segmenting their company under the Alphabet is going to impact the technology sector over the next 5 years. - -Did a topic (or two) pop into year head? Great. - -Now think about what it would be like to have a conversation with someone who was just as passionate and knew just as much as you did on the topic. It’d be pretty awesome, right?  _Finally, _ someone who gets it! - -That’s exactly the kind of emotional response we’re aiming to get from a hiring manager. - -There are five “neutral” topics out there that people enjoy talking about: - -1. Food/Drink - -2. Sports - -3. College - -4. Hobbies - -5. Geography (travel, where people are from, etc.) - -These topics are present in plenty of interest sections but we want to take them one step further. - -Let’s say you had the best night of your life at the Full Moon Party in Thailand. Which of the following two options would you be more excited to read: - -* Traveling - -* Ko Pha Ngan beaches (where the full moon party is held) - -Or, let’s say that you went to Duke (an ACC school) and still follow their basketball team. Which would you be more pumped about: - -* College Sports - -* ACC Basketball (Go Blue Devils!) - -In both cases, the second answer would probably invoke a larger emotional response because it is tied directly to your experience. - -I want you to think about your interests that fit into the five categories I mentioned above. - -Now I want you to write a specific favorite associated with each category in parentheses next to your original list. For example, if you wrote travel you can add (ask me about the time I was chased by an elephant in India) or (specifically meditation in a Tibetan monastery). - -Here is the [exact set of interests][5] I used on my resume when I interviewed at Google, Microsoft, and Twitter: - - _ABC Kitchen’s Atmosphere, Stumptown Coffee (primarily cold brew), Michael Lewis (Liar’s Poker), Fishing (especially fly), Foods That Are Vehicles For Hot Sauce, ACC Sports (Go Deacs!) & The New York Giants_ - - -![](https://cdn-images-1.medium.com/max/1000/1*ONxtGr_xUYmz4_Xe66aeng.jpeg) - -If you want to cheat here, my experience shows that anything about hot sauce is an instant conversation starter. - -### The Proven Plug & Play Resume Template - -Now that we have our strategies down, it’s time to apply these tactics to a real resume. Our goal is to write something that increases your chances of hearing back from companies, enhances your relationships with hiring managers, and ultimately helps you score the job offer. - -The example below is the exact resume that I used to land interviews and offers at Microsoft, Google, and Twitter. I was targeting roles in Account Management and Sales, so this sample is tailored towards those positions. We’ll break down each section below: - - -![](https://cdn-images-1.medium.com/max/1000/1*B2RQ89ue2dGymRdwMY2lBA.png) - -First, I want you to notice how clean this is. Each section is clearly labeled and separated and flows nicely from top to bottom. - -My summary speaks directly to the value I’ve created in the past around company culture and its bottom line: - -* I consistently exceeded expectations - -* I started my own business in the space (and saw real results) - -* I’m a team player who prioritizes culture - -I purposefully include my Interests section right below my Summary. If my hiring manager’s six second scan focused on the summary, I know they’ll be interested. Those bullets cover all the subconscious criteria for qualification in sales. They’re going to be curious to read more in my Experience section. - -By sandwiching my Interests in the middle, I’m upping their visibility and increasing the chance of creating that personal connection. - -You never know — the person reading my resume may also be a hot sauce connoisseur and I don’t want that to be overlooked because my interests were sitting at the bottom. - -Next, my Experience section aims to flesh out the points made in my Summary. I mentioned exceeding my quota up top, so I included two specific initiatives that led to that attainment, including measurable results: - -* A partnership leveraging display advertising to drive users to a gamified experience. The campaign resulted in over 3000 acquisitions and laid the groundwork for the 2nd largest deal in company history. - -* A partnership with a top tier agency aimed at increasing conversions for a client by improving user experience and upgrading tracking during a company-wide website overhaul (the client has ~20 brand sites). Our efforts over 6 months resulted in a contract extension worth 316% more than their original deal. - -Finally, I included my education at the very bottom starting with the most relevant coursework. - -Download My Resume Templates For Free - -You can download a copy of the resume sample above as well as a plug and play template here: - -Austin’s Resume: [Click To Download][6] - -Plug & Play Resume Template: [Click To Download][7] - -### Bonus Tip: An Unconventional Resume “Hack” To Help You Beat Applicant Tracking Software - -If you’re not already familiar, Applicant Tracking Systems are pieces of software that companies use to help “automate” the hiring process. - -After you hit submit on your online application, the ATS software scans your resume looking for specific keywords and phrases (if you want more details, [this article][8] does a good job of explaining ATS). - -If the language in your resume matches up, the software sees it as a good fit for the role and will pass it on to the recruiter. However, even if you’re highly qualified for the role but you don’t use the right wording, your resume can end up sitting in a black hole. - -I’m going to teach you a little hack to help improve your chances of beating the system and getting your resume in the hands of a human: - -Step 1: Highlight and select the entire job description page and copy it to your clipboard. - -Step 2: Head over to [WordClouds.com][9] and click on the “Word List” button at the top. Towards the top of the pop up box, you should see a link for Paste/Type Text. Go ahead and click that. - -Step 3: Now paste the entire job description into the box, then hit “Apply.” - -WordClouds is going to spit out an image that showcases every word in the job description. The larger words are the ones that appear most frequently (and the ones you want to make sure to include when writing your resume). Here’s an example for a data a science role: - - -![](https://cdn-images-1.medium.com/max/1000/1*O7VO1C9nhC9LZct7vexTbA.png) - -You can also get a quantitative view by clicking “Word List” again after creating your cloud. That will show you the number of times each word appeared in the job description: - -9 data - -6 models - -4 experience - -4 learning - -3 Experience - -3 develop - -3 team - -2 Qualifications - -2 statistics - -2 techniques - -2 libraries - -2 preferred - -2 research - -2 business - -When writing your resume, your goal is to include those words in the same proportions as the job description. - -It’s not a guaranteed way to beat the online application process, but it will definitely help improve your chances of getting your foot in the door! - -* * * - -### Want The Inside Info On Landing A Dream Job Without Connections, Without “Experience,” & Without Applying Online? - -[Click here to get the 5 free strategies that my students have used to land jobs at Google, Microsoft, Amazon, and more without applying online.][10] - - _Originally published at _ [_cultivatedculture.com_][11] _._ - --------------------------------------------------------------------------------- - -作者简介: - -I help people land jobs they love and salaries they deserve at CultivatedCulture.com - ----------- - -via: https://medium.freecodecamp.org/how-to-write-a-really-great-resume-that-actually-gets-you-hired-e18533cd8d17 - -作者:[Austin Belcak ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://medium.freecodecamp.org/@austin.belcak -[1]:http://www.upwork.com/ -[2]:https://www.thrillist.com/news/nation/this-guy-hides-his-resume-in-boxes-of-donuts-to-score-job-interviews -[3]:https://www.psychologytoday.com/blog/inside-the-consumer-mind/201302/how-emotions-influence-what-we-buy -[4]:https://www.businesswire.com/news/home/20070608005253/en/Apple-Mac-Named-Successful-Marketing-Campaign-2007 -[5]:http://cultivatedculture.com/resume-skills-section/ -[6]:https://drive.google.com/file/d/182gN6Kt1kBCo1LgMjtsGHOQW2lzATpZr/view?usp=sharing -[7]:https://drive.google.com/open?id=0B3WIcEDrxeYYdXFPVlcyQlJIbWc -[8]:https://www.jobscan.co/blog/8-things-you-need-to-know-about-applicant-tracking-systems/ -[9]:https://www.wordclouds.com/ -[10]:https://cultivatedculture.com/dreamjob/ -[11]:https://cultivatedculture.com/write-a-resume/ \ No newline at end of file diff --git a/sources/talk/20180206 UQDS- A software-development process that puts quality first.md b/sources/talk/20180206 UQDS- A software-development process that puts quality first.md deleted file mode 100644 index e9f7bb94ac..0000000000 --- a/sources/talk/20180206 UQDS- A software-development process that puts quality first.md +++ /dev/null @@ -1,99 +0,0 @@ -UQDS: A software-development process that puts quality first -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/build_structure_tech_program_code_construction.png?itok=nVsiLuag) - -The Ultimate Quality Development System (UQDS) is a software development process that provides clear guidelines for how to use branches, tickets, and code reviews. It was invented more than a decade ago by Divmod and adopted by [Twisted][1], an event-driven framework for Python that underlies popular commercial platforms like HipChat as well as open source projects like Scrapy (a web scraper). - -Divmod, sadly, is no longer around—it has gone the way of many startups. Luckily, since many of its products were open source, its legacy lives on. - -When Twisted was a young project, there was no clear process for when code was "good enough" to go in. As a result, while some parts were highly polished and reliable, others were alpha quality software—with no way to tell which was which. UQDS was designed as a process to help an existing project with definite quality challenges ramp up its quality while continuing to add features and become more useful. - -UQDS has helped the Twisted project evolve from having frequent regressions and needing multiple release candidates to get a working version, to achieving its current reputation of stability and reliability. - -### UQDS's building blocks - -UQDS was invented by Divmod back in 2006. At that time, Continuous Integration (CI) was in its infancy and modern version control systems, which allow easy branch merging, were barely proofs of concept. Although Divmod did not have today's modern tooling, it put together CI, some ad-hoc tooling to make [Subversion branches][2] work, and a lot of thought into a working process. Thus the UQDS methodology was born. - -UQDS is based upon fundamental building blocks, each with their own carefully considered best practices: - - 1. Tickets - 2. Branches - 3. Tests - 4. Reviews - 5. No exceptions - - - -Let's go into each of those in a little more detail. - -#### Tickets - -In a project using the UQDS methodology, no change is allowed to happen if it's not accompanied by a ticket. This creates a written record of what change is needed and—more importantly—why. - - * Tickets should define clear, measurable goals. - * Work on a ticket does not begin until the ticket contains goals that are clearly defined. - - - -#### Branches - -Branches in UQDS are tightly coupled with tickets. Each branch must solve one complete ticket, no more and no less. If a branch addresses either more or less than a single ticket, it means there was a problem with the ticket definition—or with the branch. Tickets might be split or merged, or a branch split and merged, until congruence is achieved. - -Enforcing that each branch addresses no more nor less than a single ticket—which corresponds to one logical, measurable change—allows a project using UQDS to have fine-grained control over the commits: A single change can be reverted or changes may even be applied in a different order than they were committed. This helps the project maintain a stable and clean codebase. - -#### Tests - -UQDS relies upon automated testing of all sorts, including unit, integration, regression, and static tests. In order for this to work, all relevant tests must pass at all times. Tests that don't pass must either be fixed or, if no longer relevant, be removed entirely. - -Tests are also coupled with tickets. All new work must include tests that demonstrate that the ticket goals are fully met. Without this, the work won't be merged no matter how good it may seem to be. - -A side effect of the focus on tests is that the only platforms that a UQDS-using project can say it supports are those on which the tests run with a CI framework—and where passing the test on the platform is a condition for merging a branch. Without this restriction on supported platforms, the quality of the project is not Ultimate. - -#### Reviews - -While automated tests are important to the quality ensured by UQDS, the methodology never loses sight of the human factor. Every branch commit requires code review, and each review must follow very strict rules: - - 1. Each commit must be reviewed by a different person than the author. - 2. Start with a comment thanking the contributor for their work. - 3. Make a note of something that the contributor did especially well (e.g., "that's the perfect name for that variable!"). - 4. Make a note of something that could be done better (e.g., "this line could use a comment explaining the choices."). - 5. Finish with directions for an explicit next step, typically either merge as-is, fix and merge, or fix and submit for re-review. - - - -These rules respect the time and effort of the contributor while also increasing the sharing of knowledge and ideas. The explicit next step allows the contributor to have a clear idea on how to make progress. - -#### No exceptions - -In any process, it's easy to come up with reasons why you might need to flex the rules just a little bit to let this thing or that thing slide through the system. The most important fundamental building block of UQDS is that there are no exceptions. The entire community works together to make sure that the rules do not flex, not for any reason whatsoever. - -Knowing that all code has been approved by a different person than the author, that the code has complete test coverage, that each branch corresponds to a single ticket, and that this ticket is well considered and complete brings a piece of mind that is too valuable to risk losing, even for a single small exception. The goal is quality, and quality does not come from compromise. - -### A downside to UQDS - -While UQDS has helped Twisted become a highly stable and reliable project, this reliability hasn't come without cost. We quickly found that the review requirements caused a slowdown and backlog of commits to review, leading to slower development. The answer to this wasn't to compromise on quality by getting rid of UQDS; it was to refocus the community priorities such that reviewing commits became one of the most important ways to contribute to the project. - -To help with this, the community developed a bot in the [Twisted IRC channel][3] that will reply to the command `review tickets` with a list of tickets that still need review. The [Twisted review queue][4] website returns a prioritized list of tickets for review. Finally, the entire community keeps close tabs on the number of tickets that need review. It's become an important metric the community uses to gauge the health of the project. - -### Learn more - -The best way to learn about UQDS is to [join the Twisted Community][5] and see it in action. If you'd like more information about the methodology and how it might help your project reach a high level of reliability and stability, have a look at the [UQDS documentation][6] in the Twisted wiki. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/uqds - -作者:[Moshe Zadka][a] -译者:[译者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 -[1]:https://twistedmatrix.com/trac/ -[2]:http://structure.usc.edu/svn/svn.branchmerge.html -[3]:http://webchat.freenode.net/?channels=%23twisted -[4]:https://twisted.reviews -[5]:https://twistedmatrix.com/trac/wiki/TwistedCommunity -[6]:https://twistedmatrix.com/trac/wiki/UltimateQualityDevelopmentSystem diff --git a/sources/talk/20180207 Why Mainframes Aren-t Going Away Any Time Soon.md b/sources/talk/20180207 Why Mainframes Aren-t Going Away Any Time Soon.md deleted file mode 100644 index 7a1a837ff9..0000000000 --- a/sources/talk/20180207 Why Mainframes Aren-t Going Away Any Time Soon.md +++ /dev/null @@ -1,73 +0,0 @@ -Why Mainframes Aren't Going Away Any Time Soon -====== - -![](http://www.datacenterknowledge.com/sites/datacenterknowledge.com/files/styles/article_featured_standard/public/ibm%20z13%20mainframe%202015%20getty.jpg?itok=uB8agshi) - -IBM's last earnings report showed the [first uptick in revenue in more than five years.][1] Some of that growth was from an expected source, cloud revenue, which was up 24 percent year over year and now accounts for 21 percent of Big Blue's take. Another major boost, however, came from a spike in mainframe revenue. Z series mainframe sales were up 70 percent, the company said. - -This may sound somewhat akin to a return to vacuum tube technology in a world where transistors are yesterday's news. In actuality, this is only a sign of the changing face of IT. - -**Related:** [One Click and Voilà, Your Entire Data Center is Encrypted][2] - -Modern mainframes definitely aren't your father's punch card-driven machines that filled entire rooms. These days, they most often run Linux and have found a renewed place in the data center, where they're being called upon to do a lot of heavy lifting. Want to know where the largest instance of Oracle's database runs? It's on a Linux mainframe. How about the largest implementation of SAP on the planet? Again, Linux on a mainframe. - -"Before the advent of Linux on the mainframe, the people who bought mainframes primarily were people who already had them," Leonard Santalucia explained to Data Center Knowledge several months back at the All Things Open conference. "They would just wait for the new version to come out and upgrade to it, because it would run cheaper and faster. - -**Related:** [IBM Designs a “Performance Beast” for AI][3] - -"When Linux came out, it opened up the door to other customers that never would have paid attention to the mainframe. In fact, probably a good three to four hundred new clients that never had mainframes before got them. They don't have any old mainframes hanging around or ones that were upgraded. These are net new mainframes." - -Although Santalucia is CTO at Vicom Infinity, primarily an IBM reseller, at the conference he was wearing his hat as chairperson of the Linux Foundation's Open Mainframe Project. He was joined in the conversation by John Mertic, the project's director of program management. - -Santalucia knows IBM's mainframes from top to bottom, having spent 27 years at Big Blue, the last eight as CTO for the company's systems and technology group. - -"Because of Linux getting started with it back in 1999, it opened up a lot of doors that were closed to the mainframe," he said. "Beforehand it was just z/OS, z/VM, z/VSE, z/TPF, the traditional operating systems. When Linux came along, it got the mainframe into other areas that it never was, or even thought to be in, because of how open it is, and because Linux on the mainframe is no different than Linux on any other platform." - -The focus on Linux isn't the only motivator behind the upsurge in mainframe use in data centers. Increasingly, enterprises with heavy IT needs are finding many advantages to incorporating modern mainframes into their plans. For example, mainframes can greatly reduce power, cooling, and floor space costs. In markets like New York City, where real estate is at a premium, electricity rates are high, and electricity use is highly taxed to reduce demand, these are significant advantages. - -"There was one customer where we were able to do a consolidation of 25 x86 cores to one core on a mainframe," Santalucia said. "They have several thousand machines that are ten and twenty cores each. So, as far as the eye could see in this data center, [x86 server workloads] could be picked up and moved onto this box that is about the size of a sub-zero refrigerator in your kitchen." - -In addition to saving on physical data center resources, this customer by design would likely see better performance. - -"When you look at the workload as it's running on an x86 system, the math, the application code, the I/O to manage the disk, and whatever else is attached to that system, is all run through the same chip," he explained. "On a Z, there are multiple chip architectures built into the system. There's one specifically just for the application code. If it senses the application needs an I/O or some mathematics, it sends it off to a separate processor to do math or I/O, all dynamically handled by the underlying firmware. Your Linux environment doesn't have to understand that. When it's running on a mainframe, it knows it's running on a mainframe and it will exploit that architecture." - -The operating system knows it's running on a mainframe because when IBM was readying its mainframe for Linux it open sourced something like 75,000 lines of code for Linux distributions to use to make sure their OS's were ready for IBM Z. - -"A lot of times people will hear there's 170 processors on the Z14," Santalucia said. "Well, there's actually another 400 other processors that nobody counts in that count of application chips, because it is taken for granted." - -Mainframes are also resilient when it comes to disaster recovery. Santalucia told the story of an insurance company located in lower Manhattan, within sight of the East River. The company operated a large data center in a basement that among other things housed a mainframe backed up to another mainframe located in Upstate New York. When Hurricane Sandy hit in 2012, the data center flooded, electrocuting two employees and destroying all of the servers, including the mainframe. But the mainframe's workload was restored within 24 hours from the remote backup. - -The x86 machines were all destroyed, and the data was never recovered. But why weren't they also backed up? - -"The reason they didn't do this disaster recovery the same way they did with the mainframe was because it was too expensive to have a mirror of all those distributed servers someplace else," he explained. "With the mainframe, you can have another mainframe as an insurance policy that's lower in price, called Capacity BackUp, and it just sits there idling until something like this happens." - -Mainframes are also evidently tough as nails. Santalucia told another story in which a data center in Japan was struck by an earthquake strong enough to destroy all of its x86 machines. The center's one mainframe fell on its side but continued to work. - -The mainframe also comes with built-in redundancy to guard against situations that would be disastrous with x86 machines. - -"What if a hard disk fails on a node in x86?" the Open Mainframe Project's Mertic asked. "You're taking down a chunk of that cluster potentially. With a mainframe you're not. A mainframe just keeps on kicking like nothing's ever happened." - -Mertic added that a motherboard can be pulled from a running mainframe, and again, "the thing keeps on running like nothing's ever happened." - -So how do you figure out if a mainframe is right for your organization? Simple, says Santalucia. Do the math. - -"The approach should be to look at it from a business, technical, and financial perspective -- not just a financial, total-cost-of-acquisition perspective," he said, pointing out that often, costs associated with software, migration, networking, and people are not considered. The break-even point, he said, comes when at least 20 to 30 servers are being migrated to a mainframe. After that point the mainframe has a financial advantage. - -"You can get a few people running the mainframe and managing hundreds or thousands of virtual servers," he added. "If you tried to do the same thing on other platforms, you'd find that you need significantly more resources to maintain an environment like that. Seven people at ADP handle the 8,000 virtual servers they have, and they need seven only in case somebody gets sick. - -"If you had eight thousand servers on x86, even if they're virtualized, do you think you could get away with seven?" - --------------------------------------------------------------------------------- - -via: http://www.datacenterknowledge.com/hardware/why-mainframes-arent-going-away-any-time-soon - -作者:[Christine Hall][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://www.datacenterknowledge.com/archives/author/christine-hall -[1]:http://www.datacenterknowledge.com/ibm/mainframe-sales-fuel-growth-ibm -[2]:http://www.datacenterknowledge.com/design/one-click-and-voil-your-entire-data-center-encrypted -[3]:http://www.datacenterknowledge.com/design/ibm-designs-performance-beast-ai diff --git a/sources/talk/20180209 Arch Anywhere Is Dead, Long Live Anarchy Linux.md b/sources/talk/20180209 Arch Anywhere Is Dead, Long Live Anarchy Linux.md deleted file mode 100644 index c3c78e84ad..0000000000 --- a/sources/talk/20180209 Arch Anywhere Is Dead, Long Live Anarchy Linux.md +++ /dev/null @@ -1,127 +0,0 @@ -Arch Anywhere Is Dead, Long Live Anarchy Linux -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/anarchy_main.jpg?itok=fyBpTjQW) - -Arch Anywhere was a distribution aimed at bringing Arch Linux to the masses. Due to a trademark infringement, Arch Anywhere has been completely rebranded to [Anarchy Linux][1]. And I’m here to say, if you’re looking for a distribution that will enable you to enjoy Arch Linux, a little Anarchy will go a very long way. This distribution is seriously impressive in what it sets out to do and what it achieves. In fact, anyone who previously feared Arch Linux can set those fears aside… because Anarchy Linux makes Arch Linux easy. - -Let’s face it; Arch Linux isn’t for the faint of heart. The installation alone will turn off many a new user (and even some seasoned users). That’s where distributions like Anarchy make for an easy bridge to Arch. With a live ISO that can be tested and then installed, Arch becomes as user-friendly as any other distribution. - -Anarchy Linux goes a little bit further than that, however. Let’s fire it up and see what it does. - -### The installation - -The installation of Anarchy Linux isn’t terribly challenging, but it’s also not quite as simple as for, say, [Ubuntu][2], [Linux Mint][3], or [Elementary OS][4]. Although you can run the installer from within the default graphical desktop environment (Xfce4), it’s still much in the same vein as Arch Linux. In other words, you’re going to have to do a bit of work—all within a text-based installer. - -To start, the very first step of the installer (Figure 1) requires you to update the mirror list, which will likely trip up new users. - -![Updating the mirror][6] - -Figure 1: Updating the mirror list is a necessity for the Anarchy Linux installation. - -[Used with permission][7] - -From the options, select Download & Rank New Mirrors. Tab down to OK and hit Enter on your keyboard. You can then select the nearest mirror (to your location) and be done with it. The next few installation screens are simple (keyboard layout, language, timezone, etc.). The next screen should surprise many an Arch fan. Anarchy Linux includes an auto partition tool. Select Auto Partition Drive (Figure 2), tab down to Ok, and hit Enter on your keyboard. - -![partitioning][9] - -Figure 2: Anarchy makes partitioning easy. - -[Used with permission][7] - -You will then have to select the drive to be used (if you only have one drive this is only a matter of hitting Enter). Once you’ve selected the drive, choose the filesystem type to be used (ext2/3/4, btrfs, jfs, reiserfs, xfs), tab down to OK, and hit Enter. Next you must choose whether you want to create SWAP space. If you select Yes, you’ll then have to define how much SWAP to use. The next window will stop many new users in their tracks. It asks if you want to use GPT (GUID Partition Table). This is different than the traditional MBR (Master Boot Record) partitioning. GPT is a newer standard and works better with UEFI. If you’ll be working with UEFI, go with GPT, otherwise, stick with the old standby, MBR. Finally select to write the changes to the disk, and your installation can continue. - -The next screen that could give new users pause, requires the selection of the desired installation. There are five options: - - * Anarchy-Desktop - - * Anarchy-Desktop-LTS - - * Anarchy-Server - - * Anarchy-Server-LTS - - * Anarchy-Advanced - - - - -If you want long term support, select Anarchy-Desktop-LTS, otherwise click Anarchy-Desktop (the default), and tab down to Ok. Click Enter on your keyboard. After you select the type of installation, you will get to select your desktop. You can select from five options: Budgie, Cinnamon, GNOME, Openbox, and Xfce4. -Once you’ve selected your desktop, give the machine a hostname, set the root password, create a user, and enable sudo for the new user (if applicable). The next section that will raise the eyebrows of new users is the software selection window (Figure 3). You must go through the various sections and select which software packages to install. Don’t worry, if you miss something, you can always installed it later. - - -![software][11] - -Figure 3: Selecting the software you want on your system. - -[Used with permission][7] - -Once you’ve made your software selections, tab to Install (Figure 4), and hit Enter on your keyboard. - -![ready to install][13] - -Figure 4: Everything is ready to install. - -[Used with permission][7] - -Once the installation completes, reboot and enjoy Anarchy. - -### Post install - -I installed two versions of Anarchy—one with Budgie and one with GNOME. Both performed quite well, however you might be surprised to see that the version of GNOME installed is decked out with a dock. In fact, comparing the desktops side-by-side and they do a good job of resembling one another (Figure 5). - -![GNOME and Budgie][15] - -Figure 5: GNOME is on the right, Budgie is on the left. - -[Used with permission][7] - -My guess is that you’ll find all desktop options for Anarchy configured in such a way to offer a similar look and feel. Of course, the second you click on the bottom left “buttons”, you’ll see those similarities immediately disappear (Figure 6). - -![GNOME and Budgie][17] - -Figure 6: The GNOME Dash and the Budgie menu are nothing alike. - -[Used with permission][7] - -Regardless of which desktop you select, you’ll find everything you need to install new applications. Open up your desktop menu of choice and select Packages to search for and install whatever is necessary for you to get your work done. - -### Why use Arch Linux without the “Arch”? - -This is a valid question. The answer is simple, but revealing. Some users may opt for a distribution like [Arch Linux][18] because they want the feeling of “elitism” that comes with using, say, [Gentoo][19], without having to go through that much hassle. With regards to complexity, Arch rests below Gentoo, which means it’s accessible to more users. However, along with that complexity in the platform, comes a certain level of dependability that may not be found in others. So if you’re looking for a Linux distribution with high stability, that’s not quite as challenging as Gentoo or Arch to install, Anarchy might be exactly what you want. In the end, you’ll wind up with an outstanding desktop platform that’s easy to work with (and maintain), based on a very highly regarded distribution of Linux. - -That’s why you might opt for Arch Linux without the Arch. - -Anarchy Linux is one of the finest “user-friendly” takes on Arch Linux I’ve ever had the privilege of using. Without a doubt, if you’re looking for a friendlier version of a rather challenging desktop operating system, you cannot go wrong with Anarchy. - -Learn more about Linux through the free ["Introduction to Linux" ][20]course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2018/2/arch-anywhere-dead-long-live-anarchy-linux - -作者:[Jack Wallen][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/jlwallen -[1]:https://anarchy-linux.org/ -[2]:https://www.ubuntu.com/ -[3]:https://linuxmint.com/ -[4]:https://elementary.io/ -[6]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/anarchy_install_1.jpg?itok=WgHRqFTf (Updating the mirror) -[7]:https://www.linux.com/licenses/category/used-permission -[9]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/anarchy_install_2.jpg?itok=D7HkR97t (partitioning) -[10]:/files/images/anarchyinstall3jpg -[11]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/anarchy_install_3.jpg?itok=5-9E2u0S (software) -[12]:/files/images/anarchyinstall4jpg -[13]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/anarchy_install_4.jpg?itok=fuSZqtZS (ready to install) -[14]:/files/images/anarchyinstall5jpg -[15]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/anarchy_install_5.jpg?itok=4y9kiC8I (GNOME and Budgie) -[16]:/files/images/anarchyinstall6jpg -[17]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/anarchy_install_6.jpg?itok=fJ7Lmdci (GNOME and Budgie) -[18]:https://www.archlinux.org/ -[19]:https://www.gentoo.org/ -[20]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/sources/talk/20180209 How writing can change your career for the better, even if you don-t identify as a writer.md b/sources/talk/20180209 How writing can change your career for the better, even if you don-t identify as a writer.md deleted file mode 100644 index 55618326c6..0000000000 --- a/sources/talk/20180209 How writing can change your career for the better, even if you don-t identify as a writer.md +++ /dev/null @@ -1,149 +0,0 @@ -How writing can change your career for the better, even if you don't identify as a writer -====== -Have you read Marie Kondo's book [The Life-Changing Magic of Tidying Up][1]? Or did you, like me, buy it and read a little bit and then add it to the pile of clutter next to your bed? - -Early in the book, Kondo talks about keeping possessions that "spark joy." In this article, I'll examine ways writing about what we and other people are doing in the open source world can "spark joy," or at least how writing can improve your career in unexpected ways. - -Because I'm a community manager and editor on Opensource.com, you might be thinking, "She just wants us to [write for Opensource.com][2]." And that is true. But everything I will tell you about why you should write is true, even if you never send a story in to Opensource.com. Writing can change your career for the better, even if you don't identify as a writer. Let me explain. - -### How I started writing - -Early in the first decade of my career, I transitioned from a customer service-related role at a tech publishing company into an editing role on Sys Admin Magazine. I was plugging along, happily laying low in my career, and then that all changed when I started writing about open source technologies and communities, and the people in them. But I did _not_ start writing voluntarily. The tl;dr: of it is that my colleagues at Linux New Media eventually talked me into launching our first blog on the [Linux Pro Magazine][3] site. And as it turns out, it was one of the best career decisions I've ever made. I would not be working on Opensource.com today had I not started writing about what other people in open source were doing all those years ago. - -When I first started writing, my goal was to raise awareness of the company I worked for and our publications, while also helping raise the visibility of women in tech. But soon after I started writing, I began seeing unexpected results. - -#### My network started growing - -When I wrote about a person, an organization, or a project, I got their attention. Suddenly the people I wrote about knew who I was. And because I was sharing knowledge—that is to say, I wasn't being a critic—I'd generally become an ally, and in many cases, a friend. I had a platform and an audience, and I was sharing them with other people in open source. - -#### I was learning - -In addition to promoting our website and magazine and growing my network, the research and fact-checking I did when writing articles helped me become more knowledgeable in my field and improve my tech chops. - -#### I started meeting more people IRL - -When I went to conferences, I found that my blog posts helped me meet people. I introduced myself to people I'd written about or learned about during my research, and I met new people to interview. People started knowing who I was because they'd read my articles. Sometimes people were even excited to meet me because I'd highlighted them, their projects, or someone or something they were interested in. I had no idea writing could be so exciting and interesting away from the keyboard. - -#### My conference talks improved - -I started speaking at events about a year after launching my blog. A few years later, I started writing articles based on my talks prior to speaking at events. The process of writing the articles helps me organize my talks and slides, and it was a great way to provide "notes" for conference attendees, while sharing the topic with a larger international audience that wasn't at the event in person. - -### What should you write about? - -Maybe you're interested in writing, but you struggle with what to write about. You should write about two things: what you know, and what you don't know. - -#### Write about what you know - -Writing about what you know can be relatively easy. For example, a script you wrote to help automate part of your daily tasks might be something you don't give any thought to, but it could make for a really exciting article for someone who hates doing that same task every day. That could be a relatively quick, short, and easy article for you to write, and you might not even think about writing it. But it could be a great contribution to the open source community. - -#### Write about what you don't know - -Writing about what you don't know can be much harder and more time consuming, but also much more fulfilling and help your career. I've found that writing about what I don't know helps me learn, because I have to research it and understand it well enough to explain it. - -> "When I write about a technical topic, I usually learn a lot more about it. I want to make sure my article is as good as it can be. So even if I'm writing about something I know well, I'll research the topic a bit more so I can make sure to get everything right." ~Jim Hall, FreeDOS project leader - -For example, I wanted to learn about machine learning, and I thought narrowing down the topic would help me get started. My team mate Jason Baker suggested that I write an article on the [Top 3 machine learning libraries for Python][4], which gave me a focus for research. - -The process of researching that article inspired another article, [3 cool machine learning projects using TensorFlow and the Raspberry Pi][5]. That article was also one of our most popular last year. I'm not an _expert_ on machine learning now, but researching the topic with writing an article in mind allowed me to give myself a crash course in the topic. - -### Why people in tech write - -Now let's look at a few benefits of writing that other people in tech have found. I emailed the Opensource.com writers' list and asked, and here's what writers told me. - -#### Grow your network or your project community - -Xavier Ho wrote for us for the first time last year ("[A programmer's cleaning guide for messy sensor data][6]"). He says: "I've been getting Twitter mentions from all over the world, including Spain, US, Australia, Indonesia, the UK, and other European countries. It shows the article is making some impact... This is the kind of reach I normally don't have. Hope it's really helping someone doing similar work!" - -#### Help people - -Writing about what other people are working on is a great way to help your fellow community members. Antoine Thomas, who wrote "[Linux helped me grow as a musician][7]", says, "I began to use open source years ago, by reading tutorials and documentation. That's why now I share my tips and tricks, experience or knowledge. It helped me to get started, so I feel that it's my turn to help others to get started too." - -#### Give back to the community - -[Jim Hall][8], who started the [FreeDOS project][9], says, "I like to write ... because I like to support the open source community by sharing something neat. I don't have time to be a program maintainer anymore, but I still like to do interesting stuff. So when something cool comes along, I like to write about it and share it." - -#### Highlight your community - -Emilio Velis wrote an article, "[Open hardware groups spread across the globe][10]", about projects in Central and South America. He explains, "I like writing about specific aspects of the open culture that are usually enclosed in my region (Latin America). I feel as if smaller communities and their ideas are hidden from the mainstream, so I think that creating this sense of broadness in participation is what makes some other cultures as valuable." - -#### Gain confidence - -[Don Watkins][11] is one of our regular writers and a [community moderator][12]. He says, "When I first started writing I thought I was an impostor, later I realized that many people feel that way. Writing and contributing to Opensource.com has been therapeutic, too, as it contributed to my self esteem and helped me to overcome feelings of inadequacy. … Writing has given me a renewed sense of purpose and empowered me to help others to write and/or see the valuable contributions that they too can make if they're willing to look at themselves in a different light. Writing has kept me younger and more open to new ideas." - -#### Get feedback - -One of our writers described writing as a feedback loop. He said that he started writing as a way to give back to the community, but what he found was that community responses give back to him. - -Another writer, [Stuart Keroff][13] says, "Writing for Opensource.com about the program I run at school gave me valuable feedback, encouragement, and support that I would not have had otherwise. Thousands upon thousands of people heard about the Asian Penguins because of the articles I wrote for the website." - -#### Exhibit expertise - -Writing can help you show that you've got expertise in a subject, and having writing samples on well-known websites can help you move toward better pay at your current job, get a new role at a different organization, or start bringing in writing income. - -[Jeff Macharyas][14] explains, "There are several ways I've benefitted from writing for Opensource.com. One, is the credibility I can add to my social media sites, resumes, bios, etc., just by saying 'I am a contributing writer to Opensource.com.' … I am hoping that I will be able to line up some freelance writing assignments, using my Opensource.com articles as examples, in the future." - -### Where should you publish your articles? - -That depends. Why are you writing? - -You can always post on your personal blog, but if you don't already have a lot of readers, your article might get lost in the noise online. - -Your project or company blog is a good option—again, you'll have to think about who will find it. How big is your company's reach? Or will you only get the attention of people who already give you their attention? - -Are you trying to reach a new audience? A bigger audience? That's where sites like Opensource.com can help. We attract more than a million page views a month, and more than 700,000 unique visitors. Plus you'll work with editors who will polish and help promote your article. - -We aren't the only site interested in your story. What are your favorite sites to read? They might want to help you share your story, and it's ok to pitch to multiple publications. Just be transparent about whether your article has been shared on other sites when working with editors. Occasionally, editors can even help you modify articles so that you can publish variations on multiple sites. - -#### Do you want to get rich by writing? (Don't count on it.) - -If your goal is to make money by writing, pitch your article to publications that have author budgets. There aren't many of them, the budgets don't tend to be huge, and you will be competing with experienced professional tech journalists who write seven days a week, 365 days a year, with large social media followings and networks. I'm not saying it can't be done—I've done it—but I am saying don't expect it to be easy or lucrative. It's not. (And frankly, I've found that nothing kills my desire to write much like having to write if I want to eat...) - -A couple of people have asked me whether Opensource.com pays for content, or whether I'm asking someone to write "for exposure." Opensource.com does not have an author budget, but I won't tell you to write "for exposure," either. You should write because it meets a need. - -If you already have a platform that meets your needs, and you don't need editing or social media and syndication help: Congratulations! You are privileged. - -### Spark joy! - -Most people don't know they have a story to tell, so I'm here to tell you that you probably do, and my team can help, if you just submit a proposal. - -Most people—myself included—could use help from other people. Sites like Opensource.com offer one way to get editing and social media services at no cost to the writer, which can be hugely valuable to someone starting out in their career, someone who isn't a native English speaker, someone who wants help with their project or organization, and so on. - -If you don't already write, I hope this article helps encourage you to get started. Or, maybe you already write. In that case, I hope this article makes you think about friends, colleagues, or people in your network who have great stories and experiences to share. I'd love to help you help them get started. - -I'll conclude with feedback I got from a recent writer, [Mario Corchero][15], a Senior Software Developer at Bloomberg. He says, "I wrote for Opensource because you told me to :)" (For the record, I "invited" him to write for our [PyCon speaker series][16] last year.) He added, "And I am extremely happy about it—not only did it help me at my workplace by gaining visibility, but I absolutely loved it! The article appeared in multiple email chains about Python and was really well received, so I am now looking to publish the second :)" Then he [wrote for us][17] again. - -I hope you find writing to be as fulfilling as we do. - -You can connect with Opensource.com editors, community moderators, and writers in our Freenode [IRC][18] channel #opensource.com, and you can reach me and the Opensource.com team by email at [open@opensource.com][19]. - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/career-changing-magic-writing - -作者:[Rikki Endsley][a] -译者:[译者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/rikki-endsley -[1]:http://tidyingup.com/books/the-life-changing-magic-of-tidying-up-hc -[2]:https://opensource.com/how-submit-article -[3]:http://linuxpromagazine.com/ -[4]:https://opensource.com/article/17/2/3-top-machine-learning-libraries-python -[5]:https://opensource.com/article/17/2/machine-learning-projects-tensorflow-raspberry-pi -[6]:https://opensource.com/article/17/9/messy-sensor-data -[7]:https://opensource.com/life/16/9/my-linux-story-musician -[8]:https://opensource.com/users/jim-hall -[9]:http://www.freedos.org/ -[10]:https://opensource.com/article/17/6/open-hardware-latin-america -[11]:https://opensource.com/users/don-watkins -[12]:https://opensource.com/community-moderator-program -[13]:https://opensource.com/education/15/3/asian-penguins-Linux-middle-school-club -[14]:https://opensource.com/users/jeffmacharyas -[15]:https://opensource.com/article/17/5/understanding-datetime-python-primer -[16]:https://opensource.com/tags/pycon -[17]:https://opensource.com/article/17/9/python-logging -[18]:https://opensource.com/article/16/6/getting-started-irc -[19]:mailto:open@opensource.com diff --git a/sources/talk/20180209 Why an involved user community makes for better software.md b/sources/talk/20180209 Why an involved user community makes for better software.md deleted file mode 100644 index 2b51023e44..0000000000 --- a/sources/talk/20180209 Why an involved user community makes for better software.md +++ /dev/null @@ -1,47 +0,0 @@ -Why an involved user community makes for better software -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_cubestalk.png?itok=Ozw4NhGW) - -Imagine releasing a major new infrastructure service based on open source software only to discover that the product you deployed had evolved so quickly that the documentation for the version you released is no longer available. At Bloomberg, we experienced this problem firsthand in our deployment of OpenStack. In late 2016, we spent six months testing and rolling out [Liberty][1] on our OpenStack environment. By that time, Liberty was about a year old, or two versions behind the latest build. - -As our users started taking advantage of its new functionality, we found ourselves unable to solve a few tricky problems and to answer some detailed questions about its API. When we went looking for Liberty's documentation, it was nowhere to be found on the OpenStack website. Liberty, it turned out, had been labeled "end of life" and was no longer supported by the OpenStack developer community. - -The disappearance wasn't intentional, rather the result of a development community that had not anticipated the real-world needs of users. The documentation was stored in the source branch along with the source code, and, as Liberty was superseded by newer versions, it had been deleted. Worse, in the intervening months, the documentation for the newer versions had been completely restructured, and there was no way to easily rebuild it in a useful form. And believe me, we tried. - -The disappearance wasn't intentional, rather the result of a development community that had not anticipated the real-world needs of users. ]After consulting other users and our vendor, we found that OpenStack's development cadence of two releases per year had created some unintended, yet deeply frustrating, consequences. Older releases that were typically still widely in use were being superseded and effectively killed for the purposes of support. - -Eventually, conversations took place between OpenStack users and developers that resulted in changes. Documentation was moved out of the source branch, and users can now build documentation for whatever version they're using—more or less indefinitely. The problem was solved. (I'm especially indebted to my colleague [Chris Morgan][2], who was knee-deep in this effort and first wrote about it in detail for the [OpenStack Superuser blog][3].) - -Many other enterprise users were in the same boat as Bloomberg—running older versions of OpenStack that are three or four versions behind the latest build. There's a good reason for that: On average it takes a reasonably large enterprise about six months to qualify, test, and deploy a new version of OpenStack. And, from my experience, this is generally true of most open source infrastructure projects. - -For most of the past decade, companies like Bloomberg that adopted open source software relied on distribution vendors to incorporate, test, verify, and support much of it. These vendors provide long-term support (LTS) releases, which enable enterprise users to plan for upgrades on a two- or three-year cycle, knowing they'll still have support for a year or two, even if their deployment schedule slips a bit (as they often do). In the past few years, though, infrastructure software has advanced so rapidly that even the distribution vendors struggle to keep up. And customers of those vendors are yet another step removed, so many are choosing to deploy this type of software without vendor support. - -Losing vendor support also usually means there are no LTS releases; OpenStack, Kubernetes, and Prometheus, and many more, do not yet provide LTS releases of their own. As a result, I'd argue that healthy interaction between the development and user community should be high on the list of considerations for adoption of any open source infrastructure. Do the developers building the software pay attention to the needs—and frustrations—of the people who deploy it and make it useful for their enterprise? - -There is a solid model for how this should happen. We recently joined the [Cloud Native Computing Foundation][4], part of The Linux Foundation. It has a formal [end-user community][5], whose members include organizations just like us: enterprises that are trying to make open source software useful to their internal customers. Corporate members also get a chance to have their voices heard as they vote to select a representative to serve on the CNCF [Technical Oversight Committee][6]. Similarly, in the OpenStack community, Bloomberg is involved in the semi-annual Operators Meetups, where companies who deploy and support OpenStack for their own users get together to discuss their challenges and provide guidance to the OpenStack developer community. - -The past few years have been great for open source infrastructure. If you're working for a large enterprise, the opportunity to deploy open source projects like the ones mentioned above has made your company more productive and more agile. - -As large companies like ours begin to consume more open source software to meet their infrastructure needs, they're going to be looking at a long list of considerations before deciding what to use: license compatibility, out-of-pocket costs, and the health of the development community are just a few examples. As a result of our experiences, we'll add the presence of a vibrant and engaged end-user community to the list. - -Increased reliance on open source infrastructure projects has also highlighted a key problem: People in the development community have little experience deploying the software they work on into production environments or supporting the people who use it to get things done on a daily basis. The fast pace of updates to these projects has created some unexpected problems for the people who deploy and use them. There are numerous examples I can cite where open source projects are updated so frequently that new versions will, usually unintentionally, break backwards compatibility. - -As open source increasingly becomes foundational to the operation of so many enterprises, this cannot be allowed to happen, and members of the user community should assert themselves accordingly and press for the creation of formal representation. In the end, the software can only be better. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/important-conversation - -作者:[Kevin P.Fleming][a] -译者:[译者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/kpfleming -[1]:https://releases.openstack.org/liberty/ -[2]:https://www.linkedin.com/in/mihalis68/ -[3]:http://superuser.openstack.org/articles/openstack-at-bloomberg/ -[4]:https://www.cncf.io/ -[5]:https://www.cncf.io/people/end-user-community/ -[6]:https://www.cncf.io/people/technical-oversight-committee/ diff --git a/sources/talk/20180214 Can anonymity and accountability coexist.md b/sources/talk/20180214 Can anonymity and accountability coexist.md deleted file mode 100644 index 8b15ed169c..0000000000 --- a/sources/talk/20180214 Can anonymity and accountability coexist.md +++ /dev/null @@ -1,79 +0,0 @@ -Can anonymity and accountability coexist? -========================================= - -Anonymity might be a boon to more open, meritocratic organizational cultures. But does it conflict with another important value: accountability? - -![Can anonymity and accountability coexist?](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/GOV_Transparency_B.png?itok=SkP1mUt5 "Can anonymity and accountability coexist?") - -Image by :opensource.com - -### Get the newsletter - -Join the 85,000 open source advocates who receive our giveaway alerts and article roundups. - -Whistleblowing protections, crowdsourcing, anonymous voting processes, and even Glassdoor reviews—anonymous speech may take many forms in organizations. - -As well-established and valued as these anonymous feedback mechanisms may be, anonymous speech becomes a paradoxical idea when one considers how to construct a more open organization. While an inability to discern speaker identity seems non-transparent, an opportunity for anonymity may actually help achieve a _more inclusive and meritocratic_ environment. - -More about open organizations - -* [Download free Open Org books](https://opensource.com/open-organization/resources/book-series?src=too_resource_menu1a) -* [What is an Open Organization?](https://opensource.com/open-organization/resources/open-org-definition?src=too_resource_menu2a) -* [How open is your organization?](https://opensource.com/open-organization/resources/open-org-maturity-model?src=too_resource_menu3a) -* [What is an Open Decision?](https://opensource.com/open-organization/resources/open-decision-framework?src=too_resource_menu4a) -* [The Open Org two years later](https://www.redhat.com/en/about/blog/open-organization-two-years-later-and-going-strong?src=too_resource_menu4b&intcmp=70160000000h1s6AAA) - -But before allowing outlets for anonymous speech to propagate, however, leaders of an organization should carefully reflect on whether an organization's "closed" practices make anonymity the unavoidable alternative to free, non-anonymous expression. Though some assurance of anonymity is necessary in a few sensitive and exceptional scenarios, dependence on anonymous feedback channels within an organization may stunt the normalization of a culture that encourages diversity and community. - -### The benefits of anonymity - -In the case of [_Talley v. California (1960)_](https://supreme.justia.com/cases/federal/us/362/60/case.html), the Supreme Court voided a city ordinance prohibiting the anonymous distribution of handbills, asserting that "there can be no doubt that such an identification requirement would tend to restrict freedom to distribute information and thereby freedom of expression." Our judicial system has legitimized the notion that the protection of anonymity facilitates the expression of otherwise unspoken ideas. A quick scroll through any [subreddit](https://www.reddit.com/reddits/) exemplifies what the Court has codified: anonymity can foster [risk-taking creativity](https://www.reddit.com/r/sixwordstories/) and the [inclusion and support of marginalized voices](https://www.reddit.com/r/MyLittleSupportGroup/). Anonymity empowers individuals by granting them the safety to speak without [detriment to their reputations or, more importantly, their physical selves.](https://www.psychologytoday.com/blog/the-compassion-chronicles/201711/why-dont-victims-sexual-harassment-come-forward-sooner) - -For example, an anonymous suggestion program to garner ideas from members or employees in an organization may strengthen inclusivity and enhance the diversity of suggestions the organization receives. It would also make for a more meritocratic decision-making process, as anonymity would ensure that the quality of the articulated idea, rather than the rank and reputation of the articulator, is what's under evaluation. Allowing members to anonymously vote for anonymously-submitted ideas would help curb the influence of office politics in decisions affecting the organization's growth. - -### The harmful consequences of anonymity - -Yet anonymity and the open value of _accountability_ may come into conflict with one another. For instance, when establishing anonymous programs to drive greater diversity and more meritocratic evaluation of ideas, organizations may need to sacrifice the ability to hold speakers accountable for the opinions they express. - -Reliance on anonymous speech for serious organizational decision-making may also contribute to complacency in an organizational culture that falls short of openness. Outlets for anonymous speech may be as similar to open as crowdsourcing is—or rather, is not. [Like efforts to crowdsource creative ideas](https://opensource.com/business/10/4/why-open-source-way-trumps-crowdsourcing-way), anonymous suggestion programs may create an organizational environment in which diverse perspectives are only valued when an organization's leaders find it convenient to take advantage of members' ideas. - -Anonymity and the open value of accountability may come into conflict with one another. - -A similar concern holds for anonymous whistle-blowing or concern submission. Though anonymity is important for sexual harassment and assault reporting, regularly redirecting member concerns and frustrations to a "complaints box" makes it more difficult for members to hold their organization's leaders accountable for acting on concerns. It may also hinder intra-organizational support networks and advocacy groups from forming around shared concerns, as members would have difficulty identifying others with similar experiences. For example, many working mothers might anonymously submit requests for a lactation room in their workplace, then falsely attribute a lack of action from leaders to a lack of similar concerns from others. - -### An anonymity checklist - -Organizations in which anonymous speech is the primary mode of communication, like subreddits, have generated innovative works and thought-provoking discourse. These anonymous networks call attention to the potential for anonymity to help organizations pursue open values of diversity and meritocracy. Organizations in which anonymous speech is _not_ the main form of communication should acknowledge the strengths of anonymous speech, but carefully consider whether anonymity is the wisest means to the goal of sustainable openness. - -Leaders may find reflecting on the following questions useful prior to establishing outlets for anonymous feedback within their organizations: - -1\. _Availability of additional communication mechanisms_: Rather than investing time and resources into establishing a new, anonymous channel for communication, can the culture or structure of existing avenues of communication be reconfigured to achieve the same goal? This question echoes the open source affinity toward realigning, rather than reinventing, the wheel. - -2\. _Failure of other communication avenues:_ How and why is the organization ill-equipped to handle the sensitive issue/situation at hand through conventional (i.e. non-anonymous) means of communication? - -Careful deliberation on these questions may help prevent outlets for anonymous speech from leading to a dangerous sense of complacency. - -3\. _Consequences of anonymity:_ If implemented, could the anonymous mechanism stifle the normalization of face-to-face discourse about issues important to the organization's growth? If so, how can leaders ensure that members consider the anonymous communication channel a "last resort," without undermining the legitimacy of the anonymous system? - -4\. _Designing the anonymous communication channel:_ How can accountability be promoted in anonymous communication without the ability to determine the identity of speakers? - -5\. _Long-term considerations_: Is the anonymous feedback mechanism sustainable, or a temporary solution to a larger organizational issue? If the latter, is [launching a campaign](https://opensource.com/open-organization/16/6/8-steps-more-open-communications) to address overarching problems with the organization's communication culture feasible? - -These five points build off of one another to help leaders recognize the tradeoffs involved in legitimizing anonymity within their organization. Careful deliberation on these questions may help prevent outlets for anonymous speech from leading to a dangerous sense of complacency with a non-inclusive organizational structure. - -About the author ----------------- - -[![](https://opensource.com/sites/default/files/styles/profile_pictures/public/osdc_default_avatar_1.png?itok=mmbfqFXm)](https://opensource.com/users/susiechoi) - -Susie Choi - Susie is an undergraduate student studying computer science at Duke University. She is interested in the implications of technological innovation and open source principles for issues relating to education and socioeconomic inequality. - -[More about me](https://opensource.com/users/susiechoi) - -* * * - -via: [https://opensource.com/open-organization/18/1/balancing-accountability-and-anonymity](https://opensource.com/open-organization/18/1/balancing-accountability-and-anonymity) - -作者: [Susie Choi](https://opensource.com/users/susiechoi) 选题者: [@lujun9972](https://github.com/lujun9972) 译者: [译者ID](https://github.com/译者ID) 校对: [校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 \ No newline at end of file diff --git a/sources/talk/20180216 Q4OS Makes Linux Easy for Everyone.md b/sources/talk/20180216 Q4OS Makes Linux Easy for Everyone.md deleted file mode 100644 index a868ed28d5..0000000000 --- a/sources/talk/20180216 Q4OS Makes Linux Easy for Everyone.md +++ /dev/null @@ -1,140 +0,0 @@ -Q4OS Makes Linux Easy for Everyone -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/q4os-main.png?itok=WDatcV-a) - -Modern Linux distributions tend to target a variety of users. Some claim to offer a flavor of the open source platform that anyone can use. And, I’ve seen some such claims succeed with aplomb, while others fall flat. [Q4OS][1] is one of those odd distributions that doesn’t bother to make such a claim but pulls off the feat anyway. - -So, who is the primary market for Q4OS? According to its website, the distribution is a: - -“fast and powerful operating system based on the latest technologies while offering highly productive desktop environment. We focus on security, reliability, long-term stability and conservative integration of verified new features. System is distinguished by speed and very low hardware requirements, runs great on brand new machines as well as legacy computers. It is also very applicable for virtualization and cloud computing.” - -What’s very interesting here is that the Q4OS developers offer commercial support for the desktop. Said support can cover the likes of system customization (including core level API programming) as well as user interface modifications. - -Once you understand this (and have installed Q4OS), the target audience becomes quite obvious: Business users looking for a Windows XP/7 replacement. But that should not prevent home users from giving Q4OS at try. It’s a Linux distribution that has a few unique tools that come together to make a solid desktop distribution. - -Let’s take a look at Q4OS and see if it’s a version of Linux that might work for you. - -### What Q4OS all about - -Q4OS that does an admirable job of being the open source equivalent of Windows XP/7. Out of the box, it pulls this off with the help of the [Trinity Desktop][2] (a fork of KDE). With a few tricks up its sleeve, Q4OS turns the Trinity Desktop into a remarkably similar desktop (Figure 1). - -![default desktop][4] - -Figure 1: The Q4OS default desktop. - -[Used with permission][5] - -When you fire up the desktop, you will be greeted by a Welcome screen that makes it very easy for new users to start setting up their desktop with just a few clicks. From this window, you can: - - * Run the Desktop Profiler (which allows you to select which desktop environment to use as well as between a full-featured desktop, a basic desktop, or a minimal desktop—Figure 2). - - * Install applications (which opens the Synaptic Package Manager). - - * Install proprietary codecs (which installs all the necessary media codecs for playing audio and video). - - * Turn on Desktop effects (if you want more eye candy, turn this on). - - * Switch to Kickoff start menu (switches from the default start menu to the newer kickoff menu). - - * Set Autologin (allows you to set login such that it won’t require your password upon boot). - - - - -![Desktop Profiler][7] - -Figure 2: The Desktop Profiler allows you to further customize your desktop experience. - -[Used with permission][5] - -If you want to install a different desktop environment, open up the Desktop Profiler and then click the Desktop environments drop-down, in the upper left corner of the window. A new window will appear, where you can select your desktop of choice from the drop-down (Figure 3). Once back at the main Profiler Window, select which type of desktop profile you want, and then click Install. - -![Desktop Profiler][9] - -Figure 3: Installing a different desktop is quite simple from within the Desktop Profiler. - -[Used with permission][5] - -Note that installing a different desktop will not wipe the default desktop. Instead, it will allow you to select between the two desktops (at the login screen). - -### Installed software - -After selecting full-featured desktop, from the Desktop Profiler, I found the following user applications ready to go: - - * LibreOffice 5.2.7.2 - - * VLC 2.2.7 - - * Google Chrome 64.0.3282 - - * Thunderbird 52.6.0 (Includes Lightning addon) - - * Synaptic 0.84.2 - - * Konqueror 14.0.5 - - * Firefox 52.6.0 - - * Shotwell 0.24.5 - - - - -Obviously some of those applications are well out of date. Since this distribution is based on Debian, we can run and update/upgrade with the commands: -``` -sudo apt update - -sudo apt upgrade - -``` - -However, after running both commands, it seems everything is up to date. This particular release (2.4) is an LTS release (supported until 2022). Because of this, expect software to be a bit behind. If you want to test out the bleeding edge version (based on Debian “Buster”), you can download the testing image [here][10]. - -### Security oddity - -There is one rather disturbing “feature” found in Q4OS. In the developer’s quest to make the distribution closely resemble Windows, they’ve made it such that installing software (from the command line) doesn’t require a password! You read that correctly. If you open the Synaptic package manager, you’re asked for a password. However (and this is a big however), open up a terminal window and issue a command like sudo apt-get install gimp. At this point, the software will install… without requiring the user to type a sudo password. - -Did you cringe at that? You should. - -I get it, the developers want to ease away the burden of Linux and make a platform the masses could easily adapt to. They’ve done a splendid job of doing just that. However, in the process of doing so, they’ve bypassed a crucial means of security. Is having as near an XP/7 clone as you can find on Linux worth that lack of security? I would say that if it enables more people to use Linux, then yes. But the fact that they’ve required a password for Synaptic (the GUI tool most Windows users would default to for software installation) and not for the command-line tool makes no sense. On top of that, bypassing passwords for the apt and dpkg commands could make for a significant security issue. - -Fear not, there is a fix. For those that prefer to require passwords for the command line installation of software, you can open up the file /etc/sudoers.d/30_q4os_apt and comment out the following three lines: -``` -%sudo ALL = NOPASSWD: /usr/bin/apt-get * - -%sudo ALL = NOPASSWD: /usr/bin/apt-key * - -%sudo ALL = NOPASSWD: /usr/bin/dpkg * - -``` - -Once commented out, save and close the file, and reboot the system. At this point, users will now be prompted for a password, should they run the apt-get, apt-key, or dpkg commands. - -### A worthy contender - -Setting aside the security curiosity, Q4OS is one of the best attempts at recreating Windows XP/7 I’ve come across in a while. If you have users who fear change, and you want to migrate them away from Windows, this distribution might be exactly what you need. I would, however, highly recommend you re-enable passwords for the apt-get, apt-key, and dpkg commands… just to be on the safe side. - -In any case, the addition of the Desktop Profiler, and the ability to easily install alternative desktops, makes Q4OS a distribution that just about anyone could use. - -Learn more about Linux through the free ["Introduction to Linux" ][11]course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2018/2/q4os-makes-linux-easy-everyone - -作者:[JACK WALLEN][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/jlwallen -[1]:https://q4os.org -[2]:https://www.trinitydesktop.org/ -[4]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/q4os_1.jpg?itok=dalJk9Xf (default desktop) -[5]:/licenses/category/used-permission -[7]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/q4os_2.jpg?itok=GlouIm73 (Desktop Profiler) -[9]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/q4os_3.jpg?itok=riSTP_1z (Desktop Profiler) -[10]:https://q4os.org/downloads2.html -[11]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/sources/talk/20180220 4 considerations when naming software development projects.md b/sources/talk/20180220 4 considerations when naming software development projects.md deleted file mode 100644 index 1e1add0b68..0000000000 --- a/sources/talk/20180220 4 considerations when naming software development projects.md +++ /dev/null @@ -1,91 +0,0 @@ -4 considerations when naming software development projects -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/hello-name-sticker-badge-tag.png?itok=fAgbMgBb) - -Working on a new open source project, you're focused on the code—getting that great new idea released so you can share it with the world. And you'll want to attract new contributors, so you need a terrific **name** for your project. - -We've all read guides for creating names, but how do you go about choosing the right one? Keeping that cool science fiction reference you're using internally might feel fun, but it won't mean much to new users you're trying to attract. A better approach is to choose a name that's memorable to new users and developers searching for your project. - -Names set expectations. Your project's name should showcase its functionality in the ecosystem and explain to users what your story is. In the crowded open source software world, it's important not to get entangled with other projects out there. Taking a little extra time now, before sending out that big announcement, will pay off later. - -Here are four factors to keep in mind when choosing a name for your project. - -### What does your project's code do? - -Start with your project: What does it do? You know the code intimately—but can you explain what it does to a new developer? Can you explain it to a CTO or non-developer at another company? What kinds of problems does your project solve for users? - -Your project's name needs to reflect what it does in a way that makes sense to newcomers who want to use or contribute to your project. That means considering the ecosystem for your technology and understanding if there are any naming styles or conventions used for similar kinds of projects. Imagine that you're trying to evaluate someone else's project: Would the name be appealing to you? - -Any distribution channels you push to are also part of the ecosystem. If your code will be in a Linux distribution, [npm][1], [CPAN][2], [Maven][3], or in a Ruby Gem, you need to review any naming standards or common practices for that package manager. Review any similar existing names in that distribution channel, and get a feel for naming styles of other programs there. - -### Who are the users and developers you want to attract? - -The hardest aspect of choosing a new name is putting yourself in the shoes of new users. You built this project; you already know how powerful it is, so while your cool name may sound great, it might not draw in new people. You need a name that is interesting to someone new, and that tells the world what problems your project solves. - -Great names depend on what kind of users you want to attract. Are you building an [Eclipse][4] plugin or npm module that's focused on developers? Or an analytics toolkit that brings visualizations to the average user? Understanding your user base and the kinds of open source contributors you want to attract is critical. - -Great names depend on what kind of users you want to attract. - -Take the time to think this through. Who does your project most appeal to, and how can it help them do their job? What kinds of problems does your code solve for end users? Understanding the target user helps you focus on what users need, and what kind of names or brands they respond to. - -Take the time to think this through. Who does your project most appeal to, and how can it help them do their job? What kinds of problems does your code solve for end users? Understanding the target user helps you focus on what users need, and what kind of names or brands they respond to. - -When you're open source, this equation changes a bit—your target is not just users; it's also developers who will want to contribute code back to your project. You're probably a developer, too: What kinds of names and brands excite you, and what images would entice you to try out someone else's new project? - -Once you have a better feel of what users and potential contributors expect, use that knowledge to refine your names. Remember, you need to step outside your project and think about how the name would appeal to someone who doesn't know how amazing your code is—yet. Once someone gets to your website, does the name synchronize with what your product does? If so, move to the next step. - -### Who else is using similar names for software? - -Now that you've tried on a user's shoes to evaluate potential names, what's next? Figuring out if anyone else is already using a similar name. It sometimes feels like all the best names are taken—but if you search carefully, you'll find that's not true. - -The first step is to do a few web searches using your proposed name. Search for the name, plus "software", "open source", and a few keywords for the functionality that your code provides. Look through several pages of results for each search to see what's out there in the software world. - -The first step is to do a few web searches using your proposed name. - -Unless you're using a completely made-up word, you'll likely get a lot of hits. The trick is understanding which search results might be a problem. Again, put on the shoes of a new user to your project. If you were searching for this great new product and saw the other search results along with your project's homepage, would you confuse them? Are the other search results even software products? If your product solves a similar problem to other search results, that's a problem: Users may gravitate to an existing product instead of a new one. - -Unless you're using a completely made-up word, you'll likely get a lot of hits. The trick is understanding which search results might be a problem. Again, put on the shoes of a new user to your project. If you were searching for this great new product and saw the other search results along with your project's homepage, would you confuse them? Are the other search results even software products? If your product solves a similar problem to other search results, that's a problem: Users may gravitate to an existing product instead of a new one. - -Similar non-software product names are rarely an issue unless they are famous trademarks—like Nike or Red Bull, for example—where the companies behind them won't look kindly on anyone using a similar name. Using the same name as a less famous non-software product might be OK, depending on how big your project gets. - -### How big do you plan to grow your project? - -Are you building a new node module or command-line utility, but not planning a career around it? Is your new project a million-dollar business idea, and you're thinking startup? Or is it something in between? - -If your project is a basic developer utility—something useful that developers will integrate into their workflow—then you have enough data to choose a name. Think through the ecosystem and how a new user would see your potential names, and pick one. You don't need perfection, just a name you're happy with that seems right for your project. - -If you're planning to build a business around your project, use these tips to develop a shortlist of names, but do more vetting before announcing the winner. Use for a business or major project requires some level of registered trademark search, which is usually performed by a law firm. - -### Common pitfalls - -Finally, when choosing a name, avoid these common pitfalls: - - * Using an esoteric acronym. If new users don't understand the name, they'll have a hard time finding you. - - * Using current pop-culture references. If you want your project's appeal to last, pick a name that will last. - - * Failing to consider non-English speakers. Does the name have a specific meaning in another language that might be confusing? - - * Using off-color jokes or potentially unsavory references. Even if it seems funny to developers, it may fall flat for newcomers and turn away contributors. - - - - -Good luck—and remember to take the time to step out of your shoes and consider how a newcomer to your project will think of the name. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/choosing-project-names-four-key-considerations - -作者:[Shane Curcuru][a] -译者:[译者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/shane-curcuru -[1]:https://www.npmjs.com/ -[2]:https://www.cpan.org/ -[3]:https://maven.apache.org/ -[4]:https://www.eclipse.org/ diff --git a/sources/talk/20180221 3 warning flags of DevOps metrics.md b/sources/talk/20180221 3 warning flags of DevOps metrics.md deleted file mode 100644 index a103a2bbca..0000000000 --- a/sources/talk/20180221 3 warning flags of DevOps metrics.md +++ /dev/null @@ -1,42 +0,0 @@ -3 warning flags of DevOps metrics -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_graph_stats_blue.png?itok=OKCc_60D) - -Metrics. Measurements. Data. Monitoring. Alerting. These are all big topics for DevOps and for cloud-native infrastructure and application development more broadly. In fact, acm Queue, a magazine published by the Association of Computing Machinery, recently devoted an [entire issue][1] to the topic. - -I've argued before that we conflate a lot of things under the "metrics" term, from key performance indicators to critical failure alerts to data that may be vaguely useful someday for something or other. But that's a topic for another day. What I want to discuss here is how metrics affect behavior. - -In 2008, Daniel Ariely published [Predictably Irrational][2] , one of a number of books written around that time that introduced behavioral psychology and behavioral economics to the general public. One memorable quote from that book is the following: "Human beings adjust behavior based on the metrics they're held against. Anything you measure will impel a person to optimize his score on that metric. What you measure is what you'll get. Period." - -This shouldn't be surprising. It's a finding that's been repeatedly confirmed by research. It should also be familiar to just about anyone with business experience. It's certainly not news to anyone in sales management, for example. Base sales reps' (or their managers'!) bonuses solely on revenue, and they'll discount whatever it takes to maximize revenue even if it puts margin in the toilet. Conversely, want the sales force to push a new product line—which will probably take extra effort—but skip the [spiffs][3]? Probably not happening. - -And lest you think I'm unfairly picking on sales, this behavior is pervasive, all the way up to the CEO, as Ariely describes in [a 2010 Harvard Business Review article][4]. "CEOs care about stock value because that's how we measure them. If we want to change what they care about, we should change what we measure," writes Ariely. - -Think developers and operations folks are immune from such behaviors? Think again. Let's consider some problematic measurements. They're not all bad or wrong but, if you rely too much on them, warning flags should go up. - -### Three warning signs for DevOps metrics - -First, there are the quantity metrics. Lines of code or bugs fixed are perhaps self-evidently absurd. But there are also the deployments per week or per month that are so widely quoted to illustrate DevOps velocity relative to more traditional development and deployment practices. Speed is good. It's one of the reasons you're probably doing DevOps—but don't reward people on it excessively relative to quality and other measures. - -Second, it's obvious that you want to reward individuals who do their work quickly and well. Yes. But. Whether it's your local pro sports team or some project team you've been on, you can probably name someone who was really a talent, but was just so toxic and such a distraction for everyone else that they were a net negative for the team. Moral: Don't provide incentives that solely encourage individual behaviors. You may also want to put in place programs, such as peer rewards, that explicitly value collaboration. [As Red Hat's Jen Krieger told me][5] in a podcast last year: "Having those automated pots of awards, or some sort of system that's tracked for that, can only help teams feel a little more cooperative with one another as in, 'Hey, we're all working together to get something done.'" - -The third red flag area is incentives that don't actually incent because neither the individual nor the team has a meaningful ability to influence the outcome. It's often a good thing when DevOps metrics connect to business goals and outcomes. For example, customer ticket volume relates to perceived shortcomings in applications and infrastructure. And it's also a reasonable proxy for overall customer satisfaction, which certainly should be of interest to the executive suite. The best reward systems to drive DevOps behaviors should be tied to specific individual and team actions as opposed to just company success generally. - -You've probably noticed a common theme. That theme is balance. Velocity is good but so is quality. Individual achievement is good but not when it damages the effectiveness of the team. The overall success of the business is certainly important, but the best reward systems also tie back to actions and behaviors within development and operations. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/three-warning-flags-devops-metrics - -作者:[Gordon Haff][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/ghaff -[1]:https://queue.acm.org/issuedetail.cfm?issue=3178368 -[2]:https://en.wikipedia.org/wiki/Predictably_Irrational -[3]:https://en.wikipedia.org/wiki/Spiff -[4]:https://hbr.org/2010/06/column-you-are-what-you-measure -[5]:http://bitmason.blogspot.com/2015/09/podcast-making-devops-succeed-with-red.html diff --git a/sources/talk/20180222 3 reasons to say -no- in DevOps.md b/sources/talk/20180222 3 reasons to say -no- in DevOps.md deleted file mode 100644 index 5f27fbaf47..0000000000 --- a/sources/talk/20180222 3 reasons to say -no- in DevOps.md +++ /dev/null @@ -1,105 +0,0 @@ -3 reasons to say 'no' in DevOps -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LIFE_DesirePath.png?itok=N_zLVWlK) - -DevOps, it has often been pointed out, is a culture that emphasizes mutual respect, cooperation, continual improvement, and aligning responsibility with authority. - -Instead of saying no, it may be helpful to take a hint from improv comedy and say, "Yes, and..." or "Yes, but...". This opens the request from the binary nature of "yes" and "no" toward having a nuanced discussion around priority, capacity, and responsibility. - -However, sometimes you have no choice but to give a hard "no." These should be rare and exceptional, but they will occur. - -### Protecting yourself - -Both Agile and DevOps have been touted as ways to improve value to the customer and business, ultimately leading to greater productivity. While reasonable people can understand that the improvements will take time to yield, and the improvements will result in higher quality of work being done, and a better quality of life for those performing it, I think we can all agree that not everyone is reasonable. The less understanding that a person has of the particulars of a given task, the more likely they are to expect that it is a combination of "simple" and "easy." - -"You told me that [Agile/DevOps] is supposed to be all about us getting more productivity. Since we're doing [Agile/DevOps] now, you can take care of my need, right?" - -Like "Agile," some people have tried to use "DevOps" as a stick to coerce people to do more work than they can handle. Whether the person confronting you with this question is asking in earnest or is being manipulative doesn't really matter. - -The biggest areas of concern for me have been **capacity** , **firefighting/maintenance** , **level of quality** , and **" future me."** Many of these ultimately tie back to capacity, but they relate to a long-term effort in different respects. - -#### Capacity - -Capacity is simple: You know what your workload is, and how much flex occurs due to the unexpected. Exceeding your capacity will not only cause undue stress, but it could decrease the quality of your work and can injure your reputation with regards to making commitments. - -There are several avenues of discussion that can happen from here. The simplest is "Your request is reasonable, but I don't have the capacity to work on it." This seldom ends the conversation, and a discussion will often run up the flagpole to clarify priorities or reassign work. - -#### Firefighting/maintenance - -It's possible that the thing that you're being asked for won't take long to do, but it will require maintenance that you'll be expected to perform, including keeping it alive and fulfilling requests for it on behalf of others. - -An example in my mind is the Jenkins server that you're asked to stand up for someone else, but somehow end up being the sole owner and caretaker of. Even if you're careful to scope your level of involvement early on, you might be saddled with responsibility that you did not agree to. Should the service become unavailable, for example, you might be the one who is called. You might be called on to help triage a build that is failing. This is additional firefighting and maintenance work that you did not sign up for and now must fend off. - -This needs to be addressed as soon and publicly as possible. I'm not saying that (again, for example) standing up a Jenkins instance is a "no," but rather a ["Yes, but"][1]—where all parties understand that they take on the long-term care, feeding, and use of the product. Make sure to include all your bosses in this conversation so they can have your back. - -#### Level of quality - -There may be times when you are presented with requirements that include a timeframe that is...problematic. Perhaps you could get a "minimum (cough) viable (cough) product" out in that time. But it wouldn't be resilient or in any way ready for production. It might impact your time and productivity. It could end up hurting your reputation. - -The resulting conversation can get into the weeds, with lots of horse-trading about time and features. Another approach is to ask "What is driving this deadline? Where did that timeframe come from?" Discussing the bigger picture might lead to a better option, or that the timeline doesn't depend on the original date. - -#### Future me - -Ultimately, we are trying to protect "future you." These are lessons learned from the many times that "past me" has knowingly left "current me" to clean up. Sometimes we joke that "that's a problem for 'future me,'" but don't forget that 'future you' will just be 'you' eventually. I've cursed "past me" as a jerk many times. Do your best to keep other people from making "past you" be a jerk to "future you." - -I recognize that I have a significant amount of privilege in this area, but if you are told that you cannot say "no" on behalf of your own welfare, you should consider whether you are respected enough to maintain your autonomy. - -### Protecting the user experience - -Everyone should be an advocate for the user. Regardless of whether that user is right next to you, someone down the hall, or someone you have never met and likely never will, you must care for the customer. - -Behavior that is actively hostile to the user—whether it's a poor user experience or something more insidious like quietly violating reasonable expectations of privacy—deserves a "no." A common example of this would be automatically including people into a service or feature, forcing them to explicitly opt-out. - -If a "no" is not welcome, it bears considering, or explicitly asking, what the company's relationship with its customers is, who the company thinks of as it's customers, and what it thinks of them. - -When bringing up your objections, be clear about what they are. Additionally, remember that your coworkers are people too, and make it clear that you are not attacking their character; you simply find the idea disagreeable. - -### Legal, ethical, and moral grounds - -There might be situations that don't feel right. A simple test is to ask: "If this were to become public, or come up in a lawsuit deposition, would it be a scandal?" - -#### Ethics and morals - -If you are asked to lie, that should be a hard no. - -Remember if you will the Volkswagen Emissions Scandal of 2017? The emissions systems software was written such that it recognized that the vehicle was operated in a manner consistent with an emissions test, and would run more efficiently than under normal driving conditions. - -I don't know what you do in your job, or what your office is like, but I have a hard time imagining the Individual Contributor software engineer coming up with that as a solution on their own. In fact, I imagine a comment along the lines of "the engine engineers can't make their product pass the tests, so I need to hack the performance so that it will!" - -When the Volkswagen scandal came public, Volkswagen officials blamed the engineers. I find it unlikely that it came from the mind and IDE of an individual software engineer. Rather, it's more likely indicates significant systemic problems within the company culture. - -If you are asked to lie, get the request in writing, citing that the circumstances are suspect. If you are so privileged, decide whether you may decline the request on the basis that it is fundamentally dishonest and hostile to the customer, and would break the public's trust. - -#### Legal - -I am not a lawyer. If your work should involve legal matters, including requests from law enforcement, involve your company's legal counsel or speak with a private lawyer. - -With that said, if you are asked to provide information for law enforcement, I believe that you are within your rights to see the documentation that justifies the request. There should be a signed warrant. You should be provided with a copy of it, or make a copy of it yourself. - -When in doubt, begin recording and request legal counsel. - -It has been well documented that especially in the early years of the U.S. Patriot Act, law enforcement placed so many requests of telecoms that they became standard work, and the paperwork started slipping. While tedious and potentially stressful, make sure that the legal requirements for disclosure are met. - -If for no other reason, we would not want the good work of law enforcement to be put at risk because key evidence was improperly acquired, making it inadmissible. - -### Wrapping up - -You are going to be your single biggest advocate. There may be times when you are asked to compromise for the greater good. However, you should feel that your dignity is preserved, your autonomy is respected, and that your morals remain intact. - -If you don't feel that this is the case, get it on record, doing your best to communicate it calmly and clearly. - -Nobody likes being declined, but if you don't have the ability to say no, there may be a bigger problem than your environment not being DevOps. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/3-reasons-say-no-devops - -作者:[H. "Waldo" Grunenwal][a] -译者:[译者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/gwaldo -[1]:http://gwaldo.blogspot.com/2015/12/fear-and-loathing-in-systems.html diff --git a/sources/talk/20180223 Plasma Mobile Could Give Life to a Mobile Linux Experience.md b/sources/talk/20180223 Plasma Mobile Could Give Life to a Mobile Linux Experience.md deleted file mode 100644 index 583714836e..0000000000 --- a/sources/talk/20180223 Plasma Mobile Could Give Life to a Mobile Linux Experience.md +++ /dev/null @@ -1,123 +0,0 @@ -Plasma Mobile Could Give Life to a Mobile Linux Experience -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/plasma-mobile_0.png?itok=uUIQFRcm) - -In the past few years, it’s become clear that, outside of powering Android, Linux on mobile devices has been a resounding failure. Canonical came close, even releasing devices running Ubuntu Touch. Unfortunately, the idea of [Scopes][1]was doomed before it touched down on its first piece of hardware and subsequently died a silent death. - -The next best hope for mobile Linux comes in the form of the [Samsung DeX][2] program. With DeX, users will be able to install an app (Linux On Galaxy—not available yet) on their Samsung devices, which would in turn allow them to run a full-blown Linux distribution. The caveat here is that you’ll be running both Android and Linux at the same time—which is not exactly an efficient use of resources. On top of that, most Linux distributions aren’t designed to run on such small form factors. The good news for DeX is that, when you run Linux on Galaxy and dock your Samsung device to DeX, that Linux OS will be running on your connected monitor—so form factor issues need not apply. - -Outside of those two options, a pure Linux on mobile experience doesn’t exist. Or does it? - -You may have heard of the [Purism Librem 5][3]. It’s a crowdfunded device that promises to finally bring a pure Linux experience to the mobile landscape. This device will be powered by a i.MX8 SoC chip, so it should run most any Linux operating system. - -Out of the box, the device will run an encrypted version of [PureOS][4]. However, last year Purism and KDE joined together to create a mobile version of the KDE desktop that could run on the Librem 5. Recently [ISOs were made available for a beta version of Plasma Mobile][5] and, judging from first glance, they’re onto something that makes perfect sense for a mobile Linux platform. I’ve booted up a live instance of Plasma Mobile to kick the tires a bit. - -What I saw seriously impressed me. Let’s take a look. - -### Testing platform - -Before you download the ISO and attempt to fire it up as a VirtualBox VM, you should know that it won’t work well. Because Plasma Mobile uses Wayland (and VirtualBox has yet to play well with that particular X replacement), you’ll find VirtualBox VM a less-than-ideal platform for the beta release. Also know that the Calamares installer doesn’t function well either. In fact, I have yet to get the OS installed on a non-mobile device. And since I don’t own a supported mobile device, I’ve had to run it as a live session on either a laptop or an [Antsle][6] antlet VM every time. - -### What makes Plasma Mobile special? - -This could be easily summed up by saying, Plasma Mobile got it all right. Instead of Canonical re-inventing a perfectly functioning wheel, the developers of KDE simply re-tooled the interface such that a full-functioning Linux distribution (complete with all the apps you’ve grown to love and depend upon) could work on a smaller platform. And they did a spectacular job. Even better, they’ve created an interface that any user of a mobile device could instantly feel familiar with. - -What you have with the Plasma Mobile interface (Figure 1) are the elements common to most Android home screens: - - * Quick Launchers - - * Notification Shade - - * App Drawer - - * Overview button (so you can go back to a previously used app, still running in memory) - - * Home button - - - - -![KDE mobile][8] - -Figure 1: The Plasma Mobile desktop interface. - -[Used with permission][9] - -Because KDE went this route with the UX, it means there’s zero learning curve. And because this is an actual Linux platform, it takes that user-friendly mobile interface and overlays it onto a system that allows for easy installation and usage of apps like: - - * GIMP - - * LibreOffice - - * Audacity - - * Clementine - - * Dropbox - - * And so much more - - - - -Unfortunately, without being able to install Plasma Mobile, you cannot really kick the tires too much, as the live user doesn’t have permission to install applications. However, once Plasma Mobile is fully installed, the Discover software center will allow you to install a host of applications (Figure 2). - - -![Discover center][11] - -Figure 2: The Discover software center on Plasma Mobile. - -[Used with permission][9] - -Swipe up (or scroll down—depending on what hardware you’re using) to reveal the app drawer, where you can launch all of your installed applications (Figure 3). - -![KDE mobile][13] - -Figure 3: The Plasma Mobile app drawer ready to launch applications. - -[Used with permission][9] - -Open up a terminal window and you can take care of standard Linux admin tasks, such as using SSH to log into a remote server. Using apt, you can install all of the developer tools you need to make Plasma Mobile a powerful development platform. - -We’re talking serious mobile power—either from a phone or a tablet. - -### A ways to go - -Clearly Plasma Mobile is still way too early in development for it to be of any use to the average user. And because most virtual machine technology doesn’t play well with Wayland, you’re likely to get too frustrated with the current ISO image to thoroughly try it out. However, even without being able to fully install the platform (or get full usage out of it), it’s obvious KDE and Purism are going to have the ideal platform that will put Linux into the hands of mobile users. - -If you want to test the waters of Plasma Mobile on an actual mobile device, a handy list of supported hardware can be found [here][14] (for PostmarketOS) or [here][15] (for Halium). If you happen to be lucky enough to have a device that also includes Wi-Fi support, you’ll find you get more out of testing the environment. - -If you do have a supported device, you’ll need to use either [PostmarketOS][16] (a touch-optimized, pre-configured Alpine Linux that can be installed on smartphones and other mobile devices) or [Halium][15] (an application that creates an minimal Android layer which allows a new interface to interact with the Android kernel). Using Halium further limits the number of supported devices, as it has only been built for select hardware. However, if you’re willing, you can build your own Halium images (documentation for this process is found [here][17]). If you want to give PostmarketOS a go, [here are the necessary build instructions][18]. - -Suffice it to say, Plasma Mobile isn’t nearly ready for mass market. If you’re a Linux enthusiast and want to give it a go, let either PostmarketOS or Halium help you get the operating system up and running on your device. Otherwise, your best bet is to wait it out and hope Purism and KDE succeed in bringing this oustanding mobile take on Linux to the masses. - -Learn more about Linux through the free ["Introduction to Linux" ][19]course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2018/2/plasma-mobile-could-give-life-mobile-linux-experience - -作者:[JACK WALLEN][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/jlwallen -[1]:https://launchpad.net/unity-scopes -[2]:http://www.samsung.com/global/galaxy/apps/samsung-dex/ -[3]:https://puri.sm/shop/librem-5/ -[4]:https://www.pureos.net/ -[5]:http://blog.bshah.in/2018/01/26/trying-out-plasma-mobile/ -[6]:https://antsle.com/ -[8]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kdemobile_1.jpg?itok=EK3_vFVP (KDE mobile) -[9]:https://www.linux.com/licenses/category/used-permission -[11]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kdemobile_2.jpg?itok=CiUQ-MnB (Discover center) -[13]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kdemobile_3.jpg?itok=i6V8fgK8 (KDE mobile) -[14]:http://blog.bshah.in/2018/02/02/trying-out-plasma-mobile-part-two/ -[15]:https://github.com/halium/projectmanagement/issues?q=is%3Aissue+is%3Aopen+label%3APorts -[16]:https://postmarketos.org/ -[17]:http://docs.halium.org/en/latest/ -[18]:https://wiki.postmarketos.org/wiki/Installation_guide -[19]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/sources/talk/20180223 Why culture is the most important issue in a DevOps transformation.md b/sources/talk/20180223 Why culture is the most important issue in a DevOps transformation.md deleted file mode 100644 index 8fe1b6f273..0000000000 --- a/sources/talk/20180223 Why culture is the most important issue in a DevOps transformation.md +++ /dev/null @@ -1,91 +0,0 @@ -Why culture is the most important issue in a DevOps transformation -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_community2.png?itok=1blC7-NY) - -You've been appointed the DevOps champion in your organisation: congratulations. So, what's the most important issue that you need to address? - -It's the technology—tools and the toolchain—right? Everybody knows that unless you get the right tools for the job, you're never going to make things work. You need integration with your existing stack (though whether you go with tight or loose integration will be an interesting question), a support plan (vendor, third party, or internal), and a bug-tracking system to go with your source code management system. And that's just the start. - -No! Don't be ridiculous: It's clearly the process that's most important. If the team doesn't agree on how stand-ups are run, who participates, the frequency and length of the meetings, and how many people are required for a quorum, then you'll never be able to institute a consistent, repeatable working pattern. - -In fact, although both the technology and the process are important, there's a third component that is equally important, but typically even harder to get right: culture. Yup, it's that touch-feely thing we techies tend to struggle with.1 - -### Culture - -I was visiting a midsized government institution a few months ago (not in the UK, as it happens), and we arrived a little early to meet the CEO and CTO. We were ushered into the CEO's office and waited for a while as the two of them finished participating in the daily stand-up. They apologised for being a minute or two late, but far from being offended, I was impressed. Here was an organisation where the culture of participation was clearly infused all the way up to the top. - -Not that culture can be imposed from the top—nor can you rely on it percolating up from the bottom3—but these two C-level execs were not only modelling the behaviour they expected from the rest of their team, but also seemed, from the brief discussion we had about the process afterwards, to be truly invested in it. If you can get management to buy into the process—and be seen buying in—you are at least likely to have problems with other groups finding plausible excuses to keep their distance and get away with it. - -So let's assume management believes you should give DevOps a go. Where do you start? - -Developers may well be your easiest target group. They are often keen to try new things and find ways to move things along faster, so they are often the group that can be expected to adopt new technologies and methodologies. DevOps arguably has been driven mainly by the development community. - -But you shouldn't assume all developers will be keen to embrace this change. For some, the way things have always been done—your Rick Parfitts of dev, if you will7—is fine. Finding ways to help them work efficiently in the new world is part of your job, not just theirs. If you have superstar developers who aren't happy with change, you risk alienating and losing them if you try to force them into your brave new world. What's worse, if they dig their heels in, you risk the adoption of your DevSecOps vision being compromised when they explain to their managers that things aren't going to change if it makes their lives more difficult and reduces their productivity. - -Maybe you're not going to be able to move all the systems and people to DevOps immediately. Maybe you're going to need to choose which apps start with and who will be your first DevOps champions. Maybe it's time to move slowly. - -### Not maybe: definitely - -No—I lied. You're definitely going to need to move slowly. Trying to change everything at once is a recipe for disaster. - -This goes for all elements of the change—which people to choose, which technologies to choose, which applications to choose, which user base to choose, which use cases to choose—bar one. For those elements, if you try to move everything in one go, you will fail. You'll fail for a number of reasons. You'll fail for reasons I can't imagine and, more importantly, for reasons you can't imagine. But some of the reasons will include: - - * People—most people—don't like change. - * Technologies don't like change (you can't just switch and expect everything to still work). - * Applications don't like change (things worked before, or at least failed in known ways). You want to change everything in one go? Well, they'll all fail in new and exciting9 ways. - * Users don't like change. - * Use cases don't like change. - - - -### The one exception - -You noticed I wrote "bar one" when discussing which elements you shouldn't choose to change all in one go? Well done. - -What's that exception? It's the initial team. When you choose your initial application to change and you're thinking about choosing the team to make that change, select the members carefully and select a complete set. This is important. If you choose just developers, just test folks, just security folks, just ops folks, or just management—if you leave out one functional group from your list—you won't have proved anything at all. Well, you might have proved to a small section of your community that it kind of works, but you'll have missed out on a trick. And that trick is: If you choose keen people from across your functional groups, it's much harder to fail. - -Say your first attempt goes brilliantly. How are you going to convince other people to replicate your success and adopt DevOps? Well, the company newsletter, of course. And that will convince how many people, exactly? Yes, that number.12 If, on the other hand, you have team members from across the functional parts or the organisation, when you succeed, they'll tell their colleagues and you'll get more buy-in next time. - -If it fails, if you've chosen your team wisely—if they're all enthusiastic and know that "fail often, fail fast" is good—they'll be ready to go again. - -Therefore, you need to choose enthusiasts from across your functional groups. They can work on the technologies and the process, and once that's working, it's the people who will create that cultural change. You can just sit back and enjoy. Until the next crisis, of course. - -1\. OK, you're right. It should be "with which we techies tend to struggle."2 - -2\. You thought I was going to qualify that bit about techies struggling with touchy-feely stuff, didn't you? Read it again: I put "tend to." That's the best you're getting. - -3\. Is percolating a bottom-up process? I don't drink coffee,4 so I wouldn't know. - -4\. Do people even use percolators to make coffee anymore? Feel free to let me know in the comments. I may pretend interest if you're lucky. - -5\. For U.S. readers (and some other countries, maybe?), please substitute "check" for "tick" here.6 - -6\. For U.S. techie readers, feel free to perform `s/tick/check/;`. - -7\. This is a Status Quo8 reference for which I'm extremely sorry. - -8\. For millennial readers, please consult your favourite online reference engine or just roll your eyes and move on. - -9\. For people who say, "but I love excitement," try being on call at 2 a.m. on a Sunday at the end of the quarter when your chief financial officer calls you up to ask why all of last month's sales figures have been corrupted with the letters "DEADBEEF."10 - -10\. For people not in the know, this is a string often used by techies as test data because a) it's non-numerical; b) it's numerical (in hexadecimal); c) it's easy to search for in debug files; and d) it's funny.11 - -11\. Though see.9 - -12\. It's a low number, is all I'm saying. - -This article originally appeared on [Alice, Eve, and Bob – a security blog][1] and is republished with permission. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/most-important-issue-devops-transformation - -作者:[Mike Bursell][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/mikecamel -[1]:https://aliceevebob.com/2018/02/06/moving-to-devops-whats-most-important/ diff --git a/sources/talk/20180301 How to hire the right DevOps talent.md b/sources/talk/20180301 How to hire the right DevOps talent.md deleted file mode 100644 index bcf9bb3d20..0000000000 --- a/sources/talk/20180301 How to hire the right DevOps talent.md +++ /dev/null @@ -1,48 +0,0 @@ -How to hire the right DevOps talent -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/desk_clock_job_work.jpg?itok=Nj4fuhl6) - -DevOps culture is quickly gaining ground, and demand for top-notch DevOps talent is greater than ever at companies all over the world. With the [annual base salary for a junior DevOps engineer][1] now topping $100,000, IT professionals are hurrying to [make the transition into DevOps.][2] - -But how do you choose the right candidate to fill your DevOps role? - -### Overview - -Most teams are looking for candidates with a background in operations and infrastructure, software engineering, or development. This is in conjunction with skills that relate to configuration management, continuous integration, and deployment (CI/CD), as well as cloud infrastructure. Knowledge of container orchestration is also in high demand. - -In a perfect world, the two backgrounds would meet somewhere in the middle to form Dev and Ops, but in most cases, candidates lean toward one side or the other. Yet they must possess the skills necessary to understand the needs of their counterparts to work effectively as a team to achieve continuous delivery and deployment. Since every company is different, there is no single right or wrong since so much depends on a company’s tech stack and infrastructure, as well as the goals and the skills of other team members. So how do you focus your search? - -### Decide on the background - -Begin by assessing the strength of your current team. Do you have rock-star software engineers but lack infrastructure knowledge? Focus on closing the skill gaps. Just because you have the budget to hire a DevOps engineer doesn’t mean you should spend weeks, or even months, trying to find the best software engineer who also happens to use Kubernetes and Docker because they are currently the trend. Instead, look for someone who will provide the most value in your environment, and see how things go from there. - -### There is no “Ctrl + F” solution - -Instead of concentrating on specific tools, concentrate on a candidate's understanding of DevOps and CI/CD-related processes. You'll be better off with someone who understands methodologies over tools. It is more important to ensure that candidates comprehend the concept of CI/CD than to ask if they prefer Jenkins, Bamboo, or TeamCity. Don’t get too caught up in the exact toolchain—rather, focus on problem-solving skills and the ability to increase efficiency, save time, and automate manual processes. You don't want to miss out on the right candidate just because the word “Puppet” was not on their resume. - -### Check your ego - -As mentioned above, DevOps is a rapidly growing field, and DevOps engineers are in hot demand. That means candidates have great buying power. You may have an amazing company or product, but hiring top talent is no longer as simple as putting up a “Help Wanted” sign and waiting for top-quality applicants to rush in. I'm not suggesting that maintaining a reputation a great place to work is unimportant, but in today's environment, you need to make an effort to sell your position. Flaws or glitches in the hiring process, such as abruptly canceling interviews or not offering feedback after interviews, can lead to negative reviews spreading across the industry. Remember, it takes just a couple of minutes to leave a negative review on Glassdoor. - -### Contractor or permanent employee? - -Most recruiters and hiring managers immediately start searching for a full-time employee, even though they may have other options. If you’re looking to design, build, and implement a new DevOps environment, why not hire a senior person who has done this in the past? Consider hiring a senior contractor, along with a junior full-time hire. That way, you can tap the knowledge and experience of the contractor by having them work with the junior employee. Contractors can be expensive, but they bring invaluable knowledge—especially if the work can be done within a short timeframe. - -### Cultivate from within - -With so many companies competing for talent, it is difficult to find the right DevOps engineer. Not only will you need to pay top dollar to hire this person, but you must also consider that the search can take several months. However, since few companies are lucky enough to find the ideal DevOps engineer, consider searching for a candidate internally. You might be surprised at the talent you can cultivate from within your own organization. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/how-hire-right-des-talentvop - -作者:[Stanislav Ivaschenko][a] -译者:[译者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/ilyadudkin -[1]:https://www.glassdoor.com/Salaries/junior-devops-engineer-salary-SRCH_KO0,22.htm -[2]:https://squadex.com/insights/system-administrator-making-leap-devops/ diff --git a/sources/talk/20180302 Beyond metrics- How to operate as team on today-s open source project.md b/sources/talk/20180302 Beyond metrics- How to operate as team on today-s open source project.md deleted file mode 100644 index fb5454bbe4..0000000000 --- a/sources/talk/20180302 Beyond metrics- How to operate as team on today-s open source project.md +++ /dev/null @@ -1,53 +0,0 @@ -Beyond metrics: How to operate as team on today's open source project -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/diversity-women-meeting-team.png?itok=BdDKxT1w) - -How do we traditionally think about community health and vibrancy? - -We might quickly zero in on metrics related primarily to code contributions: How many companies are contributing? How many individuals? How many lines of code? Collectively, these speak to both the level of development activity and the breadth of the contributor base. The former speaks to whether the project continues to be enhanced and expanded; the latter to whether it has attracted a diverse group of developers or is controlled primarily by a single organization. - -The [Linux Kernel Development Report][1] tracks these kinds of statistics and, unsurprisingly, it appears extremely healthy on all counts. - -However, while development cadence and code contributions are still clearly important, other aspects of the open source communities are also coming to the forefront. This is in part because, increasingly, open source is about more than a development model. It’s also about making it easier for users and other interested parties to interact in ways that go beyond being passive recipients of code. Of course, there have long been user groups. But open source streamlines the involvement of users, just as it does software development. - -This was the topic of my discussion with Diane Mueller, the director of community development for OpenShift. - -When OpenShift became a container platform based in part on Kubernetes in version 3, Mueller saw a need to broaden the community beyond the core code contributors. In part, this was because OpenShift was increasingly touching a broad range of open source projects and organizations such those associated with the [Open Container Initiative (OCI)][2] and the [Cloud Native Computing Foundation (CNCF)][3]. In addition to users, cloud service providers who were offering managed services also wanted ways to get involved in the project. - -“What we tried to do was open up our minds about what the community constituted,” Mueller explained, adding, “We called it the [Commons][4] because Red Hat's near Boston, and I'm from that area. Boston Common is a shared resource, the grass where you bring your cows to graze, and you have your farmer's hipster market or whatever it is today that they do on Boston Common.” - -This new model, she said, was really “a new ecosystem that incorporated all of those different parties and different perspectives. We used a lot of virtual tools, a lot of new tools like Slack. We stepped up beyond the mailing list. We do weekly briefings. We went very virtual because, one, I don't scale. The Evangelist and Dev Advocate team didn't scale. We need to be able to get all that word out there, all this new information out there, so we went very virtual. We worked with a lot of people to create online learning stuff, a lot of really good tooling, and we had a lot of community help and support in doing that.” - -![diane mueller open shift][6] - -Diane Mueller, director of community development at Open Shift, discusses the role of strong user communities in open source software development. (Credit: Gordon Haff, CC BY-SA 4.0) - -However, one interesting aspect of the Commons model is that it isn’t just virtual. We see the same pattern elsewhere in many successful open source communities, such as the Linux kernel. Lots of day-to-day activities happen on mailings lists, IRC, and other collaboration tools. But this doesn’t eliminate the benefits of face-to-face time that allows for both richer and informal discussions and exchanges. - -This interview with Mueller took place in London the day after the [OpenShift Commons Gathering][7]. Gatherings are full-day events, held a number of times a year, which are typically attended by a few hundred people. Much of the focus is on users and user stories. In fact, Mueller notes, “Here in London, one of the Commons members, Secnix, was really the major reason we actually hosted the gathering here. Justin Cook did an amazing job organizing the venue and helping us pull this whole thing together in less than 50 days. A lot of the community gatherings and things are driven by the Commons members.” - -Mueller wants to focus on users more and more. “The OpenShift Commons gathering at [Red Hat] Summit will be almost entirely case studies,” she noted. “Users talking about what's in their stack. What lessons did they learn? What are the best practices? Sharing those ideas that they've done just like we did here in London.” - -Although the Commons model grew out of some specific OpenShift needs at the time it was created, Mueller believes it’s an approach that can be applied more broadly. “I think if you abstract what we've done, you can apply it to any existing open source community,” she said. “The foundations still, in some ways, play a nice role in giving you some structure around governance, and helping incubate stuff, and helping create standards. I really love what OCI is doing to create standards around containers. There's still a role for that in some ways. I think the lesson that we can learn from the experience and we can apply to other projects is to open up the community so that it includes feedback mechanisms and gives the podium away.” - -The evolution of the community model though approaches like the OpenShift Commons mirror the healthy evolution of open source more broadly. Certainly, some users have been involved in the development of open source software for a long time. What’s striking today is how widespread and pervasive direct user participation has become. Sure, open source remains central to much of modern software development. But it’s also becoming increasingly central to how users learn from each other and work together with their partners and developers. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/how-communities-are-evolving - -作者:[Gordon Haff][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/ghaff -[1]:https://www.linuxfoundation.org/2017-linux-kernel-report-landing-page/ -[2]:https://www.opencontainers.org/ -[3]:https://www.cncf.io/ -[4]:https://commons.openshift.org/ -[5]:/file/388586 -[6]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/39369010275_7df2c3c260_z.jpg?itok=gIhnBl6F (diane mueller open shift) -[7]:https://www.meetup.com/London-OpenShift-User-Group/events/246498196/ diff --git a/sources/talk/20180303 4 meetup ideas- Make your data open.md b/sources/talk/20180303 4 meetup ideas- Make your data open.md deleted file mode 100644 index a431b8376a..0000000000 --- a/sources/talk/20180303 4 meetup ideas- Make your data open.md +++ /dev/null @@ -1,75 +0,0 @@ -4 meetup ideas: Make your data open -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/people_team_community_group.png?itok=Nc_lTsUK) - -[Open Data Day][1] (ODD) is an annual, worldwide celebration of open data and an opportunity to show the importance of open data in improving our communities. - -Not many individuals and organizations know about the meaningfulness of open data or why they might want to liberate their data from the restrictions of copyright, patents, and more. They also don't know how to make their data open—that is, publicly available for anyone to use, share, or republish with modifications. - -This year ODD falls on Saturday, March 3, and there are [events planned][2] in every continent except Antarctica. While it might be too late to organize an event for this year, it's never too early to plan for next year. Also, since open data is important every day of the year, there's no reason to wait until ODD 2019 to host an event in your community. - -There are many ways to build local awareness of open data. Here are four ideas to help plan an excellent open data event any time of year. - -### 1. Organize an entry-level event - -You can host an educational event at a local library, college, or another public venue about how open data can be used and why it matters for all of us. If possible, invite a [local speaker][3] or have someone present remotely. You could also have a roundtable discussion with several knowledgeable people in your community. - -Consider offering resources such as the [Open Data Handbook][4], which not only provides a guide to the philosophy and rationale behind adopting open data, but also offers case studies, use cases, how-to guides, and other material to support making data open. - -### 2. Organize an advanced-level event - -For a deeper experience, organize a hands-on training event for open data newbies. Ideas for good topics include [training teachers on open science][5], [creating audiovisual expressions from open data][6], and using [open government data][7] in meaningful ways. - -The options are endless. To choose a topic, think about what is locally relevant, identify issues that open data might be able to address, and find people who can do the training. - -### 3. Organize a hackathon - -Open data hackathons can be a great way to bring open data advocates, developers, and enthusiasts together under one roof. Hackathons are more than just training sessions, though; the idea is to build prototypes or solve real-life challenges that are tied to open data. In a hackathon, people in various groups can contribute to the entire assembly line in multiple ways, such as identifying issues by working collaboratively through [Etherpad][8] or creating focus groups. - -Once the hackathon is over, make sure to upload all the useful data that is produced to the internet with an open license. - -### 4. Release or relicense data as open - -Open data is about making meaningful data publicly available under open licenses while protecting any data that might put people's private information at risk. (Learn [how to protect private data][9].) Try to find existing, interesting, and useful data that is privately owned by individuals or organizations and negotiate with them to relicense or release the data online under any of the [recommended open data licenses][10]. The widely popular [Creative Commons licenses][11] (particularly the CC0 license and the 4.0 licenses) are quite compatible with relicensing public data. (See this FAQ from Creative Commons for more information on [openly licensing data][12].) - -Open data can be published on multiple platforms—your website, [GitHub][13], [GitLab][14], [DataHub.io][15], or anywhere else that supports open standards. - -### Tips for event success - -No matter what type of event you decide to do, here are some general planning tips to improve your chances of success. - - * Find a venue that's accessible to the people you want to reach, such as a library, a school, or a community center. - * Create a curriculum that will engage the participants. - * Invite your target audience—make sure to distribute information through social media, community events calendars, Meetup, and the like. - - - -Have you attended or hosted a successful open data event? If so, please share your ideas in the comments. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/celebrate-open-data-day - -作者:[Subhashish Panigraphi][a] -译者:[译者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/psubhashish -[1]:http://www.opendataday.org/ -[2]:http://opendataday.org/#map -[3]:https://openspeakers.org/ -[4]:http://opendatahandbook.org/ -[5]:https://docs.google.com/forms/d/1BRsyzlbn8KEMP8OkvjyttGgIKuTSgETZW9NHRtCbT1s/viewform?edit_requested=true -[6]:http://dattack.lv/en/ -[7]:https://www.eventbrite.co.nz/e/open-data-open-potential-event-friday-2-march-2018-tickets-42733708673 -[8]:http://etherpad.org/ -[9]:https://ssd.eff.org/en/module/keeping-your-data-safe -[10]:https://opendatacommons.org/licenses/ -[11]:https://creativecommons.org/share-your-work/licensing-types-examples/ -[12]:https://wiki.creativecommons.org/wiki/Data#Frequently_asked_questions_about_data_and_CC_licenses -[13]:https://github.com/MartinBriza/MediaWriter -[14]:https://about.gitlab.com/ -[15]:https://datahub.io/ diff --git a/sources/talk/20180314 How to apply systems thinking in DevOps.md b/sources/talk/20180314 How to apply systems thinking in DevOps.md deleted file mode 100644 index c35eb041bd..0000000000 --- a/sources/talk/20180314 How to apply systems thinking in DevOps.md +++ /dev/null @@ -1,89 +0,0 @@ -How to apply systems thinking in DevOps -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/idea_innovation_kid_education.png?itok=3lRp6gFa) -For most organizations, adopting DevOps requires a mindset shift. Unless you understand the core of [DevOps][1], you might think it's hype or just another buzzword—or worse, you might believe you have already adopted DevOps because you are using the right tools. - -Let’s dig deeper into what DevOps means, and explore how to apply systems thinking in your organization. - -### What is systems thinking? - -Systems thinking is a holistic approach to problem-solving. It's the opposite of analytical thinking, which separates a problem from the "bigger picture" to better understand it. Instead, systems thinking studies all the elements of a problem, along with the interactions between these elements. - -Most people are not used to thinking this way. Since childhood, most of us were taught math, science, and every other subject separately, by different teachers. This approach to learning follows us throughout our lives, from school to university to the workplace. When we first join an organization, we typically work in only one department. - -Unfortunately, the world is not that simple. Complexity, unpredictability, and sometimes chaos are unavoidable and require a broader way of thinking. Systems thinking helps us understand the systems we are part of, which in turn enables us to manage them rather than be controlled by them. - -According to systems thinking, everything is a system: your body, your family, your neighborhood, your city, your company, and even the communities you belong to. These systems evolve organically; they are alive and fluid. The better you understand a system's behavior, the better you can manage and leverage it. You become their change agent and are accountable for them. - -### Systems thinking and DevOps - -All systems include properties that DevOps addresses through its practices and tools. Awareness of these properties helps us properly adapt to DevOps. Let's look at the properties of a system and how DevOps relates to each one. - -### How systems work - -The figure below represents a system. To reach a goal, the system requires input, which is processed and generates output. Feedback is essential for moving the system toward the goal. Without a purpose, the system dies. - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/system.png?itok=UlqAf39I) - -If an organization is a system, its departments are subsystems. The flow of work moves through each department, starting with identifying a market need (the first input on the left) and moving toward releasing a solution that meets that need (the last output on the right). The output that each department generates serves as required input for the next department in the chain. - -The more specialized teams an organization has, the more handoffs happen between departments. The process of generating value to clients is more likely to create bottlenecks and thus it takes longer to deliver value. Also, when work is passed between teams, the gap between the goal and what has been done widens. - -DevOps aims to optimize the flow of work throughout the organization to deliver value to clients faster—in other words, DevOps reduces time to market. This is done in part by maximizing automation, but mainly by targeting the organization's goals. This empowers prioritization and reduces duplicated work and other inefficiencies that happen during the delivery process. - -### System deterioration - -All systems are affected by entropy. Nothing can prevent system degradation; that's irreversible. The tendency to decline shows the failure nature of systems. Moreover, systems are subject to threats of all types, and failure is a matter of time. - -To mitigate entropy, systems require constant maintenance and improvements. The effects of entropy can be delayed only when new actions are taken or input is changed. - -This pattern of deterioration and its opposite force, survival, can be observed in living organisms, social relationships, and other systems as well as in organizations. In fact, if an organization is not evolving, entropy is guaranteed to be increasing. - -DevOps attempts to break the entropy process within an organization by fostering continuous learning and improvement. With DevOps, the organization becomes fault-tolerant because it recognizes the inevitability of failure. DevOps enables a blameless culture that offers the opportunity to learn from failure. The [postmortem][2] is an example of a DevOps practice used by organizations that embrace inherent failure. - -The idea of intentionally embracing failure may sound counterintuitive, but that's exactly what happens in techniques like [Chaos Monkey][3]: Failure is intentionally introduced to improve availability and reliability in the system. DevOps suggests that putting some pressure into the system in a controlled way is not a bad thing. Like a muscle that gets stronger with exercise, the system benefits from the challenge. - -### System complexity - -The figure below shows how complex the systems can be. In most cases, one effect can have multiple causes, and one cause can generate multiple effects. The more elements and interactions a system has, the more complex the system. - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/system-complexity.png?itok=GYZS00Lm) - -In this scenario, we can't immediately identify the reason for a particular event. Likewise, we can't predict with 100% certainty what will happen if a specific action is taken. We are constantly making assumptions and dealing with hypotheses. - -System complexity can be explained using the scientific method. In a recent study, for example, mice that were fed excess salt showed suppressed cerebral blood flow. This same experiment would have had different results if, say, the mice were fed sugar and salt. One variable can radically change results in complex systems. - -DevOps handles complexity by encouraging experimentation—for example, using the scientific method—and reducing feedback cycles. Smaller changes inserted into the system can be tested and validated more quickly. With a "[fail-fast][4]" approach, organizations can pivot quickly and achieve resiliency. Reacting rapidly to changes makes organizations more adaptable. - -DevOps also aims to minimize guesswork and maximize understanding by making the process of delivering value more tangible. By measuring processes, revealing flaws and advantages, and monitoring as much as possible, DevOps helps organizations discover the changes they need to make. - -### System limitations - -All systems have constraints that limit their performance; a system's overall capacity is delimited by its restrictions. Most of us have learned from experience that systems operating too long at full capacity can crash, and most systems work better when they function with some slack. Ignoring limitations puts systems at risk. For example, when we are under too much stress for a long time, we get sick. Similarly, overused vehicle engines can be damaged. - -This principle also applies to organizations. Unfortunately, organizations can't put everything into a system at once. Although this limitation may sometimes lead to frustration, the quality of work usually improves when input is reduced. - -Consider what happened when the speed limit on the main roads in São Paulo, Brazil was reduced from 90 km/h to 70 km/h. Studies showed that the number of accidents decreased by 38.5% and the average speed increased by 8.7%. In other words, the entire road system improved and more vehicles arrived safely at their destinations. - -For organizations, DevOps suggests global rather than local improvements. It doesn't matter if some improvement is put after a constraint because there's no effect on the system at all. One constraint that DevOps addresses, for instance, is dependency on specialized teams. DevOps brings to organizations a more collaborative culture, knowledge sharing, and cross-functional teams. - -### Conclusion - -Before adopting DevOps, understand what is involved and how you want to apply it to your organization. Systems thinking will help you accomplish that while also opening your mind to new possibilities. DevOps may be seen as a popular trend today, but in 10 or 20 years, it will be status quo. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/how-apply-systems-thinking-devops - -作者:[Gustavo Muniz do Carmo][a] -译者:[译者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/gustavomcarmo -[1]:https://opensource.com/tags/devops -[2]:https://landing.google.com/sre/book/chapters/postmortem-culture.html -[3]:https://medium.com/netflix-techblog/the-netflix-simian-army-16e57fbab116 -[4]:https://en.wikipedia.org/wiki/Fail-fast diff --git a/sources/talk/20180315 6 ways a thriving community will help your project succeed.md b/sources/talk/20180315 6 ways a thriving community will help your project succeed.md deleted file mode 100644 index cf15b7f06f..0000000000 --- a/sources/talk/20180315 6 ways a thriving community will help your project succeed.md +++ /dev/null @@ -1,111 +0,0 @@ -6 ways a thriving community will help your project succeed -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/open_community_lead.jpg?itok=F9KKLI7x) -NethServer is an open source product that my company, [Nethesis][1], launched just a few years ago. [The product][2] wouldn't be [what it is today][3] without the vibrant community that surrounds and supports it. - -In my previous article, I [discussed what organizations should expect to give][4] if they want to experience the benefits of thriving communities. In this article, I'll describe what organizations should expect to receive in return for their investments in the passionate people that make up their communities. - -Let's review six benefits. - -### 1\. Innovation - -"Open innovation" occurs when a company sharing information also listens to the feedback and suggestions from outside the company. As a company, we don't just look at the crowd for ideas. We innovate in, with, and through communities. - -You may know that "[the best way to have a good idea is to have a lot of ideas][5]." You can't always expect to have the right idea on your own, so having different point of views on your product is essential. How many truly disruptive ideas can a small company (like Nethesis) create? We're all young, caucasian, and European—while in our community, we can pick up a set of inspirations from a variety of people, with different genders, backgrounds, skills, and ethnicities. - -So the ability to invite the entire world to continuously improve the product is now no longer a dream; it's happening before our eyes. Your community could be the idea factory for innovation. With the community, you can really leverage the power of the collective. - -No matter who you are, most of the smartest people work for someone else. And community is the way to reach those smart people and work with them. - -### 2\. Research - -A community can be your strongest source of valuable product research. - -First, it can help you avoid "ivory tower development." [As Stack Exchange co-founder Jeff Atwood has said][6], creating an environment where developers have no idea who the users are is dangerous. Isolated developers, who have worked for years in their high towers, often encounter bad results because they don't have any clue about how users actually use their software. Developing in an Ivory tower keeps you away from your users and can only lead to bad decisions. A community brings developers back to reality and helps them stay grounded. Gone are the days of developers working in isolation with limited resources. In this day and age, thanks to the advent of open source communities research department is opening up to the entire world. - -No matter who you are, most of the smartest people work for someone else. And community is the way to reach those smart people and work with them. - -Second, a community can be an obvious source of product feedback—always necessary as you're researching potential paths forward. If someone gives you feedback, it means that person cares about you. It's a big gift. The community is a good place to acquire such invaluable feedback. Receiving early feedback is super important, because it reduces the cost of developing something that doesn't work in your target market. You can safely fail early, fail fast, and fail often. - -And third, communities help you generate comparisons with other projects. You can't know all the features, pros, and cons of your competitors' offerings. [The community, however, can.][7] Ask your community. - -### 3\. Perspective - -Communities enable companies to look at themselves and their products [from the outside][8], letting them catch strengths and weaknesses, and mostly realize who their products' audiences really are. - -Let me offer an example. When we launched the NethServer, we chose a catchy tagline for it. We were all convinced the following sentence was perfect: - -> [NethServer][9] is an operating system for Linux enthusiasts, designed for small offices and medium enterprises. - -Two years have passed since then. And we've learned that sentence was an epic fail. - -We failed to realize who our audience was. Now we know: NethServer is not just for Linux enthusiasts; actually, Windows users are the majority. It's not just for small offices and medium enterprises; actually, several home users install NethServer for personal use. Our community helps us to fully understand our product and look at it from our users' eyes. - -### 4\. Development - -In open source communities especially, communities can be a welcome source of product development. - -They can, first of all, provide testing and bug reporting. In fact, if I ask my developers about the most important community benefit, they'd answer "testing and bug reporting." Definitely. But because your code is freely available to the whole world, practically anyone with a good working knowledge of it (even hobbyists and other companies) has the opportunity to play with it, tweak it, and constantly improve it (even develop additional modules, as in our case). People can do more than just report bugs; they can fix those bugs, too, if they have the time and knowledge. - -But the community doesn't just create code. It can also generate resources like [how-to guides,][10] FAQs, support documents, and case studies. How much would it cost to fully translate your product in seven different languages? At NethServer, we got that for free—thanks to our community members. - -### 5\. Marketing - -Communities can help your company go global. Our small Italian company, for example, wasn't prepared for a global market. The community got us prepared. For example, we needed to study and improve our English so we could read and write correctly or speak in public without looking foolish for an audience. The community gently forced us to organize [our first NethServer Conference][11], too—only in English. - -A strong community can also help your organization attain the holy grail of marketers everywhere: word of mouth marketing (or what Seth Godin calls "[tribal marketing][12]"). - -Communities ensure that your company's messaging travels not only from company to tribe but also "sideways," from tribe member to potential tribe member. The community will become your street team, spreading word of your organization and its projects to anyone who will listen. - -In addition, communities help organizations satisfy one of the most fundamental members needs: the desire to belong, to be involved in something bigger than themselves, and to change the world together. - -Never forget that working with communities is always a matter of giving and taking—striking a delicate balance between the company and the community. - -### 6\. Loyalty - -Attracting new users costs a business five times as much as keeping an existing one. So loyalty can have a huge impact on your bottom line. Quite simply, community helps us build brand loyalty. It's much more difficult to leave a group of people you're connected to than a faceless product or company. In a community, you're building connections with people, which is way more powerful than features or money (trust me!). - -### Conclusion - -Never forget that working with communities is always a matter of giving and taking—striking a delicate balance between the company and the community. - -And I wouldn't be honest with you if I didn't admit that the approach has some drawbacks. Doing everything in the open means moderating, evaluating, and processing of all the data you're receiving. Supporting your members and leading the discussions definitely takes time and resources. But, if you look at what a community enables, you'll see that all this is totally worth the effort. - -As my friend and mentor [David Spinks keeps saying over and over again][13], "Companies fail their communities when when they treat community as a tactic instead of making it a core part of their business philosophy." And [as I've said][4]: Communities aren't simply extensions of your marketing teams; "community" isn't an efficient short-term strategy. When community is a core part of your business philosophy, it can do so much more than give you short-term returns. - -At Nethesis we experience that every single day. As a small company, we could never have achieved the results we have without our community. Never. - -Community can completely set your business apart from every other company in the field. It can redefine markets. It can inspire millions of people, give them a sense of belonging, and make them feel an incredible bond with your company. - -And it can make you a whole lot of money. - -Community-driven companies will always win. Remember that. - -[Subscribe to our weekly newsletter][14] to learn more about open organizations. - --------------------------------------------------------------------------------- - -via: https://opensource.com/open-organization/18/3/why-build-community-3 - -作者:[Alessio Fattorini][a] -译者:[译者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/alefattorini -[1]:http://www.nethesis.it/ -[2]:https://www.nethserver.org/ -[3]:https://distrowatch.com/table.php?distribution=nethserver -[4]:https://opensource.com/open-organization/18/2/why-build-community-2 -[5]:https://www.goodreads.com/author/quotes/52938.Linus_Pauling -[6]:https://blog.codinghorror.com/ivory-tower-development/ -[7]:https://community.nethserver.org/tags/comparison -[8]:https://community.nethserver.org/t/improve-our-communication/2569 -[9]:http://www.nethserver.org/ -[10]:https://community.nethserver.org/c/howto -[11]:https://community.nethserver.org/t/nethserver-conference-in-italy-sept-29-30-2017/6404 -[12]:https://www.ted.com/talks/seth_godin_on_the_tribes_we_lead -[13]:http://cmxhub.com/article/community-business-philosophy-tactic/ -[14]:https://opensource.com/open-organization/resources/newsletter diff --git a/sources/talk/20180315 Lessons Learned from Growing an Open Source Project Too Fast.md b/sources/talk/20180315 Lessons Learned from Growing an Open Source Project Too Fast.md deleted file mode 100644 index 6ae7cbea2c..0000000000 --- a/sources/talk/20180315 Lessons Learned from Growing an Open Source Project Too Fast.md +++ /dev/null @@ -1,40 +0,0 @@ -Lessons Learned from Growing an Open Source Project Too Fast -====== -![open source project][1] - -Are you managing an open source project or considering launching one? If so, it may come as a surprise that one of the challenges you can face is rapid growth. Matt Butcher, Principal Software Development Engineer at Microsoft, addressed this issue in a presentation at Open Source Summit North America. His talk covered everything from teamwork to the importance of knowing your goals and sticking to them. - -Butcher is no stranger to managing open source projects. As [Microsoft invests more deeply into open source][2], Butcher has been involved with many projects, including toolkits for Kubernetes and QueryPath, the jQuery-like library for PHP. - -Butcher described a case study involving Kubernetes Helm, a package system for Kubernetes. Helm arose from a company team-building hackathon, with an original team of three people giving birth to it. Within 18 months, the project had hundreds of contributors and thousands of active users. - -### Teamwork - -“We were stretched to our limits as we learned to grow,” Butcher said. “When you’re trying to set up your team of core maintainers and they’re all trying to work together, you want to spend some actual time trying to optimize for a process that lets you be cooperative. You have to adjust some expectations regarding how you treat each other. When you’re working as a group of open source collaborators, the relationship is not employer/employee necessarily. It’s a collaborative effort.” - -In addition to focusing on the right kinds of teamwork, Butcher and his collaborators learned that managing governance and standards is an ongoing challenge. “You want people to understand who makes decisions, how they make decisions and why they make the decisions that they make,” he said. “When we were a small project, there might have been two paragraphs in one of our documents on standards, but as a project grows and you get growing pains, these documented things gain a life of their own. They get their very own repositories, and they just keep getting bigger along with the project.” - -Should all discussion surrounding a open source project go on in public, bathed in the hot lights of community scrutiny? Not necessarily, Butcher noted. “A minor thing can get blown into catastrophic proportions in a short time because of misunderstandings and because something that should have been done in private ended up being public,” he said. “Sometimes we actually make architectural recommendations as a closed group. The reason we do this is that we don’t want to miscue the community. The people who are your core maintainers are core maintainers because they’re experts, right? These are the people that have been selected from the community because they understand the project. They understand what people are trying to do with it. They understand the frustrations and concerns of users.” - -### Acknowledge Contributions - -Butcher added that it is essential to acknowledge people’s contributions to keep the environment surrounding a fast-growing project from becoming toxic. “We actually have an internal rule in our core maintainers guide that says, ‘Make sure that at least one comment that you leave on a code review, if you’re asking for changes, is a positive one,” he said. “It sounds really juvenile, right? But it serves a specific purpose. It lets somebody know, ‘I acknowledge that you just made a gift of your time and your resources.” - -Want more tips on successfully launching and managing open source projects? Stay tuned for more insight from Matt Butcher’s talk, in which he provides specific project management issues faced by Kubernetes Helm. - -For more information, be sure to check out [The Linux Foundation’s growing list of Open Source Guides for the Enterprise][3], covering topics such as starting an open source project, improving your open source impact, and participating in open source communities. - --------------------------------------------------------------------------------- - -via: https://www.linuxfoundation.org/blog/lessons-learned-from-growing-an-open-source-project-too-fast/ - -作者:[Sam Dean][a] -译者:[译者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/author/sdean/ -[1]:https://www.linuxfoundation.org/wp-content/uploads/2018/03/huskies-2279627_1920.jpg -[2]:https://thenewstack.io/microsoft-shifting-emphasis-open-source/ -[3]:https://www.linuxfoundation.org/resources/open-source-guides/ diff --git a/sources/talk/20180316 How to avoid humiliating newcomers- A guide for advanced developers.md b/sources/talk/20180316 How to avoid humiliating newcomers- A guide for advanced developers.md deleted file mode 100644 index e433e85d5f..0000000000 --- a/sources/talk/20180316 How to avoid humiliating newcomers- A guide for advanced developers.md +++ /dev/null @@ -1,119 +0,0 @@ -How to avoid humiliating newcomers: A guide for advanced developers -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop-music-headphones.png?itok=EQZ2WKzy) -Every year in New York City, a few thousand young men come to town, dress up like Santa Claus, and do a pub crawl. One year during this SantaCon event, I was walking on the sidewalk and minding my own business, when I saw an extraordinary scene. There was a man dressed up in a red hat and red jacket, and he was talking to a homeless man who was sitting in a wheelchair. The homeless man asked Santa Claus, "Can you spare some change?" Santa dug into his pocket and brought out a $5 bill. He hesitated, then gave it to the homeless man. The homeless man put the bill in his pocket. - -In an instant, something went wrong. Santa yelled at the homeless man, "I gave you $5. I wanted to give you one dollar, but five is the smallest I had, so you oughtta be grateful. This is your lucky day, man. You should at least say thank you!" - -This was a terrible scene to witness. First, the power difference was terrible: Santa was an able-bodied white man with money and a home, and the other man was black, homeless, and using a wheelchair. It was also terrible because Santa Claus was dressed like the very symbol of generosity! And he was behaving like Santa until, in an instant, something went wrong and he became cruel. - -This is not merely a story about Drunk Santa, however; this is a story about technology communities. We, too, try to be generous when we answer new programmers' questions, and every day our generosity turns to rage. Why? - -### My cruelty - -I'm reminded of my own bad behavior in the past. I was hanging out on my company's Slack when a new colleague asked a question. - -> **New Colleague:** Hey, does anyone know how to do such-and-such with MongoDB? -> **Jesse:** That's going to be implemented in the next release. -> **New Colleague:** What's the ticket number for that feature? -> **Jesse:** I memorize all ticket numbers. It's #12345. -> **New Colleague:** Are you sure? I can't find ticket 12345. - -He had missed my sarcasm, and his mistake embarrassed him in front of his peers. I laughed to myself, and then I felt terrible. As one of the most senior programmers at MongoDB, I should not have been setting this example. And yet, such behavior is commonplace among programmers everywhere: We get sarcastic with newcomers, and we humiliate them. - -### Why does it matter? - -Perhaps you are not here to make friends; you are here to write code. If the code works, does it matter if we are nice to each other or not? - -A few months ago on the Stack Overflow blog, David Robinson showed that [Python has been growing dramatically][1], and it is now the top language that people view questions about on Stack Overflow. Even in the most pessimistic forecast, it will far outgrow the other languages this year. - -![Projections for programming language popularity][2] - -If you are a Python expert, then the line surging up and to the right is good news for you. It does not represent competition, but confirmation. As more new programmers learn Python, our expertise becomes ever more valuable, and we will see that reflected in our salaries, our job opportunities, and our job security. - -But there is a danger. There are soon to be more new Python programmers than ever before. To sustain this growth, we must welcome them, and we are not always a welcoming bunch. - -### The trouble with Stack Overflow - -I searched Stack Overflow for rude answers to beginners' questions, and they were not hard to find. - -![An abusive answer on StackOverflow][3] - -The message is plain: If you are asking a question this stupid, you are doomed. Get out. - -I immediately found another example of bad behavior: - -![Another abusive answer on Stack Overflow][4] - -Who has never been confused by Unicode in Python? Yet the message is clear: You do not belong here. Get out. - -Do you remember how it felt when you needed help and someone insulted you? It feels terrible. And it decimates the community. Some of our best experts leave every day because they see us treating each other this way. Maybe they still program Python, but they are no longer participating in conversations online. This cruelty drives away newcomers, too, particularly members of groups underrepresented in tech who might not be confident they belong. People who could have become the great Python programmers of the next generation, but if they ask a question and somebody is cruel to them, they leave. - -This is not in our interest. It hurts our community, and it makes our skills less valuable because we drive people out. So, why do we act against our own interests? - -### Why generosity turns to rage - -There are a few scenarios that really push my buttons. One is when I act generously but don't get the acknowledgment I expect. (I am not the only person with this resentment: This is probably why Drunk Santa snapped when he gave a $5 bill to a homeless man and did not receive any thanks.) - -Another is when answering requires more effort than I expect. An example is when my colleague asked a question on Slack and followed-up with, "What's the ticket number?" I had judged how long it would take to help him, and when he asked for more help, I lost my temper. - -These scenarios boil down to one problem: I have expectations for how things are going to go, and when those expectations are violated, I get angry. - -I've been studying Buddhism for years, so my understanding of this topic is based in Buddhism. I like to think that the Buddha discussed the problem of expectations in his first tech talk when, in his mid-30s, he experienced a breakthrough after years of meditation and convened a small conference to discuss his findings. He had not rented a venue, so he sat under a tree. The attendees were a handful of meditators the Buddha had met during his wanderings in northern India. The Buddha explained that he had discovered four truths: - - * First, that to be alive is to be dissatisfied—to want things to be better than they are now. - * Second, this dissatisfaction is caused by wants; specifically, by our expectation that if we acquire what we want and eliminate what we do not want, it will make us happy for a long time. This expectation is unrealistic: If I get a promotion or if I delete 10 emails, it is temporarily satisfying, but it does not make me happy over the long-term. We are dissatisfied because every material thing quickly disappoints us. - * The third truth is that we can be liberated from this dissatisfaction by accepting our lives as they are. - * The fourth truth is that the way to transform ourselves is to understand our minds and to live a generous and ethical life. - - - -I still get angry at people on the internet. It happened to me recently, when someone posted a comment on [a video I published about Python co-routines][5]. It had taken me months of research and preparation to create this video, and then a newcomer commented, "I want to master python what should I do." - -![Comment on YouTube][6] - -This infuriated me. My first impulse was to be sarcastic, "For starters, maybe you could spell Python with a capital P and end a question with a question mark." Fortunately, I recognized my anger before I acted on it, and closed the tab instead. Sometimes liberation is just a Command+W away. - -### What to do about it - -If you joined a community with the intent to be helpful but on occasion find yourself flying into a rage, I have a method to prevent this. For me, it is the step when I ask myself, "Am I angry?" Knowing is most of the battle. Online, however, we can lose track of our emotions. It is well-established that one reason we are cruel on the internet is because, without seeing or hearing the other person, our natural empathy is not activated. But the other problem with the internet is that, when we use computers, we lose awareness of our bodies. I can be angry and type a sarcastic message without even knowing I am angry. I do not feel my heart pound and my neck grow tense. So, the most important step is to ask myself, "How do I feel?" - -If I am too angry to answer, I can usually walk away. As [Thumper learned in Bambi][7], "If you can't say something nice, don't say nothing at all." - -### The reward - -Helping a newcomer is its own reward, whether you receive thanks or not. But it does not hurt to treat yourself to a glass of whiskey or a chocolate, or just a sigh of satisfaction after your good deed. - -But besides our personal rewards, the payoff for the Python community is immense. We keep the line surging up and to the right. Python continues growing, and that makes our own skills more valuable. We welcome new members, people who might not be sure they belong with us, by reassuring them that there is no such thing as a stupid question. We use Python to create an inclusive and diverse community around writing code. And besides, it simply feels good to be part of a community where people treat each other with respect. It is the kind of community that I want to be a member of. - -### The three-breath vow - -There is one idea I hope you remember from this article: To control our behavior online, we must occasionally pause and notice our feelings. I invite you, if you so choose, to repeat the following vow out loud: - -> I vow -> to take three breaths -> before I answer a question online. - -This article is based on a talk, [Why Generosity Turns To Rage, and What To Do About It][8], that Jesse gave at PyTennessee in February. For more insight for Python developers, attend [PyCon 2018][9], May 9-17 in Cleveland, Ohio. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/avoid-humiliating-newcomers - -作者:[A. Jesse][a] -译者:[译者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/emptysquare -[1]:https://stackoverflow.blog/2017/09/06/incredible-growth-python/ -[2]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/projections.png?itok=5QTeJ4oe (Projections for programming language popularity) -[3]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/abusive-answer-1.jpg?itok=BIWW10Rl (An abusive answer on StackOverflow) -[4]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/abusive-answer-2.jpg?itok=0L-n7T-k (Another abusive answer on Stack Overflow) -[5]:https://www.youtube.com/watch?v=7sCu4gEjH5I -[6]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/i-want-to-master-python.png?itok=Y-2u1XwA (Comment on YouTube) -[7]:https://www.youtube.com/watch?v=nGt9jAkWie4 -[8]:https://www.pytennessee.org/schedule/presentation/175/ -[9]:https://us.pycon.org/2018/ diff --git a/sources/talk/20180320 Easily Fund Open Source Projects With These Platforms.md b/sources/talk/20180320 Easily Fund Open Source Projects With These Platforms.md deleted file mode 100644 index 8c02ca228b..0000000000 --- a/sources/talk/20180320 Easily Fund Open Source Projects With These Platforms.md +++ /dev/null @@ -1,96 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: subject: (Easily Fund Open Source Projects With These Platforms) -[#]: via: (https://itsfoss.com/open-source-funding-platforms/) -[#]: author: ([Ambarish Kumar](https://itsfoss.com/author/ambarish/)) -[#]: url: ( ) - -Easily Fund Open Source Projects With These Platforms -====== - -**Brief: We list out some funding platforms you can use to financially support open source projects. ** - -Financial support is one of the many ways to [help Linux and Open Source community][1]. This is why you see “Donate” option on the websites of most open source projects. - -While the big corporations have the necessary funding and resources, most open source projects are developed by individuals in their spare time. However, it does require one’s efforts, time and probably includes some overhead costs too. Monetary supports surely help drive the project development. - -If you would like to support open source projects financially, let me show you some platforms dedicated to open source and/or Linux. - -### Funding platforms for Open Source projects - -![Open Source funding platforms][2] - -Just to clarify, we are not associated with any of the funding platforms mentioned here. - -#### 1\. Liberapay - -[Gratipay][3] was probably the biggest platform for funding open source projects and people associated with the project, which got shut down at the end of the year 2017. However, there’s a fork – Liberapay that works as a recurrent donation platform for the open source projects and the contributors. - -[Liberapay][4] is a non-profit, open source organization that helps in a periodic donation to a project. You can create an account as a contributor and ask the people who would really like to help (usually the consumer of your products) to donate. - -To receive a donation, you will have to create an account on Liberapay, brief what you do and about your project, reasons for asking for the donation and what will be done with the money you receive. - -For someone who would like to donate, they would have to add money to their accounts and set up a period for payment that can be weekly, monthly or yearly to someone. There’s a mail triggered when there is not much left to donate. - -The currency supported are dollars and Euro as of now and you can always put up a badge on Github, your Twitter profile or website for a donation. - -#### 2\. Bountysource - -[Bountysource][5] is a funding platform for open source software that has a unique way of paying a developer for his time and work int he name of Bounties. - -There are basically two campaigns, bounties and salt campaign. - -Under the Bounties, users declare bounties aka cash prizes on open issues that they believe should be fixed or any new features which they want to see in the software they are using. A developer can then go and fix it to receive the cash prize. - -Salt Campaign is like any other funding, anyone can pay a recurring amount to a project or an individual working for an open source project for as long as they want. - -Bountysource accepts any software that is approved by Free Software Foundation or Open Source Initiatives. The bounties can be placed using PayPal, Bitcoin or the bounty itself if owned previously. Bountysource supports a no. of issue tracker currently like GitHub, Bugzilla, Google Code, Jira, Launchpad etc. - -#### 3\. Open Collective - -[Open Collective][6] is another popular funding initiative where a person who is willing to receive the donation for the work he is doing in Open Source world can create a page. He can submit the expense reports for the project he is working on. A contributor can add money to his account and pay him for his expenses. - -The complete process is transparent and everyone can track whoever is associated with Open Collective. The contributions are visible along with the unpaid expenses. There is also the option to contribute on a recurring basis. - -Open Collective currently has more than 500 collectives being backed up by more than 5000 users. - -The fact that it is transparent and you know what you are contributing to, drives more accountability. Some common example of collective include hosting costs, community maintenance, travel expenses etc. - -Though Open Collective keeps 10% of all the transactions, it is still a nice way to get your expenses covered in the process of contributing towards an open source project. - -#### 4\. Open Source Grants - -[Open Source Grants][7] is still in its beta stage and has not matured yet. They are looking for projects that do not have any stable funding and adds value to open source community. Most open source projects are run by a small community in a free time and they are trying to fund them so that the developers can work full time on the projects. - -They are equally searching for companies that want to help open source enthusiasts. The process of submitting a project is still being worked upon, and hopefully, in coming days we will see a working way of funding. - -### Final Words - -In the end, I would also like to mention [Patreon][8]. This funding platform is not exclusive to open source but is focused on creators of all kinds. Some projects like [elementary OS have created their accounts on Patreon][9] so that you can support the project on a recurring basis. - -Think Free Speech, not Free Beer. Your small contribution to a project can help it sustain in the long run. For the developers, the above platform can provide a good way to cover up their expenses. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/open-source-funding-platforms/ - -作者:[Ambarish Kumar][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/ambarish/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/help-linux-grow/ -[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/03/Fund-Open-Source-projects.png?resize=800%2C450&ssl=1 -[3]: https://itsfoss.com/gratipay-open-source/ -[4]: https://liberapay.com/ -[5]: https://www.bountysource.com/ -[6]: https://opencollective.com/ -[7]: https://foundation.travis-ci.org/grants/ -[8]: https://www.patreon.com/ -[9]: https://www.patreon.com/elementary diff --git a/sources/talk/20180321 8 tips for better agile retrospective meetings.md b/sources/talk/20180321 8 tips for better agile retrospective meetings.md deleted file mode 100644 index ec45bf17f0..0000000000 --- a/sources/talk/20180321 8 tips for better agile retrospective meetings.md +++ /dev/null @@ -1,66 +0,0 @@ -8 tips for better agile retrospective meetings -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_meeting.png?itok=4_CivQgp) -I’ve often thought that retrospectives should be called prospectives, as that term concerns the future rather than focusing on the past. The retro itself is truly future-looking: It’s the space where we can ask the question, “With what we know now, what’s the next experiment we need to try for improving our lives, and the lives of our customers?” - -### What’s a retro supposed to look like? - -There are two significant loops in product development: One produces the desired potentially shippable nugget. The other is where we examine how we’re working—not only to avoid doing what didn’t work so well, but also to determine how we can amplify the stuff we do well—and devise an experiment to pull into the next production loop to improve how our team is delighting our customers. This is the loop on the right side of this diagram: - - -![Retrospective 1][2] - -### When retros implode - -While attending various teams' iteration retrospective meetings, I saw a common thread of malcontent associated with a relentless focus on continuous improvement. - -One of the engineers put it bluntly: “[Our] continuous improvement feels like we are constantly failing.” - -The teams talked about what worked, restated the stuff that didn’t work (perhaps already feeling like they were constantly failing), nodded to one another, and gave long sighs. Then one of the engineers (already late for another meeting) finally summed up the meeting: “Ok, let’s try not to submit all of the code on the last day of the sprint.” There was no opportunity to amplify the good, as the good was not discussed. - -In effect, here’s what the retrospective felt like: - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/retro_2.jpg?itok=HrDkppCG) - -The anti-pattern is where retrospectives become dreaded sessions where we look back at the last iteration, make two columns—what worked and what didn’t work—and quickly come to some solution for the next iteration. There is no [scientific method][3] involved. There is no data gathering and research, no hypothesis, and very little deep thought. The result? You don’t get an experiment or a potential improvement to pull into the next iteration. - -### 8 tips for better retrospectives - - 1. Amplify the good! Instead of focusing on what didn’t work well, why not begin the retro by having everyone mention one positive item first? - 2. Don’t jump to a solution. Thinking about a problem deeply instead of trying to solve it right away might be a better option. - 3. If the retrospective doesn’t make you feel excited about an experiment, maybe you shouldn’t try it in the next iteration. - 4. If you’re not analyzing how to improve, ([5 Whys][4], [force-field analysis][5], [impact mapping][6], or [fish-boning][7]), you might be jumping to solutions too quickly. - 5. Vary your methods. If every time you do a retrospective you ask, “What worked, what didn’t work?” and then vote on the top item from either column, your team will quickly get bored. [Retromat][8] is a great free retrospective tool to help vary your methods. - 6. End each retrospective by asking for feedback on the retro itself. This might seem a bit meta, but it works: Continually improving the retrospective is recursively improving as a team. - 7. Remove the impediments. Ask how you are enabling the team's search for improvement, and be prepared to act on any feedback. - 8. There are no "iteration police." Take breaks as needed. Deriving hypotheses from analysis and coming up with experiments involves creativity, and it can be taxing. Every once in a while, go out as a team and enjoy a nice retrospective lunch. - - - -This article was inspired by [Retrospective anti-pattern: continuous improvement should not feel like constantly failing][9], posted at [Podojo.com][10]. - -**[See our related story,[How to build a business case for DevOps transformation][11].]** - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/tips-better-agile-retrospective-meetings - -作者:[Catherine Louis][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/catherinelouis -[1]:/file/389021 -[2]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/retro_1.jpg?itok=bggmHN1Q (Retrospective 1) -[3]:https://en.wikipedia.org/wiki/Scientific_method -[4]:https://en.wikipedia.org/wiki/5_Whys -[5]:https://en.wikipedia.org/wiki/Force-field_analysis -[6]:https://opensource.com/open-organization/17/6/experiment-impact-mapping -[7]:https://en.wikipedia.org/wiki/Ishikawa_diagram -[8]:https://plans-for-retrospectives.com/en/?id=28 -[9]:http://www.podojo.com/retrospective-anti-pattern-continuous-improvement-should-not-feel-like-constantly-failing/ -[10]:http://www.podojo.com/ -[11]:https://opensource.com/article/18/2/how-build-business-case-devops-transformation diff --git a/sources/talk/20180323 7 steps to DevOps hiring success.md b/sources/talk/20180323 7 steps to DevOps hiring success.md deleted file mode 100644 index cdea0c65ac..0000000000 --- a/sources/talk/20180323 7 steps to DevOps hiring success.md +++ /dev/null @@ -1,56 +0,0 @@ -7 steps to DevOps hiring success -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/desk_clock_job_work.jpg?itok=Nj4fuhl6) -As many of us in the DevOps scene know, most companies are hiring, or, at least, trying to do so. The required skills and job descriptions can change entirely from company to company. As a broad overview, most teams are looking for a candidate from either an operations and infrastructure background or someone from a software engineering and development background, then combined with key skills relating to continuous integration, configuration management, continuous delivery/deployment, and cloud infrastructure. Currently in high-demand is knowledge of container orchestration. - -In the ideal world, the two backgrounds will meet somewhere in the middle to form Dev and Ops, but in most cases, there is a lean toward one side or the other while maintaining sufficient skills to understand the needs and demands of their counterparts to work collaboratively and achieve the end goal of continuous delivery/deployment. Every company is different and there isn’t necessarily a right or wrong here. It all depends on your infrastructure, tech stack, other team members’ skills, and the individual goals you hope to achieve by hiring this individual. - -### Focus your hiring - -Now, given the various routes to becoming a DevOps practitioner, how do hiring managers focus their search and selection process to ensure that they’re hitting the mark? - -#### Decide on the background - -Assess the strengths of your existing team. Do you already have some amazing software engineers but you’re lacking the infrastructure knowledge? Aim to close these gaps in skills. You may have been given the budget to hire for DevOps, but you don’t have to spend weeks/months searching for the best software engineer who happens to use Docker and Kubernetes because they are the current hot trends in this space. Find the person who will provide the most value in your environment and go from there. - -#### Contractor or permanent employee? - -Many hiring managers will automatically start searching for a full-time permanent employee when their needs may suggest that they have other options. Sometimes a contractor is your best bet or maybe contract-hire. If you’re aiming to design, implement and build a new DevOps environment, why not find a senior person who has done this a number of times already? Try hiring a senior contractor and bring on a junior full-time hire in parallel; this way, you’ll be able to retain the external contractor knowledge by having them work alongside the junior hire. Contractors can be expensive, but the knowledge they bring can be invaluable, especially if the work can be completed over a shorter time frame. Again, this is just another point of view and you might be best off with a full-time hire to grow the team. - -#### CTRL F is not the solution - -Focus on their understanding of DevOps and CI/CD-related processes over specific tools. I believe the best approach is to focus on finding someone who understands the methodologies over the tools. Does your candidate understand the concept of continuous integration or the concept of continuous delivery? That’s more important than asking whether your candidate uses Jenkins versus Bamboo versus TeamCity and so on. Try not to get caught up in the exact tool chain. The focus should be on the candidates’ ability to solve problems. Are they obsessed with increasing efficiency, saving time, automating manual processes and constantly searching for flaws in the system? They might be the person you were looking for, but you missed them because you didn’t see the word "Puppet" on the resume. - -#### Work closely with your internal talent acquisition team and/or an external recruiter - -Be clear and precise with what you’re looking for and have an ongoing, open communication with recruiters. They can and will help you if used effectively. The job of these recruiters is to save you time by sourcing candidates while you’re focusing on your day-to-day role. Work closely with them and deliver in the same way that you would expect them to deliver for you. If you say you will review a candidate by X time, do it. If they say they’ll have a candidate in your inbox by Y time, make sure they do it, too. Start by setting up an initial call to talk through your requirement, lay out a timeline in which you expect candidates by a specific time, and explain your process in terms of when you will interview, how many interview rounds, and how soon after you will be able to make a final decision on whether to offer or reject the candidates. If you can get this relationship working well, you’ll save lots of time. And make sure your internal teams are focused on supporting your process, not blocking it. - -#### $$$ - -Decide how much you want to pay. It’s not all about the money, but you can waste a lot of your and other people’s time if you don’t lock down the ballpark salary or hourly rate that you can afford. If your budget doesn’t stretch as far as your competitors’, you need to consider what else can help sell the opportunity. Flexible working hours and remote working options are some great ways to do this. Most companies have snacks, beer, and cool offices nowadays, so focus on the real value such as the innovative work your team is doing and how awesome your game-changing product might be. - -#### Drop the ego - -You may have an amazing company and/or product, but you also have some hot competition. Everyone is hiring in this space and candidates have a lot of the buying power. It is no longer as simple as saying, "We are hiring" and the awesome candidates come flowing in. You need to sell your opportunities. Maintaining a reputation as a great place to work is also important. A poor hiring process, such as interviewing without giving feedback, can contribute to bad rumors being spread across the industry. It only takes a few minutes to leave a sour review on Glassdoor. - -#### A smooth process is a successful One - -"Let’s get every single person within the company to do a one-hour interview with the new DevOps person we are hiring!" No, let’s not do that. Two or three stages should be sufficient. You have managers and directors for a reason. Trust your instinct and use your experience to make decisions on who will fit into your organization. Some of the most successful companies can do one phone screen followed by an in-person meeting. During the in-person interview, spend a morning or afternoon allowing the candidate to meet the relevant leaders and senior members of their direct team, then take them for lunch, dinner, or drinks where you can see how they are on a social level. If you can’t have a simple conversation with them, then you probably won’t enjoy working with them. If the thumbs are up, make the hire and don’t wait around. A good candidate will usually have numerous offers on the table at the same time. - -If all goes well, you should be inviting your shiny new employee or contractor into the office in the next few weeks and hopefully many more throughout the year. - -This article was originally published on [DevOps.com][1] and republished with author permission. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/7-steps-devops-hiring-success - -作者:[Conor Delanbanque][a] -译者:[译者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/cdelanbanque -[1]:https://devops.com/7-steps-devops-hiring-success/ diff --git a/sources/talk/20180330 Meet OpenAuto, an Android Auto emulator for Raspberry Pi.md b/sources/talk/20180330 Meet OpenAuto, an Android Auto emulator for Raspberry Pi.md deleted file mode 100644 index bac0819e74..0000000000 --- a/sources/talk/20180330 Meet OpenAuto, an Android Auto emulator for Raspberry Pi.md +++ /dev/null @@ -1,81 +0,0 @@ -Meet OpenAuto, an Android Auto emulator for Raspberry Pi -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lightbulb_computer_person_general_.png?itok=BRGJXU7e) - -In 2015, Google introduced [Android Auto][1], a system that allows users to project certain apps from their Android smartphones onto a car's infotainment display. Android Auto's driver-friendly interface, with larger touchscreen buttons and voice commands, aims to make it easier and safer for drivers to control navigation, music, podcasts, radio, phone calls, and more while keeping their eyes on the road. Android Auto can also run as an app on an Android smartphone, enabling owners of older-model vehicles without modern head unit displays to take advantage of these features. - -While there are many [apps][2] available for Android Auto, developers are working to add to its catalog. A new, open source tool named [OpenAuto][3] is hoping to make that easier by giving developers a way to emulate Android Auto on a Raspberry Pi. With OpenAuto, developers can test their applications in conditions similar to how they'll work on an actual car head unit. - -OpenAuto's creator, Michal Szwaj, answered some questions about his project for Opensource.com. Some responses have been edited for conciseness and clarity. - -### What is OpenAuto? - -In a nutshell, OpenAuto is an emulator for the Android Auto head unit. It emulates the head unit software and allows you to use Android Auto on your PC or on any other embedded platform like Raspberry Pi 3. - -Head unit software is a frontend for the Android Auto projection. All magic related to the Android Auto, like navigation, Google Voice Assistant, or music playback, is done on the Android device. Projection of Android Auto on the head unit is accomplished using the [H.264][4] codec for video and [PCM][5] codec for audio streaming. This is what the head unit software mostly does—it decodes the H.264 video stream and PCM audio streams and plays them back together. Another function of the head unit is providing user inputs. OpenAuto supports both touch events and hard keys. - -### What platforms does OpenAuto run on? - -My target platform for deployment of the OpenAuto is Raspberry Pi 3 computer. For successful deployment, I needed to implement support of video hardware acceleration using the Raspberry Pi 3 GPU (VideoCore 4). Thanks to this, Android Auto projection on the Raspberry Pi 3 computer can be handled even using 1080p@60 fps resolution. I used [OpenMAX IL][6] and IL client libraries delivered together with the Raspberry Pi firmware to implement video hardware acceleration. - -Taking advantage of the fact that the Raspberry Pi operating system is Raspbian based on Debian Linux, OpenAuto can be also built for any other Linux-based platform that provides support for hardware video decoding. Most of the Linux-based platforms provide support for hardware video decoding directly in GStreamer. Thanks to highly portable libraries like Boost and [Qt][7], OpenAuto can be built and run on the Windows platform. Support of MacOS is being implemented by the community and should be available soon. - -![][https://www.youtube.com/embed/k9tKRqIkQs8?origin=https://opensource.com&enablejsapi=1] - -### What software libraries does the project use? - -The core of the OpenAuto is the [aasdk][8] library, which provides support for all Android Auto features. aasdk library is built on top of the Boost, libusb, and OpenSSL libraries. [libusb][9] implements communication between the head unit and an Android device (via USB bus). [Boost][10] provides support for the asynchronous mechanisms for communication. It is required for high efficiency and scalability of the head unit software. [OpenSSL][11] is used for encrypting communication. - -The aasdk library is designed to be fully reusable for any purposes related to implementation of the head unit software. You can use it to build your own head unit software for your desired platform. - -Another very important library used in OpenAuto is Qt. It provides support for OpenAuto's multimedia, user input, and graphical interface. And the build system OpenAuto is using is [CMake][12]. - -Note: The Android Auto protocol is taken from another great Android Auto head unit project called [HeadUnit][13]. The people working on this project did an amazing job in reverse engineering the AndroidAuto protocol and creating the protocol buffers that structurize all messages. - -### What equipment do you need to run OpenAuto on Raspberry Pi? - -In addition to a Raspberry Pi 3 computer and an Android device, you need: - - * **USB sound card:** The Raspberry Pi 3 doesn't have a microphone input, which is required to use Google Voice Assistant - * **Video output device:** You can use either a touchscreen or any other video output device connected to HDMI or composite output (RCA) - * **Input device:** For example, a touchscreen or a USB keyboard - - - -### What else do you need to get started? - -In order to use OpenAuto, you must build it first. On the OpenAuto's wiki page you can find [detailed instructions][14] for how to build it for the Raspberry Pi 3 platform. On other Linux-based platforms, the build process will look very similar. - -On the wiki page you can also find other useful instructions, such as how to configure the Bluetooth Hands-Free Profile (HFP) and Advanced Audio Distribution Profile (A2DP) and PulseAudio. - -### What else should we know about OpenAuto? - -OpenAuto allows anyone to create a head unit based on the Raspberry Pi 3 hardware. Nevertheless, you should always be careful about safety and keep in mind that OpenAuto is just an emulator. It was not certified by any authority and was not tested in a driving environment, so using it in a car is not recommended. - -OpenAuto is licensed under GPLv3. For more information, visit the [project's GitHub page][3], where you can find its source code and other information. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/openauto-emulator-Raspberry-Pi - -作者:[Michal Szwaj][a] -译者:[译者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/michalszwaj -[1]:https://www.android.com/auto/faq/ -[2]:https://play.google.com/store/apps/collection/promotion_3001303_android_auto_all -[3]:https://github.com/f1xpl/openauto -[4]:https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC -[5]:https://en.wikipedia.org/wiki/Pulse-code_modulation -[6]:https://www.khronos.org/openmaxil -[7]:https://www.qt.io/ -[8]:https://github.com/f1xpl/aasdk -[9]:http://libusb.info/ -[10]:http://www.boost.org/ -[11]:https://www.openssl.org/ -[12]:https://cmake.org/ -[13]:https://github.com/gartnera/headunit -[14]:https://github.com/f1xpl/ diff --git a/sources/talk/20180403 3 pitfalls everyone should avoid with hybrid multicloud.md b/sources/talk/20180403 3 pitfalls everyone should avoid with hybrid multicloud.md deleted file mode 100644 index b128be62f0..0000000000 --- a/sources/talk/20180403 3 pitfalls everyone should avoid with hybrid multicloud.md +++ /dev/null @@ -1,87 +0,0 @@ -3 pitfalls everyone should avoid with hybrid multicloud -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BIZ_darwincloud_520x292_0311LL.png?itok=74DLgd8Q) - -This article was co-written with [Roel Hodzelmans][1]. - -We're all told the cloud is the way to ensure a digital future for our businesses. But which cloud? From cloud to hybrid cloud to hybrid multi-cloud, you need to make choices, and these choices don't preclude the daily work of enhancing your customers' experience or agile delivery of the applications they need. - -This article is the first in a four-part series on avoiding pitfalls in hybrid multi-cloud computing. Let's start by examining multi-cloud, hybrid cloud, and hybrid multi-cloud and what makes them different from one another. - -### Hybrid vs. multi-cloud - -There are many conversations you may be having in your business around moving to the cloud. For example, you may want to take your on-premises computing capacity and turn it into your own private cloud. You may wish to provide developers with a cloud-like experience using the same resources you already have. A more traditional reason for expansion is to use external computing resources to augment those in your own data centers. The latter leads you to the various public cloud providers, as well as to our first definition, multi-cloud. - -#### Multi-cloud - -Multi-cloud means using multiple clouds from multiple providers for multiple tasks. - -![Multi-cloud][3] - -Figure 1. Multi-cloud IT with multiple isolated cloud environments - -Typically, multi-cloud refers to the use of several different public clouds in order to achieve greater flexibility, lower costs, avoid vendor lock-in, or use specific regional cloud providers. - -A challenge of the multi-cloud approach is achieving consistent policies, compliance, and management with different providers involved. - -Multi-cloud is mainly a strategy to expand your business while leveraging multi-vendor cloud solutions and spreading the risk of lock-in. Figure 1 shows the isolated nature of cloud services in this model, without any sort of coordination between the services and business applications. Each is managed separately, and applications are isolated to services found in their environments. - -#### Hybrid cloud - -Hybrid cloud solves issues where isolation and coordination are central to the solution. It is a combination of one or more public and private clouds with at least a degree of workload portability, integration, orchestration, and unified management. - -![Hybrid cloud][5] - -Figure 2. Hybrid clouds may be on or off premises, but must have a degree of interoperability - -The key issue here is that there is an element of interoperability, migration potential, and a connection between tasks running in public clouds and on-premises infrastructure, even if it's not always seamless or otherwise fully implemented. - -If your cloud model is missing portability, integration, orchestration, and management, then it's just a bunch of clouds, not a hybrid cloud. - -The cloud environments in Fig. 2 include at least one private and public cloud. They can be off or on premises, but they have some degree of the following: - - * Interoperability - * Application portability - * Data portability - * Common management - - - -As you can probably guess, combining multi-cloud and hybrid cloud results in a hybrid multi-cloud. But what does that look like? - -### Hybrid multi-cloud - -Hybrid multi-cloud pulls together multiple clouds and provides the tools to ensure interoperability between the various services in hybrid and multi-cloud solutions. - -![Hybrid multi-cloud][7] - -Figure 3. Hybrid multi-cloud solutions using open technologies - -Bringing these together can be a serious challenge, but the result ensures better use of resources without isolation in their respective clouds. - -Fig. 3 shows an example of hybrid multi-cloud based on open technologies for interoperability, workload portability, and management. - -### Moving forward: Pitfalls of hybrid multi-cloud - -In part two of this series, we'll look at the first of three pitfalls to avoid with hybrid multi-cloud. Namely, why cost is not always the obvious motivator when determining how to transition your business to the cloud. - -This article is based on "[3 pitfalls everyone should avoid with hybrid multi-cloud][8]," a talk the authors will be giving at [Red Hat Summit 2018][9], which will be held May 8-10 in San Francisco. [Register by May 7][9] to save US$ 500 off of registration. Use discount code **OPEN18** on the payment page to apply the discount. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/4/pitfalls-hybrid-multi-cloud - -作者:[Eric D.Schabell][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/eschabell -[1]:https://opensource.com/users/roelh -[3]:https://opensource.com/sites/default/files/u128651/multi-cloud.png (Multi-cloud) -[5]:https://opensource.com/sites/default/files/u128651/hybrid-cloud.png (Hybrid cloud) -[7]:https://opensource.com/sites/default/files/u128651/hybrid-multicloud.png (Hybrid multi-cloud) -[8]:https://agenda.summit.redhat.com/SessionDetail.aspx?id=153892 -[9]:https://www.redhat.com/en/summit/2018 diff --git a/sources/talk/20180404 Is the term DevSecOps necessary.md b/sources/talk/20180404 Is the term DevSecOps necessary.md deleted file mode 100644 index 96b544e7c4..0000000000 --- a/sources/talk/20180404 Is the term DevSecOps necessary.md +++ /dev/null @@ -1,51 +0,0 @@ -Is the term DevSecOps necessary? -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/document_free_access_cut_security.png?itok=ocvCv8G2) -First came the term "DevOps." - -It has many different aspects. For some, [DevOps][1] is mostly about a culture valuing collaboration, openness, and transparency. Others focus more on key practices and principles such as automating everything, constantly iterating, and instrumenting heavily. And while DevOps isn’t about specific tools, certain platforms and tooling make it a more practical proposition. Think containers and associated open source cloud-native technologies like [Kubernetes][2] and CI/CD pipeline tools like [Jenkins][3]—as well as native Linux capabilities. - -However, one of the earliest articulated concepts around DevOps was the breaking down of the “wall of confusion” specifically between developers and operations teams. This was rooted in the idea that developers didn’t think much about operational concerns and operators didn’t think much about application development. Add the fact that developers want to move quickly and operators care more about (and tend to be measured on) stability than speed, and it’s easy to see why it was difficult to get the two groups on the same page. Hence, DevOps came to symbolize developers and operators working more closely together, or even merging roles to some degree. - -Of course, calls for improved communications and better-integrated workflows were never just about dev and ops. Business owners should be part of conversations as well. And there are the actual users of the software. Indeed, you can write up an almost arbitrarily long list of stakeholders concerned with the functionality, cost, reliability, and other aspects of software and its associated infrastructure. Which raises the question that many have asked: “What’s so special about security that we need a DevSecOps term?” - -I’m glad you asked. - -The first is simply that it serves as a useful reminder. If developers and operations were historically two of the most common silos in IT organizations, security was (and often still is) another. Security people are often thought of as conservative gatekeepers for whom “no” often seems the safest response to new software releases and technologies. Security’s job is to protect the company, even if that means putting the brakes on a speedy development process. - -Many aspects of traditional security, and even its vocabulary, can also seem arcane to non-specialists. This has also contributed to the notion that security is something apart from mainstream IT. I often share the following anecdote: A year or two ago I was leading a security discussion at a [DevOpsDays][4] event in London in which we were talking about traditional security roles. One of the participants raised his hand and admitted that he was one of those security gatekeepers. He went on to say that this was the first time in his career that he had ever been to a conference that wasn’t a traditional security conference like RSA. (He also noted that he was going to broaden both his and his team’s horizons more.) - -So DevSecOps perhaps shouldn’t be a needed term. But explicitly calling it out seems like a good practice at a time when software security threats are escalating. - -The second reason is that the widespread introduction of cloud-native technologies, particularly those built around containers, are closely tied to DevOps practices. These new technologies are both leading to and enabling greater scale and more dynamic infrastructures. Static security policies and checklists no longer suffice. Security must become a continuous activity. And it must be considered at every stage of your application and infrastructure lifecycle. - -**Here are a few examples:** - -You need to secure the pipeline and applications. You need to use trusted sources for content so that you know who has signed off on container images and that they’re up-to-date with the most recent patches. Your continuous integration system must integrate automated security testing. You’ll sometimes hear people talking about “shifting security left,” which means earlier in the process so that problems can be dealt with sooner. But it’s actually better to think about embedding security throughout the entire pipeline at each step of the testing, integration, deployment, and ongoing management process. - -You need to secure the underlying infrastructure. This means securing the host Linux kernel from container escapes and securing containers from each other. It means using a container orchestration platform with integrated security features. It means defending the network by using network namespaces to isolate applications from other applications within a cluster and isolate environments (such as dev, test, and production) from each other. - -And it means taking advantage of the broader security ecosystem such as container content scanners and vulnerability management tools. - -In short, it’s DevSecOps because modern application development and container platforms require a new type of Dev and a new type of Ops. But they also require a new type of Sec. Thus, DevSecOps. - -**[See our related story,[Security and the SRE: How chaos engineering can play a key role][5].]** - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/4/devsecops - -作者:[Gordon Haff][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) -选题:[lujun9972](https://github.com/lujun9972) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/ghaff -[1]:https://opensource.com/resources/devops -[2]:https://kubernetes.io/ -[3]:https://jenkins.io/ -[4]:https://www.devopsdays.org/ -[5]:https://opensource.com/article/18/3/through-looking-glass-security-sre diff --git a/sources/talk/20180405 Rethinking -ownership- across the organization.md b/sources/talk/20180405 Rethinking -ownership- across the organization.md deleted file mode 100644 index d41a3a86dc..0000000000 --- a/sources/talk/20180405 Rethinking -ownership- across the organization.md +++ /dev/null @@ -1,125 +0,0 @@ -Rethinking "ownership" across the organization -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/chain.png?itok=sgAjswFf) -Differences in organizational design don't necessarily make some organizations better than others—just better suited to different purposes. Any style of organization must account for its models of ownership (the way tasks get delegated, assumed, executed) and responsibility (the way accountability for those tasks gets distributed and enforced). Conventional organizations and open organizations treat these issues differently, however, and those difference can be jarring for anyone hopping transitioning from one organizational model to another. But transitions are ripe for stumbling over—oops, I mean, learning from. - -Let's do that. - -### Ownership explained - -In most organizations (and according to typical project management standards), work on projects proceeds in five phases: - - * Initiation: Assess project feasibility, identify deliverables and stakeholders, assess benefits - * Planning (Design): Craft project requirements, scope, and schedule; develop communication and quality plans - * Executing: Manage task execution, implement plans, maintain stakeholder relationships - * Monitoring/Controlling: Manage project performance, risk, and quality of deliverables - * Closing: Sign-off on completion requirements, release resources - - - -The list above is not exhaustive, but I'd like to add one phase that is often overlooked: the "Adoption" phase, frequently needed for strategic projects where a change to the culture or organization is required for "closing" or completion. - - * Adoption: Socializing the work of the project; providing communication, training, or integration into processes and standard workflows. - - - -Examining project phases is one way contrast the expression of ownership and responsibility in organizations. - -### Two models, contrasted - -In my experience, "ownership" in a traditional software organization works like this. - -A manager or senior technical associate initiates a project with senior stakeholders and, with the authority to champion and guide the project, they bestow the project on an associate at some point during the planning and execution stages. Frequently, but not always, the groundwork or fundamental design of the work has already been defined and approved—sometimes even partially solved. Employees are expected to see the project through execution and monitoring to completion. - -Employees cut their teeth on a "starter project," where they prove their abilities to a management chain (for example, I recall several such starter projects that were already defined by a manager and architect, and I was assigned to help implement them). Employees doing a good job on a project for which they're responsible get rewarded with additional opportunities, like a coveted assignment, a new project, or increased responsibility. - -An associate acting as "owner" of work is responsible and accountable for that work (if someone, somewhere, doesn't do their job, then the responsible employee either does the necessary work herself or alerts a manager to the problem.) A sense of ownership begins to feel stable over time: Employees generally work on the same projects, and in the same areas for an extended period. For some employees, it means the development of deep expertise. That's because the social network has tighter integration between people and the work they do, so moving around and changing roles and projects is rather difficult. - -This process works differently in an open organization. - -Associates continually define the parameters of responsibility and ownership in an open organization—typically in light of their interests and passions. Associates have more agency to perform all the stages of the project themselves, rather than have pre-defined projects assigned to them. This places additional emphasis on leadership skills in an open organization, because the process is less about one group of people making decisions for others, and more about how an associate manages responsibilities and ownership (whether or not they roughly follow the project phases while being inclusive, adaptable, and community-focused, for example). - -Being responsible for all project phases can make ownership feel more risky for associates in an open organization. Proposing a new project, designing it, and leading its implementation takes initiative and courage—especially when none of this is pre-defined by leadership. It's important to get continuous buy-in, which comes with questions, criticisms, and resistance not only from leaders but also from peers. By default, in open organizations this makes associates leaders; they do much the same work that higher-level leaders do in conventional organizations. And incidentally, this is why Jim Whitehurst, in The Open Organization, cautions us about the full power of "transparency" and the trickiness of getting people's real opinions and thoughts whether we like them or not. The risk is not as high in a traditional organization, because in those organizations leaders manage some of it by shielding associates from heady discussions that arise. - -The reward in an Open Organization is more opportunity—offers of new roles, promotions, raises, etc., much like in a conventional organization. Yet in the case of open organizations, associates have developed reputations of excellence based on their own initiatives, rather than on pre-sanctioned opportunities from leadership. - -### Thinking about adoption - -Any discussion of ownership and responsibility involves addressing the issue of buy-in, because owning a project means we are accountable to our sponsors and users—our stakeholders. We need our stakeholders to buy-into our idea and direction, or we need users to adopt an innovation we've created with our stakeholders. Achieving buy-in for ideas and work is important in each type of organization, and it's difficult in both traditional and open systems—but for different reasons. - -Open organizations better allow highly motivated associates, who are ambitious and skilled, to drive their careers. But support for their ideas is required across the organization, rather than from leadership alone. - -Penetrating a traditional organization's closely knit social ties can be difficult, and it takes time. In such "command-and-control" environments, one would think that employees are simply "forced" to do whatever leaders want them to do. In some cases that's true (e.g., a travel reimbursement system). However, with more innovative programs, this may not be the case; the adoption of a program, tool, or process can be difficult to achieve by fiat, just like in an open organization. And yet these organizations tend to reduce redundancies of work and effort, because "ownership" here involves leaders exerting responsibility over clearly defined "domains" (and because those domains don't change frequently, knowing "who's who"—who's in charge, who to contact with a request or inquiry or idea—can be easier). - -Open organizations better allow highly motivated associates, who are ambitious and skilled, to drive their careers. But support for their ideas is required across the organization, rather than from leadership alone. Points of contact and sources of immediate support can be less obvious, and this means achieving ownership of a project or acquiring new responsibility takes more time. And even then someone's idea may never get adopted. A project's owner can change—and the idea of "ownership" itself is more flexible. Ideas that don't get adopted can even be abandoned, leaving a great idea unimplemented or incomplete. Because any associate can "own" an idea in an open organization, these organizations tend to exhibit more redundancy. (Some people immediately think this means "wasted effort," but I think it can augment the implementation and adoption of innovative solutions. By comparing these organizations, we can also see why Jim Whitehurst calls this kind of culture "chaotic" in The Open Organization). - -### Two models of ownership - -In my experience, I've seen very clear differences between conventional and open organizations when it comes to the issues of ownership and responsibility. - -In an traditional organization: - - * I couldn't "own" things as easily - * I felt frustrated, wanting to take initiative and always needing permission - * I could more easily see who was responsible because stakeholder responsibility was more clearly sanctioned and defined - * I could more easily "find" people, because the organizational network was more fixed and stable - * I more clearly saw what needed to happen (because leadership was more involved in telling me). - - - -Over time, I've learned the following about ownership and responsibility in an open organization: - - * People can feel good about what they are doing because the structure rewards behavior that's more self-driven - * Responsibility is less clear, especially in situations where there's no leader - * In cases where open organizations have "shared responsibility," there is the possibility that no one in the group identified with being responsible; often there is lack of role clarity ("who should own this?") - * More people participate - * Someone's leadership skills must be stronger because everyone is "on their own"; you are the leader. - - - -### Making it work - -On the subject of ownership, each type of organization can learn from the other. The important thing to remember here: Don't make changes to one open or conventional value without considering all the values in both organizations. - -Sound confusing? Maybe these tips will help. - -If you're a more conventional organization trying to act more openly: - - * Allow associates to take ownership out of passion or interest that align with the strategic goals of the organization. This enactment of meritocracy can help them build a reputation for excellence and execution. - * But don't be afraid sprinkle in a bit of "high-level perspective" in the spirit of transparency; that is, an associate should clearly communicate plans to their leadership, so the initiative doesn't create irrelevant or unneeded projects. - * Involving an entire community (as when, for example, the associate gathers feedback from multiple stakeholders and user groups) aids buy-in and creates beneficial feedback from the diversity of perspectives, and this helps direct the work. - * Exploring the work with the community [doesn't mean having to come to consensus with thousands of people][1]. Use the [Open Decision Framework][2] to set limits and be transparent about what those limits are so that feedback and participation is organized ad boundaries are understood. - - - -If you're already an open organization, then you should remember: - - * Although associates initiate projects from "the bottom up," leadership needs to be involved to provide guidance, input to the vision, and circulate centralized knowledge about ownership and responsibility creating a synchronicity of engagement that is transparent to the community. - * Ownership creates responsibility, and the definition and degree of these should be something both associates and leaders agree upon, increasing the transparency of expectations and accountability during the project. Don't make this a matter of oversight or babysitting, but rather [a collaboration where both parties give and take][3]—associates initiate, leaders guide; associates own, leaders support. - - - -Leadership education and mentorship, as it pertains to a particular organization, needs to be available to proactive associates, especially since there is often a huge difference between supporting individual contributors and guiding and coordinating a multiplicity of contributions. - -["Owning your own career"][4] can be difficult when "ownership" isn't a concept an organization completely understands. - -[Subscribe to our weekly newsletter][5] to learn more about open organizations. - --------------------------------------------------------------------------------- - -via: https://opensource.com/open-organization/18/4/rethinking-ownership-across-organization - -作者:[Heidi Hess von Ludewig][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) -选题:[lujun9972](https://github.com/lujun9972) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/heidi-hess-von-ludewig -[1]:https://opensource.com/open-organization/17/8/achieving-alignment-in-openorg -[2]:https://opensource.com/open-organization/resources/open-decision-framework -[3]:https://opensource.com/open-organization/17/11/what-is-collaboration -[4]:https://opensource.com/open-organization/17/12/drive-open-career-forward -[5]:https://opensource.com/open-organization/resources/newsletter diff --git a/sources/talk/20180410 Microservices Explained.md b/sources/talk/20180410 Microservices Explained.md deleted file mode 100644 index 1d7e946a12..0000000000 --- a/sources/talk/20180410 Microservices Explained.md +++ /dev/null @@ -1,61 +0,0 @@ -Microservices Explained -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/cloud-microservices.jpg?itok=GpoWiDeG) -Microservices is not a new term. Like containers, the concept been around for a while, but it’s become a buzzword recently as many companies embark on their cloud native journey. But, what exactly does the term microservices mean? Who should care about it? In this article, we’ll take a deep dive into the microservices architecture. - -### Evolution of microservices - -Patrick Chanezon, Chief Developer Advocate for Docker provided a brief history lesson during our conversation: In the late 1990s, developers started to structure their applications into monoliths where massive apps hadall features and functionalities baked into them. Monoliths were easy to write and manage. Companies could have a team of developers who built their applications based on customer feedback through sales and marketing teams. The entire developer team would work together to build tightly glued pieces as an app that can be run on their own app servers. It was a popular way of writing and delivering web applications. - -There is a flip side to the monolithic coin. Monoliths slow everything and everyone down. It’s not easy to update one service or feature of the application. The entire app needs to be updated and a new version released. It takes time. There is a direct impact on businesses. Organizations could not respond quickly to keep up with new trends and changing market dynamics. Additionally, scalability was challenging. - -Around 2011, SOA (Service Oriented Architecture) became popular where developers could cram multi-tier web applications as software services inside a VM (virtual machine). It did allow them to add or update services independent of each other. However, scalability still remained a problem. - -“The scale out strategy then was to deploy multiple copies of the virtual machine behind a load balancer. The problems with this model are several. Your services can not scale or be upgraded independently as the VM is your lowest granularity for scale. VMs are bulky as they carry extra weight of an operating system, so you need to be careful about simply deploying multiple copies of VMs for scaling,” said Madhura Maskasky, co-founder and VP of Product at Platform9. - -Some five years ago when Docker hit the scene and containers became popular, SOA faded out in favor of “microservices” architecture. “Containers and microservices fix a lot of these problems. Containers enable deployment of microservices that are focused and independent, as containers are lightweight. The Microservices paradigm, combined with a powerful framework with native support for the paradigm, enables easy deployment of independent services as one or more containers as well as easy scale out and upgrade of these,” said Maskasky. - -### What’s are microservices? - -Basically, a microservice architecture is a way of structuring applications. With the rise of containers, people have started to break monoliths into microservices. “The idea is that you are building your application as a set of loosely coupled services that can be updated and scaled separately under the container infrastructure,” said Chanezon. - -“Microservices seem to have evolved from the more strictly defined service-oriented architecture (SOA), which in turn can be seen as an expression object oriented programming concepts for networked applications. Some would call it just a rebranding of SOA, but the term “microservices” often implies the use of even smaller functional components than SOA, RESTful APIs exchanging JSON, lighter-weight servers (often containerized, and modern web technologies and protocols,” said Troy Topnik, SUSE Senior Product Manager, Cloud Application Platform. - -Microservices provides a way to scale development and delivery of large, complex applications by breaking them down that allows the individual components to evolve independently from each other. - -“Microservices architecture brings more flexibility through the independence of services, enabling organizations to become more agile in how they deliver new business capabilities or respond to changing market conditions. Microservices allows for using the ‘right tool for the right task’, meaning that apps can be developed and delivered by the technology that will be best for the task, rather than being locked into a single technology, runtime or framework,” said Christian Posta, senior principal application platform specialist, Red Hat. - -### Who consumes microservices? - -“The main consumers of microservices architecture patterns are developers and application architects,” said Topnik. As far as admins and DevOps engineers are concerned their role is to build and maintain the infrastructure and processes that support microservices. - -“Developers have been building their applications traditionally using various design patterns for efficient scale out, high availability and lifecycle management of their applications. Microservices done along with the right orchestration framework help simplify their lives by providing a lot of these features out of the box. A well-designed application built using microservices will showcase its benefits to the customers by being easy to scale, upgrade, debug, but without exposing the end customer to complex details of the microservices architecture,” said Maskasky. - -### Who needs microservices? - -Everyone. Microservices is the modern approach to writing and deploying applications more efficiently. If an organization cares about being able to write and deploy its services at a faster rate they should care about it. If you want to stay ahead of your competitors, microservices is the fastest route. Security is another major benefit of the microservices architecture, as this approach allows developers to keep up with security and bug fixes, without having to worry about downtime. - -“Application developers have always known that they should build their applications in a modular and flexible way, but now that enough of them are actually doing this, those that don’t risk being left behind by their competitors,” said Topnik. - -If you are building a new application, you should design it as microservices. You never have to hold up a release if one team is late. New functionalities are available when they're ready, and the overall system never breaks. - -“We see customers using this as an opportunity to also fix other problems around their application deployment -- such as end-to-end security, better observability, deployment and upgrade issues,” said Maskasky. - -Failing to do so means you would be stuck in the traditional stack, which means microservices won’t be able to add any value to it. If you are building new applications, microservices is the way to go. - -Learn more about cloud-native at [KubeCon + CloudNativeCon Europe][1], coming up May 2-4 in Copenhagen, Denmark. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/2018/4/microservices-explained - -作者:[SWAPNIL BHARTIYA][a] -译者:[runningwater](https://github.com/runningwater) -校对:[校对者ID](https://github.com/校对者ID) -选题:[lujun9972](https://github.com/lujun9972) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/arnieswap -[1]:https://events.linuxfoundation.org/events/kubecon-cloudnativecon-europe-2018/attend/register/ diff --git a/sources/talk/20180412 Management, from coordination to collaboration.md b/sources/talk/20180412 Management, from coordination to collaboration.md deleted file mode 100644 index 1262f88300..0000000000 --- a/sources/talk/20180412 Management, from coordination to collaboration.md +++ /dev/null @@ -1,71 +0,0 @@ -Management, from coordination to collaboration -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUS_consensuscollab2.png?itok=uMO9zn5U) - -Any organization is fundamentally a pattern of interactions between people. The nature of those interactions—their quality, their frequency, their outcomes—is the most important product an organization can create. Perhaps counterintuitively, recognizing this fact has never been more important than it is today—a time when digital technologies are reshaping not only how we work but also what we do when we come together. - - -And yet many organizational leaders treat those interactions between people as obstacles or hindrances to avoid or eliminate, rather than as the powerful sources of innovation they really are. - -That's why we're observing that some of the most successful organizations today are those capable of shifting the way they think about the value of the interactions in the workplace. And to do that, they've radically altered their approach to management and leadership. - -### Moving beyond mechanical management - -Simply put, traditionally managed organizations treat unanticipated interactions between stakeholders as potentially destructive forces—and therefore as costs to be mitigated. - -This view has a long, storied history in the field of economics. But it's perhaps nowhere more clear than in the early writing of Nobel Prize-winning economist[Ronald Coase][1]. In 1937, Coase published "[The Nature of the Firm][2]," an essay about the reasons people organized into firms to work on large-scale projects—rather than tackle those projects alone. Coase argued that when the cost of coordinating workers together inside a firm is less than that of similar market transactions outside, people will tend to organize so they can reap the benefits of lower operating costs. - -But at some point, Coase's theory goes, the work of coordinating interactions between so many people inside the firm actually outweighs the benefits of having an organization in the first place. The complexity of those interactions becomes too difficult to handle. Management, then, should serve the function of decreasing this complexity. Its primary goal is coordination, eliminating the costs associated with messy interpersonal interactions that could slow the firm and reduce its efficiency. As one Fortune 100 CEO recently told me, "Failures happen most often around organizational handoffs." - -This makes sense to people practicing what I've called "[mechanical management][3]," where managing people is the act of keeping them focused on specific, repeatable, specialized tasks. Here, management's key function is optimizing coordination costs—ensuring that every specialized component of the finely-tuned organizational machine doesn't impinge on the others and slow them down. Managers work to avoid failures by coordinating different functions across the organization (accounts payable, research and development, engineering, human resources, sales, and so on) to get them to operate toward a common goal. And managers create value by controlling information flows, intervening only when functions become misaligned. - -Today, when so many of these traditionally well-defined tasks have become automated, value creation is much more a result of novel innovation and problem solving—not finding new ways to drive efficiency from repeatable processes. But numerous studies demonstrate that innovative, problem-solving activity occurs much more regularly when people work in cross-functional teams—not as isolated individuals or groups constrained by single-functional silos. This kind of activity can lead to what some call "accidental integration": the serendipitous innovation that occurs when old elements combine in new and unforeseen ways. - -That's why working collaboratively has now become a necessity that managers need to foster, not eliminate. - -### From coordination to collaboration - -Reframing the value of the firm—from something that coordinated individual transactions to something that produces novel innovations—means rethinking the value of the relations at the core of our organizations. And that begins with reimagining the task of management, which is no longer concerned primarily with minimizing coordination costs but maximizing cooperation opportunities. - -Too few of our tried-and-true management practices have this goal. If they're seeking greater innovation, managers need to encourage more interactions between people in different functional areas, not fewer. A cross-functional team may not be as efficient as one composed of people with the same skill sets. But a cross-functional team is more likely to be the one connecting points between elements in your organization that no one had ever thought to connect (the one more likely, in other words, to achieve accidental integration). - -Working collaboratively has now become a necessity that managers need to foster, not eliminate. - -I have three suggestions for leaders interested in making this shift: - -First, define organizations around processes, not functions. We've seen this strategy work in enterprise IT, for example, in the case of [DevOps][4], where teams emerge around end goals (like a mobile application or a website), not singular functions (like developing, testing, and production). In DevOps environments, the same team that writes the code is responsible for maintaining it once it's in production. (We've found that when the same people who write the code are the ones woken up when it fails at 3 a.m., we get better code.) - -Second, define work around the optimal organization rather than the organization around the work. Amazon is a good example of this strategy. Teams usually stick to the "[Two Pizza Rule][5]" when establishing optimal conditions for collaboration. In other words, Amazon leaders have determined that the best-sized team for maximum innovation is about 10 people, or a group they can feed with two pizzas. If the problem gets bigger than that two-pizza team can handle, they split the problem into two simpler problems, dividing the work between multiple teams rather than adding more people to the single team. - -And third, to foster creative behavior and really get people cooperating with one another, do whatever you can to cultivate a culture of honest and direct feedback. Be straightforward and, as I wrote in The Open Organization, let the sparks fly; have frank conversations and let the best ideas win. - -### Let it go - -I realize that asking managers to significantly shift the way they think about their roles can lead to fear and skepticism. Some managers define their performance (and their very identities) by the control they exert over information and people. But the more you dictate the specific ways your organization should do something, the more static and brittle that activity becomes. Agility requires letting go—giving up a certain degree of control. - -Front-line managers will see their roles morph from dictating and monitoring to enabling and supporting. Instead of setting individual-oriented goals, they'll need to set group-oriented goals. Instead of developing individual incentives, they'll need to consider group-oriented incentives. - -Because ultimately, their goal should be to[create the context in which their teams can do their best work][6]. - -[Subscribe to our weekly newsletter][7] to learn more about open organizations. - --------------------------------------------------------------------------------- - -via: https://opensource.com/open-organization/18/4/management-coordination-collaboration - -作者:[Jim Whitehurst][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) -选题:[lujun9972](https://github.com/lujun9972) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/remyd -[1]:https://news.uchicago.edu/article/2013/09/02/ronald-h-coase-founding-scholar-law-and-economics-1910-2013 -[2]:http://onlinelibrary.wiley.com/doi/10.1111/j.1468-0335.1937.tb00002.x/full -[3]:https://opensource.com/open-organization/18/2/try-learn-modify -[4]:https://enterprisersproject.com/devops -[5]:https://www.fastcompany.com/3037542/productivity-hack-of-the-week-the-two-pizza-approach-to-productive-teamwork -[6]:https://opensource.com/open-organization/16/3/what-it-means-be-open-source-leader -[7]:https://opensource.com/open-organization/resources/newsletter diff --git a/sources/talk/20180416 For project safety back up your people, not just your data.md b/sources/talk/20180416 For project safety back up your people, not just your data.md deleted file mode 100644 index 0dc6d41fa5..0000000000 --- a/sources/talk/20180416 For project safety back up your people, not just your data.md +++ /dev/null @@ -1,79 +0,0 @@ -For project safety back up your people, not just your data -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/people_remote_teams_world.png?itok=_9DCHEel) -The [FSF][1] was founded in 1985, Perl in 1987 ([happy 30th birthday, Perl][2]!), and Linux in 1991. The [term open source][3] and the [Open Source Initiative][4] both came into being in 1998 (and [turn 20 years old][5] in 2018). Since then, free and open source software has grown to become the default choice for software development, enabling incredible innovation. - -We, the greater open source community, have come of age. Millions of open source projects exist today, and each year the [GitHub Octoverse][6] reports millions of new public repositories. We rely on these projects every day, and many of us could not operate our services or our businesses without them. - -So what happens when the leaders of these projects move on? How can we help ease those transitions while ensuring that the projects thrive? By teaching and encouraging **succession planning**. - -### What is succession planning? - -Succession planning is a popular topic among business executives, boards of directors, and human resources professionals, but it doesn't often come up with maintainers of free and open source projects. Because the concept is common in business contexts, that's where you'll find most resources and advice about establishing a succession plan. As you might expect, most of these articles aren't directly applicable to FOSS, but they do form a springboard from which we can launch our own ideas about succession planning. - -According to [Wikipedia][7]: - -> Succession planning is a process for identifying and developing new leaders who can replace old leaders when they leave, retire, or die. - -In my opinion, this definition doesn't apply very well to free and open source software projects. I primarily object to the use of the term leaders. For the collaborative projects of FOSS, everyone can be some form of leader. Roles other than "project founder" or "benevolent dictator for life" are just as important. Any project role that is measured by bus factor is one that can benefit from succession planning. - -> A project's bus factor is the number of team members who, if hit by a bus, would endanger the smooth operation of the project. The smallest and worst bus factor is 1: when only a single person's loss would put the project in jeopardy. It's a somewhat grim but still very useful concept. - -I propose that instead of viewing succession planning as a leadership pipeline, free and open source projects should view it as a skills pipeline. What sorts of skills does your project need to continue functioning well, and how can you make sure those skills always exist in your community? - -### Benefits of succession planning - -When I talk to project maintainers about succession planning, they often respond with something like, "We've been pretty successful so far without having to think about this. Why should we start now?" - -Aside from the fact that the phrase, "We've always done it this way" is probably one of the most dangerous in the English language, and hearing (or saying) it should send up red flags in any community, succession planning provides plenty of very real benefits: - - * **Continuity** : When someone leaves, what happens to the tasks they were performing? Succession planning helps ensure those tasks continue uninterrupted and no one is left hanging. - * **Avoiding a power vacuum** : When a person leaves a role with no replacement, it can lead to confusion, delays, and often most damaging, political woes. After all, it's much easier to fix delays than hurt feelings. A succession plan helps alleviate the insecure and unstable time when someone in a vital role moves on. - * **Increased project/organization longevity** : The thinking required for succession planning is the same sort of thinking that contributes to project longevity. Ensuring continuity in leadership, culture, and productivity also helps ensure the project will continue. It will evolve, but it will survive. - * **Reduced workload/pressure on current leaders** : When a single team member performs a critical role in the project, they often feel pressure to be constantly "on." This can lead to burnout and worse, resignations. A succession plan ensures that all important individuals have a backup or successor. The knowledge that someone can take over is often enough to reduce the pressure, but it also means that key players can take breaks or vacations without worrying that their role will be neglected in their absence. - * **Talent development** : Members of the FOSS community talk a lot about mentoring these days, and that's great. However, most of the conversation is around mentoring people to contribute code to a project. There are many different ways to contribute to free and open source software projects beyond programming. A robust succession plan recognizes these other forms of contribution and provides mentoring to prepare people to step into critical non-programming roles. - * **Inspiration for new members** : It can be very motivational for new or prospective community members to see that a project uses its succession plan. Not only does it show them that the project is well-organized and considers its own health and welfare as well as that of its members, but it also clearly shows new members how they can grow in the community. An obvious path to critical roles and leadership positions inspires new members to stick around to walk that path. - * **Diversity of thoughts/get out of a rut** : Succession plans provide excellent opportunities to bring in new people and ideas to the critical roles of a project. [Studies show][8] that diverse leadership teams are more effective and the projects they lead are more innovative. Using your project's succession plan to mentor people from different backgrounds and with different perspectives will help strengthen and evolve the project in a healthy way. - * **Enabling meritocracy** : Unfortunately, what often passes for meritocracy in many free and open source projects is thinly veiled hostility toward new contributors and diverse opinions—hostility that's delivered from within an echo chamber. Meritocracy without a mentoring program and healthy governance structure is simply an excuse to practice subjective discrimination while hiding behind unexpressed biases. A well-executed succession plan helps teams reach the goal of a true meritocracy. What counts as merit for any given role, and how to reach that level of merit, are openly, honestly, and completely documented. The entire community will be able to see and judge which members are on the path or deserve to take on a particular critical role. - - - -### Why it doesn't happen - -Succession planning isn't a panacea, and it won't solve all problems for all projects, but as described above, it offers a lot of worthwhile benefits to your project. - -Despite that, very few free and open source projects or organizations put much thought into it. I was curious why that might be, so I asked around. I learned that the reasons for not having a succession plan fall into one of five different buckets: - - * **Too busy** : Many people recognize succession planning (or lack thereof) as a problem for their project but just "hadn't ever gotten around to it" because there's "always something more important to work on." I understand and sympathize with this, but I suspect the problem may have more to do with prioritization than with time availability. - * **Don't think of it** : Some people are so busy and preoccupied that they haven't considered, "Hey, what would happen if Jen had to leave the project?" This never occurs to them. After all, Jen's always been there when they need her, right? And that will always be the case, right? - * **Don't want to think of it** : Succession planning shares a trait with estate planning: It's associated with negative feelings like loss and can make people address their own mortality. Some people are uncomfortable with this and would rather not consider it at all than take the time to make the inevitable easier for those they leave behind. - * **Attitude of current leaders** : A few of the people with whom I spoke didn't want to recognize that they're replaceable, or to consider that they may one day give up their power and influence on the project. While this was (thankfully) not a common response, it was alarming enough to deserve its own bucket. Failure of someone in a critical role to recognize or admit that they won't be around forever can set a project up for failure in the long run. - * **Don't know where to start** : Many people I interviewed realize that succession planning is something that their project should be doing. They were even willing to carve out the time to tackle this very large task. What they lacked was any guidance on how to start the process of creating a succession plan. - - - -As you can imagine, something as important and people-focused as a succession plan isn't easy to create, and it doesn't happen overnight. Also, there are many different ways to do it. Each project has its own needs and critical roles. One size does not fit all where succession plans are concerned. - -There are, however, some guidelines for how every project could proceed with the succession plan creation process. I'll cover these guidelines in my next article. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/4/passing-baton-succession-planning-foss-leadership - -作者:[VM(Vicky) Brasseur][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) -选题:[lujun9972](https://github.com/lujun9972) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/vmbrasseur -[1]:http://www.fsf.org -[2]:https://opensource.com/article/17/10/perl-turns-30 -[3]:https://opensource.com/article/18/2/coining-term-open-source-software -[4]:https://opensource.org -[5]:https://opensource.org/node/910 -[6]:https://octoverse.github.com -[7]:https://en.wikipedia.org/wiki/Succession_planning -[8]:https://hbr.org/2016/11/why-diverse-teams-are-smarter diff --git a/sources/talk/20180417 How to develop the FOSS leaders of the future.md b/sources/talk/20180417 How to develop the FOSS leaders of the future.md deleted file mode 100644 index a65dc9dabd..0000000000 --- a/sources/talk/20180417 How to develop the FOSS leaders of the future.md +++ /dev/null @@ -1,93 +0,0 @@ -How to develop the FOSS leaders of the future -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/life_paperclips.png?itok=j48op49T) -Do you hold a critical role in a free and open source software project? Would you like to make it easier for the next person to step into your shoes, while also giving yourself the freedom to take breaks and avoid burnout? - -Of course you would! But how do you get started? - -Before you do anything, remember that this is a free or open source project. As with all things in FOSS, your succession planning should happen in collaboration with others. The [Principle of Least Astonishment][1] also applies: Don't work on your plan in isolation, then spring it on the entire community. Work together and publicly, so no one is caught off guard when the cultural or governance changes start happening. - -### Identify and analyse critical roles - -As a project leader, your first step is to identify the critical roles in your community. While it can help to ask each community members what role they perform, it's important to realize that most people perform multiple roles. Make sure you consider every role that each community member plays in the project. - -Once you've identified the roles and determined which ones are critical to your project, the next step is to list all of the duties and responsibilities for each of those critical roles. Be very honest here. List the duties and responsibilities you think each role has, then ask the person who performs that role to list the duties the role actually has. You'll almost certainly find that the second list is longer than the first. - -### Refactor large roles - -During this process, have you discovered any roles that encompass a large number of duties and responsibilities? Large roles are like large methods in your code: They're a sign of a problem, and they need to be refactored to make them easier to maintain. One of the easiest and most effective steps in succession planning for FOSS projects is to split up each large role into two or more smaller roles and distribute these to other community members. With that one step, you've greatly improved the [bus factor][2] for your project. Even better, you've made each one of those new, smaller roles much more accessible and less intimidating for new community members. People are much more likely to volunteer for a role if it's not a massive burden. - -### Limit role tenure - -Another way to make a role more enticing is to limit its tenure. Community members will be more willing to step into roles that aren't open-ended. They can look at their life and work plans and ask themselves, "Can I take on this role for the next eighteen months?" (or whatever term limit you set). - -Setting term limits also helps those who are currently performing the role. They know when they can set aside those duties and move on to something else, which can help alleviate burnout. Also, setting a term limit creates a pool of people who have performed the role and are qualified to step in if needed, which can also mitigate burnout. - -### Knowledge transfer - -Once you've identified and defined the critical roles in your project, most of what remains is knowledge transfer. Even small projects involve a lot of moving parts and knowledge that needs to be where everyone can see, share, use, and contribute to it. What sort of knowledge should you be collecting? The answer will vary by project, needs, and role, but here are some of the most common (and commonly overlooked) types of information needed to implement a succession plan: - - * **Roles and their duties** : You've spent a lot of time identifying, analyzing, and potentially refactoring roles and their duties. Make sure this information doesn't get lost. - * **Policies and procedures** : None of those duties occur in a vacuum. Each duty must be performed in a particular way (procedures) when particular conditions are met (policies). Take stock of these details for every duty of every role. - * **Resources** : What accounts are associated with the project, or are necessary for it to operate? Who helps you with meetup space, sponsorship, or in-kind services? Such information is vital to project operation but can be easily lost when the responsible community member moves on. - * **Credentials** : Ideally, every external service required by the project will use a login that goes to an email address designated for a specific role (`sre@project.org`) rather than to a personal address. Every role's address should include multiple people on the distribution list to ensure that important messages (such as downtime or bogus "forgot password" requests) aren't missed. The credentials for every service should be kept in a secure keystore, with access limited to the fewest number of people possible. - * **Project history** : All community members benefit greatly from learning the history of the project. Collecting project history information can clarify why decisions were made in the past, for example, and reveal otherwise unexpressed requirements and values of the community. Project histories can also help new community members understand "inside jokes," jargon, and other cultural factors. - * **Transition plans** : A succession plan doesn't do much good if project leaders haven't thought through how to transition a role from one person to another. How will you locate and prepare people to take over a critical role? Since the project has already done a lot of thinking and knowledge transfer, transition plans for each role may be easier to put together. - - - -Doing a complete knowledge transfer for all roles in a project can be an enormous undertaking, but the effort is worth it. To avoid being overwhelmed by such a daunting task, approach it one role at a time, finishing each one before you move onto the next. Limiting the scope in this way makes both progress and success much more likely. - -### Document, document, document! - -Succession planning takes time. The community will be making a lot of decisions and collecting a lot of information, so make sure nothing gets lost. It's important to document everything (not just in email threads). Where knowledge is concerned, documentation scales and people do not. Include even the things that you think are obvious—what's obvious to a more seasoned community member may be less so to a newbie, so don't skip steps or information. - -Gather these decisions, processes, policies, and other bits of information into a single place, even if it's just a collection of markdown files in the main project repository. The "how" and "where" of the documentation can be sorted out later. It's better to capture key information first and spend time [bike-shedding][3] a documentation system later. - -Once you've collected all of this information, you should understand that it's unlikely that anyone will read it. I know, it seems unfair, but that's just how things usually work out. The reason? There is simply too much documentation and too little time. To address this, add an abstract, or summary, at the top of each item. Often that's all a person needs, and if not, the complete document is there for a deep dive. Recognizing and adapting to how most people use documentation increases the likelihood that they will use yours. - -Above all, don't skip the documentation process. Without documentation, succession plans are impossible. - -### New leaders - -If you don't yet perform a critical role but would like to, you can contribute to the succession planning process while apprenticing your way into one of those roles. - -For starters, actively look for opportunities to learn and contribute. Shadow people in critical roles. You'll learn how the role is done, and you can document it to help with the succession planning process. You'll also get the opportunity to see whether it's a role you're interested in pursuing further. - -Asking for mentorship is a great way to get yourself closer to taking on a critical role in the project. Even if you haven't heard that mentoring is available, it's perfectly OK to ask about it. The people already in those roles are usually happy to mentor others, but often are too busy to think about offering mentorship. Asking is a helpful reminder to them that they should be helping to train people to take over their role when they need a break. - -As you perform your own tasks, actively seek out feedback. This will not only improve your skills, but it shows that you're interested in doing a better job for the community. This commitment will pay off when your project needs people to step into critical roles. - -Finally, as you communicate with more experienced community members, take note of anecdotes about the history of the project and how it operates. This history is very important, especially for new contributors or people stepping into critical roles. It provides the context necessary for new contributors to understand what things do or don't work and why. As you hear these stories, document them so they can be passed on to those who come after you. - -### Succession planning examples - -While too few FOSS projects are actively considering succession planning, some are doing a great job of trying to reduce their bus factor and prevent maintainer burnout. - -[Exercism][4] isn't just an excellent tool for gaining fluency in programming languages. It's also an [open source project][5] that goes out of its way to help contributors [land their first patch][6]. In 2016, the project reviewed the health of each language track and [discovered that many were woefully maintained][7]. There simply weren't enough people covering each language, so maintainers were burning out. The Exercism community recognized the risk this created and pushed to find new maintainers for as many language tracks as possible. As a result, the project was able to revive several tracks from near-death and develop a structure for inviting people to become maintainers. - -The purpose of the [Vox Pupuli][8] project is to serve as a sort of succession plan for the [Puppet module][9] community. When a maintainer no longer wishes or is able to work on their module, they can bequeath it to the Vox Pupuli community. This community of 30 collaborators shares responsibility for maintaining all the modules it accepts into the project. The large number of collaborators ensures that no single person bears the burden of maintenance while also providing a long and fruitful life for every module in the project. - -These are just two examples of how some FOSS projects are tackling succession planning. Share your stories in the comments below. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/4/succession-planning-how-develop-foss-leaders-future - -作者:[VM(Vicky) Brasseur)][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) -选题:[lujun9972](https://github.com/lujun9972) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/vmbrasseur -[1]:https://en.wikipedia.org/wiki/Principle_of_least_astonishment -[2]:https://en.wikipedia.org/wiki/Bus_factor -[3]:https://en.wikipedia.org/wiki/Law_of_triviality -[4]:http://exercism.io -[5]:https://github.com/exercism/exercism.io -[6]:https://github.com/exercism/exercism.io/blob/master/CONTRIBUTING.md -[7]:https://tinyletter.com/exercism/letters/exercism-track-health-check-new-maintainers -[8]:https://voxpupuli.org -[9]:https://forge.puppet.com diff --git a/sources/talk/20180418 Is DevOps compatible with part-time community teams.md b/sources/talk/20180418 Is DevOps compatible with part-time community teams.md deleted file mode 100644 index e78b96959f..0000000000 --- a/sources/talk/20180418 Is DevOps compatible with part-time community teams.md +++ /dev/null @@ -1,73 +0,0 @@ -Is DevOps compatible with part-time community teams? -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/collab-team-pair-programming-code-keyboard.png?itok=kBeRTFL1) -DevOps seems to be the talk of the IT world of late—and for good reason. DevOps has streamlined the process and production of IT development and operations. However, there is also an upfront cost to embracing a DevOps ideology, in terms of time, effort, knowledge, and financial investment. Larger companies may have the bandwidth, budget, and time to make the necessary changes, but is it feasible for part-time, resource-strapped communities? - -Part-time communities are teams of like-minded people who take on projects outside of their normal work schedules. The members of these communities are driven by passion and a shared purpose. For instance, one such community is the [ALM | DevOps Rangers][1]. With 100 rangers engaged across the globe, a DevOps solution may seem daunting; nonetheless, they took on the challenge and embraced the ideology. Through their example, we've learned that DevOps is not only feasible but desirable in smaller teams. To read about their transformation, check out [How DevOps eliminates development bottlenecks][2]. - -> “DevOps is the union of people, process, and products to enable continuous delivery of value to our end customers.” - Donovan Brown - -### The cost of DevOps - -As stated above, there is an upfront "cost" to DevOps. The cost manifests itself in many forms, such as the time and collaboration between development, operations, and other stakeholders, planning a smooth-flowing process that delivers continuous value, finding the best DevOps products, and training the team in new technologies, to name a few. This aligns directly with Donovan's definition of DevOps, in fact—a **process** for delivering **continuous value** and the **people** who make that happen. - -Streamlined DevOps takes a lot of planning and training just to create the process, and that doesn't even consider the testing phase. We also can't forget the existing in-flight projects that need to be converted into the new system. While the cost increases the more pervasive the transformation—for instance, if an organization aims to unify its entire development organization under a single process, then that would cost more versus transforming a single pilot or subset of the entire portfolio—these upfront costs must be addressed regardless of their scale. There are a lot of resources and products already out there that can be implemented for a smoother transition—but again, we face the time and effort that will be necessary just to research which ones might work best. - -In the case of the ALM | DevOps Rangers, they had to halt all projects for a couple of sprints to set up the initial process. Many organizations would not be able to do that. Even part-time groups might have very good reasons to keep things moving, which only adds to the complexity. In such scenarios, additional cutover planning (and therefore additional cost) is needed, and the overall state of the community is one of flux and change, which adds risk, which—you guessed it—requires more cost to mitigate. - -There is also an ongoing "cost" that teams will face with a DevOps mindset: Simple maintenance of the system, training and transitioning new team members, and keeping up with new, improved technologies are all a part of the process. - -### DevOps for a part-time community - -Whereas larger companies can dedicate a single manager or even a team to the task over overseeing the continuous integration and continuous deployment (CI/CD) pipelines, part-time community teams don't have the bandwidth to give. With such a massive undertaking we must ask: Is it even worth it for groups with fewer resources to take on DevOps for their community? Or should they abandon the idea of DevOps altogether? - -The answer to that is dependent on a few variables, such as the ability of the teams to be self-managing, the time and effort each member is willing to put into the transformation, and the dedication of the community to the process. - -### Example: Benefits of DevOps in a part-time community - -Luckily, we aren't without examples to demonstrate just how DevOps can benefit a smaller group. Let's take a quick look at the ALM Rangers again. The results from their transformation help us understand how DevOps changed their community: - -![](https://opensource.com/sites/default/files/images/life-uploads/devops.png) - -As illustrated, there are some huge benefits for part-time community teams. Planning goes from long, arduous design sessions to a quick prototyping and storyboarding process. Builds become automated, reliable, and resilient. Testing and bug detection are proactive instead of reactive, which turns into a happier clientele. Multiple full-time program managers are replaced with self-managing teams with a single part-time manager to oversee projects. Teams become smaller and more efficient, which equates to higher production rates and higher-quality project delivery. With results like these, it's hard to argue against DevOps. - -Still, the upfront and ongoing costs aren't right for every community. The number-one most important aspect of any DevOps transformation is the mindset of the people involved. Adopting the idea of self-managing teams who work in autonomy instead of the traditional chain-of-command scheme can be a challenge for any group. The members must be willing to work independently without a lot of oversight and take ownership of their features and user experience, but at the same time, work in a setting that is fully transparent to the rest of the community. **The success or failure of a DevOps strategy lies on the team.** - -### Making the DevOps transition in 4 steps - -Another important question to ask: How can a low-bandwidth group make such a massive transition? The good news is that a DevOps transformation doesn’t need to happen all at once. Taken in smaller, more manageable steps, organizations of any size can embrace DevOps. - - 1. Determine why DevOps may be the solution you need. Are your projects bottlenecking? Are they running over budget and over time? Of course, these concerns are common for any community, big or small. Answering these questions leads us to step two: - 2. Develop the right framework to improve the engineering process. DevOps is all about automation, collaboration, and streamlining. Rather than trying to fit everyone into the same process box, the framework should support the work habits, preferences, and delivery needs of the community. Some broad standards should be established (for example, that all teams use a particular version control system). Beyond that, however, let the teams decide their own best process. - 3. Use the current products that are already available if they meet your needs. Why reinvent the wheel? - 4. Finally, implement and test the actual DevOps solution. This is, of course, where the actual value of DevOps is realized. There will likely be a few issues and some heartburn, but it will all be worth it in the end because, once established, the products of the community’s work will be nimbler and faster for the users. - - - -### Reuse DevOps solutions - -One benefit to creating effective CI/CD pipelines is the reusability of those pipelines. Although there is no one-size fits all solution, anyone can adopt a process. There are several pre-made templates available for you to examine, such as build templates on VSTS, ARM templates to deploy Azure resources, and "cookbook"-style textbooks from technical publishers. Once it identifies a process that works well, a community can also create its own template by defining and establishing standards and making that template easily discoverable by the entire community. For more information on DevOps journeys and tools, check out [this site][3]. - -### Summary - -Overall, the success or failure of DevOps relies on the culture of a community. It doesn't matter if the community is a large, resource-rich enterprise or a small, resource-sparse, part-time group. DevOps will still bring solid benefits. The difference is in the approach for adoption and the scale of that adoption. There are both upfront and ongoing costs, but the value greatly outweighs those costs. Communities can use any of the powerful tools available today for their pipelines, and they can also leverage reusability, such as templates, to reduce upfront implementation costs. DevOps is most certainly feasible—and even critical—for the success of part-time community teams. - -**[See our related story,[How DevOps eliminates development bottlenecks][4].]** - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/4/devops-compatible-part-time-community-teams - -作者:[Edward Fry][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/edwardf -[1]:https://github.com/ALM-Rangers -[2]:https://opensource.com/article/17/11/devops-rangers-transformation -[3]:https://www.visualstudio.com/devops/ -[4]:https://opensource.com/article/17/11/devops-rangers-transformation diff --git a/sources/talk/20180419 3 tips for organizing your open source project-s workflow on GitHub.md b/sources/talk/20180419 3 tips for organizing your open source project-s workflow on GitHub.md deleted file mode 100644 index 29e4ea2f48..0000000000 --- a/sources/talk/20180419 3 tips for organizing your open source project-s workflow on GitHub.md +++ /dev/null @@ -1,109 +0,0 @@ -3 tips for organizing your open source project's workflow on GitHub -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/email_paper_envelope_document.png?itok=uPj_kouJ) - -Managing an open source project is challenging work, and the challenges grow as a project grows. Eventually, a project may need to meet different requirements and span multiple repositories. These problems aren't technical, but they are important to solve to scale a technical project. [Business process management][1] methodologies such as agile and [kanban][2] bring a method to the madness. Developers and managers can make realistic decisions for estimating deadlines and team bandwidth with an organized development focus. - -At the [UNICEF Office of Innovation][3], we use GitHub project boards to organize development on the MagicBox project. [MagicBox][4] is a full-stack application and open source platform to serve and visualize data for decision-making in humanitarian crises and emergencies. The project spans multiple GitHub repositories and works with multiple developers. With GitHub project boards, we organize our work across multiple repositories to better understand development focus and team bandwidth. - -Here are three tips from the UNICEF Office of Innovation on how to organize your open source projects with the built-in project boards on GitHub. - -### 1\. Bring development discussion to issues and pull requests - -Transparency is a critical part of an open source community. When mapping out new features or milestones for a project, the community needs to see and understand a decision or why a specific direction was chosen. Filing new GitHub issues for features and milestones is an easy way for someone to follow the project direction. GitHub issues and pull requests are the cards (or building blocks) of project boards. To be successful with GitHub project boards, you need to use issues and pull requests. - - -![GitHub issues for magicbox-maps, MagicBox's front-end application][6] - -GitHub issues for magicbox-maps, MagicBox's front-end application. - -The UNICEF MagicBox team uses GitHub issues to track ongoing development milestones and other tasks to revisit. The team files new GitHub issues for development goals, feature requests, or bugs. These goals or features may come from external stakeholders or the community. We also use the issues as a place for discussion on those tasks. This makes it easy to cross-reference in the future and visualize upcoming work on one of our projects. - -Once you begin using GitHub issues and pull requests as a way of discussing and using your project, organizing with project boards becomes easier. - -### 2\. Set up kanban-style project boards - -GitHub issues and pull requests are the first step. After you begin using them, it may become harder to visualize what work is in progress and what work is yet to begin. [GitHub's project boards][7] give you a platform to visualize and organize cards into different columns. - -There are two types of project boards available: - - * **Repository** : Boards for use in a single repository - * **Organization** : Boards for use in a GitHub organization across multiple repositories (but private to organization members) - - - -The choice you make depends on the structure and size of your projects. The UNICEF MagicBox team uses boards for development and documentation at the organization level, and then repository-specific boards for focused work (like our [community management board][8]). - -#### Creating your first board - -Project boards are found on your GitHub organization page or on a specific repository. You will see the Projects tab in the same row as Issues and Pull requests. From the page, you'll see a green button to create a new project. - -There, you can set a name and description for the project. You can also choose templates to set up basic columns and sorting for your board. Currently, the only options are for kanban-style boards. - - -![Creating a new GitHub project board.][10] - -Creating a new GitHub project board. - -After creating the project board, you can make adjustments to it as needed. You can create new columns, [set up automation][11], and add pre-existing GitHub issues and pull requests to the project board. - -You may notice new options for the metadata in each GitHub issue and pull request. Inside of an issue or pull request, you can add it to a project board. If you use automation, it will automatically enter a column you configured. - -### 3\. Build project boards into your workflow - -After you set up a project board and populate it with issues and pull requests, you need to integrate it into your workflow. Project boards are effective only when actively used. The UNICEF MagicBox team uses the project boards as a way to track our progress as a team, update external stakeholders on development, and estimate team bandwidth for reaching our milestones. - - -![Tracking progress][13] - -Tracking progress with GitHub project boards. - -If you are an open source project and community, consider using the project boards for development-focused meetings. It also helps remind you and other core contributors to spend five minutes each day updating progress as needed. If you're at a company using GitHub to do open source work, consider using project boards to update other team members and encourage participation inside of GitHub issues and pull requests. - -Once you begin using the project board, yours may look like this: - - -![Development progress board][15] - -Development progress board for all UNICEF MagicBox repositories in organization-wide GitHub project boards. - -### Open alternatives - -GitHub project boards require your project to be on GitHub to take advantage of this functionality. While GitHub is a popular repository for open source projects, it's not an open source platform itself. Fortunately, there are open source alternatives to GitHub with tools to replicate the workflow explained above. [GitLab Issue Boards][16] and [Taiga][17] are good alternatives that offer similar functionality. - -### Go forth and organize! - -With these tools, you can bring a method to the madness of organizing your open source project. These three tips for using GitHub project boards encourage transparency in your open source project and make it easier to track progress and milestones in the open. - -Do you use GitHub project boards for your open source project? Have any tips for success that aren't mentioned in the article? Leave a comment below to share how you make sense of your open source projects. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/4/keep-your-project-organized-git-repo - -作者:[Justin W.Flory][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/jflory -[1]:https://en.wikipedia.org/wiki/Business_process_management -[2]:https://en.wikipedia.org/wiki/Kanban_(development) -[3]:http://unicefstories.org/about/ -[4]:http://unicefstories.org/magicbox/ -[5]:/file/393356 -[6]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/github-open-issues.png?itok=OcWPX575 (GitHub issues for magicbox-maps, MagicBox's front-end application) -[7]:https://help.github.com/articles/about-project-boards/ -[8]:https://github.com/unicef/magicbox/projects/3?fullscreen=true -[9]:/file/393361 -[10]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/github-project-boards-create-board.png?itok=pp7SXH9g (Creating a new GitHub project board.) -[11]:https://help.github.com/articles/about-automation-for-project-boards/ -[12]:/file/393351 -[13]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/github-issues-metadata.png?itok=xp5auxCQ (Tracking progress) -[14]:/file/393366 -[15]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/github-project-boards-overview.png?itok=QSbOOOkF (Development progress board) -[16]:https://about.gitlab.com/features/issueboard/ -[17]:https://taiga.io/ diff --git a/sources/talk/20180420 What You Don-t Know About Linux Open Source Could Be Costing to More Than You Think.md b/sources/talk/20180420 What You Don-t Know About Linux Open Source Could Be Costing to More Than You Think.md deleted file mode 100644 index 10511c3a7d..0000000000 --- a/sources/talk/20180420 What You Don-t Know About Linux Open Source Could Be Costing to More Than You Think.md +++ /dev/null @@ -1,39 +0,0 @@ -What You Don’t Know About Linux Open Source Could Be Costing to More Than You Think -====== - -If you would like to test out Linux before completely switching it as your everyday driver, there are a number of means by which you can do it. Linux was not intended to run on Windows, and Windows was not meant to host Linux. To begin with, and perhaps most of all, Linux is open source computer software. In any event, Linux outperforms Windows on all your hardware. - -If you’ve always wished to try out Linux but were never certain where to begin, have a look at our how to begin guide for Linux. Linux is not any different than Windows or Mac OS, it’s basically an Operating System but the leading different is the fact that it is Free for everyone. Employing Linux today isn’t any more challenging than switching from one sort of smartphone platform to another. - -You’re most likely already using Linux, whether you are aware of it or not. Linux has a lot of distinct versions to suit nearly any sort of user. Today, Linux is a small no-brainer. Linux plays an essential part in keeping our world going. - -Even then, it is dependent on the build of Linux that you’re using. Linux runs a lot of the underbelly of cloud operations. Linux is also different in that, even though the core pieces of the Linux operating system are usually common, there are lots of distributions of Linux, like different software alternatives. While Linux might seem intimidatingly intricate and technical to the ordinary user, contemporary Linux distros are in reality very user-friendly, and it’s no longer the case you have to have advanced skills to get started using them. Linux was the very first major Internet-centred open-source undertaking. Linux is beginning to increase the range of patches it pushes automatically, but several of the security patches continue to be opt-in only. - -You are able to remove Linux later in case you need to. Linux plays a vital part in keeping our world going. Linux supplies a huge library of functionality which can be leveraged to accelerate development. - -Even then, it’s dependent on the build of Linux that you’re using. Linux is also different in that, even though the core pieces of the Linux operating system are typically common, there are lots of distributions of Linux, like different software alternatives. While Linux might seem intimidatingly intricate and technical to the ordinary user, contemporary Linux distros are in fact very user-friendly, and it’s no longer the case you require to have advanced skills to get started using them. Linux runs a lot of the underbelly of cloud operations. Linux is beginning to increase the range of patches it pushes automatically, but several of the security patches continue to be opt-in only. Read More, open source projects including Linux are incredibly capable because of the contributions that all these individuals have added over time. - -### Life After Linux Open Source - -The development edition of the manual typically has more documentation, but might also document new characteristics that aren’t in the released version. Fortunately, it’s so lightweight you can just jump to some other version in case you don’t like it. It’s extremely hard to modify the compiled version of the majority of applications and nearly not possible to see exactly the way the developer created different sections of the program. - -On the challenges of bottoms-up go-to-market It’s really really hard to grasp the difference between your organic product the product your developers use and love and your company product, which ought to be, effectively, a different product. As stated by the report, it’s going to be hard for developers to switch. Developers are now incredibly important and influential in the purchasing procedure. Some OpenWrt developers will attend the event and get ready to reply to your questions! - -When the program is installed, it has to be configured. Suppose you discover that the software you bought actually does not do what you would like it to do. Open source software is much more common than you believe, and an amazing philosophy to live by. Employing open source software gives an inexpensive method to bootstrap a business. It’s more difficult to deal with closed source software generally. So regarding Application and Software, you’re all set if you are prepared to learn an alternate software or finding a means to make it run on Linux. Possibly the most famous copyleft software is Linux. - -Article sponsored by [Vegas Palms online slots][1] - - --------------------------------------------------------------------------------- - -via: https://linuxaria.com/article/what-you-dont-know-about-linux-open-source-could-be-costing-to-more-than-you-think - -作者:[Marc Fisher][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://linuxaria.com -[1]:https://www.vegaspalmscasino.com/casino-games/slots/ diff --git a/sources/talk/20180424 There-s a Server in Every Serverless Platform.md b/sources/talk/20180424 There-s a Server in Every Serverless Platform.md deleted file mode 100644 index 9bc935c06d..0000000000 --- a/sources/talk/20180424 There-s a Server in Every Serverless Platform.md +++ /dev/null @@ -1,87 +0,0 @@ -There’s a Server in Every Serverless Platform -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/servers.jpg?itok=i_gyObMP) -Serverless computing or Function as a Service (FaaS) is a new buzzword created by an industry that loves to coin new terms as market dynamics change and technologies evolve. But what exactly does it mean? What is serverless computing? - -Before getting into the definition, let’s take a brief history lesson from Sirish Raghuram, CEO and co-founder of Platform9, to understand the evolution of serverless computing. - -“In the 90s, we used to build applications and run them on hardware. Then came virtual machines that allowed users to run multiple applications on the same hardware. But you were still running the full-fledged OS for each application. The arrival of containers got rid of OS duplication and process level isolation which made it lightweight and agile,” said Raghuram. - -Serverless, specifically, Function as a Service, takes it to the next level as users are now able to code functions and run them at the granularity of build, ship and run. There is no complexity of underlying machinery needed to run those functions. No need to worry about spinning containers using Kubernetes. Everything is hidden behind the scenes. - -“That’s what is driving a lot of interest in function as a service,” said Raghuram. - -### What exactly is serverless? - -There is no single definition of the term, but to build some consensus around the idea, the [Cloud Native Computing Foundation (CNCF)][1] Serverless Working Group wrote a [white paper][2] to define serverless computing. - -According to the white paper, “Serverless computing refers to the concept of building and running applications that do not require server management. It describes a finer-grained deployment model where applications, bundled as one or more functions, are uploaded to a platform and then executed, scaled, and billed in response to the exact demand needed at the moment.” - -Ken Owens, a member of the Technical Oversight Committee at CNCF said that the primary goal of serverless computing is to help users build and run their applications without having to worry about the cost and complexity of servers in terms of provisioning, management and scaling. - -“Serverless is a natural evolution of cloud-native computing. The CNCF is advancing serverless adoption through collaboration and community-driven initiatives that will enable interoperability,” [said][3] Chris Aniszczyk, COO, CNCF. - -### It’s not without servers - -First things first, don’t get fooled by the term “serverless.” There are still servers in serverless computing. Remember what Raghuram said: all the machinery is hidden; it’s not gone. - -The clear benefit here is that developers need not concern themselves with tasks that don’t add any value to their deliverables. Instead of worrying about managing the function, they can dedicate their time to adding featured and building apps that add business value. Time is money and every minute saved in management goes toward innovation. Developers don’t have to worry about scaling based on peaks and valleys; it’s automated. Because cloud providers charge only for the duration that functions are run, developers cut costs by not having to pay for blinking lights. - -But… someone still has to do the work behind the scenes. There are still servers offering FaaS platforms. - -In the case of public cloud offerings like Google Cloud Platform, AWS, and Microsoft Azure, these companies manage the servers and charge customers for running those functions. In the case of private cloud or datacenters, where developers don’t have to worry about provisioning or interacting with such servers, there are other teams who do. - -The CNCF white paper identifies two groups of professionals that are involved in the serverless movement: developers and providers. We have already talked about developers. But, there are also providers that offer serverless platforms; they deal with all the work involved in keeping that server running. - -That’s why many companies, like SUSE, refrain from using the term “serverless” and prefer the term function as a service, because they offer products that run those “serverless” servers. But what kind of functions are these? Is it the ultimate future of app delivery? - -### Event-driven computing - -Many see serverless computing as an umbrella that offers FaaS among many other potential services. According to CNCF, FaaS provides event-driven computing where functions are triggered by events or HTTP requests. “Developers run and manage application code with functions that are triggered by events or HTTP requests. Developers deploy small units of code to the FaaS, which are executed as needed as discrete actions, scaling without the need to manage servers or any other underlying infrastructure,” said the white paper. - -Does that mean FaaS is the silver bullet that solves all problems for developing and deploying applications? Not really. At least not at the moment. FaaS does solve problems in several use cases and its scope is expanding. A good use case of FaaS could be the functions that an application needs to run when an event takes place. - -Let’s take an example: a user takes a picture from a phone and uploads it to the cloud. Many things happen when the picture is uploaded - it’s scanned (exif data is read), a thumbnail is created, based on deep learning/machine learning the content of the image is analyzed, the information of the image is stored in the database. That one event of uploading that picture triggers all those functions. Those functions die once the event is over. That’s what FaaS does. It runs code quickly to perform all those tasks and then disappears. - -That’s just one example. Another example could be an IoT device where a motion sensor triggers an event that instructs the camera to start recording and sends the clip to the designated contant. Your thermostat may trigger the fan when the sensor detects a change in temperature. These are some of the many use cases where function as a service make more sense than the traditional approach. Which also says that not all applications (at least at the moment, but that will change as more organizations embrace the serverless platform) can be run as function as service. - -According to CNCF, serverless computing should be considered if you have these kinds of workloads: - - * Asynchronous, concurrent, easy to parallelize into independent units of work - - * Infrequent or has sporadic demand, with large, unpredictable variance in scaling requirements - - * Stateless, ephemeral, without a major need for instantaneous cold start time - - * Highly dynamic in terms of changing business requirements that drive a need for accelerated developer velocity - - - - -### Why should you care? - -Serverless is a very new technology and paradigm, just the way VMs and containers transformed the app development and delivery models, FaaS can also bring dramatic changes. We are still in the early days of serverless computing. As the market evolves, consensus is created and new technologies evolve, and FaaS may grow beyond the workloads and use cases mentioned here. - -What is becoming quite clear is that companies who are embarking on their cloud native journey must have serverless computing as part of their strategy. The only way to stay ahead of competitors is by keeping up with the latest technologies and trends. - -It’s about time to put serverless into servers. - -For more information, check out the CNCF Working Group's serverless whitepaper [here][2]. And, you can learn more at [KubeCon + CloudNativeCon Europe][4], coming up May 2-4 in Copenhagen, Denmark. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/2018/4/theres-server-every-serverless-platform - -作者:[SWAPNIL BHARTIYA][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/arnieswap -[1]:https://www.cncf.io/ -[2]:https://github.com/cncf/wg-serverless/blob/master/whitepaper/cncf_serverless_whitepaper_v1.0.pdf -[3]:https://www.cncf.io/blog/2018/02/14/cncf-takes-first-step-towards-serverless-computing/ -[4]:https://events.linuxfoundation.org/events/kubecon-cloudnativecon-europe-2018/attend/register/ diff --git a/sources/talk/20180511 Looking at the Lispy side of Perl.md b/sources/talk/20180511 Looking at the Lispy side of Perl.md deleted file mode 100644 index 1fa51b314c..0000000000 --- a/sources/talk/20180511 Looking at the Lispy side of Perl.md +++ /dev/null @@ -1,357 +0,0 @@ -Looking at the Lispy side of Perl -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus_cloud_database.png?itok=lhhU42fg) -Some programming languages (e.g., C) have named functions only, whereas others (e.g., Lisp, Java, and Perl) have both named and unnamed functions. A lambda is an unnamed function, with Lisp as the language that popularized the term. Lambdas have various uses, but they are particularly well-suited for data-rich applications. Consider this depiction of a data pipeline, with two processing stages shown: - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/data_source.png?itok=OON2cC2R) - -### Lambdas and higher-order functions - -The filter and transform stages can be implemented as higher-order functions—that is, functions that can take a function as an argument. Suppose that the depicted pipeline is part of an accounts-receivable application. The filter stage could consist of a function named `filter_data`, whose single argument is another function—for example, a `high_buyers` function that filters out amounts that fall below a threshold. The transform stage might convert amounts in U.S. dollars to equivalent amounts in euros or some other currency, depending on the function plugged in as the argument to the higher-order `transform_data` function. Changing the filter or the transform behavior requires only plugging in a different function argument to the higher order `filter_data` or `transform_data` functions. - -Lambdas serve nicely as arguments to higher-order functions for two reasons. First, lambdas can be crafted on the fly, and even written in place as arguments. Second, lambdas encourage the coding of pure functions, which are functions whose behavior depends solely on the argument(s) passed in; such functions have no side effects and thereby promote safe concurrent programs. - -Perl has a straightforward syntax and semantics for lambdas and higher-order functions, as shown in the following example: - -### A first look at lambdas in Perl - -``` -#!/usr/bin/perl - -use strict; -use warnings; - -## References to lambdas that increment, decrement, and do nothing. -## $_[0] is the argument passed to each lambda. -my $inc = sub { $_[0] + 1 };  ## could use 'return $_[0] + 1' for clarity -my $dec = sub { $_[0] - 1 };  ## ditto -my $nop = sub { $_[0] };      ## ditto - -sub trace { -    my ($val, $func, @rest) = @_; -    print $val, " ", $func, " ", @rest, "\nHit RETURN to continue...\n"; -    <STDIN>; -} - -## Apply an operation to a value. The base case occurs when there are -## no further operations in the list named @rest. -sub apply { -    my ($val, $first, @rest) = @_; -    trace($val, $first, @rest) if 1;  ## 0 to stop tracing - -    return ($val, apply($first->($val), @rest)) if @rest; ## recursive case -    return ($val, $first->($val));                        ## base case -} - -my $init_val = 0; -my @ops = (                        ## list of lambda references -    $inc, $dec, $dec, $inc, -    $inc, $inc, $inc, $dec, -    $nop, $dec, $dec, $nop, -    $nop, $inc, $inc, $nop -    ); - -## Execute. -print join(' ', apply($init_val, @ops)), "\n"; -## Final line of output: 0 1 0 -1 0 1 2 3 2 2 1 0 0 0 1 2 2strictwarningstraceSTDINapplytraceapplyapply -``` - -The lispy program shown above highlights the basics of Perl lambdas and higher-order functions. Named functions in Perl start with the keyword `sub` followed by a name: -``` -sub increment { ... }   # named function - -``` - -An unnamed or anonymous function omits the name: -``` -sub {...}               # lambda, or unnamed function - -``` - -In the lispy example, there are three lambdas, and each has a reference to it for convenience. Here, for review, is the `$inc` reference and the lambda referred to: -``` -my $inc = sub { $_[0] + 1 }; - -``` - -The lambda itself, the code block to the right of the assignment operator `=`, increments its argument `$_[0]` by 1. The lambda’s body is written in Lisp style; that is, without either an explicit `return` or a semicolon after the incrementing expression. In Perl, as in Lisp, the value of the last expression in a function’s body becomes the returned value if there is no explicit `return` statement. In this example, each lambda has only one expression in its body—a simplification that befits the spirit of lambda programming. - -The `trace` function in the lispy program helps to clarify how the program works (as I'll illustrate below). The higher-order function `apply`, a nod to a Lisp function of the same name, takes a numeric value as its first argument and a list of lambda references as its second argument. The `apply` function is called initially, at the bottom of the program, with zero as the first argument and the list named `@ops` as the second argument. This list consists of 16 lambda references from among `$inc` (increment a value), `$dec` (decrement a value), and `$nop` (do nothing). The list could contain the lambdas themselves, but the code is easier to write and to understand with the more concise lambda references. - -The logic of the higher-order `apply` function can be clarified as follows: - - 1. The argument list passed to `apply` in typical Perl fashion is separated into three pieces: -``` -my ($val, $first, @rest) = @_; ## break the argument list into three elements - -``` - -The first element `$val` is a numeric value, initially `0`. The second element `$first` is a lambda reference, one of `$inc` `$dec`, or `$nop`. The third element `@rest` is a list of any remaining lambda references after the first such reference is extracted as `$first`. - - 2. If the list `@rest` is not empty after its first element is removed, then `apply` is called recursively. The two arguments to the recursively invoked `apply` are: - - * The value generated by applying lambda operation `$first` to numeric value `$val`. For example, if `$first` is the incrementing lambda to which `$inc` refers, and `$val` is 2, then the new first argument to `apply` would be 3. - * The list of remaining lambda references. Eventually, this list becomes empty because each call to `apply` shortens the list by extracting its first element. - - - -Here is some output from a sample run of the lispy program, with `%` as the command-line prompt: -``` -% ./lispy.pl - -0 CODE(0x8f6820) CODE(0x8f68c8)CODE(0x8f68c8)CODE(0x8f6820)CODE(0x8f6820)CODE(0x8f6820)... -Hit RETURN to continue... - -1 CODE(0x8f68c8) CODE(0x8f68c8)CODE(0x8f6820)CODE(0x8f6820)CODE(0x8f6820)CODE(0x8f6820)... -Hit RETURN to continue -``` - -The first output line can be clarified as follows: - - * The `0` is the numeric value passed as an argument in the initial (and thus non-recursive) call to function `apply`. The argument name is `$val` in `apply`. - * The `CODE(0x8f6820)` is a reference to one of the lambdas, in this case the lambda to which `$inc` refers. The second argument is thus the address of some lambda code. The argument name is `$first` in `apply` - * The third piece, the series of `CODE` references, is the list of lambda references beyond the first. The argument name is `@rest` in `apply`. - - - -The second line of output shown above also deserves a look. The numeric value is now `1`, the result of incrementing `0`: the initial lambda is `$inc` and the initial value is `0`. The extracted reference `CODE(0x8f68c8)` is now `$first`, as this reference is the first element in the `@rest` list after `$inc` has been extracted earlier. - -Eventually, the `@rest` list becomes empty, which ends the recursive calls to `apply`. In this case, the function `apply` simply returns a list with two elements: - - 1. The numeric value taken in as an argument (in the sample run, 2). - 2. This argument transformed by the lambda (also 2 because the last lambda reference happens to be `$nop` for do nothing). - - - -The lispy example underscores that Perl supports lambdas without any special fussy syntax: A lambda is just an unnamed code block, perhaps with a reference to it for convenience. Lambdas themselves, or references to them, can be passed straightforwardly as arguments to higher-order functions such as `apply` in the lispy example. Invoking a lambda through a reference is likewise straightforward. In the `apply` function, the call is: -``` -$first->($val)    ## $first is a lambda reference, $val a numeric argument passed to the lambda - -``` - -### A richer code example - -The next code example puts a lambda and a higher-order function to practical use. The example implements Conway’s Game of Life, a cellular automaton that can be represented as a matrix of cells. Such a matrix goes through various transformations, each yielding a new generation of cells. The Game of Life is fascinating because even relatively simple initial configurations can lead to quite complex behavior. A quick look at the rules governing cell birth, survival, and death is in order. - -Consider this 5x5 matrix, with a star representing a live cell and a dash representing a dead one: -``` - -----              ## initial configuration - --*-- - --*-- - --*-- - ----- -``` - -The next generation becomes: -``` - -----              ## next generation - ----- - -***- - ---- - ----- -``` - -As life continues, the generations oscillate between these two configurations. - -Here are the rules determining birth, death, and survival for a cell. A given cell has between three neighbors (a corner cell) and eight neighbors (an interior cell): - - * A dead cell with exactly three live neighbors comes to life. - * A live cell with more than three live neighbors dies from over-crowding. - * A live cell with two or three live neighbors survives; hence, a live cell with fewer than two live neighbors dies from loneliness. - - - -In the initial configuration shown above, the top and bottom live cells die because neither has two or three live neighbors. By contrast, the middle live cell in the initial configuration gains two live neighbors, one on either side, in the next generation. - -## Conway’s Game of Life -``` -#!/usr/bin/perl - -### A simple implementation of Conway's game of life. -# Usage: ./gol.pl [input file]  ;; If no file name given, DefaultInfile is used. - -use constant Dead  => "-"; -use constant Alive => "*"; -use constant DefaultInfile => 'conway.in'; - -use strict; -use warnings; - -my $dimension = undef; -my @matrix = (); -my $generation = 1; - -sub read_data { -    my $datafile = DefaultInfile; -    $datafile = shift @ARGV if @ARGV; -    die "File $datafile does not exist.\n" if !-f $datafile; -    open(INFILE, "<$datafile"); - -    ## Check 1st line for dimension; -    $dimension = <INFILE>; -    die "1st line of input file $datafile not an integer.\n" if $dimension !~ /\d+/; - -    my $record_count = 0; -    while (<INFILE>) { -        chomp($_); -        last if $record_count++ == $dimension; -        die "$_: bad input record -- incorrect length\n" if length($_) != $dimension; -        my @cells = split(//, $_); -        push @matrix, @cells; -    } -    close(INFILE); -    draw_matrix(); -} - -sub draw_matrix { -    my $n = $dimension * $dimension; -    print "\n\tGeneration $generation\n"; -    for (my $i = 0; $i < $n; $i++) { -        print "\n\t" if ($i % $dimension) == 0; -        print $matrix[$i]; -    } -    print "\n\n"; -    $generation++; -} - -sub has_left_neighbor { -    my ($ind) = @_; -    return ($ind % $dimension) != 0; -} - -sub has_right_neighbor { -    my ($ind) = @_; -    return (($ind + 1) % $dimension) != 0; -} - -sub has_up_neighbor { -    my ($ind) = @_; -    return (int($ind / $dimension)) != 0; -} - -sub has_down_neighbor { -    my ($ind) = @_; -    return (int($ind / $dimension) + 1) != $dimension; -} - -sub has_left_up_neighbor { -    my ($ind) = @_; -    ($ind) && has_up_neighbor($ind); -} - -sub has_right_up_neighbor { -    my ($ind) = @_; -    ($ind) && has_up_neighbor($ind); -} - -sub has_left_down_neighbor { -    my ($ind) = @_; -    ($ind) && has_down_neighbor($ind); -} - -sub has_right_down_neighbor { -    my ($ind) = @_; -    ($ind) && has_down_neighbor($ind); -} - -sub compute_cell { -    my ($ind) = @_; -    my @neighbors; - -    # 8 possible neighbors -    push(@neighbors, $ind - 1) if has_left_neighbor($ind); -    push(@neighbors, $ind + 1) if has_right_neighbor($ind); -    push(@neighbors, $ind - $dimension) if has_up_neighbor($ind); -    push(@neighbors, $ind + $dimension) if has_down_neighbor($ind); -    push(@neighbors, $ind - $dimension - 1) if has_left_up_neighbor($ind); -    push(@neighbors, $ind - $dimension + 1) if has_right_up_neighbor($ind); -    push(@neighbors, $ind + $dimension - 1) if has_left_down_neighbor($ind); -    push(@neighbors, $ind + $dimension + 1) if has_right_down_neighbor($ind); - -    my $count = 0; -    foreach my $n (@neighbors) { -        $count++ if $matrix[$n] eq Alive; -    } - -    if ($matrix[$ind] eq Alive) && (($count == 2) || ($count == 3)); ## survival -    if ($matrix[$ind] eq Dead)  && ($count == 3);                    ## birth -    ;                                                                  ## death -} - -sub again_or_quit { -    print "RETURN to continue, 'q' to quit.\n"; -    my $flag = <STDIN>; -    chomp($flag); -    return ($flag eq 'q') ? 1 : 0; -} - -sub animate { -    my @new_matrix; -    my $n = $dimension * $dimension - 1; - -    while (1) {                                       ## loop until user signals stop -        @new_matrix = map {compute_cell($_)} (0..$n); ## generate next matrix - -        splice @matrix;                               ## empty current matrix -        push @matrix, @new_matrix;                    ## repopulate matrix -        draw_matrix();                                ## display the current matrix - -        last if again_or_quit();                      ## continue? -        splice @new_matrix;                           ## empty temp matrix -    } -} - -### Execute -read_data();  ## read initial configuration from input file -animate();    ## display and recompute the matrix until user tires -``` - -The gol program (see [Conway’s Game of Life][1]) has almost 140 lines of code, but most of these involve reading the input file, displaying the matrix, and bookkeeping tasks such as determining the number of live neighbors for a given cell. Input files should be configured as follows: -``` - 5 - ----- - --*-- - --*-- - --*-- - ----- -``` - -The first record gives the matrix side, in this case 5 for a 5x5 matrix. The remaining rows are the contents, with stars for live cells and spaces for dead ones. - -The code of primary interest resides in two functions, `animate` and `compute_cell`. The `animate` function constructs the next generation, and this function needs to call `compute_cell` on every cell in order to determine the cell’s new status as either alive or dead. How should the `animate` function be structured? - -The `animate` function has a `while` loop that iterates until the user decides to terminate the program. Within this `while` loop the high-level logic is straightforward: - - 1. Create the next generation by iterating over the matrix cells, calling function `compute_cell` on each cell to determine its new status. At issue is how best to do the iteration. A loop nested inside the `while `loop would do, of course, but nested loops can be clunky. Another way is to use a higher-order function, as clarified shortly. - 2. Replace the current matrix with the new one. - 3. Display the next generation. - 4. Check if the user wants to continue: if so, continue; otherwise, terminate. - - - -Here, for review, is the call to Perl’s higher-order `map` function, with the function’s name again a nod to Lisp. This call occurs as the first statement within the `while` loop in `animate`: -``` -while (1) { -    @new_matrix = map {compute_cell($_)} (0..$n); ## generate next matrixcompute_cell -``` - -The `map` function takes two arguments: an unnamed code block (a lambda!), and a list of values passed to this code block one at a time. In this example, the code block calls the `compute_cell` function with one of the matrix indexes, 0 through the matrix size - 1. Although the matrix is displayed as two-dimensional, it is implemented as a one-dimensional list. - -Higher-order functions such as `map` encourage the code brevity for which Perl is famous. My view is that such functions also make code easier to write and to understand, as they dispense with the required but messy details of loops. In any case, lambdas and higher-order functions make up the Lispy side of Perl. - -If you're interested in more detail, I recommend Mark Jason Dominus's book, [Higher-Order Perl][2]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/5/looking-lispy-side-perl - -作者:[Marty Kalin][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/mkalindepauledu -[1]:https://trello-attachments.s3.amazonaws.com/575088ec94ca6ac38b49b30e/5ad4daf12f6b6a3ac2318d28/c0700c7379983ddf61f5ab5ab4891f0c/lispyPerl.html#gol (Conway’s Game of Life) -[2]:https://www.elsevier.com/books/higher-order-perl/dominus/978-1-55860-701-9 diff --git a/sources/talk/20180527 Whatever Happened to the Semantic Web.md b/sources/talk/20180527 Whatever Happened to the Semantic Web.md deleted file mode 100644 index 22d48c150a..0000000000 --- a/sources/talk/20180527 Whatever Happened to the Semantic Web.md +++ /dev/null @@ -1,106 +0,0 @@ -Whatever Happened to the Semantic Web? -====== -In 2001, Tim Berners-Lee, inventor of the World Wide Web, published an article in Scientific American. Berners-Lee, along with two other researchers, Ora Lassila and James Hendler, wanted to give the world a preview of the revolutionary new changes they saw coming to the web. Since its introduction only a decade before, the web had fast become the world’s best means for sharing documents with other people. Now, the authors promised, the web would evolve to encompass not just documents but every kind of data one could imagine. - -They called this new web the Semantic Web. The great promise of the Semantic Web was that it would be readable not just by humans but also by machines. Pages on the web would be meaningful to software programs—they would have semantics—allowing programs to interact with the web the same way that people do. Programs could exchange data across the Semantic Web without having to be explicitly engineered to talk to each other. According to Berners-Lee, Lassila, and Hendler, a typical day living with the myriad conveniences of the Semantic Web might look something like this: - -> The entertainment system was belting out the Beatles’ “We Can Work It Out” when the phone rang. When Pete answered, his phone turned the sound down by sending a message to all the other local devices that had a volume control. His sister, Lucy, was on the line from the doctor’s office: “Mom needs to see a specialist and then has to have a series of physical therapy sessions. Biweekly or something. I’m going to have my agent set up the appointments.” Pete immediately agreed to share the chauffeuring. At the doctor’s office, Lucy instructed her Semantic Web agent through her handheld Web browser. The agent promptly retrieved the information about Mom’s prescribed treatment within a 20-mile radius of her home and with a rating of excellent or very good on trusted rating services. It then began trying to find a match between available appointment times (supplied by the agents of individual providers through their Web sites) and Pete’s and Lucy’s busy schedules. - -The vision was that the Semantic Web would become a playground for intelligent “agents.” These agents would automate much of the work that the world had only just learned to do on the web. - -![][1] - -For a while, this vision enticed a lot of people. After new technologies such as AJAX led to the rise of what Silicon Valley called Web 2.0, Berners-Lee began referring to the Semantic Web as Web 3.0. Many thought that the Semantic Web was indeed the inevitable next step. A New York Times article published in 2006 quotes a speech Berners-Lee gave at a conference in which he said that the extant web would, twenty years in the future, be seen as only the “embryonic” form of something far greater. A venture capitalist, also quoted in the article, claimed that the Semantic Web would be “profound,” and ultimately “as obvious as the web seems obvious to us today.” - -Of course, the Semantic Web we were promised has yet to be delivered. In 2018, we have “agents” like Siri that can do certain tasks for us. But Siri can only do what it can because engineers at Apple have manually hooked it up to a medley of web services each capable of answering only a narrow category of questions. An important consequence is that, without being large and important enough for Apple to care, you cannot advertise your services directly to Siri from your own website. Unlike the physical therapists that Berners-Lee and his co-authors imagined would be able to hang out their shingles on the web, today we are stuck with giant, centralized repositories of information. Today’s physical therapists must enter information about their practice into Google or Yelp, because those are the only services that the smartphone agents know how to use and the only ones human beings will bother to check. The key difference between our current reality and the promised Semantic future is best captured by this throwaway aside in the excerpt above: “…appointment times (supplied by the agents of individual providers through **their** Web sites)…” - -In fact, over the last decade, the web has not only failed to become the Semantic Web but also threatened to recede as an idea altogether. We now hardly ever talk about “the web” and instead talk about “the internet,” which as of 2016 has become such a common term that newspapers no longer capitalize it. (To be fair, they stopped capitalizing “web” too.) Some might still protest that the web and the internet are two different things, but the distinction gets less clear all the time. The web we have today is slowly becoming a glorified app store, just the easiest way among many to download software that communicates with distant servers using closed protocols and schemas, making it functionally identical to the software ecosystem that existed before the web. How did we get here? If the effort to build a Semantic Web had succeeded, would the web have looked different today? Or have there been so many forces working against a decentralized web for so long that the Semantic Web was always going to be stillborn? - -### Semweb Hucksters and Their Metacrap - -To some more practically minded engineers, the Semantic Web was, from the outset, a utopian dream. - -The basic idea behind the Semantic Web was that everyone would use a new set of standards to annotate their webpages with little bits of XML. These little bits of XML would have no effect on the presentation of the webpage, but they could be read by software programs to divine meaning that otherwise would only be available to humans. - -The bits of XML were a way of expressing metadata about the webpage. We are all familiar with metadata in the context of a file system: When we look at a file on our computers, we can see when it was created, when it was last updated, and whom it was originally created by. Likewise, webpages on the Semantic Web would be able to tell your browser who authored the page and perhaps even where that person went to school, or where that person is currently employed. In theory, this information would allow Semantic Web browsers to answer queries across a large collection of webpages. In their article for Scientific American, Berners-Lee and his co-authors explain that you could, for example, use the Semantic Web to look up a person you met at a conference whose name you only partially remember. - -Cory Doctorow, a blogger and digital rights activist, published an influential essay in 2001 that pointed out the many problems with depending on voluntarily supplied metadata. A world of “exhaustive, reliable” metadata would be wonderful, he argued, but such a world was “a pipe-dream, founded on self-delusion, nerd hubris, and hysterically inflated market opportunities.” Doctorow had found himself in a series of debates over the Semantic Web at tech conferences and wanted to catalog the serious issues that the Semantic Web enthusiasts (Doctorow calls them “semweb hucksters”) were overlooking. The essay, titled “Metacrap,” identifies seven problems, among them the obvious fact that most web users were likely to provide either no metadata at all or else lots of misleading metadata meant to draw clicks. Even if users were universally diligent and well-intentioned, in order for the metadata to be robust and reliable, users would all have to agree on a single representation for each important concept. Doctorow argued that in some cases a single representation might not be appropriate, desirable, or fair to all users. - -Indeed, the web had already seen people abusing the HTML `` tag (introduced at least as early as HTML 4) in an attempt to improve the visibility of their webpages in search results. In a 2004 paper, Ben Munat, then an academic at Evergreen State College, explains how search engines once experimented with using keywords supplied via the `` tag to index results, but soon discovered that unscrupulous webpage authors were including tags unrelated to the actual content of their webpage. As a result, search engines came to ignore the `` tag in favor of using complex algorithms to analyze the actual content of a webpage. Munat concludes that a general-purpose Semantic Web is unworkable, and that the focus should be on specific domains within medicine and science. - -Others have also seen the Semantic Web project as tragically flawed, though they have located the flaw elsewhere. Aaron Swartz, the famous programmer and another digital rights activist, wrote in an unfinished book about the Semantic Web published after his death that Doctorow was “attacking a strawman.” Nobody expected that metadata on the web would be thoroughly accurate and reliable, but the Semantic Web, or at least a more realistically scoped version of it, remained possible. The problem, in Swartz’ view, was the “formalizing mindset of mathematics and the institutional structure of academics” that the “semantic Webheads” brought to bear on the challenge. In forums like the World Wide Web Consortium (W3C), a huge amount of effort and discussion went into creating standards before there were any applications out there to standardize. And the standards that emerged from these “Talmudic debates” were so abstract that few of them ever saw widespread adoption. The few that did, like XML, were “uniformly scourges on the planet, offenses against hardworking programmers that have pushed out sensible formats (like JSON) in favor of overly-complicated hairballs with no basis in reality.” The Semantic Web might have thrived if, like the original web, its standards were eagerly adopted by everyone. But that never happened because—as [has been discussed][2] on this blog before—the putative benefits of something like XML are not easy to sell to a programmer when the alternatives are both entirely sufficient and much easier to understand. - -### Building the Semantic Web - -If the Semantic Web was not an outright impossibility, it was always going to require the contributions of lots of clever people working in concert. - -The long effort to build the Semantic Web has been said to consist of four phases. The first phase, which lasted from 2001 to 2005, was the golden age of Semantic Web activity. Between 2001 and 2005, the W3C issued a slew of new standards laying out the foundational technologies of the Semantic future. - -The most important of these was the Resource Description Framework (RDF). The W3C issued the first version of the RDF standard in 2004, but RDF had been floating around since 1997, when a W3C working group introduced it in a draft specification. RDF was originally conceived of as a tool for modeling metadata and was partly based on earlier attempts by Ramanathan Guha, an Apple engineer, to develop a metadata system for files stored on Apple computers. The Semantic Web working groups at W3C repurposed RDF to represent arbitrary kinds of general knowledge. - -RDF would be the grammar in which Semantic webpages expressed information. The grammar is a simple one: Facts about the world are expressed in RDF as triplets of subject, predicate, and object. Tim Bray, who worked with Ramanathan Guha on an early version of RDF, gives the following example, describing TV shows and movies: - -``` -@prefix rdf: . - -@prefix ex: . - - -ex:vincent_donofrio ex:starred_in ex:law_and_order_ci . - -ex:law_and_order_ci rdf:type ex:tv_show . - -ex:the_thirteenth_floor ex:similar_plot_as ex:the_matrix . -``` - -The syntax is not important, especially since RDF can be represented in a number of formats, including XML and JSON. This example is in a format called Turtle, which expresses RDF triplets as straightforward sentences terminated by periods. The three essential sentences, which appear above after the `@prefix` preamble, state three facts: Vincent Donofrio starred in Law and Order, Law and Order is a type of TV Show, and the movie The Thirteenth Floor has a similar plot as The Matrix. (If you don’t know who Vincent Donofrio is and have never seen The Thirteenth Floor, I, too, was watching Nickelodeon and sipping Capri Suns in 1999.) - -Other specifications finalized and drafted during this first era of Semantic Web development describe all the ways in which RDF can be used. RDF in Attributes (RDFa) defines how RDF can be embedded in HTML so that browsers, search engines, and other programs can glean meaning from a webpage. RDF Schema and another standard called OWL allows RDF authors to demarcate the boundary between valid and invalid RDF statements in their RDF documents. RDF Schema and OWL, in other words, are tools for creating what are known as ontologies, explicit specifications of what can and cannot be said within a specific domain. An ontology might include a rule, for example, expressing that no person can be the mother of another person without also being a parent of that person. The hope was that these ontologies would be widely used not only to check the accuracy of RDF found in the wild but also to make inferences about omitted information. - -In 2006, Tim Berners-Lee posted a short article in which he argued that the existing work on Semantic Web standards needed to be supplemented by a concerted effort to make semantic data available on the web. Furthermore, once on the web, it was important that semantic data link to other kinds of semantic data, ensuring the rise of a data-based web as interconnected as the existing web. Berners-Lee used the term “linked data” to describe this ideal scenario. Though “linked data” was in one sense just a recapitulation of the original vision for the Semantic Web, it became a term that people could rally around and thus amounted to a rebranding of the Semantic Web project. - -Berners-Lee’s article launched the second phase of the Semantic Web’s development, where the focus shifted from setting standards and building toy examples to creating and popularizing large RDF datasets. Perhaps the most successful of these datasets was [DBpedia][3], a giant repository of RDF triplets extracted from Wikipedia articles. DBpedia, which made heavy use of the Semantic Web standards that had been developed in the first half of the 2000s, was a standout example of what could be accomplished using the W3C’s new formats. Today DBpedia describes 4.58 million entities and is used by organizations like the NY Times, BBC, and IBM, which employed DBpedia as a knowledge source for IBM Watson, the Jeopardy-winning artificial intelligence system. - -![][4] - -The third phase of the Semantic Web’s development involved adapting the W3C’s standards to fit the actual practices and preferences of web developers. By 2008, JSON had begun its meteoric rise to popularity. Whereas XML came packaged with a bunch of associated technologies of indeterminate purpose (XLST, XPath, XQuery, XLink), JSON was just JSON. It was less verbose and more readable. Manu Sporny, an entrepreneur and member of the W3C, had already started using JSON at his company and wanted to find an easy way for RDFa and JSON to work together. The result would be JSON-LD, which in essence was RDF reimagined for a world that had chosen JSON over XML. Sporny, together with his CTO, Dave Longley, issued a draft specification of JSON-LD in 2010. For the next few years, JSON-LD and an updated RDF specification would be the primary focus of Semantic Web work at the W3C. JSON-LD could be used on its own or it could be embedded within a `